--- psiconv/trunk/program/psiconv/gen_html4.c 1999/10/11 19:17:17 14
+++ psiconv/trunk/program/psiconv/gen_html4.c 2002/01/29 18:38:38 142
@@ -23,14 +23,19 @@
#include
#include
#include
-#include "data.h"
-#include "list.h"
+#include "psiconv/data.h"
+#include "psiconv/list.h"
#include "gen.h"
+#include "psiconv.h"
#ifndef TRUE
#define TRUE (0==0)
#endif
+#ifdef DMALLOC
+#include "dmalloc.h"
+#endif
+
/*
* Various string tables for HTML4 settings
*/
@@ -131,11 +136,11 @@
static const char *screenfont_name(psiconv_u8 screenfont)
{
- if (screenfont == 1)
+ if (screenfont == psiconv_font_sansserif)
return "sans-serif";
- else if (screenfont == 2)
+ else if (screenfont == psiconv_font_nonprop)
return "monospace";
- else if (screenfont == 3)
+ else if (screenfont == psiconv_font_serif)
return "serif";
else
return "serif";
@@ -211,13 +216,13 @@
const psiconv_paragraph_layout old,
const psiconv_paragraph_layout new)
{
- return ((old->top_space != new->top_space) ||
+ return ((old->space_above != new->space_above) ||
(old->indent_right != new->indent_right) ||
- (old->bottom_space != new->bottom_space) ||
+ (old->space_below != new->space_below) ||
(old->indent_left != new->indent_left) ||
(old->indent_first != new->indent_first) ||
(old->justify_hor != new->justify_hor) ||
- (old->interline_exact != new->interline_exact) ||
+ (old->linespacing_exact != new->linespacing_exact) ||
borders_different(old->left_border, new->left_border) ||
borders_different(old->right_border, new->right_border) ||
borders_different(old->top_border, new->top_border) ||
@@ -228,12 +233,12 @@
const psiconv_paragraph_layout old,
const psiconv_paragraph_layout new)
{
- if (!old || (old->top_space != new->top_space))
- fprintf(of, "margin-top:%.1fpt;", new->top_space);
+ if (!old || (old->space_above != new->space_above))
+ fprintf(of, "margin-top:%.1fpt;", new->space_above);
if (!old || (old->indent_right != new->indent_right))
fprintf(of, "margin-right:%.2fcm;", new->indent_right);
- if (!old || (old->bottom_space != new->bottom_space))
- fprintf(of, "margin-bottom:%.1fpt;", new->bottom_space);
+ if (!old || (old->space_below != new->space_below))
+ fprintf(of, "margin-bottom:%.1fpt;", new->space_below);
if (!old ||
(old->bullet->on != new->bullet->on) ||
(old->bullet->indent != new->bullet->indent) ||
@@ -253,11 +258,11 @@
}
if (!old || (old->justify_hor != new->justify_hor))
fprintf(of, "text-align:%s;", justify_strings[new->justify_hor]);
- if (!old || (old->interline_exact != new->interline_exact)) {
- if (!old || old->interline_exact)
+ if (!old || (old->linespacing_exact != new->linespacing_exact)) {
+ if (!old || old->linespacing_exact)
fputs("line-height:normal;", of);
else
- fprintf(of, "line-height:%.1fpt;", new->interline);
+ fprintf(of, "line-height:%.1fpt;", new->linespacing);
}
fput_border(of, "left", old ? old->left_border : NULL,
new->left_border);
@@ -287,7 +292,7 @@
(old->bold != new->bold) ||
(old->super_sub != new->super_sub) ||
(old->underline != new->underline) ||
- (old->strike_out != new->strike_out));
+ (old->strikethrough != new->strikethrough));
}
static void fput_character_layout(FILE * of,
@@ -316,13 +321,13 @@
if (!old || (old->super_sub != new->super_sub))
fprintf(of, "vertical-align:%s;", vertical_strings[new->super_sub]);
if (!old || (old->underline != new->underline) ||
- (old->strike_out != new->strike_out)) {
+ (old->strikethrough != new->strikethrough)) {
fputs("text-decoration:", of);
- if (new->strike_out)
+ if (new->strikethrough)
fputs("line-through ", of);
if (new->underline)
fputs("underline", of);
- else if (!new->strike_out)
+ else if (!new->strikethrough)
fputs("none", of);
fputs(";", of);
}
@@ -446,8 +451,10 @@
fputs("}\n", of);
}
-void psiconv_gen_html4(FILE * of, psiconv_file file)
+static int psiconv_gen_html4(const char *filename, const psiconv_file file,
+ const char *dest)
{
+ FILE * of;
int i;
psiconv_paragraph para;
psiconv_word_style normal, sty;
@@ -457,20 +464,24 @@
wf = file->file;
else {
/* Fall back on the normal HTML generator */
- psiconv_gen_html(of,file);
- return;
+ return psiconv_gen_html(filename,file,dest);
}
+ if (! (of = fopen(filename,"w")))
+ return -1;
+
fputs("", of);
fputs("\n\n\n \n", of);
- if (psiconv_list_length(wf->page_sec->header->text->paragraphs) > 0) {
- fputs(" ", of);
- para = psiconv_list_get(wf->page_sec->header->text->paragraphs, 0);
- i = 0;
- fput_text(of, para->text, strlen(para->text), &i);
- fputs("\n", of);
+ if (wf->page_sec->header->text) {
+ if (psiconv_list_length(wf->page_sec->header->text->paragraphs) > 0) {
+ fputs(" ", of);
+ para = psiconv_list_get(wf->page_sec->header->text->paragraphs, 0);
+ i = 0;
+ fput_text(of, para->text, strlen(para->text), &i);
+ fputs("\n", of);
+ }
}
normal = wf->styles_sec->normal;
@@ -485,10 +496,26 @@
fput_style(of, normal, sty, wf);
}
fputs(" -->\n\n\n", of);
- for (i = 0; i < psiconv_list_length(wf->paragraphs); i++) {
- para = psiconv_list_get(wf->paragraphs, i);
- fput_para(of, para, wf);
+ if (wf->page_sec->header->text) {
+ for (i = 0; i < psiconv_list_length(wf->paragraphs); i++) {
+ para = psiconv_list_get(wf->paragraphs, i);
+ fput_para(of, para, wf);
+ }
}
fputs("\n\n", of);
+
+ return fclose(of);
+}
+
+static struct psiconv_fileformat_s ff =
+ {
+ "HTML4",
+ "HTML 4.0 with cascading style sheets",
+ psiconv_gen_html4
+ };
+
+void init_html4(void)
+{
+ psiconv_list_add(fileformat_list,&ff);
}