AlterOffice
AlterOffice 2026.2 SDK C/C++ API Reference
propshlp.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 
3 
4 #ifndef INCLUDED_CPPUHELPER_PROPSHLP_HXX
5 #define INCLUDED_CPPUHELPER_PROPSHLP_HXX
6 
7 #include "rtl/alloc.h"
8 
10 
11 #include "com/sun/star/beans/XPropertySet.hpp"
12 #include "com/sun/star/beans/XPropertySetOption.hpp"
13 #include "com/sun/star/beans/XMultiPropertySet.hpp"
14 #include "com/sun/star/beans/XFastPropertySet.hpp"
15 
17 
18 
19 namespace cppu
20 {
21 
22 
23 /*************************************************************************
24 *************************************************************************/
25 
26 
31 {
32 public:
33  // these are here to force memory de/allocation to sal lib.
34  static void * SAL_CALL operator new( size_t nSize )
35  { return ::rtl_allocateMemory( nSize ); }
36  static void SAL_CALL operator delete( void * pMem )
37  { ::rtl_freeMemory( pMem ); }
38  static void * SAL_CALL operator new( size_t, void * pMem )
39  { return pMem; }
40  static void SAL_CALL operator delete( void *, void * )
41  {}
42 
47 
60  ::rtl::OUString * pPropName, sal_Int16 * pAttributes, sal_Int32 nHandle ) = 0;
64  virtual css::uno::Sequence< css::beans::Property > SAL_CALL getProperties() = 0;
70  virtual css::beans::Property SAL_CALL getPropertyByName(
71  const ::rtl::OUString& rPropertyName ) = 0;
76  virtual sal_Bool SAL_CALL hasPropertyByName(const ::rtl::OUString& rPropertyName) = 0;
82  virtual sal_Int32 SAL_CALL getHandleByName( const ::rtl::OUString & rPropertyName ) = 0;
88  virtual sal_Int32 SAL_CALL fillHandles(
89  /*out*/ sal_Int32 * pHandles, const css::uno::Sequence< ::rtl::OUString > & rPropNames ) = 0;
90 };
91 
97 {
98 public:
108  css::beans::Property *pProps,
109  sal_Int32 nElements ,
110  sal_Bool bSorted = true );
111 
119  const css::uno::Sequence< css::beans::Property > & aProps,
120  sal_Bool bSorted = true );
121 
125  sal_Int32 SAL_CALL getCount() const;
139  ::rtl::OUString * pPropName, sal_Int16 * pAttributes, sal_Int32 nHandle ) SAL_OVERRIDE;
143  virtual css::uno::Sequence< css::beans::Property > SAL_CALL getProperties() SAL_OVERRIDE;
149  virtual css::beans::Property SAL_CALL getPropertyByName(
150  const ::rtl::OUString& rPropertyName ) SAL_OVERRIDE;
155  virtual sal_Bool SAL_CALL hasPropertyByName(const ::rtl::OUString& rPropertyName) SAL_OVERRIDE;
161  virtual sal_Int32 SAL_CALL getHandleByName( const ::rtl::OUString & rPropertyName ) SAL_OVERRIDE;
167  virtual sal_Int32 SAL_CALL fillHandles(
168  /*out*/sal_Int32 * pHandles, const css::uno::Sequence< ::rtl::OUString > & rPropNames ) SAL_OVERRIDE;
169 
170 protected:
173  void * m_pReserved;
174 
175 private:
176  void init( sal_Bool bSorted );
177 
179  css::uno::Sequence< css::beans::Property > aInfos;
180 
185  sal_Bool bRightOrdered;
186 };
187 
188 
189 // helper defines needed for an interface container with a 32 bit key values
190 
192 {
193  bool operator()(const sal_Int32 & i1 , const sal_Int32 & i2) const
194  { return i1 == i2; }
195 };
196 
198 {
199  size_t operator()(const sal_Int32 & i) const
200  { return i; }
201 };
202 
207 {
208 public:
209  // these are here to force memory de/allocation to sal lib.
210  static void * SAL_CALL operator new( size_t nSize )
211  { return ::rtl_allocateMemory( nSize ); }
212  static void SAL_CALL operator delete( void * pMem )
213  { ::rtl_freeMemory( pMem ); }
214  static void * SAL_CALL operator new( size_t, void * pMem )
215  { return pMem; }
216  static void SAL_CALL operator delete( void *, void * )
217  {}
218 
231 
235  css::uno::Sequence< sal_Int32 > SAL_CALL getContainedTypes() const;
236 
242  OInterfaceContainerHelper * SAL_CALL getContainer( const sal_Int32 & rKey ) const;
243 
251  sal_Int32 SAL_CALL addInterface(
252  const sal_Int32 & rKey,
253  const css::uno::Reference< css::uno::XInterface > & r );
254 
262  sal_Int32 SAL_CALL removeInterface(
263  const sal_Int32 & rKey,
264  const css::uno::Reference< css::uno::XInterface > & rxIFace );
265 
270  void SAL_CALL disposeAndClear( const css::lang::EventObject & rEvt );
274  void SAL_CALL clear();
275 
276  typedef sal_Int32 keyType;
277 private:
278  void * m_pMap;
279  ::osl::Mutex & rMutex;
280 
283 };
284 
285 
289 {
290 public:
310  virtual void fireEvents(
311  sal_Int32 * pnHandles,
312  sal_Int32 nCount,
313  sal_Bool bVetoable,
314  bool bIgnoreRuntimeExceptionsWhileFiring) = 0;
315 
316 #if !defined _MSC_VER // public -> protected changes mangled names there
317 protected:
318 #endif
320  // avoid warnings about virtual members and non-virtual dtor
321 };
322 
323 
337  public css::beans::XMultiPropertySet,
338  public css::beans::XFastPropertySet,
339  public css::beans::XPropertySet
340 {
341 public:
349 
369  OBroadcastHelper & rBHelper, bool bIgnoreRuntimeExceptionsWhileFiring );
370 
393  OBroadcastHelper & rBHelper,
394  IEventNotificationHook *i_pFireEvents,
395  bool bIgnoreRuntimeExceptionsWhileFiring = false);
396 
401  virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) SAL_OVERRIDE;
402 
407  css::uno::Sequence< css::uno::Type > getTypes();
408 
415  void SAL_CALL disposing();
416 
422  virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& rPropertyName, const css::uno::Any& aValue ) SAL_OVERRIDE;
427  virtual css::uno::Any SAL_CALL getPropertyValue(const ::rtl::OUString& aPropertyName) SAL_OVERRIDE;
429  virtual void SAL_CALL addPropertyChangeListener(
430  const ::rtl::OUString& aPropertyName,
431  const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener) SAL_OVERRIDE;
432 
434  virtual void SAL_CALL removePropertyChangeListener(
435  const ::rtl::OUString& aPropertyName,
436  const css::uno::Reference < css::beans::XPropertyChangeListener >& aListener) SAL_OVERRIDE;
437 
439  virtual void SAL_CALL addVetoableChangeListener(
440  const ::rtl::OUString& aPropertyName,
441  const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener) SAL_OVERRIDE;
442 
444  virtual void SAL_CALL removeVetoableChangeListener(
445  const ::rtl::OUString& aPropertyName,
446  const css::uno::Reference< css::beans::XVetoableChangeListener > & aListener ) SAL_OVERRIDE;
447 
455  virtual void SAL_CALL setFastPropertyValue( sal_Int32 nHandle, const css::uno::Any& rValue ) SAL_OVERRIDE;
456 
461  virtual css::uno::Any SAL_CALL getFastPropertyValue( sal_Int32 nHandle ) SAL_OVERRIDE;
462 
463  // XMultiPropertySet
464  virtual void SAL_CALL setPropertyValues(
465  const css::uno::Sequence< ::rtl::OUString >& PropertyNames,
466  const css::uno::Sequence< css::uno::Any >& Values ) SAL_OVERRIDE;
467 
468  virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues(
469  const css::uno::Sequence< ::rtl::OUString >& PropertyNames ) SAL_OVERRIDE;
470 
471  virtual void SAL_CALL addPropertiesChangeListener(
472  const css::uno::Sequence< ::rtl::OUString >& PropertyNames,
473  const css::uno::Reference< css::beans::XPropertiesChangeListener >& Listener ) SAL_OVERRIDE;
474 
475  virtual void SAL_CALL removePropertiesChangeListener(
476  const css::uno::Reference< css::beans::XPropertiesChangeListener >& Listener ) SAL_OVERRIDE;
477 
478  virtual void SAL_CALL firePropertiesChangeEvent(
479  const css::uno::Sequence< ::rtl::OUString >& PropertyNames,
480  const css::uno::Reference< css::beans::XPropertiesChangeListener > & Listener ) SAL_OVERRIDE;
481 
485  static css::uno::Reference < css::beans::XPropertySetInfo > SAL_CALL
487 protected:
497  void SAL_CALL fire(
498  sal_Int32 * pnHandles,
499  const css::uno::Any * pNewValues,
500  const css::uno::Any * pOldValues,
501  sal_Int32 nCount,
502  sal_Bool bVetoable );
503 
513  void SAL_CALL setFastPropertyValues(
514  sal_Int32 nSeqLen,
515  sal_Int32 * pHandles,
516  const css::uno::Any * pValues,
517  sal_Int32 nHitCount );
518 
523  virtual IPropertyArrayHelper & SAL_CALL getInfoHelper() = 0;
524 
541  css::uno::Any & rConvertedValue,
542  css::uno::Any & rOldValue,
543  sal_Int32 nHandle,
544  const css::uno::Any& rValue ) = 0;
545 
565  virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
566  sal_Int32 nHandle,
567  const css::uno::Any& rValue ) = 0;
573  virtual void SAL_CALL getFastPropertyValue(
574  css::uno::Any& rValue,
575  sal_Int32 nHandle ) const = 0;
576 
596  sal_Int32 i_handle,
597  const css::uno::Any& i_value
598  );
599 
610 
611  class Impl;
612 
615  Impl * const m_pReserved;
616 
617 private:
619  OPropertySetHelper & operator = ( const OPropertySetHelper & )
621 
625  void impl_fireAll(
626  sal_Int32* i_handles,
627  const css::uno::Any * i_newValues,
628  const css::uno::Any * i_oldValues,
629  sal_Int32 i_count
630  );
631 
632 #if defined _MSC_VER // public -> protected changes mangled names there
633 public:
634 #else
635 protected:
636 #endif
641 };
642 
651  public css::beans::XPropertySetOption
652 {
653 public:
659  OBroadcastHelper & rBHelper,
660  IEventNotificationHook *i_pFireEvents = NULL,
661  bool bIgnoreRuntimeExceptionsWhileFiring = false);
662 
663  // XInterface
664  virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) SAL_OVERRIDE;
665 
666  // XPropertySetOption
667  virtual void SAL_CALL enableChangeListenerNotification( sal_Bool bEnable ) SAL_OVERRIDE;
668 
669 
670 private:
672  OPropertySetHelper2 & operator = ( const OPropertySetHelper2 & )
674 
675 #if defined _MSC_VER // public -> protected changes mangled names there
676 public:
677 #else
678 protected:
679 #endif
680 // Suppress warning about virtual functions but non-virtual destructor:
685 };
686 
687 } // end namespace cppuhelper
688 #endif
689 
690 
691 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:358
unsigned char sal_Bool
Definition: types.h:18
#define SAL_OVERRIDE
C++11 "override" feature.
Definition: types.h:371
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:567
SAL_DLLPUBLIC void rtl_freeMemory(void *Ptr) SAL_THROW_EXTERN_C()
Free memory.
SAL_DLLPUBLIC void * rtl_allocateMemory(sal_Size Bytes) SAL_THROW_EXTERN_C()
Allocate memory.
#define CPPUHELPER_DLLPUBLIC
Definition: cppuhelperdllapi.h:12
Definition: types.h:339
Definition: bootstrap.hxx:14
Definition: Enterable.hxx:11
This String class provides base functionality for C++ like Unicode character array handling.
Definition: ustring.hxx:184
A mutual exclusion synchronization object.
Definition: mutex.hxx:15
A container of interfaces.
Definition: interfacecontainer.h:112
This struct contains the standard variables of a broadcaster.
Definition: interfacecontainer.h:420
This interface is used by the OPropertyHelper, to access the property description.
Definition: propshlp.hxx:31
virtual sal_Bool hasPropertyByName(const ::rtl::OUString &rPropertyName)=0
Return true if the property with the name rPropertyName exist, otherwise false.
virtual css::beans::Property getPropertyByName(const ::rtl::OUString &rPropertyName)=0
Return the property with the name rPropertyName.
virtual ~IPropertyArrayHelper()
Following the rule, the first virtual method implies a virtual destructor.
virtual sal_Bool fillPropertyMembersByHandle(::rtl::OUString *pPropName, sal_Int16 *pAttributes, sal_Int32 nHandle)=0
Return the property members Name and Attribute from the handle nHandle.
virtual sal_Int32 fillHandles(sal_Int32 *pHandles, const css::uno::Sequence< ::rtl::OUString > &rPropNames)=0
Fill the array with the handles of the properties.
virtual css::uno::Sequence< css::beans::Property > getProperties()=0
Return the sequence of properties.
virtual sal_Int32 getHandleByName(const ::rtl::OUString &rPropertyName)=0
Return the handle of the property with the name rPropertyName.
You can use this helper class to map a XPropertySet-Interface to a XFast- or a XMultiPropertySet inte...
Definition: propshlp.hxx:97
sal_Int32 getCount() const
Return the number of properties.
OPropertyArrayHelper(const css::uno::Sequence< css::beans::Property > &aProps, sal_Bool bSorted=true)
Create an object which supports the common property interfaces.
virtual css::uno::Sequence< css::beans::Property > getProperties() SAL_OVERRIDE
Return the sequence of properties.
OPropertyArrayHelper(css::beans::Property *pProps, sal_Int32 nElements, sal_Bool bSorted=true)
Create an object which supports the common property interfaces.
virtual sal_Bool fillPropertyMembersByHandle(::rtl::OUString *pPropName, sal_Int16 *pAttributes, sal_Int32 nHandle) SAL_OVERRIDE
Return the property members Name and Attribute from the handle nHandle.
Definition: propshlp.hxx:192
bool operator()(const sal_Int32 &i1, const sal_Int32 &i2) const
Definition: propshlp.hxx:193
Definition: propshlp.hxx:198
size_t operator()(const sal_Int32 &i) const
Definition: propshlp.hxx:199
Specialized class for key type sal_Int32, without explicit usage of STL symbols.
Definition: propshlp.hxx:207
sal_Int32 addInterface(const sal_Int32 &rKey, const css::uno::Reference< css::uno::XInterface > &r)
Insert an element in the container specified with the key.
void clear()
Remove all elements of all containers.
css::uno::Sequence< sal_Int32 > getContainedTypes() const
Return all id's under which at least one interface is added.
sal_Int32 keyType
Definition: propshlp.hxx:276
~OMultiTypeInterfaceContainerHelperInt32()
Delete all containers.
sal_Int32 removeInterface(const sal_Int32 &rKey, const css::uno::Reference< css::uno::XInterface > &rxIFace)
Remove an element from the container specified with the key.
OMultiTypeInterfaceContainerHelperInt32(::osl::Mutex &rMutex)
Create a container of interface containers.
void disposeAndClear(const css::lang::EventObject &rEvt)
Call disposing on all objects in the container that support XEventListener.
OInterfaceContainerHelper * getContainer(const sal_Int32 &rKey) const
Return the container created under this key.
An interface to extend event notification actions.
Definition: propshlp.hxx:289
virtual void fireEvents(sal_Int32 *pnHandles, sal_Int32 nCount, sal_Bool bVetoable, bool bIgnoreRuntimeExceptionsWhileFiring)=0
Method to be called by OPropertySetHelper::fire.
~IEventNotificationHook()
Definition: propshlp.hxx:319
This abstract class maps the methods of the interfaces XMultiPropertySet, XFastPropertySet and XPrope...
Definition: propshlp.hxx:340
virtual sal_Bool convertFastPropertyValue(css::uno::Any &rConvertedValue, css::uno::Any &rOldValue, sal_Int32 nHandle, const css::uno::Any &rValue)=0
Converted the value rValue and return the result in rConvertedValue and the old value in rOldValue.
void setDependentFastPropertyValue(sal_Int32 i_handle, const css::uno::Any &i_value)
sets an dependent property's value
virtual void removeVetoableChangeListener(const ::rtl::OUString &aPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) SAL_OVERRIDE
Ignored if the property is not constrained.
void setFastPropertyValues(sal_Int32 nSeqLen, sal_Int32 *pHandles, const css::uno::Any *pValues, sal_Int32 nHitCount)
Set multiple properties with the handles.
virtual void firePropertiesChangeEvent(const css::uno::Sequence< ::rtl::OUString > &PropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &Listener) SAL_OVERRIDE
virtual IPropertyArrayHelper & getInfoHelper()=0
This abstract method must return the name to index table.
virtual css::uno::Sequence< css::uno::Any > getPropertyValues(const css::uno::Sequence< ::rtl::OUString > &PropertyNames) SAL_OVERRIDE
virtual void setPropertyValue(const ::rtl::OUString &rPropertyName, const css::uno::Any &aValue) SAL_OVERRIDE
Throw UnknownPropertyException or PropertyVetoException if the property with the name rPropertyName d...
Impl *const m_pReserved
reserved for future use.
Definition: propshlp.hxx:611
~OPropertySetHelper()
You must call disposing before destruction.
virtual void getFastPropertyValue(css::uno::Any &rValue, sal_Int32 nHandle) const =0
The same as getFastPropertyValue, but return the value through rValue and nHandle is always valid.
OMultiTypeInterfaceContainerHelperInt32 aBoundLC
Container for the XPropertyChangedListener.
Definition: propshlp.hxx:605
virtual void setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const css::uno::Any &rValue)=0
The same as setFastPropertyValue; nHandle is always valid.
virtual void setFastPropertyValue(sal_Int32 nHandle, const css::uno::Any &rValue) SAL_OVERRIDE
Throw UnknownPropertyException or PropertyVetoException if the property with the name rPropertyName d...
void disposing()
Send a disposing notification to the listeners in the containers aBoundLC and aVetoableLC.
OBroadcastHelper & rBHelper
The common data of a broadcaster.
Definition: propshlp.hxx:601
OPropertySetHelper(OBroadcastHelper &rBHelper, bool bIgnoreRuntimeExceptionsWhileFiring)
Constructor.
virtual css::uno::Any queryInterface(const css::uno::Type &rType) SAL_OVERRIDE
Only returns a reference to XMultiPropertySet, XFastPropertySet, XPropertySet and XEventListener.
virtual css::uno::Any getPropertyValue(const ::rtl::OUString &aPropertyName) SAL_OVERRIDE
Throw UnknownPropertyException if the property with the name rPropertyName does not exist.
OMultiTypeInterfaceContainerHelperInt32 aVetoableLC
Container for the XPropertyVetoableListener.
Definition: propshlp.hxx:609
virtual void setPropertyValues(const css::uno::Sequence< ::rtl::OUString > &PropertyNames, const css::uno::Sequence< css::uno::Any > &Values) SAL_OVERRIDE
OPropertySetHelper(OBroadcastHelper &rBHelper)
virtual css::uno::Any getFastPropertyValue(sal_Int32 nHandle) SAL_OVERRIDE
virtual void removePropertiesChangeListener(const css::uno::Reference< css::beans::XPropertiesChangeListener > &Listener) SAL_OVERRIDE
virtual void removePropertyChangeListener(const ::rtl::OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) SAL_OVERRIDE
Ignored if the property is not bound.
OPropertySetHelper(OBroadcastHelper &rBHelper, IEventNotificationHook *i_pFireEvents, bool bIgnoreRuntimeExceptionsWhileFiring=false)
Constructor.
void fire(sal_Int32 *pnHandles, const css::uno::Any *pNewValues, const css::uno::Any *pOldValues, sal_Int32 nCount, sal_Bool bVetoable)
This method fire events to all registered property listeners.
virtual void addPropertyChangeListener(const ::rtl::OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) SAL_OVERRIDE
Ignored if the property is not bound.
virtual void addVetoableChangeListener(const ::rtl::OUString &aPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) SAL_OVERRIDE
Ignored if the property is not constrained.
virtual void addPropertiesChangeListener(const css::uno::Sequence< ::rtl::OUString > &PropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &Listener) SAL_OVERRIDE
css::uno::Sequence< css::uno::Type > getTypes()
eases implementing XTypeProvider::getTypes, returns the types of XMultiPropertySet,...
static css::uno::Reference< css::beans::XPropertySetInfo > createPropertySetInfo(IPropertyArrayHelper &rProperties)
The property sequence is created in the call.
OPropertySetHelper plus XPropertySetOption.
Definition: propshlp.hxx:652
virtual void enableChangeListenerNotification(sal_Bool bEnable) SAL_OVERRIDE
virtual css::uno::Any queryInterface(const css::uno::Type &rType) SAL_OVERRIDE
Only returns a reference to XMultiPropertySet, XFastPropertySet, XPropertySet and XEventListener.
OPropertySetHelper2(OBroadcastHelper &rBHelper, IEventNotificationHook *i_pFireEvents=NULL, bool bIgnoreRuntimeExceptionsWhileFiring=false)
Constructor.
virtual ~OPropertySetHelper2()
You must call disposing before destruction.