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

Generated by: LCOV version 1.10