… | |
… | |
171 | return 0; |
171 | return 0; |
172 | |
172 | |
173 | ERROR2: |
173 | ERROR2: |
174 | free (*result); |
174 | free (*result); |
175 | ERROR1: |
175 | ERROR1: |
176 | psiconv_warn(lev+1,off,"Reading of Sjeet Status Section failed"); |
176 | psiconv_warn(lev+1,off,"Reading of Sheet Status Section failed"); |
177 | if (length) |
177 | if (length) |
178 | *length = 0; |
178 | *length = 0; |
179 | if (!res) |
179 | if (!res) |
180 | return -PSICONV_E_NOMEM; |
180 | return -PSICONV_E_NOMEM; |
181 | else |
181 | else |
… | |
… | |
185 | int psiconv_parse_sheet_workbook_section(const psiconv_buffer buf, int lev, |
185 | int psiconv_parse_sheet_workbook_section(const psiconv_buffer buf, int lev, |
186 | psiconv_u32 off, int *length, |
186 | psiconv_u32 off, int *length, |
187 | psiconv_sheet_workbook_section *result) |
187 | psiconv_sheet_workbook_section *result) |
188 | { |
188 | { |
189 | int res=0; |
189 | int res=0; |
190 | psiconv_u32 temp,formulas_off; |
190 | psiconv_u32 temp,formulas_off,worksheets_off; |
191 | int len=0; |
191 | int len=0; |
192 | |
192 | |
193 | psiconv_progress(lev+1,off,"Going to read the sheet workbook section"); |
193 | psiconv_progress(lev+1,off,"Going to read the sheet workbook section"); |
194 | if (!(*result = malloc(sizeof(**result)))) |
194 | if (!(*result = malloc(sizeof(**result)))) |
195 | goto ERROR1; |
195 | goto ERROR1; |
… | |
… | |
221 | goto ERROR2; |
221 | goto ERROR2; |
222 | psiconv_debug(lev+2,off+len,"Offset: %04x",formulas_off); |
222 | psiconv_debug(lev+2,off+len,"Offset: %04x",formulas_off); |
223 | len += 4; |
223 | len += 4; |
224 | |
224 | |
225 | psiconv_progress(lev+2,off+len, |
225 | psiconv_progress(lev+2,off+len, |
226 | "Going to read the offset of the 3rd ??? Section"); |
226 | "Going to read the offset of the Worksheets Section"); |
227 | temp = psiconv_read_u32(buf,lev+2,off+len,&res); |
227 | worksheets_off = psiconv_read_u32(buf,lev+2,off+len,&res); |
228 | if (res) |
228 | if (res) |
229 | goto ERROR2; |
229 | goto ERROR2; |
230 | psiconv_debug(lev+2,off+len,"Offset: %04x",temp); |
230 | psiconv_debug(lev+2,off+len,"Offset: %04x",temp); |
231 | len += 4; |
231 | len += 4; |
232 | |
232 | |
… | |
… | |
241 | psiconv_progress(lev+2,off+len,"Going to read the formulas list"); |
241 | psiconv_progress(lev+2,off+len,"Going to read the formulas list"); |
242 | if ((res = psiconv_parse_sheet_formula_table(buf,lev+2,formulas_off,NULL, |
242 | if ((res = psiconv_parse_sheet_formula_table(buf,lev+2,formulas_off,NULL, |
243 | &(*result)->formulas))) |
243 | &(*result)->formulas))) |
244 | goto ERROR2; |
244 | goto ERROR2; |
245 | |
245 | |
|
|
246 | psiconv_progress(lev+2,off+len,"Going to read the worksheets"); |
|
|
247 | if ((res = psiconv_parse_sheet_worksheet_section(buf,lev+2,worksheets_off, |
|
|
248 | NULL,&(*result)->worksheet))) |
|
|
249 | goto ERROR2; |
246 | |
250 | |
|
|
251 | |
247 | if (length) |
252 | if (length) |
248 | *length = len; |
253 | *length = len; |
249 | |
254 | |
250 | psiconv_progress(lev,off+len-1, |
255 | psiconv_progress(lev,off+len-1, |
251 | "End of sheet workbook section (total length: %08x)", len); |
256 | "End of sheet workbook section (total length: %08x)", len); |
… | |
… | |
326 | if (!res) |
331 | if (!res) |
327 | return -PSICONV_E_NOMEM; |
332 | return -PSICONV_E_NOMEM; |
328 | else |
333 | else |
329 | return res; |
334 | return res; |
330 | } |
335 | } |
|
|
336 | |
|
|
337 | int psiconv_parse_sheet_cell(const psiconv_buffer buf, int lev, |
|
|
338 | psiconv_u32 off, int *length, |
|
|
339 | psiconv_sheet_cell *result) |
|
|
340 | { |
|
|
341 | int res=0; |
|
|
342 | int len=0; |
|
|
343 | psiconv_u32 temp; |
|
|
344 | psiconv_bool_t has_layout; |
|
|
345 | int leng; |
|
|
346 | |
|
|
347 | psiconv_progress(lev+1,off,"Going to read a sheet cell structure"); |
|
|
348 | if (!(*result = malloc(sizeof(**result)))) |
|
|
349 | goto ERROR1; |
|
|
350 | |
|
|
351 | psiconv_progress(lev+2,off+len,"Going to read the cell position"); |
|
|
352 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
|
|
353 | if (res) |
|
|
354 | goto ERROR2; |
|
|
355 | len ++; |
|
|
356 | temp += psiconv_read_u8(buf,lev+2,off+len,&res) << 8; |
|
|
357 | if (res) |
|
|
358 | goto ERROR2; |
|
|
359 | len ++; |
|
|
360 | temp += psiconv_read_u8(buf,lev+2,off+len,&res) << 16; |
|
|
361 | if (res) |
|
|
362 | goto ERROR2; |
|
|
363 | len ++; |
|
|
364 | (*result)->column = (temp >> 2) & 0xFF; |
|
|
365 | (*result)->row = (temp >> 10) & 0x3FFF; |
|
|
366 | psiconv_debug(lev+2,off+len,"Cell position is col:%02x row:%04x", |
|
|
367 | (*result)->column,(*result)->row); |
|
|
368 | |
|
|
369 | psiconv_progress(lev+2,off+len,"Going to read the cell type"); |
|
|
370 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
|
|
371 | if (res) |
|
|
372 | goto ERROR2; |
|
|
373 | len ++; |
|
|
374 | (*result)->type = (temp >> 5) & 0x07; |
|
|
375 | (*result)->calculated = (temp & 0x08)?psiconv_bool_true:psiconv_bool_false; |
|
|
376 | has_layout = (temp & 0x10)?psiconv_bool_true:psiconv_bool_false; |
|
|
377 | |
|
|
378 | psiconv_progress(lev+2,off+len,"Going to read the cell value"); |
|
|
379 | if ((*result)->type == psiconv_cell_blank) { |
|
|
380 | psiconv_debug(lev+2,off+len,"Cell type is blank: no value given."); |
|
|
381 | } else if ((*result)->type == psiconv_cell_int) { |
|
|
382 | psiconv_progress(lev+2,off+len,"Going to read an integer"); |
|
|
383 | (*result)->data.dat_int = psiconv_read_u32(buf,lev+2,off+len,&res); |
|
|
384 | if (res) |
|
|
385 | goto ERROR2; |
|
|
386 | len += 4; |
|
|
387 | psiconv_debug(lev+2,off+len,"Cell contents: %ld",(*result)->data.dat_int); |
|
|
388 | |
|
|
389 | } else if ((*result)->type == psiconv_cell_bool) { |
|
|
390 | psiconv_progress(lev+2,off+len,"Going to read a boolean"); |
|
|
391 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
|
|
392 | if (res) |
|
|
393 | goto ERROR2; |
|
|
394 | len ++; |
|
|
395 | psiconv_debug(lev+2,off+len,"Cell contents: %01x",temp); |
|
|
396 | (*result)->data.dat_bool = temp?psiconv_bool_true:psiconv_bool_false; |
|
|
397 | |
|
|
398 | } else if ((*result)->type == psiconv_cell_error) { |
|
|
399 | psiconv_progress(lev+2,off+len,"Going to read the error code"); |
|
|
400 | (*result)->data.dat_error = psiconv_read_u16(buf,lev+2,off+len,&res); |
|
|
401 | if (res) |
|
|
402 | goto ERROR2; |
|
|
403 | len += 2; |
|
|
404 | psiconv_debug(lev+2,off+len,"Cell contents: %04x", |
|
|
405 | (*result)->data.dat_error); |
|
|
406 | |
|
|
407 | } else if ((*result)->type == psiconv_cell_float) { |
|
|
408 | psiconv_progress(lev+2,off+len,"Going to read a float"); |
|
|
409 | (*result)->data.dat_float = |
|
|
410 | psiconv_read_float(buf,lev+2,off+len,&leng,&res); |
|
|
411 | if (res) |
|
|
412 | goto ERROR2; |
|
|
413 | len += leng; |
|
|
414 | psiconv_debug(lev+2,off+len,"Cell contents: %f",(*result)->data.dat_float); |
|
|
415 | |
|
|
416 | } else if ((*result)->type == psiconv_cell_string) { |
|
|
417 | psiconv_progress(lev+2,off+len,"Going to read a string"); |
|
|
418 | (*result)->data.dat_string = |
|
|
419 | psiconv_read_short_string(buf,lev+2,off+len,&leng,&res); |
|
|
420 | if (res) |
|
|
421 | goto ERROR2; |
|
|
422 | len += leng; |
|
|
423 | psiconv_debug(lev+2,off+len,"Cell contents: `%s'", |
|
|
424 | (*result)->data.dat_string); |
|
|
425 | } else { |
|
|
426 | psiconv_warn(lev+2,off+len,"Unknown Sheet Cell type: %02x",(*result)->type); |
|
|
427 | } |
|
|
428 | |
|
|
429 | if (has_layout) { |
|
|
430 | psiconv_progress(lev+2,off+len,"Going to read the cell layout"); |
|
|
431 | |
|
|
432 | psiconv_progress(lev+2,off+len,"Going to read the cell layout flags"); |
|
|
433 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
|
|
434 | if (res) |
|
|
435 | goto ERROR2; |
|
|
436 | len ++; |
|
|
437 | |
|
|
438 | if (temp & 0x01) { |
|
|
439 | if (!((*result)->paragraph = psiconv_basic_paragraph_layout())) |
|
|
440 | goto ERROR2; |
|
|
441 | psiconv_progress(lev+3,off+len,"Going to read the paragraph codes"); |
|
|
442 | if ((res = psiconv_parse_paragraph_layout_list(buf,lev+3,off+len,&leng, |
|
|
443 | (*result)->paragraph))) |
|
|
444 | goto ERROR2; |
|
|
445 | len += leng; |
|
|
446 | } |
|
|
447 | |
|
|
448 | if (temp & 0x02) { |
|
|
449 | psiconv_progress(lev+3,off+len,"Going to read the character codes"); |
|
|
450 | if (!((*result)->character = psiconv_basic_character_layout())) |
|
|
451 | goto ERROR2; |
|
|
452 | if ((res = psiconv_parse_character_layout_list(buf,lev+3,off+len,&leng, |
|
|
453 | (*result)->character))) |
|
|
454 | goto ERROR2; |
|
|
455 | len += leng; |
|
|
456 | } |
|
|
457 | |
|
|
458 | if (temp & 0x04) { |
|
|
459 | /* TODO: default number format */ |
|
|
460 | psiconv_read_u8(buf,lev+2,off+len,&res); |
|
|
461 | if (res) |
|
|
462 | goto ERROR2; |
|
|
463 | len ++; |
|
|
464 | psiconv_read_u8(buf,lev+2,off+len,&res); |
|
|
465 | if (res) |
|
|
466 | goto ERROR2; |
|
|
467 | len ++; |
|
|
468 | psiconv_read_u8(buf,lev+2,off+len,&res); |
|
|
469 | if (res) |
|
|
470 | goto ERROR2; |
|
|
471 | len ++; |
|
|
472 | } |
|
|
473 | } |
|
|
474 | |
|
|
475 | if ((*result)->calculated) { |
|
|
476 | psiconv_progress(lev+2,off+len,"Going to read the cell formula reference"); |
|
|
477 | temp = psiconv_read_X(buf,lev+2,off+len,&leng,&res); |
|
|
478 | if (res) |
|
|
479 | goto ERROR2; |
|
|
480 | psiconv_debug(lev+2,off+len,"Cell formula reference: %d",temp); |
|
|
481 | len += leng; |
|
|
482 | (*result)->ref_formula = temp; |
|
|
483 | } |
|
|
484 | |
|
|
485 | if (length) |
|
|
486 | *length = len; |
|
|
487 | |
|
|
488 | psiconv_progress(lev,off+len-1, |
|
|
489 | "End of sheet cell structure (total length: %08x)", len); |
|
|
490 | return 0; |
|
|
491 | |
|
|
492 | ERROR2: |
|
|
493 | psiconv_free_sheet_cell(*result); |
|
|
494 | ERROR1: |
|
|
495 | psiconv_warn(lev+1,off,"Reading of Sheet Cell Structure failed"); |
|
|
496 | if (length) |
|
|
497 | *length = 0; |
|
|
498 | if (!res) |
|
|
499 | return -PSICONV_E_NOMEM; |
|
|
500 | else |
|
|
501 | return res; |
|
|
502 | } |
|
|
503 | |
|
|
504 | int psiconv_parse_sheet_cell_list(const psiconv_buffer buf, int lev, |
|
|
505 | psiconv_u32 off, int *length, |
|
|
506 | psiconv_sheet_cell_list *result) |
|
|
507 | { |
|
|
508 | int res=0; |
|
|
509 | int len=0; |
|
|
510 | psiconv_u32 temp; |
|
|
511 | psiconv_sheet_cell cell; |
|
|
512 | psiconv_u32 listlen,i; |
|
|
513 | int leng; |
|
|
514 | |
|
|
515 | psiconv_progress(lev+1,off,"Going to read the sheet cells list"); |
|
|
516 | if (!(*result = psiconv_list_new(sizeof(struct psiconv_sheet_cell_s)))) |
|
|
517 | goto ERROR1; |
|
|
518 | |
|
|
519 | psiconv_progress(lev+2,off+len, |
|
|
520 | "Going to read the initial byte (%02x expected)",0x02); |
|
|
521 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
|
|
522 | if (res) |
|
|
523 | goto ERROR2; |
|
|
524 | if (temp != 0x02) { |
|
|
525 | psiconv_warn(lev+2,off+len, |
|
|
526 | "Sheet cell list initial byte unknown value (ignored)"); |
|
|
527 | psiconv_debug(lev+2,off+len,"Initial byte: %02x",temp); |
|
|
528 | } |
|
|
529 | len ++; |
|
|
530 | |
|
|
531 | psiconv_progress(lev+2,off+len, |
|
|
532 | "Going to read the initial byte (%02x expected)",0x00); |
|
|
533 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
|
|
534 | if (res) |
|
|
535 | goto ERROR2; |
|
|
536 | if (temp != 0x00) { |
|
|
537 | psiconv_warn(lev+2,off+len, |
|
|
538 | "Sheet cell list initial byte unknown value (ignored)"); |
|
|
539 | psiconv_debug(lev+2,off+len,"Initial byte: %02x",temp); |
|
|
540 | } |
|
|
541 | len ++; |
|
|
542 | |
|
|
543 | psiconv_progress(lev+2,off+len, |
|
|
544 | "Going to read the number of defined cells"); |
|
|
545 | listlen = psiconv_read_X(buf,lev+2,off+len,&leng,&res); |
|
|
546 | if (res) |
|
|
547 | goto ERROR2; |
|
|
548 | psiconv_debug(lev+2,off+len,"Number of defined cells: %d",listlen); |
|
|
549 | len += leng; |
|
|
550 | |
|
|
551 | psiconv_progress(lev+2,off+len,"Going to read all cells"); |
|
|
552 | for (i = 0; i < listlen; i++) { |
|
|
553 | psiconv_progress(lev+3,off+len,"Going to read cell %d",i); |
|
|
554 | if ((res = psiconv_parse_sheet_cell(buf,lev+3,off+len,&leng,&cell))) |
|
|
555 | goto ERROR2; |
|
|
556 | if ((res = psiconv_list_add(*result,cell))) |
|
|
557 | goto ERROR3; |
|
|
558 | len += leng; |
|
|
559 | } |
|
|
560 | |
|
|
561 | if (length) |
|
|
562 | *length = len; |
|
|
563 | |
|
|
564 | psiconv_progress(lev,off+len-1, |
|
|
565 | "End of sheet cell list (total length: %08x)", len); |
|
|
566 | return 0; |
|
|
567 | |
|
|
568 | ERROR3: |
|
|
569 | psiconv_free_sheet_cell(cell); |
|
|
570 | ERROR2: |
|
|
571 | psiconv_free_sheet_cell_list(*result); |
|
|
572 | ERROR1: |
|
|
573 | psiconv_warn(lev+1,off,"Reading of Sheet Cells List failed"); |
|
|
574 | if (length) |
|
|
575 | *length = 0; |
|
|
576 | if (!res) |
|
|
577 | return -PSICONV_E_NOMEM; |
|
|
578 | else |
|
|
579 | return res; |
|
|
580 | } |
|
|
581 | |
|
|
582 | |
|
|
583 | int psiconv_parse_sheet_worksheet_section(const psiconv_buffer buf, int lev, |
|
|
584 | psiconv_u32 off, int *length, |
|
|
585 | psiconv_sheet_worksheet_section *result) |
|
|
586 | { |
|
|
587 | int res=0; |
|
|
588 | psiconv_u32 temp,cells_off,grid_off; |
|
|
589 | int len=0; |
|
|
590 | int leng; |
|
|
591 | |
|
|
592 | /* TODO: this is the section that might be an XListE instead... */ |
|
|
593 | psiconv_progress(lev+2,off+len, |
|
|
594 | "Going to read the initial bytes (%02x expected)",0x02); |
|
|
595 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
|
|
596 | if (res) |
|
|
597 | goto ERROR1; |
|
|
598 | if (temp != 0x04) { |
|
|
599 | psiconv_warn(lev+2,off+len, |
|
|
600 | "Sheet worksheet section initial byte unknown value (ignored)"); |
|
|
601 | psiconv_debug(lev+2,off+len,"Initial byte: %02x",temp); |
|
|
602 | } |
|
|
603 | len ++; |
|
|
604 | |
|
|
605 | psiconv_progress(lev+2,off+len, |
|
|
606 | "Going to read the initial bytes (%02x expected)",0x02); |
|
|
607 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
|
|
608 | if (res) |
|
|
609 | goto ERROR1; |
|
|
610 | if (temp != 0x04) { |
|
|
611 | psiconv_warn(lev+2,off+len, |
|
|
612 | "Sheet worksheet section initial byte unknown value (ignored)"); |
|
|
613 | psiconv_debug(lev+2,off+len,"Initial byte: %02x",temp); |
|
|
614 | } |
|
|
615 | len ++; |
|
|
616 | |
|
|
617 | psiconv_progress(lev+2,off+len, |
|
|
618 | "Going to read the initial bytes (%02x expected)",0x00); |
|
|
619 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
|
|
620 | if (res) |
|
|
621 | goto ERROR1; |
|
|
622 | if (temp != 0x04) { |
|
|
623 | psiconv_warn(lev+2,off+len, |
|
|
624 | "Sheet worksheet section initial byte unknown value (ignored)"); |
|
|
625 | psiconv_debug(lev+2,off+len,"Initial byte: %02x",temp); |
|
|
626 | } |
|
|
627 | len ++; |
|
|
628 | |
|
|
629 | psiconv_progress(lev+2,off+len, |
|
|
630 | "Going to read the offset of the Worksheet Section"); |
|
|
631 | temp = psiconv_read_u32(buf,lev+2,off+len,&res); |
|
|
632 | if (res) |
|
|
633 | goto ERROR1; |
|
|
634 | psiconv_debug(lev+2,off+len,"Offset: %04x",temp); |
|
|
635 | len += 4; |
|
|
636 | |
|
|
637 | len = 0; |
|
|
638 | off = temp; |
|
|
639 | |
|
|
640 | /* this is the real worksheet section from here */ |
|
|
641 | |
|
|
642 | psiconv_progress(lev+1,off,"Going to read the sheet worksheet section"); |
|
|
643 | if (!(*result = malloc(sizeof(**result)))) |
|
|
644 | goto ERROR1; |
|
|
645 | |
|
|
646 | psiconv_progress(lev+2,off+len, |
|
|
647 | "Going to read the initial bytes (%02x expected)",0x04); |
|
|
648 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
|
|
649 | if (res) |
|
|
650 | goto ERROR2; |
|
|
651 | if (temp != 0x04) { |
|
|
652 | psiconv_warn(lev+2,off+len, |
|
|
653 | "Worksheet section initial byte unknown value (ignored)"); |
|
|
654 | psiconv_debug(lev+2,off+len,"Initial byte: %02x",temp); |
|
|
655 | } |
|
|
656 | len ++; |
|
|
657 | |
|
|
658 | psiconv_progress(lev+2,off+len, |
|
|
659 | "Going to read the initial bytes (%02x expected)",0x01); |
|
|
660 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
|
|
661 | if (res) |
|
|
662 | goto ERROR2; |
|
|
663 | if (temp != 0x01) { |
|
|
664 | psiconv_warn(lev+2,off+len, |
|
|
665 | "Worksheet section initial byte unknown value (ignored)"); |
|
|
666 | psiconv_debug(lev+2,off+len,"Initial byte: %02x",temp); |
|
|
667 | } |
|
|
668 | len ++; |
|
|
669 | |
|
|
670 | psiconv_progress(lev+2,off+len, |
|
|
671 | "Going to read the initial bytes (%02x expected)",0x02); |
|
|
672 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
|
|
673 | if (res) |
|
|
674 | goto ERROR2; |
|
|
675 | if (temp != 0x02) { |
|
|
676 | psiconv_warn(lev+2,off+len, |
|
|
677 | "Worksheet section initial byte unknown value (ignored)"); |
|
|
678 | psiconv_debug(lev+2,off+len,"Initial byte: %02x",temp); |
|
|
679 | } |
|
|
680 | len ++; |
|
|
681 | |
|
|
682 | psiconv_progress(lev+2,off+len,"Going to read the default formats flag"); |
|
|
683 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
|
|
684 | if (res) |
|
|
685 | goto ERROR2; |
|
|
686 | len ++; |
|
|
687 | |
|
|
688 | if (temp & 0x01) { |
|
|
689 | if (!((*result)->paragraph = psiconv_basic_paragraph_layout())) |
|
|
690 | goto ERROR2; |
|
|
691 | psiconv_progress(lev+3,off+len,"Going to read the default paragraph codes"); |
|
|
692 | if ((res = psiconv_parse_paragraph_layout_list(buf,lev+3,off+len,&leng, |
|
|
693 | (*result)->paragraph))) |
|
|
694 | goto ERROR2_1; |
|
|
695 | len += leng; |
|
|
696 | } |
|
|
697 | |
|
|
698 | if (temp & 0x02) { |
|
|
699 | psiconv_progress(lev+3,off+len,"Going to read the default character codes"); |
|
|
700 | if (!((*result)->character = psiconv_basic_character_layout())) |
|
|
701 | goto ERROR2_1; |
|
|
702 | if ((res = psiconv_parse_character_layout_list(buf,lev+3,off+len,&leng, |
|
|
703 | (*result)->character))) |
|
|
704 | goto ERROR2_2; |
|
|
705 | len += leng; |
|
|
706 | } |
|
|
707 | |
|
|
708 | if (temp & 0x04) { |
|
|
709 | /* TODO: default number format */ |
|
|
710 | psiconv_read_u8(buf,lev+2,off+len,&res); |
|
|
711 | if (res) |
|
|
712 | goto ERROR2_3; |
|
|
713 | len ++; |
|
|
714 | psiconv_read_u8(buf,lev+2,off+len,&res); |
|
|
715 | if (res) |
|
|
716 | goto ERROR2_3; |
|
|
717 | len ++; |
|
|
718 | psiconv_read_u8(buf,lev+2,off+len,&res); |
|
|
719 | if (res) |
|
|
720 | goto ERROR2_3; |
|
|
721 | len ++; |
|
|
722 | } |
|
|
723 | |
|
|
724 | psiconv_progress(lev+2,off+len, |
|
|
725 | "Going to read the offset of the 1st ??? Section"); |
|
|
726 | temp = psiconv_read_u32(buf,lev+2,off+len,&res); |
|
|
727 | if (res) |
|
|
728 | goto ERROR2; |
|
|
729 | psiconv_debug(lev+2,off+len,"Offset: %04x",temp); |
|
|
730 | len += 4; |
|
|
731 | |
|
|
732 | psiconv_progress(lev+2,off+len, |
|
|
733 | "Going to read the offset of the 2nd ??? Section"); |
|
|
734 | temp = psiconv_read_u32(buf,lev+2,off+len,&res); |
|
|
735 | if (res) |
|
|
736 | goto ERROR2; |
|
|
737 | psiconv_debug(lev+2,off+len,"Offset: %04x",temp); |
|
|
738 | len += 4; |
|
|
739 | |
|
|
740 | psiconv_progress(lev+2,off+len, |
|
|
741 | "Going to read the offset of the Cells List"); |
|
|
742 | cells_off = psiconv_read_u32(buf,lev+2,off+len,&res); |
|
|
743 | if (res) |
|
|
744 | goto ERROR2; |
|
|
745 | psiconv_debug(lev+2,off+len,"Offset: %04x",cells_off); |
|
|
746 | len += 4; |
|
|
747 | |
|
|
748 | psiconv_progress(lev+2,off+len, |
|
|
749 | "Going to read the offset of the Grid Section"); |
|
|
750 | grid_off = psiconv_read_u32(buf,lev+2,off+len,&res); |
|
|
751 | if (res) |
|
|
752 | goto ERROR2; |
|
|
753 | psiconv_debug(lev+2,off+len,"Offset: %04x",grid_off); |
|
|
754 | len += 4; |
|
|
755 | |
|
|
756 | psiconv_progress(lev+2,off+len, |
|
|
757 | "Going to read the offset of the 3rd ??? Section"); |
|
|
758 | temp = psiconv_read_u32(buf,lev+2,off+len,&res); |
|
|
759 | if (res) |
|
|
760 | goto ERROR2; |
|
|
761 | psiconv_debug(lev+2,off+len,"Offset: %04x",temp); |
|
|
762 | len += 4; |
|
|
763 | |
|
|
764 | psiconv_progress(lev+2,off+len,"Going to read the cells list"); |
|
|
765 | if ((res = psiconv_parse_sheet_cell_list(buf,lev+2,cells_off,NULL, |
|
|
766 | &(*result)->cells))) |
|
|
767 | goto ERROR2; |
|
|
768 | |
|
|
769 | |
|
|
770 | /* TODO: parse grid section */ |
|
|
771 | |
|
|
772 | if (length) |
|
|
773 | *length = len; |
|
|
774 | |
|
|
775 | psiconv_progress(lev,off+len-1, |
|
|
776 | "End of sheet worksheet section (total length: %08x)", len); |
|
|
777 | return 0; |
|
|
778 | |
|
|
779 | ERROR2_3: |
|
|
780 | psiconv_free_numberformat((*result)->numberformat); |
|
|
781 | ERROR2_2: |
|
|
782 | psiconv_free_character_layout((*result)->character); |
|
|
783 | ERROR2_1: |
|
|
784 | psiconv_free_paragraph_layout((*result)->paragraph); |
|
|
785 | goto ERROR2; |
|
|
786 | |
|
|
787 | ERROR2: |
|
|
788 | free (*result); |
|
|
789 | ERROR1: |
|
|
790 | psiconv_warn(lev+1,off,"Reading of Sheet Worksheet Section failed"); |
|
|
791 | if (length) |
|
|
792 | *length = 0; |
|
|
793 | if (!res) |
|
|
794 | return -PSICONV_E_NOMEM; |
|
|
795 | else |
|
|
796 | return res; |
|
|
797 | } |
|
|
798 | |
|
|
799 | |