LCOV - code coverage report
Current view: top level - libreoffice/oox/source/drawingml - shape.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 221 343 64.4 %
Date: 2012-12-27 Functions: 19 27 70.4 %
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 "oox/drawingml/customshapeproperties.hxx"
      22             : #include "oox/drawingml/theme.hxx"
      23             : #include "oox/drawingml/fillproperties.hxx"
      24             : #include "oox/drawingml/lineproperties.hxx"
      25             : #include "oox/drawingml/effectproperties.hxx"
      26             : #include "oox/drawingml/shapepropertymap.hxx"
      27             : #include "oox/drawingml/textbody.hxx"
      28             : #include "oox/drawingml/table/tableproperties.hxx"
      29             : #include "oox/drawingml/chart/chartconverter.hxx"
      30             : #include "oox/drawingml/chart/chartspacefragment.hxx"
      31             : #include "oox/drawingml/chart/chartspacemodel.hxx"
      32             : #include "oox/vml/vmldrawing.hxx"
      33             : #include "oox/vml/vmlshape.hxx"
      34             : #include "oox/vml/vmlshapecontainer.hxx"
      35             : #include "oox/core/xmlfilterbase.hxx"
      36             : #include "oox/helper/graphichelper.hxx"
      37             : #include "oox/helper/propertyset.hxx"
      38             : 
      39             : #include <tools/solar.h>        // for the F_PI180 define
      40             : #include <com/sun/star/graphic/XGraphic.hpp>
      41             : #include <com/sun/star/container/XNamed.hpp>
      42             : #include <com/sun/star/container/XNameContainer.hpp>
      43             : #include <com/sun/star/beans/XMultiPropertySet.hpp>
      44             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      45             : #include <com/sun/star/xml/AttributeData.hpp>
      46             : #include <com/sun/star/drawing/HomogenMatrix3.hpp>
      47             : #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
      48             : #include <com/sun/star/text/XText.hpp>
      49             : #include <com/sun/star/chart2/XChartDocument.hpp>
      50             : #include <com/sun/star/style/ParagraphAdjust.hpp>
      51             : #include <basegfx/point/b2dpoint.hxx>
      52             : #include <basegfx/polygon/b2dpolygon.hxx>
      53             : #include <basegfx/matrix/b2dhommatrix.hxx>
      54             : #include <com/sun/star/document/XActionLockable.hpp>
      55             : 
      56             : using namespace ::oox::core;
      57             : using namespace ::com::sun::star;
      58             : using namespace ::com::sun::star::uno;
      59             : using namespace ::com::sun::star::beans;
      60             : using namespace ::com::sun::star::frame;
      61             : using namespace ::com::sun::star::text;
      62             : using namespace ::com::sun::star::drawing;
      63             : using namespace ::com::sun::star::style;
      64             : 
      65             : namespace oox { namespace drawingml {
      66             : 
      67             : // ============================================================================
      68             : 
      69         263 : Shape::Shape( const sal_Char* pServiceName )
      70             : : mbIsChild( false )
      71         263 : , mpLinePropertiesPtr( new LineProperties )
      72         263 : , mpFillPropertiesPtr( new FillProperties )
      73         263 : , mpGraphicPropertiesPtr( new GraphicProperties )
      74         263 : , mpCustomShapePropertiesPtr( new CustomShapeProperties )
      75         263 : , mpEffectPropertiesPtr( new EffectProperties )
      76         263 : , mpMasterTextListStyle( new TextListStyle )
      77             : , mnSubType( 0 )
      78             : , meFrameType( FRAMETYPE_GENERIC )
      79             : , mnRotation( 0 )
      80             : , mbFlipH( false )
      81             : , mbFlipV( false )
      82             : , mbHidden( false )
      83        1841 : , mbHiddenMasterShape( false )
      84             : {
      85         263 :     if ( pServiceName )
      86          91 :         msServiceName = OUString::createFromAscii( pServiceName );
      87         263 :     setDefaults();
      88         263 : }
      89             : 
      90           0 : Shape::Shape( const ShapePtr& pSourceShape )
      91             : : maChildren()
      92           0 : , mbIsChild( pSourceShape->mbIsChild )
      93           0 : , mpTextBody(pSourceShape->mpTextBody)
      94           0 : , mpLinePropertiesPtr( pSourceShape->mpLinePropertiesPtr )
      95           0 : , mpFillPropertiesPtr( pSourceShape->mpFillPropertiesPtr )
      96           0 : , mpGraphicPropertiesPtr( pSourceShape->mpGraphicPropertiesPtr )
      97           0 : , mpCustomShapePropertiesPtr( pSourceShape->mpCustomShapePropertiesPtr )
      98           0 : , mpTablePropertiesPtr( pSourceShape->mpTablePropertiesPtr )
      99           0 : , mp3DPropertiesPtr( pSourceShape->mp3DPropertiesPtr )
     100           0 : , mpEffectPropertiesPtr (pSourceShape->mpEffectPropertiesPtr)
     101           0 : , maShapeProperties( pSourceShape->maShapeProperties )
     102           0 : , mpMasterTextListStyle( pSourceShape->mpMasterTextListStyle )
     103             : , mxShape()
     104           0 : , msServiceName( pSourceShape->msServiceName )
     105           0 : , msName( pSourceShape->msName )
     106           0 : , msId( pSourceShape->msId )
     107           0 : , mnSubType( pSourceShape->mnSubType )
     108           0 : , moSubTypeIndex( pSourceShape->moSubTypeIndex )
     109           0 : , maShapeStyleRefs( pSourceShape->maShapeStyleRefs )
     110           0 : , maSize( pSourceShape->maSize )
     111           0 : , maPosition( pSourceShape->maPosition )
     112           0 : , meFrameType( pSourceShape->meFrameType )
     113           0 : , mnRotation( pSourceShape->mnRotation )
     114           0 : , mbFlipH( pSourceShape->mbFlipH )
     115           0 : , mbFlipV( pSourceShape->mbFlipV )
     116           0 : , mbHidden( pSourceShape->mbHidden )
     117           0 : , mbHiddenMasterShape( pSourceShape->mbHiddenMasterShape )
     118           0 : {}
     119             : 
     120             : 
     121         300 : Shape::~Shape()
     122             : {
     123         300 : }
     124             : 
     125           0 : table::TablePropertiesPtr Shape::getTableProperties()
     126             : {
     127           0 :     if ( !mpTablePropertiesPtr.get() )
     128           0 :         mpTablePropertiesPtr.reset( new table::TableProperties() );
     129           0 :     return mpTablePropertiesPtr;
     130             : }
     131             : 
     132         263 : void Shape::setDefaults()
     133             : {
     134         263 :     maDefaultShapeProperties[ PROP_TextAutoGrowHeight ] <<= false;
     135         263 :     maDefaultShapeProperties[ PROP_TextWordWrap ] <<= true;
     136         263 :     maDefaultShapeProperties[ PROP_TextLeftDistance ]  <<= static_cast< sal_Int32 >( 250 );
     137         263 :     maDefaultShapeProperties[ PROP_TextUpperDistance ] <<= static_cast< sal_Int32 >( 125 );
     138         263 :     maDefaultShapeProperties[ PROP_TextRightDistance ] <<= static_cast< sal_Int32 >( 250 );
     139         263 :     maDefaultShapeProperties[ PROP_TextLowerDistance ] <<= static_cast< sal_Int32 >( 125 );
     140         263 :     maDefaultShapeProperties[ PROP_CharHeight ] <<= static_cast< float >( 18.0 );
     141         263 :     maDefaultShapeProperties[ PROP_TextVerticalAdjust ] <<= TextVerticalAdjust_TOP;
     142         263 :     maDefaultShapeProperties[ PROP_ParaAdjust ] <<= static_cast< sal_Int16 >( ParagraphAdjust_LEFT ); // check for RTL?
     143         263 : }
     144             : 
     145           0 : ::oox::vml::OleObjectInfo& Shape::setOleObjectType()
     146             : {
     147             :     OSL_ENSURE( meFrameType == FRAMETYPE_GENERIC, "Shape::setOleObjectType - multiple frame types" );
     148           0 :     meFrameType = FRAMETYPE_OLEOBJECT;
     149           0 :     mxOleObjectInfo.reset( new ::oox::vml::OleObjectInfo( true ) );
     150           0 :     return *mxOleObjectInfo;
     151             : }
     152             : 
     153           0 : ChartShapeInfo& Shape::setChartType( bool bEmbedShapes )
     154             : {
     155             :     OSL_ENSURE( meFrameType == FRAMETYPE_GENERIC, "Shape::setChartType - multiple frame types" );
     156           0 :     meFrameType = FRAMETYPE_CHART;
     157           0 :     msServiceName = CREATE_OUSTRING( "com.sun.star.drawing.OLE2Shape" );
     158           0 :     mxChartShapeInfo.reset( new ChartShapeInfo( bEmbedShapes ) );
     159           0 :     return *mxChartShapeInfo;
     160             : }
     161             : 
     162           1 : void Shape::setDiagramType()
     163             : {
     164             :     OSL_ENSURE( meFrameType == FRAMETYPE_GENERIC, "Shape::setDiagramType - multiple frame types" );
     165           1 :     meFrameType = FRAMETYPE_DIAGRAM;
     166           1 :     msServiceName = CREATE_OUSTRING( "com.sun.star.drawing.GroupShape" );
     167           1 :     mnSubType = 0;
     168           1 : }
     169             : 
     170           0 : void Shape::setTableType()
     171             : {
     172             :     OSL_ENSURE( meFrameType == FRAMETYPE_GENERIC, "Shape::setTableType - multiple frame types" );
     173           0 :     meFrameType = FRAMETYPE_TABLE;
     174           0 :     msServiceName = CREATE_OUSTRING( "com.sun.star.drawing.TableShape" );
     175           0 :     mnSubType = 0;
     176           0 : }
     177             : 
     178           0 : void Shape::setServiceName( const sal_Char* pServiceName )
     179             : {
     180           0 :     if ( pServiceName )
     181           0 :         msServiceName = OUString::createFromAscii( pServiceName );
     182           0 : }
     183             : 
     184             : 
     185         135 : const ShapeStyleRef* Shape::getShapeStyleRef( sal_Int32 nRefType ) const
     186             : {
     187         135 :     ShapeStyleRefMap::const_iterator aIt = maShapeStyleRefs.find( nRefType );
     188         135 :     return (aIt == maShapeStyleRefs.end()) ? 0 : &aIt->second;
     189             : }
     190             : 
     191          18 : void Shape::addShape(
     192             :         ::oox::core::XmlFilterBase& rFilterBase,
     193             :         const Theme* pTheme,
     194             :         const Reference< XShapes >& rxShapes,
     195             :         basegfx::B2DHomMatrix& aTransformation,
     196             :         const awt::Rectangle* pShapeRect,
     197             :         ShapeIdMap* pShapeMap )
     198             : {
     199             :     SAL_INFO("oox", OSL_THIS_FUNC << " id: " << msId);
     200             : 
     201             :     try
     202             :     {
     203          18 :         OUString sServiceName( msServiceName );
     204          18 :         if( !sServiceName.isEmpty() )
     205             :         {
     206          18 :             basegfx::B2DHomMatrix aMatrix( aTransformation );
     207          18 :             Reference< XShape > xShape( createAndInsert( rFilterBase, sServiceName, pTheme, rxShapes, pShapeRect, sal_False, sal_False, aMatrix ) );
     208             : 
     209          18 :             if( pShapeMap && !msId.isEmpty() )
     210             :             {
     211           0 :                 (*pShapeMap)[ msId ] = shared_from_this();
     212             :             }
     213             : 
     214             :             // if this is a group shape, we have to add also each child shape
     215          18 :             Reference< XShapes > xShapes( xShape, UNO_QUERY );
     216          18 :             if ( xShapes.is() )
     217           1 :                 addChildren( rFilterBase, *this, pTheme, xShapes, pShapeRect ? *pShapeRect : awt::Rectangle( maPosition.X, maPosition.Y, maSize.Width, maSize.Height ), pShapeMap, aMatrix );
     218          18 :         }
     219             :     }
     220           0 :     catch( const Exception&  )
     221             :     {
     222             :     }
     223          18 : }
     224             : 
     225          18 : void Shape::applyShapeReference( const Shape& rReferencedShape, bool bUseText )
     226             : {
     227             :     SAL_INFO("oox", "apply shape reference: " << rReferencedShape.msId << " to shape id: " << msId);
     228             : 
     229          18 :     if ( rReferencedShape.mpTextBody.get() && bUseText )
     230          18 :         mpTextBody = TextBodyPtr( new TextBody( *rReferencedShape.mpTextBody.get() ) );
     231             :     else
     232           0 :         mpTextBody.reset();
     233          18 :     maShapeProperties = rReferencedShape.maShapeProperties;
     234          18 :     mpLinePropertiesPtr = LinePropertiesPtr( new LineProperties( *rReferencedShape.mpLinePropertiesPtr.get() ) );
     235          18 :     mpFillPropertiesPtr = FillPropertiesPtr( new FillProperties( *rReferencedShape.mpFillPropertiesPtr.get() ) );
     236          18 :     mpCustomShapePropertiesPtr = CustomShapePropertiesPtr( new CustomShapeProperties( *rReferencedShape.mpCustomShapePropertiesPtr.get() ) );
     237          18 :     mpTablePropertiesPtr = table::TablePropertiesPtr( rReferencedShape.mpTablePropertiesPtr.get() ? new table::TableProperties( *rReferencedShape.mpTablePropertiesPtr.get() ) : NULL );
     238          18 :     mpEffectPropertiesPtr = EffectPropertiesPtr( new EffectProperties( *rReferencedShape.mpEffectPropertiesPtr.get() ) );
     239          18 :     mpMasterTextListStyle = TextListStylePtr( new TextListStyle( *rReferencedShape.mpMasterTextListStyle.get() ) );
     240          18 :     maShapeStyleRefs = rReferencedShape.maShapeStyleRefs;
     241          18 :     maSize = rReferencedShape.maSize;
     242          18 :     maPosition = rReferencedShape.maPosition;
     243          18 :     mnRotation = rReferencedShape.mnRotation;
     244          18 :     mbFlipH = rReferencedShape.mbFlipH;
     245          18 :     mbFlipV = rReferencedShape.mbFlipV;
     246          18 :     mbHidden = rReferencedShape.mbHidden;
     247          18 : }
     248             : 
     249           0 : void Shape::addChildren( ::oox::core::XmlFilterBase& rFilterBase,
     250             :                          const Theme* pTheme,
     251             :                          const Reference< XShapes >& rxShapes,
     252             :                          basegfx::B2DHomMatrix& aTransformation,
     253             :                          const awt::Rectangle* pShapeRect,
     254             :                          ShapeIdMap* pShapeMap )
     255             : {
     256             :     addChildren(rFilterBase, *this, pTheme, rxShapes,
     257             :                 pShapeRect ?
     258             :                  *pShapeRect :
     259             :                  awt::Rectangle( maPosition.X, maPosition.Y, maSize.Width, maSize.Height ),
     260           0 :                 pShapeMap, aTransformation);
     261           0 : }
     262             : 
     263             : struct ActionLockGuard
     264             : {
     265          42 :     explicit ActionLockGuard(Reference<drawing::XShape> const& xShape)
     266          42 :         : m_xLockable(xShape, UNO_QUERY)
     267             :     {
     268          42 :         if (m_xLockable.is()) {
     269          42 :             m_xLockable->addActionLock();
     270             :         }
     271          42 :     }
     272          42 :     ~ActionLockGuard()
     273          42 :     {
     274          42 :         if (m_xLockable.is()) {
     275          42 :             m_xLockable->removeActionLock();
     276             :         }
     277          42 :     }
     278             : private:
     279             :     Reference<document::XActionLockable> m_xLockable;
     280             : };
     281             : 
     282             : // for group shapes, the following method is also adding each child
     283           1 : void Shape::addChildren(
     284             :         XmlFilterBase& rFilterBase,
     285             :         Shape& rMaster,
     286             :         const Theme* pTheme,
     287             :         const Reference< XShapes >& rxShapes,
     288             :         const awt::Rectangle&,
     289             :         ShapeIdMap* pShapeMap,
     290             :         basegfx::B2DHomMatrix& aTransformation )
     291             : {
     292           1 :     basegfx::B2DHomMatrix aChildTransformation;
     293             : 
     294           1 :     aChildTransformation.translate(-maChPosition.X, -maChPosition.Y);
     295           1 :     aChildTransformation.scale(1/(maChSize.Width ? maChSize.Width : 1.0), 1/(maChSize.Height ? maChSize.Height : 1.0));
     296           1 :     aChildTransformation *= aTransformation;
     297             : 
     298             :     OSL_TRACE("parent matrix:\n%f %f %f\n%f %f %f\n%f %f %f",
     299             :               aChildTransformation.get(0, 0),
     300             :               aChildTransformation.get(0, 1),
     301             :               aChildTransformation.get(0, 2),
     302             :               aChildTransformation.get(1, 0),
     303             :               aChildTransformation.get(1, 1),
     304             :               aChildTransformation.get(1, 2),
     305             :               aChildTransformation.get(2, 0),
     306             :               aChildTransformation.get(2, 1),
     307             :               aChildTransformation.get(2, 2));
     308             : 
     309           1 :     std::vector< ShapePtr >::iterator aIter( rMaster.maChildren.begin() );
     310           6 :     while( aIter != rMaster.maChildren.end() ) {
     311           4 :         (*aIter)->setMasterTextListStyle( mpMasterTextListStyle );
     312           4 :         (*aIter++)->addShape( rFilterBase, pTheme, rxShapes, aChildTransformation, NULL, pShapeMap );
     313           1 :     }
     314           1 : }
     315             : 
     316          42 : Reference< XShape > Shape::createAndInsert(
     317             :         ::oox::core::XmlFilterBase& rFilterBase,
     318             :         const OUString& rServiceName,
     319             :         const Theme* pTheme,
     320             :         const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
     321             :         const awt::Rectangle* /* pShapeRect */,
     322             :         sal_Bool bClearText,
     323             :         sal_Bool bDoNotInsertEmptyTextBody,
     324             :         basegfx::B2DHomMatrix& aParentTransformation )
     325             : {
     326          42 :     bool bIsEmbMedia = false;
     327             :     SAL_INFO("oox", OSL_THIS_FUNC << " id: " << msId);
     328             : 
     329          42 :     awt::Rectangle aShapeRectHmm( maPosition.X / 360, maPosition.Y / 360, maSize.Width / 360, maSize.Height / 360 );
     330             : 
     331          42 :     OUString aServiceName;
     332          70 :     if( rServiceName == "com.sun.star.drawing.GraphicObjectShape" &&
     333          28 :         mpGraphicPropertiesPtr && !mpGraphicPropertiesPtr->maAudio.msEmbed.isEmpty() )
     334             :     {
     335           0 :         aServiceName = finalizeServiceName( rFilterBase, "com.sun.star.presentation.MediaShape", aShapeRectHmm );
     336           0 :         bIsEmbMedia = true;
     337             :     }
     338             :     else
     339             :     {
     340          42 :         aServiceName = finalizeServiceName( rFilterBase, rServiceName, aShapeRectHmm );
     341             :     }
     342          42 :     sal_Bool bIsCustomShape = ( aServiceName == "com.sun.star.drawing.CustomShape" ||
     343          42 :                                 aServiceName == "com.sun.star.drawing.ConnectorShape" );
     344             : 
     345          42 :     basegfx::B2DHomMatrix aTransformation;
     346             : 
     347          42 :     if( maSize.Width != 1 || maSize.Height != 1)
     348             :     {
     349             :         // take care there are no zeros used by error
     350             :         aTransformation.scale(
     351             :             maSize.Width ? maSize.Width : 1.0,
     352          42 :             maSize.Height ? maSize.Height : 1.0 );
     353             :     }
     354             : 
     355          42 :     if( mbFlipH || mbFlipV || mnRotation != 0)
     356             :     {
     357             :         // calculate object's center
     358           2 :         basegfx::B2DPoint aCenter(0.5, 0.5);
     359           2 :         aCenter *= aTransformation;
     360             : 
     361             :         // center object at origin
     362           2 :         aTransformation.translate( -aCenter.getX(), -aCenter.getY() );
     363             : 
     364           2 :         if( !bIsCustomShape && ( mbFlipH || mbFlipV ) )
     365             :         {
     366             :             // mirror around object's center
     367           0 :             aTransformation.scale( mbFlipH ? -1.0 : 1.0, mbFlipV ? -1.0 : 1.0 );
     368             :         }
     369             : 
     370           2 :         if( mnRotation != 0 )
     371             :         {
     372             :             // rotate around object's center
     373           0 :             aTransformation.rotate( F_PI180 * ( (double)mnRotation / 60000.0 ) );
     374             :         }
     375             : 
     376             :         // move object back from center
     377           2 :         aTransformation.translate( aCenter.getX(), aCenter.getY() );
     378             :     }
     379             : 
     380          42 :     if( maPosition.X != 0 || maPosition.Y != 0)
     381             :     {
     382             :         // if global position is used, add it to transformation
     383          28 :         aTransformation.translate( maPosition.X, maPosition.Y );
     384             :     }
     385             : 
     386          42 :     aTransformation = aParentTransformation*aTransformation;
     387          42 :     aParentTransformation = aTransformation;
     388          42 :     aTransformation.scale(1/360.0, 1/360.0);
     389             : 
     390             :     // special for lineshape
     391          42 :     if ( aServiceName == "com.sun.star.drawing.LineShape" )
     392             :     {
     393           0 :         ::basegfx::B2DPolygon aPoly;
     394           0 :         aPoly.insert( 0, ::basegfx::B2DPoint( 0, 0 ) );
     395           0 :         aPoly.insert( 1, ::basegfx::B2DPoint( maSize.Width ? 1 : 0, maSize.Height ? 1 : 0 ) );
     396           0 :         aPoly.transform( aTransformation );
     397             : 
     398             :         // now creating the corresponding PolyPolygon
     399           0 :         sal_Int32 i, nNumPoints = aPoly.count();
     400           0 :         uno::Sequence< awt::Point > aPointSequence( nNumPoints );
     401           0 :         awt::Point* pPoints = aPointSequence.getArray();
     402           0 :         for( i = 0; i < nNumPoints; ++i )
     403             :         {
     404           0 :             const ::basegfx::B2DPoint aPoint( aPoly.getB2DPoint( i ) );
     405           0 :             pPoints[ i ] = awt::Point( static_cast< sal_Int32 >( aPoint.getX() ), static_cast< sal_Int32 >( aPoint.getY() ) );
     406           0 :         }
     407           0 :         uno::Sequence< uno::Sequence< awt::Point > > aPolyPolySequence( 1 );
     408           0 :         aPolyPolySequence.getArray()[ 0 ] = aPointSequence;
     409             : 
     410           0 :         maShapeProperties[ PROP_PolyPolygon ] <<= aPolyPolySequence;
     411             :     }
     412          42 :     else if ( aServiceName == "com.sun.star.drawing.ConnectorShape" )
     413             :     {
     414           0 :         ::basegfx::B2DPolygon aPoly;
     415           0 :         aPoly.insert( 0, ::basegfx::B2DPoint( 0, 0 ) );
     416           0 :         aPoly.insert( 1, ::basegfx::B2DPoint( maSize.Width ? 1 : 0, maSize.Height ? 1 : 0 ) );
     417           0 :         aPoly.transform( aTransformation );
     418             : 
     419           0 :         basegfx::B2DPoint aStartPosition( aPoly.getB2DPoint( 0 ) );
     420           0 :         basegfx::B2DPoint aEndPosition( aPoly.getB2DPoint( 1 ) );
     421           0 :         awt::Point aAWTStartPosition( static_cast< sal_Int32 >( aStartPosition.getX() ), static_cast< sal_Int32 >( aStartPosition.getY() ) );
     422           0 :         awt::Point aAWTEndPosition( static_cast< sal_Int32 >( aEndPosition.getX() ), static_cast< sal_Int32 >( aEndPosition.getY() ) );
     423             : 
     424           0 :         maShapeProperties[ PROP_StartPosition ] <<= aAWTStartPosition;
     425           0 :         maShapeProperties[ PROP_EndPosition ] <<= aAWTEndPosition;
     426             :     }
     427             :     else
     428             :     {
     429             :         // now set transformation for this object
     430          42 :         HomogenMatrix3 aMatrix;
     431             : 
     432             : 
     433          42 :         aMatrix.Line1.Column1 = aTransformation.get(0,0);
     434          42 :         aMatrix.Line1.Column2 = aTransformation.get(0,1);
     435          42 :         aMatrix.Line1.Column3 = aTransformation.get(0,2);
     436             : 
     437          42 :         aMatrix.Line2.Column1 = aTransformation.get(1,0);
     438          42 :         aMatrix.Line2.Column2 = aTransformation.get(1,1);
     439          42 :         aMatrix.Line2.Column3 = aTransformation.get(1,2);
     440             : 
     441          42 :         aMatrix.Line3.Column1 = aTransformation.get(2,0);
     442          42 :         aMatrix.Line3.Column2 = aTransformation.get(2,1);
     443          42 :         aMatrix.Line3.Column3 = aTransformation.get(2,2);
     444             : 
     445          42 :         maShapeProperties[ PROP_Transformation ] <<= aMatrix;
     446             :     }
     447             : 
     448          42 :     Reference< lang::XMultiServiceFactory > xServiceFact( rFilterBase.getModel(), UNO_QUERY_THROW );
     449          42 :     if ( !mxShape.is() )
     450          42 :         mxShape = Reference< drawing::XShape >( xServiceFact->createInstance( aServiceName ), UNO_QUERY_THROW );
     451             : 
     452          42 :     Reference< XPropertySet > xSet( mxShape, UNO_QUERY );
     453          42 :     if( mxShape.is() && xSet.is() )
     454             :     {
     455          42 :         if( !msName.isEmpty() )
     456             :         {
     457          36 :             Reference< container::XNamed > xNamed( mxShape, UNO_QUERY );
     458          36 :             if( xNamed.is() )
     459          36 :                 xNamed->setName( msName );
     460             :         }
     461          42 :         rxShapes->add( mxShape );
     462             : 
     463          42 :         if ( mbHidden || mbHiddenMasterShape )
     464             :         {
     465             :             SAL_INFO("oox", "invisible shape with id: " << msId);
     466           0 :             const OUString sVisible( CREATE_OUSTRING( "Visible" ) );
     467           0 :             xSet->setPropertyValue( sVisible, Any( sal_False ) );
     468             :         }
     469             : 
     470          42 :         ActionLockGuard const alg(mxShape);
     471             : 
     472             :         // sj: removing default text of placeholder objects such as SlideNumberShape or HeaderShape
     473          42 :         if ( bClearText )
     474             :         {
     475           7 :             uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY );
     476           7 :             if ( xText.is() )
     477             :             {
     478           7 :                 OUString aEmpty;
     479           7 :                 xText->setString( aEmpty );
     480           7 :             }
     481             :         }
     482             : 
     483          42 :         const GraphicHelper& rGraphicHelper = rFilterBase.getGraphicHelper();
     484             : 
     485          42 :         LineProperties aLineProperties;
     486          42 :         aLineProperties.maLineFill.moFillType = XML_noFill;
     487          42 :         sal_Int32 nLinePhClr = -1;
     488          42 :         FillProperties aFillProperties;
     489          42 :         aFillProperties.moFillType = XML_noFill;
     490          42 :         sal_Int32 nFillPhClr = -1;
     491          42 :         EffectProperties aEffectProperties;
     492             :         // TODO: use ph color when applying effect properties
     493             :         //sal_Int32 nEffectPhClr = -1;
     494             : 
     495          42 :         if( pTheme )
     496             :         {
     497          39 :             if( const ShapeStyleRef* pLineRef = getShapeStyleRef( XML_lnRef ) )
     498             :             {
     499           8 :                 if( const LineProperties* pLineProps = pTheme->getLineStyle( pLineRef->mnThemedIdx ) )
     500           7 :                     aLineProperties.assignUsed( *pLineProps );
     501           8 :                 nLinePhClr = pLineRef->maPhClr.getColor( rGraphicHelper );
     502             :             }
     503          39 :             if( const ShapeStyleRef* pFillRef = getShapeStyleRef( XML_fillRef ) )
     504             :             {
     505           8 :                 if( const FillProperties* pFillProps = pTheme->getFillStyle( pFillRef->mnThemedIdx ) )
     506           4 :                     aFillProperties.assignUsed( *pFillProps );
     507           8 :                 nFillPhClr = pFillRef->maPhClr.getColor( rGraphicHelper );
     508             :             }
     509          39 :             if( const ShapeStyleRef* pEffectRef = getShapeStyleRef( XML_effectRef ) )
     510             :             {
     511           8 :                 if( const EffectProperties* pEffectProps = pTheme->getEffectStyle( pEffectRef->mnThemedIdx ) )
     512           0 :                     aEffectProperties.assignUsed( *pEffectProps );
     513             :                 // TODO: use ph color when applying effect properties
     514             :                 // nEffectPhClr = pEffectRef->maPhClr.getColor( rGraphicHelper );
     515             :             }
     516             :         }
     517             : 
     518          42 :         aLineProperties.assignUsed( getLineProperties() );
     519          42 :         aFillProperties.assignUsed( getFillProperties() );
     520          42 :         aEffectProperties.assignUsed ( getEffectProperties() );
     521             : 
     522          42 :         ShapePropertyMap aShapeProps( rFilterBase.getModelObjectHelper() );
     523             : 
     524             :         // add properties from textbody to shape properties
     525          42 :         if( mpTextBody.get() )
     526             :         {
     527          22 :             mpTextBody->getTextProperties().pushRotationAdjustments( mnRotation );
     528          22 :             aShapeProps.assignUsed( mpTextBody->getTextProperties().maPropertyMap );
     529             :         }
     530             : 
     531             :         // applying properties
     532          42 :         aShapeProps.assignUsed( getShapeProperties() );
     533          42 :         aShapeProps.assignUsed( maDefaultShapeProperties );
     534          42 :         if ( bIsEmbMedia || aServiceName == "com.sun.star.drawing.GraphicObjectShape" )
     535          14 :             mpGraphicPropertiesPtr->pushToPropMap( aShapeProps, rGraphicHelper );
     536          42 :         if ( mpTablePropertiesPtr.get() && aServiceName == "com.sun.star.drawing.TableShape" )
     537           0 :             mpTablePropertiesPtr->pushToPropSet( rFilterBase, xSet, mpMasterTextListStyle );
     538          42 :         aFillProperties.pushToPropMap( aShapeProps, rGraphicHelper, mnRotation, nFillPhClr, mbFlipH, mbFlipV );
     539          42 :         aLineProperties.pushToPropMap( aShapeProps, rGraphicHelper, nLinePhClr );
     540             :         // TODO: use ph color when applying effect properties
     541          42 :         aEffectProperties.pushToPropMap( aShapeProps, rGraphicHelper );
     542             : 
     543             :         // applying autogrowheight property before setting shape size, because
     544             :         // the shape size might be changed if currently autogrowheight is true
     545             :         // we must also check that the PropertySet supports the property.
     546          42 :         Reference< XPropertySetInfo > xSetInfo( xSet->getPropertySetInfo() );
     547          42 :         const OUString& rPropName = PropertyMap::getPropertyName( PROP_TextAutoGrowHeight );
     548          42 :         if( xSetInfo.is() && xSetInfo->hasPropertyByName( rPropName ) )
     549          40 :             if( aShapeProps.hasProperty( PROP_TextAutoGrowHeight ) )
     550          40 :                 xSet->setPropertyValue( rPropName, Any( false ) );
     551             : 
     552             :         // do not set properties at a group shape (this causes assertions from svx)
     553          42 :         if( aServiceName != "com.sun.star.drawing.GroupShape" )
     554             :         {
     555          41 :             PropertySet( xSet ).setProperties( aShapeProps );
     556             :         }
     557             : 
     558          42 :         if( bIsCustomShape )
     559             :         {
     560          10 :             if ( mbFlipH )
     561           2 :                 mpCustomShapePropertiesPtr->setMirroredX( sal_True );
     562          10 :             if ( mbFlipV )
     563           0 :                 mpCustomShapePropertiesPtr->setMirroredY( sal_True );
     564          10 :             if( getTextBody() )
     565             :             {
     566           5 :                 sal_Int32 nTextRotateAngle = static_cast< sal_Int32 >( getTextBody()->getTextProperties().moRotation.get( 0 ) );
     567           5 :                 mpCustomShapePropertiesPtr->setTextRotateAngle( nTextRotateAngle / 60000 );
     568             :             }
     569             : 
     570             :             SAL_INFO("oox", "==cscode== shape name: '" << msName << "'");
     571          10 :             mpCustomShapePropertiesPtr->pushToPropSet( rFilterBase, xSet, mxShape );
     572             :         }
     573          32 :         else if( getTextBody() )
     574          17 :             getTextBody()->getTextProperties().pushVertSimulation();
     575             : 
     576             :         // in some cases, we don't have any text body.
     577          42 :         if( getTextBody() && ( !bDoNotInsertEmptyTextBody || !mpTextBody->isEmpty() ) )
     578             :         {
     579          18 :             Reference < XText > xText( mxShape, UNO_QUERY );
     580          18 :             if ( xText.is() )   // not every shape is supporting an XText interface (e.g. GroupShape)
     581             :             {
     582          18 :                 TextCharacterProperties aCharStyleProperties;
     583          18 :                 if( const ShapeStyleRef* pFontRef = getShapeStyleRef( XML_fontRef ) )
     584             :                 {
     585           3 :                     if( pTheme )
     586           3 :                         if( const TextCharacterProperties* pCharProps = pTheme->getFontStyle( pFontRef->mnThemedIdx ) )
     587           3 :                             aCharStyleProperties.assignUsed( *pCharProps );
     588             :                     SAL_INFO("oox", "use font color");
     589           3 :                     aCharStyleProperties.maCharColor.assignIfUsed( pFontRef->maPhClr );
     590             :                 }
     591             : 
     592          18 :                 Reference < XTextCursor > xAt = xText->createTextCursor();
     593          18 :                 getTextBody()->insertAt( rFilterBase, xText, xAt, aCharStyleProperties, mpMasterTextListStyle );
     594          18 :             }
     595          42 :         }
     596             :     }
     597             : 
     598          42 :     if( mxShape.is() )
     599          42 :         finalizeXShape( rFilterBase, rxShapes );
     600             : 
     601          42 :     return mxShape;
     602             : }
     603             : 
     604          53 : void Shape::setTextBody(const TextBodyPtr & pTextBody)
     605             : {
     606          53 :     mpTextBody = pTextBody;
     607          53 : }
     608             : 
     609             : 
     610         264 : TextBodyPtr Shape::getTextBody()
     611             : {
     612         264 :     return mpTextBody;
     613             : }
     614             : 
     615           0 : void Shape::moveAllToPosition( const awt::Point &rPoint )
     616             : {
     617           0 :     setPosition( awt::Point( rPoint.X + maPosition.X, rPoint.Y + maPosition.Y ) );
     618           0 :     for( ::std::vector<ShapePtr>::const_iterator aIt = maChildren.begin(), aEnd = maChildren.end();aIt != aEnd; ++aIt )
     619           0 :         (*aIt)->moveAllToPosition( rPoint );
     620           0 : }
     621             : 
     622          28 : void Shape::setMasterTextListStyle( const TextListStylePtr& pMasterTextListStyle )
     623             : {
     624             :     SAL_INFO("oox", "set master text list style to shape id: " << msId);
     625             : 
     626          28 :     mpMasterTextListStyle = pMasterTextListStyle;
     627          28 : }
     628             : 
     629          42 : OUString Shape::finalizeServiceName( XmlFilterBase& rFilter, const OUString& rServiceName, const awt::Rectangle& rShapeRect )
     630             : {
     631          42 :     OUString aServiceName = rServiceName;
     632          42 :     switch( meFrameType )
     633             :     {
     634             :         case FRAMETYPE_OLEOBJECT:
     635             :         {
     636           0 :             awt::Size aOleSize( rShapeRect.Width, rShapeRect.Height );
     637           0 :             if( rFilter.getOleObjectHelper().importOleObject( maShapeProperties, *mxOleObjectInfo, aOleSize ) )
     638           0 :                 aServiceName = CREATE_OUSTRING( "com.sun.star.drawing.OLE2Shape" );
     639             : 
     640             :             // get the path to the representation graphic
     641           0 :             OUString aGraphicPath;
     642           0 :             if( !mxOleObjectInfo->maShapeId.isEmpty() )
     643           0 :                 if( ::oox::vml::Drawing* pVmlDrawing = rFilter.getVmlDrawing() )
     644           0 :                     if( const ::oox::vml::ShapeBase* pVmlShape = pVmlDrawing->getShapes().getShapeById( mxOleObjectInfo->maShapeId, true ) )
     645           0 :                         aGraphicPath = pVmlShape->getGraphicPath();
     646             : 
     647             :             // import and store the graphic
     648           0 :             if( !aGraphicPath.isEmpty() )
     649             :             {
     650           0 :                 Reference< graphic::XGraphic > xGraphic = rFilter.getGraphicHelper().importEmbeddedGraphic( aGraphicPath );
     651           0 :                 if( xGraphic.is() )
     652           0 :                     maShapeProperties[ PROP_Graphic ] <<= xGraphic;
     653           0 :             }
     654             :         }
     655           0 :         break;
     656             : 
     657             :         default:;
     658             :     }
     659          42 :     return aServiceName;
     660             : }
     661             : 
     662          42 : void Shape::finalizeXShape( XmlFilterBase& rFilter, const Reference< XShapes >& rxShapes )
     663             : {
     664          42 :     switch( meFrameType )
     665             :     {
     666             :         case FRAMETYPE_CHART:
     667             :         {
     668             :             OSL_ENSURE( !mxChartShapeInfo->maFragmentPath.isEmpty(), "Shape::finalizeXShape - missing chart fragment" );
     669           0 :             if( mxShape.is() && !mxChartShapeInfo->maFragmentPath.isEmpty() ) try
     670             :             {
     671             :                 // set the chart2 OLE class ID at the OLE shape
     672           0 :                 PropertySet aShapeProp( mxShape );
     673           0 :                 aShapeProp.setProperty( PROP_CLSID, CREATE_OUSTRING( "12dcae26-281f-416f-a234-c3086127382e" ) );
     674             : 
     675             :                 // get the XModel interface of the embedded object from the OLE shape
     676           0 :                 Reference< frame::XModel > xDocModel;
     677           0 :                 aShapeProp.getProperty( xDocModel, PROP_Model );
     678           0 :                 Reference< chart2::XChartDocument > xChartDoc( xDocModel, UNO_QUERY_THROW );
     679             : 
     680             :                 // load the chart data from the XML fragment
     681           0 :                 chart::ChartSpaceModel aModel;
     682           0 :                 rFilter.importFragment( new chart::ChartSpaceFragment( rFilter, mxChartShapeInfo->maFragmentPath, aModel ) );
     683             : 
     684             :                 // convert imported chart model to chart document
     685           0 :                 Reference< drawing::XShapes > xExternalPage;
     686           0 :                 if( !mxChartShapeInfo->mbEmbedShapes )
     687           0 :                     xExternalPage = rxShapes;
     688           0 :                 if( rFilter.getChartConverter() )
     689           0 :                     rFilter.getChartConverter()->convertFromModel( rFilter, aModel, xChartDoc, xExternalPage, mxShape->getPosition(), mxShape->getSize() );
     690             :             }
     691           0 :             catch( Exception& )
     692             :             {
     693             :             }
     694             :         }
     695           0 :         break;
     696             : 
     697             :         default:;
     698             :     }
     699          42 : }
     700             : 
     701             : // ============================================================================
     702             : 
     703          51 : } }
     704             : 
     705             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10