LCOV - code coverage report
Current view: top level - sc/source/filter/inc - xecontent.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 10 0.0 %
Date: 2014-04-14 Functions: 0 18 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_XECONTENT_HXX
      21             : #define SC_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           0 : 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             :     virtual void        WriteEmbeddedData( XclExpStream& rStrm );
     112             :     void                SetDisplay( bool bDisplay ) { mbSetDisplay = bDisplay; }
     113             : private:
     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             :     OUString            BuildFileName(
     118             :                             sal_uInt16& rnLevel, bool& rbRel,
     119             :                             const OUString& rUrl, const XclExpRoot& rRoot ) const;
     120             : 
     121             :     /** Writes the body of the HLINK record. */
     122             :     virtual void        WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
     123             : 
     124             : private:
     125             :     typedef boost::scoped_ptr< SvStream > SvStreamPtr;
     126             : 
     127             :     ScAddress           maScPos;            /// Position of the hyperlink.
     128             :     OUString            m_Repr;             /// Cell representation text.
     129             :     SvStreamPtr         mxVarData;          /// Buffer stream with variable data.
     130             :     sal_uInt32          mnFlags;            /// Option flags.
     131             :     XclExpStringRef     mxTextMark;         /// Location within m_Repr
     132             :     OUString            msTarget;           /// Target URL
     133             :     bool                mbSetDisplay;       /// True if display attribute it written
     134             : };
     135             : 
     136             : typedef XclExpRecordList< XclExpHyperlink > XclExpHyperlinkList;
     137             : 
     138             : // Label ranges ===============================================================
     139             : 
     140             : /** Provides export of the row/column label range list of a sheet. */
     141           0 : class XclExpLabelranges : public XclExpRecordBase, protected XclExpRoot
     142             : {
     143             : public:
     144             :     /** Fills the cell range lists with all ranges of the current sheet. */
     145             :     explicit            XclExpLabelranges( const XclExpRoot& rRoot );
     146             : 
     147             :     /** Writes the LABELRANGES record if it contains at least one range. */
     148             :     virtual void        Save( XclExpStream& rStrm ) SAL_OVERRIDE;
     149             : 
     150             : private:
     151             :     /** Fills the specified range list with all label headers of the current sheet.
     152             :         @param rRanges  The cell range list to fill.
     153             :         @param xLabelRangesRef  The core range list with all ranges.
     154             :         @param nScTab  The current Calc sheet index. */
     155             :     void                FillRangeList( ScRangeList& rScRanges,
     156             :                             ScRangePairListRef xLabelRangesRef, SCTAB nScTab );
     157             : 
     158             : private:
     159             :     ScRangeList         maRowRanges;    /// Cell range list for row labels.
     160             :     ScRangeList         maColRanges;    /// Cell range list for column labels.
     161             : };
     162             : 
     163             : // Conditional formatting =====================================================
     164             : 
     165             : class ScCondFormatEntry;
     166             : class XclExpCFImpl;
     167             : 
     168             : /** Represents a CF record that contains one condition of a conditional format. */
     169             : class XclExpCF : public XclExpRecord, protected XclExpRoot
     170             : {
     171             : public:
     172             :     explicit            XclExpCF( const XclExpRoot& rRoot, const ScCondFormatEntry& rFormatEntry, sal_Int32 nPriority );
     173             :     virtual             ~XclExpCF();
     174             : 
     175             :     virtual void        SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     176             : 
     177             : private:
     178             :     /** Writes the body of the CF record. */
     179             :     virtual void        WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
     180             : 
     181             : private:
     182             :     typedef boost::scoped_ptr< XclExpCFImpl > XclExpCFImplPtr;
     183             :     XclExpCFImplPtr     mxImpl;
     184             : };
     185             : 
     186             : class XclExpDateFormat : public XclExpRecord, protected XclExpRoot
     187             : {
     188             : public:
     189             :     explicit XclExpDateFormat( const XclExpRoot& rRoot, const ScCondDateFormatEntry& rFormatEntry, sal_Int32 nPriority );
     190             :     virtual ~XclExpDateFormat();
     191             : 
     192             :     virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     193             : 
     194             : private:
     195             :     const ScCondDateFormatEntry& mrFormatEntry;
     196             :     sal_Int32 mnPriority;
     197             : };
     198             : 
     199             : class XclExpCfvo : public XclExpRecord, protected XclExpRoot
     200             : {
     201             : public:
     202             :     explicit XclExpCfvo( const XclExpRoot& rRoot, const ScColorScaleEntry& rFormatEntry, const ScAddress& rPos, bool bFirst = true);
     203           0 :     virtual ~XclExpCfvo() {}
     204             : 
     205             :     virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     206             : private:
     207             :     const ScColorScaleEntry& mrEntry;
     208             :     ScAddress maSrcPos;
     209             :     bool mbFirst;
     210             : };
     211             : 
     212             : class XclExpColScaleCol : public XclExpRecord, protected XclExpRoot
     213             : {
     214             : public:
     215             :     explicit XclExpColScaleCol( const XclExpRoot& rRoot, const Color& rColor);
     216             :     virtual ~XclExpColScaleCol();
     217             : 
     218             :     virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     219             : private:
     220             :     const Color& mrColor;
     221             : };
     222             : 
     223             : class ScConditionalFormat;
     224             : 
     225             : /** Represents a CONDFMT record that contains all conditions of a conditional format.
     226             :     @descr  Contains the conditions which are stored in CF records. */
     227             : class XclExpCondfmt : public XclExpRecord, protected XclExpRoot
     228             : {
     229             : public:
     230             :     explicit            XclExpCondfmt( const XclExpRoot& rRoot, const ScConditionalFormat& rCondFormat, XclExtLstRef xExtLst, sal_Int32& rIndex );
     231             :     virtual             ~XclExpCondfmt();
     232             : 
     233             :     /** Returns true, if this conditional format contains at least one cell range and CF record. */
     234             :     bool                IsValid() const;
     235             : 
     236             :     /** Writes the CONDFMT record with following CF records, if there is valid data. */
     237             :     virtual void        Save( XclExpStream& rStrm ) SAL_OVERRIDE;
     238             :     virtual void        SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     239             : 
     240             : private:
     241             :     /** Writes the body of the CONDFMT record. */
     242             :     virtual void        WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
     243             : 
     244             : private:
     245             :     typedef XclExpRecordList< XclExpRecord > XclExpCFList;
     246             : 
     247             :     XclExpCFList        maCFList;       /// List of CF records.
     248             :     XclRangeList        maXclRanges;    /// Cell ranges for this conditional format.
     249             :     OUString            msSeqRef;       /// OOXML Sequence of References
     250             : };
     251             : 
     252           0 : class XclExpColorScale: public XclExpRecord, protected XclExpRoot
     253             : {
     254             : public:
     255             :     explicit XclExpColorScale( const XclExpRoot& rRoot, const ScColorScaleFormat& rFormat, sal_Int32 nPriority );
     256             : 
     257             :     virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     258             : private:
     259             :     typedef XclExpRecordList< XclExpCfvo > XclExpCfvoList;
     260             :     typedef XclExpRecordList< XclExpColScaleCol > XclExpColScaleColList;
     261             : 
     262             :     XclExpCfvoList maCfvoList;
     263             :     XclExpColScaleColList maColList;
     264             :     sal_Int32 mnPriority;
     265             : };
     266             : 
     267           0 : class XclExpDataBar : public XclExpRecord, protected XclExpRoot
     268             : {
     269             : public:
     270             :     explicit XclExpDataBar( const XclExpRoot& rRoot, const ScDataBarFormat& rFormat, sal_Int32 nPriority, XclExtLstRef xExtLst );
     271             : 
     272             :     virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     273             : private:
     274             :     boost::scoped_ptr<XclExpCfvo> mpCfvoLowerLimit;
     275             :     boost::scoped_ptr<XclExpCfvo> mpCfvoUpperLimit;
     276             :     boost::scoped_ptr<XclExpColScaleCol> mpCol;
     277             : 
     278             :     const ScDataBarFormat& mrFormat;
     279             :     sal_Int32 mnPriority;
     280             :     OString maGuid;
     281             : };
     282             : 
     283           0 : class XclExpIconSet : public XclExpRecord, protected XclExpRoot
     284             : {
     285             : public:
     286             :     explicit XclExpIconSet( const XclExpRoot& rRoot, const ScIconSetFormat& rFormat, sal_Int32 nPriority );
     287             : 
     288             :     virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     289             : private:
     290             :     typedef XclExpRecordList< XclExpCfvo > XclExpCfvoList;
     291             : 
     292             :     XclExpCfvoList maCfvoList;
     293             :     const ScIconSetFormat& mrFormat;
     294             :     sal_Int32 mnPriority;
     295             : };
     296             : 
     297             : /** Contains all conditional formats of a specific sheet. */
     298           0 : class XclExpCondFormatBuffer : public XclExpRecordBase, protected XclExpRoot
     299             : {
     300             : public:
     301             :     /** Constructs CONDFMT and CF records containing the conditional formats of the current sheet. */
     302             :     explicit            XclExpCondFormatBuffer( const XclExpRoot& rRoot, XclExtLstRef xExtLst );
     303             : 
     304             :     /** Writes all contained CONDFMT records with their CF records. */
     305             :     virtual void        Save( XclExpStream& rStrm ) SAL_OVERRIDE;
     306             :     virtual void        SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     307             : 
     308             : private:
     309             :     typedef XclExpRecordList< XclExpCondfmt > XclExpCondfmtList;
     310             :     XclExpCondfmtList   maCondfmtList;  /// List of CONDFMT records.
     311             : };
     312             : 
     313             : // Data Validation ============================================================
     314             : 
     315             : /** Provides export of the data of a DV record.
     316             :     @descr  This record contains the settings for a data validation. In detail
     317             :     this is a pointer to the core validation data and a cell range list with all
     318             :     affected cells. The handle index is used to optimize list search algorithm. */
     319             : class XclExpDV : public XclExpRecord, protected XclExpRoot
     320             : {
     321             : public:
     322             :     explicit            XclExpDV( const XclExpRoot& rRoot, sal_uLong nScHandle );
     323             :     virtual             ~XclExpDV();
     324             : 
     325             :     /** Returns the core handle of the validation data. */
     326           0 :     inline sal_uLong        GetScHandle() const { return mnScHandle; }
     327             : 
     328             :     /** Inserts a new cell range into the cell range list. */
     329             :     void                InsertCellRange( const ScRange& rPos );
     330             :     /** Converts the Calc range list to the Excel range list.
     331             :         @return  false = Resulting range list empty - do not write this record. */
     332             :     bool                Finalize();
     333             : 
     334             :     virtual void        SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     335             : 
     336             : private:
     337             :     /** Writes the body of the DV record. */
     338             :     virtual void        WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
     339             : 
     340             : private:
     341             :     ScRangeList         maScRanges;     /// Calc range list with all affected cells.
     342             :     XclRangeList        maXclRanges;    /// Excel range list with all affected cells.
     343             :     XclExpString        maPromptTitle;  /// The prompt title.
     344             :     XclExpString        maPromptText;   /// The prompt text.
     345             :     XclExpString        maErrorTitle;   /// The error title.
     346             :     XclExpString        maErrorText;    /// The error text.
     347             :     XclExpStringRef     mxString1;      /// String for first condition formula.
     348             :     XclTokenArrayRef    mxTokArr1;      /// Formula for first condition.
     349             :     OUString            msFormula1;     /// OOXML Formula for first condition.
     350             :     XclTokenArrayRef    mxTokArr2;      /// Formula for second condition.
     351             :     OUString            msFormula2;     /// OOXML Formula for second condition.
     352             :     sal_uInt32          mnFlags;        /// Miscellaneous flags.
     353             :     sal_uLong               mnScHandle;     /// The core handle for quick list search.
     354             : };
     355             : 
     356             : /** This class contains the DV record list following the DVAL record. */
     357             : class XclExpDval : public XclExpRecord, protected XclExpRoot
     358             : {
     359             : public:
     360             :     explicit            XclExpDval( const XclExpRoot& rRoot );
     361             :     virtual             ~XclExpDval();
     362             : 
     363             :     /** Inserts the cell range into the range list of the DV record with the specified handle. */
     364             :     void                InsertCellRange( const ScRange& rRange, sal_uLong nScHandle );
     365             : 
     366             :     /** Writes the DVAL record and the DV record list. */
     367             :     virtual void        Save( XclExpStream& rStrm ) SAL_OVERRIDE;
     368             :     virtual void        SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
     369             : 
     370             : private:
     371             :     /** Searches for or creates a XclExpDV record object with the specified handle. */
     372             :     XclExpDV&           SearchOrCreateDv( sal_uLong nScHandle );
     373             : 
     374             :     /** Writes the body of the DVAL record. */
     375             :     virtual void        WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
     376             : 
     377             : private:
     378             :     typedef XclExpRecordList< XclExpDV >    XclExpDVList;
     379             :     typedef XclExpDVList::RecordRefType     XclExpDVRef;
     380             : 
     381             :     XclExpDVList        maDVList;       /// List of DV records
     382             :     XclExpDVRef         mxLastFoundDV;  /// For search optimization.
     383             : };
     384             : 
     385             : // Web Queries ================================================================
     386             : 
     387             : /** Contains all records for a web query (linked tables in an HTML document).
     388             :     @descr  mode 1 (entire document): mpQryTables==0, mbEntireDoc==true;
     389             :     mode 2 (all tables): mpQryTables==0, mbEntireDoc==false;
     390             :     mode 3 (custom range list): mpQryTables!=0, mbEntireDoc==false. */
     391             : class XclExpWebQuery : public XclExpRecordBase
     392             : {
     393             : public:
     394             :     /** Constructs a web query record container with settings from Calc. */
     395             :     explicit            XclExpWebQuery(
     396             :                             const OUString& rRangeName,
     397             :                             const OUString& rUrl,
     398             :                             const OUString& rSource,
     399             :                             sal_Int32 nRefrSecs );
     400             :     virtual             ~XclExpWebQuery();
     401             : 
     402             :     /** Writes all needed records for this web query. */
     403             :     virtual void        Save( XclExpStream& rStrm ) SAL_OVERRIDE;
     404             : 
     405             : private:
     406             :     XclExpString        maDestRange;    /// Destination range.
     407             :     XclExpString        maUrl;          /// Source document URL.
     408             :     XclExpStringRef     mxQryTables;    /// List of source range names.
     409             :     sal_Int16           mnRefresh;      /// Refresh time in minutes.
     410             :     bool                mbEntireDoc;    /// true = entire document.
     411             : };
     412             : 
     413             : /** Contains all web query records for this document. */
     414           0 : class XclExpWebQueryBuffer : public XclExpRecordList< XclExpWebQuery >
     415             : {
     416             : public:
     417             :     explicit            XclExpWebQueryBuffer( const XclExpRoot& rRoot );
     418             : };
     419             : 
     420             : #endif
     421             : 
     422             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10