Update ooo320-m1
[ooovba.git] / xmloff / source / forms / formenums.cxx
blob90efb4b39c6d06da07e8a42dd1cc2a5be30f437b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: formenums.cxx,v $
10 * $Revision: 1.17 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
33 #include "formenums.hxx"
34 #include <osl/diagnose.h>
35 #include <com/sun/star/form/FormSubmitEncoding.hpp>
36 #include <com/sun/star/form/FormSubmitMethod.hpp>
37 #include <com/sun/star/sdb/CommandType.hpp>
38 #include <com/sun/star/form/NavigationBarMode.hpp>
39 #include <com/sun/star/form/TabulatorCycle.hpp>
40 #include <com/sun/star/form/FormButtonType.hpp>
41 #include <com/sun/star/form/ListSourceType.hpp>
42 #include <com/sun/star/awt/TextAlign.hpp>
43 #include <com/sun/star/awt/FontWidth.hpp>
44 #include <com/sun/star/awt/FontEmphasisMark.hpp>
45 #include <com/sun/star/awt/FontRelief.hpp>
46 #include <com/sun/star/awt/ScrollBarOrientation.hpp>
47 #include <com/sun/star/awt/VisualEffect.hpp>
48 #include <com/sun/star/awt/ImageScaleMode.hpp>
49 #include <vcl/wintypes.hxx> // for check states
50 #include <xmloff/xmltoken.hxx>
52 //.........................................................................
53 namespace xmloff
55 //.........................................................................
57 using namespace ::com::sun::star::form;
58 using namespace ::com::sun::star::sdb;
59 using namespace ::com::sun::star::awt;
60 using namespace ::xmloff::token;
62 const SvXMLEnumMapEntry* OEnumMapper::s_pEnumMap[OEnumMapper::KNOWN_ENUM_PROPERTIES] =
64 NULL,
65 NULL,
66 NULL,
67 NULL,
68 NULL,
69 NULL,
70 NULL,
71 NULL,
72 NULL,
73 NULL,
74 NULL,
75 NULL,
76 NULL,
77 NULL,
78 NULL
81 //---------------------------------------------------------------------
82 const SvXMLEnumMapEntry* OEnumMapper::getEnumMap(EnumProperties _eProperty)
84 OSL_ENSURE(_eProperty < KNOWN_ENUM_PROPERTIES, "OEnumMapper::getEnumMap: invalid index (this will crash)!");
86 const SvXMLEnumMapEntry*& rReturn = s_pEnumMap[_eProperty];
87 if (!rReturn)
89 // the map for this property is not initialized yet
90 switch (_eProperty)
92 // FormSubmitEncoding
93 case epSubmitEncoding:
95 static SvXMLEnumMapEntry aSubmitEncodingMap[] =
97 { XML_APPLICATION_X_WWW_FORM_URLENCODED, FormSubmitEncoding_URL },
98 { XML_MULTIPART_FORMDATA, FormSubmitEncoding_MULTIPART },
99 { XML_APPLICATION_TEXT, FormSubmitEncoding_TEXT },
100 { XML_TOKEN_INVALID, 0 }
102 rReturn = aSubmitEncodingMap;
104 break;
105 // FormSubmitMethod
106 case epSubmitMethod:
108 static SvXMLEnumMapEntry aSubmitMethodMap[] =
110 { XML_GET, FormSubmitMethod_GET },
111 { XML_POST, FormSubmitMethod_POST },
112 { XML_TOKEN_INVALID, 0 }
114 rReturn = aSubmitMethodMap;
116 break;
117 // CommandType
118 case epCommandType:
120 static SvXMLEnumMapEntry aCommandTypeMap[] =
122 { XML_TABLE, CommandType::TABLE },
123 { XML_QUERY, CommandType::QUERY },
124 { XML_COMMAND, CommandType::COMMAND },
125 { XML_TOKEN_INVALID, 0 }
127 rReturn = aCommandTypeMap;
129 break;
130 // NavigationBarMode
131 case epNavigationType:
133 static SvXMLEnumMapEntry aNavigationTypeMap[] =
135 { XML_NONE, NavigationBarMode_NONE },
136 { XML_CURRENT, NavigationBarMode_CURRENT },
137 { XML_PARENT, NavigationBarMode_PARENT },
138 { XML_TOKEN_INVALID, 0 }
140 rReturn = aNavigationTypeMap;
142 break;
143 // TabulatorCycle
144 case epTabCyle:
146 static SvXMLEnumMapEntry aTabulytorCycleMap[] =
148 { XML_RECORDS, TabulatorCycle_RECORDS },
149 { XML_CURRENT, TabulatorCycle_CURRENT },
150 { XML_PAGE, TabulatorCycle_PAGE },
151 { XML_TOKEN_INVALID, 0 }
153 rReturn = aTabulytorCycleMap;
155 break;
156 // FormButtonType
157 case epButtonType:
159 static SvXMLEnumMapEntry aFormButtonTypeMap[] =
161 { XML_PUSH, FormButtonType_PUSH },
162 { XML_SUBMIT, FormButtonType_SUBMIT },
163 { XML_RESET, FormButtonType_RESET },
164 { XML_URL, FormButtonType_URL },
165 { XML_TOKEN_INVALID, 0 }
167 rReturn = aFormButtonTypeMap;
169 break;
170 // ListSourceType
171 case epListSourceType:
173 static SvXMLEnumMapEntry aListSourceTypeMap[] =
175 { XML_VALUE_LIST, ListSourceType_VALUELIST },
176 { XML_TABLE, ListSourceType_TABLE },
177 { XML_QUERY, ListSourceType_QUERY },
178 { XML_SQL, ListSourceType_SQL },
179 { XML_SQL_PASS_THROUGH, ListSourceType_SQLPASSTHROUGH },
180 { XML_TABLE_FIELDS, ListSourceType_TABLEFIELDS },
181 { XML_TOKEN_INVALID, 0 }
183 rReturn = aListSourceTypeMap;
185 break;
186 // check state of a checkbox
187 case epCheckState:
189 static SvXMLEnumMapEntry aCheckStateMap[] =
191 { XML_UNCHECKED, STATE_NOCHECK },
192 { XML_CHECKED, STATE_CHECK },
193 { XML_UNKNOWN, STATE_DONTKNOW },
194 { XML_TOKEN_INVALID, 0 }
196 rReturn = aCheckStateMap;
198 break;
199 case epTextAlign:
201 static SvXMLEnumMapEntry aTextAlignMap[] =
203 { XML_START, TextAlign::LEFT },
204 { XML_CENTER, TextAlign::CENTER },
205 { XML_END, TextAlign::RIGHT },
206 { XML_JUSTIFY, (sal_uInt16)-1 },
207 { XML_JUSTIFIED, (sal_uInt16)-1 },
208 { XML_TOKEN_INVALID, 0 }
210 rReturn = aTextAlignMap;
212 break;
213 case epBorderWidth:
215 static SvXMLEnumMapEntry aBorderTypeMap[] =
217 { XML_NONE, 0 },
218 { XML_HIDDEN, 0 },
219 { XML_SOLID, 2 },
220 { XML_DOUBLE, 2 },
221 { XML_DOTTED, 2 },
222 { XML_DASHED, 2 },
223 { XML_GROOVE, 1 },
224 { XML_RIDGE, 1 },
225 { XML_INSET, 1 },
226 { XML_OUTSET, 1 },
227 { XML_TOKEN_INVALID, 0 }
229 rReturn = aBorderTypeMap;
231 break;
233 case epFontEmphasis:
235 static SvXMLEnumMapEntry aFontEmphasisMap[] =
237 { XML_NONE, FontEmphasisMark::NONE },
238 { XML_DOT, FontEmphasisMark::DOT },
239 { XML_CIRCLE, FontEmphasisMark::CIRCLE },
240 { XML_DISC, FontEmphasisMark::DISC },
241 { XML_ACCENT, FontEmphasisMark::ACCENT },
242 { XML_TOKEN_INVALID, 0 }
244 rReturn = aFontEmphasisMap;
246 break;
248 case epFontRelief:
250 static SvXMLEnumMapEntry aFontReliefMap[] =
252 { XML_NONE, FontRelief::NONE },
253 { XML_ENGRAVED, FontRelief::ENGRAVED },
254 { XML_EMBOSSED, FontRelief::EMBOSSED },
255 { XML_TOKEN_INVALID, 0 }
257 rReturn = aFontReliefMap;
259 break;
261 case epListLinkageType:
263 static SvXMLEnumMapEntry aListLinkageMap[] =
265 { XML_SELECTION, 0 },
266 { XML_SELECTION_INDEXES, 1 },
267 { XML_TOKEN_INVALID, 0 }
269 rReturn = aListLinkageMap;
271 break;
273 case epOrientation:
275 static SvXMLEnumMapEntry aOrientationMap[] =
277 { XML_HORIZONTAL, ScrollBarOrientation::HORIZONTAL },
278 { XML_VERTICAL, ScrollBarOrientation::VERTICAL },
279 { XML_TOKEN_INVALID, 0 }
281 rReturn = aOrientationMap;
283 break;
285 case epVisualEffect:
287 static SvXMLEnumMapEntry aVisualEffectMap[] =
289 { XML_NONE, VisualEffect::NONE },
290 { XML_3D, VisualEffect::LOOK3D },
291 { XML_FLAT, VisualEffect::FLAT },
292 { XML_TOKEN_INVALID, 0 }
294 rReturn = aVisualEffectMap;
296 break;
298 case epImagePosition:
300 static SvXMLEnumMapEntry aImagePositionMap[] =
302 { XML_START, 0 },
303 { XML_END, 1 },
304 { XML_TOP, 2 },
305 { XML_BOTTOM, 3 },
306 { XML_CENTER, (sal_uInt16)-1 },
307 { XML_TOKEN_INVALID, 0 }
309 rReturn = aImagePositionMap;
311 break;
313 case epImageAlign:
315 static SvXMLEnumMapEntry aImageAlignMap[] =
317 { XML_START, 0 },
318 { XML_CENTER, 1 },
319 { XML_END, 2 },
320 { XML_TOKEN_INVALID, 0 }
322 rReturn = aImageAlignMap;
324 break;
326 case epImageScaleMode:
328 static const SvXMLEnumMapEntry aScaleModeMap[] =
330 { XML_BACKGROUND_NO_REPEAT, ImageScaleMode::None },
331 { XML_REPEAT, ImageScaleMode::None }, // repeating the image is not supported
332 { XML_STRETCH, ImageScaleMode::Anisotropic },
333 { XML_SCALE, ImageScaleMode::Isotropic },
334 { XML_TOKEN_INVALID, ImageScaleMode::None }
336 rReturn = aScaleModeMap;
338 break;
340 case KNOWN_ENUM_PROPERTIES:
341 break;
345 return rReturn;
348 //.........................................................................
349 } // namespace xmloff
350 //.........................................................................