… | |
… | |
34 | int lev,psiconv_u32 off, |
34 | int lev,psiconv_u32 off, |
35 | int *length, |
35 | int *length, |
36 | psiconv_text_and_layout result, |
36 | psiconv_text_and_layout result, |
37 | psiconv_word_styles_section styles, |
37 | psiconv_word_styles_section styles, |
38 | int with_styles); |
38 | int with_styles); |
|
|
39 | static psiconv_file_type_t psiconv_determine_embedded_object_type |
|
|
40 | (const psiconv_buffer buf,int lev, |
|
|
41 | int *status); |
39 | |
42 | |
40 | int psiconv_parse_header_section(const psiconv_buffer buf,int lev, |
43 | int psiconv_parse_header_section(const psiconv_buffer buf,int lev, |
41 | psiconv_u32 off, int *length, |
44 | psiconv_u32 off, int *length, |
42 | psiconv_header_section *result) |
45 | psiconv_header_section *result) |
43 | { |
46 | { |
… | |
… | |
714 | psiconv_warn(lev+3,off+len, |
717 | psiconv_warn(lev+3,off+len, |
715 | "Layout section inlines: not enough element"); |
718 | "Layout section inlines: not enough element"); |
716 | psiconv_debug(lev+3,off+len,"Can't read element!"); |
719 | psiconv_debug(lev+3,off+len,"Can't read element!"); |
717 | } else { |
720 | } else { |
718 | total ++; |
721 | total ++; |
|
|
722 | in_line.object = NULL; |
|
|
723 | in_line.layout = NULL; |
719 | if (!(in_line.layout = psiconv_clone_character_layout |
724 | if (!(in_line.layout = psiconv_clone_character_layout |
720 | (para->base_character))) |
725 | (para->base_character))) |
721 | goto ERROR4; |
726 | goto ERROR4; |
722 | psiconv_progress(lev+4,off+len,"Going to read the element type"); |
727 | psiconv_progress(lev+4,off+len,"Going to read the element type"); |
723 | temp = psiconv_read_u8(buf,lev+4,len+off,&res); |
728 | temp = psiconv_read_u8(buf,lev+4,len+off,&res); |
724 | if (res) |
729 | if (res) |
725 | goto ERROR4; |
730 | goto ERROR5; |
726 | len += 1; |
731 | len += 1; |
727 | psiconv_debug(lev+4,off+len,"Type: %02x",temp); |
732 | psiconv_debug(lev+4,off+len,"Type: %02x",temp); |
728 | psiconv_progress(lev+4,off+len, |
733 | psiconv_progress(lev+4,off+len, |
729 | "Going to read the number of characters it applies to"); |
734 | "Going to read the number of characters it applies to"); |
730 | in_line.length = psiconv_read_u32(buf,lev+4,len+off,&res); |
735 | in_line.length = psiconv_read_u32(buf,lev+4,len+off,&res); |
731 | if (res) |
736 | if (res) |
732 | goto ERROR4; |
737 | goto ERROR5; |
733 | psiconv_debug(lev+4,off+len,"Length: %02x",in_line.length); |
738 | psiconv_debug(lev+4,off+len,"Length: %02x",in_line.length); |
734 | len += 4; |
739 | len += 4; |
735 | psiconv_progress(lev+4,off+len,"Going to read the character layout"); |
740 | psiconv_progress(lev+4,off+len,"Going to read the character layout"); |
736 | if ((res = psiconv_parse_character_layout_list(buf,lev+4,off+len,&leng, |
741 | if ((res = psiconv_parse_character_layout_list(buf,lev+4,off+len,&leng, |
737 | in_line.layout))) |
742 | in_line.layout))) |
738 | goto ERROR4; |
743 | goto ERROR5; |
739 | len += leng; |
744 | len += leng; |
740 | |
745 | |
741 | if (temp == 0x01) { |
746 | if (temp == 0x01) { |
742 | psiconv_debug(lev+4,off+len,"Skipping object data"); |
747 | psiconv_debug(lev+4,off+len,"Found an embedded object"); |
743 | len += 0x10; |
748 | psiconv_progress(lev+4,off+len,"Going to read the object marker " |
|
|
749 | "(0x%08x expected)",PSICONV_ID_OBJECT); |
|
|
750 | temp = psiconv_read_u32(buf,lev+4,off+len,&res); |
|
|
751 | if (res) |
|
|
752 | goto ERROR5; |
|
|
753 | if (temp != PSICONV_ID_OBJECT) { |
|
|
754 | psiconv_warn(lev+4,off+len,"Unknown id marks embedded object"); |
|
|
755 | psiconv_debug(lev+4,off+len,"Marker: read %08x, expected %08x", |
|
|
756 | temp,PSICONV_ID_OBJECT); |
|
|
757 | } |
|
|
758 | len += 4; |
|
|
759 | psiconv_progress(lev+4,off+len, |
|
|
760 | "Going to read the Embedded Object Section offset"); |
|
|
761 | temp = psiconv_read_u32(buf,lev+4,off+len,&res); |
|
|
762 | if (res) |
|
|
763 | goto ERROR5; |
|
|
764 | psiconv_debug(lev+4,off+len, "Offset: %08x",temp); |
|
|
765 | len += 4; |
|
|
766 | psiconv_progress(lev+4,off+len, |
|
|
767 | "Going to parse the Embedded Object"); |
|
|
768 | if ((res = psiconv_parse_embedded_object(buf,lev+4,temp, |
|
|
769 | NULL,&(in_line.object)))) |
|
|
770 | goto ERROR5; |
|
|
771 | psiconv_progress(lev+4,off+len, |
|
|
772 | "Going to read the object width"); |
|
|
773 | in_line.object_width = psiconv_read_length(buf,lev+4,off+len, |
|
|
774 | &leng,&res); |
|
|
775 | if (res) |
|
|
776 | goto ERROR5; |
|
|
777 | psiconv_debug(lev+4,off+len,"Object width: %f cm", |
|
|
778 | in_line.object_width); |
|
|
779 | len += leng; |
|
|
780 | psiconv_progress(lev+4,off+len, |
|
|
781 | "Going to read the object height"); |
|
|
782 | in_line.object_height = psiconv_read_length(buf,lev+4,off+len,&leng, |
|
|
783 | &res); |
|
|
784 | if (res) |
|
|
785 | goto ERROR5; |
|
|
786 | psiconv_debug(lev+4,off+len,"Object height: %f cm", |
|
|
787 | in_line.object_height); |
|
|
788 | len += leng; |
744 | } else if (temp != 0x00) { |
789 | } else if (temp != 0x00) { |
745 | psiconv_warn(lev+4,off+len,"Layout section unknown inline type"); |
790 | psiconv_warn(lev+4,off+len,"Layout section unknown inline type"); |
746 | } |
791 | } |
747 | if (line_length + in_line.length > strlen(para->text)) { |
792 | if (line_length + in_line.length > strlen(para->text)) { |
748 | psiconv_warn(lev+4,off+len, |
793 | psiconv_warn(lev+4,off+len, |
… | |
… | |
750 | res = -1; |
795 | res = -1; |
751 | in_line.length = strlen(para->text) - line_length; |
796 | in_line.length = strlen(para->text) - line_length; |
752 | } |
797 | } |
753 | line_length += in_line.length; |
798 | line_length += in_line.length; |
754 | if ((res = psiconv_list_add(para->in_lines,&in_line))) |
799 | if ((res = psiconv_list_add(para->in_lines,&in_line))) |
755 | goto ERROR4; |
800 | goto ERROR5; |
756 | } |
801 | } |
757 | } |
802 | } |
758 | } |
803 | } |
759 | |
804 | |
760 | if (total != nr) { |
805 | if (total != nr) { |
… | |
… | |
796 | psiconv_free_character_layout(anon.character); |
841 | psiconv_free_character_layout(anon.character); |
797 | ERROR3_1: |
842 | ERROR3_1: |
798 | psiconv_free_paragraph_layout(anon.paragraph); |
843 | psiconv_free_paragraph_layout(anon.paragraph); |
799 | goto ERROR3; |
844 | goto ERROR3; |
800 | |
845 | |
|
|
846 | ERROR5: |
|
|
847 | if (in_line.layout) |
|
|
848 | psiconv_free_character_layout(in_line.layout); |
|
|
849 | if (in_line.object) |
|
|
850 | psiconv_free_object(in_line.object); |
801 | ERROR4: |
851 | ERROR4: |
802 | free(inline_count); |
852 | free(inline_count); |
803 | ERROR3: |
853 | ERROR3: |
804 | for (i = 0; i < psiconv_list_length(anon_styles); i++) { |
854 | for (i = 0; i < psiconv_list_length(anon_styles); i++) { |
805 | if (!(anon_ptr = psiconv_list_get(anon_styles,i))) { |
855 | if (!(anon_ptr = psiconv_list_get(anon_styles,i))) { |
… | |
… | |
882 | return -PSICONV_E_NOMEM; |
932 | return -PSICONV_E_NOMEM; |
883 | else |
933 | else |
884 | return res; |
934 | return res; |
885 | } |
935 | } |
886 | |
936 | |
|
|
937 | int psiconv_parse_embedded_object(const psiconv_buffer buf, int lev, |
|
|
938 | psiconv_u32 off, int *length, |
|
|
939 | psiconv_object *result) |
|
|
940 | { |
|
|
941 | int res=0; |
|
|
942 | int len=0; |
|
|
943 | int leng,i; |
|
|
944 | psiconv_section_table_section table; |
|
|
945 | psiconv_section_table_entry entry; |
|
|
946 | psiconv_u32 icon_sec=0,display_sec=0,table_sec=0; |
|
|
947 | psiconv_buffer subbuf; |
|
|
948 | |
|
|
949 | psiconv_progress(lev+1,off+len,"Going to read an Embedded Object"); |
|
|
950 | if (!(*result = malloc(sizeof(**result)))) |
|
|
951 | goto ERROR1; |
|
|
952 | |
|
|
953 | psiconv_progress(lev+2,off+len,"Going to read the Embedded Object Section"); |
|
|
954 | psiconv_parse_section_table_section(buf,lev+2,off+len,&leng,&table); |
|
|
955 | len += leng; |
|
|
956 | |
|
|
957 | for (i = 0; i < psiconv_list_length(table); i++) { |
|
|
958 | psiconv_progress(lev+2,off+len,"Going to read entry %d",i); |
|
|
959 | if (!(entry = psiconv_list_get(table,i))) |
|
|
960 | goto ERROR2; |
|
|
961 | if (entry->id == PSICONV_ID_OBJECT_DISPLAY_SECTION) { |
|
|
962 | display_sec = entry->offset; |
|
|
963 | psiconv_debug(lev+3,off+len,"Found the Object Display Section at %08x", |
|
|
964 | display_sec); |
|
|
965 | } else if (entry->id == PSICONV_ID_OBJECT_ICON_SECTION) { |
|
|
966 | icon_sec = entry->offset; |
|
|
967 | psiconv_debug(lev+3,off+len,"Found the Object Icon Section at %08x", |
|
|
968 | icon_sec); |
|
|
969 | } else if (entry->id == PSICONV_ID_OBJECT_SECTION_TABLE_SECTION) { |
|
|
970 | table_sec = entry->offset; |
|
|
971 | psiconv_debug(lev+3,off+len,"Found the Object Section Table Section at %08x", |
|
|
972 | table_sec); |
|
|
973 | } else { |
|
|
974 | psiconv_warn(lev+3,off+len, |
|
|
975 | "Found unknown section in the Object Display Section " |
|
|
976 | "(ignoring)"); |
|
|
977 | psiconv_debug(lev+3,off+len,"Section ID %08x, offset %08x", |
|
|
978 | entry->id, entry->offset); |
|
|
979 | } |
|
|
980 | } |
|
|
981 | |
|
|
982 | psiconv_progress(lev+2,off+len,"Looking for the Object Display Section"); |
|
|
983 | if (!icon_sec) { |
|
|
984 | psiconv_warn(lev+2,off+len,"Object Display Section not found"); |
|
|
985 | (*result)->display = NULL; |
|
|
986 | } else { |
|
|
987 | psiconv_debug(lev+2,off+len,"Object Display Section at offset %08x", |
|
|
988 | display_sec); |
|
|
989 | if ((res = psiconv_parse_object_display_section(buf,lev+2,display_sec,NULL, |
|
|
990 | &(*result)->display))) |
|
|
991 | goto ERROR2; |
|
|
992 | } |
|
|
993 | |
|
|
994 | psiconv_progress(lev+2,off+len,"Looking for the Object Icon Section"); |
|
|
995 | if (!icon_sec) { |
|
|
996 | psiconv_warn(lev+2,off+len,"Object Icon Section not found"); |
|
|
997 | (*result)->icon = NULL; |
|
|
998 | } else { |
|
|
999 | psiconv_debug(lev+2,off+len,"Object Icon Section at offset %08x",icon_sec); |
|
|
1000 | if ((res = psiconv_parse_object_icon_section(buf,lev+2,icon_sec,NULL, |
|
|
1001 | &(*result)->icon))) |
|
|
1002 | goto ERROR3; |
|
|
1003 | } |
|
|
1004 | |
|
|
1005 | psiconv_progress(lev+2,off+len, |
|
|
1006 | "Looking for the Section Table Offset Section"); |
|
|
1007 | if (!table_sec) { |
|
|
1008 | psiconv_warn(lev+2,off+len, |
|
|
1009 | "Embedded Section Table Offset Section not found"); |
|
|
1010 | (*result)->object = NULL; |
|
|
1011 | } else { |
|
|
1012 | psiconv_progress(lev+2,off+len, |
|
|
1013 | "Extracting object: add %08x to all following offsets", |
|
|
1014 | table_sec); |
|
|
1015 | /* We can't determine the length of the object, so we just take it all */ |
|
|
1016 | if ((res = psiconv_buffer_subbuffer(&subbuf,buf,table_sec, |
|
|
1017 | psiconv_buffer_length(buf)-table_sec))) |
|
|
1018 | goto ERROR4; |
|
|
1019 | |
|
|
1020 | if (!((*result)->object = malloc(sizeof(*(*result)->object)))) |
|
|
1021 | goto ERROR5; |
|
|
1022 | |
|
|
1023 | /* We need to find the file type, but we don't have a normal header */ |
|
|
1024 | /* So we try to find the Application ID Section and hope for the best */ |
|
|
1025 | psiconv_progress(lev+3,0,"Trying to determine the file type"); |
|
|
1026 | (*result)->object->type = psiconv_determine_embedded_object_type |
|
|
1027 | (subbuf,lev+3,&res); |
|
|
1028 | switch ((*result)->object->type) { |
|
|
1029 | case psiconv_word_file: |
|
|
1030 | if ((res = psiconv_parse_word_file(subbuf,lev+3,0, |
|
|
1031 | ((psiconv_word_f *) &(*result)->object->file)))) |
|
|
1032 | goto ERROR6; |
|
|
1033 | break; |
|
|
1034 | case psiconv_texted_file: |
|
|
1035 | if ((res = psiconv_parse_texted_file(subbuf,lev+3,0, |
|
|
1036 | ((psiconv_texted_f *) &(*result)->object->file)))) |
|
|
1037 | goto ERROR6; |
|
|
1038 | break; |
|
|
1039 | case psiconv_sheet_file: |
|
|
1040 | if ((res = psiconv_parse_sheet_file(subbuf,lev+3,0, |
|
|
1041 | ((psiconv_sheet_f *) &(*result)->object->file)))) |
|
|
1042 | goto ERROR6; |
|
|
1043 | break; |
|
|
1044 | case psiconv_sketch_file: |
|
|
1045 | if ((res = psiconv_parse_sketch_file(subbuf,lev+3,0, |
|
|
1046 | ((psiconv_sketch_f *) &(*result)->object->file)))) |
|
|
1047 | goto ERROR6; |
|
|
1048 | break; |
|
|
1049 | default: |
|
|
1050 | psiconv_warn(lev+3,0,"Can't parse embedded object (still continuing)"); |
|
|
1051 | (*result)->object->file = NULL; |
|
|
1052 | } |
|
|
1053 | } |
|
|
1054 | |
|
|
1055 | if (length) |
|
|
1056 | *length = len; |
|
|
1057 | |
|
|
1058 | psiconv_progress(lev+1,off+len-1,"End of Embedded Object Section " |
|
|
1059 | "(total length: %08x)",len); |
|
|
1060 | |
|
|
1061 | return res; |
|
|
1062 | |
|
|
1063 | |
|
|
1064 | ERROR6: |
|
|
1065 | free((*result)->object); |
|
|
1066 | ERROR5: |
|
|
1067 | psiconv_buffer_free(subbuf); |
|
|
1068 | ERROR4: |
|
|
1069 | psiconv_free_object_icon_section((*result)->icon); |
|
|
1070 | ERROR3: |
|
|
1071 | psiconv_free_object_display_section((*result)->display); |
|
|
1072 | ERROR2: |
|
|
1073 | psiconv_free_section_table_section(table); |
|
|
1074 | ERROR1: |
|
|
1075 | psiconv_warn(lev+1,off,"Reading Embedded Object failed"); |
|
|
1076 | |
|
|
1077 | if (length) |
|
|
1078 | *length = 0; |
|
|
1079 | |
|
|
1080 | if (res == 0) |
|
|
1081 | return -PSICONV_E_NOMEM; |
|
|
1082 | else |
|
|
1083 | return res; |
|
|
1084 | } |
|
|
1085 | |
|
|
1086 | psiconv_file_type_t psiconv_determine_embedded_object_type |
|
|
1087 | (const psiconv_buffer buf,int lev, |
|
|
1088 | int *status) |
|
|
1089 | { |
|
|
1090 | psiconv_u32 off; |
|
|
1091 | psiconv_section_table_section table; |
|
|
1092 | int res,i; |
|
|
1093 | psiconv_file_type_t file_type = psiconv_unknown_file; |
|
|
1094 | psiconv_section_table_entry entry; |
|
|
1095 | psiconv_application_id_section applid; |
|
|
1096 | |
|
|
1097 | psiconv_progress(lev+1,0,"Going to determine embedded object file type"); |
|
|
1098 | psiconv_progress(lev+2,0,"Going to read the Section Table Offset Section"); |
|
|
1099 | off = psiconv_read_u32(buf,lev,0,&res); |
|
|
1100 | if (res) |
|
|
1101 | goto ERROR1; |
|
|
1102 | psiconv_debug(lev+2,0,"Offset: %08x",off); |
|
|
1103 | |
|
|
1104 | psiconv_progress(lev+2,off,"Going to read the Section Table Section"); |
|
|
1105 | if ((res = psiconv_parse_section_table_section(buf,lev+2,off,NULL,&table))) |
|
|
1106 | goto ERROR1; |
|
|
1107 | |
|
|
1108 | psiconv_progress(lev+2,off,"Going to search the Section Table Section " |
|
|
1109 | "for the Application ID Section"); |
|
|
1110 | for (i=0; i < psiconv_list_length(table); i++) { |
|
|
1111 | psiconv_progress(lev+3,off,"Going to read entry %d",i); |
|
|
1112 | if (!(entry = psiconv_list_get(table,i))) |
|
|
1113 | goto ERROR2; |
|
|
1114 | if (entry->id == PSICONV_ID_APPL_ID_SECTION) { |
|
|
1115 | psiconv_progress(lev+3,off, |
|
|
1116 | "Found the Application ID Section at offset %08x", |
|
|
1117 | entry->offset); |
|
|
1118 | off = entry->offset; |
|
|
1119 | break; |
|
|
1120 | } |
|
|
1121 | } |
|
|
1122 | if (i == psiconv_list_length(table)) { |
|
|
1123 | psiconv_warn(lev+2,off,"No Application ID Section found"); |
|
|
1124 | res = PSICONV_E_PARSE; |
|
|
1125 | goto ERROR2; |
|
|
1126 | } |
|
|
1127 | |
|
|
1128 | psiconv_progress(lev+2,off,"Going to read the Application ID Section"); |
|
|
1129 | if ((res = psiconv_parse_application_id_section(buf,lev+2,off,NULL,&applid))) |
|
|
1130 | goto ERROR2; |
|
|
1131 | |
|
|
1132 | switch (applid->id) { |
|
|
1133 | case PSICONV_ID_WORD: file_type = psiconv_word_file; |
|
|
1134 | psiconv_debug(lev+2,off,"Found a Word file"); |
|
|
1135 | break; |
|
|
1136 | case PSICONV_ID_TEXTED: file_type = psiconv_texted_file; |
|
|
1137 | psiconv_debug(lev+2,off,"Found a TextEd file"); |
|
|
1138 | break; |
|
|
1139 | case PSICONV_ID_SKETCH: file_type = psiconv_sketch_file; |
|
|
1140 | psiconv_debug(lev+2,off,"Found a Sketch file"); |
|
|
1141 | break; |
|
|
1142 | case PSICONV_ID_SHEET: file_type = psiconv_sheet_file; |
|
|
1143 | psiconv_debug(lev+2,off,"Found a Sheet file"); |
|
|
1144 | break; |
|
|
1145 | default: psiconv_warn(lev+2,off,"Found an unknown file type"); |
|
|
1146 | psiconv_debug(lev+2,off,"Found ID %08x",applid->id); |
|
|
1147 | } |
|
|
1148 | |
|
|
1149 | ERROR2: |
|
|
1150 | psiconv_free_application_id_section(applid); |
|
|
1151 | ERROR1: |
|
|
1152 | psiconv_free_section_table_section(table); |
|
|
1153 | if (status) |
|
|
1154 | *status = res; |
|
|
1155 | return file_type; |
|
|
1156 | |
|
|
1157 | } |
|
|
1158 | |
|
|
1159 | int psiconv_parse_object_display_section(const psiconv_buffer buf,int lev, |
|
|
1160 | psiconv_u32 off, int *length, |
|
|
1161 | psiconv_object_display_section *result) |
|
|
1162 | { |
|
|
1163 | int res = 0; |
|
|
1164 | int len = 0; |
|
|
1165 | int leng; |
|
|
1166 | psiconv_u32 temp; |
|
|
1167 | |
|
|
1168 | psiconv_progress(lev+1,off,"Going to read the Object Display Section"); |
|
|
1169 | if (!(*result = malloc(sizeof(**result)))) |
|
|
1170 | goto ERROR1; |
|
|
1171 | |
|
|
1172 | psiconv_progress(lev+2,off+len,"Going to read the display as icon flag " |
|
|
1173 | "(expecting 0x00 or 0x01)"); |
|
|
1174 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
|
|
1175 | if (res) |
|
|
1176 | goto ERROR2; |
|
|
1177 | if (temp == 0x00) { |
|
|
1178 | (*result)->show_icon = psiconv_bool_true; |
|
|
1179 | psiconv_debug(lev+2,off+len,"Displayed as icon"); |
|
|
1180 | } else if (temp == 0x01) { |
|
|
1181 | (*result)->show_icon = psiconv_bool_false; |
|
|
1182 | psiconv_debug(lev+2,off+len,"Displayed as full document"); |
|
|
1183 | } else { |
|
|
1184 | psiconv_warn(lev+2,off+len,"Unknown Object Display Section Icon Flag"); |
|
|
1185 | psiconv_debug(lev+2,off+len,"Icon flag found: %02x",temp); |
|
|
1186 | /* Improvise */ |
|
|
1187 | (*result)->show_icon = (temp & 0x01?psiconv_bool_false:psiconv_bool_true); |
|
|
1188 | } |
|
|
1189 | len ++; |
|
|
1190 | |
|
|
1191 | psiconv_progress(lev+2,off+len,"Going to read the display width"); |
|
|
1192 | (*result)->width = psiconv_read_length(buf,lev+2,off+len,&leng,&res); |
|
|
1193 | if (res) |
|
|
1194 | goto ERROR2; |
|
|
1195 | psiconv_debug(lev+2,off+len,"Display width: %f cm",(*result)->width); |
|
|
1196 | len += leng; |
|
|
1197 | |
|
|
1198 | psiconv_progress(lev+2,off+len,"Going to read the display height"); |
|
|
1199 | (*result)->height = psiconv_read_length(buf,lev+2,off+len,&leng,&res); |
|
|
1200 | if (res) |
|
|
1201 | goto ERROR2; |
|
|
1202 | psiconv_debug(lev+2,off+len,"Display length: %f cm",(*result)->height); |
|
|
1203 | len += leng; |
|
|
1204 | |
|
|
1205 | psiconv_progress(lev+2,off+len,"Going to read unknown long (%08x expected)", |
|
|
1206 | 0); |
|
|
1207 | temp = psiconv_read_u32(buf,lev+2,off+len,&res); |
|
|
1208 | if (temp != 0) { |
|
|
1209 | psiconv_warn(lev+2,off+len,"Unknown Object Display Section final long"); |
|
|
1210 | psiconv_debug(lev+2,off+len,"Long read: %08x",temp); |
|
|
1211 | } |
|
|
1212 | len += 4; |
|
|
1213 | |
|
|
1214 | if (length) |
|
|
1215 | *length = len; |
|
|
1216 | |
|
|
1217 | psiconv_progress(lev+1,off+len-1,"End of Object Display Section " |
|
|
1218 | "(total length: %08x",len); |
|
|
1219 | return res; |
|
|
1220 | |
|
|
1221 | ERROR2: |
|
|
1222 | free(*result); |
|
|
1223 | ERROR1: |
|
|
1224 | psiconv_warn(lev+1,off+len,"Reading of Object Display Section failed"); |
|
|
1225 | if (length) |
|
|
1226 | *length=0; |
|
|
1227 | if (!res) |
|
|
1228 | return -PSICONV_E_NOMEM; |
|
|
1229 | else |
|
|
1230 | return res; |
|
|
1231 | } |
|
|
1232 | |
|
|
1233 | int psiconv_parse_object_icon_section(const psiconv_buffer buf,int lev, |
|
|
1234 | psiconv_u32 off, int *length, |
|
|
1235 | psiconv_object_icon_section *result) |
|
|
1236 | { |
|
|
1237 | int res = 0; |
|
|
1238 | int len = 0; |
|
|
1239 | int leng; |
|
|
1240 | |
|
|
1241 | psiconv_progress(lev+1,off,"Going to read the Object Icon Section"); |
|
|
1242 | if (!(*result = malloc(sizeof(**result)))) |
|
|
1243 | goto ERROR1; |
|
|
1244 | |
|
|
1245 | psiconv_progress(lev+2,off+len,"Going to read the icon name"); |
|
|
1246 | (*result)->icon_name = psiconv_read_string(buf,lev+2,off+len,&leng,&res); |
|
|
1247 | if (res) |
|
|
1248 | goto ERROR2; |
|
|
1249 | psiconv_debug(lev+2,off+len,"Icon name: %s",(*result)->icon_name); |
|
|
1250 | len += leng; |
|
|
1251 | |
|
|
1252 | psiconv_progress(lev+2,off+len,"Going to read the icon width"); |
|
|
1253 | (*result)->icon_width = psiconv_read_length(buf,lev+2,off+len,&leng,&res); |
|
|
1254 | if (res) |
|
|
1255 | goto ERROR3; |
|
|
1256 | psiconv_debug(lev+2,off+len,"Icon width: %f cm",(*result)->icon_width); |
|
|
1257 | len += leng; |
|
|
1258 | |
|
|
1259 | psiconv_progress(lev+2,off+len,"Going to read the icon height"); |
|
|
1260 | (*result)->icon_height = psiconv_read_length(buf,lev+2,off+len,&leng,&res); |
|
|
1261 | if (res) |
|
|
1262 | goto ERROR3; |
|
|
1263 | psiconv_debug(lev+2,off+len,"Icon length: %f cm",(*result)->icon_height); |
|
|
1264 | len += leng; |
|
|
1265 | |
|
|
1266 | if (length) |
|
|
1267 | *length = len; |
|
|
1268 | |
|
|
1269 | psiconv_progress(lev+1,off+len-1,"End of Object Icon Section" |
|
|
1270 | "(total length: %08x",len); |
|
|
1271 | return res; |
|
|
1272 | |
|
|
1273 | ERROR3: |
|
|
1274 | free((*result)->icon_name); |
|
|
1275 | ERROR2: |
|
|
1276 | free(*result); |
|
|
1277 | ERROR1: |
|
|
1278 | psiconv_warn(lev+1,off+len,"Reading of Object Icon Section failed"); |
|
|
1279 | if (length) |
|
|
1280 | *length=0; |
|
|
1281 | if (!res) |
|
|
1282 | return -PSICONV_E_NOMEM; |
|
|
1283 | else |
|
|
1284 | return res; |
|
|
1285 | } |