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

Generated by: LCOV version 1.10