1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: propertybaghelper.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef FORMS_PROPERTYBAGHELPER_HXX
32 #define FORMS_PROPERTYBAGHELPER_HXX
34 /** === begin UNO includes === **/
35 #include <com/sun/star/beans/PropertyValue.hpp>
36 /** === end UNO includes === **/
38 #include <comphelper/propertybag.hxx>
39 #include <comphelper/propagg.hxx>
41 #include <boost/noncopyable.hpp>
43 //........................................................................
46 //........................................................................
48 //====================================================================
49 //= class IPropertyBagHelperContext
50 //====================================================================
51 class SAL_NO_VTABLE IPropertyBagHelperContext
54 virtual ::osl::Mutex
& getMutex() = 0;
56 virtual void describeFixedAndAggregateProperties(
57 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::Property
>& _out_rFixedProperties
,
58 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::Property
>& _out_rAggregateProperties
61 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XMultiPropertySet
>
62 getPropertiesInterface() = 0;
65 //====================================================================
66 //= class PropertyBagHelper
67 //====================================================================
68 class PropertyBagHelper
: public ::boost::noncopyable
71 IPropertyBagHelperContext
& m_rContext
;
72 ::comphelper::OPropertyArrayAggregationHelper
* m_pPropertyArrayHelper
;
73 ::comphelper::PropertyBag m_aDynamicProperties
;
77 PropertyBagHelper( IPropertyBagHelperContext
& _rContext
);
80 // XComponent equivalent
83 // OPropertySetHelper equivalent
84 inline ::comphelper::OPropertyArrayAggregationHelper
& getInfoHelper() const;
86 // XPropertyContainer equivalent
87 void addProperty( const ::rtl::OUString
& _rName
, ::sal_Int16 _nAttributes
, const ::com::sun::star::uno::Any
& _rInitialValue
);
88 void removeProperty( const ::rtl::OUString
& _rName
);
90 // XPropertyAccess equivalent
91 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
> SAL_CALL
getPropertyValues();
92 void setPropertyValues( const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& _rProps
);
94 // forwards to m_aDynamicProperties
95 inline void getDynamicFastPropertyValue( sal_Int32 _nHandle
, ::com::sun::star::uno::Any
& _out_rValue
) const;
96 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;
97 inline void setDynamicFastPropertyValue( sal_Int32 _nHandle
, const ::com::sun::star::uno::Any
& _rValue
);
98 inline void getDynamicPropertyDefaultByHandle( sal_Int32 _nHandle
, ::com::sun::star::uno::Any
& _out_rValue
) const;
99 inline bool hasDynamicPropertyByName( const ::rtl::OUString
& _rName
) const;
100 inline bool hasDynamicPropertyByHandle( sal_Int32 _nHandle
) const;
103 void impl_nts_checkDisposed_throw() const;
105 /** invalidates our property set info, so subsequent calls to impl_ts_getArrayHelper and thus
106 getInfoHelper will return a newly created instance
108 void impl_nts_invalidatePropertySetInfo();
110 /** returns the IPropertyArrayHelper instance used by |this|
112 ::comphelper::OPropertyArrayAggregationHelper
& impl_ts_getArrayHelper() const;
114 /** finds a free property handle
115 @param _rPropertyName
116 the name of the property to find a handle for. If possible, the handle as determined by
117 our ConcreteInfoService instance will be used
119 sal_Int32
impl_findFreeHandle( const ::rtl::OUString
& _rPropertyName
);
122 //--------------------------------------------------------------------
123 inline ::comphelper::OPropertyArrayAggregationHelper
& PropertyBagHelper::getInfoHelper() const
125 return impl_ts_getArrayHelper();
128 //--------------------------------------------------------------------
129 inline void PropertyBagHelper::getDynamicFastPropertyValue( sal_Int32 _nHandle
, ::com::sun::star::uno::Any
& _out_rValue
) const
131 m_aDynamicProperties
.getFastPropertyValue( _nHandle
, _out_rValue
);
134 //--------------------------------------------------------------------
135 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
137 return m_aDynamicProperties
.convertFastPropertyValue( _nHandle
, _rNewValue
, _out_rConvertedValue
, _out_rCurrentValue
);
140 //--------------------------------------------------------------------
141 inline void PropertyBagHelper::setDynamicFastPropertyValue( sal_Int32 _nHandle
, const ::com::sun::star::uno::Any
& _rValue
)
143 m_aDynamicProperties
.setFastPropertyValue( _nHandle
, _rValue
);
146 //--------------------------------------------------------------------
147 inline void PropertyBagHelper::getDynamicPropertyDefaultByHandle( sal_Int32 _nHandle
, ::com::sun::star::uno::Any
& _out_rValue
) const
149 m_aDynamicProperties
.getPropertyDefaultByHandle( _nHandle
, _out_rValue
);
152 //--------------------------------------------------------------------
153 inline bool PropertyBagHelper::hasDynamicPropertyByName( const ::rtl::OUString
& _rName
) const
155 return m_aDynamicProperties
.hasPropertyByName( _rName
);
158 //--------------------------------------------------------------------
159 inline bool PropertyBagHelper::hasDynamicPropertyByHandle( sal_Int32 _nHandle
) const
161 return m_aDynamicProperties
.hasPropertyByHandle( _nHandle
);
164 //........................................................................
166 //........................................................................
168 #endif // FORMS_PROPERTYBAGHELPER_HXX