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