X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Foutput%2Fodt.c;h=a3f945421f00e351fc8e84a08a56f435dc7d95b1;hb=f967d0e36a2193c1249799f463ea9109b753f7a8;hp=18827a600e6f0135e8d5d3c0c3469b1a20b869c7;hpb=a353919df75c25331144602421353a856f4236d6;p=pspp diff --git a/src/output/odt.c b/src/output/odt.c index 18827a600e..a3f945421f 100644 --- a/src/output/odt.c +++ b/src/output/odt.c @@ -40,7 +40,6 @@ #include "output/driver-provider.h" #include "output/message-item.h" #include "output/options.h" -#include "output/tab.h" #include "output/table-item.h" #include "output/table-provider.h" #include "output/text-item.h" @@ -57,6 +56,7 @@ struct odt_driver struct output_driver driver; struct zip_writer *zip; /* ZIP file writer. */ + struct file_handle *handle; /* Handle for 'file_name'. */ char *file_name; /* Output file name. */ /* content.xml */ @@ -80,26 +80,6 @@ odt_driver_cast (struct output_driver *driver) return UP_CAST (driver, struct odt_driver, driver); } -/* Create the "mimetype" file needed by ODF */ -static bool -create_mimetype (struct zip_writer *zip) -{ - FILE *fp; - - fp = create_temp_file (); - if (fp == NULL) - { - msg_error (errno, _("error creating temporary file")); - return false; - } - - fprintf (fp, "application/vnd.oasis.opendocument.text"); - zip_writer_add (zip, fp, "mimetype"); - close_temp_file (fp); - - return true; -} - /* Creates a new temporary file and stores it in *FILE, then creates an XML writer for it and stores it in *W. */ static void @@ -303,13 +283,11 @@ odt_create (struct file_handle *fh, enum settings_output_devices device_type, output_driver_init (d, &odt_driver_class, file_name, device_type); odt->zip = zip; + odt->handle = fh; odt->file_name = xstrdup (file_name); - if (!create_mimetype (zip)) - { - output_driver_destroy (d); - return NULL; - } + zip_writer_add_string (zip, "mimetype", + "application/vnd.oasis.opendocument.text"); /* Create the manifest */ create_writer (&odt->manifest_file, &odt->manifest_wtr); @@ -380,6 +358,7 @@ odt_destroy (struct output_driver *driver) zip_writer_close (odt->zip); } + fh_unref (odt->handle); free (odt->file_name); free (odt); } @@ -496,7 +475,6 @@ write_table (struct odt_driver *odt, const struct table_item *item) for (c = 0 ; c < table_nc (tab) ; ++c) { struct table_cell cell; - size_t i; table_get_cell (tab, c, r, &cell); @@ -518,25 +496,27 @@ write_table (struct odt_driver *odt, const struct table_item *item) odt->content_wtr, _xml("table:number-rows-spanned"), "%d", rowspan); - for (i = 0; i < cell.n_contents; i++) - { - const struct cell_contents *contents = &cell.contents[i]; - int j; - - xmlTextWriterStartElement (odt->content_wtr, _xml("text:p")); + xmlTextWriterStartElement (odt->content_wtr, _xml("text:p")); - if ( r < table_ht (tab) || c < table_hl (tab) ) - xmlTextWriterWriteAttribute (odt->content_wtr, _xml("text:style-name"), _xml("Table_20_Heading")); - else - xmlTextWriterWriteAttribute (odt->content_wtr, _xml("text:style-name"), _xml("Table_20_Contents")); + if ( r < table_ht (tab) || c < table_hl (tab) ) + xmlTextWriterWriteAttribute (odt->content_wtr, _xml("text:style-name"), _xml("Table_20_Heading")); + else + xmlTextWriterWriteAttribute (odt->content_wtr, _xml("text:style-name"), _xml("Table_20_Contents")); - write_xml_with_line_breaks (odt, contents->text); + if (cell.options & TAB_MARKUP) + { + /* XXX */ + char *s = output_get_text_from_markup (cell.text); + write_xml_with_line_breaks (odt, s); + free (s); + } + else + write_xml_with_line_breaks (odt, cell.text); - for (j = 0; j < contents->n_footnotes; j++) - write_footnote (odt, contents->footnotes[j]); + for (int i = 0; i < cell.n_footnotes; i++) + write_footnote (odt, cell.footnotes[i]); - xmlTextWriterEndElement (odt->content_wtr); /* text:p */ - } + xmlTextWriterEndElement (odt->content_wtr); /* text:p */ xmlTextWriterEndElement (odt->content_wtr); /* table:table-cell */ } else