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 ExcFngroupcount -
215 class ExcFngroupcount
: public ExcRecord
218 virtual void SaveCont( XclExpStream
& rStrm
);
220 virtual UINT16
GetNum( void ) const;
221 virtual sal_Size
GetLen( void ) const;
225 //--------------------------------------------------------- class ExcDummy_00 -
226 // INTERFACEHDR to FNGROUPCOUNT (see excrecds.cxx)
228 class ExcDummy_00
: public ExcDummyRec
231 static const BYTE pMyData
[];
232 static const sal_Size nMyLen
;
234 virtual sal_Size
GetLen( void ) const;
235 virtual const BYTE
* GetData( void ) const;
238 // EXC_ID_WINDOWPROTECTION
239 class XclExpWindowProtection
: public XclExpBoolRecord
242 XclExpWindowProtection(bool bValue
);
244 virtual void SaveXml( XclExpXmlStream
& rStrm
);
247 // EXC_ID_PROTECT Document Protection
248 class XclExpProtection
: public XclExpBoolRecord
251 XclExpProtection(bool bValue
);
254 class XclExpPassHash
: public XclExpRecord
257 XclExpPassHash(const ::com::sun::star::uno::Sequence
<sal_Int8
>& aHash
);
258 virtual ~XclExpPassHash();
261 virtual void WriteBody(XclExpStream
& rStrm
);
268 //-------------------------------------------------------- class ExcDummy_04x -
269 // PASSWORD to BOOKBOOL (see excrecds.cxx), no 1904
271 class ExcDummy_040
: 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;
283 class ExcDummy_041
: public ExcDummyRec
286 static const BYTE pMyData
[];
287 static const sal_Size nMyLen
;
289 virtual sal_Size
GetLen( void ) const;
290 virtual const BYTE
* GetData( void ) const;
294 //------------------------------------------------------------- class Exc1904 -
296 class Exc1904
: public ExcBoolRecord
299 Exc1904( ScDocument
& rDoc
);
300 virtual UINT16
GetNum( void ) const;
302 virtual void SaveXml( XclExpXmlStream
& rStrm
);
306 //------------------------------------------------------ class ExcBundlesheet -
308 class ExcBundlesheetBase
: public ExcRecord
312 sal_Size nOwnPos
; // Position NACH # und Len
316 ExcBundlesheetBase();
319 ExcBundlesheetBase( RootData
& rRootData
, SCTAB nTab
);
321 inline void SetStreamPos( sal_Size nNewStrPos
) { nStrPos
= nNewStrPos
; }
322 void UpdateStreamPos( XclExpStream
& rStrm
);
324 virtual UINT16
GetNum() const;
329 class ExcBundlesheet
: public ExcBundlesheetBase
334 virtual void SaveCont( XclExpStream
& rStrm
);
337 ExcBundlesheet( RootData
& rRootData
, SCTAB nTab
);
338 virtual sal_Size
GetLen() const;
341 //--------------------------------------------------------- class ExcDummy_02 -
342 // sheet dummies: CALCMODE to SETUP
344 class ExcDummy_02a
: public ExcDummyRec
347 static const BYTE pMyData
[];
348 static const sal_Size nMyLen
;
350 virtual sal_Size
GetLen( void ) const;
351 virtual const BYTE
* GetData( void ) const;
355 // ----------------------------------------------------------------------------
357 /** This record contains the Windows country IDs for the UI and document language. */
358 class XclExpCountry
: public XclExpRecord
361 explicit XclExpCountry( const XclExpRoot
& rRoot
);
364 sal_uInt16 mnUICountry
; /// The UI country ID.
365 sal_uInt16 mnDocCountry
; /// The document country ID.
367 /** Writes the body of the COUNTRY record. */
368 virtual void WriteBody( XclExpStream
& rStrm
);
372 // XclExpWsbool ===============================================================
374 class XclExpWsbool
: public XclExpUInt16Record
377 explicit XclExpWsbool( bool bFitToPages
, SCTAB nScTab
= -1, XclExpFilterManager
* pManager
= NULL
);
379 virtual void SaveXml( XclExpXmlStream
& rStrm
);
382 XclExpFilterManager
* mpManager
;
386 // ============================================================================
388 class XclExpFiltermode
: public XclExpEmptyRecord
391 explicit XclExpFiltermode();
394 // ----------------------------------------------------------------------------
396 class XclExpAutofilterinfo
: public XclExpUInt16Record
399 explicit XclExpAutofilterinfo( const ScAddress
& rStartPos
, SCCOL nScCol
);
401 inline const ScAddress
GetStartPos() const { return maStartPos
; }
402 inline SCCOL
GetColCount() const { return static_cast< SCCOL
>( GetValue() ); }
405 ScAddress maStartPos
;
408 // ----------------------------------------------------------------------------
410 class ExcFilterCondition
420 ExcFilterCondition();
421 ~ExcFilterCondition();
423 inline BOOL
IsEmpty() const { return (nType
== EXC_AFTYPE_NOTUSED
); }
424 inline BOOL
HasEqual() const { return (nOper
== EXC_AFOPER_EQUAL
); }
425 ULONG
GetTextBytes() const;
427 void SetCondition( UINT8 nTp
, UINT8 nOp
, double fV
, String
* pT
);
429 void Save( XclExpStream
& rStrm
);
430 void SaveXml( XclExpXmlStream
& rStrm
);
431 void SaveText( XclExpStream
& rStrm
);
434 // ----------------------------------------------------------------------------
436 class XclExpAutofilter
: public XclExpRecord
, protected XclExpRoot
441 ExcFilterCondition aCond
[ 2 ];
443 BOOL
AddCondition( ScQueryConnect eConn
, UINT8 nType
,
444 UINT8 nOp
, double fVal
, String
* pText
,
445 BOOL bSimple
= FALSE
);
447 virtual void WriteBody( XclExpStream
& rStrm
);
451 XclExpAutofilter( const XclExpRoot
& rRoot
, UINT16 nC
);
453 inline UINT16
GetCol() const { return nCol
; }
454 inline BOOL
HasCondition() const { return !aCond
[ 0 ].IsEmpty(); }
455 inline BOOL
HasTop10() const { return ::get_flag( nFlags
, EXC_AFFLAG_TOP10
); }
457 BOOL
AddEntry( const ScQueryEntry
& rEntry
);
459 virtual void SaveXml( XclExpXmlStream
& rStrm
);
462 // ----------------------------------------------------------------------------
464 class ExcAutoFilterRecs
: public XclExpRecordBase
, protected XclExpRoot
467 explicit ExcAutoFilterRecs( const XclExpRoot
& rRoot
, SCTAB nTab
);
468 virtual ~ExcAutoFilterRecs();
472 virtual void Save( XclExpStream
& rStrm
);
473 virtual void SaveXml( XclExpXmlStream
& rStrm
);
475 bool HasFilterMode() const;
478 XclExpAutofilter
* GetByCol( SCCOL nCol
); // always 0-based
479 BOOL
IsFiltered( SCCOL nCol
);
482 typedef XclExpRecordList
< XclExpAutofilter
> XclExpAutofilterList
;
483 typedef XclExpAutofilterList::RecordRefType XclExpAutofilterRef
;
485 XclExpAutofilterList maFilterList
;
486 XclExpFiltermode
* pFilterMode
;
487 XclExpAutofilterinfo
* pFilterInfo
;
491 // ----------------------------------------------------------------------------
493 /** Sheet filter manager. Contains auto filters or advanced filters from all sheets. */
494 class XclExpFilterManager
: protected XclExpRoot
497 explicit XclExpFilterManager( const XclExpRoot
& rRoot
);
499 /** Creates the filter records for the specified sheet.
500 @descr Creates and inserts related built-in NAME records. Therefore this
501 function is called from the name buffer itself. */
502 void InitTabFilter( SCTAB nScTab
);
504 /** Returns a record object containing all filter records for the specified sheet. */
505 XclExpRecordRef
CreateRecord( SCTAB nScTab
);
507 /** Returns whether or not FilterMode is present */
508 bool HasFilterMode( SCTAB nScTab
);
511 using XclExpRoot::CreateRecord
;
513 typedef ScfRef
< ExcAutoFilterRecs
> XclExpTabFilterRef
;
514 typedef ::std::map
< SCTAB
, XclExpTabFilterRef
> XclExpTabFilterMap
;
516 XclExpTabFilterMap maFilterMap
;