1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include <cppuhelper/propshlp.hxx>
24 // interfaces and types
25 #include <com/sun/star/lang/XTypeProvider.hpp>
26 #include <com/sun/star/beans/XPropertyState.hpp>
27 #include <com/sun/star/beans/XMultiPropertyStates.hpp>
28 #include <com/sun/star/style/XStyleSupplier.hpp>
36 { class ImplOPropertySet
; }
39 public ::cppu::OBroadcastHelper
,
40 // includes beans::XPropertySet, XMultiPropertySet and XFastPropertySet
41 public ::cppu::OPropertySetHelper
,
42 // includes uno::XWeak (and XInterface, esp. ref-counting)
44 public css::lang::XTypeProvider
,
45 public css::beans::XPropertyState
,
46 public css::beans::XMultiPropertyStates
,
47 public css::style::XStyleSupplier
50 OPropertySet( ::osl::Mutex
& rMutex
);
51 virtual ~OPropertySet();
54 explicit OPropertySet( const OPropertySet
& rOther
, ::osl::Mutex
& rMutex
);
56 void SetNewValuesExplicitlyEvenIfTheyEqualDefault();
58 /** implement this method to provide default values for all properties
59 supporting defaults. If a property does not have a default value, you
60 may throw an UnknownPropertyException.
62 @throws css::beans::UnknownPropertyException
63 @throws css::uno::RuntimeException
65 virtual css::uno::Any
GetDefaultValue( sal_Int32 nHandle
) const = 0;
67 /** The InfoHelper table contains all property names and types of
70 @return the object that provides information for the
73 @see ::cppu::OPropertySetHelper
75 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper() override
= 0;
77 /** Try to convert the value <code>rValue</code> to the type required by the
78 property associated with <code>nHandle</code>.
80 Override this method to take influence in modification of properties.
82 If the conversion changed , </sal_True> is returned and the converted value
83 is in <code>rConvertedValue</code>. The former value is contained in
84 <code>rOldValue</code>.
86 After this call returns successfully, the vetoable listeners are
89 @throws IllegalArgumentException, if the conversion was not successful,
90 or if there is no corresponding property to the given handle.
92 @param rConvertedValue the converted value. Only set if return is true.
93 @param rOldValue the old value. Only set if return is true.
94 @param nHandle the handle of the property.
96 @return true, if the conversion was successful and converted value
97 differs from the old value.
99 @see ::cppu::OPropertySetHelper
101 virtual sal_Bool SAL_CALL convertFastPropertyValue
102 ( css::uno::Any
& rConvertedValue
,
103 css::uno::Any
& rOldValue
,
105 const css::uno::Any
& rValue
) override
;
107 /** The same as setFastPropertyValue; nHandle is always valid.
108 The changes must not be broadcasted in this method.
111 Although you are permitted to throw any UNO exception, only the following
113 -- css::beans::UnknownPropertyException
114 -- css::beans::PropertyVetoException
115 -- css::lang::IllegalArgumentException
116 -- css::lang::WrappedTargetException
117 -- css::uno::RuntimeException
119 @param nHandle handle
122 @see ::cppu::OPropertySetHelper
124 virtual void SAL_CALL setFastPropertyValue_NoBroadcast
126 const css::uno::Any
& rValue
) override
;
129 The same as getFastPropertyValue, but return the value through rValue and
130 nHandle is always valid.
132 @see ::cppu::OPropertySetHelper
134 virtual void SAL_CALL getFastPropertyValue
135 ( css::uno::Any
& rValue
,
136 sal_Int32 nHandle
) const override
;
138 /// make original interface function visible again
139 using ::com::sun::star::beans::XFastPropertySet::getFastPropertyValue
;
141 /** implement this method in derived classes to get called when properties
144 virtual void firePropertyChangeEvent();
148 // ____ XInterface ____
149 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& aType
) override
;
151 // ____ XTypeProvider ____
152 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
154 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
155 getImplementationId() override
;
157 // ____ XPropertyState ____
158 virtual css::beans::PropertyState SAL_CALL
159 getPropertyState( const OUString
& PropertyName
) override
;
160 virtual css::uno::Sequence
< css::beans::PropertyState
> SAL_CALL
161 getPropertyStates( const css::uno::Sequence
< OUString
>& aPropertyName
) override
;
162 virtual void SAL_CALL
163 setPropertyToDefault( const OUString
& PropertyName
) override
;
164 virtual css::uno::Any SAL_CALL
165 getPropertyDefault( const OUString
& aPropertyName
) override
;
167 // ____ XMultiPropertyStates ____
168 // Note: getPropertyStates() is already implemented in XPropertyState with the
170 virtual void SAL_CALL
171 setAllPropertiesToDefault() override
;
172 virtual void SAL_CALL
173 setPropertiesToDefault( const css::uno::Sequence
< OUString
>& aPropertyNames
) override
;
174 virtual css::uno::Sequence
< css::uno::Any
> SAL_CALL
175 getPropertyDefaults( const css::uno::Sequence
< OUString
>& aPropertyNames
) override
;
177 // ____ XStyleSupplier ____
178 virtual css::uno::Reference
< css::style::XStyle
> SAL_CALL
getStyle() override
;
179 virtual void SAL_CALL
setStyle( const css::uno::Reference
< css::style::XStyle
>& xStyle
) override
;
181 // ____ XMultiPropertySet ____
182 virtual void SAL_CALL
setPropertyValues(
183 const css::uno::Sequence
< OUString
>& PropertyNames
,
184 const css::uno::Sequence
< css::uno::Any
>& Values
) override
;
186 // ____ XFastPropertySet ____
187 virtual void SAL_CALL
setFastPropertyValue( sal_Int32 nHandle
, const css::uno::Any
& rValue
) override
;
189 // Note: it is assumed that the base class implements setPropertyValue by
190 // using setFastPropertyValue
193 /// reference to mutex of class deriving from here
194 ::osl::Mutex
& m_rMutex
;
196 /// pImpl idiom implementation
197 std::unique_ptr
< impl::ImplOPropertySet
> m_pImplProperties
;
198 bool m_bSetNewValuesExplicitlyEvenIfTheyEqualDefault
;
201 } // namespace property
203 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */