Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <basegfx/matrix/b2dhommatrix.hxx>
21 : #include <basegfx/matrix/b2dhommatrixtools.hxx>
22 : #include <basegfx/matrix/b3dhommatrix.hxx>
23 : #include <basegfx/point/b2dpoint.hxx>
24 : #include <basegfx/polygon/b2dpolypolygon.hxx>
25 : #include <basegfx/polygon/b2dpolypolygontools.hxx>
26 : #include <basegfx/polygon/b2dpolygontools.hxx>
27 : #include <basegfx/polygon/b3dpolypolygon.hxx>
28 : #include <basegfx/polygon/b3dpolypolygontools.hxx>
29 : #include <basegfx/tuple/b2dtuple.hxx>
30 : #include <basegfx/vector/b3dvector.hxx>
31 :
32 : #include <com/sun/star/beans/XPropertyState.hpp>
33 : #include <com/sun/star/beans/PropertyValues.hpp>
34 : #include <com/sun/star/chart/XChartDocument.hpp>
35 : #include <com/sun/star/container/XChild.hpp>
36 : #include <com/sun/star/container/XEnumerationAccess.hpp>
37 : #include <com/sun/star/container/XIdentifierAccess.hpp>
38 : #include <com/sun/star/container/XIdentifierContainer.hpp>
39 : #include <com/sun/star/container/XNamed.hpp>
40 : #include <com/sun/star/document/XEventsSupplier.hpp>
41 : #include <com/sun/star/drawing/Alignment.hpp>
42 : #include <com/sun/star/drawing/CameraGeometry.hpp>
43 : #include <com/sun/star/drawing/CircleKind.hpp>
44 : #include <com/sun/star/drawing/ConnectorType.hpp>
45 : #include <com/sun/star/drawing/Direction3D.hpp>
46 : #include <com/sun/star/drawing/DoubleSequence.hpp>
47 : #include <com/sun/star/drawing/EscapeDirection.hpp>
48 : #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
49 : #include <com/sun/star/drawing/EnhancedCustomShapeGluePointType.hpp>
50 : #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
51 : #include <com/sun/star/drawing/EnhancedCustomShapeParameterType.hpp>
52 : #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
53 : #include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp>
54 : #include <com/sun/star/drawing/EnhancedCustomShapeTextFrame.hpp>
55 : #include <com/sun/star/drawing/EnhancedCustomShapeTextPathMode.hpp>
56 : #include <com/sun/star/drawing/GluePoint2.hpp>
57 : #include <com/sun/star/drawing/HomogenMatrix.hpp>
58 : #include <com/sun/star/drawing/HomogenMatrix3.hpp>
59 : #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
60 : #include <com/sun/star/drawing/PolyPolygonShape3D.hpp>
61 : #include <com/sun/star/drawing/Position3D.hpp>
62 : #include <com/sun/star/drawing/ProjectionMode.hpp>
63 : #include <com/sun/star/drawing/ShadeMode.hpp>
64 : #include <com/sun/star/drawing/XControlShape.hpp>
65 : #include <com/sun/star/drawing/XCustomShapeEngine.hpp>
66 : #include <com/sun/star/drawing/XGluePointsSupplier.hpp>
67 : #include <com/sun/star/embed/ElementModes.hpp>
68 : #include <com/sun/star/embed/XTransactedObject.hpp>
69 : #include <com/sun/star/graphic/XGraphic.hpp>
70 : #include <com/sun/star/graphic/GraphicProvider.hpp>
71 : #include <com/sun/star/graphic/XGraphicProvider.hpp>
72 : #include <com/sun/star/io/XSeekableInputStream.hpp>
73 : #include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
74 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
75 : #include <com/sun/star/media/ZoomLevel.hpp>
76 : #include <com/sun/star/presentation/AnimationSpeed.hpp>
77 : #include <com/sun/star/presentation/ClickAction.hpp>
78 : #include <com/sun/star/style/XStyle.hpp>
79 : #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
80 : #include <com/sun/star/table/XColumnRowRange.hpp>
81 : #include <com/sun/star/text/XText.hpp>
82 : #include <com/sun/star/document/XStorageBasedDocument.hpp>
83 :
84 : #include <comphelper/classids.hxx>
85 : #include <comphelper/processfactory.hxx>
86 : #include <comphelper/storagehelper.hxx>
87 :
88 : #include <rtl/math.hxx>
89 : #include <rtl/ustrbuf.hxx>
90 :
91 : #include <sax/tools/converter.hxx>
92 :
93 : #include <tools/debug.hxx>
94 : #include <tools/globname.hxx>
95 : #include <tools/helpers.hxx>
96 : #include <tools/urlobj.hxx>
97 :
98 : #include <xmloff/contextid.hxx>
99 : #include <xmloff/families.hxx>
100 : #include <xmloff/nmspmap.hxx>
101 : #include <xmloff/shapeexport.hxx>
102 : #include <xmloff/unointerfacetouniqueidentifiermapper.hxx>
103 : #include <xmloff/xmlexp.hxx>
104 : #include <xmloff/xmlnmspe.hxx>
105 : #include <xmloff/xmltoken.hxx>
106 : #include <xmloff/xmluconv.hxx>
107 :
108 : #include "anim.hxx"
109 : #include "EnhancedCustomShapeToken.hxx"
110 : #include "PropertySetMerger.hxx"
111 : #include "sdpropls.hxx"
112 : #include "sdxmlexp_impl.hxx"
113 : #include "xexptran.hxx"
114 : #include "XMLBase64Export.hxx"
115 : #include "XMLImageMapExport.hxx"
116 : #include <boost/scoped_ptr.hpp>
117 :
118 : #include <config_features.h>
119 :
120 : using namespace ::com::sun::star;
121 : using namespace ::xmloff::EnhancedCustomShapeToken;
122 : using namespace ::xmloff::token;
123 :
124 834 : XMLShapeExport::XMLShapeExport(SvXMLExport& rExp,
125 : SvXMLExportPropertyMapper *pExtMapper )
126 : : mrExport( rExp ),
127 : maShapesInfos(),
128 834 : maCurrentShapesIter(maShapesInfos.end()),
129 : mbExportLayer( false ),
130 : // #88546# init to sal_False
131 : mbHandleProgressBar( false ),
132 : msZIndex( "ZOrder" ),
133 : msPrintable( "Printable" ),
134 : msVisible( "Visible" ),
135 : msEmptyPres( "IsEmptyPresentationObject" ),
136 : msModel( "Model" ),
137 : msStartShape( "StartShape" ),
138 : msEndShape( "EndShape" ),
139 : msOnClick( "OnClick" ),
140 : msEventType( "EventType" ),
141 : msPresentation( "Presentation" ),
142 : msMacroName( "MacroName" ),
143 : msScript( "Script" ),
144 : msLibrary( "Library" ),
145 : msClickAction( "ClickAction" ),
146 : msBookmark( "Bookmark" ),
147 : msEffect( "Effect" ),
148 : msPlayFull( "PlayFull" ),
149 : msVerb( "Verb" ),
150 : msSoundURL( "SoundURL" ),
151 : msSpeed( "Speed" ),
152 1668 : msStarBasic( "StarBasic" )
153 : {
154 : // construct PropertyHandlerFactory
155 834 : mxSdPropHdlFactory = new XMLSdPropHdlFactory( mrExport.GetModel(), rExp );
156 : // construct PropertySetMapper
157 834 : mxPropertySetMapper = CreateShapePropMapper( mrExport );
158 834 : if( pExtMapper )
159 : {
160 120 : rtl::Reference < SvXMLExportPropertyMapper > xExtMapper( pExtMapper );
161 120 : mxPropertySetMapper->ChainExportMapper( xExtMapper );
162 : }
163 :
164 : /*
165 : // chain text attributes
166 : xPropertySetMapper->ChainExportMapper(XMLTextParagraphExport::CreateParaExtPropMapper(rExp));
167 : */
168 :
169 : mrExport.GetAutoStylePool()->AddFamily(
170 : XML_STYLE_FAMILY_SD_GRAPHICS_ID,
171 : OUString(XML_STYLE_FAMILY_SD_GRAPHICS_NAME),
172 : GetPropertySetMapper(),
173 834 : OUString(XML_STYLE_FAMILY_SD_GRAPHICS_PREFIX));
174 : mrExport.GetAutoStylePool()->AddFamily(
175 : XML_STYLE_FAMILY_SD_PRESENTATION_ID,
176 : OUString(XML_STYLE_FAMILY_SD_PRESENTATION_NAME),
177 : GetPropertySetMapper(),
178 834 : OUString(XML_STYLE_FAMILY_SD_PRESENTATION_PREFIX));
179 :
180 834 : maCurrentInfo = maShapeInfos.end();
181 :
182 : // create table export helper and let him add his families in time
183 834 : GetShapeTableExport();
184 834 : }
185 :
186 1572 : XMLShapeExport::~XMLShapeExport()
187 : {
188 1572 : }
189 :
190 : // sj: replacing CustomShapes with standard objects that are also supported in OpenOffice.org format
191 180 : uno::Reference< drawing::XShape > XMLShapeExport::checkForCustomShapeReplacement( const uno::Reference< drawing::XShape >& xShape )
192 : {
193 180 : uno::Reference< drawing::XShape > xCustomShapeReplacement;
194 :
195 180 : if( ( GetExport().getExportFlags() & EXPORT_OASIS ) == 0 )
196 : {
197 0 : OUString aType( xShape->getShapeType() );
198 0 : if( aType.equalsAscii( "com.sun.star.drawing.CustomShape" ) )
199 : {
200 0 : uno::Reference< beans::XPropertySet > xSet( xShape, uno::UNO_QUERY );
201 0 : if( xSet.is() )
202 : {
203 0 : OUString aEngine;
204 0 : xSet->getPropertyValue("CustomShapeEngine") >>= aEngine;
205 0 : if ( aEngine.isEmpty() )
206 : {
207 0 : aEngine = "com.sun.star.drawing.EnhancedCustomShapeEngine";
208 : }
209 0 : uno::Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
210 :
211 0 : if ( !aEngine.isEmpty() )
212 : {
213 0 : uno::Sequence< uno::Any > aArgument( 1 );
214 0 : uno::Sequence< beans::PropertyValue > aPropValues( 2 );
215 0 : aPropValues[ 0 ].Name = "CustomShape";
216 0 : aPropValues[ 0 ].Value <<= xShape;
217 0 : bool bForceGroupWithText = true;
218 0 : aPropValues[ 1 ].Name = "ForceGroupWithText";
219 0 : aPropValues[ 1 ].Value <<= bForceGroupWithText;
220 0 : aArgument[ 0 ] <<= aPropValues;
221 : uno::Reference< uno::XInterface > xInterface(
222 0 : xContext->getServiceManager()->createInstanceWithArgumentsAndContext(aEngine, aArgument, xContext) );
223 0 : if ( xInterface.is() )
224 : {
225 : uno::Reference< drawing::XCustomShapeEngine > xCustomShapeEngine(
226 0 : uno::Reference< drawing::XCustomShapeEngine >( xInterface, uno::UNO_QUERY ) );
227 0 : if ( xCustomShapeEngine.is() )
228 0 : xCustomShapeReplacement = xCustomShapeEngine->render();
229 0 : }
230 0 : }
231 0 : }
232 0 : }
233 : }
234 180 : return xCustomShapeReplacement;
235 : }
236 :
237 : // This method collects all automatic styles for the given XShape
238 180 : void XMLShapeExport::collectShapeAutoStyles(const uno::Reference< drawing::XShape >& xShape )
239 : {
240 180 : if( maCurrentShapesIter == maShapesInfos.end() )
241 : {
242 : OSL_FAIL( "XMLShapeExport::collectShapeAutoStyles(): no call to seekShapes()!" );
243 0 : return;
244 : }
245 180 : sal_Int32 nZIndex = 0;
246 180 : uno::Reference< beans::XPropertySet > xSet( xShape, uno::UNO_QUERY );
247 180 : if( xSet.is() )
248 180 : xSet->getPropertyValue(msZIndex) >>= nZIndex;
249 :
250 180 : ImplXMLShapeExportInfoVector& aShapeInfoVector = (*maCurrentShapesIter).second;
251 :
252 180 : if( (sal_Int32)aShapeInfoVector.size() <= nZIndex )
253 : {
254 : OSL_FAIL( "XMLShapeExport::collectShapeAutoStyles(): no shape info allocated for a given shape" );
255 0 : return;
256 : }
257 :
258 180 : ImplXMLShapeExportInfo& aShapeInfo = aShapeInfoVector[nZIndex];
259 :
260 360 : uno::Reference< drawing::XShape > xCustomShapeReplacement = checkForCustomShapeReplacement( xShape );
261 180 : if ( xCustomShapeReplacement.is() )
262 0 : aShapeInfo.xCustomShapeReplacement = xCustomShapeReplacement;
263 :
264 : // first compute the shapes type
265 180 : ImpCalcShapeType(xShape, aShapeInfo.meShapeType);
266 :
267 : // #i118485# enabled XmlShapeTypeDrawChartShape and XmlShapeTypeDrawOLE2Shape
268 : // to have text
269 : const bool bObjSupportsText =
270 360 : aShapeInfo.meShapeType != XmlShapeTypePresChartShape &&
271 360 : aShapeInfo.meShapeType != XmlShapeTypePresOLE2Shape &&
272 360 : aShapeInfo.meShapeType != XmlShapeTypeDrawSheetShape &&
273 360 : aShapeInfo.meShapeType != XmlShapeTypePresSheetShape &&
274 360 : aShapeInfo.meShapeType != XmlShapeTypeDraw3DSceneObject &&
275 360 : aShapeInfo.meShapeType != XmlShapeTypeDraw3DCubeObject &&
276 360 : aShapeInfo.meShapeType != XmlShapeTypeDraw3DSphereObject &&
277 360 : aShapeInfo.meShapeType != XmlShapeTypeDraw3DLatheObject &&
278 360 : aShapeInfo.meShapeType != XmlShapeTypeDraw3DExtrudeObject &&
279 360 : aShapeInfo.meShapeType != XmlShapeTypeDrawPageShape &&
280 528 : aShapeInfo.meShapeType != XmlShapeTypePresPageShape &&
281 348 : aShapeInfo.meShapeType != XmlShapeTypeDrawGroupShape;
282 :
283 : const bool bObjSupportsStyle =
284 180 : aShapeInfo.meShapeType != XmlShapeTypeDrawGroupShape;
285 :
286 180 : bool bIsEmptyPresObj = false;
287 :
288 360 : uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
289 180 : if ( aShapeInfo.xCustomShapeReplacement.is() )
290 0 : xPropSet.clear();
291 :
292 : // prep text styles
293 180 : if( xPropSet.is() && bObjSupportsText )
294 : {
295 168 : uno::Reference< text::XText > xText(xShape, uno::UNO_QUERY);
296 168 : if(xText.is() && !xText->getString().isEmpty())
297 : {
298 88 : uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
299 :
300 88 : if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(msEmptyPres) )
301 : {
302 82 : uno::Any aAny = xPropSet->getPropertyValue(msEmptyPres);
303 82 : aAny >>= bIsEmptyPresObj;
304 : }
305 :
306 88 : if(!bIsEmptyPresObj)
307 : {
308 74 : GetExport().GetTextParagraphExport()->collectTextAutoStyles( xText );
309 88 : }
310 168 : }
311 : }
312 :
313 : // compute the shape parent style
314 180 : if( xPropSet.is() )
315 : {
316 180 : uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( xPropSet->getPropertySetInfo() );
317 :
318 360 : OUString aParentName;
319 360 : uno::Reference< style::XStyle > xStyle;
320 :
321 180 : if( bObjSupportsStyle )
322 : {
323 180 : if( xPropertySetInfo.is() && xPropertySetInfo->hasPropertyByName("Style") )
324 150 : xPropSet->getPropertyValue("Style") >>= xStyle;
325 :
326 180 : if(xStyle.is())
327 : {
328 : // get family ID
329 108 : uno::Reference< beans::XPropertySet > xStylePropSet(xStyle, uno::UNO_QUERY);
330 : DBG_ASSERT( xStylePropSet.is(), "style without a XPropertySet?" );
331 : try
332 : {
333 108 : if(xStylePropSet.is())
334 : {
335 108 : OUString aFamilyName;
336 108 : xStylePropSet->getPropertyValue("Family") >>= aFamilyName;
337 108 : if( !aFamilyName.isEmpty() && aFamilyName != "graphics" )
338 80 : aShapeInfo.mnFamily = XML_STYLE_FAMILY_SD_PRESENTATION_ID;
339 : }
340 : }
341 0 : catch(const beans::UnknownPropertyException&)
342 : {
343 : // Ignored.
344 : DBG_ASSERT(false,
345 : "XMLShapeExport::collectShapeAutoStyles: style has no 'Family' property");
346 : }
347 :
348 : // get parent-style name
349 108 : if(XML_STYLE_FAMILY_SD_PRESENTATION_ID == aShapeInfo.mnFamily)
350 : {
351 80 : aParentName = msPresentationStylePrefix;
352 : }
353 :
354 108 : aParentName += xStyle->getName();
355 : }
356 : }
357 :
358 180 : if (aParentName.isEmpty() && xPropertySetInfo->hasPropertyByName("TextBox") && xPropSet->getPropertyValue("TextBox").get<bool>())
359 : {
360 : // Shapes with a Writer TextBox always have a parent style.
361 : // If there would be none, then just assign the first available.
362 2 : uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(GetExport().GetModel(), uno::UNO_QUERY);
363 4 : uno::Reference<container::XNameAccess> xStyleFamilies = xStyleFamiliesSupplier->getStyleFamilies();
364 4 : uno::Reference<container::XNameAccess> xFrameStyles = xStyleFamilies->getByName("FrameStyles").get< uno::Reference<container::XNameAccess> >();
365 4 : uno::Sequence<OUString> aFrameStyles = xFrameStyles->getElementNames();
366 2 : if (aFrameStyles.hasElements())
367 4 : aParentName = aFrameStyles[0];
368 : }
369 :
370 : // filter propset
371 360 : std::vector< XMLPropertyState > xPropStates;
372 :
373 180 : sal_Int32 nCount = 0;
374 180 : if( (!bIsEmptyPresObj || (aShapeInfo.meShapeType != XmlShapeTypePresPageShape)) )
375 : {
376 180 : xPropStates = GetPropertySetMapper()->Filter( xPropSet );
377 :
378 180 : if (XmlShapeTypeDrawControlShape == aShapeInfo.meShapeType)
379 : {
380 : // for control shapes, we additionally need the number format style (if any)
381 0 : uno::Reference< drawing::XControlShape > xControl(xShape, uno::UNO_QUERY);
382 : DBG_ASSERT(xControl.is(), "XMLShapeExport::collectShapeAutoStyles: ShapeType control, but no XControlShape!");
383 0 : if (xControl.is())
384 : {
385 0 : uno::Reference< beans::XPropertySet > xControlModel(xControl->getControl(), uno::UNO_QUERY);
386 : DBG_ASSERT(xControlModel.is(), "XMLShapeExport::collectShapeAutoStyles: no control model on the control shape!");
387 :
388 0 : OUString sNumberStyle = mrExport.GetFormExport()->getControlNumberStyle(xControlModel);
389 0 : if (!sNumberStyle.isEmpty())
390 : {
391 0 : sal_Int32 nIndex = GetPropertySetMapper()->getPropertySetMapper()->FindEntryIndex(CTF_SD_CONTROL_SHAPE_DATA_STYLE);
392 : // TODO : this retrieval of the index could be moved into the ctor, holding the index
393 : // as member, thus saving time.
394 : DBG_ASSERT(-1 != nIndex, "XMLShapeExport::collectShapeAutoStyles: could not obtain the index for our context id!");
395 :
396 0 : XMLPropertyState aNewState(nIndex, uno::makeAny(sNumberStyle));
397 0 : xPropStates.push_back(aNewState);
398 0 : }
399 0 : }
400 : }
401 :
402 180 : std::vector< XMLPropertyState >::iterator aIter = xPropStates.begin();
403 180 : std::vector< XMLPropertyState >::iterator aEnd = xPropStates.end();
404 1678 : while( aIter != aEnd )
405 : {
406 1318 : if( aIter->mnIndex != -1 )
407 810 : nCount++;
408 1318 : ++aIter;
409 : }
410 : }
411 :
412 180 : if(nCount == 0)
413 : {
414 : // no hard attributes, use parent style name for export
415 60 : aShapeInfo.msStyleName = aParentName;
416 : }
417 : else
418 : {
419 : // there are filtered properties -> hard attributes
420 : // try to find this style in AutoStylePool
421 120 : aShapeInfo.msStyleName = mrExport.GetAutoStylePool()->Find(aShapeInfo.mnFamily, aParentName, xPropStates);
422 :
423 120 : if(aShapeInfo.msStyleName.isEmpty())
424 : {
425 : // Style did not exist, add it to AutoStalePool
426 82 : aShapeInfo.msStyleName = mrExport.GetAutoStylePool()->Add(aShapeInfo.mnFamily, aParentName, xPropStates);
427 : }
428 : }
429 :
430 : // optionaly generate auto style for text attributes
431 180 : if( (!bIsEmptyPresObj || (aShapeInfo.meShapeType != XmlShapeTypePresPageShape)) && bObjSupportsText )
432 : {
433 168 : xPropStates = GetExport().GetTextParagraphExport()->GetParagraphPropertyMapper()->Filter( xPropSet );
434 :
435 : // yet more additionally, we need to care for the ParaAdjust property
436 168 : if ( XmlShapeTypeDrawControlShape == aShapeInfo.meShapeType )
437 : {
438 0 : uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
439 0 : uno::Reference< beans::XPropertyState > xPropState( xPropSet, uno::UNO_QUERY );
440 0 : if ( xPropSetInfo.is() && xPropState.is() )
441 : {
442 : // this is because:
443 : // * if controls shapes have a ParaAdjust property, then this is the Align property of the control model
444 : // * control models are allowed to have an Align of "void"
445 : // * the Default for control model's Align is TextAlign_LEFT
446 : // * defaults for style properties are not written, but we need to write the "left",
447 : // because we need to distiguish this "left" from the case where not align attribute
448 : // is present which means "void"
449 0 : if ( xPropSetInfo->hasPropertyByName( "ParaAdjust" )
450 0 : && ( beans::PropertyState_DEFAULT_VALUE == xPropState->getPropertyState( "ParaAdjust" ) )
451 : )
452 : {
453 0 : sal_Int32 nIndex = GetExport().GetTextParagraphExport()->GetParagraphPropertyMapper()->getPropertySetMapper()->FindEntryIndex( CTF_SD_SHAPE_PARA_ADJUST );
454 : // TODO : this retrieval of the index should be moved into the ctor, holding the index
455 : // as member, thus saving time.
456 : DBG_ASSERT(-1 != nIndex, "XMLShapeExport::collectShapeAutoStyles: could not obtain the index for the ParaAdjust context id!");
457 :
458 0 : uno::Any aParaAdjustValue = xPropSet->getPropertyValue( "ParaAdjust" );
459 0 : XMLPropertyState aAlignDefaultState( nIndex, aParaAdjustValue );
460 :
461 0 : xPropStates.push_back( aAlignDefaultState );
462 : }
463 0 : }
464 : }
465 :
466 168 : nCount = 0;
467 168 : std::vector< XMLPropertyState >::iterator aIter = xPropStates.begin();
468 168 : std::vector< XMLPropertyState >::iterator aEnd = xPropStates.end();
469 1108 : while( aIter != aEnd )
470 : {
471 772 : if( aIter->mnIndex != -1 )
472 704 : nCount++;
473 772 : ++aIter;
474 : }
475 :
476 168 : if( nCount )
477 : {
478 108 : const OUString aEmpty;
479 108 : aShapeInfo.msTextStyleName = mrExport.GetAutoStylePool()->Find( XML_STYLE_FAMILY_TEXT_PARAGRAPH, aEmpty, xPropStates );
480 108 : if(aShapeInfo.msTextStyleName.isEmpty())
481 : {
482 : // Style did not exist, add it to AutoStalePool
483 50 : aShapeInfo.msTextStyleName = mrExport.GetAutoStylePool()->Add(XML_STYLE_FAMILY_TEXT_PARAGRAPH, aEmpty, xPropStates);
484 108 : }
485 : }
486 180 : }
487 : }
488 :
489 : // prepare animation information if needed
490 180 : if( mxAnimationsExporter.is() )
491 0 : mxAnimationsExporter->prepare( xShape, mrExport );
492 :
493 : // check for special shapes
494 :
495 180 : switch( aShapeInfo.meShapeType )
496 : {
497 : case XmlShapeTypeDrawConnectorShape:
498 : {
499 0 : uno::Reference< uno::XInterface > xConnection;
500 :
501 : // create shape ids for export later
502 0 : xPropSet->getPropertyValue( msStartShape ) >>= xConnection;
503 0 : if( xConnection.is() )
504 0 : mrExport.getInterfaceToIdentifierMapper().registerReference( xConnection );
505 :
506 0 : xPropSet->getPropertyValue( msEndShape ) >>= xConnection;
507 0 : if( xConnection.is() )
508 0 : mrExport.getInterfaceToIdentifierMapper().registerReference( xConnection );
509 0 : break;
510 : }
511 : case XmlShapeTypePresTableShape:
512 : case XmlShapeTypeDrawTableShape:
513 : {
514 : try
515 : {
516 0 : uno::Reference< table::XColumnRowRange > xRange( xSet->getPropertyValue( msModel ), uno::UNO_QUERY_THROW );
517 0 : GetShapeTableExport()->collectTableAutoStyles( xRange );
518 : }
519 0 : catch(const uno::Exception&)
520 : {
521 : OSL_FAIL( "XMLShapeExport::collectShapeAutoStyles(): exception caught while collection auto styles for a table!" );
522 : }
523 0 : break;
524 : }
525 : default:
526 180 : break;
527 : }
528 :
529 180 : maShapeInfos.push_back( aShapeInfo );
530 180 : maCurrentInfo = maShapeInfos.begin();
531 :
532 : // check for shape collections (group shape or 3d scene)
533 : // and collect contained shapes style infos
534 180 : const uno::Reference< drawing::XShape >& xCollection = aShapeInfo.xCustomShapeReplacement.is()
535 180 : ? aShapeInfo.xCustomShapeReplacement : xShape;
536 : {
537 180 : uno::Reference< drawing::XShapes > xShapes( xCollection, uno::UNO_QUERY );
538 180 : if( xShapes.is() )
539 : {
540 0 : collectShapesAutoStyles( xShapes );
541 180 : }
542 180 : }
543 : }
544 :
545 : namespace
546 : {
547 : class NewTextListsHelper
548 : {
549 : public:
550 180 : NewTextListsHelper( SvXMLExport& rExp )
551 180 : : mrExport( rExp )
552 : {
553 180 : mrExport.GetTextParagraphExport()->PushNewTextListsHelper();
554 180 : }
555 :
556 180 : ~NewTextListsHelper()
557 : {
558 180 : mrExport.GetTextParagraphExport()->PopTextListsHelper();
559 180 : }
560 :
561 : private:
562 : SvXMLExport& mrExport;
563 : };
564 : }
565 : // This method exports the given XShape
566 180 : void XMLShapeExport::exportShape(const uno::Reference< drawing::XShape >& xShape,
567 : sal_Int32 nFeatures /* = SEF_DEFAULT */,
568 : com::sun::star::awt::Point* pRefPoint /* = NULL */,
569 : SvXMLAttributeList* pAttrList /* = NULL */ )
570 : {
571 : SAL_WARN("xmloff", xShape->getShapeType());
572 180 : if( maCurrentShapesIter == maShapesInfos.end() )
573 : {
574 : SAL_WARN( "xmloff", "XMLShapeExport::exportShape(): no auto styles where collected before export" );
575 0 : return;
576 : }
577 180 : sal_Int32 nZIndex = 0;
578 180 : uno::Reference< beans::XPropertySet > xSet( xShape, uno::UNO_QUERY );
579 :
580 360 : boost::scoped_ptr< SvXMLElementExport > mpHyperlinkElement;
581 :
582 : // export hyperlinks with <a><shape/></a>. Currently only in draw since draw
583 : // does not support document events
584 180 : if( xSet.is() && (GetExport().GetModelType() == SvtModuleOptions::E_DRAW) ) try
585 : {
586 0 : presentation::ClickAction eAction = presentation::ClickAction_NONE;
587 0 : xSet->getPropertyValue("OnClick") >>= eAction;
588 :
589 0 : if( (eAction == presentation::ClickAction_DOCUMENT) ||
590 0 : (eAction == presentation::ClickAction_BOOKMARK) )
591 : {
592 0 : OUString sURL;
593 0 : xSet->getPropertyValue(msBookmark) >>= sURL;
594 :
595 0 : if( !sURL.isEmpty() )
596 : {
597 0 : mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, sURL );
598 0 : mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
599 0 : mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
600 0 : mpHyperlinkElement.reset( new SvXMLElementExport(mrExport, XML_NAMESPACE_DRAW, XML_A, true, true) );
601 0 : }
602 : }
603 : }
604 0 : catch(const uno::Exception&)
605 : {
606 : SAL_WARN("xmloff", "XMLShapeExport::exportShape(): exception during hyperlink export");
607 : }
608 :
609 180 : if( xSet.is() )
610 180 : xSet->getPropertyValue(msZIndex) >>= nZIndex;
611 :
612 180 : ImplXMLShapeExportInfoVector& aShapeInfoVector = (*maCurrentShapesIter).second;
613 :
614 180 : if( (sal_Int32)aShapeInfoVector.size() <= nZIndex )
615 : {
616 : SAL_WARN( "xmloff", "XMLShapeExport::exportShape(): no shape info collected for a given shape" );
617 0 : return;
618 : }
619 :
620 360 : NewTextListsHelper aNewTextListsHelper( mrExport );
621 :
622 180 : const ImplXMLShapeExportInfo& aShapeInfo = aShapeInfoVector[nZIndex];
623 :
624 : #ifdef DBG_UTIL
625 : // check if this is the correct ShapesInfo
626 : uno::Reference< container::XChild > xChild( xShape, uno::UNO_QUERY );
627 : if( xChild.is() )
628 : {
629 : uno::Reference< drawing::XShapes > xParent( xChild->getParent(), uno::UNO_QUERY );
630 : DBG_ASSERT( xParent.is() && xParent.get() == (*maCurrentShapesIter).first.get(), "XMLShapeExport::exportShape(): Wrong call to XMLShapeExport::seekShapes()" );
631 : }
632 :
633 : // first compute the shapes type
634 : {
635 : XmlShapeType eShapeType(XmlShapeTypeNotYetSet);
636 : ImpCalcShapeType(xShape, eShapeType);
637 :
638 : SAL_WARN_IF( eShapeType != aShapeInfo.meShapeType, "xmloff", "exportShape callings do not correspond to collectShapeAutoStyles calls!: " << xShape->getShapeType() );
639 : }
640 : #endif
641 :
642 : // collect animation information if needed
643 180 : if( mxAnimationsExporter.is() )
644 0 : mxAnimationsExporter->collect( xShape, mrExport );
645 :
646 : /* Export shapes name if he has one (#i51726#)
647 : Export of the shape name for text documents only if the OpenDocument
648 : file format is written - exceptions are group shapes.
649 : Note: Writer documents in OpenOffice.org file format doesn't contain
650 : any names for shapes, except for group shapes.
651 : */
652 : {
653 526 : if ( ( GetExport().GetModelType() != SvtModuleOptions::E_WRITER &&
654 332 : GetExport().GetModelType() != SvtModuleOptions::E_WRITERWEB &&
655 180 : GetExport().GetModelType() != SvtModuleOptions::E_WRITERGLOBAL ) ||
656 14 : ( GetExport().getExportFlags() & EXPORT_OASIS ) != 0 ||
657 360 : aShapeInfo.meShapeType == XmlShapeTypeDrawGroupShape ||
658 0 : ( aShapeInfo.meShapeType == XmlShapeTypeDrawCustomShape &&
659 0 : aShapeInfo.xCustomShapeReplacement.is() ) )
660 : {
661 180 : uno::Reference< container::XNamed > xNamed( xShape, uno::UNO_QUERY );
662 180 : if( xNamed.is() )
663 : {
664 180 : const OUString aName( xNamed->getName() );
665 180 : if( !aName.isEmpty() )
666 18 : mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_NAME, aName );
667 180 : }
668 : }
669 : }
670 :
671 : // export style name
672 180 : if( !aShapeInfo.msStyleName.isEmpty() )
673 : {
674 144 : if(XML_STYLE_FAMILY_SD_GRAPHICS_ID == aShapeInfo.mnFamily)
675 64 : mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_STYLE_NAME, mrExport.EncodeStyleName( aShapeInfo.msStyleName) );
676 : else
677 80 : mrExport.AddAttribute(XML_NAMESPACE_PRESENTATION, XML_STYLE_NAME, mrExport.EncodeStyleName( aShapeInfo.msStyleName) );
678 : }
679 :
680 : // export text style name
681 180 : if( !aShapeInfo.msTextStyleName.isEmpty() )
682 : {
683 108 : mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_TEXT_STYLE_NAME, aShapeInfo.msTextStyleName );
684 : }
685 :
686 : // export shapes id if needed
687 : {
688 180 : uno::Reference< uno::XInterface > xRef( xShape, uno::UNO_QUERY );
689 180 : const OUString& rShapeId = mrExport.getInterfaceToIdentifierMapper().getIdentifier( xRef );
690 180 : if( !rShapeId.isEmpty() )
691 : {
692 0 : mrExport.AddAttributeIdLegacy(XML_NAMESPACE_DRAW, rShapeId);
693 180 : }
694 : }
695 :
696 : // export layer information
697 180 : if( IsLayerExportEnabled() )
698 : {
699 : // check for group or scene shape and not export layer if this is one
700 150 : uno::Reference< drawing::XShapes > xShapes( xShape, uno::UNO_QUERY );
701 150 : if( !xShapes.is() )
702 : {
703 : try
704 : {
705 150 : uno::Reference< beans::XPropertySet > xProps( xShape, uno::UNO_QUERY );
706 300 : OUString aLayerName;
707 150 : xProps->getPropertyValue("LayerName") >>= aLayerName;
708 300 : mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_LAYER, aLayerName );
709 :
710 : }
711 0 : catch(const uno::Exception&)
712 : {
713 : OSL_FAIL( "could not export layer name for shape!" );
714 : }
715 150 : }
716 : }
717 :
718 : // export draw:display (do not export in ODF 1.2 or older)
719 180 : if( xSet.is() && ( mrExport.getDefaultVersion() > SvtSaveOptions::ODFVER_012 ) )
720 : {
721 348 : if( aShapeInfo.meShapeType != XmlShapeTypeDrawPageShape && aShapeInfo.meShapeType != XmlShapeTypePresPageShape &&
722 300 : aShapeInfo.meShapeType != XmlShapeTypeHandoutShape && aShapeInfo.meShapeType != XmlShapeTypeDrawChartShape )
723 :
724 : try
725 : {
726 124 : bool bVisible = true;
727 124 : bool bPrintable = true;
728 :
729 124 : xSet->getPropertyValue(msVisible) >>= bVisible;
730 120 : xSet->getPropertyValue(msPrintable) >>= bPrintable;
731 :
732 120 : XMLTokenEnum eDisplayToken = XML_TOKEN_INVALID;
733 120 : const unsigned short nDisplay = (bVisible ? 2 : 0) | (bPrintable ? 1 : 0);
734 120 : switch( nDisplay )
735 : {
736 0 : case 0: eDisplayToken = XML_NONE; break;
737 0 : case 1: eDisplayToken = XML_PRINTER; break;
738 0 : case 2: eDisplayToken = XML_SCREEN; break;
739 : // case 3: eDisplayToken = XML_ALWAYS break; this is the default
740 : }
741 :
742 120 : if( eDisplayToken != XML_TOKEN_INVALID )
743 0 : mrExport.AddAttribute(XML_NAMESPACE_DRAW_EXT, XML_DISPLAY, eDisplayToken );
744 : }
745 4 : catch(const uno::Exception&)
746 : {
747 : OSL_FAIL( "XMLShapeExport::exportShape(), exception caught!" );
748 : }
749 : }
750 :
751 : // #82003# test export count
752 : // #91587# ALWAYS increment since now ALL to be exported shapes are counted.
753 180 : if(mrExport.GetShapeExport()->IsHandleProgressBarEnabled())
754 : {
755 150 : mrExport.GetProgressBarHelper()->Increment();
756 : }
757 :
758 180 : onExport( xShape );
759 :
760 : // export shape element
761 180 : switch(aShapeInfo.meShapeType)
762 : {
763 : case XmlShapeTypeDrawRectangleShape:
764 : {
765 4 : ImpExportRectangleShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
766 4 : break;
767 : }
768 : case XmlShapeTypeDrawEllipseShape:
769 : {
770 0 : ImpExportEllipseShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
771 0 : break;
772 : }
773 : case XmlShapeTypeDrawLineShape:
774 : {
775 10 : ImpExportLineShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
776 10 : break;
777 : }
778 : case XmlShapeTypeDrawPolyPolygonShape: // closed PolyPolygon
779 : case XmlShapeTypeDrawPolyLineShape: // open PolyPolygon
780 : case XmlShapeTypeDrawClosedBezierShape: // closed tools::PolyPolygon containing curves
781 : case XmlShapeTypeDrawOpenBezierShape: // open tools::PolyPolygon containing curves
782 : {
783 0 : ImpExportPolygonShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
784 0 : break;
785 : }
786 :
787 : case XmlShapeTypeDrawTextShape:
788 : case XmlShapeTypePresTitleTextShape:
789 : case XmlShapeTypePresOutlinerShape:
790 : case XmlShapeTypePresSubtitleShape:
791 : case XmlShapeTypePresNotesShape:
792 : case XmlShapeTypePresHeaderShape:
793 : case XmlShapeTypePresFooterShape:
794 : case XmlShapeTypePresSlideNumberShape:
795 : case XmlShapeTypePresDateTimeShape:
796 : {
797 98 : ImpExportTextBoxShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
798 98 : break;
799 : }
800 :
801 : case XmlShapeTypeDrawGraphicObjectShape:
802 : case XmlShapeTypePresGraphicObjectShape:
803 : {
804 0 : ImpExportGraphicObjectShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
805 0 : break;
806 : }
807 :
808 : case XmlShapeTypeDrawChartShape:
809 : case XmlShapeTypePresChartShape:
810 : {
811 8 : ImpExportChartShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint, pAttrList );
812 8 : break;
813 : }
814 :
815 : case XmlShapeTypeDrawControlShape:
816 : {
817 0 : ImpExportControlShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
818 0 : break;
819 : }
820 :
821 : case XmlShapeTypeDrawConnectorShape:
822 : {
823 0 : ImpExportConnectorShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
824 0 : break;
825 : }
826 :
827 : case XmlShapeTypeDrawMeasureShape:
828 : {
829 0 : ImpExportMeasureShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
830 0 : break;
831 : }
832 :
833 : case XmlShapeTypeDrawOLE2Shape:
834 : case XmlShapeTypePresOLE2Shape:
835 : case XmlShapeTypeDrawSheetShape:
836 : case XmlShapeTypePresSheetShape:
837 : {
838 0 : ImpExportOLE2Shape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
839 0 : break;
840 : }
841 :
842 : case XmlShapeTypePresTableShape:
843 : case XmlShapeTypeDrawTableShape:
844 : {
845 0 : ImpExportTableShape( xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
846 0 : break;
847 : }
848 :
849 : case XmlShapeTypeDrawPageShape:
850 : case XmlShapeTypePresPageShape:
851 : case XmlShapeTypeHandoutShape:
852 : {
853 48 : ImpExportPageShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
854 48 : break;
855 : }
856 :
857 : case XmlShapeTypeDrawCaptionShape:
858 : {
859 4 : ImpExportCaptionShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
860 4 : break;
861 : }
862 :
863 : case XmlShapeTypeDraw3DCubeObject:
864 : case XmlShapeTypeDraw3DSphereObject:
865 : case XmlShapeTypeDraw3DLatheObject:
866 : case XmlShapeTypeDraw3DExtrudeObject:
867 : {
868 0 : ImpExport3DShape(xShape, aShapeInfo.meShapeType);
869 0 : break;
870 : }
871 :
872 : case XmlShapeTypeDraw3DSceneObject:
873 : {
874 0 : ImpExport3DSceneShape( xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
875 0 : break;
876 : }
877 :
878 : case XmlShapeTypeDrawGroupShape:
879 : {
880 : // empty group
881 0 : ImpExportGroupShape( xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
882 0 : break;
883 : }
884 :
885 : case XmlShapeTypeDrawFrameShape:
886 : {
887 0 : ImpExportFrameShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
888 0 : break;
889 : }
890 :
891 : case XmlShapeTypeDrawAppletShape:
892 : {
893 0 : ImpExportAppletShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
894 0 : break;
895 : }
896 :
897 : case XmlShapeTypeDrawPluginShape:
898 : {
899 0 : ImpExportPluginShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
900 0 : break;
901 : }
902 :
903 : case XmlShapeTypeDrawCustomShape:
904 : {
905 4 : if ( aShapeInfo.xCustomShapeReplacement.is() )
906 0 : ImpExportGroupShape( aShapeInfo.xCustomShapeReplacement, XmlShapeTypeDrawGroupShape, nFeatures, pRefPoint );
907 : else
908 4 : ImpExportCustomShape( xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
909 4 : break;
910 : }
911 :
912 : case XmlShapeTypePresMediaShape:
913 : case XmlShapeTypeDrawMediaShape:
914 : {
915 4 : ImpExportMediaShape( xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
916 4 : break;
917 : }
918 :
919 : case XmlShapeTypePresOrgChartShape:
920 : case XmlShapeTypeUnknown:
921 : case XmlShapeTypeNotYetSet:
922 : default:
923 : {
924 : // this should never happen and is an error
925 : OSL_FAIL("XMLEXP: WriteShape: unknown or unexpected type of shape in export!");
926 0 : break;
927 : }
928 : }
929 :
930 180 : mpHyperlinkElement.reset();
931 :
932 : // #97489# #97111#
933 : // if there was an error and no element for the shape was exported
934 : // we need to clear the attribute list or the attributes will be
935 : // set on the next exported element, which can result in corrupt
936 : // xml files due to duplicate attributes
937 :
938 180 : mrExport.CheckAttrList(); // asserts in non pro if we have attributes left
939 360 : mrExport.ClearAttrList(); // clears the attributes
940 : }
941 :
942 : // This method collects all automatic styles for the shapes inside the given XShapes collection
943 28 : void XMLShapeExport::collectShapesAutoStyles( const uno::Reference < drawing::XShapes >& xShapes )
944 : {
945 28 : ShapesInfos::iterator aOldCurrentShapesIter = maCurrentShapesIter;
946 28 : seekShapes( xShapes );
947 :
948 28 : uno::Reference< drawing::XShape > xShape;
949 28 : const sal_Int32 nShapeCount(xShapes->getCount());
950 178 : for(sal_Int32 nShapeId = 0; nShapeId < nShapeCount; nShapeId++)
951 : {
952 150 : xShapes->getByIndex(nShapeId) >>= xShape;
953 : SAL_WARN_IF( !xShape.is(), "xmloff", "Shape without a XShape?" );
954 150 : if(!xShape.is())
955 0 : continue;
956 :
957 150 : collectShapeAutoStyles( xShape );
958 : }
959 :
960 28 : maCurrentShapesIter = aOldCurrentShapesIter;
961 28 : }
962 :
963 : // This method exports all XShape inside the given XShapes collection
964 28 : void XMLShapeExport::exportShapes( const uno::Reference < drawing::XShapes >& xShapes, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */ )
965 : {
966 28 : ShapesInfos::iterator aOldCurrentShapesIter = maCurrentShapesIter;
967 28 : seekShapes( xShapes );
968 :
969 28 : uno::Reference< drawing::XShape > xShape;
970 28 : const sal_Int32 nShapeCount(xShapes->getCount());
971 178 : for(sal_Int32 nShapeId = 0; nShapeId < nShapeCount; nShapeId++)
972 : {
973 150 : xShapes->getByIndex(nShapeId) >>= xShape;
974 : SAL_WARN_IF( !xShape.is(), "xmloff", "Shape without a XShape?" );
975 150 : if(!xShape.is())
976 0 : continue;
977 :
978 150 : exportShape( xShape, nFeatures, pRefPoint );
979 : }
980 :
981 28 : maCurrentShapesIter = aOldCurrentShapesIter;
982 28 : }
983 :
984 288 : void XMLShapeExport::seekShapes( const uno::Reference< drawing::XShapes >& xShapes ) throw()
985 : {
986 288 : if( xShapes.is() )
987 : {
988 288 : maCurrentShapesIter = maShapesInfos.find( xShapes );
989 288 : if( maCurrentShapesIter == maShapesInfos.end() )
990 : {
991 204 : ImplXMLShapeExportInfoVector aNewInfoVector;
992 204 : aNewInfoVector.resize( (ShapesInfos::size_type) xShapes->getCount() );
993 204 : maShapesInfos[ xShapes ] = aNewInfoVector;
994 :
995 204 : maCurrentShapesIter = maShapesInfos.find( xShapes );
996 :
997 204 : DBG_ASSERT( maCurrentShapesIter != maShapesInfos.end(), "XMLShapeExport::seekShapes(): insert into stl::map failed" );
998 : }
999 :
1000 : DBG_ASSERT( (*maCurrentShapesIter).second.size() == (ShapesInfos::size_type)xShapes->getCount(), "XMLShapeExport::seekShapes(): XShapes size varied between calls" );
1001 :
1002 : }
1003 : else
1004 : {
1005 0 : maCurrentShapesIter = maShapesInfos.end();
1006 : }
1007 288 : }
1008 :
1009 752 : void XMLShapeExport::exportAutoStyles()
1010 : {
1011 : // export all autostyle infos
1012 :
1013 : // ...for graphic
1014 : {
1015 752 : GetExport().GetAutoStylePool()->exportXML(
1016 : XML_STYLE_FAMILY_SD_GRAPHICS_ID
1017 752 : , GetExport().GetDocHandler(),
1018 752 : GetExport().GetMM100UnitConverter(),
1019 752 : GetExport().GetNamespaceMap()
1020 752 : );
1021 : }
1022 :
1023 : // ...for presentation
1024 : {
1025 752 : GetExport().GetAutoStylePool()->exportXML(
1026 : XML_STYLE_FAMILY_SD_PRESENTATION_ID
1027 752 : , GetExport().GetDocHandler(),
1028 752 : GetExport().GetMM100UnitConverter(),
1029 752 : GetExport().GetNamespaceMap()
1030 752 : );
1031 : }
1032 :
1033 752 : if( mxShapeTableExport.is() )
1034 752 : mxShapeTableExport->exportAutoStyles();
1035 752 : }
1036 :
1037 : /// returns the export property mapper for external chaining
1038 2620 : SvXMLExportPropertyMapper* XMLShapeExport::CreateShapePropMapper(
1039 : SvXMLExport& rExport )
1040 : {
1041 2620 : rtl::Reference< XMLPropertyHandlerFactory > xFactory = new XMLSdPropHdlFactory( rExport.GetModel(), rExport );
1042 5240 : rtl::Reference < XMLPropertySetMapper > xMapper = new XMLShapePropertySetMapper( xFactory, true );
1043 2620 : rExport.GetTextParagraphExport(); // get or create text paragraph export
1044 : SvXMLExportPropertyMapper* pResult =
1045 2620 : new XMLShapeExportPropertyMapper( xMapper, rExport );
1046 : // chain text attributes
1047 5240 : return pResult;
1048 : }
1049 :
1050 180 : void XMLShapeExport::ImpCalcShapeType(const uno::Reference< drawing::XShape >& xShape,
1051 : XmlShapeType& eShapeType)
1052 : {
1053 : // set in every case, so init here
1054 180 : eShapeType = XmlShapeTypeUnknown;
1055 :
1056 180 : uno::Reference< drawing::XShapeDescriptor > xShapeDescriptor(xShape, uno::UNO_QUERY);
1057 180 : if(xShapeDescriptor.is())
1058 : {
1059 180 : OUString aType(xShapeDescriptor->getShapeType());
1060 :
1061 180 : if(aType.match("com.sun.star."))
1062 : {
1063 180 : if(aType.match("drawing.", 13))
1064 : {
1065 : // drawing shapes
1066 34 : if (aType.match("Rectangle", 21)) { eShapeType = XmlShapeTypeDrawRectangleShape; }
1067 :
1068 : // #i72177# Note: Correcting CustomShape, CustomShape->Custom, len from 9 (was wrong anyways) to 6.
1069 : // As can be seen at the other compares, the appendix "Shape" is left out of the comparison.
1070 30 : else if(aType.match("Custom", 21)) { eShapeType = XmlShapeTypeDrawCustomShape; }
1071 :
1072 26 : else if(aType.match("Ellipse", 21)) { eShapeType = XmlShapeTypeDrawEllipseShape; }
1073 26 : else if(aType.match("Control", 21)) { eShapeType = XmlShapeTypeDrawControlShape; }
1074 26 : else if(aType.match("Connector", 21)) { eShapeType = XmlShapeTypeDrawConnectorShape; }
1075 26 : else if(aType.match("Measure", 21)) { eShapeType = XmlShapeTypeDrawMeasureShape; }
1076 26 : else if(aType.match("Line", 21)) { eShapeType = XmlShapeTypeDrawLineShape; }
1077 :
1078 : // #i72177# Note: This covers two types by purpose, PolyPolygonShape and PolyPolygonPathShape
1079 16 : else if(aType.match("PolyPolygon", 21)) { eShapeType = XmlShapeTypeDrawPolyPolygonShape; }
1080 :
1081 : // #i72177# Note: This covers two types by purpose, PolyLineShape and PolyLinePathShape
1082 16 : else if(aType.match("PolyLine", 21)) { eShapeType = XmlShapeTypeDrawPolyLineShape; }
1083 :
1084 16 : else if(aType.match("OpenBezier", 21)) { eShapeType = XmlShapeTypeDrawOpenBezierShape; }
1085 16 : else if(aType.match("ClosedBezier", 21)) { eShapeType = XmlShapeTypeDrawClosedBezierShape; }
1086 :
1087 : // #i72177# FreeHand (opened and closed) now supports the types OpenFreeHandShape and
1088 : // ClosedFreeHandShape respectively. Represent them as bezier shapes
1089 16 : else if(aType.match("OpenFreeHand", 21)) { eShapeType = XmlShapeTypeDrawOpenBezierShape; }
1090 16 : else if(aType.match("ClosedFreeHand", 21)) { eShapeType = XmlShapeTypeDrawClosedBezierShape; }
1091 :
1092 16 : else if(aType.match("GraphicObject", 21)) { eShapeType = XmlShapeTypeDrawGraphicObjectShape; }
1093 16 : else if(aType.match("Group", 21)) { eShapeType = XmlShapeTypeDrawGroupShape; }
1094 16 : else if(aType.match("Text", 21)) { eShapeType = XmlShapeTypeDrawTextShape; }
1095 16 : else if(aType.match("OLE2", 21))
1096 : {
1097 8 : eShapeType = XmlShapeTypeDrawOLE2Shape;
1098 :
1099 : // get info about presentation shape
1100 8 : uno::Reference <beans::XPropertySet> xPropSet(xShape, uno::UNO_QUERY);
1101 :
1102 8 : if(xPropSet.is())
1103 : {
1104 8 : OUString sCLSID;
1105 8 : if(xPropSet->getPropertyValue("CLSID") >>= sCLSID)
1106 : {
1107 16 : if (sCLSID.equals(mrExport.GetChartExport()->getChartCLSID()) ||
1108 8 : sCLSID.equals(OUString( SvGlobalName( SO3_RPTCH_CLASSID ).GetHexName())))
1109 : {
1110 8 : eShapeType = XmlShapeTypeDrawChartShape;
1111 : }
1112 0 : else if (sCLSID.equals(OUString( SvGlobalName( SO3_SC_CLASSID ).GetHexName())))
1113 : {
1114 0 : eShapeType = XmlShapeTypeDrawSheetShape;
1115 : }
1116 : else
1117 : {
1118 : // general OLE2 Object
1119 : }
1120 8 : }
1121 8 : }
1122 : }
1123 8 : else if(aType.match("Page", 21)) { eShapeType = XmlShapeTypeDrawPageShape; }
1124 8 : else if(aType.match("Frame", 21)) { eShapeType = XmlShapeTypeDrawFrameShape; }
1125 8 : else if(aType.match("Caption", 21)) { eShapeType = XmlShapeTypeDrawCaptionShape; }
1126 4 : else if(aType.match("Plugin", 21)) { eShapeType = XmlShapeTypeDrawPluginShape; }
1127 4 : else if(aType.match("Applet", 21)) { eShapeType = XmlShapeTypeDrawAppletShape; }
1128 4 : else if(aType.match("MediaShape", 21)) { eShapeType = XmlShapeTypeDrawMediaShape; }
1129 0 : else if(aType.match("TableShape", 21)) { eShapeType = XmlShapeTypeDrawTableShape; }
1130 :
1131 : // 3D shapes
1132 0 : else if(aType.match("Scene", 21 + 7)) { eShapeType = XmlShapeTypeDraw3DSceneObject; }
1133 0 : else if(aType.match("Cube", 21 + 7)) { eShapeType = XmlShapeTypeDraw3DCubeObject; }
1134 0 : else if(aType.match("Sphere", 21 + 7)) { eShapeType = XmlShapeTypeDraw3DSphereObject; }
1135 0 : else if(aType.match("Lathe", 21 + 7)) { eShapeType = XmlShapeTypeDraw3DLatheObject; }
1136 0 : else if(aType.match("Extrude", 21 + 7)) { eShapeType = XmlShapeTypeDraw3DExtrudeObject; }
1137 : }
1138 146 : else if(aType.match("presentation.", 13))
1139 : {
1140 : // presentation shapes
1141 146 : if (aType.match("TitleText", 26)) { eShapeType = XmlShapeTypePresTitleTextShape; }
1142 136 : else if(aType.match("Outliner", 26)) { eShapeType = XmlShapeTypePresOutlinerShape; }
1143 132 : else if(aType.match("Subtitle", 26)) { eShapeType = XmlShapeTypePresSubtitleShape; }
1144 126 : else if(aType.match("GraphicObject", 26)) { eShapeType = XmlShapeTypePresGraphicObjectShape; }
1145 126 : else if(aType.match("Page", 26)) { eShapeType = XmlShapeTypePresPageShape; }
1146 114 : else if(aType.match("OLE2", 26))
1147 : {
1148 0 : eShapeType = XmlShapeTypePresOLE2Shape;
1149 :
1150 : // get info about presentation shape
1151 0 : uno::Reference <beans::XPropertySet> xPropSet(xShape, uno::UNO_QUERY);
1152 :
1153 0 : if(xPropSet.is()) try
1154 : {
1155 0 : OUString sCLSID;
1156 0 : if(xPropSet->getPropertyValue("CLSID") >>= sCLSID)
1157 : {
1158 0 : if( sCLSID.equals(OUString( SvGlobalName( SO3_SC_CLASSID ).GetHexName())) )
1159 : {
1160 0 : eShapeType = XmlShapeTypePresSheetShape;
1161 : }
1162 0 : }
1163 : }
1164 0 : catch(const uno::Exception&)
1165 : {
1166 : SAL_WARN( "xmloff", "XMLShapeExport::ImpCalcShapeType(), expected ole shape to have the CLSID property?" );
1167 0 : }
1168 : }
1169 114 : else if(aType.match("Chart", 26)) { eShapeType = XmlShapeTypePresChartShape; }
1170 114 : else if(aType.match("OrgChart", 26)) { eShapeType = XmlShapeTypePresOrgChartShape; }
1171 114 : else if(aType.match("CalcShape", 26)) { eShapeType = XmlShapeTypePresSheetShape; }
1172 114 : else if(aType.match("TableShape", 26)) { eShapeType = XmlShapeTypePresTableShape; }
1173 114 : else if(aType.match("Notes", 26)) { eShapeType = XmlShapeTypePresNotesShape; }
1174 102 : else if(aType.match("HandoutShape", 26)) { eShapeType = XmlShapeTypeHandoutShape; }
1175 66 : else if(aType.match("HeaderShape", 26)) { eShapeType = XmlShapeTypePresHeaderShape; }
1176 54 : else if(aType.match("FooterShape", 26)) { eShapeType = XmlShapeTypePresFooterShape; }
1177 36 : else if(aType.match("SlideNumberShape", 26)) { eShapeType = XmlShapeTypePresSlideNumberShape; }
1178 18 : else if(aType.match("DateTimeShape", 26)) { eShapeType = XmlShapeTypePresDateTimeShape; }
1179 0 : else if(aType.match("MediaShape", 26)) { eShapeType = XmlShapeTypePresMediaShape; }
1180 : }
1181 180 : }
1182 180 : }
1183 180 : }
1184 :
1185 : extern SvXMLEnumMapEntry aXML_GlueAlignment_EnumMap[];
1186 : extern SvXMLEnumMapEntry aXML_GlueEscapeDirection_EnumMap[];
1187 :
1188 : /** exports all user defined glue points */
1189 128 : void XMLShapeExport::ImpExportGluePoints( const uno::Reference< drawing::XShape >& xShape )
1190 : {
1191 128 : uno::Reference< drawing::XGluePointsSupplier > xSupplier( xShape, uno::UNO_QUERY );
1192 128 : if( !xSupplier.is() )
1193 0 : return;
1194 :
1195 256 : uno::Reference< container::XIdentifierAccess > xGluePoints( xSupplier->getGluePoints(), uno::UNO_QUERY );
1196 128 : if( !xGluePoints.is() )
1197 0 : return;
1198 :
1199 128 : drawing::GluePoint2 aGluePoint;
1200 :
1201 256 : uno::Sequence< sal_Int32 > aIdSequence( xGluePoints->getIdentifiers() );
1202 :
1203 128 : const sal_Int32 nCount = aIdSequence.getLength();
1204 640 : for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
1205 : {
1206 512 : const sal_Int32 nIdentifier = aIdSequence[nIndex];
1207 512 : if( (xGluePoints->getByIdentifier( nIdentifier ) >>= aGluePoint) && aGluePoint.IsUserDefined )
1208 : {
1209 : // export only user defined glue points
1210 :
1211 0 : const OUString sId( OUString::number( nIdentifier ) );
1212 0 : mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_ID, sId );
1213 :
1214 0 : mrExport.GetMM100UnitConverter().convertMeasureToXML(msBuffer,
1215 0 : aGluePoint.Position.X);
1216 0 : mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_X, msBuffer.makeStringAndClear());
1217 :
1218 0 : mrExport.GetMM100UnitConverter().convertMeasureToXML(msBuffer,
1219 0 : aGluePoint.Position.Y);
1220 0 : mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_Y, msBuffer.makeStringAndClear());
1221 :
1222 0 : if( !aGluePoint.IsRelative )
1223 : {
1224 0 : SvXMLUnitConverter::convertEnum( msBuffer, aGluePoint.PositionAlignment, aXML_GlueAlignment_EnumMap );
1225 0 : mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_ALIGN, msBuffer.makeStringAndClear() );
1226 : }
1227 :
1228 0 : if( aGluePoint.Escape != drawing::EscapeDirection_SMART )
1229 : {
1230 0 : SvXMLUnitConverter::convertEnum( msBuffer, aGluePoint.Escape, aXML_GlueEscapeDirection_EnumMap );
1231 0 : mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_ESCAPE_DIRECTION, msBuffer.makeStringAndClear() );
1232 : }
1233 :
1234 0 : SvXMLElementExport aEventsElemt(mrExport, XML_NAMESPACE_DRAW, XML_GLUE_POINT, true, true);
1235 : }
1236 128 : }
1237 : }
1238 :
1239 94 : void XMLShapeExport::ExportGraphicDefaults()
1240 : {
1241 94 : XMLStyleExport aStEx(mrExport, OUString(), mrExport.GetAutoStylePool().get());
1242 :
1243 : // construct PropertySetMapper
1244 188 : rtl::Reference< SvXMLExportPropertyMapper > xPropertySetMapper( CreateShapePropMapper( mrExport ) );
1245 94 : static_cast<XMLShapeExportPropertyMapper*>(xPropertySetMapper.get())->SetAutoStyles( false );
1246 :
1247 : // chain text attributes
1248 94 : xPropertySetMapper->ChainExportMapper(XMLTextParagraphExport::CreateParaExtPropMapper(mrExport));
1249 :
1250 : // chain special Writer/text frame default attributes
1251 94 : xPropertySetMapper->ChainExportMapper(XMLTextParagraphExport::CreateParaDefaultExtPropMapper(mrExport));
1252 :
1253 : // write graphic family default style
1254 188 : uno::Reference< lang::XMultiServiceFactory > xFact( mrExport.GetModel(), uno::UNO_QUERY );
1255 94 : if( xFact.is() )
1256 : {
1257 : try
1258 : {
1259 94 : uno::Reference< beans::XPropertySet > xDefaults( xFact->createInstance("com.sun.star.drawing.Defaults"), uno::UNO_QUERY );
1260 94 : if( xDefaults.is() )
1261 : {
1262 94 : aStEx.exportDefaultStyle( xDefaults, OUString(XML_STYLE_FAMILY_SD_GRAPHICS_NAME), xPropertySetMapper );
1263 :
1264 : // write graphic family styles
1265 94 : aStEx.exportStyleFamily("graphics", OUString(XML_STYLE_FAMILY_SD_GRAPHICS_NAME), xPropertySetMapper, false, XML_STYLE_FAMILY_SD_GRAPHICS_ID);
1266 94 : }
1267 : }
1268 0 : catch(const lang::ServiceNotRegisteredException&)
1269 : {
1270 : }
1271 94 : }
1272 94 : }
1273 :
1274 164 : void XMLShapeExport::onExport( const com::sun::star::uno::Reference < com::sun::star::drawing::XShape >& )
1275 : {
1276 164 : }
1277 :
1278 856 : const rtl::Reference< XMLTableExport >& XMLShapeExport::GetShapeTableExport()
1279 : {
1280 856 : if( !mxShapeTableExport.is() )
1281 : {
1282 834 : rtl::Reference< XMLPropertyHandlerFactory > xFactory( new XMLSdPropHdlFactory( mrExport.GetModel(), mrExport ) );
1283 1668 : rtl::Reference < XMLPropertySetMapper > xMapper( new XMLShapePropertySetMapper( xFactory.get(), true ) );
1284 834 : mrExport.GetTextParagraphExport(); // get or create text paragraph export
1285 1668 : rtl::Reference< SvXMLExportPropertyMapper > xPropertySetMapper( new XMLShapeExportPropertyMapper( xMapper, mrExport ) );
1286 1668 : mxShapeTableExport = new XMLTableExport( mrExport, xPropertySetMapper, xFactory );
1287 : }
1288 :
1289 856 : return mxShapeTableExport;
1290 : }
1291 :
1292 170 : void XMLShapeExport::ImpExportNewTrans(const uno::Reference< beans::XPropertySet >& xPropSet,
1293 : sal_Int32 nFeatures, awt::Point* pRefPoint)
1294 : {
1295 : // get matrix
1296 170 : ::basegfx::B2DHomMatrix aMatrix;
1297 170 : ImpExportNewTrans_GetB2DHomMatrix(aMatrix, xPropSet);
1298 :
1299 : // decompose and correct abour pRefPoint
1300 340 : ::basegfx::B2DTuple aTRScale;
1301 170 : double fTRShear(0.0);
1302 170 : double fTRRotate(0.0);
1303 340 : ::basegfx::B2DTuple aTRTranslate;
1304 170 : ImpExportNewTrans_DecomposeAndRefPoint(aMatrix, aTRScale, fTRShear, fTRRotate, aTRTranslate, pRefPoint);
1305 :
1306 : // use features and write
1307 340 : ImpExportNewTrans_FeaturesAndWrite(aTRScale, fTRShear, fTRRotate, aTRTranslate, nFeatures);
1308 170 : }
1309 :
1310 180 : void XMLShapeExport::ImpExportNewTrans_GetB2DHomMatrix(::basegfx::B2DHomMatrix& rMatrix,
1311 : const uno::Reference< beans::XPropertySet >& xPropSet)
1312 : {
1313 : /* Get <TransformationInHoriL2R>, if it exist
1314 : and if the document is exported into the OpenOffice.org file format.
1315 : This property only exists at service com::sun::star::text::Shape - the
1316 : Writer UNO service for shapes.
1317 : This code is needed, because the positioning attributes in the
1318 : OpenOffice.org file format are given in horizontal left-to-right layout
1319 : regardless the layout direction the shape is in. In the OASIS Open Office
1320 : file format the positioning attributes are correctly given in the layout
1321 : direction the shape is in. Thus, this code provides the conversion from
1322 : the OASIS Open Office file format to the OpenOffice.org file format. (#i28749#)
1323 : */
1324 180 : uno::Any aAny;
1325 540 : if ( ( GetExport().getExportFlags() & EXPORT_OASIS ) == 0 &&
1326 180 : xPropSet->getPropertySetInfo()->hasPropertyByName("TransformationInHoriL2R") )
1327 : {
1328 0 : aAny = xPropSet->getPropertyValue("TransformationInHoriL2R");
1329 : }
1330 : else
1331 : {
1332 180 : aAny = xPropSet->getPropertyValue("Transformation");
1333 : }
1334 180 : drawing::HomogenMatrix3 aMatrix;
1335 180 : aAny >>= aMatrix;
1336 :
1337 180 : rMatrix.set(0, 0, aMatrix.Line1.Column1);
1338 180 : rMatrix.set(0, 1, aMatrix.Line1.Column2);
1339 180 : rMatrix.set(0, 2, aMatrix.Line1.Column3);
1340 180 : rMatrix.set(1, 0, aMatrix.Line2.Column1);
1341 180 : rMatrix.set(1, 1, aMatrix.Line2.Column2);
1342 180 : rMatrix.set(1, 2, aMatrix.Line2.Column3);
1343 180 : rMatrix.set(2, 0, aMatrix.Line3.Column1);
1344 180 : rMatrix.set(2, 1, aMatrix.Line3.Column2);
1345 180 : rMatrix.set(2, 2, aMatrix.Line3.Column3);
1346 180 : }
1347 :
1348 180 : void XMLShapeExport::ImpExportNewTrans_DecomposeAndRefPoint(const ::basegfx::B2DHomMatrix& rMatrix, ::basegfx::B2DTuple& rTRScale,
1349 : double& fTRShear, double& fTRRotate, ::basegfx::B2DTuple& rTRTranslate, com::sun::star::awt::Point* pRefPoint)
1350 : {
1351 : // decompose matrix
1352 180 : rMatrix.decompose(rTRScale, rTRTranslate, fTRRotate, fTRShear);
1353 :
1354 : // correct translation about pRefPoint
1355 180 : if(pRefPoint)
1356 : {
1357 4 : rTRTranslate -= ::basegfx::B2DTuple(pRefPoint->X, pRefPoint->Y);
1358 : }
1359 180 : }
1360 :
1361 170 : void XMLShapeExport::ImpExportNewTrans_FeaturesAndWrite(::basegfx::B2DTuple& rTRScale, double fTRShear,
1362 : double fTRRotate, ::basegfx::B2DTuple& rTRTranslate, const sal_Int32 nFeatures)
1363 : {
1364 : // always write Size (rTRScale) since this statement carries the union
1365 : // of the object
1366 170 : OUString aStr;
1367 340 : OUStringBuffer sStringBuffer;
1368 340 : ::basegfx::B2DTuple aTRScale(rTRScale);
1369 :
1370 : // svg: width
1371 170 : if(!(nFeatures & SEF_EXPORT_WIDTH))
1372 : {
1373 0 : aTRScale.setX(1.0);
1374 : }
1375 : else
1376 : {
1377 170 : if( aTRScale.getX() > 0.0 )
1378 170 : aTRScale.setX(aTRScale.getX() - 1.0);
1379 0 : else if( aTRScale.getX() < 0.0 )
1380 0 : aTRScale.setX(aTRScale.getX() + 1.0);
1381 : }
1382 :
1383 170 : mrExport.GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
1384 340 : FRound(aTRScale.getX()));
1385 170 : aStr = sStringBuffer.makeStringAndClear();
1386 170 : mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_WIDTH, aStr);
1387 :
1388 : // svg: height
1389 170 : if(!(nFeatures & SEF_EXPORT_HEIGHT))
1390 : {
1391 0 : aTRScale.setY(1.0);
1392 : }
1393 : else
1394 : {
1395 170 : if( aTRScale.getY() > 0.0 )
1396 170 : aTRScale.setY(aTRScale.getY() - 1.0);
1397 0 : else if( aTRScale.getY() < 0.0 )
1398 0 : aTRScale.setY(aTRScale.getY() + 1.0);
1399 : }
1400 :
1401 170 : mrExport.GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
1402 340 : FRound(aTRScale.getY()));
1403 170 : aStr = sStringBuffer.makeStringAndClear();
1404 170 : mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_HEIGHT, aStr);
1405 :
1406 : // decide if transformation is necessary
1407 170 : bool bTransformationIsNecessary(fTRShear != 0.0 || fTRRotate != 0.0);
1408 :
1409 170 : if(bTransformationIsNecessary)
1410 : {
1411 : // write transformation, but WITHOUT scale which is exported as size above
1412 4 : SdXMLImExTransform2D aTransform;
1413 :
1414 4 : aTransform.AddSkewX(atan(fTRShear));
1415 :
1416 : // #i78696#
1417 : // fTRRotate is mathematically correct, but due to the error
1418 : // we export/import it mirrored. Since the API implementation is fixed and
1419 : // uses the correctly oriented angle, it is necessary for compatibility to
1420 : // mirror the angle here to stay at the old behaviour. There is a follow-up
1421 : // task (#i78698#) to fix this in the next ODF FileFormat version
1422 4 : aTransform.AddRotate(-fTRRotate);
1423 :
1424 4 : aTransform.AddTranslate(rTRTranslate);
1425 :
1426 : // does transformation need to be exported?
1427 4 : if(aTransform.NeedsAction())
1428 4 : mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_TRANSFORM, aTransform.GetExportString(mrExport.GetMM100UnitConverter()));
1429 : }
1430 : else
1431 : {
1432 : // no shear, no rotate; just add object position to export and we are done
1433 166 : if(nFeatures & SEF_EXPORT_X)
1434 : {
1435 : // svg: x
1436 166 : mrExport.GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
1437 332 : FRound(rTRTranslate.getX()));
1438 166 : aStr = sStringBuffer.makeStringAndClear();
1439 166 : mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_X, aStr);
1440 : }
1441 :
1442 166 : if(nFeatures & SEF_EXPORT_Y)
1443 : {
1444 : // svg: y
1445 166 : mrExport.GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
1446 332 : FRound(rTRTranslate.getY()));
1447 166 : aStr = sStringBuffer.makeStringAndClear();
1448 166 : mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_Y, aStr);
1449 : }
1450 170 : }
1451 170 : }
1452 :
1453 98 : bool XMLShapeExport::ImpExportPresentationAttributes( const uno::Reference< beans::XPropertySet >& xPropSet, const OUString& rClass )
1454 : {
1455 98 : bool bIsEmpty = false;
1456 :
1457 : // write presentation class entry
1458 98 : mrExport.AddAttribute(XML_NAMESPACE_PRESENTATION, XML_CLASS, rClass);
1459 :
1460 98 : if( xPropSet.is() )
1461 : {
1462 98 : uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
1463 :
1464 98 : bool bTemp = false;
1465 :
1466 : // is empty pes shape?
1467 98 : if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName("IsEmptyPresentationObject"))
1468 : {
1469 98 : xPropSet->getPropertyValue("IsEmptyPresentationObject") >>= bIsEmpty;
1470 98 : if( bIsEmpty )
1471 28 : mrExport.AddAttribute(XML_NAMESPACE_PRESENTATION, XML_PLACEHOLDER, XML_TRUE);
1472 : }
1473 :
1474 : // is user-transformed?
1475 98 : if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName("IsPlaceholderDependent"))
1476 : {
1477 98 : xPropSet->getPropertyValue("IsPlaceholderDependent") >>= bTemp;
1478 98 : if(!bTemp)
1479 10 : mrExport.AddAttribute(XML_NAMESPACE_PRESENTATION, XML_USER_TRANSFORMED, XML_TRUE);
1480 98 : }
1481 : }
1482 :
1483 98 : return bIsEmpty;
1484 : }
1485 :
1486 92 : void XMLShapeExport::ImpExportText( const uno::Reference< drawing::XShape >& xShape )
1487 : {
1488 92 : uno::Reference< text::XText > xText( xShape, uno::UNO_QUERY );
1489 92 : if( xText.is() )
1490 : {
1491 92 : uno::Reference< container::XEnumerationAccess > xEnumAccess( xShape, uno::UNO_QUERY );
1492 92 : if( xEnumAccess.is() && xEnumAccess->hasElements() )
1493 92 : mrExport.GetTextParagraphExport()->exportText( xText );
1494 92 : }
1495 92 : }
1496 :
1497 :
1498 : namespace {
1499 :
1500 : const sal_Int32 FOUND_CLICKACTION = 0x00000001;
1501 : const sal_Int32 FOUND_BOOKMARK = 0x00000002;
1502 : const sal_Int32 FOUND_EFFECT = 0x00000004;
1503 : const sal_Int32 FOUND_PLAYFULL = 0x00000008;
1504 : const sal_Int32 FOUND_VERB = 0x00000010;
1505 : const sal_Int32 FOUND_SOUNDURL = 0x00000020;
1506 : const sal_Int32 FOUND_SPEED = 0x00000040;
1507 : const sal_Int32 FOUND_CLICKEVENTTYPE = 0x00000080;
1508 : const sal_Int32 FOUND_MACRO = 0x00000100;
1509 : const sal_Int32 FOUND_LIBRARY = 0x00000200;
1510 :
1511 : } // namespace
1512 :
1513 128 : void XMLShapeExport::ImpExportEvents( const uno::Reference< drawing::XShape >& xShape )
1514 : {
1515 128 : uno::Reference< document::XEventsSupplier > xEventsSupplier( xShape, uno::UNO_QUERY );
1516 128 : if( !xEventsSupplier.is() )
1517 14 : return;
1518 :
1519 130 : uno::Reference< container::XNameAccess > xEvents( xEventsSupplier->getEvents(), uno::UNO_QUERY );
1520 : DBG_ASSERT( xEvents.is(), "XEventsSupplier::getEvents() returned NULL" );
1521 114 : if( !xEvents.is() )
1522 0 : return;
1523 :
1524 114 : sal_Int32 nFound = 0;
1525 :
1526 130 : OUString aClickEventType;
1527 114 : presentation::ClickAction eClickAction = presentation::ClickAction_NONE;
1528 114 : presentation::AnimationEffect eEffect = presentation::AnimationEffect_NONE;
1529 114 : presentation::AnimationSpeed eSpeed = presentation::AnimationSpeed_SLOW;
1530 130 : OUString aStrSoundURL;
1531 114 : bool bPlayFull = false;
1532 114 : sal_Int32 nVerb = 0;
1533 130 : OUString aStrMacro;
1534 130 : OUString aStrLibrary;
1535 130 : OUString aStrBookmark;
1536 :
1537 130 : uno::Sequence< beans::PropertyValue > aClickProperties;
1538 114 : if( xEvents->hasByName( msOnClick ) && (xEvents->getByName( msOnClick ) >>= aClickProperties) )
1539 : {
1540 114 : const beans::PropertyValue* pProperty = aClickProperties.getConstArray();
1541 114 : const beans::PropertyValue* pPropertyEnd = pProperty + aClickProperties.getLength();
1542 310 : for( ; pProperty != pPropertyEnd; ++pProperty )
1543 : {
1544 196 : if( ( ( nFound & FOUND_CLICKEVENTTYPE ) == 0 ) && pProperty->Name == msEventType )
1545 : {
1546 98 : if( pProperty->Value >>= aClickEventType )
1547 98 : nFound |= FOUND_CLICKEVENTTYPE;
1548 : }
1549 98 : else if( ( ( nFound & FOUND_CLICKACTION ) == 0 ) && pProperty->Name == msClickAction )
1550 : {
1551 98 : if( pProperty->Value >>= eClickAction )
1552 98 : nFound |= FOUND_CLICKACTION;
1553 : }
1554 0 : else if( ( ( nFound & FOUND_MACRO ) == 0 ) && ( pProperty->Name == msMacroName || pProperty->Name == msScript ) )
1555 : {
1556 0 : if( pProperty->Value >>= aStrMacro )
1557 0 : nFound |= FOUND_MACRO;
1558 : }
1559 0 : else if( ( ( nFound & FOUND_LIBRARY ) == 0 ) && pProperty->Name == msLibrary )
1560 : {
1561 0 : if( pProperty->Value >>= aStrLibrary )
1562 0 : nFound |= FOUND_LIBRARY;
1563 : }
1564 0 : else if( ( ( nFound & FOUND_EFFECT ) == 0 ) && pProperty->Name == msEffect )
1565 : {
1566 0 : if( pProperty->Value >>= eEffect )
1567 0 : nFound |= FOUND_EFFECT;
1568 : }
1569 0 : else if( ( ( nFound & FOUND_BOOKMARK ) == 0 ) && pProperty->Name == msBookmark )
1570 : {
1571 0 : if( pProperty->Value >>= aStrBookmark )
1572 0 : nFound |= FOUND_BOOKMARK;
1573 : }
1574 0 : else if( ( ( nFound & FOUND_SPEED ) == 0 ) && pProperty->Name == msSpeed )
1575 : {
1576 0 : if( pProperty->Value >>= eSpeed )
1577 0 : nFound |= FOUND_SPEED;
1578 : }
1579 0 : else if( ( ( nFound & FOUND_SOUNDURL ) == 0 ) && pProperty->Name == msSoundURL )
1580 : {
1581 0 : if( pProperty->Value >>= aStrSoundURL )
1582 0 : nFound |= FOUND_SOUNDURL;
1583 : }
1584 0 : else if( ( ( nFound & FOUND_PLAYFULL ) == 0 ) && pProperty->Name == msPlayFull )
1585 : {
1586 0 : if( pProperty->Value >>= bPlayFull )
1587 0 : nFound |= FOUND_PLAYFULL;
1588 : }
1589 0 : else if( ( ( nFound & FOUND_VERB ) == 0 ) && pProperty->Name == msVerb )
1590 : {
1591 0 : if( pProperty->Value >>= nVerb )
1592 0 : nFound |= FOUND_VERB;
1593 : }
1594 : }
1595 : }
1596 :
1597 : // create the XML elements
1598 :
1599 114 : if( aClickEventType == msPresentation )
1600 : {
1601 98 : if( ((nFound & FOUND_CLICKACTION) == 0) || (eClickAction == presentation::ClickAction_NONE) )
1602 98 : return;
1603 :
1604 0 : SvXMLElementExport aEventsElemt(mrExport, XML_NAMESPACE_OFFICE, XML_EVENT_LISTENERS, true, true);
1605 :
1606 : enum XMLTokenEnum eStrAction;
1607 :
1608 0 : switch( eClickAction )
1609 : {
1610 0 : case presentation::ClickAction_PREVPAGE: eStrAction = XML_PREVIOUS_PAGE; break;
1611 0 : case presentation::ClickAction_NEXTPAGE: eStrAction = XML_NEXT_PAGE; break;
1612 0 : case presentation::ClickAction_FIRSTPAGE: eStrAction = XML_FIRST_PAGE; break;
1613 0 : case presentation::ClickAction_LASTPAGE: eStrAction = XML_LAST_PAGE; break;
1614 0 : case presentation::ClickAction_INVISIBLE: eStrAction = XML_HIDE; break;
1615 0 : case presentation::ClickAction_STOPPRESENTATION:eStrAction = XML_STOP; break;
1616 0 : case presentation::ClickAction_PROGRAM: eStrAction = XML_EXECUTE; break;
1617 0 : case presentation::ClickAction_BOOKMARK: eStrAction = XML_SHOW; break;
1618 0 : case presentation::ClickAction_DOCUMENT: eStrAction = XML_SHOW; break;
1619 0 : case presentation::ClickAction_MACRO: eStrAction = XML_EXECUTE_MACRO; break;
1620 0 : case presentation::ClickAction_VERB: eStrAction = XML_VERB; break;
1621 0 : case presentation::ClickAction_VANISH: eStrAction = XML_FADE_OUT; break;
1622 0 : case presentation::ClickAction_SOUND: eStrAction = XML_SOUND; break;
1623 : default:
1624 : OSL_FAIL( "unknown presentation::ClickAction found!" );
1625 0 : eStrAction = XML_UNKNOWN;
1626 : }
1627 :
1628 : OUString aEventQName(
1629 0 : mrExport.GetNamespaceMap().GetQNameByKey(
1630 0 : XML_NAMESPACE_DOM, OUString( "click" ) ) );
1631 0 : mrExport.AddAttribute( XML_NAMESPACE_SCRIPT, XML_EVENT_NAME, aEventQName );
1632 0 : mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_ACTION, eStrAction );
1633 :
1634 0 : if( eClickAction == presentation::ClickAction_VANISH )
1635 : {
1636 0 : if( nFound & FOUND_EFFECT )
1637 : {
1638 : XMLEffect eKind;
1639 : XMLEffectDirection eDirection;
1640 : sal_Int16 nStartScale;
1641 : bool bIn;
1642 :
1643 0 : SdXMLImplSetEffect( eEffect, eKind, eDirection, nStartScale, bIn );
1644 :
1645 0 : if( eKind != EK_none )
1646 : {
1647 0 : SvXMLUnitConverter::convertEnum( msBuffer, eKind, aXML_AnimationEffect_EnumMap );
1648 0 : mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_EFFECT, msBuffer.makeStringAndClear() );
1649 : }
1650 :
1651 0 : if( eDirection != ED_none )
1652 : {
1653 0 : SvXMLUnitConverter::convertEnum( msBuffer, eDirection, aXML_AnimationDirection_EnumMap );
1654 0 : mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_DIRECTION, msBuffer.makeStringAndClear() );
1655 : }
1656 :
1657 0 : if( nStartScale != -1 )
1658 : {
1659 0 : ::sax::Converter::convertPercent( msBuffer, nStartScale );
1660 0 : mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_START_SCALE, msBuffer.makeStringAndClear() );
1661 : }
1662 : }
1663 :
1664 0 : if( nFound & FOUND_SPEED && eEffect != presentation::AnimationEffect_NONE )
1665 : {
1666 0 : if( eSpeed != presentation::AnimationSpeed_MEDIUM )
1667 : {
1668 0 : SvXMLUnitConverter::convertEnum( msBuffer, eSpeed, aXML_AnimationSpeed_EnumMap );
1669 0 : mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_SPEED, msBuffer.makeStringAndClear() );
1670 : }
1671 : }
1672 : }
1673 :
1674 0 : if( eClickAction == presentation::ClickAction_PROGRAM ||
1675 0 : eClickAction == presentation::ClickAction_BOOKMARK ||
1676 0 : eClickAction == presentation::ClickAction_DOCUMENT )
1677 : {
1678 0 : if( eClickAction == presentation::ClickAction_BOOKMARK )
1679 0 : msBuffer.append( '#' );
1680 :
1681 0 : msBuffer.append( aStrBookmark );
1682 0 : mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, GetExport().GetRelativeReference(msBuffer.makeStringAndClear()) );
1683 0 : mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
1684 0 : mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
1685 0 : mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONREQUEST );
1686 : }
1687 :
1688 0 : if( ( nFound & FOUND_VERB ) && eClickAction == presentation::ClickAction_VERB )
1689 : {
1690 0 : msBuffer.append( nVerb );
1691 0 : mrExport.AddAttribute(XML_NAMESPACE_PRESENTATION, XML_VERB, msBuffer.makeStringAndClear());
1692 : }
1693 :
1694 0 : SvXMLElementExport aEventElemt(mrExport, XML_NAMESPACE_PRESENTATION, XML_EVENT_LISTENER, true, true);
1695 :
1696 0 : if( eClickAction == presentation::ClickAction_VANISH || eClickAction == presentation::ClickAction_SOUND )
1697 : {
1698 0 : if( ( nFound & FOUND_SOUNDURL ) && !aStrSoundURL.isEmpty() )
1699 : {
1700 0 : mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, GetExport().GetRelativeReference(aStrSoundURL) );
1701 0 : mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
1702 0 : mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_NEW );
1703 0 : mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONREQUEST );
1704 0 : if( nFound & FOUND_PLAYFULL && bPlayFull )
1705 0 : mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_PLAY_FULL, XML_TRUE );
1706 :
1707 0 : SvXMLElementExport aElem( mrExport, XML_NAMESPACE_PRESENTATION, XML_SOUND, true, true );
1708 : }
1709 0 : }
1710 : }
1711 16 : else if( aClickEventType == msStarBasic )
1712 : {
1713 0 : if( nFound & FOUND_MACRO )
1714 : {
1715 0 : SvXMLElementExport aEventsElemt(mrExport, XML_NAMESPACE_OFFICE, XML_EVENT_LISTENERS, true, true);
1716 :
1717 : mrExport.AddAttribute( XML_NAMESPACE_SCRIPT, XML_LANGUAGE,
1718 0 : mrExport.GetNamespaceMap().GetQNameByKey(
1719 : XML_NAMESPACE_OOO,
1720 0 : OUString( "starbasic" ) ) );
1721 : OUString aEventQName(
1722 0 : mrExport.GetNamespaceMap().GetQNameByKey(
1723 0 : XML_NAMESPACE_DOM, OUString( "click" ) ) );
1724 0 : mrExport.AddAttribute( XML_NAMESPACE_SCRIPT, XML_EVENT_NAME, aEventQName );
1725 :
1726 0 : if( nFound & FOUND_LIBRARY )
1727 : {
1728 : OUString sLocation( GetXMLToken(
1729 0 : (aStrLibrary.equalsIgnoreAsciiCase("StarOffice") ||
1730 0 : aStrLibrary.equalsIgnoreAsciiCase("application") ) ? XML_APPLICATION
1731 0 : : XML_DOCUMENT ) );
1732 : mrExport.AddAttribute(XML_NAMESPACE_SCRIPT, XML_MACRO_NAME,
1733 0 : sLocation + ":" + aStrMacro);
1734 : }
1735 : else
1736 : {
1737 0 : mrExport.AddAttribute( XML_NAMESPACE_SCRIPT, XML_MACRO_NAME, aStrMacro );
1738 : }
1739 :
1740 0 : SvXMLElementExport aEventElemt(mrExport, XML_NAMESPACE_SCRIPT, XML_EVENT_LISTENER, true, true);
1741 : }
1742 : }
1743 16 : else if( aClickEventType == msScript )
1744 : {
1745 0 : if( nFound & FOUND_MACRO )
1746 : {
1747 0 : SvXMLElementExport aEventsElemt(mrExport, XML_NAMESPACE_OFFICE, XML_EVENT_LISTENERS, true, true);
1748 0 : if ( nFound & FOUND_MACRO )
1749 : {
1750 0 : mrExport.AddAttribute( XML_NAMESPACE_SCRIPT, XML_LANGUAGE, mrExport.GetNamespaceMap().GetQNameByKey(
1751 0 : XML_NAMESPACE_OOO, GetXMLToken(XML_SCRIPT) ) );
1752 : OUString aEventQName(
1753 0 : mrExport.GetNamespaceMap().GetQNameByKey(
1754 0 : XML_NAMESPACE_DOM, OUString( "click" ) ) );
1755 0 : mrExport.AddAttribute( XML_NAMESPACE_SCRIPT, XML_EVENT_NAME, aEventQName );
1756 0 : mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, aStrMacro );
1757 :
1758 0 : SvXMLElementExport aEventElemt(mrExport, XML_NAMESPACE_SCRIPT, XML_EVENT_LISTENER, true, true);
1759 0 : }
1760 : }
1761 16 : }
1762 : }
1763 :
1764 : /** #i68101# export shape Title and Description */
1765 128 : void XMLShapeExport::ImpExportDescription( const uno::Reference< drawing::XShape >& xShape )
1766 : {
1767 : try
1768 : {
1769 128 : OUString aTitle;
1770 256 : OUString aDescription;
1771 :
1772 256 : uno::Reference< beans::XPropertySet > xProps( xShape, uno::UNO_QUERY_THROW );
1773 128 : xProps->getPropertyValue("Title") >>= aTitle;
1774 128 : xProps->getPropertyValue("Description") >>= aDescription;
1775 :
1776 128 : if(!aTitle.isEmpty())
1777 : {
1778 0 : SvXMLElementExport aEventElemt(mrExport, XML_NAMESPACE_SVG, XML_TITLE, true, false);
1779 0 : mrExport.Characters( aTitle );
1780 : }
1781 :
1782 128 : if(!aDescription.isEmpty())
1783 : {
1784 0 : SvXMLElementExport aEventElemt(mrExport, XML_NAMESPACE_SVG, XML_DESC, true, false );
1785 0 : mrExport.Characters( aDescription );
1786 128 : }
1787 : }
1788 0 : catch( uno::Exception& )
1789 : {
1790 : OSL_FAIL( "could not export Title and/or Description for shape!" );
1791 : }
1792 128 : }
1793 :
1794 0 : void XMLShapeExport::ImpExportGroupShape( const uno::Reference< drawing::XShape >& xShape, XmlShapeType, sal_Int32 nFeatures, awt::Point* pRefPoint)
1795 : {
1796 0 : uno::Reference< drawing::XShapes > xShapes(xShape, uno::UNO_QUERY);
1797 0 : if(xShapes.is() && xShapes->getCount())
1798 : {
1799 : // write group shape
1800 0 : bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
1801 0 : SvXMLElementExport aPGR(mrExport, XML_NAMESPACE_DRAW, XML_G, bCreateNewline, true);
1802 :
1803 0 : ImpExportDescription( xShape ); // #i68101#
1804 0 : ImpExportEvents( xShape );
1805 0 : ImpExportGluePoints( xShape );
1806 :
1807 : // #89764# if export of position is supressed for group shape,
1808 : // positions of contained objects should be written relative to
1809 : // the upper left edge of the group.
1810 0 : awt::Point aUpperLeft;
1811 :
1812 0 : if(!(nFeatures & SEF_EXPORT_POSITION))
1813 : {
1814 0 : nFeatures |= SEF_EXPORT_POSITION;
1815 0 : aUpperLeft = xShape->getPosition();
1816 0 : pRefPoint = &aUpperLeft;
1817 : }
1818 :
1819 : // write members
1820 0 : exportShapes( xShapes, nFeatures, pRefPoint );
1821 0 : }
1822 0 : }
1823 :
1824 98 : void XMLShapeExport::ImpExportTextBoxShape(
1825 : const uno::Reference< drawing::XShape >& xShape,
1826 : XmlShapeType eShapeType, sal_Int32 nFeatures, awt::Point* pRefPoint)
1827 : {
1828 98 : const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
1829 98 : if(xPropSet.is())
1830 : {
1831 98 : uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
1832 :
1833 : // presentation attribute (if presentation)
1834 98 : bool bIsPresShape(false);
1835 98 : bool bIsEmptyPresObj(false);
1836 196 : OUString aStr;
1837 :
1838 98 : switch(eShapeType)
1839 : {
1840 : case XmlShapeTypePresSubtitleShape:
1841 : {
1842 6 : aStr = GetXMLToken(XML_PRESENTATION_SUBTITLE);
1843 6 : bIsPresShape = true;
1844 6 : break;
1845 : }
1846 : case XmlShapeTypePresTitleTextShape:
1847 : {
1848 10 : aStr = GetXMLToken(XML_PRESENTATION_TITLE);
1849 10 : bIsPresShape = true;
1850 10 : break;
1851 : }
1852 : case XmlShapeTypePresOutlinerShape:
1853 : {
1854 4 : aStr = GetXMLToken(XML_PRESENTATION_OUTLINE);
1855 4 : bIsPresShape = true;
1856 4 : break;
1857 : }
1858 : case XmlShapeTypePresNotesShape:
1859 : {
1860 12 : aStr = GetXMLToken(XML_PRESENTATION_NOTES);
1861 12 : bIsPresShape = true;
1862 12 : break;
1863 : }
1864 : case XmlShapeTypePresHeaderShape:
1865 : {
1866 12 : aStr = GetXMLToken(XML_HEADER);
1867 12 : bIsPresShape = true;
1868 12 : break;
1869 : }
1870 : case XmlShapeTypePresFooterShape:
1871 : {
1872 18 : aStr = GetXMLToken(XML_FOOTER);
1873 18 : bIsPresShape = true;
1874 18 : break;
1875 : }
1876 : case XmlShapeTypePresSlideNumberShape:
1877 : {
1878 18 : aStr = GetXMLToken(XML_PAGE_NUMBER);
1879 18 : bIsPresShape = true;
1880 18 : break;
1881 : }
1882 : case XmlShapeTypePresDateTimeShape:
1883 : {
1884 18 : aStr = GetXMLToken(XML_DATE_TIME);
1885 18 : bIsPresShape = true;
1886 18 : break;
1887 : }
1888 : default:
1889 0 : break;
1890 : }
1891 :
1892 : // Transformation
1893 98 : ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
1894 :
1895 98 : if(bIsPresShape)
1896 98 : bIsEmptyPresObj = ImpExportPresentationAttributes( xPropSet, aStr );
1897 :
1898 98 : bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
1899 : SvXMLElementExport aElem( mrExport, XML_NAMESPACE_DRAW,
1900 98 : XML_FRAME, bCreateNewline, true );
1901 :
1902 : // evtl. corner radius?
1903 98 : sal_Int32 nCornerRadius(0L);
1904 98 : xPropSet->getPropertyValue("CornerRadius") >>= nCornerRadius;
1905 98 : if(nCornerRadius)
1906 : {
1907 0 : OUStringBuffer sStringBuffer;
1908 0 : mrExport.GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
1909 0 : nCornerRadius);
1910 0 : mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_CORNER_RADIUS, sStringBuffer.makeStringAndClear());
1911 : }
1912 :
1913 : {
1914 : // write text-box
1915 98 : SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_TEXT_BOX, true, true);
1916 98 : if(!bIsEmptyPresObj)
1917 70 : ImpExportText( xShape );
1918 : }
1919 :
1920 98 : ImpExportDescription( xShape ); // #i68101#
1921 98 : ImpExportEvents( xShape );
1922 196 : ImpExportGluePoints( xShape );
1923 98 : }
1924 98 : }
1925 :
1926 4 : void XMLShapeExport::ImpExportRectangleShape(
1927 : const uno::Reference< drawing::XShape >& xShape,
1928 : XmlShapeType, sal_Int32 nFeatures, com::sun::star::awt::Point* pRefPoint)
1929 : {
1930 4 : const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
1931 4 : if(xPropSet.is())
1932 : {
1933 : // Transformation
1934 4 : ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
1935 :
1936 : // evtl. corner radius?
1937 4 : sal_Int32 nCornerRadius(0L);
1938 4 : xPropSet->getPropertyValue("CornerRadius") >>= nCornerRadius;
1939 4 : if(nCornerRadius)
1940 : {
1941 0 : OUStringBuffer sStringBuffer;
1942 0 : mrExport.GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
1943 0 : nCornerRadius);
1944 0 : mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_CORNER_RADIUS, sStringBuffer.makeStringAndClear());
1945 : }
1946 :
1947 : // write rectangle
1948 4 : bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
1949 4 : SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_RECT, bCreateNewline, true);
1950 :
1951 4 : ImpExportDescription( xShape ); // #i68101#
1952 4 : ImpExportEvents( xShape );
1953 4 : ImpExportGluePoints( xShape );
1954 4 : ImpExportText( xShape );
1955 4 : }
1956 4 : }
1957 :
1958 10 : void XMLShapeExport::ImpExportLineShape(
1959 : const uno::Reference< drawing::XShape >& xShape,
1960 : XmlShapeType, sal_Int32 nFeatures, awt::Point* pRefPoint)
1961 : {
1962 10 : const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
1963 10 : if(xPropSet.is())
1964 : {
1965 10 : OUString aStr;
1966 20 : OUStringBuffer sStringBuffer;
1967 10 : awt::Point aStart(0,0);
1968 10 : awt::Point aEnd(1,1);
1969 :
1970 : // #85920# use 'Geometry' to get the points of the line
1971 : // since this slot take anchor pos into account.
1972 :
1973 : // get matrix
1974 20 : ::basegfx::B2DHomMatrix aMatrix;
1975 10 : ImpExportNewTrans_GetB2DHomMatrix(aMatrix, xPropSet);
1976 :
1977 : // decompose and correct about pRefPoint
1978 20 : ::basegfx::B2DTuple aTRScale;
1979 10 : double fTRShear(0.0);
1980 10 : double fTRRotate(0.0);
1981 20 : ::basegfx::B2DTuple aTRTranslate;
1982 10 : ImpExportNewTrans_DecomposeAndRefPoint(aMatrix, aTRScale, fTRShear, fTRRotate, aTRTranslate, pRefPoint);
1983 :
1984 : // create base position
1985 10 : awt::Point aBasePosition(FRound(aTRTranslate.getX()), FRound(aTRTranslate.getY()));
1986 :
1987 : // get the two points
1988 20 : uno::Any aAny(xPropSet->getPropertyValue("Geometry"));
1989 10 : drawing::PointSequenceSequence* pSourcePolyPolygon = (drawing::PointSequenceSequence*)aAny.getValue();
1990 :
1991 10 : if(pSourcePolyPolygon)
1992 : {
1993 10 : drawing::PointSequence* pOuterSequence = pSourcePolyPolygon->getArray();
1994 10 : if(pOuterSequence)
1995 : {
1996 10 : drawing::PointSequence* pInnerSequence = pOuterSequence++;
1997 10 : if(pInnerSequence)
1998 : {
1999 10 : awt::Point* pArray = pInnerSequence->getArray();
2000 10 : if(pArray)
2001 : {
2002 10 : if(pInnerSequence->getLength() > 0)
2003 : {
2004 : aStart = awt::Point(
2005 10 : pArray->X + aBasePosition.X,
2006 20 : pArray->Y + aBasePosition.Y);
2007 10 : pArray++;
2008 : }
2009 :
2010 10 : if(pInnerSequence->getLength() > 1)
2011 : {
2012 : aEnd = awt::Point(
2013 10 : pArray->X + aBasePosition.X,
2014 20 : pArray->Y + aBasePosition.Y);
2015 : }
2016 : }
2017 : }
2018 : }
2019 : }
2020 :
2021 10 : if( nFeatures & SEF_EXPORT_X )
2022 : {
2023 : // svg: x1
2024 10 : mrExport.GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
2025 20 : aStart.X);
2026 10 : aStr = sStringBuffer.makeStringAndClear();
2027 10 : mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_X1, aStr);
2028 : }
2029 : else
2030 : {
2031 0 : aEnd.X -= aStart.X;
2032 : }
2033 :
2034 10 : if( nFeatures & SEF_EXPORT_Y )
2035 : {
2036 : // svg: y1
2037 10 : mrExport.GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
2038 20 : aStart.Y);
2039 10 : aStr = sStringBuffer.makeStringAndClear();
2040 10 : mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_Y1, aStr);
2041 : }
2042 : else
2043 : {
2044 0 : aEnd.Y -= aStart.Y;
2045 : }
2046 :
2047 : // svg: x2
2048 10 : mrExport.GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
2049 20 : aEnd.X);
2050 10 : aStr = sStringBuffer.makeStringAndClear();
2051 10 : mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_X2, aStr);
2052 :
2053 : // svg: y2
2054 10 : mrExport.GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
2055 20 : aEnd.Y);
2056 10 : aStr = sStringBuffer.makeStringAndClear();
2057 10 : mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_Y2, aStr);
2058 :
2059 : // write line
2060 10 : bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
2061 20 : SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_LINE, bCreateNewline, true);
2062 :
2063 10 : ImpExportDescription( xShape ); // #i68101#
2064 10 : ImpExportEvents( xShape );
2065 10 : ImpExportGluePoints( xShape );
2066 20 : ImpExportText( xShape );
2067 10 : }
2068 10 : }
2069 :
2070 0 : void XMLShapeExport::ImpExportEllipseShape(
2071 : const uno::Reference< drawing::XShape >& xShape,
2072 : XmlShapeType, sal_Int32 nFeatures, awt::Point* pRefPoint)
2073 : {
2074 0 : const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
2075 0 : if(xPropSet.is())
2076 : {
2077 : // get size to decide between Circle and Ellipse
2078 0 : awt::Size aSize = xShape->getSize();
2079 0 : sal_Int32 nRx((aSize.Width + 1) / 2);
2080 0 : sal_Int32 nRy((aSize.Height + 1) / 2);
2081 0 : bool bCircle(nRx == nRy);
2082 :
2083 : // Transformation
2084 0 : ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
2085 :
2086 0 : drawing::CircleKind eKind = drawing::CircleKind_FULL;
2087 0 : xPropSet->getPropertyValue("CircleKind") >>= eKind;
2088 0 : if( eKind != drawing::CircleKind_FULL )
2089 : {
2090 0 : OUStringBuffer sStringBuffer;
2091 0 : sal_Int32 nStartAngle = 0;
2092 0 : sal_Int32 nEndAngle = 0;
2093 0 : xPropSet->getPropertyValue("CircleStartAngle") >>= nStartAngle;
2094 0 : xPropSet->getPropertyValue("CircleEndAngle") >>= nEndAngle;
2095 :
2096 0 : const double dStartAngle = nStartAngle / 100.0;
2097 0 : const double dEndAngle = nEndAngle / 100.0;
2098 :
2099 : // export circle kind
2100 0 : SvXMLUnitConverter::convertEnum( sStringBuffer, (sal_uInt16)eKind, aXML_CircleKind_EnumMap );
2101 0 : mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_KIND, sStringBuffer.makeStringAndClear() );
2102 :
2103 : // export start angle
2104 0 : ::sax::Converter::convertDouble( sStringBuffer, dStartAngle );
2105 0 : mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_START_ANGLE, sStringBuffer.makeStringAndClear() );
2106 :
2107 : // export end angle
2108 0 : ::sax::Converter::convertDouble( sStringBuffer, dEndAngle );
2109 0 : mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_END_ANGLE, sStringBuffer.makeStringAndClear() );
2110 : }
2111 :
2112 0 : bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
2113 :
2114 : // write ellipse or circle
2115 : SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW,
2116 : bCircle ? XML_CIRCLE : XML_ELLIPSE,
2117 0 : bCreateNewline, true);
2118 :
2119 0 : ImpExportDescription( xShape ); // #i68101#
2120 0 : ImpExportEvents( xShape );
2121 0 : ImpExportGluePoints( xShape );
2122 0 : ImpExportText( xShape );
2123 :
2124 0 : }
2125 0 : }
2126 :
2127 0 : void XMLShapeExport::ImpExportPolygonShape(
2128 : const uno::Reference< drawing::XShape >& xShape,
2129 : XmlShapeType eShapeType, sal_Int32 nFeatures, awt::Point* pRefPoint)
2130 : {
2131 0 : const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
2132 0 : if(xPropSet.is())
2133 : {
2134 : bool bBezier(eShapeType == XmlShapeTypeDrawClosedBezierShape
2135 0 : || eShapeType == XmlShapeTypeDrawOpenBezierShape);
2136 :
2137 : // get matrix
2138 0 : ::basegfx::B2DHomMatrix aMatrix;
2139 0 : ImpExportNewTrans_GetB2DHomMatrix(aMatrix, xPropSet);
2140 :
2141 : // decompose and correct abour pRefPoint
2142 0 : ::basegfx::B2DTuple aTRScale;
2143 0 : double fTRShear(0.0);
2144 0 : double fTRRotate(0.0);
2145 0 : ::basegfx::B2DTuple aTRTranslate;
2146 0 : ImpExportNewTrans_DecomposeAndRefPoint(aMatrix, aTRScale, fTRShear, fTRRotate, aTRTranslate, pRefPoint);
2147 :
2148 : // use features and write
2149 0 : ImpExportNewTrans_FeaturesAndWrite(aTRScale, fTRShear, fTRRotate, aTRTranslate, nFeatures);
2150 :
2151 : // create and export ViewBox
2152 0 : awt::Point aPoint(0, 0);
2153 0 : awt::Size aSize(FRound(aTRScale.getX()), FRound(aTRScale.getY()));
2154 0 : SdXMLImExViewBox aViewBox(0, 0, aSize.Width, aSize.Height);
2155 0 : mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_VIEWBOX, aViewBox.GetExportString());
2156 :
2157 0 : bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
2158 :
2159 : // prepare name (with most used)
2160 0 : enum ::xmloff::token::XMLTokenEnum eName(XML_PATH);
2161 :
2162 0 : if(bBezier)
2163 : {
2164 : // get PolygonBezier
2165 0 : uno::Any aAny( xPropSet->getPropertyValue("Geometry") );
2166 : const basegfx::B2DPolyPolygon aPolyPolygon(
2167 0 : basegfx::tools::UnoPolyPolygonBezierCoordsToB2DPolyPolygon(*(drawing::PolyPolygonBezierCoords*)aAny.getValue()));
2168 :
2169 0 : if(aPolyPolygon.count())
2170 : {
2171 : // complex polygon shape, write as svg:d
2172 : const OUString aPolygonString(
2173 : basegfx::tools::exportToSvgD(
2174 : aPolyPolygon,
2175 : true, // bUseRelativeCoordinates
2176 : false, // bDetectQuadraticBeziers: not used in old, but maybe activated now
2177 0 : true)); // bHandleRelativeNextPointCompatible
2178 :
2179 : // write point array
2180 0 : mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_D, aPolygonString);
2181 0 : }
2182 : }
2183 : else
2184 : {
2185 : // get non-bezier polygon
2186 0 : uno::Any aAny( xPropSet->getPropertyValue("Geometry") );
2187 : const basegfx::B2DPolyPolygon aPolyPolygon(
2188 0 : basegfx::tools::UnoPointSequenceSequenceToB2DPolyPolygon(*(drawing::PointSequenceSequence*)aAny.getValue()));
2189 :
2190 0 : if(!aPolyPolygon.areControlPointsUsed() && 1 == aPolyPolygon.count())
2191 : {
2192 : // simple polygon shape, can be written as svg:points sequence
2193 0 : const basegfx::B2DPolygon aPolygon(aPolyPolygon.getB2DPolygon(0));
2194 0 : const OUString aPointString(basegfx::tools::exportToSvgPoints(aPolygon));
2195 :
2196 : // write point array
2197 0 : mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_POINTS, aPointString);
2198 :
2199 : // set name
2200 0 : eName = aPolygon.isClosed() ? XML_POLYGON : XML_POLYLINE;
2201 : }
2202 : else
2203 : {
2204 : // complex polygon shape, write as svg:d
2205 : const OUString aPolygonString(
2206 : basegfx::tools::exportToSvgD(
2207 : aPolyPolygon,
2208 : true, // bUseRelativeCoordinates
2209 : false, // bDetectQuadraticBeziers: not used in old, but maybe activated now
2210 0 : true)); // bHandleRelativeNextPointCompatible
2211 :
2212 : // write point array
2213 0 : mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_D, aPolygonString);
2214 0 : }
2215 : }
2216 :
2217 : // write object, but after attributes are added since this call will
2218 : // consume all of these added attributes and the destructor will close the
2219 : // scope. Also before text is added; this may add sub-scopes as needed
2220 : SvXMLElementExport aOBJ(
2221 : mrExport,
2222 : XML_NAMESPACE_DRAW,
2223 : eName,
2224 : bCreateNewline,
2225 0 : true);
2226 :
2227 0 : ImpExportDescription( xShape ); // #i68101#
2228 0 : ImpExportEvents( xShape );
2229 0 : ImpExportGluePoints( xShape );
2230 0 : ImpExportText( xShape );
2231 0 : }
2232 0 : }
2233 :
2234 0 : void XMLShapeExport::ImpExportGraphicObjectShape(
2235 : const uno::Reference< drawing::XShape >& xShape,
2236 : XmlShapeType eShapeType, sal_Int32 nFeatures, awt::Point* pRefPoint)
2237 : {
2238 0 : const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
2239 0 : if(xPropSet.is())
2240 : {
2241 0 : bool bIsEmptyPresObj = false;
2242 0 : uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
2243 :
2244 : // Transformation
2245 0 : ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
2246 :
2247 0 : OUString sImageURL;
2248 :
2249 0 : if(eShapeType == XmlShapeTypePresGraphicObjectShape)
2250 0 : bIsEmptyPresObj = ImpExportPresentationAttributes( xPropSet, GetXMLToken(XML_PRESENTATION_GRAPHIC) );
2251 :
2252 0 : bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
2253 : SvXMLElementExport aElem( mrExport, XML_NAMESPACE_DRAW,
2254 0 : XML_FRAME, bCreateNewline, true );
2255 :
2256 0 : const bool bSaveBackwardsCompatible = ( mrExport.getExportFlags() & EXPORT_SAVEBACKWARDCOMPATIBLE );
2257 :
2258 0 : if( !bIsEmptyPresObj || bSaveBackwardsCompatible )
2259 : {
2260 0 : if( !bIsEmptyPresObj )
2261 : {
2262 0 : OUString aStreamURL;
2263 :
2264 0 : xPropSet->getPropertyValue("GraphicStreamURL") >>= aStreamURL;
2265 0 : xPropSet->getPropertyValue("GraphicURL") >>= sImageURL;
2266 :
2267 0 : OUString aResolveURL( sImageURL );
2268 0 : const OUString sPackageURL( "vnd.sun.star.Package:" );
2269 :
2270 : // trying to preserve the filename for embedded images which already have its stream inside the package
2271 0 : bool bIsEmbeddedImageWithExistingStreamInPackage = false;
2272 0 : if ( aStreamURL.match( sPackageURL, 0 ) )
2273 : {
2274 0 : bIsEmbeddedImageWithExistingStreamInPackage = true;
2275 :
2276 0 : OUString sRequestedName( aStreamURL.copy( sPackageURL.getLength(), aStreamURL.getLength() - sPackageURL.getLength() ) );
2277 0 : sal_Int32 nLastIndex = sRequestedName.lastIndexOf( '/' ) + 1;
2278 0 : if ( ( nLastIndex > 0 ) && ( nLastIndex < sRequestedName.getLength() ) )
2279 0 : sRequestedName = sRequestedName.copy( nLastIndex, sRequestedName.getLength() - nLastIndex );
2280 0 : nLastIndex = sRequestedName.lastIndexOf( '.' );
2281 0 : if ( nLastIndex >= 0 )
2282 0 : sRequestedName = sRequestedName.copy( 0, nLastIndex );
2283 0 : if ( !sRequestedName.isEmpty() )
2284 : {
2285 0 : aResolveURL = aResolveURL.concat( "?requestedName=");
2286 0 : aResolveURL = aResolveURL.concat( sRequestedName );
2287 0 : }
2288 : }
2289 :
2290 0 : const OUString aStr = mrExport.AddEmbeddedGraphicObject( aResolveURL );
2291 0 : mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, aStr );
2292 :
2293 0 : if( !aStr.isEmpty() )
2294 : {
2295 : // apply possible changed stream URL to embedded image object
2296 0 : if ( bIsEmbeddedImageWithExistingStreamInPackage )
2297 : {
2298 0 : aStreamURL = sPackageURL;
2299 0 : if ( aStr[0] == '#' )
2300 : {
2301 0 : aStreamURL = aStreamURL.concat( aStr.copy( 1, aStr.getLength() - 1 ) );
2302 : }
2303 : else
2304 : {
2305 0 : aStreamURL = aStreamURL.concat( aStr );
2306 : }
2307 :
2308 0 : uno::Any aAny;
2309 0 : aAny <<= aStreamURL;
2310 0 : xPropSet->setPropertyValue( "GraphicStreamURL", aAny );
2311 : }
2312 :
2313 0 : mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
2314 0 : mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
2315 0 : mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
2316 0 : }
2317 : }
2318 : else
2319 : {
2320 0 : OUString aStr;
2321 0 : mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, aStr );
2322 0 : mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
2323 0 : mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
2324 0 : mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
2325 : }
2326 :
2327 : {
2328 0 : SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_IMAGE, true, true);
2329 :
2330 0 : if( !sImageURL.isEmpty() )
2331 : {
2332 : // optional office:binary-data
2333 0 : mrExport.AddEmbeddedGraphicObjectAsBase64( sImageURL );
2334 : }
2335 0 : if( !bIsEmptyPresObj )
2336 0 : ImpExportText( xShape );
2337 : }
2338 :
2339 : //Resolves: fdo#62461 put preferred image first above, followed by
2340 : //fallback here
2341 0 : if( !bIsEmptyPresObj )
2342 : {
2343 0 : OUString aReplacementUrl;
2344 0 : xPropSet->getPropertyValue("ReplacementGraphicURL") >>= aReplacementUrl;
2345 :
2346 : // If there is no url, then then graphic is empty
2347 0 : if(!aReplacementUrl.isEmpty())
2348 : {
2349 0 : const OUString aStr = mrExport.AddEmbeddedGraphicObject(aReplacementUrl);
2350 :
2351 0 : if(aStr.getLength())
2352 : {
2353 0 : mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, aStr);
2354 0 : mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
2355 0 : mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
2356 0 : mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
2357 :
2358 : // xlink:href for replacement, only written for Svg content
2359 0 : SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_IMAGE, true, true);
2360 :
2361 : // optional office:binary-data
2362 0 : mrExport.AddEmbeddedGraphicObjectAsBase64(aReplacementUrl);
2363 0 : }
2364 0 : }
2365 : }
2366 : }
2367 :
2368 0 : ImpExportEvents( xShape );
2369 0 : ImpExportGluePoints( xShape );
2370 :
2371 : // image map
2372 0 : GetExport().GetImageMapExport().Export( xPropSet );
2373 0 : ImpExportDescription( xShape ); // #i68101#
2374 0 : }
2375 0 : }
2376 :
2377 8 : void XMLShapeExport::ImpExportChartShape(
2378 : const uno::Reference< drawing::XShape >& xShape,
2379 : XmlShapeType eShapeType, sal_Int32 nFeatures, awt::Point* pRefPoint,
2380 : SvXMLAttributeList* pAttrList )
2381 : {
2382 8 : ImpExportOLE2Shape( xShape, eShapeType, nFeatures, pRefPoint, pAttrList );
2383 8 : }
2384 :
2385 0 : void XMLShapeExport::ImpExportControlShape(
2386 : const uno::Reference< drawing::XShape >& xShape,
2387 : XmlShapeType, sal_Int32 nFeatures, awt::Point* pRefPoint)
2388 : {
2389 0 : const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
2390 0 : if(xPropSet.is())
2391 : {
2392 : // Transformation
2393 0 : ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
2394 : }
2395 :
2396 0 : uno::Reference< drawing::XControlShape > xControl( xShape, uno::UNO_QUERY );
2397 : DBG_ASSERT( xControl.is(), "Control shape is not supporting XControlShape" );
2398 0 : if( xControl.is() )
2399 : {
2400 0 : uno::Reference< beans::XPropertySet > xControlModel( xControl->getControl(), uno::UNO_QUERY );
2401 : DBG_ASSERT( xControlModel.is(), "Control shape has not XControlModel" );
2402 0 : if( xControlModel.is() )
2403 : {
2404 0 : mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_CONTROL, mrExport.GetFormExport()->getControlId( xControlModel ) );
2405 0 : }
2406 : }
2407 :
2408 0 : bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
2409 0 : SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_CONTROL, bCreateNewline, true);
2410 :
2411 0 : ImpExportDescription( xShape ); // #i68101#
2412 0 : }
2413 :
2414 0 : void XMLShapeExport::ImpExportConnectorShape(
2415 : const uno::Reference< drawing::XShape >& xShape,
2416 : XmlShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */)
2417 : {
2418 0 : uno::Reference< beans::XPropertySet > xProps( xShape, uno::UNO_QUERY );
2419 :
2420 0 : OUString aStr;
2421 0 : OUStringBuffer sStringBuffer;
2422 :
2423 : // export connection kind
2424 0 : drawing::ConnectorType eType = drawing::ConnectorType_STANDARD;
2425 0 : uno::Any aAny = xProps->getPropertyValue("EdgeKind");
2426 0 : aAny >>= eType;
2427 :
2428 0 : if( eType != drawing::ConnectorType_STANDARD )
2429 : {
2430 0 : SvXMLUnitConverter::convertEnum( sStringBuffer, (sal_uInt16)eType, aXML_ConnectionKind_EnumMap );
2431 0 : aStr = sStringBuffer.makeStringAndClear();
2432 0 : mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_TYPE, aStr);
2433 : }
2434 :
2435 : // export line skew
2436 0 : sal_Int32 nDelta1 = 0, nDelta2 = 0, nDelta3 = 0;
2437 :
2438 0 : aAny = xProps->getPropertyValue("EdgeLine1Delta");
2439 0 : aAny >>= nDelta1;
2440 0 : aAny = xProps->getPropertyValue("EdgeLine2Delta");
2441 0 : aAny >>= nDelta2;
2442 0 : aAny = xProps->getPropertyValue("EdgeLine3Delta");
2443 0 : aAny >>= nDelta3;
2444 :
2445 0 : if( nDelta1 != 0 || nDelta2 != 0 || nDelta3 != 0 )
2446 : {
2447 0 : mrExport.GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
2448 0 : nDelta1);
2449 0 : if( nDelta2 != 0 || nDelta3 != 0 )
2450 : {
2451 0 : const char aSpace = ' ';
2452 0 : sStringBuffer.appendAscii( &aSpace, 1 );
2453 0 : mrExport.GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
2454 0 : nDelta2);
2455 0 : if( nDelta3 != 0 )
2456 : {
2457 0 : sStringBuffer.appendAscii( &aSpace, 1 );
2458 0 : mrExport.GetMM100UnitConverter().convertMeasureToXML(
2459 0 : sStringBuffer, nDelta3);
2460 : }
2461 : }
2462 :
2463 0 : aStr = sStringBuffer.makeStringAndClear();
2464 0 : mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_LINE_SKEW, aStr);
2465 : }
2466 :
2467 : // export start and end point
2468 0 : awt::Point aStart(0,0);
2469 0 : awt::Point aEnd(1,1);
2470 :
2471 : /* Get <StartPositionInHoriL2R> and
2472 : <EndPositionInHoriL2R>, if they exist and if the document is exported
2473 : into the OpenOffice.org file format.
2474 : These properties only exist at service com::sun::star::text::Shape - the
2475 : Writer UNO service for shapes.
2476 : This code is needed, because the positioning attributes in the
2477 : OpenOffice.org file format are given in horizontal left-to-right layout
2478 : regardless the layout direction the shape is in. In the OASIS Open Office
2479 : file format the positioning attributes are correctly given in the layout
2480 : direction the shape is in. Thus, this code provides the conversion from
2481 : the OASIS Open Office file format to the OpenOffice.org file format. (#i36248#)
2482 : */
2483 0 : if ( ( GetExport().getExportFlags() & EXPORT_OASIS ) == 0 &&
2484 0 : xProps->getPropertySetInfo()->hasPropertyByName("StartPositionInHoriL2R") &&
2485 0 : xProps->getPropertySetInfo()->hasPropertyByName("EndPositionInHoriL2R") )
2486 : {
2487 0 : xProps->getPropertyValue("StartPositionInHoriL2R") >>= aStart;
2488 0 : xProps->getPropertyValue("EndPositionInHoriL2R") >>= aEnd;
2489 : }
2490 : else
2491 : {
2492 0 : xProps->getPropertyValue("StartPosition") >>= aStart;
2493 0 : xProps->getPropertyValue("EndPosition") >>= aEnd;
2494 : }
2495 :
2496 0 : if( pRefPoint )
2497 : {
2498 0 : aStart.X -= pRefPoint->X;
2499 0 : aStart.Y -= pRefPoint->Y;
2500 0 : aEnd.X -= pRefPoint->X;
2501 0 : aEnd.Y -= pRefPoint->Y;
2502 : }
2503 :
2504 0 : if( nFeatures & SEF_EXPORT_X )
2505 : {
2506 : // svg: x1
2507 0 : mrExport.GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
2508 0 : aStart.X);
2509 0 : aStr = sStringBuffer.makeStringAndClear();
2510 0 : mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_X1, aStr);
2511 : }
2512 : else
2513 : {
2514 0 : aEnd.X -= aStart.X;
2515 : }
2516 :
2517 0 : if( nFeatures & SEF_EXPORT_Y )
2518 : {
2519 : // svg: y1
2520 0 : mrExport.GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
2521 0 : aStart.Y);
2522 0 : aStr = sStringBuffer.makeStringAndClear();
2523 0 : mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_Y1, aStr);
2524 : }
2525 : else
2526 : {
2527 0 : aEnd.Y -= aStart.Y;
2528 : }
2529 :
2530 : // svg: x2
2531 0 : mrExport.GetMM100UnitConverter().convertMeasureToXML(sStringBuffer, aEnd.X);
2532 0 : aStr = sStringBuffer.makeStringAndClear();
2533 0 : mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_X2, aStr);
2534 :
2535 : // svg: y2
2536 0 : mrExport.GetMM100UnitConverter().convertMeasureToXML(sStringBuffer, aEnd.Y);
2537 0 : aStr = sStringBuffer.makeStringAndClear();
2538 0 : mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_Y2, aStr);
2539 :
2540 : // #i39320#
2541 0 : uno::Reference< uno::XInterface > xRefS;
2542 0 : uno::Reference< uno::XInterface > xRefE;
2543 :
2544 : // export start connection
2545 0 : xProps->getPropertyValue("StartShape") >>= xRefS;
2546 0 : if( xRefS.is() )
2547 : {
2548 0 : const OUString& rShapeId = mrExport.getInterfaceToIdentifierMapper().getIdentifier( xRefS );
2549 0 : mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_START_SHAPE, rShapeId);
2550 :
2551 0 : aAny = xProps->getPropertyValue("StartGluePointIndex");
2552 0 : sal_Int32 nGluePointId = 0;
2553 0 : if( aAny >>= nGluePointId )
2554 : {
2555 0 : if( nGluePointId != -1 )
2556 : {
2557 0 : mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_START_GLUE_POINT, OUString::number( nGluePointId ));
2558 : }
2559 : }
2560 : }
2561 :
2562 : // export end connection
2563 0 : xProps->getPropertyValue("EndShape") >>= xRefE;
2564 0 : if( xRefE.is() )
2565 : {
2566 0 : const OUString& rShapeId = mrExport.getInterfaceToIdentifierMapper().getIdentifier( xRefE );
2567 0 : mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_END_SHAPE, rShapeId);
2568 :
2569 0 : aAny = xProps->getPropertyValue("EndGluePointIndex");
2570 0 : sal_Int32 nGluePointId = 0;
2571 0 : if( aAny >>= nGluePointId )
2572 : {
2573 0 : if( nGluePointId != -1 )
2574 : {
2575 0 : mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_END_GLUE_POINT, OUString::number( nGluePointId ));
2576 : }
2577 : }
2578 : }
2579 :
2580 0 : if( xProps->getPropertyValue("PolyPolygonBezier") >>= aAny )
2581 : {
2582 : // get PolygonBezier
2583 0 : drawing::PolyPolygonBezierCoords* pSourcePolyPolygon = (drawing::PolyPolygonBezierCoords*)aAny.getValue();
2584 :
2585 0 : if(pSourcePolyPolygon && pSourcePolyPolygon->Coordinates.getLength())
2586 : {
2587 : const basegfx::B2DPolyPolygon aPolyPolygon(
2588 : basegfx::tools::UnoPolyPolygonBezierCoordsToB2DPolyPolygon(
2589 0 : *pSourcePolyPolygon));
2590 : const OUString aPolygonString(
2591 : basegfx::tools::exportToSvgD(
2592 : aPolyPolygon,
2593 : true, // bUseRelativeCoordinates
2594 : false, // bDetectQuadraticBeziers: not used in old, but maybe activated now
2595 0 : true)); // bHandleRelativeNextPointCompatible
2596 :
2597 : // write point array
2598 0 : mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_D, aPolygonString);
2599 : }
2600 : }
2601 :
2602 : // get matrix
2603 0 : ::basegfx::B2DHomMatrix aMatrix;
2604 0 : ImpExportNewTrans_GetB2DHomMatrix(aMatrix, xProps);
2605 :
2606 : // decompose and correct about pRefPoint
2607 0 : ::basegfx::B2DTuple aTRScale;
2608 0 : double fTRShear(0.0);
2609 0 : double fTRRotate(0.0);
2610 0 : ::basegfx::B2DTuple aTRTranslate;
2611 : ImpExportNewTrans_DecomposeAndRefPoint(aMatrix, aTRScale, fTRShear,
2612 0 : fTRRotate, aTRTranslate, pRefPoint);
2613 :
2614 : // fdo#49678: create and export ViewBox
2615 0 : awt::Point aPoint(0, 0);
2616 0 : awt::Size aSize(FRound(aTRScale.getX()), FRound(aTRScale.getY()));
2617 0 : SdXMLImExViewBox aViewBox(0, 0, aSize.Width, aSize.Height);
2618 0 : mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_VIEWBOX, aViewBox.GetExportString());
2619 :
2620 : // write connector shape. Add Export later.
2621 0 : bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
2622 0 : SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_CONNECTOR, bCreateNewline, true);
2623 :
2624 0 : ImpExportDescription( xShape ); // #i68101#
2625 0 : ImpExportEvents( xShape );
2626 0 : ImpExportGluePoints( xShape );
2627 0 : ImpExportText( xShape );
2628 0 : }
2629 :
2630 0 : void XMLShapeExport::ImpExportMeasureShape(
2631 : const uno::Reference< drawing::XShape >& xShape,
2632 : XmlShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */)
2633 : {
2634 0 : uno::Reference< beans::XPropertySet > xProps( xShape, uno::UNO_QUERY );
2635 :
2636 0 : OUString aStr;
2637 0 : OUStringBuffer sStringBuffer;
2638 :
2639 : // export start and end point
2640 0 : awt::Point aStart(0,0);
2641 0 : awt::Point aEnd(1,1);
2642 :
2643 : /* Get <StartPositionInHoriL2R> and
2644 : <EndPositionInHoriL2R>, if they exist and if the document is exported
2645 : into the OpenOffice.org file format.
2646 : These properties only exist at service com::sun::star::text::Shape - the
2647 : Writer UNO service for shapes.
2648 : This code is needed, because the positioning attributes in the
2649 : OpenOffice.org file format are given in horizontal left-to-right layout
2650 : regardless the layout direction the shape is in. In the OASIS Open Office
2651 : file format the positioning attributes are correctly given in the layout
2652 : direction the shape is in. Thus, this code provides the conversion from
2653 : the OASIS Open Office file format to the OpenOffice.org file format. (#i36248#)
2654 : */
2655 0 : if ( ( GetExport().getExportFlags() & EXPORT_OASIS ) == 0 &&
2656 0 : xProps->getPropertySetInfo()->hasPropertyByName("StartPositionInHoriL2R") &&
2657 0 : xProps->getPropertySetInfo()->hasPropertyByName("EndPositionInHoriL2R") )
2658 : {
2659 0 : xProps->getPropertyValue("StartPositionInHoriL2R") >>= aStart;
2660 0 : xProps->getPropertyValue("EndPositionInHoriL2R") >>= aEnd;
2661 : }
2662 : else
2663 : {
2664 0 : xProps->getPropertyValue("StartPosition") >>= aStart;
2665 0 : xProps->getPropertyValue("EndPosition") >>= aEnd;
2666 : }
2667 :
2668 0 : if( pRefPoint )
2669 : {
2670 0 : aStart.X -= pRefPoint->X;
2671 0 : aStart.Y -= pRefPoint->Y;
2672 0 : aEnd.X -= pRefPoint->X;
2673 0 : aEnd.Y -= pRefPoint->Y;
2674 : }
2675 :
2676 0 : if( nFeatures & SEF_EXPORT_X )
2677 : {
2678 : // svg: x1
2679 0 : mrExport.GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
2680 0 : aStart.X);
2681 0 : aStr = sStringBuffer.makeStringAndClear();
2682 0 : mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_X1, aStr);
2683 : }
2684 : else
2685 : {
2686 0 : aEnd.X -= aStart.X;
2687 : }
2688 :
2689 0 : if( nFeatures & SEF_EXPORT_Y )
2690 : {
2691 : // svg: y1
2692 0 : mrExport.GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
2693 0 : aStart.Y);
2694 0 : aStr = sStringBuffer.makeStringAndClear();
2695 0 : mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_Y1, aStr);
2696 : }
2697 : else
2698 : {
2699 0 : aEnd.Y -= aStart.Y;
2700 : }
2701 :
2702 : // svg: x2
2703 0 : mrExport.GetMM100UnitConverter().convertMeasureToXML(sStringBuffer, aEnd.X);
2704 0 : aStr = sStringBuffer.makeStringAndClear();
2705 0 : mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_X2, aStr);
2706 :
2707 : // svg: y2
2708 0 : mrExport.GetMM100UnitConverter().convertMeasureToXML(sStringBuffer, aEnd.Y);
2709 0 : aStr = sStringBuffer.makeStringAndClear();
2710 0 : mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_Y2, aStr);
2711 :
2712 : // write measure shape
2713 0 : bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
2714 0 : SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_MEASURE, bCreateNewline, true);
2715 :
2716 0 : ImpExportDescription( xShape ); // #i68101#
2717 0 : ImpExportEvents( xShape );
2718 0 : ImpExportGluePoints( xShape );
2719 :
2720 0 : uno::Reference< text::XText > xText( xShape, uno::UNO_QUERY );
2721 0 : if( xText.is() )
2722 0 : mrExport.GetTextParagraphExport()->exportText( xText );
2723 0 : }
2724 :
2725 8 : void XMLShapeExport::ImpExportOLE2Shape(
2726 : const uno::Reference< drawing::XShape >& xShape,
2727 : XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */,
2728 : SvXMLAttributeList* pAttrList /* = NULL */ )
2729 : {
2730 8 : uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
2731 16 : uno::Reference< container::XNamed > xNamed(xShape, uno::UNO_QUERY);
2732 :
2733 : DBG_ASSERT( xPropSet.is() && xNamed.is(), "ole shape is not implementing needed interfaces");
2734 8 : if(xPropSet.is() && xNamed.is())
2735 : {
2736 : // Transformation
2737 8 : ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
2738 :
2739 8 : bool bIsEmptyPresObj = false;
2740 :
2741 : // presentation settings
2742 8 : if(eShapeType == XmlShapeTypePresOLE2Shape)
2743 0 : bIsEmptyPresObj = ImpExportPresentationAttributes( xPropSet, GetXMLToken(XML_PRESENTATION_OBJECT) );
2744 8 : else if(eShapeType == XmlShapeTypePresChartShape)
2745 0 : bIsEmptyPresObj = ImpExportPresentationAttributes( xPropSet, GetXMLToken(XML_PRESENTATION_CHART) );
2746 8 : else if(eShapeType == XmlShapeTypePresSheetShape)
2747 0 : bIsEmptyPresObj = ImpExportPresentationAttributes( xPropSet, GetXMLToken(XML_PRESENTATION_TABLE) );
2748 :
2749 8 : bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
2750 8 : bool bExportEmbedded(0 != (mrExport.getExportFlags() & EXPORT_EMBEDDED));
2751 8 : OUString sPersistName;
2752 : SvXMLElementExport aElement( mrExport, XML_NAMESPACE_DRAW,
2753 16 : XML_FRAME, bCreateNewline, true );
2754 :
2755 8 : const bool bSaveBackwardsCompatible = ( mrExport.getExportFlags() & EXPORT_SAVEBACKWARDCOMPATIBLE );
2756 :
2757 8 : if( !bIsEmptyPresObj || bSaveBackwardsCompatible )
2758 : {
2759 8 : if (pAttrList)
2760 : {
2761 8 : mrExport.AddAttributeList(pAttrList);
2762 : }
2763 :
2764 8 : OUString sClassId;
2765 16 : OUString sURL;
2766 8 : bool bInternal = false;
2767 8 : xPropSet->getPropertyValue("IsInternal") >>= bInternal;
2768 :
2769 8 : if( !bIsEmptyPresObj )
2770 : {
2771 :
2772 8 : if ( bInternal )
2773 : {
2774 : // OOo internal links have no storage persistence, URL is stored in the XML file
2775 : // the result LinkURL is empty in case the object is not a link
2776 8 : xPropSet->getPropertyValue("LinkURL") >>= sURL;
2777 : }
2778 :
2779 8 : xPropSet->getPropertyValue("PersistName") >>= sPersistName;
2780 8 : if ( sURL.isEmpty() )
2781 : {
2782 8 : if( !sPersistName.isEmpty() )
2783 : {
2784 8 : sURL = "vnd.sun.star.EmbeddedObject:" + sPersistName;
2785 : }
2786 : }
2787 :
2788 8 : if( !bInternal )
2789 0 : xPropSet->getPropertyValue("CLSID") >>= sClassId;
2790 :
2791 8 : if( !sClassId.isEmpty() )
2792 0 : mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_CLASS_ID, sClassId );
2793 :
2794 8 : if(eShapeType != XmlShapeTypePresChartShape && eShapeType != XmlShapeTypeDrawChartShape)
2795 : {
2796 : // #i118485# Add text export, the draw OLE shape allows text now
2797 : // fdo#58571 chart objects don't allow text:p
2798 0 : ImpExportText( xShape );
2799 : }
2800 :
2801 8 : if(!bExportEmbedded)
2802 : {
2803 : // xlink:href
2804 8 : if( !sURL.isEmpty() )
2805 : {
2806 : // #96717# in theorie, if we don't have a url we shouldn't even
2807 : // export this ole shape. But practical its to risky right now
2808 : // to change this so we better dispose this on load
2809 8 : sURL = mrExport.AddEmbeddedObject( sURL );
2810 :
2811 8 : mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, sURL );
2812 8 : mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
2813 8 : mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
2814 8 : mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
2815 : }
2816 : }
2817 : }
2818 : else
2819 : {
2820 : // export empty href for empty placeholders to be valid ODF
2821 0 : OUString sEmptyURL;
2822 :
2823 0 : mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, sEmptyURL );
2824 0 : mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
2825 0 : mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
2826 0 : mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
2827 : }
2828 :
2829 8 : enum XMLTokenEnum eElem = sClassId.isEmpty() ? XML_OBJECT : XML_OBJECT_OLE ;
2830 16 : SvXMLElementExport aElem( mrExport, XML_NAMESPACE_DRAW, eElem, true, true );
2831 :
2832 8 : if(bExportEmbedded && !bIsEmptyPresObj)
2833 : {
2834 : // #100592#
2835 0 : if(bInternal)
2836 : {
2837 : // embedded XML
2838 0 : uno::Reference< lang::XComponent > xComp;
2839 0 : xPropSet->getPropertyValue("Model") >>= xComp;
2840 : DBG_ASSERT( xComp.is(), "no xModel for own OLE format" );
2841 0 : mrExport.ExportEmbeddedOwnObject( xComp );
2842 : }
2843 : else
2844 : {
2845 : // embed as Base64
2846 : // this is an alien object ( currently MSOLE is the only supported type of such objects )
2847 : // in case it is not an OASIS format the object should be asked to store replacement image if possible
2848 :
2849 0 : OUString sURLRequest( sURL );
2850 0 : if ( ( mrExport.getExportFlags() & EXPORT_OASIS ) == 0 )
2851 0 : sURLRequest += "?oasis=false";
2852 0 : mrExport.AddEmbeddedObjectAsBase64( sURLRequest );
2853 : }
2854 8 : }
2855 : }
2856 8 : if( !bIsEmptyPresObj )
2857 : {
2858 8 : OUString sURL( "vnd.sun.star.GraphicObject:" );
2859 8 : sURL += sPersistName;
2860 8 : if( !bExportEmbedded )
2861 : {
2862 8 : sURL = GetExport().AddEmbeddedObject( sURL );
2863 8 : mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, sURL );
2864 8 : mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
2865 8 : mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
2866 8 : mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
2867 : }
2868 :
2869 8 : SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_DRAW,
2870 16 : XML_IMAGE, false, true );
2871 :
2872 8 : if( bExportEmbedded )
2873 8 : GetExport().AddEmbeddedObjectAsBase64( sURL );
2874 : }
2875 :
2876 8 : ImpExportEvents( xShape );
2877 8 : ImpExportGluePoints( xShape );
2878 16 : ImpExportDescription( xShape ); // #i68101#
2879 8 : }
2880 8 : }
2881 :
2882 48 : void XMLShapeExport::ImpExportPageShape(
2883 : const uno::Reference< drawing::XShape >& xShape,
2884 : XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */)
2885 : {
2886 48 : const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
2887 48 : if(xPropSet.is())
2888 : {
2889 : // #86163# Transformation
2890 48 : ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
2891 :
2892 : // export page number used for this page
2893 48 : uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
2894 96 : const OUString aPageNumberStr("PageNumber");
2895 48 : if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(aPageNumberStr))
2896 : {
2897 42 : sal_Int32 nPageNumber = 0;
2898 42 : xPropSet->getPropertyValue(aPageNumberStr) >>= nPageNumber;
2899 42 : if( nPageNumber )
2900 6 : mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_PAGE_NUMBER, OUString::number(nPageNumber));
2901 : }
2902 :
2903 : // a presentation page shape, normally used on notes pages only. If
2904 : // it is used not as presentation shape, it may have been created with
2905 : // copy-paste exchange between draw and impress (this IS possible...)
2906 48 : if(eShapeType == XmlShapeTypePresPageShape)
2907 : {
2908 : mrExport.AddAttribute(XML_NAMESPACE_PRESENTATION, XML_CLASS,
2909 12 : XML_PRESENTATION_PAGE);
2910 : }
2911 :
2912 : // write Page shape
2913 48 : bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
2914 96 : SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_PAGE_THUMBNAIL, bCreateNewline, true);
2915 48 : }
2916 48 : }
2917 :
2918 4 : void XMLShapeExport::ImpExportCaptionShape(
2919 : const uno::Reference< drawing::XShape >& xShape,
2920 : XmlShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */)
2921 : {
2922 4 : const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
2923 4 : if(xPropSet.is())
2924 : {
2925 : // Transformation
2926 4 : ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
2927 :
2928 : // evtl. corner radius?
2929 4 : sal_Int32 nCornerRadius(0L);
2930 4 : xPropSet->getPropertyValue("CornerRadius") >>= nCornerRadius;
2931 4 : if(nCornerRadius)
2932 : {
2933 0 : OUStringBuffer sStringBuffer;
2934 0 : mrExport.GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
2935 0 : nCornerRadius);
2936 0 : mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_CORNER_RADIUS, sStringBuffer.makeStringAndClear());
2937 : }
2938 :
2939 4 : awt::Point aCaptionPoint;
2940 4 : xPropSet->getPropertyValue("CaptionPoint") >>= aCaptionPoint;
2941 :
2942 4 : mrExport.GetMM100UnitConverter().convertMeasureToXML(msBuffer,
2943 8 : aCaptionPoint.X);
2944 4 : mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_CAPTION_POINT_X, msBuffer.makeStringAndClear() );
2945 4 : mrExport.GetMM100UnitConverter().convertMeasureToXML(msBuffer,
2946 8 : aCaptionPoint.Y);
2947 4 : mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_CAPTION_POINT_Y, msBuffer.makeStringAndClear() );
2948 :
2949 : // write Caption shape. Add export later.
2950 4 : bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
2951 4 : bool bAnnotation( (nFeatures & SEF_EXPORT_ANNOTATION) == SEF_EXPORT_ANNOTATION );
2952 :
2953 : SvXMLElementExport aObj( mrExport,
2954 : (bAnnotation ? XML_NAMESPACE_OFFICE
2955 : : XML_NAMESPACE_DRAW),
2956 : (bAnnotation ? XML_ANNOTATION : XML_CAPTION),
2957 4 : bCreateNewline, true );
2958 :
2959 4 : ImpExportDescription( xShape ); // #i68101#
2960 4 : ImpExportEvents( xShape );
2961 4 : ImpExportGluePoints( xShape );
2962 4 : if( bAnnotation )
2963 4 : mrExport.exportAnnotationMeta( xShape );
2964 4 : ImpExportText( xShape );
2965 4 : }
2966 4 : }
2967 :
2968 0 : void XMLShapeExport::ImpExportFrameShape(
2969 : const uno::Reference< drawing::XShape >& xShape,
2970 : XmlShapeType, sal_Int32 nFeatures, com::sun::star::awt::Point* pRefPoint)
2971 : {
2972 0 : const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
2973 0 : if(xPropSet.is())
2974 : {
2975 : // Transformation
2976 0 : ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
2977 :
2978 0 : bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
2979 : SvXMLElementExport aElem( mrExport, XML_NAMESPACE_DRAW,
2980 0 : XML_FRAME, bCreateNewline, true );
2981 :
2982 : // export frame url
2983 0 : OUString aStr;
2984 0 : xPropSet->getPropertyValue("FrameURL") >>= aStr;
2985 0 : mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_HREF, GetExport().GetRelativeReference(aStr) );
2986 0 : mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
2987 0 : mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
2988 0 : mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
2989 :
2990 : // export name
2991 0 : xPropSet->getPropertyValue("FrameName") >>= aStr;
2992 0 : if( !aStr.isEmpty() )
2993 0 : mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_FRAME_NAME, aStr );
2994 :
2995 : // write floating frame
2996 : {
2997 0 : SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_FLOATING_FRAME, true, true);
2998 0 : }
2999 0 : }
3000 0 : }
3001 :
3002 0 : void XMLShapeExport::ImpExportAppletShape(
3003 : const uno::Reference< drawing::XShape >& xShape,
3004 : XmlShapeType, sal_Int32 nFeatures, com::sun::star::awt::Point* pRefPoint)
3005 : {
3006 0 : const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
3007 0 : if(xPropSet.is())
3008 : {
3009 : // Transformation
3010 0 : ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
3011 :
3012 0 : bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
3013 : SvXMLElementExport aElement( mrExport, XML_NAMESPACE_DRAW,
3014 0 : XML_FRAME, bCreateNewline, true );
3015 :
3016 : // export frame url
3017 0 : OUString aStr;
3018 0 : xPropSet->getPropertyValue("AppletCodeBase") >>= aStr;
3019 0 : mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_HREF, GetExport().GetRelativeReference(aStr) );
3020 0 : mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
3021 0 : mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
3022 0 : mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
3023 :
3024 : // export draw:applet-name
3025 0 : xPropSet->getPropertyValue("AppletName") >>= aStr;
3026 0 : if( !aStr.isEmpty() )
3027 0 : mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_APPLET_NAME, aStr );
3028 :
3029 : // export draw:code
3030 0 : xPropSet->getPropertyValue("AppletCode") >>= aStr;
3031 0 : mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_CODE, aStr );
3032 :
3033 : // export draw:may-script
3034 0 : bool bIsScript = false;
3035 0 : xPropSet->getPropertyValue("AppletIsScript") >>= bIsScript;
3036 0 : mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_MAY_SCRIPT, bIsScript ? XML_TRUE : XML_FALSE );
3037 :
3038 : {
3039 : // write applet
3040 0 : SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_APPLET, true, true);
3041 :
3042 : // export parameters
3043 0 : uno::Sequence< beans::PropertyValue > aCommands;
3044 0 : xPropSet->getPropertyValue("AppletCommands") >>= aCommands;
3045 0 : const sal_Int32 nCount = aCommands.getLength();
3046 0 : for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
3047 : {
3048 0 : aCommands[nIndex].Value >>= aStr;
3049 0 : mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, aCommands[nIndex].Name );
3050 0 : mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_VALUE, aStr );
3051 0 : SvXMLElementExport aElem( mrExport, XML_NAMESPACE_DRAW, XML_PARAM, false, true );
3052 0 : }
3053 0 : }
3054 0 : }
3055 0 : }
3056 :
3057 0 : void XMLShapeExport::ImpExportPluginShape(
3058 : const uno::Reference< drawing::XShape >& xShape,
3059 : XmlShapeType, sal_Int32 nFeatures, com::sun::star::awt::Point* pRefPoint)
3060 : {
3061 0 : const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
3062 0 : if(xPropSet.is())
3063 : {
3064 : // Transformation
3065 0 : ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
3066 :
3067 0 : bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
3068 : SvXMLElementExport aElement( mrExport, XML_NAMESPACE_DRAW,
3069 0 : XML_FRAME, bCreateNewline, true );
3070 :
3071 : // export plugin url
3072 0 : OUString aStr;
3073 0 : xPropSet->getPropertyValue("PluginURL") >>= aStr;
3074 0 : mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_HREF, GetExport().GetRelativeReference(aStr) );
3075 0 : mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
3076 0 : mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
3077 0 : mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
3078 :
3079 : // export mime-type
3080 0 : xPropSet->getPropertyValue("PluginMimeType") >>= aStr;
3081 0 : if(!aStr.isEmpty())
3082 0 : mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_MIME_TYPE, aStr );
3083 :
3084 : {
3085 : // write plugin
3086 0 : SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_PLUGIN, true, true);
3087 :
3088 : // export parameters
3089 0 : uno::Sequence< beans::PropertyValue > aCommands;
3090 0 : xPropSet->getPropertyValue("PluginCommands") >>= aCommands;
3091 0 : const sal_Int32 nCount = aCommands.getLength();
3092 0 : for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
3093 : {
3094 0 : aCommands[nIndex].Value >>= aStr;
3095 0 : mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, aCommands[nIndex].Name );
3096 0 : mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_VALUE, aStr );
3097 0 : SvXMLElementExport aElem( mrExport, XML_NAMESPACE_DRAW, XML_PARAM, false, true );
3098 0 : }
3099 0 : }
3100 0 : }
3101 0 : }
3102 :
3103 4 : static void lcl_CopyStream(
3104 : uno::Reference<io::XInputStream> const& xInStream,
3105 : uno::Reference<embed::XStorage> const& xTarget,
3106 : OUString const& rPath, const OUString& rMimeType)
3107 : {
3108 4 : ::comphelper::LifecycleProxy proxy;
3109 : uno::Reference<io::XStream> const xStream(
3110 : ::comphelper::OStorageHelper::GetStreamAtPackageURL(xTarget, rPath,
3111 8 : embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE, proxy));
3112 : uno::Reference<io::XOutputStream> const xOutStream(
3113 8 : (xStream.is()) ? xStream->getOutputStream() : 0);
3114 4 : if (!xOutStream.is())
3115 : {
3116 : SAL_WARN("xmloff", "no output stream");
3117 0 : throw uno::Exception("no output stream",0);
3118 : }
3119 : uno::Reference< beans::XPropertySet > const xStreamProps(xStream,
3120 8 : uno::UNO_QUERY);
3121 4 : if (xStreamProps.is()) { // this is NOT supported in FileSystemStorage
3122 4 : xStreamProps->setPropertyValue("MediaType",
3123 4 : uno::makeAny(rMimeType));
3124 4 : xStreamProps->setPropertyValue( // turn off compression
3125 : "Compressed",
3126 4 : uno::makeAny(sal_False));
3127 : }
3128 4 : ::comphelper::OStorageHelper::CopyInputToOutput(xInStream, xOutStream);
3129 4 : xOutStream->closeOutput();
3130 8 : proxy.commitStorages();
3131 4 : }
3132 :
3133 : static OUString
3134 4 : lcl_StoreMediaAndGetURL(SvXMLExport & rExport,
3135 : uno::Reference<beans::XPropertySet> const& xPropSet,
3136 : OUString const& rURL, const OUString& rMimeType)
3137 : {
3138 4 : OUString urlPath;
3139 4 : if (rURL.startsWithIgnoreAsciiCase("vnd.sun.star.Package:", &urlPath))
3140 : {
3141 : try // video is embedded
3142 : {
3143 : uno::Reference<embed::XStorage> const xTarget(
3144 4 : rExport.GetTargetStorage(), uno::UNO_QUERY_THROW);
3145 8 : uno::Reference<io::XInputStream> xInStream;
3146 4 : xPropSet->getPropertyValue("PrivateStream")
3147 4 : >>= xInStream;
3148 :
3149 4 : if (!xInStream.is())
3150 : {
3151 : SAL_WARN("xmloff", "no input stream");
3152 0 : return OUString();
3153 : }
3154 :
3155 4 : lcl_CopyStream(xInStream, xTarget, rURL, rMimeType);
3156 :
3157 8 : return urlPath;
3158 : }
3159 0 : catch (uno::Exception const& e)
3160 : {
3161 : SAL_INFO("xmloff", "exception while storing embedded media: '"
3162 : << e.Message << "'");
3163 : }
3164 0 : return OUString();
3165 : }
3166 : else
3167 : {
3168 0 : return rExport.GetRelativeReference(rURL); // linked
3169 4 : }
3170 : }
3171 :
3172 : #if HAVE_FEATURE_GLTF
3173 2 : static void lcl_StoreGltfExternals(
3174 : SvXMLExport& rExport,
3175 : const OUString& rURL )
3176 : {
3177 2 : OUString sUrlPath;
3178 2 : if (rURL.startsWithIgnoreAsciiCase("vnd.sun.star.Package:", &sUrlPath))
3179 : {
3180 2 : sUrlPath = sUrlPath.copy(0,sUrlPath.lastIndexOf("/"));
3181 : try
3182 : {
3183 : // Base storage
3184 : uno::Reference<document::XStorageBasedDocument> const xSBD(
3185 2 : rExport.GetModel(), uno::UNO_QUERY_THROW);
3186 : const uno::Reference<embed::XStorage> xStorage(
3187 4 : xSBD->getDocumentStorage(), uno::UNO_QUERY_THROW);
3188 :
3189 : // Model source
3190 4 : ::comphelper::LifecycleProxy proxy;
3191 : const uno::Reference<embed::XStorage> xModelStorage(
3192 : ::comphelper::OStorageHelper::GetStorageAtPath(xStorage, sUrlPath,
3193 4 : embed::ElementModes::READ, proxy));
3194 :
3195 : // Target storage
3196 : uno::Reference<embed::XStorage> const xTarget(
3197 4 : rExport.GetTargetStorage(), uno::UNO_QUERY_THROW);
3198 :
3199 : // Target of all models
3200 : const uno::Reference<embed::XStorage> xModelsTarget(
3201 4 : xTarget->openStorageElement(sUrlPath.copy(0,sUrlPath.lastIndexOf("/")), embed::ElementModes::WRITE));
3202 :
3203 : // Target of current model
3204 4 : const OUString sModelName = sUrlPath.copy(sUrlPath.lastIndexOf("/")+1);
3205 : const uno::Reference<embed::XStorage> xModelTarget(
3206 4 : xModelsTarget->openStorageElement(sModelName, embed::ElementModes::WRITE));
3207 :
3208 2 : xModelStorage->copyToStorage(xModelTarget);
3209 :
3210 4 : const uno::Reference<embed::XTransactedObject> xModelsTransaction(xModelsTarget, uno::UNO_QUERY);
3211 2 : if (xModelsTransaction.is())
3212 : {
3213 2 : xModelsTransaction->commit();
3214 2 : }
3215 : }
3216 0 : catch (uno::Exception const& e)
3217 : {
3218 : SAL_INFO("xmloff", "exception while saving embedded model: '" << e.Message << "'");
3219 : }
3220 2 : }
3221 2 : }
3222 :
3223 2 : static void lcl_StoreGltfFallback(
3224 : SvXMLExport& rExport,
3225 : const uno::Reference<beans::XPropertySet> xPropSet,
3226 : const OUString& rURL )
3227 : {
3228 2 : OUString sUrlPath;
3229 2 : if (rURL.startsWithIgnoreAsciiCase("vnd.sun.star.Package:", &sUrlPath))
3230 : {
3231 2 : sUrlPath = sUrlPath.copy(0,sUrlPath.lastIndexOf("/"));
3232 : try
3233 : {
3234 : // Base storage
3235 : uno::Reference<document::XStorageBasedDocument> const xSBD(
3236 2 : rExport.GetModel(), uno::UNO_QUERY_THROW);
3237 : const uno::Reference<embed::XStorage> xStorage(
3238 4 : xSBD->getDocumentStorage(), uno::UNO_QUERY_THROW);
3239 :
3240 : // Model source
3241 4 : ::comphelper::LifecycleProxy proxy;
3242 : const uno::Reference<embed::XStorage> xModelStorage(
3243 : ::comphelper::OStorageHelper::GetStorageAtPath(xStorage, sUrlPath,
3244 4 : embed::ElementModes::READ, proxy));
3245 :
3246 : // Target storage
3247 : uno::Reference<embed::XStorage> const xTarget(
3248 4 : rExport.GetTargetStorage(), uno::UNO_QUERY_THROW);
3249 :
3250 : // Target of all models
3251 : const uno::Reference<embed::XStorage> xModelsTarget(
3252 4 : xTarget->openStorageElement(sUrlPath.copy(0,sUrlPath.lastIndexOf("/")), embed::ElementModes::WRITE));
3253 :
3254 : /// Save the fallback image under the 'Models/Fallbacks/' folder
3255 4 : uno::Reference< graphic::XGraphic > xGraphic( xPropSet->getPropertyValue("FallbackGraphic"), uno::UNO_QUERY );
3256 2 : if( xGraphic.is() )
3257 : {
3258 : // Fallback storage
3259 : const uno::Reference<embed::XStorage> xFallbackTarget(
3260 2 : xModelsTarget->openStorageElement("Fallbacks", embed::ElementModes::WRITE));
3261 :
3262 4 : const OUString sModelName = sUrlPath.copy(sUrlPath.lastIndexOf("/")+1);
3263 : uno::Reference< io::XStream > xPictureStream(
3264 4 : xFallbackTarget->openStreamElement( sModelName + ".png", embed::ElementModes::WRITE ), uno::UNO_QUERY_THROW );
3265 :
3266 4 : uno::Reference< graphic::XGraphicProvider > xProvider( graphic::GraphicProvider::create(comphelper::getProcessComponentContext()) );
3267 4 : uno::Sequence< beans::PropertyValue > aArgs( 2 );
3268 2 : aArgs[ 0 ].Name = "MimeType";
3269 2 : aArgs[ 0 ].Value <<= OUString( "image/png" );
3270 2 : aArgs[ 1 ].Name = "OutputStream";
3271 2 : aArgs[ 1 ].Value <<= xPictureStream->getOutputStream();
3272 2 : xProvider->storeGraphic( xGraphic, aArgs );
3273 :
3274 4 : const uno::Reference<embed::XTransactedObject> xFallbackTransaction(xFallbackTarget, uno::UNO_QUERY);
3275 2 : if (xFallbackTransaction.is())
3276 : {
3277 2 : xFallbackTransaction->commit();
3278 : }
3279 :
3280 4 : const OUString sFallbackURL( sUrlPath.copy(0,sUrlPath.lastIndexOf("/")) + "/Fallbacks/" + sModelName + ".png");
3281 2 : rExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, sFallbackURL );
3282 2 : rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
3283 2 : rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
3284 2 : rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
3285 :
3286 4 : SvXMLElementExport aImage( rExport, XML_NAMESPACE_DRAW, XML_IMAGE, false, true );
3287 : }
3288 :
3289 4 : const uno::Reference<embed::XTransactedObject> xModelsTransaction(xModelsTarget, uno::UNO_QUERY);
3290 2 : if (xModelsTransaction.is())
3291 : {
3292 2 : xModelsTransaction->commit();
3293 2 : }
3294 : }
3295 0 : catch (uno::Exception const& e)
3296 : {
3297 : SAL_INFO("xmloff", "exception while saving fallback image of glTF model: '" << e.Message << "'");
3298 : }
3299 2 : }
3300 2 : }
3301 :
3302 : #endif
3303 :
3304 4 : void XMLShapeExport::ImpExportMediaShape(
3305 : const uno::Reference< drawing::XShape >& xShape,
3306 : XmlShapeType eShapeType, sal_Int32 nFeatures, com::sun::star::awt::Point* pRefPoint)
3307 : {
3308 4 : const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
3309 4 : if(xPropSet.is())
3310 : {
3311 : // Transformation
3312 4 : ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
3313 :
3314 4 : if(eShapeType == XmlShapeTypePresMediaShape)
3315 : {
3316 0 : (void)ImpExportPresentationAttributes( xPropSet, GetXMLToken(XML_PRESENTATION_OBJECT) );
3317 : }
3318 4 : bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
3319 : SvXMLElementExport aElem( mrExport, XML_NAMESPACE_DRAW,
3320 4 : XML_FRAME, bCreateNewline, true );
3321 :
3322 : // export media url
3323 8 : OUString aMediaURL;
3324 4 : xPropSet->getPropertyValue("MediaURL") >>= aMediaURL;
3325 8 : OUString sMimeType;
3326 4 : xPropSet->getPropertyValue("MediaMimeType") >>= sMimeType;
3327 :
3328 : OUString const persistentURL =
3329 8 : lcl_StoreMediaAndGetURL(GetExport(), xPropSet, aMediaURL, sMimeType);
3330 : #if HAVE_FEATURE_GLTF
3331 4 : if( sMimeType == "model/vnd.gltf+json" )
3332 2 : lcl_StoreGltfExternals(GetExport(), aMediaURL);
3333 : #endif
3334 :
3335 4 : mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_HREF, persistentURL );
3336 4 : mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
3337 4 : mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
3338 4 : mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
3339 :
3340 : // export mime-type
3341 4 : mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_MIME_TYPE, sMimeType );
3342 :
3343 : // write plugin
3344 4 : SvXMLElementExport* pPluginOBJ = new SvXMLElementExport(mrExport, XML_NAMESPACE_DRAW, XML_PLUGIN, !( nFeatures & SEF_EXPORT_NO_WS ), true);
3345 :
3346 : // export parameters
3347 8 : const OUString aFalseStr( "false" ), aTrueStr( "true" );
3348 :
3349 4 : bool bLoop = false;
3350 8 : const OUString aLoopStr( "Loop" );
3351 4 : xPropSet->getPropertyValue( aLoopStr ) >>= bLoop;
3352 4 : mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, aLoopStr );
3353 4 : mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_VALUE, bLoop ? aTrueStr : aFalseStr );
3354 4 : delete( new SvXMLElementExport( mrExport, XML_NAMESPACE_DRAW, XML_PARAM, false, true ) );
3355 :
3356 4 : bool bMute = false;
3357 8 : const OUString aMuteStr( "Mute" );
3358 4 : xPropSet->getPropertyValue( aMuteStr ) >>= bMute;
3359 4 : mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, aMuteStr );
3360 4 : mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_VALUE, bMute ? aTrueStr : aFalseStr );
3361 4 : delete( new SvXMLElementExport( mrExport, XML_NAMESPACE_DRAW, XML_PARAM, false, true ) );
3362 :
3363 4 : sal_Int16 nVolumeDB = 0;
3364 8 : const OUString aVolumeDBStr( "VolumeDB" );
3365 4 : xPropSet->getPropertyValue("VolumeDB") >>= nVolumeDB;
3366 4 : mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, aVolumeDBStr );
3367 4 : mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_VALUE, OUString::number( nVolumeDB ) );
3368 4 : delete( new SvXMLElementExport( mrExport, XML_NAMESPACE_DRAW, XML_PARAM, false, true ) );
3369 :
3370 : media::ZoomLevel eZoom;
3371 8 : const OUString aZoomStr( "Zoom" );
3372 8 : OUString aZoomValue;
3373 4 : xPropSet->getPropertyValue("Zoom") >>= eZoom;
3374 4 : switch( eZoom )
3375 : {
3376 0 : case( media::ZoomLevel_ZOOM_1_TO_4 ) : aZoomValue = "25%"; break;
3377 0 : case( media::ZoomLevel_ZOOM_1_TO_2 ) : aZoomValue = "50%"; break;
3378 2 : case( media::ZoomLevel_ORIGINAL ) : aZoomValue = "100%"; break;
3379 0 : case( media::ZoomLevel_ZOOM_2_TO_1 ) : aZoomValue = "200%"; break;
3380 0 : case( media::ZoomLevel_ZOOM_4_TO_1 ) : aZoomValue = "400%"; break;
3381 0 : case( media::ZoomLevel_FIT_TO_WINDOW ): aZoomValue = "fit"; break;
3382 0 : case( media::ZoomLevel_FIT_TO_WINDOW_FIXED_ASPECT ): aZoomValue = "fixedfit"; break;
3383 0 : case( media::ZoomLevel_FULLSCREEN ) : aZoomValue = "fullscreen"; break;
3384 :
3385 : default:
3386 2 : break;
3387 : }
3388 :
3389 4 : if( !aZoomValue.isEmpty() )
3390 : {
3391 2 : mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, aZoomStr );
3392 2 : mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_VALUE, aZoomValue );
3393 2 : delete( new SvXMLElementExport( mrExport, XML_NAMESPACE_DRAW, XML_PARAM, false, true ) );
3394 : }
3395 :
3396 4 : delete pPluginOBJ;
3397 : #if HAVE_FEATURE_GLTF
3398 4 : if( sMimeType == "model/vnd.gltf+json" )
3399 6 : lcl_StoreGltfFallback(GetExport(), xPropSet, aMediaURL);
3400 : #endif
3401 4 : }
3402 4 : }
3403 :
3404 0 : void XMLShapeExport::ImpExport3DSceneShape( const uno::Reference< drawing::XShape >& xShape, XmlShapeType, sal_Int32 nFeatures, awt::Point* pRefPoint)
3405 : {
3406 0 : uno::Reference< drawing::XShapes > xShapes(xShape, uno::UNO_QUERY);
3407 0 : if(xShapes.is() && xShapes->getCount())
3408 : {
3409 0 : uno::Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_QUERY );
3410 : DBG_ASSERT( xPropSet.is(), "XMLShapeExport::ImpExport3DSceneShape can't export a scene without a propertyset" );
3411 0 : if( xPropSet.is() )
3412 : {
3413 : // Transformation
3414 0 : ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
3415 :
3416 : // 3d attributes
3417 0 : export3DSceneAttributes( xPropSet );
3418 :
3419 : // write 3DScene shape
3420 0 : bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
3421 0 : SvXMLElementExport aOBJ( mrExport, XML_NAMESPACE_DR3D, XML_SCENE, bCreateNewline, true);
3422 :
3423 0 : ImpExportDescription( xShape ); // #i68101#
3424 0 : ImpExportEvents( xShape );
3425 :
3426 : // write 3DSceneLights
3427 0 : export3DLamps( xPropSet );
3428 :
3429 : // #89764# if export of position is supressed for group shape,
3430 : // positions of contained objects should be written relative to
3431 : // the upper left edge of the group.
3432 0 : awt::Point aUpperLeft;
3433 :
3434 0 : if(!(nFeatures & SEF_EXPORT_POSITION))
3435 : {
3436 0 : nFeatures |= SEF_EXPORT_POSITION;
3437 0 : aUpperLeft = xShape->getPosition();
3438 0 : pRefPoint = &aUpperLeft;
3439 : }
3440 :
3441 : // write members
3442 0 : exportShapes( xShapes, nFeatures, pRefPoint );
3443 0 : }
3444 0 : }
3445 0 : }
3446 :
3447 0 : void XMLShapeExport::ImpExport3DShape(
3448 : const uno::Reference< drawing::XShape >& xShape,
3449 : XmlShapeType eShapeType, sal_Int32 /* nFeatures = SEF_DEFAULT */, awt::Point* /*pRefPoint = NULL */)
3450 : {
3451 0 : const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
3452 0 : if(xPropSet.is())
3453 : {
3454 0 : OUString aStr;
3455 0 : OUStringBuffer sStringBuffer;
3456 :
3457 : // transformation (UNO_NAME_3D_TRANSFORM_MATRIX == "D3DTransformMatrix")
3458 0 : uno::Any aAny = xPropSet->getPropertyValue("D3DTransformMatrix");
3459 0 : drawing::HomogenMatrix xHomMat;
3460 0 : aAny >>= xHomMat;
3461 0 : SdXMLImExTransform3D aTransform;
3462 0 : aTransform.AddHomogenMatrix(xHomMat);
3463 0 : if(aTransform.NeedsAction())
3464 0 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_TRANSFORM, aTransform.GetExportString(mrExport.GetMM100UnitConverter()));
3465 :
3466 0 : switch(eShapeType)
3467 : {
3468 : case XmlShapeTypeDraw3DCubeObject:
3469 : {
3470 : // minEdge
3471 0 : aAny = xPropSet->getPropertyValue("D3DPosition");
3472 0 : drawing::Position3D aPosition3D;
3473 0 : aAny >>= aPosition3D;
3474 0 : ::basegfx::B3DVector aPos3D(aPosition3D.PositionX, aPosition3D.PositionY, aPosition3D.PositionZ);
3475 :
3476 : // maxEdge
3477 0 : aAny = xPropSet->getPropertyValue("D3DSize");
3478 0 : drawing::Direction3D aDirection3D;
3479 0 : aAny >>= aDirection3D;
3480 0 : ::basegfx::B3DVector aDir3D(aDirection3D.DirectionX, aDirection3D.DirectionY, aDirection3D.DirectionZ);
3481 :
3482 : // transform maxEdge from distance to pos
3483 0 : aDir3D = aPos3D + aDir3D;
3484 :
3485 : // write minEdge
3486 0 : if(aPos3D != ::basegfx::B3DVector(-2500.0, -2500.0, -2500.0)) // write only when not default
3487 : {
3488 0 : SvXMLUnitConverter::convertB3DVector(sStringBuffer, aPos3D);
3489 0 : aStr = sStringBuffer.makeStringAndClear();
3490 0 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_MIN_EDGE, aStr);
3491 : }
3492 :
3493 : // write maxEdge
3494 0 : if(aDir3D != ::basegfx::B3DVector(2500.0, 2500.0, 2500.0)) // write only when not default
3495 : {
3496 0 : SvXMLUnitConverter::convertB3DVector(sStringBuffer, aDir3D);
3497 0 : aStr = sStringBuffer.makeStringAndClear();
3498 0 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_MAX_EDGE, aStr);
3499 : }
3500 :
3501 : // write 3DCube shape
3502 : // #i123542# Do this *after* the attributes are added, else these will be lost since opening
3503 : // the scope will clear the global attribute list at the exporter
3504 0 : SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DR3D, XML_CUBE, true, true);
3505 :
3506 0 : break;
3507 : }
3508 : case XmlShapeTypeDraw3DSphereObject:
3509 : {
3510 : // Center
3511 0 : aAny = xPropSet->getPropertyValue("D3DPosition");
3512 0 : drawing::Position3D aPosition3D;
3513 0 : aAny >>= aPosition3D;
3514 0 : ::basegfx::B3DVector aPos3D(aPosition3D.PositionX, aPosition3D.PositionY, aPosition3D.PositionZ);
3515 :
3516 : // Size
3517 0 : aAny = xPropSet->getPropertyValue("D3DSize");
3518 0 : drawing::Direction3D aDirection3D;
3519 0 : aAny >>= aDirection3D;
3520 0 : ::basegfx::B3DVector aDir3D(aDirection3D.DirectionX, aDirection3D.DirectionY, aDirection3D.DirectionZ);
3521 :
3522 : // write Center
3523 0 : if(aPos3D != ::basegfx::B3DVector(0.0, 0.0, 0.0)) // write only when not default
3524 : {
3525 0 : SvXMLUnitConverter::convertB3DVector(sStringBuffer, aPos3D);
3526 0 : aStr = sStringBuffer.makeStringAndClear();
3527 0 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_CENTER, aStr);
3528 : }
3529 :
3530 : // write Size
3531 0 : if(aDir3D != ::basegfx::B3DVector(5000.0, 5000.0, 5000.0)) // write only when not default
3532 : {
3533 0 : SvXMLUnitConverter::convertB3DVector(sStringBuffer, aDir3D);
3534 0 : aStr = sStringBuffer.makeStringAndClear();
3535 0 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_SIZE, aStr);
3536 : }
3537 :
3538 : // write 3DSphere shape
3539 : // #i123542# Do this *after* the attributes are added, else these will be lost since opening
3540 : // the scope will clear the global attribute list at the exporter
3541 0 : SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DR3D, XML_SPHERE, true, true);
3542 :
3543 0 : break;
3544 : }
3545 : case XmlShapeTypeDraw3DLatheObject:
3546 : case XmlShapeTypeDraw3DExtrudeObject:
3547 : {
3548 : // write special 3DLathe/3DExtrude attributes, get 3D tools::PolyPolygon as drawing::PolyPolygonShape3D
3549 0 : aAny = xPropSet->getPropertyValue("D3DPolyPolygon3D");
3550 0 : drawing::PolyPolygonShape3D xPolyPolygon3D;
3551 0 : aAny >>= xPolyPolygon3D;
3552 :
3553 : // convert to 3D PolyPolygon
3554 : const basegfx::B3DPolyPolygon aPolyPolygon3D(
3555 : basegfx::tools::UnoPolyPolygonShape3DToB3DPolyPolygon(
3556 0 : xPolyPolygon3D));
3557 :
3558 : // convert to 2D tools::PolyPolygon using identity 3D transformation (just grep X and Y)
3559 0 : const basegfx::B3DHomMatrix aB3DHomMatrixFor2DConversion;
3560 : const basegfx::B2DPolyPolygon aPolyPolygon(
3561 : basegfx::tools::createB2DPolyPolygonFromB3DPolyPolygon(
3562 : aPolyPolygon3D,
3563 0 : aB3DHomMatrixFor2DConversion));
3564 :
3565 : // get 2D range of it
3566 0 : const basegfx::B2DRange aPolyPolygonRange(aPolyPolygon.getB2DRange());
3567 :
3568 : // export ViewBox
3569 : SdXMLImExViewBox aViewBox(
3570 : aPolyPolygonRange.getMinX(),
3571 : aPolyPolygonRange.getMinY(),
3572 : aPolyPolygonRange.getWidth(),
3573 0 : aPolyPolygonRange.getHeight());
3574 :
3575 0 : mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_VIEWBOX, aViewBox.GetExportString());
3576 :
3577 : // prepare svg:d string
3578 : const OUString aPolygonString(
3579 : basegfx::tools::exportToSvgD(
3580 : aPolyPolygon,
3581 : true, // bUseRelativeCoordinates
3582 : false, // bDetectQuadraticBeziers TTTT: not used in old, but maybe activated now
3583 0 : true)); // bHandleRelativeNextPointCompatible
3584 :
3585 : // write point array
3586 0 : mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_D, aPolygonString);
3587 :
3588 0 : if(eShapeType == XmlShapeTypeDraw3DLatheObject)
3589 : {
3590 : // write 3DLathe shape
3591 0 : SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DR3D, XML_ROTATE, true, true);
3592 : }
3593 : else
3594 : {
3595 : // write 3DExtrude shape
3596 0 : SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DR3D, XML_EXTRUDE, true, true);
3597 : }
3598 0 : break;
3599 : }
3600 : default:
3601 0 : break;
3602 0 : }
3603 0 : }
3604 0 : }
3605 :
3606 : /** helper for chart that adds all attributes of a 3d scene element to the export */
3607 204 : void XMLShapeExport::export3DSceneAttributes( const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& xPropSet )
3608 : {
3609 204 : OUString aStr;
3610 408 : OUStringBuffer sStringBuffer;
3611 :
3612 : // world transformation (UNO_NAME_3D_TRANSFORM_MATRIX == "D3DTransformMatrix")
3613 408 : uno::Any aAny = xPropSet->getPropertyValue("D3DTransformMatrix");
3614 204 : drawing::HomogenMatrix xHomMat;
3615 204 : aAny >>= xHomMat;
3616 408 : SdXMLImExTransform3D aTransform;
3617 204 : aTransform.AddHomogenMatrix(xHomMat);
3618 204 : if(aTransform.NeedsAction())
3619 204 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_TRANSFORM, aTransform.GetExportString(mrExport.GetMM100UnitConverter()));
3620 :
3621 : // VRP, VPN, VUP
3622 204 : aAny = xPropSet->getPropertyValue("D3DCameraGeometry");
3623 204 : drawing::CameraGeometry aCamGeo;
3624 204 : aAny >>= aCamGeo;
3625 :
3626 408 : ::basegfx::B3DVector aVRP(aCamGeo.vrp.PositionX, aCamGeo.vrp.PositionY, aCamGeo.vrp.PositionZ);
3627 204 : if(aVRP != ::basegfx::B3DVector(0.0, 0.0, 1.0)) // write only when not default
3628 : {
3629 204 : SvXMLUnitConverter::convertB3DVector(sStringBuffer, aVRP);
3630 204 : aStr = sStringBuffer.makeStringAndClear();
3631 204 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_VRP, aStr);
3632 : }
3633 :
3634 408 : ::basegfx::B3DVector aVPN(aCamGeo.vpn.DirectionX, aCamGeo.vpn.DirectionY, aCamGeo.vpn.DirectionZ);
3635 204 : if(aVPN != ::basegfx::B3DVector(0.0, 0.0, 1.0)) // write only when not default
3636 : {
3637 204 : SvXMLUnitConverter::convertB3DVector(sStringBuffer, aVPN);
3638 204 : aStr = sStringBuffer.makeStringAndClear();
3639 204 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_VPN, aStr);
3640 : }
3641 :
3642 408 : ::basegfx::B3DVector aVUP(aCamGeo.vup.DirectionX, aCamGeo.vup.DirectionY, aCamGeo.vup.DirectionZ);
3643 204 : if(aVUP != ::basegfx::B3DVector(0.0, 1.0, 0.0)) // write only when not default
3644 : {
3645 204 : SvXMLUnitConverter::convertB3DVector(sStringBuffer, aVUP);
3646 204 : aStr = sStringBuffer.makeStringAndClear();
3647 204 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_VUP, aStr);
3648 : }
3649 :
3650 : // projection "D3DScenePerspective" drawing::ProjectionMode
3651 204 : aAny = xPropSet->getPropertyValue("D3DScenePerspective");
3652 : drawing::ProjectionMode xPrjMode;
3653 204 : aAny >>= xPrjMode;
3654 204 : if(xPrjMode == drawing::ProjectionMode_PARALLEL)
3655 180 : aStr = GetXMLToken(XML_PARALLEL);
3656 : else
3657 24 : aStr = GetXMLToken(XML_PERSPECTIVE);
3658 204 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_PROJECTION, aStr);
3659 :
3660 : // distance
3661 204 : aAny = xPropSet->getPropertyValue("D3DSceneDistance");
3662 204 : sal_Int32 nDistance = 0;
3663 204 : aAny >>= nDistance;
3664 204 : mrExport.GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
3665 408 : nDistance);
3666 204 : aStr = sStringBuffer.makeStringAndClear();
3667 204 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_DISTANCE, aStr);
3668 :
3669 : // focalLength
3670 204 : aAny = xPropSet->getPropertyValue("D3DSceneFocalLength");
3671 204 : sal_Int32 nFocalLength = 0;
3672 204 : aAny >>= nFocalLength;
3673 204 : mrExport.GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
3674 408 : nFocalLength);
3675 204 : aStr = sStringBuffer.makeStringAndClear();
3676 204 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_FOCAL_LENGTH, aStr);
3677 :
3678 : // shadowSlant
3679 204 : aAny = xPropSet->getPropertyValue("D3DSceneShadowSlant");
3680 204 : sal_Int16 nShadowSlant = 0;
3681 204 : aAny >>= nShadowSlant;
3682 204 : ::sax::Converter::convertNumber(sStringBuffer, (sal_Int32)nShadowSlant);
3683 204 : aStr = sStringBuffer.makeStringAndClear();
3684 204 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_SHADOW_SLANT, aStr);
3685 :
3686 : // shadeMode
3687 204 : aAny = xPropSet->getPropertyValue("D3DSceneShadeMode");
3688 : drawing::ShadeMode xShadeMode;
3689 204 : if(aAny >>= xShadeMode)
3690 : {
3691 204 : if(xShadeMode == drawing::ShadeMode_FLAT)
3692 204 : aStr = GetXMLToken(XML_FLAT);
3693 0 : else if(xShadeMode == drawing::ShadeMode_PHONG)
3694 0 : aStr = GetXMLToken(XML_PHONG);
3695 0 : else if(xShadeMode == drawing::ShadeMode_SMOOTH)
3696 0 : aStr = GetXMLToken(XML_GOURAUD);
3697 : else
3698 0 : aStr = GetXMLToken(XML_DRAFT);
3699 : }
3700 : else
3701 : {
3702 : // ShadeMode enum not there, write default
3703 0 : aStr = GetXMLToken(XML_GOURAUD);
3704 : }
3705 204 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_SHADE_MODE, aStr);
3706 :
3707 : // ambientColor
3708 204 : aAny = xPropSet->getPropertyValue("D3DSceneAmbientColor");
3709 204 : sal_Int32 nAmbientColor = 0;
3710 204 : aAny >>= nAmbientColor;
3711 204 : ::sax::Converter::convertColor(sStringBuffer, nAmbientColor);
3712 204 : aStr = sStringBuffer.makeStringAndClear();
3713 204 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_AMBIENT_COLOR, aStr);
3714 :
3715 : // lightingMode
3716 204 : aAny = xPropSet->getPropertyValue("D3DSceneTwoSidedLighting");
3717 204 : bool bTwoSidedLighting = false;
3718 204 : aAny >>= bTwoSidedLighting;
3719 204 : ::sax::Converter::convertBool(sStringBuffer, bTwoSidedLighting);
3720 204 : aStr = sStringBuffer.makeStringAndClear();
3721 408 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_LIGHTING_MODE, aStr);
3722 204 : }
3723 :
3724 : /** helper for chart that exports all lamps from the propertyset */
3725 204 : void XMLShapeExport::export3DLamps( const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& xPropSet )
3726 : {
3727 : // write lamps 1..8 as content
3728 204 : OUString aStr;
3729 408 : OUStringBuffer sStringBuffer;
3730 :
3731 408 : const OUString aColorPropName("D3DSceneLightColor");
3732 408 : const OUString aDirectionPropName("D3DSceneLightDirection");
3733 408 : const OUString aLightOnPropName("D3DSceneLightOn");
3734 :
3735 408 : OUString aPropName;
3736 408 : OUString aIndexStr;
3737 408 : ::basegfx::B3DVector aLightDirection;
3738 204 : drawing::Direction3D xLightDir;
3739 204 : bool bLightOnOff = false;
3740 1836 : for(sal_Int32 nLamp = 1; nLamp <= 8; nLamp++)
3741 : {
3742 1632 : aIndexStr = OUString::number( nLamp );
3743 :
3744 : // lightcolor
3745 1632 : aPropName = aColorPropName;
3746 1632 : aPropName += aIndexStr;
3747 1632 : sal_Int32 nLightColor = 0;
3748 1632 : xPropSet->getPropertyValue( aPropName ) >>= nLightColor;
3749 1632 : ::sax::Converter::convertColor(sStringBuffer, nLightColor);
3750 1632 : aStr = sStringBuffer.makeStringAndClear();
3751 1632 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_DIFFUSE_COLOR, aStr);
3752 :
3753 : // lightdirection
3754 1632 : aPropName = aDirectionPropName;
3755 1632 : aPropName += aIndexStr;
3756 1632 : xPropSet->getPropertyValue(aPropName) >>= xLightDir;
3757 1632 : aLightDirection = ::basegfx::B3DVector(xLightDir.DirectionX, xLightDir.DirectionY, xLightDir.DirectionZ);
3758 1632 : SvXMLUnitConverter::convertB3DVector(sStringBuffer, aLightDirection);
3759 1632 : aStr = sStringBuffer.makeStringAndClear();
3760 1632 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_DIRECTION, aStr);
3761 :
3762 : // lighton
3763 1632 : aPropName = aLightOnPropName;
3764 1632 : aPropName += aIndexStr;
3765 1632 : xPropSet->getPropertyValue(aPropName) >>= bLightOnOff;
3766 1632 : ::sax::Converter::convertBool(sStringBuffer, bLightOnOff);
3767 1632 : aStr = sStringBuffer.makeStringAndClear();
3768 1632 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_ENABLED, aStr);
3769 :
3770 : // specular
3771 : mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_SPECULAR,
3772 1632 : nLamp == 1 ? XML_TRUE : XML_FALSE);
3773 :
3774 : // write light entry
3775 1632 : SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DR3D, XML_LIGHT, true, true);
3776 1836 : }
3777 204 : }
3778 :
3779 :
3780 : // using namespace ::com::sun::star::io;
3781 : // using namespace ::xmloff::EnhancedCustomShapeToken;
3782 :
3783 :
3784 72 : void ExportParameter( OUStringBuffer& rStrBuffer, const com::sun::star::drawing::EnhancedCustomShapeParameter& rParameter )
3785 : {
3786 72 : if ( !rStrBuffer.isEmpty() )
3787 62 : rStrBuffer.append( ' ' );
3788 72 : if ( rParameter.Value.getValueTypeClass() == uno::TypeClass_DOUBLE )
3789 : {
3790 0 : double fNumber = 0.0;
3791 0 : rParameter.Value >>= fNumber;
3792 0 : ::rtl::math::doubleToUStringBuffer( rStrBuffer, fNumber, rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, '.', true );
3793 : }
3794 : else
3795 : {
3796 72 : sal_Int32 nValue = 0;
3797 72 : rParameter.Value >>= nValue;
3798 :
3799 72 : switch( rParameter.Type )
3800 : {
3801 : case com::sun::star::drawing::EnhancedCustomShapeParameterType::EQUATION :
3802 : {
3803 36 : rStrBuffer.append( "?f" + OUString::number( nValue ) );
3804 : }
3805 36 : break;
3806 :
3807 : case com::sun::star::drawing::EnhancedCustomShapeParameterType::ADJUSTMENT :
3808 : {
3809 2 : rStrBuffer.append( '$' );
3810 2 : rStrBuffer.append( OUString::number( nValue ) );
3811 : }
3812 2 : break;
3813 :
3814 : case com::sun::star::drawing::EnhancedCustomShapeParameterType::BOTTOM :
3815 0 : rStrBuffer.append( GetXMLToken( XML_BOTTOM ) ); break;
3816 : case com::sun::star::drawing::EnhancedCustomShapeParameterType::RIGHT :
3817 0 : rStrBuffer.append( GetXMLToken( XML_RIGHT ) ); break;
3818 : case com::sun::star::drawing::EnhancedCustomShapeParameterType::TOP :
3819 2 : rStrBuffer.append( GetXMLToken( XML_TOP ) ); break;
3820 : case com::sun::star::drawing::EnhancedCustomShapeParameterType::LEFT :
3821 0 : rStrBuffer.append( GetXMLToken( XML_LEFT ) ); break;
3822 : case com::sun::star::drawing::EnhancedCustomShapeParameterType::XSTRETCH :
3823 0 : rStrBuffer.append( GetXMLToken( XML_XSTRETCH ) ); break;
3824 : case com::sun::star::drawing::EnhancedCustomShapeParameterType::YSTRETCH :
3825 0 : rStrBuffer.append( GetXMLToken( XML_YSTRETCH ) ); break;
3826 : case com::sun::star::drawing::EnhancedCustomShapeParameterType::HASSTROKE :
3827 0 : rStrBuffer.append( GetXMLToken( XML_HASSTROKE ) ); break;
3828 : case com::sun::star::drawing::EnhancedCustomShapeParameterType::HASFILL :
3829 0 : rStrBuffer.append( GetXMLToken( XML_HASFILL ) ); break;
3830 : case com::sun::star::drawing::EnhancedCustomShapeParameterType::WIDTH :
3831 0 : rStrBuffer.append( GetXMLToken( XML_WIDTH ) ); break;
3832 : case com::sun::star::drawing::EnhancedCustomShapeParameterType::HEIGHT :
3833 0 : rStrBuffer.append( GetXMLToken( XML_HEIGHT ) ); break;
3834 : case com::sun::star::drawing::EnhancedCustomShapeParameterType::LOGWIDTH :
3835 0 : rStrBuffer.append( GetXMLToken( XML_LOGWIDTH ) ); break;
3836 : case com::sun::star::drawing::EnhancedCustomShapeParameterType::LOGHEIGHT :
3837 0 : rStrBuffer.append( GetXMLToken( XML_LOGHEIGHT ) ); break;
3838 : default :
3839 32 : rStrBuffer.append( OUString::number( nValue ) );
3840 : }
3841 : }
3842 72 : }
3843 :
3844 4 : void ImpExportEquations( SvXMLExport& rExport, const uno::Sequence< OUString >& rEquations )
3845 : {
3846 : sal_Int32 i;
3847 34 : for ( i = 0; i < rEquations.getLength(); i++ )
3848 : {
3849 30 : OUString aStr('f');
3850 30 : aStr += OUString::number( i );
3851 30 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, aStr );
3852 :
3853 30 : aStr = rEquations[ i ];
3854 30 : sal_Int32 nIndex = 0;
3855 42 : do
3856 : {
3857 42 : nIndex = aStr.indexOf( '?', nIndex );
3858 42 : if ( nIndex != -1 )
3859 : {
3860 12 : OUString aNew( aStr.copy( 0, nIndex + 1 ) );
3861 12 : aNew += OUString('f');
3862 12 : aNew += aStr.copy( nIndex + 1, ( aStr.getLength() - nIndex ) - 1 );
3863 12 : aStr = aNew;
3864 12 : nIndex++;
3865 : }
3866 : } while( nIndex != -1 );
3867 30 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_FORMULA, aStr );
3868 30 : SvXMLElementExport aOBJ( rExport, XML_NAMESPACE_DRAW, XML_EQUATION, true, true );
3869 30 : }
3870 4 : }
3871 :
3872 2 : void ImpExportHandles( SvXMLExport& rExport, const uno::Sequence< beans::PropertyValues >& rHandles )
3873 : {
3874 2 : sal_uInt32 i, j, nElements = rHandles.getLength();
3875 2 : if ( nElements )
3876 : {
3877 2 : OUString aStr;
3878 4 : OUStringBuffer aStrBuffer;
3879 :
3880 4 : for ( i = 0; i < nElements; i++ )
3881 : {
3882 2 : bool bPosition = false;
3883 2 : const uno::Sequence< beans::PropertyValue >& rPropSeq = rHandles[ i ];
3884 10 : for ( j = 0; j < (sal_uInt32)rPropSeq.getLength(); j++ )
3885 : {
3886 8 : const beans::PropertyValue& rPropVal = rPropSeq[ j ];
3887 8 : switch( EASGet( rPropVal.Name ) )
3888 : {
3889 : case EAS_Position :
3890 : {
3891 2 : com::sun::star::drawing::EnhancedCustomShapeParameterPair aPosition;
3892 2 : if ( rPropVal.Value >>= aPosition )
3893 : {
3894 2 : ExportParameter( aStrBuffer, aPosition.First );
3895 2 : ExportParameter( aStrBuffer, aPosition.Second );
3896 2 : aStr = aStrBuffer.makeStringAndClear();
3897 2 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_POSITION, aStr );
3898 2 : bPosition = true;
3899 2 : }
3900 : }
3901 2 : break;
3902 : case EAS_MirroredX :
3903 : {
3904 : bool bMirroredX;
3905 0 : if ( rPropVal.Value >>= bMirroredX )
3906 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_MIRROR_HORIZONTAL,
3907 0 : bMirroredX ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) );
3908 : }
3909 0 : break;
3910 : case EAS_MirroredY :
3911 : {
3912 : bool bMirroredY;
3913 0 : if ( rPropVal.Value >>= bMirroredY )
3914 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_MIRROR_VERTICAL,
3915 0 : bMirroredY ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) );
3916 : }
3917 0 : break;
3918 : case EAS_Switched :
3919 : {
3920 : bool bSwitched;
3921 2 : if ( rPropVal.Value >>= bSwitched )
3922 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_SWITCHED,
3923 2 : bSwitched ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) );
3924 : }
3925 2 : break;
3926 : case EAS_Polar :
3927 : {
3928 0 : com::sun::star::drawing::EnhancedCustomShapeParameterPair aPolar;
3929 0 : if ( rPropVal.Value >>= aPolar )
3930 : {
3931 0 : ExportParameter( aStrBuffer, aPolar.First );
3932 0 : ExportParameter( aStrBuffer, aPolar.Second );
3933 0 : aStr = aStrBuffer.makeStringAndClear();
3934 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_POLAR, aStr );
3935 0 : }
3936 : }
3937 0 : break;
3938 : case EAS_RadiusRangeMinimum :
3939 : {
3940 0 : com::sun::star::drawing::EnhancedCustomShapeParameter aRadiusRangeMinimum;
3941 0 : if ( rPropVal.Value >>= aRadiusRangeMinimum )
3942 : {
3943 0 : ExportParameter( aStrBuffer, aRadiusRangeMinimum );
3944 0 : aStr = aStrBuffer.makeStringAndClear();
3945 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_RADIUS_RANGE_MINIMUM, aStr );
3946 0 : }
3947 : }
3948 0 : break;
3949 : case EAS_RadiusRangeMaximum :
3950 : {
3951 0 : com::sun::star::drawing::EnhancedCustomShapeParameter aRadiusRangeMaximum;
3952 0 : if ( rPropVal.Value >>= aRadiusRangeMaximum )
3953 : {
3954 0 : ExportParameter( aStrBuffer, aRadiusRangeMaximum );
3955 0 : aStr = aStrBuffer.makeStringAndClear();
3956 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_RADIUS_RANGE_MAXIMUM, aStr );
3957 0 : }
3958 : }
3959 0 : break;
3960 : case EAS_RangeXMinimum :
3961 : {
3962 2 : com::sun::star::drawing::EnhancedCustomShapeParameter aXRangeMinimum;
3963 2 : if ( rPropVal.Value >>= aXRangeMinimum )
3964 : {
3965 2 : ExportParameter( aStrBuffer, aXRangeMinimum );
3966 2 : aStr = aStrBuffer.makeStringAndClear();
3967 2 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_RANGE_X_MINIMUM, aStr );
3968 2 : }
3969 : }
3970 2 : break;
3971 : case EAS_RangeXMaximum :
3972 : {
3973 2 : com::sun::star::drawing::EnhancedCustomShapeParameter aXRangeMaximum;
3974 2 : if ( rPropVal.Value >>= aXRangeMaximum )
3975 : {
3976 2 : ExportParameter( aStrBuffer, aXRangeMaximum );
3977 2 : aStr = aStrBuffer.makeStringAndClear();
3978 2 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_RANGE_X_MAXIMUM, aStr );
3979 2 : }
3980 : }
3981 2 : break;
3982 : case EAS_RangeYMinimum :
3983 : {
3984 0 : com::sun::star::drawing::EnhancedCustomShapeParameter aYRangeMinimum;
3985 0 : if ( rPropVal.Value >>= aYRangeMinimum )
3986 : {
3987 0 : ExportParameter( aStrBuffer, aYRangeMinimum );
3988 0 : aStr = aStrBuffer.makeStringAndClear();
3989 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_RANGE_Y_MINIMUM, aStr );
3990 0 : }
3991 : }
3992 0 : break;
3993 : case EAS_RangeYMaximum :
3994 : {
3995 0 : com::sun::star::drawing::EnhancedCustomShapeParameter aYRangeMaximum;
3996 0 : if ( rPropVal.Value >>= aYRangeMaximum )
3997 : {
3998 0 : ExportParameter( aStrBuffer, aYRangeMaximum );
3999 0 : aStr = aStrBuffer.makeStringAndClear();
4000 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_RANGE_Y_MAXIMUM, aStr );
4001 0 : }
4002 : }
4003 0 : break;
4004 : default:
4005 0 : break;
4006 : }
4007 : }
4008 2 : if ( bPosition )
4009 2 : SvXMLElementExport aOBJ( rExport, XML_NAMESPACE_DRAW, XML_HANDLE, true, true );
4010 : else
4011 0 : rExport.ClearAttrList();
4012 2 : }
4013 : }
4014 2 : }
4015 :
4016 4 : void ImpExportEnhancedPath( SvXMLExport& rExport,
4017 : const uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair >& rCoordinates,
4018 : const uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeSegment >& rSegments,
4019 : bool bExtended = false )
4020 : {
4021 :
4022 4 : OUString aStr;
4023 8 : OUStringBuffer aStrBuffer;
4024 4 : bool bNeedExtended = false;
4025 :
4026 : sal_Int32 i, j, k, l;
4027 :
4028 4 : sal_Int32 nCoords = rCoordinates.getLength();
4029 4 : sal_Int32 nSegments = rSegments.getLength();
4030 4 : bool bSimpleSegments = nSegments == 0;
4031 4 : if ( bSimpleSegments )
4032 0 : nSegments = 4;
4033 32 : for ( j = i = 0; j < nSegments; j++ )
4034 : {
4035 28 : com::sun::star::drawing::EnhancedCustomShapeSegment aSegment;
4036 28 : if ( bSimpleSegments )
4037 : {
4038 : // if there are not enough segments we will default them
4039 0 : switch( j )
4040 : {
4041 : case 0 :
4042 : {
4043 0 : aSegment.Count = 1;
4044 0 : aSegment.Command = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::MOVETO;
4045 : }
4046 0 : break;
4047 : case 1 :
4048 : {
4049 0 : aSegment.Count = (sal_Int16)std::min( nCoords - 1, (sal_Int32)32767 );
4050 0 : aSegment.Command = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::LINETO;
4051 : }
4052 0 : break;
4053 : case 2 :
4054 : {
4055 0 : aSegment.Count = 1;
4056 0 : aSegment.Command = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::CLOSESUBPATH;
4057 : }
4058 0 : break;
4059 : case 3 :
4060 : {
4061 0 : aSegment.Count = 1;
4062 0 : aSegment.Command = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ENDSUBPATH;
4063 : }
4064 0 : break;
4065 : }
4066 : }
4067 : else
4068 28 : aSegment = rSegments[ j ];
4069 :
4070 28 : if ( !aStrBuffer.isEmpty() )
4071 24 : aStrBuffer.append( ' ' );
4072 :
4073 28 : sal_Int32 nParameter = 0;
4074 28 : switch( aSegment.Command )
4075 : {
4076 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::CLOSESUBPATH :
4077 4 : aStrBuffer.append( 'Z' ); break;
4078 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ENDSUBPATH :
4079 4 : aStrBuffer.append( 'N' ); break;
4080 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::NOFILL :
4081 0 : aStrBuffer.append( 'F' ); break;
4082 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::NOSTROKE :
4083 0 : aStrBuffer.append( 'S' ); break;
4084 :
4085 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::MOVETO :
4086 4 : aStrBuffer.append( 'M' ); nParameter = 1; break;
4087 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::LINETO :
4088 8 : aStrBuffer.append( 'L' ); nParameter = 1; break;
4089 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::CURVETO :
4090 0 : aStrBuffer.append( 'C' ); nParameter = 3; break;
4091 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ANGLEELLIPSETO :
4092 0 : aStrBuffer.append( 'T' ); nParameter = 3; break;
4093 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ANGLEELLIPSE :
4094 0 : aStrBuffer.append( 'U' ); nParameter = 3; break;
4095 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ARCTO :
4096 0 : aStrBuffer.append( 'A' ); nParameter = 4; break;
4097 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ARC :
4098 0 : aStrBuffer.append( 'B' ); nParameter = 4; break;
4099 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::CLOCKWISEARCTO :
4100 0 : aStrBuffer.append( 'W' ); nParameter = 4; break;
4101 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::CLOCKWISEARC :
4102 0 : aStrBuffer.append( 'V' ); nParameter = 4; break;
4103 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTX :
4104 4 : aStrBuffer.append( 'X' ); nParameter = 1; break;
4105 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTY :
4106 4 : aStrBuffer.append( 'Y' ); nParameter = 1; break;
4107 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::QUADRATICCURVETO :
4108 0 : aStrBuffer.append( 'Q' ); nParameter = 2; break;
4109 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ARCANGLETO :
4110 0 : if ( bExtended ) {
4111 0 : aStrBuffer.append( 'G' );
4112 0 : nParameter = 2;
4113 : } else {
4114 0 : aStrBuffer.setLength( aStrBuffer.getLength() - 1);
4115 0 : bNeedExtended = true;
4116 0 : i += 2;
4117 : }
4118 0 : break;
4119 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::DARKEN :
4120 0 : if ( bExtended )
4121 0 : aStrBuffer.append( 'H' );
4122 : else
4123 0 : bNeedExtended = true;
4124 0 : break;
4125 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::DARKENLESS :
4126 0 : if ( bExtended )
4127 0 : aStrBuffer.append( 'I' );
4128 : else
4129 0 : bNeedExtended = true;
4130 0 : break;
4131 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::LIGHTEN :
4132 0 : if ( bExtended )
4133 0 : aStrBuffer.append( 'J' );
4134 : else
4135 0 : bNeedExtended = true;
4136 0 : break;
4137 : case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::LIGHTENLESS :
4138 0 : if ( bExtended )
4139 0 : aStrBuffer.append( 'K' );
4140 : else
4141 0 : bNeedExtended = true;
4142 0 : break;
4143 : default : // ups, seems to be something wrong
4144 : {
4145 0 : aSegment.Count = 1;
4146 0 : aSegment.Command = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::LINETO;
4147 : }
4148 0 : break;
4149 : }
4150 28 : if ( nParameter )
4151 : {
4152 44 : for ( k = 0; k < aSegment.Count; k++ )
4153 : {
4154 24 : if ( ( i + nParameter ) <= nCoords )
4155 : {
4156 48 : for ( l = 0; l < nParameter; l++ )
4157 : {
4158 24 : ExportParameter( aStrBuffer, rCoordinates[ i ].First );
4159 24 : ExportParameter( aStrBuffer, rCoordinates[ i++ ].Second );
4160 : }
4161 : }
4162 : else
4163 : {
4164 0 : j = nSegments; // error -> exiting
4165 0 : break;
4166 : }
4167 : }
4168 : }
4169 : }
4170 4 : aStr = aStrBuffer.makeStringAndClear();
4171 4 : rExport.AddAttribute( bExtended ? XML_NAMESPACE_DRAW_EXT : XML_NAMESPACE_DRAW, XML_ENHANCED_PATH, aStr );
4172 4 : if ( !bExtended && bNeedExtended )
4173 4 : ImpExportEnhancedPath( rExport, rCoordinates, rSegments, true );
4174 4 : }
4175 :
4176 4 : void ImpExportEnhancedGeometry( SvXMLExport& rExport, const uno::Reference< beans::XPropertySet >& xPropSet )
4177 : {
4178 4 : bool bEquations = false;
4179 4 : uno::Sequence< OUString > aEquations;
4180 :
4181 4 : bool bHandles = false;
4182 8 : uno::Sequence< beans::PropertyValues > aHandles;
4183 :
4184 4 : bool bCoordinates = false;
4185 8 : uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeSegment > aSegments;
4186 8 : uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair > aCoordinates;
4187 :
4188 8 : uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue > aAdjustmentValues;
4189 :
4190 8 : OUString aStr;
4191 8 : OUStringBuffer aStrBuffer;
4192 4 : SvXMLUnitConverter& rUnitConverter = rExport.GetMM100UnitConverter();
4193 :
4194 8 : uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
4195 :
4196 : // geometry
4197 8 : const OUString sCustomShapeGeometry( "CustomShapeGeometry" );
4198 4 : if ( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName( sCustomShapeGeometry ) )
4199 : {
4200 4 : uno::Any aGeoPropSet( xPropSet->getPropertyValue( sCustomShapeGeometry ) );
4201 8 : uno::Sequence< beans::PropertyValue > aGeoPropSeq;
4202 :
4203 4 : if ( aGeoPropSet >>= aGeoPropSeq )
4204 : {
4205 4 : const OUString sCustomShapeType( "non-primitive" );
4206 8 : OUString aCustomShapeType( sCustomShapeType );
4207 :
4208 4 : sal_Int32 j, nGeoPropCount = aGeoPropSeq.getLength();
4209 30 : for ( j = 0; j < nGeoPropCount; j++ )
4210 : {
4211 26 : const beans::PropertyValue& rGeoProp = aGeoPropSeq[ j ];
4212 26 : switch( EASGet( rGeoProp.Name ) )
4213 : {
4214 : case EAS_Type :
4215 : {
4216 4 : rGeoProp.Value >>= aCustomShapeType;
4217 : }
4218 4 : break;
4219 : case EAS_MirroredX :
4220 : {
4221 : bool bMirroredX;
4222 2 : if ( rGeoProp.Value >>= bMirroredX )
4223 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_MIRROR_HORIZONTAL,
4224 2 : bMirroredX ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) );
4225 : }
4226 2 : break;
4227 : case EAS_MirroredY :
4228 : {
4229 : bool bMirroredY;
4230 2 : if ( rGeoProp.Value >>= bMirroredY )
4231 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_MIRROR_VERTICAL,
4232 2 : bMirroredY ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) );
4233 : }
4234 2 : break;
4235 : case EAS_ViewBox :
4236 : {
4237 4 : awt::Rectangle aRect;
4238 4 : if ( rGeoProp.Value >>= aRect )
4239 : {
4240 4 : SdXMLImExViewBox aViewBox( aRect.X, aRect.Y, aRect.Width, aRect.Height );
4241 4 : rExport.AddAttribute( XML_NAMESPACE_SVG, XML_VIEWBOX, aViewBox.GetExportString() );
4242 : }
4243 : }
4244 4 : break;
4245 : case EAS_TextRotateAngle :
4246 : {
4247 0 : double fTextRotateAngle = 0;
4248 0 : if ( rGeoProp.Value >>= fTextRotateAngle )
4249 : {
4250 : ::sax::Converter::convertDouble(
4251 0 : aStrBuffer, fTextRotateAngle );
4252 0 : aStr = aStrBuffer.makeStringAndClear();
4253 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_TEXT_ROTATE_ANGLE, aStr );
4254 : }
4255 : }
4256 0 : break;
4257 : case EAS_Extrusion :
4258 : {
4259 0 : uno::Sequence< beans::PropertyValue > aExtrusionPropSeq;
4260 0 : if ( rGeoProp.Value >>= aExtrusionPropSeq )
4261 : {
4262 0 : sal_Int32 i, nCount = aExtrusionPropSeq.getLength();
4263 0 : for ( i = 0; i < nCount; i++ )
4264 : {
4265 0 : const beans::PropertyValue& rProp = aExtrusionPropSeq[ i ];
4266 0 : switch( EASGet( rProp.Name ) )
4267 : {
4268 : case EAS_Extrusion :
4269 : {
4270 : bool bExtrusionOn;
4271 0 : if ( rProp.Value >>= bExtrusionOn )
4272 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION,
4273 0 : bExtrusionOn ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) );
4274 : }
4275 0 : break;
4276 : case EAS_Brightness :
4277 : {
4278 0 : double fExtrusionBrightness = 0;
4279 0 : if ( rProp.Value >>= fExtrusionBrightness )
4280 : {
4281 : ::sax::Converter::convertDouble(
4282 : aStrBuffer,
4283 : fExtrusionBrightness,
4284 : false,
4285 : util::MeasureUnit::PERCENT,
4286 0 : util::MeasureUnit::PERCENT);
4287 0 : aStrBuffer.append( '%' );
4288 0 : aStr = aStrBuffer.makeStringAndClear();
4289 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_BRIGHTNESS, aStr );
4290 : }
4291 : }
4292 0 : break;
4293 : case EAS_Depth :
4294 : {
4295 0 : com::sun::star::drawing::EnhancedCustomShapeParameterPair aDepthParaPair;
4296 0 : if ( rProp.Value >>= aDepthParaPair )
4297 : {
4298 0 : double fDepth = 0;
4299 0 : if ( aDepthParaPair.First.Value >>= fDepth )
4300 : {
4301 0 : rExport.GetMM100UnitConverter().convertDouble( aStrBuffer, fDepth, true );
4302 0 : ExportParameter( aStrBuffer, aDepthParaPair.Second );
4303 0 : aStr = aStrBuffer.makeStringAndClear();
4304 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_DEPTH, aStr );
4305 : }
4306 0 : }
4307 : }
4308 0 : break;
4309 : case EAS_Diffusion :
4310 : {
4311 0 : double fExtrusionDiffusion = 0;
4312 0 : if ( rProp.Value >>= fExtrusionDiffusion )
4313 : {
4314 : ::sax::Converter::convertDouble(
4315 : aStrBuffer,
4316 : fExtrusionDiffusion,
4317 : false,
4318 : util::MeasureUnit::PERCENT,
4319 0 : util::MeasureUnit::PERCENT);
4320 0 : aStrBuffer.append( '%' );
4321 0 : aStr = aStrBuffer.makeStringAndClear();
4322 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_DIFFUSION, aStr );
4323 : }
4324 : }
4325 0 : break;
4326 : case EAS_NumberOfLineSegments :
4327 : {
4328 0 : sal_Int32 nExtrusionNumberOfLineSegments = 0;
4329 0 : if ( rProp.Value >>= nExtrusionNumberOfLineSegments )
4330 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_NUMBER_OF_LINE_SEGMENTS, OUString::number( nExtrusionNumberOfLineSegments ) );
4331 : }
4332 0 : break;
4333 : case EAS_LightFace :
4334 : {
4335 : bool bExtrusionLightFace;
4336 0 : if ( rProp.Value >>= bExtrusionLightFace )
4337 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_LIGHT_FACE,
4338 0 : bExtrusionLightFace ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) );
4339 : }
4340 0 : break;
4341 : case EAS_FirstLightHarsh :
4342 : {
4343 : bool bExtrusionFirstLightHarsh;
4344 0 : if ( rProp.Value >>= bExtrusionFirstLightHarsh )
4345 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_FIRST_LIGHT_HARSH,
4346 0 : bExtrusionFirstLightHarsh ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) );
4347 : }
4348 0 : break;
4349 : case EAS_SecondLightHarsh :
4350 : {
4351 : bool bExtrusionSecondLightHarsh;
4352 0 : if ( rProp.Value >>= bExtrusionSecondLightHarsh )
4353 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_SECOND_LIGHT_HARSH,
4354 0 : bExtrusionSecondLightHarsh ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) );
4355 : }
4356 0 : break;
4357 : case EAS_FirstLightLevel :
4358 : {
4359 0 : double fExtrusionFirstLightLevel = 0;
4360 0 : if ( rProp.Value >>= fExtrusionFirstLightLevel )
4361 : {
4362 : ::sax::Converter::convertDouble(
4363 : aStrBuffer,
4364 : fExtrusionFirstLightLevel,
4365 : false,
4366 : util::MeasureUnit::PERCENT,
4367 0 : util::MeasureUnit::PERCENT);
4368 0 : aStrBuffer.append( '%' );
4369 0 : aStr = aStrBuffer.makeStringAndClear();
4370 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_FIRST_LIGHT_LEVEL, aStr );
4371 : }
4372 : }
4373 0 : break;
4374 : case EAS_SecondLightLevel :
4375 : {
4376 0 : double fExtrusionSecondLightLevel = 0;
4377 0 : if ( rProp.Value >>= fExtrusionSecondLightLevel )
4378 : {
4379 : ::sax::Converter::convertDouble(
4380 : aStrBuffer,
4381 : fExtrusionSecondLightLevel,
4382 : false,
4383 : util::MeasureUnit::PERCENT,
4384 0 : util::MeasureUnit::PERCENT);
4385 0 : aStrBuffer.append( '%' );
4386 0 : aStr = aStrBuffer.makeStringAndClear();
4387 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_SECOND_LIGHT_LEVEL, aStr );
4388 : }
4389 : }
4390 0 : break;
4391 : case EAS_FirstLightDirection :
4392 : {
4393 0 : drawing::Direction3D aExtrusionFirstLightDirection;
4394 0 : if ( rProp.Value >>= aExtrusionFirstLightDirection )
4395 : {
4396 : ::basegfx::B3DVector aVec3D( aExtrusionFirstLightDirection.DirectionX, aExtrusionFirstLightDirection.DirectionY,
4397 0 : aExtrusionFirstLightDirection.DirectionZ );
4398 0 : SvXMLUnitConverter::convertB3DVector( aStrBuffer, aVec3D );
4399 0 : aStr = aStrBuffer.makeStringAndClear();
4400 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_FIRST_LIGHT_DIRECTION, aStr );
4401 : }
4402 : }
4403 0 : break;
4404 : case EAS_SecondLightDirection :
4405 : {
4406 0 : drawing::Direction3D aExtrusionSecondLightDirection;
4407 0 : if ( rProp.Value >>= aExtrusionSecondLightDirection )
4408 : {
4409 : ::basegfx::B3DVector aVec3D( aExtrusionSecondLightDirection.DirectionX, aExtrusionSecondLightDirection.DirectionY,
4410 0 : aExtrusionSecondLightDirection.DirectionZ );
4411 0 : SvXMLUnitConverter::convertB3DVector( aStrBuffer, aVec3D );
4412 0 : aStr = aStrBuffer.makeStringAndClear();
4413 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_SECOND_LIGHT_DIRECTION, aStr );
4414 : }
4415 : }
4416 0 : break;
4417 : case EAS_Metal :
4418 : {
4419 : bool bExtrusionMetal;
4420 0 : if ( rProp.Value >>= bExtrusionMetal )
4421 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_METAL,
4422 0 : bExtrusionMetal ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) );
4423 : }
4424 0 : break;
4425 : case EAS_ShadeMode :
4426 : {
4427 : // shadeMode
4428 : drawing::ShadeMode eShadeMode;
4429 0 : if( rProp.Value >>= eShadeMode )
4430 : {
4431 0 : if( eShadeMode == drawing::ShadeMode_FLAT )
4432 0 : aStr = GetXMLToken( XML_FLAT );
4433 0 : else if( eShadeMode == drawing::ShadeMode_PHONG )
4434 0 : aStr = GetXMLToken( XML_PHONG );
4435 0 : else if( eShadeMode == drawing::ShadeMode_SMOOTH )
4436 0 : aStr = GetXMLToken( XML_GOURAUD );
4437 : else
4438 0 : aStr = GetXMLToken( XML_DRAFT );
4439 : }
4440 : else
4441 : {
4442 : // ShadeMode enum not there, write default
4443 0 : aStr = GetXMLToken( XML_FLAT);
4444 : }
4445 0 : rExport.AddAttribute( XML_NAMESPACE_DR3D, XML_SHADE_MODE, aStr );
4446 : }
4447 0 : break;
4448 : case EAS_RotateAngle :
4449 : {
4450 0 : com::sun::star::drawing::EnhancedCustomShapeParameterPair aRotateAngleParaPair;
4451 0 : if ( rProp.Value >>= aRotateAngleParaPair )
4452 : {
4453 0 : ExportParameter( aStrBuffer, aRotateAngleParaPair.First );
4454 0 : ExportParameter( aStrBuffer, aRotateAngleParaPair.Second );
4455 0 : aStr = aStrBuffer.makeStringAndClear();
4456 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_ROTATION_ANGLE, aStr );
4457 0 : }
4458 : }
4459 0 : break;
4460 : case EAS_RotationCenter :
4461 : {
4462 0 : drawing::Direction3D aExtrusionRotationCenter;
4463 0 : if ( rProp.Value >>= aExtrusionRotationCenter )
4464 : {
4465 : ::basegfx::B3DVector aVec3D( aExtrusionRotationCenter.DirectionX, aExtrusionRotationCenter.DirectionY,
4466 0 : aExtrusionRotationCenter.DirectionZ );
4467 0 : SvXMLUnitConverter::convertB3DVector( aStrBuffer, aVec3D );
4468 0 : aStr = aStrBuffer.makeStringAndClear();
4469 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_ROTATION_CENTER, aStr );
4470 : }
4471 : }
4472 0 : break;
4473 : case EAS_Shininess :
4474 : {
4475 0 : double fExtrusionShininess = 0;
4476 0 : if ( rProp.Value >>= fExtrusionShininess )
4477 : {
4478 : ::sax::Converter::convertDouble(
4479 : aStrBuffer,
4480 : fExtrusionShininess,
4481 : false,
4482 : util::MeasureUnit::PERCENT,
4483 0 : util::MeasureUnit::PERCENT);
4484 0 : aStrBuffer.append( '%' );
4485 0 : aStr = aStrBuffer.makeStringAndClear();
4486 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_SHININESS, aStr );
4487 : }
4488 : }
4489 0 : break;
4490 : case EAS_Skew :
4491 : {
4492 0 : com::sun::star::drawing::EnhancedCustomShapeParameterPair aSkewParaPair;
4493 0 : if ( rProp.Value >>= aSkewParaPair )
4494 : {
4495 0 : ExportParameter( aStrBuffer, aSkewParaPair.First );
4496 0 : ExportParameter( aStrBuffer, aSkewParaPair.Second );
4497 0 : aStr = aStrBuffer.makeStringAndClear();
4498 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_SKEW, aStr );
4499 0 : }
4500 : }
4501 0 : break;
4502 : case EAS_Specularity :
4503 : {
4504 0 : double fExtrusionSpecularity = 0;
4505 0 : if ( rProp.Value >>= fExtrusionSpecularity )
4506 : {
4507 : ::sax::Converter::convertDouble(
4508 : aStrBuffer,
4509 : fExtrusionSpecularity,
4510 : false,
4511 : util::MeasureUnit::PERCENT,
4512 0 : util::MeasureUnit::PERCENT);
4513 0 : aStrBuffer.append( '%' );
4514 0 : aStr = aStrBuffer.makeStringAndClear();
4515 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_SPECULARITY, aStr );
4516 : }
4517 : }
4518 0 : break;
4519 : case EAS_ProjectionMode :
4520 : {
4521 : drawing::ProjectionMode eProjectionMode;
4522 0 : if ( rProp.Value >>= eProjectionMode )
4523 : rExport.AddAttribute( XML_NAMESPACE_DR3D, XML_PROJECTION,
4524 0 : eProjectionMode == drawing::ProjectionMode_PARALLEL ? GetXMLToken( XML_PARALLEL ) : GetXMLToken( XML_PERSPECTIVE ) );
4525 : }
4526 0 : break;
4527 : case EAS_ViewPoint :
4528 : {
4529 0 : drawing::Position3D aExtrusionViewPoint;
4530 0 : if ( rProp.Value >>= aExtrusionViewPoint )
4531 : {
4532 0 : rUnitConverter.convertPosition3D( aStrBuffer, aExtrusionViewPoint );
4533 0 : aStr = aStrBuffer.makeStringAndClear();
4534 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_VIEWPOINT, aStr );
4535 : }
4536 : }
4537 0 : break;
4538 : case EAS_Origin :
4539 : {
4540 0 : com::sun::star::drawing::EnhancedCustomShapeParameterPair aOriginParaPair;
4541 0 : if ( rProp.Value >>= aOriginParaPair )
4542 : {
4543 0 : ExportParameter( aStrBuffer, aOriginParaPair.First );
4544 0 : ExportParameter( aStrBuffer, aOriginParaPair.Second );
4545 0 : aStr = aStrBuffer.makeStringAndClear();
4546 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_ORIGIN, aStr );
4547 0 : }
4548 : }
4549 0 : break;
4550 : case EAS_Color :
4551 : {
4552 : bool bExtrusionColor;
4553 0 : if ( rProp.Value >>= bExtrusionColor )
4554 : {
4555 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_COLOR,
4556 0 : bExtrusionColor ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) );
4557 : }
4558 : }
4559 0 : break;
4560 : default:
4561 0 : break;
4562 : }
4563 : }
4564 0 : }
4565 : }
4566 0 : break;
4567 : case EAS_TextPath :
4568 : {
4569 0 : uno::Sequence< beans::PropertyValue > aTextPathPropSeq;
4570 0 : if ( rGeoProp.Value >>= aTextPathPropSeq )
4571 : {
4572 0 : sal_Int32 i, nCount = aTextPathPropSeq.getLength();
4573 0 : for ( i = 0; i < nCount; i++ )
4574 : {
4575 0 : const beans::PropertyValue& rProp = aTextPathPropSeq[ i ];
4576 0 : switch( EASGet( rProp.Name ) )
4577 : {
4578 : case EAS_TextPath :
4579 : {
4580 : bool bTextPathOn;
4581 0 : if ( rProp.Value >>= bTextPathOn )
4582 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_TEXT_PATH,
4583 0 : bTextPathOn ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) );
4584 : }
4585 0 : break;
4586 : case EAS_TextPathMode :
4587 : {
4588 : com::sun::star::drawing::EnhancedCustomShapeTextPathMode eTextPathMode;
4589 0 : if ( rProp.Value >>= eTextPathMode )
4590 : {
4591 0 : switch ( eTextPathMode )
4592 : {
4593 0 : case com::sun::star::drawing::EnhancedCustomShapeTextPathMode_NORMAL: aStr = GetXMLToken( XML_NORMAL ); break;
4594 0 : case com::sun::star::drawing::EnhancedCustomShapeTextPathMode_PATH : aStr = GetXMLToken( XML_PATH ); break;
4595 0 : case com::sun::star::drawing::EnhancedCustomShapeTextPathMode_SHAPE : aStr = GetXMLToken( XML_SHAPE ); break;
4596 : default:
4597 0 : break;
4598 : }
4599 0 : if ( !aStr.isEmpty() )
4600 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_TEXT_PATH_MODE, aStr );
4601 : }
4602 : }
4603 0 : break;
4604 : case EAS_ScaleX :
4605 : {
4606 : bool bScaleX;
4607 0 : if ( rProp.Value >>= bScaleX )
4608 : {
4609 0 : aStr = bScaleX ? GetXMLToken( XML_SHAPE ) : GetXMLToken( XML_PATH );
4610 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_TEXT_PATH_SCALE, aStr );
4611 : }
4612 : }
4613 0 : break;
4614 : case EAS_SameLetterHeights :
4615 : {
4616 : bool bSameLetterHeights;
4617 0 : if ( rProp.Value >>= bSameLetterHeights )
4618 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_TEXT_PATH_SAME_LETTER_HEIGHTS,
4619 0 : bSameLetterHeights ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) );
4620 : }
4621 0 : break;
4622 : default:
4623 0 : break;
4624 : }
4625 : }
4626 0 : }
4627 : }
4628 0 : break;
4629 : case EAS_Path :
4630 : {
4631 4 : uno::Sequence< beans::PropertyValue > aPathPropSeq;
4632 4 : if ( rGeoProp.Value >>= aPathPropSeq )
4633 : {
4634 4 : sal_Int32 i, nCount = aPathPropSeq.getLength();
4635 20 : for ( i = 0; i < nCount; i++ )
4636 : {
4637 16 : const beans::PropertyValue& rProp = aPathPropSeq[ i ];
4638 :
4639 16 : switch( EASGet( rProp.Name ) )
4640 : {
4641 : case EAS_SubViewSize:
4642 : {
4643 0 : uno::Sequence< awt::Size > aSubViewSizes;
4644 0 : rProp.Value >>= aSubViewSizes;
4645 :
4646 0 : for ( int nIdx = 0; nIdx < aSubViewSizes.getLength(); nIdx++ )
4647 : {
4648 0 : if ( nIdx )
4649 0 : aStrBuffer.append(' ');
4650 0 : ::sax::Converter::convertNumber( aStrBuffer, aSubViewSizes[nIdx].Width );
4651 0 : aStrBuffer.append(' ');
4652 0 : ::sax::Converter::convertNumber( aStrBuffer, aSubViewSizes[nIdx].Height );
4653 : }
4654 0 : aStr = aStrBuffer.makeStringAndClear();
4655 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW_EXT, XML_SUB_VIEW_SIZE, aStr );
4656 : }
4657 0 : break;
4658 : case EAS_ExtrusionAllowed :
4659 : {
4660 : bool bExtrusionAllowed;
4661 0 : if ( rProp.Value >>= bExtrusionAllowed )
4662 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_EXTRUSION_ALLOWED,
4663 0 : bExtrusionAllowed ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) );
4664 : }
4665 0 : break;
4666 : case EAS_ConcentricGradientFillAllowed :
4667 : {
4668 : bool bConcentricGradientFillAllowed;
4669 0 : if ( rProp.Value >>= bConcentricGradientFillAllowed )
4670 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_CONCENTRIC_GRADIENT_FILL_ALLOWED,
4671 0 : bConcentricGradientFillAllowed ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) );
4672 : }
4673 0 : break;
4674 : case EAS_TextPathAllowed :
4675 : {
4676 : bool bTextPathAllowed;
4677 0 : if ( rProp.Value >>= bTextPathAllowed )
4678 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_TEXT_PATH_ALLOWED,
4679 0 : bTextPathAllowed ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) );
4680 : }
4681 0 : break;
4682 : case EAS_GluePoints :
4683 : {
4684 0 : com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair> aGluePoints;
4685 0 : if ( rProp.Value >>= aGluePoints )
4686 : {
4687 0 : sal_Int32 k, nElements = aGluePoints.getLength();
4688 0 : if ( nElements )
4689 : {
4690 0 : for( k = 0; k < nElements; k++ )
4691 : {
4692 0 : ExportParameter( aStrBuffer, aGluePoints[ k ].First );
4693 0 : ExportParameter( aStrBuffer, aGluePoints[ k ].Second );
4694 : }
4695 0 : aStr = aStrBuffer.makeStringAndClear();
4696 : }
4697 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_GLUE_POINTS, aStr );
4698 0 : }
4699 : }
4700 0 : break;
4701 : case EAS_GluePointType :
4702 : {
4703 0 : sal_Int16 nGluePointType = sal_Int16();
4704 0 : if ( rProp.Value >>= nGluePointType )
4705 : {
4706 0 : switch ( nGluePointType )
4707 : {
4708 0 : case com::sun::star::drawing::EnhancedCustomShapeGluePointType::NONE : aStr = GetXMLToken( XML_NONE ); break;
4709 0 : case com::sun::star::drawing::EnhancedCustomShapeGluePointType::SEGMENTS : aStr = GetXMLToken( XML_SEGMENTS ); break;
4710 0 : case com::sun::star::drawing::EnhancedCustomShapeGluePointType::RECT : aStr = GetXMLToken( XML_RECTANGLE ); break;
4711 : }
4712 0 : if ( !aStr.isEmpty() )
4713 0 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_GLUE_POINT_TYPE, aStr );
4714 : }
4715 : }
4716 0 : break;
4717 : case EAS_Coordinates :
4718 : {
4719 4 : bCoordinates = ( rProp.Value >>= aCoordinates );
4720 : }
4721 4 : break;
4722 : case EAS_Segments :
4723 : {
4724 4 : rProp.Value >>= aSegments;
4725 : }
4726 4 : break;
4727 : case EAS_StretchX :
4728 : {
4729 2 : sal_Int32 nStretchPoint = 0;
4730 2 : if ( rProp.Value >>= nStretchPoint )
4731 2 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_PATH_STRETCHPOINT_X, OUString::number( nStretchPoint ) );
4732 : }
4733 2 : break;
4734 : case EAS_StretchY :
4735 : {
4736 2 : sal_Int32 nStretchPoint = 0;
4737 2 : if ( rProp.Value >>= nStretchPoint )
4738 2 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_PATH_STRETCHPOINT_Y, OUString::number( nStretchPoint ) );
4739 : }
4740 2 : break;
4741 : case EAS_TextFrames :
4742 : {
4743 4 : com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeTextFrame > aPathTextFrames;
4744 4 : if ( rProp.Value >>= aPathTextFrames )
4745 : {
4746 4 : if ( (sal_uInt16)aPathTextFrames.getLength() )
4747 : {
4748 4 : sal_uInt16 k, nElements = (sal_uInt16)aPathTextFrames.getLength();
4749 8 : for ( k = 0; k < nElements; k++ )
4750 : {
4751 4 : ExportParameter( aStrBuffer, aPathTextFrames[ k ].TopLeft.First );
4752 4 : ExportParameter( aStrBuffer, aPathTextFrames[ k ].TopLeft.Second );
4753 4 : ExportParameter( aStrBuffer, aPathTextFrames[ k ].BottomRight.First );
4754 4 : ExportParameter( aStrBuffer, aPathTextFrames[ k ].BottomRight.Second );
4755 : }
4756 4 : aStr = aStrBuffer.makeStringAndClear();
4757 : }
4758 4 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_TEXT_AREAS, aStr );
4759 4 : }
4760 : }
4761 4 : break;
4762 : default:
4763 0 : break;
4764 : }
4765 : }
4766 4 : }
4767 : }
4768 4 : break;
4769 : case EAS_Equations :
4770 : {
4771 4 : bEquations = ( rGeoProp.Value >>= aEquations );
4772 : }
4773 4 : break;
4774 : case EAS_Handles :
4775 : {
4776 2 : bHandles = ( rGeoProp.Value >>= aHandles );
4777 : }
4778 2 : break;
4779 : case EAS_AdjustmentValues :
4780 : {
4781 4 : rGeoProp.Value >>= aAdjustmentValues;
4782 : }
4783 4 : break;
4784 : default:
4785 0 : break;
4786 : }
4787 : } // for
4788 4 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_TYPE, aCustomShapeType );
4789 :
4790 : // adjustments
4791 4 : sal_Int32 nAdjustmentValues = aAdjustmentValues.getLength();
4792 4 : if ( nAdjustmentValues )
4793 : {
4794 2 : sal_Int32 i, nValue = 0;
4795 4 : for ( i = 0; i < nAdjustmentValues; i++ )
4796 : {
4797 2 : if ( i )
4798 0 : aStrBuffer.append( ' ' );
4799 :
4800 2 : const com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue& rAdj = aAdjustmentValues[ i ];
4801 2 : if ( rAdj.State == beans::PropertyState_DIRECT_VALUE )
4802 : {
4803 2 : if ( rAdj.Value.getValueTypeClass() == uno::TypeClass_DOUBLE )
4804 : {
4805 0 : double fValue = 0.0;
4806 0 : rAdj.Value >>= fValue;
4807 0 : ::sax::Converter::convertDouble(aStrBuffer, fValue);
4808 : }
4809 : else
4810 : {
4811 2 : rAdj.Value >>= nValue;
4812 2 : ::sax::Converter::convertNumber(aStrBuffer, nValue);
4813 : }
4814 : }
4815 : else
4816 : {
4817 : // this should not be, but better than setting nothing
4818 0 : ::sax::Converter::convertNumber( aStrBuffer, 0 );
4819 : }
4820 : }
4821 2 : aStr = aStrBuffer.makeStringAndClear();
4822 2 : rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_MODIFIERS, aStr );
4823 : }
4824 4 : if ( bCoordinates )
4825 8 : ImpExportEnhancedPath( rExport, aCoordinates, aSegments );
4826 4 : }
4827 : }
4828 4 : SvXMLElementExport aOBJ( rExport, XML_NAMESPACE_DRAW, XML_ENHANCED_GEOMETRY, true, true );
4829 4 : if ( bEquations )
4830 4 : ImpExportEquations( rExport, aEquations );
4831 4 : if ( bHandles )
4832 6 : ImpExportHandles( rExport, aHandles );
4833 4 : }
4834 :
4835 4 : void XMLShapeExport::ImpExportCustomShape(
4836 : const uno::Reference< drawing::XShape >& xShape,
4837 : XmlShapeType, sal_Int32 nFeatures, com::sun::star::awt::Point* pRefPoint )
4838 : {
4839 4 : const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
4840 4 : if ( xPropSet.is() )
4841 : {
4842 4 : OUString aStr;
4843 8 : uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
4844 :
4845 : // Transformation
4846 4 : ImpExportNewTrans( xPropSet, nFeatures, pRefPoint );
4847 :
4848 4 : if ( xPropSetInfo.is() )
4849 : {
4850 4 : if ( xPropSetInfo->hasPropertyByName( "CustomShapeEngine" ) )
4851 : {
4852 4 : uno::Any aEngine( xPropSet->getPropertyValue( "CustomShapeEngine" ) );
4853 4 : if ( ( aEngine >>= aStr ) && !aStr.isEmpty() )
4854 0 : mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_ENGINE, aStr );
4855 : }
4856 4 : if ( xPropSetInfo->hasPropertyByName( "CustomShapeData" ) )
4857 : {
4858 4 : uno::Any aData( xPropSet->getPropertyValue( "CustomShapeData" ) );
4859 4 : if ( ( aData >>= aStr ) && !aStr.isEmpty() )
4860 0 : mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_DATA, aStr );
4861 : }
4862 : }
4863 4 : bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 ); // #86116#/#92210#
4864 8 : SvXMLElementExport aOBJ( mrExport, XML_NAMESPACE_DRAW, XML_CUSTOM_SHAPE, bCreateNewline, true );
4865 4 : ImpExportDescription( xShape ); // #i68101#
4866 4 : ImpExportEvents( xShape );
4867 4 : ImpExportGluePoints( xShape );
4868 4 : ImpExportText( xShape );
4869 8 : ImpExportEnhancedGeometry( mrExport, xPropSet );
4870 4 : }
4871 4 : }
4872 :
4873 0 : void XMLShapeExport::ImpExportTableShape( const uno::Reference< drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures, com::sun::star::awt::Point* pRefPoint )
4874 : {
4875 0 : uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
4876 0 : uno::Reference< container::XNamed > xNamed(xShape, uno::UNO_QUERY);
4877 :
4878 : DBG_ASSERT( xPropSet.is() && xNamed.is(), "xmloff::XMLShapeExport::ImpExportTableShape(), tabe shape is not implementing needed interfaces");
4879 0 : if(xPropSet.is() && xNamed.is()) try
4880 : {
4881 : // Transformation
4882 0 : ImpExportNewTrans(xPropSet, nFeatures, pRefPoint);
4883 :
4884 0 : bool bIsEmptyPresObj = false;
4885 :
4886 : // presentation settings
4887 0 : if(eShapeType == XmlShapeTypePresTableShape)
4888 0 : bIsEmptyPresObj = ImpExportPresentationAttributes( xPropSet, GetXMLToken(XML_PRESENTATION_TABLE) );
4889 :
4890 0 : const bool bCreateNewline( (nFeatures & SEF_EXPORT_NO_WS) == 0 );
4891 0 : const bool bExportEmbedded(0 != (mrExport.getExportFlags() & EXPORT_EMBEDDED));
4892 :
4893 0 : SvXMLElementExport aElement( mrExport, XML_NAMESPACE_DRAW, XML_FRAME, bCreateNewline, true );
4894 :
4895 : // do not export in ODF 1.1 or older
4896 0 : if( mrExport.getDefaultVersion() >= SvtSaveOptions::ODFVER_012 )
4897 : {
4898 0 : if( !bIsEmptyPresObj )
4899 : {
4900 0 : uno::Reference< container::XNamed > xTemplate( xPropSet->getPropertyValue("TableTemplate"), uno::UNO_QUERY );
4901 0 : if( xTemplate.is() )
4902 : {
4903 0 : const OUString sTemplate( xTemplate->getName() );
4904 0 : if( !sTemplate.isEmpty() )
4905 : {
4906 0 : mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_TEMPLATE_NAME, sTemplate );
4907 :
4908 0 : for( const XMLPropertyMapEntry* pEntry = &aXMLTableShapeAttributes[0]; pEntry->msApiName; pEntry++ )
4909 : {
4910 : try
4911 : {
4912 0 : bool bBool = false;
4913 0 : const OUString sAPIPropertyName( pEntry->msApiName, pEntry->nApiNameLength, RTL_TEXTENCODING_ASCII_US );
4914 :
4915 0 : xPropSet->getPropertyValue( sAPIPropertyName ) >>= bBool;
4916 0 : if( bBool )
4917 0 : mrExport.AddAttribute(pEntry->mnNameSpace, pEntry->meXMLName, XML_TRUE );
4918 : }
4919 0 : catch( uno::Exception& )
4920 : {
4921 : OSL_FAIL("XMLShapeExport::ImpExportTableShape(), exception caught!");
4922 : }
4923 : }
4924 0 : }
4925 : }
4926 :
4927 0 : uno::Reference< table::XColumnRowRange > xRange( xPropSet->getPropertyValue( msModel ), uno::UNO_QUERY_THROW );
4928 0 : GetShapeTableExport()->exportTable( xRange );
4929 : }
4930 : }
4931 :
4932 0 : if( !bIsEmptyPresObj )
4933 : {
4934 0 : uno::Reference< graphic::XGraphic > xGraphic( xPropSet->getPropertyValue("ReplacementGraphic"), uno::UNO_QUERY );
4935 0 : if( xGraphic.is() ) try
4936 : {
4937 0 : uno::Reference< uno::XComponentContext > xContext = GetExport().getComponentContext();
4938 :
4939 0 : uno::Reference< embed::XStorage > xPictureStorage;
4940 0 : uno::Reference< embed::XStorage > xStorage;
4941 0 : uno::Reference< io::XStream > xPictureStream;
4942 :
4943 0 : OUString sPictureName;
4944 0 : if( bExportEmbedded )
4945 : {
4946 0 : xPictureStream.set( xContext->getServiceManager()->createInstanceWithContext( "com.sun.star.comp.MemoryStream", xContext), uno::UNO_QUERY_THROW );
4947 : }
4948 : else
4949 : {
4950 0 : xStorage.set( GetExport().GetTargetStorage(), uno::UNO_QUERY_THROW );
4951 :
4952 0 : xPictureStorage.set( xStorage->openStorageElement( "Pictures" , ::embed::ElementModes::READWRITE ), uno::UNO_QUERY_THROW );
4953 :
4954 0 : sal_Int32 nIndex = 0;
4955 0 : do
4956 : {
4957 0 : sPictureName = "TablePreview";
4958 0 : sPictureName += OUString::number( ++nIndex );
4959 0 : sPictureName += ".svm";
4960 : }
4961 0 : while( xPictureStorage->hasByName( sPictureName ) );
4962 :
4963 0 : xPictureStream.set( xPictureStorage->openStreamElement( sPictureName, ::embed::ElementModes::READWRITE ), uno::UNO_QUERY_THROW );
4964 : }
4965 :
4966 0 : uno::Reference< graphic::XGraphicProvider > xProvider( graphic::GraphicProvider::create(xContext) );
4967 0 : uno::Sequence< beans::PropertyValue > aArgs( 2 );
4968 0 : aArgs[ 0 ].Name = "MimeType";
4969 0 : aArgs[ 0 ].Value <<= OUString( "image/x-vclgraphic" );
4970 0 : aArgs[ 1 ].Name = "OutputStream";
4971 0 : aArgs[ 1 ].Value <<= xPictureStream->getOutputStream();
4972 0 : xProvider->storeGraphic( xGraphic, aArgs );
4973 :
4974 0 : if( xPictureStorage.is() )
4975 : {
4976 0 : uno::Reference< embed::XTransactedObject > xTrans( xPictureStorage, uno::UNO_QUERY );
4977 0 : if( xTrans.is() )
4978 0 : xTrans->commit();
4979 : }
4980 :
4981 0 : if( !bExportEmbedded )
4982 : {
4983 0 : OUString sURL( "Pictures/" );
4984 0 : sURL += sPictureName;
4985 0 : mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, sURL );
4986 0 : mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
4987 0 : mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
4988 0 : mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
4989 : }
4990 :
4991 0 : SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_DRAW, XML_IMAGE, false, true );
4992 :
4993 0 : if( bExportEmbedded )
4994 : {
4995 0 : uno::Reference< io::XSeekableInputStream > xSeekable( xPictureStream, uno::UNO_QUERY_THROW );
4996 0 : xSeekable->seek(0);
4997 :
4998 0 : XMLBase64Export aBase64Exp( GetExport() );
4999 0 : aBase64Exp.exportOfficeBinaryDataElement( uno::Reference < io::XInputStream >( xPictureStream, uno::UNO_QUERY_THROW ) );
5000 0 : }
5001 : }
5002 0 : catch( uno::Exception& )
5003 : {
5004 : OSL_FAIL("xmloff::XMLShapeExport::ImpExportTableShape(), exception caught!");
5005 0 : }
5006 : }
5007 :
5008 0 : ImpExportEvents( xShape );
5009 0 : ImpExportGluePoints( xShape );
5010 0 : ImpExportDescription( xShape ); // #i68101#
5011 : }
5012 0 : catch( uno::Exception& )
5013 : {
5014 : OSL_FAIL( "xmloff::XMLShapeExport::ImpExportTableShape(), exception caught!" );
5015 0 : }
5016 0 : }
5017 :
5018 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|