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 #ifndef CHART_WRAPPEDPROPERTYSET_HXX
24 #define CHART_WRAPPEDPROPERTYSET_HXX
25 
26 #include "WrappedProperty.hxx"
27 #include "MutexContainer.hxx"
28 #include "charttoolsdllapi.hxx"
29 #include <com/sun/star/beans/XMultiPropertySet.hpp>
30 #include <com/sun/star/beans/XMultiPropertyStates.hpp>
31 #include <com/sun/star/beans/XPropertySet.hpp>
32 #include <com/sun/star/beans/XPropertyState.hpp>
33 #include <com/sun/star/beans/Property.hpp>
34 #include <cppuhelper/implbase4.hxx>
35 
36 // header for class OPropertyArrayHelper
37 #include <cppuhelper/propshlp.hxx>
38 
39 // header for class OMultiTypeInterfaceContainerHelperInt32
40 #include <cppuhelper/propshlp.hxx>
41 
42 #include <vector>
43 
44 //.............................................................................
45 namespace chart
46 {
47 //.............................................................................
48 
49 class OOO_DLLPUBLIC_CHARTTOOLS WrappedPropertySet :
50                            public MutexContainer
51                          , public ::cppu::WeakImplHelper4
52                          < ::com::sun::star::beans::XPropertySet
53                          , ::com::sun::star::beans::XMultiPropertySet
54                          , ::com::sun::star::beans::XPropertyState
55                          , ::com::sun::star::beans::XMultiPropertyStates
56                          //	,::com::sun::star::uno::XWeak			// implemented by WeakImplHelper(optional interface)
57 	                     //	,::com::sun::star::uno::XInterface		// implemented by WeakImplHelper
58 	                     //	,::com::sun::star::lang::XTypeProvider	// implemented by WeakImplHelper
59                          >
60 {
61 public:
62     WrappedPropertySet();
63     virtual ~WrappedPropertySet();
64 
65     void clearWrappedPropertySet();
66 
67 public:
68     //XPropertySet
69     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw (::com::sun::star::uno::RuntimeException);
70 
71     virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) 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);
72     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
73 
74     virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
75     virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
76     virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
77     virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
78 
79     //XMultiPropertySet
80     //getPropertySetInfo() already declared in XPropertySet
81     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 ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
82     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (::com::sun::star::uno::RuntimeException);
83     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 ) throw (::com::sun::star::uno::RuntimeException);
84     virtual void SAL_CALL removePropertiesChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
85     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 ) throw (::com::sun::star::uno::RuntimeException);
86 
87     //XPropertyState
88     virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
89     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);
90     virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
91     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);
92 
93     //XMultiPropertyStates
94     //getPropertyStates() already declared in XPropertyState
95     virtual void SAL_CALL setAllPropertiesToDefault(  ) throw (::com::sun::star::uno::RuntimeException);
96     virtual void SAL_CALL setPropertiesToDefault( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
97     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyDefaults( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
98 
99 protected: //methods
100     /** give all the properties that should be visible to the outer side
101     */
102     virtual const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& getPropertySequence()=0;
103     /** give a list of all properties that need a special treatment;
104     properties that are not in this list will be wrapped identical.
105     The base class 'WrappedPropertySet' will take ownership on the contained pointer.
106     It is not allowed to have duplicate entries in this list.
107     */
108     virtual const std::vector< WrappedProperty* > createWrappedProperties()=0;
109 
110     virtual ::com::sun::star::uno::Reference<
111                         ::com::sun::star::beans::XPropertySet > getInnerPropertySet() = 0;
112     SAL_DLLPRIVATE ::com::sun::star::uno::Reference<
113                         ::com::sun::star::beans::XPropertyState > getInnerPropertyState();
114 
115     ::cppu::IPropertyArrayHelper&   getInfoHelper();
116     SAL_DLLPRIVATE tWrappedPropertyMap&            getWrappedPropertyMap();
117 
118     const WrappedProperty*          getWrappedProperty( const ::rtl::OUString& rOuterName );
119     const WrappedProperty*          getWrappedProperty( sal_Int32 nHandle );
120 
121 protected: //member
122     ::com::sun::star::uno::Reference<
123         ::com::sun::star::beans::XPropertySetInfo >     m_xInfo;//outer PropertySetInfo
124 
125     ::cppu::OPropertyArrayHelper*                       m_pPropertyArrayHelper;//holds all possible outer properties
126 
127     tWrappedPropertyMap*                                m_pWrappedPropertyMap;//holds all wrapped properties (containing the special mapping from inner to outer properties)
128 
129     //Container for the XProperyChangedListener. The listeners are inserted by handle.
130 	//OMultiTypeInterfaceContainerHelperInt32             m_aBoundListenerContainer;
131 
132 	//Container for the XPropertyVetoableListener. The listeners are inserted by handle.
133 	//OMultiTypeInterfaceContainerHelperInt32             m_aVetoableListenerContainer;
134 };
135 
136 //.............................................................................
137 } //namespace chart
138 //.............................................................................
139 
140 // CHART_WRAPPEDPROPERTYSET_HXX
141 #endif
142