LibreOffice Module sc (master)  1
excrecds.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_EXCRECDS_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_EXCRECDS_HXX
22 
23 #include <rtl/string.hxx>
24 #include <rtl/ustring.hxx>
25 #include <tools/color.hxx>
26 
27 #include "xerecord.hxx"
28 #include "xeroot.hxx"
29 #include "excdefs.hxx"
30 
31 //------------------------------------------------------------------ Forwards -
32 
33 class ScDBData;
34 struct ScQueryEntry;
35 
36 //----------------------------------------------------------- class ExcRecord -
37 
38 class ExcRecord : public XclExpRecord
39 {
40 public:
41  virtual void Save( XclExpStream& rStrm ) override;
42  virtual void SaveXml( XclExpXmlStream& rStrm ) override;
43 
44  virtual sal_uInt16 GetNum() const = 0;
45  virtual std::size_t GetLen() const = 0;
46 
47 protected:
48  virtual void SaveCont( XclExpStream& rStrm );
49 
50 private:
52  virtual void WriteBody( XclExpStream& rStrm ) override;
53 };
54 
55 //--------------------------------------------------------- class ExcEmptyRec -
56 
57 class ExcEmptyRec : public ExcRecord
58 {
59 private:
60 protected:
61 public:
62  virtual void Save( XclExpStream& rStrm ) override;
63  virtual sal_uInt16 GetNum() const override;
64  virtual std::size_t GetLen() const override;
65 };
66 
67 //--------------------------------------------------------- class ExcDummyRec -
68 
69 class ExcDummyRec : public ExcRecord
70 {
71 protected:
72 public:
73  virtual void Save( XclExpStream& rStrm ) override;
74  virtual sal_uInt16 GetNum() const override;
75  virtual const sal_uInt8* GetData() const = 0; // byte data must contain header and body
76 };
77 
78 //------------------------------------------------------- class ExcBoolRecord -
79 // stores bool as 16bit val ( 0x0000 | 0x0001 )
80 
81 class ExcBoolRecord : public ExcRecord
82 {
83 private:
84  virtual void SaveCont( XclExpStream& rStrm ) override;
85 
86 protected:
87  bool bVal;
88 
89  ExcBoolRecord() : bVal( false ) {}
90 
91 public:
92  virtual std::size_t GetLen() const override;
93 };
94 
95 //--------------------------------------------------------- class ExcBof_Base -
96 
97 class ExcBof_Base : public ExcRecord
98 {
99 private:
100 protected:
101  sal_uInt16 nDocType;
102  sal_uInt16 nVers;
103  sal_uInt16 nRupBuild;
104  sal_uInt16 nRupYear;
105 public:
106  ExcBof_Base();
107 };
108 
109 //-------------------------------------------------------------- class ExcBof -
110 // Header Record for WORKSHEETS
111 
112 class ExcBof : public ExcBof_Base
113 {
114 private:
115  virtual void SaveCont( XclExpStream& rStrm ) override;
116 public:
117  ExcBof();
118 
119  virtual sal_uInt16 GetNum() const override;
120  virtual std::size_t GetLen() const override;
121 };
122 
123 //------------------------------------------------------------- class ExcBofW -
124 // Header Record for WORKBOOKS
125 
126 class ExcBofW : public ExcBof_Base
127 {
128 private:
129  virtual void SaveCont( XclExpStream& rStrm ) override;
130 public:
131  ExcBofW();
132 
133  virtual sal_uInt16 GetNum() const override;
134  virtual std::size_t GetLen() const override;
135 };
136 
137 //-------------------------------------------------------------- class ExcEof -
138 
139 class ExcEof : public ExcRecord
140 {
141 private:
142 public:
143  virtual sal_uInt16 GetNum() const override;
144  virtual std::size_t GetLen() const override;
145 };
146 
147 //--------------------------------------------------------- class ExcDummy_00 -
148 // INTERFACEHDR to FNGROUPCOUNT (see excrecds.cxx)
149 
150 class ExcDummy_00 : public ExcDummyRec
151 {
152 private:
153  static const sal_uInt8 pMyData[];
154  static const std::size_t nMyLen;
155 public:
156  virtual std::size_t GetLen() const override;
157  virtual const sal_uInt8* GetData() const override;
158 };
159 
160 // EXC_ID_WINDOWPROTECTION
162 {
163  public:
164  XclExpWindowProtection(bool bValue);
165 
166  virtual void SaveXml( XclExpXmlStream& rStrm ) override;
167 };
168 
169 // EXC_ID_PROTECT Document Protection
171 {
172  public:
173  XclExpProtection(bool bValue);
174 };
175 
177 {
179  public:
180  XclExpSheetProtection(bool bValue, SCTAB nTab);
181  virtual void SaveXml( XclExpXmlStream& rStrm ) override;
182 };
183 
185 {
186 public:
187  XclExpPassHash(const css::uno::Sequence<sal_Int8>& aHash);
188  virtual ~XclExpPassHash() override;
189 
190 private:
191  virtual void WriteBody(XclExpStream& rStrm) override;
192 
193 private:
194  sal_uInt16 mnHash;
195 };
196 
197 //-------------------------------------------------------- class ExcDummy_04x -
198 // PASSWORD to BOOKBOOL (see excrecds.cxx), no 1904
199 
200 class ExcDummy_040 : public ExcDummyRec
201 {
202 private:
203  static const sal_uInt8 pMyData[];
204  static const std::size_t nMyLen;
205 public:
206  virtual std::size_t GetLen() const override;
207  virtual const sal_uInt8* GetData() const override;
208 };
209 
210 class ExcDummy_041 : public ExcDummyRec
211 {
212 private:
213  static const sal_uInt8 pMyData[];
214  static const std::size_t nMyLen;
215 public:
216  virtual std::size_t GetLen() const override;
217  virtual const sal_uInt8* GetData() const override;
218 };
219 
220 //------------------------------------------------------------- class Exc1904 -
221 
222 class Exc1904 : public ExcBoolRecord
223 {
224 public:
225  Exc1904( const ScDocument& rDoc );
226  virtual sal_uInt16 GetNum() const override;
227 
228  virtual void SaveXml( XclExpXmlStream& rStrm ) override;
229 private:
231 };
232 
233 //------------------------------------------------------ class ExcBundlesheet -
234 
236 {
237 protected:
238  sal_uInt64 m_nStrPos;
239  sal_uInt64 m_nOwnPos; // Position after # and Len
240  sal_uInt16 nGrbit;
242 
244 
245 public:
246  ExcBundlesheetBase( const RootData& rRootData, SCTAB nTab );
247 
248  void SetStreamPos(sal_uInt64 const nStrPos) { m_nStrPos = nStrPos; }
249  void UpdateStreamPos( XclExpStream& rStrm );
250 
251  virtual sal_uInt16 GetNum() const override;
252 };
253 
255 {
256 private:
257  OString aName;
258 
259  virtual void SaveCont( XclExpStream& rStrm ) override;
260 
261 public:
262  ExcBundlesheet( const RootData& rRootData, SCTAB nTab );
263  virtual std::size_t GetLen() const override;
264 };
265 
266 //--------------------------------------------------------- class ExcDummy_02 -
267 // sheet dummies: CALCMODE to SETUP
268 
269 class ExcDummy_02a : public ExcDummyRec
270 {
271 private:
272  static const sal_uInt8 pMyData[];
273  static const std::size_t nMyLen;
274 public:
275  virtual std::size_t GetLen() const override;
276  virtual const sal_uInt8* GetData() const override;
277 };
278 
281 {
282 public:
283  explicit XclExpCountry( const XclExpRoot& rRoot );
284 
285 private:
286  sal_uInt16 mnUICountry;
287  sal_uInt16 mnDocCountry;
288 
290  virtual void WriteBody( XclExpStream& rStrm ) override;
291 };
292 
293 // XclExpWsbool ===============================================================
294 
296 {
297 public:
298  explicit XclExpWsbool( bool bFitToPages );
299 };
300 
305 {
306 public:
307  explicit XclExpXmlSheetPr(
308  bool bFitToPages, SCTAB nScTab, const Color& rTabColor, XclExpFilterManager* pManager );
309 
310  virtual void SaveXml( XclExpXmlStream& rStrm ) override;
311 
312 private:
317 };
318 
320 {
321 public:
322  explicit XclExpFiltermode();
323 };
324 
326 {
327 public:
328  explicit XclExpAutofilterinfo( const ScAddress& rStartPos, SCCOL nScCol );
329 
330  const ScAddress& GetStartPos() const { return maStartPos; }
331  SCCOL GetColCount() const { return static_cast< SCCOL >( GetValue() ); }
332 
333 private:
335 };
336 
338 {
339 private:
342  double fVal;
343  std::unique_ptr<XclExpString>
345 
346 protected:
347 public:
350 
351  bool IsEmpty() const { return (nType == EXC_AFTYPE_NOTUSED); }
352  std::size_t GetTextBytes() const;
353 
354  void SetCondition( sal_uInt8 nTp, sal_uInt8 nOp, double fV, const OUString* pT );
355 
356  void Save( XclExpStream& rStrm );
357  void SaveXml( XclExpXmlStream& rStrm );
358  void SaveText( XclExpStream& rStrm );
359 };
360 
361 class XclExpAutofilter : public XclExpRecord, protected XclExpRoot
362 {
363 private:
366  sal_uInt16 nCol;
367  sal_uInt16 nFlags;
369  std::vector<OUString> maMultiValues;
370 
372  sal_uInt8 nOp, double fVal, const OUString* pText,
373  bool bSimple = false );
374 
375  virtual void WriteBody( XclExpStream& rStrm ) override;
376 
377 public:
378  XclExpAutofilter( const XclExpRoot& rRoot, sal_uInt16 nC );
379 
380  sal_uInt16 GetCol() const { return nCol; }
381  bool HasTop10() const { return ::get_flag( nFlags, EXC_AFFLAG_TOP10 ); }
382 
383  bool HasCondition() const;
384  bool AddEntry( const ScQueryEntry& rEntry );
385  void AddMultiValueEntry( const ScQueryEntry& rEntry );
386 
387  virtual void SaveXml( XclExpXmlStream& rStrm ) override;
388 };
389 
391 {
392 public:
397  explicit ExcAutoFilterRecs( const XclExpRoot& rRoot, SCTAB nTab, const ScDBData* pDefinedData );
398  virtual ~ExcAutoFilterRecs() override;
399 
400  void AddObjRecs();
401 
402  virtual void Save( XclExpStream& rStrm ) override;
403  virtual void SaveXml( XclExpXmlStream& rStrm ) override;
404 
405  bool HasFilterMode() const;
406 
407 private:
408  XclExpAutofilter* GetByCol( SCCOL nCol ); // always 0-based
409  bool IsFiltered( SCCOL nCol );
410 
411 private:
414 
415  XclExpAutofilterList maFilterList;
420 
421  ScRange maSortRef; // sort area without headers
422  std::vector< std::tuple<ScRange, OUString, bool> > maSortCustomList; // sorted column with list of sorted items
423 };
424 
427 {
428 public:
429  explicit XclExpFilterManager( const XclExpRoot& rRoot );
430 
434  void InitTabFilter( SCTAB nScTab );
435 
438 
440  bool HasFilterMode( SCTAB nScTab );
441 
442 private:
444 
446  typedef ::std::map< SCTAB, XclExpTabFilterRef > XclExpTabFilterMap;
447 
448  XclExpTabFilterMap maFilterMap;
449 };
450 
451 #endif
452 
453 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt16 nRupBuild
Definition: excrecds.hxx:103
XclExpWindowProtection(bool bValue)
Definition: excrecds.cxx:401
virtual void SaveCont(XclExpStream &rStrm)
Definition: excrecds.cxx:95
XclExpRecordList< XclExpAutofilter > XclExpAutofilterList
Definition: excrecds.hxx:412
bool AddEntry(const ScQueryEntry &rEntry)
Definition: excrecds.cxx:651
sal_uInt16 nGrbit
Definition: excrecds.hxx:240
bool IsFiltered(SCCOL nCol)
Definition: excrecds.cxx:1008
ExcBof()
Definition: excrecds.cxx:160
XclExpXmlSheetPr(bool bFitToPages, SCTAB nScTab, const Color &rTabColor, XclExpFilterManager *pManager)
Definition: excrecds.cxx:367
virtual const sal_uInt8 * GetData() const override
Definition: excrecds.cxx:223
virtual const sal_uInt8 * GetData() const =0
static const sal_uInt8 pMyData[]
Definition: excrecds.hxx:203
void InitTabFilter(SCTAB nScTab)
Creates the filter records for the specified sheet.
Definition: excrecds.cxx:1085
This class is used to export Excel record streams.
Definition: xestream.hxx:71
std::unique_ptr< XclExpString > pText
Definition: excrecds.hxx:344
static const sal_uInt8 pMyData[]
Definition: excrecds.hxx:153
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: excrecds.cxx:406
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: excrecds.cxx:1039
virtual sal_uInt16 GetNum() const override
Definition: excrecds.cxx:171
XclExpWsbool(bool bFitToPages)
Definition: excrecds.cxx:360
const Type & GetValue() const
Returns the value of the record.
Definition: xerecord.hxx:209
bool AddCondition(ScQueryConnect eConn, sal_uInt8 nType, sal_uInt8 nOp, double fVal, const OUString *pText, bool bSimple=false)
Definition: excrecds.cxx:626
static const std::size_t nMyLen
Definition: excrecds.hxx:204
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: excrecds.cxx:104
This record contains the Windows country IDs for the UI and document language.
Definition: excrecds.hxx:280
XclExpPassHash(const css::uno::Sequence< sal_Int8 > &aHash)
Definition: excrecds.cxx:496
ExcFilterCondition aCond[2]
Definition: excrecds.hxx:368
sal_uInt16 GetCol() const
Definition: excrecds.hxx:380
static const std::size_t nMyLen
Definition: excrecds.hxx:154
void SetCondition(sal_uInt8 nTp, sal_uInt8 nOp, double fV, const OUString *pT)
Definition: excrecds.cxx:543
static const sal_uInt8 pMyData[]
Definition: excrecds.hxx:213
virtual const sal_uInt8 * GetData() const override
Definition: excrecds.cxx:338
XclExpAutofilterList::RecordRefType XclExpAutofilterRef
Definition: excrecds.hxx:413
ScAddress maStartPos
Definition: excrecds.hxx:334
rtl::Reference< XclExpFiltermode > m_pFilterMode
Definition: excrecds.hxx:416
virtual void SaveCont(XclExpStream &rStrm) override
Definition: excrecds.cxx:189
sal_uInt16 nRupYear
Definition: excrecds.hxx:104
std::vector< OUString > maMultiValues
Definition: excrecds.hxx:369
Save sheetPr element and its children for xlsx export.
Definition: excrecds.hxx:304
void AddMultiValueEntry(const ScQueryEntry &rEntry)
Definition: excrecds.cxx:779
void SaveXml(XclExpXmlStream &rStrm)
Definition: excrecds.cxx:597
const ScAddress & GetStartPos() const
Definition: excrecds.hxx:330
virtual ~ExcAutoFilterRecs() override
Definition: excrecds.cxx:990
virtual void WriteBody(XclExpStream &rStrm) override
Writes the body of the record (without record header).
Definition: excrecds.cxx:787
static const sal_uInt8 pMyData[]
Definition: excrecds.hxx:272
static const std::size_t nMyLen
Definition: excrecds.hxx:273
Access to global data from other classes.
Definition: xeroot.hxx:113
virtual void Save(XclExpStream &rStrm) override
Overwrite this method to do any operation while saving the record.
Definition: excrecds.cxx:1030
SCCOL GetColCount() const
Definition: excrecds.hxx:331
OString aName
Definition: excrecds.hxx:257
void Save(XclExpStream &rStrm)
Definition: excrecds.cxx:551
sal_uInt16 nDocType
Definition: excrecds.hxx:101
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: excrecds.cxx:264
XclExpAutofilter(const XclExpRoot &rRoot, sal_uInt16 nC)
Definition: excrecds.cxx:617
XclExpAutofilterinfo(const ScAddress &rStartPos, SCCOL nScCol)
Definition: excrecds.cxx:521
Base class for all Excel records.
Definition: xerecord.hxx:39
virtual std::size_t GetLen() const override
Definition: excrecds.cxx:218
const sal_uInt16 EXC_AFFLAG_TOP10
Definition: excdefs.hxx:33
XclExpTabFilterMap maFilterMap
Definition: excrecds.hxx:448
virtual std::size_t GetLen() const =0
bool HasFilterMode(SCTAB nScTab)
Returns whether or not FilterMode is present.
Definition: excrecds.cxx:1102
virtual ~XclExpPassHash() override
Definition: excrecds.cxx:507
virtual std::size_t GetLen() const override
Definition: excrecds.cxx:240
bool bDateCompatibility
Definition: excrecds.hxx:230
virtual sal_uInt16 GetNum() const override
Definition: excrecds.cxx:194
virtual const sal_uInt8 * GetData() const override
Definition: excrecds.cxx:245
virtual std::size_t GetLen() const override
Definition: excrecds.cxx:143
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: excrecds.cxx:796
std::vector< std::tuple< ScRange, OUString, bool > > maSortCustomList
Definition: excrecds.hxx:422
virtual void Save(XclExpStream &rStrm) override
Writes the record header and calls WriteBody().
Definition: excrecds.cxx:110
A record with a single value of type Type.
Definition: xerecord.hxx:199
XclExpProtection(bool bValue)
Definition: excrecds.cxx:413
virtual void SaveCont(XclExpStream &rStrm) override
Definition: excrecds.cxx:318
Exc1904(const ScDocument &rDoc)
Definition: excrecds.cxx:252
virtual void SaveCont(XclExpStream &rStrm) override
Definition: excrecds.cxx:138
virtual void WriteBody(XclExpStream &rStrm) override
The document country ID.
Definition: excrecds.cxx:353
sal_uInt16 nFlags
Definition: excrecds.hxx:367
sal_uInt16 nVers
Definition: excrecds.hxx:102
sal_Int16 SCCOL
Definition: types.hxx:22
bool HasCondition() const
Definition: excrecds.cxx:646
sal_uInt16 mnHash
Definition: excrecds.hxx:194
virtual std::size_t GetLen() const override
Definition: excrecds.cxx:326
bool get_flag(Type nBitField, Type nMask)
Returns true, if at least one of the bits set in nMask is set in nBitField.
Definition: ftools.hxx:73
virtual void WriteBody(XclExpStream &rStrm) override
Writes the body of the record.
Definition: excrecds.cxx:99
::std::map< SCTAB, XclExpTabFilterRef > XclExpTabFilterMap
Definition: excrecds.hxx:446
void SaveText(XclExpStream &rStrm)
Definition: excrecds.cxx:607
XclExpRecordRef CreateRecord(sal_uInt16 nRecId) const
Returns the reference to a record (or record list) representing a root object.
Definition: xeroot.cxx:280
bool HasFilterMode() const
Definition: excrecds.cxx:1075
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: excrecds.cxx:424
sal_uInt64 m_nStrPos
Definition: excrecds.hxx:238
bool HasTop10() const
Definition: excrecds.hxx:381
rtl::Reference< ExcAutoFilterRecs > XclExpTabFilterRef
Definition: excrecds.hxx:445
virtual sal_uInt16 GetNum() const override
Definition: excrecds.cxx:131
XclExpCountry(const XclExpRoot &rRoot)
Definition: excrecds.cxx:344
virtual std::size_t GetLen() const override
Definition: excrecds.cxx:119
virtual std::size_t GetLen() const override
Definition: excrecds.cxx:176
virtual std::size_t GetLen() const override
Definition: excrecds.cxx:333
virtual void Save(XclExpStream &rStrm) override
Writes the record header and calls WriteBody().
Definition: excrecds.cxx:89
bool IsEmpty() const
Definition: excrecds.hxx:351
virtual void SaveCont(XclExpStream &rStrm) override
Definition: excrecds.cxx:166
static const std::size_t nMyLen
Definition: excrecds.hxx:214
void UpdateStreamPos(XclExpStream &rStrm)
Definition: excrecds.cxx:297
virtual std::size_t GetLen() const override
Definition: excrecds.cxx:230
virtual sal_uInt16 GetNum() const override
Definition: excrecds.cxx:114
unsigned char sal_uInt8
virtual void Save(XclExpStream &rStrm) override
Writes the record header and calls WriteBody().
Definition: excrecds.cxx:126
A record without body.
Definition: xerecord.hxx:184
virtual std::size_t GetLen() const override
Definition: excrecds.cxx:211
Sheet filter manager.
Definition: excrecds.hxx:426
virtual std::size_t GetLen() const override
Definition: excrecds.cxx:199
XclExpAutofilterList maFilterList
Definition: excrecds.hxx:415
std::size_t GetTextBytes() const
Definition: excrecds.cxx:538
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:401
virtual void WriteBody(XclExpStream &rStrm) override
Writes the body of the record (without record header).
Definition: excrecds.cxx:511
XclExpFilterManager(const XclExpRoot &rRoot)
Definition: excrecds.cxx:1080
virtual sal_uInt16 GetNum() const override
Definition: excrecds.cxx:305
ExcBundlesheet(const RootData &rRootData, SCTAB nTab)
Definition: excrecds.cxx:310
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: excrecds.cxx:370
virtual const sal_uInt8 * GetData() const override
Definition: excrecds.cxx:235
XclExpRecordRef CreateRecord(SCTAB nScTab)
Returns a record object containing all filter records for the specified sheet.
Definition: excrecds.cxx:1090
XclExpAutofilter * GetByCol(SCCOL nCol)
Definition: excrecds.cxx:994
virtual sal_uInt16 GetNum() const override
Definition: excrecds.cxx:206
virtual sal_uInt16 GetNum() const override
Definition: excrecds.cxx:259
XclExpSheetProtection(bool bValue, SCTAB nTab)
Definition: excrecds.cxx:418
sal_uInt16 mnUICountry
Definition: excrecds.hxx:286
sal_uInt16 mnDocCountry
The UI country ID.
Definition: excrecds.hxx:287
void SvStream & rStrm
void SetStreamPos(sal_uInt64 const nStrPos)
Definition: excrecds.hxx:248
ExcAutoFilterRecs(const XclExpRoot &rRoot, SCTAB nTab, const ScDBData *pDefinedData)
Definition: excrecds.cxx:853
FilterType meType
Definition: excrecds.hxx:365
sal_uInt64 m_nOwnPos
Definition: excrecds.hxx:239
Each instance of this struct represents a single filtering criteria.
Definition: queryentry.hxx:33
virtual sal_uInt16 GetNum() const =0
Base class for single records with any content.
Definition: xerecord.hxx:143
sal_Int16 SCTAB
Definition: types.hxx:23
Record which contains a Boolean value.
Definition: xerecord.hxx:255
rtl::Reference< XclExpAutofilterinfo > m_pFilterInfo
Definition: excrecds.hxx:417
sal_uInt16 nCol
Definition: excrecds.hxx:366
ScQueryConnect
Definition: global.hxx:838
const sal_uInt8 EXC_AFTYPE_NOTUSED
Definition: excdefs.hxx:38
XclExpFilterManager * mpManager
Definition: excrecds.hxx:314