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

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

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

Revision 73 Revision 217
1/* 1/*
2 generate_common.c - Part of psiconv, a PSION 5 file formats converter 2 generate_common.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.
23#include <string.h> 23#include <string.h>
24 24
25#include "generate_routines.h" 25#include "generate_routines.h"
26#include "error.h" 26#include "error.h"
27 27
28#ifdef DMALLOC
29#include <dmalloc.h>
30#endif
31
32static int psiconv_write_layout_section(const psiconv_config config,
33 psiconv_buffer buf, int lev,
34 const psiconv_text_and_layout value,
35 const psiconv_word_styles_section styles,
36 int with_styles);
28 37
29/* Maybe use a psiconv_header_section variable instead? */ 38/* Maybe use a psiconv_header_section variable instead? */
30int psiconv_write_header_section(psiconv_buffer buf,psiconv_u32 uid1, 39int psiconv_write_header_section(const psiconv_config config,
40 psiconv_buffer buf,int lev,psiconv_u32 uid1,
31 psiconv_u32 uid2, psiconv_u32 uid3) 41 psiconv_u32 uid2, psiconv_u32 uid3)
32{ 42{
33 int res; 43 int res;
44 psiconv_progress(config,lev,0,"Writing header section");
34 if ((res = psiconv_write_u32(buf,uid1))) 45 if ((res = psiconv_write_u32(config,buf,lev+1,uid1)))
35 return res; 46 return res;
36 if ((res = psiconv_write_u32(buf,uid2))) 47 if ((res = psiconv_write_u32(config,buf,lev+1,uid2)))
37 return res; 48 return res;
38 if ((res = psiconv_write_u32(buf,uid3))) 49 if ((res = psiconv_write_u32(config,buf,lev+1,uid3)))
39 return res; 50 return res;
40 return psiconv_write_u32(buf,psiconv_checkuid(uid1,uid2,uid3)); 51 return psiconv_write_u32(config,buf,lev+1,psiconv_checkuid(uid1,uid2,uid3));
41} 52}
42 53
43int psiconv_write_section_table_section(psiconv_buffer buf, 54int psiconv_write_section_table_section(const psiconv_config config,
55 psiconv_buffer buf,int lev,
44 const psiconv_section_table_section value) 56 const psiconv_section_table_section value)
45{ 57{
46 int res,i; 58 int res,i;
47 psiconv_section_table_entry entry; 59 psiconv_section_table_entry entry;
48 60
61 psiconv_progress(config,lev,0,"Writing section table section");
49 if (!value) { 62 if (!value) {
50 psiconv_warn(0,psiconv_list_length(buf),"Null section table section"); 63 psiconv_error(config,0,psiconv_buffer_length(buf),"Null section table section");
51 return -PSICONV_E_GENERATE; 64 return -PSICONV_E_GENERATE;
52 } 65 }
53 66
54 if (!(entry = malloc(sizeof(*entry)))) 67 if ((res = psiconv_write_u8(config,buf,lev+1,2 * psiconv_list_length(value))))
55 return -PSICONV_E_NOMEM; 68 return res;
56
57 if ((res = psiconv_write_u8(buf,2 * sizeof(psiconv_u32) *
58 psiconv_list_length(value))))
59 goto ERROR;
60 for (i = 0; i < psiconv_list_length(value); i++) { 69 for (i = 0; i < psiconv_list_length(value); i++) {
61 if (!(entry = psiconv_list_get(value,i))) { 70 if (!(entry = psiconv_list_get(value,i))) {
62 psiconv_warn(0,psiconv_list_length(buf),"Massive memory corruption"); 71 psiconv_error(config,0,psiconv_buffer_length(buf),"Massive memory corruption");
63 res = -PSICONV_E_NOMEM; 72 return -PSICONV_E_NOMEM;
64 goto ERROR;
65 } 73 }
66 if ((res = psiconv_write_u32(buf,entry->id))) 74 if ((res = psiconv_write_u32(config,buf,lev+1,entry->id)))
67 goto ERROR;
68 if ((res = psiconv_write_u32(buf,entry->offset)))
69 goto ERROR;
70 }
71 res = -PSICONV_E_OK;
72ERROR:
73 free(entry);
74 return res; 75 return res;
76 if ((res = psiconv_write_offset(config,buf,lev+1,entry->offset)))
77 return res;
78 }
79 return -PSICONV_E_OK;
75} 80}
76 81
77int psiconv_write_application_id_section(psiconv_buffer buf,psiconv_u32 id, 82int psiconv_write_application_id_section(const psiconv_config config,
83 psiconv_buffer buf,int lev,psiconv_u32 id,
78 const psiconv_string_t text) 84 const psiconv_string_t text)
79{ 85{
80 int res; 86 int res;
87 psiconv_progress(config,lev,0,"Writing application id section");
81 if ((res = psiconv_write_u32(buf,id))) 88 if ((res = psiconv_write_u32(config,buf,lev+1,id)))
82 return res; 89 return res;
83 return psiconv_write_string(buf,text); 90 return psiconv_write_string(config,buf,lev+1,text);
84} 91}
85 92
86int psiconv_write_text_section(psiconv_buffer buf, 93int psiconv_write_text_section(const psiconv_config config,
94 psiconv_buffer buf,int lev,
87 const psiconv_text_and_layout value) 95 const psiconv_text_and_layout value)
88{ 96{
89 int res; 97 int res;
90 psiconv_buffer extra_buf; 98 psiconv_buffer extra_buf;
91 int i,j; 99 int i,j;
92 psiconv_paragraph paragraph; 100 psiconv_paragraph paragraph;
93 101
102 psiconv_progress(config,lev,0,"Writing text section");
94 if (!value) { 103 if (!value) {
95 psiconv_warn(0,psiconv_list_length(buf),"Null text section"); 104 psiconv_error(config,0,psiconv_buffer_length(buf),"Null text section");
96 return -PSICONV_E_GENERATE; 105 return -PSICONV_E_GENERATE;
97 } 106 }
98 107
108 if (psiconv_list_length(value)) {
99 if (!(extra_buf = psiconv_new_buffer())) 109 if (!(extra_buf = psiconv_buffer_new()))
100 return -PSICONV_E_NOMEM; 110 return -PSICONV_E_NOMEM;
111 for (i = 0; i < psiconv_list_length(value); i++) {
112 if (!(paragraph = psiconv_list_get(value,i))) {
113 psiconv_error(config,0,psiconv_buffer_length(buf),"Massive memory corruption");
114 res = -PSICONV_E_NOMEM;
115 goto ERROR;
116 }
117 for (j = 0; j < psiconv_unicode_strlen(paragraph->text); j++)
118 if ((res = psiconv_unicode_write_char(config,extra_buf,lev+1,
119 paragraph->text[j])))
120 goto ERROR;
121 psiconv_unicode_write_char(config,extra_buf,lev+1,0x06);
122 }
123 if ((res = psiconv_write_X(config,buf,lev+1,psiconv_buffer_length(extra_buf))))
124 goto ERROR;
125 res = psiconv_buffer_concat(buf,extra_buf);
126 } else
127 /* Hack: empty text sections are just not allowed */
128 return psiconv_write_u16(config,buf,lev+1,0x0602);
129
130ERROR:
131 psiconv_buffer_free(extra_buf);
132 return res;
133}
134
135int psiconv_write_layout_section(const psiconv_config config,
136 psiconv_buffer buf,int lev,
137 const psiconv_text_and_layout value,
138 const psiconv_word_styles_section styles,
139 int with_styles)
140{
141 typedef struct psiconv_paragraph_type_list_s
142 {
143 psiconv_character_layout character;
144 psiconv_paragraph_layout paragraph;
145 psiconv_u8 style;
146 psiconv_u8 nr;
147 } *psiconv_paragraph_type_list;
148 psiconv_u32 obj_id;
149 psiconv_list paragraph_type_list; /* Of psiconv_paragraph_type_list_s */
150 psiconv_paragraph_type_list paragraph_type;
151 struct psiconv_paragraph_type_list_s new_type;
152 psiconv_buffer buf_types,buf_elements,buf_inlines,buf_objects;
153 psiconv_paragraph paragraph;
154 psiconv_in_line_layout in_line = NULL;
155 psiconv_word_style style;
156 psiconv_character_layout para_charlayout;
157 int i,j,para_type,nr_of_inlines=0,res,ptl_length,pel_length,thislen,paralen;
158
159 psiconv_progress(config,lev,0,"Writing layout section");
160 if (!value) {
161 psiconv_error(config,0,psiconv_buffer_length(buf),"Null text section");
162 return -PSICONV_E_GENERATE;
163 }
164
165 if (!(paragraph_type_list = psiconv_list_new(sizeof(new_type)))) {
166 res = -PSICONV_E_NOMEM;
167 goto ERROR1;
168 }
169
170 if (!(buf_types = psiconv_buffer_new())) {
171 res = -PSICONV_E_NOMEM;
172 goto ERROR2;
173 }
174
175 if (!(buf_elements = psiconv_buffer_new())) {
176 res = -PSICONV_E_NOMEM;
177 goto ERROR3;
178 }
179
180 if (!(buf_inlines = psiconv_buffer_new())) {
181 res = -PSICONV_E_NOMEM;
182 goto ERROR4;
183 }
184
185 if (!(buf_objects = psiconv_buffer_new())) {
186 res = -PSICONV_E_NOMEM;
187 goto ERROR5;
188 }
189
101 for (i = 0; i < psiconv_list_length(value); i++) { 190 for (i = 0; i < psiconv_list_length(value); i++) {
102 if (!(paragraph = psiconv_list_get(value,i))) { 191 if (!(paragraph = psiconv_list_get(value,i))) {
103 psiconv_warn(0,psiconv_list_length(buf),"Massive memory corruption"); 192 psiconv_error(config,0,psiconv_buffer_length(buf),"Massive memory corruption");
104 res = -PSICONV_E_OTHER; 193 res = -PSICONV_E_NOMEM;
105 goto ERROR; 194 goto ERROR6;
106 } 195 }
107 for (j = 0; j < strlen(paragraph->text); j++) 196 if ((res = psiconv_write_u32(config,buf_elements,lev+1,
108 if ((res = psiconv_write_u8(extra_buf,paragraph->text[j]))) 197 psiconv_unicode_strlen(paragraph->text)+1)))
198 goto ERROR6;
199
200 /* We need it for the next if-statement */
201 if (psiconv_list_length(paragraph->in_lines) == 1)
202 if (!(in_line = psiconv_list_get(paragraph->in_lines,1)))
203 goto ERROR6;
204
205 if ((psiconv_list_length(paragraph->in_lines) > 1) ||
206 ((psiconv_list_length(paragraph->in_lines) == 1) &&
207 (in_line->object != NULL))) {
208 /* Inline layouts, or an object, so we generate a paragraph element
209 and inline elements */
210 if ((res = psiconv_write_u8(config,buf_elements,lev+1,0x00)))
109 goto ERROR; 211 goto ERROR6;
110 psiconv_write_u8(extra_buf,0x06); 212 if (!(style = psiconv_get_style(styles,paragraph->base_style))) {
213 psiconv_error(config,0,psiconv_buffer_length(buf),"Unknown style");
214 res = -PSICONV_E_GENERATE;
215 goto ERROR6;
216 }
217 if ((res = psiconv_write_paragraph_layout_list(config,buf_elements,lev+1,
218 paragraph->base_paragraph,
219 style->paragraph)))
220 goto ERROR6;
221 if (with_styles)
222 if ((res = psiconv_write_u8(config,buf_elements,lev+1,paragraph->base_style)))
223 goto ERROR6;
224 if ((res = psiconv_write_u32(config,buf_elements,lev+1,
225 psiconv_list_length(paragraph->in_lines))))
226 goto ERROR6;
227
228 /* Generate the inlines. NB: Against what are all settings relative?!? */
229 paralen = 0;
230 for (j = 0; j < psiconv_list_length(paragraph->in_lines); j++) {
231 nr_of_inlines ++;
232 if (!(in_line = psiconv_list_get(paragraph->in_lines,j))) {
233 psiconv_error(config,0,psiconv_buffer_length(buf),
234 "Massive memory corruption");
235 res = -PSICONV_E_NOMEM;
236 goto ERROR6;
237 }
238 if ((res = psiconv_write_u8(config,buf_inlines,lev+1,in_line->object?0x01:0x00)))
239 goto ERROR6;
240 thislen = in_line->length;
241 paralen += thislen;
242 /* If this is the last in_line, we need to make sure that the
243 complete length of all inlines equals the text length */
244 if (j == psiconv_list_length(paragraph->in_lines)-1) {
245 if (paralen > psiconv_unicode_strlen(paragraph->text)+1) {
246 res = -PSICONV_E_GENERATE;
247 goto ERROR6;
248 }
249 thislen += psiconv_unicode_strlen(paragraph->text)+1-paralen;
250 }
251 if ((res = psiconv_write_u32(config,buf_inlines,lev+1,thislen)))
252 goto ERROR6;
253 if ((res = psiconv_write_character_layout_list(config,buf_inlines,lev+1,
254 in_line->layout,
255 style->character)))
256 goto ERROR6;
257 if (in_line->object) {
258 if ((res = psiconv_write_u32(config,buf_inlines,lev+1,PSICONV_ID_OBJECT)))
259 goto ERROR6;
260 obj_id = psiconv_buffer_unique_id();
261 if ((res = psiconv_buffer_add_reference(buf_inlines,obj_id)))
262 goto ERROR6;
263 if ((res = psiconv_buffer_add_target(buf_objects,obj_id)))
264 goto ERROR6;
265 if ((res = psiconv_write_embedded_object_section(config,buf_objects,lev+1,
266 in_line->object)))
267 goto ERROR6;
268 if ((res = psiconv_write_length(config,buf_inlines,lev+1,in_line->object_width)))
269 goto ERROR6;
270 if ((res = psiconv_write_length(config,buf_inlines,lev+1,in_line->object_height)))
271 goto ERROR6;
272 }
273 }
274 } else {
275 /* No inline layouts (or only 1), so we generate a paragraph type list */
276 para_type = 0;
277 /* Set para_charlayout to the correct character-level layout */
278 if (psiconv_list_length(paragraph->in_lines) == 0)
279 para_charlayout = paragraph->base_character;
280 else {
281 if (!(in_line = psiconv_list_get(paragraph->in_lines,0))) {
282 psiconv_error(config,0,psiconv_buffer_length(buf),
283 "Massive memory corruption");
284 res = -PSICONV_E_NOMEM;
285 goto ERROR6;
286 }
287 para_charlayout = in_line->layout;
288 }
289 for (j = 0; j < psiconv_list_length(paragraph_type_list); j++) {
290 if (!(paragraph_type = psiconv_list_get(paragraph_type_list,j))) {
291 psiconv_error(config,0,psiconv_buffer_length(buf),
292 "Massive memory corruption");
293 res = -PSICONV_E_NOMEM;
294 goto ERROR6;
295 }
296 if ((paragraph->base_style == paragraph_type->style) &&
297 !psiconv_compare_character_layout(para_charlayout,
298 paragraph_type->character) &&
299 !psiconv_compare_paragraph_layout(paragraph->base_paragraph,
300 paragraph_type->paragraph)) {
301 para_type = paragraph_type->nr;
302 break;
303 }
304 }
305 if (!para_type) {
306 /* We need to add a new entry */
307 para_type = new_type.nr = j+1;
308 /* No need to copy them, we won't change them anyway */
309 new_type.paragraph = paragraph->base_paragraph;
310 new_type.character = para_charlayout;
311 new_type.style = paragraph->base_style;
312 paragraph_type = &new_type;
313 if ((res = psiconv_list_add(paragraph_type_list,paragraph_type)))
314 goto ERROR6;
315 if ((res = psiconv_write_u32(config,buf_types,lev+1,paragraph_type->nr)))
316 goto ERROR6;
317 if (!(style = psiconv_get_style(styles,paragraph_type->style))) {
318 psiconv_error(config,0,psiconv_buffer_length(buf),"Unknown style");
319 res = -PSICONV_E_GENERATE;
320 goto ERROR6;
321 }
322 if ((res = psiconv_write_paragraph_layout_list(config,buf_types,lev+1,
323 paragraph_type->paragraph,style->paragraph)))
324 goto ERROR6;
325 if (with_styles)
326 if ((res = psiconv_write_u8(config,buf_types,lev+1,paragraph_type->style)))
327 goto ERROR6;
328 if ((res = psiconv_write_character_layout_list(config,buf_types,lev+1,
329 paragraph_type->character,style->character)))
330 goto ERROR6;
331 }
332 if ((res = psiconv_write_u8(config,buf_elements,lev+1,para_type)))
333 goto ERROR6;
111 } 334 }
112 if ((res = psiconv_write_X(buf,psiconv_list_length(extra_buf)))) 335 }
336
337 /* HACK: special case: no paragraphs at all. We need to improvize. */
338 if (!psiconv_list_length(value)) {
339 if ((res = psiconv_write_u32(config,buf_types,lev+1,1)))
340 goto ERROR6;
341 if ((res = psiconv_write_u32(config,buf_types,lev+1,0)))
342 goto ERROR6;
343 if (with_styles)
344 if ((res = psiconv_write_u8(config,buf_types,lev+1,0)))
345 goto ERROR6;
346 if ((res = psiconv_write_u32(config,buf_types,lev+1,0)))
347 goto ERROR6;
348
349 if ((res = psiconv_write_u32(config,buf_elements,lev+1,1)))
350 goto ERROR6;
351 if ((res = psiconv_write_u8(config,buf_elements,lev+1,1)))
352 goto ERROR6;
353 pel_length = 1;
354 ptl_length = 1;
355 } else {
356 pel_length = psiconv_list_length(value);
357 ptl_length = psiconv_list_length(paragraph_type_list);
358 }
359
360 /* Now append everything */
361 if ((res = psiconv_write_u16(config,buf,lev+1,with_styles?0x0001:0x0000)))
113 goto ERROR; 362 goto ERROR6;
114 res = psiconv_list_concat(buf,extra_buf); 363 if ((res = psiconv_write_u8(config,buf,lev+1, ptl_length)))
364 goto ERROR6;
365 if ((res = psiconv_buffer_concat(buf,buf_types)))
366 goto ERROR6;
367 if ((res = psiconv_write_u32(config,buf,lev+1,pel_length)))
368 goto ERROR6;
369 if ((res = psiconv_buffer_concat(buf,buf_elements)))
370 goto ERROR6;
371 if ((res = psiconv_write_u32(config,buf,lev+1,nr_of_inlines)))
372 goto ERROR6;
373 if ((res = psiconv_buffer_concat(buf,buf_inlines)))
374 goto ERROR6;
375 if ((res = psiconv_buffer_concat(buf,buf_objects)))
376 goto ERROR6;
115 377
116ERROR: 378ERROR6:
379 psiconv_buffer_free(buf_objects);
380ERROR5:
381 psiconv_buffer_free(buf_inlines);
382ERROR4:
383 psiconv_buffer_free(buf_elements);
384ERROR3:
385 psiconv_buffer_free(buf_types);
386ERROR2:
387 psiconv_list_free(paragraph_type_list);
388ERROR1:
389 return res;
390}
391
392int psiconv_write_styled_layout_section(const psiconv_config config,
393 psiconv_buffer buf,int lev,
394 psiconv_text_and_layout result,
395 psiconv_word_styles_section styles)
396{
397 psiconv_progress(config,lev,0,"Writing styled layout section");
398 return psiconv_write_layout_section(config,buf,lev+1,result,styles,1);
399}
400
401int psiconv_write_styleless_layout_section(const psiconv_config config,
402 psiconv_buffer buf,int lev,
403 const psiconv_text_and_layout value,
404 const psiconv_character_layout base_char,
405 const psiconv_paragraph_layout base_para)
406{
407 int res = 0;
408 psiconv_word_styles_section styles_section;
409
410 psiconv_progress(config,lev,0,"Writing styleless layout section");
411 if (!(styles_section = malloc(sizeof(*styles_section))))
412 goto ERROR1;
413 if (!(styles_section->normal = malloc(sizeof(*styles_section->normal))))
414 goto ERROR2;
415 if (!(styles_section->normal->character =
416 psiconv_clone_character_layout(base_char)))
417 goto ERROR3;
418 if (!(styles_section->normal->paragraph =
419 psiconv_clone_paragraph_layout(base_para)))
420 goto ERROR4;
421 styles_section->normal->hotkey = 0;
422 if (!(styles_section->normal->name = psiconv_unicode_empty_string()))
423 goto ERROR5;
424 if (!(styles_section->styles = psiconv_list_new(sizeof(
425 struct psiconv_word_style_s))))
426 goto ERROR6;
427
428 res = psiconv_write_layout_section(config,buf,lev+1,value,styles_section,0);
429 psiconv_free_word_styles_section(styles_section);
430 return res;
431
432ERROR6:
433 free(styles_section->normal->name);
434ERROR5:
435 psiconv_free_paragraph_layout(styles_section->normal->paragraph);
436ERROR4:
437 psiconv_free_character_layout(styles_section->normal->character);
438ERROR3:
439 free(styles_section->normal);
440ERROR2:
441 free(styles_section);
442ERROR1:
443 if (!res)
444 return -PSICONV_E_NOMEM;
445 else
446 return res;
447}
448
449
450int psiconv_write_embedded_object_section(const psiconv_config config,
451 psiconv_buffer buf,int lev,
452 const psiconv_embedded_object_section value)
453{
454 int res;
455 psiconv_u32 display_id,icon_id,table_id;
117 psiconv_free_buffer(extra_buf); 456 psiconv_buffer extra_buf;
457
458 psiconv_progress(config,lev,0,"Writing embedded object section");
459 if (!value) {
460 psiconv_error(config,0,psiconv_buffer_length(buf),"Null Object");
461 res = -PSICONV_E_GENERATE;
462 goto ERROR1;
463 }
464
465 if (!(extra_buf = psiconv_buffer_new())) {
466 res = -PSICONV_E_NOMEM;
467 goto ERROR1;
468 }
469
470 display_id = psiconv_buffer_unique_id();
471 icon_id = psiconv_buffer_unique_id();
472 table_id = psiconv_buffer_unique_id();
473 if ((res = psiconv_write_u8(config,buf,lev+1,0x06)))
474 goto ERROR2;
475 if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_OBJECT_DISPLAY_SECTION)))
476 goto ERROR2;
477 if ((res = psiconv_buffer_add_reference(buf,display_id)))
478 goto ERROR2;
479 if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_OBJECT_ICON_SECTION)))
480 goto ERROR2;
481 if ((res = psiconv_buffer_add_reference(buf,icon_id)))
482 goto ERROR2;
483 if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_OBJECT_SECTION_TABLE_SECTION)))
484 goto ERROR2;
485 if ((res = psiconv_buffer_add_reference(buf,table_id)))
486 goto ERROR2;
487
488 if ((res = psiconv_buffer_add_target(buf,display_id)))
489 goto ERROR2;
490 if ((res = psiconv_write_object_display_section(config,buf,lev+1,value->display)))
491 goto ERROR2;
492 if ((res = psiconv_buffer_add_target(buf,icon_id)))
493 goto ERROR2;
494 if ((res = psiconv_write_object_icon_section(config,buf,lev+1,value->icon)))
495 goto ERROR2;
496 if ((res = psiconv_buffer_add_target(buf,table_id)))
497 goto ERROR2;
498 switch(value->object->type) {
499 case psiconv_word_file:
500 if ((res = psiconv_write_word_file(config,extra_buf,lev+1,
501 (psiconv_word_f) value->object->file)))
502 goto ERROR2;
503 break;
504 case psiconv_sketch_file:
505 if ((res = psiconv_write_sketch_file(config,extra_buf,lev+1,
506 (psiconv_sketch_f) value->object->file)))
507 goto ERROR2;
508 break;
509/*
510 case psiconv_sheet_file:
511 if ((res = psiconv_write_sheet_file(config,extra_buf,lev+1,
512 (psiconv_sheet_f) value->object->file)))
513 goto ERROR2;
514 break;
515*/
516 default:
517 psiconv_error(config,0,psiconv_buffer_length(buf),
518 "Unknown or unsupported object type");
519 res = -PSICONV_E_GENERATE;
520 goto ERROR2;
521 }
522
523 if ((res = psiconv_buffer_resolve(extra_buf)))
524 goto ERROR2;
525 if ((res = psiconv_buffer_concat(buf,extra_buf)))
526 goto ERROR2;
527 psiconv_buffer_free(extra_buf);
528
529 return 0;
530
531ERROR2:
532 psiconv_buffer_free(extra_buf);
533ERROR1:
534 return res;
118} 535}
536
537
538int psiconv_write_object_display_section(const psiconv_config config,
539 psiconv_buffer buf,int lev,
540 const psiconv_object_display_section value)
541{
542 int res;
543
544 psiconv_progress(config,lev,0,"Writing object display section");
545
546 if (!value) {
547 psiconv_error(config,0,psiconv_buffer_length(buf),"Null Object Display Section");
548 res = -PSICONV_E_GENERATE;
549 goto ERROR1;
550 }
551
552 if ((res = psiconv_write_u8(config,buf,lev+1,value->show_icon?0x00:0x01)))
553 goto ERROR1;
554 if ((res = psiconv_write_length(config,buf,lev+1,value->width)))
555 goto ERROR1;
556 if ((res = psiconv_write_length(config,buf,lev+1,value->height)))
557 goto ERROR1;
558 if ((res = psiconv_write_u32(config,buf,lev+1,0x00000000)))
559 goto ERROR1;
560
561 return 0;
562
563ERROR1:
564 return res;
565}
566
567int psiconv_write_object_icon_section(const psiconv_config config,
568 psiconv_buffer buf,int lev,
569 const psiconv_object_icon_section value)
570{
571 int res;
572
573 psiconv_progress(config,lev,0,"Writing object icon section");
574
575 if (!value) {
576 psiconv_error(config,0,psiconv_buffer_length(buf),"Null Object Icon Section");
577 res = -PSICONV_E_GENERATE;
578 goto ERROR1;
579 }
580
581 if ((res = psiconv_write_string(config,buf,lev+1,value->icon_name)))
582 goto ERROR1;
583 if ((res = psiconv_write_length(config,buf,lev+1,value->icon_width)))
584 goto ERROR1;
585 if ((res = psiconv_write_length(config,buf,lev+1,value->icon_height)))
586 goto ERROR1;
587
588 return 0;
589
590ERROR1:
591 return res;
592}

Legend:
Removed from v.73  
changed lines
  Added in v.217

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