xref: /aoo42x/main/chart2/source/inc/OPropertySet.hxx (revision de7b3f82)
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_OPROPERTYSET_HXX
24 #define CHART_OPROPERTYSET_HXX
25 
26 // helper classes
27 #include <cppuhelper/propshlp.hxx>
28 #include <cppuhelper/interfacecontainer.hxx>
29 #include <cppuhelper/weak.hxx>
30 
31 // interfaces and types
32 // #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
33 // #include <com/sun/star/lang/XServiceInfo.hpp>
34 // #endif
35 #include <com/sun/star/lang/XTypeProvider.hpp>
36 #include <com/sun/star/beans/XPropertyState.hpp>
37 #include <com/sun/star/beans/XMultiPropertyStates.hpp>
38 #include <com/sun/star/beans/Property.hpp>
39 #include <com/sun/star/style/XStyleSupplier.hpp>
40 // #ifndef _COM_SUN_STAR_BEANS_XFASTPROPERTYSTATE_HPP_
41 // #include <com/sun/star/beans/XFastPropertyState.hpp>
42 // #endif
43 #include <osl/mutex.hxx>
44 #include "charttoolsdllapi.hxx"
45 
46 #include <memory>
47 
48 namespace property
49 {
50 
51 namespace impl
52 { class ImplOPropertySet; }
53 
54 
55 class OOO_DLLPUBLIC_CHARTTOOLS OPropertySet :
56     public ::cppu::OBroadcastHelper,
57     // includes beans::XPropertySet, XMultiPropertySet and XFastPropertySet
58     public ::cppu::OPropertySetHelper,
59     // includes uno::XWeak (and XInterface, esp. ref-counting)
60 //     public virtual ::cppu::OWeakObject,
61 
62 //     public virtual ::com::sun::star::lang::XServiceInfo,
63     public ::com::sun::star::lang::XTypeProvider,
64     public ::com::sun::star::beans::XPropertyState,
65     public ::com::sun::star::beans::XMultiPropertyStates,
66     public ::com::sun::star::style::XStyleSupplier
67 //     public ::com::sun::star::beans::XFastPropertyState
68 {
69 public:
70     OPropertySet( ::osl::Mutex & rMutex );
71     virtual ~OPropertySet();
72 
73 protected:
74     explicit OPropertySet( const OPropertySet & rOther, ::osl::Mutex & rMutex );
75 
76     void SetNewValuesExplicitlyEvenIfTheyEqualDefault();
77 
78     /** implement this method to provide default values for all properties
79         supporting defaults.  If a property does not have a default value, you
80         may throw an UnknownPropertyException.
81      */
82     virtual ::com::sun::star::uno::Any GetDefaultValue( sal_Int32 nHandle ) const
83         throw(::com::sun::star::beans::UnknownPropertyException) = 0;
84 
85 	/** The InfoHelper table contains all property names and types of
86         this object.
87 
88         @return the object that provides information for the
89                 PropertySetInfo
90 
91         @see ::cppu::OPropertySetHelper
92 	 */
93 	virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() = 0;
94 
95 
96     /** Try to convert the value <code>rValue</code> to the type required by the
97         property associated with <code>nHandle</code>.
98 
99         Overload this method to take influence in modification of properties.
100 
101         If the conversion changed , </sal_True> is returned and the converted value
102         is in <code>rConvertedValue</code>.  The former value is contained in
103         <code>rOldValue</code>.
104 
105         After this call returns successfully, the vetoable listeners are
106         notified.
107 
108         @throws IllegalArgumentException, if the conversion was not successful,
109                 or if there is no corresponding property to the given handle.
110 
111         @param rConvertedValue the converted value. Only set if return is true.
112         @param rOldValue the old value. Only set if return is true.
113         @param nHandle the handle of the property.
114 
115         @return true, if the conversion was successful and converted value
116                 differs from the old value.
117 
118         @see ::cppu::OPropertySetHelper
119 	 */
120 	virtual sal_Bool SAL_CALL convertFastPropertyValue
121         ( ::com::sun::star::uno::Any & rConvertedValue,
122           ::com::sun::star::uno::Any & rOldValue,
123           sal_Int32 nHandle,
124           const ::com::sun::star::uno::Any& rValue )
125 		throw (::com::sun::star::lang::IllegalArgumentException);
126 
127 	/** The same as setFastProperyValue; nHandle is always valid.
128         The changes must not be broadcasted in this method.
129 
130         @attention
131         Although you are permitted to throw any UNO exception, only the following
132         are valid for usage:
133         -- ::com::sun::star::beans::UnknownPropertyException
134         -- ::com::sun::star::beans::PropertyVetoException
135         -- ::com::sun::star::lang::IllegalArgumentException
136         -- ::com::sun::star::lang::WrappedTargetException
137         -- ::com::sun::star::uno::RuntimeException
138 
139         @param nHandle handle
140         @param rValue  value
141 
142         @see ::cppu::OPropertySetHelper
143     */
144 	virtual void SAL_CALL setFastPropertyValue_NoBroadcast
145         ( sal_Int32 nHandle,
146           const ::com::sun::star::uno::Any& rValue )
147 		throw (::com::sun::star::uno::Exception);
148 
149 	/**
150 	   The same as getFastProperyValue, but return the value through rValue and
151 	   nHandle is always valid.
152 
153         @see ::cppu::OPropertySetHelper
154 	 */
155 	virtual void SAL_CALL getFastPropertyValue
156         ( ::com::sun::star::uno::Any& rValue,
157           sal_Int32 nHandle ) const;
158 
159     /// make original interface function visible again
160     using ::com::sun::star::beans::XFastPropertySet::getFastPropertyValue;
161 
162     /** implement this method in derived classes to get called when properties
163         change.
164      */
165     virtual void firePropertyChangeEvent();
166 
167     /// call this when a derived component is disposed
168     virtual void disposePropertySet();
169 
170     // ========================================
171     // Interfaces
172     // ========================================
173 
174     // ____ XInterface ____
175     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType )
176         throw (::com::sun::star::uno::RuntimeException);
177 //     virtual void SAL_CALL acquire() throw ();
178 //     virtual void SAL_CALL release() throw ();
179 
180 
181     // ____ XServiceInfo ____
182 //     virtual ::rtl::OUString SAL_CALL
183 //         getImplementationName()
184 //         throw (::com::sun::star::uno::RuntimeException);
185 //     virtual sal_Bool SAL_CALL
186 //         supportsService( const ::rtl::OUString& ServiceName )
187 //         throw (::com::sun::star::uno::RuntimeException);
188 //     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
189 //         getSupportedServiceNames()
190 //         throw (::com::sun::star::uno::RuntimeException);
191 
192     // ____ XTypeProvider ____
193     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL
194         getTypes()
195         throw (::com::sun::star::uno::RuntimeException);
196     virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL
197         getImplementationId()
198         throw (::com::sun::star::uno::RuntimeException);
199 
200     // ____ XPropertyState ____
201     virtual ::com::sun::star::beans::PropertyState SAL_CALL
202         getPropertyState( const ::rtl::OUString& PropertyName )
203         throw (::com::sun::star::beans::UnknownPropertyException,
204                ::com::sun::star::uno::RuntimeException);
205     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL
206         getPropertyStates( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName )
207         throw (::com::sun::star::beans::UnknownPropertyException,
208                ::com::sun::star::uno::RuntimeException);
209     virtual void SAL_CALL
210         setPropertyToDefault( const ::rtl::OUString& PropertyName )
211         throw (::com::sun::star::beans::UnknownPropertyException,
212                ::com::sun::star::uno::RuntimeException);
213     virtual ::com::sun::star::uno::Any SAL_CALL
214         getPropertyDefault( const ::rtl::OUString& aPropertyName )
215         throw (::com::sun::star::beans::UnknownPropertyException,
216                ::com::sun::star::lang::WrappedTargetException,
217                ::com::sun::star::uno::RuntimeException);
218 
219     // ____ XMultiPropertyStates ____
220     // Note: getPropertyStates() is already implemented in XPropertyState with the
221     // same signature
222     virtual void SAL_CALL
223         setAllPropertiesToDefault()
224         throw (::com::sun::star::uno::RuntimeException);
225     virtual void SAL_CALL
226         setPropertiesToDefault( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames )
227         throw (::com::sun::star::beans::UnknownPropertyException,
228                ::com::sun::star::uno::RuntimeException);
229     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL
230         getPropertyDefaults( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames )
231         throw (::com::sun::star::beans::UnknownPropertyException,
232                ::com::sun::star::lang::WrappedTargetException,
233                ::com::sun::star::uno::RuntimeException);
234 
235     // ____ XStyleSupplier ____
236     virtual ::com::sun::star::uno::Reference< ::com::sun::star::style::XStyle > SAL_CALL getStyle()
237         throw (::com::sun::star::uno::RuntimeException);
238     virtual void SAL_CALL setStyle( const ::com::sun::star::uno::Reference< ::com::sun::star::style::XStyle >& xStyle )
239         throw (::com::sun::star::lang::IllegalArgumentException,
240                ::com::sun::star::uno::RuntimeException);
241 
242     // ____ XFastPropertyState ____
243 //     virtual ::com::sun::star::beans::PropertyState SAL_CALL getFastPropertyState( sal_Int32 nHandle )
244 //         throw (::com::sun::star::beans::UnknownPropertyException,
245 //                ::com::sun::star::uno::RuntimeException);
246 //     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getFastPropertyStates( const ::com::sun::star::uno::Sequence< sal_Int32 >& aHandles )
247 //         throw (::com::sun::star::beans::UnknownPropertyException,
248 //                ::com::sun::star::uno::RuntimeException);
249 //     virtual void SAL_CALL setFastPropertyToDefault( sal_Int32 nHandle )
250 //         throw (::com::sun::star::beans::UnknownPropertyException,
251 //                ::com::sun::star::uno::RuntimeException);
252 //     virtual ::com::sun::star::uno::Any SAL_CALL getFastPropertyDefault( sal_Int32 nHandle )
253 //         throw (::com::sun::star::beans::UnknownPropertyException,
254 //                ::com::sun::star::lang::WrappedTargetException,
255 //                ::com::sun::star::uno::RuntimeException);
256 
257     // ____ XMultiPropertySet ____
258 	virtual void SAL_CALL setPropertyValues(
259 		const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames,
260 		const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Values )
261 		throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
262 
263     // ____ XFastPropertySet ____
264 	virtual void SAL_CALL setFastPropertyValue( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue )
265 		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);
266 
267     // Note: it is assumed that the base class implements setPropertyValue by
268     // using setFastPropertyValue
269 
270 private:
271     /// reference to mutex of class deriving from here
272     ::osl::Mutex &   m_rMutex;
273 
274     /// pImpl idiom implementation
275     ::std::auto_ptr< impl::ImplOPropertySet > m_pImplProperties;
276     bool m_bSetNewValuesExplicitlyEvenIfTheyEqualDefault;
277 };
278 
279 } //  namespace property
280 
281 // CHART_OPROPERTYSET_HXX
282 #endif
283