1*2d785d7eSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*2d785d7eSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2d785d7eSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2d785d7eSAndrew Rist * distributed with this work for additional information 6*2d785d7eSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2d785d7eSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2d785d7eSAndrew Rist * "License"); you may not use this file except in compliance 9*2d785d7eSAndrew Rist * with the License. You may obtain a copy of the License at 10*2d785d7eSAndrew Rist * 11*2d785d7eSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*2d785d7eSAndrew Rist * 13*2d785d7eSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2d785d7eSAndrew Rist * software distributed under the License is distributed on an 15*2d785d7eSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2d785d7eSAndrew Rist * KIND, either express or implied. See the License for the 17*2d785d7eSAndrew Rist * specific language governing permissions and limitations 18*2d785d7eSAndrew Rist * under the License. 19*2d785d7eSAndrew Rist * 20*2d785d7eSAndrew Rist *************************************************************/ 21*2d785d7eSAndrew Rist 22*2d785d7eSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _FRM_PROPERTY_HXX_ 25cdf0e10cSrcweir #define _FRM_PROPERTY_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <com/sun/star/uno/XAggregation.hpp> 28cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyState.hpp> 29cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp> 30cdf0e10cSrcweir #include <cppuhelper/propshlp.hxx> 31cdf0e10cSrcweir #include <cppuhelper/proptypehlp.hxx> 32cdf0e10cSrcweir #include <comphelper/property.hxx> 33cdf0e10cSrcweir #include <comphelper/propagg.hxx> 34cdf0e10cSrcweir #include <comphelper/stl_types.hxx> 35cdf0e10cSrcweir 36cdf0e10cSrcweir using namespace comphelper; 37cdf0e10cSrcweir 38cdf0e10cSrcweir //========================================================================= 39cdf0e10cSrcweir //= property helper classes 40cdf0e10cSrcweir //========================================================================= 41cdf0e10cSrcweir 42cdf0e10cSrcweir //... namespace frm ....................................................... 43cdf0e10cSrcweir namespace frm 44cdf0e10cSrcweir { 45cdf0e10cSrcweir //......................................................................... 46cdf0e10cSrcweir 47cdf0e10cSrcweir //================================================================== 48cdf0e10cSrcweir //= assigment property handle <-> property name 49cdf0e10cSrcweir //= used by the PropertySetAggregationHelper 50cdf0e10cSrcweir //================================================================== 51cdf0e10cSrcweir 52cdf0e10cSrcweir class PropertyInfoService 53cdf0e10cSrcweir { 54cdf0e10cSrcweir //.................................................................. 55cdf0e10cSrcweir struct PropertyAssignment 56cdf0e10cSrcweir { 57cdf0e10cSrcweir ::rtl::OUString sName; 58cdf0e10cSrcweir sal_Int32 nHandle; 59cdf0e10cSrcweir 60cdf0e10cSrcweir PropertyAssignment() { nHandle = -1; } 61cdf0e10cSrcweir PropertyAssignment(const PropertyAssignment& _rSource) 62cdf0e10cSrcweir :sName(_rSource.sName), nHandle(_rSource.nHandle) { } 63cdf0e10cSrcweir PropertyAssignment(const ::rtl::OUString& _rName, sal_Int32 _nHandle) 64cdf0e10cSrcweir :sName(_rName), nHandle(_nHandle) { } 65cdf0e10cSrcweir 66cdf0e10cSrcweir }; 67cdf0e10cSrcweir 68cdf0e10cSrcweir DECLARE_STL_VECTOR(PropertyAssignment, PropertyMap); 69cdf0e10cSrcweir static PropertyMap s_AllKnownProperties; 70cdf0e10cSrcweir 71cdf0e10cSrcweir //.................................................................. 72cdf0e10cSrcweir // comparing two PropertyAssignment's 73cdf0e10cSrcweir public: 74cdf0e10cSrcweir typedef PropertyAssignment PUBLIC_SOLARIS_COMPILER_HACK; 75cdf0e10cSrcweir // did not get the following compiled under with SUNPRO 5 without this 76cdf0e10cSrcweir // public typedef 77cdf0e10cSrcweir private: 78cdf0e10cSrcweir friend struct PropertyAssignmentNameCompareLess; 79cdf0e10cSrcweir typedef ::std::binary_function< PUBLIC_SOLARIS_COMPILER_HACK, PUBLIC_SOLARIS_COMPILER_HACK, sal_Bool > PropertyAssignmentNameCompareLess_Base; 80cdf0e10cSrcweir struct PropertyAssignmentNameCompareLess : public PropertyAssignmentNameCompareLess_Base 81cdf0e10cSrcweir { 82cdf0e10cSrcweir inline sal_Bool operator() (const PUBLIC_SOLARIS_COMPILER_HACK& _rL, const PUBLIC_SOLARIS_COMPILER_HACK& _rR) const 83cdf0e10cSrcweir { 84cdf0e10cSrcweir return (_rL.sName.compareTo(_rR.sName) < 0); 85cdf0e10cSrcweir } 86cdf0e10cSrcweir }; 87cdf0e10cSrcweir 88cdf0e10cSrcweir public: 89cdf0e10cSrcweir PropertyInfoService() { } 90cdf0e10cSrcweir 91cdf0e10cSrcweir public: 92cdf0e10cSrcweir static sal_Int32 getPropertyId(const ::rtl::OUString& _rName); 93cdf0e10cSrcweir static ::rtl::OUString getPropertyName(sal_Int32 _nHandle); 94cdf0e10cSrcweir 95cdf0e10cSrcweir private: 96cdf0e10cSrcweir static void initialize(); 97cdf0e10cSrcweir }; 98cdf0e10cSrcweir 99cdf0e10cSrcweir //.................................................................. 100cdf0e10cSrcweir // a class implementing the comphelper::IPropertyInfoService 101cdf0e10cSrcweir class ConcreteInfoService : public ::comphelper::IPropertyInfoService 102cdf0e10cSrcweir { 103cdf0e10cSrcweir public: 104cdf0e10cSrcweir virtual sal_Int32 getPreferedPropertyId(const ::rtl::OUString& _rName); 105cdf0e10cSrcweir }; 106cdf0e10cSrcweir 107cdf0e10cSrcweir //------------------------------------------------------------------------------ 108cdf0e10cSrcweir #define DECL_PROP_IMPL(varname, type) \ 109cdf0e10cSrcweir *pProperties++ = com::sun::star::beans::Property(PROPERTY_##varname, PROPERTY_ID_##varname, ::getCppuType(reinterpret_cast< type* >(NULL)), 110cdf0e10cSrcweir 111cdf0e10cSrcweir //------------------------------------------------------------------------------ 112cdf0e10cSrcweir #define DECL_BOOL_PROP_IMPL(varname) \ 113cdf0e10cSrcweir *pProperties++ = com::sun::star::beans::Property(PROPERTY_##varname, PROPERTY_ID_##varname, ::getBooleanCppuType(), 114cdf0e10cSrcweir 115cdf0e10cSrcweir //------------------------------------------------------------------------------ 116cdf0e10cSrcweir #define DECL_IFACE_PROP_IMPL(varname, type) \ 117cdf0e10cSrcweir *pProperties++ = com::sun::star::beans::Property(PROPERTY_##varname, PROPERTY_ID_##varname, ::getCppuType(reinterpret_cast< com::sun::star::uno::Reference< type >* >(NULL)), 118cdf0e10cSrcweir 119cdf0e10cSrcweir //------------------------------------------------------------------------------ 120cdf0e10cSrcweir #define BEGIN_DESCRIBE_PROPERTIES( count, baseclass ) \ 121cdf0e10cSrcweir baseclass::describeFixedProperties( _rProps ); \ 122cdf0e10cSrcweir sal_Int32 nOldCount = _rProps.getLength(); \ 123cdf0e10cSrcweir _rProps.realloc( nOldCount + ( count ) ); \ 124cdf0e10cSrcweir ::com::sun::star::beans::Property* pProperties = _rProps.getArray() + nOldCount; \ 125cdf0e10cSrcweir 126cdf0e10cSrcweir //------------------------------------------------------------------------------ 127cdf0e10cSrcweir #define BEGIN_DESCRIBE_BASE_PROPERTIES( count ) \ 128cdf0e10cSrcweir _rProps.realloc( count ); \ 129cdf0e10cSrcweir ::com::sun::star::beans::Property* pProperties = _rProps.getArray(); \ 130cdf0e10cSrcweir 131cdf0e10cSrcweir //------------------------------------------------------------------------------ 132cdf0e10cSrcweir #define BEGIN_DESCRIBE_AGGREGATION_PROPERTIES( count, aggregate ) \ 133cdf0e10cSrcweir _rProps.realloc( count ); \ 134cdf0e10cSrcweir ::com::sun::star::beans::Property* pProperties = _rProps.getArray(); \ 135cdf0e10cSrcweir \ 136cdf0e10cSrcweir if (aggregate.is()) \ 137cdf0e10cSrcweir _rAggregateProps = aggregate->getPropertySetInfo()->getProperties(); \ 138cdf0e10cSrcweir 139cdf0e10cSrcweir // === 140cdf0e10cSrcweir //------------------------------------------------------------------------------ 141cdf0e10cSrcweir #define DECL_PROP0(varname, type) \ 142cdf0e10cSrcweir DECL_PROP_IMPL(varname, type) 0) 143cdf0e10cSrcweir 144cdf0e10cSrcweir //------------------------------------------------------------------------------ 145cdf0e10cSrcweir #define DECL_PROP1(varname, type, attrib1) \ 146cdf0e10cSrcweir DECL_PROP_IMPL(varname, type) com::sun::star::beans::PropertyAttribute::attrib1) 147cdf0e10cSrcweir 148cdf0e10cSrcweir //------------------------------------------------------------------------------ 149cdf0e10cSrcweir #define DECL_PROP2(varname, type, attrib1, attrib2) \ 150cdf0e10cSrcweir DECL_PROP_IMPL(varname, type) com::sun::star::beans::PropertyAttribute::attrib1 | com::sun::star::beans::PropertyAttribute::attrib2) 151cdf0e10cSrcweir 152cdf0e10cSrcweir //------------------------------------------------------------------------------ 153cdf0e10cSrcweir #define DECL_PROP3(varname, type, attrib1, attrib2, attrib3) \ 154cdf0e10cSrcweir DECL_PROP_IMPL(varname, type) com::sun::star::beans::PropertyAttribute::attrib1 | com::sun::star::beans::PropertyAttribute::attrib2 | com::sun::star::beans::PropertyAttribute::attrib3) 155cdf0e10cSrcweir 156cdf0e10cSrcweir //------------------------------------------------------------------------------ 157cdf0e10cSrcweir #define DECL_PROP4(varname, type, attrib1, attrib2, attrib3, attrib4) \ 158cdf0e10cSrcweir DECL_PROP_IMPL(varname, type) com::sun::star::beans::PropertyAttribute::attrib1 | com::sun::star::beans::PropertyAttribute::attrib2 | com::sun::star::beans::PropertyAttribute::attrib3 | com::sun::star::beans::PropertyAttribute::attrib4) 159cdf0e10cSrcweir 160cdf0e10cSrcweir // === some property types require special handling 161cdf0e10cSrcweir // === such as interfaces 162cdf0e10cSrcweir //------------------------------------------------------------------------------ 163cdf0e10cSrcweir #define DECL_IFACE_PROP0(varname, type) \ 164cdf0e10cSrcweir DECL_IFACE_PROP_IMPL(varname, type) 0) 165cdf0e10cSrcweir 166cdf0e10cSrcweir //------------------------------------------------------------------------------ 167cdf0e10cSrcweir #define DECL_IFACE_PROP1(varname, type, attrib1) \ 168cdf0e10cSrcweir DECL_IFACE_PROP_IMPL(varname, type) starbeans::PropertyAttribute::attrib1) 169cdf0e10cSrcweir 170cdf0e10cSrcweir //------------------------------------------------------------------------------ 171cdf0e10cSrcweir #define DECL_IFACE_PROP2(varname, type, attrib1, attrib2) \ 172cdf0e10cSrcweir DECL_IFACE_PROP_IMPL(varname, type) com::sun::star::beans::PropertyAttribute::attrib1 | com::sun::star::beans::PropertyAttribute::attrib2) 173cdf0e10cSrcweir 174cdf0e10cSrcweir //------------------------------------------------------------------------------ 175cdf0e10cSrcweir #define DECL_IFACE_PROP3(varname, type, attrib1, attrib2, attrib3) \ 176cdf0e10cSrcweir DECL_IFACE_PROP_IMPL(varname, type) starbeans::PropertyAttribute::attrib1 | starbeans::PropertyAttribute::attrib2 | starbeans::PropertyAttribute::attrib3) 177cdf0e10cSrcweir 178cdf0e10cSrcweir //------------------------------------------------------------------------------ 179cdf0e10cSrcweir #define DECL_IFACE_PROP4(varname, type, attrib1, attrib2, attrib3, attrib4) \ 180cdf0e10cSrcweir DECL_IFACE_PROP_IMPL(varname, type) starbeans::PropertyAttribute::attrib1 | starbeans::PropertyAttribute::attrib2 | starbeans::PropertyAttribute::attrib3 | PropertyAttribute::attrib4) 181cdf0e10cSrcweir 182cdf0e10cSrcweir // === or Boolean properties 183cdf0e10cSrcweir //------------------------------------------------------------------------------ 184cdf0e10cSrcweir #define DECL_BOOL_PROP0(varname) \ 185cdf0e10cSrcweir DECL_BOOL_PROP_IMPL(varname) 0) 186cdf0e10cSrcweir 187cdf0e10cSrcweir //------------------------------------------------------------------------------ 188cdf0e10cSrcweir #define DECL_BOOL_PROP1(varname, attrib1) \ 189cdf0e10cSrcweir DECL_BOOL_PROP_IMPL(varname) com::sun::star::beans::PropertyAttribute::attrib1) 190cdf0e10cSrcweir 191cdf0e10cSrcweir //------------------------------------------------------------------------------ 192cdf0e10cSrcweir #define DECL_BOOL_PROP2(varname, attrib1, attrib2) \ 193cdf0e10cSrcweir DECL_BOOL_PROP_IMPL(varname) com::sun::star::beans::PropertyAttribute::attrib1 | com::sun::star::beans::PropertyAttribute::attrib2) 194cdf0e10cSrcweir 195cdf0e10cSrcweir //------------------------------------------------------------------------------ 196cdf0e10cSrcweir #define DECL_BOOL_PROP3( varname, attrib1, attrib2, attrib3 ) \ 197cdf0e10cSrcweir DECL_BOOL_PROP_IMPL(varname) com::sun::star::beans::PropertyAttribute::attrib1 | com::sun::star::beans::PropertyAttribute::attrib2 | com::sun::star::beans::PropertyAttribute::attrib3 ) 198cdf0e10cSrcweir 199cdf0e10cSrcweir // === 200cdf0e10cSrcweir //------------------------------------------------------------------------------ 201cdf0e10cSrcweir #define END_DESCRIBE_PROPERTIES() \ 202cdf0e10cSrcweir DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(), "<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?"); \ 203cdf0e10cSrcweir 204cdf0e10cSrcweir //============================================================================== 205cdf0e10cSrcweir //------------------------------------------------------------------------------ 206cdf0e10cSrcweir #define REGISTER_PROP_1( prop, member, attrib1 ) \ 207cdf0e10cSrcweir registerProperty( PROPERTY_##prop, PROPERTY_ID_##prop, PropertyAttribute::attrib1, \ 208cdf0e10cSrcweir &member, ::getCppuType( &member ) ); 209cdf0e10cSrcweir 210cdf0e10cSrcweir #define REGISTER_PROP_2( prop, member, attrib1, attrib2 ) \ 211cdf0e10cSrcweir registerProperty( PROPERTY_##prop, PROPERTY_ID_##prop, PropertyAttribute::attrib1 | PropertyAttribute::attrib2, \ 212cdf0e10cSrcweir &member, ::getCppuType( &member ) ); 213cdf0e10cSrcweir 214cdf0e10cSrcweir #define REGISTER_PROP_3( prop, member, attrib1, attrib2, attrib3 ) \ 215cdf0e10cSrcweir registerProperty( PROPERTY_##prop, PROPERTY_ID_##prop, PropertyAttribute::attrib1 | PropertyAttribute::attrib2 | PropertyAttribute::attrib3, \ 216cdf0e10cSrcweir &member, ::getCppuType( &member ) ); 217cdf0e10cSrcweir 218cdf0e10cSrcweir //------------------------------------------------------------------------------ 219cdf0e10cSrcweir #define REGISTER_VOID_PROP_1( prop, memberAny, type, attrib1 ) \ 220cdf0e10cSrcweir registerMayBeVoidProperty( PROPERTY_##prop, PROPERTY_ID_##prop, PropertyAttribute::MAYBEVOID | PropertyAttribute::attrib1, \ 221cdf0e10cSrcweir &memberAny, ::getCppuType( static_cast< type* >( NULL ) ) ); 222cdf0e10cSrcweir 223cdf0e10cSrcweir #define REGISTER_VOID_PROP_2( prop, memberAny, type, attrib1, attrib2 ) \ 224cdf0e10cSrcweir registerMayBeVoidProperty( PROPERTY_##prop, PROPERTY_ID_##prop, PropertyAttribute::MAYBEVOID | PropertyAttribute::attrib1 | PropertyAttribute::attrib2, \ 225cdf0e10cSrcweir &memberAny, ::getCppuType( static_cast< type* >( NULL ) ) ); 226cdf0e10cSrcweir 227cdf0e10cSrcweir //......................................................................... 228cdf0e10cSrcweir } 229cdf0e10cSrcweir //... namespace frm ....................................................... 230cdf0e10cSrcweir 231cdf0e10cSrcweir #endif // _FRM_PROPERTY_HXX_ 232cdf0e10cSrcweir 233