LCOV - code coverage report
Current view: top level - oox/source/drawingml - shape.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 616 742 83.0 %
Date: 2014-11-03 Functions: 33 34 97.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 "oox/drawingml/shape.hxx"
      21             : #include "drawingml/customshapeproperties.hxx"
      22             : #include "oox/drawingml/theme.hxx"
      23             : #include "oox/drawingml/fillproperties.hxx"
      24             : #include "drawingml/graphicproperties.hxx"
      25             : #include <drawingml/scene3dcontext.hxx>
      26             : #include "oox/drawingml/lineproperties.hxx"
      27             : #include "effectproperties.hxx"
      28             : #include "oox/drawingml/shapepropertymap.hxx"
      29             : #include "drawingml/textbody.hxx"
      30             : #include <drawingml/ThemeOverrideFragmentHandler.hxx>
      31             : #include "drawingml/table/tableproperties.hxx"
      32             : #include "oox/drawingml/chart/chartconverter.hxx"
      33             : #include "drawingml/chart/chartspacefragment.hxx"
      34             : #include "drawingml/chart/chartspacemodel.hxx"
      35             : #include "oox/ppt/pptimport.hxx"
      36             : #include "oox/vml/vmldrawing.hxx"
      37             : #include "oox/vml/vmlshape.hxx"
      38             : #include "oox/vml/vmlshapecontainer.hxx"
      39             : #include "oox/core/xmlfilterbase.hxx"
      40             : #include "oox/helper/graphichelper.hxx"
      41             : #include "oox/helper/propertyset.hxx"
      42             : #include "oox/helper/modelobjecthelper.hxx"
      43             : 
      44             : #include <tools/gen.hxx>
      45             : #include <tools/mapunit.hxx>
      46             : #include <editeng/unoprnms.hxx>
      47             : #include <com/sun/star/awt/Size.hpp>
      48             : #include <com/sun/star/graphic/XGraphic.hpp>
      49             : #include <com/sun/star/container/XNamed.hpp>
      50             : #include <com/sun/star/container/XNameContainer.hpp>
      51             : #include <com/sun/star/beans/XMultiPropertySet.hpp>
      52             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      53             : #include <com/sun/star/xml/AttributeData.hpp>
      54             : #include <com/sun/star/xml/sax/XFastSAXSerializable.hpp>
      55             : #include <com/sun/star/drawing/HomogenMatrix3.hpp>
      56             : #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
      57             : #include <com/sun/star/drawing/GraphicExportFilter.hpp>
      58             : #include <com/sun/star/text/XText.hpp>
      59             : #include <com/sun/star/table/BorderLine2.hpp>
      60             : #include <com/sun/star/table/ShadowFormat.hpp>
      61             : #include <com/sun/star/chart2/XChartDocument.hpp>
      62             : #include <com/sun/star/style/ParagraphAdjust.hpp>
      63             : #include <com/sun/star/io/XOutputStream.hpp>
      64             : 
      65             : #include <basegfx/point/b2dpoint.hxx>
      66             : #include <basegfx/polygon/b2dpolygon.hxx>
      67             : #include <basegfx/matrix/b2dhommatrix.hxx>
      68             : #include <com/sun/star/document/XActionLockable.hpp>
      69             : #include <com/sun/star/chart2/data/XDataReceiver.hpp>
      70             : #include <svl/outstrm.hxx>
      71             : #include <svx/svdtrans.hxx>
      72             : #include <unotools/streamwrap.hxx>
      73             : #include <unotools/fltrcfg.hxx>
      74             : #include <vcl/graph.hxx>
      75             : #include <vcl/graphicfilter.hxx>
      76             : #include <vcl/svapp.hxx>
      77             : 
      78             : #include <vcl/wmf.hxx>
      79             : 
      80             : using namespace ::oox::core;
      81             : using namespace ::com::sun::star;
      82             : using namespace ::com::sun::star::uno;
      83             : using namespace ::com::sun::star::beans;
      84             : using namespace ::com::sun::star::frame;
      85             : using namespace ::com::sun::star::text;
      86             : using namespace ::com::sun::star::drawing;
      87             : using namespace ::com::sun::star::style;
      88             : 
      89             : namespace oox { namespace drawingml {
      90             : 
      91             : #define PUT_PROP( aProperties, nPos, sPropName, aPropValue ) \
      92             :     aProperties[nPos].Name = sPropName; \
      93             :     aProperties[nPos].Value = Any( aPropValue );
      94             : 
      95       22440 : Shape::Shape( const sal_Char* pServiceName, bool bDefaultHeight )
      96             : : mbIsChild( false )
      97       22440 : , mpLinePropertiesPtr( new LineProperties )
      98       22440 : , mpFillPropertiesPtr( new FillProperties )
      99       22440 : , mpGraphicPropertiesPtr( new GraphicProperties )
     100       22440 : , mpCustomShapePropertiesPtr( new CustomShapeProperties )
     101       22440 : , mp3DPropertiesPtr( new Shape3DProperties )
     102       22440 : , mpEffectPropertiesPtr( new EffectProperties )
     103       22440 : , mpMasterTextListStyle( new TextListStyle )
     104             : , mnSubType( 0 )
     105             : , meFrameType( FRAMETYPE_GENERIC )
     106             : , mnRotation( 0 )
     107             : , mbFlipH( false )
     108             : , mbFlipV( false )
     109             : , mbHidden( false )
     110             : , mbHiddenMasterShape( false )
     111             : , mbLockedCanvas( false )
     112             : , mbWps( false )
     113             : , mbTextBox( false )
     114             : , mbHasLinkedTxbx( false )
     115      179520 : , maDiagramDoms( 0 )
     116             : {
     117       22440 :     if ( pServiceName )
     118        7120 :         msServiceName = OUString::createFromAscii( pServiceName );
     119       22440 :     setDefaults(bDefaultHeight);
     120       22440 : }
     121             : 
     122         346 : Shape::Shape( const ShapePtr& pSourceShape )
     123             : : maChildren()
     124         346 : , mbIsChild( pSourceShape->mbIsChild )
     125         346 : , mpTextBody(pSourceShape->mpTextBody)
     126         346 : , mpLinePropertiesPtr( pSourceShape->mpLinePropertiesPtr )
     127         346 : , mpFillPropertiesPtr( pSourceShape->mpFillPropertiesPtr )
     128         346 : , mpGraphicPropertiesPtr( pSourceShape->mpGraphicPropertiesPtr )
     129         346 : , mpCustomShapePropertiesPtr( pSourceShape->mpCustomShapePropertiesPtr )
     130         346 : , mpTablePropertiesPtr( pSourceShape->mpTablePropertiesPtr )
     131         346 : , mp3DPropertiesPtr( pSourceShape->mp3DPropertiesPtr )
     132         346 : , mpEffectPropertiesPtr (pSourceShape->mpEffectPropertiesPtr)
     133         346 : , maShapeProperties( pSourceShape->maShapeProperties )
     134         346 : , mpMasterTextListStyle( pSourceShape->mpMasterTextListStyle )
     135             : , mxShape()
     136         346 : , msServiceName( pSourceShape->msServiceName )
     137         346 : , msName( pSourceShape->msName )
     138         346 : , msId( pSourceShape->msId )
     139         346 : , mnSubType( pSourceShape->mnSubType )
     140         346 : , moSubTypeIndex( pSourceShape->moSubTypeIndex )
     141         346 : , maShapeStyleRefs( pSourceShape->maShapeStyleRefs )
     142         346 : , maSize( pSourceShape->maSize )
     143         346 : , maPosition( pSourceShape->maPosition )
     144         346 : , meFrameType( pSourceShape->meFrameType )
     145         346 : , mnRotation( pSourceShape->mnRotation )
     146         346 : , mbFlipH( pSourceShape->mbFlipH )
     147         346 : , mbFlipV( pSourceShape->mbFlipV )
     148         346 : , mbHidden( pSourceShape->mbHidden )
     149         346 : , mbHiddenMasterShape( pSourceShape->mbHiddenMasterShape )
     150         346 : , mbLockedCanvas( pSourceShape->mbLockedCanvas )
     151         346 : , mbWps( pSourceShape->mbWps )
     152         346 : , mbTextBox( pSourceShape->mbTextBox )
     153             : , maLinkedTxbxAttr()
     154             : , mbHasLinkedTxbx(false)
     155       10034 : , maDiagramDoms( pSourceShape->maDiagramDoms )
     156         346 : {}
     157             : 
     158       32726 : Shape::~Shape()
     159             : {
     160       32726 : }
     161             : 
     162           6 : table::TablePropertiesPtr Shape::getTableProperties()
     163             : {
     164           6 :     if ( !mpTablePropertiesPtr.get() )
     165           6 :         mpTablePropertiesPtr.reset( new table::TableProperties() );
     166           6 :     return mpTablePropertiesPtr;
     167             : }
     168             : 
     169       22440 : void Shape::setDefaults(bool bHeight)
     170             : {
     171       22440 :     maDefaultShapeProperties.setProperty(PROP_TextAutoGrowHeight, false);
     172       22440 :     maDefaultShapeProperties.setProperty(PROP_TextWordWrap, true);
     173       22440 :     maDefaultShapeProperties.setProperty(PROP_TextLeftDistance, static_cast< sal_Int32 >( 250 ));
     174       22440 :     maDefaultShapeProperties.setProperty(PROP_TextUpperDistance, static_cast< sal_Int32 >( 125 ));
     175       22440 :     maDefaultShapeProperties.setProperty(PROP_TextRightDistance, static_cast< sal_Int32 >( 250 ));
     176       22440 :     maDefaultShapeProperties.setProperty(PROP_TextLowerDistance, static_cast< sal_Int32 >( 125 ));
     177       22440 :     if (bHeight)
     178       21750 :         maDefaultShapeProperties.setProperty(PROP_CharHeight, static_cast< float >( 18.0 ));
     179       22440 :     maDefaultShapeProperties.setProperty(PROP_TextVerticalAdjust, TextVerticalAdjust_TOP);
     180       22440 :     maDefaultShapeProperties.setProperty(PROP_ParaAdjust, static_cast< sal_Int16 >( ParagraphAdjust_LEFT )); // check for RTL?
     181       22440 : }
     182             : 
     183           4 : ::oox::vml::OleObjectInfo& Shape::setOleObjectType()
     184             : {
     185             :     OSL_ENSURE( meFrameType == FRAMETYPE_GENERIC, "Shape::setOleObjectType - multiple frame types" );
     186           4 :     meFrameType = FRAMETYPE_OLEOBJECT;
     187           4 :     mxOleObjectInfo.reset( new ::oox::vml::OleObjectInfo( true ) );
     188           4 :     return *mxOleObjectInfo;
     189             : }
     190             : 
     191         232 : ChartShapeInfo& Shape::setChartType( bool bEmbedShapes )
     192             : {
     193             :     OSL_ENSURE( meFrameType == FRAMETYPE_GENERIC, "Shape::setChartType - multiple frame types" );
     194         232 :     meFrameType = FRAMETYPE_CHART;
     195         232 :     msServiceName = "com.sun.star.drawing.OLE2Shape";
     196         232 :     mxChartShapeInfo.reset( new ChartShapeInfo( bEmbedShapes ) );
     197         232 :     return *mxChartShapeInfo;
     198             : }
     199             : 
     200         140 : void Shape::setDiagramType()
     201             : {
     202             :     OSL_ENSURE( meFrameType == FRAMETYPE_GENERIC, "Shape::setDiagramType - multiple frame types" );
     203         140 :     meFrameType = FRAMETYPE_DIAGRAM;
     204         140 :     msServiceName = "com.sun.star.drawing.GroupShape";
     205         140 :     mnSubType = 0;
     206         140 : }
     207             : 
     208           6 : void Shape::setTableType()
     209             : {
     210             :     OSL_ENSURE( meFrameType == FRAMETYPE_GENERIC, "Shape::setTableType - multiple frame types" );
     211           6 :     meFrameType = FRAMETYPE_TABLE;
     212           6 :     msServiceName = "com.sun.star.drawing.TableShape";
     213           6 :     mnSubType = 0;
     214           6 : }
     215             : 
     216         172 : void Shape::setServiceName( const sal_Char* pServiceName )
     217             : {
     218         172 :     if ( pServiceName )
     219         172 :         msServiceName = OUString::createFromAscii( pServiceName );
     220         172 : }
     221             : 
     222       18576 : const ShapeStyleRef* Shape::getShapeStyleRef( sal_Int32 nRefType ) const
     223             : {
     224       18576 :     ShapeStyleRefMap::const_iterator aIt = maShapeStyleRefs.find( nRefType );
     225       18576 :     return (aIt == maShapeStyleRefs.end()) ? 0 : &aIt->second;
     226             : }
     227             : 
     228        4314 : void Shape::addShape(
     229             :         ::oox::core::XmlFilterBase& rFilterBase,
     230             :         const Theme* pTheme,
     231             :         const Reference< XShapes >& rxShapes,
     232             :         const basegfx::B2DHomMatrix& aTransformation,
     233             :         FillProperties& rShapeOrParentShapeFillProps,
     234             :         const awt::Rectangle* pShapeRect,
     235             :         ShapeIdMap* pShapeMap )
     236             : {
     237             :     SAL_INFO("oox.drawingml", OSL_THIS_FUNC << " id: " << msId);
     238             : 
     239             :     try
     240             :     {
     241        4314 :         OUString sServiceName( msServiceName );
     242        4314 :         if( !sServiceName.isEmpty() )
     243             :         {
     244        4314 :             basegfx::B2DHomMatrix aMatrix( aTransformation );
     245        8628 :             Reference< XShape > xShape( createAndInsert( rFilterBase, sServiceName, pTheme, rxShapes, pShapeRect, false, false, aMatrix, rShapeOrParentShapeFillProps ) );
     246             : 
     247        4314 :             if( pShapeMap && !msId.isEmpty() )
     248             :             {
     249         250 :                 (*pShapeMap)[ msId ] = shared_from_this();
     250             :             }
     251             : 
     252             :             // if this is a group shape, we have to add also each child shape
     253        8628 :             Reference< XShapes > xShapes( xShape, UNO_QUERY );
     254        4314 :             if ( xShapes.is() )
     255         422 :                 addChildren( rFilterBase, *this, pTheme, xShapes, pShapeRect ? *pShapeRect : awt::Rectangle( maPosition.X, maPosition.Y, maSize.Width, maSize.Height ), pShapeMap, aMatrix );
     256             : 
     257        4314 :             if( meFrameType == FRAMETYPE_DIAGRAM )
     258             :             {
     259          72 :                 if( !SvtFilterOptions::Get().IsSmartArt2Shape() )
     260          68 :                     keepDiagramCompatibilityInfo( rFilterBase );
     261        4314 :             }
     262        4314 :         }
     263             :     }
     264           0 :     catch( const Exception& e )
     265             :     {
     266             :         SAL_WARN( "oox.drawingml", OSL_THIS_FUNC << "Exception: " << e.Message );
     267             :     }
     268        4314 : }
     269             : 
     270          20 : void Shape::setLockedCanvas(bool bLockedCanvas)
     271             : {
     272          20 :     mbLockedCanvas = bLockedCanvas;
     273          20 : }
     274             : 
     275        2876 : void Shape::setWps(bool bWps)
     276             : {
     277        2876 :     mbWps = bWps;
     278        2876 : }
     279             : 
     280         804 : void Shape::setTextBox(bool bTextBox)
     281             : {
     282         804 :     mbTextBox = bTextBox;
     283         804 : }
     284             : 
     285         438 : void Shape::applyShapeReference( const Shape& rReferencedShape, bool bUseText )
     286             : {
     287             :     SAL_INFO("oox", OSL_THIS_FUNC << "apply shape reference: " << rReferencedShape.msId << " to shape id: " << msId);
     288             : 
     289         438 :     if ( rReferencedShape.mpTextBody.get() && bUseText )
     290         428 :         mpTextBody = TextBodyPtr( new TextBody( *rReferencedShape.mpTextBody.get() ) );
     291             :     else
     292          10 :         mpTextBody.reset();
     293         438 :     maShapeProperties = rReferencedShape.maShapeProperties;
     294         438 :     mpLinePropertiesPtr = LinePropertiesPtr( new LineProperties( *rReferencedShape.mpLinePropertiesPtr.get() ) );
     295         438 :     mpFillPropertiesPtr = FillPropertiesPtr( new FillProperties( *rReferencedShape.mpFillPropertiesPtr.get() ) );
     296         438 :     mpCustomShapePropertiesPtr = CustomShapePropertiesPtr( new CustomShapeProperties( *rReferencedShape.mpCustomShapePropertiesPtr.get() ) );
     297         438 :     mpTablePropertiesPtr = table::TablePropertiesPtr( rReferencedShape.mpTablePropertiesPtr.get() ? new table::TableProperties( *rReferencedShape.mpTablePropertiesPtr.get() ) : NULL );
     298         438 :     mpEffectPropertiesPtr = EffectPropertiesPtr( new EffectProperties( *rReferencedShape.mpEffectPropertiesPtr.get() ) );
     299         438 :     mpMasterTextListStyle = TextListStylePtr( new TextListStyle( *rReferencedShape.mpMasterTextListStyle.get() ) );
     300         438 :     maShapeStyleRefs = rReferencedShape.maShapeStyleRefs;
     301         438 :     maSize = rReferencedShape.maSize;
     302         438 :     maPosition = rReferencedShape.maPosition;
     303         438 :     mnRotation = rReferencedShape.mnRotation;
     304         438 :     mbFlipH = rReferencedShape.mbFlipH;
     305         438 :     mbFlipV = rReferencedShape.mbFlipV;
     306         438 :     mbHidden = rReferencedShape.mbHidden;
     307         438 : }
     308             : 
     309           0 : void Shape::addChildren( ::oox::core::XmlFilterBase& rFilterBase,
     310             :                          const Theme* pTheme,
     311             :                          const Reference< XShapes >& rxShapes,
     312             :                          basegfx::B2DHomMatrix& aTransformation,
     313             :                          const awt::Rectangle* pShapeRect,
     314             :                          ShapeIdMap* pShapeMap )
     315             : {
     316             :     addChildren(rFilterBase, *this, pTheme, rxShapes,
     317             :                 pShapeRect ?
     318             :                  *pShapeRect :
     319             :                  awt::Rectangle( maPosition.X, maPosition.Y, maSize.Width, maSize.Height ),
     320           0 :                 pShapeMap, aTransformation);
     321           0 : }
     322             : 
     323             : struct ActionLockGuard
     324             : {
     325        5406 :     explicit ActionLockGuard(Reference<drawing::XShape> const& xShape)
     326        5406 :         : m_xLockable(xShape, UNO_QUERY)
     327             :     {
     328        5406 :         if (m_xLockable.is()) {
     329        5406 :             m_xLockable->addActionLock();
     330             :         }
     331        5406 :     }
     332        5406 :     ~ActionLockGuard()
     333        5406 :     {
     334        5406 :         if (m_xLockable.is()) {
     335        5406 :             m_xLockable->removeActionLock();
     336             :         }
     337        5406 :     }
     338             : private:
     339             :     Reference<document::XActionLockable> m_xLockable;
     340             : };
     341             : 
     342             : // for group shapes, the following method is also adding each child
     343         458 : void Shape::addChildren(
     344             :         XmlFilterBase& rFilterBase,
     345             :         Shape& rMaster,
     346             :         const Theme* pTheme,
     347             :         const Reference< XShapes >& rxShapes,
     348             :         const awt::Rectangle&,
     349             :         ShapeIdMap* pShapeMap,
     350             :         const basegfx::B2DHomMatrix& aTransformation )
     351             : {
     352         458 :     basegfx::B2DHomMatrix aChildTransformation;
     353             : 
     354         458 :     aChildTransformation.translate(-maChPosition.X, -maChPosition.Y);
     355         458 :     aChildTransformation.scale(1/(maChSize.Width ? maChSize.Width : 1.0), 1/(maChSize.Height ? maChSize.Height : 1.0));
     356             : 
     357             :     // Child position and size is typically non-zero, but it's allowed to have
     358             :     // it like that, and in that case Word ignores the parent transformation
     359             :     // (excluding translate component).
     360         458 :     if (!mbWps || maChPosition.X || maChPosition.Y || maChSize.Width || maChSize.Height)
     361             :     {
     362         388 :         aChildTransformation *= aTransformation;
     363             :     }
     364             :     else
     365             :     {
     366         140 :         basegfx::B2DVector aScale, aTranslate;
     367             :         double fRotate, fShearX;
     368          70 :         aTransformation.decompose(aScale, aTranslate, fRotate, fShearX);
     369         140 :         aChildTransformation.translate(aTranslate.getX(), aTranslate.getY());
     370             :     }
     371             : 
     372             :     SAL_INFO("oox.drawingml", OSL_THIS_FUNC << "parent matrix:\n"
     373             :              << aChildTransformation.get(0, 0) << " "
     374             :              << aChildTransformation.get(0, 1) << " "
     375             :              << aChildTransformation.get(0, 2) << "\n"
     376             :              << aChildTransformation.get(1, 0) << " "
     377             :              << aChildTransformation.get(1, 1) << " "
     378             :              << aChildTransformation.get(1, 2) << "\n"
     379             :              << aChildTransformation.get(2, 0) << " "
     380             :              << aChildTransformation.get(2, 1) << " "
     381             :              << aChildTransformation.get(2, 2));
     382             : 
     383         458 :     std::vector< ShapePtr >::iterator aIter( rMaster.maChildren.begin() );
     384        2700 :     while( aIter != rMaster.maChildren.end() ) {
     385        1784 :         (*aIter)->setMasterTextListStyle( mpMasterTextListStyle );
     386        1784 :         (*aIter++)->addShape( rFilterBase, pTheme, rxShapes, aChildTransformation, getFillProperties(), NULL, pShapeMap );
     387         458 :     }
     388         458 : }
     389             : 
     390        5406 : Reference< XShape > Shape::createAndInsert(
     391             :         ::oox::core::XmlFilterBase& rFilterBase,
     392             :         const OUString& rServiceName,
     393             :         const Theme* pTheme,
     394             :         const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
     395             :         const awt::Rectangle* /* pShapeRect */,
     396             :         bool bClearText,
     397             :         bool bDoNotInsertEmptyTextBody,
     398             :         basegfx::B2DHomMatrix& aParentTransformation,
     399             :         FillProperties& rShapeOrParentShapeFillProps )
     400             : {
     401        5406 :     bool bIsEmbMedia = false;
     402             :     SAL_INFO("oox.drawingml", OSL_THIS_FUNC << " id: " << msId);
     403             : 
     404        5406 :     awt::Rectangle aShapeRectHmm( maPosition.X / EMU_PER_HMM, maPosition.Y / EMU_PER_HMM, maSize.Width / EMU_PER_HMM, maSize.Height / EMU_PER_HMM );
     405             : 
     406        5406 :     OUString aServiceName;
     407       11328 :     if( rServiceName == "com.sun.star.drawing.GraphicObjectShape" &&
     408        5922 :         mpGraphicPropertiesPtr && !mpGraphicPropertiesPtr->m_sMediaPackageURL.isEmpty())
     409             :     {
     410           4 :         aServiceName = finalizeServiceName( rFilterBase, "com.sun.star.presentation.MediaShape", aShapeRectHmm );
     411           4 :         bIsEmbMedia = true;
     412             :     }
     413             :     else
     414             :     {
     415        5402 :         aServiceName = finalizeServiceName( rFilterBase, rServiceName, aShapeRectHmm );
     416             :     }
     417        7132 :     bool bIsCustomShape = ( aServiceName == "com.sun.star.drawing.CustomShape" ||
     418        7132 :                             aServiceName == "com.sun.star.drawing.ConnectorShape" );
     419        7176 :     bool bUseRotationTransform = ( !mbWps ||
     420        3502 :             aServiceName == "com.sun.star.drawing.LineShape" ||
     421        3300 :             aServiceName == "com.sun.star.drawing.GroupShape" ||
     422        6956 :             mbFlipH ||
     423        5406 :             mbFlipV );
     424             : 
     425       10812 :     basegfx::B2DHomMatrix aTransformation;
     426             : 
     427        5406 :     if( maSize.Width != 1 || maSize.Height != 1)
     428             :     {
     429             :         // take care there are no zeros used by error
     430             :         aTransformation.scale(
     431             :             maSize.Width ? maSize.Width : 1.0,
     432        5406 :             maSize.Height ? maSize.Height : 1.0 );
     433             :     }
     434             : 
     435        5406 :     if( mbFlipH || mbFlipV || mnRotation != 0)
     436             :     {
     437             :         // calculate object's center
     438         324 :         basegfx::B2DPoint aCenter(0.5, 0.5);
     439         324 :         aCenter *= aTransformation;
     440             : 
     441             :         // center object at origin
     442         324 :         aTransformation.translate( -aCenter.getX(), -aCenter.getY() );
     443             : 
     444         324 :         if( !bIsCustomShape && ( mbFlipH || mbFlipV ) )
     445             :         {
     446             :             // mirror around object's center
     447          20 :             aTransformation.scale( mbFlipH ? -1.0 : 1.0, mbFlipV ? -1.0 : 1.0 );
     448             :         }
     449             : 
     450         324 :         if( bUseRotationTransform && mnRotation != 0 )
     451             :         {
     452             :             // rotate around object's center
     453         106 :             aTransformation.rotate( F_PI180 * ( (double)mnRotation / 60000.0 ) );
     454             :         }
     455             : 
     456             :         // move object back from center
     457         324 :         aTransformation.translate( aCenter.getX(), aCenter.getY() );
     458             :     }
     459             : 
     460        5406 :     if( maPosition.X != 0 || maPosition.Y != 0)
     461             :     {
     462             :         // if global position is used, add it to transformation
     463        4114 :         if (mbWps && aParentTransformation.isIdentity())
     464        1486 :             aTransformation.translate( maPosition.X * EMU_PER_HMM, maPosition.Y * EMU_PER_HMM);
     465             :         else
     466        2628 :             aTransformation.translate( maPosition.X, maPosition.Y );
     467             :     }
     468             : 
     469        5406 :     aTransformation = aParentTransformation*aTransformation;
     470        5406 :     aParentTransformation = aTransformation;
     471        5406 :     aTransformation.scale(1/double(EMU_PER_HMM), 1/double(EMU_PER_HMM));
     472             : 
     473             :     // special for lineshape
     474        5406 :     if ( aServiceName == "com.sun.star.drawing.LineShape" )
     475             :     {
     476          76 :         ::basegfx::B2DPolygon aPoly;
     477          76 :         aPoly.insert( 0, ::basegfx::B2DPoint( 0, 0 ) );
     478          76 :         aPoly.insert( 1, ::basegfx::B2DPoint( maSize.Width ? 1 : 0, maSize.Height ? 1 : 0 ) );
     479          76 :         aPoly.transform( aTransformation );
     480             : 
     481             :         // now creating the corresponding PolyPolygon
     482          76 :         sal_Int32 i, nNumPoints = aPoly.count();
     483         152 :         uno::Sequence< awt::Point > aPointSequence( nNumPoints );
     484          76 :         awt::Point* pPoints = aPointSequence.getArray();
     485         228 :         for( i = 0; i < nNumPoints; ++i )
     486             :         {
     487         152 :             const ::basegfx::B2DPoint aPoint( aPoly.getB2DPoint( i ) );
     488         152 :             pPoints[ i ] = awt::Point( static_cast< sal_Int32 >( aPoint.getX() ), static_cast< sal_Int32 >( aPoint.getY() ) );
     489         152 :         }
     490         152 :         uno::Sequence< uno::Sequence< awt::Point > > aPolyPolySequence( 1 );
     491          76 :         aPolyPolySequence.getArray()[ 0 ] = aPointSequence;
     492             : 
     493         152 :         maShapeProperties.setProperty(PROP_PolyPolygon, aPolyPolySequence);
     494             :     }
     495        5330 :     else if ( aServiceName == "com.sun.star.drawing.ConnectorShape" )
     496             :     {
     497           0 :         ::basegfx::B2DPolygon aPoly;
     498           0 :         aPoly.insert( 0, ::basegfx::B2DPoint( 0, 0 ) );
     499           0 :         aPoly.insert( 1, ::basegfx::B2DPoint( maSize.Width ? 1 : 0, maSize.Height ? 1 : 0 ) );
     500           0 :         aPoly.transform( aTransformation );
     501             : 
     502           0 :         basegfx::B2DPoint aStartPosition( aPoly.getB2DPoint( 0 ) );
     503           0 :         basegfx::B2DPoint aEndPosition( aPoly.getB2DPoint( 1 ) );
     504           0 :         awt::Point aAWTStartPosition( static_cast< sal_Int32 >( aStartPosition.getX() ), static_cast< sal_Int32 >( aStartPosition.getY() ) );
     505           0 :         awt::Point aAWTEndPosition( static_cast< sal_Int32 >( aEndPosition.getX() ), static_cast< sal_Int32 >( aEndPosition.getY() ) );
     506             : 
     507           0 :         maShapeProperties.setProperty(PROP_StartPosition, aAWTStartPosition);
     508           0 :         maShapeProperties.setProperty(PROP_EndPosition, aAWTEndPosition);
     509             :     }
     510             :     else
     511             :     {
     512             :         // now set transformation for this object
     513        5330 :         HomogenMatrix3 aMatrix;
     514             : 
     515        5330 :         aMatrix.Line1.Column1 = aTransformation.get(0,0);
     516        5330 :         aMatrix.Line1.Column2 = aTransformation.get(0,1);
     517        5330 :         aMatrix.Line1.Column3 = aTransformation.get(0,2);
     518             : 
     519        5330 :         aMatrix.Line2.Column1 = aTransformation.get(1,0);
     520        5330 :         aMatrix.Line2.Column2 = aTransformation.get(1,1);
     521        5330 :         aMatrix.Line2.Column3 = aTransformation.get(1,2);
     522             : 
     523        5330 :         aMatrix.Line3.Column1 = aTransformation.get(2,0);
     524        5330 :         aMatrix.Line3.Column2 = aTransformation.get(2,1);
     525        5330 :         aMatrix.Line3.Column3 = aTransformation.get(2,2);
     526             : 
     527        5330 :         maShapeProperties.setProperty(PROP_Transformation, aMatrix);
     528             :     }
     529             : 
     530       10812 :     Reference< lang::XMultiServiceFactory > xServiceFact( rFilterBase.getModel(), UNO_QUERY_THROW );
     531        5406 :     if ( !mxShape.is() )
     532        5406 :         mxShape = Reference< drawing::XShape >( xServiceFact->createInstance( aServiceName ), UNO_QUERY_THROW );
     533             : 
     534       10812 :     Reference< XPropertySet > xSet( mxShape, UNO_QUERY );
     535        5406 :     if( mxShape.is() && xSet.is() )
     536             :     {
     537        5406 :         if( !msName.isEmpty() )
     538             :         {
     539        1820 :             Reference< container::XNamed > xNamed( mxShape, UNO_QUERY );
     540        1820 :             if( xNamed.is() )
     541        1820 :                 xNamed->setName( msName );
     542             :         }
     543        5406 :         if (aServiceName != "com.sun.star.text.TextFrame")
     544        5406 :             rxShapes->add( mxShape );
     545             : 
     546        5406 :         if ( mbHidden || mbHiddenMasterShape )
     547             :         {
     548             :             SAL_INFO("oox.drawingml", OSL_THIS_FUNC << "invisible shape with id: " << msId);
     549           4 :             const OUString sVisible( "Visible" );
     550           4 :             xSet->setPropertyValue( sVisible, Any( sal_False ) );
     551             :         }
     552             : 
     553        5406 :         ActionLockGuard const alg(mxShape);
     554             : 
     555             :         // sj: removing default text of placeholder objects such as SlideNumberShape or HeaderShape
     556        5406 :         if ( bClearText )
     557             :         {
     558         386 :             uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY );
     559         386 :             if ( xText.is() )
     560             :             {
     561         386 :                 OUString aEmpty;
     562         386 :                 xText->setString( aEmpty );
     563         386 :             }
     564             :         }
     565             : 
     566        5406 :         const GraphicHelper& rGraphicHelper = rFilterBase.getGraphicHelper();
     567             : 
     568       10812 :         LineProperties aLineProperties;
     569        5406 :         aLineProperties.maLineFill.moFillType = XML_noFill;
     570        5406 :         sal_Int32 nLinePhClr = -1;
     571       10812 :         FillProperties aFillProperties;
     572        5406 :         aFillProperties.moFillType = XML_noFill;
     573        5406 :         sal_Int32 nFillPhClr = -1;
     574       10812 :         EffectProperties aEffectProperties;
     575             :         // TODO: use ph color when applying effect properties
     576             :         //sal_Int32 nEffectPhClr = -1;
     577             : 
     578        5406 :         if( pTheme )
     579             :         {
     580        5372 :             if( const ShapeStyleRef* pLineRef = getShapeStyleRef( XML_lnRef ) )
     581             :             {
     582        1974 :                 if( const LineProperties* pLineProps = pTheme->getLineStyle( pLineRef->mnThemedIdx ) )
     583        1094 :                     aLineProperties.assignUsed( *pLineProps );
     584        1974 :                 nLinePhClr = pLineRef->maPhClr.getColor( rGraphicHelper );
     585             : 
     586             :                 // Store style-related properties to InteropGrabBag to be able to export them back
     587        1974 :                 Sequence< PropertyValue > aProperties( 7 );
     588        1974 :                 PUT_PROP( aProperties, 0, "SchemeClr",      pLineRef->maPhClr.getSchemeName() );
     589        1974 :                 PUT_PROP( aProperties, 1, "Idx",            pLineRef->mnThemedIdx );
     590        1974 :                 PUT_PROP( aProperties, 2, "Color",          nLinePhClr );
     591        1974 :                 PUT_PROP( aProperties, 3, "LineStyle",      aLineProperties.getLineStyle() );
     592        1974 :                 PUT_PROP( aProperties, 4, "LineJoint",      aLineProperties.getLineJoint() );
     593        1974 :                 PUT_PROP( aProperties, 5, "LineWidth",      aLineProperties.getLineWidth() );
     594        1974 :                 PUT_PROP( aProperties, 6, "Transformations", pLineRef->maPhClr.getTransformations() );
     595        1974 :                 putPropertyToGrabBag( "StyleLnRef", Any( aProperties ) );
     596             :             }
     597        5372 :             if( const ShapeStyleRef* pFillRef = getShapeStyleRef( XML_fillRef ) )
     598             :             {
     599        1974 :                 if( const FillProperties* pFillProps = pTheme->getFillStyle( pFillRef->mnThemedIdx ) )
     600        1044 :                     aFillProperties.assignUsed( *pFillProps );
     601        1974 :                 nFillPhClr = pFillRef->maPhClr.getColor( rGraphicHelper );
     602             : 
     603        1974 :                 OUString sColorScheme = pFillRef->maPhClr.getSchemeName();
     604        1974 :                 if( !sColorScheme.isEmpty() )
     605             :                 {
     606         728 :                     Sequence< PropertyValue > aProperties(4);
     607         728 :                     PUT_PROP( aProperties, 0, "SchemeClr",      sColorScheme );
     608         728 :                     PUT_PROP( aProperties, 1, "Idx",            pFillRef->mnThemedIdx );
     609         728 :                     PUT_PROP( aProperties, 2, "Color",          nFillPhClr );
     610         728 :                     PUT_PROP( aProperties, 3, "Transformations", pFillRef->maPhClr.getTransformations() );
     611             : 
     612         728 :                     putPropertyToGrabBag( "StyleFillRef", Any( aProperties ) );
     613        1974 :                 }
     614             :             }
     615        5372 :             if( const ShapeStyleRef* pEffectRef = getShapeStyleRef( XML_effectRef ) )
     616             :             {
     617        1974 :                 if( const EffectProperties* pEffectProps = pTheme->getEffectStyle( pEffectRef->mnThemedIdx ) )
     618         162 :                     aEffectProperties.assignUsed( *pEffectProps );
     619             :                 // TODO: use ph color when applying effect properties
     620             :                 // nEffectPhClr = pEffectRef->maPhClr.getColor( rGraphicHelper );
     621             : 
     622             :                 // Store style-related properties to InteropGrabBag to be able to export them back
     623        1974 :                 Sequence< PropertyValue > aProperties( 3 );
     624        1974 :                 PUT_PROP( aProperties, 0, "SchemeClr",      pEffectRef->maPhClr.getSchemeName() );
     625        1974 :                 PUT_PROP( aProperties, 1, "Idx",            pEffectRef->mnThemedIdx );
     626        1974 :                 PUT_PROP( aProperties, 2, "Transformations", pEffectRef->maPhClr.getTransformations() );
     627        1974 :                 putPropertyToGrabBag( "StyleEffectRef", Any( aProperties ) );
     628             :             }
     629             :         }
     630             : 
     631        5406 :         aLineProperties.assignUsed( getLineProperties() );
     632             : 
     633             :         // group fill inherits from parent
     634        5406 :         if ( getFillProperties().moFillType.has() && getFillProperties().moFillType.get() == XML_grpFill )
     635           0 :             getFillProperties().assignUsed( rShapeOrParentShapeFillProps );
     636        5406 :         aFillProperties.assignUsed( getFillProperties() );
     637        5406 :         aEffectProperties.assignUsed ( getEffectProperties() );
     638             : 
     639       10812 :         ShapePropertyMap aShapeProps( rFilterBase.getModelObjectHelper() );
     640             : 
     641             :         // add properties from textbody to shape properties
     642        5406 :         if( mpTextBody.get() )
     643             :         {
     644        1792 :             mpTextBody->getTextProperties().pushRotationAdjustments( mnRotation );
     645        1792 :             aShapeProps.assignUsed( mpTextBody->getTextProperties().maPropertyMap );
     646             :             // Push char properties as well - specifically useful when this is a placeholder
     647        1792 :             if( mpMasterTextListStyle &&  mpMasterTextListStyle->getListStyle()[0]->getTextCharacterProperties().moHeight.has() )
     648         638 :                 aShapeProps.setProperty(PROP_CharHeight, GetFontHeight( mpMasterTextListStyle->getListStyle()[0]->getTextCharacterProperties().moHeight.get() ));
     649             :         }
     650             : 
     651             :         // applying properties
     652        5406 :         aShapeProps.assignUsed( getShapeProperties() );
     653        5406 :         aShapeProps.assignUsed( maDefaultShapeProperties );
     654        5406 :         if ( bIsEmbMedia || aServiceName == "com.sun.star.drawing.GraphicObjectShape" || aServiceName == "com.sun.star.drawing.OLE2Shape" )
     655         572 :             mpGraphicPropertiesPtr->pushToPropMap( aShapeProps, rGraphicHelper );
     656        5406 :         if ( mpTablePropertiesPtr.get() && aServiceName == "com.sun.star.drawing.TableShape" )
     657           6 :             mpTablePropertiesPtr->pushToPropSet( rFilterBase, xSet, mpMasterTextListStyle );
     658        5406 :         aFillProperties.pushToPropMap( aShapeProps, rGraphicHelper, mnRotation, nFillPhClr, mbFlipH, mbFlipV );
     659        5406 :         aLineProperties.pushToPropMap( aShapeProps, rGraphicHelper, nLinePhClr );
     660             :         // TODO: use ph color when applying effect properties
     661        5406 :         aEffectProperties.pushToPropMap( aShapeProps, rGraphicHelper );
     662             : 
     663             :         // applying autogrowheight property before setting shape size, because
     664             :         // the shape size might be changed if currently autogrowheight is true
     665             :         // we must also check that the PropertySet supports the property.
     666       10812 :         Reference< XPropertySetInfo > xSetInfo( xSet->getPropertySetInfo() );
     667        5406 :         const OUString& rPropName = PropertyMap::getPropertyName( PROP_TextAutoGrowHeight );
     668        5406 :         if( xSetInfo.is() && xSetInfo->hasPropertyByName( rPropName ) )
     669        4928 :             if( aShapeProps.hasProperty( PROP_TextAutoGrowHeight ) )
     670        4834 :                 xSet->setPropertyValue( rPropName, Any( false ) );
     671             : 
     672             :         // do not set properties at a group shape (this causes
     673             :         // assertions from svx) ...
     674        5406 :         if( aServiceName != "com.sun.star.drawing.GroupShape" )
     675             :         {
     676        4948 :             if (aServiceName == "com.sun.star.text.TextFrame")
     677             :             {
     678           0 :                 if (mpCustomShapePropertiesPtr && mpCustomShapePropertiesPtr->getShapeTypeOverride())
     679             :                 {
     680           0 :                     uno::Reference<beans::XPropertySet> propertySet (mxShape, uno::UNO_QUERY);
     681           0 :                     uno::Sequence<beans::PropertyValue> aGrabBag;
     682           0 :                     propertySet->getPropertyValue("FrameInteropGrabBag") >>= aGrabBag;
     683           0 :                     sal_Int32 length = aGrabBag.getLength();
     684           0 :                     aGrabBag.realloc( length+1);
     685           0 :                     aGrabBag[length].Name = "mso-orig-shape-type";
     686             :                     const uno::Sequence< sal_Int8 > aNameSeq =
     687           0 :                         mpCustomShapePropertiesPtr->getShapePresetTypeName();
     688             :                     OUString sShapePresetTypeName(reinterpret_cast< const char* >(
     689           0 :                         aNameSeq.getConstArray()), aNameSeq.getLength(), RTL_TEXTENCODING_UTF8);
     690           0 :                     aGrabBag[length].Value = uno::makeAny(sShapePresetTypeName);
     691           0 :                     propertySet->setPropertyValue("FrameInteropGrabBag",uno::makeAny(aGrabBag));
     692             :                 }
     693             :                 //If the text box has links then save the link information so that
     694             :                 //it can be accessed in DomainMapper_Impl.cxx while chaining the text frames.
     695           0 :                 if (this->isLinkedTxbx())
     696             :                 {
     697           0 :                     uno::Reference<beans::XPropertySet> propertySet (mxShape, uno::UNO_QUERY);
     698           0 :                     uno::Sequence<beans::PropertyValue> aGrabBag;
     699           0 :                     propertySet->getPropertyValue("FrameInteropGrabBag") >>= aGrabBag;
     700           0 :                     sal_Int32 length = aGrabBag.getLength();
     701           0 :                     aGrabBag.realloc( length + 3 );
     702           0 :                     aGrabBag[length].Name = "TxbxHasLink";
     703           0 :                     aGrabBag[length].Value = uno::makeAny(this->isLinkedTxbx());
     704           0 :                     aGrabBag[length + 1 ].Name = "Txbx-Id";
     705           0 :                     aGrabBag[length + 1 ].Value = uno::makeAny(this->getLinkedTxbxAttributes().id);
     706           0 :                     aGrabBag[length + 2 ].Name = "Txbx-Seq";
     707           0 :                     aGrabBag[length + 2 ].Value = uno::makeAny(this->getLinkedTxbxAttributes().seq);
     708           0 :                     propertySet->setPropertyValue("FrameInteropGrabBag",uno::makeAny(aGrabBag));
     709             :                 }
     710             : 
     711             :                 // TextFrames have BackColor, not FillColor
     712           0 :                 if (aShapeProps.hasProperty(PROP_FillColor))
     713             :                 {
     714           0 :                     aShapeProps.setProperty(PROP_BackColor, aShapeProps.getProperty(PROP_FillColor));
     715           0 :                     aShapeProps.erase(PROP_FillColor);
     716             :                 }
     717             :                 // TextFrames have BackColorTransparency, not FillTransparence
     718           0 :                 if (aShapeProps.hasProperty(PROP_FillTransparence))
     719             :                 {
     720           0 :                     aShapeProps.setProperty(PROP_BackColorTransparency, aShapeProps.getProperty(PROP_FillTransparence));
     721           0 :                     aShapeProps.erase(PROP_FillTransparence);
     722             :                 }
     723             :                 // TextFrames have BackGrahicURL, not FillBitmapURL
     724           0 :                 if (aShapeProps.hasProperty(PROP_FillBitmapURL))
     725             :                 {
     726           0 :                     aShapeProps.setProperty(PROP_BackGraphicURL, aShapeProps.getProperty(PROP_FillBitmapURL));
     727           0 :                     aShapeProps.erase(PROP_FillBitmapURL);
     728             :                 }
     729           0 :                 if (aShapeProps.hasProperty(PROP_FillBitmapName))
     730             :                 {
     731           0 :                     uno::Any aAny = aShapeProps.getProperty(PROP_FillBitmapName);
     732           0 :                     aShapeProps.setProperty(PROP_BackGraphicURL, rFilterBase.getModelObjectHelper().getFillBitmapUrl( aAny.get<OUString>() ));
     733             :                     // aShapeProps.erase(PROP_FillBitmapName);  // Maybe, leave the name as well
     734             :                 }
     735             :                 // And no LineColor property; individual borders can have colors
     736           0 :                 if (aShapeProps.hasProperty(PROP_LineColor))
     737             :                 {
     738           0 :                     uno::Reference<beans::XPropertySet> xPropertySet(mxShape, uno::UNO_QUERY);
     739             :                     static const sal_Int32 aBorders[] =
     740             :                     {
     741             :                         PROP_TopBorder, PROP_LeftBorder, PROP_BottomBorder, PROP_RightBorder
     742             :                     };
     743           0 :                     for (unsigned int i = 0; i < SAL_N_ELEMENTS(aBorders); ++i)
     744             :                     {
     745           0 :                         css::table::BorderLine2 aBorderLine = xPropertySet->getPropertyValue(PropertyMap::getPropertyName(aBorders[i])).get<css::table::BorderLine2>();
     746           0 :                         aBorderLine.Color = aShapeProps.getProperty(PROP_LineColor).get<sal_Int32>();
     747           0 :                         if (aLineProperties.moLineWidth.has())
     748           0 :                             aBorderLine.LineWidth = convertEmuToHmm(aLineProperties.moLineWidth.get());
     749           0 :                         aShapeProps.setProperty(aBorders[i], uno::makeAny(aBorderLine));
     750             :                     }
     751           0 :                     aShapeProps.erase(PROP_LineColor);
     752             :                 }
     753           0 :                 if(mnRotation)
     754             :                 {
     755           0 :                     uno::Reference<beans::XPropertySet> xPropertySet(mxShape, uno::UNO_QUERY);
     756           0 :                     const OUString aGrabBagPropName = "FrameInteropGrabBag";
     757           0 :                     uno::Sequence<beans::PropertyValue> aGrabBag;
     758           0 :                     xPropertySet->getPropertyValue(aGrabBagPropName) >>= aGrabBag;
     759           0 :                     beans::PropertyValue aPair;
     760           0 :                     aPair.Name = "mso-rotation-angle";
     761           0 :                     aPair.Value = uno::makeAny(mnRotation);
     762           0 :                     if (aGrabBag.hasElements())
     763             :                     {
     764           0 :                         sal_Int32 nLength = aGrabBag.getLength();
     765           0 :                         aGrabBag.realloc(nLength + 1);
     766           0 :                         aGrabBag[nLength] = aPair;
     767             :                     }
     768             :                     else
     769             :                     {
     770           0 :                         aGrabBag.realloc(1);
     771           0 :                         aGrabBag[0] = aPair;
     772             :                     }
     773           0 :                     xPropertySet->setPropertyValue(aGrabBagPropName, uno::makeAny(aGrabBag));
     774             :                 }
     775             :                 // TextFrames have ShadowFormat, not individual shadow properties.
     776           0 :                 boost::optional<sal_Int32> oShadowDistance;
     777           0 :                 if (aShapeProps.hasProperty(PROP_ShadowXDistance))
     778             :                 {
     779           0 :                     oShadowDistance = aShapeProps.getProperty(PROP_ShadowXDistance).get<sal_Int32>();
     780           0 :                     aShapeProps.erase(PROP_ShadowXDistance);
     781             :                 }
     782           0 :                 if (aShapeProps.hasProperty(PROP_ShadowYDistance))
     783             :                 {
     784             :                     // There is a single 'dist' attribute, so no need to count the avg of x and y.
     785           0 :                     aShapeProps.erase(PROP_ShadowYDistance);
     786             :                 }
     787           0 :                 boost::optional<sal_Int32> oShadowColor;
     788           0 :                 if (aShapeProps.hasProperty(PROP_ShadowColor))
     789             :                 {
     790           0 :                     oShadowColor = aShapeProps.getProperty(PROP_ShadowColor).get<sal_Int32>();
     791           0 :                     aShapeProps.erase(PROP_ShadowColor);
     792             :                 }
     793           0 :                 if (aShapeProps.hasProperty(PROP_Shadow))
     794           0 :                     aShapeProps.erase(PROP_Shadow);
     795             : 
     796           0 :                 if (oShadowDistance || oShadowColor || aEffectProperties.maShadow.moShadowDir.has())
     797             :                 {
     798           0 :                     css::table::ShadowFormat aFormat;
     799           0 :                     if (oShadowColor)
     800           0 :                         aFormat.Color = *oShadowColor;
     801           0 :                     if (aEffectProperties.maShadow.moShadowDir.has())
     802             :                     {
     803           0 :                         css::table::ShadowLocation nLocation = css::table::ShadowLocation_NONE;
     804           0 :                         switch (aEffectProperties.maShadow.moShadowDir.get())
     805             :                         {
     806             :                         case 13500000:
     807           0 :                             nLocation = css::table::ShadowLocation_TOP_LEFT;
     808           0 :                             break;
     809             :                         case 18900000:
     810           0 :                             nLocation = css::table::ShadowLocation_TOP_RIGHT;
     811           0 :                             break;
     812             :                         case 8100000:
     813           0 :                             nLocation = css::table::ShadowLocation_BOTTOM_LEFT;
     814           0 :                             break;
     815             :                         case 2700000:
     816           0 :                             nLocation = css::table::ShadowLocation_BOTTOM_RIGHT;
     817           0 :                             break;
     818             :                         }
     819           0 :                         aFormat.Location = nLocation;
     820             :                     }
     821           0 :                     aFormat.ShadowWidth = *oShadowDistance;
     822           0 :                     aShapeProps.setProperty(PROP_ShadowFormat, uno::makeAny(aFormat));
     823           0 :                 }
     824             :             }
     825        4948 :             else if (mbTextBox)
     826             :             {
     827         804 :                 aShapeProps.setProperty(PROP_TextBox, uno::makeAny(true));
     828             :             }
     829             : 
     830        4948 :             if (aServiceName != "com.sun.star.text.TextFrame" && isLinkedTxbx())
     831             :             {
     832          12 :                 uno::Reference<beans::XPropertySet> propertySet (mxShape, uno::UNO_QUERY);
     833          24 :                 uno::Sequence<beans::PropertyValue> aGrabBag;
     834          12 :                 propertySet->getPropertyValue("InteropGrabBag") >>= aGrabBag;
     835          12 :                 sal_Int32 length = aGrabBag.getLength();
     836          12 :                 aGrabBag.realloc( length + 3 );
     837          12 :                 aGrabBag[length].Name = "TxbxHasLink";
     838          12 :                 aGrabBag[length].Value = uno::makeAny(this->isLinkedTxbx());
     839          12 :                 aGrabBag[length + 1 ].Name = "Txbx-Id";
     840          12 :                 aGrabBag[length + 1 ].Value = uno::makeAny(this->getLinkedTxbxAttributes().id);
     841          12 :                 aGrabBag[length + 2 ].Name = "Txbx-Seq";
     842          12 :                 aGrabBag[length + 2 ].Value = uno::makeAny(this->getLinkedTxbxAttributes().seq);
     843          24 :                 propertySet->setPropertyValue("InteropGrabBag",uno::makeAny(aGrabBag));
     844             :             }
     845             : 
     846        4948 :             PropertySet( xSet ).setProperties( aShapeProps );
     847        4948 :             if (mbLockedCanvas)
     848             :             {
     849           8 :                 putPropertyToGrabBag( "LockedCanvas", Any( true ) );
     850           8 :                 if (aServiceName == "com.sun.star.drawing.LineShape")
     851             :                 {
     852             :                     // It seems the position and size for lines inside a locked canvas is absolute.
     853           2 :                     mxShape->setPosition(awt::Point(aShapeRectHmm.X, aShapeRectHmm.Y));
     854           2 :                     mxShape->setSize(awt::Size(aShapeRectHmm.Width, aShapeRectHmm.Height));
     855             :                 }
     856             :             }
     857             : 
     858             :             // Store original fill and line colors of the shape and the theme color name to InteropGrabBag
     859        4948 :             Sequence< PropertyValue > aProperties( 6 );  //allocate the maximum possible number of slots
     860        4948 :             sal_Int32 nSize = 2;
     861        4948 :             PUT_PROP( aProperties, 0, "OriginalSolidFillClr", aShapeProps.getProperty(PROP_FillColor) );
     862        4948 :             PUT_PROP( aProperties, 1, "OriginalLnSolidFillClr", aShapeProps.getProperty(PROP_LineColor) );
     863        9896 :             OUString sColorFillScheme = aFillProperties.maFillColor.getSchemeName();
     864        4948 :             if( !aFillProperties.maFillColor.isPlaceHolder() && !sColorFillScheme.isEmpty() )
     865             :             {
     866         402 :                 PUT_PROP( aProperties, nSize, "SpPrSolidFillSchemeClr", sColorFillScheme );
     867         402 :                 nSize++;
     868         402 :                 PUT_PROP( aProperties, nSize, "SpPrSolidFillSchemeClrTransformations",
     869             :                           aFillProperties.maFillColor.getTransformations() );
     870         402 :                 nSize++;
     871             :             }
     872        9896 :             OUString sLnColorFillScheme = aLineProperties.maLineFill.maFillColor.getSchemeName();
     873        4948 :             if( !aLineProperties.maLineFill.maFillColor.isPlaceHolder() && !sLnColorFillScheme.isEmpty() )
     874             :             {
     875         506 :                 PUT_PROP( aProperties, nSize, "SpPrLnSolidFillSchemeClr", sLnColorFillScheme );
     876         506 :                 nSize++;
     877         506 :                 PUT_PROP( aProperties, nSize, "SpPrLnSolidFillSchemeClrTransformations",
     878             :                           aLineProperties.maLineFill.maFillColor.getTransformations() );
     879         506 :                 nSize++;
     880             :             }
     881        4948 :             aProperties.realloc( nSize ); //shrink the Sequence if we didn't use all the slots
     882        4948 :             putPropertiesToGrabBag( aProperties );
     883             : 
     884             :             // Store original gradient fill of the shape to InteropGrabBag
     885             :             // LibreOffice doesn't support all the kinds of gradient so we save its complete definition
     886        4948 :             if( aShapeProps.hasProperty( PROP_FillGradient ) )
     887             :             {
     888         278 :                 Sequence< PropertyValue > aGradientStops( aFillProperties.maGradientProps.maGradientStops.size() );
     889         278 :                 ::std::map< double, Color >::iterator aIt = aFillProperties.maGradientProps.maGradientStops.begin();
     890         978 :                 for( sal_uInt32 i = 0; i < aFillProperties.maGradientProps.maGradientStops.size(); ++i )
     891             :                 { // for each stop in the gradient definition:
     892             : 
     893             :                     // save position
     894         700 :                     Sequence< PropertyValue > aGradientStop( 3 );
     895         700 :                     PUT_PROP( aGradientStop, 0, "Pos", aIt->first );
     896             : 
     897        1400 :                     OUString sStopColorScheme = aIt->second.getSchemeName();
     898         700 :                     if( sStopColorScheme.isEmpty() )
     899             :                     {
     900             :                         // save RGB color
     901         234 :                         PUT_PROP( aGradientStop, 1, "RgbClr", aIt->second.getColor( rGraphicHelper, nFillPhClr ) );
     902             :                         // in the case of a RGB color, transformations are already applied to
     903             :                         // the color with the exception of alpha transformations. We only need
     904             :                         // to keep the transparency value to calculate the alpha value later.
     905         234 :                         if( aIt->second.hasTransparency() )
     906             :                         {
     907          60 :                             PUT_PROP( aGradientStop, 2, "Transparency", aIt->second.getTransparency() );
     908             :                         }
     909             :                     }
     910             :                     else
     911             :                     {
     912             :                         // save color with scheme name
     913         466 :                         PUT_PROP( aGradientStop, 1, "SchemeClr", sStopColorScheme );
     914             :                         // save all color transformations
     915         466 :                         PUT_PROP( aGradientStop, 2, "Transformations", aIt->second.getTransformations() );
     916             :                     }
     917             : 
     918         700 :                     PUT_PROP( aGradientStops, i, OUString::number( i ), aGradientStop );
     919         700 :                     ++aIt;
     920         700 :                 }
     921             :                 // If getFillProperties.moFillType is unused that means gradient is defined by a theme
     922             :                 // which is already saved into StyleFillRef property, so no need to save the explicit values too
     923         278 :                 if( getFillProperties().moFillType.has() )
     924         266 :                     putPropertyToGrabBag( "GradFillDefinition", Any( aGradientStops ) );
     925         278 :                 putPropertyToGrabBag( "OriginalGradFill", aShapeProps.getProperty(PROP_FillGradient) );
     926             :             }
     927             : 
     928             :             // store unsupported effect attributes in the grab bag
     929        4948 :             if( aEffectProperties.maEffects.size() > 0 )
     930             :             {
     931         390 :                 Sequence< PropertyValue > aEffects( aEffectProperties.maEffects.size() );
     932         390 :                 sal_uInt32 i = 0;
     933        2430 :                 for( boost::ptr_vector< Effect >::iterator it = aEffectProperties.maEffects.begin();
     934        1620 :                         it != aEffectProperties.maEffects.end(); ++it )
     935             :                 {
     936         420 :                     PropertyValue aEffect = it->getEffect();
     937         420 :                     if( !aEffect.Name.isEmpty() )
     938             :                     {
     939         420 :                         Sequence< PropertyValue > aEffectsGrabBag( 3 );
     940         420 :                         PUT_PROP( aEffectsGrabBag, 0, "Attribs", aEffect.Value );
     941             : 
     942         420 :                         Color& aColor( it->moColor );
     943         840 :                         OUString sColorScheme = aColor.getSchemeName();
     944         420 :                         if( sColorScheme.isEmpty() )
     945             :                         {
     946             :                             // RGB color and transparency value
     947         376 :                             PUT_PROP( aEffectsGrabBag, 1, "RgbClr",
     948             :                                       aColor.getColor( rGraphicHelper, nFillPhClr ) );
     949         376 :                             PUT_PROP( aEffectsGrabBag, 2, "RgbClrTransparency",
     950             :                                       aColor.getTransparency() );
     951             :                         }
     952             :                         else
     953             :                         {
     954             :                             // scheme color with name and transformations
     955          44 :                             PUT_PROP( aEffectsGrabBag, 1, "SchemeClr", sColorScheme );
     956          44 :                             PUT_PROP( aEffectsGrabBag, 2, "SchemeClrTransformations",
     957             :                                       aColor.getTransformations() );
     958             :                         }
     959         420 :                         PUT_PROP( aEffects, i, aEffect.Name, aEffectsGrabBag );
     960         840 :                         ++i;
     961             :                     }
     962         420 :                 }
     963         390 :                 putPropertyToGrabBag( "EffectProperties", Any( aEffects ) );
     964             :             }
     965             : 
     966             :             // add 3D effects if any
     967        9896 :             Sequence< PropertyValue > aCamera3DEffects = get3DProperties().getCameraAttributes();
     968        9896 :             Sequence< PropertyValue > aLightRig3DEffects = get3DProperties().getLightRigAttributes();
     969        9896 :             Sequence< PropertyValue > aShape3DEffects = get3DProperties().getShape3DAttributes( rGraphicHelper, nFillPhClr );
     970        4948 :             if( aCamera3DEffects.getLength() > 0 || aLightRig3DEffects.getLength() > 0 || aShape3DEffects.getLength() > 0 )
     971             :             {
     972         164 :                 Sequence< PropertyValue > a3DEffectsGrabBag( 3 );
     973         164 :                 PUT_PROP( a3DEffectsGrabBag, 0, "Camera", Any( aCamera3DEffects ) );
     974         164 :                 PUT_PROP( a3DEffectsGrabBag, 1, "LightRig", Any( aLightRig3DEffects ) );
     975         164 :                 PUT_PROP( a3DEffectsGrabBag, 2, "Shape3D", Any( aShape3DEffects ) );
     976         164 :                 putPropertyToGrabBag( "3DEffectProperties", Any( a3DEffectsGrabBag ) );
     977             :             }
     978             : 
     979             :             // store bitmap artistic effects in the grab bag
     980        4948 :             if( !mpGraphicPropertiesPtr->maBlipProps.maEffect.isEmpty() )
     981             :                 putPropertyToGrabBag( "ArtisticEffectProperties",
     982        4986 :                                       Any( mpGraphicPropertiesPtr->maBlipProps.maEffect.getEffect() ) );
     983             :         }
     984             : 
     985         458 :         else if( mbLockedCanvas )
     986             :         {
     987             :             //If we have aServiceName as "com.sun.star.drawing.GroupShape" and lockedCanvas
     988           6 :             putPropertyToGrabBag( "LockedCanvas", Any( true ) );
     989             :         }
     990             : 
     991             :         // These can have a custom geometry, so position should be set here,
     992             :         // after creation but before custom shape handling, using the position
     993             :         // we got from the caller.
     994        5406 :         if (mbWps && aServiceName == "com.sun.star.drawing.LineShape")
     995          38 :             mxShape->setPosition(maPosition);
     996             : 
     997        5406 :         if( bIsCustomShape )
     998             :         {
     999        3680 :             if ( mbFlipH )
    1000          26 :                 mpCustomShapePropertiesPtr->setMirroredX( true );
    1001        3680 :             if ( mbFlipV )
    1002         182 :                 mpCustomShapePropertiesPtr->setMirroredY( true );
    1003        3680 :             if( getTextBody() )
    1004             :             {
    1005        1318 :                 sal_Int32 nTextRotateAngle = static_cast< sal_Int32 >( getTextBody()->getTextProperties().moRotation.get( 0 ) );
    1006        1318 :                 mpCustomShapePropertiesPtr->setTextRotateAngle( nTextRotateAngle / 60000 );
    1007             :             }
    1008             : 
    1009             :             SAL_INFO("oox.cscode", "==cscode== shape name: '" << msName << "'");
    1010             :             SAL_INFO("oox.csdata", "==csdata== shape name: '" << msName << "'");
    1011        3680 :             mpCustomShapePropertiesPtr->pushToPropSet( rFilterBase, xSet, mxShape, maSize );
    1012             :         }
    1013        1726 :         else if( getTextBody() )
    1014         474 :             getTextBody()->getTextProperties().pushVertSimulation();
    1015             : 
    1016        5406 :         PropertySet aPropertySet(mxShape);
    1017        5406 :         if ( !bUseRotationTransform && mnRotation != 0 )
    1018             :         {
    1019             :             // use the same logic for rotation from VML exporter (SimpleShape::implConvertAndInsert at vmlshape.cxx)
    1020          36 :             aPropertySet.setAnyProperty( PROP_RotateAngle, makeAny( sal_Int32( NormAngle360( mnRotation / -600 ) ) ) );
    1021          36 :             aPropertySet.setAnyProperty( PROP_HoriOrientPosition, makeAny( maPosition.X ) );
    1022          36 :             aPropertySet.setAnyProperty( PROP_VertOrientPosition, makeAny( maPosition.Y ) );
    1023             :         }
    1024             : 
    1025             :         // in some cases, we don't have any text body.
    1026        5406 :         if( getTextBody() && ( !bDoNotInsertEmptyTextBody || !mpTextBody->isEmpty() ) )
    1027             :         {
    1028        1656 :             Reference < XText > xText( mxShape, UNO_QUERY );
    1029        1656 :             if ( xText.is() )   // not every shape is supporting an XText interface (e.g. GroupShape)
    1030             :             {
    1031        1656 :                 TextCharacterProperties aCharStyleProperties;
    1032        1656 :                 if( const ShapeStyleRef* pFontRef = getShapeStyleRef( XML_fontRef ) )
    1033             :                 {
    1034         836 :                     if( pTheme )
    1035         836 :                         if( const TextCharacterProperties* pCharProps = pTheme->getFontStyle( pFontRef->mnThemedIdx ) )
    1036         810 :                             aCharStyleProperties.assignUsed( *pCharProps );
    1037             :                     SAL_INFO("oox.drawingml", OSL_THIS_FUNC << "use font color");
    1038         836 :                     aCharStyleProperties.maCharColor.assignIfUsed( pFontRef->maPhClr );
    1039             :                 }
    1040             : 
    1041        3312 :                 Reference < XTextCursor > xAt = xText->createTextCursor();
    1042        3312 :                 getTextBody()->insertAt( rFilterBase, xText, xAt, aCharStyleProperties, mpMasterTextListStyle );
    1043        1656 :             }
    1044             :         }
    1045        3750 :         else if (mbTextBox)
    1046             :         {
    1047             :             // No drawingML text, but WPS text is expected: save the theme
    1048             :             // character color on the shape, then.
    1049         804 :             if(const ShapeStyleRef* pFontRef = getShapeStyleRef(XML_fontRef))
    1050             :             {
    1051         358 :                 sal_Int32 nCharColor = pFontRef->maPhClr.getColor(rGraphicHelper);
    1052         358 :                 aPropertySet.setAnyProperty(PROP_CharColor, uno::makeAny(nCharColor));
    1053             :             }
    1054       10812 :         }
    1055             :     }
    1056             : 
    1057        5406 :     if( mxShape.is() )
    1058        5406 :         finalizeXShape( rFilterBase, rxShapes );
    1059             : 
    1060       10812 :     return mxShape;
    1061             : }
    1062             : 
    1063          68 : void Shape::keepDiagramCompatibilityInfo( XmlFilterBase& rFilterBase )
    1064             : {
    1065             :     try
    1066             :     {
    1067          68 :         if( !maDiagramDoms.hasElements() )
    1068           0 :             return;
    1069             : 
    1070          68 :         Reference < XPropertySet > xSet( mxShape, UNO_QUERY_THROW );
    1071         136 :         Reference < XPropertySetInfo > xSetInfo( xSet->getPropertySetInfo() );
    1072          68 :         if ( !xSetInfo.is() )
    1073           0 :             return;
    1074             : 
    1075         136 :         const OUString aGrabBagPropName = UNO_NAME_MISC_OBJ_INTEROPGRABBAG;
    1076          68 :         if( !xSetInfo->hasPropertyByName( aGrabBagPropName ) )
    1077           0 :             return;
    1078             : 
    1079         136 :         Sequence < PropertyValue > aGrabBag;
    1080          68 :         xSet->getPropertyValue( aGrabBagPropName ) >>= aGrabBag;
    1081             : 
    1082             :         // We keep the previous items, if present
    1083          68 :         if ( aGrabBag.hasElements() )
    1084             :         {
    1085           0 :             sal_Int32 length = aGrabBag.getLength();
    1086           0 :             aGrabBag.realloc( length+maDiagramDoms.getLength() );
    1087             : 
    1088           0 :             for( sal_Int32 i = 0; i < maDiagramDoms.getLength(); ++i )
    1089           0 :                 aGrabBag[length+i] = maDiagramDoms[i];
    1090             : 
    1091           0 :             xSet->setPropertyValue( aGrabBagPropName, Any( aGrabBag ) );
    1092             :         } else
    1093          68 :             xSet->setPropertyValue( aGrabBagPropName, Any( maDiagramDoms ) );
    1094             : 
    1095          68 :         xSet->setPropertyValue( OUString( "MoveProtect" ), Any( sal_True ) );
    1096          68 :         xSet->setPropertyValue( OUString( "SizeProtect" ), Any( sal_True ) );
    1097             : 
    1098             :         // Replace existing shapes with a new Graphic Object rendered
    1099             :         // from them
    1100         136 :         Reference < XShape > xShape( renderDiagramToGraphic( rFilterBase ) );
    1101         136 :         Reference < XShapes > xShapes( mxShape, UNO_QUERY_THROW );
    1102         556 :         while( xShapes->hasElements() )
    1103         420 :             xShapes->remove( Reference < XShape > ( xShapes->getByIndex( 0 ),  UNO_QUERY_THROW ) );
    1104         136 :         xShapes->add( xShape );
    1105             :     }
    1106           0 :     catch( const Exception& e )
    1107             :     {
    1108             :         SAL_WARN( "oox.drawingml", OSL_THIS_FUNC << "Exception: " << e.Message );
    1109             :     }
    1110             : }
    1111             : 
    1112          68 : Reference < XShape > Shape::renderDiagramToGraphic( XmlFilterBase& rFilterBase )
    1113             : {
    1114          68 :     Reference< XShape > xShape;
    1115             : 
    1116             :     try
    1117             :     {
    1118          68 :         if( !maDiagramDoms.hasElements() )
    1119           0 :             return xShape;
    1120             : 
    1121             :         // Stream in which to place the rendered shape
    1122          68 :         SvMemoryStream mpTempStream;
    1123         136 :         Reference < io::XStream > xStream( new utl::OStreamWrapper( mpTempStream ) );
    1124         136 :         Reference < io::XOutputStream > xOutputStream( xStream->getOutputStream() );
    1125             : 
    1126             :         // Rendering format
    1127         136 :         OUString sFormat( "SVM" );
    1128             : 
    1129             :         // Size of the rendering
    1130          68 :         awt::Size aActualSize = mxShape->getSize();
    1131          68 :         Size aResolution( Application::GetDefaultDevice()->LogicToPixel( Size( 100, 100 ), MAP_CM ) );
    1132          68 :         double fPixelsPer100thmm = static_cast < double > ( aResolution.Width() ) / 100000.0;
    1133          68 :         awt::Size aSize = awt::Size( static_cast < sal_Int32 > ( ( fPixelsPer100thmm * aActualSize.Width ) + 0.5 ),
    1134         136 :                                      static_cast < sal_Int32 > ( ( fPixelsPer100thmm * aActualSize.Height ) + 0.5 ) );
    1135             : 
    1136         136 :         Sequence< PropertyValue > aFilterData( 4 );
    1137          68 :         aFilterData[ 0 ].Name = "PixelWidth";
    1138          68 :         aFilterData[ 0 ].Value <<= aSize.Width;
    1139          68 :         aFilterData[ 1 ].Name = "PixelHeight";
    1140          68 :         aFilterData[ 1 ].Value <<= aSize.Height;
    1141          68 :         aFilterData[ 2 ].Name = "LogicalWidth";
    1142          68 :         aFilterData[ 2 ].Value <<= aActualSize.Width;
    1143          68 :         aFilterData[ 3 ].Name = "LogicalHeight";
    1144          68 :         aFilterData[ 3 ].Value <<= aActualSize.Height;
    1145             : 
    1146         136 :         Sequence < PropertyValue > aDescriptor( 3 );
    1147          68 :         aDescriptor[ 0 ].Name = "OutputStream";
    1148          68 :         aDescriptor[ 0 ].Value <<= xOutputStream;
    1149          68 :         aDescriptor[ 1 ].Name = "FilterName";
    1150          68 :         aDescriptor[ 1 ].Value <<= sFormat;
    1151          68 :         aDescriptor[ 2 ].Name = "FilterData";
    1152          68 :         aDescriptor[ 2 ].Value <<= aFilterData;
    1153             : 
    1154         136 :         Reference < lang::XComponent > xSourceDoc( mxShape, UNO_QUERY_THROW );
    1155         122 :         Reference < XGraphicExportFilter > xGraphicExporter = GraphicExportFilter::create( rFilterBase.getComponentContext() );
    1156          54 :         xGraphicExporter->setSourceDocument( xSourceDoc );
    1157          54 :         xGraphicExporter->filter( aDescriptor );
    1158             : 
    1159          54 :         mpTempStream.Seek( STREAM_SEEK_TO_BEGIN );
    1160             : 
    1161         108 :         Graphic aGraphic;
    1162         108 :         GraphicFilter aFilter( false );
    1163          54 :         if ( aFilter.ImportGraphic( aGraphic, "", mpTempStream, GRFILTER_FORMAT_NOTFOUND, NULL, 0, static_cast < Sequence < PropertyValue >* > ( NULL ), NULL ) != GRFILTER_OK )
    1164             :         {
    1165             :             SAL_WARN( "oox.drawingml", OSL_THIS_FUNC
    1166             :                       << "Unable to import rendered stream into graphic object" );
    1167           0 :             return xShape;
    1168             :         }
    1169             : 
    1170         108 :         Reference < graphic::XGraphic > xGraphic( aGraphic.GetXGraphic() );
    1171         108 :         Reference < lang::XMultiServiceFactory > xServiceFact( rFilterBase.getModel(), UNO_QUERY_THROW );
    1172          54 :         xShape = Reference < XShape > ( xServiceFact->createInstance( OUString( "com.sun.star.drawing.GraphicObjectShape" ) ), UNO_QUERY_THROW );
    1173         108 :         Reference < XPropertySet > xPropSet( xShape, UNO_QUERY_THROW );
    1174          54 :         xPropSet->setPropertyValue( OUString( "Graphic" ), Any( xGraphic ) );
    1175          54 :         xPropSet->setPropertyValue( OUString( "MoveProtect" ), Any( sal_True ) );
    1176          54 :         xPropSet->setPropertyValue( OUString( "SizeProtect" ), Any( sal_True ) );
    1177         122 :         xPropSet->setPropertyValue( OUString( "Name" ), Any( OUString( "RenderedShapes" ) ) );
    1178             :     }
    1179          14 :     catch( const Exception& e )
    1180             :     {
    1181             :         SAL_WARN( "oox.drawingml", OSL_THIS_FUNC << "Exception: " << e.Message );
    1182             :     }
    1183             : 
    1184          68 :     return xShape;
    1185             : }
    1186             : 
    1187        4932 : void Shape::setTextBody(const TextBodyPtr & pTextBody)
    1188             : {
    1189        4932 :     mpTextBody = pTextBody;
    1190        4932 : }
    1191             : 
    1192        2876 : void Shape::setMasterTextListStyle( const TextListStylePtr& pMasterTextListStyle )
    1193             : {
    1194             :     SAL_INFO("oox.drawingml", OSL_THIS_FUNC << "set master text list style to shape id: " << msId);
    1195             : 
    1196        2876 :     mpMasterTextListStyle = pMasterTextListStyle;
    1197        2876 : }
    1198             : 
    1199        5406 : OUString Shape::finalizeServiceName( XmlFilterBase& rFilter, const OUString& rServiceName, const awt::Rectangle& rShapeRect )
    1200             : {
    1201        5406 :     OUString aServiceName = rServiceName;
    1202        5406 :     switch( meFrameType )
    1203             :     {
    1204             :         case FRAMETYPE_OLEOBJECT:
    1205             :         {
    1206           4 :             awt::Size aOleSize( rShapeRect.Width, rShapeRect.Height );
    1207           4 :             if( rFilter.getOleObjectHelper().importOleObject( maShapeProperties, *mxOleObjectInfo, aOleSize ) )
    1208           4 :                 aServiceName = "com.sun.star.drawing.OLE2Shape";
    1209             : 
    1210             :             // get the path to the representation graphic
    1211           4 :             OUString aGraphicPath;
    1212           4 :             if( !mxOleObjectInfo->maShapeId.isEmpty() )
    1213           4 :                 if( ::oox::vml::Drawing* pVmlDrawing = rFilter.getVmlDrawing() )
    1214           4 :                     if( const ::oox::vml::ShapeBase* pVmlShape = pVmlDrawing->getShapes().getShapeById( mxOleObjectInfo->maShapeId, true ) )
    1215           4 :                         aGraphicPath = pVmlShape->getGraphicPath();
    1216             : 
    1217             :             // import and store the graphic
    1218           4 :             if( !aGraphicPath.isEmpty() )
    1219             :             {
    1220             :                 // Transfer shape's width and heightto graphicsfilter (can be used by WMF/EMF)
    1221           4 :                 WMF_EXTERNALHEADER aExtHeader;
    1222           4 :                 aExtHeader.mapMode = 8; // MM_ANISOTROPIC
    1223           4 :                 aExtHeader.xExt = rShapeRect.Width;
    1224           4 :                 aExtHeader.yExt = rShapeRect.Height;
    1225             : 
    1226           4 :                 Reference< graphic::XGraphic > xGraphic = rFilter.getGraphicHelper().importEmbeddedGraphic( aGraphicPath, &aExtHeader );
    1227           4 :                 if( xGraphic.is() )
    1228           4 :                     maShapeProperties.setProperty(PROP_Graphic, xGraphic);
    1229           4 :             }
    1230             :         }
    1231           4 :         break;
    1232             : 
    1233             :         default:;
    1234             :     }
    1235        5406 :     return aServiceName;
    1236             : }
    1237             : 
    1238        5406 : void Shape::finalizeXShape( XmlFilterBase& rFilter, const Reference< XShapes >& rxShapes )
    1239             : {
    1240        5406 :     switch( meFrameType )
    1241             :     {
    1242             :         case FRAMETYPE_CHART:
    1243             :         {
    1244             :             OSL_ENSURE( !mxChartShapeInfo->maFragmentPath.isEmpty(), "Shape::finalizeXShape - missing chart fragment" );
    1245         224 :             if( mxShape.is() && !mxChartShapeInfo->maFragmentPath.isEmpty() ) try
    1246             :             {
    1247             :                 // set the chart2 OLE class ID at the OLE shape
    1248         224 :                 PropertySet aShapeProp( mxShape );
    1249         224 :                 aShapeProp.setProperty( PROP_CLSID, OUString( "12dcae26-281f-416f-a234-c3086127382e" ) );
    1250             : 
    1251             :                 // get the XModel interface of the embedded object from the OLE shape
    1252         448 :                 Reference< frame::XModel > xDocModel;
    1253         224 :                 aShapeProp.getProperty( xDocModel, PROP_Model );
    1254         448 :                 Reference< chart2::XChartDocument > xChartDoc( xDocModel, UNO_QUERY_THROW );
    1255             : 
    1256             :                 // load the chart data from the XML fragment
    1257         448 :                 chart::ChartSpaceModel aModel;
    1258             :                 chart::ChartSpaceFragment *pChartSpaceFragment = new chart::ChartSpaceFragment(
    1259         224 :                         rFilter, mxChartShapeInfo->maFragmentPath, aModel );
    1260             :                 const OUString aThemeOverrideFragmentPath( pChartSpaceFragment->
    1261         448 :                         getFragmentPathFromFirstTypeFromOfficeDoc("themeOverride") );
    1262         224 :                 rFilter.importFragment( pChartSpaceFragment );
    1263             :                 ::oox::ppt::PowerPointImport *pPowerPointImport =
    1264         224 :                     dynamic_cast< ::oox::ppt::PowerPointImport* >(&rFilter);
    1265         224 :                 if (!aThemeOverrideFragmentPath.isEmpty() && pPowerPointImport)
    1266             :                 {
    1267             :                     uno::Reference< xml::sax::XFastSAXSerializable > xDoc(
    1268           0 :                             rFilter.importFragment(aThemeOverrideFragmentPath), uno::UNO_QUERY_THROW);
    1269           0 :                     ThemePtr pTheme = pPowerPointImport->getActualSlidePersist()->getTheme();
    1270             :                     rFilter.importFragment(new ThemeOverrideFragmentHandler(
    1271           0 :                                 rFilter, aThemeOverrideFragmentPath, *pTheme), xDoc);
    1272           0 :                     pPowerPointImport->getActualSlidePersist()->setTheme(pTheme);
    1273             :                 }
    1274             : 
    1275             :                 // convert imported chart model to chart document
    1276         448 :                 Reference< drawing::XShapes > xExternalPage;
    1277         224 :                 if( !mxChartShapeInfo->mbEmbedShapes )
    1278           0 :                     xExternalPage = rxShapes;
    1279         224 :                 if( rFilter.getChartConverter() )
    1280             :                 {
    1281         224 :                     rFilter.getChartConverter()->convertFromModel( rFilter, aModel, xChartDoc, xExternalPage, mxShape->getPosition(), mxShape->getSize() );
    1282         224 :                     if( !xChartDoc->hasInternalDataProvider() )
    1283             :                     {
    1284          34 :                         Reference< chart2::data::XDataReceiver > xDataRec( xChartDoc, UNO_QUERY );
    1285          68 :                         Reference< chart2::data::XDataSource > xData( xDataRec->getUsedData(), UNO_QUERY );
    1286         136 :                         if( xData->getDataSequences().getLength() <= 0 || !xData->getDataSequences()[0]->getValues().is() ||
    1287         102 :                                 xData->getDataSequences()[0]->getValues()->getData().getLength() <= 0 )
    1288             :                         {
    1289           0 :                             rFilter.useInternalChartDataTable( true );
    1290           0 :                             rFilter.getChartConverter()->convertFromModel( rFilter, aModel, xChartDoc, xExternalPage, mxShape->getPosition(), mxShape->getSize() );
    1291           0 :                             rFilter.useInternalChartDataTable( false );
    1292          34 :                         }
    1293             :                     }
    1294             : 
    1295         224 :                 }
    1296             :             }
    1297           0 :             catch( Exception& )
    1298             :             {
    1299             :             }
    1300             :         }
    1301         224 :         break;
    1302             : 
    1303             :         default:;
    1304             :     }
    1305        5406 : }
    1306             : 
    1307        5826 : void Shape::putPropertyToGrabBag( const OUString& sPropertyName, const Any& aPropertyValue )
    1308             : {
    1309        5826 :     PropertyValue pNewProperty;
    1310        5826 :     pNewProperty.Name = sPropertyName;
    1311        5826 :     pNewProperty.Value = aPropertyValue;
    1312        5826 :     putPropertyToGrabBag( pNewProperty );
    1313        5826 : }
    1314             : 
    1315        5826 : void Shape::putPropertyToGrabBag( const PropertyValue& pProperty )
    1316             : {
    1317        5826 :     Reference< XPropertySet > xSet( mxShape, UNO_QUERY );
    1318       11652 :     Reference< XPropertySetInfo > xSetInfo( xSet->getPropertySetInfo() );
    1319       11652 :     const OUString& aGrabBagPropName = OUString( UNO_NAME_MISC_OBJ_INTEROPGRABBAG );
    1320        5826 :     if( mxShape.is() && xSet.is() && xSetInfo.is() && xSetInfo->hasPropertyByName( aGrabBagPropName ) )
    1321             :     {
    1322        5826 :         Sequence< PropertyValue > aGrabBag;
    1323        5826 :         xSet->getPropertyValue( aGrabBagPropName ) >>= aGrabBag;
    1324             : 
    1325        5826 :         sal_Int32 length = aGrabBag.getLength();
    1326        5826 :         aGrabBag.realloc( length + 1 );
    1327        5826 :         aGrabBag[length] = pProperty;
    1328             : 
    1329        5826 :         xSet->setPropertyValue( aGrabBagPropName, Any( aGrabBag ) );
    1330        5826 :     }
    1331        5826 : }
    1332             : 
    1333        4948 : void Shape::putPropertiesToGrabBag( const Sequence< PropertyValue >& aProperties )
    1334             : {
    1335        4948 :     Reference< XPropertySet > xSet( mxShape, UNO_QUERY );
    1336        9896 :     Reference< XPropertySetInfo > xSetInfo( xSet->getPropertySetInfo() );
    1337        9896 :     const OUString& aGrabBagPropName = OUString( UNO_NAME_MISC_OBJ_INTEROPGRABBAG );
    1338        4948 :     if( mxShape.is() && xSet.is() && xSetInfo.is() && xSetInfo->hasPropertyByName( aGrabBagPropName ) )
    1339             :     {
    1340             :         // get existing grab bag
    1341        4496 :         Sequence< PropertyValue > aGrabBag;
    1342        4496 :         xSet->getPropertyValue( aGrabBagPropName ) >>= aGrabBag;
    1343        4496 :         sal_Int32 length = aGrabBag.getLength();
    1344             : 
    1345             :         // update grab bag size to contain the new items
    1346        4496 :         aGrabBag.realloc( length + aProperties.getLength() );
    1347             : 
    1348             :         // put the new items
    1349       15304 :         for( sal_Int32 i=0; i < aProperties.getLength(); ++i )
    1350             :         {
    1351       10808 :             aGrabBag[length + i].Name = aProperties[i].Name;
    1352       10808 :             aGrabBag[length + i].Value = aProperties[i].Value;
    1353             :         }
    1354             : 
    1355             :         // put it back to the shape
    1356        4496 :         xSet->setPropertyValue( aGrabBagPropName, Any( aGrabBag ) );
    1357        4948 :     }
    1358        4948 : }
    1359             : 
    1360         140 : uno::Sequence< uno::Sequence< uno::Any > >  Shape::resolveRelationshipsOfTypeFromOfficeDoc(core::XmlFilterBase& rFilter, const OUString& sFragment, const OUString& sType )
    1361             : {
    1362         140 :     uno::Sequence< uno::Sequence< uno::Any > > xRelListTemp;
    1363         140 :     sal_Int32 counter = 0;
    1364             : 
    1365         280 :     core::RelationsRef xRels = rFilter.importRelations( sFragment );
    1366         140 :     if ( xRels )
    1367             :     {
    1368         140 :         core::RelationsRef xImageRels = xRels->getRelationsFromTypeFromOfficeDoc( sType );
    1369         140 :         if ( xImageRels )
    1370             :         {
    1371         140 :             xRelListTemp.realloc( xImageRels->size() );
    1372         296 :             for( ::std::map< OUString, core::Relation >::const_iterator aIt = xImageRels->begin(), aEnd = xImageRels->end(); aIt != aEnd; ++aIt )
    1373             :             {
    1374         156 :                 uno::Sequence< uno::Any > diagramRelTuple (3);
    1375             :                 // [0] => RID, [1] => InputStream [2] => extension
    1376         312 :                 OUString sRelId = aIt->second.maId;
    1377             : 
    1378         156 :                 diagramRelTuple[0] = uno::makeAny ( sRelId );
    1379         312 :                 OUString sTarget = xImageRels->getFragmentPathFromRelId( sRelId );
    1380             : 
    1381         312 :                 uno::Reference< io::XInputStream > xImageInputStrm( rFilter.openInputStream( sTarget ), uno::UNO_SET_THROW );
    1382         312 :                 StreamDataSequence dataSeq;
    1383         156 :                 if ( rFilter.importBinaryData( dataSeq, sTarget ) )
    1384             :                 {
    1385         156 :                     diagramRelTuple[1] = uno::makeAny( dataSeq );
    1386             :                 }
    1387             : 
    1388         156 :                 diagramRelTuple[2] = uno::makeAny( sTarget.copy( sTarget.lastIndexOf(".") ) );
    1389             : 
    1390         156 :                 xRelListTemp[counter] = diagramRelTuple;
    1391         156 :                 ++counter;
    1392         156 :             }
    1393         140 :             xRelListTemp.realloc(counter);
    1394             : 
    1395         140 :         }
    1396             :     }
    1397         280 :     return xRelListTemp;
    1398             : }
    1399             : 
    1400         408 : } }
    1401             : 
    1402             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10