1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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"
32 #include "rangelst.hxx"
33 #include "xerecord.hxx"
35 #include "xeformula.hxx"
36 #include "xestring.hxx"
38 #include "excdefs.hxx"
42 //------------------------------------------------------------------ Forwards -
47 //----------------------------------------------------------- class ExcRecord -
49 class ExcRecord
: public XclExpRecord
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;
59 virtual void SaveCont( XclExpStream
& rStrm
);
62 /** Writes the body of the record. */
63 virtual void WriteBody( XclExpStream
& rStrm
) override
;
66 //--------------------------------------------------------- class ExcEmptyRec -
68 class ExcEmptyRec
: public ExcRecord
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
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
95 virtual void SaveCont( XclExpStream
& rStrm
) override
;
100 inline ExcBoolRecord() : bVal( false ) {}
103 virtual sal_Size
GetLen() const override
;
106 //--------------------------------------------------------- class ExcBof_Base -
108 class ExcBof_Base
: public ExcRecord
114 sal_uInt16 nRupBuild
;
120 //-------------------------------------------------------------- class ExcBof -
121 // Header Record fuer WORKSHEETS
123 class ExcBof
: public ExcBof_Base
126 virtual void SaveCont( XclExpStream
& rStrm
) override
;
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
140 virtual void SaveCont( XclExpStream
& rStrm
) override
;
144 virtual sal_uInt16
GetNum() const override
;
145 virtual sal_Size
GetLen() const override
;
148 //-------------------------------------------------------------- class ExcEof -
150 class ExcEof
: public ExcRecord
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
164 static const sal_uInt8 pMyData
[];
165 static const sal_Size nMyLen
;
167 virtual sal_Size
GetLen() const override
;
168 virtual const sal_uInt8
* GetData() const override
;
171 // EXC_ID_WINDOWPROTECTION
172 class XclExpWindowProtection
: public XclExpBoolRecord
175 XclExpWindowProtection(bool bValue
);
177 virtual void SaveXml( XclExpXmlStream
& rStrm
) override
;
180 // EXC_ID_PROTECT Document Protection
181 class XclExpProtection
: public XclExpBoolRecord
184 XclExpProtection(bool bValue
);
187 class XclExpSheetProtection
: public XclExpProtection
191 XclExpSheetProtection(bool bValue
, SCTAB nTab
);
192 virtual void SaveXml( XclExpXmlStream
& rStrm
) override
;
195 class XclExpPassHash
: public XclExpRecord
198 XclExpPassHash(const css::uno::Sequence
<sal_Int8
>& aHash
);
199 virtual ~XclExpPassHash();
202 virtual void WriteBody(XclExpStream
& rStrm
) override
;
208 //-------------------------------------------------------- class ExcDummy_04x -
209 // PASSWORD to BOOKBOOL (see excrecds.cxx), no 1904
211 class ExcDummy_040
: public ExcDummyRec
214 static const sal_uInt8 pMyData
[];
215 static const sal_Size nMyLen
;
217 virtual sal_Size
GetLen() const override
;
218 virtual const sal_uInt8
* GetData() const override
;
221 class ExcDummy_041
: public ExcDummyRec
224 static const sal_uInt8 pMyData
[];
225 static const sal_Size nMyLen
;
227 virtual sal_Size
GetLen() const override
;
228 virtual const sal_uInt8
* GetData() const override
;
231 //------------------------------------------------------------- class Exc1904 -
233 class Exc1904
: public ExcBoolRecord
236 Exc1904( ScDocument
& rDoc
);
237 virtual sal_uInt16
GetNum() const override
;
239 virtual void SaveXml( XclExpXmlStream
& rStrm
) override
;
241 bool bDateCompatibility
;
244 //------------------------------------------------------ class ExcBundlesheet -
246 class ExcBundlesheetBase
: public ExcRecord
249 sal_uInt64 m_nStrPos
;
250 sal_uInt64 m_nOwnPos
; // Position after # and Len
254 ExcBundlesheetBase();
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
270 virtual void SaveCont( XclExpStream
& rStrm
) override
;
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
283 static const sal_uInt8 pMyData
[];
284 static const sal_Size nMyLen
;
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
294 explicit XclExpCountry( const XclExpRoot
& rRoot
);
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
309 explicit XclExpWsbool( bool bFitToPages
);
313 * Save sheetPr element and its children for xlsx export.
315 class XclExpXmlSheetPr
: public XclExpRecordBase
318 explicit XclExpXmlSheetPr(
319 bool bFitToPages
, SCTAB nScTab
, const Color
& rTabColor
, XclExpFilterManager
* pManager
);
321 virtual void SaveXml( XclExpXmlStream
& rStrm
) override
;
325 XclExpFilterManager
* mpManager
;
330 class XclExpFiltermode
: public XclExpEmptyRecord
333 explicit XclExpFiltermode();
336 class XclExpAutofilterinfo
: public XclExpUInt16Record
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() ); }
345 ScAddress maStartPos
;
348 class ExcFilterCondition
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
374 enum FilterType
{ FilterCondition
, MultiValue
};
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
;
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
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();
412 virtual void Save( XclExpStream
& rStrm
) override
;
413 virtual void SaveXml( XclExpXmlStream
& rStrm
) override
;
415 bool HasFilterMode() const;
418 XclExpAutofilter
* GetByCol( SCCOL nCol
); // always 0-based
419 bool IsFiltered( SCCOL nCol
);
422 typedef XclExpRecordList
< XclExpAutofilter
> XclExpAutofilterList
;
423 typedef XclExpAutofilterList::RecordRefType XclExpAutofilterRef
;
425 XclExpAutofilterList maFilterList
;
426 XclExpFiltermode
* pFilterMode
;
427 XclExpAutofilterinfo
* pFilterInfo
;
432 /** Sheet filter manager. Contains auto filters or advanced filters from all sheets. */
433 class XclExpFilterManager
: protected XclExpRoot
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
);
450 using XclExpRoot::CreateRecord
;
452 typedef std::shared_ptr
< ExcAutoFilterRecs
> XclExpTabFilterRef
;
453 typedef ::std::map
< SCTAB
, XclExpTabFilterRef
> XclExpTabFilterMap
;
455 XclExpTabFilterMap maFilterMap
;
460 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */