-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,21 +1,49 @@ | |||
1 | /* | ||
2 | =. This file is part of the Opie Project | ||
3 | .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> | ||
4 | .>+-= | ||
5 | _;:, .> :=|. This program is free software; you can | ||
6 | .> <`_, > . <= redistribute it and/or modify it under | ||
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
8 | .="- .-=="i, .._ License as published by the Free Software | ||
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This program is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
1 | 28 | ||
29 | #include "Excel.h" | ||
2 | 30 | ||
31 | /* STD */ | ||
3 | #include <stdio.h> | 32 | #include <stdio.h> |
4 | #include <stdlib.h> | 33 | #include <stdlib.h> |
5 | #include <math.h> | 34 | #include <math.h> |
6 | #include <time.h> | 35 | #include <time.h> |
7 | #include <sys/types.h> | 36 | #include <sys/types.h> |
8 | #include <strings.h> | 37 | #include <strings.h> |
9 | #include "Excel.h" | ||
10 | 38 | ||
11 | static xfrecord formatter[] = { | 39 | static xfrecord formatter[] = { |
12 | { 0xe , DATEFORMAT, "%m/%d/%y"}, | 40 | { 0xe , DATEFORMAT, "%m/%d/%y"}, |
13 | { 0xf , DATEFORMAT, "%d-%b-%y"}, | 41 | { 0xf , DATEFORMAT, "%d-%b-%y"}, |
14 | { 0x10, DATEFORMAT, "%d-%b"}, | 42 | { 0x10, DATEFORMAT, "%d-%b"}, |
15 | { 0x11, DATEFORMAT, "%b-%y"}, | 43 | { 0x11, DATEFORMAT, "%b-%y"}, |
16 | { 0x12, DATEFORMAT, "%I:%M %p"}, | 44 | { 0x12, DATEFORMAT, "%I:%M %p"}, |
17 | { 0x13, DATEFORMAT, "%I:%M:%S %p"}, | 45 | { 0x13, DATEFORMAT, "%I:%M:%S %p"}, |
18 | { 0x14, DATEFORMAT, "%H:%M"}, | 46 | { 0x14, DATEFORMAT, "%H:%M"}, |
19 | { 0x15, DATEFORMAT, "%H:%M:%S"}, | 47 | { 0x15, DATEFORMAT, "%H:%M:%S"}, |
20 | { 0x16, DATEFORMAT, "%m/%d/%y %H:%M"}, | 48 | { 0x16, DATEFORMAT, "%m/%d/%y %H:%M"}, |
21 | { 0x2d, DATEFORMAT, "%M:%S"}, | 49 | { 0x2d, DATEFORMAT, "%M:%S"}, |
@@ -54,25 +82,26 @@ int ExcelBook::Integer2Byte(int b1, int b2) | |||
54 | int val = i2 << 8 | i1; | 82 | int val = i2 << 8 | i1; |
55 | return val; | 83 | return val; |
56 | }; | 84 | }; |
57 | 85 | ||
58 | int ExcelBook::Integer4Byte(int b1,int b2,int b3,int b4) | 86 | int ExcelBook::Integer4Byte(int b1,int b2,int b3,int b4) |
59 | { | 87 | { |
60 | int i1 = Integer2Byte(b1, b2); | 88 | int i1 = Integer2Byte(b1, b2); |
61 | int i2 = Integer2Byte(b3, b4); | 89 | int i2 = Integer2Byte(b3, b4); |
62 | int val = i2 << 16 | i1; | 90 | int val = i2 << 16 | i1; |
63 | return val; | 91 | return val; |
64 | }; | 92 | }; |
65 | 93 | ||
66 | int ExcelBook::Integer2ByteFile(FILE *f) { | 94 | int ExcelBook::Integer2ByteFile(FILE *f) |
95 | { | ||
67 | int i1, i2; | 96 | int i1, i2; |
68 | i1 = fgetc(f); | 97 | i1 = fgetc(f); |
69 | i2 = fgetc(f); | 98 | i2 = fgetc(f); |
70 | return Integer2Byte(i1,i2); | 99 | return Integer2Byte(i1,i2); |
71 | }; | 100 | }; |
72 | 101 | ||
73 | float ExcelBook::Float4Byte(int b1, int b2, int b3, int b4) | 102 | float ExcelBook::Float4Byte(int b1, int b2, int b3, int b4) |
74 | { | 103 | { |
75 | int i; | 104 | int i; |
76 | float f; | 105 | float f; |
77 | unsigned char *ieee; | 106 | unsigned char *ieee; |
78 | ieee = (unsigned char *) &f; | 107 | ieee = (unsigned char *) &f; |
@@ -93,25 +122,26 @@ double ExcelBook::Double4Byte(int b1, int b2, int b3, int b4) | |||
93 | //printf("Double4Bytes:%d,%d,%d,%d\r\n",b1,b2,b3,b4); | 122 | //printf("Double4Bytes:%d,%d,%d,%d\r\n",b1,b2,b3,b4); |
94 | if ( (rk & 0x02) != 0) | 123 | if ( (rk & 0x02) != 0) |
95 | { | 124 | { |
96 | long int intval = rk >> 2; //drops the 2 bits | 125 | long int intval = rk >> 2; //drops the 2 bits |
97 | printf("Double4Byte:intval=%d, rk=%d, rk>>2=%d\r\n",intval,rk,rk>>2); | 126 | printf("Double4Byte:intval=%d, rk=%d, rk>>2=%d\r\n",intval,rk,rk>>2); |
98 | value = (double) intval; | 127 | value = (double) intval; |
99 | printf("Double4Byte: VALUEINT=%f\r\n",value); | 128 | printf("Double4Byte: VALUEINT=%f\r\n",value); |
100 | if ( (rk & 0x01) != 0) | 129 | if ( (rk & 0x01) != 0) |
101 | { | 130 | { |
102 | value /= 100.0; | 131 | value /= 100.0; |
103 | }; | 132 | }; |
104 | return value; | 133 | return value; |
105 | }else | 134 | } |
135 | else | ||
106 | { | 136 | { |
107 | 137 | ||
108 | union { double d; unsigned long int b[2]; } dbl_byte; | 138 | union { double d; unsigned long int b[2]; } dbl_byte; |
109 | unsigned long int valbits = (rk & 0xfffffffc); | 139 | unsigned long int valbits = (rk & 0xfffffffc); |
110 | #if defined(__arm__) && !defined(__vfp__) | 140 | #if defined(__arm__) && !defined(__vfp__) |
111 | dbl_byte.b[0]=valbits; | 141 | dbl_byte.b[0]=valbits; |
112 | dbl_byte.b[1]=0; | 142 | dbl_byte.b[1]=0; |
113 | #else | 143 | #else |
114 | dbl_byte.b[0]=0; | 144 | dbl_byte.b[0]=0; |
115 | dbl_byte.b[1]=valbits; | 145 | dbl_byte.b[1]=valbits; |
116 | #endif | 146 | #endif |
117 | printf("dbl_byte.b[0]=%d,dbl_byte.b[1]=%d\r\n",dbl_byte.b[0],dbl_byte.b[1]); | 147 | printf("dbl_byte.b[0]=%d,dbl_byte.b[1]=%d\r\n",dbl_byte.b[0],dbl_byte.b[1]); |
@@ -123,46 +153,52 @@ double ExcelBook::Double4Byte(int b1, int b2, int b3, int b4) | |||
123 | value /= 100.0; | 153 | value /= 100.0; |
124 | }; | 154 | }; |
125 | return value; | 155 | return value; |
126 | }; | 156 | }; |
127 | }; | 157 | }; |
128 | 158 | ||
129 | void ExcelBook::DetectEndian(void) | 159 | void ExcelBook::DetectEndian(void) |
130 | { | 160 | { |
131 | int end; | 161 | int end; |
132 | long i = 0x44332211; | 162 | long i = 0x44332211; |
133 | unsigned char* a = (unsigned char*) &i; | 163 | unsigned char* a = (unsigned char*) &i; |
134 | end = (*a != 0x11); | 164 | end = (*a != 0x11); |
135 | if (end == 1) { | 165 | if (end == 1) |
166 | { | ||
136 | endian = BIG_ENDIAN; | 167 | endian = BIG_ENDIAN; |
137 | printf("BIGENDIAN!\r\n"); | 168 | printf("BIGENDIAN!\r\n"); |
138 | } else { | 169 | } |
170 | else | ||
171 | { | ||
139 | endian = LITTLE_ENDIAN; | 172 | endian = LITTLE_ENDIAN; |
140 | printf("LITTLEENDIAN!\r\n"); | 173 | printf("LITTLEENDIAN!\r\n"); |
141 | } | 174 | } |
142 | }; | 175 | }; |
143 | 176 | ||
144 | double ExcelBook::Double8Byte(int b1, int b2, int b3, int b4, int b5, int b6, int b7, int b8) | 177 | double ExcelBook::Double8Byte(int b1, int b2, int b3, int b4, int b5, int b6, int b7, int b8) |
145 | { | 178 | { |
146 | int i; | 179 | int i; |
147 | double d; | 180 | double d; |
148 | unsigned char *ieee; | 181 | unsigned char *ieee; |
149 | ieee = (unsigned char *)&d; | 182 | ieee = (unsigned char *)&d; |
150 | for (i = 0; i < 8; i++) ieee[i] = 0; | 183 | for (i = 0; i < 8; i++) ieee[i] = 0; |
151 | if (endian == BIG_ENDIAN) { | 184 | if (endian == BIG_ENDIAN) |
185 | { | ||
152 | ieee[0] = ((int)b8) & 0xff;ieee[1] = ((int)b7) & 0xff; | 186 | ieee[0] = ((int)b8) & 0xff;ieee[1] = ((int)b7) & 0xff; |
153 | ieee[2] = ((int)b6) & 0xff;ieee[3] = ((int)b5) & 0xff; | 187 | ieee[2] = ((int)b6) & 0xff;ieee[3] = ((int)b5) & 0xff; |
154 | ieee[4] = ((int)b4) & 0xff;ieee[5] = ((int)b3) & 0xff; | 188 | ieee[4] = ((int)b4) & 0xff;ieee[5] = ((int)b3) & 0xff; |
155 | ieee[6] = ((int)b2) & 0xff;ieee[7] = ((int)b1) & 0xff; | 189 | ieee[6] = ((int)b2) & 0xff;ieee[7] = ((int)b1) & 0xff; |
156 | } else { | 190 | } |
191 | else | ||
192 | { | ||
157 | ieee[0] = ((int)b1) & 0xff;ieee[1] = ((int)b2) & 0xff; | 193 | ieee[0] = ((int)b1) & 0xff;ieee[1] = ((int)b2) & 0xff; |
158 | ieee[2] = ((int)b3) & 0xff;ieee[3] = ((int)b4) & 0xff; | 194 | ieee[2] = ((int)b3) & 0xff;ieee[3] = ((int)b4) & 0xff; |
159 | ieee[4] = ((int)b5) & 0xff;ieee[5] = ((int)b6) & 0xff; | 195 | ieee[4] = ((int)b5) & 0xff;ieee[5] = ((int)b6) & 0xff; |
160 | ieee[6] = ((int)b7) & 0xff;ieee[7] = ((int)b8) & 0xff; | 196 | ieee[6] = ((int)b7) & 0xff;ieee[7] = ((int)b8) & 0xff; |
161 | } | 197 | } |
162 | return d; | 198 | return d; |
163 | }; | 199 | }; |
164 | 200 | ||
165 | bool ExcelBook::OpenFile(char *Filename) | 201 | bool ExcelBook::OpenFile(char *Filename) |
166 | { | 202 | { |
167 | printf("Opening excel file!\r\n"); | 203 | printf("Opening excel file!\r\n"); |
168 | File= fopen(Filename, "r"); | 204 | File= fopen(Filename, "r"); |
@@ -384,25 +420,26 @@ ExcelCell* ExcelSheet::Get(int row, int col) | |||
384 | 420 | ||
385 | int ExcelBook::SheetHandleRecord(ExcelSheet* sheet, ExcelBREC* record) | 421 | int ExcelBook::SheetHandleRecord(ExcelSheet* sheet, ExcelBREC* record) |
386 | { | 422 | { |
387 | char* data=NULL; | 423 | char* data=NULL; |
388 | switch (record->code) | 424 | switch (record->code) |
389 | { | 425 | { |
390 | case XL_DIMENSION: | 426 | case XL_DIMENSION: |
391 | data = GetDataOfBREC(record); | 427 | data = GetDataOfBREC(record); |
392 | if (record->length == 10) | 428 | if (record->length == 10) |
393 | { | 429 | { |
394 | sheet->rows = Integer2Byte(data[2], data[3]); | 430 | sheet->rows = Integer2Byte(data[2], data[3]); |
395 | sheet->cols = Integer2Byte(data[6], data[7]); | 431 | sheet->cols = Integer2Byte(data[6], data[7]); |
396 | } else | 432 | } |
433 | else | ||
397 | { | 434 | { |
398 | sheet->rows = Integer4Byte(data[4], data[5], data[6], data[7]); | 435 | sheet->rows = Integer4Byte(data[4], data[5], data[6], data[7]); |
399 | sheet->cols = Integer2Byte(data[10], data[11]); | 436 | sheet->cols = Integer2Byte(data[10], data[11]); |
400 | } | 437 | } |
401 | sheet->InitCells(); | 438 | sheet->InitCells(); |
402 | break; | 439 | break; |
403 | 440 | ||
404 | case XL_LABELSST: | 441 | case XL_LABELSST: |
405 | HandleLabelSST(sheet, record); | 442 | HandleLabelSST(sheet, record); |
406 | break; | 443 | break; |
407 | 444 | ||
408 | case XL_RK: | 445 | case XL_RK: |
@@ -593,25 +630,26 @@ void ExcelBook::HandleBoundSheet(ExcelBREC* rec) | |||
593 | int length; | 630 | int length; |
594 | int pos; | 631 | int pos; |
595 | QString name; | 632 | QString name; |
596 | pos = 8; | 633 | pos = 8; |
597 | data = GetDataOfBREC(rec); | 634 | data = GetDataOfBREC(rec); |
598 | type = data[4]; | 635 | type = data[4]; |
599 | visibility = data[5]; | 636 | visibility = data[5]; |
600 | length = data[6]; | 637 | length = data[6]; |
601 | if(data[7]==0) | 638 | if(data[7]==0) |
602 | { | 639 | { |
603 | //ascii | 640 | //ascii |
604 | name=GetASCII(data,pos,length); | 641 | name=GetASCII(data,pos,length); |
605 | }else | 642 | } |
643 | else | ||
606 | { | 644 | { |
607 | name=GetUnicode(data,pos,length); | 645 | name=GetUnicode(data,pos,length); |
608 | }; | 646 | }; |
609 | Names.resize(Names.count()+1); | 647 | Names.resize(Names.count()+1); |
610 | Names[Names.count()-1]=new QString(name); | 648 | Names[Names.count()-1]=new QString(name); |
611 | }; | 649 | }; |
612 | 650 | ||
613 | void ExcelBook::HandleName(ExcelSheet* sheet, ExcelBREC* rec) | 651 | void ExcelBook::HandleName(ExcelSheet* sheet, ExcelBREC* rec) |
614 | { | 652 | { |
615 | char* data; | 653 | char* data; |
616 | QString name; | 654 | QString name; |
617 | int length; | 655 | int length; |
@@ -799,38 +837,41 @@ QString* ExcelBook::CellDataString(ExcelSheet* sh, int row, int col) | |||
799 | case CELL_LABEL: | 837 | case CELL_LABEL: |
800 | return new QString(c->valuec); | 838 | return new QString(c->valuec); |
801 | case CELL_NUMBER: | 839 | case CELL_NUMBER: |
802 | if (XFRecords[c->xfindex]->type == DATEFORMAT) | 840 | if (XFRecords[c->xfindex]->type == DATEFORMAT) |
803 | { | 841 | { |
804 | 842 | ||
805 | format = XFRecords[c->xfindex]->format; | 843 | format = XFRecords[c->xfindex]->format; |
806 | date = (time_t) ((c->valued - utcOffsetDays) * sInADay); | 844 | date = (time_t) ((c->valued - utcOffsetDays) * sInADay); |
807 | tmptr = gmtime(&date); | 845 | tmptr = gmtime(&date); |
808 | if (dateformat) | 846 | if (dateformat) |
809 | { | 847 | { |
810 | strftime(str,1024,dateformat.ascii(),tmptr); | 848 | strftime(str,1024,dateformat.ascii(),tmptr); |
811 | } else | 849 | } |
850 | else | ||
812 | { | 851 | { |
813 | strftime(str,1024,format.ascii(),tmptr); | 852 | strftime(str,1024,format.ascii(),tmptr); |
814 | }; | 853 | }; |
815 | } else | 854 | } |
855 | else | ||
816 | if (XFRecords[c->xfindex]->type == NUMBERFORMAT) | 856 | if (XFRecords[c->xfindex]->type == NUMBERFORMAT) |
817 | { | 857 | { |
818 | format = XFRecords[c->xfindex]->format; | 858 | format = XFRecords[c->xfindex]->format; |
819 | //sprintf(str,format.ascii(),c->valued); | 859 | //sprintf(str,format.ascii(),c->valued); |
820 | // the real format is ignored... | 860 | // the real format is ignored... |
821 | // because there is more work to be done in the field | 861 | // because there is more work to be done in the field |
822 | precision = CellGetPrecision(c->valued); | 862 | precision = CellGetPrecision(c->valued); |
823 | sprintf(str,"%.*f",precision,c->valued); | 863 | sprintf(str,"%.*f",precision,c->valued); |
824 | }else | 864 | } |
865 | else | ||
825 | { | 866 | { |
826 | precision = CellGetPrecision(c->valued); | 867 | precision = CellGetPrecision(c->valued); |
827 | sprintf(str,"%.*f",precision,c->valued); | 868 | sprintf(str,"%.*f",precision,c->valued); |
828 | }; | 869 | }; |
829 | break; | 870 | break; |
830 | case CELL_DATE: | 871 | case CELL_DATE: |
831 | break; | 872 | break; |
832 | case CELL_BOOLEAN: | 873 | case CELL_BOOLEAN: |
833 | break; | 874 | break; |
834 | case CELL_ERROR: | 875 | case CELL_ERROR: |
835 | break; | 876 | break; |
836 | } | 877 | } |
@@ -993,29 +1034,31 @@ void ExcelBook::HandleRK(ExcelSheet* sheet, ExcelBREC* record) | |||
993 | 1034 | ||
994 | void ExcelBook::HandleFormula(ExcelSheet* sheet, ExcelBREC* record) | 1035 | void ExcelBook::HandleFormula(ExcelSheet* sheet, ExcelBREC* record) |
995 | { | 1036 | { |
996 | int xfindex, row, col; | 1037 | int xfindex, row, col; |
997 | char* data; | 1038 | char* data; |
998 | double d; | 1039 | double d; |
999 | data = GetDataOfBREC(record); | 1040 | data = GetDataOfBREC(record); |
1000 | row = Integer2Byte(data[0], data[1]); | 1041 | row = Integer2Byte(data[0], data[1]); |
1001 | col = Integer2Byte(data[2], data[3]); | 1042 | col = Integer2Byte(data[2], data[3]); |
1002 | if (data[6] == 0 && data[12] == -1 && data[13] == -1) | 1043 | if (data[6] == 0 && data[12] == -1 && data[13] == -1) |
1003 | { | 1044 | { |
1004 | // string | 1045 | // string |
1005 | } else | 1046 | } |
1047 | else | ||
1006 | if (data[6] == 1 && data[12] == -1 && data[13] == -1) | 1048 | if (data[6] == 1 && data[12] == -1 && data[13] == -1) |
1007 | { | 1049 | { |
1008 | // boolean | 1050 | // boolean |
1009 | } else | 1051 | } |
1052 | else | ||
1010 | if ( data[6] == 2 && data[12] == -1 && data[13] == -1) | 1053 | if ( data[6] == 2 && data[12] == -1 && data[13] == -1) |
1011 | { | 1054 | { |
1012 | // error | 1055 | // error |
1013 | } | 1056 | } |
1014 | else | 1057 | else |
1015 | { | 1058 | { |
1016 | // number | 1059 | // number |
1017 | xfindex = Integer2Byte(data[4], data[5]); | 1060 | xfindex = Integer2Byte(data[4], data[5]); |
1018 | d=Double8Byte(data[6], data[7], data[8], data[9],data[10], data[11], data[12], data[13]); | 1061 | d=Double8Byte(data[6], data[7], data[8], data[9],data[10], data[11], data[12], data[13]); |
1019 | QString s1; | 1062 | QString s1; |
1020 | int sz; | 1063 | int sz; |
1021 | sz=Integer2Byte(data[20],data[21]);// size of the formula | 1064 | sz=Integer2Byte(data[20],data[21]);// size of the formula |
@@ -1114,63 +1157,66 @@ QString ExcelBook::GetFormula(int row, int col, ExcelSheet* sheet, char* data, i | |||
1114 | }; | 1157 | }; |
1115 | // HERE TO PUT richformat handling | 1158 | // HERE TO PUT richformat handling |
1116 | if (richstring) | 1159 | if (richstring) |
1117 | { | 1160 | { |
1118 | idx += 4 * richruns; | 1161 | idx += 4 * richruns; |
1119 | }; | 1162 | }; |
1120 | if (fareaststring) | 1163 | if (fareaststring) |
1121 | { | 1164 | { |
1122 | idx += fareastsize; | 1165 | idx += fareastsize; |
1123 | }; | 1166 | }; |
1124 | s1=QString("""")+s1+QString(""""); | 1167 | s1=QString("""")+s1+QString(""""); |
1125 | operands.prepend(new QString(s1)); | 1168 | operands.prepend(new QString(s1)); |
1126 | }else | 1169 | } |
1170 | else | ||
1127 | { | 1171 | { |
1128 | w1=data[idx];idx++; | 1172 | w1=data[idx];idx++; |
1129 | s1=GetASCII(data,idx,w1); | 1173 | s1=GetASCII(data,idx,w1); |
1130 | s1=QString("""")+s1+QString(""""); | 1174 | s1=QString("""")+s1+QString(""""); |
1131 | idx=idx+w1; | 1175 | idx=idx+w1; |
1132 | operands.prepend(new QString(s1)); | 1176 | operands.prepend(new QString(s1)); |
1133 | }; | 1177 | }; |
1134 | printf(" token:ptgStr,num=%d\r\n",w1); | 1178 | printf(" token:ptgStr,num=%d\r\n",w1); |
1135 | break; | 1179 | break; |
1136 | case 0x25: | 1180 | case 0x25: |
1137 | case 0x45: | 1181 | case 0x45: |
1138 | case 0x65: // ptgArea | 1182 | case 0x65: // ptgArea |
1139 | if(Version==8) | 1183 | if(Version==8) |
1140 | { | 1184 | { |
1141 | w1=Integer2Byte(data[idx],data[idx+1]);idx=idx+2;//row1 | 1185 | w1=Integer2Byte(data[idx],data[idx+1]);idx=idx+2;//row1 |
1142 | w2=Integer2Byte(data[idx],data[idx+1]);idx=idx+2;//row2 | 1186 | w2=Integer2Byte(data[idx],data[idx+1]);idx=idx+2;//row2 |
1143 | w3=Integer2Byte(data[idx],data[idx+1]) & 0x00FF;idx=idx+2;//col1 | 1187 | w3=Integer2Byte(data[idx],data[idx+1]) & 0x00FF;idx=idx+2;//col1 |
1144 | w4=Integer2Byte(data[idx],data[idx+1]) & 0x00FF;idx=idx+2;//col2 | 1188 | w4=Integer2Byte(data[idx],data[idx+1]) & 0x00FF;idx=idx+2;//col2 |
1145 | }else | 1189 | } |
1190 | else | ||
1146 | { | 1191 | { |
1147 | w1=Integer2Byte(data[idx],data[idx+1]) & 0x3FFF;idx=idx+2;//row1 | 1192 | w1=Integer2Byte(data[idx],data[idx+1]) & 0x3FFF;idx=idx+2;//row1 |
1148 | w2=Integer2Byte(data[idx],data[idx+1]) & 0x3FFF;idx=idx+2;//row2 | 1193 | w2=Integer2Byte(data[idx],data[idx+1]) & 0x3FFF;idx=idx+2;//row2 |
1149 | w3=Integer2Byte(data[idx],data[idx+1]);idx=idx+2;//col1 | 1194 | w3=Integer2Byte(data[idx],data[idx+1]);idx=idx+2;//col1 |
1150 | w4=Integer2Byte(data[idx],data[idx+1]);idx=idx+2;//col2 | 1195 | w4=Integer2Byte(data[idx],data[idx+1]);idx=idx+2;//col2 |
1151 | }; | 1196 | }; |
1152 | //ignores relative or absolute refs | 1197 | //ignores relative or absolute refs |
1153 | s1=FindCellName(w1,w3)+":"+FindCellName(w2,w4); | 1198 | s1=FindCellName(w1,w3)+":"+FindCellName(w2,w4); |
1154 | printf(" token:ptgArea,ref=%s\r\n",s1.ascii()); | 1199 | printf(" token:ptgArea,ref=%s\r\n",s1.ascii()); |
1155 | operands.prepend(new QString(s1)); | 1200 | operands.prepend(new QString(s1)); |
1156 | break; | 1201 | break; |
1157 | case 0x24: | 1202 | case 0x24: |
1158 | case 0x44: | 1203 | case 0x44: |
1159 | case 0x64://ptgRef | 1204 | case 0x64://ptgRef |
1160 | if(Version==8) | 1205 | if(Version==8) |
1161 | { | 1206 | { |
1162 | w1=Integer2Byte(data[idx],data[idx+1]);idx=idx+2;//row | 1207 | w1=Integer2Byte(data[idx],data[idx+1]);idx=idx+2;//row |
1163 | w2=Integer2Byte(data[idx],data[idx+1]) & 0x00FF;idx=idx+2;//col | 1208 | w2=Integer2Byte(data[idx],data[idx+1]) & 0x00FF;idx=idx+2;//col |
1164 | }else | 1209 | } |
1210 | else | ||
1165 | { | 1211 | { |
1166 | w1=Integer2Byte(data[idx],data[idx+1]) & 0x3FFF;idx=idx+2;//row | 1212 | w1=Integer2Byte(data[idx],data[idx+1]) & 0x3FFF;idx=idx+2;//row |
1167 | w2=Integer2Byte(data[idx],data[idx+1]);idx=idx+2;//col | 1213 | w2=Integer2Byte(data[idx],data[idx+1]);idx=idx+2;//col |
1168 | }; | 1214 | }; |
1169 | s1=FindCellName(w1,w2); | 1215 | s1=FindCellName(w1,w2); |
1170 | printf("token:ptgRef,ref=%s\r\n",s1.ascii()); | 1216 | printf("token:ptgRef,ref=%s\r\n",s1.ascii()); |
1171 | operands.prepend(new QString(s1)); | 1217 | operands.prepend(new QString(s1)); |
1172 | break; | 1218 | break; |
1173 | case 0x1D: // ptgBool | 1219 | case 0x1D: // ptgBool |
1174 | w1=data[idx];idx++; | 1220 | w1=data[idx];idx++; |
1175 | printf("token:ptgBool,val=%d\r\n",w1); | 1221 | printf("token:ptgBool,val=%d\r\n",w1); |
1176 | operands.prepend(new QString(QString::number(w1))); | 1222 | operands.prepend(new QString(QString::number(w1))); |
@@ -1323,25 +1369,26 @@ QString ExcelBook::GetFormula(int row, int col, ExcelSheet* sheet, char* data, i | |||
1323 | 1369 | ||
1324 | case 0x21: | 1370 | case 0x21: |
1325 | case 0x22: | 1371 | case 0x22: |
1326 | case 0x42: | 1372 | case 0x42: |
1327 | case 0x62: | 1373 | case 0x62: |
1328 | case 0x41: | 1374 | case 0x41: |
1329 | case 0x61://ptgFunction | 1375 | case 0x61://ptgFunction |
1330 | printf("token:ptgFunction\r\n"); | 1376 | printf("token:ptgFunction\r\n"); |
1331 | if(token==0x22||token==0x42||token==0x62) | 1377 | if(token==0x22||token==0x42||token==0x62) |
1332 | { | 1378 | { |
1333 | w2=(int)data[idx];idx++; | 1379 | w2=(int)data[idx];idx++; |
1334 | w1=Integer2Byte(data[idx],data[idx+1]);idx=idx+2; | 1380 | w1=Integer2Byte(data[idx],data[idx+1]);idx=idx+2; |
1335 | }else | 1381 | } |
1382 | else | ||
1336 | { | 1383 | { |
1337 | w1=Integer2Byte(data[idx],data[idx+1]);idx=idx+2; | 1384 | w1=Integer2Byte(data[idx],data[idx+1]);idx=idx+2; |
1338 | }; | 1385 | }; |
1339 | switch(w1) | 1386 | switch(w1) |
1340 | { | 1387 | { |
1341 | case 0xf://SIN | 1388 | case 0xf://SIN |
1342 | s1=QString("SIN(")+operands.first()->ascii()+QString(")"); | 1389 | s1=QString("SIN(")+operands.first()->ascii()+QString(")"); |
1343 | operands.removeFirst(); | 1390 | operands.removeFirst(); |
1344 | operands.prepend(new QString(s1)); | 1391 | operands.prepend(new QString(s1)); |
1345 | break; | 1392 | break; |
1346 | case 0x10://COS | 1393 | case 0x10://COS |
1347 | s1=QString("COS(")+operands.first()->ascii()+QString(")"); | 1394 | s1=QString("COS(")+operands.first()->ascii()+QString(")"); |
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,22 +1,52 @@ | |||
1 | /* | ||
2 | =. This file is part of the Opie Project | ||
3 | .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> | ||
4 | .>+-= | ||
5 | _;:, .> :=|. This program is free software; you can | ||
6 | .> <`_, > . <= redistribute it and/or modify it under | ||
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
8 | .="- .-=="i, .._ License as published by the Free Software | ||
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This program is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | /* QT */ | ||
30 | #include <qstring.h> | ||
31 | #include <qarray.h> | ||
32 | #include <qlist.h> | ||
1 | 33 | ||
34 | /* STD */ | ||
2 | #include <stdio.h> | 35 | #include <stdio.h> |
3 | #include <stdlib.h> | 36 | #include <stdlib.h> |
4 | #include <math.h> | 37 | #include <math.h> |
5 | #include <time.h> | 38 | #include <time.h> |
6 | #include <sys/types.h> | 39 | #include <sys/types.h> |
7 | #include <strings.h> | 40 | #include <strings.h> |
8 | #include <qstring.h> | ||
9 | #include <qarray.h> | ||
10 | #include <qlist.h> | ||
11 | 41 | ||
12 | #define DATEFORMAT 0x1 | 42 | #define DATEFORMAT 0x1 |
13 | #define NUMBERFORMAT 0x2 | 43 | #define NUMBERFORMAT 0x2 |
14 | 44 | ||
15 | #define BIFF8 0x600 | 45 | #define BIFF8 0x600 |
16 | #define BIFF7 0x500 | 46 | #define BIFF7 0x500 |
17 | #define WBKGLOBAL 0x5 | 47 | #define WBKGLOBAL 0x5 |
18 | #define WRKSHEET 0x10 | 48 | #define WRKSHEET 0x10 |
19 | 49 | ||
20 | #define XL_ARRAY 0x221 | 50 | #define XL_ARRAY 0x221 |
21 | #define XL_BOUNDSHEET 0x85 | 51 | #define XL_BOUNDSHEET 0x85 |
22 | #define XL_BOF 0x809 | 52 | #define XL_BOF 0x809 |
@@ -105,37 +135,35 @@ public: | |||
105 | int type; | 135 | int type; |
106 | int rows; | 136 | int rows; |
107 | int cols; | 137 | int cols; |
108 | 138 | ||
109 | int cellsize,rowalloc,cellalloc; | 139 | int cellsize,rowalloc,cellalloc; |
110 | QArray <ExcelCell*> Cells; | 140 | QArray <ExcelCell*> Cells; |
111 | bool InitCells(void); // true if ok | 141 | bool InitCells(void); // true if ok |
112 | ExcelCell* Get(int row, int col); | 142 | ExcelCell* Get(int row, int col); |
113 | void Set(int row, int col, ExcelCell* cell); | 143 | void Set(int row, int col, ExcelCell* cell); |
114 | 144 | ||
115 | }; | 145 | }; |
116 | 146 | ||
117 | struct mulrk { | 147 | struct mulrk |
148 | { | ||
118 | int row; | 149 | int row; |
119 | int first; | 150 | int first; |
120 | int last; | 151 | int last; |
121 | int numrks; | 152 | int numrks; |
122 | QArray<int> rknumbers; | 153 | QArray<int> rknumbers; |
123 | QArray<double> rkdbls; | 154 | QArray<double> rkdbls; |
124 | QArray<int> xfindices; | 155 | QArray<int> xfindices; |
125 | }; | 156 | }; |
126 | 157 | ||
127 | |||
128 | |||
129 | |||
130 | class ExcelBook | 158 | class ExcelBook |
131 | { | 159 | { |
132 | public: | 160 | public: |
133 | FILE *File; | 161 | FILE *File; |
134 | int Position; | 162 | int Position; |
135 | //int stringcount; | 163 | //int stringcount; |
136 | QArray <QString*> SharedStrings; | 164 | QArray <QString*> SharedStrings; |
137 | //int xfcount; | 165 | //int xfcount; |
138 | QArray <ExcelFormat*> XFRecords; | 166 | QArray <ExcelFormat*> XFRecords; |
139 | //int Sheetcount; | 167 | //int Sheetcount; |
140 | QArray <ExcelSheet*> Sheets; | 168 | QArray <ExcelSheet*> Sheets; |
141 | //int name count; | 169 | //int name count; |
@@ -187,19 +215,14 @@ ExcelCell* CellNumber(int row, int col, int index, double d); | |||
187 | QString* CellDataString(ExcelSheet* sh, int row, int col); | 215 | QString* CellDataString(ExcelSheet* sh, int row, int col); |
188 | int CellGetPrecision(double d); | 216 | int CellGetPrecision(double d); |
189 | void CellSetDateFormat(char *d); | 217 | void CellSetDateFormat(char *d); |
190 | void HandleMulrk(ExcelSheet* sheet, ExcelBREC* record); | 218 | void HandleMulrk(ExcelSheet* sheet, ExcelBREC* record); |
191 | void MulrkRead(struct mulrk *mulrk, char* data); | 219 | void MulrkRead(struct mulrk *mulrk, char* data); |
192 | void HandleNumber(ExcelSheet* sheet, ExcelBREC* record); | 220 | void HandleNumber(ExcelSheet* sheet, ExcelBREC* record); |
193 | void HandleFormat(ExcelBREC* rec); | 221 | void HandleFormat(ExcelBREC* rec); |
194 | void HandleXF(ExcelBREC* rec); | 222 | void HandleXF(ExcelBREC* rec); |
195 | void HandleRK(ExcelSheet* sheet, ExcelBREC* record); | 223 | void HandleRK(ExcelSheet* sheet, ExcelBREC* record); |
196 | void HandleFormula(ExcelSheet* sheet, ExcelBREC* record); | 224 | void HandleFormula(ExcelSheet* sheet, ExcelBREC* record); |
197 | QString GetFormula(int row, int col, ExcelSheet* sheet, char* data, int sz); | 225 | QString GetFormula(int row, int col, ExcelSheet* sheet, char* data, int sz); |
198 | QString FindCellName(int row, int col); | 226 | QString FindCellName(int row, int col); |
199 | |||
200 | |||
201 | |||
202 | |||
203 | |||
204 | }; | 227 | }; |
205 | 228 | ||
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,28 +1,48 @@ | |||
1 | /*************************************************************************** | 1 | /* |
2 | * * | 2 | =. This file is part of the Opie Project |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> |
4 | * it under the terms of the GNU General Public License as published by * | 4 | .>+-= |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | _;:, .> :=|. This program is free software; you can |
6 | * (at your option) any later version. * | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | * * | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | ***************************************************************************/ | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This program is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
9 | 28 | ||
10 | /* | 29 | /* |
11 | * Opie Sheet (formerly Sheet/Qt) | 30 | * Opie Sheet (formerly Sheet/Qt) |
12 | * by Serdar Ozler <sozler@sitebest.com> | 31 | * by Serdar Ozler <sozler@sitebest.com> |
13 | */ | 32 | */ |
14 | 33 | ||
15 | #include "cellformat.h" | 34 | #include "cellformat.h" |
16 | 35 | ||
36 | /* QT */ | ||
17 | #include <qlistbox.h> | 37 | #include <qlistbox.h> |
18 | #include <qlabel.h> | 38 | #include <qlabel.h> |
19 | 39 | ||
20 | #define COMBO_WIDTHS 155 | 40 | #define COMBO_WIDTHS 155 |
21 | #define COMBO_HEIGHTS 21 | 41 | #define COMBO_HEIGHTS 21 |
22 | 42 | ||
23 | #define COLOR_COUNT 17 | 43 | #define COLOR_COUNT 17 |
24 | #define STYLE_COUNT 14 | 44 | #define STYLE_COUNT 14 |
25 | #define HALIGN_COUNT 3 | 45 | #define HALIGN_COUNT 3 |
26 | #define VALIGN_COUNT 3 | 46 | #define VALIGN_COUNT 3 |
27 | 47 | ||
28 | QColor qtColors[COLOR_COUNT]={Qt::black,Qt::white, Qt::darkGray, | 48 | QColor qtColors[COLOR_COUNT]={Qt::black,Qt::white, Qt::darkGray, |
@@ -140,26 +160,25 @@ CellFormat::CellFormat(QWidget *parent) | |||
140 | buttonAlignmentDefaults=new QPushButton(tr("&Default Alignment"), widgetAlignment); | 160 | buttonAlignmentDefaults=new QPushButton(tr("&Default Alignment"), widgetAlignment); |
141 | buttonAlignmentDefaults->setGeometry(115, 165+2*(COMBO_HEIGHTS+10), 110, COMBO_HEIGHTS); | 161 | buttonAlignmentDefaults->setGeometry(115, 165+2*(COMBO_HEIGHTS+10), 110, COMBO_HEIGHTS); |
142 | connect(buttonAlignmentDefaults, SIGNAL(clicked()), this, SLOT(slotAlignmentDefaults())); | 162 | connect(buttonAlignmentDefaults, SIGNAL(clicked()), this, SLOT(slotAlignmentDefaults())); |
143 | 163 | ||
144 | // Main widget | 164 | // Main widget |
145 | box=new QVBoxLayout(this); | 165 | box=new QVBoxLayout(this); |
146 | box->addWidget(tabs); | 166 | box->addWidget(tabs); |
147 | 167 | ||
148 | setCaption(tr("Format Cells")); | 168 | setCaption(tr("Format Cells")); |
149 | } | 169 | } |
150 | 170 | ||
151 | CellFormat::~CellFormat() | 171 | CellFormat::~CellFormat() |
152 | { | 172 | {} |
153 | } | ||
154 | 173 | ||
155 | int CellFormat::findColorIndex(const QColor &color) | 174 | int CellFormat::findColorIndex(const QColor &color) |
156 | { | 175 | { |
157 | for (int i=0; i<COLOR_COUNT; ++i) | 176 | for (int i=0; i<COLOR_COUNT; ++i) |
158 | if (qtColors[i]==color) | 177 | if (qtColors[i]==color) |
159 | return i; | 178 | return i; |
160 | return 0; | 179 | return 0; |
161 | } | 180 | } |
162 | 181 | ||
163 | int CellFormat::findVAlignIndex(Qt::AlignmentFlags flag) | 182 | int CellFormat::findVAlignIndex(Qt::AlignmentFlags flag) |
164 | { | 183 | { |
165 | for (int i=0; i<VALIGN_COUNT; ++i) | 184 | for (int i=0; i<VALIGN_COUNT; ++i) |
@@ -520,26 +539,25 @@ int CellFormat::exec(Sheet *s) | |||
520 | 539 | ||
521 | // | 540 | // |
522 | // Border Editor | 541 | // Border Editor |
523 | // | 542 | // |
524 | 543 | ||
525 | BorderEditor::BorderEditor(QWidget *parent) | 544 | BorderEditor::BorderEditor(QWidget *parent) |
526 | :QFrame(parent) | 545 | :QFrame(parent) |
527 | { | 546 | { |
528 | setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); | 547 | setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); |
529 | } | 548 | } |
530 | 549 | ||
531 | BorderEditor::~BorderEditor() | 550 | BorderEditor::~BorderEditor() |
532 | { | 551 | {} |
533 | } | ||
534 | 552 | ||
535 | void BorderEditor::drawContents(QPainter *p) | 553 | void BorderEditor::drawContents(QPainter *p) |
536 | { | 554 | { |
537 | QFrame::drawContents(p); | 555 | QFrame::drawContents(p); |
538 | 556 | ||
539 | int x=contentsRect().x(), y=contentsRect().y(), width=contentsRect().width()/3, height=contentsRect().height()/3; | 557 | int x=contentsRect().x(), y=contentsRect().y(), width=contentsRect().width()/3, height=contentsRect().height()/3; |
540 | int lineFirstX=x+width/6, lineFirstY=y+height/6, lineLastX=contentsRect().right()-width/6, lineLastY=contentsRect().bottom()-height/6; | 558 | int lineFirstX=x+width/6, lineFirstY=y+height/6, lineLastX=contentsRect().right()-width/6, lineLastY=contentsRect().bottom()-height/6; |
541 | 559 | ||
542 | p->fillRect(contentsRect(), Qt::white); | 560 | p->fillRect(contentsRect(), Qt::white); |
543 | 561 | ||
544 | p->fillRect(x+width/3, y+height/3, width, height, Qt::gray); | 562 | p->fillRect(x+width/3, y+height/3, width, height, Qt::gray); |
545 | p->fillRect(x+(5*width/3), y+height/3, width, height, Qt::gray); | 563 | p->fillRect(x+(5*width/3), y+height/3, width, height, Qt::gray); |
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,39 +1,61 @@ | |||
1 | /*************************************************************************** | 1 | /* |
2 | * * | 2 | =. This file is part of the Opie Project |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> |
4 | * it under the terms of the GNU General Public License as published by * | 4 | .>+-= |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | _;:, .> :=|. This program is free software; you can |
6 | * (at your option) any later version. * | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | * * | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | ***************************************************************************/ | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This program is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
9 | 28 | ||
10 | /* | 29 | /* |
11 | * Opie Sheet (formerly Sheet/Qt) | 30 | * Opie Sheet (formerly Sheet/Qt) |
12 | * by Serdar Ozler <sozler@sitebest.com> | 31 | * by Serdar Ozler <sozler@sitebest.com> |
13 | */ | 32 | */ |
14 | 33 | ||
15 | #ifndef CELLFORMAT_H | 34 | #ifndef CELLFORMAT_H |
16 | #define CELLFORMAT_H | 35 | #define CELLFORMAT_H |
17 | 36 | ||
37 | #include "sheet.h" | ||
38 | |||
39 | /* OPIE */ | ||
18 | #include <qpe/fontdatabase.h> | 40 | #include <qpe/fontdatabase.h> |
41 | |||
42 | /* QT */ | ||
19 | #include <qdialog.h> | 43 | #include <qdialog.h> |
20 | #include <qtabwidget.h> | 44 | #include <qtabwidget.h> |
21 | #include <qlayout.h> | 45 | #include <qlayout.h> |
22 | #include <qcombobox.h> | 46 | #include <qcombobox.h> |
23 | #include <qcheckbox.h> | 47 | #include <qcheckbox.h> |
24 | #include <qpushbutton.h> | 48 | #include <qpushbutton.h> |
25 | 49 | ||
26 | #include "sheet.h" | ||
27 | |||
28 | class BorderEditor: public QFrame | 50 | class BorderEditor: public QFrame |
29 | { | 51 | { |
30 | Q_OBJECT | 52 | Q_OBJECT |
31 | 53 | ||
32 | // QT objects | 54 | // QT objects |
33 | QPen penTop, penBottom, penLeft, penRight, penHorz, penVert; | 55 | QPen penTop, penBottom, penLeft, penRight, penHorz, penVert; |
34 | 56 | ||
35 | // Private functions | 57 | // Private functions |
36 | void drawContents(QPainter *p); | 58 | void drawContents(QPainter *p); |
37 | 59 | ||
38 | // Reimplemented QFrame functions | 60 | // Reimplemented QFrame functions |
39 | void mouseReleaseEvent(QMouseEvent *e); | 61 | void mouseReleaseEvent(QMouseEvent *e); |
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,29 +1,50 @@ | |||
1 | /*************************************************************************** | 1 | /* |
2 | * * | 2 | =. This file is part of the Opie Project |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> |
4 | * it under the terms of the GNU General Public License as published by * | 4 | .>+-= |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | _;:, .> :=|. This program is free software; you can |
6 | * (at your option) any later version. * | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | * * | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | ***************************************************************************/ | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This program is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
9 | 28 | ||
10 | /* | 29 | /* |
11 | * Opie Sheet (formerly Sheet/Qt) | 30 | * Opie Sheet (formerly Sheet/Qt) |
12 | * by Serdar Ozler <sozler@sitebest.com> | 31 | * by Serdar Ozler <sozler@sitebest.com> |
13 | */ | 32 | */ |
14 | 33 | ||
34 | #include "finddlg.h" | ||
35 | |||
36 | /* QT */ | ||
15 | #include <qlabel.h> | 37 | #include <qlabel.h> |
16 | #include <qradiobutton.h> | 38 | #include <qradiobutton.h> |
17 | #include "finddlg.h" | ||
18 | 39 | ||
19 | FindDialog::FindDialog(QWidget *parent) | 40 | FindDialog::FindDialog(QWidget *parent) |
20 | :QDialog(parent, 0, TRUE) | 41 | :QDialog(parent, 0, TRUE) |
21 | { | 42 | { |
22 | // Main widget | 43 | // Main widget |
23 | tabs=new QTabWidget(this); | 44 | tabs=new QTabWidget(this); |
24 | widgetFind=new QWidget(tabs); | 45 | widgetFind=new QWidget(tabs); |
25 | widgetOptions=new QWidget(tabs); | 46 | widgetOptions=new QWidget(tabs); |
26 | tabs->addTab(widgetFind, tr("&Find && Replace")); | 47 | tabs->addTab(widgetFind, tr("&Find && Replace")); |
27 | tabs->addTab(widgetOptions, tr("&Options")); | 48 | tabs->addTab(widgetOptions, tr("&Options")); |
28 | 49 | ||
29 | // Find tab | 50 | // Find tab |
@@ -55,26 +76,25 @@ FindDialog::FindDialog(QWidget *parent) | |||
55 | checkSelection->setGeometry(10, 40, 215, 20); | 76 | checkSelection->setGeometry(10, 40, 215, 20); |
56 | checkEntire=new QCheckBox(tr("&Entire cell"), widgetOptions); | 77 | checkEntire=new QCheckBox(tr("&Entire cell"), widgetOptions); |
57 | checkEntire->setGeometry(10, 70, 215, 20); | 78 | checkEntire->setGeometry(10, 70, 215, 20); |
58 | 79 | ||
59 | // Main widget | 80 | // Main widget |
60 | box=new QVBoxLayout(this); | 81 | box=new QVBoxLayout(this); |
61 | box->addWidget(tabs); | 82 | box->addWidget(tabs); |
62 | 83 | ||
63 | setCaption(tr("Find & Replace")); | 84 | setCaption(tr("Find & Replace")); |
64 | } | 85 | } |
65 | 86 | ||
66 | FindDialog::~FindDialog() | 87 | FindDialog::~FindDialog() |
67 | { | 88 | {} |
68 | } | ||
69 | 89 | ||
70 | void FindDialog::typeChanged(int id) | 90 | void FindDialog::typeChanged(int id) |
71 | { | 91 | { |
72 | editReplace->setEnabled(id>0); | 92 | editReplace->setEnabled(id>0); |
73 | } | 93 | } |
74 | 94 | ||
75 | int FindDialog::exec(Sheet *s) | 95 | int FindDialog::exec(Sheet *s) |
76 | { | 96 | { |
77 | if (QDialog::exec()==QDialog::Accepted) | 97 | if (QDialog::exec()==QDialog::Accepted) |
78 | { | 98 | { |
79 | int id=groupType->id(groupType->selected()); | 99 | int id=groupType->id(groupType->selected()); |
80 | s->dataFindReplace(editFind->text(), editReplace->text(), checkCase->isChecked(), !checkSelection->isChecked(), checkEntire->isChecked(), id>0, id>1); | 100 | s->dataFindReplace(editFind->text(), editReplace->text(), checkCase->isChecked(), !checkSelection->isChecked(), checkEntire->isChecked(), id>0, id>1); |
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,37 +1,58 @@ | |||
1 | /*************************************************************************** | 1 | /* |
2 | * * | 2 | =. This file is part of the Opie Project |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> |
4 | * it under the terms of the GNU General Public License as published by * | 4 | .>+-= |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | _;:, .> :=|. This program is free software; you can |
6 | * (at your option) any later version. * | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | * * | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | ***************************************************************************/ | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This program is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
9 | 28 | ||
10 | /* | 29 | /* |
11 | * Opie Sheet (formerly Sheet/Qt) | 30 | * Opie Sheet (formerly Sheet/Qt) |
12 | * by Serdar Ozler <sozler@sitebest.com> | 31 | * by Serdar Ozler <sozler@sitebest.com> |
13 | */ | 32 | */ |
14 | 33 | ||
15 | #ifndef FINDDLG_H | 34 | #ifndef FINDDLG_H |
16 | #define FINDDLG_H | 35 | #define FINDDLG_H |
17 | 36 | ||
37 | #include "sheet.h" | ||
38 | |||
39 | /* QT */ | ||
18 | #include <qdialog.h> | 40 | #include <qdialog.h> |
19 | #include <qtabwidget.h> | 41 | #include <qtabwidget.h> |
20 | #include <qlayout.h> | 42 | #include <qlayout.h> |
21 | #include <qlineedit.h> | 43 | #include <qlineedit.h> |
22 | #include <qcheckbox.h> | 44 | #include <qcheckbox.h> |
23 | #include <qpushbutton.h> | 45 | #include <qpushbutton.h> |
24 | #include <qvbuttongroup.h> | 46 | #include <qvbuttongroup.h> |
25 | #include "sheet.h" | ||
26 | 47 | ||
27 | class FindDialog: public QDialog | 48 | class FindDialog: public QDialog |
28 | { | 49 | { |
29 | Q_OBJECT | 50 | Q_OBJECT |
30 | 51 | ||
31 | // QT objects | 52 | // QT objects |
32 | QBoxLayout *box; | 53 | QBoxLayout *box; |
33 | QTabWidget *tabs; | 54 | QTabWidget *tabs; |
34 | QWidget *widgetFind, *widgetOptions; | 55 | QWidget *widgetFind, *widgetOptions; |
35 | QCheckBox *checkCase, *checkSelection, *checkEntire; | 56 | QCheckBox *checkCase, *checkSelection, *checkEntire; |
36 | QLineEdit *editFind, *editReplace; | 57 | QLineEdit *editFind, *editReplace; |
37 | QVButtonGroup *groupType; | 58 | QVButtonGroup *groupType; |
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,20 +1,39 @@ | |||
1 | /*************************************************************************** | 1 | /* |
2 | * * | 2 | =. This file is part of the Opie Project |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> |
4 | * it under the terms of the GNU General Public License as published by * | 4 | .>+-= |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | _;:, .> :=|. This program is free software; you can |
6 | * (at your option) any later version. * | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | * * | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | ***************************************************************************/ | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This program is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
9 | 28 | ||
10 | /* | 29 | /* |
11 | * Opie Sheet (formerly Sheet/Qt) | 30 | * Opie Sheet (formerly Sheet/Qt) |
12 | * by Serdar Ozler <sozler@sitebest.com> | 31 | * by Serdar Ozler <sozler@sitebest.com> |
13 | */ | 32 | */ |
14 | 33 | ||
15 | 34 | ||
16 | #include "mainwindow.h" | 35 | #include "mainwindow.h" |
17 | 36 | ||
18 | #include <opie2/oapplicationfactory.h> | 37 | #include <opie2/oapplicationfactory.h> |
19 | 38 | ||
20 | using namespace Opie::Core; | 39 | using namespace Opie::Core; |
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,61 +1,82 @@ | |||
1 | /*************************************************************************** | 1 | /* |
2 | * * | 2 | =. This file is part of the Opie Project |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> |
4 | * it under the terms of the GNU General Public License as published by * | 4 | .>+-= |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | _;:, .> :=|. This program is free software; you can |
6 | * (at your option) any later version. * | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | * * | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | ***************************************************************************/ | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This program is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
9 | 28 | ||
10 | /* | 29 | /* |
11 | * Opie Sheet (formerly Sheet/Qt) | 30 | * Opie Sheet (formerly Sheet/Qt) |
12 | * by Serdar Ozler <sozler@sitebest.com> | 31 | * by Serdar Ozler <sozler@sitebest.com> |
13 | */ | 32 | */ |
14 | 33 | ||
15 | #include "mainwindow.h" | 34 | #include "mainwindow.h" |
16 | 35 | ||
36 | /* OPIE */ | ||
17 | #include <qpe/resource.h> | 37 | #include <qpe/resource.h> |
18 | #include <qpe/qpeapplication.h> | 38 | #include <qpe/qpeapplication.h> |
19 | 39 | ||
40 | /* QT */ | ||
20 | #include <qmessagebox.h> | 41 | #include <qmessagebox.h> |
21 | #include <qradiobutton.h> | 42 | #include <qradiobutton.h> |
22 | 43 | ||
44 | /* STD */ | ||
23 | #include "cellformat.h" | 45 | #include "cellformat.h" |
24 | #include "numberdlg.h" | 46 | #include "numberdlg.h" |
25 | #include "textdlg.h" | 47 | #include "textdlg.h" |
26 | #include "sortdlg.h" | 48 | #include "sortdlg.h" |
27 | #include "finddlg.h" | 49 | #include "finddlg.h" |
28 | 50 | ||
29 | #define DEFAULT_NUM_ROWS 300 | 51 | #define DEFAULT_NUM_ROWS 300 |
30 | #define DEFAULT_NUM_COLS (26*3) | 52 | #define DEFAULT_NUM_COLS (26*3) |
31 | #define DEFAULT_NUM_SHEETS 3 | 53 | #define DEFAULT_NUM_SHEETS 3 |
32 | 54 | ||
33 | MainWindow::MainWindow(QWidget *parent, const char* n, WFlags fl) | 55 | MainWindow::MainWindow(QWidget *parent, const char* n, WFlags fl) |
34 | :QMainWindow(parent, n, fl) | 56 | :QMainWindow(parent, n, fl) |
35 | { | 57 | { |
36 | // initialize variables | 58 | // initialize variables |
37 | documentModified=FALSE; | 59 | documentModified=FALSE; |
38 | 60 | ||
39 | // construct objects | 61 | // construct objects |
40 | currentDoc=0; | 62 | currentDoc=0; |
41 | fileSelector=new FileSelector("application/sheet-qt", this, QString::null); | 63 | fileSelector=new FileSelector("application/opie-sheet", this, QString::null); |
42 | ExcelSelector=new FileSelector("application/excel",this,QString::null,FALSE); | 64 | ExcelSelector=new FileSelector("application/excel",this,QString::null,FALSE); |
43 | connect(fileSelector, SIGNAL(closeMe()), this, SLOT(selectorHide())); | 65 | connect(fileSelector, SIGNAL(closeMe()), this, SLOT(selectorHide())); |
44 | connect(fileSelector, SIGNAL(newSelected(const DocLnk&)), this, SLOT(selectorFileNew(const DocLnk&))); | 66 | connect(fileSelector, SIGNAL(newSelected(const DocLnk&)), this, SLOT(selectorFileNew(const DocLnk&))); |
45 | connect(fileSelector, SIGNAL(fileSelected(const DocLnk&)), this, SLOT(selectorFileOpen(const DocLnk&))); | 67 | connect(fileSelector, SIGNAL(fileSelected(const DocLnk&)), this, SLOT(selectorFileOpen(const DocLnk&))); |
46 | connect(ExcelSelector,SIGNAL(fileSelected(const DocLnk&)),this,SLOT(slotImportExcel(const DocLnk&))); | 68 | connect(ExcelSelector,SIGNAL(fileSelected(const DocLnk&)),this,SLOT(slotImportExcel(const DocLnk&))); |
47 | connect(ExcelSelector,SIGNAL(closeMe()), this, SLOT(ExcelSelectorHide())); | 69 | connect(ExcelSelector,SIGNAL(closeMe()), this, SLOT(ExcelSelectorHide())); |
48 | 70 | ||
49 | |||
50 | listSheets.setAutoDelete(TRUE); | 71 | listSheets.setAutoDelete(TRUE); |
51 | 72 | ||
52 | initActions(); | 73 | initActions(); |
53 | initMenu(); | 74 | initMenu(); |
54 | initEditToolbar(); | 75 | initEditToolbar(); |
55 | initFunctionsToolbar(); | 76 | initFunctionsToolbar(); |
56 | initStandardToolbar(); | 77 | initStandardToolbar(); |
57 | initSheet(); | 78 | initSheet(); |
58 | 79 | ||
59 | // set window title | 80 | // set window title |
60 | setCaption(tr("Opie Sheet")); | 81 | setCaption(tr("Opie Sheet")); |
61 | 82 | ||
@@ -81,25 +102,25 @@ void MainWindow::documentSave(DocLnk *lnkDoc) | |||
81 | return; | 102 | return; |
82 | } | 103 | } |
83 | sheet->copySheetData(¤tSheet->data); | 104 | sheet->copySheetData(¤tSheet->data); |
84 | stream.writeRawBytes("SQT100", 6); | 105 | stream.writeRawBytes("SQT100", 6); |
85 | stream << (Q_UINT32)listSheets.count(); | 106 | stream << (Q_UINT32)listSheets.count(); |
86 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) | 107 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) |
87 | { | 108 | { |
88 | stream << tempSheet->name << (Q_UINT32)tempSheet->data.count(); | 109 | stream << tempSheet->name << (Q_UINT32)tempSheet->data.count(); |
89 | for (typeCellData *tempCell=tempSheet->data.first(); tempCell; tempCell=tempSheet->data.next()) | 110 | for (typeCellData *tempCell=tempSheet->data.first(); tempCell; tempCell=tempSheet->data.next()) |
90 | 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; | 111 | 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; |
91 | } | 112 | } |
92 | 113 | ||
93 | lnkDoc->setType("application/sheet-qt"); | 114 | lnkDoc->setType("application/opie-sheet"); |
94 | if (!fm.saveFile(*lnkDoc, streamBuffer)) | 115 | if (!fm.saveFile(*lnkDoc, streamBuffer)) |
95 | { | 116 | { |
96 | QMessageBox::critical(this, tr("Error"), tr("File cannot be saved!")); | 117 | QMessageBox::critical(this, tr("Error"), tr("File cannot be saved!")); |
97 | return; | 118 | return; |
98 | } | 119 | } |
99 | documentModified=FALSE; | 120 | documentModified=FALSE; |
100 | } | 121 | } |
101 | 122 | ||
102 | void MainWindow::documentOpen(const DocLnk &lnkDoc) | 123 | void MainWindow::documentOpen(const DocLnk &lnkDoc) |
103 | { | 124 | { |
104 | FileManager fm; | 125 | FileManager fm; |
105 | QByteArray streamBuffer; | 126 | QByteArray streamBuffer; |
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,41 +1,64 @@ | |||
1 | /*************************************************************************** | 1 | /* |
2 | * * | 2 | =. This file is part of the Opie Project |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> |
4 | * it under the terms of the GNU General Public License as published by * | 4 | .>+-= |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | _;:, .> :=|. This program is free software; you can |
6 | * (at your option) any later version. * | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | * * | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | ***************************************************************************/ | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This program is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
9 | 28 | ||
10 | /* | 29 | /* |
11 | * Opie Sheet (formerly Sheet/Qt) | 30 | * Opie Sheet (formerly Sheet/Qt) |
12 | * by Serdar Ozler <sozler@sitebest.com> | 31 | * by Serdar Ozler <sozler@sitebest.com> |
13 | */ | 32 | */ |
14 | 33 | ||
15 | #ifndef MAINWINDOW_H | 34 | #ifndef MAINWINDOW_H |
16 | #define MAINWINDOW_H | 35 | #define MAINWINDOW_H |
17 | 36 | ||
37 | #include "Excel.h" | ||
38 | #include "sheet.h" | ||
39 | |||
40 | /* OPIE */ | ||
18 | #include <qpe/applnk.h> | 41 | #include <qpe/applnk.h> |
19 | #include <qpe/fileselector.h> | 42 | #include <qpe/fileselector.h> |
43 | |||
44 | /* QT */ | ||
20 | #include <qmenubar.h> | 45 | #include <qmenubar.h> |
21 | #include <qtoolbar.h> | 46 | #include <qtoolbar.h> |
22 | #include <qmainwindow.h> | 47 | #include <qmainwindow.h> |
23 | #include <qaction.h> | 48 | #include <qaction.h> |
24 | #include <qlineedit.h> | 49 | #include <qlineedit.h> |
25 | #include <qbutton.h> | 50 | #include <qbutton.h> |
26 | #include <qcombobox.h> | 51 | #include <qcombobox.h> |
27 | #include <qtoolbutton.h> | 52 | #include <qtoolbutton.h> |
28 | #include "Excel.h" | ||
29 | #include "sheet.h" | ||
30 | 53 | ||
31 | typedef struct typeSheet | 54 | typedef struct typeSheet |
32 | { | 55 | { |
33 | QString name; | 56 | QString name; |
34 | QList<typeCellData> data; | 57 | QList<typeCellData> data; |
35 | }; | 58 | }; |
36 | 59 | ||
37 | class MainWindow: public QMainWindow | 60 | class MainWindow: public QMainWindow |
38 | { | 61 | { |
39 | Q_OBJECT | 62 | Q_OBJECT |
40 | 63 | ||
41 | // QPE objects | 64 | // QPE objects |
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,44 +1,62 @@ | |||
1 | /*************************************************************************** | 1 | /* |
2 | * * | 2 | =. This file is part of the Opie Project |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> |
4 | * it under the terms of the GNU General Public License as published by * | 4 | .>+-= |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | _;:, .> :=|. This program is free software; you can |
6 | * (at your option) any later version. * | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | * * | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | ***************************************************************************/ | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This program is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
9 | 28 | ||
10 | /* | 29 | /* |
11 | * Opie Sheet (formerly Sheet/Qt) | 30 | * Opie Sheet (formerly Sheet/Qt) |
12 | * by Serdar Ozler <sozler@sitebest.com> | 31 | * by Serdar Ozler <sozler@sitebest.com> |
13 | */ | 32 | */ |
14 | 33 | ||
15 | #include "numberdlg.h" | 34 | #include "numberdlg.h" |
16 | 35 | ||
17 | NumberDialog::NumberDialog(QWidget *parent) | 36 | NumberDialog::NumberDialog(QWidget *parent) |
18 | :QDialog(parent, 0, TRUE) | 37 | :QDialog(parent, 0, TRUE) |
19 | { | 38 | { |
20 | edit=new QSpinBox(this); | 39 | edit=new QSpinBox(this); |
21 | edit->setGeometry(120, 10, 70, 25); | 40 | edit->setGeometry(120, 10, 70, 25); |
22 | 41 | ||
23 | label=new QLabel(this); | 42 | label=new QLabel(this); |
24 | label->setGeometry(10, 10, 100, 25); | 43 | label->setGeometry(10, 10, 100, 25); |
25 | label->setBuddy(edit); | 44 | label->setBuddy(edit); |
26 | 45 | ||
27 | resize(200, 45); | 46 | resize(200, 45); |
28 | } | 47 | } |
29 | 48 | ||
30 | NumberDialog::~NumberDialog() | 49 | NumberDialog::~NumberDialog() |
31 | { | 50 | {} |
32 | } | ||
33 | 51 | ||
34 | int NumberDialog::exec(const QString &caption, const QString &text, | 52 | int NumberDialog::exec(const QString &caption, const QString &text, |
35 | int value, int min, int max, int step) | 53 | int value, int min, int max, int step) |
36 | { | 54 | { |
37 | setCaption(caption); | 55 | setCaption(caption); |
38 | label->setText(text); | 56 | label->setText(text); |
39 | edit->setValue(value); | 57 | edit->setValue(value); |
40 | edit->setMinValue(min); | 58 | edit->setMinValue(min); |
41 | edit->setMaxValue(max); | 59 | edit->setMaxValue(max); |
42 | edit->setLineStep(step); | 60 | edit->setLineStep(step); |
43 | 61 | ||
44 | return QDialog::exec(); | 62 | return QDialog::exec(); |
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,29 +1,49 @@ | |||
1 | /*************************************************************************** | 1 | /* |
2 | * * | 2 | =. This file is part of the Opie Project |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> |
4 | * it under the terms of the GNU General Public License as published by * | 4 | .>+-= |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | _;:, .> :=|. This program is free software; you can |
6 | * (at your option) any later version. * | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | * * | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | ***************************************************************************/ | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This program is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
9 | 28 | ||
10 | /* | 29 | /* |
11 | * Opie Sheet (formerly Sheet/Qt) | 30 | * Opie Sheet (formerly Sheet/Qt) |
12 | * by Serdar Ozler <sozler@sitebest.com> | 31 | * by Serdar Ozler <sozler@sitebest.com> |
13 | */ | 32 | */ |
14 | 33 | ||
15 | #ifndef NUMBERDLG_H | 34 | #ifndef NUMBERDLG_H |
16 | #define NUMBERDLG_H | 35 | #define NUMBERDLG_H |
17 | 36 | ||
37 | /* QT */ | ||
18 | #include <qdialog.h> | 38 | #include <qdialog.h> |
19 | #include <qlabel.h> | 39 | #include <qlabel.h> |
20 | #include <qspinbox.h> | 40 | #include <qspinbox.h> |
21 | 41 | ||
22 | class NumberDialog: public QDialog | 42 | class NumberDialog: public QDialog |
23 | { | 43 | { |
24 | Q_OBJECT | 44 | Q_OBJECT |
25 | 45 | ||
26 | // QT objects | 46 | // QT objects |
27 | QLabel *label; | 47 | QLabel *label; |
28 | QSpinBox *edit; | 48 | QSpinBox *edit; |
29 | 49 | ||
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 @@ | |||
1 | CONFIG = qt warn_on quick-app | 1 | CONFIG = qt warn_on quick-app |
2 | HEADERS = mainwindow.h sheet.h cellformat.h finddlg.h numberdlg.h sortdlg.h textdlg.h Excel.h | 2 | HEADERS = mainwindow.h \ |
3 | SOURCES = main.cpp mainwindow.cpp sheet.cpp cellformat.cpp finddlg.cpp numberdlg.cpp sortdlg.cpp textdlg.cpp Excel.cpp | 3 | sheet.h \ |
4 | cellformat.h \ | ||
5 | finddlg.h \ | ||
6 | numberdlg.h \ | ||
7 | sortdlg.h \ | ||
8 | textdlg.h \ | ||
9 | Excel.h | ||
10 | SOURCES = main.cpp \ | ||
11 | mainwindow.cpp \ | ||
12 | sheet.cpp \ | ||
13 | cellformat.cpp \ | ||
14 | finddlg.cpp \ | ||
15 | numberdlg.cpp \ | ||
16 | sortdlg.cpp \ | ||
17 | textdlg.cpp \ | ||
18 | Excel.cpp | ||
4 | INCLUDEPATH += $(OPIEDIR)/include | 19 | INCLUDEPATH += $(OPIEDIR)/include |
5 | DEPENDPATH += $(OPIEDIR)/include | 20 | DEPENDPATH += $(OPIEDIR)/include |
6 | LIBS += -lqpe -lopiecore2 | 21 | LIBS += -lqpe -lopiecore2 |
7 | TARGET = opie-sheet | 22 | TARGET = opie-sheet |
8 | 23 | ||
9 | include ( $(OPIEDIR)/include.pro ) | 24 | 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,29 +1,51 @@ | |||
1 | /*************************************************************************** | 1 | /* |
2 | * * | 2 | =. This file is part of the Opie Project |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> |
4 | * it under the terms of the GNU General Public License as published by * | 4 | .>+-= |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | _;:, .> :=|. This program is free software; you can |
6 | * (at your option) any later version. * | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | * * | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | ***************************************************************************/ | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This program is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
9 | 28 | ||
10 | /* | 29 | /* |
11 | * Opie Sheet (formerly Sheet/Qt) | 30 | * Opie Sheet (formerly Sheet/Qt) |
12 | * by Serdar Ozler <sozler@sitebest.com> | 31 | * by Serdar Ozler <sozler@sitebest.com> |
13 | */ | 32 | */ |
14 | 33 | ||
15 | #include "sheet.h" | 34 | #include "sheet.h" |
16 | 35 | ||
36 | /* QT */ | ||
17 | #include <qmessagebox.h> | 37 | #include <qmessagebox.h> |
38 | |||
39 | /* STD */ | ||
18 | #include <math.h> | 40 | #include <math.h> |
19 | #include <stdlib.h> | 41 | #include <stdlib.h> |
20 | #include <stdio.h> | 42 | #include <stdio.h> |
21 | #include <time.h> | 43 | #include <time.h> |
22 | 44 | ||
23 | #define DEFAULT_COL_WIDTH 50 | 45 | #define DEFAULT_COL_WIDTH 50 |
24 | 46 | ||
25 | Sheet::Sheet(int numRows, int numCols, QWidget *parent) | 47 | Sheet::Sheet(int numRows, int numCols, QWidget *parent) |
26 | :QTable(numRows, numCols, parent) | 48 | :QTable(numRows, numCols, parent) |
27 | { | 49 | { |
28 | defaultBorders.right=defaultBorders.bottom=QPen(Qt::gray, 1, Qt::SolidLine); | 50 | defaultBorders.right=defaultBorders.bottom=QPen(Qt::gray, 1, Qt::SolidLine); |
29 | defaultCellData.data=""; | 51 | defaultCellData.data=""; |
@@ -39,44 +61,44 @@ Sheet::Sheet(int numRows, int numCols, QWidget *parent) | |||
39 | 61 | ||
40 | sheetData.setAutoDelete(TRUE); | 62 | sheetData.setAutoDelete(TRUE); |
41 | clipboardData.setAutoDelete(TRUE); | 63 | clipboardData.setAutoDelete(TRUE); |
42 | for (int i=0; i<numCols; ++i) | 64 | for (int i=0; i<numCols; ++i) |
43 | horizontalHeader()->setLabel(i, getHeaderString(i+1), DEFAULT_COL_WIDTH); | 65 | horizontalHeader()->setLabel(i, getHeaderString(i+1), DEFAULT_COL_WIDTH); |
44 | 66 | ||
45 | 67 | ||
46 | connect(this, SIGNAL(currentChanged(int,int)), this, SLOT(slotCellSelected(int,int))); | 68 | connect(this, SIGNAL(currentChanged(int,int)), this, SLOT(slotCellSelected(int,int))); |
47 | connect(this, SIGNAL(valueChanged(int,int)), this, SLOT(slotCellChanged(int,int))); | 69 | connect(this, SIGNAL(valueChanged(int,int)), this, SLOT(slotCellChanged(int,int))); |
48 | } | 70 | } |
49 | 71 | ||
50 | Sheet::~Sheet() | 72 | Sheet::~Sheet() |
51 | { | 73 | {} |
52 | } | ||
53 | 74 | ||
54 | typeCellData *Sheet::findCellData(int row, int col) | 75 | typeCellData *Sheet::findCellData(int row, int col) |
55 | { | 76 | { |
56 | typeCellData *tempCellData; | 77 | typeCellData *tempCellData; |
57 | for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) | 78 | for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) |
58 | { | 79 | { |
59 | if (tempCellData->row==row && tempCellData->col==col) return tempCellData; | 80 | if (tempCellData->row==row && tempCellData->col==col) return tempCellData; |
60 | } | 81 | } |
61 | return NULL; | 82 | return NULL; |
62 | } | 83 | } |
63 | 84 | ||
64 | void Sheet::slotCellSelected(int row, int col) | 85 | void Sheet::slotCellSelected(int row, int col) |
65 | { | 86 | { |
66 | typeCellData *cellData=findCellData(row, col); | 87 | typeCellData *cellData=findCellData(row, col); |
67 | if (cellData) | 88 | if (cellData) |
68 | { | 89 | { |
69 | emit currentDataChanged(cellData->data); | 90 | emit currentDataChanged(cellData->data); |
70 | }else | 91 | } |
92 | else | ||
71 | emit currentDataChanged(""); | 93 | emit currentDataChanged(""); |
72 | } | 94 | } |
73 | 95 | ||
74 | typeCellData *Sheet::createCellData(int row, int col) | 96 | typeCellData *Sheet::createCellData(int row, int col) |
75 | { | 97 | { |
76 | if (row<0 || col<0) return NULL; | 98 | if (row<0 || col<0) return NULL; |
77 | typeCellData *cellData=new typeCellData; | 99 | typeCellData *cellData=new typeCellData; |
78 | cellData->row=row; | 100 | cellData->row=row; |
79 | cellData->col=col; | 101 | cellData->col=col; |
80 | cellData->data=defaultCellData.data; | 102 | cellData->data=defaultCellData.data; |
81 | cellData->borders=defaultCellData.borders; | 103 | cellData->borders=defaultCellData.borders; |
82 | cellData->alignment=defaultCellData.alignment; | 104 | cellData->alignment=defaultCellData.alignment; |
@@ -219,42 +241,44 @@ QString Sheet::calculateVariable(const QString &variable) | |||
219 | } | 241 | } |
220 | 242 | ||
221 | double Sheet::BesselI0(double x) | 243 | double Sheet::BesselI0(double x) |
222 | { | 244 | { |
223 | //Returns the modi ed Bessel function I0(x) for any real x. | 245 | //Returns the modi ed Bessel function I0(x) for any real x. |
224 | double ax,ans; | 246 | double ax,ans; |
225 | double y; | 247 | double y; |
226 | if ((ax=fabs(x)) < 3.75) | 248 | if ((ax=fabs(x)) < 3.75) |
227 | { | 249 | { |
228 | y=x/3.75; | 250 | y=x/3.75; |
229 | y*=y; | 251 | y*=y; |
230 | ans=1.0+y*(3.5156229+y*(3.0899424+y*(1.2067492 +y*(0.2659732+y*(0.360768e-1+y*0.45813e-2))))); | 252 | ans=1.0+y*(3.5156229+y*(3.0899424+y*(1.2067492 +y*(0.2659732+y*(0.360768e-1+y*0.45813e-2))))); |
231 | }else | 253 | } |
254 | else | ||
232 | { | 255 | { |
233 | y=3.75/ax; | 256 | y=3.75/ax; |
234 | 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)))))))); | 257 | 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)))))))); |
235 | } | 258 | } |
236 | return ans; | 259 | return ans; |
237 | }; | 260 | }; |
238 | 261 | ||
239 | double Sheet::BesselI1(double x) | 262 | double Sheet::BesselI1(double x) |
240 | { | 263 | { |
241 | double ax,ans; | 264 | double ax,ans; |
242 | double y; | 265 | double y; |
243 | if ((ax=fabs(x)) < 3.75) | 266 | if ((ax=fabs(x)) < 3.75) |
244 | { | 267 | { |
245 | y=x/3.75; | 268 | y=x/3.75; |
246 | y*=y; | 269 | y*=y; |
247 | 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)))))); | 270 | 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)))))); |
248 | } else | 271 | } |
272 | else | ||
249 | { | 273 | { |
250 | y=3.75/ax; | 274 | y=3.75/ax; |
251 | 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)))); | 275 | 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)))); |
252 | ans *= (exp(ax)/sqrt(ax)); | 276 | ans *= (exp(ax)/sqrt(ax)); |
253 | } | 277 | } |
254 | return x < 0.0 ? -ans : ans; | 278 | return x < 0.0 ? -ans : ans; |
255 | }; | 279 | }; |
256 | 280 | ||
257 | double Sheet::BesselI(int n, double x) | 281 | double Sheet::BesselI(int n, double x) |
258 | { | 282 | { |
259 | double ACC=40.0; | 283 | double ACC=40.0; |
260 | double BIGNO=1.0e10; | 284 | double BIGNO=1.0e10; |
@@ -283,40 +307,42 @@ double Sheet::BesselI(int n, double x) | |||
283 | ans *= BesselI0(x)/bi; | 307 | ans *= BesselI0(x)/bi; |
284 | return x < 0.0 && (n & 1) ? -ans : ans; | 308 | return x < 0.0 && (n & 1) ? -ans : ans; |
285 | } | 309 | } |
286 | }; | 310 | }; |
287 | 311 | ||
288 | double Sheet::BesselK0(double x) | 312 | double Sheet::BesselK0(double x) |
289 | { | 313 | { |
290 | double y,ans; | 314 | double y,ans; |
291 | if (x <= 2.0) | 315 | if (x <= 2.0) |
292 | { | 316 | { |
293 | y=x*x/4.0; | 317 | y=x*x/4.0; |
294 | 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)))))); | 318 | 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)))))); |
295 | } else | 319 | } |
320 | else | ||
296 | { | 321 | { |
297 | y=2.0/x; | 322 | y=2.0/x; |
298 | 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)))))); | 323 | 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)))))); |
299 | } | 324 | } |
300 | return ans; | 325 | return ans; |
301 | }; | 326 | }; |
302 | 327 | ||
303 | double Sheet::BesselK1(double x) | 328 | double Sheet::BesselK1(double x) |
304 | { | 329 | { |
305 | double y,ans; | 330 | double y,ans; |
306 | if (x <= 2.0) | 331 | if (x <= 2.0) |
307 | { | 332 | { |
308 | y=x*x/4.0; | 333 | y=x*x/4.0; |
309 | 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))))))); | 334 | 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))))))); |
310 | } else | 335 | } |
336 | else | ||
311 | { | 337 | { |
312 | y=2.0/x; | 338 | y=2.0/x; |
313 | 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))))))); | 339 | 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))))))); |
314 | } | 340 | } |
315 | return ans; | 341 | return ans; |
316 | }; | 342 | }; |
317 | 343 | ||
318 | double Sheet::BesselK(int n, double x) | 344 | double Sheet::BesselK(int n, double x) |
319 | { | 345 | { |
320 | int j; | 346 | int j; |
321 | double bk,bkm,bkp,tox; | 347 | double bk,bkm,bkp,tox; |
322 | if (n < 2) return 0.0; | 348 | if (n < 2) return 0.0; |
@@ -333,90 +359,94 @@ double Sheet::BesselK(int n, double x) | |||
333 | }; | 359 | }; |
334 | 360 | ||
335 | double Sheet::BesselJ0(double x) | 361 | double Sheet::BesselJ0(double x) |
336 | { | 362 | { |
337 | double ax,z; | 363 | double ax,z; |
338 | double xx,y,ans,ans1,ans2; | 364 | double xx,y,ans,ans1,ans2; |
339 | if ((ax=fabs(x)) < 8.0) | 365 | if ((ax=fabs(x)) < 8.0) |
340 | { | 366 | { |
341 | y=x*x; | 367 | y=x*x; |
342 | ans1=57568490574.0+y*(-13362590354.0+y*(651619640.7 +y*(-11214424.18+y*(77392.33017+y*(-184.9052456))))); | 368 | ans1=57568490574.0+y*(-13362590354.0+y*(651619640.7 +y*(-11214424.18+y*(77392.33017+y*(-184.9052456))))); |
343 | ans2=57568490411.0+y*(1029532985.0+y*(9494680.718 +y*(59272.64853+y*(267.8532712+y*1.0)))); | 369 | ans2=57568490411.0+y*(1029532985.0+y*(9494680.718 +y*(59272.64853+y*(267.8532712+y*1.0)))); |
344 | ans=ans1/ans2; | 370 | ans=ans1/ans2; |
345 | } else | 371 | } |
372 | else | ||
346 | { | 373 | { |
347 | z=8.0/ax; | 374 | z=8.0/ax; |
348 | y=z*z; | 375 | y=z*z; |
349 | xx=ax-0.785398164; | 376 | xx=ax-0.785398164; |
350 | ans1=1.0+y*(-0.1098628627e-2+y*(0.2734510407e-4 +y*(-0.2073370639e-5+y*0.2093887211e-6))); | 377 | ans1=1.0+y*(-0.1098628627e-2+y*(0.2734510407e-4 +y*(-0.2073370639e-5+y*0.2093887211e-6))); |
351 | ans2 = -0.1562499995e-1+y*(0.1430488765e-3 +y*(-0.6911147651e-5+y*(0.7621095161e-6 -y*0.934935152e-7))); | 378 | ans2 = -0.1562499995e-1+y*(0.1430488765e-3 +y*(-0.6911147651e-5+y*(0.7621095161e-6 -y*0.934935152e-7))); |
352 | ans=sqrt(0.636619772/ax)*(cos(xx)*ans1-z*sin(xx)*ans2); | 379 | ans=sqrt(0.636619772/ax)*(cos(xx)*ans1-z*sin(xx)*ans2); |
353 | } | 380 | } |
354 | return ans; | 381 | return ans; |
355 | }; | 382 | }; |
356 | 383 | ||
357 | double Sheet::BesselY0(double x) | 384 | double Sheet::BesselY0(double x) |
358 | { | 385 | { |
359 | double z; | 386 | double z; |
360 | double xx,y,ans,ans1,ans2; | 387 | double xx,y,ans,ans1,ans2; |
361 | if (x < 8.0) | 388 | if (x < 8.0) |
362 | { | 389 | { |
363 | y=x*x; | 390 | y=x*x; |
364 | ans1 = -2957821389.0+y*(7062834065.0+y*(-512359803.6 +y*(10879881.29+y*(-86327.92757+y*228.4622733)))); | 391 | ans1 = -2957821389.0+y*(7062834065.0+y*(-512359803.6 +y*(10879881.29+y*(-86327.92757+y*228.4622733)))); |
365 | ans2=40076544269.0+y*(745249964.8+y*(7189466.438 +y*(47447.26470+y*(226.1030244+y*1.0)))); | 392 | ans2=40076544269.0+y*(745249964.8+y*(7189466.438 +y*(47447.26470+y*(226.1030244+y*1.0)))); |
366 | ans=(ans1/ans2)+0.636619772*BesselJ0(x)*log(x); | 393 | ans=(ans1/ans2)+0.636619772*BesselJ0(x)*log(x); |
367 | } else | 394 | } |
395 | else | ||
368 | { | 396 | { |
369 | z=8.0/x; | 397 | z=8.0/x; |
370 | y=z*z; | 398 | y=z*z; |
371 | xx=x-0.785398164; | 399 | xx=x-0.785398164; |
372 | ans1=1.0+y*(-0.1098628627e-2+y*(0.2734510407e-4 +y*(-0.2073370639e-5+y*0.2093887211e-6))); | 400 | ans1=1.0+y*(-0.1098628627e-2+y*(0.2734510407e-4 +y*(-0.2073370639e-5+y*0.2093887211e-6))); |
373 | ans2 = -0.1562499995e-1+y*(0.1430488765e-3 +y*(-0.6911147651e-5+y*(0.7621095161e-6 +y*(-0.934945152e-7)))); | 401 | ans2 = -0.1562499995e-1+y*(0.1430488765e-3 +y*(-0.6911147651e-5+y*(0.7621095161e-6 +y*(-0.934945152e-7)))); |
374 | ans=sqrt(0.636619772/x)*(sin(xx)*ans1+z*cos(xx)*ans2); | 402 | ans=sqrt(0.636619772/x)*(sin(xx)*ans1+z*cos(xx)*ans2); |
375 | } | 403 | } |
376 | return ans; | 404 | return ans; |
377 | }; | 405 | }; |
378 | 406 | ||
379 | double Sheet::BesselJ1(double x) | 407 | double Sheet::BesselJ1(double x) |
380 | { | 408 | { |
381 | double ax,z; | 409 | double ax,z; |
382 | double xx,y,ans,ans1,ans2; | 410 | double xx,y,ans,ans1,ans2; |
383 | if ((ax=fabs(x)) < 8.0) | 411 | if ((ax=fabs(x)) < 8.0) |
384 | { | 412 | { |
385 | y=x*x; | 413 | y=x*x; |
386 | ans1=x*(72362614232.0+y*(-7895059235.0+y*(242396853.1 +y*(-2972611.439+y*(15704.48260+y*(-30.16036606)))))); | 414 | ans1=x*(72362614232.0+y*(-7895059235.0+y*(242396853.1 +y*(-2972611.439+y*(15704.48260+y*(-30.16036606)))))); |
387 | ans2=144725228442.0+y*(2300535178.0+y*(18583304.74 +y*(99447.43394+y*(376.9991397+y*1.0)))); | 415 | ans2=144725228442.0+y*(2300535178.0+y*(18583304.74 +y*(99447.43394+y*(376.9991397+y*1.0)))); |
388 | ans=ans1/ans2; | 416 | ans=ans1/ans2; |
389 | } else | 417 | } |
418 | else | ||
390 | { | 419 | { |
391 | z=8.0/ax; y=z*z; xx=ax-2.356194491; | 420 | z=8.0/ax; y=z*z; xx=ax-2.356194491; |
392 | ans1=1.0+y*(0.183105e-2+y*(-0.3516396496e-4 +y*(0.2457520174e-5+y*(-0.240337019e-6)))); | 421 | ans1=1.0+y*(0.183105e-2+y*(-0.3516396496e-4 +y*(0.2457520174e-5+y*(-0.240337019e-6)))); |
393 | ans2=0.04687499995+y*(-0.2002690873e-3 +y*(0.8449199096e-5+y*(-0.88228987e-6 +y*0.105787412e-6))); | 422 | ans2=0.04687499995+y*(-0.2002690873e-3 +y*(0.8449199096e-5+y*(-0.88228987e-6 +y*0.105787412e-6))); |
394 | ans=sqrt(0.636619772/ax)*(cos(xx)*ans1-z*sin(xx)*ans2); | 423 | ans=sqrt(0.636619772/ax)*(cos(xx)*ans1-z*sin(xx)*ans2); |
395 | if (x < 0.0) ans = -ans; | 424 | if (x < 0.0) ans = -ans; |
396 | } | 425 | } |
397 | return ans; | 426 | return ans; |
398 | }; | 427 | }; |
399 | 428 | ||
400 | double Sheet::BesselY1(double x) | 429 | double Sheet::BesselY1(double x) |
401 | { | 430 | { |
402 | double z; | 431 | double z; |
403 | double xx,y,ans,ans1,ans2; | 432 | double xx,y,ans,ans1,ans2; |
404 | if (x < 8.0) | 433 | if (x < 8.0) |
405 | { | 434 | { |
406 | y=x*x; | 435 | y=x*x; |
407 | ans1=x*(-0.4900604943e13+y*(0.1275274390e13 +y*(-0.5153438139e11+y*(0.7349264551e9 +y*(-0.4237922726e7+y*0.8511937935e4))))); | 436 | ans1=x*(-0.4900604943e13+y*(0.1275274390e13 +y*(-0.5153438139e11+y*(0.7349264551e9 +y*(-0.4237922726e7+y*0.8511937935e4))))); |
408 | ans2=0.2499580570e14+y*(0.4244419664e12 +y*(0.3733650367e10+y*(0.2245904002e8 +y*(0.1020426050e6+y*(0.3549632885e3+y))))); | 437 | ans2=0.2499580570e14+y*(0.4244419664e12 +y*(0.3733650367e10+y*(0.2245904002e8 +y*(0.1020426050e6+y*(0.3549632885e3+y))))); |
409 | ans=(ans1/ans2)+0.636619772*(BesselJ1(x)*log(x)-1.0/x); | 438 | ans=(ans1/ans2)+0.636619772*(BesselJ1(x)*log(x)-1.0/x); |
410 | } else | 439 | } |
440 | else | ||
411 | { | 441 | { |
412 | z=8.0/x; | 442 | z=8.0/x; |
413 | y=z*z; | 443 | y=z*z; |
414 | xx=x-2.356194491; | 444 | xx=x-2.356194491; |
415 | ans1=1.0+y*(0.183105e-2+y*(-0.3516396496e-4 +y*(0.2457520174e-5+y*(-0.240337019e-6)))); | 445 | ans1=1.0+y*(0.183105e-2+y*(-0.3516396496e-4 +y*(0.2457520174e-5+y*(-0.240337019e-6)))); |
416 | ans2=0.04687499995+y*(-0.2002690873e-3 +y*(0.8449199096e-5+y*(-0.88228987e-6 +y*0.105787412e-6))); | 446 | ans2=0.04687499995+y*(-0.2002690873e-3 +y*(0.8449199096e-5+y*(-0.88228987e-6 +y*0.105787412e-6))); |
417 | ans=sqrt(0.636619772/x)*(sin(xx)*ans1+z*cos(xx)*ans2); | 447 | ans=sqrt(0.636619772/x)*(sin(xx)*ans1+z*cos(xx)*ans2); |
418 | } | 448 | } |
419 | return ans; | 449 | return ans; |
420 | }; | 450 | }; |
421 | 451 | ||
422 | double Sheet::BesselY(int n, double x) | 452 | double Sheet::BesselY(int n, double x) |
@@ -449,25 +479,26 @@ double Sheet::BesselJ(int n, double x) | |||
449 | else if (ax > (double) n) | 479 | else if (ax > (double) n) |
450 | { | 480 | { |
451 | tox=2.0/ax; | 481 | tox=2.0/ax; |
452 | bjm=BesselJ0(ax); | 482 | bjm=BesselJ0(ax); |
453 | bj=BesselJ1(ax); | 483 | bj=BesselJ1(ax); |
454 | for (j=1;j<n;j++) | 484 | for (j=1;j<n;j++) |
455 | { | 485 | { |
456 | bjp=j*tox*bj-bjm; | 486 | bjp=j*tox*bj-bjm; |
457 | bjm=bj; | 487 | bjm=bj; |
458 | bj=bjp; | 488 | bj=bjp; |
459 | } | 489 | } |
460 | ans=bj; | 490 | ans=bj; |
461 | } else | 491 | } |
492 | else | ||
462 | { | 493 | { |
463 | tox=2.0/ax; | 494 | tox=2.0/ax; |
464 | m=2*((n+(int) sqrt(ACC*n))/2); | 495 | m=2*((n+(int) sqrt(ACC*n))/2); |
465 | jsum=0; | 496 | jsum=0; |
466 | bjp=ans=sum=0.0; | 497 | bjp=ans=sum=0.0; |
467 | bj=1.0; | 498 | bj=1.0; |
468 | for (j=m;j>0;j--) | 499 | for (j=m;j>0;j--) |
469 | { | 500 | { |
470 | bjm=j*tox*bj-bjp; | 501 | bjm=j*tox*bj-bjp; |
471 | bjp=bj; | 502 | bjp=bj; |
472 | bj=bjm; | 503 | bj=bjm; |
473 | if (fabs(bj) > BIGNO) | 504 | if (fabs(bj) > BIGNO) |
@@ -509,25 +540,26 @@ double Sheet::Factorial(double n) | |||
509 | 540 | ||
510 | double Sheet::GammaP(double a, double x) | 541 | double Sheet::GammaP(double a, double x) |
511 | { | 542 | { |
512 | // returns GammaP(a,x) | 543 | // returns GammaP(a,x) |
513 | //void gcf(float *gammcf, float a, float x, float *gln); | 544 | //void gcf(float *gammcf, float a, float x, float *gln); |
514 | //void gser(float *gamser, float a, float x, float *gln); | 545 | //void gser(float *gamser, float a, float x, float *gln); |
515 | double gamser,gammcf,gln; | 546 | double gamser,gammcf,gln; |
516 | if (x < 0.0 || a <= 0.0) return 0.0;//error | 547 | if (x < 0.0 || a <= 0.0) return 0.0;//error |
517 | if (x < (a+1.0)) | 548 | if (x < (a+1.0)) |
518 | { | 549 | { |
519 | GammaSeries(&gamser,a,x,&gln); | 550 | GammaSeries(&gamser,a,x,&gln); |
520 | return gamser; | 551 | return gamser; |
521 | }else | 552 | } |
553 | else | ||
522 | { | 554 | { |
523 | GammaContinuedFraction(&gammcf,a,x,&gln); | 555 | GammaContinuedFraction(&gammcf,a,x,&gln); |
524 | return 1.0-gammcf; | 556 | return 1.0-gammcf; |
525 | } | 557 | } |
526 | }; | 558 | }; |
527 | 559 | ||
528 | double Sheet::GammaQ(double a,double x) | 560 | double Sheet::GammaQ(double a,double x) |
529 | { | 561 | { |
530 | //returns GammaQ(a,x)=1.0 - GammaP(a,x); | 562 | //returns GammaQ(a,x)=1.0 - GammaP(a,x); |
531 | return (1.0-GammaP(a,x)); | 563 | return (1.0-GammaP(a,x)); |
532 | }; | 564 | }; |
533 | 565 | ||
@@ -535,39 +567,41 @@ double Sheet::GammaQ(double a,double x) | |||
535 | void Sheet::GammaSeries(double *gamser, double a, double x, double *gln) | 567 | void Sheet::GammaSeries(double *gamser, double a, double x, double *gln) |
536 | { | 568 | { |
537 | double EPS=3.0e-7; | 569 | double EPS=3.0e-7; |
538 | int ITMAX=100; | 570 | int ITMAX=100; |
539 | int n; | 571 | int n; |
540 | double sum,del,ap; | 572 | double sum,del,ap; |
541 | *gln=GammaLn(a); | 573 | *gln=GammaLn(a); |
542 | if (x <= 0.0) | 574 | if (x <= 0.0) |
543 | { | 575 | { |
544 | if (x < 0.0) return;//error | 576 | if (x < 0.0) return;//error |
545 | *gamser=0.0; | 577 | *gamser=0.0; |
546 | return; | 578 | return; |
547 | } else | 579 | } |
580 | else | ||
548 | { | 581 | { |
549 | ap=a; | 582 | ap=a; |
550 | del=sum=1.0/a; | 583 | del=sum=1.0/a; |
551 | for (n=1;n<=ITMAX;n++) | 584 | for (n=1;n<=ITMAX;n++) |
552 | { | 585 | { |
553 | ++ap; | 586 | ++ap; |
554 | del *= x/ap; | 587 | del *= x/ap; |
555 | sum += del; | 588 | sum += del; |
556 | if (fabs(del) < fabs(sum)*EPS) | 589 | if (fabs(del) < fabs(sum)*EPS) |
557 | { | 590 | { |
558 | *gamser=sum*exp(-x+a*log(x)-(*gln)); | 591 | *gamser=sum*exp(-x+a*log(x)-(*gln)); |
559 | return; | 592 | return; |
560 | } | 593 | } |
561 | } return; | 594 | } |
595 | return; | ||
562 | return; | 596 | return; |
563 | } | 597 | } |
564 | }; | 598 | }; |
565 | 599 | ||
566 | 600 | ||
567 | void Sheet::GammaContinuedFraction(double *gammcf, double a, double x, double *gln) | 601 | void Sheet::GammaContinuedFraction(double *gammcf, double a, double x, double *gln) |
568 | { | 602 | { |
569 | double EPS=3.0e-7; | 603 | double EPS=3.0e-7; |
570 | double FPMIN=1.0e-30; | 604 | double FPMIN=1.0e-30; |
571 | int ITMAX=100; | 605 | int ITMAX=100; |
572 | int i; | 606 | int i; |
573 | double an,b,c,d,del,h; | 607 | double an,b,c,d,del,h; |
@@ -653,25 +687,26 @@ double Sheet::functionSum(const QString ¶m1, const QString ¶m2) | |||
653 | int row1, col1, row2, col2, row, col; | 687 | int row1, col1, row2, col2, row, col; |
654 | double result=0, tempResult; | 688 | double result=0, tempResult; |
655 | bool ok; | 689 | bool ok; |
656 | if (findRange(param1, param2, &row1, &col1, &row2, &col2)) | 690 | if (findRange(param1, param2, &row1, &col1, &row2, &col2)) |
657 | { | 691 | { |
658 | for (row=row1; row<=row2; ++row) | 692 | for (row=row1; row<=row2; ++row) |
659 | for (col=col1; col<=col2; ++col) | 693 | for (col=col1; col<=col2; ++col) |
660 | { | 694 | { |
661 | tempResult=text(row, col).toDouble(&ok); | 695 | tempResult=text(row, col).toDouble(&ok); |
662 | if (ok) result+=tempResult; | 696 | if (ok) result+=tempResult; |
663 | } | 697 | } |
664 | return result; | 698 | return result; |
665 | }else | 699 | } |
700 | else | ||
666 | { | 701 | { |
667 | double d1=0,d2=0; | 702 | double d1=0,d2=0; |
668 | d1=calculateVariable(param1).toDouble(&ok); | 703 | d1=calculateVariable(param1).toDouble(&ok); |
669 | d2=calculateVariable(param2).toDouble(&ok); | 704 | d2=calculateVariable(param2).toDouble(&ok); |
670 | return(d1+d2); | 705 | return(d1+d2); |
671 | }; | 706 | }; |
672 | return 0; | 707 | return 0; |
673 | } | 708 | } |
674 | 709 | ||
675 | QString Sheet::functionIndex(const QString ¶m1, const QString ¶m2, int indx) | 710 | QString Sheet::functionIndex(const QString ¶m1, const QString ¶m2, int indx) |
676 | { | 711 | { |
677 | int row1, col1, row2, col2, row, col; | 712 | int row1, col1, row2, col2, row, col; |
@@ -780,25 +815,26 @@ double Sheet::functionSumSQ(const QString ¶m1, const QString ¶m2) | |||
780 | int row1, col1, row2, col2, row, col; | 815 | int row1, col1, row2, col2, row, col; |
781 | double result=0, tempResult; | 816 | double result=0, tempResult; |
782 | bool ok; | 817 | bool ok; |
783 | if (findRange(param1, param2, &row1, &col1, &row2, &col2)) | 818 | if (findRange(param1, param2, &row1, &col1, &row2, &col2)) |
784 | { | 819 | { |
785 | for (row=row1; row<=row2; ++row) | 820 | for (row=row1; row<=row2; ++row) |
786 | for (col=col1; col<=col2; ++col) | 821 | for (col=col1; col<=col2; ++col) |
787 | { | 822 | { |
788 | tempResult=text(row, col).toDouble(&ok); | 823 | tempResult=text(row, col).toDouble(&ok); |
789 | if (ok) result+=tempResult*tempResult; | 824 | if (ok) result+=tempResult*tempResult; |
790 | } | 825 | } |
791 | return result; | 826 | return result; |
792 | }else | 827 | } |
828 | else | ||
793 | { | 829 | { |
794 | double d1=0,d2=0; | 830 | double d1=0,d2=0; |
795 | d1=calculateVariable(param1).toDouble(&ok); | 831 | d1=calculateVariable(param1).toDouble(&ok); |
796 | d2=calculateVariable(param2).toDouble(&ok); | 832 | d2=calculateVariable(param2).toDouble(&ok); |
797 | return(d1*d1+d2*d2); | 833 | return(d1*d1+d2*d2); |
798 | }; | 834 | }; |
799 | return 0; | 835 | return 0; |
800 | } | 836 | } |
801 | 837 | ||
802 | 838 | ||
803 | 839 | ||
804 | double Sheet::functionMin(const QString ¶m1, const QString ¶m2) | 840 | double Sheet::functionMin(const QString ¶m1, const QString ¶m2) |
@@ -810,25 +846,26 @@ double Sheet::functionMin(const QString ¶m1, const QString ¶m2) | |||
810 | { | 846 | { |
811 | for (row=row1; row<=row2; ++row) | 847 | for (row=row1; row<=row2; ++row) |
812 | for (col=col1; col<=col2; ++col) | 848 | for (col=col1; col<=col2; ++col) |
813 | { | 849 | { |
814 | tempMin=text(row, col).toDouble(&ok); | 850 | tempMin=text(row, col).toDouble(&ok); |
815 | if (ok && (!init || tempMin<min)) | 851 | if (ok && (!init || tempMin<min)) |
816 | { | 852 | { |
817 | min=tempMin; | 853 | min=tempMin; |
818 | init=TRUE; | 854 | init=TRUE; |
819 | } | 855 | } |
820 | } | 856 | } |
821 | return min; | 857 | return min; |
822 | }else | 858 | } |
859 | else | ||
823 | { | 860 | { |
824 | double d1=0,d2=0; | 861 | double d1=0,d2=0; |
825 | d1=calculateVariable(param1).toDouble(&ok); | 862 | d1=calculateVariable(param1).toDouble(&ok); |
826 | d2=calculateVariable(param2).toDouble(&ok); | 863 | d2=calculateVariable(param2).toDouble(&ok); |
827 | if(d1<d2) return(d1); else return(d2); | 864 | if(d1<d2) return(d1); else return(d2); |
828 | }; | 865 | }; |
829 | return 0; | 866 | return 0; |
830 | } | 867 | } |
831 | 868 | ||
832 | double Sheet::functionMax(const QString ¶m1, const QString ¶m2) | 869 | double Sheet::functionMax(const QString ¶m1, const QString ¶m2) |
833 | { | 870 | { |
834 | int row1, col1, row2, col2, row, col; | 871 | int row1, col1, row2, col2, row, col; |
@@ -838,25 +875,26 @@ double Sheet::functionMax(const QString ¶m1, const QString ¶m2) | |||
838 | { | 875 | { |
839 | for (row=row1; row<=row2; ++row) | 876 | for (row=row1; row<=row2; ++row) |
840 | for (col=col1; col<=col2; ++col) | 877 | for (col=col1; col<=col2; ++col) |
841 | { | 878 | { |
842 | tempMax=text(row, col).toDouble(&ok); | 879 | tempMax=text(row, col).toDouble(&ok); |
843 | if (ok && (!init || tempMax>max)) | 880 | if (ok && (!init || tempMax>max)) |
844 | { | 881 | { |
845 | max=tempMax; | 882 | max=tempMax; |
846 | init=TRUE; | 883 | init=TRUE; |
847 | } | 884 | } |
848 | }; | 885 | }; |
849 | return max; | 886 | return max; |
850 | }else | 887 | } |
888 | else | ||
851 | { | 889 | { |
852 | double d1=0,d2=0; | 890 | double d1=0,d2=0; |
853 | d1=calculateVariable(param1).toDouble(&ok); | 891 | d1=calculateVariable(param1).toDouble(&ok); |
854 | d2=calculateVariable(param2).toDouble(&ok); | 892 | d2=calculateVariable(param2).toDouble(&ok); |
855 | if(d1>d2) return(d1); else return(d2); | 893 | if(d1>d2) return(d1); else return(d2); |
856 | }; | 894 | }; |
857 | return 0; | 895 | return 0; |
858 | } | 896 | } |
859 | 897 | ||
860 | double Sheet::functionAvg(const QString ¶m1, const QString ¶m2) | 898 | double Sheet::functionAvg(const QString ¶m1, const QString ¶m2) |
861 | { | 899 | { |
862 | double resultSum=functionSum(param1, param2), resultCount=functionCount(param1, param2); | 900 | double resultSum=functionSum(param1, param2), resultCount=functionCount(param1, param2); |
@@ -868,25 +906,26 @@ double Sheet::functionCount(const QString ¶m1, const QString ¶m2) | |||
868 | int row1, col1, row2, col2, row, col; | 906 | int row1, col1, row2, col2, row, col; |
869 | int divider=0; | 907 | int divider=0; |
870 | bool ok; | 908 | bool ok; |
871 | if (findRange(param1, param2, &row1, &col1, &row2, &col2)) | 909 | if (findRange(param1, param2, &row1, &col1, &row2, &col2)) |
872 | { | 910 | { |
873 | for (row=row1; row<=row2; ++row) | 911 | for (row=row1; row<=row2; ++row) |
874 | for (col=col1; col<=col2; ++col) | 912 | for (col=col1; col<=col2; ++col) |
875 | { | 913 | { |
876 | text(row, col).toDouble(&ok); | 914 | text(row, col).toDouble(&ok); |
877 | if (ok) ++divider; | 915 | if (ok) ++divider; |
878 | }; | 916 | }; |
879 | return divider; | 917 | return divider; |
880 | }else | 918 | } |
919 | else | ||
881 | { | 920 | { |
882 | double d1=0,d2=0;int ii=0; | 921 | double d1=0,d2=0;int ii=0; |
883 | d1=calculateVariable(param1).toDouble(&ok); | 922 | d1=calculateVariable(param1).toDouble(&ok); |
884 | if (ok) ii++; | 923 | if (ok) ii++; |
885 | d2=calculateVariable(param2).toDouble(&ok); | 924 | d2=calculateVariable(param2).toDouble(&ok); |
886 | if (ok) ii++; | 925 | if (ok) ii++; |
887 | return(ii); | 926 | return(ii); |
888 | }; | 927 | }; |
889 | return 0; | 928 | return 0; |
890 | } | 929 | } |
891 | 930 | ||
892 | double Sheet::functionCountIf(const QString ¶m1, const QString ¶m2, const QString ¶m3) | 931 | double Sheet::functionCountIf(const QString ¶m1, const QString ¶m2, const QString ¶m3) |
@@ -983,51 +1022,55 @@ QString Sheet::calculateFunction(const QString &func, const QString ¶meters, | |||
983 | { | 1022 | { |
984 | val1=calculateVariable(getParameter(parameters, 0)).toDouble(&ok); | 1023 | val1=calculateVariable(getParameter(parameters, 0)).toDouble(&ok); |
985 | val2=calculateVariable(getParameter(parameters, 1)).toDouble(&ok); | 1024 | val2=calculateVariable(getParameter(parameters, 1)).toDouble(&ok); |
986 | if(val1==val2) return QString::number(1); else return QString::number(0); | 1025 | if(val1==val2) return QString::number(1); else return QString::number(0); |
987 | }; | 1026 | }; |
988 | 1027 | ||
989 | //LOGICAL / INFO | 1028 | //LOGICAL / INFO |
990 | if (function=="ISBLANK") | 1029 | if (function=="ISBLANK") |
991 | { | 1030 | { |
992 | if(findRowColumn(getParameter(parameters, 0), &row, &col, FALSE)) | 1031 | if(findRowColumn(getParameter(parameters, 0), &row, &col, FALSE)) |
993 | { | 1032 | { |
994 | if(text(row,col).length()==0) val1=1; else val1=0; | 1033 | if(text(row,col).length()==0) val1=1; else val1=0; |
995 | }else | 1034 | } |
1035 | else | ||
996 | { | 1036 | { |
997 | if(findRowColumn(calculateVariable(getParameter(parameters, 0)), &row,&col, FALSE)) | 1037 | if(findRowColumn(calculateVariable(getParameter(parameters, 0)), &row,&col, FALSE)) |
998 | { | 1038 | { |
999 | if(text(row,col).length()==0) val1=1; else val1=0; | 1039 | if(text(row,col).length()==0) val1=1; else val1=0; |
1000 | }else | 1040 | } |
1041 | else | ||
1001 | { | 1042 | { |
1002 | val1=0; | 1043 | val1=0; |
1003 | }; | 1044 | }; |
1004 | }; | 1045 | }; |
1005 | return QString::number(val1); | 1046 | return QString::number(val1); |
1006 | }; | 1047 | }; |
1007 | 1048 | ||
1008 | 1049 | ||
1009 | if (function=="ISNUMBER") | 1050 | if (function=="ISNUMBER") |
1010 | { | 1051 | { |
1011 | if(findRowColumn(getParameter(parameters, 0, TRUE, function), &row, &col, FALSE)) | 1052 | if(findRowColumn(getParameter(parameters, 0, TRUE, function), &row, &col, FALSE)) |
1012 | { | 1053 | { |
1013 | val1=text(row,col).toDouble(&ok); | 1054 | val1=text(row,col).toDouble(&ok); |
1014 | if(ok) val1=1; else val1=0; | 1055 | if(ok) val1=1; else val1=0; |
1015 | }else | 1056 | } |
1057 | else | ||
1016 | { | 1058 | { |
1017 | if(findRowColumn(calculateVariable(getParameter(parameters, 0, TRUE, function)), &row,&col, FALSE)) | 1059 | if(findRowColumn(calculateVariable(getParameter(parameters, 0, TRUE, function)), &row,&col, FALSE)) |
1018 | { | 1060 | { |
1019 | val1=text(row,col).toDouble(&ok); | 1061 | val1=text(row,col).toDouble(&ok); |
1020 | if(ok) val1=1; else val1=0; | 1062 | if(ok) val1=1; else val1=0; |
1021 | }else | 1063 | } |
1064 | else | ||
1022 | { | 1065 | { |
1023 | val1=0; | 1066 | val1=0; |
1024 | }; | 1067 | }; |
1025 | }; | 1068 | }; |
1026 | return QString::number(val1); | 1069 | return QString::number(val1); |
1027 | }; | 1070 | }; |
1028 | if (function=="AND") | 1071 | if (function=="AND") |
1029 | { | 1072 | { |
1030 | vali=calculateVariable(getParameter(parameters, 0, TRUE, function)).toInt(&ok) | 1073 | vali=calculateVariable(getParameter(parameters, 0, TRUE, function)).toInt(&ok) |
1031 | & calculateVariable(getParameter(parameters, 1, TRUE, function)).toInt(&ok); | 1074 | & calculateVariable(getParameter(parameters, 1, TRUE, function)).toInt(&ok); |
1032 | return QString::number(vali); | 1075 | return QString::number(vali); |
1033 | }; | 1076 | }; |
@@ -1380,25 +1423,26 @@ QString Sheet::calculateFunction(const QString &func, const QString ¶meters, | |||
1380 | s1=s1.lower(); | 1423 | s1=s1.lower(); |
1381 | return QString(s1); | 1424 | return QString(s1); |
1382 | }; | 1425 | }; |
1383 | if (function=="IF") | 1426 | if (function=="IF") |
1384 | { | 1427 | { |
1385 | //usage: IF(param1,param2,param3) | 1428 | //usage: IF(param1,param2,param3) |
1386 | //returns param4 if true(param1)/ param5 if false(param1) | 1429 | //returns param4 if true(param1)/ param5 if false(param1) |
1387 | val1=getParameter(parameters, 0, TRUE, function).toDouble(&ok); | 1430 | val1=getParameter(parameters, 0, TRUE, function).toDouble(&ok); |
1388 | if(val1==1.0) | 1431 | if(val1==1.0) |
1389 | { | 1432 | { |
1390 | s1=calculateVariable(getParameter(parameters, 1, TRUE, function)); | 1433 | s1=calculateVariable(getParameter(parameters, 1, TRUE, function)); |
1391 | return QString(s1); | 1434 | return QString(s1); |
1392 | }else | 1435 | } |
1436 | else | ||
1393 | { | 1437 | { |
1394 | s1=calculateVariable(getParameter(parameters, 2, TRUE, function)); | 1438 | s1=calculateVariable(getParameter(parameters, 2, TRUE, function)); |
1395 | return QString(s1); | 1439 | return QString(s1); |
1396 | }; | 1440 | }; |
1397 | }; | 1441 | }; |
1398 | if (function=="SUM") | 1442 | if (function=="SUM") |
1399 | { | 1443 | { |
1400 | //NumOfParams | 1444 | //NumOfParams |
1401 | val2=0.0; | 1445 | val2=0.0; |
1402 | for(w1=1;w1<=(NumOfParams/2);w1++) | 1446 | for(w1=1;w1<=(NumOfParams/2);w1++) |
1403 | { | 1447 | { |
1404 | val1=functionSum(getParameter(parameters, (w1-1)*2, FALSE, function), getParameter(parameters, (w1-1)*2+1, TRUE, function)); | 1448 | val1=functionSum(getParameter(parameters, (w1-1)*2, FALSE, function), getParameter(parameters, (w1-1)*2+1, TRUE, function)); |
@@ -1543,55 +1587,58 @@ QString Sheet::calculateFunction(const QString &func, const QString ¶meters, | |||
1543 | val2=calculateVariable(getParameter(parameters, 1, TRUE, function)).toDouble(&ok); | 1587 | val2=calculateVariable(getParameter(parameters, 1, TRUE, function)).toDouble(&ok); |
1544 | return QString::number(ErrorFunctionComplementary(val2)-ErrorFunctionComplementary(val1)); | 1588 | return QString::number(ErrorFunctionComplementary(val2)-ErrorFunctionComplementary(val1)); |
1545 | }; | 1589 | }; |
1546 | if(function=="POISSON") | 1590 | if(function=="POISSON") |
1547 | { | 1591 | { |
1548 | // POISSON DISTR(x,n,distr/desnt) | 1592 | // POISSON DISTR(x,n,distr/desnt) |
1549 | val1=calculateVariable(getParameter(parameters, 0, TRUE, function)).toDouble(&ok); | 1593 | val1=calculateVariable(getParameter(parameters, 0, TRUE, function)).toDouble(&ok); |
1550 | val2=calculateVariable(getParameter(parameters, 1, TRUE, function)).toDouble(&ok); | 1594 | val2=calculateVariable(getParameter(parameters, 1, TRUE, function)).toDouble(&ok); |
1551 | vali=calculateVariable(getParameter(parameters, 2, TRUE, function)).toInt(&ok); | 1595 | vali=calculateVariable(getParameter(parameters, 2, TRUE, function)).toInt(&ok); |
1552 | if(vali==1) | 1596 | if(vali==1) |
1553 | { | 1597 | { |
1554 | return QString::number(GammaQ(floor(val1)+1, val2)); | 1598 | return QString::number(GammaQ(floor(val1)+1, val2)); |
1555 | }else | 1599 | } |
1600 | else | ||
1556 | { | 1601 | { |
1557 | return QString::number(exp(-val2)*pow(val2,val1)/exp(GammaLn(val1+1.0))); | 1602 | return QString::number(exp(-val2)*pow(val2,val1)/exp(GammaLn(val1+1.0))); |
1558 | }; | 1603 | }; |
1559 | }; | 1604 | }; |
1560 | if(function=="CHIDIST") | 1605 | if(function=="CHIDIST") |
1561 | { | 1606 | { |
1562 | // POISSON CHIDIST(x,n,distr/density) | 1607 | // POISSON CHIDIST(x,n,distr/density) |
1563 | val1=calculateVariable(getParameter(parameters, 0, TRUE, function)).toDouble(&ok); | 1608 | val1=calculateVariable(getParameter(parameters, 0, TRUE, function)).toDouble(&ok); |
1564 | val2=calculateVariable(getParameter(parameters, 1, TRUE, function)).toDouble(&ok); | 1609 | val2=calculateVariable(getParameter(parameters, 1, TRUE, function)).toDouble(&ok); |
1565 | vali=calculateVariable(getParameter(parameters, 2, TRUE, function)).toInt(&ok); | 1610 | vali=calculateVariable(getParameter(parameters, 2, TRUE, function)).toInt(&ok); |
1566 | if(vali==1) | 1611 | if(vali==1) |
1567 | { | 1612 | { |
1568 | return QString::number(GammaP(val2/2.0,val1*val1/2.0)); | 1613 | return QString::number(GammaP(val2/2.0,val1*val1/2.0)); |
1569 | } else | 1614 | } |
1615 | else | ||
1570 | { | 1616 | { |
1571 | return QString::number( | 1617 | return QString::number( |
1572 | pow(val1,val2-1.0)*exp(-val1*val1/2)/ ( pow(2,val2/2.0-1.0)*exp(GammaLn(val2/2.0))) | 1618 | pow(val1,val2-1.0)*exp(-val1*val1/2)/ ( pow(2,val2/2.0-1.0)*exp(GammaLn(val2/2.0))) |
1573 | ); | 1619 | ); |
1574 | }; | 1620 | }; |
1575 | }; | 1621 | }; |
1576 | if(function=="CHI2DIST") | 1622 | if(function=="CHI2DIST") |
1577 | { | 1623 | { |
1578 | // POISSON CHISQUAREDIST(x,n,distr/density) | 1624 | // POISSON CHISQUAREDIST(x,n,distr/density) |
1579 | val1=calculateVariable(getParameter(parameters, 0, TRUE, function)).toDouble(&ok); | 1625 | val1=calculateVariable(getParameter(parameters, 0, TRUE, function)).toDouble(&ok); |
1580 | val2=calculateVariable(getParameter(parameters, 1, TRUE, function)).toDouble(&ok); | 1626 | val2=calculateVariable(getParameter(parameters, 1, TRUE, function)).toDouble(&ok); |
1581 | vali=calculateVariable(getParameter(parameters, 2, TRUE, function)).toInt(&ok); | 1627 | vali=calculateVariable(getParameter(parameters, 2, TRUE, function)).toInt(&ok); |
1582 | if(vali==1) | 1628 | if(vali==1) |
1583 | { | 1629 | { |
1584 | return QString::number(GammaP(val2/2.0,val1/2.0)); | 1630 | return QString::number(GammaP(val2/2.0,val1/2.0)); |
1585 | } else | 1631 | } |
1632 | else | ||
1586 | { | 1633 | { |
1587 | return QString::number( | 1634 | return QString::number( |
1588 | pow(val1,val2/2.0-1.0)/(exp(val1/2.0)*pow(sqrt(2.0),val2)*exp(GammaLn(val2/2.0))) | 1635 | pow(val1,val2/2.0-1.0)/(exp(val1/2.0)*pow(sqrt(2.0),val2)*exp(GammaLn(val2/2.0))) |
1589 | ); | 1636 | ); |
1590 | }; | 1637 | }; |
1591 | }; | 1638 | }; |
1592 | if(function=="BETAI") | 1639 | if(function=="BETAI") |
1593 | { | 1640 | { |
1594 | // BETA INCOMPLETE BETA(x,a,b) | 1641 | // BETA INCOMPLETE BETA(x,a,b) |
1595 | val1=calculateVariable(getParameter(parameters, 0, TRUE, function)).toDouble(&ok); | 1642 | val1=calculateVariable(getParameter(parameters, 0, TRUE, function)).toDouble(&ok); |
1596 | val2=calculateVariable(getParameter(parameters, 1, TRUE, function)).toDouble(&ok); | 1643 | val2=calculateVariable(getParameter(parameters, 1, TRUE, function)).toDouble(&ok); |
1597 | val3=calculateVariable(getParameter(parameters, 2, TRUE, function)).toDouble(&ok); | 1644 | val3=calculateVariable(getParameter(parameters, 2, TRUE, function)).toDouble(&ok); |
@@ -2376,25 +2423,26 @@ void Expression::GetNext() | |||
2376 | } | 2423 | } |
2377 | else | 2424 | else |
2378 | { | 2425 | { |
2379 | break; | 2426 | break; |
2380 | } | 2427 | } |
2381 | } | 2428 | } |
2382 | else | 2429 | else |
2383 | { | 2430 | { |
2384 | break; | 2431 | break; |
2385 | } | 2432 | } |
2386 | }//while | 2433 | }//while |
2387 | }//else if | 2434 | }//else if |
2388 | };//end function | 2435 | } |
2436 | ;//end function | ||
2389 | 2437 | ||
2390 | 2438 | ||
2391 | void Expression::First() | 2439 | void Expression::First() |
2392 | { | 2440 | { |
2393 | GetNext(); | 2441 | GetNext(); |
2394 | if (!(chunk=="") && !ErrorFound) Third(); | 2442 | if (!(chunk=="") && !ErrorFound) Third(); |
2395 | else ErrorFound = true; | 2443 | else ErrorFound = true; |
2396 | }; | 2444 | }; |
2397 | 2445 | ||
2398 | void Expression::Third() | 2446 | void Expression::Third() |
2399 | { | 2447 | { |
2400 | QChar sign, secS='\0'; | 2448 | QChar sign, secS='\0'; |
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,29 +1,49 @@ | |||
1 | /*************************************************************************** | 1 | /* |
2 | * * | 2 | =. This file is part of the Opie Project |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> |
4 | * it under the terms of the GNU General Public License as published by * | 4 | .>+-= |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | _;:, .> :=|. This program is free software; you can |
6 | * (at your option) any later version. * | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | * * | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | ***************************************************************************/ | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This program is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
9 | 28 | ||
10 | /* | 29 | /* |
11 | * Opie Sheet (formerly Sheet/Qt) | 30 | * Opie Sheet (formerly Sheet/Qt) |
12 | * by Serdar Ozler <sozler@sitebest.com> | 31 | * by Serdar Ozler <sozler@sitebest.com> |
13 | */ | 32 | */ |
14 | 33 | ||
15 | #ifndef SHEET_H | 34 | #ifndef SHEET_H |
16 | #define SHEET_H | 35 | #define SHEET_H |
17 | 36 | ||
37 | /* QT */ | ||
18 | #include <qtable.h> | 38 | #include <qtable.h> |
19 | #include <qstack.h> | 39 | #include <qstack.h> |
20 | 40 | ||
21 | typedef struct typeCellBorders | 41 | typedef struct typeCellBorders |
22 | { | 42 | { |
23 | QPen right, bottom; | 43 | QPen right, bottom; |
24 | }; | 44 | }; |
25 | 45 | ||
26 | typedef struct typeCellData | 46 | typedef struct typeCellData |
27 | { | 47 | { |
28 | int col, row; | 48 | int col, row; |
29 | typeCellBorders borders; | 49 | typeCellBorders borders; |
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,30 +1,51 @@ | |||
1 | /*************************************************************************** | 1 | /* |
2 | * * | 2 | =. This file is part of the Opie Project |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> |
4 | * it under the terms of the GNU General Public License as published by * | 4 | .>+-= |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | _;:, .> :=|. This program is free software; you can |
6 | * (at your option) any later version. * | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | * * | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | ***************************************************************************/ | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This program is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
9 | 28 | ||
10 | /* | 29 | /* |
11 | * Opie Sheet (formerly Sheet/Qt) | 30 | * Opie Sheet (formerly Sheet/Qt) |
12 | * by Serdar Ozler <sozler@sitebest.com> | 31 | * by Serdar Ozler <sozler@sitebest.com> |
13 | */ | 32 | */ |
14 | 33 | ||
34 | #include "sortdlg.h" | ||
35 | |||
36 | /* QT */ | ||
15 | #include <qlabel.h> | 37 | #include <qlabel.h> |
16 | #include <qradiobutton.h> | 38 | #include <qradiobutton.h> |
17 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
18 | #include "sortdlg.h" | ||
19 | 40 | ||
20 | SortDialog::SortDialog(QWidget *parent) | 41 | SortDialog::SortDialog(QWidget *parent) |
21 | :QDialog(parent, 0, TRUE) | 42 | :QDialog(parent, 0, TRUE) |
22 | { | 43 | { |
23 | // Main widget | 44 | // Main widget |
24 | tabs=new QTabWidget(this); | 45 | tabs=new QTabWidget(this); |
25 | widgetSort=new QWidget(tabs); | 46 | widgetSort=new QWidget(tabs); |
26 | widgetOptions=new QWidget(tabs); | 47 | widgetOptions=new QWidget(tabs); |
27 | tabs->addTab(widgetSort, tr("&Sort")); | 48 | tabs->addTab(widgetSort, tr("&Sort")); |
28 | tabs->addTab(widgetOptions, tr("&Options")); | 49 | tabs->addTab(widgetOptions, tr("&Options")); |
29 | 50 | ||
30 | // Sort tab | 51 | // Sort tab |
@@ -46,26 +67,25 @@ SortDialog::SortDialog(QWidget *parent) | |||
46 | radio=new QRadioButton(tr("&Left to right (columns)"), groupDirection); | 67 | radio=new QRadioButton(tr("&Left to right (columns)"), groupDirection); |
47 | groupDirection->setButton(0); | 68 | groupDirection->setButton(0); |
48 | connect(groupDirection, SIGNAL(clicked(int)), this, SLOT(directionChanged(int))); | 69 | connect(groupDirection, SIGNAL(clicked(int)), this, SLOT(directionChanged(int))); |
49 | 70 | ||
50 | // Main widget | 71 | // Main widget |
51 | box=new QVBoxLayout(this); | 72 | box=new QVBoxLayout(this); |
52 | box->addWidget(tabs); | 73 | box->addWidget(tabs); |
53 | 74 | ||
54 | setCaption(tr("Sort")); | 75 | setCaption(tr("Sort")); |
55 | } | 76 | } |
56 | 77 | ||
57 | SortDialog::~SortDialog() | 78 | SortDialog::~SortDialog() |
58 | { | 79 | {} |
59 | } | ||
60 | 80 | ||
61 | QComboBox *SortDialog::createFieldCombo(const QString &caption, int y) | 81 | QComboBox *SortDialog::createFieldCombo(const QString &caption, int y) |
62 | { | 82 | { |
63 | QLabel *label=new QLabel(caption, widgetSort); | 83 | QLabel *label=new QLabel(caption, widgetSort); |
64 | label->setGeometry(10, y+5, 215, 20); | 84 | label->setGeometry(10, y+5, 215, 20); |
65 | QComboBox *combo=new QComboBox(FALSE, widgetSort); | 85 | QComboBox *combo=new QComboBox(FALSE, widgetSort); |
66 | combo->setGeometry(10, y+35, 105, 20); | 86 | combo->setGeometry(10, y+35, 105, 20); |
67 | label->setBuddy(combo); | 87 | label->setBuddy(combo); |
68 | return combo; | 88 | return combo; |
69 | } | 89 | } |
70 | 90 | ||
71 | QVButtonGroup *SortDialog::createOrderButtons(int y) | 91 | QVButtonGroup *SortDialog::createOrderButtons(int y) |
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,37 +1,58 @@ | |||
1 | /*************************************************************************** | 1 | /* |
2 | * * | 2 | =. This file is part of the Opie Project |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> |
4 | * it under the terms of the GNU General Public License as published by * | 4 | .>+-= |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | _;:, .> :=|. This program is free software; you can |
6 | * (at your option) any later version. * | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | * * | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | ***************************************************************************/ | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This program is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
9 | 28 | ||
10 | /* | 29 | /* |
11 | * Opie Sheet (formerly Sheet/Qt) | 30 | * Opie Sheet (formerly Sheet/Qt) |
12 | * by Serdar Ozler <sozler@sitebest.com> | 31 | * by Serdar Ozler <sozler@sitebest.com> |
13 | */ | 32 | */ |
14 | 33 | ||
15 | #ifndef SORTDLG_H | 34 | #ifndef SORTDLG_H |
16 | #define SORTDLG_H | 35 | #define SORTDLG_H |
17 | 36 | ||
37 | #include "sheet.h" | ||
38 | |||
39 | /* QT */ | ||
18 | #include <qdialog.h> | 40 | #include <qdialog.h> |
19 | #include <qtabwidget.h> | 41 | #include <qtabwidget.h> |
20 | #include <qlayout.h> | 42 | #include <qlayout.h> |
21 | #include <qcombobox.h> | 43 | #include <qcombobox.h> |
22 | #include <qcheckbox.h> | 44 | #include <qcheckbox.h> |
23 | #include <qpushbutton.h> | 45 | #include <qpushbutton.h> |
24 | #include <qvbuttongroup.h> | 46 | #include <qvbuttongroup.h> |
25 | #include "sheet.h" | ||
26 | 47 | ||
27 | class SortDialog: public QDialog | 48 | class SortDialog: public QDialog |
28 | { | 49 | { |
29 | Q_OBJECT | 50 | Q_OBJECT |
30 | 51 | ||
31 | // QT objects | 52 | // QT objects |
32 | QBoxLayout *box; | 53 | QBoxLayout *box; |
33 | QTabWidget *tabs; | 54 | QTabWidget *tabs; |
34 | QWidget *widgetSort, *widgetOptions; | 55 | QWidget *widgetSort, *widgetOptions; |
35 | QVButtonGroup *groupOrderA, *groupOrderB, *groupOrderC, *groupDirection; | 56 | QVButtonGroup *groupOrderA, *groupOrderB, *groupOrderC, *groupDirection; |
36 | QCheckBox *checkCase; | 57 | QCheckBox *checkCase; |
37 | QComboBox *comboFieldA, *comboFieldB, *comboFieldC; | 58 | QComboBox *comboFieldA, *comboFieldB, *comboFieldC; |
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,44 +1,62 @@ | |||
1 | /*************************************************************************** | 1 | /* |
2 | * * | 2 | =. This file is part of the Opie Project |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> |
4 | * it under the terms of the GNU General Public License as published by * | 4 | .>+-= |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | _;:, .> :=|. This program is free software; you can |
6 | * (at your option) any later version. * | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | * * | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | ***************************************************************************/ | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This program is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
9 | 28 | ||
10 | /* | 29 | /* |
11 | * Opie Sheet (formerly Sheet/Qt) | 30 | * Opie Sheet (formerly Sheet/Qt) |
12 | * by Serdar Ozler <sozler@sitebest.com> | 31 | * by Serdar Ozler <sozler@sitebest.com> |
13 | */ | 32 | */ |
14 | 33 | ||
15 | #include "textdlg.h" | 34 | #include "textdlg.h" |
16 | 35 | ||
17 | TextDialog::TextDialog(QWidget *parent) | 36 | TextDialog::TextDialog(QWidget *parent) |
18 | :QDialog(parent, 0, TRUE) | 37 | :QDialog(parent, 0, TRUE) |
19 | { | 38 | { |
20 | edit=new QLineEdit(this); | 39 | edit=new QLineEdit(this); |
21 | edit->setGeometry(90, 10, 100, 25); | 40 | edit->setGeometry(90, 10, 100, 25); |
22 | 41 | ||
23 | label=new QLabel(this); | 42 | label=new QLabel(this); |
24 | label->setGeometry(10, 10, 70, 25); | 43 | label->setGeometry(10, 10, 70, 25); |
25 | label->setBuddy(edit); | 44 | label->setBuddy(edit); |
26 | 45 | ||
27 | resize(200, 45); | 46 | resize(200, 45); |
28 | } | 47 | } |
29 | 48 | ||
30 | TextDialog::~TextDialog() | 49 | TextDialog::~TextDialog() |
31 | { | 50 | {} |
32 | } | ||
33 | 51 | ||
34 | int TextDialog::exec(const QString &caption, const QString &text, | 52 | int TextDialog::exec(const QString &caption, const QString &text, |
35 | const QString &value) | 53 | const QString &value) |
36 | { | 54 | { |
37 | setCaption(caption); | 55 | setCaption(caption); |
38 | label->setText(text); | 56 | label->setText(text); |
39 | edit->setText(value); | 57 | edit->setText(value); |
40 | 58 | ||
41 | return QDialog::exec(); | 59 | return QDialog::exec(); |
42 | } | 60 | } |
43 | 61 | ||
44 | QString TextDialog::getValue() | 62 | QString TextDialog::getValue() |
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,29 +1,49 @@ | |||
1 | /*************************************************************************** | 1 | /* |
2 | * * | 2 | =. This file is part of the Opie Project |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> |
4 | * it under the terms of the GNU General Public License as published by * | 4 | .>+-= |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | _;:, .> :=|. This program is free software; you can |
6 | * (at your option) any later version. * | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | * * | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | ***************************************************************************/ | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This program is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
9 | 28 | ||
10 | /* | 29 | /* |
11 | * Opie Sheet (formerly Sheet/Qt) | 30 | * Opie Sheet (formerly Sheet/Qt) |
12 | * by Serdar Ozler <sozler@sitebest.com> | 31 | * by Serdar Ozler <sozler@sitebest.com> |
13 | */ | 32 | */ |
14 | 33 | ||
15 | #ifndef TEXTDLG_H | 34 | #ifndef TEXTDLG_H |
16 | #define TEXTDLG_H | 35 | #define TEXTDLG_H |
17 | 36 | ||
37 | /* QT */ | ||
18 | #include <qdialog.h> | 38 | #include <qdialog.h> |
19 | #include <qlabel.h> | 39 | #include <qlabel.h> |
20 | #include <qlineedit.h> | 40 | #include <qlineedit.h> |
21 | 41 | ||
22 | class TextDialog: public QDialog | 42 | class TextDialog: public QDialog |
23 | { | 43 | { |
24 | Q_OBJECT | 44 | Q_OBJECT |
25 | 45 | ||
26 | // QT objects | 46 | // QT objects |
27 | QLabel *label; | 47 | QLabel *label; |
28 | QLineEdit *edit; | 48 | QLineEdit *edit; |
29 | 49 | ||