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 #pragma once
21 
22 #include <rangelst.hxx>
23 #include "xistring.hxx"
24 #include "xiroot.hxx"
25 #include <validat.hxx>
26 #include <tabprotection.hxx>
27 
28 #include <map>
29 #include <vector>
30 #include <memory>
31 
32 class ErrCode;
33 struct XclRange;
34 
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 ============================================================================ */
47 
48 // Shared string table ========================================================
49 
55 class XclImpSst : protected XclImpRoot
56 {
57 public:
58  explicit XclImpSst( const XclImpRoot& rRoot );
59 
62  void ReadSst( XclImpStream& rStrm );
63 
65  const XclImpString* GetString( sal_uInt32 nSstIndex ) const;
66 
67 private:
68  typedef ::std::vector< XclImpString > XclImpStringVec;
69  XclImpStringVec maStrings;
70 };
71 
72 // Hyperlinks =================================================================
73 
76 {
77 public:
79  XclImpHyperlink(const XclImpHyperlink&) = delete;
81  const XclImpHyperlink& operator=(const XclImpHyperlink&) = delete;
84  XclImpHyperlink() = delete;
85 
88  static void ReadHlink( XclImpStream& rStrm );
89 
91  static OUString ReadEmbeddedData( XclImpStream& rStrm );
92 
94  static void InsertUrl( XclImpRoot& rRoot, const XclRange& rXclRange, const OUString& rUrl );
95 
98  static void ConvertToValidTabName(OUString& rName);
99 };
100 
101 // Label ranges ===============================================================
102 
105 {
106 public:
108  XclImpLabelranges(const XclImpLabelranges&) = delete;
110  const XclImpLabelranges& operator=(const XclImpLabelranges&) = delete;
113  XclImpLabelranges() = delete;
116  static void ReadLabelranges( XclImpStream& rStrm );
117 };
118 
119 // Conditional formatting =====================================================
120 
122 class XclImpCondFormat : protected XclImpRoot
123 {
124 public:
125  explicit XclImpCondFormat( const XclImpRoot& rRoot, sal_uInt32 nFormatIndex );
126  virtual ~XclImpCondFormat() override;
127 
129  void ReadCondfmt( XclImpStream& rStrm );
131  void ReadCF( XclImpStream& rStrm );
132 
134  void Apply();
135 
136 private:
137  typedef ::std::unique_ptr< ScConditionalFormat > ScCondFmtPtr;
138 
140  ScCondFmtPtr mxScCondFmt;
141  sal_uInt32 mnFormatIndex;
142  sal_uInt16 mnCondCount;
143  sal_uInt16 mnCondIndex;
144 };
145 
148 {
149 public:
150  explicit XclImpCondFormatManager( const XclImpRoot& rRoot );
151 
153  void ReadCondfmt( XclImpStream& rStrm );
155  void ReadCF( XclImpStream& rStrm );
156 
158  void Apply();
159 
160 private:
161  std::vector< std::unique_ptr<XclImpCondFormat> >
163 };
164 
165 // Data Validation ============================================================
166 
169 {
170 public:
171  explicit XclImpValidationManager( const XclImpRoot& rRoot );
172 
174  static void ReadDval( XclImpStream& rStrm );
176  void ReadDV( XclImpStream& rStrm );
177 
178  void Apply();
179 private:
180  struct DVItem
181  {
184 
185  explicit DVItem ( const ScRangeList& rRanges, const ScValidationData& rValidData );
186  };
187 
188  std::vector< std::unique_ptr<DVItem> > maDVItems;
189 };
190 
191 // Web queries ================================================================
192 
195 {
196 public:
197  explicit XclImpWebQuery( const ScRange& rDestRange );
198 
202  void ReadWqstring( XclImpStream& rStrm );
204  void ReadWqsettings( XclImpStream& rStrm );
206  void ReadWqtables( XclImpStream& rStrm );
207 
209  void Apply( ScDocument& rDoc, const OUString& rFilterName );
210 
211 private:
214  {
219  };
220 
221  OUString maURL;
222  OUString maTables;
225  sal_uInt16 mnRefresh;
226 };
227 
229 {
230 public:
231  explicit XclImpWebQueryBuffer( const XclImpRoot& rRoot );
232 
234  void ReadQsi( XclImpStream& rStrm );
236  void ReadParamqry( XclImpStream& rStrm );
238  void ReadWqstring( XclImpStream& rStrm );
240  void ReadWqsettings( XclImpStream& rStrm );
242  void ReadWqtables( XclImpStream& rStrm );
243 
245  void Apply();
246 
247 private:
248  typedef std::vector< XclImpWebQuery > XclImpWebQueryList;
249  XclImpWebQueryList maWQList;
250 };
251 
252 // Decryption =================================================================
253 
256 {
257 public:
259  XclImpDecryptHelper(const XclImpDecryptHelper&) = delete;
261  const XclImpDecryptHelper& operator=(const XclImpDecryptHelper&) = delete;
264  XclImpDecryptHelper() = delete;
265 
268  static const ErrCode& ReadFilepass( XclImpStream& rStrm );
269 };
270 
271 // Document protection ========================================================
272 
274 {
275 public:
276  explicit XclImpDocProtectBuffer( const XclImpRoot& rRoot );
277 
280 
282  void ReadWinProtect( XclImpStream& rStrm );
283 
284  void ReadPasswordHash( XclImpStream& rStrm );
285 
286  void Apply() const;
287 
288 private:
289  sal_uInt16 mnPassHash;
290  bool mbDocProtect:1;
291  bool mbWinProtect:1;
292 };
293 
294 // Sheet protection ===========================================================
295 
297 {
298 public:
299  explicit XclImpSheetProtectBuffer( const XclImpRoot& rRoot );
300 
301  void ReadProtect( XclImpStream& rStrm, SCTAB nTab );
302 
303  void ReadOptions( XclImpStream& rStrm, SCTAB nTab );
304 
305  void AppendEnhancedProtection( const ScEnhancedProtection & rProt, SCTAB nTab );
306 
307  void ReadPasswordHash( XclImpStream& rStrm, SCTAB nTab );
308 
309  void Apply() const;
310 
311 private:
312  struct Sheet
313  {
315  sal_uInt16 mnPasswordHash;
316  sal_uInt16 mnOptions;
317  ::std::vector< ScEnhancedProtection > maEnhancedProtections;
318 
319  Sheet();
320  Sheet(const Sheet& r);
321  };
322 
323  Sheet* GetSheetItem( SCTAB nTab );
324 
325 private:
326  typedef ::std::map<SCTAB, Sheet> ProtectedSheetMap;
327  ProtectedSheetMap maProtectedSheets;
328 };
329 
330 /* 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:213
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:326
XclImpWebQueryMode meMode
Destination range.
Definition: xicontent.hxx:224
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:222
std::vector< std::unique_ptr< DVItem > > maDVItems
Definition: xicontent.hxx:188
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:142
std::vector< XclImpWebQuery > XclImpWebQueryList
Definition: xicontent.hxx:248
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:249
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:141
XclImpSst(const XclImpRoot &rRoot)
Definition: xicontent.cxx:68
sal_uInt16 mnCondIndex
Number of conditions to be inserted.
Definition: xicontent.hxx:143
Imports and collects all conditional formatting of a sheet.
Definition: xicontent.hxx:147
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:139
::std::unique_ptr< ScConditionalFormat > ScCondFmtPtr
Definition: xicontent.hxx:137
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:69
::std::vector< XclImpString > XclImpStringVec
Definition: xicontent.hxx:68
XclImpValidationManager(const XclImpRoot &rRoot)
Definition: xicontent.cxx:734
ProtectedSheetMap maProtectedSheets
Definition: xicontent.hxx:327
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:225
ScCondFmtPtr mxScCondFmt
Destination cell ranges.
Definition: xicontent.hxx:140
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:317
ScRange maDestRange
List of source range names.
Definition: xicontent.hxx:223
std::vector< std::unique_ptr< XclImpCondFormat > > maCondFmtList
Definition: xicontent.hxx:162
Imports validation data.
Definition: xicontent.hxx:168
Stores the data of one web query.
Definition: xicontent.hxx:194
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:221
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:55
Provides static functions to import stream decryption settings.
Definition: xicontent.hxx:255
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:104
This class is used to import record oriented streams.
Definition: xistream.hxx:277
Represents a conditional format with condition formulas, and formatting attributes.
Definition: xicontent.hxx:122
const XclImpLabelranges & operator=(const XclImpLabelranges &)=delete
delete copy-assignment operator
void SvStream & rStrm
Access to global data from other classes.
Definition: xiroot.hxx:125
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:30
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:22
static void ReadLabelranges(XclImpStream &rStrm)
Reads a LABELRANGES record and inserts the label ranges into the document.
Definition: xicontent.cxx:431