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

Generated by: LCOV version 1.10