Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
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/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
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 .
18 : : */
19 : : #ifndef _UNOFIELD_HXX
20 : : #define _UNOFIELD_HXX
21 : :
22 : : #include <com/sun/star/lang/XUnoTunnel.hpp>
23 : : #include <com/sun/star/util/XRefreshable.hpp>
24 : : #include <com/sun/star/util/XUpdatable.hpp>
25 : : #include <com/sun/star/text/XDependentTextField.hpp>
26 : :
27 : : #include <cppuhelper/implbase5.hxx>
28 : :
29 : : #include <calbck.hxx>
30 : : #include <unocoll.hxx>
31 : : #include <RefreshListenerContainer.hxx>
32 : :
33 : :
34 : : class SwFieldType;
35 : : class SwDoc;
36 : : class SwFmtFld;
37 : : class SwField;
38 : : class SwSetExpField;
39 : : class SwTextAPIObject;
40 : :
41 : : class SwXFieldMaster : public cppu::WeakImplHelper4
42 : : <
43 : : ::com::sun::star::beans::XPropertySet,
44 : : ::com::sun::star::lang::XServiceInfo,
45 : : ::com::sun::star::lang::XUnoTunnel,
46 : : ::com::sun::star::lang::XComponent
47 : : >,
48 : : public SwClient
49 : : {
50 : : SwEventListenerContainer aLstnrCntnr;
51 : : sal_uInt16 nResTypeId;
52 : : SwDoc* m_pDoc;
53 : :
54 : : sal_Bool m_bIsDescriptor;
55 : :
56 : : String sParam1; //Content / Database / NumberingSeparator
57 : : String sParam2; // - /DataTablename
58 : : String sParam3; // - /DataFieldName
59 : : String sParam4;
60 : : String sParam5; // - /DataBaseURL
61 : : String sParam6; // - /DataBaseResource
62 : : double fParam1; // Value / -
63 : : sal_Int8 nParam1; // ChapterNumberingLevel
64 : : sal_Bool bParam1; // IsExpression
65 : : sal_Int32 nParam2;
66 : :
67 : : protected:
68 : : virtual ~SwXFieldMaster();
69 : : //SwClient
70 : : virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew);
71 : :
72 : : public:
73 : :
74 : : SwXFieldMaster(SwDoc* pDoc, sal_uInt16 nResId);
75 : : SwXFieldMaster(SwFieldType& rType, SwDoc* pDoc);
76 : :
77 : :
78 : : TYPEINFO();
79 : :
80 : : static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId();
81 : :
82 : : //XUnoTunnel
83 : : virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
84 : :
85 : : //XPropertySet
86 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
87 : : 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);
88 : : 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);
89 : : 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);
90 : : 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);
91 : : 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);
92 : : 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);
93 : :
94 : : //XComponent
95 : : virtual void SAL_CALL dispose(void) throw( ::com::sun::star::uno::RuntimeException );
96 : : virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException );
97 : : virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException );
98 : :
99 : : //XServiceInfo
100 : : virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException );
101 : : virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException );
102 : : virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException );
103 : :
104 : : static rtl::OUString GetProgrammaticName(const SwFieldType& rType, SwDoc& rDoc);
105 : : static rtl::OUString LocalizeFormula(const SwSetExpField& rFld, const rtl::OUString& rFormula, sal_Bool bQuery);
106 : :
107 : : SwFieldType* GetFldType(sal_Bool bDontCreate = sal_False) const;
108 : 3 : SwDoc* GetDoc() {return m_pDoc;}
109 : :
110 : : sal_Bool IsDescriptor()const {return m_bIsDescriptor;}
111 : : };
112 : :
113 : : struct SwFieldProperties_Impl;
114 : : class SwXTextField : public cppu::WeakImplHelper5
115 : : <
116 : : ::com::sun::star::text::XDependentTextField,
117 : : ::com::sun::star::lang::XServiceInfo,
118 : : ::com::sun::star::beans::XPropertySet,
119 : : ::com::sun::star::lang::XUnoTunnel,
120 : : ::com::sun::star::util::XUpdatable
121 : : >,
122 : : public SwClient
123 : : {
124 : : SwEventListenerContainer aLstnrCntnr;
125 : : const SwFmtFld* pFmtFld;
126 : : SwDoc* m_pDoc;
127 : : SwTextAPIObject* m_pTextObject;
128 : :
129 : : sal_Bool m_bIsDescriptor;
130 : : SwClient m_aFieldTypeClient; // required to access field master of not yet inserted fields
131 : : sal_Bool m_bCallUpdate;
132 : : sal_uInt16 m_nServiceId;
133 : : SwFieldProperties_Impl* m_pProps;
134 : : String m_sTypeName;
135 : :
136 : :
137 : : //SwFieldType* GetFldType() const { return (SwFieldType*)GetRegisteredIn(); }
138 : 151 : SwDoc* GetDoc() {return m_pDoc;}
139 : : protected:
140 : : virtual ~SwXTextField();
141 : : //SwClient
142 : : virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew);
143 : :
144 : : public:
145 : : SwXTextField(sal_uInt16 nServiceId, SwDoc* pDoc=0);
146 : : SwXTextField(const SwFmtFld& rFmt, SwDoc* pDoc);
147 : :
148 : :
149 : : TYPEINFO();
150 : :
151 : : static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId();
152 : :
153 : : //XUnoTunnel
154 : : virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
155 : :
156 : : //XDependentTextField
157 : : 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 );
158 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL getTextFieldMaster(void) throw( ::com::sun::star::uno::RuntimeException );
159 : :
160 : : //XTextField
161 : : virtual rtl::OUString SAL_CALL getPresentation(sal_Bool bShowCommand) throw( ::com::sun::star::uno::RuntimeException );
162 : :
163 : : //XTextContent
164 : : 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 );
165 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getAnchor(void) throw( ::com::sun::star::uno::RuntimeException );
166 : :
167 : : //XComponent
168 : : virtual void SAL_CALL dispose(void) throw( ::com::sun::star::uno::RuntimeException );
169 : : virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException );
170 : : virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException );
171 : :
172 : : //XPropertySet
173 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
174 : : 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);
175 : : 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);
176 : : 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);
177 : : 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);
178 : : 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);
179 : : 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);
180 : :
181 : : //XServiceInfo
182 : : virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException );
183 : : virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException );
184 : : virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException );
185 : :
186 : : //XUpdatable
187 : : virtual void SAL_CALL update( ) throw (::com::sun::star::uno::RuntimeException);
188 : :
189 : : 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 );
190 : :
191 : : const SwField* GetField() const;
192 [ # # ]: 0 : const SwFmtFld* GetFldFmt(){return GetField() ? pFmtFld : 0; };
193 : :
194 : : void Invalidate();
195 : :
196 : : /// @return an SwXTextField, either an already existing one or a new one
197 : : static SwXTextField* CreateSwXTextField(SwDoc & rDoc, SwFmtFld const& rFmt);
198 : : sal_uInt16 GetServiceId();
199 : : };
200 : :
201 : : typedef
202 : : cppu::WeakImplHelper2
203 : : <
204 : : ::com::sun::star::container::XNameAccess,
205 : : ::com::sun::star::lang::XServiceInfo
206 : : >
207 : : SwXTextFieldMastersBaseClass;
208 : : class SwXTextFieldMasters : public SwXTextFieldMastersBaseClass,
209 : : public SwUnoCollection
210 : : {
211 : : protected:
212 : : virtual ~SwXTextFieldMasters();
213 : : public:
214 : : SwXTextFieldMasters(SwDoc* pDoc);
215 : :
216 : :
217 : : //XNameAccess
218 : : 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 );
219 : : virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getElementNames(void) throw( ::com::sun::star::uno::RuntimeException );
220 : : virtual sal_Bool SAL_CALL hasByName(const rtl::OUString& Name) throw( ::com::sun::star::uno::RuntimeException );
221 : :
222 : : //XElementAccess
223 : : virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException);
224 : : virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException);
225 : :
226 : : //XServiceInfo
227 : : virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException );
228 : : virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException );
229 : : virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException );
230 : :
231 : :
232 : : static sal_Bool getInstanceName(const SwFieldType& rFldType, String& rName);
233 : : };
234 : :
235 : : typedef
236 : : cppu::WeakImplHelper3
237 : : <
238 : : ::com::sun::star::container::XEnumerationAccess,
239 : : ::com::sun::star::lang::XServiceInfo,
240 : : ::com::sun::star::util::XRefreshable
241 : : >
242 : : SwXTextFieldTypesBaseClass;
243 : : class SwXTextFieldTypes : public SwXTextFieldTypesBaseClass,
244 : : public SwUnoCollection
245 : : {
246 : : SwRefreshListenerContainer aRefreshCont;
247 : : protected:
248 : : virtual ~SwXTextFieldTypes();
249 : : public:
250 : : SwXTextFieldTypes(SwDoc* pDoc);
251 : :
252 : :
253 : : //XEnumerationAccess
254 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration(void) throw( ::com::sun::star::uno::RuntimeException );
255 : :
256 : : //XElementAccess
257 : : virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException);
258 : : virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException);
259 : :
260 : : // ::com::sun::star::util::XRefreshable
261 : : virtual void SAL_CALL refresh( ) throw(::com::sun::star::uno::RuntimeException);
262 : : virtual void SAL_CALL addRefreshListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XRefreshListener >& l ) throw(::com::sun::star::uno::RuntimeException);
263 : : virtual void SAL_CALL removeRefreshListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XRefreshListener >& l ) throw(::com::sun::star::uno::RuntimeException);
264 : :
265 : : //XServiceInfo
266 : : virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException );
267 : : virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException );
268 : : virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException );
269 : :
270 : : // SwUnoCollection
271 : : virtual void Invalidate();
272 : : };
273 : :
274 : : class SwXFieldEnumeration : public cppu::WeakImplHelper2
275 : : <
276 : : ::com::sun::star::container::XEnumeration,
277 : : ::com::sun::star::lang::XServiceInfo
278 : : >,
279 : : public SwClient
280 : : {
281 : : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextField > > aItems;
282 : : sal_Int32 nNextIndex; // index of next element to be returned
283 : :
284 : : SwDoc* pDoc;
285 : :
286 : : protected:
287 : : virtual ~SwXFieldEnumeration();
288 : : //SwClient
289 : : virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew);
290 : : public:
291 : : SwXFieldEnumeration(SwDoc* pDoc);
292 : :
293 : : //XEnumeration
294 : : virtual sal_Bool SAL_CALL hasMoreElements(void) throw( ::com::sun::star::uno::RuntimeException );
295 : : 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 );
296 : :
297 : : //XServiceInfo
298 : : virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException );
299 : : virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException );
300 : : virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException );
301 : :
302 : : };
303 : : #endif
304 : :
305 : :
306 : :
307 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|