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

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

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

Revision 81 Revision 82
35 return -PSICONV_E_OTHER; 35 return -PSICONV_E_OTHER;
36 } 36 }
37 if (!(*buf = psiconv_buffer_new())) 37 if (!(*buf = psiconv_buffer_new()))
38 return -PSICONV_E_NOMEM; 38 return -PSICONV_E_NOMEM;
39 39
40#if 0
41 if (value->type == psiconv_word_file) { 40 if (value->type == psiconv_word_file) {
42 if ((res =psiconv_write_word_file(*buf,(psiconv_word_f) (value->file)))) 41 if ((res =psiconv_write_word_file(*buf,(psiconv_word_f) (value->file))))
43 goto ERROR; 42 goto ERROR;
44 } else
45#endif
46 if (value->type == psiconv_texted_file) { 43 } else if (value->type == psiconv_texted_file) {
47 if ((res =psiconv_write_texted_file(*buf, 44 if ((res =psiconv_write_texted_file(*buf,
48 (psiconv_texted_f) (value->file)))) 45 (psiconv_texted_f) (value->file))))
49 goto ERROR; 46 goto ERROR;
50#if 0 47#if 0
51 } else if (value->type == psiconv_sketch_file) { 48 } else if (value->type == psiconv_sketch_file) {
167ERROR2: 164ERROR2:
168 psiconv_list_free(section_table); 165 psiconv_list_free(section_table);
169ERROR1: 166ERROR1:
170 return res; 167 return res;
171} 168}
169
170int psiconv_write_word_file(psiconv_buffer buf,psiconv_word_f value)
171{
172 int res;
173 psiconv_section_table_section section_table;
174 psiconv_section_table_entry entry;
175 psiconv_u32 section_table_id;
176
177 if (!value) {
178 psiconv_warn(0,0,"Null Word file");
179 return -PSICONV_E_GENERATE;
180 }
181
182 if (!(section_table = psiconv_list_new(sizeof(*entry)))) {
183 res = -PSICONV_E_NOMEM;
184 goto ERROR1;
185 }
186
187 if (!(entry = malloc(sizeof(*entry)))) {
188 res = -PSICONV_E_NOMEM;
189 goto ERROR2;
190 }
191
192 if ((res = psiconv_write_header_section(buf,PSICONV_ID_PSION5,
193 PSICONV_ID_DATA_FILE,
194 PSICONV_ID_WORD)))
195 goto ERROR3;
196
197 section_table_id = psiconv_buffer_unique_id();
198 if ((res = psiconv_write_offset(buf,section_table_id)))
199 goto ERROR3;
200
201 entry->id = PSICONV_ID_APPL_ID_SECTION;
202 entry->offset = psiconv_buffer_unique_id();
203 if ((res = psiconv_list_add(section_table,entry)))
204 goto ERROR3;
205 if ((res = psiconv_buffer_add_target(buf,entry->offset)))
206 goto ERROR3;
207 if ((res=psiconv_write_application_id_section(buf,
208 PSICONV_ID_WORD,"Word.app")))
209 goto ERROR3;
210
211 entry->id = PSICONV_ID_WORD_STATUS_SECTION;
212 entry->offset = psiconv_buffer_unique_id();
213 if ((res = psiconv_list_add(section_table,entry)))
214 goto ERROR3;
215 if ((res = psiconv_buffer_add_target(buf,entry->offset)))
216 goto ERROR3;
217 if ((res = psiconv_write_word_status_section(buf,value->status_sec)))
218 goto ERROR3;
219
220 entry->id = PSICONV_ID_PAGE_LAYOUT_SECTION;
221 entry->offset = psiconv_buffer_unique_id();
222 if ((res = psiconv_list_add(section_table,entry)))
223 goto ERROR3;
224 if ((res = psiconv_buffer_add_target(buf,entry->offset)))
225 goto ERROR3;
226 if ((res = psiconv_write_page_layout_section(buf,value->page_sec)))
227 goto ERROR3;
228
229 entry->id = PSICONV_ID_WORD_STYLES_SECTION;
230 entry->offset = psiconv_buffer_unique_id();
231 if ((res = psiconv_list_add(section_table,entry)))
232 goto ERROR3;
233 if ((res = psiconv_buffer_add_target(buf,entry->offset)))
234 goto ERROR3;
235 if ((res = psiconv_write_word_styles_section(buf,value->styles_sec)))
236 goto ERROR3;
237
238 entry->id = PSICONV_ID_TEXT_SECTION;
239 entry->offset = psiconv_buffer_unique_id();
240 if ((res = psiconv_list_add(section_table,entry)))
241 goto ERROR3;
242 if ((res = psiconv_buffer_add_target(buf,entry->offset)))
243 goto ERROR3;
244 if ((res = psiconv_write_text_section(buf,value->paragraphs)))
245 goto ERROR3;
246
247 entry->id = PSICONV_ID_LAYOUT_SECTION;
248 entry->offset = psiconv_buffer_unique_id();
249 if ((res = psiconv_list_add(section_table,entry)))
250 goto ERROR3;
251 if ((res = psiconv_buffer_add_target(buf,entry->offset)))
252 goto ERROR3;
253 if ((res = psiconv_write_styled_layout_section(buf,value->paragraphs,
254 value->styles_sec)))
255 goto ERROR3;
256
257 if ((res = psiconv_buffer_add_target(buf,section_table_id)))
258 goto ERROR3;
259
260 res = psiconv_write_section_table_section(buf,section_table);
261
262ERROR3:
263 free(entry);
264ERROR2:
265 psiconv_list_free(section_table);
266ERROR1:
267 return res;
268}

Legend:
Removed from v.81  
changed lines
  Added in v.82

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