summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-sheet/Excel.h
Unidiff
Diffstat (limited to 'noncore/apps/opie-sheet/Excel.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-sheet/Excel.h255
1 files changed, 139 insertions, 116 deletions
diff --git a/noncore/apps/opie-sheet/Excel.h b/noncore/apps/opie-sheet/Excel.h
index 0a581cf..51ccf5c 100644
--- a/noncore/apps/opie-sheet/Excel.h
+++ b/noncore/apps/opie-sheet/Excel.h
@@ -1,2 +1,35 @@
1/*
2 =. This file is part of the Opie Project
3 .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org>
4 .>+-=
5 _;:, .> :=|. This program is free software; you can
6.> <`_, > . <= redistribute it and/or modify it under
7:`=1 )Y*s>-.-- : the terms of the GNU General Public
8.="- .-=="i, .._ License as published by the Free Software
9 - . .-<_> .<> Foundation; either version 2 of the License,
10 ._= =} : or (at your option) any later version.
11 .%`+i> _;_.
12 .i_,=:_. -<s. This program is distributed in the hope that
13 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
14 : .. .:, . . . without even the implied warranty of
15 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
16 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.= = ; Library General Public License for more
18++= -. .` .: details.
19 : = ...= . :.=-
20 -. .:....=;==+<; You should have received a copy of the GNU
21 -_. . . )=. = Library General Public License along with
22 -- :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29/* QT */
30#include <qstring.h>
31#include <qarray.h>
32#include <qlist.h>
1 33
34/* STD */
2#include <stdio.h> 35#include <stdio.h>
@@ -7,5 +40,2 @@
7#include <strings.h> 40#include <strings.h>
8#include <qstring.h>
9#include <qarray.h>
10#include <qlist.h>
11 41
@@ -57,7 +87,7 @@ class ExcelFormat
57public: 87public:
58int code; 88 int code;
59int type; 89 int type;
60QString format; 90 QString format;
61ExcelFormat(); 91 ExcelFormat();
62ExcelFormat(int c,int t, QString s); 92 ExcelFormat(int c,int t, QString s);
63}; 93};
@@ -66,5 +96,5 @@ struct xfrecord
66{ 96{
67int code; 97 int code;
68int type; 98 int type;
69QString format; 99 QString format;
70}; 100};
@@ -74,8 +104,8 @@ class ExcelCell
74public: 104public:
75int type; 105 int type;
76int row,col; 106 int row,col;
77int xfindex; //xf format index of cell 107 int xfindex; //xf format index of cell
78int valuei; 108 int valuei;
79double valued; 109 double valued;
80QString valuec; 110 QString valuec;
81 111
@@ -86,6 +116,6 @@ class ExcelBREC
86public: 116public:
87 int code; 117 int code;
88 int length; 118 int length;
89 int position; 119 int position;
90 char* data; 120 char* data;
91}; 121};
@@ -95,3 +125,3 @@ class SSTList
95public: 125public:
96 QArray <ExcelBREC*> rec; 126 QArray <ExcelBREC*> rec;
97}; 127};
@@ -101,14 +131,14 @@ class ExcelSheet
101public: 131public:
102 QString name; 132 QString name;
103 ExcelBREC BOFRecord; 133 ExcelBREC BOFRecord;
104 int position; 134 int position;
105 int type; 135 int type;
106 int rows; 136 int rows;
107 int cols; 137 int cols;
108 138
109 int cellsize,rowalloc,cellalloc; 139 int cellsize,rowalloc,cellalloc;
110 QArray <ExcelCell*> Cells; 140 QArray <ExcelCell*> Cells;
111 bool InitCells(void); // true if ok 141 bool InitCells(void); // true if ok
112 ExcelCell* Get(int row, int col); 142 ExcelCell* Get(int row, int col);
113 void Set(int row, int col, ExcelCell* cell); 143 void Set(int row, int col, ExcelCell* cell);
114 144
@@ -116,15 +146,13 @@ public:
116 146
117struct mulrk { 147struct mulrk
118 int row; 148{
119 int first; 149 int row;
120 int last; 150 int first;
121 int numrks; 151 int last;
122 QArray<int> rknumbers; 152 int numrks;
123 QArray<double> rkdbls; 153 QArray<int> rknumbers;
124 QArray<int> xfindices; 154 QArray<double> rkdbls;
155 QArray<int> xfindices;
125}; 156};
126 157
127
128
129
130class ExcelBook 158class ExcelBook
@@ -132,73 +160,68 @@ class ExcelBook
132public: 160public:
133FILE *File; 161 FILE *File;
134int Position; 162 int Position;
135//int stringcount; 163 //int stringcount;
136QArray <QString*> SharedStrings; 164 QArray <QString*> SharedStrings;
137//int xfcount; 165 //int xfcount;
138QArray <ExcelFormat*> XFRecords; 166 QArray <ExcelFormat*> XFRecords;
139//int Sheetcount; 167 //int Sheetcount;
140QArray <ExcelSheet*> Sheets; 168 QArray <ExcelSheet*> Sheets;
141//int name count; 169 //int name count;
142QArray <QString*> Names; 170 QArray <QString*> Names;
143 171
144QString dateformat; 172 QString dateformat;
145int Version; 173 int Version;
146int endian; 174 int endian;
147int Integer2Byte(int b1, int b2 ); 175 int Integer2Byte(int b1, int b2 );
148int Integer4Byte(int b1, int b2, int b3, int b4 ); 176 int Integer4Byte(int b1, int b2, int b3, int b4 );
149int Integer2ByteFile(FILE *f); 177 int Integer2ByteFile(FILE *f);
150float Float4Byte(int b1, int b2, int b3, int b4); 178 float Float4Byte(int b1, int b2, int b3, int b4);
151double Double4Byte(int b1, int b2, int b3, int b4); 179 double Double4Byte(int b1, int b2, int b3, int b4);
152double Double8Byte(int b1, int b2, int b3, int b4, int b5, int b6, int b7, int b8); 180 double Double8Byte(int b1, int b2, int b3, int b4, int b5, int b6, int b7, int b8);
153void DetectEndian(void); 181 void DetectEndian(void);
154 182
155bool OpenFile(char *Filename); // true if ok 183 bool OpenFile(char *Filename); // true if ok
156bool CloseFile(void); // true if ok 184 bool CloseFile(void); // true if ok
157void SeekPosition(int pos); // go to Pos 185 void SeekPosition(int pos); // go to Pos
158void SeekSkip(int pos); // skips pos bytes. 186 void SeekSkip(int pos); // skips pos bytes.
159int FileEOF(void); //returns -1 if EOF else 0 187 int FileEOF(void); //returns -1 if EOF else 0
160int Get2Bytes(void); //gets an int from the file 188 int Get2Bytes(void); //gets an int from the file
161char* Read(int pos, int length); 189 char* Read(int pos, int length);
162QString ReadUnicodeChar(int pos, int length); 190 QString ReadUnicodeChar(int pos, int length);
163QString* GetString(int num); //gets the num string from SharedStrings; 191 QString* GetString(int num); //gets the num string from SharedStrings;
164int SeekBOF(void); 192 int SeekBOF(void);
165ExcelBREC* GetBREC(void); 193 ExcelBREC* GetBREC(void);
166ExcelBREC* PeekBREC(void); 194 ExcelBREC* PeekBREC(void);
167char* GetDataOfBREC(ExcelBREC* record); 195 char* GetDataOfBREC(ExcelBREC* record);
168void ConvertCharToArray(ExcelBREC* record, char* chars, int length); 196 void ConvertCharToArray(ExcelBREC* record, char* chars, int length);
169int SheetHandleRecord(ExcelSheet* sheet, ExcelBREC* record); 197 int SheetHandleRecord(ExcelSheet* sheet, ExcelBREC* record);
170int ReadSheet(ExcelSheet* sheet); //read the sheet sheet* 198 int ReadSheet(ExcelSheet* sheet); //read the sheet sheet*
171ExcelSheet* GetSheet(void); 199 ExcelSheet* GetSheet(void);
172void ParseSheets(void); 200 void ParseSheets(void);
173void GetSheets(void); 201 void GetSheets(void);
174 202
175bool ParseBook(char *file); // THIS IS THE MAIN PARSE FUNCTION of file 203 bool ParseBook(char *file); // THIS IS THE MAIN PARSE FUNCTION of file
176QString GetASCII(char* inbytes, int pos, int chars); 204 QString GetASCII(char* inbytes, int pos, int chars);
177QString GetUnicode(char * inbytes, int pos, int chars); 205 QString GetUnicode(char * inbytes, int pos, int chars);
178void HandleBoundSheet( ExcelBREC* rec); 206 void HandleBoundSheet( ExcelBREC* rec);
179void HandleName(ExcelSheet* sheet, ExcelBREC* rec); 207 void HandleName(ExcelSheet* sheet, ExcelBREC* rec);
180ExcelFormat* GetFormatting(int xf); 208 ExcelFormat* GetFormatting(int xf);
181void HandleSetOfSST(ExcelBREC* rec/*, SSTList* cont*/, char* bytes); 209 void HandleSetOfSST(ExcelBREC* rec/*, SSTList* cont*/, char* bytes);
182char* MergeBytesFromSSTs(ExcelBREC* rec,SSTList* cont); 210 char* MergeBytesFromSSTs(ExcelBREC* rec,SSTList* cont);
183void HandleSST(ExcelBREC* rec); 211 void HandleSST(ExcelBREC* rec);
184void HandleLabelSST(ExcelSheet* sheet, ExcelBREC* rec); 212 void HandleLabelSST(ExcelSheet* sheet, ExcelBREC* rec);
185ExcelCell* CellLabel(int row, int col, QString str); 213 ExcelCell* CellLabel(int row, int col, QString str);
186ExcelCell* CellNumber(int row, int col, int index, double d); 214 ExcelCell* CellNumber(int row, int col, int index, double d);
187QString* CellDataString(ExcelSheet* sh, int row, int col); 215 QString* CellDataString(ExcelSheet* sh, int row, int col);
188int CellGetPrecision(double d); 216 int CellGetPrecision(double d);
189void CellSetDateFormat(char *d); 217 void CellSetDateFormat(char *d);
190void HandleMulrk(ExcelSheet* sheet, ExcelBREC* record); 218 void HandleMulrk(ExcelSheet* sheet, ExcelBREC* record);
191void MulrkRead(struct mulrk *mulrk, char* data); 219 void MulrkRead(struct mulrk *mulrk, char* data);
192void HandleNumber(ExcelSheet* sheet, ExcelBREC* record); 220 void HandleNumber(ExcelSheet* sheet, ExcelBREC* record);
193void HandleFormat(ExcelBREC* rec); 221 void HandleFormat(ExcelBREC* rec);
194void HandleXF(ExcelBREC* rec); 222 void HandleXF(ExcelBREC* rec);
195void HandleRK(ExcelSheet* sheet, ExcelBREC* record); 223 void HandleRK(ExcelSheet* sheet, ExcelBREC* record);
196void HandleFormula(ExcelSheet* sheet, ExcelBREC* record); 224 void HandleFormula(ExcelSheet* sheet, ExcelBREC* record);
197QString GetFormula(int row, int col, ExcelSheet* sheet, char* data, int sz); 225 QString GetFormula(int row, int col, ExcelSheet* sheet, char* data, int sz);
198QString FindCellName(int row, int col); 226 QString FindCellName(int row, int col);
199
200
201
202
203
204}; 227};