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

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

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

Revision 168 Revision 231
1/* 1/*
2 generate_page.c - Part of psiconv, a PSION 5 file formats converter 2 generate_page.c - Part of psiconv, a PSION 5 file formats converter
3 Copyright (c) 2000 Frodo Looijaard <frodol@dds.nl> 3 Copyright (c) 2000-2004 Frodo Looijaard <frodol@dds.nl>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
31#endif 31#endif
32 32
33 33
34 34
35int psiconv_write_page_header(const psiconv_config config, 35int psiconv_write_page_header(const psiconv_config config,
36 psiconv_buffer buf, 36 psiconv_buffer buf, int lev,
37 const psiconv_page_header value, 37 const psiconv_page_header value,
38 psiconv_buffer *extra_buf) 38 psiconv_buffer *extra_buf)
39{ 39{
40 int res; 40 int res;
41 psiconv_paragraph_layout basepara; 41 psiconv_paragraph_layout basepara;
42 psiconv_character_layout basechar; 42 psiconv_character_layout basechar;
43 43
44 psiconv_progress(config,lev,0,"Writing page header");
45
44 if (!value) { 46 if (!value) {
45 psiconv_warn(config,0,psiconv_buffer_length(buf),"Null page header"); 47 psiconv_error(config,lev,0,"Null page header");
46 res = -PSICONV_E_GENERATE; 48 res = -PSICONV_E_GENERATE;
47 goto ERROR1; 49 goto ERROR1;
48 } 50 }
49 51
50 if (!(basepara=psiconv_basic_paragraph_layout())) { 52 if (!(basepara=psiconv_basic_paragraph_layout())) {
55 res = -PSICONV_E_NOMEM; 57 res = -PSICONV_E_NOMEM;
56 goto ERROR2; 58 goto ERROR2;
57 } 59 }
58 60
59 /* Unknown byte */ 61 /* Unknown byte */
60 if ((res = psiconv_write_u8(config,buf,0x01))) 62 if ((res = psiconv_write_u8(config,buf,lev+1,0x01)))
61 goto ERROR3; 63 goto ERROR3;
62 if ((res = psiconv_write_bool(config,buf,value->on_first_page))) 64 if ((res = psiconv_write_bool(config,buf,lev+1,value->on_first_page)))
63 goto ERROR3; 65 goto ERROR3;
64 /* Three unknown bytes */ 66 /* Three unknown bytes */
65 if ((res = psiconv_write_u8(config,buf,0x00))) 67 if ((res = psiconv_write_u8(config,buf,lev+1,0x00)))
66 goto ERROR3; 68 goto ERROR3;
67 if ((res = psiconv_write_u8(config,buf,0x00))) 69 if ((res = psiconv_write_u8(config,buf,lev+1,0x00)))
68 goto ERROR3; 70 goto ERROR3;
69 if ((res = psiconv_write_u8(config,buf,0x00))) 71 if ((res = psiconv_write_u8(config,buf,lev+1,0x00)))
70 goto ERROR3; 72 goto ERROR3;
71 if ((res = psiconv_write_paragraph_layout_list(config,buf, 73 if ((res = psiconv_write_paragraph_layout_list(config,buf,lev+1,
72 value->base_paragraph_layout,basepara))) 74 value->base_paragraph_layout,basepara)))
73 goto ERROR3; 75 goto ERROR3;
74 if ((res = psiconv_write_character_layout_list(config,buf, 76 if ((res = psiconv_write_character_layout_list(config,buf,lev+1,
75 value->base_character_layout,basechar))) 77 value->base_character_layout,basechar)))
76 goto ERROR3; 78 goto ERROR3;
77 res = psiconv_write_texted_section(config,buf,value->text, 79 res = psiconv_write_texted_section(config,buf,lev+1,value->text,
78 value->base_character_layout, 80 value->base_character_layout,
79 value->base_paragraph_layout,extra_buf); 81 value->base_paragraph_layout,extra_buf);
80ERROR3: 82ERROR3:
81 psiconv_free_character_layout(basechar); 83 psiconv_free_character_layout(basechar);
82ERROR2: 84ERROR2:
83 psiconv_free_paragraph_layout(basepara); 85 psiconv_free_paragraph_layout(basepara);
84ERROR1: 86ERROR1:
87 if (res)
88 psiconv_error(config,lev,0,"Writing of page header failed");
89 else
90 psiconv_progress(config,lev,0,"End of page header");
85 return res; 91 return res;
86} 92}
87 93
88int psiconv_write_page_layout_section(const psiconv_config config, 94int psiconv_write_page_layout_section(const psiconv_config config,
89 psiconv_buffer buf, 95 psiconv_buffer buf, int lev,
90 const psiconv_page_layout_section value) 96 const psiconv_page_layout_section value)
91{ 97{
92 int res; 98 int res;
93 psiconv_buffer header_buf,footer_buf; 99 psiconv_buffer header_buf,footer_buf;
94 100
101 psiconv_progress(config,lev,0,"Writing page layout section");
102
95 if (!value) { 103 if (!value) {
96 psiconv_warn(config,0,psiconv_buffer_length(buf),"Null page section"); 104 psiconv_error(config,lev,0,"Null page section");
97 res = -PSICONV_E_GENERATE; 105 res = -PSICONV_E_GENERATE;
98 goto ERROR1; 106 goto ERROR1;
99 } 107 }
100 108
101 if ((res = psiconv_write_u32(config,buf,value->first_page_nr))) 109 if ((res = psiconv_write_u32(config,buf,lev+1,value->first_page_nr)))
102 goto ERROR1; 110 goto ERROR1;
103 if ((res = psiconv_write_length(config,buf,value->header_dist))) 111 if ((res = psiconv_write_length(config,buf,lev+1,value->header_dist)))
104 goto ERROR1; 112 goto ERROR1;
105 if ((res = psiconv_write_length(config,buf,value->footer_dist))) 113 if ((res = psiconv_write_length(config,buf,lev+1,value->footer_dist)))
106 goto ERROR1; 114 goto ERROR1;
107 if ((res = psiconv_write_length(config,buf,value->left_margin))) 115 if ((res = psiconv_write_length(config,buf,lev+1,value->left_margin)))
108 goto ERROR1; 116 goto ERROR1;
109 if ((res = psiconv_write_length(config,buf,value->right_margin))) 117 if ((res = psiconv_write_length(config,buf,lev+1,value->right_margin)))
110 goto ERROR1; 118 goto ERROR1;
111 if ((res = psiconv_write_length(config,buf,value->top_margin))) 119 if ((res = psiconv_write_length(config,buf,lev+1,value->top_margin)))
112 goto ERROR1; 120 goto ERROR1;
113 if ((res = psiconv_write_length(config,buf,value->bottom_margin))) 121 if ((res = psiconv_write_length(config,buf,lev+1,value->bottom_margin)))
114 goto ERROR1; 122 goto ERROR1;
115 if ((res = psiconv_write_page_header(config,buf,value->header,&header_buf))) 123 if ((res = psiconv_write_page_header(config,buf,lev+1,value->header,&header_buf)))
116 goto ERROR1; 124 goto ERROR1;
117 if ((res = psiconv_write_page_header(config,buf,value->footer,&footer_buf))) 125 if ((res = psiconv_write_page_header(config,buf,lev+1,value->footer,&footer_buf)))
118 goto ERROR2; 126 goto ERROR2;
119 if ((res = psiconv_write_u32(config,buf,PSICONV_ID_PAGE_DIMENSIONS2))) 127 if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_PAGE_DIMENSIONS2)))
120 goto ERROR3; 128 goto ERROR3;
121 if ((res = psiconv_write_length(config,buf,value->page_width))) 129 if ((res = psiconv_write_length(config,buf,lev+1,value->page_width)))
122 goto ERROR3; 130 goto ERROR3;
123 if ((res = psiconv_write_length(config,buf,value->page_height))) 131 if ((res = psiconv_write_length(config,buf,lev+1,value->page_height)))
124 goto ERROR3; 132 goto ERROR3;
125 if ((res = psiconv_write_bool(config,buf,value->landscape))) 133 if ((res = psiconv_write_bool(config,buf,lev+1,value->landscape)))
126 goto ERROR3; 134 goto ERROR3;
127 if ((res = psiconv_buffer_concat(buf,header_buf))) 135 if ((res = psiconv_buffer_concat(buf,header_buf)))
128 goto ERROR3; 136 goto ERROR3;
129 res = psiconv_buffer_concat(buf,footer_buf); 137 res = psiconv_buffer_concat(buf,footer_buf);
130 138
132ERROR3: 140ERROR3:
133 psiconv_buffer_free(footer_buf); 141 psiconv_buffer_free(footer_buf);
134ERROR2: 142ERROR2:
135 psiconv_buffer_free(header_buf); 143 psiconv_buffer_free(header_buf);
136ERROR1: 144ERROR1:
145 if (res)
146 psiconv_error(config,lev,0,"Writing of page layout section failed");
147 else
148 psiconv_progress(config,lev,0,"End of page layout section");
137 return res; 149 return res;
138} 150}

Legend:
Removed from v.168  
changed lines
  Added in v.231

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