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 FORMS_PROPERTYBAGHELPER_HXX
21 #define FORMS_PROPERTYBAGHELPER_HXX
23 #include <com/sun/star/beans/PropertyValue.hpp>
25 #include <comphelper/propertybag.hxx>
26 #include <comphelper/propagg.hxx>
28 #include <boost/noncopyable.hpp>
30 //........................................................................
33 //........................................................................
35 //====================================================================
36 //= class IPropertyBagHelperContext
37 //====================================================================
38 class SAL_NO_VTABLE IPropertyBagHelperContext
41 virtual ::osl::Mutex
& getMutex() = 0;
43 virtual void describeFixedAndAggregateProperties(
44 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::Property
>& _out_rFixedProperties
,
45 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::Property
>& _out_rAggregateProperties
48 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XMultiPropertySet
>
49 getPropertiesInterface() = 0;
52 ~IPropertyBagHelperContext() {}
55 //====================================================================
56 //= class PropertyBagHelper
57 //====================================================================
58 class PropertyBagHelper
: public ::boost::noncopyable
61 IPropertyBagHelperContext
& m_rContext
;
62 ::comphelper::OPropertyArrayAggregationHelper
* m_pPropertyArrayHelper
;
63 ::comphelper::PropertyBag m_aDynamicProperties
;
67 PropertyBagHelper( IPropertyBagHelperContext
& _rContext
);
70 // XComponent equivalent
73 // OPropertySetHelper equivalent
74 inline ::comphelper::OPropertyArrayAggregationHelper
& getInfoHelper() const;
76 // XPropertyContainer equivalent
77 void addProperty( const OUString
& _rName
, ::sal_Int16 _nAttributes
, const ::com::sun::star::uno::Any
& _rInitialValue
);
78 void removeProperty( const OUString
& _rName
);
80 // XPropertyAccess equivalent
81 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
> SAL_CALL
getPropertyValues();
82 void setPropertyValues( const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& _rProps
);
84 // forwards to m_aDynamicProperties
85 inline void getDynamicFastPropertyValue( sal_Int32 _nHandle
, ::com::sun::star::uno::Any
& _out_rValue
) const;
86 inline bool convertDynamicFastPropertyValue( sal_Int32 _nHandle
, const ::com::sun::star::uno::Any
& _rNewValue
, ::com::sun::star::uno::Any
& _out_rConvertedValue
, ::com::sun::star::uno::Any
& _out_rCurrentValue
) const;
87 inline void setDynamicFastPropertyValue( sal_Int32 _nHandle
, const ::com::sun::star::uno::Any
& _rValue
);
88 inline void getDynamicPropertyDefaultByHandle( sal_Int32 _nHandle
, ::com::sun::star::uno::Any
& _out_rValue
) const;
89 inline bool hasDynamicPropertyByName( const OUString
& _rName
) const;
90 inline bool hasDynamicPropertyByHandle( sal_Int32 _nHandle
) const;
93 void impl_nts_checkDisposed_throw() const;
95 /** invalidates our property set info, so subsequent calls to impl_ts_getArrayHelper and thus
96 getInfoHelper will return a newly created instance
98 void impl_nts_invalidatePropertySetInfo();
100 /** returns the IPropertyArrayHelper instance used by |this|
102 ::comphelper::OPropertyArrayAggregationHelper
& impl_ts_getArrayHelper() const;
104 /** finds a free property handle
105 @param _rPropertyName
106 the name of the property to find a handle for. If possible, the handle as determined by
107 our ConcreteInfoService instance will be used
109 sal_Int32
impl_findFreeHandle( const OUString
& _rPropertyName
);
112 //--------------------------------------------------------------------
113 inline ::comphelper::OPropertyArrayAggregationHelper
& PropertyBagHelper::getInfoHelper() const
115 return impl_ts_getArrayHelper();
118 //--------------------------------------------------------------------
119 inline void PropertyBagHelper::getDynamicFastPropertyValue( sal_Int32 _nHandle
, ::com::sun::star::uno::Any
& _out_rValue
) const
121 m_aDynamicProperties
.getFastPropertyValue( _nHandle
, _out_rValue
);
124 //--------------------------------------------------------------------
125 inline bool PropertyBagHelper::convertDynamicFastPropertyValue( sal_Int32 _nHandle
, const ::com::sun::star::uno::Any
& _rNewValue
, ::com::sun::star::uno::Any
& _out_rConvertedValue
, ::com::sun::star::uno::Any
& _out_rCurrentValue
) const
127 return m_aDynamicProperties
.convertFastPropertyValue( _nHandle
, _rNewValue
, _out_rConvertedValue
, _out_rCurrentValue
);
130 //--------------------------------------------------------------------
131 inline void PropertyBagHelper::setDynamicFastPropertyValue( sal_Int32 _nHandle
, const ::com::sun::star::uno::Any
& _rValue
)
133 m_aDynamicProperties
.setFastPropertyValue( _nHandle
, _rValue
);
136 //--------------------------------------------------------------------
137 inline void PropertyBagHelper::getDynamicPropertyDefaultByHandle( sal_Int32 _nHandle
, ::com::sun::star::uno::Any
& _out_rValue
) const
139 m_aDynamicProperties
.getPropertyDefaultByHandle( _nHandle
, _out_rValue
);
142 //--------------------------------------------------------------------
143 inline bool PropertyBagHelper::hasDynamicPropertyByName( const OUString
& _rName
) const
145 return m_aDynamicProperties
.hasPropertyByName( _rName
);
148 //--------------------------------------------------------------------
149 inline bool PropertyBagHelper::hasDynamicPropertyByHandle( sal_Int32 _nHandle
) const
151 return m_aDynamicProperties
.hasPropertyByHandle( _nHandle
);
154 //........................................................................
156 //........................................................................
158 #endif // FORMS_PROPERTYBAGHELPER_HXX
160 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */