Update ooo320-m1
[ooovba.git] / sw / inc / unofield.hxx
blobabbd3f9e8ff8cab22c9050da3bf59843e45ad5a8
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unofield.hxx,v $
10 * $Revision: 1.20 $
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 ************************************************************************/
30 #ifndef _UNOFIELD_HXX
31 #define _UNOFIELD_HXX
33 #include <com/sun/star/text/XDependentTextField.hpp>
34 #include <com/sun/star/util/XRefreshable.hpp>
35 #include <com/sun/star/util/XUpdatable.hpp>
36 #include <calbck.hxx>
37 #include <unoobj.hxx>
38 #include <unocoll.hxx>
39 #include <RefreshListenerContainer.hxx>
41 class SwFieldType;
42 class SwDoc;
43 class SwFmtFld;
44 class SwField;
45 class SwSetExpField;
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
58 public SwClient
60 SwEventListenerContainer aLstnrCntnr;
61 sal_uInt16 nResTypeId;
62 SwDoc* m_pDoc;
64 sal_Bool m_bIsDescriptor;
66 String sParam1; //Content / Database / NumberingSeparator
67 String sParam2; // - /DataTablename
68 String sParam3; // - /DataFieldName
69 String sParam4;
70 String sParam5; // - /DataBaseURL
71 String sParam6; // - /DataBaseResource
72 double fParam1; // Value / -
73 sal_Int8 nParam1; // ChapterNumberingLevel
74 sal_Bool bParam1; // IsExpression
75 sal_Int32 nParam2;
77 protected:
78 virtual ~SwXFieldMaster();
79 public:
81 SwXFieldMaster(SwDoc* pDoc, sal_uInt16 nResId);
82 SwXFieldMaster(SwFieldType& rType, SwDoc* pDoc);
85 TYPEINFO();
87 static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId();
89 //XUnoTunnel
90 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
92 //XPropertySet
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);
101 //XComponent
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 );
106 //XServiceInfo
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 );
111 //SwClient
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
136 public SwClient
138 SwEventListenerContainer aLstnrCntnr;
139 const SwFmtFld* pFmtFld;
140 SwDoc* m_pDoc;
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;
148 String m_sTypeName;
151 //SwFieldType* GetFldType() const { return (SwFieldType*)GetRegisteredIn(); }
152 SwDoc* GetDoc() {return m_pDoc;}
153 protected:
154 virtual ~SwXTextField();
155 public:
156 SwXTextField(sal_uInt16 nServiceId, SwDoc* pDoc=0);
157 SwXTextField(const SwFmtFld& rFmt, SwDoc* pDoc);
160 TYPEINFO();
162 static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId();
164 //XUnoTunnel
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 );
171 //XTextField
172 virtual rtl::OUString SAL_CALL getPresentation(sal_Bool bShowCommand) throw( ::com::sun::star::uno::RuntimeException );
174 //XTextContent
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 );
178 //XComponent
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 );
183 //XPropertySet
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);
192 //XServiceInfo
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 );
197 //XUpdatable
198 virtual void SAL_CALL update( ) throw (::com::sun::star::uno::RuntimeException);
200 //SwClient
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; };
208 void Invalidate();
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 * --------------------------------------------------*/
218 typedef
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
228 protected:
229 virtual ~SwXTextFieldMasters();
230 public:
231 SwXTextFieldMasters(SwDoc* pDoc);
234 //XNameAccess
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 );
239 //XElementAccess
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);
243 //XServiceInfo
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 * --------------------------------------------------*/
255 typedef
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;
267 protected:
268 virtual ~SwXTextFieldTypes();
269 public:
270 SwXTextFieldTypes(SwDoc* pDoc);
273 //XEnumerationAccess
274 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration(void) throw( ::com::sun::star::uno::RuntimeException );
276 //XElementAccess
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);
285 //XServiceInfo
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 );
290 // SwUnoCollection
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
302 public SwClient
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
307 SwDoc* pDoc;
309 protected:
310 virtual ~SwXFieldEnumeration();
311 public:
312 SwXFieldEnumeration(SwDoc* pDoc);
314 //XEnumeration
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 );
318 //XServiceInfo
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 );
323 //SwClient
324 virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew);
326 #endif