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