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

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

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

Revision 14 Revision 142
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"
28
29#ifdef DMALLOC
30#include "dmalloc.h"
31#endif
27 32
28/* This determines for each character how it is displayed */ 33/* This determines for each character how it is displayed */
29static const char *char_table[0x100] = 34static const char *char_table[0x100] =
30{ 35{
31 /* 0x00 */ "" ,"" ,"" ,"" ,"" ,"" ,"<P> ","<BR>" , 36 /* 0x00 */ "" ,"" ,"" ,"" ,"" ,"" ,"<P> ","<BR>" ,
90 This one is specific for the base point of HTML */ 95 This one is specific for the base point of HTML */
91psiconv_character_layout gen_base_char(const psiconv_font font, 96psiconv_character_layout gen_base_char(const psiconv_font font,
92 const psiconv_color color, 97 const psiconv_color color,
93 const psiconv_color back_color) 98 const psiconv_color back_color)
94{ 99{
95 struct psiconv_character_layout base_char_struct = 100 struct psiconv_character_layout_s base_char_struct =
96 { 101 {
97 color, /* color */ 102 NULL, /* color */
98 back_color, /* back_color */ 103 NULL, /* back_color */
99 13.0, /* font_size */ 104 13.0, /* font_size */
100 psiconv_bool_false, /* italic */ 105 psiconv_bool_false, /* italic */
101 psiconv_bool_false, /* bold */ 106 psiconv_bool_false, /* bold */
102 psiconv_normalscript, /* super_sub */ 107 psiconv_normalscript, /* super_sub */
103 psiconv_bool_false, /* underline */ 108 psiconv_bool_false, /* underline */
104 psiconv_bool_false, /* strike_out */ 109 psiconv_bool_false, /* strikethrough */
105 font, /* font */ 110 NULL, /* font */
106 }; 111 };
112 base_char_struct.color = color;
113 base_char_struct.back_color = back_color;
114 base_char_struct.font = font;
107 return psiconv_clone_character_layout(&base_char_struct); 115 return psiconv_clone_character_layout(&base_char_struct);
108} 116}
109 117
110/* flags & 1: 0 if no <FONT> was yet generated. 118/* flags & 1: 0 if no <FONT> was yet generated.
111 flags & 2: 1 if at end-of-paragraph 119 flags & 2: 1 if at end-of-paragraph
127 fputs("</I>",of); 135 fputs("</I>",of);
128 if (old->bold) 136 if (old->bold)
129 fputs("</B>",of); 137 fputs("</B>",of);
130 if (old->underline) 138 if (old->underline)
131 fputs("</U>",of); 139 fputs("</U>",of);
132 if (old->strike_out) 140 if (old->strikethrough)
133 fputs("</STRIKE>",of); 141 fputs("</STRIKE>",of);
134 if (old->super_sub == psiconv_superscript) 142 if (old->super_sub == psiconv_superscript)
135 fputs("</SUP>",of); 143 fputs("</SUP>",of);
136 if (old->super_sub == psiconv_subscript) 144 if (old->super_sub == psiconv_subscript)
137 fputs("</SUB>",of); 145 fputs("</SUB>",of);
154 fputs("6",of); 162 fputs("6",of);
155 else 163 else
156 fputs("7",of); 164 fputs("7",of);
157 fprintf(of," COLOR=#%02x%02x%02x",new->color->red,new->color->green, 165 fprintf(of," COLOR=#%02x%02x%02x",new->color->red,new->color->green,
158 new->color->blue); 166 new->color->blue);
159 if (new->font->screenfont == 1) 167 if (new->font->screenfont == psiconv_font_sansserif)
160 fprintf(of," FACE=\"%s, Sans-Serif\">",new->font->name); 168 fprintf(of," FACE=\"%s, Sans-Serif\">",new->font->name);
161 else if (new->font->screenfont == 2) 169 else if (new->font->screenfont == psiconv_font_nonprop)
162 fprintf(of," FACE=\"%s, Monospace\">",new->font-> name); 170 fprintf(of," FACE=\"%s, Monospace\">",new->font-> name);
163 else if (new->font->screenfont == 3) 171 else if (new->font->screenfont == psiconv_font_serif)
164 fprintf(of," FACE=\"%s, Serif\">",new->font-> name); 172 fprintf(of," FACE=\"%s, Serif\">",new->font-> name);
165 else 173 else
166 fprintf(of," FACE=\"%s, Serif\">",new->font-> name); 174 fprintf(of," FACE=\"%s, Serif\">",new->font-> name);
167 } 175 }
168 if (new->italic) 176 if (new->italic)
169 fputs("<I>",of); 177 fputs("<I>",of);
170 if (new->bold) 178 if (new->bold)
171 fputs("<B>",of); 179 fputs("<B>",of);
172 if (new->underline) 180 if (new->underline)
173 fputs("<U>",of); 181 fputs("<U>",of);
174 if (new->strike_out) 182 if (new->strikethrough)
175 fputs("<STRIKE>",of); 183 fputs("<STRIKE>",of);
176 if (new->super_sub == psiconv_superscript) 184 if (new->super_sub == psiconv_superscript)
177 fputs("<SUP>",of); 185 fputs("<SUP>",of);
178 if (new->super_sub == psiconv_subscript) 186 if (new->super_sub == psiconv_subscript)
179 fputs("<SUB>",of); 187 fputs("<SUB>",of);
194 if (old->underline) 202 if (old->underline)
195 fputs("</U>",of); 203 fputs("</U>",of);
196 else 204 else
197 fputs("<U>",of); 205 fputs("<U>",of);
198 } 206 }
199 if (old->strike_out != new->strike_out) { 207 if (old->strikethrough != new->strikethrough) {
200 if (old->strike_out) 208 if (old->strikethrough)
201 fputs("</STRIKE>",of); 209 fputs("</STRIKE>",of);
202 else 210 else
203 fputs("<STRIKE>",of); 211 fputs("<STRIKE>",of);
204 } 212 }
205 if (old->super_sub != new->super_sub) { 213 if (old->super_sub != new->super_sub) {
273 fputs("</UL>",of); 281 fputs("</UL>",of);
274 282
275 fputs("</P>\n",of); 283 fputs("</P>\n",of);
276} 284}
277 285
278void psiconv_gen_html(FILE *of,psiconv_file file) 286int psiconv_gen_html(const char * filename,const psiconv_file file,
287 const char *dest)
279{ 288{
289 FILE *of = fopen(filename,"w");
290 if (! of)
291 return -1;
292
280 if (file->type == psiconv_word_file) 293 if (file->type == psiconv_word_file) {
281 psiconv_gen_html_word(of,(psiconv_word_f) file->file); 294 psiconv_gen_html_word(of,(psiconv_word_f) file->file);
282 else if (file->type == psiconv_texted_file) 295 } else if (file->type == psiconv_texted_file) {
283 psiconv_gen_html_texted(of,(psiconv_texted_f) file->file); 296 psiconv_gen_html_texted(of,(psiconv_texted_f) file->file);
284 else 297 } else {
298 fclose(of);
285 return; 299 return -1;
300 }
301 return fclose(of);
286} 302}
287 303
288void psiconv_gen_html_texted(FILE *of,psiconv_texted_f tf) 304void psiconv_gen_html_texted(FILE *of,psiconv_texted_f tf)
289{ 305{
290 psiconv_character_layout base_char; 306 psiconv_character_layout base_char;
341 } 357 }
342 fputs("</BODY>\n</HTML>\n",of); 358 fputs("</BODY>\n</HTML>\n",of);
343 psiconv_free_character_layout(base_char); 359 psiconv_free_character_layout(base_char);
344} 360}
345 361
362static struct psiconv_fileformat_s ff =
363 {
364 "HTML3",
365 "HTML 3.2, not verified so probably not completely compliant",
366 &psiconv_gen_html
367 };
346 368
369void init_html(void)
370{
371 psiconv_list_add(fileformat_list,&ff);
372}

Legend:
Removed from v.14  
changed lines
  Added in v.142

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