Diffstat (limited to 'noncore/apps/opie-sheet/Excel.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-sheet/Excel.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/noncore/apps/opie-sheet/Excel.cpp b/noncore/apps/opie-sheet/Excel.cpp index 51fe707..27080e9 100644 --- a/noncore/apps/opie-sheet/Excel.cpp +++ b/noncore/apps/opie-sheet/Excel.cpp | |||
@@ -332,97 +332,99 @@ int ExcelBook::SeekBOF(void) | |||
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 | ||
353 | ExcelBREC* ExcelBook::GetBREC(void) | 353 | ExcelBREC* 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 | ||
366 | ExcelBREC* ExcelBook::PeekBREC(void) | 366 | ExcelBREC* 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 | ||
376 | char* ExcelBook::GetDataOfBREC(ExcelBREC* record) | 376 | char* 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 | char* readData = Read(record->position,record->length); |
381 | ConvertCharToArray(record,readData,record->length); | ||
382 | delete [] readData; | ||
381 | }; | 383 | }; |
382 | return record->data;//new? | 384 | return record->data;//new? |
383 | }; | 385 | }; |
384 | 386 | ||
385 | void ExcelBook::ConvertCharToArray(ExcelBREC* record, char* chars, int length) | 387 | void ExcelBook::ConvertCharToArray(ExcelBREC* record, char* chars, int length) |
386 | { | 388 | { |
387 | record->data=new char[length]; | 389 | record->data=new char[length]; |
388 | for(int w1=0;w1<=length-1;w1++) | 390 | for(int w1=0;w1<=length-1;w1++) |
389 | record->data[w1]=chars[w1]; | 391 | record->data[w1]=chars[w1]; |
390 | }; | 392 | }; |
391 | 393 | ||
392 | 394 | ||
393 | bool ExcelSheet::InitCells() | 395 | bool ExcelSheet::InitCells() |
394 | { | 396 | { |
395 | int r; | 397 | int r; |
396 | Cells.resize(rows * cols + cols+1); | 398 | Cells.resize(rows * cols + cols+1); |
397 | if(Cells.count()==0) return false; | 399 | if(Cells.count()==0) return false; |
398 | for(r=0;r < Cells.count();r++) | 400 | for(r=0;r < Cells.count();r++) |
399 | { | 401 | { |
400 | Cells[r]=NULL; | 402 | Cells[r]=NULL; |
401 | }; | 403 | }; |
402 | return true; | 404 | return true; |
403 | }; | 405 | }; |
404 | 406 | ||
405 | void ExcelSheet::Set(int row, int col, ExcelCell* cell) | 407 | void ExcelSheet::Set(int row, int col, ExcelCell* cell) |
406 | { | 408 | { |
407 | if(cell!=NULL&&(row*cols+col)<Cells.count()) | 409 | if(cell!=NULL&&(row*cols+col)<Cells.count()) |
408 | { | 410 | { |
409 | Cells[row*cols+col]=cell; | 411 | Cells[row*cols+col]=cell; |
410 | }; | 412 | }; |
411 | }; | 413 | }; |
412 | 414 | ||
413 | ExcelCell* ExcelSheet::Get(int row, int col) | 415 | ExcelCell* ExcelSheet::Get(int row, int col) |
414 | { | 416 | { |
415 | ExcelCell* cell; | 417 | ExcelCell* cell; |
416 | cell=Cells[row*cols+col]; | 418 | cell=Cells[row*cols+col]; |
417 | if(cell==NULL) return NULL; | 419 | if(cell==NULL) return NULL; |
418 | return cell; | 420 | return cell; |
419 | }; | 421 | }; |
420 | 422 | ||
421 | int ExcelBook::SheetHandleRecord(ExcelSheet* sheet, ExcelBREC* record) | 423 | int ExcelBook::SheetHandleRecord(ExcelSheet* sheet, ExcelBREC* record) |
422 | { | 424 | { |
423 | char* data=NULL; | 425 | char* data=NULL; |
424 | switch (record->code) | 426 | switch (record->code) |
425 | { | 427 | { |
426 | case XL_DIMENSION: | 428 | case XL_DIMENSION: |
427 | data = GetDataOfBREC(record); | 429 | data = GetDataOfBREC(record); |
428 | if (record->length == 10) | 430 | if (record->length == 10) |