/[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 53 Revision 142
21#include "config.h" 21#include "config.h"
22#include <stdio.h> 22#include <stdio.h>
23#include <string.h> 23#include <string.h>
24#include <ctype.h> 24#include <ctype.h>
25#include <stdlib.h> 25#include <stdlib.h>
26#include "data.h" 26#include "psiconv/data.h"
27#include "list.h" 27#include "psiconv/list.h"
28#include "gen.h" 28#include "gen.h"
29#include "psiconv.h" 29#include "psiconv.h"
30 30
31#ifndef TRUE 31#ifndef TRUE
32#define TRUE (0==0) 32#define TRUE (0==0)
33#endif
34
35#ifdef DMALLOC
36#include "dmalloc.h"
33#endif 37#endif
34 38
35/* 39/*
36 * Various string tables for HTML4 settings 40 * Various string tables for HTML4 settings
37 */ 41 */
130 } 134 }
131} 135}
132 136
133static const char *screenfont_name(psiconv_u8 screenfont) 137static const char *screenfont_name(psiconv_u8 screenfont)
134{ 138{
135 if (screenfont == 1) 139 if (screenfont == psiconv_font_sansserif)
136 return "sans-serif"; 140 return "sans-serif";
137 else if (screenfont == 2) 141 else if (screenfont == psiconv_font_nonprop)
138 return "monospace"; 142 return "monospace";
139 else if (screenfont == 3) 143 else if (screenfont == psiconv_font_serif)
140 return "serif"; 144 return "serif";
141 else 145 else
142 return "serif"; 146 return "serif";
143} 147}
144 148
210/* Paragraph formats */ 214/* Paragraph formats */
211static int paragraph_layouts_different( 215static int paragraph_layouts_different(
212 const psiconv_paragraph_layout old, 216 const psiconv_paragraph_layout old,
213 const psiconv_paragraph_layout new) 217 const psiconv_paragraph_layout new)
214{ 218{
215 return ((old->top_space != new->top_space) || 219 return ((old->space_above != new->space_above) ||
216 (old->indent_right != new->indent_right) || 220 (old->indent_right != new->indent_right) ||
217 (old->bottom_space != new->bottom_space) || 221 (old->space_below != new->space_below) ||
218 (old->indent_left != new->indent_left) || 222 (old->indent_left != new->indent_left) ||
219 (old->indent_first != new->indent_first) || 223 (old->indent_first != new->indent_first) ||
220 (old->justify_hor != new->justify_hor) || 224 (old->justify_hor != new->justify_hor) ||
221 (old->interline_exact != new->interline_exact) || 225 (old->linespacing_exact != new->linespacing_exact) ||
222 borders_different(old->left_border, new->left_border) || 226 borders_different(old->left_border, new->left_border) ||
223 borders_different(old->right_border, new->right_border) || 227 borders_different(old->right_border, new->right_border) ||
224 borders_different(old->top_border, new->top_border) || 228 borders_different(old->top_border, new->top_border) ||
225 borders_different(old->bottom_border, new->bottom_border)); 229 borders_different(old->bottom_border, new->bottom_border));
226} 230}
227 231
228static void fput_paragraph_layout(FILE * of, 232static void fput_paragraph_layout(FILE * of,
229 const psiconv_paragraph_layout old, 233 const psiconv_paragraph_layout old,
230 const psiconv_paragraph_layout new) 234 const psiconv_paragraph_layout new)
231{ 235{
232 if (!old || (old->top_space != new->top_space)) 236 if (!old || (old->space_above != new->space_above))
233 fprintf(of, "margin-top:%.1fpt;", new->top_space); 237 fprintf(of, "margin-top:%.1fpt;", new->space_above);
234 if (!old || (old->indent_right != new->indent_right)) 238 if (!old || (old->indent_right != new->indent_right))
235 fprintf(of, "margin-right:%.2fcm;", new->indent_right); 239 fprintf(of, "margin-right:%.2fcm;", new->indent_right);
236 if (!old || (old->bottom_space != new->bottom_space)) 240 if (!old || (old->space_below != new->space_below))
237 fprintf(of, "margin-bottom:%.1fpt;", new->bottom_space); 241 fprintf(of, "margin-bottom:%.1fpt;", new->space_below);
238 if (!old || 242 if (!old ||
239 (old->bullet->on != new->bullet->on) || 243 (old->bullet->on != new->bullet->on) ||
240 (old->bullet->indent != new->bullet->indent) || 244 (old->bullet->indent != new->bullet->indent) ||
241 (old->indent_left != new->indent_left) || 245 (old->indent_left != new->indent_left) ||
242 (old->indent_first != new->indent_first)) { 246 (old->indent_first != new->indent_first)) {
252 fprintf(of, "margin-left:%.2fcm;", margin); 256 fprintf(of, "margin-left:%.2fcm;", margin);
253 fprintf(of, "text-indent:%.2fcm;", indent); 257 fprintf(of, "text-indent:%.2fcm;", indent);
254 } 258 }
255 if (!old || (old->justify_hor != new->justify_hor)) 259 if (!old || (old->justify_hor != new->justify_hor))
256 fprintf(of, "text-align:%s;", justify_strings[new->justify_hor]); 260 fprintf(of, "text-align:%s;", justify_strings[new->justify_hor]);
257 if (!old || (old->interline_exact != new->interline_exact)) { 261 if (!old || (old->linespacing_exact != new->linespacing_exact)) {
258 if (!old || old->interline_exact) 262 if (!old || old->linespacing_exact)
259 fputs("line-height:normal;", of); 263 fputs("line-height:normal;", of);
260 else 264 else
261 fprintf(of, "line-height:%.1fpt;", new->interline); 265 fprintf(of, "line-height:%.1fpt;", new->linespacing);
262 } 266 }
263 fput_border(of, "left", old ? old->left_border : NULL, 267 fput_border(of, "left", old ? old->left_border : NULL,
264 new->left_border); 268 new->left_border);
265 fput_border(of, "right", old ? old->right_border : NULL, 269 fput_border(of, "right", old ? old->right_border : NULL,
266 new->right_border); 270 new->right_border);
286 (old->back_color->blue != new->back_color->blue) || 290 (old->back_color->blue != new->back_color->blue) ||
287 (old->italic != new->italic) || 291 (old->italic != new->italic) ||
288 (old->bold != new->bold) || 292 (old->bold != new->bold) ||
289 (old->super_sub != new->super_sub) || 293 (old->super_sub != new->super_sub) ||
290 (old->underline != new->underline) || 294 (old->underline != new->underline) ||
291 (old->strike_out != new->strike_out)); 295 (old->strikethrough != new->strikethrough));
292} 296}
293 297
294static void fput_character_layout(FILE * of, 298static void fput_character_layout(FILE * of,
295 const psiconv_character_layout old, 299 const psiconv_character_layout old,
296 const psiconv_character_layout new, 300 const psiconv_character_layout new,
315 fprintf(of, "background-color:#%02x%02x%02x;", 319 fprintf(of, "background-color:#%02x%02x%02x;",
316 new->back_color->red, new->back_color->green, new->back_color->blue); 320 new->back_color->red, new->back_color->green, new->back_color->blue);
317 if (!old || (old->super_sub != new->super_sub)) 321 if (!old || (old->super_sub != new->super_sub))
318 fprintf(of, "vertical-align:%s;", vertical_strings[new->super_sub]); 322 fprintf(of, "vertical-align:%s;", vertical_strings[new->super_sub]);
319 if (!old || (old->underline != new->underline) || 323 if (!old || (old->underline != new->underline) ||
320 (old->strike_out != new->strike_out)) { 324 (old->strikethrough != new->strikethrough)) {
321 fputs("text-decoration:", of); 325 fputs("text-decoration:", of);
322 if (new->strike_out) 326 if (new->strikethrough)
323 fputs("line-through ", of); 327 fputs("line-through ", of);
324 if (new->underline) 328 if (new->underline)
325 fputs("underline", of); 329 fputs("underline", of);
326 else if (!new->strike_out) 330 else if (!new->strikethrough)
327 fputs("none", of); 331 fputs("none", of);
328 fputs(";", of); 332 fputs(";", of);
329 } 333 }
330} 334}
331 335
468 472
469 fputs("<!doctype html public \"-//W3C//DTD HTML 4.0 STRICT//EN\">", of); 473 fputs("<!doctype html public \"-//W3C//DTD HTML 4.0 STRICT//EN\">", of);
470 fputs("\n<HTML>\n<HEAD>\n <META NAME=\"GENERATOR\"", of); 474 fputs("\n<HTML>\n<HEAD>\n <META NAME=\"GENERATOR\"", of);
471 fputs(" CONTENT=\"psiconv-" VERSION "\">\n", of); 475 fputs(" CONTENT=\"psiconv-" VERSION "\">\n", of);
472 476
477 if (wf->page_sec->header->text) {
473 if (psiconv_list_length(wf->page_sec->header->text->paragraphs) > 0) { 478 if (psiconv_list_length(wf->page_sec->header->text->paragraphs) > 0) {
474 fputs(" <TITLE>", of); 479 fputs(" <TITLE>", of);
475 para = psiconv_list_get(wf->page_sec->header->text->paragraphs, 0); 480 para = psiconv_list_get(wf->page_sec->header->text->paragraphs, 0);
476 i = 0; 481 i = 0;
477 fput_text(of, para->text, strlen(para->text), &i); 482 fput_text(of, para->text, strlen(para->text), &i);
478 fputs("</TITLE>\n", of); 483 fputs("</TITLE>\n", of);
484 }
479 } 485 }
480 486
481 normal = wf->styles_sec->normal; 487 normal = wf->styles_sec->normal;
482 fputs(" <STYLE TYPE=\"text/css\"><!--\n", of); 488 fputs(" <STYLE TYPE=\"text/css\"><!--\n", of);
483 fprintf(of," BODY { background-color: #%02x%02x%02x }\n", 489 fprintf(of," BODY { background-color: #%02x%02x%02x }\n",
488 for (i = 0; i < psiconv_list_length(wf->styles_sec->styles); i++) { 494 for (i = 0; i < psiconv_list_length(wf->styles_sec->styles); i++) {
489 sty = psiconv_list_get(wf->styles_sec->styles, i); 495 sty = psiconv_list_get(wf->styles_sec->styles, i);
490 fput_style(of, normal, sty, wf); 496 fput_style(of, normal, sty, wf);
491 } 497 }
492 fputs(" --></STYLE>\n</HEAD>\n<BODY>\n", of); 498 fputs(" --></STYLE>\n</HEAD>\n<BODY>\n", of);
499 if (wf->page_sec->header->text) {
493 for (i = 0; i < psiconv_list_length(wf->paragraphs); i++) { 500 for (i = 0; i < psiconv_list_length(wf->paragraphs); i++) {
494 para = psiconv_list_get(wf->paragraphs, i); 501 para = psiconv_list_get(wf->paragraphs, i);
495 fput_para(of, para, wf); 502 fput_para(of, para, wf);
503 }
496 } 504 }
497 fputs("</BODY>\n</HTML>\n", of); 505 fputs("</BODY>\n</HTML>\n", of);
498 506
499 return fclose(of); 507 return fclose(of);
500} 508}
501 509
502static struct psiconv_fileformat ff = 510static struct psiconv_fileformat_s ff =
503 { 511 {
504 "HTML4", 512 "HTML4",
505 "HTML 4.0 with cascading style sheets", 513 "HTML 4.0 with cascading style sheets",
506 psiconv_gen_html4 514 psiconv_gen_html4
507 }; 515 };

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

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