1 | /* |
1 | /* |
2 | generate_texted.c - Part of psiconv, a PSION 5 file formats converter |
2 | generate_texted.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. |
… | |
… | |
30 | #endif |
30 | #endif |
31 | |
31 | |
32 | |
32 | |
33 | |
33 | |
34 | int psiconv_write_texted_section(const psiconv_config config, |
34 | int psiconv_write_texted_section(const psiconv_config config, |
35 | psiconv_buffer buf, |
35 | psiconv_buffer buf, int lev, |
36 | const psiconv_texted_section value, |
36 | const psiconv_texted_section value, |
37 | const psiconv_character_layout base_char, |
37 | const psiconv_character_layout base_char, |
38 | const psiconv_paragraph_layout base_para, |
38 | const psiconv_paragraph_layout base_para, |
39 | psiconv_buffer *extra_buf) |
39 | psiconv_buffer *extra_buf) |
40 | { |
40 | { |
41 | int res,with_layout_section=0; |
41 | int res,with_layout_section=0; |
42 | psiconv_u32 layout_id; |
42 | psiconv_u32 layout_id; |
43 | |
43 | |
|
|
44 | psiconv_progress(config,lev,0,"Writing texted section"); |
|
|
45 | |
44 | if (!value) { |
46 | if (!value) { |
45 | psiconv_warn(config,0,psiconv_buffer_length(buf),"Null TextEd section"); |
47 | psiconv_error(config,0,psiconv_buffer_length(buf),"Null TextEd section"); |
46 | res = -PSICONV_E_GENERATE; |
48 | res = -PSICONV_E_GENERATE; |
47 | goto ERROR1; |
49 | goto ERROR1; |
48 | } |
50 | } |
49 | |
51 | |
50 | if (!(*extra_buf = psiconv_buffer_new())) { |
52 | if (!(*extra_buf = psiconv_buffer_new())) { |
… | |
… | |
55 | layout_id = psiconv_buffer_unique_id(); |
57 | layout_id = psiconv_buffer_unique_id(); |
56 | psiconv_buffer_add_target(*extra_buf,layout_id); |
58 | psiconv_buffer_add_target(*extra_buf,layout_id); |
57 | |
59 | |
58 | if (psiconv_list_length(value->paragraphs)) { |
60 | if (psiconv_list_length(value->paragraphs)) { |
59 | with_layout_section = 1; |
61 | with_layout_section = 1; |
60 | if ((res = psiconv_write_styleless_layout_section(config,*extra_buf, |
62 | if ((res = psiconv_write_styleless_layout_section(config,*extra_buf,lev+1, |
61 | value->paragraphs, |
63 | value->paragraphs, |
62 | base_char,base_para))) |
64 | base_char,base_para))) |
63 | goto ERROR2; |
65 | goto ERROR2; |
64 | } |
66 | } |
65 | |
67 | |
66 | if ((res = psiconv_write_u32(config,buf,PSICONV_ID_TEXTED_BODY))) |
68 | if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_TEXTED_BODY))) |
67 | goto ERROR2; |
69 | goto ERROR2; |
68 | |
70 | |
69 | /* Partly dummy TextEd Jumptable */ |
71 | /* Partly dummy TextEd Jumptable */ |
70 | if ((res = psiconv_write_u32(config,buf,PSICONV_ID_TEXTED_REPLACEMENT))) |
72 | if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_TEXTED_REPLACEMENT))) |
71 | goto ERROR2; |
73 | goto ERROR2; |
72 | if ((res = psiconv_write_u32(config,buf,0))) |
74 | if ((res = psiconv_write_u32(config,buf,lev+1,0))) |
73 | goto ERROR2; |
75 | goto ERROR2; |
74 | if ((res = psiconv_write_u32(config,buf,PSICONV_ID_TEXTED_UNKNOWN))) |
76 | if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_TEXTED_UNKNOWN))) |
75 | goto ERROR2; |
77 | goto ERROR2; |
76 | if ((res = psiconv_write_u32(config,buf,0))) |
78 | if ((res = psiconv_write_u32(config,buf,lev+1,0))) |
77 | goto ERROR2; |
79 | goto ERROR2; |
78 | if ((res = psiconv_write_u32(config,buf,PSICONV_ID_TEXTED_LAYOUT))) |
80 | if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_TEXTED_LAYOUT))) |
79 | goto ERROR2; |
81 | goto ERROR2; |
80 | if (with_layout_section) { |
82 | if (with_layout_section) { |
81 | if ((res = psiconv_write_offset(config,buf,layout_id))) |
83 | if ((res = psiconv_write_offset(config,buf,lev+1,layout_id))) |
82 | goto ERROR2; |
84 | goto ERROR2; |
83 | } else { |
85 | } else { |
84 | if ((res = psiconv_write_u32(config,buf,0))) |
86 | if ((res = psiconv_write_u32(config,buf,lev+1,0))) |
85 | goto ERROR2; |
87 | goto ERROR2; |
86 | } |
88 | } |
87 | |
89 | |
88 | if ((res = psiconv_write_u32(config,buf,PSICONV_ID_TEXTED_TEXT))) |
90 | if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_TEXTED_TEXT))) |
89 | goto ERROR2; |
91 | goto ERROR2; |
90 | |
92 | |
91 | return psiconv_write_text_section(config,buf,value->paragraphs); |
93 | return psiconv_write_text_section(config,buf,lev+1,value->paragraphs); |
92 | |
94 | |
93 | ERROR2: |
95 | ERROR2: |
94 | psiconv_buffer_free(*extra_buf); |
96 | psiconv_buffer_free(*extra_buf); |
95 | ERROR1: |
97 | ERROR1: |
96 | return res; |
98 | return res; |