1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SC_SOURCE_FILTER_INC_XICONTENT_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_XICONTENT_HXX
24 #include "rangelst.hxx"
25 #include "xlcontent.hxx"
26 #include "xistring.hxx"
28 #include "validat.hxx"
29 #include "tabprotection.hxx"
32 #include <boost/ptr_container/ptr_vector.hpp>
33 #include <boost/noncopyable.hpp>
35 /* ============================================================================
36 Classes to import the big Excel document contents (related to several cells or
37 globals for the document).
42 - Conditional formatting
46 ============================================================================ */
48 // Shared string table ========================================================
50 /** The SST (shared string table) contains all strings used in a BIFF8 file.
52 This class loads the SST, provides access to the strings, and is able to
53 create Calc string or edit cells.
55 class XclImpSst
: protected XclImpRoot
58 explicit XclImpSst( const XclImpRoot
& rRoot
);
60 /** Reads the entire SST record.
61 @descr Import stream must be located at start of a SST record. */
62 void ReadSst( XclImpStream
& rStrm
);
64 /** Returns a pointer to the string with the passed index. */
65 const XclImpString
* GetString( sal_uInt32 nSstIndex
) const;
68 typedef ::std::vector
< XclImpString
> XclImpStringVec
;
69 XclImpStringVec maStrings
; /// List with all strings in the SST.
72 // Hyperlinks =================================================================
74 /** Provides importing hyperlinks and inserting them into a document. */
75 class XclImpHyperlink
: private boost::noncopyable
78 /** Reads a HLINK record and inserts it into the document.
79 @descr Import stream must be located at start of a HLINK record. */
80 static void ReadHlink( XclImpStream
& rStrm
);
82 /** Reads the (undocumented) embedded hyperlink data and returns the URL. */
83 static OUString
ReadEmbeddedData( XclImpStream
& rStrm
);
85 /** Inserts the URL into a range of cells. Does not modify value or formula cells. */
86 static void InsertUrl( XclImpRoot
& rRoot
, const XclRange
& rXclRange
, const OUString
& rUrl
);
88 /** Convert the sheet name with invalid character(s) in URL when the URL is
89 to a location within the same document (e.g. #'Sheet&Name'.A1). */
90 static void ConvertToValidTabName(OUString
& rName
);
93 /** We don't want anybody to instantiate this class, since it is just a
94 collection of static methods. To enforce this, the default constructor
99 // Label ranges ===============================================================
101 /** Provides importing label ranges and inserting them into a document. */
102 class XclImpLabelranges
: private boost::noncopyable
105 /** Reads a LABELRANGES record and inserts the label ranges into the document.
106 @descr Import stream must be located at start of a LABELRANGES record. */
107 static void ReadLabelranges( XclImpStream
& rStrm
);
110 /** We don't want anybody to instantiate this class, since it is just a
111 collection of static methods. To enforce this, the default constructor
116 // Conditional formatting =====================================================
118 class ScConditionalFormat
;
120 /** Represents a conditional format with condition formulas, and formatting attributes. */
121 class XclImpCondFormat
: protected XclImpRoot
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. */
136 typedef ::std::unique_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 /** Imports and collects all conditional formatting of a sheet. */
146 class XclImpCondFormatManager
: protected XclImpRoot
149 explicit XclImpCondFormatManager( const XclImpRoot
& rRoot
);
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
);
156 /** Inserts the conditional formatting into the document. */
160 typedef boost::ptr_vector
< XclImpCondFormat
> XclImpCondFmtList
;
161 XclImpCondFmtList maCondFmtList
; /// List with all conditional formatting.
164 // Data Validation ============================================================
166 /** Imports validation data. */
167 class XclImpValidationManager
: protected XclImpRoot
170 explicit XclImpValidationManager( const XclImpRoot
& rRoot
);
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 void ReadDV( XclImpStream
& rStrm
);
181 ScRangeList maRanges
;
182 ScValidationData maValidData
;
184 explicit DVItem ( const ScRangeList
& rRanges
, const ScValidationData
& rValidData
);
186 typedef ::boost::ptr_vector
<DVItem
> DVItemList
;
188 DVItemList maDVItems
;
191 // Web queries ================================================================
193 /** Stores the data of one web query. */
194 class XclImpWebQuery
: private boost::noncopyable
197 explicit XclImpWebQuery( const ScRange
& rDestRange
);
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
);
208 /** Inserts the web query into the document. */
209 void Apply( ScDocument
& rDoc
, const OUString
& rFilterName
);
212 /** Specifies the type of the web query (which ranges are imported). */
213 enum XclImpWebQueryMode
215 xlWQUnknown
, /// Not specified.
216 xlWQDocument
, /// Entire document.
217 xlWQAllTables
, /// All tables.
218 xlWQSpecTables
/// Specific tables.
221 OUString maURL
; /// Source document URL.
222 OUString 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.
228 class XclImpWebQueryBuffer
: protected XclImpRoot
231 explicit XclImpWebQueryBuffer( const XclImpRoot
& rRoot
);
233 /** Reads the QSI record and creates a new web query in the buffer. */
234 void ReadQsi( XclImpStream
& rStrm
);
235 /** Reads a PARAMQRY record and sets data to the current web query. */
236 void ReadParamqry( XclImpStream
& rStrm
);
237 /** Reads a WQSTRING record and sets URL to the current web query. */
238 void ReadWqstring( XclImpStream
& rStrm
);
239 /** Reads a WEBQRYSETTINGS record and sets refresh rate to the current web query. */
240 void ReadWqsettings( XclImpStream
& rStrm
);
241 /** Reads a WEBQRYTABLES record and sets source range list to the current web query. */
242 void ReadWqtables( XclImpStream
& rStrm
);
244 /** Inserts all web queries into the document. */
248 typedef boost::ptr_vector
< XclImpWebQuery
> XclImpWebQueryList
;
249 XclImpWebQueryList maWQList
; /// List of the web query objects.
252 // Decryption =================================================================
254 /** Provides static functions to import stream decryption settings. */
255 class XclImpDecryptHelper
: private boost::noncopyable
258 /** Reads the FILEPASS record, queries a password and sets decryption algorihm.
259 @return Error code that may cause an error message after import. */
260 static ErrCode
ReadFilepass( XclImpStream
& rStrm
);
263 /** We don't want anybody to instantiate this class, since it is just a
264 collection of static methods. To enforce this, the default constructor
266 XclImpDecryptHelper();
269 // Document protection ========================================================
271 class XclImpDocProtectBuffer
: protected XclImpRoot
274 explicit XclImpDocProtectBuffer( const XclImpRoot
& rRoot
);
276 /** document structure protection flag */
277 void ReadDocProtect( XclImpStream
& rStrm
);
279 /** document windows properties protection flag */
280 void ReadWinProtect( XclImpStream
& rStrm
);
282 void ReadPasswordHash( XclImpStream
& rStrm
);
287 sal_uInt16 mnPassHash
;
292 // Sheet protection ===========================================================
294 class XclImpSheetProtectBuffer
: protected XclImpRoot
297 explicit XclImpSheetProtectBuffer( const XclImpRoot
& rRoot
);
299 void ReadProtect( XclImpStream
& rStrm
, SCTAB nTab
);
301 void ReadOptions( XclImpStream
& rStrm
, SCTAB nTab
);
303 void AppendEnhancedProtection( const ScEnhancedProtection
& rProt
, SCTAB nTab
);
305 void ReadPasswordHash( XclImpStream
& rStrm
, SCTAB nTab
);
313 sal_uInt16 mnPasswordHash
;
314 sal_uInt16 mnOptions
;
315 ::std::vector
< ScEnhancedProtection
> maEnhancedProtections
;
318 Sheet(const Sheet
& r
);
321 Sheet
* GetSheetItem( SCTAB nTab
);
324 typedef ::std::map
<SCTAB
, Sheet
> ProtectedSheetMap
;
325 ProtectedSheetMap maProtectedSheets
;
330 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */