LCOV - code coverage report
Current view: top level - include/oox/drawingml - shape.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 49 51 96.1 %
Date: 2015-06-13 12:38:46 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 <memory>
      31             : #include <basegfx/matrix/b2dhommatrix.hxx>
      32             : #include <vector>
      33             : #include <map>
      34             : #include <oox/dllapi.h>
      35             : 
      36             : namespace oox { namespace vml {
      37             :     struct OleObjectInfo;
      38             : } }
      39             : 
      40             : namespace oox { namespace drawingml {
      41             : 
      42             : class CustomShapeProperties;
      43             : typedef std::shared_ptr< CustomShapeProperties > CustomShapePropertiesPtr;
      44             : 
      45             : typedef ::std::map< OUString, ShapePtr > ShapeIdMap;
      46             : 
      47       11120 : struct ShapeStyleRef
      48             : {
      49             :     Color               maPhClr;
      50             :     sal_Int32           mnThemedIdx;
      51        6852 :     ShapeStyleRef() : mnThemedIdx(0) {}
      52             : };
      53             : 
      54             : typedef ::std::map< sal_Int32, ShapeStyleRef > ShapeStyleRefMap;
      55             : 
      56             : /** Additional information for a chart embedded in a drawing shape. */
      57         169 : struct ChartShapeInfo
      58             : {
      59             :     OUString     maFragmentPath;     ///< Path to related XML stream, e.g. for charts.
      60             :     bool                mbEmbedShapes;      ///< True = load chart shapes into chart, false = load into parent drawpage.
      61             : 
      62         169 :     explicit     ChartShapeInfo( bool bEmbedShapes ) : mbEmbedShapes( bEmbedShapes ) {}
      63             : };
      64             : 
      65             : /// Attributes for a linked textbox.
      66             : struct LinkedTxbxAttr
      67             : {
      68             :     sal_Int32 id;
      69             :     sal_Int32 seq;
      70       13183 :     LinkedTxbxAttr(): id(0),seq(0){};
      71       13183 :     ~LinkedTxbxAttr(){};
      72             : };
      73             : 
      74             : class OOX_DLLPUBLIC Shape
      75             :     : public std::enable_shared_from_this< Shape >
      76             : {
      77             : public:
      78             : 
      79             :     explicit Shape( const sal_Char* pServiceType = 0, bool bDefaultHeight = true );
      80             :     explicit Shape( const ShapePtr& pSourceShape );
      81             :     virtual ~Shape();
      82             : 
      83         158 :     OUString&                  getServiceName(){ return msServiceName; }
      84             :     void                            setServiceName( const sal_Char* pServiceName );
      85             : 
      86        4285 :     PropertyMap&                    getShapeProperties(){ return maShapeProperties; }
      87             : 
      88        7014 :     LineProperties&          getLineProperties() { return *mpLinePropertiesPtr; }
      89             :     const LineProperties&    getLineProperties() const { return *mpLinePropertiesPtr; }
      90             : 
      91       14719 :     FillProperties&          getFillProperties() { return *mpFillPropertiesPtr; }
      92             :     const FillProperties&    getFillProperties() const { return *mpFillPropertiesPtr; }
      93             : 
      94         330 :     GraphicProperties&       getGraphicProperties() { return *mpGraphicPropertiesPtr; }
      95             :     const GraphicProperties& getGraphicProperties() const { return *mpGraphicPropertiesPtr; }
      96             : 
      97        3450 :     CustomShapePropertiesPtr        getCustomShapeProperties(){ return mpCustomShapePropertiesPtr; }
      98             : 
      99        8764 :     Shape3DProperties&              get3DProperties() { return *mp3DPropertiesPtr; }
     100             :     const Shape3DProperties&        get3DProperties() const { return *mp3DPropertiesPtr; }
     101             : 
     102             :     table::TablePropertiesPtr       getTableProperties();
     103             : 
     104        4072 :     EffectProperties&               getEffectProperties() { return *mpEffectPropertiesPtr; }
     105             : 
     106         346 :     void                              setChildPosition( com::sun::star::awt::Point nPosition ){ maChPosition = nPosition; }
     107         346 :     void                              setChildSize( com::sun::star::awt::Size aSize ){ maChSize = aSize; }
     108             : 
     109        4618 :     void                              setPosition( com::sun::star::awt::Point nPosition ){ maPosition = nPosition; }
     110         159 :     const com::sun::star::awt::Point& getPosition() const { return maPosition; }
     111             : 
     112        3740 :     void                              setSize( com::sun::star::awt::Size aSize ){ maSize = aSize; }
     113         336 :     const com::sun::star::awt::Size&  getSize() const { return maSize; }
     114             : 
     115        3573 :     void                            setRotation( sal_Int32 nRotation ) { mnRotation = nRotation; }
     116        3476 :     void                            setFlip( bool bFlipH, bool bFlipV ) { mbFlipH = bFlipH; mbFlipV = bFlipV; }
     117        2419 :     void                            addChild( const ShapePtr& rChildPtr ) { maChildren.push_back( rChildPtr ); }
     118        6977 :     std::vector< ShapePtr >&        getChildren() { return maChildren; }
     119             : 
     120        2395 :     void                            setName( const OUString& rName ) { msName = rName; }
     121           9 :     OUString                       getName( ) { return msName; }
     122        2386 :     void                            setId( const OUString& rId ) { msId = rId; }
     123             :     OUString                        getId() { return msId; }
     124        2372 :     void                            setHidden( bool bHidden ) { mbHidden = bHidden; }
     125             :     bool                            getHidden() const { return mbHidden; };
     126           5 :     void                            setHiddenMasterShape( bool bHiddenMasterShape ) { mbHiddenMasterShape = bHiddenMasterShape; }
     127         805 :     void                            setSubType( sal_Int32 nSubType ) { mnSubType = nSubType; }
     128        5747 :     sal_Int32                       getSubType() const { return mnSubType; }
     129         435 :     void                            setSubTypeIndex( sal_Int32 nSubTypeIndex ) { moSubTypeIndex = nSubTypeIndex; }
     130        8280 :     const OptValue< sal_Int32 >&    getSubTypeIndex() const { return moSubTypeIndex; }
     131             : 
     132             :     // setDefaults has to be called if styles are imported (OfficeXML is not storing properties having the default value)
     133             :     void                            setDefaults(bool bHeight);
     134             : 
     135             :     ::oox::vml::OleObjectInfo&      setOleObjectType();
     136             :     ChartShapeInfo&                 setChartType( bool bEmbedShapes );
     137             :     void                            setDiagramType();
     138             :     void                            setTableType();
     139             : 
     140             :     void                setTextBody(const TextBodyPtr & pTextBody);
     141       14213 :     TextBodyPtr         getTextBody() { return mpTextBody;}
     142             :     void                setMasterTextListStyle( const TextListStylePtr& pMasterTextListStyle );
     143          96 :     TextListStylePtr    getMasterTextListStyle() const { return mpMasterTextListStyle; }
     144             : 
     145        4447 :     ShapeStyleRefMap&        getShapeStyleRefs() { return maShapeStyleRefs; }
     146             :     const ShapeStyleRefMap&  getShapeStyleRefs() const { return maShapeStyleRefs; }
     147             :     const ShapeStyleRef*            getShapeStyleRef( sal_Int32 nRefType ) const;
     148             : 
     149             :     // addShape is creating and inserting the corresponding XShape.
     150             :     void                addShape(
     151             :                             ::oox::core::XmlFilterBase& rFilterBase,
     152             :                             const Theme* pTheme,
     153             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
     154             :                             const basegfx::B2DHomMatrix& aTransformation,
     155             :                             FillProperties& rShapeOrParentShapeFillProps,
     156             :                             const ::com::sun::star::awt::Rectangle* pShapeRect = 0,
     157             :                             ShapeIdMap* pShapeMap = 0 );
     158             : 
     159             :     void                dropChildren() { maChildren.clear(); }
     160             : 
     161             :     void                addChildren(
     162             :                             ::oox::core::XmlFilterBase& rFilterBase,
     163             :                             const Theme* pTheme,
     164             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
     165             :                             basegfx::B2DHomMatrix& aTransformation,
     166             :                             const ::com::sun::star::awt::Rectangle* pShapeRect = 0,
     167             :                             ShapeIdMap* pShapeMap = 0 );
     168             : 
     169           0 :     void                setXShape( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rXShape )
     170           0 :                             { mxShape = rXShape; };
     171             :     const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > &
     172        1439 :                         getXShape() const { return mxShape; }
     173             : 
     174             :     virtual void        applyShapeReference( const Shape& rReferencedShape, bool bUseText = true );
     175             :     const ::std::vector<OUString>&
     176         190 :                         getExtDrawings() { return maExtDrawings; }
     177          37 :     void                addExtDrawingRelId( const OUString &rRelId ) { maExtDrawings.push_back( rRelId ); }
     178             :     // Set font color only for extdrawings.
     179          37 :     void                setFontRefColorForNodes(const Color& rColor) { maFontRefColorForNodes = rColor; }
     180          13 :     const Color&        getFontRefColorForNodes() const { return maFontRefColorForNodes; }
     181             :     void                setLockedCanvas(bool bLockedCanvas);
     182           1 :     bool                getLockedCanvas() { return mbLockedCanvas;}
     183             :     void                setWps(bool bWps);
     184         326 :     bool                getWps() { return mbWps;}
     185             :     void                setTextBox(bool bTextBox);
     186             :     const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> &
     187          28 :                         getDiagramDoms() { return maDiagramDoms; }
     188          75 :     void                setDiagramDoms(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& rDiagramDoms) { maDiagramDoms = rDiagramDoms; }
     189             :     com::sun::star::uno::Sequence< com::sun::star::uno::Sequence< com::sun::star::uno::Any > >resolveRelationshipsOfTypeFromOfficeDoc(
     190             :                                                                           core::XmlFilterBase& rFilter, const OUString& sFragment, const OUString& sType );
     191           6 :     void                setLinkedTxbxAttributes(const LinkedTxbxAttr& rhs){ maLinkedTxbxAttr = rhs; };
     192           6 :     void                setTxbxHasLinkedTxtBox( const bool rhs){ mbHasLinkedTxbx = rhs; };
     193          12 :     const LinkedTxbxAttr&     getLinkedTxbxAttributes() { return maLinkedTxbxAttr; };
     194        2871 :     bool                isLinkedTxbx() { return mbHasLinkedTxbx; };
     195             : 
     196             : protected:
     197             : 
     198             :     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     199             :                         createAndInsert(
     200             :                             ::oox::core::XmlFilterBase& rFilterBase,
     201             :                             const OUString& rServiceName,
     202             :                             const Theme* pTheme,
     203             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
     204             :                             const ::com::sun::star::awt::Rectangle* pShapeRect,
     205             :                             bool bClearText,
     206             :                             bool bDoNotInsertEmptyTextBody,
     207             :                             basegfx::B2DHomMatrix& aTransformation,
     208             :                             FillProperties& rShapeOrParentShapeFillProps
     209             :                              );
     210             : 
     211             :     void                addChildren(
     212             :                             ::oox::core::XmlFilterBase& rFilterBase,
     213             :                             Shape& rMaster,
     214             :                             const Theme* pTheme,
     215             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
     216             :                             const ::com::sun::star::awt::Rectangle& rClientRect,
     217             :                             ShapeIdMap* pShapeMap,
     218             :                             const basegfx::B2DHomMatrix& aTransformation );
     219             : 
     220             :     void                keepDiagramCompatibilityInfo( ::oox::core::XmlFilterBase& rFilterBase );
     221             : 
     222             :     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     223             :                         renderDiagramToGraphic( ::oox::core::XmlFilterBase& rFilterBase );
     224             : 
     225             :     OUString finalizeServiceName(
     226             :                             ::oox::core::XmlFilterBase& rFilter,
     227             :                             const OUString& rServiceName,
     228             :                             const ::com::sun::star::awt::Rectangle& rShapeRect );
     229             : 
     230             :     virtual void        finalizeXShape(
     231             :                             ::oox::core::XmlFilterBase& rFilter,
     232             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes );
     233             : 
     234             :     void                putPropertyToGrabBag(
     235             :                             const OUString& sPropertyName, const ::com::sun::star::uno::Any& aPropertyValue );
     236             :     void                putPropertyToGrabBag(
     237             :                             const ::com::sun::star::beans::PropertyValue& pProperty );
     238             :     void                putPropertiesToGrabBag(
     239             :                             const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aProperties );
     240             : 
     241             :     std::vector< ShapePtr >     maChildren;               // only used for group shapes
     242             :     com::sun::star::awt::Size   maChSize;                 // only used for group shapes
     243             :     com::sun::star::awt::Point  maChPosition;             // only used for group shapes
     244             :     bool                        mbIsChild;
     245             : 
     246             :     TextBodyPtr                 mpTextBody;
     247             :     LinePropertiesPtr           mpLinePropertiesPtr;
     248             :     LinePropertiesPtr           mpShapeRefLinePropPtr;
     249             :     FillPropertiesPtr           mpFillPropertiesPtr;
     250             :     FillPropertiesPtr           mpShapeRefFillPropPtr;
     251             :     GraphicPropertiesPtr        mpGraphicPropertiesPtr;
     252             :     CustomShapePropertiesPtr    mpCustomShapePropertiesPtr;
     253             :     table::TablePropertiesPtr   mpTablePropertiesPtr;
     254             :     Shape3DPropertiesPtr        mp3DPropertiesPtr;
     255             :     EffectPropertiesPtr         mpEffectPropertiesPtr;
     256             :     EffectPropertiesPtr         mpShapeRefEffectPropPtr;
     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 std::shared_ptr< ::oox::vml::OleObjectInfo >    OleObjectInfoRef;
     286             :     typedef std::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.11