X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Foutput%2Fspv-driver.c;h=707e82abfa33afe34348743664bcc176a13a6fce;hb=cee6f0eb54144da7034566fa1bcdcee22337ae6a;hp=0fb0928372debcdb4cdd8f1e1e1dc6689d8ebf28;hpb=f8659933d48c5682010d1e1f04ae7acb5cbcd611;p=pspp diff --git a/src/output/spv-driver.c b/src/output/spv-driver.c index 0fb0928372..707e82abfa 100644 --- a/src/output/spv-driver.c +++ b/src/output/spv-driver.c @@ -22,15 +22,8 @@ #include "data/file-handle-def.h" #include "libpspp/cast.h" -#ifdef HAVE_CAIRO #include "output/cairo-chart.h" -#endif -#include "output/chart-item.h" -#include "output/group-item.h" -#include "output/page-eject-item.h" -#include "output/page-setup-item.h" -#include "output/table-item.h" -#include "output/text-item.h" +#include "output/output-item.h" #include "output/spv/spv-writer.h" #include "gl/xalloc.h" @@ -56,12 +49,10 @@ spv_driver_cast (struct output_driver *driver) static struct output_driver * spv_create (struct file_handle *fh, enum settings_output_devices device_type, - struct string_map *o UNUSED) + struct string_map *o UNUSED) { struct output_driver *d; - struct spv_driver *spv; - - spv = xzalloc (sizeof *spv); + struct spv_driver *spv = XZALLOC (struct spv_driver); d = &spv->driver; spv->handle = fh; output_driver_init (&spv->driver, &spv_driver_class, fh_get_file_name (fh), @@ -76,7 +67,7 @@ spv_create (struct file_handle *fh, enum settings_output_devices device_type, return d; - error: +error: output_driver_destroy (d); return NULL; } @@ -95,46 +86,20 @@ spv_destroy (struct output_driver *driver) static void spv_submit (struct output_driver *driver, - const struct output_item *output_item) + const struct output_item *output_item) { struct spv_driver *spv = spv_driver_cast (driver); - if (is_group_open_item (output_item)) - spv_writer_open_heading (spv->writer, - to_group_open_item (output_item)->command_name, - to_group_open_item (output_item)->command_name); - else if (is_group_close_item (output_item)) - spv_writer_close_heading (spv->writer); - else if (is_table_item (output_item)) - { - const struct table_item *table_item = to_table_item (output_item); - if (table_item->pt) - spv_writer_put_table (spv->writer, table_item->pt); - } -#ifdef HAVE_CAIRO - else if (is_chart_item (output_item)) - { - cairo_surface_t *surface = xr_draw_image_chart ( - to_chart_item (output_item), - &(struct cell_color) CELL_COLOR_BLACK, - &(struct cell_color) CELL_COLOR_WHITE); - if (cairo_surface_status (surface) == CAIRO_STATUS_SUCCESS) - spv_writer_put_image (spv->writer, surface); - cairo_surface_destroy (surface); - } -#endif - else if (is_text_item (output_item)) - { - char *command_id = output_get_command_name (); - spv_writer_put_text (spv->writer, to_text_item (output_item), - command_id); - free (command_id); - } - else if (is_page_eject_item (output_item)) - spv_writer_eject_page (spv->writer); - else if (is_page_setup_item (output_item)) - spv_writer_set_page_setup (spv->writer, - to_page_setup_item (output_item)->page_setup); + spv_writer_write (spv->writer, output_item); +} + +static void +spv_setup (struct output_driver *driver, + const struct page_setup *ps) +{ + struct spv_driver *spv = spv_driver_cast (driver); + + spv_writer_set_page_setup (spv->writer, ps); } struct output_driver_factory spv_driver_factory = @@ -142,8 +107,10 @@ struct output_driver_factory spv_driver_factory = static const struct output_driver_class spv_driver_class = { - "spv", - spv_destroy, - spv_submit, - NULL, + .name = "spv", + .destroy = spv_destroy, + .submit = spv_submit, + .setup = spv_setup, + .handles_show = true, + .handles_groups = true, };