1*38d50f7bSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*38d50f7bSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*38d50f7bSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*38d50f7bSAndrew Rist * distributed with this work for additional information 6*38d50f7bSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*38d50f7bSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*38d50f7bSAndrew Rist * "License"); you may not use this file except in compliance 9*38d50f7bSAndrew Rist * with the License. You may obtain a copy of the License at 10*38d50f7bSAndrew Rist * 11*38d50f7bSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*38d50f7bSAndrew Rist * 13*38d50f7bSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*38d50f7bSAndrew Rist * software distributed under the License is distributed on an 15*38d50f7bSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*38d50f7bSAndrew Rist * KIND, either express or implied. See the License for the 17*38d50f7bSAndrew Rist * specific language governing permissions and limitations 18*38d50f7bSAndrew Rist * under the License. 19*38d50f7bSAndrew Rist * 20*38d50f7bSAndrew Rist *************************************************************/ 21*38d50f7bSAndrew Rist 22*38d50f7bSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef SC_XICONTENT_HXX 25cdf0e10cSrcweir #define SC_XICONTENT_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "global.hxx" 28cdf0e10cSrcweir #include "rangelst.hxx" 29cdf0e10cSrcweir #include "xlcontent.hxx" 30cdf0e10cSrcweir #include "xistring.hxx" 31cdf0e10cSrcweir #include "xiroot.hxx" 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <map> 34cdf0e10cSrcweir 35cdf0e10cSrcweir /* ============================================================================ 36cdf0e10cSrcweir Classes to import the big Excel document contents (related to several cells or 37cdf0e10cSrcweir globals for the document). 38cdf0e10cSrcweir - Shared string tables 39cdf0e10cSrcweir - Hyperlinks 40cdf0e10cSrcweir - Label ranges 41cdf0e10cSrcweir - Conditional formatting 42cdf0e10cSrcweir - Data validation 43cdf0e10cSrcweir - Web queries 44cdf0e10cSrcweir - Stream decryption 45cdf0e10cSrcweir ============================================================================ */ 46cdf0e10cSrcweir 47cdf0e10cSrcweir // Shared string table ======================================================== 48cdf0e10cSrcweir 49cdf0e10cSrcweir class ScBaseCell; 50cdf0e10cSrcweir 51cdf0e10cSrcweir /** The SST (shared string table) contains all strings used in a BIFF8 file. 52cdf0e10cSrcweir 53cdf0e10cSrcweir This class loads the SST, provides access to the strings, and is able to 54cdf0e10cSrcweir create Calc string or edit cells. 55cdf0e10cSrcweir */ 56cdf0e10cSrcweir class XclImpSst : protected XclImpRoot 57cdf0e10cSrcweir { 58cdf0e10cSrcweir public: 59cdf0e10cSrcweir explicit XclImpSst( const XclImpRoot& rRoot ); 60cdf0e10cSrcweir 61cdf0e10cSrcweir /** Reads the entire SST record. 62cdf0e10cSrcweir @descr Import stream must be located at start of a SST record. */ 63cdf0e10cSrcweir void ReadSst( XclImpStream& rStrm ); 64cdf0e10cSrcweir 65cdf0e10cSrcweir /** Returns a pointer to the string with the passed index. */ 66cdf0e10cSrcweir const XclImpString* GetString( sal_uInt32 nSstIndex ) const; 67cdf0e10cSrcweir 68cdf0e10cSrcweir /** Creates a new text cell or edit cell for a Calc document. 69cdf0e10cSrcweir @param nXFIndex Index to XF for first text portion (checks escapement). */ 70cdf0e10cSrcweir ScBaseCell* CreateCell( sal_uInt32 nSstIndex, sal_uInt16 nXFIndex = 0 ) const; 71cdf0e10cSrcweir 72cdf0e10cSrcweir private: 73cdf0e10cSrcweir typedef ::std::vector< XclImpString > XclImpStringVec; 74cdf0e10cSrcweir XclImpStringVec maStrings; /// List with all strings in the SST. 75cdf0e10cSrcweir }; 76cdf0e10cSrcweir 77cdf0e10cSrcweir // Hyperlinks ================================================================= 78cdf0e10cSrcweir 79cdf0e10cSrcweir /** Provides importing hyperlinks and inserting them into a document. */ 80cdf0e10cSrcweir class XclImpHyperlink : ScfNoInstance 81cdf0e10cSrcweir { 82cdf0e10cSrcweir public: 83cdf0e10cSrcweir /** Reads a HLINK record and inserts it into the document. 84cdf0e10cSrcweir @descr Import stream must be located at start of a HLINK record. */ 85cdf0e10cSrcweir static void ReadHlink( XclImpStream& rStrm ); 86cdf0e10cSrcweir 87cdf0e10cSrcweir /** Reads the (undocumented) embedded hyperlink data and returns the URL. */ 88cdf0e10cSrcweir static String ReadEmbeddedData( XclImpStream& rStrm ); 89cdf0e10cSrcweir 90cdf0e10cSrcweir /** Inserts the URL into a range of cells. Does not modify value or formula cells. */ 91cdf0e10cSrcweir static void InsertUrl( const XclImpRoot& rRoot, const XclRange& rXclRange, const String& rUrl ); 92cdf0e10cSrcweir 93cdf0e10cSrcweir /** Convert the sheet name with invalid character(s) in URL when the URL is 94cdf0e10cSrcweir to a location within the same document (e.g. #'Sheet&Name'.A1). */ 95cdf0e10cSrcweir static void ConvertToValidTabName(String& rName); 96cdf0e10cSrcweir }; 97cdf0e10cSrcweir 98cdf0e10cSrcweir // Label ranges =============================================================== 99cdf0e10cSrcweir 100cdf0e10cSrcweir /** Provides importing label ranges and inserting them into a document. */ 101cdf0e10cSrcweir class XclImpLabelranges : ScfNoInstance 102cdf0e10cSrcweir { 103cdf0e10cSrcweir public: 104cdf0e10cSrcweir /** Reads a LABELRANGES record and inserts the label ranges into the document. 105cdf0e10cSrcweir @descr Import stream must be located at start of a LABELRANGES record. */ 106cdf0e10cSrcweir static void ReadLabelranges( XclImpStream& rStrm ); 107cdf0e10cSrcweir }; 108cdf0e10cSrcweir 109cdf0e10cSrcweir // Conditional formatting ===================================================== 110cdf0e10cSrcweir 111cdf0e10cSrcweir class ScConditionalFormat; 112cdf0e10cSrcweir 113cdf0e10cSrcweir /** Represents a conditional format with condition formulas, and formatting attributes. */ 114cdf0e10cSrcweir class XclImpCondFormat : protected XclImpRoot 115cdf0e10cSrcweir { 116cdf0e10cSrcweir public: 117cdf0e10cSrcweir explicit XclImpCondFormat( const XclImpRoot& rRoot, sal_uInt32 nFormatIndex ); 118cdf0e10cSrcweir virtual ~XclImpCondFormat(); 119cdf0e10cSrcweir 120cdf0e10cSrcweir /** Reads a CONDFMT record and initializes this conditional format. */ 121cdf0e10cSrcweir void ReadCondfmt( XclImpStream& rStrm ); 122cdf0e10cSrcweir /** Reads a CF record and adds a new condition and the formatting attributes. */ 123cdf0e10cSrcweir void ReadCF( XclImpStream& rStrm ); 124cdf0e10cSrcweir 125cdf0e10cSrcweir /** Inserts this conditional format into the document. */ 126cdf0e10cSrcweir void Apply(); 127cdf0e10cSrcweir 128cdf0e10cSrcweir private: 129cdf0e10cSrcweir typedef ::std::auto_ptr< ScConditionalFormat > ScCondFmtPtr; 130cdf0e10cSrcweir 131cdf0e10cSrcweir ScRangeList maRanges; /// Destination cell ranges. 132cdf0e10cSrcweir ScCondFmtPtr mxScCondFmt; /// Calc conditional format. 133cdf0e10cSrcweir sal_uInt32 mnFormatIndex; /// Index of this conditional format in list. 134cdf0e10cSrcweir sal_uInt16 mnCondCount; /// Number of conditions to be inserted. 135cdf0e10cSrcweir sal_uInt16 mnCondIndex; /// Condition index to be inserted next. 136cdf0e10cSrcweir }; 137cdf0e10cSrcweir 138cdf0e10cSrcweir // ---------------------------------------------------------------------------- 139cdf0e10cSrcweir 140cdf0e10cSrcweir /** Imports and collects all conditional formatting of a sheet. */ 141cdf0e10cSrcweir class XclImpCondFormatManager : protected XclImpRoot 142cdf0e10cSrcweir { 143cdf0e10cSrcweir public: 144cdf0e10cSrcweir explicit XclImpCondFormatManager( const XclImpRoot& rRoot ); 145cdf0e10cSrcweir 146cdf0e10cSrcweir /** Reads a CONDFMT record and starts a new conditional format to be filled from CF records. */ 147cdf0e10cSrcweir void ReadCondfmt( XclImpStream& rStrm ); 148cdf0e10cSrcweir /** Reads a CF record and inserts the formatting data to the current conditional format. */ 149cdf0e10cSrcweir void ReadCF( XclImpStream& rStrm ); 150cdf0e10cSrcweir 151cdf0e10cSrcweir /** Inserts the conditional formattings into the document. */ 152cdf0e10cSrcweir void Apply(); 153cdf0e10cSrcweir 154cdf0e10cSrcweir private: 155cdf0e10cSrcweir typedef ScfDelList< XclImpCondFormat > XclImpCondFmtList; 156cdf0e10cSrcweir XclImpCondFmtList maCondFmtList; /// List with all conditional formattings. 157cdf0e10cSrcweir }; 158cdf0e10cSrcweir 159cdf0e10cSrcweir // Data Validation ============================================================ 160cdf0e10cSrcweir 161cdf0e10cSrcweir /** Provides importing validation data and inserting it into a document. */ 162cdf0e10cSrcweir class XclImpValidation : ScfNoInstance 163cdf0e10cSrcweir { 164cdf0e10cSrcweir public: 165cdf0e10cSrcweir /** Reads a DVAL record and sets marks the dropdown arrow control to be ignored. */ 166cdf0e10cSrcweir static void ReadDval( XclImpStream& rStrm ); 167cdf0e10cSrcweir /** Reads a DV record and inserts validation data into the document. */ 168cdf0e10cSrcweir static void ReadDV( XclImpStream& rStrm ); 169cdf0e10cSrcweir }; 170cdf0e10cSrcweir 171cdf0e10cSrcweir // Web queries ================================================================ 172cdf0e10cSrcweir 173cdf0e10cSrcweir /** Stores the data of one web query. */ 174cdf0e10cSrcweir class XclImpWebQuery : ScfNoCopy 175cdf0e10cSrcweir { 176cdf0e10cSrcweir public: 177cdf0e10cSrcweir explicit XclImpWebQuery( const ScRange& rDestRange ); 178cdf0e10cSrcweir 179cdf0e10cSrcweir /** Reads a PARAMQRY record and sets data to the web query. */ 180cdf0e10cSrcweir void ReadParamqry( XclImpStream& rStrm ); 181cdf0e10cSrcweir /** Reads a WQSTRING record and sets URL. */ 182cdf0e10cSrcweir void ReadWqstring( XclImpStream& rStrm ); 183cdf0e10cSrcweir /** Reads a WEBQRYSETTINGS record and sets refresh rate. */ 184cdf0e10cSrcweir void ReadWqsettings( XclImpStream& rStrm ); 185cdf0e10cSrcweir /** Reads a WEBQRYTABLES record and sets source range list. */ 186cdf0e10cSrcweir void ReadWqtables( XclImpStream& rStrm ); 187cdf0e10cSrcweir 188cdf0e10cSrcweir /** Inserts the web query into the document. */ 189cdf0e10cSrcweir void Apply( ScDocument& rDoc, const String& rFilterName ); 190cdf0e10cSrcweir 191cdf0e10cSrcweir private: 192cdf0e10cSrcweir /** Specifies the type of the web query (which ranges are imported). */ 193cdf0e10cSrcweir enum XclImpWebQueryMode 194cdf0e10cSrcweir { 195cdf0e10cSrcweir xlWQUnknown, /// Not specified. 196cdf0e10cSrcweir xlWQDocument, /// Entire document. 197cdf0e10cSrcweir xlWQAllTables, /// All tables. 198cdf0e10cSrcweir xlWQSpecTables /// Specific tables. 199cdf0e10cSrcweir }; 200cdf0e10cSrcweir 201cdf0e10cSrcweir String maURL; /// Source document URL. 202cdf0e10cSrcweir String maTables; /// List of source range names. 203cdf0e10cSrcweir ScRange maDestRange; /// Destination range. 204cdf0e10cSrcweir XclImpWebQueryMode meMode; /// Current mode of the web query. 205cdf0e10cSrcweir sal_uInt16 mnRefresh; /// Refresh time in minutes. 206cdf0e10cSrcweir }; 207cdf0e10cSrcweir 208cdf0e10cSrcweir // ---------------------------------------------------------------------------- 209cdf0e10cSrcweir 210cdf0e10cSrcweir class XclImpWebQueryBuffer : protected XclImpRoot 211cdf0e10cSrcweir { 212cdf0e10cSrcweir public: 213cdf0e10cSrcweir explicit XclImpWebQueryBuffer( const XclImpRoot& rRoot ); 214cdf0e10cSrcweir 215cdf0e10cSrcweir /** Reads the QSI record and creates a new web query in the buffer. */ 216cdf0e10cSrcweir void ReadQsi( XclImpStream& rStrm ); 217cdf0e10cSrcweir /** Reads a PARAMQRY record and sets data to the current web query. */ 218cdf0e10cSrcweir void ReadParamqry( XclImpStream& rStrm ); 219cdf0e10cSrcweir /** Reads a WQSTRING record and sets URL to the current web query. */ 220cdf0e10cSrcweir void ReadWqstring( XclImpStream& rStrm ); 221cdf0e10cSrcweir /** Reads a WEBQRYSETTINGS record and sets refresh rate to the current web query. */ 222cdf0e10cSrcweir void ReadWqsettings( XclImpStream& rStrm ); 223cdf0e10cSrcweir /** Reads a WEBQRYTABLES record and sets source range list to the current web query. */ 224cdf0e10cSrcweir void ReadWqtables( XclImpStream& rStrm ); 225cdf0e10cSrcweir 226cdf0e10cSrcweir /** Inserts all web queries into the document. */ 227cdf0e10cSrcweir void Apply(); 228cdf0e10cSrcweir 229cdf0e10cSrcweir private: 230cdf0e10cSrcweir typedef ScfDelList< XclImpWebQuery > XclImpWebQueryList; 231cdf0e10cSrcweir XclImpWebQueryList maWQList; /// List of the web query objects. 232cdf0e10cSrcweir }; 233cdf0e10cSrcweir 234cdf0e10cSrcweir // Decryption ================================================================= 235cdf0e10cSrcweir 236cdf0e10cSrcweir /** Provides static functions to import stream decryption settings. */ 237cdf0e10cSrcweir class XclImpDecryptHelper : ScfNoInstance 238cdf0e10cSrcweir { 239cdf0e10cSrcweir public: 240cdf0e10cSrcweir /** Reads the FILEPASS record, queries a password and sets decryption algorihm. 241cdf0e10cSrcweir @return Error code that may cause an error message after import. */ 242cdf0e10cSrcweir static ErrCode ReadFilepass( XclImpStream& rStrm ); 243cdf0e10cSrcweir }; 244cdf0e10cSrcweir 245cdf0e10cSrcweir // ============================================================================ 246cdf0e10cSrcweir 247cdf0e10cSrcweir // Document protection ======================================================== 248cdf0e10cSrcweir 249cdf0e10cSrcweir class XclImpDocProtectBuffer : protected XclImpRoot 250cdf0e10cSrcweir { 251cdf0e10cSrcweir public: 252cdf0e10cSrcweir explicit XclImpDocProtectBuffer( const XclImpRoot& rRoot ); 253cdf0e10cSrcweir 254cdf0e10cSrcweir /** document structure protection flag */ 255cdf0e10cSrcweir void ReadDocProtect( XclImpStream& rStrm ); 256cdf0e10cSrcweir 257cdf0e10cSrcweir /** document windows properties protection flag */ 258cdf0e10cSrcweir void ReadWinProtect( XclImpStream& rStrm ); 259cdf0e10cSrcweir 260cdf0e10cSrcweir void ReadPasswordHash( XclImpStream& rStrm ); 261cdf0e10cSrcweir 262cdf0e10cSrcweir void Apply() const; 263cdf0e10cSrcweir 264cdf0e10cSrcweir private: 265cdf0e10cSrcweir sal_uInt16 mnPassHash; 266cdf0e10cSrcweir bool mbDocProtect:1; 267cdf0e10cSrcweir bool mbWinProtect:1; 268cdf0e10cSrcweir }; 269cdf0e10cSrcweir 270cdf0e10cSrcweir // Sheet protection =========================================================== 271cdf0e10cSrcweir 272cdf0e10cSrcweir class XclImpSheetProtectBuffer : protected XclImpRoot 273cdf0e10cSrcweir { 274cdf0e10cSrcweir public: 275cdf0e10cSrcweir explicit XclImpSheetProtectBuffer( const XclImpRoot& rRoot ); 276cdf0e10cSrcweir 277cdf0e10cSrcweir void ReadProtect( XclImpStream& rStrm, SCTAB nTab ); 278cdf0e10cSrcweir 279cdf0e10cSrcweir void ReadOptions( XclImpStream& rStrm, SCTAB nTab ); 280cdf0e10cSrcweir 281cdf0e10cSrcweir void ReadPasswordHash( XclImpStream& rStrm, SCTAB nTab ); 282cdf0e10cSrcweir 283cdf0e10cSrcweir void Apply() const; 284cdf0e10cSrcweir 285cdf0e10cSrcweir private: 286cdf0e10cSrcweir struct Sheet 287cdf0e10cSrcweir { 288cdf0e10cSrcweir bool mbProtected; 289cdf0e10cSrcweir sal_uInt16 mnPasswordHash; 290cdf0e10cSrcweir sal_uInt16 mnOptions; 291cdf0e10cSrcweir 292cdf0e10cSrcweir Sheet(); 293cdf0e10cSrcweir Sheet(const Sheet& r); 294cdf0e10cSrcweir }; 295cdf0e10cSrcweir 296cdf0e10cSrcweir Sheet* GetSheetItem( SCTAB nTab ); 297cdf0e10cSrcweir 298cdf0e10cSrcweir private: 299cdf0e10cSrcweir typedef ::std::map<SCTAB, Sheet> ProtectedSheetMap; 300cdf0e10cSrcweir ProtectedSheetMap maProtectedSheets; 301cdf0e10cSrcweir }; 302cdf0e10cSrcweir 303cdf0e10cSrcweir 304cdf0e10cSrcweir // ============================================================================ 305cdf0e10cSrcweir 306cdf0e10cSrcweir #endif 307cdf0e10cSrcweir 308