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 
189  std::vector< std::unique_ptr<DVItem> > maDVItems;
190 };
191 
192 // Web queries ================================================================
193 
196 {
197 public:
198  explicit XclImpWebQuery( const ScRange& rDestRange );
199 
203  void ReadWqstring( XclImpStream& rStrm );
205  void ReadWqsettings( XclImpStream& rStrm );
207  void ReadWqtables( XclImpStream& rStrm );
208 
210  void Apply( ScDocument& rDoc, const OUString& rFilterName );
211 
212 private:
215  {
220  };
221 
222  OUString maURL;
223  OUString maTables;
226  sal_uInt16 mnRefresh;
227 };
228 
230 {
231 public:
232  explicit XclImpWebQueryBuffer( const XclImpRoot& rRoot );
233 
235  void ReadQsi( XclImpStream& rStrm );
237  void ReadParamqry( XclImpStream& rStrm );
239  void ReadWqstring( XclImpStream& rStrm );
241  void ReadWqsettings( XclImpStream& rStrm );
243  void ReadWqtables( XclImpStream& rStrm );
244 
246  void Apply();
247 
248 private:
249  typedef std::vector< XclImpWebQuery > XclImpWebQueryList;
250  XclImpWebQueryList maWQList;
251 };
252 
253 // Decryption =================================================================
254 
257 {
258 public:
260  XclImpDecryptHelper(const XclImpDecryptHelper&) = delete;
262  const XclImpDecryptHelper& operator=(const XclImpDecryptHelper&) = delete;
265  XclImpDecryptHelper() = delete;
266 
269  static const ErrCode& ReadFilepass( XclImpStream& rStrm );
270 };
271 
272 // Document protection ========================================================
273 
275 {
276 public:
277  explicit XclImpDocProtectBuffer( const XclImpRoot& rRoot );
278 
281 
283  void ReadWinProtect( XclImpStream& rStrm );
284 
285  void ReadPasswordHash( XclImpStream& rStrm );
286 
287  void Apply() const;
288 
289 private:
290  sal_uInt16 mnPassHash;
291  bool mbDocProtect:1;
292  bool mbWinProtect:1;
293 };
294 
295 // Sheet protection ===========================================================
296 
298 {
299 public:
300  explicit XclImpSheetProtectBuffer( const XclImpRoot& rRoot );
301 
302  void ReadProtect( XclImpStream& rStrm, SCTAB nTab );
303 
304  void ReadOptions( XclImpStream& rStrm, SCTAB nTab );
305 
306  void AppendEnhancedProtection( const ScEnhancedProtection & rProt, SCTAB nTab );
307 
308  void ReadPasswordHash( XclImpStream& rStrm, SCTAB nTab );
309 
310  void Apply() const;
311 
312 private:
313  struct Sheet
314  {
316  sal_uInt16 mnPasswordHash;
317  sal_uInt16 mnOptions;
318  ::std::vector< ScEnhancedProtection > maEnhancedProtections;
319 
320  Sheet();
321  Sheet(const Sheet& r);
322  };
323 
324  Sheet* GetSheetItem( SCTAB nTab );
325 
326 private:
327  typedef ::std::map<SCTAB, Sheet> ProtectedSheetMap;
328  ProtectedSheetMap maProtectedSheets;
329 };
330 
331 #endif
332 
333 /* 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:214
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:327
XclImpWebQueryMode meMode
Destination range.
Definition: xicontent.hxx:225
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:223
std::vector< std::unique_ptr< DVItem > > maDVItems
Definition: xicontent.hxx:189
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:249
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:250
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:328
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:226
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:318
ScRange maDestRange
List of source range names.
Definition: xicontent.hxx:224
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:195
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:222
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:256
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