1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unofield.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 #include <com/sun/star/text/XDependentTextField.hpp>
34 #include <com/sun/star/util/XRefreshable.hpp>
35 #include <com/sun/star/util/XUpdatable.hpp>
38 #include <unocoll.hxx>
39 #include <RefreshListenerContainer.hxx>
46 class SwTextAPIObject
;
48 /* -----------------04.12.98 12:49-------------------
50 * --------------------------------------------------*/
51 class SwXFieldMaster
: public cppu::WeakImplHelper4
53 ::com::sun::star::beans::XPropertySet
,
54 ::com::sun::star::lang::XServiceInfo
,
55 ::com::sun::star::lang::XUnoTunnel
,
56 ::com::sun::star::lang::XComponent
60 SwEventListenerContainer aLstnrCntnr
;
61 sal_uInt16 nResTypeId
;
64 sal_Bool m_bIsDescriptor
;
66 String sParam1
; //Content / Database / NumberingSeparator
67 String sParam2
; // - /DataTablename
68 String sParam3
; // - /DataFieldName
70 String sParam5
; // - /DataBaseURL
71 String sParam6
; // - /DataBaseResource
72 double fParam1
; // Value / -
73 sal_Int8 nParam1
; // ChapterNumberingLevel
74 sal_Bool bParam1
; // IsExpression
78 virtual ~SwXFieldMaster();
81 SwXFieldMaster(SwDoc
* pDoc
, sal_uInt16 nResId
);
82 SwXFieldMaster(SwFieldType
& rType
, SwDoc
* pDoc
);
87 static const ::com::sun::star::uno::Sequence
< sal_Int8
> & getUnoTunnelId();
90 virtual sal_Int64 SAL_CALL
getSomething( const ::com::sun::star::uno::Sequence
< sal_Int8
>& aIdentifier
) throw(::com::sun::star::uno::RuntimeException
);
93 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException
);
94 virtual void SAL_CALL
setPropertyValue( const ::rtl::OUString
& aPropertyName
, const ::com::sun::star::uno::Any
& aValue
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::beans::PropertyVetoException
, ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
95 virtual ::com::sun::star::uno::Any SAL_CALL
getPropertyValue( const ::rtl::OUString
& PropertyName
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
96 virtual void SAL_CALL
addPropertyChangeListener( const ::rtl::OUString
& aPropertyName
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertyChangeListener
>& xListener
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
97 virtual void SAL_CALL
removePropertyChangeListener( const ::rtl::OUString
& aPropertyName
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertyChangeListener
>& aListener
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
98 virtual void SAL_CALL
addVetoableChangeListener( const ::rtl::OUString
& PropertyName
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XVetoableChangeListener
>& aListener
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
99 virtual void SAL_CALL
removeVetoableChangeListener( const ::rtl::OUString
& PropertyName
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XVetoableChangeListener
>& aListener
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
102 virtual void SAL_CALL
dispose(void) throw( ::com::sun::star::uno::RuntimeException
);
103 virtual void SAL_CALL
addEventListener(const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
> & aListener
) throw( ::com::sun::star::uno::RuntimeException
);
104 virtual void SAL_CALL
removeEventListener(const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
> & aListener
) throw( ::com::sun::star::uno::RuntimeException
);
107 virtual rtl::OUString SAL_CALL
getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException
);
108 virtual BOOL SAL_CALL
supportsService(const rtl::OUString
& ServiceName
) throw( ::com::sun::star::uno::RuntimeException
);
109 virtual ::com::sun::star::uno::Sequence
< rtl::OUString
> SAL_CALL
getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException
);
112 virtual void Modify( SfxPoolItem
*pOld
, SfxPoolItem
*pNew
);
114 static rtl::OUString
GetProgrammaticName(const SwFieldType
& rType
, SwDoc
& rDoc
);
115 static rtl::OUString
LocalizeFormula(const SwSetExpField
& rFld
, const rtl::OUString
& rFormula
, sal_Bool bQuery
);
117 SwFieldType
* GetFldType(sal_Bool bDontCreate
= sal_False
) const;
118 SwDoc
* GetDoc() {return m_pDoc
;}
120 sal_Bool
IsDescriptor()const {return m_bIsDescriptor
;}
121 sal_uInt16
GetResId() const {return nResTypeId
;}
124 /* -----------------04.12.98 12:49-------------------
126 * --------------------------------------------------*/
127 struct SwFieldProperties_Impl
;
128 class SwXTextField
: public cppu::WeakImplHelper5
130 ::com::sun::star::text::XDependentTextField
,
131 ::com::sun::star::lang::XServiceInfo
,
132 ::com::sun::star::beans::XPropertySet
,
133 ::com::sun::star::lang::XUnoTunnel
,
134 ::com::sun::star::util::XUpdatable
138 SwEventListenerContainer aLstnrCntnr
;
139 const SwFmtFld
* pFmtFld
;
141 SwTextAPIObject
* m_pTextObject
;
143 sal_Bool m_bIsDescriptor
;
144 SwClient m_aFieldTypeClient
; // required to access field master of not yet inserted fields
145 sal_Bool m_bCallUpdate
;
146 sal_uInt16 m_nServiceId
;
147 SwFieldProperties_Impl
* m_pProps
;
151 //SwFieldType* GetFldType() const { return (SwFieldType*)GetRegisteredIn(); }
152 SwDoc
* GetDoc() {return m_pDoc
;}
154 virtual ~SwXTextField();
156 SwXTextField(sal_uInt16 nServiceId
, SwDoc
* pDoc
=0);
157 SwXTextField(const SwFmtFld
& rFmt
, SwDoc
* pDoc
);
162 static const ::com::sun::star::uno::Sequence
< sal_Int8
> & getUnoTunnelId();
165 virtual sal_Int64 SAL_CALL
getSomething( const ::com::sun::star::uno::Sequence
< sal_Int8
>& aIdentifier
) throw(::com::sun::star::uno::RuntimeException
);
167 //XDependentTextField
168 virtual void SAL_CALL
attachTextFieldMaster(const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> & xFieldMaster
) throw( ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
169 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> SAL_CALL
getTextFieldMaster(void) throw( ::com::sun::star::uno::RuntimeException
);
172 virtual rtl::OUString SAL_CALL
getPresentation(sal_Bool bShowCommand
) throw( ::com::sun::star::uno::RuntimeException
);
175 virtual void SAL_CALL
attach(const ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextRange
> & xTextRange
) throw( ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
176 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextRange
> SAL_CALL
getAnchor(void) throw( ::com::sun::star::uno::RuntimeException
);
179 virtual void SAL_CALL
dispose(void) throw( ::com::sun::star::uno::RuntimeException
);
180 virtual void SAL_CALL
addEventListener(const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
> & aListener
) throw( ::com::sun::star::uno::RuntimeException
);
181 virtual void SAL_CALL
removeEventListener(const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
> & aListener
) throw( ::com::sun::star::uno::RuntimeException
);
184 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException
);
185 virtual void SAL_CALL
setPropertyValue( const ::rtl::OUString
& aPropertyName
, const ::com::sun::star::uno::Any
& aValue
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::beans::PropertyVetoException
, ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
186 virtual ::com::sun::star::uno::Any SAL_CALL
getPropertyValue( const ::rtl::OUString
& PropertyName
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
187 virtual void SAL_CALL
addPropertyChangeListener( const ::rtl::OUString
& aPropertyName
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertyChangeListener
>& xListener
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
188 virtual void SAL_CALL
removePropertyChangeListener( const ::rtl::OUString
& aPropertyName
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertyChangeListener
>& aListener
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
189 virtual void SAL_CALL
addVetoableChangeListener( const ::rtl::OUString
& PropertyName
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XVetoableChangeListener
>& aListener
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
190 virtual void SAL_CALL
removeVetoableChangeListener( const ::rtl::OUString
& PropertyName
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XVetoableChangeListener
>& aListener
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
193 virtual rtl::OUString SAL_CALL
getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException
);
194 virtual BOOL SAL_CALL
supportsService(const rtl::OUString
& ServiceName
) throw( ::com::sun::star::uno::RuntimeException
);
195 virtual ::com::sun::star::uno::Sequence
< rtl::OUString
> SAL_CALL
getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException
);
198 virtual void SAL_CALL
update( ) throw (::com::sun::star::uno::RuntimeException
);
201 virtual void Modify( SfxPoolItem
*pOld
, SfxPoolItem
*pNew
);
203 void attachToRange(const ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextRange
> & xTextRange
)throw( ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
205 const SwField
* GetField() const;
206 const SwFmtFld
* GetFldFmt(){return GetField() ? pFmtFld
: 0; };
211 /// @return a SwXTextField, either an already existing one or a new one
212 SwXTextField
* CreateSwXTextField(SwDoc
& rDoc
, SwFmtFld
const& rFmt
);
215 /* -----------------21.12.98 10:26-------------------
217 * --------------------------------------------------*/
219 cppu::WeakImplHelper2
221 ::com::sun::star::container::XNameAccess
,
222 ::com::sun::star::lang::XServiceInfo
224 SwXTextFieldMastersBaseClass
;
225 class SwXTextFieldMasters
: public SwXTextFieldMastersBaseClass
,
226 public SwUnoCollection
229 virtual ~SwXTextFieldMasters();
231 SwXTextFieldMasters(SwDoc
* pDoc
);
235 virtual ::com::sun::star::uno::Any SAL_CALL
getByName(const rtl::OUString
& Name
) throw( ::com::sun::star::container::NoSuchElementException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
236 virtual ::com::sun::star::uno::Sequence
< rtl::OUString
> SAL_CALL
getElementNames(void) throw( ::com::sun::star::uno::RuntimeException
);
237 virtual sal_Bool SAL_CALL
hasByName(const rtl::OUString
& Name
) throw( ::com::sun::star::uno::RuntimeException
);
240 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType( ) throw(::com::sun::star::uno::RuntimeException
);
241 virtual sal_Bool SAL_CALL
hasElements( ) throw(::com::sun::star::uno::RuntimeException
);
244 virtual rtl::OUString SAL_CALL
getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException
);
245 virtual BOOL SAL_CALL
supportsService(const rtl::OUString
& ServiceName
) throw( ::com::sun::star::uno::RuntimeException
);
246 virtual ::com::sun::star::uno::Sequence
< rtl::OUString
> SAL_CALL
getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException
);
249 static sal_Bool
getInstanceName(const SwFieldType
& rFldType
, String
& rName
);
252 /* -----------------21.12.98 10:26-------------------
254 * --------------------------------------------------*/
256 cppu::WeakImplHelper3
258 ::com::sun::star::container::XEnumerationAccess
,
259 ::com::sun::star::lang::XServiceInfo
,
260 ::com::sun::star::util::XRefreshable
262 SwXTextFieldTypesBaseClass
;
263 class SwXTextFieldTypes
: public SwXTextFieldTypesBaseClass
,
264 public SwUnoCollection
266 SwRefreshListenerContainer aRefreshCont
;
268 virtual ~SwXTextFieldTypes();
270 SwXTextFieldTypes(SwDoc
* pDoc
);
274 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XEnumeration
> SAL_CALL
createEnumeration(void) throw( ::com::sun::star::uno::RuntimeException
);
277 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType( ) throw(::com::sun::star::uno::RuntimeException
);
278 virtual sal_Bool SAL_CALL
hasElements( ) throw(::com::sun::star::uno::RuntimeException
);
280 // ::com::sun::star::util::XRefreshable
281 virtual void SAL_CALL
refresh( ) throw(::com::sun::star::uno::RuntimeException
);
282 virtual void SAL_CALL
addRefreshListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XRefreshListener
>& l
) throw(::com::sun::star::uno::RuntimeException
);
283 virtual void SAL_CALL
removeRefreshListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XRefreshListener
>& l
) throw(::com::sun::star::uno::RuntimeException
);
286 virtual rtl::OUString SAL_CALL
getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException
);
287 virtual BOOL SAL_CALL
supportsService(const rtl::OUString
& ServiceName
) throw( ::com::sun::star::uno::RuntimeException
);
288 virtual ::com::sun::star::uno::Sequence
< rtl::OUString
> SAL_CALL
getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException
);
291 virtual void Invalidate();
294 /* -----------------21.12.98 14:49-------------------
296 * --------------------------------------------------*/
297 class SwXFieldEnumeration
: public cppu::WeakImplHelper2
299 ::com::sun::star::container::XEnumeration
,
300 ::com::sun::star::lang::XServiceInfo
304 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextField
> > aItems
;
305 sal_Int32 nNextIndex
; // index of next element to be returned
310 virtual ~SwXFieldEnumeration();
312 SwXFieldEnumeration(SwDoc
* pDoc
);
315 virtual BOOL SAL_CALL
hasMoreElements(void) throw( ::com::sun::star::uno::RuntimeException
);
316 virtual ::com::sun::star::uno::Any SAL_CALL
nextElement(void) throw( ::com::sun::star::container::NoSuchElementException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
319 virtual rtl::OUString SAL_CALL
getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException
);
320 virtual BOOL SAL_CALL
supportsService(const rtl::OUString
& ServiceName
) throw( ::com::sun::star::uno::RuntimeException
);
321 virtual ::com::sun::star::uno::Sequence
< rtl::OUString
> SAL_CALL
getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException
);
324 virtual void Modify( SfxPoolItem
*pOld
, SfxPoolItem
*pNew
);