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