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/beans/PropertyValue.hpp>
24 #include <comphelper/propertybag.hxx>
25 #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 std::unique_ptr
<::comphelper::OPropertyArrayAggregationHelper
>
57 m_pPropertyArrayHelper
;
58 ::comphelper::PropertyBag m_aDynamicProperties
;
62 PropertyBagHelper( IPropertyBagHelperContext
& _rContext
);
64 PropertyBagHelper(const PropertyBagHelper
&) = delete;
65 PropertyBagHelper
& operator=(const PropertyBagHelper
&) = delete;
67 // XComponent equivalent
70 // OPropertySetHelper equivalent
71 inline ::comphelper::OPropertyArrayAggregationHelper
& getInfoHelper() const;
73 // XPropertyContainer equivalent
74 void addProperty( const OUString
& _rName
, ::sal_Int16 _nAttributes
, const css::uno::Any
& _rInitialValue
);
75 void removeProperty( const OUString
& _rName
);
77 // XPropertyAccess equivalent
78 css::uno::Sequence
< css::beans::PropertyValue
> getPropertyValues();
79 void setPropertyValues( const css::uno::Sequence
< css::beans::PropertyValue
>& _rProps
);
81 // forwards to m_aDynamicProperties
82 inline void getDynamicFastPropertyValue( sal_Int32 _nHandle
, css::uno::Any
& _out_rValue
) const;
83 inline bool convertDynamicFastPropertyValue( sal_Int32 _nHandle
, const css::uno::Any
& _rNewValue
, css::uno::Any
& _out_rConvertedValue
, css::uno::Any
& _out_rCurrentValue
) const;
84 inline void setDynamicFastPropertyValue( sal_Int32 _nHandle
, const css::uno::Any
& _rValue
);
85 inline void getDynamicPropertyDefaultByHandle( sal_Int32 _nHandle
, css::uno::Any
& _out_rValue
) const;
86 inline bool hasDynamicPropertyByHandle( sal_Int32 _nHandle
) const;
89 void impl_nts_checkDisposed_throw() const;
91 /** invalidates our property set info, so subsequent calls to impl_ts_getArrayHelper and thus
92 getInfoHelper will return a newly created instance
94 void impl_nts_invalidatePropertySetInfo();
96 /** returns the IPropertyArrayHelper instance used by |this|
98 ::comphelper::OPropertyArrayAggregationHelper
& impl_ts_getArrayHelper() const;
100 /** finds a free property handle
101 @param _rPropertyName
102 the name of the property to find a handle for. If possible, the handle as determined by
103 our ConcreteInfoService instance will be used
105 sal_Int32
impl_findFreeHandle( const OUString
& _rPropertyName
);
109 inline ::comphelper::OPropertyArrayAggregationHelper
& PropertyBagHelper::getInfoHelper() const
111 return impl_ts_getArrayHelper();
115 inline void PropertyBagHelper::getDynamicFastPropertyValue( sal_Int32 _nHandle
, css::uno::Any
& _out_rValue
) const
117 m_aDynamicProperties
.getFastPropertyValue( _nHandle
, _out_rValue
);
121 inline bool PropertyBagHelper::convertDynamicFastPropertyValue( sal_Int32 _nHandle
, const css::uno::Any
& _rNewValue
, css::uno::Any
& _out_rConvertedValue
, css::uno::Any
& _out_rCurrentValue
) const
123 return m_aDynamicProperties
.convertFastPropertyValue( _nHandle
, _rNewValue
, _out_rConvertedValue
, _out_rCurrentValue
);
127 inline void PropertyBagHelper::setDynamicFastPropertyValue( sal_Int32 _nHandle
, const css::uno::Any
& _rValue
)
129 m_aDynamicProperties
.setFastPropertyValue( _nHandle
, _rValue
);
133 inline void PropertyBagHelper::getDynamicPropertyDefaultByHandle( sal_Int32 _nHandle
, css::uno::Any
& _out_rValue
) const
135 m_aDynamicProperties
.getPropertyDefaultByHandle( _nHandle
, _out_rValue
);
138 inline bool PropertyBagHelper::hasDynamicPropertyByHandle( sal_Int32 _nHandle
) const
140 return m_aDynamicProperties
.hasPropertyByHandle( _nHandle
);
147 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */