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