1*2d785d7eSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2d785d7eSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2d785d7eSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2d785d7eSAndrew Rist  * distributed with this work for additional information
6*2d785d7eSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2d785d7eSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2d785d7eSAndrew Rist  * "License"); you may not use this file except in compliance
9*2d785d7eSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2d785d7eSAndrew Rist  *
11*2d785d7eSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2d785d7eSAndrew Rist  *
13*2d785d7eSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2d785d7eSAndrew Rist  * software distributed under the License is distributed on an
15*2d785d7eSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2d785d7eSAndrew Rist  * KIND, either express or implied.  See the License for the
17*2d785d7eSAndrew Rist  * specific language governing permissions and limitations
18*2d785d7eSAndrew Rist  * under the License.
19*2d785d7eSAndrew Rist  *
20*2d785d7eSAndrew Rist  *************************************************************/
21*2d785d7eSAndrew Rist 
22*2d785d7eSAndrew Rist 
23cdf0e10cSrcweir #ifndef _PROPERTYSETBASE_HXX
24cdf0e10cSrcweir #define _PROPERTYSETBASE_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir 
27cdf0e10cSrcweir // include for parent class
28cdf0e10cSrcweir #include <cppuhelper/weak.hxx>
29cdf0e10cSrcweir #include <com/sun/star/lang/XTypeProvider.hpp>
30cdf0e10cSrcweir #include <comphelper/propstate.hxx>
31cdf0e10cSrcweir #include <comphelper/propertysetinfo.hxx>
32cdf0e10cSrcweir #include <comphelper/proparrhlp.hxx>
33cdf0e10cSrcweir #include <rtl/ref.hxx>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir // include for inlined helper function below
36cdf0e10cSrcweir #include <com/sun/star/lang/IllegalArgumentException.hpp>
37cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir #include <map>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir // forward declarations for method arguments
42cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace uno {
43cdf0e10cSrcweir         class Any;
44cdf0e10cSrcweir         class Type;
45cdf0e10cSrcweir         class RuntimeException;
46cdf0e10cSrcweir         template<class T> class Sequence;
47cdf0e10cSrcweir } } } }
48cdf0e10cSrcweir 
49cdf0e10cSrcweir /** base class which encapsulates accessing (reading/writing) concrete property values
50cdf0e10cSrcweir */
51cdf0e10cSrcweir class PropertyAccessorBase : public ::rtl::IReference
52cdf0e10cSrcweir {
53cdf0e10cSrcweir private:
54cdf0e10cSrcweir     oslInterlockedCount m_refCount;
55cdf0e10cSrcweir 
56cdf0e10cSrcweir protected:
PropertyAccessorBase()57cdf0e10cSrcweir     PropertyAccessorBase() : m_refCount( 0 ) { }
58cdf0e10cSrcweir 
59cdf0e10cSrcweir public:
60cdf0e10cSrcweir     virtual oslInterlockedCount SAL_CALL acquire();
61cdf0e10cSrcweir     virtual oslInterlockedCount SAL_CALL release();
62cdf0e10cSrcweir 
63cdf0e10cSrcweir     virtual bool    approveValue( const com::sun::star::uno::Any& rValue ) const = 0;
64cdf0e10cSrcweir     virtual void    setValue( const com::sun::star::uno::Any& rValue ) = 0;
65cdf0e10cSrcweir     virtual void    getValue( com::sun::star::uno::Any& rValue ) const = 0;
66cdf0e10cSrcweir     virtual bool    isWriteable() const = 0;
67cdf0e10cSrcweir };
68cdf0e10cSrcweir 
69cdf0e10cSrcweir 
70cdf0e10cSrcweir /** helper class for implementing property accessors through public member functions
71cdf0e10cSrcweir */
72cdf0e10cSrcweir template< typename CLASS, typename VALUE, class WRITER, class READER >
73cdf0e10cSrcweir class GenericPropertyAccessor : public PropertyAccessorBase
74cdf0e10cSrcweir {
75cdf0e10cSrcweir public:
76cdf0e10cSrcweir     typedef WRITER  Writer;
77cdf0e10cSrcweir     typedef READER  Reader;
78cdf0e10cSrcweir 
79cdf0e10cSrcweir private:
80cdf0e10cSrcweir     CLASS*      m_pInstance;
81cdf0e10cSrcweir     Writer      m_pWriter;
82cdf0e10cSrcweir     Reader      m_pReader;
83cdf0e10cSrcweir 
84cdf0e10cSrcweir public:
GenericPropertyAccessor(CLASS * pInstance,Writer pWriter,Reader pReader)85cdf0e10cSrcweir     GenericPropertyAccessor( CLASS* pInstance, Writer pWriter, Reader pReader )
86cdf0e10cSrcweir         :m_pInstance( pInstance )
87cdf0e10cSrcweir         ,m_pWriter( pWriter )
88cdf0e10cSrcweir         ,m_pReader( pReader )
89cdf0e10cSrcweir     {
90cdf0e10cSrcweir     }
91cdf0e10cSrcweir 
approveValue(const com::sun::star::uno::Any & rValue) const92cdf0e10cSrcweir     virtual bool    approveValue( const com::sun::star::uno::Any& rValue ) const
93cdf0e10cSrcweir     {
94cdf0e10cSrcweir         VALUE aVal;
95cdf0e10cSrcweir         return ( rValue >>= aVal );
96cdf0e10cSrcweir     }
97cdf0e10cSrcweir 
setValue(const com::sun::star::uno::Any & rValue)98cdf0e10cSrcweir     virtual void    setValue( const com::sun::star::uno::Any& rValue )
99cdf0e10cSrcweir     {
100cdf0e10cSrcweir         VALUE aTypedVal = VALUE();
101cdf0e10cSrcweir         OSL_VERIFY( rValue >>= aTypedVal );
102cdf0e10cSrcweir         (m_pInstance->*m_pWriter)( aTypedVal );
103cdf0e10cSrcweir     }
104cdf0e10cSrcweir 
getValue(com::sun::star::uno::Any & rValue) const105cdf0e10cSrcweir     virtual void getValue( com::sun::star::uno::Any& rValue ) const
106cdf0e10cSrcweir     {
107cdf0e10cSrcweir         rValue = com::sun::star::uno::makeAny( (m_pInstance->*m_pReader)() );
108cdf0e10cSrcweir     }
109cdf0e10cSrcweir 
isWriteable() const110cdf0e10cSrcweir     virtual bool isWriteable() const
111cdf0e10cSrcweir     {
112cdf0e10cSrcweir         return m_pWriter != NULL;
113cdf0e10cSrcweir     }
114cdf0e10cSrcweir };
115cdf0e10cSrcweir 
116cdf0e10cSrcweir /** helper class for implementing property accessors via non-UNO methods
117cdf0e10cSrcweir */
118cdf0e10cSrcweir template< typename CLASS, typename VALUE >
119cdf0e10cSrcweir class DirectPropertyAccessor
120cdf0e10cSrcweir     :public GenericPropertyAccessor < CLASS
121cdf0e10cSrcweir                                 , VALUE
122cdf0e10cSrcweir                                 , void (CLASS::*)( const VALUE& )
123cdf0e10cSrcweir                                 , VALUE (CLASS::*)() const
124cdf0e10cSrcweir                                 >
125cdf0e10cSrcweir {
126cdf0e10cSrcweir protected:
127cdf0e10cSrcweir     typedef void (CLASS::*Writer)( const VALUE& );
128cdf0e10cSrcweir     typedef VALUE (CLASS::*Reader)() const;
129cdf0e10cSrcweir public:
DirectPropertyAccessor(CLASS * pInstance,Writer pWriter,Reader pReader)130cdf0e10cSrcweir     DirectPropertyAccessor( CLASS* pInstance, Writer pWriter, Reader pReader )
131cdf0e10cSrcweir         :GenericPropertyAccessor< CLASS, VALUE, Writer, Reader >( pInstance, pWriter, pReader )
132cdf0e10cSrcweir     {
133cdf0e10cSrcweir     }
134cdf0e10cSrcweir };
135cdf0e10cSrcweir 
136cdf0e10cSrcweir /** helper class for implementing non-UNO accessors to a boolean property
137cdf0e10cSrcweir */
138cdf0e10cSrcweir template< typename CLASS, typename DUMMY >
139cdf0e10cSrcweir class BooleanPropertyAccessor
140cdf0e10cSrcweir     :public GenericPropertyAccessor < CLASS
141cdf0e10cSrcweir                                 , bool
142cdf0e10cSrcweir                                 , void (CLASS::*)( bool )
143cdf0e10cSrcweir                                 , bool (CLASS::*)() const
144cdf0e10cSrcweir                                 >
145cdf0e10cSrcweir {
146cdf0e10cSrcweir protected:
147cdf0e10cSrcweir     typedef void (CLASS::*Writer)( bool );
148cdf0e10cSrcweir     typedef bool (CLASS::*Reader)() const;
149cdf0e10cSrcweir public:
BooleanPropertyAccessor(CLASS * pInstance,Writer pWriter,Reader pReader)150cdf0e10cSrcweir     BooleanPropertyAccessor( CLASS* pInstance, Writer pWriter, Reader pReader )
151cdf0e10cSrcweir         :GenericPropertyAccessor< CLASS, bool, Writer, Reader >( pInstance, pWriter, pReader )
152cdf0e10cSrcweir     {
153cdf0e10cSrcweir     }
154cdf0e10cSrcweir };
155cdf0e10cSrcweir 
156cdf0e10cSrcweir /** helper class for implementing property accessors via UNO methods
157cdf0e10cSrcweir */
158cdf0e10cSrcweir template< typename CLASS, typename VALUE >
159cdf0e10cSrcweir class APIPropertyAccessor
160cdf0e10cSrcweir     :public GenericPropertyAccessor < CLASS
161cdf0e10cSrcweir                                     , VALUE
162cdf0e10cSrcweir                                     , void (SAL_CALL CLASS::*)( const VALUE& )
163cdf0e10cSrcweir                                     , VALUE (SAL_CALL CLASS::*)()
164cdf0e10cSrcweir                                     >
165cdf0e10cSrcweir {
166cdf0e10cSrcweir protected:
167cdf0e10cSrcweir     typedef void (SAL_CALL CLASS::*Writer)( const VALUE& );
168cdf0e10cSrcweir     typedef VALUE (SAL_CALL CLASS::*Reader)();
169cdf0e10cSrcweir public:
APIPropertyAccessor(CLASS * pInstance,Writer pWriter,Reader pReader)170cdf0e10cSrcweir     APIPropertyAccessor( CLASS* pInstance, Writer pWriter, Reader pReader )
171cdf0e10cSrcweir         :GenericPropertyAccessor< CLASS, VALUE, Writer, Reader >( pInstance, pWriter, pReader )
172cdf0e10cSrcweir     {
173cdf0e10cSrcweir     }
174cdf0e10cSrcweir };
175cdf0e10cSrcweir 
176cdf0e10cSrcweir /** bridges two XPropertySet helper implementations
177cdf0e10cSrcweir 
178cdf0e10cSrcweir     The <type scope="comphelper">OStatefulPropertySet</type> (basically, the
179cdf0e10cSrcweir     <type scope="cppu">OPropertySetHelper</type>) implements a comprehensive framework
180cdf0e10cSrcweir     for property sets, including property change notifications.
181cdf0e10cSrcweir     However, it lacks some easy possibilities to declare the supported properties.
182cdf0e10cSrcweir     Other helper structs and classes allow for this, but are lacking needed features
183cdf0e10cSrcweir     such as property change notifications.
184cdf0e10cSrcweir 
185cdf0e10cSrcweir     The <type>PropertySetBase</type> bridges various implementations,
186cdf0e10cSrcweir     so you have the best of both worlds.
187cdf0e10cSrcweir  */
188cdf0e10cSrcweir class PropertySetBase : public ::comphelper::OStatefulPropertySet
189cdf0e10cSrcweir {
190cdf0e10cSrcweir private:
191cdf0e10cSrcweir     typedef com::sun::star::uno::Any    Any_t;
192cdf0e10cSrcweir 
193cdf0e10cSrcweir     typedef ::std::map< const sal_Int32, ::rtl::Reference< PropertyAccessorBase > >     PropertyAccessors;
194cdf0e10cSrcweir     typedef ::std::vector< ::com::sun::star::beans::Property >                          PropertyArray;
195cdf0e10cSrcweir     typedef ::std::map< const sal_Int32, Any_t >                                        PropertyValueCache;
196cdf0e10cSrcweir 
197cdf0e10cSrcweir     PropertyArray                   m_aProperties;
198cdf0e10cSrcweir     cppu::IPropertyArrayHelper*     m_pProperties;
199cdf0e10cSrcweir     PropertyAccessors               m_aAccessors;
200cdf0e10cSrcweir     PropertyValueCache              m_aCache;
201cdf0e10cSrcweir 
202cdf0e10cSrcweir protected:
203cdf0e10cSrcweir     PropertySetBase();
204cdf0e10cSrcweir     virtual ~PropertySetBase();
205cdf0e10cSrcweir 
206cdf0e10cSrcweir     /** registers a new property to be supported by this instance
207cdf0e10cSrcweir         @param rProperty
208cdf0e10cSrcweir             the descriptor for the to-be-supported property
209cdf0e10cSrcweir         @param rAccessor
210cdf0e10cSrcweir             an instance which is able to provide read and possibly write access to
211cdf0e10cSrcweir             the property.
212cdf0e10cSrcweir         @precond
213cdf0e10cSrcweir             Must not be called after any of the property set related UNO interfaces
214cdf0e10cSrcweir             has been used. Usually, you will do a number of <member>registerProperty</member>
215cdf0e10cSrcweir             calls in the constructor of your class.
216cdf0e10cSrcweir     */
217cdf0e10cSrcweir     void registerProperty(
218cdf0e10cSrcweir         const com::sun::star::beans::Property& rProperty,
219cdf0e10cSrcweir         const ::rtl::Reference< PropertyAccessorBase >& rAccessor
220cdf0e10cSrcweir     );
221cdf0e10cSrcweir 
222cdf0e10cSrcweir     /** notifies a change in a given property value, if necessary
223cdf0e10cSrcweir 
224cdf0e10cSrcweir         The necessity of the notification is determined by a cached value for the given
225cdf0e10cSrcweir         property. Caching happens after notification.
226cdf0e10cSrcweir 
227cdf0e10cSrcweir         That is, when you call <member>notifyAndCachePropertyValue</member> for the first time,
228cdf0e10cSrcweir         a value for the given property is default constructed, and considered to be the "old value".
229cdf0e10cSrcweir         If this value differs from the current value, then this change is notified to all interested
230cdf0e10cSrcweir         listeners. Finally, the current value is remembered.
231cdf0e10cSrcweir 
232cdf0e10cSrcweir         Subsequent calls to <member>notifyAndCachePropertyValue</member> use the remembered value as
233cdf0e10cSrcweir         "old value", and from then on behave as the first call.
234cdf0e10cSrcweir 
235cdf0e10cSrcweir         @param nHandle
236cdf0e10cSrcweir             the handle of the property. Must denote a property supported by this instance, i.e.
237cdf0e10cSrcweir             one previously registered via <member>registerProperty</member>.
238cdf0e10cSrcweir 
239cdf0e10cSrcweir         @precond
240cdf0e10cSrcweir             our ref count must not be 0. The reason is that during this method's execution,
241cdf0e10cSrcweir             the instance might be acquired and released, which would immediately destroy
242cdf0e10cSrcweir             the instance if it has a ref count of 0.
243cdf0e10cSrcweir 
244cdf0e10cSrcweir         @seealso initializePropertyValueCache
245cdf0e10cSrcweir     */
246cdf0e10cSrcweir     void notifyAndCachePropertyValue( sal_Int32 nHandle );
247cdf0e10cSrcweir 
248cdf0e10cSrcweir     /** initializes the property value cache for the given property, with its current value
249cdf0e10cSrcweir 
250cdf0e10cSrcweir         Usually used to initialize the cache with values which are different from default
251cdf0e10cSrcweir         constructed values. Say you have a boolean property whose initial state
252cdf0e10cSrcweir         is <TRUE/>. Say you call <member>notifyAndCachePropertyValue</member> the first time: it will
253cdf0e10cSrcweir         default construct the "old value" for this property as <FALSE/>, and thus <b>not</b> do
254cdf0e10cSrcweir         any notifications if the "current value" is also <FALSE/> - which might be wrong, since
255cdf0e10cSrcweir         the guessing of the "old value" differed from the real initial value which was <TRUE/>.
256cdf0e10cSrcweir 
257cdf0e10cSrcweir         Too confusing? Okay, than just call this method for every property you have.
258cdf0e10cSrcweir 
259cdf0e10cSrcweir         @param nHandle
260cdf0e10cSrcweir             the handle of the property. Must denote a property supported by this instance, i.e.
261cdf0e10cSrcweir             one previously registered via <member>registerProperty</member>.
262cdf0e10cSrcweir         @param rValue
263cdf0e10cSrcweir             the value to cache
264cdf0e10cSrcweir         @seealso notifyAndCachePropertyValue
265cdf0e10cSrcweir     */
266cdf0e10cSrcweir     void initializePropertyValueCache( sal_Int32 nHandle );
267cdf0e10cSrcweir 
268cdf0e10cSrcweir     /// OPropertysetHelper methods
269cdf0e10cSrcweir     virtual sal_Bool SAL_CALL convertFastPropertyValue( Any_t& rConvertedValue, Any_t& rOldValue, sal_Int32 nHandle, const Any_t& rValue )
270cdf0e10cSrcweir 		throw (::com::sun::star::lang::IllegalArgumentException);
271cdf0e10cSrcweir 	virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any_t& rValue )
272cdf0e10cSrcweir         throw (::com::sun::star::uno::Exception);
273cdf0e10cSrcweir 	virtual void SAL_CALL getFastPropertyValue( Any_t& rValue, sal_Int32 nHandle ) const;
274cdf0e10cSrcweir 
275cdf0e10cSrcweir     virtual cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
276cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException);
277cdf0e10cSrcweir 
278cdf0e10cSrcweir public:
279cdf0e10cSrcweir     /// helper struct for granting selective access to some notification-related methods
NotifierAccessPropertySetBase::NotifierAccess280cdf0e10cSrcweir     struct NotifierAccess { friend struct PropertyChangeNotifier; private: NotifierAccess() { } };
281cdf0e10cSrcweir     /** retrieves the current property value for the given handle
282cdf0e10cSrcweir         @param nHandle
283cdf0e10cSrcweir             the handle of the property. Must denote a property supported by this instance, i.e.
284cdf0e10cSrcweir             one previously registered via <member>registerProperty</member>.
285cdf0e10cSrcweir         @see registerProperty
286cdf0e10cSrcweir     */
getCurrentPropertyValueByHandle(sal_Int32 nHandle,Any_t & rValue,const NotifierAccess &) const287cdf0e10cSrcweir     inline void getCurrentPropertyValueByHandle( sal_Int32 nHandle, Any_t& /* [out] */ rValue, const NotifierAccess& ) const
288cdf0e10cSrcweir     {
289cdf0e10cSrcweir         getFastPropertyValue( rValue, nHandle );
290cdf0e10cSrcweir     }
291cdf0e10cSrcweir 
292cdf0e10cSrcweir     /** notifies a change in a given property to all interested listeners
293cdf0e10cSrcweir     */
notifyPropertyChange(sal_Int32 nHandle,const Any_t & rOldValue,const Any_t & rNewValue,const NotifierAccess &) const294cdf0e10cSrcweir 	inline void notifyPropertyChange( sal_Int32 nHandle, const Any_t& rOldValue, const Any_t& rNewValue, const NotifierAccess& ) const
295cdf0e10cSrcweir     {
296cdf0e10cSrcweir         const_cast< PropertySetBase* >( this )->firePropertyChange( nHandle, rNewValue, rOldValue );
297cdf0e10cSrcweir     }
298cdf0e10cSrcweir 
299cdf0e10cSrcweir     using ::comphelper::OStatefulPropertySet::getFastPropertyValue;
300cdf0e10cSrcweir 
301cdf0e10cSrcweir private:
302cdf0e10cSrcweir     /** locates a property given by handle
303cdf0e10cSrcweir         @param nHandle
304cdf0e10cSrcweir             the handle of the property. Must denote a property supported by this instance, i.e.
305cdf0e10cSrcweir             one previously registered via <member>registerProperty</member>.
306cdf0e10cSrcweir         @see registerProperty
307cdf0e10cSrcweir     */
308cdf0e10cSrcweir     PropertyAccessorBase& locatePropertyHandler( sal_Int32 nHandle ) const;
309cdf0e10cSrcweir };
310cdf0e10cSrcweir 
311cdf0e10cSrcweir /** a helper class for notifying property changes in a <type>PropertySetBase</type> instance.
312cdf0e10cSrcweir 
313cdf0e10cSrcweir     You can create an instance of this class on the stack of a method which is to programmatically
314cdf0e10cSrcweir     change the value of a property. In its constructor, the instance will acquire the current property
315cdf0e10cSrcweir     value, and in its destructor, it will notify the change of this property's value (if necessary).
316cdf0e10cSrcweir 
317cdf0e10cSrcweir     You do not need this class if you are modifying property values by using the X(Fast|Multi)PropertSet
318cdf0e10cSrcweir     methods, since those already care for property notifications. You only need it if you're changing
319cdf0e10cSrcweir     the internal representation of your property directly.
320cdf0e10cSrcweir 
321cdf0e10cSrcweir     Also note that usually, notifications in the UNO world should be done without a locked mutex. So
322cdf0e10cSrcweir     if you use this class in conjunction with a <type>MutexGuard</type>, ensure that you <b>first</b>
323cdf0e10cSrcweir     instantiate the <type>PropertyChangeNotifier</type>, and <b>then</b> the <type>MutexGuard</type>,
324cdf0e10cSrcweir     so your mutex is released before the notification happens.
325cdf0e10cSrcweir */
326cdf0e10cSrcweir struct PropertyChangeNotifier
327cdf0e10cSrcweir {
328cdf0e10cSrcweir private:
329cdf0e10cSrcweir     const PropertySetBase&      m_rPropertySet;
330cdf0e10cSrcweir     sal_Int32                   m_nHandle;
331cdf0e10cSrcweir     com::sun::star::uno::Any    m_aOldValue;
332cdf0e10cSrcweir 
333cdf0e10cSrcweir public:
334cdf0e10cSrcweir     /** constructs a PropertyChangeNotifier
335cdf0e10cSrcweir         @param rPropertySet
336cdf0e10cSrcweir             the property set implementation whose property is going to be changed. Note
337cdf0e10cSrcweir             that this property set implementation must live at least as long as the
338cdf0e10cSrcweir             PropertyChangeNotifier instance does.
339cdf0e10cSrcweir         @param nHandle
340cdf0e10cSrcweir             the handle of the property which is going to be changed. Must be a valid property
341cdf0e10cSrcweir             handle for the given <arg>rPropertySet</arg>
342cdf0e10cSrcweir     */
PropertyChangeNotifierPropertyChangeNotifier343cdf0e10cSrcweir     inline PropertyChangeNotifier( const PropertySetBase& rPropertySet, sal_Int32 nHandle )
344cdf0e10cSrcweir         :m_rPropertySet( rPropertySet )
345cdf0e10cSrcweir         ,m_nHandle( nHandle )
346cdf0e10cSrcweir     {
347cdf0e10cSrcweir         m_rPropertySet.getCurrentPropertyValueByHandle( m_nHandle, m_aOldValue, PropertySetBase::NotifierAccess() );
348cdf0e10cSrcweir     }
~PropertyChangeNotifierPropertyChangeNotifier349cdf0e10cSrcweir     inline ~PropertyChangeNotifier()
350cdf0e10cSrcweir     {
351cdf0e10cSrcweir         com::sun::star::uno::Any aNewValue;
352cdf0e10cSrcweir         m_rPropertySet.getCurrentPropertyValueByHandle( m_nHandle, aNewValue, PropertySetBase::NotifierAccess() );
353cdf0e10cSrcweir         if ( aNewValue != m_aOldValue )
354cdf0e10cSrcweir         {
355cdf0e10cSrcweir             m_rPropertySet.notifyPropertyChange( m_nHandle, m_aOldValue, aNewValue, PropertySetBase::NotifierAccess() );
356cdf0e10cSrcweir         }
357cdf0e10cSrcweir     }
358cdf0e10cSrcweir };
359cdf0e10cSrcweir 
360cdf0e10cSrcweir 
361cdf0e10cSrcweir #define PROPERTY_FLAGS( NAME, TYPE, FLAG ) com::sun::star::beans::Property( \
362cdf0e10cSrcweir     ::rtl::OUString( #NAME, sizeof( #NAME ) - 1, RTL_TEXTENCODING_ASCII_US ), \
363cdf0e10cSrcweir     HANDLE_##NAME, getCppuType( static_cast< TYPE* >( NULL ) ), FLAG )
364cdf0e10cSrcweir #define PROPERTY( NAME, TYPE )      PROPERTY_FLAGS( NAME, TYPE, com::sun::star::beans::PropertyAttribute::BOUND )
365cdf0e10cSrcweir #define PROPERTY_RO( NAME, TYPE )   PROPERTY_FLAGS( NAME, TYPE, com::sun::star::beans::PropertyAttribute::BOUND | com::sun::star::beans::PropertyAttribute::READONLY )
366cdf0e10cSrcweir 
367cdf0e10cSrcweir #endif
368