1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #ifndef FORMS_PROPERTYBAGHELPER_HXX 29*cdf0e10cSrcweir #define FORMS_PROPERTYBAGHELPER_HXX 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir /** === begin UNO includes === **/ 32*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp> 33*cdf0e10cSrcweir /** === end UNO includes === **/ 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #include <comphelper/propertybag.hxx> 36*cdf0e10cSrcweir #include <comphelper/propagg.hxx> 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir #include <boost/noncopyable.hpp> 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir //........................................................................ 41*cdf0e10cSrcweir namespace frm 42*cdf0e10cSrcweir { 43*cdf0e10cSrcweir //........................................................................ 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir //==================================================================== 46*cdf0e10cSrcweir //= class IPropertyBagHelperContext 47*cdf0e10cSrcweir //==================================================================== 48*cdf0e10cSrcweir class SAL_NO_VTABLE IPropertyBagHelperContext 49*cdf0e10cSrcweir { 50*cdf0e10cSrcweir public: 51*cdf0e10cSrcweir virtual ::osl::Mutex& getMutex() = 0; 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir virtual void describeFixedAndAggregateProperties( 54*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& _out_rFixedProperties, 55*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& _out_rAggregateProperties 56*cdf0e10cSrcweir ) const = 0; 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XMultiPropertySet > 59*cdf0e10cSrcweir getPropertiesInterface() = 0; 60*cdf0e10cSrcweir }; 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir //==================================================================== 63*cdf0e10cSrcweir //= class PropertyBagHelper 64*cdf0e10cSrcweir //==================================================================== 65*cdf0e10cSrcweir class PropertyBagHelper : public ::boost::noncopyable 66*cdf0e10cSrcweir { 67*cdf0e10cSrcweir private: 68*cdf0e10cSrcweir IPropertyBagHelperContext& m_rContext; 69*cdf0e10cSrcweir ::comphelper::OPropertyArrayAggregationHelper* m_pPropertyArrayHelper; 70*cdf0e10cSrcweir ::comphelper::PropertyBag m_aDynamicProperties; 71*cdf0e10cSrcweir bool m_bDisposed; 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir public: 74*cdf0e10cSrcweir PropertyBagHelper( IPropertyBagHelperContext& _rContext ); 75*cdf0e10cSrcweir ~PropertyBagHelper(); 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir // XComponent equivalent 78*cdf0e10cSrcweir void dispose(); 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir // OPropertySetHelper equivalent 81*cdf0e10cSrcweir inline ::comphelper::OPropertyArrayAggregationHelper& getInfoHelper() const; 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir // XPropertyContainer equivalent 84*cdf0e10cSrcweir void addProperty( const ::rtl::OUString& _rName, ::sal_Int16 _nAttributes, const ::com::sun::star::uno::Any& _rInitialValue ); 85*cdf0e10cSrcweir void removeProperty( const ::rtl::OUString& _rName ); 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir // XPropertyAccess equivalent 88*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getPropertyValues(); 89*cdf0e10cSrcweir void setPropertyValues( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rProps ); 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir // forwards to m_aDynamicProperties 92*cdf0e10cSrcweir inline void getDynamicFastPropertyValue( sal_Int32 _nHandle, ::com::sun::star::uno::Any& _out_rValue ) const; 93*cdf0e10cSrcweir 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; 94*cdf0e10cSrcweir inline void setDynamicFastPropertyValue( sal_Int32 _nHandle, const ::com::sun::star::uno::Any& _rValue ); 95*cdf0e10cSrcweir inline void getDynamicPropertyDefaultByHandle( sal_Int32 _nHandle, ::com::sun::star::uno::Any& _out_rValue ) const; 96*cdf0e10cSrcweir inline bool hasDynamicPropertyByName( const ::rtl::OUString& _rName ) const; 97*cdf0e10cSrcweir inline bool hasDynamicPropertyByHandle( sal_Int32 _nHandle ) const; 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir private: 100*cdf0e10cSrcweir void impl_nts_checkDisposed_throw() const; 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir /** invalidates our property set info, so subsequent calls to impl_ts_getArrayHelper and thus 103*cdf0e10cSrcweir getInfoHelper will return a newly created instance 104*cdf0e10cSrcweir */ 105*cdf0e10cSrcweir void impl_nts_invalidatePropertySetInfo(); 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir /** returns the IPropertyArrayHelper instance used by |this| 108*cdf0e10cSrcweir */ 109*cdf0e10cSrcweir ::comphelper::OPropertyArrayAggregationHelper& impl_ts_getArrayHelper() const; 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir /** finds a free property handle 112*cdf0e10cSrcweir @param _rPropertyName 113*cdf0e10cSrcweir the name of the property to find a handle for. If possible, the handle as determined by 114*cdf0e10cSrcweir our ConcreteInfoService instance will be used 115*cdf0e10cSrcweir */ 116*cdf0e10cSrcweir sal_Int32 impl_findFreeHandle( const ::rtl::OUString& _rPropertyName ); 117*cdf0e10cSrcweir }; 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir //-------------------------------------------------------------------- 120*cdf0e10cSrcweir inline ::comphelper::OPropertyArrayAggregationHelper& PropertyBagHelper::getInfoHelper() const 121*cdf0e10cSrcweir { 122*cdf0e10cSrcweir return impl_ts_getArrayHelper(); 123*cdf0e10cSrcweir } 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir //-------------------------------------------------------------------- 126*cdf0e10cSrcweir inline void PropertyBagHelper::getDynamicFastPropertyValue( sal_Int32 _nHandle, ::com::sun::star::uno::Any& _out_rValue ) const 127*cdf0e10cSrcweir { 128*cdf0e10cSrcweir m_aDynamicProperties.getFastPropertyValue( _nHandle, _out_rValue ); 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir //-------------------------------------------------------------------- 132*cdf0e10cSrcweir 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 133*cdf0e10cSrcweir { 134*cdf0e10cSrcweir return m_aDynamicProperties.convertFastPropertyValue( _nHandle, _rNewValue, _out_rConvertedValue, _out_rCurrentValue ); 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir //-------------------------------------------------------------------- 138*cdf0e10cSrcweir inline void PropertyBagHelper::setDynamicFastPropertyValue( sal_Int32 _nHandle, const ::com::sun::star::uno::Any& _rValue ) 139*cdf0e10cSrcweir { 140*cdf0e10cSrcweir m_aDynamicProperties.setFastPropertyValue( _nHandle, _rValue ); 141*cdf0e10cSrcweir } 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir //-------------------------------------------------------------------- 144*cdf0e10cSrcweir inline void PropertyBagHelper::getDynamicPropertyDefaultByHandle( sal_Int32 _nHandle, ::com::sun::star::uno::Any& _out_rValue ) const 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir m_aDynamicProperties.getPropertyDefaultByHandle( _nHandle, _out_rValue ); 147*cdf0e10cSrcweir } 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir //-------------------------------------------------------------------- 150*cdf0e10cSrcweir inline bool PropertyBagHelper::hasDynamicPropertyByName( const ::rtl::OUString& _rName ) const 151*cdf0e10cSrcweir { 152*cdf0e10cSrcweir return m_aDynamicProperties.hasPropertyByName( _rName ); 153*cdf0e10cSrcweir } 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir //-------------------------------------------------------------------- 156*cdf0e10cSrcweir inline bool PropertyBagHelper::hasDynamicPropertyByHandle( sal_Int32 _nHandle ) const 157*cdf0e10cSrcweir { 158*cdf0e10cSrcweir return m_aDynamicProperties.hasPropertyByHandle( _nHandle ); 159*cdf0e10cSrcweir } 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir //........................................................................ 162*cdf0e10cSrcweir } // namespace frm 163*cdf0e10cSrcweir //........................................................................ 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir #endif // FORMS_PROPERTYBAGHELPER_HXX 166*cdf0e10cSrcweir 167