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,12 +1,40 @@
+/*
+ =. 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"},
@@ -63,7 +91,8 @@ int ExcelBook::Integer4Byte(int b1,int b2,int b3,int b4)
return val;
};
-int ExcelBook::Integer2ByteFile(FILE *f) {
+int ExcelBook::Integer2ByteFile(FILE *f)
+{
int i1, i2;
i1 = fgetc(f);
i2 = fgetc(f);
@@ -102,7 +131,8 @@ 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;
@@ -132,10 +162,13 @@ void ExcelBook::DetectEndian(void)
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");
}
@@ -148,12 +181,15 @@ double ExcelBook::Double8Byte(int b1, int b2, int b3, int b4, int b5, int b6, in
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;
@@ -393,7 +429,8 @@ int ExcelBook::SheetHandleRecord(ExcelSheet* sheet, ExcelBREC* record)
{
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]);
@@ -602,7 +639,8 @@ void ExcelBook::HandleBoundSheet(ExcelBREC* rec)
{
//ascii
name=GetASCII(data,pos,length);
- }else
+ }
+ else
{
name=GetUnicode(data,pos,length);
};
@@ -808,11 +846,13 @@ QString* ExcelBook::CellDataString(ExcelSheet* sh, int row, int col)
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;
@@ -821,7 +861,8 @@ QString* ExcelBook::CellDataString(ExcelSheet* sh, int row, int col)
// 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);
@@ -1002,11 +1043,13 @@ void ExcelBook::HandleFormula(ExcelSheet* sheet, ExcelBREC* record)
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
@@ -1123,7 +1166,8 @@ QString ExcelBook::GetFormula(int row, int col, ExcelSheet* sheet, char* data, i
};
s1=QString("""")+s1+QString("""");
operands.prepend(new QString(s1));
- }else
+ }
+ else
{
w1=data[idx];idx++;
s1=GetASCII(data,idx,w1);
@@ -1142,7 +1186,8 @@ QString ExcelBook::GetFormula(int row, int col, ExcelSheet* sheet, char* data, i
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
@@ -1161,7 +1206,8 @@ QString ExcelBook::GetFormula(int row, int col, ExcelSheet* sheet, char* data, i
{
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
@@ -1332,7 +1378,8 @@ QString ExcelBook::GetFormula(int row, int col, ExcelSheet* sheet, char* data, i
{
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;
};