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