LibreOffice Module comphelper (master) 1
propagg.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
20#ifndef INCLUDED_COMPHELPER_PROPAGG_HXX
21#define INCLUDED_COMPHELPER_PROPAGG_HXX
22
23#include <config_options.h>
24#include <com/sun/star/beans/Property.hpp>
25#include <com/sun/star/beans/PropertyState.hpp>
26#include <com/sun/star/beans/XPropertiesChangeListener.hpp>
27#include <com/sun/star/beans/XVetoableChangeListener.hpp>
28#include <com/sun/star/lang/EventObject.hpp>
31
32#include <cstddef>
33#include <map>
34#include <memory>
35#include <vector>
36
37
38//= property helper classes
39
40
41namespace comphelper
42{
43
44
45//= OPropertyAccessor
46//= internal helper class for OPropertyArrayAggregationHelper
47
48namespace internal
49{
51 {
52 sal_Int32 nOriginalHandle;
53 std::size_t nPos;
55
56 OPropertyAccessor(sal_Int32 _nOriginalHandle, std::size_t _nPos, bool _bAggregate)
57 :nOriginalHandle(_nOriginalHandle) ,nPos(_nPos) ,bAggregate(_bAggregate) { }
58
59 bool operator==(const OPropertyAccessor& rOb) const { return nPos == rOb.nPos; }
60 bool operator <(const OPropertyAccessor& rOb) const { return nPos < rOb.nPos; }
61 };
62}
63
64
69{
70public:
76 virtual sal_Int32 getPreferredPropertyId(const OUString& _rName) = 0;
77
78protected:
80};
81
87#define DEFAULT_AGGREGATE_PROPERTY_ID 10000
88
90{
91 friend class OPropertySetAggregationHelper;
92
93 std::vector<css::beans::Property> m_aProperties;
94 std::map< sal_Int32, internal::OPropertyAccessor > m_aPropertyAccessors;
95
96public:
120 OPropertyArrayAggregationHelper(const css::uno::Sequence< css::beans::Property>& _rProperties,
121 const css::uno::Sequence< css::beans::Property>& _rAggProperties,
122 IPropertyInfoService* _pInfoService = nullptr,
123 sal_Int32 _nFirstAggregateId = DEFAULT_AGGREGATE_PROPERTY_ID);
124
125
127 virtual sal_Bool SAL_CALL fillPropertyMembersByHandle( OUString* _pPropName, sal_Int16* _pAttributes,
128 sal_Int32 _nHandle) override ;
129
131 virtual css::uno::Sequence< css::beans::Property> SAL_CALL getProperties() override;
133 virtual css::beans::Property SAL_CALL getPropertyByName(const OUString& _rPropertyName) override;
134
136 virtual sal_Bool SAL_CALL hasPropertyByName(const OUString& _rPropertyName) override ;
138 virtual sal_Int32 SAL_CALL getHandleByName(const OUString & _rPropertyName) override;
140 virtual sal_Int32 SAL_CALL fillHandles( /*out*/sal_Int32* _pHandles, const css::uno::Sequence< OUString >& _rPropNames ) override;
141
150 bool fillAggregatePropertyInfoByHandle(OUString* _pPropName, sal_Int32* _pOriginalHandle,
151 sal_Int32 _nHandle) const;
152
155 bool getPropertyByHandle( sal_Int32 _nHandle, css::beans::Property& _rProperty ) const;
156
157
158 enum class PropertyOrigin
159 {
160 Aggregate,
161 Delegator,
162 Unknown
163 };
176 PropertyOrigin classifyProperty( const OUString& _rName );
177
178private:
179 const css::beans::Property* findPropertyByName(const OUString& _rName) const;
180};
181
182
183namespace internal
184{
185 class PropertyForwarder;
186}
187
194class UNLESS_MERGELIBS(COMPHELPER_DLLPUBLIC) OPropertySetAggregationHelper :public OPropertyStateHelper
195 ,public css::beans::XPropertiesChangeListener
196 ,public css::beans::XVetoableChangeListener
197{
198 friend class internal::PropertyForwarder;
199
200protected:
201 css::uno::Reference< css::beans::XPropertyState> m_xAggregateState;
202 css::uno::Reference< css::beans::XPropertySet> m_xAggregateSet;
203 css::uno::Reference< css::beans::XMultiPropertySet> m_xAggregateMultiSet;
204 css::uno::Reference< css::beans::XFastPropertySet> m_xAggregateFastSet;
205
206 std::unique_ptr<internal::PropertyForwarder> m_pForwarder;
207 bool m_bListening : 1;
208
209public:
210 OPropertySetAggregationHelper( ::cppu::OBroadcastHelper& rBHelper );
211
212 virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& aType) override;
213
214// XEventListener
215 virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override;
216
217// XFastPropertySet
218 virtual void SAL_CALL setFastPropertyValue(sal_Int32 nHandle, const css::uno::Any& aValue) override;
219 virtual css::uno::Any SAL_CALL getFastPropertyValue(sal_Int32 nHandle) override;
220
221// XPropertySet
222 virtual void SAL_CALL addPropertyChangeListener(const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override;
223 virtual void SAL_CALL addVetoableChangeListener(const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener) override;
224
225// XPropertiesChangeListener
226 virtual void SAL_CALL propertiesChange(const css::uno::Sequence< css::beans::PropertyChangeEvent >& evt) override;
227
228// XVetoableChangeListener
229 virtual void SAL_CALL vetoableChange(const css::beans::PropertyChangeEvent& aEvent) override;
230
231// XMultiPropertySet
232 virtual void SAL_CALL setPropertyValues(const css::uno::Sequence< OUString >& PropertyNames, const css::uno::Sequence< css::uno::Any >& Values) override;
233 virtual void SAL_CALL addPropertiesChangeListener(const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener) override;
234
235// XPropertyState
236 virtual css::beans::PropertyState SAL_CALL getPropertyState(const OUString& PropertyName) override;
237 virtual void SAL_CALL setPropertyToDefault(const OUString& PropertyName) override;
238 virtual css::uno::Any SAL_CALL getPropertyDefault(const OUString& aPropertyName) override;
239
240// OPropertySetHelper
244 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override = 0;
245
249 virtual sal_Bool SAL_CALL convertFastPropertyValue( css::uno::Any& _rConvertedValue, css::uno::Any& _rOldValue, sal_Int32 _nHandle, const css::uno::Any& _rValue ) override;
250
254 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle, const css::uno::Any& _rValue ) override;
255
256protected:
257 virtual ~OPropertySetAggregationHelper() override;
258
259 virtual void SAL_CALL getFastPropertyValue(css::uno::Any& rValue, sal_Int32 nHandle) const override;
260 void disposing();
261
262 sal_Int32 getOriginalHandle( sal_Int32 _nHandle ) const;
263 OUString getPropertyName( sal_Int32 _nHandle ) const;
264
286 void declareForwardedProperty( sal_Int32 _nHandle );
287
294 bool isCurrentlyForwardingProperty( sal_Int32 _nHandle ) const;
295
302 virtual void forwardingPropertyValue( sal_Int32 _nHandle );
303
310 virtual void forwardedPropertyValue( sal_Int32 _nHandle );
311
315 void setAggregation(const css::uno::Reference< css::uno::XInterface >&);
316 void startListening();
317};
318
319
320} // namespace comphelper
321
322
323#endif // INCLUDED_COMPHELPER_PROPAGG_HXX
324
325/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
AnyEventRef aEvent
used as callback for an OPropertyArrayAggregationHelper
Definition: propagg.hxx:69
virtual sal_Int32 getPreferredPropertyId(const OUString &_rName)=0
get the preferred handle for the given property
std::map< sal_Int32, internal::OPropertyAccessor > m_aPropertyAccessors
Definition: propagg.hxx:94
std::vector< css::beans::Property > m_aProperties
Definition: propagg.hxx:93
#define COMPHELPER_DLLPUBLIC
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)
Unknown
OUString getPropertyName(sal_Int32 nPropertyType)
#define DEFAULT_AGGREGATE_PROPERTY_ID
used for implementing a cppu::IPropertyArrayHelper for classes aggregating property sets
Definition: propagg.hxx:87
bool operator<(const OPropertyAccessor &rOb) const
Definition: propagg.hxx:60
bool operator==(const OPropertyAccessor &rOb) const
Definition: propagg.hxx:59
OPropertyAccessor(sal_Int32 _nOriginalHandle, std::size_t _nPos, bool _bAggregate)
Definition: propagg.hxx:56
unsigned char sal_Bool
sal_Int32 _nPos