update ooo310-m15
[ooovba.git] / sc / source / filter / inc / xicontent.hxx
blob07b237a0a6a105cf26934b77024b8b34998d4163
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xicontent.hxx,v $
10 * $Revision: 1.16 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_XICONTENT_HXX
32 #define SC_XICONTENT_HXX
34 #include "global.hxx"
35 #include "rangelst.hxx"
36 #include "xlcontent.hxx"
37 #include "xistring.hxx"
38 #include "xiroot.hxx"
40 #include <map>
42 /* ============================================================================
43 Classes to import the big Excel document contents (related to several cells or
44 globals for the document).
45 - Shared string tables
46 - Hyperlinks
47 - Label ranges
48 - Conditional formatting
49 - Data validation
50 - Web queries
51 - Stream decryption
52 ============================================================================ */
54 // Shared string table ========================================================
56 class ScBaseCell;
58 /** The SST (shared string table) contains all strings used in a BIFF8 file.
60 This class loads the SST, provides access to the strings, and is able to
61 create Calc string or edit cells.
63 class XclImpSst : protected XclImpRoot
65 public:
66 explicit XclImpSst( const XclImpRoot& rRoot );
68 /** Reads the entire SST record.
69 @descr Import stream must be located at start of a SST record. */
70 void ReadSst( XclImpStream& rStrm );
72 /** Returns a pointer to the string with the passed index. */
73 const XclImpString* GetString( sal_uInt32 nSstIndex ) const;
75 /** Creates a new text cell or edit cell for a Calc document.
76 @param nXFIndex Index to XF for first text portion (checks escapement). */
77 ScBaseCell* CreateCell( sal_uInt32 nSstIndex, sal_uInt16 nXFIndex = 0 ) const;
79 private:
80 typedef ::std::vector< XclImpString > XclImpStringVec;
81 XclImpStringVec maStrings; /// List with all strings in the SST.
84 // Hyperlinks =================================================================
86 /** Provides importing hyperlinks and inserting them into a document. */
87 class XclImpHyperlink : ScfNoInstance
89 public:
90 /** Reads a HLINK record and inserts it into the document.
91 @descr Import stream must be located at start of a HLINK record. */
92 static void ReadHlink( XclImpStream& rStrm );
94 /** Reads the (undocumented) embedded hyperlink data and returns the URL. */
95 static String ReadEmbeddedData( XclImpStream& rStrm );
97 /** Inserts the URL into a range of cells. Does not modify value or formula cells. */
98 static void InsertUrl( const XclImpRoot& rRoot, const XclRange& rXclRange, const String& rUrl );
100 /** Convert the sheet name with invalid character(s) in URL when the URL is
101 to a location within the same document (e.g. #'Sheet&Name'.A1). */
102 static void ConvertToValidTabName(String& rName);
105 // Label ranges ===============================================================
107 /** Provides importing label ranges and inserting them into a document. */
108 class XclImpLabelranges : ScfNoInstance
110 public:
111 /** Reads a LABELRANGES record and inserts the label ranges into the document.
112 @descr Import stream must be located at start of a LABELRANGES record. */
113 static void ReadLabelranges( XclImpStream& rStrm );
116 // Conditional formatting =====================================================
118 class ScConditionalFormat;
120 /** Represents a conditional format with condition formulas, and formatting attributes. */
121 class XclImpCondFormat : protected XclImpRoot
123 public:
124 explicit XclImpCondFormat( const XclImpRoot& rRoot, sal_uInt32 nFormatIndex );
125 virtual ~XclImpCondFormat();
127 /** Reads a CONDFMT record and initializes this conditional format. */
128 void ReadCondfmt( XclImpStream& rStrm );
129 /** Reads a CF record and adds a new condition and the formatting attributes. */
130 void ReadCF( XclImpStream& rStrm );
132 /** Inserts this conditional format into the document. */
133 void Apply();
135 private:
136 typedef ::std::auto_ptr< ScConditionalFormat > ScCondFmtPtr;
138 ScRangeList maRanges; /// Destination cell ranges.
139 ScCondFmtPtr mxScCondFmt; /// Calc conditional format.
140 sal_uInt32 mnFormatIndex; /// Index of this conditional format in list.
141 sal_uInt16 mnCondCount; /// Number of conditions to be inserted.
142 sal_uInt16 mnCondIndex; /// Condition index to be inserted next.
145 // ----------------------------------------------------------------------------
147 /** Imports and collects all conditional formatting of a sheet. */
148 class XclImpCondFormatManager : protected XclImpRoot
150 public:
151 explicit XclImpCondFormatManager( const XclImpRoot& rRoot );
153 /** Reads a CONDFMT record and starts a new conditional format to be filled from CF records. */
154 void ReadCondfmt( XclImpStream& rStrm );
155 /** Reads a CF record and inserts the formatting data to the current conditional format. */
156 void ReadCF( XclImpStream& rStrm );
158 /** Inserts the conditional formattings into the document. */
159 void Apply();
161 private:
162 typedef ScfDelList< XclImpCondFormat > XclImpCondFmtList;
163 XclImpCondFmtList maCondFmtList; /// List with all conditional formattings.
166 // Data Validation ============================================================
168 /** Provides importing validation data and inserting it into a document. */
169 class XclImpValidation : ScfNoInstance
171 public:
172 /** Reads a DVAL record and sets marks the dropdown arrow control to be ignored. */
173 static void ReadDval( XclImpStream& rStrm );
174 /** Reads a DV record and inserts validation data into the document. */
175 static void ReadDV( XclImpStream& rStrm );
178 // Web queries ================================================================
180 /** Stores the data of one web query. */
181 class XclImpWebQuery : ScfNoCopy
183 public:
184 explicit XclImpWebQuery( const ScRange& rDestRange );
186 /** Reads a PARAMQRY record and sets data to the web query. */
187 void ReadParamqry( XclImpStream& rStrm );
188 /** Reads a WQSTRING record and sets URL. */
189 void ReadWqstring( XclImpStream& rStrm );
190 /** Reads a WEBQRYSETTINGS record and sets refresh rate. */
191 void ReadWqsettings( XclImpStream& rStrm );
192 /** Reads a WEBQRYTABLES record and sets source range list. */
193 void ReadWqtables( XclImpStream& rStrm );
195 /** Inserts the web query into the document. */
196 void Apply( ScDocument& rDoc, const String& rFilterName );
198 private:
199 /** Specifies the type of the web query (which ranges are imported). */
200 enum XclImpWebQueryMode
202 xlWQUnknown, /// Not specified.
203 xlWQDocument, /// Entire document.
204 xlWQAllTables, /// All tables.
205 xlWQSpecTables /// Specific tables.
208 String maURL; /// Source document URL.
209 String maTables; /// List of source range names.
210 ScRange maDestRange; /// Destination range.
211 XclImpWebQueryMode meMode; /// Current mode of the web query.
212 sal_uInt16 mnRefresh; /// Refresh time in minutes.
215 // ----------------------------------------------------------------------------
217 class XclImpWebQueryBuffer : protected XclImpRoot
219 public:
220 explicit XclImpWebQueryBuffer( const XclImpRoot& rRoot );
222 /** Reads the QSI record and creates a new web query in the buffer. */
223 void ReadQsi( XclImpStream& rStrm );
224 /** Reads a PARAMQRY record and sets data to the current web query. */
225 void ReadParamqry( XclImpStream& rStrm );
226 /** Reads a WQSTRING record and sets URL to the current web query. */
227 void ReadWqstring( XclImpStream& rStrm );
228 /** Reads a WEBQRYSETTINGS record and sets refresh rate to the current web query. */
229 void ReadWqsettings( XclImpStream& rStrm );
230 /** Reads a WEBQRYTABLES record and sets source range list to the current web query. */
231 void ReadWqtables( XclImpStream& rStrm );
233 /** Inserts all web queries into the document. */
234 void Apply();
236 private:
237 typedef ScfDelList< XclImpWebQuery > XclImpWebQueryList;
238 XclImpWebQueryList maWQList; /// List of the web query objects.
241 // Decryption =================================================================
243 /** Provides static functions to import stream decryption settings. */
244 class XclImpDecryptHelper : ScfNoInstance
246 public:
247 /** Reads the FILEPASS record, queries a password and sets decryption algorihm.
248 @return Error code that may cause an error message after import. */
249 static ErrCode ReadFilepass( XclImpStream& rStrm );
252 // ============================================================================
254 // Document protection ========================================================
256 class XclImpDocProtectBuffer : protected XclImpRoot
258 public:
259 explicit XclImpDocProtectBuffer( const XclImpRoot& rRoot );
261 /** document structure protection flag */
262 void ReadDocProtect( XclImpStream& rStrm );
264 /** document windows properties protection flag */
265 void ReadWinProtect( XclImpStream& rStrm );
267 void ReadPasswordHash( XclImpStream& rStrm );
269 void Apply() const;
271 private:
272 sal_uInt16 mnPassHash;
273 bool mbDocProtect:1;
274 bool mbWinProtect:1;
277 // Sheet protection ===========================================================
279 class XclImpSheetProtectBuffer : protected XclImpRoot
281 public:
282 explicit XclImpSheetProtectBuffer( const XclImpRoot& rRoot );
284 void ReadProtect( XclImpStream& rStrm, SCTAB nTab );
286 void ReadOptions( XclImpStream& rStrm, SCTAB nTab );
288 void ReadPasswordHash( XclImpStream& rStrm, SCTAB nTab );
290 void Apply() const;
292 private:
293 struct Sheet
295 bool mbProtected;
296 sal_uInt16 mnPasswordHash;
297 sal_uInt16 mnOptions;
299 Sheet();
300 Sheet(const Sheet& r);
303 Sheet* GetSheetItem( SCTAB nTab );
305 private:
306 typedef ::std::map<SCTAB, Sheet> ProtectedSheetMap;
307 ProtectedSheetMap maProtectedSheets;
311 // ============================================================================
313 #endif