/[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 64 Revision 142
20#include "config.h" 20#include "config.h"
21#include "compat.h" 21#include "compat.h"
22#include <stdlib.h> 22#include <stdlib.h>
23#include <string.h> 23#include <string.h>
24 24
25#include "data.h"
26#include "parse_routines.h" 25#include "parse_routines.h"
26#include "error.h"
27
28#ifdef DMALLOC
29#include <dmalloc.h>
30#endif
31
27 32
28static int psiconv_parse_layout_section(const psiconv_buffer buf, 33static int psiconv_parse_layout_section(const psiconv_buffer buf,
29 int lev,psiconv_u32 off, 34 int lev,psiconv_u32 off,
30 int *length, 35 int *length,
31 psiconv_text_and_layout result, 36 psiconv_text_and_layout result,
44 if (!((*result) = malloc(sizeof(**result)))) 49 if (!((*result) = malloc(sizeof(**result))))
45 goto ERROR1; 50 goto ERROR1;
46 51
47 psiconv_progress(lev+2,off+len,"Going to read UID1 to UID3"); 52 psiconv_progress(lev+2,off+len,"Going to read UID1 to UID3");
48 (*result)->uid1 = psiconv_read_u32(buf,lev+2,off+len,&res); 53 (*result)->uid1 = psiconv_read_u32(buf,lev+2,off+len,&res);
49 if (!res) 54 if (res)
50 goto ERROR2; 55 goto ERROR2;
51 psiconv_debug(lev+2,off+len,"UID1: %08x",(*result)->uid1); 56 psiconv_debug(lev+2,off+len,"UID1: %08x",(*result)->uid1);
52 if ((*result)->uid1 == PSICONV_ID_CLIPART) { 57 if ((*result)->uid1 == PSICONV_ID_CLIPART) {
53 /* That's all folks... */ 58 /* That's all folks... */
54 (*result)->file = psiconv_clipart_file; 59 (*result)->file = psiconv_clipart_file;
87 (*result)->file = psiconv_texted_file; 92 (*result)->file = psiconv_texted_file;
88 psiconv_debug(lev+2,off+len,"File is a TextEd file"); 93 psiconv_debug(lev+2,off+len,"File is a TextEd file");
89 } else if ((*result)->uid3 == PSICONV_ID_SKETCH) { 94 } else if ((*result)->uid3 == PSICONV_ID_SKETCH) {
90 (*result)->file = psiconv_sketch_file; 95 (*result)->file = psiconv_sketch_file;
91 psiconv_debug(lev+2,off+len,"File is a Sketch file"); 96 psiconv_debug(lev+2,off+len,"File is a Sketch file");
97 } else if ((*result)->uid3 == PSICONV_ID_SHEET) {
98 (*result)->file = psiconv_sheet_file;
99 psiconv_debug(lev+2,off+len,"File is a Sheet file");
92 } 100 }
93 } else if ((*result)->uid2 == PSICONV_ID_MBM_FILE) { 101 } else if ((*result)->uid2 == PSICONV_ID_MBM_FILE) {
94 (*result)->file = psiconv_mbm_file; 102 (*result)->file = psiconv_mbm_file;
95 if ((*result)->uid3 != 0x00) 103 if ((*result)->uid3 != 0x00)
96 psiconv_warn(lev+2,off+len,"UID3 set in MBM file?!?"); 104 psiconv_warn(lev+2,off+len,"UID3 set in MBM file?!?");
97 psiconv_debug(lev+2,off+len,"File is a MBM file"); 105 psiconv_debug(lev+2,off+len,"File is a MBM file");
271 goto ERROR1; 279 goto ERROR1;
272 if (!(para = malloc(sizeof(*para)))) 280 if (!(para = malloc(sizeof(*para))))
273 goto ERROR2; 281 goto ERROR2;
274 282
275 text_len = psiconv_read_X(buf,lev+2,off,&leng,&res); 283 text_len = psiconv_read_X(buf,lev+2,off,&leng,&res);
276 if (!res) 284 if (res)
277 goto ERROR3; 285 goto ERROR3;
278 psiconv_debug(lev+2,off,"Length: %08x",text_len); 286 psiconv_debug(lev+2,off,"Length: %08x",text_len);
279 len += leng; 287 len += leng;
280 288
281 psiconv_progress(lev+2,off+len,"Going to read all paragraph text"); 289 psiconv_progress(lev+2,off+len,"Going to read all paragraph text");
567 if (!(para = psiconv_list_get(result,i))) 575 if (!(para = psiconv_list_get(result,i)))
568 goto ERROR4; 576 goto ERROR4;
569 577
570 psiconv_progress(lev+4,off+len,"Going to read the paragraph length"); 578 psiconv_progress(lev+4,off+len,"Going to read the paragraph length");
571 temp = psiconv_read_u32(buf,lev+4,off+len,&res); 579 temp = psiconv_read_u32(buf,lev+4,off+len,&res);
572 if (!res) 580 if (res)
573 goto ERROR4; 581 goto ERROR4;
574 if (temp != strlen(para->text)+1) { 582 if (temp != strlen(para->text)+1) {
575 psiconv_warn(lev+4,off+len, 583 psiconv_warn(lev+4,off+len,
576 "Disagreement of the length of paragraph in layout section"); 584 "Disagreement of the length of paragraph in layout section");
577 psiconv_debug(lev+4,off+len, 585 psiconv_debug(lev+4,off+len,
581 psiconv_debug(lev+4,off+len,"Paragraph length: %d",temp); 589 psiconv_debug(lev+4,off+len,"Paragraph length: %d",temp);
582 len += 4; 590 len += 4;
583 591
584 psiconv_progress(lev+4,off+len,"Going to read the paragraph type"); 592 psiconv_progress(lev+4,off+len,"Going to read the paragraph type");
585 temp = psiconv_read_u8(buf,lev+4,off+len,&res); 593 temp = psiconv_read_u8(buf,lev+4,off+len,&res);
586 if (!res) 594 if (res)
587 goto ERROR4; 595 goto ERROR4;
588 if (temp != 0x00) { 596 if (temp != 0x00) {
589 psiconv_debug(lev+4,off+len,"Type: %02x",temp); 597 psiconv_debug(lev+4,off+len,"Type: %02x",temp);
590 for (j = 0; j < psiconv_list_length(anon_styles); j++) { 598 for (j = 0; j < psiconv_list_length(anon_styles); j++) {
591 if (!(anon_ptr = psiconv_list_get(anon_styles,j))) { 599 if (!(anon_ptr = psiconv_list_get(anon_styles,j))) {
663 psiconv_free_character_layout(para->base_character); 671 psiconv_free_character_layout(para->base_character);
664 para->base_character = temp_char; 672 para->base_character = temp_char;
665 673
666 para->base_style = temp; 674 para->base_style = temp;
667 psiconv_progress(lev+4,off+len,"Going to read paragraph layout"); 675 psiconv_progress(lev+4,off+len,"Going to read paragraph layout");
668 if (!(psiconv_parse_paragraph_layout_list(buf,lev+4,off+len,&leng, 676 if ((res = psiconv_parse_paragraph_layout_list(buf,lev+4,off+len,&leng,
669 para->base_paragraph))) 677 para->base_paragraph)))
670 goto ERROR4; 678 goto ERROR4;
671 len += leng; 679 len += leng;
672 if (parse_styles) 680 if (parse_styles)
673 len += 1; 681 len += 1;
685 693
686 psiconv_progress(lev+3,off+len,"Going to read the number of elements"); 694 psiconv_progress(lev+3,off+len,"Going to read the number of elements");
687 nr = psiconv_read_u32(buf,lev+3,off+len,&res); 695 nr = psiconv_read_u32(buf,lev+3,off+len,&res);
688 if (res) 696 if (res)
689 goto ERROR4; 697 goto ERROR4;
690 psiconv_debug(lev+3,off,"Elements: %08x",nr); 698 psiconv_debug(lev+3,off+len,"Elements: %08x",nr);
691 len += 0x04; 699 len += 0x04;
692 700
693 psiconv_progress(lev+3,off+len, 701 psiconv_progress(lev+3,off+len,
694 "Going to read the text layout inline elements"); 702 "Going to read the text layout inline elements");
695 total = 0; 703 total = 0;
714 psiconv_progress(lev+4,off+len,"Going to read the element type"); 722 psiconv_progress(lev+4,off+len,"Going to read the element type");
715 temp = psiconv_read_u8(buf,lev+4,len+off,&res); 723 temp = psiconv_read_u8(buf,lev+4,len+off,&res);
716 if (res) 724 if (res)
717 goto ERROR4; 725 goto ERROR4;
718 len += 1; 726 len += 1;
719 psiconv_debug(lev+4,off,"Type: %02x",temp); 727 psiconv_debug(lev+4,off+len,"Type: %02x",temp);
720 psiconv_progress(lev+4,off, 728 psiconv_progress(lev+4,off+len,
721 "Going to read the number of characters it applies to"); 729 "Going to read the number of characters it applies to");
722 in_line.length = psiconv_read_u32(buf,lev+4,len+off,&res); 730 in_line.length = psiconv_read_u32(buf,lev+4,len+off,&res);
723 if (res) 731 if (res)
724 goto ERROR4; 732 goto ERROR4;
725 psiconv_debug(lev+4,off+len,"Length: %02x",in_line.length); 733 psiconv_debug(lev+4,off+len,"Length: %02x",in_line.length);
767 psiconv_list_free(anon_styles); 775 psiconv_list_free(anon_styles);
768 776
769 if (length) 777 if (length)
770 *length = len; 778 *length = len;
771 779
772 psiconv_progress(lev+1,off+len-1,"End of layout section (total length: %08x", 780 psiconv_progress(lev+1,off+len-1,"End of layout section (total length: %08x)",
773 len); 781 len);
774 782
775 return 0; 783 return 0;
776 784
777ERROR4_4: 785ERROR4_4:
822{ 830{
823 return psiconv_parse_layout_section(buf,lev,off,length,result,styles,1); 831 return psiconv_parse_layout_section(buf,lev,off,length,result,styles,1);
824} 832}
825 833
826int psiconv_parse_styleless_layout_section(const psiconv_buffer buf, 834int psiconv_parse_styleless_layout_section(const psiconv_buffer buf,
827 int lev,psiconv_u32 off, 835 int lev,psiconv_u32 off,
828 int *length, 836 int *length,
829 psiconv_text_and_layout result, 837 psiconv_text_and_layout result,
830 psiconv_character_layout base_char, 838 const psiconv_character_layout base_char,
831 psiconv_paragraph_layout base_para) 839 const psiconv_paragraph_layout base_para)
832{ 840{
833 int res = 0; 841 int res = 0;
834 psiconv_word_styles_section styles_section; 842 psiconv_word_styles_section styles_section;
835 843
836 if (!(styles_section = malloc(sizeof(*styles_section)))) 844 if (!(styles_section = malloc(sizeof(*styles_section))))

Legend:
Removed from v.64  
changed lines
  Added in v.142

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