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