author | ar <ar> | 2004-06-12 09:24:00 (UTC) |
---|---|---|
committer | ar <ar> | 2004-06-12 09:24:00 (UTC) |
commit | 7a62e8e3601ee98f5f06261c361fe8132334cd56 (patch) (side-by-side diff) | |
tree | 72e1e68878e32c70140fe1de478bced96670e348 | |
parent | 3fbf3cb264200c5ac11dbef43a51f3ab2a969587 (diff) | |
download | opie-7a62e8e3601ee98f5f06261c361fe8132334cd56.zip opie-7a62e8e3601ee98f5f06261c361fe8132334cd56.tar.gz opie-7a62e8e3601ee98f5f06261c361fe8132334cd56.tar.bz2 |
- rename sheet-qt -> opie-sheet
- format source code for a better readability
-rw-r--r-- | noncore/apps/opie-sheet/Excel.cpp | 83 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/Excel.h | 47 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/cellformat.cpp | 42 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/cellformat.h | 42 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/finddlg.cpp | 42 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/finddlg.h | 39 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/main.cpp | 35 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/mainwindow.cpp | 43 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/mainwindow.h | 43 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/numberdlg.cpp | 38 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/numberdlg.h | 36 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/opie-sheet.pro | 19 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/sheet.cpp | 122 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/sheet.h | 36 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/sortdlg.cpp | 42 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/sortdlg.h | 39 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/textdlg.cpp | 38 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/textdlg.h | 36 |
18 files changed, 618 insertions, 204 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,33 +1,61 @@ +/* + =. 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"}, { 0x10, DATEFORMAT, "%d-%b"}, { 0x11, DATEFORMAT, "%b-%y"}, { 0x12, DATEFORMAT, "%I:%M %p"}, { 0x13, DATEFORMAT, "%I:%M:%S %p"}, { 0x14, DATEFORMAT, "%H:%M"}, { 0x15, DATEFORMAT, "%H:%M:%S"}, { 0x16, DATEFORMAT, "%m/%d/%y %H:%M"}, { 0x2d, DATEFORMAT, "%M:%S"}, { 0x2e, DATEFORMAT, "%H:%M:%S"}, { 0x2f, DATEFORMAT, "%M:%S"}, { 0xa5, DATEFORMAT, "%m/%d/%y %I:%M %p"}, { 0x1 , NUMBERFORMAT, "%.0f"}, { 0x2 , NUMBERFORMAT, "%.2f"}, { 0x3 , NUMBERFORMAT, "#,##%.0f"}, { 0x4 , NUMBERFORMAT, "#,##%.2f"}, { 0x5 , NUMBERFORMAT, "$#,##%.0f"}, { 0x6 , NUMBERFORMAT, "$#,##%.0f"}, { 0x7 , NUMBERFORMAT, "$#,##%.2f"}, { 0x8 , NUMBERFORMAT, "$#,##%.2f"}, { 0x9 , NUMBERFORMAT, "%.0f%%"}, @@ -42,139 +70,147 @@ static xfrecord formatter[] = { { 0x2b, NUMBERFORMAT, "#,##%.2f;(#,##0.00)"}, { 0x2c, NUMBERFORMAT, "$#,##%.2f;($#,##0.00)"}, { 0x30, NUMBERFORMAT, "##0.0E0"}, { 0, 0, ""} }; int ExcelBook::Integer2Byte(int b1, int b2) { int i1 = b1 & 0xff; int i2 = b2 & 0xff; int val = i2 << 8 | i1; return val; }; int ExcelBook::Integer4Byte(int b1,int b2,int b3,int b4) { int i1 = Integer2Byte(b1, b2); int i2 = Integer2Byte(b3, 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); }; float ExcelBook::Float4Byte(int b1, int b2, int b3, int b4) { int i; float f; unsigned char *ieee; ieee = (unsigned char *) &f; for (i = 0; i < 4; i++) ieee[i] = 0; ieee[0] = ((int)b4) & 0xff; ieee[1] = ((int)b3) & 0xff; ieee[2] = ((int)b2) & 0xff; ieee[3] = ((int)b1) & 0xff; return f; }; double ExcelBook::Double4Byte(int b1, int b2, int b3, int b4) { long int rk; double value; rk=Integer4Byte(b1,b2,b3,b4); //printf("Double4Bytes:%d,%d,%d,%d\r\n",b1,b2,b3,b4); if ( (rk & 0x02) != 0) { long int intval = rk >> 2; //drops the 2 bits printf("Double4Byte:intval=%d, rk=%d, rk>>2=%d\r\n",intval,rk,rk>>2); value = (double) intval; printf("Double4Byte: VALUEINT=%f\r\n",value); if ( (rk & 0x01) != 0) { value /= 100.0; }; return value; - }else + } + else { union { double d; unsigned long int b[2]; } dbl_byte; unsigned long int valbits = (rk & 0xfffffffc); #if defined(__arm__) && !defined(__vfp__) dbl_byte.b[0]=valbits; dbl_byte.b[1]=0; #else dbl_byte.b[0]=0; dbl_byte.b[1]=valbits; #endif printf("dbl_byte.b[0]=%d,dbl_byte.b[1]=%d\r\n",dbl_byte.b[0],dbl_byte.b[1]); value=dbl_byte.d; printf("Double4Byte: VALUE=%f\r\n",value); if ( (rk & 0x01) != 0) { value /= 100.0; }; return value; }; }; 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"); } }; double ExcelBook::Double8Byte(int b1, int b2, int b3, int b4, int b5, int b6, int b7, int b8) { int i; 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; } return d; }; bool ExcelBook::OpenFile(char *Filename) { printf("Opening excel file!\r\n"); File= fopen(Filename, "r"); Position=0; // first byte index in file XFRecords.resize(0); SharedStrings.resize(0); Names.resize(0); Sheets.resize(0); if(File==NULL) return false; printf("Opened excel file!\r\n"); return true; }; bool ExcelBook::CloseFile(void) { @@ -372,49 +408,50 @@ void ExcelSheet::Set(int row, int col, ExcelCell* cell) { Cells[row*cols+col]=cell; }; }; ExcelCell* ExcelSheet::Get(int row, int col) { ExcelCell* cell; cell=Cells[row*cols+col]; if(cell==NULL) return NULL; return cell; }; int ExcelBook::SheetHandleRecord(ExcelSheet* sheet, ExcelBREC* record) { char* data=NULL; switch (record->code) { case XL_DIMENSION: data = GetDataOfBREC(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]); } sheet->InitCells(); break; case XL_LABELSST: HandleLabelSST(sheet, record); break; case XL_RK: case XL_RK2: HandleRK(sheet, record); break; case XL_MULRK: HandleMulrk(sheet, record); break; case XL_ROW: break; case XL_NUMBER: @@ -581,49 +618,50 @@ QString ExcelBook::GetUnicode(char * inbytes, int pos, int chars) outstr.append(QChar(rc)); i++; }; return outstr; }; void ExcelBook::HandleBoundSheet(ExcelBREC* rec) { char* data; int type; int visibility; int length; int pos; QString name; pos = 8; data = GetDataOfBREC(rec); type = data[4]; visibility = data[5]; length = data[6]; if(data[7]==0) { //ascii name=GetASCII(data,pos,length); - }else + } + else { name=GetUnicode(data,pos,length); }; Names.resize(Names.count()+1); Names[Names.count()-1]=new QString(name); }; void ExcelBook::HandleName(ExcelSheet* sheet, ExcelBREC* rec) { char* data; QString name; int length; int pos; pos = 15; data = GetDataOfBREC(rec); length = data[3]; name = GetASCII(data,pos,length); }; ExcelFormat* ExcelBook::GetFormatting(int xf) { int i; @@ -787,62 +825,65 @@ QString* ExcelBook::CellDataString(ExcelSheet* sh, int row, int col) time_t date; struct tm *tmptr; ExcelCell* c; char str[128]; QString format; int precision; int utcOffsetDays = 25569; int sInADay = 24 * 60 * 60; c = sh->Get(row,col); if (c == NULL) return new QString(""); switch (c->type) { case CELL_LABEL: return new QString(c->valuec); case CELL_NUMBER: if (XFRecords[c->xfindex]->type == DATEFORMAT) { format = XFRecords[c->xfindex]->format; date = (time_t) ((c->valued - utcOffsetDays) * sInADay); 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); }; break; case CELL_DATE: break; case CELL_BOOLEAN: break; case CELL_ERROR: break; } return new QString(str); }; int ExcelBook::CellGetPrecision(double d) { double t; int i,x; int count; if (d < 0) d *= -1; i = (int)d; t = d - (double)i; if (t <= 0) @@ -981,53 +1022,55 @@ void ExcelBook::HandleRK(ExcelSheet* sheet, ExcelBREC* record) int xfindex, row, col; char* data; double d; data = GetDataOfBREC(record); row = Integer2Byte(data[0], data[1]); col = Integer2Byte(data[2], data[3]); xfindex = Integer2Byte(data[4], data[5]); d=Double4Byte(data[6], data[7], data[8], data[9]); sheet->Set(row,col,CellNumber(row,col,xfindex,d)); //printf("handleRK:row=%d,col=%d,val=%f\r\n",row,col,d); }; void ExcelBook::HandleFormula(ExcelSheet* sheet, ExcelBREC* record) { int xfindex, row, col; char* data; double d; data = GetDataOfBREC(record); row = Integer2Byte(data[0], data[1]); 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 } else { // number xfindex = Integer2Byte(data[4], data[5]); d=Double8Byte(data[6], data[7], data[8], data[9],data[10], data[11], data[12], data[13]); QString s1; int sz; sz=Integer2Byte(data[20],data[21]);// size of the formula char* formuladata; formuladata=new char[sz]; for(int w1=0;w1<sz;w1++) { formuladata[w1]=data[22+w1]; }; //22 is the first 0 idx of formula data s1="="+GetFormula(row,col,sheet,formuladata,sz); //printf("GetFormula:Formula=%s\r\n",s1.ascii()); sheet->Set(row,col,CellLabel(row,col,s1)); } }; @@ -1102,87 +1145,90 @@ QString ExcelBook::GetFormula(int row, int col, ExcelSheet* sheet, char* data, i if ((options & 0x01) == 0) //8 bit chars { /* ascii */ s1 = GetASCII(data,idx,w1); idx=idx+w1; printf("STRING:ASCII=%s\r\n",s1.ascii()); }else //16 bit chars { /* unicode */ s1 = GetUnicode(data,idx,w1); idx=idx+w1*2; printf("STRING:unicode=%s\r\n",s1.ascii()); }; // HERE TO PUT richformat handling if (richstring) { idx += 4 * richruns; }; if (fareaststring) { 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(""""); idx=idx+w1; operands.prepend(new QString(s1)); }; printf(" token:ptgStr,num=%d\r\n",w1); break; case 0x25: case 0x45: case 0x65: // ptgArea if(Version==8) { 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 w4=Integer2Byte(data[idx],data[idx+1]);idx=idx+2;//col2 }; //ignores relative or absolute refs s1=FindCellName(w1,w3)+":"+FindCellName(w2,w4); printf(" token:ptgArea,ref=%s\r\n",s1.ascii()); operands.prepend(new QString(s1)); break; case 0x24: case 0x44: case 0x64://ptgRef 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 }; s1=FindCellName(w1,w2); printf("token:ptgRef,ref=%s\r\n",s1.ascii()); operands.prepend(new QString(s1)); break; case 0x1D: // ptgBool w1=data[idx];idx++; printf("token:ptgBool,val=%d\r\n",w1); operands.prepend(new QString(QString::number(w1))); break; case 0x16://ptg MissArg printf("token:ptgMissArg, val=' '\r\n"); operands.prepend(new QString("0")); break; case 0x12://ptgUplus== printf("token:ptgUplus\r\n"); s1=QString("+")+operands.first()->ascii(); operands.removeFirst(); operands.prepend(new QString(s1)); break; case 0x13://ptgUminus @@ -1311,49 +1357,50 @@ QString ExcelBook::GetFormula(int row, int col, ExcelSheet* sheet, char* data, i } else if(w3&0x02)//if { printf("token:IF\r\n"); } else if(w3&0x10)//sum { printf("token:SUM\r\n"); }; break; case 0x21: case 0x22: case 0x42: case 0x62: case 0x41: case 0x61://ptgFunction printf("token:ptgFunction\r\n"); 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) { case 0xf://SIN s1=QString("SIN(")+operands.first()->ascii()+QString(")"); operands.removeFirst(); operands.prepend(new QString(s1)); break; case 0x10://COS s1=QString("COS(")+operands.first()->ascii()+QString(")"); operands.removeFirst(); operands.prepend(new QString(s1)); break; case 0x11://tan s1=QString("TAN(")+operands.first()->ascii()+QString(")"); operands.removeFirst(); operands.prepend(new QString(s1)); break; case 0x62://asin s1=QString("ASIN(")+operands.first()->ascii()+QString(")"); operands.removeFirst(); operands.prepend(new QString(s1)); 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,34 +1,64 @@ +/* + =. 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. + +*/ + +/* QT */ +#include <qstring.h> +#include <qarray.h> +#include <qlist.h> +/* STD */ #include <stdio.h> #include <stdlib.h> #include <math.h> #include <time.h> #include <sys/types.h> #include <strings.h> -#include <qstring.h> -#include <qarray.h> -#include <qlist.h> #define DATEFORMAT 0x1 #define NUMBERFORMAT 0x2 #define BIFF8 0x600 #define BIFF7 0x500 #define WBKGLOBAL 0x5 #define WRKSHEET 0x10 #define XL_ARRAY 0x221 #define XL_BOUNDSHEET 0x85 #define XL_BOF 0x809 #define XL_BOOLERR 0x205 #define XL_CONTINUE 0x3c #define XL_DIMENSION 0x200 #define XL_EOF 0x0a #define XL_EXTSST 0xff #define XL_FORMULA 0x406 #define XL_FORMULA2 0x6 #define XL_FORMAT 0x41e #define XL_INDEX 0x20b #define XL_LABEL 0x204 #define XL_LABELSST 0xfd #define XL_MULRK 0xbd @@ -93,61 +123,59 @@ public: class SSTList { public: QArray <ExcelBREC*> rec; }; class ExcelSheet { public: QString name; ExcelBREC BOFRecord; int position; int type; int rows; int cols; int cellsize,rowalloc,cellalloc; QArray <ExcelCell*> Cells; bool InitCells(void); // true if ok ExcelCell* Get(int row, int col); void Set(int row, int col, ExcelCell* cell); }; -struct mulrk { +struct mulrk +{ int row; int first; int last; int numrks; QArray<int> rknumbers; QArray<double> rkdbls; QArray<int> xfindices; }; - - - class ExcelBook { public: FILE *File; int Position; //int stringcount; QArray <QString*> SharedStrings; //int xfcount; QArray <ExcelFormat*> XFRecords; //int Sheetcount; QArray <ExcelSheet*> Sheets; //int name count; QArray <QString*> 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); @@ -175,31 +203,26 @@ 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); - - - - - }; diff --git a/noncore/apps/opie-sheet/cellformat.cpp b/noncore/apps/opie-sheet/cellformat.cpp index 342ebe9..602d20d 100644 --- a/noncore/apps/opie-sheet/cellformat.cpp +++ b/noncore/apps/opie-sheet/cellformat.cpp @@ -1,40 +1,60 @@ -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ +/* + =. 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. + +*/ /* * Opie Sheet (formerly Sheet/Qt) * by Serdar Ozler <sozler@sitebest.com> */ #include "cellformat.h" +/* QT */ #include <qlistbox.h> #include <qlabel.h> #define COMBO_WIDTHS 155 #define COMBO_HEIGHTS 21 #define COLOR_COUNT 17 #define STYLE_COUNT 14 #define HALIGN_COUNT 3 #define VALIGN_COUNT 3 QColor qtColors[COLOR_COUNT]={Qt::black,Qt::white, Qt::darkGray, Qt::gray, Qt::lightGray, Qt::red, Qt::green, Qt::blue, Qt::cyan, Qt::magenta, Qt::yellow, Qt::darkRed, Qt::darkGreen, Qt::darkBlue, Qt::darkCyan, Qt::darkMagenta, Qt::darkYellow}; Qt::BrushStyle brushStyles[STYLE_COUNT]={Qt::SolidPattern, Qt::Dense1Pattern, Qt::Dense2Pattern, Qt::Dense3Pattern, Qt::Dense4Pattern, Qt::Dense5Pattern, Qt::Dense6Pattern, Qt::Dense7Pattern, Qt::HorPattern, @@ -128,50 +148,49 @@ CellFormat::CellFormat(QWidget *parent) frameAlignment->setGeometry(10, 10, 215, 145); frameAlignment->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); comboAlignmentVertical=createCombo(COMBO_VALIGN, widgetAlignment, tr("&Vertical:"), 165); connect(comboAlignmentVertical, SIGNAL(activated(int)), this, SLOT(alignClicked(int))); comboAlignmentHorizontal=createCombo(COMBO_HALIGN, widgetAlignment, tr("&Horizontal:"), 165+(COMBO_HEIGHTS+10)); connect(comboAlignmentHorizontal, SIGNAL(activated(int)), this, SLOT(alignClicked(int))); checkAlignmentWrap=new QCheckBox(tr("&Word Wrap"), widgetAlignment); checkAlignmentWrap->setGeometry(10, 165+2*(COMBO_HEIGHTS+10), 90, COMBO_HEIGHTS); connect(checkAlignmentWrap, SIGNAL(toggled(bool)), this, SLOT(alignClicked(bool))); buttonAlignmentDefaults=new QPushButton(tr("&Default Alignment"), widgetAlignment); buttonAlignmentDefaults->setGeometry(115, 165+2*(COMBO_HEIGHTS+10), 110, COMBO_HEIGHTS); connect(buttonAlignmentDefaults, SIGNAL(clicked()), this, SLOT(slotAlignmentDefaults())); // Main widget box=new QVBoxLayout(this); box->addWidget(tabs); setCaption(tr("Format Cells")); } CellFormat::~CellFormat() -{ -} +{} int CellFormat::findColorIndex(const QColor &color) { for (int i=0; i<COLOR_COUNT; ++i) if (qtColors[i]==color) return i; return 0; } int CellFormat::findVAlignIndex(Qt::AlignmentFlags flag) { for (int i=0; i<VALIGN_COUNT; ++i) if (flagsVAlign[i] & flag) return i; return 0; } int CellFormat::findHAlignIndex(Qt::AlignmentFlags flag) { for (int i=0; i<HALIGN_COUNT; ++i) if (flagsHAlign[i] & flag) return i; return 0; } @@ -508,50 +527,49 @@ int CellFormat::exec(Sheet *s) } if (changedFont) { for (row=row1; row<=row2; ++row) for (col=col1; col<=col2; ++col) sheet->setTextFont(row, col, fontFont, fontColor); } return QDialog::Accepted; } return QDialog::Rejected; } // // Border Editor // BorderEditor::BorderEditor(QWidget *parent) :QFrame(parent) { setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); } BorderEditor::~BorderEditor() -{ -} +{} void BorderEditor::drawContents(QPainter *p) { QFrame::drawContents(p); int x=contentsRect().x(), y=contentsRect().y(), width=contentsRect().width()/3, height=contentsRect().height()/3; int lineFirstX=x+width/6, lineFirstY=y+height/6, lineLastX=contentsRect().right()-width/6, lineLastY=contentsRect().bottom()-height/6; p->fillRect(contentsRect(), Qt::white); p->fillRect(x+width/3, y+height/3, width, height, Qt::gray); p->fillRect(x+(5*width/3), y+height/3, width, height, Qt::gray); p->fillRect(x+width/3, y+(5*height)/3, width, height, Qt::gray); p->fillRect(x+(5*width)/3, y+(5*height)/3, width, height, Qt::gray); if (penTop.width()>0) { p->setPen(penTop); p->drawLine(lineFirstX, lineFirstY, lineLastX, lineFirstY); } if (penBottom.width()>0) { p->setPen(penBottom); p->drawLine(lineFirstX, lineLastY, lineLastX, lineLastY); diff --git a/noncore/apps/opie-sheet/cellformat.h b/noncore/apps/opie-sheet/cellformat.h index b569b7f..e07af9c 100644 --- a/noncore/apps/opie-sheet/cellformat.h +++ b/noncore/apps/opie-sheet/cellformat.h @@ -1,51 +1,73 @@ -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ +/* + =. 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. + +*/ /* * Opie Sheet (formerly Sheet/Qt) * by Serdar Ozler <sozler@sitebest.com> */ #ifndef CELLFORMAT_H #define CELLFORMAT_H +#include "sheet.h" + +/* OPIE */ #include <qpe/fontdatabase.h> + +/* QT */ #include <qdialog.h> #include <qtabwidget.h> #include <qlayout.h> #include <qcombobox.h> #include <qcheckbox.h> #include <qpushbutton.h> -#include "sheet.h" - class BorderEditor: public QFrame { Q_OBJECT // QT objects QPen penTop, penBottom, penLeft, penRight, penHorz, penVert; // Private functions void drawContents(QPainter *p); // Reimplemented QFrame functions void mouseReleaseEvent(QMouseEvent *e); public: // Definitions enum BorderArea {None, Top, Bottom, Left, Right, Horz, Vert}; BorderEditor(QWidget *parent=0); ~BorderEditor(); void setPen(const QPen &pen, BorderArea area); QPen getPen(BorderArea area); QPen getDefaultPen() { return QPen(Qt::black, 1, Qt::DotLine); } diff --git a/noncore/apps/opie-sheet/finddlg.cpp b/noncore/apps/opie-sheet/finddlg.cpp index e4c6ec8..c724159 100644 --- a/noncore/apps/opie-sheet/finddlg.cpp +++ b/noncore/apps/opie-sheet/finddlg.cpp @@ -1,41 +1,62 @@ -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ +/* + =. 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. + +*/ /* * Opie Sheet (formerly Sheet/Qt) * by Serdar Ozler <sozler@sitebest.com> */ +#include "finddlg.h" + +/* QT */ #include <qlabel.h> #include <qradiobutton.h> -#include "finddlg.h" FindDialog::FindDialog(QWidget *parent) :QDialog(parent, 0, TRUE) { // Main widget tabs=new QTabWidget(this); widgetFind=new QWidget(tabs); widgetOptions=new QWidget(tabs); tabs->addTab(widgetFind, tr("&Find && Replace")); tabs->addTab(widgetOptions, tr("&Options")); // Find tab QLabel *label=new QLabel(tr("&Search for:"), widgetFind); label->setGeometry(10, 10, 215, 20); editFind=new QLineEdit(widgetFind); editFind->setGeometry(10, 40, 215, 20); label->setBuddy(editFind); label=new QLabel(tr("&Replace with:"), widgetFind); label->setGeometry(10, 80, 215, 20); editReplace=new QLineEdit(widgetFind); editReplace->setGeometry(10, 110, 215, 20); editReplace->setEnabled(FALSE); label->setBuddy(editReplace); @@ -43,42 +64,41 @@ FindDialog::FindDialog(QWidget *parent) groupType=new QVButtonGroup(tr("&Type"), widgetFind); groupType->setGeometry(10, 150, 215, 90); QRadioButton *radio=new QRadioButton(tr("&Find"), groupType); radio=new QRadioButton(tr("&Replace"), groupType); radio=new QRadioButton(tr("Replace &all"), groupType); groupType->setButton(0); connect(groupType, SIGNAL(clicked(int)), this, SLOT(typeChanged(int))); // Options tab checkCase=new QCheckBox(tr("Match &case"), widgetOptions); checkCase->setGeometry(10, 10, 215, 20); checkSelection=new QCheckBox(tr("Current &selection only"), widgetOptions); checkSelection->setGeometry(10, 40, 215, 20); checkEntire=new QCheckBox(tr("&Entire cell"), widgetOptions); checkEntire->setGeometry(10, 70, 215, 20); // Main widget box=new QVBoxLayout(this); box->addWidget(tabs); setCaption(tr("Find & Replace")); } FindDialog::~FindDialog() -{ -} +{} void FindDialog::typeChanged(int id) { editReplace->setEnabled(id>0); } int FindDialog::exec(Sheet *s) { if (QDialog::exec()==QDialog::Accepted) { int id=groupType->id(groupType->selected()); s->dataFindReplace(editFind->text(), editReplace->text(), checkCase->isChecked(), !checkSelection->isChecked(), checkEntire->isChecked(), id>0, id>1); return QDialog::Accepted; } return QDialog::Rejected; } diff --git a/noncore/apps/opie-sheet/finddlg.h b/noncore/apps/opie-sheet/finddlg.h index 1af2da5..b456f21 100644 --- a/noncore/apps/opie-sheet/finddlg.h +++ b/noncore/apps/opie-sheet/finddlg.h @@ -1,49 +1,70 @@ -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ +/* + =. 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. + +*/ /* * Opie Sheet (formerly Sheet/Qt) * by Serdar Ozler <sozler@sitebest.com> */ #ifndef FINDDLG_H #define FINDDLG_H +#include "sheet.h" + +/* QT */ #include <qdialog.h> #include <qtabwidget.h> #include <qlayout.h> #include <qlineedit.h> #include <qcheckbox.h> #include <qpushbutton.h> #include <qvbuttongroup.h> -#include "sheet.h" class FindDialog: public QDialog { Q_OBJECT // QT objects QBoxLayout *box; QTabWidget *tabs; QWidget *widgetFind, *widgetOptions; QCheckBox *checkCase, *checkSelection, *checkEntire; QLineEdit *editFind, *editReplace; QVButtonGroup *groupType; private slots: void typeChanged(int id); public: FindDialog(QWidget *parent=0); ~FindDialog(); int exec(Sheet *s); }; #endif diff --git a/noncore/apps/opie-sheet/main.cpp b/noncore/apps/opie-sheet/main.cpp index 861473e..bf35908 100644 --- a/noncore/apps/opie-sheet/main.cpp +++ b/noncore/apps/opie-sheet/main.cpp @@ -1,23 +1,42 @@ -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ +/* + =. 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. + +*/ /* * Opie Sheet (formerly Sheet/Qt) * by Serdar Ozler <sozler@sitebest.com> */ #include "mainwindow.h" #include <opie2/oapplicationfactory.h> using namespace Opie::Core; OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) diff --git a/noncore/apps/opie-sheet/mainwindow.cpp b/noncore/apps/opie-sheet/mainwindow.cpp index 061748e..bb85a24 100644 --- a/noncore/apps/opie-sheet/mainwindow.cpp +++ b/noncore/apps/opie-sheet/mainwindow.cpp @@ -1,117 +1,138 @@ -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ +/* + =. 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. + +*/ /* * Opie Sheet (formerly Sheet/Qt) * by Serdar Ozler <sozler@sitebest.com> */ #include "mainwindow.h" +/* OPIE */ #include <qpe/resource.h> #include <qpe/qpeapplication.h> +/* QT */ #include <qmessagebox.h> #include <qradiobutton.h> +/* STD */ #include "cellformat.h" #include "numberdlg.h" #include "textdlg.h" #include "sortdlg.h" #include "finddlg.h" #define DEFAULT_NUM_ROWS 300 #define DEFAULT_NUM_COLS (26*3) #define DEFAULT_NUM_SHEETS 3 MainWindow::MainWindow(QWidget *parent, const char* n, WFlags fl) :QMainWindow(parent, n, fl) { // initialize variables documentModified=FALSE; // construct objects currentDoc=0; - fileSelector=new FileSelector("application/sheet-qt", this, QString::null); + fileSelector=new FileSelector("application/opie-sheet", this, QString::null); ExcelSelector=new FileSelector("application/excel",this,QString::null,FALSE); connect(fileSelector, SIGNAL(closeMe()), this, SLOT(selectorHide())); connect(fileSelector, SIGNAL(newSelected(const DocLnk&)), this, SLOT(selectorFileNew(const DocLnk&))); connect(fileSelector, SIGNAL(fileSelected(const DocLnk&)), this, SLOT(selectorFileOpen(const DocLnk&))); connect(ExcelSelector,SIGNAL(fileSelected(const DocLnk&)),this,SLOT(slotImportExcel(const DocLnk&))); connect(ExcelSelector,SIGNAL(closeMe()), this, SLOT(ExcelSelectorHide())); - listSheets.setAutoDelete(TRUE); initActions(); initMenu(); initEditToolbar(); initFunctionsToolbar(); initStandardToolbar(); initSheet(); // set window title setCaption(tr("Opie Sheet")); // create sheets selectorFileNew(DocLnk()); } MainWindow::~MainWindow() { if (currentDoc) delete currentDoc; } void MainWindow::documentSave(DocLnk *lnkDoc) { FileManager fm; QByteArray streamBuffer; QDataStream stream(streamBuffer, IO_WriteOnly); typeSheet *currentSheet=findSheet(sheet->getName()); if (!currentSheet) { QMessageBox::critical(this, tr("Error"), tr("Inconsistency error!")); return; } sheet->copySheetData(¤tSheet->data); stream.writeRawBytes("SQT100", 6); stream << (Q_UINT32)listSheets.count(); for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) { stream << tempSheet->name << (Q_UINT32)tempSheet->data.count(); for (typeCellData *tempCell=tempSheet->data.first(); tempCell; tempCell=tempSheet->data.next()) stream << (Q_UINT32)tempCell->col << (Q_UINT32)tempCell->row << tempCell->borders.right << tempCell->borders.bottom << tempCell->background << (Q_UINT32)tempCell->alignment << tempCell->fontColor << tempCell->font << tempCell->data; } - lnkDoc->setType("application/sheet-qt"); + lnkDoc->setType("application/opie-sheet"); if (!fm.saveFile(*lnkDoc, streamBuffer)) { QMessageBox::critical(this, tr("Error"), tr("File cannot be saved!")); return; } documentModified=FALSE; } void MainWindow::documentOpen(const DocLnk &lnkDoc) { FileManager fm; QByteArray streamBuffer; if (!lnkDoc.isValid() || !fm.loadFile(lnkDoc, streamBuffer)) { QMessageBox::critical(this, tr("Error"), tr("File cannot be opened!")); documentModified=FALSE; selectorFileNew(DocLnk()); return; } QDataStream stream(streamBuffer, IO_ReadOnly); Q_UINT32 countSheet, countCell, i, j, row, col, alignment; typeSheet *newSheet; typeCellData *newCell; diff --git a/noncore/apps/opie-sheet/mainwindow.h b/noncore/apps/opie-sheet/mainwindow.h index eacbe36..642b7ae 100644 --- a/noncore/apps/opie-sheet/mainwindow.h +++ b/noncore/apps/opie-sheet/mainwindow.h @@ -1,53 +1,76 @@ -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ +/* + =. 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. + +*/ /* * Opie Sheet (formerly Sheet/Qt) * by Serdar Ozler <sozler@sitebest.com> */ #ifndef MAINWINDOW_H #define MAINWINDOW_H +#include "Excel.h" +#include "sheet.h" + +/* OPIE */ #include <qpe/applnk.h> #include <qpe/fileselector.h> + +/* QT */ #include <qmenubar.h> #include <qtoolbar.h> #include <qmainwindow.h> #include <qaction.h> #include <qlineedit.h> #include <qbutton.h> #include <qcombobox.h> #include <qtoolbutton.h> -#include "Excel.h" -#include "sheet.h" typedef struct typeSheet { QString name; QList<typeCellData> data; }; class MainWindow: public QMainWindow { Q_OBJECT // QPE objects DocLnk* currentDoc; QMenuBar *menu; QToolBar *toolbarFunctions, *toolbarEdit, *toolbarStandard; FileSelector *fileSelector; FileSelector *ExcelSelector; // QT objects QPopupMenu *menuFile, *menuEdit, *menuInsert, *menuFormat, *menuData, *menuHelp, *submenuFunc, *submenuFuncStd, *submenuFuncStandard, *submenuFuncLogic, *submenuFuncTrig, *submenuFuncString, *submenuFuncScientific, *submenuFuncDistr, *submenuFuncStat, *submenuRow, *submenuCol, *submenuSheet; diff --git a/noncore/apps/opie-sheet/numberdlg.cpp b/noncore/apps/opie-sheet/numberdlg.cpp index 90fbaa2..43574e9 100644 --- a/noncore/apps/opie-sheet/numberdlg.cpp +++ b/noncore/apps/opie-sheet/numberdlg.cpp @@ -1,50 +1,68 @@ -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ +/* + =. 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. + +*/ /* * Opie Sheet (formerly Sheet/Qt) * by Serdar Ozler <sozler@sitebest.com> */ #include "numberdlg.h" NumberDialog::NumberDialog(QWidget *parent) :QDialog(parent, 0, TRUE) { edit=new QSpinBox(this); edit->setGeometry(120, 10, 70, 25); label=new QLabel(this); label->setGeometry(10, 10, 100, 25); label->setBuddy(edit); resize(200, 45); } NumberDialog::~NumberDialog() -{ -} +{} int NumberDialog::exec(const QString &caption, const QString &text, int value, int min, int max, int step) { setCaption(caption); label->setText(text); edit->setValue(value); edit->setMinValue(min); edit->setMaxValue(max); edit->setLineStep(step); return QDialog::exec(); } int NumberDialog::getValue() { return edit->value(); } diff --git a/noncore/apps/opie-sheet/numberdlg.h b/noncore/apps/opie-sheet/numberdlg.h index 81e3326..497c076 100644 --- a/noncore/apps/opie-sheet/numberdlg.h +++ b/noncore/apps/opie-sheet/numberdlg.h @@ -1,38 +1,58 @@ -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ +/* + =. 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. + +*/ /* * Opie Sheet (formerly Sheet/Qt) * by Serdar Ozler <sozler@sitebest.com> */ #ifndef NUMBERDLG_H #define NUMBERDLG_H +/* QT */ #include <qdialog.h> #include <qlabel.h> #include <qspinbox.h> class NumberDialog: public QDialog { Q_OBJECT // QT objects QLabel *label; QSpinBox *edit; public: NumberDialog(QWidget *parent=0); ~NumberDialog(); int exec(const QString &caption, const QString &text, int value=1, int min=1, int max=99, int step=1); int getValue(); }; #endif diff --git a/noncore/apps/opie-sheet/opie-sheet.pro b/noncore/apps/opie-sheet/opie-sheet.pro index ced4daf..d0beb93 100644 --- a/noncore/apps/opie-sheet/opie-sheet.pro +++ b/noncore/apps/opie-sheet/opie-sheet.pro @@ -1,9 +1,24 @@ CONFIG = qt warn_on quick-app -HEADERS = mainwindow.h sheet.h cellformat.h finddlg.h numberdlg.h sortdlg.h textdlg.h Excel.h -SOURCES = main.cpp mainwindow.cpp sheet.cpp cellformat.cpp finddlg.cpp numberdlg.cpp sortdlg.cpp textdlg.cpp Excel.cpp +HEADERS = mainwindow.h \ + sheet.h \ + cellformat.h \ + finddlg.h \ + numberdlg.h \ + sortdlg.h \ + textdlg.h \ + Excel.h +SOURCES = main.cpp \ + mainwindow.cpp \ + sheet.cpp \ + cellformat.cpp \ + finddlg.cpp \ + numberdlg.cpp \ + sortdlg.cpp \ + textdlg.cpp \ + Excel.cpp INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lopiecore2 TARGET = opie-sheet include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/apps/opie-sheet/sheet.cpp b/noncore/apps/opie-sheet/sheet.cpp index 88847da..477c982 100644 --- a/noncore/apps/opie-sheet/sheet.cpp +++ b/noncore/apps/opie-sheet/sheet.cpp @@ -1,94 +1,116 @@ -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ +/* + =. 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. + +*/ /* * Opie Sheet (formerly Sheet/Qt) * by Serdar Ozler <sozler@sitebest.com> */ #include "sheet.h" +/* QT */ #include <qmessagebox.h> + +/* STD */ #include <math.h> #include <stdlib.h> #include <stdio.h> #include <time.h> #define DEFAULT_COL_WIDTH 50 Sheet::Sheet(int numRows, int numCols, QWidget *parent) :QTable(numRows, numCols, parent) { defaultBorders.right=defaultBorders.bottom=QPen(Qt::gray, 1, Qt::SolidLine); defaultCellData.data=""; defaultCellData.background=QBrush(Qt::white, Qt::SolidPattern); defaultCellData.alignment=(Qt::AlignmentFlags)(Qt::AlignLeft | Qt::AlignTop); defaultCellData.fontColor=Qt::black; defaultCellData.font=font(); defaultCellData.borders=defaultBorders; clicksLocked=FALSE; selectionNo=-1; setSelectionMode(QTable::Single); sheetData.setAutoDelete(TRUE); clipboardData.setAutoDelete(TRUE); for (int i=0; i<numCols; ++i) horizontalHeader()->setLabel(i, getHeaderString(i+1), DEFAULT_COL_WIDTH); connect(this, SIGNAL(currentChanged(int,int)), this, SLOT(slotCellSelected(int,int))); connect(this, SIGNAL(valueChanged(int,int)), this, SLOT(slotCellChanged(int,int))); } Sheet::~Sheet() -{ -} +{} typeCellData *Sheet::findCellData(int row, int col) { typeCellData *tempCellData; for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) { if (tempCellData->row==row && tempCellData->col==col) return tempCellData; } return NULL; } void Sheet::slotCellSelected(int row, int col) { typeCellData *cellData=findCellData(row, col); if (cellData) { emit currentDataChanged(cellData->data); - }else + } + else emit currentDataChanged(""); } typeCellData *Sheet::createCellData(int row, int col) { if (row<0 || col<0) return NULL; typeCellData *cellData=new typeCellData; cellData->row=row; cellData->col=col; cellData->data=defaultCellData.data; cellData->borders=defaultCellData.borders; cellData->alignment=defaultCellData.alignment; cellData->font=defaultCellData.font; cellData->fontColor=defaultCellData.fontColor; cellData->background=defaultCellData.background; sheetData.append(cellData); return cellData; } void Sheet::slotCellChanged(int row, int col) { typeCellData *cellData=findCellData(row, col); if (!cellData) cellData=createCellData(row, col); if (cellData) cellData->data=text(row, col); @@ -207,228 +229,236 @@ QString Sheet::calculateVariable(const QString &variable) } else { if(variable!="0" || variable!="0.0") return QString(variable); // hereis a string variable return QString::number(tempResult); }; }; int row, col; if(findRowColumn(variable, &row, &col, FALSE)) return dataParser(variable, text(row,col)); //return (findRowColumn(variable, &row, &col, TRUE) ? dataParser(variable, text(row, col)) : 0); return QString(variable); } double Sheet::BesselI0(double x) { //Returns the modi ed Bessel function I0(x) for any real x. double ax,ans; double y; if ((ax=fabs(x)) < 3.75) { y=x/3.75; y*=y; ans=1.0+y*(3.5156229+y*(3.0899424+y*(1.2067492 +y*(0.2659732+y*(0.360768e-1+y*0.45813e-2))))); - }else + } + else { y=3.75/ax; ans=(exp(ax)/sqrt(ax))*(0.39894228+y*(0.1328592e-1 +y*(0.225319e-2+y*(-0.157565e-2+y*(0.916281e-2 +y*(-0.2057706e-1+y*(0.2635537e-1+y*(-0.1647633e-1 +y*0.392377e-2)))))))); } return ans; }; double Sheet::BesselI1(double x) { double ax,ans; double y; if ((ax=fabs(x)) < 3.75) { y=x/3.75; y*=y; ans=ax*(0.5+y*(0.87890594+y*(0.51498869+y*(0.15084934 +y*(0.2658733e-1+y*(0.301532e-2+y*0.32411e-3)))))); - } else + } + else { y=3.75/ax; ans=0.2282967e-1+y*(-0.2895312e-1+y*(0.1787654e-1 -y*0.420059e-2)); ans=0.39894228+y*(-0.3988024e-1+y*(-0.362018e-2 +y*(0.163801e-2+y*(-0.1031555e-1+y*ans)))); ans *= (exp(ax)/sqrt(ax)); } return x < 0.0 ? -ans : ans; }; double Sheet::BesselI(int n, double x) { double ACC=40.0; double BIGNO=1.0e10; double BIGNI=1.0e-10; int j; double bi,bim,bip,tox,ans; if (n < 2) return 0.0; if (x == 0.0) return 0.0; else { tox=2.0/fabs(x); bip=ans=0.0; bi=1.0; for (j=2*(n+(int) sqrt(ACC*n));j>0;j--) { bim=bip+j*tox*bi; bip=bi; bi=bim; if (fabs(bi) > BIGNO) { ans *= BIGNI; bi *= BIGNI; bip *= BIGNI; } if (j == n) ans=bip; } ans *= BesselI0(x)/bi; return x < 0.0 && (n & 1) ? -ans : ans; } }; double Sheet::BesselK0(double x) { double y,ans; if (x <= 2.0) { y=x*x/4.0; ans=(-log(x/2.0)*BesselI0(x))+(-0.57721566+y*(0.42278420 +y*(0.23069756+y*(0.3488590e-1+y*(0.262698e-2 +y*(0.10750e-3+y*0.74e-5)))))); - } else + } + else { y=2.0/x; ans=(exp(-x)/sqrt(x))*(1.25331414+y*(-0.7832358e-1 +y*(0.2189568e-1+y*(-0.1062446e-1+y*(0.587872e-2 +y*(-0.251540e-2+y*0.53208e-3)))))); } return ans; }; double Sheet::BesselK1(double x) { double y,ans; if (x <= 2.0) { y=x*x/4.0; ans=(log(x/2.0)*BesselI1(x))+(1.0/x)*(1.0+y*(0.15443144 +y*(-0.67278579+y*(-0.18156897+y*(-0.1919402e-1 +y*(-0.110404e-2+y*(-0.4686e-4))))))); - } else + } + else { y=2.0/x; ans=(exp(-x)/sqrt(x))*(1.25331414+y*(0.23498619 +y*(-0.3655620e-1+y*(0.1504268e-1+y*(-0.780353e-2 +y*(0.325614e-2+y*(-0.68245e-3))))))); } return ans; }; double Sheet::BesselK(int n, double x) { int j; double bk,bkm,bkp,tox; if (n < 2) return 0.0; tox=2.0/x; bkm=BesselK0(x); bk=BesselK1(x); for (j=1;j<n;j++) { bkp=bkm+j*tox*bk; bkm=bk; bk=bkp; } return bk; }; double Sheet::BesselJ0(double x) { double ax,z; double xx,y,ans,ans1,ans2; if ((ax=fabs(x)) < 8.0) { y=x*x; ans1=57568490574.0+y*(-13362590354.0+y*(651619640.7 +y*(-11214424.18+y*(77392.33017+y*(-184.9052456))))); ans2=57568490411.0+y*(1029532985.0+y*(9494680.718 +y*(59272.64853+y*(267.8532712+y*1.0)))); ans=ans1/ans2; - } else + } + else { z=8.0/ax; y=z*z; xx=ax-0.785398164; ans1=1.0+y*(-0.1098628627e-2+y*(0.2734510407e-4 +y*(-0.2073370639e-5+y*0.2093887211e-6))); ans2 = -0.1562499995e-1+y*(0.1430488765e-3 +y*(-0.6911147651e-5+y*(0.7621095161e-6 -y*0.934935152e-7))); ans=sqrt(0.636619772/ax)*(cos(xx)*ans1-z*sin(xx)*ans2); } return ans; }; double Sheet::BesselY0(double x) { double z; double xx,y,ans,ans1,ans2; if (x < 8.0) { y=x*x; ans1 = -2957821389.0+y*(7062834065.0+y*(-512359803.6 +y*(10879881.29+y*(-86327.92757+y*228.4622733)))); ans2=40076544269.0+y*(745249964.8+y*(7189466.438 +y*(47447.26470+y*(226.1030244+y*1.0)))); ans=(ans1/ans2)+0.636619772*BesselJ0(x)*log(x); - } else + } + else { z=8.0/x; y=z*z; xx=x-0.785398164; ans1=1.0+y*(-0.1098628627e-2+y*(0.2734510407e-4 +y*(-0.2073370639e-5+y*0.2093887211e-6))); ans2 = -0.1562499995e-1+y*(0.1430488765e-3 +y*(-0.6911147651e-5+y*(0.7621095161e-6 +y*(-0.934945152e-7)))); ans=sqrt(0.636619772/x)*(sin(xx)*ans1+z*cos(xx)*ans2); } return ans; }; double Sheet::BesselJ1(double x) { double ax,z; double xx,y,ans,ans1,ans2; if ((ax=fabs(x)) < 8.0) { y=x*x; ans1=x*(72362614232.0+y*(-7895059235.0+y*(242396853.1 +y*(-2972611.439+y*(15704.48260+y*(-30.16036606)))))); ans2=144725228442.0+y*(2300535178.0+y*(18583304.74 +y*(99447.43394+y*(376.9991397+y*1.0)))); ans=ans1/ans2; - } else + } + else { z=8.0/ax; y=z*z; xx=ax-2.356194491; ans1=1.0+y*(0.183105e-2+y*(-0.3516396496e-4 +y*(0.2457520174e-5+y*(-0.240337019e-6)))); ans2=0.04687499995+y*(-0.2002690873e-3 +y*(0.8449199096e-5+y*(-0.88228987e-6 +y*0.105787412e-6))); ans=sqrt(0.636619772/ax)*(cos(xx)*ans1-z*sin(xx)*ans2); if (x < 0.0) ans = -ans; } return ans; }; double Sheet::BesselY1(double x) { double z; double xx,y,ans,ans1,ans2; if (x < 8.0) { y=x*x; ans1=x*(-0.4900604943e13+y*(0.1275274390e13 +y*(-0.5153438139e11+y*(0.7349264551e9 +y*(-0.4237922726e7+y*0.8511937935e4))))); ans2=0.2499580570e14+y*(0.4244419664e12 +y*(0.3733650367e10+y*(0.2245904002e8 +y*(0.1020426050e6+y*(0.3549632885e3+y))))); ans=(ans1/ans2)+0.636619772*(BesselJ1(x)*log(x)-1.0/x); - } else + } + else { z=8.0/x; y=z*z; xx=x-2.356194491; ans1=1.0+y*(0.183105e-2+y*(-0.3516396496e-4 +y*(0.2457520174e-5+y*(-0.240337019e-6)))); ans2=0.04687499995+y*(-0.2002690873e-3 +y*(0.8449199096e-5+y*(-0.88228987e-6 +y*0.105787412e-6))); ans=sqrt(0.636619772/x)*(sin(xx)*ans1+z*cos(xx)*ans2); } return ans; }; double Sheet::BesselY(int n, double x) { int j; double by,bym,byp,tox; if (n < 2) return 0.0; tox=2.0/x; by=BesselY1(x); bym=BesselY0(x); for (j=1;j<n;j++) { byp=j*tox*by-bym; bym=by; by=byp; @@ -437,49 +467,50 @@ double Sheet::BesselY(int n, double x) }; double Sheet::BesselJ(int n, double x) { double ACC=40.0; double BIGNO=1.0e10; double BIGNI=1.0e-10; int j,jsum,m; double ax,bj,bjm,bjp,sum,tox,ans; if (n < 2) return 0.0; ax=fabs(x); if (ax == 0.0) return 0.0; else if (ax > (double) n) { tox=2.0/ax; bjm=BesselJ0(ax); bj=BesselJ1(ax); for (j=1;j<n;j++) { bjp=j*tox*bj-bjm; bjm=bj; bj=bjp; } ans=bj; - } else + } + else { tox=2.0/ax; m=2*((n+(int) sqrt(ACC*n))/2); jsum=0; bjp=ans=sum=0.0; bj=1.0; for (j=m;j>0;j--) { bjm=j*tox*bj-bjp; bjp=bj; bj=bjm; if (fabs(bj) > BIGNO) { bj *= BIGNI; bjp *= BIGNI; ans *= BIGNI; sum *= BIGNI; } if (jsum) sum += bj; jsum=!jsum; if (j == n) ans=bjp; } sum=2.0*sum-bj; ans /= sum; @@ -497,89 +528,92 @@ double Sheet::GammaLn(double xx) tmp -= (x+0.5)*log(tmp); ser=1.000000000190015; for (j=0;j<=5;j++) ser += cof[j]/++y; return -tmp+log(2.5066282746310005*ser/x); }; double Sheet::Factorial(double n) { if (n < 0) return 0.0; if (n > 100) return 0.0; return exp(GammaLn(n+1.0)); }; double Sheet::GammaP(double a, double x) { // returns GammaP(a,x) //void gcf(float *gammcf, float a, float x, float *gln); //void gser(float *gamser, float a, float x, float *gln); double gamser,gammcf,gln; if (x < 0.0 || a <= 0.0) return 0.0;//error if (x < (a+1.0)) { GammaSeries(&gamser,a,x,&gln); return gamser; - }else + } + else { GammaContinuedFraction(&gammcf,a,x,&gln); return 1.0-gammcf; } }; double Sheet::GammaQ(double a,double x) { //returns GammaQ(a,x)=1.0 - GammaP(a,x); return (1.0-GammaP(a,x)); }; void Sheet::GammaSeries(double *gamser, double a, double x, double *gln) { double EPS=3.0e-7; int ITMAX=100; int n; double sum,del,ap; *gln=GammaLn(a); if (x <= 0.0) { if (x < 0.0) return;//error *gamser=0.0; return; - } else + } + else { ap=a; del=sum=1.0/a; for (n=1;n<=ITMAX;n++) { ++ap; del *= x/ap; sum += del; if (fabs(del) < fabs(sum)*EPS) { *gamser=sum*exp(-x+a*log(x)-(*gln)); return; } - } return; + } + return; return; } }; void Sheet::GammaContinuedFraction(double *gammcf, double a, double x, double *gln) { double EPS=3.0e-7; double FPMIN=1.0e-30; int ITMAX=100; int i; double an,b,c,d,del,h; *gln=GammaLn(a); b=x+1.0-a; c=1.0/FPMIN; d=1.0/b; h=d; for (i=1;i<=ITMAX;i++) { an = -i*(i-a); b += 2.0; d=an*d+b; if (fabs(d) < FPMIN) d=FPMIN; c=b+an/c; if (fabs(c) < FPMIN) c=FPMIN; d=1.0/d; del=d*c; h *= del; @@ -641,49 +675,50 @@ double Sheet::BetaIncomplete(double a, double b, double x) double bt; if (x < 0.0 || x > 1.0) return 0.0; if (x == 0.0 || x == 1.0) bt=0.0; else bt=exp(GammaLn(a+b)-GammaLn(a)-GammaLn(b)+a*log(x)+b*log(1.0-x)); if (x < (a+1.0)/(a+b+2.0)) return bt*BetaContinuedFraction(a,b,x)/a; else return 1.0-bt*BetaContinuedFraction(b,a,1.0-x)/b; }; double Sheet::functionSum(const QString ¶m1, const QString ¶m2) { int row1, col1, row2, col2, row, col; double result=0, tempResult; bool ok; if (findRange(param1, param2, &row1, &col1, &row2, &col2)) { for (row=row1; row<=row2; ++row) for (col=col1; col<=col2; ++col) { tempResult=text(row, col).toDouble(&ok); if (ok) result+=tempResult; } return result; - }else + } + else { double d1=0,d2=0; d1=calculateVariable(param1).toDouble(&ok); d2=calculateVariable(param2).toDouble(&ok); return(d1+d2); }; return 0; } QString Sheet::functionIndex(const QString ¶m1, const QString ¶m2, int indx) { int row1, col1, row2, col2, row, col; if (!findRange(param1, param2, &row1, &col1, &row2, &col2)) return 0; int ii=1; for (col=col1; col<=col2; ++col) for (row=row1; row<=row2; ++row) { if(ii==indx) return text(row,col); ii++; } return QString(""); } @@ -768,137 +803,141 @@ double Sheet::functionKurt(const QString ¶m1, const QString ¶m2) (tempResult - avg1)*(tempResult - avg1)/(var1*var1*var1*var1); count1++; }; } if(count1>0) result=result/double(count1)-3.0; else result=0.0; return result; }; double Sheet::functionSumSQ(const QString ¶m1, const QString ¶m2) { int row1, col1, row2, col2, row, col; double result=0, tempResult; bool ok; if (findRange(param1, param2, &row1, &col1, &row2, &col2)) { for (row=row1; row<=row2; ++row) for (col=col1; col<=col2; ++col) { tempResult=text(row, col).toDouble(&ok); if (ok) result+=tempResult*tempResult; } return result; - }else + } + else { double d1=0,d2=0; d1=calculateVariable(param1).toDouble(&ok); d2=calculateVariable(param2).toDouble(&ok); return(d1*d1+d2*d2); }; return 0; } double Sheet::functionMin(const QString ¶m1, const QString ¶m2) { int row1, col1, row2, col2, row, col; double min=0, tempMin; bool ok, init=FALSE; if (findRange(param1, param2, &row1, &col1, &row2, &col2)) { for (row=row1; row<=row2; ++row) for (col=col1; col<=col2; ++col) { tempMin=text(row, col).toDouble(&ok); if (ok && (!init || tempMin<min)) { min=tempMin; init=TRUE; } } return min; - }else + } + else { double d1=0,d2=0; d1=calculateVariable(param1).toDouble(&ok); d2=calculateVariable(param2).toDouble(&ok); if(d1<d2) return(d1); else return(d2); }; return 0; } double Sheet::functionMax(const QString ¶m1, const QString ¶m2) { int row1, col1, row2, col2, row, col; double max=0, tempMax; bool ok, init=FALSE; if (findRange(param1, param2, &row1, &col1, &row2, &col2)) { for (row=row1; row<=row2; ++row) for (col=col1; col<=col2; ++col) { tempMax=text(row, col).toDouble(&ok); if (ok && (!init || tempMax>max)) { max=tempMax; init=TRUE; } }; return max; - }else + } + else { double d1=0,d2=0; d1=calculateVariable(param1).toDouble(&ok); d2=calculateVariable(param2).toDouble(&ok); if(d1>d2) return(d1); else return(d2); }; return 0; } double Sheet::functionAvg(const QString ¶m1, const QString ¶m2) { double resultSum=functionSum(param1, param2), resultCount=functionCount(param1, param2); return (resultCount>0 ? resultSum/resultCount : 0); } double Sheet::functionCount(const QString ¶m1, const QString ¶m2) { int row1, col1, row2, col2, row, col; int divider=0; bool ok; if (findRange(param1, param2, &row1, &col1, &row2, &col2)) { for (row=row1; row<=row2; ++row) for (col=col1; col<=col2; ++col) { text(row, col).toDouble(&ok); if (ok) ++divider; }; return divider; - }else + } + else { double d1=0,d2=0;int ii=0; d1=calculateVariable(param1).toDouble(&ok); if (ok) ii++; d2=calculateVariable(param2).toDouble(&ok); if (ok) ii++; return(ii); }; return 0; } double Sheet::functionCountIf(const QString ¶m1, const QString ¶m2, const QString ¶m3) { int row1, col1, row2, col2, row, col; if (!findRange(param1, param2, &row1, &col1, &row2, &col2)) return 0; //same as count except check if each field is equal to param3 int divider=0; QString s2; bool ok; s2=calculateVariable(param3); for (row=row1; row<=row2; ++row) for (col=col1; col<=col2; ++col) { text(row, col).toDouble(&ok); @@ -971,75 +1010,79 @@ QString Sheet::calculateFunction(const QString &func, const QString ¶meters, { val1=calculateVariable(getParameter(parameters, 0)).toDouble(&ok); val2=calculateVariable(getParameter(parameters, 1)).toDouble(&ok); if(val1<=val2) return QString::number(1); else return QString::number(0); }; if (function=="!=") { val1=calculateVariable(getParameter(parameters, 0)).toDouble(&ok); val2=calculateVariable(getParameter(parameters, 1)).toDouble(&ok); if(val1!=val2) return QString::number(1); else return QString::number(0); }; if (function=="=="||function=="=") { val1=calculateVariable(getParameter(parameters, 0)).toDouble(&ok); val2=calculateVariable(getParameter(parameters, 1)).toDouble(&ok); if(val1==val2) return QString::number(1); else return QString::number(0); }; //LOGICAL / INFO if (function=="ISBLANK") { if(findRowColumn(getParameter(parameters, 0), &row, &col, FALSE)) { if(text(row,col).length()==0) val1=1; else val1=0; - }else + } + else { if(findRowColumn(calculateVariable(getParameter(parameters, 0)), &row,&col, FALSE)) { if(text(row,col).length()==0) val1=1; else val1=0; - }else + } + else { val1=0; }; }; return QString::number(val1); }; if (function=="ISNUMBER") { if(findRowColumn(getParameter(parameters, 0, TRUE, function), &row, &col, FALSE)) { val1=text(row,col).toDouble(&ok); if(ok) val1=1; else val1=0; - }else + } + else { if(findRowColumn(calculateVariable(getParameter(parameters, 0, TRUE, function)), &row,&col, FALSE)) { val1=text(row,col).toDouble(&ok); if(ok) val1=1; else val1=0; - }else + } + else { val1=0; }; }; return QString::number(val1); }; if (function=="AND") { vali=calculateVariable(getParameter(parameters, 0, TRUE, function)).toInt(&ok) & calculateVariable(getParameter(parameters, 1, TRUE, function)).toInt(&ok); return QString::number(vali); }; if (function=="OR") { vali=calculateVariable(getParameter(parameters, 0, TRUE, function)).toInt(&ok) | calculateVariable(getParameter(parameters, 1, TRUE, function)).toInt(&ok); return QString::number(vali); }; if (function=="NOT") { vali=!calculateVariable(getParameter(parameters, 0, TRUE, function)).toInt(&ok); return QString::number(vali); }; @@ -1368,49 +1411,50 @@ QString Sheet::calculateFunction(const QString &func, const QString ¶meters, }; if (function=="UPPER") { // returns the upper param1 string s1=calculateVariable(getParameter(parameters, 0, TRUE, function)); s1=s1.upper(); return QString(s1); }; if (function=="LOWER") { // returns the lower param1 string s1=calculateVariable(getParameter(parameters, 0, TRUE, function)); s1=s1.lower(); return QString(s1); }; if (function=="IF") { //usage: IF(param1,param2,param3) //returns param4 if true(param1)/ param5 if false(param1) val1=getParameter(parameters, 0, TRUE, function).toDouble(&ok); if(val1==1.0) { s1=calculateVariable(getParameter(parameters, 1, TRUE, function)); return QString(s1); - }else + } + else { s1=calculateVariable(getParameter(parameters, 2, TRUE, function)); return QString(s1); }; }; if (function=="SUM") { //NumOfParams val2=0.0; for(w1=1;w1<=(NumOfParams/2);w1++) { val1=functionSum(getParameter(parameters, (w1-1)*2, FALSE, function), getParameter(parameters, (w1-1)*2+1, TRUE, function)); val2=val2+val1; }; if(NumOfParams%2==1) { val2=val2+calculateVariable(getParameter(parameters,NumOfParams-1,FALSE, function)).toDouble(&ok); }; return QString::number(val2); }; if (function=="INDEX") { s1=functionIndex(getParameter(parameters,0,TRUE,function), getParameter(parameters, 1, TRUE, function), getParameter(parameters,2,TRUE,function).toInt(&ok)); return QString(s1); @@ -1531,79 +1575,82 @@ QString Sheet::calculateFunction(const QString &func, const QString ¶meters, }; if(function=="ERF") { // ERF (a,b) val1=calculateVariable(getParameter(parameters, 0, TRUE, function)).toDouble(&ok); val2=calculateVariable(getParameter(parameters, 1, TRUE, function)).toDouble(&ok); return QString::number(ErrorFunction(val2)-ErrorFunction(val1)); }; if(function=="ERFC") { // ERFC (a,b) val1=calculateVariable(getParameter(parameters, 0, TRUE, function)).toDouble(&ok); val2=calculateVariable(getParameter(parameters, 1, TRUE, function)).toDouble(&ok); return QString::number(ErrorFunctionComplementary(val2)-ErrorFunctionComplementary(val1)); }; if(function=="POISSON") { // POISSON DISTR(x,n,distr/desnt) val1=calculateVariable(getParameter(parameters, 0, TRUE, function)).toDouble(&ok); val2=calculateVariable(getParameter(parameters, 1, TRUE, function)).toDouble(&ok); vali=calculateVariable(getParameter(parameters, 2, TRUE, function)).toInt(&ok); if(vali==1) { return QString::number(GammaQ(floor(val1)+1, val2)); - }else + } + else { return QString::number(exp(-val2)*pow(val2,val1)/exp(GammaLn(val1+1.0))); }; }; if(function=="CHIDIST") { // POISSON CHIDIST(x,n,distr/density) val1=calculateVariable(getParameter(parameters, 0, TRUE, function)).toDouble(&ok); val2=calculateVariable(getParameter(parameters, 1, TRUE, function)).toDouble(&ok); vali=calculateVariable(getParameter(parameters, 2, TRUE, function)).toInt(&ok); if(vali==1) { return QString::number(GammaP(val2/2.0,val1*val1/2.0)); - } else + } + else { return QString::number( pow(val1,val2-1.0)*exp(-val1*val1/2)/ ( pow(2,val2/2.0-1.0)*exp(GammaLn(val2/2.0))) ); }; }; if(function=="CHI2DIST") { // POISSON CHISQUAREDIST(x,n,distr/density) val1=calculateVariable(getParameter(parameters, 0, TRUE, function)).toDouble(&ok); val2=calculateVariable(getParameter(parameters, 1, TRUE, function)).toDouble(&ok); vali=calculateVariable(getParameter(parameters, 2, TRUE, function)).toInt(&ok); if(vali==1) { return QString::number(GammaP(val2/2.0,val1/2.0)); - } else + } + else { return QString::number( pow(val1,val2/2.0-1.0)/(exp(val1/2.0)*pow(sqrt(2.0),val2)*exp(GammaLn(val2/2.0))) ); }; }; if(function=="BETAI") { // BETA INCOMPLETE BETA(x,a,b) val1=calculateVariable(getParameter(parameters, 0, TRUE, function)).toDouble(&ok); val2=calculateVariable(getParameter(parameters, 1, TRUE, function)).toDouble(&ok); val3=calculateVariable(getParameter(parameters, 2, TRUE, function)).toDouble(&ok); return QString::number(BetaIncomplete(val2,val3,val1)); }; if(function=="GAMMAP") { // GammaP (x,a) val1=calculateVariable(getParameter(parameters, 0, TRUE, function)).toDouble(&ok); val2=calculateVariable(getParameter(parameters, 1, TRUE, function)).toDouble(&ok); return QString::number(GammaP(val2,val1)); }; if(function=="GAMMAQ") { // GammaQ (x,a) @@ -2364,49 +2411,50 @@ void Expression::GetNext() } else if(InExpr[n]=='e') { if((n+1)<(int)InExpr.length()) { if(InExpr[n+1]=='-' || InExpr[n+1]=='+' || InExpr[n+1].isDigit()) { chunk+=InExpr[n]; chunk+=InExpr[n+1]; SymbGroup=NUMBER_TOKEN; n+=2; } } else { break; } } else { break; } }//while }//else if -};//end function +} +;//end function void Expression::First() { GetNext(); if (!(chunk=="") && !ErrorFound) Third(); else ErrorFound = true; }; void Expression::Third() { QChar sign, secS='\0'; Fourth(); sign = chunk0(); if((int)chunk.length()>1) secS=chunk[1]; while( sign == '+' || sign == '-'|| sign == '<' || sign == '>'|| sign == '%'|| sign == '&' || sign == '|' || sign == '!' || sign == '=' ) { GetNext(); Fourth(); QString name; if( sign == '+' ) name= "+" ; diff --git a/noncore/apps/opie-sheet/sheet.h b/noncore/apps/opie-sheet/sheet.h index f705cd0..92c8061 100644 --- a/noncore/apps/opie-sheet/sheet.h +++ b/noncore/apps/opie-sheet/sheet.h @@ -1,41 +1,61 @@ -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ +/* + =. 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. + +*/ /* * Opie Sheet (formerly Sheet/Qt) * by Serdar Ozler <sozler@sitebest.com> */ #ifndef SHEET_H #define SHEET_H +/* QT */ #include <qtable.h> #include <qstack.h> typedef struct typeCellBorders { QPen right, bottom; }; typedef struct typeCellData { int col, row; typeCellBorders borders; QBrush background; Qt::AlignmentFlags alignment; QColor fontColor; QFont font; QString data; }; #define NONE_TOKEN 0 #define NUMBER_TOKEN 1 #define VARIABLE_TOKEN 2 #define FUNCTION_TOKEN 3 diff --git a/noncore/apps/opie-sheet/sortdlg.cpp b/noncore/apps/opie-sheet/sortdlg.cpp index c2cdec8..47d666f 100644 --- a/noncore/apps/opie-sheet/sortdlg.cpp +++ b/noncore/apps/opie-sheet/sortdlg.cpp @@ -1,83 +1,103 @@ -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ +/* + =. 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. + +*/ /* * Opie Sheet (formerly Sheet/Qt) * by Serdar Ozler <sozler@sitebest.com> */ +#include "sortdlg.h" + +/* QT */ #include <qlabel.h> #include <qradiobutton.h> #include <qmessagebox.h> -#include "sortdlg.h" SortDialog::SortDialog(QWidget *parent) :QDialog(parent, 0, TRUE) { // Main widget tabs=new QTabWidget(this); widgetSort=new QWidget(tabs); widgetOptions=new QWidget(tabs); tabs->addTab(widgetSort, tr("&Sort")); tabs->addTab(widgetOptions, tr("&Options")); // Sort tab comboFieldA=createFieldCombo(tr("&Sort by"), 10); groupOrderA=createOrderButtons(10); comboFieldB=createFieldCombo(tr("&Then by"), 90); groupOrderB=createOrderButtons(90); comboFieldC=createFieldCombo(tr("Then &by"), 170); groupOrderC=createOrderButtons(170); // Options tab checkCase=new QCheckBox(tr("&Case Sensitive"), widgetOptions); checkCase->setGeometry(10, 10, 215, 20); checkCase->setChecked(TRUE); groupDirection=new QVButtonGroup(tr("&Direction"), widgetOptions); groupDirection->setGeometry(10, 40, 215, 70); QRadioButton *radio=new QRadioButton(tr("&Top to bottom (rows)"), groupDirection); radio=new QRadioButton(tr("&Left to right (columns)"), groupDirection); groupDirection->setButton(0); connect(groupDirection, SIGNAL(clicked(int)), this, SLOT(directionChanged(int))); // Main widget box=new QVBoxLayout(this); box->addWidget(tabs); setCaption(tr("Sort")); } SortDialog::~SortDialog() -{ -} +{} QComboBox *SortDialog::createFieldCombo(const QString &caption, int y) { QLabel *label=new QLabel(caption, widgetSort); label->setGeometry(10, y+5, 215, 20); QComboBox *combo=new QComboBox(FALSE, widgetSort); combo->setGeometry(10, y+35, 105, 20); label->setBuddy(combo); return combo; } QVButtonGroup *SortDialog::createOrderButtons(int y) { QVButtonGroup *group=new QVButtonGroup(widgetSort); group->setGeometry(125, y, 100, 60); QRadioButton *radio=new QRadioButton(tr("&Ascending"), group); radio=new QRadioButton(tr("&Descending"), group); group->setButton(0); return group; } void SortDialog::directionChanged(int id) { direction=id; diff --git a/noncore/apps/opie-sheet/sortdlg.h b/noncore/apps/opie-sheet/sortdlg.h index b3699a9..5a1025e 100644 --- a/noncore/apps/opie-sheet/sortdlg.h +++ b/noncore/apps/opie-sheet/sortdlg.h @@ -1,49 +1,70 @@ -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ +/* + =. 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. + +*/ /* * Opie Sheet (formerly Sheet/Qt) * by Serdar Ozler <sozler@sitebest.com> */ #ifndef SORTDLG_H #define SORTDLG_H +#include "sheet.h" + +/* QT */ #include <qdialog.h> #include <qtabwidget.h> #include <qlayout.h> #include <qcombobox.h> #include <qcheckbox.h> #include <qpushbutton.h> #include <qvbuttongroup.h> -#include "sheet.h" class SortDialog: public QDialog { Q_OBJECT // QT objects QBoxLayout *box; QTabWidget *tabs; QWidget *widgetSort, *widgetOptions; QVButtonGroup *groupOrderA, *groupOrderB, *groupOrderC, *groupDirection; QCheckBox *checkCase; QComboBox *comboFieldA, *comboFieldB, *comboFieldC; // Other objects & variables int row1, col1, row2, col2, direction; Sheet *sheet; // Private functions QVButtonGroup *createOrderButtons(int y); QComboBox *createFieldCombo(const QString &caption, int y); void fillFieldCombo(QComboBox *combo); int compareItems(QTableItem *item1, QTableItem *item2, int descending=0, bool caseSensitive=TRUE); private slots: diff --git a/noncore/apps/opie-sheet/textdlg.cpp b/noncore/apps/opie-sheet/textdlg.cpp index 34cec29..020b9ae 100644 --- a/noncore/apps/opie-sheet/textdlg.cpp +++ b/noncore/apps/opie-sheet/textdlg.cpp @@ -1,47 +1,65 @@ -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ +/* + =. 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. + +*/ /* * Opie Sheet (formerly Sheet/Qt) * by Serdar Ozler <sozler@sitebest.com> */ #include "textdlg.h" TextDialog::TextDialog(QWidget *parent) :QDialog(parent, 0, TRUE) { edit=new QLineEdit(this); edit->setGeometry(90, 10, 100, 25); label=new QLabel(this); label->setGeometry(10, 10, 70, 25); label->setBuddy(edit); resize(200, 45); } TextDialog::~TextDialog() -{ -} +{} int TextDialog::exec(const QString &caption, const QString &text, const QString &value) { setCaption(caption); label->setText(text); edit->setText(value); return QDialog::exec(); } QString TextDialog::getValue() { return edit->text(); } diff --git a/noncore/apps/opie-sheet/textdlg.h b/noncore/apps/opie-sheet/textdlg.h index 78ef580..d54da16 100644 --- a/noncore/apps/opie-sheet/textdlg.h +++ b/noncore/apps/opie-sheet/textdlg.h @@ -1,38 +1,58 @@ -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ +/* + =. 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. + +*/ /* * Opie Sheet (formerly Sheet/Qt) * by Serdar Ozler <sozler@sitebest.com> */ #ifndef TEXTDLG_H #define TEXTDLG_H +/* QT */ #include <qdialog.h> #include <qlabel.h> #include <qlineedit.h> class TextDialog: public QDialog { Q_OBJECT // QT objects QLabel *label; QLineEdit *edit; public: TextDialog(QWidget *parent=0); ~TextDialog(); int exec(const QString &caption, const QString &text, const QString &value=""); QString getValue(); }; #endif |