1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: excrecds.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_EXCRECDS_HXX
32 #define SC_EXCRECDS_HXX
34 #include <tools/solar.h>
35 #include <svtools/zforlist.hxx>
36 #include <tools/string.hxx>
37 #include <vcl/vclenum.hxx>
38 #include <tools/color.hxx>
42 #include "olinetab.hxx"
44 #include "rangelst.hxx"
45 #include "xerecord.hxx"
47 #include "xeformula.hxx"
48 #include "xestring.hxx"
50 #include "excdefs.hxx"
53 //------------------------------------------------------------------ Forwards -
72 //----------------------------------------------------------- class ExcRecord -
74 class ExcRecord
: public XclExpRecord
77 virtual void Save( XclExpStream
& rStrm
);
79 virtual UINT16
GetNum() const = 0;
80 virtual sal_Size
GetLen() const = 0;
83 virtual void SaveCont( XclExpStream
& rStrm
);
86 /** Writes the body of the record. */
87 virtual void WriteBody( XclExpStream
& rStrm
);
91 //--------------------------------------------------------- class ExcEmptyRec -
93 class ExcEmptyRec
: public ExcRecord
98 virtual void Save( XclExpStream
& rStrm
);
99 virtual UINT16
GetNum() const;
100 virtual sal_Size
GetLen() const;
104 //------------------------------------------------------- class ExcRecordList -
106 class ExcRecordList
: protected List
, public ExcEmptyRec
111 virtual ~ExcRecordList();
115 inline ExcRecord
* First( void ) { return ( ExcRecord
* ) List::First(); }
116 inline ExcRecord
* Next( void ) { return ( ExcRecord
* ) List::Next(); }
118 inline void Append( ExcRecord
* pNew
) { if( pNew
) List::Insert( pNew
, LIST_APPEND
); }
119 inline const ExcRecord
* Get( UINT32 nNum
) const { return ( ExcRecord
* ) List::GetObject( nNum
); }
121 virtual void Save( XclExpStream
& rStrm
);
125 //--------------------------------------------------------- class ExcDummyRec -
127 class ExcDummyRec
: public ExcRecord
131 virtual void Save( XclExpStream
& rStrm
);
132 virtual UINT16
GetNum() const;
133 virtual const BYTE
* GetData() const = 0; // byte data must contain header and body
137 //------------------------------------------------------- class ExcBoolRecord -
138 // stores BOOL as 16bit val ( 0x0000 | 0x0001 )
140 class ExcBoolRecord
: public ExcRecord
143 virtual void SaveCont( XclExpStream
& rStrm
);
148 inline ExcBoolRecord() : bVal( FALSE
) {}
151 inline ExcBoolRecord( const BOOL bDefault
) : bVal( bDefault
) {}
153 virtual sal_Size
GetLen( void ) const;
157 //--------------------------------------------------------- class ExcBof_Base -
159 class ExcBof_Base
: public ExcRecord
172 //-------------------------------------------------------------- class ExcBof -
173 // Header Record fuer WORKSHEETS
175 class ExcBof
: public ExcBof_Base
178 virtual void SaveCont( XclExpStream
& rStrm
);
182 virtual UINT16
GetNum( void ) const;
183 virtual sal_Size
GetLen( void ) const;
187 //------------------------------------------------------------- class ExcBofW -
188 // Header Record fuer WORKBOOKS
190 class ExcBofW
: public ExcBof_Base
193 virtual void SaveCont( XclExpStream
& rStrm
);
197 virtual UINT16
GetNum( void ) const;
198 virtual sal_Size
GetLen( void ) const;
202 //-------------------------------------------------------------- class ExcEof -
204 class ExcEof
: public ExcRecord
208 virtual UINT16
GetNum( void ) const;
209 virtual sal_Size
GetLen( void ) const;
213 //--------------------------------------------------------- class ExcDummy_00 -
214 // INTERFACEHDR to FNGROUPCOUNT (see excrecds.cxx)
216 class ExcDummy_00
: public ExcDummyRec
219 static const BYTE pMyData
[];
220 static const sal_Size nMyLen
;
222 virtual sal_Size
GetLen( void ) const;
223 virtual const BYTE
* GetData( void ) const;
226 // EXC_ID_WINDOWPROTECTION
227 class XclExpWindowProtection
: public XclExpBoolRecord
230 XclExpWindowProtection(bool bValue
);
232 virtual void SaveXml( XclExpXmlStream
& rStrm
);
235 // EXC_ID_PROTECT Document Protection
236 class XclExpProtection
: public XclExpBoolRecord
239 XclExpProtection(bool bValue
);
242 class XclExpPassHash
: public XclExpRecord
245 XclExpPassHash(const ::com::sun::star::uno::Sequence
<sal_Int8
>& aHash
);
246 virtual ~XclExpPassHash();
249 virtual void WriteBody(XclExpStream
& rStrm
);
256 //-------------------------------------------------------- class ExcDummy_04x -
257 // PASSWORD to BOOKBOOL (see excrecds.cxx), no 1904
259 class ExcDummy_040
: public ExcDummyRec
262 static const BYTE pMyData
[];
263 static const sal_Size nMyLen
;
265 virtual sal_Size
GetLen( void ) const;
266 virtual const BYTE
* GetData( void ) const;
271 class ExcDummy_041
: public ExcDummyRec
274 static const BYTE pMyData
[];
275 static const sal_Size nMyLen
;
277 virtual sal_Size
GetLen( void ) const;
278 virtual const BYTE
* GetData( void ) const;
282 //------------------------------------------------------------- class Exc1904 -
284 class Exc1904
: public ExcBoolRecord
287 Exc1904( ScDocument
& rDoc
);
288 virtual UINT16
GetNum( void ) const;
290 virtual void SaveXml( XclExpXmlStream
& rStrm
);
294 //------------------------------------------------------ class ExcBundlesheet -
296 class ExcBundlesheetBase
: public ExcRecord
300 sal_Size nOwnPos
; // Position NACH # und Len
304 ExcBundlesheetBase();
307 ExcBundlesheetBase( RootData
& rRootData
, SCTAB nTab
);
309 inline void SetStreamPos( sal_Size nNewStrPos
) { nStrPos
= nNewStrPos
; }
310 void UpdateStreamPos( XclExpStream
& rStrm
);
312 virtual UINT16
GetNum() const;
317 class ExcBundlesheet
: public ExcBundlesheetBase
322 virtual void SaveCont( XclExpStream
& rStrm
);
325 ExcBundlesheet( RootData
& rRootData
, SCTAB nTab
);
326 virtual sal_Size
GetLen() const;
329 //--------------------------------------------------------- class ExcDummy_02 -
330 // sheet dummies: CALCMODE to SETUP
332 class ExcDummy_02a
: public ExcDummyRec
335 static const BYTE pMyData
[];
336 static const sal_Size nMyLen
;
338 virtual sal_Size
GetLen( void ) const;
339 virtual const BYTE
* GetData( void ) const;
343 // ----------------------------------------------------------------------------
345 /** This record contains the Windows country IDs for the UI and document language. */
346 class XclExpCountry
: public XclExpRecord
349 explicit XclExpCountry( const XclExpRoot
& rRoot
);
352 sal_uInt16 mnUICountry
; /// The UI country ID.
353 sal_uInt16 mnDocCountry
; /// The document country ID.
355 /** Writes the body of the COUNTRY record. */
356 virtual void WriteBody( XclExpStream
& rStrm
);
360 // XclExpWsbool ===============================================================
362 class XclExpWsbool
: public XclExpUInt16Record
365 explicit XclExpWsbool( bool bFitToPages
, SCTAB nScTab
= -1, XclExpFilterManager
* pManager
= NULL
);
367 virtual void SaveXml( XclExpXmlStream
& rStrm
);
370 XclExpFilterManager
* mpManager
;
374 // ============================================================================
376 class XclExpFiltermode
: public XclExpEmptyRecord
379 explicit XclExpFiltermode();
382 // ----------------------------------------------------------------------------
384 class XclExpAutofilterinfo
: public XclExpUInt16Record
387 explicit XclExpAutofilterinfo( const ScAddress
& rStartPos
, SCCOL nScCol
);
389 inline const ScAddress
GetStartPos() const { return maStartPos
; }
390 inline SCCOL
GetColCount() const { return static_cast< SCCOL
>( GetValue() ); }
393 ScAddress maStartPos
;
396 // ----------------------------------------------------------------------------
398 class ExcFilterCondition
408 ExcFilterCondition();
409 ~ExcFilterCondition();
411 inline BOOL
IsEmpty() const { return (nType
== EXC_AFTYPE_NOTUSED
); }
412 inline BOOL
HasEqual() const { return (nOper
== EXC_AFOPER_EQUAL
); }
413 ULONG
GetTextBytes() const;
415 void SetCondition( UINT8 nTp
, UINT8 nOp
, double fV
, String
* pT
);
417 void Save( XclExpStream
& rStrm
);
418 void SaveXml( XclExpXmlStream
& rStrm
);
419 void SaveText( XclExpStream
& rStrm
);
422 // ----------------------------------------------------------------------------
424 class XclExpAutofilter
: public XclExpRecord
, protected XclExpRoot
429 ExcFilterCondition aCond
[ 2 ];
431 BOOL
AddCondition( ScQueryConnect eConn
, UINT8 nType
,
432 UINT8 nOp
, double fVal
, String
* pText
,
433 BOOL bSimple
= FALSE
);
435 virtual void WriteBody( XclExpStream
& rStrm
);
439 XclExpAutofilter( const XclExpRoot
& rRoot
, UINT16 nC
);
441 inline UINT16
GetCol() const { return nCol
; }
442 inline BOOL
HasCondition() const { return !aCond
[ 0 ].IsEmpty(); }
443 inline BOOL
HasTop10() const { return ::get_flag( nFlags
, EXC_AFFLAG_TOP10
); }
445 BOOL
AddEntry( const ScQueryEntry
& rEntry
);
447 virtual void SaveXml( XclExpXmlStream
& rStrm
);
450 // ----------------------------------------------------------------------------
452 class ExcAutoFilterRecs
: public XclExpRecordBase
, protected XclExpRoot
455 explicit ExcAutoFilterRecs( const XclExpRoot
& rRoot
, SCTAB nTab
);
456 virtual ~ExcAutoFilterRecs();
460 virtual void Save( XclExpStream
& rStrm
);
461 virtual void SaveXml( XclExpXmlStream
& rStrm
);
463 bool HasFilterMode() const;
466 XclExpAutofilter
* GetByCol( SCCOL nCol
); // always 0-based
467 BOOL
IsFiltered( SCCOL nCol
);
470 typedef XclExpRecordList
< XclExpAutofilter
> XclExpAutofilterList
;
471 typedef XclExpAutofilterList::RecordRefType XclExpAutofilterRef
;
473 XclExpAutofilterList maFilterList
;
474 XclExpFiltermode
* pFilterMode
;
475 XclExpAutofilterinfo
* pFilterInfo
;
479 // ----------------------------------------------------------------------------
481 /** Sheet filter manager. Contains auto filters or advanced filters from all sheets. */
482 class XclExpFilterManager
: protected XclExpRoot
485 explicit XclExpFilterManager( const XclExpRoot
& rRoot
);
487 /** Creates the filter records for the specified sheet.
488 @descr Creates and inserts related built-in NAME records. Therefore this
489 function is called from the name buffer itself. */
490 void InitTabFilter( SCTAB nScTab
);
492 /** Returns a record object containing all filter records for the specified sheet. */
493 XclExpRecordRef
CreateRecord( SCTAB nScTab
);
495 /** Returns whether or not FilterMode is present */
496 bool HasFilterMode( SCTAB nScTab
);
499 using XclExpRoot::CreateRecord
;
501 typedef ScfRef
< ExcAutoFilterRecs
> XclExpTabFilterRef
;
502 typedef ::std::map
< SCTAB
, XclExpTabFilterRef
> XclExpTabFilterMap
;
504 XclExpTabFilterMap maFilterMap
;