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