1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: formenums.cxx,v $
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 //.........................................................................
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
] =
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
];
89 // the map for this property is not initialized yet
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
;
108 static SvXMLEnumMapEntry aSubmitMethodMap
[] =
110 { XML_GET
, FormSubmitMethod_GET
},
111 { XML_POST
, FormSubmitMethod_POST
},
112 { XML_TOKEN_INVALID
, 0 }
114 rReturn
= aSubmitMethodMap
;
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
;
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
;
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
;
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
;
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
;
186 // check state of a checkbox
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
;
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
;
215 static SvXMLEnumMapEntry aBorderTypeMap
[] =
227 { XML_TOKEN_INVALID
, 0 }
229 rReturn
= aBorderTypeMap
;
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
;
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
;
261 case epListLinkageType
:
263 static SvXMLEnumMapEntry aListLinkageMap
[] =
265 { XML_SELECTION
, 0 },
266 { XML_SELECTION_INDEXES
, 1 },
267 { XML_TOKEN_INVALID
, 0 }
269 rReturn
= aListLinkageMap
;
275 static SvXMLEnumMapEntry aOrientationMap
[] =
277 { XML_HORIZONTAL
, ScrollBarOrientation::HORIZONTAL
},
278 { XML_VERTICAL
, ScrollBarOrientation::VERTICAL
},
279 { XML_TOKEN_INVALID
, 0 }
281 rReturn
= aOrientationMap
;
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
;
298 case epImagePosition
:
300 static SvXMLEnumMapEntry aImagePositionMap
[] =
306 { XML_CENTER
, (sal_uInt16
)-1 },
307 { XML_TOKEN_INVALID
, 0 }
309 rReturn
= aImagePositionMap
;
315 static SvXMLEnumMapEntry aImageAlignMap
[] =
320 { XML_TOKEN_INVALID
, 0 }
322 rReturn
= aImageAlignMap
;
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
;
340 case KNOWN_ENUM_PROPERTIES
:
348 //.........................................................................
349 } // namespace xmloff
350 //.........................................................................