LCOV - code coverage report
Current view: top level - sc/source/filter/inc - xicontent.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 7 8 87.5 %
Date: 2012-08-25 Functions: 13 14 92.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 10 24 41.7 %

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

Generated by: LCOV version 1.10