Bump for 4.0-11
[LibreOffice.git] / xmloff / source / draw / shapeexport.cxx
blobc7d812b3f8ae1cb26716997d75ef62eff5b87934
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <memory>
23 #include <xmloff/unointerfacetouniqueidentifiermapper.hxx>
24 #include <com/sun/star/presentation/ClickAction.hpp>
25 #include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
26 #include <com/sun/star/container/XChild.hpp>
27 #include <com/sun/star/text/XText.hpp>
28 #include <com/sun/star/chart/XChartDocument.hpp>
29 #include <com/sun/star/drawing/XControlShape.hpp>
30 #include <com/sun/star/style/XStyle.hpp>
31 #include <com/sun/star/drawing/XGluePointsSupplier.hpp>
32 #include <com/sun/star/container/XIdentifierAccess.hpp>
33 #include <com/sun/star/drawing/GluePoint2.hpp>
34 #include <com/sun/star/drawing/Alignment.hpp>
35 #include <com/sun/star/drawing/EscapeDirection.hpp>
36 #include <com/sun/star/table/XColumnRowRange.hpp>
37 #include <xmloff/xmluconv.hxx>
38 #include "PropertySetMerger.hxx"
40 #include <xmloff/shapeexport.hxx>
41 #include "sdpropls.hxx"
42 #include "sdxmlexp_impl.hxx"
43 #include <xmloff/families.hxx>
44 #include <tools/debug.hxx>
45 #include <xmloff/contextid.hxx>
46 #include <xmloff/xmltoken.hxx>
47 #include <sot/clsids.hxx>
48 #include <tools/globname.hxx>
49 #include <com/sun/star/beans/XPropertyState.hpp>
51 #include <comphelper/processfactory.hxx>
52 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
53 #include <com/sun/star/drawing/XCustomShapeEngine.hpp>
55 #include "xmloff/xmlnmspe.hxx"
57 using namespace ::com::sun::star;
58 using namespace ::xmloff::token;
60 //////////////////////////////////////////////////////////////////////////////
62 XMLShapeExport::XMLShapeExport(SvXMLExport& rExp,
63 SvXMLExportPropertyMapper *pExtMapper )
64 : mrExport( rExp ),
65 mnNextUniqueShapeId(1),
66 maShapesInfos(),
67 maCurrentShapesIter(maShapesInfos.end()),
68 mbExportLayer( sal_False ),
69 // #88546# init to sal_False
70 mbHandleProgressBar( sal_False ),
71 msZIndex( "ZOrder" ),
72 msPrintable( "Printable" ),
73 msVisible( "Visible" ),
74 msEmptyPres( "IsEmptyPresentationObject" ),
75 msModel( "Model" ),
76 msStartShape( "StartShape" ),
77 msEndShape( "EndShape" ),
78 msOnClick( "OnClick" ),
79 msEventType( "EventType" ),
80 msPresentation( "Presentation" ),
81 msMacroName( "MacroName" ),
82 msScript( "Script" ),
83 msLibrary( "Library" ),
84 msClickAction( "ClickAction" ),
85 msBookmark( "Bookmark" ),
86 msEffect( "Effect" ),
87 msPlayFull( "PlayFull" ),
88 msVerb( "Verb" ),
89 msSoundURL( "SoundURL" ),
90 msSpeed( "Speed" ),
91 msStarBasic( "StarBasic" )
93 // construct PropertyHandlerFactory
94 mxSdPropHdlFactory = new XMLSdPropHdlFactory( mrExport.GetModel(), rExp );
95 // construct PropertySetMapper
96 mxPropertySetMapper = CreateShapePropMapper( mrExport );
97 if( pExtMapper )
99 UniReference < SvXMLExportPropertyMapper > xExtMapper( pExtMapper );
100 mxPropertySetMapper->ChainExportMapper( xExtMapper );
104 // chain text attributes
105 xPropertySetMapper->ChainExportMapper(XMLTextParagraphExport::CreateParaExtPropMapper(rExp));
108 mrExport.GetAutoStylePool()->AddFamily(
109 XML_STYLE_FAMILY_SD_GRAPHICS_ID,
110 OUString(XML_STYLE_FAMILY_SD_GRAPHICS_NAME),
111 GetPropertySetMapper(),
112 OUString(XML_STYLE_FAMILY_SD_GRAPHICS_PREFIX));
113 mrExport.GetAutoStylePool()->AddFamily(
114 XML_STYLE_FAMILY_SD_PRESENTATION_ID,
115 OUString(XML_STYLE_FAMILY_SD_PRESENTATION_NAME),
116 GetPropertySetMapper(),
117 OUString(XML_STYLE_FAMILY_SD_PRESENTATION_PREFIX));
119 maCurrentInfo = maShapeInfos.end();
121 // create table export helper and let him add his families in time
122 GetShapeTableExport();
125 ///////////////////////////////////////////////////////////////////////
127 XMLShapeExport::~XMLShapeExport()
131 ///////////////////////////////////////////////////////////////////////
133 // sj: replacing CustomShapes with standard objects that are also supported in OpenOffice.org format
134 uno::Reference< drawing::XShape > XMLShapeExport::checkForCustomShapeReplacement( const uno::Reference< drawing::XShape >& xShape )
136 uno::Reference< drawing::XShape > xCustomShapeReplacement;
138 if( ( GetExport().getExportFlags() & EXPORT_OASIS ) == 0 )
140 OUString aType( xShape->getShapeType() );
141 if( aType.equalsAscii( "com.sun.star.drawing.CustomShape" ) )
143 uno::Reference< beans::XPropertySet > xSet( xShape, uno::UNO_QUERY );
144 if( xSet.is() )
146 OUString aEngine;
147 xSet->getPropertyValue( OUString( "CustomShapeEngine" ) ) >>= aEngine;
148 if ( aEngine.isEmpty() )
150 aEngine = "com.sun.star.drawing.EnhancedCustomShapeEngine";
152 uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
154 if ( !aEngine.isEmpty() && xFactory.is() )
156 uno::Sequence< uno::Any > aArgument( 1 );
157 uno::Sequence< beans::PropertyValue > aPropValues( 2 );
158 aPropValues[ 0 ].Name = rtl::OUString( "CustomShape" );
159 aPropValues[ 0 ].Value <<= xShape;
160 sal_Bool bForceGroupWithText = sal_True;
161 aPropValues[ 1 ].Name = rtl::OUString( "ForceGroupWithText" );
162 aPropValues[ 1 ].Value <<= bForceGroupWithText;
163 aArgument[ 0 ] <<= aPropValues;
164 uno::Reference< uno::XInterface > xInterface( xFactory->createInstanceWithArguments( aEngine, aArgument ) );
165 if ( xInterface.is() )
167 uno::Reference< drawing::XCustomShapeEngine > xCustomShapeEngine(
168 uno::Reference< drawing::XCustomShapeEngine >( xInterface, uno::UNO_QUERY ) );
169 if ( xCustomShapeEngine.is() )
170 xCustomShapeReplacement = xCustomShapeEngine->render();
176 return xCustomShapeReplacement;
179 // This method collects all automatic styles for the given XShape
180 void XMLShapeExport::collectShapeAutoStyles(const uno::Reference< drawing::XShape >& xShape )
182 if( maCurrentShapesIter == maShapesInfos.end() )
184 OSL_FAIL( "XMLShapeExport::collectShapeAutoStyles(): no call to seekShapes()!" );
185 return;
187 sal_Int32 nZIndex = 0;
188 uno::Reference< beans::XPropertySet > xSet( xShape, uno::UNO_QUERY );
189 if( xSet.is() )
190 xSet->getPropertyValue(msZIndex) >>= nZIndex;
192 ImplXMLShapeExportInfoVector& aShapeInfoVector = (*maCurrentShapesIter).second;
194 if( (sal_Int32)aShapeInfoVector.size() <= nZIndex )
196 OSL_FAIL( "XMLShapeExport::collectShapeAutoStyles(): no shape info allocated for a given shape" );
197 return;
200 ImplXMLShapeExportInfo& aShapeInfo = aShapeInfoVector[nZIndex];
202 uno::Reference< drawing::XShape > xCustomShapeReplacement = checkForCustomShapeReplacement( xShape );
203 if ( xCustomShapeReplacement.is() )
204 aShapeInfo.xCustomShapeReplacement = xCustomShapeReplacement;
206 // -----------------------------
207 // first compute the shapes type
208 // -----------------------------
209 ImpCalcShapeType(xShape, aShapeInfo.meShapeType);
211 // #i118485# enabled XmlShapeTypeDrawChartShape and XmlShapeTypeDrawOLE2Shape
212 // to have text
213 const bool bObjSupportsText =
214 aShapeInfo.meShapeType != XmlShapeTypePresChartShape &&
215 aShapeInfo.meShapeType != XmlShapeTypePresOLE2Shape &&
216 aShapeInfo.meShapeType != XmlShapeTypeDrawSheetShape &&
217 aShapeInfo.meShapeType != XmlShapeTypePresSheetShape &&
218 aShapeInfo.meShapeType != XmlShapeTypeDraw3DSceneObject &&
219 aShapeInfo.meShapeType != XmlShapeTypeDraw3DCubeObject &&
220 aShapeInfo.meShapeType != XmlShapeTypeDraw3DSphereObject &&
221 aShapeInfo.meShapeType != XmlShapeTypeDraw3DLatheObject &&
222 aShapeInfo.meShapeType != XmlShapeTypeDraw3DExtrudeObject &&
223 aShapeInfo.meShapeType != XmlShapeTypeDrawPageShape &&
224 aShapeInfo.meShapeType != XmlShapeTypePresPageShape &&
225 aShapeInfo.meShapeType != XmlShapeTypeDrawGroupShape;
227 const bool bObjSupportsStyle =
228 aShapeInfo.meShapeType != XmlShapeTypeDrawGroupShape;
230 sal_Bool bIsEmptyPresObj = sal_False;
232 uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
233 if ( aShapeInfo.xCustomShapeReplacement.is() )
234 xPropSet.clear();
236 // ----------------
237 // prep text styles
238 // ----------------
239 if( xPropSet.is() && bObjSupportsText )
241 uno::Reference< text::XText > xText(xShape, uno::UNO_QUERY);
242 if(xText.is() && !xText->getString().isEmpty())
244 uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
246 if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(msEmptyPres) )
248 uno::Any aAny = xPropSet->getPropertyValue(msEmptyPres);
249 aAny >>= bIsEmptyPresObj;
252 if(!bIsEmptyPresObj)
254 GetExport().GetTextParagraphExport()->collectTextAutoStyles( xText );
259 // ------------------------------
260 // compute the shape parent style
261 // ------------------------------
262 if( xPropSet.is() )
264 uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( xPropSet->getPropertySetInfo() );
266 OUString aParentName;
267 uno::Reference< style::XStyle > xStyle;
269 if( bObjSupportsStyle )
271 if( xPropertySetInfo.is() && xPropertySetInfo->hasPropertyByName( OUString("Style")) )
272 xPropSet->getPropertyValue(OUString("Style")) >>= xStyle;
274 if(xStyle.is())
276 // get family ID
277 uno::Reference< beans::XPropertySet > xStylePropSet(xStyle, uno::UNO_QUERY);
278 DBG_ASSERT( xStylePropSet.is(), "style without a XPropertySet?" );
281 if(xStylePropSet.is())
283 OUString aFamilyName;
284 xStylePropSet->getPropertyValue(OUString("Family")) >>= aFamilyName;
285 if( !aFamilyName.isEmpty() && aFamilyName != "graphics" )
286 aShapeInfo.mnFamily = XML_STYLE_FAMILY_SD_PRESENTATION_ID;
289 catch(const beans::UnknownPropertyException&)
291 // Ignored.
292 DBG_ASSERT(false,
293 "XMLShapeExport::collectShapeAutoStyles: style has no 'Family' property");
296 // get parent-style name
297 if(XML_STYLE_FAMILY_SD_PRESENTATION_ID == aShapeInfo.mnFamily)
299 aParentName = msPresentationStylePrefix;
302 aParentName += xStyle->getName();
306 // filter propset
307 std::vector< XMLPropertyState > xPropStates;
309 sal_Int32 nCount = 0;
310 if( (!bIsEmptyPresObj || (aShapeInfo.meShapeType != XmlShapeTypePresPageShape)) )
312 xPropStates = GetPropertySetMapper()->Filter( xPropSet );
314 if (XmlShapeTypeDrawControlShape == aShapeInfo.meShapeType)
316 // for control shapes, we additionally need the number format style (if any)
317 uno::Reference< drawing::XControlShape > xControl(xShape, uno::UNO_QUERY);
318 DBG_ASSERT(xControl.is(), "XMLShapeExport::collectShapeAutoStyles: ShapeType control, but no XControlShape!");
319 if (xControl.is())
321 uno::Reference< beans::XPropertySet > xControlModel(xControl->getControl(), uno::UNO_QUERY);
322 DBG_ASSERT(xControlModel.is(), "XMLShapeExport::collectShapeAutoStyles: no control model on the control shape!");
324 ::rtl::OUString sNumberStyle = mrExport.GetFormExport()->getControlNumberStyle(xControlModel);
325 if (!sNumberStyle.isEmpty())
327 sal_Int32 nIndex = GetPropertySetMapper()->getPropertySetMapper()->FindEntryIndex(CTF_SD_CONTROL_SHAPE_DATA_STYLE);
328 // TODO : this retrieval of the index could be moved into the ctor, holding the index
329 // as member, thus saving time.
330 DBG_ASSERT(-1 != nIndex, "XMLShapeExport::collectShapeAutoStyles: could not obtain the index for our context id!");
332 XMLPropertyState aNewState(nIndex, uno::makeAny(sNumberStyle));
333 xPropStates.push_back(aNewState);
338 std::vector< XMLPropertyState >::iterator aIter = xPropStates.begin();
339 std::vector< XMLPropertyState >::iterator aEnd = xPropStates.end();
340 while( aIter != aEnd )
342 if( aIter->mnIndex != -1 )
343 nCount++;
344 ++aIter;
348 if(nCount == 0)
350 // no hard attributes, use parent style name for export
351 aShapeInfo.msStyleName = aParentName;
353 else
355 // there are filtered properties -> hard attributes
356 // try to find this style in AutoStylePool
357 aShapeInfo.msStyleName = mrExport.GetAutoStylePool()->Find(aShapeInfo.mnFamily, aParentName, xPropStates);
359 if(aShapeInfo.msStyleName.isEmpty())
361 // Style did not exist, add it to AutoStalePool
362 aShapeInfo.msStyleName = mrExport.GetAutoStylePool()->Add(aShapeInfo.mnFamily, aParentName, xPropStates);
366 // optionaly generate auto style for text attributes
367 if( (!bIsEmptyPresObj || (aShapeInfo.meShapeType != XmlShapeTypePresPageShape)) && bObjSupportsText )
369 xPropStates = GetExport().GetTextParagraphExport()->GetParagraphPropertyMapper()->Filter( xPropSet );
371 // ----------------------------------------------------------------------
372 // yet more additionally, we need to care for the ParaAdjust property
373 if ( XmlShapeTypeDrawControlShape == aShapeInfo.meShapeType )
375 uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
376 uno::Reference< beans::XPropertyState > xPropState( xPropSet, uno::UNO_QUERY );
377 if ( xPropSetInfo.is() && xPropState.is() )
379 // this is because:
380 // * if controls shapes have a ParaAdjust property, then this is the Align property of the control model
381 // * control models are allowed to have an Align of "void"
382 // * the Default for control model's Align is TextAlign_LEFT
383 // * defaults for style properties are not written, but we need to write the "left",
384 // because we need to distiguish this "left" from the case where not align attribute
385 // is present which means "void"
386 static const ::rtl::OUString s_sParaAdjustPropertyName( "ParaAdjust" );
387 if ( xPropSetInfo->hasPropertyByName( s_sParaAdjustPropertyName )
388 && ( beans::PropertyState_DEFAULT_VALUE == xPropState->getPropertyState( s_sParaAdjustPropertyName ) )
391 sal_Int32 nIndex = GetExport().GetTextParagraphExport()->GetParagraphPropertyMapper()->getPropertySetMapper()->FindEntryIndex( CTF_SD_SHAPE_PARA_ADJUST );
392 // TODO : this retrieval of the index should 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 the ParaAdjust context id!");
396 uno::Any aParaAdjustValue = xPropSet->getPropertyValue( s_sParaAdjustPropertyName );
397 XMLPropertyState aAlignDefaultState( nIndex, aParaAdjustValue );
399 xPropStates.push_back( aAlignDefaultState );
403 // ----------------------------------------------------------------------
405 nCount = 0;
406 std::vector< XMLPropertyState >::iterator aIter = xPropStates.begin();
407 std::vector< XMLPropertyState >::iterator aEnd = xPropStates.end();
408 while( aIter != aEnd )
410 if( aIter->mnIndex != -1 )
411 nCount++;
412 ++aIter;
415 if( nCount )
417 const OUString aEmpty;
418 aShapeInfo.msTextStyleName = mrExport.GetAutoStylePool()->Find( XML_STYLE_FAMILY_TEXT_PARAGRAPH, aEmpty, xPropStates );
419 if(aShapeInfo.msTextStyleName.isEmpty())
421 // Style did not exist, add it to AutoStalePool
422 aShapeInfo.msTextStyleName = mrExport.GetAutoStylePool()->Add(XML_STYLE_FAMILY_TEXT_PARAGRAPH, aEmpty, xPropStates);
428 // ----------------------------------------
429 // prepare animation informations if needed
430 // ----------------------------------------
431 if( mxAnimationsExporter.is() )
432 mxAnimationsExporter->prepare( xShape, mrExport );
434 // check for special shapes
436 switch( aShapeInfo.meShapeType )
438 case XmlShapeTypeDrawConnectorShape:
440 uno::Reference< uno::XInterface > xConnection;
442 // create shape ids for export later
443 xPropSet->getPropertyValue( msStartShape ) >>= xConnection;
444 if( xConnection.is() )
445 mrExport.getInterfaceToIdentifierMapper().registerReference( xConnection );
447 xPropSet->getPropertyValue( msEndShape ) >>= xConnection;
448 if( xConnection.is() )
449 mrExport.getInterfaceToIdentifierMapper().registerReference( xConnection );
450 break;
452 case XmlShapeTypePresTableShape:
453 case XmlShapeTypeDrawTableShape:
457 uno::Reference< table::XColumnRowRange > xRange( xSet->getPropertyValue( msModel ), uno::UNO_QUERY_THROW );
458 GetShapeTableExport()->collectTableAutoStyles( xRange );
460 catch(const uno::Exception&)
462 OSL_FAIL( "XMLShapeExport::collectShapeAutoStyles(): exception caught while collection auto styles for a table!" );
464 break;
466 default:
467 break;
470 maShapeInfos.push_back( aShapeInfo );
471 maCurrentInfo = maShapeInfos.begin();
473 // -----------------------------------------------------
474 // check for shape collections (group shape or 3d scene)
475 // and collect contained shapes style infos
476 // -----------------------------------------------------
477 const uno::Reference< drawing::XShape >& xCollection = aShapeInfo.xCustomShapeReplacement.is()
478 ? aShapeInfo.xCustomShapeReplacement : xShape;
480 uno::Reference< drawing::XShapes > xShapes( xCollection, uno::UNO_QUERY );
481 if( xShapes.is() )
483 collectShapesAutoStyles( xShapes );
488 ///////////////////////////////////////////////////////////////////////
490 namespace
492 class NewTextListsHelper
494 public:
495 NewTextListsHelper( SvXMLExport& rExp )
496 : mrExport( rExp )
498 mrExport.GetTextParagraphExport()->PushNewTextListsHelper();
501 ~NewTextListsHelper()
503 mrExport.GetTextParagraphExport()->PopTextListsHelper();
506 private:
507 SvXMLExport& mrExport;
510 // This method exports the given XShape
511 void XMLShapeExport::exportShape(const uno::Reference< drawing::XShape >& xShape,
512 sal_Int32 nFeatures /* = SEF_DEFAULT */,
513 com::sun::star::awt::Point* pRefPoint /* = NULL */,
514 SvXMLAttributeList* pAttrList /* = NULL */ )
516 if( maCurrentShapesIter == maShapesInfos.end() )
518 OSL_FAIL( "XMLShapeExport::exportShape(): no auto styles where collected before export" );
519 return;
521 sal_Int32 nZIndex = 0;
522 uno::Reference< beans::XPropertySet > xSet( xShape, uno::UNO_QUERY );
525 ::std::auto_ptr< SvXMLElementExport > mpHyperlinkElement;
527 // export hyperlinks with <a><shape/></a>. Currently only in draw since draw
528 // does not support document events
529 if( xSet.is() && (GetExport().GetModelType() == SvtModuleOptions::E_DRAW) ) try
531 presentation::ClickAction eAction = presentation::ClickAction_NONE;
532 xSet->getPropertyValue(OUString("OnClick")) >>= eAction;
534 if( (eAction == presentation::ClickAction_DOCUMENT) ||
535 (eAction == presentation::ClickAction_BOOKMARK) )
537 OUString sURL;
538 xSet->getPropertyValue(msBookmark) >>= sURL;
540 if( !sURL.isEmpty() )
542 mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, sURL );
543 mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
544 mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
545 mpHyperlinkElement.reset( new SvXMLElementExport(mrExport, XML_NAMESPACE_DRAW, XML_A, sal_True, sal_True) );
549 catch(const uno::Exception&)
551 OSL_FAIL("XMLShapeExport::exportShape(): exception during hyperlink export");
555 if( xSet.is() )
556 xSet->getPropertyValue(msZIndex) >>= nZIndex;
558 ImplXMLShapeExportInfoVector& aShapeInfoVector = (*maCurrentShapesIter).second;
560 if( (sal_Int32)aShapeInfoVector.size() <= nZIndex )
562 OSL_FAIL( "XMLShapeExport::exportShape(): no shape info collected for a given shape" );
563 return;
566 NewTextListsHelper aNewTextListsHelper( mrExport );
568 const ImplXMLShapeExportInfo& aShapeInfo = aShapeInfoVector[nZIndex];
571 #ifdef DBG_UTIL
572 // ---------------------------------------
573 // check if this is the correct ShapesInfo
574 // ---------------------------------------
575 uno::Reference< container::XChild > xChild( xShape, uno::UNO_QUERY );
576 if( xChild.is() )
578 uno::Reference< drawing::XShapes > xParent( xChild->getParent(), uno::UNO_QUERY );
579 DBG_ASSERT( xParent.is() && xParent.get() == (*maCurrentShapesIter).first.get(), "XMLShapeExport::exportShape(): Wrong call to XMLShapeExport::seekShapes()" );
582 // -----------------------------
583 // first compute the shapes type
584 // -----------------------------
586 XmlShapeType eShapeType(XmlShapeTypeNotYetSet);
587 ImpCalcShapeType(xShape, eShapeType);
589 DBG_ASSERT( eShapeType == aShapeInfo.meShapeType, "exportShape callings do not correspond to collectShapeAutoStyles calls!" );
591 #endif
593 // ----------------------------------------
594 // collect animation informations if needed
595 // ----------------------------------------
596 if( mxAnimationsExporter.is() )
597 mxAnimationsExporter->collect( xShape, mrExport );
599 /* Export shapes name if he has one (#i51726#)
600 Export of the shape name for text documents only if the OpenDocument
601 file format is written - exceptions are group shapes.
602 Note: Writer documents in OpenOffice.org file format doesn't contain
603 any names for shapes, except for group shapes.
606 if ( ( GetExport().GetModelType() != SvtModuleOptions::E_WRITER &&
607 GetExport().GetModelType() != SvtModuleOptions::E_WRITERWEB &&
608 GetExport().GetModelType() != SvtModuleOptions::E_WRITERGLOBAL ) ||
609 ( GetExport().getExportFlags() & EXPORT_OASIS ) != 0 ||
610 aShapeInfo.meShapeType == XmlShapeTypeDrawGroupShape ||
611 ( aShapeInfo.meShapeType == XmlShapeTypeDrawCustomShape &&
612 aShapeInfo.xCustomShapeReplacement.is() ) )
614 uno::Reference< container::XNamed > xNamed( xShape, uno::UNO_QUERY );
615 if( xNamed.is() )
617 const OUString aName( xNamed->getName() );
618 if( !aName.isEmpty() )
619 mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_NAME, aName );
624 // ------------------
625 // export style name
626 // ------------------
627 if( !aShapeInfo.msStyleName.isEmpty() )
629 if(XML_STYLE_FAMILY_SD_GRAPHICS_ID == aShapeInfo.mnFamily)
630 mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_STYLE_NAME, mrExport.EncodeStyleName( aShapeInfo.msStyleName) );
631 else
632 mrExport.AddAttribute(XML_NAMESPACE_PRESENTATION, XML_STYLE_NAME, mrExport.EncodeStyleName( aShapeInfo.msStyleName) );
635 // ------------------
636 // export text style name
637 // ------------------
638 if( !aShapeInfo.msTextStyleName.isEmpty() )
640 mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_TEXT_STYLE_NAME, aShapeInfo.msTextStyleName );
643 // --------------------------
644 // export shapes id if needed
645 // --------------------------
647 uno::Reference< uno::XInterface > xRef( xShape, uno::UNO_QUERY );
648 const OUString& rShapeId = mrExport.getInterfaceToIdentifierMapper().getIdentifier( xRef );
649 if( !rShapeId.isEmpty() )
651 mrExport.AddAttributeIdLegacy(XML_NAMESPACE_DRAW, rShapeId);
655 // --------------------------
656 // export layer information
657 // --------------------------
658 if( IsLayerExportEnabled() )
660 // check for group or scene shape and not export layer if this is one
661 uno::Reference< drawing::XShapes > xShapes( xShape, uno::UNO_QUERY );
662 if( !xShapes.is() )
666 uno::Reference< beans::XPropertySet > xProps( xShape, uno::UNO_QUERY );
667 OUString aLayerName;
668 xProps->getPropertyValue( OUString( "LayerName" ) ) >>= aLayerName;
669 mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_LAYER, aLayerName );
672 catch(const uno::Exception&)
674 OSL_FAIL( "could not export layer name for shape!" );
679 // export draw:display (do not export in ODF 1.2 or older)
680 if( xSet.is() && ( mrExport.getDefaultVersion() > SvtSaveOptions::ODFVER_012 ) )
682 if( aShapeInfo.meShapeType != XmlShapeTypeDrawPageShape && aShapeInfo.meShapeType != XmlShapeTypePresPageShape &&
683 aShapeInfo.meShapeType != XmlShapeTypeHandoutShape && aShapeInfo.meShapeType != XmlShapeTypeDrawChartShape )
687 sal_Bool bVisible = sal_True;
688 sal_Bool bPrintable = sal_True;
690 xSet->getPropertyValue(msVisible) >>= bVisible;
691 xSet->getPropertyValue(msPrintable) >>= bPrintable;
693 XMLTokenEnum eDisplayToken = XML_TOKEN_INVALID;
694 const unsigned short nDisplay = (bVisible ? 2 : 0) | (bPrintable ? 1 : 0);
695 switch( nDisplay )
697 case 0: eDisplayToken = XML_NONE; break;
698 case 1: eDisplayToken = XML_PRINTER; break;
699 case 2: eDisplayToken = XML_SCREEN; break;
700 // case 3: eDisplayToken = XML_ALWAYS break; this is the default
703 if( eDisplayToken != XML_TOKEN_INVALID )
704 mrExport.AddAttribute(XML_NAMESPACE_DRAW_EXT, XML_DISPLAY, eDisplayToken );
706 catch(const uno::Exception&)
708 OSL_FAIL( "XMLShapeExport::exportShape(), exception caught!" );
712 // #82003# test export count
713 // #91587# ALWAYS increment since now ALL to be exported shapes are counted.
714 if(mrExport.GetShapeExport()->IsHandleProgressBarEnabled())
716 mrExport.GetProgressBarHelper()->Increment();
719 onExport( xShape );
721 // --------------------
722 // export shape element
723 // --------------------
724 switch(aShapeInfo.meShapeType)
726 case XmlShapeTypeDrawRectangleShape:
728 ImpExportRectangleShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
729 break;
731 case XmlShapeTypeDrawEllipseShape:
733 ImpExportEllipseShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
734 break;
736 case XmlShapeTypeDrawLineShape:
738 ImpExportLineShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
739 break;
741 case XmlShapeTypeDrawPolyPolygonShape: // closed PolyPolygon
742 case XmlShapeTypeDrawPolyLineShape: // open PolyPolygon
743 case XmlShapeTypeDrawClosedBezierShape: // closed PolyPolygon containing curves
744 case XmlShapeTypeDrawOpenBezierShape: // open PolyPolygon containing curves
746 ImpExportPolygonShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
747 break;
750 case XmlShapeTypeDrawTextShape:
751 case XmlShapeTypePresTitleTextShape:
752 case XmlShapeTypePresOutlinerShape:
753 case XmlShapeTypePresSubtitleShape:
754 case XmlShapeTypePresNotesShape:
755 case XmlShapeTypePresHeaderShape:
756 case XmlShapeTypePresFooterShape:
757 case XmlShapeTypePresSlideNumberShape:
758 case XmlShapeTypePresDateTimeShape:
760 ImpExportTextBoxShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
761 break;
764 case XmlShapeTypeDrawGraphicObjectShape:
765 case XmlShapeTypePresGraphicObjectShape:
767 ImpExportGraphicObjectShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
768 break;
771 case XmlShapeTypeDrawChartShape:
772 case XmlShapeTypePresChartShape:
774 ImpExportChartShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint, pAttrList );
775 break;
778 case XmlShapeTypeDrawControlShape:
780 ImpExportControlShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
781 break;
784 case XmlShapeTypeDrawConnectorShape:
786 ImpExportConnectorShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
787 break;
790 case XmlShapeTypeDrawMeasureShape:
792 ImpExportMeasureShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
793 break;
796 case XmlShapeTypeDrawOLE2Shape:
797 case XmlShapeTypePresOLE2Shape:
798 case XmlShapeTypeDrawSheetShape:
799 case XmlShapeTypePresSheetShape:
801 ImpExportOLE2Shape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
802 break;
805 case XmlShapeTypePresTableShape:
806 case XmlShapeTypeDrawTableShape:
808 ImpExportTableShape( xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
809 break;
812 case XmlShapeTypeDrawPageShape:
813 case XmlShapeTypePresPageShape:
814 case XmlShapeTypeHandoutShape:
816 ImpExportPageShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
817 break;
820 case XmlShapeTypeDrawCaptionShape:
822 ImpExportCaptionShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
823 break;
826 case XmlShapeTypeDraw3DCubeObject:
827 case XmlShapeTypeDraw3DSphereObject:
828 case XmlShapeTypeDraw3DLatheObject:
829 case XmlShapeTypeDraw3DExtrudeObject:
831 ImpExport3DShape(xShape, aShapeInfo.meShapeType);
832 break;
835 case XmlShapeTypeDraw3DSceneObject:
837 ImpExport3DSceneShape( xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
838 break;
841 case XmlShapeTypeDrawGroupShape:
843 // empty group
844 ImpExportGroupShape( xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
845 break;
848 case XmlShapeTypeDrawFrameShape:
850 ImpExportFrameShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
851 break;
854 case XmlShapeTypeDrawAppletShape:
856 ImpExportAppletShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
857 break;
860 case XmlShapeTypeDrawPluginShape:
862 ImpExportPluginShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
863 break;
866 case XmlShapeTypeDrawCustomShape:
868 if ( aShapeInfo.xCustomShapeReplacement.is() )
869 ImpExportGroupShape( aShapeInfo.xCustomShapeReplacement, XmlShapeTypeDrawGroupShape, nFeatures, pRefPoint );
870 else
871 ImpExportCustomShape( xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
872 break;
875 case XmlShapeTypePresMediaShape:
876 case XmlShapeTypeDrawMediaShape:
878 ImpExportMediaShape( xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
879 break;
882 case XmlShapeTypePresOrgChartShape:
883 case XmlShapeTypeUnknown:
884 case XmlShapeTypeNotYetSet:
885 default:
887 // this should never happen and is an error
888 OSL_FAIL("XMLEXP: WriteShape: unknown or unexpected type of shape in export!");
889 break;
893 mpHyperlinkElement.reset();
895 // #97489# #97111#
896 // if there was an error and no element for the shape was exported
897 // we need to clear the attribute list or the attributes will be
898 // set on the next exported element, which can result in corrupt
899 // xml files due to duplicate attributes
901 mrExport.CheckAttrList(); // asserts in non pro if we have attributes left
902 mrExport.ClearAttrList(); // clears the attributes
905 ///////////////////////////////////////////////////////////////////////
907 // This method collects all automatic styles for the shapes inside the given XShapes collection
908 void XMLShapeExport::collectShapesAutoStyles( const uno::Reference < drawing::XShapes >& xShapes )
910 ShapesInfos::iterator aOldCurrentShapesIter = maCurrentShapesIter;
911 seekShapes( xShapes );
913 uno::Reference< drawing::XShape > xShape;
914 const sal_Int32 nShapeCount(xShapes->getCount());
915 for(sal_Int32 nShapeId = 0; nShapeId < nShapeCount; nShapeId++)
917 xShapes->getByIndex(nShapeId) >>= xShape;
918 DBG_ASSERT( xShape.is(), "Shape without a XShape?" );
919 if(!xShape.is())
920 continue;
922 collectShapeAutoStyles( xShape );
925 maCurrentShapesIter = aOldCurrentShapesIter;
928 ///////////////////////////////////////////////////////////////////////
930 // This method exports all XShape inside the given XShapes collection
931 void XMLShapeExport::exportShapes( const uno::Reference < drawing::XShapes >& xShapes, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */ )
933 ShapesInfos::iterator aOldCurrentShapesIter = maCurrentShapesIter;
934 seekShapes( xShapes );
936 uno::Reference< drawing::XShape > xShape;
937 const sal_Int32 nShapeCount(xShapes->getCount());
938 for(sal_Int32 nShapeId = 0; nShapeId < nShapeCount; nShapeId++)
940 xShapes->getByIndex(nShapeId) >>= xShape;
941 DBG_ASSERT( xShape.is(), "Shape without a XShape?" );
942 if(!xShape.is())
943 continue;
945 exportShape( xShape, nFeatures, pRefPoint );
948 maCurrentShapesIter = aOldCurrentShapesIter;
951 ///////////////////////////////////////////////////////////////////////
953 void XMLShapeExport::seekShapes( const uno::Reference< drawing::XShapes >& xShapes ) throw()
955 if( xShapes.is() )
957 maCurrentShapesIter = maShapesInfos.find( xShapes );
958 if( maCurrentShapesIter == maShapesInfos.end() )
960 ImplXMLShapeExportInfoVector aNewInfoVector;
961 aNewInfoVector.resize( (ShapesInfos::size_type) xShapes->getCount() );
962 maShapesInfos[ xShapes ] = aNewInfoVector;
964 maCurrentShapesIter = maShapesInfos.find( xShapes );
966 DBG_ASSERT( maCurrentShapesIter != maShapesInfos.end(), "XMLShapeExport::seekShapes(): insert into stl::map failed" );
969 DBG_ASSERT( (*maCurrentShapesIter).second.size() == (ShapesInfos::size_type)xShapes->getCount(), "XMLShapeExport::seekShapes(): XShapes size varied between calls" );
972 else
974 maCurrentShapesIter = maShapesInfos.end();
978 ///////////////////////////////////////////////////////////////////////
980 void XMLShapeExport::exportAutoStyles()
982 // export all autostyle infos
984 // ...for graphic
986 GetExport().GetAutoStylePool()->exportXML(
987 XML_STYLE_FAMILY_SD_GRAPHICS_ID
988 , GetExport().GetDocHandler(),
989 GetExport().GetMM100UnitConverter(),
990 GetExport().GetNamespaceMap()
994 // ...for presentation
996 GetExport().GetAutoStylePool()->exportXML(
997 XML_STYLE_FAMILY_SD_PRESENTATION_ID
998 , GetExport().GetDocHandler(),
999 GetExport().GetMM100UnitConverter(),
1000 GetExport().GetNamespaceMap()
1004 if( mxShapeTableExport.is() )
1005 mxShapeTableExport->exportAutoStyles();
1008 ///////////////////////////////////////////////////////////////////////
1010 /// returns the export property mapper for external chaining
1011 SvXMLExportPropertyMapper* XMLShapeExport::CreateShapePropMapper(
1012 SvXMLExport& rExport )
1014 UniReference< XMLPropertyHandlerFactory > xFactory = new XMLSdPropHdlFactory( rExport.GetModel(), rExport );
1015 UniReference < XMLPropertySetMapper > xMapper = new XMLShapePropertySetMapper( xFactory );
1016 rExport.GetTextParagraphExport(); // get or create text paragraph export
1017 SvXMLExportPropertyMapper* pResult =
1018 new XMLShapeExportPropertyMapper( xMapper, rExport );
1019 // chain text attributes
1020 return pResult;
1023 ///////////////////////////////////////////////////////////////////////
1025 void XMLShapeExport::ImpCalcShapeType(const uno::Reference< drawing::XShape >& xShape,
1026 XmlShapeType& eShapeType)
1028 // set in every case, so init here
1029 eShapeType = XmlShapeTypeUnknown;
1031 uno::Reference< drawing::XShapeDescriptor > xShapeDescriptor(xShape, uno::UNO_QUERY);
1032 if(xShapeDescriptor.is())
1034 OUString aType(xShapeDescriptor->getShapeType());
1036 if(aType.match("com.sun.star."))
1038 if(aType.match("drawing.", 13))
1040 // drawing shapes
1041 if (aType.match("Rectangle", 21)) { eShapeType = XmlShapeTypeDrawRectangleShape; }
1043 // #i72177# Note: Correcting CustomShape, CustomShape->Custom, len from 9 (was wrong anyways) to 6.
1044 // As can be seen at the other compares, the appendix "Shape" is left out of the comparison.
1045 else if(aType.match("Custom", 21)) { eShapeType = XmlShapeTypeDrawCustomShape; }
1047 else if(aType.match("Ellipse", 21)) { eShapeType = XmlShapeTypeDrawEllipseShape; }
1048 else if(aType.match("Control", 21)) { eShapeType = XmlShapeTypeDrawControlShape; }
1049 else if(aType.match("Connector", 21)) { eShapeType = XmlShapeTypeDrawConnectorShape; }
1050 else if(aType.match("Measure", 21)) { eShapeType = XmlShapeTypeDrawMeasureShape; }
1051 else if(aType.match("Line", 21)) { eShapeType = XmlShapeTypeDrawLineShape; }
1053 // #i72177# Note: This covers two types by purpose, PolyPolygonShape and PolyPolygonPathShape
1054 else if(aType.match("PolyPolygon", 21)) { eShapeType = XmlShapeTypeDrawPolyPolygonShape; }
1056 // #i72177# Note: This covers two types by purpose, PolyLineShape and PolyLinePathShape
1057 else if(aType.match("PolyLine", 21)) { eShapeType = XmlShapeTypeDrawPolyLineShape; }
1059 else if(aType.match("OpenBezier", 21)) { eShapeType = XmlShapeTypeDrawOpenBezierShape; }
1060 else if(aType.match("ClosedBezier", 21)) { eShapeType = XmlShapeTypeDrawClosedBezierShape; }
1062 // #i72177# FreeHand (opened and closed) now supports the types OpenFreeHandShape and
1063 // ClosedFreeHandShape respectively. Represent them as bezier shapes
1064 else if(aType.match("OpenFreeHand", 21)) { eShapeType = XmlShapeTypeDrawOpenBezierShape; }
1065 else if(aType.match("ClosedFreeHand", 21)) { eShapeType = XmlShapeTypeDrawClosedBezierShape; }
1067 else if(aType.match("GraphicObject", 21)) { eShapeType = XmlShapeTypeDrawGraphicObjectShape; }
1068 else if(aType.match("Group", 21)) { eShapeType = XmlShapeTypeDrawGroupShape; }
1069 else if(aType.match("Text", 21)) { eShapeType = XmlShapeTypeDrawTextShape; }
1070 else if(aType.match("OLE2", 21))
1072 eShapeType = XmlShapeTypeDrawOLE2Shape;
1074 // get info about presentation shape
1075 uno::Reference <beans::XPropertySet> xPropSet(xShape, uno::UNO_QUERY);
1077 if(xPropSet.is())
1079 rtl::OUString sCLSID;
1080 if(xPropSet->getPropertyValue(OUString("CLSID")) >>= sCLSID)
1082 if (sCLSID.equals(mrExport.GetChartExport()->getChartCLSID()) ||
1083 sCLSID.equals(rtl::OUString( SvGlobalName( SO3_RPTCH_CLASSID ).GetHexName())))
1085 eShapeType = XmlShapeTypeDrawChartShape;
1087 else if (
1088 sCLSID.equals(rtl::OUString( SvGlobalName( SO3_SC_CLASSID ).GetHexName()))
1089 // #110680#
1090 // same reaction for binfilter
1091 || sCLSID.equals(rtl::OUString( SvGlobalName( BF_SO3_SC_CLASSID ).GetHexName()))
1094 eShapeType = XmlShapeTypeDrawSheetShape;
1096 else
1098 // general OLE2 Object
1103 else if(aType.match("Page", 21)) { eShapeType = XmlShapeTypeDrawPageShape; }
1104 else if(aType.match("Frame", 21)) { eShapeType = XmlShapeTypeDrawFrameShape; }
1105 else if(aType.match("Caption", 21)) { eShapeType = XmlShapeTypeDrawCaptionShape; }
1106 else if(aType.match("Plugin", 21)) { eShapeType = XmlShapeTypeDrawPluginShape; }
1107 else if(aType.match("Applet", 21)) { eShapeType = XmlShapeTypeDrawAppletShape; }
1108 else if(aType.match("MediaShape", 21)) { eShapeType = XmlShapeTypeDrawMediaShape; }
1109 else if(aType.match("TableShape", 21)) { eShapeType = XmlShapeTypeDrawTableShape; }
1111 // 3D shapes
1112 else if(aType.match("Scene", 21 + 7)) { eShapeType = XmlShapeTypeDraw3DSceneObject; }
1113 else if(aType.match("Cube", 21 + 7)) { eShapeType = XmlShapeTypeDraw3DCubeObject; }
1114 else if(aType.match("Sphere", 21 + 7)) { eShapeType = XmlShapeTypeDraw3DSphereObject; }
1115 else if(aType.match("Lathe", 21 + 7)) { eShapeType = XmlShapeTypeDraw3DLatheObject; }
1116 else if(aType.match("Extrude", 21 + 7)) { eShapeType = XmlShapeTypeDraw3DExtrudeObject; }
1118 else if(aType.match("presentation.", 13))
1120 // presentation shapes
1121 if (aType.match("TitleText", 26)) { eShapeType = XmlShapeTypePresTitleTextShape; }
1122 else if(aType.match("Outliner", 26)) { eShapeType = XmlShapeTypePresOutlinerShape; }
1123 else if(aType.match("Subtitle", 26)) { eShapeType = XmlShapeTypePresSubtitleShape; }
1124 else if(aType.match("GraphicObject", 26)) { eShapeType = XmlShapeTypePresGraphicObjectShape; }
1125 else if(aType.match("Page", 26)) { eShapeType = XmlShapeTypePresPageShape; }
1126 else if(aType.match("OLE2", 26))
1128 eShapeType = XmlShapeTypePresOLE2Shape;
1130 // get info about presentation shape
1131 uno::Reference <beans::XPropertySet> xPropSet(xShape, uno::UNO_QUERY);
1133 if(xPropSet.is()) try
1135 rtl::OUString sCLSID;
1136 if(xPropSet->getPropertyValue(OUString("CLSID")) >>= sCLSID)
1138 if( sCLSID.equals(OUString( SvGlobalName( SO3_SC_CLASSID ).GetHexName())) ||
1139 sCLSID.equals(OUString( SvGlobalName( BF_SO3_SC_CLASSID ).GetHexName())) )
1141 eShapeType = XmlShapeTypePresSheetShape;
1145 catch(const uno::Exception&)
1147 OSL_FAIL( "XMLShapeExport::ImpCalcShapeType(), expected ole shape to have the CLSID property?" );
1150 else if(aType.match("Chart", 26)) { eShapeType = XmlShapeTypePresChartShape; }
1151 else if(aType.match("OrgChart", 26)) { eShapeType = XmlShapeTypePresOrgChartShape; }
1152 else if(aType.match("CalcShape", 26)) { eShapeType = XmlShapeTypePresSheetShape; }
1153 else if(aType.match("TableShape", 26)) { eShapeType = XmlShapeTypePresTableShape; }
1154 else if(aType.match("Notes", 26)) { eShapeType = XmlShapeTypePresNotesShape; }
1155 else if(aType.match("HandoutShape", 26)) { eShapeType = XmlShapeTypeHandoutShape; }
1156 else if(aType.match("HeaderShape", 26)) { eShapeType = XmlShapeTypePresHeaderShape; }
1157 else if(aType.match("FooterShape", 26)) { eShapeType = XmlShapeTypePresFooterShape; }
1158 else if(aType.match("SlideNumberShape", 26)) { eShapeType = XmlShapeTypePresSlideNumberShape; }
1159 else if(aType.match("DateTimeShape", 26)) { eShapeType = XmlShapeTypePresDateTimeShape; }
1160 else if(aType.match("MediaShape", 26)) { eShapeType = XmlShapeTypePresMediaShape; }
1166 ///////////////////////////////////////////////////////////////////////
1168 extern SvXMLEnumMapEntry aXML_GlueAlignment_EnumMap[];
1169 extern SvXMLEnumMapEntry aXML_GlueEscapeDirection_EnumMap[];
1171 /** exports all user defined glue points */
1172 void XMLShapeExport::ImpExportGluePoints( const uno::Reference< drawing::XShape >& xShape )
1174 uno::Reference< drawing::XGluePointsSupplier > xSupplier( xShape, uno::UNO_QUERY );
1175 if( !xSupplier.is() )
1176 return;
1178 uno::Reference< container::XIdentifierAccess > xGluePoints( xSupplier->getGluePoints(), uno::UNO_QUERY );
1179 if( !xGluePoints.is() )
1180 return;
1182 drawing::GluePoint2 aGluePoint;
1184 uno::Sequence< sal_Int32 > aIdSequence( xGluePoints->getIdentifiers() );
1186 const sal_Int32 nCount = aIdSequence.getLength();
1187 for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
1189 const sal_Int32 nIdentifier = aIdSequence[nIndex];
1190 if( (xGluePoints->getByIdentifier( nIdentifier ) >>= aGluePoint) && aGluePoint.IsUserDefined )
1192 // export only user defined glue points
1194 const OUString sId( OUString::valueOf( nIdentifier ) );
1195 mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_ID, sId );
1197 mrExport.GetMM100UnitConverter().convertMeasureToXML(msBuffer,
1198 aGluePoint.Position.X);
1199 mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_X, msBuffer.makeStringAndClear());
1201 mrExport.GetMM100UnitConverter().convertMeasureToXML(msBuffer,
1202 aGluePoint.Position.Y);
1203 mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_Y, msBuffer.makeStringAndClear());
1205 if( !aGluePoint.IsRelative )
1207 SvXMLUnitConverter::convertEnum( msBuffer, aGluePoint.PositionAlignment, aXML_GlueAlignment_EnumMap );
1208 mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_ALIGN, msBuffer.makeStringAndClear() );
1211 if( aGluePoint.Escape != drawing::EscapeDirection_SMART )
1213 SvXMLUnitConverter::convertEnum( msBuffer, aGluePoint.Escape, aXML_GlueEscapeDirection_EnumMap );
1214 mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_ESCAPE_DIRECTION, msBuffer.makeStringAndClear() );
1217 SvXMLElementExport aEventsElemt(mrExport, XML_NAMESPACE_DRAW, XML_GLUE_POINT, sal_True, sal_True);
1222 void XMLShapeExport::ExportGraphicDefaults()
1224 XMLStyleExport aStEx(mrExport, OUString(), mrExport.GetAutoStylePool().get());
1226 // construct PropertySetMapper
1227 UniReference< SvXMLExportPropertyMapper > xPropertySetMapper( CreateShapePropMapper( mrExport ) );
1228 ((XMLShapeExportPropertyMapper*)xPropertySetMapper.get())->SetAutoStyles( sal_False );
1230 // chain text attributes
1231 xPropertySetMapper->ChainExportMapper(XMLTextParagraphExport::CreateParaExtPropMapper(mrExport));
1233 // chain special Writer/text frame default attributes
1234 xPropertySetMapper->ChainExportMapper(XMLTextParagraphExport::CreateParaDefaultExtPropMapper(mrExport));
1236 // write graphic family default style
1237 uno::Reference< lang::XMultiServiceFactory > xFact( mrExport.GetModel(), uno::UNO_QUERY );
1238 if( xFact.is() )
1242 uno::Reference< beans::XPropertySet > xDefaults( xFact->createInstance( OUString("com.sun.star.drawing.Defaults" ) ), uno::UNO_QUERY );
1243 if( xDefaults.is() )
1245 aStEx.exportDefaultStyle( xDefaults, OUString(XML_STYLE_FAMILY_SD_GRAPHICS_NAME), xPropertySetMapper );
1247 // write graphic family styles
1248 aStEx.exportStyleFamily("graphics", OUString(XML_STYLE_FAMILY_SD_GRAPHICS_NAME), xPropertySetMapper, sal_False, XML_STYLE_FAMILY_SD_GRAPHICS_ID);
1251 catch(const lang::ServiceNotRegisteredException&)
1257 void XMLShapeExport::onExport( const com::sun::star::uno::Reference < com::sun::star::drawing::XShape >& )
1261 const rtl::Reference< XMLTableExport >& XMLShapeExport::GetShapeTableExport()
1263 if( !mxShapeTableExport.is() )
1265 rtl::Reference< XMLPropertyHandlerFactory > xFactory( new XMLSdPropHdlFactory( mrExport.GetModel(), mrExport ) );
1266 UniReference < XMLPropertySetMapper > xMapper( new XMLShapePropertySetMapper( xFactory.get() ) );
1267 mrExport.GetTextParagraphExport(); // get or create text paragraph export
1268 rtl::Reference< SvXMLExportPropertyMapper > xPropertySetMapper( new XMLShapeExportPropertyMapper( xMapper, mrExport ) );
1269 mxShapeTableExport = new XMLTableExport( mrExport, xPropertySetMapper, xFactory );
1272 return mxShapeTableExport;
1275 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */