Fix GNU C++ version check
[LibreOffice.git] / xmlscript / source / xmldlg_imexp / xmldlg_impmodels.cxx
blob5457d02edb7e33b878485ccc1bf72c1f25df8883
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( u"com.sun.star.awt.UnoFrameModel"_ustr ), 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, u"value"_ustr, 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(u"expected event element!"_ustr, Reference< XInterface >(), Any() );
67 void Frame::endElement()
69 if ( !m_xContainer.is() )
70 m_xContainer.set( m_pImport->_xDialogModelFactory->createInstance( u"com.sun.star.awt.UnoFrameModel"_ustr ), 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( u"Label"_ustr , 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( u"expected event element!"_ustr, 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(u"MultiPageValue"_ustr , u"value"_ustr, _xAttributes );
145 ctx.importBooleanProperty( u"Decoration"_ustr, u"withtabs"_ustr, _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(u"expected event element!"_ustr, 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( u"Title"_ustr, u"title"_ustr, _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( u"expected event element!"_ustr, 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 ), u"com.sun.star.awt.UnoControlProgressBarModel"_ustr );
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( u"ProgressValue"_ustr, u"value"_ustr, _xAttributes );
237 ctx.importLongProperty( u"ProgressValueMin"_ustr, u"value-min"_ustr, _xAttributes );
238 ctx.importLongProperty( u"ProgressValueMax"_ustr, u"value-max"_ustr, _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(u"expected event element!"_ustr, 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( u"com.sun.star.awt.UnoControlScrollBarModel"_ustr , _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( u"Orientation"_ustr , u"align"_ustr, _xAttributes );
276 ctx.importLongProperty( u"BlockIncrement"_ustr , u"pageincrement"_ustr , _xAttributes );
277 ctx.importLongProperty( u"LineIncrement"_ustr , u"increment"_ustr , _xAttributes );
278 ctx.importLongProperty( u"ScrollValue"_ustr ,u"curpos"_ustr, _xAttributes );
279 ctx.importLongProperty( u"ScrollValueMax"_ustr , u"maxpos"_ustr , _xAttributes );
280 ctx.importLongProperty( u"ScrollValueMin"_ustr,u"minpos"_ustr, _xAttributes );
281 ctx.importLongProperty( u"VisibleSize"_ustr, u"visible-size"_ustr, _xAttributes );
282 ctx.importLongProperty( u"RepeatDelay"_ustr, u"repeat"_ustr, _xAttributes );
283 ctx.importBooleanProperty( u"Tabstop"_ustr, u"tabstop"_ustr , _xAttributes );
284 ctx.importBooleanProperty( u"LiveScroll"_ustr, u"live-scroll"_ustr, _xAttributes );
285 ctx.importHexLongProperty( u"SymbolColor"_ustr, u"symbol-color"_ustr, _xAttributes );
287 ctx.importDataAwareProperty( u"linked-cell"_ustr , _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(u"expected event element!"_ustr, 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( u"com.sun.star.awt.UnoControlSpinButtonModel"_ustr, _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( u"Orientation"_ustr, u"align"_ustr, _xAttributes );
325 ctx.importLongProperty(u"SpinIncrement"_ustr, u"increment"_ustr, _xAttributes );
326 ctx.importLongProperty(u"SpinValue"_ustr, u"curval"_ustr ,_xAttributes );
327 ctx.importLongProperty(u"SpinValueMax"_ustr, u"maxval"_ustr, _xAttributes );
328 ctx.importLongProperty( u"SpinValueMin"_ustr,u"minval"_ustr,_xAttributes );
329 ctx.importLongProperty( u"Repeat"_ustr, u"repeat"_ustr, _xAttributes );
330 ctx.importLongProperty( u"RepeatDelay"_ustr, u"repeat-delay"_ustr,_xAttributes );
331 ctx.importBooleanProperty( u"Tabstop"_ustr, u"tabstop"_ustr, _xAttributes );
332 ctx.importHexLongProperty( u"SymbolColor"_ustr, u"symbol-color"_ustr , _xAttributes );
333 ctx.importDataAwareProperty( u"linked-cell"_ustr , _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(u"expected event element!"_ustr, Reference< XInterface >(), Any() );
353 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
356 void FixedLineElement::endElement()
358 ControlImportContext ctx(m_pImport, getControlId( _xAttributes ), u"com.sun.star.awt.UnoControlFixedLineModel"_ustr );
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( u"Label"_ustr, u"value"_ustr, _xAttributes );
372 ctx.importOrientationProperty( u"Orientation"_ustr, u"align"_ustr, _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(u"expected event element!"_ustr, Reference< XInterface >(), Any() );
392 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
395 void PatternFieldElement::endElement()
397 ControlImportContext ctx( m_pImport, getControlId( _xAttributes ), u"com.sun.star.awt.UnoControlPatternFieldModel"_ustr );
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( u"Tabstop"_ustr, u"tabstop"_ustr, _xAttributes );
413 ctx.importBooleanProperty( u"ReadOnly"_ustr, u"readonly"_ustr , _xAttributes );
414 ctx.importBooleanProperty( u"StrictFormat"_ustr, u"strict-format"_ustr, _xAttributes );
415 ctx.importBooleanProperty( u"HideInactiveSelection"_ustr, u"hide-inactive-selection"_ustr, _xAttributes );
416 ctx.importStringProperty( u"Text"_ustr, u"value"_ustr, _xAttributes );
417 ctx.importShortProperty( u"MaxTextLen"_ustr, u"maxlength"_ustr, _xAttributes );
418 ctx.importStringProperty( u"EditMask"_ustr, u"edit-mask"_ustr, _xAttributes );
419 ctx.importStringProperty( u"LiteralMask"_ustr, u"literal-mask"_ustr, _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(u"expected event element!"_ustr, Reference< XInterface >(), Any() );
439 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
442 void FormattedFieldElement::endElement()
444 ControlImportContext ctx( m_pImport, getControlId( _xAttributes ), u"com.sun.star.awt.UnoControlFormattedFieldModel"_ustr );
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( u"Tabstop"_ustr, u"tabstop"_ustr, _xAttributes );
460 ctx.importBooleanProperty( u"ReadOnly"_ustr, u"readonly"_ustr , _xAttributes );
461 ctx.importBooleanProperty( u"StrictFormat"_ustr, u"strict-format"_ustr , _xAttributes );
462 ctx.importBooleanProperty( u"HideInactiveSelection"_ustr, u"hide-inactive-selection"_ustr, _xAttributes );
463 ctx.importAlignProperty( u"Align"_ustr , u"align"_ustr , _xAttributes );
464 ctx.importDoubleProperty( u"EffectiveMin"_ustr, u"value-min"_ustr , _xAttributes );
465 ctx.importDoubleProperty( u"EffectiveMax"_ustr, u"value-max"_ustr, _xAttributes);
466 ctx.importDoubleProperty( u"EffectiveValue"_ustr, u"value"_ustr, _xAttributes );
467 ctx.importStringProperty( u"Text"_ustr, u"text"_ustr, _xAttributes );
468 ctx.importShortProperty( u"MaxTextLen"_ustr, u"maxlength"_ustr, _xAttributes );
469 ctx.importBooleanProperty( u"Spin"_ustr, u"spin"_ustr, _xAttributes );
470 if (ctx.importLongProperty( u"RepeatDelay"_ustr, u"repeat"_ustr, _xAttributes ))
471 ctx.getControlModel()->setPropertyValue( u"Repeat"_ustr , Any(true) );
473 OUString sDefault(_xAttributes->getValueByUidName(m_pImport->XMLNS_DIALOGS_UID, u"value-default"_ustr) );
474 if (!sDefault.isEmpty())
476 double d = sDefault.toDouble();
477 if (d != 0.0 || sDefault == "0" || sDefault == "0.0" )
479 ctx.getControlModel()->setPropertyValue( u"EffectiveDefault"_ustr, Any( d ) );
481 else // treat as string
483 ctx.getControlModel()->setPropertyValue( u"EffectiveDefault"_ustr, Any( sDefault ) );
487 // format spec
488 ctx.getControlModel()->setPropertyValue(u"FormatsSupplier"_ustr, Any( m_pImport->getNumberFormatsSupplier() ) );
490 OUString sFormat( _xAttributes->getValueByUidName(m_pImport->XMLNS_DIALOGS_UID, u"format-code"_ustr ) );
491 if (!sFormat.isEmpty())
493 lang::Locale locale;
495 OUString sLocale( _xAttributes->getValueByUidName( m_pImport->XMLNS_DIALOGS_UID, u"format-locale"_ustr ) );
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(u"FormatKey"_ustr, 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(u"TreatAsNumber"_ustr, u"treat-as-number"_ustr , _xAttributes );
544 ctx.importBooleanProperty(u"EnforceFormat"_ustr, u"enforce-format"_ustr, _xAttributes );
546 ctx.importDataAwareProperty( u"linked-cell"_ustr , _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(u"expected event element!"_ustr, Reference< XInterface >(), Any() );
566 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
569 void TimeFieldElement::endElement()
571 ControlImportContext ctx( m_pImport, getControlId( _xAttributes ), u"com.sun.star.awt.UnoControlTimeFieldModel"_ustr );
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(u"Tabstop"_ustr, u"tabstop"_ustr, _xAttributes );
587 ctx.importBooleanProperty(u"ReadOnly"_ustr, u"readonly"_ustr, _xAttributes );
588 ctx.importBooleanProperty( u"StrictFormat"_ustr, u"strict-format"_ustr, _xAttributes );
589 ctx.importBooleanProperty(u"HideInactiveSelection"_ustr,u"hide-inactive-selection"_ustr, _xAttributes );
590 ctx.importTimeFormatProperty( u"TimeFormat"_ustr, u"time-format"_ustr, _xAttributes );
591 ctx.importTimeProperty( u"Time"_ustr, u"value"_ustr, _xAttributes );
592 ctx.importTimeProperty( u"TimeMin"_ustr, u"value-min"_ustr, _xAttributes );
593 ctx.importTimeProperty( u"TimeMax"_ustr, u"value-max"_ustr, _xAttributes );
594 ctx.importBooleanProperty( u"Spin"_ustr, u"spin"_ustr, _xAttributes );
595 if (ctx.importLongProperty( u"RepeatDelay"_ustr, u"repeat"_ustr, _xAttributes ))
596 ctx.getControlModel()->setPropertyValue(u"Repeat"_ustr, Any(true) );
597 ctx.importStringProperty( u"Text"_ustr, u"text"_ustr , _xAttributes );
598 ctx.importBooleanProperty( u"EnforceFormat"_ustr, u"enforce-format"_ustr , _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( u"expected event element!"_ustr, Reference< XInterface >(), Any() );
619 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
622 void NumericFieldElement::endElement()
624 ControlImportContext ctx( m_pImport, getControlId( _xAttributes ), u"com.sun.star.awt.UnoControlNumericFieldModel"_ustr );
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( u"Align"_ustr, u"align"_ustr, _xAttributes );
640 ctx.importVerticalAlignProperty( u"VerticalAlign"_ustr, u"valign"_ustr, _xAttributes );
641 ctx.importBooleanProperty( u"Tabstop"_ustr,u"tabstop"_ustr,_xAttributes );
642 ctx.importBooleanProperty( u"ReadOnly"_ustr, u"readonly"_ustr,_xAttributes );
643 ctx.importBooleanProperty( u"StrictFormat"_ustr, u"strict-format"_ustr, _xAttributes );
644 ctx.importBooleanProperty( u"HideInactiveSelection"_ustr, u"hide-inactive-selection"_ustr, _xAttributes );
645 ctx.importShortProperty( u"DecimalAccuracy"_ustr, u"decimal-accuracy"_ustr, _xAttributes );
646 ctx.importBooleanProperty( u"ShowThousandsSeparator"_ustr, u"thousands-separator"_ustr, _xAttributes );
647 ctx.importDoubleProperty( u"Value"_ustr, u"value"_ustr, _xAttributes );
648 ctx.importDoubleProperty( u"ValueMin"_ustr, u"value-min"_ustr, _xAttributes );
649 ctx.importDoubleProperty( u"ValueMax"_ustr, u"value-max"_ustr, _xAttributes );
650 ctx.importDoubleProperty( u"ValueStep"_ustr, u"value-step"_ustr, _xAttributes );
651 ctx.importBooleanProperty( u"Spin"_ustr, u"spin"_ustr, _xAttributes );
652 if (ctx.importLongProperty( u"RepeatDelay"_ustr, u"repeat"_ustr, _xAttributes ))
653 ctx.getControlModel()->setPropertyValue(u"Repeat"_ustr, Any(true) );
654 ctx.importBooleanProperty( u"EnforceFormat"_ustr, u"enforce-format"_ustr, _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(u"expected event element!"_ustr, Reference< XInterface >(), Any() );
674 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
677 void DateFieldElement::endElement()
679 ControlImportContext ctx( m_pImport, getControlId( _xAttributes ), u"com.sun.star.awt.UnoControlDateFieldModel"_ustr );
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( u"Align"_ustr, u"align"_ustr, _xAttributes );
695 ctx.importVerticalAlignProperty( u"VerticalAlign"_ustr, u"valign"_ustr, _xAttributes );
696 ctx.importBooleanProperty( u"Tabstop"_ustr, u"tabstop"_ustr, _xAttributes );
697 ctx.importBooleanProperty( u"ReadOnly"_ustr, u"readonly"_ustr, _xAttributes );
698 ctx.importBooleanProperty( u"StrictFormat"_ustr, u"strict-format"_ustr, _xAttributes );
699 ctx.importBooleanProperty( u"HideInactiveSelection"_ustr, u"hide-inactive-selection"_ustr, _xAttributes );
700 ctx.importDateFormatProperty( u"DateFormat"_ustr, u"date-format"_ustr, _xAttributes );
701 ctx.importBooleanProperty( u"DateShowCentury"_ustr, u"show-century"_ustr, _xAttributes );
702 ctx.importDateProperty( u"Date"_ustr, u"value"_ustr, _xAttributes );
703 ctx.importDateProperty( u"DateMin"_ustr, u"value-min"_ustr, _xAttributes );
704 ctx.importDateProperty( u"DateMax"_ustr, u"value-max"_ustr, _xAttributes );
705 ctx.importBooleanProperty( u"Spin"_ustr, u"spin"_ustr, _xAttributes );
706 if (ctx.importLongProperty( u"RepeatDelay"_ustr, u"repeat"_ustr, _xAttributes ))
707 ctx.getControlModel()->setPropertyValue( u"Repeat"_ustr, Any(true) );
708 ctx.importBooleanProperty( u"Dropdown"_ustr, u"dropdown"_ustr, _xAttributes );
709 ctx.importStringProperty( u"Text"_ustr, u"text"_ustr, _xAttributes );
710 ctx.importBooleanProperty( u"EnforceFormat"_ustr, u"enforce-format"_ustr, _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( u"expected event element!"_ustr , Reference< XInterface >(), Any() );
730 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
733 void CurrencyFieldElement::endElement()
735 ControlImportContext ctx( m_pImport, getControlId( _xAttributes ), u"com.sun.star.awt.UnoControlCurrencyFieldModel"_ustr );
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( u"Align"_ustr, u"align"_ustr, _xAttributes );
751 ctx.importVerticalAlignProperty( u"VerticalAlign"_ustr, u"valign"_ustr, _xAttributes );
752 ctx.importBooleanProperty(u"Tabstop"_ustr, u"tabstop"_ustr, _xAttributes );
753 ctx.importBooleanProperty( u"ReadOnly"_ustr, u"readonly"_ustr , _xAttributes );
754 ctx.importBooleanProperty( u"StrictFormat"_ustr, u"strict-format"_ustr, _xAttributes );
755 ctx.importBooleanProperty( u"HideInactiveSelection"_ustr, u"hide-inactive-selection"_ustr, _xAttributes );
756 ctx.importStringProperty( u"CurrencySymbol"_ustr, u"currency-symbol"_ustr, _xAttributes );
757 ctx.importShortProperty( u"DecimalAccuracy"_ustr, u"decimal-accuracy"_ustr, _xAttributes );
758 ctx.importBooleanProperty( u"ShowThousandsSeparator"_ustr, u"thousands-separator"_ustr, _xAttributes );
759 ctx.importDoubleProperty( u"Value"_ustr, u"value"_ustr, _xAttributes );
760 ctx.importDoubleProperty( u"ValueMin"_ustr, u"value-min"_ustr, _xAttributes );
761 ctx.importDoubleProperty( u"ValueMax"_ustr, u"value-max"_ustr, _xAttributes );
762 ctx.importDoubleProperty( u"ValueStep"_ustr, u"value-step"_ustr, _xAttributes );
763 ctx.importBooleanProperty( u"Spin"_ustr, u"spin"_ustr, _xAttributes );
764 if (ctx.importLongProperty( u"RepeatDelay"_ustr, u"repeat"_ustr, _xAttributes ))
765 ctx.getControlModel()->setPropertyValue( u"Repeat"_ustr, Any(true) );
766 ctx.importBooleanProperty( u"PrependCurrencySymbol"_ustr, u"prepend-symbol"_ustr, _xAttributes );
767 ctx.importBooleanProperty( u"EnforceFormat"_ustr, u"enforce-format"_ustr, _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( u"expected event element!"_ustr, Reference< XInterface >(), Any() );
787 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
790 void FileControlElement::endElement()
792 ControlImportContext ctx( m_pImport, getControlId( _xAttributes ), u"com.sun.star.awt.UnoControlFileControlModel"_ustr );
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( u"Tabstop"_ustr, u"tabstop"_ustr, _xAttributes );
808 ctx.importBooleanProperty(u"HideInactiveSelection"_ustr,u"hide-inactive-selection"_ustr, _xAttributes );
809 ctx.importStringProperty( u"Text"_ustr, u"value"_ustr, _xAttributes );
810 ctx.importBooleanProperty( u"ReadOnly"_ustr, u"readonly"_ustr, _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( u"expected event element!"_ustr, Reference< XInterface >(), Any() );
830 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
833 void TreeControlElement::endElement()
835 ControlImportContext ctx( m_pImport, getControlId( _xAttributes ), u"com.sun.star.awt.tree.TreeControlModel"_ustr );
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( u"Tabstop"_ustr, u"tabstop"_ustr, _xAttributes );
848 ctx.importSelectionTypeProperty( u"SelectionType"_ustr, u"selectiontype"_ustr, _xAttributes );
849 ctx.importBooleanProperty( u"RootDisplayed"_ustr, u"rootdisplayed"_ustr, _xAttributes );
850 ctx.importBooleanProperty( u"ShowsHandles"_ustr, u"showshandles"_ustr, _xAttributes );
851 ctx.importBooleanProperty( u"ShowsRootHandles"_ustr, u"showsroothandles"_ustr ,_xAttributes );
852 ctx.importBooleanProperty( u"Editable"_ustr, u"editable"_ustr, _xAttributes );
853 ctx.importBooleanProperty( u"RowHeight"_ustr, u"readonly"_ustr, _xAttributes );
854 ctx.importBooleanProperty( u"InvokesStopNodeEditing"_ustr, u"invokesstopnodeediting"_ustr, _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( u"expected event element!"_ustr , Reference< XInterface >(), Any() );
875 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
878 void ImageControlElement::endElement()
880 ControlImportContext ctx( m_pImport, getControlId( _xAttributes ), u"com.sun.star.awt.UnoControlImageControlModel"_ustr );
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( u"ScaleImage"_ustr, u"scale-image"_ustr, _xAttributes );
893 ctx.importImageScaleModeProperty( u"ScaleMode"_ustr , u"scale-mode"_ustr , _xAttributes );
894 ctx.importGraphicOrImageProperty(u"src"_ustr , _xAttributes);
895 ctx.importBooleanProperty( u"Tabstop"_ustr, u"tabstop"_ustr, _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( u"expected event element!"_ustr, Reference< XInterface >(), Any() );
915 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
918 void TextElement::endElement()
920 ControlImportContext ctx( m_pImport, getControlId( _xAttributes ), u"com.sun.star.awt.UnoControlFixedTextModel"_ustr );
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( u"Label"_ustr, u"value"_ustr, _xAttributes );
936 ctx.importAlignProperty( u"Align"_ustr, u"align"_ustr, _xAttributes );
937 ctx.importVerticalAlignProperty( u"VerticalAlign"_ustr, u"valign"_ustr, _xAttributes );
938 ctx.importBooleanProperty( u"MultiLine"_ustr, u"multiline"_ustr ,_xAttributes );
939 ctx.importBooleanProperty( u"Tabstop"_ustr, u"tabstop"_ustr, _xAttributes );
940 ctx.importBooleanProperty( u"NoLabel"_ustr, u"nolabel"_ustr, _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( u"expected event element!"_ustr , Reference< XInterface >(), Any() );
960 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
963 void FixedHyperLinkElement::endElement()
965 ControlImportContext ctx( m_pImport, getControlId( _xAttributes ), u"com.sun.star.awt.UnoControlFixedHyperlinkModel"_ustr );
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( u"Label"_ustr, u"value"_ustr, _xAttributes );
981 ctx.importStringProperty( u"URL"_ustr, u"url"_ustr, _xAttributes );
983 ctx.importAlignProperty( u"Align"_ustr, u"align"_ustr ,_xAttributes );
984 ctx.importVerticalAlignProperty( u"VerticalAlign"_ustr, u"valign"_ustr, _xAttributes );
985 ctx.importBooleanProperty( u"MultiLine"_ustr, u"multiline"_ustr, _xAttributes );
986 ctx.importBooleanProperty( u"Tabstop"_ustr, u"tabstop"_ustr, _xAttributes );
987 ctx.importBooleanProperty( u"NoLabel"_ustr, u"nolabel"_ustr, _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( u"expected event element!"_ustr, Reference< XInterface >(), Any() );
1007 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
1010 void TextFieldElement::endElement()
1012 ControlImportContext ctx( m_pImport, getControlId( _xAttributes ), u"com.sun.star.awt.UnoControlEditModel"_ustr );
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(u"Tabstop"_ustr, u"tabstop"_ustr, _xAttributes );
1028 ctx.importAlignProperty( u"Align"_ustr, u"align"_ustr, _xAttributes );
1029 ctx.importVerticalAlignProperty( u"VerticalAlign"_ustr, u"valign"_ustr, _xAttributes );
1030 ctx.importBooleanProperty( u"HardLineBreaks"_ustr, u"hard-linebreaks"_ustr, _xAttributes );
1031 ctx.importBooleanProperty( u"HScroll"_ustr, u"hscroll"_ustr ,_xAttributes );
1032 ctx.importBooleanProperty( u"VScroll"_ustr, u"vscroll"_ustr, _xAttributes );
1033 ctx.importBooleanProperty(u"HideInactiveSelection"_ustr, u"hide-inactive-selection"_ustr, _xAttributes );
1034 ctx.importShortProperty( u"MaxTextLen"_ustr, u"maxlength"_ustr, _xAttributes );
1035 ctx.importBooleanProperty( u"MultiLine"_ustr, u"multiline"_ustr, _xAttributes );
1036 ctx.importBooleanProperty( u"ReadOnly"_ustr, u"readonly"_ustr, _xAttributes );
1037 ctx.importStringProperty( u"Text"_ustr, u"value"_ustr, _xAttributes );
1038 ctx.importLineEndFormatProperty( u"LineEndFormat"_ustr, u"lineend-format"_ustr, _xAttributes );
1039 OUString aValue;
1040 if (getStringAttr( &aValue, u"echochar"_ustr, _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( u"EchoChar"_ustr, 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( u"illegal namespace!"_ustr, Reference< XInterface >(), Any() );
1073 // title
1074 else if ( rLocalName == "title" )
1076 getStringAttr( &_label, u"value"_ustr, 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 ), u"com.sun.star.awt.UnoControlGroupBoxModel"_ustr );
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( u"Label"_ustr, 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( u"com.sun.star.awt.UnoControlRadioButtonModel"_ustr, 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( u"Tabstop"_ustr, u"tabstop"_ustr, xAttributes );
1147 ctx.importStringProperty( u"Label"_ustr, u"value"_ustr, xAttributes );
1148 ctx.importAlignProperty( u"Align"_ustr, u"align"_ustr, xAttributes );
1149 ctx.importVerticalAlignProperty( u"VerticalAlign"_ustr, u"valign"_ustr, xAttributes );
1150 ctx.importGraphicOrImageProperty(u"image-src"_ustr , _xAttributes);
1151 ctx.importImagePositionProperty( u"ImagePosition"_ustr, u"image-position"_ustr, xAttributes );
1152 ctx.importBooleanProperty( u"MultiLine"_ustr, u"multiline"_ustr, xAttributes );
1153 ctx.importStringProperty( u"GroupName"_ustr, u"group-name"_ustr, xAttributes );
1155 sal_Int16 nVal = 0;
1156 sal_Bool bChecked = false;
1157 if (getBoolAttr( &bChecked, u"checked"_ustr, xAttributes, m_pImport->XMLNS_DIALOGS_UID ) && bChecked)
1159 nVal = 1;
1161 xControlModel->setPropertyValue( u"State"_ustr, Any( nVal ) );
1162 ctx.importDataAwareProperty( u"linked-cell"_ustr , 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(u"expected event element!"_ustr, 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( u"illegal namespace!"_ustr, 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( u"expected radio element!"_ustr, 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( u"com.sun.star.awt.UnoControlRadioButtonModel"_ustr, 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(u"Tabstop"_ustr, u"tabstop"_ustr, xAttributes );
1238 ctx.importStringProperty( u"Label"_ustr, u"value"_ustr, xAttributes );
1239 ctx.importAlignProperty( u"Align"_ustr, u"align"_ustr, xAttributes );
1240 ctx.importVerticalAlignProperty( u"VerticalAlign"_ustr, u"valign"_ustr, xAttributes );
1241 ctx.importGraphicOrImageProperty(u"image-src"_ustr , _xAttributes);
1242 ctx.importImagePositionProperty( u"ImagePosition"_ustr, u"image-position"_ustr, xAttributes );
1243 ctx.importBooleanProperty( u"MultiLine"_ustr, u"multiline"_ustr, xAttributes );
1244 ctx.importStringProperty( u"GroupName"_ustr, u"group-name"_ustr, xAttributes );
1245 sal_Int16 nVal = 0;
1246 sal_Bool bChecked = false;
1247 if (getBoolAttr( &bChecked, u"checked"_ustr, xAttributes, m_pImport->XMLNS_DIALOGS_UID ) && bChecked)
1249 nVal = 1;
1251 xControlModel->setPropertyValue( u"State"_ustr, Any( nVal ) );
1253 ctx.importDataAwareProperty( u"linked-cell"_ustr, 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( u"illegal namespace!"_ustr, Reference< XInterface >(), Any() );
1278 // menuitem
1279 else if ( rLocalName == "menuitem" )
1281 OUString aValue( xAttributes->getValueByUidName( m_pImport->XMLNS_DIALOGS_UID,u"value"_ustr ) );
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, u"selected"_ustr ) );
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(u"expected menuitem!"_ustr , 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( u"illegal namespace!"_ustr, 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( u"expected event or menupopup element!"_ustr, Reference< XInterface >(), Any() );
1347 void MenuListElement::endElement()
1349 ControlImportContext ctx( m_pImport, getControlId( _xAttributes ), getControlModelName( u"com.sun.star.awt.UnoControlListBoxModel"_ustr, _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( u"Tabstop"_ustr, u"tabstop"_ustr, _xAttributes );
1365 ctx.importBooleanProperty( u"MultiSelection"_ustr, u"multiselection"_ustr, _xAttributes );
1366 ctx.importBooleanProperty( u"ReadOnly"_ustr, u"readonly"_ustr, _xAttributes );
1367 ctx.importBooleanProperty( u"Dropdown"_ustr, u"spin"_ustr, _xAttributes );
1368 ctx.importShortProperty( u"LineCount"_ustr, u"linecount"_ustr, _xAttributes );
1369 ctx.importAlignProperty( u"Align"_ustr, u"align"_ustr, _xAttributes );
1370 bool bHasLinkedCell = ctx.importDataAwareProperty( u"linked-cell"_ustr , _xAttributes );
1371 bool bHasSrcRange = ctx.importDataAwareProperty( u"source-cell-range"_ustr , _xAttributes );
1372 if (_popup.is())
1374 if ( !bHasSrcRange )
1375 xControlModel->setPropertyValue( u"StringItemList"_ustr, Any( _popup->getItemValues() ) );
1376 if ( !bHasLinkedCell )
1377 xControlModel->setPropertyValue( u"SelectedItems"_ustr, Any( _popup->getSelectedItems() ) );
1380 ctx.importEvents( _events );
1381 // avoid ring-reference:
1382 // vector< event elements > holding event elements holding this (via _pParent)
1383 _events.clear();
1385 ctx.finish();
1388 // combobox
1389 Reference< xml::input::XElement > ComboBoxElement::startChildElement(
1390 sal_Int32 nUid, OUString const & rLocalName,
1391 Reference< xml::input::XAttributes > const & xAttributes )
1393 // event
1394 if (m_pImport->isEventElement( nUid, rLocalName ))
1396 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
1398 else if (m_pImport->XMLNS_DIALOGS_UID != nUid)
1400 throw xml::sax::SAXException( u"illegal namespace!"_ustr, Reference< XInterface >(), Any() );
1402 // menupopup
1403 else if ( rLocalName == "menupopup" )
1405 _popup = new MenuPopupElement( rLocalName, xAttributes, this, m_pImport, true );
1406 return _popup;
1408 else
1410 throw xml::sax::SAXException( u"expected event or menupopup element!"_ustr, Reference< XInterface >(), Any() );
1413 void ComboBoxElement::endElement()
1415 ControlImportContext ctx( m_pImport, getControlId( _xAttributes ), getControlModelName( u"com.sun.star.awt.UnoControlComboBoxModel"_ustr, _xAttributes ) );
1416 Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() );
1418 Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
1419 if (xStyle.is())
1421 StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
1422 pStyle->importBackgroundColorStyle( xControlModel );
1423 pStyle->importTextColorStyle( xControlModel );
1424 pStyle->importTextLineColorStyle( xControlModel );
1425 pStyle->importBorderStyle( xControlModel );
1426 pStyle->importFontStyle( xControlModel );
1429 ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
1430 ctx.importBooleanProperty( u"Tabstop"_ustr, u"tabstop"_ustr, _xAttributes );
1431 ctx.importBooleanProperty( u"ReadOnly"_ustr, u"readonly"_ustr, _xAttributes );
1432 ctx.importBooleanProperty( u"Autocomplete"_ustr, u"autocomplete"_ustr, _xAttributes );
1433 ctx.importBooleanProperty( u"Dropdown"_ustr, u"spin"_ustr, _xAttributes );
1434 ctx.importBooleanProperty( u"HideInactiveSelection"_ustr, u"hide-inactive-selection"_ustr, _xAttributes );
1435 ctx.importShortProperty( u"MaxTextLen"_ustr, u"maxlength"_ustr ,_xAttributes );
1436 ctx.importShortProperty( u"LineCount"_ustr, u"linecount"_ustr ,_xAttributes );
1437 ctx.importStringProperty( u"Text"_ustr, u"value"_ustr, _xAttributes );
1438 ctx.importAlignProperty( u"Align"_ustr, u"align"_ustr, _xAttributes );
1439 ctx.importDataAwareProperty( u"linked-cell"_ustr , _xAttributes );
1440 bool bHasSrcRange = ctx.importDataAwareProperty( u"source-cell-range"_ustr , _xAttributes );
1441 if (_popup.is() && !bHasSrcRange )
1443 xControlModel->setPropertyValue( u"StringItemList"_ustr, Any( _popup->getItemValues() ) );
1446 ctx.importEvents( _events );
1447 // avoid ring-reference:
1448 // vector< event elements > holding event elements holding this (via _pParent)
1449 _events.clear();
1451 ctx.finish();
1454 // checkbox
1455 Reference< xml::input::XElement > CheckBoxElement::startChildElement(
1456 sal_Int32 nUid, OUString const & rLocalName,
1457 Reference< xml::input::XAttributes > const & xAttributes )
1459 // event
1460 if (!m_pImport->isEventElement( nUid, rLocalName ))
1462 throw xml::sax::SAXException( u"expected event element!"_ustr, Reference< XInterface >(), Any() );
1465 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
1468 void CheckBoxElement::endElement()
1470 ControlImportContext ctx( m_pImport, getControlId( _xAttributes ), u"com.sun.star.awt.UnoControlCheckBoxModel"_ustr );
1471 Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() );
1473 Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
1474 if (xStyle.is())
1476 StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
1477 pStyle->importBackgroundColorStyle( xControlModel );
1478 pStyle->importTextColorStyle( xControlModel );
1479 pStyle->importTextLineColorStyle( xControlModel );
1480 pStyle->importFontStyle( xControlModel );
1481 pStyle->importVisualEffectStyle( xControlModel );
1484 ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
1485 ctx.importBooleanProperty( u"Tabstop"_ustr, u"tabstop"_ustr, _xAttributes );
1486 ctx.importStringProperty( u"Label"_ustr, u"value"_ustr, _xAttributes );
1487 ctx.importAlignProperty( u"Align"_ustr, u"align"_ustr, _xAttributes );
1488 ctx.importVerticalAlignProperty( u"VerticalAlign"_ustr, u"valign"_ustr, _xAttributes );
1489 ctx.importGraphicOrImageProperty(u"image-src"_ustr , _xAttributes);
1490 ctx.importImagePositionProperty( u"ImagePosition"_ustr, u"image-position"_ustr, _xAttributes );
1491 ctx.importBooleanProperty( u"MultiLine"_ustr, u"multiline"_ustr, _xAttributes );
1493 sal_Bool bTriState = false;
1494 if (getBoolAttr( &bTriState, u"tristate"_ustr, _xAttributes, m_pImport->XMLNS_DIALOGS_UID ))
1496 xControlModel->setPropertyValue( u"TriState"_ustr, Any( bTriState ) );
1498 sal_Bool bChecked = false;
1499 if (getBoolAttr( &bChecked, u"checked"_ustr, _xAttributes, m_pImport->XMLNS_DIALOGS_UID ))
1501 // has "checked" attribute
1502 sal_Int16 nVal = (bChecked ? 1 : 0);
1503 xControlModel->setPropertyValue( u"State"_ustr, Any( nVal ) );
1505 else
1507 sal_Int16 nVal = (bTriState ? 2 : 0); // if tristate set, but checked omitted => don't know!
1508 xControlModel->setPropertyValue( u"State"_ustr, Any( nVal ) );
1511 ctx.importEvents( _events );
1512 // avoid ring-reference:
1513 // vector< event elements > holding event elements holding this (via _pParent)
1514 _events.clear();
1516 ctx.finish();
1519 // button
1520 Reference< xml::input::XElement > ButtonElement::startChildElement(
1521 sal_Int32 nUid, OUString const & rLocalName,
1522 Reference< xml::input::XAttributes > const & xAttributes )
1524 // event
1525 if (!m_pImport->isEventElement( nUid, rLocalName ))
1527 throw xml::sax::SAXException( u"expected event element!"_ustr, Reference< XInterface >(), Any() );
1530 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
1533 void ButtonElement::endElement()
1535 ControlImportContext ctx( m_pImport, getControlId( _xAttributes ), u"com.sun.star.awt.UnoControlButtonModel"_ustr );
1537 Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
1538 if (xStyle.is())
1540 StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
1541 const Reference< beans::XPropertySet >& xControlModel( ctx.getControlModel() );
1542 pStyle->importBackgroundColorStyle( xControlModel );
1543 pStyle->importTextColorStyle( xControlModel );
1544 pStyle->importTextLineColorStyle( xControlModel );
1545 pStyle->importFontStyle( xControlModel );
1548 ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
1549 ctx.importBooleanProperty( u"Tabstop"_ustr, u"tabstop"_ustr, _xAttributes );
1550 ctx.importStringProperty( u"Label"_ustr, u"value"_ustr, _xAttributes );
1551 ctx.importAlignProperty( u"Align"_ustr, u"align"_ustr, _xAttributes );
1552 ctx.importVerticalAlignProperty( u"VerticalAlign"_ustr, u"valign"_ustr, _xAttributes );
1553 ctx.importBooleanProperty( u"DefaultButton"_ustr, u"default"_ustr, _xAttributes );
1554 ctx.importButtonTypeProperty( u"PushButtonType"_ustr, u"button-type"_ustr, _xAttributes );
1555 ctx.importGraphicOrImageProperty(u"image-src"_ustr , _xAttributes);
1556 ctx.importImagePositionProperty( u"ImagePosition"_ustr, u"image-position"_ustr, _xAttributes );
1557 ctx.importImageAlignProperty( u"ImageAlign"_ustr, u"image-align"_ustr, _xAttributes );
1558 if (ctx.importLongProperty( u"RepeatDelay"_ustr, u"repeat"_ustr, _xAttributes ))
1559 ctx.getControlModel()->setPropertyValue( u"Repeat"_ustr, Any(true) );
1560 sal_Int32 toggled = 0;
1561 if (getLongAttr( &toggled, u"toggled"_ustr, _xAttributes, m_pImport->XMLNS_DIALOGS_UID ) && toggled == 1)
1562 ctx.getControlModel()->setPropertyValue( u"Toggle"_ustr , Any(true));
1563 ctx.importBooleanProperty( u"FocusOnClick"_ustr, u"grab-focus"_ustr, _xAttributes );
1564 ctx.importBooleanProperty( u"MultiLine"_ustr, u"multiline"_ustr, _xAttributes );
1565 // State
1566 sal_Bool bChecked = false;
1567 if (getBoolAttr( &bChecked, u"checked"_ustr, _xAttributes, m_pImport->XMLNS_DIALOGS_UID ) && bChecked)
1569 ctx.getControlModel()->setPropertyValue( u"State"_ustr , Any( sal_Int16(1) ) );
1572 ctx.importEvents( _events );
1573 // avoid ring-reference:
1574 // vector< event elements > holding event elements holding this (via _pParent)
1575 _events.clear();
1577 ctx.finish();
1580 // bulletinboard
1581 Reference< xml::input::XElement > BulletinBoardElement::startChildElement(
1582 sal_Int32 nUid, OUString const & rLocalName,
1583 Reference< xml::input::XAttributes > const & xAttributes )
1585 if (m_pImport->XMLNS_DIALOGS_UID != nUid)
1587 throw xml::sax::SAXException(u"illegal namespace!"_ustr, Reference< XInterface >(), Any() );
1589 // button
1590 else if ( rLocalName == "button" )
1592 return new ButtonElement( rLocalName, xAttributes, this, m_pImport );
1594 // checkbox
1595 else if ( rLocalName == "checkbox" )
1597 return new CheckBoxElement( rLocalName, xAttributes, this, m_pImport );
1599 // combobox
1600 else if ( rLocalName == "combobox" )
1602 return new ComboBoxElement( rLocalName, xAttributes, this, m_pImport );
1604 // listbox
1605 else if ( rLocalName == "menulist" )
1607 return new MenuListElement( rLocalName, xAttributes, this, m_pImport );
1609 // radiogroup
1610 else if ( rLocalName == "radiogroup" )
1612 return new RadioGroupElement( rLocalName, xAttributes, this, m_pImport );
1614 // titledbox
1615 else if ( rLocalName == "titledbox" )
1617 return new TitledBoxElement( rLocalName, xAttributes, this, m_pImport );
1619 // text
1620 else if ( rLocalName == "text" )
1622 return new TextElement( rLocalName, xAttributes, this, m_pImport );
1624 else if ( rLocalName == "linklabel" )
1626 return new FixedHyperLinkElement( rLocalName, xAttributes, this, m_pImport );
1628 // textfield
1629 else if ( rLocalName == "textfield" )
1631 return new TextFieldElement( rLocalName, xAttributes, this, m_pImport );
1633 // img
1634 else if ( rLocalName == "img" )
1636 return new ImageControlElement( rLocalName, xAttributes, this, m_pImport );
1638 // filecontrol
1639 else if ( rLocalName == "filecontrol" )
1641 return new FileControlElement( rLocalName, xAttributes, this, m_pImport );
1643 // treecontrol
1644 else if ( rLocalName == "treecontrol" )
1646 return new TreeControlElement( rLocalName, xAttributes, this, m_pImport );
1648 // currencyfield
1649 else if ( rLocalName == "currencyfield" )
1651 return new CurrencyFieldElement( rLocalName, xAttributes, this, m_pImport );
1653 // datefield
1654 else if ( rLocalName == "datefield" )
1656 return new DateFieldElement( rLocalName, xAttributes, this, m_pImport );
1658 // datefield
1659 else if ( rLocalName == "numericfield" )
1661 return new NumericFieldElement( rLocalName, xAttributes, this, m_pImport );
1663 // timefield
1664 else if ( rLocalName == "timefield" )
1666 return new TimeFieldElement( rLocalName, xAttributes, this, m_pImport );
1668 // patternfield
1669 else if ( rLocalName == "patternfield" )
1671 return new PatternFieldElement( rLocalName, xAttributes, this, m_pImport );
1673 // formattedfield
1674 else if ( rLocalName == "formattedfield" )
1676 return new FormattedFieldElement( rLocalName, xAttributes, this, m_pImport );
1678 // fixedline
1679 else if ( rLocalName == "fixedline" )
1681 return new FixedLineElement( rLocalName, xAttributes, this, m_pImport );
1683 // scrollbar
1684 else if ( rLocalName == "scrollbar" )
1686 return new ScrollBarElement( rLocalName, xAttributes, this, m_pImport );
1688 // spinbutton
1689 else if ( rLocalName == "spinbutton" )
1691 return new SpinButtonElement( rLocalName, xAttributes, this, m_pImport );
1693 // progressmeter
1694 else if ( rLocalName == "progressmeter" )
1696 return new ProgressBarElement( rLocalName, xAttributes, this, m_pImport );
1698 // table
1699 else if (rLocalName == "table")
1701 return new GridControlElement( rLocalName, xAttributes, this, m_pImport );
1703 else if ( rLocalName == "multipage" )
1705 return new MultiPage( rLocalName, xAttributes, this, m_pImport );
1707 else if ( rLocalName == "frame" )
1709 return new Frame( rLocalName, xAttributes, this, m_pImport );
1711 else if ( rLocalName == "page" )
1713 return new Page( rLocalName, xAttributes, this, m_pImport );
1715 // bulletinboard
1716 else if ( rLocalName == "bulletinboard" )
1718 return new BulletinBoardElement( rLocalName, xAttributes, this, m_pImport );
1720 else
1722 throw xml::sax::SAXException( "expected styles, bulletinboard or bulletinboard element, not: " + rLocalName, Reference< XInterface >(), Any() );
1726 BulletinBoardElement::BulletinBoardElement(
1727 OUString const & rLocalName,
1728 Reference< xml::input::XAttributes > const & xAttributes,
1729 ElementBase * pParent, DialogImport * pImport )
1730 : ControlElement( rLocalName, xAttributes, pParent, pImport ),
1731 mxDialogImport(pImport)
1733 OUString aValue( _xAttributes->getValueByUidName( m_pImport->XMLNS_DIALOGS_UID, u"left"_ustr ) );
1734 if (!aValue.isEmpty())
1736 _nBasePosX += toInt32( aValue );
1738 aValue = _xAttributes->getValueByUidName( m_pImport->XMLNS_DIALOGS_UID, u"top"_ustr );
1739 if (!aValue.isEmpty())
1741 _nBasePosY += toInt32( aValue );
1745 // style
1746 Reference< xml::input::XElement > StyleElement::startChildElement(
1747 sal_Int32 /*nUid*/, OUString const & /*rLocalName*/,
1748 Reference< xml::input::XAttributes > const & /*xAttributes*/ )
1750 throw xml::sax::SAXException( u"unexpected sub elements of style!"_ustr, Reference< XInterface >(), Any() );
1753 void StyleElement::endElement()
1755 OUString aStyleId( _xAttributes->getValueByUidName( m_pImport->XMLNS_DIALOGS_UID, u"style-id"_ustr ) );
1756 if (aStyleId.isEmpty())
1758 throw xml::sax::SAXException( u"missing style-id attribute!"_ustr, Reference< XInterface >(), Any() );
1761 m_pImport->addStyle( aStyleId, this );
1764 // styles
1765 Reference< xml::input::XElement > StylesElement::startChildElement(
1766 sal_Int32 nUid, OUString const & rLocalName,
1767 Reference< xml::input::XAttributes > const & xAttributes )
1769 if (m_pImport->XMLNS_DIALOGS_UID != nUid)
1771 throw xml::sax::SAXException( u"illegal namespace!"_ustr, Reference< XInterface >(), Any() );
1773 // style
1774 else if ( rLocalName == "style" )
1776 return new StyleElement( rLocalName, xAttributes, this, m_pImport );
1778 else
1780 throw xml::sax::SAXException( u"expected style element!"_ustr, Reference< XInterface >(), Any() );
1784 // window
1785 Reference< xml::input::XElement > WindowElement::startChildElement(
1786 sal_Int32 nUid, OUString const & rLocalName,
1787 Reference< xml::input::XAttributes > const & xAttributes )
1789 // event
1790 if (m_pImport->isEventElement( nUid, rLocalName ))
1792 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
1794 else if (m_pImport->XMLNS_DIALOGS_UID != nUid)
1796 throw xml::sax::SAXException( u"illegal namespace!"_ustr, Reference< XInterface >(), Any() );
1798 // styles
1799 else if ( rLocalName == "styles" )
1801 return new StylesElement( rLocalName, xAttributes, this, m_pImport );
1803 // bulletinboard
1804 else if ( rLocalName == "bulletinboard" )
1806 return new BulletinBoardElement( rLocalName, xAttributes, this, m_pImport );
1808 else
1810 throw xml::sax::SAXException( u"expected styles or bulletinboard element!"_ustr, Reference< XInterface >(), Any() );
1814 void WindowElement::endElement()
1816 Reference< beans::XPropertySet > xProps(
1817 m_pImport->_xDialogModel, UNO_QUERY_THROW );
1818 ImportContext ctx( m_pImport, xProps, getControlId( _xAttributes ) );
1820 Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
1821 if (xStyle.is())
1823 StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
1824 pStyle->importBackgroundColorStyle( xProps );
1825 pStyle->importTextColorStyle( xProps );
1826 pStyle->importTextLineColorStyle( xProps );
1827 pStyle->importFontStyle( xProps );
1830 ctx.importDefaults( 0, 0, _xAttributes, false );
1831 ctx.importBooleanProperty( u"Closeable"_ustr, u"closeable"_ustr, _xAttributes );
1832 ctx.importBooleanProperty( u"Moveable"_ustr, u"moveable"_ustr, _xAttributes );
1833 ctx.importBooleanProperty(u"Sizeable"_ustr, u"resizeable"_ustr, _xAttributes );
1834 ctx.importStringProperty(u"Title"_ustr, u"title"_ustr, _xAttributes );
1835 ctx.importBooleanProperty(u"Decoration"_ustr, u"withtitlebar"_ustr, _xAttributes );
1836 ctx.importGraphicOrImageProperty(u"image-src"_ustr , _xAttributes);
1837 ctx.importScollableSettings( _xAttributes );
1838 ctx.importEvents( _events );
1839 // avoid ring-reference:
1840 // vector< event elements > holding event elements holding this (via _pParent)
1841 _events.clear();
1844 // table
1845 Reference< xml::input::XElement > GridControlElement::startChildElement(
1846 sal_Int32 nUid, OUString const & rLocalName,
1847 Reference< xml::input::XAttributes > const & xAttributes )
1849 // event
1850 if (!m_pImport->isEventElement( nUid, rLocalName ))
1852 throw xml::sax::SAXException( u"expected event element!"_ustr, Reference< XInterface >(), Any() );
1855 return new EventElement( nUid, rLocalName, xAttributes, this, m_pImport );
1859 void GridControlElement::endElement()
1861 ControlImportContext ctx( m_pImport, getControlId( _xAttributes ), u"com.sun.star.awt.grid.UnoControlGridModel"_ustr);
1862 Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() );
1863 Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
1864 if (xStyle.is())
1866 StyleElement * pStyle = static_cast< StyleElement * >( xStyle.get () );
1867 pStyle->importBackgroundColorStyle( xControlModel );
1868 pStyle->importBorderStyle( xControlModel );
1869 pStyle->importTextColorStyle( xControlModel );
1870 pStyle->importTextLineColorStyle( xControlModel );
1871 pStyle->importFontStyle( xControlModel );
1873 ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
1874 ctx.importBooleanProperty( u"Tabstop"_ustr, u"tabstop"_ustr, _xAttributes );
1875 ctx.importVerticalAlignProperty( u"VerticalAlign"_ustr, u"valign"_ustr, _xAttributes );
1876 ctx.importSelectionTypeProperty( u"SelectionModel"_ustr, u"selectiontype"_ustr, _xAttributes );
1877 ctx.importBooleanProperty( u"ShowColumnHeader"_ustr, u"showcolumnheader"_ustr, _xAttributes );
1878 ctx.importBooleanProperty( u"ShowRowHeader"_ustr, u"showrowheader"_ustr, _xAttributes );
1879 ctx.importHexLongProperty( u"GridLineColor"_ustr, u"gridline-color"_ustr, _xAttributes );
1880 ctx.importBooleanProperty( u"UseGridLines"_ustr, u"usegridlines"_ustr, _xAttributes );
1881 ctx.importHexLongProperty( u"HeaderBackgroundColor"_ustr, u"headerbackground-color"_ustr, _xAttributes );
1882 ctx.importHexLongProperty( u"HeaderTextColor"_ustr, u"headertext-color"_ustr, _xAttributes );
1883 ctx.importHexLongProperty( u"ActiveSelectionBackgroundColor"_ustr, u"activeselectionbackground-color"_ustr, _xAttributes );
1884 ctx.importHexLongProperty( u"ActiveSelectionTextColor"_ustr, u"activeselectiontext-color"_ustr, _xAttributes );
1885 ctx.importHexLongProperty( u"InactiveSelectionBackgroundColor"_ustr, u"inactiveselectionbackground-color"_ustr, _xAttributes );
1886 ctx.importHexLongProperty( u"InactiveSelectionTextColor"_ustr, u"inactiveselectiontext-color"_ustr, _xAttributes );
1887 ctx.importEvents( _events );
1888 // avoid ring-reference:
1889 // vector< event elements > holding event elements holding this (via _pParent)
1890 _events.clear();
1892 ctx.finish();
1895 //##################################################################################################
1899 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */