LCOV - code coverage report
Current view: top level - sc/source/filter/inc - xecontent.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 7 10 70.0 %
Date: 2015-06-13 12:38:46 Functions: 14 18 77.8 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_SC_SOURCE_FILTER_INC_XECONTENT_HXX
      21             : #define INCLUDED_SC_SOURCE_FILTER_INC_XECONTENT_HXX
      22             : 
      23             : #include "rangelst.hxx"
      24             : #include "xlcontent.hxx"
      25             : #include "xladdress.hxx"
      26             : #include "xerecord.hxx"
      27             : #include "xeroot.hxx"
      28             : #include "xestring.hxx"
      29             : #include "xeformula.hxx"
      30             : #include "xeextlst.hxx"
      31             : 
      32             : #include "colorscale.hxx"
      33             : 
      34             : /* ============================================================================
      35             : Classes to export the big Excel document contents (related to several cells or
      36             : globals for the sheet or document).
      37             : - Shared string table
      38             : - Merged cells
      39             : - Hyperlinks
      40             : - Label ranges
      41             : - Conditional formatting
      42             : - Data validation
      43             : - Web Queries
      44             : ============================================================================ */
      45             : 
      46             : // Shared string table ========================================================
      47             : 
      48             : class XclExpSstImpl;
      49             : 
      50             : /** Provides export of the SST (shared string table) record.
      51             :     @descr  Contains all strings in the document and writes the SST. */
      52             : class XclExpSst : public XclExpRecordBase
      53             : {
      54             : public:
      55             :     explicit            XclExpSst();
      56             :     virtual             ~XclExpSst();
      57             : 
      58             :     /** Inserts a new string into the table.
      59             :         @return  The index of the string in the SST, used in other records. */
      60             :     sal_uInt32          Insert( XclExpStringRef xString );
      61             : 
      62             :     /** Writes the complete SST and EXTSST records. */
      63             :     virtual void        Save( XclExpStream& rStrm ) SAL_OVERRIDE;
      64             :     virtual void        SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
      65             : 
      66             : private:
      67             :     typedef boost::scoped_ptr< XclExpSstImpl > XclExpSstImplPtr;
      68             :     XclExpSstImplPtr    mxImpl;
      69             : };
      70             : 
      71             : // Merged cells ===============================================================
      72             : 
      73             : /** Represents a MERGEDCELLS record containing all merged cell ranges in a sheet. */
      74         258 : class XclExpMergedcells : public XclExpRecordBase, protected XclExpRoot
      75             : {
      76             : public:
      77             :     explicit            XclExpMergedcells( const XclExpRoot& rRoot );
      78             : 
      79             :     /** Appends a new range to the list of merged cell ranges. */
      80             :     void                AppendRange( const ScRange& rRange, sal_uInt32 nBaseXFId );
      81             :     /** Returns the XF identifier of the top-left cell in a merged range. */
      82             :     sal_uInt32          GetBaseXFId( const ScAddress& rPos ) const;
      83             : 
      84             :     /** Writes the record, if it contains at least one merged cell range. */
      85             :     virtual void        Save( XclExpStream& rStrm ) SAL_OVERRIDE;
      86             :     virtual void        SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
      87             : 
      88             : private:
      89             :     ScRangeList         maMergedRanges;     /// All merged cell ranges of the sheet.
      90             :     ScfUInt32Vec        maBaseXFIds;        /// The XF identifiers of the top-left cells.
      91             : };
      92             : 
      93             : // Hyperlinks =================================================================
      94             : 
      95             : class SvxURLField;
      96             : 
      97             : /** Provides export of hyperlink data. */
      98             : class XclExpHyperlink : public XclExpRecord
      99             : {
     100             : public:
     101             :     /** Constructs the HLINK record from an URL text field. */
     102             :     explicit            XclExpHyperlink( const XclExpRoot& rRoot,
     103             :                             const SvxURLField& rUrlField, const ScAddress& rScPos );
     104             :     virtual             ~XclExpHyperlink();
     105             : 
     106             :     /** Returns the cell representation text or 0, if not available. */
     107           0 :     inline const OUString* GetRepr() const { return m_Repr.isEmpty() ? 0 : &m_Repr; }
     108             : 
     109             :     virtual void        SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     110             : 
     111             :     void                WriteEmbeddedData( XclExpStream& rStrm );
     112             :     void                SetDisplay( bool bDisplay ) { mbSetDisplay = bDisplay; }
     113             : 
     114             :     /** Builds file name from the passed file URL. Tries to convert to relative file name.
     115             :         @param rnLevel  (out-param) The parent directory level.
     116             :         @param rbRel  (out-param) true = path is relative.
     117             :         @param bEncoded if true return an IURI encoded name, not a DOS name. */
     118             :     static OUString     BuildFileName(
     119             :                             sal_uInt16& rnLevel, bool& rbRel,
     120             :                             const OUString& rUrl, const XclExpRoot& rRoot, bool bEncoded );
     121             : private:
     122             : 
     123             :     /** Writes the body of the HLINK record. */
     124             :     virtual void        WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
     125             : 
     126             : private:
     127             :     typedef boost::scoped_ptr< SvStream > SvStreamPtr;
     128             : 
     129             :     ScAddress           maScPos;            /// Position of the hyperlink.
     130             :     OUString            m_Repr;             /// Cell representation text.
     131             :     SvStreamPtr         mxVarData;          /// Buffer stream with variable data.
     132             :     sal_uInt32          mnFlags;            /// Option flags.
     133             :     XclExpStringRef     mxTextMark;         /// Location within m_Repr
     134             :     OUString            msTarget;           /// Target URL
     135             :     bool                mbSetDisplay;       /// True if display attribute it written
     136             : };
     137             : 
     138             : typedef XclExpRecordList< XclExpHyperlink > XclExpHyperlinkList;
     139             : 
     140             : // Label ranges ===============================================================
     141             : 
     142             : /** Provides export of the row/column label range list of a sheet. */
     143          58 : class XclExpLabelranges : public XclExpRecordBase, protected XclExpRoot
     144             : {
     145             : public:
     146             :     /** Fills the cell range lists with all ranges of the current sheet. */
     147             :     explicit            XclExpLabelranges( const XclExpRoot& rRoot );
     148             : 
     149             :     /** Writes the LABELRANGES record if it contains at least one range. */
     150             :     virtual void        Save( XclExpStream& rStrm ) SAL_OVERRIDE;
     151             : 
     152             : private:
     153             :     /** Fills the specified range list with all label headers of the current sheet.
     154             :         @param rRanges  The cell range list to fill.
     155             :         @param xLabelRangesRef  The core range list with all ranges.
     156             :         @param nScTab  The current Calc sheet index. */
     157             :     static void         FillRangeList( ScRangeList& rScRanges,
     158             :                             ScRangePairListRef xLabelRangesRef, SCTAB nScTab );
     159             : 
     160             : private:
     161             :     ScRangeList         maRowRanges;    /// Cell range list for row labels.
     162             :     ScRangeList         maColRanges;    /// Cell range list for column labels.
     163             : };
     164             : 
     165             : // Conditional formatting =====================================================
     166             : 
     167             : class ScCondFormatEntry;
     168             : class XclExpCFImpl;
     169             : 
     170             : /** Represents a CF record that contains one condition of a conditional format. */
     171             : class XclExpCF : public XclExpRecord, protected XclExpRoot
     172             : {
     173             : public:
     174             :     explicit            XclExpCF( const XclExpRoot& rRoot, const ScCondFormatEntry& rFormatEntry, sal_Int32 nPriority );
     175             :     virtual             ~XclExpCF();
     176             : 
     177             :     virtual void        SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     178             : 
     179             : private:
     180             :     /** Writes the body of the CF record. */
     181             :     virtual void        WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
     182             : 
     183             : private:
     184             :     typedef boost::scoped_ptr< XclExpCFImpl > XclExpCFImplPtr;
     185             :     XclExpCFImplPtr     mxImpl;
     186             : };
     187             : 
     188             : class XclExpDateFormat : public XclExpRecord, protected XclExpRoot
     189             : {
     190             : public:
     191             :     explicit XclExpDateFormat( const XclExpRoot& rRoot, const ScCondDateFormatEntry& rFormatEntry, sal_Int32 nPriority );
     192             :     virtual ~XclExpDateFormat();
     193             : 
     194             :     virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     195             : 
     196             : private:
     197             :     const ScCondDateFormatEntry& mrFormatEntry;
     198             :     sal_Int32 mnPriority;
     199             : };
     200             : 
     201             : class XclExpCfvo : public XclExpRecord, protected XclExpRoot
     202             : {
     203             : public:
     204             :     explicit XclExpCfvo( const XclExpRoot& rRoot, const ScColorScaleEntry& rFormatEntry, const ScAddress& rPos, bool bFirst = true);
     205          50 :     virtual ~XclExpCfvo() {}
     206             : 
     207             :     virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     208             : private:
     209             :     const ScColorScaleEntry& mrEntry;
     210             :     ScAddress maSrcPos;
     211             :     bool mbFirst;
     212             : };
     213             : 
     214             : class XclExpColScaleCol : public XclExpRecord, protected XclExpRoot
     215             : {
     216             : public:
     217             :     explicit XclExpColScaleCol( const XclExpRoot& rRoot, const Color& rColor);
     218             :     virtual ~XclExpColScaleCol();
     219             : 
     220             :     virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     221             : private:
     222             :     const Color& mrColor;
     223             : };
     224             : 
     225             : class ScConditionalFormat;
     226             : 
     227             : /** Represents a CONDFMT record that contains all conditions of a conditional format.
     228             :     @descr  Contains the conditions which are stored in CF records. */
     229             : class XclExpCondfmt : public XclExpRecord, protected XclExpRoot
     230             : {
     231             : public:
     232             :     explicit            XclExpCondfmt( const XclExpRoot& rRoot, const ScConditionalFormat& rCondFormat, XclExtLstRef xExtLst, sal_Int32& rIndex );
     233             :     virtual             ~XclExpCondfmt();
     234             : 
     235             :     /** Returns true, if this conditional format contains at least one cell range and CF record. */
     236             :     bool                IsValid() const;
     237             : 
     238             :     /** Writes the CONDFMT record with following CF records, if there is valid data. */
     239             :     virtual void        Save( XclExpStream& rStrm ) SAL_OVERRIDE;
     240             :     virtual void        SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     241             : 
     242             : private:
     243             :     /** Writes the body of the CONDFMT record. */
     244             :     virtual void        WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
     245             : 
     246             : private:
     247             :     typedef XclExpRecordList< XclExpRecord > XclExpCFList;
     248             : 
     249             :     XclExpCFList        maCFList;       /// List of CF records.
     250             :     XclRangeList        maXclRanges;    /// Cell ranges for this conditional format.
     251             :     OUString            msSeqRef;       /// OOXML Sequence of References
     252             : };
     253             : 
     254          12 : class XclExpColorScale: public XclExpRecord, protected XclExpRoot
     255             : {
     256             : public:
     257             :     explicit XclExpColorScale( const XclExpRoot& rRoot, const ScColorScaleFormat& rFormat, sal_Int32 nPriority );
     258             : 
     259             :     virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     260             : private:
     261             :     typedef XclExpRecordList< XclExpCfvo > XclExpCfvoList;
     262             :     typedef XclExpRecordList< XclExpColScaleCol > XclExpColScaleColList;
     263             : 
     264             :     XclExpCfvoList maCfvoList;
     265             :     XclExpColScaleColList maColList;
     266             :     sal_Int32 mnPriority;
     267             : };
     268             : 
     269          10 : class XclExpDataBar : public XclExpRecord, protected XclExpRoot
     270             : {
     271             : public:
     272             :     explicit XclExpDataBar( const XclExpRoot& rRoot, const ScDataBarFormat& rFormat, sal_Int32 nPriority, const OString& rGUID);
     273             : 
     274             :     virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     275             : private:
     276             :     boost::scoped_ptr<XclExpCfvo> mpCfvoLowerLimit;
     277             :     boost::scoped_ptr<XclExpCfvo> mpCfvoUpperLimit;
     278             :     boost::scoped_ptr<XclExpColScaleCol> mpCol;
     279             : 
     280             :     const ScDataBarFormat& mrFormat;
     281             :     sal_Int32 mnPriority;
     282             :     OString maGUID;
     283             : };
     284             : 
     285           0 : class XclExpIconSet : public XclExpRecord, protected XclExpRoot
     286             : {
     287             : public:
     288             :     explicit XclExpIconSet( const XclExpRoot& rRoot, const ScIconSetFormat& rFormat, sal_Int32 nPriority );
     289             : 
     290             :     virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     291             : private:
     292             :     typedef XclExpRecordList< XclExpCfvo > XclExpCfvoList;
     293             : 
     294             :     XclExpCfvoList maCfvoList;
     295             :     const ScIconSetFormat& mrFormat;
     296             :     sal_Int32 mnPriority;
     297             : };
     298             : 
     299             : /** Contains all conditional formats of a specific sheet. */
     300         258 : class XclExpCondFormatBuffer : public XclExpRecordBase, protected XclExpRoot
     301             : {
     302             : public:
     303             :     /** Constructs CONDFMT and CF records containing the conditional formats of the current sheet. */
     304             :     explicit            XclExpCondFormatBuffer( const XclExpRoot& rRoot, XclExtLstRef xExtLst );
     305             : 
     306             :     /** Writes all contained CONDFMT records with their CF records. */
     307             :     virtual void        Save( XclExpStream& rStrm ) SAL_OVERRIDE;
     308             :     virtual void        SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     309             : 
     310             : private:
     311             :     typedef XclExpRecordList< XclExpCondfmt > XclExpCondfmtList;
     312             :     XclExpCondfmtList   maCondfmtList;  /// List of CONDFMT records.
     313             : };
     314             : 
     315             : // Data Validation ============================================================
     316             : 
     317             : /** Provides export of the data of a DV record.
     318             :     @descr  This record contains the settings for a data validation. In detail
     319             :     this is a pointer to the core validation data and a cell range list with all
     320             :     affected cells. The handle index is used to optimize list search algorithm. */
     321             : class XclExpDV : public XclExpRecord, protected XclExpRoot
     322             : {
     323             : public:
     324             :     explicit            XclExpDV( const XclExpRoot& rRoot, sal_uLong nScHandle );
     325             :     virtual             ~XclExpDV();
     326             : 
     327             :     /** Returns the core handle of the validation data. */
     328           0 :     inline sal_uLong        GetScHandle() const { return mnScHandle; }
     329             : 
     330             :     /** Inserts a new cell range into the cell range list. */
     331             :     void                InsertCellRange( const ScRange& rPos );
     332             :     /** Converts the Calc range list to the Excel range list.
     333             :         @return  false = Resulting range list empty - do not write this record. */
     334             :     bool                Finalize();
     335             : 
     336             :     virtual void        SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     337             : 
     338             : private:
     339             :     /** Writes the body of the DV record. */
     340             :     virtual void        WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
     341             : 
     342             : private:
     343             :     ScRangeList         maScRanges;     /// Calc range list with all affected cells.
     344             :     XclRangeList        maXclRanges;    /// Excel range list with all affected cells.
     345             :     XclExpString        maPromptTitle;  /// The prompt title.
     346             :     XclExpString        maPromptText;   /// The prompt text.
     347             :     XclExpString        maErrorTitle;   /// The error title.
     348             :     XclExpString        maErrorText;    /// The error text.
     349             :     XclExpStringRef     mxString1;      /// String for first condition formula.
     350             :     XclTokenArrayRef    mxTokArr1;      /// Formula for first condition.
     351             :     OUString            msFormula1;     /// OOXML Formula for first condition.
     352             :     XclTokenArrayRef    mxTokArr2;      /// Formula for second condition.
     353             :     OUString            msFormula2;     /// OOXML Formula for second condition.
     354             :     sal_uInt32          mnFlags;        /// Miscellaneous flags.
     355             :     sal_uLong               mnScHandle;     /// The core handle for quick list search.
     356             : };
     357             : 
     358             : /** This class contains the DV record list following the DVAL record. */
     359             : class XclExpDval : public XclExpRecord, protected XclExpRoot
     360             : {
     361             : public:
     362             :     explicit            XclExpDval( const XclExpRoot& rRoot );
     363             :     virtual             ~XclExpDval();
     364             : 
     365             :     /** Inserts the cell range into the range list of the DV record with the specified handle. */
     366             :     void                InsertCellRange( const ScRange& rRange, sal_uLong nScHandle );
     367             : 
     368             :     /** Writes the DVAL record and the DV record list. */
     369             :     virtual void        Save( XclExpStream& rStrm ) SAL_OVERRIDE;
     370             :     virtual void        SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     371             : 
     372             : private:
     373             :     /** Searches for or creates a XclExpDV record object with the specified handle. */
     374             :     XclExpDV&           SearchOrCreateDv( sal_uLong nScHandle );
     375             : 
     376             :     /** Writes the body of the DVAL record. */
     377             :     virtual void        WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
     378             : 
     379             : private:
     380             :     typedef XclExpRecordList< XclExpDV >    XclExpDVList;
     381             :     typedef XclExpDVList::RecordRefType     XclExpDVRef;
     382             : 
     383             :     XclExpDVList        maDVList;       /// List of DV records
     384             :     XclExpDVRef         mxLastFoundDV;  /// For search optimization.
     385             : };
     386             : 
     387             : // Web Queries ================================================================
     388             : 
     389             : /** Contains all records for a web query (linked tables in an HTML document).
     390             :     @descr  mode 1 (entire document): mpQryTables==0, mbEntireDoc==true;
     391             :     mode 2 (all tables): mpQryTables==0, mbEntireDoc==false;
     392             :     mode 3 (custom range list): mpQryTables!=0, mbEntireDoc==false. */
     393             : class XclExpWebQuery : public XclExpRecordBase
     394             : {
     395             : public:
     396             :     /** Constructs a web query record container with settings from Calc. */
     397             :     explicit            XclExpWebQuery(
     398             :                             const OUString& rRangeName,
     399             :                             const OUString& rUrl,
     400             :                             const OUString& rSource,
     401             :                             sal_Int32 nRefrSecs );
     402             :     virtual             ~XclExpWebQuery();
     403             : 
     404             :     /** Writes all needed records for this web query. */
     405             :     virtual void        Save( XclExpStream& rStrm ) SAL_OVERRIDE;
     406             : 
     407             : private:
     408             :     XclExpString        maDestRange;    /// Destination range.
     409             :     XclExpString        maUrl;          /// Source document URL.
     410             :     XclExpStringRef     mxQryTables;    /// List of source range names.
     411             :     sal_Int16           mnRefresh;      /// Refresh time in minutes.
     412             :     bool                mbEntireDoc;    /// true = entire document.
     413             : };
     414             : 
     415             : /** Contains all web query records for this document. */
     416          58 : class XclExpWebQueryBuffer : public XclExpRecordList< XclExpWebQuery >
     417             : {
     418             : public:
     419             :     explicit            XclExpWebQueryBuffer( const XclExpRoot& rRoot );
     420             : };
     421             : 
     422             : #endif
     423             : 
     424             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11