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 :
21 : #include <com/sun/star/graphic/XGraphic.hpp>
22 : #include <com/sun/star/graphic/GraphicProvider.hpp>
23 : #include <com/sun/star/graphic/XGraphicProvider.hpp>
24 : #include <com/sun/star/embed/ElementModes.hpp>
25 : #include <com/sun/star/embed/XTransactedObject.hpp>
26 : #include <com/sun/star/io/XSeekableInputStream.hpp>
27 : #include <com/sun/star/drawing/HomogenMatrix.hpp>
28 : #include <com/sun/star/drawing/PolyPolygonShape3D.hpp>
29 : #include <com/sun/star/drawing/ProjectionMode.hpp>
30 : #include <com/sun/star/drawing/ShadeMode.hpp>
31 : #include <com/sun/star/drawing/Direction3D.hpp>
32 : #include <com/sun/star/drawing/Position3D.hpp>
33 : #include <com/sun/star/drawing/CameraGeometry.hpp>
34 : #include <com/sun/star/drawing/DoubleSequence.hpp>
35 :
36 : #include <com/sun/star/table/XColumnRowRange.hpp>
37 :
38 : #include <sax/tools/converter.hxx>
39 :
40 : #include <xmloff/shapeexport.hxx>
41 : #include "sdpropls.hxx"
42 : #include <tools/debug.hxx>
43 : #include <rtl/ustrbuf.hxx>
44 : #include <xmloff/xmlexp.hxx>
45 : #include <xmloff/xmluconv.hxx>
46 : #include "xexptran.hxx"
47 : #include <xmloff/xmltoken.hxx>
48 : #include "EnhancedCustomShapeToken.hxx"
49 : #include <com/sun/star/container/XIdentifierContainer.hpp>
50 : #include <com/sun/star/drawing/EnhancedCustomShapeParameterType.hpp>
51 : #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
52 : #include <com/sun/star/drawing/EnhancedCustomShapeGluePointType.hpp>
53 : #include <com/sun/star/drawing/EnhancedCustomShapeTextFrame.hpp>
54 : #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
55 : #include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp>
56 : #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
57 : #include <com/sun/star/drawing/EnhancedCustomShapeTextPathMode.hpp>
58 : #include <com/sun/star/beans/PropertyValues.hpp>
59 : #include <rtl/math.hxx>
60 : #include <basegfx/vector/b3dvector.hxx>
61 :
62 : #include "xmloff/xmlnmspe.hxx"
63 : #include "XMLBase64Export.hxx"
64 : #include <comphelper/processfactory.hxx>
65 :
66 : using namespace ::com::sun::star;
67 : using namespace ::com::sun::star::io;
68 : using namespace ::xmloff::token;
69 : using namespace ::xmloff::EnhancedCustomShapeToken;
70 :
71 : using ::com::sun::star::embed::XStorage;
72 : using ::com::sun::star::uno::UNO_QUERY;
73 : using ::com::sun::star::uno::UNO_QUERY_THROW;
74 : using ::com::sun::star::uno::Reference;
75 : using ::com::sun::star::uno::Sequence;
76 :
77 : //////////////////////////////////////////////////////////////////////////////
78 :
79 0 : void ExportParameter( OUStringBuffer& rStrBuffer, const com::sun::star::drawing::EnhancedCustomShapeParameter& rParameter )
80 : {
81 0 : if ( !rStrBuffer.isEmpty() )
82 0 : rStrBuffer.append( (sal_Unicode)' ' );
83 0 : if ( rParameter.Value.getValueTypeClass() == uno::TypeClass_DOUBLE )
84 : {
85 0 : double fNumber = 0.0;
86 0 : rParameter.Value >>= fNumber;
87 0 : ::rtl::math::doubleToUStringBuffer( rStrBuffer, fNumber, rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, '.', sal_True );
88 : }
89 : else
90 : {
91 0 : sal_Int32 nValue = 0;
92 0 : rParameter.Value >>= nValue;
93 :
94 0 : switch( rParameter.Type )
95 : {
96 : case com::sun::star::drawing::EnhancedCustomShapeParameterType::EQUATION :
97 : {
98 0 : rStrBuffer.append( (sal_Unicode)'?' );
99 0 : rStrBuffer.append( (sal_Unicode)'f' );
100 0 : rStrBuffer.append( OUString::valueOf( nValue ) );
101 : }
102 0 : break;
103 :
104 : case com::sun::star::drawing::EnhancedCustomShapeParameterType::ADJUSTMENT :
105 : {
106 0 : rStrBuffer.append( (sal_Unicode)'$' );
107 0 : rStrBuffer.append( OUString::valueOf( nValue ) );
108 : }
109 0 : break;
110 :
111 : case com::sun::star::drawing::EnhancedCustomShapeParameterType::BOTTOM :
112 0 : rStrBuffer.append( GetXMLToken( XML_BOTTOM ) ); break;
113 : case com::sun::star::drawing::EnhancedCustomShapeParameterType::RIGHT :
114 0 : rStrBuffer.append( GetXMLToken( XML_RIGHT ) ); break;
115 : case com::sun::star::drawing::EnhancedCustomShapeParameterType::TOP :
116 0 : rStrBuffer.append( GetXMLToken( XML_TOP ) ); break;
117 : case com::sun::star::drawing::EnhancedCustomShapeParameterType::LEFT :
118 0 : rStrBuffer.append( GetXMLToken( XML_LEFT ) ); break;
119 : case com::sun::star::drawing::EnhancedCustomShapeParameterType::XSTRETCH :
120 0 : rStrBuffer.append( GetXMLToken( XML_XSTRETCH ) ); break;
121 : case com::sun::star::drawing::EnhancedCustomShapeParameterType::YSTRETCH :
122 0 : rStrBuffer.append( GetXMLToken( XML_YSTRETCH ) ); break;
123 : case com::sun::star::drawing::EnhancedCustomShapeParameterType::HASSTROKE :
124 0 : rStrBuffer.append( GetXMLToken( XML_HASSTROKE ) ); break;
125 : case com::sun::star::drawing::EnhancedCustomShapeParameterType::HASFILL :
126 0 : rStrBuffer.append( GetXMLToken( XML_HASFILL ) ); break;
127 : case com::sun::star::drawing::EnhancedCustomShapeParameterType::WIDTH :
128 0 : rStrBuffer.append( GetXMLToken( XML_WIDTH ) ); break;
129 : case com::sun::star::drawing::EnhancedCustomShapeParameterType::HEIGHT :
130 0 : rStrBuffer.append( GetXMLToken( XML_HEIGHT ) ); break;
131 : case com::sun::star::drawing::EnhancedCustomShapeParameterType::LOGWIDTH :
132 0 : rStrBuffer.append( GetXMLToken( XML_LOGWIDTH ) ); break;
133 : case com::sun::star::drawing::EnhancedCustomShapeParameterType::LOGHEIGHT :
134 0 : rStrBuffer.append( GetXMLToken( XML_LOGHEIGHT ) ); break;
135 : default :
136 0 : rStrBuffer.append( OUString::valueOf( nValue ) );
137 : }
138 : }
139 0 : }
140 :
141 0 : void ImpExportEquations( SvXMLExport& rExport, const uno::Sequence< OUString >& rEquations )
142 : {
143 : sal_Int32 i;
144 0 : for ( i = 0; i < rEquations.getLength(); i++ )
145 : {
146 0 : OUString aStr(static_cast<sal_Unicode>('f'));
147 0 : aStr += OUString::valueOf( i );
148 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, aStr );
149 :
150 0 : aStr = rEquations[ i ];
151 0 : sal_Int32 nIndex = 0;
152 0 : do
153 : {
154 0 : nIndex = aStr.indexOf( (sal_Unicode)'?', nIndex );
155 0 : if ( nIndex != -1 )
156 : {
157 0 : OUString aNew( aStr.copy( 0, nIndex + 1 ) );
158 0 : aNew += OUString(static_cast<sal_Unicode>('f'));
159 0 : aNew += aStr.copy( nIndex + 1, ( aStr.getLength() - nIndex ) - 1 );
160 0 : aStr = aNew;
161 0 : nIndex++;
162 : }
163 : } while( nIndex != -1 );
164 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_FORMULA, aStr );
165 0 : SvXMLElementExport aOBJ( rExport, XML_NAMESPACE_DRAW, XML_EQUATION, sal_True, sal_True );
166 0 : }
167 0 : }
168 :
169 0 : void ImpExportHandles( SvXMLExport& rExport, const uno::Sequence< beans::PropertyValues >& rHandles )
170 : {
171 0 : sal_uInt32 i, j, nElements = rHandles.getLength();
172 0 : if ( nElements )
173 : {
174 0 : OUString aStr;
175 0 : OUStringBuffer aStrBuffer;
176 :
177 0 : for ( i = 0; i < nElements; i++ )
178 : {
179 0 : sal_Bool bPosition = sal_False;
180 0 : const uno::Sequence< beans::PropertyValue >& rPropSeq = rHandles[ i ];
181 0 : for ( j = 0; j < (sal_uInt32)rPropSeq.getLength(); j++ )
182 : {
183 0 : const beans::PropertyValue& rPropVal = rPropSeq[ j ];
184 0 : switch( EASGet( rPropVal.Name ) )
185 : {
186 : case EAS_Position :
187 : {
188 0 : com::sun::star::drawing::EnhancedCustomShapeParameterPair aPosition;
189 0 : if ( rPropVal.Value >>= aPosition )
190 : {
191 0 : ExportParameter( aStrBuffer, aPosition.First );
192 0 : ExportParameter( aStrBuffer, aPosition.Second );
193 0 : aStr = aStrBuffer.makeStringAndClear();
194 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_POSITION, aStr );
195 0 : bPosition = sal_True;
196 0 : }
197 : }
198 0 : break;
199 : case EAS_MirroredX :
200 : {
201 0 : sal_Bool bMirroredX = sal_Bool();
202 0 : if ( rPropVal.Value >>= bMirroredX )
203 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_MIRROR_HORIZONTAL,
204 0 : bMirroredX ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) );
205 : }
206 0 : break;
207 : case EAS_MirroredY :
208 : {
209 0 : sal_Bool bMirroredY = sal_Bool();
210 0 : if ( rPropVal.Value >>= bMirroredY )
211 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_MIRROR_VERTICAL,
212 0 : bMirroredY ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) );
213 : }
214 0 : break;
215 : case EAS_Switched :
216 : {
217 0 : sal_Bool bSwitched = sal_Bool();
218 0 : if ( rPropVal.Value >>= bSwitched )
219 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_SWITCHED,
220 0 : bSwitched ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) );
221 : }
222 0 : break;
223 : case EAS_Polar :
224 : {
225 0 : com::sun::star::drawing::EnhancedCustomShapeParameterPair aPolar;
226 0 : if ( rPropVal.Value >>= aPolar )
227 : {
228 0 : ExportParameter( aStrBuffer, aPolar.First );
229 0 : ExportParameter( aStrBuffer, aPolar.Second );
230 0 : aStr = aStrBuffer.makeStringAndClear();
231 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_POLAR, aStr );
232 0 : }
233 : }
234 0 : break;
235 : case EAS_RadiusRangeMinimum :
236 : {
237 0 : com::sun::star::drawing::EnhancedCustomShapeParameter aRadiusRangeMinimum;
238 0 : if ( rPropVal.Value >>= aRadiusRangeMinimum )
239 : {
240 0 : ExportParameter( aStrBuffer, aRadiusRangeMinimum );
241 0 : aStr = aStrBuffer.makeStringAndClear();
242 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_RADIUS_RANGE_MINIMUM, aStr );
243 0 : }
244 : }
245 0 : break;
246 : case EAS_RadiusRangeMaximum :
247 : {
248 0 : com::sun::star::drawing::EnhancedCustomShapeParameter aRadiusRangeMaximum;
249 0 : if ( rPropVal.Value >>= aRadiusRangeMaximum )
250 : {
251 0 : ExportParameter( aStrBuffer, aRadiusRangeMaximum );
252 0 : aStr = aStrBuffer.makeStringAndClear();
253 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_RADIUS_RANGE_MAXIMUM, aStr );
254 0 : }
255 : }
256 0 : break;
257 : case EAS_RangeXMinimum :
258 : {
259 0 : com::sun::star::drawing::EnhancedCustomShapeParameter aXRangeMinimum;
260 0 : if ( rPropVal.Value >>= aXRangeMinimum )
261 : {
262 0 : ExportParameter( aStrBuffer, aXRangeMinimum );
263 0 : aStr = aStrBuffer.makeStringAndClear();
264 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_RANGE_X_MINIMUM, aStr );
265 0 : }
266 : }
267 0 : break;
268 : case EAS_RangeXMaximum :
269 : {
270 0 : com::sun::star::drawing::EnhancedCustomShapeParameter aXRangeMaximum;
271 0 : if ( rPropVal.Value >>= aXRangeMaximum )
272 : {
273 0 : ExportParameter( aStrBuffer, aXRangeMaximum );
274 0 : aStr = aStrBuffer.makeStringAndClear();
275 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_RANGE_X_MAXIMUM, aStr );
276 0 : }
277 : }
278 0 : break;
279 : case EAS_RangeYMinimum :
280 : {
281 0 : com::sun::star::drawing::EnhancedCustomShapeParameter aYRangeMinimum;
282 0 : if ( rPropVal.Value >>= aYRangeMinimum )
283 : {
284 0 : ExportParameter( aStrBuffer, aYRangeMinimum );
285 0 : aStr = aStrBuffer.makeStringAndClear();
286 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_RANGE_Y_MINIMUM, aStr );
287 0 : }
288 : }
289 0 : break;
290 : case EAS_RangeYMaximum :
291 : {
292 0 : com::sun::star::drawing::EnhancedCustomShapeParameter aYRangeMaximum;
293 0 : if ( rPropVal.Value >>= aYRangeMaximum )
294 : {
295 0 : ExportParameter( aStrBuffer, aYRangeMaximum );
296 0 : aStr = aStrBuffer.makeStringAndClear();
297 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_RANGE_Y_MAXIMUM, aStr );
298 0 : }
299 : }
300 0 : break;
301 : default:
302 0 : break;
303 : }
304 : }
305 0 : if ( bPosition )
306 0 : SvXMLElementExport aOBJ( rExport, XML_NAMESPACE_DRAW, XML_HANDLE, sal_True, sal_True );
307 : else
308 0 : rExport.ClearAttrList();
309 0 : }
310 : }
311 0 : }
312 :
313 0 : void ImpExportEnhancedPath( SvXMLExport& rExport,
314 : const uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair >& rCoordinates,
315 : const uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeSegment >& rSegments,
316 : bool bExtended = false )
317 : {
318 :
319 0 : OUString aStr;
320 0 : OUStringBuffer aStrBuffer;
321 0 : bool bNeedExtended = false;
322 :
323 : sal_Int32 i, j, k, l;
324 :
325 0 : sal_Int32 nCoords = rCoordinates.getLength();
326 0 : sal_Int32 nSegments = rSegments.getLength();
327 0 : sal_Bool bSimpleSegments = nSegments == 0;
328 0 : if ( bSimpleSegments )
329 0 : nSegments = 4;
330 0 : for ( j = i = 0; j < nSegments; j++ )
331 : {
332 0 : com::sun::star::drawing::EnhancedCustomShapeSegment aSegment;
333 0 : if ( bSimpleSegments )
334 : {
335 : // if there are not enough segments we will default them
336 0 : switch( j )
337 : {
338 : case 0 :
339 : {
340 0 : aSegment.Count = 1;
341 0 : aSegment.Command = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::MOVETO;
342 : }
343 0 : break;
344 : case 1 :
345 : {
346 0 : aSegment.Count = (sal_Int16)std::min( nCoords - 1, (sal_Int32)32767 );
347 0 : aSegment.Command = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::LINETO;
348 : }
349 0 : break;
350 : case 2 :
351 : {
352 0 : aSegment.Count = 1;
353 0 : aSegment.Command = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::CLOSESUBPATH;
354 : }
355 0 : break;
356 : case 3 :
357 : {
358 0 : aSegment.Count = 1;
359 0 : aSegment.Command = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ENDSUBPATH;
360 : }
361 0 : break;
362 : }
363 : }
364 : else
365 0 : aSegment = rSegments[ j ];
366 :
367 0 : if ( !aStrBuffer.isEmpty() )
368 0 : aStrBuffer.append( (sal_Unicode)' ' );
369 :
370 0 : sal_Int32 nParameter = 0;
371 0 : switch( aSegment.Command )
372 : {
373 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::CLOSESUBPATH :
374 0 : aStrBuffer.append( (sal_Unicode)'Z' ); break;
375 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ENDSUBPATH :
376 0 : aStrBuffer.append( (sal_Unicode)'N' ); break;
377 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::NOFILL :
378 0 : aStrBuffer.append( (sal_Unicode)'F' ); break;
379 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::NOSTROKE :
380 0 : aStrBuffer.append( (sal_Unicode)'S' ); break;
381 :
382 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::MOVETO :
383 0 : aStrBuffer.append( (sal_Unicode)'M' ); nParameter = 1; break;
384 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::LINETO :
385 0 : aStrBuffer.append( (sal_Unicode)'L' ); nParameter = 1; break;
386 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::CURVETO :
387 0 : aStrBuffer.append( (sal_Unicode)'C' ); nParameter = 3; break;
388 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ANGLEELLIPSETO :
389 0 : aStrBuffer.append( (sal_Unicode)'T' ); nParameter = 3; break;
390 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ANGLEELLIPSE :
391 0 : aStrBuffer.append( (sal_Unicode)'U' ); nParameter = 3; break;
392 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ARCTO :
393 0 : aStrBuffer.append( (sal_Unicode)'A' ); nParameter = 4; break;
394 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ARC :
395 0 : aStrBuffer.append( (sal_Unicode)'B' ); nParameter = 4; break;
396 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::CLOCKWISEARCTO :
397 0 : aStrBuffer.append( (sal_Unicode)'W' ); nParameter = 4; break;
398 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::CLOCKWISEARC :
399 0 : aStrBuffer.append( (sal_Unicode)'V' ); nParameter = 4; break;
400 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTX :
401 0 : aStrBuffer.append( (sal_Unicode)'X' ); nParameter = 1; break;
402 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTY :
403 0 : aStrBuffer.append( (sal_Unicode)'Y' ); nParameter = 1; break;
404 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::QUADRATICCURVETO :
405 0 : aStrBuffer.append( (sal_Unicode)'Q' ); nParameter = 2; break;
406 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ARCANGLETO :
407 0 : if ( bExtended ) {
408 0 : aStrBuffer.append( (sal_Unicode)'G' );
409 0 : nParameter = 2;
410 : } else {
411 0 : aStrBuffer.setLength( aStrBuffer.getLength() - 1);
412 0 : bNeedExtended = true;
413 0 : i += 2;
414 : }
415 0 : break;
416 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::DARKEN :
417 0 : if ( bExtended )
418 0 : aStrBuffer.append( (sal_Unicode)'H' );
419 : else
420 0 : bNeedExtended = true;
421 0 : break;
422 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::DARKENLESS :
423 0 : if ( bExtended )
424 0 : aStrBuffer.append( (sal_Unicode)'I' );
425 : else
426 0 : bNeedExtended = true;
427 0 : break;
428 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::LIGHTEN :
429 0 : if ( bExtended )
430 0 : aStrBuffer.append( (sal_Unicode)'J' );
431 : else
432 0 : bNeedExtended = true;
433 0 : break;
434 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::LIGHTENLESS :
435 0 : if ( bExtended )
436 0 : aStrBuffer.append( (sal_Unicode)'K' );
437 : else
438 0 : bNeedExtended = true;
439 0 : break;
440 : default : // ups, seems to be something wrong
441 : {
442 0 : aSegment.Count = 1;
443 0 : aSegment.Command = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::LINETO;
444 : }
445 0 : break;
446 : }
447 0 : if ( nParameter )
448 : {
449 0 : for ( k = 0; k < aSegment.Count; k++ )
450 : {
451 0 : if ( ( i + nParameter ) <= nCoords )
452 : {
453 0 : for ( l = 0; l < nParameter; l++ )
454 : {
455 0 : ExportParameter( aStrBuffer, rCoordinates[ i ].First );
456 0 : ExportParameter( aStrBuffer, rCoordinates[ i++ ].Second );
457 : }
458 : }
459 : else
460 : {
461 0 : j = nSegments; // error -> exiting
462 0 : break;
463 : }
464 : }
465 : }
466 : }
467 0 : aStr = aStrBuffer.makeStringAndClear();
468 0 : rExport.AddAttribute( bExtended ? XML_NAMESPACE_DRAW_EXT : XML_NAMESPACE_DRAW, XML_ENHANCED_PATH, aStr );
469 0 : if ( !bExtended && bNeedExtended )
470 0 : ImpExportEnhancedPath( rExport, rCoordinates, rSegments, true );
471 0 : }
472 :
473 0 : void ImpExportEnhancedGeometry( SvXMLExport& rExport, const uno::Reference< beans::XPropertySet >& xPropSet )
474 : {
475 0 : sal_Bool bEquations = sal_False;
476 0 : uno::Sequence< OUString > aEquations;
477 :
478 0 : sal_Bool bHandles = sal_False;
479 0 : uno::Sequence< beans::PropertyValues > aHandles;
480 :
481 0 : sal_Bool bCoordinates = sal_False;
482 0 : uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeSegment > aSegments;
483 0 : uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair > aCoordinates;
484 :
485 0 : uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue > aAdjustmentValues;
486 :
487 0 : OUString aStr;
488 0 : OUStringBuffer aStrBuffer;
489 0 : SvXMLUnitConverter& rUnitConverter = rExport.GetMM100UnitConverter();
490 :
491 0 : uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
492 :
493 : // geometry
494 0 : const OUString sCustomShapeGeometry( "CustomShapeGeometry" );
495 0 : if ( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName( sCustomShapeGeometry ) )
496 : {
497 0 : uno::Any aGeoPropSet( xPropSet->getPropertyValue( sCustomShapeGeometry ) );
498 0 : uno::Sequence< beans::PropertyValue > aGeoPropSeq;
499 :
500 0 : if ( aGeoPropSet >>= aGeoPropSeq )
501 : {
502 0 : const OUString sCustomShapeType( "non-primitive" );
503 0 : OUString aCustomShapeType( sCustomShapeType );
504 :
505 0 : sal_Int32 j, nGeoPropCount = aGeoPropSeq.getLength();
506 0 : for ( j = 0; j < nGeoPropCount; j++ )
507 : {
508 0 : const beans::PropertyValue& rGeoProp = aGeoPropSeq[ j ];
509 0 : switch( EASGet( rGeoProp.Name ) )
510 : {
511 : case EAS_Type :
512 : {
513 0 : rGeoProp.Value >>= aCustomShapeType;
514 : }
515 0 : break;
516 : case EAS_MirroredX :
517 : {
518 0 : sal_Bool bMirroredX = sal_Bool();
519 0 : if ( rGeoProp.Value >>= bMirroredX )
520 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_MIRROR_HORIZONTAL,
521 0 : bMirroredX ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) );
522 : }
523 0 : break;
524 : case EAS_MirroredY :
525 : {
526 0 : sal_Bool bMirroredY = sal_Bool();
527 0 : if ( rGeoProp.Value >>= bMirroredY )
528 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_MIRROR_VERTICAL,
529 0 : bMirroredY ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) );
530 : }
531 0 : break;
532 : case EAS_ViewBox :
533 : {
534 0 : awt::Rectangle aRect;
535 0 : if ( rGeoProp.Value >>= aRect )
536 : {
537 0 : SdXMLImExViewBox aViewBox( aRect.X, aRect.Y, aRect.Width, aRect.Height );
538 0 : rExport.AddAttribute( XML_NAMESPACE_SVG, XML_VIEWBOX, aViewBox.GetExportString() );
539 : }
540 : }
541 0 : break;
542 : case EAS_TextRotateAngle :
543 : {
544 0 : double fTextRotateAngle = 0;
545 0 : if ( rGeoProp.Value >>= fTextRotateAngle )
546 : {
547 : ::sax::Converter::convertDouble(
548 0 : aStrBuffer, fTextRotateAngle );
549 0 : aStr = aStrBuffer.makeStringAndClear();
550 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_TEXT_ROTATE_ANGLE, aStr );
551 : }
552 : }
553 0 : break;
554 : case EAS_Extrusion :
555 : {
556 0 : uno::Sequence< beans::PropertyValue > aExtrusionPropSeq;
557 0 : if ( rGeoProp.Value >>= aExtrusionPropSeq )
558 : {
559 0 : sal_Int32 i, nCount = aExtrusionPropSeq.getLength();
560 0 : for ( i = 0; i < nCount; i++ )
561 : {
562 0 : const beans::PropertyValue& rProp = aExtrusionPropSeq[ i ];
563 0 : switch( EASGet( rProp.Name ) )
564 : {
565 : case EAS_Extrusion :
566 : {
567 0 : sal_Bool bExtrusionOn = sal_Bool();
568 0 : if ( rProp.Value >>= bExtrusionOn )
569 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION,
570 0 : bExtrusionOn ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) );
571 : }
572 0 : break;
573 : case EAS_Brightness :
574 : {
575 0 : double fExtrusionBrightness = 0;
576 0 : if ( rProp.Value >>= fExtrusionBrightness )
577 : {
578 : ::sax::Converter::convertDouble(
579 : aStrBuffer,
580 : fExtrusionBrightness,
581 : false,
582 : util::MeasureUnit::PERCENT,
583 0 : util::MeasureUnit::PERCENT);
584 0 : aStrBuffer.append( (sal_Unicode)'%' );
585 0 : aStr = aStrBuffer.makeStringAndClear();
586 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_BRIGHTNESS, aStr );
587 : }
588 : }
589 0 : break;
590 : case EAS_Depth :
591 : {
592 0 : com::sun::star::drawing::EnhancedCustomShapeParameterPair aDepthParaPair;
593 0 : if ( rProp.Value >>= aDepthParaPair )
594 : {
595 0 : double fDepth = 0;
596 0 : if ( aDepthParaPair.First.Value >>= fDepth )
597 : {
598 0 : rExport.GetMM100UnitConverter().convertDouble( aStrBuffer, fDepth, sal_True );
599 0 : ExportParameter( aStrBuffer, aDepthParaPair.Second );
600 0 : aStr = aStrBuffer.makeStringAndClear();
601 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_DEPTH, aStr );
602 : }
603 0 : }
604 : }
605 0 : break;
606 : case EAS_Diffusion :
607 : {
608 0 : double fExtrusionDiffusion = 0;
609 0 : if ( rProp.Value >>= fExtrusionDiffusion )
610 : {
611 : ::sax::Converter::convertDouble(
612 : aStrBuffer,
613 : fExtrusionDiffusion,
614 : false,
615 : util::MeasureUnit::PERCENT,
616 0 : util::MeasureUnit::PERCENT);
617 0 : aStrBuffer.append( (sal_Unicode)'%' );
618 0 : aStr = aStrBuffer.makeStringAndClear();
619 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_DIFFUSION, aStr );
620 : }
621 : }
622 0 : break;
623 : case EAS_NumberOfLineSegments :
624 : {
625 0 : sal_Int32 nExtrusionNumberOfLineSegments = 0;
626 0 : if ( rProp.Value >>= nExtrusionNumberOfLineSegments )
627 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_NUMBER_OF_LINE_SEGMENTS, OUString::valueOf( nExtrusionNumberOfLineSegments ) );
628 : }
629 0 : break;
630 : case EAS_LightFace :
631 : {
632 0 : sal_Bool bExtrusionLightFace = sal_Bool();
633 0 : if ( rProp.Value >>= bExtrusionLightFace )
634 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_LIGHT_FACE,
635 0 : bExtrusionLightFace ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) );
636 : }
637 0 : break;
638 : case EAS_FirstLightHarsh :
639 : {
640 0 : sal_Bool bExtrusionFirstLightHarsh = sal_Bool();
641 0 : if ( rProp.Value >>= bExtrusionFirstLightHarsh )
642 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_FIRST_LIGHT_HARSH,
643 0 : bExtrusionFirstLightHarsh ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) );
644 : }
645 0 : break;
646 : case EAS_SecondLightHarsh :
647 : {
648 0 : sal_Bool bExtrusionSecondLightHarsh = sal_Bool();
649 0 : if ( rProp.Value >>= bExtrusionSecondLightHarsh )
650 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_SECOND_LIGHT_HARSH,
651 0 : bExtrusionSecondLightHarsh ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) );
652 : }
653 0 : break;
654 : case EAS_FirstLightLevel :
655 : {
656 0 : double fExtrusionFirstLightLevel = 0;
657 0 : if ( rProp.Value >>= fExtrusionFirstLightLevel )
658 : {
659 : ::sax::Converter::convertDouble(
660 : aStrBuffer,
661 : fExtrusionFirstLightLevel,
662 : false,
663 : util::MeasureUnit::PERCENT,
664 0 : util::MeasureUnit::PERCENT);
665 0 : aStrBuffer.append( (sal_Unicode)'%' );
666 0 : aStr = aStrBuffer.makeStringAndClear();
667 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_FIRST_LIGHT_LEVEL, aStr );
668 : }
669 : }
670 0 : break;
671 : case EAS_SecondLightLevel :
672 : {
673 0 : double fExtrusionSecondLightLevel = 0;
674 0 : if ( rProp.Value >>= fExtrusionSecondLightLevel )
675 : {
676 : ::sax::Converter::convertDouble(
677 : aStrBuffer,
678 : fExtrusionSecondLightLevel,
679 : false,
680 : util::MeasureUnit::PERCENT,
681 0 : util::MeasureUnit::PERCENT);
682 0 : aStrBuffer.append( (sal_Unicode)'%' );
683 0 : aStr = aStrBuffer.makeStringAndClear();
684 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_SECOND_LIGHT_LEVEL, aStr );
685 : }
686 : }
687 0 : break;
688 : case EAS_FirstLightDirection :
689 : {
690 0 : drawing::Direction3D aExtrusionFirstLightDirection;
691 0 : if ( rProp.Value >>= aExtrusionFirstLightDirection )
692 : {
693 : ::basegfx::B3DVector aVec3D( aExtrusionFirstLightDirection.DirectionX, aExtrusionFirstLightDirection.DirectionY,
694 0 : aExtrusionFirstLightDirection.DirectionZ );
695 0 : rUnitConverter.convertB3DVector( aStrBuffer, aVec3D );
696 0 : aStr = aStrBuffer.makeStringAndClear();
697 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_FIRST_LIGHT_DIRECTION, aStr );
698 : }
699 : }
700 0 : break;
701 : case EAS_SecondLightDirection :
702 : {
703 0 : drawing::Direction3D aExtrusionSecondLightDirection;
704 0 : if ( rProp.Value >>= aExtrusionSecondLightDirection )
705 : {
706 : ::basegfx::B3DVector aVec3D( aExtrusionSecondLightDirection.DirectionX, aExtrusionSecondLightDirection.DirectionY,
707 0 : aExtrusionSecondLightDirection.DirectionZ );
708 0 : rUnitConverter.convertB3DVector( aStrBuffer, aVec3D );
709 0 : aStr = aStrBuffer.makeStringAndClear();
710 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_SECOND_LIGHT_DIRECTION, aStr );
711 : }
712 : }
713 0 : break;
714 : case EAS_Metal :
715 : {
716 0 : sal_Bool bExtrusionMetal = sal_Bool();
717 0 : if ( rProp.Value >>= bExtrusionMetal )
718 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_METAL,
719 0 : bExtrusionMetal ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) );
720 : }
721 0 : break;
722 : case EAS_ShadeMode :
723 : {
724 : // shadeMode
725 : drawing::ShadeMode eShadeMode;
726 0 : if( rProp.Value >>= eShadeMode )
727 : {
728 0 : if( eShadeMode == drawing::ShadeMode_FLAT )
729 0 : aStr = GetXMLToken( XML_FLAT );
730 0 : else if( eShadeMode == drawing::ShadeMode_PHONG )
731 0 : aStr = GetXMLToken( XML_PHONG );
732 0 : else if( eShadeMode == drawing::ShadeMode_SMOOTH )
733 0 : aStr = GetXMLToken( XML_GOURAUD );
734 : else
735 0 : aStr = GetXMLToken( XML_DRAFT );
736 : }
737 : else
738 : {
739 : // ShadeMode enum not there, write default
740 0 : aStr = GetXMLToken( XML_FLAT);
741 : }
742 0 : rExport.AddAttribute( XML_NAMESPACE_DR3D, XML_SHADE_MODE, aStr );
743 : }
744 0 : break;
745 : case EAS_RotateAngle :
746 : {
747 0 : com::sun::star::drawing::EnhancedCustomShapeParameterPair aRotateAngleParaPair;
748 0 : if ( rProp.Value >>= aRotateAngleParaPair )
749 : {
750 0 : ExportParameter( aStrBuffer, aRotateAngleParaPair.First );
751 0 : ExportParameter( aStrBuffer, aRotateAngleParaPair.Second );
752 0 : aStr = aStrBuffer.makeStringAndClear();
753 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_ROTATION_ANGLE, aStr );
754 0 : }
755 : }
756 0 : break;
757 : case EAS_RotationCenter :
758 : {
759 0 : drawing::Direction3D aExtrusionRotationCenter;
760 0 : if ( rProp.Value >>= aExtrusionRotationCenter )
761 : {
762 : ::basegfx::B3DVector aVec3D( aExtrusionRotationCenter.DirectionX, aExtrusionRotationCenter.DirectionY,
763 0 : aExtrusionRotationCenter.DirectionZ );
764 0 : rUnitConverter.convertB3DVector( aStrBuffer, aVec3D );
765 0 : aStr = aStrBuffer.makeStringAndClear();
766 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_ROTATION_CENTER, aStr );
767 : }
768 : }
769 0 : break;
770 : case EAS_Shininess :
771 : {
772 0 : double fExtrusionShininess = 0;
773 0 : if ( rProp.Value >>= fExtrusionShininess )
774 : {
775 : ::sax::Converter::convertDouble(
776 : aStrBuffer,
777 : fExtrusionShininess,
778 : false,
779 : util::MeasureUnit::PERCENT,
780 0 : util::MeasureUnit::PERCENT);
781 0 : aStrBuffer.append( (sal_Unicode)'%' );
782 0 : aStr = aStrBuffer.makeStringAndClear();
783 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_SHININESS, aStr );
784 : }
785 : }
786 0 : break;
787 : case EAS_Skew :
788 : {
789 0 : com::sun::star::drawing::EnhancedCustomShapeParameterPair aSkewParaPair;
790 0 : if ( rProp.Value >>= aSkewParaPair )
791 : {
792 0 : ExportParameter( aStrBuffer, aSkewParaPair.First );
793 0 : ExportParameter( aStrBuffer, aSkewParaPair.Second );
794 0 : aStr = aStrBuffer.makeStringAndClear();
795 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_SKEW, aStr );
796 0 : }
797 : }
798 0 : break;
799 : case EAS_Specularity :
800 : {
801 0 : double fExtrusionSpecularity = 0;
802 0 : if ( rProp.Value >>= fExtrusionSpecularity )
803 : {
804 : ::sax::Converter::convertDouble(
805 : aStrBuffer,
806 : fExtrusionSpecularity,
807 : false,
808 : util::MeasureUnit::PERCENT,
809 0 : util::MeasureUnit::PERCENT);
810 0 : aStrBuffer.append( (sal_Unicode)'%' );
811 0 : aStr = aStrBuffer.makeStringAndClear();
812 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_SPECULARITY, aStr );
813 : }
814 : }
815 0 : break;
816 : case EAS_ProjectionMode :
817 : {
818 : drawing::ProjectionMode eProjectionMode;
819 0 : if ( rProp.Value >>= eProjectionMode )
820 : rExport.AddAttribute( XML_NAMESPACE_DR3D, XML_PROJECTION,
821 0 : eProjectionMode == drawing::ProjectionMode_PARALLEL ? GetXMLToken( XML_PARALLEL ) : GetXMLToken( XML_PERSPECTIVE ) );
822 : }
823 0 : break;
824 : case EAS_ViewPoint :
825 : {
826 0 : drawing::Position3D aExtrusionViewPoint;
827 0 : if ( rProp.Value >>= aExtrusionViewPoint )
828 : {
829 0 : rUnitConverter.convertPosition3D( aStrBuffer, aExtrusionViewPoint );
830 0 : aStr = aStrBuffer.makeStringAndClear();
831 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_VIEWPOINT, aStr );
832 : }
833 : }
834 0 : break;
835 : case EAS_Origin :
836 : {
837 0 : com::sun::star::drawing::EnhancedCustomShapeParameterPair aOriginParaPair;
838 0 : if ( rProp.Value >>= aOriginParaPair )
839 : {
840 0 : ExportParameter( aStrBuffer, aOriginParaPair.First );
841 0 : ExportParameter( aStrBuffer, aOriginParaPair.Second );
842 0 : aStr = aStrBuffer.makeStringAndClear();
843 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_ORIGIN, aStr );
844 0 : }
845 : }
846 0 : break;
847 : case EAS_Color :
848 : {
849 0 : sal_Bool bExtrusionColor = sal_Bool();
850 0 : if ( rProp.Value >>= bExtrusionColor )
851 : {
852 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_COLOR,
853 0 : bExtrusionColor ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) );
854 : }
855 : }
856 0 : break;
857 : default:
858 0 : break;
859 : }
860 : }
861 0 : }
862 : }
863 0 : break;
864 : case EAS_TextPath :
865 : {
866 0 : uno::Sequence< beans::PropertyValue > aTextPathPropSeq;
867 0 : if ( rGeoProp.Value >>= aTextPathPropSeq )
868 : {
869 0 : sal_Int32 i, nCount = aTextPathPropSeq.getLength();
870 0 : for ( i = 0; i < nCount; i++ )
871 : {
872 0 : const beans::PropertyValue& rProp = aTextPathPropSeq[ i ];
873 0 : switch( EASGet( rProp.Name ) )
874 : {
875 : case EAS_TextPath :
876 : {
877 0 : sal_Bool bTextPathOn = sal_Bool();
878 0 : if ( rProp.Value >>= bTextPathOn )
879 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_TEXT_PATH,
880 0 : bTextPathOn ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) );
881 : }
882 0 : break;
883 : case EAS_TextPathMode :
884 : {
885 : com::sun::star::drawing::EnhancedCustomShapeTextPathMode eTextPathMode;
886 0 : if ( rProp.Value >>= eTextPathMode )
887 : {
888 0 : switch ( eTextPathMode )
889 : {
890 0 : case com::sun::star::drawing::EnhancedCustomShapeTextPathMode_NORMAL: aStr = GetXMLToken( XML_NORMAL ); break;
891 0 : case com::sun::star::drawing::EnhancedCustomShapeTextPathMode_PATH : aStr = GetXMLToken( XML_PATH ); break;
892 0 : case com::sun::star::drawing::EnhancedCustomShapeTextPathMode_SHAPE : aStr = GetXMLToken( XML_SHAPE ); break;
893 : default:
894 0 : break;
895 : }
896 0 : if ( !aStr.isEmpty() )
897 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_TEXT_PATH_MODE, aStr );
898 : }
899 : }
900 0 : break;
901 : case EAS_ScaleX :
902 : {
903 0 : sal_Bool bScaleX = sal_Bool();
904 0 : if ( rProp.Value >>= bScaleX )
905 : {
906 0 : aStr = bScaleX ? GetXMLToken( XML_SHAPE ) : GetXMLToken( XML_PATH );
907 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_TEXT_PATH_SCALE, aStr );
908 : }
909 : }
910 0 : break;
911 : case EAS_SameLetterHeights :
912 : {
913 0 : sal_Bool bSameLetterHeights = sal_Bool();
914 0 : if ( rProp.Value >>= bSameLetterHeights )
915 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_TEXT_PATH_SAME_LETTER_HEIGHTS,
916 0 : bSameLetterHeights ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) );
917 : }
918 0 : break;
919 : default:
920 0 : break;
921 : }
922 : }
923 0 : }
924 : }
925 0 : break;
926 : case EAS_Path :
927 : {
928 0 : uno::Sequence< beans::PropertyValue > aPathPropSeq;
929 0 : if ( rGeoProp.Value >>= aPathPropSeq )
930 : {
931 0 : sal_Int32 i, nCount = aPathPropSeq.getLength();
932 0 : for ( i = 0; i < nCount; i++ )
933 : {
934 0 : const beans::PropertyValue& rProp = aPathPropSeq[ i ];
935 :
936 0 : switch( EASGet( rProp.Name ) )
937 : {
938 : case EAS_SubViewSize:
939 : {
940 0 : uno::Sequence< awt::Size > aSubViewSizes;
941 0 : rProp.Value >>= aSubViewSizes;
942 :
943 0 : for ( int nIdx = 0; nIdx < aSubViewSizes.getLength(); nIdx++ )
944 : {
945 0 : if ( nIdx )
946 0 : aStrBuffer.append(' ');
947 0 : ::sax::Converter::convertNumber( aStrBuffer, aSubViewSizes[nIdx].Width );
948 0 : aStrBuffer.append(' ');
949 0 : ::sax::Converter::convertNumber( aStrBuffer, aSubViewSizes[nIdx].Height );
950 : }
951 0 : aStr = aStrBuffer.makeStringAndClear();
952 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW_EXT, XML_SUB_VIEW_SIZE, aStr );
953 : }
954 0 : break;
955 : case EAS_ExtrusionAllowed :
956 : {
957 0 : sal_Bool bExtrusionAllowed = sal_Bool();
958 0 : if ( rProp.Value >>= bExtrusionAllowed )
959 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_ALLOWED,
960 0 : bExtrusionAllowed ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) );
961 : }
962 0 : break;
963 : case EAS_ConcentricGradientFillAllowed :
964 : {
965 0 : sal_Bool bConcentricGradientFillAllowed = sal_Bool();
966 0 : if ( rProp.Value >>= bConcentricGradientFillAllowed )
967 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_CONCENTRIC_GRADIENT_FILL_ALLOWED,
968 0 : bConcentricGradientFillAllowed ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) );
969 : }
970 0 : break;
971 : case EAS_TextPathAllowed :
972 : {
973 0 : sal_Bool bTextPathAllowed = sal_Bool();
974 0 : if ( rProp.Value >>= bTextPathAllowed )
975 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_TEXT_PATH_ALLOWED,
976 0 : bTextPathAllowed ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) );
977 : }
978 0 : break;
979 : case EAS_GluePoints :
980 : {
981 0 : com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair> aGluePoints;
982 0 : if ( rProp.Value >>= aGluePoints )
983 : {
984 0 : sal_Int32 k, nElements = aGluePoints.getLength();
985 0 : if ( nElements )
986 : {
987 0 : for( k = 0; k < nElements; k++ )
988 : {
989 0 : ExportParameter( aStrBuffer, aGluePoints[ k ].First );
990 0 : ExportParameter( aStrBuffer, aGluePoints[ k ].Second );
991 : }
992 0 : aStr = aStrBuffer.makeStringAndClear();
993 : }
994 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_GLUE_POINTS, aStr );
995 0 : }
996 : }
997 0 : break;
998 : case EAS_GluePointType :
999 : {
1000 0 : sal_Int16 nGluePointType = sal_Int16();
1001 0 : if ( rProp.Value >>= nGluePointType )
1002 : {
1003 0 : switch ( nGluePointType )
1004 : {
1005 0 : case com::sun::star::drawing::EnhancedCustomShapeGluePointType::NONE : aStr = GetXMLToken( XML_NONE ); break;
1006 0 : case com::sun::star::drawing::EnhancedCustomShapeGluePointType::SEGMENTS : aStr = GetXMLToken( XML_SEGMENTS ); break;
1007 0 : case com::sun::star::drawing::EnhancedCustomShapeGluePointType::RECT : aStr = GetXMLToken( XML_RECTANGLE ); break;
1008 : }
1009 0 : if ( !aStr.isEmpty() )
1010 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_GLUE_POINT_TYPE, aStr );
1011 : }
1012 : }
1013 0 : break;
1014 : case EAS_Coordinates :
1015 : {
1016 0 : bCoordinates = ( rProp.Value >>= aCoordinates );
1017 : }
1018 0 : break;
1019 : case EAS_Segments :
1020 : {
1021 0 : rProp.Value >>= aSegments;
1022 : }
1023 0 : break;
1024 : case EAS_StretchX :
1025 : {
1026 0 : sal_Int32 nStretchPoint = 0;
1027 0 : if ( rProp.Value >>= nStretchPoint )
1028 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_PATH_STRETCHPOINT_X, OUString::valueOf( nStretchPoint ) );
1029 : }
1030 0 : break;
1031 : case EAS_StretchY :
1032 : {
1033 0 : sal_Int32 nStretchPoint = 0;
1034 0 : if ( rProp.Value >>= nStretchPoint )
1035 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_PATH_STRETCHPOINT_Y, OUString::valueOf( nStretchPoint ) );
1036 : }
1037 0 : break;
1038 : case EAS_TextFrames :
1039 : {
1040 0 : com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeTextFrame > aPathTextFrames;
1041 0 : if ( rProp.Value >>= aPathTextFrames )
1042 : {
1043 0 : if ( (sal_uInt16)aPathTextFrames.getLength() )
1044 : {
1045 0 : sal_uInt16 k, nElements = (sal_uInt16)aPathTextFrames.getLength();
1046 0 : for ( k = 0; k < nElements; k++ )
1047 : {
1048 0 : ExportParameter( aStrBuffer, aPathTextFrames[ k ].TopLeft.First );
1049 0 : ExportParameter( aStrBuffer, aPathTextFrames[ k ].TopLeft.Second );
1050 0 : ExportParameter( aStrBuffer, aPathTextFrames[ k ].BottomRight.First );
1051 0 : ExportParameter( aStrBuffer, aPathTextFrames[ k ].BottomRight.Second );
1052 : }
1053 0 : aStr = aStrBuffer.makeStringAndClear();
1054 : }
1055 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_TEXT_AREAS, aStr );
1056 0 : }
1057 : }
1058 0 : break;
1059 : default:
1060 0 : break;
1061 : }
1062 : }
1063 0 : }
1064 : }
1065 0 : break;
1066 : case EAS_Equations :
1067 : {
1068 0 : bEquations = ( rGeoProp.Value >>= aEquations );
1069 : }
1070 0 : break;
1071 : case EAS_Handles :
1072 : {
1073 0 : bHandles = ( rGeoProp.Value >>= aHandles );
1074 : }
1075 0 : break;
1076 : case EAS_AdjustmentValues :
1077 : {
1078 0 : rGeoProp.Value >>= aAdjustmentValues;
1079 : }
1080 0 : break;
1081 : default:
1082 0 : break;
1083 : }
1084 : } // for
1085 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_TYPE, aCustomShapeType );
1086 :
1087 : // adjustments
1088 0 : sal_Int32 nAdjustmentValues = aAdjustmentValues.getLength();
1089 0 : if ( nAdjustmentValues )
1090 : {
1091 0 : sal_Int32 i, nValue = 0;
1092 0 : for ( i = 0; i < nAdjustmentValues; i++ )
1093 : {
1094 0 : if ( i )
1095 0 : aStrBuffer.append( (sal_Unicode)' ' );
1096 :
1097 0 : const com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue& rAdj = aAdjustmentValues[ i ];
1098 0 : if ( rAdj.State == beans::PropertyState_DIRECT_VALUE )
1099 : {
1100 0 : if ( rAdj.Value.getValueTypeClass() == uno::TypeClass_DOUBLE )
1101 : {
1102 0 : double fValue = 0.0;
1103 0 : rAdj.Value >>= fValue;
1104 0 : ::sax::Converter::convertDouble(aStrBuffer, fValue);
1105 : }
1106 : else
1107 : {
1108 0 : rAdj.Value >>= nValue;
1109 0 : ::sax::Converter::convertNumber(aStrBuffer, nValue);
1110 : }
1111 : }
1112 : else
1113 : {
1114 : // this should not be, but better than setting nothing
1115 0 : ::sax::Converter::convertNumber( aStrBuffer, 0 );
1116 : }
1117 : }
1118 0 : aStr = aStrBuffer.makeStringAndClear();
1119 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_MODIFIERS, aStr );
1120 : }
1121 0 : if ( bCoordinates )
1122 0 : ImpExportEnhancedPath( rExport, aCoordinates, aSegments );
1123 0 : }
1124 : }
1125 0 : SvXMLElementExport aOBJ( rExport, XML_NAMESPACE_DRAW, XML_ENHANCED_GEOMETRY, sal_True, sal_True );
1126 0 : if ( bEquations )
1127 0 : ImpExportEquations( rExport, aEquations );
1128 0 : if ( bHandles )
1129 0 : ImpExportHandles( rExport, aHandles );
1130 0 : }
1131 :
1132 0 : void XMLShapeExport::ImpExportCustomShape(
1133 : const uno::Reference< drawing::XShape >& xShape,
1134 : XmlShapeType, sal_Int32 nFeatures, com::sun::star::awt::Point* pRefPoint )
1135 : {
1136 0 : const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
1137 0 : if ( xPropSet.is() )
1138 : {
1139 0 : OUString aStr;
1140 0 : uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
1141 :
1142 : // Transformation
1143 0 : ImpExportNewTrans( xPropSet, nFeatures, pRefPoint );
1144 :
1145 0 : if ( xPropSetInfo.is() )
1146 : {
1147 0 : const OUString sCustomShapeEngine( "CustomShapeEngine" );
1148 0 : if ( xPropSetInfo->hasPropertyByName( sCustomShapeEngine ) )
1149 : {
1150 0 : uno::Any aEngine( xPropSet->getPropertyValue( sCustomShapeEngine ) );
1151 0 : if ( ( aEngine >>= aStr ) && !aStr.isEmpty() )
1152 0 : mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_ENGINE, aStr );
1153 : }
1154 0 : const OUString sCustomShapeData( "CustomShapeData" );
1155 0 : if ( xPropSetInfo->hasPropertyByName( sCustomShapeData ) )
1156 : {
1157 0 : uno::Any aData( xPropSet->getPropertyValue( sCustomShapeData ) );
1158 0 : if ( ( aData >>= aStr ) && !aStr.isEmpty() )
1159 0 : mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_DATA, aStr );
1160 0 : }
1161 : }
1162 0 : sal_Bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
1163 0 : SvXMLElementExport aOBJ( mrExport, XML_NAMESPACE_DRAW, XML_CUSTOM_SHAPE, bCreateNewline, sal_True );
1164 0 : ImpExportDescription( xShape ); // #i68101#
1165 0 : ImpExportEvents( xShape );
1166 0 : ImpExportGluePoints( xShape );
1167 0 : ImpExportText( xShape );
1168 0 : ImpExportEnhancedGeometry( mrExport, xPropSet );
1169 0 : }
1170 0 : }
1171 :
1172 0 : void XMLShapeExport::ImpExportTableShape( const uno::Reference< drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures, com::sun::star::awt::Point* pRefPoint )
1173 : {
1174 0 : uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
1175 0 : uno::Reference< container::XNamed > xNamed(xShape, uno::UNO_QUERY);
1176 :
1177 : DBG_ASSERT( xPropSet.is() && xNamed.is(), "xmloff::XMLShapeExport::ImpExportTableShape(), tabe shape is not implementing needed interfaces");
1178 0 : if(xPropSet.is() && xNamed.is()) try
1179 : {
1180 : // Transformation
1181 0 : ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
1182 :
1183 0 : sal_Bool bIsEmptyPresObj = sal_False;
1184 :
1185 : // presentation settings
1186 0 : if(eShapeType == XmlShapeTypePresTableShape)
1187 0 : bIsEmptyPresObj = ImpExportPresentationAttributes( xPropSet, GetXMLToken(XML_PRESENTATION_TABLE) );
1188 :
1189 0 : const bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 );
1190 0 : const bool bExportEmbedded(0 != (mrExport.getExportFlags() & EXPORT_EMBEDDED));
1191 :
1192 0 : SvXMLElementExport aElement( mrExport, XML_NAMESPACE_DRAW, XML_FRAME, bCreateNewline, sal_True );
1193 :
1194 : // do not export in ODF 1.1 or older
1195 0 : if( mrExport.getDefaultVersion() >= SvtSaveOptions::ODFVER_012 )
1196 : {
1197 0 : if( !bIsEmptyPresObj )
1198 : {
1199 0 : uno::Reference< container::XNamed > xTemplate( xPropSet->getPropertyValue("TableTemplate"), uno::UNO_QUERY );
1200 0 : if( xTemplate.is() )
1201 : {
1202 0 : const OUString sTemplate( xTemplate->getName() );
1203 0 : if( !sTemplate.isEmpty() )
1204 : {
1205 0 : mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_TEMPLATE_NAME, sTemplate );
1206 :
1207 0 : for( const XMLPropertyMapEntry* pEntry = &aXMLTableShapeAttributes[0]; pEntry->msApiName; pEntry++ )
1208 : {
1209 : try
1210 : {
1211 0 : sal_Bool bBool = sal_False;
1212 0 : const OUString sAPIPropertyName( OUString(pEntry->msApiName, pEntry->nApiNameLength, RTL_TEXTENCODING_ASCII_US ) );
1213 :
1214 0 : xPropSet->getPropertyValue( sAPIPropertyName ) >>= bBool;
1215 0 : if( bBool )
1216 0 : mrExport.AddAttribute(pEntry->mnNameSpace, pEntry->meXMLName, XML_TRUE );
1217 : }
1218 0 : catch( uno::Exception& )
1219 : {
1220 : OSL_FAIL("XMLShapeExport::ImpExportTableShape(), exception caught!");
1221 : }
1222 : }
1223 0 : }
1224 : }
1225 :
1226 :
1227 0 : uno::Reference< table::XColumnRowRange > xRange( xPropSet->getPropertyValue( msModel ), uno::UNO_QUERY_THROW );
1228 0 : GetShapeTableExport()->exportTable( xRange );
1229 : }
1230 : }
1231 :
1232 0 : if( !bIsEmptyPresObj )
1233 : {
1234 0 : uno::Reference< graphic::XGraphic > xGraphic( xPropSet->getPropertyValue("ReplacementGraphic"), uno::UNO_QUERY );
1235 0 : if( xGraphic.is() ) try
1236 : {
1237 0 : Reference< uno::XComponentContext > xContext = GetExport().getComponentContext();
1238 :
1239 0 : uno::Reference< embed::XStorage > xPictureStorage;
1240 0 : uno::Reference< embed::XStorage > xStorage;
1241 0 : uno::Reference< io::XStream > xPictureStream;
1242 :
1243 0 : OUString sPictureName;
1244 0 : if( bExportEmbedded )
1245 : {
1246 0 : xPictureStream.set( xContext->getServiceManager()->createInstanceWithContext( "com.sun.star.comp.MemoryStream", xContext), UNO_QUERY_THROW );
1247 : }
1248 : else
1249 : {
1250 0 : xStorage.set( GetExport().GetTargetStorage(), UNO_QUERY_THROW );
1251 :
1252 0 : xPictureStorage.set( xStorage->openStorageElement( OUString( "Pictures" ), ::embed::ElementModes::READWRITE ), uno::UNO_QUERY_THROW );
1253 0 : const OUString sPrefix( "TablePreview" );
1254 0 : const OUString sSuffix( ".svm" );
1255 :
1256 0 : sal_Int32 nIndex = 0;
1257 0 : do
1258 : {
1259 0 : sPictureName = sPrefix;
1260 0 : sPictureName += OUString::valueOf( ++nIndex );
1261 0 : sPictureName += sSuffix;
1262 : }
1263 0 : while( xPictureStorage->hasByName( sPictureName ) );
1264 :
1265 0 : xPictureStream.set( xPictureStorage->openStreamElement( sPictureName, ::embed::ElementModes::READWRITE ), UNO_QUERY_THROW );
1266 : }
1267 :
1268 0 : Reference< graphic::XGraphicProvider > xProvider( graphic::GraphicProvider::create(xContext) );
1269 0 : Sequence< beans::PropertyValue > aArgs( 2 );
1270 0 : aArgs[ 0 ].Name = OUString( "MimeType" );
1271 0 : aArgs[ 0 ].Value <<= OUString( "image/x-vclgraphic" );
1272 0 : aArgs[ 1 ].Name = OUString( "OutputStream" );
1273 0 : aArgs[ 1 ].Value <<= xPictureStream->getOutputStream();
1274 0 : xProvider->storeGraphic( xGraphic, aArgs );
1275 :
1276 0 : if( xPictureStorage.is() )
1277 : {
1278 0 : Reference< embed::XTransactedObject > xTrans( xPictureStorage, UNO_QUERY );
1279 0 : if( xTrans.is() )
1280 0 : xTrans->commit();
1281 : }
1282 :
1283 0 : if( !bExportEmbedded )
1284 : {
1285 0 : OUString sURL( "Pictures/" );
1286 0 : sURL += sPictureName;
1287 0 : mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, sURL );
1288 0 : mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
1289 0 : mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
1290 0 : mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
1291 : }
1292 :
1293 0 : SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_DRAW, XML_IMAGE, sal_False, sal_True );
1294 :
1295 0 : if( bExportEmbedded )
1296 : {
1297 0 : Reference< XSeekableInputStream > xSeekable( xPictureStream, UNO_QUERY_THROW );
1298 0 : xSeekable->seek(0);
1299 :
1300 0 : XMLBase64Export aBase64Exp( GetExport() );
1301 0 : aBase64Exp.exportOfficeBinaryDataElement( Reference < XInputStream >( xPictureStream, UNO_QUERY_THROW ) );
1302 0 : }
1303 : }
1304 0 : catch( uno::Exception& )
1305 : {
1306 : OSL_FAIL("xmloff::XMLShapeExport::ImpExportTableShape(), exception caught!");
1307 0 : }
1308 : }
1309 :
1310 0 : ImpExportEvents( xShape );
1311 0 : ImpExportGluePoints( xShape );
1312 0 : ImpExportDescription( xShape ); // #i68101#
1313 : }
1314 0 : catch( uno::Exception& )
1315 : {
1316 : OSL_FAIL( "xmloff::XMLShapeExport::ImpExportTableShape(), exception caught!" );
1317 0 : }
1318 0 : }
1319 :
1320 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|