1 /*
2  *  Copyright (c) 2001 Graham Short.  <grahshrt@netscape.net>
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 
19 #ifndef QPRO_RECORD_H
20 #define QPRO_RECORD_H
21 
22 #include <qpro/tablenames.h>
23 #include <qpro/stream.h>
24 
25 enum QpRecType {
26     QpBof               = 0,
27     QpEof               = 1,
28     QpRecalcMode        = 2,
29     QpRecalcOrder       = 3,
30     QpEmptyCell         = 12,
31     QpIntegerCell       = 13,
32     QpFloatingPointCell = 14,
33     QpLabelCell         = 15,
34     QpFormulaCell       = 16,
35     QpPassword          = 75,
36     QpBop               = 202,
37     QpPageName          = 204,
38     QpUnknown           = -1
39 };
40 
41 // -----------------------------------------------------------------------
42 
43 class QpRec
44 {
45 public:
46     explicit QpRec(QpRecType pType);
47     ~QpRec();
48 
49     QP_INT16 type();
50 
51 protected:
52     QP_INT16 cType;
53 };
54 
55 // -----------------------------------------------------------------------
56 
57 //class QP_CELL_REF
58 //{
59 //public:
60 //   QP_CELL_REF(QpIStream& pIn);
61 //   ~QP_CELL_REF();
62 //
63 //   QP_UINT8 Column();
64 //   QP_INT16 Row();
65 //
66 //protected:
67 //   QP_UINT8 cColumn;
68 //   QP_INT16 cNoteBook;
69 //   QP_INT8  cPage;
70 //   QP_INT16 cRow;
71 //};
72 
73 // -----------------------------------------------------------------------
74 
75 class QpRecCell : public QpRec
76 {
77 public:
78     explicit QpRecCell(QpRecType pType);
79     ~QpRecCell();
80 
81     void        attributes(QP_INT16 pAttributes);
82     QP_INT16    attributes();
83 
84 //   const char* cellRef();
85     void        cellRef(char* pText, QpTableNames& pTable, QP_INT16 pNoteBook, QP_UINT8 pPage, QP_UINT8 pColumn, QP_INT16 pRow);
86     void        cellRef(char* pText, QpTableNames& pTable, QpIStream& pFormulaRef);
87 
88     void        column(QP_UINT8 pColumn);
89     QP_UINT8    column();
90 
91     void        row(QP_INT16 pRow);
92     QP_INT16    row();
93 
94 protected:
95     int         loadCellInfo(QpIStream& pIn);
96 
97     QP_INT16 cAttributes;
98     QP_UINT8 cColumn;
99     QP_UINT8 cPage;
100     QP_INT16 cRow;
101     char*    cCellRef;
102 };
103 
104 // -----------------------------------------------------------------------
105 
106 class QpRecBof : public QpRec
107 {
108 public:
109     QpRecBof(QP_INT16 pLen, QpIStream& pIn);
110     ~QpRecBof();
111 
112     void     fileFormat(QP_INT16 pFileFormat);
113     QP_INT16 fileFormat();
114 
115 protected:
116     QP_INT16 cFileFormat;
117 };
118 
119 // -----------------------------------------------------------------------
120 
121 class QpRecEof : public QpRec
122 {
123 public:
124     QpRecEof(QP_INT16 pLen, QpIStream& pIn);
125     ~QpRecEof();
126 };
127 
128 
129 // -----------------------------------------------------------------------
130 
131 class QpRecRecalcMode : public QpRec
132 {
133 public:
134     enum MODE {Manual = 0, Background = 1, Automatic = 255};
135 
136     QpRecRecalcMode(QP_INT16 pLen, QpIStream& pIn);
137     ~QpRecRecalcMode();
138 
139     void mode(MODE pMode);
140     MODE mode();
141 
142 protected:
143     MODE cMode;
144 };
145 
146 
147 // -----------------------------------------------------------------------
148 
149 class QpRecRecalcOrder : public QpRec
150 {
151 public:
152     enum ORDER { Natural = 0, Column = 1, Row = 255 };
153 
154     QpRecRecalcOrder(QP_INT16 pLen, QpIStream& pIn);
155     ~QpRecRecalcOrder();
156 
157     void  order(ORDER pOrder);
158     ORDER order();
159 
160 protected:
161     ORDER cOrder;
162 };
163 
164 
165 // -----------------------------------------------------------------------
166 
167 // QpRecDimension
168 // -----------------------------------------------------------------------
169 
170 // QpRecName
171 
172 // -----------------------------------------------------------------------
173 
174 class QpRecEmptyCell : public QpRecCell
175 {
176 public:
177     QpRecEmptyCell(QP_INT16 pLen, QpIStream& pIn);
178     ~QpRecEmptyCell();
179 };
180 
181 
182 // -----------------------------------------------------------------------
183 
184 class QpRecIntegerCell : public QpRecCell
185 {
186 public:
187     QpRecIntegerCell(QP_INT16 pLen, QpIStream& pIn);
188     ~QpRecIntegerCell();
189 
190 
191     QP_INT16 integer();
192 protected:
193     QP_INT16 cInt;
194 };
195 
196 // -----------------------------------------------------------------------
197 
198 class QpRecFloatingPointCell : public QpRecCell
199 {
200 public:
201     QpRecFloatingPointCell(QP_INT16 pLen, QpIStream& pIn);
202     ~QpRecFloatingPointCell();
203 
204     QP_INT64 value();
205 protected:
206     QP_INT64 cValue;
207 };
208 
209 // -----------------------------------------------------------------------
210 
211 class QpRecFormulaCell : public QpRecCell
212 {
213 public:
214     QpRecFormulaCell(QP_INT16 pLen, QpIStream& pIn);
215     ~QpRecFormulaCell();
216 
217     const char* formula();
218     QP_INT16    formulaReferences();
219     QP_INT16    formulaLen();
220 
221 protected:
222     QP_INT16    cCellRef;
223     char*       cFormula;
224     QP_INT64    cLastValue;
225     QP_INT16    cLen;
226     QP_INT16    cState;
227 };
228 
229 // -----------------------------------------------------------------------
230 
231 class QpRecLabelCell : public QpRecCell
232 {
233 public:
234     QpRecLabelCell(QP_INT16 pLen, QpIStream& pIn);
235     ~QpRecLabelCell();
236 
237     char        labelPrefix();
238     const char* label();
239 
240 protected:
241     char  cLabelPrefix;
242     char* cLabel;
243 };
244 
245 // -----------------------------------------------------------------------
246 
247 class QpRecUnknown : public QpRec
248 {
249 public:
250     QpRecUnknown(QP_INT16 pType, QP_INT16 pLen, QpIStream& pIn);
251     ~QpRecUnknown();
252 };
253 
254 // -----------------------------------------------------------------------
255 
256 class QpRecBop : public QpRec
257 {
258 public:
259     QpRecBop(QP_INT16 pLen, QpIStream& pIn);
260     ~QpRecBop();
261 
262     QP_UINT8 pageIndex();
263 
264 protected:
265     QP_UINT8 cPageIndex;
266 };
267 
268 // -----------------------------------------------------------------------
269 
270 class QpRecPageName : public QpRec
271 {
272 public:
273     QpRecPageName(QP_INT16 pLen, QpIStream& pIn);
274     ~QpRecPageName();
275 
276     const char* pageName();
277 
278 protected:
279     char* cPageName;
280 };
281 
282 // -----------------------------------------------------------------------
283 
284 class QpRecPassword : public QpRec
285 {
286 public:
287     QpRecPassword(QP_INT16 pLen, QpIStream& pIn);
288     ~QpRecPassword();
289 
290     const QP_UINT8* password();
291 
292 protected:
293     QP_UINT8* cPassword;
294 };
295 
296 #endif // QPRO_RECORD_H
297 
298