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 <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>
28 #include <cppuhelper/implbase.hxx>
29 #include <comphelper/interfacecontainer3.hxx>
30 #include <comphelper/propstate.hxx>
31 #include <comphelper/broadcasthelper.hxx>
32 #include <comphelper/propertybag.hxx>
33 #include <comphelper/uno3.hxx>
46 bool operator()( const css::uno::Type
& _rLHS
, const css::uno::Type
& _rRHS
) const
48 return rtl_ustr_compare(
49 _rLHS
.getTypeLibType()->pTypeName
->buffer
,
50 _rRHS
.getTypeLibType()->pTypeName
->buffer
55 typedef std::map
< sal_Int32
, css::uno::Any
> MapInt2Any
;
56 typedef std::set
< css::uno::Type
, UnoTypeLess
> TypeBag
;
58 typedef ::cppu::WeakImplHelper
< 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
;
66 class OPropertyBag final
: public ::comphelper::OMutexAndBroadcastHelper
// must be before OPropertyBag_PBase
67 ,public OPropertyBag_PBase
68 ,public OPropertyBag_Base
69 ,public ::cppu::IEventNotificationHook
72 /// our IPropertyArrayHelper implementation
73 std::unique_ptr
< ::cppu::OPropertyArrayHelper
>
75 ::comphelper::PropertyBag
77 /// set of allowed property types
78 TypeBag m_aAllowedTypes
;
79 /// should we automatically add properties which are tried to set, if they don't exist previously?
80 bool m_bAutoAddProperties
;
83 ::comphelper::OInterfaceContainerHelper3
<css::util::XModifyListener
> m_NotifyListeners
;
89 OPropertyBag(const OPropertyBag
&) = delete;
90 const OPropertyBag
& operator=(const OPropertyBag
&) = delete;
92 virtual ~OPropertyBag() override
;
96 DECLARE_XTYPEPROVIDER()
98 /** === begin UNO interface implementations == **/
100 virtual void SAL_CALL
initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
) override
;
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
;
108 virtual sal_Bool SAL_CALL
isModified( ) override
;
109 virtual void SAL_CALL
setModified( sal_Bool bModified
) override
;
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
;
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
;
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
;
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
); }
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
;
147 // XEnumerationAccess (base of XSet)
148 virtual css::uno::Reference
< css::container::XEnumeration
> SAL_CALL
createEnumeration( ) override
;
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
156 virtual css::uno::Any
getPropertyDefaultByHandle( sal_Int32 _nHandle
) const override
;
158 // OPropertyStateHelper
159 virtual css::beans::PropertyState
getPropertyStateByHandle( sal_Int32 _nHandle
) override
;
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
;
167 // IEventNotificationHook
168 virtual void fireEvents(
169 sal_Int32
* pnHandles
,
172 bool bIgnoreRuntimeExceptionsWhileFiring
) override
;
174 void setModifiedImpl( bool bModified
,
175 bool bIgnoreRuntimeExceptionsWhileFiring
);
177 /** finds a free property handle
181 sal_Int32
findFreeHandle() const;
183 /** implements the setPropertyValues method
185 the property values to set
187 @throws PropertyVetoException
188 if the XMultiPropertySet::setPropertyValues call does so
190 @throws css::lang::IllegalArgumentException
191 if the XMultiPropertySet::setPropertyValues call does so
193 @throws css::lang::WrappedTargetException
194 if the XMultiPropertySet::setPropertyValues call does so
196 @throws css::uno::RuntimeException
197 if the XMultiPropertySet::setPropertyValues call does so
199 @throws css::beans::UnknownPropertyException
200 if the XMultiPropertySet::setPropertyValues call does so, and <arg>_bTolerateUnknownProperties</arg>
203 @throws css::lang::WrappedTargetException
204 if the XMultiPropertySet::setPropertyValues call did throw an exception not listed
207 void impl_setPropertyValues_throw( const css::uno::Sequence
< css::beans::PropertyValue
>& _rProps
);
209 using ::cppu::OPropertySetHelper::getPropertyValues
;
210 using ::cppu::OPropertySetHelper::setPropertyValues
;
211 using ::cppu::OPropertySetHelper::getFastPropertyValue
;
215 } // namespace comphelper
218 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */