output: Introduce pivot tables.
[pspp] / src / output / odt.c
index 153cd393c116f357f615e3d113ea9e336d8292e5..56b26bb1ac6db335c8227d651e8bb7b7087b2e43 100644 (file)
@@ -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"
@@ -467,6 +466,7 @@ write_table (struct odt_driver *odt, const struct table_item *item)
 
   /* Write a heading for the table */
   write_table_item_text (odt, table_item_get_title (item));
+  write_table_item_text (odt, table_item_get_layers (item));
 
   /* Start table */
   xmlTextWriterStartElement (odt->content_wtr, _xml("table:table"));
@@ -495,7 +495,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);
 
@@ -517,25 +516,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
@@ -577,17 +578,11 @@ odt_submit (struct output_driver *driver,
   if (is_table_item (output_item))
     write_table (odt, to_table_item (output_item));
   else if (is_text_item (output_item))
-    {
-      struct text_item *text_item = to_text_item (output_item);
-
-      if (text_item_get_type (text_item) != TEXT_ITEM_COMMAND_CLOSE)
-        odt_output_text (odt, text_item_get_text (text_item));
-    }
+    odt_output_text (odt, text_item_get_text (to_text_item (output_item)));
   else if (is_message_item (output_item))
     {
       const struct message_item *message_item = to_message_item (output_item);
-      const struct msg *msg = message_item_get_msg (message_item);
-      char *s = msg_to_string (msg, message_item->command_name);
+      char *s = msg_to_string (message_item_get_msg (message_item));
       odt_output_text (odt, s);
       free (s);
     }