LCOV - code coverage report
Current view: top level - sc/source/filter/inc - xetable.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 70 0.0 %
Date: 2014-04-14 Functions: 0 97 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef SC_XETABLE_HXX
      21             : #define SC_XETABLE_HXX
      22             : 
      23             : #include "xltable.hxx"
      24             : 
      25             : #include <deque>
      26             : #include <tools/mempool.hxx>
      27             : #include "xladdress.hxx"
      28             : #include "xerecord.hxx"
      29             : #include "xestring.hxx"
      30             : #include "xeformula.hxx"
      31             : #include "xestyle.hxx"
      32             : #include "xeextlst.hxx"
      33             : 
      34             : #include <boost/unordered_set.hpp>
      35             : #include <boost/unordered_map.hpp>
      36             : #include <boost/shared_ptr.hpp>
      37             : #include <map>
      38             : 
      39             : /* ============================================================================
      40             : Export of cell tables including row and column description.
      41             : - Managing all used and formatted cells in a sheet.
      42             : - Row and column properties, i.e. width/height, visibility.
      43             : - Find default row formatting and default column formatting.
      44             : - Merged cell ranges.
      45             : ============================================================================ */
      46             : 
      47             : 
      48             : // Helper records for cell records
      49             : 
      50             : 
      51             : /** Represents a STRING record that contains the result of a string formula. */
      52           0 : class XclExpStringRec : public XclExpRecord
      53             : {
      54             : public:
      55             :     explicit            XclExpStringRec( const XclExpRoot& rRoot, const OUString& rResult );
      56             : 
      57             : private:
      58             :     virtual void        WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
      59             : 
      60             : private:
      61             :     XclExpStringRef     mxResult;
      62             : };
      63             : 
      64             : // Additional records for special formula ranges ==============================
      65             : 
      66             : /** Base record for additional range formula records (i.e. ARRAY, SHRFMLA). */
      67           0 : class XclExpRangeFmlaBase : public XclExpRecord
      68             : {
      69             : public:
      70             :     /** Returns true, if the passed cell position is equal to own base position. */
      71             :     bool                IsBasePos( sal_uInt16 nXclCol, sal_uInt32 nXclRow ) const;
      72             : 
      73             :     /** Derived classes create the token array for a corresponding FORMULA cell record. */
      74             :     virtual XclTokenArrayRef CreateCellTokenArray( const XclExpRoot& rRoot ) const = 0;
      75             :     /** Derived classes return true, if the own formula contains volatile functions. */
      76             :     virtual bool        IsVolatile() const = 0;
      77             : 
      78             : protected:
      79             :     /** Constructs the record with a single cell. */
      80             :     explicit            XclExpRangeFmlaBase(
      81             :                             sal_uInt16 nRecId, sal_uInt32 nRecSize, const ScAddress& rScPos );
      82             :     /** Constructs the record with a cell range. */
      83             :     explicit            XclExpRangeFmlaBase(
      84             :                             sal_uInt16 nRecId, sal_uInt32 nRecSize, const ScRange& rScRange );
      85             : 
      86             :     /** Extends the cell range to include the passed cell address. */
      87             :     void                Extend( const ScAddress& rScPos );
      88             : 
      89             :     /** Writes the range address covered by this record. */
      90             :     void                WriteRangeAddress( XclExpStream& rStrm ) const;
      91             : 
      92             : protected:
      93             :     XclRange            maXclRange;     /// Range described by this record.
      94             :     XclAddress          maBaseXclPos;   /// Address of base cell (first FORMULA record).
      95             : };
      96             : 
      97             : typedef boost::shared_ptr< XclExpRangeFmlaBase > XclExpRangeFmlaRef;
      98             : 
      99             : // Array formulas =============================================================
     100             : 
     101             : class ScTokenArray;
     102             : 
     103             : /** Represents an ARRAY record that contains the token array of a matrix formula.
     104             : 
     105             :     An ARRAY record is stored following the first FORMULA record that is part
     106             :     of a matrix formula. All FORMULA records of a matrix formula contain a
     107             :     reference to the ARRAY record, while the ARRAY record contains the formula
     108             :     token array used by all formulas.
     109             :  */
     110           0 : class XclExpArray : public XclExpRangeFmlaBase
     111             : {
     112             : public:
     113             :     explicit            XclExpArray( XclTokenArrayRef xTokArr, const ScRange& rScRange );
     114             : 
     115             :     /** Creates and returns the token array for a corresponding FORMULA cell record. */
     116             :     virtual XclTokenArrayRef CreateCellTokenArray( const XclExpRoot& rRoot ) const SAL_OVERRIDE;
     117             :     /** Returns true, if the array formula contains volatile functions. */
     118             :     virtual bool        IsVolatile() const SAL_OVERRIDE;
     119             : 
     120             : private:
     121             :     virtual void        WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
     122             : 
     123             : private:
     124             :     XclTokenArrayRef    mxTokArr;       /// The token array of a matrix formula.
     125             : };
     126             : 
     127             : typedef boost::shared_ptr< XclExpArray > XclExpArrayRef;
     128             : 
     129             : /** Caches all ARRAY records. */
     130           0 : class XclExpArrayBuffer : protected XclExpRoot
     131             : {
     132             : public:
     133             :     explicit            XclExpArrayBuffer( const XclExpRoot& rRoot );
     134             : 
     135             :     /** Inserts a new ARRAY record into the buffer and returns it. */
     136             :     XclExpArrayRef      CreateArray( const ScTokenArray& rScTokArr, const ScRange& rScRange );
     137             :     /** Tries to find an ARRAY record that corresponds to an ocMatRef token. */
     138             :     XclExpArrayRef FindArray( const ScTokenArray& rScTokArr, const ScAddress& rBasePos ) const;
     139             : 
     140             : private:
     141             :     typedef ::std::map< ScAddress, XclExpArrayRef > XclExpArrayMap;
     142             :     XclExpArrayMap      maRecMap;       /// Map containing the ARRAY records.
     143             : };
     144             : 
     145             : // Shared formulas ============================================================
     146             : 
     147             : /** Represents a SHRFMLA record that contains the token array of a shared formula.
     148             : 
     149             :     A SHRFMLA record is stored following the first FORMULA record that is part
     150             :     of a shared formula. All FORMULA records of a shared formula contain a
     151             :     reference to the SHRFMLA record, while the SHRFMLA record contains the
     152             :     formula token array used by all formulas.
     153             :  */
     154           0 : class XclExpShrfmla : public XclExpRangeFmlaBase
     155             : {
     156             : public:
     157             :     /** Creates a SHRFMLA record that consists of the passed cell address only. */
     158             :     explicit            XclExpShrfmla( XclTokenArrayRef xTokArr, const ScAddress& rScPos );
     159             : 
     160             :     /** Extends the cell range to include the passed cell address. */
     161             :     void                ExtendRange( const ScAddress& rScPos );
     162             : 
     163             :     /** Creates and returns the token array for a corresponding FORMULA cell record. */
     164             :     virtual XclTokenArrayRef CreateCellTokenArray( const XclExpRoot& rRoot ) const SAL_OVERRIDE;
     165             :     /** Returns true, if the shared formula contains volatile functions. */
     166             :     virtual bool        IsVolatile() const SAL_OVERRIDE;
     167             : 
     168             : private:
     169             :     virtual void        WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
     170             : 
     171             : private:
     172             :     XclTokenArrayRef    mxTokArr;       /// The token array of a shared formula.
     173             :     sal_uInt8           mnUsedCount;    /// Number of FORMULA records referring to this record.
     174             : };
     175             : 
     176             : typedef boost::shared_ptr< XclExpShrfmla > XclExpShrfmlaRef;
     177             : 
     178             : /** Caches all SHRFMLA records and provides functions to update their ranges. */
     179           0 : class XclExpShrfmlaBuffer : protected XclExpRoot
     180             : {
     181             : public:
     182             :     explicit            XclExpShrfmlaBuffer( const XclExpRoot& rRoot );
     183             : 
     184             :     /** Tries to create a new or to update an existing SHRFMLA record.
     185             :         @return  An empty reference, if the passed token array does not contain
     186             :             a shared formula. If the token array is a shared formula, this
     187             :             function updates its cell range to include the passed cell position,
     188             :             if there is a SHRFMLA record for the passed token array; otherwise
     189             :             this function creates and returns a new SHRFMLA record. */
     190             :     XclExpShrfmlaRef CreateOrExtendShrfmla( const ScFormulaCell& rScCell, const ScAddress& rScPos );
     191             : 
     192             : private:
     193             :     /**
     194             :      * Check for presence of token that's not allowed in Excel's shared
     195             :      * formula. Refer to the "SharedParsedFormula" section of [MS-XLS] spec
     196             :      * for more info.
     197             :      */
     198             :     bool IsValidTokenArray( const ScTokenArray& rArray ) const;
     199             : 
     200             :     typedef boost::unordered_map<const ScTokenArray*, XclExpShrfmlaRef> TokensType;
     201             :     typedef boost::unordered_set<const ScTokenArray*> BadTokenArraysType;
     202             : 
     203             :     TokensType         maRecMap;    /// Map containing the SHRFMLA records.
     204             :     BadTokenArraysType maBadTokens; /// shared tokens we should *not* export as SHRFMLA
     205             : };
     206             : 
     207             : // Multiple operations ========================================================
     208             : 
     209             : struct XclMultipleOpRefs;
     210             : 
     211             : /** Represents a TABLEOP record for a multiple operations range. */
     212           0 : class XclExpTableop : public XclExpRangeFmlaBase
     213             : {
     214             : public:
     215             :     explicit            XclExpTableop( const ScAddress& rScPos,
     216             :                             const XclMultipleOpRefs& rRefs, sal_uInt8 nScMode );
     217             : 
     218             :     /** Returns true, if the cell range has been extended to the passed position.
     219             :         @descr  All references passed in rRefs must fit the ranges passed in the constructor. */
     220             :     bool                TryExtend( const ScAddress& rScPos, const XclMultipleOpRefs& rRefs );
     221             : 
     222             :     /** Finalizes the record. Tests on valid cell range and reference addresses. */
     223             :     void                Finalize();
     224             : 
     225             :     /** Creates and returns the token array for a corresponding FORMULA cell record. */
     226             :     virtual XclTokenArrayRef CreateCellTokenArray( const XclExpRoot& rRoot ) const SAL_OVERRIDE;
     227             :     /** Returns true, if the multiple operations range is volatile. */
     228             :     virtual bool        IsVolatile() const SAL_OVERRIDE;
     229             :     /** Writes the record if it is valid. */
     230             :     virtual void        Save( XclExpStream& rStrm ) SAL_OVERRIDE;
     231             : 
     232             : private:
     233             :     /** Returns true, if the passed cell position can be appended to this record. */
     234             :     bool                IsAppendable( sal_uInt16 nXclCol, sal_uInt16 nXclRow ) const;
     235             : 
     236             :     /** Writes the contents of the TABLEOP record. */
     237             :     virtual void        WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
     238             : 
     239             : private:
     240             :     sal_uInt16          mnLastAppXclCol;/// Column index of last appended cell.
     241             :     sal_uInt16          mnColInpXclCol; /// Column index of column input cell.
     242             :     sal_uInt32          mnColInpXclRow; /// Row index of column input cell.
     243             :     sal_uInt16          mnRowInpXclCol; /// Column index of row input cell.
     244             :     sal_uInt32          mnRowInpXclRow; /// Row index of row input cell.
     245             :     sal_uInt8           mnScMode;       /// Type of the multiple operation (Calc constant).
     246             :     bool                mbValid;        /// true = Contains valid references.
     247             : };
     248             : 
     249             : typedef boost::shared_ptr< XclExpTableop > XclExpTableopRef;
     250             : 
     251             : /** Contains all created TABLEOP records and supports creating or updating them. */
     252           0 : class XclExpTableopBuffer : protected XclExpRoot
     253             : {
     254             : public:
     255             :     explicit            XclExpTableopBuffer( const XclExpRoot& rRoot );
     256             : 
     257             :     /** Tries to update an existing or to create a new TABLEOP record.
     258             :         @return  Reference to the TABLEOP record for this cell (existing or new),
     259             :             or an empty reference, if rScTokArr does not contain a multiple
     260             :             operations formula. */
     261             :     XclExpTableopRef    CreateOrExtendTableop(
     262             :                             const ScTokenArray& rScTokArr, const ScAddress& rScPos );
     263             : 
     264             :     /** Finalizes all contained TABLEOP records. */
     265             :     void                Finalize();
     266             : 
     267             : private:
     268             :     /** Tries to create a new TABLEOP record, if rRefs contains valid references. */
     269             :     XclExpTableopRef    TryCreate( const ScAddress& rScPos, const XclMultipleOpRefs& rRefs );
     270             : 
     271             : private:
     272             :     typedef XclExpRecordList< XclExpTableop > XclExpTableopList;
     273             :     XclExpTableopList   maTableopList;  /// List of all TABLEOP records.
     274             : };
     275             : 
     276             : 
     277             : // Cell records
     278             : 
     279             : 
     280             : /** The base class of all cell records. */
     281           0 : class XclExpCellBase : public XclExpRecord
     282             : {
     283             : public:
     284             :     /** Returns the (first) address of the cell(s). */
     285           0 :     inline const XclAddress& GetXclPos() const { return maXclPos; }
     286             :     /** Returns the (first) Excel column index of the cell(s). */
     287           0 :     inline sal_uInt16   GetXclCol() const { return maXclPos.mnCol; }
     288             :     /** Returns the Excel row index of the cell. */
     289           0 :     inline sal_uInt32   GetXclRow() const { return maXclPos.mnRow; }
     290             : 
     291             :     /** Derived classes return the column index of the last contained cell. */
     292             :     virtual sal_uInt16  GetLastXclCol() const = 0;
     293             :     /** Derived classes return the XF identifier of the first contained cell. */
     294             :     virtual sal_uInt32  GetFirstXFId() const = 0;
     295             :     /** Derived classes return true, if this record does not contain at least one valid cell. */
     296             :     virtual bool        IsEmpty() const = 0;
     297             :     /** Derived classes return whether the cell contains multi-line text. */
     298             :     virtual bool        IsMultiLineText() const;
     299             : 
     300             :     /** Derived classes try to merge the contents of the passed cell to own data. */
     301             :     virtual bool        TryMerge( const XclExpCellBase& rCell );
     302             :     /** Derived classes convert the XF identifier(s) into the Excel XF index(es).
     303             :         @param rXFIndexes  The converted XF index(es) are inserted here. */
     304             :     virtual void        ConvertXFIndexes( const XclExpRoot& rRoot ) = 0;
     305             :     /** Derived classes for blank cells insert the Excel XF index(es) into the passed vector. */
     306             :     virtual void        GetBlankXFIndexes( ScfUInt16Vec& rXFIndexes ) const;
     307             :     /** Derived classes for blank cells remove unused Excel XF index(es). */
     308             :     virtual void        RemoveUnusedBlankCells( const ScfUInt16Vec& rXFIndexes );
     309             : 
     310             : protected:
     311             :     explicit            XclExpCellBase(
     312             :                             sal_uInt16 nRecId, sal_Size nContSize, const XclAddress& rXclPos );
     313             : 
     314             :     /** Sets this record to a new column position. */
     315           0 :     inline void         SetXclCol( sal_uInt16 nXclCol ) { maXclPos.mnCol = nXclCol; }
     316             :     /** Sets this record to a new row position. */
     317             :     inline void         SetXclRow( sal_uInt32 nXclRow ) { maXclPos.mnRow = nXclRow; }
     318             : 
     319             : private:
     320             :     XclAddress          maXclPos;       /// Address of the cell.
     321             : };
     322             : 
     323             : typedef boost::shared_ptr< XclExpCellBase > XclExpCellRef;
     324             : 
     325             : // Single cell records ========================================================
     326             : 
     327             : /** Base class for all cell records not supporting multiple contents. */
     328           0 : class XclExpSingleCellBase : public XclExpCellBase
     329             : {
     330             : public:
     331             :     /** Returns the last column, which is equal to the first column for single cells. */
     332             :     virtual sal_uInt16  GetLastXclCol() const SAL_OVERRIDE;
     333             :     /** Return the XF identifier of the cell. */
     334             :     virtual sal_uInt32  GetFirstXFId() const SAL_OVERRIDE;
     335             :     /** Returns true, if this record does not contain at least one valid cell. */
     336             :     virtual bool        IsEmpty() const SAL_OVERRIDE;
     337             :     /** Converts the XF identifier into the Excel XF index. */
     338             :     virtual void        ConvertXFIndexes( const XclExpRoot& rRoot ) SAL_OVERRIDE;
     339             :     /** Writes cell address, XF index, and calls WriteContents() for each cell. */
     340             :     virtual void        Save( XclExpStream& rStrm ) SAL_OVERRIDE;
     341             : 
     342             : protected:
     343             :     explicit            XclExpSingleCellBase( sal_uInt16 nRecId, sal_Size nContSize,
     344             :                             const XclAddress& rXclPos, sal_uInt32 nXFId );
     345             : 
     346             :     explicit            XclExpSingleCellBase( const XclExpRoot& rRoot,
     347             :                             sal_uInt16 nRecId, sal_Size nContSize, const XclAddress& rXclPos,
     348             :                             const ScPatternAttr* pPattern, sal_Int16 nScript, sal_uInt32 nForcedXFId );
     349             : 
     350           0 :     inline void         SetContSize( sal_Size nContSize ) { mnContSize = nContSize; }
     351           0 :     inline sal_Size     GetContSize() const { return mnContSize; }
     352             : 
     353           0 :     inline void         SetXFId( sal_uInt32 nXFId ) { maXFId.mnXFId = nXFId; }
     354           0 :     inline sal_uInt32   GetXFId() const { return maXFId.mnXFId; }
     355             : 
     356             : private:
     357             :     /** Writes cell address, XF index, and calls WriteContents() for each cell. */
     358             :     virtual void        WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
     359             :     /** Derived classes write the contents of the specified cell (without XF index). */
     360             :     virtual void        WriteContents( XclExpStream& rStrm ) = 0;
     361             : 
     362             : private:
     363             :     XclExpXFId          maXFId;         /// The XF identifier of the cell formatting.
     364             :     sal_Size            mnContSize;     /// The size of the cell contents.
     365             : };
     366             : 
     367             : /** Represents a NUMBER record that describes a cell with a double value. */
     368           0 : class XclExpNumberCell : public XclExpSingleCellBase
     369             : {
     370           0 :     DECL_FIXEDMEMPOOL_NEWDEL( XclExpNumberCell )
     371             : 
     372             : public:
     373             :     explicit            XclExpNumberCell( const XclExpRoot& rRoot, const XclAddress& rXclPos,
     374             :                             const ScPatternAttr* pPattern, sal_uInt32 nForcedXFId,
     375             :                             double fValue );
     376             : 
     377             :     virtual void        SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     378             : private:
     379             :     virtual void        WriteContents( XclExpStream& rStrm ) SAL_OVERRIDE;
     380             : 
     381             : private:
     382             :     double              mfValue;        /// The cell value.
     383             : };
     384             : 
     385             : /** Represents a BOOLERR record that describes a cell with a Boolean value. */
     386           0 : class XclExpBooleanCell : public XclExpSingleCellBase
     387             : {
     388           0 :     DECL_FIXEDMEMPOOL_NEWDEL( XclExpBooleanCell )
     389             : 
     390             : public:
     391             :     explicit            XclExpBooleanCell( const XclExpRoot rRoot, const XclAddress& rXclPos,
     392             :                             const ScPatternAttr* pPattern, sal_uInt32 nForcedXFId,
     393             :                             bool bValue );
     394             : 
     395             :     virtual void        SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     396             : private:
     397             :     virtual void        WriteContents( XclExpStream& rStrm ) SAL_OVERRIDE;
     398             : 
     399             : private:
     400             :     bool                mbValue;        /// The cell value.
     401             : };
     402             : 
     403             : class XclExpHyperlinkHelper;
     404             : class EditTextObject;
     405             : 
     406             : /** Represents a text cell record.
     407             : 
     408             :     May contain a BIFF2-BIFF7 LABEL record for a simple string, or a BIFF2-BIFF7
     409             :     RSTRING record for a formatted string, or a BIFF8 LABELSST string for any
     410             :     string (simply stores a reference to the Shared String Table).
     411             :  */
     412           0 : class XclExpLabelCell : public XclExpSingleCellBase
     413             : {
     414           0 :     DECL_FIXEDMEMPOOL_NEWDEL( XclExpLabelCell )
     415             : 
     416             : public:
     417             :     /** Constructs the record from an unformatted Calc string cell. */
     418             :     explicit            XclExpLabelCell( const XclExpRoot& rRoot, const XclAddress& rXclPos,
     419             :                             const ScPatternAttr* pPattern, sal_uInt32 nForcedXFId,
     420             :                             const OUString& rStr );
     421             : 
     422             :     /** Constructs the record from a formatted Calc edit cell. */
     423             :     explicit            XclExpLabelCell( const XclExpRoot& rRoot, const XclAddress& rXclPos,
     424             :                             const ScPatternAttr* pPattern, sal_uInt32 nForcedXFId,
     425             :                             const EditTextObject* pEditText, XclExpHyperlinkHelper& rHlinkHelper );
     426             : 
     427             :     /** Returns true if the cell contains multi-line text. */
     428             :     virtual bool        IsMultiLineText() const SAL_OVERRIDE;
     429             : 
     430             :     virtual void        SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     431             : private:
     432             :     /** Initializes the record contents. Called from constructors. */
     433             :     void                Init( const XclExpRoot& rRoot,
     434             :                             const ScPatternAttr* pPattern, XclExpStringRef xText );
     435             : 
     436             :     virtual void        WriteContents( XclExpStream& rStrm ) SAL_OVERRIDE;
     437             : 
     438             : private:
     439             :     XclExpStringRef     mxText;         /// The cell text.
     440             :     sal_uInt32          mnSstIndex;     /// Index into Shared String Table (only used for BIFF8).
     441             :     bool                mbLineBreak;    /// True = cell has automatic linebreaks enabled.
     442             : };
     443             : 
     444             : class ScFormulaCell;
     445             : 
     446             : /** Represents a FORMULA record that describes a cell with a formula. */
     447           0 : class XclExpFormulaCell : public XclExpSingleCellBase
     448             : {
     449           0 :     DECL_FIXEDMEMPOOL_NEWDEL( XclExpFormulaCell )
     450             : 
     451             : public:
     452             :     explicit            XclExpFormulaCell( const XclExpRoot& rRoot, const XclAddress& rXclPos,
     453             :                             const ScPatternAttr* pPattern, sal_uInt32 nForcedXFId,
     454             :                             const ScFormulaCell& rScFmlaCell,
     455             :                             XclExpArrayBuffer& rArrayBfr,
     456             :                             XclExpShrfmlaBuffer& rShrfmlaBfr,
     457             :                             XclExpTableopBuffer& rTableopBfr );
     458             : 
     459             :     /** Writes the FORMULA record and additional records related to the formula. */
     460             :     virtual void        Save( XclExpStream& rStrm ) SAL_OVERRIDE;
     461             :     virtual void        SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     462             : 
     463             : private:
     464             :     virtual void        WriteContents( XclExpStream& rStrm ) SAL_OVERRIDE;
     465             : 
     466             : private:
     467             :     ScFormulaCell&      mrScFmlaCell;   /// The Calc formula cell.
     468             :     XclTokenArrayRef    mxTokArr;       /// The token array of the formula.
     469             :     XclExpRangeFmlaRef  mxAddRec;       /// Additional record for matrix/shared formulas.
     470             :     XclExpRecordRef     mxStringRec;    /// STRING record for string result.
     471             : };
     472             : 
     473             : // Multiple cell records ======================================================
     474             : 
     475             : struct XclExpMultiXFId : public XclExpXFId
     476             : {
     477             :     sal_uInt16          mnCount;        /// Number of XF identifiers.
     478             : 
     479           0 :     inline explicit     XclExpMultiXFId( sal_uInt32 nXFId, sal_uInt16 nCount = 1 ) :
     480           0 :                             XclExpXFId( nXFId ), mnCount( nCount ) {}
     481             : };
     482             : 
     483             : /** Base class for all cell records supporting multiple contents. */
     484           0 : class XclExpMultiCellBase : public XclExpCellBase
     485             : {
     486             : public:
     487             :     /** Returns the column index of the last cell this record describes. */
     488             :     virtual sal_uInt16  GetLastXclCol() const SAL_OVERRIDE;
     489             :     /** Return the XF identifier of the first contained cell. */
     490             :     virtual sal_uInt32  GetFirstXFId() const SAL_OVERRIDE;
     491             :     /** Returns true, if this record does not contain at least one valid cell. */
     492             :     virtual bool        IsEmpty() const SAL_OVERRIDE;
     493             : 
     494             :     /** Convert all XF identifiers into the Excel XF indexes. */
     495             :     virtual void        ConvertXFIndexes( const XclExpRoot& rRoot ) SAL_OVERRIDE;
     496             :     /** Writes the record, calls WriteContents() for each contained cell.
     497             :         @descr  May write several records, if unused XF indexes are contained. */
     498             :     virtual void        Save( XclExpStream& rStrm ) SAL_OVERRIDE;
     499             :     virtual void        SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     500             : 
     501             : protected:
     502             :     explicit            XclExpMultiCellBase( sal_uInt16 nRecId, sal_uInt16 nMulRecId,
     503             :                             sal_Size nContSize, const XclAddress& rXclPos );
     504             : 
     505             :     /** Sets the size of the remaining contents of one cell (without the XF index). */
     506             :     inline void         SetContSize( sal_Size nContSize ) { mnContSize = nContSize; }
     507             :     /** Returns the size of the remaining contents of one cell (without the XF index). */
     508             :     inline sal_Size     GetContSize() const { return mnContSize; }
     509             : 
     510             :     /** Returns the number of cells this record represents. */
     511             :     sal_uInt16          GetCellCount() const;
     512             : 
     513             :     /** Appends the passed XF identifier nCount times to the list of XF identifiers. */
     514             :     void                AppendXFId( const XclExpMultiXFId& rXFId );
     515             :     /** Appends the passed cell format nCount times to the list of XF identifiers. */
     516             :     void                AppendXFId( const XclExpRoot& rRoot,
     517             :                             const ScPatternAttr* pPattern, sal_uInt16 nScript,
     518             :                             sal_uInt32 nForcedXFId, sal_uInt16 nCount = 1 );
     519             : 
     520             :     /** Tries to merge the XF ID list of the passed cell with the own list. */
     521             :     bool                TryMergeXFIds( const XclExpMultiCellBase& rCell );
     522             :     /** Inserts the Excel XF index(es) into the passed vector. */
     523             :     void                GetXFIndexes( ScfUInt16Vec& rXFIndexes ) const;
     524             : 
     525             :     /** Removes unused Excel XF index(es).
     526             :         @param rXFIndexes  Specifies which XF indexes are used. */
     527             :     void                RemoveUnusedXFIndexes( const ScfUInt16Vec& rXFIndexes );
     528             : 
     529             : private:
     530             :     /** Derived classes write the remaining contents of the specified cell (without XF index).
     531             :         @param nRelCol  Relative column index (starts with 0 for first cell of this record). */
     532             :     virtual void        WriteContents( XclExpStream& rStrm, sal_uInt16 nRelCol ) = 0;
     533             :     virtual void        WriteXmlContents( XclExpXmlStream& rStrm, const XclAddress& rAddress, sal_uInt32 nXFId, sal_uInt16 nRelCol ) = 0;
     534             : 
     535             : private:
     536             :     typedef ::std::deque< XclExpMultiXFId > XclExpMultiXFIdDeq;
     537             : 
     538             :     sal_uInt16          mnMulRecId;     /// Record ID for multiple record variant.
     539             :     sal_Size            mnContSize;     /// Data size of contents for one cell
     540             :     XclExpMultiXFIdDeq  maXFIds;        /// The XF identifiers of the cell formatting.
     541             : };
     542             : 
     543             : /** Represents a BLANK or MULBLANK record that describes empty but formatted cells. */
     544           0 : class XclExpBlankCell : public XclExpMultiCellBase
     545             : {
     546           0 :     DECL_FIXEDMEMPOOL_NEWDEL( XclExpBlankCell )
     547             : 
     548             : public:
     549             :     explicit            XclExpBlankCell( const XclAddress& rXclPos, const XclExpMultiXFId& rXFId );
     550             : 
     551             :     explicit            XclExpBlankCell( const XclExpRoot& rRoot,
     552             :                             const XclAddress& rXclPos, sal_uInt16 nLastXclCol,
     553             :                             const ScPatternAttr* pPattern, sal_uInt32 nForcedXFId );
     554             : 
     555             :     /** Tries to merge the contents of the passed cell to own data. */
     556             :     virtual bool        TryMerge( const XclExpCellBase& rCell ) SAL_OVERRIDE;
     557             :     /** Inserts the Excel XF index(es) into the passed vector. */
     558             :     virtual void        GetBlankXFIndexes( ScfUInt16Vec& rXFIndexes ) const SAL_OVERRIDE;
     559             :     /** Tries to remove unused Excel XF index(es). */
     560             :     virtual void        RemoveUnusedBlankCells( const ScfUInt16Vec& rXFIndexes ) SAL_OVERRIDE;
     561             : 
     562             : private:
     563             :     /** Writes the remaining contents of the specified cell (without XF index). */
     564             :     virtual void        WriteContents( XclExpStream& rStrm, sal_uInt16 nRelCol ) SAL_OVERRIDE;
     565             :     virtual void        WriteXmlContents( XclExpXmlStream& rStrm, const XclAddress& rAddress, sal_uInt32 nXFId, sal_uInt16 nRelCol ) SAL_OVERRIDE;
     566             : };
     567             : 
     568             : /** Represents an RK or MULRK record that describes cells with a compressed double values. */
     569           0 : class XclExpRkCell : public XclExpMultiCellBase
     570             : {
     571           0 :     DECL_FIXEDMEMPOOL_NEWDEL( XclExpRkCell )
     572             : 
     573             : public:
     574             :     explicit            XclExpRkCell( const XclExpRoot& rRoot, const XclAddress& rXclPos,
     575             :                             const ScPatternAttr* pPattern, sal_uInt32 nForcedXFId,
     576             :                             sal_Int32 nRkValue );
     577             : 
     578             :     /** Tries to merge the contents of the passed cell to own data. */
     579             :     virtual bool        TryMerge( const XclExpCellBase& rCell ) SAL_OVERRIDE;
     580             : 
     581             : private:
     582             :     /** Writes the remaining contents of the specified cell (without XF index). */
     583             :     virtual void        WriteContents( XclExpStream& rStrm, sal_uInt16 nRelCol ) SAL_OVERRIDE;
     584             :     virtual void        WriteXmlContents( XclExpXmlStream& rStrm, const XclAddress& rAddress, sal_uInt32 nXFId, sal_uInt16 nRelCol ) SAL_OVERRIDE;
     585             : 
     586             : private:
     587             :     ScfInt32Vec         maRkValues;     /// The cell values.
     588             : };
     589             : 
     590             : 
     591             : // Rows and Columns
     592             : 
     593             : 
     594             : class ScOutlineArray;
     595             : 
     596             : /** Base class for buffers containing row or column outline data. */
     597           0 : class XclExpOutlineBuffer
     598             : {
     599             : public:
     600             :     /** Returns true, if a collapsed group ends at the last processed position. */
     601           0 :     inline bool         IsCollapsed() const { return mbCurrCollapse; }
     602             :     /** Returns the highest level of an open group at the last processed position. */
     603           0 :     inline sal_uInt8    GetLevel() const { return ::std::min( mnCurrLevel, EXC_OUTLINE_MAX ); }
     604             : 
     605             : protected:
     606             :     /** Constructs the outline buffer.
     607             :         @param bRows  true = Process row ouline array; false = Process column outline array. */
     608             :     explicit            XclExpOutlineBuffer( const XclExpRoot& rRoot, bool bRows );
     609             : 
     610             :     /** Updates the current state by processing the settings at the passed Calc position. */
     611             :     void                UpdateColRow( SCCOLROW nScPos );
     612             : 
     613             : private:
     614             :     /** Data about an outline level. */
     615             :     struct XclExpLevelInfo
     616             :     {
     617             :         SCCOLROW            mnScEndPos;         /// The end position of a group in a level.
     618             :         bool                mbHidden;           /// true = Group in this level is hidden.
     619           0 :         inline explicit     XclExpLevelInfo() : mnScEndPos( 0 ), mbHidden( false ) {}
     620             :     };
     621             :     typedef ::std::vector< XclExpLevelInfo > XclExpLevelInfoVec;
     622             : 
     623             :     const ScOutlineArray* mpScOLArray;      /// Pointer to Calc outline array.
     624             :     XclExpLevelInfoVec  maLevelInfos;       /// Info for current row and all levels.
     625             :     sal_uInt8           mnCurrLevel;        /// Highest level of an open group for current position.
     626             :     bool                mbCurrCollapse;     /// true = Collapsed group ends at current position.
     627             : };
     628             : 
     629             : /** The outline buffer for column outlines. */
     630           0 : class XclExpColOutlineBuffer : public XclExpOutlineBuffer
     631             : {
     632             : public:
     633           0 :     inline explicit     XclExpColOutlineBuffer( const XclExpRoot& rRoot ) :
     634           0 :                             XclExpOutlineBuffer( rRoot, false ) {}
     635             : 
     636             :     /** Updates the current state by processing the settings of the passed Calc column. */
     637           0 :     inline void         Update( SCCOL nScCol )
     638           0 :                             { UpdateColRow( static_cast< SCCOLROW >( nScCol ) ); }
     639             : };
     640             : 
     641             : /** The outline buffer for row outlines. */
     642           0 : class XclExpRowOutlineBuffer : public XclExpOutlineBuffer
     643             : {
     644             : public:
     645           0 :     inline explicit     XclExpRowOutlineBuffer( const XclExpRoot& rRoot ) :
     646           0 :                             XclExpOutlineBuffer( rRoot, true ) {}
     647             : 
     648             :     /** Updates the current state by processing the settings of the passed Calc row. */
     649           0 :     inline void         Update( SCROW nScRow )
     650           0 :                             { UpdateColRow( static_cast< SCCOLROW >( nScRow ) ); }
     651             : };
     652             : 
     653             : /** Represents a GUTS record containing the level count of row and column outlines. */
     654           0 : class XclExpGuts : public XclExpRecord
     655             : {
     656             : public:
     657             :     explicit            XclExpGuts( const XclExpRoot& rRoot );
     658             : 
     659             : private:
     660             :     virtual void        WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
     661             : 
     662             : private:
     663             :     sal_uInt16          mnColLevels;    /// Number of visible column outline levels.
     664             :     sal_uInt16          mnColWidth;     /// Width of column outline area (pixels).
     665             :     sal_uInt16          mnRowLevels;    /// Number of visible row outline levels.
     666             :     sal_uInt16          mnRowWidth;     /// Width of row outline area (pixels).
     667             : };
     668             : 
     669             : /** Represents a DIMENSIONS record containing the used area of a sheet. */
     670           0 : class XclExpDimensions : public XclExpRecord
     671             : {
     672             : public:
     673             :     explicit            XclExpDimensions( const XclExpRoot& rRoot );
     674             : 
     675             :     /** Sets the used area to the record. */
     676             :     void                SetDimensions(
     677             :                             sal_uInt16 nFirstUsedXclCol, sal_uInt32 nFirstUsedXclRow,
     678             :                             sal_uInt16 nFirstFreeXclCol, sal_uInt32 nFirstFreeXclRow );
     679             : 
     680             :     virtual void        SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     681             : private:
     682             :     /** Writes the contents of the DIMENSIONS record. */
     683             :     virtual void        WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
     684             : 
     685             : private:
     686             :     sal_uInt32          mnFirstUsedXclRow;  /// First used row.
     687             :     sal_uInt32          mnFirstFreeXclRow;  /// First unused row after used area.
     688             :     sal_uInt16          mnFirstUsedXclCol;  /// First used column.
     689             :     sal_uInt16          mnFirstFreeXclCol;  /// First free column after used area.
     690             : };
     691             : 
     692             : /** Represents the DEFCOLWIDTH record containing the default column width of a sheet.
     693             : 
     694             :     Excel stores the default column width in entire character widths of the '0'
     695             :     character using the application default font (i.e. the default width is 10,
     696             :     if the '0' character fits 10 times into a cell in a column with default
     697             :     width.
     698             : 
     699             :     The IsDefWidth() function returns true, if the passed width (measured in
     700             :     1/256 of the width of the '0' character) could be converted exactly to the
     701             :     default width. If the passed width is rounded up or down to get the default
     702             :     width, the function returns false.
     703             :  */
     704           0 : class XclExpDefcolwidth : public XclExpUInt16Record, protected XclExpRoot
     705             : {
     706             : public:
     707             :     explicit            XclExpDefcolwidth( const XclExpRoot& rRoot );
     708             : 
     709             :     /** Returns true, if the own default width exactly matches the passed width. */
     710             :     bool                IsDefWidth( sal_uInt16 nXclColWidth ) const;
     711             : 
     712             :     /** Sets the passed column width (in 1/256 character width) as default width. */
     713             :     void                SetDefWidth( sal_uInt16 nXclColWidth );
     714             : };
     715             : 
     716             : /** Contains the column settings for a range of columns.
     717             : 
     718             :     After construction the record contains a temporary XF identifier returned
     719             :     from the XF buffer. After creating the entire Excel document in memory, the
     720             :     ConvertXFIndexes() function converts it into the real Excel XF index.
     721             :  */
     722           0 : class XclExpColinfo : public XclExpRecord, protected XclExpRoot
     723             : {
     724             : public:
     725             :     /** Constructs the record with the settings in the Calc document. */
     726             :     explicit            XclExpColinfo( const XclExpRoot& rRoot,
     727             :                             SCCOL nScCol, SCROW nLastScRow,
     728             :                             XclExpColOutlineBuffer& rOutlineBfr );
     729             : 
     730             :     /** Converts the XF identifier into the Excel XF index, returns the latter. */
     731             :     sal_uInt16          ConvertXFIndexes();
     732             : 
     733             :     /** Tries to merge this record with the passed record.
     734             :         @descr  Possible, if passed record directly follows this record and has equal contents.
     735             :         @return  true = This record is equal to passed record and has been updated. */
     736             :     bool                TryMerge( const XclExpColinfo& rColInfo );
     737             : 
     738             :     /** Returns the Excel width of the column(s). */
     739           0 :     inline sal_uInt16   GetColWidth() const { return mnWidth; }
     740             :     /** Returns the final Excel XF index of the column(s). */
     741           0 :     inline sal_uInt16   GetXFIndex() const { return maXFId.mnXFIndex; }
     742             :     /** Returns the number of columns represented by this record. */
     743           0 :     inline sal_uInt16   GetColCount() const { return mnLastXclCol - mnFirstXclCol + 1; }
     744             : 
     745             :     /** Returns true, if the column has default format and width. */
     746             :     bool                IsDefault( const XclExpDefcolwidth& rDefColWidth ) const;
     747             : 
     748             :     virtual void        SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     749             : 
     750             : private:
     751             :     /** Writes the contents of this COLINFO record. */
     752             :     virtual void        WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
     753             : 
     754             : private:
     755             :     XclExpXFId          maXFId;             /// The XF identifier for column default format.
     756             :     sal_uInt16          mnWidth;            /// Excel width of the column.
     757             :     sal_uInt16          mnScWidth;          /// Calc width of the column.
     758             :     sal_uInt16          mnFlags;            /// Additional column flags.
     759             :     sal_uInt16          mnFirstXclCol;      /// Index to first column.
     760             :     sal_uInt16          mnLastXclCol;       /// Index to last column.
     761             : };
     762             : 
     763             : /** Contains COLINFO records for all columns of a Calc sheet.
     764             : 
     765             :     On construction one COLINFO record per column is created. After creating
     766             :     the entire Excel document in memory, the ConvertXFIndexes() function converts
     767             :     all temporary XF identifiers into real Excel XF indexes and merges all equal
     768             :     COLINFO records together.
     769             :  */
     770           0 : class XclExpColinfoBuffer : public XclExpRecordBase, protected XclExpRoot
     771             : {
     772             : public:
     773             :     explicit            XclExpColinfoBuffer( const XclExpRoot& rRoot );
     774             : 
     775             :     /** Initializes the buffer: finds settings and formatting of all columns.
     776             :         @param nLastScRow  Last row used to find default formatting. */
     777             :     void                Initialize( SCROW nLastScRow );
     778             :     /** Converts the XF identifiers into the Excel XF indexes and merges equal columns.
     779             :         @param rXFIndexes  Returns the final XF indexes of all columns. */
     780             :     void                Finalize( ScfUInt16Vec& rXFIndexes );
     781             : 
     782             :     /** Writes all COLINFO records of this buffer. */
     783             :     virtual void        Save( XclExpStream& rStrm ) SAL_OVERRIDE;
     784             :     virtual void        SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     785             : 
     786             : private:
     787             :     typedef XclExpRecordList< XclExpColinfo >   XclExpColinfoList;
     788             :     typedef XclExpColinfoList::RecordRefType    XclExpColinfoRef;
     789             : 
     790             :     XclExpColinfoList   maColInfos;         /// List of COLINFO records.
     791             :     XclExpDefcolwidth   maDefcolwidth;      /// The DEFCOLWIDTH record.
     792             :     XclExpColOutlineBuffer maOutlineBfr;    /// Buffer for column outline groups.
     793             : };
     794             : 
     795             : class XclExpRow;
     796             : 
     797             : /** Contains all possible default row settings. */
     798             : struct XclExpDefaultRowData
     799             : {
     800             :     sal_uInt16          mnFlags;            /// Default flags for unspecified rows.
     801             :     sal_uInt16          mnHeight;           /// Default height for unspecified rows.
     802             : 
     803             :     explicit            XclExpDefaultRowData();
     804             :     explicit            XclExpDefaultRowData( const XclExpRow& rRow );
     805             : 
     806             :     /** Returns true, if rows are hidden by default. */
     807           0 :     inline bool         IsHidden() const { return ::get_flag( mnFlags, EXC_DEFROW_HIDDEN ); }
     808             :     /** Returns true, if the rows have a manually set height by default. */
     809           0 :     inline bool         IsUnsynced() const { return ::get_flag( mnFlags, EXC_DEFROW_UNSYNCED ); }
     810             : };
     811             : 
     812             : /** Represents a DEFROWHEIGHT record containing default format for unused rows. */
     813           0 : class XclExpDefrowheight : public XclExpRecord
     814             : {
     815             : public:
     816             :     explicit            XclExpDefrowheight();
     817             : 
     818             :     /** Sets the passed default data as current record contents. */
     819             :     void                SetDefaultData( const XclExpDefaultRowData& rDefData );
     820           0 :     XclExpDefaultRowData& GetDefaultData() { return maDefData; }
     821             : private:
     822             :     /** Writes the contents of the record. */
     823             :     virtual void        WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
     824             : 
     825             : private:
     826             :     XclExpDefaultRowData maDefData;         /// Record data.
     827             : };
     828             : 
     829             : /** Represents a ROW record and additionally contains all cells records of a row.
     830             : 
     831             :     This class contains all cell records of a row in a spreadsheet. There are 2
     832             :     cell records in Excel that support storing a range of cells in one record
     833             :     (MULBLANK for multiple blank cells, and MULRK for multiple RK values). The
     834             :     insertion functions try to merge a new inserted cell with existing
     835             :     neighbors, if this is supported by the current type of cell record.
     836             : 
     837             :     The Finalize() function converts the XF identifiers of all cell records to
     838             :     the final Excel XF indexes. Then a default
     839             :  */
     840           0 : class XclExpRow : public XclExpRecord, protected XclExpRoot
     841             : {
     842             : public:
     843             :     /** Constructs the ROW record and converts the Calc row settings.
     844             :         @param bAlwaysEmpty  true = This row will not be filled with blank cells
     845             :             in the Finalize() function. */
     846             :     explicit            XclExpRow( const XclExpRoot& rRoot, sal_uInt32 nXclRow,
     847             :                             XclExpRowOutlineBuffer& rOutlineBfr, bool bAlwaysEmpty );
     848             : 
     849             :     /** Returns the excel row index of this ROW record. */
     850           0 :     inline sal_uInt32   GetXclRow() const { return mnXclRow; }
     851             :     /** Returns the height of the row in twips. */
     852           0 :     inline sal_uInt16   GetHeight() const { return mnHeight; }
     853             :     /** Returns true, if this row does not contain at least one valid cell. */
     854           0 :     inline bool         IsEmpty() const { return maCellList.IsEmpty(); }
     855             :     /** Returns true, if this row is hidden. */
     856           0 :     inline bool         IsHidden() const { return ::get_flag( mnFlags, EXC_ROW_HIDDEN ); }
     857             :     /** Returns true, if this row contains a manually set height. */
     858           0 :     inline bool         IsUnsynced() const { return ::get_flag( mnFlags, EXC_ROW_UNSYNCED ); }
     859             :     /** Returns true, if this row is enabled (will be exported). */
     860           0 :     inline bool         IsEnabled() const { return mbEnabled; }
     861             : 
     862             :     /** Appends the passed cell object to this row. */
     863             :     void                AppendCell( XclExpCellRef xCell, bool bIsMergedBase );
     864             : 
     865             :     /** Converts all XF identifiers into the Excel XF indexes. */
     866             :     void                Finalize( const ScfUInt16Vec& rColXFIndexes );
     867             : 
     868             :     /** Returns the column index of the first used cell in this row.
     869             :         @descr  This function can only be called after Finalize(). */
     870             :     sal_uInt16          GetFirstUsedXclCol() const;
     871             :     /** Returns the column index of the first unused cell following all used cells in this row.
     872             :         @descr  This function can only be called after Finalize(). */
     873             :     sal_uInt16          GetFirstFreeXclCol() const;
     874             : 
     875             :     /** Returns true, if this row may be omitted by using the DEFROWHEIGHT record.
     876             :         @descr  A row may be omitted, if it does not contain any cell or
     877             :         explicit default cell formatting, and is not part of an outline.
     878             :         This function can only be called after Finalize(). */
     879             :     bool                IsDefaultable() const;
     880             :     /** Disables this row, if it is defaultable and has the passed default format.
     881             :         @descr  Disabled rows will not be saved.
     882             :             This function can only be called after Finalize(). */
     883             :     void                DisableIfDefault( const XclExpDefaultRowData& rDefRowData );
     884             : 
     885             :     /** Writes all cell records of this row. */
     886             :     void                WriteCellList( XclExpStream& rStrm );
     887             : 
     888             :     /** Writes the ROW record if the row is not disabled (see DisableIfDefault() function). */
     889             :     virtual void        Save( XclExpStream& rStrm ) SAL_OVERRIDE;
     890             :     virtual void        SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     891             : 
     892           0 :     inline sal_uInt32   GetXclRowRpt() const { return mnXclRowRpt; }
     893           0 :     inline void         SetXclRowRpt( sal_uInt32 nRpt ){ mnXclRowRpt = nRpt; }
     894             : private:
     895             :     /** Initializes the record data. Called from constructors. */
     896             :     void                Init( sal_uInt16 nXclRow, XclExpRowOutlineBuffer* pOutlineBfr );
     897             :     /** Inserts a cell at the specified list position, tries to merge with neighbors. */
     898             :     void                InsertCell( XclExpCellRef xCell, size_t nPos, bool bIsMergedBase );
     899             : 
     900             :     /** Writes the contents of the ROW record. */
     901             :     virtual void        WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
     902             : 
     903             : private:
     904             :     typedef XclExpRecordList< XclExpCellBase > XclExpCellList;
     905             : 
     906             :     XclExpCellList      maCellList;         /// List of cell records for this row.
     907             :     sal_uInt32          mnXclRow;           /// Excel row index of this row.
     908             :     sal_uInt16          mnHeight;           /// Row height in twips.
     909             :     sal_uInt16          mnFlags;            /// Flags for the ROW record.
     910             :     sal_uInt16          mnXFIndex;          /// Default row formatting.
     911             :     sal_uInt16          mnOutlineLevel;     /// Outline Level (for OOXML)
     912             :     sal_uInt32          mnXclRowRpt;
     913             :     sal_uInt32          mnCurrentRow;
     914             :     bool                mbAlwaysEmpty;      /// true = Do not add blank cells in Finalize().
     915             :     bool                mbEnabled;          /// true = Write this ROW record.
     916             : };
     917             : 
     918             : /** Collects all rows which contain all cells of a sheet.
     919             : 
     920             :     This row buffer automatically creates ROW records when cells are inserted
     921             :     with the AppendCell() function. It is possible to force creation of more
     922             :     ROW records with the CreateRows() function. In both cases, all preceding
     923             :     missing ROW records are inserted too.
     924             :  */
     925           0 : class XclExpRowBuffer : public XclExpRecordBase, protected XclExpRoot
     926             : {
     927             : public:
     928             :     explicit            XclExpRowBuffer( const XclExpRoot& rRoot );
     929             : 
     930             :     /** Appends the passed cell object to the row that the cell specifies. */
     931             :     void                AppendCell( XclExpCellRef xCell, bool bIsMergedBase );
     932             :     /** Forces insertion of all ROW records before the passed row. */
     933             :     void                CreateRows( SCROW nFirstFreeScRow );
     934             : 
     935             :     /** Converts all XF identifiers into the Excel XF indexes and calculates default formats.
     936             :         @param rDefRowData  (out-param) The default row format is returned here.
     937             :         @param rColXFIndexes  The column default XF indexes. */
     938             :     void                Finalize( XclExpDefaultRowData& rDefRowData, const ScfUInt16Vec& rColXFIndexes );
     939             : 
     940             :     /** Writes the DIMENSIONS record, all ROW records and all cell records. */
     941             :     virtual void        Save( XclExpStream& rStrm ) SAL_OVERRIDE;
     942             :     virtual void        SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     943             : 
     944             :     XclExpDimensions*   GetDimensions();
     945             : 
     946             : private:
     947             :     /** Returns access to the specified ROW record. Inserts preceding missing ROW records.
     948             :         @param bRowAlwaysEmpty  true = Created rows will not be filled with blank cells
     949             :             in the XclExpRow::Finalize() function. */
     950             :     XclExpRow&          GetOrCreateRow( sal_uInt32 nXclRow, bool bRowAlwaysEmpty );
     951             : 
     952             : private:
     953             :     typedef ::boost::shared_ptr<XclExpRow>  RowRef;
     954             :     typedef ::std::map<sal_uInt32, RowRef>  RowMap;
     955             : 
     956             :     RowMap              maRowMap;
     957             :     XclExpRowOutlineBuffer maOutlineBfr;    /// Buffer for row outline groups.
     958             :     XclExpDimensions    maDimensions;       /// DIMENSIONS record for used area.
     959             : };
     960             : 
     961             : 
     962             : // Cell Table
     963             : 
     964             : 
     965             : class XclExpNote;
     966             : class XclExpMergedcells;
     967             : class XclExpHyperlink;
     968             : class XclExpDval;
     969             : 
     970             : /** This class contains the cell contents and more of an entire sheet.
     971             : 
     972             :     The cell table includes the settings and default formatting of all columns,
     973             :     the settings and default formatting of all used rows, and the contents of
     974             :     all cells of one sheet in a spreadsheet document.
     975             : 
     976             :     The constructor does all the work creating the cell table. It reads the
     977             :     Calc sheet and converts all columns, rows, and cells to Excel record data.
     978             :     Additioanlly, hyperlink records, note records, additional records for
     979             :     formula cells, data validation records, and outline records are created.
     980             : 
     981             :     The Finalize() function does even more work. It calculates default column
     982             :     settings and removes column records that are equal to this default. The
     983             :     same happens with rows: A default format is calculated for each row, and
     984             :     all blank cells in this row that have the same format are removed. Then,
     985             :     the most used row settings are calculated, and all empty rows that have the
     986             :     same settings are removed too.
     987             : 
     988             :     Records that are not stored inside the cell table area in an Excel file
     989             :     (i.e. DEFROWHEIGHT record, NOTE records, MERGEDCELLS record, HLINK records,
     990             :     DVAL and DV records for data validation) can be accessed with the function
     991             :     CreateRecord(). It returns the reference to the respective record (or
     992             :     record list) which can be inserted into a record list.
     993             :  */
     994           0 : class XclExpCellTable : public XclExpRecordBase, protected XclExpRoot
     995             : {
     996             : public:
     997             :     explicit            XclExpCellTable( const XclExpRoot& rRoot );
     998             : 
     999             :     /** Converts all XF identifiers into the Excel XF indexes and calculates default formats. */
    1000             :     void                Finalize();
    1001             : 
    1002             :     /** Returns the reference to an internal record specified by the passed record id.
    1003             :         @param nRecId  The record identifier that specifies which record is
    1004             :             returned. Possible values are: EXC_ID_DEFROWHEIGHT, EXC_ID_NOTE,
    1005             :             EXC_ID_MERGEDCELLS, EXC_ID_HLINK, EXC_ID_DVAL. */
    1006             :     XclExpRecordRef     CreateRecord( sal_uInt16 nRecId ) const;
    1007             :     /** Saves the entire cell table. */
    1008             :     virtual void        Save( XclExpStream& rStrm ) SAL_OVERRIDE;
    1009             :     virtual void        SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
    1010             : 
    1011             : private:
    1012             :     typedef XclExpRecordList< XclExpNote >      XclExpNoteList;
    1013             :     typedef XclExpRecordList< XclExpHyperlink > XclExpHyperlinkList;
    1014             : 
    1015             :     typedef boost::shared_ptr< XclExpDefrowheight >        XclExpDefrowhRef;
    1016             :     typedef boost::shared_ptr< XclExpNoteList >            XclExpNoteListRef;
    1017             :     typedef boost::shared_ptr< XclExpMergedcells >         XclExpMergedcellsRef;
    1018             :     typedef boost::shared_ptr< XclExpHyperlinkList >       XclExpHyperlinkRef;
    1019             :     typedef boost::shared_ptr< XclExpDval >                XclExpDvalRef;
    1020             :     typedef boost::shared_ptr< XclExtLst >                 XclExtLstRef;
    1021             : 
    1022             :     XclExpColinfoBuffer maColInfoBfr;       /// Buffer for column formatting.
    1023             :     XclExpRowBuffer     maRowBfr;           /// Rows and cell records.
    1024             :     XclExpArrayBuffer   maArrayBfr;         /// Buffer for ARRAY records.
    1025             :     XclExpShrfmlaBuffer maShrfmlaBfr;       /// Buffer for SHRFMLA records.
    1026             :     XclExpTableopBuffer maTableopBfr;       /// Buffer for TABLEOP records.
    1027             :     XclExpDefrowhRef    mxDefrowheight;     /// DEFROWHEIGHT record for default row format.
    1028             :     XclExpRecordRef     mxGuts;             /// GUTS record for outline areas.
    1029             :     XclExpNoteListRef   mxNoteList;         /// List of NOTE records.
    1030             :     XclExpMergedcellsRef mxMergedcells;     /// MERGEDCELLS record for merged cell ranges.
    1031             :     XclExpHyperlinkRef  mxHyperlinkList;    /// List of HLINK records.
    1032             :     XclExpDvalRef       mxDval;             /// Data validation with DVAL and DV records.
    1033             :     XclExtLstRef        mxExtLst;
    1034             : };
    1035             : 
    1036             : #endif
    1037             : 
    1038             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10