xref: /trunk/main/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx (revision cf6516809c57e1bb0a940545cca99cdad54d4ce2)
1e1d5bd03SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3e1d5bd03SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4e1d5bd03SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5e1d5bd03SAndrew Rist  * distributed with this work for additional information
6e1d5bd03SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7e1d5bd03SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8e1d5bd03SAndrew Rist  * "License"); you may not use this file except in compliance
9e1d5bd03SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11e1d5bd03SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13e1d5bd03SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14e1d5bd03SAndrew Rist  * software distributed under the License is distributed on an
15e1d5bd03SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16e1d5bd03SAndrew Rist  * KIND, either express or implied.  See the License for the
17e1d5bd03SAndrew Rist  * specific language governing permissions and limitations
18e1d5bd03SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20e1d5bd03SAndrew Rist  *************************************************************/
21e1d5bd03SAndrew Rist 
22e1d5bd03SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_xmlscript.hxx"
26cdf0e10cSrcweir #include "exp_share.hxx"
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
29cdf0e10cSrcweir #include <tools/diagnose_ex.h>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <com/sun/star/awt/CharSet.hpp>
32cdf0e10cSrcweir #include <com/sun/star/awt/FontFamily.hpp>
33cdf0e10cSrcweir #include <com/sun/star/awt/FontPitch.hpp>
34cdf0e10cSrcweir #include <com/sun/star/awt/FontSlant.hpp>
35cdf0e10cSrcweir #include <com/sun/star/awt/FontStrikeout.hpp>
36cdf0e10cSrcweir #include <com/sun/star/awt/FontType.hpp>
37cdf0e10cSrcweir #include <com/sun/star/awt/FontUnderline.hpp>
38cdf0e10cSrcweir #include <com/sun/star/awt/FontWeight.hpp>
39cdf0e10cSrcweir #include <com/sun/star/awt/FontWidth.hpp>
40cdf0e10cSrcweir #include <com/sun/star/awt/ImagePosition.hpp>
41874957b9STsutomu Uchino #include <com/sun/star/awt/ImageScaleMode.hpp>
42cdf0e10cSrcweir #include <com/sun/star/awt/LineEndFormat.hpp>
43cdf0e10cSrcweir #include <com/sun/star/awt/PushButtonType.hpp>
44cdf0e10cSrcweir #include <com/sun/star/awt/VisualEffect.hpp>
45cdf0e10cSrcweir 
46cdf0e10cSrcweir #include <com/sun/star/script/XScriptEventsSupplier.hpp>
47cdf0e10cSrcweir #include <com/sun/star/script/ScriptEventDescriptor.hpp>
48cdf0e10cSrcweir 
49cdf0e10cSrcweir #include <com/sun/star/style/VerticalAlignment.hpp>
50cdf0e10cSrcweir 
51cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
52cdf0e10cSrcweir #include <com/sun/star/lang/Locale.hpp>
53cdf0e10cSrcweir #include <com/sun/star/util/NumberFormat.hpp>
54cdf0e10cSrcweir 
55cdf0e10cSrcweir #include <com/sun/star/view/SelectionType.hpp>
56cdf0e10cSrcweir 
57cdf0e10cSrcweir 
58cdf0e10cSrcweir using namespace ::com::sun::star;
59cdf0e10cSrcweir using namespace ::com::sun::star::uno;
60cdf0e10cSrcweir using ::rtl::OUString;
61cdf0e10cSrcweir using ::rtl::OUStringBuffer;
62cdf0e10cSrcweir 
63cdf0e10cSrcweir namespace xmlscript
64cdf0e10cSrcweir {
65cdf0e10cSrcweir 
66cdf0e10cSrcweir //__________________________________________________________________________________________________
createElement()67cdf0e10cSrcweir Reference< xml::sax::XAttributeList > Style::createElement()
68cdf0e10cSrcweir {
69cdf0e10cSrcweir     ElementDescriptor * pStyle = new ElementDescriptor(
70cdf0e10cSrcweir         OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style") ) );
71cdf0e10cSrcweir 
72cdf0e10cSrcweir     // style-id
73cdf0e10cSrcweir     pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":style-id") ), _id );
74cdf0e10cSrcweir 
75cdf0e10cSrcweir     // background-color
76cdf0e10cSrcweir     if (_set & 0x1)
77cdf0e10cSrcweir     {
78cdf0e10cSrcweir         OUStringBuffer buf( 16 );
79cdf0e10cSrcweir         buf.append( (sal_Unicode)'0' );
80cdf0e10cSrcweir         buf.append( (sal_Unicode)'x' );
81cdf0e10cSrcweir         buf.append( OUString::valueOf( (sal_Int64)(sal_uInt64)_backgroundColor, 16 ) );
82cdf0e10cSrcweir         pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":background-color") ),
83cdf0e10cSrcweir                               buf.makeStringAndClear() );
84cdf0e10cSrcweir     }
85cdf0e10cSrcweir 
86cdf0e10cSrcweir     // text-color
87cdf0e10cSrcweir     if (_set & 0x2)
88cdf0e10cSrcweir     {
89cdf0e10cSrcweir         OUStringBuffer buf( 16 );
90cdf0e10cSrcweir         buf.append( (sal_Unicode)'0' );
91cdf0e10cSrcweir         buf.append( (sal_Unicode)'x' );
92cdf0e10cSrcweir         buf.append( OUString::valueOf( (sal_Int64)(sal_uInt64)_textColor, 16 ) );
93cdf0e10cSrcweir         pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":text-color") ),
94cdf0e10cSrcweir                               buf.makeStringAndClear() );
95cdf0e10cSrcweir     }
96cdf0e10cSrcweir 
97cdf0e10cSrcweir     // textline-color
98cdf0e10cSrcweir     if (_set & 0x20)
99cdf0e10cSrcweir     {
100cdf0e10cSrcweir         OUStringBuffer buf( 16 );
101cdf0e10cSrcweir         buf.append( (sal_Unicode)'0' );
102cdf0e10cSrcweir         buf.append( (sal_Unicode)'x' );
103cdf0e10cSrcweir         buf.append( OUString::valueOf( (sal_Int64)(sal_uInt64)_textLineColor, 16 ) );
104cdf0e10cSrcweir         pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":textline-color") ),
105cdf0e10cSrcweir                               buf.makeStringAndClear() );
106cdf0e10cSrcweir     }
107cdf0e10cSrcweir 
108cdf0e10cSrcweir     // fill-color
109cdf0e10cSrcweir     if (_set & 0x10)
110cdf0e10cSrcweir     {
111cdf0e10cSrcweir         OUStringBuffer buf( 16 );
112cdf0e10cSrcweir         buf.append( (sal_Unicode)'0' );
113cdf0e10cSrcweir         buf.append( (sal_Unicode)'x' );
114cdf0e10cSrcweir         buf.append( OUString::valueOf( (sal_Int64)(sal_uInt64)_fillColor, 16 ) );
115cdf0e10cSrcweir         pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":fill-color") ),
116cdf0e10cSrcweir                               buf.makeStringAndClear() );
117cdf0e10cSrcweir     }
118cdf0e10cSrcweir 
119cdf0e10cSrcweir     // border
120cdf0e10cSrcweir     if (_set & 0x4)
121cdf0e10cSrcweir     {
122cdf0e10cSrcweir         switch (_border)
123cdf0e10cSrcweir         {
124cdf0e10cSrcweir         case BORDER_NONE:
125cdf0e10cSrcweir             pStyle->addAttribute( OUSTR(XMLNS_DIALOGS_PREFIX ":border"),
126cdf0e10cSrcweir                                   OUSTR("none") );
127cdf0e10cSrcweir             break;
128cdf0e10cSrcweir         case BORDER_3D:
129cdf0e10cSrcweir             pStyle->addAttribute( OUSTR(XMLNS_DIALOGS_PREFIX ":border"),
130cdf0e10cSrcweir                                   OUSTR("3d") );
131cdf0e10cSrcweir             break;
132cdf0e10cSrcweir         case BORDER_SIMPLE:
133cdf0e10cSrcweir             pStyle->addAttribute( OUSTR(XMLNS_DIALOGS_PREFIX ":border"),
134cdf0e10cSrcweir                                   OUSTR("simple") );
135cdf0e10cSrcweir             break;
136cdf0e10cSrcweir         case BORDER_SIMPLE_COLOR: {
137cdf0e10cSrcweir             OUStringBuffer buf;
138cdf0e10cSrcweir             buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("0x") );
139cdf0e10cSrcweir             buf.append( OUString::valueOf(
140cdf0e10cSrcweir                             (sal_Int64)(sal_uInt64)_borderColor, 16 ) );
141cdf0e10cSrcweir             pStyle->addAttribute( OUSTR(XMLNS_DIALOGS_PREFIX ":border"),
142cdf0e10cSrcweir                                   buf.makeStringAndClear() );
143cdf0e10cSrcweir             break;
144cdf0e10cSrcweir         }
145cdf0e10cSrcweir         default:
146cdf0e10cSrcweir             OSL_ENSURE( 0, "### unexpected border value!" );
147cdf0e10cSrcweir             break;
148cdf0e10cSrcweir         }
149cdf0e10cSrcweir     }
150cdf0e10cSrcweir 
151cdf0e10cSrcweir     // visual effect (look)
152cdf0e10cSrcweir     if (_set & 0x40)
153cdf0e10cSrcweir     {
154cdf0e10cSrcweir         switch (_visualEffect)
155cdf0e10cSrcweir         {
156cdf0e10cSrcweir         case awt::VisualEffect::NONE:
157cdf0e10cSrcweir             pStyle->addAttribute( OUSTR(XMLNS_DIALOGS_PREFIX ":look"),
158cdf0e10cSrcweir                                   OUSTR("none") );
159cdf0e10cSrcweir             break;
160cdf0e10cSrcweir         case awt::VisualEffect::LOOK3D:
161cdf0e10cSrcweir             pStyle->addAttribute( OUSTR(XMLNS_DIALOGS_PREFIX ":look"),
162cdf0e10cSrcweir                                   OUSTR("3d") );
163cdf0e10cSrcweir             break;
164cdf0e10cSrcweir         case awt::VisualEffect::FLAT:
165cdf0e10cSrcweir             pStyle->addAttribute( OUSTR(XMLNS_DIALOGS_PREFIX ":look"),
166cdf0e10cSrcweir                                   OUSTR("simple") );
167cdf0e10cSrcweir             break;
168cdf0e10cSrcweir         default:
169cdf0e10cSrcweir             OSL_ENSURE( 0, "### unexpected visual effect value!" );
170cdf0e10cSrcweir             break;
171cdf0e10cSrcweir         }
172cdf0e10cSrcweir     }
173cdf0e10cSrcweir 
174cdf0e10cSrcweir     // font-
175cdf0e10cSrcweir     if (_set & 0x8)
176cdf0e10cSrcweir     {
177cdf0e10cSrcweir         awt::FontDescriptor def_descr;
178cdf0e10cSrcweir 
179cdf0e10cSrcweir         // dialog:font-name CDATA #IMPLIED
180cdf0e10cSrcweir         if (def_descr.Name != _descr.Name)
181cdf0e10cSrcweir         {
182cdf0e10cSrcweir             pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-name") ),
183cdf0e10cSrcweir                                   _descr.Name );
184cdf0e10cSrcweir         }
185cdf0e10cSrcweir         // dialog:font-height %numeric; #IMPLIED
186cdf0e10cSrcweir         if (def_descr.Height != _descr.Height)
187cdf0e10cSrcweir         {
188cdf0e10cSrcweir             pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-height") ),
189cdf0e10cSrcweir                                   OUString::valueOf( (sal_Int32)_descr.Height ) );
190cdf0e10cSrcweir         }
191cdf0e10cSrcweir         // dialog:font-width %numeric; #IMPLIED
192cdf0e10cSrcweir         if (def_descr.Width != _descr.Width)
193cdf0e10cSrcweir         {
194cdf0e10cSrcweir             pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-width") ),
195cdf0e10cSrcweir                                   OUString::valueOf( (sal_Int32)_descr.Width ) );
196cdf0e10cSrcweir         }
197cdf0e10cSrcweir         // dialog:font-stylename CDATA #IMPLIED
198cdf0e10cSrcweir         if (def_descr.StyleName != _descr.StyleName)
199cdf0e10cSrcweir         {
200cdf0e10cSrcweir             pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-stylename") ),
201cdf0e10cSrcweir                                   _descr.StyleName );
202cdf0e10cSrcweir         }
203cdf0e10cSrcweir         // dialog:font-family "(decorative|modern|roman|script|swiss|system)" #IMPLIED
204cdf0e10cSrcweir         if (def_descr.Family != _descr.Family)
205cdf0e10cSrcweir         {
206cdf0e10cSrcweir             switch (_descr.Family)
207cdf0e10cSrcweir             {
208cdf0e10cSrcweir             case awt::FontFamily::DECORATIVE:
209cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-family") ),
210cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("decorative") ) );
211cdf0e10cSrcweir                 break;
212cdf0e10cSrcweir             case awt::FontFamily::MODERN:
213cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-family") ),
214cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("modern") ) );
215cdf0e10cSrcweir                 break;
216cdf0e10cSrcweir             case awt::FontFamily::ROMAN:
217cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-family") ),
218cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("roman") ) );
219cdf0e10cSrcweir                 break;
220cdf0e10cSrcweir             case awt::FontFamily::SCRIPT:
221cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-family") ),
222cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("script") ) );
223cdf0e10cSrcweir                 break;
224cdf0e10cSrcweir             case awt::FontFamily::SWISS:
225cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-family") ),
226cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("swiss") ) );
227cdf0e10cSrcweir                 break;
228cdf0e10cSrcweir             case awt::FontFamily::SYSTEM:
229cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-family") ),
230cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("system") ) );
231cdf0e10cSrcweir                 break;
232cdf0e10cSrcweir             default:
233cdf0e10cSrcweir                 OSL_ENSURE( 0, "### unexpected font-family!" );
234cdf0e10cSrcweir                 break;
235cdf0e10cSrcweir             }
236cdf0e10cSrcweir         }
237cdf0e10cSrcweir         // dialog:font-charset "(ansi|mac|ibmpc_437|ibmpc_850|ibmpc_860|ibmpc_861|ibmpc_863|ibmpc_865|system|symbol)" #IMPLIED
238cdf0e10cSrcweir         if (def_descr.CharSet != _descr.CharSet)
239cdf0e10cSrcweir         {
240cdf0e10cSrcweir             switch (_descr.CharSet)
241cdf0e10cSrcweir             {
242cdf0e10cSrcweir             case awt::CharSet::ANSI:
243cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ),
244cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("ansi") ) );
245cdf0e10cSrcweir                 break;
246cdf0e10cSrcweir             case awt::CharSet::MAC:
247cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ),
248cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("mac") ) );
249cdf0e10cSrcweir                 break;
250cdf0e10cSrcweir             case awt::CharSet::IBMPC_437:
251cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ),
252cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("ibmpc_437") ) );
253cdf0e10cSrcweir                 break;
254cdf0e10cSrcweir             case awt::CharSet::IBMPC_850:
255cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ),
256cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("ibmpc_850") ) );
257cdf0e10cSrcweir                 break;
258cdf0e10cSrcweir             case awt::CharSet::IBMPC_860:
259cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ),
260cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("ibmpc_860") ) );
261cdf0e10cSrcweir                 break;
262cdf0e10cSrcweir             case awt::CharSet::IBMPC_861:
263cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ),
264cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("ibmpc_861") ) );
265cdf0e10cSrcweir                 break;
266cdf0e10cSrcweir             case awt::CharSet::IBMPC_863:
267cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ),
268cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("ibmpc_863") ) );
269cdf0e10cSrcweir                 break;
270cdf0e10cSrcweir             case awt::CharSet::IBMPC_865:
271cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ),
272cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("ibmpc_865") ) );
273cdf0e10cSrcweir                 break;
274cdf0e10cSrcweir             case awt::CharSet::SYSTEM:
275cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ),
276cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("system") ) );
277cdf0e10cSrcweir                 break;
278cdf0e10cSrcweir             case awt::CharSet::SYMBOL:
279cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charset") ),
280cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("symbol") ) );
281cdf0e10cSrcweir                 break;
282cdf0e10cSrcweir             default:
283cdf0e10cSrcweir                 OSL_ENSURE( 0, "### unexpected font-charset!" );
284cdf0e10cSrcweir                 break;
285cdf0e10cSrcweir             }
286cdf0e10cSrcweir         }
287cdf0e10cSrcweir         // dialog:font-pitch "(fixed|variable)" #IMPLIED
288cdf0e10cSrcweir         if (def_descr.Pitch != _descr.Pitch)
289cdf0e10cSrcweir         {
290cdf0e10cSrcweir             switch (_descr.Pitch)
291cdf0e10cSrcweir             {
292cdf0e10cSrcweir             case awt::FontPitch::FIXED:
293cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-pitch") ),
294cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("fixed") ) );
295cdf0e10cSrcweir                 break;
296cdf0e10cSrcweir             case awt::FontPitch::VARIABLE:
297cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-pitch") ),
298cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("variable") ) );
299cdf0e10cSrcweir                 break;
300cdf0e10cSrcweir             default:
301cdf0e10cSrcweir                 OSL_ENSURE( 0, "### unexpected font-pitch!" );
302cdf0e10cSrcweir                 break;
303cdf0e10cSrcweir             }
304cdf0e10cSrcweir         }
305cdf0e10cSrcweir         // dialog:font-charwidth CDATA #IMPLIED
306cdf0e10cSrcweir         if (def_descr.CharacterWidth != _descr.CharacterWidth)
307cdf0e10cSrcweir         {
308cdf0e10cSrcweir             pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-charwidth") ),
309cdf0e10cSrcweir                                   OUString::valueOf( (float)_descr.CharacterWidth ) );
310cdf0e10cSrcweir         }
311cdf0e10cSrcweir         // dialog:font-weight CDATA #IMPLIED
312cdf0e10cSrcweir         if (def_descr.Weight != _descr.Weight)
313cdf0e10cSrcweir         {
314cdf0e10cSrcweir             pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-weight") ),
315cdf0e10cSrcweir                                   OUString::valueOf( (float)_descr.Weight ) );
316cdf0e10cSrcweir         }
317cdf0e10cSrcweir         // dialog:font-slant "(oblique|italic|reverse_oblique|reverse_italic)" #IMPLIED
318cdf0e10cSrcweir         if (def_descr.Slant != _descr.Slant)
319cdf0e10cSrcweir         {
320cdf0e10cSrcweir             switch (_descr.Slant)
321cdf0e10cSrcweir             {
322cdf0e10cSrcweir             case awt::FontSlant_OBLIQUE:
323cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-slant") ),
324cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("oblique") ) );
325cdf0e10cSrcweir                 break;
326cdf0e10cSrcweir             case awt::FontSlant_ITALIC:
327cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-slant") ),
328cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("italic") ) );
329cdf0e10cSrcweir                 break;
330cdf0e10cSrcweir             case awt::FontSlant_REVERSE_OBLIQUE:
331cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-slant") ),
332cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("reverse_oblique") ) );
333cdf0e10cSrcweir                 break;
334cdf0e10cSrcweir             case awt::FontSlant_REVERSE_ITALIC:
335cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-slant") ),
336cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("reverse_italic") ) );
337cdf0e10cSrcweir                 break;
338cdf0e10cSrcweir             default:
339cdf0e10cSrcweir                 OSL_ENSURE( 0, "### unexpected font-slant!" );
340cdf0e10cSrcweir                 break;
341cdf0e10cSrcweir             }
342cdf0e10cSrcweir         }
343cdf0e10cSrcweir         // dialog:font-underline "(single|double|dotted|dash|longdash|dashdot|dashdotdot|smallwave|wave|doublewave|bold|bolddotted|bolddash|boldlongdash|bolddashdot|bolddashdotdot|boldwave)" #IMPLIED
344cdf0e10cSrcweir         if (def_descr.Underline != _descr.Underline)
345cdf0e10cSrcweir         {
346cdf0e10cSrcweir             switch (_descr.Underline)
347cdf0e10cSrcweir             {
348cdf0e10cSrcweir             case awt::FontUnderline::SINGLE:
349cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
350cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("single") ) );
351cdf0e10cSrcweir                 break;
352cdf0e10cSrcweir             case awt::FontUnderline::DOUBLE:
353cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
354cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("double") ) );
355cdf0e10cSrcweir                 break;
356cdf0e10cSrcweir             case awt::FontUnderline::DOTTED:
357cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
358cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("dotted") ) );
359cdf0e10cSrcweir                 break;
360cdf0e10cSrcweir             case awt::FontUnderline::DASH:
361cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
362cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("dash") ) );
363cdf0e10cSrcweir                 break;
364cdf0e10cSrcweir             case awt::FontUnderline::LONGDASH:
365cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
366cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("longdash") ) );
367cdf0e10cSrcweir                 break;
368cdf0e10cSrcweir             case awt::FontUnderline::DASHDOT:
369cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
370cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("dashdot") ) );
371cdf0e10cSrcweir                 break;
372cdf0e10cSrcweir             case awt::FontUnderline::DASHDOTDOT:
373cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
374cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("dashdotdot") ) );
375cdf0e10cSrcweir                 break;
376cdf0e10cSrcweir             case awt::FontUnderline::SMALLWAVE:
377cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
378cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("smallwave") ) );
379cdf0e10cSrcweir                 break;
380cdf0e10cSrcweir             case awt::FontUnderline::WAVE:
381cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
382cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("wave") ) );
383cdf0e10cSrcweir                 break;
384cdf0e10cSrcweir             case awt::FontUnderline::DOUBLEWAVE:
385cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
386cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("doublewave") ) );
387cdf0e10cSrcweir                 break;
388cdf0e10cSrcweir             case awt::FontUnderline::BOLD:
389cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
390cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("bold") ) );
391cdf0e10cSrcweir                 break;
392cdf0e10cSrcweir             case awt::FontUnderline::BOLDDOTTED:
393cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
394cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("bolddotted") ) );
395cdf0e10cSrcweir                 break;
396cdf0e10cSrcweir             case awt::FontUnderline::BOLDDASH:
397cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
398cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("bolddash") ) );
399cdf0e10cSrcweir                 break;
400cdf0e10cSrcweir             case awt::FontUnderline::BOLDLONGDASH:
401cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
402cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("boldlongdash") ) );
403cdf0e10cSrcweir                 break;
404cdf0e10cSrcweir             case awt::FontUnderline::BOLDDASHDOT:
405cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
406cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("bolddashdot") ) );
407cdf0e10cSrcweir                 break;
408cdf0e10cSrcweir             case awt::FontUnderline::BOLDDASHDOTDOT:
409cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
410cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("bolddashdotdot") ) );
411cdf0e10cSrcweir                 break;
412cdf0e10cSrcweir             case awt::FontUnderline::BOLDWAVE:
413cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-underline") ),
414cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("boldwave") ) );
415cdf0e10cSrcweir                 break;
416cdf0e10cSrcweir             default:
417cdf0e10cSrcweir                 OSL_ENSURE( 0, "### unexpected font-underline!" );
418cdf0e10cSrcweir                 break;
419cdf0e10cSrcweir             }
420cdf0e10cSrcweir         }
421cdf0e10cSrcweir         // dialog:font-strikeout "(single|double|bold|slash|x)" #IMPLIED
422cdf0e10cSrcweir         if (def_descr.Strikeout != _descr.Strikeout)
423cdf0e10cSrcweir         {
424cdf0e10cSrcweir             switch (_descr.Strikeout)
425cdf0e10cSrcweir             {
426cdf0e10cSrcweir             case awt::FontStrikeout::SINGLE:
427cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-strikeout") ),
428cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("single") ) );
429cdf0e10cSrcweir                 break;
430cdf0e10cSrcweir             case awt::FontStrikeout::DOUBLE:
431cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-strikeout") ),
432cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("double") ) );
433cdf0e10cSrcweir                 break;
434cdf0e10cSrcweir             case awt::FontStrikeout::BOLD:
435cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-strikeout") ),
436cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("bold") ) );
437cdf0e10cSrcweir                 break;
438cdf0e10cSrcweir             case awt::FontStrikeout::SLASH:
439cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-strikeout") ),
440cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("slash") ) );
441cdf0e10cSrcweir                 break;
442cdf0e10cSrcweir             case awt::FontStrikeout::X:
443cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-strikeout") ),
444cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("x") ) );
445cdf0e10cSrcweir                 break;
446cdf0e10cSrcweir             default:
447cdf0e10cSrcweir                 OSL_ENSURE( 0, "### unexpected font-strikeout!" );
448cdf0e10cSrcweir                 break;
449cdf0e10cSrcweir             }
450cdf0e10cSrcweir         }
451cdf0e10cSrcweir         // dialog:font-orientation CDATA #IMPLIED
452cdf0e10cSrcweir         if (def_descr.Orientation != _descr.Orientation)
453cdf0e10cSrcweir         {
454cdf0e10cSrcweir             pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-orientation") ),
455cdf0e10cSrcweir                                   OUString::valueOf( (float)_descr.Orientation ) );
456cdf0e10cSrcweir         }
457cdf0e10cSrcweir         // dialog:font-kerning %boolean; #IMPLIED
458cdf0e10cSrcweir         if ((def_descr.Kerning != sal_False) != (_descr.Kerning != sal_False))
459cdf0e10cSrcweir         {
460cdf0e10cSrcweir             pStyle->addBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-kerning") ),
461cdf0e10cSrcweir                                     _descr.Kerning );
462cdf0e10cSrcweir         }
463cdf0e10cSrcweir         // dialog:font-wordlinemode %boolean; #IMPLIED
464cdf0e10cSrcweir         if ((def_descr.WordLineMode != sal_False) != (_descr.WordLineMode != sal_False))
465cdf0e10cSrcweir         {
466cdf0e10cSrcweir             pStyle->addBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-wordlinemode") ),
467cdf0e10cSrcweir                                  _descr.WordLineMode );
468cdf0e10cSrcweir         }
469cdf0e10cSrcweir         // dialog:font-type "(raster|device|scalable)" #IMPLIED
470cdf0e10cSrcweir         if (def_descr.Type != _descr.Type)
471cdf0e10cSrcweir         {
472cdf0e10cSrcweir             switch (_descr.Type)
473cdf0e10cSrcweir             {
474cdf0e10cSrcweir             case awt::FontType::RASTER:
475cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-type") ),
476cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("raster") ) );
477cdf0e10cSrcweir                 break;
478cdf0e10cSrcweir             case awt::FontType::DEVICE:
479cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-type") ),
480cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("device") ) );
481cdf0e10cSrcweir                 break;
482cdf0e10cSrcweir             case awt::FontType::SCALABLE:
483cdf0e10cSrcweir                 pStyle->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-type") ),
484cdf0e10cSrcweir                                       OUString( RTL_CONSTASCII_USTRINGPARAM("scalable") ) );
485cdf0e10cSrcweir                 break;
486cdf0e10cSrcweir             default:
487cdf0e10cSrcweir                 OSL_ENSURE( 0, "### unexpected font-type!" );
488cdf0e10cSrcweir                 break;
489cdf0e10cSrcweir             }
490cdf0e10cSrcweir         }
491cdf0e10cSrcweir 
492cdf0e10cSrcweir         // additional attributes not in FontDescriptor struct
493cdf0e10cSrcweir         // dialog:font-relief (none|embossed|engraved) #IMPLIED
494cdf0e10cSrcweir         switch (_fontRelief)
495cdf0e10cSrcweir         {
496cdf0e10cSrcweir         case awt::FontRelief::NONE: // dont export default
497cdf0e10cSrcweir             break;
498cdf0e10cSrcweir         case awt::FontRelief::EMBOSSED:
499cdf0e10cSrcweir             pStyle->addAttribute(
500cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-relief") ),
501cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM("embossed") ) );
502cdf0e10cSrcweir             break;
503cdf0e10cSrcweir         case awt::FontRelief::ENGRAVED:
504cdf0e10cSrcweir             pStyle->addAttribute(
505cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-relief") ),
506cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM("engraved") ) );
507cdf0e10cSrcweir             break;
508cdf0e10cSrcweir         default:
509cdf0e10cSrcweir             OSL_ENSURE( 0, "### unexpected font-relief!" );
510cdf0e10cSrcweir             break;
511cdf0e10cSrcweir         }
512cdf0e10cSrcweir         // dialog:font-emphasismark (none|dot|circle|disc|accent|above|below) #IMPLIED
513cdf0e10cSrcweir         switch (_fontEmphasisMark)
514cdf0e10cSrcweir         {
515cdf0e10cSrcweir         case awt::FontEmphasisMark::NONE: // dont export default
516cdf0e10cSrcweir             break;
517cdf0e10cSrcweir         case awt::FontEmphasisMark::DOT:
518cdf0e10cSrcweir             pStyle->addAttribute(
519cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-emphasismark") ),
520cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM("dot") ) );
521cdf0e10cSrcweir             break;
522cdf0e10cSrcweir         case awt::FontEmphasisMark::CIRCLE:
523cdf0e10cSrcweir             pStyle->addAttribute(
524cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-emphasismark") ),
525cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM("circle") ) );
526cdf0e10cSrcweir             break;
527cdf0e10cSrcweir         case awt::FontEmphasisMark::DISC:
528cdf0e10cSrcweir             pStyle->addAttribute(
529cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-emphasismark") ),
530cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM("disc") ) );
531cdf0e10cSrcweir             break;
532cdf0e10cSrcweir         case awt::FontEmphasisMark::ACCENT:
533cdf0e10cSrcweir             pStyle->addAttribute(
534cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-emphasismark") ),
535cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM("accent") ) );
536cdf0e10cSrcweir             break;
537cdf0e10cSrcweir         case awt::FontEmphasisMark::ABOVE:
538cdf0e10cSrcweir             pStyle->addAttribute(
539cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-emphasismark") ),
540cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM("above") ) );
541cdf0e10cSrcweir             break;
542cdf0e10cSrcweir         case awt::FontEmphasisMark::BELOW:
543cdf0e10cSrcweir             pStyle->addAttribute(
544cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":font-emphasismark") ),
545cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM("below") ) );
546cdf0e10cSrcweir             break;
547cdf0e10cSrcweir         default:
548cdf0e10cSrcweir             OSL_ENSURE( 0, "### unexpected font-emphasismark!" );
549cdf0e10cSrcweir             break;
550cdf0e10cSrcweir         }
551cdf0e10cSrcweir     }
552cdf0e10cSrcweir 
553cdf0e10cSrcweir     return pStyle;
554cdf0e10cSrcweir }
555cdf0e10cSrcweir 
556cdf0e10cSrcweir //##################################################################################################
557cdf0e10cSrcweir 
558cdf0e10cSrcweir //__________________________________________________________________________________________________
addNumberFormatAttr(Reference<beans::XPropertySet> const & xFormatProperties,OUString const &)559cdf0e10cSrcweir void ElementDescriptor::addNumberFormatAttr(
560cdf0e10cSrcweir     Reference< beans::XPropertySet > const & xFormatProperties,
561cdf0e10cSrcweir     OUString const & /*rAttrName*/ )
562cdf0e10cSrcweir {
563cdf0e10cSrcweir     Reference< beans::XPropertyState > xState( xFormatProperties, UNO_QUERY );
564cdf0e10cSrcweir     OUString sFormat;
565cdf0e10cSrcweir     lang::Locale locale;
566cdf0e10cSrcweir     OSL_VERIFY( xFormatProperties->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("FormatString") ) ) >>= sFormat );
567cdf0e10cSrcweir     OSL_VERIFY( xFormatProperties->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Locale") ) ) >>= locale );
568cdf0e10cSrcweir 
569cdf0e10cSrcweir     addAttribute(
570cdf0e10cSrcweir         OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":format-code") ),
571cdf0e10cSrcweir         sFormat );
572cdf0e10cSrcweir 
573cdf0e10cSrcweir     // format-locale
574cdf0e10cSrcweir     OUStringBuffer buf( 48 );
575cdf0e10cSrcweir     buf.append( locale.Language );
576cdf0e10cSrcweir     if (locale.Country.getLength())
577cdf0e10cSrcweir     {
578cdf0e10cSrcweir         buf.append( (sal_Unicode)';' );
579cdf0e10cSrcweir         buf.append( locale.Country );
580cdf0e10cSrcweir         if (locale.Variant.getLength())
581cdf0e10cSrcweir         {
582cdf0e10cSrcweir             buf.append( (sal_Unicode)';' );
583cdf0e10cSrcweir             buf.append( locale.Variant );
584cdf0e10cSrcweir         }
585cdf0e10cSrcweir     }
586cdf0e10cSrcweir     addAttribute(
587cdf0e10cSrcweir         OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":format-locale") ),
588cdf0e10cSrcweir         buf.makeStringAndClear() );
589cdf0e10cSrcweir }
590cdf0e10cSrcweir //__________________________________________________________________________________________________
readProp(OUString const & rPropName)591cdf0e10cSrcweir Any ElementDescriptor::readProp( OUString const & rPropName )
592cdf0e10cSrcweir {
593cdf0e10cSrcweir     if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
594cdf0e10cSrcweir     {
595cdf0e10cSrcweir         return _xProps->getPropertyValue( rPropName );
596cdf0e10cSrcweir     }
597cdf0e10cSrcweir     return Any();
598cdf0e10cSrcweir }
599cdf0e10cSrcweir 
600cdf0e10cSrcweir //______________________________________________________________________________
readStringAttr(OUString const & rPropName,OUString const & rAttrName)601cdf0e10cSrcweir void ElementDescriptor::readStringAttr(
602cdf0e10cSrcweir     OUString const & rPropName, OUString const & rAttrName )
603cdf0e10cSrcweir {
604cdf0e10cSrcweir     if (beans::PropertyState_DEFAULT_VALUE !=
605cdf0e10cSrcweir         _xPropState->getPropertyState( rPropName ))
606cdf0e10cSrcweir     {
607cdf0e10cSrcweir         Any a( _xProps->getPropertyValue( rPropName ) );
608cdf0e10cSrcweir         OUString v;
609cdf0e10cSrcweir         if (a >>= v)
610cdf0e10cSrcweir             addAttribute( rAttrName, v );
611cdf0e10cSrcweir         else
612cdf0e10cSrcweir             OSL_ENSURE( 0, "### unexpected property type!" );
613cdf0e10cSrcweir     }
614cdf0e10cSrcweir }
615cdf0e10cSrcweir 
616cdf0e10cSrcweir //__________________________________________________________________________________________________
readHexLongAttr(OUString const & rPropName,OUString const & rAttrName)617cdf0e10cSrcweir void ElementDescriptor::readHexLongAttr( OUString const & rPropName, OUString const & rAttrName )
618cdf0e10cSrcweir {
619cdf0e10cSrcweir     if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
620cdf0e10cSrcweir     {
621cdf0e10cSrcweir         Any a( _xProps->getPropertyValue( rPropName ) );
622cdf0e10cSrcweir         if (a.getValueTypeClass() == TypeClass_LONG)
623cdf0e10cSrcweir         {
624cdf0e10cSrcweir             OUStringBuffer buf( 16 );
625cdf0e10cSrcweir             buf.append( (sal_Unicode)'0' );
626cdf0e10cSrcweir             buf.append( (sal_Unicode)'x' );
627cdf0e10cSrcweir             buf.append( OUString::valueOf( (sal_Int64)(sal_uInt64)*(sal_uInt32 *)a.getValue(), 16 ) );
628cdf0e10cSrcweir             addAttribute( rAttrName, buf.makeStringAndClear() );
629cdf0e10cSrcweir         }
630cdf0e10cSrcweir     }
631cdf0e10cSrcweir }
632cdf0e10cSrcweir 
633cdf0e10cSrcweir //__________________________________________________________________________________________________
readDateFormatAttr(OUString const & rPropName,OUString const & rAttrName)634cdf0e10cSrcweir void ElementDescriptor::readDateFormatAttr( OUString const & rPropName, OUString const & rAttrName )
635cdf0e10cSrcweir {
636cdf0e10cSrcweir     if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
637cdf0e10cSrcweir     {
638cdf0e10cSrcweir         Any a( _xProps->getPropertyValue( rPropName ) );
639cdf0e10cSrcweir         if (a.getValueTypeClass() == TypeClass_SHORT)
640cdf0e10cSrcweir         {
641cdf0e10cSrcweir             switch (*(sal_Int16 const *)a.getValue())
642cdf0e10cSrcweir             {
643cdf0e10cSrcweir             case 0:
644cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("system_short") ) );
645cdf0e10cSrcweir                 break;
646cdf0e10cSrcweir             case 1:
647cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("system_short_YY") ) );
648cdf0e10cSrcweir                 break;
649cdf0e10cSrcweir             case 2:
650cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("system_short_YYYY") ) );
651cdf0e10cSrcweir                 break;
652cdf0e10cSrcweir             case 3:
653cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("system_long") ) );
654cdf0e10cSrcweir                 break;
655cdf0e10cSrcweir             case 4:
656cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("short_DDMMYY") ) );
657cdf0e10cSrcweir                 break;
658cdf0e10cSrcweir             case 5:
659cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("short_MMDDYY") ) );
660cdf0e10cSrcweir                 break;
661cdf0e10cSrcweir             case 6:
662cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("short_YYMMDD") ) );
663cdf0e10cSrcweir                 break;
664cdf0e10cSrcweir             case 7:
665cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("short_DDMMYYYY") ) );
666cdf0e10cSrcweir                 break;
667cdf0e10cSrcweir             case 8:
668cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("short_MMDDYYYY") ) );
669cdf0e10cSrcweir                 break;
670cdf0e10cSrcweir             case 9:
671cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("short_YYYYMMDD") ) );
672cdf0e10cSrcweir                 break;
673cdf0e10cSrcweir             case 10:
674cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("short_YYMMDD_DIN5008") ) );
675cdf0e10cSrcweir                 break;
676cdf0e10cSrcweir             case 11:
677cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("short_YYYYMMDD_DIN5008") ) );
678cdf0e10cSrcweir                 break;
679cdf0e10cSrcweir             default:
680cdf0e10cSrcweir                 OSL_ENSURE( 0, "### unexpected date format!" );
681cdf0e10cSrcweir                 break;
682cdf0e10cSrcweir             }
683cdf0e10cSrcweir         }
684cdf0e10cSrcweir     }
685cdf0e10cSrcweir }
686cdf0e10cSrcweir //__________________________________________________________________________________________________
readTimeFormatAttr(OUString const & rPropName,OUString const & rAttrName)687cdf0e10cSrcweir void ElementDescriptor::readTimeFormatAttr( OUString const & rPropName, OUString const & rAttrName )
688cdf0e10cSrcweir {
689cdf0e10cSrcweir     if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
690cdf0e10cSrcweir     {
691cdf0e10cSrcweir         Any a( _xProps->getPropertyValue( rPropName ) );
692cdf0e10cSrcweir         if (a.getValueTypeClass() == TypeClass_SHORT)
693cdf0e10cSrcweir         {
694cdf0e10cSrcweir             switch (*(sal_Int16 const *)a.getValue())
695cdf0e10cSrcweir             {
696cdf0e10cSrcweir             case 0:
697cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("24h_short") ) );
698cdf0e10cSrcweir                 break;
699cdf0e10cSrcweir             case 1:
700cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("24h_long") ) );
701cdf0e10cSrcweir                 break;
702cdf0e10cSrcweir             case 2:
703cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("12h_short") ) );
704cdf0e10cSrcweir                 break;
705cdf0e10cSrcweir             case 3:
706cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("12h_long") ) );
707cdf0e10cSrcweir                 break;
708cdf0e10cSrcweir             case 4:
709cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("Duration_short") ) );
710cdf0e10cSrcweir                 break;
711cdf0e10cSrcweir             case 5:
712cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("Duration_long") ) );
713cdf0e10cSrcweir                 break;
714cdf0e10cSrcweir             default:
715cdf0e10cSrcweir                 OSL_ENSURE( 0, "### unexpected time format!" );
716cdf0e10cSrcweir                 break;
717cdf0e10cSrcweir             }
718cdf0e10cSrcweir         }
719cdf0e10cSrcweir     }
720cdf0e10cSrcweir }
721cdf0e10cSrcweir //__________________________________________________________________________________________________
readAlignAttr(OUString const & rPropName,OUString const & rAttrName)722cdf0e10cSrcweir void ElementDescriptor::readAlignAttr( OUString const & rPropName, OUString const & rAttrName )
723cdf0e10cSrcweir {
724cdf0e10cSrcweir     if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
725cdf0e10cSrcweir     {
726cdf0e10cSrcweir         Any a( _xProps->getPropertyValue( rPropName ) );
727cdf0e10cSrcweir         if (a.getValueTypeClass() == TypeClass_SHORT)
728cdf0e10cSrcweir         {
729cdf0e10cSrcweir             switch (*(sal_Int16 const *)a.getValue())
730cdf0e10cSrcweir             {
731cdf0e10cSrcweir             case 0:
732cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("left") ) );
733cdf0e10cSrcweir                 break;
734cdf0e10cSrcweir             case 1:
735cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("center") ) );
736cdf0e10cSrcweir                 break;
737cdf0e10cSrcweir             case 2:
738cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("right") ) );
739cdf0e10cSrcweir                 break;
740cdf0e10cSrcweir             default:
741cdf0e10cSrcweir                 OSL_ENSURE( 0, "### illegal alignment value!" );
742cdf0e10cSrcweir                 break;
743cdf0e10cSrcweir             }
744cdf0e10cSrcweir         }
745cdf0e10cSrcweir     }
746cdf0e10cSrcweir }
747cdf0e10cSrcweir //__________________________________________________________________________________________________
readVerticalAlignAttr(OUString const & rPropName,OUString const & rAttrName)748cdf0e10cSrcweir void ElementDescriptor::readVerticalAlignAttr( OUString const & rPropName, OUString const & rAttrName )
749cdf0e10cSrcweir {
750cdf0e10cSrcweir     if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
751cdf0e10cSrcweir     {
752cdf0e10cSrcweir         Any a( _xProps->getPropertyValue( rPropName ) );
753cdf0e10cSrcweir         if (a.getValueTypeClass() == TypeClass_ENUM && a.getValueType() == ::getCppuType( (style::VerticalAlignment*)0 ))
754cdf0e10cSrcweir         {
755cdf0e10cSrcweir             style::VerticalAlignment eAlign;
756cdf0e10cSrcweir             a >>= eAlign;
757cdf0e10cSrcweir             switch (eAlign)
758cdf0e10cSrcweir             {
759cdf0e10cSrcweir             case style::VerticalAlignment_TOP:
760cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("top") ) );
761cdf0e10cSrcweir                 break;
762cdf0e10cSrcweir             case style::VerticalAlignment_MIDDLE:
763cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("center") ) );
764cdf0e10cSrcweir                 break;
765cdf0e10cSrcweir             case style::VerticalAlignment_BOTTOM:
766cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("bottom") ) );
767cdf0e10cSrcweir                 break;
768cdf0e10cSrcweir             default:
769cdf0e10cSrcweir                 OSL_ENSURE( 0, "### illegal vertical alignment value!" );
770cdf0e10cSrcweir                 break;
771cdf0e10cSrcweir             }
772cdf0e10cSrcweir         }
773cdf0e10cSrcweir     }
774cdf0e10cSrcweir }
775cdf0e10cSrcweir //__________________________________________________________________________________________________
readImageAlignAttr(OUString const & rPropName,OUString const & rAttrName)776cdf0e10cSrcweir void ElementDescriptor::readImageAlignAttr( OUString const & rPropName, OUString const & rAttrName )
777cdf0e10cSrcweir {
778cdf0e10cSrcweir     if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
779cdf0e10cSrcweir     {
780cdf0e10cSrcweir         Any a( _xProps->getPropertyValue( rPropName ) );
781cdf0e10cSrcweir         if (a.getValueTypeClass() == TypeClass_SHORT)
782cdf0e10cSrcweir         {
783cdf0e10cSrcweir             switch (*(sal_Int16 const *)a.getValue())
784cdf0e10cSrcweir             {
785cdf0e10cSrcweir             case 0:
786cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("left") ) );
787cdf0e10cSrcweir                 break;
788cdf0e10cSrcweir             case 1:
789cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("top") ) );
790cdf0e10cSrcweir                 break;
791cdf0e10cSrcweir             case 2:
792cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("right") ) );
793cdf0e10cSrcweir                 break;
794cdf0e10cSrcweir             case 3:
795cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("bottom") ) );
796cdf0e10cSrcweir                 break;
797cdf0e10cSrcweir             default:
798cdf0e10cSrcweir                 OSL_ENSURE( 0, "### illegal image alignment value!" );
799cdf0e10cSrcweir                 break;
800cdf0e10cSrcweir             }
801cdf0e10cSrcweir         }
802cdf0e10cSrcweir     }
803cdf0e10cSrcweir }
804cdf0e10cSrcweir //__________________________________________________________________________________________________
readImagePositionAttr(OUString const & rPropName,OUString const & rAttrName)805cdf0e10cSrcweir void ElementDescriptor::readImagePositionAttr( OUString const & rPropName, OUString const & rAttrName )
806cdf0e10cSrcweir {
807cdf0e10cSrcweir     if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
808cdf0e10cSrcweir     {
809cdf0e10cSrcweir         Any a( _xProps->getPropertyValue( rPropName ) );
810cdf0e10cSrcweir         if (a.getValueTypeClass() == TypeClass_SHORT)
811cdf0e10cSrcweir         {
812cdf0e10cSrcweir             switch (*(sal_Int16 const *)a.getValue())
813cdf0e10cSrcweir             {
814cdf0e10cSrcweir             case awt::ImagePosition::LeftTop:
815cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("left-top") ) );
816cdf0e10cSrcweir                 break;
817cdf0e10cSrcweir             case awt::ImagePosition::LeftCenter:
818cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("left-center") ) );
819cdf0e10cSrcweir                 break;
820cdf0e10cSrcweir             case awt::ImagePosition::LeftBottom:
821cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("left-bottom") ) );
822cdf0e10cSrcweir                 break;
823cdf0e10cSrcweir             case awt::ImagePosition::RightTop:
824cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("right-top") ) );
825cdf0e10cSrcweir                 break;
826cdf0e10cSrcweir             case awt::ImagePosition::RightCenter:
827cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("right-center") ) );
828cdf0e10cSrcweir                 break;
829cdf0e10cSrcweir             case awt::ImagePosition::RightBottom:
830cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("right-bottom") ) );
831cdf0e10cSrcweir                 break;
832cdf0e10cSrcweir             case awt::ImagePosition::AboveLeft:
833cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("top-left") ) );
834cdf0e10cSrcweir                 break;
835cdf0e10cSrcweir             case awt::ImagePosition::AboveCenter:
836cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("top-center") ) );
837cdf0e10cSrcweir                 break;
838cdf0e10cSrcweir             case awt::ImagePosition::AboveRight:
839cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("top-right") ) );
840cdf0e10cSrcweir                 break;
841cdf0e10cSrcweir             case awt::ImagePosition::BelowLeft:
842cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("bottom-left") ) );
843cdf0e10cSrcweir                 break;
844cdf0e10cSrcweir             case awt::ImagePosition::BelowCenter:
845cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("bottom-center") ) );
846cdf0e10cSrcweir                 break;
847cdf0e10cSrcweir             case awt::ImagePosition::BelowRight:
848cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("bottom-right") ) );
849cdf0e10cSrcweir                 break;
850cdf0e10cSrcweir             case awt::ImagePosition::Centered:
851cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("center") ) );
852cdf0e10cSrcweir                 break;
853cdf0e10cSrcweir             default:
854cdf0e10cSrcweir                 OSL_ENSURE( 0, "### illegal image position value!" );
855cdf0e10cSrcweir                 break;
856cdf0e10cSrcweir             }
857cdf0e10cSrcweir         }
858cdf0e10cSrcweir     }
859cdf0e10cSrcweir }
860cdf0e10cSrcweir //__________________________________________________________________________________________________
readButtonTypeAttr(OUString const & rPropName,OUString const & rAttrName)861cdf0e10cSrcweir void ElementDescriptor::readButtonTypeAttr( OUString const & rPropName, OUString const & rAttrName )
862cdf0e10cSrcweir {
863cdf0e10cSrcweir     if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
864cdf0e10cSrcweir     {
865cdf0e10cSrcweir         Any a( _xProps->getPropertyValue( rPropName ) );
866cdf0e10cSrcweir         if (a.getValueTypeClass() == TypeClass_SHORT)
867cdf0e10cSrcweir         {
868cdf0e10cSrcweir             switch (*(sal_Int16 const *)a.getValue())
869cdf0e10cSrcweir             {
870cdf0e10cSrcweir             case awt::PushButtonType_STANDARD:
871cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("standard") ) );
872cdf0e10cSrcweir                 break;
873cdf0e10cSrcweir             case awt::PushButtonType_OK:
874cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("ok") ) );
875cdf0e10cSrcweir                 break;
876cdf0e10cSrcweir             case awt::PushButtonType_CANCEL:
877cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("cancel") ) );
878cdf0e10cSrcweir                 break;
879cdf0e10cSrcweir             case awt::PushButtonType_HELP:
880cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("help") ) );
881cdf0e10cSrcweir                 break;
882cdf0e10cSrcweir             default:
883cdf0e10cSrcweir                 OSL_ENSURE( 0, "### illegal button-type value!" );
884cdf0e10cSrcweir                 break;
885cdf0e10cSrcweir             }
886cdf0e10cSrcweir         }
887cdf0e10cSrcweir     }
888cdf0e10cSrcweir }
889cdf0e10cSrcweir //__________________________________________________________________________________________________
readOrientationAttr(OUString const & rPropName,OUString const & rAttrName)890cdf0e10cSrcweir void ElementDescriptor::readOrientationAttr( OUString const & rPropName, OUString const & rAttrName )
891cdf0e10cSrcweir {
892cdf0e10cSrcweir     if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
893cdf0e10cSrcweir     {
894cdf0e10cSrcweir         Any a( _xProps->getPropertyValue( rPropName ) );
895cdf0e10cSrcweir         if (a.getValueTypeClass() == TypeClass_LONG)
896cdf0e10cSrcweir         {
897cdf0e10cSrcweir             switch (*(sal_Int32 const *)a.getValue())
898cdf0e10cSrcweir             {
899cdf0e10cSrcweir             case 0:
900cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("horizontal") ) );
901cdf0e10cSrcweir                 break;
902cdf0e10cSrcweir             case 1:
903cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("vertical") ) );
904cdf0e10cSrcweir                 break;
905cdf0e10cSrcweir             default:
906cdf0e10cSrcweir                 OSL_ENSURE( 0, "### illegal orientation value!" );
907cdf0e10cSrcweir                 break;
908cdf0e10cSrcweir             }
909cdf0e10cSrcweir         }
910cdf0e10cSrcweir     }
911cdf0e10cSrcweir }
912cdf0e10cSrcweir //__________________________________________________________________________________________________
readLineEndFormatAttr(OUString const & rPropName,OUString const & rAttrName)913cdf0e10cSrcweir void ElementDescriptor::readLineEndFormatAttr( OUString const & rPropName, OUString const & rAttrName )
914cdf0e10cSrcweir {
915cdf0e10cSrcweir     if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
916cdf0e10cSrcweir     {
917cdf0e10cSrcweir         Any a( _xProps->getPropertyValue( rPropName ) );
918cdf0e10cSrcweir         if (a.getValueTypeClass() == TypeClass_SHORT)
919cdf0e10cSrcweir         {
920cdf0e10cSrcweir             switch (*(sal_Int16 const *)a.getValue())
921cdf0e10cSrcweir             {
922cdf0e10cSrcweir             case awt::LineEndFormat::CARRIAGE_RETURN:
923cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("carriage-return") ) );
924cdf0e10cSrcweir                 break;
925cdf0e10cSrcweir             case awt::LineEndFormat::LINE_FEED:
926cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("line-feed") ) );
927cdf0e10cSrcweir                 break;
928cdf0e10cSrcweir             case awt::LineEndFormat::CARRIAGE_RETURN_LINE_FEED:
929cdf0e10cSrcweir                 addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("carriage-return-line-feed") ) );
930cdf0e10cSrcweir                 break;
931cdf0e10cSrcweir             default:
932cdf0e10cSrcweir                 OSL_ENSURE( 0, "### illegal line end format value!" );
933cdf0e10cSrcweir                 break;
934cdf0e10cSrcweir             }
935cdf0e10cSrcweir         }
936cdf0e10cSrcweir     }
937cdf0e10cSrcweir }
938cdf0e10cSrcweir //__________________________________________________________________________________________________
readSelectionTypeAttr(OUString const & rPropName,OUString const & rAttrName)939cdf0e10cSrcweir void ElementDescriptor::readSelectionTypeAttr( OUString const & rPropName, OUString const & rAttrName )
940cdf0e10cSrcweir {
941cdf0e10cSrcweir     if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
942cdf0e10cSrcweir     {
943cdf0e10cSrcweir         Any aSelectionType ( _xProps->getPropertyValue( rPropName ) );
944cdf0e10cSrcweir 
945cdf0e10cSrcweir         if (aSelectionType.getValueTypeClass() == TypeClass_ENUM && aSelectionType.getValueType() == ::getCppuType( (::view::SelectionType*)0 ))
946cdf0e10cSrcweir         {
947cdf0e10cSrcweir             ::view::SelectionType eSelectionType;
948cdf0e10cSrcweir             aSelectionType >>= eSelectionType;
949cdf0e10cSrcweir 
950cdf0e10cSrcweir             switch (eSelectionType)
951cdf0e10cSrcweir             {
952cdf0e10cSrcweir                 case ::view::SelectionType_NONE:
953cdf0e10cSrcweir                     addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("none") ) );
954cdf0e10cSrcweir                     break;
955cdf0e10cSrcweir                 case ::view::SelectionType_SINGLE:
956cdf0e10cSrcweir                     addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("single") ) );
957cdf0e10cSrcweir                     break;
958cdf0e10cSrcweir                 case ::view::SelectionType_MULTI:
959cdf0e10cSrcweir                     addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("multi") ) );
960cdf0e10cSrcweir                     break;
961cdf0e10cSrcweir                 case ::view::SelectionType_RANGE:
962cdf0e10cSrcweir                     addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("range") ) );
963cdf0e10cSrcweir                     break;
964cdf0e10cSrcweir                 default:
965cdf0e10cSrcweir                     OSL_ENSURE( 0, "### illegal selection type value!" );
966cdf0e10cSrcweir                     break;
967cdf0e10cSrcweir             }
968cdf0e10cSrcweir         }
969cdf0e10cSrcweir     }
970cdf0e10cSrcweir }
971cdf0e10cSrcweir //__________________________________________________________________________________________________
readImageScaleModeAttr(OUString const & rPropName,OUString const & rAttrName)972874957b9STsutomu Uchino void ElementDescriptor::readImageScaleModeAttr( OUString const & rPropName, OUString const & rAttrName )
973874957b9STsutomu Uchino {
974874957b9STsutomu Uchino     if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
975874957b9STsutomu Uchino     {
976874957b9STsutomu Uchino         Any aImageScaleMode( _xProps->getPropertyValue( rPropName ) );
977874957b9STsutomu Uchino 
978874957b9STsutomu Uchino         if (aImageScaleMode.getValueTypeClass() == TypeClass_SHORT)
979874957b9STsutomu Uchino         {
980874957b9STsutomu Uchino             sal_Int16 nImageScaleMode;
981874957b9STsutomu Uchino             aImageScaleMode >>= nImageScaleMode;
982874957b9STsutomu Uchino 
983874957b9STsutomu Uchino             switch(nImageScaleMode)
984874957b9STsutomu Uchino             {
985874957b9STsutomu Uchino                 case ::awt::ImageScaleMode::NONE:
986874957b9STsutomu Uchino                     addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("none") ) );
987874957b9STsutomu Uchino                     break;
988874957b9STsutomu Uchino                 case ::awt::ImageScaleMode::ISOTROPIC:
989874957b9STsutomu Uchino                     addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("isotropic") ) );
990874957b9STsutomu Uchino                     break;
991874957b9STsutomu Uchino                 case ::awt::ImageScaleMode::ANISOTROPIC:
992874957b9STsutomu Uchino                     addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("anisotropic") ) );
993874957b9STsutomu Uchino                     break;
994874957b9STsutomu Uchino                 default:
995874957b9STsutomu Uchino                     OSL_ENSURE( 0, "### illegal image scale mode value.");
996874957b9STsutomu Uchino                     break;
997874957b9STsutomu Uchino             }
998874957b9STsutomu Uchino         }
999874957b9STsutomu Uchino     }
1000874957b9STsutomu Uchino }
1001874957b9STsutomu Uchino //__________________________________________________________________________________________________
readDefaults(bool supportPrintable,bool supportVisible)1002cdf0e10cSrcweir void ElementDescriptor::readDefaults( bool supportPrintable, bool supportVisible )
1003cdf0e10cSrcweir {
1004cdf0e10cSrcweir     Any a( _xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Name") ) ) );
1005cdf0e10cSrcweir     addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ),
1006cdf0e10cSrcweir              * reinterpret_cast< const OUString * >( a.getValue() ) );
1007cdf0e10cSrcweir     readShortAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("TabIndex") ),
1008cdf0e10cSrcweir                    OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":tab-index") ) );
1009cdf0e10cSrcweir 
1010cdf0e10cSrcweir     sal_Bool bEnabled = sal_False;
1011cdf0e10cSrcweir     if (_xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Enabled") ) ) >>= bEnabled)
1012cdf0e10cSrcweir     {
1013cdf0e10cSrcweir         if (! bEnabled)
1014cdf0e10cSrcweir         {
1015cdf0e10cSrcweir             addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":disabled") ),
1016cdf0e10cSrcweir                           OUString( RTL_CONSTASCII_USTRINGPARAM("true") ) );
1017cdf0e10cSrcweir         }
1018cdf0e10cSrcweir     }
1019cdf0e10cSrcweir     else
1020cdf0e10cSrcweir     {
1021cdf0e10cSrcweir         OSL_ENSURE( 0, "unexpected property type for \"Enabled\": not bool!" );
1022cdf0e10cSrcweir     }
1023cdf0e10cSrcweir 
1024cdf0e10cSrcweir     sal_Bool bVisible = sal_True;
1025cdf0e10cSrcweir     if (supportVisible) try
1026cdf0e10cSrcweir     {
1027cdf0e10cSrcweir         if (_xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("EnableVisible") ) ) >>= bVisible)
1028cdf0e10cSrcweir         {
1029cdf0e10cSrcweir 
1030cdf0e10cSrcweir             // only write out the non default case
1031cdf0e10cSrcweir             if (! bVisible)
1032cdf0e10cSrcweir             {
1033cdf0e10cSrcweir                 addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":visible") ),
1034cdf0e10cSrcweir                               OUString( RTL_CONSTASCII_USTRINGPARAM("false") ) );
1035cdf0e10cSrcweir             }
1036cdf0e10cSrcweir         }
1037cdf0e10cSrcweir     }
1038cdf0e10cSrcweir     catch( Exception& )
1039cdf0e10cSrcweir     {
1040cdf0e10cSrcweir         DBG_UNHANDLED_EXCEPTION();
1041cdf0e10cSrcweir     }
1042cdf0e10cSrcweir     // force writing of pos/size
1043cdf0e10cSrcweir     a = _xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("PositionX") ) );
1044cdf0e10cSrcweir     if (a.getValueTypeClass() == TypeClass_LONG)
1045cdf0e10cSrcweir     {
1046cdf0e10cSrcweir         addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":left") ),
1047cdf0e10cSrcweir                       OUString::valueOf( *(sal_Int32 const *)a.getValue() ) );
1048cdf0e10cSrcweir     }
1049cdf0e10cSrcweir     a = _xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("PositionY") ) );
1050cdf0e10cSrcweir     if (a.getValueTypeClass() == TypeClass_LONG)
1051cdf0e10cSrcweir     {
1052cdf0e10cSrcweir         addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":top") ),
1053cdf0e10cSrcweir                       OUString::valueOf( *(sal_Int32 const *)a.getValue() ) );
1054cdf0e10cSrcweir     }
1055cdf0e10cSrcweir     a = _xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Width") ) );
1056cdf0e10cSrcweir     if (a.getValueTypeClass() == TypeClass_LONG)
1057cdf0e10cSrcweir     {
1058cdf0e10cSrcweir         addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":width") ),
1059cdf0e10cSrcweir                       OUString::valueOf( *(sal_Int32 const *)a.getValue() ) );
1060cdf0e10cSrcweir     }
1061cdf0e10cSrcweir     a = _xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Height") ) );
1062cdf0e10cSrcweir     if (a.getValueTypeClass() == TypeClass_LONG)
1063cdf0e10cSrcweir     {
1064cdf0e10cSrcweir         addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":height") ),
1065cdf0e10cSrcweir                       OUString::valueOf( *(sal_Int32 const *)a.getValue() ) );
1066cdf0e10cSrcweir     }
1067cdf0e10cSrcweir 
1068cdf0e10cSrcweir     if (supportPrintable)
1069cdf0e10cSrcweir     {
1070cdf0e10cSrcweir         readBoolAttr(
1071cdf0e10cSrcweir             OUString( RTL_CONSTASCII_USTRINGPARAM("Printable") ),
1072cdf0e10cSrcweir             OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":printable") ) );
1073cdf0e10cSrcweir     }
1074cdf0e10cSrcweir     readLongAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Step") ),
1075cdf0e10cSrcweir                   OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":page") ) );
1076cdf0e10cSrcweir     readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Tag") ),
1077cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":tag") ) );
1078cdf0e10cSrcweir     readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("HelpText") ),
1079cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":help-text") ) );
1080cdf0e10cSrcweir     readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("HelpURL") ),
1081cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":help-url") ) );
1082cdf0e10cSrcweir }
1083cdf0e10cSrcweir 
1084cdf0e10cSrcweir struct StringTriple
1085cdf0e10cSrcweir {
1086cdf0e10cSrcweir     char const * first;
1087cdf0e10cSrcweir     char const * second;
1088cdf0e10cSrcweir     char const * third;
1089cdf0e10cSrcweir };
1090cdf0e10cSrcweir extern StringTriple const * const g_pEventTranslations;
1091cdf0e10cSrcweir 
1092cdf0e10cSrcweir //__________________________________________________________________________________________________
readEvents()1093cdf0e10cSrcweir void ElementDescriptor::readEvents()
1094cdf0e10cSrcweir     SAL_THROW( (Exception) )
1095cdf0e10cSrcweir {
1096cdf0e10cSrcweir     Reference< script::XScriptEventsSupplier > xSupplier( _xProps, UNO_QUERY );
1097cdf0e10cSrcweir     if (xSupplier.is())
1098cdf0e10cSrcweir     {
1099cdf0e10cSrcweir         Reference< container::XNameContainer > xEvents( xSupplier->getEvents() );
1100cdf0e10cSrcweir         if (xEvents.is())
1101cdf0e10cSrcweir         {
1102cdf0e10cSrcweir             Sequence< OUString > aNames( xEvents->getElementNames() );
1103cdf0e10cSrcweir             OUString const * pNames = aNames.getConstArray();
1104cdf0e10cSrcweir             for ( sal_Int32 nPos = 0; nPos < aNames.getLength(); ++nPos )
1105cdf0e10cSrcweir             {
1106cdf0e10cSrcweir                 script::ScriptEventDescriptor descr;
1107cdf0e10cSrcweir                 if (xEvents->getByName( pNames[ nPos ] ) >>= descr)
1108cdf0e10cSrcweir                 {
1109cdf0e10cSrcweir                     OSL_ENSURE( descr.ListenerType.getLength() > 0 &&
1110cdf0e10cSrcweir                                 descr.EventMethod.getLength() > 0 &&
1111cdf0e10cSrcweir                                 descr.ScriptCode.getLength() > 0 &&
1112cdf0e10cSrcweir                                 descr.ScriptType.getLength() > 0,
1113cdf0e10cSrcweir                                 "### invalid event descr!" );
1114cdf0e10cSrcweir 
1115cdf0e10cSrcweir                     OUString aEventName;
1116cdf0e10cSrcweir 
1117cdf0e10cSrcweir                     if (! descr.AddListenerParam.getLength())
1118cdf0e10cSrcweir                     {
1119cdf0e10cSrcweir                         // detection of event-name
1120cdf0e10cSrcweir                         ::rtl::OString listenerType(
1121cdf0e10cSrcweir                             ::rtl::OUStringToOString(
1122cdf0e10cSrcweir                                 descr.ListenerType,
1123cdf0e10cSrcweir                                 RTL_TEXTENCODING_ASCII_US ) );
1124cdf0e10cSrcweir                         ::rtl::OString eventMethod(
1125cdf0e10cSrcweir                             ::rtl::OUStringToOString(
1126cdf0e10cSrcweir                                 descr.EventMethod,
1127cdf0e10cSrcweir                                 RTL_TEXTENCODING_ASCII_US ) );
1128cdf0e10cSrcweir                         StringTriple const * p = g_pEventTranslations;
1129cdf0e10cSrcweir                         while (p->first)
1130cdf0e10cSrcweir                         {
1131cdf0e10cSrcweir                             if (0 == ::rtl_str_compare( p->second, eventMethod.getStr() ) &&
1132cdf0e10cSrcweir                                 0 == ::rtl_str_compare( p->first, listenerType.getStr() ))
1133cdf0e10cSrcweir                             {
1134cdf0e10cSrcweir                                 aEventName = OUString( p->third, ::rtl_str_getLength( p->third ), RTL_TEXTENCODING_ASCII_US );
1135cdf0e10cSrcweir                                 break;
1136cdf0e10cSrcweir                             }
1137cdf0e10cSrcweir                             ++p;
1138cdf0e10cSrcweir                         }
1139cdf0e10cSrcweir                     }
1140cdf0e10cSrcweir 
1141cdf0e10cSrcweir                     ElementDescriptor * pElem;
1142cdf0e10cSrcweir                     Reference< xml::sax::XAttributeList > xElem;
1143cdf0e10cSrcweir 
1144cdf0e10cSrcweir                     if (aEventName.getLength()) // script:event
1145cdf0e10cSrcweir                     {
1146cdf0e10cSrcweir                         pElem = new ElementDescriptor(
1147cdf0e10cSrcweir                             OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":event") ) );
1148cdf0e10cSrcweir                         xElem = pElem;
1149cdf0e10cSrcweir 
1150cdf0e10cSrcweir                         pElem->addAttribute(
1151cdf0e10cSrcweir                             OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":event-name") ),
1152cdf0e10cSrcweir                             aEventName );
1153cdf0e10cSrcweir                     }
1154cdf0e10cSrcweir                     else // script:listener-event
1155cdf0e10cSrcweir                     {
1156cdf0e10cSrcweir                         pElem = new ElementDescriptor(
1157cdf0e10cSrcweir                             OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":listener-event") ) );
1158cdf0e10cSrcweir                         xElem = pElem;
1159cdf0e10cSrcweir 
1160cdf0e10cSrcweir                         pElem->addAttribute(
1161cdf0e10cSrcweir                             OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":listener-type") ),
1162cdf0e10cSrcweir                             descr.ListenerType );
1163cdf0e10cSrcweir                         pElem->addAttribute(
1164cdf0e10cSrcweir                             OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":listener-method") ),
1165cdf0e10cSrcweir                             descr.EventMethod );
1166cdf0e10cSrcweir 
1167cdf0e10cSrcweir                         if (descr.AddListenerParam.getLength())
1168cdf0e10cSrcweir                         {
1169cdf0e10cSrcweir                             pElem->addAttribute(
1170cdf0e10cSrcweir                                 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":listener-param") ),
1171cdf0e10cSrcweir                                 descr.AddListenerParam );
1172cdf0e10cSrcweir                         }
1173cdf0e10cSrcweir                     }
1174cdf0e10cSrcweir                     if ( descr.ScriptType.equals( OUString(  RTL_CONSTASCII_USTRINGPARAM( "StarBasic" ) ) ) )
1175cdf0e10cSrcweir                     {
1176cdf0e10cSrcweir                         // separate optional location
1177cdf0e10cSrcweir                         sal_Int32 nIndex = descr.ScriptCode.indexOf( (sal_Unicode)':' );
1178cdf0e10cSrcweir                         if (nIndex >= 0)
1179cdf0e10cSrcweir                         {
1180cdf0e10cSrcweir                             pElem->addAttribute(
1181cdf0e10cSrcweir                                 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":location") ),
1182cdf0e10cSrcweir                                 descr.ScriptCode.copy( 0, nIndex ) );
1183cdf0e10cSrcweir                             pElem->addAttribute(
1184cdf0e10cSrcweir                                 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":macro-name") ),
1185cdf0e10cSrcweir                                 descr.ScriptCode.copy( nIndex +1 ) );
1186cdf0e10cSrcweir                         }
1187cdf0e10cSrcweir                         else
1188cdf0e10cSrcweir                         {
1189cdf0e10cSrcweir                             pElem->addAttribute(
1190cdf0e10cSrcweir                                 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":macro-name") ),
1191cdf0e10cSrcweir                                 descr.ScriptCode );
1192cdf0e10cSrcweir                         }
1193cdf0e10cSrcweir                     }
1194cdf0e10cSrcweir                     else
1195cdf0e10cSrcweir                     {
1196cdf0e10cSrcweir                         pElem->addAttribute(
1197cdf0e10cSrcweir                             OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":macro-name") ),
1198cdf0e10cSrcweir                             descr.ScriptCode );
1199cdf0e10cSrcweir                     }
1200cdf0e10cSrcweir 
1201cdf0e10cSrcweir                     // language
1202cdf0e10cSrcweir                     pElem->addAttribute(
1203cdf0e10cSrcweir                         OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":language") ),
1204cdf0e10cSrcweir                         descr.ScriptType );
1205cdf0e10cSrcweir 
1206cdf0e10cSrcweir                     addSubElement( xElem );
1207cdf0e10cSrcweir                 }
1208cdf0e10cSrcweir                 else
1209cdf0e10cSrcweir                 {
1210cdf0e10cSrcweir                     OSL_ENSURE( 0, "### unexpected event type in container!" );
1211cdf0e10cSrcweir                 }
1212cdf0e10cSrcweir             }
1213cdf0e10cSrcweir         }
1214cdf0e10cSrcweir     }
1215cdf0e10cSrcweir }
1216cdf0e10cSrcweir 
1217cdf0e10cSrcweir //##################################################################################################
1218cdf0e10cSrcweir 
equalFont(Style const & style1,Style const & style2)1219cdf0e10cSrcweir inline bool equalFont( Style const & style1, Style const & style2 )
1220cdf0e10cSrcweir {
1221cdf0e10cSrcweir     awt::FontDescriptor const & f1 = style1._descr;
1222cdf0e10cSrcweir     awt::FontDescriptor const & f2 = style2._descr;
1223cdf0e10cSrcweir     return (
1224cdf0e10cSrcweir         f1.Name == f2.Name &&
1225cdf0e10cSrcweir         f1.Height == f2.Height &&
1226cdf0e10cSrcweir         f1.Width == f2.Width &&
1227cdf0e10cSrcweir         f1.StyleName == f2.StyleName &&
1228cdf0e10cSrcweir         f1.Family == f2.Family &&
1229cdf0e10cSrcweir         f1.CharSet == f2.CharSet &&
1230cdf0e10cSrcweir         f1.Pitch == f2.CharSet &&
1231cdf0e10cSrcweir         f1.CharacterWidth == f2.CharacterWidth &&
1232cdf0e10cSrcweir         f1.Weight == f2.Weight &&
1233cdf0e10cSrcweir         f1.Slant == f2.Slant &&
1234cdf0e10cSrcweir         f1.Underline == f2.Underline &&
1235cdf0e10cSrcweir         f1.Strikeout == f2.Strikeout &&
1236cdf0e10cSrcweir         f1.Orientation == f2.Orientation &&
1237cdf0e10cSrcweir         (f1.Kerning != sal_False) == (f2.Kerning != sal_False) &&
1238cdf0e10cSrcweir         (f1.WordLineMode != sal_False) == (f2.WordLineMode != sal_False) &&
1239cdf0e10cSrcweir         f1.Type == f2.Type &&
1240cdf0e10cSrcweir         style1._fontRelief == style2._fontRelief &&
1241cdf0e10cSrcweir         style1._fontEmphasisMark == style2._fontEmphasisMark
1242cdf0e10cSrcweir         );
1243cdf0e10cSrcweir }
1244cdf0e10cSrcweir //__________________________________________________________________________________________________
getStyleId(Style const & rStyle)1245cdf0e10cSrcweir OUString StyleBag::getStyleId( Style const & rStyle )
1246cdf0e10cSrcweir     SAL_THROW( () )
1247cdf0e10cSrcweir {
1248*52eeacffSMatthias Seidel     if (! rStyle._set) // nothing set
1249cdf0e10cSrcweir     {
1250cdf0e10cSrcweir         return OUString(); // everything default: no need to export a specific style
1251cdf0e10cSrcweir     }
1252cdf0e10cSrcweir 
1253cdf0e10cSrcweir     // lookup existing style
1254cdf0e10cSrcweir     for ( size_t nStylesPos = 0; nStylesPos < _styles.size(); ++nStylesPos )
1255cdf0e10cSrcweir     {
1256cdf0e10cSrcweir         Style * pStyle = _styles[ nStylesPos ];
1257cdf0e10cSrcweir 
1258cdf0e10cSrcweir         short demanded_defaults = ~rStyle._set & rStyle._all;
1259cdf0e10cSrcweir         // test, if defaults are not set
1260cdf0e10cSrcweir         if ((~pStyle->_set & demanded_defaults) == demanded_defaults &&
1261cdf0e10cSrcweir             (rStyle._set & (pStyle->_all & ~pStyle->_set)) == 0)
1262cdf0e10cSrcweir         {
1263cdf0e10cSrcweir             short bset = rStyle._set & pStyle->_set;
1264cdf0e10cSrcweir             if ((bset & 0x1) &&
1265cdf0e10cSrcweir                 rStyle._backgroundColor != pStyle->_backgroundColor)
1266cdf0e10cSrcweir                 continue;
1267cdf0e10cSrcweir             if ((bset & 0x2) &&
1268cdf0e10cSrcweir                 rStyle._textColor != pStyle->_textColor)
1269cdf0e10cSrcweir                 continue;
1270cdf0e10cSrcweir             if ((bset & 0x20) &&
1271cdf0e10cSrcweir                 rStyle._textLineColor != pStyle->_textLineColor)
1272cdf0e10cSrcweir                 continue;
1273cdf0e10cSrcweir             if ((bset & 0x10) &&
1274cdf0e10cSrcweir                 rStyle._fillColor != pStyle->_fillColor)
1275cdf0e10cSrcweir                 continue;
1276cdf0e10cSrcweir             if ((bset & 0x4) &&
1277cdf0e10cSrcweir                 (rStyle._border != pStyle->_border ||
1278cdf0e10cSrcweir                  (rStyle._border == BORDER_SIMPLE_COLOR &&
1279cdf0e10cSrcweir                   rStyle._borderColor != pStyle->_borderColor)))
1280cdf0e10cSrcweir                 continue;
1281cdf0e10cSrcweir             if ((bset & 0x8) &&
1282cdf0e10cSrcweir                 !equalFont( rStyle, *pStyle ))
1283cdf0e10cSrcweir                 continue;
1284cdf0e10cSrcweir             if ((bset & 0x40) &&
1285cdf0e10cSrcweir                 rStyle._visualEffect != pStyle->_visualEffect)
1286cdf0e10cSrcweir                 continue;
1287cdf0e10cSrcweir 
1288cdf0e10cSrcweir             // merge in
1289cdf0e10cSrcweir             short bnset = rStyle._set & ~pStyle->_set;
1290cdf0e10cSrcweir             if (bnset & 0x1)
1291cdf0e10cSrcweir                 pStyle->_backgroundColor = rStyle._backgroundColor;
1292cdf0e10cSrcweir             if (bnset & 0x2)
1293cdf0e10cSrcweir                 pStyle->_textColor = rStyle._textColor;
1294cdf0e10cSrcweir             if (bnset & 0x20)
1295cdf0e10cSrcweir                 pStyle->_textLineColor = rStyle._textLineColor;
1296cdf0e10cSrcweir             if (bnset & 0x10)
1297cdf0e10cSrcweir                 pStyle->_fillColor = rStyle._fillColor;
1298cdf0e10cSrcweir             if (bnset & 0x4) {
1299cdf0e10cSrcweir                 pStyle->_border = rStyle._border;
1300cdf0e10cSrcweir                 pStyle->_borderColor = rStyle._borderColor;
1301cdf0e10cSrcweir             }
1302cdf0e10cSrcweir             if (bnset & 0x8) {
1303cdf0e10cSrcweir                 pStyle->_descr = rStyle._descr;
1304cdf0e10cSrcweir                 pStyle->_fontRelief = rStyle._fontRelief;
1305cdf0e10cSrcweir                 pStyle->_fontEmphasisMark = rStyle._fontEmphasisMark;
1306cdf0e10cSrcweir             }
1307cdf0e10cSrcweir             if (bnset & 0x40)
1308cdf0e10cSrcweir                 pStyle->_visualEffect = rStyle._visualEffect;
1309cdf0e10cSrcweir 
1310cdf0e10cSrcweir             pStyle->_all |= rStyle._all;
1311cdf0e10cSrcweir             pStyle->_set |= rStyle._set;
1312cdf0e10cSrcweir 
1313cdf0e10cSrcweir             return pStyle->_id;
1314cdf0e10cSrcweir         }
1315cdf0e10cSrcweir     }
1316cdf0e10cSrcweir 
1317cdf0e10cSrcweir     // no appr style found, append new
1318cdf0e10cSrcweir     Style * pStyle = new Style( rStyle );
1319cdf0e10cSrcweir     pStyle->_id = OUString::valueOf( (sal_Int32)_styles.size() );
1320cdf0e10cSrcweir     _styles.push_back( pStyle );
1321cdf0e10cSrcweir     return pStyle->_id;
1322cdf0e10cSrcweir }
1323cdf0e10cSrcweir //__________________________________________________________________________________________________
~StyleBag()1324cdf0e10cSrcweir StyleBag::~StyleBag() SAL_THROW( () )
1325cdf0e10cSrcweir {
1326cdf0e10cSrcweir     for ( size_t nPos = 0; nPos < _styles.size(); ++nPos )
1327cdf0e10cSrcweir     {
1328cdf0e10cSrcweir         delete _styles[ nPos ];
1329cdf0e10cSrcweir     }
1330cdf0e10cSrcweir }
1331cdf0e10cSrcweir //__________________________________________________________________________________________________
dump(Reference<xml::sax::XExtendedDocumentHandler> const & xOut)1332cdf0e10cSrcweir void StyleBag::dump( Reference< xml::sax::XExtendedDocumentHandler > const & xOut )
1333cdf0e10cSrcweir {
1334cdf0e10cSrcweir     if (! _styles.empty())
1335cdf0e10cSrcweir     {
1336cdf0e10cSrcweir         OUString aStylesName( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":styles") );
1337cdf0e10cSrcweir         xOut->ignorableWhitespace( OUString() );
1338cdf0e10cSrcweir         xOut->startElement( aStylesName, Reference< xml::sax::XAttributeList >() );
1339cdf0e10cSrcweir         // export styles
1340cdf0e10cSrcweir         for ( size_t nPos = 0; nPos < _styles.size(); ++nPos )
1341cdf0e10cSrcweir         {
1342cdf0e10cSrcweir             Reference< xml::sax::XAttributeList > xAttr( _styles[ nPos ]->createElement() );
1343cdf0e10cSrcweir             static_cast< ElementDescriptor * >( xAttr.get() )->dump( xOut.get() );
1344cdf0e10cSrcweir         }
1345cdf0e10cSrcweir         xOut->ignorableWhitespace( OUString() );
1346cdf0e10cSrcweir         xOut->endElement( aStylesName );
1347cdf0e10cSrcweir     }
1348cdf0e10cSrcweir }
1349cdf0e10cSrcweir 
1350cdf0e10cSrcweir //##################################################################################################
1351cdf0e10cSrcweir 
1352cdf0e10cSrcweir //==================================================================================================
exportDialogModel(Reference<xml::sax::XExtendedDocumentHandler> const & xOut,Reference<container::XNameContainer> const & xDialogModel)1353cdf0e10cSrcweir void SAL_CALL exportDialogModel(
1354cdf0e10cSrcweir     Reference< xml::sax::XExtendedDocumentHandler > const & xOut,
1355cdf0e10cSrcweir     Reference< container::XNameContainer > const & xDialogModel )
1356cdf0e10cSrcweir     SAL_THROW( (Exception) )
1357cdf0e10cSrcweir {
1358cdf0e10cSrcweir     StyleBag all_styles;
1359cdf0e10cSrcweir     ::std::vector< Reference< xml::sax::XAttributeList > > all_elements;
1360cdf0e10cSrcweir 
1361cdf0e10cSrcweir     // read out all props
1362cdf0e10cSrcweir 
1363cdf0e10cSrcweir     Sequence< OUString > aElements( xDialogModel->getElementNames() );
1364cdf0e10cSrcweir     OUString const * pElements = aElements.getConstArray();
1365cdf0e10cSrcweir 
1366cdf0e10cSrcweir     ElementDescriptor * pRadioGroup = 0;
1367cdf0e10cSrcweir 
1368cdf0e10cSrcweir     sal_Int32 nPos;
1369cdf0e10cSrcweir     for ( nPos = 0; nPos < aElements.getLength(); ++nPos )
1370cdf0e10cSrcweir     {
1371cdf0e10cSrcweir         Any aControlModel( xDialogModel->getByName( pElements[ nPos ] ) );
1372cdf0e10cSrcweir         Reference< beans::XPropertySet > xProps;
1373cdf0e10cSrcweir         OSL_VERIFY( aControlModel >>= xProps );
1374cdf0e10cSrcweir         if (! xProps.is())
1375cdf0e10cSrcweir             continue;
1376cdf0e10cSrcweir         Reference< beans::XPropertyState > xPropState( xProps, UNO_QUERY );
1377cdf0e10cSrcweir         OSL_ENSURE( xPropState.is(), "no XPropertyState!" );
1378cdf0e10cSrcweir         if (! xPropState.is())
1379cdf0e10cSrcweir             continue;
1380cdf0e10cSrcweir         Reference< lang::XServiceInfo > xServiceInfo( xProps, UNO_QUERY );
1381cdf0e10cSrcweir         OSL_ENSURE( xServiceInfo.is(), "no XServiceInfo!" );
1382cdf0e10cSrcweir         if (! xServiceInfo.is())
1383cdf0e10cSrcweir             continue;
1384cdf0e10cSrcweir 
1385cdf0e10cSrcweir         ElementDescriptor * pElem = 0;
1386cdf0e10cSrcweir         Reference< xml::sax::XAttributeList > xElem;
1387cdf0e10cSrcweir 
1388cdf0e10cSrcweir         // group up radio buttons
1389cdf0e10cSrcweir         if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlRadioButtonModel") ) ) )
1390cdf0e10cSrcweir         {
1391cdf0e10cSrcweir             if (! pRadioGroup) // open radiogroup
1392cdf0e10cSrcweir             {
1393cdf0e10cSrcweir                 pRadioGroup = new ElementDescriptor(
1394cdf0e10cSrcweir                     xProps, xPropState,
1395cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":radiogroup") ) );
1396cdf0e10cSrcweir                 all_elements.push_back( pRadioGroup );
1397cdf0e10cSrcweir             }
1398cdf0e10cSrcweir 
1399cdf0e10cSrcweir             pElem = new ElementDescriptor(
1400cdf0e10cSrcweir                 xProps, xPropState,
1401cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":radio") ) );
1402cdf0e10cSrcweir             xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1403cdf0e10cSrcweir             pElem->readRadioButtonModel( &all_styles );
1404cdf0e10cSrcweir             pRadioGroup->addSubElement( xElem );
1405cdf0e10cSrcweir         }
1406cdf0e10cSrcweir         else // no radio
1407cdf0e10cSrcweir         {
1408cdf0e10cSrcweir             pRadioGroup = 0; // close radiogroup
1409cdf0e10cSrcweir 
1410cdf0e10cSrcweir             if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlButtonModel") ) ) )
1411cdf0e10cSrcweir             {
1412cdf0e10cSrcweir                 pElem = new ElementDescriptor(
1413cdf0e10cSrcweir                     xProps, xPropState,
1414cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":button") ) );
1415cdf0e10cSrcweir                 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1416cdf0e10cSrcweir                 pElem->readButtonModel( &all_styles );
1417cdf0e10cSrcweir             }
1418cdf0e10cSrcweir             else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlCheckBoxModel") ) ) )
1419cdf0e10cSrcweir             {
1420cdf0e10cSrcweir                 pElem = new ElementDescriptor(
1421cdf0e10cSrcweir                     xProps, xPropState,
1422cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":checkbox") ) );
1423cdf0e10cSrcweir                 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1424cdf0e10cSrcweir                 pElem->readCheckBoxModel( &all_styles );
1425cdf0e10cSrcweir             }
1426cdf0e10cSrcweir             else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlComboBoxModel") ) ) )
1427cdf0e10cSrcweir             {
1428cdf0e10cSrcweir                 pElem = new ElementDescriptor(
1429cdf0e10cSrcweir                     xProps, xPropState,
1430cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":combobox") ) );
1431cdf0e10cSrcweir                 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1432cdf0e10cSrcweir                 pElem->readComboBoxModel( &all_styles );
1433cdf0e10cSrcweir             }
1434cdf0e10cSrcweir             else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlListBoxModel") ) ) )
1435cdf0e10cSrcweir             {
1436cdf0e10cSrcweir                 pElem = new ElementDescriptor(
1437cdf0e10cSrcweir                     xProps, xPropState,
1438cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":menulist") ) );
1439cdf0e10cSrcweir                 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1440cdf0e10cSrcweir                 pElem->readListBoxModel( &all_styles );
1441cdf0e10cSrcweir             }
1442cdf0e10cSrcweir             else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlGroupBoxModel") ) ) )
1443cdf0e10cSrcweir             {
1444cdf0e10cSrcweir                 pElem = new ElementDescriptor(
1445cdf0e10cSrcweir                     xProps, xPropState,
1446cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":titledbox") ) );
1447cdf0e10cSrcweir                 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1448cdf0e10cSrcweir                 pElem->readGroupBoxModel( &all_styles );
1449cdf0e10cSrcweir             }
1450cdf0e10cSrcweir             else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedTextModel") ) ) )
1451cdf0e10cSrcweir             {
1452cdf0e10cSrcweir                 pElem = new ElementDescriptor(
1453cdf0e10cSrcweir                     xProps, xPropState,
1454cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":text") ) );
1455cdf0e10cSrcweir                 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1456cdf0e10cSrcweir                 pElem->readFixedTextModel( &all_styles );
1457cdf0e10cSrcweir             }
1458cdf0e10cSrcweir             else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlEditModel") ) ) )
1459cdf0e10cSrcweir             {
1460cdf0e10cSrcweir                 pElem = new ElementDescriptor(
1461cdf0e10cSrcweir                     xProps, xPropState,
1462cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":textfield") ) );
1463cdf0e10cSrcweir                 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1464cdf0e10cSrcweir                 pElem->readEditModel( &all_styles );
1465cdf0e10cSrcweir             }
1466cdf0e10cSrcweir             // FixedHyperLink
1467cdf0e10cSrcweir             else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedHyperlinkModel") ) ) )
1468cdf0e10cSrcweir             {
1469cdf0e10cSrcweir                 pElem = new ElementDescriptor(
1470cdf0e10cSrcweir                     xProps, xPropState,
1471cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":linklabel") ) );
1472cdf0e10cSrcweir                 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1473cdf0e10cSrcweir                 pElem->readFixedHyperLinkModel( &all_styles );
1474cdf0e10cSrcweir             }
1475cdf0e10cSrcweir             else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlImageControlModel") ) ) )
1476cdf0e10cSrcweir             {
1477cdf0e10cSrcweir                 pElem = new ElementDescriptor(
1478cdf0e10cSrcweir                     xProps, xPropState,
1479cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":img") ) );
1480cdf0e10cSrcweir                 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1481cdf0e10cSrcweir                 pElem->readImageControlModel( &all_styles );
1482cdf0e10cSrcweir             }
1483cdf0e10cSrcweir             else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFileControlModel") ) ) )
1484cdf0e10cSrcweir             {
1485cdf0e10cSrcweir                 pElem = new ElementDescriptor(
1486cdf0e10cSrcweir                     xProps, xPropState,
1487cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":filecontrol") ) );
1488cdf0e10cSrcweir                 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1489cdf0e10cSrcweir                 pElem->readFileControlModel( &all_styles );
1490cdf0e10cSrcweir             }
1491cdf0e10cSrcweir             else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.tree.TreeControlModel") ) ) )
1492cdf0e10cSrcweir             {
1493cdf0e10cSrcweir                 pElem = new ElementDescriptor(
1494cdf0e10cSrcweir                     xProps, xPropState,
1495cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":treecontrol") ) );
1496cdf0e10cSrcweir                 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1497cdf0e10cSrcweir                 pElem->readTreeControlModel( &all_styles );
1498cdf0e10cSrcweir             }
1499cdf0e10cSrcweir             else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlCurrencyFieldModel") ) ) )
1500cdf0e10cSrcweir             {
1501cdf0e10cSrcweir                 pElem = new ElementDescriptor(
1502cdf0e10cSrcweir                     xProps, xPropState,
1503cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":currencyfield") ) );
1504cdf0e10cSrcweir                 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1505cdf0e10cSrcweir                 pElem->readCurrencyFieldModel( &all_styles );
1506cdf0e10cSrcweir             }
1507cdf0e10cSrcweir             else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlDateFieldModel") ) ) )
1508cdf0e10cSrcweir             {
1509cdf0e10cSrcweir                 pElem = new ElementDescriptor(
1510cdf0e10cSrcweir                     xProps, xPropState,
1511cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":datefield") ) );
1512cdf0e10cSrcweir                 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1513cdf0e10cSrcweir                 pElem->readDateFieldModel( &all_styles );
1514cdf0e10cSrcweir             }
1515cdf0e10cSrcweir             else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlNumericFieldModel") ) ) )
1516cdf0e10cSrcweir             {
1517cdf0e10cSrcweir                 pElem = new ElementDescriptor(
1518cdf0e10cSrcweir                     xProps, xPropState,
1519cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":numericfield") ) );
1520cdf0e10cSrcweir                 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1521cdf0e10cSrcweir                 pElem->readNumericFieldModel( &all_styles );
1522cdf0e10cSrcweir             }
1523cdf0e10cSrcweir             else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlTimeFieldModel") ) ) )
1524cdf0e10cSrcweir             {
1525cdf0e10cSrcweir                 pElem = new ElementDescriptor(
1526cdf0e10cSrcweir                     xProps, xPropState,
1527cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":timefield") ) );
1528cdf0e10cSrcweir                 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1529cdf0e10cSrcweir                 pElem->readTimeFieldModel( &all_styles );
1530cdf0e10cSrcweir             }
1531cdf0e10cSrcweir             else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlPatternFieldModel") ) ) )
1532cdf0e10cSrcweir             {
1533cdf0e10cSrcweir                 pElem = new ElementDescriptor(
1534cdf0e10cSrcweir                     xProps, xPropState,
1535cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":patternfield") ) );
1536cdf0e10cSrcweir                 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1537cdf0e10cSrcweir                 pElem->readPatternFieldModel( &all_styles );
1538cdf0e10cSrcweir             }
1539cdf0e10cSrcweir             else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFormattedFieldModel") ) ) )
1540cdf0e10cSrcweir             {
1541cdf0e10cSrcweir                 pElem = new ElementDescriptor(
1542cdf0e10cSrcweir                     xProps, xPropState,
1543cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":formattedfield") ) );
1544cdf0e10cSrcweir                 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1545cdf0e10cSrcweir                 pElem->readFormattedFieldModel( &all_styles );
1546cdf0e10cSrcweir             }
1547cdf0e10cSrcweir             else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedLineModel") ) ) )
1548cdf0e10cSrcweir             {
1549cdf0e10cSrcweir                 pElem = new ElementDescriptor(
1550cdf0e10cSrcweir                     xProps, xPropState,
1551cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":fixedline") ) );
1552cdf0e10cSrcweir                 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1553cdf0e10cSrcweir                 pElem->readFixedLineModel( &all_styles );
1554cdf0e10cSrcweir             }
1555cdf0e10cSrcweir             else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlScrollBarModel") ) ) )
1556cdf0e10cSrcweir             {
1557cdf0e10cSrcweir                 pElem = new ElementDescriptor(
1558cdf0e10cSrcweir                     xProps, xPropState,
1559cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":scrollbar") ) );
1560cdf0e10cSrcweir                 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1561cdf0e10cSrcweir                 pElem->readScrollBarModel( &all_styles );
1562cdf0e10cSrcweir             }
1563cdf0e10cSrcweir             else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlProgressBarModel") ) ) )
1564cdf0e10cSrcweir             {
1565cdf0e10cSrcweir                 pElem = new ElementDescriptor(
1566cdf0e10cSrcweir                     xProps, xPropState,
1567cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":progressmeter") ) );
1568cdf0e10cSrcweir                 xElem = static_cast< xml::sax::XAttributeList * >( pElem );
1569cdf0e10cSrcweir                 pElem->readProgressBarModel( &all_styles );
1570cdf0e10cSrcweir             }
1571cdf0e10cSrcweir             //
1572cdf0e10cSrcweir 
1573cdf0e10cSrcweir             OSL_ASSERT( xElem.is() );
1574cdf0e10cSrcweir             if (xElem.is())
1575cdf0e10cSrcweir             {
1576cdf0e10cSrcweir                 all_elements.push_back( xElem );
1577cdf0e10cSrcweir             }
1578cdf0e10cSrcweir             else
1579cdf0e10cSrcweir             {
1580cdf0e10cSrcweir                 OSL_ENSURE( sal_False, "unknown control type!" );
1581cdf0e10cSrcweir                 continue;
1582cdf0e10cSrcweir             }
1583cdf0e10cSrcweir         }
1584cdf0e10cSrcweir     }
1585cdf0e10cSrcweir 
1586cdf0e10cSrcweir     xOut->startDocument();
1587cdf0e10cSrcweir 
1588cdf0e10cSrcweir     OUString aDocTypeStr( RTL_CONSTASCII_USTRINGPARAM(
1589cdf0e10cSrcweir         "<!DOCTYPE dlg:window PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\""
1590cdf0e10cSrcweir         " \"dialog.dtd\">" ) );
1591cdf0e10cSrcweir     xOut->unknown( aDocTypeStr );
1592cdf0e10cSrcweir     xOut->ignorableWhitespace( OUString() );
1593cdf0e10cSrcweir 
1594cdf0e10cSrcweir     // window
1595cdf0e10cSrcweir     Reference< beans::XPropertySet > xProps( xDialogModel, UNO_QUERY );
1596cdf0e10cSrcweir     OSL_ASSERT( xProps.is() );
1597cdf0e10cSrcweir     Reference< beans::XPropertyState > xPropState( xProps, UNO_QUERY );
1598cdf0e10cSrcweir     OSL_ASSERT( xPropState.is() );
1599cdf0e10cSrcweir 
1600cdf0e10cSrcweir     OUString aWindowName( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":window") );
1601cdf0e10cSrcweir     ElementDescriptor * pWindow = new ElementDescriptor( xProps, xPropState, aWindowName );
1602cdf0e10cSrcweir     Reference< xml::sax::XAttributeList > xWindow( pWindow );
1603cdf0e10cSrcweir     pWindow->readDialogModel( &all_styles );
1604cdf0e10cSrcweir     xOut->ignorableWhitespace( OUString() );
1605cdf0e10cSrcweir     xOut->startElement( aWindowName, xWindow );
1606cdf0e10cSrcweir      // dump out events
1607cdf0e10cSrcweir     pWindow->dumpSubElements( xOut.get() );
1608cdf0e10cSrcweir     // dump out stylebag
1609cdf0e10cSrcweir     all_styles.dump( xOut );
1610cdf0e10cSrcweir 
1611cdf0e10cSrcweir     if (! all_elements.empty())
1612cdf0e10cSrcweir     {
1613cdf0e10cSrcweir         // open up bulletinboard
1614cdf0e10cSrcweir         OUString aBBoardName( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":bulletinboard") );
1615cdf0e10cSrcweir         xOut->ignorableWhitespace( OUString() );
1616cdf0e10cSrcweir         xOut->startElement( aBBoardName, Reference< xml::sax::XAttributeList >() );
1617cdf0e10cSrcweir 
1618cdf0e10cSrcweir         // export control elements
1619cdf0e10cSrcweir         for ( std::size_t n = 0; n < all_elements.size(); ++n )
1620cdf0e10cSrcweir         {
1621cdf0e10cSrcweir             ElementDescriptor * pElem = static_cast< ElementDescriptor * >( all_elements[ n ].get() );
1622cdf0e10cSrcweir             pElem->dump( xOut.get() );
1623cdf0e10cSrcweir         }
1624cdf0e10cSrcweir 
1625cdf0e10cSrcweir         // end bulletinboard
1626cdf0e10cSrcweir         xOut->ignorableWhitespace( OUString() );
1627cdf0e10cSrcweir         xOut->endElement( aBBoardName );
1628cdf0e10cSrcweir     }
1629cdf0e10cSrcweir 
1630cdf0e10cSrcweir     // end window
1631cdf0e10cSrcweir     xOut->ignorableWhitespace( OUString() );
1632cdf0e10cSrcweir     xOut->endElement( aWindowName );
1633cdf0e10cSrcweir 
1634cdf0e10cSrcweir     xOut->endDocument();
1635cdf0e10cSrcweir }
1636cdf0e10cSrcweir 
1637cdf0e10cSrcweir }
1638