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
) {}
152 ExcBoolRecord( SfxItemSet
*, USHORT nWhich
, BOOL bDefault
);
154 virtual sal_Size
GetLen( void ) const;
158 //--------------------------------------------------------- class ExcBof_Base -
160 class ExcBof_Base
: public ExcRecord
173 //-------------------------------------------------------------- class ExcBof -
174 // Header Record fuer WORKSHEETS
176 class ExcBof
: public ExcBof_Base
179 virtual void SaveCont( XclExpStream
& rStrm
);
183 virtual UINT16
GetNum( void ) const;
184 virtual sal_Size
GetLen( void ) const;
188 //------------------------------------------------------------- class ExcBofW -
189 // Header Record fuer WORKBOOKS
191 class ExcBofW
: public ExcBof_Base
194 virtual void SaveCont( XclExpStream
& rStrm
);
198 virtual UINT16
GetNum( void ) const;
199 virtual sal_Size
GetLen( void ) const;
203 //-------------------------------------------------------------- class ExcEof -
205 class ExcEof
: public ExcRecord
209 virtual UINT16
GetNum( void ) const;
210 virtual sal_Size
GetLen( void ) const;
214 //----------------------------------------------------- class ExcFngroupcount -
216 class ExcFngroupcount
: public ExcRecord
219 virtual void SaveCont( XclExpStream
& rStrm
);
221 virtual UINT16
GetNum( void ) const;
222 virtual sal_Size
GetLen( void ) const;
226 //--------------------------------------------------------- class ExcDummy_00 -
227 // INTERFACEHDR to FNGROUPCOUNT (see excrecds.cxx)
229 class ExcDummy_00
: public ExcDummyRec
232 static const BYTE pMyData
[];
233 static const sal_Size nMyLen
;
235 virtual sal_Size
GetLen( void ) const;
236 virtual const BYTE
* GetData( void ) const;
239 // EXC_ID_WINDOWPROTECTION
240 class XclExpWindowProtection
: public XclExpBoolRecord
243 XclExpWindowProtection(bool bValue
);
245 virtual void SaveXml( XclExpXmlStream
& rStrm
);
248 // EXC_ID_PROTECT Document Protection
249 class XclExpProtection
: public XclExpBoolRecord
252 XclExpProtection(bool bValue
);
255 class XclExpPassHash
: public XclExpRecord
258 XclExpPassHash(const ::com::sun::star::uno::Sequence
<sal_Int8
>& aHash
);
259 virtual ~XclExpPassHash();
262 virtual void WriteBody(XclExpStream
& rStrm
);
269 //-------------------------------------------------------- class ExcDummy_04x -
270 // PASSWORD to BOOKBOOL (see excrecds.cxx), no 1904
272 class ExcDummy_040
: public ExcDummyRec
275 static const BYTE pMyData
[];
276 static const sal_Size nMyLen
;
278 virtual sal_Size
GetLen( void ) const;
279 virtual const BYTE
* GetData( void ) const;
284 class ExcDummy_041
: public ExcDummyRec
287 static const BYTE pMyData
[];
288 static const sal_Size nMyLen
;
290 virtual sal_Size
GetLen( void ) const;
291 virtual const BYTE
* GetData( void ) const;
295 //------------------------------------------------------------- class Exc1904 -
297 class Exc1904
: public ExcBoolRecord
300 Exc1904( ScDocument
& rDoc
);
301 virtual UINT16
GetNum( void ) const;
303 virtual void SaveXml( XclExpXmlStream
& rStrm
);
307 //------------------------------------------------------ class ExcBundlesheet -
309 class ExcBundlesheetBase
: public ExcRecord
313 sal_Size nOwnPos
; // Position NACH # und Len
317 ExcBundlesheetBase();
320 ExcBundlesheetBase( RootData
& rRootData
, SCTAB nTab
);
322 inline void SetStreamPos( sal_Size nNewStrPos
) { nStrPos
= nNewStrPos
; }
323 void UpdateStreamPos( XclExpStream
& rStrm
);
325 virtual UINT16
GetNum() const;
330 class ExcBundlesheet
: public ExcBundlesheetBase
335 virtual void SaveCont( XclExpStream
& rStrm
);
338 ExcBundlesheet( RootData
& rRootData
, SCTAB nTab
);
339 virtual sal_Size
GetLen() const;
342 //--------------------------------------------------------- class ExcDummy_02 -
343 // sheet dummies: CALCMODE to SETUP
345 class ExcDummy_02a
: public ExcDummyRec
348 static const BYTE pMyData
[];
349 static const sal_Size nMyLen
;
351 virtual sal_Size
GetLen( void ) const;
352 virtual const BYTE
* GetData( void ) const;
356 // ----------------------------------------------------------------------------
358 /** This record contains the Windows country IDs for the UI and document language. */
359 class XclExpCountry
: public XclExpRecord
362 explicit XclExpCountry( const XclExpRoot
& rRoot
);
365 sal_uInt16 mnUICountry
; /// The UI country ID.
366 sal_uInt16 mnDocCountry
; /// The document country ID.
368 /** Writes the body of the COUNTRY record. */
369 virtual void WriteBody( XclExpStream
& rStrm
);
373 // XclExpWsbool ===============================================================
375 class XclExpWsbool
: public XclExpUInt16Record
378 explicit XclExpWsbool( bool bFitToPages
, SCTAB nScTab
= -1, XclExpFilterManager
* pManager
= NULL
);
380 virtual void SaveXml( XclExpXmlStream
& rStrm
);
383 XclExpFilterManager
* mpManager
;
387 // ============================================================================
389 class XclExpFiltermode
: public XclExpEmptyRecord
392 explicit XclExpFiltermode();
395 // ----------------------------------------------------------------------------
397 class XclExpAutofilterinfo
: public XclExpUInt16Record
400 explicit XclExpAutofilterinfo( const ScAddress
& rStartPos
, SCCOL nScCol
);
402 inline const ScAddress
GetStartPos() const { return maStartPos
; }
403 inline SCCOL
GetColCount() const { return static_cast< SCCOL
>( GetValue() ); }
406 ScAddress maStartPos
;
409 // ----------------------------------------------------------------------------
411 class ExcFilterCondition
421 ExcFilterCondition();
422 ~ExcFilterCondition();
424 inline BOOL
IsEmpty() const { return (nType
== EXC_AFTYPE_NOTUSED
); }
425 inline BOOL
HasEqual() const { return (nOper
== EXC_AFOPER_EQUAL
); }
426 ULONG
GetTextBytes() const;
428 void SetCondition( UINT8 nTp
, UINT8 nOp
, double fV
, String
* pT
);
430 void Save( XclExpStream
& rStrm
);
431 void SaveXml( XclExpXmlStream
& rStrm
);
432 void SaveText( XclExpStream
& rStrm
);
435 // ----------------------------------------------------------------------------
437 class XclExpAutofilter
: public XclExpRecord
, protected XclExpRoot
442 ExcFilterCondition aCond
[ 2 ];
444 BOOL
AddCondition( ScQueryConnect eConn
, UINT8 nType
,
445 UINT8 nOp
, double fVal
, String
* pText
,
446 BOOL bSimple
= FALSE
);
448 virtual void WriteBody( XclExpStream
& rStrm
);
452 XclExpAutofilter( const XclExpRoot
& rRoot
, UINT16 nC
);
454 inline UINT16
GetCol() const { return nCol
; }
455 inline BOOL
HasCondition() const { return !aCond
[ 0 ].IsEmpty(); }
456 inline BOOL
HasTop10() const { return ::get_flag( nFlags
, EXC_AFFLAG_TOP10
); }
458 BOOL
AddEntry( const ScQueryEntry
& rEntry
, const ScQueryParam
& rParam
);
460 virtual void SaveXml( XclExpXmlStream
& rStrm
);
463 // ----------------------------------------------------------------------------
465 class ExcAutoFilterRecs
: public XclExpRecordBase
, protected XclExpRoot
468 explicit ExcAutoFilterRecs( const XclExpRoot
& rRoot
, SCTAB nTab
);
469 virtual ~ExcAutoFilterRecs();
473 virtual void Save( XclExpStream
& rStrm
);
474 virtual void SaveXml( XclExpXmlStream
& rStrm
);
476 bool HasFilterMode() const;
479 XclExpAutofilter
* GetByCol( SCCOL nCol
); // always 0-based
480 BOOL
IsFiltered( SCCOL nCol
);
483 typedef XclExpRecordList
< XclExpAutofilter
> XclExpAutofilterList
;
484 typedef XclExpAutofilterList::RecordRefType XclExpAutofilterRef
;
486 XclExpAutofilterList maFilterList
;
487 XclExpFiltermode
* pFilterMode
;
488 XclExpAutofilterinfo
* pFilterInfo
;
492 // ----------------------------------------------------------------------------
494 /** Sheet filter manager. Contains auto filters or advanced filters from all sheets. */
495 class XclExpFilterManager
: protected XclExpRoot
498 explicit XclExpFilterManager( const XclExpRoot
& rRoot
);
500 /** Creates the filter records for the specified sheet.
501 @descr Creates and inserts related built-in NAME records. Therefore this
502 function is called from the name buffer itself. */
503 void InitTabFilter( SCTAB nScTab
);
505 /** Returns a record object containing all filter records for the specified sheet. */
506 XclExpRecordRef
CreateRecord( SCTAB nScTab
);
508 /** Returns whether or not FilterMode is present */
509 bool HasFilterMode( SCTAB nScTab
);
512 using XclExpRoot::CreateRecord
;
514 typedef ScfRef
< ExcAutoFilterRecs
> XclExpTabFilterRef
;
515 typedef ::std::map
< SCTAB
, XclExpTabFilterRef
> XclExpTabFilterMap
;
517 XclExpTabFilterMap maFilterMap
;