admin
2023-03-07 8b06b1cbf112d55307ea8a6efe711db4e7506d89
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *
 * This file is part of xlslib -- A multiplatform, C/C++ library
 * for dynamic generation of Excel(TM) files.
 *
 * Copyright 2004 Yeico S. A. de C. V. All Rights Reserved.
 * Copyright 2008-2013 David Hoerl All Rights Reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification, are
 * permitted provided that the following conditions are met:
 *
 *    1. Redistributions of source code must retain the above copyright notice, this list of
 *       conditions and the following disclaimer.
 *
 *    2. Redistributions in binary form must reproduce the above copyright notice, this list
 *       of conditions and the following disclaimer in the documentation and/or other materials
 *       provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY David Hoerl ''AS IS'' AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL David Hoerl OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 
#ifndef RECDEF_H
#define RECDEF_H
 
#include "../common/xlsys.h"
#include "../common/systype.h"
 
// #include "common/xls_pshpack2.h"
 
namespace xlslib_core
{
/*
 ******************************
 * CBof class declaration
 ******************************
 */
#define  VERSION_BIFF                0x0600
// BIFF8, the last one!
 
#define BOF_TYPE_WBGLOBALS            0x0005
#define BOF_TYPE_VBMODULE            0x0006
#define BOF_TYPE_WORKSHEET            0x0010
#define BOF_TYPE_CHART                0x0020
#define BOF_TYPE_EXCEL4_MACROSH        0x0040
#define BOF_TYPE_WSFILE                0x0100
 
#define BOF_BUILD_DFLT                0x1d5f
// from some old file???
#define BOF_YEAR_DFLT                0x07cd
// 1997
 
#define TWIP                        20
 
 
#if 0
#define CODEPAGE_IBMPC                0x01b5
#define CODEPAGE_APPLE                0x8000
#define CODEPAGE_ANSI                0x04e4
#endif
 
    // forward ref
    class CDataStorage;
 
    class CBof : public CRecord
    {
        friend class CDataStorage;
 
    protected:
        CBof(CDataStorage &datastore, unsigned16_t boftype);
    private:
        virtual ~CBof();
    };
 
/*
 ******************************
 * CEof class declaration
 ******************************
 */
    class CEof : public CRecord
    {
        friend class CDataStorage;
 
    protected:
        CEof(CDataStorage &datastore);
    private:
        virtual ~CEof();
    };
 
/*
 ******************************
 * CCodePage class declaration
 ******************************
 */
    class CCodePage : public CRecord
    {
        friend class CDataStorage;
 
    protected:
        CCodePage(CDataStorage &datastore, unsigned16_t boftype);
    private:
        virtual ~CCodePage();
    };
 
/*
 ******************************
 * CWindow1 class declaration
 ******************************
 */
    class CWindow1;
 
    class window1
    {
        friend class CWindow1;
 
    private:
        unsigned16_t horzPos, vertPos;      // points
        unsigned16_t windWidth, windHeight;         // points
        unsigned16_t activeSheet;           // 0 offset
        unsigned16_t firstVisibleTab;       // 0 offset
        unsigned16_t tabBarWidth;           // 0 - 1000, from no tab bar up to no scroll bar
 
    public:
        window1();
        virtual ~window1();
 
        // access from workBook
        void SetPosition(unsigned16_t horz, unsigned16_t vert) { horzPos=horz; vertPos=vert; }
        void SetSize(unsigned16_t width, unsigned16_t height) { windWidth=width; windHeight=height; }
        void SetFirstTab(unsigned16_t firstTab) { firstVisibleTab=firstTab; }
        void SetTabBarWidth(unsigned16_t width) { tabBarWidth = (width > 1000) ? 1000 : width; }
 
        // access from workSheet
        void SetActiveSheet(unsigned16_t theSheet) { activeSheet=theSheet; }
        unsigned16_t GetActiveSheet() const { return activeSheet; }
    };
 
    class CWindow1 : public CRecord
    {
        friend class CDataStorage;
 
    protected:
        CWindow1(CDataStorage &datastore, const window1& wind1);
    private:
        virtual ~CWindow1();
    };
/*
 ******************************
 * CDateMode class declaration
 ******************************
 */
    class CDateMode : public CRecord
    {
        friend class CDataStorage;
 
    protected:
        CDateMode(CDataStorage &datastore);
    private:
        virtual ~CDateMode();
 
    public:
        static bool Is_In_1904_Mode(void);
    };
 
 
 
/*
 ******************************
 * CWindow2 class declaration
 ******************************
 */
 
#define W2_OFFSET_GRBIT          4
#define W2_OFFSET_TOPROW         6
#define W2_OFFSET_LEFTCOL        8
#define W2_OFFSET_COLOR          10
#define W2_OFFSET_ZOOMPREVIEW    14
#define W2_OFFSET_ZOOMNORMAL     16
#define W2_OFFSET_RESERVED       18
 
 
#define W2_DFLT_TOPROW     0x0000
#define W2_DFLT_LEFTCOL    0x0000
#define W2_DFLT_COLOR      0x00000000
    // NOTE: Check a BIFF8 example to verify the units of the two following values
#define W2_DFLT_ZOOMPBPREV 0x0100
#define W2_DFLT_ZOOMNORMAL 0x0100
#define W2_DFLT_RESERVED   0x00000000
 
    // GRBIT mask-flags:
#define W2_GRBITMASK_FMLA          0x0001
#define W2_GRBITMASK_GRIDS         0x0002
#define W2_GRBITMASK_HROWCOL       0x0004
#define W2_GRBITMASK_FROZEN        0x0008
#define W2_GRBITMASK_ZEROS         0x0010
#define W2_GRBITMASK_DFLTHDRCOLOR  0x0020
#define W2_GRBITMASK_ARABIC        0x0040
#define W2_GRBITMASK_GUTS          0x0080
#define W2_GRBITMASK_FRZNOSPLIT    0x0100
#define W2_GRBITMASK_SELECTED      0x0200
#define W2_GRBITMASK_ACTIVE        0x0400
#define W2_GRBITMASK_PAGEBRK       0x0800
#define W2_GRBITMASK_RESERVED      0xf000
 
    /*
     *  NOTE: Hardcoded from an excel example
     * #define W2_DFLT_GRBIT ((unsigned16_t)0x06b6)
     * #define W2_DFLT_GRBIT ((unsigned16_t) \
     *  (W2_GRBITMASK_GRIDS|W2_GRBITMASK_HROWCOL|W2_GRBITMASK_DFLTHDRCOLOR))
     */
    class CWindow2 : public CRecord
    {
        friend class CDataStorage;
 
    protected:
        // TODO: Create a constructor that gets user-defined arguments that specify the appearence
        // The following constructor establishes default values.
        CWindow2(CDataStorage &datastore, bool isActive);
    private:
        virtual ~CWindow2();
 
    public:
        void SetSelected();
        void SetPaged();
        void ClearSelected();
        void ClearPaged();
    };
 
/*
 ******************************
 * CDimension class declaration
 ******************************
 */
    class CDimension : public CRecord
    {
        friend class CDataStorage;
 
    protected:
        CDimension(CDataStorage &datastore,
                   unsigned32_t minRow,
                   unsigned32_t maxRow,
                   unsigned32_t minCol,
                   unsigned32_t maxCol);
    private:
        virtual ~CDimension();
    };
 
/*
 ******************************
 * CStyle class declaration
 ******************************
 */
 
    struct style_t
    {
        unsigned16_t xfindex;
        unsigned8_t builtintype;
        unsigned8_t level;
    };
 
    typedef std::vector<xlslib_core::style_t* XLSLIB_DFLT_ALLOCATOR> Style_Vect_t;
    typedef Style_Vect_t::iterator Style_Vect_Itor_t;
 
    class CStyle : public CRecord
    {
        friend class CDataStorage;
 
    protected:
        CStyle(CDataStorage &datastore, const style_t* styledef);
    private:
        virtual ~CStyle();
    };
 
 
/*
 ******************************
 * CBSheet class declaration
 ******************************
 */
 
#define BSHEET_OFFSET_POSITION    4
#define BSHEET_OFFSET_FLAGS       8
#define BSHEET_OFFSET_NAMELENGHT  10
#define BSHEET_OFFSET_B7NAME      11
#define BSHEET_OFFSET_B8NAME      12
 
#define BSHEET_ATTR_WORKSHEET  0x0000
#define BSHEET_ATTR_EX4MACRO   0x0001
#define BSHEET_ATTR_CHART      0x0002
#define BSHEET_ATTR_VBMODULE   0x0006
 
#define BSHEET_ATTR_VISIBLE     0x0000
#define BSHEET_ATTR_HIDDEN      0x0100
#define BSHEET_ATTR_VERYHIDDEN  0x0200
 
    class CBSheet;
    class CGlobalRecords;
 
    class boundsheet_t
    {
    public:
        boundsheet_t(CGlobalRecords& gRecords);
        boundsheet_t(CGlobalRecords& gRecords, const xlslib_strings::u16string& sheetname, unsigned16_t attributes, unsigned32_t streampos);
        virtual ~boundsheet_t();
 
    private:
        boundsheet_t(const boundsheet_t& that);
        boundsheet_t& operator=(const boundsheet_t& right);
 
    protected:
        xlslib_strings::u16string sheetname;
        unsigned32_t streampos;
        bool worksheet : 1;
        bool ex4macro : 1;
        bool chart : 1;
        bool vbmodule : 1;
        bool visible : 1;
        bool hidden : 1;
        bool veryhidden : 1;
 
        unsigned16_t notes;
 
        CBSheet    *sheetData;
 
        CGlobalRecords& m_GlobalRecords;
 
    public:
        unsigned32_t GetStreamPos(void) const { return streampos; }
        const xlslib_strings::u16string& GetSheetName(void) const
        {
            return sheetname;
        }
 
        void SetAttributes(unsigned16_t attributes);
        bool IsWorkSheet(void) const { return worksheet; }
        bool IsEx4macro(void) const { return ex4macro; }
        bool IsChart(void) const { return chart; }
        bool IsVBModule(void) const { return vbmodule; }
        bool IsVisible(void) const { return visible; }
        bool IsHidden(void) const { return hidden; }
        bool IsVeryHidden(void) const { return veryhidden; }
 
        CBSheet *SetSheetData(CBSheet *sh)
        {
            sheetData = sh;
            return sh;
        }
 
        unsigned16_t GetNoteCount(void) const { return notes; }
        void BumpNoteCount(void) { ++notes; }
        void SetSheetStreamPosition(size_t offset);
        const CBSheet *GetSheetData(void) const { return sheetData; }
 
        CGlobalRecords& GetGlobalRecords(void) const { return m_GlobalRecords; }
    };
 
    typedef std::vector<xlslib_core::boundsheet_t* XLSLIB_DFLT_ALLOCATOR> Boundsheet_Vect_t;
    typedef Boundsheet_Vect_t::iterator Boundsheet_Vect_Itor_t;
    typedef Boundsheet_Vect_t::const_iterator Boundsheet_Vect_CItor_t;
 
 
    class CBSheet : public CRecord
    {
        friend class CDataStorage;
 
    protected:
        CBSheet(CDataStorage &datastore, const boundsheet_t* bsheetdef);
    private:
        virtual ~CBSheet();
 
    public:
        void SetStreamPosition(size_t pos);
    };
}
 
// #include "common/xls_poppack.h"
 
#endif