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