LCOV - code coverage report
Current view: top level - solver/unxlngi6.pro/inc/oox/drawingml - shape.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 26 35 74.3 %
Date: 2012-08-25 Functions: 28 37 75.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     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 OOX_DRAWINGML_SHAPE_HXX
      21                 :            : #define 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< ::rtl::OUString, ShapePtr > ShapeIdMap;
      48                 :            : 
      49                 :        576 : struct ShapeStyleRef
      50                 :            : {
      51                 :            :     Color               maPhClr;
      52                 :            :     sal_Int32           mnThemedIdx;
      53                 :            : };
      54                 :            : 
      55                 :            : typedef ::std::map< sal_Int32, ShapeStyleRef > ShapeStyleRefMap;
      56                 :            : 
      57                 :            : // ============================================================================
      58                 :            : 
      59                 :            : /** Additional information for a chart embedded in a drawing shape. */
      60                 :          0 : struct ChartShapeInfo
      61                 :            : {
      62                 :            :     ::rtl::OUString     maFragmentPath;     /// Path to related XML stream, e.g. for charts.
      63                 :            :     bool                mbEmbedShapes;      /// True = load chart shapes into chart, false = load into parent drawpage.
      64                 :            : 
      65                 :          0 :     inline explicit     ChartShapeInfo( bool bEmbedShapes ) : mbEmbedShapes( bEmbedShapes ) {}
      66                 :            : };
      67                 :            : 
      68                 :            : // ============================================================================
      69                 :            : 
      70                 :            : class OOX_DLLPUBLIC Shape
      71                 :            :     : public boost::enable_shared_from_this< Shape >
      72                 :            : {
      73                 :            : public:
      74                 :            : 
      75                 :            :     explicit Shape( const sal_Char* pServiceType = 0 );
      76                 :            :     explicit Shape( const ShapePtr& pSourceShape );
      77                 :            :     virtual ~Shape();
      78                 :            : 
      79                 :         12 :     rtl::OUString&                  getServiceName(){ return msServiceName; }
      80                 :            :     void                            setServiceName( const sal_Char* pServiceName );
      81                 :            : 
      82                 :        174 :     PropertyMap&                    getShapeProperties(){ return maShapeProperties; }
      83                 :            : 
      84                 :        120 :     inline LineProperties&          getLineProperties() { return *mpLinePropertiesPtr; }
      85                 :            :     inline const LineProperties&    getLineProperties() const { return *mpLinePropertiesPtr; }
      86                 :            : 
      87                 :        123 :     inline FillProperties&          getFillProperties() { return *mpFillPropertiesPtr; }
      88                 :            :     inline const FillProperties&    getFillProperties() const { return *mpFillPropertiesPtr; }
      89                 :            : 
      90                 :         15 :     inline GraphicProperties&       getGraphicProperties() { return *mpGraphicPropertiesPtr; }
      91                 :            :     inline const GraphicProperties& getGraphicProperties() const { return *mpGraphicPropertiesPtr; }
      92                 :            : 
      93                 :        114 :     CustomShapePropertiesPtr        getCustomShapeProperties(){ return mpCustomShapePropertiesPtr; }
      94                 :            : 
      95                 :            :     Shape3DProperties&              get3DProperties() { return *mp3DPropertiesPtr; }
      96                 :            :     const Shape3DProperties&        get3DProperties() const { return *mp3DPropertiesPtr; }
      97                 :            : 
      98                 :            :     table::TablePropertiesPtr       getTableProperties();
      99                 :            : 
     100                 :         33 :     void                              setChildPosition( com::sun::star::awt::Point nPosition ){ maChPosition = nPosition; }
     101                 :         33 :     void                              setChildSize( com::sun::star::awt::Size aSize ){ maChSize = aSize; }
     102                 :            :     void                              moveAllToPosition( const com::sun::star::awt::Point &rPoint );
     103                 :            : 
     104                 :        159 :     void                              setPosition( com::sun::star::awt::Point nPosition ){ maPosition = nPosition; }
     105                 :          0 :     const com::sun::star::awt::Point& getPosition() const { return maPosition; }
     106                 :            : 
     107                 :        159 :     void                              setSize( com::sun::star::awt::Size aSize ){ maSize = aSize; }
     108                 :          0 :     const com::sun::star::awt::Size&  getSize() const { return maSize; }
     109                 :            : 
     110                 :        159 :     void                            setRotation( sal_Int32 nRotation ) { mnRotation = nRotation; }
     111                 :        159 :     void                            setFlip( sal_Bool bFlipH, sal_Bool bFlipV ) { mbFlipH = bFlipH; mbFlipV = bFlipV; }
     112                 :        171 :     void                            addChild( const ShapePtr pChildPtr ) { maChildren.push_back( pChildPtr ); }
     113                 :        975 :     std::vector< ShapePtr >&        getChildren() { return maChildren; }
     114                 :            : 
     115                 :        189 :     void                            setName( const rtl::OUString& rName ) { msName = rName; }
     116                 :          0 :     ::rtl::OUString                 getName( ) { return msName; }
     117                 :        189 :     void                            setId( const rtl::OUString& rId ) { msId = rId; }
     118                 :            :     ::rtl::OUString                 getId() { return msId; }
     119                 :        186 :     void                            setHidden( sal_Bool bHidden ) { mbHidden = bHidden; }
     120                 :            :     sal_Bool                        getHidden() const { return mbHidden; };
     121                 :          0 :     void                            setHiddenMasterShape( sal_Bool bHiddenMasterShape ) { mbHiddenMasterShape = bHiddenMasterShape; }
     122                 :        105 :     void                            setSubType( sal_Int32 nSubType ) { mnSubType = nSubType; }
     123                 :        423 :     sal_Int32                       getSubType() const { return mnSubType; }
     124                 :         66 :     void                            setSubTypeIndex( sal_Int32 nSubTypeIndex ) { moSubTypeIndex = nSubTypeIndex; }
     125                 :       1002 :     const OptValue< sal_Int32 >&    getSubTypeIndex() const { return moSubTypeIndex; }
     126                 :            : 
     127                 :            :     // setDefaults has to be called if styles are imported (OfficeXML is not storing properties having the default value)
     128                 :            :     void                            setDefaults();
     129                 :            : 
     130                 :            :     ::oox::vml::OleObjectInfo&      setOleObjectType();
     131                 :            :     ChartShapeInfo&                 setChartType( bool bEmbedShapes );
     132                 :            :     void                            setDiagramType();
     133                 :            :     void                            setTableType();
     134                 :            : 
     135                 :            :     void                setTextBody(const TextBodyPtr & pTextBody);
     136                 :            :     TextBodyPtr         getTextBody();
     137                 :            :     void                setMasterTextListStyle( const TextListStylePtr& pMasterTextListStyle );
     138                 :          0 :     TextListStylePtr    getMasterTextListStyle() const { return mpMasterTextListStyle; }
     139                 :            : 
     140                 :         96 :     inline ShapeStyleRefMap&        getShapeStyleRefs() { return maShapeStyleRefs; }
     141                 :            :     inline const ShapeStyleRefMap&  getShapeStyleRefs() const { return maShapeStyleRefs; }
     142                 :            :     const ShapeStyleRef*            getShapeStyleRef( sal_Int32 nRefType ) const;
     143                 :            : 
     144                 :            :     // addShape is creating and inserting the corresponding XShape.
     145                 :            :     void                addShape(
     146                 :            :                             ::oox::core::XmlFilterBase& rFilterBase,
     147                 :            :                             const Theme* pTheme,
     148                 :            :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
     149                 :            :                             basegfx::B2DHomMatrix& aTransformation,
     150                 :            :                             const ::com::sun::star::awt::Rectangle* pShapeRect = 0,
     151                 :            :                             ShapeIdMap* pShapeMap = 0 );
     152                 :            : 
     153                 :            :     void                dropChildren() { maChildren.clear(); }
     154                 :            : 
     155                 :            :     void                addChildren(
     156                 :            :                             ::oox::core::XmlFilterBase& rFilterBase,
     157                 :            :                             const Theme* pTheme,
     158                 :            :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
     159                 :            :                             basegfx::B2DHomMatrix& aTransformation,
     160                 :            :                             const ::com::sun::star::awt::Rectangle* pShapeRect = 0,
     161                 :            :                             ShapeIdMap* pShapeMap = 0 );
     162                 :            : 
     163                 :          0 :     void                setXShape( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rXShape )
     164                 :          0 :                             { mxShape = rXShape; };
     165                 :            :     const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > &
     166                 :         15 :                         getXShape() const { return mxShape; }
     167                 :            : 
     168                 :            :     virtual void        applyShapeReference( const Shape& rReferencedShape, bool bUseText = true );
     169                 :            :     const ::std::vector<rtl::OUString>&
     170                 :         12 :                         getExtDrawings() { return maExtDrawings; }
     171                 :          3 :     void                addExtDrawingRelId( const ::rtl::OUString &rRelId ) { maExtDrawings.push_back( rRelId ); }
     172                 :            : 
     173                 :            : protected:
     174                 :            : 
     175                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     176                 :            :                         createAndInsert(
     177                 :            :                             ::oox::core::XmlFilterBase& rFilterBase,
     178                 :            :                             const ::rtl::OUString& rServiceName,
     179                 :            :                             const Theme* pTheme,
     180                 :            :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
     181                 :            :                             const ::com::sun::star::awt::Rectangle* pShapeRect,
     182                 :            :                             sal_Bool bClearText,
     183                 :            :                             sal_Bool bDoNotInsertEmptyTextBody,
     184                 :            :                             basegfx::B2DHomMatrix& aTransformation );
     185                 :            : 
     186                 :            :     void                addChildren(
     187                 :            :                             ::oox::core::XmlFilterBase& rFilterBase,
     188                 :            :                             Shape& rMaster,
     189                 :            :                             const Theme* pTheme,
     190                 :            :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
     191                 :            :                             const ::com::sun::star::awt::Rectangle& rClientRect,
     192                 :            :                             ShapeIdMap* pShapeMap,
     193                 :            :                             basegfx::B2DHomMatrix& aTransformation );
     194                 :            : 
     195                 :            :     virtual ::rtl::OUString finalizeServiceName(
     196                 :            :                             ::oox::core::XmlFilterBase& rFilter,
     197                 :            :                             const ::rtl::OUString& rServiceName,
     198                 :            :                             const ::com::sun::star::awt::Rectangle& rShapeRect );
     199                 :            : 
     200                 :            :     virtual void        finalizeXShape(
     201                 :            :                             ::oox::core::XmlFilterBase& rFilter,
     202                 :            :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes );
     203                 :            : 
     204                 :            :     std::vector< ShapePtr >     maChildren;               // only used for group shapes
     205                 :            :     com::sun::star::awt::Size   maChSize;                 // only used for group shapes
     206                 :            :     com::sun::star::awt::Point  maChPosition;             // only used for group shapes
     207                 :            :     com::sun::star::awt::Size   maAbsoluteSize;           // only used for group shapes
     208                 :            :     com::sun::star::awt::Point  maAbsolutePosition;       // only used for group shapes
     209                 :            :     sal_Bool                    mbIsChild;
     210                 :            : 
     211                 :            :     TextBodyPtr                 mpTextBody;
     212                 :            :     LinePropertiesPtr           mpLinePropertiesPtr;
     213                 :            :     FillPropertiesPtr           mpFillPropertiesPtr;
     214                 :            :     GraphicPropertiesPtr        mpGraphicPropertiesPtr;
     215                 :            :     CustomShapePropertiesPtr    mpCustomShapePropertiesPtr;
     216                 :            :     table::TablePropertiesPtr   mpTablePropertiesPtr;
     217                 :            :     Shape3DPropertiesPtr        mp3DPropertiesPtr;
     218                 :            :     PropertyMap                 maShapeProperties;
     219                 :            :     PropertyMap                 maDefaultShapeProperties;
     220                 :            :     TextListStylePtr            mpMasterTextListStyle;
     221                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > mxShape;
     222                 :            : 
     223                 :            :     rtl::OUString       msServiceName;
     224                 :            :     rtl::OUString       msName;
     225                 :            :     rtl::OUString       msId;
     226                 :            :     sal_Int32           mnSubType;      // if this type is not zero, then the shape is a placeholder
     227                 :            :     OptValue< sal_Int32 >   moSubTypeIndex;
     228                 :            : 
     229                 :            :     ShapeStyleRefMap   maShapeStyleRefs;
     230                 :            : 
     231                 :            :     com::sun::star::awt::Size       maSize;
     232                 :            :     com::sun::star::awt::Point      maPosition;
     233                 :            :     ::std::vector<rtl::OUString>    maExtDrawings;
     234                 :            : 
     235                 :            : private:
     236                 :            :     enum FrameType
     237                 :            :     {
     238                 :            :         FRAMETYPE_GENERIC,          /// Generic shape, no special type.
     239                 :            :         FRAMETYPE_OLEOBJECT,        /// OLE object embedded in a shape.
     240                 :            :         FRAMETYPE_CHART,            /// Chart embedded in a shape.
     241                 :            :         FRAMETYPE_DIAGRAM,          /// Complex diagram drawing shape.
     242                 :            :         FRAMETYPE_TABLE             /// A table embedded in a shape.
     243                 :            :     };
     244                 :            : 
     245                 :            :     typedef ::boost::shared_ptr< ::oox::vml::OleObjectInfo >    OleObjectInfoRef;
     246                 :            :     typedef ::boost::shared_ptr< ChartShapeInfo >               ChartShapeInfoRef;
     247                 :            : 
     248                 :            :     FrameType           meFrameType;        /// Type for graphic frame shapes.
     249                 :            :     OleObjectInfoRef    mxOleObjectInfo;    /// Additional data for OLE objects.
     250                 :            :     ChartShapeInfoRef   mxChartShapeInfo;   /// Additional data for chart shapes.
     251                 :            : 
     252                 :            :     sal_Int32                       mnRotation;
     253                 :            :     sal_Bool                        mbFlipH;
     254                 :            :     sal_Bool                        mbFlipV;
     255                 :            :     sal_Bool                        mbHidden;
     256                 :            :     sal_Bool                        mbHiddenMasterShape; // master shapes can be hidden in layout slides
     257                 :            :                                                          // we need separate flag because we don't want
     258                 :            :                                                          // to propagate it when applying reference shape
     259                 :            : };
     260                 :            : 
     261                 :            : // ============================================================================
     262                 :            : 
     263                 :            : } }
     264                 :            : 
     265                 :            : #endif  //  OOX_DRAWINGML_SHAPE_HXX
     266                 :            : 
     267                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10