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 _XMLOFF_FORMATTRIBUTES_HXX_
30 : : #define _XMLOFF_FORMATTRIBUTES_HXX_
31 : :
32 : : #include <com/sun/star/beans/XPropertySet.hpp>
33 : : #include <sal/types.h>
34 : : #include <salhelper/simplereferenceobject.hxx>
35 : : #include <comphelper/stl_types.hxx>
36 : :
37 : : struct SvXMLEnumMapEntry;
38 : :
39 : : //.........................................................................
40 : : namespace xmloff
41 : : {
42 : : //.........................................................................
43 : :
44 : : // flags for common control attributes
45 : : #define CCA_NAME 0x00000001
46 : : #define CCA_SERVICE_NAME 0x00000002
47 : : #define CCA_BUTTON_TYPE 0x00000004
48 : : #define CCA_CONTROL_ID 0x00000008
49 : : #define CCA_CURRENT_SELECTED 0x00000010
50 : : #define CCA_CURRENT_VALUE 0x00000020
51 : : #define CCA_DISABLED 0x00000040
52 : : #define CCA_DROPDOWN 0x00000080
53 : : #define CCA_FOR 0x00000100
54 : : #define CCA_IMAGE_DATA 0x00000200
55 : : #define CCA_LABEL 0x00000400
56 : : #define CCA_MAX_LENGTH 0x00000800
57 : : #define CCA_PRINTABLE 0x00001000
58 : : #define CCA_READONLY 0x00002000
59 : : #define CCA_SELECTED 0x00004000
60 : : #define CCA_SIZE 0x00008000
61 : : #define CCA_TAB_INDEX 0x00010000
62 : : #define CCA_TARGET_FRAME 0x00020000
63 : : #define CCA_TARGET_LOCATION 0x00040000
64 : : #define CCA_TAB_STOP 0x00080000
65 : : #define CCA_TITLE 0x00100000
66 : : #define CCA_VALUE 0x00200000
67 : : #define CCA_ORIENTATION 0x00400000
68 : : #define CCA_VISUAL_EFFECT 0x00800000
69 : : #define CCA_ENABLEVISIBLE 0x01000000
70 : :
71 : : // flags for database control atttributes
72 : : #define DA_BOUND_COLUMN 0x00000001
73 : : #define DA_CONVERT_EMPTY 0x00000002
74 : : #define DA_DATA_FIELD 0x00000004
75 : : #define DA_LIST_SOURCE 0x00000008
76 : : #define DA_LIST_SOURCE_TYPE 0x00000010
77 : : #define DA_INPUT_REQUIRED 0x00000020
78 : :
79 : : // flags for binding related control attributes
80 : : #define BA_LINKED_CELL 0x00000001
81 : : #define BA_LIST_LINKING_TYPE 0x00000002
82 : : #define BA_LIST_CELL_RANGE 0x00000004
83 : : #define BA_XFORMS_BIND 0x00000008
84 : : #define BA_XFORMS_LISTBIND 0x00000010
85 : : #define BA_XFORMS_SUBMISSION 0x00000020
86 : :
87 : : // flags for event attributes
88 : : #define EA_CONTROL_EVENTS 0x00000001
89 : : #define EA_ON_CHANGE 0x00000002
90 : : #define EA_ON_CLICK 0x00000004
91 : : #define EA_ON_DBLCLICK 0x00000008
92 : : #define EA_ON_SELECT 0x00000010
93 : :
94 : : /// attributes in the xml tag representing a form
95 : : enum FormAttributes
96 : : {
97 : : faName,
98 : : faServiceName,
99 : : faAction,
100 : : faEnctype,
101 : : faMethod,
102 : : faTargetFrame,
103 : : faAllowDeletes,
104 : : faAllowInserts,
105 : : faAllowUpdates,
106 : : faApplyFilter,
107 : : faCommand,
108 : : faCommandType,
109 : : faEscapeProcessing,
110 : : faDatasource,
111 : : faConnectionResource,
112 : : faDetailFiels,
113 : : faFilter,
114 : : faIgnoreResult,
115 : : faMasterFields,
116 : : faNavigationMode,
117 : : faOrder,
118 : : faTabbingCycle
119 : : };
120 : :
121 : : // any other attributes, which are special to some control types
122 : : #define SCA_ECHO_CHAR 0x00000001
123 : : #define SCA_MAX_VALUE 0x00000002
124 : : #define SCA_MIN_VALUE 0x00000004
125 : : #define SCA_VALIDATION 0x00000008
126 : : #define SCA_GROUP_NAME 0x00000010
127 : : #define SCA_MULTI_LINE 0x00000020
128 : : #define SCA_AUTOMATIC_COMPLETION 0x00000080
129 : : #define SCA_MULTIPLE 0x00000100
130 : : #define SCA_DEFAULT_BUTTON 0x00000200
131 : : #define SCA_CURRENT_STATE 0x00000400
132 : : #define SCA_IS_TRISTATE 0x00000800
133 : : #define SCA_STATE 0x00001000
134 : : #define SCA_COLUMN_STYLE_NAME 0x00002000
135 : : #define SCA_STEP_SIZE 0x00004000
136 : : #define SCA_PAGE_STEP_SIZE 0x00008000
137 : : #define SCA_REPEAT_DELAY 0x00010000
138 : : #define SCA_TOGGLE 0x00020000
139 : : #define SCA_FOCUS_ON_CLICK 0x00040000
140 : : #define SCA_IMAGE_POSITION 0x00080000
141 : :
142 : : // attributes of the office:forms element
143 : : enum OfficeFormsAttributes
144 : : {
145 : : ofaAutomaticFocus,
146 : : ofaApplyDesignMode
147 : : };
148 : :
149 : : //=====================================================================
150 : : //= OAttributeMetaData
151 : : //=====================================================================
152 : : /** allows the translation of attribute ids into strings.
153 : :
154 : : <p>This class does not allow to connect xml attributes to property names or
155 : : something like that, it only deals with the xml side</p>
156 : : */
157 : : class OAttributeMetaData
158 : : {
159 : : public:
160 : : /** calculates the xml attribute representation of a common control attribute.
161 : : @param _nId
162 : : the id of the attribute. Has to be one of the CCA_* constants.
163 : : */
164 : : static const sal_Char* getCommonControlAttributeName(sal_Int32 _nId);
165 : :
166 : : /** calculates the xml namespace key to use for a common control attribute
167 : : @param _nId
168 : : the id of the attribute. Has to be one of the CCA_* constants.
169 : : */
170 : : static sal_uInt16 getCommonControlAttributeNamespace(sal_Int32 _nId);
171 : :
172 : : /** retrieves the name of an attribute of a form xml representation
173 : : @param _eAttrib
174 : : enum value specifying the attribute
175 : : */
176 : : static const sal_Char* getFormAttributeName(FormAttributes _eAttrib);
177 : :
178 : : /** calculates the xml namespace key to use for a attribute of a form xml representation
179 : : @param _eAttrib
180 : : enum value specifying the attribute
181 : : */
182 : : static sal_uInt16 getFormAttributeNamespace(FormAttributes _eAttrib);
183 : :
184 : : /** calculates the xml attribute representation of a database attribute.
185 : : @param _nId
186 : : the id of the attribute. Has to be one of the DA_* constants.
187 : : */
188 : : static const sal_Char* getDatabaseAttributeName(sal_Int32 _nId);
189 : :
190 : : /** calculates the xml namespace key to use for a database attribute.
191 : : @param _nId
192 : : the id of the attribute. Has to be one of the DA_* constants.
193 : : */
194 : : static sal_uInt16 getDatabaseAttributeNamespace(sal_Int32 _nId);
195 : :
196 : : /** calculates the xml attribute representation of a special attribute.
197 : : @param _nId
198 : : the id of the attribute. Has to be one of the SCA_* constants.
199 : : */
200 : : static const sal_Char* getSpecialAttributeName(sal_Int32 _nId);
201 : :
202 : : /** calculates the xml attribute representation of a binding attribute.
203 : : @param _nId
204 : : the id of the attribute. Has to be one of the BA_* constants.
205 : : */
206 : : static const sal_Char* getBindingAttributeName(sal_Int32 _nId);
207 : :
208 : : /** calculates the xml namespace key to use for a binding attribute.
209 : : @param _nId
210 : : the id of the attribute. Has to be one of the BA_* constants.
211 : : */
212 : : static sal_uInt16 getBindingAttributeNamespace(sal_Int32 _nId);
213 : :
214 : : /** calculates the xml namespace key to use for a special attribute.
215 : : @param _nId
216 : : the id of the attribute. Has to be one of the SCA_* constants.
217 : : */
218 : : static sal_uInt16 getSpecialAttributeNamespace(sal_Int32 _nId);
219 : :
220 : : /** calculates the xml attribute representation of a attribute of the office:forms element
221 : : @param _nId
222 : : the id of the attribute
223 : : */
224 : : static const sal_Char* getOfficeFormsAttributeName(OfficeFormsAttributes _eAttrib);
225 : :
226 : : /** calculates the xml namedspace key of a attribute of the office:forms element
227 : : @param _nId
228 : : the id of the attribute
229 : : */
230 : : static sal_uInt16 getOfficeFormsAttributeNamespace(OfficeFormsAttributes _eAttrib);
231 : : };
232 : :
233 : : //=====================================================================
234 : : //= OAttribute2Property
235 : : //=====================================================================
236 : : /** some kind of opposite to the OAttributeMetaData class. Able to translate
237 : : attributes into property names/types
238 : :
239 : : <p>The construction of this class is rather expensive (or at least it's initialization from outside),
240 : : so it should be shared</p>
241 : : */
242 : : class OAttribute2Property
243 : : {
244 : : public:
245 : : // TODO: maybe the following struct should be used for exports, too. In this case we would not need to
246 : : // store it's instances in a map, but in a vector for faster access.
247 : 126378 : struct AttributeAssignment
248 : : {
249 : : ::rtl::OUString sAttributeName; // the attribute name
250 : : ::rtl::OUString sPropertyName; // the property name
251 : : ::com::sun::star::uno::Type aPropertyType; // the property type
252 : : ::rtl::OUString sAttributeDefault; // the default if the attribute is not present
253 : :
254 : : // entries which are special to some value types
255 : : const SvXMLEnumMapEntry* pEnumMap; // the enum map, if appliable
256 : : sal_Bool bInverseSemantics; // for booleanss: attribute and property value have the same or an inverse semantics?
257 : :
258 : 36108 : AttributeAssignment() : pEnumMap(NULL), bInverseSemantics(sal_False) { }
259 : : };
260 : :
261 : : protected:
262 : : DECLARE_STL_USTRINGACCESS_MAP( AttributeAssignment, AttributeAssignments );
263 : : AttributeAssignments m_aKnownProperties;
264 : :
265 : : public:
266 : : OAttribute2Property();
267 : : virtual ~OAttribute2Property();
268 : :
269 : : /** return the AttributeAssignment which corresponds to the given attribute
270 : :
271 : : @param _rAttribName
272 : : the name of the attrribute
273 : : @return
274 : : a pointer to the <type>AttributeAssignment</type> structure as requested, NULL if the attribute
275 : : does not represent a property.
276 : : */
277 : : const AttributeAssignment* getAttributeTranslation(
278 : : const ::rtl::OUString& _rAttribName);
279 : :
280 : : /** add a attribute assignment referring to a string property to the map
281 : : @param _pAttributeName
282 : : the name of the attrribute
283 : : @param _rPropertyName
284 : : the name of the property assigned to the attribute
285 : : @param _pAttributeDefault
286 : : the default value for the attribute, if any. May be NULL, in this case the default is assumed to be
287 : : an empty string.
288 : : */
289 : : void addStringProperty(
290 : : const sal_Char* _pAttributeName, const ::rtl::OUString& _rPropertyName,
291 : : const sal_Char* _pAttributeDefault = NULL);
292 : :
293 : : /** add a attribute assignment referring to a boolean property to the map
294 : :
295 : : @param _pAttributeName
296 : : the name of the attrribute
297 : : @param _rPropertyName
298 : : the name of the property assigned to the attribute
299 : : @param _bAttributeDefault
300 : : the default value for the attribute.
301 : : @param _bInverseSemantics
302 : : if <TRUE/>, a attribute value of <TRUE/> means a property value of <FALSE/> and vice verse.<br/>
303 : : if <FALSE/>, the attribute value is used as property value directly
304 : : */
305 : : void addBooleanProperty(
306 : : const sal_Char* _pAttributeName, const ::rtl::OUString& _rPropertyName,
307 : : const sal_Bool _bAttributeDefault, const sal_Bool _bInverseSemantics = sal_False);
308 : :
309 : : /** add a attribute assignment referring to an int16 property to the map
310 : :
311 : : @param _pAttributeName
312 : : the name of the attrribute
313 : : @param _rPropertyName
314 : : the name of the property assigned to the attribute
315 : : @param _nAttributeDefault
316 : : the default value for the attribute.
317 : : */
318 : : void addInt16Property(
319 : : const sal_Char* _pAttributeName, const ::rtl::OUString& _rPropertyName,
320 : : const sal_Int16 _nAttributeDefault);
321 : :
322 : : /** add a attribute assignment referring to an int32 property to the map
323 : :
324 : : @param _pAttributeName
325 : : the name of the attrribute
326 : : @param _rPropertyName
327 : : the name of the property assigned to the attribute
328 : : @param _nAttributeDefault
329 : : the default value for the attribute.
330 : : */
331 : : void addInt32Property(
332 : : const sal_Char* _pAttributeName, const ::rtl::OUString& _rPropertyName,
333 : : const sal_Int32 _nAttributeDefault );
334 : :
335 : : /** add a attribute assignment referring to an enum property to the map
336 : :
337 : : @param _pAttributeName
338 : : the name of the attrribute
339 : : @param _rPropertyName
340 : : the name of the property assigned to the attribute
341 : : @param _nAttributeDefault
342 : : the default value for the attribute, as (32bit) integer
343 : : @param _pValueMap
344 : : the map to translate strings into enum values
345 : : @param _pType
346 : : the type of the property. May be NULL, in this case 32bit integer is assumed.
347 : : */
348 : : void addEnumProperty(
349 : : const sal_Char* _pAttributeName, const ::rtl::OUString& _rPropertyName,
350 : : const sal_uInt16 _nAttributeDefault, const SvXMLEnumMapEntry* _pValueMap,
351 : : const ::com::sun::star::uno::Type* _pType = NULL);
352 : :
353 : : protected:
354 : : /// some common code for the various add*Property methods
355 : : AttributeAssignment& implAdd(
356 : : const sal_Char* _pAttributeName, const ::rtl::OUString& _rPropertyName,
357 : : const ::com::sun::star::uno::Type& _rType, const ::rtl::OUString& _rDefaultString);
358 : : };
359 : : //.........................................................................
360 : : } // namespace xmloff
361 : : //.........................................................................
362 : :
363 : : #endif // _XMLOFF_FORMATTRIBUTES_HXX_
364 : :
365 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|