Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _CPPUHELPER_PROPSHLP_HXX
30 : : #define _CPPUHELPER_PROPSHLP_HXX
31 : :
32 : : #include <rtl/alloc.h>
33 : :
34 : : #include <cppuhelper/interfacecontainer.hxx>
35 : :
36 : : #include <com/sun/star/beans/XPropertySet.hpp>
37 : : #include <com/sun/star/beans/XPropertySetOption.hpp>
38 : : #include <com/sun/star/beans/XMultiPropertySet.hpp>
39 : : #include <com/sun/star/beans/XFastPropertySet.hpp>
40 : :
41 : : #include <memory>
42 : : #include "cppuhelperdllapi.h"
43 : :
44 : :
45 : : namespace cppu
46 : : {
47 : :
48 : :
49 : : /*************************************************************************
50 : : *************************************************************************/
51 : :
52 : :
53 : : /**
54 : : This interface is used by the OPropertyHelper, to access the property description.
55 : : */
56 : 5926 : class CPPUHELPER_DLLPUBLIC IPropertyArrayHelper
57 : : {
58 : : public:
59 : : // these are here to force memory de/allocation to sal lib.
60 : 5255 : inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW(())
61 : 5255 : { return ::rtl_allocateMemory( nSize ); }
62 : 5101 : inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW(())
63 : 5101 : { ::rtl_freeMemory( pMem ); }
64 : : inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW(())
65 : : { return pMem; }
66 : : inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW(())
67 : : {}
68 : :
69 : : /**
70 : : Following the rule, the first virtual method implies a virtual destructor.
71 : : */
72 : : virtual ~IPropertyArrayHelper();
73 : :
74 : : /**
75 : : Return the property members Name and Attribute from the handle nHandle.
76 : : @param nHandle the handle of a property. If the values of the handles
77 : : are sorted in the same way as the names and the highest handle value
78 : : is getCount() -1, than it must be an indexed acces to the property array.
79 : : @param pPropName is an out parameter filled with property name of the property with the
80 : : handle nHandle. May be NULL.
81 : : @param pAttributes is an out parameter filled with attributes of the property with the
82 : : handle nHandle. May be NULL.
83 : : @return True, if the handle exist, otherwise false.
84 : : */
85 : : virtual sal_Bool SAL_CALL fillPropertyMembersByHandle(
86 : : ::rtl::OUString * pPropName, sal_Int16 * pAttributes, sal_Int32 nHandle ) = 0;
87 : : /**
88 : : Return the sequence of properties. The sequence is sorted by name.
89 : : */
90 : : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > SAL_CALL getProperties(void) = 0;
91 : : /**
92 : : Return the property with the name rPropertyName.
93 : : @param rPropertyName the name of the property.
94 : : @exception UnknownPropertyException thrown if the property name is unknown.
95 : : */
96 : : virtual ::com::sun::star::beans::Property SAL_CALL getPropertyByName(
97 : : const ::rtl::OUString& rPropertyName )
98 : : throw (::com::sun::star::beans::UnknownPropertyException) = 0;
99 : : /**
100 : : Return true if the property with the name rPropertyName exist, otherwise false.
101 : : @param rPropertyName the name of the property.
102 : : */
103 : : virtual sal_Bool SAL_CALL hasPropertyByName(const ::rtl::OUString& rPropertyName) = 0;
104 : : /**
105 : : Return the handle of the property with the name rPropertyName.
106 : : If the property does not exist -1 is returned.
107 : : @param rPropertyName the name of the property.
108 : : */
109 : : virtual sal_Int32 SAL_CALL getHandleByName( const ::rtl::OUString & rPropertyName ) = 0;
110 : : /**
111 : : Fill the array with the handles of the properties.
112 : : @return the handles of the names from the pHandles array. -1
113 : : indicates an unknown property name.
114 : : */
115 : : virtual sal_Int32 SAL_CALL fillHandles(
116 : : /*out*/ sal_Int32 * pHandles, const ::com::sun::star::uno::Sequence< ::rtl::OUString > & rPropNames ) = 0;
117 : : };
118 : :
119 : : /**
120 : : You can use this helper class to map a XPropertySet-Interface to a XFast-
121 : : or a XMultiPropertySet interface.
122 : : */
123 [ + - ][ - + ]: 8057 : class CPPUHELPER_DLLPUBLIC OPropertyArrayHelper : public IPropertyArrayHelper
124 : : {
125 : : public:
126 : : /**
127 : : Create an object which supports the common property interfaces.
128 : :
129 : : @param pProps array of properties
130 : : The array pProps should be sorted.
131 : : @param nElements is the number of properties in the pProps structure.
132 : : @param bSorted indicates that the elements are sorted.
133 : : *********/
134 : : OPropertyArrayHelper(
135 : : ::com::sun::star::beans::Property *pProps,
136 : : sal_Int32 nElements ,
137 : : sal_Bool bSorted = sal_True )
138 : : SAL_THROW(());
139 : :
140 : : /**
141 : : Create an object which supports the common property interfaces.
142 : : @param aProps sequence of properties which are supported by this helper.
143 : : The sequence aProps should be sorted.
144 : : @param bSorted indicates that the elements are sorted.
145 : : */
146 : : OPropertyArrayHelper(
147 : : const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > & aProps,
148 : : sal_Bool bSorted = sal_True )
149 : : SAL_THROW(());
150 : :
151 : : /**
152 : : Return the number of properties.
153 : : */
154 : : sal_Int32 SAL_CALL getCount() const SAL_THROW(());
155 : : /**
156 : : Return the property members Name and Attribute from the handle nHandle.
157 : : @param nHandle the handle of a property. If the values of the handles
158 : : are sorted in the same way as the names and the highest handle value
159 : : is getCount() -1, than it is only an indexed acces to the property array.
160 : : Otherwise it is a linear search through the array.
161 : : @param pPropName is an out parameter filled with property name of the property with the
162 : : handle nHandle. May be NULL.
163 : : @param pAttributes is an out parameter filled with attributes of the property with the
164 : : handle nHandle. May be NULL.
165 : : @return True, if the handle exist, otherwise false.
166 : : */
167 : : virtual sal_Bool SAL_CALL fillPropertyMembersByHandle(
168 : : ::rtl::OUString * pPropName, sal_Int16 * pAttributes, sal_Int32 nHandle );
169 : : /**
170 : : Return the sequence of properties. The sequence is sorted by name.
171 : : */
172 : : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > SAL_CALL getProperties(void);
173 : : /**
174 : : Return the property with the name rPropertyName.
175 : : @param rPropertyName the name of the property.
176 : : @exception UnknownPropertyException thrown if the property name is unknown.
177 : : */
178 : : virtual ::com::sun::star::beans::Property SAL_CALL getPropertyByName(
179 : : const ::rtl::OUString& rPropertyName )
180 : : throw (::com::sun::star::beans::UnknownPropertyException);
181 : : /**
182 : : Return true if the property with the name rPropertyName exist, otherwise false.
183 : : @param rPropertyName the name of the property.
184 : : */
185 : : virtual sal_Bool SAL_CALL hasPropertyByName(const ::rtl::OUString& rPropertyName);
186 : : /**
187 : : Return the handle of the property with the name rPropertyName.
188 : : If the property does not exist -1 is returned.
189 : : @param rPropertyName the name of the property.
190 : : */
191 : : virtual sal_Int32 SAL_CALL getHandleByName( const ::rtl::OUString & rPropertyName );
192 : : /**
193 : : Fill the array with the handles of the properties.
194 : : @return the handles of the names from the pHandles array. -1
195 : : indicates an unknown property name.
196 : : */
197 : : virtual sal_Int32 SAL_CALL fillHandles(
198 : : /*out*/sal_Int32 * pHandles, const ::com::sun::star::uno::Sequence< ::rtl::OUString > & rPropNames );
199 : :
200 : : protected:
201 : : /** reserved for future use. do not use.
202 : : */
203 : : void * m_pReserved;
204 : :
205 : : private:
206 : : void init( sal_Bool bSorted ) SAL_THROW(());
207 : :
208 : : /** The sequence generated from the pProperties array. */
209 : : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > aInfos;
210 : :
211 : : /**
212 : : True, If the values of the handles are sorted in the same way as the names
213 : : and the highest handle value is getCount() -1, otherwise false.
214 : : */
215 : : sal_Bool bRightOrdered;
216 : : };
217 : :
218 : :
219 : : //-----------------------------------------------------------------------------
220 : : // helper defines needed for an interface container with a 32 bit key values
221 : :
222 : : struct equalInt32_Impl
223 : : {
224 : : bool operator()(const sal_Int32 & i1 , const sal_Int32 & i2) const SAL_THROW(())
225 : : { return i1 == i2; }
226 : : };
227 : :
228 : : struct hashInt32_Impl
229 : : {
230 : : size_t operator()(const sal_Int32 & i) const SAL_THROW(())
231 : : { return i; }
232 : : };
233 : : /** Specialized class for key type sal_Int32,
234 : : without explicit usage of STL symbols.
235 : : */
236 : : class CPPUHELPER_DLLPUBLIC OMultiTypeInterfaceContainerHelperInt32
237 : : {
238 : : public:
239 : : // these are here to force memory de/allocation to sal lib.
240 : 3 : inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW(())
241 : 3 : { return ::rtl_allocateMemory( nSize ); }
242 : 3 : inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW(())
243 : 3 : { ::rtl_freeMemory( pMem ); }
244 : : inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW(())
245 : : { return pMem; }
246 : : inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW(())
247 : : {}
248 : :
249 : : /**
250 : : Create a container of interface containers.
251 : :
252 : : @param rMutex the mutex to protect multi thread access.
253 : : The lifetime must be longer than the lifetime
254 : : of this object.
255 : : */
256 : : OMultiTypeInterfaceContainerHelperInt32( ::osl::Mutex & rMutex ) SAL_THROW(());
257 : : /**
258 : : Delete all containers.
259 : : */
260 : : ~OMultiTypeInterfaceContainerHelperInt32() SAL_THROW(());
261 : :
262 : : /**
263 : : Return all id's under which at least one interface is added.
264 : : */
265 : : ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL getContainedTypes() const SAL_THROW(());
266 : :
267 : : /**
268 : : Return the container created under this key.
269 : : @return the container created under this key. If the container
270 : : was not created, null was returned.
271 : : */
272 : : OInterfaceContainerHelper * SAL_CALL getContainer( const sal_Int32 & rKey ) const SAL_THROW(());
273 : :
274 : : /**
275 : : Insert an element in the container specified with the key. The position is not specified.
276 : : @param rKey the id of the container.
277 : : @param r the added interface. It is allowed to insert null or
278 : : the same pointer more than once.
279 : : @return the new count of elements in the container.
280 : : */
281 : : sal_Int32 SAL_CALL addInterface(
282 : : const sal_Int32 & rKey,
283 : : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & r )
284 : : SAL_THROW(());
285 : :
286 : : /**
287 : : Remove an element from the container specified with the key.
288 : : It uses the equal definition of uno objects to remove the interfaces.
289 : : @param rKey the id of the container.
290 : : @param rxIFace the removed interface.
291 : : @return the new count of elements in the container.
292 : : */
293 : : sal_Int32 SAL_CALL removeInterface(
294 : : const sal_Int32 & rKey,
295 : : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rxIFace )
296 : : SAL_THROW(());
297 : :
298 : : /**
299 : : Call disposing on all objects in the container that
300 : : support XEventListener. Then clear the container.
301 : : */
302 : : void SAL_CALL disposeAndClear( const ::com::sun::star::lang::EventObject & rEvt ) SAL_THROW(());
303 : : /**
304 : : Remove all elements of all containers. Does not delete the container.
305 : : */
306 : : void SAL_CALL clear() SAL_THROW(());
307 : :
308 : : typedef sal_Int32 keyType;
309 : : private:
310 : : void *m_pMap;
311 : : ::osl::Mutex & rMutex;
312 : :
313 : : inline OMultiTypeInterfaceContainerHelperInt32( const OMultiTypeInterfaceContainerHelperInt32 & ) SAL_THROW(());
314 : : inline OMultiTypeInterfaceContainerHelperInt32 & operator = ( const OMultiTypeInterfaceContainerHelperInt32 & ) SAL_THROW(());
315 : : };
316 : :
317 : :
318 : : /** An interface to extend event notification actions.
319 : : */
320 : 768 : class IEventNotificationHook
321 : : {
322 : : public:
323 : : /**
324 : : Method to be called by OPropertySetHelper::fire.
325 : :
326 : : @param bIgnoreRuntimeExceptionsWhileFiring
327 : : indicates whether occuring RuntimeExceptions shall be
328 : : ignored when firing notifications
329 : :
330 : : @see OPropertySetHelper::fire
331 : : */
332 : : virtual void fireEvents(
333 : : sal_Int32 * pnHandles,
334 : : sal_Int32 nCount,
335 : : sal_Bool bVetoable,
336 : : bool bIgnoreRuntimeExceptionsWhileFiring) = 0;
337 : :
338 : : #if !defined _MSC_VER // public -> protected changes mangled names there
339 : : protected:
340 : : #endif
341 : 673 : ~IEventNotificationHook() {}
342 : : // avoid warnings about virtual members and non-virtual dtor
343 : : };
344 : :
345 : :
346 : :
347 : : /**
348 : : This abstract class maps the methods of the interfaces XMultiPropertySet, XFastPropertySet
349 : : and XPropertySet to the methods getInfoHelper, convertFastPropertyValue,
350 : : setFastPropertyValue_NoBroadcast and getFastPropertyValue. You must derive from
351 : : this class and overload the methods.
352 : : It provides a standard implementation of the XPropertySetInfo.
353 : : The XPropertiesChangeListener are inserted in the rBHelper.aLC structure.
354 : : The XPropertyChangeListener and XVetoableChangeListener with no names are inserted
355 : : in the rBHelper.aLC structure. So it is possible to advise property listeners with
356 : : the connection point interfaces. But only listeners that listen to all property changes.
357 : :
358 : : */
359 : : class CPPUHELPER_DLLPUBLIC OPropertySetHelper :
360 : : public ::com::sun::star::beans::XMultiPropertySet,
361 : : public ::com::sun::star::beans::XFastPropertySet,
362 : : public ::com::sun::star::beans::XPropertySet
363 : : {
364 : : public:
365 : : /**
366 : : @param rBHelper this structure contains the basic members of
367 : : a broadcaster.
368 : : The lifetime must be longer than the lifetime
369 : : of this object. Stored in the variable rBHelper.
370 : : */
371 : : OPropertySetHelper( OBroadcastHelper & rBHelper ) SAL_THROW(());
372 : :
373 : : /** Constructor.
374 : :
375 : : @param rBHelper
376 : : this structure contains the basic members of
377 : : a broadcaster.
378 : : The lifetime must be longer than the lifetime
379 : : of this object. Stored in the variable rBHelper.
380 : :
381 : : @param bIgnoreRuntimeExceptionsWhileFiring
382 : : indicates whether occurring RuntimeExceptions will be
383 : : ignored when firing notifications
384 : : (vetoableChange(), propertyChange())
385 : : to listeners.
386 : : PropertyVetoExceptions may still be thrown.
387 : : This flag is useful in an inter-process scenario when
388 : : remote bridges may break down
389 : : (firing DisposedExceptions).
390 : : */
391 : : OPropertySetHelper(
392 : : OBroadcastHelper & rBHelper, bool bIgnoreRuntimeExceptionsWhileFiring );
393 : :
394 : : /** Constructor.
395 : :
396 : : @param rBHelper
397 : : this structure contains the basic members of
398 : : a broadcaster.
399 : : The lifetime must be longer than the lifetime
400 : : of this object. Stored in the variable rBHelper.
401 : :
402 : : @param i_pFireEvents
403 : : additional event notifier
404 : :
405 : : @param bIgnoreRuntimeExceptionsWhileFiring
406 : : indicates whether occurring RuntimeExceptions will be
407 : : ignored when firing notifications
408 : : (vetoableChange(), propertyChange())
409 : : to listeners.
410 : : PropertyVetoExceptions may still be thrown.
411 : : This flag is useful in an inter-process scenario when
412 : : remote bridges may break down
413 : : (firing DisposedExceptions).
414 : : */
415 : : OPropertySetHelper(
416 : : OBroadcastHelper & rBHelper,
417 : : IEventNotificationHook *i_pFireEvents,
418 : : bool bIgnoreRuntimeExceptionsWhileFiring = false);
419 : :
420 : : /**
421 : : Only returns a reference to XMultiPropertySet, XFastPropertySet, XPropertySet and
422 : : XEventListener.
423 : : */
424 : : virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType )
425 : : throw (::com::sun::star::uno::RuntimeException);
426 : :
427 : : /** eases implementing XTypeProvider::getTypes, returns the types of XMultiPropertySet, XFastPropertySet, XPropertySet
428 : : */
429 : : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > getTypes()
430 : : throw(::com::sun::star::uno::RuntimeException);
431 : :
432 : : /**
433 : : Send a disposing notification to the listeners in the conatiners aBoundLC
434 : : and aVetoableLC.
435 : :
436 : : @see OComponentHelper
437 : : */
438 : : void SAL_CALL disposing() SAL_THROW(());
439 : :
440 : : /**
441 : : Throw UnknownPropertyException or PropertyVetoException if the property with the name
442 : : rPropertyName does not exist or is readonly. Otherwise rPropertyName is changed to its handle
443 : : value and setFastPropertyValue is called.
444 : : */
445 : : virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& rPropertyName, const ::com::sun::star::uno::Any& aValue )
446 : : 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);
447 : : /**
448 : : Throw UnknownPropertyException if the property with the name
449 : : rPropertyName does not exist.
450 : : */
451 : : virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(const ::rtl::OUString& aPropertyName)
452 : : throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
453 : : /** Ignored if the property is not bound. */
454 : : virtual void SAL_CALL addPropertyChangeListener(
455 : : const ::rtl::OUString& aPropertyName,
456 : : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener)
457 : : throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
458 : :
459 : : /** Ignored if the property is not bound. */
460 : : virtual void SAL_CALL removePropertyChangeListener(
461 : : const ::rtl::OUString& aPropertyName,
462 : : const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertyChangeListener >& aListener)
463 : : throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
464 : :
465 : : /** Ignored if the property is not constrained. */
466 : : virtual void SAL_CALL addVetoableChangeListener(
467 : : const ::rtl::OUString& aPropertyName,
468 : : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener)
469 : : throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
470 : :
471 : : /** Ignored if the property is not constrained. */
472 : : virtual void SAL_CALL removeVetoableChangeListener(
473 : : const ::rtl::OUString& aPropertyName,
474 : : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener > & aListener )
475 : : throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
476 : :
477 : : /**
478 : : Throw UnknownPropertyException or PropertyVetoException if the property with the name
479 : : rPropertyName does not exist or is readonly. Otherwise the method convertFastPropertyValue
480 : : is called, then the vetoable listeners are notified. After this the value of the property
481 : : is changed with the setFastPropertyValue_NoBroadcast method and the bound listeners are
482 : : notified.
483 : : */
484 : : virtual void SAL_CALL setFastPropertyValue( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue )
485 : : 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);
486 : :
487 : : /**
488 : : @exception com::sun::star::beans::UnknownPropertyException
489 : : if the property with the handle nHandle does not exist.
490 : : */
491 : : virtual ::com::sun::star::uno::Any SAL_CALL getFastPropertyValue( sal_Int32 nHandle )
492 : : throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
493 : :
494 : : // XMultiPropertySet
495 : : virtual void SAL_CALL setPropertyValues(
496 : : const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames,
497 : : const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Values )
498 : : throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
499 : :
500 : : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyValues(
501 : : const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames )
502 : : throw(::com::sun::star::uno::RuntimeException);
503 : :
504 : : virtual void SAL_CALL addPropertiesChangeListener(
505 : : const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames,
506 : : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& Listener )
507 : : throw(::com::sun::star::uno::RuntimeException);
508 : :
509 : : virtual void SAL_CALL removePropertiesChangeListener(
510 : : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& Listener )
511 : : throw(::com::sun::star::uno::RuntimeException);
512 : :
513 : : virtual void SAL_CALL firePropertiesChangeEvent(
514 : : const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames,
515 : : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener > & Listener )
516 : : throw(::com::sun::star::uno::RuntimeException);
517 : :
518 : : /**
519 : : The property sequence is created in the call. The interface isn't used after the call.
520 : : */
521 : : static ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySetInfo > SAL_CALL
522 : : createPropertySetInfo( IPropertyArrayHelper & rProperties ) SAL_THROW(());
523 : : protected:
524 : : /**
525 : : This method fire events to all registered property listeners.
526 : : @param pnHandles the id's of the properties that changed.
527 : : @param pNewValues the new values of the properties.
528 : : @param pOldValues the old values of the properties.
529 : : @param nCount the number of elements in the arrays pnHandles, pNewValues and pOldValues.
530 : : @param bVetoable true means fire to VetoableChangeListener, false means fire to
531 : : XPropertyChangedListener and XMultiPropertyChangedListener.
532 : : */
533 : : void SAL_CALL fire(
534 : : sal_Int32 * pnHandles,
535 : : const ::com::sun::star::uno::Any * pNewValues,
536 : : const ::com::sun::star::uno::Any * pOldValues,
537 : : sal_Int32 nCount,
538 : : sal_Bool bVetoable );
539 : :
540 : : /**
541 : : Set multiple properties with the handles.
542 : : @param nSeqLen the length of the arrays pHandles and Values.
543 : : @param pHandles the handles of the properties. The number of elements
544 : : in the Values sequence is the length of the handle array. A value of -1
545 : : of a handle means invalid property. These are ignored.
546 : : @param pValues the values of the properties.
547 : : @param nHitCount the number of valid entries in the handle array.
548 : : */
549 : : void SAL_CALL setFastPropertyValues(
550 : : sal_Int32 nSeqLen,
551 : : sal_Int32 * pHandles,
552 : : const ::com::sun::star::uno::Any * pValues,
553 : : sal_Int32 nHitCount )
554 : : SAL_THROW( (::com::sun::star::uno::Exception) );
555 : :
556 : : /**
557 : : This abstract method must return the name to index table. This table contains all property
558 : : names and types of this object. The method is not implemented in this class.
559 : : */
560 : : virtual IPropertyArrayHelper & SAL_CALL getInfoHelper() = 0;
561 : :
562 : : /**
563 : : Converted the value rValue and return the result in rConvertedValue and the
564 : : old value in rOldValue. A IllegalArgumentException is thrown.
565 : : The method is not implemented in this class. After this call the vetoable
566 : : listeners are notified.
567 : :
568 : : @param rConvertedValue the converted value. Only set if return is true.
569 : : @param rOldValue the old value. Only set if return is true.
570 : : @param nHandle the handle of the proberty.
571 : : @return true if the value converted.
572 : : */
573 : : virtual sal_Bool SAL_CALL convertFastPropertyValue(
574 : : ::com::sun::star::uno::Any & rConvertedValue,
575 : : ::com::sun::star::uno::Any & rOldValue,
576 : : sal_Int32 nHandle,
577 : : const ::com::sun::star::uno::Any& rValue )
578 : : throw (::com::sun::star::lang::IllegalArgumentException) = 0;
579 : :
580 : : /** The same as setFastProperyValue; nHandle is always valid.
581 : : The changes must not be broadcasted in this method.
582 : : The method is implemented in a derived class.
583 : :
584 : : @attention
585 : : Although you are permitted to throw any UNO exception, only the following
586 : : are valid for usage:
587 : : -- ::com::sun::star::beans::UnknownPropertyException
588 : : -- ::com::sun::star::beans::PropertyVetoException
589 : : -- ::com::sun::star::lang::IllegalArgumentException
590 : : -- ::com::sun::star::lang::WrappedTargetException
591 : : -- ::com::sun::star::uno::RuntimeException
592 : :
593 : : @param nHandle
594 : : handle
595 : : @param rValue
596 : : value
597 : : */
598 : : virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
599 : : sal_Int32 nHandle,
600 : : const ::com::sun::star::uno::Any& rValue )
601 : : throw (::com::sun::star::uno::Exception) = 0;
602 : : /**
603 : : The same as getFastProperyValue, but return the value through rValue and nHandle
604 : : is always valid.
605 : : The method is not implemented in this class.
606 : : */
607 : : virtual void SAL_CALL getFastPropertyValue(
608 : : ::com::sun::star::uno::Any& rValue,
609 : : sal_Int32 nHandle ) const = 0;
610 : :
611 : : /** sets an dependent property's value
612 : :
613 : : <p>Sometimes setting a given property needs to implicitly modify another property's value. Calling |setPropertyValue|
614 : : from within |setFastPropertyValue_NoBroadcast| is not an option here, as it would notify the property listeners
615 : : while our mutex is still locked. Setting the dependent property's value directly (e.g. by calling |setFastPropertyValue_NoBroadcast|
616 : : recursively) is not an option, too, since it would miss firing the property change event.</p>
617 : :
618 : : <p>So, in such cases, you use |setDependentFastPropertyValue| from within |setFastPropertyValue_NoBroadcast|.
619 : : It will convert and actually set the property value (invoking |convertFastPropertyValue| and |setFastPropertyValue_NoBroadcast|
620 : : for the given handle and value), and add the property change event to the list of events to be notified
621 : : when the bottom-most |setFastPropertyValue_NoBroadcast| on the stack returns.</p>
622 : :
623 : : <p><strong>Note</strong>: The method will <em>not</em> invoke veto listeners for the property.</p>
624 : :
625 : : <p><strong>Note</strong>: It's the caller's responsibility to ensure that our mutex is locked. This is
626 : : canonically given when the method is invoked from within |setFastPropertyValue_NoBroadcast|, in other
627 : : contexts, you might need to take own measures.</p>
628 : : */
629 : : void setDependentFastPropertyValue(
630 : : sal_Int32 i_handle,
631 : : const ::com::sun::star::uno::Any& i_value
632 : : );
633 : :
634 : : /** The common data of a broadcaster. Use the mutex, disposing state and the listener container. */
635 : : OBroadcastHelper &rBHelper;
636 : : /**
637 : : Container for the XProperyChangedListener. The listeners are inserted by handle.
638 : : */
639 : : OMultiTypeInterfaceContainerHelperInt32 aBoundLC;
640 : : /**
641 : : Container for the XPropertyVetoableListener. The listeners are inserted by handle.
642 : : */
643 : : OMultiTypeInterfaceContainerHelperInt32 aVetoableLC;
644 : :
645 : : class Impl;
646 : :
647 : : /** reserved for future use. finally, the future has arrived...
648 : : */
649 : : const std::auto_ptr<Impl> m_pReserved;
650 : :
651 : : private:
652 : : OPropertySetHelper( const OPropertySetHelper & ) SAL_THROW(());
653 : : OPropertySetHelper & operator = ( const OPropertySetHelper & ) SAL_THROW(());
654 : :
655 : : /** notifies the given changes in property's values, <em>plus</em> all property changes collected during recent
656 : : |setDependentFastPropertyValue| calls.
657 : : */
658 : : void impl_fireAll(
659 : : sal_Int32* i_handles,
660 : : const ::com::sun::star::uno::Any * i_newValues,
661 : : const ::com::sun::star::uno::Any * i_oldValues,
662 : : sal_Int32 i_count
663 : : );
664 : :
665 : : #if defined _MSC_VER // public -> protected changes mangled names there
666 : : public:
667 : : #else
668 : : protected:
669 : : #endif
670 : : // Suppress warning about virtual functions but non-virtual destructor:
671 : : #if defined _MSC_VER
672 : : #pragma warning(push)
673 : : #pragma warning(disable: 4265)
674 : : #endif
675 : : /**
676 : : You must call disposing before destruction.
677 : : */
678 : : ~OPropertySetHelper() SAL_THROW(());
679 : : };
680 : : #if defined _MSC_VER
681 : : #pragma warning(pop)
682 : : #endif
683 : :
684 : : /**
685 : : OPropertySetHelper plus XPropertySetOption
686 : : */
687 : : class CPPUHELPER_DLLPUBLIC OPropertySetHelper2 : public OPropertySetHelper,
688 : : public ::com::sun::star::beans::XPropertySetOption
689 : : {
690 : : public:
691 : : /** Constructor.
692 : :
693 : : See OPropertySetHelper constructors documentation
694 : : */
695 : : explicit OPropertySetHelper2(
696 : : OBroadcastHelper & rBHelper,
697 : : IEventNotificationHook *i_pFireEvents = NULL,
698 : : bool bIgnoreRuntimeExceptionsWhileFiring = false);
699 : :
700 : : // XInterface
701 : : virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType )
702 : : throw (::com::sun::star::uno::RuntimeException);
703 : :
704 : : // XPropertySetOption
705 : : virtual void SAL_CALL enableChangeListenerNotification( sal_Bool bEnable )
706 : : throw(::com::sun::star::uno::RuntimeException);
707 : :
708 : :
709 : :
710 : : private:
711 : : OPropertySetHelper2( const OPropertySetHelper2 & ) SAL_THROW(());
712 : : OPropertySetHelper2 & operator = ( const OPropertySetHelper2 & ) SAL_THROW(());
713 : :
714 : : #if defined _MSC_VER // public -> protected changes mangled names there
715 : : public:
716 : : #else
717 : : protected:
718 : : #endif
719 : : // Suppress warning about virtual functions but non-virtual destructor:
720 : : /**
721 : : You must call disposing before destruction.
722 : : */
723 : : virtual ~OPropertySetHelper2() SAL_THROW(());
724 : : };
725 : :
726 : : } // end namespace cppuhelper
727 : : #endif //
728 : :
729 : :
730 : :
731 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|