1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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"
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
;
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
);
68 const SfxItemPropertySet
* getEmptyPropertySet()
70 static const SfxItemPropertyMapEntry aMapContent
[] =
72 { OUString(), 0, css::uno::Type(), 0, 0 }
74 static SfxItemPropertySet
aMap(aMapContent
);
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
)
125 case text::FilenameDisplayFormat::FULL
: return SVXFILEFORMAT_FULLPATH
;
126 case text::FilenameDisplayFormat::PATH
: return SVXFILEFORMAT_PATH
;
127 case text::FilenameDisplayFormat::NAME
: return SVXFILEFORMAT_NAME
;
129 return SVXFILEFORMAT_NAME_EXT
;
133 sal_Int16
lcl_SvxToUnoFileFormat( SvxFileFormat 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
;
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
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
173 sal_uInt16 nFieldIndex
;
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
)
194 , mnFieldType(text::textfield::Type::UNSPECIFIED
)
200 EditTextObject
* pData
= pSource
->CreateTextObject();
205 ScUnoEditEngine::~ScUnoEditEngine()
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();
219 if (mnFieldType
== text::textfield::Type::UNSPECIFIED
|| pFieldData
->GetClassId() == mnFieldType
)
221 if ( eMode
== SC_UNO_COLLECT_FINDINDEX
&& !pFound
&& nFieldCount
== nFieldIndex
)
223 pFound
= pFieldData
->Clone();
227 if ( eMode
== SC_UNO_COLLECT_FINDPOS
&& !pFound
&&
228 nPara
== nFieldPar
&& nPos
== nFieldPos
)
230 pFound
= pFieldData
->Clone();
231 nFieldIndex
= nFieldCount
;
240 sal_uInt16
ScUnoEditEngine::CountFields()
242 eMode
= SC_UNO_COLLECT_COUNT
;
243 mnFieldType
= text::textfield::Type::UNSPECIFIED
;
246 eMode
= SC_UNO_COLLECT_NONE
;
251 SvxFieldData
* ScUnoEditEngine::FindByIndex(sal_uInt16 nIndex
)
253 eMode
= SC_UNO_COLLECT_FINDINDEX
;
254 nFieldIndex
= nIndex
;
255 mnFieldType
= text::textfield::Type::UNSPECIFIED
;
258 eMode
= SC_UNO_COLLECT_NONE
;
263 SvxFieldData
* ScUnoEditEngine::FindByPos(sal_Int32 nPar
, sal_Int32 nPos
, sal_Int32 nType
)
265 eMode
= SC_UNO_COLLECT_FINDPOS
;
271 mnFieldType
= text::textfield::Type::UNSPECIFIED
;
272 eMode
= SC_UNO_COLLECT_NONE
;
277 ScCellFieldsObj::ScCellFieldsObj(
278 const uno::Reference
<text::XTextRange
>& xContent
,
279 ScDocShell
* pDocSh
, const ScAddress
& rPos
) :
283 mpRefreshListeners( NULL
)
285 pDocShell
->GetDocument().AddUnoObject(*this);
287 mpEditSource
= new ScCellEditSource( pDocShell
, aCellPos
);
290 ScCellFieldsObj::~ScCellFieldsObj()
295 pDocShell
->GetDocument().RemoveUnoObject(*this);
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
) )
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
));
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
));
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
));
368 return uno::makeAny(xField
);
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");
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());
417 const uno::Reference
< uno::XInterface
>* pInterfaces
= aListeners
.getConstArray();
420 lang::EventObject aEvent
;
421 aEvent
.Source
.set(uno::Reference
< util::XRefreshable
>(this));
429 static_cast< util::XRefreshListener
* >(pInterfaces
->get())->refreshed(aEvent
);
434 catch(uno::RuntimeException
&)
445 void SAL_CALL
ScCellFieldsObj::addRefreshListener( const uno::Reference
< util::XRefreshListener
>& xListener
)
446 throw (uno::RuntimeException
, std::exception
)
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
)
462 SolarMutexGuard aGuard
;
463 if (mpRefreshListeners
)
464 mpRefreshListeners
->removeInterface(xListener
);
468 ScHeaderFieldsObj::ScHeaderFieldsObj(ScHeaderFooterTextData
& rData
) :
470 mpRefreshListeners( NULL
)
472 mpEditSource
= new ScHeaderFooterEditSource(rData
);
475 ScHeaderFieldsObj::~ScHeaderFieldsObj()
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
));
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();
516 xText
= rContentObj
->getRightText();
518 uno::Reference
<text::XTextRange
> xTemp(xText
, uno::UNO_QUERY
);
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
));
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
));
548 return uno::makeAny(xField
);
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");
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());
597 const uno::Reference
< uno::XInterface
>* pInterfaces
= aListeners
.getConstArray();
600 lang::EventObject aEvent
;
601 aEvent
.Source
.set(uno::Reference
< util::XRefreshable
>(this));
609 static_cast< util::XRefreshListener
* >(pInterfaces
->get())->refreshed(aEvent
);
614 catch(uno::RuntimeException
&)
625 void SAL_CALL
ScHeaderFieldsObj::addRefreshListener( const uno::Reference
< util::XRefreshListener
>& xListener
)
626 throw (uno::RuntimeException
, std::exception
)
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
)
642 SolarMutexGuard aGuard
;
643 if (mpRefreshListeners
)
644 mpRefreshListeners
->removeInterface(xListener
);
648 SvxFieldData
* ScEditFieldObj::getData()
654 case text::textfield::Type::DATE
:
655 mpData
.reset(new SvxDateField
);
657 case text::textfield::Type::EXTENDED_FILE
:
659 new SvxExtFileField(OUString(), SVXFILETYPE_VAR
, SVXFILEFORMAT_NAME_EXT
));
661 case text::textfield::Type::PAGE
:
662 mpData
.reset(new SvxPageField
);
664 case text::textfield::Type::PAGES
:
665 mpData
.reset(new SvxPagesField
);
667 case text::textfield::Type::TABLE
:
668 mpData
.reset(new SvxTableField
);
670 case text::textfield::Type::TIME
:
671 mpData
.reset(new SvxTimeField
);
673 case text::textfield::Type::EXTENDED_TIME
:
676 mpData
.reset(new SvxDateField
);
678 mpData
.reset(new SvxExtTimeField
);
681 case text::textfield::Type::DOCINFO_TITLE
:
682 mpData
.reset(new SvxFileField
);
684 case text::textfield::Type::URL
:
686 new SvxURLField(OUString(), OUString(), SVXURLFORMAT_APPDEFAULT
));
689 mpData
.reset(new SvxFieldData
);
695 void ScEditFieldObj::setPropertyValueURL(const OUString
& rName
, const com::sun::star::uno::Any
& rVal
)
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");
711 if (pField
->GetClassId() != text::textfield::Type::URL
)
712 // Make sure this is indeed a URL field.
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
);
733 throw beans::UnknownPropertyException();
735 pEditEngine
->QuickInsertField( SvxFieldItem(*pField
, EE_FEATURE_FIELD
), aSelection
);
736 mpEditSource
->UpdateData();
740 // Edit engine instance not yet present. Store the item data for later use.
741 SvxFieldData
* pData
= getData();
743 throw uno::RuntimeException();
745 SvxURLField
* p
= static_cast<SvxURLField
*>(pData
);
746 if (rName
== SC_UNONAME_URL
)
748 if (rVal
>>= 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
);
762 throw beans::UnknownPropertyException();
765 uno::Any
ScEditFieldObj::getPropertyValueURL(const OUString
& rName
)
769 // anchor type is always "as character", text wrap always "none"
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");
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();
796 throw beans::UnknownPropertyException();
798 else // noch nicht eingefuegt
800 const SvxFieldData
* pField
= getData();
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();
812 throw beans::UnknownPropertyException();
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
);
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");
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();
842 SvxFieldData
* pField
= getData();
843 SvxExtFileField
* pExtFile
= static_cast<SvxExtFileField
*>(pField
);
844 pExtFile
->SetFormat(eFormat
);
849 throw beans::UnknownPropertyException();
852 uno::Any
ScEditFieldObj::getPropertyValueFile(const OUString
& rName
)
855 if (rName
== SC_UNONAME_FILEFORM
)
857 SvxFileFormat eFormat
= SVXFILEFORMAT_NAME_EXT
;
858 const SvxFieldData
* pField
= NULL
;
861 ScEditEngineDefaulter
* pEditEngine
= mpEditSource
->GetEditEngine();
862 ScUnoEditEngine
aTempEngine(pEditEngine
);
863 pField
= aTempEngine
.FindByPos(
864 aSelection
.nStartPara
, aSelection
.nStartPos
, text::textfield::Type::EXTENDED_FILE
);
869 OSL_ENSURE(pField
, "setPropertyValueFile: Field not found");
871 throw uno::RuntimeException();
873 const SvxExtFileField
* pExtFile
= static_cast<const SvxExtFileField
*>(pField
);
874 eFormat
= pExtFile
->GetFormat();
875 sal_Int16 nIntVal
= lcl_SvxToUnoFileFormat(eFormat
);
879 throw beans::UnknownPropertyException();
884 void ScEditFieldObj::setPropertyValueDateTime(const OUString
& rName
, const uno::Any
& rVal
)
888 // Field already inserted.
889 ScEditEngineDefaulter
* pEditEngine
= mpEditSource
->GetEditEngine();
890 ScUnoEditEngine
aTempEngine(pEditEngine
);
891 SvxFieldData
* pField
= aTempEngine
.FindByPos(aSelection
.nStartPara
, aSelection
.nStartPos
, 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
;
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
));
921 throw beans::UnknownPropertyException();
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();
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
;
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
));
956 throw beans::UnknownPropertyException();
960 throw beans::UnknownPropertyException();
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
>();
974 throw beans::UnknownPropertyException();
978 uno::Any
ScEditFieldObj::getPropertyValueDateTime(const OUString
& rName
)
982 // Field already inserted.
983 ScEditEngineDefaulter
* pEditEngine
= mpEditSource
->GetEditEngine();
984 ScUnoEditEngine
aTempEngine(pEditEngine
);
985 SvxFieldData
* pField
= aTempEngine
.FindByPos(aSelection
.nStartPara
, aSelection
.nStartPos
, meType
);
987 throw uno::RuntimeException();
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());
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
)
1032 return uno::makeAny
<sal_Int32
>(0);
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;
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());
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
)
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");
1098 if (pField
->GetClassId() != text::textfield::Type::TABLE
)
1099 // Make sure this is indeed a URL field.
1102 SvxTableField
* p
= static_cast<SvxTableField
*>(pField
);
1104 if (rName
== SC_UNONAME_TABLEPOS
)
1106 sal_Int32 nTab
= rVal
.get
<sal_Int32
>();
1110 throw beans::UnknownPropertyException();
1112 pEditEngine
->QuickInsertField(SvxFieldItem(*pField
, EE_FEATURE_FIELD
), aSelection
);
1113 mpEditSource
->UpdateData();
1117 // Edit engine instance not yet present. Store the item data for later use.
1118 SvxFieldData
* pData
= getData();
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
>();
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()),
1138 mpEditSource(pEditSrc
),
1140 meType(eType
), mpData(NULL
), mpContent(rContent
), mnNumFormat(0), mbIsDate(false), mbIsFixed(false)
1144 case text::textfield::Type::DOCINFO_TITLE
:
1145 pPropSet
= getEmptyPropertySet();
1147 case text::textfield::Type::EXTENDED_FILE
:
1148 pPropSet
= lcl_GetFileFieldPropertySet();
1150 case text::textfield::Type::URL
:
1151 pPropSet
= lcl_GetURLPropertySet();
1153 case text::textfield::Type::DATE
:
1154 case text::textfield::Type::TIME
:
1155 case text::textfield::Type::EXTENDED_TIME
:
1156 pPropSet
= getDateTimePropertySet();
1159 pPropSet
= lcl_GetHeaderFieldPropertySet();
1162 if (meType
== text::textfield::Type::DATE
)
1166 void ScEditFieldObj::InitDoc(
1167 const uno::Reference
<text::XTextRange
>& rContent
, ScEditSource
* pEditSrc
, const ESelection
& rSel
)
1171 mpContent
= rContent
;
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()
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
;
1213 OUString SAL_CALL
ScEditFieldObj::getPresentation( sal_Bool bShowCommand
)
1214 throw(uno::RuntimeException
, std::exception
)
1216 SolarMutexGuard aGuard
;
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");
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();
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());
1261 xText
->insertTextContent( xTextRange
, this, sal_True
);
1266 uno::Reference
<text::XTextRange
> SAL_CALL
ScEditFieldObj::getAnchor() throw(uno::RuntimeException
, std::exception
)
1268 SolarMutexGuard aGuard
;
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
);
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();
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
;
1318 case text::textfield::Type::URL
:
1319 setPropertyValueURL(aPropertyName
, aValue
);
1321 case text::textfield::Type::EXTENDED_FILE
:
1322 setPropertyValueFile(aPropertyName
, aValue
);
1324 case text::textfield::Type::DATE
:
1325 case text::textfield::Type::TIME
:
1326 case text::textfield::Type::EXTENDED_TIME
:
1327 setPropertyValueDateTime(aPropertyName
, aValue
);
1329 case text::textfield::Type::TABLE
:
1330 setPropertyValueSheet(aPropertyName
, aValue
);
1332 case text::textfield::Type::DOCINFO_TITLE
:
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
)
1352 aRet
<<= text::TextContentAnchorType_AS_CHARACTER
;
1355 if (aPropertyName
== SC_UNONAME_ANCTYPES
)
1358 uno::Sequence
<text::TextContentAnchorType
> aSeq(1);
1359 aSeq
[0] = text::TextContentAnchorType_AS_CHARACTER
;
1363 if (aPropertyName
== SC_UNONAME_TEXTWRAP
)
1366 aRet
<<= text::WrapTextMode_NONE
;
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
:
1382 throw beans::UnknownPropertyException();
1386 SC_IMPL_DUMMY_PROPERTY_LISTENER( ScEditFieldObj
)
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));
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
);
1417 pRet
= reinterpret_cast<ScEditFieldObj
*>(sal::static_int_cast
<sal_IntPtr
>(xUT
->getSomething(getUnoTunnelId())));
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";
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
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: */