1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xmldlg_import.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmlscript.hxx"
33 #include "imp_share.hxx"
35 #include <osl/diagnose.h>
36 #include <tools/diagnose_ex.h>
37 #include <osl/mutex.hxx>
39 #include <rtl/ustrbuf.hxx>
41 #include <xmlscript/xml_import.hxx>
42 #include <comphelper/processfactory.hxx>
44 #include <com/sun/star/awt/CharSet.hpp>
45 #include <com/sun/star/awt/FontFamily.hpp>
46 #include <com/sun/star/awt/FontPitch.hpp>
47 #include <com/sun/star/awt/FontSlant.hpp>
48 #include <com/sun/star/awt/FontStrikeout.hpp>
49 #include <com/sun/star/awt/FontType.hpp>
50 #include <com/sun/star/awt/FontUnderline.hpp>
51 #include <com/sun/star/awt/FontWeight.hpp>
52 #include <com/sun/star/awt/FontWidth.hpp>
53 #include <com/sun/star/awt/ImagePosition.hpp>
54 #include <com/sun/star/awt/LineEndFormat.hpp>
55 #include <com/sun/star/awt/PushButtonType.hpp>
56 #include <com/sun/star/awt/VisualEffect.hpp>
57 #include <com/sun/star/style/VerticalAlignment.hpp>
59 #include <com/sun/star/script/XScriptEventsSupplier.hpp>
60 #include <com/sun/star/script/ScriptEventDescriptor.hpp>
62 #include <com/sun/star/view/SelectionType.hpp>
63 #include <com/sun/star/document/XStorageBasedDocument.hpp>
64 #include <com/sun/star/script/DocumentScriptLibraryContainer.hpp>
65 #include <com/sun/star/script/XVBACompat.hpp>
67 using namespace ::com::sun::star
;
68 using namespace ::com::sun::star::uno
;
69 using namespace ::com::sun::star::frame
;
70 using ::rtl::OUString
;
75 //__________________________________________________________________________________________________
76 void EventElement::endElement()
77 throw (xml::sax::SAXException
, RuntimeException
)
79 static_cast< ControlElement
* >( _pParent
)->_events
.push_back( this );
81 //__________________________________________________________________________________________________
82 ControlElement::ControlElement(
83 OUString
const & rLocalName
,
84 Reference
< xml::input::XAttributes
> const & xAttributes
,
85 ElementBase
* pParent
, DialogImport
* pImport
)
88 pImport
->XMLNS_DIALOGS_UID
, rLocalName
, xAttributes
, pParent
, pImport
)
93 _nBasePosX
= static_cast< ControlElement
* >( _pParent
)->_nBasePosX
;
94 _nBasePosY
= static_cast< ControlElement
* >( _pParent
)->_nBasePosY
;
103 //__________________________________________________________________________________________________
104 Reference
< xml::input::XElement
> ControlElement::getStyle(
105 Reference
< xml::input::XAttributes
> const & xAttributes
)
108 xAttributes
->getValueByUidName(
109 _pImport
->XMLNS_DIALOGS_UID
,
110 OUString( RTL_CONSTASCII_USTRINGPARAM("style-id") ) ) );
111 if (aStyleId
.getLength())
113 return _pImport
->getStyle( aStyleId
);
115 return Reference
< xml::input::XElement
>();
117 //__________________________________________________________________________________________________
118 OUString
ControlElement::getControlId(
119 Reference
< xml::input::XAttributes
> const & xAttributes
)
122 xAttributes
->getValueByUidName(
123 _pImport
->XMLNS_DIALOGS_UID
,
124 OUString( RTL_CONSTASCII_USTRINGPARAM("id") ) ) );
125 if (! aId
.getLength())
127 throw xml::sax::SAXException(
128 OUString( RTL_CONSTASCII_USTRINGPARAM("missing id attribute!") ),
129 Reference
< XInterface
>(), Any() );
134 //##################################################################################################
136 //__________________________________________________________________________________________________
137 bool StyleElement::importTextColorStyle(
138 Reference
< beans::XPropertySet
> const & xProps
)
140 if ((_inited
& 0x2) != 0)
142 if ((_hasValue
& 0x2) != 0)
144 xProps
->setPropertyValue(
145 OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ),
146 makeAny( _textColor
) );
153 if (getLongAttr( &_textColor
,
154 OUString( RTL_CONSTASCII_USTRINGPARAM("text-color") ),
155 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
158 xProps
->setPropertyValue(
159 OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ),
160 makeAny( _textColor
) );
165 //__________________________________________________________________________________________________
166 bool StyleElement::importTextLineColorStyle(
167 Reference
< beans::XPropertySet
> const & xProps
)
169 if ((_inited
& 0x20) != 0)
171 if ((_hasValue
& 0x20) != 0)
173 xProps
->setPropertyValue(
174 OUString( RTL_CONSTASCII_USTRINGPARAM("TextLineColor") ),
175 makeAny( _textLineColor
) );
182 if (getLongAttr( &_textLineColor
,
183 OUString( RTL_CONSTASCII_USTRINGPARAM("textline-color") ),
184 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
187 xProps
->setPropertyValue(
188 OUString( RTL_CONSTASCII_USTRINGPARAM("TextLineColor") ),
189 makeAny( _textLineColor
) );
194 //__________________________________________________________________________________________________
195 bool StyleElement::importFillColorStyle(
196 Reference
< beans::XPropertySet
> const & xProps
)
198 if ((_inited
& 0x10) != 0)
200 if ((_hasValue
& 0x10) != 0)
202 xProps
->setPropertyValue(
203 OUString( RTL_CONSTASCII_USTRINGPARAM("FillColor") ), makeAny( _fillColor
) );
212 OUString( RTL_CONSTASCII_USTRINGPARAM("fill-color") ),
213 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
216 xProps
->setPropertyValue(
217 OUString( RTL_CONSTASCII_USTRINGPARAM("FillColor") ),
218 makeAny( _fillColor
) );
223 //__________________________________________________________________________________________________
224 bool StyleElement::importBackgroundColorStyle(
225 Reference
< beans::XPropertySet
> const & xProps
)
227 if ((_inited
& 0x1) != 0)
229 if ((_hasValue
& 0x1) != 0)
231 xProps
->setPropertyValue(
232 OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ), makeAny( _backgroundColor
) );
241 OUString( RTL_CONSTASCII_USTRINGPARAM("background-color") ),
242 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
245 xProps
->setPropertyValue(
246 OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ), makeAny( _backgroundColor
) );
252 //__________________________________________________________________________________________________
253 bool StyleElement::importBorderStyle(
254 Reference
< beans::XPropertySet
> const & xProps
)
256 if ((_inited
& 0x4) != 0)
258 if ((_hasValue
& 0x4) != 0)
260 xProps
->setPropertyValue(
261 OUSTR("Border"), makeAny( _border
== BORDER_SIMPLE_COLOR
262 ? BORDER_SIMPLE
: _border
) );
263 if (_border
== BORDER_SIMPLE_COLOR
)
264 xProps
->setPropertyValue( OUSTR("BorderColor"),
265 makeAny(_borderColor
) );
274 &aValue
, OUSTR("border"),
275 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
)) {
276 if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("none") ))
277 _border
= BORDER_NONE
;
278 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("3d") ))
280 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("simple") ))
281 _border
= BORDER_SIMPLE
;
283 _border
= BORDER_SIMPLE_COLOR
;
284 _borderColor
= toInt32(aValue
);
288 importBorderStyle(xProps
); // write values
293 //______________________________________________________________________________
294 bool StyleElement::importVisualEffectStyle(
295 Reference
<beans::XPropertySet
> const & xProps
)
297 if ((_inited
& 0x40) != 0)
299 if ((_hasValue
& 0x40) != 0)
301 xProps
->setPropertyValue( OUSTR("VisualEffect"),
302 makeAny(_visualEffect
) );
310 if (getStringAttr( &aValue
, OUString( RTL_CONSTASCII_USTRINGPARAM("look") ),
311 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
313 if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("none") ))
315 _visualEffect
= awt::VisualEffect::NONE
;
317 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("3d") ))
319 _visualEffect
= awt::VisualEffect::LOOK3D
;
321 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("simple") ))
323 _visualEffect
= awt::VisualEffect::FLAT
;
329 xProps
->setPropertyValue( OUSTR("VisualEffect"),
330 makeAny(_visualEffect
) );
335 //__________________________________________________________________________________________________
336 void StyleElement::setFontProperties(
337 Reference
< beans::XPropertySet
> const & xProps
)
339 xProps
->setPropertyValue(
340 OUString( RTL_CONSTASCII_USTRINGPARAM("FontDescriptor") ), makeAny( _descr
) );
341 xProps
->setPropertyValue(
342 OUString( RTL_CONSTASCII_USTRINGPARAM("FontEmphasisMark") ), makeAny( _fontEmphasisMark
) );
343 xProps
->setPropertyValue(
344 OUString( RTL_CONSTASCII_USTRINGPARAM("FontRelief") ), makeAny( _fontRelief
) );
346 //__________________________________________________________________________________________________
347 bool StyleElement::importFontStyle(
348 Reference
< beans::XPropertySet
> const & xProps
)
350 if ((_inited
& 0x8) != 0)
352 if ((_hasValue
& 0x8) != 0)
354 setFontProperties( xProps
);
364 // dialog:font-name CDATA #IMPLIED
365 bFontImport
= getStringAttr(
366 &_descr
.Name
, OUString( RTL_CONSTASCII_USTRINGPARAM("font-name") ),
367 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
);
369 // dialog:font-height %numeric; #IMPLIED
371 &aValue
, OUString( RTL_CONSTASCII_USTRINGPARAM("font-height") ),
372 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
374 _descr
.Height
= (sal_Int16
)toInt32( aValue
);
377 // dialog:font-width %numeric; #IMPLIED
379 &aValue
, OUString( RTL_CONSTASCII_USTRINGPARAM("font-width") ),
380 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
382 _descr
.Width
= (sal_Int16
)toInt32( aValue
);
385 // dialog:font-stylename CDATA #IMPLIED
386 bFontImport
|= getStringAttr(
388 OUString( RTL_CONSTASCII_USTRINGPARAM("font-stylename") ),
389 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
);
391 // dialog:font-family "(decorative|modern|roman|script|swiss|system)" #IMPLIED
393 &aValue
, OUString( RTL_CONSTASCII_USTRINGPARAM("font-family") ),
394 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
396 if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("decorative") ))
398 _descr
.Family
= awt::FontFamily::DECORATIVE
;
400 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("modern") ))
402 _descr
.Family
= awt::FontFamily::MODERN
;
404 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("roman") ))
406 _descr
.Family
= awt::FontFamily::ROMAN
;
408 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("script") ))
410 _descr
.Family
= awt::FontFamily::SCRIPT
;
412 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("swiss") ))
414 _descr
.Family
= awt::FontFamily::SWISS
;
416 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("system") ))
418 _descr
.Family
= awt::FontFamily::SYSTEM
;
422 throw xml::sax::SAXException(
423 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-family style!") ),
424 Reference
< XInterface
>(), Any() );
429 // dialog:font-charset "(ansi|mac|ibmpc_437|ibmpc_850|ibmpc_860|ibmpc_861|ibmpc_863|ibmpc_865|system|symbol)" #IMPLIED
431 &aValue
, OUString( RTL_CONSTASCII_USTRINGPARAM("font-charset") ),
432 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
434 if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ansi") ))
436 _descr
.CharSet
= awt::CharSet::ANSI
;
438 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("mac") ))
440 _descr
.CharSet
= awt::CharSet::MAC
;
442 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ibmpc_437") ))
444 _descr
.CharSet
= awt::CharSet::IBMPC_437
;
446 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ibmpc_850") ))
448 _descr
.CharSet
= awt::CharSet::IBMPC_850
;
450 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ibmpc_860") ))
452 _descr
.CharSet
= awt::CharSet::IBMPC_860
;
454 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ibmpc_861") ))
456 _descr
.CharSet
= awt::CharSet::IBMPC_861
;
458 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ibmpc_863") ))
460 _descr
.CharSet
= awt::CharSet::IBMPC_863
;
462 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ibmpc_865") ))
464 _descr
.CharSet
= awt::CharSet::IBMPC_865
;
466 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("system") ))
468 _descr
.CharSet
= awt::CharSet::SYSTEM
;
470 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("symbol") ))
472 _descr
.CharSet
= awt::CharSet::SYMBOL
;
476 throw xml::sax::SAXException(
477 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-charset style!") ),
478 Reference
< XInterface
>(), Any() );
483 // dialog:font-pitch "(fixed|variable)" #IMPLIED
485 &aValue
, OUString( RTL_CONSTASCII_USTRINGPARAM("font-pitch") ),
486 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
488 if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("fixed") ))
490 _descr
.Pitch
= awt::FontPitch::FIXED
;
492 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("variable") ))
494 _descr
.Pitch
= awt::FontPitch::VARIABLE
;
498 throw xml::sax::SAXException(
499 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-pitch style!") ),
500 Reference
< XInterface
>(), Any() );
505 // dialog:font-charwidth CDATA #IMPLIED
507 &aValue
, OUString( RTL_CONSTASCII_USTRINGPARAM("font-charwidth") ),
508 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
510 _descr
.CharacterWidth
= aValue
.toFloat();
513 // dialog:font-weight CDATA #IMPLIED
515 &aValue
, OUString( RTL_CONSTASCII_USTRINGPARAM("font-weight") ),
516 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
518 _descr
.Weight
= aValue
.toFloat();
522 // dialog:font-slant "(oblique|italic|reverse_oblique|reverse_italic)" #IMPLIED
524 &aValue
, OUString( RTL_CONSTASCII_USTRINGPARAM("font-slant") ),
525 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
527 if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("oblique") ))
529 _descr
.Slant
= awt::FontSlant_OBLIQUE
;
531 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("italic") ))
533 _descr
.Slant
= awt::FontSlant_ITALIC
;
535 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("reverse_oblique") ))
537 _descr
.Slant
= awt::FontSlant_REVERSE_OBLIQUE
;
539 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("reverse_italic") ))
541 _descr
.Slant
= awt::FontSlant_REVERSE_ITALIC
;
545 throw xml::sax::SAXException(
546 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-slant style!") ),
547 Reference
< XInterface
>(), Any() );
552 // dialog:font-underline "(single|double|dotted|dash|longdash|dashdot|dashdotdot|smallwave|wave|doublewave|bold|bolddotted|bolddash|boldlongdash|bolddashdot|bolddashdotdot|boldwave)" #IMPLIED
554 &aValue
, OUString( RTL_CONSTASCII_USTRINGPARAM("font-underline") ),
555 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
557 if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("single") ))
559 _descr
.Underline
= awt::FontUnderline::SINGLE
;
561 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("double") ))
563 _descr
.Underline
= awt::FontUnderline::DOUBLE
;
565 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("dotted") ))
567 _descr
.Underline
= awt::FontUnderline::DOTTED
;
569 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("dash") ))
571 _descr
.Underline
= awt::FontUnderline::DASH
;
573 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("longdash") ))
575 _descr
.Underline
= awt::FontUnderline::LONGDASH
;
577 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("dashdot") ))
579 _descr
.Underline
= awt::FontUnderline::DASHDOT
;
581 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("dashdotdot") ))
583 _descr
.Underline
= awt::FontUnderline::DASHDOTDOT
;
585 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("smallwave") ))
587 _descr
.Underline
= awt::FontUnderline::SMALLWAVE
;
589 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("wave") ))
591 _descr
.Underline
= awt::FontUnderline::WAVE
;
593 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("doublewave") ))
595 _descr
.Underline
= awt::FontUnderline::DOUBLEWAVE
;
597 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bold") ))
599 _descr
.Underline
= awt::FontUnderline::BOLD
;
601 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bolddotted") ))
603 _descr
.Underline
= awt::FontUnderline::BOLDDOTTED
;
605 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bolddash") ))
607 _descr
.Underline
= awt::FontUnderline::BOLDDASH
;
609 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("boldlongdash") ))
611 _descr
.Underline
= awt::FontUnderline::BOLDLONGDASH
;
613 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bolddashdot") ))
615 _descr
.Underline
= awt::FontUnderline::BOLDDASHDOT
;
617 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bolddashdotdot") ))
619 _descr
.Underline
= awt::FontUnderline::BOLDDASHDOTDOT
;
621 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("boldwave") ))
623 _descr
.Underline
= awt::FontUnderline::BOLDWAVE
;
627 throw xml::sax::SAXException(
628 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-underline style!") ),
629 Reference
< XInterface
>(), Any() );
634 // dialog:font-strikeout "(single|double|bold|slash|x)" #IMPLIED
636 &aValue
, OUString( RTL_CONSTASCII_USTRINGPARAM("font-strikeout") ),
637 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
639 if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("single") ))
641 _descr
.Strikeout
= awt::FontStrikeout::SINGLE
;
643 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("double") ))
645 _descr
.Strikeout
= awt::FontStrikeout::DOUBLE
;
647 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bold") ))
649 _descr
.Strikeout
= awt::FontStrikeout::BOLD
;
651 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("slash") ))
653 _descr
.Strikeout
= awt::FontStrikeout::SLASH
;
655 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("x") ))
657 _descr
.Strikeout
= awt::FontStrikeout::X
;
661 throw xml::sax::SAXException(
662 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-strikeout style!") ),
663 Reference
< XInterface
>(), Any() );
668 // dialog:font-orientation CDATA #IMPLIED
671 OUString( RTL_CONSTASCII_USTRINGPARAM("font-orientation") ),
672 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
674 _descr
.Orientation
= aValue
.toFloat();
677 // dialog:font-kerning %boolean; #IMPLIED
678 bFontImport
|= getBoolAttr(
680 OUString( RTL_CONSTASCII_USTRINGPARAM("font-kerning") ),
681 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
);
682 // dialog:font-wordlinemode %boolean; #IMPLIED
683 bFontImport
|= getBoolAttr(
684 &_descr
.WordLineMode
,
685 OUString( RTL_CONSTASCII_USTRINGPARAM("font-wordlinemode") ),
686 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
);
688 // dialog:font-type "(raster|device|scalable)" #IMPLIED
690 &aValue
, OUString( RTL_CONSTASCII_USTRINGPARAM("font-type") ),
691 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
693 if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("raster") ))
695 _descr
.Type
= awt::FontType::RASTER
;
697 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("device") ))
699 _descr
.Type
= awt::FontType::DEVICE
;
701 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("scalable") ))
703 _descr
.Type
= awt::FontType::SCALABLE
;
707 throw xml::sax::SAXException(
708 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-type style!") ),
709 Reference
< XInterface
>(), Any() );
714 // additional properties which are not part of the FontDescriptor struct
715 // dialog:font-relief (none|embossed|engraved) #IMPLIED
717 &aValue
, OUString( RTL_CONSTASCII_USTRINGPARAM("font-relief") ),
718 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
720 if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("none") ))
722 _fontRelief
= awt::FontRelief::NONE
;
724 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("embossed") ))
726 _fontRelief
= awt::FontRelief::EMBOSSED
;
728 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("engraved") ))
730 _fontRelief
= awt::FontRelief::ENGRAVED
;
734 throw xml::sax::SAXException(
735 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-relief style!") ),
736 Reference
< XInterface
>(), Any() );
740 // dialog:font-emphasismark (none|dot|circle|disc|accent|above|below) #IMPLIED
743 OUString( RTL_CONSTASCII_USTRINGPARAM("font-emphasismark") ),
744 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
746 if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("none") ))
748 _fontEmphasisMark
= awt::FontEmphasisMark::NONE
;
750 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("dot") ))
752 _fontEmphasisMark
= awt::FontEmphasisMark::DOT
;
754 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("circle") ))
756 _fontEmphasisMark
= awt::FontEmphasisMark::CIRCLE
;
758 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("disc") ))
760 _fontEmphasisMark
= awt::FontEmphasisMark::DISC
;
762 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("accent") ))
764 _fontEmphasisMark
= awt::FontEmphasisMark::ACCENT
;
766 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("above") ))
768 _fontEmphasisMark
= awt::FontEmphasisMark::ABOVE
;
770 else if (aValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("below") ))
772 _fontEmphasisMark
= awt::FontEmphasisMark::BELOW
;
776 throw xml::sax::SAXException(
777 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-emphasismark style!") ),
778 Reference
< XInterface
>(), Any() );
783 // ==================================================
787 setFontProperties( xProps
);
793 //##################################################################################################
795 //__________________________________________________________________________________________________
796 bool ImportContext::importStringProperty(
797 OUString
const & rPropName
, OUString
const & rAttrName
,
798 Reference
< xml::input::XAttributes
> const & xAttributes
)
801 xAttributes
->getValueByUidName(
802 _pImport
->XMLNS_DIALOGS_UID
, rAttrName
) );
803 if (aValue
.getLength())
805 _xControlModel
->setPropertyValue( rPropName
, makeAny( aValue
) );
810 //__________________________________________________________________________________________________
811 bool ImportContext::importDoubleProperty(
812 OUString
const & rPropName
, OUString
const & rAttrName
,
813 Reference
< xml::input::XAttributes
> const & xAttributes
)
816 xAttributes
->getValueByUidName(
817 _pImport
->XMLNS_DIALOGS_UID
, rAttrName
) );
818 if (aValue
.getLength())
820 _xControlModel
->setPropertyValue( rPropName
, makeAny( aValue
.toDouble() ) );
825 //__________________________________________________________________________________________________
826 bool ImportContext::importBooleanProperty(
827 OUString
const & rPropName
, OUString
const & rAttrName
,
828 Reference
< xml::input::XAttributes
> const & xAttributes
)
832 &bBool
, rAttrName
, xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
834 _xControlModel
->setPropertyValue( rPropName
, makeAny( bBool
) );
839 //__________________________________________________________________________________________________
840 bool ImportContext::importLongProperty(
841 OUString
const & rPropName
, OUString
const & rAttrName
,
842 Reference
< xml::input::XAttributes
> const & xAttributes
)
845 xAttributes
->getValueByUidName(
846 _pImport
->XMLNS_DIALOGS_UID
, rAttrName
) );
847 if (aValue
.getLength())
849 _xControlModel
->setPropertyValue( rPropName
, makeAny( toInt32( aValue
) ) );
854 //__________________________________________________________________________________________________
855 bool ImportContext::importLongProperty(
857 OUString
const & rPropName
, OUString
const & rAttrName
,
858 Reference
< xml::input::XAttributes
> const & xAttributes
)
861 xAttributes
->getValueByUidName(
862 _pImport
->XMLNS_DIALOGS_UID
, rAttrName
) );
863 if (aValue
.getLength())
865 _xControlModel
->setPropertyValue( rPropName
, makeAny( toInt32( aValue
) + nOffset
) );
870 //__________________________________________________________________________________________________
871 bool ImportContext::importHexLongProperty(
872 OUString
const & rPropName
, OUString
const & rAttrName
,
873 Reference
< xml::input::XAttributes
> const & xAttributes
)
876 xAttributes
->getValueByUidName(
877 _pImport
->XMLNS_DIALOGS_UID
, rAttrName
) );
878 if (aValue
.getLength())
880 _xControlModel
->setPropertyValue( rPropName
, makeAny( toInt32( aValue
) ) );
885 //__________________________________________________________________________________________________
886 bool ImportContext::importShortProperty(
887 OUString
const & rPropName
, OUString
const & rAttrName
,
888 Reference
< xml::input::XAttributes
> const & xAttributes
)
891 xAttributes
->getValueByUidName(
892 _pImport
->XMLNS_DIALOGS_UID
, rAttrName
) );
893 if (aValue
.getLength())
895 _xControlModel
->setPropertyValue( rPropName
, makeAny( (sal_Int16
)toInt32( aValue
) ) );
900 //__________________________________________________________________________________________________
901 bool ImportContext::importAlignProperty(
902 OUString
const & rPropName
, OUString
const & rAttrName
,
903 Reference
< xml::input::XAttributes
> const & xAttributes
)
906 xAttributes
->getValueByUidName(
907 _pImport
->XMLNS_DIALOGS_UID
, rAttrName
) );
908 if (aAlign
.getLength())
911 if (aAlign
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("left") ))
915 else if (aAlign
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("center") ))
919 else if (aAlign
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("right") ))
923 else if (aAlign
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("none") ))
925 nAlign
= 0; // default
929 throw xml::sax::SAXException(
930 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid align value!") ),
931 Reference
< XInterface
>(), Any() );
934 _xControlModel
->setPropertyValue( rPropName
, makeAny( nAlign
) );
939 //__________________________________________________________________________________________________
940 bool ImportContext::importVerticalAlignProperty(
941 OUString
const & rPropName
, OUString
const & rAttrName
,
942 Reference
< xml::input::XAttributes
> const & xAttributes
)
945 xAttributes
->getValueByUidName(
946 _pImport
->XMLNS_DIALOGS_UID
, rAttrName
) );
947 if (aAlign
.getLength())
949 style::VerticalAlignment eAlign
;
951 if (aAlign
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("top") ))
953 eAlign
= style::VerticalAlignment_TOP
;
955 else if (aAlign
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("center") ))
957 eAlign
= style::VerticalAlignment_MIDDLE
;
959 else if (aAlign
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bottom") ))
961 eAlign
= style::VerticalAlignment_BOTTOM
;
965 throw xml::sax::SAXException(
966 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid vertical align value!") ),
967 Reference
< XInterface
>(), Any() );
970 _xControlModel
->setPropertyValue( rPropName
, makeAny( eAlign
) );
975 //__________________________________________________________________________________________________
976 bool ImportContext::importImageAlignProperty(
977 OUString
const & rPropName
, OUString
const & rAttrName
,
978 Reference
< xml::input::XAttributes
> const & xAttributes
)
981 xAttributes
->getValueByUidName(
982 _pImport
->XMLNS_DIALOGS_UID
, rAttrName
) );
983 if (aAlign
.getLength())
986 if (aAlign
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("left") ))
990 else if (aAlign
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("top") ))
994 else if (aAlign
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("right") ))
998 else if (aAlign
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bottom") ))
1004 throw xml::sax::SAXException(
1005 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid image align value!") ),
1006 Reference
< XInterface
>(), Any() );
1009 _xControlModel
->setPropertyValue( rPropName
, makeAny( nAlign
) );
1014 //__________________________________________________________________________________________________
1015 bool ImportContext::importImagePositionProperty(
1016 OUString
const & rPropName
, OUString
const & rAttrName
,
1017 Reference
< xml::input::XAttributes
> const & xAttributes
)
1020 xAttributes
->getValueByUidName(
1021 _pImport
->XMLNS_DIALOGS_UID
, rAttrName
) );
1022 if (aPosition
.getLength())
1024 sal_Int16 nPosition
;
1025 if (aPosition
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("left-top") ))
1027 nPosition
= awt::ImagePosition::LeftTop
;
1029 else if (aPosition
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("left-center") ))
1031 nPosition
= awt::ImagePosition::LeftCenter
;
1033 else if (aPosition
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("left-bottom") ))
1035 nPosition
= awt::ImagePosition::LeftBottom
;
1037 else if (aPosition
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("right-top") ))
1039 nPosition
= awt::ImagePosition::RightTop
;
1041 else if (aPosition
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("right-center") ))
1043 nPosition
= awt::ImagePosition::RightCenter
;
1045 else if (aPosition
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("right-bottom") ))
1047 nPosition
= awt::ImagePosition::RightBottom
;
1049 else if (aPosition
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("top-left") ))
1051 nPosition
= awt::ImagePosition::AboveLeft
;
1053 else if (aPosition
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("top-center") ))
1055 nPosition
= awt::ImagePosition::AboveCenter
;
1057 else if (aPosition
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("top-right") ))
1059 nPosition
= awt::ImagePosition::AboveRight
;
1061 else if (aPosition
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bottom-left") ))
1063 nPosition
= awt::ImagePosition::BelowLeft
;
1065 else if (aPosition
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bottom-center") ))
1067 nPosition
= awt::ImagePosition::BelowCenter
;
1069 else if (aPosition
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bottom-right") ))
1071 nPosition
= awt::ImagePosition::BelowRight
;
1073 else if (aPosition
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("center") ))
1075 nPosition
= awt::ImagePosition::Centered
;
1079 throw xml::sax::SAXException(
1080 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid image position value!") ),
1081 Reference
< XInterface
>(), Any() );
1084 _xControlModel
->setPropertyValue( rPropName
, makeAny( nPosition
) );
1089 //__________________________________________________________________________________________________
1090 bool ImportContext::importButtonTypeProperty(
1091 OUString
const & rPropName
, OUString
const & rAttrName
,
1092 Reference
< xml::input::XAttributes
> const & xAttributes
)
1094 OUString
buttonType(
1095 xAttributes
->getValueByUidName(
1096 _pImport
->XMLNS_DIALOGS_UID
, rAttrName
) );
1097 if (buttonType
.getLength())
1099 sal_Int16 nButtonType
;
1100 if (buttonType
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("standard") ))
1102 nButtonType
= awt::PushButtonType_STANDARD
;
1104 else if (buttonType
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ok") ))
1106 nButtonType
= awt::PushButtonType_OK
;
1108 else if (buttonType
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("cancel") ))
1110 nButtonType
= awt::PushButtonType_CANCEL
;
1112 else if (buttonType
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("help") ))
1114 nButtonType
= awt::PushButtonType_HELP
;
1118 throw xml::sax::SAXException(
1119 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid button-type value!") ),
1120 Reference
< XInterface
>(), Any() );
1123 _xControlModel
->setPropertyValue( rPropName
, makeAny( nButtonType
) );
1128 //__________________________________________________________________________________________________
1129 bool ImportContext::importDateFormatProperty(
1130 OUString
const & rPropName
, OUString
const & rAttrName
,
1131 Reference
< xml::input::XAttributes
> const & xAttributes
)
1134 xAttributes
->getValueByUidName(
1135 _pImport
->XMLNS_DIALOGS_UID
, rAttrName
) );
1136 if (aFormat
.getLength())
1139 if (aFormat
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("system_short") ))
1143 else if (aFormat
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("system_short_YY") ))
1147 else if (aFormat
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("system_short_YYYY") ))
1151 else if (aFormat
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("system_long") ))
1155 else if (aFormat
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("short_DDMMYY") ))
1159 else if (aFormat
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("short_MMDDYY") ))
1163 else if (aFormat
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("short_YYMMDD") ))
1167 else if (aFormat
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("short_DDMMYYYY") ))
1171 else if (aFormat
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("short_MMDDYYYY") ))
1175 else if (aFormat
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("short_YYYYMMDD") ))
1179 else if (aFormat
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("short_YYMMDD_DIN5008") ))
1183 else if (aFormat
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("short_YYYYMMDD_DIN5008") ))
1189 throw xml::sax::SAXException(
1190 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid date-format value!") ),
1191 Reference
< XInterface
>(), Any() );
1194 _xControlModel
->setPropertyValue( rPropName
, makeAny( nFormat
) );
1199 //__________________________________________________________________________________________________
1200 bool ImportContext::importTimeFormatProperty(
1201 OUString
const & rPropName
, OUString
const & rAttrName
,
1202 Reference
< xml::input::XAttributes
> const & xAttributes
)
1205 xAttributes
->getValueByUidName(
1206 _pImport
->XMLNS_DIALOGS_UID
, rAttrName
) );
1207 if (aFormat
.getLength())
1210 if (aFormat
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("24h_short") ))
1214 else if (aFormat
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("24h_long") ))
1218 else if (aFormat
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("12h_short") ))
1222 else if (aFormat
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("12h_long") ))
1226 else if (aFormat
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Duration_short") ))
1230 else if (aFormat
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Duration_long") ))
1236 throw xml::sax::SAXException(
1237 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid time-format value!") ),
1238 Reference
< XInterface
>(), Any() );
1241 _xControlModel
->setPropertyValue( rPropName
, makeAny( nFormat
) );
1246 //__________________________________________________________________________________________________
1247 bool ImportContext::importOrientationProperty(
1248 OUString
const & rPropName
, OUString
const & rAttrName
,
1249 Reference
< xml::input::XAttributes
> const & xAttributes
)
1252 xAttributes
->getValueByUidName(
1253 _pImport
->XMLNS_DIALOGS_UID
, rAttrName
) );
1254 if (aOrient
.getLength())
1257 if (aOrient
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("horizontal") ))
1261 else if (aOrient
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("vertical") ))
1267 throw xml::sax::SAXException(
1268 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid orientation value!") ),
1269 Reference
< XInterface
>(), Any() );
1272 _xControlModel
->setPropertyValue( rPropName
, makeAny( nOrient
) );
1277 //__________________________________________________________________________________________________
1278 bool ImportContext::importLineEndFormatProperty(
1279 OUString
const & rPropName
, OUString
const & rAttrName
,
1280 Reference
< xml::input::XAttributes
> const & xAttributes
)
1283 xAttributes
->getValueByUidName(
1284 _pImport
->XMLNS_DIALOGS_UID
, rAttrName
) );
1285 if (aFormat
.getLength())
1288 if (aFormat
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("carriage-return") ))
1290 nFormat
= awt::LineEndFormat::CARRIAGE_RETURN
;
1292 else if (aFormat
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("line-feed") ))
1294 nFormat
= awt::LineEndFormat::LINE_FEED
;
1296 else if (aFormat
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("carriage-return-line-feed") ))
1298 nFormat
= awt::LineEndFormat::CARRIAGE_RETURN_LINE_FEED
;
1302 throw xml::sax::SAXException(
1303 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid line end format value!") ),
1304 Reference
< XInterface
>(), Any() );
1307 _xControlModel
->setPropertyValue( rPropName
, makeAny( nFormat
) );
1312 //__________________________________________________________________________________________________
1313 bool ImportContext::importSelectionTypeProperty(
1314 OUString
const & rPropName
, OUString
const & rAttrName
,
1315 Reference
< xml::input::XAttributes
> const & xAttributes
)
1317 OUString
aSelectionType(
1318 xAttributes
->getValueByUidName(
1319 _pImport
->XMLNS_DIALOGS_UID
, rAttrName
) );
1320 if (aSelectionType
.getLength())
1322 view::SelectionType eSelectionType
;
1324 if (aSelectionType
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("none") ))
1326 eSelectionType
= view::SelectionType_NONE
;
1328 else if (aSelectionType
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("single") ))
1330 eSelectionType
= view::SelectionType_SINGLE
;
1332 else if (aSelectionType
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("multi") ))
1334 eSelectionType
= view::SelectionType_MULTI
;
1336 else if (aSelectionType
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("range") ))
1338 eSelectionType
= view::SelectionType_RANGE
;
1342 throw xml::sax::SAXException(
1343 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid selection type value!") ),
1344 Reference
< XInterface
>(), Any() );
1347 _xControlModel
->setPropertyValue( rPropName
, makeAny( eSelectionType
) );
1353 //==================================================================================================
1357 char const * second
;
1360 static StringTriple
const s_aEventTranslations
[] =
1362 // from xmloff/source/forms/formevents.cxx
1363 // 28.09.2001 tbe added on-adjustmentvaluechange
1364 { "com.sun.star.form.XApproveActionListener", "approveAction", "on-approveaction" },
1365 { "com.sun.star.awt.XActionListener", "actionPerformed", "on-performaction" },
1366 { "com.sun.star.form.XChangeListener", "changed", "on-change" },
1367 { "com.sun.star.awt.XTextListener", "textChanged", "on-textchange" },
1368 { "com.sun.star.awt.XItemListener", "itemStateChanged", "on-itemstatechange" },
1369 { "com.sun.star.awt.XFocusListener", "focusGained", "on-focus" },
1370 { "com.sun.star.awt.XFocusListener", "focusLost", "on-blur" },
1371 { "com.sun.star.awt.XKeyListener", "keyPressed", "on-keydown" },
1372 { "com.sun.star.awt.XKeyListener", "keyReleased", "on-keyup" },
1373 { "com.sun.star.awt.XMouseListener", "mouseEntered", "on-mouseover" },
1374 { "com.sun.star.awt.XMouseMotionListener", "mouseDragged", "on-mousedrag" },
1375 { "com.sun.star.awt.XMouseMotionListener", "mouseMoved", "on-mousemove" },
1376 { "com.sun.star.awt.XMouseListener", "mousePressed", "on-mousedown" },
1377 { "com.sun.star.awt.XMouseListener", "mouseReleased", "on-mouseup" },
1378 { "com.sun.star.awt.XMouseListener", "mouseExited", "on-mouseout" },
1379 { "com.sun.star.form.XResetListener", "approveReset", "on-approvereset" },
1380 { "com.sun.star.form.XResetListener", "resetted", "on-reset" },
1381 { "com.sun.star.form.XSubmitListener", "approveSubmit", "on-submit" },
1382 { "com.sun.star.form.XUpdateListener", "approveUpdate", "on-approveupdate" },
1383 { "com.sun.star.form.XUpdateListener", "updated", "on-update" },
1384 { "com.sun.star.form.XLoadListener", "loaded", "on-load" },
1385 { "com.sun.star.form.XLoadListener", "reloading", "on-startreload" },
1386 { "com.sun.star.form.XLoadListener", "reloaded", "on-reload" },
1387 { "com.sun.star.form.XLoadListener", "unloading", "on-startunload" },
1388 { "com.sun.star.form.XLoadListener", "unloaded", "on-unload" },
1389 { "com.sun.star.form.XConfirmDeleteListener", "confirmDelete", "on-confirmdelete" },
1390 { "com.sun.star.sdb.XRowSetApproveListener", "approveRowChange", "on-approverowchange" },
1391 { "com.sun.star.sdbc.XRowSetListener", "rowChanged", "on-rowchange" },
1392 { "com.sun.star.sdb.XRowSetApproveListener", "approveCursorMove", "on-approvecursormove" },
1393 { "com.sun.star.sdbc.XRowSetListener", "cursorMoved", "on-cursormove" },
1394 { "com.sun.star.form.XDatabaseParameterListener", "approveParameter", "on-supplyparameter" },
1395 { "com.sun.star.sdb.XSQLErrorListener", "errorOccured", "on-error" },
1396 { "com.sun.star.awt.XAdjustmentListener", "adjustmentValueChanged", "on-adjustmentvaluechange" },
1399 extern StringTriple
const * const g_pEventTranslations
;
1400 StringTriple
const * const g_pEventTranslations
= s_aEventTranslations
;
1402 //__________________________________________________________________________________________________
1403 void ImportContext::importEvents(
1404 ::std::vector
< Reference
< xml::input::XElement
> > const & rEvents
)
1406 Reference
< script::XScriptEventsSupplier
> xSupplier(
1407 _xControlModel
, UNO_QUERY
);
1410 Reference
< container::XNameContainer
> xEvents( xSupplier
->getEvents() );
1413 for ( size_t nPos
= 0; nPos
< rEvents
.size(); ++nPos
)
1415 script::ScriptEventDescriptor descr
;
1417 EventElement
* pEventElement
= static_cast< EventElement
* >( rEvents
[ nPos
].get() );
1418 sal_Int32 nUid
= pEventElement
->getUid();
1419 OUString
aLocalName( pEventElement
->getLocalName() );
1420 Reference
< xml::input::XAttributes
> xAttributes(
1421 pEventElement
->getAttributes() );
1423 // nowadays script events
1424 if (_pImport
->XMLNS_SCRIPT_UID
== nUid
)
1426 if (!getStringAttr( &descr
.ScriptType
,
1427 OUString( RTL_CONSTASCII_USTRINGPARAM(
1430 _pImport
->XMLNS_SCRIPT_UID
) ||
1431 !getStringAttr( &descr
.ScriptCode
,
1432 OUString( RTL_CONSTASCII_USTRINGPARAM(
1435 _pImport
->XMLNS_SCRIPT_UID
))
1437 throw xml::sax::SAXException(
1438 OUString( RTL_CONSTASCII_USTRINGPARAM(
1439 "missing language or macro-name "
1440 "attribute(s) of event!") ),
1441 Reference
< XInterface
>(), Any() );
1443 if ( descr
.ScriptType
.equals( OUString( RTL_CONSTASCII_USTRINGPARAM( "StarBasic" ) ) ) )
1446 if (getStringAttr( &aLocation
,
1447 OUString( RTL_CONSTASCII_USTRINGPARAM(
1450 _pImport
->XMLNS_SCRIPT_UID
))
1453 ::rtl::OUStringBuffer buf
;
1454 buf
.append( aLocation
);
1455 buf
.append( (sal_Unicode
)':' );
1456 buf
.append( descr
.ScriptCode
);
1457 descr
.ScriptCode
= buf
.makeStringAndClear();
1460 else if ( descr
.ScriptType
.equals( OUString( RTL_CONSTASCII_USTRINGPARAM( "Script" ) ) ) )
1462 // Check if there is a protocol, if not assume
1463 // this is an early scripting framework url ( without
1464 // the protocol ) and fix it up!!
1465 if ( descr
.ScriptCode
.indexOf( ':' ) == -1 )
1467 ::rtl::OUStringBuffer buf
;
1468 buf
.append( OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.script:" ) ) );
1469 buf
.append( descr
.ScriptCode
);
1470 descr
.ScriptCode
= buf
.makeStringAndClear();
1474 // script:event element
1475 if (aLocalName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") ))
1477 OUString aEventName
;
1478 if (! getStringAttr(
1481 RTL_CONSTASCII_USTRINGPARAM("event-name") ),
1483 _pImport
->XMLNS_SCRIPT_UID
))
1485 throw xml::sax::SAXException(
1487 RTL_CONSTASCII_USTRINGPARAM(
1488 "missing event-name attribute!") ),
1489 Reference
< XInterface
>(), Any() );
1494 ::rtl::OUStringToOString(
1495 aEventName
, RTL_TEXTENCODING_ASCII_US
) );
1496 StringTriple
const * p
= g_pEventTranslations
;
1499 if (0 == ::rtl_str_compare( p
->third
, str
.getStr() ))
1501 descr
.ListenerType
= OUString(
1502 p
->first
, ::rtl_str_getLength( p
->first
),
1503 RTL_TEXTENCODING_ASCII_US
);
1504 descr
.EventMethod
= OUString(
1505 p
->second
, ::rtl_str_getLength( p
->second
),
1506 RTL_TEXTENCODING_ASCII_US
);
1514 throw xml::sax::SAXException(
1515 OUString( RTL_CONSTASCII_USTRINGPARAM("no matching event-name found!") ),
1516 Reference
< XInterface
>(), Any() );
1519 else // script:listener-event element
1521 OSL_ASSERT( aLocalName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("listener-event") ) );
1524 &descr
.ListenerType
,
1525 OUString( RTL_CONSTASCII_USTRINGPARAM(
1528 _pImport
->XMLNS_SCRIPT_UID
) ||
1531 OUString( RTL_CONSTASCII_USTRINGPARAM(
1532 "listener-method") ),
1533 xAttributes
, _pImport
->XMLNS_SCRIPT_UID
))
1535 throw xml::sax::SAXException(
1537 RTL_CONSTASCII_USTRINGPARAM(
1538 "missing listener-type or "
1539 "listener-method attribute(s)!") ),
1540 Reference
< XInterface
>(), Any() );
1542 // optional listener param
1544 &descr
.AddListenerParam
,
1545 OUString( RTL_CONSTASCII_USTRINGPARAM(
1546 "listener-param") ),
1547 xAttributes
, _pImport
->XMLNS_SCRIPT_UID
);
1550 else // deprecated dlg:event element
1553 _pImport
->XMLNS_DIALOGS_UID
== nUid
&&
1554 aLocalName
.equalsAsciiL(
1555 RTL_CONSTASCII_STRINGPARAM("event") ) );
1557 if (!getStringAttr( &descr
.ListenerType
,
1558 OUString( RTL_CONSTASCII_USTRINGPARAM(
1561 _pImport
->XMLNS_DIALOGS_UID
) ||
1562 !getStringAttr( &descr
.EventMethod
,
1563 OUString( RTL_CONSTASCII_USTRINGPARAM(
1566 _pImport
->XMLNS_DIALOGS_UID
))
1568 throw xml::sax::SAXException(
1569 OUString( RTL_CONSTASCII_USTRINGPARAM("missing listener-type or event-method attribute(s)!") ),
1570 Reference
< XInterface
>(), Any() );
1575 OUString( RTL_CONSTASCII_USTRINGPARAM("script-type") ),
1576 xAttributes
, _pImport
->XMLNS_DIALOGS_UID
);
1579 OUString( RTL_CONSTASCII_USTRINGPARAM("script-code") ),
1580 xAttributes
, _pImport
->XMLNS_DIALOGS_UID
);
1582 &descr
.AddListenerParam
,
1583 OUString( RTL_CONSTASCII_USTRINGPARAM("param") ),
1584 xAttributes
, _pImport
->XMLNS_DIALOGS_UID
);
1587 ::rtl::OUStringBuffer buf
;
1588 buf
.append( descr
.ListenerType
);
1589 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM("::") );
1590 buf
.append( descr
.EventMethod
);
1591 xEvents
->insertByName( buf
.makeStringAndClear(), makeAny( descr
) );
1596 //__________________________________________________________________________________________________
1597 void ImportContext::importDefaults(
1598 sal_Int32 nBaseX
, sal_Int32 nBaseY
,
1599 Reference
< xml::input::XAttributes
> const & xAttributes
,
1600 bool supportPrintable
)
1602 _xControlModel
->setPropertyValue(
1603 OUString( RTL_CONSTASCII_USTRINGPARAM("Name") ),
1606 importShortProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("TabIndex") ),
1607 OUString( RTL_CONSTASCII_USTRINGPARAM("tab-index") ),
1610 sal_Bool bDisable
= sal_False
;
1612 &bDisable
, OUString( RTL_CONSTASCII_USTRINGPARAM("disabled") ),
1613 xAttributes
, _pImport
->XMLNS_DIALOGS_UID
) &&
1616 _xControlModel
->setPropertyValue(
1617 OUString( RTL_CONSTASCII_USTRINGPARAM("Enabled") ), makeAny( sal_False
) );
1620 sal_Bool bVisible
= sal_True
;
1622 &bVisible
, OUString( RTL_CONSTASCII_USTRINGPARAM("visible") ),
1623 xAttributes
, _pImport
->XMLNS_DIALOGS_UID
) && !bVisible
)
1628 _xControlModel
->setPropertyValue(
1629 OUString( RTL_CONSTASCII_USTRINGPARAM("EnableVisible") ), makeAny( sal_False
) );
1633 DBG_UNHANDLED_EXCEPTION();
1637 if (!importLongProperty( nBaseX
,
1638 OUString( RTL_CONSTASCII_USTRINGPARAM("PositionX") ),
1639 OUString( RTL_CONSTASCII_USTRINGPARAM("left") ),
1641 !importLongProperty( nBaseY
,
1642 OUString( RTL_CONSTASCII_USTRINGPARAM("PositionY") ),
1643 OUString( RTL_CONSTASCII_USTRINGPARAM("top") ),
1645 !importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Width") ),
1646 OUString( RTL_CONSTASCII_USTRINGPARAM("width") ),
1648 !importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Height") ),
1649 OUString( RTL_CONSTASCII_USTRINGPARAM("height") ),
1652 throw xml::sax::SAXException(
1653 OUString( RTL_CONSTASCII_USTRINGPARAM("missing pos size attribute(s)!") ),
1654 Reference
< XInterface
>(), Any() );
1657 if (supportPrintable
)
1659 importBooleanProperty(
1660 OUString( RTL_CONSTASCII_USTRINGPARAM("Printable") ),
1661 OUString( RTL_CONSTASCII_USTRINGPARAM("printable") ),
1668 OUString( RTL_CONSTASCII_USTRINGPARAM("page") ),
1669 xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
1673 _xControlModel
->setPropertyValue(
1674 OUString( RTL_CONSTASCII_USTRINGPARAM("Step") ),
1677 importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Tag") ),
1678 OUString( RTL_CONSTASCII_USTRINGPARAM("tag") ),
1680 importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("HelpText") ),
1681 OUString( RTL_CONSTASCII_USTRINGPARAM("help-text") ),
1683 importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("HelpURL") ),
1684 OUString( RTL_CONSTASCII_USTRINGPARAM("help-url") ),
1688 //##################################################################################################
1690 //__________________________________________________________________________________________________
1691 Reference
< xml::input::XElement
> ElementBase::getParent()
1692 throw (RuntimeException
)
1694 return static_cast< xml::input::XElement
* >( _pParent
);
1696 //__________________________________________________________________________________________________
1697 OUString
ElementBase::getLocalName()
1698 throw (RuntimeException
)
1702 //__________________________________________________________________________________________________
1703 sal_Int32
ElementBase::getUid()
1704 throw (RuntimeException
)
1708 //__________________________________________________________________________________________________
1709 Reference
< xml::input::XAttributes
> ElementBase::getAttributes()
1710 throw (RuntimeException
)
1712 return _xAttributes
;
1714 //__________________________________________________________________________________________________
1715 void ElementBase::ignorableWhitespace(
1716 OUString
const & /*rWhitespaces*/ )
1717 throw (xml::sax::SAXException
, RuntimeException
)
1721 //__________________________________________________________________________________________________
1722 void ElementBase::characters( OUString
const & /*rChars*/ )
1723 throw (xml::sax::SAXException
, RuntimeException
)
1725 // not used, all characters ignored
1727 //__________________________________________________________________________________________________
1728 void ElementBase::endElement()
1729 throw (xml::sax::SAXException
, RuntimeException
)
1732 //______________________________________________________________________________
1733 void ElementBase::processingInstruction(
1734 OUString
const & /*Target*/, OUString
const & /*Data*/ )
1735 throw (xml::sax::SAXException
, RuntimeException
)
1738 //__________________________________________________________________________________________________
1739 Reference
< xml::input::XElement
> ElementBase::startChildElement(
1740 sal_Int32
/*nUid*/, OUString
const & /*rLocalName*/,
1741 Reference
< xml::input::XAttributes
> const & /*xAttributes*/ )
1742 throw (xml::sax::SAXException
, RuntimeException
)
1744 throw xml::sax::SAXException(
1745 OUString( RTL_CONSTASCII_USTRINGPARAM("unexpected element!") ),
1746 Reference
< XInterface
>(), Any() );
1749 //__________________________________________________________________________________________________
1750 ElementBase::ElementBase(
1751 sal_Int32 nUid
, OUString
const & rLocalName
,
1752 Reference
< xml::input::XAttributes
> const & xAttributes
,
1753 ElementBase
* pParent
, DialogImport
* pImport
)
1755 : _pImport( pImport
)
1756 , _pParent( pParent
)
1758 , _aLocalName( rLocalName
)
1759 , _xAttributes( xAttributes
)
1761 _pImport
->acquire();
1765 _pParent
->acquire();
1768 //__________________________________________________________________________________________________
1769 ElementBase::~ElementBase()
1772 _pImport
->release();
1776 _pParent
->release();
1779 #if OSL_DEBUG_LEVEL > 1
1780 ::rtl::OString
aStr( ::rtl::OUStringToOString(
1781 _aLocalName
, RTL_TEXTENCODING_ASCII_US
) );
1782 OSL_TRACE( "ElementBase::~ElementBase(): %s\n", aStr
.getStr() );
1786 //##################################################################################################
1791 //______________________________________________________________________________
1792 void DialogImport::startDocument(
1793 Reference
< xml::input::XNamespaceMapping
> const & xNamespaceMapping
)
1794 throw (xml::sax::SAXException
, RuntimeException
)
1796 XMLNS_DIALOGS_UID
= xNamespaceMapping
->getUidByUri(
1797 OUSTR(XMLNS_DIALOGS_URI
) );
1798 XMLNS_SCRIPT_UID
= xNamespaceMapping
->getUidByUri(
1799 OUSTR(XMLNS_SCRIPT_URI
) );
1801 //__________________________________________________________________________________________________
1802 void DialogImport::endDocument()
1803 throw (xml::sax::SAXException
, RuntimeException
)
1807 //__________________________________________________________________________________________________
1808 void DialogImport::processingInstruction(
1809 OUString
const & /*rTarget*/, OUString
const & /*rData*/ )
1810 throw (xml::sax::SAXException
, RuntimeException
)
1812 // ignored for now: xxx todo
1814 //__________________________________________________________________________________________________
1815 void DialogImport::setDocumentLocator(
1816 Reference
< xml::sax::XLocator
> const & /*xLocator*/ )
1817 throw (xml::sax::SAXException
, RuntimeException
)
1819 // ignored for now: xxx todo
1821 //__________________________________________________________________________________________________
1822 Reference
< xml::input::XElement
> DialogImport::startRootElement(
1823 sal_Int32 nUid
, OUString
const & rLocalName
,
1824 Reference
< xml::input::XAttributes
> const & xAttributes
)
1825 throw (xml::sax::SAXException
, RuntimeException
)
1827 if (XMLNS_DIALOGS_UID
!= nUid
)
1829 throw xml::sax::SAXException(
1830 OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ),
1831 Reference
< XInterface
>(), Any() );
1834 else if (rLocalName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("window") ))
1836 return new WindowElement( rLocalName
, xAttributes
, 0, this );
1840 throw xml::sax::SAXException(
1841 OUString( RTL_CONSTASCII_USTRINGPARAM(
1842 "illegal root element (expected window) given: ") ) +
1843 rLocalName
, Reference
< XInterface
>(), Any() );
1846 //__________________________________________________________________________________________________
1847 DialogImport::~DialogImport()
1850 #if OSL_DEBUG_LEVEL > 1
1851 OSL_TRACE( "DialogImport::~DialogImport().\n" );
1854 //__________________________________________________________________________________________________
1855 Reference
< util::XNumberFormatsSupplier
> const & DialogImport::getNumberFormatsSupplier()
1857 if (! _xSupplier
.is())
1859 Reference
< XComponentContext
> xContext( getComponentContext() );
1860 Reference
< util::XNumberFormatsSupplier
> xSupplier(
1861 xContext
->getServiceManager()->createInstanceWithContext(
1862 OUString( RTL_CONSTASCII_USTRINGPARAM(
1863 "com.sun.star.util.NumberFormatsSupplier") ),
1864 xContext
), UNO_QUERY
);
1866 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
1867 if (! _xSupplier
.is())
1869 _xSupplier
= xSupplier
;
1875 //__________________________________________________________________________________________________
1876 void DialogImport::addStyle(
1877 OUString
const & rStyleId
,
1878 Reference
< xml::input::XElement
> const & xStyle
)
1881 _styleNames
.push_back( rStyleId
);
1882 _styles
.push_back( xStyle
);
1884 //__________________________________________________________________________________________________
1885 Reference
< xml::input::XElement
> DialogImport::getStyle(
1886 OUString
const & rStyleId
) const
1889 for ( size_t nPos
= 0; nPos
< _styleNames
.size(); ++nPos
)
1891 if (_styleNames
[ nPos
] == rStyleId
)
1893 return _styles
[ nPos
];
1898 //__________________________________________________________________________________________________
1899 Reference
< script::XLibraryContainer
> DialogImport::getScriptLibraryContainer()
1901 if( !_xScriptLibraryContainer
.is() )
1905 Reference
< document::XStorageBasedDocument
> xStorageDoc( _xDoc
, UNO_QUERY
);
1906 if( xStorageDoc
.is() )
1907 _xScriptLibraryContainer
.set(
1908 script::DocumentScriptLibraryContainer::create( comphelper_getProcessComponentContext(), xStorageDoc
),
1911 catch( const Exception
& )
1916 return _xScriptLibraryContainer
;
1919 //##################################################################################################
1921 //==================================================================================================
1922 Reference
< xml::sax::XDocumentHandler
> SAL_CALL
importDialogModel(
1923 Reference
< container::XNameContainer
> const & xDialogModel
,
1924 Reference
< XComponentContext
> const & xContext
,
1925 Reference
< XModel
> const & xDocument
)
1926 SAL_THROW( (Exception
) )
1928 DialogImport
* pImport
= new DialogImport( xContext
, xDialogModel
, xDocument
);
1929 uno::Reference
< script::XVBACompat
> xVBAModeSource( pImport
->getScriptLibraryContainer(), uno::UNO_QUERY
);
1931 uno::Reference
< beans::XPropertySet
> xDlgProps( xDialogModel
, uno::UNO_QUERY
);
1932 if ( xVBAModeSource
.is() && xDlgProps
.is() && xVBAModeSource
->getVBACompatModeOn() )
1933 xDlgProps
->setPropertyValue( OUSTR("VBAForm"), uno::makeAny( sal_True
) );
1934 return ::xmlscript::createDocumentHandler(
1935 static_cast< xml::input::XRoot
* >( pImport
) );