merge the formfield patch from ooo-build
[ooovba.git] / chart2 / source / inc / OPropertySet.hxx
blobbf1ddce66c602fc805cfc3d62cc0297b57799d29
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: OPropertySet.hxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef CHART_OPROPERTYSET_HXX
31 #define CHART_OPROPERTYSET_HXX
33 // helper classes
34 #include <cppuhelper/propshlp.hxx>
35 #include <cppuhelper/interfacecontainer.hxx>
36 #include <cppuhelper/weak.hxx>
38 // interfaces and types
39 // #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
40 // #include <com/sun/star/lang/XServiceInfo.hpp>
41 // #endif
42 #include <com/sun/star/lang/XTypeProvider.hpp>
43 #include <com/sun/star/beans/XPropertyState.hpp>
44 #include <com/sun/star/beans/XMultiPropertyStates.hpp>
45 #include <com/sun/star/beans/Property.hpp>
46 #include <com/sun/star/style/XStyleSupplier.hpp>
47 // #ifndef _COM_SUN_STAR_BEANS_XFASTPROPERTYSTATE_HPP_
48 // #include <com/sun/star/beans/XFastPropertyState.hpp>
49 // #endif
50 #include <osl/mutex.hxx>
51 #include "charttoolsdllapi.hxx"
53 #include <memory>
55 namespace property
58 namespace impl
59 { class ImplOPropertySet; }
62 class OOO_DLLPUBLIC_CHARTTOOLS OPropertySet :
63 public ::cppu::OBroadcastHelper,
64 // includes beans::XPropertySet, XMultiPropertySet and XFastPropertySet
65 public ::cppu::OPropertySetHelper,
66 // includes uno::XWeak (and XInterface, esp. ref-counting)
67 // public virtual ::cppu::OWeakObject,
69 // public virtual ::com::sun::star::lang::XServiceInfo,
70 public ::com::sun::star::lang::XTypeProvider,
71 public ::com::sun::star::beans::XPropertyState,
72 public ::com::sun::star::beans::XMultiPropertyStates,
73 public ::com::sun::star::style::XStyleSupplier
74 // public ::com::sun::star::beans::XFastPropertyState
76 public:
77 OPropertySet( ::osl::Mutex & rMutex );
78 virtual ~OPropertySet();
80 protected:
81 explicit OPropertySet( const OPropertySet & rOther, ::osl::Mutex & rMutex );
83 void SetNewValuesExplicitlyEvenIfTheyEqualDefault();
85 /** implement this method to provide default values for all properties
86 supporting defaults. If a property does not have a default value, you
87 may throw an UnknownPropertyException.
89 virtual ::com::sun::star::uno::Any GetDefaultValue( sal_Int32 nHandle ) const
90 throw(::com::sun::star::beans::UnknownPropertyException) = 0;
92 /** The InfoHelper table contains all property names and types of
93 this object.
95 @return the object that provides information for the
96 PropertySetInfo
98 @see ::cppu::OPropertySetHelper
100 virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() = 0;
102 // ____ XPropertySet ____
103 /** sample implementation using the InfoHelper:
105 <pre>
106 uno::Reference&lt; beans::XPropertySetInfo &gt; SAL_CALL
107 OPropertySet::getPropertySetInfo()
108 throw (uno::RuntimeException)
110 static uno::Reference&lt; beans::XPropertySetInfo &gt; xInfo;
112 // /--
113 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
114 if( !xInfo.is())
116 xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo(
117 getInfoHelper());
120 return xInfo;
121 // \--
123 </pre>
125 <p>(The reason why this isn't implemented here is, that the static
126 object is only valid per concrete PropertySet. Otherwise all
127 PropertySets derived from this base calss would have the same
128 properties.)</p>
130 @see ::cppu::OPropertySetHelper
132 // virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL
133 // getPropertySetInfo()
134 // throw (::com::sun::star::uno::RuntimeException) = 0;
136 /** Try to convert the value <code>rValue</code> to the type required by the
137 property associated with <code>nHandle</code>.
139 Overload this method to take influence in modification of properties.
141 If the conversion changed , </TRUE> is returned and the converted value
142 is in <code>rConvertedValue</code>. The former value is contained in
143 <code>rOldValue</code>.
145 After this call returns successfully, the vetoable listeners are
146 notified.
148 @throws IllegalArgumentException, if the conversion was not successful,
149 or if there is no corresponding property to the given handle.
151 @param rConvertedValue the converted value. Only set if return is true.
152 @param rOldValue the old value. Only set if return is true.
153 @param nHandle the handle of the property.
155 @return true, if the conversion was successful and converted value
156 differs from the old value.
158 @see ::cppu::OPropertySetHelper
160 virtual sal_Bool SAL_CALL convertFastPropertyValue
161 ( ::com::sun::star::uno::Any & rConvertedValue,
162 ::com::sun::star::uno::Any & rOldValue,
163 sal_Int32 nHandle,
164 const ::com::sun::star::uno::Any& rValue )
165 throw (::com::sun::star::lang::IllegalArgumentException);
167 /** The same as setFastProperyValue; nHandle is always valid.
168 The changes must not be broadcasted in this method.
170 @attention
171 Although you are permitted to throw any UNO exception, only the following
172 are valid for usage:
173 -- ::com::sun::star::beans::UnknownPropertyException
174 -- ::com::sun::star::beans::PropertyVetoException
175 -- ::com::sun::star::lang::IllegalArgumentException
176 -- ::com::sun::star::lang::WrappedTargetException
177 -- ::com::sun::star::uno::RuntimeException
179 @param nHandle handle
180 @param rValue value
182 @see ::cppu::OPropertySetHelper
184 virtual void SAL_CALL setFastPropertyValue_NoBroadcast
185 ( sal_Int32 nHandle,
186 const ::com::sun::star::uno::Any& rValue )
187 throw (::com::sun::star::uno::Exception);
190 The same as getFastProperyValue, but return the value through rValue and
191 nHandle is always valid.
193 @see ::cppu::OPropertySetHelper
195 virtual void SAL_CALL getFastPropertyValue
196 ( ::com::sun::star::uno::Any& rValue,
197 sal_Int32 nHandle ) const;
199 /// make original interface function visible again
200 using ::com::sun::star::beans::XFastPropertySet::getFastPropertyValue;
202 /** implement this method in derived classes to get called when properties
203 change.
205 virtual void firePropertyChangeEvent();
207 /// call this when a derived component is disposed
208 virtual void disposePropertySet();
210 // ========================================
211 // Interfaces
212 // ========================================
214 // ____ XInterface ____
215 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType )
216 throw (::com::sun::star::uno::RuntimeException);
217 // virtual void SAL_CALL acquire() throw ();
218 // virtual void SAL_CALL release() throw ();
221 // ____ XServiceInfo ____
222 // virtual ::rtl::OUString SAL_CALL
223 // getImplementationName()
224 // throw (::com::sun::star::uno::RuntimeException);
225 // virtual sal_Bool SAL_CALL
226 // supportsService( const ::rtl::OUString& ServiceName )
227 // throw (::com::sun::star::uno::RuntimeException);
228 // virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
229 // getSupportedServiceNames()
230 // throw (::com::sun::star::uno::RuntimeException);
232 // ____ XTypeProvider ____
233 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL
234 getTypes()
235 throw (::com::sun::star::uno::RuntimeException);
236 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL
237 getImplementationId()
238 throw (::com::sun::star::uno::RuntimeException);
240 // ____ XPropertyState ____
241 virtual ::com::sun::star::beans::PropertyState SAL_CALL
242 getPropertyState( const ::rtl::OUString& PropertyName )
243 throw (::com::sun::star::beans::UnknownPropertyException,
244 ::com::sun::star::uno::RuntimeException);
245 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL
246 getPropertyStates( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName )
247 throw (::com::sun::star::beans::UnknownPropertyException,
248 ::com::sun::star::uno::RuntimeException);
249 virtual void SAL_CALL
250 setPropertyToDefault( const ::rtl::OUString& PropertyName )
251 throw (::com::sun::star::beans::UnknownPropertyException,
252 ::com::sun::star::uno::RuntimeException);
253 virtual ::com::sun::star::uno::Any SAL_CALL
254 getPropertyDefault( const ::rtl::OUString& aPropertyName )
255 throw (::com::sun::star::beans::UnknownPropertyException,
256 ::com::sun::star::lang::WrappedTargetException,
257 ::com::sun::star::uno::RuntimeException);
259 // ____ XMultiPropertyStates ____
260 // Note: getPropertyStates() is already implemented in XPropertyState with the
261 // same signature
262 virtual void SAL_CALL
263 setAllPropertiesToDefault()
264 throw (::com::sun::star::uno::RuntimeException);
265 virtual void SAL_CALL
266 setPropertiesToDefault( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames )
267 throw (::com::sun::star::beans::UnknownPropertyException,
268 ::com::sun::star::uno::RuntimeException);
269 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL
270 getPropertyDefaults( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames )
271 throw (::com::sun::star::beans::UnknownPropertyException,
272 ::com::sun::star::lang::WrappedTargetException,
273 ::com::sun::star::uno::RuntimeException);
275 // ____ XStyleSupplier ____
276 virtual ::com::sun::star::uno::Reference< ::com::sun::star::style::XStyle > SAL_CALL getStyle()
277 throw (::com::sun::star::uno::RuntimeException);
278 virtual void SAL_CALL setStyle( const ::com::sun::star::uno::Reference< ::com::sun::star::style::XStyle >& xStyle )
279 throw (::com::sun::star::lang::IllegalArgumentException,
280 ::com::sun::star::uno::RuntimeException);
282 // ____ XFastPropertyState ____
283 // virtual ::com::sun::star::beans::PropertyState SAL_CALL getFastPropertyState( sal_Int32 nHandle )
284 // throw (::com::sun::star::beans::UnknownPropertyException,
285 // ::com::sun::star::uno::RuntimeException);
286 // virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getFastPropertyStates( const ::com::sun::star::uno::Sequence< sal_Int32 >& aHandles )
287 // throw (::com::sun::star::beans::UnknownPropertyException,
288 // ::com::sun::star::uno::RuntimeException);
289 // virtual void SAL_CALL setFastPropertyToDefault( sal_Int32 nHandle )
290 // throw (::com::sun::star::beans::UnknownPropertyException,
291 // ::com::sun::star::uno::RuntimeException);
292 // virtual ::com::sun::star::uno::Any SAL_CALL getFastPropertyDefault( sal_Int32 nHandle )
293 // throw (::com::sun::star::beans::UnknownPropertyException,
294 // ::com::sun::star::lang::WrappedTargetException,
295 // ::com::sun::star::uno::RuntimeException);
297 // ____ XMultiPropertySet ____
298 virtual void SAL_CALL setPropertyValues(
299 const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames,
300 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Values )
301 throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
303 // ____ XFastPropertySet ____
304 virtual void SAL_CALL setFastPropertyValue( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue )
305 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);
307 // Note: it is assumed that the base class implements setPropertyValue by
308 // using setFastPropertyValue
310 private:
311 /// reference to mutex of class deriving from here
312 ::osl::Mutex & m_rMutex;
314 /// pImpl idiom implementation
315 ::std::auto_ptr< impl::ImplOPropertySet > m_pImplProperties;
316 bool m_bSetNewValuesExplicitlyEvenIfTheyEqualDefault;
319 } // namespace property
321 // CHART_OPROPERTYSET_HXX
322 #endif