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>
33 //= class IPropertyBagHelperContext
35 class SAL_NO_VTABLE IPropertyBagHelperContext
38 virtual ::osl::Mutex
& getMutex() = 0;
40 virtual void describeFixedAndAggregateProperties(
41 css::uno::Sequence
< css::beans::Property
>& _out_rFixedProperties
,
42 css::uno::Sequence
< css::beans::Property
>& _out_rAggregateProperties
45 virtual css::uno::Reference
< css::beans::XMultiPropertySet
>
46 getPropertiesInterface() = 0;
49 ~IPropertyBagHelperContext() {}
52 class PropertyBagHelper
55 IPropertyBagHelperContext
& m_rContext
;
56 ::comphelper::OPropertyArrayAggregationHelper
* m_pPropertyArrayHelper
;
57 ::comphelper::PropertyBag m_aDynamicProperties
;
61 PropertyBagHelper( IPropertyBagHelperContext
& _rContext
);
63 PropertyBagHelper(const PropertyBagHelper
&) = delete;
64 PropertyBagHelper
& operator=(const PropertyBagHelper
&) = delete;
66 // XComponent equivalent
69 // OPropertySetHelper equivalent
70 inline ::comphelper::OPropertyArrayAggregationHelper
& getInfoHelper() const;
72 // XPropertyContainer equivalent
73 void addProperty( const OUString
& _rName
, ::sal_Int16 _nAttributes
, const css::uno::Any
& _rInitialValue
);
74 void removeProperty( const OUString
& _rName
);
76 // XPropertyAccess equivalent
77 css::uno::Sequence
< css::beans::PropertyValue
> SAL_CALL
getPropertyValues();
78 void setPropertyValues( const css::uno::Sequence
< css::beans::PropertyValue
>& _rProps
);
80 // forwards to m_aDynamicProperties
81 inline void getDynamicFastPropertyValue( sal_Int32 _nHandle
, css::uno::Any
& _out_rValue
) const;
82 inline bool convertDynamicFastPropertyValue( sal_Int32 _nHandle
, const css::uno::Any
& _rNewValue
, css::uno::Any
& _out_rConvertedValue
, css::uno::Any
& _out_rCurrentValue
) const;
83 inline void setDynamicFastPropertyValue( sal_Int32 _nHandle
, const css::uno::Any
& _rValue
);
84 inline void getDynamicPropertyDefaultByHandle( sal_Int32 _nHandle
, css::uno::Any
& _out_rValue
) const;
85 inline bool hasDynamicPropertyByHandle( sal_Int32 _nHandle
) const;
88 void impl_nts_checkDisposed_throw() const;
90 /** invalidates our property set info, so subsequent calls to impl_ts_getArrayHelper and thus
91 getInfoHelper will return a newly created instance
93 void impl_nts_invalidatePropertySetInfo();
95 /** returns the IPropertyArrayHelper instance used by |this|
97 ::comphelper::OPropertyArrayAggregationHelper
& impl_ts_getArrayHelper() const;
99 /** finds a free property handle
100 @param _rPropertyName
101 the name of the property to find a handle for. If possible, the handle as determined by
102 our ConcreteInfoService instance will be used
104 sal_Int32
impl_findFreeHandle( const OUString
& _rPropertyName
);
108 inline ::comphelper::OPropertyArrayAggregationHelper
& PropertyBagHelper::getInfoHelper() const
110 return impl_ts_getArrayHelper();
114 inline void PropertyBagHelper::getDynamicFastPropertyValue( sal_Int32 _nHandle
, css::uno::Any
& _out_rValue
) const
116 m_aDynamicProperties
.getFastPropertyValue( _nHandle
, _out_rValue
);
120 inline bool PropertyBagHelper::convertDynamicFastPropertyValue( sal_Int32 _nHandle
, const css::uno::Any
& _rNewValue
, css::uno::Any
& _out_rConvertedValue
, css::uno::Any
& _out_rCurrentValue
) const
122 return m_aDynamicProperties
.convertFastPropertyValue( _nHandle
, _rNewValue
, _out_rConvertedValue
, _out_rCurrentValue
);
126 inline void PropertyBagHelper::setDynamicFastPropertyValue( sal_Int32 _nHandle
, const css::uno::Any
& _rValue
)
128 m_aDynamicProperties
.setFastPropertyValue( _nHandle
, _rValue
);
132 inline void PropertyBagHelper::getDynamicPropertyDefaultByHandle( sal_Int32 _nHandle
, css::uno::Any
& _out_rValue
) const
134 m_aDynamicProperties
.getPropertyDefaultByHandle( _nHandle
, _out_rValue
);
137 inline bool PropertyBagHelper::hasDynamicPropertyByHandle( sal_Int32 _nHandle
) const
139 return m_aDynamicProperties
.hasPropertyByHandle( _nHandle
);
146 #endif // INCLUDED_FORMS_SOURCE_INC_PROPERTYBAGHELPER_HXX
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */