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