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 { 1095 Reference< script::XScriptEventsSupplier > xSupplier( _xProps, UNO_QUERY ); 1096 if (xSupplier.is()) 1097 { 1098 Reference< container::XNameContainer > xEvents( xSupplier->getEvents() ); 1099 if (xEvents.is()) 1100 { 1101 Sequence< OUString > aNames( xEvents->getElementNames() ); 1102 OUString const * pNames = aNames.getConstArray(); 1103 for ( sal_Int32 nPos = 0; nPos < aNames.getLength(); ++nPos ) 1104 { 1105 script::ScriptEventDescriptor descr; 1106 if (xEvents->getByName( pNames[ nPos ] ) >>= descr) 1107 { 1108 OSL_ENSURE( descr.ListenerType.getLength() > 0 && 1109 descr.EventMethod.getLength() > 0 && 1110 descr.ScriptCode.getLength() > 0 && 1111 descr.ScriptType.getLength() > 0, 1112 "### invalid event descr!" ); 1113 1114 OUString aEventName; 1115 1116 if (! descr.AddListenerParam.getLength()) 1117 { 1118 // detection of event-name 1119 ::rtl::OString listenerType( 1120 ::rtl::OUStringToOString( 1121 descr.ListenerType, 1122 RTL_TEXTENCODING_ASCII_US ) ); 1123 ::rtl::OString eventMethod( 1124 ::rtl::OUStringToOString( 1125 descr.EventMethod, 1126 RTL_TEXTENCODING_ASCII_US ) ); 1127 StringTriple const * p = g_pEventTranslations; 1128 while (p->first) 1129 { 1130 if (0 == ::rtl_str_compare( p->second, eventMethod.getStr() ) && 1131 0 == ::rtl_str_compare( p->first, listenerType.getStr() )) 1132 { 1133 aEventName = OUString( p->third, ::rtl_str_getLength( p->third ), RTL_TEXTENCODING_ASCII_US ); 1134 break; 1135 } 1136 ++p; 1137 } 1138 } 1139 1140 ElementDescriptor * pElem; 1141 Reference< xml::sax::XAttributeList > xElem; 1142 1143 if (aEventName.getLength()) // script:event 1144 { 1145 pElem = new ElementDescriptor( 1146 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":event") ) ); 1147 xElem = pElem; 1148 1149 pElem->addAttribute( 1150 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":event-name") ), 1151 aEventName ); 1152 } 1153 else // script:listener-event 1154 { 1155 pElem = new ElementDescriptor( 1156 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":listener-event") ) ); 1157 xElem = pElem; 1158 1159 pElem->addAttribute( 1160 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":listener-type") ), 1161 descr.ListenerType ); 1162 pElem->addAttribute( 1163 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":listener-method") ), 1164 descr.EventMethod ); 1165 1166 if (descr.AddListenerParam.getLength()) 1167 { 1168 pElem->addAttribute( 1169 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":listener-param") ), 1170 descr.AddListenerParam ); 1171 } 1172 } 1173 if ( descr.ScriptType.equals( OUString( RTL_CONSTASCII_USTRINGPARAM( "StarBasic" ) ) ) ) 1174 { 1175 // separate optional location 1176 sal_Int32 nIndex = descr.ScriptCode.indexOf( (sal_Unicode)':' ); 1177 if (nIndex >= 0) 1178 { 1179 pElem->addAttribute( 1180 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":location") ), 1181 descr.ScriptCode.copy( 0, nIndex ) ); 1182 pElem->addAttribute( 1183 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":macro-name") ), 1184 descr.ScriptCode.copy( nIndex +1 ) ); 1185 } 1186 else 1187 { 1188 pElem->addAttribute( 1189 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":macro-name") ), 1190 descr.ScriptCode ); 1191 } 1192 } 1193 else 1194 { 1195 pElem->addAttribute( 1196 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":macro-name") ), 1197 descr.ScriptCode ); 1198 } 1199 1200 // language 1201 pElem->addAttribute( 1202 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":language") ), 1203 descr.ScriptType ); 1204 1205 addSubElement( xElem ); 1206 } 1207 else 1208 { 1209 OSL_ENSURE( 0, "### unexpected event type in container!" ); 1210 } 1211 } 1212 } 1213 } 1214 } 1215 1216 //################################################################################################## 1217 1218 inline bool equalFont( Style const & style1, Style const & style2 ) 1219 { 1220 awt::FontDescriptor const & f1 = style1._descr; 1221 awt::FontDescriptor const & f2 = style2._descr; 1222 return ( 1223 f1.Name == f2.Name && 1224 f1.Height == f2.Height && 1225 f1.Width == f2.Width && 1226 f1.StyleName == f2.StyleName && 1227 f1.Family == f2.Family && 1228 f1.CharSet == f2.CharSet && 1229 f1.Pitch == f2.CharSet && 1230 f1.CharacterWidth == f2.CharacterWidth && 1231 f1.Weight == f2.Weight && 1232 f1.Slant == f2.Slant && 1233 f1.Underline == f2.Underline && 1234 f1.Strikeout == f2.Strikeout && 1235 f1.Orientation == f2.Orientation && 1236 (f1.Kerning != sal_False) == (f2.Kerning != sal_False) && 1237 (f1.WordLineMode != sal_False) == (f2.WordLineMode != sal_False) && 1238 f1.Type == f2.Type && 1239 style1._fontRelief == style2._fontRelief && 1240 style1._fontEmphasisMark == style2._fontEmphasisMark 1241 ); 1242 } 1243 //__________________________________________________________________________________________________ 1244 OUString StyleBag::getStyleId( Style const & rStyle ) 1245 SAL_THROW( () ) 1246 { 1247 if (! rStyle._set) // nothing set 1248 { 1249 return OUString(); // everything default: no need to export a specific style 1250 } 1251 1252 // lookup existing style 1253 for ( size_t nStylesPos = 0; nStylesPos < _styles.size(); ++nStylesPos ) 1254 { 1255 Style * pStyle = _styles[ nStylesPos ]; 1256 1257 short demanded_defaults = ~rStyle._set & rStyle._all; 1258 // test, if defaults are not set 1259 if ((~pStyle->_set & demanded_defaults) == demanded_defaults && 1260 (rStyle._set & (pStyle->_all & ~pStyle->_set)) == 0) 1261 { 1262 short bset = rStyle._set & pStyle->_set; 1263 if ((bset & 0x1) && 1264 rStyle._backgroundColor != pStyle->_backgroundColor) 1265 continue; 1266 if ((bset & 0x2) && 1267 rStyle._textColor != pStyle->_textColor) 1268 continue; 1269 if ((bset & 0x20) && 1270 rStyle._textLineColor != pStyle->_textLineColor) 1271 continue; 1272 if ((bset & 0x10) && 1273 rStyle._fillColor != pStyle->_fillColor) 1274 continue; 1275 if ((bset & 0x4) && 1276 (rStyle._border != pStyle->_border || 1277 (rStyle._border == BORDER_SIMPLE_COLOR && 1278 rStyle._borderColor != pStyle->_borderColor))) 1279 continue; 1280 if ((bset & 0x8) && 1281 !equalFont( rStyle, *pStyle )) 1282 continue; 1283 if ((bset & 0x40) && 1284 rStyle._visualEffect != pStyle->_visualEffect) 1285 continue; 1286 1287 // merge in 1288 short bnset = rStyle._set & ~pStyle->_set; 1289 if (bnset & 0x1) 1290 pStyle->_backgroundColor = rStyle._backgroundColor; 1291 if (bnset & 0x2) 1292 pStyle->_textColor = rStyle._textColor; 1293 if (bnset & 0x20) 1294 pStyle->_textLineColor = rStyle._textLineColor; 1295 if (bnset & 0x10) 1296 pStyle->_fillColor = rStyle._fillColor; 1297 if (bnset & 0x4) { 1298 pStyle->_border = rStyle._border; 1299 pStyle->_borderColor = rStyle._borderColor; 1300 } 1301 if (bnset & 0x8) { 1302 pStyle->_descr = rStyle._descr; 1303 pStyle->_fontRelief = rStyle._fontRelief; 1304 pStyle->_fontEmphasisMark = rStyle._fontEmphasisMark; 1305 } 1306 if (bnset & 0x40) 1307 pStyle->_visualEffect = rStyle._visualEffect; 1308 1309 pStyle->_all |= rStyle._all; 1310 pStyle->_set |= rStyle._set; 1311 1312 return pStyle->_id; 1313 } 1314 } 1315 1316 // no appr style found, append new 1317 Style * pStyle = new Style( rStyle ); 1318 pStyle->_id = OUString::valueOf( (sal_Int32)_styles.size() ); 1319 _styles.push_back( pStyle ); 1320 return pStyle->_id; 1321 } 1322 //__________________________________________________________________________________________________ 1323 StyleBag::~StyleBag() SAL_THROW( () ) 1324 { 1325 for ( size_t nPos = 0; nPos < _styles.size(); ++nPos ) 1326 { 1327 delete _styles[ nPos ]; 1328 } 1329 } 1330 //__________________________________________________________________________________________________ 1331 void StyleBag::dump( Reference< xml::sax::XExtendedDocumentHandler > const & xOut ) 1332 { 1333 if (! _styles.empty()) 1334 { 1335 OUString aStylesName( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":styles") ); 1336 xOut->ignorableWhitespace( OUString() ); 1337 xOut->startElement( aStylesName, Reference< xml::sax::XAttributeList >() ); 1338 // export styles 1339 for ( size_t nPos = 0; nPos < _styles.size(); ++nPos ) 1340 { 1341 Reference< xml::sax::XAttributeList > xAttr( _styles[ nPos ]->createElement() ); 1342 static_cast< ElementDescriptor * >( xAttr.get() )->dump( xOut.get() ); 1343 } 1344 xOut->ignorableWhitespace( OUString() ); 1345 xOut->endElement( aStylesName ); 1346 } 1347 } 1348 1349 //################################################################################################## 1350 1351 //================================================================================================== 1352 void SAL_CALL exportDialogModel( 1353 Reference< xml::sax::XExtendedDocumentHandler > const & xOut, 1354 Reference< container::XNameContainer > const & xDialogModel ) 1355 { 1356 StyleBag all_styles; 1357 ::std::vector< Reference< xml::sax::XAttributeList > > all_elements; 1358 1359 // read out all props 1360 1361 Sequence< OUString > aElements( xDialogModel->getElementNames() ); 1362 OUString const * pElements = aElements.getConstArray(); 1363 1364 ElementDescriptor * pRadioGroup = 0; 1365 1366 sal_Int32 nPos; 1367 for ( nPos = 0; nPos < aElements.getLength(); ++nPos ) 1368 { 1369 Any aControlModel( xDialogModel->getByName( pElements[ nPos ] ) ); 1370 Reference< beans::XPropertySet > xProps; 1371 OSL_VERIFY( aControlModel >>= xProps ); 1372 if (! xProps.is()) 1373 continue; 1374 Reference< beans::XPropertyState > xPropState( xProps, UNO_QUERY ); 1375 OSL_ENSURE( xPropState.is(), "no XPropertyState!" ); 1376 if (! xPropState.is()) 1377 continue; 1378 Reference< lang::XServiceInfo > xServiceInfo( xProps, UNO_QUERY ); 1379 OSL_ENSURE( xServiceInfo.is(), "no XServiceInfo!" ); 1380 if (! xServiceInfo.is()) 1381 continue; 1382 1383 ElementDescriptor * pElem = 0; 1384 Reference< xml::sax::XAttributeList > xElem; 1385 1386 // group up radio buttons 1387 if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlRadioButtonModel") ) ) ) 1388 { 1389 if (! pRadioGroup) // open radiogroup 1390 { 1391 pRadioGroup = new ElementDescriptor( 1392 xProps, xPropState, 1393 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":radiogroup") ) ); 1394 all_elements.push_back( pRadioGroup ); 1395 } 1396 1397 pElem = new ElementDescriptor( 1398 xProps, xPropState, 1399 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":radio") ) ); 1400 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1401 pElem->readRadioButtonModel( &all_styles ); 1402 pRadioGroup->addSubElement( xElem ); 1403 } 1404 else // no radio 1405 { 1406 pRadioGroup = 0; // close radiogroup 1407 1408 if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlButtonModel") ) ) ) 1409 { 1410 pElem = new ElementDescriptor( 1411 xProps, xPropState, 1412 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":button") ) ); 1413 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1414 pElem->readButtonModel( &all_styles ); 1415 } 1416 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlCheckBoxModel") ) ) ) 1417 { 1418 pElem = new ElementDescriptor( 1419 xProps, xPropState, 1420 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":checkbox") ) ); 1421 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1422 pElem->readCheckBoxModel( &all_styles ); 1423 } 1424 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlComboBoxModel") ) ) ) 1425 { 1426 pElem = new ElementDescriptor( 1427 xProps, xPropState, 1428 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":combobox") ) ); 1429 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1430 pElem->readComboBoxModel( &all_styles ); 1431 } 1432 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlListBoxModel") ) ) ) 1433 { 1434 pElem = new ElementDescriptor( 1435 xProps, xPropState, 1436 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":menulist") ) ); 1437 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1438 pElem->readListBoxModel( &all_styles ); 1439 } 1440 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlGroupBoxModel") ) ) ) 1441 { 1442 pElem = new ElementDescriptor( 1443 xProps, xPropState, 1444 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":titledbox") ) ); 1445 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1446 pElem->readGroupBoxModel( &all_styles ); 1447 } 1448 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedTextModel") ) ) ) 1449 { 1450 pElem = new ElementDescriptor( 1451 xProps, xPropState, 1452 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":text") ) ); 1453 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1454 pElem->readFixedTextModel( &all_styles ); 1455 } 1456 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlEditModel") ) ) ) 1457 { 1458 pElem = new ElementDescriptor( 1459 xProps, xPropState, 1460 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":textfield") ) ); 1461 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1462 pElem->readEditModel( &all_styles ); 1463 } 1464 // FixedHyperLink 1465 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedHyperlinkModel") ) ) ) 1466 { 1467 pElem = new ElementDescriptor( 1468 xProps, xPropState, 1469 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":linklabel") ) ); 1470 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1471 pElem->readFixedHyperLinkModel( &all_styles ); 1472 } 1473 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlImageControlModel") ) ) ) 1474 { 1475 pElem = new ElementDescriptor( 1476 xProps, xPropState, 1477 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":img") ) ); 1478 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1479 pElem->readImageControlModel( &all_styles ); 1480 } 1481 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFileControlModel") ) ) ) 1482 { 1483 pElem = new ElementDescriptor( 1484 xProps, xPropState, 1485 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":filecontrol") ) ); 1486 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1487 pElem->readFileControlModel( &all_styles ); 1488 } 1489 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.tree.TreeControlModel") ) ) ) 1490 { 1491 pElem = new ElementDescriptor( 1492 xProps, xPropState, 1493 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":treecontrol") ) ); 1494 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1495 pElem->readTreeControlModel( &all_styles ); 1496 } 1497 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlCurrencyFieldModel") ) ) ) 1498 { 1499 pElem = new ElementDescriptor( 1500 xProps, xPropState, 1501 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":currencyfield") ) ); 1502 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1503 pElem->readCurrencyFieldModel( &all_styles ); 1504 } 1505 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlDateFieldModel") ) ) ) 1506 { 1507 pElem = new ElementDescriptor( 1508 xProps, xPropState, 1509 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":datefield") ) ); 1510 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1511 pElem->readDateFieldModel( &all_styles ); 1512 } 1513 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlNumericFieldModel") ) ) ) 1514 { 1515 pElem = new ElementDescriptor( 1516 xProps, xPropState, 1517 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":numericfield") ) ); 1518 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1519 pElem->readNumericFieldModel( &all_styles ); 1520 } 1521 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlTimeFieldModel") ) ) ) 1522 { 1523 pElem = new ElementDescriptor( 1524 xProps, xPropState, 1525 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":timefield") ) ); 1526 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1527 pElem->readTimeFieldModel( &all_styles ); 1528 } 1529 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlPatternFieldModel") ) ) ) 1530 { 1531 pElem = new ElementDescriptor( 1532 xProps, xPropState, 1533 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":patternfield") ) ); 1534 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1535 pElem->readPatternFieldModel( &all_styles ); 1536 } 1537 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFormattedFieldModel") ) ) ) 1538 { 1539 pElem = new ElementDescriptor( 1540 xProps, xPropState, 1541 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":formattedfield") ) ); 1542 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1543 pElem->readFormattedFieldModel( &all_styles ); 1544 } 1545 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedLineModel") ) ) ) 1546 { 1547 pElem = new ElementDescriptor( 1548 xProps, xPropState, 1549 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":fixedline") ) ); 1550 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1551 pElem->readFixedLineModel( &all_styles ); 1552 } 1553 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlScrollBarModel") ) ) ) 1554 { 1555 pElem = new ElementDescriptor( 1556 xProps, xPropState, 1557 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":scrollbar") ) ); 1558 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1559 pElem->readScrollBarModel( &all_styles ); 1560 } 1561 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlProgressBarModel") ) ) ) 1562 { 1563 pElem = new ElementDescriptor( 1564 xProps, xPropState, 1565 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":progressmeter") ) ); 1566 xElem = static_cast< xml::sax::XAttributeList * >( pElem ); 1567 pElem->readProgressBarModel( &all_styles ); 1568 } 1569 // 1570 1571 OSL_ASSERT( xElem.is() ); 1572 if (xElem.is()) 1573 { 1574 all_elements.push_back( xElem ); 1575 } 1576 else 1577 { 1578 OSL_ENSURE( sal_False, "unknown control type!" ); 1579 continue; 1580 } 1581 } 1582 } 1583 1584 xOut->startDocument(); 1585 1586 OUString aDocTypeStr( RTL_CONSTASCII_USTRINGPARAM( 1587 "<!DOCTYPE dlg:window PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\"" 1588 " \"dialog.dtd\">" ) ); 1589 xOut->unknown( aDocTypeStr ); 1590 xOut->ignorableWhitespace( OUString() ); 1591 1592 // window 1593 Reference< beans::XPropertySet > xProps( xDialogModel, UNO_QUERY ); 1594 OSL_ASSERT( xProps.is() ); 1595 Reference< beans::XPropertyState > xPropState( xProps, UNO_QUERY ); 1596 OSL_ASSERT( xPropState.is() ); 1597 1598 OUString aWindowName( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":window") ); 1599 ElementDescriptor * pWindow = new ElementDescriptor( xProps, xPropState, aWindowName ); 1600 Reference< xml::sax::XAttributeList > xWindow( pWindow ); 1601 pWindow->readDialogModel( &all_styles ); 1602 xOut->ignorableWhitespace( OUString() ); 1603 xOut->startElement( aWindowName, xWindow ); 1604 // dump out events 1605 pWindow->dumpSubElements( xOut.get() ); 1606 // dump out stylebag 1607 all_styles.dump( xOut ); 1608 1609 if (! all_elements.empty()) 1610 { 1611 // open up bulletinboard 1612 OUString aBBoardName( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":bulletinboard") ); 1613 xOut->ignorableWhitespace( OUString() ); 1614 xOut->startElement( aBBoardName, Reference< xml::sax::XAttributeList >() ); 1615 1616 // export control elements 1617 for ( std::size_t n = 0; n < all_elements.size(); ++n ) 1618 { 1619 ElementDescriptor * pElem = static_cast< ElementDescriptor * >( all_elements[ n ].get() ); 1620 pElem->dump( xOut.get() ); 1621 } 1622 1623 // end bulletinboard 1624 xOut->ignorableWhitespace( OUString() ); 1625 xOut->endElement( aBBoardName ); 1626 } 1627 1628 // end window 1629 xOut->ignorableWhitespace( OUString() ); 1630 xOut->endElement( aWindowName ); 1631 1632 xOut->endDocument(); 1633 } 1634 1635 } 1636