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