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

Generated by: LCOV version 1.10