LibreOffice Module comphelper (master) 1
opropertybag.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#pragma once
21
22#include <com/sun/star/lang/XInitialization.hpp>
23#include <com/sun/star/lang/XServiceInfo.hpp>
24#include <com/sun/star/util/XModifiable.hpp>
25#include <com/sun/star/beans/XPropertyBag.hpp>
26#include <com/sun/star/container/XSet.hpp>
27
33#include <comphelper/uno3.hxx>
34
35#include <map>
36#include <set>
37#include <memory>
38
39
40namespace comphelper
41{
42
43
45 {
46 bool operator()( const css::uno::Type& _rLHS, const css::uno::Type& _rRHS ) const
47 {
48 return rtl_ustr_compare(
49 _rLHS.getTypeLibType()->pTypeName->buffer,
50 _rRHS.getTypeLibType()->pTypeName->buffer
51 ) < 0;
52 }
53 };
54
55 typedef std::map< sal_Int32, css::uno::Any > MapInt2Any;
56 typedef std::set< css::uno::Type, UnoTypeLess > TypeBag;
57
58 typedef ::cppu::WeakAggImplHelper5 < css::beans::XPropertyBag
59 , css::util::XModifiable
60 , css::lang::XServiceInfo
61 , css::lang::XInitialization
62 , css::container::XSet
64 typedef ::comphelper::OPropertyStateHelper OPropertyBag_PBase;
65
66 class OPropertyBag final : public ::comphelper::OMutexAndBroadcastHelper // must be before OPropertyBag_PBase
67 ,public OPropertyBag_PBase
68 ,public OPropertyBag_Base
70 {
71 private:
73 std::unique_ptr< ::cppu::OPropertyArrayHelper >
75 ::comphelper::PropertyBag
81
86
87 public:
88 //noncopyable
89 OPropertyBag(const OPropertyBag&) = delete;
90 const OPropertyBag& operator=(const OPropertyBag&) = delete;
92 virtual ~OPropertyBag() override;
93
94 private:
97
99 // XInitialization
100 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
101
102 // XServiceInfo
103 virtual OUString SAL_CALL getImplementationName( ) override;
104 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
105 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
106
107 // XModifiable:
108 virtual sal_Bool SAL_CALL isModified( ) override;
109 virtual void SAL_CALL setModified( sal_Bool bModified ) override;
110
111 // XModifyBroadcaster
112 virtual void SAL_CALL addModifyListener(
113 const css::uno::Reference<
114 css::util::XModifyListener > & xListener) override;
115 virtual void SAL_CALL removeModifyListener(
116 const css::uno::Reference<
117 css::util::XModifyListener > & xListener) override;
118
119 // XPropertyContainer
120 virtual void SAL_CALL addProperty( const OUString& Name, ::sal_Int16 Attributes, const css::uno::Any& DefaultValue ) override;
121 virtual void SAL_CALL removeProperty( const OUString& Name ) override;
122
123 // XPropertyAccess
124 virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getPropertyValues( ) override;
125 virtual void SAL_CALL setPropertyValues( const css::uno::Sequence< css::beans::PropertyValue >& aProps ) override;
126
127 // XPropertySet
128 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
129 virtual void SAL_CALL setPropertyValue(const OUString& p1, const css::uno::Any& p2) override
130 { OPropertyBag_PBase::setPropertyValue(p1, p2); }
131 virtual css::uno::Any SAL_CALL getPropertyValue(const OUString& p1) override
132 { return OPropertyBag_PBase::getPropertyValue(p1); }
133 virtual void SAL_CALL addPropertyChangeListener(const OUString& p1, const css::uno::Reference<css::beans::XPropertyChangeListener>& p2) override
134 { OPropertyBag_PBase::addPropertyChangeListener(p1, p2); }
135 virtual void SAL_CALL removePropertyChangeListener(const OUString& p1, const css::uno::Reference<css::beans::XPropertyChangeListener>& p2) override
136 { OPropertyBag_PBase::removePropertyChangeListener(p1, p2); }
137 virtual void SAL_CALL addVetoableChangeListener(const OUString& p1, const css::uno::Reference<css::beans::XVetoableChangeListener>& p2) override
138 { OPropertyBag_PBase::addVetoableChangeListener(p1, p2); }
139 virtual void SAL_CALL removeVetoableChangeListener(const OUString& p1, const css::uno::Reference<css::beans::XVetoableChangeListener>& p2) override
140 { OPropertyBag_PBase::removeVetoableChangeListener(p1, p2); }
141
142 // XSet
143 virtual sal_Bool SAL_CALL has( const css::uno::Any& aElement ) override;
144 virtual void SAL_CALL insert( const css::uno::Any& aElement ) override;
145 virtual void SAL_CALL remove( const css::uno::Any& aElement ) override;
146
147 // XEnumerationAccess (base of XSet)
148 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration( ) override;
149
150 // XElementAccess (base of XEnumerationAccess)
151 virtual css::uno::Type SAL_CALL getElementType( ) override;
152 virtual sal_Bool SAL_CALL hasElements( ) override;
153 // UNO interface implementations
154
155 // XPropertyState
156 virtual css::uno::Any getPropertyDefaultByHandle( sal_Int32 _nHandle ) const override;
157
158 // OPropertyStateHelper
159 virtual css::beans::PropertyState getPropertyStateByHandle( sal_Int32 _nHandle ) override;
160
161 // OPropertySetHelper
162 virtual void SAL_CALL getFastPropertyValue( css::uno::Any& rValue, sal_Int32 nHandle ) const override;
163 virtual sal_Bool SAL_CALL convertFastPropertyValue( css::uno::Any & rConvertedValue, css::uno::Any & rOldValue, sal_Int32 nHandle, const css::uno::Any& rValue ) override;
164 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const css::uno::Any& rValue ) override;
165 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override;
166
167 // IEventNotificationHook
168 virtual void fireEvents(
169 sal_Int32 * pnHandles,
170 sal_Int32 nCount,
171 sal_Bool bVetoable,
172 bool bIgnoreRuntimeExceptionsWhileFiring) override;
173
174 void setModifiedImpl( bool bModified,
175 bool bIgnoreRuntimeExceptionsWhileFiring);
176
181 sal_Int32 findFreeHandle() const;
182
207 void impl_setPropertyValues_throw( const css::uno::Sequence< css::beans::PropertyValue >& _rProps );
208
209 using ::cppu::OPropertySetHelper::getPropertyValues;
210 using ::cppu::OPropertySetHelper::setPropertyValues;
211 using ::cppu::OPropertySetHelper::getFastPropertyValue;
212 };
213
214
215} // namespace comphelper
216
217
218/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual sal_Bool SAL_CALL convertFastPropertyValue(css::uno::Any &rConvertedValue, css::uno::Any &rOldValue, sal_Int32 nHandle, const css::uno::Any &rValue) override
const OPropertyBag & operator=(const OPropertyBag &)=delete
void setModifiedImpl(bool bModified, bool bIgnoreRuntimeExceptionsWhileFiring)
virtual void SAL_CALL addPropertyChangeListener(const OUString &p1, const css::uno::Reference< css::beans::XPropertyChangeListener > &p2) override
virtual void SAL_CALL remove(const css::uno::Any &aElement) override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
virtual void SAL_CALL addVetoableChangeListener(const OUString &p1, const css::uno::Reference< css::beans::XVetoableChangeListener > &p2) override
virtual void SAL_CALL removeProperty(const OUString &Name) override
bool m_bAutoAddProperties
should we automatically add properties which are tried to set, if they don't exist previously?
::comphelper::PropertyBag m_aDynamicProperties
TypeBag m_aAllowedTypes
set of allowed property types
virtual css::uno::Any getPropertyDefaultByHandle(sal_Int32 _nHandle) const override
virtual OUString SAL_CALL getImplementationName() override
virtual void SAL_CALL addModifyListener(const css::uno::Reference< css::util::XModifyListener > &xListener) override
virtual void SAL_CALL removePropertyChangeListener(const OUString &p1, const css::uno::Reference< css::beans::XPropertyChangeListener > &p2) override
OPropertyBag(const OPropertyBag &)=delete
virtual void SAL_CALL setPropertyValues(const css::uno::Sequence< css::beans::PropertyValue > &aProps) override
virtual css::uno::Type SAL_CALL getElementType() override
virtual void fireEvents(sal_Int32 *pnHandles, sal_Int32 nCount, sal_Bool bVetoable, bool bIgnoreRuntimeExceptionsWhileFiring) override
virtual void SAL_CALL setModified(sal_Bool bModified) override
bool m_isModified
modify flag
virtual void SAL_CALL removeVetoableChangeListener(const OUString &p1, const css::uno::Reference< css::beans::XVetoableChangeListener > &p2) override
virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const css::uno::Any &rValue) override
virtual css::beans::PropertyState getPropertyStateByHandle(sal_Int32 _nHandle) override
virtual void SAL_CALL setPropertyValue(const OUString &p1, const css::uno::Any &p2) override
virtual ~OPropertyBag() override
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getPropertyValues() override
virtual void SAL_CALL getFastPropertyValue(css::uno::Any &rValue, sal_Int32 nHandle) const override
std::unique_ptr< ::cppu::OPropertyArrayHelper > m_pArrayHelper
our IPropertyArrayHelper implementation
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &p1) override
virtual void SAL_CALL removeModifyListener(const css::uno::Reference< css::util::XModifyListener > &xListener) override
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
=== begin UNO interface implementations ==
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
::comphelper::OInterfaceContainerHelper3< css::util::XModifyListener > m_NotifyListeners
for notification
virtual void SAL_CALL addProperty(const OUString &Name, ::sal_Int16 Attributes, const css::uno::Any &DefaultValue) override
virtual sal_Bool SAL_CALL isModified() override
virtual sal_Bool SAL_CALL has(const css::uno::Any &aElement) override
sal_Int32 findFreeHandle() const
finds a free property handle @precond our mutex is locked
void impl_setPropertyValues_throw(const css::uno::Sequence< css::beans::PropertyValue > &_rProps)
implements the setPropertyValues method
virtual sal_Bool SAL_CALL hasElements() override
virtual void SAL_CALL insert(const css::uno::Any &aElement) override
std::map< sal_Int32, css::uno::Any > MapInt2Any
::cppu::WeakAggImplHelper5< css::beans::XPropertyBag, css::util::XModifiable, css::lang::XServiceInfo, css::lang::XInitialization, css::container::XSet > OPropertyBag_Base
::comphelper::OPropertyStateHelper OPropertyBag_PBase
std::set< css::uno::Type, UnoTypeLess > TypeBag
bool operator()(const css::uno::Type &_rLHS, const css::uno::Type &_rRHS) const
unsigned char sal_Bool
#define DECLARE_XTYPEPROVIDER()
Definition: uno3.hxx:126
#define DECLARE_XINTERFACE()
Definition: uno3.hxx:90