/[public]/psiconv/trunk/program/psiconv/gen_html4.c
ViewVC logotype

Diff of /psiconv/trunk/program/psiconv/gen_html4.c

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

Revision 193 Revision 267
1/*
1/* gen_html.c - Part of psiconv, a PSION 5 file formats converter 2 gen_html.c - Part of psiconv, a PSION 5 file formats converter
2 Copyright (c) 1999-2004 Frodo Looijaard <frodol@dds.nl> 3 Copyright (c) 1999-2004 Frodo Looijaard <frodol@dds.nl>
3 4
4 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
5 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
6 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
94{ 95{
95 output_simple_chars(config,list,"</BODY>\n",enc); 96 output_simple_chars(config,list,"</BODY>\n",enc);
96 output_simple_chars(config,list,"</HTML>\n",enc); 97 output_simple_chars(config,list,"</HTML>\n",enc);
97} 98}
98 99
100int character_layout_equal(const psiconv_character_layout l1,
101 const psiconv_character_layout l2)
102{
103 int font_size1,font_size2;
99 104
105 font_size1 = l1->font_size < 8 ?1:
106 l1->font_size < 10 ?2:
107 l1->font_size < 13 ?3:
108 l1->font_size < 17 ?4:
109 l1->font_size < 24 ?5:
110 l1->font_size < 36 ?6:7;
111 font_size2 = l2->font_size < 8 ?1:
112 l2->font_size < 10 ?2:
113 l2->font_size < 13 ?3:
114 l2->font_size < 17 ?4:
115 l2->font_size < 24 ?5:
116 l2->font_size < 36 ?6:7;
117
118 return (l1 && l2 &&
119 (l1->color->red == l2->color->red) &&
120 (l1->color->green == l2->color->green) &&
121 (l1->color->blue == l2->color->blue) &&
122 (font_size1 == font_size2) &&
123 (l1->italic == l2->italic) &&
124 (l1->bold == l2->bold) &&
125 (l1->super_sub == l2->super_sub) &&
126 (l1->underline == l2->underline) &&
127 (l1->strikethrough == l2->strikethrough) &&
128 (l1->font->screenfont == l2->font->screenfont));
129}
130
100void characters(const psiconv_config config, psiconv_list list, 131void characters(const psiconv_config config, psiconv_list list,
101 const psiconv_string_t textstr, 132 const psiconv_string_t textstr,
102 const psiconv_character_layout layout,const encoding enc) 133 const psiconv_character_layout layout,const encoding enc)
103{ 134{
104 char tempstr[TEMPSTR_LEN]; 135 char tempstr[TEMPSTR_LEN];
165} 196}
166 197
167void paragraph(const psiconv_config config, psiconv_list list, 198void paragraph(const psiconv_config config, psiconv_list list,
168 psiconv_paragraph para, const encoding enc) 199 psiconv_paragraph para, const encoding enc)
169{ 200{
170 int i,charnr; 201 int i,charnr,start,len;
171 psiconv_string_t text; 202 psiconv_string_t text;
172 psiconv_in_line_layout layout; 203 psiconv_in_line_layout layout,next_layout;
173 204
174 205
175 output_simple_chars(config,list, 206 output_simple_chars(config,list,
176 para->base_paragraph->bullet->on?"<UL><LI":"<P",enc); 207 para->base_paragraph->bullet->on?"<UL><LI":"<P",enc);
177 208
183 output_simple_chars(config,list," align=justify",enc); 214 output_simple_chars(config,list," align=justify",enc);
184 215
185 output_simple_chars(config,list,">",enc); 216 output_simple_chars(config,list,">",enc);
186 217
187 if (psiconv_list_length(para->in_lines) == 0) { 218 if (psiconv_list_length(para->in_lines) == 0) {
219 if (psiconv_unicode_strlen(para->text))
188 characters(config,list,para->text,para->base_character,enc); 220 characters(config,list,para->text,para->base_character,enc);
189 } else { 221 } else {
190 charnr = 0; 222 charnr = 0;
223 start = -1;
191 for (i = 0; i < psiconv_list_length(para->in_lines); i++) { 224 for (i = 0; i < psiconv_list_length(para->in_lines); i++) {
225 if (start < 0)
226 start = charnr;
192 if (!(layout = psiconv_list_get(para->in_lines,i))) { 227 if (!(layout = psiconv_list_get(para->in_lines,i))) {
193 fputs("Internal data structures corruption\n",stderr); 228 fputs("Internal data structures corruption\n",stderr);
194 exit(1); 229 exit(1);
195 } 230 }
196 if (!(text = malloc(sizeof (*text) * (layout->length + 1)))) { 231 if (i+1 < psiconv_list_length(para->in_lines)) {
197 fputs("Out of memory error\n",stderr); 232 if (!(next_layout = psiconv_list_get(para->in_lines,i+1))) {
233 fputs("Internal data structures corruption\n",stderr);
198 exit(1); 234 exit(1);
235 }
236 } else {
237 next_layout = NULL;
199 } 238 }
239 if (next_layout &&
240 character_layout_equal(layout->layout,next_layout->layout)) {
241 charnr += layout->length;
242 continue;
243 }
244 len = charnr - start + layout->length;
245 if (len) {
246 if (!(text = malloc(sizeof (*text) * (len + 1)))) {
247 fputs("Out of memory error\n",stderr);
248 exit(1);
249 }
200 memcpy(text,para->text+charnr,layout->length * sizeof(*text)); 250 memcpy(text,para->text+charnr,len * sizeof(*text));
201 text[layout->length] = 0; 251 text[len] = 0;
202 characters(config,list,text,layout->layout,enc); 252 characters(config,list,text,layout->layout,enc);
203 free(text); 253 free(text);
254 }
204 charnr += layout->length; 255 charnr += layout->length;
256 start = -1;
205 } 257 }
206 } 258 }
207 output_simple_chars(config, list, 259 output_simple_chars(config, list,
208 para->base_paragraph->bullet->on?"</UL>\n":"\n",enc); 260 para->base_paragraph->bullet->on?"</UL>\n":"\n",enc);
209} 261}
263 } else 315 } else
264 return -1; 316 return -1;
265} 317}
266 318
267 319
268static struct fileformat_s ffs[] = 320static struct fileformat_s fileformats[] =
269 { 321 {
270 { 322 {
271 "HTML4", 323 "HTML4",
272 "HTML 4.01 Transitional, without CSS", 324 "HTML 4.01 Transitional, without CSS",
273 FORMAT_WORD | FORMAT_TEXTED, 325 FORMAT_WORD | FORMAT_TEXTED,
283 335
284 336
285void init_html4(void) 337void init_html4(void)
286{ 338{
287 int i; 339 int i;
288 for (i = 0; ffs[i].name; i++) 340 for (i = 0; fileformats[i].name; i++)
289 psiconv_list_add(fileformat_list,ffs+i); 341 psiconv_list_add(fileformat_list,fileformats+i);
290} 342}

Legend:
Removed from v.193  
changed lines
  Added in v.267

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