These really don't have much in common.
#include "libpspp/u8-line.h"
#include "output/pivot-table.h"
#include "output/table.h"
+#include "output/page-eject-item.h"
#include "output/text-item.h"
#include "gl/xalloc.h"
{
*eject = false;
if (trns->writer == NULL)
- text_item_submit (text_item_create (TEXT_ITEM_EJECT_PAGE, ""));
+ page_eject_item_submit (page_eject_item_create ());
else
leader = '1';
}
const struct text_item *text_item = to_text_item (output_item);
enum text_item_type type = text_item_get_type (text_item);
- if (type != TEXT_ITEM_PAGE_TITLE && type != TEXT_ITEM_EJECT_PAGE)
+ if (type != TEXT_ITEM_PAGE_TITLE)
ascii_output_table_item_unref (
a, text_item_to_table_item (text_item_ref (text_item)));
}
src/output/output-item-provider.h \
src/output/output-item.c \
src/output/output-item.h \
+ src/output/page-eject-item.c \
+ src/output/page-eject-item.h \
src/output/page-setup-item.c \
src/output/page-setup-item.h \
src/output/pivot-output.c \
#include "output/group-item.h"
#include "output/message-item.h"
#include "output/options.h"
+#include "output/page-eject-item.h"
#include "output/page-setup-item.h"
#include "output/render.h"
#include "output/table-item.h"
case TEXT_ITEM_PAGE_TITLE:
break;
- case TEXT_ITEM_EJECT_PAGE:
- if (xr->y > 0)
- return xr_render_eject ();
- break;
-
default:
return xr_render_table (
xr, text_item_to_table_item (text_item_ref (text_item)));
return xr_render_chart (to_chart_item (output_item));
else if (is_text_item (output_item))
return xr_render_text (xr, to_text_item (output_item));
+ else if (is_page_eject_item (output_item))
+ return xr->y > 0 ? xr_render_eject () : NULL;
else if (is_message_item (output_item))
return xr_render_message (xr, to_message_item (output_item));
else
#include "output/driver-provider.h"
#include "output/options.h"
#include "output/message-item.h"
+#include "output/page-eject-item.h"
#include "output/table-item.h"
#include "output/table-provider.h"
else
csv_output_lines (csv, text);
}
+ else if (is_page_eject_item (output_item))
+ {
+ csv_put_separator (csv);
+ csv_output_lines (csv, "");
+ }
else if (is_message_item (output_item))
{
const struct message_item *message_item = to_message_item (output_item);
case TEXT_ITEM_LOG:
print_title_tag (html->file, "pre", s); /* should be <P><TT> */
break;
-
- case TEXT_ITEM_EJECT_PAGE:
- /* Nothing to do. */
- break;
}
}
else if (is_message_item (output_item))
--- /dev/null
+/* PSPP - a program for statistical analysis.
+ Copyright (C) 2020 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+#include "output/page-eject-item.h"
+
+#include <stdlib.h>
+
+#include "output/driver-provider.h"
+#include "output/output-item-provider.h"
+
+#include "gl/xalloc.h"
+
+struct page_eject_item *
+page_eject_item_create (void)
+{
+ struct page_eject_item *item = xmalloc (sizeof *item);
+ output_item_init (&item->output_item, &page_eject_item_class);
+ return item;
+}
+
+/* Submits ITEM to the configured output drivers, and transfers ownership to
+ the output subsystem. */
+void
+page_eject_item_submit (struct page_eject_item *item)
+{
+ output_submit (&item->output_item);
+}
+
+static void
+page_eject_item_destroy (struct output_item *output_item)
+{
+ free (to_page_eject_item (output_item));
+}
+
+const struct output_item_class page_eject_item_class =
+ {
+ "page_eject",
+ page_eject_item_destroy,
+ };
--- /dev/null
+/* PSPP - a program for statistical analysis.
+ Copyright (C) 2020 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef OUTPUT_PAGE_EJECT_ITEM_H
+#define OUTPUT_PAGE_EJECT_ITEM_H 1
+
+/* Page eject items.
+
+ This ejects the page (for output devices that have pages). */
+
+#include <stdbool.h>
+#include "output/output-item.h"
+
+/* A page eject item. */
+struct page_eject_item
+ {
+ struct output_item output_item;
+ };
+
+struct page_eject_item *page_eject_item_create (void);
+\f
+/* This boilerplate for page_eject_item, a subclass of output_item, was
+ autogenerated by mk-class-boilerplate. */
+
+#include <assert.h>
+#include "libpspp/cast.h"
+
+extern const struct output_item_class page_eject_item_class;
+
+/* Returns true if SUPER is a page_eject_item, otherwise false. */
+static inline bool
+is_page_eject_item (const struct output_item *super)
+{
+ return super->class == &page_eject_item_class;
+}
+
+/* Returns SUPER converted to page_eject_item. SUPER must be a page_eject_item, as
+ reported by is_page_eject_item. */
+static inline struct page_eject_item *
+to_page_eject_item (const struct output_item *super)
+{
+ assert (is_page_eject_item (super));
+ return UP_CAST (super, struct page_eject_item, output_item);
+}
+
+/* Returns INSTANCE converted to output_item. */
+static inline struct output_item *
+page_eject_item_super (const struct page_eject_item *instance)
+{
+ return CONST_CAST (struct output_item *, &instance->output_item);
+}
+
+/* Increments INSTANCE's reference count and returns INSTANCE. */
+static inline struct page_eject_item *
+page_eject_item_ref (const struct page_eject_item *instance)
+{
+ return to_page_eject_item (output_item_ref (&instance->output_item));
+}
+
+/* Decrements INSTANCE's reference count, then destroys INSTANCE if
+ the reference count is now zero. */
+static inline void
+page_eject_item_unref (struct page_eject_item *instance)
+{
+ output_item_unref (&instance->output_item);
+}
+
+/* Returns true if INSTANCE's reference count is greater than 1,
+ false otherwise. */
+static inline bool
+page_eject_item_is_shared (const struct page_eject_item *instance)
+{
+ return output_item_is_shared (&instance->output_item);
+}
+
+void page_eject_item_submit (struct page_eject_item *);
+\f
+#endif /* output/page-eject-item.h */
#include "libpspp/assertion.h"
#include "libpspp/pool.h"
#include "output/table.h"
+#include "output/page-eject-item.h"
#include "output/table-item.h"
#include "output/text-item.h"
#include "output/table-provider.h"
PIVOT_AXIS_FOR_EACH (layer_indexes, &pt->axes[PIVOT_AXIS_LAYER])
{
if (pt->look.paginate_layers)
- text_item_submit (text_item_create (TEXT_ITEM_EJECT_PAGE, ""));
+ page_eject_item_submit (page_eject_item_create ());
pivot_table_submit_layer (pt, layer_indexes);
}
}
#include "data/file-handle-def.h"
#include "libpspp/cast.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"
else if (is_text_item (output_item))
spv_writer_put_text (spv->writer, to_text_item (output_item),
output_get_command_name ());
+ 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_put_text (struct spv_writer *w, const struct text_item *text,
const char *command_id)
{
- if (text->type == TEXT_ITEM_EJECT_PAGE)
- w->need_page_break = true;
-
bool initial_depth = w->heading_depth;
if (!initial_depth)
spv_writer_open_file (w);
if (!initial_depth)
spv_writer_close_file (w, "");
}
+
+void
+spv_writer_eject_page (struct spv_writer *w)
+{
+ w->need_page_break = true;
+}
\f
#define H TABLE_HORZ
#define V TABLE_VERT
const char *command_id);
void spv_writer_put_table (struct spv_writer *, const struct pivot_table *);
+void spv_writer_eject_page (struct spv_writer *);
+
#endif /* output/spv/spv-writer.h */
shipout (&tex->token_list, "}\\par\n\n");
break;
- case TEXT_ITEM_EJECT_PAGE:
- /* Nothing to do. */
- break;
-
case TEXT_ITEM_SYNTAX:
/* So far as I'm aware, this can never happen. */
default:
case TEXT_ITEM_LOG:
return _("Log");
- case TEXT_ITEM_EJECT_PAGE:
- return _("Page Break");
-
default:
return _("Text");
}
TEXT_ITEM_TITLE, /* Title. */
TEXT_ITEM_SYNTAX, /* Syntax printback logging. */
TEXT_ITEM_LOG, /* Other logging. */
- TEXT_ITEM_EJECT_PAGE /* Eject page. */
};
const char *text_item_type_to_string (enum text_item_type);