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_xmlscript.hxx" 30 #include "exp_share.hxx" 31 32 #include <rtl/ustrbuf.hxx> 33 #include <tools/diagnose_ex.h> 34 35 #include <com/sun/star/awt/CharSet.hpp> 36 #include <com/sun/star/awt/FontFamily.hpp> 37 #include <com/sun/star/awt/FontPitch.hpp> 38 #include <com/sun/star/awt/FontSlant.hpp> 39 #include <com/sun/star/awt/FontStrikeout.hpp> 40 #include <com/sun/star/awt/FontType.hpp> 41 #include <com/sun/star/awt/FontUnderline.hpp> 42 #include <com/sun/star/awt/FontWeight.hpp> 43 #include <com/sun/star/awt/FontWidth.hpp> 44 #include <com/sun/star/awt/ImagePosition.hpp> 45 #include <com/sun/star/awt/LineEndFormat.hpp> 46 #include <com/sun/star/awt/PushButtonType.hpp> 47 #include <com/sun/star/awt/VisualEffect.hpp> 48 49 #include <com/sun/star/script/XScriptEventsSupplier.hpp> 50 #include <com/sun/star/script/ScriptEventDescriptor.hpp> 51 52 #include <com/sun/star/style/VerticalAlignment.hpp> 53 54 #include <com/sun/star/lang/XServiceInfo.hpp> 55 #include <com/sun/star/lang/Locale.hpp> 56 #include <com/sun/star/util/NumberFormat.hpp> 57 58 #include <com/sun/star/view/SelectionType.hpp> 59 60 61 using namespace ::com::sun::star; 62 using namespace ::com::sun::star::uno; 63 using ::rtl::OUString; 64 using ::rtl::OUStringBuffer; 65 66 namespace xmlscript 67 { 68 69 //__________________________________________________________________________________________________ 70 Reference< xml::sax::XAttributeList > Style::createElement() 71 { 72 ElementDescriptor * pStyle = new ElementDescriptor( 73 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style") ) ); 74 75 // style-id 76 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ), _id ); 77 78 // background-color 79 if (_set & 0x1) 80 { 81 OUStringBuffer buf( 16 ); 82 buf.append( (sal_Unicode)'0' ); 83 buf.append( (sal_Unicode)'x' ); 84 buf.append( OUString::valueOf( (sal_Int64)(sal_uInt64)_backgroundColor, 16 ) ); 85 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":background-color") ), 86 buf.makeStringAndClear() ); 87 } 88 89 // text-color 90 if (_set & 0x2) 91 { 92 OUStringBuffer buf( 16 ); 93 buf.append( (sal_Unicode)'0' ); 94 buf.append( (sal_Unicode)'x' ); 95 buf.append( OUString::valueOf( (sal_Int64)(sal_uInt64)_textColor, 16 ) ); 96 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":text-color") ), 97 buf.makeStringAndClear() ); 98 } 99 100 // textline-color 101 if (_set & 0x20) 102 { 103 OUStringBuffer buf( 16 ); 104 buf.append( (sal_Unicode)'0' ); 105 buf.append( (sal_Unicode)'x' ); 106 buf.append( OUString::valueOf( (sal_Int64)(sal_uInt64)_textLineColor, 16 ) ); 107 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":textline-color") ), 108 buf.makeStringAndClear() ); 109 } 110 111 // fill-color 112 if (_set & 0x10) 113 { 114 OUStringBuffer buf( 16 ); 115 buf.append( (sal_Unicode)'0' ); 116 buf.append( (sal_Unicode)'x' ); 117 buf.append( OUString::valueOf( (sal_Int64)(sal_uInt64)_fillColor, 16 ) ); 118 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":fill-color") ), 119 buf.makeStringAndClear() ); 120 } 121 122 // border 123 if (_set & 0x4) 124 { 125 switch (_border) 126 { 127 case BORDER_NONE: 128 pStyle->addAttribute( OUSTR(XMLNS_DIALOGS_PREFIX ":border"), 129 OUSTR("none") ); 130 break; 131 case BORDER_3D: 132 pStyle->addAttribute( OUSTR(XMLNS_DIALOGS_PREFIX ":border"), 133 OUSTR("3d") ); 134 break; 135 case BORDER_SIMPLE: 136 pStyle->addAttribute( OUSTR(XMLNS_DIALOGS_PREFIX ":border"), 137 OUSTR("simple") ); 138 break; 139 case BORDER_SIMPLE_COLOR: { 140 OUStringBuffer buf; 141 buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("0x") ); 142 buf.append( OUString::valueOf( 143 (sal_Int64)(sal_uInt64)_borderColor, 16 ) ); 144 pStyle->addAttribute( OUSTR(XMLNS_DIALOGS_PREFIX ":border"), 145 buf.makeStringAndClear() ); 146 break; 147 } 148 default: 149 OSL_ENSURE( 0, "### unexpected border value!" ); 150 break; 151 } 152 } 153 154 // visual effect (look) 155 if (_set & 0x40) 156 { 157 switch (_visualEffect) 158 { 159 case awt::VisualEffect::NONE: 160 pStyle->addAttribute( OUSTR(XMLNS_DIALOGS_PREFIX ":look"), 161 OUSTR("none") ); 162 break; 163 case awt::VisualEffect::LOOK3D: 164 pStyle->addAttribute( OUSTR(XMLNS_DIALOGS_PREFIX ":look"), 165 OUSTR("3d") ); 166 break; 167 case awt::VisualEffect::FLAT: 168 pStyle->addAttribute( OUSTR(XMLNS_DIALOGS_PREFIX ":look"), 169 OUSTR("simple") ); 170 break; 171 default: 172 OSL_ENSURE( 0, "### unexpected visual effect value!" ); 173 break; 174 } 175 } 176 177 // font- 178 if (_set & 0x8) 179 { 180 awt::FontDescriptor def_descr; 181 182 // dialog:font-name CDATA #IMPLIED 183 if (def_descr.Name != _descr.Name) 184 { 185 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-name") ), 186 _descr.Name ); 187 } 188 // dialog:font-height %numeric; #IMPLIED 189 if (def_descr.Height != _descr.Height) 190 { 191 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-height") ), 192 OUString::valueOf( (sal_Int32)_descr.Height ) ); 193 } 194 // dialog:font-width %numeric; #IMPLIED 195 if (def_descr.Width != _descr.Width) 196 { 197 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-width") ), 198 OUString::valueOf( (sal_Int32)_descr.Width ) ); 199 } 200 // dialog:font-stylename CDATA #IMPLIED 201 if (def_descr.StyleName != _descr.StyleName) 202 { 203 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-stylename") ), 204 _descr.StyleName ); 205 } 206 // dialog:font-family "(decorative|modern|roman|script|swiss|system)" #IMPLIED 207 if (def_descr.Family != _descr.Family) 208 { 209 switch (_descr.Family) 210 { 211 case awt::FontFamily::DECORATIVE: 212 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-family") ), 213 OUString( RTL_CONSTASCII_USTRINGPARAM("decorative") ) ); 214 break; 215 case awt::FontFamily::MODERN: 216 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-family") ), 217 OUString( RTL_CONSTASCII_USTRINGPARAM("modern") ) ); 218 break; 219 case awt::FontFamily::ROMAN: 220 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-family") ), 221 OUString( RTL_CONSTASCII_USTRINGPARAM("roman") ) ); 222 break; 223 case awt::FontFamily::SCRIPT: 224 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-family") ), 225 OUString( RTL_CONSTASCII_USTRINGPARAM("script") ) ); 226 break; 227 case awt::FontFamily::SWISS: 228 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-family") ), 229 OUString( RTL_CONSTASCII_USTRINGPARAM("swiss") ) ); 230 break; 231 case awt::FontFamily::SYSTEM: 232 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-family") ), 233 OUString( RTL_CONSTASCII_USTRINGPARAM("system") ) ); 234 break; 235 default: 236 OSL_ENSURE( 0, "### unexpected font-family!" ); 237 break; 238 } 239 } 240 // dialog:font-charset "(ansi|mac|ibmpc_437|ibmpc_850|ibmpc_860|ibmpc_861|ibmpc_863|ibmpc_865|system|symbol)" #IMPLIED 241 if (def_descr.CharSet != _descr.CharSet) 242 { 243 switch (_descr.CharSet) 244 { 245 case awt::CharSet::ANSI: 246 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ), 247 OUString( RTL_CONSTASCII_USTRINGPARAM("ansi") ) ); 248 break; 249 case awt::CharSet::MAC: 250 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ), 251 OUString( RTL_CONSTASCII_USTRINGPARAM("mac") ) ); 252 break; 253 case awt::CharSet::IBMPC_437: 254 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ), 255 OUString( RTL_CONSTASCII_USTRINGPARAM("ibmpc_437") ) ); 256 break; 257 case awt::CharSet::IBMPC_850: 258 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ), 259 OUString( RTL_CONSTASCII_USTRINGPARAM("ibmpc_850") ) ); 260 break; 261 case awt::CharSet::IBMPC_860: 262 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ), 263 OUString( RTL_CONSTASCII_USTRINGPARAM("ibmpc_860") ) ); 264 break; 265 case awt::CharSet::IBMPC_861: 266 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ), 267 OUString( RTL_CONSTASCII_USTRINGPARAM("ibmpc_861") ) ); 268 break; 269 case awt::CharSet::IBMPC_863: 270 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ), 271 OUString( RTL_CONSTASCII_USTRINGPARAM("ibmpc_863") ) ); 272 break; 273 case awt::CharSet::IBMPC_865: 274 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ), 275 OUString( RTL_CONSTASCII_USTRINGPARAM("ibmpc_865") ) ); 276 break; 277 case awt::CharSet::SYSTEM: 278 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ), 279 OUString( RTL_CONSTASCII_USTRINGPARAM("system") ) ); 280 break; 281 case awt::CharSet::SYMBOL: 282 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ), 283 OUString( RTL_CONSTASCII_USTRINGPARAM("symbol") ) ); 284 break; 285 default: 286 OSL_ENSURE( 0, "### unexpected font-charset!" ); 287 break; 288 } 289 } 290 // dialog:font-pitch "(fixed|variable)" #IMPLIED 291 if (def_descr.Pitch != _descr.Pitch) 292 { 293 switch (_descr.Pitch) 294 { 295 case awt::FontPitch::FIXED: 296 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-pitch") ), 297 OUString( RTL_CONSTASCII_USTRINGPARAM("fixed") ) ); 298 break; 299 case awt::FontPitch::VARIABLE: 300 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-pitch") ), 301 OUString( RTL_CONSTASCII_USTRINGPARAM("variable") ) ); 302 break; 303 default: 304 OSL_ENSURE( 0, "### unexpected font-pitch!" ); 305 break; 306 } 307 } 308 // dialog:font-charwidth CDATA #IMPLIED 309 if (def_descr.CharacterWidth != _descr.CharacterWidth) 310 { 311 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charwidth") ), 312 OUString::valueOf( (float)_descr.CharacterWidth ) ); 313 } 314 // dialog:font-weight CDATA #IMPLIED 315 if (def_descr.Weight != _descr.Weight) 316 { 317 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-weight") ), 318 OUString::valueOf( (float)_descr.Weight ) ); 319 } 320 // dialog:font-slant "(oblique|italic|reverse_oblique|reverse_italic)" #IMPLIED 321 if (def_descr.Slant != _descr.Slant) 322 { 323 switch (_descr.Slant) 324 { 325 case awt::FontSlant_OBLIQUE: 326 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-slant") ), 327 OUString( RTL_CONSTASCII_USTRINGPARAM("oblique") ) ); 328 break; 329 case awt::FontSlant_ITALIC: 330 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-slant") ), 331 OUString( RTL_CONSTASCII_USTRINGPARAM("italic") ) ); 332 break; 333 case awt::FontSlant_REVERSE_OBLIQUE: 334 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-slant") ), 335 OUString( RTL_CONSTASCII_USTRINGPARAM("reverse_oblique") ) ); 336 break; 337 case awt::FontSlant_REVERSE_ITALIC: 338 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-slant") ), 339 OUString( RTL_CONSTASCII_USTRINGPARAM("reverse_italic") ) ); 340 break; 341 default: 342 OSL_ENSURE( 0, "### unexpected font-slant!" ); 343 break; 344 } 345 } 346 // dialog:font-underline "(single|double|dotted|dash|longdash|dashdot|dashdotdot|smallwave|wave|doublewave|bold|bolddotted|bolddash|boldlongdash|bolddashdot|bolddashdotdot|boldwave)" #IMPLIED 347 if (def_descr.Underline != _descr.Underline) 348 { 349 switch (_descr.Underline) 350 { 351 case awt::FontUnderline::SINGLE: 352 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ), 353 OUString( RTL_CONSTASCII_USTRINGPARAM("single") ) ); 354 break; 355 case awt::FontUnderline::DOUBLE: 356 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ), 357 OUString( RTL_CONSTASCII_USTRINGPARAM("double") ) ); 358 break; 359 case awt::FontUnderline::DOTTED: 360 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ), 361 OUString( RTL_CONSTASCII_USTRINGPARAM("dotted") ) ); 362 break; 363 case awt::FontUnderline::DASH: 364 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ), 365 OUString( RTL_CONSTASCII_USTRINGPARAM("dash") ) ); 366 break; 367 case awt::FontUnderline::LONGDASH: 368 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ), 369 OUString( RTL_CONSTASCII_USTRINGPARAM("longdash") ) ); 370 break; 371 case awt::FontUnderline::DASHDOT: 372 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ), 373 OUString( RTL_CONSTASCII_USTRINGPARAM("dashdot") ) ); 374 break; 375 case awt::FontUnderline::DASHDOTDOT: 376 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ), 377 OUString( RTL_CONSTASCII_USTRINGPARAM("dashdotdot") ) ); 378 break; 379 case awt::FontUnderline::SMALLWAVE: 380 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ), 381 OUString( RTL_CONSTASCII_USTRINGPARAM("smallwave") ) ); 382 break; 383 case awt::FontUnderline::WAVE: 384 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ), 385 OUString( RTL_CONSTASCII_USTRINGPARAM("wave") ) ); 386 break; 387 case awt::FontUnderline::DOUBLEWAVE: 388 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ), 389 OUString( RTL_CONSTASCII_USTRINGPARAM("doublewave") ) ); 390 break; 391 case awt::FontUnderline::BOLD: 392 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ), 393 OUString( RTL_CONSTASCII_USTRINGPARAM("bold") ) ); 394 break; 395 case awt::FontUnderline::BOLDDOTTED: 396 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ), 397 OUString( RTL_CONSTASCII_USTRINGPARAM("bolddotted") ) ); 398 break; 399 case awt::FontUnderline::BOLDDASH: 400 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ), 401 OUString( RTL_CONSTASCII_USTRINGPARAM("bolddash") ) ); 402 break; 403 case awt::FontUnderline::BOLDLONGDASH: 404 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ), 405 OUString( RTL_CONSTASCII_USTRINGPARAM("boldlongdash") ) ); 406 break; 407 case awt::FontUnderline::BOLDDASHDOT: 408 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ), 409 OUString( RTL_CONSTASCII_USTRINGPARAM("bolddashdot") ) ); 410 break; 411 case awt::FontUnderline::BOLDDASHDOTDOT: 412 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ), 413 OUString( RTL_CONSTASCII_USTRINGPARAM("bolddashdotdot") ) ); 414 break; 415 case awt::FontUnderline::BOLDWAVE: 416 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ), 417 OUString( RTL_CONSTASCII_USTRINGPARAM("boldwave") ) ); 418 break; 419 default: 420 OSL_ENSURE( 0, "### unexpected font-underline!" ); 421 break; 422 } 423 } 424 // dialog:font-strikeout "(single|double|bold|slash|x)" #IMPLIED 425 if (def_descr.Strikeout != _descr.Strikeout) 426 { 427 switch (_descr.Strikeout) 428 { 429 case awt::FontStrikeout::SINGLE: 430 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-strikeout") ), 431 OUString( RTL_CONSTASCII_USTRINGPARAM("single") ) ); 432 break; 433 case awt::FontStrikeout::DOUBLE: 434 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-strikeout") ), 435 OUString( RTL_CONSTASCII_USTRINGPARAM("double") ) ); 436 break; 437 case awt::FontStrikeout::BOLD: 438 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-strikeout") ), 439 OUString( RTL_CONSTASCII_USTRINGPARAM("bold") ) ); 440 break; 441 case awt::FontStrikeout::SLASH: 442 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-strikeout") ), 443 OUString( RTL_CONSTASCII_USTRINGPARAM("slash") ) ); 444 break; 445 case awt::FontStrikeout::X: 446 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-strikeout") ), 447 OUString( RTL_CONSTASCII_USTRINGPARAM("x") ) ); 448 break; 449 default: 450 OSL_ENSURE( 0, "### unexpected font-strikeout!" ); 451 break; 452 } 453 } 454 // dialog:font-orientation CDATA #IMPLIED 455 if (def_descr.Orientation != _descr.Orientation) 456 { 457 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-orientation") ), 458 OUString::valueOf( (float)_descr.Orientation ) ); 459 } 460 // dialog:font-kerning %boolean; #IMPLIED 461 if ((def_descr.Kerning != sal_False) != (_descr.Kerning != sal_False)) 462 { 463 pStyle->addBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-kerning") ), 464 _descr.Kerning ); 465 } 466 // dialog:font-wordlinemode %boolean; #IMPLIED 467 if ((def_descr.WordLineMode != sal_False) != (_descr.WordLineMode != sal_False)) 468 { 469 pStyle->addBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-wordlinemode") ), 470 _descr.WordLineMode ); 471 } 472 // dialog:font-type "(raster|device|scalable)" #IMPLIED 473 if (def_descr.Type != _descr.Type) 474 { 475 switch (_descr.Type) 476 { 477 case awt::FontType::RASTER: 478 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-type") ), 479 OUString( RTL_CONSTASCII_USTRINGPARAM("raster") ) ); 480 break; 481 case awt::FontType::DEVICE: 482 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-type") ), 483 OUString( RTL_CONSTASCII_USTRINGPARAM("device") ) ); 484 break; 485 case awt::FontType::SCALABLE: 486 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-type") ), 487 OUString( RTL_CONSTASCII_USTRINGPARAM("scalable") ) ); 488 break; 489 default: 490 OSL_ENSURE( 0, "### unexpected font-type!" ); 491 break; 492 } 493 } 494 495 // additional attributes not in FontDescriptor struct 496 // dialog:font-relief (none|embossed|engraved) #IMPLIED 497 switch (_fontRelief) 498 { 499 case awt::FontRelief::NONE: // dont export default 500 break; 501 case awt::FontRelief::EMBOSSED: 502 pStyle->addAttribute( 503 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-relief") ), 504 OUString( RTL_CONSTASCII_USTRINGPARAM("embossed") ) ); 505 break; 506 case awt::FontRelief::ENGRAVED: 507 pStyle->addAttribute( 508 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-relief") ), 509 OUString( RTL_CONSTASCII_USTRINGPARAM("engraved") ) ); 510 break; 511 default: 512 OSL_ENSURE( 0, "### unexpected font-relief!" ); 513 break; 514 } 515 // dialog:font-emphasismark (none|dot|circle|disc|accent|above|below) #IMPLIED 516 switch (_fontEmphasisMark) 517 { 518 case awt::FontEmphasisMark::NONE: // dont export default 519 break; 520 case awt::FontEmphasisMark::DOT: 521 pStyle->addAttribute( 522 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-emphasismark") ), 523 OUString( RTL_CONSTASCII_USTRINGPARAM("dot") ) ); 524 break; 525 case awt::FontEmphasisMark::CIRCLE: 526 pStyle->addAttribute( 527 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-emphasismark") ), 528 OUString( RTL_CONSTASCII_USTRINGPARAM("circle") ) ); 529 break; 530 case awt::FontEmphasisMark::DISC: 531 pStyle->addAttribute( 532 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-emphasismark") ), 533 OUString( RTL_CONSTASCII_USTRINGPARAM("disc") ) ); 534 break; 535 case awt::FontEmphasisMark::ACCENT: 536 pStyle->addAttribute( 537 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-emphasismark") ), 538 OUString( RTL_CONSTASCII_USTRINGPARAM("accent") ) ); 539 break; 540 case awt::FontEmphasisMark::ABOVE: 541 pStyle->addAttribute( 542 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-emphasismark") ), 543 OUString( RTL_CONSTASCII_USTRINGPARAM("above") ) ); 544 break; 545 case awt::FontEmphasisMark::BELOW: 546 pStyle->addAttribute( 547 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-emphasismark") ), 548 OUString( RTL_CONSTASCII_USTRINGPARAM("below") ) ); 549 break; 550 default: 551 OSL_ENSURE( 0, "### unexpected font-emphasismark!" ); 552 break; 553 } 554 } 555 556 return pStyle; 557 } 558 559 //################################################################################################## 560 561 //__________________________________________________________________________________________________ 562 void ElementDescriptor::addNumberFormatAttr( 563 Reference< beans::XPropertySet > const & xFormatProperties, 564 OUString const & /*rAttrName*/ ) 565 { 566 Reference< beans::XPropertyState > xState( xFormatProperties, UNO_QUERY ); 567 OUString sFormat; 568 lang::Locale locale; 569 OSL_VERIFY( xFormatProperties->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("FormatString") ) ) >>= sFormat ); 570 OSL_VERIFY( xFormatProperties->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Locale") ) ) >>= locale ); 571 572 addAttribute( 573 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":format-code") ), 574 sFormat ); 575 576 // format-locale 577 OUStringBuffer buf( 48 ); 578 buf.append( locale.Language ); 579 if (locale.Country.getLength()) 580 { 581 buf.append( (sal_Unicode)';' ); 582 buf.append( locale.Country ); 583 if (locale.Variant.getLength()) 584 { 585 buf.append( (sal_Unicode)';' ); 586 buf.append( locale.Variant ); 587 } 588 } 589 addAttribute( 590 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":format-locale") ), 591 buf.makeStringAndClear() ); 592 } 593 //__________________________________________________________________________________________________ 594 Any ElementDescriptor::readProp( OUString const & rPropName ) 595 { 596 if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName )) 597 { 598 return _xProps->getPropertyValue( rPropName ); 599 } 600 return Any(); 601 } 602 603 //______________________________________________________________________________ 604 void ElementDescriptor::readStringAttr( 605 OUString const & rPropName, OUString const & rAttrName ) 606 { 607 if (beans::PropertyState_DEFAULT_VALUE != 608 _xPropState->getPropertyState( rPropName )) 609 { 610 Any a( _xProps->getPropertyValue( rPropName ) ); 611 OUString v; 612 if (a >>= v) 613 addAttribute( rAttrName, v ); 614 else 615 OSL_ENSURE( 0, "### unexpected property type!" ); 616 } 617 } 618 619 //__________________________________________________________________________________________________ 620 void ElementDescriptor::readHexLongAttr( OUString const & rPropName, OUString const & rAttrName ) 621 { 622 if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName )) 623 { 624 Any a( _xProps->getPropertyValue( rPropName ) ); 625 if (a.getValueTypeClass() == TypeClass_LONG) 626 { 627 OUStringBuffer buf( 16 ); 628 buf.append( (sal_Unicode)'0' ); 629 buf.append( (sal_Unicode)'x' ); 630 buf.append( OUString::valueOf( (sal_Int64)(sal_uInt64)*(sal_uInt32 *)a.getValue(), 16 ) ); 631 addAttribute( rAttrName, buf.makeStringAndClear() ); 632 } 633 } 634 } 635 636 //__________________________________________________________________________________________________ 637 void ElementDescriptor::readDateFormatAttr( OUString const & rPropName, OUString const & rAttrName ) 638 { 639 if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName )) 640 { 641 Any a( _xProps->getPropertyValue( rPropName ) ); 642 if (a.getValueTypeClass() == TypeClass_SHORT) 643 { 644 switch (*(sal_Int16 const *)a.getValue()) 645 { 646 case 0: 647 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("system_short") ) ); 648 break; 649 case 1: 650 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("system_short_YY") ) ); 651 break; 652 case 2: 653 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("system_short_YYYY") ) ); 654 break; 655 case 3: 656 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("system_long") ) ); 657 break; 658 case 4: 659 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("short_DDMMYY") ) ); 660 break; 661 case 5: 662 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("short_MMDDYY") ) ); 663 break; 664 case 6: 665 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("short_YYMMDD") ) ); 666 break; 667 case 7: 668 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("short_DDMMYYYY") ) ); 669 break; 670 case 8: 671 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("short_MMDDYYYY") ) ); 672 break; 673 case 9: 674 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("short_YYYYMMDD") ) ); 675 break; 676 case 10: 677 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("short_YYMMDD_DIN5008") ) ); 678 break; 679 case 11: 680 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("short_YYYYMMDD_DIN5008") ) ); 681 break; 682 default: 683 OSL_ENSURE( 0, "### unexpected date format!" ); 684 break; 685 } 686 } 687 } 688 } 689 //__________________________________________________________________________________________________ 690 void ElementDescriptor::readTimeFormatAttr( OUString const & rPropName, OUString const & rAttrName ) 691 { 692 if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName )) 693 { 694 Any a( _xProps->getPropertyValue( rPropName ) ); 695 if (a.getValueTypeClass() == TypeClass_SHORT) 696 { 697 switch (*(sal_Int16 const *)a.getValue()) 698 { 699 case 0: 700 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("24h_short") ) ); 701 break; 702 case 1: 703 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("24h_long") ) ); 704 break; 705 case 2: 706 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("12h_short") ) ); 707 break; 708 case 3: 709 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("12h_long") ) ); 710 break; 711 case 4: 712 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("Duration_short") ) ); 713 break; 714 case 5: 715 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("Duration_long") ) ); 716 break; 717 default: 718 OSL_ENSURE( 0, "### unexpected time format!" ); 719 break; 720 } 721 } 722 } 723 } 724 //__________________________________________________________________________________________________ 725 void ElementDescriptor::readAlignAttr( OUString const & rPropName, OUString const & rAttrName ) 726 { 727 if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName )) 728 { 729 Any a( _xProps->getPropertyValue( rPropName ) ); 730 if (a.getValueTypeClass() == TypeClass_SHORT) 731 { 732 switch (*(sal_Int16 const *)a.getValue()) 733 { 734 case 0: 735 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("left") ) ); 736 break; 737 case 1: 738 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("center") ) ); 739 break; 740 case 2: 741 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("right") ) ); 742 break; 743 default: 744 OSL_ENSURE( 0, "### illegal alignment value!" ); 745 break; 746 } 747 } 748 } 749 } 750 //__________________________________________________________________________________________________ 751 void ElementDescriptor::readVerticalAlignAttr( OUString const & rPropName, OUString const & rAttrName ) 752 { 753 if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName )) 754 { 755 Any a( _xProps->getPropertyValue( rPropName ) ); 756 if (a.getValueTypeClass() == TypeClass_ENUM && a.getValueType() == ::getCppuType( (style::VerticalAlignment*)0 )) 757 { 758 style::VerticalAlignment eAlign; 759 a >>= eAlign; 760 switch (eAlign) 761 { 762 case style::VerticalAlignment_TOP: 763 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("top") ) ); 764 break; 765 case style::VerticalAlignment_MIDDLE: 766 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("center") ) ); 767 break; 768 case style::VerticalAlignment_BOTTOM: 769 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("bottom") ) ); 770 break; 771 default: 772 OSL_ENSURE( 0, "### illegal vertical alignment value!" ); 773 break; 774 } 775 } 776 } 777 } 778 //__________________________________________________________________________________________________ 779 void ElementDescriptor::readImageAlignAttr( OUString const & rPropName, OUString const & rAttrName ) 780 { 781 if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName )) 782 { 783 Any a( _xProps->getPropertyValue( rPropName ) ); 784 if (a.getValueTypeClass() == TypeClass_SHORT) 785 { 786 switch (*(sal_Int16 const *)a.getValue()) 787 { 788 case 0: 789 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("left") ) ); 790 break; 791 case 1: 792 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("top") ) ); 793 break; 794 case 2: 795 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("right") ) ); 796 break; 797 case 3: 798 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("bottom") ) ); 799 break; 800 default: 801 OSL_ENSURE( 0, "### illegal image alignment value!" ); 802 break; 803 } 804 } 805 } 806 } 807 //__________________________________________________________________________________________________ 808 void ElementDescriptor::readImagePositionAttr( OUString const & rPropName, OUString const & rAttrName ) 809 { 810 if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName )) 811 { 812 Any a( _xProps->getPropertyValue( rPropName ) ); 813 if (a.getValueTypeClass() == TypeClass_SHORT) 814 { 815 switch (*(sal_Int16 const *)a.getValue()) 816 { 817 case awt::ImagePosition::LeftTop: 818 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("left-top") ) ); 819 break; 820 case awt::ImagePosition::LeftCenter: 821 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("left-center") ) ); 822 break; 823 case awt::ImagePosition::LeftBottom: 824 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("left-bottom") ) ); 825 break; 826 case awt::ImagePosition::RightTop: 827 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("right-top") ) ); 828 break; 829 case awt::ImagePosition::RightCenter: 830 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("right-center") ) ); 831 break; 832 case awt::ImagePosition::RightBottom: 833 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("right-bottom") ) ); 834 break; 835 case awt::ImagePosition::AboveLeft: 836 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("top-left") ) ); 837 break; 838 case awt::ImagePosition::AboveCenter: 839 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("top-center") ) ); 840 break; 841 case awt::ImagePosition::AboveRight: 842 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("top-right") ) ); 843 break; 844 case awt::ImagePosition::BelowLeft: 845 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("bottom-left") ) ); 846 break; 847 case awt::ImagePosition::BelowCenter: 848 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("bottom-center") ) ); 849 break; 850 case awt::ImagePosition::BelowRight: 851 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("bottom-right") ) ); 852 break; 853 case awt::ImagePosition::Centered: 854 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("center") ) ); 855 break; 856 default: 857 OSL_ENSURE( 0, "### illegal image position value!" ); 858 break; 859 } 860 } 861 } 862 } 863 //__________________________________________________________________________________________________ 864 void ElementDescriptor::readButtonTypeAttr( OUString const & rPropName, OUString const & rAttrName ) 865 { 866 if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName )) 867 { 868 Any a( _xProps->getPropertyValue( rPropName ) ); 869 if (a.getValueTypeClass() == TypeClass_SHORT) 870 { 871 switch (*(sal_Int16 const *)a.getValue()) 872 { 873 case awt::PushButtonType_STANDARD: 874 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("standard") ) ); 875 break; 876 case awt::PushButtonType_OK: 877 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("ok") ) ); 878 break; 879 case awt::PushButtonType_CANCEL: 880 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("cancel") ) ); 881 break; 882 case awt::PushButtonType_HELP: 883 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("help") ) ); 884 break; 885 default: 886 OSL_ENSURE( 0, "### illegal button-type value!" ); 887 break; 888 } 889 } 890 } 891 } 892 //__________________________________________________________________________________________________ 893 void ElementDescriptor::readOrientationAttr( OUString const & rPropName, OUString const & rAttrName ) 894 { 895 if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName )) 896 { 897 Any a( _xProps->getPropertyValue( rPropName ) ); 898 if (a.getValueTypeClass() == TypeClass_LONG) 899 { 900 switch (*(sal_Int32 const *)a.getValue()) 901 { 902 case 0: 903 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("horizontal") ) ); 904 break; 905 case 1: 906 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("vertical") ) ); 907 break; 908 default: 909 OSL_ENSURE( 0, "### illegal orientation value!" ); 910 break; 911 } 912 } 913 } 914 } 915 //__________________________________________________________________________________________________ 916 void ElementDescriptor::readLineEndFormatAttr( OUString const & rPropName, OUString const & rAttrName ) 917 { 918 if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName )) 919 { 920 Any a( _xProps->getPropertyValue( rPropName ) ); 921 if (a.getValueTypeClass() == TypeClass_SHORT) 922 { 923 switch (*(sal_Int16 const *)a.getValue()) 924 { 925 case awt::LineEndFormat::CARRIAGE_RETURN: 926 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("carriage-return") ) ); 927 break; 928 case awt::LineEndFormat::LINE_FEED: 929 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("line-feed") ) ); 930 break; 931 case awt::LineEndFormat::CARRIAGE_RETURN_LINE_FEED: 932 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("carriage-return-line-feed") ) ); 933 break; 934 default: 935 OSL_ENSURE( 0, "### illegal line end format value!" ); 936 break; 937 } 938 } 939 } 940 } 941 //__________________________________________________________________________________________________ 942 void ElementDescriptor::readSelectionTypeAttr( OUString const & rPropName, OUString const & rAttrName ) 943 { 944 if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName )) 945 { 946 Any aSelectionType ( _xProps->getPropertyValue( rPropName ) ); 947 948 if (aSelectionType.getValueTypeClass() == TypeClass_ENUM && aSelectionType.getValueType() == ::getCppuType( (::view::SelectionType*)0 )) 949 { 950 ::view::SelectionType eSelectionType; 951 aSelectionType >>= eSelectionType; 952 953 switch (eSelectionType) 954 { 955 case ::view::SelectionType_NONE: 956 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("none") ) ); 957 break; 958 case ::view::SelectionType_SINGLE: 959 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("single") ) ); 960 break; 961 case ::view::SelectionType_MULTI: 962 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("multi") ) ); 963 break; 964 case ::view::SelectionType_RANGE: 965 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("range") ) ); 966 break; 967 default: 968 OSL_ENSURE( 0, "### illegal selection type value!" ); 969 break; 970 } 971 } 972 } 973 } 974 //__________________________________________________________________________________________________ 975 void ElementDescriptor::readDefaults( bool supportPrintable, bool supportVisible ) 976 { 977 Any a( _xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Name") ) ) ); 978 addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ), 979 * reinterpret_cast< const OUString * >( a.getValue() ) ); 980 readShortAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("TabIndex") ), 981 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":tab-index") ) ); 982 983 sal_Bool bEnabled = sal_False; 984 if (_xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Enabled") ) ) >>= bEnabled) 985 { 986 if (! bEnabled) 987 { 988 addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":disabled") ), 989 OUString( RTL_CONSTASCII_USTRINGPARAM("true") ) ); 990 } 991 } 992 else 993 { 994 OSL_ENSURE( 0, "unexpected property type for \"Enabled\": not bool!" ); 995 } 996 997 sal_Bool bVisible = sal_True; 998 if (supportVisible) try 999 { 1000 if (_xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("EnableVisible") ) ) >>= bVisible) 1001 { 1002 1003 // only write out the non default case 1004 if (! bVisible) 1005 { 1006 addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":visible") ), 1007 OUString( RTL_CONSTASCII_USTRINGPARAM("false") ) ); 1008 } 1009 } 1010 } 1011 catch( Exception& ) 1012 { 1013 DBG_UNHANDLED_EXCEPTION(); 1014 } 1015 // force writing of pos/size 1016 a = _xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("PositionX") ) ); 1017 if (a.getValueTypeClass() == TypeClass_LONG) 1018 { 1019 addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":left") ), 1020 OUString::valueOf( *(sal_Int32 const *)a.getValue() ) ); 1021 } 1022 a = _xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("PositionY") ) ); 1023 if (a.getValueTypeClass() == TypeClass_LONG) 1024 { 1025 addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":top") ), 1026 OUString::valueOf( *(sal_Int32 const *)a.getValue() ) ); 1027 } 1028 a = _xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Width") ) ); 1029 if (a.getValueTypeClass() == TypeClass_LONG) 1030 { 1031 addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":width") ), 1032 OUString::valueOf( *(sal_Int32 const *)a.getValue() ) ); 1033 } 1034 a = _xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Height") ) ); 1035 if (a.getValueTypeClass() == TypeClass_LONG) 1036 { 1037 addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":height") ), 1038 OUString::valueOf( *(sal_Int32 const *)a.getValue() ) ); 1039 } 1040 1041 if (supportPrintable) 1042 { 1043 readBoolAttr( 1044 OUString( RTL_CONSTASCII_USTRINGPARAM("Printable") ), 1045 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":printable") ) ); 1046 } 1047 readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Step") ), 1048 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":page") ) ); 1049 readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Tag") ), 1050 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":tag") ) ); 1051 readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("HelpText") ), 1052 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":help-text") ) ); 1053 readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("HelpURL") ), 1054 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":help-url") ) ); 1055 } 1056 1057 struct StringTriple 1058 { 1059 char const * first; 1060 char const * second; 1061 char const * third; 1062 }; 1063 extern StringTriple const * const g_pEventTranslations; 1064 1065 //__________________________________________________________________________________________________ 1066 void ElementDescriptor::readEvents() 1067 SAL_THROW( (Exception) ) 1068 { 1069 Reference< script::XScriptEventsSupplier > xSupplier( _xProps, UNO_QUERY ); 1070 if (xSupplier.is()) 1071 { 1072 Reference< container::XNameContainer > xEvents( xSupplier->getEvents() ); 1073 if (xEvents.is()) 1074 { 1075 Sequence< OUString > aNames( xEvents->getElementNames() ); 1076 OUString const * pNames = aNames.getConstArray(); 1077 for ( sal_Int32 nPos = 0; nPos < aNames.getLength(); ++nPos ) 1078 { 1079 script::ScriptEventDescriptor descr; 1080 if (xEvents->getByName( pNames[ nPos ] ) >>= descr) 1081 { 1082 OSL_ENSURE( descr.ListenerType.getLength() > 0 && 1083 descr.EventMethod.getLength() > 0 && 1084 descr.ScriptCode.getLength() > 0 && 1085 descr.ScriptType.getLength() > 0, 1086 "### invalid event descr!" ); 1087 1088 OUString aEventName; 1089 1090 if (! descr.AddListenerParam.getLength()) 1091 { 1092 // detection of event-name 1093 ::rtl::OString listenerType( 1094 ::rtl::OUStringToOString( 1095 descr.ListenerType, 1096 RTL_TEXTENCODING_ASCII_US ) ); 1097 ::rtl::OString eventMethod( 1098 ::rtl::OUStringToOString( 1099 descr.EventMethod, 1100 RTL_TEXTENCODING_ASCII_US ) ); 1101 StringTriple const * p = g_pEventTranslations; 1102 while (p->first) 1103 { 1104 if (0 == ::rtl_str_compare( p->second, eventMethod.getStr() ) && 1105 0 == ::rtl_str_compare( p->first, listenerType.getStr() )) 1106 { 1107 aEventName = OUString( p->third, ::rtl_str_getLength( p->third ), RTL_TEXTENCODING_ASCII_US ); 1108 break; 1109 } 1110 ++p; 1111 } 1112 } 1113 1114 ElementDescriptor * pElem; 1115 Reference< xml::sax::XAttributeList > xElem; 1116 1117 if (aEventName.getLength()) // script:event 1118 { 1119 pElem = new ElementDescriptor( 1120 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":event") ) ); 1121 xElem = pElem; 1122 1123 pElem->addAttribute( 1124 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":event-name") ), 1125 aEventName ); 1126 } 1127 else // script:listener-event 1128 { 1129 pElem = new ElementDescriptor( 1130 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":listener-event") ) ); 1131 xElem = pElem; 1132 1133 pElem->addAttribute( 1134 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":listener-type") ), 1135 descr.ListenerType ); 1136 pElem->addAttribute( 1137 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":listener-method") ), 1138 descr.EventMethod ); 1139 1140 if (descr.AddListenerParam.getLength()) 1141 { 1142 pElem->addAttribute( 1143 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":listener-param") ), 1144 descr.AddListenerParam ); 1145 } 1146 } 1147 if ( descr.ScriptType.equals( OUString( RTL_CONSTASCII_USTRINGPARAM( "StarBasic" ) ) ) ) 1148 { 1149 // separate optional location 1150 sal_Int32 nIndex = descr.ScriptCode.indexOf( (sal_Unicode)':' ); 1151 if (nIndex >= 0) 1152 { 1153 pElem->addAttribute( 1154 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":location") ), 1155 descr.ScriptCode.copy( 0, nIndex ) ); 1156 pElem->addAttribute( 1157 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":macro-name") ), 1158 descr.ScriptCode.copy( nIndex +1 ) ); 1159 } 1160 else 1161 { 1162 pElem->addAttribute( 1163 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":macro-name") ), 1164 descr.ScriptCode ); 1165 } 1166 } 1167 else 1168 { 1169 pElem->addAttribute( 1170 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":macro-name") ), 1171 descr.ScriptCode ); 1172 } 1173 1174 // language 1175 pElem->addAttribute( 1176 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":language") ), 1177 descr.ScriptType ); 1178 1179 addSubElement( xElem ); 1180 } 1181 else 1182 { 1183 OSL_ENSURE( 0, "### unexpected event type in container!" ); 1184 } 1185 } 1186 } 1187 } 1188 } 1189 1190 //################################################################################################## 1191 1192 inline bool equalFont( Style const & style1, Style const & style2 ) 1193 { 1194 awt::FontDescriptor const & f1 = style1._descr; 1195 awt::FontDescriptor const & f2 = style2._descr; 1196 return ( 1197 f1.Name == f2.Name && 1198 f1.Height == f2.Height && 1199 f1.Width == f2.Width && 1200 f1.StyleName == f2.StyleName && 1201 f1.Family == f2.Family && 1202 f1.CharSet == f2.CharSet && 1203 f1.Pitch == f2.CharSet && 1204 f1.CharacterWidth == f2.CharacterWidth && 1205 f1.Weight == f2.Weight && 1206 f1.Slant == f2.Slant && 1207 f1.Underline == f2.Underline && 1208 f1.Strikeout == f2.Strikeout && 1209 f1.Orientation == f2.Orientation && 1210 (f1.Kerning != sal_False) == (f2.Kerning != sal_False) && 1211 (f1.WordLineMode != sal_False) == (f2.WordLineMode != sal_False) && 1212 f1.Type == f2.Type && 1213 style1._fontRelief == style2._fontRelief && 1214 style1._fontEmphasisMark == style2._fontEmphasisMark 1215 ); 1216 } 1217 //__________________________________________________________________________________________________ 1218 OUString StyleBag::getStyleId( Style const & rStyle ) 1219 SAL_THROW( () ) 1220 { 1221 if (! rStyle._set) // nothin set 1222 { 1223 return OUString(); // everything default: no need to export a specific style 1224 } 1225 1226 // lookup existing style 1227 for ( size_t nStylesPos = 0; nStylesPos < _styles.size(); ++nStylesPos ) 1228 { 1229 Style * pStyle = _styles[ nStylesPos ]; 1230 1231 short demanded_defaults = ~rStyle._set & rStyle._all; 1232 // test, if defaults are not set 1233 if ((~pStyle->_set & demanded_defaults) == demanded_defaults && 1234 (rStyle._set & (pStyle->_all & ~pStyle->_set)) == 0) 1235 { 1236 short bset = rStyle._set & pStyle->_set; 1237 if ((bset & 0x1) && 1238 rStyle._backgroundColor != pStyle->_backgroundColor) 1239 continue; 1240 if ((bset & 0x2) && 1241 rStyle._textColor != pStyle->_textColor) 1242 continue; 1243 if ((bset & 0x20) && 1244 rStyle._textLineColor != pStyle->_textLineColor) 1245 continue; 1246 if ((bset & 0x10) && 1247 rStyle._fillColor != pStyle->_fillColor) 1248 continue; 1249 if ((bset & 0x4) && 1250 (rStyle._border != pStyle->_border || 1251 (rStyle._border == BORDER_SIMPLE_COLOR && 1252 rStyle._borderColor != pStyle->_borderColor))) 1253 continue; 1254 if ((bset & 0x8) && 1255 !equalFont( rStyle, *pStyle )) 1256 continue; 1257 if ((bset & 0x40) && 1258 rStyle._visualEffect != pStyle->_visualEffect) 1259 continue; 1260 1261 // merge in 1262 short bnset = rStyle._set & ~pStyle->_set; 1263 if (bnset & 0x1) 1264 pStyle->_backgroundColor = rStyle._backgroundColor; 1265 if (bnset & 0x2) 1266 pStyle->_textColor = rStyle._textColor; 1267 if (bnset & 0x20) 1268 pStyle->_textLineColor = rStyle._textLineColor; 1269 if (bnset & 0x10) 1270 pStyle->_fillColor = rStyle._fillColor; 1271 if (bnset & 0x4) { 1272 pStyle->_border = rStyle._border; 1273 pStyle->_borderColor = rStyle._borderColor; 1274 } 1275 if (bnset & 0x8) { 1276 pStyle->_descr = rStyle._descr; 1277 pStyle->_fontRelief = rStyle._fontRelief; 1278 pStyle->_fontEmphasisMark = rStyle._fontEmphasisMark; 1279 } 1280 if (bnset & 0x40) 1281 pStyle->_visualEffect = rStyle._visualEffect; 1282 1283 pStyle->_all |= rStyle._all; 1284 pStyle->_set |= rStyle._set; 1285 1286 return pStyle->_id; 1287 } 1288 } 1289 1290 // no appr style found, append new 1291 Style * pStyle = new Style( rStyle ); 1292 pStyle->_id = OUString::valueOf( (sal_Int32)_styles.size() ); 1293 _styles.push_back( pStyle ); 1294 return pStyle->_id; 1295 } 1296 //__________________________________________________________________________________________________ 1297 StyleBag::~StyleBag() SAL_THROW( () ) 1298 { 1299 for ( size_t nPos = 0; nPos < _styles.size(); ++nPos ) 1300 { 1301 delete _styles[ nPos ]; 1302 } 1303 } 1304 //__________________________________________________________________________________________________ 1305 void StyleBag::dump( Reference< xml::sax::XExtendedDocumentHandler > const & xOut ) 1306 { 1307 if (! _styles.empty()) 1308 { 1309 OUString aStylesName( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":styles") ); 1310 xOut->ignorableWhitespace( OUString() ); 1311 xOut->startElement( aStylesName, Reference< xml::sax::XAttributeList >() ); 1312 // export styles 1313 for ( size_t nPos = 0; nPos < _styles.size(); ++nPos ) 1314 { 1315 Reference< xml::sax::XAttributeList > xAttr( _styles[ nPos ]->createElement() ); 1316 static_cast< ElementDescriptor * >( xAttr.get() )->dump( xOut.get() ); 1317 } 1318 xOut->ignorableWhitespace( OUString() ); 1319 xOut->endElement( aStylesName ); 1320 } 1321 } 1322 1323 //################################################################################################## 1324 1325 //================================================================================================== 1326 void SAL_CALL exportDialogModel( 1327 Reference< xml::sax::XExtendedDocumentHandler > const & xOut, 1328 Reference< container::XNameContainer > const & xDialogModel ) 1329 SAL_THROW( (Exception) ) 1330 { 1331 StyleBag all_styles; 1332 ::std::vector< Reference< xml::sax::XAttributeList > > all_elements; 1333 1334 // read out all props 1335 1336 Sequence< OUString > aElements( xDialogModel->getElementNames() ); 1337 OUString const * pElements = aElements.getConstArray(); 1338 1339 ElementDescriptor * pRadioGroup = 0; 1340 1341 sal_Int32 nPos; 1342 for ( nPos = 0; nPos < aElements.getLength(); ++nPos ) 1343 { 1344 Any aControlModel( xDialogModel->getByName( pElements[ nPos ] ) ); 1345 Reference< beans::XPropertySet > xProps; 1346 OSL_VERIFY( aControlModel >>= xProps ); 1347 if (! xProps.is()) 1348 continue; 1349 Reference< beans::XPropertyState > xPropState( xProps, UNO_QUERY ); 1350 OSL_ENSURE( xPropState.is(), "no XPropertyState!" ); 1351 if (! xPropState.is()) 1352 continue; 1353 Reference< lang::XServiceInfo > xServiceInfo( xProps, UNO_QUERY ); 1354 OSL_ENSURE( xServiceInfo.is(), "no XServiceInfo!" ); 1355 if (! xServiceInfo.is()) 1356 continue; 1357 1358 ElementDescriptor * pElem = 0; 1359 Reference< xml::sax::XAttributeList > xElem; 1360 1361 // group up radio buttons 1362 if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlRadioButtonModel") ) ) ) 1363 { 1364 if (! pRadioGroup) // open radiogroup 1365 { 1366 pRadioGroup = new ElementDescriptor( 1367 xProps, xPropState, 1368 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":radiogroup") ) ); 1369 all_elements.push_back( pRadioGroup ); 1370 } 1371 1372 pElem = new ElementDescriptor( 1373 xProps, xPropState, 1374 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":radio") ) ); 1375 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1376 pElem->readRadioButtonModel( &all_styles ); 1377 pRadioGroup->addSubElement( xElem ); 1378 } 1379 else // no radio 1380 { 1381 pRadioGroup = 0; // close radiogroup 1382 1383 if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlButtonModel") ) ) ) 1384 { 1385 pElem = new ElementDescriptor( 1386 xProps, xPropState, 1387 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":button") ) ); 1388 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1389 pElem->readButtonModel( &all_styles ); 1390 } 1391 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlCheckBoxModel") ) ) ) 1392 { 1393 pElem = new ElementDescriptor( 1394 xProps, xPropState, 1395 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":checkbox") ) ); 1396 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1397 pElem->readCheckBoxModel( &all_styles ); 1398 } 1399 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlComboBoxModel") ) ) ) 1400 { 1401 pElem = new ElementDescriptor( 1402 xProps, xPropState, 1403 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":combobox") ) ); 1404 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1405 pElem->readComboBoxModel( &all_styles ); 1406 } 1407 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlListBoxModel") ) ) ) 1408 { 1409 pElem = new ElementDescriptor( 1410 xProps, xPropState, 1411 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":menulist") ) ); 1412 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1413 pElem->readListBoxModel( &all_styles ); 1414 } 1415 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlGroupBoxModel") ) ) ) 1416 { 1417 pElem = new ElementDescriptor( 1418 xProps, xPropState, 1419 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":titledbox") ) ); 1420 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1421 pElem->readGroupBoxModel( &all_styles ); 1422 } 1423 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedTextModel") ) ) ) 1424 { 1425 pElem = new ElementDescriptor( 1426 xProps, xPropState, 1427 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":text") ) ); 1428 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1429 pElem->readFixedTextModel( &all_styles ); 1430 } 1431 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlEditModel") ) ) ) 1432 { 1433 pElem = new ElementDescriptor( 1434 xProps, xPropState, 1435 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":textfield") ) ); 1436 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1437 pElem->readEditModel( &all_styles ); 1438 } 1439 // FixedHyperLink 1440 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedHyperlinkModel") ) ) ) 1441 { 1442 pElem = new ElementDescriptor( 1443 xProps, xPropState, 1444 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":linklabel") ) ); 1445 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1446 pElem->readFixedHyperLinkModel( &all_styles ); 1447 } 1448 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlImageControlModel") ) ) ) 1449 { 1450 pElem = new ElementDescriptor( 1451 xProps, xPropState, 1452 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":img") ) ); 1453 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1454 pElem->readImageControlModel( &all_styles ); 1455 } 1456 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFileControlModel") ) ) ) 1457 { 1458 pElem = new ElementDescriptor( 1459 xProps, xPropState, 1460 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":filecontrol") ) ); 1461 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1462 pElem->readFileControlModel( &all_styles ); 1463 } 1464 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.tree.TreeControlModel") ) ) ) 1465 { 1466 pElem = new ElementDescriptor( 1467 xProps, xPropState, 1468 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":treecontrol") ) ); 1469 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1470 pElem->readTreeControlModel( &all_styles ); 1471 } 1472 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlCurrencyFieldModel") ) ) ) 1473 { 1474 pElem = new ElementDescriptor( 1475 xProps, xPropState, 1476 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":currencyfield") ) ); 1477 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1478 pElem->readCurrencyFieldModel( &all_styles ); 1479 } 1480 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlDateFieldModel") ) ) ) 1481 { 1482 pElem = new ElementDescriptor( 1483 xProps, xPropState, 1484 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":datefield") ) ); 1485 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1486 pElem->readDateFieldModel( &all_styles ); 1487 } 1488 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlNumericFieldModel") ) ) ) 1489 { 1490 pElem = new ElementDescriptor( 1491 xProps, xPropState, 1492 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":numericfield") ) ); 1493 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1494 pElem->readNumericFieldModel( &all_styles ); 1495 } 1496 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlTimeFieldModel") ) ) ) 1497 { 1498 pElem = new ElementDescriptor( 1499 xProps, xPropState, 1500 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":timefield") ) ); 1501 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1502 pElem->readTimeFieldModel( &all_styles ); 1503 } 1504 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlPatternFieldModel") ) ) ) 1505 { 1506 pElem = new ElementDescriptor( 1507 xProps, xPropState, 1508 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":patternfield") ) ); 1509 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1510 pElem->readPatternFieldModel( &all_styles ); 1511 } 1512 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFormattedFieldModel") ) ) ) 1513 { 1514 pElem = new ElementDescriptor( 1515 xProps, xPropState, 1516 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":formattedfield") ) ); 1517 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1518 pElem->readFormattedFieldModel( &all_styles ); 1519 } 1520 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedLineModel") ) ) ) 1521 { 1522 pElem = new ElementDescriptor( 1523 xProps, xPropState, 1524 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":fixedline") ) ); 1525 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1526 pElem->readFixedLineModel( &all_styles ); 1527 } 1528 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlScrollBarModel") ) ) ) 1529 { 1530 pElem = new ElementDescriptor( 1531 xProps, xPropState, 1532 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":scrollbar") ) ); 1533 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1534 pElem->readScrollBarModel( &all_styles ); 1535 } 1536 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlProgressBarModel") ) ) ) 1537 { 1538 pElem = new ElementDescriptor( 1539 xProps, xPropState, 1540 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":progressmeter") ) ); 1541 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1542 pElem->readProgressBarModel( &all_styles ); 1543 } 1544 // 1545 1546 OSL_ASSERT( xElem.is() ); 1547 if (xElem.is()) 1548 { 1549 all_elements.push_back( xElem ); 1550 } 1551 else 1552 { 1553 OSL_ENSURE( sal_False, "unknown control type!" ); 1554 continue; 1555 } 1556 } 1557 } 1558 1559 xOut->startDocument(); 1560 1561 OUString aDocTypeStr( RTL_CONSTASCII_USTRINGPARAM( 1562 "<!DOCTYPE dlg:window PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\"" 1563 " \"dialog.dtd\">" ) ); 1564 xOut->unknown( aDocTypeStr ); 1565 xOut->ignorableWhitespace( OUString() ); 1566 1567 // window 1568 Reference< beans::XPropertySet > xProps( xDialogModel, UNO_QUERY ); 1569 OSL_ASSERT( xProps.is() ); 1570 Reference< beans::XPropertyState > xPropState( xProps, UNO_QUERY ); 1571 OSL_ASSERT( xPropState.is() ); 1572 1573 OUString aWindowName( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":window") ); 1574 ElementDescriptor * pWindow = new ElementDescriptor( xProps, xPropState, aWindowName ); 1575 Reference< xml::sax::XAttributeList > xWindow( pWindow ); 1576 pWindow->readDialogModel( &all_styles ); 1577 xOut->ignorableWhitespace( OUString() ); 1578 xOut->startElement( aWindowName, xWindow ); 1579 // dump out events 1580 pWindow->dumpSubElements( xOut.get() ); 1581 // dump out stylebag 1582 all_styles.dump( xOut ); 1583 1584 if (! all_elements.empty()) 1585 { 1586 // open up bulletinboard 1587 OUString aBBoardName( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":bulletinboard") ); 1588 xOut->ignorableWhitespace( OUString() ); 1589 xOut->startElement( aBBoardName, Reference< xml::sax::XAttributeList >() ); 1590 1591 // export control elements 1592 for ( std::size_t n = 0; n < all_elements.size(); ++n ) 1593 { 1594 ElementDescriptor * pElem = static_cast< ElementDescriptor * >( all_elements[ n ].get() ); 1595 pElem->dump( xOut.get() ); 1596 } 1597 1598 // end bulletinboard 1599 xOut->ignorableWhitespace( OUString() ); 1600 xOut->endElement( aBBoardName ); 1601 } 1602 1603 // end window 1604 xOut->ignorableWhitespace( OUString() ); 1605 xOut->endElement( aWindowName ); 1606 1607 xOut->endDocument(); 1608 } 1609 1610 } 1611