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