LibreOffice Module forms (master) 1
Classes | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
PropertySetBase Class Reference

bridges two XPropertySet helper implementations More...

#include <propertysetbase.hxx>

Inheritance diagram for PropertySetBase:
[legend]
Collaboration diagram for PropertySetBase:
[legend]

Classes

struct  NotifierAccess
 helper struct for granting selective access to some notification-related methods More...
 

Public Member Functions

void getCurrentPropertyValueByHandle (sal_Int32 nHandle, css::uno::Any &rValue, const NotifierAccess &) const
 retrieves the current property value for the given handle More...
 
void notifyPropertyChange (sal_Int32 nHandle, const css::uno::Any &rOldValue, const css::uno::Any &rNewValue, const NotifierAccess &) const
 notifies a change in a given property to all interested listeners More...
 

Protected Member Functions

 PropertySetBase ()
 
virtual ~PropertySetBase () override
 
void registerProperty (const css::beans::Property &rProperty, const ::rtl::Reference< PropertyAccessorBase > &rAccessor)
 registers a new property to be supported by this instance More...
 
void notifyAndCachePropertyValue (sal_Int32 nHandle)
 notifies a change in a given property value, if necessary More...
 
void initializePropertyValueCache (sal_Int32 nHandle)
 initializes the property value cache for the given property, with its current value More...
 
virtual sal_Bool SAL_CALL convertFastPropertyValue (css::uno::Any &rConvertedValue, css::uno::Any &rOldValue, sal_Int32 nHandle, const css::uno::Any &rValue) override
 OPropertysetHelper methods. More...
 
virtual void SAL_CALL setFastPropertyValue_NoBroadcast (sal_Int32 nHandle, const css::uno::Any &rValue) override
 
virtual void SAL_CALL getFastPropertyValue (css::uno::Any &rValue, sal_Int32 nHandle) const override
 
virtual cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper () override
 
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo () override
 

Private Types

typedef ::std::map< const sal_Int32, ::rtl::Reference< PropertyAccessorBase > > PropertyAccessors
 
typedef ::std::vector< css::beans::Property > PropertyArray
 
typedef ::std::map< const sal_Int32, css::uno::Any > PropertyValueCache
 

Private Member Functions

PropertyAccessorBaselocatePropertyHandler (sal_Int32 nHandle) const
 locates a property given by handle More...
 

Private Attributes

PropertyArray m_aProperties
 
std::unique_ptr< cppu::IPropertyArrayHelperm_pProperties
 
PropertyAccessors m_aAccessors
 
PropertyValueCache m_aCache
 

Detailed Description

bridges two XPropertySet helper implementations

The <type scope="comphelper">OStatefulPropertySet</type> (basically, the <type scope="cppu">OPropertySetHelper</type>) implements a comprehensive framework for property sets, including property change notifications. However, it lacks some easy possibilities to declare the supported properties. Other helper structs and classes allow for this, but are lacking needed features such as property change notifications.

The <type>PropertySetBase</type> bridges various implementations, so you have the best of both worlds.

Definition at line 172 of file propertysetbase.hxx.

Member Typedef Documentation

◆ PropertyAccessors

Definition at line 175 of file propertysetbase.hxx.

◆ PropertyArray

typedef ::std::vector< css::beans::Property > PropertySetBase::PropertyArray
private

Definition at line 176 of file propertysetbase.hxx.

◆ PropertyValueCache

typedef ::std::map< const sal_Int32, css::uno::Any > PropertySetBase::PropertyValueCache
private

Definition at line 177 of file propertysetbase.hxx.

Constructor & Destructor Documentation

◆ PropertySetBase()

PropertySetBase::PropertySetBase ( )
protected

Definition at line 37 of file propertysetbase.cxx.

◆ ~PropertySetBase()

PropertySetBase::~PropertySetBase ( )
overrideprotectedvirtual

Definition at line 41 of file propertysetbase.cxx.

Member Function Documentation

◆ convertFastPropertyValue()

sal_Bool SAL_CALL PropertySetBase::convertFastPropertyValue ( css::uno::Any &  rConvertedValue,
css::uno::Any &  rOldValue,
sal_Int32  nHandle,
const css::uno::Any &  rValue 
)
overrideprotectedvirtual

◆ getCurrentPropertyValueByHandle()

void PropertySetBase::getCurrentPropertyValueByHandle ( sal_Int32  nHandle,
css::uno::Any &  rValue,
const NotifierAccess  
) const
inline

retrieves the current property value for the given handle

Parameters
nHandlethe handle of the property. Must denote a property supported by this instance, i.e. one previously registered via <member>registerProperty</member>.
See also
registerProperty

Definition at line 267 of file propertysetbase.hxx.

References getFastPropertyValue(), and nHandle.

Referenced by PropertyChangeNotifier::PropertyChangeNotifier(), and PropertyChangeNotifier::~PropertyChangeNotifier().

◆ getFastPropertyValue()

void SAL_CALL PropertySetBase::getFastPropertyValue ( css::uno::Any &  rValue,
sal_Int32  nHandle 
) const
overrideprotectedvirtual

◆ getInfoHelper()

cppu::IPropertyArrayHelper &SAL_CALL PropertySetBase::getInfoHelper ( )
overrideprotectedvirtual

Definition at line 45 of file propertysetbase.cxx.

References m_aProperties, and m_pProperties.

Referenced by getPropertySetInfo(), and notifyAndCachePropertyValue().

◆ getPropertySetInfo()

Reference< XPropertySetInfo > SAL_CALL PropertySetBase::getPropertySetInfo ( )
overrideprotectedvirtual

◆ initializePropertyValueCache()

void PropertySetBase::initializePropertyValueCache ( sal_Int32  nHandle)
protected

initializes the property value cache for the given property, with its current value

Usually used to initialize the cache with values which are different from default constructed values. Say you have a boolean property whose initial state is <TRUE>. Say you call <member>notifyAndCachePropertyValue</member> the first time: it will default construct the "old value" for this property as <FALSE>, and thus not do any notifications if the "current value" is also <FALSE> - which might be wrong, since the guessing of the "old value" differed from the real initial value which was <TRUE>.

Too confusing? Okay, then just call this method for every property you have.

Parameters
nHandlethe handle of the property. Must denote a property supported by this instance, i.e. one previously registered via <member>registerProperty</member>.
rValuethe value to cache @seealso notifyAndCachePropertyValue

Definition at line 110 of file propertysetbase.cxx.

References Any, getFastPropertyValue(), m_aCache, and nHandle.

◆ locatePropertyHandler()

PropertyAccessorBase & PropertySetBase::locatePropertyHandler ( sal_Int32  nHandle) const
private

locates a property given by handle

Parameters
nHandlethe handle of the property. Must denote a property supported by this instance, i.e. one previously registered via <member>registerProperty</member>.
See also
registerProperty

Definition at line 120 of file propertysetbase.cxx.

References m_aAccessors, and nHandle.

Referenced by convertFastPropertyValue(), getFastPropertyValue(), and setFastPropertyValue_NoBroadcast().

◆ notifyAndCachePropertyValue()

void PropertySetBase::notifyAndCachePropertyValue ( sal_Int32  nHandle)
protected

notifies a change in a given property value, if necessary

The necessity of the notification is determined by a cached value for the given property. Caching happens after notification.

That is, when you call <member>notifyAndCachePropertyValue</member> for the first time, a value for the given property is default constructed, and considered to be the "old value". If this value differs from the current value, then this change is notified to all interested listeners. Finally, the current value is remembered.

Subsequent calls to <member>notifyAndCachePropertyValue</member> use the remembered value as "old value", and from then on behave as the first call.

Parameters
nHandlethe handle of the property. Must denote a property supported by this instance, i.e. one previously registered via <member>registerProperty</member>.

@precond our ref count must not be 0. The reason is that during this method's execution, the instance might be acquired and released, which would immediately destroy the instance if it has a ref count of 0.

@seealso initializePropertyValueCache

Definition at line 74 of file propertysetbase.cxx.

References Any, Exception, cppu::IPropertyArrayHelper::fillPropertyMembersByHandle(), getFastPropertyValue(), getInfoHelper(), cppu::IPropertyArrayHelper::getPropertyByName(), m_aCache, nHandle, and Property.

◆ notifyPropertyChange()

void PropertySetBase::notifyPropertyChange ( sal_Int32  nHandle,
const css::uno::Any &  rOldValue,
const css::uno::Any &  rNewValue,
const NotifierAccess  
) const
inline

notifies a change in a given property to all interested listeners

Definition at line 274 of file propertysetbase.hxx.

References nHandle.

Referenced by PropertyChangeNotifier::~PropertyChangeNotifier().

◆ registerProperty()

void PropertySetBase::registerProperty ( const css::beans::Property &  rProperty,
const ::rtl::Reference< PropertyAccessorBase > &  rAccessor 
)
protected

registers a new property to be supported by this instance

Parameters
rPropertythe descriptor for the to-be-supported property
rAccessoran instance which is able to provide read and possibly write access to the property. @precond Must not be called after any of the property set related UNO interfaces has been used. Usually, you will do a number of <member>registerProperty</member> calls in the constructor of your class.

Definition at line 60 of file propertysetbase.cxx.

References m_aAccessors, and m_aProperties.

◆ setFastPropertyValue_NoBroadcast()

void SAL_CALL PropertySetBase::setFastPropertyValue_NoBroadcast ( sal_Int32  nHandle,
const css::uno::Any &  rValue 
)
overrideprotectedvirtual

Member Data Documentation

◆ m_aAccessors

PropertyAccessors PropertySetBase::m_aAccessors
private

Definition at line 181 of file propertysetbase.hxx.

Referenced by locatePropertyHandler(), and registerProperty().

◆ m_aCache

PropertyValueCache PropertySetBase::m_aCache
private

◆ m_aProperties

PropertyArray PropertySetBase::m_aProperties
private

Definition at line 179 of file propertysetbase.hxx.

Referenced by getInfoHelper(), and registerProperty().

◆ m_pProperties

std::unique_ptr<cppu::IPropertyArrayHelper> PropertySetBase::m_pProperties
private

Definition at line 180 of file propertysetbase.hxx.

Referenced by getInfoHelper().


The documentation for this class was generated from the following files: