Update ooo320-m1
[ooovba.git] / sc / source / filter / inc / excrecds.hxx
blobba8a573575381cf0f2af7b22052203b76fb2f44d
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 $
10 * $Revision: 1.51 $
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>
41 #include <vector>
42 #include "olinetab.hxx"
43 #include "filter.hxx"
44 #include "rangelst.hxx"
45 #include "xerecord.hxx"
46 #include "xeroot.hxx"
47 #include "xeformula.hxx"
48 #include "xestring.hxx"
49 #include "root.hxx"
50 #include "excdefs.hxx"
51 #include "cell.hxx"
53 //------------------------------------------------------------------ Forwards -
55 class SvxBorderLine;
57 class SvStream;
58 class Font;
59 class List;
60 class ScPatternAttr;
61 class ScTokenArray;
62 class ScRangeData;
63 class ScDBData;
64 class ScEditCell;
65 class SfxItemSet;
66 class EditTextObject;
67 class ScPageHFItem;
68 class ScProgress;
70 class ExcTable;
72 //----------------------------------------------------------- class ExcRecord -
74 class ExcRecord : public XclExpRecord
76 public:
77 virtual void Save( XclExpStream& rStrm );
79 virtual UINT16 GetNum() const = 0;
80 virtual sal_Size GetLen() const = 0;
82 protected:
83 virtual void SaveCont( XclExpStream& rStrm );
85 private:
86 /** Writes the body of the record. */
87 virtual void WriteBody( XclExpStream& rStrm );
91 //--------------------------------------------------------- class ExcEmptyRec -
93 class ExcEmptyRec : public ExcRecord
95 private:
96 protected:
97 public:
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
108 private:
109 protected:
110 public:
111 virtual ~ExcRecordList();
113 using List::Count;
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
129 protected:
130 public:
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
142 private:
143 virtual void SaveCont( XclExpStream& rStrm );
145 protected:
146 BOOL bVal;
148 inline ExcBoolRecord() : bVal( FALSE ) {}
150 public:
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
161 private:
162 protected:
163 UINT16 nDocType;
164 UINT16 nVers;
165 UINT16 nRupBuild;
166 UINT16 nRupYear;
167 public:
168 ExcBof_Base( void );
172 //-------------------------------------------------------------- class ExcBof -
173 // Header Record fuer WORKSHEETS
175 class ExcBof : public ExcBof_Base
177 private:
178 virtual void SaveCont( XclExpStream& rStrm );
179 public:
180 ExcBof( void );
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
192 private:
193 virtual void SaveCont( XclExpStream& rStrm );
194 public:
195 ExcBofW( void );
197 virtual UINT16 GetNum( void ) const;
198 virtual sal_Size GetLen( void ) const;
202 //-------------------------------------------------------------- class ExcEof -
204 class ExcEof : public ExcRecord
206 private:
207 public:
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
218 private:
219 static const BYTE pMyData[];
220 static const sal_Size nMyLen;
221 public:
222 virtual sal_Size GetLen( void ) const;
223 virtual const BYTE* GetData( void ) const;
226 // EXC_ID_WINDOWPROTECTION
227 class XclExpWindowProtection : public XclExpBoolRecord
229 public:
230 XclExpWindowProtection(bool bValue);
232 virtual void SaveXml( XclExpXmlStream& rStrm );
235 // EXC_ID_PROTECT Document Protection
236 class XclExpProtection : public XclExpBoolRecord
238 public:
239 XclExpProtection(bool bValue);
242 class XclExpPassHash : public XclExpRecord
244 public:
245 XclExpPassHash(const ::com::sun::star::uno::Sequence<sal_Int8>& aHash);
246 virtual ~XclExpPassHash();
248 private:
249 virtual void WriteBody(XclExpStream& rStrm);
251 private:
252 sal_uInt16 mnHash;
256 //-------------------------------------------------------- class ExcDummy_04x -
257 // PASSWORD to BOOKBOOL (see excrecds.cxx), no 1904
259 class ExcDummy_040 : public ExcDummyRec
261 private:
262 static const BYTE pMyData[];
263 static const sal_Size nMyLen;
264 public:
265 virtual sal_Size GetLen( void ) const;
266 virtual const BYTE* GetData( void ) const;
271 class ExcDummy_041 : public ExcDummyRec
273 private:
274 static const BYTE pMyData[];
275 static const sal_Size nMyLen;
276 public:
277 virtual sal_Size GetLen( void ) const;
278 virtual const BYTE* GetData( void ) const;
282 //------------------------------------------------------------- class Exc1904 -
284 class Exc1904 : public ExcBoolRecord
286 public:
287 Exc1904( ScDocument& rDoc );
288 virtual UINT16 GetNum( void ) const;
290 virtual void SaveXml( XclExpXmlStream& rStrm );
294 //------------------------------------------------------ class ExcBundlesheet -
296 class ExcBundlesheetBase : public ExcRecord
298 protected:
299 sal_Size nStrPos;
300 sal_Size nOwnPos; // Position NACH # und Len
301 UINT16 nGrbit;
302 SCTAB nTab;
304 ExcBundlesheetBase();
306 public:
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
319 private:
320 ByteString aName;
322 virtual void SaveCont( XclExpStream& rStrm );
324 public:
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
334 private:
335 static const BYTE pMyData[];
336 static const sal_Size nMyLen;
337 public:
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
348 public:
349 explicit XclExpCountry( const XclExpRoot& rRoot );
351 private:
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
364 public:
365 explicit XclExpWsbool( bool bFitToPages, SCTAB nScTab = -1, XclExpFilterManager* pManager = NULL );
367 virtual void SaveXml( XclExpXmlStream& rStrm );
368 private:
369 SCTAB mnScTab;
370 XclExpFilterManager* mpManager;
374 // ============================================================================
376 class XclExpFiltermode : public XclExpEmptyRecord
378 public:
379 explicit XclExpFiltermode();
382 // ----------------------------------------------------------------------------
384 class XclExpAutofilterinfo : public XclExpUInt16Record
386 public:
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() ); }
392 private:
393 ScAddress maStartPos;
396 // ----------------------------------------------------------------------------
398 class ExcFilterCondition
400 private:
401 UINT8 nType;
402 UINT8 nOper;
403 double fVal;
404 XclExpString* pText;
406 protected:
407 public:
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
426 private:
427 UINT16 nCol;
428 UINT16 nFlags;
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 );
437 protected:
438 public:
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
454 public:
455 explicit ExcAutoFilterRecs( const XclExpRoot& rRoot, SCTAB nTab );
456 virtual ~ExcAutoFilterRecs();
458 void AddObjRecs();
460 virtual void Save( XclExpStream& rStrm );
461 virtual void SaveXml( XclExpXmlStream& rStrm );
463 bool HasFilterMode() const;
465 private:
466 XclExpAutofilter* GetByCol( SCCOL nCol ); // always 0-based
467 BOOL IsFiltered( SCCOL nCol );
469 private:
470 typedef XclExpRecordList< XclExpAutofilter > XclExpAutofilterList;
471 typedef XclExpAutofilterList::RecordRefType XclExpAutofilterRef;
473 XclExpAutofilterList maFilterList;
474 XclExpFiltermode* pFilterMode;
475 XclExpAutofilterinfo* pFilterInfo;
476 ScRange maRef;
479 // ----------------------------------------------------------------------------
481 /** Sheet filter manager. Contains auto filters or advanced filters from all sheets. */
482 class XclExpFilterManager : protected XclExpRoot
484 public:
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 );
498 private:
499 using XclExpRoot::CreateRecord;
501 typedef ScfRef< ExcAutoFilterRecs > XclExpTabFilterRef;
502 typedef ::std::map< SCTAB, XclExpTabFilterRef > XclExpTabFilterMap;
504 XclExpTabFilterMap maFilterMap;
508 #endif