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

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

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