X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Foutput%2Fhtml.c;h=d3049e6564bd95e5c925a99a605c7bb2e96cd8a8;hb=95cde62bdf5210c1c60dad5598a888b864f93161;hp=3fb6bb83b5dc49a157c45f72627f21c6a0228243;hpb=865bc07bb98f77536103372c1b070f62f8f693a2;p=pspp diff --git a/src/output/html.c b/src/output/html.c index 3fb6bb83b5..d3049e6564 100644 --- a/src/output/html.c +++ b/src/output/html.c @@ -33,15 +33,14 @@ #include "libpspp/i18n.h" #include "libpspp/message.h" #include "libpspp/version.h" -#include "output/cairo.h" -#include "output/chart-item.h" +#include "output/cairo-chart.h" +#include "output/chart.h" #include "output/driver-provider.h" -#include "output/message-item.h" #include "output/options.h" -#include "output/output-item-provider.h" +#include "output/output-item.h" +#include "output/pivot-output.h" +#include "output/pivot-table.h" #include "output/table-provider.h" -#include "output/table-item.h" -#include "output/text-item.h" #include "gl/minmax.h" #include "gl/xalloc.h" @@ -49,26 +48,30 @@ #include "gettext.h" #define _(msgid) gettext (msgid) +/* This file uses TABLE_HORZ and TABLE_VERT enough to warrant abbreviating. */ +#define H TABLE_HORZ +#define V TABLE_VERT + struct html_driver { struct output_driver driver; -#ifdef HAVE_CAIRO struct cell_color fg; struct cell_color bg; -#endif struct file_handle *handle; char *chart_file_name; FILE *file; - size_t chart_cnt; + size_t n_charts; + bool bare; bool css; bool borders; }; static const struct output_driver_class html_driver_class; -static void html_output_table (struct html_driver *, const struct table_item *); +static void html_output_table (struct html_driver *, + const struct output_item *); static void escape_string (FILE *file, const char *text, const char *space, const char *newline); static void print_title_tag (FILE *file, const char *name, @@ -81,43 +84,15 @@ html_driver_cast (struct output_driver *driver) return UP_CAST (driver, struct html_driver, driver); } -static struct driver_option * -opt (struct output_driver *d, struct string_map *options, const char *key, - const char *default_value) +static struct driver_option +opt (struct driver_options *options, const char *key, const char *default_value) { - return driver_option_get (d, options, key, default_value); + return driver_option_get (options, key, default_value); } -static struct output_driver * -html_create (struct file_handle *fh, enum settings_output_devices device_type, - struct string_map *o) +static void +put_header (struct html_driver *html) { - struct output_driver *d; - struct html_driver *html; - - html = xzalloc (sizeof *html); - d = &html->driver; - output_driver_init (&html->driver, &html_driver_class, fh_get_file_name (fh), - device_type); - html->css = parse_boolean (opt (d, o, "css", "true")); - html->borders = parse_boolean (opt (d, o, "borders", "true")); - - html->handle = fh; - html->chart_file_name = parse_chart_file_name (opt (d, o, "charts", - fh_get_file_name (fh))); - html->file = NULL; - html->chart_cnt = 1; -#ifdef HAVE_CAIRO - parse_color (d, o, "background-color", "#FFFFFFFFFFFF", &html->bg); - parse_color (d, o, "foreground-color", "#000000000000", &html->fg); -#endif - html->file = fn_open (html->handle, "w"); - if (html->file == NULL) - { - msg_error (errno, _("error opening output file `%s'"), fh_get_file_name (html->handle)); - goto error; - } - fputs ("\n", html->file); fprintf (html->file, "\n", html->file); fputs ("
\n", html->file); +} + +static struct output_driver * +html_create (struct file_handle *fh, enum settings_output_devices device_type, + struct driver_options *o) +{ + FILE *file = fn_open (fh, "w"); + if (!file) + { + msg_error (errno, _("error opening output file `%s'"), + fh_get_file_name (fh)); + return NULL; + } + + struct html_driver *html = xmalloc (sizeof *html); + *html = (struct html_driver) { + .driver = { + .class = &html_driver_class, + .name = xstrdup (fh_get_file_name (fh)), + .device_type = device_type + }, + .bare = parse_boolean (opt (o, "bare", "false")), + .css = parse_boolean (opt (o, "css", "true")), + .borders = parse_boolean (opt (o, "borders", "true")), + .handle = fh, + .chart_file_name = parse_chart_file_name (opt (o, "charts", + fh_get_file_name (fh))), + .file = file, + .n_charts = 1, + .bg = parse_color (opt (o, "background-color", "#FFFFFFFFFFFF")), + .fg = parse_color (opt (o, "foreground-color", "#000000000000")), + }; - return d; + if (!html->bare) + put_header (html); - error: - output_driver_destroy (d); - return NULL; + return &html->driver; } /* Emits