fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / filter / inc / xicontent.hxx
blob181a199745eb476750181853ddfe255a5c93ba15
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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
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 #include "tabprotection.hxx"
31 #include <map>
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).
38 - Shared
39 tables
40 - Hyperlinks
41 - Label ranges
42 - Conditional formatting
43 - Data validation
44 - Web queries
45 - Stream decryption
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
57 public:
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;
67 private:
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
77 public:
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);
92 private:
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
95 is made private */
96 XclImpHyperlink();
99 // Label ranges ===============================================================
101 /** Provides importing label ranges and inserting them into a document. */
102 class XclImpLabelranges : private boost::noncopyable
104 public:
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 );
109 private:
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
112 is made private */
113 XclImpLabelranges();
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::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
148 public:
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. */
157 void Apply();
159 private:
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
169 public:
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 );
177 void Apply();
178 private:
179 struct DVItem
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
196 public:
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 );
211 private:
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
230 public:
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. */
245 void Apply();
247 private:
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
257 public:
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 );
262 private:
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
265 is made private */
266 XclImpDecryptHelper();
269 // Document protection ========================================================
271 class XclImpDocProtectBuffer : protected XclImpRoot
273 public:
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 );
284 void Apply() const;
286 private:
287 sal_uInt16 mnPassHash;
288 bool mbDocProtect:1;
289 bool mbWinProtect:1;
292 // Sheet protection ===========================================================
294 class XclImpSheetProtectBuffer : protected XclImpRoot
296 public:
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 );
307 void Apply() const;
309 private:
310 struct Sheet
312 bool mbProtected;
313 sal_uInt16 mnPasswordHash;
314 sal_uInt16 mnOptions;
315 ::std::vector< ScEnhancedProtection > maEnhancedProtections;
317 Sheet();
318 Sheet(const Sheet& r);
321 Sheet* GetSheetItem( SCTAB nTab );
323 private:
324 typedef ::std::map<SCTAB, Sheet> ProtectedSheetMap;
325 ProtectedSheetMap maProtectedSheets;
328 #endif
330 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */