Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef SC_EXCRECDS_HXX
30 : : #define SC_EXCRECDS_HXX
31 : :
32 : : #include <tools/solar.h>
33 : : #include <svl/zforlist.hxx>
34 : : #include <tools/string.hxx>
35 : : #include <vcl/vclenum.hxx>
36 : :
37 : :
38 : : #include <vector>
39 : : #include "olinetab.hxx"
40 : : #include "filter.hxx"
41 : : #include "rangelst.hxx"
42 : : #include "xerecord.hxx"
43 : : #include "xeroot.hxx"
44 : : #include "xeformula.hxx"
45 : : #include "xestring.hxx"
46 : : #include "root.hxx"
47 : : #include "excdefs.hxx"
48 : : #include "cell.hxx"
49 : : #include <boost/shared_ptr.hpp>
50 : :
51 : : //------------------------------------------------------------------ Forwards -
52 : :
53 : : struct ScQueryEntry;
54 : :
55 : : //----------------------------------------------------------- class ExcRecord -
56 : :
57 [ # # ][ # # ]: 0 : class ExcRecord : public XclExpRecord
58 : : {
59 : : public:
60 : : virtual void Save( XclExpStream& rStrm );
61 : : virtual void SaveXml( XclExpXmlStream& rStrm );
62 : :
63 : : virtual sal_uInt16 GetNum() const = 0;
64 : : virtual sal_Size GetLen() const = 0;
65 : :
66 : : protected:
67 : : virtual void SaveCont( XclExpStream& rStrm );
68 : :
69 : : private:
70 : : /** Writes the body of the record. */
71 : : virtual void WriteBody( XclExpStream& rStrm );
72 : : };
73 : :
74 : :
75 : : //--------------------------------------------------------- class ExcEmptyRec -
76 : :
77 [ # # ]: 0 : class ExcEmptyRec : public ExcRecord
78 : : {
79 : : private:
80 : : protected:
81 : : public:
82 : : virtual void Save( XclExpStream& rStrm );
83 : : virtual sal_uInt16 GetNum() const;
84 : : virtual sal_Size GetLen() const;
85 : : };
86 : :
87 : : //--------------------------------------------------------- class ExcDummyRec -
88 : :
89 [ # # ]: 0 : class ExcDummyRec : public ExcRecord
90 : : {
91 : : protected:
92 : : public:
93 : : virtual void Save( XclExpStream& rStrm );
94 : : virtual sal_uInt16 GetNum() const;
95 : : virtual const sal_uInt8* GetData() const = 0; // byte data must contain header and body
96 : : };
97 : :
98 : :
99 : : //------------------------------------------------------- class ExcBoolRecord -
100 : : // stores sal_Bool as 16bit val ( 0x0000 | 0x0001 )
101 : :
102 [ # # ]: 0 : class ExcBoolRecord : public ExcRecord
103 : : {
104 : : private:
105 : : virtual void SaveCont( XclExpStream& rStrm );
106 : :
107 : : protected:
108 : : sal_Bool bVal;
109 : :
110 : 0 : inline ExcBoolRecord() : bVal( false ) {}
111 : :
112 : : public:
113 : : inline ExcBoolRecord( const sal_Bool bDefault ) : bVal( bDefault ) {}
114 : :
115 : : virtual sal_Size GetLen( void ) const;
116 : : };
117 : :
118 : :
119 : : //--------------------------------------------------------- class ExcBof_Base -
120 : :
121 [ # # ]: 0 : class ExcBof_Base : public ExcRecord
122 : : {
123 : : private:
124 : : protected:
125 : : sal_uInt16 nDocType;
126 : : sal_uInt16 nVers;
127 : : sal_uInt16 nRupBuild;
128 : : sal_uInt16 nRupYear;
129 : : public:
130 : : ExcBof_Base( void );
131 : : };
132 : :
133 : :
134 : : //-------------------------------------------------------------- class ExcBof -
135 : : // Header Record fuer WORKSHEETS
136 : :
137 [ # # ]: 0 : class ExcBof : public ExcBof_Base
138 : : {
139 : : private:
140 : : virtual void SaveCont( XclExpStream& rStrm );
141 : : public:
142 : : ExcBof( void );
143 : :
144 : : virtual sal_uInt16 GetNum( void ) const;
145 : : virtual sal_Size GetLen( void ) const;
146 : : };
147 : :
148 : :
149 : : //------------------------------------------------------------- class ExcBofW -
150 : : // Header Record fuer WORKBOOKS
151 : :
152 [ # # ]: 0 : class ExcBofW : public ExcBof_Base
153 : : {
154 : : private:
155 : : virtual void SaveCont( XclExpStream& rStrm );
156 : : public:
157 : : ExcBofW( void );
158 : :
159 : : virtual sal_uInt16 GetNum( void ) const;
160 : : virtual sal_Size GetLen( void ) const;
161 : : };
162 : :
163 : :
164 : : //-------------------------------------------------------------- class ExcEof -
165 : :
166 [ # # ]: 0 : class ExcEof : public ExcRecord
167 : : {
168 : : private:
169 : : public:
170 : : virtual sal_uInt16 GetNum( void ) const;
171 : : virtual sal_Size GetLen( void ) const;
172 : : };
173 : :
174 : :
175 : : //--------------------------------------------------------- class ExcDummy_00 -
176 : : // INTERFACEHDR to FNGROUPCOUNT (see excrecds.cxx)
177 : :
178 [ # # ]: 0 : class ExcDummy_00 : public ExcDummyRec
179 : : {
180 : : private:
181 : : static const sal_uInt8 pMyData[];
182 : : static const sal_Size nMyLen;
183 : : public:
184 : : virtual sal_Size GetLen( void ) const;
185 : : virtual const sal_uInt8* GetData( void ) const;
186 : : };
187 : :
188 : : // EXC_ID_WINDOWPROTECTION
189 [ # # ]: 0 : class XclExpWindowProtection : public XclExpBoolRecord
190 : : {
191 : : public:
192 : : XclExpWindowProtection(bool bValue);
193 : :
194 : : virtual void SaveXml( XclExpXmlStream& rStrm );
195 : : };
196 : :
197 : : // EXC_ID_PROTECT Document Protection
198 [ # # ]: 0 : class XclExpProtection : public XclExpBoolRecord
199 : : {
200 : : public:
201 : : XclExpProtection(bool bValue);
202 : : };
203 : :
204 : : class XclExpPassHash : public XclExpRecord
205 : : {
206 : : public:
207 : : XclExpPassHash(const ::com::sun::star::uno::Sequence<sal_Int8>& aHash);
208 : : virtual ~XclExpPassHash();
209 : :
210 : : private:
211 : : virtual void WriteBody(XclExpStream& rStrm);
212 : :
213 : : private:
214 : : sal_uInt16 mnHash;
215 : : };
216 : :
217 : :
218 : : //-------------------------------------------------------- class ExcDummy_04x -
219 : : // PASSWORD to BOOKBOOL (see excrecds.cxx), no 1904
220 : :
221 [ # # ]: 0 : class ExcDummy_040 : public ExcDummyRec
222 : : {
223 : : private:
224 : : static const sal_uInt8 pMyData[];
225 : : static const sal_Size nMyLen;
226 : : public:
227 : : virtual sal_Size GetLen( void ) const;
228 : : virtual const sal_uInt8* GetData( void ) const;
229 : : };
230 : :
231 : :
232 : :
233 [ # # ]: 0 : class ExcDummy_041 : public ExcDummyRec
234 : : {
235 : : private:
236 : : static const sal_uInt8 pMyData[];
237 : : static const sal_Size nMyLen;
238 : : public:
239 : : virtual sal_Size GetLen( void ) const;
240 : : virtual const sal_uInt8* GetData( void ) const;
241 : : };
242 : :
243 : :
244 : : //------------------------------------------------------------- class Exc1904 -
245 : :
246 [ # # ]: 0 : class Exc1904 : public ExcBoolRecord
247 : : {
248 : : public:
249 : : Exc1904( ScDocument& rDoc );
250 : : virtual sal_uInt16 GetNum( void ) const;
251 : :
252 : : virtual void SaveXml( XclExpXmlStream& rStrm );
253 : : private:
254 : : sal_Bool bDateCompatibility;
255 : : };
256 : :
257 : :
258 : : //------------------------------------------------------ class ExcBundlesheet -
259 : :
260 [ # # ]: 0 : class ExcBundlesheetBase : public ExcRecord
261 : : {
262 : : protected:
263 : : sal_Size nStrPos;
264 : : sal_Size nOwnPos; // Position NACH # und Len
265 : : sal_uInt16 nGrbit;
266 : : SCTAB nTab;
267 : :
268 : : ExcBundlesheetBase();
269 : :
270 : : public:
271 : : ExcBundlesheetBase( RootData& rRootData, SCTAB nTab );
272 : :
273 : 0 : inline void SetStreamPos( sal_Size nNewStrPos ) { nStrPos = nNewStrPos; }
274 : : void UpdateStreamPos( XclExpStream& rStrm );
275 : :
276 : : virtual sal_uInt16 GetNum() const;
277 : : };
278 : :
279 : :
280 : :
281 [ # # ]: 0 : class ExcBundlesheet : public ExcBundlesheetBase
282 : : {
283 : : private:
284 : : rtl::OString aName;
285 : :
286 : : virtual void SaveCont( XclExpStream& rStrm );
287 : :
288 : : public:
289 : : ExcBundlesheet( RootData& rRootData, SCTAB nTab );
290 : : virtual sal_Size GetLen() const;
291 : : };
292 : :
293 : : //--------------------------------------------------------- class ExcDummy_02 -
294 : : // sheet dummies: CALCMODE to SETUP
295 : :
296 [ # # ]: 0 : class ExcDummy_02a : public ExcDummyRec
297 : : {
298 : : private:
299 : : static const sal_uInt8 pMyData[];
300 : : static const sal_Size nMyLen;
301 : : public:
302 : : virtual sal_Size GetLen( void ) const;
303 : : virtual const sal_uInt8* GetData( void ) const;
304 : : };
305 : :
306 : :
307 : : // ----------------------------------------------------------------------------
308 : :
309 : : /** This record contains the Windows country IDs for the UI and document language. */
310 [ # # ]: 0 : class XclExpCountry : public XclExpRecord
311 : : {
312 : : public:
313 : : explicit XclExpCountry( const XclExpRoot& rRoot );
314 : :
315 : : private:
316 : : sal_uInt16 mnUICountry; /// The UI country ID.
317 : : sal_uInt16 mnDocCountry; /// The document country ID.
318 : :
319 : : /** Writes the body of the COUNTRY record. */
320 : : virtual void WriteBody( XclExpStream& rStrm );
321 : : };
322 : :
323 : :
324 : : // XclExpWsbool ===============================================================
325 : :
326 [ # # ]: 0 : class XclExpWsbool : public XclExpUInt16Record
327 : : {
328 : : public:
329 : : explicit XclExpWsbool( bool bFitToPages, SCTAB nScTab = -1, XclExpFilterManager* pManager = NULL );
330 : :
331 : : virtual void SaveXml( XclExpXmlStream& rStrm );
332 : : private:
333 : : SCTAB mnScTab;
334 : : XclExpFilterManager* mpManager;
335 : : };
336 : :
337 : :
338 : : // ============================================================================
339 : :
340 [ # # ]: 0 : class XclExpFiltermode : public XclExpEmptyRecord
341 : : {
342 : : public:
343 : : explicit XclExpFiltermode();
344 : : };
345 : :
346 : : // ----------------------------------------------------------------------------
347 : :
348 [ # # ]: 0 : class XclExpAutofilterinfo : public XclExpUInt16Record
349 : : {
350 : : public:
351 : : explicit XclExpAutofilterinfo( const ScAddress& rStartPos, SCCOL nScCol );
352 : :
353 : 0 : inline const ScAddress GetStartPos() const { return maStartPos; }
354 : 0 : inline SCCOL GetColCount() const { return static_cast< SCCOL >( GetValue() ); }
355 : :
356 : : private:
357 : : ScAddress maStartPos;
358 : : };
359 : :
360 : : // ----------------------------------------------------------------------------
361 : :
362 : : class ExcFilterCondition
363 : : {
364 : : private:
365 : : sal_uInt8 nType;
366 : : sal_uInt8 nOper;
367 : : double fVal;
368 : : XclExpString* pText;
369 : :
370 : : protected:
371 : : public:
372 : : ExcFilterCondition();
373 : : ~ExcFilterCondition();
374 : :
375 : 0 : inline bool IsEmpty() const { return (nType == EXC_AFTYPE_NOTUSED); }
376 : : inline bool HasEqual() const { return (nOper == EXC_AFOPER_EQUAL); }
377 : : sal_uLong GetTextBytes() const;
378 : :
379 : : void SetCondition( sal_uInt8 nTp, sal_uInt8 nOp, double fV, String* pT );
380 : :
381 : : void Save( XclExpStream& rStrm );
382 : : void SaveXml( XclExpXmlStream& rStrm );
383 : : void SaveText( XclExpStream& rStrm );
384 : : };
385 : :
386 : : // ----------------------------------------------------------------------------
387 : :
388 [ # # ][ # # ]: 0 : class XclExpAutofilter : public XclExpRecord, protected XclExpRoot
[ # # ][ # # ]
389 : : {
390 : : private:
391 : : enum FilterType { FilterCondition, MultiValue };
392 : : FilterType meType;
393 : : sal_uInt16 nCol;
394 : : sal_uInt16 nFlags;
395 : : ExcFilterCondition aCond[ 2 ];
396 : : std::vector<rtl::OUString> maMultiValues;
397 : :
398 : : bool AddCondition( ScQueryConnect eConn, sal_uInt8 nType,
399 : : sal_uInt8 nOp, double fVal, String* pText,
400 : : bool bSimple = false );
401 : :
402 : : virtual void WriteBody( XclExpStream& rStrm );
403 : :
404 : : public:
405 : : XclExpAutofilter( const XclExpRoot& rRoot, sal_uInt16 nC );
406 : :
407 : 0 : inline sal_uInt16 GetCol() const { return nCol; }
408 : 0 : inline bool HasTop10() const { return ::get_flag( nFlags, EXC_AFFLAG_TOP10 ); }
409 : :
410 : : bool HasCondition() const;
411 : : bool AddEntry( const ScQueryEntry& rEntry );
412 : : bool AddMultiValueEntry( const ScQueryEntry& rEntry );
413 : :
414 : : virtual void SaveXml( XclExpXmlStream& rStrm );
415 : : };
416 : :
417 : : // ----------------------------------------------------------------------------
418 : :
419 : : class ExcAutoFilterRecs : public XclExpRecordBase, protected XclExpRoot
420 : : {
421 : : public:
422 : : explicit ExcAutoFilterRecs( const XclExpRoot& rRoot, SCTAB nTab );
423 : : virtual ~ExcAutoFilterRecs();
424 : :
425 : : void AddObjRecs();
426 : :
427 : : virtual void Save( XclExpStream& rStrm );
428 : : virtual void SaveXml( XclExpXmlStream& rStrm );
429 : :
430 : : bool HasFilterMode() const;
431 : :
432 : : private:
433 : : XclExpAutofilter* GetByCol( SCCOL nCol ); // always 0-based
434 : : bool IsFiltered( SCCOL nCol );
435 : :
436 : : private:
437 : : typedef XclExpRecordList< XclExpAutofilter > XclExpAutofilterList;
438 : : typedef XclExpAutofilterList::RecordRefType XclExpAutofilterRef;
439 : :
440 : : XclExpAutofilterList maFilterList;
441 : : XclExpFiltermode* pFilterMode;
442 : : XclExpAutofilterinfo* pFilterInfo;
443 : : ScRange maRef;
444 : : bool mbAutoFilter;
445 : : };
446 : :
447 : : // ----------------------------------------------------------------------------
448 : :
449 : : /** Sheet filter manager. Contains auto filters or advanced filters from all sheets. */
450 [ # # ]: 0 : class XclExpFilterManager : protected XclExpRoot
451 : : {
452 : : public:
453 : : explicit XclExpFilterManager( const XclExpRoot& rRoot );
454 : :
455 : : /** Creates the filter records for the specified sheet.
456 : : @descr Creates and inserts related built-in NAME records. Therefore this
457 : : function is called from the name buffer itself. */
458 : : void InitTabFilter( SCTAB nScTab );
459 : :
460 : : /** Returns a record object containing all filter records for the specified sheet. */
461 : : XclExpRecordRef CreateRecord( SCTAB nScTab );
462 : :
463 : : /** Returns whether or not FilterMode is present */
464 : : bool HasFilterMode( SCTAB nScTab );
465 : :
466 : : private:
467 : : using XclExpRoot::CreateRecord;
468 : :
469 : : typedef boost::shared_ptr< ExcAutoFilterRecs > XclExpTabFilterRef;
470 : : typedef ::std::map< SCTAB, XclExpTabFilterRef > XclExpTabFilterMap;
471 : :
472 : : XclExpTabFilterMap maFilterMap;
473 : : };
474 : :
475 : :
476 : : #endif
477 : :
478 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|