bump product version to 5.0.4.1
[LibreOffice.git] / xmloff / source / forms / formenums.cxx
blobecaba1cfd3dd31ad70a3430120612e16be0a91b0
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 #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>
39 namespace xmloff
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] =
50 NULL,
51 NULL,
52 NULL,
53 NULL,
54 NULL,
55 NULL,
56 NULL,
57 NULL,
58 NULL,
59 NULL,
60 NULL,
61 NULL,
62 NULL,
63 NULL,
64 NULL
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];
72 if (!rReturn)
74 // the map for this property is not initialized yet
75 switch (_eProperty)
77 // FormSubmitEncoding
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;
89 break;
90 // FormSubmitMethod
91 case epSubmitMethod:
93 static const SvXMLEnumMapEntry aSubmitMethodMap[] =
95 { XML_GET, FormSubmitMethod_GET },
96 { XML_POST, FormSubmitMethod_POST },
97 { XML_TOKEN_INVALID, 0 }
99 rReturn = aSubmitMethodMap;
101 break;
102 // CommandType
103 case epCommandType:
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;
114 break;
115 // NavigationBarMode
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;
127 break;
128 // TabulatorCycle
129 case epTabCyle:
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;
140 break;
141 // FormButtonType
142 case epButtonType:
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;
154 break;
155 // ListSourceType
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;
170 break;
171 // check state of a checkbox
172 case epCheckState:
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;
183 break;
184 case epTextAlign:
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;
197 break;
198 case epBorderWidth:
200 static const SvXMLEnumMapEntry aBorderTypeMap[] =
202 { XML_NONE, 0 },
203 { XML_HIDDEN, 0 },
204 { XML_SOLID, 2 },
205 { XML_DOUBLE, 2 },
206 { XML_DOTTED, 2 },
207 { XML_DASHED, 2 },
208 { XML_GROOVE, 1 },
209 { XML_RIDGE, 1 },
210 { XML_INSET, 1 },
211 { XML_OUTSET, 1 },
212 { XML_TOKEN_INVALID, 0 }
214 rReturn = aBorderTypeMap;
216 break;
218 case epFontEmphasis:
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;
231 break;
233 case epFontRelief:
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;
244 break;
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;
256 break;
258 case epOrientation:
260 static const SvXMLEnumMapEntry aOrientationMap[] =
262 { XML_HORIZONTAL, ScrollBarOrientation::HORIZONTAL },
263 { XML_VERTICAL, ScrollBarOrientation::VERTICAL },
264 { XML_TOKEN_INVALID, 0 }
266 rReturn = aOrientationMap;
268 break;
270 case epVisualEffect:
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;
281 break;
283 case epImagePosition:
285 static const SvXMLEnumMapEntry aImagePositionMap[] =
287 { XML_START, 0 },
288 { XML_END, 1 },
289 { XML_TOP, 2 },
290 { XML_BOTTOM, 3 },
291 { XML_CENTER, (sal_uInt16)-1 },
292 { XML_TOKEN_INVALID, 0 }
294 rReturn = aImagePositionMap;
296 break;
298 case epImageAlign:
300 static const SvXMLEnumMapEntry aImageAlignMap[] =
302 { XML_START, 0 },
303 { XML_CENTER, 1 },
304 { XML_END, 2 },
305 { XML_TOKEN_INVALID, 0 }
307 rReturn = aImageAlignMap;
309 break;
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;
323 break;
325 case KNOWN_ENUM_PROPERTIES:
326 break;
330 return rReturn;
333 } // namespace xmloff
335 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */