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_PROPERTY_STATE_HXX_
25 #define _COMPHELPER_PROPERTY_STATE_HXX_
26 
27 #include <com/sun/star/beans/XPropertyState.hpp>
28 #include <com/sun/star/uno/Sequence.hxx>
29 
30 
31 #include <cppuhelper/propshlp.hxx>
32 #include <cppuhelper/proptypehlp.hxx>
33 #include <cppuhelper/weak.hxx>
34 #include <comphelper/uno3.hxx>
35 #include <comphelper/broadcasthelper.hxx>
36 #include <com/sun/star/lang/XTypeProvider.hpp>
37 #include "comphelper/comphelperdllapi.h"
38 
39 //=========================================================================
40 //= property helper classes
41 //=========================================================================
42 
43 //.........................................................................
44 namespace comphelper
45 {
46 //.........................................................................
47 
48     //==================================================================
49     //= OPropertyStateHelper
50     //==================================================================
51     /// helper class for implementing property states
52     class COMPHELPER_DLLPUBLIC OPropertyStateHelper :public ::cppu::OPropertySetHelper
53 							                        ,public ::com::sun::star::beans::XPropertyState
54     {
55     public:
OPropertyStateHelper(::cppu::OBroadcastHelper & rBHlp)56 	    OPropertyStateHelper(::cppu::OBroadcastHelper& rBHlp):OPropertySetHelper(rBHlp) { }
57 	    OPropertyStateHelper(::cppu::OBroadcastHelper& rBHlp,
58                              ::cppu::IEventNotificationHook *i_pFireEvents);
59 
60         virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(const ::com::sun::star::uno::Type& aType) throw(::com::sun::star::uno::RuntimeException);
61 
62     // XPropertyState
63         virtual ::com::sun::star::beans::PropertyState SAL_CALL
64             getPropertyState(const ::rtl::OUString& PropertyName) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
65         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState> SAL_CALL
66             getPropertyStates(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
67         virtual void SAL_CALL
68             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
70             getPropertyDefault(const ::rtl::OUString& aPropertyName) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
71 
72     // access via handle
73 	    virtual ::com::sun::star::beans::PropertyState	getPropertyStateByHandle(sal_Int32 nHandle);
74 	    virtual void									setPropertyToDefaultByHandle(sal_Int32 nHandle);
75 	    virtual ::com::sun::star::uno::Any				getPropertyDefaultByHandle(sal_Int32 nHandle) const;
76 
77     protected:
78         virtual ~OPropertyStateHelper();
79 
80 	    void firePropertyChange(sal_Int32 nHandle, const ::com::sun::star::uno::Any& aNewValue, const ::com::sun::star::uno::Any& aOldValue);
81 
82     protected:
83         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> SAL_CALL getTypes() throw(::com::sun::star::uno::RuntimeException);
84     };
85 
86     //==================================================================
87     //= OPropertyStateHelper
88     //==================================================================
89     class COMPHELPER_DLLPUBLIC OStatefulPropertySet  :public ::cppu::OWeakObject
90                                 ,public ::com::sun::star::lang::XTypeProvider
91                                 ,public OMutexAndBroadcastHelper    // order matters: before OPropertyStateHelper/OPropertySetHelper
92                                 ,public OPropertyStateHelper
93     {
94     protected:
95 	    OStatefulPropertySet();
96         virtual ~OStatefulPropertySet();
97 
98     protected:
99         DECLARE_XINTERFACE()
100         DECLARE_XTYPEPROVIDER()
101     };
102 
103 //.........................................................................
104 }	// namespace comphelper
105 //.........................................................................
106 
107 #endif // _COMPHELPER_PROPERTY_STATE_HXX_
108 
109