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