/[public]/psiconv/trunk/lib/psiconv/parse_sheet.c
ViewVC logotype

Diff of /psiconv/trunk/lib/psiconv/parse_sheet.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 168 Revision 196
1/* 1/*
2 parse_sheet.c - Part of psiconv, a PSION 5 file formats converter 2 parse_sheet.c - Part of psiconv, a PSION 5 file formats converter
3 Copyright (c) 2001 Frodo Looijaard <frodol@dds.nl> 3 Copyright (c) 2000-2004 Frodo Looijaard <frodol@dds.nl>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
131 131
132 psiconv_progress(config,lev,off+len-1, 132 psiconv_progress(config,lev,off+len-1,
133 "End of sheet column reference (total length: %08x)", len); 133 "End of sheet column reference (total length: %08x)", len);
134 return result; 134 return result;
135ERROR1: 135ERROR1:
136 psiconv_warn(config,lev+1,off,"Reading of Sheet Column Reference failed"); 136 psiconv_error(config,lev+1,off,"Reading of Sheet Column Reference failed");
137 if (length) 137 if (length)
138 *length = 0; 138 *length = 0;
139 if (status) 139 if (status)
140 *status = res?res:-PSICONV_E_NOMEM; 140 *status = res?res:-PSICONV_E_NOMEM;
141 return result; 141 return result;
215 psiconv_progress(config,lev,off+len-1, 215 psiconv_progress(config,lev,off+len-1,
216 "End of sheet cell block reference (total length: %08x)", 216 "End of sheet cell block reference (total length: %08x)",
217 len); 217 len);
218 return result; 218 return result;
219ERROR1: 219ERROR1:
220 psiconv_warn(config,lev+1,off,"Reading of Sheet Cell Block Reference failed"); 220 psiconv_error(config,lev+1,off,"Reading of Sheet Cell Block Reference failed");
221 if (length) 221 if (length)
222 *length = 0; 222 *length = 0;
223 if (status) 223 if (status)
224 *status = res?res:-PSICONV_E_NOMEM; 224 *status = res?res:-PSICONV_E_NOMEM;
225 return result; 225 return result;
334 psiconv_progress(config,lev,off+len-1, 334 psiconv_progress(config,lev,off+len-1,
335 "End of sheet number format (total length: %08x)", len); 335 "End of sheet number format (total length: %08x)", len);
336 return 0; 336 return 0;
337 337
338ERROR1: 338ERROR1:
339 psiconv_warn(config,lev+1,off,"Reading of Sheet Number Format failed"); 339 psiconv_error(config,lev+1,off,"Reading of Sheet Number Format failed");
340 if (length) 340 if (length)
341 *length = 0; 341 *length = 0;
342 if (!res) 342 if (!res)
343 return -PSICONV_E_NOMEM; 343 return -PSICONV_E_NOMEM;
344 else 344 else
492 return 0; 492 return 0;
493 493
494ERROR2: 494ERROR2:
495 free (*result); 495 free (*result);
496ERROR1: 496ERROR1:
497 psiconv_warn(config,lev+1,off,"Reading of Sheet Status Section failed"); 497 psiconv_error(config,lev+1,off,"Reading of Sheet Status Section failed");
498 if (length) 498 if (length)
499 *length = 0; 499 *length = 0;
500 if (!res) 500 if (!res)
501 return -PSICONV_E_NOMEM; 501 return -PSICONV_E_NOMEM;
502 else 502 else
617ERROR3: 617ERROR3:
618 psiconv_free_sheet_info_section((*result)->info); 618 psiconv_free_sheet_info_section((*result)->info);
619ERROR2: 619ERROR2:
620 free (*result); 620 free (*result);
621ERROR1: 621ERROR1:
622 psiconv_warn(config,lev+1,off,"Reading of Sheet Workbook Section failed"); 622 psiconv_error(config,lev+1,off,"Reading of Sheet Workbook Section failed");
623 if (length) 623 if (length)
624 *length = 0; 624 *length = 0;
625 if (!res) 625 if (!res)
626 return -PSICONV_E_NOMEM; 626 return -PSICONV_E_NOMEM;
627 else 627 else
667 return 0; 667 return 0;
668 668
669ERROR2: 669ERROR2:
670 free(*result); 670 free(*result);
671ERROR1: 671ERROR1:
672 psiconv_warn(config,lev+1,off,"Reading of Sheet Name Section failed"); 672 psiconv_error(config,lev+1,off,"Reading of Sheet Name Section failed");
673 if (length) 673 if (length)
674 *length = 0; 674 *length = 0;
675 if (!res) 675 if (!res)
676 return -PSICONV_E_NOMEM; 676 return -PSICONV_E_NOMEM;
677 else 677 else
734 return 0; 734 return 0;
735 735
736ERROR2: 736ERROR2:
737 free(*result); 737 free(*result);
738ERROR1: 738ERROR1:
739 psiconv_warn(config,lev+1,off,"Reading of Sheet Name Section failed"); 739 psiconv_error(config,lev+1,off,"Reading of Sheet Name Section failed");
740 if (length) 740 if (length)
741 *length = 0; 741 *length = 0;
742 if (!res) 742 if (!res)
743 return -PSICONV_E_NOMEM; 743 return -PSICONV_E_NOMEM;
744 else 744 else
802ERROR3: 802ERROR3:
803 psiconv_free_formula(formula); 803 psiconv_free_formula(formula);
804ERROR2: 804ERROR2:
805 psiconv_list_free(*result); 805 psiconv_list_free(*result);
806ERROR1: 806ERROR1:
807 psiconv_warn(config,lev+1,off,"Reading of Sheet Formula list failed"); 807 psiconv_error(config,lev+1,off,"Reading of Sheet Formula list failed");
808 if (length) 808 if (length)
809 *length = 0; 809 *length = 0;
810 if (!res) 810 if (!res)
811 return -PSICONV_E_NOMEM; 811 return -PSICONV_E_NOMEM;
812 else 812 else
824 int res=0; 824 int res=0;
825 int len=0; 825 int len=0;
826 psiconv_u32 temp; 826 psiconv_u32 temp;
827 psiconv_bool_t has_layout; 827 psiconv_bool_t has_layout;
828 int leng; 828 int leng;
829 char *auxstr;
829 830
830 psiconv_progress(config,lev+1,off,"Going to read a sheet cell structure"); 831 psiconv_progress(config,lev+1,off,"Going to read a sheet cell structure");
831 if (!(*result = malloc(sizeof(**result)))) 832 if (!(*result = malloc(sizeof(**result))))
832 goto ERROR1; 833 goto ERROR1;
833 834
925 psiconv_progress(config,lev+2,off+len,"Going to read a string"); 926 psiconv_progress(config,lev+2,off+len,"Going to read a string");
926 (*result)->data.dat_string = 927 (*result)->data.dat_string =
927 psiconv_read_string(config,buf,lev+2,off+len,&leng,&res); 928 psiconv_read_string(config,buf,lev+2,off+len,&leng,&res);
928 if (res) 929 if (res)
929 goto ERROR2; 930 goto ERROR2;
931 if (!(auxstr = psiconv_make_printable(config,(*result)->data.dat_string)))
932 goto ERROR2;
930 psiconv_debug(config,lev+2,off+len,"Cell contents: `%s'", 933 psiconv_debug(config,lev+2,off+len,"Cell contents: `%s'",auxstr);
931 (*result)->data.dat_string); 934 free(auxstr);
932 len += leng; 935 len += leng;
933 } else { 936 } else {
934 psiconv_warn(config,lev+2,off+len,"Unknown Sheet Cell type: %02x",(*result)->type); 937 psiconv_error(config,lev+2,off+len,"Unknown Sheet Cell type: %02x",(*result)->type);
935 res = PSICONV_E_PARSE; 938 res = PSICONV_E_PARSE;
936 goto ERROR2; 939 goto ERROR2;
937 } 940 }
938 941
939 if (!((*result)->layout = psiconv_clone_cell_layout( 942 if (!((*result)->layout = psiconv_clone_cell_layout(
1053ERROR3: 1056ERROR3:
1054 psiconv_free_sheet_cell(cell); 1057 psiconv_free_sheet_cell(cell);
1055ERROR2: 1058ERROR2:
1056 psiconv_free_sheet_cell_list(*result); 1059 psiconv_free_sheet_cell_list(*result);
1057ERROR1: 1060ERROR1:
1058 psiconv_warn(config,lev+1,off,"Reading of Sheet Cells List failed"); 1061 psiconv_error(config,lev+1,off,"Reading of Sheet Cells List failed");
1059 if (length) 1062 if (length)
1060 *length = 0; 1063 *length = 0;
1061 if (!res) 1064 if (!res)
1062 return -PSICONV_E_NOMEM; 1065 return -PSICONV_E_NOMEM;
1063 else 1066 else
1141ERROR3: 1144ERROR3:
1142 psiconv_free_sheet_worksheet(worksheet); 1145 psiconv_free_sheet_worksheet(worksheet);
1143ERROR2: 1146ERROR2:
1144 psiconv_free_sheet_worksheet_list(*result); 1147 psiconv_free_sheet_worksheet_list(*result);
1145ERROR1: 1148ERROR1:
1146 psiconv_warn(config,lev+1,off,"Reading of worksheet list failed"); 1149 psiconv_error(config,lev+1,off,"Reading of worksheet list failed");
1147 if (length) 1150 if (length)
1148 *length = 0; 1151 *length = 0;
1149 if (!res) 1152 if (!res)
1150 return -PSICONV_E_NOMEM; 1153 return -PSICONV_E_NOMEM;
1151 else 1154 else
1213 "End of sheet cell layout (total length: %08x)", len); 1216 "End of sheet cell layout (total length: %08x)", len);
1214 1217
1215 return 0; 1218 return 0;
1216 1219
1217ERROR1: 1220ERROR1:
1218 psiconv_warn(config,lev+1,off,"Reading of sheet cell layout failed"); 1221 psiconv_error(config,lev+1,off,"Reading of sheet cell layout failed");
1219 if (length) 1222 if (length)
1220 *length = 0; 1223 *length = 0;
1221 if (!res) 1224 if (!res)
1222 return -PSICONV_E_NOMEM; 1225 return -PSICONV_E_NOMEM;
1223 else 1226 else
1368ERROR3: 1371ERROR3:
1369 psiconv_free_sheet_cell_layout((*result)->default_layout); 1372 psiconv_free_sheet_cell_layout((*result)->default_layout);
1370ERROR2: 1373ERROR2:
1371 free (*result); 1374 free (*result);
1372ERROR1: 1375ERROR1:
1373 psiconv_warn(config,lev+1,off,"Reading of Sheet Worksheet Section failed"); 1376 psiconv_error(config,lev+1,off,"Reading of Sheet Worksheet Section failed");
1374 if (length) 1377 if (length)
1375 *length = 0; 1378 *length = 0;
1376 if (!res) 1379 if (!res)
1377 return -PSICONV_E_NOMEM; 1380 return -PSICONV_E_NOMEM;
1378 else 1381 else
1418ERROR3: 1421ERROR3:
1419 psiconv_free_sheet_cell_layout((*result)->layout); 1422 psiconv_free_sheet_cell_layout((*result)->layout);
1420ERROR2: 1423ERROR2:
1421 free (*result); 1424 free (*result);
1422ERROR1: 1425ERROR1:
1423 psiconv_warn(config,lev+1,off,"Reading of the sheet line failed"); 1426 psiconv_error(config,lev+1,off,"Reading of the sheet line failed");
1424 if (length) 1427 if (length)
1425 *length = 0; 1428 *length = 0;
1426 if (!res) 1429 if (!res)
1427 return -PSICONV_E_NOMEM; 1430 return -PSICONV_E_NOMEM;
1428 else 1431 else
1489ERROR3: 1492ERROR3:
1490 psiconv_free_sheet_line(line); 1493 psiconv_free_sheet_line(line);
1491ERROR2: 1494ERROR2:
1492 psiconv_free_sheet_line_list(*result); 1495 psiconv_free_sheet_line_list(*result);
1493ERROR1: 1496ERROR1:
1494 psiconv_warn(config,lev+1,off,"Reading of Sheet Line List failed"); 1497 psiconv_error(config,lev+1,off,"Reading of Sheet Line List failed");
1495 if (length) 1498 if (length)
1496 *length = 0; 1499 *length = 0;
1497 if (!res) 1500 if (!res)
1498 return -PSICONV_E_NOMEM; 1501 return -PSICONV_E_NOMEM;
1499 else 1502 else
1545 psiconv_debug(config,lev+2,off+len,"Value: %f",(*result)->data.dat_float); 1548 psiconv_debug(config,lev+2,off+len,"Value: %f",(*result)->data.dat_float);
1546 len += leng; 1549 len += leng;
1547 } else if (marker == 0x02) { 1550 } else if (marker == 0x02) {
1548 (*result)->type = psiconv_var_string; 1551 (*result)->type = psiconv_var_string;
1549 psiconv_progress(config,lev+2,off+len,"Going to read a string"); 1552 psiconv_progress(config,lev+2,off+len,"Going to read a string");
1550 (*result)->data.dat_string = psiconv_read_string(config,buf,lev+2,off+len,&leng, 1553 (*result)->data.dat_string = psiconv_read_string(config,buf,lev+2,off+len,
1551 &res); 1554 &leng, &res);
1552 if (res) 1555 if (res)
1553 goto ERROR3; 1556 goto ERROR3;
1554 len += leng; 1557 len += leng;
1555 } else if (marker == 0x03) { 1558 } else if (marker == 0x03) {
1556 (*result)->type = psiconv_var_cellref; 1559 (*result)->type = psiconv_var_cellref;
1568 &leng, &res); 1571 &leng, &res);
1569 if (res) 1572 if (res)
1570 goto ERROR3; 1573 goto ERROR3;
1571 len += leng; 1574 len += leng;
1572 } else { 1575 } else {
1573 psiconv_warn(config,lev+2,off+len,"Sheet variable unknown type marker"); 1576 psiconv_error(config,lev+2,off+len,"Sheet variable unknown type marker");
1574 res = -PSICONV_E_PARSE; 1577 res = -PSICONV_E_PARSE;
1575 goto ERROR3; 1578 goto ERROR3;
1576 } 1579 }
1577 1580
1578 psiconv_progress(config,lev+2,off+len,"Going to read the variable number"); 1581 psiconv_progress(config,lev+2,off+len,"Going to read the variable number");
1595ERROR3: 1598ERROR3:
1596 free((*result)->name); 1599 free((*result)->name);
1597ERROR2: 1600ERROR2:
1598 free (*result); 1601 free (*result);
1599ERROR1: 1602ERROR1:
1600 psiconv_warn(config,lev+1,off,"Reading of Sheet Variable failed"); 1603 psiconv_error(config,lev+1,off,"Reading of Sheet Variable failed");
1601 if (length) 1604 if (length)
1602 *length = 0; 1605 *length = 0;
1603 if (!res) 1606 if (!res)
1604 return -PSICONV_E_NOMEM; 1607 return -PSICONV_E_NOMEM;
1605 else 1608 else
1663ERROR3: 1666ERROR3:
1664 psiconv_free_sheet_variable(variable); 1667 psiconv_free_sheet_variable(variable);
1665ERROR2: 1668ERROR2:
1666 psiconv_list_free(*result); 1669 psiconv_list_free(*result);
1667ERROR1: 1670ERROR1:
1668 psiconv_warn(config,lev+1,off,"Reading of Sheet Variable list failed"); 1671 psiconv_error(config,lev+1,off,"Reading of Sheet Variable list failed");
1669 if (length) 1672 if (length)
1670 *length = 0; 1673 *length = 0;
1671 if (!res) 1674 if (!res)
1672 return -PSICONV_E_NOMEM; 1675 return -PSICONV_E_NOMEM;
1673 else 1676 else
1931ERROR3: 1934ERROR3:
1932 psiconv_free_sheet_grid_size_list((*result)->row_heights); 1935 psiconv_free_sheet_grid_size_list((*result)->row_heights);
1933ERROR2: 1936ERROR2:
1934 free(*result); 1937 free(*result);
1935ERROR1: 1938ERROR1:
1936 psiconv_warn(config,lev+1,off,"Reading of Sheet Grid Section failed"); 1939 psiconv_error(config,lev+1,off,"Reading of Sheet Grid Section failed");
1937 if (length) 1940 if (length)
1938 *length = 0; 1941 *length = 0;
1939 if (!res) 1942 if (!res)
1940 return -PSICONV_E_NOMEM; 1943 return -PSICONV_E_NOMEM;
1941 else 1944 else
1986ERROR3: 1989ERROR3:
1987 psiconv_free_sheet_grid_size(size); 1990 psiconv_free_sheet_grid_size(size);
1988ERROR2: 1991ERROR2:
1989 psiconv_list_free(*result); 1992 psiconv_list_free(*result);
1990ERROR1: 1993ERROR1:
1991 psiconv_warn(config,lev+1,off,"Reading of Sheet Grid Size List failed"); 1994 psiconv_error(config,lev+1,off,"Reading of Sheet Grid Size List failed");
1992 if (length) 1995 if (length)
1993 *length = 0; 1996 *length = 0;
1994 if (!res) 1997 if (!res)
1995 return -PSICONV_E_NOMEM; 1998 return -PSICONV_E_NOMEM;
1996 else 1999 else
2033 return 0; 2036 return 0;
2034 2037
2035ERROR2: 2038ERROR2:
2036 free (*result); 2039 free (*result);
2037ERROR1: 2040ERROR1:
2038 psiconv_warn(config,lev+1,off,"Reading of Sheet Grid Size failed"); 2041 psiconv_error(config,lev+1,off,"Reading of Sheet Grid Size failed");
2039 if (length) 2042 if (length)
2040 *length = 0; 2043 *length = 0;
2041 if (!res) 2044 if (!res)
2042 return -PSICONV_E_NOMEM; 2045 return -PSICONV_E_NOMEM;
2043 else 2046 else
2086 return 0; 2089 return 0;
2087 2090
2088ERROR2: 2091ERROR2:
2089 psiconv_list_free(*result); 2092 psiconv_list_free(*result);
2090ERROR1: 2093ERROR1:
2091 psiconv_warn(config,lev+1,off,"Reading of Sheet Grid break List failed"); 2094 psiconv_error(config,lev+1,off,"Reading of Sheet Grid break List failed");
2092 if (length) 2095 if (length)
2093 *length = 0; 2096 *length = 0;
2094 if (!res) 2097 if (!res)
2095 return -PSICONV_E_NOMEM; 2098 return -PSICONV_E_NOMEM;
2096 else 2099 else

Legend:
Removed from v.168  
changed lines
  Added in v.196

frodo@frodo.looijaard.name
ViewVC Help
Powered by ViewVC 1.1.26