LibreOffice Module xmloff (master) 1
formattributes.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include <sal/config.h>
23
24#include <map>
25
26#include <com/sun/star/uno/Type.hxx>
27#include <rtl/ustring.hxx>
28#include <sal/types.h>
30#include <xmloff/xmltoken.hxx>
32
33template<typename EnumT>
35
36 // flags for common control attributes
37enum class CCAFlags {
38 NONE = 0x00000000,
39 Name = 0x00000001,
40 ServiceName = 0x00000002,
41 ButtonType = 0x00000004,
42 ControlId = 0x00000008,
43 CurrentSelected = 0x00000010,
44 CurrentValue = 0x00000020,
45 Disabled = 0x00000040,
46 Dropdown = 0x00000080,
47 For = 0x00000100,
48 ImageData = 0x00000200,
49 Label = 0x00000400,
50 MaxLength = 0x00000800,
51 Printable = 0x00001000,
52 ReadOnly = 0x00002000,
53 Selected = 0x00004000,
54 Size = 0x00008000,
55 TabIndex = 0x00010000,
56 TargetFrame = 0x00020000,
57 TargetLocation = 0x00040000,
58 TabStop = 0x00080000,
59 Title = 0x00100000,
60 Value = 0x00200000,
61 Orientation = 0x00400000,
62 VisualEffect = 0x00800000,
63 EnableVisible = 0x01000000,
64};
65namespace o3tl {
66 template<> struct typed_flags<CCAFlags> : is_typed_flags<CCAFlags, 0x01ffffff> {};
67}
68
69 // flags for database control attributes
70enum class DAFlags {
71 NONE = 0x0000,
72 BoundColumn = 0x0001,
73 ConvertEmpty = 0x0002,
74 DataField = 0x0004,
75 ListSource = 0x0008,
76 ListSource_TYPE = 0x0010,
77 InputRequired = 0x0020,
78};
79namespace o3tl {
80 template<> struct typed_flags<DAFlags> : is_typed_flags<DAFlags, 0x003f> {};
81}
82
83 // flags for binding related control attributes
84enum class BAFlags {
85 NONE = 0x0000,
86 LinkedCell = 0x0001,
87 ListLinkingType = 0x0002,
88 ListCellRange = 0x0004,
89 XFormsBind = 0x0008,
90 XFormsListBind = 0x0010,
91 XFormsSubmission = 0x0020
92};
93namespace o3tl {
94 template<> struct typed_flags<BAFlags> : is_typed_flags<BAFlags, 0x003f> {};
95}
96
97 // flags for event attributes
98enum class EAFlags {
99 NONE = 0x0000,
100 ControlEvents = 0x0001,
101 OnChange = 0x0002,
102 OnClick = 0x0004,
103 OnDoubleClick = 0x0008,
104 OnSelect = 0x0010
105};
106namespace o3tl {
107 template<> struct typed_flags<EAFlags> : is_typed_flags<EAFlags, 0x001f> {};
108}
109
110 // any other attributes, which are special to some control types
111enum class SCAFlags {
112 NONE = 0x000000,
113 EchoChar = 0x000001,
114 MaxValue = 0x000002,
115 MinValue = 0x000004,
116 Validation = 0x000008,
117 GroupName = 0x000010,
118 MultiLine = 0x000020,
119 AutoCompletion = 0x000080,
120 Multiple = 0x000100,
121 DefaultButton = 0x000200,
122 CurrentState = 0x000400,
123 IsTristate = 0x000800,
124 State = 0x001000,
125 ColumnStyleName = 0x002000,
126 StepSize = 0x004000,
127 PageStepSize = 0x008000,
128 RepeatDelay = 0x010000,
129 Toggle = 0x020000,
130 FocusOnClick = 0x040000,
131 ImagePosition = 0x080000
132};
133namespace o3tl {
134 template<> struct typed_flags<SCAFlags> : is_typed_flags<SCAFlags, 0x0fffbf> {};
135}
136
137
138namespace xmloff
139{
140
143 {
163 };
164
165 // attributes of the office:forms element
167 {
170 };
171
172 //= OAttributeMetaData
179 {
180 public:
185 static OUString getCommonControlAttributeName(CCAFlags _nId);
186
191 static sal_Int32 getCommonControlAttributeToken(CCAFlags _nId);
192
197 static sal_uInt16 getCommonControlAttributeNamespace(CCAFlags _nId);
198
203 static OUString getFormAttributeName(FormAttributes _eAttrib);
204
209 static sal_Int32 getFormAttributeToken(FormAttributes _eAttrib);
210
215 static sal_uInt16 getFormAttributeNamespace(FormAttributes _eAttrib);
216
221 static OUString getDatabaseAttributeName(DAFlags _nId);
222
227 static sal_Int32 getDatabaseAttributeToken(DAFlags _nId);
228
234 {
235 // nothing special here
236 return XML_NAMESPACE_FORM;
237 }
238
243 static OUString getSpecialAttributeName(SCAFlags _nId);
244
249 static sal_Int32 getSpecialAttributeToken(SCAFlags _nId);
250
255 static OUString getBindingAttributeName(BAFlags _nId);
256
261 static sal_Int32 getBindingAttributeToken(BAFlags _nId);
262
268 {
269 // nothing special here
270 return XML_NAMESPACE_FORM;
271 }
272
277 static sal_uInt16 getSpecialAttributeNamespace(SCAFlags _nId);
278
283 static OUString getOfficeFormsAttributeName(OfficeFormsAttributes _eAttrib);
285
291 { // nothing special here
292 return XML_NAMESPACE_FORM;
293 }
294 };
295
296 //= OAttribute2Property
304 {
305 public:
306 // TODO: maybe the following struct should be used for exports, too. In this case we would not need to
307 // store it's instances in a map, but in a vector for faster access.
309 {
310 OUString sPropertyName; // the property name
311 css::uno::Type aPropertyType; // the property type
312
313 // entries which are special to some value types
315 pEnumMap; // the enum map, if applicable
316 bool bInverseSemantics; // for booleans: attribute and property value have the same or an inverse semantics?
317
319 };
320
321 private:
322 std::map<sal_Int32, AttributeAssignment> m_aKnownProperties;
323
324 public:
327
334 const AttributeAssignment* getAttributeTranslation(sal_Int32 nAttributeToken);
335
343 sal_Int32 nAttributeToken, const OUString& _rPropertyName);
344
358 sal_Int32 nAttributeToken, const OUString& _rPropertyName,
359 const bool _bAttributeDefault, const bool _bInverseSemantics = false);
360
368 void addInt16Property(
369 sal_Int32 nAttributeToken, const OUString& _rPropertyName);
370
378 void addInt32Property(
379 sal_Int32 nAttributeToken, const OUString& _rPropertyName );
380
392 template<typename EnumT>
394 sal_Int32 nAttributeToken, const OUString& _rPropertyName,
395 const SvXMLEnumMapEntry<EnumT>* _pValueMap,
396 const css::uno::Type* _pType = nullptr)
397 {
398 addEnumPropertyImpl(nAttributeToken, _rPropertyName,
399 reinterpret_cast<const SvXMLEnumMapEntry<sal_uInt16>*>(_pValueMap), _pType);
400 }
401
402 private:
404 sal_Int32 nAttributeToken, const OUString& _rPropertyName,
405 const SvXMLEnumMapEntry<sal_uInt16>* _pValueMap,
406 const css::uno::Type* _pType);
408 AttributeAssignment& implAdd(
409 sal_Int32 nAttributeToken, const OUString& _rPropertyName,
410 const css::uno::Type& _rType);
411 };
412} // namespace xmloff
413
414/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
some kind of opposite to the OAttributeMetaData class.
void addEnumProperty(sal_Int32 nAttributeToken, const OUString &_rPropertyName, const SvXMLEnumMapEntry< EnumT > *_pValueMap, const css::uno::Type *_pType=nullptr)
add an attribute assignment referring to an enum property to the map
void addInt16Property(sal_Int32 nAttributeToken, const OUString &_rPropertyName)
add an attribute assignment referring to an int16 property to the map
void addStringProperty(sal_Int32 nAttributeToken, const OUString &_rPropertyName)
add an attribute assignment referring to a string property to the map
AttributeAssignment & implAdd(sal_Int32 nAttributeToken, const OUString &_rPropertyName, const css::uno::Type &_rType)
some common code for the various add*Property methods
void addBooleanProperty(sal_Int32 nAttributeToken, const OUString &_rPropertyName, const bool _bAttributeDefault, const bool _bInverseSemantics=false)
add an attribute assignment referring to a boolean property to the map
void addInt32Property(sal_Int32 nAttributeToken, const OUString &_rPropertyName)
add an attribute assignment referring to an int32 property to the map
std::map< sal_Int32, AttributeAssignment > m_aKnownProperties
void addEnumPropertyImpl(sal_Int32 nAttributeToken, const OUString &_rPropertyName, const SvXMLEnumMapEntry< sal_uInt16 > *_pValueMap, const css::uno::Type *_pType)
const AttributeAssignment * getAttributeTranslation(sal_Int32 nAttributeToken)
return the AttributeAssignment which corresponds to the given attribute
allows the translation of attribute ids into strings.
static OUString getBindingAttributeName(BAFlags _nId)
calculates the xml attribute representation of a binding attribute.
static OUString getFormAttributeName(FormAttributes _eAttrib)
retrieves the name of an attribute of a form xml representation
static sal_uInt16 getSpecialAttributeNamespace(SCAFlags _nId)
calculates the xml namespace key to use for a special attribute.
static OUString getSpecialAttributeName(SCAFlags _nId)
calculates the xml attribute representation of a special attribute.
static sal_uInt16 getFormAttributeNamespace(FormAttributes _eAttrib)
calculates the xml namespace key to use for an attribute of a form xml representation
static sal_Int32 getFormAttributeToken(FormAttributes _eAttrib)
retrieves the name of an attribute of a form xml representation
static xmloff::token::XMLTokenEnum getOfficeFormsAttributeToken(OfficeFormsAttributes _eAttrib)
static sal_uInt16 getDatabaseAttributeNamespace()
calculates the xml namespace key to use for a database attribute.
static OUString getCommonControlAttributeName(CCAFlags _nId)
calculates the xml attribute representation of a common control attribute.
static sal_Int32 getCommonControlAttributeToken(CCAFlags _nId)
calculates the xml attribute representation of a common control attribute.
static OUString getDatabaseAttributeName(DAFlags _nId)
calculates the xml attribute representation of a database attribute.
static OUString getOfficeFormsAttributeName(OfficeFormsAttributes _eAttrib)
calculates the xml attribute representation of an attribute of the office:forms element
static sal_uInt16 getOfficeFormsAttributeNamespace()
calculates the xml namedspace key of an attribute of the office:forms element
static sal_Int32 getDatabaseAttributeToken(DAFlags _nId)
calculates the xml attribute representation of a database attribute.
static sal_uInt16 getBindingAttributeNamespace()
calculates the xml namespace key to use for a binding attribute.
static sal_Int32 getSpecialAttributeToken(SCAFlags _nId)
calculates the xml attribute representation of a special attribute.
static sal_Int32 getBindingAttributeToken(BAFlags _nId)
calculates the xml attribute representation of a binding attribute.
static sal_uInt16 getCommonControlAttributeNamespace(CCAFlags _nId)
calculates the xml namespace key to use for a common control attribute
SCAFlags
@ ColumnStyleName
@ AutoCompletion
DAFlags
@ ListSource_TYPE
@ ConvertEmpty
@ InputRequired
BAFlags
@ ListLinkingType
@ ListCellRange
@ XFormsSubmission
@ XFormsListBind
EAFlags
@ ControlEvents
@ OnDoubleClick
CCAFlags
@ TargetLocation
@ CurrentSelected
NONE
Value
Title
State
XMLTokenEnum
The enumeration of all XML tokens.
Definition: xmltoken.hxx:50
@ ofaApplyDesignMode
FormAttributes
attributes in the xml tag representing a form
@ faEscapeProcessing
Orientation
const SvXMLEnumMapEntry< sal_uInt16 > * pEnumMap
OUString Name
ButtonType
constexpr sal_uInt16 XML_NAMESPACE_FORM