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

Generated by: LCOV version 1.10