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

Contents of /psiconv/trunk/lib/psiconv/generate_texted.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 196 - (show annotations)
Wed Feb 4 12:19:09 2004 UTC (15 years, 11 months ago) by frodo
File MIME type: text/plain
File size: 3130 byte(s)
(Frodo) Copyright dates update

1 /*
2 generate_texted.c - Part of psiconv, a PSION 5 file formats converter
3 Copyright (c) 2000-2004 Frodo Looijaard <frodol@dds.nl>
4
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
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #include "config.h"
21 #include "compat.h"
22
23 #include <stdlib.h>
24
25 #include "generate_routines.h"
26 #include "error.h"
27
28 #ifdef DMALLOC
29 #include <dmalloc.h>
30 #endif
31
32
33
34 int psiconv_write_texted_section(const psiconv_config config,
35 psiconv_buffer buf, int lev,
36 const psiconv_texted_section value,
37 const psiconv_character_layout base_char,
38 const psiconv_paragraph_layout base_para,
39 psiconv_buffer *extra_buf)
40 {
41 int res,with_layout_section=0;
42 psiconv_u32 layout_id;
43
44 psiconv_progress(config,lev,0,"Writing texted section");
45
46 if (!value) {
47 psiconv_error(config,0,psiconv_buffer_length(buf),"Null TextEd section");
48 res = -PSICONV_E_GENERATE;
49 goto ERROR1;
50 }
51
52 if (!(*extra_buf = psiconv_buffer_new())) {
53 res = -PSICONV_E_NOMEM;
54 goto ERROR1;
55 }
56
57 layout_id = psiconv_buffer_unique_id();
58 psiconv_buffer_add_target(*extra_buf,layout_id);
59
60 if (psiconv_list_length(value->paragraphs)) {
61 with_layout_section = 1;
62 if ((res = psiconv_write_styleless_layout_section(config,*extra_buf,lev+1,
63 value->paragraphs,
64 base_char,base_para)))
65 goto ERROR2;
66 }
67
68 if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_TEXTED_BODY)))
69 goto ERROR2;
70
71 /* Partly dummy TextEd Jumptable */
72 if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_TEXTED_REPLACEMENT)))
73 goto ERROR2;
74 if ((res = psiconv_write_u32(config,buf,lev+1,0)))
75 goto ERROR2;
76 if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_TEXTED_UNKNOWN)))
77 goto ERROR2;
78 if ((res = psiconv_write_u32(config,buf,lev+1,0)))
79 goto ERROR2;
80 if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_TEXTED_LAYOUT)))
81 goto ERROR2;
82 if (with_layout_section) {
83 if ((res = psiconv_write_offset(config,buf,lev+1,layout_id)))
84 goto ERROR2;
85 } else {
86 if ((res = psiconv_write_u32(config,buf,lev+1,0)))
87 goto ERROR2;
88 }
89
90 if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_TEXTED_TEXT)))
91 goto ERROR2;
92
93 return psiconv_write_text_section(config,buf,lev+1,value->paragraphs);
94
95 ERROR2:
96 psiconv_buffer_free(*extra_buf);
97 ERROR1:
98 return res;
99 }

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