LibreOffice Module sc (master)  1
xicontent.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_SC_SOURCE_FILTER_INC_XICONTENT_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_XICONTENT_HXX
22 
23 #include <rangelst.hxx>
24 #include "xistring.hxx"
25 #include "xiroot.hxx"
26 #include <validat.hxx>
27 #include <tabprotection.hxx>
28 
29 #include <map>
30 #include <vector>
31 #include <memory>
32 
33 class ErrCode;
34 struct XclRange;
35 
36 /* ============================================================================
37 Classes to import the big Excel document contents (related to several cells or
38 globals for the document).
39 - Shared
40  tables
41 - Hyperlinks
42 - Label ranges
43 - Conditional formatting
44 - Data validation
45 - Web queries
46 - Stream decryption
47 ============================================================================ */
48 
49 // Shared string table ========================================================
50 
56 class XclImpSst : protected XclImpRoot
57 {
58 public:
59  explicit XclImpSst( const XclImpRoot& rRoot );
60 
63  void ReadSst( XclImpStream& rStrm );
64 
66  const XclImpString* GetString( sal_uInt32 nSstIndex ) const;
67 
68 private:
69  typedef ::std::vector< XclImpString > XclImpStringVec;
70  XclImpStringVec maStrings;
71 };
72 
73 // Hyperlinks =================================================================
74 
77 {
78 public:
80  XclImpHyperlink(const XclImpHyperlink&) = delete;
82  const XclImpHyperlink& operator=(const XclImpHyperlink&) = delete;
85  XclImpHyperlink() = delete;
86 
89  static void ReadHlink( XclImpStream& rStrm );
90 
92  static OUString ReadEmbeddedData( XclImpStream& rStrm );
93 
95  static void InsertUrl( XclImpRoot& rRoot, const XclRange& rXclRange, const OUString& rUrl );
96 
99  static void ConvertToValidTabName(OUString& rName);
100 };
101 
102 // Label ranges ===============================================================
103 
106 {
107 public:
109  XclImpLabelranges(const XclImpLabelranges&) = delete;
111  const XclImpLabelranges& operator=(const XclImpLabelranges&) = delete;
114  XclImpLabelranges() = delete;
117  static void ReadLabelranges( XclImpStream& rStrm );
118 };
119 
120 // Conditional formatting =====================================================
121 
123 class XclImpCondFormat : protected XclImpRoot
124 {
125 public:
126  explicit XclImpCondFormat( const XclImpRoot& rRoot, sal_uInt32 nFormatIndex );
127  virtual ~XclImpCondFormat() override;
128 
130  void ReadCondfmt( XclImpStream& rStrm );
132  void ReadCF( XclImpStream& rStrm );
133 
135  void Apply();
136 
137 private:
138  typedef ::std::unique_ptr< ScConditionalFormat > ScCondFmtPtr;
139 
141  ScCondFmtPtr mxScCondFmt;
142  sal_uInt32 mnFormatIndex;
143  sal_uInt16 mnCondCount;
144  sal_uInt16 mnCondIndex;
145 };
146 
149 {
150 public:
151  explicit XclImpCondFormatManager( const XclImpRoot& rRoot );
152 
154  void ReadCondfmt( XclImpStream& rStrm );
156  void ReadCF( XclImpStream& rStrm );
157 
159  void Apply();
160 
161 private:
162  std::vector< std::unique_ptr<XclImpCondFormat> >
164 };
165 
166 // Data Validation ============================================================
167 
170 {
171 public:
172  explicit XclImpValidationManager( const XclImpRoot& rRoot );
173 
175  static void ReadDval( XclImpStream& rStrm );
177  void ReadDV( XclImpStream& rStrm );
178 
179  void Apply();
180 private:
181  struct DVItem
182  {
185 
186  explicit DVItem ( const ScRangeList& rRanges, const ScValidationData& rValidData );
187  };
188  typedef std::vector< std::unique_ptr<DVItem> > DVItemList;
189 
190  DVItemList maDVItems;
191 };
192 
193 // Web queries ================================================================
194 
197 {
198 public:
199  explicit XclImpWebQuery( const ScRange& rDestRange );
200 
204  void ReadWqstring( XclImpStream& rStrm );
206  void ReadWqsettings( XclImpStream& rStrm );
208  void ReadWqtables( XclImpStream& rStrm );
209 
211  void Apply( ScDocument& rDoc, const OUString& rFilterName );
212 
213 private:
216  {
221  };
222 
223  OUString maURL;
224  OUString maTables;
227  sal_uInt16 mnRefresh;
228 };
229 
231 {
232 public:
233  explicit XclImpWebQueryBuffer( const XclImpRoot& rRoot );
234 
236  void ReadQsi( XclImpStream& rStrm );
238  void ReadParamqry( XclImpStream& rStrm );
240  void ReadWqstring( XclImpStream& rStrm );
242  void ReadWqsettings( XclImpStream& rStrm );
244  void ReadWqtables( XclImpStream& rStrm );
245 
247  void Apply();
248 
249 private:
250  typedef std::vector< XclImpWebQuery > XclImpWebQueryList;
251  XclImpWebQueryList maWQList;
252 };
253 
254 // Decryption =================================================================
255 
258 {
259 public:
261  XclImpDecryptHelper(const XclImpDecryptHelper&) = delete;
263  const XclImpDecryptHelper& operator=(const XclImpDecryptHelper&) = delete;
266  XclImpDecryptHelper() = delete;
267 
270  static const ErrCode& ReadFilepass( XclImpStream& rStrm );
271 };
272 
273 // Document protection ========================================================
274 
276 {
277 public:
278  explicit XclImpDocProtectBuffer( const XclImpRoot& rRoot );
279 
282 
284  void ReadWinProtect( XclImpStream& rStrm );
285 
286  void ReadPasswordHash( XclImpStream& rStrm );
287 
288  void Apply() const;
289 
290 private:
291  sal_uInt16 mnPassHash;
292  bool mbDocProtect:1;
293  bool mbWinProtect:1;
294 };
295 
296 // Sheet protection ===========================================================
297 
299 {
300 public:
301  explicit XclImpSheetProtectBuffer( const XclImpRoot& rRoot );
302 
303  void ReadProtect( XclImpStream& rStrm, SCTAB nTab );
304 
305  void ReadOptions( XclImpStream& rStrm, SCTAB nTab );
306 
307  void AppendEnhancedProtection( const ScEnhancedProtection & rProt, SCTAB nTab );
308 
309  void ReadPasswordHash( XclImpStream& rStrm, SCTAB nTab );
310 
311  void Apply() const;
312 
313 private:
314  struct Sheet
315  {
317  sal_uInt16 mnPasswordHash;
318  sal_uInt16 mnOptions;
319  ::std::vector< ScEnhancedProtection > maEnhancedProtections;
320 
321  Sheet();
322  Sheet(const Sheet& r);
323  };
324 
325  Sheet* GetSheetItem( SCTAB nTab );
326 
327 private:
328  typedef ::std::map<SCTAB, Sheet> ProtectedSheetMap;
329  ProtectedSheetMap maProtectedSheets;
330 };
331 
332 #endif
333 
334 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
XclImpWebQueryBuffer(const XclImpRoot &rRoot)
Definition: xicontent.cxx:1025
void ReadDV(XclImpStream &rStrm)
Reads a DV record and inserts validation data into the document.
Definition: xicontent.cxx:754
void ReadParamqry(XclImpStream &rStrm)
Reads a PARAMQRY record and sets data to the web query.
Definition: xicontent.cxx:953
void ReadWqstring(XclImpStream &rStrm)
Reads a WQSTRING record and sets URL.
Definition: xicontent.cxx:972
XclImpWebQueryMode
Specifies the type of the web query (which ranges are imported).
Definition: xicontent.hxx:215
void ReadProtect(XclImpStream &rStrm, SCTAB nTab)
Definition: xicontent.cxx:1327
void ReadQsi(XclImpStream &rStrm)
Reads the QSI record and creates a new web query in the buffer.
Definition: xicontent.cxx:1030
::std::map< SCTAB, Sheet > ProtectedSheetMap
Definition: xicontent.hxx:328
XclImpWebQueryMode meMode
Destination range.
Definition: xicontent.hxx:226
void ReadCondfmt(XclImpStream &rStrm)
Reads a CONDFMT record and starts a new conditional format to be filled from CF records.
Definition: xicontent.cxx:708
OUString maTables
Source document URL.
Definition: xicontent.hxx:224
XclImpCondFormat(const XclImpRoot &rRoot, sal_uInt32 nFormatIndex)
Definition: xicontent.cxx:490
void ReadCondfmt(XclImpStream &rStrm)
Reads a CONDFMT record and initializes this conditional format.
Definition: xicontent.cxx:502
sal_uInt16 mnCondCount
Index of this conditional format in list.
Definition: xicontent.hxx:143
std::vector< XclImpWebQuery > XclImpWebQueryList
Definition: xicontent.hxx:250
const XclImpString * GetString(sal_uInt32 nSstIndex) const
Returns a pointer to the string with the passed index.
Definition: xicontent.cxx:94
const XclImpDecryptHelper & operator=(const XclImpDecryptHelper &)=delete
delete copy-assignment operator
XclImpDocProtectBuffer(const XclImpRoot &rRoot)
Definition: xicontent.cxx:1258
XclImpWebQueryList maWQList
Definition: xicontent.hxx:251
void ReadWinProtect(XclImpStream &rStrm)
document windows properties protection flag
Definition: xicontent.cxx:1271
DVItem(const ScRangeList &rRanges, const ScValidationData &rValidData)
Definition: xicontent.cxx:731
XclImpSheetProtectBuffer(const XclImpRoot &rRoot)
Definition: xicontent.cxx:1322
void ReadWqtables(XclImpStream &rStrm)
Reads a WEBQRYTABLES record and sets source range list.
Definition: xicontent.cxx:988
sal_uInt32 mnFormatIndex
Calc conditional format.
Definition: xicontent.hxx:142
XclImpSst(const XclImpRoot &rRoot)
Definition: xicontent.cxx:68
sal_uInt16 mnCondIndex
Number of conditions to be inserted.
Definition: xicontent.hxx:144
Imports and collects all conditional formatting of a sheet.
Definition: xicontent.hxx:148
void ReadWqtables(XclImpStream &rStrm)
Reads a WEBQRYTABLES record and sets source range list to the current web query.
Definition: xicontent.cxx:1075
ScRangeList maRanges
Definition: xicontent.hxx:140
::std::unique_ptr< ScConditionalFormat > ScCondFmtPtr
Definition: xicontent.hxx:138
void ReadWqsettings(XclImpStream &rStrm)
Reads a WEBQRYSETTINGS record and sets refresh rate to the current web query.
Definition: xicontent.cxx:1069
Sheet * GetSheetItem(SCTAB nTab)
Definition: xicontent.cxx:1416
void ReadPasswordHash(XclImpStream &rStrm)
Definition: xicontent.cxx:1276
static const ErrCode & ReadFilepass(XclImpStream &rStrm)
Reads the FILEPASS record, queries a password and sets decryption algorithm.
Definition: xicontent.cxx:1229
XclImpStringVec maStrings
Definition: xicontent.hxx:70
::std::vector< XclImpString > XclImpStringVec
Definition: xicontent.hxx:69
XclImpValidationManager(const XclImpRoot &rRoot)
Definition: xicontent.cxx:734
ProtectedSheetMap maProtectedSheets
Definition: xicontent.hxx:329
std::vector< std::unique_ptr< DVItem > > DVItemList
Definition: xicontent.hxx:188
void ReadSst(XclImpStream &rStrm)
Reads the entire SST record.
Definition: xicontent.cxx:73
sal_uInt16 mnRefresh
Current mode of the web query.
Definition: xicontent.hxx:227
ScCondFmtPtr mxScCondFmt
Destination cell ranges.
Definition: xicontent.hxx:141
XclImpCondFormatManager(const XclImpRoot &rRoot)
Definition: xicontent.cxx:703
static void ReadDval(XclImpStream &rStrm)
Reads a DVAL record and sets marks the dropdown arrow control to be ignored.
Definition: xicontent.cxx:739
Container for the Excel EnhancedProtection feature.
void ReadCF(XclImpStream &rStrm)
Reads a CF record and inserts the formatting data to the current conditional format.
Definition: xicontent.cxx:715
void ReadWqstring(XclImpStream &rStrm)
Reads a WQSTRING record and sets URL to the current web query.
Definition: xicontent.cxx:1063
void ReadDocProtect(XclImpStream &rStrm)
document structure protection flag
Definition: xicontent.cxx:1266
XclImpWebQuery(const ScRange &rDestRange)
Definition: xicontent.cxx:946
::std::vector< ScEnhancedProtection > maEnhancedProtections
Definition: xicontent.hxx:319
ScRange maDestRange
List of source range names.
Definition: xicontent.hxx:225
std::vector< std::unique_ptr< XclImpCondFormat > > maCondFmtList
Definition: xicontent.hxx:163
Imports validation data.
Definition: xicontent.hxx:169
Stores the data of one web query.
Definition: xicontent.hxx:196
void ReadPasswordHash(XclImpStream &rStrm, SCTAB nTab)
Definition: xicontent.cxx:1363
void Apply()
Inserts the conditional formatting into the document.
Definition: xicontent.cxx:722
void AppendEnhancedProtection(const ScEnhancedProtection &rProt, SCTAB nTab)
Definition: xicontent.cxx:1356
virtual ~XclImpCondFormat() override
Definition: xicontent.cxx:498
XclImpDecryptHelper()=delete
We don't want anybody to instantiate this class, since it is just a collection of static methods...
void ReadCF(XclImpStream &rStrm)
Reads a CF record and adds a new condition and the formatting attributes.
Definition: xicontent.cxx:512
void ReadWqsettings(XclImpStream &rStrm)
Reads a WEBQRYSETTINGS record and sets refresh rate.
Definition: xicontent.cxx:977
OUString maURL
Definition: xicontent.hxx:223
XclImpLabelranges()=delete
We don't want anybody to instantiate this class, since it is just a collection of static methods...
The SST (shared string table) contains all strings used in a BIFF8 file.
Definition: xicontent.hxx:56
Provides static functions to import stream decryption settings.
Definition: xicontent.hxx:257
void Apply(ScDocument &rDoc, const OUString &rFilterName)
Inserts the web query into the document.
Definition: xicontent.cxx:1014
Provides importing label ranges and inserting them into a document.
Definition: xicontent.hxx:105
This class is used to import record oriented streams.
Definition: xistream.hxx:278
Represents a conditional format with condition formulas, and formatting attributes.
Definition: xicontent.hxx:123
const XclImpLabelranges & operator=(const XclImpLabelranges &)=delete
delete copy-assignment operator
void SvStream & rStrm
Access to global data from other classes.
Definition: xiroot.hxx:126
void Apply()
Inserts this conditional format into the document.
Definition: xicontent.cxx:690
This class represents an unformatted or formatted string and provides importing from stream...
Definition: xistring.hxx:31
void Apply()
Inserts all web queries into the document.
Definition: xicontent.cxx:1081
void ReadParamqry(XclImpStream &rStrm)
Reads a PARAMQRY record and sets data to the current web query.
Definition: xicontent.cxx:1057
void ReadOptions(XclImpStream &rStrm, SCTAB nTab)
Definition: xicontent.cxx:1337
A 2D cell range address struct with Excel column and row indexes.
Definition: xladdress.hxx:58
sal_Int16 SCTAB
Definition: types.hxx:23
static void ReadLabelranges(XclImpStream &rStrm)
Reads a LABELRANGES record and inserts the label ranges into the document.
Definition: xicontent.cxx:431