1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/wintypes.hxx> // for check states
37 #include <xmloff/xmltoken.hxx>
39 //.........................................................................
42 //.........................................................................
44 using namespace ::com::sun::star::form
;
45 using namespace ::com::sun::star::sdb
;
46 using namespace ::com::sun::star::awt
;
47 using namespace ::com::sun::star
;
48 using namespace ::xmloff::token
;
50 const SvXMLEnumMapEntry
* OEnumMapper::s_pEnumMap
[OEnumMapper::KNOWN_ENUM_PROPERTIES
] =
69 //---------------------------------------------------------------------
70 const SvXMLEnumMapEntry
* OEnumMapper::getEnumMap(EnumProperties _eProperty
)
72 OSL_ENSURE(_eProperty
< KNOWN_ENUM_PROPERTIES
, "OEnumMapper::getEnumMap: invalid index (this will crash)!");
74 const SvXMLEnumMapEntry
*& rReturn
= s_pEnumMap
[_eProperty
];
77 // the map for this property is not initialized yet
81 case epSubmitEncoding
:
83 static SvXMLEnumMapEntry aSubmitEncodingMap
[] =
85 { XML_APPLICATION_X_WWW_FORM_URLENCODED
, FormSubmitEncoding_URL
},
86 { XML_MULTIPART_FORMDATA
, FormSubmitEncoding_MULTIPART
},
87 { XML_APPLICATION_TEXT
, FormSubmitEncoding_TEXT
},
88 { XML_TOKEN_INVALID
, 0 }
90 rReturn
= aSubmitEncodingMap
;
96 static SvXMLEnumMapEntry aSubmitMethodMap
[] =
98 { XML_GET
, FormSubmitMethod_GET
},
99 { XML_POST
, FormSubmitMethod_POST
},
100 { XML_TOKEN_INVALID
, 0 }
102 rReturn
= aSubmitMethodMap
;
108 static SvXMLEnumMapEntry aCommandTypeMap
[] =
110 { XML_TABLE
, CommandType::TABLE
},
111 { XML_QUERY
, CommandType::QUERY
},
112 { XML_COMMAND
, CommandType::COMMAND
},
113 { XML_TOKEN_INVALID
, 0 }
115 rReturn
= aCommandTypeMap
;
119 case epNavigationType
:
121 static SvXMLEnumMapEntry aNavigationTypeMap
[] =
123 { XML_NONE
, NavigationBarMode_NONE
},
124 { XML_CURRENT
, NavigationBarMode_CURRENT
},
125 { XML_PARENT
, NavigationBarMode_PARENT
},
126 { XML_TOKEN_INVALID
, 0 }
128 rReturn
= aNavigationTypeMap
;
134 static SvXMLEnumMapEntry aTabulytorCycleMap
[] =
136 { XML_RECORDS
, TabulatorCycle_RECORDS
},
137 { XML_CURRENT
, TabulatorCycle_CURRENT
},
138 { XML_PAGE
, TabulatorCycle_PAGE
},
139 { XML_TOKEN_INVALID
, 0 }
141 rReturn
= aTabulytorCycleMap
;
147 static SvXMLEnumMapEntry aFormButtonTypeMap
[] =
149 { XML_PUSH
, FormButtonType_PUSH
},
150 { XML_SUBMIT
, FormButtonType_SUBMIT
},
151 { XML_RESET
, FormButtonType_RESET
},
152 { XML_URL
, FormButtonType_URL
},
153 { XML_TOKEN_INVALID
, 0 }
155 rReturn
= aFormButtonTypeMap
;
159 case epListSourceType
:
161 static SvXMLEnumMapEntry aListSourceTypeMap
[] =
163 { XML_VALUE_LIST
, ListSourceType_VALUELIST
},
164 { XML_TABLE
, ListSourceType_TABLE
},
165 { XML_QUERY
, ListSourceType_QUERY
},
166 { XML_SQL
, ListSourceType_SQL
},
167 { XML_SQL_PASS_THROUGH
, ListSourceType_SQLPASSTHROUGH
},
168 { XML_TABLE_FIELDS
, ListSourceType_TABLEFIELDS
},
169 { XML_TOKEN_INVALID
, 0 }
171 rReturn
= aListSourceTypeMap
;
174 // check state of a checkbox
177 static SvXMLEnumMapEntry aCheckStateMap
[] =
179 { XML_UNCHECKED
, STATE_NOCHECK
},
180 { XML_CHECKED
, STATE_CHECK
},
181 { XML_UNKNOWN
, STATE_DONTKNOW
},
182 { XML_TOKEN_INVALID
, 0 }
184 rReturn
= aCheckStateMap
;
189 static SvXMLEnumMapEntry aTextAlignMap
[] =
191 { XML_START
, awt::TextAlign::LEFT
},
192 { XML_CENTER
, awt::TextAlign::CENTER
},
193 { XML_END
, awt::TextAlign::RIGHT
},
194 { XML_JUSTIFY
, (sal_uInt16
)-1 },
195 { XML_JUSTIFIED
, (sal_uInt16
)-1 },
196 { XML_TOKEN_INVALID
, 0 }
198 rReturn
= aTextAlignMap
;
203 static SvXMLEnumMapEntry aBorderTypeMap
[] =
215 { XML_TOKEN_INVALID
, 0 }
217 rReturn
= aBorderTypeMap
;
223 static SvXMLEnumMapEntry aFontEmphasisMap
[] =
225 { XML_NONE
, awt::FontEmphasisMark::NONE
},
226 { XML_DOT
, awt::FontEmphasisMark::DOT
},
227 { XML_CIRCLE
, awt::FontEmphasisMark::CIRCLE
},
228 { XML_DISC
, awt::FontEmphasisMark::DISC
},
229 { XML_ACCENT
, awt::FontEmphasisMark::ACCENT
},
230 { XML_TOKEN_INVALID
, 0 }
232 rReturn
= aFontEmphasisMap
;
238 static SvXMLEnumMapEntry aFontReliefMap
[] =
240 { XML_NONE
, FontRelief::NONE
},
241 { XML_ENGRAVED
, FontRelief::ENGRAVED
},
242 { XML_EMBOSSED
, FontRelief::EMBOSSED
},
243 { XML_TOKEN_INVALID
, 0 }
245 rReturn
= aFontReliefMap
;
249 case epListLinkageType
:
251 static SvXMLEnumMapEntry aListLinkageMap
[] =
253 { XML_SELECTION
, 0 },
254 { XML_SELECTION_INDEXES
, 1 },
255 { XML_TOKEN_INVALID
, 0 }
257 rReturn
= aListLinkageMap
;
263 static SvXMLEnumMapEntry aOrientationMap
[] =
265 { XML_HORIZONTAL
, ScrollBarOrientation::HORIZONTAL
},
266 { XML_VERTICAL
, ScrollBarOrientation::VERTICAL
},
267 { XML_TOKEN_INVALID
, 0 }
269 rReturn
= aOrientationMap
;
275 static SvXMLEnumMapEntry aVisualEffectMap
[] =
277 { XML_NONE
, VisualEffect::NONE
},
278 { XML_3D
, VisualEffect::LOOK3D
},
279 { XML_FLAT
, VisualEffect::FLAT
},
280 { XML_TOKEN_INVALID
, 0 }
282 rReturn
= aVisualEffectMap
;
286 case epImagePosition
:
288 static SvXMLEnumMapEntry aImagePositionMap
[] =
294 { XML_CENTER
, (sal_uInt16
)-1 },
295 { XML_TOKEN_INVALID
, 0 }
297 rReturn
= aImagePositionMap
;
303 static SvXMLEnumMapEntry aImageAlignMap
[] =
308 { XML_TOKEN_INVALID
, 0 }
310 rReturn
= aImageAlignMap
;
314 case epImageScaleMode
:
316 static const SvXMLEnumMapEntry aScaleModeMap
[] =
318 { XML_BACKGROUND_NO_REPEAT
, ImageScaleMode::None
},
319 { XML_REPEAT
, ImageScaleMode::None
}, // repeating the image is not supported
320 { XML_STRETCH
, ImageScaleMode::Anisotropic
},
321 { XML_SCALE
, ImageScaleMode::Isotropic
},
322 { XML_TOKEN_INVALID
, ImageScaleMode::None
}
324 rReturn
= aScaleModeMap
;
328 case KNOWN_ENUM_PROPERTIES
:
336 //.........................................................................
337 } // namespace xmloff
338 //.........................................................................
340 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */