NOT_REACHED ();
case OUTPUT_ITEM_PAGE_BREAK:
- case OUTPUT_ITEM_PAGE_SETUP:
break;
}
}
break;
case OUTPUT_ITEM_GROUP:
- case OUTPUT_ITEM_PAGE_SETUP:
return NULL;
case OUTPUT_ITEM_MESSAGE:
case OUTPUT_ITEM_GROUP:
case OUTPUT_ITEM_MESSAGE:
case OUTPUT_ITEM_PAGE_BREAK:
- case OUTPUT_ITEM_PAGE_SETUP:
case OUTPUT_ITEM_TEXT:
default:
NOT_REACHED ();
case OUTPUT_ITEM_GROUP:
case OUTPUT_ITEM_MESSAGE:
case OUTPUT_ITEM_PAGE_BREAK:
- case OUTPUT_ITEM_PAGE_SETUP:
case OUTPUT_ITEM_TEXT:
NOT_REACHED ();
}
case OUTPUT_ITEM_GROUP:
case OUTPUT_ITEM_MESSAGE:
- case OUTPUT_ITEM_PAGE_SETUP:
case OUTPUT_ITEM_TEXT:
default:
NOT_REACHED ();
{
struct xr_driver *xr = xr_driver_cast (driver);
- if (item->type == OUTPUT_ITEM_PAGE_SETUP)
- {
- if (!xr->pager)
- xr_update_page_setup (driver, item->page_setup);
- return;
- }
-
if (!xr->pager)
{
xr->pager = xr_pager_create (xr->page_style, xr->fsm_style);
xr_pager_add_page (xr->pager, cairo_create (xr->drawing_surface));
}
}
+
+static void
+xr_setup (struct output_driver *driver, const struct page_setup *ps)
+{
+ struct xr_driver *xr = xr_driver_cast (driver);
+
+ if (!xr->pager)
+ xr_update_page_setup (driver, ps);
+}
\f
struct output_driver_factory pdf_driver_factory =
{ "pdf", "pspp.pdf", xr_pdf_create };
.name = "cairo",
.destroy = xr_destroy,
.submit = xr_submit,
+ .setup = xr_setup,
.handles_groups = true,
};
csv_output_lines (csv, "");
break;
- case OUTPUT_ITEM_PAGE_SETUP:
- break;
-
case OUTPUT_ITEM_TABLE:
{
size_t *layer_indexes;
struct output_iterator;
struct string_map;
struct file_handle;
+struct page_setup;
/* A configured output driver. */
struct output_driver
void (*submit) (struct output_driver *driver,
const struct output_item *item);
+ /* Changes DRIVER's output page setup to PS, if possible. This may be NUL
+ if the driver doesn't support page setup. */
+ void (*setup) (struct output_driver *driver, const struct page_setup *ps);
+
/* Ensures that any output items passed to the 'submit' function for DRIVER
have actually been displayed.
case OUTPUT_ITEM_GROUP:
case OUTPUT_ITEM_IMAGE:
case OUTPUT_ITEM_PAGE_BREAK:
- case OUTPUT_ITEM_PAGE_SETUP:
case OUTPUT_ITEM_TABLE:
break;
}
{
return output_driver_get_engine (driver) != NULL;
}
+
+void
+output_set_page_setup (const struct page_setup *ps)
+{
+ struct output_engine *e = engine_stack_top ();
+
+ struct llx *llx;
+ llx_for_each (llx, &e->drivers)
+ {
+ struct output_driver *d = llx_data (llx);
+ if (d->class->setup)
+ d->class->setup (d, ps);
+ }
+}
\f
extern const struct output_driver_factory csv_driver_factory;
extern const struct output_driver_factory html_driver_factory;
#include "libpspp/compiler.h"
struct output_item;
+struct page_setup;
struct string_set;
struct string_map;
void output_driver_register (struct output_driver *);
void output_driver_unregister (struct output_driver *);
+void output_set_page_setup (const struct page_setup *);
+
#endif /* output/driver.h */
case OUTPUT_ITEM_PAGE_BREAK:
break;
- case OUTPUT_ITEM_PAGE_SETUP:
- break;
-
case OUTPUT_ITEM_TABLE:
html_output_table (html, item);
break;
case OUTPUT_ITEM_CHART:
case OUTPUT_ITEM_IMAGE:
case OUTPUT_ITEM_PAGE_BREAK:
- case OUTPUT_ITEM_PAGE_SETUP:
case OUTPUT_ITEM_TABLE:
break;
}
case OUTPUT_ITEM_PAGE_BREAK:
break;
- case OUTPUT_ITEM_PAGE_SETUP:
- break;
-
case OUTPUT_ITEM_TABLE:
write_table (odt, item->table);
break;
#include "libpspp/zip-reader.h"
#include "output/chart.h"
#include "output/driver.h"
-#include "output/page-setup.h"
#include "output/pivot-table.h"
#include "gl/xalloc.h"
case OUTPUT_ITEM_IMAGE: return "image";
case OUTPUT_ITEM_MESSAGE: return "message";
case OUTPUT_ITEM_PAGE_BREAK: return "page break";
- case OUTPUT_ITEM_PAGE_SETUP: return "page setup";
case OUTPUT_ITEM_TABLE: return "table";
case OUTPUT_ITEM_TEXT: return "text";
}
case OUTPUT_ITEM_PAGE_BREAK:
break;
- case OUTPUT_ITEM_PAGE_SETUP:
- page_setup_destroy (item->page_setup);
- break;
-
case OUTPUT_ITEM_TABLE:
pivot_table_unref (item->table);
break;
case OUTPUT_ITEM_PAGE_BREAK:
break;
- case OUTPUT_ITEM_PAGE_SETUP:
- new->page_setup = page_setup_clone (old->page_setup);
- break;
-
case OUTPUT_ITEM_TABLE:
new->table = pivot_table_ref (old->table);
break;
case OUTPUT_ITEM_PAGE_BREAK:
return _("Page Break");
- case OUTPUT_ITEM_PAGE_SETUP:
- /* Not marked for translation: user should never see it. */
- return "Page Setup";
-
case OUTPUT_ITEM_TABLE:
if (!item->cached_label)
{
printf ("page break\n");
break;
- case OUTPUT_ITEM_PAGE_SETUP:
- printf ("page setup\n");
- break;
-
case OUTPUT_ITEM_TABLE:
pivot_table_dump (item->table, indentation + 1);
break;
return item;
}
\f
-struct output_item *
-page_setup_item_create (const struct page_setup *ps)
-{
- struct output_item *item = xmalloc (sizeof *item);
- *item = (struct output_item) {
- OUTPUT_ITEM_INITIALIZER (OUTPUT_ITEM_PAGE_SETUP),
- .page_setup = page_setup_clone (ps),
- };
- return item;
-}
-\f
/* Returns a new output_item for rendering TABLE. Takes ownership of
TABLE. */
struct output_item *
OUTPUT_ITEM_IMAGE,
OUTPUT_ITEM_MESSAGE,
OUTPUT_ITEM_PAGE_BREAK,
- OUTPUT_ITEM_PAGE_SETUP,
OUTPUT_ITEM_TABLE,
OUTPUT_ITEM_TEXT,
};
struct msg *message;
- struct page_setup *page_setup;
-
struct pivot_table *table;
struct
struct output_item *page_break_item_create (void);
\f
-/* OUTPUT_ITEM_PAGE_SETUP. */
-
-struct output_item *page_setup_item_create (const struct page_setup *);
-\f
/* OUTPUT_ITEM_TABLE. */
struct output_item *table_item_create (struct pivot_table *);
case OUTPUT_ITEM_PAGE_BREAK:
return OUTPUT_CLASS_OTHER;
- case OUTPUT_ITEM_PAGE_SETUP:
- return OUTPUT_CLASS_OTHER;
-
case OUTPUT_ITEM_TABLE:
return (!strcmp (label, "Warnings") ? OUTPUT_CLASS_WARNINGS
: !strcmp (label, "Notes") ? OUTPUT_CLASS_NOTES
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;
return d;
- error:
+error:
output_driver_destroy (d);
return NULL;
}
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);
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 =
{ "spv", "pspp.spv", spv_create };
.name = "spv",
.destroy = spv_destroy,
.submit = spv_submit,
+ .setup = spv_setup,
.handles_show = true,
.handles_groups = true,
};
w->need_page_break = true;
break;
- case OUTPUT_ITEM_PAGE_SETUP:
- page_setup_destroy (w->page_setup);
- w->page_setup = page_setup_clone (item->page_setup);
- break;
-
case OUTPUT_ITEM_TABLE:
spv_writer_put_table (w, item);
break;
break;
}
}
+
+void
+spv_writer_set_page_setup (struct spv_writer *w,
+ const struct page_setup *ps)
+{
+ page_setup_destroy (w->page_setup);
+ w->page_setup = page_setup_clone (ps);
+}
#define OUTPUT_SPV_WRITER_H 1
struct output_item;
+struct page_setup;
struct spv_writer;
#include "libpspp/compiler.h"
char *spv_writer_close (struct spv_writer *) WARN_UNUSED_RESULT;
void spv_writer_write (struct spv_writer *, const struct output_item *);
+void spv_writer_set_page_setup (struct spv_writer *,
+ const struct page_setup *);
#endif /* output/spv/spv-writer.h */
case OUTPUT_ITEM_PAGE_BREAK:
break;
- case OUTPUT_ITEM_PAGE_SETUP:
- break;
-
case OUTPUT_ITEM_TABLE:
tex_output_table (tex, item->table);
break;
if (ps)
{
- output_item_submit (page_setup_item_create (ps));
+ output_set_page_setup (ps);
page_setup_destroy (ps);
}
output_item_submit_children (root);