1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include "imp_share.hxx"
31 #include <osl/diagnose.h>
32 #include <tools/diagnose_ex.h>
33 #include <osl/mutex.hxx>
35 #include <rtl/ustrbuf.hxx>
37 #include <xml_import.hxx>
38 #include <comphelper/processfactory.hxx>
40 #include <com/sun/star/awt/CharSet.hpp>
41 #include <com/sun/star/awt/FontFamily.hpp>
42 #include <com/sun/star/awt/FontPitch.hpp>
43 #include <com/sun/star/awt/FontSlant.hpp>
44 #include <com/sun/star/awt/FontStrikeout.hpp>
45 #include <com/sun/star/awt/FontType.hpp>
46 #include <com/sun/star/awt/FontUnderline.hpp>
47 #include <com/sun/star/awt/FontWeight.hpp>
48 #include <com/sun/star/awt/FontWidth.hpp>
49 #include <com/sun/star/awt/ImagePosition.hpp>
50 #include <com/sun/star/awt/LineEndFormat.hpp>
51 #include <com/sun/star/awt/PushButtonType.hpp>
52 #include <com/sun/star/awt/VisualEffect.hpp>
53 #include <com/sun/star/style/VerticalAlignment.hpp>
55 #include <com/sun/star/script/XScriptEventsSupplier.hpp>
56 #include <com/sun/star/script/ScriptEventDescriptor.hpp>
58 #include <com/sun/star/view/SelectionType.hpp>
59 #include <com/sun/star/lang/XServiceInfo.hpp>
60 #include <com/sun/star/form/binding/XBindableValue.hpp>
61 #include <com/sun/star/form/binding/XValueBinding.hpp>
62 #include <com/sun/star/form/binding/XListEntrySink.hpp>
63 #include <com/sun/star/beans/NamedValue.hpp>
64 #include <com/sun/star/table/CellAddress.hpp>
65 #include <com/sun/star/table/CellRangeAddress.hpp>
66 #include <com/sun/star/document/XGraphicObjectResolver.hpp>
67 #include <com/sun/star/document/XStorageBasedDocument.hpp>
68 #include <com/sun/star/script/DocumentScriptLibraryContainer.hpp>
69 #include <com/sun/star/script/vba/XVBACompatibility.hpp>
71 #include <comphelper/componentcontext.hxx>
73 using namespace ::com::sun::star
;
74 using namespace ::com::sun::star::uno
;
75 using namespace ::com::sun::star::frame
;
76 using ::rtl::OUString
;
81 //__________________________________________________________________________________________________
82 void EventElement::endElement()
83 throw (xml::sax::SAXException
, RuntimeException
)
85 static_cast< ControlElement
* >( _pParent
)->_events
.push_back( this );
87 //__________________________________________________________________________________________________
88 ControlElement::ControlElement(
89 OUString
const & rLocalName
,
90 Reference
< xml::input::XAttributes
> const & xAttributes
,
91 ElementBase
* pParent
, DialogImport
* pImport
)
94 pImport
->XMLNS_DIALOGS_UID
, rLocalName
, xAttributes
, pParent
, pImport
)
99 _nBasePosX
= static_cast< ControlElement
* >( _pParent
)->_nBasePosX
;
100 _nBasePosY
= static_cast< ControlElement
* >( _pParent
)->_nBasePosY
;
109 //__________________________________________________________________________________________________
110 Reference
< xml::input::XElement
> ControlElement::getStyle(
111 Reference
< xml::input::XAttributes
> const & xAttributes
)
114 xAttributes
->getValueByUidName(
115 _pImport
->XMLNS_DIALOGS_UID
,
116 OUString( RTL_CONSTASCII_USTRINGPARAM("style-id") ) ) );
117 if (!aStyleId
.isEmpty())
119 return _pImport
->getStyle( aStyleId
);
121 return Reference
< xml::input::XElement
>();
123 //__________________________________________________________________________________________________
124 OUString
ControlElement::getControlId(
125 Reference
< xml::input::XAttributes
> const & xAttributes
)
128 xAttributes
->getValueByUidName(
129 _pImport
->XMLNS_DIALOGS_UID
,
130 OUString( RTL_CONSTASCII_USTRINGPARAM("id") ) ) );
133 throw xml::sax::SAXException(
134 OUString( RTL_CONSTASCII_USTRINGPARAM("missing id attribute!") ),
135 Reference
< XInterface
>(), Any() );
140 OUString
ControlElement::getControlModelName(
141 OUString
const& rDefaultModel
,
142 Reference
< xml::input::XAttributes
> const & xAttributes
)
145 aModel
= xAttributes
->getValueByUidName(
146 _pImport
->XMLNS_DIALOGS_UID
,
147 OUString( RTL_CONSTASCII_USTRINGPARAM("control-implementation") ) );
148 if (aModel
.isEmpty())
149 aModel
= rDefaultModel
;
154 //##################################################################################################
156 //__________________________________________________________________________________________________
157 bool StyleElement::importTextColorStyle(
158 Reference
< beans::XPropertySet
> const & xProps
)
160 if ((_inited
& 0x2) != 0)
162 if ((_hasValue
& 0x2) != 0)
164 xProps
->setPropertyValue(
165 OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ),
166 makeAny( _textColor
) );
173 if (getLongAttr( &_textColor
,
174 OUString( RTL_CONSTASCII_USTRINGPARAM("text-color") ),
175 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
178 xProps
->setPropertyValue(
179 OUString( RTL_CONSTASCII_USTRINGPARAM("TextColor") ),
180 makeAny( _textColor
) );
185 //__________________________________________________________________________________________________
186 bool StyleElement::importTextLineColorStyle(
187 Reference
< beans::XPropertySet
> const & xProps
)
189 if ((_inited
& 0x20) != 0)
191 if ((_hasValue
& 0x20) != 0)
193 xProps
->setPropertyValue(
194 OUString( RTL_CONSTASCII_USTRINGPARAM("TextLineColor") ),
195 makeAny( _textLineColor
) );
202 if (getLongAttr( &_textLineColor
,
203 OUString( RTL_CONSTASCII_USTRINGPARAM("textline-color") ),
204 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
207 xProps
->setPropertyValue(
208 OUString( RTL_CONSTASCII_USTRINGPARAM("TextLineColor") ),
209 makeAny( _textLineColor
) );
214 //__________________________________________________________________________________________________
215 bool StyleElement::importFillColorStyle(
216 Reference
< beans::XPropertySet
> const & xProps
)
218 if ((_inited
& 0x10) != 0)
220 if ((_hasValue
& 0x10) != 0)
222 xProps
->setPropertyValue(
223 OUString( RTL_CONSTASCII_USTRINGPARAM("FillColor") ), makeAny( _fillColor
) );
232 OUString( RTL_CONSTASCII_USTRINGPARAM("fill-color") ),
233 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
236 xProps
->setPropertyValue(
237 OUString( RTL_CONSTASCII_USTRINGPARAM("FillColor") ),
238 makeAny( _fillColor
) );
243 //__________________________________________________________________________________________________
244 bool StyleElement::importBackgroundColorStyle(
245 Reference
< beans::XPropertySet
> const & xProps
)
247 if ((_inited
& 0x1) != 0)
249 if ((_hasValue
& 0x1) != 0)
251 xProps
->setPropertyValue(
252 OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ), makeAny( _backgroundColor
) );
261 OUString( RTL_CONSTASCII_USTRINGPARAM("background-color") ),
262 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
265 xProps
->setPropertyValue(
266 OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ), makeAny( _backgroundColor
) );
272 //__________________________________________________________________________________________________
273 bool StyleElement::importBorderStyle(
274 Reference
< beans::XPropertySet
> const & xProps
)
276 if ((_inited
& 0x4) != 0)
278 if ((_hasValue
& 0x4) != 0)
280 xProps
->setPropertyValue(
281 OUSTR("Border"), makeAny( _border
== BORDER_SIMPLE_COLOR
282 ? BORDER_SIMPLE
: _border
) );
283 if (_border
== BORDER_SIMPLE_COLOR
)
284 xProps
->setPropertyValue( OUSTR("BorderColor"),
285 makeAny(_borderColor
) );
294 &aValue
, OUSTR("border"),
295 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
)) {
296 if ( aValue
== "none" )
297 _border
= BORDER_NONE
;
298 else if ( aValue
== "3d" )
300 else if ( aValue
== "simple" )
301 _border
= BORDER_SIMPLE
;
303 _border
= BORDER_SIMPLE_COLOR
;
304 _borderColor
= toInt32(aValue
);
308 importBorderStyle(xProps
); // write values
313 //______________________________________________________________________________
314 bool StyleElement::importVisualEffectStyle(
315 Reference
<beans::XPropertySet
> const & xProps
)
317 if ((_inited
& 0x40) != 0)
319 if ((_hasValue
& 0x40) != 0)
321 xProps
->setPropertyValue( OUSTR("VisualEffect"),
322 makeAny(_visualEffect
) );
330 if (getStringAttr( &aValue
, OUString( RTL_CONSTASCII_USTRINGPARAM("look") ),
331 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
333 if ( aValue
== "none" )
335 _visualEffect
= awt::VisualEffect::NONE
;
337 else if ( aValue
== "3d" )
339 _visualEffect
= awt::VisualEffect::LOOK3D
;
341 else if ( aValue
== "simple" )
343 _visualEffect
= awt::VisualEffect::FLAT
;
349 xProps
->setPropertyValue( OUSTR("VisualEffect"),
350 makeAny(_visualEffect
) );
355 //__________________________________________________________________________________________________
356 void StyleElement::setFontProperties(
357 Reference
< beans::XPropertySet
> const & xProps
)
359 xProps
->setPropertyValue(
360 OUString( RTL_CONSTASCII_USTRINGPARAM("FontDescriptor") ), makeAny( _descr
) );
361 xProps
->setPropertyValue(
362 OUString( RTL_CONSTASCII_USTRINGPARAM("FontEmphasisMark") ), makeAny( _fontEmphasisMark
) );
363 xProps
->setPropertyValue(
364 OUString( RTL_CONSTASCII_USTRINGPARAM("FontRelief") ), makeAny( _fontRelief
) );
366 //__________________________________________________________________________________________________
367 bool StyleElement::importFontStyle(
368 Reference
< beans::XPropertySet
> const & xProps
)
370 if ((_inited
& 0x8) != 0)
372 if ((_hasValue
& 0x8) != 0)
374 setFontProperties( xProps
);
384 // dialog:font-name CDATA #IMPLIED
385 bFontImport
= getStringAttr(
386 &_descr
.Name
, OUString( RTL_CONSTASCII_USTRINGPARAM("font-name") ),
387 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
);
389 // dialog:font-height %numeric; #IMPLIED
391 &aValue
, OUString( RTL_CONSTASCII_USTRINGPARAM("font-height") ),
392 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
394 _descr
.Height
= (sal_Int16
)toInt32( aValue
);
397 // dialog:font-width %numeric; #IMPLIED
399 &aValue
, OUString( RTL_CONSTASCII_USTRINGPARAM("font-width") ),
400 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
402 _descr
.Width
= (sal_Int16
)toInt32( aValue
);
405 // dialog:font-stylename CDATA #IMPLIED
406 bFontImport
|= getStringAttr(
408 OUString( RTL_CONSTASCII_USTRINGPARAM("font-stylename") ),
409 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
);
411 // dialog:font-family "(decorative|modern|roman|script|swiss|system)" #IMPLIED
413 &aValue
, OUString( RTL_CONSTASCII_USTRINGPARAM("font-family") ),
414 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
416 if ( aValue
== "decorative" )
418 _descr
.Family
= awt::FontFamily::DECORATIVE
;
420 else if ( aValue
== "modern" )
422 _descr
.Family
= awt::FontFamily::MODERN
;
424 else if ( aValue
== "roman" )
426 _descr
.Family
= awt::FontFamily::ROMAN
;
428 else if ( aValue
== "script" )
430 _descr
.Family
= awt::FontFamily::SCRIPT
;
432 else if ( aValue
== "swiss" )
434 _descr
.Family
= awt::FontFamily::SWISS
;
436 else if ( aValue
== "system" )
438 _descr
.Family
= awt::FontFamily::SYSTEM
;
442 throw xml::sax::SAXException(
443 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-family style!") ),
444 Reference
< XInterface
>(), Any() );
449 // dialog:font-charset "(ansi|mac|ibmpc_437|ibmpc_850|ibmpc_860|ibmpc_861|ibmpc_863|ibmpc_865|system|symbol)" #IMPLIED
451 &aValue
, OUString( RTL_CONSTASCII_USTRINGPARAM("font-charset") ),
452 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
454 if ( aValue
== "ansi" )
456 _descr
.CharSet
= awt::CharSet::ANSI
;
458 else if ( aValue
== "mac" )
460 _descr
.CharSet
= awt::CharSet::MAC
;
462 else if ( aValue
== "ibmpc_437" )
464 _descr
.CharSet
= awt::CharSet::IBMPC_437
;
466 else if ( aValue
== "ibmpc_850" )
468 _descr
.CharSet
= awt::CharSet::IBMPC_850
;
470 else if ( aValue
== "ibmpc_860" )
472 _descr
.CharSet
= awt::CharSet::IBMPC_860
;
474 else if ( aValue
== "ibmpc_861" )
476 _descr
.CharSet
= awt::CharSet::IBMPC_861
;
478 else if ( aValue
== "ibmpc_863" )
480 _descr
.CharSet
= awt::CharSet::IBMPC_863
;
482 else if ( aValue
== "ibmpc_865" )
484 _descr
.CharSet
= awt::CharSet::IBMPC_865
;
486 else if ( aValue
== "system" )
488 _descr
.CharSet
= awt::CharSet::SYSTEM
;
490 else if ( aValue
== "symbol" )
492 _descr
.CharSet
= awt::CharSet::SYMBOL
;
496 throw xml::sax::SAXException(
497 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-charset style!") ),
498 Reference
< XInterface
>(), Any() );
503 // dialog:font-pitch "(fixed|variable)" #IMPLIED
505 &aValue
, OUString( RTL_CONSTASCII_USTRINGPARAM("font-pitch") ),
506 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
508 if ( aValue
== "fixed" )
510 _descr
.Pitch
= awt::FontPitch::FIXED
;
512 else if ( aValue
== "variable" )
514 _descr
.Pitch
= awt::FontPitch::VARIABLE
;
518 throw xml::sax::SAXException(
519 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-pitch style!") ),
520 Reference
< XInterface
>(), Any() );
525 // dialog:font-charwidth CDATA #IMPLIED
527 &aValue
, OUString( RTL_CONSTASCII_USTRINGPARAM("font-charwidth") ),
528 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
530 _descr
.CharacterWidth
= aValue
.toFloat();
533 // dialog:font-weight CDATA #IMPLIED
535 &aValue
, OUString( RTL_CONSTASCII_USTRINGPARAM("font-weight") ),
536 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
538 _descr
.Weight
= aValue
.toFloat();
542 // dialog:font-slant "(oblique|italic|reverse_oblique|reverse_italic)" #IMPLIED
544 &aValue
, OUString( RTL_CONSTASCII_USTRINGPARAM("font-slant") ),
545 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
547 if ( aValue
== "oblique" )
549 _descr
.Slant
= awt::FontSlant_OBLIQUE
;
551 else if ( aValue
== "italic" )
553 _descr
.Slant
= awt::FontSlant_ITALIC
;
555 else if ( aValue
== "reverse_oblique" )
557 _descr
.Slant
= awt::FontSlant_REVERSE_OBLIQUE
;
559 else if ( aValue
== "reverse_italic" )
561 _descr
.Slant
= awt::FontSlant_REVERSE_ITALIC
;
565 throw xml::sax::SAXException(
566 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-slant style!") ),
567 Reference
< XInterface
>(), Any() );
572 // dialog:font-underline "(single|double|dotted|dash|longdash|dashdot|dashdotdot|smallwave|wave|doublewave|bold|bolddotted|bolddash|boldlongdash|bolddashdot|bolddashdotdot|boldwave)" #IMPLIED
574 &aValue
, OUString( RTL_CONSTASCII_USTRINGPARAM("font-underline") ),
575 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
577 if ( aValue
== "single" )
579 _descr
.Underline
= awt::FontUnderline::SINGLE
;
581 else if ( aValue
== "double" )
583 _descr
.Underline
= awt::FontUnderline::DOUBLE
;
585 else if ( aValue
== "dotted" )
587 _descr
.Underline
= awt::FontUnderline::DOTTED
;
589 else if ( aValue
== "dash" )
591 _descr
.Underline
= awt::FontUnderline::DASH
;
593 else if ( aValue
== "longdash" )
595 _descr
.Underline
= awt::FontUnderline::LONGDASH
;
597 else if ( aValue
== "dashdot" )
599 _descr
.Underline
= awt::FontUnderline::DASHDOT
;
601 else if ( aValue
== "dashdotdot" )
603 _descr
.Underline
= awt::FontUnderline::DASHDOTDOT
;
605 else if ( aValue
== "smallwave" )
607 _descr
.Underline
= awt::FontUnderline::SMALLWAVE
;
609 else if ( aValue
== "wave" )
611 _descr
.Underline
= awt::FontUnderline::WAVE
;
613 else if ( aValue
== "doublewave" )
615 _descr
.Underline
= awt::FontUnderline::DOUBLEWAVE
;
617 else if ( aValue
== "bold" )
619 _descr
.Underline
= awt::FontUnderline::BOLD
;
621 else if ( aValue
== "bolddotted" )
623 _descr
.Underline
= awt::FontUnderline::BOLDDOTTED
;
625 else if ( aValue
== "bolddash" )
627 _descr
.Underline
= awt::FontUnderline::BOLDDASH
;
629 else if ( aValue
== "boldlongdash" )
631 _descr
.Underline
= awt::FontUnderline::BOLDLONGDASH
;
633 else if ( aValue
== "bolddashdot" )
635 _descr
.Underline
= awt::FontUnderline::BOLDDASHDOT
;
637 else if ( aValue
== "bolddashdotdot" )
639 _descr
.Underline
= awt::FontUnderline::BOLDDASHDOTDOT
;
641 else if ( aValue
== "boldwave" )
643 _descr
.Underline
= awt::FontUnderline::BOLDWAVE
;
647 throw xml::sax::SAXException(
648 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-underline style!") ),
649 Reference
< XInterface
>(), Any() );
654 // dialog:font-strikeout "(single|double|bold|slash|x)" #IMPLIED
656 &aValue
, OUString( RTL_CONSTASCII_USTRINGPARAM("font-strikeout") ),
657 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
659 if ( aValue
== "single" )
661 _descr
.Strikeout
= awt::FontStrikeout::SINGLE
;
663 else if ( aValue
== "double" )
665 _descr
.Strikeout
= awt::FontStrikeout::DOUBLE
;
667 else if ( aValue
== "bold" )
669 _descr
.Strikeout
= awt::FontStrikeout::BOLD
;
671 else if ( aValue
== "slash" )
673 _descr
.Strikeout
= awt::FontStrikeout::SLASH
;
675 else if ( aValue
== "x" )
677 _descr
.Strikeout
= awt::FontStrikeout::X
;
681 throw xml::sax::SAXException(
682 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-strikeout style!") ),
683 Reference
< XInterface
>(), Any() );
688 // dialog:font-orientation CDATA #IMPLIED
691 OUString( RTL_CONSTASCII_USTRINGPARAM("font-orientation") ),
692 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
694 _descr
.Orientation
= aValue
.toFloat();
697 // dialog:font-kerning %boolean; #IMPLIED
698 bFontImport
|= getBoolAttr(
700 OUString( RTL_CONSTASCII_USTRINGPARAM("font-kerning") ),
701 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
);
702 // dialog:font-wordlinemode %boolean; #IMPLIED
703 bFontImport
|= getBoolAttr(
704 &_descr
.WordLineMode
,
705 OUString( RTL_CONSTASCII_USTRINGPARAM("font-wordlinemode") ),
706 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
);
708 // dialog:font-type "(raster|device|scalable)" #IMPLIED
710 &aValue
, OUString( RTL_CONSTASCII_USTRINGPARAM("font-type") ),
711 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
713 if ( aValue
== "raster" )
715 _descr
.Type
= awt::FontType::RASTER
;
717 else if ( aValue
== "device" )
719 _descr
.Type
= awt::FontType::DEVICE
;
721 else if ( aValue
== "scalable" )
723 _descr
.Type
= awt::FontType::SCALABLE
;
727 throw xml::sax::SAXException(
728 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-type style!") ),
729 Reference
< XInterface
>(), Any() );
734 // additional properties which are not part of the FontDescriptor struct
735 // dialog:font-relief (none|embossed|engraved) #IMPLIED
737 &aValue
, OUString( RTL_CONSTASCII_USTRINGPARAM("font-relief") ),
738 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
740 if ( aValue
== "none" )
742 _fontRelief
= awt::FontRelief::NONE
;
744 else if ( aValue
== "embossed" )
746 _fontRelief
= awt::FontRelief::EMBOSSED
;
748 else if ( aValue
== "engraved" )
750 _fontRelief
= awt::FontRelief::ENGRAVED
;
754 throw xml::sax::SAXException(
755 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-relief style!") ),
756 Reference
< XInterface
>(), Any() );
760 // dialog:font-emphasismark (none|dot|circle|disc|accent|above|below) #IMPLIED
763 OUString( RTL_CONSTASCII_USTRINGPARAM("font-emphasismark") ),
764 _xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
766 if ( aValue
== "none" )
768 _fontEmphasisMark
= awt::FontEmphasisMark::NONE
;
770 else if ( aValue
== "dot" )
772 _fontEmphasisMark
= awt::FontEmphasisMark::DOT
;
774 else if ( aValue
== "circle" )
776 _fontEmphasisMark
= awt::FontEmphasisMark::CIRCLE
;
778 else if ( aValue
== "disc" )
780 _fontEmphasisMark
= awt::FontEmphasisMark::DISC
;
782 else if ( aValue
== "accent" )
784 _fontEmphasisMark
= awt::FontEmphasisMark::ACCENT
;
786 else if ( aValue
== "above" )
788 _fontEmphasisMark
= awt::FontEmphasisMark::ABOVE
;
790 else if ( aValue
== "below" )
792 _fontEmphasisMark
= awt::FontEmphasisMark::BELOW
;
796 throw xml::sax::SAXException(
797 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid font-emphasismark style!") ),
798 Reference
< XInterface
>(), Any() );
803 // ==================================================
807 setFontProperties( xProps
);
813 //##################################################################################################
815 //__________________________________________________________________________________________________
816 bool ImportContext::importStringProperty(
817 OUString
const & rPropName
, OUString
const & rAttrName
,
818 Reference
< xml::input::XAttributes
> const & xAttributes
)
821 xAttributes
->getValueByUidName(
822 _pImport
->XMLNS_DIALOGS_UID
, rAttrName
) );
823 if (!aValue
.isEmpty())
825 _xControlModel
->setPropertyValue( rPropName
, makeAny( aValue
) );
830 //__________________________________________________________________________________________________
831 bool ImportContext::importDoubleProperty(
832 OUString
const & rPropName
, OUString
const & rAttrName
,
833 Reference
< xml::input::XAttributes
> const & xAttributes
)
836 xAttributes
->getValueByUidName(
837 _pImport
->XMLNS_DIALOGS_UID
, rAttrName
) );
838 if (!aValue
.isEmpty())
840 _xControlModel
->setPropertyValue( rPropName
, makeAny( aValue
.toDouble() ) );
846 //__________________________________________________________________________________________________
847 bool ImportContext::importBooleanProperty(
848 OUString
const & rPropName
, OUString
const & rAttrName
,
849 Reference
< xml::input::XAttributes
> const & xAttributes
)
853 &bBool
, rAttrName
, xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
855 _xControlModel
->setPropertyValue( rPropName
, makeAny( bBool
) );
860 //__________________________________________________________________________________________________
861 bool ImportContext::importLongProperty(
862 OUString
const & rPropName
, OUString
const & rAttrName
,
863 Reference
< xml::input::XAttributes
> const & xAttributes
)
866 xAttributes
->getValueByUidName(
867 _pImport
->XMLNS_DIALOGS_UID
, rAttrName
) );
868 if (!aValue
.isEmpty())
870 _xControlModel
->setPropertyValue( rPropName
, makeAny( toInt32( aValue
) ) );
875 //__________________________________________________________________________________________________
876 bool ImportContext::importLongProperty(
878 OUString
const & rPropName
, OUString
const & rAttrName
,
879 Reference
< xml::input::XAttributes
> const & xAttributes
)
882 xAttributes
->getValueByUidName(
883 _pImport
->XMLNS_DIALOGS_UID
, rAttrName
) );
884 if (!aValue
.isEmpty())
886 _xControlModel
->setPropertyValue( rPropName
, makeAny( toInt32( aValue
) + nOffset
) );
891 //__________________________________________________________________________________________________
892 bool ImportContext::importHexLongProperty(
893 OUString
const & rPropName
, OUString
const & rAttrName
,
894 Reference
< xml::input::XAttributes
> const & xAttributes
)
897 xAttributes
->getValueByUidName(
898 _pImport
->XMLNS_DIALOGS_UID
, rAttrName
) );
899 if (!aValue
.isEmpty())
901 _xControlModel
->setPropertyValue( rPropName
, makeAny( toInt32( aValue
) ) );
906 //__________________________________________________________________________________________________
907 bool ImportContext::importShortProperty(
908 OUString
const & rPropName
, OUString
const & rAttrName
,
909 Reference
< xml::input::XAttributes
> const & xAttributes
)
912 xAttributes
->getValueByUidName(
913 _pImport
->XMLNS_DIALOGS_UID
, rAttrName
) );
914 if (!aValue
.isEmpty())
916 _xControlModel
->setPropertyValue( rPropName
, makeAny( (sal_Int16
)toInt32( aValue
) ) );
921 //__________________________________________________________________________________________________
922 bool ImportContext::importAlignProperty(
923 OUString
const & rPropName
, OUString
const & rAttrName
,
924 Reference
< xml::input::XAttributes
> const & xAttributes
)
927 xAttributes
->getValueByUidName(
928 _pImport
->XMLNS_DIALOGS_UID
, rAttrName
) );
929 if (!aAlign
.isEmpty())
932 if ( aAlign
== "left" )
936 else if ( aAlign
== "center" )
940 else if ( aAlign
== "right" )
944 else if ( aAlign
== "none" )
946 nAlign
= 0; // default
950 throw xml::sax::SAXException(
951 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid align value!") ),
952 Reference
< XInterface
>(), Any() );
955 _xControlModel
->setPropertyValue( rPropName
, makeAny( nAlign
) );
960 //__________________________________________________________________________________________________
961 bool ImportContext::importVerticalAlignProperty(
962 OUString
const & rPropName
, OUString
const & rAttrName
,
963 Reference
< xml::input::XAttributes
> const & xAttributes
)
966 xAttributes
->getValueByUidName(
967 _pImport
->XMLNS_DIALOGS_UID
, rAttrName
) );
968 if (!aAlign
.isEmpty())
970 style::VerticalAlignment eAlign
;
972 if ( aAlign
== "top" )
974 eAlign
= style::VerticalAlignment_TOP
;
976 else if ( aAlign
== "center" )
978 eAlign
= style::VerticalAlignment_MIDDLE
;
980 else if ( aAlign
== "bottom" )
982 eAlign
= style::VerticalAlignment_BOTTOM
;
986 throw xml::sax::SAXException(
987 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid vertical align value!") ),
988 Reference
< XInterface
>(), Any() );
991 _xControlModel
->setPropertyValue( rPropName
, makeAny( eAlign
) );
996 //__________________________________________________________________________________________________
997 bool ImportContext::importImageURLProperty(
998 OUString
const & rPropName
, OUString
const & rAttrName
,
999 Reference
< xml::input::XAttributes
> const & xAttributes
)
1001 rtl::OUString sURL
= xAttributes
->getValueByUidName( _pImport
->XMLNS_DIALOGS_UID
, rAttrName
);
1002 if ( !sURL
.isEmpty() )
1004 Reference
< document::XStorageBasedDocument
> xDocStorage( _pImport
->getDocOwner(), UNO_QUERY
);
1006 uno::Reference
< document::XGraphicObjectResolver
> xGraphicResolver
;
1007 if ( xDocStorage
.is() )
1009 uno::Sequence
< Any
> aArgs( 1 );
1010 aArgs
[ 0 ] <<= xDocStorage
->getDocumentStorage();
1011 ::comphelper::ComponentContext
aContext( _pImport
->getComponentContext() );
1012 aContext
.createComponentWithArguments( OUSTR( "com.sun.star.comp.Svx.GraphicImportHelper" ), aArgs
, xGraphicResolver
);
1013 if ( xGraphicResolver
.is() )
1015 rtl::OUString
aTmp( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.Package:" ) );
1019 aTmp
= xGraphicResolver
->resolveGraphicObjectURL( aTmp
);
1020 if ( !aTmp
.isEmpty() )
1023 catch( const uno::Exception
& )
1030 if ( !sURL
.isEmpty() )
1032 Reference
< beans::XPropertySet
> xProps( getControlModel(), UNO_QUERY
);
1035 xProps
->setPropertyValue( rPropName
, makeAny( sURL
) );
1042 //__________________________________________________________________________________________________
1043 bool ImportContext::importDataAwareProperty(
1044 ::rtl::OUString
const & rPropName
,
1045 Reference
<xml::input::XAttributes
> const & xAttributes
)
1047 OUString sLinkedCell
;
1048 OUString sCellRange
;
1049 if ( rPropName
.equals( OUSTR("linked-cell" ) ) )
1050 sLinkedCell
= xAttributes
->getValueByUidName( _pImport
->XMLNS_DIALOGS_UID
, rPropName
);
1051 if ( rPropName
.equals( OUSTR( "source-cell-range" ) ) )
1052 sCellRange
= xAttributes
->getValueByUidName( _pImport
->XMLNS_DIALOGS_UID
, rPropName
);
1054 Reference
< lang::XMultiServiceFactory
> xFac( _pImport
->getDocOwner(), UNO_QUERY
);
1055 if ( xFac
.is() && ( !sLinkedCell
.isEmpty() || !sCellRange
.isEmpty() ) )
1058 if ( !sLinkedCell
.isEmpty() )
1060 Reference
< form::binding::XBindableValue
> xBindable( getControlModel(), uno::UNO_QUERY
);
1061 Reference
< beans::XPropertySet
> xConvertor( xFac
->createInstance( OUSTR( "com.sun.star.table.CellAddressConversion" )), uno::UNO_QUERY
);
1062 if ( xBindable
.is() && xConvertor
.is() )
1064 table::CellAddress aAddress
;
1065 xConvertor
->setPropertyValue( OUSTR( "PersistentRepresentation" ), uno::makeAny( sLinkedCell
) );
1066 xConvertor
->getPropertyValue( OUSTR( "Address" ) ) >>= aAddress
;
1067 beans::NamedValue aArg1
;
1068 aArg1
.Name
= OUSTR("BoundCell");
1069 aArg1
.Value
<<= aAddress
;
1071 uno::Sequence
< uno::Any
> aArgs(1);
1072 aArgs
[ 0 ] <<= aArg1
;
1074 uno::Reference
< form::binding::XValueBinding
> xBinding( xFac
->createInstanceWithArguments( OUSTR("com.sun.star.table.CellValueBinding" ), aArgs
), uno::UNO_QUERY
);
1075 xBindable
->setValueBinding( xBinding
);
1079 // Set up CelllRange
1080 if ( !sCellRange
.isEmpty() )
1082 Reference
< form::binding::XListEntrySink
> xListEntrySink( getControlModel(), uno::UNO_QUERY
);
1083 Reference
< beans::XPropertySet
> xConvertor( xFac
->createInstance( OUSTR( "com.sun.star.table.CellRangeAddressConversion" )), uno::UNO_QUERY
);
1084 if ( xListEntrySink
.is() && xConvertor
.is() )
1086 table::CellRangeAddress aAddress
;
1087 xConvertor
->setPropertyValue( OUSTR( "PersistentRepresentation" ), uno::makeAny( sCellRange
) );
1088 xConvertor
->getPropertyValue( OUSTR( "Address" ) ) >>= aAddress
;
1089 beans::NamedValue aArg1
;
1090 aArg1
.Name
= OUSTR("CellRange");
1091 aArg1
.Value
<<= aAddress
;
1093 uno::Sequence
< uno::Any
> aArgs(1);
1094 aArgs
[ 0 ] <<= aArg1
;
1096 uno::Reference
< form::binding::XListEntrySource
> xSource( xFac
->createInstanceWithArguments( OUSTR("com.sun.star.table.CellRangeListSource" ), aArgs
), uno::UNO_QUERY
);
1097 xListEntrySink
->setListEntrySource( xSource
);
1104 //__________________________________________________________________________________________________
1105 bool ImportContext::importImageAlignProperty(
1106 OUString
const & rPropName
, OUString
const & rAttrName
,
1107 Reference
< xml::input::XAttributes
> const & xAttributes
)
1110 xAttributes
->getValueByUidName(
1111 _pImport
->XMLNS_DIALOGS_UID
, rAttrName
) );
1112 if (!aAlign
.isEmpty())
1115 if ( aAlign
== "left" )
1119 else if ( aAlign
== "top" )
1123 else if ( aAlign
== "right" )
1127 else if ( aAlign
== "bottom" )
1133 throw xml::sax::SAXException(
1134 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid image align value!") ),
1135 Reference
< XInterface
>(), Any() );
1138 _xControlModel
->setPropertyValue( rPropName
, makeAny( nAlign
) );
1143 //__________________________________________________________________________________________________
1144 bool ImportContext::importImagePositionProperty(
1145 OUString
const & rPropName
, OUString
const & rAttrName
,
1146 Reference
< xml::input::XAttributes
> const & xAttributes
)
1149 xAttributes
->getValueByUidName(
1150 _pImport
->XMLNS_DIALOGS_UID
, rAttrName
) );
1151 if (!aPosition
.isEmpty())
1153 sal_Int16 nPosition
;
1154 if ( aPosition
== "left-top" )
1156 nPosition
= awt::ImagePosition::LeftTop
;
1158 else if ( aPosition
== "left-center" )
1160 nPosition
= awt::ImagePosition::LeftCenter
;
1162 else if ( aPosition
== "left-bottom" )
1164 nPosition
= awt::ImagePosition::LeftBottom
;
1166 else if ( aPosition
== "right-top" )
1168 nPosition
= awt::ImagePosition::RightTop
;
1170 else if ( aPosition
== "right-center" )
1172 nPosition
= awt::ImagePosition::RightCenter
;
1174 else if ( aPosition
== "right-bottom" )
1176 nPosition
= awt::ImagePosition::RightBottom
;
1178 else if ( aPosition
== "top-left" )
1180 nPosition
= awt::ImagePosition::AboveLeft
;
1182 else if ( aPosition
== "top-center" )
1184 nPosition
= awt::ImagePosition::AboveCenter
;
1186 else if ( aPosition
== "top-right" )
1188 nPosition
= awt::ImagePosition::AboveRight
;
1190 else if ( aPosition
== "bottom-left" )
1192 nPosition
= awt::ImagePosition::BelowLeft
;
1194 else if ( aPosition
== "bottom-center" )
1196 nPosition
= awt::ImagePosition::BelowCenter
;
1198 else if ( aPosition
== "bottom-right" )
1200 nPosition
= awt::ImagePosition::BelowRight
;
1202 else if ( aPosition
== "center" )
1204 nPosition
= awt::ImagePosition::Centered
;
1208 throw xml::sax::SAXException(
1209 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid image position value!") ),
1210 Reference
< XInterface
>(), Any() );
1213 _xControlModel
->setPropertyValue( rPropName
, makeAny( nPosition
) );
1218 //__________________________________________________________________________________________________
1219 bool ImportContext::importButtonTypeProperty(
1220 OUString
const & rPropName
, OUString
const & rAttrName
,
1221 Reference
< xml::input::XAttributes
> const & xAttributes
)
1223 OUString
buttonType(
1224 xAttributes
->getValueByUidName(
1225 _pImport
->XMLNS_DIALOGS_UID
, rAttrName
) );
1226 if (!buttonType
.isEmpty())
1228 sal_Int16 nButtonType
;
1229 if ( buttonType
== "standard" )
1231 nButtonType
= awt::PushButtonType_STANDARD
;
1233 else if ( buttonType
== "ok" )
1235 nButtonType
= awt::PushButtonType_OK
;
1237 else if ( buttonType
== "cancel" )
1239 nButtonType
= awt::PushButtonType_CANCEL
;
1241 else if ( buttonType
== "help" )
1243 nButtonType
= awt::PushButtonType_HELP
;
1247 throw xml::sax::SAXException(
1248 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid button-type value!") ),
1249 Reference
< XInterface
>(), Any() );
1252 _xControlModel
->setPropertyValue( rPropName
, makeAny( nButtonType
) );
1257 //__________________________________________________________________________________________________
1258 bool ImportContext::importDateFormatProperty(
1259 OUString
const & rPropName
, OUString
const & rAttrName
,
1260 Reference
< xml::input::XAttributes
> const & xAttributes
)
1263 xAttributes
->getValueByUidName(
1264 _pImport
->XMLNS_DIALOGS_UID
, rAttrName
) );
1265 if (!aFormat
.isEmpty())
1268 if ( aFormat
== "system_short" )
1272 else if ( aFormat
== "system_short_YY" )
1276 else if ( aFormat
== "system_short_YYYY" )
1280 else if ( aFormat
== "system_long" )
1284 else if ( aFormat
== "short_DDMMYY" )
1288 else if ( aFormat
== "short_MMDDYY" )
1292 else if ( aFormat
== "short_YYMMDD" )
1296 else if ( aFormat
== "short_DDMMYYYY" )
1300 else if ( aFormat
== "short_MMDDYYYY" )
1304 else if ( aFormat
== "short_YYYYMMDD" )
1308 else if ( aFormat
== "short_YYMMDD_DIN5008" )
1312 else if ( aFormat
== "short_YYYYMMDD_DIN5008" )
1318 throw xml::sax::SAXException(
1319 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid date-format value!") ),
1320 Reference
< XInterface
>(), Any() );
1323 _xControlModel
->setPropertyValue( rPropName
, makeAny( nFormat
) );
1328 //__________________________________________________________________________________________________
1329 bool ImportContext::importTimeFormatProperty(
1330 OUString
const & rPropName
, OUString
const & rAttrName
,
1331 Reference
< xml::input::XAttributes
> const & xAttributes
)
1334 xAttributes
->getValueByUidName(
1335 _pImport
->XMLNS_DIALOGS_UID
, rAttrName
) );
1336 if (!aFormat
.isEmpty())
1339 if ( aFormat
== "24h_short" )
1343 else if ( aFormat
== "24h_long" )
1347 else if ( aFormat
== "12h_short" )
1351 else if ( aFormat
== "12h_long" )
1355 else if ( aFormat
== "Duration_short" )
1359 else if ( aFormat
== "Duration_long" )
1365 throw xml::sax::SAXException(
1366 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid time-format value!") ),
1367 Reference
< XInterface
>(), Any() );
1370 _xControlModel
->setPropertyValue( rPropName
, makeAny( nFormat
) );
1375 //__________________________________________________________________________________________________
1376 bool ImportContext::importOrientationProperty(
1377 OUString
const & rPropName
, OUString
const & rAttrName
,
1378 Reference
< xml::input::XAttributes
> const & xAttributes
)
1381 xAttributes
->getValueByUidName(
1382 _pImport
->XMLNS_DIALOGS_UID
, rAttrName
) );
1383 if (!aOrient
.isEmpty())
1386 if ( aOrient
== "horizontal" )
1390 else if ( aOrient
== "vertical" )
1396 throw xml::sax::SAXException(
1397 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid orientation value!") ),
1398 Reference
< XInterface
>(), Any() );
1401 _xControlModel
->setPropertyValue( rPropName
, makeAny( nOrient
) );
1406 //__________________________________________________________________________________________________
1407 bool ImportContext::importLineEndFormatProperty(
1408 OUString
const & rPropName
, OUString
const & rAttrName
,
1409 Reference
< xml::input::XAttributes
> const & xAttributes
)
1412 xAttributes
->getValueByUidName(
1413 _pImport
->XMLNS_DIALOGS_UID
, rAttrName
) );
1414 if (!aFormat
.isEmpty())
1417 if ( aFormat
== "carriage-return" )
1419 nFormat
= awt::LineEndFormat::CARRIAGE_RETURN
;
1421 else if ( aFormat
== "line-feed" )
1423 nFormat
= awt::LineEndFormat::LINE_FEED
;
1425 else if ( aFormat
== "carriage-return-line-feed" )
1427 nFormat
= awt::LineEndFormat::CARRIAGE_RETURN_LINE_FEED
;
1431 throw xml::sax::SAXException(
1432 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid line end format value!") ),
1433 Reference
< XInterface
>(), Any() );
1436 _xControlModel
->setPropertyValue( rPropName
, makeAny( nFormat
) );
1441 //__________________________________________________________________________________________________
1442 bool ImportContext::importSelectionTypeProperty(
1443 OUString
const & rPropName
, OUString
const & rAttrName
,
1444 Reference
< xml::input::XAttributes
> const & xAttributes
)
1446 OUString
aSelectionType(
1447 xAttributes
->getValueByUidName(
1448 _pImport
->XMLNS_DIALOGS_UID
, rAttrName
) );
1449 if (!aSelectionType
.isEmpty())
1451 view::SelectionType eSelectionType
;
1453 if ( aSelectionType
== "none" )
1455 eSelectionType
= view::SelectionType_NONE
;
1457 else if ( aSelectionType
== "single" )
1459 eSelectionType
= view::SelectionType_SINGLE
;
1461 else if ( aSelectionType
== "multi" )
1463 eSelectionType
= view::SelectionType_MULTI
;
1465 else if ( aSelectionType
== "range" )
1467 eSelectionType
= view::SelectionType_RANGE
;
1471 throw xml::sax::SAXException(
1472 OUString( RTL_CONSTASCII_USTRINGPARAM("invalid selection type value!") ),
1473 Reference
< XInterface
>(), Any() );
1476 _xControlModel
->setPropertyValue( rPropName
, makeAny( eSelectionType
) );
1482 //==================================================================================================
1486 char const * second
;
1489 static StringTriple
const s_aEventTranslations
[] =
1491 // from xmloff/source/forms/formevents.cxx
1492 // 28.09.2001 tbe added on-adjustmentvaluechange
1493 { "com.sun.star.form.XApproveActionListener", "approveAction", "on-approveaction" },
1494 { "com.sun.star.awt.XActionListener", "actionPerformed", "on-performaction" },
1495 { "com.sun.star.form.XChangeListener", "changed", "on-change" },
1496 { "com.sun.star.awt.XTextListener", "textChanged", "on-textchange" },
1497 { "com.sun.star.awt.XItemListener", "itemStateChanged", "on-itemstatechange" },
1498 { "com.sun.star.awt.XFocusListener", "focusGained", "on-focus" },
1499 { "com.sun.star.awt.XFocusListener", "focusLost", "on-blur" },
1500 { "com.sun.star.awt.XKeyListener", "keyPressed", "on-keydown" },
1501 { "com.sun.star.awt.XKeyListener", "keyReleased", "on-keyup" },
1502 { "com.sun.star.awt.XMouseListener", "mouseEntered", "on-mouseover" },
1503 { "com.sun.star.awt.XMouseMotionListener", "mouseDragged", "on-mousedrag" },
1504 { "com.sun.star.awt.XMouseMotionListener", "mouseMoved", "on-mousemove" },
1505 { "com.sun.star.awt.XMouseListener", "mousePressed", "on-mousedown" },
1506 { "com.sun.star.awt.XMouseListener", "mouseReleased", "on-mouseup" },
1507 { "com.sun.star.awt.XMouseListener", "mouseExited", "on-mouseout" },
1508 { "com.sun.star.form.XResetListener", "approveReset", "on-approvereset" },
1509 { "com.sun.star.form.XResetListener", "resetted", "on-reset" },
1510 { "com.sun.star.form.XSubmitListener", "approveSubmit", "on-submit" },
1511 { "com.sun.star.form.XUpdateListener", "approveUpdate", "on-approveupdate" },
1512 { "com.sun.star.form.XUpdateListener", "updated", "on-update" },
1513 { "com.sun.star.form.XLoadListener", "loaded", "on-load" },
1514 { "com.sun.star.form.XLoadListener", "reloading", "on-startreload" },
1515 { "com.sun.star.form.XLoadListener", "reloaded", "on-reload" },
1516 { "com.sun.star.form.XLoadListener", "unloading", "on-startunload" },
1517 { "com.sun.star.form.XLoadListener", "unloaded", "on-unload" },
1518 { "com.sun.star.form.XConfirmDeleteListener", "confirmDelete", "on-confirmdelete" },
1519 { "com.sun.star.sdb.XRowSetApproveListener", "approveRowChange", "on-approverowchange" },
1520 { "com.sun.star.sdbc.XRowSetListener", "rowChanged", "on-rowchange" },
1521 { "com.sun.star.sdb.XRowSetApproveListener", "approveCursorMove", "on-approvecursormove" },
1522 { "com.sun.star.sdbc.XRowSetListener", "cursorMoved", "on-cursormove" },
1523 { "com.sun.star.form.XDatabaseParameterListener", "approveParameter", "on-supplyparameter" },
1524 { "com.sun.star.sdb.XSQLErrorListener", "errorOccured", "on-error" },
1525 { "com.sun.star.awt.XAdjustmentListener", "adjustmentValueChanged", "on-adjustmentvaluechange" },
1528 extern StringTriple
const * const g_pEventTranslations
;
1529 StringTriple
const * const g_pEventTranslations
= s_aEventTranslations
;
1531 //__________________________________________________________________________________________________
1532 void ImportContext::importEvents(
1533 ::std::vector
< Reference
< xml::input::XElement
> > const & rEvents
)
1535 Reference
< script::XScriptEventsSupplier
> xSupplier(
1536 _xControlModel
, UNO_QUERY
);
1539 Reference
< container::XNameContainer
> xEvents( xSupplier
->getEvents() );
1542 for ( size_t nPos
= 0; nPos
< rEvents
.size(); ++nPos
)
1544 script::ScriptEventDescriptor descr
;
1546 EventElement
* pEventElement
= static_cast< EventElement
* >( rEvents
[ nPos
].get() );
1547 sal_Int32 nUid
= pEventElement
->getUid();
1548 OUString
aLocalName( pEventElement
->getLocalName() );
1549 Reference
< xml::input::XAttributes
> xAttributes(
1550 pEventElement
->getAttributes() );
1552 // nowadays script events
1553 if (_pImport
->XMLNS_SCRIPT_UID
== nUid
)
1555 if (!getStringAttr( &descr
.ScriptType
,
1556 OUString( RTL_CONSTASCII_USTRINGPARAM(
1559 _pImport
->XMLNS_SCRIPT_UID
) ||
1560 !getStringAttr( &descr
.ScriptCode
,
1561 OUString( RTL_CONSTASCII_USTRINGPARAM(
1564 _pImport
->XMLNS_SCRIPT_UID
))
1566 throw xml::sax::SAXException(
1567 OUString( RTL_CONSTASCII_USTRINGPARAM(
1568 "missing language or macro-name "
1569 "attribute(s) of event!") ),
1570 Reference
< XInterface
>(), Any() );
1572 if ( descr
.ScriptType
== "StarBasic" )
1575 if (getStringAttr( &aLocation
,
1576 OUString( RTL_CONSTASCII_USTRINGPARAM(
1579 _pImport
->XMLNS_SCRIPT_UID
))
1582 ::rtl::OUStringBuffer buf
;
1583 buf
.append( aLocation
);
1584 buf
.append( (sal_Unicode
)':' );
1585 buf
.append( descr
.ScriptCode
);
1586 descr
.ScriptCode
= buf
.makeStringAndClear();
1589 else if ( descr
.ScriptType
== "Script" )
1591 // Check if there is a protocol, if not assume
1592 // this is an early scripting framework url ( without
1593 // the protocol ) and fix it up!!
1594 if ( descr
.ScriptCode
.indexOf( ':' ) == -1 )
1596 ::rtl::OUStringBuffer buf
;
1597 buf
.append( OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.script:" ) ) );
1598 buf
.append( descr
.ScriptCode
);
1599 descr
.ScriptCode
= buf
.makeStringAndClear();
1603 // script:event element
1604 if ( aLocalName
== "event" )
1606 OUString aEventName
;
1607 if (! getStringAttr(
1610 RTL_CONSTASCII_USTRINGPARAM("event-name") ),
1612 _pImport
->XMLNS_SCRIPT_UID
))
1614 throw xml::sax::SAXException(
1616 RTL_CONSTASCII_USTRINGPARAM(
1617 "missing event-name attribute!") ),
1618 Reference
< XInterface
>(), Any() );
1623 ::rtl::OUStringToOString(
1624 aEventName
, RTL_TEXTENCODING_ASCII_US
) );
1625 StringTriple
const * p
= g_pEventTranslations
;
1628 if (0 == ::rtl_str_compare( p
->third
, str
.getStr() ))
1630 descr
.ListenerType
= OUString(
1631 p
->first
, ::rtl_str_getLength( p
->first
),
1632 RTL_TEXTENCODING_ASCII_US
);
1633 descr
.EventMethod
= OUString(
1634 p
->second
, ::rtl_str_getLength( p
->second
),
1635 RTL_TEXTENCODING_ASCII_US
);
1643 throw xml::sax::SAXException(
1644 OUString( RTL_CONSTASCII_USTRINGPARAM("no matching event-name found!") ),
1645 Reference
< XInterface
>(), Any() );
1648 else // script:listener-event element
1650 OSL_ASSERT( aLocalName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("listener-event") ) );
1653 &descr
.ListenerType
,
1654 OUString( RTL_CONSTASCII_USTRINGPARAM(
1657 _pImport
->XMLNS_SCRIPT_UID
) ||
1660 OUString( RTL_CONSTASCII_USTRINGPARAM(
1661 "listener-method") ),
1662 xAttributes
, _pImport
->XMLNS_SCRIPT_UID
))
1664 throw xml::sax::SAXException(
1666 RTL_CONSTASCII_USTRINGPARAM(
1667 "missing listener-type or "
1668 "listener-method attribute(s)!") ),
1669 Reference
< XInterface
>(), Any() );
1671 // optional listener param
1673 &descr
.AddListenerParam
,
1674 OUString( RTL_CONSTASCII_USTRINGPARAM(
1675 "listener-param") ),
1676 xAttributes
, _pImport
->XMLNS_SCRIPT_UID
);
1679 else // deprecated dlg:event element
1682 _pImport
->XMLNS_DIALOGS_UID
== nUid
&&
1683 aLocalName
.equalsAsciiL(
1684 RTL_CONSTASCII_STRINGPARAM("event") ) );
1686 if (!getStringAttr( &descr
.ListenerType
,
1687 OUString( RTL_CONSTASCII_USTRINGPARAM(
1690 _pImport
->XMLNS_DIALOGS_UID
) ||
1691 !getStringAttr( &descr
.EventMethod
,
1692 OUString( RTL_CONSTASCII_USTRINGPARAM(
1695 _pImport
->XMLNS_DIALOGS_UID
))
1697 throw xml::sax::SAXException(
1698 OUString( RTL_CONSTASCII_USTRINGPARAM("missing listener-type or event-method attribute(s)!") ),
1699 Reference
< XInterface
>(), Any() );
1704 OUString( RTL_CONSTASCII_USTRINGPARAM("script-type") ),
1705 xAttributes
, _pImport
->XMLNS_DIALOGS_UID
);
1708 OUString( RTL_CONSTASCII_USTRINGPARAM("script-code") ),
1709 xAttributes
, _pImport
->XMLNS_DIALOGS_UID
);
1711 &descr
.AddListenerParam
,
1712 OUString( RTL_CONSTASCII_USTRINGPARAM("param") ),
1713 xAttributes
, _pImport
->XMLNS_DIALOGS_UID
);
1716 ::rtl::OUStringBuffer buf
;
1717 buf
.append( descr
.ListenerType
);
1718 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM("::") );
1719 buf
.append( descr
.EventMethod
);
1720 xEvents
->insertByName( buf
.makeStringAndClear(), makeAny( descr
) );
1725 //__________________________________________________________________________________________________
1726 void ImportContext::importDefaults(
1727 sal_Int32 nBaseX
, sal_Int32 nBaseY
,
1728 Reference
< xml::input::XAttributes
> const & xAttributes
,
1729 bool supportPrintable
)
1731 _xControlModel
->setPropertyValue(
1732 OUString( RTL_CONSTASCII_USTRINGPARAM("Name") ),
1735 importShortProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("TabIndex") ),
1736 OUString( RTL_CONSTASCII_USTRINGPARAM("tab-index") ),
1739 sal_Bool bDisable
= sal_False
;
1741 &bDisable
, OUString( RTL_CONSTASCII_USTRINGPARAM("disabled") ),
1742 xAttributes
, _pImport
->XMLNS_DIALOGS_UID
) &&
1745 _xControlModel
->setPropertyValue(
1746 OUString( RTL_CONSTASCII_USTRINGPARAM("Enabled") ), makeAny( sal_False
) );
1749 sal_Bool bVisible
= sal_True
;
1751 &bVisible
, OUString( RTL_CONSTASCII_USTRINGPARAM("visible") ),
1752 xAttributes
, _pImport
->XMLNS_DIALOGS_UID
) && !bVisible
)
1757 _xControlModel
->setPropertyValue(
1758 OUString( RTL_CONSTASCII_USTRINGPARAM("EnableVisible") ), makeAny( sal_False
) );
1762 DBG_UNHANDLED_EXCEPTION();
1766 if (!importLongProperty( nBaseX
,
1767 OUString( RTL_CONSTASCII_USTRINGPARAM("PositionX") ),
1768 OUString( RTL_CONSTASCII_USTRINGPARAM("left") ),
1770 !importLongProperty( nBaseY
,
1771 OUString( RTL_CONSTASCII_USTRINGPARAM("PositionY") ),
1772 OUString( RTL_CONSTASCII_USTRINGPARAM("top") ),
1774 !importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Width") ),
1775 OUString( RTL_CONSTASCII_USTRINGPARAM("width") ),
1777 !importLongProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Height") ),
1778 OUString( RTL_CONSTASCII_USTRINGPARAM("height") ),
1781 throw xml::sax::SAXException(
1782 OUString( RTL_CONSTASCII_USTRINGPARAM("missing pos size attribute(s)!") ),
1783 Reference
< XInterface
>(), Any() );
1786 if (supportPrintable
)
1788 importBooleanProperty(
1789 OUString( RTL_CONSTASCII_USTRINGPARAM("Printable") ),
1790 OUString( RTL_CONSTASCII_USTRINGPARAM("printable") ),
1797 OUString( RTL_CONSTASCII_USTRINGPARAM("page") ),
1798 xAttributes
, _pImport
->XMLNS_DIALOGS_UID
))
1802 _xControlModel
->setPropertyValue(
1803 OUString( RTL_CONSTASCII_USTRINGPARAM("Step") ),
1806 importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Tag") ),
1807 OUString( RTL_CONSTASCII_USTRINGPARAM("tag") ),
1809 importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("HelpText") ),
1810 OUString( RTL_CONSTASCII_USTRINGPARAM("help-text") ),
1812 importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("HelpURL") ),
1813 OUString( RTL_CONSTASCII_USTRINGPARAM("help-url") ),
1817 //##################################################################################################
1819 //__________________________________________________________________________________________________
1820 Reference
< xml::input::XElement
> ElementBase::getParent()
1821 throw (RuntimeException
)
1823 return static_cast< xml::input::XElement
* >( _pParent
);
1825 //__________________________________________________________________________________________________
1826 OUString
ElementBase::getLocalName()
1827 throw (RuntimeException
)
1831 //__________________________________________________________________________________________________
1832 sal_Int32
ElementBase::getUid()
1833 throw (RuntimeException
)
1837 //__________________________________________________________________________________________________
1838 Reference
< xml::input::XAttributes
> ElementBase::getAttributes()
1839 throw (RuntimeException
)
1841 return _xAttributes
;
1843 //__________________________________________________________________________________________________
1844 void ElementBase::ignorableWhitespace(
1845 OUString
const & /*rWhitespaces*/ )
1846 throw (xml::sax::SAXException
, RuntimeException
)
1850 //__________________________________________________________________________________________________
1851 void ElementBase::characters( OUString
const & /*rChars*/ )
1852 throw (xml::sax::SAXException
, RuntimeException
)
1854 // not used, all characters ignored
1856 //__________________________________________________________________________________________________
1857 void ElementBase::endElement()
1858 throw (xml::sax::SAXException
, RuntimeException
)
1861 //______________________________________________________________________________
1862 void ElementBase::processingInstruction(
1863 OUString
const & /*Target*/, OUString
const & /*Data*/ )
1864 throw (xml::sax::SAXException
, RuntimeException
)
1867 //__________________________________________________________________________________________________
1868 Reference
< xml::input::XElement
> ElementBase::startChildElement(
1869 sal_Int32
/*nUid*/, OUString
const & /*rLocalName*/,
1870 Reference
< xml::input::XAttributes
> const & /*xAttributes*/ )
1871 throw (xml::sax::SAXException
, RuntimeException
)
1873 throw xml::sax::SAXException(
1874 OUString( RTL_CONSTASCII_USTRINGPARAM("unexpected element!") ),
1875 Reference
< XInterface
>(), Any() );
1878 //__________________________________________________________________________________________________
1879 ElementBase::ElementBase(
1880 sal_Int32 nUid
, OUString
const & rLocalName
,
1881 Reference
< xml::input::XAttributes
> const & xAttributes
,
1882 ElementBase
* pParent
, DialogImport
* pImport
)
1884 : _pImport( pImport
)
1885 , _pParent( pParent
)
1887 , _aLocalName( rLocalName
)
1888 , _xAttributes( xAttributes
)
1890 _pImport
->acquire();
1894 _pParent
->acquire();
1897 //__________________________________________________________________________________________________
1898 ElementBase::~ElementBase()
1901 _pImport
->release();
1905 _pParent
->release();
1908 #if OSL_DEBUG_LEVEL > 1
1909 ::rtl::OString
aStr( ::rtl::OUStringToOString(
1910 _aLocalName
, RTL_TEXTENCODING_ASCII_US
) );
1911 OSL_TRACE( "ElementBase::~ElementBase(): %s", aStr
.getStr() );
1915 //##################################################################################################
1920 //______________________________________________________________________________
1921 void DialogImport::startDocument(
1922 Reference
< xml::input::XNamespaceMapping
> const & xNamespaceMapping
)
1923 throw (xml::sax::SAXException
, RuntimeException
)
1925 XMLNS_DIALOGS_UID
= xNamespaceMapping
->getUidByUri(
1926 OUSTR(XMLNS_DIALOGS_URI
) );
1927 XMLNS_SCRIPT_UID
= xNamespaceMapping
->getUidByUri(
1928 OUSTR(XMLNS_SCRIPT_URI
) );
1930 //__________________________________________________________________________________________________
1931 void DialogImport::endDocument()
1932 throw (xml::sax::SAXException
, RuntimeException
)
1936 //__________________________________________________________________________________________________
1937 void DialogImport::processingInstruction(
1938 OUString
const & /*rTarget*/, OUString
const & /*rData*/ )
1939 throw (xml::sax::SAXException
, RuntimeException
)
1941 // ignored for now: xxx todo
1943 //__________________________________________________________________________________________________
1944 void DialogImport::setDocumentLocator(
1945 Reference
< xml::sax::XLocator
> const & /*xLocator*/ )
1946 throw (xml::sax::SAXException
, RuntimeException
)
1948 // ignored for now: xxx todo
1950 //__________________________________________________________________________________________________
1951 Reference
< xml::input::XElement
> DialogImport::startRootElement(
1952 sal_Int32 nUid
, OUString
const & rLocalName
,
1953 Reference
< xml::input::XAttributes
> const & xAttributes
)
1954 throw (xml::sax::SAXException
, RuntimeException
)
1956 if (XMLNS_DIALOGS_UID
!= nUid
)
1958 throw xml::sax::SAXException(
1959 OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ),
1960 Reference
< XInterface
>(), Any() );
1963 else if ( rLocalName
== "window" )
1965 return new WindowElement( rLocalName
, xAttributes
, 0, this );
1969 throw xml::sax::SAXException(
1970 OUString( RTL_CONSTASCII_USTRINGPARAM(
1971 "illegal root element (expected window) given: ") ) +
1972 rLocalName
, Reference
< XInterface
>(), Any() );
1975 //__________________________________________________________________________________________________
1976 DialogImport::~DialogImport()
1979 #if OSL_DEBUG_LEVEL > 1
1980 OSL_TRACE( "DialogImport::~DialogImport()." );
1983 //__________________________________________________________________________________________________
1984 Reference
< util::XNumberFormatsSupplier
> const & DialogImport::getNumberFormatsSupplier()
1986 if (! _xSupplier
.is())
1988 Reference
< XComponentContext
> xContext( getComponentContext() );
1989 Reference
< util::XNumberFormatsSupplier
> xSupplier(
1990 xContext
->getServiceManager()->createInstanceWithContext(
1991 OUString( RTL_CONSTASCII_USTRINGPARAM(
1992 "com.sun.star.util.NumberFormatsSupplier") ),
1993 xContext
), UNO_QUERY
);
1995 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
1996 if (! _xSupplier
.is())
1998 _xSupplier
= xSupplier
;
2004 //__________________________________________________________________________________________________
2005 void DialogImport::addStyle(
2006 OUString
const & rStyleId
,
2007 Reference
< xml::input::XElement
> const & xStyle
)
2010 (*_pStyleNames
).push_back( rStyleId
);
2011 (*_pStyles
).push_back( xStyle
);
2013 //__________________________________________________________________________________________________
2014 Reference
< xml::input::XElement
> DialogImport::getStyle(
2015 OUString
const & rStyleId
) const
2018 for ( size_t nPos
= 0; nPos
< (*_pStyleNames
).size(); ++nPos
)
2020 if ( (*_pStyleNames
)[ nPos
] == rStyleId
)
2022 return (*_pStyles
)[ nPos
];
2028 Reference
< xml::sax::XDocumentHandler
> SAL_CALL
importDialogModel(
2029 Reference
< container::XNameContainer
> const & xDialogModel
,
2030 Reference
< XComponentContext
> const & xContext
,
2031 Reference
< XModel
> const & xDocument
)
2032 SAL_THROW( (Exception
) )
2034 // single set of styles and stylenames apply to all containees
2035 :: boost::shared_ptr
< ::std::vector
< ::rtl::OUString
> > pStyleNames( new ::std::vector
< ::rtl::OUString
> );
2036 :: boost::shared_ptr
< ::std::vector
< css::uno::Reference
< css::xml::input::XElement
> > > pStyles( new ::std::vector
< css::uno::Reference
< css::xml::input::XElement
> > );
2037 return ::xmlscript::createDocumentHandler(
2038 static_cast< xml::input::XRoot
* >(
2039 new DialogImport( xContext
, xDialogModel
, pStyleNames
, pStyles
, xDocument
) ) );
2043 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */