{
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);
- }
- 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);
- }
- else if (is_image_item (output_item))
- spv_writer_put_image (spv->writer, to_image_item (output_item)->image);
- 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);
}
struct output_driver_factory spv_driver_factory =
#include "output/spv/spv-writer.h"
+#include <cairo.h>
#include <inttypes.h>
#include <libxml/xmlwriter.h>
#include <math.h>
#include "libpspp/temp-file.h"
#include "libpspp/version.h"
#include "libpspp/zip-writer.h"
+#include "output/cairo-chart.h"
+#include "output/chart-item.h"
+#include "output/driver.h"
+#include "output/group-item.h"
+#include "output/image-item.h"
+#include "output/page-eject-item.h"
#include "output/page-setup-item.h"
#include "output/pivot-table.h"
+#include "output/table-item.h"
#include "output/text-item.h"
#include "gl/xalloc.h"
bool need_page_break;
};
+static void spv_writer_close_heading (struct spv_writer *);
+
char * WARN_UNUSED_RESULT
spv_writer_open (const char *filename, struct spv_writer **writerp)
{
return error;
}
-void
-spv_writer_set_page_setup (struct spv_writer *w,
- const struct page_setup *page_setup)
-{
- page_setup_destroy (w->page_setup);
- w->page_setup = page_setup_clone (page_setup);
-}
-
static void
write_attr (struct spv_writer *w, const char *name, const char *value)
{
return true;
}
-void
+static void
spv_writer_open_heading (struct spv_writer *w, const char *command_id,
const char *label)
{
w->heading = NULL;
}
-void
+static void
spv_writer_close_heading (struct spv_writer *w)
{
const char *infix = "";
}
}
-void
+static void
spv_writer_put_text (struct spv_writer *w, const struct text_item *text,
const char *command_id)
{
return CAIRO_STATUS_SUCCESS;
}
-void
+static void
spv_writer_put_image (struct spv_writer *w, cairo_surface_t *image)
{
bool initial_depth = w->heading_depth;
free (uri);
}
-
-void
-spv_writer_eject_page (struct spv_writer *w)
-{
- w->need_page_break = true;
-}
\f
#define H TABLE_HORZ
#define V TABLE_VERT
}
}
-void
+static void
spv_writer_put_table (struct spv_writer *w, const struct pivot_table *table)
{
struct pivot_table *table_rw = CONST_CAST (struct pivot_table *, table);
free (data_path);
}
+\f
+void
+spv_writer_write (struct spv_writer *w, const struct output_item *item)
+{
+ if (is_group_open_item (item))
+ spv_writer_open_heading (w,
+ to_group_open_item (item)->command_name,
+ to_group_open_item (item)->command_name);
+ else if (is_group_close_item (item))
+ spv_writer_close_heading (w);
+ else if (is_table_item (item))
+ {
+ const struct table_item *table_item = to_table_item (item);
+ if (table_item->pt)
+ spv_writer_put_table (w, table_item->pt);
+ }
+ else if (is_chart_item (item))
+ {
+ cairo_surface_t *surface = xr_draw_image_chart (
+ to_chart_item (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 (w, surface);
+ cairo_surface_destroy (surface);
+ }
+ else if (is_image_item (item))
+ spv_writer_put_image (w, to_image_item (item)->image);
+ else if (is_text_item (item))
+ {
+ char *command_id = output_get_command_name ();
+ spv_writer_put_text (w, to_text_item (item),
+ command_id);
+ free (command_id);
+ }
+ else if (is_page_eject_item (item))
+ w->need_page_break = true;
+ else if (is_page_setup_item (item))
+ {
+ page_setup_destroy (w->page_setup);
+ w->page_setup = page_setup_clone (to_page_setup_item (item)->page_setup);
+ }
+}
#ifndef OUTPUT_SPV_WRITER_H
#define OUTPUT_SPV_WRITER_H 1
-struct page_setup;
-struct pivot_table;
+struct output_item;
struct spv_writer;
-struct text_item;
-
-#include <cairo.h>
#include "libpspp/compiler.h"
WARN_UNUSED_RESULT;
char *spv_writer_close (struct spv_writer *) WARN_UNUSED_RESULT;
-void spv_writer_set_page_setup (struct spv_writer *,
- const struct page_setup *);
-
-void spv_writer_open_heading (struct spv_writer *, const char *command_id,
- const char *label);
-void spv_writer_close_heading (struct spv_writer *);
-
-void spv_writer_put_text (struct spv_writer *, const struct text_item *,
- const char *command_id);
-void spv_writer_put_table (struct spv_writer *, const struct pivot_table *);
-
-void spv_writer_put_image (struct spv_writer *, cairo_surface_t *);
-
-void spv_writer_eject_page (struct spv_writer *);
+void spv_writer_write (struct spv_writer *, const struct output_item *);
#endif /* output/spv/spv-writer.h */