LibreOffice Module forms (master) 1
|
bridges two XPropertySet helper implementations More...
#include <propertysetbase.hxx>
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 | |
PropertyAccessorBase & | locatePropertyHandler (sal_Int32 nHandle) const |
locates a property given by handle More... | |
Private Attributes | |
PropertyArray | m_aProperties |
std::unique_ptr< cppu::IPropertyArrayHelper > | m_pProperties |
PropertyAccessors | m_aAccessors |
PropertyValueCache | m_aCache |
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.
|
private |
Definition at line 175 of file propertysetbase.hxx.
|
private |
Definition at line 176 of file propertysetbase.hxx.
|
private |
Definition at line 177 of file propertysetbase.hxx.
|
protected |
Definition at line 37 of file propertysetbase.cxx.
|
overrideprotectedvirtual |
Definition at line 41 of file propertysetbase.cxx.
|
overrideprotectedvirtual |
OPropertysetHelper methods.
Definition at line 130 of file propertysetbase.cxx.
References PropertyAccessorBase::approveValue(), PropertyAccessorBase::getValue(), locatePropertyHandler(), and nHandle.
Referenced by xforms::Submission::convertFastPropertyValue().
|
inline |
retrieves the current property value for the given handle
nHandle | the handle of the property. Must denote a property supported by this instance, i.e. one previously registered via <member>registerProperty</member>. |
Definition at line 267 of file propertysetbase.hxx.
References getFastPropertyValue(), and nHandle.
Referenced by PropertyChangeNotifier::PropertyChangeNotifier(), and PropertyChangeNotifier::~PropertyChangeNotifier().
|
overrideprotectedvirtual |
Definition at line 152 of file propertysetbase.cxx.
References PropertyAccessorBase::getValue(), locatePropertyHandler(), and nHandle.
Referenced by getCurrentPropertyValueByHandle(), initializePropertyValueCache(), and notifyAndCachePropertyValue().
|
overrideprotectedvirtual |
Definition at line 45 of file propertysetbase.cxx.
References m_aProperties, and m_pProperties.
Referenced by getPropertySetInfo(), and notifyAndCachePropertyValue().
|
overrideprotectedvirtual |
Definition at line 55 of file propertysetbase.cxx.
References cppu::OPropertySetHelper::createPropertySetInfo(), and getInfoHelper().
Referenced by xforms::Model::getPropertySetInfo(), and xforms::Submission::getPropertySetInfo().
|
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.
nHandle | the handle of the property. Must denote a property supported by this instance, i.e. one previously registered via <member>registerProperty</member>. |
rValue | the value to cache @seealso notifyAndCachePropertyValue |
Definition at line 110 of file propertysetbase.cxx.
References Any, getFastPropertyValue(), m_aCache, and nHandle.
|
private |
locates a property given by handle
nHandle | the handle of the property. Must denote a property supported by this instance, i.e. one previously registered via <member>registerProperty</member>. |
Definition at line 120 of file propertysetbase.cxx.
References m_aAccessors, and nHandle.
Referenced by convertFastPropertyValue(), getFastPropertyValue(), and setFastPropertyValue_NoBroadcast().
|
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.
nHandle | the 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.
|
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().
|
protected |
registers a new property to be supported by this instance
rProperty | the descriptor for the to-be-supported property |
rAccessor | an 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.
|
overrideprotectedvirtual |
Definition at line 146 of file propertysetbase.cxx.
References locatePropertyHandler(), nHandle, and PropertyAccessorBase::setValue().
|
private |
Definition at line 181 of file propertysetbase.hxx.
Referenced by locatePropertyHandler(), and registerProperty().
|
private |
Definition at line 182 of file propertysetbase.hxx.
Referenced by initializePropertyValueCache(), and notifyAndCachePropertyValue().
|
private |
Definition at line 179 of file propertysetbase.hxx.
Referenced by getInfoHelper(), and registerProperty().
|
private |
Definition at line 180 of file propertysetbase.hxx.
Referenced by getInfoHelper().