bump product version to 4.1.6.2
[LibreOffice.git] / xmloff / source / forms / formattributes.hxx
blobf535d0172ba068c01ee124f74d8d8e22b9f0f81f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef _XMLOFF_FORMATTRIBUTES_HXX_
21 #define _XMLOFF_FORMATTRIBUTES_HXX_
23 #include <com/sun/star/beans/XPropertySet.hpp>
24 #include <sal/types.h>
25 #include <salhelper/simplereferenceobject.hxx>
26 #include <comphelper/stl_types.hxx>
28 struct SvXMLEnumMapEntry;
30 //.........................................................................
31 namespace xmloff
33 //.........................................................................
35 // flags for common control attributes
36 #define CCA_NAME 0x00000001
37 #define CCA_SERVICE_NAME 0x00000002
38 #define CCA_BUTTON_TYPE 0x00000004
39 #define CCA_CONTROL_ID 0x00000008
40 #define CCA_CURRENT_SELECTED 0x00000010
41 #define CCA_CURRENT_VALUE 0x00000020
42 #define CCA_DISABLED 0x00000040
43 #define CCA_DROPDOWN 0x00000080
44 #define CCA_FOR 0x00000100
45 #define CCA_IMAGE_DATA 0x00000200
46 #define CCA_LABEL 0x00000400
47 #define CCA_MAX_LENGTH 0x00000800
48 #define CCA_PRINTABLE 0x00001000
49 #define CCA_READONLY 0x00002000
50 #define CCA_SELECTED 0x00004000
51 #define CCA_SIZE 0x00008000
52 #define CCA_TAB_INDEX 0x00010000
53 #define CCA_TARGET_FRAME 0x00020000
54 #define CCA_TARGET_LOCATION 0x00040000
55 #define CCA_TAB_STOP 0x00080000
56 #define CCA_TITLE 0x00100000
57 #define CCA_VALUE 0x00200000
58 #define CCA_ORIENTATION 0x00400000
59 #define CCA_VISUAL_EFFECT 0x00800000
60 #define CCA_ENABLEVISIBLE 0x01000000
62 // flags for database control atttributes
63 #define DA_BOUND_COLUMN 0x00000001
64 #define DA_CONVERT_EMPTY 0x00000002
65 #define DA_DATA_FIELD 0x00000004
66 #define DA_LIST_SOURCE 0x00000008
67 #define DA_LIST_SOURCE_TYPE 0x00000010
68 #define DA_INPUT_REQUIRED 0x00000020
70 // flags for binding related control attributes
71 #define BA_LINKED_CELL 0x00000001
72 #define BA_LIST_LINKING_TYPE 0x00000002
73 #define BA_LIST_CELL_RANGE 0x00000004
74 #define BA_XFORMS_BIND 0x00000008
75 #define BA_XFORMS_LISTBIND 0x00000010
76 #define BA_XFORMS_SUBMISSION 0x00000020
78 // flags for event attributes
79 #define EA_CONTROL_EVENTS 0x00000001
80 #define EA_ON_CHANGE 0x00000002
81 #define EA_ON_CLICK 0x00000004
82 #define EA_ON_DBLCLICK 0x00000008
83 #define EA_ON_SELECT 0x00000010
85 /// attributes in the xml tag representing a form
86 enum FormAttributes
88 faName,
89 faServiceName,
90 faAction,
91 faEnctype,
92 faMethod,
93 faTargetFrame,
94 faAllowDeletes,
95 faAllowInserts,
96 faAllowUpdates,
97 faApplyFilter,
98 faCommand,
99 faCommandType,
100 faEscapeProcessing,
101 faDatasource,
102 faConnectionResource,
103 faDetailFiels,
104 faFilter,
105 faIgnoreResult,
106 faMasterFields,
107 faNavigationMode,
108 faOrder,
109 faTabbingCycle
112 // any other attributes, which are special to some control types
113 #define SCA_ECHO_CHAR 0x00000001
114 #define SCA_MAX_VALUE 0x00000002
115 #define SCA_MIN_VALUE 0x00000004
116 #define SCA_VALIDATION 0x00000008
117 #define SCA_GROUP_NAME 0x00000010
118 #define SCA_MULTI_LINE 0x00000020
119 #define SCA_AUTOMATIC_COMPLETION 0x00000080
120 #define SCA_MULTIPLE 0x00000100
121 #define SCA_DEFAULT_BUTTON 0x00000200
122 #define SCA_CURRENT_STATE 0x00000400
123 #define SCA_IS_TRISTATE 0x00000800
124 #define SCA_STATE 0x00001000
125 #define SCA_COLUMN_STYLE_NAME 0x00002000
126 #define SCA_STEP_SIZE 0x00004000
127 #define SCA_PAGE_STEP_SIZE 0x00008000
128 #define SCA_REPEAT_DELAY 0x00010000
129 #define SCA_TOGGLE 0x00020000
130 #define SCA_FOCUS_ON_CLICK 0x00040000
131 #define SCA_IMAGE_POSITION 0x00080000
133 // attributes of the office:forms element
134 enum OfficeFormsAttributes
136 ofaAutomaticFocus,
137 ofaApplyDesignMode
140 //=====================================================================
141 //= OAttributeMetaData
142 //=====================================================================
143 /** allows the translation of attribute ids into strings.
145 <p>This class does not allow to connect xml attributes to property names or
146 something like that, it only deals with the xml side</p>
148 class OAttributeMetaData
150 public:
151 /** calculates the xml attribute representation of a common control attribute.
152 @param _nId
153 the id of the attribute. Has to be one of the CCA_* constants.
155 static const sal_Char* getCommonControlAttributeName(sal_Int32 _nId);
157 /** calculates the xml namespace key to use for a common control attribute
158 @param _nId
159 the id of the attribute. Has to be one of the CCA_* constants.
161 static sal_uInt16 getCommonControlAttributeNamespace(sal_Int32 _nId);
163 /** retrieves the name of an attribute of a form xml representation
164 @param _eAttrib
165 enum value specifying the attribute
167 static const sal_Char* getFormAttributeName(FormAttributes _eAttrib);
169 /** calculates the xml namespace key to use for a attribute of a form xml representation
170 @param _eAttrib
171 enum value specifying the attribute
173 static sal_uInt16 getFormAttributeNamespace(FormAttributes _eAttrib);
175 /** calculates the xml attribute representation of a database attribute.
176 @param _nId
177 the id of the attribute. Has to be one of the DA_* constants.
179 static const sal_Char* getDatabaseAttributeName(sal_Int32 _nId);
181 /** calculates the xml namespace key to use for a database attribute.
182 @param _nId
183 the id of the attribute. Has to be one of the DA_* constants.
185 static sal_uInt16 getDatabaseAttributeNamespace(sal_Int32 _nId);
187 /** calculates the xml attribute representation of a special attribute.
188 @param _nId
189 the id of the attribute. Has to be one of the SCA_* constants.
191 static const sal_Char* getSpecialAttributeName(sal_Int32 _nId);
193 /** calculates the xml attribute representation of a binding attribute.
194 @param _nId
195 the id of the attribute. Has to be one of the BA_* constants.
197 static const sal_Char* getBindingAttributeName(sal_Int32 _nId);
199 /** calculates the xml namespace key to use for a binding attribute.
200 @param _nId
201 the id of the attribute. Has to be one of the BA_* constants.
203 static sal_uInt16 getBindingAttributeNamespace(sal_Int32 _nId);
205 /** calculates the xml namespace key to use for a special attribute.
206 @param _nId
207 the id of the attribute. Has to be one of the SCA_* constants.
209 static sal_uInt16 getSpecialAttributeNamespace(sal_Int32 _nId);
211 /** calculates the xml attribute representation of a attribute of the office:forms element
212 @param _nId
213 the id of the attribute
215 static const sal_Char* getOfficeFormsAttributeName(OfficeFormsAttributes _eAttrib);
217 /** calculates the xml namedspace key of a attribute of the office:forms element
218 @param _nId
219 the id of the attribute
221 static sal_uInt16 getOfficeFormsAttributeNamespace(OfficeFormsAttributes _eAttrib);
224 //=====================================================================
225 //= OAttribute2Property
226 //=====================================================================
227 /** some kind of opposite to the OAttributeMetaData class. Able to translate
228 attributes into property names/types
230 <p>The construction of this class is rather expensive (or at least it's initialization from outside),
231 so it should be shared</p>
233 class OAttribute2Property
235 public:
236 // TODO: maybe the following struct should be used for exports, too. In this case we would not need to
237 // store it's instances in a map, but in a vector for faster access.
238 struct AttributeAssignment
240 OUString sAttributeName; // the attribute name
241 OUString sPropertyName; // the property name
242 ::com::sun::star::uno::Type aPropertyType; // the property type
243 OUString sAttributeDefault; // the default if the attribute is not present
245 // entries which are special to some value types
246 const SvXMLEnumMapEntry* pEnumMap; // the enum map, if appliable
247 sal_Bool bInverseSemantics; // for booleanss: attribute and property value have the same or an inverse semantics?
249 AttributeAssignment() : pEnumMap(NULL), bInverseSemantics(sal_False) { }
252 protected:
253 DECLARE_STL_USTRINGACCESS_MAP( AttributeAssignment, AttributeAssignments );
254 AttributeAssignments m_aKnownProperties;
256 public:
257 OAttribute2Property();
258 virtual ~OAttribute2Property();
260 /** return the AttributeAssignment which corresponds to the given attribute
262 @param _rAttribName
263 the name of the attrribute
264 @return
265 a pointer to the <type>AttributeAssignment</type> structure as requested, NULL if the attribute
266 does not represent a property.
268 const AttributeAssignment* getAttributeTranslation(
269 const OUString& _rAttribName);
271 /** add a attribute assignment referring to a string property to the map
272 @param _pAttributeName
273 the name of the attrribute
274 @param _rPropertyName
275 the name of the property assigned to the attribute
276 @param _pAttributeDefault
277 the default value for the attribute, if any. May be NULL, in this case the default is assumed to be
278 an empty string.
280 void addStringProperty(
281 const sal_Char* _pAttributeName, const OUString& _rPropertyName,
282 const sal_Char* _pAttributeDefault = NULL);
284 /** add a attribute assignment referring to a boolean property to the map
286 @param _pAttributeName
287 the name of the attrribute
288 @param _rPropertyName
289 the name of the property assigned to the attribute
290 @param _bAttributeDefault
291 the default value for the attribute.
292 @param _bInverseSemantics
293 if <TRUE/>, a attribute value of <TRUE/> means a property value of <FALSE/> and vice verse.<br/>
294 if <FALSE/>, the attribute value is used as property value directly
296 void addBooleanProperty(
297 const sal_Char* _pAttributeName, const OUString& _rPropertyName,
298 const sal_Bool _bAttributeDefault, const sal_Bool _bInverseSemantics = sal_False);
300 /** add a attribute assignment referring to an int16 property to the map
302 @param _pAttributeName
303 the name of the attrribute
304 @param _rPropertyName
305 the name of the property assigned to the attribute
306 @param _nAttributeDefault
307 the default value for the attribute.
309 void addInt16Property(
310 const sal_Char* _pAttributeName, const OUString& _rPropertyName,
311 const sal_Int16 _nAttributeDefault);
313 /** add a attribute assignment referring to an int32 property to the map
315 @param _pAttributeName
316 the name of the attrribute
317 @param _rPropertyName
318 the name of the property assigned to the attribute
319 @param _nAttributeDefault
320 the default value for the attribute.
322 void addInt32Property(
323 const sal_Char* _pAttributeName, const OUString& _rPropertyName,
324 const sal_Int32 _nAttributeDefault );
326 /** add a attribute assignment referring to an enum property to the map
328 @param _pAttributeName
329 the name of the attrribute
330 @param _rPropertyName
331 the name of the property assigned to the attribute
332 @param _nAttributeDefault
333 the default value for the attribute, as (32bit) integer
334 @param _pValueMap
335 the map to translate strings into enum values
336 @param _pType
337 the type of the property. May be NULL, in this case 32bit integer is assumed.
339 void addEnumProperty(
340 const sal_Char* _pAttributeName, const OUString& _rPropertyName,
341 const sal_uInt16 _nAttributeDefault, const SvXMLEnumMapEntry* _pValueMap,
342 const ::com::sun::star::uno::Type* _pType = NULL);
344 protected:
345 /// some common code for the various add*Property methods
346 AttributeAssignment& implAdd(
347 const sal_Char* _pAttributeName, const OUString& _rPropertyName,
348 const ::com::sun::star::uno::Type& _rType, const OUString& _rDefaultString);
350 //.........................................................................
351 } // namespace xmloff
352 //.........................................................................
354 #endif // _XMLOFF_FORMATTRIBUTES_HXX_
356 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */