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