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 #include "formenums.hxx"
21 #include <osl/diagnose.h>
22 #include <com/sun/star/form/FormSubmitEncoding.hpp>
23 #include <com/sun/star/form/FormSubmitMethod.hpp>
24 #include <com/sun/star/sdb/CommandType.hpp>
25 #include <com/sun/star/form/NavigationBarMode.hpp>
26 #include <com/sun/star/form/TabulatorCycle.hpp>
27 #include <com/sun/star/form/FormButtonType.hpp>
28 #include <com/sun/star/form/ListSourceType.hpp>
29 #include <com/sun/star/awt/TextAlign.hpp>
30 #include <com/sun/star/awt/FontWidth.hpp>
31 #include <com/sun/star/awt/FontEmphasisMark.hpp>
32 #include <com/sun/star/awt/FontRelief.hpp>
33 #include <com/sun/star/awt/ScrollBarOrientation.hpp>
34 #include <com/sun/star/awt/VisualEffect.hpp>
35 #include <com/sun/star/awt/ImageScaleMode.hpp>
36 #include <tools/gen.hxx>
37 #include <xmloff/xmltoken.hxx>
42 using namespace ::com::sun::star::form
;
43 using namespace ::com::sun::star::sdb
;
44 using namespace ::com::sun::star::awt
;
45 using namespace ::com::sun::star
;
46 using namespace ::xmloff::token
;
48 const SvXMLEnumMapEntry
* OEnumMapper::s_pEnumMap
[OEnumMapper::KNOWN_ENUM_PROPERTIES
] =
67 const SvXMLEnumMapEntry
* OEnumMapper::getEnumMap(EnumProperties _eProperty
)
69 OSL_ENSURE(_eProperty
< KNOWN_ENUM_PROPERTIES
, "OEnumMapper::getEnumMap: invalid index (this will crash)!");
71 const SvXMLEnumMapEntry
*& rReturn
= s_pEnumMap
[_eProperty
];
74 // the map for this property is not initialized yet
78 case epSubmitEncoding
:
80 static const SvXMLEnumMapEntry aSubmitEncodingMap
[] =
82 { XML_APPLICATION_X_WWW_FORM_URLENCODED
, FormSubmitEncoding_URL
},
83 { XML_MULTIPART_FORMDATA
, FormSubmitEncoding_MULTIPART
},
84 { XML_APPLICATION_TEXT
, FormSubmitEncoding_TEXT
},
85 { XML_TOKEN_INVALID
, 0 }
87 rReturn
= aSubmitEncodingMap
;
93 static const SvXMLEnumMapEntry aSubmitMethodMap
[] =
95 { XML_GET
, FormSubmitMethod_GET
},
96 { XML_POST
, FormSubmitMethod_POST
},
97 { XML_TOKEN_INVALID
, 0 }
99 rReturn
= aSubmitMethodMap
;
105 static const SvXMLEnumMapEntry aCommandTypeMap
[] =
107 { XML_TABLE
, CommandType::TABLE
},
108 { XML_QUERY
, CommandType::QUERY
},
109 { XML_COMMAND
, CommandType::COMMAND
},
110 { XML_TOKEN_INVALID
, 0 }
112 rReturn
= aCommandTypeMap
;
116 case epNavigationType
:
118 static const SvXMLEnumMapEntry aNavigationTypeMap
[] =
120 { XML_NONE
, NavigationBarMode_NONE
},
121 { XML_CURRENT
, NavigationBarMode_CURRENT
},
122 { XML_PARENT
, NavigationBarMode_PARENT
},
123 { XML_TOKEN_INVALID
, 0 }
125 rReturn
= aNavigationTypeMap
;
131 static const SvXMLEnumMapEntry aTabulytorCycleMap
[] =
133 { XML_RECORDS
, TabulatorCycle_RECORDS
},
134 { XML_CURRENT
, TabulatorCycle_CURRENT
},
135 { XML_PAGE
, TabulatorCycle_PAGE
},
136 { XML_TOKEN_INVALID
, 0 }
138 rReturn
= aTabulytorCycleMap
;
144 static const SvXMLEnumMapEntry aFormButtonTypeMap
[] =
146 { XML_PUSH
, FormButtonType_PUSH
},
147 { XML_SUBMIT
, FormButtonType_SUBMIT
},
148 { XML_RESET
, FormButtonType_RESET
},
149 { XML_URL
, FormButtonType_URL
},
150 { XML_TOKEN_INVALID
, 0 }
152 rReturn
= aFormButtonTypeMap
;
156 case epListSourceType
:
158 static const SvXMLEnumMapEntry aListSourceTypeMap
[] =
160 { XML_VALUE_LIST
, ListSourceType_VALUELIST
},
161 { XML_TABLE
, ListSourceType_TABLE
},
162 { XML_QUERY
, ListSourceType_QUERY
},
163 { XML_SQL
, ListSourceType_SQL
},
164 { XML_SQL_PASS_THROUGH
, ListSourceType_SQLPASSTHROUGH
},
165 { XML_TABLE_FIELDS
, ListSourceType_TABLEFIELDS
},
166 { XML_TOKEN_INVALID
, 0 }
168 rReturn
= aListSourceTypeMap
;
171 // check state of a checkbox
174 static const SvXMLEnumMapEntry aCheckStateMap
[] =
176 { XML_UNCHECKED
, TRISTATE_FALSE
},
177 { XML_CHECKED
, TRISTATE_TRUE
},
178 { XML_UNKNOWN
, TRISTATE_INDET
},
179 { XML_TOKEN_INVALID
, 0 }
181 rReturn
= aCheckStateMap
;
186 static const SvXMLEnumMapEntry aTextAlignMap
[] =
188 { XML_START
, awt::TextAlign::LEFT
},
189 { XML_CENTER
, awt::TextAlign::CENTER
},
190 { XML_END
, awt::TextAlign::RIGHT
},
191 { XML_JUSTIFY
, (sal_uInt16
)-1 },
192 { XML_JUSTIFIED
, (sal_uInt16
)-1 },
193 { XML_TOKEN_INVALID
, 0 }
195 rReturn
= aTextAlignMap
;
200 static const SvXMLEnumMapEntry aBorderTypeMap
[] =
212 { XML_TOKEN_INVALID
, 0 }
214 rReturn
= aBorderTypeMap
;
220 static const SvXMLEnumMapEntry aFontEmphasisMap
[] =
222 { XML_NONE
, awt::FontEmphasisMark::NONE
},
223 { XML_DOT
, awt::FontEmphasisMark::DOT
},
224 { XML_CIRCLE
, awt::FontEmphasisMark::CIRCLE
},
225 { XML_DISC
, awt::FontEmphasisMark::DISC
},
226 { XML_ACCENT
, awt::FontEmphasisMark::ACCENT
},
227 { XML_TOKEN_INVALID
, 0 }
229 rReturn
= aFontEmphasisMap
;
235 static const SvXMLEnumMapEntry aFontReliefMap
[] =
237 { XML_NONE
, FontRelief::NONE
},
238 { XML_ENGRAVED
, FontRelief::ENGRAVED
},
239 { XML_EMBOSSED
, FontRelief::EMBOSSED
},
240 { XML_TOKEN_INVALID
, 0 }
242 rReturn
= aFontReliefMap
;
246 case epListLinkageType
:
248 static const SvXMLEnumMapEntry aListLinkageMap
[] =
250 { XML_SELECTION
, 0 },
251 { XML_SELECTION_INDEXES
, 1 },
252 { XML_TOKEN_INVALID
, 0 }
254 rReturn
= aListLinkageMap
;
260 static const SvXMLEnumMapEntry aOrientationMap
[] =
262 { XML_HORIZONTAL
, ScrollBarOrientation::HORIZONTAL
},
263 { XML_VERTICAL
, ScrollBarOrientation::VERTICAL
},
264 { XML_TOKEN_INVALID
, 0 }
266 rReturn
= aOrientationMap
;
272 static const SvXMLEnumMapEntry aVisualEffectMap
[] =
274 { XML_NONE
, VisualEffect::NONE
},
275 { XML_3D
, VisualEffect::LOOK3D
},
276 { XML_FLAT
, VisualEffect::FLAT
},
277 { XML_TOKEN_INVALID
, 0 }
279 rReturn
= aVisualEffectMap
;
283 case epImagePosition
:
285 static const SvXMLEnumMapEntry aImagePositionMap
[] =
291 { XML_CENTER
, (sal_uInt16
)-1 },
292 { XML_TOKEN_INVALID
, 0 }
294 rReturn
= aImagePositionMap
;
300 static const SvXMLEnumMapEntry aImageAlignMap
[] =
305 { XML_TOKEN_INVALID
, 0 }
307 rReturn
= aImageAlignMap
;
311 case epImageScaleMode
:
313 static const SvXMLEnumMapEntry aScaleModeMap
[] =
315 { XML_BACKGROUND_NO_REPEAT
, ImageScaleMode::NONE
},
316 { XML_REPEAT
, ImageScaleMode::NONE
}, // repeating the image is not supported
317 { XML_STRETCH
, ImageScaleMode::ANISOTROPIC
},
318 { XML_SCALE
, ImageScaleMode::ISOTROPIC
},
319 { XML_TOKEN_INVALID
, ImageScaleMode::NONE
}
321 rReturn
= aScaleModeMap
;
325 case KNOWN_ENUM_PROPERTIES
:
333 } // namespace xmloff
335 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */