LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/filter/inc - xicontent.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 7 8 87.5 %
Date: 2013-07-09 Functions: 13 14 92.9 %
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_XICONTENT_HXX
      21             : #define SC_XICONTENT_HXX
      22             : 
      23             : #include "global.hxx"
      24             : #include "rangelst.hxx"
      25             : #include "xlcontent.hxx"
      26             : #include "xistring.hxx"
      27             : #include "xiroot.hxx"
      28             : #include "validat.hxx"
      29             : 
      30             : #include <map>
      31             : #include <boost/ptr_container/ptr_vector.hpp>
      32             : #include <boost/noncopyable.hpp>
      33             : 
      34             : /* ============================================================================
      35             : Classes to import the big Excel document contents (related to several cells or
      36             : globals for the document).
      37             : - Shared string tables
      38             : - Hyperlinks
      39             : - Label ranges
      40             : - Conditional formatting
      41             : - Data validation
      42             : - Web queries
      43             : - Stream decryption
      44             : ============================================================================ */
      45             : 
      46             : // Shared string table ========================================================
      47             : 
      48             : /** The SST (shared string table) contains all strings used in a BIFF8 file.
      49             : 
      50             :     This class loads the SST, provides access to the strings, and is able to
      51             :     create Calc string or edit cells.
      52             :  */
      53          92 : class XclImpSst : protected XclImpRoot
      54             : {
      55             : public:
      56             :     explicit            XclImpSst( const XclImpRoot& rRoot );
      57             : 
      58             :     /** Reads the entire SST record.
      59             :         @descr  Import stream must be located at start of a SST record. */
      60             :     void                ReadSst( XclImpStream& rStrm );
      61             : 
      62             :     /** Returns a pointer to the string with the passed index. */
      63             :     const XclImpString* GetString( sal_uInt32 nSstIndex ) const;
      64             : 
      65             : private:
      66             :     typedef ::std::vector< XclImpString > XclImpStringVec;
      67             :     XclImpStringVec     maStrings;          /// List with all strings in the SST.
      68             : };
      69             : 
      70             : // Hyperlinks =================================================================
      71             : 
      72             : /** Provides importing hyperlinks and inserting them into a document. */
      73             : class XclImpHyperlink : private boost::noncopyable
      74             : {
      75             : public:
      76             :     /** Reads a HLINK record and inserts it into the document.
      77             :         @descr  Import stream must be located at start of a HLINK record. */
      78             :     static void         ReadHlink( XclImpStream& rStrm );
      79             : 
      80             :     /** Reads the (undocumented) embedded hyperlink data and returns the URL. */
      81             :     static String       ReadEmbeddedData( XclImpStream& rStrm );
      82             : 
      83             :     /** Inserts the URL into a range of cells. Does not modify value or formula cells. */
      84             :     static void         InsertUrl( const XclImpRoot& rRoot, const XclRange& rXclRange, const String& rUrl );
      85             : 
      86             :     /** Convert the sheet name with invalid character(s) in URL when the URL is
      87             :         to a location within the same document (e.g. #'Sheet&Name'.A1). */
      88             :     static void         ConvertToValidTabName(String& rName);
      89             : 
      90             : private:
      91             :     /** We don't want anybody to instantiate this class, since it is just a
      92             :         collection of static methods. To enforce this, the default constructor
      93             :         is made private */
      94             :     XclImpHyperlink();
      95             : };
      96             : 
      97             : // Label ranges ===============================================================
      98             : 
      99             : /** Provides importing label ranges and inserting them into a document. */
     100             : class XclImpLabelranges : private  boost::noncopyable
     101             : {
     102             : public:
     103             :     /** Reads a LABELRANGES record and inserts the label ranges into the document.
     104             :         @descr  Import stream must be located at start of a LABELRANGES record. */
     105             :     static void         ReadLabelranges( XclImpStream& rStrm );
     106             : 
     107             : private:
     108             :     /** We don't want anybody to instantiate this class, since it is just a
     109             :         collection of static methods. To enforce this, the default constructor
     110             :         is made private */
     111             :     XclImpLabelranges();
     112             : };
     113             : 
     114             : // Conditional formatting =====================================================
     115             : 
     116             : class ScConditionalFormat;
     117             : 
     118             : /** Represents a conditional format with condition formulas, and formatting attributes. */
     119             : class XclImpCondFormat : protected XclImpRoot
     120             : {
     121             : public:
     122             :     explicit            XclImpCondFormat( const XclImpRoot& rRoot, sal_uInt32 nFormatIndex );
     123             :     virtual             ~XclImpCondFormat();
     124             : 
     125             :     /** Reads a CONDFMT record and initializes this conditional format. */
     126             :     void                ReadCondfmt( XclImpStream& rStrm );
     127             :     /** Reads a CF record and adds a new condition and the formatting attributes. */
     128             :     void                ReadCF( XclImpStream& rStrm );
     129             : 
     130             :     /** Inserts this conditional format into the document. */
     131             :     void                Apply();
     132             : 
     133             : private:
     134             :     typedef ::std::auto_ptr< ScConditionalFormat > ScCondFmtPtr;
     135             : 
     136             :     ScRangeList         maRanges;           /// Destination cell ranges.
     137             :     ScCondFmtPtr        mxScCondFmt;        /// Calc conditional format.
     138             :     sal_uInt32          mnFormatIndex;      /// Index of this conditional format in list.
     139             :     sal_uInt16          mnCondCount;        /// Number of conditions to be inserted.
     140             :     sal_uInt16          mnCondIndex;        /// Condition index to be inserted next.
     141             : };
     142             : 
     143             : // ----------------------------------------------------------------------------
     144             : 
     145             : /** Imports and collects all conditional formatting of a sheet. */
     146          92 : class XclImpCondFormatManager : protected XclImpRoot
     147             : {
     148             : public:
     149             :     explicit            XclImpCondFormatManager( const XclImpRoot& rRoot );
     150             : 
     151             :     /** Reads a CONDFMT record and starts a new conditional format to be filled from CF records. */
     152             :     void                ReadCondfmt( XclImpStream& rStrm );
     153             :     /** Reads a CF record and inserts the formatting data to the current conditional format. */
     154             :     void                ReadCF( XclImpStream& rStrm );
     155             : 
     156             :     /** Inserts the conditional formatting into the document. */
     157             :     void                Apply();
     158             : 
     159             : private:
     160             :     typedef boost::ptr_vector< XclImpCondFormat > XclImpCondFmtList;
     161             :     XclImpCondFmtList   maCondFmtList;      /// List with all conditional formatting.
     162             : };
     163             : 
     164             : // Data Validation ============================================================
     165             : 
     166             : /** Imports validation data. */
     167          92 : class XclImpValidationManager : protected XclImpRoot
     168             : {
     169             : public:
     170             :     explicit            XclImpValidationManager( const XclImpRoot& rRoot );
     171             : 
     172             :     /** Reads a DVAL record and sets marks the dropdown arrow control to be ignored. */
     173             :     void                ReadDval( XclImpStream& rStrm );
     174             :     /** Reads a DV record and inserts validation data into the document. */
     175             :     void                ReadDV( XclImpStream& rStrm );
     176             : 
     177             :     void                Apply();
     178             : private:
     179           3 :     struct DVItem
     180             :     {
     181             :         ScRangeList         maRanges;
     182             :         ScValidationData    maValidData;
     183             : 
     184             :         explicit DVItem ( const ScRangeList& rRanges, const ScValidationData& rValidData );
     185             :     };
     186             :     typedef ::boost::ptr_vector<DVItem> DVItemList;
     187             : 
     188             :     DVItemList maDVItems;
     189             : };
     190             : 
     191             : // Web queries ================================================================
     192             : 
     193             : /** Stores the data of one web query. */
     194           0 : class XclImpWebQuery : private boost::noncopyable
     195             : {
     196             : public:
     197             :     explicit            XclImpWebQuery( const ScRange& rDestRange );
     198             : 
     199             :     /** Reads a PARAMQRY record and sets data to the web query. */
     200             :     void                ReadParamqry( XclImpStream& rStrm );
     201             :     /** Reads a WQSTRING record and sets URL. */
     202             :     void                ReadWqstring( XclImpStream& rStrm );
     203             :     /** Reads a WEBQRYSETTINGS record and sets refresh rate. */
     204             :     void                ReadWqsettings( XclImpStream& rStrm );
     205             :     /** Reads a WEBQRYTABLES record and sets source range list. */
     206             :     void                ReadWqtables( XclImpStream& rStrm );
     207             : 
     208             :     /** Inserts the web query into the document. */
     209             :     void                Apply( ScDocument& rDoc, const String& rFilterName );
     210             : 
     211             : private:
     212             :     /** Specifies the type of the web query (which ranges are imported). */
     213             :     enum XclImpWebQueryMode
     214             :     {
     215             :         xlWQUnknown,                /// Not specified.
     216             :         xlWQDocument,               /// Entire document.
     217             :         xlWQAllTables,              /// All tables.
     218             :         xlWQSpecTables              /// Specific tables.
     219             :     };
     220             : 
     221             :     String              maURL;          /// Source document URL.
     222             :     String              maTables;       /// List of source range names.
     223             :     ScRange             maDestRange;    /// Destination range.
     224             :     XclImpWebQueryMode  meMode;         /// Current mode of the web query.
     225             :     sal_uInt16          mnRefresh;      /// Refresh time in minutes.
     226             : };
     227             : 
     228             : // ----------------------------------------------------------------------------
     229             : 
     230          92 : class XclImpWebQueryBuffer : protected XclImpRoot
     231             : {
     232             : public:
     233             :     explicit            XclImpWebQueryBuffer( const XclImpRoot& rRoot );
     234             : 
     235             :     /** Reads the QSI record and creates a new web query in the buffer. */
     236             :     void                ReadQsi( XclImpStream& rStrm );
     237             :     /** Reads a PARAMQRY record and sets data to the current web query. */
     238             :     void                ReadParamqry( XclImpStream& rStrm );
     239             :     /** Reads a WQSTRING record and sets URL to the current web query. */
     240             :     void                ReadWqstring( XclImpStream& rStrm );
     241             :     /** Reads a WEBQRYSETTINGS record and sets refresh rate to the current web query. */
     242             :     void                ReadWqsettings( XclImpStream& rStrm );
     243             :     /** Reads a WEBQRYTABLES record and sets source range list to the current web query. */
     244             :     void                ReadWqtables( XclImpStream& rStrm );
     245             : 
     246             :     /** Inserts all web queries into the document. */
     247             :     void                Apply();
     248             : 
     249             : private:
     250             :     typedef boost::ptr_vector< XclImpWebQuery > XclImpWebQueryList;
     251             :     XclImpWebQueryList  maWQList;       /// List of the web query objects.
     252             : };
     253             : 
     254             : // Decryption =================================================================
     255             : 
     256             : /** Provides static functions to import stream decryption settings. */
     257             : class XclImpDecryptHelper : private boost::noncopyable
     258             : {
     259             : public:
     260             :     /** Reads the FILEPASS record, queries a password and sets decryption algorihm.
     261             :         @return  Error code that may cause an error message after import. */
     262             :     static ErrCode      ReadFilepass( XclImpStream& rStrm );
     263             : 
     264             : private:
     265             :     /** We don't want anybody to instantiate this class, since it is just a
     266             :         collection of static methods. To enforce this, the default constructor
     267             :         is made private */
     268             :     XclImpDecryptHelper();
     269             : };
     270             : 
     271             : // ============================================================================
     272             : 
     273             : // Document protection ========================================================
     274             : 
     275          92 : class XclImpDocProtectBuffer : protected XclImpRoot
     276             : {
     277             : public:
     278             :     explicit            XclImpDocProtectBuffer( const XclImpRoot& rRoot );
     279             : 
     280             :     /** document structure protection flag  */
     281             :     void                ReadDocProtect( XclImpStream& rStrm );
     282             : 
     283             :     /** document windows properties protection flag */
     284             :     void                ReadWinProtect( XclImpStream& rStrm );
     285             : 
     286             :     void                ReadPasswordHash( XclImpStream& rStrm );
     287             : 
     288             :     void                Apply() const;
     289             : 
     290             : private:
     291             :     sal_uInt16      mnPassHash;
     292             :     bool            mbDocProtect:1;
     293             :     bool            mbWinProtect:1;
     294             : };
     295             : 
     296             : // Sheet protection ===========================================================
     297             : 
     298          92 : class XclImpSheetProtectBuffer : protected XclImpRoot
     299             : {
     300             : public:
     301             :     explicit            XclImpSheetProtectBuffer( const XclImpRoot& rRoot );
     302             : 
     303             :     void                ReadProtect( XclImpStream& rStrm, SCTAB nTab );
     304             : 
     305             :     void                ReadOptions( XclImpStream& rStrm, SCTAB nTab );
     306             : 
     307             :     void                ReadPasswordHash( XclImpStream& rStrm, SCTAB nTab );
     308             : 
     309             :     void                Apply() const;
     310             : 
     311             : private:
     312             :     struct Sheet
     313             :     {
     314             :         bool        mbProtected;
     315             :         sal_uInt16  mnPasswordHash;
     316             :         sal_uInt16  mnOptions;
     317             : 
     318             :         Sheet();
     319             :         Sheet(const Sheet& r);
     320             :     };
     321             : 
     322             :     Sheet* GetSheetItem( SCTAB nTab );
     323             : 
     324             : private:
     325             :     typedef ::std::map<SCTAB, Sheet> ProtectedSheetMap;
     326             :     ProtectedSheetMap   maProtectedSheets;
     327             : };
     328             : 
     329             : // ============================================================================
     330             : 
     331             : #endif
     332             : 
     333             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10