LibreOffice Module comphelper (master) 1
propshlp.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19#pragma once
20
22
23#include <com/sun/star/beans/XPropertySet.hpp>
24#include <com/sun/star/beans/XPropertySetOption.hpp>
25#include <com/sun/star/beans/XMultiPropertySet.hpp>
26#include <com/sun/star/beans/XFastPropertySet.hpp>
27
31
32namespace comphelper
33{
34/*************************************************************************
35*************************************************************************/
36
48 public css::beans::XMultiPropertySet,
49 public css::beans::XFastPropertySet,
50 public css::beans::XPropertySet
51{
52public:
54
67 OPropertySetHelper(bool bIgnoreRuntimeExceptionsWhileFiring);
68
73 virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& rType) override;
74
79 static css::uno::Sequence<css::uno::Type> getTypes();
80
86 void disposing(std::unique_lock<std::mutex>& rGuard);
87
93 virtual void SAL_CALL setPropertyValue(const ::rtl::OUString& rPropertyName,
94 const css::uno::Any& aValue) override final;
99 virtual css::uno::Any SAL_CALL
100 getPropertyValue(const ::rtl::OUString& aPropertyName) override final;
101
103 virtual void SAL_CALL addPropertyChangeListener(
104 const ::rtl::OUString& aPropertyName,
105 const css::uno::Reference<css::beans::XPropertyChangeListener>& aListener) override final;
106
108 virtual void SAL_CALL removePropertyChangeListener(
109 const ::rtl::OUString& aPropertyName,
110 const css::uno::Reference<css::beans::XPropertyChangeListener>& aListener) override final;
111
113 virtual void SAL_CALL addVetoableChangeListener(
114 const ::rtl::OUString& aPropertyName,
115 const css::uno::Reference<css::beans::XVetoableChangeListener>& aListener) override final;
116
118 virtual void SAL_CALL removeVetoableChangeListener(
119 const ::rtl::OUString& aPropertyName,
120 const css::uno::Reference<css::beans::XVetoableChangeListener>& aListener) override final;
121
129 virtual void SAL_CALL setFastPropertyValue(sal_Int32 nHandle,
130 const css::uno::Any& rValue) override final;
131
136 virtual css::uno::Any SAL_CALL getFastPropertyValue(sal_Int32 nHandle) override final;
137
138 // XMultiPropertySet
139 virtual void SAL_CALL
140 setPropertyValues(const css::uno::Sequence<::rtl::OUString>& PropertyNames,
141 const css::uno::Sequence<css::uno::Any>& Values) override;
142
143 virtual css::uno::Sequence<css::uno::Any> SAL_CALL
144 getPropertyValues(const css::uno::Sequence<::rtl::OUString>& PropertyNames) override final;
145
146 virtual void SAL_CALL addPropertiesChangeListener(
147 const css::uno::Sequence<::rtl::OUString>& PropertyNames,
148 const css::uno::Reference<css::beans::XPropertiesChangeListener>& Listener) override final;
149
150 virtual void SAL_CALL removePropertiesChangeListener(
151 const css::uno::Reference<css::beans::XPropertiesChangeListener>& Listener) override final;
152
153 virtual void SAL_CALL firePropertiesChangeEvent(
154 const css::uno::Sequence<::rtl::OUString>& PropertyNames,
155 const css::uno::Reference<css::beans::XPropertiesChangeListener>& Listener) override final;
156
160 static css::uno::Reference<css::beans::XPropertySetInfo>
161 createPropertySetInfo(cppu::IPropertyArrayHelper& rProperties);
162
163protected:
168
170 virtual void setFastPropertyValueImpl(std::unique_lock<std::mutex>& rGuard, sal_Int32 nHandle,
171 const css::uno::Any& rValue);
173 virtual css::uno::Any getPropertyValueImpl(std::unique_lock<std::mutex>& rGuard,
174 const ::rtl::OUString& aPropertyName);
175
185 void fire(std::unique_lock<std::mutex>& rGuard, sal_Int32* pnHandles,
186 const css::uno::Any* pNewValues, const css::uno::Any* pOldValues, sal_Int32 nCount,
187 bool bVetoable);
188
198 void setFastPropertyValues(std::unique_lock<std::mutex>& rGuard, sal_Int32 nSeqLen,
199 sal_Int32* pHandles, const css::uno::Any* pValues,
200 sal_Int32 nHitCount);
201
207
223 virtual bool convertFastPropertyValue(std::unique_lock<std::mutex>& rGuard,
224 css::uno::Any& rConvertedValue, css::uno::Any& rOldValue,
225 sal_Int32 nHandle, const css::uno::Any& rValue)
226 = 0;
227
247 virtual void setFastPropertyValue_NoBroadcast(std::unique_lock<std::mutex>& rGuard,
248 sal_Int32 nHandle, const css::uno::Any& rValue)
249 = 0;
255 virtual void getFastPropertyValue(std::unique_lock<std::mutex>& rGuard, css::uno::Any& rValue,
256 sal_Int32 nHandle) const = 0;
257
276 void setDependentFastPropertyValue(std::unique_lock<std::mutex>& rGuard, sal_Int32 i_handle,
277 const css::uno::Any& i_value);
278
279private:
301 std::vector<sal_Int32> m_handles;
302 std::vector<css::uno::Any> m_newValues;
303 std::vector<css::uno::Any> m_oldValues;
304 bool m_bIgnoreRuntimeExceptionsWhileFiring = false;
305
309 void impl_fireAll(std::unique_lock<std::mutex>& rGuard, sal_Int32* i_handles,
310 const css::uno::Any* i_newValues, const css::uno::Any* i_oldValues,
311 sal_Int32 i_count);
312
313 void fireVetoableChangeListeners(
314 std::unique_lock<std::mutex>& rGuard,
316 const css::beans::PropertyChangeEvent& rChangeEvent);
317 void firePropertyChangeListeners(
318 std::unique_lock<std::mutex>& rGuard,
320 const css::beans::PropertyChangeEvent& rChangeEvent);
321};
322
323} // end namespace comphelper
324
325/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This abstract class maps the methods of the interfaces XMultiPropertySet, XFastPropertySet and XPrope...
Definition: propshlp.hxx:51
std::vector< sal_Int32 > m_handles
Definition: propshlp.hxx:301
virtual void SAL_CALL removePropertyChangeListener(const ::rtl::OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override final
Ignored if the property is not bound.
comphelper::OInterfaceContainerHelper4< css::beans::XVetoableChangeListener > maVetoableChangeListeners
Container for the XVetoableChangeListener where the listeners want to listen to all properties.
Definition: propshlp.hxx:300
virtual void getFastPropertyValue(std::unique_lock< std::mutex > &rGuard, css::uno::Any &rValue, sal_Int32 nHandle) const =0
The same as getFastPropertyValue, but return the value through rValue and nHandle is always valid.
virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues(const css::uno::Sequence<::rtl::OUString > &PropertyNames) override final
std::vector< css::uno::Any > m_oldValues
Definition: propshlp.hxx:303
virtual bool convertFastPropertyValue(std::unique_lock< std::mutex > &rGuard, css::uno::Any &rConvertedValue, css::uno::Any &rOldValue, sal_Int32 nHandle, const css::uno::Any &rValue)=0
Converted the value rValue and return the result in rConvertedValue and the old value in rOldValue.
virtual css::uno::Any SAL_CALL getPropertyValue(const ::rtl::OUString &aPropertyName) override final
Throw UnknownPropertyException if the property with the name rPropertyName does not exist.
virtual void SAL_CALL removeVetoableChangeListener(const ::rtl::OUString &aPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override final
Ignored if the property is not constrained.
virtual void SAL_CALL setPropertyValue(const ::rtl::OUString &rPropertyName, const css::uno::Any &aValue) override final
Throw UnknownPropertyException or PropertyVetoException if the property with the name rPropertyName d...
virtual void SAL_CALL addPropertyChangeListener(const ::rtl::OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override final
Ignored if the property is not bound.
OMultiTypeInterfaceContainerHelperVar4< sal_Int32, css::beans::XVetoableChangeListener > aVetoableLC
Container for the XPropertyVetoableListener.
Definition: propshlp.hxx:288
void impl_fireAll(std::unique_lock< std::mutex > &rGuard, sal_Int32 *i_handles, const css::uno::Any *i_newValues, const css::uno::Any *i_oldValues, sal_Int32 i_count)
notifies the given changes in property's values, plus all property changes collected during recent |s...
std::vector< css::uno::Any > m_newValues
Definition: propshlp.hxx:302
void setFastPropertyValues(std::unique_lock< std::mutex > &rGuard, sal_Int32 nSeqLen, sal_Int32 *pHandles, const css::uno::Any *pValues, sal_Int32 nHitCount)
Set multiple properties with the handles.
virtual void SAL_CALL removePropertiesChangeListener(const css::uno::Reference< css::beans::XPropertiesChangeListener > &Listener) override final
comphelper::OInterfaceContainerHelper4< css::beans::XPropertyChangeListener > maPropertyChangeListeners
Container for the XPropertyChangedListener where the listeners want to listen to all properties.
Definition: propshlp.hxx:293
virtual void SAL_CALL addPropertiesChangeListener(const css::uno::Sequence<::rtl::OUString > &PropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &Listener) override final
virtual void SAL_CALL firePropertiesChangeEvent(const css::uno::Sequence<::rtl::OUString > &PropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &Listener) override final
virtual void setFastPropertyValue_NoBroadcast(std::unique_lock< std::mutex > &rGuard, sal_Int32 nHandle, const css::uno::Any &rValue)=0
The same as setFastPropertyValue; nHandle is always valid.
virtual void SAL_CALL setPropertyValues(const css::uno::Sequence<::rtl::OUString > &PropertyNames, const css::uno::Sequence< css::uno::Any > &Values) override
virtual void SAL_CALL setFastPropertyValue(sal_Int32 nHandle, const css::uno::Any &rValue) override final
Throw UnknownPropertyException or PropertyVetoException if the property with the name rPropertyName d...
comphelper::OInterfaceContainerHelper4< css::beans::XPropertiesChangeListener > maPropertiesChangeListeners
Definition: propshlp.hxx:295
virtual cppu::IPropertyArrayHelper & getInfoHelper()=0
This abstract method must return the name to index table.
void fire(std::unique_lock< std::mutex > &rGuard, sal_Int32 *pnHandles, const css::uno::Any *pNewValues, const css::uno::Any *pOldValues, sal_Int32 nCount, bool bVetoable)
This method fire events to all registered property listeners.
OMultiTypeInterfaceContainerHelperVar4< sal_Int32, css::beans::XPropertyChangeListener > aBoundLC
Container for the XPropertyChangedListener.
Definition: propshlp.hxx:283
virtual void SAL_CALL addVetoableChangeListener(const ::rtl::OUString &aPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override final
Ignored if the property is not constrained.
This class is meant to be used as a base class for UNO object implementations that want to use std::m...
Definition: unoimplbase.hxx:23
#define COMPHELPER_DLLPUBLIC
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)