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>
35 #include <editeng/eeitem.hxx>
37 #include <editeng/editeng.hxx>
38 #include <editeng/editobj.hxx>
39 #include <editeng/flditem.hxx>
40 #include <comphelper/servicehelper.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 { MAP_CHAR_LEN(SC_UNONAME_DATETIME
), 0, &getCppuType((const util::DateTime
*)0), 0, 0 },
59 { MAP_CHAR_LEN(SC_UNONAME_ISFIXED
), 0, &getBooleanCppuType(), 0, 0 },
60 { MAP_CHAR_LEN(SC_UNONAME_ISDATE
), 0, &getBooleanCppuType(), 0, 0 },
61 { MAP_CHAR_LEN(SC_UNONAME_NUMFMT
), 0, &getCppuType((const sal_Int32
*)0), 0, 0 },
64 static SfxItemPropertySet
aMap(aMapContent
);
68 const SfxItemPropertySet
* getEmptyPropertySet()
70 static const SfxItemPropertyMapEntry aMapContent
[] =
74 static SfxItemPropertySet
aMap(aMapContent
);
78 const SfxItemPropertySet
* lcl_GetURLPropertySet()
80 static const SfxItemPropertyMapEntry aURLPropertyMap_Impl
[] =
82 {MAP_CHAR_LEN(SC_UNONAME_ANCTYPE
), 0, &getCppuType((text::TextContentAnchorType
*)0), beans::PropertyAttribute::READONLY
, 0 },
83 {MAP_CHAR_LEN(SC_UNONAME_ANCTYPES
), 0, &getCppuType((uno::Sequence
<text::TextContentAnchorType
>*)0), beans::PropertyAttribute::READONLY
, 0 },
84 {MAP_CHAR_LEN(SC_UNONAME_REPR
), 0, &getCppuType((OUString
*)0), 0, 0},
85 {MAP_CHAR_LEN(SC_UNONAME_TARGET
), 0, &getCppuType((OUString
*)0), 0, 0},
86 {MAP_CHAR_LEN(SC_UNONAME_TEXTWRAP
), 0, &getCppuType((text::WrapTextMode
*)0), beans::PropertyAttribute::READONLY
, 0 },
87 {MAP_CHAR_LEN(SC_UNONAME_URL
), 0, &getCppuType((OUString
*)0), 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 {MAP_CHAR_LEN(SC_UNONAME_ANCTYPE
), 0, &getCppuType((text::TextContentAnchorType
*)0), beans::PropertyAttribute::READONLY
, 0 },
99 {MAP_CHAR_LEN(SC_UNONAME_ANCTYPES
), 0, &getCppuType((uno::Sequence
<text::TextContentAnchorType
>*)0), beans::PropertyAttribute::READONLY
, 0 },
100 {MAP_CHAR_LEN(SC_UNONAME_TEXTWRAP
), 0, &getCppuType((text::WrapTextMode
*)0), beans::PropertyAttribute::READONLY
, 0 },
103 static SfxItemPropertySet
aHeaderFieldPropertySet_Impl( aHeaderFieldPropertyMap_Impl
);
104 return &aHeaderFieldPropertySet_Impl
;
107 const SfxItemPropertySet
* lcl_GetFileFieldPropertySet()
109 static const SfxItemPropertyMapEntry aFileFieldPropertyMap_Impl
[] =
111 {MAP_CHAR_LEN(SC_UNONAME_ANCTYPE
), 0, &getCppuType((text::TextContentAnchorType
*)0), beans::PropertyAttribute::READONLY
, 0 },
112 {MAP_CHAR_LEN(SC_UNONAME_ANCTYPES
), 0, &getCppuType((uno::Sequence
<text::TextContentAnchorType
>*)0), beans::PropertyAttribute::READONLY
, 0 },
113 {MAP_CHAR_LEN(SC_UNONAME_FILEFORM
), 0, &getCppuType((sal_Int16
*)0), 0, 0 },
114 {MAP_CHAR_LEN(SC_UNONAME_TEXTWRAP
), 0, &getCppuType((text::WrapTextMode
*)0), beans::PropertyAttribute::READONLY
, 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 #define SCTEXTFIELD_SERVICE "com.sun.star.text.TextField"
148 #define SCTEXTCONTENT_SERVICE "com.sun.star.text.TextContent"
150 SC_SIMPLE_SERVICE_INFO( ScCellFieldsObj
, "ScCellFieldsObj", "com.sun.star.text.TextFields" )
151 SC_SIMPLE_SERVICE_INFO( ScHeaderFieldsObj
, "ScHeaderFieldsObj", "com.sun.star.text.TextFields" )
153 //------------------------------------------------------------------------
155 // ScUnoEditEngine nur um aus einer EditEngine die Felder herauszubekommen...
157 enum ScUnoCollectMode
160 SC_UNO_COLLECT_COUNT
,
161 SC_UNO_COLLECT_FINDINDEX
,
162 SC_UNO_COLLECT_FINDPOS
166 * This class exists solely to allow searching through field items. TODO:
167 * Look into providing the same functionality directly in EditEngine, to
168 * avoid having this class altogether.
170 class ScUnoEditEngine
: public ScEditEngineDefaulter
172 ScUnoCollectMode eMode
;
173 sal_uInt16 nFieldCount
;
174 sal_Int32 mnFieldType
;
175 SvxFieldData
* pFound
; // lokale Kopie
177 xub_StrLen nFieldPos
;
178 sal_uInt16 nFieldIndex
;
181 ScUnoEditEngine(ScEditEngineDefaulter
* pSource
);
184 //! nPos should be xub_StrLen
185 virtual OUString
CalcFieldValue( const SvxFieldItem
& rField
, sal_Int32 nPara
, sal_uInt16 nPos
,
186 Color
*& rTxtColor
, Color
*& rFldColor
);
188 sal_uInt16
CountFields();
189 SvxFieldData
* FindByIndex(sal_uInt16 nIndex
);
190 SvxFieldData
* FindByPos(sal_Int32 nPar
, xub_StrLen nPos
, sal_Int32 nType
);
192 sal_Int32
GetFieldPar() const { return nFieldPar
; }
193 xub_StrLen
GetFieldPos() const { return nFieldPos
; }
196 ScUnoEditEngine::ScUnoEditEngine(ScEditEngineDefaulter
* pSource
) :
197 ScEditEngineDefaulter( *pSource
),
198 eMode( SC_UNO_COLLECT_NONE
),
200 mnFieldType(text::textfield::Type::UNSPECIFIED
),
205 EditTextObject
* pData
= pSource
->CreateTextObject();
211 ScUnoEditEngine::~ScUnoEditEngine()
216 OUString
ScUnoEditEngine::CalcFieldValue( const SvxFieldItem
& rField
,
217 sal_Int32 nPara
, sal_uInt16 nPos
, Color
*& rTxtColor
, Color
*& rFldColor
)
219 OUString
aRet(EditEngine::CalcFieldValue( rField
, nPara
, nPos
, rTxtColor
, rFldColor
));
220 if (eMode
!= SC_UNO_COLLECT_NONE
)
222 const SvxFieldData
* pFieldData
= rField
.GetField();
225 if (mnFieldType
== text::textfield::Type::UNSPECIFIED
|| pFieldData
->GetClassId() == mnFieldType
)
227 if ( eMode
== SC_UNO_COLLECT_FINDINDEX
&& !pFound
&& nFieldCount
== nFieldIndex
)
229 pFound
= pFieldData
->Clone();
233 if ( eMode
== SC_UNO_COLLECT_FINDPOS
&& !pFound
&&
234 nPara
== nFieldPar
&& nPos
== nFieldPos
)
236 pFound
= pFieldData
->Clone();
237 nFieldIndex
= nFieldCount
;
246 sal_uInt16
ScUnoEditEngine::CountFields()
248 eMode
= SC_UNO_COLLECT_COUNT
;
249 mnFieldType
= text::textfield::Type::UNSPECIFIED
;
252 eMode
= SC_UNO_COLLECT_NONE
;
257 SvxFieldData
* ScUnoEditEngine::FindByIndex(sal_uInt16 nIndex
)
259 eMode
= SC_UNO_COLLECT_FINDINDEX
;
260 nFieldIndex
= nIndex
;
261 mnFieldType
= text::textfield::Type::UNSPECIFIED
;
264 eMode
= SC_UNO_COLLECT_NONE
;
269 SvxFieldData
* ScUnoEditEngine::FindByPos(sal_Int32 nPar
, xub_StrLen nPos
, sal_Int32 nType
)
271 eMode
= SC_UNO_COLLECT_FINDPOS
;
277 mnFieldType
= text::textfield::Type::UNSPECIFIED
;
278 eMode
= SC_UNO_COLLECT_NONE
;
283 //------------------------------------------------------------------------
285 ScCellFieldsObj::ScCellFieldsObj(
286 const uno::Reference
<text::XTextRange
>& xContent
,
287 ScDocShell
* pDocSh
, const ScAddress
& rPos
) :
291 mpRefreshListeners( NULL
)
293 pDocShell
->GetDocument()->AddUnoObject(*this);
295 mpEditSource
= new ScCellEditSource( pDocShell
, aCellPos
);
298 ScCellFieldsObj::~ScCellFieldsObj()
301 pDocShell
->GetDocument()->RemoveUnoObject(*this);
305 // increment refcount to prevent double call off dtor
306 osl_atomic_increment( &m_refCount
);
308 if (mpRefreshListeners
)
310 lang::EventObject aEvent
;
311 aEvent
.Source
.set(static_cast<cppu::OWeakObject
*>(this));
312 if (mpRefreshListeners
)
314 mpRefreshListeners
->disposeAndClear(aEvent
);
315 DELETEZ( mpRefreshListeners
);
320 void ScCellFieldsObj::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
322 if ( rHint
.ISA( ScUpdateRefHint
) )
326 else if ( rHint
.ISA( SfxSimpleHint
) &&
327 ((const SfxSimpleHint
&)rHint
).GetId() == SFX_HINT_DYING
)
329 pDocShell
= NULL
; // ungueltig geworden
332 // EditSource hat sich selber als Listener angemeldet
335 // XIndexAccess (via XTextFields)
337 uno::Reference
<text::XTextField
> ScCellFieldsObj::GetObjectByIndex_Impl(sal_Int32 Index
) const
339 //! Feld-Funktionen muessen an den Forwarder !!!
340 ScEditEngineDefaulter
* pEditEngine
= mpEditSource
->GetEditEngine();
341 ScUnoEditEngine
aTempEngine(pEditEngine
);
342 SvxFieldData
* pData
= aTempEngine
.FindByIndex(static_cast<sal_uInt16
>(Index
));
344 return uno::Reference
<text::XTextField
>();
346 sal_Int32 nPar
= aTempEngine
.GetFieldPar();
347 xub_StrLen nPos
= aTempEngine
.GetFieldPos();
348 ESelection
aSelection( nPar
, nPos
, nPar
, nPos
+1 ); // Feld ist 1 Zeichen
350 sal_Int32 eType
= pData
->GetClassId();
351 uno::Reference
<text::XTextField
> xRet(
352 new ScEditFieldObj(mxContent
, new ScCellEditSource(pDocShell
, aCellPos
), eType
, aSelection
));
356 sal_Int32 SAL_CALL
ScCellFieldsObj::getCount() throw(uno::RuntimeException
)
358 SolarMutexGuard aGuard
;
360 //! Feld-Funktionen muessen an den Forwarder !!!
361 ScEditEngineDefaulter
* pEditEngine
= mpEditSource
->GetEditEngine();
362 ScUnoEditEngine
aTempEngine(pEditEngine
);
364 return aTempEngine
.CountFields(); // Felder zaehlen, in Zelle ist der Typ egal
367 uno::Any SAL_CALL
ScCellFieldsObj::getByIndex( sal_Int32 nIndex
)
368 throw(lang::IndexOutOfBoundsException
,
369 lang::WrappedTargetException
, uno::RuntimeException
)
371 SolarMutexGuard aGuard
;
372 uno::Reference
<text::XTextField
> xField(GetObjectByIndex_Impl(nIndex
));
374 return uno::makeAny(xField
);
376 throw lang::IndexOutOfBoundsException();
379 uno::Type SAL_CALL
ScCellFieldsObj::getElementType() throw(uno::RuntimeException
)
381 SolarMutexGuard aGuard
;
382 return getCppuType((uno::Reference
<text::XTextField
>*)0);
385 sal_Bool SAL_CALL
ScCellFieldsObj::hasElements() throw(uno::RuntimeException
)
387 SolarMutexGuard aGuard
;
388 return ( getCount() != 0 );
391 uno::Reference
<container::XEnumeration
> SAL_CALL
ScCellFieldsObj::createEnumeration()
392 throw(uno::RuntimeException
)
394 SolarMutexGuard aGuard
;
395 return new ScIndexEnumeration(this, OUString("com.sun.star.text.TextFieldEnumeration"));
398 void SAL_CALL
ScCellFieldsObj::addContainerListener(
399 const uno::Reference
<container::XContainerListener
>& /* xListener */ )
400 throw(uno::RuntimeException
)
402 OSL_FAIL("not implemented");
405 void SAL_CALL
ScCellFieldsObj::removeContainerListener(
406 const uno::Reference
<container::XContainerListener
>& /* xListener */ )
407 throw(uno::RuntimeException
)
409 OSL_FAIL("not implemented");
413 void SAL_CALL
ScCellFieldsObj::refresh( )
414 throw (uno::RuntimeException
)
416 if (mpRefreshListeners
)
418 // Call all listeners.
419 uno::Sequence
< uno::Reference
< uno::XInterface
> > aListeners(mpRefreshListeners
->getElements());
420 sal_uInt32
nLength(aListeners
.getLength());
423 const uno::Reference
< uno::XInterface
>* pInterfaces
= aListeners
.getConstArray();
426 lang::EventObject aEvent
;
427 aEvent
.Source
.set(uno::Reference
< util::XRefreshable
>(const_cast<ScCellFieldsObj
*>(this)));
435 static_cast< util::XRefreshListener
* >(pInterfaces
->get())->refreshed(aEvent
);
440 catch(uno::RuntimeException
&)
451 void SAL_CALL
ScCellFieldsObj::addRefreshListener( const uno::Reference
< util::XRefreshListener
>& xListener
)
452 throw (uno::RuntimeException
)
456 SolarMutexGuard aGuard
;
457 if (!mpRefreshListeners
)
458 mpRefreshListeners
= new cppu::OInterfaceContainerHelper(aMutex
);
459 mpRefreshListeners
->addInterface(xListener
);
463 void SAL_CALL
ScCellFieldsObj::removeRefreshListener( const uno::Reference
<util::XRefreshListener
>& xListener
)
464 throw (uno::RuntimeException
)
468 SolarMutexGuard aGuard
;
469 if (mpRefreshListeners
)
470 mpRefreshListeners
->removeInterface(xListener
);
474 ScHeaderFieldsObj::ScHeaderFieldsObj(ScHeaderFooterTextData
& rData
) :
476 mpRefreshListeners( NULL
)
478 mpEditSource
= new ScHeaderFooterEditSource(rData
);
481 ScHeaderFieldsObj::~ScHeaderFieldsObj()
485 // increment refcount to prevent double call off dtor
486 osl_atomic_increment( &m_refCount
);
488 if (mpRefreshListeners
)
490 lang::EventObject aEvent
;
491 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
492 if (mpRefreshListeners
)
494 mpRefreshListeners
->disposeAndClear(aEvent
);
495 DELETEZ( mpRefreshListeners
);
500 // XIndexAccess (via XTextFields)
502 uno::Reference
<text::XTextField
> ScHeaderFieldsObj::GetObjectByIndex_Impl(sal_Int32 Index
) const
504 //! Feld-Funktionen muessen an den Forwarder !!!
505 ScEditEngineDefaulter
* pEditEngine
= mpEditSource
->GetEditEngine();
506 ScUnoEditEngine
aTempEngine(pEditEngine
);
508 SvxFieldData
* pData
= aTempEngine
.FindByIndex(static_cast<sal_uInt16
>(Index
));
512 // Get the parent text range instance.
513 uno::Reference
<text::XTextRange
> xTextRange
;
514 ScHeaderFooterContentObj
& rContentObj
= mrData
.GetContentObj();
515 uno::Reference
<text::XText
> xText
;
516 sal_uInt16 nPart
= mrData
.GetPart();
517 if (nPart
== SC_HDFT_LEFT
)
518 xText
= rContentObj
.getLeftText();
519 else if (nPart
== SC_HDFT_CENTER
)
520 xText
= rContentObj
.getCenterText();
522 xText
= rContentObj
.getRightText();
524 uno::Reference
<text::XTextRange
> xTemp(xText
, uno::UNO_QUERY
);
527 sal_Int32 nPar
= aTempEngine
.GetFieldPar();
528 xub_StrLen nPos
= aTempEngine
.GetFieldPos();
529 ESelection
aSelection( nPar
, nPos
, nPar
, nPos
+1 ); // Field is 1 character
531 sal_Int32 eRealType
= pData
->GetClassId();
532 uno::Reference
<text::XTextField
> xRet(
533 new ScEditFieldObj(xTextRange
, new ScHeaderFooterEditSource(mrData
), eRealType
, aSelection
));
537 sal_Int32 SAL_CALL
ScHeaderFieldsObj::getCount() throw(uno::RuntimeException
)
539 SolarMutexGuard aGuard
;
541 //! Feld-Funktionen muessen an den Forwarder !!!
542 ScEditEngineDefaulter
* pEditEngine
= mpEditSource
->GetEditEngine();
543 ScUnoEditEngine
aTempEngine(pEditEngine
);
544 return aTempEngine
.CountFields();
547 uno::Any SAL_CALL
ScHeaderFieldsObj::getByIndex( sal_Int32 nIndex
)
548 throw(lang::IndexOutOfBoundsException
,
549 lang::WrappedTargetException
, uno::RuntimeException
)
551 SolarMutexGuard aGuard
;
552 uno::Reference
<text::XTextField
> xField(GetObjectByIndex_Impl(nIndex
));
554 return uno::makeAny(xField
);
556 throw lang::IndexOutOfBoundsException();
559 uno::Type SAL_CALL
ScHeaderFieldsObj::getElementType() throw(uno::RuntimeException
)
561 SolarMutexGuard aGuard
;
562 return getCppuType((uno::Reference
<text::XTextField
>*)0);
565 sal_Bool SAL_CALL
ScHeaderFieldsObj::hasElements() throw(uno::RuntimeException
)
567 SolarMutexGuard aGuard
;
568 return ( getCount() != 0 );
571 uno::Reference
<container::XEnumeration
> SAL_CALL
ScHeaderFieldsObj::createEnumeration()
572 throw(uno::RuntimeException
)
574 SolarMutexGuard aGuard
;
575 return new ScIndexEnumeration(this, OUString("com.sun.star.text.TextFieldEnumeration"));
578 void SAL_CALL
ScHeaderFieldsObj::addContainerListener(
579 const uno::Reference
<container::XContainerListener
>& /* xListener */ )
580 throw(uno::RuntimeException
)
582 OSL_FAIL("not implemented");
585 void SAL_CALL
ScHeaderFieldsObj::removeContainerListener(
586 const uno::Reference
<container::XContainerListener
>& /* xListener */ )
587 throw(uno::RuntimeException
)
589 OSL_FAIL("not implemented");
593 void SAL_CALL
ScHeaderFieldsObj::refresh( )
594 throw (uno::RuntimeException
)
596 if (mpRefreshListeners
)
598 // Call all listeners.
599 uno::Sequence
< uno::Reference
< uno::XInterface
> > aListeners(mpRefreshListeners
->getElements());
600 sal_uInt32
nLength(aListeners
.getLength());
603 const uno::Reference
< uno::XInterface
>* pInterfaces
= aListeners
.getConstArray();
606 lang::EventObject aEvent
;
607 aEvent
.Source
.set(uno::Reference
< util::XRefreshable
>(const_cast<ScHeaderFieldsObj
*>(this)));
615 static_cast< util::XRefreshListener
* >(pInterfaces
->get())->refreshed(aEvent
);
620 catch(uno::RuntimeException
&)
631 void SAL_CALL
ScHeaderFieldsObj::addRefreshListener( const uno::Reference
< util::XRefreshListener
>& xListener
)
632 throw (uno::RuntimeException
)
636 SolarMutexGuard aGuard
;
637 if (!mpRefreshListeners
)
638 mpRefreshListeners
= new cppu::OInterfaceContainerHelper(aMutex
);
639 mpRefreshListeners
->addInterface(xListener
);
643 void SAL_CALL
ScHeaderFieldsObj::removeRefreshListener( const uno::Reference
<util::XRefreshListener
>& xListener
)
644 throw (uno::RuntimeException
)
648 SolarMutexGuard aGuard
;
649 if (mpRefreshListeners
)
650 mpRefreshListeners
->removeInterface(xListener
);
654 SvxFieldData
* ScEditFieldObj::getData()
660 case text::textfield::Type::DATE
:
661 mpData
.reset(new SvxDateField
);
663 case text::textfield::Type::EXTENDED_FILE
:
665 new SvxExtFileField(OUString(), SVXFILETYPE_VAR
, SVXFILEFORMAT_NAME_EXT
));
667 case text::textfield::Type::PAGE
:
668 mpData
.reset(new SvxPageField
);
670 case text::textfield::Type::PAGES
:
671 mpData
.reset(new SvxPagesField
);
673 case text::textfield::Type::TABLE
:
674 mpData
.reset(new SvxTableField
);
676 case text::textfield::Type::TIME
:
677 mpData
.reset(new SvxTimeField
);
679 case text::textfield::Type::EXTENDED_TIME
:
682 mpData
.reset(new SvxDateField
);
684 mpData
.reset(new SvxExtTimeField
);
687 case text::textfield::Type::DOCINFO_TITLE
:
688 mpData
.reset(new SvxFileField
);
690 case text::textfield::Type::URL
:
692 new SvxURLField(OUString(), OUString(), SVXURLFORMAT_APPDEFAULT
));
695 mpData
.reset(new SvxFieldData
);
701 void ScEditFieldObj::setPropertyValueURL(const OUString
& rName
, const com::sun::star::uno::Any
& rVal
)
706 // Edit engine instance already exists for this field item. Use it.
707 ScEditEngineDefaulter
* pEditEngine
= mpEditSource
->GetEditEngine();
708 ScUnoEditEngine
aTempEngine(pEditEngine
);
710 // Typ egal (in Zellen gibts nur URLs)
711 SvxFieldData
* pField
= aTempEngine
.FindByPos(
712 aSelection
.nStartPara
, aSelection
.nStartPos
, text::textfield::Type::UNSPECIFIED
);
713 OSL_ENSURE(pField
,"setPropertyValue: Feld nicht gefunden");
717 if (pField
->GetClassId() != text::textfield::Type::URL
)
718 // Make sure this is indeed a URL field.
721 SvxURLField
* pURL
= static_cast<SvxURLField
*>(pField
);
723 if (rName
== SC_UNONAME_URL
)
725 if (rVal
>>= aStrVal
)
726 pURL
->SetURL(aStrVal
);
728 else if (rName
== SC_UNONAME_REPR
)
730 if (rVal
>>= aStrVal
)
731 pURL
->SetRepresentation(aStrVal
);
733 else if (rName
== SC_UNONAME_TARGET
)
735 if (rVal
>>= aStrVal
)
736 pURL
->SetTargetFrame(aStrVal
);
739 throw beans::UnknownPropertyException();
741 pEditEngine
->QuickInsertField( SvxFieldItem(*pField
, EE_FEATURE_FIELD
), aSelection
);
742 mpEditSource
->UpdateData();
746 // Edit engine instance not yet present. Store the item data for later use.
747 SvxFieldData
* pData
= getData();
749 throw uno::RuntimeException();
751 SvxURLField
* p
= static_cast<SvxURLField
*>(pData
);
752 if (rName
== SC_UNONAME_URL
)
754 if (rVal
>>= aStrVal
)
757 else if (rName
== SC_UNONAME_REPR
)
759 if (rVal
>>= aStrVal
)
760 p
->SetRepresentation(aStrVal
);
762 else if (rName
== SC_UNONAME_TARGET
)
764 if (rVal
>>= aStrVal
)
765 p
->SetTargetFrame(aStrVal
);
768 throw beans::UnknownPropertyException();
771 uno::Any
ScEditFieldObj::getPropertyValueURL(const OUString
& rName
)
775 // anchor type is always "as character", text wrap always "none"
779 //! Feld-Funktionen muessen an den Forwarder !!!
780 ScEditEngineDefaulter
* pEditEngine
= mpEditSource
->GetEditEngine();
781 ScUnoEditEngine
aTempEngine(pEditEngine
);
783 // Typ egal (in Zellen gibts nur URLs)
784 const SvxFieldData
* pField
= aTempEngine
.FindByPos(
785 aSelection
.nStartPara
, aSelection
.nStartPos
, text::textfield::Type::UNSPECIFIED
);
786 OSL_ENSURE(pField
,"getPropertyValue: Feld nicht gefunden");
788 throw uno::RuntimeException();
790 if (pField
->GetClassId() != text::textfield::Type::URL
)
791 throw uno::RuntimeException();
793 const SvxURLField
* pURL
= static_cast<const SvxURLField
*>(pField
);
795 if (rName
== SC_UNONAME_URL
)
796 aRet
<<= pURL
->GetURL();
797 else if (rName
== SC_UNONAME_REPR
)
798 aRet
<<= pURL
->GetRepresentation();
799 else if (rName
== SC_UNONAME_TARGET
)
800 aRet
<<= pURL
->GetTargetFrame();
802 throw beans::UnknownPropertyException();
804 else // noch nicht eingefuegt
806 const SvxFieldData
* pField
= getData();
810 const SvxURLField
* pURL
= static_cast<const SvxURLField
*>(pField
);
811 if (rName
== SC_UNONAME_URL
)
812 aRet
<<= pURL
->GetURL();
813 else if (rName
== SC_UNONAME_REPR
)
814 aRet
<<= pURL
->GetRepresentation();
815 else if (rName
== SC_UNONAME_TARGET
)
816 aRet
<<= pURL
->GetTargetFrame();
818 throw beans::UnknownPropertyException();
823 void ScEditFieldObj::setPropertyValueFile(const OUString
& rName
, const uno::Any
& rVal
)
825 if (rName
== SC_UNONAME_FILEFORM
)
827 sal_Int16 nIntVal
= 0;
828 if (rVal
>>= nIntVal
)
830 SvxFileFormat eFormat
= lcl_UnoToSvxFileFormat(nIntVal
);
833 ScEditEngineDefaulter
* pEditEngine
= mpEditSource
->GetEditEngine();
834 ScUnoEditEngine
aTempEngine(pEditEngine
);
835 SvxFieldData
* pField
= aTempEngine
.FindByPos(
836 aSelection
.nStartPara
, aSelection
.nStartPos
, text::textfield::Type::EXTENDED_FILE
);
837 OSL_ENSURE(pField
, "setPropertyValueFile: Field not found");
840 SvxExtFileField
* pExtFile
= static_cast<SvxExtFileField
*>(pField
); // local to the ScUnoEditEngine
841 pExtFile
->SetFormat(eFormat
);
842 pEditEngine
->QuickInsertField(SvxFieldItem(*pField
, EE_FEATURE_FIELD
), aSelection
);
843 mpEditSource
->UpdateData();
848 SvxFieldData
* pField
= getData();
849 SvxExtFileField
* pExtFile
= static_cast<SvxExtFileField
*>(pField
);
850 pExtFile
->SetFormat(eFormat
);
855 throw beans::UnknownPropertyException();
858 uno::Any
ScEditFieldObj::getPropertyValueFile(const OUString
& rName
)
861 if (rName
== SC_UNONAME_FILEFORM
)
863 SvxFileFormat eFormat
= SVXFILEFORMAT_NAME_EXT
;
864 const SvxFieldData
* pField
= NULL
;
867 ScEditEngineDefaulter
* pEditEngine
= mpEditSource
->GetEditEngine();
868 ScUnoEditEngine
aTempEngine(pEditEngine
);
869 pField
= aTempEngine
.FindByPos(
870 aSelection
.nStartPara
, aSelection
.nStartPos
, text::textfield::Type::EXTENDED_FILE
);
875 OSL_ENSURE(pField
, "setPropertyValueFile: Field not found");
877 throw uno::RuntimeException();
879 const SvxExtFileField
* pExtFile
= static_cast<const SvxExtFileField
*>(pField
);
880 eFormat
= pExtFile
->GetFormat();
881 sal_Int16 nIntVal
= lcl_SvxToUnoFileFormat(eFormat
);
885 throw beans::UnknownPropertyException();
890 void ScEditFieldObj::setPropertyValueDateTime(const OUString
& rName
, const uno::Any
& rVal
)
894 // Field already inserted.
895 ScEditEngineDefaulter
* pEditEngine
= mpEditSource
->GetEditEngine();
896 ScUnoEditEngine
aTempEngine(pEditEngine
);
897 SvxFieldData
* pField
= aTempEngine
.FindByPos(aSelection
.nStartPara
, aSelection
.nStartPos
, meType
);
903 case text::textfield::Type::DATE
:
905 SvxDateField
* p
= static_cast<SvxDateField
*>(pField
);
906 if (rName
== SC_UNONAME_ISDATE
)
908 // Do nothing for now.
910 else if (rName
== SC_UNONAME_ISFIXED
)
912 SvxDateType eType
= rVal
.get
<sal_Bool
>() ? SVXDATETYPE_FIX
: SVXDATETYPE_VAR
;
915 else if (rName
== SC_UNONAME_DATETIME
)
917 maDateTime
= rVal
.get
<util::DateTime
>();
918 Date
aDate(maDateTime
.Day
, maDateTime
.Month
, maDateTime
.Year
);
919 p
->SetFixDate(aDate
);
921 else if (rName
== SC_UNONAME_NUMFMT
)
923 mnNumFormat
= rVal
.get
<sal_Int32
>();
924 p
->SetFormat(static_cast<SvxDateFormat
>(mnNumFormat
));
927 throw beans::UnknownPropertyException();
930 case text::textfield::Type::TIME
:
932 // SvxTimeField doesn't have any attributes.
933 if (rName
!= SC_UNONAME_ISDATE
&& rName
!= SC_UNONAME_ISFIXED
&&
934 rName
!= SC_UNONAME_DATETIME
&& rName
!= SC_UNONAME_NUMFMT
)
935 throw beans::UnknownPropertyException();
938 case text::textfield::Type::EXTENDED_TIME
:
940 SvxExtTimeField
* p
= static_cast<SvxExtTimeField
*>(pField
);
941 if (rName
== SC_UNONAME_ISDATE
)
943 // Do nothing for now.
945 else if (rName
== SC_UNONAME_ISFIXED
)
947 SvxTimeType eType
= rVal
.get
<sal_Bool
>() ? SVXTIMETYPE_FIX
: SVXTIMETYPE_VAR
;
950 else if (rName
== SC_UNONAME_DATETIME
)
952 maDateTime
= rVal
.get
<util::DateTime
>();
953 Time
aTime(maDateTime
.Hours
, maDateTime
.Minutes
, maDateTime
.Seconds
, maDateTime
.NanoSeconds
);
954 p
->SetFixTime(aTime
);
956 else if (rName
== SC_UNONAME_NUMFMT
)
958 mnNumFormat
= rVal
.get
<sal_Int32
>();
959 p
->SetFormat(static_cast<SvxTimeFormat
>(mnNumFormat
));
962 throw beans::UnknownPropertyException();
966 throw beans::UnknownPropertyException();
971 if (rName
== SC_UNONAME_ISDATE
)
972 mbIsDate
= rVal
.get
<sal_Bool
>();
973 else if (rName
== SC_UNONAME_ISFIXED
)
974 mbIsFixed
= rVal
.get
<sal_Bool
>();
975 else if (rName
== SC_UNONAME_DATETIME
)
976 maDateTime
= rVal
.get
<util::DateTime
>();
977 else if (rName
== SC_UNONAME_NUMFMT
)
978 mnNumFormat
= rVal
.get
<sal_Int32
>();
980 throw beans::UnknownPropertyException();
984 uno::Any
ScEditFieldObj::getPropertyValueDateTime(const OUString
& rName
)
988 // Field already inserted.
989 ScEditEngineDefaulter
* pEditEngine
= mpEditSource
->GetEditEngine();
990 ScUnoEditEngine
aTempEngine(pEditEngine
);
991 SvxFieldData
* pField
= aTempEngine
.FindByPos(aSelection
.nStartPara
, aSelection
.nStartPos
, meType
);
993 throw uno::RuntimeException();
997 case text::textfield::Type::DATE
:
999 SvxDateField
* p
= static_cast<SvxDateField
*>(pField
);
1000 if (rName
== SC_UNONAME_ISDATE
)
1001 return uno::makeAny(sal_True
);
1003 if (rName
== SC_UNONAME_ISFIXED
)
1004 return uno::makeAny
<sal_Bool
>(p
->GetType() == SVXDATETYPE_FIX
);
1006 if (rName
== SC_UNONAME_DATETIME
)
1008 Date
aD(p
->GetFixDate());
1009 maDateTime
.Year
= aD
.GetYear();
1010 maDateTime
.Month
= aD
.GetMonth();
1011 maDateTime
.Day
= aD
.GetDay();
1012 maDateTime
.Hours
= 0;
1013 maDateTime
.Minutes
= 0;
1014 maDateTime
.Seconds
= 0;
1015 maDateTime
.NanoSeconds
= 0;
1016 return uno::makeAny(maDateTime
);
1019 if (rName
== SC_UNONAME_NUMFMT
)
1020 return uno::makeAny
<sal_Int32
>(p
->GetFormat());
1023 case text::textfield::Type::TIME
:
1025 // SvxTimeField doesn't have any attributes.
1026 if (rName
== SC_UNONAME_ISDATE
)
1027 return uno::makeAny(sal_False
);
1029 if (rName
== SC_UNONAME_ISFIXED
)
1030 return uno::makeAny(sal_False
);
1032 if (rName
== SC_UNONAME_DATETIME
)
1033 // This is the best we can do.
1034 return uno::makeAny(maDateTime
);
1036 if (rName
== SC_UNONAME_NUMFMT
)
1038 return uno::makeAny
<sal_Int32
>(0);
1041 case text::textfield::Type::EXTENDED_TIME
:
1043 SvxExtTimeField
* p
= static_cast<SvxExtTimeField
*>(pField
);
1044 if (rName
== SC_UNONAME_ISDATE
)
1045 return uno::makeAny(sal_False
);
1047 if (rName
== SC_UNONAME_ISFIXED
)
1048 return uno::makeAny
<sal_Bool
>(p
->GetType() == SVXTIMETYPE_FIX
);
1050 if (rName
== SC_UNONAME_DATETIME
)
1052 Time
aT(p
->GetFixTime());
1053 maDateTime
.Year
= 0;
1054 maDateTime
.Month
= 0;
1056 maDateTime
.Hours
= aT
.GetHour();
1057 maDateTime
.Minutes
= aT
.GetMin();
1058 maDateTime
.Seconds
= aT
.GetSec();
1059 maDateTime
.NanoSeconds
= aT
.GetNanoSec();
1060 return uno::makeAny(maDateTime
);
1063 if (rName
== SC_UNONAME_NUMFMT
)
1064 return uno::makeAny
<sal_Int32
>(p
->GetFormat());
1073 if (rName
== SC_UNONAME_ISDATE
)
1074 return uno::makeAny
<sal_Bool
>(mbIsDate
);
1076 if (rName
== SC_UNONAME_ISFIXED
)
1077 return uno::makeAny
<sal_Bool
>(mbIsFixed
);
1079 if (rName
== SC_UNONAME_DATETIME
)
1080 return uno::makeAny(maDateTime
);
1082 if (rName
== SC_UNONAME_NUMFMT
)
1083 return uno::makeAny(mnNumFormat
);
1086 throw beans::UnknownPropertyException();
1089 void ScEditFieldObj::setPropertyValueSheet(const OUString
& rName
, const uno::Any
& rVal
)
1093 // Edit engine instance already exists for this field item. Use it.
1094 ScEditEngineDefaulter
* pEditEngine
= mpEditSource
->GetEditEngine();
1095 ScUnoEditEngine
aTempEngine(pEditEngine
);
1097 // Typ egal (in Zellen gibts nur URLs)
1098 SvxFieldData
* pField
= aTempEngine
.FindByPos(
1099 aSelection
.nStartPara
, aSelection
.nStartPos
, text::textfield::Type::UNSPECIFIED
);
1100 OSL_ENSURE(pField
,"setPropertyValue: Feld nicht gefunden");
1104 if (pField
->GetClassId() != text::textfield::Type::TABLE
)
1105 // Make sure this is indeed a URL field.
1108 SvxTableField
* p
= static_cast<SvxTableField
*>(pField
);
1110 if (rName
== SC_UNONAME_TABLEPOS
)
1112 sal_Int32 nTab
= rVal
.get
<sal_Int32
>();
1116 throw beans::UnknownPropertyException();
1118 pEditEngine
->QuickInsertField(SvxFieldItem(*pField
, EE_FEATURE_FIELD
), aSelection
);
1119 mpEditSource
->UpdateData();
1123 // Edit engine instance not yet present. Store the item data for later use.
1124 SvxFieldData
* pData
= getData();
1126 throw uno::RuntimeException();
1128 SvxTableField
* p
= static_cast<SvxTableField
*>(pData
);
1129 if (rName
== SC_UNONAME_TABLEPOS
)
1131 sal_Int32 nTab
= rVal
.get
<sal_Int32
>();
1135 throw beans::UnknownPropertyException();
1139 ScEditFieldObj::ScEditFieldObj(
1140 const uno::Reference
<text::XTextRange
>& rContent
,
1141 ScEditSource
* pEditSrc
, sal_Int32 eType
, const ESelection
& rSel
) :
1142 OComponentHelper(getMutex()),
1144 mpEditSource(pEditSrc
),
1146 meType(eType
), mpData(NULL
), mpContent(rContent
), mnNumFormat(0), mbIsDate(false), mbIsFixed(false)
1150 case text::textfield::Type::DOCINFO_TITLE
:
1151 pPropSet
= getEmptyPropertySet();
1153 case text::textfield::Type::EXTENDED_FILE
:
1154 pPropSet
= lcl_GetFileFieldPropertySet();
1156 case text::textfield::Type::URL
:
1157 pPropSet
= lcl_GetURLPropertySet();
1159 case text::textfield::Type::DATE
:
1160 case text::textfield::Type::TIME
:
1161 case text::textfield::Type::EXTENDED_TIME
:
1162 pPropSet
= getDateTimePropertySet();
1165 pPropSet
= lcl_GetHeaderFieldPropertySet();
1168 if (meType
== text::textfield::Type::DATE
)
1172 void ScEditFieldObj::InitDoc(
1173 const uno::Reference
<text::XTextRange
>& rContent
, ScEditSource
* pEditSrc
, const ESelection
& rSel
)
1177 mpContent
= rContent
;
1181 mpEditSource
= pEditSrc
;
1185 ScEditFieldObj::~ScEditFieldObj()
1187 delete mpEditSource
;
1190 SvxFieldItem
ScEditFieldObj::CreateFieldItem()
1192 OSL_ENSURE( !mpEditSource
, "CreateFieldItem mit eingefuegtem Feld" );
1193 return SvxFieldItem(*getData(), EE_FEATURE_FIELD
);
1196 sal_Int32
ScEditFieldObj::GetFieldType() const
1201 void ScEditFieldObj::DeleteField()
1205 SvxTextForwarder
* pForwarder
= mpEditSource
->GetTextForwarder();
1206 pForwarder
->QuickInsertText( OUString(), aSelection
);
1207 mpEditSource
->UpdateData();
1209 aSelection
.nEndPara
= aSelection
.nStartPara
;
1210 aSelection
.nEndPos
= aSelection
.nStartPos
;
1212 //! Broadcast, um Selektion in anderen Objekten anzupassen
1213 //! (auch bei anderen Aktionen)
1217 bool ScEditFieldObj::IsInserted() const
1219 return mpEditSource
!= NULL
;
1224 OUString SAL_CALL
ScEditFieldObj::getPresentation( sal_Bool bShowCommand
)
1225 throw(uno::RuntimeException
)
1227 SolarMutexGuard aGuard
;
1232 //! Feld-Funktionen muessen an den Forwarder !!!
1233 ScEditEngineDefaulter
* pEditEngine
= mpEditSource
->GetEditEngine();
1234 ScUnoEditEngine
aTempEngine(pEditEngine
);
1236 // Typ egal (in Zellen gibts nur URLs)
1237 const SvxFieldData
* pField
= aTempEngine
.FindByPos(
1238 aSelection
.nStartPara
, aSelection
.nStartPos
, text::textfield::Type::UNSPECIFIED
);
1239 OSL_ENSURE(pField
,"getPresentation: Feld nicht gefunden");
1245 case text::textfield::Type::URL
:
1247 if (pField
->GetClassId() != text::textfield::Type::URL
)
1248 // Not an URL field, but URL is expected.
1249 throw uno::RuntimeException();
1251 const SvxURLField
* pURL
= static_cast<const SvxURLField
*>(pField
);
1252 return bShowCommand
? pURL
->GetURL() : pURL
->GetRepresentation();
1263 void SAL_CALL
ScEditFieldObj::attach( const uno::Reference
<text::XTextRange
>& xTextRange
)
1264 throw(lang::IllegalArgumentException
, uno::RuntimeException
)
1266 SolarMutexGuard aGuard
;
1267 if (xTextRange
.is())
1269 uno::Reference
<text::XText
> xText(xTextRange
->getText());
1272 xText
->insertTextContent( xTextRange
, this, sal_True
);
1277 uno::Reference
<text::XTextRange
> SAL_CALL
ScEditFieldObj::getAnchor() throw(uno::RuntimeException
)
1279 SolarMutexGuard aGuard
;
1285 void SAL_CALL
ScEditFieldObj::dispose() throw(uno::RuntimeException
)
1287 OComponentHelper::dispose();
1290 void SAL_CALL
ScEditFieldObj::addEventListener(
1291 const uno::Reference
<lang::XEventListener
>& xListener
)
1292 throw(uno::RuntimeException
)
1294 OComponentHelper::addEventListener( xListener
);
1297 void SAL_CALL
ScEditFieldObj::removeEventListener(
1298 const uno::Reference
<lang::XEventListener
>& xListener
)
1299 throw(uno::RuntimeException
)
1301 OComponentHelper::removeEventListener( xListener
);
1306 uno::Reference
<beans::XPropertySetInfo
> SAL_CALL
ScEditFieldObj::getPropertySetInfo()
1307 throw(uno::RuntimeException
)
1309 SolarMutexGuard aGuard
;
1310 uno::Reference
<beans::XPropertySetInfo
> aRef
= pPropSet
->getPropertySetInfo();
1314 void SAL_CALL
ScEditFieldObj::setPropertyValue(
1315 const OUString
& aPropertyName
, const uno::Any
& aValue
)
1316 throw(beans::UnknownPropertyException
, beans::PropertyVetoException
,
1317 lang::IllegalArgumentException
, lang::WrappedTargetException
,
1318 uno::RuntimeException
)
1320 SolarMutexGuard aGuard
;
1321 if (aPropertyName
== SC_UNONAME_ANCHOR
)
1323 aValue
>>= mpContent
;
1329 case text::textfield::Type::URL
:
1330 setPropertyValueURL(aPropertyName
, aValue
);
1332 case text::textfield::Type::EXTENDED_FILE
:
1333 setPropertyValueFile(aPropertyName
, aValue
);
1335 case text::textfield::Type::DATE
:
1336 case text::textfield::Type::TIME
:
1337 case text::textfield::Type::EXTENDED_TIME
:
1338 setPropertyValueDateTime(aPropertyName
, aValue
);
1340 case text::textfield::Type::TABLE
:
1341 setPropertyValueSheet(aPropertyName
, aValue
);
1343 case text::textfield::Type::DOCINFO_TITLE
:
1345 throw beans::UnknownPropertyException();
1349 uno::Any SAL_CALL
ScEditFieldObj::getPropertyValue( const OUString
& aPropertyName
)
1350 throw(beans::UnknownPropertyException
, lang::WrappedTargetException
,
1351 uno::RuntimeException
)
1353 SolarMutexGuard aGuard
;
1354 if (aPropertyName
.equals(SC_UNONAME_TEXTFIELD_TYPE
))
1355 return uno::makeAny(meType
);
1357 if (aPropertyName
== SC_UNONAME_ANCHOR
)
1358 return uno::makeAny(mpContent
);
1360 if (aPropertyName
== SC_UNONAME_ANCTYPE
)
1363 aRet
<<= text::TextContentAnchorType_AS_CHARACTER
;
1366 if (aPropertyName
== SC_UNONAME_ANCTYPES
)
1369 uno::Sequence
<text::TextContentAnchorType
> aSeq(1);
1370 aSeq
[0] = text::TextContentAnchorType_AS_CHARACTER
;
1374 if (aPropertyName
== SC_UNONAME_TEXTWRAP
)
1377 aRet
<<= text::WrapTextMode_NONE
;
1383 case text::textfield::Type::URL
:
1384 return getPropertyValueURL(aPropertyName
);
1385 case text::textfield::Type::EXTENDED_FILE
:
1386 return getPropertyValueFile(aPropertyName
);
1387 case text::textfield::Type::DATE
:
1388 case text::textfield::Type::TIME
:
1389 case text::textfield::Type::EXTENDED_TIME
:
1390 return getPropertyValueDateTime(aPropertyName
);
1391 case text::textfield::Type::DOCINFO_TITLE
:
1393 throw beans::UnknownPropertyException();
1397 SC_IMPL_DUMMY_PROPERTY_LISTENER( ScEditFieldObj
)
1401 sal_Int64 SAL_CALL
ScEditFieldObj::getSomething(
1402 const uno::Sequence
<sal_Int8
>& rId
) throw(uno::RuntimeException
)
1404 if ( rId
.getLength() == 16 &&
1405 0 == memcmp( getUnoTunnelId().getConstArray(),
1406 rId
.getConstArray(), 16 ) )
1408 return sal::static_int_cast
<sal_Int64
>(reinterpret_cast<sal_IntPtr
>(this));
1415 class theScEditFieldObjUnoTunnelId
: public rtl::Static
< UnoTunnelIdInit
, theScEditFieldObjUnoTunnelId
> {};
1418 const uno::Sequence
<sal_Int8
>& ScEditFieldObj::getUnoTunnelId()
1420 return theScEditFieldObjUnoTunnelId::get().getSeq();
1423 ScEditFieldObj
* ScEditFieldObj::getImplementation(const uno::Reference
<text::XTextContent
>& xObj
)
1425 ScEditFieldObj
* pRet
= NULL
;
1426 uno::Reference
<lang::XUnoTunnel
> xUT( xObj
, uno::UNO_QUERY
);
1428 pRet
= reinterpret_cast<ScEditFieldObj
*>(sal::static_int_cast
<sal_IntPtr
>(xUT
->getSomething(getUnoTunnelId())));
1434 OUString SAL_CALL
ScEditFieldObj::getImplementationName() throw(uno::RuntimeException
)
1436 return OUString("ScEditFieldObj");
1439 sal_Bool SAL_CALL
ScEditFieldObj::supportsService( const OUString
& rServiceName
)
1440 throw(uno::RuntimeException
)
1442 return rServiceName
== SCTEXTFIELD_SERVICE
|| rServiceName
== SCTEXTCONTENT_SERVICE
;
1445 uno::Sequence
<OUString
> SAL_CALL
ScEditFieldObj::getSupportedServiceNames()
1446 throw(uno::RuntimeException
)
1448 uno::Sequence
<OUString
> aRet(2);
1449 OUString
* pArray
= aRet
.getArray();
1450 pArray
[0] = SCTEXTFIELD_SERVICE
;
1451 pArray
[1] = SCTEXTCONTENT_SERVICE
;
1455 uno::Sequence
<uno::Type
> SAL_CALL
ScEditFieldObj::getTypes() throw(uno::RuntimeException
)
1457 static uno::Sequence
<uno::Type
> aTypes
;
1458 if ( aTypes
.getLength() == 0 )
1460 uno::Sequence
<uno::Type
> aParentTypes(OComponentHelper::getTypes());
1461 long nParentLen
= aParentTypes
.getLength();
1462 const uno::Type
* pParentPtr
= aParentTypes
.getConstArray();
1464 aTypes
.realloc( nParentLen
+ 4 );
1465 uno::Type
* pPtr
= aTypes
.getArray();
1466 pPtr
[nParentLen
+ 0] = getCppuType((const uno::Reference
<text::XTextField
>*)0);
1467 pPtr
[nParentLen
+ 1] = getCppuType((const uno::Reference
<beans::XPropertySet
>*)0);
1468 pPtr
[nParentLen
+ 2] = getCppuType((const uno::Reference
<lang::XUnoTunnel
>*)0);
1469 pPtr
[nParentLen
+ 3] = getCppuType((const uno::Reference
<lang::XServiceInfo
>*)0);
1471 for (long i
=0; i
<nParentLen
; i
++)
1472 pPtr
[i
] = pParentPtr
[i
]; // parent types first
1479 class theScEditFieldObjImplementationId
: public rtl::Static
<UnoTunnelIdInit
, theScEditFieldObjImplementationId
> {};
1482 uno::Sequence
<sal_Int8
> SAL_CALL
ScEditFieldObj::getImplementationId()
1483 throw(uno::RuntimeException
)
1485 return theScEditFieldObjImplementationId::get().getSeq();
1488 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */