Version 7.5.1.1, tag libreoffice-7.5.1.1
[LibreOffice.git] / sc / source / filter / inc / excrecds.hxx
blobc7ab0aa96bd2c70efae1d53a85bdf0e8e1052646
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <rtl/string.hxx>
23 #include <rtl/ustring.hxx>
24 #include <tools/color.hxx>
26 #include "xerecord.hxx"
27 #include "xeroot.hxx"
28 #include "excdefs.hxx"
30 //------------------------------------------------------------------ Forwards -
32 class ScDBData;
33 struct ScQueryEntry;
35 //----------------------------------------------------------- class ExcRecord -
37 class ExcRecord : public XclExpRecord
39 public:
40 virtual void Save( XclExpStream& rStrm ) override;
41 virtual void SaveXml( XclExpXmlStream& rStrm ) override;
43 virtual sal_uInt16 GetNum() const = 0;
44 virtual std::size_t GetLen() const = 0;
46 protected:
47 virtual void SaveCont( XclExpStream& rStrm );
49 private:
50 /** Writes the body of the record. */
51 virtual void WriteBody( XclExpStream& rStrm ) override;
54 //--------------------------------------------------------- class ExcEmptyRec -
56 class ExcEmptyRec : public ExcRecord
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;
66 //--------------------------------------------------------- class ExcDummyRec -
68 class ExcDummyRec : public ExcRecord
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
77 //------------------------------------------------------- class ExcBoolRecord -
78 // stores bool as 16bit val ( 0x0000 | 0x0001 )
80 class ExcBoolRecord : public ExcRecord
82 private:
83 virtual void SaveCont( XclExpStream& rStrm ) override;
85 protected:
86 bool bVal;
88 ExcBoolRecord() : bVal( false ) {}
90 public:
91 virtual std::size_t GetLen() const override;
94 //--------------------------------------------------------- class ExcBof_Base -
96 class ExcBof_Base : public ExcRecord
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();
108 //-------------------------------------------------------------- class ExcBof -
109 // Header Record for WORKSHEETS
111 class ExcBof : public ExcBof_Base
113 private:
114 virtual void SaveCont( XclExpStream& rStrm ) override;
115 public:
116 ExcBof();
118 virtual sal_uInt16 GetNum() const override;
119 virtual std::size_t GetLen() const override;
122 //------------------------------------------------------------- class ExcBofW -
123 // Header Record for WORKBOOKS
125 class ExcBofW : public ExcBof_Base
127 private:
128 virtual void SaveCont( XclExpStream& rStrm ) override;
129 public:
130 ExcBofW();
132 virtual sal_uInt16 GetNum() const override;
133 virtual std::size_t GetLen() const override;
136 //-------------------------------------------------------------- class ExcEof -
138 class ExcEof : public ExcRecord
140 private:
141 public:
142 virtual sal_uInt16 GetNum() const override;
143 virtual std::size_t GetLen() const override;
146 //--------------------------------------------------------- class ExcDummy_00 -
147 // INTERFACEHDR to FNGROUPCOUNT (see excrecds.cxx)
149 class ExcDummy_00 : public ExcDummyRec
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;
159 // EXC_ID_WINDOWPROTECTION
160 class XclExpWindowProtection : public XclExpBoolRecord
162 public:
163 XclExpWindowProtection(bool bValue);
165 virtual void SaveXml( XclExpXmlStream& rStrm ) override;
168 // EXC_ID_PROTECT Document Protection
169 class XclExpProtection : public XclExpBoolRecord
171 public:
172 XclExpProtection(bool bValue);
175 class XclExpSheetProtection : public XclExpProtection
177 SCTAB mnTab;
178 public:
179 XclExpSheetProtection(bool bValue, SCTAB nTab);
180 virtual void SaveXml( XclExpXmlStream& rStrm ) override;
183 class XclExpPassHash : public XclExpRecord
185 public:
186 XclExpPassHash(const css::uno::Sequence<sal_Int8>& aHash);
187 virtual ~XclExpPassHash() override;
189 private:
190 virtual void WriteBody(XclExpStream& rStrm) override;
192 private:
193 sal_uInt16 mnHash;
196 //-------------------------------------------------------- class ExcDummy_04x -
197 // PASSWORD to BOOKBOOL (see excrecds.cxx), no 1904
199 class ExcDummy_040 : public ExcDummyRec
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;
209 class ExcDummy_041 : public ExcDummyRec
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;
219 //------------------------------------------------------------- class Exc1904 -
221 class Exc1904 : public ExcBoolRecord
223 public:
224 Exc1904( const ScDocument& rDoc );
225 virtual sal_uInt16 GetNum() const override;
227 virtual void SaveXml( XclExpXmlStream& rStrm ) override;
228 private:
229 bool bDateCompatibility;
232 //------------------------------------------------------ class ExcBundlesheet -
234 class ExcBundlesheetBase : public ExcRecord
236 protected:
237 sal_uInt64 m_nStrPos;
238 sal_uInt64 m_nOwnPos; // Position after # and Len
239 sal_uInt16 nGrbit;
240 SCTAB nTab;
242 ExcBundlesheetBase();
244 public:
245 ExcBundlesheetBase( const RootData& rRootData, SCTAB nTab );
247 void SetStreamPos(sal_uInt64 const nStrPos) { m_nStrPos = nStrPos; }
248 void UpdateStreamPos( XclExpStream& rStrm );
250 virtual sal_uInt16 GetNum() const override;
253 class ExcBundlesheet : public ExcBundlesheetBase
255 private:
256 OString aName;
258 virtual void SaveCont( XclExpStream& rStrm ) override;
260 public:
261 ExcBundlesheet( const RootData& rRootData, SCTAB nTab );
262 virtual std::size_t GetLen() const override;
265 //--------------------------------------------------------- class ExcDummy_02 -
266 // sheet dummies: CALCMODE to SETUP
268 class ExcDummy_02a : public ExcDummyRec
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;
278 /** This record contains the Windows country IDs for the UI and document language. */
279 class XclExpCountry : public XclExpRecord
281 public:
282 explicit XclExpCountry( const XclExpRoot& rRoot );
284 private:
285 sal_uInt16 mnUICountry; /// The UI country ID.
286 sal_uInt16 mnDocCountry; /// The document country ID.
288 /** Writes the body of the COUNTRY record. */
289 virtual void WriteBody( XclExpStream& rStrm ) override;
292 // XclExpWsbool ===============================================================
294 class XclExpWsbool : public XclExpUInt16Record
296 public:
297 explicit XclExpWsbool( bool bFitToPages );
301 * Save sheetPr element and its children for xlsx export.
303 class XclExpXmlSheetPr : public XclExpRecordBase
305 public:
306 explicit XclExpXmlSheetPr(
307 bool bFitToPages, SCTAB nScTab, const Color& rTabColor, XclExpFilterManager* pManager );
309 virtual void SaveXml( XclExpXmlStream& rStrm ) override;
311 private:
312 SCTAB mnScTab;
313 XclExpFilterManager* mpManager;
314 bool mbFitToPage;
315 Color maTabColor;
318 class XclExpFiltermode : public XclExpEmptyRecord
320 public:
321 explicit XclExpFiltermode();
324 class XclExpAutofilterinfo : public XclExpUInt16Record
326 public:
327 explicit XclExpAutofilterinfo( const ScAddress& rStartPos, SCCOL nScCol );
329 const ScAddress& GetStartPos() const { return maStartPos; }
330 SCCOL GetColCount() const { return static_cast< SCCOL >( GetValue() ); }
332 private:
333 ScAddress maStartPos;
336 class ExcFilterCondition
338 private:
339 sal_uInt8 nType;
340 sal_uInt8 nOper;
341 std::unique_ptr<XclExpString>
342 pText;
344 protected:
345 public:
346 ExcFilterCondition();
347 ~ExcFilterCondition();
349 bool IsEmpty() const { return (nType == EXC_AFTYPE_NOTUSED); }
350 std::size_t GetTextBytes() const;
352 void SetCondition( sal_uInt8 nTp, sal_uInt8 nOp, const OUString* pT );
354 void Save( XclExpStream& rStrm );
355 void SaveXml( XclExpXmlStream& rStrm );
356 void SaveText( XclExpStream& rStrm );
359 class XclExpAutofilter : public XclExpRecord, protected XclExpRoot
361 private:
362 enum FilterType
364 Empty,
365 FilterCondition,
366 MultiValue,
367 BlankValue,
368 ColorValue
370 FilterType meType;
371 sal_uInt16 nCol;
372 bool bIsButtonHidden;
373 sal_uInt16 nFlags;
374 bool bHasBlankValue;
375 ExcFilterCondition aCond[ 2 ];
376 std::vector<std::pair<OUString, bool>> maMultiValues; // first->values, second->bDateFormat
377 std::vector<std::pair<::Color, bool>> maColorValues; // first->Color, second->bIsBackgroundColor (vs. TextColor)
379 bool AddCondition( ScQueryConnect eConn, sal_uInt8 nType,
380 sal_uInt8 nOp, const OUString* pText, bool bSimple = false );
382 virtual void WriteBody( XclExpStream& rStrm ) override;
384 public:
385 XclExpAutofilter( const XclExpRoot& rRoot, sal_uInt16 nC, bool bIsEmpty = false );
387 sal_uInt16 GetCol() const { return nCol; }
388 bool HasTop10() const { return ::get_flag( nFlags, EXC_AFFLAG_TOP10 ); }
390 bool HasCondition() const;
391 bool AddEntry( const ScQueryEntry& rEntry );
392 void AddMultiValueEntry( const ScQueryEntry& rEntry );
393 void SetButtonHidden(bool bValue) { bIsButtonHidden = bValue; }
394 void AddColorEntry( const ScQueryEntry& rEntry );
396 virtual void SaveXml( XclExpXmlStream& rStrm ) override;
399 class ExcAutoFilterRecs : public XclExpRecordBase, protected XclExpRoot
401 public:
402 /** @param pDefinedData
403 If nullptr, obtain anonymous ScDBData from sheet nTab.
404 Else, use defined database range; used with XclExpTables.
406 explicit ExcAutoFilterRecs( const XclExpRoot& rRoot, SCTAB nTab, const ScDBData* pDefinedData );
407 virtual ~ExcAutoFilterRecs() override;
409 void AddObjRecs();
411 virtual void Save( XclExpStream& rStrm ) override;
412 virtual void SaveXml( XclExpXmlStream& rStrm ) override;
414 bool HasFilterMode() const;
416 private:
417 XclExpAutofilter* GetByCol( SCCOL nCol ); // always 0-based
418 bool IsFiltered( SCCOL nCol );
420 private:
421 typedef XclExpRecordList< XclExpAutofilter > XclExpAutofilterList;
422 typedef XclExpAutofilterList::RecordRefType XclExpAutofilterRef;
424 XclExpAutofilterList maFilterList;
425 rtl::Reference<XclExpFiltermode> m_pFilterMode;
426 rtl::Reference<XclExpAutofilterinfo> m_pFilterInfo;
427 ScRange maRef;
428 bool mbAutoFilter;
430 ScRange maSortRef; // sort area without headers
431 std::vector< std::tuple<ScRange, OUString, bool> > maSortCustomList; // sorted column with list of sorted items
434 /** Sheet filter manager. Contains auto filters or advanced filters from all sheets. */
435 class XclExpFilterManager : protected XclExpRoot
437 public:
438 explicit XclExpFilterManager( const XclExpRoot& rRoot );
440 /** Creates the filter records for the specified sheet.
441 @descr Creates and inserts related built-in NAME records. Therefore this
442 function is called from the name buffer itself. */
443 void InitTabFilter( SCTAB nScTab );
445 /** Returns a record object containing all filter records for the specified sheet. */
446 XclExpRecordRef CreateRecord( SCTAB nScTab );
448 /** Returns whether or not FilterMode is present */
449 bool HasFilterMode( SCTAB nScTab );
451 private:
452 using XclExpRoot::CreateRecord;
454 typedef rtl::Reference< ExcAutoFilterRecs > XclExpTabFilterRef;
455 typedef ::std::map< SCTAB, XclExpTabFilterRef > XclExpTabFilterMap;
457 XclExpTabFilterMap maFilterMap;
460 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */