update dev300-m58
[ooovba.git] / xmlscript / source / xmldlg_imexp / xmldlg_export.cxx
blob656ead7e725820e4b16f7a1535534562c29483c5
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xmldlg_export.cxx,v $
10 * $Revision: 1.40 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmlscript.hxx"
33 #include "exp_share.hxx"
35 #include <rtl/ustrbuf.hxx>
36 #include <tools/diagnose_ex.h>
38 #include <com/sun/star/awt/CharSet.hpp>
39 #include <com/sun/star/awt/FontFamily.hpp>
40 #include <com/sun/star/awt/FontPitch.hpp>
41 #include <com/sun/star/awt/FontSlant.hpp>
42 #include <com/sun/star/awt/FontStrikeout.hpp>
43 #include <com/sun/star/awt/FontType.hpp>
44 #include <com/sun/star/awt/FontUnderline.hpp>
45 #include <com/sun/star/awt/FontWeight.hpp>
46 #include <com/sun/star/awt/FontWidth.hpp>
47 #include <com/sun/star/awt/ImagePosition.hpp>
48 #include <com/sun/star/awt/LineEndFormat.hpp>
49 #include <com/sun/star/awt/PushButtonType.hpp>
50 #include <com/sun/star/awt/VisualEffect.hpp>
52 #include <com/sun/star/script/XScriptEventsSupplier.hpp>
53 #include <com/sun/star/script/ScriptEventDescriptor.hpp>
55 #include <com/sun/star/style/VerticalAlignment.hpp>
57 #include <com/sun/star/lang/XServiceInfo.hpp>
58 #include <com/sun/star/lang/Locale.hpp>
59 #include <com/sun/star/util/NumberFormat.hpp>
61 #include <com/sun/star/view/SelectionType.hpp>
64 using namespace ::com::sun::star;
65 using namespace ::com::sun::star::uno;
66 using ::rtl::OUString;
67 using ::rtl::OUStringBuffer;
69 namespace xmlscript
72 //__________________________________________________________________________________________________
73 Reference< xml::sax::XAttributeList > Style::createElement()
75 ElementDescriptor * pStyle = new ElementDescriptor(
76 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style") ) );
78 // style-id
79 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ), _id );
81 // background-color
82 if (_set & 0x1)
84 OUStringBuffer buf( 16 );
85 buf.append( (sal_Unicode)'0' );
86 buf.append( (sal_Unicode)'x' );
87 buf.append( OUString::valueOf( (sal_Int64)(sal_uInt64)_backgroundColor, 16 ) );
88 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":background-color") ),
89 buf.makeStringAndClear() );
92 // text-color
93 if (_set & 0x2)
95 OUStringBuffer buf( 16 );
96 buf.append( (sal_Unicode)'0' );
97 buf.append( (sal_Unicode)'x' );
98 buf.append( OUString::valueOf( (sal_Int64)(sal_uInt64)_textColor, 16 ) );
99 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":text-color") ),
100 buf.makeStringAndClear() );
103 // textline-color
104 if (_set & 0x20)
106 OUStringBuffer buf( 16 );
107 buf.append( (sal_Unicode)'0' );
108 buf.append( (sal_Unicode)'x' );
109 buf.append( OUString::valueOf( (sal_Int64)(sal_uInt64)_textLineColor, 16 ) );
110 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":textline-color") ),
111 buf.makeStringAndClear() );
114 // fill-color
115 if (_set & 0x10)
117 OUStringBuffer buf( 16 );
118 buf.append( (sal_Unicode)'0' );
119 buf.append( (sal_Unicode)'x' );
120 buf.append( OUString::valueOf( (sal_Int64)(sal_uInt64)_fillColor, 16 ) );
121 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":fill-color") ),
122 buf.makeStringAndClear() );
125 // border
126 if (_set & 0x4)
128 switch (_border)
130 case BORDER_NONE:
131 pStyle->addAttribute( OUSTR(XMLNS_DIALOGS_PREFIX ":border"),
132 OUSTR("none") );
133 break;
134 case BORDER_3D:
135 pStyle->addAttribute( OUSTR(XMLNS_DIALOGS_PREFIX ":border"),
136 OUSTR("3d") );
137 break;
138 case BORDER_SIMPLE:
139 pStyle->addAttribute( OUSTR(XMLNS_DIALOGS_PREFIX ":border"),
140 OUSTR("simple") );
141 break;
142 case BORDER_SIMPLE_COLOR: {
143 OUStringBuffer buf;
144 buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("0x") );
145 buf.append( OUString::valueOf(
146 (sal_Int64)(sal_uInt64)_borderColor, 16 ) );
147 pStyle->addAttribute( OUSTR(XMLNS_DIALOGS_PREFIX ":border"),
148 buf.makeStringAndClear() );
149 break;
151 default:
152 OSL_ENSURE( 0, "### unexpected border value!" );
153 break;
157 // visual effect (look)
158 if (_set & 0x40)
160 switch (_visualEffect)
162 case awt::VisualEffect::NONE:
163 pStyle->addAttribute( OUSTR(XMLNS_DIALOGS_PREFIX ":look"),
164 OUSTR("none") );
165 break;
166 case awt::VisualEffect::LOOK3D:
167 pStyle->addAttribute( OUSTR(XMLNS_DIALOGS_PREFIX ":look"),
168 OUSTR("3d") );
169 break;
170 case awt::VisualEffect::FLAT:
171 pStyle->addAttribute( OUSTR(XMLNS_DIALOGS_PREFIX ":look"),
172 OUSTR("simple") );
173 break;
174 default:
175 OSL_ENSURE( 0, "### unexpected visual effect value!" );
176 break;
180 // font-
181 if (_set & 0x8)
183 awt::FontDescriptor def_descr;
185 // dialog:font-name CDATA #IMPLIED
186 if (def_descr.Name != _descr.Name)
188 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-name") ),
189 _descr.Name );
191 // dialog:font-height %numeric; #IMPLIED
192 if (def_descr.Height != _descr.Height)
194 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-height") ),
195 OUString::valueOf( (sal_Int32)_descr.Height ) );
197 // dialog:font-width %numeric; #IMPLIED
198 if (def_descr.Width != _descr.Width)
200 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-width") ),
201 OUString::valueOf( (sal_Int32)_descr.Width ) );
203 // dialog:font-stylename CDATA #IMPLIED
204 if (def_descr.StyleName != _descr.StyleName)
206 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-stylename") ),
207 _descr.StyleName );
209 // dialog:font-family "(decorative|modern|roman|script|swiss|system)" #IMPLIED
210 if (def_descr.Family != _descr.Family)
212 switch (_descr.Family)
214 case awt::FontFamily::DECORATIVE:
215 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-family") ),
216 OUString( RTL_CONSTASCII_USTRINGPARAM("decorative") ) );
217 break;
218 case awt::FontFamily::MODERN:
219 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-family") ),
220 OUString( RTL_CONSTASCII_USTRINGPARAM("modern") ) );
221 break;
222 case awt::FontFamily::ROMAN:
223 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-family") ),
224 OUString( RTL_CONSTASCII_USTRINGPARAM("roman") ) );
225 break;
226 case awt::FontFamily::SCRIPT:
227 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-family") ),
228 OUString( RTL_CONSTASCII_USTRINGPARAM("script") ) );
229 break;
230 case awt::FontFamily::SWISS:
231 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-family") ),
232 OUString( RTL_CONSTASCII_USTRINGPARAM("swiss") ) );
233 break;
234 case awt::FontFamily::SYSTEM:
235 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-family") ),
236 OUString( RTL_CONSTASCII_USTRINGPARAM("system") ) );
237 break;
238 default:
239 OSL_ENSURE( 0, "### unexpected font-family!" );
240 break;
243 // dialog:font-charset "(ansi|mac|ibmpc_437|ibmpc_850|ibmpc_860|ibmpc_861|ibmpc_863|ibmpc_865|system|symbol)" #IMPLIED
244 if (def_descr.CharSet != _descr.CharSet)
246 switch (_descr.CharSet)
248 case awt::CharSet::ANSI:
249 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ),
250 OUString( RTL_CONSTASCII_USTRINGPARAM("ansi") ) );
251 break;
252 case awt::CharSet::MAC:
253 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ),
254 OUString( RTL_CONSTASCII_USTRINGPARAM("mac") ) );
255 break;
256 case awt::CharSet::IBMPC_437:
257 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ),
258 OUString( RTL_CONSTASCII_USTRINGPARAM("ibmpc_437") ) );
259 break;
260 case awt::CharSet::IBMPC_850:
261 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ),
262 OUString( RTL_CONSTASCII_USTRINGPARAM("ibmpc_850") ) );
263 break;
264 case awt::CharSet::IBMPC_860:
265 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ),
266 OUString( RTL_CONSTASCII_USTRINGPARAM("ibmpc_860") ) );
267 break;
268 case awt::CharSet::IBMPC_861:
269 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ),
270 OUString( RTL_CONSTASCII_USTRINGPARAM("ibmpc_861") ) );
271 break;
272 case awt::CharSet::IBMPC_863:
273 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ),
274 OUString( RTL_CONSTASCII_USTRINGPARAM("ibmpc_863") ) );
275 break;
276 case awt::CharSet::IBMPC_865:
277 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ),
278 OUString( RTL_CONSTASCII_USTRINGPARAM("ibmpc_865") ) );
279 break;
280 case awt::CharSet::SYSTEM:
281 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ),
282 OUString( RTL_CONSTASCII_USTRINGPARAM("system") ) );
283 break;
284 case awt::CharSet::SYMBOL:
285 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ),
286 OUString( RTL_CONSTASCII_USTRINGPARAM("symbol") ) );
287 break;
288 default:
289 OSL_ENSURE( 0, "### unexpected font-charset!" );
290 break;
293 // dialog:font-pitch "(fixed|variable)" #IMPLIED
294 if (def_descr.Pitch != _descr.Pitch)
296 switch (_descr.Pitch)
298 case awt::FontPitch::FIXED:
299 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-pitch") ),
300 OUString( RTL_CONSTASCII_USTRINGPARAM("fixed") ) );
301 break;
302 case awt::FontPitch::VARIABLE:
303 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-pitch") ),
304 OUString( RTL_CONSTASCII_USTRINGPARAM("variable") ) );
305 break;
306 default:
307 OSL_ENSURE( 0, "### unexpected font-pitch!" );
308 break;
311 // dialog:font-charwidth CDATA #IMPLIED
312 if (def_descr.CharacterWidth != _descr.CharacterWidth)
314 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charwidth") ),
315 OUString::valueOf( (float)_descr.CharacterWidth ) );
317 // dialog:font-weight CDATA #IMPLIED
318 if (def_descr.Weight != _descr.Weight)
320 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-weight") ),
321 OUString::valueOf( (float)_descr.Weight ) );
323 // dialog:font-slant "(oblique|italic|reverse_oblique|reverse_italic)" #IMPLIED
324 if (def_descr.Slant != _descr.Slant)
326 switch (_descr.Slant)
328 case awt::FontSlant_OBLIQUE:
329 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-slant") ),
330 OUString( RTL_CONSTASCII_USTRINGPARAM("oblique") ) );
331 break;
332 case awt::FontSlant_ITALIC:
333 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-slant") ),
334 OUString( RTL_CONSTASCII_USTRINGPARAM("italic") ) );
335 break;
336 case awt::FontSlant_REVERSE_OBLIQUE:
337 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-slant") ),
338 OUString( RTL_CONSTASCII_USTRINGPARAM("reverse_oblique") ) );
339 break;
340 case awt::FontSlant_REVERSE_ITALIC:
341 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-slant") ),
342 OUString( RTL_CONSTASCII_USTRINGPARAM("reverse_italic") ) );
343 break;
344 default:
345 OSL_ENSURE( 0, "### unexpected font-slant!" );
346 break;
349 // dialog:font-underline "(single|double|dotted|dash|longdash|dashdot|dashdotdot|smallwave|wave|doublewave|bold|bolddotted|bolddash|boldlongdash|bolddashdot|bolddashdotdot|boldwave)" #IMPLIED
350 if (def_descr.Underline != _descr.Underline)
352 switch (_descr.Underline)
354 case awt::FontUnderline::SINGLE:
355 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
356 OUString( RTL_CONSTASCII_USTRINGPARAM("single") ) );
357 break;
358 case awt::FontUnderline::DOUBLE:
359 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
360 OUString( RTL_CONSTASCII_USTRINGPARAM("double") ) );
361 break;
362 case awt::FontUnderline::DOTTED:
363 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
364 OUString( RTL_CONSTASCII_USTRINGPARAM("dotted") ) );
365 break;
366 case awt::FontUnderline::DASH:
367 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
368 OUString( RTL_CONSTASCII_USTRINGPARAM("dash") ) );
369 break;
370 case awt::FontUnderline::LONGDASH:
371 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
372 OUString( RTL_CONSTASCII_USTRINGPARAM("longdash") ) );
373 break;
374 case awt::FontUnderline::DASHDOT:
375 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
376 OUString( RTL_CONSTASCII_USTRINGPARAM("dashdot") ) );
377 break;
378 case awt::FontUnderline::DASHDOTDOT:
379 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
380 OUString( RTL_CONSTASCII_USTRINGPARAM("dashdotdot") ) );
381 break;
382 case awt::FontUnderline::SMALLWAVE:
383 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
384 OUString( RTL_CONSTASCII_USTRINGPARAM("smallwave") ) );
385 break;
386 case awt::FontUnderline::WAVE:
387 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
388 OUString( RTL_CONSTASCII_USTRINGPARAM("wave") ) );
389 break;
390 case awt::FontUnderline::DOUBLEWAVE:
391 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
392 OUString( RTL_CONSTASCII_USTRINGPARAM("doublewave") ) );
393 break;
394 case awt::FontUnderline::BOLD:
395 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
396 OUString( RTL_CONSTASCII_USTRINGPARAM("bold") ) );
397 break;
398 case awt::FontUnderline::BOLDDOTTED:
399 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
400 OUString( RTL_CONSTASCII_USTRINGPARAM("bolddotted") ) );
401 break;
402 case awt::FontUnderline::BOLDDASH:
403 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
404 OUString( RTL_CONSTASCII_USTRINGPARAM("bolddash") ) );
405 break;
406 case awt::FontUnderline::BOLDLONGDASH:
407 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
408 OUString( RTL_CONSTASCII_USTRINGPARAM("boldlongdash") ) );
409 break;
410 case awt::FontUnderline::BOLDDASHDOT:
411 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
412 OUString( RTL_CONSTASCII_USTRINGPARAM("bolddashdot") ) );
413 break;
414 case awt::FontUnderline::BOLDDASHDOTDOT:
415 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
416 OUString( RTL_CONSTASCII_USTRINGPARAM("bolddashdotdot") ) );
417 break;
418 case awt::FontUnderline::BOLDWAVE:
419 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
420 OUString( RTL_CONSTASCII_USTRINGPARAM("boldwave") ) );
421 break;
422 default:
423 OSL_ENSURE( 0, "### unexpected font-underline!" );
424 break;
427 // dialog:font-strikeout "(single|double|bold|slash|x)" #IMPLIED
428 if (def_descr.Strikeout != _descr.Strikeout)
430 switch (_descr.Strikeout)
432 case awt::FontStrikeout::SINGLE:
433 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-strikeout") ),
434 OUString( RTL_CONSTASCII_USTRINGPARAM("single") ) );
435 break;
436 case awt::FontStrikeout::DOUBLE:
437 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-strikeout") ),
438 OUString( RTL_CONSTASCII_USTRINGPARAM("double") ) );
439 break;
440 case awt::FontStrikeout::BOLD:
441 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-strikeout") ),
442 OUString( RTL_CONSTASCII_USTRINGPARAM("bold") ) );
443 break;
444 case awt::FontStrikeout::SLASH:
445 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-strikeout") ),
446 OUString( RTL_CONSTASCII_USTRINGPARAM("slash") ) );
447 break;
448 case awt::FontStrikeout::X:
449 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-strikeout") ),
450 OUString( RTL_CONSTASCII_USTRINGPARAM("x") ) );
451 break;
452 default:
453 OSL_ENSURE( 0, "### unexpected font-strikeout!" );
454 break;
457 // dialog:font-orientation CDATA #IMPLIED
458 if (def_descr.Orientation != _descr.Orientation)
460 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-orientation") ),
461 OUString::valueOf( (float)_descr.Orientation ) );
463 // dialog:font-kerning %boolean; #IMPLIED
464 if ((def_descr.Kerning != sal_False) != (_descr.Kerning != sal_False))
466 pStyle->addBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-kerning") ),
467 _descr.Kerning );
469 // dialog:font-wordlinemode %boolean; #IMPLIED
470 if ((def_descr.WordLineMode != sal_False) != (_descr.WordLineMode != sal_False))
472 pStyle->addBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-wordlinemode") ),
473 _descr.WordLineMode );
475 // dialog:font-type "(raster|device|scalable)" #IMPLIED
476 if (def_descr.Type != _descr.Type)
478 switch (_descr.Type)
480 case awt::FontType::RASTER:
481 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-type") ),
482 OUString( RTL_CONSTASCII_USTRINGPARAM("raster") ) );
483 break;
484 case awt::FontType::DEVICE:
485 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-type") ),
486 OUString( RTL_CONSTASCII_USTRINGPARAM("device") ) );
487 break;
488 case awt::FontType::SCALABLE:
489 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-type") ),
490 OUString( RTL_CONSTASCII_USTRINGPARAM("scalable") ) );
491 break;
492 default:
493 OSL_ENSURE( 0, "### unexpected font-type!" );
494 break;
498 // additional attributes not in FontDescriptor struct
499 // dialog:font-relief (none|embossed|engraved) #IMPLIED
500 switch (_fontRelief)
502 case awt::FontRelief::NONE: // dont export default
503 break;
504 case awt::FontRelief::EMBOSSED:
505 pStyle->addAttribute(
506 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-relief") ),
507 OUString( RTL_CONSTASCII_USTRINGPARAM("embossed") ) );
508 break;
509 case awt::FontRelief::ENGRAVED:
510 pStyle->addAttribute(
511 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-relief") ),
512 OUString( RTL_CONSTASCII_USTRINGPARAM("engraved") ) );
513 break;
514 default:
515 OSL_ENSURE( 0, "### unexpected font-relief!" );
516 break;
518 // dialog:font-emphasismark (none|dot|circle|disc|accent|above|below) #IMPLIED
519 switch (_fontEmphasisMark)
521 case awt::FontEmphasisMark::NONE: // dont export default
522 break;
523 case awt::FontEmphasisMark::DOT:
524 pStyle->addAttribute(
525 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-emphasismark") ),
526 OUString( RTL_CONSTASCII_USTRINGPARAM("dot") ) );
527 break;
528 case awt::FontEmphasisMark::CIRCLE:
529 pStyle->addAttribute(
530 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-emphasismark") ),
531 OUString( RTL_CONSTASCII_USTRINGPARAM("circle") ) );
532 break;
533 case awt::FontEmphasisMark::DISC:
534 pStyle->addAttribute(
535 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-emphasismark") ),
536 OUString( RTL_CONSTASCII_USTRINGPARAM("disc") ) );
537 break;
538 case awt::FontEmphasisMark::ACCENT:
539 pStyle->addAttribute(
540 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-emphasismark") ),
541 OUString( RTL_CONSTASCII_USTRINGPARAM("accent") ) );
542 break;
543 case awt::FontEmphasisMark::ABOVE:
544 pStyle->addAttribute(
545 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-emphasismark") ),
546 OUString( RTL_CONSTASCII_USTRINGPARAM("above") ) );
547 break;
548 case awt::FontEmphasisMark::BELOW:
549 pStyle->addAttribute(
550 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-emphasismark") ),
551 OUString( RTL_CONSTASCII_USTRINGPARAM("below") ) );
552 break;
553 default:
554 OSL_ENSURE( 0, "### unexpected font-emphasismark!" );
555 break;
559 return pStyle;
562 //##################################################################################################
564 //__________________________________________________________________________________________________
565 void ElementDescriptor::addNumberFormatAttr(
566 Reference< beans::XPropertySet > const & xFormatProperties,
567 OUString const & /*rAttrName*/ )
569 Reference< beans::XPropertyState > xState( xFormatProperties, UNO_QUERY );
570 OUString sFormat;
571 lang::Locale locale;
572 OSL_VERIFY( xFormatProperties->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("FormatString") ) ) >>= sFormat );
573 OSL_VERIFY( xFormatProperties->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Locale") ) ) >>= locale );
575 addAttribute(
576 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":format-code") ),
577 sFormat );
579 // format-locale
580 OUStringBuffer buf( 48 );
581 buf.append( locale.Language );
582 if (locale.Country.getLength())
584 buf.append( (sal_Unicode)';' );
585 buf.append( locale.Country );
586 if (locale.Variant.getLength())
588 buf.append( (sal_Unicode)';' );
589 buf.append( locale.Variant );
592 addAttribute(
593 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":format-locale") ),
594 buf.makeStringAndClear() );
596 //__________________________________________________________________________________________________
597 Any ElementDescriptor::readProp( OUString const & rPropName )
599 if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
601 return _xProps->getPropertyValue( rPropName );
603 return Any();
606 //______________________________________________________________________________
607 void ElementDescriptor::readStringAttr(
608 OUString const & rPropName, OUString const & rAttrName )
610 if (beans::PropertyState_DEFAULT_VALUE !=
611 _xPropState->getPropertyState( rPropName ))
613 Any a( _xProps->getPropertyValue( rPropName ) );
614 OUString v;
615 if (a >>= v)
616 addAttribute( rAttrName, v );
617 else
618 OSL_ENSURE( 0, "### unexpected property type!" );
622 //__________________________________________________________________________________________________
623 void ElementDescriptor::readHexLongAttr( OUString const & rPropName, OUString const & rAttrName )
625 if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
627 Any a( _xProps->getPropertyValue( rPropName ) );
628 if (a.getValueTypeClass() == TypeClass_LONG)
630 OUStringBuffer buf( 16 );
631 buf.append( (sal_Unicode)'0' );
632 buf.append( (sal_Unicode)'x' );
633 buf.append( OUString::valueOf( (sal_Int64)(sal_uInt64)*(sal_uInt32 *)a.getValue(), 16 ) );
634 addAttribute( rAttrName, buf.makeStringAndClear() );
639 //__________________________________________________________________________________________________
640 void ElementDescriptor::readDateFormatAttr( OUString const & rPropName, OUString const & rAttrName )
642 if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
644 Any a( _xProps->getPropertyValue( rPropName ) );
645 if (a.getValueTypeClass() == TypeClass_SHORT)
647 switch (*(sal_Int16 const *)a.getValue())
649 case 0:
650 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("system_short") ) );
651 break;
652 case 1:
653 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("system_short_YY") ) );
654 break;
655 case 2:
656 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("system_short_YYYY") ) );
657 break;
658 case 3:
659 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("system_long") ) );
660 break;
661 case 4:
662 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("short_DDMMYY") ) );
663 break;
664 case 5:
665 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("short_MMDDYY") ) );
666 break;
667 case 6:
668 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("short_YYMMDD") ) );
669 break;
670 case 7:
671 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("short_DDMMYYYY") ) );
672 break;
673 case 8:
674 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("short_MMDDYYYY") ) );
675 break;
676 case 9:
677 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("short_YYYYMMDD") ) );
678 break;
679 case 10:
680 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("short_YYMMDD_DIN5008") ) );
681 break;
682 case 11:
683 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("short_YYYYMMDD_DIN5008") ) );
684 break;
685 default:
686 OSL_ENSURE( 0, "### unexpected date format!" );
687 break;
692 //__________________________________________________________________________________________________
693 void ElementDescriptor::readTimeFormatAttr( OUString const & rPropName, OUString const & rAttrName )
695 if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
697 Any a( _xProps->getPropertyValue( rPropName ) );
698 if (a.getValueTypeClass() == TypeClass_SHORT)
700 switch (*(sal_Int16 const *)a.getValue())
702 case 0:
703 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("24h_short") ) );
704 break;
705 case 1:
706 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("24h_long") ) );
707 break;
708 case 2:
709 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("12h_short") ) );
710 break;
711 case 3:
712 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("12h_long") ) );
713 break;
714 case 4:
715 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("Duration_short") ) );
716 break;
717 case 5:
718 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("Duration_long") ) );
719 break;
720 default:
721 OSL_ENSURE( 0, "### unexpected time format!" );
722 break;
727 //__________________________________________________________________________________________________
728 void ElementDescriptor::readAlignAttr( OUString const & rPropName, OUString const & rAttrName )
730 if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
732 Any a( _xProps->getPropertyValue( rPropName ) );
733 if (a.getValueTypeClass() == TypeClass_SHORT)
735 switch (*(sal_Int16 const *)a.getValue())
737 case 0:
738 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("left") ) );
739 break;
740 case 1:
741 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("center") ) );
742 break;
743 case 2:
744 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("right") ) );
745 break;
746 default:
747 OSL_ENSURE( 0, "### illegal alignment value!" );
748 break;
753 //__________________________________________________________________________________________________
754 void ElementDescriptor::readVerticalAlignAttr( OUString const & rPropName, OUString const & rAttrName )
756 if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
758 Any a( _xProps->getPropertyValue( rPropName ) );
759 if (a.getValueTypeClass() == TypeClass_ENUM && a.getValueType() == ::getCppuType( (style::VerticalAlignment*)0 ))
761 style::VerticalAlignment eAlign;
762 a >>= eAlign;
763 switch (eAlign)
765 case style::VerticalAlignment_TOP:
766 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("top") ) );
767 break;
768 case style::VerticalAlignment_MIDDLE:
769 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("center") ) );
770 break;
771 case style::VerticalAlignment_BOTTOM:
772 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("bottom") ) );
773 break;
774 default:
775 OSL_ENSURE( 0, "### illegal vertical alignment value!" );
776 break;
781 //__________________________________________________________________________________________________
782 void ElementDescriptor::readImageAlignAttr( OUString const & rPropName, OUString const & rAttrName )
784 if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
786 Any a( _xProps->getPropertyValue( rPropName ) );
787 if (a.getValueTypeClass() == TypeClass_SHORT)
789 switch (*(sal_Int16 const *)a.getValue())
791 case 0:
792 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("left") ) );
793 break;
794 case 1:
795 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("top") ) );
796 break;
797 case 2:
798 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("right") ) );
799 break;
800 case 3:
801 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("bottom") ) );
802 break;
803 default:
804 OSL_ENSURE( 0, "### illegal image alignment value!" );
805 break;
810 //__________________________________________________________________________________________________
811 void ElementDescriptor::readImagePositionAttr( OUString const & rPropName, OUString const & rAttrName )
813 if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
815 Any a( _xProps->getPropertyValue( rPropName ) );
816 if (a.getValueTypeClass() == TypeClass_SHORT)
818 switch (*(sal_Int16 const *)a.getValue())
820 case awt::ImagePosition::LeftTop:
821 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("left-top") ) );
822 break;
823 case awt::ImagePosition::LeftCenter:
824 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("left-center") ) );
825 break;
826 case awt::ImagePosition::LeftBottom:
827 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("left-bottom") ) );
828 break;
829 case awt::ImagePosition::RightTop:
830 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("right-top") ) );
831 break;
832 case awt::ImagePosition::RightCenter:
833 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("right-center") ) );
834 break;
835 case awt::ImagePosition::RightBottom:
836 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("right-bottom") ) );
837 break;
838 case awt::ImagePosition::AboveLeft:
839 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("top-left") ) );
840 break;
841 case awt::ImagePosition::AboveCenter:
842 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("top-center") ) );
843 break;
844 case awt::ImagePosition::AboveRight:
845 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("top-right") ) );
846 break;
847 case awt::ImagePosition::BelowLeft:
848 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("bottom-left") ) );
849 break;
850 case awt::ImagePosition::BelowCenter:
851 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("bottom-center") ) );
852 break;
853 case awt::ImagePosition::BelowRight:
854 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("bottom-right") ) );
855 break;
856 case awt::ImagePosition::Centered:
857 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("center") ) );
858 break;
859 default:
860 OSL_ENSURE( 0, "### illegal image position value!" );
861 break;
866 //__________________________________________________________________________________________________
867 void ElementDescriptor::readButtonTypeAttr( OUString const & rPropName, OUString const & rAttrName )
869 if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
871 Any a( _xProps->getPropertyValue( rPropName ) );
872 if (a.getValueTypeClass() == TypeClass_SHORT)
874 switch (*(sal_Int16 const *)a.getValue())
876 case awt::PushButtonType_STANDARD:
877 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("standard") ) );
878 break;
879 case awt::PushButtonType_OK:
880 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("ok") ) );
881 break;
882 case awt::PushButtonType_CANCEL:
883 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("cancel") ) );
884 break;
885 case awt::PushButtonType_HELP:
886 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("help") ) );
887 break;
888 default:
889 OSL_ENSURE( 0, "### illegal button-type value!" );
890 break;
895 //__________________________________________________________________________________________________
896 void ElementDescriptor::readOrientationAttr( OUString const & rPropName, OUString const & rAttrName )
898 if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
900 Any a( _xProps->getPropertyValue( rPropName ) );
901 if (a.getValueTypeClass() == TypeClass_LONG)
903 switch (*(sal_Int32 const *)a.getValue())
905 case 0:
906 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("horizontal") ) );
907 break;
908 case 1:
909 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("vertical") ) );
910 break;
911 default:
912 OSL_ENSURE( 0, "### illegal orientation value!" );
913 break;
918 //__________________________________________________________________________________________________
919 void ElementDescriptor::readLineEndFormatAttr( OUString const & rPropName, OUString const & rAttrName )
921 if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
923 Any a( _xProps->getPropertyValue( rPropName ) );
924 if (a.getValueTypeClass() == TypeClass_SHORT)
926 switch (*(sal_Int16 const *)a.getValue())
928 case awt::LineEndFormat::CARRIAGE_RETURN:
929 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("carriage-return") ) );
930 break;
931 case awt::LineEndFormat::LINE_FEED:
932 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("line-feed") ) );
933 break;
934 case awt::LineEndFormat::CARRIAGE_RETURN_LINE_FEED:
935 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("carriage-return-line-feed") ) );
936 break;
937 default:
938 OSL_ENSURE( 0, "### illegal line end format value!" );
939 break;
944 //__________________________________________________________________________________________________
945 void ElementDescriptor::readSelectionTypeAttr( OUString const & rPropName, OUString const & rAttrName )
947 if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
949 Any aSelectionType ( _xProps->getPropertyValue( rPropName ) );
951 if (aSelectionType.getValueTypeClass() == TypeClass_ENUM && aSelectionType.getValueType() == ::getCppuType( (::view::SelectionType*)0 ))
953 ::view::SelectionType eSelectionType;
954 aSelectionType >>= eSelectionType;
956 switch (eSelectionType)
958 case ::view::SelectionType_NONE:
959 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("none") ) );
960 break;
961 case ::view::SelectionType_SINGLE:
962 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("single") ) );
963 break;
964 case ::view::SelectionType_MULTI:
965 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("multi") ) );
966 break;
967 case ::view::SelectionType_RANGE:
968 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("range") ) );
969 break;
970 default:
971 OSL_ENSURE( 0, "### illegal selection type value!" );
972 break;
977 //__________________________________________________________________________________________________
978 void ElementDescriptor::readDefaults( bool supportPrintable )
980 Any a( _xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Name") ) ) );
981 addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ),
982 * reinterpret_cast< const OUString * >( a.getValue() ) );
983 readShortAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("TabIndex") ),
984 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":tab-index") ) );
986 sal_Bool bEnabled = sal_False;
987 if (_xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Enabled") ) ) >>= bEnabled)
989 if (! bEnabled)
991 addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":disabled") ),
992 OUString( RTL_CONSTASCII_USTRINGPARAM("true") ) );
995 else
997 OSL_ENSURE( 0, "unexpected property type for \"Enabled\": not bool!" );
1000 sal_Bool bVisible = sal_True;
1003 if (_xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("EnableVisible") ) ) >>= bVisible)
1006 // only write out the non default case
1007 if (! bVisible)
1009 addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":visible") ),
1010 OUString( RTL_CONSTASCII_USTRINGPARAM("false") ) );
1014 catch( Exception& )
1016 DBG_UNHANDLED_EXCEPTION();
1018 // force writing of pos/size
1019 a = _xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("PositionX") ) );
1020 if (a.getValueTypeClass() == TypeClass_LONG)
1022 addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":left") ),
1023 OUString::valueOf( *(sal_Int32 const *)a.getValue() ) );
1025 a = _xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("PositionY") ) );
1026 if (a.getValueTypeClass() == TypeClass_LONG)
1028 addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":top") ),
1029 OUString::valueOf( *(sal_Int32 const *)a.getValue() ) );
1031 a = _xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Width") ) );
1032 if (a.getValueTypeClass() == TypeClass_LONG)
1034 addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":width") ),
1035 OUString::valueOf( *(sal_Int32 const *)a.getValue() ) );
1037 a = _xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Height") ) );
1038 if (a.getValueTypeClass() == TypeClass_LONG)
1040 addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":height") ),
1041 OUString::valueOf( *(sal_Int32 const *)a.getValue() ) );
1044 if (supportPrintable)
1046 readBoolAttr(
1047 OUString( RTL_CONSTASCII_USTRINGPARAM("Printable") ),
1048 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":printable") ) );
1050 readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Step") ),
1051 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":page") ) );
1052 readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Tag") ),
1053 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":tag") ) );
1054 readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("HelpText") ),
1055 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":help-text") ) );
1056 readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("HelpURL") ),
1057 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":help-url") ) );
1060 struct StringTriple
1062 char const * first;
1063 char const * second;
1064 char const * third;
1066 extern StringTriple const * const g_pEventTranslations;
1068 //__________________________________________________________________________________________________
1069 void ElementDescriptor::readEvents()
1070 SAL_THROW( (Exception) )
1072 Reference< script::XScriptEventsSupplier > xSupplier( _xProps, UNO_QUERY );
1073 if (xSupplier.is())
1075 Reference< container::XNameContainer > xEvents( xSupplier->getEvents() );
1076 if (xEvents.is())
1078 Sequence< OUString > aNames( xEvents->getElementNames() );
1079 OUString const * pNames = aNames.getConstArray();
1080 for ( sal_Int32 nPos = 0; nPos < aNames.getLength(); ++nPos )
1082 script::ScriptEventDescriptor descr;
1083 if (xEvents->getByName( pNames[ nPos ] ) >>= descr)
1085 OSL_ENSURE( descr.ListenerType.getLength() > 0 &&
1086 descr.EventMethod.getLength() > 0 &&
1087 descr.ScriptCode.getLength() > 0 &&
1088 descr.ScriptType.getLength() > 0,
1089 "### invalid event descr!" );
1091 OUString aEventName;
1093 if (! descr.AddListenerParam.getLength())
1095 // detection of event-name
1096 ::rtl::OString listenerType(
1097 ::rtl::OUStringToOString(
1098 descr.ListenerType,
1099 RTL_TEXTENCODING_ASCII_US ) );
1100 ::rtl::OString eventMethod(
1101 ::rtl::OUStringToOString(
1102 descr.EventMethod,
1103 RTL_TEXTENCODING_ASCII_US ) );
1104 StringTriple const * p = g_pEventTranslations;
1105 while (p->first)
1107 if (0 == ::rtl_str_compare( p->second, eventMethod.getStr() ) &&
1108 0 == ::rtl_str_compare( p->first, listenerType.getStr() ))
1110 aEventName = OUString( p->third, ::rtl_str_getLength( p->third ), RTL_TEXTENCODING_ASCII_US );
1111 break;
1113 ++p;
1117 ElementDescriptor * pElem;
1118 Reference< xml::sax::XAttributeList > xElem;
1120 if (aEventName.getLength()) // script:event
1122 pElem = new ElementDescriptor(
1123 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":event") ) );
1124 xElem = pElem;
1126 pElem->addAttribute(
1127 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":event-name") ),
1128 aEventName );
1130 else // script:listener-event
1132 pElem = new ElementDescriptor(
1133 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":listener-event") ) );
1134 xElem = pElem;
1136 pElem->addAttribute(
1137 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":listener-type") ),
1138 descr.ListenerType );
1139 pElem->addAttribute(
1140 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":listener-method") ),
1141 descr.EventMethod );
1143 if (descr.AddListenerParam.getLength())
1145 pElem->addAttribute(
1146 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":listener-param") ),
1147 descr.AddListenerParam );
1150 if ( descr.ScriptType.equals( OUString( RTL_CONSTASCII_USTRINGPARAM( "StarBasic" ) ) ) )
1152 // separate optional location
1153 sal_Int32 nIndex = descr.ScriptCode.indexOf( (sal_Unicode)':' );
1154 if (nIndex >= 0)
1156 pElem->addAttribute(
1157 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":location") ),
1158 descr.ScriptCode.copy( 0, nIndex ) );
1159 pElem->addAttribute(
1160 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":macro-name") ),
1161 descr.ScriptCode.copy( nIndex +1 ) );
1163 else
1165 pElem->addAttribute(
1166 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":macro-name") ),
1167 descr.ScriptCode );
1170 else
1172 pElem->addAttribute(
1173 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":macro-name") ),
1174 descr.ScriptCode );
1177 // language
1178 pElem->addAttribute(
1179 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":language") ),
1180 descr.ScriptType );
1182 addSubElement( xElem );
1184 else
1186 OSL_ENSURE( 0, "### unexpected event type in container!" );
1193 //##################################################################################################
1195 inline bool equalFont( Style const & style1, Style const & style2 )
1197 awt::FontDescriptor const & f1 = style1._descr;
1198 awt::FontDescriptor const & f2 = style2._descr;
1199 return (
1200 f1.Name == f2.Name &&
1201 f1.Height == f2.Height &&
1202 f1.Width == f2.Width &&
1203 f1.StyleName == f2.StyleName &&
1204 f1.Family == f2.Family &&
1205 f1.CharSet == f2.CharSet &&
1206 f1.Pitch == f2.CharSet &&
1207 f1.CharacterWidth == f2.CharacterWidth &&
1208 f1.Weight == f2.Weight &&
1209 f1.Slant == f2.Slant &&
1210 f1.Underline == f2.Underline &&
1211 f1.Strikeout == f2.Strikeout &&
1212 f1.Orientation == f2.Orientation &&
1213 (f1.Kerning != sal_False) == (f2.Kerning != sal_False) &&
1214 (f1.WordLineMode != sal_False) == (f2.WordLineMode != sal_False) &&
1215 f1.Type == f2.Type &&
1216 style1._fontRelief == style2._fontRelief &&
1217 style1._fontEmphasisMark == style2._fontEmphasisMark
1220 //__________________________________________________________________________________________________
1221 OUString StyleBag::getStyleId( Style const & rStyle )
1222 SAL_THROW( () )
1224 if (! rStyle._set) // nothin set
1226 return OUString(); // everything default: no need to export a specific style
1229 // lookup existing style
1230 for ( size_t nStylesPos = 0; nStylesPos < _styles.size(); ++nStylesPos )
1232 Style * pStyle = _styles[ nStylesPos ];
1234 short demanded_defaults = ~rStyle._set & rStyle._all;
1235 // test, if defaults are not set
1236 if ((~pStyle->_set & demanded_defaults) == demanded_defaults &&
1237 (rStyle._set & (pStyle->_all & ~pStyle->_set)) == 0)
1239 short bset = rStyle._set & pStyle->_set;
1240 if ((bset & 0x1) &&
1241 rStyle._backgroundColor != pStyle->_backgroundColor)
1242 continue;
1243 if ((bset & 0x2) &&
1244 rStyle._textColor != pStyle->_textColor)
1245 continue;
1246 if ((bset & 0x20) &&
1247 rStyle._textLineColor != pStyle->_textLineColor)
1248 continue;
1249 if ((bset & 0x10) &&
1250 rStyle._fillColor != pStyle->_fillColor)
1251 continue;
1252 if ((bset & 0x4) &&
1253 (rStyle._border != pStyle->_border ||
1254 (rStyle._border == BORDER_SIMPLE_COLOR &&
1255 rStyle._borderColor != pStyle->_borderColor)))
1256 continue;
1257 if ((bset & 0x8) &&
1258 !equalFont( rStyle, *pStyle ))
1259 continue;
1260 if ((bset & 0x40) &&
1261 rStyle._visualEffect != pStyle->_visualEffect)
1262 continue;
1264 // merge in
1265 short bnset = rStyle._set & ~pStyle->_set;
1266 if (bnset & 0x1)
1267 pStyle->_backgroundColor = rStyle._backgroundColor;
1268 if (bnset & 0x2)
1269 pStyle->_textColor = rStyle._textColor;
1270 if (bnset & 0x20)
1271 pStyle->_textLineColor = rStyle._textLineColor;
1272 if (bnset & 0x10)
1273 pStyle->_fillColor = rStyle._fillColor;
1274 if (bnset & 0x4) {
1275 pStyle->_border = rStyle._border;
1276 pStyle->_borderColor = rStyle._borderColor;
1278 if (bnset & 0x8) {
1279 pStyle->_descr = rStyle._descr;
1280 pStyle->_fontRelief = rStyle._fontRelief;
1281 pStyle->_fontEmphasisMark = rStyle._fontEmphasisMark;
1283 if (bnset & 0x40)
1284 pStyle->_visualEffect = rStyle._visualEffect;
1286 pStyle->_all |= rStyle._all;
1287 pStyle->_set |= rStyle._set;
1289 return pStyle->_id;
1293 // no appr style found, append new
1294 Style * pStyle = new Style( rStyle );
1295 pStyle->_id = OUString::valueOf( (sal_Int32)_styles.size() );
1296 _styles.push_back( pStyle );
1297 return pStyle->_id;
1299 //__________________________________________________________________________________________________
1300 StyleBag::~StyleBag() SAL_THROW( () )
1302 for ( size_t nPos = 0; nPos < _styles.size(); ++nPos )
1304 delete _styles[ nPos ];
1307 //__________________________________________________________________________________________________
1308 void StyleBag::dump( Reference< xml::sax::XExtendedDocumentHandler > const & xOut )
1310 if (! _styles.empty())
1312 OUString aStylesName( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":styles") );
1313 xOut->ignorableWhitespace( OUString() );
1314 xOut->startElement( aStylesName, Reference< xml::sax::XAttributeList >() );
1315 // export styles
1316 for ( size_t nPos = 0; nPos < _styles.size(); ++nPos )
1318 Reference< xml::sax::XAttributeList > xAttr( _styles[ nPos ]->createElement() );
1319 static_cast< ElementDescriptor * >( xAttr.get() )->dump( xOut.get() );
1321 xOut->ignorableWhitespace( OUString() );
1322 xOut->endElement( aStylesName );
1326 //##################################################################################################
1328 //==================================================================================================
1329 void SAL_CALL exportDialogModel(
1330 Reference< xml::sax::XExtendedDocumentHandler > const & xOut,
1331 Reference< container::XNameContainer > const & xDialogModel,
1332 Reference< frame::XModel > const & xDocument )
1333 SAL_THROW( (Exception) )
1335 StyleBag all_styles;
1336 ::std::vector< Reference< xml::sax::XAttributeList > > all_elements;
1338 // read out all props
1340 Sequence< OUString > aElements( xDialogModel->getElementNames() );
1341 OUString const * pElements = aElements.getConstArray();
1343 ElementDescriptor * pRadioGroup = 0;
1345 sal_Int32 nPos;
1346 for ( nPos = 0; nPos < aElements.getLength(); ++nPos )
1348 Any aControlModel( xDialogModel->getByName( pElements[ nPos ] ) );
1349 Reference< beans::XPropertySet > xProps;
1350 OSL_VERIFY( aControlModel >>= xProps );
1351 if (! xProps.is())
1352 continue;
1353 Reference< beans::XPropertyState > xPropState( xProps, UNO_QUERY );
1354 OSL_ENSURE( xPropState.is(), "no XPropertyState!" );
1355 if (! xPropState.is())
1356 continue;
1357 Reference< lang::XServiceInfo > xServiceInfo( xProps, UNO_QUERY );
1358 OSL_ENSURE( xServiceInfo.is(), "no XServiceInfo!" );
1359 if (! xServiceInfo.is())
1360 continue;
1362 ElementDescriptor * pElem = 0;
1363 Reference< xml::sax::XAttributeList > xElem;
1365 // group up radio buttons
1366 if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlRadioButtonModel") ) ) )
1368 if (! pRadioGroup) // open radiogroup
1370 pRadioGroup = new ElementDescriptor(
1371 xProps, xPropState,
1372 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":radiogroup") ) );
1373 all_elements.push_back( pRadioGroup );
1376 pElem = new ElementDescriptor(
1377 xProps, xPropState,
1378 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":radio") ) );
1379 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1380 pElem->readRadioButtonModel( &all_styles, xDocument );
1381 pRadioGroup->addSubElement( xElem );
1383 else // no radio
1385 pRadioGroup = 0; // close radiogroup
1387 if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlButtonModel") ) ) )
1389 pElem = new ElementDescriptor(
1390 xProps, xPropState,
1391 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":button") ) );
1392 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1393 pElem->readButtonModel( &all_styles );
1395 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlCheckBoxModel") ) ) )
1397 pElem = new ElementDescriptor(
1398 xProps, xPropState,
1399 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":checkbox") ) );
1400 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1401 pElem->readCheckBoxModel( &all_styles );
1403 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlComboBoxModel") ) ) )
1405 pElem = new ElementDescriptor(
1406 xProps, xPropState,
1407 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":combobox") ) );
1408 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1409 pElem->readComboBoxModel( &all_styles, xDocument );
1411 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlListBoxModel") ) ) )
1413 pElem = new ElementDescriptor(
1414 xProps, xPropState,
1415 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":menulist") ) );
1416 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1417 pElem->readListBoxModel( &all_styles, xDocument );
1419 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlGroupBoxModel") ) ) )
1421 pElem = new ElementDescriptor(
1422 xProps, xPropState,
1423 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":titledbox") ) );
1424 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1425 pElem->readGroupBoxModel( &all_styles );
1427 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoMultiPageModel") ) ) )
1429 pElem = new ElementDescriptor(
1430 xProps, xPropState,
1431 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":multipage") ) );
1432 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1433 pElem->readMultiPageModel( &all_styles );
1435 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedTextModel") ) ) )
1437 pElem = new ElementDescriptor(
1438 xProps, xPropState,
1439 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":text") ) );
1440 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1441 pElem->readFixedTextModel( &all_styles );
1443 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlEditModel") ) ) )
1445 pElem = new ElementDescriptor(
1446 xProps, xPropState,
1447 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":textfield") ) );
1448 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1449 pElem->readEditModel( &all_styles );
1451 // FixedHyperLink
1452 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedHyperlinkModel") ) ) )
1454 pElem = new ElementDescriptor(
1455 xProps, xPropState,
1456 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":linklabel") ) );
1457 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1458 pElem->readFixedHyperLinkModel( &all_styles );
1460 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlImageControlModel") ) ) )
1462 pElem = new ElementDescriptor(
1463 xProps, xPropState,
1464 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":img") ) );
1465 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1466 pElem->readImageControlModel( &all_styles, xDocument );
1468 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFileControlModel") ) ) )
1470 pElem = new ElementDescriptor(
1471 xProps, xPropState,
1472 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":filecontrol") ) );
1473 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1474 pElem->readFileControlModel( &all_styles );
1476 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.tree.TreeControlModel") ) ) )
1478 pElem = new ElementDescriptor(
1479 xProps, xPropState,
1480 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":treecontrol") ) );
1481 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1482 pElem->readTreeControlModel( &all_styles );
1484 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlCurrencyFieldModel") ) ) )
1486 pElem = new ElementDescriptor(
1487 xProps, xPropState,
1488 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":currencyfield") ) );
1489 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1490 pElem->readCurrencyFieldModel( &all_styles );
1492 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlDateFieldModel") ) ) )
1494 pElem = new ElementDescriptor(
1495 xProps, xPropState,
1496 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":datefield") ) );
1497 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1498 pElem->readDateFieldModel( &all_styles );
1500 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlNumericFieldModel") ) ) )
1502 pElem = new ElementDescriptor(
1503 xProps, xPropState,
1504 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":numericfield") ) );
1505 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1506 pElem->readNumericFieldModel( &all_styles );
1508 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlTimeFieldModel") ) ) )
1510 pElem = new ElementDescriptor(
1511 xProps, xPropState,
1512 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":timefield") ) );
1513 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1514 pElem->readTimeFieldModel( &all_styles );
1516 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlPatternFieldModel") ) ) )
1518 pElem = new ElementDescriptor(
1519 xProps, xPropState,
1520 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":patternfield") ) );
1521 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1522 pElem->readPatternFieldModel( &all_styles );
1524 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFormattedFieldModel") ) ) )
1526 pElem = new ElementDescriptor(
1527 xProps, xPropState,
1528 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":formattedfield") ) );
1529 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1530 pElem->readFormattedFieldModel( &all_styles );
1532 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedLineModel") ) ) )
1534 pElem = new ElementDescriptor(
1535 xProps, xPropState,
1536 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":fixedline") ) );
1537 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1538 pElem->readFixedLineModel( &all_styles );
1540 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlScrollBarModel") ) ) )
1542 pElem = new ElementDescriptor(
1543 xProps, xPropState,
1544 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":scrollbar") ) );
1545 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1546 pElem->readScrollBarModel( &all_styles, xDocument );
1548 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlSpinButtonModel") ) ) )
1550 pElem = new ElementDescriptor(
1551 xProps, xPropState,
1552 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":spinbutton") ) );
1553 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1554 pElem->readSpinButtonModel( &all_styles, xDocument );
1556 else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlProgressBarModel") ) ) )
1558 pElem = new ElementDescriptor(
1559 xProps, xPropState,
1560 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":progressmeter") ) );
1561 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1562 pElem->readProgressBarModel( &all_styles );
1566 OSL_ASSERT( xElem.is() );
1567 if (xElem.is())
1569 all_elements.push_back( xElem );
1571 else
1573 OSL_ENSURE( sal_False, "unknown control type!" );
1574 continue;
1579 xOut->startDocument();
1581 OUString aDocTypeStr( RTL_CONSTASCII_USTRINGPARAM(
1582 "<!DOCTYPE dlg:window PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\""
1583 " \"dialog.dtd\">" ) );
1584 xOut->unknown( aDocTypeStr );
1585 xOut->ignorableWhitespace( OUString() );
1587 // window
1588 Reference< beans::XPropertySet > xProps( xDialogModel, UNO_QUERY );
1589 OSL_ASSERT( xProps.is() );
1590 Reference< beans::XPropertyState > xPropState( xProps, UNO_QUERY );
1591 OSL_ASSERT( xPropState.is() );
1593 OUString aWindowName( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":window") );
1594 ElementDescriptor * pWindow = new ElementDescriptor( xProps, xPropState, aWindowName );
1595 Reference< xml::sax::XAttributeList > xWindow( pWindow );
1596 pWindow->readDialogModel( &all_styles );
1597 xOut->ignorableWhitespace( OUString() );
1598 xOut->startElement( aWindowName, xWindow );
1599 // dump out events
1600 pWindow->dumpSubElements( xOut.get() );
1601 // dump out stylebag
1602 all_styles.dump( xOut );
1604 if (! all_elements.empty())
1606 // open up bulletinboard
1607 OUString aBBoardName( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":bulletinboard") );
1608 xOut->ignorableWhitespace( OUString() );
1609 xOut->startElement( aBBoardName, Reference< xml::sax::XAttributeList >() );
1611 // export control elements
1612 for ( std::size_t n = 0; n < all_elements.size(); ++n )
1614 ElementDescriptor * pElem = static_cast< ElementDescriptor * >( all_elements[ n ].get() );
1615 pElem->dump( xOut.get() );
1618 // end bulletinboard
1619 xOut->ignorableWhitespace( OUString() );
1620 xOut->endElement( aBBoardName );
1623 // end window
1624 xOut->ignorableWhitespace( OUString() );
1625 xOut->endElement( aWindowName );
1627 xOut->endDocument();