Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / sc / source / filter / inc / excrecds.hxx
blob727c96c7f6d02675ce99d49ee77d729b8fb6cb28
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 #ifndef INCLUDED_SC_SOURCE_FILTER_INC_EXCRECDS_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_EXCRECDS_HXX
23 #include <rtl/string.hxx>
24 #include <rtl/ustring.hxx>
25 #include <svl/zforlist.hxx>
26 #include <tools/solar.h>
27 #include <tools/color.hxx>
28 #include <vcl/vclenum.hxx>
30 #include "olinetab.hxx"
31 #include "filter.hxx"
32 #include "rangelst.hxx"
33 #include "xerecord.hxx"
34 #include "xeroot.hxx"
35 #include "xeformula.hxx"
36 #include "xestring.hxx"
37 #include "root.hxx"
38 #include "excdefs.hxx"
39 #include <memory>
40 #include <vector>
42 //------------------------------------------------------------------ Forwards -
44 class ScDBData;
45 struct ScQueryEntry;
47 //----------------------------------------------------------- class ExcRecord -
49 class ExcRecord : public XclExpRecord
51 public:
52 virtual void Save( XclExpStream& rStrm ) override;
53 virtual void SaveXml( XclExpXmlStream& rStrm ) override;
55 virtual sal_uInt16 GetNum() const = 0;
56 virtual sal_Size GetLen() const = 0;
58 protected:
59 virtual void SaveCont( XclExpStream& rStrm );
61 private:
62 /** Writes the body of the record. */
63 virtual void WriteBody( XclExpStream& rStrm ) override;
66 //--------------------------------------------------------- class ExcEmptyRec -
68 class ExcEmptyRec : public ExcRecord
70 private:
71 protected:
72 public:
73 virtual void Save( XclExpStream& rStrm ) override;
74 virtual sal_uInt16 GetNum() const override;
75 virtual sal_Size GetLen() const override;
78 //--------------------------------------------------------- class ExcDummyRec -
80 class ExcDummyRec : public ExcRecord
82 protected:
83 public:
84 virtual void Save( XclExpStream& rStrm ) override;
85 virtual sal_uInt16 GetNum() const override;
86 virtual const sal_uInt8* GetData() const = 0; // byte data must contain header and body
89 //------------------------------------------------------- class ExcBoolRecord -
90 // stores bool as 16bit val ( 0x0000 | 0x0001 )
92 class ExcBoolRecord : public ExcRecord
94 private:
95 virtual void SaveCont( XclExpStream& rStrm ) override;
97 protected:
98 bool bVal;
100 inline ExcBoolRecord() : bVal( false ) {}
102 public:
103 virtual sal_Size GetLen() const override;
106 //--------------------------------------------------------- class ExcBof_Base -
108 class ExcBof_Base : public ExcRecord
110 private:
111 protected:
112 sal_uInt16 nDocType;
113 sal_uInt16 nVers;
114 sal_uInt16 nRupBuild;
115 sal_uInt16 nRupYear;
116 public:
117 ExcBof_Base();
120 //-------------------------------------------------------------- class ExcBof -
121 // Header Record fuer WORKSHEETS
123 class ExcBof : public ExcBof_Base
125 private:
126 virtual void SaveCont( XclExpStream& rStrm ) override;
127 public:
128 ExcBof();
130 virtual sal_uInt16 GetNum() const override;
131 virtual sal_Size GetLen() const override;
134 //------------------------------------------------------------- class ExcBofW -
135 // Header Record fuer WORKBOOKS
137 class ExcBofW : public ExcBof_Base
139 private:
140 virtual void SaveCont( XclExpStream& rStrm ) override;
141 public:
142 ExcBofW();
144 virtual sal_uInt16 GetNum() const override;
145 virtual sal_Size GetLen() const override;
148 //-------------------------------------------------------------- class ExcEof -
150 class ExcEof : public ExcRecord
152 private:
153 public:
154 virtual sal_uInt16 GetNum() const override;
155 virtual sal_Size GetLen() const override;
158 //--------------------------------------------------------- class ExcDummy_00 -
159 // INTERFACEHDR to FNGROUPCOUNT (see excrecds.cxx)
161 class ExcDummy_00 : public ExcDummyRec
163 private:
164 static const sal_uInt8 pMyData[];
165 static const sal_Size nMyLen;
166 public:
167 virtual sal_Size GetLen() const override;
168 virtual const sal_uInt8* GetData() const override;
171 // EXC_ID_WINDOWPROTECTION
172 class XclExpWindowProtection : public XclExpBoolRecord
174 public:
175 XclExpWindowProtection(bool bValue);
177 virtual void SaveXml( XclExpXmlStream& rStrm ) override;
180 // EXC_ID_PROTECT Document Protection
181 class XclExpProtection : public XclExpBoolRecord
183 public:
184 XclExpProtection(bool bValue);
187 class XclExpSheetProtection : public XclExpProtection
189 SCTAB mnTab;
190 public:
191 XclExpSheetProtection(bool bValue, SCTAB nTab);
192 virtual void SaveXml( XclExpXmlStream& rStrm ) override;
195 class XclExpPassHash : public XclExpRecord
197 public:
198 XclExpPassHash(const css::uno::Sequence<sal_Int8>& aHash);
199 virtual ~XclExpPassHash();
201 private:
202 virtual void WriteBody(XclExpStream& rStrm) override;
204 private:
205 sal_uInt16 mnHash;
208 //-------------------------------------------------------- class ExcDummy_04x -
209 // PASSWORD to BOOKBOOL (see excrecds.cxx), no 1904
211 class ExcDummy_040 : public ExcDummyRec
213 private:
214 static const sal_uInt8 pMyData[];
215 static const sal_Size nMyLen;
216 public:
217 virtual sal_Size GetLen() const override;
218 virtual const sal_uInt8* GetData() const override;
221 class ExcDummy_041 : public ExcDummyRec
223 private:
224 static const sal_uInt8 pMyData[];
225 static const sal_Size nMyLen;
226 public:
227 virtual sal_Size GetLen() const override;
228 virtual const sal_uInt8* GetData() const override;
231 //------------------------------------------------------------- class Exc1904 -
233 class Exc1904 : public ExcBoolRecord
235 public:
236 Exc1904( ScDocument& rDoc );
237 virtual sal_uInt16 GetNum() const override;
239 virtual void SaveXml( XclExpXmlStream& rStrm ) override;
240 private:
241 bool bDateCompatibility;
244 //------------------------------------------------------ class ExcBundlesheet -
246 class ExcBundlesheetBase : public ExcRecord
248 protected:
249 sal_uInt64 m_nStrPos;
250 sal_uInt64 m_nOwnPos; // Position after # and Len
251 sal_uInt16 nGrbit;
252 SCTAB nTab;
254 ExcBundlesheetBase();
256 public:
257 ExcBundlesheetBase( RootData& rRootData, SCTAB nTab );
259 inline void SetStreamPos(sal_uInt64 const nStrPos) { m_nStrPos = nStrPos; }
260 void UpdateStreamPos( XclExpStream& rStrm );
262 virtual sal_uInt16 GetNum() const override;
265 class ExcBundlesheet : public ExcBundlesheetBase
267 private:
268 OString aName;
270 virtual void SaveCont( XclExpStream& rStrm ) override;
272 public:
273 ExcBundlesheet( RootData& rRootData, SCTAB nTab );
274 virtual sal_Size GetLen() const override;
277 //--------------------------------------------------------- class ExcDummy_02 -
278 // sheet dummies: CALCMODE to SETUP
280 class ExcDummy_02a : public ExcDummyRec
282 private:
283 static const sal_uInt8 pMyData[];
284 static const sal_Size nMyLen;
285 public:
286 virtual sal_Size GetLen() const override;
287 virtual const sal_uInt8* GetData() const override;
290 /** This record contains the Windows country IDs for the UI and document language. */
291 class XclExpCountry : public XclExpRecord
293 public:
294 explicit XclExpCountry( const XclExpRoot& rRoot );
296 private:
297 sal_uInt16 mnUICountry; /// The UI country ID.
298 sal_uInt16 mnDocCountry; /// The document country ID.
300 /** Writes the body of the COUNTRY record. */
301 virtual void WriteBody( XclExpStream& rStrm ) override;
304 // XclExpWsbool ===============================================================
306 class XclExpWsbool : public XclExpUInt16Record
308 public:
309 explicit XclExpWsbool( bool bFitToPages );
313 * Save sheetPr element and its children for xlsx export.
315 class XclExpXmlSheetPr : public XclExpRecordBase
317 public:
318 explicit XclExpXmlSheetPr(
319 bool bFitToPages, SCTAB nScTab, const Color& rTabColor, XclExpFilterManager* pManager );
321 virtual void SaveXml( XclExpXmlStream& rStrm ) override;
323 private:
324 SCTAB mnScTab;
325 XclExpFilterManager* mpManager;
326 bool mbFitToPage;
327 Color maTabColor;
330 class XclExpFiltermode : public XclExpEmptyRecord
332 public:
333 explicit XclExpFiltermode();
336 class XclExpAutofilterinfo : public XclExpUInt16Record
338 public:
339 explicit XclExpAutofilterinfo( const ScAddress& rStartPos, SCCOL nScCol );
341 inline const ScAddress& GetStartPos() const { return maStartPos; }
342 inline SCCOL GetColCount() const { return static_cast< SCCOL >( GetValue() ); }
344 private:
345 ScAddress maStartPos;
348 class ExcFilterCondition
350 private:
351 sal_uInt8 nType;
352 sal_uInt8 nOper;
353 double fVal;
354 XclExpString* pText;
356 protected:
357 public:
358 ExcFilterCondition();
359 ~ExcFilterCondition();
361 inline bool IsEmpty() const { return (nType == EXC_AFTYPE_NOTUSED); }
362 sal_uLong GetTextBytes() const;
364 void SetCondition( sal_uInt8 nTp, sal_uInt8 nOp, double fV, OUString* pT );
366 void Save( XclExpStream& rStrm );
367 void SaveXml( XclExpXmlStream& rStrm );
368 void SaveText( XclExpStream& rStrm );
371 class XclExpAutofilter : public XclExpRecord, protected XclExpRoot
373 private:
374 enum FilterType { FilterCondition, MultiValue };
375 FilterType meType;
376 sal_uInt16 nCol;
377 sal_uInt16 nFlags;
378 ExcFilterCondition aCond[ 2 ];
379 std::vector<OUString> maMultiValues;
381 bool AddCondition( ScQueryConnect eConn, sal_uInt8 nType,
382 sal_uInt8 nOp, double fVal, OUString* pText,
383 bool bSimple = false );
385 virtual void WriteBody( XclExpStream& rStrm ) override;
387 public:
388 XclExpAutofilter( const XclExpRoot& rRoot, sal_uInt16 nC );
390 inline sal_uInt16 GetCol() const { return nCol; }
391 inline bool HasTop10() const { return ::get_flag( nFlags, EXC_AFFLAG_TOP10 ); }
393 bool HasCondition() const;
394 bool AddEntry( const ScQueryEntry& rEntry );
395 bool AddMultiValueEntry( const ScQueryEntry& rEntry );
397 virtual void SaveXml( XclExpXmlStream& rStrm ) override;
400 class ExcAutoFilterRecs : public XclExpRecordBase, protected XclExpRoot
402 public:
403 /** @param pDefinedData
404 If nullptr, obtain anonymous ScDBData from sheet nTab.
405 Else, use defined database range; used with XclExpTables.
407 explicit ExcAutoFilterRecs( const XclExpRoot& rRoot, SCTAB nTab, const ScDBData* pDefinedData );
408 virtual ~ExcAutoFilterRecs();
410 void AddObjRecs();
412 virtual void Save( XclExpStream& rStrm ) override;
413 virtual void SaveXml( XclExpXmlStream& rStrm ) override;
415 bool HasFilterMode() const;
417 private:
418 XclExpAutofilter* GetByCol( SCCOL nCol ); // always 0-based
419 bool IsFiltered( SCCOL nCol );
421 private:
422 typedef XclExpRecordList< XclExpAutofilter > XclExpAutofilterList;
423 typedef XclExpAutofilterList::RecordRefType XclExpAutofilterRef;
425 XclExpAutofilterList maFilterList;
426 XclExpFiltermode* pFilterMode;
427 XclExpAutofilterinfo* pFilterInfo;
428 ScRange maRef;
429 bool mbAutoFilter;
432 /** Sheet filter manager. Contains auto filters or advanced filters from all sheets. */
433 class XclExpFilterManager : protected XclExpRoot
435 public:
436 explicit XclExpFilterManager( const XclExpRoot& rRoot );
438 /** Creates the filter records for the specified sheet.
439 @descr Creates and inserts related built-in NAME records. Therefore this
440 function is called from the name buffer itself. */
441 void InitTabFilter( SCTAB nScTab );
443 /** Returns a record object containing all filter records for the specified sheet. */
444 XclExpRecordRef CreateRecord( SCTAB nScTab );
446 /** Returns whether or not FilterMode is present */
447 bool HasFilterMode( SCTAB nScTab );
449 private:
450 using XclExpRoot::CreateRecord;
452 typedef std::shared_ptr< ExcAutoFilterRecs > XclExpTabFilterRef;
453 typedef ::std::map< SCTAB, XclExpTabFilterRef > XclExpTabFilterMap;
455 XclExpTabFilterMap maFilterMap;
458 #endif
460 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */