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/frame/XModel.hpp>
41 #include <com/sun/star/util/Date.hpp>
42 #include <com/sun/star/util/Time.hpp>
43 #include <tools/date.hxx>
44 #include <tools/time.hxx>
46 #include <com/sun/star/io/XPersistObject.hpp>
48 #include <com/sun/star/script/XScriptEventsSupplier.hpp>
49 #include <com/sun/star/script/ScriptEventDescriptor.hpp>
51 #include <com/sun/star/style/VerticalAlignment.hpp>
53 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
54 #include <com/sun/star/lang/XServiceInfo.hpp>
55 #include <com/sun/star/lang/Locale.hpp>
57 #include <com/sun/star/view/SelectionType.hpp>
59 #include <com/sun/star/form/binding/XListEntrySink.hpp>
60 #include <com/sun/star/form/binding/XBindableValue.hpp>
61 #include <com/sun/star/table/CellAddress.hpp>
62 #include <com/sun/star/table/CellRangeAddress.hpp>
63 #include <com/sun/star/document/XStorageBasedDocument.hpp>
64 #include <com/sun/star/document/GraphicStorageHandler.hpp>
65 #include <com/sun/star/document/XGraphicStorageHandler.hpp>
66 #include <com/sun/star/graphic/XGraphic.hpp>
67 #include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
69 #include <comphelper/processfactory.hxx>
70 #include <i18nlangtag/languagetag.hxx>
72 using namespace ::com::sun::star
;
73 using namespace ::com::sun::star::uno
;
78 Reference
< xml::sax::XAttributeList
> Style::createElement()
80 ElementDescriptor
* pStyle
= new ElementDescriptor( XMLNS_DIALOGS_PREFIX
":style" );
83 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":style-id", _id
);
88 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":background-color", "0x" + OUString::number(_backgroundColor
,16));
94 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":text-color", "0x" + OUString::number(_textColor
,16));
100 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":textline-color", "0x" + OUString::number(_textLineColor
,16));
106 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":fill-color", "0x" + OUString::number(_fillColor
,16));
115 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":border", "none" );
118 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":border", "3d" );
121 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":border", "simple" );
123 case BORDER_SIMPLE_COLOR
: {
124 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":border", "0x" + OUString::number(_borderColor
,16));
128 SAL_WARN( "xmlscript.xmldlg", "### unexpected border value!" );
133 // visual effect (look)
136 switch (_visualEffect
)
138 case awt::VisualEffect::NONE
:
139 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":look", "none" );
141 case awt::VisualEffect::LOOK3D
:
142 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":look", "3d" );
144 case awt::VisualEffect::FLAT
:
145 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":look", "simple" );
148 SAL_WARN( "xmlscript.xmldlg", "### unexpected visual effect value!" );
156 awt::FontDescriptor def_descr
;
158 // dialog:font-name CDATA #IMPLIED
159 if (def_descr
.Name
!= _descr
.Name
)
161 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-name", _descr
.Name
);
163 // dialog:font-height %numeric; #IMPLIED
164 if (def_descr
.Height
!= _descr
.Height
)
166 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-height", OUString::number( _descr
.Height
) );
168 // dialog:font-width %numeric; #IMPLIED
169 if (def_descr
.Width
!= _descr
.Width
)
171 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-width", OUString::number( _descr
.Width
) );
173 // dialog:font-stylename CDATA #IMPLIED
174 if (def_descr
.StyleName
!= _descr
.StyleName
)
176 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-stylename", _descr
.StyleName
);
178 // dialog:font-family "(decorative|modern|roman|script|swiss|system)" #IMPLIED
179 if (def_descr
.Family
!= _descr
.Family
)
181 switch (_descr
.Family
)
183 case awt::FontFamily::DECORATIVE
:
184 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-family", "decorative" );
186 case awt::FontFamily::MODERN
:
187 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-family", "modern" );
189 case awt::FontFamily::ROMAN
:
190 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-family", "roman" );
192 case awt::FontFamily::SCRIPT
:
193 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-family", "script" );
195 case awt::FontFamily::SWISS
:
196 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-family", "swiss" );
198 case awt::FontFamily::SYSTEM
:
199 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-family", "system" );
202 SAL_WARN( "xmlscript.xmldlg", "### unexpected font-family!" );
206 // dialog:font-charset "(ansi|mac|ibmpc_437|ibmpc_850|ibmpc_860|ibmpc_861|ibmpc_863|ibmpc_865|system|symbol)" #IMPLIED
207 if (def_descr
.CharSet
!= _descr
.CharSet
)
209 switch (_descr
.CharSet
)
211 case awt::CharSet::ANSI
:
212 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-charset", "ansi" );
214 case awt::CharSet::MAC
:
215 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-charset", "mac" );
217 case awt::CharSet::IBMPC_437
:
218 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-charset", "ibmpc_437" );
220 case awt::CharSet::IBMPC_850
:
221 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-charset", "ibmpc_850" );
223 case awt::CharSet::IBMPC_860
:
224 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-charset", "ibmpc_860" );
226 case awt::CharSet::IBMPC_861
:
227 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-charset", "ibmpc_861" );
229 case awt::CharSet::IBMPC_863
:
230 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-charset", "ibmpc_863" );
232 case awt::CharSet::IBMPC_865
:
233 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-charset", "ibmpc_865" );
235 case awt::CharSet::SYSTEM
:
236 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-charset", "system" );
238 case awt::CharSet::SYMBOL
:
239 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-charset", "symbol" );
242 SAL_WARN( "xmlscript.xmldlg", "### unexpected font-charset!" );
246 // dialog:font-pitch "(fixed|variable)" #IMPLIED
247 if (def_descr
.Pitch
!= _descr
.Pitch
)
249 switch (_descr
.Pitch
)
251 case awt::FontPitch::FIXED
:
252 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-pitch", "fixed" );
254 case awt::FontPitch::VARIABLE
:
255 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-pitch", "variable" );
258 SAL_WARN( "xmlscript.xmldlg", "### unexpected font-pitch!" );
262 // dialog:font-charwidth CDATA #IMPLIED
263 if (def_descr
.CharacterWidth
!= _descr
.CharacterWidth
)
265 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-charwidth", OUString::number( _descr
.CharacterWidth
) );
267 // dialog:font-weight CDATA #IMPLIED
268 if (def_descr
.Weight
!= _descr
.Weight
)
270 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-weight", OUString::number( _descr
.Weight
) );
272 // dialog:font-slant "(oblique|italic|reverse_oblique|reverse_italic)" #IMPLIED
273 if (def_descr
.Slant
!= _descr
.Slant
)
275 switch (_descr
.Slant
)
277 case awt::FontSlant_OBLIQUE
:
278 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-slant", "oblique" );
280 case awt::FontSlant_ITALIC
:
281 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-slant", "italic" );
283 case awt::FontSlant_REVERSE_OBLIQUE
:
284 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-slant", "reverse_oblique" );
286 case awt::FontSlant_REVERSE_ITALIC
:
287 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-slant", "reverse_italic" );
290 SAL_WARN( "xmlscript.xmldlg", "### unexpected font-slant!" );
294 // dialog:font-underline "(single|double|dotted|dash|longdash|dashdot|dashdotdot|smallwave|wave|doublewave|bold|bolddotted|bolddash|boldlongdash|bolddashdot|bolddashdotdot|boldwave)" #IMPLIED
295 if (def_descr
.Underline
!= _descr
.Underline
)
297 switch (_descr
.Underline
)
299 case awt::FontUnderline::SINGLE
:
300 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "single" );
302 case awt::FontUnderline::DOUBLE
:
303 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "double" );
305 case awt::FontUnderline::DOTTED
:
306 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "dotted" );
308 case awt::FontUnderline::DASH
:
309 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "dash" );
311 case awt::FontUnderline::LONGDASH
:
312 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "longdash" );
314 case awt::FontUnderline::DASHDOT
:
315 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "dashdot" );
317 case awt::FontUnderline::DASHDOTDOT
:
318 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "dashdotdot" );
320 case awt::FontUnderline::SMALLWAVE
:
321 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "smallwave" );
323 case awt::FontUnderline::WAVE
:
324 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "wave" );
326 case awt::FontUnderline::DOUBLEWAVE
:
327 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "doublewave" );
329 case awt::FontUnderline::BOLD
:
330 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "bold" );
332 case awt::FontUnderline::BOLDDOTTED
:
333 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "bolddotted" );
335 case awt::FontUnderline::BOLDDASH
:
336 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "bolddash" );
338 case awt::FontUnderline::BOLDLONGDASH
:
339 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "boldlongdash" );
341 case awt::FontUnderline::BOLDDASHDOT
:
342 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "bolddashdot" );
344 case awt::FontUnderline::BOLDDASHDOTDOT
:
345 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "bolddashdotdot" );
347 case awt::FontUnderline::BOLDWAVE
:
348 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "boldwave" );
351 SAL_WARN( "xmlscript.xmldlg", "### unexpected font-underline!" );
355 // dialog:font-strikeout "(single|double|bold|slash|x)" #IMPLIED
356 if (def_descr
.Strikeout
!= _descr
.Strikeout
)
358 switch (_descr
.Strikeout
)
360 case awt::FontStrikeout::SINGLE
:
361 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-strikeout", "single" );
363 case awt::FontStrikeout::DOUBLE
:
364 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-strikeout", "double" );
366 case awt::FontStrikeout::BOLD
:
367 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-strikeout", "bold" );
369 case awt::FontStrikeout::SLASH
:
370 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-strikeout", "slash" );
372 case awt::FontStrikeout::X
:
373 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-strikeout", "x" );
376 SAL_WARN( "xmlscript.xmldlg", "### unexpected font-strikeout!" );
380 // dialog:font-orientation CDATA #IMPLIED
381 if (def_descr
.Orientation
!= _descr
.Orientation
)
383 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-orientation", OUString::number( _descr
.Orientation
) );
385 // dialog:font-kerning %boolean; #IMPLIED
386 if (bool(def_descr
.Kerning
) != bool(_descr
.Kerning
))
388 pStyle
->addBoolAttr( XMLNS_DIALOGS_PREFIX
":font-kerning", _descr
.Kerning
);
390 // dialog:font-wordlinemode %boolean; #IMPLIED
391 if (bool(def_descr
.WordLineMode
) != bool(_descr
.WordLineMode
))
393 pStyle
->addBoolAttr( XMLNS_DIALOGS_PREFIX
":font-wordlinemode", _descr
.WordLineMode
);
395 // dialog:font-type "(raster|device|scalable)" #IMPLIED
396 if (def_descr
.Type
!= _descr
.Type
)
400 case awt::FontType::RASTER
:
401 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-type", "raster" );
403 case awt::FontType::DEVICE
:
404 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-type", "device" );
406 case awt::FontType::SCALABLE
:
407 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-type", "scalable" );
410 SAL_WARN( "xmlscript.xmldlg", "### unexpected font-type!" );
415 // additional attributes not in FontDescriptor struct
416 // dialog:font-relief (none|embossed|engraved) #IMPLIED
419 case awt::FontRelief::NONE
: // don't export default
421 case awt::FontRelief::EMBOSSED
:
422 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-relief", "embossed" );
424 case awt::FontRelief::ENGRAVED
:
425 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-relief", "engraved" );
428 SAL_WARN( "xmlscript.xmldlg", "### unexpected font-relief!" );
431 // dialog:font-emphasismark (none|dot|circle|disc|accent|above|below) #IMPLIED
432 switch (_fontEmphasisMark
)
434 case awt::FontEmphasisMark::NONE
: // don't export default
436 case awt::FontEmphasisMark::DOT
:
437 pStyle
->addAttribute(XMLNS_DIALOGS_PREFIX
":font-emphasismark", "dot" );
439 case awt::FontEmphasisMark::CIRCLE
:
440 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-emphasismark", "circle" );
442 case awt::FontEmphasisMark::DISC
:
443 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-emphasismark", "disc" );
445 case awt::FontEmphasisMark::ACCENT
:
446 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-emphasismark", "accent" );
448 case awt::FontEmphasisMark::ABOVE
:
449 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-emphasismark", "above" );
451 case awt::FontEmphasisMark::BELOW
:
452 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-emphasismark", "below" );
455 SAL_WARN( "xmlscript.xmldlg", "### unexpected font-emphasismark!" );
463 void ElementDescriptor::addNumberFormatAttr(
464 Reference
< beans::XPropertySet
> const & xFormatProperties
)
468 OSL_VERIFY( xFormatProperties
->getPropertyValue( "FormatString" ) >>= sFormat
);
469 OSL_VERIFY( xFormatProperties
->getPropertyValue( "Locale" ) >>= locale
);
471 addAttribute(XMLNS_DIALOGS_PREFIX
":format-code", sFormat
);
474 LanguageTag
aLanguageTag( locale
);
476 if (aLanguageTag
.isIsoLocale())
478 // Old style "lll;CC" for compatibility, I really don't know what may
480 if (aLanguageTag
.getCountry().isEmpty())
481 aStr
= aLanguageTag
.getLanguage();
483 aStr
= aLanguageTag
.getLanguage() + ";" + aLanguageTag
.getCountry();
487 aStr
= aLanguageTag
.getBcp47( false);
489 addAttribute( XMLNS_DIALOGS_PREFIX
":format-locale", aStr
);
492 Any
ElementDescriptor::readProp( OUString
const & rPropName
)
494 if (beans::PropertyState_DEFAULT_VALUE
!= _xPropState
->getPropertyState( rPropName
))
496 return _xProps
->getPropertyValue( rPropName
);
501 void ElementDescriptor::readStringAttr(
502 OUString
const & rPropName
, OUString
const & rAttrName
)
504 if (beans::PropertyState_DEFAULT_VALUE
!=
505 _xPropState
->getPropertyState( rPropName
))
507 Any
a( _xProps
->getPropertyValue( rPropName
) );
510 addAttribute( rAttrName
, v
);
512 SAL_WARN( "xmlscript.xmldlg", "### unexpected property type!" );
516 void ElementDescriptor::readHexLongAttr( OUString
const & rPropName
, OUString
const & rAttrName
)
518 if (beans::PropertyState_DEFAULT_VALUE
!= _xPropState
->getPropertyState( rPropName
))
520 Any
a( _xProps
->getPropertyValue( rPropName
) );
521 if (auto n
= o3tl::tryAccess
<sal_uInt32
>(a
))
523 addAttribute( rAttrName
, "0x" + OUString::number(*n
, 16) );
528 void ElementDescriptor::readDateFormatAttr( OUString
const & rPropName
, OUString
const & rAttrName
)
530 if (beans::PropertyState_DEFAULT_VALUE
== _xPropState
->getPropertyState( rPropName
))
533 Any
a( _xProps
->getPropertyValue( rPropName
) );
534 if (auto n
= o3tl::tryAccess
<sal_Int16
>(a
))
539 addAttribute( rAttrName
, "system_short" );
542 addAttribute( rAttrName
, "system_short_YY" );
545 addAttribute( rAttrName
, "system_short_YYYY" );
548 addAttribute( rAttrName
, "system_long" );
551 addAttribute( rAttrName
, "short_DDMMYY" );
554 addAttribute( rAttrName
, "short_MMDDYY" );
557 addAttribute( rAttrName
, "short_YYMMDD" );
560 addAttribute( rAttrName
, "short_DDMMYYYY" );
563 addAttribute( rAttrName
, "short_MMDDYYYY" );
566 addAttribute( rAttrName
, "short_YYYYMMDD" );
569 addAttribute( rAttrName
, "short_YYMMDD_DIN5008" );
572 addAttribute( rAttrName
, "short_YYYYMMDD_DIN5008" );
575 SAL_WARN( "xmlscript.xmldlg", "### unexpected date format!" );
580 OSL_FAIL( "### unexpected property type!" );
583 void ElementDescriptor::readDateAttr( OUString
const & rPropName
, OUString
const & rAttrName
)
585 if (beans::PropertyState_DEFAULT_VALUE
== _xPropState
->getPropertyState( rPropName
))
588 Any
a( _xProps
->getPropertyValue( rPropName
) );
589 if (a
.getValueTypeClass() == TypeClass_STRUCT
&& a
.getValueType() == cppu::UnoType
<util::Date
>::get())
594 ::Date
aTDate(aUDate
);
595 addAttribute( rAttrName
, OUString::number( aTDate
.GetDate() ) );
598 OSL_FAIL( "### internal error" );
601 OSL_FAIL( "### unexpected property type!" );
604 void ElementDescriptor::readTimeAttr( OUString
const & rPropName
, OUString
const & rAttrName
)
606 if (beans::PropertyState_DEFAULT_VALUE
== _xPropState
->getPropertyState( rPropName
))
609 Any
a( _xProps
->getPropertyValue( rPropName
) );
610 if (a
.getValueTypeClass() == TypeClass_STRUCT
&& a
.getValueType() == cppu::UnoType
<util::Time
>::get())
615 ::tools::Time
aTTime(aUTime
);
616 addAttribute( rAttrName
, OUString::number( aTTime
.GetTime() / ::tools::Time::nanoPerCenti
) );
619 OSL_FAIL( "### internal error" );
622 OSL_FAIL( "### unexpected property type!" );
625 void ElementDescriptor::readTimeFormatAttr( OUString
const & rPropName
, OUString
const & rAttrName
)
627 if (beans::PropertyState_DEFAULT_VALUE
== _xPropState
->getPropertyState( rPropName
))
630 Any
a( _xProps
->getPropertyValue( rPropName
) );
631 if (auto n
= o3tl::tryAccess
<sal_Int16
>(a
))
636 addAttribute( rAttrName
, "24h_short" );
639 addAttribute( rAttrName
, "24h_long" );
642 addAttribute( rAttrName
, "12h_short" );
645 addAttribute( rAttrName
, "12h_long" );
648 addAttribute( rAttrName
, "Duration_short" );
651 addAttribute( rAttrName
, "Duration_long" );
654 SAL_WARN( "xmlscript.xmldlg", "### unexpected time format!" );
659 OSL_FAIL( "### unexpected property type!" );
662 void ElementDescriptor::readAlignAttr( OUString
const & rPropName
, OUString
const & rAttrName
)
664 if (beans::PropertyState_DEFAULT_VALUE
== _xPropState
->getPropertyState( rPropName
))
667 Any
a( _xProps
->getPropertyValue( rPropName
) );
668 if (auto n
= o3tl::tryAccess
<sal_Int16
>(a
))
673 addAttribute( rAttrName
, "left" );
676 addAttribute( rAttrName
, "center" );
679 addAttribute( rAttrName
, "right" );
682 SAL_WARN( "xmlscript.xmldlg", "### illegal alignment value!" );
687 OSL_FAIL( "### unexpected property type!" );
690 void ElementDescriptor::readVerticalAlignAttr( OUString
const & rPropName
, OUString
const & rAttrName
)
692 if (beans::PropertyState_DEFAULT_VALUE
== _xPropState
->getPropertyState( rPropName
))
695 Any
a( _xProps
->getPropertyValue( rPropName
) );
696 if (a
.getValueTypeClass() == TypeClass_ENUM
&& a
.getValueType() == cppu::UnoType
<style::VerticalAlignment
>::get())
698 style::VerticalAlignment eAlign
;
702 case style::VerticalAlignment_TOP
:
703 addAttribute( rAttrName
, "top" );
705 case style::VerticalAlignment_MIDDLE
:
706 addAttribute( rAttrName
, "center" );
708 case style::VerticalAlignment_BOTTOM
:
709 addAttribute( rAttrName
, "bottom" );
712 SAL_WARN( "xmlscript.xmldlg", "### illegal vertical alignment value!" );
717 OSL_FAIL( "### unexpected property type!" );
720 void ElementDescriptor::readImageOrGraphicAttr(OUString
const & rAttrName
)
723 if (beans::PropertyState_DEFAULT_VALUE
!= _xPropState
->getPropertyState("Graphic"))
725 uno::Reference
<graphic::XGraphic
> xGraphic
;
726 _xProps
->getPropertyValue("Graphic") >>= xGraphic
;
729 Reference
< document::XStorageBasedDocument
> xDocStorage( _xDocument
, UNO_QUERY
);
730 if ( xDocStorage
.is() )
732 Reference
<XComponentContext
> xContext
= ::comphelper::getProcessComponentContext();
733 uno::Reference
<document::XGraphicStorageHandler
> xGraphicStorageHandler
;
734 xGraphicStorageHandler
.set(document::GraphicStorageHandler::createWithStorage(xContext
, xDocStorage
->getDocumentStorage()));
735 if (xGraphicStorageHandler
.is())
737 sURL
= xGraphicStorageHandler
->saveGraphic(xGraphic
);
742 // tdf#130793 Above fails if the dialog is not part of a document. Export the ImageURL then.
744 && beans::PropertyState_DEFAULT_VALUE
!= _xPropState
->getPropertyState("ImageURL"))
746 _xProps
->getPropertyValue("ImageURL") >>= sURL
;
749 addAttribute(rAttrName
, sURL
);
752 void ElementDescriptor::readImageAlignAttr( OUString
const & rPropName
, OUString
const & rAttrName
)
754 if (beans::PropertyState_DEFAULT_VALUE
== _xPropState
->getPropertyState( rPropName
))
757 Any
a( _xProps
->getPropertyValue( rPropName
) );
758 if (auto n
= o3tl::tryAccess
<sal_Int16
>(a
))
763 addAttribute( rAttrName
, "left" );
766 addAttribute( rAttrName
, "top" );
769 addAttribute( rAttrName
, "right" );
772 addAttribute( rAttrName
, "bottom" );
775 SAL_WARN( "xmlscript.xmldlg", "### illegal image alignment value!" );
780 OSL_FAIL( "### unexpected property type!" );
783 void ElementDescriptor::readImagePositionAttr( OUString
const & rPropName
, OUString
const & rAttrName
)
785 if (beans::PropertyState_DEFAULT_VALUE
== _xPropState
->getPropertyState( rPropName
))
788 Any
a( _xProps
->getPropertyValue( rPropName
) );
789 auto n
= o3tl::tryAccess
<sal_Int16
>(a
);
795 case awt::ImagePosition::LeftTop
:
796 addAttribute( rAttrName
, "left-top" );
798 case awt::ImagePosition::LeftCenter
:
799 addAttribute( rAttrName
, "left-center" );
801 case awt::ImagePosition::LeftBottom
:
802 addAttribute( rAttrName
, "left-bottom" );
804 case awt::ImagePosition::RightTop
:
805 addAttribute( rAttrName
, "right-top" );
807 case awt::ImagePosition::RightCenter
:
808 addAttribute( rAttrName
, "right-center" );
810 case awt::ImagePosition::RightBottom
:
811 addAttribute( rAttrName
, "right-bottom" );
813 case awt::ImagePosition::AboveLeft
:
814 addAttribute( rAttrName
, "top-left" );
816 case awt::ImagePosition::AboveCenter
:
817 addAttribute( rAttrName
, "top-center" );
819 case awt::ImagePosition::AboveRight
:
820 addAttribute( rAttrName
, "top-right" );
822 case awt::ImagePosition::BelowLeft
:
823 addAttribute( rAttrName
, "bottom-left" );
825 case awt::ImagePosition::BelowCenter
:
826 addAttribute( rAttrName
, "bottom-center" );
828 case awt::ImagePosition::BelowRight
:
829 addAttribute( rAttrName
, "bottom-right" );
831 case awt::ImagePosition::Centered
:
832 addAttribute( rAttrName
, "center" );
835 SAL_WARN( "xmlscript.xmldlg", "### illegal image position value!" );
840 void ElementDescriptor::readButtonTypeAttr( OUString
const & rPropName
, OUString
const & rAttrName
)
842 if (beans::PropertyState_DEFAULT_VALUE
== _xPropState
->getPropertyState( rPropName
))
845 Any
a( _xProps
->getPropertyValue( rPropName
) );
846 auto n
= o3tl::tryAccess
<sal_Int16
>(a
);
850 switch (static_cast<awt::PushButtonType
>(*n
))
852 case awt::PushButtonType_STANDARD
:
853 addAttribute( rAttrName
, "standard" );
855 case awt::PushButtonType_OK
:
856 addAttribute( rAttrName
, "ok" );
858 case awt::PushButtonType_CANCEL
:
859 addAttribute( rAttrName
, "cancel" );
861 case awt::PushButtonType_HELP
:
862 addAttribute( rAttrName
, "help" );
865 SAL_WARN( "xmlscript.xmldlg", "### illegal button-type value!" );
870 void ElementDescriptor::readOrientationAttr( OUString
const & rPropName
, OUString
const & rAttrName
)
872 if (beans::PropertyState_DEFAULT_VALUE
== _xPropState
->getPropertyState( rPropName
))
875 Any
a( _xProps
->getPropertyValue( rPropName
) );
876 auto n
= o3tl::tryAccess
<sal_Int32
>(a
);
883 addAttribute( rAttrName
, "horizontal" );
886 addAttribute( rAttrName
, "vertical" );
889 SAL_WARN( "xmlscript.xmldlg", "### illegal orientation value!" );
894 void ElementDescriptor::readLineEndFormatAttr( OUString
const & rPropName
, OUString
const & rAttrName
)
896 if (beans::PropertyState_DEFAULT_VALUE
== _xPropState
->getPropertyState( rPropName
))
899 Any
a( _xProps
->getPropertyValue( rPropName
) );
900 auto n
= o3tl::tryAccess
<sal_Int16
>(a
);
906 case awt::LineEndFormat::CARRIAGE_RETURN
:
907 addAttribute( rAttrName
, "carriage-return" );
909 case awt::LineEndFormat::LINE_FEED
:
910 addAttribute( rAttrName
, "line-feed" );
912 case awt::LineEndFormat::CARRIAGE_RETURN_LINE_FEED
:
913 addAttribute( rAttrName
, "carriage-return-line-feed" );
916 SAL_WARN( "xmlscript.xmldlg", "### illegal line end format value!" );
921 void ElementDescriptor::readDataAwareAttr( OUString
const & rAttrName
)
923 Reference
< lang::XMultiServiceFactory
> xFac
;
924 if ( _xDocument
.is() )
925 xFac
.set( _xDocument
, uno::UNO_QUERY
);
927 Reference
< form::binding::XBindableValue
> xBinding( _xProps
, UNO_QUERY
);
929 if ( xFac
.is() && xBinding
.is() && rAttrName
== XMLNS_DIALOGS_PREFIX
":linked-cell" )
933 Reference
< beans::XPropertySet
> xConvertor( xFac
->createInstance( "com.sun.star.table.CellAddressConversion" ), uno::UNO_QUERY
);
934 Reference
< beans::XPropertySet
> xBindable( xBinding
->getValueBinding(), UNO_QUERY
);
935 if ( xBindable
.is() )
937 table::CellAddress aAddress
;
938 xBindable
->getPropertyValue( "BoundCell" ) >>= aAddress
;
939 xConvertor
->setPropertyValue( "Address", makeAny( aAddress
) );
941 xConvertor
->getPropertyValue( "PersistentRepresentation" ) >>= sAddress
;
942 if ( !sAddress
.isEmpty() )
943 addAttribute( rAttrName
, sAddress
);
945 SAL_INFO("xmlscript.xmldlg", "*** Bindable value " << sAddress
);
949 catch( uno::Exception
& )
953 Reference
< form::binding::XListEntrySink
> xEntrySink( _xProps
, UNO_QUERY
);
954 if ( !(xEntrySink
.is() && rAttrName
== XMLNS_DIALOGS_PREFIX
":source-cell-range") )
957 Reference
< beans::XPropertySet
> xListSource( xEntrySink
->getListEntrySource(), UNO_QUERY
);
958 if ( !xListSource
.is() )
963 Reference
< beans::XPropertySet
> xConvertor( xFac
->createInstance( "com.sun.star.table.CellRangeAddressConversion" ), uno::UNO_QUERY
);
965 table::CellRangeAddress aAddress
;
966 xListSource
->getPropertyValue( "CellRange" ) >>= aAddress
;
969 xConvertor
->setPropertyValue( "Address", makeAny( aAddress
) );
970 xConvertor
->getPropertyValue( "PersistentRepresentation" ) >>= sAddress
;
971 SAL_INFO("xmlscript.xmldlg","**** cell range source list " << sAddress
);
972 if ( !sAddress
.isEmpty() )
973 addAttribute( rAttrName
, sAddress
);
975 catch( uno::Exception
& )
980 void ElementDescriptor::readSelectionTypeAttr( OUString
const & rPropName
, OUString
const & rAttrName
)
982 if (beans::PropertyState_DEFAULT_VALUE
== _xPropState
->getPropertyState( rPropName
))
985 Any
aSelectionType ( _xProps
->getPropertyValue( rPropName
) );
987 if (aSelectionType
.getValueTypeClass() != TypeClass_ENUM
||
988 aSelectionType
.getValueType() != cppu::UnoType
<view::SelectionType
>::get())
991 ::view::SelectionType eSelectionType
;
992 aSelectionType
>>= eSelectionType
;
994 switch (eSelectionType
)
996 case ::view::SelectionType_NONE
:
997 addAttribute( rAttrName
, "none" );
999 case ::view::SelectionType_SINGLE
:
1000 addAttribute( rAttrName
, "single" );
1002 case ::view::SelectionType_MULTI
:
1003 addAttribute( rAttrName
, "multi" );
1005 case ::view::SelectionType_RANGE
:
1006 addAttribute( rAttrName
, "range" );
1009 SAL_WARN( "xmlscript.xmldlg", "### illegal selection type value!" );
1014 void ElementDescriptor::readScrollableSettings()
1016 readLongAttr( "ScrollHeight",
1017 XMLNS_DIALOGS_PREFIX
":scrollheight" );
1018 readLongAttr( "ScrollWidth",
1019 XMLNS_DIALOGS_PREFIX
":scrollwidth" );
1020 readLongAttr( "ScrollTop",
1021 XMLNS_DIALOGS_PREFIX
":scrolltop" );
1022 readLongAttr( "ScrollLeft",
1023 XMLNS_DIALOGS_PREFIX
":scrollleft" );
1024 readBoolAttr( "HScroll",
1025 XMLNS_DIALOGS_PREFIX
":hscroll" );
1026 readBoolAttr( "VScroll",
1027 XMLNS_DIALOGS_PREFIX
":vscroll" );
1030 void ElementDescriptor::readImageScaleModeAttr( OUString
const & rPropName
, OUString
const & rAttrName
)
1032 if (beans::PropertyState_DEFAULT_VALUE
== _xPropState
->getPropertyState( rPropName
))
1035 Any
aImageScaleMode( _xProps
->getPropertyValue( rPropName
) );
1037 if (aImageScaleMode
.getValueTypeClass() != TypeClass_SHORT
)
1040 sal_Int16 nImageScaleMode
= 0;
1041 aImageScaleMode
>>= nImageScaleMode
;
1043 switch(nImageScaleMode
)
1045 case ::awt::ImageScaleMode::NONE
:
1046 addAttribute( rAttrName
, "none" );
1048 case ::awt::ImageScaleMode::ISOTROPIC
:
1049 addAttribute( rAttrName
, "isotropic" );
1051 case ::awt::ImageScaleMode::ANISOTROPIC
:
1052 addAttribute( rAttrName
, "anisotropic" );
1055 OSL_ENSURE( false, "### illegal image scale mode value.");
1060 void ElementDescriptor::readDefaults( bool supportPrintable
, bool supportVisible
)
1062 Any
a( _xProps
->getPropertyValue( "Name" ) );
1064 // The following is a hack to allow 'form' controls to override the default
1065 // control supported by dialogs. This should work well for both VBA support and
1066 // normal LibreOffice (when normal 'Dialogs' decide to support form control models)
1067 // In the future VBA support might require custom models ( and not the just the form
1068 // variant of a control that we currently use ) In this case the door is still open,
1069 // we just need to define a new way for the 'ServiceName' to be extracted from the
1070 // incoming model. E.g. the use of supporting service
1071 // "com.sun.star.form.FormComponent", 'ServiceName' and XPersistObject
1072 // is only an implementation detail here, in the future some other
1073 // method (perhaps a custom prop) could be used instead.
1074 Reference
< lang::XServiceInfo
> xSrvInfo( _xProps
, UNO_QUERY
);
1075 if ( xSrvInfo
.is() && xSrvInfo
->supportsService( "com.sun.star.form.FormComponent" ) )
1077 Reference
< io::XPersistObject
> xPersist( _xProps
, UNO_QUERY
);
1078 if ( xPersist
.is() )
1080 OUString sCtrlName
= xPersist
->getServiceName();
1081 if ( !sCtrlName
.isEmpty() )
1082 addAttribute( XMLNS_DIALOGS_PREFIX
":control-implementation", sCtrlName
);
1085 addAttribute( XMLNS_DIALOGS_PREFIX
":id", *o3tl::doAccess
<OUString
>(a
) );
1086 readShortAttr( "TabIndex", XMLNS_DIALOGS_PREFIX
":tab-index" );
1088 bool bEnabled
= false;
1089 if (_xProps
->getPropertyValue( "Enabled" ) >>= bEnabled
)
1093 addAttribute( XMLNS_DIALOGS_PREFIX
":disabled", "true" );
1098 SAL_WARN( "xmlscript.xmldlg", "unexpected property type for \"Enabled\": not bool!" );
1101 if (supportVisible
) try
1103 bool bVisible
= true;
1104 if (_xProps
->getPropertyValue("EnableVisible" ) >>= bVisible
)
1107 // only write out the non default case
1110 addAttribute( XMLNS_DIALOGS_PREFIX
":visible", "false" );
1116 DBG_UNHANDLED_EXCEPTION("xmlscript.xmldlg");
1118 // force writing of pos/size
1119 a
= _xProps
->getPropertyValue( "PositionX" );
1120 if (auto n
= o3tl::tryAccess
<sal_Int32
>(a
))
1122 addAttribute( XMLNS_DIALOGS_PREFIX
":left", OUString::number(*n
) );
1124 a
= _xProps
->getPropertyValue( "PositionY" );
1125 if (auto n
= o3tl::tryAccess
<sal_Int32
>(a
))
1127 addAttribute( XMLNS_DIALOGS_PREFIX
":top", OUString::number(*n
) );
1129 a
= _xProps
->getPropertyValue( "Width" );
1130 if (auto n
= o3tl::tryAccess
<sal_Int32
>(a
))
1132 addAttribute( XMLNS_DIALOGS_PREFIX
":width", OUString::number(*n
) );
1134 a
= _xProps
->getPropertyValue( "Height" );
1135 if (auto n
= o3tl::tryAccess
<sal_Int32
>(a
))
1137 addAttribute( XMLNS_DIALOGS_PREFIX
":height", OUString::number(*n
) );
1140 if (supportPrintable
)
1142 readBoolAttr( "Printable", XMLNS_DIALOGS_PREFIX
":printable" );
1144 readLongAttr( "Step", XMLNS_DIALOGS_PREFIX
":page" );
1145 readStringAttr( "Tag", XMLNS_DIALOGS_PREFIX
":tag" );
1146 readStringAttr( "HelpText", XMLNS_DIALOGS_PREFIX
":help-text" );
1147 readStringAttr( "HelpURL", XMLNS_DIALOGS_PREFIX
":help-url" );
1150 void ElementDescriptor::readEvents()
1152 Reference
< script::XScriptEventsSupplier
> xSupplier( _xProps
, UNO_QUERY
);
1153 if (!xSupplier
.is())
1156 Reference
< container::XNameContainer
> xEvents( xSupplier
->getEvents() );
1160 const Sequence
< OUString
> aNames( xEvents
->getElementNames() );
1161 for ( const auto& rName
: aNames
)
1163 script::ScriptEventDescriptor descr
;
1164 if (xEvents
->getByName( rName
) >>= descr
)
1166 SAL_WARN_IF( descr
.ListenerType
.isEmpty() ||
1167 descr
.EventMethod
.isEmpty() ||
1168 descr
.ScriptCode
.isEmpty() ||
1169 descr
.ScriptType
.isEmpty() , "xmlscript.xmldlg", "### invalid event descr!" );
1171 OUString aEventName
;
1173 if (descr
.AddListenerParam
.isEmpty())
1175 // detection of event-name
1176 OString
listenerType( OUStringToOString( descr
.ListenerType
, RTL_TEXTENCODING_ASCII_US
) );
1177 OString
eventMethod( OUStringToOString( descr
.EventMethod
, RTL_TEXTENCODING_ASCII_US
) );
1178 StringTriple
const * p
= g_pEventTranslations
;
1181 if (0 == ::rtl_str_compare( p
->second
, eventMethod
.getStr() ) &&
1182 0 == ::rtl_str_compare( p
->first
, listenerType
.getStr() ))
1184 aEventName
= OUString( p
->third
, ::rtl_str_getLength( p
->third
), RTL_TEXTENCODING_ASCII_US
);
1191 ElementDescriptor
* pElem
;
1192 Reference
< xml::sax::XAttributeList
> xElem
;
1194 if (!aEventName
.isEmpty()) // script:event
1196 pElem
= new ElementDescriptor( XMLNS_SCRIPT_PREFIX
":event" );
1199 pElem
->addAttribute( XMLNS_SCRIPT_PREFIX
":event-name", aEventName
);
1201 else // script:listener-event
1203 pElem
= new ElementDescriptor( XMLNS_SCRIPT_PREFIX
":listener-event" );
1206 pElem
->addAttribute( XMLNS_SCRIPT_PREFIX
":listener-type", descr
.ListenerType
);
1207 pElem
->addAttribute( XMLNS_SCRIPT_PREFIX
":listener-method", descr
.EventMethod
);
1209 if (!descr
.AddListenerParam
.isEmpty())
1211 pElem
->addAttribute( XMLNS_SCRIPT_PREFIX
":listener-param", descr
.AddListenerParam
);
1214 if ( descr
.ScriptType
== "StarBasic" )
1216 // separate optional location
1217 sal_Int32 nIndex
= descr
.ScriptCode
.indexOf( ':' );
1220 pElem
->addAttribute( XMLNS_SCRIPT_PREFIX
":location", descr
.ScriptCode
.copy( 0, nIndex
) );
1221 pElem
->addAttribute( XMLNS_SCRIPT_PREFIX
":macro-name", descr
.ScriptCode
.copy( nIndex
+1 ) );
1225 pElem
->addAttribute( XMLNS_SCRIPT_PREFIX
":macro-name", descr
.ScriptCode
);
1230 pElem
->addAttribute(XMLNS_SCRIPT_PREFIX
":macro-name", descr
.ScriptCode
);
1234 pElem
->addAttribute( XMLNS_SCRIPT_PREFIX
":language", descr
.ScriptType
);
1236 addSubElement( xElem
);
1240 SAL_WARN( "xmlscript.xmldlg", "### unexpected event type in container!" );
1245 static bool equalFont( Style
const & style1
, Style
const & style2
)
1247 awt::FontDescriptor
const & f1
= style1
._descr
;
1248 awt::FontDescriptor
const & f2
= style2
._descr
;
1250 f1
.Name
== f2
.Name
&&
1251 f1
.Height
== f2
.Height
&&
1252 f1
.Width
== f2
.Width
&&
1253 f1
.StyleName
== f2
.StyleName
&&
1254 f1
.Family
== f2
.Family
&&
1255 f1
.CharSet
== f2
.CharSet
&&
1256 f1
.Pitch
== f2
.Pitch
&&
1257 f1
.CharacterWidth
== f2
.CharacterWidth
&&
1258 f1
.Weight
== f2
.Weight
&&
1259 f1
.Slant
== f2
.Slant
&&
1260 f1
.Underline
== f2
.Underline
&&
1261 f1
.Strikeout
== f2
.Strikeout
&&
1262 f1
.Orientation
== f2
.Orientation
&&
1263 bool(f1
.Kerning
) == bool(f2
.Kerning
) &&
1264 bool(f1
.WordLineMode
) == bool(f2
.WordLineMode
) &&
1265 f1
.Type
== f2
.Type
&&
1266 style1
._fontRelief
== style2
._fontRelief
&&
1267 style1
._fontEmphasisMark
== style2
._fontEmphasisMark
1271 OUString
StyleBag::getStyleId( Style
const & rStyle
)
1273 if (! rStyle
._set
) // nothing set
1275 return OUString(); // everything default: no need to export a specific style
1278 // lookup existing style
1279 for (auto const & pStyle
: _styles
)
1281 short demanded_defaults
= ~rStyle
._set
& rStyle
._all
;
1282 // test, if defaults are not set
1283 if ((~pStyle
->_set
& demanded_defaults
) == demanded_defaults
&&
1284 (rStyle
._set
& (pStyle
->_all
& ~pStyle
->_set
)) == 0)
1286 short bset
= rStyle
._set
& pStyle
->_set
;
1288 rStyle
._backgroundColor
!= pStyle
->_backgroundColor
)
1291 rStyle
._textColor
!= pStyle
->_textColor
)
1293 if ((bset
& 0x20) &&
1294 rStyle
._textLineColor
!= pStyle
->_textLineColor
)
1296 if ((bset
& 0x10) &&
1297 rStyle
._fillColor
!= pStyle
->_fillColor
)
1300 (rStyle
._border
!= pStyle
->_border
||
1301 (rStyle
._border
== BORDER_SIMPLE_COLOR
&&
1302 rStyle
._borderColor
!= pStyle
->_borderColor
)))
1305 !equalFont( rStyle
, *pStyle
))
1307 if ((bset
& 0x40) &&
1308 rStyle
._visualEffect
!= pStyle
->_visualEffect
)
1312 short bnset
= rStyle
._set
& ~pStyle
->_set
;
1314 pStyle
->_backgroundColor
= rStyle
._backgroundColor
;
1316 pStyle
->_textColor
= rStyle
._textColor
;
1318 pStyle
->_textLineColor
= rStyle
._textLineColor
;
1320 pStyle
->_fillColor
= rStyle
._fillColor
;
1322 pStyle
->_border
= rStyle
._border
;
1323 pStyle
->_borderColor
= rStyle
._borderColor
;
1326 pStyle
->_descr
= rStyle
._descr
;
1327 pStyle
->_fontRelief
= rStyle
._fontRelief
;
1328 pStyle
->_fontEmphasisMark
= rStyle
._fontEmphasisMark
;
1331 pStyle
->_visualEffect
= rStyle
._visualEffect
;
1333 pStyle
->_all
|= rStyle
._all
;
1334 pStyle
->_set
|= rStyle
._set
;
1340 // no appr style found, append new
1341 std::unique_ptr
<Style
> pStyle(new Style( rStyle
));
1342 pStyle
->_id
= OUString::number( _styles
.size() );
1343 _styles
.push_back( std::move(pStyle
) );
1344 return _styles
.back()->_id
;
1347 StyleBag::~StyleBag()
1351 void StyleBag::dump( Reference
< xml::sax::XExtendedDocumentHandler
> const & xOut
)
1353 if ( _styles
.empty())
1356 OUString
aStylesName( XMLNS_DIALOGS_PREFIX
":styles" );
1357 xOut
->ignorableWhitespace( OUString() );
1358 xOut
->startElement( aStylesName
, Reference
< xml::sax::XAttributeList
>() );
1360 for (auto const & _style
: _styles
)
1362 Reference
< xml::sax::XAttributeList
> xAttr( _style
->createElement() );
1363 static_cast< ElementDescriptor
* >( xAttr
.get() )->dump( xOut
.get() );
1365 xOut
->ignorableWhitespace( OUString() );
1366 xOut
->endElement( aStylesName
);
1369 void exportDialogModel(
1370 Reference
< xml::sax::XExtendedDocumentHandler
> const & xOut
,
1371 Reference
< container::XNameContainer
> const & xDialogModel
,
1372 Reference
< frame::XModel
> const & xDocument
)
1374 StyleBag all_styles
;
1376 Reference
< beans::XPropertySet
> xProps( xDialogModel
, UNO_QUERY
);
1377 OSL_ASSERT( xProps
.is() );
1378 Reference
< beans::XPropertyState
> xPropState( xProps
, UNO_QUERY
);
1379 OSL_ASSERT( xPropState
.is() );
1381 ElementDescriptor
* pElem
= new ElementDescriptor( xProps
, xPropState
, XMLNS_DIALOGS_PREFIX
":bulletinboard", xDocument
);
1382 Reference
< xml::sax::XAttributeList
> xElem( pElem
);
1383 pElem
->readBullitinBoard( &all_styles
);
1385 xOut
->startDocument();
1388 "<!DOCTYPE dlg:window PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\""
1389 " \"dialog.dtd\">" );
1390 xOut
->ignorableWhitespace( OUString() );
1392 OUString
aWindowName( XMLNS_DIALOGS_PREFIX
":window" );
1393 ElementDescriptor
* pWindow
= new ElementDescriptor( xProps
, xPropState
, aWindowName
, xDocument
);
1394 Reference
< xml::sax::XAttributeList
> xWindow( pWindow
);
1395 pWindow
->readDialogModel( &all_styles
);
1396 xOut
->ignorableWhitespace( OUString() );
1397 xOut
->startElement( aWindowName
, xWindow
);
1399 pWindow
->dumpSubElements( xOut
.get() );
1400 // dump out stylebag
1401 all_styles
.dump( xOut
);
1403 if ( xDialogModel
->getElementNames().hasElements() )
1405 // open up bulletinboard
1406 OUString
aBBoardName( XMLNS_DIALOGS_PREFIX
":bulletinboard" );
1407 xOut
->ignorableWhitespace( OUString() );
1408 xOut
->startElement( aBBoardName
, xElem
);
1410 pElem
->dumpSubElements( xOut
.get() );
1411 // end bulletinboard
1412 xOut
->ignorableWhitespace( OUString() );
1413 xOut
->endElement( aBBoardName
);
1417 xOut
->ignorableWhitespace( OUString() );
1418 xOut
->endElement( aWindowName
);
1420 xOut
->endDocument();
1425 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */