… | |
… | |
19 | |
19 | |
20 | #include "config.h" |
20 | #include "config.h" |
21 | #include <stdio.h> |
21 | #include <stdio.h> |
22 | #include <string.h> |
22 | #include <string.h> |
23 | #include <stdlib.h> |
23 | #include <stdlib.h> |
24 | #include "data.h" |
24 | #include "psiconv/data.h" |
25 | #include "list.h" |
25 | #include "psiconv/list.h" |
26 | #include "gen.h" |
26 | #include "gen.h" |
|
|
27 | #include "psiconv.h" |
27 | |
28 | |
28 | /* This determines for each character how it is displayed */ |
29 | /* This determines for each character how it is displayed */ |
29 | static const char *char_table[0x100] = |
30 | static const char *char_table[0x100] = |
30 | { |
31 | { |
31 | /* 0x00 */ "" ,"" ,"" ,"" ,"" ,"" ,"<P> ","<BR>" , |
32 | /* 0x00 */ "" ,"" ,"" ,"" ,"" ,"" ,"<P> ","<BR>" , |
… | |
… | |
90 | This one is specific for the base point of HTML */ |
91 | This one is specific for the base point of HTML */ |
91 | psiconv_character_layout gen_base_char(const psiconv_font font, |
92 | psiconv_character_layout gen_base_char(const psiconv_font font, |
92 | const psiconv_color color, |
93 | const psiconv_color color, |
93 | const psiconv_color back_color) |
94 | const psiconv_color back_color) |
94 | { |
95 | { |
95 | struct psiconv_character_layout base_char_struct = |
96 | struct psiconv_character_layout_s base_char_struct = |
96 | { |
97 | { |
97 | NULL, /* color */ |
98 | NULL, /* color */ |
98 | NULL, /* back_color */ |
99 | NULL, /* back_color */ |
99 | 13.0, /* font_size */ |
100 | 13.0, /* font_size */ |
100 | psiconv_bool_false, /* italic */ |
101 | psiconv_bool_false, /* italic */ |
101 | psiconv_bool_false, /* bold */ |
102 | psiconv_bool_false, /* bold */ |
102 | psiconv_normalscript, /* super_sub */ |
103 | psiconv_normalscript, /* super_sub */ |
103 | psiconv_bool_false, /* underline */ |
104 | psiconv_bool_false, /* underline */ |
104 | psiconv_bool_false, /* strike_out */ |
105 | psiconv_bool_false, /* strikethrough */ |
105 | NULL, /* font */ |
106 | NULL, /* font */ |
106 | }; |
107 | }; |
107 | base_char_struct.color = color; |
108 | base_char_struct.color = color; |
108 | base_char_struct.back_color = back_color; |
109 | base_char_struct.back_color = back_color; |
109 | base_char_struct.font = font; |
110 | base_char_struct.font = font; |
… | |
… | |
130 | fputs("</I>",of); |
131 | fputs("</I>",of); |
131 | if (old->bold) |
132 | if (old->bold) |
132 | fputs("</B>",of); |
133 | fputs("</B>",of); |
133 | if (old->underline) |
134 | if (old->underline) |
134 | fputs("</U>",of); |
135 | fputs("</U>",of); |
135 | if (old->strike_out) |
136 | if (old->strikethrough) |
136 | fputs("</STRIKE>",of); |
137 | fputs("</STRIKE>",of); |
137 | if (old->super_sub == psiconv_superscript) |
138 | if (old->super_sub == psiconv_superscript) |
138 | fputs("</SUP>",of); |
139 | fputs("</SUP>",of); |
139 | if (old->super_sub == psiconv_subscript) |
140 | if (old->super_sub == psiconv_subscript) |
140 | fputs("</SUB>",of); |
141 | fputs("</SUB>",of); |
… | |
… | |
157 | fputs("6",of); |
158 | fputs("6",of); |
158 | else |
159 | else |
159 | fputs("7",of); |
160 | fputs("7",of); |
160 | fprintf(of," COLOR=#%02x%02x%02x",new->color->red,new->color->green, |
161 | fprintf(of," COLOR=#%02x%02x%02x",new->color->red,new->color->green, |
161 | new->color->blue); |
162 | new->color->blue); |
162 | if (new->font->screenfont == 1) |
163 | if (new->font->screenfont == psiconv_font_sansserif) |
163 | fprintf(of," FACE=\"%s, Sans-Serif\">",new->font->name); |
164 | fprintf(of," FACE=\"%s, Sans-Serif\">",new->font->name); |
164 | else if (new->font->screenfont == 2) |
165 | else if (new->font->screenfont == psiconv_font_nonprop) |
165 | fprintf(of," FACE=\"%s, Monospace\">",new->font-> name); |
166 | fprintf(of," FACE=\"%s, Monospace\">",new->font-> name); |
166 | else if (new->font->screenfont == 3) |
167 | else if (new->font->screenfont == psiconv_font_serif) |
167 | fprintf(of," FACE=\"%s, Serif\">",new->font-> name); |
168 | fprintf(of," FACE=\"%s, Serif\">",new->font-> name); |
168 | else |
169 | else |
169 | fprintf(of," FACE=\"%s, Serif\">",new->font-> name); |
170 | fprintf(of," FACE=\"%s, Serif\">",new->font-> name); |
170 | } |
171 | } |
171 | if (new->italic) |
172 | if (new->italic) |
172 | fputs("<I>",of); |
173 | fputs("<I>",of); |
173 | if (new->bold) |
174 | if (new->bold) |
174 | fputs("<B>",of); |
175 | fputs("<B>",of); |
175 | if (new->underline) |
176 | if (new->underline) |
176 | fputs("<U>",of); |
177 | fputs("<U>",of); |
177 | if (new->strike_out) |
178 | if (new->strikethrough) |
178 | fputs("<STRIKE>",of); |
179 | fputs("<STRIKE>",of); |
179 | if (new->super_sub == psiconv_superscript) |
180 | if (new->super_sub == psiconv_superscript) |
180 | fputs("<SUP>",of); |
181 | fputs("<SUP>",of); |
181 | if (new->super_sub == psiconv_subscript) |
182 | if (new->super_sub == psiconv_subscript) |
182 | fputs("<SUB>",of); |
183 | fputs("<SUB>",of); |
… | |
… | |
197 | if (old->underline) |
198 | if (old->underline) |
198 | fputs("</U>",of); |
199 | fputs("</U>",of); |
199 | else |
200 | else |
200 | fputs("<U>",of); |
201 | fputs("<U>",of); |
201 | } |
202 | } |
202 | if (old->strike_out != new->strike_out) { |
203 | if (old->strikethrough != new->strikethrough) { |
203 | if (old->strike_out) |
204 | if (old->strikethrough) |
204 | fputs("</STRIKE>",of); |
205 | fputs("</STRIKE>",of); |
205 | else |
206 | else |
206 | fputs("<STRIKE>",of); |
207 | fputs("<STRIKE>",of); |
207 | } |
208 | } |
208 | if (old->super_sub != new->super_sub) { |
209 | if (old->super_sub != new->super_sub) { |
… | |
… | |
276 | fputs("</UL>",of); |
277 | fputs("</UL>",of); |
277 | |
278 | |
278 | fputs("</P>\n",of); |
279 | fputs("</P>\n",of); |
279 | } |
280 | } |
280 | |
281 | |
281 | void psiconv_gen_html(FILE *of,psiconv_file file) |
282 | int psiconv_gen_html(const char * filename,const psiconv_file file, |
|
|
283 | const char *dest) |
282 | { |
284 | { |
|
|
285 | FILE *of = fopen(filename,"w"); |
|
|
286 | if (! of) |
|
|
287 | return -1; |
|
|
288 | |
283 | if (file->type == psiconv_word_file) |
289 | if (file->type == psiconv_word_file) { |
284 | psiconv_gen_html_word(of,(psiconv_word_f) file->file); |
290 | psiconv_gen_html_word(of,(psiconv_word_f) file->file); |
285 | else if (file->type == psiconv_texted_file) |
291 | } else if (file->type == psiconv_texted_file) { |
286 | psiconv_gen_html_texted(of,(psiconv_texted_f) file->file); |
292 | psiconv_gen_html_texted(of,(psiconv_texted_f) file->file); |
287 | else |
293 | } else { |
|
|
294 | fclose(of); |
288 | return; |
295 | return -1; |
|
|
296 | } |
|
|
297 | return fclose(of); |
289 | } |
298 | } |
290 | |
299 | |
291 | void psiconv_gen_html_texted(FILE *of,psiconv_texted_f tf) |
300 | void psiconv_gen_html_texted(FILE *of,psiconv_texted_f tf) |
292 | { |
301 | { |
293 | psiconv_character_layout base_char; |
302 | psiconv_character_layout base_char; |
… | |
… | |
344 | } |
353 | } |
345 | fputs("</BODY>\n</HTML>\n",of); |
354 | fputs("</BODY>\n</HTML>\n",of); |
346 | psiconv_free_character_layout(base_char); |
355 | psiconv_free_character_layout(base_char); |
347 | } |
356 | } |
348 | |
357 | |
|
|
358 | static struct psiconv_fileformat_s ff = |
|
|
359 | { |
|
|
360 | "HTML3", |
|
|
361 | "HTML 3.2, not verified so probably not completely compliant", |
|
|
362 | &psiconv_gen_html |
|
|
363 | }; |
349 | |
364 | |
|
|
365 | void init_html(void) |
|
|
366 | { |
|
|
367 | psiconv_list_add(fileformat_list,&ff); |
|
|
368 | } |