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

Generated by: LCOV version 1.10