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 -
46 //----------------------------------------------------------- class ExcRecord -
48 class ExcRecord
: public XclExpRecord
51 virtual void Save( XclExpStream
& rStrm
) SAL_OVERRIDE
;
52 virtual void SaveXml( XclExpXmlStream
& rStrm
) SAL_OVERRIDE
;
54 virtual sal_uInt16
GetNum() const = 0;
55 virtual sal_Size
GetLen() const = 0;
58 virtual void SaveCont( XclExpStream
& rStrm
);
61 /** Writes the body of the record. */
62 virtual void WriteBody( XclExpStream
& rStrm
) SAL_OVERRIDE
;
65 //--------------------------------------------------------- class ExcEmptyRec -
67 class ExcEmptyRec
: public ExcRecord
72 virtual void Save( XclExpStream
& rStrm
) SAL_OVERRIDE
;
73 virtual sal_uInt16
GetNum() const SAL_OVERRIDE
;
74 virtual sal_Size
GetLen() const SAL_OVERRIDE
;
77 //--------------------------------------------------------- class ExcDummyRec -
79 class ExcDummyRec
: public ExcRecord
83 virtual void Save( XclExpStream
& rStrm
) SAL_OVERRIDE
;
84 virtual sal_uInt16
GetNum() const SAL_OVERRIDE
;
85 virtual const sal_uInt8
* GetData() const = 0; // byte data must contain header and body
88 //------------------------------------------------------- class ExcBoolRecord -
89 // stores bool as 16bit val ( 0x0000 | 0x0001 )
91 class ExcBoolRecord
: public ExcRecord
94 virtual void SaveCont( XclExpStream
& rStrm
) SAL_OVERRIDE
;
99 inline ExcBoolRecord() : bVal( false ) {}
102 inline ExcBoolRecord( const bool bDefault
) : bVal( bDefault
) {}
104 virtual sal_Size
GetLen() const SAL_OVERRIDE
;
107 //--------------------------------------------------------- class ExcBof_Base -
109 class ExcBof_Base
: public ExcRecord
115 sal_uInt16 nRupBuild
;
121 //-------------------------------------------------------------- class ExcBof -
122 // Header Record fuer WORKSHEETS
124 class ExcBof
: public ExcBof_Base
127 virtual void SaveCont( XclExpStream
& rStrm
) SAL_OVERRIDE
;
131 virtual sal_uInt16
GetNum() const SAL_OVERRIDE
;
132 virtual sal_Size
GetLen() const SAL_OVERRIDE
;
135 //------------------------------------------------------------- class ExcBofW -
136 // Header Record fuer WORKBOOKS
138 class ExcBofW
: public ExcBof_Base
141 virtual void SaveCont( XclExpStream
& rStrm
) SAL_OVERRIDE
;
145 virtual sal_uInt16
GetNum() const SAL_OVERRIDE
;
146 virtual sal_Size
GetLen() const SAL_OVERRIDE
;
149 //-------------------------------------------------------------- class ExcEof -
151 class ExcEof
: public ExcRecord
155 virtual sal_uInt16
GetNum() const SAL_OVERRIDE
;
156 virtual sal_Size
GetLen() const SAL_OVERRIDE
;
159 //--------------------------------------------------------- class ExcDummy_00 -
160 // INTERFACEHDR to FNGROUPCOUNT (see excrecds.cxx)
162 class ExcDummy_00
: public ExcDummyRec
165 static const sal_uInt8 pMyData
[];
166 static const sal_Size nMyLen
;
168 virtual sal_Size
GetLen() const SAL_OVERRIDE
;
169 virtual const sal_uInt8
* GetData() const SAL_OVERRIDE
;
172 // EXC_ID_WINDOWPROTECTION
173 class XclExpWindowProtection
: public XclExpBoolRecord
176 XclExpWindowProtection(bool bValue
);
178 virtual void SaveXml( XclExpXmlStream
& rStrm
) SAL_OVERRIDE
;
181 // EXC_ID_PROTECT Document Protection
182 class XclExpProtection
: public XclExpBoolRecord
185 XclExpProtection(bool bValue
);
188 class XclExpSheetProtection
: public XclExpProtection
192 XclExpSheetProtection(bool bValue
, SCTAB nTab
);
193 virtual void SaveXml( XclExpXmlStream
& rStrm
) SAL_OVERRIDE
;
196 class XclExpPassHash
: public XclExpRecord
199 XclExpPassHash(const ::com::sun::star::uno::Sequence
<sal_Int8
>& aHash
);
200 virtual ~XclExpPassHash();
203 virtual void WriteBody(XclExpStream
& rStrm
) SAL_OVERRIDE
;
209 //-------------------------------------------------------- class ExcDummy_04x -
210 // PASSWORD to BOOKBOOL (see excrecds.cxx), no 1904
212 class ExcDummy_040
: public ExcDummyRec
215 static const sal_uInt8 pMyData
[];
216 static const sal_Size nMyLen
;
218 virtual sal_Size
GetLen() const SAL_OVERRIDE
;
219 virtual const sal_uInt8
* GetData() const SAL_OVERRIDE
;
222 class ExcDummy_041
: public ExcDummyRec
225 static const sal_uInt8 pMyData
[];
226 static const sal_Size nMyLen
;
228 virtual sal_Size
GetLen() const SAL_OVERRIDE
;
229 virtual const sal_uInt8
* GetData() const SAL_OVERRIDE
;
232 //------------------------------------------------------------- class Exc1904 -
234 class Exc1904
: public ExcBoolRecord
237 Exc1904( ScDocument
& rDoc
);
238 virtual sal_uInt16
GetNum() const SAL_OVERRIDE
;
240 virtual void SaveXml( XclExpXmlStream
& rStrm
) SAL_OVERRIDE
;
242 bool bDateCompatibility
;
245 //------------------------------------------------------ class ExcBundlesheet -
247 class ExcBundlesheetBase
: public ExcRecord
250 sal_uInt64 m_nStrPos
;
251 sal_uInt64 m_nOwnPos
; // Position after # and Len
255 ExcBundlesheetBase();
258 ExcBundlesheetBase( RootData
& rRootData
, SCTAB nTab
);
260 inline void SetStreamPos(sal_uInt64
const nStrPos
) { m_nStrPos
= nStrPos
; }
261 void UpdateStreamPos( XclExpStream
& rStrm
);
263 virtual sal_uInt16
GetNum() const SAL_OVERRIDE
;
266 class ExcBundlesheet
: public ExcBundlesheetBase
271 virtual void SaveCont( XclExpStream
& rStrm
) SAL_OVERRIDE
;
274 ExcBundlesheet( RootData
& rRootData
, SCTAB nTab
);
275 virtual sal_Size
GetLen() const SAL_OVERRIDE
;
278 //--------------------------------------------------------- class ExcDummy_02 -
279 // sheet dummies: CALCMODE to SETUP
281 class ExcDummy_02a
: public ExcDummyRec
284 static const sal_uInt8 pMyData
[];
285 static const sal_Size nMyLen
;
287 virtual sal_Size
GetLen() const SAL_OVERRIDE
;
288 virtual const sal_uInt8
* GetData() const SAL_OVERRIDE
;
291 /** This record contains the Windows country IDs for the UI and document language. */
292 class XclExpCountry
: public XclExpRecord
295 explicit XclExpCountry( const XclExpRoot
& rRoot
);
298 sal_uInt16 mnUICountry
; /// The UI country ID.
299 sal_uInt16 mnDocCountry
; /// The document country ID.
301 /** Writes the body of the COUNTRY record. */
302 virtual void WriteBody( XclExpStream
& rStrm
) SAL_OVERRIDE
;
305 // XclExpWsbool ===============================================================
307 class XclExpWsbool
: public XclExpUInt16Record
310 explicit XclExpWsbool( bool bFitToPages
);
314 * Save sheetPr element and its children for xlsx export.
316 class XclExpXmlSheetPr
: public XclExpRecordBase
319 explicit XclExpXmlSheetPr(
320 bool bFitToPages
, SCTAB nScTab
, const Color
& rTabColor
, XclExpFilterManager
* pManager
);
322 virtual void SaveXml( XclExpXmlStream
& rStrm
) SAL_OVERRIDE
;
326 XclExpFilterManager
* mpManager
;
331 class XclExpFiltermode
: public XclExpEmptyRecord
334 explicit XclExpFiltermode();
337 class XclExpAutofilterinfo
: public XclExpUInt16Record
340 explicit XclExpAutofilterinfo( const ScAddress
& rStartPos
, SCCOL nScCol
);
342 inline const ScAddress
GetStartPos() const { return maStartPos
; }
343 inline SCCOL
GetColCount() const { return static_cast< SCCOL
>( GetValue() ); }
346 ScAddress maStartPos
;
349 class ExcFilterCondition
359 ExcFilterCondition();
360 ~ExcFilterCondition();
362 inline bool IsEmpty() const { return (nType
== EXC_AFTYPE_NOTUSED
); }
363 inline bool HasEqual() const { return (nOper
== EXC_AFOPER_EQUAL
); }
364 sal_uLong
GetTextBytes() const;
366 void SetCondition( sal_uInt8 nTp
, sal_uInt8 nOp
, double fV
, OUString
* pT
);
368 void Save( XclExpStream
& rStrm
);
369 void SaveXml( XclExpXmlStream
& rStrm
);
370 void SaveText( XclExpStream
& rStrm
);
373 class XclExpAutofilter
: public XclExpRecord
, protected XclExpRoot
376 enum FilterType
{ FilterCondition
, MultiValue
};
380 ExcFilterCondition aCond
[ 2 ];
381 std::vector
<OUString
> maMultiValues
;
383 bool AddCondition( ScQueryConnect eConn
, sal_uInt8 nType
,
384 sal_uInt8 nOp
, double fVal
, OUString
* pText
,
385 bool bSimple
= false );
387 virtual void WriteBody( XclExpStream
& rStrm
) SAL_OVERRIDE
;
390 XclExpAutofilter( const XclExpRoot
& rRoot
, sal_uInt16 nC
);
392 inline sal_uInt16
GetCol() const { return nCol
; }
393 inline bool HasTop10() const { return ::get_flag( nFlags
, EXC_AFFLAG_TOP10
); }
395 bool HasCondition() const;
396 bool AddEntry( const ScQueryEntry
& rEntry
);
397 bool AddMultiValueEntry( const ScQueryEntry
& rEntry
);
399 virtual void SaveXml( XclExpXmlStream
& rStrm
) SAL_OVERRIDE
;
402 class ExcAutoFilterRecs
: public XclExpRecordBase
, protected XclExpRoot
405 explicit ExcAutoFilterRecs( const XclExpRoot
& rRoot
, SCTAB nTab
);
406 virtual ~ExcAutoFilterRecs();
410 virtual void Save( XclExpStream
& rStrm
) SAL_OVERRIDE
;
411 virtual void SaveXml( XclExpXmlStream
& rStrm
) SAL_OVERRIDE
;
413 bool HasFilterMode() const;
416 XclExpAutofilter
* GetByCol( SCCOL nCol
); // always 0-based
417 bool IsFiltered( SCCOL nCol
);
420 typedef XclExpRecordList
< XclExpAutofilter
> XclExpAutofilterList
;
421 typedef XclExpAutofilterList::RecordRefType XclExpAutofilterRef
;
423 XclExpAutofilterList maFilterList
;
424 XclExpFiltermode
* pFilterMode
;
425 XclExpAutofilterinfo
* pFilterInfo
;
430 /** Sheet filter manager. Contains auto filters or advanced filters from all sheets. */
431 class XclExpFilterManager
: protected XclExpRoot
434 explicit XclExpFilterManager( const XclExpRoot
& rRoot
);
436 /** Creates the filter records for the specified sheet.
437 @descr Creates and inserts related built-in NAME records. Therefore this
438 function is called from the name buffer itself. */
439 void InitTabFilter( SCTAB nScTab
);
441 /** Returns a record object containing all filter records for the specified sheet. */
442 XclExpRecordRef
CreateRecord( SCTAB nScTab
);
444 /** Returns whether or not FilterMode is present */
445 bool HasFilterMode( SCTAB nScTab
);
448 using XclExpRoot::CreateRecord
;
450 typedef std::shared_ptr
< ExcAutoFilterRecs
> XclExpTabFilterRef
;
451 typedef ::std::map
< SCTAB
, XclExpTabFilterRef
> XclExpTabFilterMap
;
453 XclExpTabFilterMap maFilterMap
;
458 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */