summaryrefslogtreecommitdiff
authoreilers <eilers>2004-11-06 19:41:22 (UTC)
committer eilers <eilers>2004-11-06 19:41:22 (UTC)
commit82023570a9b5880629a5f7ce477479ffcb7af930 (patch) (unidiff)
treedf2e790812950d2a2cc32af3e39cc8d293133259
parent90d458c63d274a66ca427710b88e2f090a0ab11b (diff)
downloadopie-82023570a9b5880629a5f7ce477479ffcb7af930.zip
opie-82023570a9b5880629a5f7ce477479ffcb7af930.tar.gz
opie-82023570a9b5880629a5f7ce477479ffcb7af930.tar.bz2
Avoid crash if app was unable to open the file
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-sheet/Excel.cpp3
-rw-r--r--noncore/apps/opie-sheet/mainwindow.cpp7
2 files changed, 7 insertions, 3 deletions
diff --git a/noncore/apps/opie-sheet/Excel.cpp b/noncore/apps/opie-sheet/Excel.cpp
index 57aef20..338bc30 100644
--- a/noncore/apps/opie-sheet/Excel.cpp
+++ b/noncore/apps/opie-sheet/Excel.cpp
@@ -1,1708 +1,1709 @@
1/* 1/*
2 =. This file is part of the Opie Project 2 =. This file is part of the Opie Project
3 .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> 3 .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org>
4 .>+-= 4 .>+-=
5 _;:, .> :=|. This program is free software; you can 5 _;:, .> :=|. This program is free software; you can
6.> <`_, > . <= redistribute it and/or modify it under 6.> <`_, > . <= redistribute it and/or modify it under
7:`=1 )Y*s>-.-- : the terms of the GNU General Public 7:`=1 )Y*s>-.-- : the terms of the GNU General Public
8.="- .-=="i, .._ License as published by the Free Software 8.="- .-=="i, .._ License as published by the Free Software
9 - . .-<_> .<> Foundation; either version 2 of the License, 9 - . .-<_> .<> Foundation; either version 2 of the License,
10 ._= =} : or (at your option) any later version. 10 ._= =} : or (at your option) any later version.
11 .%`+i> _;_. 11 .%`+i> _;_.
12 .i_,=:_. -<s. This program is distributed in the hope that 12 .i_,=:_. -<s. This program is distributed in the hope that
13 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 13 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
14 : .. .:, . . . without even the implied warranty of 14 : .. .:, . . . without even the implied warranty of
15 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 15 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
16 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 16 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.= = ; Library General Public License for more 17..}^=.= = ; Library General Public License for more
18++= -. .` .: details. 18++= -. .` .: details.
19 : = ...= . :.=- 19 : = ...= . :.=-
20 -. .:....=;==+<; You should have received a copy of the GNU 20 -. .:....=;==+<; You should have received a copy of the GNU
21 -_. . . )=. = Library General Public License along with 21 -_. . . )=. = Library General Public License along with
22 -- :-=` this library; see the file COPYING.LIB. 22 -- :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include "Excel.h" 29#include "Excel.h"
30 30
31/* STD */ 31/* STD */
32#include <stdio.h> 32#include <stdio.h>
33#include <stdlib.h> 33#include <stdlib.h>
34#include <math.h> 34#include <math.h>
35#include <time.h> 35#include <time.h>
36#include <sys/types.h> 36#include <sys/types.h>
37#include <strings.h> 37#include <strings.h>
38 38
39static xfrecord formatter[] = { 39static xfrecord formatter[] = {
40 { 0xe , DATEFORMAT, "%m/%d/%y"}, 40 { 0xe , DATEFORMAT, "%m/%d/%y"},
41 { 0xf , DATEFORMAT, "%d-%b-%y"}, 41 { 0xf , DATEFORMAT, "%d-%b-%y"},
42 { 0x10, DATEFORMAT, "%d-%b"}, 42 { 0x10, DATEFORMAT, "%d-%b"},
43 { 0x11, DATEFORMAT, "%b-%y"}, 43 { 0x11, DATEFORMAT, "%b-%y"},
44 { 0x12, DATEFORMAT, "%I:%M %p"}, 44 { 0x12, DATEFORMAT, "%I:%M %p"},
45 { 0x13, DATEFORMAT, "%I:%M:%S %p"}, 45 { 0x13, DATEFORMAT, "%I:%M:%S %p"},
46 { 0x14, DATEFORMAT, "%H:%M"}, 46 { 0x14, DATEFORMAT, "%H:%M"},
47 { 0x15, DATEFORMAT, "%H:%M:%S"}, 47 { 0x15, DATEFORMAT, "%H:%M:%S"},
48 { 0x16, DATEFORMAT, "%m/%d/%y %H:%M"}, 48 { 0x16, DATEFORMAT, "%m/%d/%y %H:%M"},
49 { 0x2d, DATEFORMAT, "%M:%S"}, 49 { 0x2d, DATEFORMAT, "%M:%S"},
50 { 0x2e, DATEFORMAT, "%H:%M:%S"}, 50 { 0x2e, DATEFORMAT, "%H:%M:%S"},
51 { 0x2f, DATEFORMAT, "%M:%S"}, 51 { 0x2f, DATEFORMAT, "%M:%S"},
52 { 0xa5, DATEFORMAT, "%m/%d/%y %I:%M %p"}, 52 { 0xa5, DATEFORMAT, "%m/%d/%y %I:%M %p"},
53 { 0x1 , NUMBERFORMAT, "%.0f"}, 53 { 0x1 , NUMBERFORMAT, "%.0f"},
54 { 0x2 , NUMBERFORMAT, "%.2f"}, 54 { 0x2 , NUMBERFORMAT, "%.2f"},
55 { 0x3 , NUMBERFORMAT, "#,##%.0f"}, 55 { 0x3 , NUMBERFORMAT, "#,##%.0f"},
56 { 0x4 , NUMBERFORMAT, "#,##%.2f"}, 56 { 0x4 , NUMBERFORMAT, "#,##%.2f"},
57 { 0x5 , NUMBERFORMAT, "$#,##%.0f"}, 57 { 0x5 , NUMBERFORMAT, "$#,##%.0f"},
58 { 0x6 , NUMBERFORMAT, "$#,##%.0f"}, 58 { 0x6 , NUMBERFORMAT, "$#,##%.0f"},
59 { 0x7 , NUMBERFORMAT, "$#,##%.2f"}, 59 { 0x7 , NUMBERFORMAT, "$#,##%.2f"},
60 { 0x8 , NUMBERFORMAT, "$#,##%.2f"}, 60 { 0x8 , NUMBERFORMAT, "$#,##%.2f"},
61 { 0x9 , NUMBERFORMAT, "%.0f%%"}, 61 { 0x9 , NUMBERFORMAT, "%.0f%%"},
62 { 0xa , NUMBERFORMAT, "%.2f%%"}, 62 { 0xa , NUMBERFORMAT, "%.2f%%"},
63 { 0xb , NUMBERFORMAT, "%e"}, 63 { 0xb , NUMBERFORMAT, "%e"},
64 { 0x25, NUMBERFORMAT, "#,##%.0f;(#,##0)"}, 64 { 0x25, NUMBERFORMAT, "#,##%.0f;(#,##0)"},
65 { 0x26, NUMBERFORMAT, "#,##%.0f;(#,##0)"}, 65 { 0x26, NUMBERFORMAT, "#,##%.0f;(#,##0)"},
66 { 0x27, NUMBERFORMAT, "#,##%.2f;(#,##0.00)"}, 66 { 0x27, NUMBERFORMAT, "#,##%.2f;(#,##0.00)"},
67 { 0x28, NUMBERFORMAT, "#,##%.2f;(#,##0.00)"}, 67 { 0x28, NUMBERFORMAT, "#,##%.2f;(#,##0.00)"},
68 { 0x29, NUMBERFORMAT, "#,##%.0f;(#,##0)"}, 68 { 0x29, NUMBERFORMAT, "#,##%.0f;(#,##0)"},
69 { 0x2a, NUMBERFORMAT, "$#,##%.0f;($#,##0)"}, 69 { 0x2a, NUMBERFORMAT, "$#,##%.0f;($#,##0)"},
70 { 0x2b, NUMBERFORMAT, "#,##%.2f;(#,##0.00)"}, 70 { 0x2b, NUMBERFORMAT, "#,##%.2f;(#,##0.00)"},
71 { 0x2c, NUMBERFORMAT, "$#,##%.2f;($#,##0.00)"}, 71 { 0x2c, NUMBERFORMAT, "$#,##%.2f;($#,##0.00)"},
72 { 0x30, NUMBERFORMAT, "##0.0E0"}, 72 { 0x30, NUMBERFORMAT, "##0.0E0"},
73 { 0, 0, ""} 73 { 0, 0, ""}
74 }; 74 };
75 75
76 76
77 77
78int ExcelBook::Integer2Byte(int b1, int b2) 78int ExcelBook::Integer2Byte(int b1, int b2)
79{ 79{
80 int i1 = b1 & 0xff; 80 int i1 = b1 & 0xff;
81 int i2 = b2 & 0xff; 81 int i2 = b2 & 0xff;
82 int val = i2 << 8 | i1; 82 int val = i2 << 8 | i1;
83 return val; 83 return val;
84}; 84};
85 85
86int ExcelBook::Integer4Byte(int b1,int b2,int b3,int b4) 86int ExcelBook::Integer4Byte(int b1,int b2,int b3,int b4)
87{ 87{
88 int i1 = Integer2Byte(b1, b2); 88 int i1 = Integer2Byte(b1, b2);
89 int i2 = Integer2Byte(b3, b4); 89 int i2 = Integer2Byte(b3, b4);
90 int val = i2 << 16 | i1; 90 int val = i2 << 16 | i1;
91 return val; 91 return val;
92}; 92};
93 93
94int ExcelBook::Integer2ByteFile(FILE *f) 94int ExcelBook::Integer2ByteFile(FILE *f)
95{ 95{
96 int i1, i2; 96 int i1, i2;
97 i1 = fgetc(f); 97 i1 = fgetc(f);
98 i2 = fgetc(f); 98 i2 = fgetc(f);
99 return Integer2Byte(i1,i2); 99 return Integer2Byte(i1,i2);
100}; 100};
101 101
102float ExcelBook::Float4Byte(int b1, int b2, int b3, int b4) 102float ExcelBook::Float4Byte(int b1, int b2, int b3, int b4)
103{ 103{
104 int i; 104 int i;
105 float f; 105 float f;
106 unsigned char *ieee; 106 unsigned char *ieee;
107 ieee = (unsigned char *) &f; 107 ieee = (unsigned char *) &f;
108 for (i = 0; i < 4; i++) ieee[i] = 0; 108 for (i = 0; i < 4; i++) ieee[i] = 0;
109 ieee[0] = ((int)b4) & 0xff; 109 ieee[0] = ((int)b4) & 0xff;
110 ieee[1] = ((int)b3) & 0xff; 110 ieee[1] = ((int)b3) & 0xff;
111 ieee[2] = ((int)b2) & 0xff; 111 ieee[2] = ((int)b2) & 0xff;
112 ieee[3] = ((int)b1) & 0xff; 112 ieee[3] = ((int)b1) & 0xff;
113 return f; 113 return f;
114}; 114};
115 115
116double ExcelBook::Double4Byte(int b1, int b2, int b3, int b4) 116double ExcelBook::Double4Byte(int b1, int b2, int b3, int b4)
117{ 117{
118 long int rk; 118 long int rk;
119 double value; 119 double value;
120 120
121 rk=Integer4Byte(b1,b2,b3,b4); 121 rk=Integer4Byte(b1,b2,b3,b4);
122 //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);
123 if ( (rk & 0x02) != 0) 123 if ( (rk & 0x02) != 0)
124 { 124 {
125 long int intval = rk >> 2; //drops the 2 bits 125 long int intval = rk >> 2; //drops the 2 bits
126 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);
127 value = (double) intval; 127 value = (double) intval;
128 printf("Double4Byte: VALUEINT=%f\r\n",value); 128 printf("Double4Byte: VALUEINT=%f\r\n",value);
129 if ( (rk & 0x01) != 0) 129 if ( (rk & 0x01) != 0)
130 { 130 {
131 value /= 100.0; 131 value /= 100.0;
132 }; 132 };
133 return value; 133 return value;
134 } 134 }
135 else 135 else
136 { 136 {
137 137
138 union { double d; unsigned long int b[2]; } dbl_byte; 138 union { double d; unsigned long int b[2]; } dbl_byte;
139 unsigned long int valbits = (rk & 0xfffffffc); 139 unsigned long int valbits = (rk & 0xfffffffc);
140#if defined(__arm__) && !defined(__vfp__) 140#if defined(__arm__) && !defined(__vfp__)
141 dbl_byte.b[0]=valbits; 141 dbl_byte.b[0]=valbits;
142 dbl_byte.b[1]=0; 142 dbl_byte.b[1]=0;
143#else 143#else
144 dbl_byte.b[0]=0; 144 dbl_byte.b[0]=0;
145 dbl_byte.b[1]=valbits; 145 dbl_byte.b[1]=valbits;
146#endif 146#endif
147 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]);
148 value=dbl_byte.d; 148 value=dbl_byte.d;
149 printf("Double4Byte: VALUE=%f\r\n",value); 149 printf("Double4Byte: VALUE=%f\r\n",value);
150 150
151 if ( (rk & 0x01) != 0) 151 if ( (rk & 0x01) != 0)
152 { 152 {
153 value /= 100.0; 153 value /= 100.0;
154 }; 154 };
155 return value; 155 return value;
156 }; 156 };
157}; 157};
158 158
159void ExcelBook::DetectEndian(void) 159void ExcelBook::DetectEndian(void)
160{ 160{
161 int end; 161 int end;
162 long i = 0x44332211; 162 long i = 0x44332211;
163 unsigned char* a = (unsigned char*) &i; 163 unsigned char* a = (unsigned char*) &i;
164 end = (*a != 0x11); 164 end = (*a != 0x11);
165 if (end == 1) 165 if (end == 1)
166 { 166 {
167 endian = BIG_ENDIAN; 167 endian = BIG_ENDIAN;
168 printf("BIGENDIAN!\r\n"); 168 printf("BIGENDIAN!\r\n");
169 } 169 }
170 else 170 else
171 { 171 {
172 endian = LITTLE_ENDIAN; 172 endian = LITTLE_ENDIAN;
173 printf("LITTLEENDIAN!\r\n"); 173 printf("LITTLEENDIAN!\r\n");
174 } 174 }
175}; 175};
176 176
177double ExcelBook::Double8Byte(int b1, int b2, int b3, int b4, int b5, int b6, int b7, int b8) 177double ExcelBook::Double8Byte(int b1, int b2, int b3, int b4, int b5, int b6, int b7, int b8)
178{ 178{
179 int i; 179 int i;
180 double d; 180 double d;
181 unsigned char *ieee; 181 unsigned char *ieee;
182 ieee = (unsigned char *)&d; 182 ieee = (unsigned char *)&d;
183 for (i = 0; i < 8; i++) ieee[i] = 0; 183 for (i = 0; i < 8; i++) ieee[i] = 0;
184 if (endian == BIG_ENDIAN) 184 if (endian == BIG_ENDIAN)
185 { 185 {
186 ieee[0] = ((int)b8) & 0xff;ieee[1] = ((int)b7) & 0xff; 186 ieee[0] = ((int)b8) & 0xff;ieee[1] = ((int)b7) & 0xff;
187 ieee[2] = ((int)b6) & 0xff;ieee[3] = ((int)b5) & 0xff; 187 ieee[2] = ((int)b6) & 0xff;ieee[3] = ((int)b5) & 0xff;
188 ieee[4] = ((int)b4) & 0xff;ieee[5] = ((int)b3) & 0xff; 188 ieee[4] = ((int)b4) & 0xff;ieee[5] = ((int)b3) & 0xff;
189 ieee[6] = ((int)b2) & 0xff;ieee[7] = ((int)b1) & 0xff; 189 ieee[6] = ((int)b2) & 0xff;ieee[7] = ((int)b1) & 0xff;
190 } 190 }
191 else 191 else
192 { 192 {
193 ieee[0] = ((int)b1) & 0xff;ieee[1] = ((int)b2) & 0xff; 193 ieee[0] = ((int)b1) & 0xff;ieee[1] = ((int)b2) & 0xff;
194 ieee[2] = ((int)b3) & 0xff;ieee[3] = ((int)b4) & 0xff; 194 ieee[2] = ((int)b3) & 0xff;ieee[3] = ((int)b4) & 0xff;
195 ieee[4] = ((int)b5) & 0xff;ieee[5] = ((int)b6) & 0xff; 195 ieee[4] = ((int)b5) & 0xff;ieee[5] = ((int)b6) & 0xff;
196 ieee[6] = ((int)b7) & 0xff;ieee[7] = ((int)b8) & 0xff; 196 ieee[6] = ((int)b7) & 0xff;ieee[7] = ((int)b8) & 0xff;
197 } 197 }
198 return d; 198 return d;
199}; 199};
200 200
201bool ExcelBook::OpenFile(char *Filename) 201bool ExcelBook::OpenFile(char *Filename)
202{ 202{
203 printf("Opening excel file!\r\n"); 203 printf("Opening excel file!\r\n");
204 File= fopen(Filename, "r"); 204 File= fopen(Filename, "r");
205 Position=0; // first byte index in file 205 Position=0; // first byte index in file
206 XFRecords.resize(0); 206 XFRecords.resize(0);
207 SharedStrings.resize(0); 207 SharedStrings.resize(0);
208 Names.resize(0); 208 Names.resize(0);
209 Sheets.resize(0); 209 Sheets.resize(0);
210 if(File==NULL) return false; 210 if(File==NULL) return false;
211 printf("Opened excel file!\r\n"); 211 printf("Opened excel file!\r\n");
212 return true; 212 return true;
213}; 213};
214 214
215bool ExcelBook::CloseFile(void) 215bool ExcelBook::CloseFile(void)
216{ 216{
217 int w1; 217 int w1;
218 for(w1=0;w1<(int)XFRecords.count();w1++) 218 for(w1=0;w1<(int)XFRecords.count();w1++)
219 { 219 {
220 if(XFRecords[w1]!=NULL) {delete XFRecords[w1];XFRecords[w1]=NULL;}; 220 if(XFRecords[w1]!=NULL) {delete XFRecords[w1];XFRecords[w1]=NULL;};
221 }; 221 };
222 for(w1=0;w1<(int)SharedStrings.count();w1++) 222 for(w1=0;w1<(int)SharedStrings.count();w1++)
223 { 223 {
224 if(SharedStrings[w1]!=NULL) {delete SharedStrings[w1];SharedStrings[w1]=NULL;}; 224 if(SharedStrings[w1]!=NULL) {delete SharedStrings[w1];SharedStrings[w1]=NULL;};
225 }; 225 };
226 for(w1=0;w1<(int)Names.count();w1++) 226 for(w1=0;w1<(int)Names.count();w1++)
227 { 227 {
228 if(Names[w1]!=NULL) {delete Names[w1];Names[w1]=NULL;}; 228 if(Names[w1]!=NULL) {delete Names[w1];Names[w1]=NULL;};
229 }; 229 };
230 for(w1=0;w1<(int)Sheets.count();w1++) 230 for(w1=0;w1<(int)Sheets.count();w1++)
231 { 231 {
232 if(Sheets[w1]!=NULL) {delete Sheets[w1];Sheets[w1]=NULL;}; 232 if(Sheets[w1]!=NULL) {delete Sheets[w1];Sheets[w1]=NULL;};
233 }; 233 };
234 XFRecords.resize(0); 234 XFRecords.resize(0);
235 SharedStrings.resize(0); 235 SharedStrings.resize(0);
236 Names.resize(0); 236 Names.resize(0);
237 Sheets.resize(0); 237 Sheets.resize(0);
238 fclose(File); 238 fclose(File);
239 printf("closed excel file!\r\n"); 239 printf("closed excel file!\r\n");
240 if(File==NULL) return true; 240 if(File==NULL) return true;
241 return false; 241 return false;
242}; 242};
243 243
244void ExcelBook::SeekPosition(int pos) 244void ExcelBook::SeekPosition(int pos)
245{ 245{
246 if(!feof(File)) 246 if(!feof(File))
247 { 247 {
248 Position=pos; 248 Position=pos;
249 //printf("SeekPosition:Pos:%d\r\n",Position); 249 //printf("SeekPosition:Pos:%d\r\n",Position);
250 fseek(File,pos,SEEK_SET); 250 fseek(File,pos,SEEK_SET);
251 }; 251 };
252}; 252};
253 253
254void ExcelBook::SeekSkip(int pos) 254void ExcelBook::SeekSkip(int pos)
255{ 255{
256 if(!feof(File)) 256 if(!feof(File))
257 { 257 {
258 Position=Position+pos; 258 Position=Position+pos;
259 //printf("SeekSkip:Pos:%d\r\n",Position); 259 //printf("SeekSkip:Pos:%d\r\n",Position);
260 fseek(File, Position, SEEK_SET); 260 fseek(File, Position, SEEK_SET);
261 }; 261 };
262}; 262};
263 263
264int ExcelBook::FileEOF(void) 264int ExcelBook::FileEOF(void)
265{ 265{
266 if(File!=NULL) return(feof(File)); else return 0; 266 if(File!=NULL) return(feof(File)); else return 0;
267 //EOF is defined in stdlib as -1 267 //EOF is defined in stdlib as -1
268}; 268};
269 269
270int ExcelBook::Get2Bytes(void) 270int ExcelBook::Get2Bytes(void)
271{ 271{
272 int i1,i2; 272 int i1,i2;
273 i1=0; i2=0; 273 i1=0; i2=0;
274 if (!feof(File)) 274 if (!feof(File))
275 { 275 {
276 i1=fgetc(File); 276 i1=fgetc(File);
277 Position++; 277 Position++;
278 }; 278 };
279 if (!feof(File)) 279 if (!feof(File))
280 { 280 {
281 i2=fgetc(File); 281 i2=fgetc(File);
282 Position++; 282 Position++;
283 }; 283 };
284 return Integer2Byte(i1,i2); 284 return Integer2Byte(i1,i2);
285}; 285};
286 286
287char* ExcelBook::Read(int pos, int length) 287char* ExcelBook::Read(int pos, int length)
288{ 288{
289 int i; 289 int i;
290 char *data; 290 char *data;
291 data= new char[length]; 291 data= new char[length];
292 SeekPosition(pos); 292 SeekPosition(pos);
293 for(i=0; i<length; i++) 293 for(i=0; i<length; i++)
294 { 294 {
295 if(!feof(File)) data[i]=fgetc(File); 295 if(!feof(File)) data[i]=fgetc(File);
296 }; 296 };
297 Position= Position+length; 297 Position= Position+length;
298 return data; 298 return data;
299}; 299};
300 300
301QString ExcelBook::ReadUnicodeChar(int pos, int length) 301QString ExcelBook::ReadUnicodeChar(int pos, int length)
302{ 302{
303 int i; 303 int i;
304 QString data; 304 QString data;
305 int i1=' ',i2=' ',ii; 305 int i1=' ',i2=' ',ii;
306 SeekPosition(pos); 306 SeekPosition(pos);
307 for(i=0; i<length; i++) 307 for(i=0; i<length; i++)
308 { 308 {
309 if(!feof(File)) i1=fgetc(File); 309 if(!feof(File)) i1=fgetc(File);
310 if(!feof(File)) i2=fgetc(File); 310 if(!feof(File)) i2=fgetc(File);
311 ii=Integer2Byte(i1,i2); 311 ii=Integer2Byte(i1,i2);
312 data.append(ii); 312 data.append(ii);
313 Position+=2; 313 Position+=2;
314 }; 314 };
315 return data; 315 return data;
316}; 316};
317 317
318QString* ExcelBook::GetString(int num) 318QString* ExcelBook::GetString(int num)
319{ 319{
320 if(num>=0 && num<(int)SharedStrings.count()) 320 if(num>=0 && num<(int)SharedStrings.count())
321 { 321 {
322 return SharedStrings[num]; 322 return SharedStrings[num];
323 }; 323 };
324 return new QString(""); 324 return new QString("");
325}; 325};
326 326
327int ExcelBook::SeekBOF(void) 327int ExcelBook::SeekBOF(void)
328{ 328{
329 int opcode,version,streamtype,length,ret=0; 329 int opcode,version,streamtype,length,ret=0;
330 char *data; 330 char *data;
331 while(!feof(File)) 331 while(!feof(File))
332 { 332 {
333 opcode=Get2Bytes(); 333 opcode=Get2Bytes();
334 if(opcode==XL_BOF) 334 if(opcode==XL_BOF)
335 { 335 {
336 length=Get2Bytes(); 336 length=Get2Bytes();
337 data=Read(Position,length); 337 data=Read(Position,length);
338 version=Integer2Byte(data[0], data[1]); 338 version=Integer2Byte(data[0], data[1]);
339 streamtype=Integer2Byte(data[2], data[3]); 339 streamtype=Integer2Byte(data[2], data[3]);
340 printf("SEEKBOF:opcode=XLBOF, %d ,version %d\r\n",Position,version); 340 printf("SEEKBOF:opcode=XLBOF, %d ,version %d\r\n",Position,version);
341 delete data; data=NULL; 341 delete data; data=NULL;
342 if (version==BIFF8) ret=8; 342 if (version==BIFF8) ret=8;
343 else if(version==BIFF7) ret=7; 343 else if(version==BIFF7) ret=7;
344 printf("SEEKBOF:versionBIFF%d\r\n",ret); 344 printf("SEEKBOF:versionBIFF%d\r\n",ret);
345 if(streamtype==WBKGLOBAL) return ret *2; 345 if(streamtype==WBKGLOBAL) return ret *2;
346 else if(streamtype==WRKSHEET) return ret *1; 346 else if(streamtype==WRKSHEET) return ret *1;
347 return 1; 347 return 1;
348 }; 348 };
349 }; 349 };
350 return 0; 350 return 0;
351}; 351};
352 352
353ExcelBREC* ExcelBook::GetBREC(void) 353ExcelBREC* ExcelBook::GetBREC(void)
354{ 354{
355 ExcelBREC* rec; 355 ExcelBREC* rec;
356 rec= new ExcelBREC; 356 rec= new ExcelBREC;
357 if(FileEOF()) return NULL; 357 if(FileEOF()) return NULL;
358 rec->data=NULL; 358 rec->data=NULL;
359 rec->code=Get2Bytes(); 359 rec->code=Get2Bytes();
360 rec->length=Get2Bytes(); 360 rec->length=Get2Bytes();
361 rec->position=Position; 361 rec->position=Position;
362 SeekSkip(rec->length); 362 SeekSkip(rec->length);
363 return rec; 363 return rec;
364}; 364};
365 365
366ExcelBREC* ExcelBook::PeekBREC(void) 366ExcelBREC* ExcelBook::PeekBREC(void)
367{ 367{
368 int oldpos; 368 int oldpos;
369 ExcelBREC* NextRec; 369 ExcelBREC* NextRec;
370 oldpos=Position; 370 oldpos=Position;
371 NextRec=GetBREC(); 371 NextRec=GetBREC();
372 SeekPosition(oldpos); 372 SeekPosition(oldpos);
373 return NextRec; 373 return NextRec;
374}; 374};
375 375
376char* ExcelBook::GetDataOfBREC(ExcelBREC* record) 376char* ExcelBook::GetDataOfBREC(ExcelBREC* record)
377{ 377{
378 if(record->data==NULL) 378 if(record->data==NULL)
379 { 379 {
380 ConvertCharToArray(record,Read(record->position,record->length),record->length); 380 ConvertCharToArray(record,Read(record->position,record->length),record->length);
381 }; 381 };
382 return record->data;//new? 382 return record->data;//new?
383}; 383};
384 384
385void ExcelBook::ConvertCharToArray(ExcelBREC* record, char* chars, int length) 385void ExcelBook::ConvertCharToArray(ExcelBREC* record, char* chars, int length)
386{ 386{
387 record->data=new char[length]; 387 record->data=new char[length];
388 for(int w1=0;w1<=length-1;w1++) 388 for(int w1=0;w1<=length-1;w1++)
389 record->data[w1]=chars[w1]; 389 record->data[w1]=chars[w1];
390}; 390};
391 391
392 392
393bool ExcelSheet::InitCells() 393bool ExcelSheet::InitCells()
394{ 394{
395 int r; 395 int r;
396 Cells.resize(rows * cols + cols+1); 396 Cells.resize(rows * cols + cols+1);
397 if(Cells.count()==0) return false; 397 if(Cells.count()==0) return false;
398 for(r=0;r < Cells.count();r++) 398 for(r=0;r < Cells.count();r++)
399 { 399 {
400 Cells[r]=NULL; 400 Cells[r]=NULL;
401 }; 401 };
402 return true; 402 return true;
403}; 403};
404 404
405void ExcelSheet::Set(int row, int col, ExcelCell* cell) 405void ExcelSheet::Set(int row, int col, ExcelCell* cell)
406{ 406{
407 if(cell!=NULL&&(row*cols+col)<Cells.count()) 407 if(cell!=NULL&&(row*cols+col)<Cells.count())
408 { 408 {
409 Cells[row*cols+col]=cell; 409 Cells[row*cols+col]=cell;
410 }; 410 };
411}; 411};
412 412
413ExcelCell* ExcelSheet::Get(int row, int col) 413ExcelCell* ExcelSheet::Get(int row, int col)
414{ 414{
415 ExcelCell* cell; 415 ExcelCell* cell;
416 cell=Cells[row*cols+col]; 416 cell=Cells[row*cols+col];
417 if(cell==NULL) return NULL; 417 if(cell==NULL) return NULL;
418 return cell; 418 return cell;
419}; 419};
420 420
421int ExcelBook::SheetHandleRecord(ExcelSheet* sheet, ExcelBREC* record) 421int ExcelBook::SheetHandleRecord(ExcelSheet* sheet, ExcelBREC* record)
422{ 422{
423 char* data=NULL; 423 char* data=NULL;
424 switch (record->code) 424 switch (record->code)
425 { 425 {
426 case XL_DIMENSION: 426 case XL_DIMENSION:
427 data = GetDataOfBREC(record); 427 data = GetDataOfBREC(record);
428 if (record->length == 10) 428 if (record->length == 10)
429 { 429 {
430 sheet->rows = Integer2Byte(data[2], data[3]); 430 sheet->rows = Integer2Byte(data[2], data[3]);
431 sheet->cols = Integer2Byte(data[6], data[7]); 431 sheet->cols = Integer2Byte(data[6], data[7]);
432 } 432 }
433 else 433 else
434 { 434 {
435 sheet->rows = Integer4Byte(data[4], data[5], data[6], data[7]); 435 sheet->rows = Integer4Byte(data[4], data[5], data[6], data[7]);
436 sheet->cols = Integer2Byte(data[10], data[11]); 436 sheet->cols = Integer2Byte(data[10], data[11]);
437 } 437 }
438 sheet->InitCells(); 438 sheet->InitCells();
439 break; 439 break;
440 440
441 case XL_LABELSST: 441 case XL_LABELSST:
442 HandleLabelSST(sheet, record); 442 HandleLabelSST(sheet, record);
443 break; 443 break;
444 444
445 case XL_RK: 445 case XL_RK:
446 case XL_RK2: 446 case XL_RK2:
447 HandleRK(sheet, record); 447 HandleRK(sheet, record);
448 break; 448 break;
449 449
450 case XL_MULRK: 450 case XL_MULRK:
451 HandleMulrk(sheet, record); 451 HandleMulrk(sheet, record);
452 break; 452 break;
453 453
454 case XL_ROW: 454 case XL_ROW:
455 break; 455 break;
456 456
457 case XL_NUMBER: 457 case XL_NUMBER:
458 HandleNumber(sheet, record); 458 HandleNumber(sheet, record);
459 break; 459 break;
460 460
461 case XL_BOOLERR: 461 case XL_BOOLERR:
462 break; 462 break;
463 463
464 case XL_CONTINUE: 464 case XL_CONTINUE:
465 break; 465 break;
466 466
467 case XL_FORMULA: 467 case XL_FORMULA:
468 case XL_FORMULA2: 468 case XL_FORMULA2:
469 HandleFormula(sheet, record); 469 HandleFormula(sheet, record);
470 break; 470 break;
471 471
472 case XL_LABEL: 472 case XL_LABEL:
473 break; 473 break;
474 474
475 case XL_NAME: 475 case XL_NAME:
476 HandleName(sheet, record); 476 HandleName(sheet, record);
477 break; 477 break;
478 478
479 case XL_BOF: 479 case XL_BOF:
480 break; 480 break;
481 case XL_EOF: 481 case XL_EOF:
482 return 0; 482 return 0;
483 default: 483 default:
484 break; 484 break;
485 }; 485 };
486 return 1; 486 return 1;
487}; 487};
488 488
489int ExcelBook::ReadSheet(ExcelSheet* sheet) 489int ExcelBook::ReadSheet(ExcelSheet* sheet)
490{ 490{
491 ExcelBREC* record; 491 ExcelBREC* record;
492 int oldpos; 492 int oldpos;
493 oldpos = Position; 493 oldpos = Position;
494 SeekPosition(sheet->position); 494 SeekPosition(sheet->position);
495 record = GetBREC(); 495 record = GetBREC();
496 while (record!=NULL) 496 while (record!=NULL)
497 { 497 {
498 if (!SheetHandleRecord(sheet, record)) break; 498 if (!SheetHandleRecord(sheet, record)) break;
499 record=GetBREC(); 499 record=GetBREC();
500 }; 500 };
501 SeekPosition(oldpos); 501 SeekPosition(oldpos);
502 return 1; 502 return 1;
503}; 503};
504 504
505ExcelSheet* ExcelBook::GetSheet(void) 505ExcelSheet* ExcelBook::GetSheet(void)
506{ 506{
507 ExcelSheet* sh=NULL; 507 ExcelSheet* sh=NULL;
508 int type; 508 int type;
509 type=SeekBOF(); 509 type=SeekBOF();
510 Version=type; 510 Version=type;
511 sh=new ExcelSheet; 511 sh=new ExcelSheet;
512 if(type) 512 if(type)
513 { 513 {
514 sh->type=type; 514 sh->type=type;
515 sh->position=Position; 515 sh->position=Position;
516 sh->name=QString(""); 516 sh->name=QString("");
517 }; 517 };
518 if(type==8||type==7) 518 if(type==8||type==7)
519 { 519 {
520 ReadSheet(sh); 520 ReadSheet(sh);
521 }; 521 };
522 return sh; 522 return sh;
523}; 523};
524 524
525void ExcelBook::ParseSheets(void) 525void ExcelBook::ParseSheets(void)
526{ 526{
527 int BOFs; 527 int BOFs;
528 ExcelBREC* r; 528 ExcelBREC* r;
529 BOFs=1; 529 BOFs=1;
530 r=GetBREC(); 530 r=GetBREC();
531 while(BOFs) 531 while(BOFs)
532 { 532 {
533 r=GetBREC(); 533 r=GetBREC();
534 switch(r->code) 534 switch(r->code)
535 { 535 {
536 case XL_SST: 536 case XL_SST:
537 HandleSST(r); 537 HandleSST(r);
538 break; 538 break;
539 539
540 case XL_TXO: 540 case XL_TXO:
541 break; 541 break;
542 case XL_NAME: 542 case XL_NAME:
543 break; 543 break;
544 case XL_ROW: 544 case XL_ROW:
545 break; 545 break;
546 546
547 case XL_FORMAT: 547 case XL_FORMAT:
548 HandleFormat(r); 548 HandleFormat(r);
549 break; 549 break;
550 550
551 case XL_XF: 551 case XL_XF:
552 HandleXF(r); 552 HandleXF(r);
553 break; 553 break;
554 554
555 case XL_BOUNDSHEET: 555 case XL_BOUNDSHEET:
556 HandleBoundSheet(r); 556 HandleBoundSheet(r);
557 break; 557 break;
558 558
559 case XL_EXTSST: 559 case XL_EXTSST:
560 break; 560 break;
561 case XL_CONTINUE: 561 case XL_CONTINUE:
562 break; 562 break;
563 563
564 case XL_EOF: 564 case XL_EOF:
565 BOFs--; 565 BOFs--;
566 break; 566 break;
567 567
568 default: 568 default:
569 break; 569 break;
570 }; 570 };
571 }; 571 };
572}; 572};
573 573
574void ExcelBook::GetSheets(void) 574void ExcelBook::GetSheets(void)
575{ 575{
576 ExcelSheet* sheet; 576 ExcelSheet* sheet;
577 Sheets.resize(0); 577 Sheets.resize(0);
578 sheet=GetSheet(); 578 sheet=GetSheet();
579 while (sheet->Cells.count()!= 0 ) 579 while (sheet->Cells.count()!= 0 )
580 { 580 {
581 Sheets.resize(Sheets.count()+1); 581 Sheets.resize(Sheets.count()+1);
582 Sheets[Sheets.count()-1]=sheet; 582 Sheets[Sheets.count()-1]=sheet;
583 sheet->name=*Names[Sheets.count()-1]; 583 sheet->name=*Names[Sheets.count()-1];
584 sheet=GetSheet(); 584 sheet=GetSheet();
585 }; 585 };
586}; 586};
587 587
588bool ExcelBook::ParseBook(char *file) 588bool ExcelBook::ParseBook(char *file)
589{ 589{
590 dateformat=QString(""); 590 dateformat=QString("");
591 DetectEndian(); 591 DetectEndian();
592 OpenFile(file); 592 if ( !OpenFile( file ) )
593 return false;
593 SeekBOF(); 594 SeekBOF();
594 ParseSheets(); 595 ParseSheets();
595 GetSheets(); 596 GetSheets();
596 return true; 597 return true;
597}; 598};
598 599
599QString ExcelBook::GetASCII(char* inbytes, int pos, int chars) 600QString ExcelBook::GetASCII(char* inbytes, int pos, int chars)
600{ 601{
601 int i; 602 int i;
602 QString outstr=""; 603 QString outstr="";
603 for (i = 0; i < chars; i++) 604 for (i = 0; i < chars; i++)
604 { 605 {
605 outstr.append(inbytes[i+pos]); 606 outstr.append(inbytes[i+pos]);
606 }; 607 };
607 return outstr; 608 return outstr;
608}; 609};
609 610
610QString ExcelBook::GetUnicode(char * inbytes, int pos, int chars) 611QString ExcelBook::GetUnicode(char * inbytes, int pos, int chars)
611{ 612{
612 QString outstr=""; 613 QString outstr="";
613 int i; 614 int i;
614 int rc; 615 int rc;
615 for (i=0; i<chars*2; i++) 616 for (i=0; i<chars*2; i++)
616 { 617 {
617 rc=Integer2Byte(inbytes[i+pos],inbytes[i+pos+1]); 618 rc=Integer2Byte(inbytes[i+pos],inbytes[i+pos+1]);
618 outstr.append(QChar(rc)); 619 outstr.append(QChar(rc));
619 i++; 620 i++;
620 }; 621 };
621 return outstr; 622 return outstr;
622}; 623};
623 624
624 625
625void ExcelBook::HandleBoundSheet(ExcelBREC* rec) 626void ExcelBook::HandleBoundSheet(ExcelBREC* rec)
626{ 627{
627 char* data; 628 char* data;
628 int type; 629 int type;
629 int visibility; 630 int visibility;
630 int length; 631 int length;
631 int pos; 632 int pos;
632 QString name; 633 QString name;
633 pos = 8; 634 pos = 8;
634 data = GetDataOfBREC(rec); 635 data = GetDataOfBREC(rec);
635 type = data[4]; 636 type = data[4];
636 visibility = data[5]; 637 visibility = data[5];
637 length = data[6]; 638 length = data[6];
638 if(data[7]==0) 639 if(data[7]==0)
639 { 640 {
640 //ascii 641 //ascii
641 name=GetASCII(data,pos,length); 642 name=GetASCII(data,pos,length);
642 } 643 }
643 else 644 else
644 { 645 {
645 name=GetUnicode(data,pos,length); 646 name=GetUnicode(data,pos,length);
646 }; 647 };
647 Names.resize(Names.count()+1); 648 Names.resize(Names.count()+1);
648 Names[Names.count()-1]=new QString(name); 649 Names[Names.count()-1]=new QString(name);
649}; 650};
650 651
651void ExcelBook::HandleName(ExcelSheet* sheet, ExcelBREC* rec) 652void ExcelBook::HandleName(ExcelSheet* sheet, ExcelBREC* rec)
652{ 653{
653 char* data; 654 char* data;
654 QString name; 655 QString name;
655 int length; 656 int length;
656 int pos; 657 int pos;
657 pos = 15; 658 pos = 15;
658 data = GetDataOfBREC(rec); 659 data = GetDataOfBREC(rec);
659 length = data[3]; 660 length = data[3];
660 name = GetASCII(data,pos,length); 661 name = GetASCII(data,pos,length);
661 662
662 663
663}; 664};
664 665
665ExcelFormat* ExcelBook::GetFormatting(int xf) 666ExcelFormat* ExcelBook::GetFormatting(int xf)
666{ 667{
667 int i; 668 int i;
668 ExcelFormat* rec; 669 ExcelFormat* rec;
669 rec=new ExcelFormat(); 670 rec=new ExcelFormat();
670 for (i = 0; formatter[i].code != 0; i++) 671 for (i = 0; formatter[i].code != 0; i++)
671 { 672 {
672 if (xf == formatter[i].code) break; 673 if (xf == formatter[i].code) break;
673 }; 674 };
674 if (formatter[i].format ==NULL) return NULL; 675 if (formatter[i].format ==NULL) return NULL;
675 rec->code = xf; 676 rec->code = xf;
676 rec->type = formatter[i].type; 677 rec->type = formatter[i].type;
677 rec->format = formatter[i].format; 678 rec->format = formatter[i].format;
678 return rec; 679 return rec;
679}; 680};
680 681
681void ExcelBook::HandleSetOfSST(ExcelBREC* rec/*, SSTList* cont*/, char* bytes) 682void ExcelBook::HandleSetOfSST(ExcelBREC* rec/*, SSTList* cont*/, char* bytes)
682{ 683{
683 QString str=QString(""); 684 QString str=QString("");
684 char* data; 685 char* data;
685 int chars, pos, options, i; 686 int chars, pos, options, i;
686 int richstring, fareaststring, runlength=0; 687 int richstring, fareaststring, runlength=0;
687 int richruns=0,fareastsize=0; 688 int richruns=0,fareastsize=0;
688 int totalstrings; 689 int totalstrings;
689 int uniquestrings; 690 int uniquestrings;
690 data = GetDataOfBREC(rec); 691 data = GetDataOfBREC(rec);
691 totalstrings = Integer4Byte(data[0], data[1], data[2], data[3]); 692 totalstrings = Integer4Byte(data[0], data[1], data[2], data[3]);
692 uniquestrings = Integer4Byte(data[4], data[5], data[6], data[7]); 693 uniquestrings = Integer4Byte(data[4], data[5], data[6], data[7]);
693 pos = 8; 694 pos = 8;
694 for (i = 0; i < uniquestrings; i++) 695 for (i = 0; i < uniquestrings; i++)
695 { 696 {
696 richruns=0; fareastsize=0; 697 richruns=0; fareastsize=0;
697 chars = Integer2Byte(data[pos], data[pos+1]); 698 chars = Integer2Byte(data[pos], data[pos+1]);
698 pos += 2; 699 pos += 2;
699 options = data[pos]; 700 options = data[pos];
700 pos++; 701 pos++;
701 fareaststring = ((options & 0x04) != 0); 702 fareaststring = ((options & 0x04) != 0);
702 richstring = ((options & 0x08) != 0); 703 richstring = ((options & 0x08) != 0);
703 if(richstring) 704 if(richstring)
704 { 705 {
705 richruns= Integer2Byte(data[pos],data[pos+1]); 706 richruns= Integer2Byte(data[pos],data[pos+1]);
706 pos+=2; 707 pos+=2;
707 }; 708 };
708 if(fareaststring) 709 if(fareaststring)
709 { 710 {
710 fareastsize=Integer4Byte(data[pos], data[pos+1], data[pos+2], data[pos+3]); 711 fareastsize=Integer4Byte(data[pos], data[pos+1], data[pos+2], data[pos+3]);
711 pos+=4; 712 pos+=4;
712 }; 713 };
713 714
714 if ((options & 0x01) == 0) //8 bit chars 715 if ((options & 0x01) == 0) //8 bit chars
715 { 716 {
716 /* ascii */ 717 /* ascii */
717 str = GetASCII(bytes,pos,chars); 718 str = GetASCII(bytes,pos,chars);
718 pos=pos+chars; 719 pos=pos+chars;
719 if(str[0]=='=') str[0]=' '; 720 if(str[0]=='=') str[0]=' ';
720 }else //16 bit chars 721 }else //16 bit chars
721 { 722 {
722 /* unicode */ 723 /* unicode */
723 str = GetUnicode(bytes,pos,chars); 724 str = GetUnicode(bytes,pos,chars);
724 pos=pos+chars*2; 725 pos=pos+chars*2;
725 }; 726 };
726 // HERE TO PUT richformat handling 727 // HERE TO PUT richformat handling
727 if (richstring) 728 if (richstring)
728 { 729 {
729 pos += 4 * richruns; 730 pos += 4 * richruns;
730 }; 731 };
731 if (fareaststring) 732 if (fareaststring)
732 { 733 {
733 pos += fareastsize; 734 pos += fareastsize;
734 }; 735 };
735 //printf("String=%s, length=%d first=0x%x\r\n",str.ascii(),str.length(),str[0].unicode()); 736 //printf("String=%s, length=%d first=0x%x\r\n",str.ascii(),str.length(),str[0].unicode());
736 SharedStrings.resize(SharedStrings.count()+1); 737 SharedStrings.resize(SharedStrings.count()+1);
737 SharedStrings[SharedStrings.count()-1]=new QString(str); 738 SharedStrings[SharedStrings.count()-1]=new QString(str);
738 } 739 }
739}; 740};
740 741
741 742
742char* ExcelBook::MergeBytesFromSSTs(ExcelBREC* rec,SSTList* cont) 743char* ExcelBook::MergeBytesFromSSTs(ExcelBREC* rec,SSTList* cont)
743{ 744{
744 int i, pos; 745 int i, pos;
745 int length; 746 int length;
746 747
747 char* data; 748 char* data;
748 char* bytes; 749 char* bytes;
749 length = rec->length; 750 length = rec->length;
750 for (i = 0; i < (int) cont->rec.count(); i++) 751 for (i = 0; i < (int) cont->rec.count(); i++)
751 { 752 {
752 length += cont->rec[i]->length; 753 length += cont->rec[i]->length;
753 } 754 }
754 bytes = GetDataOfBREC(rec); 755 bytes = GetDataOfBREC(rec);
755 pos = rec->length; 756 pos = rec->length;
756 for (i = 0; i < (int) cont->rec.count(); i++) 757 for (i = 0; i < (int) cont->rec.count(); i++)
757 { 758 {
758 data = GetDataOfBREC(cont->rec[i]); 759 data = GetDataOfBREC(cont->rec[i]);
759 *bytes += pos; 760 *bytes += pos;
760 bytes = data; 761 bytes = data;
761 pos += cont->rec[i]->length; 762 pos += cont->rec[i]->length;
762 } 763 }
763 return bytes; 764 return bytes;
764}; 765};
765 766
766 767
767void ExcelBook::HandleSST(ExcelBREC* rec) 768void ExcelBook::HandleSST(ExcelBREC* rec)
768{ 769{
769 char* bytes; 770 char* bytes;
770 SSTList* cont; 771 SSTList* cont;
771 cont= new SSTList; 772 cont= new SSTList;
772 ExcelBREC* nr; 773 ExcelBREC* nr;
773 nr = PeekBREC(); 774 nr = PeekBREC();
774 while (nr->code == XL_CONTINUE) 775 while (nr->code == XL_CONTINUE)
775 { 776 {
776 cont->rec.resize(cont->rec.count()+1); 777 cont->rec.resize(cont->rec.count()+1);
777 cont->rec[cont->rec.count()-1]=GetBREC(); 778 cont->rec[cont->rec.count()-1]=GetBREC();
778 nr = PeekBREC(); 779 nr = PeekBREC();
779 } 780 }
780 bytes = MergeBytesFromSSTs(rec,cont); 781 bytes = MergeBytesFromSSTs(rec,cont);
781 HandleSetOfSST(rec, bytes); 782 HandleSetOfSST(rec, bytes);
782 for(int w1=0;w1<(int)cont->rec.count();w1++) 783 for(int w1=0;w1<(int)cont->rec.count();w1++)
783 { 784 {
784 if(cont->rec[w1]!=NULL) {delete cont->rec[w1];cont->rec[w1]=NULL;}; 785 if(cont->rec[w1]!=NULL) {delete cont->rec[w1];cont->rec[w1]=NULL;};
785 }; 786 };
786 cont->rec.resize(0); 787 cont->rec.resize(0);
787}; 788};
788 789
789void ExcelBook::HandleLabelSST(ExcelSheet* sheet, ExcelBREC* rec) 790void ExcelBook::HandleLabelSST(ExcelSheet* sheet, ExcelBREC* rec)
790{ 791{
791 int index, row, col; 792 int index, row, col;
792 char* data; 793 char* data;
793 data = GetDataOfBREC(rec); 794 data = GetDataOfBREC(rec);
794 index = Integer4Byte(data[6], data[7], data[8], data[9]); 795 index = Integer4Byte(data[6], data[7], data[8], data[9]);
795 row = Integer2Byte(data[0], data[1]); 796 row = Integer2Byte(data[0], data[1]);
796 col = Integer2Byte(data[2], data[3]); 797 col = Integer2Byte(data[2], data[3]);
797 sheet->Set(row,col, CellLabel(row, col, *GetString(index))); 798 sheet->Set(row,col, CellLabel(row, col, *GetString(index)));
798}; 799};
799 800
800ExcelCell* ExcelBook::CellLabel(int row, int col, QString str) 801ExcelCell* ExcelBook::CellLabel(int row, int col, QString str)
801{ 802{
802 ExcelCell* c; 803 ExcelCell* c;
803 c= new ExcelCell; 804 c= new ExcelCell;
804 c->row = row; 805 c->row = row;
805 c->col = col; 806 c->col = col;
806 c->type = CELL_LABEL; 807 c->type = CELL_LABEL;
807 c->valuec = str; 808 c->valuec = str;
808 return c; 809 return c;
809}; 810};
810 811
811ExcelCell* ExcelBook::CellNumber(int row, int col, int index, double d) 812ExcelCell* ExcelBook::CellNumber(int row, int col, int index, double d)
812{ 813{
813 ExcelCell* c; 814 ExcelCell* c;
814 c=new ExcelCell; 815 c=new ExcelCell;
815 c->row = row; 816 c->row = row;
816 c->col = col; 817 c->col = col;
817 c->xfindex = index; 818 c->xfindex = index;
818 c->type = CELL_NUMBER; 819 c->type = CELL_NUMBER;
819 c->valued = d; 820 c->valued = d;
820 return c; 821 return c;
821}; 822};
822 823
823QString* ExcelBook::CellDataString(ExcelSheet* sh, int row, int col) 824QString* ExcelBook::CellDataString(ExcelSheet* sh, int row, int col)
824{ 825{
825 time_t date; 826 time_t date;
826 struct tm *tmptr; 827 struct tm *tmptr;
827 ExcelCell* c; 828 ExcelCell* c;
828 char str[128]; 829 char str[128];
829 QString format; 830 QString format;
830 int precision; 831 int precision;
831 int utcOffsetDays = 25569; 832 int utcOffsetDays = 25569;
832 int sInADay = 24 * 60 * 60; 833 int sInADay = 24 * 60 * 60;
833 c = sh->Get(row,col); 834 c = sh->Get(row,col);
834 if (c == NULL) return new QString(""); 835 if (c == NULL) return new QString("");
835 switch (c->type) 836 switch (c->type)
836 { 837 {
837 case CELL_LABEL: 838 case CELL_LABEL:
838 return new QString(c->valuec); 839 return new QString(c->valuec);
839 case CELL_NUMBER: 840 case CELL_NUMBER:
840 if (XFRecords[c->xfindex]->type == DATEFORMAT) 841 if (XFRecords[c->xfindex]->type == DATEFORMAT)
841 { 842 {
842 843
843 format = XFRecords[c->xfindex]->format; 844 format = XFRecords[c->xfindex]->format;
844 date = (time_t) ((c->valued - utcOffsetDays) * sInADay); 845 date = (time_t) ((c->valued - utcOffsetDays) * sInADay);
845 tmptr = gmtime(&date); 846 tmptr = gmtime(&date);
846 if (dateformat) 847 if (dateformat)
847 { 848 {
848 strftime(str,1024,dateformat.ascii(),tmptr); 849 strftime(str,1024,dateformat.ascii(),tmptr);
849 } 850 }
850 else 851 else
851 { 852 {
852 strftime(str,1024,format.ascii(),tmptr); 853 strftime(str,1024,format.ascii(),tmptr);
853 }; 854 };
854 } 855 }
855 else 856 else
856 if (XFRecords[c->xfindex]->type == NUMBERFORMAT) 857 if (XFRecords[c->xfindex]->type == NUMBERFORMAT)
857 { 858 {
858 format = XFRecords[c->xfindex]->format; 859 format = XFRecords[c->xfindex]->format;
859 //sprintf(str,format.ascii(),c->valued); 860 //sprintf(str,format.ascii(),c->valued);
860 // the real format is ignored... 861 // the real format is ignored...
861 // because there is more work to be done in the field 862 // because there is more work to be done in the field
862 precision = CellGetPrecision(c->valued); 863 precision = CellGetPrecision(c->valued);
863 sprintf(str,"%.*f",precision,c->valued); 864 sprintf(str,"%.*f",precision,c->valued);
864 } 865 }
865 else 866 else
866 { 867 {
867 precision = CellGetPrecision(c->valued); 868 precision = CellGetPrecision(c->valued);
868 sprintf(str,"%.*f",precision,c->valued); 869 sprintf(str,"%.*f",precision,c->valued);
869 }; 870 };
870 break; 871 break;
871 case CELL_DATE: 872 case CELL_DATE:
872 break; 873 break;
873 case CELL_BOOLEAN: 874 case CELL_BOOLEAN:
874 break; 875 break;
875 case CELL_ERROR: 876 case CELL_ERROR:
876 break; 877 break;
877 } 878 }
878 return new QString(str); 879 return new QString(str);
879}; 880};
880 881
881int ExcelBook::CellGetPrecision(double d) 882int ExcelBook::CellGetPrecision(double d)
882{ 883{
883 double t; 884 double t;
884 int i,x; 885 int i,x;
885 int count; 886 int count;
886 if (d < 0) d *= -1; 887 if (d < 0) d *= -1;
887 i = (int)d; 888 i = (int)d;
888 t = d - (double)i; 889 t = d - (double)i;
889 if (t <= 0) 890 if (t <= 0)
890 { 891 {
891 return 0; 892 return 0;
892 }; 893 };
893 count = 0; 894 count = 0;
894 for (x = 6; x > 1; x--) 895 for (x = 6; x > 1; x--)
895 { 896 {
896 i = (int)d; 897 i = (int)d;
897 t = d - (double)i; 898 t = d - (double)i;
898 t *= pow(10,x - 2); 899 t *= pow(10,x - 2);
899 i = (int)t; 900 i = (int)t;
900 t = t - (double)i; 901 t = t - (double)i;
901 t *= 10; 902 t *= 10;
902 i = (int)t; 903 i = (int)t;
903 if (i > 0) break; 904 if (i > 0) break;
904 count++; 905 count++;
905 }; 906 };
906 return (5 - count); 907 return (5 - count);
907}; 908};
908 909
909 910
910void ExcelBook::CellSetDateFormat(char *d) 911void ExcelBook::CellSetDateFormat(char *d)
911{ 912{
912 dateformat = QString(d); 913 dateformat = QString(d);
913}; 914};
914 915
915void ExcelBook::HandleMulrk(ExcelSheet* sheet, ExcelBREC* record) 916void ExcelBook::HandleMulrk(ExcelSheet* sheet, ExcelBREC* record)
916{ 917{
917 struct mulrk mulrk; 918 struct mulrk mulrk;
918 char* data; 919 char* data;
919 ExcelCell* cell; 920 ExcelCell* cell;
920 int len; 921 int len;
921 int i; 922 int i;
922 len = record->length; 923 len = record->length;
923 data = GetDataOfBREC(record); 924 data = GetDataOfBREC(record);
924 mulrk.row = Integer2Byte(data[0],data[1]); 925 mulrk.row = Integer2Byte(data[0],data[1]);
925 mulrk.first = Integer2Byte(data[2],data[3]); 926 mulrk.first = Integer2Byte(data[2],data[3]);
926 mulrk.last = Integer2Byte(data[len - 2],data[len - 1]); 927 mulrk.last = Integer2Byte(data[len - 2],data[len - 1]);
927 mulrk.numrks = mulrk.last - mulrk.first + 1; 928 mulrk.numrks = mulrk.last - mulrk.first + 1;
928 MulrkRead(&mulrk, data); 929 MulrkRead(&mulrk, data);
929 for (i = 0; i < mulrk.numrks; i++) 930 for (i = 0; i < mulrk.numrks; i++)
930 { 931 {
931 cell = CellNumber(mulrk.row, mulrk.first + i, mulrk.xfindices[i], mulrk.rkdbls[i]); 932 cell = CellNumber(mulrk.row, mulrk.first + i, mulrk.xfindices[i], mulrk.rkdbls[i]);
932 sheet->Set(mulrk.row,mulrk.first+ i, cell); 933 sheet->Set(mulrk.row,mulrk.first+ i, cell);
933 //printf("handleMULRK:row=%d,col=%d,val=%f\r\n",mulrk.row,mulrk.first+i,mulrk.rkdbls[i]); 934 //printf("handleMULRK:row=%d,col=%d,val=%f\r\n",mulrk.row,mulrk.first+i,mulrk.rkdbls[i]);
934 } 935 }
935 //delete(mulrk.xfindices); 936 //delete(mulrk.xfindices);
936 //delete(mulrk.rkdbls); 937 //delete(mulrk.rkdbls);
937}; 938};
938 939
939void ExcelBook::MulrkRead(struct mulrk *mulrk, char* data) 940void ExcelBook::MulrkRead(struct mulrk *mulrk, char* data)
940{ 941{
941 double d; 942 double d;
942 int i; 943 int i;
943 int pos; 944 int pos;
944 pos = 4; 945 pos = 4;
945 mulrk->xfindices.resize(mulrk->numrks); 946 mulrk->xfindices.resize(mulrk->numrks);
946 mulrk->rkdbls.resize(mulrk->numrks); 947 mulrk->rkdbls.resize(mulrk->numrks);
947 for (i = 0; i < mulrk->numrks; i++) 948 for (i = 0; i < mulrk->numrks; i++)
948 { 949 {
949 mulrk->xfindices[i] = Integer2Byte(data[pos], data[pos+1]); 950 mulrk->xfindices[i] = Integer2Byte(data[pos], data[pos+1]);
950 d=Double4Byte(data[pos+2], data[pos+3], data[pos+4], data[pos+5]); 951 d=Double4Byte(data[pos+2], data[pos+3], data[pos+4], data[pos+5]);
951 //printf("double:%f\r\n",d); 952 //printf("double:%f\r\n",d);
952 mulrk->rkdbls[i] = d; 953 mulrk->rkdbls[i] = d;
953 pos += 6; 954 pos += 6;
954 } 955 }
955}; 956};
956 957
957 958
958void ExcelBook::HandleNumber(ExcelSheet* sheet, ExcelBREC* record) 959void ExcelBook::HandleNumber(ExcelSheet* sheet, ExcelBREC* record)
959{ 960{
960 int xfindex, row, col; 961 int xfindex, row, col;
961 char* data; 962 char* data;
962 double d; 963 double d;
963 data = GetDataOfBREC(record); 964 data = GetDataOfBREC(record);
964 row = Integer2Byte(data[0], data[1]); 965 row = Integer2Byte(data[0], data[1]);
965 col = Integer2Byte(data[2], data[3]); 966 col = Integer2Byte(data[2], data[3]);
966 xfindex = Integer2Byte(data[4], data[5]); 967 xfindex = Integer2Byte(data[4], data[5]);
967#if defined(__arm__) && !defined(__vfp__) 968#if defined(__arm__) && !defined(__vfp__)
968 d=Double8Byte(data[10], data[11], data[12], data[13],data[6], data[7], data[8], data[9]); 969 d=Double8Byte(data[10], data[11], data[12], data[13],data[6], data[7], data[8], data[9]);
969#else 970#else
970 d=Double8Byte(data[6], data[7], data[8], data[9],data[10], data[11], data[12], data[13]); 971 d=Double8Byte(data[6], data[7], data[8], data[9],data[10], data[11], data[12], data[13]);
971#endif 972#endif
972 //even if ARM is little endian... doubles are been placed as bigendian words. 973 //even if ARM is little endian... doubles are been placed as bigendian words.
973 //thanks pb_ for that. :) 974 //thanks pb_ for that. :)
974 sheet->Set(row,col, CellNumber(row,col,xfindex,d)); 975 sheet->Set(row,col, CellNumber(row,col,xfindex,d));
975 //printf("handleNumber:row=%d,col=%d,val=%f\r\n",row,col,d); 976 //printf("handleNumber:row=%d,col=%d,val=%f\r\n",row,col,d);
976}; 977};
977 978
978ExcelFormat::ExcelFormat() 979ExcelFormat::ExcelFormat()
979{ 980{
980 code=0;type=0;format=""; 981 code=0;type=0;format="";
981}; 982};
982 983
983ExcelFormat::ExcelFormat(int c,int t, QString s) 984ExcelFormat::ExcelFormat(int c,int t, QString s)
984{ 985{
985 code=c;type=t;format=s; 986 code=c;type=t;format=s;
986}; 987};
987 988
988 989
989void ExcelBook::HandleFormat(ExcelBREC* rec) 990void ExcelBook::HandleFormat(ExcelBREC* rec)
990{ 991{
991 ExcelFormat* xfrec; 992 ExcelFormat* xfrec;
992 char* data; 993 char* data;
993 int format; 994 int format;
994 data = GetDataOfBREC(rec); 995 data = GetDataOfBREC(rec);
995 format = Integer2Byte(data[2],data[3]); 996 format = Integer2Byte(data[2],data[3]);
996 xfrec = GetFormatting(format); 997 xfrec = GetFormatting(format);
997 /*int idx; 998 /*int idx;
998 idx=XFRecords.count()-1; 999 idx=XFRecords.count()-1;
999 XFRecords[idx]->code=xfrec->code; 1000 XFRecords[idx]->code=xfrec->code;
1000 XFRecords[idx]->type=xfrec->type; 1001 XFRecords[idx]->type=xfrec->type;
1001 XFRecords[idx]->format="manos"; 1002 XFRecords[idx]->format="manos";
1002 //XFRecords[XFRecords.count()-1]=xfrec; 1003 //XFRecords[XFRecords.count()-1]=xfrec;
1003 printf("6\r\n");*/ 1004 printf("6\r\n");*/
1004}; 1005};
1005 1006
1006void ExcelBook::HandleXF(ExcelBREC* rec) 1007void ExcelBook::HandleXF(ExcelBREC* rec)
1007{ 1008{
1008 ExcelFormat* xfrec; 1009 ExcelFormat* xfrec;
1009 char* data; 1010 char* data;
1010 int format; 1011 int format;
1011 data = GetDataOfBREC(rec); 1012 data = GetDataOfBREC(rec);
1012 format = Integer2Byte(data[2],data[3]); 1013 format = Integer2Byte(data[2],data[3]);
1013 xfrec = GetFormatting(format); 1014 xfrec = GetFormatting(format);
1014 XFRecords.resize(XFRecords.count()+1); 1015 XFRecords.resize(XFRecords.count()+1);
1015 XFRecords[XFRecords.count()-1]=xfrec; 1016 XFRecords[XFRecords.count()-1]=xfrec;
1016}; 1017};
1017 1018
1018 1019
1019 1020
1020void ExcelBook::HandleRK(ExcelSheet* sheet, ExcelBREC* record) 1021void ExcelBook::HandleRK(ExcelSheet* sheet, ExcelBREC* record)
1021{ 1022{
1022 int xfindex, row, col; 1023 int xfindex, row, col;
1023 char* data; 1024 char* data;
1024 double d; 1025 double d;
1025 data = GetDataOfBREC(record); 1026 data = GetDataOfBREC(record);
1026 row = Integer2Byte(data[0], data[1]); 1027 row = Integer2Byte(data[0], data[1]);
1027 col = Integer2Byte(data[2], data[3]); 1028 col = Integer2Byte(data[2], data[3]);
1028 xfindex = Integer2Byte(data[4], data[5]); 1029 xfindex = Integer2Byte(data[4], data[5]);
1029 d=Double4Byte(data[6], data[7], data[8], data[9]); 1030 d=Double4Byte(data[6], data[7], data[8], data[9]);
1030 sheet->Set(row,col,CellNumber(row,col,xfindex,d)); 1031 sheet->Set(row,col,CellNumber(row,col,xfindex,d));
1031 //printf("handleRK:row=%d,col=%d,val=%f\r\n",row,col,d); 1032 //printf("handleRK:row=%d,col=%d,val=%f\r\n",row,col,d);
1032}; 1033};
1033 1034
1034 1035
1035void ExcelBook::HandleFormula(ExcelSheet* sheet, ExcelBREC* record) 1036void ExcelBook::HandleFormula(ExcelSheet* sheet, ExcelBREC* record)
1036{ 1037{
1037 int xfindex, row, col; 1038 int xfindex, row, col;
1038 char* data; 1039 char* data;
1039 double d; 1040 double d;
1040 data = GetDataOfBREC(record); 1041 data = GetDataOfBREC(record);
1041 row = Integer2Byte(data[0], data[1]); 1042 row = Integer2Byte(data[0], data[1]);
1042 col = Integer2Byte(data[2], data[3]); 1043 col = Integer2Byte(data[2], data[3]);
1043 if (data[6] == 0 && data[12] == -1 && data[13] == -1) 1044 if (data[6] == 0 && data[12] == -1 && data[13] == -1)
1044 { 1045 {
1045 // string 1046 // string
1046 } 1047 }
1047 else 1048 else
1048 if (data[6] == 1 && data[12] == -1 && data[13] == -1) 1049 if (data[6] == 1 && data[12] == -1 && data[13] == -1)
1049 { 1050 {
1050 // boolean 1051 // boolean
1051 } 1052 }
1052 else 1053 else
1053 if ( data[6] == 2 && data[12] == -1 && data[13] == -1) 1054 if ( data[6] == 2 && data[12] == -1 && data[13] == -1)
1054 { 1055 {
1055 // error 1056 // error
1056 } 1057 }
1057 else 1058 else
1058 { 1059 {
1059 // number 1060 // number
1060 xfindex = Integer2Byte(data[4], data[5]); 1061 xfindex = Integer2Byte(data[4], data[5]);
1061 d=Double8Byte(data[6], data[7], data[8], data[9],data[10], data[11], data[12], data[13]); 1062 d=Double8Byte(data[6], data[7], data[8], data[9],data[10], data[11], data[12], data[13]);
1062 QString s1; 1063 QString s1;
1063 int sz; 1064 int sz;
1064 sz=Integer2Byte(data[20],data[21]);// size of the formula 1065 sz=Integer2Byte(data[20],data[21]);// size of the formula
1065 char* formuladata; 1066 char* formuladata;
1066 formuladata=new char[sz]; 1067 formuladata=new char[sz];
1067 for(int w1=0;w1<sz;w1++) 1068 for(int w1=0;w1<sz;w1++)
1068 { 1069 {
1069 formuladata[w1]=data[22+w1]; 1070 formuladata[w1]=data[22+w1];
1070 }; 1071 };
1071 //22 is the first 0 idx of formula data 1072 //22 is the first 0 idx of formula data
1072 s1="="+GetFormula(row,col,sheet,formuladata,sz); 1073 s1="="+GetFormula(row,col,sheet,formuladata,sz);
1073 //printf("GetFormula:Formula=%s\r\n",s1.ascii()); 1074 //printf("GetFormula:Formula=%s\r\n",s1.ascii());
1074 sheet->Set(row,col,CellLabel(row,col,s1)); 1075 sheet->Set(row,col,CellLabel(row,col,s1));
1075 } 1076 }
1076}; 1077};
1077 1078
1078 1079
1079QString ExcelBook::GetFormula(int row, int col, ExcelSheet* sheet, char* data, int sz) 1080QString ExcelBook::GetFormula(int row, int col, ExcelSheet* sheet, char* data, int sz)
1080{ 1081{
1081 int length=sz; 1082 int length=sz;
1082 printf("{FormulaParser}\r\n"); 1083 printf("{FormulaParser}\r\n");
1083 printf("row=%d, col=%d, length=%d\r\n",row,col,length); 1084 printf("row=%d, col=%d, length=%d\r\n",row,col,length);
1084 int idx=0; 1085 int idx=0;
1085 int w1,w2,w3,w4; 1086 int w1,w2,w3,w4;
1086 double d1; 1087 double d1;
1087 int token; 1088 int token;
1088 QString s1; 1089 QString s1;
1089 QList <QString> operands; 1090 QList <QString> operands;
1090 operands.setAutoDelete(TRUE); 1091 operands.setAutoDelete(TRUE);
1091 QString formula; 1092 QString formula;
1092 operands.clear(); 1093 operands.clear();
1093 while( idx<length ) 1094 while( idx<length )
1094 { 1095 {
1095 token= data[idx]; idx++; 1096 token= data[idx]; idx++;
1096 switch(token) 1097 switch(token)
1097 { 1098 {
1098 case 0x1E: //prtInt 1099 case 0x1E: //prtInt
1099 w1=Integer2Byte(data[idx],data[idx+1]); 1100 w1=Integer2Byte(data[idx],data[idx+1]);
1100 idx=idx+2; 1101 idx=idx+2;
1101 operands.prepend(new QString(QString::number(w1))); 1102 operands.prepend(new QString(QString::number(w1)));
1102 printf(" token:ptgInt,num=%d\r\n",w1); 1103 printf(" token:ptgInt,num=%d\r\n",w1);
1103 break; 1104 break;
1104 case 0x1F: //ptgNumber 1105 case 0x1F: //ptgNumber
1105#if defined(__arm__) && !defined(__vfp__) 1106#if defined(__arm__) && !defined(__vfp__)
1106 d1=Double8Byte(data[idx+4],data[idx+5],data[idx+6],data[idx+7] 1107 d1=Double8Byte(data[idx+4],data[idx+5],data[idx+6],data[idx+7]
1107 ,data[idx],data[idx+1],data[idx+2],data[idx+3]); 1108 ,data[idx],data[idx+1],data[idx+2],data[idx+3]);
1108#else 1109#else
1109 d1=Double8Byte(data[idx],data[idx+1],data[idx+2],data[idx+3] 1110 d1=Double8Byte(data[idx],data[idx+1],data[idx+2],data[idx+3]
1110 ,data[idx+4],data[idx+5],data[idx+6],data[idx+7]); 1111 ,data[idx+4],data[idx+5],data[idx+6],data[idx+7]);
1111#endif 1112#endif
1112 idx=idx+8; 1113 idx=idx+8;
1113 operands.prepend(new QString(QString::number(d1))); 1114 operands.prepend(new QString(QString::number(d1)));
1114 printf(" token:ptgNumber,num=%f\r\n",d1); 1115 printf(" token:ptgNumber,num=%f\r\n",d1);
1115 break; 1116 break;
1116 case 0x17: //ptgStr 1117 case 0x17: //ptgStr
1117 if(Version==8) 1118 if(Version==8)
1118 { 1119 {
1119 //unicode string 1120 //unicode string
1120 //w1=Integer2Byte(data[idx],data[idx+1]);idx+=2; 1121 //w1=Integer2Byte(data[idx],data[idx+1]);idx+=2;
1121 w1=data[idx];idx++; 1122 w1=data[idx];idx++;
1122 printf("len=%d\r\n",w1); 1123 printf("len=%d\r\n",w1);
1123 int richruns=0; int fareastsize=0; 1124 int richruns=0; int fareastsize=0;
1124 int richstring,fareaststring; 1125 int richstring,fareaststring;
1125 int options = data[idx];idx++; 1126 int options = data[idx];idx++;
1126 fareaststring = ((options & 0x04) != 0); 1127 fareaststring = ((options & 0x04) != 0);
1127 richstring = ((options & 0x08) != 0); 1128 richstring = ((options & 0x08) != 0);
1128 if(richstring) 1129 if(richstring)
1129 { 1130 {
1130 //containts rich string formatting. 1131 //containts rich string formatting.
1131 printf("STRING:richstring\r\n"); 1132 printf("STRING:richstring\r\n");
1132 richruns= Integer2Byte(data[idx],data[idx+1]); 1133 richruns= Integer2Byte(data[idx],data[idx+1]);
1133 printf("richruns:%d\r\n",richruns); 1134 printf("richruns:%d\r\n",richruns);
1134 idx+=2; 1135 idx+=2;
1135 }; 1136 };
1136 if(fareaststring) 1137 if(fareaststring)
1137 { 1138 {
1138 //contains far east formatting 1139 //contains far east formatting
1139 printf("STRING:fareast!\r\n"); 1140 printf("STRING:fareast!\r\n");
1140 fareastsize=Integer4Byte(data[idx], data[idx+1], 1141 fareastsize=Integer4Byte(data[idx], data[idx+1],
1141 data[idx+2], data[idx+3]); 1142 data[idx+2], data[idx+3]);
1142 printf("fareastsize=%d",fareastsize); 1143 printf("fareastsize=%d",fareastsize);
1143 idx+=4; 1144 idx+=4;
1144 }; 1145 };
1145 if ((options & 0x01) == 0) //8 bit chars 1146 if ((options & 0x01) == 0) //8 bit chars
1146 { 1147 {
1147 /* ascii */ 1148 /* ascii */
1148 s1 = GetASCII(data,idx,w1); 1149 s1 = GetASCII(data,idx,w1);
1149 idx=idx+w1; 1150 idx=idx+w1;
1150 printf("STRING:ASCII=%s\r\n",s1.ascii()); 1151 printf("STRING:ASCII=%s\r\n",s1.ascii());
1151 }else //16 bit chars 1152 }else //16 bit chars
1152 { 1153 {
1153 /* unicode */ 1154 /* unicode */
1154 s1 = GetUnicode(data,idx,w1); 1155 s1 = GetUnicode(data,idx,w1);
1155 idx=idx+w1*2; 1156 idx=idx+w1*2;
1156 printf("STRING:unicode=%s\r\n",s1.ascii()); 1157 printf("STRING:unicode=%s\r\n",s1.ascii());
1157 }; 1158 };
1158 // HERE TO PUT richformat handling 1159 // HERE TO PUT richformat handling
1159 if (richstring) 1160 if (richstring)
1160 { 1161 {
1161 idx += 4 * richruns; 1162 idx += 4 * richruns;
1162 }; 1163 };
1163 if (fareaststring) 1164 if (fareaststring)
1164 { 1165 {
1165 idx += fareastsize; 1166 idx += fareastsize;
1166 }; 1167 };
1167 s1=QString("""")+s1+QString(""""); 1168 s1=QString("""")+s1+QString("""");
1168 operands.prepend(new QString(s1)); 1169 operands.prepend(new QString(s1));
1169 } 1170 }
1170 else 1171 else
1171 { 1172 {
1172 w1=data[idx];idx++; 1173 w1=data[idx];idx++;
1173 s1=GetASCII(data,idx,w1); 1174 s1=GetASCII(data,idx,w1);
1174 s1=QString("""")+s1+QString(""""); 1175 s1=QString("""")+s1+QString("""");
1175 idx=idx+w1; 1176 idx=idx+w1;
1176 operands.prepend(new QString(s1)); 1177 operands.prepend(new QString(s1));
1177 }; 1178 };
1178 printf(" token:ptgStr,num=%d\r\n",w1); 1179 printf(" token:ptgStr,num=%d\r\n",w1);
1179 break; 1180 break;
1180 case 0x25: 1181 case 0x25:
1181 case 0x45: 1182 case 0x45:
1182 case 0x65: // ptgArea 1183 case 0x65: // ptgArea
1183 if(Version==8) 1184 if(Version==8)
1184 { 1185 {
1185 w1=Integer2Byte(data[idx],data[idx+1]);idx=idx+2;//row1 1186 w1=Integer2Byte(data[idx],data[idx+1]);idx=idx+2;//row1
1186 w2=Integer2Byte(data[idx],data[idx+1]);idx=idx+2;//row2 1187 w2=Integer2Byte(data[idx],data[idx+1]);idx=idx+2;//row2
1187 w3=Integer2Byte(data[idx],data[idx+1]) & 0x00FF;idx=idx+2;//col1 1188 w3=Integer2Byte(data[idx],data[idx+1]) & 0x00FF;idx=idx+2;//col1
1188 w4=Integer2Byte(data[idx],data[idx+1]) & 0x00FF;idx=idx+2;//col2 1189 w4=Integer2Byte(data[idx],data[idx+1]) & 0x00FF;idx=idx+2;//col2
1189 } 1190 }
1190 else 1191 else
1191 { 1192 {
1192 w1=Integer2Byte(data[idx],data[idx+1]) & 0x3FFF;idx=idx+2;//row1 1193 w1=Integer2Byte(data[idx],data[idx+1]) & 0x3FFF;idx=idx+2;//row1
1193 w2=Integer2Byte(data[idx],data[idx+1]) & 0x3FFF;idx=idx+2;//row2 1194 w2=Integer2Byte(data[idx],data[idx+1]) & 0x3FFF;idx=idx+2;//row2
1194 w3=Integer2Byte(data[idx],data[idx+1]);idx=idx+2;//col1 1195 w3=Integer2Byte(data[idx],data[idx+1]);idx=idx+2;//col1
1195 w4=Integer2Byte(data[idx],data[idx+1]);idx=idx+2;//col2 1196 w4=Integer2Byte(data[idx],data[idx+1]);idx=idx+2;//col2
1196 }; 1197 };
1197 //ignores relative or absolute refs 1198 //ignores relative or absolute refs
1198 s1=FindCellName(w1,w3)+":"+FindCellName(w2,w4); 1199 s1=FindCellName(w1,w3)+":"+FindCellName(w2,w4);
1199 printf(" token:ptgArea,ref=%s\r\n",s1.ascii()); 1200 printf(" token:ptgArea,ref=%s\r\n",s1.ascii());
1200 operands.prepend(new QString(s1)); 1201 operands.prepend(new QString(s1));
1201 break; 1202 break;
1202 case 0x24: 1203 case 0x24:
1203 case 0x44: 1204 case 0x44:
1204 case 0x64://ptgRef 1205 case 0x64://ptgRef
1205 if(Version==8) 1206 if(Version==8)
1206 { 1207 {
1207 w1=Integer2Byte(data[idx],data[idx+1]);idx=idx+2;//row 1208 w1=Integer2Byte(data[idx],data[idx+1]);idx=idx+2;//row
1208 w2=Integer2Byte(data[idx],data[idx+1]) & 0x00FF;idx=idx+2;//col 1209 w2=Integer2Byte(data[idx],data[idx+1]) & 0x00FF;idx=idx+2;//col
1209 } 1210 }
1210 else 1211 else
1211 { 1212 {
1212 w1=Integer2Byte(data[idx],data[idx+1]) & 0x3FFF;idx=idx+2;//row 1213 w1=Integer2Byte(data[idx],data[idx+1]) & 0x3FFF;idx=idx+2;//row
1213 w2=Integer2Byte(data[idx],data[idx+1]);idx=idx+2;//col 1214 w2=Integer2Byte(data[idx],data[idx+1]);idx=idx+2;//col
1214 }; 1215 };
1215 s1=FindCellName(w1,w2); 1216 s1=FindCellName(w1,w2);
1216 printf("token:ptgRef,ref=%s\r\n",s1.ascii()); 1217 printf("token:ptgRef,ref=%s\r\n",s1.ascii());
1217 operands.prepend(new QString(s1)); 1218 operands.prepend(new QString(s1));
1218 break; 1219 break;
1219 case 0x1D: // ptgBool 1220 case 0x1D: // ptgBool
1220 w1=data[idx];idx++; 1221 w1=data[idx];idx++;
1221 printf("token:ptgBool,val=%d\r\n",w1); 1222 printf("token:ptgBool,val=%d\r\n",w1);
1222 operands.prepend(new QString(QString::number(w1))); 1223 operands.prepend(new QString(QString::number(w1)));
1223 break; 1224 break;
1224 case 0x16://ptg MissArg 1225 case 0x16://ptg MissArg
1225 printf("token:ptgMissArg, val=' '\r\n"); 1226 printf("token:ptgMissArg, val=' '\r\n");
1226 operands.prepend(new QString("0")); 1227 operands.prepend(new QString("0"));
1227 break; 1228 break;
1228 case 0x12://ptgUplus== 1229 case 0x12://ptgUplus==
1229 printf("token:ptgUplus\r\n"); 1230 printf("token:ptgUplus\r\n");
1230 s1=QString("+")+operands.first()->ascii(); 1231 s1=QString("+")+operands.first()->ascii();
1231 operands.removeFirst(); 1232 operands.removeFirst();
1232 operands.prepend(new QString(s1)); 1233 operands.prepend(new QString(s1));
1233 break; 1234 break;
1234 case 0x13://ptgUminus 1235 case 0x13://ptgUminus
1235 printf("token:ptgUminus\r\n"); 1236 printf("token:ptgUminus\r\n");
1236 s1=QString("-")+operands.first()->ascii(); 1237 s1=QString("-")+operands.first()->ascii();
1237 operands.removeFirst(); 1238 operands.removeFirst();
1238 operands.prepend(new QString(s1)); 1239 operands.prepend(new QString(s1));
1239 break; 1240 break;
1240 case 0x03://ptgAdd 1241 case 0x03://ptgAdd
1241 printf("token:ptgAdd\r\n"); 1242 printf("token:ptgAdd\r\n");
1242 operands.first(); 1243 operands.first();
1243 s1=operands.next()->ascii() 1244 s1=operands.next()->ascii()
1244 +QString("+")+operands.first()->ascii(); 1245 +QString("+")+operands.first()->ascii();
1245 operands.removeFirst();operands.removeFirst(); 1246 operands.removeFirst();operands.removeFirst();
1246 operands.prepend(new QString(s1)); 1247 operands.prepend(new QString(s1));
1247 break; 1248 break;
1248 case 0x04://ptgSub 1249 case 0x04://ptgSub
1249 printf("token:ptgSub\r\n"); 1250 printf("token:ptgSub\r\n");
1250 operands.first(); 1251 operands.first();
1251 s1=operands.next()->ascii() 1252 s1=operands.next()->ascii()
1252 +QString("-")+operands.first()->ascii(); 1253 +QString("-")+operands.first()->ascii();
1253 operands.removeFirst();operands.removeFirst(); 1254 operands.removeFirst();operands.removeFirst();
1254 operands.prepend(new QString(s1)); 1255 operands.prepend(new QString(s1));
1255 break; 1256 break;
1256 case 0x05://ptgMul 1257 case 0x05://ptgMul
1257 printf("token:ptgMul\r\n"); 1258 printf("token:ptgMul\r\n");
1258 operands.first(); 1259 operands.first();
1259 s1=operands.next()->ascii() 1260 s1=operands.next()->ascii()
1260 +QString("*")+operands.first()->ascii(); 1261 +QString("*")+operands.first()->ascii();
1261 operands.removeFirst();operands.removeFirst(); 1262 operands.removeFirst();operands.removeFirst();
1262 operands.prepend(new QString(s1)); 1263 operands.prepend(new QString(s1));
1263 break; 1264 break;
1264 case 0x06://ptgDiv 1265 case 0x06://ptgDiv
1265 printf("token:ptgDiv\r\n"); 1266 printf("token:ptgDiv\r\n");
1266 operands.first(); 1267 operands.first();
1267 s1=operands.next()->ascii() 1268 s1=operands.next()->ascii()
1268 +QString("/")+operands.first()->ascii(); 1269 +QString("/")+operands.first()->ascii();
1269 operands.removeFirst();operands.removeFirst(); 1270 operands.removeFirst();operands.removeFirst();
1270 operands.prepend(new QString(s1)); 1271 operands.prepend(new QString(s1));
1271 break; 1272 break;
1272 case 0x07://ptgPOWER 1273 case 0x07://ptgPOWER
1273 printf("token:ptgPow\r\n"); 1274 printf("token:ptgPow\r\n");
1274 operands.first(); 1275 operands.first();
1275 s1=QString("POWER(")+operands.next()->ascii() 1276 s1=QString("POWER(")+operands.next()->ascii()
1276 +QString(",")+operands.first()->ascii()+QString(")"); 1277 +QString(",")+operands.first()->ascii()+QString(")");
1277 operands.removeFirst();operands.removeFirst(); 1278 operands.removeFirst();operands.removeFirst();
1278 operands.prepend(new QString(s1)); 1279 operands.prepend(new QString(s1));
1279 break; 1280 break;
1280 case 0x08://ptgConcat 1281 case 0x08://ptgConcat
1281 printf("token:ptgConcat\r\n"); 1282 printf("token:ptgConcat\r\n");
1282 operands.first(); 1283 operands.first();
1283 s1=QString("CONCATENATE(")+operands.next()->ascii() 1284 s1=QString("CONCATENATE(")+operands.next()->ascii()
1284 +QString(",")+operands.first()->ascii()+QString(")"); 1285 +QString(",")+operands.first()->ascii()+QString(")");
1285 operands.removeFirst();operands.removeFirst(); 1286 operands.removeFirst();operands.removeFirst();
1286 operands.prepend(new QString(s1)); 1287 operands.prepend(new QString(s1));
1287 break; 1288 break;
1288 case 0x15://ptgParenthesis 1289 case 0x15://ptgParenthesis
1289 printf("token:ptgParenthesis\r\n"); 1290 printf("token:ptgParenthesis\r\n");
1290 s1=QString("(")+operands.first()->ascii()+QString(")"); 1291 s1=QString("(")+operands.first()->ascii()+QString(")");
1291 operands.removeFirst(); 1292 operands.removeFirst();
1292 operands.prepend(new QString(s1)); 1293 operands.prepend(new QString(s1));
1293 break; 1294 break;
1294 case 0x14://ptgPercent 1295 case 0x14://ptgPercent
1295 printf("token:ptgPercent\r\n"); 1296 printf("token:ptgPercent\r\n");
1296 s1=operands.first()->ascii()+QString("*0.01"); 1297 s1=operands.first()->ascii()+QString("*0.01");
1297 operands.removeFirst(); 1298 operands.removeFirst();
1298 operands.prepend(new QString(s1)); 1299 operands.prepend(new QString(s1));
1299 break; 1300 break;
1300 case 0x9://ptgLessThan 1301 case 0x9://ptgLessThan
1301 printf("token:ptgLESS\r\n"); 1302 printf("token:ptgLESS\r\n");
1302 operands.first(); 1303 operands.first();
1303 s1=operands.next()->ascii() 1304 s1=operands.next()->ascii()
1304 +QString("<")+operands.first()->ascii(); 1305 +QString("<")+operands.first()->ascii();
1305 operands.removeFirst();operands.removeFirst(); 1306 operands.removeFirst();operands.removeFirst();
1306 operands.prepend(new QString(s1)); 1307 operands.prepend(new QString(s1));
1307 break; 1308 break;
1308 case 0xa://ptgLessEqual 1309 case 0xa://ptgLessEqual
1309 printf("token:ptgLESS_EQUAL\r\n"); 1310 printf("token:ptgLESS_EQUAL\r\n");
1310 operands.first(); 1311 operands.first();
1311 s1=operands.next()->ascii() 1312 s1=operands.next()->ascii()
1312 +QString("<=")+operands.first()->ascii(); 1313 +QString("<=")+operands.first()->ascii();
1313 operands.removeFirst();operands.removeFirst(); 1314 operands.removeFirst();operands.removeFirst();
1314 operands.prepend(new QString(s1)); 1315 operands.prepend(new QString(s1));
1315 break; 1316 break;
1316 case 0xb://ptgEQUAL 1317 case 0xb://ptgEQUAL
1317 printf("token:ptgEQUAL\r\n"); 1318 printf("token:ptgEQUAL\r\n");
1318 operands.first(); 1319 operands.first();
1319 s1=operands.next()->ascii() 1320 s1=operands.next()->ascii()
1320 +QString("==")+operands.first()->ascii(); 1321 +QString("==")+operands.first()->ascii();
1321 operands.removeFirst();operands.removeFirst(); 1322 operands.removeFirst();operands.removeFirst();
1322 operands.prepend(new QString(s1)); 1323 operands.prepend(new QString(s1));
1323 break; 1324 break;
1324 case 0xc://ptgGREATER_EQUAL 1325 case 0xc://ptgGREATER_EQUAL
1325 printf("token:ptgGREAT_EQUAL\r\n"); 1326 printf("token:ptgGREAT_EQUAL\r\n");
1326 operands.first(); 1327 operands.first();
1327 s1=operands.next()->ascii() 1328 s1=operands.next()->ascii()
1328 +QString(">=")+operands.first()->ascii(); 1329 +QString(">=")+operands.first()->ascii();
1329 operands.removeFirst();operands.removeFirst(); 1330 operands.removeFirst();operands.removeFirst();
1330 operands.prepend(new QString(s1)); 1331 operands.prepend(new QString(s1));
1331 break; 1332 break;
1332 case 0xd://ptgGREAT_THAN 1333 case 0xd://ptgGREAT_THAN
1333 printf("token:ptgGREAT_THAN\r\n"); 1334 printf("token:ptgGREAT_THAN\r\n");
1334 operands.first(); 1335 operands.first();
1335 s1=operands.next()->ascii() 1336 s1=operands.next()->ascii()
1336 +QString(">")+operands.first()->ascii(); 1337 +QString(">")+operands.first()->ascii();
1337 operands.removeFirst();operands.removeFirst(); 1338 operands.removeFirst();operands.removeFirst();
1338 operands.prepend(new QString(s1)); 1339 operands.prepend(new QString(s1));
1339 break; 1340 break;
1340 case 0xe://ptgNOT_EQUAL 1341 case 0xe://ptgNOT_EQUAL
1341 printf("token:ptgNOTequal\r\n"); 1342 printf("token:ptgNOTequal\r\n");
1342 operands.first(); 1343 operands.first();
1343 s1=operands.next()->ascii() 1344 s1=operands.next()->ascii()
1344 +QString("!=")+operands.first()->ascii(); 1345 +QString("!=")+operands.first()->ascii();
1345 operands.removeFirst();operands.removeFirst(); 1346 operands.removeFirst();operands.removeFirst();
1346 operands.prepend(new QString(s1)); 1347 operands.prepend(new QString(s1));
1347 break; 1348 break;
1348 case 0x19://attribute can be Sum,If,Choose 1349 case 0x19://attribute can be Sum,If,Choose
1349 w3=Integer2Byte(data[idx],data[idx+1]);idx=idx+2; 1350 w3=Integer2Byte(data[idx],data[idx+1]);idx=idx+2;
1350 idx++; 1351 idx++;
1351 printf("token:ATTRIBUTE:0x%x\r\n",w3); 1352 printf("token:ATTRIBUTE:0x%x\r\n",w3);
1352 for(w4=idx;w4<length;w4++) 1353 for(w4=idx;w4<length;w4++)
1353 printf("0x%x, ",data[w4]); 1354 printf("0x%x, ",data[w4]);
1354 if(w3&0x01)//choose 1355 if(w3&0x01)//choose
1355 { 1356 {
1356 printf("token:CHOOSE\r\n"); 1357 printf("token:CHOOSE\r\n");
1357 } 1358 }
1358 else if(w3&0x02)//if 1359 else if(w3&0x02)//if
1359 { 1360 {
1360 printf("token:IF\r\n"); 1361 printf("token:IF\r\n");
1361 } 1362 }
1362 else if(w3&0x10)//sum 1363 else if(w3&0x10)//sum
1363 { 1364 {
1364 printf("token:SUM\r\n"); 1365 printf("token:SUM\r\n");
1365 }; 1366 };
1366 1367
1367 break; 1368 break;
1368 1369
1369 1370
1370 case 0x21: 1371 case 0x21:
1371 case 0x22: 1372 case 0x22:
1372 case 0x42: 1373 case 0x42:
1373 case 0x62: 1374 case 0x62:
1374 case 0x41: 1375 case 0x41:
1375 case 0x61://ptgFunction 1376 case 0x61://ptgFunction
1376 printf("token:ptgFunction\r\n"); 1377 printf("token:ptgFunction\r\n");
1377 if(token==0x22||token==0x42||token==0x62) 1378 if(token==0x22||token==0x42||token==0x62)
1378 { 1379 {
1379 w2=(int)data[idx];idx++; 1380 w2=(int)data[idx];idx++;
1380 w1=Integer2Byte(data[idx],data[idx+1]);idx=idx+2; 1381 w1=Integer2Byte(data[idx],data[idx+1]);idx=idx+2;
1381 } 1382 }
1382 else 1383 else
1383 { 1384 {
1384 w1=Integer2Byte(data[idx],data[idx+1]);idx=idx+2; 1385 w1=Integer2Byte(data[idx],data[idx+1]);idx=idx+2;
1385 }; 1386 };
1386 switch(w1) 1387 switch(w1)
1387 { 1388 {
1388 case 0xf://SIN 1389 case 0xf://SIN
1389 s1=QString("SIN(")+operands.first()->ascii()+QString(")"); 1390 s1=QString("SIN(")+operands.first()->ascii()+QString(")");
1390 operands.removeFirst(); 1391 operands.removeFirst();
1391 operands.prepend(new QString(s1)); 1392 operands.prepend(new QString(s1));
1392 break; 1393 break;
1393 case 0x10://COS 1394 case 0x10://COS
1394 s1=QString("COS(")+operands.first()->ascii()+QString(")"); 1395 s1=QString("COS(")+operands.first()->ascii()+QString(")");
1395 operands.removeFirst(); 1396 operands.removeFirst();
1396 operands.prepend(new QString(s1)); 1397 operands.prepend(new QString(s1));
1397 break; 1398 break;
1398 case 0x11://tan 1399 case 0x11://tan
1399 s1=QString("TAN(")+operands.first()->ascii()+QString(")"); 1400 s1=QString("TAN(")+operands.first()->ascii()+QString(")");
1400 operands.removeFirst(); 1401 operands.removeFirst();
1401 operands.prepend(new QString(s1)); 1402 operands.prepend(new QString(s1));
1402 break; 1403 break;
1403 case 0x62://asin 1404 case 0x62://asin
1404 s1=QString("ASIN(")+operands.first()->ascii()+QString(")"); 1405 s1=QString("ASIN(")+operands.first()->ascii()+QString(")");
1405 operands.removeFirst(); 1406 operands.removeFirst();
1406 operands.prepend(new QString(s1)); 1407 operands.prepend(new QString(s1));
1407 break; 1408 break;
1408 case 0x63://ACOS 1409 case 0x63://ACOS
1409 s1=QString("ACOS(")+operands.first()->ascii()+QString(")"); 1410 s1=QString("ACOS(")+operands.first()->ascii()+QString(")");
1410 operands.removeFirst(); 1411 operands.removeFirst();
1411 operands.prepend(new QString(s1)); 1412 operands.prepend(new QString(s1));
1412 break; 1413 break;
1413 case 0x12://ATAN 1414 case 0x12://ATAN
1414 s1=QString("ATAN(")+operands.first()->ascii()+QString(")"); 1415 s1=QString("ATAN(")+operands.first()->ascii()+QString(")");
1415 operands.removeFirst(); 1416 operands.removeFirst();
1416 operands.prepend(new QString(s1)); 1417 operands.prepend(new QString(s1));
1417 break; 1418 break;
1418 case 0xe5://SINH 1419 case 0xe5://SINH
1419 s1=QString("SINH(")+operands.first()->ascii()+QString(")"); 1420 s1=QString("SINH(")+operands.first()->ascii()+QString(")");
1420 operands.removeFirst(); 1421 operands.removeFirst();
1421 operands.prepend(new QString(s1)); 1422 operands.prepend(new QString(s1));
1422 break; 1423 break;
1423 case 0xe6://COSH 1424 case 0xe6://COSH
1424 s1=QString("COSH(")+operands.first()->ascii()+QString(")"); 1425 s1=QString("COSH(")+operands.first()->ascii()+QString(")");
1425 operands.removeFirst(); 1426 operands.removeFirst();
1426 operands.prepend(new QString(s1)); 1427 operands.prepend(new QString(s1));
1427 break; 1428 break;
1428 case 0xe7://TANH 1429 case 0xe7://TANH
1429 s1=QString("TANH(")+operands.first()->ascii()+QString(")"); 1430 s1=QString("TANH(")+operands.first()->ascii()+QString(")");
1430 operands.removeFirst(); 1431 operands.removeFirst();
1431 operands.prepend(new QString(s1)); 1432 operands.prepend(new QString(s1));
1432 break; 1433 break;
1433 case 0xe8://ASINH 1434 case 0xe8://ASINH
1434 s1=QString("ASINH(")+operands.first()->ascii()+QString(")"); 1435 s1=QString("ASINH(")+operands.first()->ascii()+QString(")");
1435 operands.removeFirst(); 1436 operands.removeFirst();
1436 operands.prepend(new QString(s1)); 1437 operands.prepend(new QString(s1));
1437 break; 1438 break;
1438 case 0xe9://ACOSH 1439 case 0xe9://ACOSH
1439 s1=QString("ACOSH(")+operands.first()->ascii()+QString(")"); 1440 s1=QString("ACOSH(")+operands.first()->ascii()+QString(")");
1440 operands.removeFirst(); 1441 operands.removeFirst();
1441 operands.prepend(new QString(s1)); 1442 operands.prepend(new QString(s1));
1442 break; 1443 break;
1443 case 0xea://ATANH 1444 case 0xea://ATANH
1444 s1=QString("ATANH(")+operands.first()->ascii()+QString(")"); 1445 s1=QString("ATANH(")+operands.first()->ascii()+QString(")");
1445 operands.removeFirst(); 1446 operands.removeFirst();
1446 operands.prepend(new QString(s1)); 1447 operands.prepend(new QString(s1));
1447 break; 1448 break;
1448 case 0x13://pi 1449 case 0x13://pi
1449 s1="PI()"; 1450 s1="PI()";
1450 operands.prepend(new QString(s1)); 1451 operands.prepend(new QString(s1));
1451 break; 1452 break;
1452 case 0x14://sqrt 1453 case 0x14://sqrt
1453 s1=QString("SQRT(")+operands.first()->ascii()+QString(")"); 1454 s1=QString("SQRT(")+operands.first()->ascii()+QString(")");
1454 operands.removeFirst(); 1455 operands.removeFirst();
1455 operands.prepend(new QString(s1)); 1456 operands.prepend(new QString(s1));
1456 break; 1457 break;
1457 case 0x15://exp 1458 case 0x15://exp
1458 s1=QString("EXP(")+operands.first()->ascii()+QString(")"); 1459 s1=QString("EXP(")+operands.first()->ascii()+QString(")");
1459 operands.removeFirst(); 1460 operands.removeFirst();
1460 operands.prepend(new QString(s1)); 1461 operands.prepend(new QString(s1));
1461 break; 1462 break;
1462 case 0x16://LN 1463 case 0x16://LN
1463 s1=QString("LN(")+operands.first()->ascii()+QString(")"); 1464 s1=QString("LN(")+operands.first()->ascii()+QString(")");
1464 operands.removeFirst(); 1465 operands.removeFirst();
1465 operands.prepend(new QString(s1)); 1466 operands.prepend(new QString(s1));
1466 break; 1467 break;
1467 case 0x17://LOG10 1468 case 0x17://LOG10
1468 s1=QString("LOG10(")+operands.first()->ascii()+QString(")"); 1469 s1=QString("LOG10(")+operands.first()->ascii()+QString(")");
1469 operands.removeFirst(); 1470 operands.removeFirst();
1470 operands.prepend(new QString(s1)); 1471 operands.prepend(new QString(s1));
1471 break; 1472 break;
1472 case 0x18://ABS 1473 case 0x18://ABS
1473 s1=QString("ABS(")+operands.first()->ascii()+QString(")"); 1474 s1=QString("ABS(")+operands.first()->ascii()+QString(")");
1474 operands.removeFirst(); 1475 operands.removeFirst();
1475 operands.prepend(new QString(s1)); 1476 operands.prepend(new QString(s1));
1476 break; 1477 break;
1477 case 0x19://int 1478 case 0x19://int
1478 s1=QString("INT(")+operands.first()->ascii()+QString(")"); 1479 s1=QString("INT(")+operands.first()->ascii()+QString(")");
1479 operands.removeFirst(); 1480 operands.removeFirst();
1480 operands.prepend(new QString(s1)); 1481 operands.prepend(new QString(s1));
1481 break; 1482 break;
1482 case 0x1a://sign 1483 case 0x1a://sign
1483 s1=QString("SIGN(")+operands.first()->ascii()+QString(")"); 1484 s1=QString("SIGN(")+operands.first()->ascii()+QString(")");
1484 operands.removeFirst(); 1485 operands.removeFirst();
1485 operands.prepend(new QString(s1)); 1486 operands.prepend(new QString(s1));
1486 break; 1487 break;
1487 case 0x1b://round 1488 case 0x1b://round
1488 operands.first(); 1489 operands.first();
1489 s1=QString("ROUND(")+operands.next()->ascii() 1490 s1=QString("ROUND(")+operands.next()->ascii()
1490 +QString(",")+operands.first()->ascii() 1491 +QString(",")+operands.first()->ascii()
1491 +QString(")"); 1492 +QString(")");
1492 operands.removeFirst();operands.removeFirst(); 1493 operands.removeFirst();operands.removeFirst();
1493 operands.prepend(new QString(s1)); 1494 operands.prepend(new QString(s1));
1494 break; 1495 break;
1495 case 0x1d://index 1496 case 0x1d://index
1496 operands.first(); 1497 operands.first();
1497 s1=QString("INDEX(")+operands.next()->ascii() 1498 s1=QString("INDEX(")+operands.next()->ascii()
1498 +QString(",") 1499 +QString(",")
1499 +operands.first()->ascii()+QString(")"); 1500 +operands.first()->ascii()+QString(")");
1500 operands.removeFirst(); 1501 operands.removeFirst();
1501 operands.removeFirst(); 1502 operands.removeFirst();
1502 operands.prepend(new QString(s1)); 1503 operands.prepend(new QString(s1));
1503 break; 1504 break;
1504 case 0x1: // if ATTRIBUTE 1505 case 0x1: // if ATTRIBUTE
1505 operands.first();operands.next(); 1506 operands.first();operands.next();
1506 s1=QString("IF(")+operands.next()->ascii()+QString(","); 1507 s1=QString("IF(")+operands.next()->ascii()+QString(",");
1507 operands.first(); 1508 operands.first();
1508 s1=s1+operands.next()->ascii()+QString(","); 1509 s1=s1+operands.next()->ascii()+QString(",");
1509 s1=s1+operands.first()->ascii()+QString(")"); 1510 s1=s1+operands.first()->ascii()+QString(")");
1510 operands.removeFirst(); 1511 operands.removeFirst();
1511 operands.removeFirst(); 1512 operands.removeFirst();
1512 operands.removeFirst(); 1513 operands.removeFirst();
1513 operands.prepend(new QString(s1)); 1514 operands.prepend(new QString(s1));
1514 break; 1515 break;
1515 case 0x81://isblank 1516 case 0x81://isblank
1516 s1=QString("ISBLANK(")+operands.first()->ascii() 1517 s1=QString("ISBLANK(")+operands.first()->ascii()
1517 +QString(")"); 1518 +QString(")");
1518 operands.removeFirst(); 1519 operands.removeFirst();
1519 operands.prepend(new QString(s1)); 1520 operands.prepend(new QString(s1));
1520 break; 1521 break;
1521 case 0x80://isnumber 1522 case 0x80://isnumber
1522 s1=QString("ISNUMBER(")+operands.first()->ascii() 1523 s1=QString("ISNUMBER(")+operands.first()->ascii()
1523 +QString(")"); 1524 +QString(")");
1524 operands.removeFirst(); 1525 operands.removeFirst();
1525 operands.prepend(new QString(s1)); 1526 operands.prepend(new QString(s1));
1526 break; 1527 break;
1527 case 0x120://ceiling 1528 case 0x120://ceiling
1528 operands.first(); 1529 operands.first();
1529 s1=QString("CEILING(")+operands.next()->ascii() 1530 s1=QString("CEILING(")+operands.next()->ascii()
1530 +QString(",")+operands.first()->ascii() 1531 +QString(",")+operands.first()->ascii()
1531 +QString(")"); 1532 +QString(")");
1532 operands.removeFirst();operands.removeFirst(); 1533 operands.removeFirst();operands.removeFirst();
1533 operands.prepend(new QString(s1)); 1534 operands.prepend(new QString(s1));
1534 break; 1535 break;
1535 case 0x11d://floor 1536 case 0x11d://floor
1536 operands.first(); 1537 operands.first();
1537 s1=QString("FLOOR(")+operands.next()->ascii() 1538 s1=QString("FLOOR(")+operands.next()->ascii()
1538 +QString(",")+operands.first()->ascii() 1539 +QString(",")+operands.first()->ascii()
1539 +QString(")"); 1540 +QString(")");
1540 operands.removeFirst();operands.removeFirst(); 1541 operands.removeFirst();operands.removeFirst();
1541 operands.prepend(new QString(s1)); 1542 operands.prepend(new QString(s1));
1542 break; 1543 break;
1543 case 0x157://degrees 1544 case 0x157://degrees
1544 s1=QString("DEGREES(")+operands.first()->ascii() 1545 s1=QString("DEGREES(")+operands.first()->ascii()
1545 +QString(")"); 1546 +QString(")");
1546 operands.removeFirst(); 1547 operands.removeFirst();
1547 operands.prepend(new QString(s1)); 1548 operands.prepend(new QString(s1));
1548 break; 1549 break;
1549 case 0x156://radians 1550 case 0x156://radians
1550 s1=QString("RADIANS(")+operands.first()->ascii() 1551 s1=QString("RADIANS(")+operands.first()->ascii()
1551 +QString(")"); 1552 +QString(")");
1552 operands.removeFirst(); 1553 operands.removeFirst();
1553 operands.prepend(new QString(s1)); 1554 operands.prepend(new QString(s1));
1554 break; 1555 break;
1555 case 0xb8://fact 1556 case 0xb8://fact
1556 s1=QString("FACT(")+operands.first()->ascii() 1557 s1=QString("FACT(")+operands.first()->ascii()
1557 +QString(")"); 1558 +QString(")");
1558 operands.removeFirst(); 1559 operands.removeFirst();
1559 operands.prepend(new QString(s1)); 1560 operands.prepend(new QString(s1));
1560 break; 1561 break;
1561 case 0x27://MOD 1562 case 0x27://MOD
1562 operands.first(); 1563 operands.first();
1563 s1=QString("MOD(")+operands.next()->ascii() 1564 s1=QString("MOD(")+operands.next()->ascii()
1564 +QString(",")+operands.first()->ascii() 1565 +QString(",")+operands.first()->ascii()
1565 +QString(")"); 1566 +QString(")");
1566 operands.removeFirst();operands.removeFirst(); 1567 operands.removeFirst();operands.removeFirst();
1567 operands.prepend(new QString(s1)); 1568 operands.prepend(new QString(s1));
1568 break; 1569 break;
1569 case 0x151://power 1570 case 0x151://power
1570 operands.first(); 1571 operands.first();
1571 s1=QString("POWER(")+operands.next()->ascii() 1572 s1=QString("POWER(")+operands.next()->ascii()
1572 +QString(",")+operands.first()->ascii() 1573 +QString(",")+operands.first()->ascii()
1573 +QString(")"); 1574 +QString(")");
1574 operands.removeFirst();operands.removeFirst(); 1575 operands.removeFirst();operands.removeFirst();
1575 operands.prepend(new QString(s1)); 1576 operands.prepend(new QString(s1));
1576 break; 1577 break;
1577 case 0x3f://rand() 1578 case 0x3f://rand()
1578 s1="RAND()"; 1579 s1="RAND()";
1579 operands.prepend(new QString(s1)); 1580 operands.prepend(new QString(s1));
1580 break; 1581 break;
1581 case 0x4://sum 1582 case 0x4://sum
1582 for(w4=1;w4<w2;w4++) operands.removeFirst(); 1583 for(w4=1;w4<w2;w4++) operands.removeFirst();
1583 s1=QString("SUM(")+operands.first()->ascii() 1584 s1=QString("SUM(")+operands.first()->ascii()
1584 +QString(")"); 1585 +QString(")");
1585 operands.removeFirst(); 1586 operands.removeFirst();
1586 operands.prepend(new QString(s1)); 1587 operands.prepend(new QString(s1));
1587 break; 1588 break;
1588 case 0x6://min 1589 case 0x6://min
1589 for(w4=1;w4<w2;w4++) operands.removeFirst(); 1590 for(w4=1;w4<w2;w4++) operands.removeFirst();
1590 s1=QString("MIN(")+operands.first()->ascii() 1591 s1=QString("MIN(")+operands.first()->ascii()
1591 +QString(")"); 1592 +QString(")");
1592 operands.removeFirst(); 1593 operands.removeFirst();
1593 operands.prepend(new QString(s1)); 1594 operands.prepend(new QString(s1));
1594 break; 1595 break;
1595 case 0x7://max 1596 case 0x7://max
1596 for(w4=1;w4<w2;w4++) operands.removeFirst(); 1597 for(w4=1;w4<w2;w4++) operands.removeFirst();
1597 s1=QString("MAX(")+operands.first()->ascii() 1598 s1=QString("MAX(")+operands.first()->ascii()
1598 +QString(")"); 1599 +QString(")");
1599 operands.removeFirst(); 1600 operands.removeFirst();
1600 operands.prepend(new QString(s1)); 1601 operands.prepend(new QString(s1));
1601 break; 1602 break;
1602 case 0x5://average 1603 case 0x5://average
1603 for(w4=1;w4<w2;w4++) operands.removeFirst(); 1604 for(w4=1;w4<w2;w4++) operands.removeFirst();
1604 s1=QString("AVERAGE(")+operands.first()->ascii() 1605 s1=QString("AVERAGE(")+operands.first()->ascii()
1605 +QString(")"); 1606 +QString(")");
1606 operands.removeFirst(); 1607 operands.removeFirst();
1607 operands.prepend(new QString(s1)); 1608 operands.prepend(new QString(s1));
1608 break; 1609 break;
1609 case 0x2e://var 1610 case 0x2e://var
1610 for(w4=1;w4<w2;w4++) operands.removeFirst(); 1611 for(w4=1;w4<w2;w4++) operands.removeFirst();
1611 s1=QString("VAR(")+operands.first()->ascii() 1612 s1=QString("VAR(")+operands.first()->ascii()
1612 +QString(")"); 1613 +QString(")");
1613 operands.removeFirst(); 1614 operands.removeFirst();
1614 operands.prepend(new QString(s1)); 1615 operands.prepend(new QString(s1));
1615 break; 1616 break;
1616 case 0xc2://varp 1617 case 0xc2://varp
1617 for(w4=1;w4<w2;w4++) operands.removeFirst(); 1618 for(w4=1;w4<w2;w4++) operands.removeFirst();
1618 s1=QString("VARP(")+operands.first()->ascii() 1619 s1=QString("VARP(")+operands.first()->ascii()
1619 +QString(")"); 1620 +QString(")");
1620 operands.removeFirst(); 1621 operands.removeFirst();
1621 operands.prepend(new QString(s1)); 1622 operands.prepend(new QString(s1));
1622 break; 1623 break;
1623 case 0xc://stdev 1624 case 0xc://stdev
1624 for(w4=1;w4<w2;w4++) operands.removeFirst(); 1625 for(w4=1;w4<w2;w4++) operands.removeFirst();
1625 s1=QString("STDEV(")+operands.first()->ascii() 1626 s1=QString("STDEV(")+operands.first()->ascii()
1626 +QString(")"); 1627 +QString(")");
1627 operands.removeFirst(); 1628 operands.removeFirst();
1628 operands.prepend(new QString(s1)); 1629 operands.prepend(new QString(s1));
1629 break; 1630 break;
1630 case 0xc1://stdevp 1631 case 0xc1://stdevp
1631 for(w4=1;w4<w2;w4++) operands.removeFirst(); 1632 for(w4=1;w4<w2;w4++) operands.removeFirst();
1632 s1=QString("STDEVP(")+operands.first()->ascii() 1633 s1=QString("STDEVP(")+operands.first()->ascii()
1633 +QString(")"); 1634 +QString(")");
1634 operands.removeFirst(); 1635 operands.removeFirst();
1635 operands.prepend(new QString(s1)); 1636 operands.prepend(new QString(s1));
1636 break; 1637 break;
1637 case 0x143://skew 1638 case 0x143://skew
1638 for(w4=1;w4<w2;w4++) operands.removeFirst(); 1639 for(w4=1;w4<w2;w4++) operands.removeFirst();
1639 s1=QString("SKEW(")+operands.first()->ascii() 1640 s1=QString("SKEW(")+operands.first()->ascii()
1640 +QString(")"); 1641 +QString(")");
1641 operands.removeFirst(); 1642 operands.removeFirst();
1642 operands.prepend(new QString(s1)); 1643 operands.prepend(new QString(s1));
1643 break; 1644 break;
1644 case 0x142://kurt 1645 case 0x142://kurt
1645 for(w4=1;w4<w2;w4++) operands.removeFirst(); 1646 for(w4=1;w4<w2;w4++) operands.removeFirst();
1646 s1=QString("KURT(")+operands.first()->ascii() 1647 s1=QString("KURT(")+operands.first()->ascii()
1647 +QString(")"); 1648 +QString(")");
1648 operands.removeFirst(); 1649 operands.removeFirst();
1649 operands.prepend(new QString(s1)); 1650 operands.prepend(new QString(s1));
1650 break; 1651 break;
1651 case 0x0://count 1652 case 0x0://count
1652 for(w4=1;w4<w2;w4++) operands.removeFirst(); 1653 for(w4=1;w4<w2;w4++) operands.removeFirst();
1653 s1=QString("COUNT(")+operands.first()->ascii() 1654 s1=QString("COUNT(")+operands.first()->ascii()
1654 +QString(")"); 1655 +QString(")");
1655 operands.removeFirst(); 1656 operands.removeFirst();
1656 operands.prepend(new QString(s1)); 1657 operands.prepend(new QString(s1));
1657 break; 1658 break;
1658 1659
1659 default: 1660 default:
1660 printf("token:FUNCTION_UNKNOWN=0x%x\r\n",w1); 1661 printf("token:FUNCTION_UNKNOWN=0x%x\r\n",w1);
1661 return QString("FUNC_UNKNOWN"); 1662 return QString("FUNC_UNKNOWN");
1662 break; 1663 break;
1663 1664
1664 }; 1665 };
1665 1666
1666 break; 1667 break;
1667 1668
1668 default: 1669 default:
1669 printf("tokenUNKNOWN=0x%x\r\n",token); 1670 printf("tokenUNKNOWN=0x%x\r\n",token);
1670 return QString("TOKEN_UKNOWN"); 1671 return QString("TOKEN_UKNOWN");
1671 //it is dangerous to go to idx++ and not return 1672 //it is dangerous to go to idx++ and not return
1672 // because the result is unexpected. 1673 // because the result is unexpected.
1673 // but there is a possibility the the parser will give the correct 1674 // but there is a possibility the the parser will give the correct
1674 // answer, because there are some tokens in excel formulas that can be //ignored. 1675 // answer, because there are some tokens in excel formulas that can be //ignored.
1675 idx++; 1676 idx++;
1676 break; 1677 break;
1677 }; 1678 };
1678 1679
1679 }; 1680 };
1680 1681
1681 1682
1682 1683
1683 printf("{////FormulaParser}\r\n"); 1684 printf("{////FormulaParser}\r\n");
1684 printf("GetFormula:::::::r=%d,c=%d,,,%s\r\n",row,col,s1.ascii()); 1685 printf("GetFormula:::::::r=%d,c=%d,,,%s\r\n",row,col,s1.ascii());
1685 printf("\r\n"); 1686 printf("\r\n");
1686 s1=operands.first()->ascii(); 1687 s1=operands.first()->ascii();
1687 operands.clear(); 1688 operands.clear();
1688 return QString(s1); 1689 return QString(s1);
1689}; 1690};
1690 1691
1691QString ExcelBook::FindCellName(int row, int col) 1692QString ExcelBook::FindCellName(int row, int col)
1692{ 1693{
1693 row++;col++; 1694 row++;col++;
1694 QString s1=""; 1695 QString s1="";
1695 int i1=col % 26; 1696 int i1=col % 26;
1696 int i2=col / 26; 1697 int i2=col / 26;
1697 if (i2!=0) s1=(char)(i2+65); //65 =A 1698 if (i2!=0) s1=(char)(i2+65); //65 =A
1698 s1=s1+(char)(i1+65-1); 1699 s1=s1+(char)(i1+65-1);
1699 return (s1+QString::number(row)); 1700 return (s1+QString::number(row));
1700}; 1701};
1701 1702
1702 1703
1703 1704
1704 1705
1705 1706
1706 1707
1707 1708
1708 1709
diff --git a/noncore/apps/opie-sheet/mainwindow.cpp b/noncore/apps/opie-sheet/mainwindow.cpp
index 7394623..3095142 100644
--- a/noncore/apps/opie-sheet/mainwindow.cpp
+++ b/noncore/apps/opie-sheet/mainwindow.cpp
@@ -1,1028 +1,1031 @@
1/* 1/*
2 =. This file is part of the Opie Project 2 =. This file is part of the Opie Project
3 .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> 3 .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org>
4 .>+-= 4 .>+-=
5 _;:, .> :=|. This program is free software; you can 5 _;:, .> :=|. This program is free software; you can
6.> <`_, > . <= redistribute it and/or modify it under 6.> <`_, > . <= redistribute it and/or modify it under
7:`=1 )Y*s>-.-- : the terms of the GNU General Public 7:`=1 )Y*s>-.-- : the terms of the GNU General Public
8.="- .-=="i, .._ License as published by the Free Software 8.="- .-=="i, .._ License as published by the Free Software
9 - . .-<_> .<> Foundation; either version 2 of the License, 9 - . .-<_> .<> Foundation; either version 2 of the License,
10 ._= =} : or (at your option) any later version. 10 ._= =} : or (at your option) any later version.
11 .%`+i> _;_. 11 .%`+i> _;_.
12 .i_,=:_. -<s. This program is distributed in the hope that 12 .i_,=:_. -<s. This program is distributed in the hope that
13 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 13 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
14 : .. .:, . . . without even the implied warranty of 14 : .. .:, . . . without even the implied warranty of
15 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 15 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
16 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 16 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.= = ; Library General Public License for more 17..}^=.= = ; Library General Public License for more
18++= -. .` .: details. 18++= -. .` .: details.
19 : = ...= . :.=- 19 : = ...= . :.=-
20 -. .:....=;==+<; You should have received a copy of the GNU 20 -. .:....=;==+<; You should have received a copy of the GNU
21 -_. . . )=. = Library General Public License along with 21 -_. . . )=. = Library General Public License along with
22 -- :-=` this library; see the file COPYING.LIB. 22 -- :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29/* 29/*
30 * Opie Sheet (formerly Sheet/Qt) 30 * Opie Sheet (formerly Sheet/Qt)
31 * by Serdar Ozler <sozler@sitebest.com> 31 * by Serdar Ozler <sozler@sitebest.com>
32 */ 32 */
33 33
34#include "mainwindow.h" 34#include "mainwindow.h"
35 35
36/* OPIE */ 36/* OPIE */
37#include <qpe/resource.h> 37#include <qpe/resource.h>
38#include <qpe/qpeapplication.h> 38#include <qpe/qpeapplication.h>
39 39
40/* QT */ 40/* QT */
41#include <qmessagebox.h> 41#include <qmessagebox.h>
42#include <qradiobutton.h> 42#include <qradiobutton.h>
43 43
44/* STD */ 44/* STD */
45#include "cellformat.h" 45#include "cellformat.h"
46#include "numberdlg.h" 46#include "numberdlg.h"
47#include "textdlg.h" 47#include "textdlg.h"
48#include "sortdlg.h" 48#include "sortdlg.h"
49#include "finddlg.h" 49#include "finddlg.h"
50 50
51#define DEFAULT_NUM_ROWS 300 51#define DEFAULT_NUM_ROWS 300
52#define DEFAULT_NUM_COLS (26*3) 52#define DEFAULT_NUM_COLS (26*3)
53#define DEFAULT_NUM_SHEETS 3 53#define DEFAULT_NUM_SHEETS 3
54 54
55MainWindow::MainWindow(QWidget *parent, const char* n, WFlags fl) 55MainWindow::MainWindow(QWidget *parent, const char* n, WFlags fl)
56 :QMainWindow(parent, n, fl) 56 :QMainWindow(parent, n, fl)
57{ 57{
58 // initialize variables 58 // initialize variables
59 documentModified=FALSE; 59 documentModified=FALSE;
60 60
61 // construct objects 61 // construct objects
62 currentDoc=0; 62 currentDoc=0;
63 fileSelector=new FileSelector("application/opie-sheet", this, QString::null); 63 fileSelector=new FileSelector("application/opie-sheet", this, QString::null);
64 ExcelSelector=new FileSelector("application/excel",this,QString::null,FALSE); 64 ExcelSelector=new FileSelector("application/excel",this,QString::null,FALSE);
65 connect(fileSelector, SIGNAL(closeMe()), this, SLOT(selectorHide())); 65 connect(fileSelector, SIGNAL(closeMe()), this, SLOT(selectorHide()));
66 connect(fileSelector, SIGNAL(newSelected(const DocLnk&)), this, SLOT(selectorFileNew(const DocLnk&))); 66 connect(fileSelector, SIGNAL(newSelected(const DocLnk&)), this, SLOT(selectorFileNew(const DocLnk&)));
67 connect(fileSelector, SIGNAL(fileSelected(const DocLnk&)), this, SLOT(selectorFileOpen(const DocLnk&))); 67 connect(fileSelector, SIGNAL(fileSelected(const DocLnk&)), this, SLOT(selectorFileOpen(const DocLnk&)));
68 connect(ExcelSelector,SIGNAL(fileSelected(const DocLnk&)),this,SLOT(slotImportExcel(const DocLnk&))); 68 connect(ExcelSelector,SIGNAL(fileSelected(const DocLnk&)),this,SLOT(slotImportExcel(const DocLnk&)));
69 connect(ExcelSelector,SIGNAL(closeMe()), this, SLOT(ExcelSelectorHide())); 69 connect(ExcelSelector,SIGNAL(closeMe()), this, SLOT(ExcelSelectorHide()));
70 70
71 listSheets.setAutoDelete(TRUE); 71 listSheets.setAutoDelete(TRUE);
72 72
73 initActions(); 73 initActions();
74 initMenu(); 74 initMenu();
75 initEditToolbar(); 75 initEditToolbar();
76 initFunctionsToolbar(); 76 initFunctionsToolbar();
77 initStandardToolbar(); 77 initStandardToolbar();
78 initSheet(); 78 initSheet();
79 79
80 // set window title 80 // set window title
81 setCaption(tr("Opie Sheet")); 81 setCaption(tr("Opie Sheet"));
82 82
83 // create sheets 83 // create sheets
84 selectorFileNew(DocLnk()); 84 selectorFileNew(DocLnk());
85} 85}
86 86
87MainWindow::~MainWindow() 87MainWindow::~MainWindow()
88{ 88{
89 if (currentDoc) delete currentDoc; 89 if (currentDoc) delete currentDoc;
90} 90}
91 91
92void MainWindow::documentSave(DocLnk *lnkDoc) 92void MainWindow::documentSave(DocLnk *lnkDoc)
93{ 93{
94 FileManager fm; 94 FileManager fm;
95 QByteArray streamBuffer; 95 QByteArray streamBuffer;
96 QDataStream stream(streamBuffer, IO_WriteOnly); 96 QDataStream stream(streamBuffer, IO_WriteOnly);
97 97
98 typeSheet *currentSheet=findSheet(sheet->getName()); 98 typeSheet *currentSheet=findSheet(sheet->getName());
99 if (!currentSheet) 99 if (!currentSheet)
100 { 100 {
101 QMessageBox::critical(this, tr("Error"), tr("Inconsistency error!")); 101 QMessageBox::critical(this, tr("Error"), tr("Inconsistency error!"));
102 return; 102 return;
103 } 103 }
104 sheet->copySheetData(&currentSheet->data); 104 sheet->copySheetData(&currentSheet->data);
105 stream.writeRawBytes("SQT100", 6); 105 stream.writeRawBytes("SQT100", 6);
106 stream << (Q_UINT32)listSheets.count(); 106 stream << (Q_UINT32)listSheets.count();
107 for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) 107 for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next())
108 { 108 {
109 stream << tempSheet->name << (Q_UINT32)tempSheet->data.count(); 109 stream << tempSheet->name << (Q_UINT32)tempSheet->data.count();
110 for (typeCellData *tempCell=tempSheet->data.first(); tempCell; tempCell=tempSheet->data.next()) 110 for (typeCellData *tempCell=tempSheet->data.first(); tempCell; tempCell=tempSheet->data.next())
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; 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;
112 } 112 }
113 113
114 lnkDoc->setType("application/opie-sheet"); 114 lnkDoc->setType("application/opie-sheet");
115 if (!fm.saveFile(*lnkDoc, streamBuffer)) 115 if (!fm.saveFile(*lnkDoc, streamBuffer))
116 { 116 {
117 QMessageBox::critical(this, tr("Error"), tr("File cannot be saved!")); 117 QMessageBox::critical(this, tr("Error"), tr("File cannot be saved!"));
118 return; 118 return;
119 } 119 }
120 documentModified=FALSE; 120 documentModified=FALSE;
121} 121}
122 122
123void MainWindow::documentOpen(const DocLnk &lnkDoc) 123void MainWindow::documentOpen(const DocLnk &lnkDoc)
124{ 124{
125 FileManager fm; 125 FileManager fm;
126 QByteArray streamBuffer; 126 QByteArray streamBuffer;
127 if (!lnkDoc.isValid() || !fm.loadFile(lnkDoc, streamBuffer)) 127 if (!lnkDoc.isValid() || !fm.loadFile(lnkDoc, streamBuffer))
128 { 128 {
129 QMessageBox::critical(this, tr("Error"), tr("File cannot be opened!")); 129 QMessageBox::critical(this, tr("Error"), tr("File cannot be opened!"));
130 documentModified=FALSE; 130 documentModified=FALSE;
131 selectorFileNew(DocLnk()); 131 selectorFileNew(DocLnk());
132 return; 132 return;
133 } 133 }
134 QDataStream stream(streamBuffer, IO_ReadOnly); 134 QDataStream stream(streamBuffer, IO_ReadOnly);
135 135
136 Q_UINT32 countSheet, countCell, i, j, row, col, alignment; 136 Q_UINT32 countSheet, countCell, i, j, row, col, alignment;
137 typeSheet *newSheet; 137 typeSheet *newSheet;
138 typeCellData *newCell; 138 typeCellData *newCell;
139 139
140 char fileFormat[7]; 140 char fileFormat[7];
141 stream.readRawBytes(fileFormat, 6); 141 stream.readRawBytes(fileFormat, 6);
142 fileFormat[6]=0; 142 fileFormat[6]=0;
143 if ((QString)fileFormat!="SQT100") 143 if ((QString)fileFormat!="SQT100")
144 { 144 {
145 QMessageBox::critical(this, tr("Error"), tr("Invalid file format!")); 145 QMessageBox::critical(this, tr("Error"), tr("Invalid file format!"));
146 documentModified=FALSE; 146 documentModified=FALSE;
147 selectorFileNew(DocLnk()); 147 selectorFileNew(DocLnk());
148 return; 148 return;
149 } 149 }
150 150
151 stream >> countSheet; 151 stream >> countSheet;
152 for (i=0; i<countSheet; ++i) 152 for (i=0; i<countSheet; ++i)
153 { 153 {
154 newSheet=new typeSheet; 154 newSheet=new typeSheet;
155 newSheet->data.setAutoDelete(TRUE); 155 newSheet->data.setAutoDelete(TRUE);
156 stream >> newSheet->name >> countCell; 156 stream >> newSheet->name >> countCell;
157 comboSheets->insertItem(newSheet->name); 157 comboSheets->insertItem(newSheet->name);
158 158
159 for (j=0; j<countCell; ++j) 159 for (j=0; j<countCell; ++j)
160 { 160 {
161 newCell=new typeCellData; 161 newCell=new typeCellData;
162 stream >> col >> row >> newCell->borders.right >> newCell->borders.bottom >> newCell->background >> alignment >> newCell->fontColor >> newCell->font >> newCell->data; 162 stream >> col >> row >> newCell->borders.right >> newCell->borders.bottom >> newCell->background >> alignment >> newCell->fontColor >> newCell->font >> newCell->data;
163 newCell->col=col; 163 newCell->col=col;
164 newCell->row=row; 164 newCell->row=row;
165 newCell->alignment=(Qt::AlignmentFlags)alignment; 165 newCell->alignment=(Qt::AlignmentFlags)alignment;
166 newSheet->data.append(newCell); 166 newSheet->data.append(newCell);
167 } 167 }
168 listSheets.append(newSheet); 168 listSheets.append(newSheet);
169 169
170 if (i==0) 170 if (i==0)
171 { 171 {
172 sheet->setName(newSheet->name); 172 sheet->setName(newSheet->name);
173 sheet->setSheetData(&newSheet->data); 173 sheet->setSheetData(&newSheet->data);
174 } 174 }
175 } 175 }
176} 176}
177 177
178int MainWindow::saveCurrentFile(bool ask) 178int MainWindow::saveCurrentFile(bool ask)
179{ 179{
180 if (ask) 180 if (ask)
181 { 181 {
182 int result=QMessageBox::information(this, tr("Save File"), tr("Do you want to save the current file?"), QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel); 182 int result=QMessageBox::information(this, tr("Save File"), tr("Do you want to save the current file?"), QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel);
183 if (result!=QMessageBox::Yes) return result; 183 if (result!=QMessageBox::Yes) return result;
184 } 184 }
185 185
186 if (!currentDoc->isValid()) 186 if (!currentDoc->isValid())
187 { 187 {
188 TextDialog dialogText(this); 188 TextDialog dialogText(this);
189 if (dialogText.exec(tr("Save File"), tr("&File Name:"), tr("UnnamedFile"))!=QDialog::Accepted || dialogText.getValue().isEmpty()) return QMessageBox::Cancel; 189 if (dialogText.exec(tr("Save File"), tr("&File Name:"), tr("UnnamedFile"))!=QDialog::Accepted || dialogText.getValue().isEmpty()) return QMessageBox::Cancel;
190 190
191 currentDoc->setName(dialogText.getValue()); 191 currentDoc->setName(dialogText.getValue());
192 currentDoc->setFile(QString::null); 192 currentDoc->setFile(QString::null);
193 currentDoc->setLinkFile(QString::null); 193 currentDoc->setLinkFile(QString::null);
194 } 194 }
195 195
196 documentSave(currentDoc); 196 documentSave(currentDoc);
197 return QMessageBox::Yes; 197 return QMessageBox::Yes;
198} 198}
199 199
200void MainWindow::selectorFileNew(const DocLnk &lnkDoc) 200void MainWindow::selectorFileNew(const DocLnk &lnkDoc)
201{ 201{
202 selectorHide(); 202 selectorHide();
203 203
204 if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; 204 if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return;
205 if (currentDoc) delete currentDoc; 205 if (currentDoc) delete currentDoc;
206 currentDoc = new DocLnk(lnkDoc); 206 currentDoc = new DocLnk(lnkDoc);
207 editData->clear(); 207 editData->clear();
208 listSheets.clear(); 208 listSheets.clear();
209 comboSheets->clear(); 209 comboSheets->clear();
210 210
211 typeSheet *newSheet=createNewSheet(); 211 typeSheet *newSheet=createNewSheet();
212 newSheet->data.setAutoDelete(TRUE); 212 newSheet->data.setAutoDelete(TRUE);
213 sheet->setName(newSheet->name); 213 sheet->setName(newSheet->name);
214 sheet->setSheetData(&newSheet->data); 214 sheet->setSheetData(&newSheet->data);
215 for (int i=1; i<DEFAULT_NUM_SHEETS; ++i) 215 for (int i=1; i<DEFAULT_NUM_SHEETS; ++i)
216 createNewSheet(); 216 createNewSheet();
217 documentModified=FALSE; 217 documentModified=FALSE;
218} 218}
219 219
220void MainWindow::closeEvent(QCloseEvent *e) 220void MainWindow::closeEvent(QCloseEvent *e)
221{ 221{
222 if (documentModified && saveCurrentFile()==QMessageBox::Cancel) e->ignore(); 222 if (documentModified && saveCurrentFile()==QMessageBox::Cancel) e->ignore();
223 else e->accept(); 223 else e->accept();
224} 224}
225 225
226void MainWindow::selectorFileOpen(const DocLnk &lnkDoc) 226void MainWindow::selectorFileOpen(const DocLnk &lnkDoc)
227{ 227{
228 selectorHide(); 228 selectorHide();
229 229
230 if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; 230 if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return;
231 if (currentDoc) delete currentDoc; 231 if (currentDoc) delete currentDoc;
232 currentDoc = new DocLnk( lnkDoc ); 232 currentDoc = new DocLnk( lnkDoc );
233 listSheets.clear(); 233 listSheets.clear();
234 comboSheets->clear(); 234 comboSheets->clear();
235 235
236 documentOpen(lnkDoc); 236 documentOpen(lnkDoc);
237 documentModified=FALSE; 237 documentModified=FALSE;
238} 238}
239 239
240void MainWindow::selectorShow() 240void MainWindow::selectorShow()
241{ 241{
242 sheet->hide(); 242 sheet->hide();
243 setCentralWidget(fileSelector); 243 setCentralWidget(fileSelector);
244 fileSelector->show(); 244 fileSelector->show();
245 fileSelector->reread(); 245 fileSelector->reread();
246} 246}
247 247
248void MainWindow::selectorHide() 248void MainWindow::selectorHide()
249{ 249{
250 fileSelector->hide(); 250 fileSelector->hide();
251 setCentralWidget(sheet); 251 setCentralWidget(sheet);
252 sheet->show(); 252 sheet->show();
253} 253}
254 254
255void MainWindow::slotFileNew() 255void MainWindow::slotFileNew()
256{ 256{
257 selectorFileNew(DocLnk()); 257 selectorFileNew(DocLnk());
258} 258}
259 259
260void MainWindow::slotFileOpen() 260void MainWindow::slotFileOpen()
261{ 261{
262 selectorShow(); 262 selectorShow();
263} 263}
264 264
265void MainWindow::slotImportExcelOpen() 265void MainWindow::slotImportExcelOpen()
266{ 266{
267 sheet->hide(); 267 sheet->hide();
268 setCentralWidget(ExcelSelector); 268 setCentralWidget(ExcelSelector);
269 ExcelSelector->show(); 269 ExcelSelector->show();
270 ExcelSelector->reread(); 270 ExcelSelector->reread();
271} 271}
272 272
273void MainWindow::ExcelSelectorHide() 273void MainWindow::ExcelSelectorHide()
274{ 274{
275 ExcelSelector->hide(); 275 ExcelSelector->hide();
276 setCentralWidget(sheet); 276 setCentralWidget(sheet);
277 sheet->show(); 277 sheet->show();
278} 278}
279 279
280void MainWindow::slotFileSave() 280void MainWindow::slotFileSave()
281{ 281{
282 saveCurrentFile(FALSE); 282 saveCurrentFile(FALSE);
283} 283}
284 284
285void MainWindow::setDocument(const QString &applnk_filename) 285void MainWindow::setDocument(const QString &applnk_filename)
286{ 286{
287 selectorFileOpen(DocLnk(applnk_filename)); 287 selectorFileOpen(DocLnk(applnk_filename));
288} 288}
289 289
290void MainWindow::initActions() 290void MainWindow::initActions()
291{ 291{
292 fileNew=new QAction(tr("New File"), Resource::loadPixmap( "new" ), tr("&New"), 0, this); 292 fileNew=new QAction(tr("New File"), Resource::loadPixmap( "new" ), tr("&New"), 0, this);
293 connect(fileNew, SIGNAL(activated()), this, SLOT(slotFileNew())); 293 connect(fileNew, SIGNAL(activated()), this, SLOT(slotFileNew()));
294 fileOpen=new QAction(tr("Open File"), Resource::loadPixmap( "fileopen" ), tr("&Open"), 0, this); 294 fileOpen=new QAction(tr("Open File"), Resource::loadPixmap( "fileopen" ), tr("&Open"), 0, this);
295 connect(fileOpen, SIGNAL(activated()), this, SLOT(slotFileOpen())); 295 connect(fileOpen, SIGNAL(activated()), this, SLOT(slotFileOpen()));
296 fileSave=new QAction(tr("Save File"),Resource::loadPixmap( "save" ), tr("&Save"), 0, this); 296 fileSave=new QAction(tr("Save File"),Resource::loadPixmap( "save" ), tr("&Save"), 0, this);
297 connect(fileSave, SIGNAL(activated()), this, SLOT(slotFileSave())); 297 connect(fileSave, SIGNAL(activated()), this, SLOT(slotFileSave()));
298 fileSaveAs=new QAction(tr("Save File As"), Resource::loadPixmap( "save" ), tr("Save &As"), 0, this); 298 fileSaveAs=new QAction(tr("Save File As"), Resource::loadPixmap( "save" ), tr("Save &As"), 0, this);
299 connect(fileSaveAs, SIGNAL(activated()), this, SLOT(slotFileSaveAs())); 299 connect(fileSaveAs, SIGNAL(activated()), this, SLOT(slotFileSaveAs()));
300 300
301 //fileQuit=new QAction(tr("Quit"), tr("&Quit"), 0, this); 301 //fileQuit=new QAction(tr("Quit"), tr("&Quit"), 0, this);
302 //connect(fileQuit, SIGNAL(activated()), this, SLOT(close())); 302 //connect(fileQuit, SIGNAL(activated()), this, SLOT(close()));
303 fileExcelImport=new QAction(tr("Import Excel file"),Resource::loadPixmap( "opie-sheet/excel16" ),tr("Import E&xcel file"),0,this); 303 fileExcelImport=new QAction(tr("Import Excel file"),Resource::loadPixmap( "opie-sheet/excel16" ),tr("Import E&xcel file"),0,this);
304 connect(fileExcelImport, SIGNAL(activated()), this, SLOT(slotImportExcelOpen())); 304 connect(fileExcelImport, SIGNAL(activated()), this, SLOT(slotImportExcelOpen()));
305 305
306 // helpGeneral=new QAction(tr("General Help"), QPixmap(help_general_xpm), tr("&General"), 0, this); 306 // helpGeneral=new QAction(tr("General Help"), QPixmap(help_general_xpm), tr("&General"), 0, this);
307 //connect(helpGeneral, SIGNAL(activated()), this, SLOT(slotHelpGeneral())); 307 //connect(helpGeneral, SIGNAL(activated()), this, SLOT(slotHelpGeneral()));
308 //helpAbout=new QAction(tr("About Opie Sheet"), tr("&About"), 0, this); 308 //helpAbout=new QAction(tr("About Opie Sheet"), tr("&About"), 0, this);
309 //connect(helpAbout, SIGNAL(activated()), this, SLOT(slotHelpAbout())); 309 //connect(helpAbout, SIGNAL(activated()), this, SLOT(slotHelpAbout()));
310 310
311 editAccept=new QAction(tr("Accept"),Resource::loadPixmap( "enter" ) , tr("&Accept"), 0, this); 311 editAccept=new QAction(tr("Accept"),Resource::loadPixmap( "enter" ) , tr("&Accept"), 0, this);
312 connect(editAccept, SIGNAL(activated()), this, SLOT(slotEditAccept())); 312 connect(editAccept, SIGNAL(activated()), this, SLOT(slotEditAccept()));
313 editCancel=new QAction(tr("Cancel"), Resource::loadPixmap( "close" ), tr("&Cancel"), 0, this); 313 editCancel=new QAction(tr("Cancel"), Resource::loadPixmap( "close" ), tr("&Cancel"), 0, this);
314 connect(editCancel, SIGNAL(activated()), this, SLOT(slotEditCancel())); 314 connect(editCancel, SIGNAL(activated()), this, SLOT(slotEditCancel()));
315 editCellSelect=new QAction(tr("Cell Selector"), Resource::loadPixmap( "opie-sheet/cell-select" ), tr("Cell &Selector"), 0, this); 315 editCellSelect=new QAction(tr("Cell Selector"), Resource::loadPixmap( "opie-sheet/cell-select" ), tr("Cell &Selector"), 0, this);
316 editCellSelect->setToggleAction(TRUE); 316 editCellSelect->setToggleAction(TRUE);
317 connect(editCellSelect, SIGNAL(toggled(bool)), this, SLOT(slotCellSelect(bool))); 317 connect(editCellSelect, SIGNAL(toggled(bool)), this, SLOT(slotCellSelect(bool)));
318 editCut=new QAction(tr("Cut Cells"), tr("Cu&t"), 0, this); 318 editCut=new QAction(tr("Cut Cells"), tr("Cu&t"), 0, this);
319 editCopy=new QAction(tr("Copy Cells"), tr("&Copy"), 0, this); 319 editCopy=new QAction(tr("Copy Cells"), tr("&Copy"), 0, this);
320 editPaste=new QAction(tr("Paste Cells"), tr("&Paste"), 0, this); 320 editPaste=new QAction(tr("Paste Cells"), tr("&Paste"), 0, this);
321 connect(editPaste, SIGNAL(activated()), this, SLOT(slotEditPaste())); 321 connect(editPaste, SIGNAL(activated()), this, SLOT(slotEditPaste()));
322 editPasteContents=new QAction(tr("Paste Contents"), tr("Paste Cont&ents"), 0, this); 322 editPasteContents=new QAction(tr("Paste Contents"), tr("Paste Cont&ents"), 0, this);
323 connect(editPasteContents, SIGNAL(activated()), this, SLOT(slotEditPasteContents())); 323 connect(editPasteContents, SIGNAL(activated()), this, SLOT(slotEditPasteContents()));
324 editClear=new QAction(tr("Clear Cells"), tr("C&lear"), 0, this); 324 editClear=new QAction(tr("Clear Cells"), tr("C&lear"), 0, this);
325 325
326 insertCells=new QAction(tr("Insert Cells"), tr("C&ells"), 0, this); 326 insertCells=new QAction(tr("Insert Cells"), tr("C&ells"), 0, this);
327 connect(insertCells, SIGNAL(activated()), this, SLOT(slotInsertCells())); 327 connect(insertCells, SIGNAL(activated()), this, SLOT(slotInsertCells()));
328 insertRows=new QAction(tr("Insert Rows"), tr("&Rows"), 0, this); 328 insertRows=new QAction(tr("Insert Rows"), tr("&Rows"), 0, this);
329 connect(insertRows, SIGNAL(activated()), this, SLOT(slotInsertRows())); 329 connect(insertRows, SIGNAL(activated()), this, SLOT(slotInsertRows()));
330 insertCols=new QAction(tr("Insert Columns"), tr("&Columns"), 0, this); 330 insertCols=new QAction(tr("Insert Columns"), tr("&Columns"), 0, this);
331 connect(insertCols, SIGNAL(activated()), this, SLOT(slotInsertCols())); 331 connect(insertCols, SIGNAL(activated()), this, SLOT(slotInsertCols()));
332 insertSheets=new QAction(tr("Add Sheets"), tr("&Sheets"), 0, this); 332 insertSheets=new QAction(tr("Add Sheets"), tr("&Sheets"), 0, this);
333 connect(insertSheets, SIGNAL(activated()), this, SLOT(slotInsertSheets())); 333 connect(insertSheets, SIGNAL(activated()), this, SLOT(slotInsertSheets()));
334 334
335 formatCells=new QAction(tr("Cells"), tr("&Cells"), 0, this); 335 formatCells=new QAction(tr("Cells"), tr("&Cells"), 0, this);
336 connect(formatCells, SIGNAL(activated()), this, SLOT(slotFormatCells())); 336 connect(formatCells, SIGNAL(activated()), this, SLOT(slotFormatCells()));
337 337
338 rowHeight=new QAction(tr("Row Height"), tr("H&eight"), 0, this); 338 rowHeight=new QAction(tr("Row Height"), tr("H&eight"), 0, this);
339 connect(rowHeight, SIGNAL(activated()), this, SLOT(slotRowHeight())); 339 connect(rowHeight, SIGNAL(activated()), this, SLOT(slotRowHeight()));
340 rowAdjust=new QAction(tr("Adjust Row"), tr("&Adjust"), 0, this); 340 rowAdjust=new QAction(tr("Adjust Row"), tr("&Adjust"), 0, this);
341 connect(rowAdjust, SIGNAL(activated()), this, SLOT(slotRowAdjust())); 341 connect(rowAdjust, SIGNAL(activated()), this, SLOT(slotRowAdjust()));
342 rowShow=new QAction(tr("Show Row"), tr("&Show"), 0, this); 342 rowShow=new QAction(tr("Show Row"), tr("&Show"), 0, this);
343 connect(rowShow, SIGNAL(activated()), this, SLOT(slotRowShow())); 343 connect(rowShow, SIGNAL(activated()), this, SLOT(slotRowShow()));
344 rowHide=new QAction(tr("Hide Row"), tr("&Hide"), 0, this); 344 rowHide=new QAction(tr("Hide Row"), tr("&Hide"), 0, this);
345 connect(rowHide, SIGNAL(activated()), this, SLOT(slotRowHide())); 345 connect(rowHide, SIGNAL(activated()), this, SLOT(slotRowHide()));
346 346
347 colWidth=new QAction(tr("Column Width"), tr("&Width"), 0, this); 347 colWidth=new QAction(tr("Column Width"), tr("&Width"), 0, this);
348 connect(colWidth, SIGNAL(activated()), this, SLOT(slotColumnWidth())); 348 connect(colWidth, SIGNAL(activated()), this, SLOT(slotColumnWidth()));
349 colAdjust=new QAction(tr("Adjust Column"), tr("&Adjust"), 0, this); 349 colAdjust=new QAction(tr("Adjust Column"), tr("&Adjust"), 0, this);
350 connect(colAdjust, SIGNAL(activated()), this, SLOT(slotColumnAdjust())); 350 connect(colAdjust, SIGNAL(activated()), this, SLOT(slotColumnAdjust()));
351 colShow=new QAction(tr("Show Column"), tr("&Show"), 0, this); 351 colShow=new QAction(tr("Show Column"), tr("&Show"), 0, this);
352 connect(colShow, SIGNAL(activated()), this, SLOT(slotColumnShow())); 352 connect(colShow, SIGNAL(activated()), this, SLOT(slotColumnShow()));
353 colHide=new QAction(tr("Hide Column"), tr("&Hide"), 0, this); 353 colHide=new QAction(tr("Hide Column"), tr("&Hide"), 0, this);
354 connect(colHide, SIGNAL(activated()), this, SLOT(slotColumnHide())); 354 connect(colHide, SIGNAL(activated()), this, SLOT(slotColumnHide()));
355 355
356 sheetRename=new QAction(tr("Rename Sheet"), tr("&Rename"), 0, this); 356 sheetRename=new QAction(tr("Rename Sheet"), tr("&Rename"), 0, this);
357 connect(sheetRename, SIGNAL(activated()), this, SLOT(slotSheetRename())); 357 connect(sheetRename, SIGNAL(activated()), this, SLOT(slotSheetRename()));
358 sheetRemove=new QAction(tr("Remove Sheet"), tr("R&emove"), 0, this); 358 sheetRemove=new QAction(tr("Remove Sheet"), tr("R&emove"), 0, this);
359 connect(sheetRemove, SIGNAL(activated()), this, SLOT(slotSheetRemove())); 359 connect(sheetRemove, SIGNAL(activated()), this, SLOT(slotSheetRemove()));
360 360
361 dataSort=new QAction(tr("Sort Data"), tr("&Sort"), 0, this); 361 dataSort=new QAction(tr("Sort Data"), tr("&Sort"), 0, this);
362 connect(dataSort, SIGNAL(activated()), this, SLOT(slotDataSort())); 362 connect(dataSort, SIGNAL(activated()), this, SLOT(slotDataSort()));
363 dataFindReplace=new QAction(tr("Find && Replace"), tr("&Find && Replace"), 0, this); 363 dataFindReplace=new QAction(tr("Find && Replace"), tr("&Find && Replace"), 0, this);
364 connect(dataFindReplace, SIGNAL(activated()), this, SLOT(slotDataFindReplace())); 364 connect(dataFindReplace, SIGNAL(activated()), this, SLOT(slotDataFindReplace()));
365 365
366 funcEqual=new QAction(tr("Equal To"), Resource::loadPixmap( "opie-sheet/func-equal" ), tr("&Equal To"), 0, this); 366 funcEqual=new QAction(tr("Equal To"), Resource::loadPixmap( "opie-sheet/func-equal" ), tr("&Equal To"), 0, this);
367 funcEqual->setToolTip("="); 367 funcEqual->setToolTip("=");
368 connect(funcEqual, SIGNAL(activated()), this, SLOT(slotFuncOutput())); 368 connect(funcEqual, SIGNAL(activated()), this, SLOT(slotFuncOutput()));
369 funcPlus=new QAction(tr("Addition"), Resource::loadPixmap( "opie-sheet/func-plus" ), tr("&Addition"), 0, this); 369 funcPlus=new QAction(tr("Addition"), Resource::loadPixmap( "opie-sheet/func-plus" ), tr("&Addition"), 0, this);
370 funcPlus->setToolTip("+"); 370 funcPlus->setToolTip("+");
371 connect(funcPlus, SIGNAL(activated()), this, SLOT(slotFuncOutput())); 371 connect(funcPlus, SIGNAL(activated()), this, SLOT(slotFuncOutput()));
372 funcMinus=new QAction(tr("Subtraction"), Resource::loadPixmap( "opie-sheet/func-minus" ), tr("&Subtraction"), 0, this); 372 funcMinus=new QAction(tr("Subtraction"), Resource::loadPixmap( "opie-sheet/func-minus" ), tr("&Subtraction"), 0, this);
373 funcMinus->setToolTip("-"); 373 funcMinus->setToolTip("-");
374 connect(funcMinus, SIGNAL(activated()), this, SLOT(slotFuncOutput())); 374 connect(funcMinus, SIGNAL(activated()), this, SLOT(slotFuncOutput()));
375 funcCross=new QAction(tr("Multiplication"), Resource::loadPixmap ("opie-sheet/func-cross" ), tr("&Multiplication"), 0, this); 375 funcCross=new QAction(tr("Multiplication"), Resource::loadPixmap ("opie-sheet/func-cross" ), tr("&Multiplication"), 0, this);
376 funcCross->setToolTip("*"); 376 funcCross->setToolTip("*");
377 connect(funcCross, SIGNAL(activated()), this, SLOT(slotFuncOutput())); 377 connect(funcCross, SIGNAL(activated()), this, SLOT(slotFuncOutput()));
378 funcDivide=new QAction(tr("Division"), Resource::loadPixmap( "opie-sheet/func-divide" ), tr("&Division"), 0, this); 378 funcDivide=new QAction(tr("Division"), Resource::loadPixmap( "opie-sheet/func-divide" ), tr("&Division"), 0, this);
379 funcDivide->setToolTip("/"); 379 funcDivide->setToolTip("/");
380 connect(funcDivide, SIGNAL(activated()), this, SLOT(slotFuncOutput())); 380 connect(funcDivide, SIGNAL(activated()), this, SLOT(slotFuncOutput()));
381 funcParanOpen=new QAction(tr("Open ParanthesistempCellData->row+row1, tempCellData->col+col1"), Resource::loadPixmap( "opie-sheet/func-paran-open" ), tr("&Open Paranthesis"), 0, this); 381 funcParanOpen=new QAction(tr("Open ParanthesistempCellData->row+row1, tempCellData->col+col1"), Resource::loadPixmap( "opie-sheet/func-paran-open" ), tr("&Open Paranthesis"), 0, this);
382 funcParanOpen->setToolTip("("); 382 funcParanOpen->setToolTip("(");
383 connect(funcParanOpen, SIGNAL(activated()), this, SLOT(slotFuncOutput())); 383 connect(funcParanOpen, SIGNAL(activated()), this, SLOT(slotFuncOutput()));
384 funcParanClose=new QAction(tr("Close Paranthesis"), Resource::loadPixmap( "opie-sheet/func-paran-close" ), tr("&Close Paranthesis"), 0, this); 384 funcParanClose=new QAction(tr("Close Paranthesis"), Resource::loadPixmap( "opie-sheet/func-paran-close" ), tr("&Close Paranthesis"), 0, this);
385 funcParanClose->setToolTip(")"); 385 funcParanClose->setToolTip(")");
386 connect(funcParanClose, SIGNAL(activated()), this, SLOT(slotFuncOutput())); 386 connect(funcParanClose, SIGNAL(activated()), this, SLOT(slotFuncOutput()));
387 funcComma=new QAction(tr("Comma"), Resource::loadPixmap( "opie-sheet/func-comma" ), tr("&Comma"), 0, this); 387 funcComma=new QAction(tr("Comma"), Resource::loadPixmap( "opie-sheet/func-comma" ), tr("&Comma"), 0, this);
388 funcComma->setToolTip(","); 388 funcComma->setToolTip(",");
389 connect(funcComma, SIGNAL(activated()), this, SLOT(slotFuncOutput())); 389 connect(funcComma, SIGNAL(activated()), this, SLOT(slotFuncOutput()));
390} 390}
391 391
392void MainWindow::initMenu() 392void MainWindow::initMenu()
393{ 393{
394 menu=new QMenuBar(this); 394 menu=new QMenuBar(this);
395 395
396 menuFile=new QPopupMenu; 396 menuFile=new QPopupMenu;
397 fileNew->addTo(menuFile); 397 fileNew->addTo(menuFile);
398 fileOpen->addTo(menuFile); 398 fileOpen->addTo(menuFile);
399 fileSave->addTo(menuFile); 399 fileSave->addTo(menuFile);
400 fileSaveAs->addTo(menuFile); 400 fileSaveAs->addTo(menuFile);
401 // menuFile->insertSeparator(); 401 // menuFile->insertSeparator();
402 // fileQuit->addTo(menuFile); 402 // fileQuit->addTo(menuFile);
403 menuFile->insertSeparator(); 403 menuFile->insertSeparator();
404 fileExcelImport->addTo(menuFile); 404 fileExcelImport->addTo(menuFile);
405 menu->insertItem(tr("&File"), menuFile); 405 menu->insertItem(tr("&File"), menuFile);
406 406
407 menuEdit=new QPopupMenu; 407 menuEdit=new QPopupMenu;
408 editAccept->addTo(menuEdit); 408 editAccept->addTo(menuEdit);
409 editCancel->addTo(menuEdit); 409 editCancel->addTo(menuEdit);
410 editCellSelect->addTo(menuEdit); 410 editCellSelect->addTo(menuEdit);
411 menuEdit->insertSeparator(); 411 menuEdit->insertSeparator();
412 editCut->addTo(menuEdit); 412 editCut->addTo(menuEdit);
413 editCopy->addTo(menuEdit); 413 editCopy->addTo(menuEdit);
414 editPaste->addTo(menuEdit); 414 editPaste->addTo(menuEdit);
415 editPasteContents->addTo(menuEdit); 415 editPasteContents->addTo(menuEdit);
416 editClear->addTo(menuEdit); 416 editClear->addTo(menuEdit);
417 menu->insertItem(tr("&Edit"), menuEdit); 417 menu->insertItem(tr("&Edit"), menuEdit);
418 418
419 menuInsert=new QPopupMenu; 419 menuInsert=new QPopupMenu;
420 menu->insertItem(tr("&Insert"), menuInsert); 420 menu->insertItem(tr("&Insert"), menuInsert);
421 421
422 menuFormat=new QPopupMenu; 422 menuFormat=new QPopupMenu;
423 formatCells->addTo(menuFormat); 423 formatCells->addTo(menuFormat);
424 menu->insertItem(tr("&Format"), menuFormat); 424 menu->insertItem(tr("&Format"), menuFormat);
425 425
426 menuData=new QPopupMenu; 426 menuData=new QPopupMenu;
427 dataSort->addTo(menuData); 427 dataSort->addTo(menuData);
428 dataFindReplace->addTo(menuData); 428 dataFindReplace->addTo(menuData);
429 menu->insertItem(tr("&Data"), menuData); 429 menu->insertItem(tr("&Data"), menuData);
430 430
431 // menuHelp=new QPopupMenu; 431 // menuHelp=new QPopupMenu;
432 // helpGeneral->addTo(menuHelp); 432 // helpGeneral->addTo(menuHelp);
433 // helpAbout->addTo(menuHelp); 433 // helpAbout->addTo(menuHelp);
434 // menu->insertItem(tr("&Help"), menuHelp); 434 // menu->insertItem(tr("&Help"), menuHelp);
435 435
436 submenuRow=new QPopupMenu; 436 submenuRow=new QPopupMenu;
437 rowHeight->addTo(submenuRow); 437 rowHeight->addTo(submenuRow);
438 rowAdjust->addTo(submenuRow); 438 rowAdjust->addTo(submenuRow);
439 rowShow->addTo(submenuRow); 439 rowShow->addTo(submenuRow);
440 rowHide->addTo(submenuRow); 440 rowHide->addTo(submenuRow);
441 menuFormat->insertItem(tr("&Row"), submenuRow); 441 menuFormat->insertItem(tr("&Row"), submenuRow);
442 442
443 submenuCol=new QPopupMenu; 443 submenuCol=new QPopupMenu;
444 colWidth->addTo(submenuCol); 444 colWidth->addTo(submenuCol);
445 colAdjust->addTo(submenuCol); 445 colAdjust->addTo(submenuCol);
446 colShow->addTo(submenuCol); 446 colShow->addTo(submenuCol);
447 colHide->addTo(submenuCol); 447 colHide->addTo(submenuCol);
448 menuFormat->insertItem(tr("Colum&n"), submenuCol); 448 menuFormat->insertItem(tr("Colum&n"), submenuCol);
449 449
450 submenuSheet=new QPopupMenu; 450 submenuSheet=new QPopupMenu;
451 sheetRename->addTo(submenuSheet); 451 sheetRename->addTo(submenuSheet);
452 sheetRemove->addTo(submenuSheet); 452 sheetRemove->addTo(submenuSheet);
453 menuFormat->insertItem(tr("&Sheet"), submenuSheet); 453 menuFormat->insertItem(tr("&Sheet"), submenuSheet);
454 454
455 submenuFunc=new QPopupMenu; 455 submenuFunc=new QPopupMenu;
456 menuInsert->insertItem(tr("&Function"), submenuFunc); 456 menuInsert->insertItem(tr("&Function"), submenuFunc);
457 457
458 submenuFuncStd=new QPopupMenu; 458 submenuFuncStd=new QPopupMenu;
459 funcPlus->addTo(submenuFuncStd); 459 funcPlus->addTo(submenuFuncStd);
460 funcMinus->addTo(submenuFuncStd); 460 funcMinus->addTo(submenuFuncStd);
461 funcCross->addTo(submenuFuncStd); 461 funcCross->addTo(submenuFuncStd);
462 funcDivide->addTo(submenuFuncStd); 462 funcDivide->addTo(submenuFuncStd);
463 submenuFunc->insertItem(tr("&Simple"), submenuFuncStd); 463 submenuFunc->insertItem(tr("&Simple"), submenuFuncStd);
464 464
465 465
466 466
467 submenuFuncStandard=new QPopupMenu; 467 submenuFuncStandard=new QPopupMenu;
468 addFlyAction(tr("ABS(x)"), tr("ABS(x)"), "ABS(", submenuFuncStandard); 468 addFlyAction(tr("ABS(x)"), tr("ABS(x)"), "ABS(", submenuFuncStandard);
469 addFlyAction(tr("CEILING(x,acc)"), tr("CEILING(x,acc)"), "CEILING(", submenuFuncStandard); 469 addFlyAction(tr("CEILING(x,acc)"), tr("CEILING(x,acc)"), "CEILING(", submenuFuncStandard);
470 addFlyAction(tr("FACT(x)"), tr("FACT(x)"), "FACT(", submenuFuncStandard); 470 addFlyAction(tr("FACT(x)"), tr("FACT(x)"), "FACT(", submenuFuncStandard);
471 addFlyAction(tr("FLOOR(x,acc)"), tr("FLOOR(x,acc)"), "FLOOR(", submenuFuncStandard); 471 addFlyAction(tr("FLOOR(x,acc)"), tr("FLOOR(x,acc)"), "FLOOR(", submenuFuncStandard);
472 addFlyAction(tr("INT(x)"), tr("INT(x)"), "INT(", submenuFuncStandard); 472 addFlyAction(tr("INT(x)"), tr("INT(x)"), "INT(", submenuFuncStandard);
473 addFlyAction(tr("MOD(x,y)"), tr("MOD(x,y)"), "MOD(", submenuFuncStandard); 473 addFlyAction(tr("MOD(x,y)"), tr("MOD(x,y)"), "MOD(", submenuFuncStandard);
474 addFlyAction(tr("ROUND(x,digits)"), tr("ROUND(x,digits)"), "ROUND(", submenuFuncStandard); 474 addFlyAction(tr("ROUND(x,digits)"), tr("ROUND(x,digits)"), "ROUND(", submenuFuncStandard);
475 addFlyAction(tr("SIGN(x)"), tr("SIGN(x)"), "SIGN(", submenuFuncStandard); 475 addFlyAction(tr("SIGN(x)"), tr("SIGN(x)"), "SIGN(", submenuFuncStandard);
476 submenuFuncStandard->insertSeparator(); 476 submenuFuncStandard->insertSeparator();
477 addFlyAction(tr("EXP(x)"), tr("EXP(x)"), "EXP(", submenuFuncStandard); 477 addFlyAction(tr("EXP(x)"), tr("EXP(x)"), "EXP(", submenuFuncStandard);
478 addFlyAction(tr("LN(x)"), tr("LN(x)"), "LN(", submenuFuncStandard); 478 addFlyAction(tr("LN(x)"), tr("LN(x)"), "LN(", submenuFuncStandard);
479 addFlyAction(tr("LOG(x,b)"), tr("LOG(x,b)"), "LOG(", submenuFuncStandard); 479 addFlyAction(tr("LOG(x,b)"), tr("LOG(x,b)"), "LOG(", submenuFuncStandard);
480 addFlyAction(tr("LOG10(x)"), tr("LOG10(x)"), "LOG10(", submenuFuncStandard); 480 addFlyAction(tr("LOG10(x)"), tr("LOG10(x)"), "LOG10(", submenuFuncStandard);
481 addFlyAction(tr("POWER(x,y)"), tr("POWER(x,y)"), "POWER(", submenuFuncStandard); 481 addFlyAction(tr("POWER(x,y)"), tr("POWER(x,y)"), "POWER(", submenuFuncStandard);
482 addFlyAction(tr("SQRT(x)"), tr("SQRT(x)"), "SQRT(", submenuFuncStandard); 482 addFlyAction(tr("SQRT(x)"), tr("SQRT(x)"), "SQRT(", submenuFuncStandard);
483 submenuFuncStandard->insertSeparator(); 483 submenuFuncStandard->insertSeparator();
484 addFlyAction(tr("DEGREES(x)"), tr("DEGREES(x)"), "DEGREES(", submenuFuncStandard); 484 addFlyAction(tr("DEGREES(x)"), tr("DEGREES(x)"), "DEGREES(", submenuFuncStandard);
485 addFlyAction(tr("RADIANS(x)"), tr("RADIANS(x)"), "RADIANS(", submenuFuncStandard); 485 addFlyAction(tr("RADIANS(x)"), tr("RADIANS(x)"), "RADIANS(", submenuFuncStandard);
486 addFlyAction(tr("PI()"), tr("PI()"), "PI()", submenuFuncStandard); 486 addFlyAction(tr("PI()"), tr("PI()"), "PI()", submenuFuncStandard);
487 addFlyAction(tr("RAND()"), tr("RAND()"), "RAND(", submenuFuncStandard); 487 addFlyAction(tr("RAND()"), tr("RAND()"), "RAND(", submenuFuncStandard);
488 addFlyAction(tr("RANDBETWEEN(a,b)"), tr("RANDBETWEEN(a,b)"), "RANDBETWEEN(", submenuFuncStandard); 488 addFlyAction(tr("RANDBETWEEN(a,b)"), tr("RANDBETWEEN(a,b)"), "RANDBETWEEN(", submenuFuncStandard);
489 submenuFunc->insertItem(tr("S&tandard"), submenuFuncStandard); 489 submenuFunc->insertItem(tr("S&tandard"), submenuFuncStandard);
490 490
491 submenuFuncLogic=new QPopupMenu; 491 submenuFuncLogic=new QPopupMenu;
492 addFlyAction(tr("AND(x1,x2)"), tr("AND(x1,x2)"), "AND(", submenuFuncLogic); 492 addFlyAction(tr("AND(x1,x2)"), tr("AND(x1,x2)"), "AND(", submenuFuncLogic);
493 addFlyAction(tr("NOT(x)"), tr("NOT(x)"), "NOT(", submenuFuncLogic); 493 addFlyAction(tr("NOT(x)"), tr("NOT(x)"), "NOT(", submenuFuncLogic);
494 addFlyAction(tr("OR(x1,x2)"), tr("OR(x1,x2)"), "OR(", submenuFuncLogic); 494 addFlyAction(tr("OR(x1,x2)"), tr("OR(x1,x2)"), "OR(", submenuFuncLogic);
495 submenuFuncLogic->insertSeparator(); 495 submenuFuncLogic->insertSeparator();
496 addFlyAction(tr("IF(compare,val1,val2)"), tr("IF(compare,val1,val2)"), "IF(", submenuFuncLogic); 496 addFlyAction(tr("IF(compare,val1,val2)"), tr("IF(compare,val1,val2)"), "IF(", submenuFuncLogic);
497 addFlyAction(tr("INDEX(range,index)"),tr("INDEX(range,index)"), "INDEX(", submenuFuncLogic); 497 addFlyAction(tr("INDEX(range,index)"),tr("INDEX(range,index)"), "INDEX(", submenuFuncLogic);
498 addFlyAction(tr("ISBLANK(x)"), tr("ISBLANK(x)"), "ISBLANK(", submenuFuncLogic); 498 addFlyAction(tr("ISBLANK(x)"), tr("ISBLANK(x)"), "ISBLANK(", submenuFuncLogic);
499 addFlyAction(tr("ISNUMBER(x)"), tr("ISNUMBER(x)"), "ISNUMBER(", submenuFuncLogic); 499 addFlyAction(tr("ISNUMBER(x)"), tr("ISNUMBER(x)"), "ISNUMBER(", submenuFuncLogic);
500 addFlyAction(tr("EVEN(x)"), tr("EVEN(x)"), "EVEN(", submenuFuncLogic); 500 addFlyAction(tr("EVEN(x)"), tr("EVEN(x)"), "EVEN(", submenuFuncLogic);
501 addFlyAction(tr("ISEVEN(x)"), tr("ISEVEN(x)"), "ISEVEN(", submenuFuncLogic); 501 addFlyAction(tr("ISEVEN(x)"), tr("ISEVEN(x)"), "ISEVEN(", submenuFuncLogic);
502 addFlyAction(tr("ODD(x)"), tr("ODD(x)"), "ODD(", submenuFuncLogic); 502 addFlyAction(tr("ODD(x)"), tr("ODD(x)"), "ODD(", submenuFuncLogic);
503 addFlyAction(tr("ISODD(x)"), tr("ISODD(x)"), "ISODD(", submenuFuncLogic); 503 addFlyAction(tr("ISODD(x)"), tr("ISODD(x)"), "ISODD(", submenuFuncLogic);
504 submenuFunc->insertItem(tr("Logical-&Information"), submenuFuncLogic); 504 submenuFunc->insertItem(tr("Logical-&Information"), submenuFuncLogic);
505 505
506 submenuFuncTrig=new QPopupMenu; 506 submenuFuncTrig=new QPopupMenu;
507 addFlyAction(tr("SIN(x)"), tr("SIN(x)"), "SIN(", submenuFuncTrig); 507 addFlyAction(tr("SIN(x)"), tr("SIN(x)"), "SIN(", submenuFuncTrig);
508 addFlyAction(tr("COS(x)"), tr("COS(x)"), "COS(", submenuFuncTrig); 508 addFlyAction(tr("COS(x)"), tr("COS(x)"), "COS(", submenuFuncTrig);
509 addFlyAction(tr("TAN(x)"), tr("TAN(x)"), "TAN(", submenuFuncTrig); 509 addFlyAction(tr("TAN(x)"), tr("TAN(x)"), "TAN(", submenuFuncTrig);
510 addFlyAction(tr("ASIN(x)"), tr("ASIN(x)"), "ASIN(", submenuFuncTrig); 510 addFlyAction(tr("ASIN(x)"), tr("ASIN(x)"), "ASIN(", submenuFuncTrig);
511 addFlyAction(tr("ACOS(x)"), tr("ACOS(x)"), "ACOS(", submenuFuncTrig); 511 addFlyAction(tr("ACOS(x)"), tr("ACOS(x)"), "ACOS(", submenuFuncTrig);
512 addFlyAction(tr("ATAN(x)"), tr("ATAN(x)"), "ATAN(", submenuFuncTrig); 512 addFlyAction(tr("ATAN(x)"), tr("ATAN(x)"), "ATAN(", submenuFuncTrig);
513 addFlyAction(tr("ATAN2(x,y)"), tr("ATAN2(x,y)"), "ATAN2(", submenuFuncTrig); 513 addFlyAction(tr("ATAN2(x,y)"), tr("ATAN2(x,y)"), "ATAN2(", submenuFuncTrig);
514 submenuFuncTrig->insertSeparator(); 514 submenuFuncTrig->insertSeparator();
515 addFlyAction(tr("SINH(x)"), tr("SINH(x)"), "SINH(", submenuFuncTrig); 515 addFlyAction(tr("SINH(x)"), tr("SINH(x)"), "SINH(", submenuFuncTrig);
516 addFlyAction(tr("COSH(x)"), tr("COSH(x)"), "COSH(", submenuFuncTrig); 516 addFlyAction(tr("COSH(x)"), tr("COSH(x)"), "COSH(", submenuFuncTrig);
517 addFlyAction(tr("TANH(x)"), tr("TANH(x)"), "TANH(", submenuFuncTrig); 517 addFlyAction(tr("TANH(x)"), tr("TANH(x)"), "TANH(", submenuFuncTrig);
518 addFlyAction(tr("ACOSH(x)"), tr("ACOSH(x)"), "ACOSH(", submenuFuncTrig); 518 addFlyAction(tr("ACOSH(x)"), tr("ACOSH(x)"), "ACOSH(", submenuFuncTrig);
519 addFlyAction(tr("ASINH(x)"), tr("ASINH(x)"), "ASINH(", submenuFuncTrig); 519 addFlyAction(tr("ASINH(x)"), tr("ASINH(x)"), "ASINH(", submenuFuncTrig);
520 addFlyAction(tr("ATANH(x)"), tr("ATANH(x)"), "ATANH(", submenuFuncTrig); 520 addFlyAction(tr("ATANH(x)"), tr("ATANH(x)"), "ATANH(", submenuFuncTrig);
521 submenuFunc->insertItem(tr("&Trigonometric"), submenuFuncTrig); 521 submenuFunc->insertItem(tr("&Trigonometric"), submenuFuncTrig);
522 522
523 submenuFuncString=new QPopupMenu; 523 submenuFuncString=new QPopupMenu;
524 addFlyAction(tr("LEN(s)"), tr("LEN(s)"), "LEN(",submenuFuncString); 524 addFlyAction(tr("LEN(s)"), tr("LEN(s)"), "LEN(",submenuFuncString);
525 addFlyAction(tr("LEFT(s,num)"), tr("LEFT(s,num)"), "LEFT(",submenuFuncString); 525 addFlyAction(tr("LEFT(s,num)"), tr("LEFT(s,num)"), "LEFT(",submenuFuncString);
526 addFlyAction(tr("RIGHT(s,num)"), tr("RIGHT(s,num)"), "RIGHT(",submenuFuncString); 526 addFlyAction(tr("RIGHT(s,num)"), tr("RIGHT(s,num)"), "RIGHT(",submenuFuncString);
527 addFlyAction(tr("MID(s,pos,len)"), tr("MID(s,pos,len)"), "MID(",submenuFuncString); 527 addFlyAction(tr("MID(s,pos,len)"), tr("MID(s,pos,len)"), "MID(",submenuFuncString);
528 submenuFuncString->insertSeparator(); 528 submenuFuncString->insertSeparator();
529 addFlyAction(tr("CONCATENATE(s1,s2..)"), tr("CONCATENATE(s1,s2..)"), "CONCATENATE(",submenuFuncString); 529 addFlyAction(tr("CONCATENATE(s1,s2..)"), tr("CONCATENATE(s1,s2..)"), "CONCATENATE(",submenuFuncString);
530 addFlyAction(tr("EXACT(s1,s2)"), tr("EXACT(s1,s2)"), "EXACT(",submenuFuncString); 530 addFlyAction(tr("EXACT(s1,s2)"), tr("EXACT(s1,s2)"), "EXACT(",submenuFuncString);
531 addFlyAction(tr("FIND(what,where,pos)"), 531 addFlyAction(tr("FIND(what,where,pos)"),
532 tr("FIND(what,where,pos)"), "FIND(",submenuFuncString); 532 tr("FIND(what,where,pos)"), "FIND(",submenuFuncString);
533 addFlyAction(tr("REPLACE(s,pos,len,ns)"), tr("REPLACE(s,pos,len,ns)"), "REPLACE(",submenuFuncString); 533 addFlyAction(tr("REPLACE(s,pos,len,ns)"), tr("REPLACE(s,pos,len,ns)"), "REPLACE(",submenuFuncString);
534 addFlyAction(tr("REPT(s,n)"), tr("REPT(s,n)"), "REPT(",submenuFuncString); 534 addFlyAction(tr("REPT(s,n)"), tr("REPT(s,n)"), "REPT(",submenuFuncString);
535 submenuFuncString->insertSeparator(); 535 submenuFuncString->insertSeparator();
536 addFlyAction(tr("UPPER(s)"), tr("UPPER(s)"), "UPPER(",submenuFuncString); 536 addFlyAction(tr("UPPER(s)"), tr("UPPER(s)"), "UPPER(",submenuFuncString);
537 addFlyAction(tr("LOWER(s)"), tr("LOWER(s)"), "LOWER(",submenuFuncString); 537 addFlyAction(tr("LOWER(s)"), tr("LOWER(s)"), "LOWER(",submenuFuncString);
538 submenuFunc->insertItem(tr("&Strings"), submenuFuncString); 538 submenuFunc->insertItem(tr("&Strings"), submenuFuncString);
539 539
540 submenuFuncStat=new QPopupMenu; 540 submenuFuncStat=new QPopupMenu;
541 addFlyAction(tr("AVERAGE(range)"), tr("AVERAGE(range)"), "AVERAGE(",submenuFuncStat); 541 addFlyAction(tr("AVERAGE(range)"), tr("AVERAGE(range)"), "AVERAGE(",submenuFuncStat);
542 addFlyAction(tr("COUNT(range)"), tr("COUNT(range)"), "COUNT(",submenuFuncStat); 542 addFlyAction(tr("COUNT(range)"), tr("COUNT(range)"), "COUNT(",submenuFuncStat);
543 addFlyAction(tr("COUNTIF(range,eqls)"), tr("COUNTIF(range,eqls)"), "COUNTIF(",submenuFuncStat); 543 addFlyAction(tr("COUNTIF(range,eqls)"), tr("COUNTIF(range,eqls)"), "COUNTIF(",submenuFuncStat);
544 addFlyAction(tr("MAX(range)"), tr("MAX(range)"), "MAX(",submenuFuncStat); 544 addFlyAction(tr("MAX(range)"), tr("MAX(range)"), "MAX(",submenuFuncStat);
545 addFlyAction(tr("MIN(range)"), tr("MIN(range)"), "MIN(",submenuFuncStat); 545 addFlyAction(tr("MIN(range)"), tr("MIN(range)"), "MIN(",submenuFuncStat);
546 addFlyAction(tr("SUM(range)"), tr("SUM(range)"), "SUM(",submenuFuncStat); 546 addFlyAction(tr("SUM(range)"), tr("SUM(range)"), "SUM(",submenuFuncStat);
547 addFlyAction(tr("SUMSQ(range)"), tr("SUMSQ(range)"), "SUMSQ(",submenuFuncStat); 547 addFlyAction(tr("SUMSQ(range)"), tr("SUMSQ(range)"), "SUMSQ(",submenuFuncStat);
548 submenuFuncStat->insertSeparator(); 548 submenuFuncStat->insertSeparator();
549 addFlyAction(tr("AVERAGE(range)"), tr("AVERAGE(range)"), "AVERAGE(",submenuFuncStat); 549 addFlyAction(tr("AVERAGE(range)"), tr("AVERAGE(range)"), "AVERAGE(",submenuFuncStat);
550 addFlyAction(tr("VAR(range)"), tr("VAR(range)"), "VAR(",submenuFuncStat); 550 addFlyAction(tr("VAR(range)"), tr("VAR(range)"), "VAR(",submenuFuncStat);
551 addFlyAction(tr("VARP(range)"), tr("VARP(range)"), "VARP(",submenuFuncStat); 551 addFlyAction(tr("VARP(range)"), tr("VARP(range)"), "VARP(",submenuFuncStat);
552 addFlyAction(tr("STDEV(range)"), tr("STDEV(range)"), "STDEV(",submenuFuncStat); 552 addFlyAction(tr("STDEV(range)"), tr("STDEV(range)"), "STDEV(",submenuFuncStat);
553 addFlyAction(tr("STDEVP(range)"), tr("STDEVP(range)"), "STDEVP(",submenuFuncStat); 553 addFlyAction(tr("STDEVP(range)"), tr("STDEVP(range)"), "STDEVP(",submenuFuncStat);
554 addFlyAction(tr("SKEW(range)"), tr("SKEW(range)"), "SKEW(",submenuFuncStat); 554 addFlyAction(tr("SKEW(range)"), tr("SKEW(range)"), "SKEW(",submenuFuncStat);
555 addFlyAction(tr("KURT(range)"), tr("KURT(range)"), "KURT(",submenuFuncStat); 555 addFlyAction(tr("KURT(range)"), tr("KURT(range)"), "KURT(",submenuFuncStat);
556 submenuFunc->insertItem(tr("Sta&tistical"), submenuFuncStat); 556 submenuFunc->insertItem(tr("Sta&tistical"), submenuFuncStat);
557 557
558 submenuFuncScientific=new QPopupMenu; 558 submenuFuncScientific=new QPopupMenu;
559 addFlyAction(tr("BESSELI(x,n)"), tr("BESSELI(x,n)"), "BESSELI(",submenuFuncScientific); 559 addFlyAction(tr("BESSELI(x,n)"), tr("BESSELI(x,n)"), "BESSELI(",submenuFuncScientific);
560 addFlyAction(tr("BESSELJ(x,n)"), tr("BESSELJ(x,n)"), "BESSELJ(",submenuFuncScientific); 560 addFlyAction(tr("BESSELJ(x,n)"), tr("BESSELJ(x,n)"), "BESSELJ(",submenuFuncScientific);
561 addFlyAction(tr("BESSELK(x,n)"), tr("BESSELK(x,n)"), "BESSELK(",submenuFuncScientific); 561 addFlyAction(tr("BESSELK(x,n)"), tr("BESSELK(x,n)"), "BESSELK(",submenuFuncScientific);
562 addFlyAction(tr("BESSELY(x,n)"), tr("BESSELY(x,n)"), "BESSELY(",submenuFuncScientific); 562 addFlyAction(tr("BESSELY(x,n)"), tr("BESSELY(x,n)"), "BESSELY(",submenuFuncScientific);
563 submenuFuncScientific->insertSeparator(); 563 submenuFuncScientific->insertSeparator();
564 addFlyAction(tr("BETAI(x,a,b)"), tr("BETAI(x,a,b)"), "BETAI(",submenuFuncScientific); 564 addFlyAction(tr("BETAI(x,a,b)"), tr("BETAI(x,a,b)"), "BETAI(",submenuFuncScientific);
565 addFlyAction(tr("ERF(a,b)"), tr("ERF(a,b)"), "ERF(",submenuFuncScientific); 565 addFlyAction(tr("ERF(a,b)"), tr("ERF(a,b)"), "ERF(",submenuFuncScientific);
566 addFlyAction(tr("ERFC(a,b)"), tr("ERFC(a,b)"), "ERFC(",submenuFuncScientific); 566 addFlyAction(tr("ERFC(a,b)"), tr("ERFC(a,b)"), "ERFC(",submenuFuncScientific);
567 addFlyAction(tr("GAMMALN(x)"), tr("GAMMALN(x)"), "GAMMALN(",submenuFuncScientific); 567 addFlyAction(tr("GAMMALN(x)"), tr("GAMMALN(x)"), "GAMMALN(",submenuFuncScientific);
568 addFlyAction(tr("GAMMAP(x,a)"), tr("GAMMAP(x,a)"), "GAMMAP(",submenuFuncScientific); 568 addFlyAction(tr("GAMMAP(x,a)"), tr("GAMMAP(x,a)"), "GAMMAP(",submenuFuncScientific);
569 addFlyAction(tr("GAMMAQ(x,a)"), tr("GAMMAQ(x,a)"), "GAMMAQ(",submenuFuncScientific); 569 addFlyAction(tr("GAMMAQ(x,a)"), tr("GAMMAQ(x,a)"), "GAMMAQ(",submenuFuncScientific);
570 submenuFunc->insertItem(tr("Scienti&fic"), submenuFuncScientific); 570 submenuFunc->insertItem(tr("Scienti&fic"), submenuFuncScientific);
571 571
572 submenuFuncDistr=new QPopupMenu; 572 submenuFuncDistr=new QPopupMenu;
573 addFlyAction(tr("BETADIST(z,a,b,Q?)"), tr("BETADIST(z,a,b,Q?)"), "BETADIST(",submenuFuncDistr); 573 addFlyAction(tr("BETADIST(z,a,b,Q?)"), tr("BETADIST(z,a,b,Q?)"), "BETADIST(",submenuFuncDistr);
574 addFlyAction(tr("CHI2DIST(x,n,Q?)"), tr("CHI2DIST(x,n,Q?)"), "CHI2DIST(",submenuFuncDistr); 574 addFlyAction(tr("CHI2DIST(x,n,Q?)"), tr("CHI2DIST(x,n,Q?)"), "CHI2DIST(",submenuFuncDistr);
575 addFlyAction(tr("CHIDIST(x,n,Q?)"), tr("CHIDIST(x,n,Q?)"), "CHIDIST(",submenuFuncDistr); 575 addFlyAction(tr("CHIDIST(x,n,Q?)"), tr("CHIDIST(x,n,Q?)"), "CHIDIST(",submenuFuncDistr);
576 addFlyAction(tr("FDIST(z,deg1,deg2,Q?)"), tr("FDIST(z,deg1,deg2,Q?)"), "FDIST(",submenuFuncDistr); 576 addFlyAction(tr("FDIST(z,deg1,deg2,Q?)"), tr("FDIST(z,deg1,deg2,Q?)"), "FDIST(",submenuFuncDistr);
577 addFlyAction(tr("GAMMADIST(x,a,b,Q?)"), tr("GAMMADIST(x,a,b,Q?)"), "GAMMADIST(",submenuFuncDistr); 577 addFlyAction(tr("GAMMADIST(x,a,b,Q?)"), tr("GAMMADIST(x,a,b,Q?)"), "GAMMADIST(",submenuFuncDistr);
578 addFlyAction(tr("NORMALDIST(x,m,s,Q?)"), tr("NORMALDIST(x,m,s,Q?)"), "NORMALDIST(",submenuFuncDistr); 578 addFlyAction(tr("NORMALDIST(x,m,s,Q?)"), tr("NORMALDIST(x,m,s,Q?)"), "NORMALDIST(",submenuFuncDistr);
579 addFlyAction(tr("PHI(x,Q?)"), tr("PHI(x,Q?)"), "PHI(",submenuFuncDistr); 579 addFlyAction(tr("PHI(x,Q?)"), tr("PHI(x,Q?)"), "PHI(",submenuFuncDistr);
580 addFlyAction(tr("POISSON(x,n,Q?)"), tr("POISSON(x,n,Q?)"), "POISSON(",submenuFuncDistr); 580 addFlyAction(tr("POISSON(x,n,Q?)"), tr("POISSON(x,n,Q?)"), "POISSON(",submenuFuncDistr);
581 submenuFunc->insertItem(tr("&Distributions"), submenuFuncDistr); 581 submenuFunc->insertItem(tr("&Distributions"), submenuFuncDistr);
582 582
583 583
584 584
585 menuInsert->insertSeparator(); 585 menuInsert->insertSeparator();
586 insertCells->addTo(menuInsert); 586 insertCells->addTo(menuInsert);
587 insertRows->addTo(menuInsert); 587 insertRows->addTo(menuInsert);
588 insertCols->addTo(menuInsert); 588 insertCols->addTo(menuInsert);
589 insertSheets->addTo(menuInsert); 589 insertSheets->addTo(menuInsert);
590} 590}
591 591
592void MainWindow::initStandardToolbar() 592void MainWindow::initStandardToolbar()
593{ 593{
594 toolbarStandard=new QToolBar(this); 594 toolbarStandard=new QToolBar(this);
595 toolbarStandard->setHorizontalStretchable(TRUE); 595 toolbarStandard->setHorizontalStretchable(TRUE);
596 moveToolBar(toolbarStandard, Top); 596 moveToolBar(toolbarStandard, Top);
597 597
598 fileNew->addTo(toolbarStandard); 598 fileNew->addTo(toolbarStandard);
599 fileOpen->addTo(toolbarStandard); 599 fileOpen->addTo(toolbarStandard);
600 fileSave->addTo(toolbarStandard); 600 fileSave->addTo(toolbarStandard);
601 601
602 comboSheets=new QComboBox(toolbarStandard); 602 comboSheets=new QComboBox(toolbarStandard);
603 toolbarStandard->setStretchableWidget(comboSheets); 603 toolbarStandard->setStretchableWidget(comboSheets);
604 connect(comboSheets, SIGNAL(activated(const QString&)), this, SLOT(slotSheetChanged(const QString&))); 604 connect(comboSheets, SIGNAL(activated(const QString&)), this, SLOT(slotSheetChanged(const QString&)));
605} 605}
606 606
607void MainWindow::initFunctionsToolbar() 607void MainWindow::initFunctionsToolbar()
608{ 608{
609 toolbarFunctions=new QToolBar(this); 609 toolbarFunctions=new QToolBar(this);
610 toolbarFunctions->setHorizontalStretchable(TRUE); 610 toolbarFunctions->setHorizontalStretchable(TRUE);
611 moveToolBar(toolbarFunctions, Bottom); 611 moveToolBar(toolbarFunctions, Bottom);
612 612
613 funcEqual->addTo(toolbarFunctions); 613 funcEqual->addTo(toolbarFunctions);
614 funcPlus->addTo(toolbarFunctions); 614 funcPlus->addTo(toolbarFunctions);
615 funcMinus->addTo(toolbarFunctions); 615 funcMinus->addTo(toolbarFunctions);
616 funcCross->addTo(toolbarFunctions); 616 funcCross->addTo(toolbarFunctions);
617 funcDivide->addTo(toolbarFunctions); 617 funcDivide->addTo(toolbarFunctions);
618 funcParanOpen->addTo(toolbarFunctions); 618 funcParanOpen->addTo(toolbarFunctions);
619 funcParanClose->addTo(toolbarFunctions); 619 funcParanClose->addTo(toolbarFunctions);
620 funcComma->addTo(toolbarFunctions); 620 funcComma->addTo(toolbarFunctions);
621 621
622 toolFunction=new QToolButton(toolbarFunctions); 622 toolFunction=new QToolButton(toolbarFunctions);
623 toolFunction->setPixmap(Resource::loadPixmap( "opie-sheet/func-func" )); 623 toolFunction->setPixmap(Resource::loadPixmap( "opie-sheet/func-func" ));
624 toolFunction->setTextLabel(tr("Functions")); 624 toolFunction->setTextLabel(tr("Functions"));
625 toolFunction->setPopup(submenuFunc); 625 toolFunction->setPopup(submenuFunc);
626 toolFunction->setPopupDelay(0); 626 toolFunction->setPopupDelay(0);
627} 627}
628 628
629void MainWindow::initEditToolbar() 629void MainWindow::initEditToolbar()
630{ 630{
631 toolbarEdit=new QToolBar(this); 631 toolbarEdit=new QToolBar(this);
632 toolbarEdit->setHorizontalStretchable(TRUE); 632 toolbarEdit->setHorizontalStretchable(TRUE);
633 moveToolBar(toolbarEdit, Bottom); 633 moveToolBar(toolbarEdit, Bottom);
634 634
635 editAccept->addTo(toolbarEdit); 635 editAccept->addTo(toolbarEdit);
636 editCancel->addTo(toolbarEdit); 636 editCancel->addTo(toolbarEdit);
637 637
638 editData=new QLineEdit(toolbarEdit); 638 editData=new QLineEdit(toolbarEdit);
639 toolbarEdit->setStretchableWidget(editData); 639 toolbarEdit->setStretchableWidget(editData);
640 connect(editData, SIGNAL(returnPressed()), this, SLOT(slotEditAccept())); 640 connect(editData, SIGNAL(returnPressed()), this, SLOT(slotEditAccept()));
641 641
642 editCellSelect->addTo(toolbarEdit); 642 editCellSelect->addTo(toolbarEdit);
643} 643}
644 644
645void MainWindow::slotHelpAbout() 645void MainWindow::slotHelpAbout()
646{ 646{
647 QDialog dialogAbout(this, 0, TRUE); 647 QDialog dialogAbout(this, 0, TRUE);
648 dialogAbout.resize(width()-40, height()-80); 648 dialogAbout.resize(width()-40, height()-80);
649 dialogAbout.setCaption(tr("About Opie Sheet")); 649 dialogAbout.setCaption(tr("About Opie Sheet"));
650 650
651 QLabel label(tr("Opie Sheet\nSpreadsheet Software for Opie\nQWDC Beta Winner (as Sheet/Qt)\n\nDeveloped by: Serdar Ozler\nRelease 1.0.2\nRelease Date: October 08, 2002\n\nThis product is licensed under GPL. It is freely distributable. If you want to get the latest version and also the source code, please visit the web site.\n\nhttp://qtopia.sitebest.com"), &dialogAbout); 651 QLabel label(tr("Opie Sheet\nSpreadsheet Software for Opie\nQWDC Beta Winner (as Sheet/Qt)\n\nDeveloped by: Serdar Ozler\nRelease 1.0.2\nRelease Date: October 08, 2002\n\nThis product is licensed under GPL. It is freely distributable. If you want to get the latest version and also the source code, please visit the web site.\n\nhttp://qtopia.sitebest.com"), &dialogAbout);
652 label.setGeometry(dialogAbout.rect()); 652 label.setGeometry(dialogAbout.rect());
653 label.setAlignment(Qt::AlignCenter | Qt::WordBreak); 653 label.setAlignment(Qt::AlignCenter | Qt::WordBreak);
654 654
655 dialogAbout.exec(); 655 dialogAbout.exec();
656} 656}
657 657
658void MainWindow::initSheet() 658void MainWindow::initSheet()
659{ 659{
660 sheet=new Sheet(DEFAULT_NUM_ROWS, DEFAULT_NUM_COLS, this); 660 sheet=new Sheet(DEFAULT_NUM_ROWS, DEFAULT_NUM_COLS, this);
661 setCentralWidget(sheet); 661 setCentralWidget(sheet);
662 662
663 connect(sheet, SIGNAL(currentDataChanged(const QString&)), editData, SLOT(setText(const QString&))); 663 connect(sheet, SIGNAL(currentDataChanged(const QString&)), editData, SLOT(setText(const QString&)));
664 connect(sheet, SIGNAL(cellClicked(const QString&)), this, SLOT(slotCellClicked(const QString&))); 664 connect(sheet, SIGNAL(cellClicked(const QString&)), this, SLOT(slotCellClicked(const QString&)));
665 connect(sheet, SIGNAL(sheetModified()), this, SLOT(slotDocModified())); 665 connect(sheet, SIGNAL(sheetModified()), this, SLOT(slotDocModified()));
666 666
667 connect(editCut, SIGNAL(activated()), sheet, SLOT(editCut())); 667 connect(editCut, SIGNAL(activated()), sheet, SLOT(editCut()));
668 connect(editCopy, SIGNAL(activated()), sheet, SLOT(editCopy())); 668 connect(editCopy, SIGNAL(activated()), sheet, SLOT(editCopy()));
669 connect(editClear, SIGNAL(activated()), sheet, SLOT(editClear())); 669 connect(editClear, SIGNAL(activated()), sheet, SLOT(editClear()));
670} 670}
671 671
672void MainWindow::slotEditAccept() 672void MainWindow::slotEditAccept()
673{ 673{
674 sheet->setData(editData->text()); 674 sheet->setData(editData->text());
675} 675}
676 676
677void MainWindow::slotEditCancel() 677void MainWindow::slotEditCancel()
678{ 678{
679 editData->setText(sheet->getData()); 679 editData->setText(sheet->getData());
680} 680}
681 681
682void MainWindow::slotCellSelect(bool lock) 682void MainWindow::slotCellSelect(bool lock)
683{ 683{
684 sheet->lockClicks(lock); 684 sheet->lockClicks(lock);
685} 685}
686 686
687void MainWindow::addToData(const QString &data) 687void MainWindow::addToData(const QString &data)
688{ 688{
689 editData->setText(editData->text().insert(editData->cursorPosition(), data)); 689 editData->setText(editData->text().insert(editData->cursorPosition(), data));
690} 690}
691 691
692void MainWindow::slotFuncOutput() 692void MainWindow::slotFuncOutput()
693{ 693{
694 if (sender()->isA("QAction")) 694 if (sender()->isA("QAction"))
695 addToData(((QAction *)sender())->toolTip()); 695 addToData(((QAction *)sender())->toolTip());
696} 696}
697 697
698void MainWindow::slotInsertRows() 698void MainWindow::slotInsertRows()
699{ 699{
700 NumberDialog dialogNumber(this); 700 NumberDialog dialogNumber(this);
701 if (dialogNumber.exec(tr("Insert Rows"), tr("&Number of rows:"))==QDialog::Accepted) 701 if (dialogNumber.exec(tr("Insert Rows"), tr("&Number of rows:"))==QDialog::Accepted)
702 sheet->insertRows(dialogNumber.getValue()); 702 sheet->insertRows(dialogNumber.getValue());
703} 703}
704 704
705void MainWindow::slotInsertCols() 705void MainWindow::slotInsertCols()
706{ 706{
707 NumberDialog dialogNumber(this); 707 NumberDialog dialogNumber(this);
708 if (dialogNumber.exec(tr("Insert Columns"), tr("&Number of columns:"))==QDialog::Accepted) 708 if (dialogNumber.exec(tr("Insert Columns"), tr("&Number of columns:"))==QDialog::Accepted)
709 sheet->insertColumns(dialogNumber.getValue()); 709 sheet->insertColumns(dialogNumber.getValue());
710} 710}
711 711
712void MainWindow::slotInsertSheets() 712void MainWindow::slotInsertSheets()
713{ 713{
714 NumberDialog dialogNumber(this); 714 NumberDialog dialogNumber(this);
715 if (dialogNumber.exec(tr("Add Sheets"), tr("&Number of sheets:"))==QDialog::Accepted) 715 if (dialogNumber.exec(tr("Add Sheets"), tr("&Number of sheets:"))==QDialog::Accepted)
716 for (int i=dialogNumber.getValue(); i>0; --i) createNewSheet(); 716 for (int i=dialogNumber.getValue(); i>0; --i) createNewSheet();
717} 717}
718 718
719void MainWindow::slotCellClicked(const QString &cell) 719void MainWindow::slotCellClicked(const QString &cell)
720{ 720{
721 editCellSelect->setOn(FALSE); 721 editCellSelect->setOn(FALSE);
722 addToData(cell); 722 addToData(cell);
723} 723}
724 724
725typeSheet *MainWindow::createNewSheet() 725typeSheet *MainWindow::createNewSheet()
726{ 726{
727 typeSheet *newSheet=new typeSheet; 727 typeSheet *newSheet=new typeSheet;
728 int currentNo=1, tempNo=0; 728 int currentNo=1, tempNo=0;
729 bool ok; 729 bool ok;
730 730
731 for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) 731 for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next())
732 if (tempSheet->name.startsWith(tr("Sheet")) && (tempNo=tempSheet->name.mid(tr("Sheet").length()).toInt(&ok))>=currentNo && ok) 732 if (tempSheet->name.startsWith(tr("Sheet")) && (tempNo=tempSheet->name.mid(tr("Sheet").length()).toInt(&ok))>=currentNo && ok)
733 currentNo=tempNo+1; 733 currentNo=tempNo+1;
734 734
735 newSheet->name=tr("Sheet")+QString::number(currentNo); 735 newSheet->name=tr("Sheet")+QString::number(currentNo);
736 newSheet->data.setAutoDelete(TRUE); 736 newSheet->data.setAutoDelete(TRUE);
737 737
738 comboSheets->insertItem(newSheet->name); 738 comboSheets->insertItem(newSheet->name);
739 listSheets.append(newSheet); 739 listSheets.append(newSheet);
740 return newSheet; 740 return newSheet;
741} 741}
742 742
743typeSheet *MainWindow::findSheet(const QString &name) 743typeSheet *MainWindow::findSheet(const QString &name)
744{ 744{
745 for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) 745 for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next())
746 if (tempSheet->name==name) 746 if (tempSheet->name==name)
747 return tempSheet; 747 return tempSheet;
748 return NULL; 748 return NULL;
749} 749}
750 750
751void MainWindow::slotSheetChanged(const QString &name) 751void MainWindow::slotSheetChanged(const QString &name)
752{ 752{
753 sheet->copySheetData(&findSheet(sheet->getName())->data); 753 sheet->copySheetData(&findSheet(sheet->getName())->data);
754 sheet->setName(name); 754 sheet->setName(name);
755 sheet->setSheetData(&findSheet(name)->data); 755 sheet->setSheetData(&findSheet(name)->data);
756 sheet->ReCalc(); 756 sheet->ReCalc();
757} 757}
758 758
759void MainWindow::addFlyAction(const QString &text, const QString &menuText, const QString &tip, QWidget *w) 759void MainWindow::addFlyAction(const QString &text, const QString &menuText, const QString &tip, QWidget *w)
760{ 760{
761 QAction *action=new QAction(text, menuText, 0, this); 761 QAction *action=new QAction(text, menuText, 0, this);
762 action->setToolTip(tip); 762 action->setToolTip(tip);
763 connect(action, SIGNAL(activated()), this, SLOT(slotFuncOutput())); 763 connect(action, SIGNAL(activated()), this, SLOT(slotFuncOutput()));
764 action->addTo(w); 764 action->addTo(w);
765} 765}
766 766
767void MainWindow::slotFormatCells() 767void MainWindow::slotFormatCells()
768{ 768{
769 CellFormat dialogCellFormat(this); 769 CellFormat dialogCellFormat(this);
770 QPEApplication::showDialog( &dialogCellFormat ); 770 QPEApplication::showDialog( &dialogCellFormat );
771 dialogCellFormat.exec(sheet); 771 dialogCellFormat.exec(sheet);
772} 772}
773 773
774void MainWindow::slotEditPaste() 774void MainWindow::slotEditPaste()
775{ 775{
776 sheet->editPaste(); 776 sheet->editPaste();
777} 777}
778 778
779void MainWindow::slotEditPasteContents() 779void MainWindow::slotEditPasteContents()
780{ 780{
781 sheet->editPaste(TRUE); 781 sheet->editPaste(TRUE);
782} 782}
783 783
784void MainWindow::slotRowHeight() 784void MainWindow::slotRowHeight()
785{ 785{
786 int row1, row2, col1, col2; 786 int row1, row2, col1, col2;
787 sheet->getSelection(&row1, &col1, &row2, &col2); 787 sheet->getSelection(&row1, &col1, &row2, &col2);
788 788
789 NumberDialog dialogNumber(this); 789 NumberDialog dialogNumber(this);
790 if (dialogNumber.exec(tr("Row Height"), tr("&Height of each row:"), sheet->rowHeight(row1))==QDialog::Accepted) 790 if (dialogNumber.exec(tr("Row Height"), tr("&Height of each row:"), sheet->rowHeight(row1))==QDialog::Accepted)
791 { 791 {
792 int newHeight=dialogNumber.getValue(), row; 792 int newHeight=dialogNumber.getValue(), row;
793 for (row=row1; row<=row2; ++row) 793 for (row=row1; row<=row2; ++row)
794 sheet->setRowHeight(row, newHeight); 794 sheet->setRowHeight(row, newHeight);
795 } 795 }
796} 796}
797 797
798void MainWindow::slotRowAdjust() 798void MainWindow::slotRowAdjust()
799{ 799{
800 int row1, row2, col1, col2; 800 int row1, row2, col1, col2;
801 sheet->getSelection(&row1, &col1, &row2, &col2); 801 sheet->getSelection(&row1, &col1, &row2, &col2);
802 802
803 for (int row=row1; row<=row2; ++row) 803 for (int row=row1; row<=row2; ++row)
804 sheet->adjustRow(row); 804 sheet->adjustRow(row);
805} 805}
806 806
807void MainWindow::slotRowShow() 807void MainWindow::slotRowShow()
808{ 808{
809 int row1, row2, col1, col2; 809 int row1, row2, col1, col2;
810 sheet->getSelection(&row1, &col1, &row2, &col2); 810 sheet->getSelection(&row1, &col1, &row2, &col2);
811 811
812 for (int row=row1; row<=row2; ++row) 812 for (int row=row1; row<=row2; ++row)
813 sheet->showRow(row); 813 sheet->showRow(row);
814} 814}
815 815
816void MainWindow::slotRowHide() 816void MainWindow::slotRowHide()
817{ 817{
818 int row1, row2, col1, col2; 818 int row1, row2, col1, col2;
819 sheet->getSelection(&row1, &col1, &row2, &col2); 819 sheet->getSelection(&row1, &col1, &row2, &col2);
820 820
821 for (int row=row1; row<=row2; ++row) 821 for (int row=row1; row<=row2; ++row)
822 sheet->hideRow(row); 822 sheet->hideRow(row);
823} 823}
824 824
825void MainWindow::slotColumnWidth() 825void MainWindow::slotColumnWidth()
826{ 826{
827 int row1, row2, col1, col2; 827 int row1, row2, col1, col2;
828 sheet->getSelection(&row1, &col1, &row2, &col2); 828 sheet->getSelection(&row1, &col1, &row2, &col2);
829 829
830 NumberDialog dialogNumber(this); 830 NumberDialog dialogNumber(this);
831 if (dialogNumber.exec(tr("Column Width"), tr("&Width of each column:"), sheet->columnWidth(col1))==QDialog::Accepted) 831 if (dialogNumber.exec(tr("Column Width"), tr("&Width of each column:"), sheet->columnWidth(col1))==QDialog::Accepted)
832 { 832 {
833 int newWidth=dialogNumber.getValue(), col; 833 int newWidth=dialogNumber.getValue(), col;
834 for (col=col1; col<=col2; ++col) 834 for (col=col1; col<=col2; ++col)
835 sheet->setColumnWidth(col, newWidth); 835 sheet->setColumnWidth(col, newWidth);
836 } 836 }
837} 837}
838 838
839void MainWindow::slotColumnAdjust() 839void MainWindow::slotColumnAdjust()
840{ 840{
841 int row1, row2, col1, col2; 841 int row1, row2, col1, col2;
842 sheet->getSelection(&row1, &col1, &row2, &col2); 842 sheet->getSelection(&row1, &col1, &row2, &col2);
843 843
844 for (int col=col1; col<=col2; ++col) 844 for (int col=col1; col<=col2; ++col)
845 sheet->adjustColumn(col); 845 sheet->adjustColumn(col);
846} 846}
847 847
848void MainWindow::slotColumnShow() 848void MainWindow::slotColumnShow()
849{ 849{
850 int row1, row2, col1, col2; 850 int row1, row2, col1, col2;
851 sheet->getSelection(&row1, &col1, &row2, &col2); 851 sheet->getSelection(&row1, &col1, &row2, &col2);
852 852
853 for (int col=col1; col<=col2; ++col) 853 for (int col=col1; col<=col2; ++col)
854 sheet->showColumn(col); 854 sheet->showColumn(col);
855} 855}
856 856
857void MainWindow::slotColumnHide() 857void MainWindow::slotColumnHide()
858{ 858{
859 int row1, row2, col1, col2; 859 int row1, row2, col1, col2;
860 sheet->getSelection(&row1, &col1, &row2, &col2); 860 sheet->getSelection(&row1, &col1, &row2, &col2);
861 861
862 for (int col=col1; col<=col2; ++col) 862 for (int col=col1; col<=col2; ++col)
863 sheet->hideColumn(col); 863 sheet->hideColumn(col);
864} 864}
865 865
866void MainWindow::slotFileSaveAs() 866void MainWindow::slotFileSaveAs()
867{ 867{
868 TextDialog dialogText(this); 868 TextDialog dialogText(this);
869 if (dialogText.exec(tr("Save File As"), tr("&File Name:"), currentDoc->name())!=QDialog::Accepted || dialogText.getValue().isEmpty()) return; 869 if (dialogText.exec(tr("Save File As"), tr("&File Name:"), currentDoc->name())!=QDialog::Accepted || dialogText.getValue().isEmpty()) return;
870 870
871 currentDoc->setName(dialogText.getValue()); 871 currentDoc->setName(dialogText.getValue());
872 currentDoc->setFile(QString::null); 872 currentDoc->setFile(QString::null);
873 currentDoc->setLinkFile(QString::null); 873 currentDoc->setLinkFile(QString::null);
874 documentSave(currentDoc); 874 documentSave(currentDoc);
875} 875}
876 876
877void MainWindow::slotImportExcel(const DocLnk &lnkDoc) 877void MainWindow::slotImportExcel(const DocLnk &lnkDoc)
878{ 878{
879 ExcelBook file1; 879 ExcelBook file1;
880 file1.ParseBook((char *)lnkDoc.file().ascii()); 880 if ( !file1.ParseBook((char *)lnkDoc.file().ascii()) ){
881 QMessageBox::critical(this, tr("Error"), tr("<td>Unable to open or parse file!</td>"));
882 return;
883 }
881 int NumOfSheets=file1.Sheets.count(); 884 int NumOfSheets=file1.Sheets.count();
882 printf("OpieSheet::NumberOfSheets:%d\r\n",NumOfSheets); 885 printf("OpieSheet::NumberOfSheets:%d\r\n",NumOfSheets);
883 if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; 886 if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return;
884 if (currentDoc) delete currentDoc; 887 if (currentDoc) delete currentDoc;
885 currentDoc = new DocLnk(); 888 currentDoc = new DocLnk();
886 listSheets.clear(); 889 listSheets.clear();
887 comboSheets->clear(); 890 comboSheets->clear();
888 int w1,r,c; 891 int w1,r,c;
889 ExcelSheet* sh1; 892 ExcelSheet* sh1;
890 typeSheet* newSheet; 893 typeSheet* newSheet;
891 QString* str; 894 QString* str;
892 typeCellData* newCell; 895 typeCellData* newCell;
893 for(w1=1;w1<=NumOfSheets;w1++) 896 for(w1=1;w1<=NumOfSheets;w1++)
894 { 897 {
895 sh1=file1.Sheets[w1-1]; 898 sh1=file1.Sheets[w1-1];
896 printf("OpieSheet:newSheet:%x,r=%d,c=%d\r\n",sh1,sh1->rows,sh1->cols); 899 // printf("OpieSheet:newSheet:%x,r=%d,c=%d\r\n",sh1, sh1->rows,sh1->cols);
897 newSheet=new typeSheet; 900 newSheet=new typeSheet;
898 newSheet->data.setAutoDelete(TRUE); 901 newSheet->data.setAutoDelete(TRUE);
899 newSheet->name=sh1->name; 902 newSheet->name=sh1->name;
900 printf("OpieSheet:Sheetname:%s\r\n",sh1->name.ascii()); 903 printf("OpieSheet:Sheetname:%s\r\n",sh1->name.ascii());
901 comboSheets->insertItem(newSheet->name); 904 comboSheets->insertItem(newSheet->name);
902 for(r=1; r <= sh1->rows; r++) 905 for(r=1; r <= sh1->rows; r++)
903 { 906 {
904 for(c=1;c <= sh1->cols; c++) 907 for(c=1;c <= sh1->cols; c++)
905 { 908 {
906 str=file1.CellDataString(sh1,r-1,c-1); 909 str=file1.CellDataString(sh1,r-1,c-1);
907 if(str!=NULL && r<DEFAULT_NUM_ROWS && c<DEFAULT_NUM_COLS) 910 if(str!=NULL && r<DEFAULT_NUM_ROWS && c<DEFAULT_NUM_COLS)
908 { 911 {
909 newCell=new typeCellData; 912 newCell=new typeCellData;
910 newCell->row=r-1; 913 newCell->row=r-1;
911 newCell->col=c-1; 914 newCell->col=c-1;
912 if(str!=NULL) newCell->data=QString(*str); else newCell->data=QString(""); 915 if(str!=NULL) newCell->data=QString(*str); else newCell->data=QString("");
913 newCell->background=QBrush(Qt::white, Qt::SolidPattern); 916 newCell->background=QBrush(Qt::white, Qt::SolidPattern);
914 newCell->alignment=(Qt::AlignmentFlags)(Qt::AlignLeft | Qt::AlignTop); 917 newCell->alignment=(Qt::AlignmentFlags)(Qt::AlignLeft | Qt::AlignTop);
915 newCell->fontColor=Qt::black; 918 newCell->fontColor=Qt::black;
916 newCell->font=font(); 919 newCell->font=font();
917 newCell->borders.right=QPen(Qt::gray, 1, Qt::SolidLine); 920 newCell->borders.right=QPen(Qt::gray, 1, Qt::SolidLine);
918 newCell->borders.bottom=QPen(Qt::gray, 1, Qt::SolidLine); 921 newCell->borders.bottom=QPen(Qt::gray, 1, Qt::SolidLine);
919 newSheet->data.append(newCell); 922 newSheet->data.append(newCell);
920 //there is no format parsing at the moment or style parsing 923 //there is no format parsing at the moment or style parsing
921 //printf("OpieSheetNumber:row=%d,col=%d,val=%s\r\n",r,c,str->latin1()); 924 //printf("OpieSheetNumber:row=%d,col=%d,val=%s\r\n",r,c,str->latin1());
922 }; 925 };
923 }; 926 };
924 }; 927 };
925 listSheets.append(newSheet); 928 listSheets.append(newSheet);
926 if (w1==1)//if i==0 link sheet1 with sheetview 929 if (w1==1)//if i==0 link sheet1 with sheetview
927 { 930 {
928 sheet->setName(newSheet->name); 931 sheet->setName(newSheet->name);
929 sheet->setSheetData(&newSheet->data); 932 sheet->setSheetData(&newSheet->data);
930 sheet->ReCalc(); 933 sheet->ReCalc();
931 }; 934 };
932 935
933 }; 936 };
934 file1.CloseFile(); 937 file1.CloseFile();
935 printf("Excel FILE read OK\r\n"); 938 printf("Excel FILE read OK\r\n");
936 documentModified=TRUE; 939 documentModified=TRUE;
937 940
938 941
939} 942}
940 943
941void MainWindow::slotSheetRename() 944void MainWindow::slotSheetRename()
942{ 945{
943 TextDialog dialogText(this); 946 TextDialog dialogText(this);
944 if (dialogText.exec(tr("Rename Sheet"), tr("&Sheet Name:"), sheet->getName())!=QDialog::Accepted || dialogText.getValue().isEmpty()) return; 947 if (dialogText.exec(tr("Rename Sheet"), tr("&Sheet Name:"), sheet->getName())!=QDialog::Accepted || dialogText.getValue().isEmpty()) return;
945 QString newName=dialogText.getValue(); 948 QString newName=dialogText.getValue();
946 949
947 typeSheet *tempSheet=findSheet(newName); 950 typeSheet *tempSheet=findSheet(newName);
948 if (tempSheet) 951 if (tempSheet)
949 { 952 {
950 QMessageBox::critical(this, tr("Error"), tr("There is already a sheet named '"+newName+'\'')); 953 QMessageBox::critical(this, tr("Error"), tr("There is already a sheet named '"+newName+'\''));
951 return; 954 return;
952 } 955 }
953 956
954 tempSheet=findSheet(sheet->getName()); 957 tempSheet=findSheet(sheet->getName());
955 for (int i=0; i<comboSheets->count(); ++i) 958 for (int i=0; i<comboSheets->count(); ++i)
956 if (comboSheets->text(i)==tempSheet->name) 959 if (comboSheets->text(i)==tempSheet->name)
957 { 960 {
958 comboSheets->changeItem(newName, i); 961 comboSheets->changeItem(newName, i);
959 break; 962 break;
960 } 963 }
961 tempSheet->name=newName; 964 tempSheet->name=newName;
962 sheet->setName(newName); 965 sheet->setName(newName);
963} 966}
964 967
965void MainWindow::slotSheetRemove() 968void MainWindow::slotSheetRemove()
966{ 969{
967 if (comboSheets->count()<2) 970 if (comboSheets->count()<2)
968 { 971 {
969 QMessageBox::warning(this, tr("Error"), tr("There is only one sheet!")); 972 QMessageBox::warning(this, tr("Error"), tr("There is only one sheet!"));
970 return; 973 return;
971 } 974 }
972 if (QMessageBox::information(this, tr("Remove Sheet"), tr("Are you sure?"), QMessageBox::Yes, QMessageBox::No)==QMessageBox::Yes) 975 if (QMessageBox::information(this, tr("Remove Sheet"), tr("Are you sure?"), QMessageBox::Yes, QMessageBox::No)==QMessageBox::Yes)
973 { 976 {
974 typeSheet *tempSheet=findSheet(sheet->getName()); 977 typeSheet *tempSheet=findSheet(sheet->getName());
975 for (int i=0; i<comboSheets->count(); ++i) 978 for (int i=0; i<comboSheets->count(); ++i)
976 if (comboSheets->text(i)==tempSheet->name) 979 if (comboSheets->text(i)==tempSheet->name)
977 { 980 {
978 comboSheets->removeItem(i); 981 comboSheets->removeItem(i);
979 break; 982 break;
980 } 983 }
981 comboSheets->setCurrentItem(0); 984 comboSheets->setCurrentItem(0);
982 slotSheetChanged(comboSheets->currentText()); 985 slotSheetChanged(comboSheets->currentText());
983 listSheets.remove(tempSheet); 986 listSheets.remove(tempSheet);
984 } 987 }
985} 988}
986 989
987void MainWindow::slotDataSort() 990void MainWindow::slotDataSort()
988{ 991{
989 SortDialog dialogSort(this); 992 SortDialog dialogSort(this);
990 QPEApplication::showDialog( &dialogSort ); 993 QPEApplication::showDialog( &dialogSort );
991 dialogSort.exec(sheet); 994 dialogSort.exec(sheet);
992} 995}
993 996
994void MainWindow::slotDocModified() 997void MainWindow::slotDocModified()
995{ 998{
996 documentModified=TRUE; 999 documentModified=TRUE;
997} 1000}
998 1001
999void MainWindow::slotInsertCells() 1002void MainWindow::slotInsertCells()
1000{ 1003{
1001 QDialog dialogInsert(this, 0, TRUE); 1004 QDialog dialogInsert(this, 0, TRUE);
1002 dialogInsert.resize(180, 130); 1005 dialogInsert.resize(180, 130);
1003 dialogInsert.setCaption(tr("Insert Cells")); 1006 dialogInsert.setCaption(tr("Insert Cells"));
1004 1007
1005 QVButtonGroup *group=new QVButtonGroup(tr("&Type"), &dialogInsert); 1008 QVButtonGroup *group=new QVButtonGroup(tr("&Type"), &dialogInsert);
1006 group->setGeometry(10, 10, 160, 110); 1009 group->setGeometry(10, 10, 160, 110);
1007 QRadioButton *radio=new QRadioButton(tr("Shift cells &down"), group); 1010 QRadioButton *radio=new QRadioButton(tr("Shift cells &down"), group);
1008 radio=new QRadioButton(tr("Shift cells &right"), group); 1011 radio=new QRadioButton(tr("Shift cells &right"), group);
1009 radio=new QRadioButton(tr("Entire ro&w"), group); 1012 radio=new QRadioButton(tr("Entire ro&w"), group);
1010 radio=new QRadioButton(tr("Entire &column"), group); 1013 radio=new QRadioButton(tr("Entire &column"), group);
1011 group->setButton(0); 1014 group->setButton(0);
1012 1015
1013 if (dialogInsert.exec()==QDialog::Accepted) 1016 if (dialogInsert.exec()==QDialog::Accepted)
1014 switch (group->id(group->selected())) 1017 switch (group->id(group->selected()))
1015 { 1018 {
1016 case 0: sheet->insertRows(1, FALSE); break; 1019 case 0: sheet->insertRows(1, FALSE); break;
1017 case 1: sheet->insertColumns(1, FALSE); break; 1020 case 1: sheet->insertColumns(1, FALSE); break;
1018 case 2: sheet->insertRows(1, TRUE); break; 1021 case 2: sheet->insertRows(1, TRUE); break;
1019 case 3: sheet->insertColumns(1, TRUE); break; 1022 case 3: sheet->insertColumns(1, TRUE); break;
1020 } 1023 }
1021} 1024}
1022 1025
1023void MainWindow::slotDataFindReplace() 1026void MainWindow::slotDataFindReplace()
1024{ 1027{
1025 FindDialog dialogFind(this); 1028 FindDialog dialogFind(this);
1026 QPEApplication::showDialog( &dialogFind ); 1029 QPEApplication::showDialog( &dialogFind );
1027 dialogFind.exec(sheet); 1030 dialogFind.exec(sheet);
1028} 1031}