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 #pragma once
21 
22 #include <rtl/string.hxx>
23 #include <rtl/ustring.hxx>
24 #include <tools/color.hxx>
25 
26 #include "xerecord.hxx"
27 #include "xeroot.hxx"
28 #include "excdefs.hxx"
29 
30 //------------------------------------------------------------------ Forwards -
31 
32 class ScDBData;
33 struct ScQueryEntry;
34 
35 //----------------------------------------------------------- class ExcRecord -
36 
37 class ExcRecord : public XclExpRecord
38 {
39 public:
40  virtual void Save( XclExpStream& rStrm ) override;
41  virtual void SaveXml( XclExpXmlStream& rStrm ) override;
42 
43  virtual sal_uInt16 GetNum() const = 0;
44  virtual std::size_t GetLen() const = 0;
45 
46 protected:
47  virtual void SaveCont( XclExpStream& rStrm );
48 
49 private:
51  virtual void WriteBody( XclExpStream& rStrm ) override;
52 };
53 
54 //--------------------------------------------------------- class ExcEmptyRec -
55 
56 class ExcEmptyRec : public ExcRecord
57 {
58 private:
59 protected:
60 public:
61  virtual void Save( XclExpStream& rStrm ) override;
62  virtual sal_uInt16 GetNum() const override;
63  virtual std::size_t GetLen() const override;
64 };
65 
66 //--------------------------------------------------------- class ExcDummyRec -
67 
68 class ExcDummyRec : public ExcRecord
69 {
70 protected:
71 public:
72  virtual void Save( XclExpStream& rStrm ) override;
73  virtual sal_uInt16 GetNum() const override;
74  virtual const sal_uInt8* GetData() const = 0; // byte data must contain header and body
75 };
76 
77 //------------------------------------------------------- class ExcBoolRecord -
78 // stores bool as 16bit val ( 0x0000 | 0x0001 )
79 
80 class ExcBoolRecord : public ExcRecord
81 {
82 private:
83  virtual void SaveCont( XclExpStream& rStrm ) override;
84 
85 protected:
86  bool bVal;
87 
88  ExcBoolRecord() : bVal( false ) {}
89 
90 public:
91  virtual std::size_t GetLen() const override;
92 };
93 
94 //--------------------------------------------------------- class ExcBof_Base -
95 
96 class ExcBof_Base : public ExcRecord
97 {
98 private:
99 protected:
100  sal_uInt16 nDocType;
101  sal_uInt16 nVers;
102  sal_uInt16 nRupBuild;
103  sal_uInt16 nRupYear;
104 public:
105  ExcBof_Base();
106 };
107 
108 //-------------------------------------------------------------- class ExcBof -
109 // Header Record for WORKSHEETS
110 
111 class ExcBof : public ExcBof_Base
112 {
113 private:
114  virtual void SaveCont( XclExpStream& rStrm ) override;
115 public:
116  ExcBof();
117 
118  virtual sal_uInt16 GetNum() const override;
119  virtual std::size_t GetLen() const override;
120 };
121 
122 //------------------------------------------------------------- class ExcBofW -
123 // Header Record for WORKBOOKS
124 
125 class ExcBofW : public ExcBof_Base
126 {
127 private:
128  virtual void SaveCont( XclExpStream& rStrm ) override;
129 public:
130  ExcBofW();
131 
132  virtual sal_uInt16 GetNum() const override;
133  virtual std::size_t GetLen() const override;
134 };
135 
136 //-------------------------------------------------------------- class ExcEof -
137 
138 class ExcEof : public ExcRecord
139 {
140 private:
141 public:
142  virtual sal_uInt16 GetNum() const override;
143  virtual std::size_t GetLen() const override;
144 };
145 
146 //--------------------------------------------------------- class ExcDummy_00 -
147 // INTERFACEHDR to FNGROUPCOUNT (see excrecds.cxx)
148 
149 class ExcDummy_00 : public ExcDummyRec
150 {
151 private:
152  static const sal_uInt8 pMyData[];
153  static const std::size_t nMyLen;
154 public:
155  virtual std::size_t GetLen() const override;
156  virtual const sal_uInt8* GetData() const override;
157 };
158 
159 // EXC_ID_WINDOWPROTECTION
161 {
162  public:
163  XclExpWindowProtection(bool bValue);
164 
165  virtual void SaveXml( XclExpXmlStream& rStrm ) override;
166 };
167 
168 // EXC_ID_PROTECT Document Protection
170 {
171  public:
172  XclExpProtection(bool bValue);
173 };
174 
176 {
178  public:
179  XclExpSheetProtection(bool bValue, SCTAB nTab);
180  virtual void SaveXml( XclExpXmlStream& rStrm ) override;
181 };
182 
184 {
185 public:
186  XclExpPassHash(const css::uno::Sequence<sal_Int8>& aHash);
187  virtual ~XclExpPassHash() override;
188 
189 private:
190  virtual void WriteBody(XclExpStream& rStrm) override;
191 
192 private:
193  sal_uInt16 mnHash;
194 };
195 
196 //-------------------------------------------------------- class ExcDummy_04x -
197 // PASSWORD to BOOKBOOL (see excrecds.cxx), no 1904
198 
199 class ExcDummy_040 : public ExcDummyRec
200 {
201 private:
202  static const sal_uInt8 pMyData[];
203  static const std::size_t nMyLen;
204 public:
205  virtual std::size_t GetLen() const override;
206  virtual const sal_uInt8* GetData() const override;
207 };
208 
209 class ExcDummy_041 : public ExcDummyRec
210 {
211 private:
212  static const sal_uInt8 pMyData[];
213  static const std::size_t nMyLen;
214 public:
215  virtual std::size_t GetLen() const override;
216  virtual const sal_uInt8* GetData() const override;
217 };
218 
219 //------------------------------------------------------------- class Exc1904 -
220 
221 class Exc1904 : public ExcBoolRecord
222 {
223 public:
224  Exc1904( const ScDocument& rDoc );
225  virtual sal_uInt16 GetNum() const override;
226 
227  virtual void SaveXml( XclExpXmlStream& rStrm ) override;
228 private:
230 };
231 
232 //------------------------------------------------------ class ExcBundlesheet -
233 
235 {
236 protected:
237  sal_uInt64 m_nStrPos;
238  sal_uInt64 m_nOwnPos; // Position after # and Len
239  sal_uInt16 nGrbit;
241 
243 
244 public:
245  ExcBundlesheetBase( const RootData& rRootData, SCTAB nTab );
246 
247  void SetStreamPos(sal_uInt64 const nStrPos) { m_nStrPos = nStrPos; }
248  void UpdateStreamPos( XclExpStream& rStrm );
249 
250  virtual sal_uInt16 GetNum() const override;
251 };
252 
254 {
255 private:
256  OString aName;
257 
258  virtual void SaveCont( XclExpStream& rStrm ) override;
259 
260 public:
261  ExcBundlesheet( const RootData& rRootData, SCTAB nTab );
262  virtual std::size_t GetLen() const override;
263 };
264 
265 //--------------------------------------------------------- class ExcDummy_02 -
266 // sheet dummies: CALCMODE to SETUP
267 
268 class ExcDummy_02a : public ExcDummyRec
269 {
270 private:
271  static const sal_uInt8 pMyData[];
272  static const std::size_t nMyLen;
273 public:
274  virtual std::size_t GetLen() const override;
275  virtual const sal_uInt8* GetData() const override;
276 };
277 
280 {
281 public:
282  explicit XclExpCountry( const XclExpRoot& rRoot );
283 
284 private:
285  sal_uInt16 mnUICountry;
286  sal_uInt16 mnDocCountry;
287 
289  virtual void WriteBody( XclExpStream& rStrm ) override;
290 };
291 
292 // XclExpWsbool ===============================================================
293 
295 {
296 public:
297  explicit XclExpWsbool( bool bFitToPages );
298 };
299 
304 {
305 public:
306  explicit XclExpXmlSheetPr(
307  bool bFitToPages, SCTAB nScTab, const Color& rTabColor, XclExpFilterManager* pManager );
308 
309  virtual void SaveXml( XclExpXmlStream& rStrm ) override;
310 
311 private:
316 };
317 
319 {
320 public:
321  explicit XclExpFiltermode();
322 };
323 
325 {
326 public:
327  explicit XclExpAutofilterinfo( const ScAddress& rStartPos, SCCOL nScCol );
328 
329  const ScAddress& GetStartPos() const { return maStartPos; }
330  SCCOL GetColCount() const { return static_cast< SCCOL >( GetValue() ); }
331 
332 private:
334 };
335 
337 {
338 private:
341  double fVal;
342  std::unique_ptr<XclExpString>
344 
345 protected:
346 public:
349 
350  bool IsEmpty() const { return (nType == EXC_AFTYPE_NOTUSED); }
351  std::size_t GetTextBytes() const;
352 
353  void SetCondition( sal_uInt8 nTp, sal_uInt8 nOp, double fV, const OUString* pT );
354 
355  void Save( XclExpStream& rStrm );
356  void SaveXml( XclExpXmlStream& rStrm );
357  void SaveText( XclExpStream& rStrm );
358 };
359 
360 class XclExpAutofilter : public XclExpRecord, protected XclExpRoot
361 {
362 private:
365  sal_uInt16 nCol;
366  sal_uInt16 nFlags;
369  std::vector<std::pair<OUString, bool>> maMultiValues; // first->values, second->bDateFormat
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 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt16 nRupBuild
Definition: excrecds.hxx:102
XclExpWindowProtection(bool bValue)
Definition: excrecds.cxx:402
virtual void SaveCont(XclExpStream &rStrm)
Definition: excrecds.cxx:96
XclExpRecordList< XclExpAutofilter > XclExpAutofilterList
Definition: excrecds.hxx:412
bool AddEntry(const ScQueryEntry &rEntry)
Definition: excrecds.cxx:653
sal_uInt16 nGrbit
Definition: excrecds.hxx:239
bool IsFiltered(SCCOL nCol)
Definition: excrecds.cxx:1044
ExcBof()
Definition: excrecds.cxx:161
XclExpXmlSheetPr(bool bFitToPages, SCTAB nScTab, const Color &rTabColor, XclExpFilterManager *pManager)
Definition: excrecds.cxx:368
virtual const sal_uInt8 * GetData() const override
Definition: excrecds.cxx:224
virtual const sal_uInt8 * GetData() const =0
static const sal_uInt8 pMyData[]
Definition: excrecds.hxx:202
void InitTabFilter(SCTAB nScTab)
Creates the filter records for the specified sheet.
Definition: excrecds.cxx:1121
This class is used to export Excel record streams.
Definition: xestream.hxx:72
std::unique_ptr< XclExpString > pText
Definition: excrecds.hxx:343
static const sal_uInt8 pMyData[]
Definition: excrecds.hxx:152
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: excrecds.cxx:407
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: excrecds.cxx:1075
virtual sal_uInt16 GetNum() const override
Definition: excrecds.cxx:172
XclExpWsbool(bool bFitToPages)
Definition: excrecds.cxx:361
const Type & GetValue() const
Returns the value of the record.
Definition: xerecord.hxx:207
bool AddCondition(ScQueryConnect eConn, sal_uInt8 nType, sal_uInt8 nOp, double fVal, const OUString *pText, bool bSimple=false)
Definition: excrecds.cxx:628
static const std::size_t nMyLen
Definition: excrecds.hxx:203
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: excrecds.cxx:105
This record contains the Windows country IDs for the UI and document language.
Definition: excrecds.hxx:279
XclExpPassHash(const css::uno::Sequence< sal_Int8 > &aHash)
Definition: excrecds.cxx:497
ExcFilterCondition aCond[2]
Definition: excrecds.hxx:368
sal_uInt16 GetCol() const
Definition: excrecds.hxx:380
static const std::size_t nMyLen
Definition: excrecds.hxx:153
void SetCondition(sal_uInt8 nTp, sal_uInt8 nOp, double fV, const OUString *pT)
Definition: excrecds.cxx:544
static const sal_uInt8 pMyData[]
Definition: excrecds.hxx:212
virtual const sal_uInt8 * GetData() const override
Definition: excrecds.cxx:339
XclExpAutofilterList::RecordRefType XclExpAutofilterRef
Definition: excrecds.hxx:413
ScAddress maStartPos
Definition: excrecds.hxx:333
rtl::Reference< XclExpFiltermode > m_pFilterMode
Definition: excrecds.hxx:416
virtual void SaveCont(XclExpStream &rStrm) override
Definition: excrecds.cxx:190
sal_uInt16 nRupYear
Definition: excrecds.hxx:103
Save sheetPr element and its children for xlsx export.
Definition: excrecds.hxx:303
void AddMultiValueEntry(const ScQueryEntry &rEntry)
Definition: excrecds.cxx:784
void SaveXml(XclExpXmlStream &rStrm)
Definition: excrecds.cxx:598
const ScAddress & GetStartPos() const
Definition: excrecds.hxx:329
virtual ~ExcAutoFilterRecs() override
Definition: excrecds.cxx:1026
virtual void WriteBody(XclExpStream &rStrm) override
Writes the body of the record (without record header).
Definition: excrecds.cxx:797
static const sal_uInt8 pMyData[]
Definition: excrecds.hxx:271
static const std::size_t nMyLen
Definition: excrecds.hxx:272
Access to global data from other classes.
Definition: xeroot.hxx:112
virtual void Save(XclExpStream &rStrm) override
Overwrite this method to do any operation while saving the record.
Definition: excrecds.cxx:1066
SCCOL GetColCount() const
Definition: excrecds.hxx:330
OString aName
Definition: excrecds.hxx:256
void Save(XclExpStream &rStrm)
Definition: excrecds.cxx:552
sal_uInt16 nDocType
Definition: excrecds.hxx:100
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: excrecds.cxx:265
XclExpAutofilter(const XclExpRoot &rRoot, sal_uInt16 nC)
Definition: excrecds.cxx:618
XclExpAutofilterinfo(const ScAddress &rStartPos, SCCOL nScCol)
Definition: excrecds.cxx:522
std::vector< std::pair< OUString, bool > > maMultiValues
Definition: excrecds.hxx:369
Base class for all Excel records.
Definition: xerecord.hxx:37
virtual std::size_t GetLen() const override
Definition: excrecds.cxx:219
const sal_uInt16 EXC_AFFLAG_TOP10
Definition: excdefs.hxx:32
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:1138
virtual ~XclExpPassHash() override
Definition: excrecds.cxx:508
virtual std::size_t GetLen() const override
Definition: excrecds.cxx:241
bool bDateCompatibility
Definition: excrecds.hxx:229
virtual sal_uInt16 GetNum() const override
Definition: excrecds.cxx:195
virtual const sal_uInt8 * GetData() const override
Definition: excrecds.cxx:246
virtual std::size_t GetLen() const override
Definition: excrecds.cxx:144
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: excrecds.cxx:806
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:111
A record with a single value of type Type.
Definition: xerecord.hxx:197
XclExpProtection(bool bValue)
Definition: excrecds.cxx:414
virtual void SaveCont(XclExpStream &rStrm) override
Definition: excrecds.cxx:319
Exc1904(const ScDocument &rDoc)
Definition: excrecds.cxx:253
virtual void SaveCont(XclExpStream &rStrm) override
Definition: excrecds.cxx:139
virtual void WriteBody(XclExpStream &rStrm) override
The document country ID.
Definition: excrecds.cxx:354
sal_uInt16 nFlags
Definition: excrecds.hxx:366
sal_uInt16 nVers
Definition: excrecds.hxx:101
sal_Int16 SCCOL
Definition: types.hxx:21
bool HasCondition() const
Definition: excrecds.cxx:648
sal_uInt16 mnHash
Definition: excrecds.hxx:193
virtual std::size_t GetLen() const override
Definition: excrecds.cxx:327
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:75
virtual void WriteBody(XclExpStream &rStrm) override
Writes the body of the record.
Definition: excrecds.cxx:100
::std::map< SCTAB, XclExpTabFilterRef > XclExpTabFilterMap
Definition: excrecds.hxx:446
void SaveText(XclExpStream &rStrm)
Definition: excrecds.cxx:608
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:1111
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: excrecds.cxx:425
sal_uInt64 m_nStrPos
Definition: excrecds.hxx:237
bool HasTop10() const
Definition: excrecds.hxx:381
rtl::Reference< ExcAutoFilterRecs > XclExpTabFilterRef
Definition: excrecds.hxx:445
virtual sal_uInt16 GetNum() const override
Definition: excrecds.cxx:132
XclExpCountry(const XclExpRoot &rRoot)
Definition: excrecds.cxx:345
virtual std::size_t GetLen() const override
Definition: excrecds.cxx:120
virtual std::size_t GetLen() const override
Definition: excrecds.cxx:177
virtual std::size_t GetLen() const override
Definition: excrecds.cxx:334
virtual void Save(XclExpStream &rStrm) override
Writes the record header and calls WriteBody().
Definition: excrecds.cxx:90
bool IsEmpty() const
Definition: excrecds.hxx:350
virtual void SaveCont(XclExpStream &rStrm) override
Definition: excrecds.cxx:167
static const std::size_t nMyLen
Definition: excrecds.hxx:213
void UpdateStreamPos(XclExpStream &rStrm)
Definition: excrecds.cxx:298
virtual std::size_t GetLen() const override
Definition: excrecds.cxx:231
virtual sal_uInt16 GetNum() const override
Definition: excrecds.cxx:115
unsigned char sal_uInt8
virtual void Save(XclExpStream &rStrm) override
Writes the record header and calls WriteBody().
Definition: excrecds.cxx:127
A record without body.
Definition: xerecord.hxx:182
virtual std::size_t GetLen() const override
Definition: excrecds.cxx:212
Sheet filter manager.
Definition: excrecds.hxx:426
virtual std::size_t GetLen() const override
Definition: excrecds.cxx:200
XclExpAutofilterList maFilterList
Definition: excrecds.hxx:415
std::size_t GetTextBytes() const
Definition: excrecds.cxx:539
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:400
virtual void WriteBody(XclExpStream &rStrm) override
Writes the body of the record (without record header).
Definition: excrecds.cxx:512
XclExpFilterManager(const XclExpRoot &rRoot)
Definition: excrecds.cxx:1116
virtual sal_uInt16 GetNum() const override
Definition: excrecds.cxx:306
ExcBundlesheet(const RootData &rRootData, SCTAB nTab)
Definition: excrecds.cxx:311
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: excrecds.cxx:371
virtual const sal_uInt8 * GetData() const override
Definition: excrecds.cxx:236
XclExpRecordRef CreateRecord(SCTAB nScTab)
Returns a record object containing all filter records for the specified sheet.
Definition: excrecds.cxx:1126
XclExpAutofilter * GetByCol(SCCOL nCol)
Definition: excrecds.cxx:1030
virtual sal_uInt16 GetNum() const override
Definition: excrecds.cxx:207
virtual sal_uInt16 GetNum() const override
Definition: excrecds.cxx:260
XclExpSheetProtection(bool bValue, SCTAB nTab)
Definition: excrecds.cxx:419
sal_uInt16 mnUICountry
Definition: excrecds.hxx:285
sal_uInt16 mnDocCountry
The UI country ID.
Definition: excrecds.hxx:286
void SvStream & rStrm
void SetStreamPos(sal_uInt64 const nStrPos)
Definition: excrecds.hxx:247
ExcAutoFilterRecs(const XclExpRoot &rRoot, SCTAB nTab, const ScDBData *pDefinedData)
Definition: excrecds.cxx:889
FilterType meType
Definition: excrecds.hxx:364
sal_uInt64 m_nOwnPos
Definition: excrecds.hxx:238
Each instance of this struct represents a single filtering criteria.
Definition: queryentry.hxx:32
virtual sal_uInt16 GetNum() const =0
Base class for single records with any content.
Definition: xerecord.hxx:141
sal_Int16 SCTAB
Definition: types.hxx:22
Record which contains a Boolean value.
Definition: xerecord.hxx:253
rtl::Reference< XclExpAutofilterinfo > m_pFilterInfo
Definition: excrecds.hxx:417
sal_uInt16 nCol
Definition: excrecds.hxx:365
ScQueryConnect
Definition: global.hxx:838
const sal_uInt8 EXC_AFTYPE_NOTUSED
Definition: excdefs.hxx:37
XclExpFilterManager * mpManager
Definition: excrecds.hxx:313