1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
21 #include "exp_share.hxx"
22 #include <xmlscript/xmlns.h>
24 #include <o3tl/any.hxx>
25 #include <sal/log.hxx>
26 #include <tools/diagnose_ex.h>
28 #include <com/sun/star/awt/CharSet.hpp>
29 #include <com/sun/star/awt/FontFamily.hpp>
30 #include <com/sun/star/awt/FontPitch.hpp>
31 #include <com/sun/star/awt/FontSlant.hpp>
32 #include <com/sun/star/awt/FontStrikeout.hpp>
33 #include <com/sun/star/awt/FontType.hpp>
34 #include <com/sun/star/awt/FontUnderline.hpp>
35 #include <com/sun/star/awt/ImagePosition.hpp>
36 #include <com/sun/star/awt/ImageScaleMode.hpp>
37 #include <com/sun/star/awt/LineEndFormat.hpp>
38 #include <com/sun/star/awt/PushButtonType.hpp>
39 #include <com/sun/star/awt/VisualEffect.hpp>
40 #include <com/sun/star/util/Date.hpp>
41 #include <com/sun/star/util/Time.hpp>
42 #include <tools/date.hxx>
43 #include <tools/time.hxx>
45 #include <com/sun/star/io/XPersistObject.hpp>
47 #include <com/sun/star/script/XScriptEventsSupplier.hpp>
48 #include <com/sun/star/script/ScriptEventDescriptor.hpp>
50 #include <com/sun/star/style/VerticalAlignment.hpp>
52 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
53 #include <com/sun/star/lang/XServiceInfo.hpp>
54 #include <com/sun/star/lang/Locale.hpp>
56 #include <com/sun/star/view/SelectionType.hpp>
58 #include <com/sun/star/form/binding/XListEntrySink.hpp>
59 #include <com/sun/star/form/binding/XBindableValue.hpp>
60 #include <com/sun/star/table/CellAddress.hpp>
61 #include <com/sun/star/table/CellRangeAddress.hpp>
62 #include <com/sun/star/document/XStorageBasedDocument.hpp>
63 #include <com/sun/star/document/GraphicStorageHandler.hpp>
64 #include <com/sun/star/document/XGraphicStorageHandler.hpp>
65 #include <com/sun/star/graphic/XGraphic.hpp>
66 #include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
68 #include <comphelper/processfactory.hxx>
69 #include <i18nlangtag/languagetag.hxx>
71 using namespace ::com::sun::star
;
72 using namespace ::com::sun::star::uno
;
77 Reference
< xml::sax::XAttributeList
> Style::createElement()
79 ElementDescriptor
* pStyle
= new ElementDescriptor( XMLNS_DIALOGS_PREFIX
":style" );
82 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":style-id", _id
);
87 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":background-color", "0x" + OUString::number(_backgroundColor
,16));
93 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":text-color", "0x" + OUString::number(_textColor
,16));
99 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":textline-color", "0x" + OUString::number(_textLineColor
,16));
105 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":fill-color", "0x" + OUString::number(_fillColor
,16));
114 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":border", "none" );
117 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":border", "3d" );
120 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":border", "simple" );
122 case BORDER_SIMPLE_COLOR
: {
123 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":border", "0x" + OUString::number(_borderColor
,16));
127 SAL_WARN( "xmlscript.xmldlg", "### unexpected border value!" );
132 // visual effect (look)
135 switch (_visualEffect
)
137 case awt::VisualEffect::NONE
:
138 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":look", "none" );
140 case awt::VisualEffect::LOOK3D
:
141 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":look", "3d" );
143 case awt::VisualEffect::FLAT
:
144 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":look", "simple" );
147 SAL_WARN( "xmlscript.xmldlg", "### unexpected visual effect value!" );
155 awt::FontDescriptor def_descr
;
157 // dialog:font-name CDATA #IMPLIED
158 if (def_descr
.Name
!= _descr
.Name
)
160 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-name", _descr
.Name
);
162 // dialog:font-height %numeric; #IMPLIED
163 if (def_descr
.Height
!= _descr
.Height
)
165 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-height", OUString::number( _descr
.Height
) );
167 // dialog:font-width %numeric; #IMPLIED
168 if (def_descr
.Width
!= _descr
.Width
)
170 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-width", OUString::number( _descr
.Width
) );
172 // dialog:font-stylename CDATA #IMPLIED
173 if (def_descr
.StyleName
!= _descr
.StyleName
)
175 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-stylename", _descr
.StyleName
);
177 // dialog:font-family "(decorative|modern|roman|script|swiss|system)" #IMPLIED
178 if (def_descr
.Family
!= _descr
.Family
)
180 switch (_descr
.Family
)
182 case awt::FontFamily::DECORATIVE
:
183 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-family", "decorative" );
185 case awt::FontFamily::MODERN
:
186 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-family", "modern" );
188 case awt::FontFamily::ROMAN
:
189 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-family", "roman" );
191 case awt::FontFamily::SCRIPT
:
192 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-family", "script" );
194 case awt::FontFamily::SWISS
:
195 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-family", "swiss" );
197 case awt::FontFamily::SYSTEM
:
198 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-family", "system" );
201 SAL_WARN( "xmlscript.xmldlg", "### unexpected font-family!" );
205 // dialog:font-charset "(ansi|mac|ibmpc_437|ibmpc_850|ibmpc_860|ibmpc_861|ibmpc_863|ibmpc_865|system|symbol)" #IMPLIED
206 if (def_descr
.CharSet
!= _descr
.CharSet
)
208 switch (_descr
.CharSet
)
210 case awt::CharSet::ANSI
:
211 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-charset", "ansi" );
213 case awt::CharSet::MAC
:
214 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-charset", "mac" );
216 case awt::CharSet::IBMPC_437
:
217 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-charset", "ibmpc_437" );
219 case awt::CharSet::IBMPC_850
:
220 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-charset", "ibmpc_850" );
222 case awt::CharSet::IBMPC_860
:
223 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-charset", "ibmpc_860" );
225 case awt::CharSet::IBMPC_861
:
226 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-charset", "ibmpc_861" );
228 case awt::CharSet::IBMPC_863
:
229 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-charset", "ibmpc_863" );
231 case awt::CharSet::IBMPC_865
:
232 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-charset", "ibmpc_865" );
234 case awt::CharSet::SYSTEM
:
235 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-charset", "system" );
237 case awt::CharSet::SYMBOL
:
238 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-charset", "symbol" );
241 SAL_WARN( "xmlscript.xmldlg", "### unexpected font-charset!" );
245 // dialog:font-pitch "(fixed|variable)" #IMPLIED
246 if (def_descr
.Pitch
!= _descr
.Pitch
)
248 switch (_descr
.Pitch
)
250 case awt::FontPitch::FIXED
:
251 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-pitch", "fixed" );
253 case awt::FontPitch::VARIABLE
:
254 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-pitch", "variable" );
257 SAL_WARN( "xmlscript.xmldlg", "### unexpected font-pitch!" );
261 // dialog:font-charwidth CDATA #IMPLIED
262 if (def_descr
.CharacterWidth
!= _descr
.CharacterWidth
)
264 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-charwidth", OUString::number( _descr
.CharacterWidth
) );
266 // dialog:font-weight CDATA #IMPLIED
267 if (def_descr
.Weight
!= _descr
.Weight
)
269 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-weight", OUString::number( _descr
.Weight
) );
271 // dialog:font-slant "(oblique|italic|reverse_oblique|reverse_italic)" #IMPLIED
272 if (def_descr
.Slant
!= _descr
.Slant
)
274 switch (_descr
.Slant
)
276 case awt::FontSlant_OBLIQUE
:
277 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-slant", "oblique" );
279 case awt::FontSlant_ITALIC
:
280 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-slant", "italic" );
282 case awt::FontSlant_REVERSE_OBLIQUE
:
283 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-slant", "reverse_oblique" );
285 case awt::FontSlant_REVERSE_ITALIC
:
286 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-slant", "reverse_italic" );
289 SAL_WARN( "xmlscript.xmldlg", "### unexpected font-slant!" );
293 // dialog:font-underline "(single|double|dotted|dash|longdash|dashdot|dashdotdot|smallwave|wave|doublewave|bold|bolddotted|bolddash|boldlongdash|bolddashdot|bolddashdotdot|boldwave)" #IMPLIED
294 if (def_descr
.Underline
!= _descr
.Underline
)
296 switch (_descr
.Underline
)
298 case awt::FontUnderline::SINGLE
:
299 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "single" );
301 case awt::FontUnderline::DOUBLE
:
302 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "double" );
304 case awt::FontUnderline::DOTTED
:
305 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "dotted" );
307 case awt::FontUnderline::DASH
:
308 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "dash" );
310 case awt::FontUnderline::LONGDASH
:
311 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "longdash" );
313 case awt::FontUnderline::DASHDOT
:
314 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "dashdot" );
316 case awt::FontUnderline::DASHDOTDOT
:
317 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "dashdotdot" );
319 case awt::FontUnderline::SMALLWAVE
:
320 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "smallwave" );
322 case awt::FontUnderline::WAVE
:
323 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "wave" );
325 case awt::FontUnderline::DOUBLEWAVE
:
326 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "doublewave" );
328 case awt::FontUnderline::BOLD
:
329 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "bold" );
331 case awt::FontUnderline::BOLDDOTTED
:
332 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "bolddotted" );
334 case awt::FontUnderline::BOLDDASH
:
335 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "bolddash" );
337 case awt::FontUnderline::BOLDLONGDASH
:
338 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "boldlongdash" );
340 case awt::FontUnderline::BOLDDASHDOT
:
341 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "bolddashdot" );
343 case awt::FontUnderline::BOLDDASHDOTDOT
:
344 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "bolddashdotdot" );
346 case awt::FontUnderline::BOLDWAVE
:
347 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "boldwave" );
350 SAL_WARN( "xmlscript.xmldlg", "### unexpected font-underline!" );
354 // dialog:font-strikeout "(single|double|bold|slash|x)" #IMPLIED
355 if (def_descr
.Strikeout
!= _descr
.Strikeout
)
357 switch (_descr
.Strikeout
)
359 case awt::FontStrikeout::SINGLE
:
360 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-strikeout", "single" );
362 case awt::FontStrikeout::DOUBLE
:
363 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-strikeout", "double" );
365 case awt::FontStrikeout::BOLD
:
366 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-strikeout", "bold" );
368 case awt::FontStrikeout::SLASH
:
369 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-strikeout", "slash" );
371 case awt::FontStrikeout::X
:
372 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-strikeout", "x" );
375 SAL_WARN( "xmlscript.xmldlg", "### unexpected font-strikeout!" );
379 // dialog:font-orientation CDATA #IMPLIED
380 if (def_descr
.Orientation
!= _descr
.Orientation
)
382 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-orientation", OUString::number( _descr
.Orientation
) );
384 // dialog:font-kerning %boolean; #IMPLIED
385 if (bool(def_descr
.Kerning
) != bool(_descr
.Kerning
))
387 pStyle
->addBoolAttr( XMLNS_DIALOGS_PREFIX
":font-kerning", _descr
.Kerning
);
389 // dialog:font-wordlinemode %boolean; #IMPLIED
390 if (bool(def_descr
.WordLineMode
) != bool(_descr
.WordLineMode
))
392 pStyle
->addBoolAttr( XMLNS_DIALOGS_PREFIX
":font-wordlinemode", _descr
.WordLineMode
);
394 // dialog:font-type "(raster|device|scalable)" #IMPLIED
395 if (def_descr
.Type
!= _descr
.Type
)
399 case awt::FontType::RASTER
:
400 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-type", "raster" );
402 case awt::FontType::DEVICE
:
403 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-type", "device" );
405 case awt::FontType::SCALABLE
:
406 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-type", "scalable" );
409 SAL_WARN( "xmlscript.xmldlg", "### unexpected font-type!" );
414 // additional attributes not in FontDescriptor struct
415 // dialog:font-relief (none|embossed|engraved) #IMPLIED
418 case awt::FontRelief::NONE
: // don't export default
420 case awt::FontRelief::EMBOSSED
:
421 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-relief", "embossed" );
423 case awt::FontRelief::ENGRAVED
:
424 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-relief", "engraved" );
427 SAL_WARN( "xmlscript.xmldlg", "### unexpected font-relief!" );
430 // dialog:font-emphasismark (none|dot|circle|disc|accent|above|below) #IMPLIED
431 switch (_fontEmphasisMark
)
433 case awt::FontEmphasisMark::NONE
: // don't export default
435 case awt::FontEmphasisMark::DOT
:
436 pStyle
->addAttribute(XMLNS_DIALOGS_PREFIX
":font-emphasismark", "dot" );
438 case awt::FontEmphasisMark::CIRCLE
:
439 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-emphasismark", "circle" );
441 case awt::FontEmphasisMark::DISC
:
442 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-emphasismark", "disc" );
444 case awt::FontEmphasisMark::ACCENT
:
445 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-emphasismark", "accent" );
447 case awt::FontEmphasisMark::ABOVE
:
448 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-emphasismark", "above" );
450 case awt::FontEmphasisMark::BELOW
:
451 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-emphasismark", "below" );
454 SAL_WARN( "xmlscript.xmldlg", "### unexpected font-emphasismark!" );
462 void ElementDescriptor::addNumberFormatAttr(
463 Reference
< beans::XPropertySet
> const & xFormatProperties
)
467 OSL_VERIFY( xFormatProperties
->getPropertyValue( "FormatString" ) >>= sFormat
);
468 OSL_VERIFY( xFormatProperties
->getPropertyValue( "Locale" ) >>= locale
);
470 addAttribute(XMLNS_DIALOGS_PREFIX
":format-code", sFormat
);
473 LanguageTag
aLanguageTag( locale
);
475 if (aLanguageTag
.isIsoLocale())
477 // Old style "lll;CC" for compatibility, I really don't know what may
479 if (aLanguageTag
.getCountry().isEmpty())
480 aStr
= aLanguageTag
.getLanguage();
482 aStr
= aLanguageTag
.getLanguage() + ";" + aLanguageTag
.getCountry();
486 aStr
= aLanguageTag
.getBcp47( false);
488 addAttribute( XMLNS_DIALOGS_PREFIX
":format-locale", aStr
);
491 Any
ElementDescriptor::readProp( OUString
const & rPropName
)
493 if (beans::PropertyState_DEFAULT_VALUE
!= _xPropState
->getPropertyState( rPropName
))
495 return _xProps
->getPropertyValue( rPropName
);
500 void ElementDescriptor::readStringAttr(
501 OUString
const & rPropName
, OUString
const & rAttrName
)
503 if (beans::PropertyState_DEFAULT_VALUE
!=
504 _xPropState
->getPropertyState( rPropName
))
506 Any
a( _xProps
->getPropertyValue( rPropName
) );
509 addAttribute( rAttrName
, v
);
511 SAL_WARN( "xmlscript.xmldlg", "### unexpected property type!" );
515 void ElementDescriptor::readHexLongAttr( OUString
const & rPropName
, OUString
const & rAttrName
)
517 if (beans::PropertyState_DEFAULT_VALUE
!= _xPropState
->getPropertyState( rPropName
))
519 Any
a( _xProps
->getPropertyValue( rPropName
) );
520 if (auto n
= o3tl::tryAccess
<sal_uInt32
>(a
))
522 addAttribute( rAttrName
, "0x" + OUString::number(*n
, 16) );
527 void ElementDescriptor::readDateFormatAttr( OUString
const & rPropName
, OUString
const & rAttrName
)
529 if (beans::PropertyState_DEFAULT_VALUE
!= _xPropState
->getPropertyState( rPropName
))
531 Any
a( _xProps
->getPropertyValue( rPropName
) );
532 if (auto n
= o3tl::tryAccess
<sal_Int16
>(a
))
537 addAttribute( rAttrName
, "system_short" );
540 addAttribute( rAttrName
, "system_short_YY" );
543 addAttribute( rAttrName
, "system_short_YYYY" );
546 addAttribute( rAttrName
, "system_long" );
549 addAttribute( rAttrName
, "short_DDMMYY" );
552 addAttribute( rAttrName
, "short_MMDDYY" );
555 addAttribute( rAttrName
, "short_YYMMDD" );
558 addAttribute( rAttrName
, "short_DDMMYYYY" );
561 addAttribute( rAttrName
, "short_MMDDYYYY" );
564 addAttribute( rAttrName
, "short_YYYYMMDD" );
567 addAttribute( rAttrName
, "short_YYMMDD_DIN5008" );
570 addAttribute( rAttrName
, "short_YYYYMMDD_DIN5008" );
573 SAL_WARN( "xmlscript.xmldlg", "### unexpected date format!" );
578 OSL_FAIL( "### unexpected property type!" );
582 void ElementDescriptor::readDateAttr( OUString
const & rPropName
, OUString
const & rAttrName
)
584 if (beans::PropertyState_DEFAULT_VALUE
!= _xPropState
->getPropertyState( rPropName
))
586 Any
a( _xProps
->getPropertyValue( rPropName
) );
587 if (a
.getValueTypeClass() == TypeClass_STRUCT
&& a
.getValueType() == cppu::UnoType
<util::Date
>::get())
592 ::Date
aTDate(aUDate
);
593 addAttribute( rAttrName
, OUString::number( aTDate
.GetDate() ) );
596 OSL_FAIL( "### internal error" );
599 OSL_FAIL( "### unexpected property type!" );
603 void ElementDescriptor::readTimeAttr( OUString
const & rPropName
, OUString
const & rAttrName
)
605 if (beans::PropertyState_DEFAULT_VALUE
!= _xPropState
->getPropertyState( rPropName
))
607 Any
a( _xProps
->getPropertyValue( rPropName
) );
608 if (a
.getValueTypeClass() == TypeClass_STRUCT
&& a
.getValueType() == cppu::UnoType
<util::Time
>::get())
613 ::tools::Time
aTTime(aUTime
);
614 addAttribute( rAttrName
, OUString::number( aTTime
.GetTime() / ::tools::Time::nanoPerCenti
) );
617 OSL_FAIL( "### internal error" );
620 OSL_FAIL( "### unexpected property type!" );
624 void ElementDescriptor::readTimeFormatAttr( OUString
const & rPropName
, OUString
const & rAttrName
)
626 if (beans::PropertyState_DEFAULT_VALUE
!= _xPropState
->getPropertyState( rPropName
))
628 Any
a( _xProps
->getPropertyValue( rPropName
) );
629 if (auto n
= o3tl::tryAccess
<sal_Int16
>(a
))
634 addAttribute( rAttrName
, "24h_short" );
637 addAttribute( rAttrName
, "24h_long" );
640 addAttribute( rAttrName
, "12h_short" );
643 addAttribute( rAttrName
, "12h_long" );
646 addAttribute( rAttrName
, "Duration_short" );
649 addAttribute( rAttrName
, "Duration_long" );
652 SAL_WARN( "xmlscript.xmldlg", "### unexpected time format!" );
657 OSL_FAIL( "### unexpected property type!" );
661 void ElementDescriptor::readAlignAttr( OUString
const & rPropName
, OUString
const & rAttrName
)
663 if (beans::PropertyState_DEFAULT_VALUE
!= _xPropState
->getPropertyState( rPropName
))
665 Any
a( _xProps
->getPropertyValue( rPropName
) );
666 if (auto n
= o3tl::tryAccess
<sal_Int16
>(a
))
671 addAttribute( rAttrName
, "left" );
674 addAttribute( rAttrName
, "center" );
677 addAttribute( rAttrName
, "right" );
680 SAL_WARN( "xmlscript.xmldlg", "### illegal alignment value!" );
685 OSL_FAIL( "### unexpected property type!" );
689 void ElementDescriptor::readVerticalAlignAttr( OUString
const & rPropName
, OUString
const & rAttrName
)
691 if (beans::PropertyState_DEFAULT_VALUE
!= _xPropState
->getPropertyState( rPropName
))
693 Any
a( _xProps
->getPropertyValue( rPropName
) );
694 if (a
.getValueTypeClass() == TypeClass_ENUM
&& a
.getValueType() == cppu::UnoType
<style::VerticalAlignment
>::get())
696 style::VerticalAlignment eAlign
;
700 case style::VerticalAlignment_TOP
:
701 addAttribute( rAttrName
, "top" );
703 case style::VerticalAlignment_MIDDLE
:
704 addAttribute( rAttrName
, "center" );
706 case style::VerticalAlignment_BOTTOM
:
707 addAttribute( rAttrName
, "bottom" );
710 SAL_WARN( "xmlscript.xmldlg", "### illegal vertical alignment value!" );
715 OSL_FAIL( "### unexpected property type!" );
719 void ElementDescriptor::readImageOrGraphicAttr(OUString
const & rAttrName
)
722 if (beans::PropertyState_DEFAULT_VALUE
!= _xPropState
->getPropertyState("Graphic"))
724 uno::Reference
<graphic::XGraphic
> xGraphic
;
725 _xProps
->getPropertyValue("Graphic") >>= xGraphic
;
728 Reference
< document::XStorageBasedDocument
> xDocStorage( _xDocument
, UNO_QUERY
);
729 if ( xDocStorage
.is() )
731 Reference
<XComponentContext
> xContext
= ::comphelper::getProcessComponentContext();
732 uno::Reference
<document::XGraphicStorageHandler
> xGraphicStorageHandler
;
733 xGraphicStorageHandler
.set(document::GraphicStorageHandler::createWithStorage(xContext
, xDocStorage
->getDocumentStorage()));
734 if (xGraphicStorageHandler
.is())
736 sURL
= xGraphicStorageHandler
->saveGraphic(xGraphic
);
741 // tdf#130793 Above fails if the dialog is not part of a document. Export the ImageURL then.
743 && beans::PropertyState_DEFAULT_VALUE
!= _xPropState
->getPropertyState("ImageURL"))
745 _xProps
->getPropertyValue("ImageURL") >>= sURL
;
748 addAttribute(rAttrName
, sURL
);
751 void ElementDescriptor::readImageAlignAttr( OUString
const & rPropName
, OUString
const & rAttrName
)
753 if (beans::PropertyState_DEFAULT_VALUE
!= _xPropState
->getPropertyState( rPropName
))
755 Any
a( _xProps
->getPropertyValue( rPropName
) );
756 if (auto n
= o3tl::tryAccess
<sal_Int16
>(a
))
761 addAttribute( rAttrName
, "left" );
764 addAttribute( rAttrName
, "top" );
767 addAttribute( rAttrName
, "right" );
770 addAttribute( rAttrName
, "bottom" );
773 SAL_WARN( "xmlscript.xmldlg", "### illegal image alignment value!" );
778 OSL_FAIL( "### unexpected property type!" );
782 void ElementDescriptor::readImagePositionAttr( OUString
const & rPropName
, OUString
const & rAttrName
)
784 if (beans::PropertyState_DEFAULT_VALUE
!= _xPropState
->getPropertyState( rPropName
))
786 Any
a( _xProps
->getPropertyValue( rPropName
) );
787 if (auto n
= o3tl::tryAccess
<sal_Int16
>(a
))
791 case awt::ImagePosition::LeftTop
:
792 addAttribute( rAttrName
, "left-top" );
794 case awt::ImagePosition::LeftCenter
:
795 addAttribute( rAttrName
, "left-center" );
797 case awt::ImagePosition::LeftBottom
:
798 addAttribute( rAttrName
, "left-bottom" );
800 case awt::ImagePosition::RightTop
:
801 addAttribute( rAttrName
, "right-top" );
803 case awt::ImagePosition::RightCenter
:
804 addAttribute( rAttrName
, "right-center" );
806 case awt::ImagePosition::RightBottom
:
807 addAttribute( rAttrName
, "right-bottom" );
809 case awt::ImagePosition::AboveLeft
:
810 addAttribute( rAttrName
, "top-left" );
812 case awt::ImagePosition::AboveCenter
:
813 addAttribute( rAttrName
, "top-center" );
815 case awt::ImagePosition::AboveRight
:
816 addAttribute( rAttrName
, "top-right" );
818 case awt::ImagePosition::BelowLeft
:
819 addAttribute( rAttrName
, "bottom-left" );
821 case awt::ImagePosition::BelowCenter
:
822 addAttribute( rAttrName
, "bottom-center" );
824 case awt::ImagePosition::BelowRight
:
825 addAttribute( rAttrName
, "bottom-right" );
827 case awt::ImagePosition::Centered
:
828 addAttribute( rAttrName
, "center" );
831 SAL_WARN( "xmlscript.xmldlg", "### illegal image position value!" );
838 void ElementDescriptor::readButtonTypeAttr( OUString
const & rPropName
, OUString
const & rAttrName
)
840 if (beans::PropertyState_DEFAULT_VALUE
!= _xPropState
->getPropertyState( rPropName
))
842 Any
a( _xProps
->getPropertyValue( rPropName
) );
843 if (auto n
= o3tl::tryAccess
<sal_Int16
>(a
))
845 switch (static_cast<awt::PushButtonType
>(*n
))
847 case awt::PushButtonType_STANDARD
:
848 addAttribute( rAttrName
, "standard" );
850 case awt::PushButtonType_OK
:
851 addAttribute( rAttrName
, "ok" );
853 case awt::PushButtonType_CANCEL
:
854 addAttribute( rAttrName
, "cancel" );
856 case awt::PushButtonType_HELP
:
857 addAttribute( rAttrName
, "help" );
860 SAL_WARN( "xmlscript.xmldlg", "### illegal button-type value!" );
867 void ElementDescriptor::readOrientationAttr( OUString
const & rPropName
, OUString
const & rAttrName
)
869 if (beans::PropertyState_DEFAULT_VALUE
!= _xPropState
->getPropertyState( rPropName
))
871 Any
a( _xProps
->getPropertyValue( rPropName
) );
872 if (auto n
= o3tl::tryAccess
<sal_Int32
>(a
))
877 addAttribute( rAttrName
, "horizontal" );
880 addAttribute( rAttrName
, "vertical" );
883 SAL_WARN( "xmlscript.xmldlg", "### illegal orientation value!" );
890 void ElementDescriptor::readLineEndFormatAttr( OUString
const & rPropName
, OUString
const & rAttrName
)
892 if (beans::PropertyState_DEFAULT_VALUE
!= _xPropState
->getPropertyState( rPropName
))
894 Any
a( _xProps
->getPropertyValue( rPropName
) );
895 if (auto n
= o3tl::tryAccess
<sal_Int16
>(a
))
899 case awt::LineEndFormat::CARRIAGE_RETURN
:
900 addAttribute( rAttrName
, "carriage-return" );
902 case awt::LineEndFormat::LINE_FEED
:
903 addAttribute( rAttrName
, "line-feed" );
905 case awt::LineEndFormat::CARRIAGE_RETURN_LINE_FEED
:
906 addAttribute( rAttrName
, "carriage-return-line-feed" );
909 SAL_WARN( "xmlscript.xmldlg", "### illegal line end format value!" );
916 void ElementDescriptor::readDataAwareAttr( OUString
const & rAttrName
)
918 Reference
< lang::XMultiServiceFactory
> xFac
;
919 if ( _xDocument
.is() )
920 xFac
.set( _xDocument
, uno::UNO_QUERY
);
922 Reference
< form::binding::XBindableValue
> xBinding( _xProps
, UNO_QUERY
);
924 if ( xFac
.is() && xBinding
.is() && rAttrName
== XMLNS_DIALOGS_PREFIX
":linked-cell" )
928 Reference
< beans::XPropertySet
> xConvertor( xFac
->createInstance( "com.sun.star.table.CellAddressConversion" ), uno::UNO_QUERY
);
929 Reference
< beans::XPropertySet
> xBindable( xBinding
->getValueBinding(), UNO_QUERY
);
930 if ( xBindable
.is() )
932 table::CellAddress aAddress
;
933 xBindable
->getPropertyValue( "BoundCell" ) >>= aAddress
;
934 xConvertor
->setPropertyValue( "Address", makeAny( aAddress
) );
936 xConvertor
->getPropertyValue( "PersistentRepresentation" ) >>= sAddress
;
937 if ( !sAddress
.isEmpty() )
938 addAttribute( rAttrName
, sAddress
);
940 SAL_INFO("xmlscript.xmldlg", "*** Bindable value " << sAddress
);
944 catch( uno::Exception
& )
948 Reference
< form::binding::XListEntrySink
> xEntrySink( _xProps
, UNO_QUERY
);
949 if ( xEntrySink
.is() && rAttrName
== XMLNS_DIALOGS_PREFIX
":source-cell-range" )
951 Reference
< beans::XPropertySet
> xListSource( xEntrySink
->getListEntrySource(), UNO_QUERY
);
952 if ( xListSource
.is() )
956 Reference
< beans::XPropertySet
> xConvertor( xFac
->createInstance( "com.sun.star.table.CellRangeAddressConversion" ), uno::UNO_QUERY
);
958 table::CellRangeAddress aAddress
;
959 xListSource
->getPropertyValue( "CellRange" ) >>= aAddress
;
962 xConvertor
->setPropertyValue( "Address", makeAny( aAddress
) );
963 xConvertor
->getPropertyValue( "PersistentRepresentation" ) >>= sAddress
;
964 SAL_INFO("xmlscript.xmldlg","**** cell range source list " << sAddress
);
965 if ( !sAddress
.isEmpty() )
966 addAttribute( rAttrName
, sAddress
);
968 catch( uno::Exception
& )
975 void ElementDescriptor::readSelectionTypeAttr( OUString
const & rPropName
, OUString
const & rAttrName
)
977 if (beans::PropertyState_DEFAULT_VALUE
!= _xPropState
->getPropertyState( rPropName
))
979 Any
aSelectionType ( _xProps
->getPropertyValue( rPropName
) );
981 if (aSelectionType
.getValueTypeClass() == TypeClass_ENUM
&& aSelectionType
.getValueType() == cppu::UnoType
<view::SelectionType
>::get())
983 ::view::SelectionType eSelectionType
;
984 aSelectionType
>>= eSelectionType
;
986 switch (eSelectionType
)
988 case ::view::SelectionType_NONE
:
989 addAttribute( rAttrName
, "none" );
991 case ::view::SelectionType_SINGLE
:
992 addAttribute( rAttrName
, "single" );
994 case ::view::SelectionType_MULTI
:
995 addAttribute( rAttrName
, "multi" );
997 case ::view::SelectionType_RANGE
:
998 addAttribute( rAttrName
, "range" );
1001 SAL_WARN( "xmlscript.xmldlg", "### illegal selection type value!" );
1008 void ElementDescriptor::readScrollableSettings()
1010 readLongAttr( "ScrollHeight",
1011 XMLNS_DIALOGS_PREFIX
":scrollheight" );
1012 readLongAttr( "ScrollWidth",
1013 XMLNS_DIALOGS_PREFIX
":scrollwidth" );
1014 readLongAttr( "ScrollTop",
1015 XMLNS_DIALOGS_PREFIX
":scrolltop" );
1016 readLongAttr( "ScrollLeft",
1017 XMLNS_DIALOGS_PREFIX
":scrollleft" );
1018 readBoolAttr( "HScroll",
1019 XMLNS_DIALOGS_PREFIX
":hscroll" );
1020 readBoolAttr( "VScroll",
1021 XMLNS_DIALOGS_PREFIX
":vscroll" );
1024 void ElementDescriptor::readImageScaleModeAttr( OUString
const & rPropName
, OUString
const & rAttrName
)
1026 if (beans::PropertyState_DEFAULT_VALUE
!= _xPropState
->getPropertyState( rPropName
))
1028 Any
aImageScaleMode( _xProps
->getPropertyValue( rPropName
) );
1030 if (aImageScaleMode
.getValueTypeClass() == TypeClass_SHORT
)
1032 sal_Int16 nImageScaleMode
= 0;
1033 aImageScaleMode
>>= nImageScaleMode
;
1035 switch(nImageScaleMode
)
1037 case ::awt::ImageScaleMode::NONE
:
1038 addAttribute( rAttrName
, "none" );
1040 case ::awt::ImageScaleMode::ISOTROPIC
:
1041 addAttribute( rAttrName
, "isotropic" );
1043 case ::awt::ImageScaleMode::ANISOTROPIC
:
1044 addAttribute( rAttrName
, "anisotropic" );
1047 OSL_ENSURE( false, "### illegal image scale mode value.");
1054 void ElementDescriptor::readDefaults( bool supportPrintable
, bool supportVisible
)
1056 Any
a( _xProps
->getPropertyValue( "Name" ) );
1058 // The following is a hack to allow 'form' controls to override the default
1059 // control supported by dialogs. This should work well for both VBA support and
1060 // normal LibreOffice (when normal 'Dialogs' decide to support form control models)
1061 // In the future VBA support might require custom models ( and not the just the form
1062 // variant of a control that we currently use ) In this case the door is still open,
1063 // we just need to define a new way for the 'ServiceName' to be extracted from the
1064 // incoming model. E.g. the use of supporting service
1065 // "com.sun.star.form.FormComponent", 'ServiceName' and XPersistObject
1066 // is only an implementation detail here, in the future some other
1067 // method (perhaps a custom prop) could be used instead.
1068 Reference
< lang::XServiceInfo
> xSrvInfo( _xProps
, UNO_QUERY
);
1069 if ( xSrvInfo
.is() && xSrvInfo
->supportsService( "com.sun.star.form.FormComponent" ) )
1071 Reference
< io::XPersistObject
> xPersist( _xProps
, UNO_QUERY
);
1072 if ( xPersist
.is() )
1074 OUString sCtrlName
= xPersist
->getServiceName();
1075 if ( !sCtrlName
.isEmpty() )
1076 addAttribute( XMLNS_DIALOGS_PREFIX
":control-implementation", sCtrlName
);
1079 addAttribute( XMLNS_DIALOGS_PREFIX
":id", *o3tl::doAccess
<OUString
>(a
) );
1080 readShortAttr( "TabIndex", XMLNS_DIALOGS_PREFIX
":tab-index" );
1082 bool bEnabled
= false;
1083 if (_xProps
->getPropertyValue( "Enabled" ) >>= bEnabled
)
1087 addAttribute( XMLNS_DIALOGS_PREFIX
":disabled", "true" );
1092 SAL_WARN( "xmlscript.xmldlg", "unexpected property type for \"Enabled\": not bool!" );
1095 if (supportVisible
) try
1097 bool bVisible
= true;
1098 if (_xProps
->getPropertyValue("EnableVisible" ) >>= bVisible
)
1101 // only write out the non default case
1104 addAttribute( XMLNS_DIALOGS_PREFIX
":visible", "false" );
1110 DBG_UNHANDLED_EXCEPTION("xmlscript.xmldlg");
1112 // force writing of pos/size
1113 a
= _xProps
->getPropertyValue( "PositionX" );
1114 if (auto n
= o3tl::tryAccess
<sal_Int32
>(a
))
1116 addAttribute( XMLNS_DIALOGS_PREFIX
":left", OUString::number(*n
) );
1118 a
= _xProps
->getPropertyValue( "PositionY" );
1119 if (auto n
= o3tl::tryAccess
<sal_Int32
>(a
))
1121 addAttribute( XMLNS_DIALOGS_PREFIX
":top", OUString::number(*n
) );
1123 a
= _xProps
->getPropertyValue( "Width" );
1124 if (auto n
= o3tl::tryAccess
<sal_Int32
>(a
))
1126 addAttribute( XMLNS_DIALOGS_PREFIX
":width", OUString::number(*n
) );
1128 a
= _xProps
->getPropertyValue( "Height" );
1129 if (auto n
= o3tl::tryAccess
<sal_Int32
>(a
))
1131 addAttribute( XMLNS_DIALOGS_PREFIX
":height", OUString::number(*n
) );
1134 if (supportPrintable
)
1136 readBoolAttr( "Printable", XMLNS_DIALOGS_PREFIX
":printable" );
1138 readLongAttr( "Step", XMLNS_DIALOGS_PREFIX
":page" );
1139 readStringAttr( "Tag", XMLNS_DIALOGS_PREFIX
":tag" );
1140 readStringAttr( "HelpText", XMLNS_DIALOGS_PREFIX
":help-text" );
1141 readStringAttr( "HelpURL", XMLNS_DIALOGS_PREFIX
":help-url" );
1144 void ElementDescriptor::readEvents()
1146 Reference
< script::XScriptEventsSupplier
> xSupplier( _xProps
, UNO_QUERY
);
1149 Reference
< container::XNameContainer
> xEvents( xSupplier
->getEvents() );
1152 const Sequence
< OUString
> aNames( xEvents
->getElementNames() );
1153 for ( const auto& rName
: aNames
)
1155 script::ScriptEventDescriptor descr
;
1156 if (xEvents
->getByName( rName
) >>= descr
)
1158 SAL_WARN_IF( descr
.ListenerType
.isEmpty() ||
1159 descr
.EventMethod
.isEmpty() ||
1160 descr
.ScriptCode
.isEmpty() ||
1161 descr
.ScriptType
.isEmpty() , "xmlscript.xmldlg", "### invalid event descr!" );
1163 OUString aEventName
;
1165 if (descr
.AddListenerParam
.isEmpty())
1167 // detection of event-name
1168 OString
listenerType( OUStringToOString( descr
.ListenerType
, RTL_TEXTENCODING_ASCII_US
) );
1169 OString
eventMethod( OUStringToOString( descr
.EventMethod
, RTL_TEXTENCODING_ASCII_US
) );
1170 StringTriple
const * p
= g_pEventTranslations
;
1173 if (0 == ::rtl_str_compare( p
->second
, eventMethod
.getStr() ) &&
1174 0 == ::rtl_str_compare( p
->first
, listenerType
.getStr() ))
1176 aEventName
= OUString( p
->third
, ::rtl_str_getLength( p
->third
), RTL_TEXTENCODING_ASCII_US
);
1183 ElementDescriptor
* pElem
;
1184 Reference
< xml::sax::XAttributeList
> xElem
;
1186 if (!aEventName
.isEmpty()) // script:event
1188 pElem
= new ElementDescriptor( XMLNS_SCRIPT_PREFIX
":event" );
1191 pElem
->addAttribute( XMLNS_SCRIPT_PREFIX
":event-name", aEventName
);
1193 else // script:listener-event
1195 pElem
= new ElementDescriptor( XMLNS_SCRIPT_PREFIX
":listener-event" );
1198 pElem
->addAttribute( XMLNS_SCRIPT_PREFIX
":listener-type", descr
.ListenerType
);
1199 pElem
->addAttribute( XMLNS_SCRIPT_PREFIX
":listener-method", descr
.EventMethod
);
1201 if (!descr
.AddListenerParam
.isEmpty())
1203 pElem
->addAttribute( XMLNS_SCRIPT_PREFIX
":listener-param", descr
.AddListenerParam
);
1206 if ( descr
.ScriptType
== "StarBasic" )
1208 // separate optional location
1209 sal_Int32 nIndex
= descr
.ScriptCode
.indexOf( ':' );
1212 pElem
->addAttribute( XMLNS_SCRIPT_PREFIX
":location", descr
.ScriptCode
.copy( 0, nIndex
) );
1213 pElem
->addAttribute( XMLNS_SCRIPT_PREFIX
":macro-name", descr
.ScriptCode
.copy( nIndex
+1 ) );
1217 pElem
->addAttribute( XMLNS_SCRIPT_PREFIX
":macro-name", descr
.ScriptCode
);
1222 pElem
->addAttribute(XMLNS_SCRIPT_PREFIX
":macro-name", descr
.ScriptCode
);
1226 pElem
->addAttribute( XMLNS_SCRIPT_PREFIX
":language", descr
.ScriptType
);
1228 addSubElement( xElem
);
1232 SAL_WARN( "xmlscript.xmldlg", "### unexpected event type in container!" );
1239 static bool equalFont( Style
const & style1
, Style
const & style2
)
1241 awt::FontDescriptor
const & f1
= style1
._descr
;
1242 awt::FontDescriptor
const & f2
= style2
._descr
;
1244 f1
.Name
== f2
.Name
&&
1245 f1
.Height
== f2
.Height
&&
1246 f1
.Width
== f2
.Width
&&
1247 f1
.StyleName
== f2
.StyleName
&&
1248 f1
.Family
== f2
.Family
&&
1249 f1
.CharSet
== f2
.CharSet
&&
1250 f1
.Pitch
== f2
.Pitch
&&
1251 f1
.CharacterWidth
== f2
.CharacterWidth
&&
1252 f1
.Weight
== f2
.Weight
&&
1253 f1
.Slant
== f2
.Slant
&&
1254 f1
.Underline
== f2
.Underline
&&
1255 f1
.Strikeout
== f2
.Strikeout
&&
1256 f1
.Orientation
== f2
.Orientation
&&
1257 bool(f1
.Kerning
) == bool(f2
.Kerning
) &&
1258 bool(f1
.WordLineMode
) == bool(f2
.WordLineMode
) &&
1259 f1
.Type
== f2
.Type
&&
1260 style1
._fontRelief
== style2
._fontRelief
&&
1261 style1
._fontEmphasisMark
== style2
._fontEmphasisMark
1265 OUString
StyleBag::getStyleId( Style
const & rStyle
)
1267 if (! rStyle
._set
) // nothing set
1269 return OUString(); // everything default: no need to export a specific style
1272 // lookup existing style
1273 for (auto const & pStyle
: _styles
)
1275 short demanded_defaults
= ~rStyle
._set
& rStyle
._all
;
1276 // test, if defaults are not set
1277 if ((~pStyle
->_set
& demanded_defaults
) == demanded_defaults
&&
1278 (rStyle
._set
& (pStyle
->_all
& ~pStyle
->_set
)) == 0)
1280 short bset
= rStyle
._set
& pStyle
->_set
;
1282 rStyle
._backgroundColor
!= pStyle
->_backgroundColor
)
1285 rStyle
._textColor
!= pStyle
->_textColor
)
1287 if ((bset
& 0x20) &&
1288 rStyle
._textLineColor
!= pStyle
->_textLineColor
)
1290 if ((bset
& 0x10) &&
1291 rStyle
._fillColor
!= pStyle
->_fillColor
)
1294 (rStyle
._border
!= pStyle
->_border
||
1295 (rStyle
._border
== BORDER_SIMPLE_COLOR
&&
1296 rStyle
._borderColor
!= pStyle
->_borderColor
)))
1299 !equalFont( rStyle
, *pStyle
))
1301 if ((bset
& 0x40) &&
1302 rStyle
._visualEffect
!= pStyle
->_visualEffect
)
1306 short bnset
= rStyle
._set
& ~pStyle
->_set
;
1308 pStyle
->_backgroundColor
= rStyle
._backgroundColor
;
1310 pStyle
->_textColor
= rStyle
._textColor
;
1312 pStyle
->_textLineColor
= rStyle
._textLineColor
;
1314 pStyle
->_fillColor
= rStyle
._fillColor
;
1316 pStyle
->_border
= rStyle
._border
;
1317 pStyle
->_borderColor
= rStyle
._borderColor
;
1320 pStyle
->_descr
= rStyle
._descr
;
1321 pStyle
->_fontRelief
= rStyle
._fontRelief
;
1322 pStyle
->_fontEmphasisMark
= rStyle
._fontEmphasisMark
;
1325 pStyle
->_visualEffect
= rStyle
._visualEffect
;
1327 pStyle
->_all
|= rStyle
._all
;
1328 pStyle
->_set
|= rStyle
._set
;
1334 // no appr style found, append new
1335 std::unique_ptr
<Style
> pStyle(new Style( rStyle
));
1336 pStyle
->_id
= OUString::number( _styles
.size() );
1337 _styles
.push_back( std::move(pStyle
) );
1338 return _styles
.back()->_id
;
1341 StyleBag::~StyleBag()
1345 void StyleBag::dump( Reference
< xml::sax::XExtendedDocumentHandler
> const & xOut
)
1347 if (! _styles
.empty())
1349 OUString
aStylesName( XMLNS_DIALOGS_PREFIX
":styles" );
1350 xOut
->ignorableWhitespace( OUString() );
1351 xOut
->startElement( aStylesName
, Reference
< xml::sax::XAttributeList
>() );
1353 for (auto const & _style
: _styles
)
1355 Reference
< xml::sax::XAttributeList
> xAttr( _style
->createElement() );
1356 static_cast< ElementDescriptor
* >( xAttr
.get() )->dump( xOut
.get() );
1358 xOut
->ignorableWhitespace( OUString() );
1359 xOut
->endElement( aStylesName
);
1363 void exportDialogModel(
1364 Reference
< xml::sax::XExtendedDocumentHandler
> const & xOut
,
1365 Reference
< container::XNameContainer
> const & xDialogModel
,
1366 Reference
< frame::XModel
> const & xDocument
)
1368 StyleBag all_styles
;
1370 Reference
< beans::XPropertySet
> xProps( xDialogModel
, UNO_QUERY
);
1371 OSL_ASSERT( xProps
.is() );
1372 Reference
< beans::XPropertyState
> xPropState( xProps
, UNO_QUERY
);
1373 OSL_ASSERT( xPropState
.is() );
1375 ElementDescriptor
* pElem
= new ElementDescriptor( xProps
, xPropState
, XMLNS_DIALOGS_PREFIX
":bulletinboard", xDocument
);
1376 Reference
< xml::sax::XAttributeList
> xElem( pElem
);
1377 pElem
->readBullitinBoard( &all_styles
);
1379 xOut
->startDocument();
1382 "<!DOCTYPE dlg:window PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\""
1383 " \"dialog.dtd\">" );
1384 xOut
->ignorableWhitespace( OUString() );
1386 OUString
aWindowName( XMLNS_DIALOGS_PREFIX
":window" );
1387 ElementDescriptor
* pWindow
= new ElementDescriptor( xProps
, xPropState
, aWindowName
, xDocument
);
1388 Reference
< xml::sax::XAttributeList
> xWindow( pWindow
);
1389 pWindow
->readDialogModel( &all_styles
);
1390 xOut
->ignorableWhitespace( OUString() );
1391 xOut
->startElement( aWindowName
, xWindow
);
1393 pWindow
->dumpSubElements( xOut
.get() );
1394 // dump out stylebag
1395 all_styles
.dump( xOut
);
1397 if ( xDialogModel
->getElementNames().hasElements() )
1399 // open up bulletinboard
1400 OUString
aBBoardName( XMLNS_DIALOGS_PREFIX
":bulletinboard" );
1401 xOut
->ignorableWhitespace( OUString() );
1402 xOut
->startElement( aBBoardName
, xElem
);
1404 pElem
->dumpSubElements( xOut
.get() );
1405 // end bulletinboard
1406 xOut
->ignorableWhitespace( OUString() );
1407 xOut
->endElement( aBBoardName
);
1411 xOut
->ignorableWhitespace( OUString() );
1412 xOut
->endElement( aWindowName
);
1414 xOut
->endDocument();
1419 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */