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

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

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

Revision 159 Revision 160
715 "Layout section inlines: not enough element"); 715 "Layout section inlines: not enough element");
716 psiconv_debug(lev+3,off+len,"Can't read element!"); 716 psiconv_debug(lev+3,off+len,"Can't read element!");
717 } else { 717 } else {
718 total ++; 718 total ++;
719 in_line.object = NULL; 719 in_line.object = NULL;
720 in_line.layout = NULL;
720 if (!(in_line.layout = psiconv_clone_character_layout 721 if (!(in_line.layout = psiconv_clone_character_layout
721 (para->base_character))) 722 (para->base_character)))
722 goto ERROR4; 723 goto ERROR4;
723 psiconv_progress(lev+4,off+len,"Going to read the element type"); 724 psiconv_progress(lev+4,off+len,"Going to read the element type");
724 temp = psiconv_read_u8(buf,lev+4,len+off,&res); 725 temp = psiconv_read_u8(buf,lev+4,len+off,&res);
725 if (res) 726 if (res)
726 goto ERROR4; 727 goto ERROR5;
727 len += 1; 728 len += 1;
728 psiconv_debug(lev+4,off+len,"Type: %02x",temp); 729 psiconv_debug(lev+4,off+len,"Type: %02x",temp);
729 psiconv_progress(lev+4,off+len, 730 psiconv_progress(lev+4,off+len,
730 "Going to read the number of characters it applies to"); 731 "Going to read the number of characters it applies to");
731 in_line.length = psiconv_read_u32(buf,lev+4,len+off,&res); 732 in_line.length = psiconv_read_u32(buf,lev+4,len+off,&res);
732 if (res) 733 if (res)
733 goto ERROR4; 734 goto ERROR5;
734 psiconv_debug(lev+4,off+len,"Length: %02x",in_line.length); 735 psiconv_debug(lev+4,off+len,"Length: %02x",in_line.length);
735 len += 4; 736 len += 4;
736 psiconv_progress(lev+4,off+len,"Going to read the character layout"); 737 psiconv_progress(lev+4,off+len,"Going to read the character layout");
737 if ((res = psiconv_parse_character_layout_list(buf,lev+4,off+len,&leng, 738 if ((res = psiconv_parse_character_layout_list(buf,lev+4,off+len,&leng,
738 in_line.layout))) 739 in_line.layout)))
739 goto ERROR4; 740 goto ERROR5;
740 len += leng; 741 len += leng;
741 742
742 if (temp == 0x01) { 743 if (temp == 0x01) {
743 psiconv_debug(lev+4,off+len,"Skipping object data"); 744 psiconv_debug(lev+4,off+len,"Found an embedded object");
744 len += 0x10; 745 psiconv_progress(lev+4,off+len,"Going to read the object marker "
746 "(0x%08x expected)",PSICONV_ID_OBJECT);
747 temp = psiconv_read_u32(buf,lev+4,off+len,&res);
748 if (res)
749 goto ERROR5;
750 if (temp != PSICONV_ID_OBJECT) {
751 psiconv_warn(lev+4,off+len,"Unknown id marks embedded object");
752 psiconv_debug(lev+4,off+len,"Marker: read %08x, expected %08x",
753 temp,PSICONV_ID_OBJECT);
754 }
755 len += 4;
756 psiconv_progress(lev+4,off+len,
757 "Going to read the Embedded Object Section offset");
758 temp = psiconv_read_u32(buf,lev+4,off+len,&res);
759 if (res)
760 goto ERROR5;
761 psiconv_debug(lev+4,off+len, "Offset: %08x",temp);
762 len += 4;
763 psiconv_progress(lev+4,off+len,
764 "Going to parse the Embedded Object");
765 if ((res = psiconv_parse_embedded_object(buf,lev+4,temp,
766 NULL,&(in_line.object))))
767 goto ERROR5;
768 psiconv_progress(lev+4,off+len,
769 "Going to read the object width");
770 in_line.object_width = psiconv_read_length(buf,lev+4,off+len,
771 &leng,&res);
772 if (res)
773 goto ERROR5;
774 psiconv_debug(lev+4,off+len,"Object width: %f cm",
775 in_line.object_width);
776 len += leng;
777 psiconv_progress(lev+4,off+len,
778 "Going to read the object height");
779 in_line.object_height = psiconv_read_length(buf,lev+4,off+len,&leng,
780 &res);
781 if (res)
782 goto ERROR5;
783 psiconv_debug(lev+4,off+len,"Object height: %f cm",
784 in_line.object_height);
785 len += leng;
745 } else if (temp != 0x00) { 786 } else if (temp != 0x00) {
746 psiconv_warn(lev+4,off+len,"Layout section unknown inline type"); 787 psiconv_warn(lev+4,off+len,"Layout section unknown inline type");
747 } 788 }
748 if (line_length + in_line.length > strlen(para->text)) { 789 if (line_length + in_line.length > strlen(para->text)) {
749 psiconv_warn(lev+4,off+len, 790 psiconv_warn(lev+4,off+len,
751 res = -1; 792 res = -1;
752 in_line.length = strlen(para->text) - line_length; 793 in_line.length = strlen(para->text) - line_length;
753 } 794 }
754 line_length += in_line.length; 795 line_length += in_line.length;
755 if ((res = psiconv_list_add(para->in_lines,&in_line))) 796 if ((res = psiconv_list_add(para->in_lines,&in_line)))
756 goto ERROR4; 797 goto ERROR5;
757 } 798 }
758 } 799 }
759 } 800 }
760 801
761 if (total != nr) { 802 if (total != nr) {
797 psiconv_free_character_layout(anon.character); 838 psiconv_free_character_layout(anon.character);
798ERROR3_1: 839ERROR3_1:
799 psiconv_free_paragraph_layout(anon.paragraph); 840 psiconv_free_paragraph_layout(anon.paragraph);
800 goto ERROR3; 841 goto ERROR3;
801 842
843ERROR5:
844 if (in_line.layout)
845 psiconv_free_character_layout(in_line.layout);
846 if (in_line.object)
847 psiconv_free_object(in_line.object);
802ERROR4: 848ERROR4:
803 free(inline_count); 849 free(inline_count);
804ERROR3: 850ERROR3:
805 for (i = 0; i < psiconv_list_length(anon_styles); i++) { 851 for (i = 0; i < psiconv_list_length(anon_styles); i++) {
806 if (!(anon_ptr = psiconv_list_get(anon_styles,i))) { 852 if (!(anon_ptr = psiconv_list_get(anon_styles,i))) {
883 return -PSICONV_E_NOMEM; 929 return -PSICONV_E_NOMEM;
884 else 930 else
885 return res; 931 return res;
886} 932}
887 933
934int psiconv_parse_embedded_object(const psiconv_buffer buf, int lev,
935 psiconv_u32 off, int *length,
936 psiconv_object *result)
937{
938 int res=0;
939 int len=0;
940 int leng,i;
941 psiconv_section_table_section table;
942 psiconv_section_table_entry entry;
943 psiconv_u32 icon_sec,display_sec,table_sec;
944
945 psiconv_progress(lev+1,off+len,"Going to read an Embedded Object");
946 if (!(*result = malloc(sizeof(**result))))
947 goto ERROR1;
948
949 psiconv_progress(lev+2,off+len,"Going to read the Embedded Object Section");
950 psiconv_parse_section_table_section(buf,lev+2,off+len,&leng,&table);
951 len += leng;
952
953 for (i = 0; i < psiconv_list_length(table); i++) {
954 psiconv_progress(lev+2,off+len,"Going to read entry %d",i);
955 if (!(entry = psiconv_list_get(table,i)))
956 goto ERROR2;
957 if (entry->id == PSICONV_ID_OBJECT_DISPLAY_SECTION) {
958 display_sec = entry->offset;
959 psiconv_debug(lev+3,off+len,"Found the Object Display Section at %08x",
960 display_sec);
961 } else if (entry->id == PSICONV_ID_OBJECT_ICON_SECTION) {
962 icon_sec = entry->offset;
963 psiconv_debug(lev+3,off+len,"Found the Object Icon Section at %08x",
964 icon_sec);
965 } else if (entry->id == PSICONV_ID_OBJECT_SECTION_TABLE_SECTION) {
966 table_sec = entry->offset;
967 psiconv_debug(lev+3,off+len,"Found the Object Section Table Section at %08x",
968 table_sec);
969 } else {
970 psiconv_warn(lev+3,off+len,
971 "Found unknown section in the Object Display Section "
972 "(ignoring)");
973 psiconv_debug(lev+3,off+len,"Section ID %08x, offset %08x",
974 entry->id, entry->offset);
975 }
976 }
977
978 psiconv_progress(lev+1,off+len-1,"End of Embedded Object Section "
979 "(total length: %08x)",len);
980 return res;
981
982
983ERROR2:
984 psiconv_free_section_table_section(table);
985ERROR1:
986 psiconv_warn(lev+1,off,"Reading Embedded Object failed");
987 if (length)
988 *length = 0;
989 if (res == 0)
990 return -PSICONV_E_NOMEM;
991 else
992 return res;
993}

Legend:
Removed from v.159  
changed lines
  Added in v.160

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