From 7a62e8e3601ee98f5f06261c361fe8132334cd56 Mon Sep 17 00:00:00 2001 From: ar Date: Sat, 12 Jun 2004 09:24:00 +0000 Subject: - rename sheet-qt -> opie-sheet - format source code for a better readability --- (limited to 'noncore/apps/opie-sheet/Excel.h') 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,13 +1,43 @@ +/* + =. This file is part of the Opie Project + .=l. Copyright (C) 2004 Opie Developer Team + .>+-= + _;:, .> :=|. This program is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -`: PARTICULAR PURPOSE. See the GNU +..}^=.= = ; Library General Public License for more +++= -. .` .: details. + : = ...= . :.=- + -. .:....=;==+<; You should have received a copy of the GNU + -_. . . )=. = Library General Public License along with + -- :-=` this library; see the file COPYING.LIB. + If not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ + +/* QT */ +#include +#include +#include +/* STD */ #include #include #include #include #include #include -#include -#include -#include #define DATEFORMAT 0x1 #define NUMBERFORMAT 0x2 @@ -55,151 +85,144 @@ class ExcelFormat { public: -int code; -int type; -QString format; -ExcelFormat(); -ExcelFormat(int c,int t, QString s); + int code; + int type; + QString format; + ExcelFormat(); + ExcelFormat(int c,int t, QString s); }; struct xfrecord { -int code; -int type; -QString format; + int code; + int type; + QString format; }; class ExcelCell { public: -int type; -int row,col; -int xfindex; //xf format index of cell -int valuei; -double valued; -QString valuec; + int type; + int row,col; + int xfindex; //xf format index of cell + int valuei; + double valued; + QString valuec; }; class ExcelBREC { public: - int code; - int length; - int position; - char* data; + int code; + int length; + int position; + char* data; }; class SSTList { public: - QArray rec; + QArray rec; }; class ExcelSheet { public: - QString name; - ExcelBREC BOFRecord; - int position; - int type; - int rows; - int cols; - - int cellsize,rowalloc,cellalloc; - QArray Cells; - bool InitCells(void); // true if ok - ExcelCell* Get(int row, int col); - void Set(int row, int col, ExcelCell* cell); + QString name; + ExcelBREC BOFRecord; + int position; + int type; + int rows; + int cols; + + int cellsize,rowalloc,cellalloc; + QArray Cells; + bool InitCells(void); // true if ok + ExcelCell* Get(int row, int col); + void Set(int row, int col, ExcelCell* cell); }; -struct mulrk { - int row; - int first; - int last; - int numrks; - QArray rknumbers; - QArray rkdbls; - QArray xfindices; +struct mulrk +{ + int row; + int first; + int last; + int numrks; + QArray rknumbers; + QArray rkdbls; + QArray xfindices; }; - - - class ExcelBook { public: -FILE *File; -int Position; -//int stringcount; -QArray SharedStrings; -//int xfcount; -QArray XFRecords; -//int Sheetcount; -QArray Sheets; -//int name count; -QArray Names; - -QString dateformat; -int Version; -int endian; -int Integer2Byte(int b1, int b2 ); -int Integer4Byte(int b1, int b2, int b3, int b4 ); -int Integer2ByteFile(FILE *f); -float Float4Byte(int b1, int b2, int b3, int b4); -double Double4Byte(int b1, int b2, int b3, int b4); -double Double8Byte(int b1, int b2, int b3, int b4, int b5, int b6, int b7, int b8); -void DetectEndian(void); - -bool OpenFile(char *Filename); // true if ok -bool CloseFile(void); // true if ok -void SeekPosition(int pos); // go to Pos -void SeekSkip(int pos); // skips pos bytes. -int FileEOF(void); //returns -1 if EOF else 0 -int Get2Bytes(void); //gets an int from the file -char* Read(int pos, int length); -QString ReadUnicodeChar(int pos, int length); -QString* GetString(int num); //gets the num string from SharedStrings; -int SeekBOF(void); -ExcelBREC* GetBREC(void); -ExcelBREC* PeekBREC(void); -char* GetDataOfBREC(ExcelBREC* record); -void ConvertCharToArray(ExcelBREC* record, char* chars, int length); -int SheetHandleRecord(ExcelSheet* sheet, ExcelBREC* record); -int ReadSheet(ExcelSheet* sheet); //read the sheet sheet* -ExcelSheet* GetSheet(void); -void ParseSheets(void); -void GetSheets(void); - -bool ParseBook(char *file); // THIS IS THE MAIN PARSE FUNCTION of file -QString GetASCII(char* inbytes, int pos, int chars); -QString GetUnicode(char * inbytes, int pos, int chars); -void HandleBoundSheet( ExcelBREC* rec); -void HandleName(ExcelSheet* sheet, ExcelBREC* rec); -ExcelFormat* GetFormatting(int xf); -void HandleSetOfSST(ExcelBREC* rec/*, SSTList* cont*/, char* bytes); -char* MergeBytesFromSSTs(ExcelBREC* rec,SSTList* cont); -void HandleSST(ExcelBREC* rec); -void HandleLabelSST(ExcelSheet* sheet, ExcelBREC* rec); -ExcelCell* CellLabel(int row, int col, QString str); -ExcelCell* CellNumber(int row, int col, int index, double d); -QString* CellDataString(ExcelSheet* sh, int row, int col); -int CellGetPrecision(double d); -void CellSetDateFormat(char *d); -void HandleMulrk(ExcelSheet* sheet, ExcelBREC* record); -void MulrkRead(struct mulrk *mulrk, char* data); -void HandleNumber(ExcelSheet* sheet, ExcelBREC* record); -void HandleFormat(ExcelBREC* rec); -void HandleXF(ExcelBREC* rec); -void HandleRK(ExcelSheet* sheet, ExcelBREC* record); -void HandleFormula(ExcelSheet* sheet, ExcelBREC* record); -QString GetFormula(int row, int col, ExcelSheet* sheet, char* data, int sz); -QString FindCellName(int row, int col); - - - - - + FILE *File; + int Position; + //int stringcount; + QArray SharedStrings; + //int xfcount; + QArray XFRecords; + //int Sheetcount; + QArray Sheets; + //int name count; + QArray Names; + + QString dateformat; + int Version; + int endian; + int Integer2Byte(int b1, int b2 ); + int Integer4Byte(int b1, int b2, int b3, int b4 ); + int Integer2ByteFile(FILE *f); + float Float4Byte(int b1, int b2, int b3, int b4); + double Double4Byte(int b1, int b2, int b3, int b4); + double Double8Byte(int b1, int b2, int b3, int b4, int b5, int b6, int b7, int b8); + void DetectEndian(void); + + bool OpenFile(char *Filename); // true if ok + bool CloseFile(void); // true if ok + void SeekPosition(int pos); // go to Pos + void SeekSkip(int pos); // skips pos bytes. + int FileEOF(void); //returns -1 if EOF else 0 + int Get2Bytes(void); //gets an int from the file + char* Read(int pos, int length); + QString ReadUnicodeChar(int pos, int length); + QString* GetString(int num); //gets the num string from SharedStrings; + int SeekBOF(void); + ExcelBREC* GetBREC(void); + ExcelBREC* PeekBREC(void); + char* GetDataOfBREC(ExcelBREC* record); + void ConvertCharToArray(ExcelBREC* record, char* chars, int length); + int SheetHandleRecord(ExcelSheet* sheet, ExcelBREC* record); + int ReadSheet(ExcelSheet* sheet); //read the sheet sheet* + ExcelSheet* GetSheet(void); + void ParseSheets(void); + void GetSheets(void); + + bool ParseBook(char *file); // THIS IS THE MAIN PARSE FUNCTION of file + QString GetASCII(char* inbytes, int pos, int chars); + QString GetUnicode(char * inbytes, int pos, int chars); + void HandleBoundSheet( ExcelBREC* rec); + void HandleName(ExcelSheet* sheet, ExcelBREC* rec); + ExcelFormat* GetFormatting(int xf); + void HandleSetOfSST(ExcelBREC* rec/*, SSTList* cont*/, char* bytes); + char* MergeBytesFromSSTs(ExcelBREC* rec,SSTList* cont); + void HandleSST(ExcelBREC* rec); + void HandleLabelSST(ExcelSheet* sheet, ExcelBREC* rec); + ExcelCell* CellLabel(int row, int col, QString str); + ExcelCell* CellNumber(int row, int col, int index, double d); + QString* CellDataString(ExcelSheet* sh, int row, int col); + int CellGetPrecision(double d); + void CellSetDateFormat(char *d); + void HandleMulrk(ExcelSheet* sheet, ExcelBREC* record); + void MulrkRead(struct mulrk *mulrk, char* data); + void HandleNumber(ExcelSheet* sheet, ExcelBREC* record); + void HandleFormat(ExcelBREC* rec); + void HandleXF(ExcelBREC* rec); + void HandleRK(ExcelSheet* sheet, ExcelBREC* record); + void HandleFormula(ExcelSheet* sheet, ExcelBREC* record); + QString GetFormula(int row, int col, ExcelSheet* sheet, char* data, int sz); + QString FindCellName(int row, int col); }; -- cgit v0.9.0.2