xref: /AOO41X/main/comphelper/inc/comphelper/ChainablePropertySet.hxx (revision 9877b273795ec465a3ce9c15d738eb34c0455705)
1*9877b273SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*9877b273SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*9877b273SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*9877b273SAndrew Rist  * distributed with this work for additional information
6*9877b273SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*9877b273SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*9877b273SAndrew Rist  * "License"); you may not use this file except in compliance
9*9877b273SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*9877b273SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*9877b273SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*9877b273SAndrew Rist  * software distributed under the License is distributed on an
15*9877b273SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9877b273SAndrew Rist  * KIND, either express or implied.  See the License for the
17*9877b273SAndrew Rist  * specific language governing permissions and limitations
18*9877b273SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*9877b273SAndrew Rist  *************************************************************/
21*9877b273SAndrew Rist 
22*9877b273SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _COMPHELPER_CHAINABLEPROPERTYSET_HXX_
25cdf0e10cSrcweir #define _COMPHELPER_CHAINABLEPROPERTYSET_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
28cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyState.hpp>
29cdf0e10cSrcweir #include <com/sun/star/beans/XMultiPropertySet.hpp>
30cdf0e10cSrcweir #include <comphelper/PropertyInfoHash.hxx>
31cdf0e10cSrcweir #include "comphelper/comphelperdllapi.h"
32cdf0e10cSrcweir 
33cdf0e10cSrcweir namespace comphelper
34cdf0e10cSrcweir {
35cdf0e10cSrcweir 	class ChainablePropertySetInfo;
36cdf0e10cSrcweir }
37cdf0e10cSrcweir namespace vos
38cdf0e10cSrcweir {
39cdf0e10cSrcweir 	class IMutex;
40cdf0e10cSrcweir }
41cdf0e10cSrcweir /*
42cdf0e10cSrcweir  * A ChainablePropertySet has the following features:
43cdf0e10cSrcweir  *
44cdf0e10cSrcweir  * 1. It implements both the PropertySet and MultiPropertySet interfaces.
45cdf0e10cSrcweir  * 2. It can be 'included' in a MasterPropertySet to seamlessly appear as if
46cdf0e10cSrcweir  *    if it's properties were in the master.
47cdf0e10cSrcweir  *
48cdf0e10cSrcweir  * To be used as a base class for PropertySets, the subclass must implement
49cdf0e10cSrcweir  * the 6 protected pure virtual functions. If a mutex is passed to the
50cdf0e10cSrcweir  * constructor, this is locked before any call to _getSingleValue or
51cdf0e10cSrcweir  * _setSingleValue and released after all processing has completed
52cdf0e10cSrcweir  * (including _postSetValues or _postGetValues )
53cdf0e10cSrcweir  *
54cdf0e10cSrcweir  * The implementations of getPropertyValues/setPropertyValues call
55cdf0e10cSrcweir  * lockMutex and _preGetValues/_preSetValues once before calling
56cdf0e10cSrcweir  * _getSingleValue/_setSingleValue for each property. After each
57cdf0e10cSrcweir  * property has been dealt with, _postGetValues/_postSetValues
58cdf0e10cSrcweir  * are called once.
59cdf0e10cSrcweir  *
60cdf0e10cSrcweir  * Any MasterPropertySet implementations that can include an
61cdf0e10cSrcweir  * implementation of a given ChainablePropertySet must be
62cdf0e10cSrcweir  * declared as a 'friend' in the implementation of the ChainablePropertySet.
63cdf0e10cSrcweir  *
64cdf0e10cSrcweir  */
65cdf0e10cSrcweir 
66cdf0e10cSrcweir namespace comphelper
67cdf0e10cSrcweir {
68cdf0e10cSrcweir 	class COMPHELPER_DLLPUBLIC ChainablePropertySet : public ::com::sun::star::beans::XPropertySet,
69cdf0e10cSrcweir 								 public ::com::sun::star::beans::XPropertyState,
70cdf0e10cSrcweir 								 public ::com::sun::star::beans::XMultiPropertySet
71cdf0e10cSrcweir 	{
72cdf0e10cSrcweir 		friend class MasterPropertySet;
73cdf0e10cSrcweir 	protected:
74cdf0e10cSrcweir 		ChainablePropertySetInfo *mpInfo;
75cdf0e10cSrcweir 		vos::IMutex *mpMutex;
76cdf0e10cSrcweir 		::com::sun::star::uno::Reference < com::sun::star::beans::XPropertySetInfo > mxInfo;
77cdf0e10cSrcweir 		void lockMutex();
78cdf0e10cSrcweir 		void unlockMutex();
79cdf0e10cSrcweir 
80cdf0e10cSrcweir 		virtual void _preSetValues ()
81cdf0e10cSrcweir 			throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException ) = 0;
82cdf0e10cSrcweir 		virtual void _setSingleValue( const comphelper::PropertyInfo & rInfo, const ::com::sun::star::uno::Any &rValue )
83cdf0e10cSrcweir 			throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException ) = 0;
84cdf0e10cSrcweir 		virtual void _postSetValues ()
85cdf0e10cSrcweir 			throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException ) = 0;
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 		virtual void _preGetValues ()
88cdf0e10cSrcweir 			throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException ) = 0;
89cdf0e10cSrcweir 		virtual void _getSingleValue( const comphelper::PropertyInfo & rInfo, ::com::sun::star::uno::Any & rValue )
90cdf0e10cSrcweir 			throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException ) = 0;
91cdf0e10cSrcweir 		virtual void _postGetValues ()
92cdf0e10cSrcweir 			throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException ) = 0;
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 		virtual void _preGetPropertyState ()
95cdf0e10cSrcweir 			throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException );
96cdf0e10cSrcweir 		virtual void _getPropertyState( const comphelper::PropertyInfo& rInfo, ::com::sun::star::beans::PropertyState& rState )
97cdf0e10cSrcweir 			throw(::com::sun::star::beans::UnknownPropertyException );
98cdf0e10cSrcweir 		virtual void _postGetPropertyState ()
99cdf0e10cSrcweir 			throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException );
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 		virtual void _setPropertyToDefault( const comphelper::PropertyInfo& rEntry )
102cdf0e10cSrcweir 			throw(::com::sun::star::beans::UnknownPropertyException );
103cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Any _getPropertyDefault( const comphelper::PropertyInfo& rEntry )
104cdf0e10cSrcweir 			throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException );
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 	public:
107cdf0e10cSrcweir 		ChainablePropertySet( comphelper::ChainablePropertySetInfo* pInfo, vos::IMutex *pMutex = NULL )
108cdf0e10cSrcweir 			throw();
109cdf0e10cSrcweir 		virtual ~ChainablePropertySet()
110cdf0e10cSrcweir 			throw();
111cdf0e10cSrcweir 
112cdf0e10cSrcweir 		// XPropertySet
113cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  )
114cdf0e10cSrcweir 			throw(::com::sun::star::uno::RuntimeException);
115cdf0e10cSrcweir 		virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue )
116cdf0e10cSrcweir 			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);
117cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName )
118cdf0e10cSrcweir 			throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
119cdf0e10cSrcweir 		virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener )
120cdf0e10cSrcweir 			throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
121cdf0e10cSrcweir 		virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener )
122cdf0e10cSrcweir 			throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
123cdf0e10cSrcweir 		virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener )
124cdf0e10cSrcweir 			throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
125cdf0e10cSrcweir 		virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener )
126cdf0e10cSrcweir 			throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
127cdf0e10cSrcweir 
128cdf0e10cSrcweir 		// XMultiPropertySet
129cdf0e10cSrcweir 		virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues )
130cdf0e10cSrcweir 			throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
131cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames )
132cdf0e10cSrcweir 			throw(::com::sun::star::uno::RuntimeException);
133cdf0e10cSrcweir 		virtual void SAL_CALL addPropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener )
134cdf0e10cSrcweir 			throw(::com::sun::star::uno::RuntimeException);
135cdf0e10cSrcweir 		virtual void SAL_CALL removePropertiesChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener )
136cdf0e10cSrcweir 			throw(::com::sun::star::uno::RuntimeException);
137cdf0e10cSrcweir 		virtual void SAL_CALL firePropertiesChangeEvent( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener )
138cdf0e10cSrcweir 			throw(::com::sun::star::uno::RuntimeException);
139cdf0e10cSrcweir 
140cdf0e10cSrcweir 		// XPropertyState
141cdf0e10cSrcweir 		virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName )
142cdf0e10cSrcweir 			throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
143cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName )
144cdf0e10cSrcweir 			throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
145cdf0e10cSrcweir 		virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName )
146cdf0e10cSrcweir 			throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
147cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName )
148cdf0e10cSrcweir 			throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
149cdf0e10cSrcweir 	};
150cdf0e10cSrcweir }
151cdf0e10cSrcweir #endif
152cdf0e10cSrcweir 
153