1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_xmlscript.hxx" 30 #include "imp_share.hxx" 31 32 #include <osl/diagnose.h> 33 #include <tools/diagnose_ex.h> 34 #include <osl/mutex.hxx> 35 36 #include <rtl/ustrbuf.hxx> 37 38 #include <xmlscript/xml_import.hxx> 39 #include <comphelper/processfactory.hxx> 40 41 #include <com/sun/star/awt/CharSet.hpp> 42 #include <com/sun/star/awt/FontFamily.hpp> 43 #include <com/sun/star/awt/FontPitch.hpp> 44 #include <com/sun/star/awt/FontSlant.hpp> 45 #include <com/sun/star/awt/FontStrikeout.hpp> 46 #include <com/sun/star/awt/FontType.hpp> 47 #include <com/sun/star/awt/FontUnderline.hpp> 48 #include <com/sun/star/awt/FontWeight.hpp> 49 #include <com/sun/star/awt/FontWidth.hpp> 50 #include <com/sun/star/awt/ImagePosition.hpp> 51 #include <com/sun/star/awt/LineEndFormat.hpp> 52 #include <com/sun/star/awt/PushButtonType.hpp> 53 #include <com/sun/star/awt/VisualEffect.hpp> 54 #include <com/sun/star/style/VerticalAlignment.hpp> 55 56 #include <com/sun/star/script/XScriptEventsSupplier.hpp> 57 #include <com/sun/star/script/ScriptEventDescriptor.hpp> 58 59 #include <com/sun/star/view/SelectionType.hpp> 60 61 using namespace ::com::sun::star; 62 using namespace ::com::sun::star::uno; 63 using ::rtl::OUString; 64 65 namespace xmlscript 66 { 67 68 //__________________________________________________________________________________________________ 69 void EventElement::endElement() 70 throw (xml::sax::SAXException, RuntimeException) 71 { 72 static_cast< ControlElement * >( _pParent )->_events.push_back( this ); 73 } 74 //__________________________________________________________________________________________________ 75 ControlElement::ControlElement( 76 OUString const & rLocalName, 77 Reference< xml::input::XAttributes > const & xAttributes, 78 ElementBase * pParent, DialogImport * pImport ) 79 SAL_THROW( () ) 80 : ElementBase( 81 pImport->XMLNS_DIALOGS_UID, rLocalName, xAttributes, pParent, pImport ) 82 { 83 if (_pParent) 84 { 85 // inherit position 86 _nBasePosX = static_cast< ControlElement * >( _pParent )->_nBasePosX; 87 _nBasePosY = static_cast< ControlElement * >( _pParent )->_nBasePosY; 88 } 89 else 90 { 91 _nBasePosX = 0; 92 _nBasePosY = 0; 93 } 94 } 95 96 //__________________________________________________________________________________________________ 97 Reference< xml::input::XElement > ControlElement::getStyle( 98 Reference< xml::input::XAttributes > const & xAttributes ) 99 { 100 OUString aStyleId( 101 xAttributes->getValueByUidName( 102 _pImport->XMLNS_DIALOGS_UID, 103 OUString( RTL_CONSTASCII_USTRINGPARAM("style-id") ) ) ); 104 if (aStyleId.getLength()) 105 { 106 return _pImport->getStyle( aStyleId ); 107 } 108 return Reference< xml::input::XElement >(); 109 } 110 //__________________________________________________________________________________________________ 111 OUString ControlElement::getControlId( 112 Reference< xml::input::XAttributes > const & xAttributes ) 113 { 114 OUString aId( 115 xAttributes->getValueByUidName( 116 _pImport->XMLNS_DIALOGS_UID, 117 OUString( RTL_CONSTASCII_USTRINGPARAM("id") ) ) ); 118 if (! aId.getLength()) 119 { 120 throw xml::sax::SAXException( 121 OUString( RTL_CONSTASCII_USTRINGPARAM("missing id attribute!") ), 122 Reference< XInterface >(), Any() ); 123 } 124 return aId; 125 } 126 127 //################################################################################################## 128 129 //__________________________________________________________________________________________________ 130 bool StyleElement::importTextColorStyle( 131 Reference< beans::XPropertySet > const & xProps ) 132 { 133 if ((_inited & 0x2) != 0) 134 { 135 if ((_hasValue & 0x2) != 0) 136 { 137 xProps->setPropertyValue( 138 OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ), 139 makeAny( _textColor ) ); 140 return true; 141 } 142 return false; 143 } 144 _inited |= 0x2; 145 146 if (getLongAttr( &_textColor, 147 OUString( RTL_CONSTASCII_USTRINGPARAM("text-color") ), 148 _xAttributes, _pImport->XMLNS_DIALOGS_UID )) 149 { 150 _hasValue |= 0x2; 151 xProps->setPropertyValue( 152 OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ), 153 makeAny( _textColor ) ); 154 return true; 155 } 156 return false; 157 } 158 //__________________________________________________________________________________________________ 159 bool StyleElement::importTextLineColorStyle( 160 Reference< beans::XPropertySet > const & xProps ) 161 { 162 if ((_inited & 0x20) != 0) 163 { 164 if ((_hasValue & 0x20) != 0) 165 { 166 xProps->setPropertyValue( 167 OUString( RTL_CONSTASCII_USTRINGPARAM("TextLineColor") ), 168 makeAny( _textLineColor ) ); 169 return true; 170 } 171 return false; 172 } 173 _inited |= 0x20; 174 175 if (getLongAttr( &_textLineColor, 176 OUString( RTL_CONSTASCII_USTRINGPARAM("textline-color") ), 177 _xAttributes, _pImport->XMLNS_DIALOGS_UID )) 178 { 179 _hasValue |= 0x20; 180 xProps->setPropertyValue( 181 OUString( RTL_CONSTASCII_USTRINGPARAM("TextLineColor") ), 182 makeAny( _textLineColor ) ); 183 return true; 184 } 185 return false; 186 } 187 //__________________________________________________________________________________________________ 188 bool StyleElement::importFillColorStyle( 189 Reference< beans::XPropertySet > const & xProps ) 190 { 191 if ((_inited & 0x10) != 0) 192 { 193 if ((_hasValue & 0x10) != 0) 194 { 195 xProps->setPropertyValue( 196 OUString( RTL_CONSTASCII_USTRINGPARAM("FillColor") ), makeAny( _fillColor ) ); 197 return true; 198 } 199 return false; 200 } 201 _inited |= 0x10; 202 203 if (getLongAttr( 204 &_fillColor, 205 OUString( RTL_CONSTASCII_USTRINGPARAM("fill-color") ), 206 _xAttributes, _pImport->XMLNS_DIALOGS_UID )) 207 { 208 _hasValue |= 0x10; 209 xProps->setPropertyValue( 210 OUString( RTL_CONSTASCII_USTRINGPARAM("FillColor") ), 211 makeAny( _fillColor ) ); 212 return true; 213 } 214 return false; 215 } 216 //__________________________________________________________________________________________________ 217 bool StyleElement::importBackgroundColorStyle( 218 Reference< beans::XPropertySet > const & xProps ) 219 { 220 if ((_inited & 0x1) != 0) 221 { 222 if ((_hasValue & 0x1) != 0) 223 { 224 xProps->setPropertyValue( 225 OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ), makeAny( _backgroundColor ) ); 226 return true; 227 } 228 return false; 229 } 230 _inited |= 0x1; 231 232 if (getLongAttr( 233 &_backgroundColor, 234 OUString( RTL_CONSTASCII_USTRINGPARAM("background-color") ), 235 _xAttributes, _pImport->XMLNS_DIALOGS_UID )) 236 { 237 _hasValue |= 0x1; 238 xProps->setPropertyValue( 239 OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ), makeAny( _backgroundColor ) ); 240 return true; 241 } 242 return false; 243 } 244 245 //__________________________________________________________________________________________________ 246 bool StyleElement::importBorderStyle( 247 Reference< beans::XPropertySet > const & xProps ) 248 { 249 if ((_inited & 0x4) != 0) 250 { 251 if ((_hasValue & 0x4) != 0) 252 { 253 xProps->setPropertyValue( 254 OUSTR("Border"), makeAny( _border == BORDER_SIMPLE_COLOR 255 ? BORDER_SIMPLE : _border ) ); 256 if (_border == BORDER_SIMPLE_COLOR) 257 xProps->setPropertyValue( OUSTR("BorderColor"), 258 makeAny(_borderColor) ); 259 return true; 260 } 261 return false; 262 } 263 _inited |= 0x4; 264 265 OUString aValue; 266 if (getStringAttr( 267 &aValue, OUSTR("border"), 268 _xAttributes, _pImport->XMLNS_DIALOGS_UID )) { 269 if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("none") )) 270 _border = BORDER_NONE; 271 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("3d") )) 272 _border = BORDER_3D; 273 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("simple") )) 274 _border = BORDER_SIMPLE; 275 else { 276 _border = BORDER_SIMPLE_COLOR; 277 _borderColor = toInt32(aValue); 278 } 279 280 _hasValue |= 0x4; 281 importBorderStyle(xProps); // write values 282 } 283 return false; 284 } 285 286 //______________________________________________________________________________ 287 bool StyleElement::importVisualEffectStyle( 288 Reference<beans::XPropertySet> const & xProps ) 289 { 290 if ((_inited & 0x40) != 0) 291 { 292 if ((_hasValue & 0x40) != 0) 293 { 294 xProps->setPropertyValue( OUSTR("VisualEffect"), 295 makeAny(_visualEffect) ); 296 return true; 297 } 298 return false; 299 } 300 _inited |= 0x40; 301 302 OUString aValue; 303 if (getStringAttr( &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("look") ), 304 _xAttributes, _pImport->XMLNS_DIALOGS_UID )) 305 { 306 if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("none") )) 307 { 308 _visualEffect = awt::VisualEffect::NONE; 309 } 310 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("3d") )) 311 { 312 _visualEffect = awt::VisualEffect::LOOK3D; 313 } 314 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("simple") )) 315 { 316 _visualEffect = awt::VisualEffect::FLAT; 317 } 318 else 319 OSL_ASSERT( 0 ); 320 321 _hasValue |= 0x40; 322 xProps->setPropertyValue( OUSTR("VisualEffect"), 323 makeAny(_visualEffect) ); 324 } 325 return false; 326 } 327 328 //__________________________________________________________________________________________________ 329 void StyleElement::setFontProperties( 330 Reference< beans::XPropertySet > const & xProps ) 331 { 332 xProps->setPropertyValue( 333 OUString( RTL_CONSTASCII_USTRINGPARAM("FontDescriptor") ), makeAny( _descr ) ); 334 xProps->setPropertyValue( 335 OUString( RTL_CONSTASCII_USTRINGPARAM("FontEmphasisMark") ), makeAny( _fontEmphasisMark ) ); 336 xProps->setPropertyValue( 337 OUString( RTL_CONSTASCII_USTRINGPARAM("FontRelief") ), makeAny( _fontRelief ) ); 338 } 339 //__________________________________________________________________________________________________ 340 bool StyleElement::importFontStyle( 341 Reference< beans::XPropertySet > const & xProps ) 342 { 343 if ((_inited & 0x8) != 0) 344 { 345 if ((_hasValue & 0x8) != 0) 346 { 347 setFontProperties( xProps ); 348 return true; 349 } 350 return false; 351 } 352 _inited |= 0x8; 353 354 OUString aValue; 355 bool bFontImport; 356 357 // dialog:font-name CDATA #IMPLIED 358 bFontImport = getStringAttr( 359 &_descr.Name, OUString( RTL_CONSTASCII_USTRINGPARAM("font-name") ), 360 _xAttributes, _pImport->XMLNS_DIALOGS_UID ); 361 362 // dialog:font-height %numeric; #IMPLIED 363 if (getStringAttr( 364 &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("font-height") ), 365 _xAttributes, _pImport->XMLNS_DIALOGS_UID )) 366 { 367 _descr.Height = (sal_Int16)toInt32( aValue ); 368 bFontImport = true; 369 } 370 // dialog:font-width %numeric; #IMPLIED 371 if (getStringAttr( 372 &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("font-width") ), 373 _xAttributes, _pImport->XMLNS_DIALOGS_UID )) 374 { 375 _descr.Width = (sal_Int16)toInt32( aValue ); 376 bFontImport = true; 377 } 378 // dialog:font-stylename CDATA #IMPLIED 379 bFontImport |= getStringAttr( 380 &_descr.StyleName, 381 OUString( RTL_CONSTASCII_USTRINGPARAM("font-stylename") ), 382 _xAttributes, _pImport->XMLNS_DIALOGS_UID ); 383 384 // dialog:font-family "(decorative|modern|roman|script|swiss|system)" #IMPLIED 385 if (getStringAttr( 386 &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("font-family") ), 387 _xAttributes, _pImport->XMLNS_DIALOGS_UID )) 388 { 389 if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("decorative") )) 390 { 391 _descr.Family = awt::FontFamily::DECORATIVE; 392 } 393 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("modern") )) 394 { 395 _descr.Family = awt::FontFamily::MODERN; 396 } 397 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("roman") )) 398 { 399 _descr.Family = awt::FontFamily::ROMAN; 400 } 401 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("script") )) 402 { 403 _descr.Family = awt::FontFamily::SCRIPT; 404 } 405 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("swiss") )) 406 { 407 _descr.Family = awt::FontFamily::SWISS; 408 } 409 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("system") )) 410 { 411 _descr.Family = awt::FontFamily::SYSTEM; 412 } 413 else 414 { 415 throw xml::sax::SAXException( 416 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-family style!") ), 417 Reference< XInterface >(), Any() ); 418 } 419 bFontImport = true; 420 } 421 422 // dialog:font-charset "(ansi|mac|ibmpc_437|ibmpc_850|ibmpc_860|ibmpc_861|ibmpc_863|ibmpc_865|system|symbol)" #IMPLIED 423 if (getStringAttr( 424 &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("font-charset") ), 425 _xAttributes, _pImport->XMLNS_DIALOGS_UID )) 426 { 427 if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ansi") )) 428 { 429 _descr.CharSet = awt::CharSet::ANSI; 430 } 431 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("mac") )) 432 { 433 _descr.CharSet = awt::CharSet::MAC; 434 } 435 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ibmpc_437") )) 436 { 437 _descr.CharSet = awt::CharSet::IBMPC_437; 438 } 439 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ibmpc_850") )) 440 { 441 _descr.CharSet = awt::CharSet::IBMPC_850; 442 } 443 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ibmpc_860") )) 444 { 445 _descr.CharSet = awt::CharSet::IBMPC_860; 446 } 447 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ibmpc_861") )) 448 { 449 _descr.CharSet = awt::CharSet::IBMPC_861; 450 } 451 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ibmpc_863") )) 452 { 453 _descr.CharSet = awt::CharSet::IBMPC_863; 454 } 455 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ibmpc_865") )) 456 { 457 _descr.CharSet = awt::CharSet::IBMPC_865; 458 } 459 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("system") )) 460 { 461 _descr.CharSet = awt::CharSet::SYSTEM; 462 } 463 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("symbol") )) 464 { 465 _descr.CharSet = awt::CharSet::SYMBOL; 466 } 467 else 468 { 469 throw xml::sax::SAXException( 470 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-charset style!") ), 471 Reference< XInterface >(), Any() ); 472 } 473 bFontImport = true; 474 } 475 476 // dialog:font-pitch "(fixed|variable)" #IMPLIED 477 if (getStringAttr( 478 &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("font-pitch") ), 479 _xAttributes, _pImport->XMLNS_DIALOGS_UID )) 480 { 481 if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("fixed") )) 482 { 483 _descr.Pitch = awt::FontPitch::FIXED; 484 } 485 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("variable") )) 486 { 487 _descr.Pitch = awt::FontPitch::VARIABLE; 488 } 489 else 490 { 491 throw xml::sax::SAXException( 492 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-pitch style!") ), 493 Reference< XInterface >(), Any() ); 494 } 495 bFontImport = true; 496 } 497 498 // dialog:font-charwidth CDATA #IMPLIED 499 if (getStringAttr( 500 &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("font-charwidth") ), 501 _xAttributes, _pImport->XMLNS_DIALOGS_UID )) 502 { 503 _descr.CharacterWidth = aValue.toFloat(); 504 bFontImport = true; 505 } 506 // dialog:font-weight CDATA #IMPLIED 507 if (getStringAttr( 508 &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("font-weight") ), 509 _xAttributes, _pImport->XMLNS_DIALOGS_UID )) 510 { 511 _descr.Weight = aValue.toFloat(); 512 bFontImport = true; 513 } 514 515 // dialog:font-slant "(oblique|italic|reverse_oblique|reverse_italic)" #IMPLIED 516 if (getStringAttr( 517 &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("font-slant") ), 518 _xAttributes, _pImport->XMLNS_DIALOGS_UID )) 519 { 520 if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("oblique") )) 521 { 522 _descr.Slant = awt::FontSlant_OBLIQUE; 523 } 524 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("italic") )) 525 { 526 _descr.Slant = awt::FontSlant_ITALIC; 527 } 528 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("reverse_oblique") )) 529 { 530 _descr.Slant = awt::FontSlant_REVERSE_OBLIQUE; 531 } 532 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("reverse_italic") )) 533 { 534 _descr.Slant = awt::FontSlant_REVERSE_ITALIC; 535 } 536 else 537 { 538 throw xml::sax::SAXException( 539 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-slant style!") ), 540 Reference< XInterface >(), Any() ); 541 } 542 bFontImport = true; 543 } 544 545 // dialog:font-underline "(single|double|dotted|dash|longdash|dashdot|dashdotdot|smallwave|wave|doublewave|bold|bolddotted|bolddash|boldlongdash|bolddashdot|bolddashdotdot|boldwave)" #IMPLIED 546 if (getStringAttr( 547 &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("font-underline") ), 548 _xAttributes, _pImport->XMLNS_DIALOGS_UID )) 549 { 550 if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("single") )) 551 { 552 _descr.Underline = awt::FontUnderline::SINGLE; 553 } 554 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("double") )) 555 { 556 _descr.Underline = awt::FontUnderline::DOUBLE; 557 } 558 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("dotted") )) 559 { 560 _descr.Underline = awt::FontUnderline::DOTTED; 561 } 562 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("dash") )) 563 { 564 _descr.Underline = awt::FontUnderline::DASH; 565 } 566 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("longdash") )) 567 { 568 _descr.Underline = awt::FontUnderline::LONGDASH; 569 } 570 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("dashdot") )) 571 { 572 _descr.Underline = awt::FontUnderline::DASHDOT; 573 } 574 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("dashdotdot") )) 575 { 576 _descr.Underline = awt::FontUnderline::DASHDOTDOT; 577 } 578 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("smallwave") )) 579 { 580 _descr.Underline = awt::FontUnderline::SMALLWAVE; 581 } 582 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("wave") )) 583 { 584 _descr.Underline = awt::FontUnderline::WAVE; 585 } 586 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("doublewave") )) 587 { 588 _descr.Underline = awt::FontUnderline::DOUBLEWAVE; 589 } 590 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bold") )) 591 { 592 _descr.Underline = awt::FontUnderline::BOLD; 593 } 594 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bolddotted") )) 595 { 596 _descr.Underline = awt::FontUnderline::BOLDDOTTED; 597 } 598 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bolddash") )) 599 { 600 _descr.Underline = awt::FontUnderline::BOLDDASH; 601 } 602 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("boldlongdash") )) 603 { 604 _descr.Underline = awt::FontUnderline::BOLDLONGDASH; 605 } 606 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bolddashdot") )) 607 { 608 _descr.Underline = awt::FontUnderline::BOLDDASHDOT; 609 } 610 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bolddashdotdot") )) 611 { 612 _descr.Underline = awt::FontUnderline::BOLDDASHDOTDOT; 613 } 614 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("boldwave") )) 615 { 616 _descr.Underline = awt::FontUnderline::BOLDWAVE; 617 } 618 else 619 { 620 throw xml::sax::SAXException( 621 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-underline style!") ), 622 Reference< XInterface >(), Any() ); 623 } 624 bFontImport = true; 625 } 626 627 // dialog:font-strikeout "(single|double|bold|slash|x)" #IMPLIED 628 if (getStringAttr( 629 &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("font-strikeout") ), 630 _xAttributes, _pImport->XMLNS_DIALOGS_UID )) 631 { 632 if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("single") )) 633 { 634 _descr.Strikeout = awt::FontStrikeout::SINGLE; 635 } 636 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("double") )) 637 { 638 _descr.Strikeout = awt::FontStrikeout::DOUBLE; 639 } 640 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bold") )) 641 { 642 _descr.Strikeout = awt::FontStrikeout::BOLD; 643 } 644 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("slash") )) 645 { 646 _descr.Strikeout = awt::FontStrikeout::SLASH; 647 } 648 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("x") )) 649 { 650 _descr.Strikeout = awt::FontStrikeout::X; 651 } 652 else 653 { 654 throw xml::sax::SAXException( 655 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-strikeout style!") ), 656 Reference< XInterface >(), Any() ); 657 } 658 bFontImport = true; 659 } 660 661 // dialog:font-orientation CDATA #IMPLIED 662 if (getStringAttr( 663 &aValue, 664 OUString( RTL_CONSTASCII_USTRINGPARAM("font-orientation") ), 665 _xAttributes, _pImport->XMLNS_DIALOGS_UID )) 666 { 667 _descr.Orientation = aValue.toFloat(); 668 bFontImport = true; 669 } 670 // dialog:font-kerning %boolean; #IMPLIED 671 bFontImport |= getBoolAttr( 672 &_descr.Kerning, 673 OUString( RTL_CONSTASCII_USTRINGPARAM("font-kerning") ), 674 _xAttributes, _pImport->XMLNS_DIALOGS_UID ); 675 // dialog:font-wordlinemode %boolean; #IMPLIED 676 bFontImport |= getBoolAttr( 677 &_descr.WordLineMode, 678 OUString( RTL_CONSTASCII_USTRINGPARAM("font-wordlinemode") ), 679 _xAttributes, _pImport->XMLNS_DIALOGS_UID ); 680 681 // dialog:font-type "(raster|device|scalable)" #IMPLIED 682 if (getStringAttr( 683 &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("font-type") ), 684 _xAttributes, _pImport->XMLNS_DIALOGS_UID )) 685 { 686 if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("raster") )) 687 { 688 _descr.Type = awt::FontType::RASTER; 689 } 690 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("device") )) 691 { 692 _descr.Type = awt::FontType::DEVICE; 693 } 694 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("scalable") )) 695 { 696 _descr.Type = awt::FontType::SCALABLE; 697 } 698 else 699 { 700 throw xml::sax::SAXException( 701 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-type style!") ), 702 Reference< XInterface >(), Any() ); 703 } 704 bFontImport = true; 705 } 706 707 // additional properties which are not part of the FontDescriptor struct 708 // dialog:font-relief (none|embossed|engraved) #IMPLIED 709 if (getStringAttr( 710 &aValue, OUString( RTL_CONSTASCII_USTRINGPARAM("font-relief") ), 711 _xAttributes, _pImport->XMLNS_DIALOGS_UID )) 712 { 713 if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("none") )) 714 { 715 _fontRelief = awt::FontRelief::NONE; 716 } 717 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("embossed") )) 718 { 719 _fontRelief = awt::FontRelief::EMBOSSED; 720 } 721 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("engraved") )) 722 { 723 _fontRelief = awt::FontRelief::ENGRAVED; 724 } 725 else 726 { 727 throw xml::sax::SAXException( 728 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-relief style!") ), 729 Reference< XInterface >(), Any() ); 730 } 731 bFontImport = true; 732 } 733 // dialog:font-emphasismark (none|dot|circle|disc|accent|above|below) #IMPLIED 734 if (getStringAttr( 735 &aValue, 736 OUString( RTL_CONSTASCII_USTRINGPARAM("font-emphasismark") ), 737 _xAttributes, _pImport->XMLNS_DIALOGS_UID )) 738 { 739 if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("none") )) 740 { 741 _fontEmphasisMark = awt::FontEmphasisMark::NONE; 742 } 743 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("dot") )) 744 { 745 _fontEmphasisMark = awt::FontEmphasisMark::DOT; 746 } 747 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("circle") )) 748 { 749 _fontEmphasisMark = awt::FontEmphasisMark::CIRCLE; 750 } 751 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("disc") )) 752 { 753 _fontEmphasisMark = awt::FontEmphasisMark::DISC; 754 } 755 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("accent") )) 756 { 757 _fontEmphasisMark = awt::FontEmphasisMark::ACCENT; 758 } 759 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("above") )) 760 { 761 _fontEmphasisMark = awt::FontEmphasisMark::ABOVE; 762 } 763 else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("below") )) 764 { 765 _fontEmphasisMark = awt::FontEmphasisMark::BELOW; 766 } 767 else 768 { 769 throw xml::sax::SAXException( 770 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-emphasismark style!") ), 771 Reference< XInterface >(), Any() ); 772 } 773 bFontImport = true; 774 } 775 776 // ================================================== 777 if (bFontImport) 778 { 779 _hasValue |= 0x8; 780 setFontProperties( xProps ); 781 } 782 783 return bFontImport; 784 } 785 786 //################################################################################################## 787 788 //__________________________________________________________________________________________________ 789 bool ImportContext::importStringProperty( 790 OUString const & rPropName, OUString const & rAttrName, 791 Reference< xml::input::XAttributes > const & xAttributes ) 792 { 793 OUString aValue( 794 xAttributes->getValueByUidName( 795 _pImport->XMLNS_DIALOGS_UID, rAttrName ) ); 796 if (aValue.getLength()) 797 { 798 _xControlModel->setPropertyValue( rPropName, makeAny( aValue ) ); 799 return true; 800 } 801 return false; 802 } 803 //__________________________________________________________________________________________________ 804 bool ImportContext::importDoubleProperty( 805 OUString const & rPropName, OUString const & rAttrName, 806 Reference< xml::input::XAttributes > const & xAttributes ) 807 { 808 OUString aValue( 809 xAttributes->getValueByUidName( 810 _pImport->XMLNS_DIALOGS_UID, rAttrName ) ); 811 if (aValue.getLength()) 812 { 813 _xControlModel->setPropertyValue( rPropName, makeAny( aValue.toDouble() ) ); 814 return true; 815 } 816 return false; 817 } 818 //__________________________________________________________________________________________________ 819 bool ImportContext::importBooleanProperty( 820 OUString const & rPropName, OUString const & rAttrName, 821 Reference< xml::input::XAttributes > const & xAttributes ) 822 { 823 sal_Bool bBool; 824 if (getBoolAttr( 825 &bBool, rAttrName, xAttributes, _pImport->XMLNS_DIALOGS_UID )) 826 { 827 _xControlModel->setPropertyValue( rPropName, makeAny( bBool ) ); 828 return true; 829 } 830 return false; 831 } 832 //__________________________________________________________________________________________________ 833 bool ImportContext::importLongProperty( 834 OUString const & rPropName, OUString const & rAttrName, 835 Reference< xml::input::XAttributes > const & xAttributes ) 836 { 837 OUString aValue( 838 xAttributes->getValueByUidName( 839 _pImport->XMLNS_DIALOGS_UID, rAttrName ) ); 840 if (aValue.getLength()) 841 { 842 _xControlModel->setPropertyValue( rPropName, makeAny( toInt32( aValue ) ) ); 843 return true; 844 } 845 return false; 846 } 847 //__________________________________________________________________________________________________ 848 bool ImportContext::importLongProperty( 849 sal_Int32 nOffset, 850 OUString const & rPropName, OUString const & rAttrName, 851 Reference< xml::input::XAttributes > const & xAttributes ) 852 { 853 OUString aValue( 854 xAttributes->getValueByUidName( 855 _pImport->XMLNS_DIALOGS_UID, rAttrName ) ); 856 if (aValue.getLength()) 857 { 858 _xControlModel->setPropertyValue( rPropName, makeAny( toInt32( aValue ) + nOffset ) ); 859 return true; 860 } 861 return false; 862 } 863 //__________________________________________________________________________________________________ 864 bool ImportContext::importHexLongProperty( 865 OUString const & rPropName, OUString const & rAttrName, 866 Reference< xml::input::XAttributes > const & xAttributes ) 867 { 868 OUString aValue( 869 xAttributes->getValueByUidName( 870 _pImport->XMLNS_DIALOGS_UID, rAttrName ) ); 871 if (aValue.getLength()) 872 { 873 _xControlModel->setPropertyValue( rPropName, makeAny( toInt32( aValue ) ) ); 874 return true; 875 } 876 return false; 877 } 878 //__________________________________________________________________________________________________ 879 bool ImportContext::importShortProperty( 880 OUString const & rPropName, OUString const & rAttrName, 881 Reference< xml::input::XAttributes > const & xAttributes ) 882 { 883 OUString aValue( 884 xAttributes->getValueByUidName( 885 _pImport->XMLNS_DIALOGS_UID, rAttrName ) ); 886 if (aValue.getLength()) 887 { 888 _xControlModel->setPropertyValue( rPropName, makeAny( (sal_Int16)toInt32( aValue ) ) ); 889 return true; 890 } 891 return false; 892 } 893 //__________________________________________________________________________________________________ 894 bool ImportContext::importAlignProperty( 895 OUString const & rPropName, OUString const & rAttrName, 896 Reference< xml::input::XAttributes > const & xAttributes ) 897 { 898 OUString aAlign( 899 xAttributes->getValueByUidName( 900 _pImport->XMLNS_DIALOGS_UID, rAttrName ) ); 901 if (aAlign.getLength()) 902 { 903 sal_Int16 nAlign; 904 if (aAlign.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("left") )) 905 { 906 nAlign = 0; 907 } 908 else if (aAlign.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("center") )) 909 { 910 nAlign = 1; 911 } 912 else if (aAlign.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("right") )) 913 { 914 nAlign = 2; 915 } 916 else if (aAlign.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("none") )) 917 { 918 nAlign = 0; // default 919 } 920 else 921 { 922 throw xml::sax::SAXException( 923 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid align value!") ), 924 Reference< XInterface >(), Any() ); 925 } 926 927 _xControlModel->setPropertyValue( rPropName, makeAny( nAlign ) ); 928 return true; 929 } 930 return false; 931 } 932 //__________________________________________________________________________________________________ 933 bool ImportContext::importVerticalAlignProperty( 934 OUString const & rPropName, OUString const & rAttrName, 935 Reference< xml::input::XAttributes > const & xAttributes ) 936 { 937 OUString aAlign( 938 xAttributes->getValueByUidName( 939 _pImport->XMLNS_DIALOGS_UID, rAttrName ) ); 940 if (aAlign.getLength()) 941 { 942 style::VerticalAlignment eAlign; 943 944 if (aAlign.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("top") )) 945 { 946 eAlign = style::VerticalAlignment_TOP; 947 } 948 else if (aAlign.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("center") )) 949 { 950 eAlign = style::VerticalAlignment_MIDDLE; 951 } 952 else if (aAlign.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bottom") )) 953 { 954 eAlign = style::VerticalAlignment_BOTTOM; 955 } 956 else 957 { 958 throw xml::sax::SAXException( 959 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid vertical align value!") ), 960 Reference< XInterface >(), Any() ); 961 } 962 963 _xControlModel->setPropertyValue( rPropName, makeAny( eAlign ) ); 964 return true; 965 } 966 return false; 967 } 968 //__________________________________________________________________________________________________ 969 bool ImportContext::importImageAlignProperty( 970 OUString const & rPropName, OUString const & rAttrName, 971 Reference< xml::input::XAttributes > const & xAttributes ) 972 { 973 OUString aAlign( 974 xAttributes->getValueByUidName( 975 _pImport->XMLNS_DIALOGS_UID, rAttrName ) ); 976 if (aAlign.getLength()) 977 { 978 sal_Int16 nAlign; 979 if (aAlign.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("left") )) 980 { 981 nAlign = 0; 982 } 983 else if (aAlign.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("top") )) 984 { 985 nAlign = 1; 986 } 987 else if (aAlign.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("right") )) 988 { 989 nAlign = 2; 990 } 991 else if (aAlign.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bottom") )) 992 { 993 nAlign = 3; 994 } 995 else 996 { 997 throw xml::sax::SAXException( 998 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid image align value!") ), 999 Reference< XInterface >(), Any() ); 1000 } 1001 1002 _xControlModel->setPropertyValue( rPropName, makeAny( nAlign ) ); 1003 return true; 1004 } 1005 return false; 1006 } 1007 //__________________________________________________________________________________________________ 1008 bool ImportContext::importImagePositionProperty( 1009 OUString const & rPropName, OUString const & rAttrName, 1010 Reference< xml::input::XAttributes > const & xAttributes ) 1011 { 1012 OUString aPosition( 1013 xAttributes->getValueByUidName( 1014 _pImport->XMLNS_DIALOGS_UID, rAttrName ) ); 1015 if (aPosition.getLength()) 1016 { 1017 sal_Int16 nPosition; 1018 if (aPosition.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("left-top") )) 1019 { 1020 nPosition = awt::ImagePosition::LeftTop; 1021 } 1022 else if (aPosition.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("left-center") )) 1023 { 1024 nPosition = awt::ImagePosition::LeftCenter; 1025 } 1026 else if (aPosition.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("left-bottom") )) 1027 { 1028 nPosition = awt::ImagePosition::LeftBottom; 1029 } 1030 else if (aPosition.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("right-top") )) 1031 { 1032 nPosition = awt::ImagePosition::RightTop; 1033 } 1034 else if (aPosition.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("right-center") )) 1035 { 1036 nPosition = awt::ImagePosition::RightCenter; 1037 } 1038 else if (aPosition.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("right-bottom") )) 1039 { 1040 nPosition = awt::ImagePosition::RightBottom; 1041 } 1042 else if (aPosition.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("top-left") )) 1043 { 1044 nPosition = awt::ImagePosition::AboveLeft; 1045 } 1046 else if (aPosition.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("top-center") )) 1047 { 1048 nPosition = awt::ImagePosition::AboveCenter; 1049 } 1050 else if (aPosition.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("top-right") )) 1051 { 1052 nPosition = awt::ImagePosition::AboveRight; 1053 } 1054 else if (aPosition.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bottom-left") )) 1055 { 1056 nPosition = awt::ImagePosition::BelowLeft; 1057 } 1058 else if (aPosition.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bottom-center") )) 1059 { 1060 nPosition = awt::ImagePosition::BelowCenter; 1061 } 1062 else if (aPosition.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bottom-right") )) 1063 { 1064 nPosition = awt::ImagePosition::BelowRight; 1065 } 1066 else if (aPosition.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("center") )) 1067 { 1068 nPosition = awt::ImagePosition::Centered; 1069 } 1070 else 1071 { 1072 throw xml::sax::SAXException( 1073 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid image position value!") ), 1074 Reference< XInterface >(), Any() ); 1075 } 1076 1077 _xControlModel->setPropertyValue( rPropName, makeAny( nPosition ) ); 1078 return true; 1079 } 1080 return false; 1081 } 1082 //__________________________________________________________________________________________________ 1083 bool ImportContext::importButtonTypeProperty( 1084 OUString const & rPropName, OUString const & rAttrName, 1085 Reference< xml::input::XAttributes > const & xAttributes ) 1086 { 1087 OUString buttonType( 1088 xAttributes->getValueByUidName( 1089 _pImport->XMLNS_DIALOGS_UID, rAttrName ) ); 1090 if (buttonType.getLength()) 1091 { 1092 sal_Int16 nButtonType; 1093 if (buttonType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("standard") )) 1094 { 1095 nButtonType = awt::PushButtonType_STANDARD; 1096 } 1097 else if (buttonType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ok") )) 1098 { 1099 nButtonType = awt::PushButtonType_OK; 1100 } 1101 else if (buttonType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("cancel") )) 1102 { 1103 nButtonType = awt::PushButtonType_CANCEL; 1104 } 1105 else if (buttonType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("help") )) 1106 { 1107 nButtonType = awt::PushButtonType_HELP; 1108 } 1109 else 1110 { 1111 throw xml::sax::SAXException( 1112 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid button-type value!") ), 1113 Reference< XInterface >(), Any() ); 1114 } 1115 1116 _xControlModel->setPropertyValue( rPropName, makeAny( nButtonType ) ); 1117 return true; 1118 } 1119 return false; 1120 } 1121 //__________________________________________________________________________________________________ 1122 bool ImportContext::importDateFormatProperty( 1123 OUString const & rPropName, OUString const & rAttrName, 1124 Reference< xml::input::XAttributes > const & xAttributes ) 1125 { 1126 OUString aFormat( 1127 xAttributes->getValueByUidName( 1128 _pImport->XMLNS_DIALOGS_UID, rAttrName ) ); 1129 if (aFormat.getLength()) 1130 { 1131 sal_Int16 nFormat; 1132 if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("system_short") )) 1133 { 1134 nFormat = 0; 1135 } 1136 else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("system_short_YY") )) 1137 { 1138 nFormat = 1; 1139 } 1140 else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("system_short_YYYY") )) 1141 { 1142 nFormat = 2; 1143 } 1144 else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("system_long") )) 1145 { 1146 nFormat = 3; 1147 } 1148 else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("short_DDMMYY") )) 1149 { 1150 nFormat = 4; 1151 } 1152 else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("short_MMDDYY") )) 1153 { 1154 nFormat = 5; 1155 } 1156 else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("short_YYMMDD") )) 1157 { 1158 nFormat = 6; 1159 } 1160 else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("short_DDMMYYYY") )) 1161 { 1162 nFormat = 7; 1163 } 1164 else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("short_MMDDYYYY") )) 1165 { 1166 nFormat = 8; 1167 } 1168 else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("short_YYYYMMDD") )) 1169 { 1170 nFormat = 9; 1171 } 1172 else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("short_YYMMDD_DIN5008") )) 1173 { 1174 nFormat = 10; 1175 } 1176 else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("short_YYYYMMDD_DIN5008") )) 1177 { 1178 nFormat = 11; 1179 } 1180 else 1181 { 1182 throw xml::sax::SAXException( 1183 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid date-format value!") ), 1184 Reference< XInterface >(), Any() ); 1185 } 1186 1187 _xControlModel->setPropertyValue( rPropName, makeAny( nFormat ) ); 1188 return true; 1189 } 1190 return false; 1191 } 1192 //__________________________________________________________________________________________________ 1193 bool ImportContext::importTimeFormatProperty( 1194 OUString const & rPropName, OUString const & rAttrName, 1195 Reference< xml::input::XAttributes > const & xAttributes ) 1196 { 1197 OUString aFormat( 1198 xAttributes->getValueByUidName( 1199 _pImport->XMLNS_DIALOGS_UID, rAttrName ) ); 1200 if (aFormat.getLength()) 1201 { 1202 sal_Int16 nFormat; 1203 if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("24h_short") )) 1204 { 1205 nFormat = 0; 1206 } 1207 else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("24h_long") )) 1208 { 1209 nFormat = 1; 1210 } 1211 else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("12h_short") )) 1212 { 1213 nFormat = 2; 1214 } 1215 else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("12h_long") )) 1216 { 1217 nFormat = 3; 1218 } 1219 else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Duration_short") )) 1220 { 1221 nFormat = 4; 1222 } 1223 else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Duration_long") )) 1224 { 1225 nFormat = 5; 1226 } 1227 else 1228 { 1229 throw xml::sax::SAXException( 1230 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid time-format value!") ), 1231 Reference< XInterface >(), Any() ); 1232 } 1233 1234 _xControlModel->setPropertyValue( rPropName, makeAny( nFormat ) ); 1235 return true; 1236 } 1237 return false; 1238 } 1239 //__________________________________________________________________________________________________ 1240 bool ImportContext::importOrientationProperty( 1241 OUString const & rPropName, OUString const & rAttrName, 1242 Reference< xml::input::XAttributes > const & xAttributes ) 1243 { 1244 OUString aOrient( 1245 xAttributes->getValueByUidName( 1246 _pImport->XMLNS_DIALOGS_UID, rAttrName ) ); 1247 if (aOrient.getLength()) 1248 { 1249 sal_Int32 nOrient; 1250 if (aOrient.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("horizontal") )) 1251 { 1252 nOrient = 0; 1253 } 1254 else if (aOrient.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("vertical") )) 1255 { 1256 nOrient = 1; 1257 } 1258 else 1259 { 1260 throw xml::sax::SAXException( 1261 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid orientation value!") ), 1262 Reference< XInterface >(), Any() ); 1263 } 1264 1265 _xControlModel->setPropertyValue( rPropName, makeAny( nOrient ) ); 1266 return true; 1267 } 1268 return false; 1269 } 1270 //__________________________________________________________________________________________________ 1271 bool ImportContext::importLineEndFormatProperty( 1272 OUString const & rPropName, OUString const & rAttrName, 1273 Reference< xml::input::XAttributes > const & xAttributes ) 1274 { 1275 OUString aFormat( 1276 xAttributes->getValueByUidName( 1277 _pImport->XMLNS_DIALOGS_UID, rAttrName ) ); 1278 if (aFormat.getLength()) 1279 { 1280 sal_Int16 nFormat; 1281 if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("carriage-return") )) 1282 { 1283 nFormat = awt::LineEndFormat::CARRIAGE_RETURN; 1284 } 1285 else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("line-feed") )) 1286 { 1287 nFormat = awt::LineEndFormat::LINE_FEED; 1288 } 1289 else if (aFormat.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("carriage-return-line-feed") )) 1290 { 1291 nFormat = awt::LineEndFormat::CARRIAGE_RETURN_LINE_FEED; 1292 } 1293 else 1294 { 1295 throw xml::sax::SAXException( 1296 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid line end format value!") ), 1297 Reference< XInterface >(), Any() ); 1298 } 1299 1300 _xControlModel->setPropertyValue( rPropName, makeAny( nFormat ) ); 1301 return true; 1302 } 1303 return false; 1304 } 1305 //__________________________________________________________________________________________________ 1306 bool ImportContext::importSelectionTypeProperty( 1307 OUString const & rPropName, OUString const & rAttrName, 1308 Reference< xml::input::XAttributes > const & xAttributes ) 1309 { 1310 OUString aSelectionType( 1311 xAttributes->getValueByUidName( 1312 _pImport->XMLNS_DIALOGS_UID, rAttrName ) ); 1313 if (aSelectionType.getLength()) 1314 { 1315 view::SelectionType eSelectionType; 1316 1317 if (aSelectionType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("none") )) 1318 { 1319 eSelectionType = view::SelectionType_NONE; 1320 } 1321 else if (aSelectionType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("single") )) 1322 { 1323 eSelectionType = view::SelectionType_SINGLE; 1324 } 1325 else if (aSelectionType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("multi") )) 1326 { 1327 eSelectionType = view::SelectionType_MULTI; 1328 } 1329 else if (aSelectionType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("range") )) 1330 { 1331 eSelectionType = view::SelectionType_RANGE; 1332 } 1333 else 1334 { 1335 throw xml::sax::SAXException( 1336 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid selection type value!") ), 1337 Reference< XInterface >(), Any() ); 1338 } 1339 1340 _xControlModel->setPropertyValue( rPropName, makeAny( eSelectionType ) ); 1341 return true; 1342 } 1343 return false; 1344 } 1345 1346 //================================================================================================== 1347 struct StringTriple 1348 { 1349 char const * first; 1350 char const * second; 1351 char const * third; 1352 }; 1353 static StringTriple const s_aEventTranslations[] = 1354 { 1355 // from xmloff/source/forms/formevents.cxx 1356 // 28.09.2001 tbe added on-adjustmentvaluechange 1357 { "com.sun.star.form.XApproveActionListener", "approveAction", "on-approveaction" }, 1358 { "com.sun.star.awt.XActionListener", "actionPerformed", "on-performaction" }, 1359 { "com.sun.star.form.XChangeListener", "changed", "on-change" }, 1360 { "com.sun.star.awt.XTextListener", "textChanged", "on-textchange" }, 1361 { "com.sun.star.awt.XItemListener", "itemStateChanged", "on-itemstatechange" }, 1362 { "com.sun.star.awt.XFocusListener", "focusGained", "on-focus" }, 1363 { "com.sun.star.awt.XFocusListener", "focusLost", "on-blur" }, 1364 { "com.sun.star.awt.XKeyListener", "keyPressed", "on-keydown" }, 1365 { "com.sun.star.awt.XKeyListener", "keyReleased", "on-keyup" }, 1366 { "com.sun.star.awt.XMouseListener", "mouseEntered", "on-mouseover" }, 1367 { "com.sun.star.awt.XMouseMotionListener", "mouseDragged", "on-mousedrag" }, 1368 { "com.sun.star.awt.XMouseMotionListener", "mouseMoved", "on-mousemove" }, 1369 { "com.sun.star.awt.XMouseListener", "mousePressed", "on-mousedown" }, 1370 { "com.sun.star.awt.XMouseListener", "mouseReleased", "on-mouseup" }, 1371 { "com.sun.star.awt.XMouseListener", "mouseExited", "on-mouseout" }, 1372 { "com.sun.star.form.XResetListener", "approveReset", "on-approvereset" }, 1373 { "com.sun.star.form.XResetListener", "resetted", "on-reset" }, 1374 { "com.sun.star.form.XSubmitListener", "approveSubmit", "on-submit" }, 1375 { "com.sun.star.form.XUpdateListener", "approveUpdate", "on-approveupdate" }, 1376 { "com.sun.star.form.XUpdateListener", "updated", "on-update" }, 1377 { "com.sun.star.form.XLoadListener", "loaded", "on-load" }, 1378 { "com.sun.star.form.XLoadListener", "reloading", "on-startreload" }, 1379 { "com.sun.star.form.XLoadListener", "reloaded", "on-reload" }, 1380 { "com.sun.star.form.XLoadListener", "unloading", "on-startunload" }, 1381 { "com.sun.star.form.XLoadListener", "unloaded", "on-unload" }, 1382 { "com.sun.star.form.XConfirmDeleteListener", "confirmDelete", "on-confirmdelete" }, 1383 { "com.sun.star.sdb.XRowSetApproveListener", "approveRowChange", "on-approverowchange" }, 1384 { "com.sun.star.sdbc.XRowSetListener", "rowChanged", "on-rowchange" }, 1385 { "com.sun.star.sdb.XRowSetApproveListener", "approveCursorMove", "on-approvecursormove" }, 1386 { "com.sun.star.sdbc.XRowSetListener", "cursorMoved", "on-cursormove" }, 1387 { "com.sun.star.form.XDatabaseParameterListener", "approveParameter", "on-supplyparameter" }, 1388 { "com.sun.star.sdb.XSQLErrorListener", "errorOccured", "on-error" }, 1389 { "com.sun.star.awt.XAdjustmentListener", "adjustmentValueChanged", "on-adjustmentvaluechange" }, 1390 { 0, 0, 0 } 1391 }; 1392 extern StringTriple const * const g_pEventTranslations; 1393 StringTriple const * const g_pEventTranslations = s_aEventTranslations; 1394 1395 //__________________________________________________________________________________________________ 1396 void ImportContext::importEvents( 1397 ::std::vector< Reference< xml::input::XElement > > const & rEvents ) 1398 { 1399 Reference< script::XScriptEventsSupplier > xSupplier( 1400 _xControlModel, UNO_QUERY ); 1401 if (xSupplier.is()) 1402 { 1403 Reference< container::XNameContainer > xEvents( xSupplier->getEvents() ); 1404 if (xEvents.is()) 1405 { 1406 for ( size_t nPos = 0; nPos < rEvents.size(); ++nPos ) 1407 { 1408 script::ScriptEventDescriptor descr; 1409 1410 EventElement * pEventElement = static_cast< EventElement * >( rEvents[ nPos ].get() ); 1411 sal_Int32 nUid = pEventElement->getUid(); 1412 OUString aLocalName( pEventElement->getLocalName() ); 1413 Reference< xml::input::XAttributes > xAttributes( 1414 pEventElement->getAttributes() ); 1415 1416 // nowadays script events 1417 if (_pImport->XMLNS_SCRIPT_UID == nUid) 1418 { 1419 if (!getStringAttr( &descr.ScriptType, 1420 OUString( RTL_CONSTASCII_USTRINGPARAM( 1421 "language") ), 1422 xAttributes, 1423 _pImport->XMLNS_SCRIPT_UID ) || 1424 !getStringAttr( &descr.ScriptCode, 1425 OUString( RTL_CONSTASCII_USTRINGPARAM( 1426 "macro-name") ), 1427 xAttributes, 1428 _pImport->XMLNS_SCRIPT_UID )) 1429 { 1430 throw xml::sax::SAXException( 1431 OUString( RTL_CONSTASCII_USTRINGPARAM( 1432 "missing language or macro-name " 1433 "attribute(s) of event!") ), 1434 Reference< XInterface >(), Any() ); 1435 } 1436 if ( descr.ScriptType.equals( OUString( RTL_CONSTASCII_USTRINGPARAM( "StarBasic" ) ) ) ) 1437 { 1438 OUString aLocation; 1439 if (getStringAttr( &aLocation, 1440 OUString( RTL_CONSTASCII_USTRINGPARAM( 1441 "location") ), 1442 xAttributes, 1443 _pImport->XMLNS_SCRIPT_UID )) 1444 { 1445 // prepend location 1446 ::rtl::OUStringBuffer buf; 1447 buf.append( aLocation ); 1448 buf.append( (sal_Unicode)':' ); 1449 buf.append( descr.ScriptCode ); 1450 descr.ScriptCode = buf.makeStringAndClear(); 1451 } 1452 } 1453 else if ( descr.ScriptType.equals( OUString( RTL_CONSTASCII_USTRINGPARAM( "Script" ) ) ) ) 1454 { 1455 // Check if there is a protocol, if not assume 1456 // this is an early scripting framework url ( without 1457 // the protocol ) and fix it up!! 1458 if ( descr.ScriptCode.indexOf( ':' ) == -1 ) 1459 { 1460 ::rtl::OUStringBuffer buf; 1461 buf.append( OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.script:" ) ) ); 1462 buf.append( descr.ScriptCode ); 1463 descr.ScriptCode = buf.makeStringAndClear(); 1464 } 1465 } 1466 1467 // script:event element 1468 if (aLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") )) 1469 { 1470 OUString aEventName; 1471 if (! getStringAttr( 1472 &aEventName, 1473 OUString( 1474 RTL_CONSTASCII_USTRINGPARAM("event-name") ), 1475 xAttributes, 1476 _pImport->XMLNS_SCRIPT_UID )) 1477 { 1478 throw xml::sax::SAXException( 1479 OUString( 1480 RTL_CONSTASCII_USTRINGPARAM( 1481 "missing event-name attribute!") ), 1482 Reference< XInterface >(), Any() ); 1483 } 1484 1485 // lookup in table 1486 ::rtl::OString str( 1487 ::rtl::OUStringToOString( 1488 aEventName, RTL_TEXTENCODING_ASCII_US ) ); 1489 StringTriple const * p = g_pEventTranslations; 1490 while (p->first) 1491 { 1492 if (0 == ::rtl_str_compare( p->third, str.getStr() )) 1493 { 1494 descr.ListenerType = OUString( 1495 p->first, ::rtl_str_getLength( p->first ), 1496 RTL_TEXTENCODING_ASCII_US ); 1497 descr.EventMethod = OUString( 1498 p->second, ::rtl_str_getLength( p->second ), 1499 RTL_TEXTENCODING_ASCII_US ); 1500 break; 1501 } 1502 ++p; 1503 } 1504 1505 if (! p->first) 1506 { 1507 throw xml::sax::SAXException( 1508 OUString( RTL_CONSTASCII_USTRINGPARAM("no matching event-name found!") ), 1509 Reference< XInterface >(), Any() ); 1510 } 1511 } 1512 else // script:listener-event element 1513 { 1514 OSL_ASSERT( aLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("listener-event") ) ); 1515 1516 if (!getStringAttr( 1517 &descr.ListenerType, 1518 OUString( RTL_CONSTASCII_USTRINGPARAM( 1519 "listener-type") ), 1520 xAttributes, 1521 _pImport->XMLNS_SCRIPT_UID ) || 1522 !getStringAttr( 1523 &descr.EventMethod, 1524 OUString( RTL_CONSTASCII_USTRINGPARAM( 1525 "listener-method") ), 1526 xAttributes, _pImport->XMLNS_SCRIPT_UID )) 1527 { 1528 throw xml::sax::SAXException( 1529 OUString( 1530 RTL_CONSTASCII_USTRINGPARAM( 1531 "missing listener-type or " 1532 "listener-method attribute(s)!") ), 1533 Reference< XInterface >(), Any() ); 1534 } 1535 // optional listener param 1536 getStringAttr( 1537 &descr.AddListenerParam, 1538 OUString( RTL_CONSTASCII_USTRINGPARAM( 1539 "listener-param") ), 1540 xAttributes, _pImport->XMLNS_SCRIPT_UID ); 1541 } 1542 } 1543 else // deprecated dlg:event element 1544 { 1545 OSL_ASSERT( 1546 _pImport->XMLNS_DIALOGS_UID == nUid && 1547 aLocalName.equalsAsciiL( 1548 RTL_CONSTASCII_STRINGPARAM("event") ) ); 1549 1550 if (!getStringAttr( &descr.ListenerType, 1551 OUString( RTL_CONSTASCII_USTRINGPARAM( 1552 "listener-type") ), 1553 xAttributes, 1554 _pImport->XMLNS_DIALOGS_UID ) || 1555 !getStringAttr( &descr.EventMethod, 1556 OUString( RTL_CONSTASCII_USTRINGPARAM( 1557 "event-method") ), 1558 xAttributes, 1559 _pImport->XMLNS_DIALOGS_UID )) 1560 { 1561 throw xml::sax::SAXException( 1562 OUString( RTL_CONSTASCII_USTRINGPARAM("missing listener-type or event-method attribute(s)!") ), 1563 Reference< XInterface >(), Any() ); 1564 } 1565 1566 getStringAttr( 1567 &descr.ScriptType, 1568 OUString( RTL_CONSTASCII_USTRINGPARAM("script-type") ), 1569 xAttributes, _pImport->XMLNS_DIALOGS_UID ); 1570 getStringAttr( 1571 &descr.ScriptCode, 1572 OUString( RTL_CONSTASCII_USTRINGPARAM("script-code") ), 1573 xAttributes, _pImport->XMLNS_DIALOGS_UID ); 1574 getStringAttr( 1575 &descr.AddListenerParam, 1576 OUString( RTL_CONSTASCII_USTRINGPARAM("param") ), 1577 xAttributes, _pImport->XMLNS_DIALOGS_UID ); 1578 } 1579 1580 ::rtl::OUStringBuffer buf; 1581 buf.append( descr.ListenerType ); 1582 buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("::") ); 1583 buf.append( descr.EventMethod ); 1584 xEvents->insertByName( buf.makeStringAndClear(), makeAny( descr ) ); 1585 } 1586 } 1587 } 1588 } 1589 //__________________________________________________________________________________________________ 1590 void ImportContext::importDefaults( 1591 sal_Int32 nBaseX, sal_Int32 nBaseY, 1592 Reference< xml::input::XAttributes > const & xAttributes, 1593 bool supportPrintable ) 1594 { 1595 _xControlModel->setPropertyValue( 1596 OUString( RTL_CONSTASCII_USTRINGPARAM("Name") ), 1597 makeAny( _aId ) ); 1598 1599 importShortProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("TabIndex") ), 1600 OUString( RTL_CONSTASCII_USTRINGPARAM("tab-index") ), 1601 xAttributes ); 1602 1603 sal_Bool bDisable = sal_False; 1604 if (getBoolAttr( 1605 &bDisable, OUString( RTL_CONSTASCII_USTRINGPARAM("disabled") ), 1606 xAttributes, _pImport->XMLNS_DIALOGS_UID ) && 1607 bDisable) 1608 { 1609 _xControlModel->setPropertyValue( 1610 OUString( RTL_CONSTASCII_USTRINGPARAM("Enabled") ), makeAny( sal_False ) ); 1611 } 1612 1613 sal_Bool bVisible = sal_True; 1614 if (getBoolAttr( 1615 &bVisible, OUString( RTL_CONSTASCII_USTRINGPARAM("visible") ), 1616 xAttributes, _pImport->XMLNS_DIALOGS_UID ) && !bVisible) 1617 { 1618 try 1619 { 1620 1621 _xControlModel->setPropertyValue( 1622 OUString( RTL_CONSTASCII_USTRINGPARAM("EnableVisible") ), makeAny( sal_False ) ); 1623 } 1624 catch( Exception& ) 1625 { 1626 DBG_UNHANDLED_EXCEPTION(); 1627 } 1628 } 1629 1630 if (!importLongProperty( nBaseX, 1631 OUString( RTL_CONSTASCII_USTRINGPARAM("PositionX") ), 1632 OUString( RTL_CONSTASCII_USTRINGPARAM("left") ), 1633 xAttributes ) || 1634 !importLongProperty( nBaseY, 1635 OUString( RTL_CONSTASCII_USTRINGPARAM("PositionY") ), 1636 OUString( RTL_CONSTASCII_USTRINGPARAM("top") ), 1637 xAttributes ) || 1638 !importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Width") ), 1639 OUString( RTL_CONSTASCII_USTRINGPARAM("width") ), 1640 xAttributes ) || 1641 !importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Height") ), 1642 OUString( RTL_CONSTASCII_USTRINGPARAM("height") ), 1643 xAttributes )) 1644 { 1645 throw xml::sax::SAXException( 1646 OUString( RTL_CONSTASCII_USTRINGPARAM("missing pos size attribute(s)!") ), 1647 Reference< XInterface >(), Any() ); 1648 } 1649 1650 if (supportPrintable) 1651 { 1652 importBooleanProperty( 1653 OUString( RTL_CONSTASCII_USTRINGPARAM("Printable") ), 1654 OUString( RTL_CONSTASCII_USTRINGPARAM("printable") ), 1655 xAttributes ); 1656 } 1657 1658 sal_Int32 nLong; 1659 if (! getLongAttr( 1660 &nLong, 1661 OUString( RTL_CONSTASCII_USTRINGPARAM("page") ), 1662 xAttributes, _pImport->XMLNS_DIALOGS_UID )) 1663 { 1664 nLong = 0; 1665 } 1666 _xControlModel->setPropertyValue( 1667 OUString( RTL_CONSTASCII_USTRINGPARAM("Step") ), 1668 makeAny( nLong ) ); 1669 1670 importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Tag") ), 1671 OUString( RTL_CONSTASCII_USTRINGPARAM("tag") ), 1672 xAttributes ); 1673 importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("HelpText") ), 1674 OUString( RTL_CONSTASCII_USTRINGPARAM("help-text") ), 1675 xAttributes ); 1676 importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("HelpURL") ), 1677 OUString( RTL_CONSTASCII_USTRINGPARAM("help-url") ), 1678 xAttributes ); 1679 } 1680 1681 //################################################################################################## 1682 1683 //__________________________________________________________________________________________________ 1684 Reference< xml::input::XElement > ElementBase::getParent() 1685 throw (RuntimeException) 1686 { 1687 return static_cast< xml::input::XElement * >( _pParent ); 1688 } 1689 //__________________________________________________________________________________________________ 1690 OUString ElementBase::getLocalName() 1691 throw (RuntimeException) 1692 { 1693 return _aLocalName; 1694 } 1695 //__________________________________________________________________________________________________ 1696 sal_Int32 ElementBase::getUid() 1697 throw (RuntimeException) 1698 { 1699 return _nUid; 1700 } 1701 //__________________________________________________________________________________________________ 1702 Reference< xml::input::XAttributes > ElementBase::getAttributes() 1703 throw (RuntimeException) 1704 { 1705 return _xAttributes; 1706 } 1707 //__________________________________________________________________________________________________ 1708 void ElementBase::ignorableWhitespace( 1709 OUString const & /*rWhitespaces*/ ) 1710 throw (xml::sax::SAXException, RuntimeException) 1711 { 1712 // not used 1713 } 1714 //__________________________________________________________________________________________________ 1715 void ElementBase::characters( OUString const & /*rChars*/ ) 1716 throw (xml::sax::SAXException, RuntimeException) 1717 { 1718 // not used, all characters ignored 1719 } 1720 //__________________________________________________________________________________________________ 1721 void ElementBase::endElement() 1722 throw (xml::sax::SAXException, RuntimeException) 1723 { 1724 } 1725 //______________________________________________________________________________ 1726 void ElementBase::processingInstruction( 1727 OUString const & /*Target*/, OUString const & /*Data*/ ) 1728 throw (xml::sax::SAXException, RuntimeException) 1729 { 1730 } 1731 //__________________________________________________________________________________________________ 1732 Reference< xml::input::XElement > ElementBase::startChildElement( 1733 sal_Int32 /*nUid*/, OUString const & /*rLocalName*/, 1734 Reference< xml::input::XAttributes > const & /*xAttributes*/ ) 1735 throw (xml::sax::SAXException, RuntimeException) 1736 { 1737 throw xml::sax::SAXException( 1738 OUString( RTL_CONSTASCII_USTRINGPARAM("unexpected element!") ), 1739 Reference< XInterface >(), Any() ); 1740 } 1741 1742 //__________________________________________________________________________________________________ 1743 ElementBase::ElementBase( 1744 sal_Int32 nUid, OUString const & rLocalName, 1745 Reference< xml::input::XAttributes > const & xAttributes, 1746 ElementBase * pParent, DialogImport * pImport ) 1747 SAL_THROW( () ) 1748 : _pImport( pImport ) 1749 , _pParent( pParent ) 1750 , _nUid( nUid ) 1751 , _aLocalName( rLocalName ) 1752 , _xAttributes( xAttributes ) 1753 { 1754 _pImport->acquire(); 1755 1756 if (_pParent) 1757 { 1758 _pParent->acquire(); 1759 } 1760 } 1761 //__________________________________________________________________________________________________ 1762 ElementBase::~ElementBase() 1763 SAL_THROW( () ) 1764 { 1765 _pImport->release(); 1766 1767 if (_pParent) 1768 { 1769 _pParent->release(); 1770 } 1771 1772 #if OSL_DEBUG_LEVEL > 1 1773 ::rtl::OString aStr( ::rtl::OUStringToOString( 1774 _aLocalName, RTL_TEXTENCODING_ASCII_US ) ); 1775 OSL_TRACE( "ElementBase::~ElementBase(): %s\n", aStr.getStr() ); 1776 #endif 1777 } 1778 1779 //################################################################################################## 1780 1781 // XRoot 1782 // 1783 1784 //______________________________________________________________________________ 1785 void DialogImport::startDocument( 1786 Reference< xml::input::XNamespaceMapping > const & xNamespaceMapping ) 1787 throw (xml::sax::SAXException, RuntimeException) 1788 { 1789 XMLNS_DIALOGS_UID = xNamespaceMapping->getUidByUri( 1790 OUSTR(XMLNS_DIALOGS_URI) ); 1791 XMLNS_SCRIPT_UID = xNamespaceMapping->getUidByUri( 1792 OUSTR(XMLNS_SCRIPT_URI) ); 1793 } 1794 //__________________________________________________________________________________________________ 1795 void DialogImport::endDocument() 1796 throw (xml::sax::SAXException, RuntimeException) 1797 { 1798 // ignored 1799 } 1800 //__________________________________________________________________________________________________ 1801 void DialogImport::processingInstruction( 1802 OUString const & /*rTarget*/, OUString const & /*rData*/ ) 1803 throw (xml::sax::SAXException, RuntimeException) 1804 { 1805 // ignored for now: xxx todo 1806 } 1807 //__________________________________________________________________________________________________ 1808 void DialogImport::setDocumentLocator( 1809 Reference< xml::sax::XLocator > const & /*xLocator*/ ) 1810 throw (xml::sax::SAXException, RuntimeException) 1811 { 1812 // ignored for now: xxx todo 1813 } 1814 //__________________________________________________________________________________________________ 1815 Reference< xml::input::XElement > DialogImport::startRootElement( 1816 sal_Int32 nUid, OUString const & rLocalName, 1817 Reference< xml::input::XAttributes > const & xAttributes ) 1818 throw (xml::sax::SAXException, RuntimeException) 1819 { 1820 if (XMLNS_DIALOGS_UID != nUid) 1821 { 1822 throw xml::sax::SAXException( 1823 OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ), 1824 Reference< XInterface >(), Any() ); 1825 } 1826 // window 1827 else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("window") )) 1828 { 1829 return new WindowElement( rLocalName, xAttributes, 0, this ); 1830 } 1831 else 1832 { 1833 throw xml::sax::SAXException( 1834 OUString( RTL_CONSTASCII_USTRINGPARAM( 1835 "illegal root element (expected window) given: ") ) + 1836 rLocalName, Reference< XInterface >(), Any() ); 1837 } 1838 } 1839 //__________________________________________________________________________________________________ 1840 DialogImport::~DialogImport() 1841 SAL_THROW( () ) 1842 { 1843 #if OSL_DEBUG_LEVEL > 1 1844 OSL_TRACE( "DialogImport::~DialogImport().\n" ); 1845 #endif 1846 } 1847 //__________________________________________________________________________________________________ 1848 Reference< util::XNumberFormatsSupplier > const & DialogImport::getNumberFormatsSupplier() 1849 { 1850 if (! _xSupplier.is()) 1851 { 1852 Reference< XComponentContext > xContext( getComponentContext() ); 1853 Reference< util::XNumberFormatsSupplier > xSupplier( 1854 xContext->getServiceManager()->createInstanceWithContext( 1855 OUString( RTL_CONSTASCII_USTRINGPARAM( 1856 "com.sun.star.util.NumberFormatsSupplier") ), 1857 xContext ), UNO_QUERY ); 1858 1859 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); 1860 if (! _xSupplier.is()) 1861 { 1862 _xSupplier = xSupplier; 1863 } 1864 } 1865 return _xSupplier; 1866 } 1867 1868 //__________________________________________________________________________________________________ 1869 void DialogImport::addStyle( 1870 OUString const & rStyleId, 1871 Reference< xml::input::XElement > const & xStyle ) 1872 SAL_THROW( () ) 1873 { 1874 _styleNames.push_back( rStyleId ); 1875 _styles.push_back( xStyle ); 1876 } 1877 //__________________________________________________________________________________________________ 1878 Reference< xml::input::XElement > DialogImport::getStyle( 1879 OUString const & rStyleId ) const 1880 SAL_THROW( () ) 1881 { 1882 for ( size_t nPos = 0; nPos < _styleNames.size(); ++nPos ) 1883 { 1884 if (_styleNames[ nPos ] == rStyleId) 1885 { 1886 return _styles[ nPos ]; 1887 } 1888 } 1889 return 0; 1890 } 1891 1892 //################################################################################################## 1893 1894 //================================================================================================== 1895 Reference< xml::sax::XDocumentHandler > SAL_CALL importDialogModel( 1896 Reference< container::XNameContainer > const & xDialogModel, 1897 Reference< XComponentContext > const & xContext ) 1898 SAL_THROW( (Exception) ) 1899 { 1900 return ::xmlscript::createDocumentHandler( 1901 static_cast< xml::input::XRoot * >( 1902 new DialogImport( xContext, xDialogModel ) ) ); 1903 } 1904 1905 } 1906