Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _FRM_PROPERTY_HXX_
30 : : #define _FRM_PROPERTY_HXX_
31 : :
32 : : #include <com/sun/star/uno/XAggregation.hpp>
33 : : #include <com/sun/star/beans/XPropertyState.hpp>
34 : : #include <com/sun/star/beans/PropertyAttribute.hpp>
35 : : #include <cppuhelper/propshlp.hxx>
36 : : #include <cppuhelper/proptypehlp.hxx>
37 : : #include <comphelper/property.hxx>
38 : : #include <comphelper/propagg.hxx>
39 : : #include <comphelper/stl_types.hxx>
40 : :
41 : : using namespace comphelper;
42 : :
43 : : //=========================================================================
44 : : //= property helper classes
45 : : //=========================================================================
46 : :
47 : : //... namespace frm .......................................................
48 : : namespace frm
49 : : {
50 : : //.........................................................................
51 : :
52 : : //==================================================================
53 : : //= assigment property handle <-> property name
54 : : //= used by the PropertySetAggregationHelper
55 : : //==================================================================
56 : :
57 : : class PropertyInfoService
58 : : {
59 : : //..................................................................
60 : 114841 : struct PropertyAssignment
61 : : {
62 : : ::rtl::OUString sName;
63 : : sal_Int32 nHandle;
64 : :
65 : : PropertyAssignment() { nHandle = -1; }
66 : 14752 : PropertyAssignment(const PropertyAssignment& _rSource)
67 : 14752 : :sName(_rSource.sName), nHandle(_rSource.nHandle) { }
68 : 70169 : PropertyAssignment(const ::rtl::OUString& _rName, sal_Int32 _nHandle)
69 : 70169 : :sName(_rName), nHandle(_nHandle) { }
70 : :
71 : : };
72 : :
73 : : DECLARE_STL_VECTOR(PropertyAssignment, PropertyMap);
74 : : static PropertyMap s_AllKnownProperties;
75 : :
76 : : //..................................................................
77 : : // comparing two PropertyAssignment's
78 : : public:
79 : : typedef PropertyAssignment PUBLIC_SOLARIS_COMPILER_HACK;
80 : : // did not get the following compiled under with SUNPRO 5 without this
81 : : // public typedef
82 : : private:
83 : : friend struct PropertyAssignmentNameCompareLess;
84 : : typedef ::std::binary_function< PUBLIC_SOLARIS_COMPILER_HACK, PUBLIC_SOLARIS_COMPILER_HACK, sal_Bool > PropertyAssignmentNameCompareLess_Base;
85 : : struct PropertyAssignmentNameCompareLess : public PropertyAssignmentNameCompareLess_Base
86 : : {
87 : 799429 : inline sal_Bool operator() (const PUBLIC_SOLARIS_COMPILER_HACK& _rL, const PUBLIC_SOLARIS_COMPILER_HACK& _rR) const
88 : : {
89 : 799429 : return (_rL.sName.compareTo(_rR.sName) < 0);
90 : : }
91 : : };
92 : :
93 : : public:
94 : : PropertyInfoService() { }
95 : :
96 : : public:
97 : : static sal_Int32 getPropertyId(const ::rtl::OUString& _rName);
98 : : static ::rtl::OUString getPropertyName(sal_Int32 _nHandle);
99 : :
100 : : private:
101 : : static void initialize();
102 : : };
103 : :
104 : : //..................................................................
105 : : // a class implementing the comphelper::IPropertyInfoService
106 : : class ConcreteInfoService : public ::comphelper::IPropertyInfoService
107 : : {
108 : : public:
109 [ - + ]: 32 : virtual ~ConcreteInfoService() {}
110 : :
111 : : virtual sal_Int32 getPreferedPropertyId(const ::rtl::OUString& _rName);
112 : : };
113 : :
114 : : //------------------------------------------------------------------------------
115 : : #define DECL_PROP_IMPL(varname, type) \
116 : : *pProperties++ = com::sun::star::beans::Property(PROPERTY_##varname, PROPERTY_ID_##varname, ::getCppuType(static_cast< type* >(0)),
117 : :
118 : : //------------------------------------------------------------------------------
119 : : #define DECL_BOOL_PROP_IMPL(varname) \
120 : : *pProperties++ = com::sun::star::beans::Property(PROPERTY_##varname, PROPERTY_ID_##varname, ::getBooleanCppuType(),
121 : :
122 : : //------------------------------------------------------------------------------
123 : : #define DECL_IFACE_PROP_IMPL(varname, type) \
124 : : *pProperties++ = com::sun::star::beans::Property(PROPERTY_##varname, PROPERTY_ID_##varname, ::getCppuType(static_cast< com::sun::star::uno::Reference< type >* >(0)),
125 : :
126 : : //------------------------------------------------------------------------------
127 : : #define BEGIN_DESCRIBE_PROPERTIES( count, baseclass ) \
128 : : baseclass::describeFixedProperties( _rProps ); \
129 : : sal_Int32 nOldCount = _rProps.getLength(); \
130 : : _rProps.realloc( nOldCount + ( count ) ); \
131 : : ::com::sun::star::beans::Property* pProperties = _rProps.getArray() + nOldCount; \
132 : :
133 : : //------------------------------------------------------------------------------
134 : : #define BEGIN_DESCRIBE_BASE_PROPERTIES( count ) \
135 : : _rProps.realloc( count ); \
136 : : ::com::sun::star::beans::Property* pProperties = _rProps.getArray(); \
137 : :
138 : : //------------------------------------------------------------------------------
139 : : #define BEGIN_DESCRIBE_AGGREGATION_PROPERTIES( count, aggregate ) \
140 : : _rProps.realloc( count ); \
141 : : ::com::sun::star::beans::Property* pProperties = _rProps.getArray(); \
142 : : \
143 : : if (aggregate.is()) \
144 : : _rAggregateProps = aggregate->getPropertySetInfo()->getProperties(); \
145 : :
146 : : // ===
147 : : //------------------------------------------------------------------------------
148 : : #define DECL_PROP0(varname, type) \
149 : : DECL_PROP_IMPL(varname, type) 0)
150 : :
151 : : //------------------------------------------------------------------------------
152 : : #define DECL_PROP1(varname, type, attrib1) \
153 : : DECL_PROP_IMPL(varname, type) com::sun::star::beans::PropertyAttribute::attrib1)
154 : :
155 : : //------------------------------------------------------------------------------
156 : : #define DECL_PROP2(varname, type, attrib1, attrib2) \
157 : : DECL_PROP_IMPL(varname, type) com::sun::star::beans::PropertyAttribute::attrib1 | com::sun::star::beans::PropertyAttribute::attrib2)
158 : :
159 : : //------------------------------------------------------------------------------
160 : : #define DECL_PROP3(varname, type, attrib1, attrib2, attrib3) \
161 : : DECL_PROP_IMPL(varname, type) com::sun::star::beans::PropertyAttribute::attrib1 | com::sun::star::beans::PropertyAttribute::attrib2 | com::sun::star::beans::PropertyAttribute::attrib3)
162 : :
163 : : //------------------------------------------------------------------------------
164 : : #define DECL_PROP4(varname, type, attrib1, attrib2, attrib3, attrib4) \
165 : : 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)
166 : :
167 : : // === some property types require special handling
168 : : // === such as interfaces
169 : : //------------------------------------------------------------------------------
170 : : #define DECL_IFACE_PROP0(varname, type) \
171 : : DECL_IFACE_PROP_IMPL(varname, type) 0)
172 : :
173 : : //------------------------------------------------------------------------------
174 : : #define DECL_IFACE_PROP1(varname, type, attrib1) \
175 : : DECL_IFACE_PROP_IMPL(varname, type) starbeans::PropertyAttribute::attrib1)
176 : :
177 : : //------------------------------------------------------------------------------
178 : : #define DECL_IFACE_PROP2(varname, type, attrib1, attrib2) \
179 : : DECL_IFACE_PROP_IMPL(varname, type) com::sun::star::beans::PropertyAttribute::attrib1 | com::sun::star::beans::PropertyAttribute::attrib2)
180 : :
181 : : //------------------------------------------------------------------------------
182 : : #define DECL_IFACE_PROP3(varname, type, attrib1, attrib2, attrib3) \
183 : : DECL_IFACE_PROP_IMPL(varname, type) starbeans::PropertyAttribute::attrib1 | starbeans::PropertyAttribute::attrib2 | starbeans::PropertyAttribute::attrib3)
184 : :
185 : : //------------------------------------------------------------------------------
186 : : #define DECL_IFACE_PROP4(varname, type, attrib1, attrib2, attrib3, attrib4) \
187 : : DECL_IFACE_PROP_IMPL(varname, type) starbeans::PropertyAttribute::attrib1 | starbeans::PropertyAttribute::attrib2 | starbeans::PropertyAttribute::attrib3 | PropertyAttribute::attrib4)
188 : :
189 : : // === or Boolean properties
190 : : //------------------------------------------------------------------------------
191 : : #define DECL_BOOL_PROP0(varname) \
192 : : DECL_BOOL_PROP_IMPL(varname) 0)
193 : :
194 : : //------------------------------------------------------------------------------
195 : : #define DECL_BOOL_PROP1(varname, attrib1) \
196 : : DECL_BOOL_PROP_IMPL(varname) com::sun::star::beans::PropertyAttribute::attrib1)
197 : :
198 : : //------------------------------------------------------------------------------
199 : : #define DECL_BOOL_PROP2(varname, attrib1, attrib2) \
200 : : DECL_BOOL_PROP_IMPL(varname) com::sun::star::beans::PropertyAttribute::attrib1 | com::sun::star::beans::PropertyAttribute::attrib2)
201 : :
202 : : //------------------------------------------------------------------------------
203 : : #define DECL_BOOL_PROP3( varname, attrib1, attrib2, attrib3 ) \
204 : : DECL_BOOL_PROP_IMPL(varname) com::sun::star::beans::PropertyAttribute::attrib1 | com::sun::star::beans::PropertyAttribute::attrib2 | com::sun::star::beans::PropertyAttribute::attrib3 )
205 : :
206 : : // ===
207 : : //------------------------------------------------------------------------------
208 : : #define END_DESCRIBE_PROPERTIES() \
209 : : DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(), "<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?"); \
210 : :
211 : : //==============================================================================
212 : : //------------------------------------------------------------------------------
213 : : #define REGISTER_PROP_1( prop, member, attrib1 ) \
214 : : registerProperty( PROPERTY_##prop, PROPERTY_ID_##prop, PropertyAttribute::attrib1, \
215 : : &member, ::getCppuType( &member ) );
216 : :
217 : : #define REGISTER_PROP_2( prop, member, attrib1, attrib2 ) \
218 : : registerProperty( PROPERTY_##prop, PROPERTY_ID_##prop, PropertyAttribute::attrib1 | PropertyAttribute::attrib2, \
219 : : &member, ::getCppuType( &member ) );
220 : :
221 : : #define REGISTER_PROP_3( prop, member, attrib1, attrib2, attrib3 ) \
222 : : registerProperty( PROPERTY_##prop, PROPERTY_ID_##prop, PropertyAttribute::attrib1 | PropertyAttribute::attrib2 | PropertyAttribute::attrib3, \
223 : : &member, ::getCppuType( &member ) );
224 : :
225 : : //------------------------------------------------------------------------------
226 : : #define REGISTER_VOID_PROP_1( prop, memberAny, type, attrib1 ) \
227 : : registerMayBeVoidProperty( PROPERTY_##prop, PROPERTY_ID_##prop, PropertyAttribute::MAYBEVOID | PropertyAttribute::attrib1, \
228 : : &memberAny, ::getCppuType( static_cast< type* >( NULL ) ) );
229 : :
230 : : #define REGISTER_VOID_PROP_2( prop, memberAny, type, attrib1, attrib2 ) \
231 : : registerMayBeVoidProperty( PROPERTY_##prop, PROPERTY_ID_##prop, PropertyAttribute::MAYBEVOID | PropertyAttribute::attrib1 | PropertyAttribute::attrib2, \
232 : : &memberAny, ::getCppuType( static_cast< type* >( NULL ) ) );
233 : :
234 : : //.........................................................................
235 : : }
236 : : //... namespace frm .......................................................
237 : :
238 : : #endif // _FRM_PROPERTY_HXX_
239 : :
240 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|