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