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