1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
27 #ifndef CHART_OPROPERTYSET_HXX
28 #define CHART_OPROPERTYSET_HXX
31 #include <cppuhelper/propshlp.hxx>
32 #include <cppuhelper/interfacecontainer.hxx>
33 #include <cppuhelper/weak.hxx>
35 // interfaces and types
36 // #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
37 // #include <com/sun/star/lang/XServiceInfo.hpp>
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>
47 #include <osl/mutex.hxx>
48 #include "charttoolsdllapi.hxx"
56 { class ImplOPropertySet
; }
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,
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
74 OPropertySet( ::osl::Mutex
& rMutex
);
75 virtual ~OPropertySet();
78 explicit OPropertySet( const OPropertySet
& rOther
, ::osl::Mutex
& rMutex
);
80 void SetNewValuesExplicitlyEvenIfTheyEqualDefault();
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.
86 virtual ::com::sun::star::uno::Any
GetDefaultValue( sal_Int32 nHandle
) const
87 throw(::com::sun::star::beans::UnknownPropertyException
) = 0;
89 /** The InfoHelper table contains all property names and types of
92 @return the object that provides information for the
95 @see ::cppu::OPropertySetHelper
97 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper() = 0;
99 // ____ XPropertySet ____
100 /** sample implementation using the InfoHelper:
103 uno::Reference< beans::XPropertySetInfo > SAL_CALL
104 OPropertySet::getPropertySetInfo()
105 throw (uno::RuntimeException)
107 static uno::Reference< beans::XPropertySetInfo > xInfo;
110 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
113 xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo(
122 <p>(The reason why this isn't implemented here is, that the static
123 object is only valid per concrete PropertySet. Otherwise all
124 PropertySets derived from this base calss would have the same
127 @see ::cppu::OPropertySetHelper
129 // virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL
130 // getPropertySetInfo()
131 // throw (::com::sun::star::uno::RuntimeException) = 0;
133 /** Try to convert the value <code>rValue</code> to the type required by the
134 property associated with <code>nHandle</code>.
136 Overload this method to take influence in modification of properties.
138 If the conversion changed , </TRUE> is returned and the converted value
139 is in <code>rConvertedValue</code>. The former value is contained in
140 <code>rOldValue</code>.
142 After this call returns successfully, the vetoable listeners are
145 @throws IllegalArgumentException, if the conversion was not successful,
146 or if there is no corresponding property to the given handle.
148 @param rConvertedValue the converted value. Only set if return is true.
149 @param rOldValue the old value. Only set if return is true.
150 @param nHandle the handle of the property.
152 @return true, if the conversion was successful and converted value
153 differs from the old value.
155 @see ::cppu::OPropertySetHelper
157 virtual sal_Bool SAL_CALL convertFastPropertyValue
158 ( ::com::sun::star::uno::Any
& rConvertedValue
,
159 ::com::sun::star::uno::Any
& rOldValue
,
161 const ::com::sun::star::uno::Any
& rValue
)
162 throw (::com::sun::star::lang::IllegalArgumentException
);
164 /** The same as setFastProperyValue; nHandle is always valid.
165 The changes must not be broadcasted in this method.
168 Although you are permitted to throw any UNO exception, only the following
170 -- ::com::sun::star::beans::UnknownPropertyException
171 -- ::com::sun::star::beans::PropertyVetoException
172 -- ::com::sun::star::lang::IllegalArgumentException
173 -- ::com::sun::star::lang::WrappedTargetException
174 -- ::com::sun::star::uno::RuntimeException
176 @param nHandle handle
179 @see ::cppu::OPropertySetHelper
181 virtual void SAL_CALL setFastPropertyValue_NoBroadcast
183 const ::com::sun::star::uno::Any
& rValue
)
184 throw (::com::sun::star::uno::Exception
);
187 The same as getFastProperyValue, but return the value through rValue and
188 nHandle is always valid.
190 @see ::cppu::OPropertySetHelper
192 virtual void SAL_CALL getFastPropertyValue
193 ( ::com::sun::star::uno::Any
& rValue
,
194 sal_Int32 nHandle
) const;
196 /// make original interface function visible again
197 using ::com::sun::star::beans::XFastPropertySet::getFastPropertyValue
;
199 /** implement this method in derived classes to get called when properties
202 virtual void firePropertyChangeEvent();
204 /// call this when a derived component is disposed
205 virtual void disposePropertySet();
207 // ========================================
209 // ========================================
211 // ____ XInterface ____
212 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& aType
)
213 throw (::com::sun::star::uno::RuntimeException
);
214 // virtual void SAL_CALL acquire() throw ();
215 // virtual void SAL_CALL release() throw ();
218 // ____ XServiceInfo ____
219 // virtual ::rtl::OUString SAL_CALL
220 // getImplementationName()
221 // throw (::com::sun::star::uno::RuntimeException);
222 // virtual sal_Bool SAL_CALL
223 // supportsService( const ::rtl::OUString& ServiceName )
224 // throw (::com::sun::star::uno::RuntimeException);
225 // virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
226 // getSupportedServiceNames()
227 // throw (::com::sun::star::uno::RuntimeException);
229 // ____ XTypeProvider ____
230 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
232 throw (::com::sun::star::uno::RuntimeException
);
233 virtual ::com::sun::star::uno::Sequence
< sal_Int8
> SAL_CALL
234 getImplementationId()
235 throw (::com::sun::star::uno::RuntimeException
);
237 // ____ XPropertyState ____
238 virtual ::com::sun::star::beans::PropertyState SAL_CALL
239 getPropertyState( const ::rtl::OUString
& PropertyName
)
240 throw (::com::sun::star::beans::UnknownPropertyException
,
241 ::com::sun::star::uno::RuntimeException
);
242 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyState
> SAL_CALL
243 getPropertyStates( const ::com::sun::star::uno::Sequence
< ::rtl::OUString
>& aPropertyName
)
244 throw (::com::sun::star::beans::UnknownPropertyException
,
245 ::com::sun::star::uno::RuntimeException
);
246 virtual void SAL_CALL
247 setPropertyToDefault( const ::rtl::OUString
& PropertyName
)
248 throw (::com::sun::star::beans::UnknownPropertyException
,
249 ::com::sun::star::uno::RuntimeException
);
250 virtual ::com::sun::star::uno::Any SAL_CALL
251 getPropertyDefault( const ::rtl::OUString
& aPropertyName
)
252 throw (::com::sun::star::beans::UnknownPropertyException
,
253 ::com::sun::star::lang::WrappedTargetException
,
254 ::com::sun::star::uno::RuntimeException
);
256 // ____ XMultiPropertyStates ____
257 // Note: getPropertyStates() is already implemented in XPropertyState with the
259 virtual void SAL_CALL
260 setAllPropertiesToDefault()
261 throw (::com::sun::star::uno::RuntimeException
);
262 virtual void SAL_CALL
263 setPropertiesToDefault( const ::com::sun::star::uno::Sequence
< ::rtl::OUString
>& aPropertyNames
)
264 throw (::com::sun::star::beans::UnknownPropertyException
,
265 ::com::sun::star::uno::RuntimeException
);
266 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> SAL_CALL
267 getPropertyDefaults( const ::com::sun::star::uno::Sequence
< ::rtl::OUString
>& aPropertyNames
)
268 throw (::com::sun::star::beans::UnknownPropertyException
,
269 ::com::sun::star::lang::WrappedTargetException
,
270 ::com::sun::star::uno::RuntimeException
);
272 // ____ XStyleSupplier ____
273 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::style::XStyle
> SAL_CALL
getStyle()
274 throw (::com::sun::star::uno::RuntimeException
);
275 virtual void SAL_CALL
setStyle( const ::com::sun::star::uno::Reference
< ::com::sun::star::style::XStyle
>& xStyle
)
276 throw (::com::sun::star::lang::IllegalArgumentException
,
277 ::com::sun::star::uno::RuntimeException
);
279 // ____ XFastPropertyState ____
280 // virtual ::com::sun::star::beans::PropertyState SAL_CALL getFastPropertyState( sal_Int32 nHandle )
281 // throw (::com::sun::star::beans::UnknownPropertyException,
282 // ::com::sun::star::uno::RuntimeException);
283 // virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getFastPropertyStates( const ::com::sun::star::uno::Sequence< sal_Int32 >& aHandles )
284 // throw (::com::sun::star::beans::UnknownPropertyException,
285 // ::com::sun::star::uno::RuntimeException);
286 // virtual void SAL_CALL setFastPropertyToDefault( sal_Int32 nHandle )
287 // throw (::com::sun::star::beans::UnknownPropertyException,
288 // ::com::sun::star::uno::RuntimeException);
289 // virtual ::com::sun::star::uno::Any SAL_CALL getFastPropertyDefault( sal_Int32 nHandle )
290 // throw (::com::sun::star::beans::UnknownPropertyException,
291 // ::com::sun::star::lang::WrappedTargetException,
292 // ::com::sun::star::uno::RuntimeException);
294 // ____ XMultiPropertySet ____
295 virtual void SAL_CALL
setPropertyValues(
296 const ::com::sun::star::uno::Sequence
< ::rtl::OUString
>& PropertyNames
,
297 const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>& Values
)
298 throw(::com::sun::star::beans::PropertyVetoException
, ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
300 // ____ XFastPropertySet ____
301 virtual void SAL_CALL
setFastPropertyValue( sal_Int32 nHandle
, const ::com::sun::star::uno::Any
& rValue
)
302 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
);
304 // Note: it is assumed that the base class implements setPropertyValue by
305 // using setFastPropertyValue
308 /// reference to mutex of class deriving from here
309 ::osl::Mutex
& m_rMutex
;
311 /// pImpl idiom implementation
312 ::std::auto_ptr
< impl::ImplOPropertySet
> m_pImplProperties
;
313 bool m_bSetNewValuesExplicitlyEvenIfTheyEqualDefault
;
316 } // namespace property
318 // CHART_OPROPERTYSET_HXX