X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Foutput%2Fodt.c;h=abb30cb530c7c1c85b3edd46afdd825fbe573fe6;hb=d8b3292a8c12564dbc67e59f24d626dcfbf2e274;hp=82480bb3e365e58caffcb0218c0e05f4377539a5;hpb=1c02620baa5dd413e3284071f6a5184c1e77bf40;p=pspp diff --git a/src/output/odt.c b/src/output/odt.c index 82480bb3e3..abb30cb530 100644 --- a/src/output/odt.c +++ b/src/output/odt.c @@ -38,13 +38,11 @@ #include "libpspp/zip-writer.h" #include "data/file-handle-def.h" #include "output/driver-provider.h" -#include "output/message-item.h" #include "output/options.h" +#include "output/output-item.h" #include "output/pivot-table.h" #include "output/pivot-output.h" -#include "output/table-item.h" #include "output/table-provider.h" -#include "output/text-item.h" #include "gl/xalloc.h" @@ -287,7 +285,6 @@ odt_create (struct file_handle *fh, enum settings_output_devices device_type, struct string_map *o UNUSED) { struct output_driver *d; - struct odt_driver *odt; struct zip_writer *zip; const char *file_name = fh_get_file_name (fh); @@ -295,7 +292,7 @@ odt_create (struct file_handle *fh, enum settings_output_devices device_type, if (zip == NULL) return NULL; - odt = xzalloc (sizeof *odt); + struct odt_driver *odt = XZALLOC (struct odt_driver); d = &odt->driver; output_driver_init (d, &odt_driver_class, file_name, device_type); @@ -448,8 +445,8 @@ write_table_item_cell (struct odt_driver *odt, xmlTextWriterWriteString (odt->content_wtr, _xml (ds_cstr (&body))); ds_destroy (&body); - write_footnotes (odt, pt, cell->value->footnote_indexes, - cell->value->n_footnotes); + const struct pivot_value_ex *ex = pivot_value_ex (cell->value); + write_footnotes (odt, pt, ex->footnote_indexes, ex->n_footnotes); } static void @@ -573,11 +570,11 @@ write_table_layer (struct odt_driver *odt, const struct pivot_table *pt, } static void -write_table (struct odt_driver *odt, const struct table_item *item) +write_table (struct odt_driver *odt, const struct pivot_table *pt) { size_t *layer_indexes; - PIVOT_OUTPUT_FOR_EACH_LAYER (layer_indexes, item->pt, true) - write_table_layer (odt, item->pt, layer_indexes); + PIVOT_OUTPUT_FOR_EACH_LAYER (layer_indexes, pt, true) + write_table_layer (odt, pt, layer_indexes); } static void @@ -590,25 +587,43 @@ odt_output_text (struct odt_driver *odt, const char *text) /* Submit a table to the ODT driver */ static void -odt_submit (struct output_driver *driver, - const struct output_item *output_item) +odt_submit (struct output_driver *driver, const struct output_item *item) { struct odt_driver *odt = odt_driver_cast (driver); - if (is_table_item (output_item)) - write_table (odt, to_table_item (output_item)); - else if (is_text_item (output_item)) + switch (item->type) { - char *text = text_item_get_plain_text (to_text_item (output_item)); - odt_output_text (odt, text); - free (text); - } - else if (is_message_item (output_item)) - { - const struct message_item *message_item = to_message_item (output_item); - char *s = msg_to_string (message_item_get_msg (message_item)); - odt_output_text (odt, s); - free (s); + case OUTPUT_ITEM_CHART: + break; + + case OUTPUT_ITEM_GROUP: + break; + + case OUTPUT_ITEM_IMAGE: + break; + + case OUTPUT_ITEM_MESSAGE: + { + char *s = msg_to_string (item->message); + odt_output_text (odt, s); + free (s); + } + break; + + case OUTPUT_ITEM_PAGE_BREAK: + break; + + case OUTPUT_ITEM_TABLE: + write_table (odt, item->table); + break; + + case OUTPUT_ITEM_TEXT: + { + char *text = text_item_get_plain_text (item); + odt_output_text (odt, text); + free (text); + } + break; } } @@ -617,8 +632,7 @@ struct output_driver_factory odt_driver_factory = static const struct output_driver_class odt_driver_class = { - "odf", - odt_destroy, - odt_submit, - NULL, + .name = "odf", + .destroy = odt_destroy, + .submit = odt_submit, };