update dev300-m58
[ooovba.git] / sc / source / filter / inc / excrecds.hxx
blobe668114c7fcc549f7fe2fe5a0a2460e58e3caa21
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 ExcFngroupcount -
215 class ExcFngroupcount : public ExcRecord
217 private:
218 virtual void SaveCont( XclExpStream& rStrm );
219 public:
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
230 private:
231 static const BYTE pMyData[];
232 static const sal_Size nMyLen;
233 public:
234 virtual sal_Size GetLen( void ) const;
235 virtual const BYTE* GetData( void ) const;
238 // EXC_ID_WINDOWPROTECTION
239 class XclExpWindowProtection : public XclExpBoolRecord
241 public:
242 XclExpWindowProtection(bool bValue);
244 virtual void SaveXml( XclExpXmlStream& rStrm );
247 // EXC_ID_PROTECT Document Protection
248 class XclExpProtection : public XclExpBoolRecord
250 public:
251 XclExpProtection(bool bValue);
254 class XclExpPassHash : public XclExpRecord
256 public:
257 XclExpPassHash(const ::com::sun::star::uno::Sequence<sal_Int8>& aHash);
258 virtual ~XclExpPassHash();
260 private:
261 virtual void WriteBody(XclExpStream& rStrm);
263 private:
264 sal_uInt16 mnHash;
268 //-------------------------------------------------------- class ExcDummy_04x -
269 // PASSWORD to BOOKBOOL (see excrecds.cxx), no 1904
271 class ExcDummy_040 : 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;
283 class ExcDummy_041 : public ExcDummyRec
285 private:
286 static const BYTE pMyData[];
287 static const sal_Size nMyLen;
288 public:
289 virtual sal_Size GetLen( void ) const;
290 virtual const BYTE* GetData( void ) const;
294 //------------------------------------------------------------- class Exc1904 -
296 class Exc1904 : public ExcBoolRecord
298 public:
299 Exc1904( ScDocument& rDoc );
300 virtual UINT16 GetNum( void ) const;
302 virtual void SaveXml( XclExpXmlStream& rStrm );
306 //------------------------------------------------------ class ExcBundlesheet -
308 class ExcBundlesheetBase : public ExcRecord
310 protected:
311 sal_Size nStrPos;
312 sal_Size nOwnPos; // Position NACH # und Len
313 UINT16 nGrbit;
314 SCTAB nTab;
316 ExcBundlesheetBase();
318 public:
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
331 private:
332 ByteString aName;
334 virtual void SaveCont( XclExpStream& rStrm );
336 public:
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
346 private:
347 static const BYTE pMyData[];
348 static const sal_Size nMyLen;
349 public:
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
360 public:
361 explicit XclExpCountry( const XclExpRoot& rRoot );
363 private:
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
376 public:
377 explicit XclExpWsbool( bool bFitToPages, SCTAB nScTab = -1, XclExpFilterManager* pManager = NULL );
379 virtual void SaveXml( XclExpXmlStream& rStrm );
380 private:
381 SCTAB mnScTab;
382 XclExpFilterManager* mpManager;
386 // ============================================================================
388 class XclExpFiltermode : public XclExpEmptyRecord
390 public:
391 explicit XclExpFiltermode();
394 // ----------------------------------------------------------------------------
396 class XclExpAutofilterinfo : public XclExpUInt16Record
398 public:
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() ); }
404 private:
405 ScAddress maStartPos;
408 // ----------------------------------------------------------------------------
410 class ExcFilterCondition
412 private:
413 UINT8 nType;
414 UINT8 nOper;
415 double fVal;
416 XclExpString* pText;
418 protected:
419 public:
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
438 private:
439 UINT16 nCol;
440 UINT16 nFlags;
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 );
449 protected:
450 public:
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
466 public:
467 explicit ExcAutoFilterRecs( const XclExpRoot& rRoot, SCTAB nTab );
468 virtual ~ExcAutoFilterRecs();
470 void AddObjRecs();
472 virtual void Save( XclExpStream& rStrm );
473 virtual void SaveXml( XclExpXmlStream& rStrm );
475 bool HasFilterMode() const;
477 private:
478 XclExpAutofilter* GetByCol( SCCOL nCol ); // always 0-based
479 BOOL IsFiltered( SCCOL nCol );
481 private:
482 typedef XclExpRecordList< XclExpAutofilter > XclExpAutofilterList;
483 typedef XclExpAutofilterList::RecordRefType XclExpAutofilterRef;
485 XclExpAutofilterList maFilterList;
486 XclExpFiltermode* pFilterMode;
487 XclExpAutofilterinfo* pFilterInfo;
488 ScRange maRef;
491 // ----------------------------------------------------------------------------
493 /** Sheet filter manager. Contains auto filters or advanced filters from all sheets. */
494 class XclExpFilterManager : protected XclExpRoot
496 public:
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 );
510 private:
511 using XclExpRoot::CreateRecord;
513 typedef ScfRef< ExcAutoFilterRecs > XclExpTabFilterRef;
514 typedef ::std::map< SCTAB, XclExpTabFilterRef > XclExpTabFilterMap;
516 XclExpTabFilterMap maFilterMap;
520 #endif