LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/xmloff/source/draw - shapeexport.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 312 514 60.7 %
Date: 2013-07-09 Functions: 18 18 100.0 %
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             : 
      21             : #include <memory>
      22             : 
      23             : #include <xmloff/unointerfacetouniqueidentifiermapper.hxx>
      24             : #include <com/sun/star/presentation/ClickAction.hpp>
      25             : #include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
      26             : #include <com/sun/star/container/XChild.hpp>
      27             : #include <com/sun/star/text/XText.hpp>
      28             : #include <com/sun/star/chart/XChartDocument.hpp>
      29             : #include <com/sun/star/drawing/XControlShape.hpp>
      30             : #include <com/sun/star/style/XStyle.hpp>
      31             : #include <com/sun/star/drawing/XGluePointsSupplier.hpp>
      32             : #include <com/sun/star/container/XIdentifierAccess.hpp>
      33             : #include <com/sun/star/drawing/GluePoint2.hpp>
      34             : #include <com/sun/star/drawing/Alignment.hpp>
      35             : #include <com/sun/star/drawing/EscapeDirection.hpp>
      36             : #include <com/sun/star/table/XColumnRowRange.hpp>
      37             : #include <xmloff/xmluconv.hxx>
      38             : #include "PropertySetMerger.hxx"
      39             : 
      40             : #include <xmloff/shapeexport.hxx>
      41             : #include "sdpropls.hxx"
      42             : #include "sdxmlexp_impl.hxx"
      43             : #include <xmloff/families.hxx>
      44             : #include <tools/debug.hxx>
      45             : #include <xmloff/contextid.hxx>
      46             : #include <xmloff/xmltoken.hxx>
      47             : #include <comphelper/classids.hxx>
      48             : #include <tools/globname.hxx>
      49             : #include <com/sun/star/beans/XPropertyState.hpp>
      50             : 
      51             : #include <comphelper/processfactory.hxx>
      52             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      53             : #include <com/sun/star/drawing/XCustomShapeEngine.hpp>
      54             : 
      55             : #include "xmloff/xmlnmspe.hxx"
      56             : 
      57             : using namespace ::com::sun::star;
      58             : using namespace ::xmloff::token;
      59             : 
      60             : //////////////////////////////////////////////////////////////////////////////
      61             : 
      62          77 : XMLShapeExport::XMLShapeExport(SvXMLExport& rExp,
      63             :                                 SvXMLExportPropertyMapper *pExtMapper )
      64             : :   mrExport( rExp ),
      65             :     mnNextUniqueShapeId(1),
      66             :     maShapesInfos(),
      67          77 :     maCurrentShapesIter(maShapesInfos.end()),
      68             :     mbExportLayer( sal_False ),
      69             :     // #88546# init to sal_False
      70             :     mbHandleProgressBar( sal_False ),
      71             :     msZIndex( "ZOrder" ),
      72             :     msPrintable( "Printable" ),
      73             :     msVisible( "Visible" ),
      74             :     msEmptyPres( "IsEmptyPresentationObject" ),
      75             :     msModel( "Model" ),
      76             :     msStartShape( "StartShape" ),
      77             :     msEndShape( "EndShape" ),
      78             :     msOnClick( "OnClick" ),
      79             :     msEventType( "EventType" ),
      80             :     msPresentation( "Presentation" ),
      81             :     msMacroName( "MacroName" ),
      82             :     msScript( "Script" ),
      83             :     msLibrary( "Library" ),
      84             :     msClickAction( "ClickAction" ),
      85             :     msBookmark( "Bookmark" ),
      86             :     msEffect( "Effect" ),
      87             :     msPlayFull( "PlayFull" ),
      88             :     msVerb( "Verb" ),
      89             :     msSoundURL( "SoundURL" ),
      90             :     msSpeed( "Speed" ),
      91         154 :     msStarBasic( "StarBasic" )
      92             : {
      93             :     // construct PropertyHandlerFactory
      94          77 :     mxSdPropHdlFactory = new XMLSdPropHdlFactory( mrExport.GetModel(), rExp );
      95             :     // construct PropertySetMapper
      96          77 :     mxPropertySetMapper = CreateShapePropMapper( mrExport );
      97          77 :     if( pExtMapper )
      98             :     {
      99          32 :         UniReference < SvXMLExportPropertyMapper > xExtMapper( pExtMapper );
     100          32 :         mxPropertySetMapper->ChainExportMapper( xExtMapper );
     101             :     }
     102             : 
     103             : /*
     104             :     // chain text attributes
     105             :     xPropertySetMapper->ChainExportMapper(XMLTextParagraphExport::CreateParaExtPropMapper(rExp));
     106             : */
     107             : 
     108             :     mrExport.GetAutoStylePool()->AddFamily(
     109             :         XML_STYLE_FAMILY_SD_GRAPHICS_ID,
     110             :         OUString(XML_STYLE_FAMILY_SD_GRAPHICS_NAME),
     111             :         GetPropertySetMapper(),
     112          77 :         OUString(XML_STYLE_FAMILY_SD_GRAPHICS_PREFIX));
     113             :     mrExport.GetAutoStylePool()->AddFamily(
     114             :         XML_STYLE_FAMILY_SD_PRESENTATION_ID,
     115             :         OUString(XML_STYLE_FAMILY_SD_PRESENTATION_NAME),
     116             :         GetPropertySetMapper(),
     117          77 :         OUString(XML_STYLE_FAMILY_SD_PRESENTATION_PREFIX));
     118             : 
     119          77 :     maCurrentInfo = maShapeInfos.end();
     120             : 
     121             :     // create table export helper and let him add his families in time
     122          77 :     GetShapeTableExport();
     123          77 : }
     124             : 
     125             : ///////////////////////////////////////////////////////////////////////
     126             : 
     127         138 : XMLShapeExport::~XMLShapeExport()
     128             : {
     129         138 : }
     130             : 
     131             : ///////////////////////////////////////////////////////////////////////
     132             : 
     133             : // sj: replacing CustomShapes with standard objects that are also supported in OpenOffice.org format
     134          52 : uno::Reference< drawing::XShape > XMLShapeExport::checkForCustomShapeReplacement( const uno::Reference< drawing::XShape >& xShape )
     135             : {
     136          52 :     uno::Reference< drawing::XShape > xCustomShapeReplacement;
     137             : 
     138          52 :     if( ( GetExport().getExportFlags() & EXPORT_OASIS ) == 0 )
     139             :     {
     140          25 :         OUString aType( xShape->getShapeType() );
     141          25 :         if( aType.equalsAscii( "com.sun.star.drawing.CustomShape" ) )
     142             :         {
     143           0 :             uno::Reference< beans::XPropertySet > xSet( xShape, uno::UNO_QUERY );
     144           0 :             if( xSet.is() )
     145             :             {
     146           0 :                 OUString aEngine;
     147           0 :                 xSet->getPropertyValue("CustomShapeEngine") >>= aEngine;
     148           0 :                 if ( aEngine.isEmpty() )
     149             :                 {
     150           0 :                     aEngine = "com.sun.star.drawing.EnhancedCustomShapeEngine";
     151             :                 }
     152           0 :                 uno::Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
     153             : 
     154           0 :                 if ( !aEngine.isEmpty() )
     155             :                 {
     156           0 :                     uno::Sequence< uno::Any > aArgument( 1 );
     157           0 :                     uno::Sequence< beans::PropertyValue > aPropValues( 2 );
     158           0 :                     aPropValues[ 0 ].Name = OUString( "CustomShape" );
     159           0 :                     aPropValues[ 0 ].Value <<= xShape;
     160           0 :                     sal_Bool bForceGroupWithText = sal_True;
     161           0 :                     aPropValues[ 1 ].Name = OUString( "ForceGroupWithText" );
     162           0 :                     aPropValues[ 1 ].Value <<= bForceGroupWithText;
     163           0 :                     aArgument[ 0 ] <<= aPropValues;
     164             :                     uno::Reference< uno::XInterface > xInterface(
     165           0 :                         xContext->getServiceManager()->createInstanceWithArgumentsAndContext(aEngine, aArgument, xContext) );
     166           0 :                     if ( xInterface.is() )
     167             :                     {
     168             :                         uno::Reference< drawing::XCustomShapeEngine > xCustomShapeEngine(
     169           0 :                             uno::Reference< drawing::XCustomShapeEngine >( xInterface, uno::UNO_QUERY ) );
     170           0 :                         if ( xCustomShapeEngine.is() )
     171           0 :                             xCustomShapeReplacement = xCustomShapeEngine->render();
     172           0 :                     }
     173           0 :                 }
     174           0 :             }
     175          25 :         }
     176             :     }
     177          52 :     return xCustomShapeReplacement;
     178             : }
     179             : 
     180             : // This method collects all automatic styles for the given XShape
     181          52 : void XMLShapeExport::collectShapeAutoStyles(const uno::Reference< drawing::XShape >& xShape )
     182             : {
     183          52 :     if( maCurrentShapesIter == maShapesInfos.end() )
     184             :     {
     185             :         OSL_FAIL( "XMLShapeExport::collectShapeAutoStyles(): no call to seekShapes()!" );
     186           0 :         return;
     187             :     }
     188          52 :     sal_Int32 nZIndex = 0;
     189          52 :     uno::Reference< beans::XPropertySet > xSet( xShape, uno::UNO_QUERY );
     190          52 :     if( xSet.is() )
     191          52 :         xSet->getPropertyValue(msZIndex) >>= nZIndex;
     192             : 
     193          52 :     ImplXMLShapeExportInfoVector& aShapeInfoVector = (*maCurrentShapesIter).second;
     194             : 
     195          52 :     if( (sal_Int32)aShapeInfoVector.size() <= nZIndex )
     196             :     {
     197             :         OSL_FAIL( "XMLShapeExport::collectShapeAutoStyles(): no shape info allocated for a given shape" );
     198           0 :         return;
     199             :     }
     200             : 
     201          52 :     ImplXMLShapeExportInfo& aShapeInfo = aShapeInfoVector[nZIndex];
     202             : 
     203         104 :     uno::Reference< drawing::XShape > xCustomShapeReplacement = checkForCustomShapeReplacement( xShape );
     204          52 :     if ( xCustomShapeReplacement.is() )
     205           0 :         aShapeInfo.xCustomShapeReplacement = xCustomShapeReplacement;
     206             : 
     207             :     // -----------------------------
     208             :     // first compute the shapes type
     209             :     // -----------------------------
     210          52 :     ImpCalcShapeType(xShape, aShapeInfo.meShapeType);
     211             : 
     212             :     // #i118485# enabled XmlShapeTypeDrawChartShape and XmlShapeTypeDrawOLE2Shape
     213             :     // to have text
     214             :     const bool bObjSupportsText =
     215         104 :         aShapeInfo.meShapeType != XmlShapeTypePresChartShape &&
     216         104 :         aShapeInfo.meShapeType != XmlShapeTypePresOLE2Shape &&
     217         104 :         aShapeInfo.meShapeType != XmlShapeTypeDrawSheetShape &&
     218         104 :         aShapeInfo.meShapeType != XmlShapeTypePresSheetShape &&
     219         104 :         aShapeInfo.meShapeType != XmlShapeTypeDraw3DSceneObject &&
     220         104 :         aShapeInfo.meShapeType != XmlShapeTypeDraw3DCubeObject &&
     221         104 :         aShapeInfo.meShapeType != XmlShapeTypeDraw3DSphereObject &&
     222         104 :         aShapeInfo.meShapeType != XmlShapeTypeDraw3DLatheObject &&
     223         104 :         aShapeInfo.meShapeType != XmlShapeTypeDraw3DExtrudeObject &&
     224         104 :         aShapeInfo.meShapeType != XmlShapeTypeDrawPageShape &&
     225         152 :         aShapeInfo.meShapeType != XmlShapeTypePresPageShape &&
     226         100 :         aShapeInfo.meShapeType != XmlShapeTypeDrawGroupShape;
     227             : 
     228             :     const bool bObjSupportsStyle =
     229          52 :         aShapeInfo.meShapeType != XmlShapeTypeDrawGroupShape;
     230             : 
     231          52 :     sal_Bool bIsEmptyPresObj = sal_False;
     232             : 
     233         104 :     uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
     234          52 :     if ( aShapeInfo.xCustomShapeReplacement.is() )
     235           0 :         xPropSet.clear();
     236             : 
     237             :     // ----------------
     238             :     // prep text styles
     239             :     // ----------------
     240          52 :     if( xPropSet.is() && bObjSupportsText )
     241             :     {
     242          48 :         uno::Reference< text::XText > xText(xShape, uno::UNO_QUERY);
     243          48 :         if(xText.is() && !xText->getString().isEmpty())
     244             :         {
     245          28 :             uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
     246             : 
     247          28 :             if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(msEmptyPres) )
     248             :             {
     249          28 :                 uno::Any aAny = xPropSet->getPropertyValue(msEmptyPres);
     250          28 :                 aAny >>= bIsEmptyPresObj;
     251             :             }
     252             : 
     253          28 :             if(!bIsEmptyPresObj)
     254             :             {
     255          22 :                 GetExport().GetTextParagraphExport()->collectTextAutoStyles( xText );
     256          28 :             }
     257          48 :         }
     258             :     }
     259             : 
     260             :     // ------------------------------
     261             :     // compute the shape parent style
     262             :     // ------------------------------
     263          52 :     if( xPropSet.is() )
     264             :     {
     265          52 :         uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( xPropSet->getPropertySetInfo() );
     266             : 
     267         104 :         OUString aParentName;
     268         104 :         uno::Reference< style::XStyle > xStyle;
     269             : 
     270          52 :         if( bObjSupportsStyle )
     271             :         {
     272          52 :             if( xPropertySetInfo.is() && xPropertySetInfo->hasPropertyByName("Style") )
     273          50 :                 xPropSet->getPropertyValue("Style") >>= xStyle;
     274             : 
     275          52 :             if(xStyle.is())
     276             :             {
     277             :                 // get family ID
     278          36 :                 uno::Reference< beans::XPropertySet > xStylePropSet(xStyle, uno::UNO_QUERY);
     279             :                 DBG_ASSERT( xStylePropSet.is(), "style without a XPropertySet?" );
     280             :                 try
     281             :                 {
     282          36 :                     if(xStylePropSet.is())
     283             :                     {
     284          36 :                         OUString aFamilyName;
     285          36 :                         xStylePropSet->getPropertyValue("Family") >>= aFamilyName;
     286          36 :                         if( !aFamilyName.isEmpty() && aFamilyName != "graphics" )
     287          28 :                             aShapeInfo.mnFamily = XML_STYLE_FAMILY_SD_PRESENTATION_ID;
     288             :                     }
     289             :                 }
     290           0 :                 catch(const beans::UnknownPropertyException&)
     291             :                 {
     292             :                     // Ignored.
     293             :                     DBG_ASSERT(false,
     294             :                         "XMLShapeExport::collectShapeAutoStyles: style has no 'Family' property");
     295             :                 }
     296             : 
     297             :                 // get parent-style name
     298          36 :                 if(XML_STYLE_FAMILY_SD_PRESENTATION_ID == aShapeInfo.mnFamily)
     299             :                 {
     300          28 :                     aParentName = msPresentationStylePrefix;
     301             :                 }
     302             : 
     303          36 :                 aParentName += xStyle->getName();
     304             :             }
     305             :         }
     306             : 
     307             :         // filter propset
     308         104 :         std::vector< XMLPropertyState > xPropStates;
     309             : 
     310          52 :         sal_Int32 nCount = 0;
     311          52 :         if( (!bIsEmptyPresObj || (aShapeInfo.meShapeType != XmlShapeTypePresPageShape)) )
     312             :         {
     313          52 :             xPropStates = GetPropertySetMapper()->Filter( xPropSet );
     314             : 
     315          52 :             if (XmlShapeTypeDrawControlShape == aShapeInfo.meShapeType)
     316             :             {
     317             :                 // for control shapes, we additionally need the number format style (if any)
     318           0 :                 uno::Reference< drawing::XControlShape > xControl(xShape, uno::UNO_QUERY);
     319             :                 DBG_ASSERT(xControl.is(), "XMLShapeExport::collectShapeAutoStyles: ShapeType control, but no XControlShape!");
     320           0 :                 if (xControl.is())
     321             :                 {
     322           0 :                     uno::Reference< beans::XPropertySet > xControlModel(xControl->getControl(), uno::UNO_QUERY);
     323             :                     DBG_ASSERT(xControlModel.is(), "XMLShapeExport::collectShapeAutoStyles: no control model on the control shape!");
     324             : 
     325           0 :                     OUString sNumberStyle = mrExport.GetFormExport()->getControlNumberStyle(xControlModel);
     326           0 :                     if (!sNumberStyle.isEmpty())
     327             :                     {
     328           0 :                         sal_Int32 nIndex = GetPropertySetMapper()->getPropertySetMapper()->FindEntryIndex(CTF_SD_CONTROL_SHAPE_DATA_STYLE);
     329             :                             // TODO : this retrieval of the index could be moved into the ctor, holding the index
     330             :                             //          as member, thus saving time.
     331             :                         DBG_ASSERT(-1 != nIndex, "XMLShapeExport::collectShapeAutoStyles: could not obtain the index for our context id!");
     332             : 
     333           0 :                         XMLPropertyState aNewState(nIndex, uno::makeAny(sNumberStyle));
     334           0 :                         xPropStates.push_back(aNewState);
     335           0 :                     }
     336           0 :                 }
     337             :             }
     338             : 
     339          52 :             std::vector< XMLPropertyState >::iterator aIter = xPropStates.begin();
     340          52 :             std::vector< XMLPropertyState >::iterator aEnd = xPropStates.end();
     341         328 :             while( aIter != aEnd )
     342             :             {
     343         224 :                 if( aIter->mnIndex != -1 )
     344         134 :                     nCount++;
     345         224 :                 ++aIter;
     346             :             }
     347             :         }
     348             : 
     349          52 :         if(nCount == 0)
     350             :         {
     351             :             // no hard attributes, use parent style name for export
     352          20 :             aShapeInfo.msStyleName = aParentName;
     353             :         }
     354             :         else
     355             :         {
     356             :             // there are filtered properties -> hard attributes
     357             :             // try to find this style in AutoStylePool
     358          32 :             aShapeInfo.msStyleName = mrExport.GetAutoStylePool()->Find(aShapeInfo.mnFamily, aParentName, xPropStates);
     359             : 
     360          32 :             if(aShapeInfo.msStyleName.isEmpty())
     361             :             {
     362             :                 // Style did not exist, add it to AutoStalePool
     363          20 :                 aShapeInfo.msStyleName = mrExport.GetAutoStylePool()->Add(aShapeInfo.mnFamily, aParentName, xPropStates);
     364             :             }
     365             :         }
     366             : 
     367             :         // optionaly generate auto style for text attributes
     368          52 :         if( (!bIsEmptyPresObj || (aShapeInfo.meShapeType != XmlShapeTypePresPageShape)) && bObjSupportsText )
     369             :         {
     370          48 :             xPropStates = GetExport().GetTextParagraphExport()->GetParagraphPropertyMapper()->Filter( xPropSet );
     371             : 
     372             :             // ----------------------------------------------------------------------
     373             :             // yet more additionally, we need to care for the ParaAdjust property
     374          48 :             if ( XmlShapeTypeDrawControlShape == aShapeInfo.meShapeType )
     375             :             {
     376           0 :                 uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
     377           0 :                 uno::Reference< beans::XPropertyState > xPropState( xPropSet, uno::UNO_QUERY );
     378           0 :                 if ( xPropSetInfo.is() && xPropState.is() )
     379             :                 {
     380             :                     // this is because:
     381             :                     // * if controls shapes have a ParaAdjust property, then this is the Align property of the control model
     382             :                     // * control models are allowed to have an Align of "void"
     383             :                     // * the Default for control model's Align is TextAlign_LEFT
     384             :                     // * defaults for style properties are not written, but we need to write the "left",
     385             :                     //   because we need to distiguish this "left" from the case where not align attribute
     386             :                     //   is present which means "void"
     387           0 :                     static const OUString s_sParaAdjustPropertyName(  "ParaAdjust"  );
     388           0 :                     if  (   xPropSetInfo->hasPropertyByName( s_sParaAdjustPropertyName )
     389           0 :                         &&  ( beans::PropertyState_DEFAULT_VALUE == xPropState->getPropertyState( s_sParaAdjustPropertyName ) )
     390             :                         )
     391             :                     {
     392           0 :                         sal_Int32 nIndex = GetExport().GetTextParagraphExport()->GetParagraphPropertyMapper()->getPropertySetMapper()->FindEntryIndex( CTF_SD_SHAPE_PARA_ADJUST );
     393             :                             // TODO : this retrieval of the index should be moved into the ctor, holding the index
     394             :                             //          as member, thus saving time.
     395             :                         DBG_ASSERT(-1 != nIndex, "XMLShapeExport::collectShapeAutoStyles: could not obtain the index for the ParaAdjust context id!");
     396             : 
     397           0 :                         uno::Any aParaAdjustValue = xPropSet->getPropertyValue( s_sParaAdjustPropertyName );
     398           0 :                         XMLPropertyState aAlignDefaultState( nIndex, aParaAdjustValue );
     399             : 
     400           0 :                         xPropStates.push_back( aAlignDefaultState );
     401             :                     }
     402           0 :                 }
     403             :             }
     404             :             // ----------------------------------------------------------------------
     405             : 
     406          48 :             nCount = 0;
     407          48 :             std::vector< XMLPropertyState >::iterator aIter = xPropStates.begin();
     408          48 :             std::vector< XMLPropertyState >::iterator aEnd = xPropStates.end();
     409         190 :             while( aIter != aEnd )
     410             :             {
     411          94 :                 if( aIter->mnIndex != -1 )
     412          94 :                     nCount++;
     413          94 :                 ++aIter;
     414             :             }
     415             : 
     416          48 :             if( nCount )
     417             :             {
     418          24 :                 const OUString aEmpty;
     419          24 :                 aShapeInfo.msTextStyleName = mrExport.GetAutoStylePool()->Find( XML_STYLE_FAMILY_TEXT_PARAGRAPH, aEmpty, xPropStates );
     420          24 :                 if(aShapeInfo.msTextStyleName.isEmpty())
     421             :                 {
     422             :                     // Style did not exist, add it to AutoStalePool
     423           2 :                     aShapeInfo.msTextStyleName = mrExport.GetAutoStylePool()->Add(XML_STYLE_FAMILY_TEXT_PARAGRAPH, aEmpty, xPropStates);
     424          24 :                 }
     425             :             }
     426          52 :         }
     427             :     }
     428             : 
     429             :     // ----------------------------------------
     430             :     // prepare animation information if needed
     431             :     // ----------------------------------------
     432          52 :     if( mxAnimationsExporter.is() )
     433           4 :         mxAnimationsExporter->prepare( xShape, mrExport );
     434             : 
     435             :     // check for special shapes
     436             : 
     437          52 :     switch( aShapeInfo.meShapeType )
     438             :     {
     439             :         case XmlShapeTypeDrawConnectorShape:
     440             :         {
     441           0 :             uno::Reference< uno::XInterface > xConnection;
     442             : 
     443             :             // create shape ids for export later
     444           0 :             xPropSet->getPropertyValue( msStartShape ) >>= xConnection;
     445           0 :             if( xConnection.is() )
     446           0 :                 mrExport.getInterfaceToIdentifierMapper().registerReference( xConnection );
     447             : 
     448           0 :             xPropSet->getPropertyValue( msEndShape ) >>= xConnection;
     449           0 :             if( xConnection.is() )
     450           0 :                 mrExport.getInterfaceToIdentifierMapper().registerReference( xConnection );
     451           0 :             break;
     452             :         }
     453             :         case XmlShapeTypePresTableShape:
     454             :         case XmlShapeTypeDrawTableShape:
     455             :         {
     456             :             try
     457             :             {
     458           0 :                 uno::Reference< table::XColumnRowRange > xRange( xSet->getPropertyValue( msModel ), uno::UNO_QUERY_THROW );
     459           0 :                 GetShapeTableExport()->collectTableAutoStyles( xRange );
     460             :             }
     461           0 :             catch(const uno::Exception&)
     462             :             {
     463             :                 OSL_FAIL( "XMLShapeExport::collectShapeAutoStyles(): exception caught while collection auto styles for a table!" );
     464             :             }
     465           0 :             break;
     466             :         }
     467             :         default:
     468          52 :             break;
     469             :     }
     470             : 
     471          52 :     maShapeInfos.push_back( aShapeInfo );
     472          52 :     maCurrentInfo = maShapeInfos.begin();
     473             : 
     474             :     // -----------------------------------------------------
     475             :     // check for shape collections (group shape or 3d scene)
     476             :     // and collect contained shapes style infos
     477             :     // -----------------------------------------------------
     478          52 :     const uno::Reference< drawing::XShape >& xCollection = aShapeInfo.xCustomShapeReplacement.is()
     479          52 :                                                 ? aShapeInfo.xCustomShapeReplacement : xShape;
     480             :     {
     481          52 :         uno::Reference< drawing::XShapes > xShapes( xCollection, uno::UNO_QUERY );
     482          52 :         if( xShapes.is() )
     483             :         {
     484           0 :             collectShapesAutoStyles( xShapes );
     485          52 :         }
     486          52 :     }
     487             : }
     488             : 
     489             : ///////////////////////////////////////////////////////////////////////
     490             : 
     491             : namespace
     492             : {
     493             :     class NewTextListsHelper
     494             :     {
     495             :         public:
     496          52 :             NewTextListsHelper( SvXMLExport& rExp )
     497          52 :                 : mrExport( rExp )
     498             :             {
     499          52 :                 mrExport.GetTextParagraphExport()->PushNewTextListsHelper();
     500          52 :             }
     501             : 
     502          52 :             ~NewTextListsHelper()
     503             :             {
     504          52 :                 mrExport.GetTextParagraphExport()->PopTextListsHelper();
     505          52 :             }
     506             : 
     507             :         private:
     508             :             SvXMLExport& mrExport;
     509             :     };
     510             : }
     511             : // This method exports the given XShape
     512          52 : void XMLShapeExport::exportShape(const uno::Reference< drawing::XShape >& xShape,
     513             :                                  sal_Int32 nFeatures /* = SEF_DEFAULT */,
     514             :                                  com::sun::star::awt::Point* pRefPoint /* = NULL */,
     515             :                                  SvXMLAttributeList* pAttrList /* = NULL */ )
     516             : {
     517             :     SAL_WARN("xmloff", xShape->getShapeType());
     518          52 :     if( maCurrentShapesIter == maShapesInfos.end() )
     519             :     {
     520             :         SAL_WARN( "xmloff", "XMLShapeExport::exportShape(): no auto styles where collected before export" );
     521           0 :         return;
     522             :     }
     523          52 :     sal_Int32 nZIndex = 0;
     524          52 :     uno::Reference< beans::XPropertySet > xSet( xShape, uno::UNO_QUERY );
     525             : 
     526             : 
     527         104 :     ::std::auto_ptr< SvXMLElementExport >  mpHyperlinkElement;
     528             : 
     529             :     // export hyperlinks with <a><shape/></a>. Currently only in draw since draw
     530             :     // does not support document events
     531          52 :     if( xSet.is() && (GetExport().GetModelType() == SvtModuleOptions::E_DRAW) ) try
     532             :     {
     533           0 :         presentation::ClickAction eAction = presentation::ClickAction_NONE;
     534           0 :         xSet->getPropertyValue("OnClick") >>= eAction;
     535             : 
     536           0 :         if( (eAction == presentation::ClickAction_DOCUMENT) ||
     537           0 :             (eAction == presentation::ClickAction_BOOKMARK) )
     538             :         {
     539           0 :             OUString sURL;
     540           0 :             xSet->getPropertyValue(msBookmark) >>= sURL;
     541             : 
     542           0 :             if( !sURL.isEmpty() )
     543             :             {
     544           0 :                 mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, sURL );
     545           0 :                 mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
     546           0 :                 mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
     547           0 :                 mpHyperlinkElement.reset( new SvXMLElementExport(mrExport, XML_NAMESPACE_DRAW, XML_A, sal_True, sal_True) );
     548           0 :             }
     549             :         }
     550             :     }
     551           0 :     catch(const uno::Exception&)
     552             :     {
     553             :         SAL_WARN("xmloff", "XMLShapeExport::exportShape(): exception during hyperlink export");
     554             :     }
     555             : 
     556             : 
     557          52 :     if( xSet.is() )
     558          52 :         xSet->getPropertyValue(msZIndex) >>= nZIndex;
     559             : 
     560          52 :     ImplXMLShapeExportInfoVector& aShapeInfoVector = (*maCurrentShapesIter).second;
     561             : 
     562          52 :     if( (sal_Int32)aShapeInfoVector.size() <= nZIndex )
     563             :     {
     564             :         SAL_WARN( "xmloff", "XMLShapeExport::exportShape(): no shape info collected for a given shape" );
     565           0 :         return;
     566             :     }
     567             : 
     568         104 :     NewTextListsHelper aNewTextListsHelper( mrExport );
     569             : 
     570          52 :     const ImplXMLShapeExportInfo& aShapeInfo = aShapeInfoVector[nZIndex];
     571             : 
     572             : 
     573             : #ifdef DBG_UTIL
     574             :     // ---------------------------------------
     575             :     // check if this is the correct ShapesInfo
     576             :     // ---------------------------------------
     577             :     uno::Reference< container::XChild > xChild( xShape, uno::UNO_QUERY );
     578             :     if( xChild.is() )
     579             :     {
     580             :         uno::Reference< drawing::XShapes > xParent( xChild->getParent(), uno::UNO_QUERY );
     581             :         DBG_ASSERT( xParent.is() && xParent.get() == (*maCurrentShapesIter).first.get(), "XMLShapeExport::exportShape(): Wrong call to XMLShapeExport::seekShapes()" );
     582             :     }
     583             : 
     584             :     // -----------------------------
     585             :     // first compute the shapes type
     586             :     // -----------------------------
     587             :     {
     588             :         XmlShapeType eShapeType(XmlShapeTypeNotYetSet);
     589             :         ImpCalcShapeType(xShape, eShapeType);
     590             : 
     591             :         SAL_WARN_IF( eShapeType != aShapeInfo.meShapeType, "xmloff", "exportShape callings do not correspond to collectShapeAutoStyles calls!: " << xShape->getShapeType() );
     592             :     }
     593             : #endif
     594             : 
     595             :     // ----------------------------------------
     596             :     // collect animation information if needed
     597             :     // ----------------------------------------
     598          52 :     if( mxAnimationsExporter.is() )
     599           2 :         mxAnimationsExporter->collect( xShape, mrExport );
     600             : 
     601             :     /* Export shapes name if he has one (#i51726#)
     602             :        Export of the shape name for text documents only if the OpenDocument
     603             :        file format is written - exceptions are group shapes.
     604             :        Note: Writer documents in OpenOffice.org file format doesn't contain
     605             :              any names for shapes, except for group shapes.
     606             :     */
     607             :     {
     608         156 :         if ( ( GetExport().GetModelType() != SvtModuleOptions::E_WRITER &&
     609         104 :                GetExport().GetModelType() != SvtModuleOptions::E_WRITERWEB &&
     610          52 :                GetExport().GetModelType() != SvtModuleOptions::E_WRITERGLOBAL ) ||
     611           0 :              ( GetExport().getExportFlags() & EXPORT_OASIS ) != 0 ||
     612         104 :              aShapeInfo.meShapeType == XmlShapeTypeDrawGroupShape ||
     613           0 :              ( aShapeInfo.meShapeType == XmlShapeTypeDrawCustomShape &&
     614           0 :                aShapeInfo.xCustomShapeReplacement.is() ) )
     615             :         {
     616          52 :             uno::Reference< container::XNamed > xNamed( xShape, uno::UNO_QUERY );
     617          52 :             if( xNamed.is() )
     618             :             {
     619          52 :                 const OUString aName( xNamed->getName() );
     620          52 :                 if( !aName.isEmpty() )
     621           0 :                     mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_NAME, aName );
     622          52 :             }
     623             :         }
     624             :     }
     625             : 
     626             :     // ------------------
     627             :     // export style name
     628             :     // ------------------
     629          52 :     if( !aShapeInfo.msStyleName.isEmpty() )
     630             :     {
     631          40 :         if(XML_STYLE_FAMILY_SD_GRAPHICS_ID == aShapeInfo.mnFamily)
     632          12 :             mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_STYLE_NAME, mrExport.EncodeStyleName( aShapeInfo.msStyleName) );
     633             :         else
     634          28 :             mrExport.AddAttribute(XML_NAMESPACE_PRESENTATION, XML_STYLE_NAME, mrExport.EncodeStyleName( aShapeInfo.msStyleName) );
     635             :     }
     636             : 
     637             :     // ------------------
     638             :     // export text style name
     639             :     // ------------------
     640          52 :     if( !aShapeInfo.msTextStyleName.isEmpty() )
     641             :     {
     642          24 :         mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_TEXT_STYLE_NAME, aShapeInfo.msTextStyleName );
     643             :     }
     644             : 
     645             :     // --------------------------
     646             :     // export shapes id if needed
     647             :     // --------------------------
     648             :     {
     649          52 :         uno::Reference< uno::XInterface > xRef( xShape, uno::UNO_QUERY );
     650          52 :         const OUString& rShapeId = mrExport.getInterfaceToIdentifierMapper().getIdentifier( xRef );
     651          52 :         if( !rShapeId.isEmpty() )
     652             :         {
     653           0 :             mrExport.AddAttributeIdLegacy(XML_NAMESPACE_DRAW, rShapeId);
     654          52 :         }
     655             :     }
     656             : 
     657             :     // --------------------------
     658             :     // export layer information
     659             :     // --------------------------
     660          52 :     if( IsLayerExportEnabled() )
     661             :     {
     662             :         // check for group or scene shape and not export layer if this is one
     663          50 :         uno::Reference< drawing::XShapes > xShapes( xShape, uno::UNO_QUERY );
     664          50 :         if( !xShapes.is() )
     665             :         {
     666             :             try
     667             :             {
     668          50 :                 uno::Reference< beans::XPropertySet > xProps( xShape, uno::UNO_QUERY );
     669         100 :                 OUString aLayerName;
     670          50 :                 xProps->getPropertyValue("LayerName") >>= aLayerName;
     671         100 :                 mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_LAYER, aLayerName );
     672             : 
     673             :             }
     674           0 :             catch(const uno::Exception&)
     675             :             {
     676             :                 OSL_FAIL( "could not export layer name for shape!" );
     677             :             }
     678          50 :         }
     679             :     }
     680             : 
     681             :     // export draw:display (do not export in ODF 1.2 or older)
     682          52 :     if( xSet.is() && ( mrExport.getDefaultVersion() > SvtSaveOptions::ODFVER_012 ) )
     683             :     {
     684         100 :         if( aShapeInfo.meShapeType != XmlShapeTypeDrawPageShape && aShapeInfo.meShapeType != XmlShapeTypePresPageShape &&
     685          84 :             aShapeInfo.meShapeType != XmlShapeTypeHandoutShape && aShapeInfo.meShapeType != XmlShapeTypeDrawChartShape )
     686             : 
     687             :         try
     688             :         {
     689          36 :             sal_Bool bVisible = sal_True;
     690          36 :             sal_Bool bPrintable = sal_True;
     691             : 
     692          36 :             xSet->getPropertyValue(msVisible) >>= bVisible;
     693          36 :             xSet->getPropertyValue(msPrintable) >>= bPrintable;
     694             : 
     695          36 :             XMLTokenEnum eDisplayToken = XML_TOKEN_INVALID;
     696          36 :             const unsigned short nDisplay = (bVisible ? 2 : 0) | (bPrintable ? 1 : 0);
     697          36 :             switch( nDisplay )
     698             :             {
     699           0 :             case 0: eDisplayToken = XML_NONE; break;
     700           0 :             case 1: eDisplayToken = XML_PRINTER; break;
     701           0 :             case 2: eDisplayToken = XML_SCREEN; break;
     702             :             // case 3: eDisplayToken = XML_ALWAYS break; this is the default
     703             :             }
     704             : 
     705          36 :             if( eDisplayToken != XML_TOKEN_INVALID )
     706           0 :                 mrExport.AddAttribute(XML_NAMESPACE_DRAW_EXT, XML_DISPLAY, eDisplayToken );
     707             :         }
     708           0 :         catch(const uno::Exception&)
     709             :         {
     710             :             OSL_FAIL( "XMLShapeExport::exportShape(), exception caught!" );
     711             :         }
     712             :     }
     713             : 
     714             :     // #82003# test export count
     715             :     // #91587# ALWAYS increment since now ALL to be exported shapes are counted.
     716          52 :     if(mrExport.GetShapeExport()->IsHandleProgressBarEnabled())
     717             :     {
     718          50 :         mrExport.GetProgressBarHelper()->Increment();
     719             :     }
     720             : 
     721          52 :     onExport( xShape );
     722             : 
     723             :     // --------------------
     724             :     // export shape element
     725             :     // --------------------
     726          52 :     switch(aShapeInfo.meShapeType)
     727             :     {
     728             :         case XmlShapeTypeDrawRectangleShape:
     729             :         {
     730           2 :             ImpExportRectangleShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
     731           2 :             break;
     732             :         }
     733             :         case XmlShapeTypeDrawEllipseShape:
     734             :         {
     735           0 :             ImpExportEllipseShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
     736           0 :             break;
     737             :         }
     738             :         case XmlShapeTypeDrawLineShape:
     739             :         {
     740           0 :             ImpExportLineShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
     741           0 :             break;
     742             :         }
     743             :         case XmlShapeTypeDrawPolyPolygonShape:  // closed PolyPolygon
     744             :         case XmlShapeTypeDrawPolyLineShape:     // open PolyPolygon
     745             :         case XmlShapeTypeDrawClosedBezierShape: // closed PolyPolygon containing curves
     746             :         case XmlShapeTypeDrawOpenBezierShape:   // open PolyPolygon containing curves
     747             :         {
     748           0 :             ImpExportPolygonShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
     749           0 :             break;
     750             :         }
     751             : 
     752             :         case XmlShapeTypeDrawTextShape:
     753             :         case XmlShapeTypePresTitleTextShape:
     754             :         case XmlShapeTypePresOutlinerShape:
     755             :         case XmlShapeTypePresSubtitleShape:
     756             :         case XmlShapeTypePresNotesShape:
     757             :         case XmlShapeTypePresHeaderShape:
     758             :         case XmlShapeTypePresFooterShape:
     759             :         case XmlShapeTypePresSlideNumberShape:
     760             :         case XmlShapeTypePresDateTimeShape:
     761             :         {
     762          34 :             ImpExportTextBoxShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
     763          34 :             break;
     764             :         }
     765             : 
     766             :         case XmlShapeTypeDrawGraphicObjectShape:
     767             :         case XmlShapeTypePresGraphicObjectShape:
     768             :         {
     769           0 :             ImpExportGraphicObjectShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
     770           0 :             break;
     771             :         }
     772             : 
     773             :         case XmlShapeTypeDrawChartShape:
     774             :         case XmlShapeTypePresChartShape:
     775             :         {
     776           0 :             ImpExportChartShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint, pAttrList );
     777           0 :             break;
     778             :         }
     779             : 
     780             :         case XmlShapeTypeDrawControlShape:
     781             :         {
     782           0 :             ImpExportControlShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
     783           0 :             break;
     784             :         }
     785             : 
     786             :         case XmlShapeTypeDrawConnectorShape:
     787             :         {
     788           0 :             ImpExportConnectorShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
     789           0 :             break;
     790             :         }
     791             : 
     792             :         case XmlShapeTypeDrawMeasureShape:
     793             :         {
     794           0 :             ImpExportMeasureShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
     795           0 :             break;
     796             :         }
     797             : 
     798             :         case XmlShapeTypeDrawOLE2Shape:
     799             :         case XmlShapeTypePresOLE2Shape:
     800             :         case XmlShapeTypeDrawSheetShape:
     801             :         case XmlShapeTypePresSheetShape:
     802             :         {
     803           0 :             ImpExportOLE2Shape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
     804           0 :             break;
     805             :         }
     806             : 
     807             :         case XmlShapeTypePresTableShape:
     808             :         case XmlShapeTypeDrawTableShape:
     809             :         {
     810           0 :             ImpExportTableShape( xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
     811           0 :             break;
     812             :         }
     813             : 
     814             :         case XmlShapeTypeDrawPageShape:
     815             :         case XmlShapeTypePresPageShape:
     816             :         case XmlShapeTypeHandoutShape:
     817             :         {
     818          16 :             ImpExportPageShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
     819          16 :             break;
     820             :         }
     821             : 
     822             :         case XmlShapeTypeDrawCaptionShape:
     823             :         {
     824           0 :             ImpExportCaptionShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
     825           0 :             break;
     826             :         }
     827             : 
     828             :         case XmlShapeTypeDraw3DCubeObject:
     829             :         case XmlShapeTypeDraw3DSphereObject:
     830             :         case XmlShapeTypeDraw3DLatheObject:
     831             :         case XmlShapeTypeDraw3DExtrudeObject:
     832             :         {
     833           0 :             ImpExport3DShape(xShape, aShapeInfo.meShapeType);
     834           0 :             break;
     835             :         }
     836             : 
     837             :         case XmlShapeTypeDraw3DSceneObject:
     838             :         {
     839           0 :             ImpExport3DSceneShape( xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
     840           0 :             break;
     841             :         }
     842             : 
     843             :         case XmlShapeTypeDrawGroupShape:
     844             :         {
     845             :             // empty group
     846           0 :             ImpExportGroupShape( xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
     847           0 :             break;
     848             :         }
     849             : 
     850             :         case XmlShapeTypeDrawFrameShape:
     851             :         {
     852           0 :             ImpExportFrameShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
     853           0 :             break;
     854             :         }
     855             : 
     856             :         case XmlShapeTypeDrawAppletShape:
     857             :         {
     858           0 :             ImpExportAppletShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
     859           0 :             break;
     860             :         }
     861             : 
     862             :         case XmlShapeTypeDrawPluginShape:
     863             :         {
     864           0 :             ImpExportPluginShape(xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
     865           0 :             break;
     866             :         }
     867             : 
     868             :         case XmlShapeTypeDrawCustomShape:
     869             :         {
     870           0 :             if ( aShapeInfo.xCustomShapeReplacement.is() )
     871           0 :                 ImpExportGroupShape( aShapeInfo.xCustomShapeReplacement, XmlShapeTypeDrawGroupShape, nFeatures, pRefPoint );
     872             :             else
     873           0 :                 ImpExportCustomShape( xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
     874           0 :             break;
     875             :         }
     876             : 
     877             :         case XmlShapeTypePresMediaShape:
     878             :         case XmlShapeTypeDrawMediaShape:
     879             :         {
     880           0 :             ImpExportMediaShape( xShape, aShapeInfo.meShapeType, nFeatures, pRefPoint );
     881           0 :             break;
     882             :         }
     883             : 
     884             :         case XmlShapeTypePresOrgChartShape:
     885             :         case XmlShapeTypeUnknown:
     886             :         case XmlShapeTypeNotYetSet:
     887             :         default:
     888             :         {
     889             :             // this should never happen and is an error
     890             :             OSL_FAIL("XMLEXP: WriteShape: unknown or unexpected type of shape in export!");
     891           0 :             break;
     892             :         }
     893             :     }
     894             : 
     895          52 :     mpHyperlinkElement.reset();
     896             : 
     897             :     // #97489# #97111#
     898             :     // if there was an error and no element for the shape was exported
     899             :     // we need to clear the attribute list or the attributes will be
     900             :     // set on the next exported element, which can result in corrupt
     901             :     // xml files due to duplicate attributes
     902             : 
     903          52 :     mrExport.CheckAttrList();   // asserts in non pro if we have attributes left
     904         104 :     mrExport.ClearAttrList();   // clears the attributes
     905             : }
     906             : 
     907             : ///////////////////////////////////////////////////////////////////////
     908             : 
     909             : // This method collects all automatic styles for the shapes inside the given XShapes collection
     910          10 : void XMLShapeExport::collectShapesAutoStyles( const uno::Reference < drawing::XShapes >& xShapes )
     911             : {
     912          10 :     ShapesInfos::iterator aOldCurrentShapesIter = maCurrentShapesIter;
     913          10 :     seekShapes( xShapes );
     914             : 
     915          10 :     uno::Reference< drawing::XShape > xShape;
     916          10 :     const sal_Int32 nShapeCount(xShapes->getCount());
     917          60 :     for(sal_Int32 nShapeId = 0; nShapeId < nShapeCount; nShapeId++)
     918             :     {
     919          50 :         xShapes->getByIndex(nShapeId) >>= xShape;
     920             :         SAL_WARN_IF( !xShape.is(), "xmloff", "Shape without a XShape?" );
     921          50 :         if(!xShape.is())
     922           0 :             continue;
     923             : 
     924          50 :         collectShapeAutoStyles( xShape );
     925             :     }
     926             : 
     927          10 :     maCurrentShapesIter = aOldCurrentShapesIter;
     928          10 : }
     929             : 
     930             : ///////////////////////////////////////////////////////////////////////
     931             : 
     932             : // This method exports all XShape inside the given XShapes collection
     933          10 : void XMLShapeExport::exportShapes( const uno::Reference < drawing::XShapes >& xShapes, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */ )
     934             : {
     935          10 :     ShapesInfos::iterator aOldCurrentShapesIter = maCurrentShapesIter;
     936          10 :     seekShapes( xShapes );
     937             : 
     938          10 :     uno::Reference< drawing::XShape > xShape;
     939          10 :     const sal_Int32 nShapeCount(xShapes->getCount());
     940          60 :     for(sal_Int32 nShapeId = 0; nShapeId < nShapeCount; nShapeId++)
     941             :     {
     942          50 :         xShapes->getByIndex(nShapeId) >>= xShape;
     943             :         SAL_WARN_IF( !xShape.is(), "xmloff", "Shape without a XShape?" );
     944          50 :         if(!xShape.is())
     945           0 :             continue;
     946             : 
     947          50 :         exportShape( xShape, nFeatures, pRefPoint );
     948             :     }
     949             : 
     950          10 :     maCurrentShapesIter = aOldCurrentShapesIter;
     951          10 : }
     952             : 
     953             : ///////////////////////////////////////////////////////////////////////
     954             : 
     955          70 : void XMLShapeExport::seekShapes( const uno::Reference< drawing::XShapes >& xShapes ) throw()
     956             : {
     957          70 :     if( xShapes.is() )
     958             :     {
     959          70 :         maCurrentShapesIter = maShapesInfos.find( xShapes );
     960          70 :         if( maCurrentShapesIter == maShapesInfos.end() )
     961             :         {
     962          51 :             ImplXMLShapeExportInfoVector aNewInfoVector;
     963          51 :             aNewInfoVector.resize( (ShapesInfos::size_type) xShapes->getCount() );
     964          51 :             maShapesInfos[ xShapes ] = aNewInfoVector;
     965             : 
     966          51 :             maCurrentShapesIter = maShapesInfos.find( xShapes );
     967             : 
     968          51 :             DBG_ASSERT( maCurrentShapesIter != maShapesInfos.end(), "XMLShapeExport::seekShapes(): insert into stl::map failed" );
     969             :         }
     970             : 
     971             :         DBG_ASSERT( (*maCurrentShapesIter).second.size() == (ShapesInfos::size_type)xShapes->getCount(), "XMLShapeExport::seekShapes(): XShapes size varied between calls" );
     972             : 
     973             :     }
     974             :     else
     975             :     {
     976           0 :         maCurrentShapesIter = maShapesInfos.end();
     977             :     }
     978          70 : }
     979             : 
     980             : ///////////////////////////////////////////////////////////////////////
     981             : 
     982          55 : void XMLShapeExport::exportAutoStyles()
     983             : {
     984             :     // export all autostyle infos
     985             : 
     986             :     // ...for graphic
     987             :     {
     988          55 :         GetExport().GetAutoStylePool()->exportXML(
     989             :             XML_STYLE_FAMILY_SD_GRAPHICS_ID
     990          55 :             , GetExport().GetDocHandler(),
     991          55 :             GetExport().GetMM100UnitConverter(),
     992          55 :             GetExport().GetNamespaceMap()
     993          55 :             );
     994             :     }
     995             : 
     996             :     // ...for presentation
     997             :     {
     998          55 :         GetExport().GetAutoStylePool()->exportXML(
     999             :             XML_STYLE_FAMILY_SD_PRESENTATION_ID
    1000          55 :             , GetExport().GetDocHandler(),
    1001          55 :             GetExport().GetMM100UnitConverter(),
    1002          55 :             GetExport().GetNamespaceMap()
    1003          55 :             );
    1004             :     }
    1005             : 
    1006          55 :     if( mxShapeTableExport.is() )
    1007          55 :         mxShapeTableExport->exportAutoStyles();
    1008          55 : }
    1009             : 
    1010             : ///////////////////////////////////////////////////////////////////////
    1011             : 
    1012             : /// returns the export property mapper for external chaining
    1013         126 : SvXMLExportPropertyMapper* XMLShapeExport::CreateShapePropMapper(
    1014             :     SvXMLExport& rExport )
    1015             : {
    1016         126 :     UniReference< XMLPropertyHandlerFactory > xFactory = new XMLSdPropHdlFactory( rExport.GetModel(), rExport );
    1017         252 :     UniReference < XMLPropertySetMapper > xMapper = new XMLShapePropertySetMapper( xFactory );
    1018         126 :     rExport.GetTextParagraphExport(); // get or create text paragraph export
    1019             :     SvXMLExportPropertyMapper* pResult =
    1020         126 :         new XMLShapeExportPropertyMapper( xMapper, rExport );
    1021             :     // chain text attributes
    1022         252 :     return pResult;
    1023             : }
    1024             : 
    1025             : ///////////////////////////////////////////////////////////////////////
    1026             : 
    1027          52 : void XMLShapeExport::ImpCalcShapeType(const uno::Reference< drawing::XShape >& xShape,
    1028             :     XmlShapeType& eShapeType)
    1029             : {
    1030             :     // set in every case, so init here
    1031          52 :     eShapeType = XmlShapeTypeUnknown;
    1032             : 
    1033          52 :     uno::Reference< drawing::XShapeDescriptor > xShapeDescriptor(xShape, uno::UNO_QUERY);
    1034          52 :     if(xShapeDescriptor.is())
    1035             :     {
    1036          52 :         OUString aType(xShapeDescriptor->getShapeType());
    1037             : 
    1038          52 :         if(aType.match("com.sun.star."))
    1039             :         {
    1040          52 :             if(aType.match("drawing.", 13))
    1041             :             {
    1042             :                 // drawing shapes
    1043           2 :                 if     (aType.match("Rectangle", 21)) { eShapeType = XmlShapeTypeDrawRectangleShape; }
    1044             : 
    1045             :                 // #i72177# Note: Correcting CustomShape, CustomShape->Custom, len from 9 (was wrong anyways) to 6.
    1046             :                 // As can be seen at the other compares, the appendix "Shape" is left out of the comparison.
    1047           0 :                 else if(aType.match("Custom", 21)) { eShapeType = XmlShapeTypeDrawCustomShape; }
    1048             : 
    1049           0 :                 else if(aType.match("Ellipse", 21)) { eShapeType = XmlShapeTypeDrawEllipseShape; }
    1050           0 :                 else if(aType.match("Control", 21)) { eShapeType = XmlShapeTypeDrawControlShape; }
    1051           0 :                 else if(aType.match("Connector", 21)) { eShapeType = XmlShapeTypeDrawConnectorShape; }
    1052           0 :                 else if(aType.match("Measure", 21)) { eShapeType = XmlShapeTypeDrawMeasureShape; }
    1053           0 :                 else if(aType.match("Line", 21)) { eShapeType = XmlShapeTypeDrawLineShape; }
    1054             : 
    1055             :                 // #i72177# Note: This covers two types by purpose, PolyPolygonShape and PolyPolygonPathShape
    1056           0 :                 else if(aType.match("PolyPolygon", 21)) { eShapeType = XmlShapeTypeDrawPolyPolygonShape; }
    1057             : 
    1058             :                 // #i72177# Note: This covers two types by purpose, PolyLineShape and PolyLinePathShape
    1059           0 :                 else if(aType.match("PolyLine", 21)) { eShapeType = XmlShapeTypeDrawPolyLineShape; }
    1060             : 
    1061           0 :                 else if(aType.match("OpenBezier", 21)) { eShapeType = XmlShapeTypeDrawOpenBezierShape; }
    1062           0 :                 else if(aType.match("ClosedBezier", 21)) { eShapeType = XmlShapeTypeDrawClosedBezierShape; }
    1063             : 
    1064             :                 // #i72177# FreeHand (opened and closed) now supports the types OpenFreeHandShape and
    1065             :                 // ClosedFreeHandShape respectively. Represent them as bezier shapes
    1066           0 :                 else if(aType.match("OpenFreeHand", 21)) { eShapeType = XmlShapeTypeDrawOpenBezierShape; }
    1067           0 :                 else if(aType.match("ClosedFreeHand", 21)) { eShapeType = XmlShapeTypeDrawClosedBezierShape; }
    1068             : 
    1069           0 :                 else if(aType.match("GraphicObject", 21)) { eShapeType = XmlShapeTypeDrawGraphicObjectShape; }
    1070           0 :                 else if(aType.match("Group", 21)) { eShapeType = XmlShapeTypeDrawGroupShape; }
    1071           0 :                 else if(aType.match("Text", 21)) { eShapeType = XmlShapeTypeDrawTextShape; }
    1072           0 :                 else if(aType.match("OLE2", 21))
    1073             :                 {
    1074           0 :                     eShapeType = XmlShapeTypeDrawOLE2Shape;
    1075             : 
    1076             :                     // get info about presentation shape
    1077           0 :                     uno::Reference <beans::XPropertySet> xPropSet(xShape, uno::UNO_QUERY);
    1078             : 
    1079           0 :                     if(xPropSet.is())
    1080             :                     {
    1081           0 :                         OUString sCLSID;
    1082           0 :                         if(xPropSet->getPropertyValue("CLSID") >>= sCLSID)
    1083             :                         {
    1084           0 :                             if (sCLSID.equals(mrExport.GetChartExport()->getChartCLSID()) ||
    1085           0 :                                 sCLSID.equals(OUString( SvGlobalName( SO3_RPTCH_CLASSID ).GetHexName())))
    1086             :                             {
    1087           0 :                                 eShapeType = XmlShapeTypeDrawChartShape;
    1088             :                             }
    1089           0 :                             else if (sCLSID.equals(OUString( SvGlobalName( SO3_SC_CLASSID ).GetHexName())))
    1090             :                             {
    1091           0 :                                 eShapeType = XmlShapeTypeDrawSheetShape;
    1092             :                             }
    1093             :                             else
    1094             :                             {
    1095             :                                 // general OLE2 Object
    1096             :                             }
    1097           0 :                         }
    1098           0 :                     }
    1099             :                 }
    1100           0 :                 else if(aType.match("Page", 21)) { eShapeType = XmlShapeTypeDrawPageShape; }
    1101           0 :                 else if(aType.match("Frame", 21)) { eShapeType = XmlShapeTypeDrawFrameShape; }
    1102           0 :                 else if(aType.match("Caption", 21)) { eShapeType = XmlShapeTypeDrawCaptionShape; }
    1103           0 :                 else if(aType.match("Plugin", 21)) { eShapeType = XmlShapeTypeDrawPluginShape; }
    1104           0 :                 else if(aType.match("Applet", 21)) { eShapeType = XmlShapeTypeDrawAppletShape; }
    1105           0 :                 else if(aType.match("MediaShape", 21)) { eShapeType = XmlShapeTypeDrawMediaShape; }
    1106           0 :                 else if(aType.match("TableShape", 21)) { eShapeType = XmlShapeTypeDrawTableShape; }
    1107             : 
    1108             :                 // 3D shapes
    1109           0 :                 else if(aType.match("Scene", 21 + 7)) { eShapeType = XmlShapeTypeDraw3DSceneObject; }
    1110           0 :                 else if(aType.match("Cube", 21 + 7)) { eShapeType = XmlShapeTypeDraw3DCubeObject; }
    1111           0 :                 else if(aType.match("Sphere", 21 + 7)) { eShapeType = XmlShapeTypeDraw3DSphereObject; }
    1112           0 :                 else if(aType.match("Lathe", 21 + 7)) { eShapeType = XmlShapeTypeDraw3DLatheObject; }
    1113           0 :                 else if(aType.match("Extrude", 21 + 7)) { eShapeType = XmlShapeTypeDraw3DExtrudeObject; }
    1114             :             }
    1115          50 :             else if(aType.match("presentation.", 13))
    1116             :             {
    1117             :                 // presentation shapes
    1118          50 :                 if     (aType.match("TitleText", 26)) { eShapeType = XmlShapeTypePresTitleTextShape; }
    1119          46 :                 else if(aType.match("Outliner", 26)) { eShapeType = XmlShapeTypePresOutlinerShape;  }
    1120          44 :                 else if(aType.match("Subtitle", 26)) { eShapeType = XmlShapeTypePresSubtitleShape;  }
    1121          42 :                 else if(aType.match("GraphicObject", 26)) { eShapeType = XmlShapeTypePresGraphicObjectShape;  }
    1122          42 :                 else if(aType.match("Page", 26)) { eShapeType = XmlShapeTypePresPageShape;  }
    1123          38 :                 else if(aType.match("OLE2", 26))
    1124             :                 {
    1125           0 :                     eShapeType = XmlShapeTypePresOLE2Shape;
    1126             : 
    1127             :                     // get info about presentation shape
    1128           0 :                     uno::Reference <beans::XPropertySet> xPropSet(xShape, uno::UNO_QUERY);
    1129             : 
    1130           0 :                     if(xPropSet.is()) try
    1131             :                     {
    1132           0 :                         OUString sCLSID;
    1133           0 :                         if(xPropSet->getPropertyValue("CLSID") >>= sCLSID)
    1134             :                         {
    1135           0 :                             if( sCLSID.equals(OUString( SvGlobalName( SO3_SC_CLASSID ).GetHexName())) )
    1136             :                             {
    1137           0 :                                 eShapeType = XmlShapeTypePresSheetShape;
    1138             :                             }
    1139           0 :                         }
    1140             :                     }
    1141           0 :                     catch(const uno::Exception&)
    1142             :                     {
    1143             :                         SAL_WARN( "xmloff", "XMLShapeExport::ImpCalcShapeType(), expected ole shape to have the CLSID property?" );
    1144           0 :                     }
    1145             :                 }
    1146          38 :                 else if(aType.match("Chart", 26)) { eShapeType = XmlShapeTypePresChartShape;  }
    1147          38 :                 else if(aType.match("OrgChart", 26)) { eShapeType = XmlShapeTypePresOrgChartShape;  }
    1148          38 :                 else if(aType.match("CalcShape", 26)) { eShapeType = XmlShapeTypePresSheetShape; }
    1149          38 :                 else if(aType.match("TableShape", 26)) { eShapeType = XmlShapeTypePresTableShape; }
    1150          38 :                 else if(aType.match("Notes", 26)) { eShapeType = XmlShapeTypePresNotesShape;  }
    1151          34 :                 else if(aType.match("HandoutShape", 26)) { eShapeType = XmlShapeTypeHandoutShape; }
    1152          22 :                 else if(aType.match("HeaderShape", 26)) { eShapeType = XmlShapeTypePresHeaderShape; }
    1153          18 :                 else if(aType.match("FooterShape", 26)) { eShapeType = XmlShapeTypePresFooterShape; }
    1154          12 :                 else if(aType.match("SlideNumberShape", 26)) { eShapeType = XmlShapeTypePresSlideNumberShape; }
    1155           6 :                 else if(aType.match("DateTimeShape", 26)) { eShapeType = XmlShapeTypePresDateTimeShape; }
    1156           0 :                 else if(aType.match("MediaShape", 26)) { eShapeType = XmlShapeTypePresMediaShape; }
    1157             :             }
    1158          52 :         }
    1159          52 :     }
    1160          52 : }
    1161             : 
    1162             : ///////////////////////////////////////////////////////////////////////
    1163             : 
    1164             : extern SvXMLEnumMapEntry aXML_GlueAlignment_EnumMap[];
    1165             : extern SvXMLEnumMapEntry aXML_GlueEscapeDirection_EnumMap[];
    1166             : 
    1167             : /** exports all user defined glue points */
    1168          36 : void XMLShapeExport::ImpExportGluePoints( const uno::Reference< drawing::XShape >& xShape )
    1169             : {
    1170          36 :     uno::Reference< drawing::XGluePointsSupplier > xSupplier( xShape, uno::UNO_QUERY );
    1171          36 :     if( !xSupplier.is() )
    1172           0 :         return;
    1173             : 
    1174          72 :     uno::Reference< container::XIdentifierAccess > xGluePoints( xSupplier->getGluePoints(), uno::UNO_QUERY );
    1175          36 :     if( !xGluePoints.is() )
    1176           0 :         return;
    1177             : 
    1178          36 :     drawing::GluePoint2 aGluePoint;
    1179             : 
    1180          72 :     uno::Sequence< sal_Int32 > aIdSequence( xGluePoints->getIdentifiers() );
    1181             : 
    1182          36 :     const sal_Int32 nCount = aIdSequence.getLength();
    1183         180 :     for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
    1184             :     {
    1185         144 :         const sal_Int32 nIdentifier = aIdSequence[nIndex];
    1186         144 :         if( (xGluePoints->getByIdentifier( nIdentifier ) >>= aGluePoint) && aGluePoint.IsUserDefined )
    1187             :         {
    1188             :             // export only user defined glue points
    1189             : 
    1190           0 :             const OUString sId( OUString::valueOf( nIdentifier ) );
    1191           0 :             mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_ID, sId );
    1192             : 
    1193           0 :             mrExport.GetMM100UnitConverter().convertMeasureToXML(msBuffer,
    1194           0 :                     aGluePoint.Position.X);
    1195           0 :             mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_X, msBuffer.makeStringAndClear());
    1196             : 
    1197           0 :             mrExport.GetMM100UnitConverter().convertMeasureToXML(msBuffer,
    1198           0 :                     aGluePoint.Position.Y);
    1199           0 :             mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_Y, msBuffer.makeStringAndClear());
    1200             : 
    1201           0 :             if( !aGluePoint.IsRelative )
    1202             :             {
    1203           0 :                 SvXMLUnitConverter::convertEnum( msBuffer, aGluePoint.PositionAlignment, aXML_GlueAlignment_EnumMap );
    1204           0 :                 mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_ALIGN, msBuffer.makeStringAndClear() );
    1205             :             }
    1206             : 
    1207           0 :             if( aGluePoint.Escape != drawing::EscapeDirection_SMART )
    1208             :             {
    1209           0 :                 SvXMLUnitConverter::convertEnum( msBuffer, aGluePoint.Escape, aXML_GlueEscapeDirection_EnumMap );
    1210           0 :                 mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_ESCAPE_DIRECTION, msBuffer.makeStringAndClear() );
    1211             :             }
    1212             : 
    1213           0 :             SvXMLElementExport aEventsElemt(mrExport, XML_NAMESPACE_DRAW, XML_GLUE_POINT, sal_True, sal_True);
    1214             :         }
    1215          36 :     }
    1216             : }
    1217             : 
    1218          24 : void XMLShapeExport::ExportGraphicDefaults()
    1219             : {
    1220          24 :     XMLStyleExport aStEx(mrExport, OUString(), mrExport.GetAutoStylePool().get());
    1221             : 
    1222             :     // construct PropertySetMapper
    1223          48 :     UniReference< SvXMLExportPropertyMapper > xPropertySetMapper( CreateShapePropMapper( mrExport ) );
    1224          24 :     ((XMLShapeExportPropertyMapper*)xPropertySetMapper.get())->SetAutoStyles( sal_False );
    1225             : 
    1226             :     // chain text attributes
    1227          24 :     xPropertySetMapper->ChainExportMapper(XMLTextParagraphExport::CreateParaExtPropMapper(mrExport));
    1228             : 
    1229             :     // chain special Writer/text frame default attributes
    1230          24 :     xPropertySetMapper->ChainExportMapper(XMLTextParagraphExport::CreateParaDefaultExtPropMapper(mrExport));
    1231             : 
    1232             :     // write graphic family default style
    1233          48 :     uno::Reference< lang::XMultiServiceFactory > xFact( mrExport.GetModel(), uno::UNO_QUERY );
    1234          24 :     if( xFact.is() )
    1235             :     {
    1236             :         try
    1237             :         {
    1238          24 :             uno::Reference< beans::XPropertySet > xDefaults( xFact->createInstance("com.sun.star.drawing.Defaults"), uno::UNO_QUERY );
    1239          24 :             if( xDefaults.is() )
    1240             :             {
    1241          24 :                 aStEx.exportDefaultStyle( xDefaults, OUString(XML_STYLE_FAMILY_SD_GRAPHICS_NAME), xPropertySetMapper );
    1242             : 
    1243             :                 // write graphic family styles
    1244          24 :                 aStEx.exportStyleFamily("graphics", OUString(XML_STYLE_FAMILY_SD_GRAPHICS_NAME), xPropertySetMapper, sal_False, XML_STYLE_FAMILY_SD_GRAPHICS_ID);
    1245          24 :             }
    1246             :         }
    1247           0 :         catch(const lang::ServiceNotRegisteredException&)
    1248             :         {
    1249             :         }
    1250          24 :     }
    1251          24 : }
    1252             : 
    1253          50 : void XMLShapeExport::onExport( const com::sun::star::uno::Reference < com::sun::star::drawing::XShape >& )
    1254             : {
    1255          50 : }
    1256             : 
    1257          83 : const rtl::Reference< XMLTableExport >& XMLShapeExport::GetShapeTableExport()
    1258             : {
    1259          83 :     if( !mxShapeTableExport.is() )
    1260             :     {
    1261          77 :         rtl::Reference< XMLPropertyHandlerFactory > xFactory( new XMLSdPropHdlFactory( mrExport.GetModel(), mrExport ) );
    1262         154 :         UniReference < XMLPropertySetMapper > xMapper( new XMLShapePropertySetMapper( xFactory.get() ) );
    1263          77 :         mrExport.GetTextParagraphExport(); // get or create text paragraph export
    1264         154 :         rtl::Reference< SvXMLExportPropertyMapper > xPropertySetMapper( new XMLShapeExportPropertyMapper( xMapper, mrExport ) );
    1265         154 :         mxShapeTableExport = new XMLTableExport( mrExport, xPropertySetMapper, xFactory );
    1266             :     }
    1267             : 
    1268          83 :     return mxShapeTableExport;
    1269             : }
    1270             : 
    1271             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10