merge the formfield patch from ooo-build
[ooovba.git] / sc / inc / fielduno.hxx
blobc09a1b66c1ee9db5f1d8bba6214932c31992eda3
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: fielduno.hxx,v $
10 * $Revision: 1.8.32.2 $
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 ************************************************************************/
31 #ifndef SC_FIELDUNO_HXX
32 #define SC_FIELDUNO_HXX
34 #include "address.hxx"
35 #include "mutexhlp.hxx"
37 #include <svtools/lstner.hxx>
38 #include <svtools/itemprop.hxx>
39 #include <svx/editdata.hxx>
40 #include <com/sun/star/text/XTextField.hpp>
41 #include <com/sun/star/lang/XServiceInfo.hpp>
42 #include <com/sun/star/container/XContainer.hpp>
43 #include <com/sun/star/lang/XUnoTunnel.hpp>
44 #include <com/sun/star/container/XEnumerationAccess.hpp>
45 #include <com/sun/star/container/XIndexAccess.hpp>
46 #include <com/sun/star/beans/XPropertySet.hpp>
47 #include <com/sun/star/util/XRefreshable.hpp>
48 #include <cppuhelper/component.hxx>
49 #include <cppuhelper/implbase5.hxx>
50 #include <osl/mutex.hxx>
52 class SvxEditSource;
53 class SvxFieldItem;
54 class ScCellFieldObj;
55 class ScHeaderFieldObj;
56 class ScHeaderFooterContentObj;
57 class ScDocShell;
60 //------------------------------------------------------------------
63 class ScCellFieldsObj : public cppu::WeakImplHelper5<
64 com::sun::star::container::XEnumerationAccess,
65 com::sun::star::container::XIndexAccess,
66 com::sun::star::container::XContainer,
67 com::sun::star::util::XRefreshable,
68 com::sun::star::lang::XServiceInfo >,
69 public SfxListener
71 private:
72 ScDocShell* pDocShell;
73 ScAddress aCellPos;
74 SvxEditSource* pEditSource;
75 /// List of refresh listeners.
76 cppu::OInterfaceContainerHelper* mpRefreshListeners;
77 /// mutex to lock the InterfaceContainerHelper
78 osl::Mutex aMutex;
80 ScCellFieldObj* GetObjectByIndex_Impl(INT32 Index) const;
82 public:
83 ScCellFieldsObj(ScDocShell* pDocSh, const ScAddress& rPos);
84 virtual ~ScCellFieldsObj();
86 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
88 // XIndexAccess
89 virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException);
90 virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index )
91 throw(::com::sun::star::lang::IndexOutOfBoundsException,
92 ::com::sun::star::lang::WrappedTargetException,
93 ::com::sun::star::uno::RuntimeException);
95 // XEnumerationAccess
96 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL
97 createEnumeration() throw(::com::sun::star::uno::RuntimeException);
99 // XElementAccess
100 virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
101 throw(::com::sun::star::uno::RuntimeException);
102 virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
104 // XContainer
105 virtual void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference<
106 ::com::sun::star::container::XContainerListener >& xListener )
107 throw(::com::sun::star::uno::RuntimeException);
108 virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference<
109 ::com::sun::star::container::XContainerListener >& xListener )
110 throw(::com::sun::star::uno::RuntimeException);
112 // XRefreshable
113 virtual void SAL_CALL refresh( )
114 throw (::com::sun::star::uno::RuntimeException);
115 virtual void SAL_CALL addRefreshListener( const ::com::sun::star::uno::Reference<
116 ::com::sun::star::util::XRefreshListener >& l )
117 throw (::com::sun::star::uno::RuntimeException);
118 virtual void SAL_CALL removeRefreshListener( const ::com::sun::star::uno::Reference<
119 ::com::sun::star::util::XRefreshListener >& l )
120 throw (::com::sun::star::uno::RuntimeException);
122 // XServiceInfo
123 virtual ::rtl::OUString SAL_CALL getImplementationName()
124 throw(::com::sun::star::uno::RuntimeException);
125 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
126 throw(::com::sun::star::uno::RuntimeException);
127 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
128 throw(::com::sun::star::uno::RuntimeException);
132 class ScCellFieldObj : public ScMutexHelper,
133 public ::cppu::OComponentHelper,
134 public ::com::sun::star::text::XTextField,
135 public ::com::sun::star::beans::XPropertySet,
136 public ::com::sun::star::lang::XUnoTunnel,
137 public ::com::sun::star::lang::XServiceInfo,
138 public SfxListener
140 private:
141 const SfxItemPropertySet* pPropSet;
142 ScDocShell* pDocShell;
143 ScAddress aCellPos;
144 SvxEditSource* pEditSource;
145 ESelection aSelection;
147 String aUrl; // Inhalt, wenn noch nicht eingefuegt (nur dann!)
148 String aRepresentation;
149 String aTarget;
151 ScCellFieldObj(); // disabled
152 public:
153 ScCellFieldObj(ScDocShell* pDocSh, const ScAddress& rPos,
154 const ESelection& rSel);
155 virtual ~ScCellFieldObj();
157 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
159 // per getImplementation gerufen:
160 void DeleteField();
161 BOOL IsInserted() const { return pEditSource != NULL; }
162 SvxFieldItem CreateFieldItem();
163 void InitDoc( ScDocShell* pDocSh, const ScAddress& rPos,
164 const ESelection& rSel );
166 virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation(
167 const ::com::sun::star::uno::Type & rType )
168 throw(::com::sun::star::uno::RuntimeException);
169 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
170 const ::com::sun::star::uno::Type & rType )
171 throw(::com::sun::star::uno::RuntimeException);
172 virtual void SAL_CALL acquire() throw();
173 virtual void SAL_CALL release() throw();
175 // XTextField
176 virtual ::rtl::OUString SAL_CALL getPresentation( sal_Bool bShowCommand )
177 throw(::com::sun::star::uno::RuntimeException);
179 // XTextContent
180 virtual void SAL_CALL attach( const ::com::sun::star::uno::Reference<
181 ::com::sun::star::text::XTextRange >& xTextRange )
182 throw(::com::sun::star::lang::IllegalArgumentException,
183 ::com::sun::star::uno::RuntimeException);
184 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL
185 getAnchor() throw(::com::sun::star::uno::RuntimeException);
187 // XComponent
188 virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException);
189 virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference<
190 ::com::sun::star::lang::XEventListener >& xListener )
191 throw(::com::sun::star::uno::RuntimeException);
192 virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference<
193 ::com::sun::star::lang::XEventListener >& aListener )
194 throw(::com::sun::star::uno::RuntimeException);
196 // XPropertySet
197 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
198 SAL_CALL getPropertySetInfo()
199 throw(::com::sun::star::uno::RuntimeException);
200 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName,
201 const ::com::sun::star::uno::Any& aValue )
202 throw(::com::sun::star::beans::UnknownPropertyException,
203 ::com::sun::star::beans::PropertyVetoException,
204 ::com::sun::star::lang::IllegalArgumentException,
205 ::com::sun::star::lang::WrappedTargetException,
206 ::com::sun::star::uno::RuntimeException);
207 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
208 const ::rtl::OUString& PropertyName )
209 throw(::com::sun::star::beans::UnknownPropertyException,
210 ::com::sun::star::lang::WrappedTargetException,
211 ::com::sun::star::uno::RuntimeException);
212 virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
213 const ::com::sun::star::uno::Reference<
214 ::com::sun::star::beans::XPropertyChangeListener >& xListener )
215 throw(::com::sun::star::beans::UnknownPropertyException,
216 ::com::sun::star::lang::WrappedTargetException,
217 ::com::sun::star::uno::RuntimeException);
218 virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
219 const ::com::sun::star::uno::Reference<
220 ::com::sun::star::beans::XPropertyChangeListener >& aListener )
221 throw(::com::sun::star::beans::UnknownPropertyException,
222 ::com::sun::star::lang::WrappedTargetException,
223 ::com::sun::star::uno::RuntimeException);
224 virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName,
225 const ::com::sun::star::uno::Reference<
226 ::com::sun::star::beans::XVetoableChangeListener >& aListener )
227 throw(::com::sun::star::beans::UnknownPropertyException,
228 ::com::sun::star::lang::WrappedTargetException,
229 ::com::sun::star::uno::RuntimeException);
230 virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName,
231 const ::com::sun::star::uno::Reference<
232 ::com::sun::star::beans::XVetoableChangeListener >& aListener )
233 throw(::com::sun::star::beans::UnknownPropertyException,
234 ::com::sun::star::lang::WrappedTargetException,
235 ::com::sun::star::uno::RuntimeException);
237 // XUnoTunnel
238 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
239 sal_Int8 >& aIdentifier )
240 throw(::com::sun::star::uno::RuntimeException);
242 static const com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId();
243 static ScCellFieldObj* getImplementation( const com::sun::star::uno::Reference<
244 com::sun::star::text::XTextContent> xObj );
246 // XServiceInfo
247 virtual ::rtl::OUString SAL_CALL getImplementationName()
248 throw(::com::sun::star::uno::RuntimeException);
249 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
250 throw(::com::sun::star::uno::RuntimeException);
251 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
252 throw(::com::sun::star::uno::RuntimeException);
254 // XTypeProvider
255 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes()
256 throw(::com::sun::star::uno::RuntimeException);
257 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
258 throw(::com::sun::star::uno::RuntimeException);
261 //------------------------------------------------------------------
263 class ScHeaderFieldsObj : public cppu::WeakImplHelper5<
264 com::sun::star::container::XEnumerationAccess,
265 com::sun::star::container::XIndexAccess,
266 com::sun::star::container::XContainer,
267 com::sun::star::util::XRefreshable,
268 com::sun::star::lang::XServiceInfo >
270 private:
271 ScHeaderFooterContentObj* pContentObj;
272 USHORT nPart;
273 UINT16 nType;
274 SvxEditSource* pEditSource;
276 /// List of refresh listeners.
277 cppu::OInterfaceContainerHelper* mpRefreshListeners;
278 /// mutex to lock the InterfaceContainerHelper
279 osl::Mutex aMutex;
281 ScHeaderFieldObj* GetObjectByIndex_Impl(INT32 Index) const;
283 public:
284 ScHeaderFieldsObj(ScHeaderFooterContentObj* pContent,
285 USHORT nP, USHORT nT);
286 virtual ~ScHeaderFieldsObj();
288 // XIndexAccess
289 virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException);
290 virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index )
291 throw(::com::sun::star::lang::IndexOutOfBoundsException,
292 ::com::sun::star::lang::WrappedTargetException,
293 ::com::sun::star::uno::RuntimeException);
295 // XEnumerationAccess
296 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL
297 createEnumeration() throw(::com::sun::star::uno::RuntimeException);
299 // XElementAccess
300 virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
301 throw(::com::sun::star::uno::RuntimeException);
302 virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
304 // XContainer
305 virtual void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference<
306 ::com::sun::star::container::XContainerListener >& xListener )
307 throw(::com::sun::star::uno::RuntimeException);
308 virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference<
309 ::com::sun::star::container::XContainerListener >& xListener )
310 throw(::com::sun::star::uno::RuntimeException);
312 // XRefreshable
313 virtual void SAL_CALL refresh( )
314 throw (::com::sun::star::uno::RuntimeException);
315 virtual void SAL_CALL addRefreshListener( const ::com::sun::star::uno::Reference<
316 ::com::sun::star::util::XRefreshListener >& l )
317 throw (::com::sun::star::uno::RuntimeException);
318 virtual void SAL_CALL removeRefreshListener( const ::com::sun::star::uno::Reference<
319 ::com::sun::star::util::XRefreshListener >& l )
320 throw (::com::sun::star::uno::RuntimeException);
322 // XServiceInfo
323 virtual ::rtl::OUString SAL_CALL getImplementationName()
324 throw(::com::sun::star::uno::RuntimeException);
325 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
326 throw(::com::sun::star::uno::RuntimeException);
327 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
328 throw(::com::sun::star::uno::RuntimeException);
332 class ScHeaderFieldObj : public ScMutexHelper,
333 public ::cppu::OComponentHelper,
334 public ::com::sun::star::text::XTextField,
335 public ::com::sun::star::beans::XPropertySet,
336 public ::com::sun::star::lang::XUnoTunnel,
337 public ::com::sun::star::lang::XServiceInfo
339 private:
340 const SfxItemPropertySet* pPropSet;
341 ScHeaderFooterContentObj* pContentObj;
342 USHORT nPart;
343 UINT16 nType;
344 SvxEditSource* pEditSource;
345 ESelection aSelection;
346 sal_Int16 nFileFormat; // enum SvxFileFormat, valid if not inserted
348 ScHeaderFieldObj(); // disabled
349 public:
350 ScHeaderFieldObj(ScHeaderFooterContentObj* pContent, USHORT nP,
351 USHORT nT, const ESelection& rSel);
352 virtual ~ScHeaderFieldObj();
354 // per getImplementation gerufen:
355 void DeleteField();
356 BOOL IsInserted() const { return pEditSource != NULL; }
357 SvxFieldItem CreateFieldItem();
358 void InitDoc( ScHeaderFooterContentObj* pContent, USHORT nP,
359 const ESelection& rSel );
361 virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation(
362 const ::com::sun::star::uno::Type & rType )
363 throw(::com::sun::star::uno::RuntimeException);
364 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
365 const ::com::sun::star::uno::Type & rType )
366 throw(::com::sun::star::uno::RuntimeException);
367 virtual void SAL_CALL acquire() throw();
368 virtual void SAL_CALL release() throw();
370 // XTextField
371 virtual ::rtl::OUString SAL_CALL getPresentation( sal_Bool bShowCommand )
372 throw(::com::sun::star::uno::RuntimeException);
374 // XTextContent
375 virtual void SAL_CALL attach( const ::com::sun::star::uno::Reference<
376 ::com::sun::star::text::XTextRange >& xTextRange )
377 throw(::com::sun::star::lang::IllegalArgumentException,
378 ::com::sun::star::uno::RuntimeException);
379 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL
380 getAnchor() throw(::com::sun::star::uno::RuntimeException);
382 // XComponent
383 virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException);
384 virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference<
385 ::com::sun::star::lang::XEventListener >& xListener )
386 throw(::com::sun::star::uno::RuntimeException);
387 virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference<
388 ::com::sun::star::lang::XEventListener >& aListener )
389 throw(::com::sun::star::uno::RuntimeException);
391 // XPropertySet
392 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
393 SAL_CALL getPropertySetInfo()
394 throw(::com::sun::star::uno::RuntimeException);
395 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName,
396 const ::com::sun::star::uno::Any& aValue )
397 throw(::com::sun::star::beans::UnknownPropertyException,
398 ::com::sun::star::beans::PropertyVetoException,
399 ::com::sun::star::lang::IllegalArgumentException,
400 ::com::sun::star::lang::WrappedTargetException,
401 ::com::sun::star::uno::RuntimeException);
402 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
403 const ::rtl::OUString& PropertyName )
404 throw(::com::sun::star::beans::UnknownPropertyException,
405 ::com::sun::star::lang::WrappedTargetException,
406 ::com::sun::star::uno::RuntimeException);
407 virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
408 const ::com::sun::star::uno::Reference<
409 ::com::sun::star::beans::XPropertyChangeListener >& xListener )
410 throw(::com::sun::star::beans::UnknownPropertyException,
411 ::com::sun::star::lang::WrappedTargetException,
412 ::com::sun::star::uno::RuntimeException);
413 virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
414 const ::com::sun::star::uno::Reference<
415 ::com::sun::star::beans::XPropertyChangeListener >& aListener )
416 throw(::com::sun::star::beans::UnknownPropertyException,
417 ::com::sun::star::lang::WrappedTargetException,
418 ::com::sun::star::uno::RuntimeException);
419 virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName,
420 const ::com::sun::star::uno::Reference<
421 ::com::sun::star::beans::XVetoableChangeListener >& aListener )
422 throw(::com::sun::star::beans::UnknownPropertyException,
423 ::com::sun::star::lang::WrappedTargetException,
424 ::com::sun::star::uno::RuntimeException);
425 virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName,
426 const ::com::sun::star::uno::Reference<
427 ::com::sun::star::beans::XVetoableChangeListener >& aListener )
428 throw(::com::sun::star::beans::UnknownPropertyException,
429 ::com::sun::star::lang::WrappedTargetException,
430 ::com::sun::star::uno::RuntimeException);
432 // XUnoTunnel
433 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
434 sal_Int8 >& aIdentifier )
435 throw(::com::sun::star::uno::RuntimeException);
437 static const com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId();
438 static ScHeaderFieldObj* getImplementation( const com::sun::star::uno::Reference<
439 com::sun::star::text::XTextContent> xObj );
441 // XServiceInfo
442 virtual ::rtl::OUString SAL_CALL getImplementationName()
443 throw(::com::sun::star::uno::RuntimeException);
444 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
445 throw(::com::sun::star::uno::RuntimeException);
446 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
447 throw(::com::sun::star::uno::RuntimeException);
449 // XTypeProvider
450 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes()
451 throw(::com::sun::star::uno::RuntimeException);
452 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
453 throw(::com::sun::star::uno::RuntimeException);
456 #endif