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