… | |
… | |
22 | |
22 | |
23 | #include <stdlib.h> |
23 | #include <stdlib.h> |
24 | |
24 | |
25 | #include "parse_routines.h" |
25 | #include "parse_routines.h" |
26 | #include "error.h" |
26 | #include "error.h" |
|
|
27 | |
|
|
28 | #ifdef DMALLOC |
|
|
29 | #include <dmalloc.h> |
|
|
30 | #endif |
27 | |
31 | |
28 | static psiconv_sheet_cell_layout psiconv_basic_cell_layout(void) |
32 | static psiconv_sheet_cell_layout psiconv_basic_cell_layout(void) |
29 | { |
33 | { |
30 | psiconv_sheet_cell_layout result; |
34 | psiconv_sheet_cell_layout result; |
31 | if (!(result = malloc(sizeof(*result)))) |
35 | if (!(result = malloc(sizeof(*result)))) |
… | |
… | |
774 | psiconv_progress(lev+3,off+len,"Going to read formula %d",i); |
778 | psiconv_progress(lev+3,off+len,"Going to read formula %d",i); |
775 | if ((res = psiconv_parse_formula(buf,lev+3,off+len,&leng,&formula))) |
779 | if ((res = psiconv_parse_formula(buf,lev+3,off+len,&leng,&formula))) |
776 | goto ERROR2; |
780 | goto ERROR2; |
777 | if ((res = psiconv_list_add(*result,formula))) |
781 | if ((res = psiconv_list_add(*result,formula))) |
778 | goto ERROR3; |
782 | goto ERROR3; |
|
|
783 | free(formula); |
779 | len += leng; |
784 | len += leng; |
780 | } |
785 | } |
781 | |
786 | |
782 | if (length) |
787 | if (length) |
783 | *length = len; |
788 | *length = len; |
… | |
… | |
1325 | (*result)->row_default_layouts, |
1330 | (*result)->row_default_layouts, |
1326 | (*result)->col_default_layouts))) |
1331 | (*result)->col_default_layouts))) |
1327 | goto ERROR5; |
1332 | goto ERROR5; |
1328 | |
1333 | |
1329 | |
1334 | |
1330 | /* TODO: parse grid section */ |
1335 | psiconv_progress(lev+2,off+len,"Going to read the grid section"); |
|
|
1336 | if ((res = psiconv_parse_sheet_grid_section(buf,lev+2,grid_off,NULL, |
|
|
1337 | &(*result)->grid))) |
|
|
1338 | goto ERROR6; |
|
|
1339 | |
|
|
1340 | |
1331 | |
1341 | |
1332 | if (length) |
1342 | if (length) |
1333 | *length = len; |
1343 | *length = len; |
1334 | |
1344 | |
1335 | psiconv_progress(lev,off+len-1, |
1345 | psiconv_progress(lev,off+len-1, |
1336 | "End of sheet worksheet section (total length: %08x)", len); |
1346 | "End of sheet worksheet section (total length: %08x)", len); |
1337 | return 0; |
1347 | return 0; |
1338 | |
1348 | |
|
|
1349 | ERROR6: |
|
|
1350 | psiconv_free_sheet_cell_list((*result)->cells); |
1339 | ERROR5: |
1351 | ERROR5: |
1340 | psiconv_free_sheet_line_list((*result)->col_default_layouts); |
1352 | psiconv_free_sheet_line_list((*result)->col_default_layouts); |
1341 | ERROR4: |
1353 | ERROR4: |
1342 | psiconv_free_sheet_line_list((*result)->row_default_layouts); |
1354 | psiconv_free_sheet_line_list((*result)->row_default_layouts); |
1343 | ERROR3: |
1355 | ERROR3: |
… | |
… | |
1642 | if (!res) |
1654 | if (!res) |
1643 | return -PSICONV_E_NOMEM; |
1655 | return -PSICONV_E_NOMEM; |
1644 | else |
1656 | else |
1645 | return res; |
1657 | return res; |
1646 | } |
1658 | } |
|
|
1659 | |
|
|
1660 | int psiconv_parse_sheet_grid_section(const psiconv_buffer buf, int lev, |
|
|
1661 | psiconv_u32 off, int *length, |
|
|
1662 | psiconv_sheet_grid_section *result) |
|
|
1663 | { |
|
|
1664 | int res=0,i; |
|
|
1665 | int len=0,leng; |
|
|
1666 | psiconv_u32 temp; |
|
|
1667 | |
|
|
1668 | psiconv_progress(lev+1,off,"Going to read the sheet grid section"); |
|
|
1669 | if (!(*result = malloc(sizeof(**result)))) |
|
|
1670 | goto ERROR1; |
|
|
1671 | |
|
|
1672 | psiconv_progress(lev+2,off+len, "Going to read the first flags byte"); |
|
|
1673 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
|
|
1674 | if (res) |
|
|
1675 | goto ERROR2; |
|
|
1676 | (*result)->show_column_titles = temp&0x01?psiconv_bool_true: |
|
|
1677 | psiconv_bool_false; |
|
|
1678 | psiconv_debug(lev+2,off+len, |
|
|
1679 | "Show column titles: %s", |
|
|
1680 | (*result)->show_column_titles?"true":"false"); |
|
|
1681 | (*result)->show_row_titles = temp&0x02?psiconv_bool_true:psiconv_bool_false; |
|
|
1682 | psiconv_debug(lev+2,off+len, |
|
|
1683 | "Show row titles: %s", |
|
|
1684 | (*result)->show_row_titles?"true":"false"); |
|
|
1685 | (*result)->show_vertical_grid = temp&0x04?psiconv_bool_true: |
|
|
1686 | psiconv_bool_false; |
|
|
1687 | psiconv_debug(lev+2,off+len, |
|
|
1688 | "Show vertical grid: %s", |
|
|
1689 | (*result)->show_vertical_grid?"true":"false"); |
|
|
1690 | (*result)->show_horizontal_grid = temp&0x07?psiconv_bool_true: |
|
|
1691 | psiconv_bool_false; |
|
|
1692 | psiconv_debug(lev+2,off+len, |
|
|
1693 | "Show horizontal grid: %s", |
|
|
1694 | (*result)->show_horizontal_grid?"true":"false"); |
|
|
1695 | (*result)->freeze_rows = temp&0x80?psiconv_bool_true:psiconv_bool_false; |
|
|
1696 | psiconv_debug(lev+2,off+len, |
|
|
1697 | "Freeze rows: %s", |
|
|
1698 | (*result)->freeze_rows?"true":"false"); |
|
|
1699 | if ((temp & 0x70) != 0x30) { |
|
|
1700 | psiconv_warn(lev+2,off+len, |
|
|
1701 | "Grid section first flag byte has unknown bits (ignored)"); |
|
|
1702 | psiconv_debug(lev+2,off+len,"Bits: %02x (%02x expected)",temp&0x70,0x30); |
|
|
1703 | } |
|
|
1704 | len ++; |
|
|
1705 | |
|
|
1706 | psiconv_progress(lev+2,off+len, "Going to read the second flags byte"); |
|
|
1707 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
|
|
1708 | if (res) |
|
|
1709 | goto ERROR2; |
|
|
1710 | (*result)->freeze_columns = temp&0x01?psiconv_bool_true:psiconv_bool_false; |
|
|
1711 | psiconv_debug(lev+2,off+len, |
|
|
1712 | "Freeze columns: %s", (*result)->freeze_columns?"true":"false"); |
|
|
1713 | if ((temp & 0xfe) != 0x80) { |
|
|
1714 | psiconv_warn(lev+2,off+len, |
|
|
1715 | "Grid section second flag byte has unknown bits (ignored)"); |
|
|
1716 | psiconv_debug(lev+2,off+len,"Bits: %02x (%02x expected)",temp&0xfe,0x80); |
|
|
1717 | } |
|
|
1718 | len ++; |
|
|
1719 | |
|
|
1720 | psiconv_progress(lev+2,off+len, |
|
|
1721 | "Going to an unknown byte (%02x expected)",0x90); |
|
|
1722 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
|
|
1723 | if (res) |
|
|
1724 | goto ERROR2; |
|
|
1725 | if (temp != 0x90) { |
|
|
1726 | psiconv_warn(lev+2,off+len, |
|
|
1727 | "Grid section third byte unknown value (ignored)"); |
|
|
1728 | psiconv_debug(lev+2,off+len,"Value: %02x",temp); |
|
|
1729 | } |
|
|
1730 | len ++; |
|
|
1731 | |
|
|
1732 | psiconv_progress(lev+2,off+len, "Going to read the fourth flags byte"); |
|
|
1733 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
|
|
1734 | if (res) |
|
|
1735 | goto ERROR2; |
|
|
1736 | (*result)->show_page_breaks = temp&0x04?psiconv_bool_true:psiconv_bool_false; |
|
|
1737 | psiconv_debug(lev+2,off+len, |
|
|
1738 | "Show page breaks: %s", |
|
|
1739 | (*result)->show_page_breaks?"true":"false"); |
|
|
1740 | if ((temp & 0xfc) != 0x00) { |
|
|
1741 | psiconv_warn(lev+2,off+len, |
|
|
1742 | "Grid section fourth flag byte has unknown bits (ignored)"); |
|
|
1743 | psiconv_debug(lev+2,off+len,"Bits: %02x (%02x expected)",temp&0xfc,0x00); |
|
|
1744 | } |
|
|
1745 | len ++; |
|
|
1746 | |
|
|
1747 | psiconv_progress(lev+2,off+len,"Going to read the first visible row"); |
|
|
1748 | (*result)->first_row = psiconv_read_u32(buf,lev+2,off+len,&res); |
|
|
1749 | if (res) |
|
|
1750 | goto ERROR2; |
|
|
1751 | psiconv_debug(lev+2,off+len,"First row: %d",(*result)->first_row); |
|
|
1752 | len += 4; |
|
|
1753 | |
|
|
1754 | psiconv_progress(lev+2,off+len,"Going to read the first visible column"); |
|
|
1755 | (*result)->first_column = psiconv_read_u32(buf,lev+2,off+len,&res); |
|
|
1756 | if (res) |
|
|
1757 | goto ERROR2; |
|
|
1758 | psiconv_debug(lev+2,off+len,"First column: %d",(*result)->first_column); |
|
|
1759 | len += 4; |
|
|
1760 | |
|
|
1761 | psiconv_progress(lev+2,off+len,"Going to read the last visible row"); |
|
|
1762 | (*result)->last_row = psiconv_read_u32(buf,lev+2,off+len,&res); |
|
|
1763 | if (res) |
|
|
1764 | goto ERROR2; |
|
|
1765 | psiconv_debug(lev+2,off+len,"Last row: %d",(*result)->last_row); |
|
|
1766 | len += 4; |
|
|
1767 | |
|
|
1768 | psiconv_progress(lev+2,off+len,"Going to read the last visible column"); |
|
|
1769 | (*result)->last_column = psiconv_read_u32(buf,lev+2,off+len,&res); |
|
|
1770 | if (res) |
|
|
1771 | goto ERROR2; |
|
|
1772 | psiconv_debug(lev+2,off+len,"Last column: %d",(*result)->last_column); |
|
|
1773 | len += 4; |
|
|
1774 | |
|
|
1775 | psiconv_progress(lev+2,off+len,"Going to read the default row height"); |
|
|
1776 | (*result)->default_row_height = psiconv_read_length(buf,lev+2,off+len, |
|
|
1777 | &leng,&res); |
|
|
1778 | if (res) |
|
|
1779 | goto ERROR2; |
|
|
1780 | psiconv_debug(lev+2,off+len,"Default row height: %f", |
|
|
1781 | (*result)->default_row_height); |
|
|
1782 | len += leng; |
|
|
1783 | |
|
|
1784 | psiconv_progress(lev+2,off+len,"Going to read the row heights list"); |
|
|
1785 | if ((res = psiconv_parse_sheet_grid_size_list(buf,lev+2,off+len,&leng, |
|
|
1786 | &(*result)->row_heights))) |
|
|
1787 | goto ERROR2; |
|
|
1788 | len += leng; |
|
|
1789 | |
|
|
1790 | psiconv_progress(lev+2,off+len,"Going to read the default column height"); |
|
|
1791 | (*result)->default_column_width = psiconv_read_length(buf,lev+2,off+len, |
|
|
1792 | &leng,&res); |
|
|
1793 | if (res) |
|
|
1794 | goto ERROR3; |
|
|
1795 | psiconv_debug(lev+2,off+len,"Default column width: %f", |
|
|
1796 | (*result)->default_column_width); |
|
|
1797 | len += leng; |
|
|
1798 | |
|
|
1799 | psiconv_progress(lev+2,off+len,"Going to read the column heights list"); |
|
|
1800 | if ((res = psiconv_parse_sheet_grid_size_list(buf,lev+2,off+len,&leng, |
|
|
1801 | &(*result)->column_heights))) |
|
|
1802 | goto ERROR3; |
|
|
1803 | len += leng; |
|
|
1804 | |
|
|
1805 | psiconv_progress(lev+2,off+len, |
|
|
1806 | "Going to read an unknown word (%04x expected)",0x00); |
|
|
1807 | temp = psiconv_read_u16(buf,lev+2,off+len,&res); |
|
|
1808 | if (res) |
|
|
1809 | goto ERROR4; |
|
|
1810 | if (temp != 0x00) { |
|
|
1811 | psiconv_warn(lev+2,off+len, |
|
|
1812 | "Grid section unknown word has unknown value (ignored)"); |
|
|
1813 | psiconv_debug(lev+2,off+len,"Value: %04x",temp); |
|
|
1814 | } |
|
|
1815 | len += 2; |
|
|
1816 | |
|
|
1817 | psiconv_progress(lev+2,off+len,"Going to read the row breaks list"); |
|
|
1818 | if ((res = psiconv_parse_sheet_grid_break_list(buf,lev+2,off+len,&leng, |
|
|
1819 | &(*result)->row_page_breaks))) |
|
|
1820 | goto ERROR4; |
|
|
1821 | len += leng; |
|
|
1822 | |
|
|
1823 | psiconv_progress(lev+2,off+len,"Going to read the column breaks list"); |
|
|
1824 | if ((res = psiconv_parse_sheet_grid_break_list(buf,lev+2,off+len,&leng, |
|
|
1825 | &(*result)->column_page_breaks))) |
|
|
1826 | goto ERROR5; |
|
|
1827 | len += leng; |
|
|
1828 | |
|
|
1829 | |
|
|
1830 | psiconv_progress(lev+2,off+len, |
|
|
1831 | "Going to read 22 unknown bytes (%02x expected)",0x00); |
|
|
1832 | for (i = 0; i < 22 ; i++) { |
|
|
1833 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
|
|
1834 | if (res) |
|
|
1835 | goto ERROR6; |
|
|
1836 | if (temp != 0x00) { |
|
|
1837 | psiconv_warn(lev+2,off+len, |
|
|
1838 | "Grid section unknown byte %d has unknown value (ignored)", |
|
|
1839 | i); |
|
|
1840 | psiconv_debug(lev+2,off+len,"Value: %02x",temp); |
|
|
1841 | } |
|
|
1842 | len += 1; |
|
|
1843 | } |
|
|
1844 | |
|
|
1845 | if ((*result)->freeze_rows || (*result)->freeze_columns) { |
|
|
1846 | |
|
|
1847 | psiconv_progress(lev+2,off+len,"Going to read number of frozen rows"); |
|
|
1848 | (*result)->frozen_rows = psiconv_read_u32(buf,lev+2,off+len, &res); |
|
|
1849 | if (res) |
|
|
1850 | goto ERROR6; |
|
|
1851 | psiconv_debug(lev+2,off+len,"Number of frozen rows: %d", |
|
|
1852 | (*result)->frozen_rows); |
|
|
1853 | len += leng; |
|
|
1854 | |
|
|
1855 | psiconv_progress(lev+2,off+len,"Going to read number of frozen columns"); |
|
|
1856 | (*result)->frozen_columns = psiconv_read_u32(buf,lev+2,off+len, &res); |
|
|
1857 | if (res) |
|
|
1858 | goto ERROR6; |
|
|
1859 | psiconv_debug(lev+2,off+len,"Number of frozen columns: %d", |
|
|
1860 | (*result)->frozen_columns); |
|
|
1861 | len += leng; |
|
|
1862 | |
|
|
1863 | psiconv_progress(lev+2,off+len,"Going to read first unfrozen row"); |
|
|
1864 | (*result)->first_unfrozen_row_displayed = psiconv_read_u32(buf,lev+2, |
|
|
1865 | off+len, &res); |
|
|
1866 | if (res) |
|
|
1867 | goto ERROR6; |
|
|
1868 | psiconv_debug(lev+2,off+len,"First row: %d", |
|
|
1869 | (*result)->first_unfrozen_row_displayed); |
|
|
1870 | len += leng; |
|
|
1871 | |
|
|
1872 | psiconv_progress(lev+2,off+len,"Going to read first unfrozen column"); |
|
|
1873 | (*result)->first_unfrozen_column_displayed = psiconv_read_u32(buf,lev+2, |
|
|
1874 | off+len,&res); |
|
|
1875 | if (res) |
|
|
1876 | goto ERROR6; |
|
|
1877 | psiconv_debug(lev+2,off+len,"First column: %d", |
|
|
1878 | (*result)->first_unfrozen_column_displayed); |
|
|
1879 | len += leng; |
|
|
1880 | } else |
|
|
1881 | (*result)->frozen_rows = (*result)->frozen_columns = |
|
|
1882 | (*result)->first_unfrozen_row_displayed = |
|
|
1883 | (*result)->first_unfrozen_column_displayed = 0; |
|
|
1884 | |
|
|
1885 | psiconv_progress(lev+2,off+len, |
|
|
1886 | "Going to read 3 unknown bytes (%02x expected)",0xff); |
|
|
1887 | for (i = 0; i < 3 ; i++) { |
|
|
1888 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
|
|
1889 | if (res) |
|
|
1890 | goto ERROR6; |
|
|
1891 | if (temp != 0xff) { |
|
|
1892 | psiconv_warn(lev+2,off+len, |
|
|
1893 | "Grid section unknown byte %d has unknown value (ignored)", |
|
|
1894 | i); |
|
|
1895 | psiconv_debug(lev+2,off+len,"Value: %02x",temp); |
|
|
1896 | } |
|
|
1897 | len ++; |
|
|
1898 | } |
|
|
1899 | |
|
|
1900 | if (length) |
|
|
1901 | *length = len; |
|
|
1902 | |
|
|
1903 | psiconv_progress(lev,off+len-1, |
|
|
1904 | "End of sheet grid section (total length: %08x)", len); |
|
|
1905 | return 0; |
|
|
1906 | |
|
|
1907 | ERROR6: |
|
|
1908 | psiconv_free_sheet_grid_break_list((*result)->column_page_breaks); |
|
|
1909 | ERROR5: |
|
|
1910 | psiconv_free_sheet_grid_break_list((*result)->row_page_breaks); |
|
|
1911 | ERROR4: |
|
|
1912 | psiconv_free_sheet_grid_size_list((*result)->column_heights); |
|
|
1913 | ERROR3: |
|
|
1914 | psiconv_free_sheet_grid_size_list((*result)->row_heights); |
|
|
1915 | ERROR2: |
|
|
1916 | free(*result); |
|
|
1917 | ERROR1: |
|
|
1918 | psiconv_warn(lev+1,off,"Reading of Sheet Grid Section failed"); |
|
|
1919 | if (length) |
|
|
1920 | *length = 0; |
|
|
1921 | if (!res) |
|
|
1922 | return -PSICONV_E_NOMEM; |
|
|
1923 | else |
|
|
1924 | return res; |
|
|
1925 | } |
|
|
1926 | |
|
|
1927 | |
|
|
1928 | int psiconv_parse_sheet_grid_size_list(const psiconv_buffer buf, int lev, |
|
|
1929 | psiconv_u32 off, int *length, |
|
|
1930 | psiconv_sheet_grid_size_list *result) |
|
|
1931 | { |
|
|
1932 | int res=0; |
|
|
1933 | int len=0,i; |
|
|
1934 | int leng,listlen; |
|
|
1935 | psiconv_sheet_grid_size size; |
|
|
1936 | |
|
|
1937 | psiconv_progress(lev+1,off,"Going to read a sheet grid size list"); |
|
|
1938 | if (!(*result = psiconv_list_new(sizeof(struct psiconv_sheet_grid_size_s)))) |
|
|
1939 | goto ERROR1; |
|
|
1940 | |
|
|
1941 | psiconv_progress(lev+2,off+len, |
|
|
1942 | "Going to read the number of elements"); |
|
|
1943 | listlen = psiconv_read_X(buf,lev+2,off+len,&leng,&res); |
|
|
1944 | if (res) |
|
|
1945 | goto ERROR2; |
|
|
1946 | psiconv_debug(lev+2,off+len,"Number of elements: %d",listlen); |
|
|
1947 | len += leng; |
|
|
1948 | |
|
|
1949 | psiconv_progress(lev+2,off+len,"Going to read all elements"); |
|
|
1950 | for (i = 0; i < listlen; i++) { |
|
|
1951 | psiconv_progress(lev+3,off+len,"Going to read element %d",i); |
|
|
1952 | if ((res = psiconv_parse_sheet_grid_size(buf,lev+3,off+len,&leng,&size))) |
|
|
1953 | goto ERROR2; |
|
|
1954 | if ((res = psiconv_list_add(*result,size))) |
|
|
1955 | goto ERROR3; |
|
|
1956 | free(size); |
|
|
1957 | len += leng; |
|
|
1958 | } |
|
|
1959 | |
|
|
1960 | if (length) |
|
|
1961 | *length = len; |
|
|
1962 | |
|
|
1963 | psiconv_progress(lev,off+len-1, |
|
|
1964 | "End of sheet grid size list (total length: %08x)", len); |
|
|
1965 | return 0; |
|
|
1966 | |
|
|
1967 | ERROR3: |
|
|
1968 | psiconv_free_sheet_grid_size(size); |
|
|
1969 | ERROR2: |
|
|
1970 | psiconv_list_free(*result); |
|
|
1971 | ERROR1: |
|
|
1972 | psiconv_warn(lev+1,off,"Reading of Sheet Grid Size List failed"); |
|
|
1973 | if (length) |
|
|
1974 | *length = 0; |
|
|
1975 | if (!res) |
|
|
1976 | return -PSICONV_E_NOMEM; |
|
|
1977 | else |
|
|
1978 | return res; |
|
|
1979 | } |
|
|
1980 | |
|
|
1981 | int psiconv_parse_sheet_grid_size(const psiconv_buffer buf, int lev, |
|
|
1982 | psiconv_u32 off, int *length, |
|
|
1983 | psiconv_sheet_grid_size *result) |
|
|
1984 | { |
|
|
1985 | int res=0; |
|
|
1986 | int len=0; |
|
|
1987 | int leng; |
|
|
1988 | |
|
|
1989 | psiconv_progress(lev+1,off,"Going to read a sheet grid size"); |
|
|
1990 | |
|
|
1991 | if (!(*result = malloc(sizeof(**result)))) |
|
|
1992 | goto ERROR1; |
|
|
1993 | |
|
|
1994 | psiconv_progress(lev+2,off+len, "Going to read the row or column number"); |
|
|
1995 | (*result)->line_number = psiconv_read_u32(buf,lev+2,off+len,&res); |
|
|
1996 | if (res) |
|
|
1997 | goto ERROR2; |
|
|
1998 | psiconv_debug(lev+2,off+len,"Line number: %d\n",(*result)->line_number); |
|
|
1999 | len += 4; |
|
|
2000 | |
|
|
2001 | psiconv_progress(lev+2,off+len, "Going to read the row or column height"); |
|
|
2002 | (*result)->size = psiconv_read_length(buf,lev+2,off+len,&leng,&res); |
|
|
2003 | if (res) |
|
|
2004 | goto ERROR2; |
|
|
2005 | psiconv_debug(lev+2,off+len,"Size: %f\n",(*result)->size); |
|
|
2006 | len += leng; |
|
|
2007 | |
|
|
2008 | if (length) |
|
|
2009 | *length = len; |
|
|
2010 | |
|
|
2011 | psiconv_progress(lev,off+len-1, |
|
|
2012 | "End of sheet grid size(total length: %08x)", len); |
|
|
2013 | return 0; |
|
|
2014 | |
|
|
2015 | ERROR2: |
|
|
2016 | free (*result); |
|
|
2017 | ERROR1: |
|
|
2018 | psiconv_warn(lev+1,off,"Reading of Sheet Grid Size failed"); |
|
|
2019 | if (length) |
|
|
2020 | *length = 0; |
|
|
2021 | if (!res) |
|
|
2022 | return -PSICONV_E_NOMEM; |
|
|
2023 | else |
|
|
2024 | return res; |
|
|
2025 | } |
|
|
2026 | |
|
|
2027 | |
|
|
2028 | int psiconv_parse_sheet_grid_break_list(const psiconv_buffer buf, int lev, |
|
|
2029 | psiconv_u32 off, int *length, |
|
|
2030 | psiconv_sheet_grid_break_list *result) |
|
|
2031 | { |
|
|
2032 | int res=0; |
|
|
2033 | int len=0,i; |
|
|
2034 | int leng,listlen; |
|
|
2035 | psiconv_u32 nr; |
|
|
2036 | |
|
|
2037 | psiconv_progress(lev+1,off,"Going to read a sheet grid break list"); |
|
|
2038 | if (!(*result = psiconv_list_new(sizeof(psiconv_u32)))) |
|
|
2039 | goto ERROR1; |
|
|
2040 | |
|
|
2041 | psiconv_progress(lev+2,off+len, |
|
|
2042 | "Going to read the number of elements"); |
|
|
2043 | listlen = psiconv_read_X(buf,lev+2,off+len,&leng,&res); |
|
|
2044 | if (res) |
|
|
2045 | goto ERROR2; |
|
|
2046 | psiconv_debug(lev+2,off+len,"Number of elements: %d",listlen); |
|
|
2047 | len += leng; |
|
|
2048 | |
|
|
2049 | psiconv_progress(lev+2,off+len,"Going to read all elements"); |
|
|
2050 | for (i = 0; i < listlen; i++) { |
|
|
2051 | psiconv_progress(lev+3,off+len,"Going to read element %d",i); |
|
|
2052 | nr = psiconv_read_u32(buf,lev+3,off+len,&res); |
|
|
2053 | if (res) |
|
|
2054 | goto ERROR2; |
|
|
2055 | if ((res = psiconv_list_add(*result,&nr))) |
|
|
2056 | goto ERROR2; |
|
|
2057 | len += leng; |
|
|
2058 | } |
|
|
2059 | |
|
|
2060 | if (length) |
|
|
2061 | *length = len; |
|
|
2062 | |
|
|
2063 | psiconv_progress(lev,off+len-1, |
|
|
2064 | "End of sheet grid break list (total length: %08x)", len); |
|
|
2065 | return 0; |
|
|
2066 | |
|
|
2067 | ERROR2: |
|
|
2068 | psiconv_list_free(*result); |
|
|
2069 | ERROR1: |
|
|
2070 | psiconv_warn(lev+1,off,"Reading of Sheet Grid break List failed"); |
|
|
2071 | if (length) |
|
|
2072 | *length = 0; |
|
|
2073 | if (!res) |
|
|
2074 | return -PSICONV_E_NOMEM; |
|
|
2075 | else |
|
|
2076 | return res; |
|
|
2077 | } |
|
|
2078 | |