more work toward making table_item just a pivot_Table
[pspp] / src / output / ascii.c
index f019fda4e112c5885b432e752b5e771432af9755..9a08a893317d656b588696e800ed5d179e001661 100644 (file)
@@ -54,6 +54,8 @@
 #include "output/driver-provider.h"
 #include "output/message-item.h"
 #include "output/options.h"
+#include "output/pivot-output.h"
+#include "output/pivot-table.h"
 #include "output/render.h"
 #include "output/table-item.h"
 #include "output/text-item.h"
@@ -558,21 +560,22 @@ static void
 ascii_output_table_item (struct ascii_driver *a,
                          const struct table_item *table_item)
 {
-  struct render_pager *p;
-
   update_page_size (a, false);
 
-  if (a->object_cnt++)
-    putc ('\n', a->file);
-
-  p = render_pager_create (&a->params, table_item);
-  for (int i = 0; render_pager_has_next (p); i++)
+  size_t *layer_indexes;
+  PIVOT_OUTPUT_FOR_EACH_LAYER (layer_indexes, table_item->pt, true)
     {
-      if (i)
-        putc ('\n', a->file);
-      ascii_output_lines (a, render_pager_draw_next (p, INT_MAX));
+      struct render_pager *p = render_pager_create (&a->params, table_item,
+                                                    layer_indexes);
+      for (int i = 0; render_pager_has_next (p); i++)
+        {
+          if (a->object_cnt++)
+            putc ('\n', a->file);
+
+          ascii_output_lines (a, render_pager_draw_next (p, INT_MAX));
+        }
+      render_pager_destroy (p);
     }
-  render_pager_destroy (p);
 }
 
 static void
@@ -608,8 +611,10 @@ ascii_submit (struct output_driver *driver,
         {
           struct text_item *text_item;
 
-          text_item = text_item_create_format (
-            TEXT_ITEM_LOG, _("See %s for a chart."), file_name);
+          text_item = text_item_create_nocopy (
+            TEXT_ITEM_LOG,
+            xasprintf (_("See %s for a chart."), file_name),
+            NULL);
 
           ascii_submit (driver, &text_item->output_item);
           text_item_unref (text_item);
@@ -706,7 +711,7 @@ ascii_measure_cell_width (void *a_, const struct table_cell *cell,
   ascii_layout_cell (a, cell, bb, clip, max_width, &h);
 
   if (cell->n_footnotes || strchr (cell->text, ' ')
-      || cell->n_subscripts || cell->superscript)
+      || cell->n_subscripts)
     {
       bb[H][1] = 1;
       ascii_layout_cell (a, cell, bb, clip, min_width, &h);
@@ -907,8 +912,6 @@ add_markers (const char *text, const struct table_cell *cell)
   ds_put_cstr (&s, text);
   for (size_t i = 0; i < cell->n_subscripts; i++)
     ds_put_format (&s, "%c%s", i ? ',' : '_', cell->subscripts[i]);
-  if (cell->superscript)
-    ds_put_format (&s, "^%s", cell->superscript);
   for (size_t i = 0; i < cell->n_footnotes; i++)
     ds_put_format (&s, "[%s]", cell->footnotes[i]->marker);
   return ds_steal_cstr (&s);
@@ -927,9 +930,9 @@ ascii_layout_cell (struct ascii_driver *a, const struct table_cell *cell,
                             ? output_get_text_from_markup (cell->text)
                             : cell->text);
 
-  /* Append footnotes, subscripts, superscript if any. */
+  /* Append footnotes, subscripts if any. */
   const char *text;
-  if (cell->n_footnotes || cell->n_subscripts || cell->superscript)
+  if (cell->n_footnotes || cell->n_subscripts)
     {
       text = add_markers (plain_text, cell);
       if (plain_text != cell->text)