LCOV - code coverage report
Current view: top level - include/oox/drawingml - shape.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 34 38 89.5 %
Date: 2014-04-11 Functions: 35 40 87.5 %
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             : #ifndef INCLUDED_OOX_DRAWINGML_SHAPE_HXX
      21             : #define INCLUDED_OOX_DRAWINGML_SHAPE_HXX
      22             : 
      23             : #include <oox/helper/propertymap.hxx>
      24             : #include <oox/drawingml/drawingmltypes.hxx>
      25             : #include <oox/drawingml/customshapeproperties.hxx>
      26             : #include <oox/drawingml/textliststyle.hxx>
      27             : #include <oox/drawingml/shape3dproperties.hxx>
      28             : 
      29             : #include <com/sun/star/frame/XModel.hpp>
      30             : #include <com/sun/star/drawing/XDrawPage.hpp>
      31             : #include <boost/shared_ptr.hpp>
      32             : #include <boost/enable_shared_from_this.hpp>
      33             : #include <basegfx/matrix/b2dhommatrix.hxx>
      34             : #include <vector>
      35             : #include <map>
      36             : #include <oox/dllapi.h>
      37             : 
      38             : namespace oox { namespace vml {
      39             :     struct OleObjectInfo;
      40             : } }
      41             : 
      42             : namespace oox { namespace drawingml {
      43             : 
      44             : class CustomShapeProperties;
      45             : typedef boost::shared_ptr< CustomShapeProperties > CustomShapePropertiesPtr;
      46             : 
      47             : typedef ::std::map< OUString, ShapePtr > ShapeIdMap;
      48             : 
      49        5280 : struct ShapeStyleRef
      50             : {
      51             :     Color               maPhClr;
      52             :     sal_Int32           mnThemedIdx;
      53             : };
      54             : 
      55             : typedef ::std::map< sal_Int32, ShapeStyleRef > ShapeStyleRefMap;
      56             : 
      57             : /** Additional information for a chart embedded in a drawing shape. */
      58          65 : struct ChartShapeInfo
      59             : {
      60             :     OUString     maFragmentPath;     ///< Path to related XML stream, e.g. for charts.
      61             :     bool                mbEmbedShapes;      ///< True = load chart shapes into chart, false = load into parent drawpage.
      62             : 
      63          65 :     explicit     ChartShapeInfo( bool bEmbedShapes ) : mbEmbedShapes( bEmbedShapes ) {}
      64             : };
      65             : 
      66             : class OOX_DLLPUBLIC Shape
      67             :     : public boost::enable_shared_from_this< Shape >
      68             : {
      69             : public:
      70             : 
      71             :     explicit Shape( const sal_Char* pServiceType = 0, bool bDefaultHeight = true );
      72             :     explicit Shape( const ShapePtr& pSourceShape );
      73             :     virtual ~Shape();
      74             : 
      75         166 :     OUString&                  getServiceName(){ return msServiceName; }
      76             :     void                            setServiceName( const sal_Char* pServiceName );
      77             : 
      78        2454 :     PropertyMap&                    getShapeProperties(){ return maShapeProperties; }
      79             : 
      80        4120 :     LineProperties&          getLineProperties() { return *mpLinePropertiesPtr; }
      81             :     const LineProperties&    getLineProperties() const { return *mpLinePropertiesPtr; }
      82             : 
      83        9513 :     FillProperties&          getFillProperties() { return *mpFillPropertiesPtr; }
      84             :     const FillProperties&    getFillProperties() const { return *mpFillPropertiesPtr; }
      85             : 
      86         167 :     GraphicProperties&       getGraphicProperties() { return *mpGraphicPropertiesPtr; }
      87             :     const GraphicProperties& getGraphicProperties() const { return *mpGraphicPropertiesPtr; }
      88             : 
      89        2120 :     CustomShapePropertiesPtr        getCustomShapeProperties(){ return mpCustomShapePropertiesPtr; }
      90             : 
      91             :     Shape3DProperties&              get3DProperties() { return *mp3DPropertiesPtr; }
      92             :     const Shape3DProperties&        get3DProperties() const { return *mp3DPropertiesPtr; }
      93             : 
      94             :     table::TablePropertiesPtr       getTableProperties();
      95             : 
      96        2357 :     EffectProperties&               getEffectProperties() { return *mpEffectPropertiesPtr; }
      97             : 
      98         128 :     void                              setChildPosition( com::sun::star::awt::Point nPosition ){ maChPosition = nPosition; }
      99         128 :     void                              setChildSize( com::sun::star::awt::Size aSize ){ maChSize = aSize; }
     100             : 
     101        2706 :     void                              setPosition( com::sun::star::awt::Point nPosition ){ maPosition = nPosition; }
     102         127 :     const com::sun::star::awt::Point& getPosition() const { return maPosition; }
     103             : 
     104        2053 :     void                              setSize( com::sun::star::awt::Size aSize ){ maSize = aSize; }
     105           0 :     const com::sun::star::awt::Size&  getSize() const { return maSize; }
     106             : 
     107        2053 :     void                            setRotation( sal_Int32 nRotation ) { mnRotation = nRotation; }
     108        2039 :     void                            setFlip( bool bFlipH, bool bFlipV ) { mbFlipH = bFlipH; mbFlipV = bFlipV; }
     109        1218 :     void                            addChild( const ShapePtr pChildPtr ) { maChildren.push_back( pChildPtr ); }
     110        2664 :     std::vector< ShapePtr >&        getChildren() { return maChildren; }
     111             : 
     112        1167 :     void                            setName( const OUString& rName ) { msName = rName; }
     113           3 :     OUString                       getName( ) { return msName; }
     114        1164 :     void                            setId( const OUString& rId ) { msId = rId; }
     115             :     OUString                        getId() { return msId; }
     116        1161 :     void                            setHidden( bool bHidden ) { mbHidden = bHidden; }
     117             :     bool                            getHidden() const { return mbHidden; };
     118           0 :     void                            setHiddenMasterShape( bool bHiddenMasterShape ) { mbHiddenMasterShape = bHiddenMasterShape; }
     119         264 :     void                            setSubType( sal_Int32 nSubType ) { mnSubType = nSubType; }
     120        1134 :     sal_Int32                       getSubType() const { return mnSubType; }
     121         163 :     void                            setSubTypeIndex( sal_Int32 nSubTypeIndex ) { moSubTypeIndex = nSubTypeIndex; }
     122        2747 :     const OptValue< sal_Int32 >&    getSubTypeIndex() const { return moSubTypeIndex; }
     123             : 
     124             :     // setDefaults has to be called if styles are imported (OfficeXML is not storing properties having the default value)
     125             :     void                            setDefaults(bool bHeight);
     126             : 
     127             :     ::oox::vml::OleObjectInfo&      setOleObjectType();
     128             :     ChartShapeInfo&                 setChartType( bool bEmbedShapes );
     129             :     void                            setDiagramType();
     130             :     void                            setTableType();
     131             : 
     132             :     void                setTextBody(const TextBodyPtr & pTextBody);
     133             :     TextBodyPtr         getTextBody();
     134             :     void                setMasterTextListStyle( const TextListStylePtr& pMasterTextListStyle );
     135          28 :     TextListStylePtr    getMasterTextListStyle() const { return mpMasterTextListStyle; }
     136             : 
     137        2640 :     ShapeStyleRefMap&        getShapeStyleRefs() { return maShapeStyleRefs; }
     138             :     const ShapeStyleRefMap&  getShapeStyleRefs() const { return maShapeStyleRefs; }
     139             :     const ShapeStyleRef*            getShapeStyleRef( sal_Int32 nRefType ) const;
     140             : 
     141             :     // addShape is creating and inserting the corresponding XShape.
     142             :     void                addShape(
     143             :                             ::oox::core::XmlFilterBase& rFilterBase,
     144             :                             const Theme* pTheme,
     145             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
     146             :                             basegfx::B2DHomMatrix& aTransformation,
     147             :                             FillProperties& rShapeOrParentShapeFillProps,
     148             :                             const ::com::sun::star::awt::Rectangle* pShapeRect = 0,
     149             :                             ShapeIdMap* pShapeMap = 0 );
     150             : 
     151             :     void                dropChildren() { maChildren.clear(); }
     152             : 
     153             :     void                addChildren(
     154             :                             ::oox::core::XmlFilterBase& rFilterBase,
     155             :                             const Theme* pTheme,
     156             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
     157             :                             basegfx::B2DHomMatrix& aTransformation,
     158             :                             const ::com::sun::star::awt::Rectangle* pShapeRect = 0,
     159             :                             ShapeIdMap* pShapeMap = 0 );
     160             : 
     161           0 :     void                setXShape( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rXShape )
     162           0 :                             { mxShape = rXShape; };
     163             :     const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > &
     164         904 :                         getXShape() const { return mxShape; }
     165             : 
     166             :     virtual void        applyShapeReference( const Shape& rReferencedShape, bool bUseText = true );
     167             :     const ::std::vector<OUString>&
     168          78 :                         getExtDrawings() { return maExtDrawings; }
     169          20 :     void                addExtDrawingRelId( const OUString &rRelId ) { maExtDrawings.push_back( rRelId ); }
     170             :     void                setLockedCanvas(bool bLockedCanvas);
     171             :     bool                getLockedCanvas();
     172             :     void                setWps(bool bWps);
     173             :     bool                getWps();
     174             :     const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> &
     175          17 :                         getDiagramDoms() { return maDiagramDoms; }
     176          37 :     void                setDiagramDoms(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& rDiagramDoms) { maDiagramDoms = rDiagramDoms; }
     177             :     com::sun::star::uno::Sequence< com::sun::star::uno::Sequence< com::sun::star::uno::Any > >resolveRelationshipsOfTypeFromOfficeDoc(
     178             :                                                                           core::XmlFilterBase& rFilter, const OUString& sFragment, const OUString& sType );
     179             : protected:
     180             : 
     181             :     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     182             :                         createAndInsert(
     183             :                             ::oox::core::XmlFilterBase& rFilterBase,
     184             :                             const OUString& rServiceName,
     185             :                             const Theme* pTheme,
     186             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
     187             :                             const ::com::sun::star::awt::Rectangle* pShapeRect,
     188             :                             bool bClearText,
     189             :                             bool bDoNotInsertEmptyTextBody,
     190             :                             basegfx::B2DHomMatrix& aTransformation,
     191             :                             FillProperties& rShapeOrParentShapeFillProps
     192             :                              );
     193             : 
     194             :     void                addChildren(
     195             :                             ::oox::core::XmlFilterBase& rFilterBase,
     196             :                             Shape& rMaster,
     197             :                             const Theme* pTheme,
     198             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
     199             :                             const ::com::sun::star::awt::Rectangle& rClientRect,
     200             :                             ShapeIdMap* pShapeMap,
     201             :                             basegfx::B2DHomMatrix& aTransformation );
     202             : 
     203             :     void                keepDiagramCompatibilityInfo( ::oox::core::XmlFilterBase& rFilterBase );
     204             : 
     205             :     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     206             :                         renderDiagramToGraphic( ::oox::core::XmlFilterBase& rFilterBase );
     207             : 
     208             :     virtual OUString finalizeServiceName(
     209             :                             ::oox::core::XmlFilterBase& rFilter,
     210             :                             const OUString& rServiceName,
     211             :                             const ::com::sun::star::awt::Rectangle& rShapeRect );
     212             : 
     213             :     virtual void        finalizeXShape(
     214             :                             ::oox::core::XmlFilterBase& rFilter,
     215             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes );
     216             : 
     217             :     void                putPropertyToGrabBag(
     218             :                             const OUString& sPropertyName, const ::com::sun::star::uno::Any& aPropertyValue );
     219             :     void                putPropertyToGrabBag(
     220             :                             const ::com::sun::star::beans::PropertyValue& pProperty );
     221             :     void                putPropertiesToGrabBag(
     222             :                             const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aProperties );
     223             : 
     224             :     std::vector< ShapePtr >     maChildren;               // only used for group shapes
     225             :     com::sun::star::awt::Size   maChSize;                 // only used for group shapes
     226             :     com::sun::star::awt::Point  maChPosition;             // only used for group shapes
     227             :     com::sun::star::awt::Size   maAbsoluteSize;           // only used for group shapes
     228             :     com::sun::star::awt::Point  maAbsolutePosition;       // only used for group shapes
     229             :     bool                        mbIsChild;
     230             : 
     231             :     TextBodyPtr                 mpTextBody;
     232             :     LinePropertiesPtr           mpLinePropertiesPtr;
     233             :     FillPropertiesPtr           mpFillPropertiesPtr;
     234             :     GraphicPropertiesPtr        mpGraphicPropertiesPtr;
     235             :     CustomShapePropertiesPtr    mpCustomShapePropertiesPtr;
     236             :     table::TablePropertiesPtr   mpTablePropertiesPtr;
     237             :     Shape3DPropertiesPtr        mp3DPropertiesPtr;
     238             :     EffectPropertiesPtr         mpEffectPropertiesPtr;
     239             :     PropertyMap                 maShapeProperties;
     240             :     PropertyMap                 maDefaultShapeProperties;
     241             :     TextListStylePtr            mpMasterTextListStyle;
     242             :     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > mxShape;
     243             : 
     244             :     OUString       msServiceName;
     245             :     OUString       msName;
     246             :     OUString       msId;
     247             :     sal_Int32           mnSubType;      // if this type is not zero, then the shape is a placeholder
     248             :     OptValue< sal_Int32 >   moSubTypeIndex;
     249             : 
     250             :     ShapeStyleRefMap   maShapeStyleRefs;
     251             : 
     252             :     com::sun::star::awt::Size       maSize;
     253             :     com::sun::star::awt::Point      maPosition;
     254             :     ::std::vector<OUString>    maExtDrawings;
     255             : 
     256             : private:
     257             :     enum FrameType
     258             :     {
     259             :         FRAMETYPE_GENERIC,          ///< Generic shape, no special type.
     260             :         FRAMETYPE_OLEOBJECT,        ///< OLE object embedded in a shape.
     261             :         FRAMETYPE_CHART,            ///< Chart embedded in a shape.
     262             :         FRAMETYPE_DIAGRAM,          ///< Complex diagram drawing shape.
     263             :         FRAMETYPE_TABLE             ///< A table embedded in a shape.
     264             :     };
     265             : 
     266             :     typedef ::boost::shared_ptr< ::oox::vml::OleObjectInfo >    OleObjectInfoRef;
     267             :     typedef ::boost::shared_ptr< ChartShapeInfo >               ChartShapeInfoRef;
     268             : 
     269             :     FrameType           meFrameType;        ///< Type for graphic frame shapes.
     270             :     OleObjectInfoRef    mxOleObjectInfo;    ///< Additional data for OLE objects.
     271             :     ChartShapeInfoRef   mxChartShapeInfo;   ///< Additional data for chart shapes.
     272             : 
     273             :     sal_Int32                       mnRotation;
     274             :     bool                            mbFlipH;
     275             :     bool                            mbFlipV;
     276             :     bool                            mbHidden;
     277             :     bool                            mbHiddenMasterShape; // master shapes can be hidden in layout slides
     278             :                                                          // we need separate flag because we don't want
     279             :                                                          // to propagate it when applying reference shape
     280             :     bool mbLockedCanvas; ///< Is this shape part of a locked canvas?
     281             :     bool mbWps; ///< Is this a wps shape?
     282             : 
     283             :     com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> maDiagramDoms;
     284             : };
     285             : 
     286             : } }
     287             : 
     288             : #endif // INCLUDED_OOX_DRAWINGML_SHAPE_HXX
     289             : 
     290             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10