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 .
20 #ifndef INCLUDED_COMPHELPER_SOURCE_PROPERTY_OPROPERTYBAG_HXX
21 #define INCLUDED_COMPHELPER_SOURCE_PROPERTY_OPROPERTYBAG_HXX
23 #include <com/sun/star/lang/XInitialization.hpp>
24 #include <com/sun/star/lang/XServiceInfo.hpp>
25 #include <com/sun/star/util/XModifiable.hpp>
26 #include <com/sun/star/beans/XPropertyBag.hpp>
27 #include <com/sun/star/container/XSet.hpp>
29 #include <cppuhelper/implbase5.hxx>
30 #include <comphelper/interfacecontainer2.hxx>
31 #include <comphelper/propstate.hxx>
32 #include <comphelper/broadcasthelper.hxx>
33 #include <comphelper/propertybag.hxx>
34 #include <comphelper/uno3.hxx>
47 bool operator()( const css::uno::Type
& _rLHS
, const css::uno::Type
& _rRHS
) const
49 return rtl_ustr_compare(
50 _rLHS
.getTypeLibType()->pTypeName
->buffer
,
51 _rRHS
.getTypeLibType()->pTypeName
->buffer
56 typedef std::map
< sal_Int32
, css::uno::Any
> MapInt2Any
;
57 typedef std::set
< css::uno::Type
, UnoTypeLess
> TypeBag
;
59 typedef ::cppu::WeakAggImplHelper5
< css::beans::XPropertyBag
60 , css::util::XModifiable
61 , css::lang::XServiceInfo
62 , css::lang::XInitialization
63 , css::container::XSet
65 typedef ::comphelper::OPropertyStateHelper OPropertyBag_PBase
;
67 class OPropertyBag final
: public ::comphelper::OMutexAndBroadcastHelper
// must be before OPropertyBag_PBase
68 ,public OPropertyBag_PBase
69 ,public OPropertyBag_Base
70 ,public ::cppu::IEventNotificationHook
73 /// our IPropertyArrayHelper implementation
74 std::unique_ptr
< ::cppu::OPropertyArrayHelper
>
76 ::comphelper::PropertyBag
78 /// set of allowed property types
79 TypeBag m_aAllowedTypes
;
80 /// should we automatically add properties which are tried to set, if they don't exist previously?
81 bool m_bAutoAddProperties
;
84 ::comphelper::OInterfaceContainerHelper2 m_NotifyListeners
;
90 OPropertyBag(const OPropertyBag
&) = delete;
91 const OPropertyBag
& operator=(const OPropertyBag
&) = delete;
93 virtual ~OPropertyBag() override
;
97 DECLARE_XTYPEPROVIDER()
99 /** === begin UNO interface implementations == **/
101 virtual void SAL_CALL
initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
) override
;
104 virtual OUString SAL_CALL
getImplementationName( ) override
;
105 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
106 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) override
;
109 virtual sal_Bool SAL_CALL
isModified( ) override
;
110 virtual void SAL_CALL
setModified( sal_Bool bModified
) override
;
112 // XModifyBroadcaster
113 virtual void SAL_CALL
addModifyListener(
114 const css::uno::Reference
<
115 css::util::XModifyListener
> & xListener
) override
;
116 virtual void SAL_CALL
removeModifyListener(
117 const css::uno::Reference
<
118 css::util::XModifyListener
> & xListener
) override
;
120 // XPropertyContainer
121 virtual void SAL_CALL
addProperty( const OUString
& Name
, ::sal_Int16 Attributes
, const css::uno::Any
& DefaultValue
) override
;
122 virtual void SAL_CALL
removeProperty( const OUString
& Name
) override
;
125 virtual css::uno::Sequence
< css::beans::PropertyValue
> SAL_CALL
getPropertyValues( ) override
;
126 virtual void SAL_CALL
setPropertyValues( const css::uno::Sequence
< css::beans::PropertyValue
>& aProps
) override
;
129 virtual css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) override
;
130 virtual void SAL_CALL
setPropertyValue(const OUString
& p1
, const css::uno::Any
& p2
) override
131 { OPropertyBag_PBase::setPropertyValue(p1
, p2
); }
132 virtual css::uno::Any SAL_CALL
getPropertyValue(const OUString
& p1
) override
133 { return OPropertyBag_PBase::getPropertyValue(p1
); }
134 virtual void SAL_CALL
addPropertyChangeListener(const OUString
& p1
, const css::uno::Reference
<css::beans::XPropertyChangeListener
>& p2
) override
135 { OPropertyBag_PBase::addPropertyChangeListener(p1
, p2
); }
136 virtual void SAL_CALL
removePropertyChangeListener(const OUString
& p1
, const css::uno::Reference
<css::beans::XPropertyChangeListener
>& p2
) override
137 { OPropertyBag_PBase::removePropertyChangeListener(p1
, p2
); }
138 virtual void SAL_CALL
addVetoableChangeListener(const OUString
& p1
, const css::uno::Reference
<css::beans::XVetoableChangeListener
>& p2
) override
139 { OPropertyBag_PBase::addVetoableChangeListener(p1
, p2
); }
140 virtual void SAL_CALL
removeVetoableChangeListener(const OUString
& p1
, const css::uno::Reference
<css::beans::XVetoableChangeListener
>& p2
) override
141 { OPropertyBag_PBase::removeVetoableChangeListener(p1
, p2
); }
144 virtual sal_Bool SAL_CALL
has( const css::uno::Any
& aElement
) override
;
145 virtual void SAL_CALL
insert( const css::uno::Any
& aElement
) override
;
146 virtual void SAL_CALL
remove( const css::uno::Any
& aElement
) override
;
148 // XEnumerationAccess (base of XSet)
149 virtual css::uno::Reference
< css::container::XEnumeration
> SAL_CALL
createEnumeration( ) override
;
151 // XElementAccess (base of XEnumerationAccess)
152 virtual css::uno::Type SAL_CALL
getElementType( ) override
;
153 virtual sal_Bool SAL_CALL
hasElements( ) override
;
154 // UNO interface implementations
157 virtual css::uno::Any
getPropertyDefaultByHandle( sal_Int32 _nHandle
) const override
;
159 // OPropertyStateHelper
160 virtual css::beans::PropertyState
getPropertyStateByHandle( sal_Int32 _nHandle
) override
;
162 // OPropertySetHelper
163 virtual void SAL_CALL
getFastPropertyValue( css::uno::Any
& rValue
, sal_Int32 nHandle
) const override
;
164 virtual sal_Bool SAL_CALL
convertFastPropertyValue( css::uno::Any
& rConvertedValue
, css::uno::Any
& rOldValue
, sal_Int32 nHandle
, const css::uno::Any
& rValue
) override
;
165 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast( sal_Int32 nHandle
, const css::uno::Any
& rValue
) override
;
166 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper() override
;
168 // IEventNotificationHook
169 virtual void fireEvents(
170 sal_Int32
* pnHandles
,
173 bool bIgnoreRuntimeExceptionsWhileFiring
) override
;
175 void setModifiedImpl( bool bModified
,
176 bool bIgnoreRuntimeExceptionsWhileFiring
);
178 /** finds a free property handle
182 sal_Int32
findFreeHandle() const;
184 /** implements the setPropertyValues method
186 the property values to set
188 @throws PropertyVetoException
189 if the XMultiPropertySet::setPropertyValues call does so
191 @throws css::lang::IllegalArgumentException
192 if the XMultiPropertySet::setPropertyValues call does so
194 @throws css::lang::WrappedTargetException
195 if the XMultiPropertySet::setPropertyValues call does so
197 @throws css::uno::RuntimeException
198 if the XMultiPropertySet::setPropertyValues call does so
200 @throws css::beans::UnknownPropertyException
201 if the XMultiPropertySet::setPropertyValues call does so, and <arg>_bTolerateUnknownProperties</arg>
204 @throws css::lang::WrappedTargetException
205 if the XMultiPropertySet::setPropertyValues call did throw an exception not listed
208 void impl_setPropertyValues_throw( const css::uno::Sequence
< css::beans::PropertyValue
>& _rProps
);
210 using ::cppu::OPropertySetHelper::getPropertyValues
;
211 using ::cppu::OPropertySetHelper::setPropertyValues
;
212 using ::cppu::OPropertySetHelper::getFastPropertyValue
;
216 } // namespace comphelper
219 #endif // INCLUDED_COMPHELPER_SOURCE_PROPERTY_OPROPERTYBAG_HXX
221 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */