LCOV - code coverage report
Current view: top level - xmloff/source/draw - shapeexport.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1360 2461 55.3 %
Date: 2015-06-13 12:38:46 Functions: 50 60 83.3 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.11