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