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_FORMS_SOURCE_INC_PROPERTYBAGHELPER_HXX
21 #define INCLUDED_FORMS_SOURCE_INC_PROPERTYBAGHELPER_HXX
23 #include <com/sun/star/beans/PropertyValue.hpp>
25 #include <comphelper/propertybag.hxx>
26 #include <comphelper/propagg.hxx>
34 //= class IPropertyBagHelperContext
36 class SAL_NO_VTABLE IPropertyBagHelperContext
39 virtual ::osl::Mutex
& getMutex() = 0;
41 virtual void describeFixedAndAggregateProperties(
42 css::uno::Sequence
< css::beans::Property
>& _out_rFixedProperties
,
43 css::uno::Sequence
< css::beans::Property
>& _out_rAggregateProperties
46 virtual css::uno::Reference
< css::beans::XMultiPropertySet
>
47 getPropertiesInterface() = 0;
50 ~IPropertyBagHelperContext() {}
53 class PropertyBagHelper
56 IPropertyBagHelperContext
& m_rContext
;
57 std::unique_ptr
<::comphelper::OPropertyArrayAggregationHelper
>
58 m_pPropertyArrayHelper
;
59 ::comphelper::PropertyBag m_aDynamicProperties
;
63 PropertyBagHelper( IPropertyBagHelperContext
& _rContext
);
65 PropertyBagHelper(const PropertyBagHelper
&) = delete;
66 PropertyBagHelper
& operator=(const PropertyBagHelper
&) = delete;
68 // XComponent equivalent
71 // OPropertySetHelper equivalent
72 inline ::comphelper::OPropertyArrayAggregationHelper
& getInfoHelper() const;
74 // XPropertyContainer equivalent
75 void addProperty( const OUString
& _rName
, ::sal_Int16 _nAttributes
, const css::uno::Any
& _rInitialValue
);
76 void removeProperty( const OUString
& _rName
);
78 // XPropertyAccess equivalent
79 css::uno::Sequence
< css::beans::PropertyValue
> getPropertyValues();
80 void setPropertyValues( const css::uno::Sequence
< css::beans::PropertyValue
>& _rProps
);
82 // forwards to m_aDynamicProperties
83 inline void getDynamicFastPropertyValue( sal_Int32 _nHandle
, css::uno::Any
& _out_rValue
) const;
84 inline bool convertDynamicFastPropertyValue( sal_Int32 _nHandle
, const css::uno::Any
& _rNewValue
, css::uno::Any
& _out_rConvertedValue
, css::uno::Any
& _out_rCurrentValue
) const;
85 inline void setDynamicFastPropertyValue( sal_Int32 _nHandle
, const css::uno::Any
& _rValue
);
86 inline void getDynamicPropertyDefaultByHandle( sal_Int32 _nHandle
, css::uno::Any
& _out_rValue
) const;
87 inline bool hasDynamicPropertyByHandle( sal_Int32 _nHandle
) const;
90 void impl_nts_checkDisposed_throw() const;
92 /** invalidates our property set info, so subsequent calls to impl_ts_getArrayHelper and thus
93 getInfoHelper will return a newly created instance
95 void impl_nts_invalidatePropertySetInfo();
97 /** returns the IPropertyArrayHelper instance used by |this|
99 ::comphelper::OPropertyArrayAggregationHelper
& impl_ts_getArrayHelper() const;
101 /** finds a free property handle
102 @param _rPropertyName
103 the name of the property to find a handle for. If possible, the handle as determined by
104 our ConcreteInfoService instance will be used
106 sal_Int32
impl_findFreeHandle( const OUString
& _rPropertyName
);
110 inline ::comphelper::OPropertyArrayAggregationHelper
& PropertyBagHelper::getInfoHelper() const
112 return impl_ts_getArrayHelper();
116 inline void PropertyBagHelper::getDynamicFastPropertyValue( sal_Int32 _nHandle
, css::uno::Any
& _out_rValue
) const
118 m_aDynamicProperties
.getFastPropertyValue( _nHandle
, _out_rValue
);
122 inline bool PropertyBagHelper::convertDynamicFastPropertyValue( sal_Int32 _nHandle
, const css::uno::Any
& _rNewValue
, css::uno::Any
& _out_rConvertedValue
, css::uno::Any
& _out_rCurrentValue
) const
124 return m_aDynamicProperties
.convertFastPropertyValue( _nHandle
, _rNewValue
, _out_rConvertedValue
, _out_rCurrentValue
);
128 inline void PropertyBagHelper::setDynamicFastPropertyValue( sal_Int32 _nHandle
, const css::uno::Any
& _rValue
)
130 m_aDynamicProperties
.setFastPropertyValue( _nHandle
, _rValue
);
134 inline void PropertyBagHelper::getDynamicPropertyDefaultByHandle( sal_Int32 _nHandle
, css::uno::Any
& _out_rValue
) const
136 m_aDynamicProperties
.getPropertyDefaultByHandle( _nHandle
, _out_rValue
);
139 inline bool PropertyBagHelper::hasDynamicPropertyByHandle( sal_Int32 _nHandle
) const
141 return m_aDynamicProperties
.hasPropertyByHandle( _nHandle
);
148 #endif // INCLUDED_FORMS_SOURCE_INC_PROPERTYBAGHELPER_HXX
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */