LCOV - code coverage report
Current view: top level - sc/source/filter/inc - xiescher.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 46 64 71.9 %
Date: 2012-08-25 Functions: 56 93 60.2 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 28 86 32.6 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef SC_XIESCHER_HXX
      30                 :            : #define SC_XIESCHER_HXX
      31                 :            : 
      32                 :            : #include <vector>
      33                 :            : #include <map>
      34                 :            : #include <filter/msfilter/msdffimp.hxx>
      35                 :            : #include <vcl/graph.hxx>
      36                 :            : #include "xlescher.hxx"
      37                 :            : #include "xiroot.hxx"
      38                 :            : #include "xistring.hxx"
      39                 :            : #include <boost/shared_ptr.hpp>
      40                 :            : #include <oox/ole/olehelper.hxx>
      41                 :            : namespace com { namespace sun { namespace star {
      42                 :            :     namespace drawing { class XShape; }
      43                 :            :     namespace form { class XForm; }
      44                 :            : } } }
      45                 :            : 
      46                 :            : class SdrObjList;
      47                 :            : class ScfProgressBar;
      48                 :            : class ScfPropertySet;
      49                 :            : class ScRangeList;
      50                 :            : class XclImpChart;
      51                 :            : class XclImpDffConverter;
      52                 :            : class XclImpDrawing;
      53                 :            : 
      54                 :            : // Drawing objects ============================================================
      55                 :            : 
      56                 :            : class XclImpDrawObjBase;
      57                 :            : typedef boost::shared_ptr< XclImpDrawObjBase > XclImpDrawObjRef;
      58                 :            : 
      59                 :            : /** Base class for drawing objects (OBJ records). */
      60                 :            : class XclImpDrawObjBase : protected XclImpRoot
      61                 :            : {
      62                 :            : public:
      63                 :            :     explicit            XclImpDrawObjBase( const XclImpRoot& rRoot );
      64                 :            :     virtual             ~XclImpDrawObjBase();
      65                 :            : 
      66                 :            :     /** Reads the BIFF3 OBJ record, returns a new drawing object. */
      67                 :            :     static XclImpDrawObjRef ReadObj3( const XclImpRoot& rRoot, XclImpStream& rStrm );
      68                 :            :     /** Reads the BIFF4 OBJ record, returns a new drawing object. */
      69                 :            :     static XclImpDrawObjRef ReadObj4( const XclImpRoot& rRoot, XclImpStream& rStrm );
      70                 :            :     /** Reads the BIFF5 OBJ record, returns a new drawing object. */
      71                 :            :     static XclImpDrawObjRef ReadObj5( const XclImpRoot& rRoot, XclImpStream& rStrm );
      72                 :            :     /** Reads the BIFF8 OBJ record, returns a new drawing object. */
      73                 :            :     static XclImpDrawObjRef ReadObj8( const XclImpRoot& rRoot, XclImpStream& rStrm );
      74                 :            : 
      75                 :            :     /** Sets whether this is an area object (then its width and height must be greater than 0). */
      76                 :        115 :     inline void         SetAreaObj( bool bAreaObj ) { mbAreaObj = bAreaObj; }
      77                 :            :     /** If set to true, a new SdrObject will be created while in DFF import. */
      78                 :         68 :     inline void         SetSimpleMacro( bool bMacro ) { mbSimpleMacro = bMacro; }
      79                 :            : 
      80                 :            :     /** Sets the object anchor explicitly. */
      81                 :            :     void                SetAnchor( const XclObjAnchor& rAnchor );
      82                 :            :     /** Sets shape data from DFF stream. */
      83                 :            :     void                SetDffData(
      84                 :            :         const DffObjData& rDffObjData, const rtl::OUString& rObjName, const rtl::OUString& rHyperlink,
      85                 :            :         bool bVisible, bool bAutoMargin );
      86                 :            : 
      87                 :            :     /** If set to false, the SdrObject will not be created, processed, or inserted into the draw page. */
      88                 :         47 :     inline void         SetProcessSdrObj( bool bProcess ) { mbProcessSdr = bProcess; }
      89                 :            :     /** If set to false, the SdrObject will be created or processed, but not be inserted into the draw page. */
      90                 :          3 :     inline void         SetInsertSdrObj( bool bInsert ) { mbInsertSdr = bInsert; }
      91                 :            :     /** If set to true, a new SdrObject will be created while in DFF import. */
      92                 :         65 :     inline void         SetCustomDffObj( bool bCustom ) { mbCustomDff = bCustom; }
      93                 :            : 
      94                 :            :     /** Returns the sheet index and Excel object identifier from OBJ record. */
      95                 :        206 :     inline sal_uInt16   GetObjId() const { return mnObjId; }
      96                 :            :     /** Returns the Excel object type from OBJ record. */
      97                 :         84 :     inline sal_uInt16   GetObjType() const { return mnObjType; }
      98                 :            :     /** Returns the name of this object, may generate a default name. */
      99                 :            :     virtual rtl::OUString GetObjName() const;
     100                 :            :     /** Returns associated macro name, if set, otherwise zero length string. */
     101                 :         15 :     inline const rtl::OUString& GetMacroName() const { return maMacroName; }
     102                 :            : 
     103                 :            :     /** Returns the shape identifier used in the DFF stream. */
     104                 :         80 :     inline sal_uInt32   GetDffShapeId() const { return mnDffShapeId; }
     105                 :            :     /** Returns the shape flags from the DFF stream. */
     106                 :         68 :     inline sal_uInt32   GetDffFlags() const { return mnDffFlags; }
     107                 :            : 
     108                 :            :     /** Returns true, if the object is hidden. */
     109                 :          0 :     inline bool         IsHidden() const { return mbHidden; }
     110                 :            :     /** Returns true, if the object is visible. */
     111                 :         26 :     inline bool         IsVisible() const { return mbVisible; }
     112                 :            :     /** Returns true, if the object is printable. */
     113                 :         68 :     inline bool         IsPrintable() const { return mbPrintable; }
     114                 :            : 
     115                 :            :     /** Returns the object anchor if existing, null otherwise. */
     116                 :            :     const XclObjAnchor* GetAnchor() const;
     117                 :            :     /** Returns true, if the passed size is valid for this object. */
     118                 :            :     bool                IsValidSize( const Rectangle& rAnchorRect ) const;
     119                 :            :     /** Returns the range in the sheet covered by this object. */
     120                 :            :     ScRange             GetUsedArea( SCTAB nScTab ) const;
     121                 :            : 
     122                 :            :     /** Returns true, if the object is valid and will be processed. */
     123 [ +  + ][ +  - ]:        101 :     inline bool         IsProcessSdrObj() const { return mbProcessSdr && !mbHidden; }
     124                 :            :     /** Returns true, if the SdrObject will be created or processed, but not be inserted into the draw page. */
     125                 :        139 :     inline bool         IsInsertSdrObj() const { return mbInsertSdr; }
     126                 :            : 
     127                 :            :     /** Returns the needed size on the progress bar (calls virtual DoGetProgressSize() function). */
     128                 :            :     sal_Size            GetProgressSize() const;
     129                 :            :     /** Creates and returns an SdrObject from the contained data. Caller takes ownership! */
     130                 :            :     SdrObject*          CreateSdrObject( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect, bool bIsDff ) const;
     131                 :            :     /** Additional processing for the passed SdrObject before insertion into
     132                 :            :         the drawing page (calls virtual DoPreProcessSdrObj() function). */
     133                 :            :     void                PreProcessSdrObject( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
     134                 :            :     /** Additional processing for the passed SdrObject after insertion into the
     135                 :            :         drawing page (calls virtual DoPostProcessSdrObj() function). */
     136                 :            :     void                PostProcessSdrObject( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
     137                 :            : 
     138                 :            : protected:
     139                 :            :     /** Reads the object name in a BIFF5 OBJ record. */
     140                 :            :     void                ReadName5( XclImpStream& rStrm, sal_uInt16 nNameLen );
     141                 :            :     /** Reads the macro link in a BIFF3 OBJ record. */
     142                 :            :     void                ReadMacro3( XclImpStream& rStrm, sal_uInt16 nMacroSize );
     143                 :            :     /** Reads the macro link in a BIFF4 OBJ record. */
     144                 :            :     void                ReadMacro4( XclImpStream& rStrm, sal_uInt16 nMacroSize );
     145                 :            :     /** Reads the macro link in a BIFF5 OBJ record. */
     146                 :            :     void                ReadMacro5( XclImpStream& rStrm, sal_uInt16 nMacroSize );
     147                 :            :     /** Reads the contents of the ftMacro sub structure in an OBJ record. */
     148                 :            :     void                ReadMacro8( XclImpStream& rStrm );
     149                 :            : 
     150                 :            :     /** Converts the passed line formatting to the passed SdrObject. */
     151                 :            :     void                ConvertLineStyle( SdrObject& rSdrObj, const XclObjLineData& rLineData ) const;
     152                 :            :     /** Converts the passed fill formatting to the passed SdrObject. */
     153                 :            :     void                ConvertFillStyle( SdrObject& rSdrObj, const XclObjFillData& rFillData ) const;
     154                 :            :     /** Converts the passed frame flags to the passed SdrObject. */
     155                 :            :     void                ConvertFrameStyle( SdrObject& rSdrObj, sal_uInt16 nFrameFlags ) const;
     156                 :            : 
     157                 :            :     /** Returns a solid line color from the passed line data struct. */
     158                 :            :     Color               GetSolidLineColor( const XclObjLineData& rLineData ) const;
     159                 :            :     /** Returns a solid fill color from the passed fill data struct. */
     160                 :            :     Color               GetSolidFillColor( const XclObjFillData& rFillData ) const;
     161                 :            : 
     162                 :            :     /** Derived classes read the contents of the a BIFF3 OBJ record from the passed stream. */
     163                 :            :     virtual void        DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize );
     164                 :            :     /** Derived classes read the contents of the a BIFF4 OBJ record from the passed stream. */
     165                 :            :     virtual void        DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize );
     166                 :            :     /** Derived classes read the contents of the a BIFF5 OBJ record from the passed stream. */
     167                 :            :     virtual void        DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
     168                 :            :     /** Derived classes read the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
     169                 :            :     virtual void        DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize );
     170                 :            : 
     171                 :            :     /** Derived classes may return a progress bar size different from 1. */
     172                 :            :     virtual sal_Size    DoGetProgressSize() const;
     173                 :            :     /** Derived classes create and return a new SdrObject from the contained data. Caller takes ownership! */
     174                 :            :     virtual SdrObject*  DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const;
     175                 :            :     /** Derived classes may perform additional processing for the passed SdrObject before insertion. */
     176                 :            :     virtual void        DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
     177                 :            :     /** Derived classes may perform additional processing for the passed SdrObject after insertion. */
     178                 :            :     virtual void        DoPostProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
     179                 :         57 :     SCTAB               GetTab() const { return mnTab; }
     180                 :            : private:
     181                 :            :     /** Reads the contents of a BIFF3 OBJ record. */
     182                 :            :     void                ImplReadObj3( XclImpStream& rStrm );
     183                 :            :     /** Reads the contents of a BIFF4 OBJ record. */
     184                 :            :     void                ImplReadObj4( XclImpStream& rStrm );
     185                 :            :     /** Reads the contents of a BIFF5 OBJ record. */
     186                 :            :     void                ImplReadObj5( XclImpStream& rStrm );
     187                 :            :     /** Reads the contents of a BIFF8 OBJ record. */
     188                 :            :     void                ImplReadObj8( XclImpStream& rStrm );
     189                 :            : 
     190                 :            : private:
     191                 :            :     XclObjAnchor        maAnchor;       /// The position of the object in its parent.
     192                 :            :     sal_uInt16          mnObjId;        /// The object identifier (unique per drawing).
     193                 :            :     SCTAB               mnTab;          /// Location of object
     194                 :            :     sal_uInt16          mnObjType;      /// The Excel object type from OBJ record.
     195                 :            :     sal_uInt32          mnDffShapeId;   /// Shape ID from DFF stream.
     196                 :            :     sal_uInt32          mnDffFlags;     /// Shape flags from DFF stream.
     197                 :            :     rtl::OUString       maObjName;      /// Name of the object.
     198                 :            :     rtl::OUString       maMacroName;    /// Name of an attached macro.
     199                 :            :     rtl::OUString       maHyperlink;    /// On-click hyperlink URL.
     200                 :            :     bool                mbHasAnchor;    /// true = maAnchor is initialized.
     201                 :            :     bool                mbHidden;       /// true = Object is hidden.
     202                 :            :     bool                mbVisible;      /// true = Object is visible.
     203                 :            :     bool                mbPrintable;    /// true = Object is printable.
     204                 :            :     bool                mbAreaObj;      /// true = Width and height must be greater than 0.
     205                 :            :     bool                mbAutoMargin;   /// true = Set automatic text margin.
     206                 :            :     bool                mbSimpleMacro;  /// true = Create simple macro link and hyperlink.
     207                 :            :     bool                mbProcessSdr;   /// true = Object is valid, do processing and insertion.
     208                 :            :     bool                mbInsertSdr;    /// true = Insert the SdrObject into draw page.
     209                 :            :     bool                mbCustomDff;    /// true = Recreate SdrObject in DFF import.
     210                 :            : };
     211                 :            : 
     212                 :            : // ----------------------------------------------------------------------------
     213                 :            : 
     214                 :         86 : class XclImpDrawObjVector : public ::std::vector< XclImpDrawObjRef >
     215                 :            : {
     216                 :            : public:
     217                 :         86 :     inline explicit     XclImpDrawObjVector() {}
     218                 :            : 
     219                 :            :     /** Tries to insert the passed object into the last group or appends it. */
     220                 :            :     void                InsertGrouped( XclImpDrawObjRef xDrawObj );
     221                 :            : 
     222                 :            :     /** Returns the needed size on the progress bar for all contained objects. */
     223                 :            :     sal_Size            GetProgressSize() const;
     224                 :            : };
     225                 :            : 
     226                 :            : // ----------------------------------------------------------------------------
     227                 :            : 
     228                 :            : /** A placeholder object for unknown object types. */
     229         [ #  # ]:          0 : class XclImpPhObj : public XclImpDrawObjBase
     230                 :            : {
     231                 :            : public:
     232                 :            :     explicit            XclImpPhObj( const XclImpRoot& rRoot );
     233                 :            : };
     234                 :            : 
     235                 :            : // ----------------------------------------------------------------------------
     236                 :            : 
     237                 :            : /** A group object. */
     238         [ #  # ]:          0 : class XclImpGroupObj : public XclImpDrawObjBase
     239                 :            : {
     240                 :            : public:
     241                 :            :     explicit            XclImpGroupObj( const XclImpRoot& rRoot );
     242                 :            : 
     243                 :            :     /** Tries to insert the drawing object into this or a nested group. */
     244                 :            :     bool                TryInsert( XclImpDrawObjRef xDrawObj );
     245                 :            : 
     246                 :            : protected:
     247                 :            :     /** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
     248                 :            :     virtual void        DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize );
     249                 :            :     /** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
     250                 :            :     virtual void        DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize );
     251                 :            :     /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
     252                 :            :     virtual void        DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
     253                 :            :     /** Returns a progress bar size that takes all group children into account. */
     254                 :            :     virtual sal_Size    DoGetProgressSize() const;
     255                 :            :     /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
     256                 :            :     virtual SdrObject*  DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const;
     257                 :            : 
     258                 :            : protected:
     259                 :            :     XclImpDrawObjVector maChildren;         /// Grouped objects.
     260                 :            :     sal_uInt16          mnFirstUngrouped;   /// Object identfier of first object not grouped into this group.
     261                 :            : };
     262                 :            : 
     263                 :            : // ----------------------------------------------------------------------------
     264                 :            : 
     265                 :            : /** A line object. */
     266         [ #  # ]:          0 : class XclImpLineObj : public XclImpDrawObjBase
     267                 :            : {
     268                 :            : public:
     269                 :            :     explicit            XclImpLineObj( const XclImpRoot& rRoot );
     270                 :            : 
     271                 :            : protected:
     272                 :            :     /** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
     273                 :            :     virtual void        DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize );
     274                 :            :     /** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
     275                 :            :     virtual void        DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize );
     276                 :            :     /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
     277                 :            :     virtual void        DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
     278                 :            :     /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
     279                 :            :     virtual SdrObject*  DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const;
     280                 :            : 
     281                 :            : protected:
     282                 :            :     XclObjLineData      maLineData;     /// BIFF5 line formatting.
     283                 :            :     sal_uInt16          mnArrows;       /// Line arrows.
     284                 :            :     sal_uInt8           mnStartPoint;   /// Starting point.
     285                 :            : };
     286                 :            : 
     287                 :            : // ----------------------------------------------------------------------------
     288                 :            : 
     289                 :            : /** A rectangle or oval object. */
     290         [ -  + ]:        101 : class XclImpRectObj : public XclImpDrawObjBase
     291                 :            : {
     292                 :            : public:
     293                 :            :     explicit            XclImpRectObj( const XclImpRoot& rRoot );
     294                 :            : 
     295                 :            : protected:
     296                 :            :     /** Reads fil data, line data, and frame flags. */
     297                 :            :     void                ReadFrameData( XclImpStream& rStrm );
     298                 :            : 
     299                 :            :     /** Converts fill formatting, line formattind, and frame style. */
     300                 :            :     void                ConvertRectStyle( SdrObject& rSdrObj ) const;
     301                 :            : 
     302                 :            :     /** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
     303                 :            :     virtual void        DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize );
     304                 :            :     /** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
     305                 :            :     virtual void        DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize );
     306                 :            :     /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
     307                 :            :     virtual void        DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
     308                 :            :     /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
     309                 :            :     virtual SdrObject*  DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const;
     310                 :            : 
     311                 :            : protected:
     312                 :            :     XclObjFillData      maFillData;     /// BIFF5 fill formatting.
     313                 :            :     XclObjLineData      maLineData;     /// BIFF5 line formatting.
     314                 :            :     sal_uInt16          mnFrameFlags;   /// Additional flags.
     315                 :            : };
     316                 :            : 
     317                 :            : // ----------------------------------------------------------------------------
     318                 :            : 
     319                 :            : /** An oval object. */
     320         [ #  # ]:          0 : class XclImpOvalObj : public XclImpRectObj
     321                 :            : {
     322                 :            : public:
     323                 :            :     explicit            XclImpOvalObj( const XclImpRoot& rRoot );
     324                 :            : 
     325                 :            : protected:
     326                 :            :     /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
     327                 :            :     virtual SdrObject*  DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const;
     328                 :            : };
     329                 :            : 
     330                 :            : // ----------------------------------------------------------------------------
     331                 :            : 
     332                 :            : /** An arc object. */
     333         [ #  # ]:          0 : class XclImpArcObj : public XclImpDrawObjBase
     334                 :            : {
     335                 :            : public:
     336                 :            :     explicit            XclImpArcObj( const XclImpRoot& rRoot );
     337                 :            : 
     338                 :            : protected:
     339                 :            :     /** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
     340                 :            :     virtual void        DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize );
     341                 :            :     /** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
     342                 :            :     virtual void        DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize );
     343                 :            :     /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
     344                 :            :     virtual void        DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
     345                 :            :     /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
     346                 :            :     virtual SdrObject*  DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const;
     347                 :            : 
     348                 :            : protected:
     349                 :            :     XclObjFillData      maFillData;     /// BIFF5 fill formatting.
     350                 :            :     XclObjLineData      maLineData;     /// BIFF5 line formatting.
     351                 :            :     sal_uInt8           mnQuadrant;     /// Visible quadrant of the circle.
     352                 :            : };
     353                 :            : 
     354                 :            : // ----------------------------------------------------------------------------
     355                 :            : 
     356                 :            : /** A polygon object. */
     357         [ #  # ]:          0 : class XclImpPolygonObj : public XclImpRectObj
     358                 :            : {
     359                 :            : public:
     360                 :            :     explicit            XclImpPolygonObj( const XclImpRoot& rRoot );
     361                 :            : 
     362                 :            : protected:
     363                 :            :     /** Reads the COORDLIST record following the OBJ record. */
     364                 :            :     void                ReadCoordList( XclImpStream& rStrm );
     365                 :            : 
     366                 :            :     /** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
     367                 :            :     virtual void        DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize );
     368                 :            :     /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
     369                 :            :     virtual void        DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
     370                 :            :     /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
     371                 :            :     virtual SdrObject*  DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const;
     372                 :            : 
     373                 :            : protected:
     374                 :            :     typedef ::std::vector< Point > PointVector;
     375                 :            :     PointVector         maCoords;       /// Coordinates relative to bounding rectangle.
     376                 :            :     sal_uInt16          mnPolyFlags;    /// Additional flags.
     377                 :            :     sal_uInt16          mnPointCount;   /// Polygon point count.
     378                 :            : };
     379                 :            : 
     380                 :            : // ----------------------------------------------------------------------------
     381                 :            : 
     382                 :        306 : struct XclImpObjTextData
     383                 :            : {
     384                 :            :     XclObjTextData      maData;         /// BIFF5 text data.
     385                 :            :     XclImpStringRef     mxString;       /// Plain or rich string.
     386                 :            : 
     387                 :            :     /** Reads a byte string from the passed stream. */
     388                 :            :     void                ReadByteString( XclImpStream& rStrm );
     389                 :            :     /** Reads text formatting from the passed stream. */
     390                 :            :     void                ReadFormats( XclImpStream& rStrm );
     391                 :            : };
     392                 :            : 
     393                 :            : // ----------------------------------------------------------------------------
     394                 :            : 
     395                 :            : /** A drawing object supporting text contents. Used for all simple objects in BIFF8. */
     396 [ +  - ][ -  + ]:        114 : class XclImpTextObj : public XclImpRectObj
     397                 :            : {
     398                 :            : public:
     399                 :            :     explicit            XclImpTextObj( const XclImpRoot& rRoot );
     400                 :            : 
     401                 :            :     /** Stores the passed textbox data. */
     402                 :         48 :     inline void         SetTextData( const XclImpObjTextData& rTextData ) { maTextData = rTextData; }
     403                 :            : 
     404                 :            : protected:
     405                 :            :     /** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
     406                 :            :     virtual void        DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize );
     407                 :            :     /** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
     408                 :            :     virtual void        DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize );
     409                 :            :     /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
     410                 :            :     virtual void        DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
     411                 :            :     /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
     412                 :            :     virtual SdrObject*  DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const;
     413                 :            :     /** Inserts the contained text data at the passed object. */
     414                 :            :     virtual void        DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
     415                 :            : 
     416                 :            : protected:
     417                 :            :     XclImpObjTextData   maTextData;     /// Textbox data from BIFF5 OBJ or BIFF8 TXO record.
     418                 :            : };
     419                 :            : 
     420                 :            : // ----------------------------------------------------------------------------
     421                 :            : 
     422                 :            : /** A chart object. This is the drawing object wrapper for the chart data. */
     423 [ +  - ][ -  + ]:         12 : class XclImpChartObj : public XclImpRectObj
     424                 :            : {
     425                 :            : public:
     426                 :            :     /** @param bOwnTab  True = chart is on an own sheet; false = chart is an embedded object. */
     427                 :            :     explicit            XclImpChartObj( const XclImpRoot& rRoot, bool bOwnTab = false );
     428                 :            : 
     429                 :            :     /** Reads the complete chart substream (BOF/EOF block). */
     430                 :            :     void                ReadChartSubStream( XclImpStream& rStrm );
     431                 :            : 
     432                 :            : protected:
     433                 :            :     /** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
     434                 :            :     virtual void        DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize );
     435                 :            :     /** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
     436                 :            :     virtual void        DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize );
     437                 :            :     /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
     438                 :            :     virtual void        DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
     439                 :            :     /** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
     440                 :            :     virtual void        DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize );
     441                 :            :     /** Returns the needed size on the progress bar. */
     442                 :            :     virtual sal_Size    DoGetProgressSize() const;
     443                 :            :     /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
     444                 :            :     virtual SdrObject*  DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const;
     445                 :            :     /** Converts the chart document. */
     446                 :            :     virtual void        DoPostProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
     447                 :            : 
     448                 :            : private:
     449                 :            :     /** Calculates the object anchor of a sheet chart (chart fills one page). */
     450                 :            :     void                FinalizeTabChart();
     451                 :            : 
     452                 :            : private:
     453                 :            :     typedef boost::shared_ptr< XclImpChart > XclImpChartRef;
     454                 :            : 
     455                 :            :     XclImpChartRef      mxChart;        /// The chart itself (BOF/EOF substream data).
     456                 :            :     bool                mbOwnTab;       /// true = own sheet; false = embedded object.
     457                 :            : };
     458                 :            : 
     459                 :            : // ----------------------------------------------------------------------------
     460                 :            : 
     461                 :            : /** A note object, which is a specialized text box objext. */
     462         [ -  + ]:          6 : class XclImpNoteObj : public XclImpTextObj
     463                 :            : {
     464                 :            : public:
     465                 :            :     explicit            XclImpNoteObj( const XclImpRoot& rRoot );
     466                 :            : 
     467                 :            :     /** Sets note flags and the note position in the Calc sheet. */
     468                 :            :     void                SetNoteData( const ScAddress& rScPos, sal_uInt16 nNoteFlags );
     469                 :            : 
     470                 :            : protected:
     471                 :            :     /** Inserts the note into the document, sets visibility. */
     472                 :            :     virtual void        DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
     473                 :            : 
     474                 :            : private:
     475                 :            :     ScAddress           maScPos;        /// Cell position of the note object.
     476                 :            :     sal_uInt16          mnNoteFlags;    /// Flags from NOTE record.
     477                 :            : };
     478                 :            : 
     479                 :            : // ----------------------------------------------------------------------------
     480                 :            : 
     481                 :            : /** Helper base class for TBX and OCX form controls to manage spreadsheet links. */
     482                 :            : class XclImpControlHelper
     483                 :            : {
     484                 :            : public:
     485                 :            :     explicit            XclImpControlHelper( const XclImpRoot& rRoot, XclCtrlBindMode eBindMode );
     486                 :            :     virtual             ~XclImpControlHelper();
     487                 :            : 
     488                 :            :     /** Returns true, if a linked cell address is present. */
     489                 :         24 :     inline bool         HasCellLink() const { return mxCellLink != 0; }
     490                 :            :     /** Returns true, if a linked source cell range is present. */
     491                 :            :     inline bool         HasSourceRange() const { return mxSrcRange != 0; }
     492                 :            : 
     493                 :            :     /** Returns the SdrObject from the passed control shape and sets the bounding rectangle. */
     494                 :            :     SdrObject*          CreateSdrObjectFromShape(
     495                 :            :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rxShape,
     496                 :            :                             const Rectangle& rAnchorRect ) const;
     497                 :            : 
     498                 :            :     /** Sets additional properties to the form control model, calls virtual DoProcessControl(). */
     499                 :            :     void                ProcessControl( const XclImpDrawObjBase& rDrawObj ) const;
     500                 :            : 
     501                 :            : protected:
     502                 :            :     /** Reads the formula for the linked cell from the current position of the stream. */
     503                 :            :     void                ReadCellLinkFormula( XclImpStream& rStrm, bool bWithBoundSize );
     504                 :            :     /** Reads the formula for the source range from the current position of the stream. */
     505                 :            :     void                ReadSourceRangeFormula( XclImpStream& rStrm, bool bWithBoundSize );
     506                 :            : 
     507                 :            :     /** Derived classes will set additional properties for the current form control. */
     508                 :            :     virtual void        DoProcessControl( ScfPropertySet& rPropSet ) const;
     509                 :            : 
     510                 :            :     void ApplySheetLinkProps() const;
     511                 :            :     mutable ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     512                 :            :                                    mxShape;        /// The UNO wrapper of the control shape.
     513                 :            :     boost::shared_ptr< ScAddress > mxCellLink;     /// Linked cell in the Calc document.
     514                 :            : private:
     515                 :            :     /** Reads a list of cell ranges from a formula at the current stream position. */
     516                 :            :     void                ReadRangeList( ScRangeList& rScRanges, XclImpStream& rStrm );
     517                 :            :     /** Reads leading formula size and a list of cell ranges from a formula if the leading size is not zero. */
     518                 :            :     void                ReadRangeList( ScRangeList& rScRanges, XclImpStream& rStrm, bool bWithBoundSize );
     519                 :            : 
     520                 :            : private:
     521                 :            :     const XclImpRoot&            mrRoot;     /// Not derived from XclImpRoot to allow multiple inheritance.
     522                 :            :     boost::shared_ptr< ScRange > mxSrcRange; /// Source data range in the Calc document.
     523                 :            :     XclCtrlBindMode              meBindMode; /// Value binding mode.
     524                 :            : };
     525                 :            : 
     526                 :            : // ----------------------------------------------------------------------------
     527                 :            : 
     528                 :            : /** Base class for textbox based form controls. */
     529 [ +  - ][ -  + ]:         45 : class XclImpTbxObjBase : public XclImpTextObj, public XclImpControlHelper
     530                 :            : {
     531                 :            : public:
     532                 :            :     explicit            XclImpTbxObjBase( const XclImpRoot& rRoot );
     533                 :            : 
     534                 :            :     /** Sets line and fill formatting from the passed DFF property set. */
     535                 :            :     void                SetDffProperties( const DffPropSet& rDffPropSet );
     536                 :            : 
     537                 :            :     /** Returns the service name of the control component to be created. */
     538                 :         15 :     inline ::rtl::OUString GetServiceName() const { return DoGetServiceName(); }
     539                 :            :     /** Fills the passed macro event descriptor. */
     540                 :            :     bool                FillMacroDescriptor(
     541                 :            :                             ::com::sun::star::script::ScriptEventDescriptor& rDescriptor ) const;
     542                 :            : 
     543                 :            : protected:
     544                 :            :     /** Sets control text formatting. */
     545                 :            :     void                ConvertFont( ScfPropertySet& rPropSet ) const;
     546                 :            :     /** Sets control label and text formatting. */
     547                 :            :     void                ConvertLabel( ScfPropertySet& rPropSet ) const;
     548                 :            : 
     549                 :            :     /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
     550                 :            :     virtual SdrObject*  DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const;
     551                 :            :     /** Additional processing on the SdrObject, calls new virtual function DoProcessControl(). */
     552                 :            :     virtual void        DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
     553                 :            : 
     554                 :            :     /** Derived classes return the service name of the control component to be created. */
     555                 :            :     virtual ::rtl::OUString DoGetServiceName() const = 0;
     556                 :            :     /** Derived classes return the type of the macro event to be created. */
     557                 :            :     virtual XclTbxEventType DoGetEventType() const = 0;
     558                 :            : };
     559                 :            : 
     560                 :            : // ----------------------------------------------------------------------------
     561                 :            : 
     562                 :            : /** A button control. */
     563         [ #  # ]:          0 : class XclImpButtonObj : public XclImpTbxObjBase
     564                 :            : {
     565                 :            : public:
     566                 :            :     explicit            XclImpButtonObj( const XclImpRoot& rRoot );
     567                 :            : 
     568                 :            : protected:
     569                 :            :     /** Sets additional properties for the current form control. */
     570                 :            :     virtual void        DoProcessControl( ScfPropertySet& rPropSet ) const;
     571                 :            :     /** Returns the service name of the control component to be created. */
     572                 :            :     virtual ::rtl::OUString DoGetServiceName() const;
     573                 :            :     /** Returns the type of the macro event to be created. */
     574                 :            :     virtual XclTbxEventType DoGetEventType() const;
     575                 :            : };
     576                 :            : 
     577                 :            : // ----------------------------------------------------------------------------
     578                 :            : 
     579                 :            : /** A checkbox control. */
     580         [ -  + ]:         12 : class XclImpCheckBoxObj : public XclImpTbxObjBase
     581                 :            : {
     582                 :            : public:
     583                 :            :     explicit            XclImpCheckBoxObj( const XclImpRoot& rRoot );
     584                 :            : 
     585                 :            : protected:
     586                 :            :     /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
     587                 :            :     virtual void        DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
     588                 :            :     /** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
     589                 :            :     virtual void        DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize );
     590                 :            :     /** Sets additional properties for the current form control. */
     591                 :            :     virtual void        DoProcessControl( ScfPropertySet& rPropSet ) const;
     592                 :            :     /** Returns the service name of the control component to be created. */
     593                 :            :     virtual ::rtl::OUString DoGetServiceName() const;
     594                 :            :     /** Returns the type of the macro event to be created. */
     595                 :            :     virtual XclTbxEventType DoGetEventType() const;
     596                 :            : 
     597                 :            : protected:
     598                 :            :     sal_uInt16          mnState;
     599                 :            :     sal_uInt16          mnCheckBoxFlags;
     600                 :            : };
     601                 :            : 
     602                 :            : // ----------------------------------------------------------------------------
     603                 :            : 
     604                 :            : /** An option button control. */
     605         [ -  + ]:         24 : class XclImpOptionButtonObj : public XclImpCheckBoxObj
     606                 :            : {
     607                 :            : public:
     608                 :            :     explicit            XclImpOptionButtonObj( const XclImpRoot& rRoot );
     609                 :            : 
     610                 :            : protected:
     611                 :            :     /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
     612                 :            :     virtual void        DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
     613                 :            :     /** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
     614                 :            :     virtual void        DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize );
     615                 :            :     /** Sets additional properties for the current form control. */
     616                 :            :     virtual void        DoProcessControl( ScfPropertySet& rPropSet ) const;
     617                 :            :     /** Returns the service name of the control component to be created. */
     618                 :            :     virtual ::rtl::OUString DoGetServiceName() const;
     619                 :            :     /** Returns the type of the macro event to be created. */
     620                 :            :     virtual XclTbxEventType DoGetEventType() const;
     621                 :            : 
     622                 :            : protected:
     623                 :            :     void ApplyGrouping( XclImpOptionButtonObj& rLeader, sal_Int32 nRefVal );
     624                 :            :     sal_uInt16          mnNextInGroup;      /// Next option button in a group.
     625                 :            :     sal_uInt16          mnFirstInGroup;     /// 1 = Button is the first in a group.
     626                 :            : };
     627                 :            : 
     628                 :            : // ----------------------------------------------------------------------------
     629                 :            : 
     630                 :            : /** A label control. */
     631         [ #  # ]:          0 : class XclImpLabelObj : public XclImpTbxObjBase
     632                 :            : {
     633                 :            : public:
     634                 :            :     explicit            XclImpLabelObj( const XclImpRoot& rRoot );
     635                 :            : 
     636                 :            : protected:
     637                 :            :     /** Sets additional properties for the current form control. */
     638                 :            :     virtual void        DoProcessControl( ScfPropertySet& rPropSet ) const;
     639                 :            :     /** Returns the service name of the control component to be created. */
     640                 :            :     virtual ::rtl::OUString DoGetServiceName() const;
     641                 :            :     /** Returns the type of the macro event to be created. */
     642                 :            :     virtual XclTbxEventType DoGetEventType() const;
     643                 :            : };
     644                 :            : 
     645                 :            : // ----------------------------------------------------------------------------
     646                 :            : 
     647                 :            : /** A groupbox control. */
     648         [ -  + ]:          6 : class XclImpGroupBoxObj : public XclImpTbxObjBase
     649                 :            : {
     650                 :            : public:
     651                 :            :     explicit            XclImpGroupBoxObj( const XclImpRoot& rRoot );
     652                 :            : 
     653                 :            : protected:
     654                 :            :     /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
     655                 :            :     virtual void        DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
     656                 :            :     /** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
     657                 :            :     virtual void        DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize );
     658                 :            :     /** Sets additional properties for the current form control. */
     659                 :            :     virtual void        DoProcessControl( ScfPropertySet& rPropSet ) const;
     660                 :            :     /** Returns the service name of the control component to be created. */
     661                 :            :     virtual ::rtl::OUString DoGetServiceName() const;
     662                 :            :     /** Returns the type of the macro event to be created. */
     663                 :            :     virtual XclTbxEventType DoGetEventType() const;
     664                 :            : 
     665                 :            : protected:
     666                 :            :     sal_uInt16          mnGroupBoxFlags;
     667                 :            : };
     668                 :            : 
     669                 :            : // ----------------------------------------------------------------------------
     670                 :            : 
     671                 :            : /** A dialog control. */
     672         [ #  # ]:          0 : class XclImpDialogObj : public XclImpTbxObjBase
     673                 :            : {
     674                 :            : public:
     675                 :            :     explicit            XclImpDialogObj( const XclImpRoot& rRoot );
     676                 :            : 
     677                 :            : protected:
     678                 :            :     /** Sets additional properties for the current form control. */
     679                 :            :     virtual void        DoProcessControl( ScfPropertySet& rPropSet ) const;
     680                 :            :     /** Returns the service name of the control component to be created. */
     681                 :            :     virtual ::rtl::OUString DoGetServiceName() const;
     682                 :            :     /** Returns the type of the macro event to be created. */
     683                 :            :     virtual XclTbxEventType DoGetEventType() const;
     684                 :            : };
     685                 :            : 
     686                 :            : // ----------------------------------------------------------------------------
     687                 :            : 
     688                 :            : /** An edit control. */
     689         [ #  # ]:          0 : class XclImpEditObj : public XclImpTbxObjBase
     690                 :            : {
     691                 :            : public:
     692                 :            :     explicit            XclImpEditObj( const XclImpRoot& rRoot );
     693                 :            : 
     694                 :            : protected:
     695                 :            :     /** REturns true, if the field type is numeric. */
     696                 :            :     bool                IsNumeric() const;
     697                 :            : 
     698                 :            :     /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
     699                 :            :     virtual void        DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
     700                 :            :     /** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
     701                 :            :     virtual void        DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize );
     702                 :            :     /** Sets additional properties for the current form control. */
     703                 :            :     virtual void        DoProcessControl( ScfPropertySet& rPropSet ) const;
     704                 :            :     /** Returns the service name of the control component to be created. */
     705                 :            :     virtual ::rtl::OUString DoGetServiceName() const;
     706                 :            :     /** Returns the type of the macro event to be created. */
     707                 :            :     virtual XclTbxEventType DoGetEventType() const;
     708                 :            : 
     709                 :            : protected:
     710                 :            :     sal_uInt16          mnContentType;
     711                 :            :     sal_uInt16          mnMultiLine;
     712                 :            :     sal_uInt16          mnScrollBar;
     713                 :            :     sal_uInt16          mnListBoxObjId;
     714                 :            : };
     715                 :            : 
     716                 :            : // ----------------------------------------------------------------------------
     717                 :            : 
     718                 :            : /** Base class of scrollable form controls (spin button, scrollbar, listbox, dropdown). */
     719         [ -  + ]:         30 : class XclImpTbxObjScrollableBase : public XclImpTbxObjBase
     720                 :            : {
     721                 :            : public:
     722                 :            :     explicit            XclImpTbxObjScrollableBase( const XclImpRoot& rRoot );
     723                 :            : 
     724                 :            : protected:
     725                 :            :     /** Reads scrollbar data. */
     726                 :            :     void                ReadSbs( XclImpStream& rStrm );
     727                 :            : 
     728                 :            :     /** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
     729                 :            :     virtual void        DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize );
     730                 :            : 
     731                 :            : protected:
     732                 :            :     sal_uInt16          mnValue;
     733                 :            :     sal_uInt16          mnMin;
     734                 :            :     sal_uInt16          mnMax;
     735                 :            :     sal_uInt16          mnStep;
     736                 :            :     sal_uInt16          mnPageStep;
     737                 :            :     sal_uInt16          mnOrient;
     738                 :            :     sal_uInt16          mnThumbWidth;
     739                 :            :     sal_uInt16          mnScrollFlags;
     740                 :            : };
     741                 :            : 
     742                 :            : // ----------------------------------------------------------------------------
     743                 :            : 
     744                 :            : /** A spinbutton control. */
     745         [ #  # ]:          0 : class XclImpSpinButtonObj : public XclImpTbxObjScrollableBase
     746                 :            : {
     747                 :            : public:
     748                 :            :     explicit            XclImpSpinButtonObj( const XclImpRoot& rRoot );
     749                 :            : 
     750                 :            : protected:
     751                 :            :     /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
     752                 :            :     virtual void        DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
     753                 :            :     /** Sets additional properties for the current form control. */
     754                 :            :     virtual void        DoProcessControl( ScfPropertySet& rPropSet ) const;
     755                 :            :     /** Returns the service name of the control component to be created. */
     756                 :            :     virtual ::rtl::OUString DoGetServiceName() const;
     757                 :            :     /** Returns the type of the macro event to be created. */
     758                 :            :     virtual XclTbxEventType DoGetEventType() const;
     759                 :            : };
     760                 :            : 
     761                 :            : // ----------------------------------------------------------------------------
     762                 :            : 
     763                 :            : /** A scrollbar control. */
     764         [ #  # ]:          0 : class XclImpScrollBarObj : public XclImpTbxObjScrollableBase
     765                 :            : {
     766                 :            : public:
     767                 :            :     explicit            XclImpScrollBarObj( const XclImpRoot& rRoot );
     768                 :            : 
     769                 :            : protected:
     770                 :            :     /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
     771                 :            :     virtual void        DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
     772                 :            :     /** Sets additional properties for the current form control. */
     773                 :            :     virtual void        DoProcessControl( ScfPropertySet& rPropSet ) const;
     774                 :            :     /** Returns the service name of the control component to be created. */
     775                 :            :     virtual ::rtl::OUString DoGetServiceName() const;
     776                 :            :     /** Returns the type of the macro event to be created. */
     777                 :            :     virtual XclTbxEventType DoGetEventType() const;
     778                 :            : };
     779                 :            : 
     780                 :            : // ----------------------------------------------------------------------------
     781                 :            : 
     782                 :            : /** Base class for list controls (listbox, dropdown). */
     783         [ -  + ]:         30 : class XclImpTbxObjListBase : public XclImpTbxObjScrollableBase
     784                 :            : {
     785                 :            : public:
     786                 :            :     explicit            XclImpTbxObjListBase( const XclImpRoot& rRoot );
     787                 :            : 
     788                 :            : protected:
     789                 :            :     /** Reads common listbox settings. */
     790                 :            :     void                ReadLbsData( XclImpStream& rStrm );
     791                 :            :     /** Sets common listbox/dropdown formatting attributes. */
     792                 :            :     void                SetBoxFormatting( ScfPropertySet& rPropSet ) const;
     793                 :            : 
     794                 :            : protected:
     795                 :            :     sal_uInt16          mnEntryCount;
     796                 :            :     sal_uInt16          mnSelEntry;
     797                 :            :     sal_uInt16          mnListFlags;
     798                 :            :     sal_uInt16          mnEditObjId;
     799                 :            :     bool                mbHasDefFontIdx;
     800                 :            : };
     801                 :            : 
     802                 :            : // ----------------------------------------------------------------------------
     803                 :            : 
     804                 :            : /** A listbox control. */
     805         [ #  # ]:          0 : class XclImpListBoxObj : public XclImpTbxObjListBase
     806                 :            : {
     807                 :            : public:
     808                 :            :     explicit            XclImpListBoxObj( const XclImpRoot& rRoot );
     809                 :            : 
     810                 :            : protected:
     811                 :            :     /** Reads listbox settings and selection. */
     812                 :            :     void                ReadFullLbsData( XclImpStream& rStrm, sal_Size nRecLeft );
     813                 :            : 
     814                 :            :     /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
     815                 :            :     virtual void        DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
     816                 :            :     /** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
     817                 :            :     virtual void        DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize );
     818                 :            :     /** Sets additional properties for the current form control. */
     819                 :            :     virtual void        DoProcessControl( ScfPropertySet& rPropSet ) const;
     820                 :            :     /** Returns the service name of the control component to be created. */
     821                 :            :     virtual ::rtl::OUString DoGetServiceName() const;
     822                 :            :     /** Returns the type of the macro event to be created. */
     823                 :            :     virtual XclTbxEventType DoGetEventType() const;
     824                 :            : 
     825                 :            : protected:
     826                 :            :     ScfUInt8Vec         maSelection;
     827                 :            : };
     828                 :            : 
     829                 :            : // ----------------------------------------------------------------------------
     830                 :            : 
     831                 :            : /** A dropdown listbox control. */
     832         [ -  + ]:         60 : class XclImpDropDownObj : public XclImpTbxObjListBase
     833                 :            : {
     834                 :            : public:
     835                 :            :     explicit            XclImpDropDownObj( const XclImpRoot& rRoot );
     836                 :            : 
     837                 :            : protected:
     838                 :            :     /** Returns the type of the dropdown control. */
     839                 :            :     sal_uInt16          GetDropDownType() const;
     840                 :            : 
     841                 :            :     /** Reads dropdown box settings. */
     842                 :            :     void                ReadFullLbsData( XclImpStream& rStrm );
     843                 :            : 
     844                 :            :     /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
     845                 :            :     virtual void        DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
     846                 :            :     /** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
     847                 :            :     virtual void        DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize );
     848                 :            :     /** Sets additional properties for the current form control. */
     849                 :            :     virtual void        DoProcessControl( ScfPropertySet& rPropSet ) const;
     850                 :            :     /** Returns the service name of the control component to be created. */
     851                 :            :     virtual ::rtl::OUString DoGetServiceName() const;
     852                 :            :     /** Returns the type of the macro event to be created. */
     853                 :            :     virtual XclTbxEventType DoGetEventType() const;
     854                 :            : 
     855                 :            : protected:
     856                 :            :     sal_uInt16          mnLeft;
     857                 :            :     sal_uInt16          mnTop;
     858                 :            :     sal_uInt16          mnRight;
     859                 :            :     sal_uInt16          mnBottom;
     860                 :            :     sal_uInt16          mnDropDownFlags;
     861                 :            :     sal_uInt16          mnLineCount;
     862                 :            :     sal_uInt16          mnMinWidth;
     863                 :            : };
     864                 :            : 
     865                 :            : // ----------------------------------------------------------------------------
     866                 :            : 
     867                 :            : /** A picture, an embedded or linked OLE object, or an OCX form control. */
     868 [ +  - ][ +  - ]:         28 : class XclImpPictureObj : public XclImpRectObj, public XclImpControlHelper
         [ +  - ][ -  + ]
     869                 :            : {
     870                 :            : public:
     871                 :            :     explicit            XclImpPictureObj( const XclImpRoot& rRoot );
     872                 :            :     /** Returns the ObjectName - can use non-obvious lookup for override in the associated vba document module stream**/
     873                 :            :     virtual rtl::OUString GetObjName() const;
     874                 :            :     /** Returns the graphic imported from the IMGDATA record. */
     875                 :          0 :     inline const Graphic& GetGraphic() const { return maGraphic; }
     876                 :            : 
     877                 :            :     /** Returns the visible area of the imported graphic. */
     878                 :          0 :     inline const Rectangle& GetVisArea() const { return maVisArea; }
     879                 :            : 
     880                 :            :     /** Returns true, if the OLE object will be shown as symbol. */
     881                 :          0 :     inline bool         IsSymbol() const { return mbSymbol; }
     882                 :            :     /** Returns the storage name for the OLE object. */
     883                 :            :     String              GetOleStorageName() const;
     884                 :            : 
     885                 :            :     /** Returns true, if this object is an OCX form control. */
     886 [ +  + ][ +  - ]:         78 :     inline bool         IsOcxControl() const { return mbEmbedded && mbControl && mbUseCtlsStrm; }
                 [ +  - ]
     887                 :            :     /** Returns the position in the 'Ctls' stream for additional form control data. */
     888                 :         11 :     inline sal_Size     GetCtlsStreamPos() const { return mnCtlsStrmPos; }
     889                 :            :     /** Returns the size in the 'Ctls' stream for additional form control data. */
     890                 :         11 :     inline sal_Size     GetCtlsStreamSize() const { return mnCtlsStrmSize; }
     891                 :            : 
     892                 :            : protected:
     893                 :            :     /** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
     894                 :            :     virtual void        DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize );
     895                 :            :     /** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
     896                 :            :     virtual void        DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize );
     897                 :            :     /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
     898                 :            :     virtual void        DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
     899                 :            :     /** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
     900                 :            :     virtual void        DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize );
     901                 :            :     /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
     902                 :            :     virtual SdrObject*  DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const;
     903                 :            :     /** Overloaded to do additional processing on the SdrObject. */
     904                 :            :     virtual void        DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
     905                 :            : 
     906                 :            : private:
     907                 :            :     /** Reads and sets the picture flags from a BIFF3-BIFF5 OBJ picture record. */
     908                 :            :     void                ReadFlags3( XclImpStream& rStrm );
     909                 :            :     /** Reads the contents of the OBJFLAGS subrecord. */
     910                 :            :     void                ReadFlags8( XclImpStream& rStrm );
     911                 :            :     /** Reads the contents of the OBJPICTFMLA subrecord. */
     912                 :            :     void                ReadPictFmla( XclImpStream& rStrm, sal_uInt16 nLinkSize );
     913                 :            : 
     914                 :            : private:
     915                 :            :     Graphic             maGraphic;      /// Picture or OLE placeholder graphic.
     916                 :            :     Rectangle           maVisArea;      /// Size of graphic.
     917                 :            :     String              maClassName;    /// Class name of embedded OLE object.
     918                 :            :     sal_uInt32          mnStorageId;    /// Identifier of the storage for this object.
     919                 :            :     sal_Size            mnCtlsStrmPos;  /// Position in 'Ctls' stream for this control.
     920                 :            :     sal_Size            mnCtlsStrmSize; /// Size in 'Ctls' stream for this control.
     921                 :            :     bool                mbEmbedded;     /// true = Embedded OLE object.
     922                 :            :     bool                mbLinked;       /// true = Linked OLE object.
     923                 :            :     bool                mbSymbol;       /// true = Show as symbol.
     924                 :            :     bool                mbControl;      /// true = Form control, false = OLE object.
     925                 :            :     bool                mbUseCtlsStrm;  /// true = Form control data in 'Ctls' stream, false = Own storage.
     926                 :            : };
     927                 :            : 
     928                 :            : // DFF stream conversion ======================================================
     929                 :            : 
     930                 :            : /** The solver container collects all connector rules for connected objects. */
     931 [ +  - ][ +  - ]:        124 : class XclImpSolverContainer : public SvxMSDffSolverContainer
     932                 :            : {
     933                 :            : public:
     934                 :            : 
     935                 :            :     /** Inserts information about a new SdrObject. */
     936                 :            :     void                InsertSdrObjectInfo( SdrObject& rSdrObj, sal_uInt32 nDffShapeId, sal_uInt32 nDffFlags );
     937                 :            :     /** Removes inforamtion of an SdrObject (and all child objects if it is a group). */
     938                 :            :     void                RemoveSdrObjectInfo( SdrObject& rSdrObj );
     939                 :            : 
     940                 :            :     /** Inserts the SdrObject pointers into all connector rules. */
     941                 :            :     void                UpdateConnectorRules();
     942                 :            :     /** Removes all contained connector rules. */
     943                 :            :     void                RemoveConnectorRules();
     944                 :            : 
     945                 :            : private:
     946                 :            :     /** Updates the data of a connected shape in a connector rule. */
     947                 :            :     void                UpdateConnection( sal_uInt32 nDffShapeId, SdrObject*& rpSdrObj, sal_uInt32* pnDffFlags = 0 );
     948                 :            : 
     949                 :            : private:
     950                 :            :     /** Stores data about an SdrObject processed during import. */
     951                 :            :     struct XclImpSdrInfo
     952                 :            :     {
     953                 :            :         SdrObject*          mpSdrObj;       /// Pointer to an SdrObject.
     954                 :            :         sal_uInt32          mnDffFlags;     /// Shape flags from DFF stream.
     955                 :         68 :         inline explicit     XclImpSdrInfo() : mpSdrObj( 0 ), mnDffFlags( 0 ) {}
     956                 :         68 :         inline void         Set( SdrObject* pSdrObj, sal_uInt32 nDffFlags )
     957                 :         68 :                                 { mpSdrObj = pSdrObj; mnDffFlags = nDffFlags; }
     958                 :            :     };
     959                 :            :     typedef ::std::map< sal_uInt32, XclImpSdrInfo > XclImpSdrInfoMap;
     960                 :            :     typedef ::std::map< SdrObject*, sal_uInt32 >    XclImpSdrObjMap;
     961                 :            : 
     962                 :            :     XclImpSdrInfoMap    maSdrInfoMap;   /// Maps shape IDs to SdrObjects and flags.
     963                 :            :     XclImpSdrObjMap     maSdrObjMap;    /// Maps SdrObjects to shape IDs.
     964                 :            : };
     965                 :            : 
     966                 :            : // ----------------------------------------------------------------------------
     967                 :            : 
     968                 :            : /** Simple implementation of the SVX DFF manager. Implements resolving palette
     969                 :            :     colors. Used by XclImpDffPropSet (as is), extended by XclImpDffConverter.
     970                 :            :  */
     971                 :            : class XclImpSimpleDffConverter : public SvxMSDffManager, protected XclImpRoot
     972                 :            : {
     973                 :            : public:
     974                 :            :     explicit            XclImpSimpleDffConverter( const XclImpRoot& rRoot, SvStream& rDffStrm );
     975                 :            :     virtual             ~XclImpSimpleDffConverter();
     976                 :            : 
     977                 :            : protected:
     978                 :            :     /** Returns a color from the Excel color palette. */
     979                 :            :     virtual bool        GetColorFromPalette( sal_uInt16 nIndex, Color& rColor ) const;
     980                 :            : };
     981                 :            : 
     982                 :            : // ----------------------------------------------------------------------------
     983                 :            : 
     984                 :            : /** This is the central instance for converting binary DFF data into shape
     985                 :            :     objects. Used for all sheet shapes and shapes embedded in chart objects.
     986                 :            : 
     987                 :            :     The class derives from SvxMSDffManager and SvxMSConvertOCXControls and
     988                 :            :     contains core implementation of DFF stream import and OCX form control
     989                 :            :     import.
     990                 :            :  */
     991                 :            : class XclImpDffConverter : public XclImpSimpleDffConverter, private oox::ole::MSConvertOCXControls
     992                 :            : {
     993                 :            : public:
     994                 :            :     explicit            XclImpDffConverter( const XclImpRoot& rRoot, SvStream& rDffStrm );
     995                 :            :     virtual             ~XclImpDffConverter();
     996                 :            : 
     997                 :            :     /** Initializes the internal progress bar with the passed size and starts it. */
     998                 :            :     void                StartProgressBar( sal_Size nProgressSize );
     999                 :            :     /** Increase the progress bar by the passed value. */
    1000                 :            :     void                Progress( sal_Size nDelta = 1 );
    1001                 :            : 
    1002                 :            :     /** Initially called before the objects of the passed drawing manager are converted. */
    1003                 :            :     void                InitializeDrawing( XclImpDrawing& rDrawing, SdrModel& rSdrModel, SdrPage& rSdrPage );
    1004                 :            :     /** Processes BIFF5 drawing objects without DFF data, inserts into the passed object list. */
    1005                 :            :     void                ProcessObject( SdrObjList& rObjList, const XclImpDrawObjBase& rDrawObj );
    1006                 :            :     /** Processes all objects in the passed list. */
    1007                 :            :     void                ProcessDrawing( const XclImpDrawObjVector& rDrawObjs );
    1008                 :            :     /** Processes a drawing container in the passed DFF stream, converts all objects. */
    1009                 :            :     void                ProcessDrawing( SvStream& rDffStrm );
    1010                 :            :     /** Finally called after the objects of the passed drawing manager have been converted. */
    1011                 :            :     void                FinalizeDrawing();
    1012                 :            : 
    1013                 :            :     /** Creates the SdrObject for the passed Excel TBX form control object. */
    1014                 :            :     SdrObject*          CreateSdrObject( const XclImpTbxObjBase& rTbxObj, const Rectangle& rAnchorRect );
    1015                 :            :     /** Creates the SdrObject for the passed Excel OLE object or OCX form control object. */
    1016                 :            :     SdrObject*          CreateSdrObject( const XclImpPictureObj& rPicObj, const Rectangle& rAnchorRect );
    1017                 :            : 
    1018                 :            :     /** Returns true, if the conversion of OLE objects is supported. */
    1019                 :            :     bool                SupportsOleObjects() const;
    1020                 :            :     /** Returns the default text margin in drawing layer units. */
    1021                 :         68 :     inline sal_Int32    GetDefaultTextMargin() const { return mnDefTextMargin; }
    1022                 :            : 
    1023                 :            : private:
    1024                 :            :     // virtual functions of SvxMSDffManager
    1025                 :            : 
    1026                 :            :     /** Reads the client anchor from the DFF stream and sets it at the correct object. */
    1027                 :            :     virtual void        ProcessClientAnchor2(
    1028                 :            :                             SvStream& rDffStrm,
    1029                 :            :                             DffRecordHeader& rHeader,
    1030                 :            :                             void* pClientData,
    1031                 :            :                             DffObjData& rObjData );
    1032                 :            :     /** Processes an DFF object, reads properties from DFF stream. */
    1033                 :            :     virtual SdrObject*  ProcessObj(
    1034                 :            :                             SvStream& rDffStrm,
    1035                 :            :                             DffObjData& rDffObjData,
    1036                 :            :                             void* pClientData,
    1037                 :            :                             Rectangle& rTextRect,
    1038                 :            :                             SdrObject* pOldSdrObj = 0 );
    1039                 :            :     /** Returns the BLIP stream position, based on the passed DFF stream position. */
    1040                 :            :     virtual sal_uLong       Calc_nBLIPPos( sal_uLong nOrgVal, sal_uLong nStreamPos ) const;
    1041                 :            : 
    1042                 :            :     // virtual functions of SvxMSConvertOCXControls
    1043                 :            : 
    1044                 :            :     /** Inserts the passed control rxFComp into the form. Needs call to SetCurrentForm() before. */
    1045                 :            :     virtual sal_Bool    InsertControl(
    1046                 :            :                             const ::com::sun::star::uno::Reference<
    1047                 :            :                                 ::com::sun::star::form::XFormComponent >& rxFormComp,
    1048                 :            :                             const ::com::sun::star::awt::Size& rSize,
    1049                 :            :                             ::com::sun::star::uno::Reference<
    1050                 :            :                                 ::com::sun::star::drawing::XShape >* pxShape,
    1051                 :            :                             sal_Bool bFloatingCtrl );
    1052                 :            : 
    1053                 :            : private:
    1054                 :            :     /** Data per registered drawing manager, will be stacked for recursive calls. */
    1055                 :         62 :     struct XclImpDffConvData
    1056                 :            :     {
    1057                 :            :         XclImpDrawing&      mrDrawing;          /// Current drawing container with all drawing objects.
    1058                 :            :         SdrModel&           mrSdrModel;         /// The SdrModel of the drawing manager.
    1059                 :            :         SdrPage&            mrSdrPage;          /// The SdrPage of the drawing manager.
    1060                 :            :         XclImpSolverContainer maSolverCont;     /// The solver container for connector rules.
    1061                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >
    1062                 :            :                             mxCtrlForm;         /// Controls form of current drawing page.
    1063                 :            :         sal_Int32           mnLastCtrlIndex;    /// Last insertion index of a form control (for macro events).
    1064                 :            :         bool                mbHasCtrlForm;      /// True = mxCtrlForm is initialized (but maybe still null).
    1065                 :            : 
    1066                 :            :         explicit            XclImpDffConvData( XclImpDrawing& rDrawing,
    1067                 :            :                                 SdrModel& rSdrModel, SdrPage& rSdrPage );
    1068                 :            :     };
    1069                 :            : 
    1070                 :            :     /** Returns the current drawing manager data struct from top of the stack. */
    1071                 :            :     XclImpDffConvData&      GetConvData();
    1072                 :            :     /** Returns the current drawing manager data struct from top of the stack. */
    1073                 :            :     const XclImpDffConvData& GetConvData() const;
    1074                 :            : 
    1075                 :            :     /** Reads contents of a hyperlink property and returns the extracted URL. */
    1076                 :            :     String              ReadHlinkProperty( SvStream& rDffStrm ) const;
    1077                 :            : 
    1078                 :            :     /** Processes a drawing container (all drawing data of a sheet). */
    1079                 :            :     void                ProcessDgContainer( SvStream& rDffStrm, const DffRecordHeader& rDgHeader );
    1080                 :            :     /** Processes the global shape group container (all shapes of a sheet). */
    1081                 :            :     void                ProcessShGrContainer( SvStream& rDffStrm, const DffRecordHeader& rShGrHeader );
    1082                 :            :     /** Processes the solver container (connectors of a sheet). */
    1083                 :            :     void                ProcessSolverContainer( SvStream& rDffStrm, const DffRecordHeader& rSolverHeader );
    1084                 :            :     /** Processes a shape or shape group container (one top-level shape). */
    1085                 :            :     void                ProcessShContainer( SvStream& rDffStrm, const DffRecordHeader& rShHeader );
    1086                 :            : 
    1087                 :            :     /** Inserts the passed SdrObject into the document. This function takes ownership of pSdrObj! */
    1088                 :            :     void                InsertSdrObject( SdrObjList& rObjList, const XclImpDrawObjBase& rDrawObj, SdrObject* pSdrObj );
    1089                 :            :     /** Initializes the mxCtrlForm referring to the standard controls form. */
    1090                 :            :     void                InitControlForm();
    1091                 :            : 
    1092                 :            : private:
    1093                 :            :     typedef boost::shared_ptr< ScfProgressBar >     ScfProgressBarRef;
    1094                 :            :     typedef boost::shared_ptr< XclImpDffConvData >  XclImpDffConvDataRef;
    1095                 :            :     typedef ::std::vector< XclImpDffConvDataRef >   XclImpDffConvDataStack;
    1096                 :            : 
    1097                 :            :     const ::rtl::OUString maStdFormName;    /// Standard name of control forms.
    1098                 :            :     SotStorageStreamRef mxCtlsStrm;         /// The 'Ctls' stream for OCX form controls.
    1099                 :            :     ScfProgressBarRef   mxProgress;         /// The progress bar used in ProcessObj().
    1100                 :            :     XclImpDffConvDataStack maDataStack;     /// Stack for registered drawing managers.
    1101                 :            :     sal_uInt32          mnOleImpFlags;      /// Application OLE import settings.
    1102                 :            :     sal_Int32           mnDefTextMargin;    /// Default margin in text boxes.
    1103                 :            : };
    1104                 :            : 
    1105                 :            : // Drawing manager ============================================================
    1106                 :            : 
    1107                 :            : /** Base class for a container for all objects on a drawing (spreadsheet or
    1108                 :            :     embedded chart object). */
    1109                 :            : class XclImpDrawing : protected XclImpRoot
    1110                 :            : {
    1111                 :            : public:
    1112                 :            :     explicit            XclImpDrawing( const XclImpRoot& rRoot, bool bOleObjects );
    1113                 :            :     virtual             ~XclImpDrawing();
    1114                 :            : 
    1115                 :            :     /** Reads and returns a bitmap from the IMGDATA record. */
    1116                 :            :     static Graphic      ReadImgData( const XclImpRoot& rRoot, XclImpStream& rStrm );
    1117                 :            : 
    1118                 :            :     /** Reads a plain OBJ record (without leading DFF data). */
    1119                 :            :     void                ReadObj( XclImpStream& rStrm );
    1120                 :            :     /** Reads the MSODRAWING or MSODRAWINGSELECTION record. */
    1121                 :            :     void                ReadMsoDrawing( XclImpStream& rStrm );
    1122                 :            : 
    1123                 :            :     /** Returns true, if the conversion of OLE objects is supported. */
    1124                 :         40 :     inline bool         SupportsOleObjects() const { return mbOleObjs; }
    1125                 :            :     /** Finds the OBJ record data related to the DFF shape at the passed position. */
    1126                 :            :     XclImpDrawObjRef    FindDrawObj( const DffRecordHeader& rHeader ) const;
    1127                 :            :     /** Finds the OBJ record data specified by the passed object identifier. */
    1128                 :            :     XclImpDrawObjRef    FindDrawObj( sal_uInt16 nObjId ) const;
    1129                 :            :     /** Finds the textbox data related to the DFF shape at the passed position. */
    1130                 :            :     const XclImpObjTextData* FindTextData( const DffRecordHeader& rHeader ) const;
    1131                 :            : 
    1132                 :            :     /** Sets the object with the passed identification to be skipped on import. */
    1133                 :            :     void                SetSkipObj( sal_uInt16 nObjId );
    1134                 :            :     /** Returns the size of the progress bar shown while processing all objects. */
    1135                 :            :     sal_Size            GetProgressSize() const;
    1136                 :            : 
    1137                 :            :     /** Derived classes calculate the resulting rectangle of the passed anchor. */
    1138                 :            :     virtual Rectangle   CalcAnchorRect( const XclObjAnchor& rAnchor, bool bDffAnchor ) const = 0;
    1139                 :            :     /** Called whenever an object has been inserted into the draw page. */
    1140                 :            :     virtual void        OnObjectInserted( const XclImpDrawObjBase& rDrawObj ) = 0;
    1141                 :            : 
    1142                 :            : protected:
    1143                 :            :     /** Appends a new drawing object to the list of raw objects (without DFF data). */
    1144                 :            :     void                AppendRawObject( const XclImpDrawObjRef& rxDrawObj );
    1145                 :            :     /** Converts all objects and inserts them into the current drawing page. */
    1146                 :            :     void                ImplConvertObjects( XclImpDffConverter& rDffConv, SdrModel& rSdrModel, SdrPage& rSdrPage );
    1147                 :            : 
    1148                 :            : private:
    1149                 :            :     /** Reads and returns a bitmap from WMF/PICT format. */
    1150                 :            :     static void         ReadWmf( Graphic& rGraphic, const XclImpRoot& rRoot, XclImpStream& rStrm );
    1151                 :            :     /** Reads and returns a bitmap from BMP format. */
    1152                 :            :     static void         ReadBmp( Graphic& rGraphic, const XclImpRoot& rRoot, XclImpStream& rStrm );
    1153                 :            : 
    1154                 :            :     /** Reads contents of an DFF record and append data to internal DFF stream. */
    1155                 :            :     void                ReadDffRecord( XclImpStream& rStrm );
    1156                 :            :     /** Reads a BIFF8 OBJ record following an MSODRAWING record. */
    1157                 :            :     void                ReadObj8( XclImpStream& rStrm );
    1158                 :            :     /** Reads the TXO record and following CONTINUE records containing string and formatting. */
    1159                 :            :     void                ReadTxo( XclImpStream& rStrm );
    1160                 :            : 
    1161                 :            : private:
    1162                 :            :     typedef ::std::map< sal_Size, XclImpDrawObjRef >    XclImpObjMap;
    1163                 :            :     typedef ::std::map< sal_uInt16, XclImpDrawObjRef >  XclImpObjMapById;
    1164                 :            :     typedef boost::shared_ptr< XclImpObjTextData >      XclImpObjTextRef;
    1165                 :            :     typedef ::std::map< sal_Size, XclImpObjTextRef >    XclImpObjTextMap;
    1166                 :            : 
    1167                 :            :     XclImpDrawObjVector maRawObjs;          /// BIFF5 objects without DFF data.
    1168                 :            :     SvMemoryStream      maDffStrm;          /// Copy of the DFF page stream in memory.
    1169                 :            :     XclImpObjMap        maObjMap;           /// Maps BIFF8 drawing objects to DFF stream position.
    1170                 :            :     XclImpObjMapById    maObjMapId;         /// Maps BIFF8 drawing objects to object ID.
    1171                 :            :     XclImpObjTextMap    maTextMap;          /// Maps BIFF8 TXO textbox data to DFF stream position.
    1172                 :            :     ScfUInt16Vec        maSkipObjs;         /// IDs of all objects to be skipped.
    1173                 :            :     bool                mbOleObjs;          /// True = draw model supports OLE objects.
    1174                 :            : };
    1175                 :            : 
    1176                 :            : // ----------------------------------------------------------------------------
    1177                 :            : 
    1178                 :            : /** Drawing manager of a single sheet. */
    1179         [ -  + ]:        172 : class XclImpSheetDrawing : public XclImpDrawing
    1180                 :            : {
    1181                 :            : public:
    1182                 :            :     explicit            XclImpSheetDrawing( const XclImpRoot& rRoot, SCTAB nScTab );
    1183                 :            : 
    1184                 :            :     /** Reads the NOTE record. */
    1185                 :            :     void                ReadNote( XclImpStream& rStrm );
    1186                 :            :     /** Inserts a new chart object and reads the chart substream (BOF/EOF block).
    1187                 :            :         @descr  Used to import chart sheets, which do not have a corresponding OBJ record. */
    1188                 :            :     void                ReadTabChart( XclImpStream& rStrm );
    1189                 :            : 
    1190                 :            :     /** Returns the total cell range covered by any shapes in the sheet. */
    1191                 :         29 :     inline const ScRange& GetUsedArea() const { return maScUsedArea; }
    1192                 :            :     /** Converts all objects and inserts them into the sheet drawing page. */
    1193                 :            :     void                ConvertObjects( XclImpDffConverter& rDffConv );
    1194                 :            : 
    1195                 :            :     /** Calculate the resulting rectangle of the passed anchor. */
    1196                 :            :     virtual Rectangle   CalcAnchorRect( const XclObjAnchor& rAnchor, bool bDffAnchor ) const;
    1197                 :            :     /** On call, updates the used area of the sheet. */
    1198                 :            :     virtual void        OnObjectInserted( const XclImpDrawObjBase& rDrawObj );
    1199                 :            : 
    1200                 :            : private:
    1201                 :            :     /** Reads a BIFF3-BIFF5 NOTE record. */
    1202                 :            :     void                ReadNote3( XclImpStream& rStrm );
    1203                 :            :     /** Reads a BIFF8 NOTE record. */
    1204                 :            :     void                ReadNote8( XclImpStream& rStrm );
    1205                 :            : 
    1206                 :            : private:
    1207                 :            :     ScRange             maScUsedArea;       /// Sheet index and used area in this sheet.
    1208                 :            : };
    1209                 :            : 
    1210                 :            : // The object manager =========================================================
    1211                 :            : 
    1212                 :            : /** Stores all drawing and OLE objects and additional data related to these objects. */
    1213                 :            : class XclImpObjectManager : protected XclImpRoot
    1214                 :            : {
    1215                 :            : public:
    1216                 :            :     explicit            XclImpObjectManager( const XclImpRoot& rRoot );
    1217                 :            :     virtual             ~XclImpObjectManager();
    1218                 :            : 
    1219                 :            :     /** Reads the MSODRAWINGGROUP record. */
    1220                 :            :     void                ReadMsoDrawingGroup( XclImpStream& rStrm );
    1221                 :            : 
    1222                 :            :     /** Returns (initially creates) the drawing manager of the specified sheet. */
    1223                 :            :     XclImpSheetDrawing& GetSheetDrawing( SCTAB nScTab );
    1224                 :            :     /** Inserts all objects into the Calc document. */
    1225                 :            :     void                ConvertObjects();
    1226                 :            : 
    1227                 :            :     /** Returns the default name for the passed object. */
    1228                 :            :     rtl::OUString       GetDefaultObjName( const XclImpDrawObjBase& rDrawObj ) const;
    1229                 :            :     /** Returns the used area in the sheet with the passed index. */
    1230                 :            :     ScRange             GetUsedArea( SCTAB nScTab ) const;
    1231                 :            :     /** Sets the container to receive overridden shape/ctrl names from
    1232                 :            :         the filter. */
    1233                 :         13 :     void SetOleNameOverrideInfo( const com::sun::star::uno::Reference< com::sun::star::container::XNameContainer >& rxOverrideInfo ) {  mxOleCtrlNameOverride = rxOverrideInfo; }
    1234                 :            :     /** Returns the name of overridden name ( or zero length string ) for
    1235                 :            :         associated object id. */
    1236                 :            :     String GetOleNameOverride( SCTAB nTab, sal_uInt16 nObjId );
    1237                 :            :     // ------------------------------------------------------------------------
    1238                 :            : private:
    1239                 :            : 
    1240                 :            :     /** Reads and returns a bitmap from WMF/PICT format. */
    1241                 :            :     static void         ReadWmf( Graphic& rGraphic, XclImpStream& rStrm );
    1242                 :            :     /** Reads and returns a bitmap from BMP format. */
    1243                 :            :     static void         ReadBmp( Graphic& rGraphic, XclImpStream& rStrm );
    1244                 :            : 
    1245                 :            :     /** Reads contents of an DFF record and append data to internal DFF stream. */
    1246                 :            :     void                ReadDffRecord( XclImpStream& rStrm );
    1247                 :            :     /** Reads a BIFF8 OBJ record following an MSODRAWING record. */
    1248                 :            :     void                ReadObj8( XclImpStream& rStrm );
    1249                 :            :     /** Reads the TXO record and following CONTINUE records containing string and formatting. */
    1250                 :            :     void                ReadTxo( XclImpStream& rStrm );
    1251                 :            : 
    1252                 :            :     /** Reads a BIFF3-BIFF5 NOTE record. */
    1253                 :            :     void                ReadNote3( XclImpStream& rStrm );
    1254                 :            :     /** Reads a BIFF8 NOTE record. */
    1255                 :            :     void                ReadNote8( XclImpStream& rStrm );
    1256                 :            : 
    1257                 :            :     /** Returns the size of the progress bar shown while processing all objects. */
    1258                 :            :     sal_Size            GetProgressSize() const;
    1259                 :            : 
    1260                 :            :     // ------------------------------------------------------------------------
    1261                 :            : private:
    1262                 :            :     typedef ::std::map< sal_uInt16, String >            DefObjNameMap;
    1263                 :            :     typedef boost::shared_ptr< XclImpSheetDrawing >     XclImpSheetDrawingRef;
    1264                 :            :     typedef ::std::map< SCTAB, XclImpSheetDrawingRef >  XclImpSheetDrawingMap;
    1265                 :            : 
    1266                 :            :     com::sun::star::uno::Reference< com::sun::star::container::XNameContainer > mxOleCtrlNameOverride;
    1267                 :            :     DefObjNameMap       maDefObjNames;      /// Default base names for all object types.
    1268                 :            :     SvMemoryStream      maDggStrm;          /// Copy of global DFF data (DGG container) in memory.
    1269                 :            :     XclImpSheetDrawingMap maSheetDrawings;  /// Drawing managers of all sheets.
    1270                 :            : };
    1271                 :            : 
    1272                 :            : // DFF property set helper ====================================================
    1273                 :            : 
    1274                 :            : /** This class reads an DFF property set (msofbtOPT record).
    1275                 :            : 
    1276                 :            :     It can return separate property values or an item set which contains items
    1277                 :            :     translated from these properties.
    1278                 :            :  */
    1279 [ #  # ][ #  # ]:          0 : class XclImpDffPropSet : protected XclImpRoot
         [ #  # ][ #  # ]
    1280                 :            : {
    1281                 :            : public:
    1282                 :            :     explicit            XclImpDffPropSet( const XclImpRoot& rRoot );
    1283                 :            : 
    1284                 :            :     /** Reads an DFF property set from the stream.
    1285                 :            :         @descr  The stream must point to the start of an DFF record containing properties. */
    1286                 :            :     void                Read( XclImpStream& rStrm );
    1287                 :            : 
    1288                 :            :     /** Returns the specified property or the default value, if not extant. */
    1289                 :            :     sal_uInt32          GetPropertyValue( sal_uInt16 nPropId, sal_uInt32 nDefault = 0 ) const;
    1290                 :            : 
    1291                 :            :     /** Translates the properties and fills the item set. */
    1292                 :            :     void                FillToItemSet( SfxItemSet& rItemSet ) const;
    1293                 :            : 
    1294                 :            : private:
    1295                 :            :     typedef ::std::auto_ptr< SvMemoryStream > SvMemoryStreamPtr;
    1296                 :            : 
    1297                 :            :     SvMemoryStream      maDummyStrm;    /// Dummy DGG stream for DFF manager.
    1298                 :            :     XclImpSimpleDffConverter maDffConv; /// DFF converter used to resolve palette colors.
    1299                 :            :     SvMemoryStreamPtr   mxMemStrm;      /// Helper stream.
    1300                 :            : };
    1301                 :            : 
    1302                 :            : XclImpStream& operator>>( XclImpStream& rStrm, XclImpDffPropSet& rPropSet );
    1303                 :            : 
    1304                 :            : // ============================================================================
    1305                 :            : 
    1306                 :            : #endif
    1307                 :            : 
    1308                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10