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 .
20 #include "exp_share.hxx"
22 #include <rtl/ustrbuf.hxx>
23 #include <sal/log.hxx>
24 #include <tools/diagnose_ex.h>
26 #include <com/sun/star/awt/CharSet.hpp>
27 #include <com/sun/star/awt/FontFamily.hpp>
28 #include <com/sun/star/awt/FontPitch.hpp>
29 #include <com/sun/star/awt/FontSlant.hpp>
30 #include <com/sun/star/awt/FontStrikeout.hpp>
31 #include <com/sun/star/awt/FontType.hpp>
32 #include <com/sun/star/awt/FontUnderline.hpp>
33 #include <com/sun/star/awt/FontWeight.hpp>
34 #include <com/sun/star/awt/FontWidth.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>
55 #include <com/sun/star/util/NumberFormat.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/form/binding/XValueBinding.hpp>
62 #include <com/sun/star/table/CellAddress.hpp>
63 #include <com/sun/star/table/CellRangeAddress.hpp>
64 #include <com/sun/star/document/XStorageBasedDocument.hpp>
65 #include <com/sun/star/document/GraphicObjectResolver.hpp>
67 #include <comphelper/processfactory.hxx>
68 #include <i18nlangtag/languagetag.hxx>
70 using namespace ::com::sun::star
;
71 using namespace ::com::sun::star::uno
;
76 Reference
< xml::sax::XAttributeList
> Style::createElement()
78 ElementDescriptor
* pStyle
= new ElementDescriptor( XMLNS_DIALOGS_PREFIX
":style" );
81 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":style-id", _id
);
86 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":background-color", "0x" + OUString::number(_backgroundColor
,16));
92 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":text-color", "0x" + OUString::number(_textColor
,16));
98 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":textline-color", "0x" + OUString::number(_textLineColor
,16));
104 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":fill-color", "0x" + OUString::number(_fillColor
,16));
113 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":border", "none" );
116 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":border", "3d" );
119 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":border", "simple" );
121 case BORDER_SIMPLE_COLOR
: {
122 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":border", "0x" + OUString::number(_borderColor
,16));
126 SAL_WARN( "xmlscript.xmldlg", "### unexpected border value!" );
131 // visual effect (look)
134 switch (_visualEffect
)
136 case awt::VisualEffect::NONE
:
137 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":look", "none" );
139 case awt::VisualEffect::LOOK3D
:
140 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":look", "3d" );
142 case awt::VisualEffect::FLAT
:
143 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":look", "simple" );
146 SAL_WARN( "xmlscript.xmldlg", "### unexpected visual effect value!" );
154 awt::FontDescriptor def_descr
;
156 // dialog:font-name CDATA #IMPLIED
157 if (def_descr
.Name
!= _descr
.Name
)
159 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-name", _descr
.Name
);
161 // dialog:font-height %numeric; #IMPLIED
162 if (def_descr
.Height
!= _descr
.Height
)
164 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-height", OUString::number( _descr
.Height
) );
166 // dialog:font-width %numeric; #IMPLIED
167 if (def_descr
.Width
!= _descr
.Width
)
169 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-width", OUString::number( _descr
.Width
) );
171 // dialog:font-stylename CDATA #IMPLIED
172 if (def_descr
.StyleName
!= _descr
.StyleName
)
174 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-stylename", _descr
.StyleName
);
176 // dialog:font-family "(decorative|modern|roman|script|swiss|system)" #IMPLIED
177 if (def_descr
.Family
!= _descr
.Family
)
179 switch (_descr
.Family
)
181 case awt::FontFamily::DECORATIVE
:
182 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-family", "decorative" );
184 case awt::FontFamily::MODERN
:
185 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-family", "modern" );
187 case awt::FontFamily::ROMAN
:
188 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-family", "roman" );
190 case awt::FontFamily::SCRIPT
:
191 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-family", "script" );
193 case awt::FontFamily::SWISS
:
194 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-family", "swiss" );
196 case awt::FontFamily::SYSTEM
:
197 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-family", "system" );
200 SAL_WARN( "xmlscript.xmldlg", "### unexpected font-family!" );
204 // dialog:font-charset "(ansi|mac|ibmpc_437|ibmpc_850|ibmpc_860|ibmpc_861|ibmpc_863|ibmpc_865|system|symbol)" #IMPLIED
205 if (def_descr
.CharSet
!= _descr
.CharSet
)
207 switch (_descr
.CharSet
)
209 case awt::CharSet::ANSI
:
210 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-charset", "ansi" );
212 case awt::CharSet::MAC
:
213 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-charset", "mac" );
215 case awt::CharSet::IBMPC_437
:
216 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-charset", "ibmpc_437" );
218 case awt::CharSet::IBMPC_850
:
219 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-charset", "ibmpc_850" );
221 case awt::CharSet::IBMPC_860
:
222 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-charset", "ibmpc_860" );
224 case awt::CharSet::IBMPC_861
:
225 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-charset", "ibmpc_861" );
227 case awt::CharSet::IBMPC_863
:
228 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-charset", "ibmpc_863" );
230 case awt::CharSet::IBMPC_865
:
231 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-charset", "ibmpc_865" );
233 case awt::CharSet::SYSTEM
:
234 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-charset", "system" );
236 case awt::CharSet::SYMBOL
:
237 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-charset", "symbol" );
240 SAL_WARN( "xmlscript.xmldlg", "### unexpected font-charset!" );
244 // dialog:font-pitch "(fixed|variable)" #IMPLIED
245 if (def_descr
.Pitch
!= _descr
.Pitch
)
247 switch (_descr
.Pitch
)
249 case awt::FontPitch::FIXED
:
250 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-pitch", "fixed" );
252 case awt::FontPitch::VARIABLE
:
253 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-pitch", "variable" );
256 SAL_WARN( "xmlscript.xmldlg", "### unexpected font-pitch!" );
260 // dialog:font-charwidth CDATA #IMPLIED
261 if (def_descr
.CharacterWidth
!= _descr
.CharacterWidth
)
263 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-charwidth", OUString::number( (float)_descr
.CharacterWidth
) );
265 // dialog:font-weight CDATA #IMPLIED
266 if (def_descr
.Weight
!= _descr
.Weight
)
268 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-weight", OUString::number( (float)_descr
.Weight
) );
270 // dialog:font-slant "(oblique|italic|reverse_oblique|reverse_italic)" #IMPLIED
271 if (def_descr
.Slant
!= _descr
.Slant
)
273 switch (_descr
.Slant
)
275 case awt::FontSlant_OBLIQUE
:
276 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-slant", "oblique" );
278 case awt::FontSlant_ITALIC
:
279 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-slant", "italic" );
281 case awt::FontSlant_REVERSE_OBLIQUE
:
282 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-slant", "reverse_oblique" );
284 case awt::FontSlant_REVERSE_ITALIC
:
285 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-slant", "reverse_italic" );
288 SAL_WARN( "xmlscript.xmldlg", "### unexpected font-slant!" );
292 // dialog:font-underline "(single|double|dotted|dash|longdash|dashdot|dashdotdot|smallwave|wave|doublewave|bold|bolddotted|bolddash|boldlongdash|bolddashdot|bolddashdotdot|boldwave)" #IMPLIED
293 if (def_descr
.Underline
!= _descr
.Underline
)
295 switch (_descr
.Underline
)
297 case awt::FontUnderline::SINGLE
:
298 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "single" );
300 case awt::FontUnderline::DOUBLE
:
301 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "double" );
303 case awt::FontUnderline::DOTTED
:
304 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "dotted" );
306 case awt::FontUnderline::DASH
:
307 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "dash" );
309 case awt::FontUnderline::LONGDASH
:
310 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "longdash" );
312 case awt::FontUnderline::DASHDOT
:
313 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "dashdot" );
315 case awt::FontUnderline::DASHDOTDOT
:
316 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "dashdotdot" );
318 case awt::FontUnderline::SMALLWAVE
:
319 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "smallwave" );
321 case awt::FontUnderline::WAVE
:
322 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "wave" );
324 case awt::FontUnderline::DOUBLEWAVE
:
325 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "doublewave" );
327 case awt::FontUnderline::BOLD
:
328 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "bold" );
330 case awt::FontUnderline::BOLDDOTTED
:
331 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "bolddotted" );
333 case awt::FontUnderline::BOLDDASH
:
334 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "bolddash" );
336 case awt::FontUnderline::BOLDLONGDASH
:
337 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "boldlongdash" );
339 case awt::FontUnderline::BOLDDASHDOT
:
340 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "bolddashdot" );
342 case awt::FontUnderline::BOLDDASHDOTDOT
:
343 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "bolddashdotdot" );
345 case awt::FontUnderline::BOLDWAVE
:
346 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-underline", "boldwave" );
349 SAL_WARN( "xmlscript.xmldlg", "### unexpected font-underline!" );
353 // dialog:font-strikeout "(single|double|bold|slash|x)" #IMPLIED
354 if (def_descr
.Strikeout
!= _descr
.Strikeout
)
356 switch (_descr
.Strikeout
)
358 case awt::FontStrikeout::SINGLE
:
359 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-strikeout", "single" );
361 case awt::FontStrikeout::DOUBLE
:
362 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-strikeout", "double" );
364 case awt::FontStrikeout::BOLD
:
365 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-strikeout", "bold" );
367 case awt::FontStrikeout::SLASH
:
368 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-strikeout", "slash" );
370 case awt::FontStrikeout::X
:
371 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-strikeout", "x" );
374 SAL_WARN( "xmlscript.xmldlg", "### unexpected font-strikeout!" );
378 // dialog:font-orientation CDATA #IMPLIED
379 if (def_descr
.Orientation
!= _descr
.Orientation
)
381 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-orientation", OUString::number( (float)_descr
.Orientation
) );
383 // dialog:font-kerning %boolean; #IMPLIED
384 if ((def_descr
.Kerning
!= sal_False
) != (_descr
.Kerning
!= sal_False
))
386 pStyle
->addBoolAttr( XMLNS_DIALOGS_PREFIX
":font-kerning", _descr
.Kerning
);
388 // dialog:font-wordlinemode %boolean; #IMPLIED
389 if ((def_descr
.WordLineMode
!= sal_False
) != (_descr
.WordLineMode
!= sal_False
))
391 pStyle
->addBoolAttr( XMLNS_DIALOGS_PREFIX
":font-wordlinemode", _descr
.WordLineMode
);
393 // dialog:font-type "(raster|device|scalable)" #IMPLIED
394 if (def_descr
.Type
!= _descr
.Type
)
398 case awt::FontType::RASTER
:
399 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-type", "raster" );
401 case awt::FontType::DEVICE
:
402 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-type", "device" );
404 case awt::FontType::SCALABLE
:
405 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-type", "scalable" );
408 SAL_WARN( "xmlscript.xmldlg", "### unexpected font-type!" );
413 // additional attributes not in FontDescriptor struct
414 // dialog:font-relief (none|embossed|engraved) #IMPLIED
417 case awt::FontRelief::NONE
: // dont export default
419 case awt::FontRelief::EMBOSSED
:
420 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-relief", "embossed" );
422 case awt::FontRelief::ENGRAVED
:
423 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-relief", "engraved" );
426 SAL_WARN( "xmlscript.xmldlg", "### unexpected font-relief!" );
429 // dialog:font-emphasismark (none|dot|circle|disc|accent|above|below) #IMPLIED
430 switch (_fontEmphasisMark
)
432 case awt::FontEmphasisMark::NONE
: // dont export default
434 case awt::FontEmphasisMark::DOT
:
435 pStyle
->addAttribute(XMLNS_DIALOGS_PREFIX
":font-emphasismark", "dot" );
437 case awt::FontEmphasisMark::CIRCLE
:
438 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-emphasismark", "circle" );
440 case awt::FontEmphasisMark::DISC
:
441 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-emphasismark", "disc" );
443 case awt::FontEmphasisMark::ACCENT
:
444 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-emphasismark", "accent" );
446 case awt::FontEmphasisMark::ABOVE
:
447 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-emphasismark", "above" );
449 case awt::FontEmphasisMark::BELOW
:
450 pStyle
->addAttribute( XMLNS_DIALOGS_PREFIX
":font-emphasismark", "below" );
453 SAL_WARN( "xmlscript.xmldlg", "### unexpected font-emphasismark!" );
461 void ElementDescriptor::addNumberFormatAttr(
462 Reference
< beans::XPropertySet
> const & xFormatProperties
)
464 Reference
< beans::XPropertyState
> xState( xFormatProperties
, UNO_QUERY
);
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 (a
.getValueTypeClass() == TypeClass_LONG
)
522 addAttribute( rAttrName
, "0x" + OUString::number((sal_Int64
)(sal_uInt64
)*static_cast<sal_uInt32
const *>(a
.getValue()),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 (a
.getValueTypeClass() == TypeClass_SHORT
)
534 switch (*static_cast<sal_Int16
const *>(a
.getValue()))
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 (a
.getValueTypeClass() == TypeClass_SHORT
)
631 switch (*static_cast<sal_Int16
const *>(a
.getValue()))
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 (a
.getValueTypeClass() == TypeClass_SHORT
)
668 switch (*static_cast<sal_Int16
const *>(a
.getValue()))
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::readImageURLAttr( OUString
const & rPropName
, OUString
const & rAttrName
)
721 if (beans::PropertyState_DEFAULT_VALUE
!= _xPropState
->getPropertyState( rPropName
))
724 _xProps
->getPropertyValue( rPropName
) >>= sURL
;
726 if ( sURL
.startsWith( XMLSCRIPT_GRAPHOBJ_URLPREFIX
) )
728 Reference
< document::XStorageBasedDocument
> xDocStorage( _xDocument
, UNO_QUERY
);
729 if ( xDocStorage
.is() )
731 Reference
<XComponentContext
> xContext
= ::comphelper::getProcessComponentContext();
732 uno::Reference
< document::XGraphicObjectResolver
> xGraphicResolver
=
733 document::GraphicObjectResolver::createWithStorage( xContext
, xDocStorage
->getDocumentStorage() );
734 sURL
= xGraphicResolver
->resolveGraphicObjectURL( sURL
);
737 if ( !sURL
.isEmpty() )
738 addAttribute( rAttrName
, sURL
);
742 void ElementDescriptor::readImageAlignAttr( OUString
const & rPropName
, OUString
const & rAttrName
)
744 if (beans::PropertyState_DEFAULT_VALUE
!= _xPropState
->getPropertyState( rPropName
))
746 Any
a( _xProps
->getPropertyValue( rPropName
) );
747 if (a
.getValueTypeClass() == TypeClass_SHORT
)
749 switch (*static_cast<sal_Int16
const *>(a
.getValue()))
752 addAttribute( rAttrName
, "left" );
755 addAttribute( rAttrName
, "top" );
758 addAttribute( rAttrName
, "right" );
761 addAttribute( rAttrName
, "bottom" );
764 SAL_WARN( "xmlscript.xmldlg", "### illegal image alignment value!" );
769 OSL_FAIL( "### unexpected property type!" );
773 void ElementDescriptor::readImagePositionAttr( OUString
const & rPropName
, OUString
const & rAttrName
)
775 if (beans::PropertyState_DEFAULT_VALUE
!= _xPropState
->getPropertyState( rPropName
))
777 Any
a( _xProps
->getPropertyValue( rPropName
) );
778 if (a
.getValueTypeClass() == TypeClass_SHORT
)
780 switch (*static_cast<sal_Int16
const *>(a
.getValue()))
782 case awt::ImagePosition::LeftTop
:
783 addAttribute( rAttrName
, "left-top" );
785 case awt::ImagePosition::LeftCenter
:
786 addAttribute( rAttrName
, "left-center" );
788 case awt::ImagePosition::LeftBottom
:
789 addAttribute( rAttrName
, "left-bottom" );
791 case awt::ImagePosition::RightTop
:
792 addAttribute( rAttrName
, "right-top" );
794 case awt::ImagePosition::RightCenter
:
795 addAttribute( rAttrName
, "right-center" );
797 case awt::ImagePosition::RightBottom
:
798 addAttribute( rAttrName
, "right-bottom" );
800 case awt::ImagePosition::AboveLeft
:
801 addAttribute( rAttrName
, "top-left" );
803 case awt::ImagePosition::AboveCenter
:
804 addAttribute( rAttrName
, "top-center" );
806 case awt::ImagePosition::AboveRight
:
807 addAttribute( rAttrName
, "top-right" );
809 case awt::ImagePosition::BelowLeft
:
810 addAttribute( rAttrName
, "bottom-left" );
812 case awt::ImagePosition::BelowCenter
:
813 addAttribute( rAttrName
, "bottom-center" );
815 case awt::ImagePosition::BelowRight
:
816 addAttribute( rAttrName
, "bottom-right" );
818 case awt::ImagePosition::Centered
:
819 addAttribute( rAttrName
, "center" );
822 SAL_WARN( "xmlscript.xmldlg", "### illegal image position value!" );
829 void ElementDescriptor::readButtonTypeAttr( OUString
const & rPropName
, OUString
const & rAttrName
)
831 if (beans::PropertyState_DEFAULT_VALUE
!= _xPropState
->getPropertyState( rPropName
))
833 Any
a( _xProps
->getPropertyValue( rPropName
) );
834 if (a
.getValueTypeClass() == TypeClass_SHORT
)
836 switch (*static_cast<sal_Int16
const *>(a
.getValue()))
838 case awt::PushButtonType_STANDARD
:
839 addAttribute( rAttrName
, "standard" );
841 case awt::PushButtonType_OK
:
842 addAttribute( rAttrName
, "ok" );
844 case awt::PushButtonType_CANCEL
:
845 addAttribute( rAttrName
, "cancel" );
847 case awt::PushButtonType_HELP
:
848 addAttribute( rAttrName
, "help" );
851 SAL_WARN( "xmlscript.xmldlg", "### illegal button-type value!" );
858 void ElementDescriptor::readOrientationAttr( OUString
const & rPropName
, OUString
const & rAttrName
)
860 if (beans::PropertyState_DEFAULT_VALUE
!= _xPropState
->getPropertyState( rPropName
))
862 Any
a( _xProps
->getPropertyValue( rPropName
) );
863 if (a
.getValueTypeClass() == TypeClass_LONG
)
865 switch (*static_cast<sal_Int32
const *>(a
.getValue()))
868 addAttribute( rAttrName
, "horizontal" );
871 addAttribute( rAttrName
, "vertical" );
874 SAL_WARN( "xmlscript.xmldlg", "### illegal orientation value!" );
881 void ElementDescriptor::readLineEndFormatAttr( OUString
const & rPropName
, OUString
const & rAttrName
)
883 if (beans::PropertyState_DEFAULT_VALUE
!= _xPropState
->getPropertyState( rPropName
))
885 Any
a( _xProps
->getPropertyValue( rPropName
) );
886 if (a
.getValueTypeClass() == TypeClass_SHORT
)
888 switch (*static_cast<sal_Int16
const *>(a
.getValue()))
890 case awt::LineEndFormat::CARRIAGE_RETURN
:
891 addAttribute( rAttrName
, "carriage-return" );
893 case awt::LineEndFormat::LINE_FEED
:
894 addAttribute( rAttrName
, "line-feed" );
896 case awt::LineEndFormat::CARRIAGE_RETURN_LINE_FEED
:
897 addAttribute( rAttrName
, "carriage-return-line-feed" );
900 SAL_WARN( "xmlscript.xmldlg", "### illegal line end format value!" );
907 void ElementDescriptor::readDataAwareAttr( OUString
const & rAttrName
)
909 Reference
< lang::XMultiServiceFactory
> xFac
;
910 if ( _xDocument
.is() )
911 xFac
.set( _xDocument
, uno::UNO_QUERY
);
913 Reference
< form::binding::XBindableValue
> xBinding( _xProps
, UNO_QUERY
);
915 if ( xFac
.is() && xBinding
.is() && rAttrName
== XMLNS_DIALOGS_PREFIX
":linked-cell" )
919 Reference
< beans::XPropertySet
> xConvertor( xFac
->createInstance( "com.sun.star.table.CellAddressConversion" ), uno::UNO_QUERY
);
920 Reference
< beans::XPropertySet
> xBindable( xBinding
->getValueBinding(), UNO_QUERY
);
921 if ( xBindable
.is() )
923 table::CellAddress aAddress
;
924 xBindable
->getPropertyValue( "BoundCell" ) >>= aAddress
;
925 xConvertor
->setPropertyValue( "Address", makeAny( aAddress
) );
927 xConvertor
->getPropertyValue( "PersistentRepresentation" ) >>= sAddress
;
928 if ( !sAddress
.isEmpty() )
929 addAttribute( rAttrName
, sAddress
);
931 SAL_INFO("xmlscript.xmldlg", "*** Bindable value " << sAddress
);
935 catch( uno::Exception
& )
939 Reference
< form::binding::XListEntrySink
> xEntrySink( _xProps
, UNO_QUERY
);
940 if ( xEntrySink
.is() && rAttrName
== XMLNS_DIALOGS_PREFIX
":source-cell-range" )
942 Reference
< beans::XPropertySet
> xListSource( xEntrySink
->getListEntrySource(), UNO_QUERY
);
943 if ( xListSource
.is() )
947 Reference
< beans::XPropertySet
> xConvertor( xFac
->createInstance( "com.sun.star.table.CellRangeAddressConversion" ), uno::UNO_QUERY
);
949 table::CellRangeAddress aAddress
;
950 xListSource
->getPropertyValue( "CellRange" ) >>= aAddress
;
953 xConvertor
->setPropertyValue( "Address", makeAny( aAddress
) );
954 xConvertor
->getPropertyValue( "PersistentRepresentation" ) >>= sAddress
;
955 SAL_INFO("xmlscript.xmldlg","**** cell range source list " << sAddress
);
956 if ( !sAddress
.isEmpty() )
957 addAttribute( rAttrName
, sAddress
);
959 catch( uno::Exception
& )
966 void ElementDescriptor::readSelectionTypeAttr( OUString
const & rPropName
, OUString
const & rAttrName
)
968 if (beans::PropertyState_DEFAULT_VALUE
!= _xPropState
->getPropertyState( rPropName
))
970 Any
aSelectionType ( _xProps
->getPropertyValue( rPropName
) );
972 if (aSelectionType
.getValueTypeClass() == TypeClass_ENUM
&& aSelectionType
.getValueType() == cppu::UnoType
<view::SelectionType
>::get())
974 ::view::SelectionType eSelectionType
;
975 aSelectionType
>>= eSelectionType
;
977 switch (eSelectionType
)
979 case ::view::SelectionType_NONE
:
980 addAttribute( rAttrName
, "none" );
982 case ::view::SelectionType_SINGLE
:
983 addAttribute( rAttrName
, "single" );
985 case ::view::SelectionType_MULTI
:
986 addAttribute( rAttrName
, "multi" );
988 case ::view::SelectionType_RANGE
:
989 addAttribute( rAttrName
, "range" );
992 SAL_WARN( "xmlscript.xmldlg", "### illegal selection type value!" );
999 void ElementDescriptor::readScrollableSettings()
1001 readLongAttr( "ScrollHeight",
1002 XMLNS_DIALOGS_PREFIX
":scrollheight" );
1003 readLongAttr( "ScrollWidth",
1004 XMLNS_DIALOGS_PREFIX
":scrollwidth" );
1005 readLongAttr( "ScrollTop",
1006 XMLNS_DIALOGS_PREFIX
":scrolltop" );
1007 readLongAttr( "ScrollLeft",
1008 XMLNS_DIALOGS_PREFIX
":scrollleft" );
1009 readBoolAttr( "HScroll",
1010 XMLNS_DIALOGS_PREFIX
":hscroll" );
1011 readBoolAttr( "VScroll",
1012 XMLNS_DIALOGS_PREFIX
":vscroll" );
1015 void ElementDescriptor::readImageScaleModeAttr( OUString
const & rPropName
, OUString
const & rAttrName
)
1017 if (beans::PropertyState_DEFAULT_VALUE
!= _xPropState
->getPropertyState( rPropName
))
1019 Any
aImageScaleMode( _xProps
->getPropertyValue( rPropName
) );
1021 if (aImageScaleMode
.getValueTypeClass() == TypeClass_SHORT
)
1023 sal_Int16 nImageScaleMode
;
1024 aImageScaleMode
>>= nImageScaleMode
;
1026 switch(nImageScaleMode
)
1028 case ::awt::ImageScaleMode::NONE
:
1029 addAttribute( rAttrName
, OUString( "none") );
1031 case ::awt::ImageScaleMode::ISOTROPIC
:
1032 addAttribute( rAttrName
, OUString( "isotropic") );
1034 case ::awt::ImageScaleMode::ANISOTROPIC
:
1035 addAttribute( rAttrName
, OUString( "anisotropic" ) );
1038 OSL_ENSURE( false, "### illegal image scale mode value.");
1045 void ElementDescriptor::readDefaults( bool supportPrintable
, bool supportVisible
)
1047 Any
a( _xProps
->getPropertyValue( "Name" ) );
1049 // The following is a hack to allow 'form' controls to override the default
1050 // control supported by dialogs. This should work well for both vba support and
1051 // normal openoffice ( when normal 'Dialogs' decide to support form control models )
1052 // In the future VBA support might require custom models ( and not the just the form
1053 // variant of a control that we currently use ) In this case the door is still open,
1054 // we just need to define a new way for the 'ServiceName' to be extracted from the
1055 // incoming model. E.g. the use of supporting service
1056 // "com.sun.star.form.FormComponent", 'ServiceName' and XPersistObject
1057 // is only an implementation detail here, in the future some other
1058 // method ( perhaps a custom prop ) could be used instead.
1059 Reference
< lang::XServiceInfo
> xSrvInfo( _xProps
, UNO_QUERY
);
1060 if ( xSrvInfo
.is() && xSrvInfo
->supportsService( "com.sun.star.form.FormComponent" ) )
1062 Reference
< io::XPersistObject
> xPersist( _xProps
, UNO_QUERY
);
1063 if ( xPersist
.is() )
1065 OUString sCtrlName
= xPersist
->getServiceName();
1066 if ( !sCtrlName
.isEmpty() )
1067 addAttribute( XMLNS_DIALOGS_PREFIX
":control-implementation", sCtrlName
);
1070 addAttribute( XMLNS_DIALOGS_PREFIX
":id", * static_cast< const OUString
* >( a
.getValue() ) );
1071 readShortAttr( "TabIndex", XMLNS_DIALOGS_PREFIX
":tab-index" );
1073 bool bEnabled
= false;
1074 if (_xProps
->getPropertyValue( "Enabled" ) >>= bEnabled
)
1078 addAttribute( XMLNS_DIALOGS_PREFIX
":disabled", "true" );
1083 SAL_WARN( "xmlscript.xmldlg", "unexpected property type for \"Enabled\": not bool!" );
1086 if (supportVisible
) try
1088 bool bVisible
= true;
1089 if (_xProps
->getPropertyValue("EnableVisible" ) >>= bVisible
)
1092 // only write out the non default case
1095 addAttribute( XMLNS_DIALOGS_PREFIX
":visible", "false" );
1101 DBG_UNHANDLED_EXCEPTION();
1103 // force writing of pos/size
1104 a
= _xProps
->getPropertyValue( "PositionX" );
1105 if (a
.getValueTypeClass() == TypeClass_LONG
)
1107 addAttribute( XMLNS_DIALOGS_PREFIX
":left", OUString::number( *static_cast<sal_Int32
const *>(a
.getValue()) ) );
1109 a
= _xProps
->getPropertyValue( "PositionY" );
1110 if (a
.getValueTypeClass() == TypeClass_LONG
)
1112 addAttribute( XMLNS_DIALOGS_PREFIX
":top", OUString::number( *static_cast<sal_Int32
const *>(a
.getValue()) ) );
1114 a
= _xProps
->getPropertyValue( "Width" );
1115 if (a
.getValueTypeClass() == TypeClass_LONG
)
1117 addAttribute( XMLNS_DIALOGS_PREFIX
":width", OUString::number( *static_cast<sal_Int32
const *>(a
.getValue()) ) );
1119 a
= _xProps
->getPropertyValue( "Height" );
1120 if (a
.getValueTypeClass() == TypeClass_LONG
)
1122 addAttribute( XMLNS_DIALOGS_PREFIX
":height", OUString::number( *static_cast<sal_Int32
const *>(a
.getValue()) ) );
1125 if (supportPrintable
)
1127 readBoolAttr( "Printable", XMLNS_DIALOGS_PREFIX
":printable" );
1129 readLongAttr( "Step", XMLNS_DIALOGS_PREFIX
":page" );
1130 readStringAttr( "Tag", XMLNS_DIALOGS_PREFIX
":tag" );
1131 readStringAttr( "HelpText", XMLNS_DIALOGS_PREFIX
":help-text" );
1132 readStringAttr( "HelpURL", XMLNS_DIALOGS_PREFIX
":help-url" );
1138 char const * second
;
1141 extern StringTriple
const * const g_pEventTranslations
;
1143 void ElementDescriptor::readEvents()
1145 Reference
< script::XScriptEventsSupplier
> xSupplier( _xProps
, UNO_QUERY
);
1148 Reference
< container::XNameContainer
> xEvents( xSupplier
->getEvents() );
1151 Sequence
< OUString
> aNames( xEvents
->getElementNames() );
1152 OUString
const * pNames
= aNames
.getConstArray();
1153 for ( sal_Int32 nPos
= 0; nPos
< aNames
.getLength(); ++nPos
)
1155 script::ScriptEventDescriptor descr
;
1156 if (xEvents
->getByName( pNames
[ nPos
] ) >>= 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( (sal_Unicode
)':' );
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 inline 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
.CharSet
&&
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 (f1
.Kerning
!= sal_False
) == (f2
.Kerning
!= sal_False
) &&
1258 (f1
.WordLineMode
!= sal_False
) == (f2
.WordLineMode
!= sal_False
) &&
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
) // nothin set
1269 return OUString(); // everything default: no need to export a specific style
1272 // lookup existing style
1273 for ( size_t nStylesPos
= 0; nStylesPos
< _styles
.size(); ++nStylesPos
)
1275 Style
* pStyle
= _styles
[ nStylesPos
];
1277 short demanded_defaults
= ~rStyle
._set
& rStyle
._all
;
1278 // test, if defaults are not set
1279 if ((~pStyle
->_set
& demanded_defaults
) == demanded_defaults
&&
1280 (rStyle
._set
& (pStyle
->_all
& ~pStyle
->_set
)) == 0)
1282 short bset
= rStyle
._set
& pStyle
->_set
;
1284 rStyle
._backgroundColor
!= pStyle
->_backgroundColor
)
1287 rStyle
._textColor
!= pStyle
->_textColor
)
1289 if ((bset
& 0x20) &&
1290 rStyle
._textLineColor
!= pStyle
->_textLineColor
)
1292 if ((bset
& 0x10) &&
1293 rStyle
._fillColor
!= pStyle
->_fillColor
)
1296 (rStyle
._border
!= pStyle
->_border
||
1297 (rStyle
._border
== BORDER_SIMPLE_COLOR
&&
1298 rStyle
._borderColor
!= pStyle
->_borderColor
)))
1301 !equalFont( rStyle
, *pStyle
))
1303 if ((bset
& 0x40) &&
1304 rStyle
._visualEffect
!= pStyle
->_visualEffect
)
1308 short bnset
= rStyle
._set
& ~pStyle
->_set
;
1310 pStyle
->_backgroundColor
= rStyle
._backgroundColor
;
1312 pStyle
->_textColor
= rStyle
._textColor
;
1314 pStyle
->_textLineColor
= rStyle
._textLineColor
;
1316 pStyle
->_fillColor
= rStyle
._fillColor
;
1318 pStyle
->_border
= rStyle
._border
;
1319 pStyle
->_borderColor
= rStyle
._borderColor
;
1322 pStyle
->_descr
= rStyle
._descr
;
1323 pStyle
->_fontRelief
= rStyle
._fontRelief
;
1324 pStyle
->_fontEmphasisMark
= rStyle
._fontEmphasisMark
;
1327 pStyle
->_visualEffect
= rStyle
._visualEffect
;
1329 pStyle
->_all
|= rStyle
._all
;
1330 pStyle
->_set
|= rStyle
._set
;
1336 // no appr style found, append new
1337 Style
* pStyle
= new Style( rStyle
);
1338 pStyle
->_id
= OUString::number( _styles
.size() );
1339 _styles
.push_back( pStyle
);
1343 StyleBag::~StyleBag()
1345 for ( size_t nPos
= 0; nPos
< _styles
.size(); ++nPos
)
1347 delete _styles
[ nPos
];
1351 void StyleBag::dump( Reference
< xml::sax::XExtendedDocumentHandler
> const & xOut
)
1353 if (! _styles
.empty())
1355 OUString
aStylesName( XMLNS_DIALOGS_PREFIX
":styles" );
1356 xOut
->ignorableWhitespace( OUString() );
1357 xOut
->startElement( aStylesName
, Reference
< xml::sax::XAttributeList
>() );
1359 for ( size_t nPos
= 0; nPos
< _styles
.size(); ++nPos
)
1361 Reference
< xml::sax::XAttributeList
> xAttr( _styles
[ nPos
]->createElement() );
1362 static_cast< ElementDescriptor
* >( xAttr
.get() )->dump( xOut
.get() );
1364 xOut
->ignorableWhitespace( OUString() );
1365 xOut
->endElement( aStylesName
);
1369 void SAL_CALL
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();
1387 OUString
aDocTypeStr(
1388 "<!DOCTYPE dlg:window PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\""
1389 " \"dialog.dtd\">" );
1390 xOut
->unknown( aDocTypeStr
);
1391 xOut
->ignorableWhitespace( OUString() );
1393 OUString
aWindowName( XMLNS_DIALOGS_PREFIX
":window" );
1394 ElementDescriptor
* pWindow
= new ElementDescriptor( xProps
, xPropState
, aWindowName
, xDocument
);
1395 Reference
< xml::sax::XAttributeList
> xWindow( pWindow
);
1396 pWindow
->readDialogModel( &all_styles
);
1397 xOut
->ignorableWhitespace( OUString() );
1398 xOut
->startElement( aWindowName
, xWindow
);
1400 pWindow
->dumpSubElements( xOut
.get() );
1401 // dump out stylebag
1402 all_styles
.dump( xOut
);
1404 if ( xDialogModel
->getElementNames().getLength() )
1406 // open up bulletinboard
1407 OUString
aBBoardName( XMLNS_DIALOGS_PREFIX
":bulletinboard" );
1408 xOut
->ignorableWhitespace( OUString() );
1409 xOut
->startElement( aBBoardName
, xElem
);
1411 pElem
->dumpSubElements( xOut
.get() );
1412 // end bulletinboard
1413 xOut
->ignorableWhitespace( OUString() );
1414 xOut
->endElement( aBBoardName
);
1418 xOut
->ignorableWhitespace( OUString() );
1419 xOut
->endElement( aWindowName
);
1421 xOut
->endDocument();
1426 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */