xref: /AOO41X/main/comphelper/inc/comphelper/propertystatecontainer.hxx (revision 9877b273795ec465a3ce9c15d738eb34c0455705)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef COMPHELPER_PROPERTYSTATECONTAINER_HXX
25 #define COMPHELPER_PROPERTYSTATECONTAINER_HXX
26 
27 #include <comphelper/propertycontainer.hxx>
28 #include <com/sun/star/beans/XPropertyState.hpp>
29 #include <cppuhelper/implbase1.hxx>
30 #include <comphelper/uno3.hxx>
31 #include <osl/diagnose.h>
32 #include "comphelper/comphelperdllapi.h"
33 
34 #include <map>
35 
36 //.........................................................................
37 namespace comphelper
38 {
39 //.........................................................................
40 
41     //=====================================================================
42     //= OPropertyStateContainer
43     //=====================================================================
44     typedef ::cppu::ImplHelper1 <   ::com::sun::star::beans::XPropertyState
45                                 >   OPropertyStateContainer_TBase;
46 
47     /** helper implementation for components which have properties with a default
48 
49         <p>This class is not intended for direct use, you need to derive from it.</p>
50 
51         @see com.sun.star.beans.XPropertyState
52     */
53     class COMPHELPER_DLLPUBLIC OPropertyStateContainer
54                 :public  OPropertyContainer
55                 ,public  OPropertyStateContainer_TBase
56     {
57     protected:
58         /** ctor
59             @param _rBHelper
60                 help to be used for broadcasting events
61         */
62         OPropertyStateContainer( ::cppu::OBroadcastHelper&  _rBHelper );
63 
64         // ................................................................
65         // XPropertyState
66         virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
67         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);
68         virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
69         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);
70 
71         // ................................................................
72         // own overridables
73         // these are the impl-methods for the XPropertyState members - they are implemented already by this class,
74         // but you may want to override them for whatever reasons (for instance, if your derived class
75         // supports the AMBIGUOUS state for properties)
76 
77         /** get the PropertyState of the property denoted by the given handle
78 
79             <p>Already implemented by this base class, no need to override</p>
80             @precond <arg>_nHandle</arg> is a valid property handle
81         */
82         virtual ::com::sun::star::beans::PropertyState  getPropertyStateByHandle( sal_Int32 _nHandle );
83 
84         /** set the property denoted by the given handle to it's default value
85 
86             <p>Already implemented by this base class, no need to override</p>
87             @precond <arg>_nHandle</arg> is a valid property handle
88         */
89         virtual void                                    setPropertyToDefaultByHandle( sal_Int32 _nHandle );
90 
91         /** get the default value for the property denoted by the given handle
92 
93             @precond
94                 <arg>_nHandle</arg> is a valid property handle
95         */
96         virtual void getPropertyDefaultByHandle( sal_Int32 _nHandle, ::com::sun::star::uno::Any& _rDefault ) const = 0;
97 
98     protected:
99         // XInterface
100         virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException);
101         // XTypeProvider
102         DECLARE_XTYPEPROVIDER( )
103 
104     protected:
105         /** returns the handle for the given name
106 
107             @throw UnknownPropertyException if the given name is not a registered property
108         */
109         sal_Int32   getHandleForName( const ::rtl::OUString& _rPropertyName ) SAL_THROW( ( ::com::sun::star::beans::UnknownPropertyException ) );
110     };
111 
112 //.........................................................................
113 }   // namespace comphelper
114 //.........................................................................
115 
116 #endif // COMPHELPER_PROPERTYSTATECONTAINER_HXX
117