fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / unoobj / fielduno.cxx
blob94c29dcc50dd3dbb45f4c04b7c3ba3bf5d6a26ef
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "fielduno.hxx"
21 #include "textuno.hxx"
22 #include "miscuno.hxx"
23 #include "docsh.hxx"
24 #include "hints.hxx"
25 #include "editsrc.hxx"
26 #include "cellsuno.hxx"
27 #include "servuno.hxx"
28 #include "unonames.hxx"
29 #include "editutil.hxx"
31 #include <svl/smplhint.hxx>
32 #include <vcl/svapp.hxx>
34 #include <editeng/eeitem.hxx>
36 #include <editeng/editeng.hxx>
37 #include <editeng/editobj.hxx>
38 #include <editeng/flditem.hxx>
39 #include <comphelper/servicehelper.hxx>
40 #include <cppuhelper/supportsservice.hxx>
42 #include <com/sun/star/beans/PropertyAttribute.hpp>
43 #include <com/sun/star/text/TextContentAnchorType.hpp>
44 #include <com/sun/star/text/WrapTextMode.hpp>
45 #include <com/sun/star/text/FilenameDisplayFormat.hpp>
46 #include <com/sun/star/text/textfield/Type.hpp>
48 using namespace com::sun::star;
50 namespace {
52 // alles ohne Which-ID, Map nur fuer PropertySetInfo
54 const SfxItemPropertySet* getDateTimePropertySet()
56 static const SfxItemPropertyMapEntry aMapContent[] =
58 { OUString(SC_UNONAME_DATETIME), 0, cppu::UnoType<util::DateTime>::get(), 0, 0 },
59 { OUString(SC_UNONAME_ISFIXED), 0, cppu::UnoType<bool>::get(), 0, 0 },
60 { OUString(SC_UNONAME_ISDATE), 0, cppu::UnoType<bool>::get(), 0, 0 },
61 { OUString(SC_UNONAME_NUMFMT), 0, cppu::UnoType<sal_Int32>::get(), 0, 0 },
62 { OUString(), 0, css::uno::Type(), 0, 0 }
64 static SfxItemPropertySet aMap(aMapContent);
65 return &aMap;
68 const SfxItemPropertySet* getEmptyPropertySet()
70 static const SfxItemPropertyMapEntry aMapContent[] =
72 { OUString(), 0, css::uno::Type(), 0, 0 }
74 static SfxItemPropertySet aMap(aMapContent);
75 return &aMap;
78 const SfxItemPropertySet* lcl_GetURLPropertySet()
80 static const SfxItemPropertyMapEntry aURLPropertyMap_Impl[] =
82 {OUString(SC_UNONAME_ANCTYPE), 0, cppu::UnoType<text::TextContentAnchorType>::get(), beans::PropertyAttribute::READONLY, 0 },
83 {OUString(SC_UNONAME_ANCTYPES), 0, cppu::UnoType<uno::Sequence<text::TextContentAnchorType>>::get(), beans::PropertyAttribute::READONLY, 0 },
84 {OUString(SC_UNONAME_REPR), 0, cppu::UnoType<OUString>::get(), 0, 0},
85 {OUString(SC_UNONAME_TARGET), 0, cppu::UnoType<OUString>::get(), 0, 0},
86 {OUString(SC_UNONAME_TEXTWRAP), 0, cppu::UnoType<text::WrapTextMode>::get(), beans::PropertyAttribute::READONLY, 0 },
87 {OUString(SC_UNONAME_URL), 0, cppu::UnoType<OUString>::get(), 0, 0},
88 { OUString(), 0, css::uno::Type(), 0, 0 }
90 static SfxItemPropertySet aURLPropertySet_Impl( aURLPropertyMap_Impl );
91 return &aURLPropertySet_Impl;
94 const SfxItemPropertySet* lcl_GetHeaderFieldPropertySet()
96 static const SfxItemPropertyMapEntry aHeaderFieldPropertyMap_Impl[] =
98 {OUString(SC_UNONAME_ANCTYPE), 0, cppu::UnoType<text::TextContentAnchorType>::get(), beans::PropertyAttribute::READONLY, 0 },
99 {OUString(SC_UNONAME_ANCTYPES), 0, cppu::UnoType<uno::Sequence<text::TextContentAnchorType>>::get(), beans::PropertyAttribute::READONLY, 0 },
100 {OUString(SC_UNONAME_TEXTWRAP), 0, cppu::UnoType<text::WrapTextMode>::get(), beans::PropertyAttribute::READONLY, 0 },
101 { OUString(), 0, css::uno::Type(), 0, 0 }
103 static SfxItemPropertySet aHeaderFieldPropertySet_Impl( aHeaderFieldPropertyMap_Impl );
104 return &aHeaderFieldPropertySet_Impl;
107 const SfxItemPropertySet* lcl_GetFileFieldPropertySet()
109 static const SfxItemPropertyMapEntry aFileFieldPropertyMap_Impl[] =
111 {OUString(SC_UNONAME_ANCTYPE), 0, cppu::UnoType<text::TextContentAnchorType>::get(), beans::PropertyAttribute::READONLY, 0 },
112 {OUString(SC_UNONAME_ANCTYPES), 0, cppu::UnoType<uno::Sequence<text::TextContentAnchorType>>::get(), beans::PropertyAttribute::READONLY, 0 },
113 {OUString(SC_UNONAME_FILEFORM), 0, cppu::UnoType<sal_Int16>::get(), 0, 0 },
114 {OUString(SC_UNONAME_TEXTWRAP), 0, cppu::UnoType<text::WrapTextMode>::get(), beans::PropertyAttribute::READONLY, 0 },
115 { OUString(), 0, css::uno::Type(), 0, 0 }
117 static SfxItemPropertySet aFileFieldPropertySet_Impl( aFileFieldPropertyMap_Impl );
118 return &aFileFieldPropertySet_Impl;
121 SvxFileFormat lcl_UnoToSvxFileFormat( sal_Int16 nUnoValue )
123 switch( nUnoValue )
125 case text::FilenameDisplayFormat::FULL: return SVXFILEFORMAT_FULLPATH;
126 case text::FilenameDisplayFormat::PATH: return SVXFILEFORMAT_PATH;
127 case text::FilenameDisplayFormat::NAME: return SVXFILEFORMAT_NAME;
128 default:
129 return SVXFILEFORMAT_NAME_EXT;
133 sal_Int16 lcl_SvxToUnoFileFormat( SvxFileFormat nSvxValue )
135 switch( nSvxValue )
137 case SVXFILEFORMAT_NAME_EXT: return text::FilenameDisplayFormat::NAME_AND_EXT;
138 case SVXFILEFORMAT_FULLPATH: return text::FilenameDisplayFormat::FULL;
139 case SVXFILEFORMAT_PATH: return text::FilenameDisplayFormat::PATH;
140 default:
141 return text::FilenameDisplayFormat::NAME;
147 SC_SIMPLE_SERVICE_INFO( ScCellFieldsObj, "ScCellFieldsObj", "com.sun.star.text.TextFields" )
148 SC_SIMPLE_SERVICE_INFO( ScHeaderFieldsObj, "ScHeaderFieldsObj", "com.sun.star.text.TextFields" )
150 // ScUnoEditEngine nur um aus einer EditEngine die Felder herauszubekommen...
152 enum ScUnoCollectMode
154 SC_UNO_COLLECT_NONE,
155 SC_UNO_COLLECT_COUNT,
156 SC_UNO_COLLECT_FINDINDEX,
157 SC_UNO_COLLECT_FINDPOS
161 * This class exists solely to allow searching through field items. TODO:
162 * Look into providing the same functionality directly in EditEngine, to
163 * avoid having this class altogether.
165 class ScUnoEditEngine : public ScEditEngineDefaulter
167 ScUnoCollectMode eMode;
168 sal_uInt16 nFieldCount;
169 sal_Int32 mnFieldType;
170 SvxFieldData* pFound; // lokale Kopie
171 sal_Int32 nFieldPar;
172 sal_Int32 nFieldPos;
173 sal_uInt16 nFieldIndex;
175 public:
176 ScUnoEditEngine(ScEditEngineDefaulter* pSource);
177 virtual ~ScUnoEditEngine();
179 virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos,
180 Color*& rTxtColor, Color*& rFldColor ) SAL_OVERRIDE;
182 sal_uInt16 CountFields();
183 SvxFieldData* FindByIndex(sal_uInt16 nIndex);
184 SvxFieldData* FindByPos(sal_Int32 nPar, sal_Int32 nPos, sal_Int32 nType);
186 sal_Int32 GetFieldPar() const { return nFieldPar; }
187 sal_Int32 GetFieldPos() const { return nFieldPos; }
190 ScUnoEditEngine::ScUnoEditEngine(ScEditEngineDefaulter* pSource)
191 : ScEditEngineDefaulter(*pSource)
192 , eMode(SC_UNO_COLLECT_NONE)
193 , nFieldCount(0)
194 , mnFieldType(text::textfield::Type::UNSPECIFIED)
195 , pFound(NULL)
196 , nFieldPar(0)
197 , nFieldPos(0)
198 , nFieldIndex(0)
200 EditTextObject* pData = pSource->CreateTextObject();
201 SetText( *pData );
202 delete pData;
205 ScUnoEditEngine::~ScUnoEditEngine()
207 delete pFound;
210 OUString ScUnoEditEngine::CalcFieldValue( const SvxFieldItem& rField,
211 sal_Int32 nPara, sal_Int32 nPos, Color*& rTxtColor, Color*& rFldColor )
213 OUString aRet(EditEngine::CalcFieldValue( rField, nPara, nPos, rTxtColor, rFldColor ));
214 if (eMode != SC_UNO_COLLECT_NONE)
216 const SvxFieldData* pFieldData = rField.GetField();
217 if ( pFieldData )
219 if (mnFieldType == text::textfield::Type::UNSPECIFIED || pFieldData->GetClassId() == mnFieldType)
221 if ( eMode == SC_UNO_COLLECT_FINDINDEX && !pFound && nFieldCount == nFieldIndex )
223 pFound = pFieldData->Clone();
224 nFieldPar = nPara;
225 nFieldPos = nPos;
227 if ( eMode == SC_UNO_COLLECT_FINDPOS && !pFound &&
228 nPara == nFieldPar && nPos == nFieldPos )
230 pFound = pFieldData->Clone();
231 nFieldIndex = nFieldCount;
233 ++nFieldCount;
237 return aRet;
240 sal_uInt16 ScUnoEditEngine::CountFields()
242 eMode = SC_UNO_COLLECT_COUNT;
243 mnFieldType = text::textfield::Type::UNSPECIFIED;
244 nFieldCount = 0;
245 UpdateFields();
246 eMode = SC_UNO_COLLECT_NONE;
248 return nFieldCount;
251 SvxFieldData* ScUnoEditEngine::FindByIndex(sal_uInt16 nIndex)
253 eMode = SC_UNO_COLLECT_FINDINDEX;
254 nFieldIndex = nIndex;
255 mnFieldType = text::textfield::Type::UNSPECIFIED;
256 nFieldCount = 0;
257 UpdateFields();
258 eMode = SC_UNO_COLLECT_NONE;
260 return pFound;
263 SvxFieldData* ScUnoEditEngine::FindByPos(sal_Int32 nPar, sal_Int32 nPos, sal_Int32 nType)
265 eMode = SC_UNO_COLLECT_FINDPOS;
266 nFieldPar = nPar;
267 nFieldPos = nPos;
268 mnFieldType = nType;
269 nFieldCount = 0;
270 UpdateFields();
271 mnFieldType = text::textfield::Type::UNSPECIFIED;
272 eMode = SC_UNO_COLLECT_NONE;
274 return pFound;
277 ScCellFieldsObj::ScCellFieldsObj(
278 const uno::Reference<text::XTextRange>& xContent,
279 ScDocShell* pDocSh, const ScAddress& rPos) :
280 mxContent(xContent),
281 pDocShell( pDocSh ),
282 aCellPos( rPos ),
283 mpRefreshListeners( NULL )
285 pDocShell->GetDocument().AddUnoObject(*this);
287 mpEditSource = new ScCellEditSource( pDocShell, aCellPos );
290 ScCellFieldsObj::~ScCellFieldsObj()
292 SolarMutexGuard g;
294 if (pDocShell)
295 pDocShell->GetDocument().RemoveUnoObject(*this);
297 delete mpEditSource;
299 // increment refcount to prevent double call off dtor
300 osl_atomic_increment( &m_refCount );
302 if (mpRefreshListeners)
304 lang::EventObject aEvent;
305 aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
306 if (mpRefreshListeners)
308 mpRefreshListeners->disposeAndClear(aEvent);
309 DELETEZ( mpRefreshListeners );
314 void ScCellFieldsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
316 if ( dynamic_cast<const ScUpdateRefHint*>(&rHint) )
318 //! Ref-Update
320 else if ( dynamic_cast<const SfxSimpleHint*>(&rHint) &&
321 static_cast<const SfxSimpleHint&>(rHint).GetId() == SFX_HINT_DYING )
323 pDocShell = NULL; // ungueltig geworden
326 // EditSource hat sich selber als Listener angemeldet
329 // XIndexAccess (via XTextFields)
331 uno::Reference<text::XTextField> ScCellFieldsObj::GetObjectByIndex_Impl(sal_Int32 Index) const
333 //! Feld-Funktionen muessen an den Forwarder !!!
334 ScEditEngineDefaulter* pEditEngine = mpEditSource->GetEditEngine();
335 ScUnoEditEngine aTempEngine(pEditEngine);
336 SvxFieldData* pData = aTempEngine.FindByIndex(static_cast<sal_uInt16>(Index));
337 if (!pData)
338 return uno::Reference<text::XTextField>();
340 sal_Int32 nPar = aTempEngine.GetFieldPar();
341 sal_Int32 nPos = aTempEngine.GetFieldPos();
342 ESelection aSelection( nPar, nPos, nPar, nPos+1 ); // Feld ist 1 Zeichen
344 sal_Int32 eType = pData->GetClassId();
345 uno::Reference<text::XTextField> xRet(
346 new ScEditFieldObj(mxContent, new ScCellEditSource(pDocShell, aCellPos), eType, aSelection));
347 return xRet;
350 sal_Int32 SAL_CALL ScCellFieldsObj::getCount() throw(uno::RuntimeException, std::exception)
352 SolarMutexGuard aGuard;
354 //! Feld-Funktionen muessen an den Forwarder !!!
355 ScEditEngineDefaulter* pEditEngine = mpEditSource->GetEditEngine();
356 ScUnoEditEngine aTempEngine(pEditEngine);
358 return aTempEngine.CountFields(); // Felder zaehlen, in Zelle ist der Typ egal
361 uno::Any SAL_CALL ScCellFieldsObj::getByIndex( sal_Int32 nIndex )
362 throw(lang::IndexOutOfBoundsException,
363 lang::WrappedTargetException, uno::RuntimeException, std::exception)
365 SolarMutexGuard aGuard;
366 uno::Reference<text::XTextField> xField(GetObjectByIndex_Impl(nIndex));
367 if (xField.is())
368 return uno::makeAny(xField);
369 else
370 throw lang::IndexOutOfBoundsException();
373 uno::Type SAL_CALL ScCellFieldsObj::getElementType() throw(uno::RuntimeException, std::exception)
375 SolarMutexGuard aGuard;
376 return cppu::UnoType<text::XTextField>::get();
379 sal_Bool SAL_CALL ScCellFieldsObj::hasElements() throw(uno::RuntimeException, std::exception)
381 SolarMutexGuard aGuard;
382 return ( getCount() != 0 );
385 uno::Reference<container::XEnumeration> SAL_CALL ScCellFieldsObj::createEnumeration()
386 throw(uno::RuntimeException, std::exception)
388 SolarMutexGuard aGuard;
389 return new ScIndexEnumeration(this, OUString("com.sun.star.text.TextFieldEnumeration"));
392 void SAL_CALL ScCellFieldsObj::addContainerListener(
393 const uno::Reference<container::XContainerListener>& /* xListener */ )
394 throw(uno::RuntimeException, std::exception)
396 OSL_FAIL("not implemented");
399 void SAL_CALL ScCellFieldsObj::removeContainerListener(
400 const uno::Reference<container::XContainerListener>& /* xListener */ )
401 throw(uno::RuntimeException, std::exception)
403 OSL_FAIL("not implemented");
406 // XRefreshable
407 void SAL_CALL ScCellFieldsObj::refresh( )
408 throw (uno::RuntimeException, std::exception)
410 if (mpRefreshListeners)
412 // Call all listeners.
413 uno::Sequence< uno::Reference< uno::XInterface > > aListeners(mpRefreshListeners->getElements());
414 sal_uInt32 nLength(aListeners.getLength());
415 if (nLength)
417 const uno::Reference< uno::XInterface >* pInterfaces = aListeners.getConstArray();
418 if (pInterfaces)
420 lang::EventObject aEvent;
421 aEvent.Source.set(uno::Reference< util::XRefreshable >(this));
422 sal_uInt32 i(0);
423 while (i < nLength)
427 while(i < nLength)
429 static_cast< util::XRefreshListener* >(pInterfaces->get())->refreshed(aEvent);
430 ++pInterfaces;
431 ++i;
434 catch(uno::RuntimeException&)
436 ++pInterfaces;
437 ++i;
445 void SAL_CALL ScCellFieldsObj::addRefreshListener( const uno::Reference< util::XRefreshListener >& xListener )
446 throw (uno::RuntimeException, std::exception)
448 if (xListener.is())
450 SolarMutexGuard aGuard;
451 if (!mpRefreshListeners)
452 mpRefreshListeners = new cppu::OInterfaceContainerHelper(aMutex);
453 mpRefreshListeners->addInterface(xListener);
457 void SAL_CALL ScCellFieldsObj::removeRefreshListener( const uno::Reference<util::XRefreshListener >& xListener )
458 throw (uno::RuntimeException, std::exception)
460 if (xListener.is())
462 SolarMutexGuard aGuard;
463 if (mpRefreshListeners)
464 mpRefreshListeners->removeInterface(xListener);
468 ScHeaderFieldsObj::ScHeaderFieldsObj(ScHeaderFooterTextData& rData) :
469 mrData(rData),
470 mpRefreshListeners( NULL )
472 mpEditSource = new ScHeaderFooterEditSource(rData);
475 ScHeaderFieldsObj::~ScHeaderFieldsObj()
477 delete mpEditSource;
479 // increment refcount to prevent double call off dtor
480 osl_atomic_increment( &m_refCount );
482 if (mpRefreshListeners)
484 lang::EventObject aEvent;
485 aEvent.Source = static_cast<cppu::OWeakObject*>(this);
486 if (mpRefreshListeners)
488 mpRefreshListeners->disposeAndClear(aEvent);
489 DELETEZ( mpRefreshListeners );
494 // XIndexAccess (via XTextFields)
496 uno::Reference<text::XTextField> ScHeaderFieldsObj::GetObjectByIndex_Impl(sal_Int32 Index) const
498 //! Feld-Funktionen muessen an den Forwarder !!!
499 ScEditEngineDefaulter* pEditEngine = mpEditSource->GetEditEngine();
500 ScUnoEditEngine aTempEngine(pEditEngine);
502 SvxFieldData* pData = aTempEngine.FindByIndex(static_cast<sal_uInt16>(Index));
503 if (!pData)
504 return NULL;
506 // Get the parent text range instance.
507 uno::Reference<text::XTextRange> xTextRange;
508 rtl::Reference<ScHeaderFooterContentObj> rContentObj = mrData.GetContentObj();
509 uno::Reference<text::XText> xText;
510 sal_uInt16 nPart = mrData.GetPart();
511 if (nPart == SC_HDFT_LEFT)
512 xText = rContentObj->getLeftText();
513 else if (nPart == SC_HDFT_CENTER)
514 xText = rContentObj->getCenterText();
515 else
516 xText = rContentObj->getRightText();
518 uno::Reference<text::XTextRange> xTemp(xText, uno::UNO_QUERY);
519 xTextRange = xTemp;
521 sal_Int32 nPar = aTempEngine.GetFieldPar();
522 sal_Int32 nPos = aTempEngine.GetFieldPos();
523 ESelection aSelection( nPar, nPos, nPar, nPos+1 ); // Field is 1 character
525 sal_Int32 eRealType = pData->GetClassId();
526 uno::Reference<text::XTextField> xRet(
527 new ScEditFieldObj(xTextRange, new ScHeaderFooterEditSource(mrData), eRealType, aSelection));
528 return xRet;
531 sal_Int32 SAL_CALL ScHeaderFieldsObj::getCount() throw(uno::RuntimeException, std::exception)
533 SolarMutexGuard aGuard;
535 //! Feld-Funktionen muessen an den Forwarder !!!
536 ScEditEngineDefaulter* pEditEngine = mpEditSource->GetEditEngine();
537 ScUnoEditEngine aTempEngine(pEditEngine);
538 return aTempEngine.CountFields();
541 uno::Any SAL_CALL ScHeaderFieldsObj::getByIndex( sal_Int32 nIndex )
542 throw(lang::IndexOutOfBoundsException,
543 lang::WrappedTargetException, uno::RuntimeException, std::exception)
545 SolarMutexGuard aGuard;
546 uno::Reference<text::XTextField> xField(GetObjectByIndex_Impl(nIndex));
547 if (xField.is())
548 return uno::makeAny(xField);
549 else
550 throw lang::IndexOutOfBoundsException();
553 uno::Type SAL_CALL ScHeaderFieldsObj::getElementType() throw(uno::RuntimeException, std::exception)
555 SolarMutexGuard aGuard;
556 return cppu::UnoType<text::XTextField>::get();
559 sal_Bool SAL_CALL ScHeaderFieldsObj::hasElements() throw(uno::RuntimeException, std::exception)
561 SolarMutexGuard aGuard;
562 return ( getCount() != 0 );
565 uno::Reference<container::XEnumeration> SAL_CALL ScHeaderFieldsObj::createEnumeration()
566 throw(uno::RuntimeException, std::exception)
568 SolarMutexGuard aGuard;
569 return new ScIndexEnumeration(this, OUString("com.sun.star.text.TextFieldEnumeration"));
572 void SAL_CALL ScHeaderFieldsObj::addContainerListener(
573 const uno::Reference<container::XContainerListener>& /* xListener */ )
574 throw(uno::RuntimeException, std::exception)
576 OSL_FAIL("not implemented");
579 void SAL_CALL ScHeaderFieldsObj::removeContainerListener(
580 const uno::Reference<container::XContainerListener>& /* xListener */ )
581 throw(uno::RuntimeException, std::exception)
583 OSL_FAIL("not implemented");
586 // XRefreshable
587 void SAL_CALL ScHeaderFieldsObj::refresh( )
588 throw (uno::RuntimeException, std::exception)
590 if (mpRefreshListeners)
592 // Call all listeners.
593 uno::Sequence< uno::Reference< uno::XInterface > > aListeners(mpRefreshListeners->getElements());
594 sal_uInt32 nLength(aListeners.getLength());
595 if (nLength)
597 const uno::Reference< uno::XInterface >* pInterfaces = aListeners.getConstArray();
598 if (pInterfaces)
600 lang::EventObject aEvent;
601 aEvent.Source.set(uno::Reference< util::XRefreshable >(this));
602 sal_uInt32 i(0);
603 while (i < nLength)
607 while(i < nLength)
609 static_cast< util::XRefreshListener* >(pInterfaces->get())->refreshed(aEvent);
610 ++pInterfaces;
611 ++i;
614 catch(uno::RuntimeException&)
616 ++pInterfaces;
617 ++i;
625 void SAL_CALL ScHeaderFieldsObj::addRefreshListener( const uno::Reference< util::XRefreshListener >& xListener )
626 throw (uno::RuntimeException, std::exception)
628 if (xListener.is())
630 SolarMutexGuard aGuard;
631 if (!mpRefreshListeners)
632 mpRefreshListeners = new cppu::OInterfaceContainerHelper(aMutex);
633 mpRefreshListeners->addInterface(xListener);
637 void SAL_CALL ScHeaderFieldsObj::removeRefreshListener( const uno::Reference<util::XRefreshListener >& xListener )
638 throw (uno::RuntimeException, std::exception)
640 if (xListener.is())
642 SolarMutexGuard aGuard;
643 if (mpRefreshListeners)
644 mpRefreshListeners->removeInterface(xListener);
648 SvxFieldData* ScEditFieldObj::getData()
650 if (!mpData)
652 switch (meType)
654 case text::textfield::Type::DATE:
655 mpData.reset(new SvxDateField);
656 break;
657 case text::textfield::Type::EXTENDED_FILE:
658 mpData.reset(
659 new SvxExtFileField(OUString(), SVXFILETYPE_VAR, SVXFILEFORMAT_NAME_EXT));
660 break;
661 case text::textfield::Type::PAGE:
662 mpData.reset(new SvxPageField);
663 break;
664 case text::textfield::Type::PAGES:
665 mpData.reset(new SvxPagesField);
666 break;
667 case text::textfield::Type::TABLE:
668 mpData.reset(new SvxTableField);
669 break;
670 case text::textfield::Type::TIME:
671 mpData.reset(new SvxTimeField);
672 break;
673 case text::textfield::Type::EXTENDED_TIME:
675 if (mbIsDate)
676 mpData.reset(new SvxDateField);
677 else
678 mpData.reset(new SvxExtTimeField);
680 break;
681 case text::textfield::Type::DOCINFO_TITLE:
682 mpData.reset(new SvxFileField);
683 break;
684 case text::textfield::Type::URL:
685 mpData.reset(
686 new SvxURLField(OUString(), OUString(), SVXURLFORMAT_APPDEFAULT));
687 break;
688 default:
689 mpData.reset(new SvxFieldData);
692 return mpData.get();
695 void ScEditFieldObj::setPropertyValueURL(const OUString& rName, const com::sun::star::uno::Any& rVal)
697 OUString aStrVal;
698 if (mpEditSource)
700 // Edit engine instance already exists for this field item. Use it.
701 ScEditEngineDefaulter* pEditEngine = mpEditSource->GetEditEngine();
702 ScUnoEditEngine aTempEngine(pEditEngine);
704 // Typ egal (in Zellen gibts nur URLs)
705 SvxFieldData* pField = aTempEngine.FindByPos(
706 aSelection.nStartPara, aSelection.nStartPos, text::textfield::Type::UNSPECIFIED);
707 OSL_ENSURE(pField,"setPropertyValue: Feld nicht gefunden");
708 if (!pField)
709 return;
711 if (pField->GetClassId() != text::textfield::Type::URL)
712 // Make sure this is indeed a URL field.
713 return;
715 SvxURLField* pURL = static_cast<SvxURLField*>(pField);
717 if (rName == SC_UNONAME_URL)
719 if (rVal >>= aStrVal)
720 pURL->SetURL(aStrVal);
722 else if (rName == SC_UNONAME_REPR)
724 if (rVal >>= aStrVal)
725 pURL->SetRepresentation(aStrVal);
727 else if (rName == SC_UNONAME_TARGET)
729 if (rVal >>= aStrVal)
730 pURL->SetTargetFrame(aStrVal);
732 else
733 throw beans::UnknownPropertyException();
735 pEditEngine->QuickInsertField( SvxFieldItem(*pField, EE_FEATURE_FIELD), aSelection );
736 mpEditSource->UpdateData();
737 return;
740 // Edit engine instance not yet present. Store the item data for later use.
741 SvxFieldData* pData = getData();
742 if (!pData)
743 throw uno::RuntimeException();
745 SvxURLField* p = static_cast<SvxURLField*>(pData);
746 if (rName == SC_UNONAME_URL)
748 if (rVal >>= aStrVal)
749 p->SetURL(aStrVal);
751 else if (rName == SC_UNONAME_REPR)
753 if (rVal >>= aStrVal)
754 p->SetRepresentation(aStrVal);
756 else if (rName == SC_UNONAME_TARGET)
758 if (rVal >>= aStrVal)
759 p->SetTargetFrame(aStrVal);
761 else
762 throw beans::UnknownPropertyException();
765 uno::Any ScEditFieldObj::getPropertyValueURL(const OUString& rName)
767 uno::Any aRet;
769 // anchor type is always "as character", text wrap always "none"
771 if (mpEditSource)
773 //! Feld-Funktionen muessen an den Forwarder !!!
774 ScEditEngineDefaulter* pEditEngine = mpEditSource->GetEditEngine();
775 ScUnoEditEngine aTempEngine(pEditEngine);
777 // Typ egal (in Zellen gibts nur URLs)
778 const SvxFieldData* pField = aTempEngine.FindByPos(
779 aSelection.nStartPara, aSelection.nStartPos, text::textfield::Type::UNSPECIFIED);
780 OSL_ENSURE(pField,"getPropertyValue: Feld nicht gefunden");
781 if (!pField)
782 throw uno::RuntimeException();
784 if (pField->GetClassId() != text::textfield::Type::URL)
785 throw uno::RuntimeException();
787 const SvxURLField* pURL = static_cast<const SvxURLField*>(pField);
789 if (rName == SC_UNONAME_URL)
790 aRet <<= pURL->GetURL();
791 else if (rName == SC_UNONAME_REPR)
792 aRet <<= pURL->GetRepresentation();
793 else if (rName == SC_UNONAME_TARGET)
794 aRet <<= pURL->GetTargetFrame();
795 else
796 throw beans::UnknownPropertyException();
798 else // noch nicht eingefuegt
800 const SvxFieldData* pField = getData();
801 if (!pField)
802 return aRet;
804 const SvxURLField* pURL = static_cast<const SvxURLField*>(pField);
805 if (rName == SC_UNONAME_URL)
806 aRet <<= pURL->GetURL();
807 else if (rName == SC_UNONAME_REPR)
808 aRet <<= pURL->GetRepresentation();
809 else if (rName == SC_UNONAME_TARGET)
810 aRet <<= pURL->GetTargetFrame();
811 else
812 throw beans::UnknownPropertyException();
814 return aRet;
817 void ScEditFieldObj::setPropertyValueFile(const OUString& rName, const uno::Any& rVal)
819 if (rName == SC_UNONAME_FILEFORM)
821 sal_Int16 nIntVal = 0;
822 if (rVal >>= nIntVal)
824 SvxFileFormat eFormat = lcl_UnoToSvxFileFormat(nIntVal);
825 if (mpEditSource)
827 ScEditEngineDefaulter* pEditEngine = mpEditSource->GetEditEngine();
828 ScUnoEditEngine aTempEngine(pEditEngine);
829 SvxFieldData* pField = aTempEngine.FindByPos(
830 aSelection.nStartPara, aSelection.nStartPos, text::textfield::Type::EXTENDED_FILE);
831 OSL_ENSURE(pField, "setPropertyValueFile: Field not found");
832 if (pField)
834 SvxExtFileField* pExtFile = static_cast<SvxExtFileField*>(pField); // local to the ScUnoEditEngine
835 pExtFile->SetFormat(eFormat);
836 pEditEngine->QuickInsertField(SvxFieldItem(*pField, EE_FEATURE_FIELD), aSelection);
837 mpEditSource->UpdateData();
840 else
842 SvxFieldData* pField = getData();
843 SvxExtFileField* pExtFile = static_cast<SvxExtFileField*>(pField);
844 pExtFile->SetFormat(eFormat);
848 else
849 throw beans::UnknownPropertyException();
852 uno::Any ScEditFieldObj::getPropertyValueFile(const OUString& rName)
854 uno::Any aRet;
855 if (rName == SC_UNONAME_FILEFORM)
857 SvxFileFormat eFormat = SVXFILEFORMAT_NAME_EXT;
858 const SvxFieldData* pField = NULL;
859 if (mpEditSource)
861 ScEditEngineDefaulter* pEditEngine = mpEditSource->GetEditEngine();
862 ScUnoEditEngine aTempEngine(pEditEngine);
863 pField = aTempEngine.FindByPos(
864 aSelection.nStartPara, aSelection.nStartPos, text::textfield::Type::EXTENDED_FILE);
866 else
867 pField = getData();
869 OSL_ENSURE(pField, "setPropertyValueFile: Field not found");
870 if (!pField)
871 throw uno::RuntimeException();
873 const SvxExtFileField* pExtFile = static_cast<const SvxExtFileField*>(pField);
874 eFormat = pExtFile->GetFormat();
875 sal_Int16 nIntVal = lcl_SvxToUnoFileFormat(eFormat);
876 aRet <<= nIntVal;
878 else
879 throw beans::UnknownPropertyException();
881 return aRet;
884 void ScEditFieldObj::setPropertyValueDateTime(const OUString& rName, const uno::Any& rVal)
886 if (mpEditSource)
888 // Field already inserted.
889 ScEditEngineDefaulter* pEditEngine = mpEditSource->GetEditEngine();
890 ScUnoEditEngine aTempEngine(pEditEngine);
891 SvxFieldData* pField = aTempEngine.FindByPos(aSelection.nStartPara, aSelection.nStartPos, meType);
892 if (!pField)
893 return;
895 switch (meType)
897 case text::textfield::Type::DATE:
899 SvxDateField* p = static_cast<SvxDateField*>(pField);
900 if (rName == SC_UNONAME_ISDATE)
902 // Do nothing for now.
904 else if (rName == SC_UNONAME_ISFIXED)
906 SvxDateType eType = rVal.get<sal_Bool>() ? SVXDATETYPE_FIX : SVXDATETYPE_VAR;
907 p->SetType(eType);
909 else if (rName == SC_UNONAME_DATETIME)
911 maDateTime = rVal.get<util::DateTime>();
912 Date aDate(maDateTime.Day, maDateTime.Month, maDateTime.Year);
913 p->SetFixDate(aDate);
915 else if (rName == SC_UNONAME_NUMFMT)
917 mnNumFormat = rVal.get<sal_Int32>();
918 p->SetFormat(static_cast<SvxDateFormat>(mnNumFormat));
920 else
921 throw beans::UnknownPropertyException();
923 break;
924 case text::textfield::Type::TIME:
926 // SvxTimeField doesn't have any attributes.
927 if (rName != SC_UNONAME_ISDATE && rName != SC_UNONAME_ISFIXED &&
928 rName != SC_UNONAME_DATETIME && rName != SC_UNONAME_NUMFMT)
929 throw beans::UnknownPropertyException();
931 break;
932 case text::textfield::Type::EXTENDED_TIME:
934 SvxExtTimeField* p = static_cast<SvxExtTimeField*>(pField);
935 if (rName == SC_UNONAME_ISDATE)
937 // Do nothing for now.
939 else if (rName == SC_UNONAME_ISFIXED)
941 SvxTimeType eType = rVal.get<sal_Bool>() ? SVXTIMETYPE_FIX : SVXTIMETYPE_VAR;
942 p->SetType(eType);
944 else if (rName == SC_UNONAME_DATETIME)
946 maDateTime = rVal.get<util::DateTime>();
947 tools::Time aTime(maDateTime);
948 p->SetFixTime(aTime);
950 else if (rName == SC_UNONAME_NUMFMT)
952 mnNumFormat = rVal.get<sal_Int32>();
953 p->SetFormat(static_cast<SvxTimeFormat>(mnNumFormat));
955 else
956 throw beans::UnknownPropertyException();
958 break;
959 default:
960 throw beans::UnknownPropertyException();
963 else
965 if (rName == SC_UNONAME_ISDATE)
966 mbIsDate = rVal.get<sal_Bool>();
967 else if (rName == SC_UNONAME_ISFIXED)
968 mbIsFixed = rVal.get<sal_Bool>();
969 else if (rName == SC_UNONAME_DATETIME)
970 maDateTime = rVal.get<util::DateTime>();
971 else if (rName == SC_UNONAME_NUMFMT)
972 mnNumFormat = rVal.get<sal_Int32>();
973 else
974 throw beans::UnknownPropertyException();
978 uno::Any ScEditFieldObj::getPropertyValueDateTime(const OUString& rName)
980 if (mpEditSource)
982 // Field already inserted.
983 ScEditEngineDefaulter* pEditEngine = mpEditSource->GetEditEngine();
984 ScUnoEditEngine aTempEngine(pEditEngine);
985 SvxFieldData* pField = aTempEngine.FindByPos(aSelection.nStartPara, aSelection.nStartPos, meType);
986 if (!pField)
987 throw uno::RuntimeException();
989 switch (meType)
991 case text::textfield::Type::DATE:
993 SvxDateField* p = static_cast<SvxDateField*>(pField);
994 if (rName == SC_UNONAME_ISDATE)
995 return uno::makeAny(sal_True);
997 if (rName == SC_UNONAME_ISFIXED)
998 return uno::makeAny<sal_Bool>(p->GetType() == SVXDATETYPE_FIX);
1000 if (rName == SC_UNONAME_DATETIME)
1002 Date aD(p->GetFixDate());
1003 maDateTime.Year = aD.GetYear();
1004 maDateTime.Month = aD.GetMonth();
1005 maDateTime.Day = aD.GetDay();
1006 maDateTime.Hours = 0;
1007 maDateTime.Minutes = 0;
1008 maDateTime.Seconds = 0;
1009 maDateTime.NanoSeconds = 0;
1010 return uno::makeAny(maDateTime);
1013 if (rName == SC_UNONAME_NUMFMT)
1014 return uno::makeAny<sal_Int32>(p->GetFormat());
1016 break;
1017 case text::textfield::Type::TIME:
1019 // SvxTimeField doesn't have any attributes.
1020 if (rName == SC_UNONAME_ISDATE)
1021 return uno::makeAny(sal_False);
1023 if (rName == SC_UNONAME_ISFIXED)
1024 return uno::makeAny(sal_False);
1026 if (rName == SC_UNONAME_DATETIME)
1027 // This is the best we can do.
1028 return uno::makeAny(maDateTime);
1030 if (rName == SC_UNONAME_NUMFMT)
1031 // Same as above.
1032 return uno::makeAny<sal_Int32>(0);
1034 break;
1035 case text::textfield::Type::EXTENDED_TIME:
1037 SvxExtTimeField* p = static_cast<SvxExtTimeField*>(pField);
1038 if (rName == SC_UNONAME_ISDATE)
1039 return uno::makeAny(sal_False);
1041 if (rName == SC_UNONAME_ISFIXED)
1042 return uno::makeAny<sal_Bool>(p->GetType() == SVXTIMETYPE_FIX);
1044 if (rName == SC_UNONAME_DATETIME)
1046 tools::Time aT(p->GetFixTime());
1047 maDateTime.Year = 0;
1048 maDateTime.Month = 0;
1049 maDateTime.Day = 0;
1050 maDateTime.Hours = aT.GetHour();
1051 maDateTime.Minutes = aT.GetMin();
1052 maDateTime.Seconds = aT.GetSec();
1053 maDateTime.NanoSeconds = aT.GetNanoSec();
1054 return uno::makeAny(maDateTime);
1057 if (rName == SC_UNONAME_NUMFMT)
1058 return uno::makeAny<sal_Int32>(p->GetFormat());
1060 break;
1061 default:
1065 else
1067 if (rName == SC_UNONAME_ISDATE)
1068 return uno::makeAny<sal_Bool>(mbIsDate);
1070 if (rName == SC_UNONAME_ISFIXED)
1071 return uno::makeAny<sal_Bool>(mbIsFixed);
1073 if (rName == SC_UNONAME_DATETIME)
1074 return uno::makeAny(maDateTime);
1076 if (rName == SC_UNONAME_NUMFMT)
1077 return uno::makeAny(mnNumFormat);
1080 throw beans::UnknownPropertyException();
1083 void ScEditFieldObj::setPropertyValueSheet(const OUString& rName, const uno::Any& rVal)
1085 if (mpEditSource)
1087 // Edit engine instance already exists for this field item. Use it.
1088 ScEditEngineDefaulter* pEditEngine = mpEditSource->GetEditEngine();
1089 ScUnoEditEngine aTempEngine(pEditEngine);
1091 // Typ egal (in Zellen gibts nur URLs)
1092 SvxFieldData* pField = aTempEngine.FindByPos(
1093 aSelection.nStartPara, aSelection.nStartPos, text::textfield::Type::UNSPECIFIED);
1094 OSL_ENSURE(pField,"setPropertyValue: Feld nicht gefunden");
1095 if (!pField)
1096 return;
1098 if (pField->GetClassId() != text::textfield::Type::TABLE)
1099 // Make sure this is indeed a URL field.
1100 return;
1102 SvxTableField* p = static_cast<SvxTableField*>(pField);
1104 if (rName == SC_UNONAME_TABLEPOS)
1106 sal_Int32 nTab = rVal.get<sal_Int32>();
1107 p->SetTab(nTab);
1109 else
1110 throw beans::UnknownPropertyException();
1112 pEditEngine->QuickInsertField(SvxFieldItem(*pField, EE_FEATURE_FIELD), aSelection);
1113 mpEditSource->UpdateData();
1114 return;
1117 // Edit engine instance not yet present. Store the item data for later use.
1118 SvxFieldData* pData = getData();
1119 if (!pData)
1120 throw uno::RuntimeException();
1122 SvxTableField* p = static_cast<SvxTableField*>(pData);
1123 if (rName == SC_UNONAME_TABLEPOS)
1125 sal_Int32 nTab = rVal.get<sal_Int32>();
1126 p->SetTab(nTab);
1128 else
1129 throw beans::UnknownPropertyException();
1133 ScEditFieldObj::ScEditFieldObj(
1134 const uno::Reference<text::XTextRange>& rContent,
1135 ScEditSource* pEditSrc, sal_Int32 eType, const ESelection& rSel) :
1136 OComponentHelper(getMutex()),
1137 pPropSet(NULL),
1138 mpEditSource(pEditSrc),
1139 aSelection(rSel),
1140 meType(eType), mpData(NULL), mpContent(rContent), mnNumFormat(0), mbIsDate(false), mbIsFixed(false)
1142 switch (meType)
1144 case text::textfield::Type::DOCINFO_TITLE:
1145 pPropSet = getEmptyPropertySet();
1146 break;
1147 case text::textfield::Type::EXTENDED_FILE:
1148 pPropSet = lcl_GetFileFieldPropertySet();
1149 break;
1150 case text::textfield::Type::URL:
1151 pPropSet = lcl_GetURLPropertySet();
1152 break;
1153 case text::textfield::Type::DATE:
1154 case text::textfield::Type::TIME:
1155 case text::textfield::Type::EXTENDED_TIME:
1156 pPropSet = getDateTimePropertySet();
1157 break;
1158 default:
1159 pPropSet = lcl_GetHeaderFieldPropertySet();
1162 if (meType == text::textfield::Type::DATE)
1163 mbIsDate = true;
1166 void ScEditFieldObj::InitDoc(
1167 const uno::Reference<text::XTextRange>& rContent, ScEditSource* pEditSrc, const ESelection& rSel)
1169 if (!mpEditSource)
1171 mpContent = rContent;
1172 mpData.reset();
1174 aSelection = rSel;
1175 mpEditSource = pEditSrc;
1179 ScEditFieldObj::~ScEditFieldObj()
1181 delete mpEditSource;
1184 SvxFieldItem ScEditFieldObj::CreateFieldItem()
1186 OSL_ENSURE( !mpEditSource, "CreateFieldItem mit eingefuegtem Feld" );
1187 return SvxFieldItem(*getData(), EE_FEATURE_FIELD);
1190 void ScEditFieldObj::DeleteField()
1192 if (mpEditSource)
1194 SvxTextForwarder* pForwarder = mpEditSource->GetTextForwarder();
1195 pForwarder->QuickInsertText( OUString(), aSelection );
1196 mpEditSource->UpdateData();
1198 aSelection.nEndPara = aSelection.nStartPara;
1199 aSelection.nEndPos = aSelection.nStartPos;
1201 //! Broadcast, um Selektion in anderen Objekten anzupassen
1202 //! (auch bei anderen Aktionen)
1206 bool ScEditFieldObj::IsInserted() const
1208 return mpEditSource != NULL;
1211 // XTextField
1213 OUString SAL_CALL ScEditFieldObj::getPresentation( sal_Bool bShowCommand )
1214 throw(uno::RuntimeException, std::exception)
1216 SolarMutexGuard aGuard;
1218 if (!mpEditSource)
1219 return OUString();
1221 //! Feld-Funktionen muessen an den Forwarder !!!
1222 ScEditEngineDefaulter* pEditEngine = mpEditSource->GetEditEngine();
1223 ScUnoEditEngine aTempEngine(pEditEngine);
1225 // Typ egal (in Zellen gibts nur URLs)
1226 const SvxFieldData* pField = aTempEngine.FindByPos(
1227 aSelection.nStartPara, aSelection.nStartPos, text::textfield::Type::UNSPECIFIED);
1228 OSL_ENSURE(pField,"getPresentation: Feld nicht gefunden");
1229 if (!pField)
1230 return OUString();
1232 switch (meType)
1234 case text::textfield::Type::URL:
1236 if (pField->GetClassId() != text::textfield::Type::URL)
1237 // Not an URL field, but URL is expected.
1238 throw uno::RuntimeException();
1240 const SvxURLField* pURL = static_cast<const SvxURLField*>(pField);
1241 return bShowCommand ? pURL->GetURL() : pURL->GetRepresentation();
1243 break;
1244 default:
1247 return OUString();
1250 // XTextContent
1252 void SAL_CALL ScEditFieldObj::attach( const uno::Reference<text::XTextRange>& xTextRange )
1253 throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
1255 SolarMutexGuard aGuard;
1256 if (xTextRange.is())
1258 uno::Reference<text::XText> xText(xTextRange->getText());
1259 if (xText.is())
1261 xText->insertTextContent( xTextRange, this, sal_True );
1266 uno::Reference<text::XTextRange> SAL_CALL ScEditFieldObj::getAnchor() throw(uno::RuntimeException, std::exception)
1268 SolarMutexGuard aGuard;
1269 return mpContent;
1272 // XComponent
1274 void SAL_CALL ScEditFieldObj::dispose() throw(uno::RuntimeException, std::exception)
1276 OComponentHelper::dispose();
1279 void SAL_CALL ScEditFieldObj::addEventListener(
1280 const uno::Reference<lang::XEventListener>& xListener )
1281 throw(uno::RuntimeException, std::exception)
1283 OComponentHelper::addEventListener( xListener );
1286 void SAL_CALL ScEditFieldObj::removeEventListener(
1287 const uno::Reference<lang::XEventListener>& xListener )
1288 throw(uno::RuntimeException, std::exception)
1290 OComponentHelper::removeEventListener( xListener );
1293 // XPropertySet
1295 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScEditFieldObj::getPropertySetInfo()
1296 throw(uno::RuntimeException, std::exception)
1298 SolarMutexGuard aGuard;
1299 uno::Reference<beans::XPropertySetInfo> aRef = pPropSet->getPropertySetInfo();
1300 return aRef;
1303 void SAL_CALL ScEditFieldObj::setPropertyValue(
1304 const OUString& aPropertyName, const uno::Any& aValue )
1305 throw (beans::UnknownPropertyException, beans::PropertyVetoException,
1306 lang::IllegalArgumentException, lang::WrappedTargetException,
1307 uno::RuntimeException, std::exception)
1309 SolarMutexGuard aGuard;
1310 if (aPropertyName == SC_UNONAME_ANCHOR)
1312 aValue >>= mpContent;
1313 return;
1316 switch (meType)
1318 case text::textfield::Type::URL:
1319 setPropertyValueURL(aPropertyName, aValue);
1320 break;
1321 case text::textfield::Type::EXTENDED_FILE:
1322 setPropertyValueFile(aPropertyName, aValue);
1323 break;
1324 case text::textfield::Type::DATE:
1325 case text::textfield::Type::TIME:
1326 case text::textfield::Type::EXTENDED_TIME:
1327 setPropertyValueDateTime(aPropertyName, aValue);
1328 break;
1329 case text::textfield::Type::TABLE:
1330 setPropertyValueSheet(aPropertyName, aValue);
1331 break;
1332 case text::textfield::Type::DOCINFO_TITLE:
1333 default:
1334 throw beans::UnknownPropertyException();
1338 uno::Any SAL_CALL ScEditFieldObj::getPropertyValue( const OUString& aPropertyName )
1339 throw(beans::UnknownPropertyException, lang::WrappedTargetException,
1340 uno::RuntimeException, std::exception)
1342 SolarMutexGuard aGuard;
1343 if (aPropertyName == SC_UNONAME_TEXTFIELD_TYPE)
1344 return uno::makeAny(meType);
1346 if (aPropertyName == SC_UNONAME_ANCHOR)
1347 return uno::makeAny(mpContent);
1349 if (aPropertyName == SC_UNONAME_ANCTYPE)
1351 uno::Any aRet;
1352 aRet <<= text::TextContentAnchorType_AS_CHARACTER;
1353 return aRet;
1355 if (aPropertyName == SC_UNONAME_ANCTYPES)
1357 uno::Any aRet;
1358 uno::Sequence<text::TextContentAnchorType> aSeq(1);
1359 aSeq[0] = text::TextContentAnchorType_AS_CHARACTER;
1360 aRet <<= aSeq;
1361 return aRet;
1363 if (aPropertyName == SC_UNONAME_TEXTWRAP)
1365 uno::Any aRet;
1366 aRet <<= text::WrapTextMode_NONE;
1367 return aRet;
1370 switch (meType)
1372 case text::textfield::Type::URL:
1373 return getPropertyValueURL(aPropertyName);
1374 case text::textfield::Type::EXTENDED_FILE:
1375 return getPropertyValueFile(aPropertyName);
1376 case text::textfield::Type::DATE:
1377 case text::textfield::Type::TIME:
1378 case text::textfield::Type::EXTENDED_TIME:
1379 return getPropertyValueDateTime(aPropertyName);
1380 case text::textfield::Type::DOCINFO_TITLE:
1381 default:
1382 throw beans::UnknownPropertyException();
1386 SC_IMPL_DUMMY_PROPERTY_LISTENER( ScEditFieldObj )
1388 // XUnoTunnel
1390 sal_Int64 SAL_CALL ScEditFieldObj::getSomething(
1391 const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException, std::exception)
1393 if ( rId.getLength() == 16 &&
1394 0 == memcmp( getUnoTunnelId().getConstArray(),
1395 rId.getConstArray(), 16 ) )
1397 return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
1399 return 0;
1402 namespace
1404 class theScEditFieldObjUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theScEditFieldObjUnoTunnelId> {};
1407 const uno::Sequence<sal_Int8>& ScEditFieldObj::getUnoTunnelId()
1409 return theScEditFieldObjUnoTunnelId::get().getSeq();
1412 ScEditFieldObj* ScEditFieldObj::getImplementation(const uno::Reference<text::XTextContent>& xObj)
1414 ScEditFieldObj* pRet = NULL;
1415 uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
1416 if (xUT.is())
1417 pRet = reinterpret_cast<ScEditFieldObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
1418 return pRet;
1421 // XServiceInfo
1423 OUString SAL_CALL ScEditFieldObj::getImplementationName() throw(uno::RuntimeException, std::exception)
1425 return OUString("ScEditFieldObj");
1428 sal_Bool SAL_CALL ScEditFieldObj::supportsService( const OUString& rServiceName )
1429 throw(uno::RuntimeException, std::exception)
1431 return cppu::supportsService(this, rServiceName);
1434 uno::Sequence<OUString> SAL_CALL ScEditFieldObj::getSupportedServiceNames()
1435 throw(uno::RuntimeException, std::exception)
1437 uno::Sequence<OUString> aRet(2);
1438 OUString* pArray = aRet.getArray();
1439 pArray[0] = "com.sun.star.text.TextField";
1440 pArray[1] = "com.sun.star.text.TextContent";
1441 return aRet;
1444 uno::Sequence<uno::Type> SAL_CALL ScEditFieldObj::getTypes() throw(uno::RuntimeException, std::exception)
1446 static uno::Sequence<uno::Type> aTypes;
1447 if ( aTypes.getLength() == 0 )
1449 uno::Sequence<uno::Type> aParentTypes(OComponentHelper::getTypes());
1450 long nParentLen = aParentTypes.getLength();
1451 const uno::Type* pParentPtr = aParentTypes.getConstArray();
1453 aTypes.realloc( nParentLen + 4 );
1454 uno::Type* pPtr = aTypes.getArray();
1455 pPtr[nParentLen + 0] = cppu::UnoType<text::XTextField>::get();
1456 pPtr[nParentLen + 1] = cppu::UnoType<beans::XPropertySet>::get();
1457 pPtr[nParentLen + 2] = cppu::UnoType<lang::XUnoTunnel>::get();
1458 pPtr[nParentLen + 3] = cppu::UnoType<lang::XServiceInfo>::get();
1460 for (long i=0; i<nParentLen; i++)
1461 pPtr[i] = pParentPtr[i]; // parent types first
1463 return aTypes;
1466 uno::Sequence<sal_Int8> SAL_CALL ScEditFieldObj::getImplementationId()
1467 throw(uno::RuntimeException, std::exception)
1469 return css::uno::Sequence<sal_Int8>();
1472 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */