xref: /aoo4110/main/sc/source/filter/inc/excrecds.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SC_EXCRECDS_HXX
25 #define SC_EXCRECDS_HXX
26 
27 #include <tools/solar.h>
28 #include <svl/zforlist.hxx>
29 #include <tools/string.hxx>
30 #include <vcl/vclenum.hxx>
31 #include <tools/color.hxx>
32 
33 
34 #include <vector>
35 #include "olinetab.hxx"
36 #include "filter.hxx"
37 #include "rangelst.hxx"
38 #include "xerecord.hxx"
39 #include "xeroot.hxx"
40 #include "xeformula.hxx"
41 #include "xestring.hxx"
42 #include "root.hxx"
43 #include "excdefs.hxx"
44 #include "cell.hxx"
45 
46 //------------------------------------------------------------------ Forwards -
47 
48 class SvxBorderLine;
49 
50 class SvStream;
51 class Font;
52 class List;
53 class ScPatternAttr;
54 class ScTokenArray;
55 class ScRangeData;
56 class ScDBData;
57 class ScEditCell;
58 class SfxItemSet;
59 class EditTextObject;
60 class ScPageHFItem;
61 class ScProgress;
62 
63 class ExcTable;
64 
65 //----------------------------------------------------------- class ExcRecord -
66 
67 class ExcRecord : public XclExpRecord
68 {
69 public:
70 	virtual void			Save( XclExpStream& rStrm );
71 
72 	virtual sal_uInt16			GetNum() const = 0;
73     virtual sal_Size        GetLen() const = 0;
74 
75 protected:
76 	virtual void			SaveCont( XclExpStream& rStrm );
77 
78 private:
79     /** Writes the body of the record. */
80     virtual void            WriteBody( XclExpStream& rStrm );
81 };
82 
83 
84 //--------------------------------------------------------- class ExcEmptyRec -
85 
86 class ExcEmptyRec : public ExcRecord
87 {
88 private:
89 protected:
90 public:
91 	virtual void			Save( XclExpStream& rStrm );
92 	virtual sal_uInt16			GetNum() const;
93     virtual sal_Size        GetLen() const;
94 };
95 
96 
97 //------------------------------------------------------- class ExcRecordList -
98 
99 class ExcRecordList : protected List, public ExcEmptyRec
100 {
101 private:
102 protected:
103 public:
104 	virtual					~ExcRecordList();
105 
106     using                   List::Count;
107 
First(void)108 	inline ExcRecord*		First( void )				{ return ( ExcRecord* ) List::First(); }
Next(void)109 	inline ExcRecord*		Next( void )				{ return ( ExcRecord* ) List::Next(); }
110 
Append(ExcRecord * pNew)111 	inline void				Append( ExcRecord* pNew )	{ if( pNew ) List::Insert( pNew, LIST_APPEND ); }
Get(sal_uInt32 nNum) const112 	inline const ExcRecord*	Get( sal_uInt32 nNum ) const	{ return ( ExcRecord* ) List::GetObject( nNum ); }
113 
114 	virtual void			Save( XclExpStream& rStrm );
115 };
116 
117 
118 //--------------------------------------------------------- class ExcDummyRec -
119 
120 class ExcDummyRec : public ExcRecord
121 {
122 protected:
123 public:
124 	virtual void			Save( XclExpStream& rStrm );
125 	virtual sal_uInt16			GetNum() const;
126 	virtual	const sal_uInt8*		GetData() const = 0;	// byte data must contain header and body
127 };
128 
129 
130 //------------------------------------------------------- class ExcBoolRecord -
131 // stores sal_Bool as 16bit val ( 0x0000 | 0x0001 )
132 
133 class ExcBoolRecord : public ExcRecord
134 {
135 private:
136 	virtual void			SaveCont( XclExpStream& rStrm );
137 
138 protected:
139 	sal_Bool					bVal;
140 
ExcBoolRecord()141 	inline					ExcBoolRecord() : bVal( sal_False ) {}
142 
143 public:
ExcBoolRecord(const sal_Bool bDefault)144 	inline					ExcBoolRecord( const sal_Bool bDefault ) : bVal( bDefault )	{}
145 
146     virtual sal_Size        GetLen( void ) const;
147 };
148 
149 
150 //--------------------------------------------------------- class ExcBof_Base -
151 
152 class ExcBof_Base : public ExcRecord
153 {
154 private:
155 protected:
156 	sal_uInt16					nDocType;
157 	sal_uInt16					nVers;
158 	sal_uInt16					nRupBuild;
159 	sal_uInt16					nRupYear;
160 public:
161 							ExcBof_Base( void );
162 };
163 
164 
165 //-------------------------------------------------------------- class ExcBof -
166 // Header Record fuer WORKSHEETS
167 
168 class ExcBof : public ExcBof_Base
169 {
170 private:
171 	virtual void			SaveCont( XclExpStream& rStrm );
172 public:
173 							ExcBof( void );
174 
175 	virtual sal_uInt16			GetNum( void ) const;
176     virtual sal_Size        GetLen( void ) const;
177 };
178 
179 
180 //------------------------------------------------------------- class ExcBofW -
181 // Header Record fuer WORKBOOKS
182 
183 class ExcBofW : public ExcBof_Base
184 {
185 private:
186 	virtual void			SaveCont( XclExpStream& rStrm );
187 public:
188 							ExcBofW( void );
189 
190 	virtual sal_uInt16			GetNum( void ) const;
191     virtual sal_Size        GetLen( void ) const;
192 };
193 
194 
195 //-------------------------------------------------------------- class ExcEof -
196 
197 class ExcEof : public ExcRecord
198 {
199 private:
200 public:
201 	virtual sal_uInt16			GetNum( void ) const;
202     virtual sal_Size        GetLen( void ) const;
203 };
204 
205 
206 //--------------------------------------------------------- class ExcDummy_00 -
207 // INTERFACEHDR to FNGROUPCOUNT (see excrecds.cxx)
208 
209 class ExcDummy_00 : public ExcDummyRec
210 {
211 private:
212 	static const sal_uInt8		pMyData[];
213     static const sal_Size   nMyLen;
214 public:
215     virtual sal_Size        GetLen( void ) const;
216 	virtual	const sal_uInt8*		GetData( void ) const;
217 };
218 
219 // EXC_ID_WINDOWPROTECTION
220 class XclExpWindowProtection : public	XclExpBoolRecord
221 {
222 	public:
223 		XclExpWindowProtection(bool bValue);
224 
225     virtual void            SaveXml( XclExpXmlStream& rStrm );
226 };
227 
228 // EXC_ID_PROTECT  Document Protection
229 class XclExpProtection : public	XclExpBoolRecord
230 {
231 	public:
232 		XclExpProtection(bool bValue);
233 };
234 
235 class XclExpPassHash : public XclExpRecord
236 {
237 public:
238     XclExpPassHash(const ::com::sun::star::uno::Sequence<sal_Int8>& aHash);
239     virtual ~XclExpPassHash();
240 
241 private:
242     virtual void    WriteBody(XclExpStream& rStrm);
243 
244 private:
245     sal_uInt16  mnHash;
246 };
247 
248 
249 //-------------------------------------------------------- class ExcDummy_04x -
250 // PASSWORD to BOOKBOOL (see excrecds.cxx), no 1904
251 
252 class ExcDummy_040 : public ExcDummyRec
253 {
254 private:
255 	static const sal_uInt8		pMyData[];
256     static const sal_Size   nMyLen;
257 public:
258     virtual sal_Size        GetLen( void ) const;
259 	virtual	const sal_uInt8*		GetData( void ) const;
260 };
261 
262 
263 
264 class ExcDummy_041 : public ExcDummyRec
265 {
266 private:
267 	static const sal_uInt8		pMyData[];
268     static const sal_Size   nMyLen;
269 public:
270     virtual sal_Size        GetLen( void ) const;
271 	virtual	const sal_uInt8*		GetData( void ) const;
272 };
273 
274 
275 //------------------------------------------------------------- class Exc1904 -
276 
277 class Exc1904 : public ExcBoolRecord
278 {
279 public:
280 							Exc1904( ScDocument& rDoc );
281 	virtual sal_uInt16			GetNum( void ) const;
282 
283     virtual void            SaveXml( XclExpXmlStream& rStrm );
284 };
285 
286 
287 //------------------------------------------------------ class ExcBundlesheet -
288 
289 class ExcBundlesheetBase : public ExcRecord
290 {
291 protected:
292     sal_Size                nStrPos;
293     sal_Size                nOwnPos;    // Position NACH # und Len
294 	sal_uInt16					nGrbit;
295     SCTAB                   nTab;
296 
297 							ExcBundlesheetBase();
298 
299 public:
300 							ExcBundlesheetBase( RootData& rRootData, SCTAB nTab );
301 
SetStreamPos(sal_Size nNewStrPos)302     inline void             SetStreamPos( sal_Size nNewStrPos ) { nStrPos = nNewStrPos; }
303 	void					UpdateStreamPos( XclExpStream& rStrm );
304 
305 	virtual sal_uInt16			GetNum() const;
306 };
307 
308 
309 
310 class ExcBundlesheet : public ExcBundlesheetBase
311 {
312 private:
313 	ByteString				aName;
314 
315 	virtual void			SaveCont( XclExpStream& rStrm );
316 
317 public:
318 							ExcBundlesheet( RootData& rRootData, SCTAB nTab );
319     virtual sal_Size        GetLen() const;
320 };
321 
322 //--------------------------------------------------------- class ExcDummy_02 -
323 // sheet dummies: CALCMODE to SETUP
324 
325 class ExcDummy_02a : public ExcDummyRec
326 {
327 private:
328 	static const sal_uInt8		pMyData[];
329     static const sal_Size   nMyLen;
330 public:
331     virtual sal_Size        GetLen( void ) const;
332 	virtual	const sal_uInt8*		GetData( void ) const;
333 };
334 
335 
336 // ----------------------------------------------------------------------------
337 
338 /** This record contains the Windows country IDs for the UI and document language. */
339 class XclExpCountry : public XclExpRecord
340 {
341 public:
342     explicit                    XclExpCountry( const XclExpRoot& rRoot );
343 
344 private:
345     sal_uInt16                  mnUICountry;        /// The UI country ID.
346     sal_uInt16                  mnDocCountry;       /// The document country ID.
347 
348     /** Writes the body of the COUNTRY record. */
349     virtual void                WriteBody( XclExpStream& rStrm );
350 };
351 
352 
353 // XclExpWsbool ===============================================================
354 
355 class XclExpWsbool : public XclExpUInt16Record
356 {
357 public:
358     explicit                    XclExpWsbool( bool bFitToPages, SCTAB nScTab = -1, XclExpFilterManager* pManager = NULL );
359 
360     virtual void                SaveXml( XclExpXmlStream& rStrm );
361 private:
362     SCTAB                       mnScTab;
363     XclExpFilterManager*        mpManager;
364 };
365 
366 
367 // ============================================================================
368 
369 class XclExpFiltermode : public XclExpEmptyRecord
370 {
371 public:
372     explicit            XclExpFiltermode();
373 };
374 
375 // ----------------------------------------------------------------------------
376 
377 class XclExpAutofilterinfo : public XclExpUInt16Record
378 {
379 public:
380     explicit            XclExpAutofilterinfo( const ScAddress& rStartPos, SCCOL nScCol );
381 
GetStartPos() const382     inline const ScAddress GetStartPos() const { return maStartPos; }
GetColCount() const383     inline SCCOL        GetColCount() const { return static_cast< SCCOL >( GetValue() ); }
384 
385 private:
386     ScAddress           maStartPos;
387 };
388 
389 // ----------------------------------------------------------------------------
390 
391 class ExcFilterCondition
392 {
393 private:
394 	sal_uInt8					nType;
395 	sal_uInt8					nOper;
396 	double					fVal;
397     XclExpString*           pText;
398 
399 protected:
400 public:
401 							ExcFilterCondition();
402 							~ExcFilterCondition();
403 
IsEmpty() const404 	inline sal_Bool				IsEmpty() const 	{ return (nType == EXC_AFTYPE_NOTUSED); }
HasEqual() const405 	inline sal_Bool				HasEqual() const	{ return (nOper == EXC_AFOPER_EQUAL); }
406 	sal_uLong					GetTextBytes() const;
407 
408 	void					SetCondition( sal_uInt8 nTp, sal_uInt8 nOp, double fV, String* pT );
409 
410 	void					Save( XclExpStream& rStrm );
411 	void					SaveXml( XclExpXmlStream& rStrm );
412 	void					SaveText( XclExpStream& rStrm );
413 };
414 
415 // ----------------------------------------------------------------------------
416 
417 class XclExpAutofilter : public XclExpRecord, protected XclExpRoot
418 {
419 private:
420 	sal_uInt16					nCol;
421 	sal_uInt16					nFlags;
422 	ExcFilterCondition		aCond[ 2 ];
423 
424 	sal_Bool					AddCondition( ScQueryConnect eConn, sal_uInt8 nType,
425 								sal_uInt8 nOp, double fVal, String* pText,
426 								sal_Bool bSimple = sal_False );
427 
428     virtual void            WriteBody( XclExpStream& rStrm );
429 
430 protected:
431 public:
432                             XclExpAutofilter( const XclExpRoot& rRoot, sal_uInt16 nC );
433 
GetCol() const434 	inline sal_uInt16			GetCol() const			{ return nCol; }
HasCondition() const435 	inline sal_Bool				HasCondition() const	{ return !aCond[ 0 ].IsEmpty(); }
HasTop10() const436     inline sal_Bool             HasTop10() const        { return ::get_flag( nFlags, EXC_AFFLAG_TOP10 ); }
437 
438     sal_Bool                    AddEntry( const ScQueryEntry& rEntry );
439 
440     virtual void            SaveXml( XclExpXmlStream& rStrm );
441 };
442 
443 // ----------------------------------------------------------------------------
444 
445 class ExcAutoFilterRecs : public XclExpRecordBase, protected XclExpRoot
446 {
447 public:
448     explicit            ExcAutoFilterRecs( const XclExpRoot& rRoot, SCTAB nTab );
449     virtual             ~ExcAutoFilterRecs();
450 
451     void                AddObjRecs();
452 
453     virtual void        Save( XclExpStream& rStrm );
454     virtual void        SaveXml( XclExpXmlStream& rStrm );
455 
456     bool                HasFilterMode() const;
457 
458 private:
459     XclExpAutofilter*   GetByCol( SCCOL nCol ); // always 0-based
460     sal_Bool                IsFiltered( SCCOL nCol );
461 
462 private:
463     typedef XclExpRecordList< XclExpAutofilter >    XclExpAutofilterList;
464     typedef XclExpAutofilterList::RecordRefType     XclExpAutofilterRef;
465 
466     XclExpAutofilterList maFilterList;
467     XclExpFiltermode*   pFilterMode;
468     XclExpAutofilterinfo* pFilterInfo;
469     ScRange                 maRef;
470 };
471 
472 // ----------------------------------------------------------------------------
473 
474 /** Sheet filter manager. Contains auto filters or advanced filters from all sheets. */
475 class XclExpFilterManager : protected XclExpRoot
476 {
477 public:
478     explicit            XclExpFilterManager( const XclExpRoot& rRoot );
479 
480     /** Creates the filter records for the specified sheet.
481         @descr  Creates and inserts related built-in NAME records. Therefore this
482             function is called from the name buffer itself. */
483     void                InitTabFilter( SCTAB nScTab );
484 
485     /** Returns a record object containing all filter records for the specified sheet. */
486     XclExpRecordRef     CreateRecord( SCTAB nScTab );
487 
488     /** Returns whether or not FilterMode is present */
489     bool                HasFilterMode( SCTAB nScTab );
490 
491 private:
492     using               XclExpRoot::CreateRecord;
493 
494     typedef ScfRef< ExcAutoFilterRecs >             XclExpTabFilterRef;
495     typedef ::std::map< SCTAB, XclExpTabFilterRef > XclExpTabFilterMap;
496 
497     XclExpTabFilterMap  maFilterMap;
498 };
499 
500 
501 #endif
502 
503