--- psiconv/trunk/lib/psiconv/parse_page.c 2000/12/22 22:31:50 71 +++ psiconv/trunk/lib/psiconv/parse_page.c 2001/03/06 23:59:46 111 @@ -31,7 +31,7 @@ { int res = 0; int len = 0; - int i,leng; + int i,leng,has_content; psiconv_u32 temp; psiconv_progress(lev+1,off,"Going to read a page header (or footer)"); @@ -39,15 +39,21 @@ goto ERROR1; psiconv_progress(lev+2,off+len, - "Going to read the first byte (0x01 expected)"); + "Going to read the has_content flag"); temp = psiconv_read_u8(buf,lev+2,off+len,&res); if (res) goto ERROR2; - if (temp != 0x01) { - psiconv_warn(lev+2,off+len,"Page header first byte mismatch"); - psiconv_debug(lev+2,off+len,"First byte: read %02x, expected %02x", - temp,0x01); + if (temp == 0x00) + has_content = 0; + else if (temp == 0x01) + has_content = 1; + else { + psiconv_warn(lev+2,off+len, + "Page header has_content flag unknown value (assumed default)"); + psiconv_debug(lev+2,off+len,"Flag: %02x",temp); + has_content = 1; } + psiconv_debug(lev+2,off+len,"Has_content flag: %02x",has_content); len += 1; psiconv_progress(lev+2,off+len,"Going to read displayed-on-first-page flag"); @@ -72,27 +78,34 @@ psiconv_progress(lev+2,off+len,"Going to read base paragraph layout"); if (!((*result)->base_paragraph_layout = psiconv_basic_paragraph_layout())) goto ERROR2; - if ((res = psiconv_parse_paragraph_layout_list(buf,lev+2,off+len,&leng, - (*result)->base_paragraph_layout))) - goto ERROR3; - len += leng; + + if (has_content) { + if ((res = psiconv_parse_paragraph_layout_list(buf,lev+2,off+len,&leng, + (*result)->base_paragraph_layout))) + goto ERROR3; + len += leng; + } psiconv_progress(lev+2,off+len,"Going to read base character layout"); if (!((*result)->base_character_layout = psiconv_basic_character_layout())) goto ERROR3; - if ((res = psiconv_parse_character_layout_list(buf,lev+2,off+len,&leng, - (*result)->base_character_layout))) - goto ERROR4; + if (has_content) { + if ((res = psiconv_parse_character_layout_list(buf,lev+2,off+len,&leng, + (*result)->base_character_layout))) + goto ERROR4; + } len += leng; psiconv_progress(lev+2,off+len,"Going to read the TextEd section"); - if ((res = psiconv_parse_texted_section(buf,lev+2,off+len,&leng, - &(*result)->text, - (*result)->base_character_layout, - (*result)->base_paragraph_layout))) - goto ERROR4; - len += leng; + if (has_content) { + if ((res = psiconv_parse_texted_section(buf,lev+2,off+len,&leng, + &(*result)->text, + (*result)->base_character_layout, + (*result)->base_paragraph_layout))) + goto ERROR4; + len += leng; + } if (length) *length = len; @@ -196,12 +209,14 @@ temp = psiconv_read_u32(buf,lev+2,off+len,&res); if (res) goto ERROR4; - if (temp != PSICONV_ID_PAGE_DIMENSIONS) { + if ((temp != PSICONV_ID_PAGE_DIMENSIONS1) && + (temp != PSICONV_ID_PAGE_DIMENSIONS2)) { psiconv_warn(lev+2,off+len, "Page layout section page dimensions marker not found"); psiconv_debug(lev+2,off+len, - "Page dimensions marker: read %08x, expected %08x",temp, - PSICONV_ID_PAGE_DIMENSIONS); + "Page dimensions marker: read %08x, expected %08x or %08x", + temp, PSICONV_ID_PAGE_DIMENSIONS1, + PSICONV_ID_PAGE_DIMENSIONS2); } len += 4; @@ -219,6 +234,13 @@ psiconv_debug(lev+2,off+len,"Page height: %6.3f",(*result)->page_height); len += leng; + psiconv_progress(lev+2,off+len,"Going to read page portrait/landscape"); + if ((res = psiconv_parse_bool(buf,lev+2,off+len,&leng,&(*result)->landscape))) + goto ERROR4; + psiconv_debug(lev+2,off+len,"Landscape: %d",(*result)->landscape); + len += leng; + + if (length) *length = len;