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>
47 class SwTextAPIObject
;
49 /* -----------------04.12.98 12:49-------------------
51 * --------------------------------------------------*/
52 class SwXFieldMaster
: public cppu::WeakImplHelper4
54 ::com::sun::star::beans::XPropertySet
,
55 ::com::sun::star::lang::XServiceInfo
,
56 ::com::sun::star::lang::XUnoTunnel
,
57 ::com::sun::star::lang::XComponent
61 SwEventListenerContainer aLstnrCntnr
;
62 sal_uInt16 nResTypeId
;
65 sal_Bool m_bIsDescriptor
;
67 String sParam1
; //Content / Database / NumberingSeparator
68 String sParam2
; // - /DataTablename
69 String sParam3
; // - /DataFieldName
71 String sParam5
; // - /DataBaseURL
72 String sParam6
; // - /DataBaseResource
73 double fParam1
; // Value / -
74 sal_Int8 nParam1
; // ChapterNumberingLevel
75 sal_Bool bParam1
; // IsExpression
79 virtual ~SwXFieldMaster();
82 SwXFieldMaster(SwDoc
* pDoc
, sal_uInt16 nResId
);
83 SwXFieldMaster(SwFieldType
& rType
, SwDoc
* pDoc
);
88 static const ::com::sun::star::uno::Sequence
< sal_Int8
> & getUnoTunnelId();
91 virtual sal_Int64 SAL_CALL
getSomething( const ::com::sun::star::uno::Sequence
< sal_Int8
>& aIdentifier
) throw(::com::sun::star::uno::RuntimeException
);
94 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException
);
95 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
);
96 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
);
97 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
);
98 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
);
99 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
);
100 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
);
103 virtual void SAL_CALL
dispose(void) throw( ::com::sun::star::uno::RuntimeException
);
104 virtual void SAL_CALL
addEventListener(const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
> & aListener
) throw( ::com::sun::star::uno::RuntimeException
);
105 virtual void SAL_CALL
removeEventListener(const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
> & aListener
) throw( ::com::sun::star::uno::RuntimeException
);
108 virtual rtl::OUString SAL_CALL
getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException
);
109 virtual BOOL SAL_CALL
supportsService(const rtl::OUString
& ServiceName
) throw( ::com::sun::star::uno::RuntimeException
);
110 virtual ::com::sun::star::uno::Sequence
< rtl::OUString
> SAL_CALL
getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException
);
113 virtual void Modify( SfxPoolItem
*pOld
, SfxPoolItem
*pNew
);
115 static rtl::OUString
GetProgrammaticName(const SwFieldType
& rType
, SwDoc
& rDoc
);
116 static rtl::OUString
LocalizeFormula(const SwSetExpField
& rFld
, const rtl::OUString
& rFormula
, sal_Bool bQuery
);
118 SwFieldType
* GetFldType(sal_Bool bDontCreate
= sal_False
) const;
119 SwDoc
* GetDoc() {return m_pDoc
;}
121 sal_Bool
IsDescriptor()const {return m_bIsDescriptor
;}
122 sal_uInt16
GetResId() const {return nResTypeId
;}
125 /* -----------------04.12.98 12:49-------------------
127 * --------------------------------------------------*/
128 struct SwFieldProperties_Impl
;
129 class SwXTextField
: public cppu::WeakImplHelper5
131 ::com::sun::star::text::XDependentTextField
,
132 ::com::sun::star::lang::XServiceInfo
,
133 ::com::sun::star::beans::XPropertySet
,
134 ::com::sun::star::lang::XUnoTunnel
,
135 ::com::sun::star::util::XUpdatable
139 SwEventListenerContainer aLstnrCntnr
;
140 const SwFmtFld
* pFmtFld
;
142 SwTextAPIObject
* m_pTextObject
;
144 sal_Bool m_bIsDescriptor
;
145 SwClient m_aFieldTypeClient
; // required to access field master of not yet inserted fields
146 sal_Bool m_bCallUpdate
;
147 sal_uInt16 m_nServiceId
;
148 SwFieldProperties_Impl
* m_pProps
;
152 //SwFieldType* GetFldType() const { return (SwFieldType*)GetRegisteredIn(); }
153 SwDoc
* GetDoc() {return m_pDoc
;}
155 virtual ~SwXTextField();
157 SwXTextField(sal_uInt16 nServiceId
, SwDoc
* pDoc
=0);
158 SwXTextField(const SwFmtFld
& rFmt
, SwDoc
* pDoc
);
163 static const ::com::sun::star::uno::Sequence
< sal_Int8
> & getUnoTunnelId();
166 virtual sal_Int64 SAL_CALL
getSomething( const ::com::sun::star::uno::Sequence
< sal_Int8
>& aIdentifier
) throw(::com::sun::star::uno::RuntimeException
);
168 //XDependentTextField
169 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
);
170 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> SAL_CALL
getTextFieldMaster(void) throw( ::com::sun::star::uno::RuntimeException
);
173 virtual rtl::OUString SAL_CALL
getPresentation(sal_Bool bShowCommand
) throw( ::com::sun::star::uno::RuntimeException
);
176 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
);
177 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextRange
> SAL_CALL
getAnchor(void) throw( ::com::sun::star::uno::RuntimeException
);
180 virtual void SAL_CALL
dispose(void) throw( ::com::sun::star::uno::RuntimeException
);
181 virtual void SAL_CALL
addEventListener(const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
> & aListener
) throw( ::com::sun::star::uno::RuntimeException
);
182 virtual void SAL_CALL
removeEventListener(const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
> & aListener
) throw( ::com::sun::star::uno::RuntimeException
);
185 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException
);
186 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
);
187 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
);
188 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
);
189 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
);
190 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
);
191 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
);
194 virtual rtl::OUString SAL_CALL
getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException
);
195 virtual BOOL SAL_CALL
supportsService(const rtl::OUString
& ServiceName
) throw( ::com::sun::star::uno::RuntimeException
);
196 virtual ::com::sun::star::uno::Sequence
< rtl::OUString
> SAL_CALL
getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException
);
199 virtual void SAL_CALL
update( ) throw (::com::sun::star::uno::RuntimeException
);
202 virtual void Modify( SfxPoolItem
*pOld
, SfxPoolItem
*pNew
);
204 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
);
206 const SwField
* GetField() const;
207 const SwFmtFld
* GetFldFmt(){return GetField() ? pFmtFld
: 0; };
211 /* -----------------21.12.98 10:26-------------------
213 * --------------------------------------------------*/
215 cppu::WeakImplHelper2
217 ::com::sun::star::container::XNameAccess
,
218 ::com::sun::star::lang::XServiceInfo
220 SwXTextFieldMastersBaseClass
;
221 class SwXTextFieldMasters
: public SwXTextFieldMastersBaseClass
,
222 public SwUnoCollection
225 virtual ~SwXTextFieldMasters();
227 SwXTextFieldMasters(SwDoc
* pDoc
);
231 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
);
232 virtual ::com::sun::star::uno::Sequence
< rtl::OUString
> SAL_CALL
getElementNames(void) throw( ::com::sun::star::uno::RuntimeException
);
233 virtual sal_Bool SAL_CALL
hasByName(const rtl::OUString
& Name
) throw( ::com::sun::star::uno::RuntimeException
);
236 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType( ) throw(::com::sun::star::uno::RuntimeException
);
237 virtual sal_Bool SAL_CALL
hasElements( ) throw(::com::sun::star::uno::RuntimeException
);
240 virtual rtl::OUString SAL_CALL
getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException
);
241 virtual BOOL SAL_CALL
supportsService(const rtl::OUString
& ServiceName
) throw( ::com::sun::star::uno::RuntimeException
);
242 virtual ::com::sun::star::uno::Sequence
< rtl::OUString
> SAL_CALL
getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException
);
245 static sal_Bool
getInstanceName(const SwFieldType
& rFldType
, String
& rName
);
248 /* -----------------21.12.98 10:26-------------------
250 * --------------------------------------------------*/
252 cppu::WeakImplHelper3
254 ::com::sun::star::container::XEnumerationAccess
,
255 ::com::sun::star::lang::XServiceInfo
,
256 ::com::sun::star::util::XRefreshable
258 SwXTextFieldTypesBaseClass
;
259 class SwXTextFieldTypes
: public SwXTextFieldTypesBaseClass
,
260 public SwUnoCollection
262 SwRefreshListenerContainer aRefreshCont
;
264 virtual ~SwXTextFieldTypes();
266 SwXTextFieldTypes(SwDoc
* pDoc
);
270 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XEnumeration
> SAL_CALL
createEnumeration(void) throw( ::com::sun::star::uno::RuntimeException
);
273 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType( ) throw(::com::sun::star::uno::RuntimeException
);
274 virtual sal_Bool SAL_CALL
hasElements( ) throw(::com::sun::star::uno::RuntimeException
);
276 // ::com::sun::star::util::XRefreshable
277 virtual void SAL_CALL
refresh( ) throw(::com::sun::star::uno::RuntimeException
);
278 virtual void SAL_CALL
addRefreshListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XRefreshListener
>& l
) throw(::com::sun::star::uno::RuntimeException
);
279 virtual void SAL_CALL
removeRefreshListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XRefreshListener
>& l
) throw(::com::sun::star::uno::RuntimeException
);
282 virtual rtl::OUString SAL_CALL
getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException
);
283 virtual BOOL SAL_CALL
supportsService(const rtl::OUString
& ServiceName
) throw( ::com::sun::star::uno::RuntimeException
);
284 virtual ::com::sun::star::uno::Sequence
< rtl::OUString
> SAL_CALL
getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException
);
287 virtual void Invalidate();
290 /* -----------------21.12.98 14:49-------------------
292 * --------------------------------------------------*/
293 class SwXFieldEnumeration
: public cppu::WeakImplHelper2
295 ::com::sun::star::container::XEnumeration
,
296 ::com::sun::star::lang::XServiceInfo
300 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextField
> > aItems
;
301 sal_Int32 nNextIndex
; // index of next element to be returned
306 virtual ~SwXFieldEnumeration();
308 SwXFieldEnumeration(SwDoc
* pDoc
);
311 virtual BOOL SAL_CALL
hasMoreElements(void) throw( ::com::sun::star::uno::RuntimeException
);
312 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
);
315 virtual rtl::OUString SAL_CALL
getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException
);
316 virtual BOOL SAL_CALL
supportsService(const rtl::OUString
& ServiceName
) throw( ::com::sun::star::uno::RuntimeException
);
317 virtual ::com::sun::star::uno::Sequence
< rtl::OUString
> SAL_CALL
getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException
);
320 virtual void Modify( SfxPoolItem
*pOld
, SfxPoolItem
*pNew
);