LCOV - code coverage report
Current view: top level - sc/source/filter/inc - drawingmanager.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 4 0.0 %
Date: 2014-04-14 Functions: 0 6 0.0 %
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_XLS_DRAWINGMANAGER_HXX
      21             : #define OOX_XLS_DRAWINGMANAGER_HXX
      22             : 
      23             : #include "drawingbase.hxx"
      24             : 
      25             : namespace com { namespace sun { namespace star {
      26             :     namespace drawing { class XDrawPage; }
      27             :     namespace drawing { class XShape; }
      28             :     namespace drawing { class XShapes; }
      29             : } } }
      30             : 
      31             : namespace oox { namespace drawingml { class ShapePropertyMap; } }
      32             : 
      33             : namespace oox {
      34             : namespace xls {
      35             : 
      36             : const sal_uInt16 BIFF_OBJ_INVALID_ID        = 0;
      37             : 
      38             : 
      39             : // Model structures for BIFF OBJ record data
      40             : 
      41             : 
      42             : /** This structure contains line formatting attributes from an OBJ record. */
      43             : struct BiffObjLineModel
      44             : {
      45             :     sal_uInt8           mnColorIdx;         /// Index into color palette.
      46             :     sal_uInt8           mnStyle;            /// Line dash style.
      47             :     sal_uInt8           mnWidth;            /// Line width.
      48             :     bool                mbAuto;             /// True = automatic line format.
      49             : 
      50             :     explicit            BiffObjLineModel();
      51             : };
      52             : 
      53             : /** This structure contains fill formatting attributes from an OBJ record. */
      54             : struct BiffObjFillModel
      55             : {
      56             :     sal_uInt8           mnBackColorIdx;     /// Index to color palette for background color.
      57             :     sal_uInt8           mnPattColorIdx;     /// Index to color palette for pattern foreground color.
      58             :     sal_uInt8           mnPattern;          /// Fill pattern.
      59             :     bool                mbAuto;             /// True = automatic fill format.
      60             : 
      61             :     explicit            BiffObjFillModel();
      62             : };
      63             : 
      64             : 
      65             : // BIFF drawing objects
      66             : 
      67             : 
      68             : class BiffDrawingBase;
      69             : class BiffDrawingObjectBase;
      70             : typedef ::boost::shared_ptr< BiffDrawingObjectBase > BiffDrawingObjectRef;
      71             : 
      72           0 : class BiffDrawingObjectContainer
      73             : {
      74             : public:
      75             :     explicit            BiffDrawingObjectContainer();
      76             : 
      77             :     /** Returns true, if the object list is empty. */
      78             :     inline bool         empty() const { return maObjects.empty(); }
      79             : 
      80             :     /** Creates and inserts all UNO shapes into the passed shape container. */
      81             :     void                convertAndInsert( BiffDrawingBase& rDrawing,
      82             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
      83             :                             const ::com::sun::star::awt::Rectangle* pParentRect = 0 ) const;
      84             : 
      85             : private:
      86             :     typedef RefVector< BiffDrawingObjectBase > BiffDrawingObjectVector;
      87             :     BiffDrawingObjectVector maObjects;
      88             : };
      89             : 
      90             : /** Base class for all BIFF drawing objects (OBJ records). */
      91             : class BiffDrawingObjectBase : public WorksheetHelper
      92             : {
      93             : public:
      94             :     explicit            BiffDrawingObjectBase( const WorksheetHelper& rHelper );
      95             :     virtual             ~BiffDrawingObjectBase();
      96             : 
      97             :     /** Sets whether this is an area object (then its width and height must be greater than 0). */
      98             :     inline void         setAreaObj( bool bAreaObj ) { mbAreaObj = bAreaObj; }
      99             :     /** If set to true, the object supports a simple on-click macro and/or hyperlink. */
     100             :     inline void         setSimpleMacro( bool bMacro ) { mbSimpleMacro = bMacro; }
     101             : 
     102             :     /** If set to false, the UNO shape will not be created, processed, or inserted into the draw page. */
     103           0 :     inline void         setProcessShape( bool bProcess ) { mbProcessShape = bProcess; }
     104             :     /** If set to false, the UNO shape will be created or processed, but not be inserted into the draw page. */
     105             :     inline void         setInsertShape( bool bInsert ) { mbInsertShape = bInsert; }
     106             :     /** If set to true, a new custom UNO shape will be created while in DFF import (BIFF8 only). */
     107             :     inline void         setCustomDffObj( bool bCustom ) { mbCustomDff = bCustom; }
     108             : 
     109             :     /** Returns the object identifier from the OBJ record. */
     110             :     inline sal_uInt16   getObjId() const { return mnObjId; }
     111             :     /** Returns the object type from the OBJ record. */
     112             :     inline sal_uInt16   getObjType() const { return mnObjType; }
     113             : 
     114             :     /** Returns true, if the object is hidden. */
     115             :     inline bool         isHidden() const { return mbHidden; }
     116             :     /** Returns true, if the object is visible. */
     117             :     inline bool         isVisible() const { return mbVisible; }
     118             :     /** Returns true, if the object is printable. */
     119             :     inline bool         isPrintable() const { return mbPrintable; }
     120             : 
     121             :     /** Creates the UNO shape and inserts it into the passed shape container. */
     122             :     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     123             :                         convertAndInsert( BiffDrawingBase& rDrawing,
     124             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
     125             :                             const ::com::sun::star::awt::Rectangle* pParentRect = 0 ) const;
     126             : 
     127             : protected:
     128             :     /** Converts the passed line formatting to the passed property map. */
     129             :     void                convertLineProperties( ::oox::drawingml::ShapePropertyMap& rPropMap, const BiffObjLineModel& rLineModel, sal_uInt16 nArrows = 0 ) const;
     130             :     /** Converts the passed fill formatting to the passed property map. */
     131             :     void                convertFillProperties( ::oox::drawingml::ShapePropertyMap& rPropMap, const BiffObjFillModel& rFillModel ) const;
     132             : 
     133             :     /** Derived classes create the corresponding XShape and insert it into the passed container. */
     134             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     135             :                         implConvertAndInsert( BiffDrawingBase& rDrawing,
     136             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
     137             :                             const ::com::sun::star::awt::Rectangle& rShapeRect ) const = 0;
     138             : 
     139             : private:
     140             :     ShapeAnchor         maAnchor;       /// Position of the drawing object.
     141             :     OUString     maObjName;      /// Name of the object.
     142             :     OUString     maMacroName;    /// Name of an attached macro.
     143             :     OUString     maHyperlink;    /// On-click hyperlink URL.
     144             :     sal_uInt16          mnObjId;        /// The object identifier (unique per drawing).
     145             :     sal_uInt16          mnObjType;      /// The object type from OBJ record.
     146             :     bool                mbHidden;       /// True = object is hidden.
     147             :     bool                mbVisible;      /// True = object is visible (form controls).
     148             :     bool                mbPrintable;    /// True = object is printable.
     149             :     bool                mbAreaObj;      /// True = width and height must be greater than 0.
     150             :     bool                mbSimpleMacro;  /// True = create simple macro link and hyperlink.
     151             :     bool                mbProcessShape; /// True = object is valid, do processing and insertion.
     152             :     bool                mbInsertShape;  /// True = insert the UNO shape into the draw page.
     153             :     bool                mbCustomDff;    /// True = recreate UNO shape in DFF import (BIFF8 only).
     154             : };
     155             : 
     156             : 
     157             : // BIFF drawing page
     158             : 
     159             : 
     160             : /** Base class for a container for all objects on a drawing page (in a
     161             :     spreadsheet or in an embedded chart object).
     162             : 
     163             :     For BIFF import, it is needed to load all drawing objects before converting
     164             :     them to UNO shapes. There might be some dummy drawing objects (e.g. the
     165             :     dropdown buttons of autofilters) which have to be skipped. The information,
     166             :     that a drawing object is a dummy object, may be located after the drawing
     167             :     objects themselves.
     168             : 
     169             :     The BIFF8 format stores drawing objects in the DFF stream (stored
     170             :     fragmented in MSODRAWING records), and in the OBJ records. The DFF stream
     171             :     fragments are collected in a single stream, and the complete stream will be
     172             :     processed afterwards.
     173             :  */
     174           0 : class BiffDrawingBase : public WorksheetHelper
     175             : {
     176             : public:
     177             :     explicit            BiffDrawingBase( const WorksheetHelper& rHelper,
     178             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& rxDrawPage );
     179             : 
     180             :     /** Sets the object with the passed identifier to be skipped on import. */
     181             :     void                setSkipObj( sal_uInt16 nObjId );
     182             : 
     183             :     /** Final processing after import of the all drawing objects. */
     184             :     void                finalizeImport();
     185             : 
     186             :     /** Derived classes may want to know that a shape has been inserted. Will
     187             :         be called from the convertAndInsert() implementation. */
     188             :     virtual void        notifyShapeInserted(
     189             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rxShape,
     190             :                             const ::com::sun::star::awt::Rectangle& rShapeRect ) = 0;
     191             : 
     192             : private:
     193             :     typedef RefMap< sal_uInt16, BiffDrawingObjectBase > BiffDrawingObjectMapById;
     194             :     typedef ::std::vector< sal_uInt16 >                 BiffObjIdVector;
     195             : 
     196             :     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >
     197             :                         mxDrawPage;         /// UNO draw page used to insert the shapes.
     198             :     BiffDrawingObjectContainer maRawObjs;   /// Drawing objects without DFF data.
     199             :     BiffDrawingObjectMapById maObjMapId;    /// Maps drawing objects by their object identifiers.
     200             :     BiffObjIdVector     maSkipObjs;         /// Identifiers of all objects to be skipped.
     201             : };
     202             : 
     203             : /** Drawing manager of a single sheet. */
     204           0 : class BiffSheetDrawing : public BiffDrawingBase
     205             : {
     206             : public:
     207             :     explicit            BiffSheetDrawing( const WorksheetHelper& rHelper );
     208             : 
     209             :     /** Called when a new UNO shape has been inserted into the draw page. */
     210             :     virtual void        notifyShapeInserted(
     211             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rxShape,
     212             :                             const ::com::sun::star::awt::Rectangle& rShapeRect ) SAL_OVERRIDE;
     213             : };
     214             : 
     215             : } // namespace xls
     216             : } // namespace oox
     217             : 
     218             : #endif
     219             : 
     220             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10