1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 INCLUDED_XMLOFF_SOURCE_FORMS_FORMATTRIBUTES_HXX
21 #define INCLUDED_XMLOFF_SOURCE_FORMS_FORMATTRIBUTES_HXX
23 #include <sal/config.h>
27 #include <com/sun/star/beans/XPropertySet.hpp>
28 #include <sal/types.h>
29 #include <salhelper/simplereferenceobject.hxx>
30 #include <xmloff/xmlnmspe.hxx>
32 struct SvXMLEnumMapEntry
;
37 // flags for common control attributes
38 #define CCA_NAME 0x00000001
39 #define CCA_SERVICE_NAME 0x00000002
40 #define CCA_BUTTON_TYPE 0x00000004
41 #define CCA_CONTROL_ID 0x00000008
42 #define CCA_CURRENT_SELECTED 0x00000010
43 #define CCA_CURRENT_VALUE 0x00000020
44 #define CCA_DISABLED 0x00000040
45 #define CCA_DROPDOWN 0x00000080
46 #define CCA_FOR 0x00000100
47 #define CCA_IMAGE_DATA 0x00000200
48 #define CCA_LABEL 0x00000400
49 #define CCA_MAX_LENGTH 0x00000800
50 #define CCA_PRINTABLE 0x00001000
51 #define CCA_READONLY 0x00002000
52 #define CCA_SELECTED 0x00004000
53 #define CCA_SIZE 0x00008000
54 #define CCA_TAB_INDEX 0x00010000
55 #define CCA_TARGET_FRAME 0x00020000
56 #define CCA_TARGET_LOCATION 0x00040000
57 #define CCA_TAB_STOP 0x00080000
58 #define CCA_TITLE 0x00100000
59 #define CCA_VALUE 0x00200000
60 #define CCA_ORIENTATION 0x00400000
61 #define CCA_VISUAL_EFFECT 0x00800000
62 #define CCA_ENABLEVISIBLE 0x01000000
64 // flags for database control atttributes
65 #define DA_BOUND_COLUMN 0x00000001
66 #define DA_CONVERT_EMPTY 0x00000002
67 #define DA_DATA_FIELD 0x00000004
68 #define DA_LIST_SOURCE 0x00000008
69 #define DA_LIST_SOURCE_TYPE 0x00000010
70 #define DA_INPUT_REQUIRED 0x00000020
72 // flags for binding related control attributes
73 #define BA_LINKED_CELL 0x00000001
74 #define BA_LIST_LINKING_TYPE 0x00000002
75 #define BA_LIST_CELL_RANGE 0x00000004
76 #define BA_XFORMS_BIND 0x00000008
77 #define BA_XFORMS_LISTBIND 0x00000010
78 #define BA_XFORMS_SUBMISSION 0x00000020
80 // flags for event attributes
81 #define EA_CONTROL_EVENTS 0x00000001
82 #define EA_ON_CHANGE 0x00000002
83 #define EA_ON_CLICK 0x00000004
84 #define EA_ON_DBLCLICK 0x00000008
85 #define EA_ON_SELECT 0x00000010
87 /// attributes in the xml tag representing a form
104 faConnectionResource
,
114 // any other attributes, which are special to some control types
115 #define SCA_ECHO_CHAR 0x00000001
116 #define SCA_MAX_VALUE 0x00000002
117 #define SCA_MIN_VALUE 0x00000004
118 #define SCA_VALIDATION 0x00000008
119 #define SCA_GROUP_NAME 0x00000010
120 #define SCA_MULTI_LINE 0x00000020
121 #define SCA_AUTOMATIC_COMPLETION 0x00000080
122 #define SCA_MULTIPLE 0x00000100
123 #define SCA_DEFAULT_BUTTON 0x00000200
124 #define SCA_CURRENT_STATE 0x00000400
125 #define SCA_IS_TRISTATE 0x00000800
126 #define SCA_STATE 0x00001000
127 #define SCA_COLUMN_STYLE_NAME 0x00002000
128 #define SCA_STEP_SIZE 0x00004000
129 #define SCA_PAGE_STEP_SIZE 0x00008000
130 #define SCA_REPEAT_DELAY 0x00010000
131 #define SCA_TOGGLE 0x00020000
132 #define SCA_FOCUS_ON_CLICK 0x00040000
133 #define SCA_IMAGE_POSITION 0x00080000
135 // attributes of the office:forms element
136 enum OfficeFormsAttributes
142 //= OAttributeMetaData
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
151 /** calculates the xml attribute representation of a common control attribute.
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
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
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
171 enum value specifying the attribute
173 static sal_uInt16
getFormAttributeNamespace(FormAttributes _eAttrib
);
175 /** calculates the xml attribute representation of a database attribute.
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.
183 the id of the attribute. Has to be one of the DA_* constants.
185 static inline sal_uInt16
getDatabaseAttributeNamespace(sal_Int32
)
187 // nothing special here
188 return XML_NAMESPACE_FORM
;
191 /** calculates the xml attribute representation of a special attribute.
193 the id of the attribute. Has to be one of the SCA_* constants.
195 static const sal_Char
* getSpecialAttributeName(sal_Int32 _nId
);
197 /** calculates the xml attribute representation of a binding attribute.
199 the id of the attribute. Has to be one of the BA_* constants.
201 static const sal_Char
* getBindingAttributeName(sal_Int32 _nId
);
203 /** calculates the xml namespace key to use for a binding attribute.
205 the id of the attribute. Has to be one of the BA_* constants.
207 static inline sal_uInt16
getBindingAttributeNamespace(sal_Int32
)
209 // nothing special here
210 return XML_NAMESPACE_FORM
;
213 /** calculates the xml namespace key to use for a special attribute.
215 the id of the attribute. Has to be one of the SCA_* constants.
217 static sal_uInt16
getSpecialAttributeNamespace(sal_Int32 _nId
);
219 /** calculates the xml attribute representation of a attribute of the office:forms element
221 the id of the attribute
223 static const sal_Char
* getOfficeFormsAttributeName(OfficeFormsAttributes _eAttrib
);
225 /** calculates the xml namedspace key of a attribute of the office:forms element
227 the id of the attribute
229 static inline sal_uInt16
getOfficeFormsAttributeNamespace(OfficeFormsAttributes
)
230 { // nothing special here
231 return XML_NAMESPACE_FORM
;
235 //= OAttribute2Property
236 /** some kind of opposite to the OAttributeMetaData class. Able to translate
237 attributes into property names/types
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>
242 class OAttribute2Property
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 struct AttributeAssignment
249 OUString sAttributeName
; // the attribute name
250 OUString sPropertyName
; // the property name
251 ::com::sun::star::uno::Type aPropertyType
; // the property type
252 OUString sAttributeDefault
; // the default if the attribute is not present
254 // entries which are special to some value types
255 const SvXMLEnumMapEntry
* pEnumMap
; // the enum map, if appliable
256 bool bInverseSemantics
; // for booleanss: attribute and property value have the same or an inverse semantics?
258 AttributeAssignment() : pEnumMap(NULL
), bInverseSemantics(false) { }
262 typedef std::map
<OUString
, AttributeAssignment
> AttributeAssignments
;
263 AttributeAssignments m_aKnownProperties
;
266 OAttribute2Property();
267 virtual ~OAttribute2Property();
269 /** return the AttributeAssignment which corresponds to the given attribute
272 the name of the attrribute
274 a pointer to the <type>AttributeAssignment</type> structure as requested, NULL if the attribute
275 does not represent a property.
277 const AttributeAssignment
* getAttributeTranslation(
278 const OUString
& _rAttribName
);
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
289 void addStringProperty(
290 const sal_Char
* _pAttributeName
, const OUString
& _rPropertyName
,
291 const sal_Char
* _pAttributeDefault
= NULL
);
293 /** add a attribute assignment referring to a boolean property to the map
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
305 void addBooleanProperty(
306 const sal_Char
* _pAttributeName
, const OUString
& _rPropertyName
,
307 const bool _bAttributeDefault
, const bool _bInverseSemantics
= false);
309 /** add a attribute assignment referring to an int16 property to the map
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.
318 void addInt16Property(
319 const sal_Char
* _pAttributeName
, const OUString
& _rPropertyName
,
320 const sal_Int16 _nAttributeDefault
);
322 /** add a attribute assignment referring to an int32 property to the map
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.
331 void addInt32Property(
332 const sal_Char
* _pAttributeName
, const OUString
& _rPropertyName
,
333 const sal_Int32 _nAttributeDefault
);
335 /** add a attribute assignment referring to an enum property to the map
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
344 the map to translate strings into enum values
346 the type of the property. May be NULL, in this case 32bit integer is assumed.
348 void addEnumProperty(
349 const sal_Char
* _pAttributeName
, const OUString
& _rPropertyName
,
350 const sal_uInt16 _nAttributeDefault
, const SvXMLEnumMapEntry
* _pValueMap
,
351 const ::com::sun::star::uno::Type
* _pType
= NULL
);
354 /// some common code for the various add*Property methods
355 AttributeAssignment
& implAdd(
356 const sal_Char
* _pAttributeName
, const OUString
& _rPropertyName
,
357 const ::com::sun::star::uno::Type
& _rType
, const OUString
& _rDefaultString
);
359 } // namespace xmloff
361 #endif // INCLUDED_XMLOFF_SOURCE_FORMS_FORMATTRIBUTES_HXX
363 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */