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
10*9877b273SAndrew Rist  *
11*9877b273SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*9877b273SAndrew Rist  *
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.
19*9877b273SAndrew Rist  *
20*9877b273SAndrew Rist  *************************************************************/
21*9877b273SAndrew Rist 
22*9877b273SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef COMPHELPER_PROPERTYSTATECONTAINER_HXX
25cdf0e10cSrcweir #define COMPHELPER_PROPERTYSTATECONTAINER_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <comphelper/propertycontainer.hxx>
28cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyState.hpp>
29cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
30cdf0e10cSrcweir #include <comphelper/uno3.hxx>
31cdf0e10cSrcweir #include <osl/diagnose.h>
32cdf0e10cSrcweir #include "comphelper/comphelperdllapi.h"
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #include <map>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir //.........................................................................
37cdf0e10cSrcweir namespace comphelper
38cdf0e10cSrcweir {
39cdf0e10cSrcweir //.........................................................................
40cdf0e10cSrcweir 
41cdf0e10cSrcweir 	//=====================================================================
42cdf0e10cSrcweir 	//= OPropertyStateContainer
43cdf0e10cSrcweir 	//=====================================================================
44cdf0e10cSrcweir 	typedef ::cppu::ImplHelper1	<	::com::sun::star::beans::XPropertyState
45cdf0e10cSrcweir 								>	OPropertyStateContainer_TBase;
46cdf0e10cSrcweir 
47cdf0e10cSrcweir 	/** helper implementation for components which have properties with a default
48cdf0e10cSrcweir 
49cdf0e10cSrcweir 		<p>This class is not intended for direct use, you need to derive from it.</p>
50cdf0e10cSrcweir 
51cdf0e10cSrcweir 		@see com.sun.star.beans.XPropertyState
52cdf0e10cSrcweir 	*/
53cdf0e10cSrcweir 	class COMPHELPER_DLLPUBLIC OPropertyStateContainer
54cdf0e10cSrcweir 				:public  OPropertyContainer
55cdf0e10cSrcweir 				,public  OPropertyStateContainer_TBase
56cdf0e10cSrcweir 	{
57cdf0e10cSrcweir 	protected:
58cdf0e10cSrcweir 		/** ctor
59cdf0e10cSrcweir 			@param _rBHelper
60cdf0e10cSrcweir 				help to be used for broadcasting events
61cdf0e10cSrcweir 		*/
62cdf0e10cSrcweir 		OPropertyStateContainer( ::cppu::OBroadcastHelper&	_rBHelper );
63cdf0e10cSrcweir 
64cdf0e10cSrcweir 		// ................................................................
65cdf0e10cSrcweir 		// XPropertyState
66cdf0e10cSrcweir 		virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
67cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
68cdf0e10cSrcweir 		virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
69cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
70cdf0e10cSrcweir 
71cdf0e10cSrcweir 		// ................................................................
72cdf0e10cSrcweir 		// own overridables
73cdf0e10cSrcweir 		// these are the impl-methods for the XPropertyState members - they are implemented already by this class,
74cdf0e10cSrcweir 		// but you may want to override them for whatever reasons (for instance, if your derived class
75cdf0e10cSrcweir 		// supports the AMBIGUOUS state for properties)
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 		/** get the PropertyState of the property denoted by the given handle
78cdf0e10cSrcweir 
79cdf0e10cSrcweir 			<p>Already implemented by this base class, no need to override</p>
80cdf0e10cSrcweir 			@precond <arg>_nHandle</arg> is a valid property handle
81cdf0e10cSrcweir 		*/
82cdf0e10cSrcweir 		virtual ::com::sun::star::beans::PropertyState	getPropertyStateByHandle( sal_Int32 _nHandle );
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 		/** set the property denoted by the given handle to it's default value
85cdf0e10cSrcweir 
86cdf0e10cSrcweir 			<p>Already implemented by this base class, no need to override</p>
87cdf0e10cSrcweir 			@precond <arg>_nHandle</arg> is a valid property handle
88cdf0e10cSrcweir 		*/
89cdf0e10cSrcweir 		virtual void									setPropertyToDefaultByHandle( sal_Int32 _nHandle );
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 		/** get the default value for the property denoted by the given handle
92cdf0e10cSrcweir 
93cdf0e10cSrcweir 			@precond
94cdf0e10cSrcweir                 <arg>_nHandle</arg> is a valid property handle
95cdf0e10cSrcweir 		*/
96cdf0e10cSrcweir 		virtual void getPropertyDefaultByHandle( sal_Int32 _nHandle, ::com::sun::star::uno::Any& _rDefault ) const = 0;
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 	protected:
99cdf0e10cSrcweir 		// XInterface
100cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException);
101cdf0e10cSrcweir 		// XTypeProvider
102cdf0e10cSrcweir 		DECLARE_XTYPEPROVIDER( )
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 	protected:
105cdf0e10cSrcweir         /** returns the handle for the given name
106cdf0e10cSrcweir 
107cdf0e10cSrcweir             @throw UnknownPropertyException if the given name is not a registered property
108cdf0e10cSrcweir         */
109cdf0e10cSrcweir 		sal_Int32	getHandleForName( const ::rtl::OUString& _rPropertyName ) SAL_THROW( ( ::com::sun::star::beans::UnknownPropertyException ) );
110cdf0e10cSrcweir 	};
111cdf0e10cSrcweir 
112cdf0e10cSrcweir //.........................................................................
113cdf0e10cSrcweir }	// namespace comphelper
114cdf0e10cSrcweir //.........................................................................
115cdf0e10cSrcweir 
116cdf0e10cSrcweir #endif // COMPHELPER_PROPERTYSTATECONTAINER_HXX
117