Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / xmlscript / source / xmldlg_imexp / xmldlg_impmodels.cxx
blob03344a5b7c4aeb0f67b9a0a57e6ff74b144da12e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "imp_share.hxx"
21 #include <com/sun/star/beans/XPropertySet.hpp>
22 #include <com/sun/star/util/MalformedNumberFormatException.hpp>
23 #include <com/sun/star/xml/sax/SAXException.hpp>
25 #include <cppuhelper/exc_hlp.hxx>
26 #include <sal/log.hxx>
27 #include <comphelper/diagnose_ex.hxx>
28 #include <i18nlangtag/languagetag.hxx>
30 using namespace ::com::sun::star;
31 using namespace ::com::sun::star::uno;
33 namespace xmlscript
36 Reference< xml::input::XElement > Frame::startChildElement(
37 sal_Int32 nUid, OUString const & rLocalName,
38 Reference< xml::input::XAttributes > const & xAttributes )
40 if ( !m_xContainer.is() )
41 m_xContainer.set( m_pImport->_xDialogModelFactory->createInstance( "com.sun.star.awt.UnoFrameModel" ), UNO_QUERY );
42 // event
43 if (m_pImport->isEventElement( nUid, rLocalName ))
45 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
47 else if ( rLocalName == "bulletinboard" )
49 // Create new DialogImport for this container
50 rtl::Reference<DialogImport> pFrameImport = new DialogImport( *m_pImport );
51 pFrameImport->_xDialogModel = m_xContainer;
52 return new BulletinBoardElement( rLocalName, xAttributes, this, pFrameImport.get() );
54 else if ( rLocalName == "title" )
56 getStringAttr( &_label, "value", xAttributes, m_pImport->XMLNS_DIALOGS_UID );
58 return new ElementBase( m_pImport->XMLNS_DIALOGS_UID, rLocalName, xAttributes, this, m_pImport );
60 else
62 SAL_INFO("xmlscript.xmldlg","****** ARGGGGG!!!! **********");
63 throw xml::sax::SAXException("expected event element!", Reference< XInterface >(), Any() );
67 void Frame::endElement()
69 if ( !m_xContainer.is() )
70 m_xContainer.set( m_pImport->_xDialogModelFactory->createInstance( "com.sun.star.awt.UnoFrameModel" ), UNO_QUERY );
71 Reference< beans::XPropertySet > xProps( m_xContainer, UNO_QUERY_THROW );
72 // m_pImport is what we need to add to ( e.g. the dialog in this case )
73 ControlImportContext ctx( m_pImport, xProps, getControlId( _xAttributes ) );
75 Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() );
77 Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
78 if (xStyle.is())
80 StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
81 pStyle->importTextColorStyle( xControlModel );
82 pStyle->importTextLineColorStyle( xControlModel );
83 pStyle->importFontStyle( xControlModel );
86 ctx.importDefaults( 0, 0, _xAttributes ); // inherited from BulletinBoardElement
87 if (!_label.isEmpty())
89 xControlModel->setPropertyValue( "Label" , Any( _label ) );
91 ctx.importEvents( _events );
92 // avoid ring-reference:
93 // vector< event elements > holding event elements holding this (via _pParent)
94 _events.clear();
96 ctx.finish();
100 Reference< xml::input::XElement > MultiPage::startChildElement(
101 sal_Int32 nUid, OUString const & rLocalName,
102 Reference< xml::input::XAttributes > const & xAttributes )
104 // event
105 if (m_pImport->isEventElement( nUid, rLocalName ))
107 return new EventElement(
108 nUid, rLocalName, xAttributes, this, m_pImport );
110 else if ( rLocalName == "bulletinboard" )
112 // Create new DialogImport for this container
114 rtl::Reference<DialogImport> pMultiPageImport = new DialogImport( *m_pImport );
115 pMultiPageImport->_xDialogModel = m_xContainer;
116 return new BulletinBoardElement( rLocalName, xAttributes, this, pMultiPageImport.get() );
118 else
121 throw xml::sax::SAXException( "expected event element!", Reference< XInterface >(), Any() );
125 void MultiPage::endElement()
127 Reference< beans::XPropertySet > xProps( m_xContainer, UNO_QUERY_THROW );
128 // m_pImport is what we need to add to ( e.g. the dialog in this case )
129 ControlImportContext ctx( m_pImport, xProps, getControlId( _xAttributes ));
131 Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() );
133 Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
134 if (xStyle.is())
136 StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
137 pStyle->importTextColorStyle( xControlModel );
138 pStyle->importTextLineColorStyle( xControlModel );
139 pStyle->importFontStyle( xControlModel );
140 pStyle->importBackgroundColorStyle( xControlModel );
143 ctx.importDefaults( 0, 0, _xAttributes ); // inherited from BulletinBoardElement
144 ctx.importLongProperty("MultiPageValue" , "value", _xAttributes );
145 ctx.importBooleanProperty( "Decoration", "withtabs", _xAttributes) ;
146 ctx.importEvents( _events );
147 // avoid ring-reference:
148 // vector< event elements > holding event elements holding this (via _pParent)
149 _events.clear();
151 ctx.finish();
154 Reference< xml::input::XElement > Page::startChildElement(
155 sal_Int32 nUid, OUString const & rLocalName,
156 Reference< xml::input::XAttributes > const & xAttributes )
158 // event
159 if (m_pImport->isEventElement( nUid, rLocalName ))
161 return new EventElement(
162 nUid, rLocalName, xAttributes, this, m_pImport );
164 else if ( rLocalName == "bulletinboard" )
167 rtl::Reference<DialogImport> pPageImport = new DialogImport( *m_pImport );
168 pPageImport->_xDialogModel = m_xContainer;
169 return new BulletinBoardElement( rLocalName, xAttributes, this, pPageImport.get() );
171 else
174 throw xml::sax::SAXException("expected event element!", Reference< XInterface >(), Any() );
178 void Page::endElement()
180 Reference< beans::XPropertySet > xProps( m_xContainer, UNO_QUERY_THROW );
182 ControlImportContext ctx( m_pImport, xProps, getControlId( _xAttributes ));
184 Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() );
186 Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
187 if (xStyle.is())
189 StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
190 pStyle->importTextColorStyle( xControlModel );
191 pStyle->importTextLineColorStyle( xControlModel );
192 pStyle->importFontStyle( xControlModel );
193 pStyle->importBackgroundColorStyle( xControlModel );
196 ctx.importDefaults( 0, 0, _xAttributes ); // inherited from BulletinBoardElement
197 ctx.importStringProperty( "Title", "title", _xAttributes );
198 ctx.importEvents( _events );
199 // avoid ring-reference:
200 // vector< event elements > holding event elements holding this (via _pParent)
201 _events.clear();
203 ctx.finish();
206 // progressmeter
207 Reference< xml::input::XElement > ProgressBarElement::startChildElement(
208 sal_Int32 nUid, OUString const & rLocalName,
209 Reference< xml::input::XAttributes > const & xAttributes )
211 // event
212 if (!m_pImport->isEventElement( nUid, rLocalName ))
214 throw xml::sax::SAXException( "expected event element!", Reference< XInterface >(), Any() );
217 return new EventElement(
218 nUid, rLocalName, xAttributes, this, m_pImport );
221 void ProgressBarElement::endElement()
223 ControlImportContext ctx( m_pImport, getControlId( _xAttributes ), "com.sun.star.awt.UnoControlProgressBarModel" );
225 Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
226 if (xStyle.is())
228 StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
229 const Reference< beans::XPropertySet >& xControlModel( ctx.getControlModel() );
230 pStyle->importBackgroundColorStyle( xControlModel );
231 pStyle->importBorderStyle( xControlModel );
232 pStyle->importFillColorStyle( xControlModel );
235 ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
236 ctx.importLongProperty( "ProgressValue", "value", _xAttributes );
237 ctx.importLongProperty( "ProgressValueMin", "value-min", _xAttributes );
238 ctx.importLongProperty( "ProgressValueMax", "value-max", _xAttributes );
239 ctx.importEvents( _events );
240 // avoid ring-reference:
241 // vector< event elements > holding event elements holding this (via _pParent)
242 _events.clear();
244 ctx.finish();
247 // scrollbar
248 Reference< xml::input::XElement > ScrollBarElement::startChildElement(
249 sal_Int32 nUid, OUString const & rLocalName,
250 Reference< xml::input::XAttributes > const & xAttributes )
252 // event
253 if (!m_pImport->isEventElement( nUid, rLocalName ))
255 throw xml::sax::SAXException("expected event element!", Reference< XInterface >(), Any() );
258 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
261 void ScrollBarElement::endElement()
263 ControlImportContext ctx( m_pImport, getControlId( _xAttributes ), getControlModelName( "com.sun.star.awt.UnoControlScrollBarModel" , _xAttributes ) );
265 Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
266 if (xStyle.is())
268 StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
269 const Reference< beans::XPropertySet >& xControlModel( ctx.getControlModel() );
270 pStyle->importBackgroundColorStyle( xControlModel );
271 pStyle->importBorderStyle( xControlModel );
274 ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
275 ctx.importOrientationProperty( "Orientation" , "align", _xAttributes );
276 ctx.importLongProperty( "BlockIncrement" , "pageincrement" , _xAttributes );
277 ctx.importLongProperty( "LineIncrement" , "increment" , _xAttributes );
278 ctx.importLongProperty( "ScrollValue" ,"curpos", _xAttributes );
279 ctx.importLongProperty( "ScrollValueMax" , "maxpos" , _xAttributes );
280 ctx.importLongProperty( "ScrollValueMin","minpos", _xAttributes );
281 ctx.importLongProperty( "VisibleSize", "visible-size", _xAttributes );
282 ctx.importLongProperty( "RepeatDelay", "repeat", _xAttributes );
283 ctx.importBooleanProperty( "Tabstop", "tabstop" , _xAttributes );
284 ctx.importBooleanProperty( "LiveScroll", "live-scroll", _xAttributes );
285 ctx.importHexLongProperty( "SymbolColor", "symbol-color", _xAttributes );
287 ctx.importDataAwareProperty( "linked-cell" , _xAttributes );
288 ctx.importEvents( _events );
289 // avoid ring-reference:
290 // vector< event elements > holding event elements holding this (via _pParent)
291 _events.clear();
293 ctx.finish();
296 // spinbutton
297 Reference< xml::input::XElement > SpinButtonElement::startChildElement(
298 sal_Int32 nUid, OUString const & rLocalName,
299 Reference< xml::input::XAttributes > const & xAttributes )
301 // event
302 if (!m_pImport->isEventElement( nUid, rLocalName ))
304 throw xml::sax::SAXException("expected event element!", Reference< XInterface >(), Any() );
307 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
310 void SpinButtonElement::endElement()
312 ControlImportContext ctx( m_pImport, getControlId( _xAttributes ), getControlModelName( "com.sun.star.awt.UnoControlSpinButtonModel", _xAttributes ) );
314 Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
315 if (xStyle.is())
317 StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
318 const Reference< beans::XPropertySet >& xControlModel( ctx.getControlModel() );
319 pStyle->importBackgroundColorStyle( xControlModel );
320 pStyle->importBorderStyle( xControlModel );
323 ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
324 ctx.importOrientationProperty( "Orientation", "align", _xAttributes );
325 ctx.importLongProperty("SpinIncrement", "increment", _xAttributes );
326 ctx.importLongProperty("SpinValue", "curval" ,_xAttributes );
327 ctx.importLongProperty("SpinValueMax", "maxval", _xAttributes );
328 ctx.importLongProperty( "SpinValueMin","minval",_xAttributes );
329 ctx.importLongProperty( "Repeat", "repeat", _xAttributes );
330 ctx.importLongProperty( "RepeatDelay", "repeat-delay",_xAttributes );
331 ctx.importBooleanProperty( "Tabstop", "tabstop", _xAttributes );
332 ctx.importHexLongProperty( "SymbolColor", "symbol-color" , _xAttributes );
333 ctx.importDataAwareProperty( "linked-cell" , _xAttributes );
334 ctx.importEvents( _events );
335 // avoid ring-reference:
336 // vector< event elements > holding event elements holding this (via _pParent)
337 _events.clear();
339 ctx.finish();
342 // fixedline
343 Reference< xml::input::XElement > FixedLineElement::startChildElement(
344 sal_Int32 nUid, OUString const & rLocalName,
345 Reference< xml::input::XAttributes > const & xAttributes )
347 // event
348 if (!m_pImport->isEventElement( nUid, rLocalName ))
350 throw xml::sax::SAXException("expected event element!", Reference< XInterface >(), Any() );
353 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
356 void FixedLineElement::endElement()
358 ControlImportContext ctx(m_pImport, getControlId( _xAttributes ), "com.sun.star.awt.UnoControlFixedLineModel" );
360 Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
361 if (xStyle.is())
363 StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
364 const Reference< beans::XPropertySet >& xControlModel( ctx.getControlModel() );
365 pStyle->importTextColorStyle( xControlModel );
366 pStyle->importTextLineColorStyle( xControlModel );
367 pStyle->importFontStyle( xControlModel );
370 ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
371 ctx.importStringProperty( "Label", "value", _xAttributes );
372 ctx.importOrientationProperty( "Orientation", "align", _xAttributes );
373 ctx.importEvents( _events );
374 // avoid ring-reference:
375 // vector< event elements > holding event elements holding this (via _pParent)
376 _events.clear();
378 ctx.finish();
381 // patternfield
382 Reference< xml::input::XElement > PatternFieldElement::startChildElement(
383 sal_Int32 nUid, OUString const & rLocalName,
384 Reference< xml::input::XAttributes > const & xAttributes )
386 // event
387 if (!m_pImport->isEventElement( nUid, rLocalName ))
389 throw xml::sax::SAXException("expected event element!", Reference< XInterface >(), Any() );
392 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
395 void PatternFieldElement::endElement()
397 ControlImportContext ctx( m_pImport, getControlId( _xAttributes ), "com.sun.star.awt.UnoControlPatternFieldModel" );
399 Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
400 if (xStyle.is())
402 StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
403 const Reference< beans::XPropertySet >& xControlModel( ctx.getControlModel() );
404 pStyle->importBackgroundColorStyle( xControlModel );
405 pStyle->importTextColorStyle( xControlModel );
406 pStyle->importTextLineColorStyle( xControlModel );
407 pStyle->importBorderStyle( xControlModel );
408 pStyle->importFontStyle( xControlModel );
411 ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
412 ctx.importBooleanProperty( "Tabstop", "tabstop", _xAttributes );
413 ctx.importBooleanProperty( "ReadOnly", "readonly" , _xAttributes );
414 ctx.importBooleanProperty( "StrictFormat", "strict-format", _xAttributes );
415 ctx.importBooleanProperty( "HideInactiveSelection", "hide-inactive-selection", _xAttributes );
416 ctx.importStringProperty( "Text", "value", _xAttributes );
417 ctx.importShortProperty( "MaxTextLen", "maxlength", _xAttributes );
418 ctx.importStringProperty( "EditMask", "edit-mask", _xAttributes );
419 ctx.importStringProperty( "LiteralMask", "literal-mask", _xAttributes );
420 ctx.importEvents( _events );
421 // avoid ring-reference:
422 // vector< event elements > holding event elements holding this (via _pParent)
423 _events.clear();
425 ctx.finish();
428 // formattedfield
429 Reference< xml::input::XElement > FormattedFieldElement::startChildElement(
430 sal_Int32 nUid, OUString const & rLocalName,
431 Reference< xml::input::XAttributes > const & xAttributes )
433 // event
434 if (!m_pImport->isEventElement( nUid, rLocalName ))
436 throw xml::sax::SAXException("expected event element!", Reference< XInterface >(), Any() );
439 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
442 void FormattedFieldElement::endElement()
444 ControlImportContext ctx( m_pImport, getControlId( _xAttributes ), "com.sun.star.awt.UnoControlFormattedFieldModel" );
446 Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
447 if (xStyle.is())
449 StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
450 const Reference< beans::XPropertySet >& xControlModel( ctx.getControlModel() );
451 pStyle->importBackgroundColorStyle( xControlModel );
452 pStyle->importTextColorStyle( xControlModel );
453 pStyle->importTextLineColorStyle( xControlModel );
454 pStyle->importBorderStyle( xControlModel );
455 pStyle->importFontStyle( xControlModel );
458 ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
459 ctx.importBooleanProperty( "Tabstop", "tabstop", _xAttributes );
460 ctx.importBooleanProperty( "ReadOnly", "readonly" , _xAttributes );
461 ctx.importBooleanProperty( "StrictFormat", "strict-format" , _xAttributes );
462 ctx.importBooleanProperty( "HideInactiveSelection", "hide-inactive-selection", _xAttributes );
463 ctx.importAlignProperty( "Align" , "align" , _xAttributes );
464 ctx.importDoubleProperty( "EffectiveMin", "value-min" , _xAttributes );
465 ctx.importDoubleProperty( "EffectiveMax", "value-max", _xAttributes);
466 ctx.importDoubleProperty( "EffectiveValue", "value", _xAttributes );
467 ctx.importStringProperty( "Text", "text", _xAttributes );
468 ctx.importShortProperty( "MaxTextLen", "maxlength", _xAttributes );
469 ctx.importBooleanProperty( "Spin", "spin", _xAttributes );
470 if (ctx.importLongProperty( "RepeatDelay", "repeat", _xAttributes ))
471 ctx.getControlModel()->setPropertyValue( "Repeat" , Any(true) );
473 OUString sDefault(_xAttributes->getValueByUidName(m_pImport->XMLNS_DIALOGS_UID, "value-default") );
474 if (!sDefault.isEmpty())
476 double d = sDefault.toDouble();
477 if (d != 0.0 || sDefault == "0" || sDefault == "0.0" )
479 ctx.getControlModel()->setPropertyValue( "EffectiveDefault", Any( d ) );
481 else // treat as string
483 ctx.getControlModel()->setPropertyValue( "EffectiveDefault", Any( sDefault ) );
487 // format spec
488 ctx.getControlModel()->setPropertyValue("FormatsSupplier", Any( m_pImport->getNumberFormatsSupplier() ) );
490 OUString sFormat( _xAttributes->getValueByUidName(m_pImport->XMLNS_DIALOGS_UID, "format-code" ) );
491 if (!sFormat.isEmpty())
493 lang::Locale locale;
495 OUString sLocale( _xAttributes->getValueByUidName( m_pImport->XMLNS_DIALOGS_UID, "format-locale" ) );
496 if (!sLocale.isEmpty())
498 // split locale
499 // Don't know what may have written what we read here, so parse all
500 // old style including the trailing ";Variant" if present.
501 sal_Int32 semi0 = sLocale.indexOf( ';' );
502 if (semi0 < 0) // no semi at all, try new BCP47 or just language
504 locale = LanguageTag::convertToLocale( sLocale, false);
506 else
508 sal_Int32 semi1 = sLocale.indexOf( ';', semi0 +1 );
509 if (semi1 > semi0) // language;country;variant
511 SAL_WARN( "xmlscript.xmldlg", "format-locale with variant that is ignored: " << sLocale);
512 locale.Language = sLocale.copy( 0, semi0 );
513 locale.Country = sLocale.copy( semi0 +1, semi1 - semi0 -1 );
514 // Ignore Variant that no one knows what it would be.
516 else // language;country
518 locale.Language = sLocale.copy( 0, semi0 );
519 locale.Country = sLocale.copy( semi0 +1 );
526 Reference< util::XNumberFormats > xFormats(
527 m_pImport->getNumberFormatsSupplier()->getNumberFormats() );
528 sal_Int32 nKey = xFormats->queryKey( sFormat, locale, true );
529 if (-1 == nKey)
531 nKey = xFormats->addNew( sFormat, locale );
533 ctx.getControlModel()->setPropertyValue("FormatKey", Any( nKey ) );
535 catch (const util::MalformedNumberFormatException & exc)
537 css::uno::Any anyEx = cppu::getCaughtException();
538 SAL_WARN( "xmlscript.xmldlg", exceptionToString(anyEx) );
539 // rethrow
540 throw xml::sax::SAXException( exc.Message, Reference< XInterface >(), anyEx );
543 ctx.importBooleanProperty("TreatAsNumber", "treat-as-number" , _xAttributes );
544 ctx.importBooleanProperty("EnforceFormat", "enforce-format", _xAttributes );
546 ctx.importDataAwareProperty( "linked-cell" , _xAttributes );
547 ctx.importEvents( _events );
548 // avoid ring-reference:
549 // vector< event elements > holding event elements holding this (via _pParent)
550 _events.clear();
552 ctx.finish();
555 // timefield
556 Reference< xml::input::XElement > TimeFieldElement::startChildElement(
557 sal_Int32 nUid, OUString const & rLocalName,
558 Reference< xml::input::XAttributes > const & xAttributes )
560 // event
561 if (!m_pImport->isEventElement( nUid, rLocalName ))
563 throw xml::sax::SAXException("expected event element!", Reference< XInterface >(), Any() );
566 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
569 void TimeFieldElement::endElement()
571 ControlImportContext ctx( m_pImport, getControlId( _xAttributes ), "com.sun.star.awt.UnoControlTimeFieldModel" );
573 Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
574 if (xStyle.is())
576 StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
577 const Reference< beans::XPropertySet >& xControlModel( ctx.getControlModel() );
578 pStyle->importBackgroundColorStyle( xControlModel );
579 pStyle->importTextColorStyle( xControlModel );
580 pStyle->importTextLineColorStyle( xControlModel );
581 pStyle->importBorderStyle( xControlModel );
582 pStyle->importFontStyle( xControlModel );
585 ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
586 ctx.importBooleanProperty("Tabstop", "tabstop", _xAttributes );
587 ctx.importBooleanProperty("ReadOnly", "readonly", _xAttributes );
588 ctx.importBooleanProperty( "StrictFormat", "strict-format", _xAttributes );
589 ctx.importBooleanProperty("HideInactiveSelection","hide-inactive-selection", _xAttributes );
590 ctx.importTimeFormatProperty( "TimeFormat", "time-format", _xAttributes );
591 ctx.importTimeProperty( "Time", "value", _xAttributes );
592 ctx.importTimeProperty( "TimeMin", "value-min", _xAttributes );
593 ctx.importTimeProperty( "TimeMax", "value-max", _xAttributes );
594 ctx.importBooleanProperty( "Spin", "spin", _xAttributes );
595 if (ctx.importLongProperty( "RepeatDelay", "repeat", _xAttributes ))
596 ctx.getControlModel()->setPropertyValue("Repeat", Any(true) );
597 ctx.importStringProperty( "Text", "text" , _xAttributes );
598 ctx.importBooleanProperty( "EnforceFormat", "enforce-format" , _xAttributes );
600 ctx.importEvents( _events );
601 // avoid ring-reference:
602 // vector< event elements > holding event elements holding this (via _pParent)
603 _events.clear();
605 ctx.finish();
608 // numericfield
609 Reference< xml::input::XElement > NumericFieldElement::startChildElement(
610 sal_Int32 nUid, OUString const & rLocalName,
611 Reference< xml::input::XAttributes > const & xAttributes )
613 // event
614 if (!m_pImport->isEventElement( nUid, rLocalName ))
616 throw xml::sax::SAXException( "expected event element!", Reference< XInterface >(), Any() );
619 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
622 void NumericFieldElement::endElement()
624 ControlImportContext ctx( m_pImport, getControlId( _xAttributes ), "com.sun.star.awt.UnoControlNumericFieldModel" );
626 Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
627 if (xStyle.is())
629 StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
630 const Reference< beans::XPropertySet >& xControlModel( ctx.getControlModel() );
631 pStyle->importBackgroundColorStyle( xControlModel );
632 pStyle->importTextColorStyle( xControlModel );
633 pStyle->importTextLineColorStyle( xControlModel );
634 pStyle->importBorderStyle( xControlModel );
635 pStyle->importFontStyle( xControlModel );
638 ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
639 ctx.importAlignProperty( "Align", "align", _xAttributes );
640 ctx.importVerticalAlignProperty( "VerticalAlign", "valign", _xAttributes );
641 ctx.importBooleanProperty( "Tabstop","tabstop",_xAttributes );
642 ctx.importBooleanProperty( "ReadOnly", "readonly",_xAttributes );
643 ctx.importBooleanProperty( "StrictFormat", "strict-format", _xAttributes );
644 ctx.importBooleanProperty( "HideInactiveSelection", "hide-inactive-selection", _xAttributes );
645 ctx.importShortProperty( "DecimalAccuracy", "decimal-accuracy", _xAttributes );
646 ctx.importBooleanProperty( "ShowThousandsSeparator", "thousands-separator", _xAttributes );
647 ctx.importDoubleProperty( "Value", "value", _xAttributes );
648 ctx.importDoubleProperty( "ValueMin", "value-min", _xAttributes );
649 ctx.importDoubleProperty( "ValueMax", "value-max", _xAttributes );
650 ctx.importDoubleProperty( "ValueStep", "value-step", _xAttributes );
651 ctx.importBooleanProperty( "Spin", "spin", _xAttributes );
652 if (ctx.importLongProperty( "RepeatDelay", "repeat", _xAttributes ))
653 ctx.getControlModel()->setPropertyValue("Repeat", Any(true) );
654 ctx.importBooleanProperty( "EnforceFormat", "enforce-format", _xAttributes );
655 ctx.importEvents( _events );
656 // avoid ring-reference:
657 // vector< event elements > holding event elements holding this (via _pParent)
658 _events.clear();
660 ctx.finish();
663 // datefield
664 Reference< xml::input::XElement > DateFieldElement::startChildElement(
665 sal_Int32 nUid, OUString const & rLocalName,
666 Reference< xml::input::XAttributes > const & xAttributes )
668 // event
669 if (!m_pImport->isEventElement( nUid, rLocalName ))
671 throw xml::sax::SAXException("expected event element!", Reference< XInterface >(), Any() );
674 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
677 void DateFieldElement::endElement()
679 ControlImportContext ctx( m_pImport, getControlId( _xAttributes ), "com.sun.star.awt.UnoControlDateFieldModel" );
681 Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
682 if (xStyle.is())
684 StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
685 const Reference< beans::XPropertySet >& xControlModel( ctx.getControlModel() );
686 pStyle->importBackgroundColorStyle( xControlModel );
687 pStyle->importTextColorStyle( xControlModel );
688 pStyle->importTextLineColorStyle( xControlModel );
689 pStyle->importBorderStyle( xControlModel );
690 pStyle->importFontStyle( xControlModel );
693 ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
694 ctx.importAlignProperty( "Align", "align", _xAttributes );
695 ctx.importVerticalAlignProperty( "VerticalAlign", "valign", _xAttributes );
696 ctx.importBooleanProperty( "Tabstop", "tabstop", _xAttributes );
697 ctx.importBooleanProperty( "ReadOnly", "readonly", _xAttributes );
698 ctx.importBooleanProperty( "StrictFormat", "strict-format", _xAttributes );
699 ctx.importBooleanProperty( "HideInactiveSelection", "hide-inactive-selection", _xAttributes );
700 ctx.importDateFormatProperty( "DateFormat", "date-format", _xAttributes );
701 ctx.importBooleanProperty( "DateShowCentury", "show-century", _xAttributes );
702 ctx.importDateProperty( "Date", "value", _xAttributes );
703 ctx.importDateProperty( "DateMin", "value-min", _xAttributes );
704 ctx.importDateProperty( "DateMax", "value-max", _xAttributes );
705 ctx.importBooleanProperty( "Spin", "spin", _xAttributes );
706 if (ctx.importLongProperty( "RepeatDelay", "repeat", _xAttributes ))
707 ctx.getControlModel()->setPropertyValue( "Repeat", Any(true) );
708 ctx.importBooleanProperty( "Dropdown", "dropdown", _xAttributes );
709 ctx.importStringProperty( "Text", "text", _xAttributes );
710 ctx.importBooleanProperty( "EnforceFormat", "enforce-format", _xAttributes );
711 ctx.importEvents( _events );
712 // avoid ring-reference:
713 // vector< event elements > holding event elements holding this (via _pParent)
714 _events.clear();
716 ctx.finish();
719 // currencyfield
720 Reference< xml::input::XElement > CurrencyFieldElement::startChildElement(
721 sal_Int32 nUid, OUString const & rLocalName,
722 Reference< xml::input::XAttributes > const & xAttributes )
724 // event
725 if (!m_pImport->isEventElement( nUid, rLocalName ))
727 throw xml::sax::SAXException( "expected event element!" , Reference< XInterface >(), Any() );
730 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
733 void CurrencyFieldElement::endElement()
735 ControlImportContext ctx( m_pImport, getControlId( _xAttributes ), "com.sun.star.awt.UnoControlCurrencyFieldModel" );
737 Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
738 if (xStyle.is())
740 StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
741 const Reference< beans::XPropertySet >& xControlModel( ctx.getControlModel() );
742 pStyle->importBackgroundColorStyle( xControlModel );
743 pStyle->importTextColorStyle( xControlModel );
744 pStyle->importTextLineColorStyle( xControlModel );
745 pStyle->importBorderStyle( xControlModel );
746 pStyle->importFontStyle( xControlModel );
749 ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
750 ctx.importAlignProperty( "Align", "align", _xAttributes );
751 ctx.importVerticalAlignProperty( "VerticalAlign", "valign", _xAttributes );
752 ctx.importBooleanProperty("Tabstop", "tabstop", _xAttributes );
753 ctx.importBooleanProperty( "ReadOnly", "readonly" , _xAttributes );
754 ctx.importBooleanProperty( "StrictFormat", "strict-format", _xAttributes );
755 ctx.importBooleanProperty( "HideInactiveSelection", "hide-inactive-selection", _xAttributes );
756 ctx.importStringProperty( "CurrencySymbol", "currency-symbol", _xAttributes );
757 ctx.importShortProperty( "DecimalAccuracy", "decimal-accuracy", _xAttributes );
758 ctx.importBooleanProperty( "ShowThousandsSeparator", "thousands-separator", _xAttributes );
759 ctx.importDoubleProperty( "Value", "value", _xAttributes );
760 ctx.importDoubleProperty( "ValueMin", "value-min", _xAttributes );
761 ctx.importDoubleProperty( "ValueMax", "value-max", _xAttributes );
762 ctx.importDoubleProperty( "ValueStep", "value-step", _xAttributes );
763 ctx.importBooleanProperty( "Spin", "spin", _xAttributes );
764 if (ctx.importLongProperty( "RepeatDelay", "repeat", _xAttributes ))
765 ctx.getControlModel()->setPropertyValue( "Repeat", Any(true) );
766 ctx.importBooleanProperty( "PrependCurrencySymbol", "prepend-symbol", _xAttributes );
767 ctx.importBooleanProperty( "EnforceFormat", "enforce-format", _xAttributes );
768 ctx.importEvents( _events );
769 // avoid ring-reference:
770 // vector< event elements > holding event elements holding this (via _pParent)
771 _events.clear();
773 ctx.finish();
776 // filecontrol
777 Reference< xml::input::XElement > FileControlElement::startChildElement(
778 sal_Int32 nUid, OUString const & rLocalName,
779 Reference< xml::input::XAttributes > const & xAttributes )
781 // event
782 if (!m_pImport->isEventElement( nUid, rLocalName ))
784 throw xml::sax::SAXException( "expected event element!", Reference< XInterface >(), Any() );
787 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
790 void FileControlElement::endElement()
792 ControlImportContext ctx( m_pImport, getControlId( _xAttributes ), "com.sun.star.awt.UnoControlFileControlModel" );
794 Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
795 if (xStyle.is())
797 StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
798 const Reference< beans::XPropertySet >& xControlModel( ctx.getControlModel() );
799 pStyle->importBackgroundColorStyle( xControlModel );
800 pStyle->importTextColorStyle( xControlModel );
801 pStyle->importTextLineColorStyle( xControlModel );
802 pStyle->importBorderStyle( xControlModel );
803 pStyle->importFontStyle( xControlModel );
806 ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
807 ctx.importBooleanProperty( "Tabstop", "tabstop", _xAttributes );
808 ctx.importBooleanProperty("HideInactiveSelection","hide-inactive-selection", _xAttributes );
809 ctx.importStringProperty( "Text", "value", _xAttributes );
810 ctx.importBooleanProperty( "ReadOnly", "readonly", _xAttributes );
811 ctx.importEvents( _events );
812 // avoid ring-reference:
813 // vector< event elements > holding event elements holding this (via _pParent)
814 _events.clear();
816 ctx.finish();
819 // treecontrol
820 Reference< xml::input::XElement > TreeControlElement::startChildElement(
821 sal_Int32 nUid, OUString const & rLocalName,
822 Reference< xml::input::XAttributes > const & xAttributes )
824 // event
825 if (!m_pImport->isEventElement( nUid, rLocalName ))
827 throw xml::sax::SAXException( "expected event element!", Reference< XInterface >(), Any() );
830 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
833 void TreeControlElement::endElement()
835 ControlImportContext ctx( m_pImport, getControlId( _xAttributes ), "com.sun.star.awt.tree.TreeControlModel" );
837 Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
838 if (xStyle.is())
840 StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
841 const Reference< beans::XPropertySet >& xControlModel( ctx.getControlModel() );
842 pStyle->importBackgroundColorStyle( xControlModel );
843 pStyle->importBorderStyle( xControlModel );
846 ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
847 ctx.importBooleanProperty( "Tabstop", "tabstop", _xAttributes );
848 ctx.importSelectionTypeProperty( "SelectionType", "selectiontype", _xAttributes );
849 ctx.importBooleanProperty( "RootDisplayed", "rootdisplayed", _xAttributes );
850 ctx.importBooleanProperty( "ShowsHandles", "showshandles", _xAttributes );
851 ctx.importBooleanProperty( "ShowsRootHandles", "showsroothandles" ,_xAttributes );
852 ctx.importBooleanProperty( "Editable", "editable", _xAttributes );
853 ctx.importBooleanProperty( "RowHeight", "readonly", _xAttributes );
854 ctx.importBooleanProperty( "InvokesStopNodeEditing", "invokesstopnodeediting", _xAttributes );
856 ctx.importEvents( _events );
857 // avoid ring-reference:
858 // vector< event elements > holding event elements holding this (via _pParent)
859 _events.clear();
861 ctx.finish();
864 // imagecontrol
865 Reference< xml::input::XElement > ImageControlElement::startChildElement(
866 sal_Int32 nUid, OUString const & rLocalName,
867 Reference< xml::input::XAttributes > const & xAttributes )
869 // event
870 if (!m_pImport->isEventElement( nUid, rLocalName ))
872 throw xml::sax::SAXException( "expected event element!" , Reference< XInterface >(), Any() );
875 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
878 void ImageControlElement::endElement()
880 ControlImportContext ctx( m_pImport, getControlId( _xAttributes ), "com.sun.star.awt.UnoControlImageControlModel" );
882 Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
883 if (xStyle.is())
885 StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
886 const Reference< beans::XPropertySet >& xControlModel( ctx.getControlModel() );
887 pStyle->importBackgroundColorStyle( xControlModel );
888 pStyle->importBorderStyle( xControlModel );
891 ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
892 ctx.importBooleanProperty( "ScaleImage", "scale-image", _xAttributes );
893 ctx.importImageScaleModeProperty( "ScaleMode" , "scale-mode" , _xAttributes );
894 ctx.importGraphicOrImageProperty("src" , _xAttributes);
895 ctx.importBooleanProperty( "Tabstop", "tabstop", _xAttributes );
896 ctx.importEvents( _events );
897 // avoid ring-reference:
898 // vector< event elements > holding event elements holding this (via _pParent)
899 _events.clear();
901 ctx.finish();
904 // textfield
905 Reference< xml::input::XElement > TextElement::startChildElement(
906 sal_Int32 nUid, OUString const & rLocalName,
907 Reference< xml::input::XAttributes > const & xAttributes )
909 // event
910 if (!m_pImport->isEventElement( nUid, rLocalName ))
912 throw xml::sax::SAXException( "expected event element!", Reference< XInterface >(), Any() );
915 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
918 void TextElement::endElement()
920 ControlImportContext ctx( m_pImport, getControlId( _xAttributes ), "com.sun.star.awt.UnoControlFixedTextModel" );
922 Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
923 if (xStyle.is())
925 StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
926 const Reference< beans::XPropertySet >& xControlModel( ctx.getControlModel() );
927 pStyle->importBackgroundColorStyle( xControlModel );
928 pStyle->importTextColorStyle( xControlModel );
929 pStyle->importTextLineColorStyle( xControlModel );
930 pStyle->importBorderStyle( xControlModel );
931 pStyle->importFontStyle( xControlModel );
934 ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
935 ctx.importStringProperty( "Label", "value", _xAttributes );
936 ctx.importAlignProperty( "Align", "align", _xAttributes );
937 ctx.importVerticalAlignProperty( "VerticalAlign", "valign", _xAttributes );
938 ctx.importBooleanProperty( "MultiLine", "multiline" ,_xAttributes );
939 ctx.importBooleanProperty( "Tabstop", "tabstop", _xAttributes );
940 ctx.importBooleanProperty( "NoLabel", "nolabel", _xAttributes );
941 ctx.importEvents( _events );
942 // avoid ring-reference:
943 // vector< event elements > holding event elements holding this (via _pParent)
944 _events.clear();
946 ctx.finish();
949 // FixedHyperLink
950 Reference< xml::input::XElement > FixedHyperLinkElement::startChildElement(
951 sal_Int32 nUid, OUString const & rLocalName,
952 Reference< xml::input::XAttributes > const & xAttributes )
954 // event
955 if (!m_pImport->isEventElement( nUid, rLocalName ))
957 throw xml::sax::SAXException( "expected event element!" , Reference< XInterface >(), Any() );
960 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
963 void FixedHyperLinkElement::endElement()
965 ControlImportContext ctx( m_pImport, getControlId( _xAttributes ), "com.sun.star.awt.UnoControlFixedHyperlinkModel" );
967 Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
968 if (xStyle.is())
970 StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
971 const Reference< beans::XPropertySet >& xControlModel( ctx.getControlModel() );
972 pStyle->importBackgroundColorStyle( xControlModel );
973 pStyle->importTextColorStyle( xControlModel );
974 pStyle->importTextLineColorStyle( xControlModel );
975 pStyle->importBorderStyle( xControlModel );
976 pStyle->importFontStyle( xControlModel );
979 ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
980 ctx.importStringProperty( "Label", "value", _xAttributes );
981 ctx.importStringProperty( "URL", "url", _xAttributes );
983 ctx.importAlignProperty( "Align", "align" ,_xAttributes );
984 ctx.importVerticalAlignProperty( "VerticalAlign", "valign", _xAttributes );
985 ctx.importBooleanProperty( "MultiLine", "multiline", _xAttributes );
986 ctx.importBooleanProperty( "Tabstop", "tabstop", _xAttributes );
987 ctx.importBooleanProperty( "NoLabel", "nolabel", _xAttributes );
988 ctx.importEvents( _events );
989 // avoid ring-reference:
990 // vector< event elements > holding event elements holding this (via _pParent)
991 _events.clear();
993 ctx.finish();
996 // edit
997 Reference< xml::input::XElement > TextFieldElement::startChildElement(
998 sal_Int32 nUid, OUString const & rLocalName,
999 Reference< xml::input::XAttributes > const & xAttributes )
1001 // event
1002 if (!m_pImport->isEventElement( nUid, rLocalName ))
1004 throw xml::sax::SAXException( "expected event element!", Reference< XInterface >(), Any() );
1007 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
1010 void TextFieldElement::endElement()
1012 ControlImportContext ctx( m_pImport, getControlId( _xAttributes ), "com.sun.star.awt.UnoControlEditModel" );
1013 Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() );
1015 Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
1016 if (xStyle.is())
1018 StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
1019 pStyle->importBackgroundColorStyle( xControlModel );
1020 pStyle->importTextColorStyle( xControlModel );
1021 pStyle->importTextLineColorStyle( xControlModel );
1022 pStyle->importBorderStyle( xControlModel );
1023 pStyle->importFontStyle( xControlModel );
1026 ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
1027 ctx.importBooleanProperty("Tabstop", "tabstop", _xAttributes );
1028 ctx.importAlignProperty( "Align", "align", _xAttributes );
1029 ctx.importVerticalAlignProperty( "VerticalAlign", "valign", _xAttributes );
1030 ctx.importBooleanProperty( "HardLineBreaks", "hard-linebreaks", _xAttributes );
1031 ctx.importBooleanProperty( "HScroll", "hscroll" ,_xAttributes );
1032 ctx.importBooleanProperty( "VScroll", "vscroll", _xAttributes );
1033 ctx.importBooleanProperty("HideInactiveSelection", "hide-inactive-selection", _xAttributes );
1034 ctx.importShortProperty( "MaxTextLen", "maxlength", _xAttributes );
1035 ctx.importBooleanProperty( "MultiLine", "multiline", _xAttributes );
1036 ctx.importBooleanProperty( "ReadOnly", "readonly", _xAttributes );
1037 ctx.importStringProperty( "Text", "value", _xAttributes );
1038 ctx.importLineEndFormatProperty( "LineEndFormat", "lineend-format", _xAttributes );
1039 OUString aValue;
1040 if (getStringAttr( &aValue, "echochar", _xAttributes, m_pImport->XMLNS_DIALOGS_UID ) && !aValue.isEmpty() )
1042 SAL_WARN_IF( aValue.getLength() != 1, "xmlscript.xmldlg", "### more than one character given for echochar!" );
1043 sal_Int16 nChar = 0;
1044 if(!aValue.isEmpty())
1046 nChar = static_cast<sal_Int16>(aValue[ 0 ]);
1048 xControlModel->setPropertyValue( "EchoChar", Any( nChar ) );
1051 ctx.importEvents( _events );
1052 // avoid ring-reference:
1053 // vector< event elements > holding event elements holding this (via _pParent)
1054 _events.clear();
1056 ctx.finish();
1059 // titledbox
1060 Reference< xml::input::XElement > TitledBoxElement::startChildElement(
1061 sal_Int32 nUid, OUString const & rLocalName,
1062 Reference< xml::input::XAttributes > const & xAttributes )
1064 // event
1065 if (m_pImport->isEventElement( nUid, rLocalName ))
1067 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
1069 else if (m_pImport->XMLNS_DIALOGS_UID != nUid)
1071 throw xml::sax::SAXException( "illegal namespace!", Reference< XInterface >(), Any() );
1073 // title
1074 else if ( rLocalName == "title" )
1076 getStringAttr( &_label, "value", xAttributes, m_pImport->XMLNS_DIALOGS_UID );
1078 return new ElementBase( m_pImport->XMLNS_DIALOGS_UID, rLocalName, xAttributes, this, m_pImport );
1080 // radio
1081 else if ( rLocalName == "radio" )
1083 // don't create radios here, => titledbox must be inserted first due to radio grouping,
1084 // possible predecessors!
1085 Reference< xml::input::XElement > xRet(
1086 new RadioElement( rLocalName, xAttributes, this, m_pImport ) );
1087 _radios.push_back( xRet );
1088 return xRet;
1090 else
1092 return BulletinBoardElement::startChildElement( nUid, rLocalName, xAttributes );
1096 void TitledBoxElement::endElement()
1099 ControlImportContext ctx(m_pImport, getControlId( _xAttributes ), "com.sun.star.awt.UnoControlGroupBoxModel" );
1100 Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() );
1102 Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
1103 if (xStyle.is())
1105 StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
1106 pStyle->importTextColorStyle( xControlModel );
1107 pStyle->importTextLineColorStyle( xControlModel );
1108 pStyle->importFontStyle( xControlModel );
1111 ctx.importDefaults( 0, 0, _xAttributes ); // inherited from BulletinBoardElement
1113 if (!_label.isEmpty())
1115 xControlModel->setPropertyValue( "Label", Any( _label ) );
1118 ctx.importEvents( _events );
1119 // avoid ring-reference:
1120 // vector< event elements > holding event elements holding this (via _pParent)
1121 _events.clear();
1123 ctx.finish();
1126 // create radios AFTER group box!
1127 for (Reference<XElement>& xRadio : _radios)
1129 Reference< xml::input::XAttributes > xAttributes( xRadio->getAttributes() );
1131 ControlImportContext ctx( m_pImport, getControlId( xAttributes ), getControlModelName( "com.sun.star.awt.UnoControlRadioButtonModel", xAttributes ) );
1132 Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() );
1134 Reference< xml::input::XElement > xStyle( getStyle( xAttributes ) );
1135 if (xStyle.is())
1137 StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
1138 pStyle->importBackgroundColorStyle( xControlModel );
1139 pStyle->importTextColorStyle( xControlModel );
1140 pStyle->importTextLineColorStyle( xControlModel );
1141 pStyle->importFontStyle( xControlModel );
1142 pStyle->importVisualEffectStyle( xControlModel );
1145 ctx.importDefaults( _nBasePosX, _nBasePosY, xAttributes );
1146 ctx.importBooleanProperty( "Tabstop", "tabstop", xAttributes );
1147 ctx.importStringProperty( "Label", "value", xAttributes );
1148 ctx.importAlignProperty( "Align", "align", xAttributes );
1149 ctx.importVerticalAlignProperty( "VerticalAlign", "valign", xAttributes );
1150 ctx.importGraphicOrImageProperty("image-src" , _xAttributes);
1151 ctx.importImagePositionProperty( "ImagePosition", "image-position", xAttributes );
1152 ctx.importBooleanProperty( "MultiLine", "multiline", xAttributes );
1153 ctx.importStringProperty( "GroupName", "group-name", xAttributes );
1155 sal_Int16 nVal = 0;
1156 sal_Bool bChecked = false;
1157 if (getBoolAttr( &bChecked, "checked", xAttributes, m_pImport->XMLNS_DIALOGS_UID ) && bChecked)
1159 nVal = 1;
1161 xControlModel->setPropertyValue( "State", Any( nVal ) );
1162 ctx.importDataAwareProperty( "linked-cell" , xAttributes );
1163 ::std::vector< Reference< xml::input::XElement > > & radioEvents =
1164 static_cast< RadioElement * >( xRadio.get() )->getEvents();
1165 ctx.importEvents( radioEvents );
1166 // avoid ring-reference:
1167 // vector< event elements > holding event elements holding this (via _pParent)
1168 radioEvents.clear();
1170 ctx.finish();
1172 // avoid ring-reference:
1173 // vector< radio elements > holding radio elements holding this (via _pParent)
1174 _radios.clear();
1177 // radio
1178 Reference< xml::input::XElement > RadioElement::startChildElement(
1179 sal_Int32 nUid, OUString const & rLocalName,
1180 Reference< xml::input::XAttributes > const & xAttributes )
1182 // event
1183 if (!m_pImport->isEventElement( nUid, rLocalName ))
1185 throw xml::sax::SAXException("expected event element!", Reference< XInterface >(), Any() );
1188 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
1191 // radiogroup
1192 Reference< xml::input::XElement > RadioGroupElement::startChildElement(
1193 sal_Int32 nUid, OUString const & rLocalName,
1194 Reference< xml::input::XAttributes > const & xAttributes )
1196 if (m_pImport->XMLNS_DIALOGS_UID != nUid)
1198 throw xml::sax::SAXException( "illegal namespace!", Reference< XInterface >(), Any() );
1200 // radio
1201 else if ( rLocalName == "radio" )
1203 // don't create radios here, => titledbox must be inserted first due to radio grouping,
1204 // possible predecessors!
1205 Reference< xml::input::XElement > xRet(
1206 new RadioElement( rLocalName, xAttributes, this, m_pImport ) );
1207 _radios.push_back( xRet );
1208 return xRet;
1210 else
1212 throw xml::sax::SAXException( "expected radio element!", Reference< XInterface >(), Any() );
1215 void RadioGroupElement::endElement()
1217 for (Reference<XElement>& xRadio : _radios)
1219 Reference< xml::input::XAttributes > xAttributes(
1220 xRadio->getAttributes() );
1222 ControlImportContext ctx( m_pImport, getControlId( xAttributes ), getControlModelName( "com.sun.star.awt.UnoControlRadioButtonModel", xAttributes ) );
1223 Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() );
1225 Reference< xml::input::XElement > xStyle( getStyle( xAttributes ) );
1226 if (xStyle.is())
1228 StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
1229 pStyle->importBackgroundColorStyle( xControlModel );
1230 pStyle->importTextColorStyle( xControlModel );
1231 pStyle->importTextLineColorStyle( xControlModel );
1232 pStyle->importFontStyle( xControlModel );
1233 pStyle->importVisualEffectStyle( xControlModel );
1236 ctx.importDefaults( _nBasePosX, _nBasePosY, xAttributes );
1237 ctx.importBooleanProperty("Tabstop", "tabstop", xAttributes );
1238 ctx.importStringProperty( "Label", "value", xAttributes );
1239 ctx.importAlignProperty( "Align", "align", xAttributes );
1240 ctx.importVerticalAlignProperty( "VerticalAlign", "valign", xAttributes );
1241 ctx.importGraphicOrImageProperty("image-src" , _xAttributes);
1242 ctx.importImagePositionProperty( "ImagePosition", "image-position", xAttributes );
1243 ctx.importBooleanProperty( "MultiLine", "multiline", xAttributes );
1244 ctx.importStringProperty( "GroupName", "group-name", xAttributes );
1245 sal_Int16 nVal = 0;
1246 sal_Bool bChecked = false;
1247 if (getBoolAttr( &bChecked, "checked", xAttributes, m_pImport->XMLNS_DIALOGS_UID ) && bChecked)
1249 nVal = 1;
1251 xControlModel->setPropertyValue( "State", Any( nVal ) );
1253 ctx.importDataAwareProperty( "linked-cell", xAttributes );
1255 ::std::vector< Reference< xml::input::XElement > > & radioEvents =
1256 static_cast< RadioElement * >( xRadio.get() )->getEvents();
1257 ctx.importEvents( radioEvents );
1258 // avoid ring-reference:
1259 // vector< event elements > holding event elements holding this (via _pParent)
1260 radioEvents.clear();
1262 ctx.finish();
1264 // avoid ring-reference:
1265 // vector< radio elements > holding radio elements holding this (via _pParent)
1266 _radios.clear();
1269 // menupopup
1270 Reference< xml::input::XElement > MenuPopupElement::startChildElement(
1271 sal_Int32 nUid, OUString const & rLocalName,
1272 Reference< xml::input::XAttributes > const & xAttributes )
1274 if (m_pImport->XMLNS_DIALOGS_UID != nUid)
1276 throw xml::sax::SAXException( "illegal namespace!", Reference< XInterface >(), Any() );
1278 // menuitem
1279 else if ( rLocalName == "menuitem" )
1281 OUString aValue( xAttributes->getValueByUidName( m_pImport->XMLNS_DIALOGS_UID,"value" ) );
1282 SAL_WARN_IF( aValue.isEmpty() && !_allowEmptyItems, "xmlscript.xmldlg", "### menuitem has no value?" );
1283 if ((!aValue.isEmpty()) || _allowEmptyItems)
1285 _itemValues.push_back( aValue );
1287 OUString aSel( xAttributes->getValueByUidName( m_pImport->XMLNS_DIALOGS_UID, "selected" ) );
1288 if (!aSel.isEmpty() && aSel == "true")
1290 _itemSelected.push_back( static_cast<sal_Int16>(_itemValues.size()) -1 );
1293 return new ElementBase( m_pImport->XMLNS_DIALOGS_UID, rLocalName, xAttributes, this, m_pImport );
1295 else
1297 throw xml::sax::SAXException("expected menuitem!" , Reference< XInterface >(), Any() );
1300 Sequence< OUString > MenuPopupElement::getItemValues()
1302 Sequence< OUString > aRet( _itemValues.size() );
1303 OUString * pRet = aRet.getArray();
1304 for ( size_t nPos = _itemValues.size(); nPos--; )
1306 pRet[ nPos ] = _itemValues[ nPos ];
1308 return aRet;
1310 Sequence< sal_Int16 > MenuPopupElement::getSelectedItems()
1312 Sequence< sal_Int16 > aRet( _itemSelected.size() );
1313 sal_Int16 * pRet = aRet.getArray();
1314 for ( size_t nPos = _itemSelected.size(); nPos--; )
1316 pRet[ nPos ] = _itemSelected[ nPos ];
1318 return aRet;
1321 // menulist
1322 Reference< xml::input::XElement > MenuListElement::startChildElement(
1323 sal_Int32 nUid, OUString const & rLocalName,
1324 Reference< xml::input::XAttributes > const & xAttributes )
1326 // event
1327 if (m_pImport->isEventElement( nUid, rLocalName ))
1329 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
1331 else if (m_pImport->XMLNS_DIALOGS_UID != nUid)
1333 throw xml::sax::SAXException( "illegal namespace!", Reference< XInterface >(), Any() );
1335 // menupopup
1336 else if ( rLocalName == "menupopup" )
1338 _popup = new MenuPopupElement( rLocalName, xAttributes, this, m_pImport, false );
1339 return _popup;
1341 else
1343 throw xml::sax::SAXException( "expected event or menupopup element!", Reference< XInterface >(), Any() );
1347 void MenuListElement::endElement()
1349 ControlImportContext ctx( m_pImport, getControlId( _xAttributes ), getControlModelName( "com.sun.star.awt.UnoControlListBoxModel", _xAttributes ) );
1350 Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() );
1352 Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
1353 if (xStyle.is())
1355 StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
1356 pStyle->importBackgroundColorStyle( xControlModel );
1357 pStyle->importTextColorStyle( xControlModel );
1358 pStyle->importTextLineColorStyle( xControlModel );
1359 pStyle->importBorderStyle( xControlModel );
1360 pStyle->importFontStyle( xControlModel );
1363 ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
1364 ctx.importBooleanProperty( "Tabstop", "tabstop", _xAttributes );
1365 ctx.importBooleanProperty( "MultiSelection", "multiselection", _xAttributes );
1366 ctx.importBooleanProperty( "ReadOnly", "readonly", _xAttributes );
1367 ctx.importBooleanProperty( "Dropdown", "spin", _xAttributes );
1368 ctx.importShortProperty( "LineCount", "linecount", _xAttributes );
1369 ctx.importAlignProperty( "Align", "align", _xAttributes );
1370 bool bHasLinkedCell = ctx.importDataAwareProperty( "linked-cell" , _xAttributes );
1371 bool bHasSrcRange = ctx.importDataAwareProperty( "source-cell-range" , _xAttributes );
1372 if (_popup.is())
1374 MenuPopupElement * p = static_cast< MenuPopupElement * >( _popup.get() );
1375 if ( !bHasSrcRange )
1376 xControlModel->setPropertyValue( "StringItemList", Any( p->getItemValues() ) );
1377 if ( !bHasLinkedCell )
1378 xControlModel->setPropertyValue( "SelectedItems", Any( p->getSelectedItems() ) );
1381 ctx.importEvents( _events );
1382 // avoid ring-reference:
1383 // vector< event elements > holding event elements holding this (via _pParent)
1384 _events.clear();
1386 ctx.finish();
1389 // combobox
1390 Reference< xml::input::XElement > ComboBoxElement::startChildElement(
1391 sal_Int32 nUid, OUString const & rLocalName,
1392 Reference< xml::input::XAttributes > const & xAttributes )
1394 // event
1395 if (m_pImport->isEventElement( nUid, rLocalName ))
1397 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
1399 else if (m_pImport->XMLNS_DIALOGS_UID != nUid)
1401 throw xml::sax::SAXException( "illegal namespace!", Reference< XInterface >(), Any() );
1403 // menupopup
1404 else if ( rLocalName == "menupopup" )
1406 _popup = new MenuPopupElement( rLocalName, xAttributes, this, m_pImport, true );
1407 return _popup;
1409 else
1411 throw xml::sax::SAXException( "expected event or menupopup element!", Reference< XInterface >(), Any() );
1414 void ComboBoxElement::endElement()
1416 ControlImportContext ctx( m_pImport, getControlId( _xAttributes ), getControlModelName( "com.sun.star.awt.UnoControlComboBoxModel", _xAttributes ) );
1417 Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() );
1419 Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
1420 if (xStyle.is())
1422 StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
1423 pStyle->importBackgroundColorStyle( xControlModel );
1424 pStyle->importTextColorStyle( xControlModel );
1425 pStyle->importTextLineColorStyle( xControlModel );
1426 pStyle->importBorderStyle( xControlModel );
1427 pStyle->importFontStyle( xControlModel );
1430 ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
1431 ctx.importBooleanProperty( "Tabstop", "tabstop", _xAttributes );
1432 ctx.importBooleanProperty( "ReadOnly", "readonly", _xAttributes );
1433 ctx.importBooleanProperty( "Autocomplete", "autocomplete", _xAttributes );
1434 ctx.importBooleanProperty( "Dropdown", "spin", _xAttributes );
1435 ctx.importBooleanProperty( "HideInactiveSelection", "hide-inactive-selection", _xAttributes );
1436 ctx.importShortProperty( "MaxTextLen", "maxlength" ,_xAttributes );
1437 ctx.importShortProperty( "LineCount", "linecount" ,_xAttributes );
1438 ctx.importStringProperty( "Text", "value", _xAttributes );
1439 ctx.importAlignProperty( "Align", "align", _xAttributes );
1440 ctx.importDataAwareProperty( "linked-cell" , _xAttributes );
1441 bool bHasSrcRange = ctx.importDataAwareProperty( "source-cell-range" , _xAttributes );
1442 if (_popup.is() && !bHasSrcRange )
1444 MenuPopupElement * p = static_cast< MenuPopupElement * >( _popup.get() );
1445 xControlModel->setPropertyValue( "StringItemList", Any( p->getItemValues() ) );
1448 ctx.importEvents( _events );
1449 // avoid ring-reference:
1450 // vector< event elements > holding event elements holding this (via _pParent)
1451 _events.clear();
1453 ctx.finish();
1456 // checkbox
1457 Reference< xml::input::XElement > CheckBoxElement::startChildElement(
1458 sal_Int32 nUid, OUString const & rLocalName,
1459 Reference< xml::input::XAttributes > const & xAttributes )
1461 // event
1462 if (!m_pImport->isEventElement( nUid, rLocalName ))
1464 throw xml::sax::SAXException( "expected event element!", Reference< XInterface >(), Any() );
1467 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
1470 void CheckBoxElement::endElement()
1472 ControlImportContext ctx( m_pImport, getControlId( _xAttributes ), "com.sun.star.awt.UnoControlCheckBoxModel" );
1473 Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() );
1475 Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
1476 if (xStyle.is())
1478 StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
1479 pStyle->importBackgroundColorStyle( xControlModel );
1480 pStyle->importTextColorStyle( xControlModel );
1481 pStyle->importTextLineColorStyle( xControlModel );
1482 pStyle->importFontStyle( xControlModel );
1483 pStyle->importVisualEffectStyle( xControlModel );
1486 ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
1487 ctx.importBooleanProperty( "Tabstop", "tabstop", _xAttributes );
1488 ctx.importStringProperty( "Label", "value", _xAttributes );
1489 ctx.importAlignProperty( "Align", "align", _xAttributes );
1490 ctx.importVerticalAlignProperty( "VerticalAlign", "valign", _xAttributes );
1491 ctx.importGraphicOrImageProperty("image-src" , _xAttributes);
1492 ctx.importImagePositionProperty( "ImagePosition", "image-position", _xAttributes );
1493 ctx.importBooleanProperty( "MultiLine", "multiline", _xAttributes );
1495 sal_Bool bTriState = false;
1496 if (getBoolAttr( &bTriState, "tristate", _xAttributes, m_pImport->XMLNS_DIALOGS_UID ))
1498 xControlModel->setPropertyValue( "TriState", Any( bTriState ) );
1500 sal_Bool bChecked = false;
1501 if (getBoolAttr( &bChecked, "checked", _xAttributes, m_pImport->XMLNS_DIALOGS_UID ))
1503 // has "checked" attribute
1504 sal_Int16 nVal = (bChecked ? 1 : 0);
1505 xControlModel->setPropertyValue( "State", Any( nVal ) );
1507 else
1509 sal_Int16 nVal = (bTriState ? 2 : 0); // if tristate set, but checked omitted => don't know!
1510 xControlModel->setPropertyValue( "State", Any( nVal ) );
1513 ctx.importEvents( _events );
1514 // avoid ring-reference:
1515 // vector< event elements > holding event elements holding this (via _pParent)
1516 _events.clear();
1518 ctx.finish();
1521 // button
1522 Reference< xml::input::XElement > ButtonElement::startChildElement(
1523 sal_Int32 nUid, OUString const & rLocalName,
1524 Reference< xml::input::XAttributes > const & xAttributes )
1526 // event
1527 if (!m_pImport->isEventElement( nUid, rLocalName ))
1529 throw xml::sax::SAXException( "expected event element!", Reference< XInterface >(), Any() );
1532 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
1535 void ButtonElement::endElement()
1537 ControlImportContext ctx( m_pImport, getControlId( _xAttributes ), "com.sun.star.awt.UnoControlButtonModel" );
1539 Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
1540 if (xStyle.is())
1542 StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
1543 const Reference< beans::XPropertySet >& xControlModel( ctx.getControlModel() );
1544 pStyle->importBackgroundColorStyle( xControlModel );
1545 pStyle->importTextColorStyle( xControlModel );
1546 pStyle->importTextLineColorStyle( xControlModel );
1547 pStyle->importFontStyle( xControlModel );
1550 ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
1551 ctx.importBooleanProperty( "Tabstop", "tabstop", _xAttributes );
1552 ctx.importStringProperty( "Label", "value", _xAttributes );
1553 ctx.importAlignProperty( "Align", "align", _xAttributes );
1554 ctx.importVerticalAlignProperty( "VerticalAlign", "valign", _xAttributes );
1555 ctx.importBooleanProperty( "DefaultButton", "default", _xAttributes );
1556 ctx.importButtonTypeProperty( "PushButtonType", "button-type", _xAttributes );
1557 ctx.importGraphicOrImageProperty("image-src" , _xAttributes);
1558 ctx.importImagePositionProperty( "ImagePosition", "image-position", _xAttributes );
1559 ctx.importImageAlignProperty( "ImageAlign", "image-align", _xAttributes );
1560 if (ctx.importLongProperty( "RepeatDelay", "repeat", _xAttributes ))
1561 ctx.getControlModel()->setPropertyValue( "Repeat", Any(true) );
1562 sal_Int32 toggled = 0;
1563 if (getLongAttr( &toggled, "toggled", _xAttributes, m_pImport->XMLNS_DIALOGS_UID ) && toggled == 1)
1564 ctx.getControlModel()->setPropertyValue( "Toggle" , Any(true));
1565 ctx.importBooleanProperty( "FocusOnClick", "grab-focus", _xAttributes );
1566 ctx.importBooleanProperty( "MultiLine", "multiline", _xAttributes );
1567 // State
1568 sal_Bool bChecked = false;
1569 if (getBoolAttr( &bChecked, "checked", _xAttributes, m_pImport->XMLNS_DIALOGS_UID ) && bChecked)
1571 ctx.getControlModel()->setPropertyValue( "State" , Any( sal_Int16(1) ) );
1574 ctx.importEvents( _events );
1575 // avoid ring-reference:
1576 // vector< event elements > holding event elements holding this (via _pParent)
1577 _events.clear();
1579 ctx.finish();
1582 // bulletinboard
1583 Reference< xml::input::XElement > BulletinBoardElement::startChildElement(
1584 sal_Int32 nUid, OUString const & rLocalName,
1585 Reference< xml::input::XAttributes > const & xAttributes )
1587 if (m_pImport->XMLNS_DIALOGS_UID != nUid)
1589 throw xml::sax::SAXException("illegal namespace!", Reference< XInterface >(), Any() );
1591 // button
1592 else if ( rLocalName == "button" )
1594 return new ButtonElement( rLocalName, xAttributes, this, m_pImport );
1596 // checkbox
1597 else if ( rLocalName == "checkbox" )
1599 return new CheckBoxElement( rLocalName, xAttributes, this, m_pImport );
1601 // combobox
1602 else if ( rLocalName == "combobox" )
1604 return new ComboBoxElement( rLocalName, xAttributes, this, m_pImport );
1606 // listbox
1607 else if ( rLocalName == "menulist" )
1609 return new MenuListElement( rLocalName, xAttributes, this, m_pImport );
1611 // radiogroup
1612 else if ( rLocalName == "radiogroup" )
1614 return new RadioGroupElement( rLocalName, xAttributes, this, m_pImport );
1616 // titledbox
1617 else if ( rLocalName == "titledbox" )
1619 return new TitledBoxElement( rLocalName, xAttributes, this, m_pImport );
1621 // text
1622 else if ( rLocalName == "text" )
1624 return new TextElement( rLocalName, xAttributes, this, m_pImport );
1626 else if ( rLocalName == "linklabel" )
1628 return new FixedHyperLinkElement( rLocalName, xAttributes, this, m_pImport );
1630 // textfield
1631 else if ( rLocalName == "textfield" )
1633 return new TextFieldElement( rLocalName, xAttributes, this, m_pImport );
1635 // img
1636 else if ( rLocalName == "img" )
1638 return new ImageControlElement( rLocalName, xAttributes, this, m_pImport );
1640 // filecontrol
1641 else if ( rLocalName == "filecontrol" )
1643 return new FileControlElement( rLocalName, xAttributes, this, m_pImport );
1645 // treecontrol
1646 else if ( rLocalName == "treecontrol" )
1648 return new TreeControlElement( rLocalName, xAttributes, this, m_pImport );
1650 // currencyfield
1651 else if ( rLocalName == "currencyfield" )
1653 return new CurrencyFieldElement( rLocalName, xAttributes, this, m_pImport );
1655 // datefield
1656 else if ( rLocalName == "datefield" )
1658 return new DateFieldElement( rLocalName, xAttributes, this, m_pImport );
1660 // datefield
1661 else if ( rLocalName == "numericfield" )
1663 return new NumericFieldElement( rLocalName, xAttributes, this, m_pImport );
1665 // timefield
1666 else if ( rLocalName == "timefield" )
1668 return new TimeFieldElement( rLocalName, xAttributes, this, m_pImport );
1670 // patternfield
1671 else if ( rLocalName == "patternfield" )
1673 return new PatternFieldElement( rLocalName, xAttributes, this, m_pImport );
1675 // formattedfield
1676 else if ( rLocalName == "formattedfield" )
1678 return new FormattedFieldElement( rLocalName, xAttributes, this, m_pImport );
1680 // fixedline
1681 else if ( rLocalName == "fixedline" )
1683 return new FixedLineElement( rLocalName, xAttributes, this, m_pImport );
1685 // scrollbar
1686 else if ( rLocalName == "scrollbar" )
1688 return new ScrollBarElement( rLocalName, xAttributes, this, m_pImport );
1690 // spinbutton
1691 else if ( rLocalName == "spinbutton" )
1693 return new SpinButtonElement( rLocalName, xAttributes, this, m_pImport );
1695 // progressmeter
1696 else if ( rLocalName == "progressmeter" )
1698 return new ProgressBarElement( rLocalName, xAttributes, this, m_pImport );
1700 // table
1701 else if (rLocalName == "table")
1703 return new GridControlElement( rLocalName, xAttributes, this, m_pImport );
1705 else if ( rLocalName == "multipage" )
1707 return new MultiPage( rLocalName, xAttributes, this, m_pImport );
1709 else if ( rLocalName == "frame" )
1711 return new Frame( rLocalName, xAttributes, this, m_pImport );
1713 else if ( rLocalName == "page" )
1715 return new Page( rLocalName, xAttributes, this, m_pImport );
1717 // bulletinboard
1718 else if ( rLocalName == "bulletinboard" )
1720 return new BulletinBoardElement( rLocalName, xAttributes, this, m_pImport );
1722 else
1724 throw xml::sax::SAXException( "expected styles, bulletinboard or bulletinboard element, not: " + rLocalName, Reference< XInterface >(), Any() );
1728 BulletinBoardElement::BulletinBoardElement(
1729 OUString const & rLocalName,
1730 Reference< xml::input::XAttributes > const & xAttributes,
1731 ElementBase * pParent, DialogImport * pImport )
1732 : ControlElement( rLocalName, xAttributes, pParent, pImport ),
1733 mxDialogImport(pImport)
1735 OUString aValue( _xAttributes->getValueByUidName( m_pImport->XMLNS_DIALOGS_UID, "left" ) );
1736 if (!aValue.isEmpty())
1738 _nBasePosX += toInt32( aValue );
1740 aValue = _xAttributes->getValueByUidName( m_pImport->XMLNS_DIALOGS_UID, "top" );
1741 if (!aValue.isEmpty())
1743 _nBasePosY += toInt32( aValue );
1747 // style
1748 Reference< xml::input::XElement > StyleElement::startChildElement(
1749 sal_Int32 /*nUid*/, OUString const & /*rLocalName*/,
1750 Reference< xml::input::XAttributes > const & /*xAttributes*/ )
1752 throw xml::sax::SAXException( "unexpected sub elements of style!", Reference< XInterface >(), Any() );
1755 void StyleElement::endElement()
1757 OUString aStyleId( _xAttributes->getValueByUidName( m_pImport->XMLNS_DIALOGS_UID, "style-id" ) );
1758 if (aStyleId.isEmpty())
1760 throw xml::sax::SAXException( "missing style-id attribute!", Reference< XInterface >(), Any() );
1763 m_pImport->addStyle( aStyleId, this );
1766 // styles
1767 Reference< xml::input::XElement > StylesElement::startChildElement(
1768 sal_Int32 nUid, OUString const & rLocalName,
1769 Reference< xml::input::XAttributes > const & xAttributes )
1771 if (m_pImport->XMLNS_DIALOGS_UID != nUid)
1773 throw xml::sax::SAXException( "illegal namespace!", Reference< XInterface >(), Any() );
1775 // style
1776 else if ( rLocalName == "style" )
1778 return new StyleElement( rLocalName, xAttributes, this, m_pImport );
1780 else
1782 throw xml::sax::SAXException( "expected style element!", Reference< XInterface >(), Any() );
1786 // window
1787 Reference< xml::input::XElement > WindowElement::startChildElement(
1788 sal_Int32 nUid, OUString const & rLocalName,
1789 Reference< xml::input::XAttributes > const & xAttributes )
1791 // event
1792 if (m_pImport->isEventElement( nUid, rLocalName ))
1794 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
1796 else if (m_pImport->XMLNS_DIALOGS_UID != nUid)
1798 throw xml::sax::SAXException( "illegal namespace!", Reference< XInterface >(), Any() );
1800 // styles
1801 else if ( rLocalName == "styles" )
1803 return new StylesElement( rLocalName, xAttributes, this, m_pImport );
1805 // bulletinboard
1806 else if ( rLocalName == "bulletinboard" )
1808 return new BulletinBoardElement( rLocalName, xAttributes, this, m_pImport );
1810 else
1812 throw xml::sax::SAXException( "expected styles or bulletinboard element!", Reference< XInterface >(), Any() );
1816 void WindowElement::endElement()
1818 Reference< beans::XPropertySet > xProps(
1819 m_pImport->_xDialogModel, UNO_QUERY_THROW );
1820 ImportContext ctx( m_pImport, xProps, getControlId( _xAttributes ) );
1822 Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
1823 if (xStyle.is())
1825 StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
1826 pStyle->importBackgroundColorStyle( xProps );
1827 pStyle->importTextColorStyle( xProps );
1828 pStyle->importTextLineColorStyle( xProps );
1829 pStyle->importFontStyle( xProps );
1832 ctx.importDefaults( 0, 0, _xAttributes, false );
1833 ctx.importBooleanProperty( "Closeable", "closeable", _xAttributes );
1834 ctx.importBooleanProperty( "Moveable", "moveable", _xAttributes );
1835 ctx.importBooleanProperty("Sizeable", "resizeable", _xAttributes );
1836 ctx.importStringProperty("Title", "title", _xAttributes );
1837 ctx.importBooleanProperty("Decoration", "withtitlebar", _xAttributes );
1838 ctx.importGraphicOrImageProperty("image-src" , _xAttributes);
1839 ctx.importScollableSettings( _xAttributes );
1840 ctx.importEvents( _events );
1841 // avoid ring-reference:
1842 // vector< event elements > holding event elements holding this (via _pParent)
1843 _events.clear();
1846 // table
1847 Reference< xml::input::XElement > GridControlElement::startChildElement(
1848 sal_Int32 nUid, OUString const & rLocalName,
1849 Reference< xml::input::XAttributes > const & xAttributes )
1851 // event
1852 if (!m_pImport->isEventElement( nUid, rLocalName ))
1854 throw xml::sax::SAXException( "expected event element!", Reference< XInterface >(), Any() );
1857 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
1861 void GridControlElement::endElement()
1863 ControlImportContext ctx( m_pImport, getControlId( _xAttributes ), "com.sun.star.awt.grid.UnoControlGridModel");
1864 Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() );
1865 Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
1866 if (xStyle.is())
1868 StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
1869 pStyle->importBackgroundColorStyle( xControlModel );
1870 pStyle->importBorderStyle( xControlModel );
1871 pStyle->importTextColorStyle( xControlModel );
1872 pStyle->importTextLineColorStyle( xControlModel );
1873 pStyle->importFontStyle( xControlModel );
1875 ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
1876 ctx.importBooleanProperty( "Tabstop", "tabstop", _xAttributes );
1877 ctx.importVerticalAlignProperty( "VerticalAlign", "valign", _xAttributes );
1878 ctx.importSelectionTypeProperty( "SelectionModel", "selectiontype", _xAttributes );
1879 ctx.importBooleanProperty( "ShowColumnHeader", "showcolumnheader", _xAttributes );
1880 ctx.importBooleanProperty( "ShowRowHeader", "showrowheader", _xAttributes );
1881 ctx.importHexLongProperty( "GridLineColor", "gridline-color", _xAttributes );
1882 ctx.importBooleanProperty( "UseGridLines", "usegridlines", _xAttributes );
1883 ctx.importHexLongProperty( "HeaderBackgroundColor", "headerbackground-color", _xAttributes );
1884 ctx.importHexLongProperty( "HeaderTextColor", "headertext-color", _xAttributes );
1885 ctx.importHexLongProperty( "ActiveSelectionBackgroundColor", "activeselectionbackground-color", _xAttributes );
1886 ctx.importHexLongProperty( "ActiveSelectionTextColor", "activeselectiontext-color", _xAttributes );
1887 ctx.importHexLongProperty( "InactiveSelectionBackgroundColor", "inactiveselectionbackground-color", _xAttributes );
1888 ctx.importHexLongProperty( "InactiveSelectionTextColor", "inactiveselectiontext-color", _xAttributes );
1889 ctx.importEvents( _events );
1890 // avoid ring-reference:
1891 // vector< event elements > holding event elements holding this (via _pParent)
1892 _events.clear();
1894 ctx.finish();
1897 //##################################################################################################
1901 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */