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