update ooo310-m15
[ooovba.git] / sc / source / filter / inc / excrecds.hxx
blobbb6a26f355af3a307634536df08cd5bff7e10e32
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 ) {}
152 ExcBoolRecord( SfxItemSet*, USHORT nWhich, BOOL bDefault );
154 virtual sal_Size GetLen( void ) const;
158 //--------------------------------------------------------- class ExcBof_Base -
160 class ExcBof_Base : public ExcRecord
162 private:
163 protected:
164 UINT16 nDocType;
165 UINT16 nVers;
166 UINT16 nRupBuild;
167 UINT16 nRupYear;
168 public:
169 ExcBof_Base( void );
173 //-------------------------------------------------------------- class ExcBof -
174 // Header Record fuer WORKSHEETS
176 class ExcBof : public ExcBof_Base
178 private:
179 virtual void SaveCont( XclExpStream& rStrm );
180 public:
181 ExcBof( void );
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
193 private:
194 virtual void SaveCont( XclExpStream& rStrm );
195 public:
196 ExcBofW( void );
198 virtual UINT16 GetNum( void ) const;
199 virtual sal_Size GetLen( void ) const;
203 //-------------------------------------------------------------- class ExcEof -
205 class ExcEof : public ExcRecord
207 private:
208 public:
209 virtual UINT16 GetNum( void ) const;
210 virtual sal_Size GetLen( void ) const;
214 //----------------------------------------------------- class ExcFngroupcount -
216 class ExcFngroupcount : public ExcRecord
218 private:
219 virtual void SaveCont( XclExpStream& rStrm );
220 public:
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
231 private:
232 static const BYTE pMyData[];
233 static const sal_Size nMyLen;
234 public:
235 virtual sal_Size GetLen( void ) const;
236 virtual const BYTE* GetData( void ) const;
239 // EXC_ID_WINDOWPROTECTION
240 class XclExpWindowProtection : public XclExpBoolRecord
242 public:
243 XclExpWindowProtection(bool bValue);
245 virtual void SaveXml( XclExpXmlStream& rStrm );
248 // EXC_ID_PROTECT Document Protection
249 class XclExpProtection : public XclExpBoolRecord
251 public:
252 XclExpProtection(bool bValue);
255 class XclExpPassHash : public XclExpRecord
257 public:
258 XclExpPassHash(const ::com::sun::star::uno::Sequence<sal_Int8>& aHash);
259 virtual ~XclExpPassHash();
261 private:
262 virtual void WriteBody(XclExpStream& rStrm);
264 private:
265 sal_uInt16 mnHash;
269 //-------------------------------------------------------- class ExcDummy_04x -
270 // PASSWORD to BOOKBOOL (see excrecds.cxx), no 1904
272 class ExcDummy_040 : public ExcDummyRec
274 private:
275 static const BYTE pMyData[];
276 static const sal_Size nMyLen;
277 public:
278 virtual sal_Size GetLen( void ) const;
279 virtual const BYTE* GetData( void ) const;
284 class ExcDummy_041 : public ExcDummyRec
286 private:
287 static const BYTE pMyData[];
288 static const sal_Size nMyLen;
289 public:
290 virtual sal_Size GetLen( void ) const;
291 virtual const BYTE* GetData( void ) const;
295 //------------------------------------------------------------- class Exc1904 -
297 class Exc1904 : public ExcBoolRecord
299 public:
300 Exc1904( ScDocument& rDoc );
301 virtual UINT16 GetNum( void ) const;
303 virtual void SaveXml( XclExpXmlStream& rStrm );
307 //------------------------------------------------------ class ExcBundlesheet -
309 class ExcBundlesheetBase : public ExcRecord
311 protected:
312 sal_Size nStrPos;
313 sal_Size nOwnPos; // Position NACH # und Len
314 UINT16 nGrbit;
315 SCTAB nTab;
317 ExcBundlesheetBase();
319 public:
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
332 private:
333 ByteString aName;
335 virtual void SaveCont( XclExpStream& rStrm );
337 public:
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
347 private:
348 static const BYTE pMyData[];
349 static const sal_Size nMyLen;
350 public:
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
361 public:
362 explicit XclExpCountry( const XclExpRoot& rRoot );
364 private:
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
377 public:
378 explicit XclExpWsbool( bool bFitToPages, SCTAB nScTab = -1, XclExpFilterManager* pManager = NULL );
380 virtual void SaveXml( XclExpXmlStream& rStrm );
381 private:
382 SCTAB mnScTab;
383 XclExpFilterManager* mpManager;
387 // ============================================================================
389 class XclExpFiltermode : public XclExpEmptyRecord
391 public:
392 explicit XclExpFiltermode();
395 // ----------------------------------------------------------------------------
397 class XclExpAutofilterinfo : public XclExpUInt16Record
399 public:
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() ); }
405 private:
406 ScAddress maStartPos;
409 // ----------------------------------------------------------------------------
411 class ExcFilterCondition
413 private:
414 UINT8 nType;
415 UINT8 nOper;
416 double fVal;
417 XclExpString* pText;
419 protected:
420 public:
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
439 private:
440 UINT16 nCol;
441 UINT16 nFlags;
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 );
450 protected:
451 public:
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
467 public:
468 explicit ExcAutoFilterRecs( const XclExpRoot& rRoot, SCTAB nTab );
469 virtual ~ExcAutoFilterRecs();
471 void AddObjRecs();
473 virtual void Save( XclExpStream& rStrm );
474 virtual void SaveXml( XclExpXmlStream& rStrm );
476 bool HasFilterMode() const;
478 private:
479 XclExpAutofilter* GetByCol( SCCOL nCol ); // always 0-based
480 BOOL IsFiltered( SCCOL nCol );
482 private:
483 typedef XclExpRecordList< XclExpAutofilter > XclExpAutofilterList;
484 typedef XclExpAutofilterList::RecordRefType XclExpAutofilterRef;
486 XclExpAutofilterList maFilterList;
487 XclExpFiltermode* pFilterMode;
488 XclExpAutofilterinfo* pFilterInfo;
489 ScRange maRef;
492 // ----------------------------------------------------------------------------
494 /** Sheet filter manager. Contains auto filters or advanced filters from all sheets. */
495 class XclExpFilterManager : protected XclExpRoot
497 public:
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 );
511 private:
512 using XclExpRoot::CreateRecord;
514 typedef ScfRef< ExcAutoFilterRecs > XclExpTabFilterRef;
515 typedef ::std::map< SCTAB, XclExpTabFilterRef > XclExpTabFilterMap;
517 XclExpTabFilterMap maFilterMap;
521 #endif