summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-sheet/Excel.cpp
Side-by-side diff
Diffstat (limited to 'noncore/apps/opie-sheet/Excel.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-sheet/Excel.cpp83
1 files changed, 65 insertions, 18 deletions
diff --git a/noncore/apps/opie-sheet/Excel.cpp b/noncore/apps/opie-sheet/Excel.cpp
index fc49d56..57aef20 100644
--- a/noncore/apps/opie-sheet/Excel.cpp
+++ b/noncore/apps/opie-sheet/Excel.cpp
@@ -1,13 +1,41 @@
+/*
+ =. This file is part of the Opie Project
+ .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org>
+ .>+-=
+ _;:, .> :=|. 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_,=:_. -<s. This program is distributed in the hope that
+ + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
+ : .. .:, . . . without even the implied warranty of
+ =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
+ _.=:. : :=>`: 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.
+
+*/
+#include "Excel.h"
+/* STD */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <sys/types.h>
#include <strings.h>
-#include "Excel.h"
static xfrecord formatter[] = {
{ 0xe , DATEFORMAT, "%m/%d/%y"},
{ 0xf , DATEFORMAT, "%d-%b-%y"},
@@ -62,9 +90,10 @@ int ExcelBook::Integer4Byte(int b1,int b2,int b3,int b4)
int val = i2 << 16 | i1;
return val;
};
-int ExcelBook::Integer2ByteFile(FILE *f) {
+int ExcelBook::Integer2ByteFile(FILE *f)
+{
int i1, i2;
i1 = fgetc(f);
i2 = fgetc(f);
return Integer2Byte(i1,i2);
@@ -101,9 +130,10 @@ double ExcelBook::Double4Byte(int b1, int b2, int b3, int b4)
{
value /= 100.0;
};
return value;
- }else
+ }
+ else
{
union { double d; unsigned long int b[2]; } dbl_byte;
unsigned long int valbits = (rk & 0xfffffffc);
@@ -131,12 +161,15 @@ void ExcelBook::DetectEndian(void)
int end;
long i = 0x44332211;
unsigned char* a = (unsigned char*) &i;
end = (*a != 0x11);
- if (end == 1) {
+ if (end == 1)
+ {
endian = BIG_ENDIAN;
printf("BIGENDIAN!\r\n");
- } else {
+ }
+ else
+ {
endian = LITTLE_ENDIAN;
printf("LITTLEENDIAN!\r\n");
}
};
@@ -147,14 +180,17 @@ double ExcelBook::Double8Byte(int b1, int b2, int b3, int b4, int b5, int b6, in
double d;
unsigned char *ieee;
ieee = (unsigned char *)&d;
for (i = 0; i < 8; i++) ieee[i] = 0;
- if (endian == BIG_ENDIAN) {
+ if (endian == BIG_ENDIAN)
+ {
ieee[0] = ((int)b8) & 0xff;ieee[1] = ((int)b7) & 0xff;
ieee[2] = ((int)b6) & 0xff;ieee[3] = ((int)b5) & 0xff;
ieee[4] = ((int)b4) & 0xff;ieee[5] = ((int)b3) & 0xff;
ieee[6] = ((int)b2) & 0xff;ieee[7] = ((int)b1) & 0xff;
- } else {
+ }
+ else
+ {
ieee[0] = ((int)b1) & 0xff;ieee[1] = ((int)b2) & 0xff;
ieee[2] = ((int)b3) & 0xff;ieee[3] = ((int)b4) & 0xff;
ieee[4] = ((int)b5) & 0xff;ieee[5] = ((int)b6) & 0xff;
ieee[6] = ((int)b7) & 0xff;ieee[7] = ((int)b8) & 0xff;
@@ -392,9 +428,10 @@ int ExcelBook::SheetHandleRecord(ExcelSheet* sheet, ExcelBREC* record)
if (record->length == 10)
{
sheet->rows = Integer2Byte(data[2], data[3]);
sheet->cols = Integer2Byte(data[6], data[7]);
- } else
+ }
+ else
{
sheet->rows = Integer4Byte(data[4], data[5], data[6], data[7]);
sheet->cols = Integer2Byte(data[10], data[11]);
}
@@ -601,9 +638,10 @@ void ExcelBook::HandleBoundSheet(ExcelBREC* rec)
if(data[7]==0)
{
//ascii
name=GetASCII(data,pos,length);
- }else
+ }
+ else
{
name=GetUnicode(data,pos,length);
};
Names.resize(Names.count()+1);
@@ -807,22 +845,25 @@ QString* ExcelBook::CellDataString(ExcelSheet* sh, int row, int col)
tmptr = gmtime(&date);
if (dateformat)
{
strftime(str,1024,dateformat.ascii(),tmptr);
- } else
+ }
+ else
{
strftime(str,1024,format.ascii(),tmptr);
};
- } else
+ }
+ else
if (XFRecords[c->xfindex]->type == NUMBERFORMAT)
{
format = XFRecords[c->xfindex]->format;
//sprintf(str,format.ascii(),c->valued);
// the real format is ignored...
// because there is more work to be done in the field
precision = CellGetPrecision(c->valued);
sprintf(str,"%.*f",precision,c->valued);
- }else
+ }
+ else
{
precision = CellGetPrecision(c->valued);
sprintf(str,"%.*f",precision,c->valued);
};
@@ -1001,13 +1042,15 @@ void ExcelBook::HandleFormula(ExcelSheet* sheet, ExcelBREC* record)
col = Integer2Byte(data[2], data[3]);
if (data[6] == 0 && data[12] == -1 && data[13] == -1)
{
// string
- } else
+ }
+ else
if (data[6] == 1 && data[12] == -1 && data[13] == -1)
{
// boolean
- } else
+ }
+ else
if ( data[6] == 2 && data[12] == -1 && data[13] == -1)
{
// error
}
@@ -1122,9 +1165,10 @@ QString ExcelBook::GetFormula(int row, int col, ExcelSheet* sheet, char* data, i
idx += fareastsize;
};
s1=QString("""")+s1+QString("""");
operands.prepend(new QString(s1));
- }else
+ }
+ else
{
w1=data[idx];idx++;
s1=GetASCII(data,idx,w1);
s1=QString("""")+s1+QString("""");
@@ -1141,9 +1185,10 @@ QString ExcelBook::GetFormula(int row, int col, ExcelSheet* sheet, char* data, i
w1=Integer2Byte(data[idx],data[idx+1]);idx=idx+2;//row1
w2=Integer2Byte(data[idx],data[idx+1]);idx=idx+2;//row2
w3=Integer2Byte(data[idx],data[idx+1]) & 0x00FF;idx=idx+2;//col1
w4=Integer2Byte(data[idx],data[idx+1]) & 0x00FF;idx=idx+2;//col2
- }else
+ }
+ else
{
w1=Integer2Byte(data[idx],data[idx+1]) & 0x3FFF;idx=idx+2;//row1
w2=Integer2Byte(data[idx],data[idx+1]) & 0x3FFF;idx=idx+2;//row2
w3=Integer2Byte(data[idx],data[idx+1]);idx=idx+2;//col1
@@ -1160,9 +1205,10 @@ QString ExcelBook::GetFormula(int row, int col, ExcelSheet* sheet, char* data, i
if(Version==8)
{
w1=Integer2Byte(data[idx],data[idx+1]);idx=idx+2;//row
w2=Integer2Byte(data[idx],data[idx+1]) & 0x00FF;idx=idx+2;//col
- }else
+ }
+ else
{
w1=Integer2Byte(data[idx],data[idx+1]) & 0x3FFF;idx=idx+2;//row
w2=Integer2Byte(data[idx],data[idx+1]);idx=idx+2;//col
};
@@ -1331,9 +1377,10 @@ QString ExcelBook::GetFormula(int row, int col, ExcelSheet* sheet, char* data, i
if(token==0x22||token==0x42||token==0x62)
{
w2=(int)data[idx];idx++;
w1=Integer2Byte(data[idx],data[idx+1]);idx=idx+2;
- }else
+ }
+ else
{
w1=Integer2Byte(data[idx],data[idx+1]);idx=idx+2;
};
switch(w1)