xref: /trunk/main/oox/source/export/drawingml.cxx (revision ca5ec2004b000a7d9aaa8381be8ac2853e3b1dc7)
1*ca5ec200SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*ca5ec200SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*ca5ec200SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*ca5ec200SAndrew Rist  * distributed with this work for additional information
6*ca5ec200SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*ca5ec200SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*ca5ec200SAndrew Rist  * "License"); you may not use this file except in compliance
9*ca5ec200SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*ca5ec200SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*ca5ec200SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*ca5ec200SAndrew Rist  * software distributed under the License is distributed on an
15*ca5ec200SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ca5ec200SAndrew Rist  * KIND, either express or implied.  See the License for the
17*ca5ec200SAndrew Rist  * specific language governing permissions and limitations
18*ca5ec200SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*ca5ec200SAndrew Rist  *************************************************************/
21*ca5ec200SAndrew Rist 
22*ca5ec200SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #include "oox/core/xmlfilterbase.hxx"
25cdf0e10cSrcweir #include "oox/export/drawingml.hxx"
26cdf0e10cSrcweir #include "oox/export/utils.hxx"
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <cstdio>
29cdf0e10cSrcweir #include <com/sun/star/awt/CharSet.hpp>
30cdf0e10cSrcweir #include <com/sun/star/awt/FontDescriptor.hpp>
31cdf0e10cSrcweir #include <com/sun/star/awt/FontSlant.hpp>
32cdf0e10cSrcweir #include <com/sun/star/awt/FontWeight.hpp>
33cdf0e10cSrcweir #include <com/sun/star/awt/FontUnderline.hpp>
34cdf0e10cSrcweir #include <com/sun/star/awt/Gradient.hpp>
35cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
36cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyState.hpp>
37cdf0e10cSrcweir #include <com/sun/star/container/XEnumerationAccess.hpp>
38cdf0e10cSrcweir #include <com/sun/star/drawing/BitmapMode.hpp>
39cdf0e10cSrcweir #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
40cdf0e10cSrcweir #include <com/sun/star/drawing/LineDash.hpp>
41cdf0e10cSrcweir #include <com/sun/star/drawing/LineJoint.hpp>
42cdf0e10cSrcweir #include <com/sun/star/drawing/LineStyle.hpp>
43cdf0e10cSrcweir #include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
44cdf0e10cSrcweir #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
45cdf0e10cSrcweir #include <com/sun/star/i18n/ScriptType.hpp>
46cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp>
47cdf0e10cSrcweir #include <com/sun/star/style/ParagraphAdjust.hpp>
48cdf0e10cSrcweir #include <com/sun/star/text/XText.hpp>
49cdf0e10cSrcweir #include <com/sun/star/text/XTextContent.hpp>
50cdf0e10cSrcweir #include <com/sun/star/text/XTextField.hpp>
51cdf0e10cSrcweir #include <com/sun/star/text/XTextRange.hpp>
52cdf0e10cSrcweir #include <tools/stream.hxx>
53cdf0e10cSrcweir #include <tools/string.hxx>
54cdf0e10cSrcweir #include <vcl/cvtgrf.hxx>
55cdf0e10cSrcweir #include <unotools/fontcvt.hxx>
56cdf0e10cSrcweir #include <vcl/graph.hxx>
57cdf0e10cSrcweir #include <svtools/grfmgr.hxx>
58cdf0e10cSrcweir #include <rtl/strbuf.hxx>
59cdf0e10cSrcweir #include <sfx2/app.hxx>
60cdf0e10cSrcweir #include <svl/languageoptions.hxx>
61cdf0e10cSrcweir #include <svx/escherex.hxx>
62cdf0e10cSrcweir #include <svx/svxenum.hxx>
63cdf0e10cSrcweir 
64cdf0e10cSrcweir using namespace ::com::sun::star;
65cdf0e10cSrcweir using namespace ::com::sun::star::uno;
66cdf0e10cSrcweir using namespace ::com::sun::star::drawing;
67cdf0e10cSrcweir using namespace ::com::sun::star::i18n;
68cdf0e10cSrcweir using ::com::sun::star::beans::PropertyState;
69cdf0e10cSrcweir using ::com::sun::star::beans::PropertyValue;
70cdf0e10cSrcweir using ::com::sun::star::beans::XPropertySet;
71cdf0e10cSrcweir using ::com::sun::star::beans::XPropertyState;
72cdf0e10cSrcweir using ::com::sun::star::container::XEnumeration;
73cdf0e10cSrcweir using ::com::sun::star::container::XEnumerationAccess;
74cdf0e10cSrcweir using ::com::sun::star::container::XIndexAccess;
75cdf0e10cSrcweir using ::com::sun::star::io::XOutputStream;
76cdf0e10cSrcweir using ::com::sun::star::text::XText;
77cdf0e10cSrcweir using ::com::sun::star::text::XTextContent;
78cdf0e10cSrcweir using ::com::sun::star::text::XTextField;
79cdf0e10cSrcweir using ::com::sun::star::text::XTextRange;
80cdf0e10cSrcweir using ::rtl::OString;
81cdf0e10cSrcweir using ::rtl::OStringBuffer;
82cdf0e10cSrcweir using ::rtl::OUString;
83cdf0e10cSrcweir using ::rtl::OUStringBuffer;
84cdf0e10cSrcweir using ::sax_fastparser::FSHelperPtr;
85cdf0e10cSrcweir 
86cdf0e10cSrcweir DBG(extern void dump_pset(Reference< XPropertySet > rXPropSet));
87cdf0e10cSrcweir 
88cdf0e10cSrcweir namespace oox {
89cdf0e10cSrcweir namespace drawingml {
90cdf0e10cSrcweir 
91cdf0e10cSrcweir #define GETA(propName) \
92cdf0e10cSrcweir     GetProperty( rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( #propName ) ) )
93cdf0e10cSrcweir 
94cdf0e10cSrcweir #define GETAD(propName) \
95cdf0e10cSrcweir     ( GetPropertyAndState( rXPropSet, rXPropState, String( RTL_CONSTASCII_USTRINGPARAM( #propName ) ), eState ) && eState == beans::PropertyState_DIRECT_VALUE )
96cdf0e10cSrcweir 
97cdf0e10cSrcweir #define GET(variable, propName) \
98cdf0e10cSrcweir     if ( GETA(propName) ) \
99cdf0e10cSrcweir         mAny >>= variable;
100cdf0e10cSrcweir 
101cdf0e10cSrcweir // not thread safe
102cdf0e10cSrcweir int DrawingML::mnImageCounter = 1;
103cdf0e10cSrcweir 
104cdf0e10cSrcweir void DrawingML::ResetCounters()
105cdf0e10cSrcweir {
106cdf0e10cSrcweir     mnImageCounter = 1;
107cdf0e10cSrcweir }
108cdf0e10cSrcweir 
109cdf0e10cSrcweir bool DrawingML::GetProperty( Reference< XPropertySet > rXPropSet, String aName )
110cdf0e10cSrcweir {
111cdf0e10cSrcweir     bool bRetValue = false;
112cdf0e10cSrcweir 
113cdf0e10cSrcweir     try {
114cdf0e10cSrcweir         mAny = rXPropSet->getPropertyValue( aName );
115cdf0e10cSrcweir         if ( mAny.hasValue() )
116cdf0e10cSrcweir             bRetValue = true;
117cdf0e10cSrcweir     } catch( Exception& ) { /* printf ("exception when trying to get value of property: %s\n", ST(aName)); */ }
118cdf0e10cSrcweir 
119cdf0e10cSrcweir     return bRetValue;
120cdf0e10cSrcweir }
121cdf0e10cSrcweir 
122cdf0e10cSrcweir bool DrawingML::GetPropertyAndState( Reference< XPropertySet > rXPropSet, Reference< XPropertyState > rXPropState, String aName, PropertyState& eState )
123cdf0e10cSrcweir {
124cdf0e10cSrcweir     bool bRetValue = false;
125cdf0e10cSrcweir 
126cdf0e10cSrcweir     try {
127cdf0e10cSrcweir         mAny = rXPropSet->getPropertyValue( aName );
128cdf0e10cSrcweir         if ( mAny.hasValue() ) {
129cdf0e10cSrcweir             bRetValue = true;
130cdf0e10cSrcweir             eState = rXPropState->getPropertyState( aName );
131cdf0e10cSrcweir         }
132cdf0e10cSrcweir     } catch( Exception& ) { /* printf ("exception when trying to get value of property: %s\n", ST(aName)); */ }
133cdf0e10cSrcweir 
134cdf0e10cSrcweir     return bRetValue;
135cdf0e10cSrcweir }
136cdf0e10cSrcweir 
137cdf0e10cSrcweir void DrawingML::WriteColor( sal_uInt32 nColor )
138cdf0e10cSrcweir {
139cdf0e10cSrcweir     OString sColor = OString::valueOf( ( sal_Int64 ) nColor, 16 );
140cdf0e10cSrcweir     if( sColor.getLength() < 6 ) {
141cdf0e10cSrcweir         OStringBuffer sBuf( "0" );
142cdf0e10cSrcweir         int remains = 5 - sColor.getLength();
143cdf0e10cSrcweir 
144cdf0e10cSrcweir         while( remains > 0 ) {
145cdf0e10cSrcweir             sBuf.append( "0" );
146cdf0e10cSrcweir             remains--;
147cdf0e10cSrcweir         }
148cdf0e10cSrcweir 
149cdf0e10cSrcweir         sBuf.append( sColor );
150cdf0e10cSrcweir 
151cdf0e10cSrcweir         sColor = sBuf.getStr();
152cdf0e10cSrcweir     }
153cdf0e10cSrcweir     mpFS->singleElementNS( XML_a, XML_srgbClr, XML_val, sColor.getStr(), FSEND );
154cdf0e10cSrcweir }
155cdf0e10cSrcweir 
156cdf0e10cSrcweir void DrawingML::WriteSolidFill( sal_uInt32 nColor )
157cdf0e10cSrcweir {
158cdf0e10cSrcweir     mpFS->startElementNS( XML_a, XML_solidFill, FSEND );
159cdf0e10cSrcweir     WriteColor( nColor );
160cdf0e10cSrcweir     mpFS->endElementNS( XML_a, XML_solidFill );
161cdf0e10cSrcweir }
162cdf0e10cSrcweir 
163cdf0e10cSrcweir void DrawingML::WriteSolidFill( Reference< XPropertySet > rXPropSet )
164cdf0e10cSrcweir {
165cdf0e10cSrcweir     if ( GetProperty( rXPropSet, S( "FillColor" ) ) )
166cdf0e10cSrcweir         WriteSolidFill( *((sal_uInt32*) mAny.getValue()) & 0xffffff );
167cdf0e10cSrcweir }
168cdf0e10cSrcweir 
169cdf0e10cSrcweir void DrawingML::WriteGradientStop( sal_uInt16 nStop, sal_uInt32 nColor )
170cdf0e10cSrcweir {
171cdf0e10cSrcweir     mpFS->startElementNS( XML_a, XML_gs,
172cdf0e10cSrcweir                           XML_pos, I32S( nStop * 1000 ),
173cdf0e10cSrcweir                           FSEND );
174cdf0e10cSrcweir     WriteColor( nColor );
175cdf0e10cSrcweir     mpFS->endElementNS( XML_a, XML_gs );
176cdf0e10cSrcweir }
177cdf0e10cSrcweir 
178cdf0e10cSrcweir sal_uInt32 DrawingML::ColorWithIntensity( sal_uInt32 nColor, sal_uInt32 nIntensity )
179cdf0e10cSrcweir {
180cdf0e10cSrcweir     return ( ( ( nColor & 0xff ) * nIntensity ) / 100 )
181cdf0e10cSrcweir         | ( ( ( ( ( nColor & 0xff00 ) >> 8 ) * nIntensity ) / 100 ) << 8 )
182cdf0e10cSrcweir         | ( ( ( ( ( nColor & 0xff0000 ) >> 8 ) * nIntensity ) / 100 ) << 8 );
183cdf0e10cSrcweir }
184cdf0e10cSrcweir 
185cdf0e10cSrcweir void DrawingML::WriteGradientFill( Reference< XPropertySet > rXPropSet )
186cdf0e10cSrcweir {
187cdf0e10cSrcweir     awt::Gradient aGradient;
188cdf0e10cSrcweir     if( GETA( FillGradient ) ) {
189cdf0e10cSrcweir         aGradient = *static_cast< const awt::Gradient* >( mAny.getValue() );
190cdf0e10cSrcweir 
191cdf0e10cSrcweir         mpFS->startElementNS( XML_a, XML_gradFill, FSEND );
192cdf0e10cSrcweir 
193cdf0e10cSrcweir         switch( aGradient.Style ) {
194cdf0e10cSrcweir             default:
195cdf0e10cSrcweir             case GradientStyle_LINEAR:
196cdf0e10cSrcweir                 mpFS->startElementNS( XML_a, XML_gsLst, FSEND );
197cdf0e10cSrcweir                 WriteGradientStop( 0, ColorWithIntensity( aGradient.StartColor, aGradient.StartIntensity ) );
198cdf0e10cSrcweir                 WriteGradientStop( 100, ColorWithIntensity( aGradient.EndColor, aGradient.EndIntensity ) );
199cdf0e10cSrcweir                 mpFS->endElementNS( XML_a, XML_gsLst );
200cdf0e10cSrcweir                 mpFS->singleElementNS( XML_a, XML_lin,
201cdf0e10cSrcweir                                        XML_ang, I32S( ( ( ( 3600 - aGradient.Angle + 900 ) * 6000 ) % 21600000 ) ),
202cdf0e10cSrcweir                                        FSEND );
203cdf0e10cSrcweir                 break;
204cdf0e10cSrcweir 
205cdf0e10cSrcweir             case GradientStyle_AXIAL:
206cdf0e10cSrcweir                 mpFS->startElementNS( XML_a, XML_gsLst, FSEND );
207cdf0e10cSrcweir                 WriteGradientStop( 0, ColorWithIntensity( aGradient.EndColor, aGradient.EndIntensity ) );
208cdf0e10cSrcweir                 WriteGradientStop( 50, ColorWithIntensity( aGradient.StartColor, aGradient.StartIntensity ) );
209cdf0e10cSrcweir                 WriteGradientStop( 100, ColorWithIntensity( aGradient.EndColor, aGradient.EndIntensity ) );
210cdf0e10cSrcweir                 mpFS->endElementNS( XML_a, XML_gsLst );
211cdf0e10cSrcweir                 mpFS->singleElementNS( XML_a, XML_lin,
212cdf0e10cSrcweir                                        XML_ang, I32S( ( ( ( 3600 - aGradient.Angle + 900 ) * 6000 ) % 21600000 ) ),
213cdf0e10cSrcweir                                        FSEND );
214cdf0e10cSrcweir                 break;
215cdf0e10cSrcweir 
216cdf0e10cSrcweir                 /* I don't see how to apply transformation to gradients, so
217cdf0e10cSrcweir                  * elliptical will end as radial and square as
218cdf0e10cSrcweir                  * rectangular. also position offsets are not applied */
219cdf0e10cSrcweir             case GradientStyle_RADIAL:
220cdf0e10cSrcweir             case GradientStyle_ELLIPTICAL:
221cdf0e10cSrcweir             case GradientStyle_RECT:
222cdf0e10cSrcweir             case GradientStyle_SQUARE:
223cdf0e10cSrcweir                 mpFS->startElementNS( XML_a, XML_gsLst, FSEND );
224cdf0e10cSrcweir                 WriteGradientStop( 0, ColorWithIntensity( aGradient.EndColor, aGradient.EndIntensity ) );
225cdf0e10cSrcweir                 WriteGradientStop( 100, ColorWithIntensity( aGradient.StartColor, aGradient.StartIntensity ) );
226cdf0e10cSrcweir                 mpFS->endElementNS( XML_a, XML_gsLst );
227cdf0e10cSrcweir                 mpFS->singleElementNS( XML_a, XML_path,
228cdf0e10cSrcweir                                        XML_path, ( aGradient.Style == awt::GradientStyle_RADIAL || aGradient.Style == awt::GradientStyle_ELLIPTICAL ) ? "circle" : "rect",
229cdf0e10cSrcweir                                        FSEND );
230cdf0e10cSrcweir                 break;
231cdf0e10cSrcweir         }
232cdf0e10cSrcweir 
233cdf0e10cSrcweir         mpFS->endElementNS( XML_a, XML_gradFill );
234cdf0e10cSrcweir     }
235cdf0e10cSrcweir 
236cdf0e10cSrcweir }
237cdf0e10cSrcweir 
238cdf0e10cSrcweir void DrawingML::WriteLineArrow( Reference< XPropertySet > rXPropSet, sal_Bool bLineStart )
239cdf0e10cSrcweir {
240cdf0e10cSrcweir     ESCHER_LineEnd eLineEnd;
241cdf0e10cSrcweir     sal_Int32 nArrowLength;
242cdf0e10cSrcweir     sal_Int32 nArrowWidth;
243cdf0e10cSrcweir 
244cdf0e10cSrcweir     if ( EscherPropertyContainer::GetLineArrow( bLineStart, rXPropSet, eLineEnd, nArrowLength, nArrowWidth ) ) {
245cdf0e10cSrcweir         const char* len;
246cdf0e10cSrcweir         const char* type;
247cdf0e10cSrcweir         const char* width;
248cdf0e10cSrcweir 
249cdf0e10cSrcweir         switch( nArrowLength ) {
250cdf0e10cSrcweir             case ESCHER_LineShortArrow:
251cdf0e10cSrcweir                 len = "sm";
252cdf0e10cSrcweir                 break;
253cdf0e10cSrcweir             default:
254cdf0e10cSrcweir             case ESCHER_LineMediumLenArrow:
255cdf0e10cSrcweir                 len = "med";
256cdf0e10cSrcweir                 break;
257cdf0e10cSrcweir             case ESCHER_LineLongArrow:
258cdf0e10cSrcweir                 len = "lg";
259cdf0e10cSrcweir                 break;
260cdf0e10cSrcweir         }
261cdf0e10cSrcweir 
262cdf0e10cSrcweir         switch( eLineEnd ) {
263cdf0e10cSrcweir             default:
264cdf0e10cSrcweir             case ESCHER_LineNoEnd:
265cdf0e10cSrcweir                 type = "none";
266cdf0e10cSrcweir                 break;
267cdf0e10cSrcweir             case ESCHER_LineArrowEnd:
268cdf0e10cSrcweir                 type = "triangle";
269cdf0e10cSrcweir                 break;
270cdf0e10cSrcweir             case ESCHER_LineArrowStealthEnd:
271cdf0e10cSrcweir                 type = "stealth";
272cdf0e10cSrcweir                 break;
273cdf0e10cSrcweir             case ESCHER_LineArrowDiamondEnd:
274cdf0e10cSrcweir                 type = "diamond";
275cdf0e10cSrcweir                 break;
276cdf0e10cSrcweir             case ESCHER_LineArrowOvalEnd:
277cdf0e10cSrcweir                 type = "oval";
278cdf0e10cSrcweir                 break;
279cdf0e10cSrcweir             case ESCHER_LineArrowOpenEnd:
280cdf0e10cSrcweir                 type = "arrow";
281cdf0e10cSrcweir                 break;
282cdf0e10cSrcweir         }
283cdf0e10cSrcweir 
284cdf0e10cSrcweir         switch( nArrowWidth ) {
285cdf0e10cSrcweir             case ESCHER_LineNarrowArrow:
286cdf0e10cSrcweir                 width = "sm";
287cdf0e10cSrcweir                 break;
288cdf0e10cSrcweir             default:
289cdf0e10cSrcweir             case ESCHER_LineMediumWidthArrow:
290cdf0e10cSrcweir                 width = "med";
291cdf0e10cSrcweir                 break;
292cdf0e10cSrcweir             case ESCHER_LineWideArrow:
293cdf0e10cSrcweir                 width = "lg";
294cdf0e10cSrcweir                 break;
295cdf0e10cSrcweir         }
296cdf0e10cSrcweir 
297cdf0e10cSrcweir         mpFS->singleElementNS( XML_a, bLineStart ? XML_headEnd : XML_tailEnd,
298cdf0e10cSrcweir                                XML_len, len,
299cdf0e10cSrcweir                                XML_type, type,
300cdf0e10cSrcweir                                XML_w, width,
301cdf0e10cSrcweir                                FSEND );
302cdf0e10cSrcweir     }
303cdf0e10cSrcweir }
304cdf0e10cSrcweir 
305cdf0e10cSrcweir void DrawingML::WriteOutline( Reference< XPropertySet > rXPropSet )
306cdf0e10cSrcweir {
307cdf0e10cSrcweir     drawing::LineStyle aLineStyle( drawing::LineStyle_NONE );
308cdf0e10cSrcweir 
309cdf0e10cSrcweir     GET( aLineStyle, LineStyle );
310cdf0e10cSrcweir 
311cdf0e10cSrcweir     if( aLineStyle == drawing::LineStyle_NONE )
312cdf0e10cSrcweir         return;
313cdf0e10cSrcweir 
314cdf0e10cSrcweir     sal_uInt32 nLineWidth = 0;
315cdf0e10cSrcweir     sal_uInt32 nColor = 0;
316cdf0e10cSrcweir     sal_Bool bColorSet = FALSE;
317cdf0e10cSrcweir     const char* cap = NULL;
318cdf0e10cSrcweir     drawing::LineDash aLineDash;
319cdf0e10cSrcweir     sal_Bool bDashSet = FALSE;
320cdf0e10cSrcweir 
321cdf0e10cSrcweir     GET( nLineWidth, LineWidth );
322cdf0e10cSrcweir 
323cdf0e10cSrcweir     switch( aLineStyle ) {
324cdf0e10cSrcweir         case drawing::LineStyle_DASH:
325cdf0e10cSrcweir             if( GETA( LineDash ) ) {
326cdf0e10cSrcweir                 aLineDash = *(drawing::LineDash*) mAny.getValue();
327cdf0e10cSrcweir                 bDashSet = TRUE;
328cdf0e10cSrcweir                 if( aLineDash.Style == DashStyle_ROUND || aLineDash.Style == DashStyle_ROUNDRELATIVE )
329cdf0e10cSrcweir                     cap = "rnd";
330cdf0e10cSrcweir 
331cdf0e10cSrcweir                 DBG(printf("dash dots: %d dashes: %d dotlen: %d dashlen: %d distance: %d\n",
332cdf0e10cSrcweir                             int( aLineDash.Dots ), int( aLineDash.Dashes ), int( aLineDash.DotLen ), int( aLineDash.DashLen ), int( aLineDash.Distance )));
333cdf0e10cSrcweir             }
334cdf0e10cSrcweir             /* fallthru intended */
335cdf0e10cSrcweir         case drawing::LineStyle_SOLID:
336cdf0e10cSrcweir         default:
337cdf0e10cSrcweir             if ( GETA( LineColor ) ) {
338cdf0e10cSrcweir                 nColor = *((sal_uInt32*) mAny.getValue()) & 0xffffff;
339cdf0e10cSrcweir                 bColorSet = TRUE;
340cdf0e10cSrcweir             }
341cdf0e10cSrcweir             break;
342cdf0e10cSrcweir     }
343cdf0e10cSrcweir 
344cdf0e10cSrcweir     mpFS->startElementNS( XML_a, XML_ln,
345cdf0e10cSrcweir                           XML_cap, cap,
346cdf0e10cSrcweir                           XML_w, nLineWidth > 1 ? I64S( MM100toEMU( nLineWidth ) ) : NULL,
347cdf0e10cSrcweir                           FSEND );
348cdf0e10cSrcweir     if( bColorSet )
349cdf0e10cSrcweir         WriteSolidFill( nColor );
350cdf0e10cSrcweir 
351cdf0e10cSrcweir     if( bDashSet ) {
352cdf0e10cSrcweir         mpFS->startElementNS( XML_a, XML_custDash, FSEND );
353cdf0e10cSrcweir         int i;
354cdf0e10cSrcweir         for( i = 0; i < aLineDash.Dots; i ++ )
355cdf0e10cSrcweir             mpFS->singleElementNS( XML_a, XML_ds,
356cdf0e10cSrcweir                                    XML_d, aLineDash.DotLen ? I64S( aLineDash.DotLen*1000 ) : "100000",
357cdf0e10cSrcweir                                    XML_sp, I64S( aLineDash.Distance*1000 ),
358cdf0e10cSrcweir                                    FSEND );
359cdf0e10cSrcweir         for( i = 0; i < aLineDash.Dashes; i ++ )
360cdf0e10cSrcweir             mpFS->singleElementNS( XML_a, XML_ds,
361cdf0e10cSrcweir                                    XML_d, aLineDash.DashLen ? I64S( aLineDash.DashLen*1000 ) : "100000",
362cdf0e10cSrcweir                                    XML_sp, I64S( aLineDash.Distance*1000 ),
363cdf0e10cSrcweir                                    FSEND );
364cdf0e10cSrcweir         mpFS->endElementNS( XML_a, XML_custDash );
365cdf0e10cSrcweir     }
366cdf0e10cSrcweir 
367cdf0e10cSrcweir     if( nLineWidth > 1 && GETA( LineJoint ) ) {
368cdf0e10cSrcweir         LineJoint eLineJoint;
369cdf0e10cSrcweir 
370cdf0e10cSrcweir         mAny >>= eLineJoint;
371cdf0e10cSrcweir         switch( eLineJoint ) {
372cdf0e10cSrcweir             case LineJoint_NONE:
373cdf0e10cSrcweir             case LineJoint_MIDDLE:
374cdf0e10cSrcweir             case LineJoint_BEVEL:
375cdf0e10cSrcweir                 mpFS->singleElementNS( XML_a, XML_bevel, FSEND );
376cdf0e10cSrcweir                 break;
377cdf0e10cSrcweir             default:
378cdf0e10cSrcweir             case LineJoint_MITER:
379cdf0e10cSrcweir                 mpFS->singleElementNS( XML_a, XML_miter, FSEND );
380cdf0e10cSrcweir                 break;
381cdf0e10cSrcweir             case LineJoint_ROUND:
382cdf0e10cSrcweir                 mpFS->singleElementNS( XML_a, XML_round, FSEND );
383cdf0e10cSrcweir                 break;
384cdf0e10cSrcweir         }
385cdf0e10cSrcweir     }
386cdf0e10cSrcweir 
387cdf0e10cSrcweir     WriteLineArrow( rXPropSet, sal_True );
388cdf0e10cSrcweir     WriteLineArrow( rXPropSet, sal_False );
389cdf0e10cSrcweir 
390cdf0e10cSrcweir     mpFS->endElementNS( XML_a, XML_ln );
391cdf0e10cSrcweir }
392cdf0e10cSrcweir 
393cdf0e10cSrcweir OUString DrawingML::WriteImage( const OUString& rURL )
394cdf0e10cSrcweir {
395cdf0e10cSrcweir     ByteString aURLBS( UniString( rURL ), RTL_TEXTENCODING_UTF8 );
396cdf0e10cSrcweir 
397cdf0e10cSrcweir     const char aURLBegin[] = "vnd.sun.star.GraphicObject:";
398cdf0e10cSrcweir     int index = aURLBS.Search( aURLBegin );
399cdf0e10cSrcweir 
400cdf0e10cSrcweir     if ( index != STRING_NOTFOUND ) {
401cdf0e10cSrcweir         DBG(printf ("begin: %ld %s\n", long( sizeof( aURLBegin ) ), USS( rURL ) + sizeof( aURLBegin ) - 1 ));
402cdf0e10cSrcweir         aURLBS.Erase( 0, sizeof( aURLBegin ) - 1 );
403cdf0e10cSrcweir         Graphic aGraphic = GraphicObject( aURLBS ).GetTransformedGraphic ();
404cdf0e10cSrcweir 
405cdf0e10cSrcweir         return WriteImage( aGraphic );
406cdf0e10cSrcweir     } else {
407cdf0e10cSrcweir         // add link to relations
408cdf0e10cSrcweir     }
409cdf0e10cSrcweir 
410cdf0e10cSrcweir     return OUString();
411cdf0e10cSrcweir }
412cdf0e10cSrcweir 
413cdf0e10cSrcweir OUString DrawingML::WriteImage( const Graphic& rGraphic )
414cdf0e10cSrcweir {
415cdf0e10cSrcweir     GfxLink aLink = rGraphic.GetLink ();
416cdf0e10cSrcweir     OUString sMediaType;
417cdf0e10cSrcweir     const char* sExtension = NULL;
418cdf0e10cSrcweir     OUString sRelId;
419cdf0e10cSrcweir 
420cdf0e10cSrcweir     SvMemoryStream aStream;
421cdf0e10cSrcweir     const void* aData = aLink.GetData();
422cdf0e10cSrcweir     sal_Size nDataSize = aLink.GetDataSize();
423cdf0e10cSrcweir 
424cdf0e10cSrcweir     switch ( aLink.GetType() ) {
425cdf0e10cSrcweir         case GFX_LINK_TYPE_NATIVE_GIF:
426cdf0e10cSrcweir             sMediaType = US( "image/gif" );
427cdf0e10cSrcweir             sExtension = ".gif";
428cdf0e10cSrcweir             break;
429cdf0e10cSrcweir         case GFX_LINK_TYPE_NATIVE_JPG:
430cdf0e10cSrcweir             sMediaType = US( "image/jpeg" );
431cdf0e10cSrcweir             sExtension = ".jpeg";
432cdf0e10cSrcweir             break;
433cdf0e10cSrcweir         case GFX_LINK_TYPE_NATIVE_PNG:
434cdf0e10cSrcweir             sMediaType = US( "image/png" );
435cdf0e10cSrcweir             sExtension = ".png";
436cdf0e10cSrcweir             break;
437cdf0e10cSrcweir         case GFX_LINK_TYPE_NATIVE_TIF:
438cdf0e10cSrcweir             sMediaType = US( "image/tiff" );
439cdf0e10cSrcweir             sExtension = ".tiff";
440cdf0e10cSrcweir             break;
441cdf0e10cSrcweir         case GFX_LINK_TYPE_NATIVE_WMF:
442cdf0e10cSrcweir             sMediaType = US( "image/x-wmf" );
443cdf0e10cSrcweir             sExtension = ".wmf";
444cdf0e10cSrcweir             break;
445cdf0e10cSrcweir         case GFX_LINK_TYPE_NATIVE_MET:
446cdf0e10cSrcweir             sMediaType = US( "image/x-met" );
447cdf0e10cSrcweir             sExtension = ".met";
448cdf0e10cSrcweir             break;
449cdf0e10cSrcweir         case GFX_LINK_TYPE_NATIVE_PCT:
450cdf0e10cSrcweir             sMediaType = US( "image/x-pict" );
451cdf0e10cSrcweir             sExtension = ".pct";
452cdf0e10cSrcweir             break;
453cdf0e10cSrcweir         default: {
454cdf0e10cSrcweir             GraphicType aType = rGraphic.GetType();
455cdf0e10cSrcweir             if ( aType == GRAPHIC_BITMAP ) {
456cdf0e10cSrcweir                 GraphicConverter::Export( aStream, rGraphic, CVT_PNG );
457cdf0e10cSrcweir                 sMediaType = US( "image/png" );
458cdf0e10cSrcweir                 sExtension = ".png";
459cdf0e10cSrcweir             } else if ( aType == GRAPHIC_GDIMETAFILE ) {
460cdf0e10cSrcweir                 GraphicConverter::Export( aStream, rGraphic, CVT_EMF );
461cdf0e10cSrcweir                 sMediaType = US( "image/x-emf" );
462cdf0e10cSrcweir                 sExtension = ".emf";
463cdf0e10cSrcweir             } else {
464cdf0e10cSrcweir                 OSL_TRACE( "unhandled graphic type" );
465cdf0e10cSrcweir                 break;
466cdf0e10cSrcweir             }
467cdf0e10cSrcweir 
468cdf0e10cSrcweir             aData = aStream.GetData();
469cdf0e10cSrcweir             nDataSize = aStream.GetSize();
470cdf0e10cSrcweir             break;
471cdf0e10cSrcweir             }
472cdf0e10cSrcweir     }
473cdf0e10cSrcweir 
474cdf0e10cSrcweir     const char *pComponent = NULL;
475cdf0e10cSrcweir     switch ( meDocumentType )
476cdf0e10cSrcweir     {
477cdf0e10cSrcweir         case DOCUMENT_DOCX: pComponent = "word"; break;
478cdf0e10cSrcweir         case DOCUMENT_PPTX: pComponent = "ppt"; break;
479cdf0e10cSrcweir         case DOCUMENT_XLSX: pComponent = "xl"; break;
480cdf0e10cSrcweir     }
481cdf0e10cSrcweir 
482cdf0e10cSrcweir     Reference< XOutputStream > xOutStream = mpFB->openOutputStream( OUStringBuffer()
483cdf0e10cSrcweir                                                                     .appendAscii( pComponent )
484cdf0e10cSrcweir                                                                     .appendAscii( "/media/image" )
485cdf0e10cSrcweir                                                                     .append( (sal_Int32) mnImageCounter )
486cdf0e10cSrcweir                                                                     .appendAscii( sExtension )
487cdf0e10cSrcweir                                                                     .makeStringAndClear(),
488cdf0e10cSrcweir                                                                     sMediaType );
489cdf0e10cSrcweir     xOutStream->writeBytes( Sequence< sal_Int8 >( (const sal_Int8*) aData, nDataSize ) );
490cdf0e10cSrcweir     xOutStream->closeOutput();
491cdf0e10cSrcweir 
492cdf0e10cSrcweir     const char *pImagePrefix = NULL;
493cdf0e10cSrcweir     switch ( meDocumentType )
494cdf0e10cSrcweir     {
495cdf0e10cSrcweir         case DOCUMENT_DOCX:
496cdf0e10cSrcweir             pImagePrefix = "media/image";
497cdf0e10cSrcweir             break;
498cdf0e10cSrcweir         case DOCUMENT_PPTX:
499cdf0e10cSrcweir         case DOCUMENT_XLSX:
500cdf0e10cSrcweir             pImagePrefix = "../media/image";
501cdf0e10cSrcweir             break;
502cdf0e10cSrcweir     }
503cdf0e10cSrcweir 
504cdf0e10cSrcweir     sRelId = mpFB->addRelation( mpFS->getOutputStream(),
505cdf0e10cSrcweir                                 US( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" ),
506cdf0e10cSrcweir                                 OUStringBuffer()
507cdf0e10cSrcweir                                 .appendAscii( pImagePrefix )
508cdf0e10cSrcweir                                 .append( (sal_Int32) mnImageCounter ++ )
509cdf0e10cSrcweir                                 .appendAscii( sExtension )
510cdf0e10cSrcweir                                 .makeStringAndClear() );
511cdf0e10cSrcweir 
512cdf0e10cSrcweir     return sRelId;
513cdf0e10cSrcweir }
514cdf0e10cSrcweir 
515cdf0e10cSrcweir OUString DrawingML::WriteBlip( OUString& rURL )
516cdf0e10cSrcweir {
517cdf0e10cSrcweir         OUString sRelId = WriteImage( rURL );
518cdf0e10cSrcweir 
519cdf0e10cSrcweir         mpFS->singleElementNS( XML_a, XML_blip,
520cdf0e10cSrcweir                                FSNS( XML_r, XML_embed), OUStringToOString( sRelId, RTL_TEXTENCODING_UTF8 ).getStr(),
521cdf0e10cSrcweir                                FSEND );
522cdf0e10cSrcweir 
523cdf0e10cSrcweir         return sRelId;
524cdf0e10cSrcweir }
525cdf0e10cSrcweir 
526cdf0e10cSrcweir void DrawingML::WriteBlipMode( Reference< XPropertySet > rXPropSet )
527cdf0e10cSrcweir {
528cdf0e10cSrcweir     BitmapMode eBitmapMode( BitmapMode_NO_REPEAT );
529cdf0e10cSrcweir     if (GetProperty( rXPropSet, S( "FillBitmapMode" ) ) )
530cdf0e10cSrcweir         mAny >>= eBitmapMode;
531cdf0e10cSrcweir 
532cdf0e10cSrcweir     DBG(printf("fill bitmap mode: %d\n", eBitmapMode));
533cdf0e10cSrcweir 
534cdf0e10cSrcweir     switch (eBitmapMode) {
535cdf0e10cSrcweir     case BitmapMode_REPEAT:
536cdf0e10cSrcweir         mpFS->singleElementNS( XML_a, XML_tile, FSEND );
537cdf0e10cSrcweir         break;
538cdf0e10cSrcweir     default:
539cdf0e10cSrcweir         ;
540cdf0e10cSrcweir     }
541cdf0e10cSrcweir }
542cdf0e10cSrcweir 
543cdf0e10cSrcweir void DrawingML::WriteBlipFill( Reference< XPropertySet > rXPropSet, String sURLPropName )
544cdf0e10cSrcweir {
545cdf0e10cSrcweir     WriteBlipFill( rXPropSet, sURLPropName, XML_a );
546cdf0e10cSrcweir }
547cdf0e10cSrcweir 
548cdf0e10cSrcweir void DrawingML::WriteBlipFill( Reference< XPropertySet > rXPropSet, String sURLPropName, sal_Int32 nXmlNamespace )
549cdf0e10cSrcweir {
550cdf0e10cSrcweir     if ( GetProperty( rXPropSet, sURLPropName ) ) {
551cdf0e10cSrcweir         OUString aURL;
552cdf0e10cSrcweir         mAny >>= aURL;
553cdf0e10cSrcweir 
554cdf0e10cSrcweir         DBG(printf ("URL: %s\n", OUStringToOString( aURL, RTL_TEXTENCODING_UTF8 ).getStr() ));
555cdf0e10cSrcweir 
556cdf0e10cSrcweir         if( !aURL.getLength() )
557cdf0e10cSrcweir             return;
558cdf0e10cSrcweir 
559cdf0e10cSrcweir         mpFS->startElementNS( nXmlNamespace , XML_blipFill, FSEND );
560cdf0e10cSrcweir 
561cdf0e10cSrcweir         WriteBlip( aURL );
562cdf0e10cSrcweir 
563cdf0e10cSrcweir         if( sURLPropName == S( "FillBitmapURL" ) )
564cdf0e10cSrcweir             WriteBlipMode( rXPropSet );
565cdf0e10cSrcweir         else if( GetProperty( rXPropSet, S( "FillBitmapStretch" ) ) ) {
566cdf0e10cSrcweir                 bool bStretch = false;
567cdf0e10cSrcweir                 mAny >>= bStretch;
568cdf0e10cSrcweir 
569cdf0e10cSrcweir                 if( bStretch )
570cdf0e10cSrcweir                     WriteStretch();
571cdf0e10cSrcweir         }
572cdf0e10cSrcweir 
573cdf0e10cSrcweir         mpFS->endElementNS( nXmlNamespace, XML_blipFill );
574cdf0e10cSrcweir     }
575cdf0e10cSrcweir }
576cdf0e10cSrcweir 
577cdf0e10cSrcweir void DrawingML::WriteStretch()
578cdf0e10cSrcweir {
579cdf0e10cSrcweir     mpFS->startElementNS( XML_a, XML_stretch, FSEND );
580cdf0e10cSrcweir     mpFS->singleElementNS( XML_a, XML_fillRect, FSEND );
581cdf0e10cSrcweir     mpFS->endElementNS( XML_a, XML_stretch );
582cdf0e10cSrcweir }
583cdf0e10cSrcweir 
584cdf0e10cSrcweir void DrawingML::WriteTransformation( const Rectangle& rRect,
585cdf0e10cSrcweir         sal_Bool bFlipH, sal_Bool bFlipV, sal_Int32 nRotation )
586cdf0e10cSrcweir {
587cdf0e10cSrcweir     mpFS->startElementNS( XML_a, XML_xfrm,
588cdf0e10cSrcweir                           XML_flipH, bFlipH ? "1" : NULL,
589cdf0e10cSrcweir                           XML_flipV, bFlipV ? "1" : NULL,
590cdf0e10cSrcweir                           XML_rot, nRotation ? I32S( nRotation ) : NULL,
591cdf0e10cSrcweir                           FSEND );
592cdf0e10cSrcweir 
593cdf0e10cSrcweir     mpFS->singleElementNS( XML_a, XML_off, XML_x, IS( MM100toEMU( rRect.Left() ) ), XML_y, IS( MM100toEMU( rRect.Top() ) ), FSEND );
594cdf0e10cSrcweir     mpFS->singleElementNS( XML_a, XML_ext, XML_cx, IS( MM100toEMU( rRect.GetWidth() ) ), XML_cy, IS( MM100toEMU( rRect.GetHeight() ) ), FSEND );
595cdf0e10cSrcweir 
596cdf0e10cSrcweir     mpFS->endElementNS( XML_a, XML_xfrm );
597cdf0e10cSrcweir }
598cdf0e10cSrcweir 
599cdf0e10cSrcweir void DrawingML::WriteShapeTransformation( Reference< XShape > rXShape, sal_Bool bFlipH, sal_Bool bFlipV, sal_Int32 nRotation )
600cdf0e10cSrcweir {
601cdf0e10cSrcweir     DBG(printf( "write shape transformation\n" ));
602cdf0e10cSrcweir 
603cdf0e10cSrcweir     awt::Point aPos = rXShape->getPosition();
604cdf0e10cSrcweir     awt::Size aSize = rXShape->getSize();
605cdf0e10cSrcweir 
606cdf0e10cSrcweir     WriteTransformation( Rectangle( Point( aPos.X, aPos.Y ), Size( aSize.Width, aSize.Height ) ), bFlipH, bFlipV, nRotation );
607cdf0e10cSrcweir }
608cdf0e10cSrcweir 
609cdf0e10cSrcweir void DrawingML::WriteRunProperties( Reference< XTextRange > rRun )
610cdf0e10cSrcweir {
611cdf0e10cSrcweir     Reference< XPropertySet > rXPropSet( rRun, UNO_QUERY );
612cdf0e10cSrcweir     Reference< XPropertyState > rXPropState( rRun, UNO_QUERY );
613cdf0e10cSrcweir     OUString usLanguage;
614cdf0e10cSrcweir     PropertyState eState;
615cdf0e10cSrcweir     sal_Int16 nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( Application::GetSettings().GetLanguage() );
616cdf0e10cSrcweir     sal_Bool bComplex = ( nScriptType == ScriptType::COMPLEX );
617cdf0e10cSrcweir     const char* bold = NULL;
618cdf0e10cSrcweir     const char* italic = NULL;
619cdf0e10cSrcweir     const char* underline = NULL;
620cdf0e10cSrcweir     sal_Int32 nSize = 1800;
621cdf0e10cSrcweir 
622cdf0e10cSrcweir     if( GETAD( CharHeight ) )
623cdf0e10cSrcweir         nSize = (sal_Int32) (100*(*((float*) mAny.getValue())));
624cdf0e10cSrcweir 
625cdf0e10cSrcweir     if ( ( bComplex && GETAD( CharWeightComplex ) ) || GETAD( CharWeight ) )
626cdf0e10cSrcweir         if ( *((float*) mAny.getValue()) >= awt::FontWeight::SEMIBOLD )
627cdf0e10cSrcweir             bold = "1";
628cdf0e10cSrcweir 
629cdf0e10cSrcweir     if ( ( bComplex && GETAD( CharPostureComplex ) ) || GETAD( CharPosture ) )
630cdf0e10cSrcweir         switch ( *((awt::FontSlant*) mAny.getValue()) )
631cdf0e10cSrcweir         {
632cdf0e10cSrcweir             case awt::FontSlant_OBLIQUE :
633cdf0e10cSrcweir             case awt::FontSlant_ITALIC :
634cdf0e10cSrcweir                 italic = "1";
635cdf0e10cSrcweir                 break;
636cdf0e10cSrcweir             default:
637cdf0e10cSrcweir                 break;
638cdf0e10cSrcweir         }
639cdf0e10cSrcweir 
640cdf0e10cSrcweir     if ( GETAD( CharUnderline ) )
641cdf0e10cSrcweir         switch ( *((sal_Int16*) mAny.getValue()) )
642cdf0e10cSrcweir         {
643cdf0e10cSrcweir             case awt::FontUnderline::SINGLE :
644cdf0e10cSrcweir                 underline = "sng";
645cdf0e10cSrcweir                 break;
646cdf0e10cSrcweir             case awt::FontUnderline::DOUBLE :
647cdf0e10cSrcweir                 underline = "dbl";
648cdf0e10cSrcweir                 break;
649cdf0e10cSrcweir             case awt::FontUnderline::DOTTED :
650cdf0e10cSrcweir                 underline = "dotted";
651cdf0e10cSrcweir                 break;
652cdf0e10cSrcweir             case awt::FontUnderline::DASH :
653cdf0e10cSrcweir                 underline = "dash";
654cdf0e10cSrcweir                 break;
655cdf0e10cSrcweir             case awt::FontUnderline::LONGDASH :
656cdf0e10cSrcweir                 underline = "dashLong";
657cdf0e10cSrcweir                 break;
658cdf0e10cSrcweir             case awt::FontUnderline::DASHDOT :
659cdf0e10cSrcweir                 underline = "dotDash";
660cdf0e10cSrcweir                 break;
661cdf0e10cSrcweir             case awt::FontUnderline::DASHDOTDOT :
662cdf0e10cSrcweir                 underline = "dotDotDash";
663cdf0e10cSrcweir                 break;
664cdf0e10cSrcweir             case awt::FontUnderline::WAVE :
665cdf0e10cSrcweir                 underline = "wavy";
666cdf0e10cSrcweir                 break;
667cdf0e10cSrcweir             case awt::FontUnderline::DOUBLEWAVE :
668cdf0e10cSrcweir                 underline = "wavyDbl";
669cdf0e10cSrcweir                 break;
670cdf0e10cSrcweir             case awt::FontUnderline::BOLD :
671cdf0e10cSrcweir                 underline = "heavy";
672cdf0e10cSrcweir                 break;
673cdf0e10cSrcweir             case awt::FontUnderline::BOLDDOTTED :
674cdf0e10cSrcweir                 underline = "dottedHeavy";
675cdf0e10cSrcweir                 break;
676cdf0e10cSrcweir             case awt::FontUnderline::BOLDDASH :
677cdf0e10cSrcweir                 underline = "dashHeavy";
678cdf0e10cSrcweir                 break;
679cdf0e10cSrcweir             case awt::FontUnderline::BOLDLONGDASH :
680cdf0e10cSrcweir                 underline = "dashLongHeavy";
681cdf0e10cSrcweir                 break;
682cdf0e10cSrcweir             case awt::FontUnderline::BOLDDASHDOT :
683cdf0e10cSrcweir                 underline = "dotDashHeavy";
684cdf0e10cSrcweir                 break;
685cdf0e10cSrcweir             case awt::FontUnderline::BOLDDASHDOTDOT :
686cdf0e10cSrcweir                 underline = "dotDotDashHeavy";
687cdf0e10cSrcweir                 break;
688cdf0e10cSrcweir             case awt::FontUnderline::BOLDWAVE :
689cdf0e10cSrcweir                 underline = "wavyHeavy";
690cdf0e10cSrcweir                 break;
691cdf0e10cSrcweir         }
692cdf0e10cSrcweir 
693cdf0e10cSrcweir     if( GETA( CharLocale ) ) {
694cdf0e10cSrcweir         com::sun::star::lang::Locale eLocale;
695cdf0e10cSrcweir         mAny >>= eLocale;
696cdf0e10cSrcweir 
697cdf0e10cSrcweir         OUStringBuffer usLanguageBuffer = eLocale.Language;
698cdf0e10cSrcweir         if( eLocale.Country.getLength() ) {
699cdf0e10cSrcweir             usLanguageBuffer.appendAscii( "-" );
700cdf0e10cSrcweir             usLanguageBuffer.append( eLocale.Country );
701cdf0e10cSrcweir         }
702cdf0e10cSrcweir 
703cdf0e10cSrcweir         if( usLanguageBuffer.getLength() )
704cdf0e10cSrcweir             usLanguage = usLanguageBuffer.makeStringAndClear();
705cdf0e10cSrcweir     }
706cdf0e10cSrcweir 
707cdf0e10cSrcweir     mpFS->startElementNS( XML_a, XML_rPr,
708cdf0e10cSrcweir                           XML_b, bold,
709cdf0e10cSrcweir                           XML_i, italic,
710cdf0e10cSrcweir                           XML_lang, usLanguage.getLength() ? USS( usLanguage ) : NULL,
711cdf0e10cSrcweir                           XML_sz, nSize == 1800 ? NULL : IS( nSize ),
712cdf0e10cSrcweir                           XML_u, underline,
713cdf0e10cSrcweir                           FSEND );
714cdf0e10cSrcweir 
715cdf0e10cSrcweir     // mso doesn't like text color to be placed after typeface
716cdf0e10cSrcweir     if( GETAD( CharColor ) ) {
717cdf0e10cSrcweir         sal_uInt32 color = *((sal_uInt32*) mAny.getValue());
718cdf0e10cSrcweir         DBG(printf("run color: %x auto: %x\n", static_cast<unsigned int>( color ), static_cast<unsigned int>( COL_AUTO )));
719cdf0e10cSrcweir 
720cdf0e10cSrcweir         if( color == COL_AUTO ) { // nCharColor depends to the background color
721cdf0e10cSrcweir             sal_Bool bIsDark = sal_False;
722cdf0e10cSrcweir             GET( bIsDark, IsBackgroundDark );
723cdf0e10cSrcweir             color = bIsDark ? 0xffffff : 0x000000;
724cdf0e10cSrcweir         }
725cdf0e10cSrcweir         color &= 0xffffff;
726cdf0e10cSrcweir 
727cdf0e10cSrcweir         // TODO: special handle embossed/engraved
728cdf0e10cSrcweir 
729cdf0e10cSrcweir         WriteSolidFill( color );
730cdf0e10cSrcweir     }
731cdf0e10cSrcweir 
732cdf0e10cSrcweir     if( GETAD( CharFontName ) ) {
733cdf0e10cSrcweir         const char* typeface = NULL;
734cdf0e10cSrcweir         const char* pitch = NULL;
735cdf0e10cSrcweir         const char* charset = NULL;
736cdf0e10cSrcweir         OUString usTypeface, usPitch, usCharset;
737cdf0e10cSrcweir 
738cdf0e10cSrcweir         mAny >>= usTypeface;
739cdf0e10cSrcweir         String aSubstName( GetSubsFontName( usTypeface, SUBSFONT_ONLYONE | SUBSFONT_MS ) );
740cdf0e10cSrcweir         if( aSubstName.Len() )
741cdf0e10cSrcweir             typeface = ST( aSubstName );
742cdf0e10cSrcweir         else
743cdf0e10cSrcweir             typeface = USS( usTypeface );
744cdf0e10cSrcweir 
745cdf0e10cSrcweir 
746cdf0e10cSrcweir 
747cdf0e10cSrcweir         mpFS->singleElementNS( XML_a, XML_latin,
748cdf0e10cSrcweir                                XML_typeface, typeface,
749cdf0e10cSrcweir                                XML_pitchFamily, pitch,
750cdf0e10cSrcweir                                XML_charset, charset,
751cdf0e10cSrcweir                                FSEND );
752cdf0e10cSrcweir     }
753cdf0e10cSrcweir 
754cdf0e10cSrcweir     if( ( bComplex && GETAD( CharFontNameComplex ) ) || ( !bComplex && GETAD( CharFontNameAsian ) ) ) {
755cdf0e10cSrcweir         const char* typeface = NULL;
756cdf0e10cSrcweir         const char* pitch = NULL;
757cdf0e10cSrcweir         const char* charset = NULL;
758cdf0e10cSrcweir         OUString usTypeface, usPitch, usCharset;
759cdf0e10cSrcweir 
760cdf0e10cSrcweir         mAny >>= usTypeface;
761cdf0e10cSrcweir         String aSubstName( GetSubsFontName( usTypeface, SUBSFONT_ONLYONE | SUBSFONT_MS ) );
762cdf0e10cSrcweir         if( aSubstName.Len() )
763cdf0e10cSrcweir             typeface = ST( aSubstName );
764cdf0e10cSrcweir         else
765cdf0e10cSrcweir             typeface = USS( usTypeface );
766cdf0e10cSrcweir 
767cdf0e10cSrcweir         mpFS->singleElementNS( XML_a, bComplex ? XML_cs : XML_ea,
768cdf0e10cSrcweir                                XML_typeface, typeface,
769cdf0e10cSrcweir                                XML_pitchFamily, pitch,
770cdf0e10cSrcweir                                XML_charset, charset,
771cdf0e10cSrcweir                                FSEND );
772cdf0e10cSrcweir     }
773cdf0e10cSrcweir 
774cdf0e10cSrcweir     mpFS->endElementNS( XML_a, XML_rPr );
775cdf0e10cSrcweir }
776cdf0e10cSrcweir 
777cdf0e10cSrcweir const char* DrawingML::GetFieldType( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > rRun )
778cdf0e10cSrcweir {
779cdf0e10cSrcweir     const char* sType = NULL;
780cdf0e10cSrcweir     Reference< XPropertySet > rXPropSet( rRun, UNO_QUERY );
781cdf0e10cSrcweir     String aFieldType;
782cdf0e10cSrcweir 
783cdf0e10cSrcweir     if( GETA( TextPortionType ) ) {
784cdf0e10cSrcweir         aFieldType = String( *(::rtl::OUString*)mAny.getValue() );
785cdf0e10cSrcweir         DBG(printf ("field type: %s\n", ST(aFieldType) ));
786cdf0e10cSrcweir     }
787cdf0e10cSrcweir 
788cdf0e10cSrcweir     if( aFieldType == S( "TextField" ) ) {
789cdf0e10cSrcweir         Reference< XTextField > rXTextField;
790cdf0e10cSrcweir         GET( rXTextField, TextField );
791cdf0e10cSrcweir         if( rXTextField.is() ) {
792cdf0e10cSrcweir             rXPropSet.set( rXTextField, UNO_QUERY );
793cdf0e10cSrcweir             if( rXPropSet.is() ) {
794cdf0e10cSrcweir                 String aFieldKind( rXTextField->getPresentation( TRUE ) );
795cdf0e10cSrcweir                 DBG(printf ("field kind: %s\n", ST(aFieldKind) ));
796cdf0e10cSrcweir                 if( aFieldKind == S( "Page" ) ) {
797cdf0e10cSrcweir                     return "slidenum";
798cdf0e10cSrcweir                 }
799cdf0e10cSrcweir             }
800cdf0e10cSrcweir         }
801cdf0e10cSrcweir     }
802cdf0e10cSrcweir 
803cdf0e10cSrcweir     return sType;
804cdf0e10cSrcweir }
805cdf0e10cSrcweir 
806cdf0e10cSrcweir void DrawingML::GetUUID( OStringBuffer& rBuffer )
807cdf0e10cSrcweir {
808cdf0e10cSrcweir     Sequence< sal_uInt8 > aSeq( 16 );
809cdf0e10cSrcweir     static char cDigits[17] = "0123456789ABCDEF";
810cdf0e10cSrcweir     rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
811cdf0e10cSrcweir     int i;
812cdf0e10cSrcweir 
813cdf0e10cSrcweir     rBuffer.append( '{' );
814cdf0e10cSrcweir     for( i = 0; i < 4; i++ ) {
815cdf0e10cSrcweir         rBuffer.append( cDigits[ aSeq[i] >> 4 ] );
816cdf0e10cSrcweir         rBuffer.append( cDigits[ aSeq[i] && 0xf ] );
817cdf0e10cSrcweir     }
818cdf0e10cSrcweir     rBuffer.append( '-' );
819cdf0e10cSrcweir     for( ; i < 6; i++ ) {
820cdf0e10cSrcweir         rBuffer.append( cDigits[ aSeq[i] >> 4 ] );
821cdf0e10cSrcweir         rBuffer.append( cDigits[ aSeq[i] && 0xf ] );
822cdf0e10cSrcweir     }
823cdf0e10cSrcweir     rBuffer.append( '-' );
824cdf0e10cSrcweir     for( ; i < 8; i++ ) {
825cdf0e10cSrcweir         rBuffer.append( cDigits[ aSeq[i] >> 4 ] );
826cdf0e10cSrcweir         rBuffer.append( cDigits[ aSeq[i] && 0xf ] );
827cdf0e10cSrcweir     }
828cdf0e10cSrcweir     rBuffer.append( '-' );
829cdf0e10cSrcweir     for( ; i < 10; i++ ) {
830cdf0e10cSrcweir         rBuffer.append( cDigits[ aSeq[i] >> 4 ] );
831cdf0e10cSrcweir         rBuffer.append( cDigits[ aSeq[i] && 0xf ] );
832cdf0e10cSrcweir     }
833cdf0e10cSrcweir     rBuffer.append( '-' );
834cdf0e10cSrcweir     for( ; i < 16; i++ ) {
835cdf0e10cSrcweir         rBuffer.append( cDigits[ aSeq[i] >> 4 ] );
836cdf0e10cSrcweir         rBuffer.append( cDigits[ aSeq[i] && 0xf ] );
837cdf0e10cSrcweir     }
838cdf0e10cSrcweir     rBuffer.append( '}' );
839cdf0e10cSrcweir }
840cdf0e10cSrcweir 
841cdf0e10cSrcweir void DrawingML::WriteRun( Reference< XTextRange > rRun )
842cdf0e10cSrcweir {
843cdf0e10cSrcweir     const char* sFieldType;
844cdf0e10cSrcweir     bool bIsField = false;
845cdf0e10cSrcweir     OUString sText = rRun->getString();
846cdf0e10cSrcweir 
847cdf0e10cSrcweir     if( sText.getLength() < 1)
848cdf0e10cSrcweir         return;
849cdf0e10cSrcweir 
850cdf0e10cSrcweir     if( ( sFieldType = GetFieldType( rRun ) ) ) {
851cdf0e10cSrcweir         OStringBuffer sUUID(39);
852cdf0e10cSrcweir 
853cdf0e10cSrcweir         GetUUID( sUUID );
854cdf0e10cSrcweir         mpFS->startElementNS( XML_a, XML_fld,
855cdf0e10cSrcweir                               XML_id, sUUID.getStr(),
856cdf0e10cSrcweir                               XML_type, sFieldType,
857cdf0e10cSrcweir                               FSEND );
858cdf0e10cSrcweir         bIsField = true;
859cdf0e10cSrcweir     } else
860cdf0e10cSrcweir         mpFS->startElementNS( XML_a, XML_r, FSEND );
861cdf0e10cSrcweir 
862cdf0e10cSrcweir     WriteRunProperties( rRun );
863cdf0e10cSrcweir 
864cdf0e10cSrcweir     mpFS->startElementNS( XML_a, XML_t, FSEND );
865cdf0e10cSrcweir     mpFS->writeEscaped( sText );
866cdf0e10cSrcweir     mpFS->endElementNS( XML_a, XML_t );
867cdf0e10cSrcweir 
868cdf0e10cSrcweir     if( bIsField )
869cdf0e10cSrcweir         mpFS->endElementNS( XML_a, XML_fld );
870cdf0e10cSrcweir     else
871cdf0e10cSrcweir         mpFS->endElementNS( XML_a, XML_r );
872cdf0e10cSrcweir }
873cdf0e10cSrcweir 
874cdf0e10cSrcweir #define AUTONUM(x) \
875cdf0e10cSrcweir                         if( bPBoth ) \
876cdf0e10cSrcweir                             pAutoNumType = #x "ParenBoth"; \
877cdf0e10cSrcweir                         else if( bPBehind ) \
878cdf0e10cSrcweir                             pAutoNumType = #x "ParenR"; \
879cdf0e10cSrcweir                         else if( bSDot ) \
880cdf0e10cSrcweir                             pAutoNumType = #x "Period";
881cdf0e10cSrcweir 
882cdf0e10cSrcweir 
883cdf0e10cSrcweir inline static const char* GetAutoNumType( sal_Int16 nNumberingType, bool bSDot, bool bPBehind, bool bPBoth )
884cdf0e10cSrcweir {
885cdf0e10cSrcweir     const char* pAutoNumType = NULL;
886cdf0e10cSrcweir 
887cdf0e10cSrcweir     switch( (SvxExtNumType)nNumberingType )
888cdf0e10cSrcweir         {
889cdf0e10cSrcweir         case SVX_NUM_CHARS_UPPER_LETTER_N :
890cdf0e10cSrcweir         case SVX_NUM_CHARS_UPPER_LETTER :
891cdf0e10cSrcweir             AUTONUM( alphaUc );
892cdf0e10cSrcweir             break;
893cdf0e10cSrcweir         case SVX_NUM_CHARS_LOWER_LETTER_N :
894cdf0e10cSrcweir         case SVX_NUM_CHARS_LOWER_LETTER :
895cdf0e10cSrcweir             AUTONUM( alphaLc );
896cdf0e10cSrcweir             break;
897cdf0e10cSrcweir         case SVX_NUM_ROMAN_UPPER :
898cdf0e10cSrcweir             AUTONUM( romanUc );
899cdf0e10cSrcweir             break;
900cdf0e10cSrcweir         case SVX_NUM_ROMAN_LOWER :
901cdf0e10cSrcweir             AUTONUM( romanLc );
902cdf0e10cSrcweir             break;
903cdf0e10cSrcweir         case SVX_NUM_ARABIC :
904cdf0e10cSrcweir             AUTONUM( arabic )
905cdf0e10cSrcweir             else
906cdf0e10cSrcweir                 pAutoNumType = "arabicPlain";
907cdf0e10cSrcweir                         break;
908cdf0e10cSrcweir         default:
909cdf0e10cSrcweir             break;
910cdf0e10cSrcweir         }
911cdf0e10cSrcweir 
912cdf0e10cSrcweir     return pAutoNumType;
913cdf0e10cSrcweir }
914cdf0e10cSrcweir 
915cdf0e10cSrcweir void DrawingML::WriteParagraphNumbering( Reference< XPropertySet > rXPropSet, sal_Int16 nLevel )
916cdf0e10cSrcweir {
917cdf0e10cSrcweir     if( nLevel >= 0 && GETA( NumberingRules ) )
918cdf0e10cSrcweir     {
919cdf0e10cSrcweir         Reference< XIndexAccess > rXIndexAccess;
920cdf0e10cSrcweir 
921cdf0e10cSrcweir         if ( ( mAny >>= rXIndexAccess ) && nLevel < rXIndexAccess->getCount() )
922cdf0e10cSrcweir         {
923cdf0e10cSrcweir             DBG(printf ("numbering rules\n"));
924cdf0e10cSrcweir 
925cdf0e10cSrcweir             Sequence< PropertyValue > aPropertySequence;
926cdf0e10cSrcweir             rXIndexAccess->getByIndex( nLevel ) >>= aPropertySequence;
927cdf0e10cSrcweir 
928cdf0e10cSrcweir 
929cdf0e10cSrcweir             const PropertyValue* pPropValue = aPropertySequence.getArray();
930cdf0e10cSrcweir 
931cdf0e10cSrcweir             sal_Int32 nPropertyCount = aPropertySequence.getLength();
932cdf0e10cSrcweir 
933cdf0e10cSrcweir             if ( nPropertyCount ) {
934cdf0e10cSrcweir 
935cdf0e10cSrcweir                 sal_Int16 nNumberingType = -1;
936cdf0e10cSrcweir                 bool bSDot = false;
937cdf0e10cSrcweir                 bool bPBehind = false;
938cdf0e10cSrcweir                 bool bPBoth = false;
939cdf0e10cSrcweir                 sal_Unicode aBulletChar = 0x2022; // a bullet
940cdf0e10cSrcweir                 awt::FontDescriptor aFontDesc;
941cdf0e10cSrcweir                 bool bHasFontDesc = false;
942cdf0e10cSrcweir                 OUString aGraphicURL;
943cdf0e10cSrcweir                 sal_Int16 nBulletRelSize = 0;
944cdf0e10cSrcweir 
945cdf0e10cSrcweir                 for ( sal_Int32 i = 0; i < nPropertyCount; i++ ) {
946cdf0e10cSrcweir                     const void* pValue = pPropValue[ i ].Value.getValue();
947cdf0e10cSrcweir                     if ( pValue ) {
948cdf0e10cSrcweir                         OUString aPropName( pPropValue[ i ].Name );
949cdf0e10cSrcweir                         DBG(printf ("pro name: %s\n", OUStringToOString( aPropName, RTL_TEXTENCODING_UTF8 ).getStr()));
950cdf0e10cSrcweir                         if ( aPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "NumberingType" ) ) )
951cdf0e10cSrcweir                             nNumberingType = *( (sal_Int16*)pValue );
952cdf0e10cSrcweir                         else if ( aPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Prefix" ) ) ) {
953cdf0e10cSrcweir                             if( *(OUString*)pValue == US( ")" ) )
954cdf0e10cSrcweir                                 bPBoth = true;
955cdf0e10cSrcweir                         } else if  ( aPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Suffix" ) ) ) {
956cdf0e10cSrcweir                             if( *(OUString*)pValue == US( "." ) )
957cdf0e10cSrcweir                                 bSDot = true;
958cdf0e10cSrcweir                             else if( *(OUString*)pValue == US( ")" ) )
959cdf0e10cSrcweir                                 bPBehind = true;
960cdf0e10cSrcweir                         } else if ( aPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "BulletChar" ) ) )
961cdf0e10cSrcweir                         {
962cdf0e10cSrcweir                             aBulletChar = String ( *( (String*)pValue ) ).GetChar( 0 );
963cdf0e10cSrcweir                             //printf ("bullet char: %d\n", aBulletChar.getStr());
964cdf0e10cSrcweir                         }
965cdf0e10cSrcweir                         else if ( aPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "BulletFont" ) ) )
966cdf0e10cSrcweir                         {
967cdf0e10cSrcweir                             aFontDesc = *( (awt::FontDescriptor*)pValue );
968cdf0e10cSrcweir                             bHasFontDesc = true;
969cdf0e10cSrcweir 
970cdf0e10cSrcweir                             // Our numbullet dialog has set the wrong textencoding for our "StarSymbol" font,
971cdf0e10cSrcweir                             // instead of a Unicode encoding the encoding RTL_TEXTENCODING_SYMBOL was used.
972cdf0e10cSrcweir                             // Because there might exist a lot of damaged documemts I added this two lines
973cdf0e10cSrcweir                             // which fixes the bullet problem for the export.
974cdf0e10cSrcweir                             if ( aFontDesc.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "StarSymbol" ) ) )
975cdf0e10cSrcweir                                 aFontDesc.CharSet = RTL_TEXTENCODING_MS_1252;
976cdf0e10cSrcweir 
977cdf0e10cSrcweir                         } else if ( aPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "BulletRelSize" ) ) ) {
978cdf0e10cSrcweir                             nBulletRelSize = *( (sal_Int16*)pValue );
979cdf0e10cSrcweir                         } else if ( aPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "GraphicURL" ) ) ) {
980cdf0e10cSrcweir                             aGraphicURL = ( *(OUString*)pValue );
981cdf0e10cSrcweir                             DBG(printf ("graphic url: %s\n", OUStringToOString( aGraphicURL, RTL_TEXTENCODING_UTF8 ).getStr()));
982cdf0e10cSrcweir                         } else if ( aPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "GraphicSize" ) ) )
983cdf0e10cSrcweir                         {
984cdf0e10cSrcweir                             if ( pPropValue[ i ].Value.getValueType() == ::getCppuType( (awt::Size*)0) )
985cdf0e10cSrcweir                             {
986cdf0e10cSrcweir                                 // don't cast awt::Size to Size as on 64-bits they are not the same.
987cdf0e10cSrcweir                                 ::com::sun::star::awt::Size aSize;
988cdf0e10cSrcweir                                 pPropValue[ i ].Value >>= aSize;
989cdf0e10cSrcweir                                 //aBuGraSize.nA = aSize.Width;
990cdf0e10cSrcweir                                 //aBuGraSize.nB = aSize.Height;
991cdf0e10cSrcweir                                 DBG(printf("graphic size: %dx%d\n", int( aSize.Width ), int( aSize.Height )));
992cdf0e10cSrcweir                             }
993cdf0e10cSrcweir                         }
994cdf0e10cSrcweir                     }
995cdf0e10cSrcweir                 }
996cdf0e10cSrcweir 
997cdf0e10cSrcweir                 const char* pAutoNumType = GetAutoNumType( nNumberingType, bSDot, bPBehind, bPBoth );
998cdf0e10cSrcweir 
999cdf0e10cSrcweir                 if( nLevel >= 0 ) {
1000cdf0e10cSrcweir                     if( aGraphicURL.getLength() > 0 ) {
1001cdf0e10cSrcweir                         OUString sRelId = WriteImage( aGraphicURL );
1002cdf0e10cSrcweir 
1003cdf0e10cSrcweir                         mpFS->startElementNS( XML_a, XML_buBlip, FSEND );
1004cdf0e10cSrcweir                         mpFS->singleElementNS( XML_a, XML_blip, FSNS( XML_r, XML_embed ), USS( sRelId ), FSEND );
1005cdf0e10cSrcweir                         mpFS->endElementNS( XML_a, XML_buBlip );
1006cdf0e10cSrcweir                     } else {
1007cdf0e10cSrcweir                         if( nBulletRelSize && nBulletRelSize != 100 )
1008cdf0e10cSrcweir                             mpFS->singleElementNS( XML_a, XML_buSzPct,
1009cdf0e10cSrcweir                                                    XML_val, IS( 1000*( (sal_Int32)nBulletRelSize ) ), FSEND );
1010cdf0e10cSrcweir                         if( bHasFontDesc )
1011cdf0e10cSrcweir                             mpFS->singleElementNS( XML_a, XML_buFont,
1012cdf0e10cSrcweir                                                    XML_typeface, OUStringToOString( aFontDesc.Name, RTL_TEXTENCODING_UTF8 ).getStr(),
1013cdf0e10cSrcweir                                                    XML_charset, (aFontDesc.CharSet == awt::CharSet::SYMBOL) ? "2" : NULL,
1014cdf0e10cSrcweir                                                    FSEND );
1015cdf0e10cSrcweir 
1016cdf0e10cSrcweir                         if( pAutoNumType )
1017cdf0e10cSrcweir                             mpFS->singleElementNS( XML_a, XML_buAutoNum, XML_type, pAutoNumType, FSEND );
1018cdf0e10cSrcweir                         else {
1019cdf0e10cSrcweir                             aBulletChar = SubstituteBullet( aBulletChar, aFontDesc );
1020cdf0e10cSrcweir                             mpFS->singleElementNS( XML_a, XML_buChar, XML_char, USS( OUString( aBulletChar ) ), FSEND );
1021cdf0e10cSrcweir                         }
1022cdf0e10cSrcweir                     }
1023cdf0e10cSrcweir                 }
1024cdf0e10cSrcweir             }
1025cdf0e10cSrcweir         }
1026cdf0e10cSrcweir     }
1027cdf0e10cSrcweir }
1028cdf0e10cSrcweir 
1029cdf0e10cSrcweir const char* DrawingML::GetAlignment( sal_Int32 nAlignment )
1030cdf0e10cSrcweir {
1031cdf0e10cSrcweir     const char* sAlignment = NULL;
1032cdf0e10cSrcweir 
1033cdf0e10cSrcweir     switch( nAlignment ) {
1034cdf0e10cSrcweir         case style::ParagraphAdjust_CENTER:
1035cdf0e10cSrcweir             sAlignment = "ctr";
1036cdf0e10cSrcweir             break;
1037cdf0e10cSrcweir         case style::ParagraphAdjust_RIGHT:
1038cdf0e10cSrcweir             sAlignment = "r";
1039cdf0e10cSrcweir             break;
1040cdf0e10cSrcweir         case style::ParagraphAdjust_BLOCK:
1041cdf0e10cSrcweir             sAlignment = "just";
1042cdf0e10cSrcweir             break;
1043cdf0e10cSrcweir         default:
1044cdf0e10cSrcweir             ;
1045cdf0e10cSrcweir     }
1046cdf0e10cSrcweir 
1047cdf0e10cSrcweir     return sAlignment;
1048cdf0e10cSrcweir }
1049cdf0e10cSrcweir 
1050cdf0e10cSrcweir void DrawingML::WriteParagraphProperties( Reference< XTextContent > rParagraph )
1051cdf0e10cSrcweir {
1052cdf0e10cSrcweir     Reference< XPropertySet > rXPropSet( rParagraph, UNO_QUERY );
1053cdf0e10cSrcweir     Reference< XPropertyState > rXPropState( rParagraph, UNO_QUERY );
1054cdf0e10cSrcweir 
1055cdf0e10cSrcweir     if( !rXPropSet.is() || !rXPropState.is() )
1056cdf0e10cSrcweir         return;
1057cdf0e10cSrcweir 
1058cdf0e10cSrcweir     sal_Int16 nLevel = -1;
1059cdf0e10cSrcweir     GET( nLevel, NumberingLevel );
1060cdf0e10cSrcweir 
1061cdf0e10cSrcweir     sal_Int32 nLeftMargin = 0;
1062cdf0e10cSrcweir     // fix coordinates
1063cdf0e10cSrcweir     //GET( nLeftMargin, ParaLeftMargin );
1064cdf0e10cSrcweir 
1065cdf0e10cSrcweir     sal_Int16 nAlignment( style::ParagraphAdjust_LEFT );
1066cdf0e10cSrcweir     GET( nAlignment, ParaAdjust );
1067cdf0e10cSrcweir 
1068cdf0e10cSrcweir     if( nLevel != -1
1069cdf0e10cSrcweir             || nLeftMargin > 0
1070cdf0e10cSrcweir             || nAlignment != style::ParagraphAdjust_LEFT ) {
1071cdf0e10cSrcweir         mpFS->startElementNS( XML_a, XML_pPr,
1072cdf0e10cSrcweir                               XML_lvl, nLevel > 0 ? I32S( nLevel ) : NULL,
1073cdf0e10cSrcweir                               XML_marL, nLeftMargin > 0 ? IS( nLeftMargin ) : NULL,
1074cdf0e10cSrcweir                               XML_algn, GetAlignment( nAlignment ),
1075cdf0e10cSrcweir                               FSEND );
1076cdf0e10cSrcweir 
1077cdf0e10cSrcweir         WriteParagraphNumbering( rXPropSet, nLevel );
1078cdf0e10cSrcweir 
1079cdf0e10cSrcweir         mpFS->endElementNS( XML_a, XML_pPr );
1080cdf0e10cSrcweir     }
1081cdf0e10cSrcweir }
1082cdf0e10cSrcweir 
1083cdf0e10cSrcweir void DrawingML::WriteParagraph( Reference< XTextContent > rParagraph )
1084cdf0e10cSrcweir {
1085cdf0e10cSrcweir     Reference< XEnumerationAccess > access( rParagraph, UNO_QUERY );
1086cdf0e10cSrcweir     if( !access.is() )
1087cdf0e10cSrcweir         return;
1088cdf0e10cSrcweir 
1089cdf0e10cSrcweir     Reference< XEnumeration > enumeration( access->createEnumeration() );
1090cdf0e10cSrcweir     if( !enumeration.is() )
1091cdf0e10cSrcweir         return;
1092cdf0e10cSrcweir 
1093cdf0e10cSrcweir     mpFS->startElementNS( XML_a, XML_p, FSEND );
1094cdf0e10cSrcweir 
1095cdf0e10cSrcweir     sal_Bool bPropertiesWritten = FALSE;
1096cdf0e10cSrcweir     while( enumeration->hasMoreElements() ) {
1097cdf0e10cSrcweir         Reference< XTextRange > run;
1098cdf0e10cSrcweir         Any any ( enumeration->nextElement() );
1099cdf0e10cSrcweir 
1100cdf0e10cSrcweir         if (any >>= run) {
1101cdf0e10cSrcweir             if( !bPropertiesWritten && run->getString().getLength() ) {
1102cdf0e10cSrcweir                 WriteParagraphProperties( rParagraph );
1103cdf0e10cSrcweir                 bPropertiesWritten = TRUE;
1104cdf0e10cSrcweir             }
1105cdf0e10cSrcweir             WriteRun( run );
1106cdf0e10cSrcweir         }
1107cdf0e10cSrcweir     }
1108cdf0e10cSrcweir     mpFS->singleElementNS( XML_a, XML_endParaRPr, FSEND );
1109cdf0e10cSrcweir 
1110cdf0e10cSrcweir     mpFS->endElementNS( XML_a, XML_p );
1111cdf0e10cSrcweir }
1112cdf0e10cSrcweir 
1113cdf0e10cSrcweir void DrawingML::WriteText( Reference< XShape > rXShape  )
1114cdf0e10cSrcweir {
1115cdf0e10cSrcweir     Reference< XText > xXText( rXShape, UNO_QUERY );
1116cdf0e10cSrcweir     Reference< XPropertySet > rXPropSet( rXShape, UNO_QUERY );
1117cdf0e10cSrcweir 
1118cdf0e10cSrcweir     if( !xXText.is() )
1119cdf0e10cSrcweir         return;
1120cdf0e10cSrcweir 
1121cdf0e10cSrcweir #define DEFLRINS 254
1122cdf0e10cSrcweir #define DEFTBINS 127
1123cdf0e10cSrcweir     sal_Int32 nLeft, nRight, nTop, nBottom;
1124cdf0e10cSrcweir     nLeft = nRight = DEFLRINS;
1125cdf0e10cSrcweir     nTop = nBottom = DEFTBINS;
1126cdf0e10cSrcweir 
1127cdf0e10cSrcweir     // top inset looks a bit different compared to ppt export
1128cdf0e10cSrcweir     // check if something related doesn't work as expected
1129cdf0e10cSrcweir     GET( nLeft, TextLeftDistance );
1130cdf0e10cSrcweir     GET( nRight, TextRightDistance );
1131cdf0e10cSrcweir     GET( nTop, TextUpperDistance );
1132cdf0e10cSrcweir     GET( nBottom, TextLowerDistance );
1133cdf0e10cSrcweir 
1134cdf0e10cSrcweir     TextVerticalAdjust eVerticalAlignment( TextVerticalAdjust_TOP );
1135cdf0e10cSrcweir     const char* sVerticalAlignment = NULL;
1136cdf0e10cSrcweir     GET( eVerticalAlignment, TextVerticalAdjust );
1137cdf0e10cSrcweir     switch( eVerticalAlignment ) {
1138cdf0e10cSrcweir         case TextVerticalAdjust_BOTTOM:
1139cdf0e10cSrcweir             sVerticalAlignment = "b";
1140cdf0e10cSrcweir             break;
1141cdf0e10cSrcweir         case TextVerticalAdjust_CENTER:
1142cdf0e10cSrcweir             sVerticalAlignment = "ctr";
1143cdf0e10cSrcweir             break;
1144cdf0e10cSrcweir         case TextVerticalAdjust_TOP:
1145cdf0e10cSrcweir         default:
1146cdf0e10cSrcweir             ;
1147cdf0e10cSrcweir     }
1148cdf0e10cSrcweir 
1149cdf0e10cSrcweir     TextHorizontalAdjust eHorizontalAlignment( TextHorizontalAdjust_CENTER );
1150cdf0e10cSrcweir     bool bHorizontalCenter = false;
1151cdf0e10cSrcweir     GET( eHorizontalAlignment, TextHorizontalAdjust );
1152cdf0e10cSrcweir     if( eHorizontalAlignment == TextHorizontalAdjust_CENTER )
1153cdf0e10cSrcweir         bHorizontalCenter = true;
1154cdf0e10cSrcweir 
1155cdf0e10cSrcweir     sal_Bool bHasWrap = FALSE;
1156cdf0e10cSrcweir     sal_Bool bWrap = FALSE;
1157cdf0e10cSrcweir     if( GETA( TextWordWrap ) ) {
1158cdf0e10cSrcweir         mAny >>= bWrap;
1159cdf0e10cSrcweir         bHasWrap = TRUE;
1160cdf0e10cSrcweir         //DBG(printf("wrap: %d\n", bWrap));
1161cdf0e10cSrcweir     }
1162cdf0e10cSrcweir 
1163cdf0e10cSrcweir     mpFS->singleElementNS( XML_a, XML_bodyPr,
1164cdf0e10cSrcweir                            XML_wrap, bHasWrap && !bWrap ? "none" : NULL,
1165cdf0e10cSrcweir                            XML_lIns, (nLeft != DEFLRINS) ? IS( MM100toEMU( nLeft ) ) : NULL,
1166cdf0e10cSrcweir                            XML_rIns, (nRight != DEFLRINS) ? IS( MM100toEMU( nRight ) ) : NULL,
1167cdf0e10cSrcweir                            XML_tIns, (nTop != DEFTBINS) ? IS( MM100toEMU( nTop ) ) : NULL,
1168cdf0e10cSrcweir                            XML_bIns, (nBottom != DEFTBINS) ? IS( MM100toEMU( nBottom ) ) : NULL,
1169cdf0e10cSrcweir                            XML_anchor, sVerticalAlignment,
1170cdf0e10cSrcweir                            XML_anchorCtr, bHorizontalCenter ? "1" : NULL,
1171cdf0e10cSrcweir                            FSEND );
1172cdf0e10cSrcweir 
1173cdf0e10cSrcweir     Reference< XEnumerationAccess > access( xXText, UNO_QUERY );
1174cdf0e10cSrcweir     if( !access.is() )
1175cdf0e10cSrcweir         return;
1176cdf0e10cSrcweir 
1177cdf0e10cSrcweir     Reference< XEnumeration > enumeration( access->createEnumeration() );
1178cdf0e10cSrcweir     if( !enumeration.is() )
1179cdf0e10cSrcweir         return;
1180cdf0e10cSrcweir 
1181cdf0e10cSrcweir     while( enumeration->hasMoreElements() ) {
1182cdf0e10cSrcweir         Reference< XTextContent > paragraph;
1183cdf0e10cSrcweir         Any any ( enumeration->nextElement() );
1184cdf0e10cSrcweir 
1185cdf0e10cSrcweir         if( any >>= paragraph)
1186cdf0e10cSrcweir             WriteParagraph( paragraph );
1187cdf0e10cSrcweir     }
1188cdf0e10cSrcweir 
1189cdf0e10cSrcweir }
1190cdf0e10cSrcweir 
1191cdf0e10cSrcweir void DrawingML::WritePresetShape( const char* pShape )
1192cdf0e10cSrcweir {
1193cdf0e10cSrcweir     mpFS->startElementNS( XML_a, XML_prstGeom,
1194cdf0e10cSrcweir                           XML_prst, pShape,
1195cdf0e10cSrcweir                           FSEND );
1196cdf0e10cSrcweir     mpFS->singleElementNS( XML_a, XML_avLst, FSEND );
1197cdf0e10cSrcweir     mpFS->endElementNS(  XML_a, XML_prstGeom );
1198cdf0e10cSrcweir }
1199cdf0e10cSrcweir 
1200cdf0e10cSrcweir void DrawingML::WritePresetShape( const char* pShape, MSO_SPT eShapeType, sal_Bool bPredefinedHandlesUsed, sal_Int32 nAdjustmentsWhichNeedsToBeConverted, const PropertyValue& rProp )
1201cdf0e10cSrcweir {
1202cdf0e10cSrcweir     mpFS->startElementNS( XML_a, XML_prstGeom,
1203cdf0e10cSrcweir                           XML_prst, pShape,
1204cdf0e10cSrcweir                           FSEND );
1205cdf0e10cSrcweir     mpFS->startElementNS( XML_a, XML_avLst, FSEND );
1206cdf0e10cSrcweir 
1207cdf0e10cSrcweir     Sequence< drawing::EnhancedCustomShapeAdjustmentValue > aAdjustmentSeq;
1208cdf0e10cSrcweir     if ( rProp.Value >>= aAdjustmentSeq ) {
1209cdf0e10cSrcweir         DBG(printf("adj seq len: %d\n", int( aAdjustmentSeq.getLength() )));
1210cdf0e10cSrcweir         if ( bPredefinedHandlesUsed )
1211cdf0e10cSrcweir             EscherPropertyContainer::LookForPolarHandles( eShapeType, nAdjustmentsWhichNeedsToBeConverted );
1212cdf0e10cSrcweir 
1213cdf0e10cSrcweir         sal_Int32 nValue, nLength = aAdjustmentSeq.getLength();
1214cdf0e10cSrcweir         for( sal_Int32 i=0; i < nLength; i++ )
1215cdf0e10cSrcweir             if( EscherPropertyContainer::GetAdjustmentValue( aAdjustmentSeq[ i ], i, nAdjustmentsWhichNeedsToBeConverted, nValue ) )
1216cdf0e10cSrcweir                 mpFS->singleElementNS( XML_a, XML_gd,
1217cdf0e10cSrcweir                                        XML_name, nLength > 1 ? ( OString( "adj" ) + OString::valueOf( i + 1 ) ).getStr() : "adj",
1218cdf0e10cSrcweir                                        XML_fmla, (OString("val ") + OString::valueOf( nValue )).getStr(),
1219cdf0e10cSrcweir                                        FSEND );
1220cdf0e10cSrcweir     }
1221cdf0e10cSrcweir 
1222cdf0e10cSrcweir     mpFS->endElementNS( XML_a, XML_avLst );
1223cdf0e10cSrcweir     mpFS->endElementNS(  XML_a, XML_prstGeom );
1224cdf0e10cSrcweir }
1225cdf0e10cSrcweir 
1226cdf0e10cSrcweir void DrawingML::WritePolyPolygon( const PolyPolygon& rPolyPolygon )
1227cdf0e10cSrcweir {
1228cdf0e10cSrcweir     if( rPolyPolygon.Count() < 1 )
1229cdf0e10cSrcweir         return;
1230cdf0e10cSrcweir 
1231cdf0e10cSrcweir     mpFS->startElementNS( XML_a, XML_custGeom, FSEND );
1232cdf0e10cSrcweir     mpFS->singleElementNS( XML_a, XML_avLst, FSEND );
1233cdf0e10cSrcweir     mpFS->singleElementNS( XML_a, XML_gdLst, FSEND );
1234cdf0e10cSrcweir     mpFS->singleElementNS( XML_a, XML_ahLst, FSEND );
1235cdf0e10cSrcweir     mpFS->singleElementNS( XML_a, XML_rect,
1236cdf0e10cSrcweir                            XML_l, "0",
1237cdf0e10cSrcweir                            XML_t, "0",
1238cdf0e10cSrcweir                            XML_r, "r",
1239cdf0e10cSrcweir                            XML_b, "b",
1240cdf0e10cSrcweir                            FSEND );
1241cdf0e10cSrcweir 
1242cdf0e10cSrcweir     mpFS->startElementNS( XML_a, XML_pathLst, FSEND );
1243cdf0e10cSrcweir 
1244cdf0e10cSrcweir     for( USHORT i = 0; i < rPolyPolygon.Count(); i ++ ) {
1245cdf0e10cSrcweir 
1246cdf0e10cSrcweir         const Polygon& rPoly = rPolyPolygon[ i ];
1247cdf0e10cSrcweir         Rectangle aRect( rPoly.GetBoundRect() );
1248cdf0e10cSrcweir         sal_Bool bBezier = FALSE;
1249cdf0e10cSrcweir 
1250cdf0e10cSrcweir         mpFS->startElementNS( XML_a, XML_path,
1251cdf0e10cSrcweir                               XML_w, I64S( aRect.GetWidth() ),
1252cdf0e10cSrcweir                               XML_h, I64S( aRect.GetHeight() ),
1253cdf0e10cSrcweir                               FSEND );
1254cdf0e10cSrcweir 
1255cdf0e10cSrcweir         if( rPoly.GetSize() > 0 )
1256cdf0e10cSrcweir         {
1257cdf0e10cSrcweir             mpFS->startElementNS( XML_a, XML_moveTo, FSEND );
1258cdf0e10cSrcweir 
1259cdf0e10cSrcweir             mpFS->singleElementNS( XML_a, XML_pt,
1260cdf0e10cSrcweir                                    XML_x, I64S( rPoly[ 0 ].X() - aRect.Left() ),
1261cdf0e10cSrcweir                                    XML_y, I64S( rPoly[ 0 ].Y() - aRect.Top() ),
1262cdf0e10cSrcweir                                    FSEND );
1263cdf0e10cSrcweir 
1264cdf0e10cSrcweir             mpFS->endElementNS( XML_a, XML_moveTo );
1265cdf0e10cSrcweir         }
1266cdf0e10cSrcweir 
1267cdf0e10cSrcweir         for( USHORT j = 1; j < rPoly.GetSize(); j ++ )
1268cdf0e10cSrcweir         {
1269cdf0e10cSrcweir             enum PolyFlags flags = rPoly.GetFlags(j);
1270cdf0e10cSrcweir             if( flags == POLY_CONTROL && !bBezier )
1271cdf0e10cSrcweir             {
1272cdf0e10cSrcweir                 mpFS->startElementNS( XML_a, XML_cubicBezTo, FSEND );
1273cdf0e10cSrcweir                 bBezier = TRUE;
1274cdf0e10cSrcweir             }
1275cdf0e10cSrcweir             else if( flags == POLY_NORMAL && !bBezier )
1276cdf0e10cSrcweir                 mpFS->startElementNS( XML_a, XML_lnTo, FSEND );
1277cdf0e10cSrcweir 
1278cdf0e10cSrcweir             mpFS->singleElementNS( XML_a, XML_pt,
1279cdf0e10cSrcweir                                    XML_x, I64S( rPoly[j].X() - aRect.Left() ),
1280cdf0e10cSrcweir                                    XML_y, I64S( rPoly[j].Y() - aRect.Top() ),
1281cdf0e10cSrcweir                                    FSEND );
1282cdf0e10cSrcweir 
1283cdf0e10cSrcweir             if( ( flags == POLY_NORMAL || flags == POLY_SYMMTR ) && bBezier )
1284cdf0e10cSrcweir             {
1285cdf0e10cSrcweir                 mpFS->endElementNS( XML_a, XML_cubicBezTo );
1286cdf0e10cSrcweir                 bBezier = FALSE;
1287cdf0e10cSrcweir             }
1288cdf0e10cSrcweir             else if( flags == POLY_NORMAL && !bBezier )
1289cdf0e10cSrcweir                 mpFS->endElementNS( XML_a, XML_lnTo );
1290cdf0e10cSrcweir             else if( bBezier && ( j % 3 ) == 0 )
1291cdf0e10cSrcweir             {
1292cdf0e10cSrcweir                 // //a:cubicBezTo can only contain 3 //a:pt elements, so we
1293cdf0e10cSrcweir                 // need to break things up...
1294cdf0e10cSrcweir                 mpFS->endElementNS( XML_a, XML_cubicBezTo );
1295cdf0e10cSrcweir                 mpFS->startElementNS( XML_a, XML_cubicBezTo, FSEND );
1296cdf0e10cSrcweir             }
1297cdf0e10cSrcweir //             switch( rPoly.GetFlags(j) ) {
1298cdf0e10cSrcweir //                 case POLY_NORMAL:
1299cdf0e10cSrcweir //                     DBG(printf("normal\n"));
1300cdf0e10cSrcweir //                     break;
1301cdf0e10cSrcweir //                 case POLY_SMOOTH:
1302cdf0e10cSrcweir //                     DBG(printf("smooth\n"));
1303cdf0e10cSrcweir //                     break;
1304cdf0e10cSrcweir //                 case POLY_CONTROL:
1305cdf0e10cSrcweir //                     DBG(printf("control\n"));
1306cdf0e10cSrcweir //                     break;
1307cdf0e10cSrcweir //                 case POLY_SYMMTR:
1308cdf0e10cSrcweir //                     DBG(printf("symmtr\n"));
1309cdf0e10cSrcweir //                         break;
1310cdf0e10cSrcweir //             }
1311cdf0e10cSrcweir //             DBG(printf("point %ld %ld\n", rPoly[j].X() - aRect.Left(), rPoly[j].Y() - aRect.Top()));
1312cdf0e10cSrcweir         }
1313cdf0e10cSrcweir 
1314cdf0e10cSrcweir         mpFS->endElementNS( XML_a, XML_path );
1315cdf0e10cSrcweir     }
1316cdf0e10cSrcweir 
1317cdf0e10cSrcweir     mpFS->endElementNS( XML_a, XML_pathLst );
1318cdf0e10cSrcweir 
1319cdf0e10cSrcweir     mpFS->endElementNS(  XML_a, XML_custGeom );
1320cdf0e10cSrcweir }
1321cdf0e10cSrcweir 
1322cdf0e10cSrcweir void DrawingML::WriteConnectorConnections( EscherConnectorListEntry& rConnectorEntry, sal_Int32 nStartID, sal_Int32 nEndID )
1323cdf0e10cSrcweir {
1324cdf0e10cSrcweir     mpFS->singleElementNS( XML_a, XML_stCxn,
1325cdf0e10cSrcweir                            XML_id, I32S( nStartID ),
1326cdf0e10cSrcweir                            XML_idx, I64S( rConnectorEntry.GetConnectorRule( TRUE ) ),
1327cdf0e10cSrcweir                            FSEND );
1328cdf0e10cSrcweir     mpFS->singleElementNS( XML_a, XML_endCxn,
1329cdf0e10cSrcweir                            XML_id, I32S( nEndID ),
1330cdf0e10cSrcweir                            XML_idx, I64S( rConnectorEntry.GetConnectorRule( FALSE ) ),
1331cdf0e10cSrcweir                            FSEND );
1332cdf0e10cSrcweir }
1333cdf0e10cSrcweir 
1334cdf0e10cSrcweir // from sw/source/filter/ww8/wrtw8num.cxx for default bullets to export to MS intact
1335cdf0e10cSrcweir static void lcl_SubstituteBullet(String& rNumStr, rtl_TextEncoding& rChrSet, String& rFontName)
1336cdf0e10cSrcweir {
1337cdf0e10cSrcweir     sal_Unicode cChar = rNumStr.GetChar(0);
1338cdf0e10cSrcweir     StarSymbolToMSMultiFont *pConvert = CreateStarSymbolToMSMultiFont();
1339cdf0e10cSrcweir     String sFont = pConvert->ConvertChar(cChar);
1340cdf0e10cSrcweir     delete pConvert;
1341cdf0e10cSrcweir     if (sFont.Len())
1342cdf0e10cSrcweir     {
1343cdf0e10cSrcweir         rNumStr = static_cast< sal_Unicode >(cChar | 0xF000);
1344cdf0e10cSrcweir         rFontName = sFont;
1345cdf0e10cSrcweir         rChrSet = RTL_TEXTENCODING_SYMBOL;
1346cdf0e10cSrcweir     }
1347cdf0e10cSrcweir     else if ( (rNumStr.GetChar(0) < 0xE000 || rNumStr.GetChar(0) > 0xF8FF) )
1348cdf0e10cSrcweir     {
1349cdf0e10cSrcweir         /*
1350cdf0e10cSrcweir            Ok we can't fit into a known windows unicode font, but
1351cdf0e10cSrcweir            we are not in the private area, so we are a
1352cdf0e10cSrcweir            standardized symbol, so turn off the symbol bit and
1353cdf0e10cSrcweir            let words own font substitution kick in
1354cdf0e10cSrcweir            */
1355cdf0e10cSrcweir         rChrSet = RTL_TEXTENCODING_UNICODE;
1356cdf0e10cSrcweir         rFontName = ::GetFontToken(rFontName, 0);
1357cdf0e10cSrcweir     }
1358cdf0e10cSrcweir     else
1359cdf0e10cSrcweir     {
1360cdf0e10cSrcweir         /*
1361cdf0e10cSrcweir            Well we don't have an available substition, and we're
1362cdf0e10cSrcweir            in our private area, so give up and show a standard
1363cdf0e10cSrcweir            bullet symbol
1364cdf0e10cSrcweir            */
1365cdf0e10cSrcweir         rFontName.AssignAscii(RTL_CONSTASCII_STRINGPARAM("Wingdings"));
1366cdf0e10cSrcweir         rNumStr = static_cast< sal_Unicode >(0x6C);
1367cdf0e10cSrcweir     }
1368cdf0e10cSrcweir }
1369cdf0e10cSrcweir 
1370cdf0e10cSrcweir sal_Unicode DrawingML::SubstituteBullet( sal_Unicode cBulletId, ::com::sun::star::awt::FontDescriptor& rFontDesc )
1371cdf0e10cSrcweir {
1372cdf0e10cSrcweir     String sNumStr = cBulletId;
1373cdf0e10cSrcweir 
1374cdf0e10cSrcweir     if ( rFontDesc.Name.equalsIgnoreAsciiCaseAscii("starsymbol") ||
1375cdf0e10cSrcweir          rFontDesc.Name.equalsIgnoreAsciiCaseAscii("opensymbol") )  {
1376cdf0e10cSrcweir         String sFontName = rFontDesc.Name;
1377cdf0e10cSrcweir         rtl_TextEncoding aCharSet = rFontDesc.CharSet;
1378cdf0e10cSrcweir 
1379cdf0e10cSrcweir         lcl_SubstituteBullet( sNumStr, aCharSet, sFontName );
1380cdf0e10cSrcweir 
1381cdf0e10cSrcweir         rFontDesc.Name = sFontName;
1382cdf0e10cSrcweir         rFontDesc.CharSet = aCharSet;
1383cdf0e10cSrcweir     }
1384cdf0e10cSrcweir 
1385cdf0e10cSrcweir     return sNumStr.GetChar( 0 );
1386cdf0e10cSrcweir }
1387cdf0e10cSrcweir 
1388cdf0e10cSrcweir }
1389cdf0e10cSrcweir }
1390