1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: shapeexport4.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
34 #include <com/sun/star/graphic/XGraphic.hpp>
35 #include <com/sun/star/graphic/XGraphicProvider.hpp>
36 #include <com/sun/star/embed/ElementModes.hpp>
37 #include <com/sun/star/embed/XTransactedObject.hpp>
38 #include <com/sun/star/io/XSeekableInputStream.hpp>
39 #include <com/sun/star/drawing/HomogenMatrix.hpp>
40 #include <com/sun/star/drawing/PolyPolygonShape3D.hpp>
41 #include <com/sun/star/drawing/ProjectionMode.hpp>
42 #include <com/sun/star/drawing/ShadeMode.hpp>
43 #include <com/sun/star/drawing/Direction3D.hpp>
44 #include <com/sun/star/drawing/Position3D.hpp>
45 #include <com/sun/star/drawing/CameraGeometry.hpp>
46 #include <com/sun/star/drawing/DoubleSequence.hpp>
48 #include <com/sun/star/table/XColumnRowRange.hpp>
50 #ifndef _XMLOFF_SHAPEEXPORT_HXX
51 #include <xmloff/shapeexport.hxx>
53 #include "sdpropls.hxx"
54 #include <tools/debug.hxx>
55 #include <rtl/ustrbuf.hxx>
56 #include <xmloff/xmlexp.hxx>
57 #include <xmloff/xmluconv.hxx>
58 #include "xexptran.hxx"
59 #include <xmloff/xmltoken.hxx>
60 #include "EnhancedCustomShapeToken.hxx"
61 #include <com/sun/star/container/XIdentifierContainer.hpp>
62 #include <com/sun/star/drawing/ShadeMode.hpp>
63 #include <com/sun/star/drawing/EnhancedCustomShapeParameterType.hpp>
64 #ifndef _COM_SUN_STAR_DRAWING_ENHANCEDCUSTOMSHAPEPARAMETERPARI_HPP_
65 #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
67 #include <com/sun/star/drawing/EnhancedCustomShapeGluePointType.hpp>
68 #include <com/sun/star/drawing/EnhancedCustomShapeTextFrame.hpp>
69 #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
70 #include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp>
71 #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
72 #include <com/sun/star/drawing/EnhancedCustomShapeTextPathMode.hpp>
73 #include <com/sun/star/beans/PropertyValues.hpp>
74 #include <rtl/math.hxx>
75 #include <tools/string.hxx>
76 #include <basegfx/vector/b3dvector.hxx>
78 #include "xmlnmspe.hxx"
79 #include "XMLBase64Export.hxx"
81 using ::rtl::OUString
;
82 using ::rtl::OUStringBuffer
;
84 using namespace ::com::sun::star
;
85 using namespace ::com::sun::star::io
;
86 using namespace ::xmloff::token
;
87 using namespace ::xmloff::EnhancedCustomShapeToken
;
89 using ::com::sun::star::embed::XStorage
;
90 using ::com::sun::star::uno::UNO_QUERY
;
91 using ::com::sun::star::uno::UNO_QUERY_THROW
;
92 using ::com::sun::star::uno::Reference
;
93 using ::com::sun::star::uno::Sequence
;
95 //////////////////////////////////////////////////////////////////////////////
97 void ExportParameter( rtl::OUStringBuffer
& rStrBuffer
, const com::sun::star::drawing::EnhancedCustomShapeParameter
& rParameter
)
99 if ( rStrBuffer
.getLength() )
100 rStrBuffer
.append( (sal_Unicode
)' ' );
101 if ( rParameter
.Value
.getValueTypeClass() == uno::TypeClass_DOUBLE
)
103 double fNumber
= 0.0;
104 rParameter
.Value
>>= fNumber
;
105 ::rtl::math::doubleToUStringBuffer( rStrBuffer
, fNumber
, rtl_math_StringFormat_Automatic
, rtl_math_DecimalPlaces_Max
, '.', sal_True
);
109 sal_Int32 nValue
= 0;
110 rParameter
.Value
>>= nValue
;
112 switch( rParameter
.Type
)
114 case com::sun::star::drawing::EnhancedCustomShapeParameterType::EQUATION
:
116 rStrBuffer
.append( (sal_Unicode
)'?' );
117 rStrBuffer
.append( (sal_Unicode
)'f' );
118 rStrBuffer
.append( rtl::OUString::valueOf( nValue
) );
122 case com::sun::star::drawing::EnhancedCustomShapeParameterType::ADJUSTMENT
:
124 rStrBuffer
.append( (sal_Unicode
)'$' );
125 rStrBuffer
.append( rtl::OUString::valueOf( nValue
) );
129 case com::sun::star::drawing::EnhancedCustomShapeParameterType::BOTTOM
:
130 rStrBuffer
.append( GetXMLToken( XML_BOTTOM
) ); break;
131 case com::sun::star::drawing::EnhancedCustomShapeParameterType::RIGHT
:
132 rStrBuffer
.append( GetXMLToken( XML_RIGHT
) ); break;
133 case com::sun::star::drawing::EnhancedCustomShapeParameterType::TOP
:
134 rStrBuffer
.append( GetXMLToken( XML_TOP
) ); break;
135 case com::sun::star::drawing::EnhancedCustomShapeParameterType::LEFT
:
136 rStrBuffer
.append( GetXMLToken( XML_LEFT
) ); break;
137 case com::sun::star::drawing::EnhancedCustomShapeParameterType::XSTRETCH
:
138 rStrBuffer
.append( GetXMLToken( XML_XSTRETCH
) ); break;
139 case com::sun::star::drawing::EnhancedCustomShapeParameterType::YSTRETCH
:
140 rStrBuffer
.append( GetXMLToken( XML_YSTRETCH
) ); break;
141 case com::sun::star::drawing::EnhancedCustomShapeParameterType::HASSTROKE
:
142 rStrBuffer
.append( GetXMLToken( XML_HASSTROKE
) ); break;
143 case com::sun::star::drawing::EnhancedCustomShapeParameterType::HASFILL
:
144 rStrBuffer
.append( GetXMLToken( XML_HASFILL
) ); break;
145 case com::sun::star::drawing::EnhancedCustomShapeParameterType::WIDTH
:
146 rStrBuffer
.append( GetXMLToken( XML_WIDTH
) ); break;
147 case com::sun::star::drawing::EnhancedCustomShapeParameterType::HEIGHT
:
148 rStrBuffer
.append( GetXMLToken( XML_HEIGHT
) ); break;
149 case com::sun::star::drawing::EnhancedCustomShapeParameterType::LOGWIDTH
:
150 rStrBuffer
.append( GetXMLToken( XML_LOGWIDTH
) ); break;
151 case com::sun::star::drawing::EnhancedCustomShapeParameterType::LOGHEIGHT
:
152 rStrBuffer
.append( GetXMLToken( XML_LOGHEIGHT
) ); break;
154 rStrBuffer
.append( rtl::OUString::valueOf( nValue
) );
159 void ImpExportEquations( SvXMLExport
& rExport
, const uno::Sequence
< rtl::OUString
>& rEquations
)
162 for ( i
= 0; i
< rEquations
.getLength(); i
++ )
164 rtl::OUString
aStr( String( 'f' ) );
165 aStr
+= rtl::OUString::valueOf( i
);
166 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_NAME
, aStr
);
168 aStr
= rEquations
[ i
];
169 sal_Int32 nIndex
= 0;
172 nIndex
= aStr
.indexOf( (sal_Unicode
)'?', nIndex
);
175 rtl::OUString
aNew( aStr
.copy( 0, nIndex
+ 1 ) );
176 aNew
+= String( 'f' );
177 aNew
+= aStr
.copy( nIndex
+ 1, ( aStr
.getLength() - nIndex
) - 1 );
181 } while( nIndex
!= -1 );
182 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_FORMULA
, aStr
);
183 SvXMLElementExport
aOBJ( rExport
, XML_NAMESPACE_DRAW
, XML_EQUATION
, sal_True
, sal_True
);
187 void ImpExportHandles( SvXMLExport
& rExport
, const uno::Sequence
< beans::PropertyValues
>& rHandles
)
189 sal_uInt32 i
, j
, nElements
= rHandles
.getLength();
193 rtl::OUStringBuffer aStrBuffer
;
195 for ( i
= 0; i
< nElements
; i
++ )
197 sal_Bool bPosition
= sal_False
;
198 const uno::Sequence
< beans::PropertyValue
>& rPropSeq
= rHandles
[ i
];
199 for ( j
= 0; j
< (sal_uInt32
)rPropSeq
.getLength(); j
++ )
201 const beans::PropertyValue
& rPropVal
= rPropSeq
[ j
];
202 switch( EASGet( rPropVal
.Name
) )
206 com::sun::star::drawing::EnhancedCustomShapeParameterPair aPosition
;
207 if ( rPropVal
.Value
>>= 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
;
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
) );
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
) );
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
) );
243 com::sun::star::drawing::EnhancedCustomShapeParameterPair aPolar
;
244 if ( rPropVal
.Value
>>= aPolar
)
246 ExportParameter( aStrBuffer
, aPolar
.First
);
247 ExportParameter( aStrBuffer
, aPolar
.Second
);
248 aStr
= aStrBuffer
.makeStringAndClear();
249 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_HANDLE_POLAR
, aStr
);
253 case EAS_RadiusRangeMinimum
:
255 com::sun::star::drawing::EnhancedCustomShapeParameter aRadiusRangeMinimum
;
256 if ( rPropVal
.Value
>>= aRadiusRangeMinimum
)
258 ExportParameter( aStrBuffer
, aRadiusRangeMinimum
);
259 aStr
= aStrBuffer
.makeStringAndClear();
260 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_HANDLE_RADIUS_RANGE_MINIMUM
, aStr
);
264 case EAS_RadiusRangeMaximum
:
266 com::sun::star::drawing::EnhancedCustomShapeParameter aRadiusRangeMaximum
;
267 if ( rPropVal
.Value
>>= aRadiusRangeMaximum
)
269 ExportParameter( aStrBuffer
, aRadiusRangeMaximum
);
270 aStr
= aStrBuffer
.makeStringAndClear();
271 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_HANDLE_RADIUS_RANGE_MAXIMUM
, aStr
);
275 case EAS_RangeXMinimum
:
277 com::sun::star::drawing::EnhancedCustomShapeParameter aXRangeMinimum
;
278 if ( rPropVal
.Value
>>= aXRangeMinimum
)
280 ExportParameter( aStrBuffer
, aXRangeMinimum
);
281 aStr
= aStrBuffer
.makeStringAndClear();
282 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_HANDLE_RANGE_X_MINIMUM
, aStr
);
286 case EAS_RangeXMaximum
:
288 com::sun::star::drawing::EnhancedCustomShapeParameter aXRangeMaximum
;
289 if ( rPropVal
.Value
>>= aXRangeMaximum
)
291 ExportParameter( aStrBuffer
, aXRangeMaximum
);
292 aStr
= aStrBuffer
.makeStringAndClear();
293 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_HANDLE_RANGE_X_MAXIMUM
, aStr
);
297 case EAS_RangeYMinimum
:
299 com::sun::star::drawing::EnhancedCustomShapeParameter aYRangeMinimum
;
300 if ( rPropVal
.Value
>>= aYRangeMinimum
)
302 ExportParameter( aStrBuffer
, aYRangeMinimum
);
303 aStr
= aStrBuffer
.makeStringAndClear();
304 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_HANDLE_RANGE_Y_MINIMUM
, aStr
);
308 case EAS_RangeYMaximum
:
310 com::sun::star::drawing::EnhancedCustomShapeParameter aYRangeMaximum
;
311 if ( rPropVal
.Value
>>= aYRangeMaximum
)
313 ExportParameter( aStrBuffer
, aYRangeMaximum
);
314 aStr
= aStrBuffer
.makeStringAndClear();
315 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_HANDLE_RANGE_Y_MAXIMUM
, aStr
);
324 SvXMLElementExport
aOBJ( rExport
, XML_NAMESPACE_DRAW
, XML_HANDLE
, sal_True
, sal_True
);
326 rExport
.ClearAttrList();
331 void ImpExportEnhancedPath( SvXMLExport
& rExport
,
332 const uno::Sequence
< com::sun::star::drawing::EnhancedCustomShapeParameterPair
>& rCoordinates
,
333 const uno::Sequence
< com::sun::star::drawing::EnhancedCustomShapeSegment
>& rSegments
)
337 rtl::OUStringBuffer aStrBuffer
;
339 sal_Int32 i
, j
, k
, l
;
341 sal_Int32 nCoords
= rCoordinates
.getLength();
342 sal_Int32 nSegments
= rSegments
.getLength();
343 sal_Bool bSimpleSegments
= nSegments
== 0;
344 if ( bSimpleSegments
)
346 for ( j
= i
= 0; j
< nSegments
; j
++ )
348 com::sun::star::drawing::EnhancedCustomShapeSegment aSegment
;
349 if ( bSimpleSegments
)
351 // if there are not enough segments we will default them
357 aSegment
.Command
= com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::MOVETO
;
362 aSegment
.Count
= (sal_Int16
)Min( nCoords
- 1, (sal_Int32
)32767 );
363 aSegment
.Command
= com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::LINETO
;
369 aSegment
.Command
= com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::CLOSESUBPATH
;
375 aSegment
.Command
= com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ENDSUBPATH
;
381 aSegment
= rSegments
[ j
];
383 if ( aStrBuffer
.getLength() )
384 aStrBuffer
.append( (sal_Unicode
)' ' );
386 sal_Int32 nParameter
= 0;
387 switch( aSegment
.Command
)
389 case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::CLOSESUBPATH
:
390 aStrBuffer
.append( (sal_Unicode
)'Z' ); break;
391 case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ENDSUBPATH
:
392 aStrBuffer
.append( (sal_Unicode
)'N' ); break;
393 case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::NOFILL
:
394 aStrBuffer
.append( (sal_Unicode
)'F' ); break;
395 case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::NOSTROKE
:
396 aStrBuffer
.append( (sal_Unicode
)'S' ); break;
398 case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::MOVETO
:
399 aStrBuffer
.append( (sal_Unicode
)'M' ); nParameter
= 1; break;
400 case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::LINETO
:
401 aStrBuffer
.append( (sal_Unicode
)'L' ); nParameter
= 1; break;
402 case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::CURVETO
:
403 aStrBuffer
.append( (sal_Unicode
)'C' ); nParameter
= 3; break;
404 case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ANGLEELLIPSETO
:
405 aStrBuffer
.append( (sal_Unicode
)'T' ); nParameter
= 3; break;
406 case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ANGLEELLIPSE
:
407 aStrBuffer
.append( (sal_Unicode
)'U' ); nParameter
= 3; break;
408 case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ARCTO
:
409 aStrBuffer
.append( (sal_Unicode
)'A' ); nParameter
= 4; break;
410 case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ARC
:
411 aStrBuffer
.append( (sal_Unicode
)'B' ); nParameter
= 4; break;
412 case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::CLOCKWISEARCTO
:
413 aStrBuffer
.append( (sal_Unicode
)'W' ); nParameter
= 4; break;
414 case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::CLOCKWISEARC
:
415 aStrBuffer
.append( (sal_Unicode
)'V' ); nParameter
= 4; break;
416 case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTX
:
417 aStrBuffer
.append( (sal_Unicode
)'X' ); nParameter
= 1; break;
418 case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTY
:
419 aStrBuffer
.append( (sal_Unicode
)'Y' ); nParameter
= 1; break;
420 case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::QUADRATICCURVETO
:
421 aStrBuffer
.append( (sal_Unicode
)'Q' ); nParameter
= 2; break;
423 default : // ups, seems to be something wrong
426 aSegment
.Command
= com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::LINETO
;
432 for ( k
= 0; k
< aSegment
.Count
; k
++ )
434 if ( ( i
+ nParameter
) <= nCoords
)
436 for ( l
= 0; l
< nParameter
; l
++ )
438 ExportParameter( aStrBuffer
, rCoordinates
[ i
].First
);
439 ExportParameter( aStrBuffer
, rCoordinates
[ i
++ ].Second
);
444 j
= nSegments
; // error -> exiting
450 aStr
= aStrBuffer
.makeStringAndClear();
451 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_ENHANCED_PATH
, aStr
);
454 void ImpExportEnhancedGeometry( SvXMLExport
& rExport
, const uno::Reference
< beans::XPropertySet
>& xPropSet
)
456 sal_Bool bEquations
= sal_False
;
457 uno::Sequence
< rtl::OUString
> aEquations
;
459 sal_Bool bHandles
= sal_False
;
460 uno::Sequence
< beans::PropertyValues
> aHandles
;
462 sal_Bool bCoordinates
= sal_False
;
463 uno::Sequence
< com::sun::star::drawing::EnhancedCustomShapeSegment
> aSegments
;
464 uno::Sequence
< com::sun::star::drawing::EnhancedCustomShapeParameterPair
> aCoordinates
;
466 uno::Sequence
< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue
> aAdjustmentValues
;
469 rtl::OUStringBuffer aStrBuffer
;
470 SvXMLUnitConverter
& rUnitConverter
= rExport
.GetMM100UnitConverter();
472 uno::Reference
< beans::XPropertySetInfo
> xPropSetInfo( xPropSet
->getPropertySetInfo() );
475 const rtl::OUString
sCustomShapeGeometry( RTL_CONSTASCII_USTRINGPARAM( "CustomShapeGeometry" ) );
476 if ( xPropSetInfo
.is() && xPropSetInfo
->hasPropertyByName( sCustomShapeGeometry
) )
478 uno::Any
aGeoPropSet( xPropSet
->getPropertyValue( sCustomShapeGeometry
) );
479 uno::Sequence
< beans::PropertyValue
> aGeoPropSeq
;
481 if ( aGeoPropSet
>>= aGeoPropSeq
)
483 const rtl::OUString
sCustomShapeType( RTL_CONSTASCII_USTRINGPARAM( "NonPrimitive" ) );
484 rtl::OUString
aCustomShapeType( sCustomShapeType
);
486 sal_Int32 j
, nGeoPropCount
= aGeoPropSeq
.getLength();
487 for ( j
= 0; j
< nGeoPropCount
; j
++ )
489 const beans::PropertyValue
& rGeoProp
= aGeoPropSeq
[ j
];
490 switch( EASGet( rGeoProp
.Name
) )
494 rGeoProp
.Value
>>= aCustomShapeType
;
499 sal_Bool bMirroredX
= sal_Bool();
500 if ( rGeoProp
.Value
>>= bMirroredX
)
501 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_MIRROR_HORIZONTAL
,
502 bMirroredX
? GetXMLToken( XML_TRUE
) : GetXMLToken( XML_FALSE
) );
507 sal_Bool bMirroredY
= sal_Bool();
508 if ( rGeoProp
.Value
>>= bMirroredY
)
509 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_MIRROR_VERTICAL
,
510 bMirroredY
? GetXMLToken( XML_TRUE
) : GetXMLToken( XML_FALSE
) );
515 awt::Rectangle aRect
;
516 if ( rGeoProp
.Value
>>= aRect
)
518 SdXMLImExViewBox
aViewBox( aRect
.X
, aRect
.Y
, aRect
.Width
, aRect
.Height
);
519 rExport
.AddAttribute( XML_NAMESPACE_SVG
, XML_VIEWBOX
, aViewBox
.GetExportString() );
523 case EAS_TextRotateAngle
:
525 double fTextRotateAngle
= 0;
526 if ( rGeoProp
.Value
>>= fTextRotateAngle
)
528 rUnitConverter
.convertDouble( aStrBuffer
, fTextRotateAngle
);
529 aStr
= aStrBuffer
.makeStringAndClear();
530 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_TEXT_ROTATE_ANGLE
, aStr
);
536 uno::Sequence
< beans::PropertyValue
> aExtrusionPropSeq
;
537 if ( rGeoProp
.Value
>>= aExtrusionPropSeq
)
539 sal_Int32 i
, nCount
= aExtrusionPropSeq
.getLength();
540 for ( i
= 0; i
< nCount
; i
++ )
542 const beans::PropertyValue
& rProp
= aExtrusionPropSeq
[ i
];
543 switch( EASGet( rProp
.Name
) )
547 sal_Bool bExtrusionOn
= sal_Bool();
548 if ( rProp
.Value
>>= bExtrusionOn
)
549 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_EXTRUSION
,
550 bExtrusionOn
? GetXMLToken( XML_TRUE
) : GetXMLToken( XML_FALSE
) );
553 case EAS_Brightness
:
555 double fExtrusionBrightness
= 0;
556 if ( rProp
.Value
>>= fExtrusionBrightness
)
558 rUnitConverter
.convertDouble( aStrBuffer
, fExtrusionBrightness
, sal_False
, MAP_RELATIVE
, MAP_RELATIVE
);
559 aStrBuffer
.append( (sal_Unicode
)'%' );
560 aStr
= aStrBuffer
.makeStringAndClear();
561 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_EXTRUSION_BRIGHTNESS
, aStr
);
567 com::sun::star::drawing::EnhancedCustomShapeParameterPair aDepthParaPair
;
568 if ( rProp
.Value
>>= aDepthParaPair
)
571 if ( aDepthParaPair
.First
.Value
>>= fDepth
)
573 rExport
.GetMM100UnitConverter().convertDouble( aStrBuffer
, fDepth
, sal_True
);
574 ExportParameter( aStrBuffer
, aDepthParaPair
.Second
);
575 aStr
= aStrBuffer
.makeStringAndClear();
576 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_EXTRUSION_DEPTH
, aStr
);
583 double fExtrusionDiffusion
= 0;
584 if ( rProp
.Value
>>= fExtrusionDiffusion
)
586 rUnitConverter
.convertDouble( aStrBuffer
, fExtrusionDiffusion
, sal_False
, MAP_RELATIVE
, MAP_RELATIVE
);
587 aStrBuffer
.append( (sal_Unicode
)'%' );
588 aStr
= aStrBuffer
.makeStringAndClear();
589 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_EXTRUSION_DIFFUSION
, aStr
);
593 case EAS_NumberOfLineSegments
:
595 sal_Int32 nExtrusionNumberOfLineSegments
= 0;
596 if ( rProp
.Value
>>= nExtrusionNumberOfLineSegments
)
597 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_EXTRUSION_NUMBER_OF_LINE_SEGMENTS
, rtl::OUString::valueOf( nExtrusionNumberOfLineSegments
) );
602 sal_Bool bExtrusionLightFace
= sal_Bool();
603 if ( rProp
.Value
>>= bExtrusionLightFace
)
604 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_EXTRUSION_LIGHT_FACE
,
605 bExtrusionLightFace
? GetXMLToken( XML_TRUE
) : GetXMLToken( XML_FALSE
) );
608 case EAS_FirstLightHarsh
:
610 sal_Bool bExtrusionFirstLightHarsh
= sal_Bool();
611 if ( rProp
.Value
>>= bExtrusionFirstLightHarsh
)
612 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_EXTRUSION_FIRST_LIGHT_HARSH
,
613 bExtrusionFirstLightHarsh
? GetXMLToken( XML_TRUE
) : GetXMLToken( XML_FALSE
) );
616 case EAS_SecondLightHarsh
:
618 sal_Bool bExtrusionSecondLightHarsh
= sal_Bool();
619 if ( rProp
.Value
>>= bExtrusionSecondLightHarsh
)
620 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_EXTRUSION_SECOND_LIGHT_HARSH
,
621 bExtrusionSecondLightHarsh
? GetXMLToken( XML_TRUE
) : GetXMLToken( XML_FALSE
) );
624 case EAS_FirstLightLevel
:
626 double fExtrusionFirstLightLevel
= 0;
627 if ( rProp
.Value
>>= fExtrusionFirstLightLevel
)
629 rUnitConverter
.convertDouble( aStrBuffer
, fExtrusionFirstLightLevel
, sal_False
, MAP_RELATIVE
, MAP_RELATIVE
);
630 aStrBuffer
.append( (sal_Unicode
)'%' );
631 aStr
= aStrBuffer
.makeStringAndClear();
632 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_EXTRUSION_FIRST_LIGHT_LEVEL
, aStr
);
636 case EAS_SecondLightLevel
:
638 double fExtrusionSecondLightLevel
= 0;
639 if ( rProp
.Value
>>= fExtrusionSecondLightLevel
)
641 rUnitConverter
.convertDouble( aStrBuffer
, fExtrusionSecondLightLevel
, sal_False
, MAP_RELATIVE
, MAP_RELATIVE
);
642 aStrBuffer
.append( (sal_Unicode
)'%' );
643 aStr
= aStrBuffer
.makeStringAndClear();
644 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_EXTRUSION_SECOND_LIGHT_LEVEL
, aStr
);
648 case EAS_FirstLightDirection
:
650 drawing::Direction3D aExtrusionFirstLightDirection
;
651 if ( rProp
.Value
>>= aExtrusionFirstLightDirection
)
653 ::basegfx::B3DVector
aVec3D( aExtrusionFirstLightDirection
.DirectionX
, aExtrusionFirstLightDirection
.DirectionY
,
654 aExtrusionFirstLightDirection
.DirectionZ
);
655 rUnitConverter
.convertB3DVector( aStrBuffer
, aVec3D
);
656 aStr
= aStrBuffer
.makeStringAndClear();
657 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_EXTRUSION_FIRST_LIGHT_DIRECTION
, aStr
);
661 case EAS_SecondLightDirection
:
663 drawing::Direction3D aExtrusionSecondLightDirection
;
664 if ( rProp
.Value
>>= aExtrusionSecondLightDirection
)
666 ::basegfx::B3DVector
aVec3D( aExtrusionSecondLightDirection
.DirectionX
, aExtrusionSecondLightDirection
.DirectionY
,
667 aExtrusionSecondLightDirection
.DirectionZ
);
668 rUnitConverter
.convertB3DVector( aStrBuffer
, aVec3D
);
669 aStr
= aStrBuffer
.makeStringAndClear();
670 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_EXTRUSION_SECOND_LIGHT_DIRECTION
, aStr
);
676 sal_Bool bExtrusionMetal
= sal_Bool();
677 if ( rProp
.Value
>>= bExtrusionMetal
)
678 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_EXTRUSION_METAL
,
679 bExtrusionMetal
? GetXMLToken( XML_TRUE
) : GetXMLToken( XML_FALSE
) );
685 drawing::ShadeMode eShadeMode
;
686 if( rProp
.Value
>>= eShadeMode
)
688 if( eShadeMode
== drawing::ShadeMode_FLAT
)
689 aStr
= GetXMLToken( XML_FLAT
);
690 else if( eShadeMode
== drawing::ShadeMode_PHONG
)
691 aStr
= GetXMLToken( XML_PHONG
);
692 else if( eShadeMode
== drawing::ShadeMode_SMOOTH
)
693 aStr
= GetXMLToken( XML_GOURAUD
);
695 aStr
= GetXMLToken( XML_DRAFT
);
699 // ShadeMode enum not there, write default
700 aStr
= GetXMLToken( XML_FLAT
);
702 rExport
.AddAttribute( XML_NAMESPACE_DR3D
, XML_SHADE_MODE
, aStr
);
705 case EAS_RotateAngle
:
707 com::sun::star::drawing::EnhancedCustomShapeParameterPair aRotateAngleParaPair
;
708 if ( rProp
.Value
>>= aRotateAngleParaPair
)
710 ExportParameter( aStrBuffer
, aRotateAngleParaPair
.First
);
711 ExportParameter( aStrBuffer
, aRotateAngleParaPair
.Second
);
712 aStr
= aStrBuffer
.makeStringAndClear();
713 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_EXTRUSION_ROTATION_ANGLE
, aStr
);
717 case EAS_RotationCenter
:
719 drawing::Direction3D aExtrusionRotationCenter
;
720 if ( rProp
.Value
>>= aExtrusionRotationCenter
)
722 ::basegfx::B3DVector
aVec3D( aExtrusionRotationCenter
.DirectionX
, aExtrusionRotationCenter
.DirectionY
,
723 aExtrusionRotationCenter
.DirectionZ
);
724 rUnitConverter
.convertB3DVector( aStrBuffer
, aVec3D
);
725 aStr
= aStrBuffer
.makeStringAndClear();
726 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_EXTRUSION_ROTATION_CENTER
, aStr
);
732 double fExtrusionShininess
= 0;
733 if ( rProp
.Value
>>= fExtrusionShininess
)
735 rUnitConverter
.convertDouble( aStrBuffer
, fExtrusionShininess
, sal_False
, MAP_RELATIVE
, MAP_RELATIVE
);
736 aStrBuffer
.append( (sal_Unicode
)'%' );
737 aStr
= aStrBuffer
.makeStringAndClear();
738 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_EXTRUSION_SHININESS
, aStr
);
744 com::sun::star::drawing::EnhancedCustomShapeParameterPair aSkewParaPair
;
745 if ( rProp
.Value
>>= aSkewParaPair
)
747 ExportParameter( aStrBuffer
, aSkewParaPair
.First
);
748 ExportParameter( aStrBuffer
, aSkewParaPair
.Second
);
749 aStr
= aStrBuffer
.makeStringAndClear();
750 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_EXTRUSION_SKEW
, aStr
);
754 case EAS_Specularity
:
756 double fExtrusionSpecularity
= 0;
757 if ( rProp
.Value
>>= fExtrusionSpecularity
)
759 rUnitConverter
.convertDouble( aStrBuffer
, fExtrusionSpecularity
, sal_False
, MAP_RELATIVE
, MAP_RELATIVE
);
760 aStrBuffer
.append( (sal_Unicode
)'%' );
761 aStr
= aStrBuffer
.makeStringAndClear();
762 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_EXTRUSION_SPECULARITY
, aStr
);
766 case EAS_ProjectionMode
:
768 drawing::ProjectionMode eProjectionMode
;
769 if ( rProp
.Value
>>= eProjectionMode
)
770 rExport
.AddAttribute( XML_NAMESPACE_DR3D
, XML_PROJECTION
,
771 eProjectionMode
== drawing::ProjectionMode_PARALLEL
? GetXMLToken( XML_PARALLEL
) : GetXMLToken( XML_PERSPECTIVE
) );
776 drawing::Position3D aExtrusionViewPoint
;
777 if ( rProp
.Value
>>= aExtrusionViewPoint
)
779 rUnitConverter
.convertPosition3D( aStrBuffer
, aExtrusionViewPoint
);
780 aStr
= aStrBuffer
.makeStringAndClear();
781 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_EXTRUSION_VIEWPOINT
, aStr
);
787 com::sun::star::drawing::EnhancedCustomShapeParameterPair aOriginParaPair
;
788 if ( rProp
.Value
>>= aOriginParaPair
)
790 ExportParameter( aStrBuffer
, aOriginParaPair
.First
);
791 ExportParameter( aStrBuffer
, aOriginParaPair
.Second
);
792 aStr
= aStrBuffer
.makeStringAndClear();
793 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_EXTRUSION_ORIGIN
, aStr
);
799 sal_Bool bExtrusionColor
= sal_Bool();
800 if ( rProp
.Value
>>= bExtrusionColor
)
802 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_EXTRUSION_COLOR
,
803 bExtrusionColor
? GetXMLToken( XML_TRUE
) : GetXMLToken( XML_FALSE
) );
816 uno::Sequence
< beans::PropertyValue
> aTextPathPropSeq
;
817 if ( rGeoProp
.Value
>>= aTextPathPropSeq
)
819 sal_Int32 i
, nCount
= aTextPathPropSeq
.getLength();
820 for ( i
= 0; i
< nCount
; i
++ )
822 const beans::PropertyValue
& rProp
= aTextPathPropSeq
[ i
];
823 switch( EASGet( rProp
.Name
) )
827 sal_Bool bTextPathOn
= sal_Bool();
828 if ( rProp
.Value
>>= bTextPathOn
)
829 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_TEXT_PATH
,
830 bTextPathOn
? GetXMLToken( XML_TRUE
) : GetXMLToken( XML_FALSE
) );
833 case EAS_TextPathMode
:
835 com::sun::star::drawing::EnhancedCustomShapeTextPathMode eTextPathMode
;
836 if ( rProp
.Value
>>= eTextPathMode
)
838 switch ( eTextPathMode
)
840 case com::sun::star::drawing::EnhancedCustomShapeTextPathMode_NORMAL
: aStr
= GetXMLToken( XML_NORMAL
); break;
841 case com::sun::star::drawing::EnhancedCustomShapeTextPathMode_PATH
: aStr
= GetXMLToken( XML_PATH
); break;
842 case com::sun::star::drawing::EnhancedCustomShapeTextPathMode_SHAPE
: aStr
= GetXMLToken( XML_SHAPE
); break;
846 if ( aStr
.getLength() )
847 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_TEXT_PATH_MODE
, aStr
);
853 sal_Bool bScaleX
= sal_Bool();
854 if ( rProp
.Value
>>= bScaleX
)
856 aStr
= bScaleX
? GetXMLToken( XML_SHAPE
) : GetXMLToken( XML_PATH
);
857 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_TEXT_PATH_SCALE
, aStr
);
861 case EAS_SameLetterHeights
:
863 sal_Bool bSameLetterHeights
= sal_Bool();
864 if ( rProp
.Value
>>= bSameLetterHeights
)
865 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_TEXT_PATH_SAME_LETTER_HEIGHTS
,
866 bSameLetterHeights
? GetXMLToken( XML_TRUE
) : GetXMLToken( XML_FALSE
) );
878 uno::Sequence
< beans::PropertyValue
> aPathPropSeq
;
879 if ( rGeoProp
.Value
>>= aPathPropSeq
)
881 sal_Int32 i
, nCount
= aPathPropSeq
.getLength();
882 for ( i
= 0; i
< nCount
; i
++ )
884 const beans::PropertyValue
& rProp
= aPathPropSeq
[ i
];
885 switch( EASGet( rProp
.Name
) )
887 case EAS_ExtrusionAllowed
:
889 sal_Bool bExtrusionAllowed
= sal_Bool();
890 if ( rProp
.Value
>>= bExtrusionAllowed
)
891 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_EXTRUSION_ALLOWED
,
892 bExtrusionAllowed
? GetXMLToken( XML_TRUE
) : GetXMLToken( XML_FALSE
) );
895 case EAS_ConcentricGradientFillAllowed
:
897 sal_Bool bConcentricGradientFillAllowed
= sal_Bool();
898 if ( rProp
.Value
>>= bConcentricGradientFillAllowed
)
899 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_CONCENTRIC_GRADIENT_FILL_ALLOWED
,
900 bConcentricGradientFillAllowed
? GetXMLToken( XML_TRUE
) : GetXMLToken( XML_FALSE
) );
903 case EAS_TextPathAllowed
:
905 sal_Bool bTextPathAllowed
= sal_Bool();
906 if ( rProp
.Value
>>= bTextPathAllowed
)
907 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_TEXT_PATH_ALLOWED
,
908 bTextPathAllowed
? GetXMLToken( XML_TRUE
) : GetXMLToken( XML_FALSE
) );
911 case EAS_GluePoints
:
913 com::sun::star::uno::Sequence
< com::sun::star::drawing::EnhancedCustomShapeParameterPair
> aGluePoints
;
914 if ( rProp
.Value
>>= aGluePoints
)
916 sal_Int32 k
, nElements
= aGluePoints
.getLength();
919 for( k
= 0; k
< nElements
; k
++ )
921 ExportParameter( aStrBuffer
, aGluePoints
[ k
].First
);
922 ExportParameter( aStrBuffer
, aGluePoints
[ k
].Second
);
924 aStr
= aStrBuffer
.makeStringAndClear();
926 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_GLUE_POINTS
, aStr
);
930 case EAS_GluePointType
:
932 sal_Int16 nGluePointType
= sal_Int16();
933 if ( rProp
.Value
>>= nGluePointType
)
935 switch ( nGluePointType
)
937 case com::sun::star::drawing::EnhancedCustomShapeGluePointType::NONE
: aStr
= GetXMLToken( XML_NONE
); break;
938 case com::sun::star::drawing::EnhancedCustomShapeGluePointType::SEGMENTS
: aStr
= GetXMLToken( XML_SEGMENTS
); break;
939 case com::sun::star::drawing::EnhancedCustomShapeGluePointType::RECT
: aStr
= GetXMLToken( XML_RECTANGLE
); break;
941 if ( aStr
.getLength() )
942 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_GLUE_POINT_TYPE
, aStr
);
946 case EAS_Coordinates
:
948 bCoordinates
= ( rProp
.Value
>>= aCoordinates
);
953 rProp
.Value
>>= aSegments
;
958 sal_Int32 nStretchPoint
= 0;
959 if ( rProp
.Value
>>= nStretchPoint
)
960 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_PATH_STRETCHPOINT_X
, rtl::OUString::valueOf( nStretchPoint
) );
965 sal_Int32 nStretchPoint
= 0;
966 if ( rProp
.Value
>>= nStretchPoint
)
967 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_PATH_STRETCHPOINT_Y
, rtl::OUString::valueOf( nStretchPoint
) );
970 case EAS_TextFrames
:
972 com::sun::star::uno::Sequence
< com::sun::star::drawing::EnhancedCustomShapeTextFrame
> aPathTextFrames
;
973 if ( rProp
.Value
>>= aPathTextFrames
)
975 if ( (sal_uInt16
)aPathTextFrames
.getLength() )
977 sal_uInt16 k
, nElements
= (sal_uInt16
)aPathTextFrames
.getLength();
978 for ( k
= 0; k
< nElements
; k
++ )
980 ExportParameter( aStrBuffer
, aPathTextFrames
[ k
].TopLeft
.First
);
981 ExportParameter( aStrBuffer
, aPathTextFrames
[ k
].TopLeft
.Second
);
982 ExportParameter( aStrBuffer
, aPathTextFrames
[ k
].BottomRight
.First
);
983 ExportParameter( aStrBuffer
, aPathTextFrames
[ k
].BottomRight
.Second
);
985 aStr
= aStrBuffer
.makeStringAndClear();
987 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_TEXT_AREAS
, aStr
);
1000 bEquations
= ( rGeoProp
.Value
>>= aEquations
);
1005 bHandles
= ( rGeoProp
.Value
>>= aHandles
);
1008 case EAS_AdjustmentValues
:
1010 rGeoProp
.Value
>>= aAdjustmentValues
;
1017 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_TYPE
, aCustomShapeType
);
1020 sal_Int32 nAdjustmentValues
= aAdjustmentValues
.getLength();
1021 if ( nAdjustmentValues
)
1023 sal_Int32 i
, nValue
= 0;
1024 for ( i
= 0; i
< nAdjustmentValues
; i
++ )
1027 aStrBuffer
.append( (sal_Unicode
)' ' );
1029 const com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue
& rAdj
= aAdjustmentValues
[ i
];
1030 if ( rAdj
.State
== beans::PropertyState_DIRECT_VALUE
)
1032 if ( rAdj
.Value
.getValueTypeClass() == uno::TypeClass_DOUBLE
)
1035 rAdj
.Value
>>= fValue
;
1036 rUnitConverter
.convertDouble( aStrBuffer
, fValue
);
1040 rAdj
.Value
>>= nValue
;
1041 rUnitConverter
.convertNumber( aStrBuffer
, nValue
);
1045 rUnitConverter
.convertNumber( aStrBuffer
, 0 ); // this should not be, but better than setting nothing
1047 aStr
= aStrBuffer
.makeStringAndClear();
1048 rExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_MODIFIERS
, aStr
);
1051 ImpExportEnhancedPath( rExport
, aCoordinates
, aSegments
);
1054 SvXMLElementExport
aOBJ( rExport
, XML_NAMESPACE_DRAW
, XML_ENHANCED_GEOMETRY
, sal_True
, sal_True
);
1056 ImpExportEquations( rExport
, aEquations
);
1058 ImpExportHandles( rExport
, aHandles
);
1061 void XMLShapeExport::ImpExportCustomShape(
1062 const uno::Reference
< drawing::XShape
>& xShape
,
1063 XmlShapeType
, sal_Int32 nFeatures
, com::sun::star::awt::Point
* pRefPoint
)
1065 const uno::Reference
< beans::XPropertySet
> xPropSet(xShape
, uno::UNO_QUERY
);
1066 if ( xPropSet
.is() )
1069 uno::Reference
< beans::XPropertySetInfo
> xPropSetInfo( xPropSet
->getPropertySetInfo() );
1072 ImpExportNewTrans( xPropSet
, nFeatures
, pRefPoint
);
1074 if ( xPropSetInfo
.is() )
1076 const rtl::OUString
sCustomShapeEngine( RTL_CONSTASCII_USTRINGPARAM( "CustomShapeEngine" ) );
1077 if ( xPropSetInfo
->hasPropertyByName( sCustomShapeEngine
) )
1079 uno::Any
aEngine( xPropSet
->getPropertyValue( sCustomShapeEngine
) );
1080 if ( ( aEngine
>>= aStr
) && aStr
.getLength() )
1081 mrExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_ENGINE
, aStr
);
1083 const rtl::OUString
sCustomShapeData( RTL_CONSTASCII_USTRINGPARAM( "CustomShapeData" ) );
1084 if ( xPropSetInfo
->hasPropertyByName( sCustomShapeData
) )
1086 uno::Any
aData( xPropSet
->getPropertyValue( sCustomShapeData
) );
1087 if ( ( aData
>>= aStr
) && aStr
.getLength() )
1088 mrExport
.AddAttribute( XML_NAMESPACE_DRAW
, XML_DATA
, aStr
);
1091 sal_Bool
bCreateNewline( (nFeatures
& SEF_EXPORT_NO_WS
) == 0 ); // #86116#/#92210#
1092 SvXMLElementExport
aOBJ( mrExport
, XML_NAMESPACE_DRAW
, XML_CUSTOM_SHAPE
, bCreateNewline
, sal_True
);
1093 ImpExportDescription( xShape
); // #i68101#
1094 ImpExportEvents( xShape
);
1095 ImpExportGluePoints( xShape
);
1096 ImpExportText( xShape
);
1097 ImpExportEnhancedGeometry( mrExport
, xPropSet
);
1101 void XMLShapeExport::ImpExportTableShape( const uno::Reference
< drawing::XShape
>& xShape
, XmlShapeType
/*eShapeType*/, sal_Int32 nFeatures
, com::sun::star::awt::Point
* pRefPoint
)
1103 uno::Reference
< beans::XPropertySet
> xPropSet(xShape
, uno::UNO_QUERY
);
1104 uno::Reference
< container::XNamed
> xNamed(xShape
, uno::UNO_QUERY
);
1106 DBG_ASSERT( xPropSet
.is() && xNamed
.is(), "xmloff::XMLShapeExport::ImpExportTableShape(), tabe shape is not implementing needed interfaces");
1107 if(xPropSet
.is() && xNamed
.is()) try
1110 ImpExportNewTrans(xPropSet
, nFeatures
, pRefPoint
);
1112 sal_Bool bIsEmptyPresObj
= sal_False
;
1114 // presentation settings
1115 // if(eShapeType == XmlShapeTypePresTableShape)
1116 // bIsEmptyPresObj = ImpExportPresentationAttributes( xPropSet, GetXMLToken(XML_PRESENTATION_TABLE) );
1118 const bool bCreateNewline( (nFeatures
& SEF_EXPORT_NO_WS
) == 0 );
1119 const bool bExportEmbedded(0 != (mrExport
.getExportFlags() & EXPORT_EMBEDDED
));
1121 SvXMLElementExport
aElement( mrExport
, XML_NAMESPACE_DRAW
, XML_FRAME
, bCreateNewline
, sal_True
);
1123 if( !bIsEmptyPresObj
)
1125 uno::Reference
< container::XNamed
> xTemplate( xPropSet
->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TableTemplate" ) ) ), uno::UNO_QUERY
);
1126 if( xTemplate
.is() )
1128 const OUString
sTemplate( xTemplate
->getName() );
1129 if( sTemplate
.getLength() )
1131 mrExport
.AddAttribute(XML_NAMESPACE_TABLE
, XML_TEMPLATE_NAME
, sTemplate
);
1133 for( const XMLPropertyMapEntry
* pEntry
= &aXMLTableShapeAttributes
[0]; pEntry
->msApiName
; pEntry
++ )
1137 sal_Bool bBool
= sal_False
;
1138 const OUString
sAPIPropertyName( OUString(pEntry
->msApiName
, pEntry
->nApiNameLength
, RTL_TEXTENCODING_ASCII_US
) );
1140 xPropSet
->getPropertyValue( sAPIPropertyName
) >>= bBool
;
1142 mrExport
.AddAttribute(pEntry
->mnNameSpace
, pEntry
->meXMLName
, XML_TRUE
);
1144 catch( uno::Exception
& )
1146 DBG_ERROR("XMLShapeExport::ImpExportTableShape(), exception caught!");
1151 uno::Reference
< table::XColumnRowRange
> xRange( xPropSet
->getPropertyValue( msModel
), uno::UNO_QUERY_THROW
);
1153 GetShapeTableExport()->exportTable( xRange
);
1155 uno::Reference
< graphic::XGraphic
> xGraphic( xPropSet
->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "ReplacementGraphic" ) ) ), uno::UNO_QUERY
);
1156 if( xGraphic
.is() ) try
1158 Reference
< lang::XMultiServiceFactory
> xSM( GetExport().getServiceFactory(), UNO_QUERY_THROW
);
1160 uno::Reference
< embed::XStorage
> xPictureStorage
;
1161 uno::Reference
< embed::XStorage
> xStorage
;
1162 uno::Reference
< io::XStream
> xPictureStream
;
1164 OUString sPictureName
;
1165 if( bExportEmbedded
)
1167 xPictureStream
.set( xSM
->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.MemoryStream" ) ) ), UNO_QUERY_THROW
);
1171 xStorage
.set( GetExport().GetTargetStorage(), UNO_QUERY_THROW
);
1173 xPictureStorage
.set( xStorage
->openStorageElement( OUString( RTL_CONSTASCII_USTRINGPARAM( "Pictures" ) ), ::embed::ElementModes::READWRITE
), uno::UNO_QUERY_THROW
);
1174 const OUString
sPrefix( RTL_CONSTASCII_USTRINGPARAM("TablePreview") );
1175 const OUString
sSuffix( RTL_CONSTASCII_USTRINGPARAM(".svm") );
1177 sal_Int32 nIndex
= 0;
1180 sPictureName
= sPrefix
;
1181 sPictureName
+= OUString::valueOf( ++nIndex
);
1182 sPictureName
+= sSuffix
;
1184 while( xPictureStorage
->hasByName( sPictureName
) );
1186 xPictureStream
.set( xPictureStorage
->openStreamElement( sPictureName
, ::embed::ElementModes::READWRITE
), UNO_QUERY_THROW
);
1189 Reference
< graphic::XGraphicProvider
> xProvider( xSM
->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.graphic.GraphicProvider" ) ) ), UNO_QUERY_THROW
);
1190 Sequence
< beans::PropertyValue
> aArgs( 2 );
1191 aArgs
[ 0 ].Name
= OUString( RTL_CONSTASCII_USTRINGPARAM( "MimeType" ) );
1192 aArgs
[ 0 ].Value
<<= OUString( RTL_CONSTASCII_USTRINGPARAM( "image/x-vclgraphic" ) );
1193 aArgs
[ 1 ].Name
= OUString( RTL_CONSTASCII_USTRINGPARAM( "OutputStream" ) );
1194 aArgs
[ 1 ].Value
<<= xPictureStream
->getOutputStream();
1195 xProvider
->storeGraphic( xGraphic
, aArgs
);
1197 if( xPictureStorage
.is() )
1199 Reference
< embed::XTransactedObject
> xTrans( xPictureStorage
, UNO_QUERY
);
1204 if( !bExportEmbedded
)
1206 OUString
sURL( RTL_CONSTASCII_USTRINGPARAM( "Pictures/" ) );
1207 sURL
+= sPictureName
;
1208 mrExport
.AddAttribute(XML_NAMESPACE_XLINK
, XML_HREF
, sURL
);
1209 mrExport
.AddAttribute( XML_NAMESPACE_XLINK
, XML_TYPE
, XML_SIMPLE
);
1210 mrExport
.AddAttribute( XML_NAMESPACE_XLINK
, XML_SHOW
, XML_EMBED
);
1211 mrExport
.AddAttribute( XML_NAMESPACE_XLINK
, XML_ACTUATE
, XML_ONLOAD
);
1214 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_DRAW
, XML_IMAGE
, sal_False
, sal_True
);
1216 if( bExportEmbedded
)
1218 Reference
< XSeekableInputStream
> xSeekable( xPictureStream
, UNO_QUERY_THROW
);
1221 XMLBase64Export
aBase64Exp( GetExport() );
1222 aBase64Exp
.exportOfficeBinaryDataElement( Reference
< XInputStream
>( xPictureStream
, UNO_QUERY_THROW
) );
1225 catch( uno::Exception
& )
1227 DBG_ERROR("xmloff::XMLShapeExport::ImpExportTableShape(), exception caught!");
1231 ImpExportEvents( xShape
);
1232 ImpExportGluePoints( xShape
);
1233 ImpExportDescription( xShape
); // #i68101#
1235 catch( uno::Exception
& )
1237 DBG_ERROR( "xmloff::XMLShapeExport::ImpExportTableShape(), exception caught!" );