Revert "work toward getting rid of struct table in table_item"
authorBen Pfaff <blp@cs.stanford.edu>
Tue, 29 Dec 2020 01:56:59 +0000 (17:56 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Thu, 31 Dec 2020 03:58:11 +0000 (19:58 -0800)
This reverts commit 4e02039cfe0e5a9e8639143591fbc03ff71a37d5.

src/output/cairo-fsm.c
src/output/cairo-fsm.h
src/output/cairo-pager.c
src/output/pivot-output.c
src/output/pivot-output.h [deleted file]
src/output/pivot-table.c
src/output/pivot-table.h
src/output/spv/spv.h
src/output/table-item.c
src/output/table-item.h
src/ui/gui/psppire-output-view.c

index 58bbf230d5aada148969733bd73eefe4ebdb66e5..708bedec03756fc379a193151066c31e2197104e 100644 (file)
@@ -115,27 +115,12 @@ xr_fsm_style_equals (const struct xr_fsm_style *a,
   return true;
 }
 \f
-/* Renders a single output_item to an output device in one of two ways:
-
-   - 'print == true': Broken across multiple pages if necessary.
-
-   - 'print == false': In a single region that the user may scroll around if
-     needed.
-
-   Normally 'output_item' corresponds to a single rendering.  There is a
-   special case when 'print == true' and 'output_item' is a table_item with
-   multiple layers and 'item->pt->table_look->print_all_layers == true'.  In
-   that case, each layer is rendered separately from the FSM's internal point
-   of view; from the client's point of view, it is all one operation.
-*/
 struct xr_fsm
   {
     struct xr_fsm_style *style;
     struct output_item *item;
-    bool print;
 
     /* Table items only. */
-    size_t *layer_indexes;
     struct render_params rp;
     struct render_pager *p;
     cairo_t *cairo;             /* XXX should this be here?! */
@@ -972,10 +957,9 @@ xr_layout_cell (struct xr_fsm *xr, const struct table_cell *cell,
 #define CHART_WIDTH 500
 #define CHART_HEIGHT 375
 
-static struct xr_fsm *
+struct xr_fsm *
 xr_fsm_create (const struct output_item *item_,
-               const struct xr_fsm_style *style, cairo_t *cr,
-               bool print)
+               const struct xr_fsm_style *style, cairo_t *cr)
 {
   if (is_page_setup_item (item_)
       || is_group_open_item (item_)
@@ -1017,14 +1001,6 @@ xr_fsm_create (const struct output_item *item_,
           || is_chart_item (item)
           || is_page_eject_item (item));
 
-  size_t *layer_indexes = NULL;
-  if (is_table_item (item))
-    {
-      layer_indexes = pivot_table_next_layer (table_item->pt, NULL, print);
-      if (!layer_indexes)
-        return NULL;
-    }
-
   static const struct render_ops xrr_render_ops = {
     .measure_cell_width = xrr_measure_cell_width,
     .measure_cell_height = xrr_measure_cell_height,
@@ -1045,16 +1021,10 @@ xr_fsm_create (const struct output_item *item_,
       [RENDER_LINE_DOUBLE] = 2 * LW + LS,
     };
 
-  size_t *layer_indexes = NULL;
-  if (is_table_item (item)
-  pivot_table_next_display_layer (
-
   struct xr_fsm *fsm = xmalloc (sizeof *fsm);
   *fsm = (struct xr_fsm) {
     .style = xr_fsm_style_ref (style),
     .item = item,
-    .print = print,
-    .layer_indexes = layer_indexes,
     .rp = {
       .ops = &xrr_render_ops,
       .aux = fsm,
@@ -1066,6 +1036,13 @@ xr_fsm_create (const struct output_item *item_,
     }
   };
 
+  if (is_table_item (item))
+    {
+      fsm->cairo = cr;
+      fsm->p = render_pager_create (&fsm->rp, to_table_item (item));
+      fsm->cairo = NULL;
+    }
+
   for (int i = 0; i < XR_N_FONTS; i++)
     {
       PangoContext *context = pango_cairo_create_context (cr);
@@ -1088,15 +1065,6 @@ xr_fsm_create (const struct output_item *item_,
       g_object_unref (G_OBJECT (layout));
     }
 
-  if (is_table_item (item))
-    {
-      struct table_item *table_item = to_table_item (item);
-
-      fsm->cairo = cr;
-      fsm->p = render_pager_create (&fsm->rp, table_item);
-      fsm->cairo = NULL;
-    }
-
   return fsm;
 }
 
index 906ce12be3dc3a8deb3a03c63ed767ef28596747..bf937835418b6b130d48c7b3edf5995223b59ab1 100644 (file)
@@ -62,20 +62,16 @@ void xr_fsm_style_unref (struct xr_fsm_style *);
 bool xr_fsm_style_equals (const struct xr_fsm_style *,
                           const struct xr_fsm_style *);
 
-/* Interface used for rendering output items in a single on-screen region. */
-struct xr_fsm *xr_fsm_create_for_scrolling (const struct output_item *,
-                                            const struct xr_fsm_style *,
-                                            cairo_t *);
+struct xr_fsm *xr_fsm_create (const struct output_item *,
+                              const struct xr_fsm_style *,
+                              cairo_t *);
+void xr_fsm_destroy (struct xr_fsm *);
+
 void xr_fsm_measure (struct xr_fsm *, cairo_t *, int *w, int *h);
 void xr_fsm_draw_all (struct xr_fsm *, cairo_t *);
 void xr_fsm_draw_region (struct xr_fsm *, cairo_t *,
                          int x, int y, int w, int h);
 
-/* Interface used for rendering output items to a series of printed pages. */
-struct xr_fsm *xr_fsm_create_for_printing (const struct output_item *,
-                                           const struct xr_fsm_style *,
-                                           cairo_t *);
-void xr_fsm_destroy (struct xr_fsm *);
 int xr_fsm_draw_slice (struct xr_fsm *, cairo_t *, int space);
 bool xr_fsm_is_empty (const struct xr_fsm *);
 
index d096b0caceec08a783cdaf9f0d951ea51823681a..e87ec325248f2cff94d2fbdd2c57d7d1febc6a07 100644 (file)
@@ -396,7 +396,7 @@ xr_pager_run (struct xr_pager *p)
                 }
             }
 
-          p->fsm = xr_fsm_create_for_printing (p->item, p->fsm_style, p->cr);
+          p->fsm = xr_fsm_create (p->item, p->fsm_style, p->cr);
           if (!p->fsm)
             {
               output_item_unref (p->item);
index 9cdb569d479cd32847e347187a6ae9dc96b6b404..ae12c4dea391e51358a97de2ca85df32fa040c24 100644 (file)
 
 #include <stdlib.h>
 
-#include "output/pivot-output.h"
+#include "output/pivot-table.h"
 
 #include "data/settings.h"
 #include "libpspp/assertion.h"
 #include "libpspp/pool.h"
+#include "output/table.h"
 #include "output/page-eject-item.h"
-#include "output/pivot-table.h"
 #include "output/table-item.h"
-#include "output/table-provider.h"
-#include "output/table.h"
 #include "output/text-item.h"
+#include "output/table-provider.h"
 
 #include "gl/minmax.h"
 #include "gl/xalloc.h"
@@ -139,7 +138,6 @@ fill_cell (struct table *t, int x1, int y1, int x2, int y2,
     }
 }
 
-<<<<<<< HEAD
 static struct table_item_text *
 pivot_value_to_table_item_text (const struct pivot_value *value,
                                 const struct table_area_style *area,
@@ -171,8 +169,6 @@ pivot_value_to_table_item_text (const struct pivot_value *value,
   return text;
 }
 
-=======
->>>>>>> 8b935a7c95 (work toward getting rid of struct table in table_item)
 static int
 get_table_rule (const struct table_border_style *styles,
                 enum pivot_border style_idx)
@@ -310,9 +306,9 @@ compose_headings (struct table *t,
     }
 }
 
-struct table *
-pivot_table_to_table (const struct pivot_table *pt,
-                      const size_t *layer_indexes)
+static void
+pivot_table_submit_layer (const struct pivot_table *pt,
+                          const size_t *layer_indexes)
 {
   const size_t *pindexes[PIVOT_N_AXES]
     = { [PIVOT_AXIS_LAYER] = layer_indexes };
@@ -459,13 +455,96 @@ pivot_table_to_table (const struct pivot_table *pt,
   free (column_enumeration);
   free (row_enumeration);
 
+  struct table_item *ti = table_item_create (table, NULL, NULL, pt->notes);
+
+  if (pt->title)
+    {
+      struct table_item_text *title = pivot_value_to_table_item_text (
+        pt->title, &pt->look->areas[PIVOT_AREA_TITLE], footnotes,
+        pt->show_values, pt->show_variables);
+      table_item_set_title (ti, title);
+      table_item_text_destroy (title);
+    }
+
+  const struct pivot_axis *layer_axis = &pt->axes[PIVOT_AXIS_LAYER];
+  struct table_item_layers *layers = NULL;
+  for (size_t i = 0; i < layer_axis->n_dimensions; i++)
+    {
+      const struct pivot_dimension *d = layer_axis->dimensions[i];
+      if (d->n_leaves)
+        {
+          if (!layers)
+            {
+              layers = xzalloc (sizeof *layers);
+              layers->style = table_area_style_override (
+                NULL, &pt->look->areas[PIVOT_AREA_LAYERS], NULL, NULL, false);
+              layers->layers = xnmalloc (layer_axis->n_dimensions,
+                                         sizeof *layers->layers);
+            }
+
+          const struct pivot_value *name
+            = d->data_leaves[layer_indexes[i]]->name;
+          struct table_item_layer *layer = &layers->layers[layers->n_layers++];
+          struct string s = DS_EMPTY_INITIALIZER;
+          pivot_value_format_body (name, pt->show_values, pt->show_variables,
+                                   &s);
+          layer->content = ds_steal_cstr (&s);
+          layer->n_footnotes = 0;
+          layer->footnotes = xnmalloc (name->n_footnotes,
+                                       sizeof *layer->footnotes);
+          for (size_t i = 0; i < name->n_footnotes; i++)
+            {
+              struct footnote *f = footnotes[name->footnotes[i]->idx];
+              if (f)
+                layer->footnotes[layer->n_footnotes++] = f;
+            }
+        }
+    }
+  if (layers)
+    {
+      table_item_set_layers (ti, layers);
+      table_item_layers_destroy (layers);
+    }
+
+  if (pt->caption && pt->show_caption)
+    {
+      struct table_item_text *caption = pivot_value_to_table_item_text (
+        pt->caption, &pt->look->areas[PIVOT_AREA_CAPTION], footnotes,
+        pt->show_values, pt->show_variables);
+      table_item_set_caption (ti, caption);
+      table_item_text_destroy (caption);
+    }
+
   free (footnotes);
+  ti->pt = pivot_table_ref (pt);
 
-  return table;
+  table_item_submit (ti);
 }
 
 void
 pivot_table_submit (struct pivot_table *pt)
 {
-  table_item_submit (table_item_create (pt));
+  pivot_table_assign_label_depth (CONST_CAST (struct pivot_table *, pt));
+
+  int old_decimal = settings_get_decimal_char (FMT_COMMA);
+  if (pt->decimal == '.' || pt->decimal == ',')
+    settings_set_decimal_char (pt->decimal);
+
+  if (pt->look->print_all_layers)
+    {
+      size_t *layer_indexes;
+
+      PIVOT_AXIS_FOR_EACH (layer_indexes, &pt->axes[PIVOT_AXIS_LAYER])
+        {
+          if (pt->look->paginate_layers)
+            page_eject_item_submit (page_eject_item_create ());
+          pivot_table_submit_layer (pt, layer_indexes);
+        }
+    }
+  else
+    pivot_table_submit_layer (pt, pt->current_layer);
+
+  settings_set_decimal_char (old_decimal);
+
+  pivot_table_unref (pt);
 }
diff --git a/src/output/pivot-output.h b/src/output/pivot-output.h
deleted file mode 100644 (file)
index 495a0a7..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/* 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_PIVOT_OUTPUT_H
-#define OUTPUT_PIVOT_OUTPUT_H 1
-
-#include <stddef.h>
-
-struct pivot_table;
-
-struct table *pivot_table_to_table (const struct pivot_table *,
-                                    const size_t *layer_indexes);
-
-#endif /* output/pivot-output.h */
index 424e93dec78482773d7a3013ab1d96c52bf82942..5c6467147300d43c0c98720c28a9b25ecaaecab8 100644 (file)
@@ -370,8 +370,7 @@ pivot_axis_iterator_next (size_t *indexes, const struct pivot_axis *axis)
           if (axis->dimensions[i]->n_leaves == 0)
             return NULL;
 
-      size_t size = axis->n_dimensions * sizeof *indexes;
-      return xzalloc (MAX (size, 1));
+      return xcalloc (axis->n_dimensions, sizeof *indexes);
     }
 
   for (size_t i = 0; i < axis->n_dimensions; i++)
@@ -994,25 +993,6 @@ pivot_table_is_empty (const struct pivot_table *table)
   return hmap_is_empty (&table->cells);
 }
 
-size_t *
-pivot_table_next_display_layer (const struct pivot_table *pt, size_t *indexes,
-                                bool print)
-{
-  const struct pivot_axis *layer_axis = &pt->axes[PIVOT_AXIS_LAYER];
-  if (print && pt->look->print_all_layers)
-    return pivot_axis_iterator_next (indexes, layer_axis);
-  else if (!indexes)
-    {
-      size_t size = layer_axis->n_dimensions * sizeof *pt->current_layer;
-      return xmemdup (pt->current_layer, MAX (size, 1));
-    }
-  else
-    {
-      free (indexes);
-      return NULL;
-    }
-}
-
 static unsigned int
 pivot_cell_hash_indexes (const size_t *indexes, size_t n_idx)
 {
index ce6b85df24b708ef799268ba480476b2054023a9..be82d0685ee1b6d4d80b06e00862967d8e2726b6 100644 (file)
@@ -432,7 +432,7 @@ struct pivot_table
     bool show_grid_lines;
     bool show_title;
     bool show_caption;
-    size_t *current_layer; /* axes[PIVOT_AXIS_LAYER].n_dimensions elements. */
+    size_t *current_layer; /* axis[PIVOT_AXIS_LAYER].n_dimensions elements. */
     enum settings_value_show show_values;
     enum settings_value_show show_variables;
     struct fmt_spec weight_format;
@@ -509,13 +509,6 @@ bool pivot_table_is_empty (const struct pivot_table *);
 /* Output. */
 void pivot_table_submit (struct pivot_table *);
 
-/* Layers. */
-#define PIVOT_TABLE_FOR_EACH_DISPLAY_LAYER(INDEXES, PT, PRINT)          \
-  for ((INDEXES) = NULL;                                                \
-       ((INDEXES) = pivot_table_next_display_layer (PT, INDEXES, PRINT)); )
-size_t *pivot_table_next_display_layer (const struct pivot_table *,
-                                        size_t *indexes, bool print);
-
 /* Data cells. */
 void pivot_table_put (struct pivot_table *, const size_t *dindexes, size_t n,
                       struct pivot_value *);
index d1706f4e7ecc4334c2e4d49e6f45b3fdc6335161..6857d9b3b67f7e0d01dd699a2c6de6893b0c1798 100644 (file)
@@ -116,8 +116,8 @@ struct spv_item
     char *structure_member;
 
     enum spv_item_type type;
-    char *label;                /* Localized label. */
-    char *command_id;           /* Non-localized unique command identifier. */
+    char *label;
+    char *command_id;           /* Unique command identifier. */
 
     /* Whether the item is visible.
        For SPV_ITEM_HEADING, false indicates that the item is collapsed.
index 7b8a23c8840420eb5a2fa42d767c11825e0c353f..1b17c320a6e8e5a119c5ac1ff70a79089dcd83c6 100644 (file)
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
 
-/* Initializes ITEM as a table item for rendering PT.  Takes ownership of
-   PT. */
-struct table_item *
-table_item_create (struct pivot_table *pt)
+struct table_item_text *
+table_item_text_create (const char *content)
+{
+  if (!content)
+    return NULL;
+
+  struct table_item_text *text = xmalloc (sizeof *text);
+  *text = (struct table_item_text) { .content = xstrdup (content) };
+  return text;
+}
+
+struct table_item_text *
+table_item_text_clone (const struct table_item_text *old)
+{
+  if (!old)
+    return NULL;
+
+  struct table_item_text *new = xmalloc (sizeof *new);
+  *new = (struct table_item_text) {
+    .content = xstrdup (old->content),
+    .footnotes = xmemdup (old->footnotes,
+                          old->n_footnotes * sizeof *old->footnotes),
+    .n_footnotes = old->n_footnotes,
+    .style = table_area_style_clone (NULL, old->style),
+  };
+  return new;
+}
+
+void
+table_item_text_destroy (struct table_item_text *text)
+{
+  if (text)
+    {
+      free (text->content);
+      free (text->footnotes);
+      table_area_style_free (text->style);
+      free (text);
+    }
+}
+
+void
+table_item_layer_copy (struct table_item_layer *dst,
+                       const struct table_item_layer *src)
+{
+  dst->content = xstrdup (src->content);
+  dst->footnotes = xmemdup (src->footnotes,
+                            src->n_footnotes * sizeof *src->footnotes);
+  dst->n_footnotes = src->n_footnotes;
+}
+void
+table_item_layer_uninit (struct table_item_layer *layer)
+{
+  if (layer)
+    {
+      free (layer->content);
+      free (layer->footnotes);
+    }
+}
+
+struct table_item_layers *
+table_item_layers_clone (const struct table_item_layers *old)
 {
-  pivot_table_assign_label_depth (pt);
+  if (!old)
+    return NULL;
 
+  struct table_item_layers *new = xmalloc (sizeof *new);
+  *new = (struct table_item_layers) {
+    .layers = xnmalloc (old->n_layers, sizeof *new->layers),
+    .n_layers = old->n_layers,
+    .style = table_area_style_clone (NULL, old->style),
+  };
+  for (size_t i = 0; i < new->n_layers; i++)
+    table_item_layer_copy (&new->layers[i], &old->layers[i]);
+  return new;
+}
+
+void
+table_item_layers_destroy (struct table_item_layers *layers)
+{
+  if (layers)
+    {
+      for (size_t i = 0; i < layers->n_layers; i++)
+        table_item_layer_uninit (&layers->layers[i]);
+      free (layers->layers);
+      table_area_style_free (layers->style);
+      free (layers);
+    }
+}
+
+/* Initializes ITEM as a table item for rendering TABLE.  The new table item
+   initially has the specified TITLE, CAPTION, and NOTES, which may each be
+   NULL.  The caller retains ownership of TITLE, CAPTION, and NOTES. */
+struct table_item *
+table_item_create (struct table *table, const char *title, const char *caption,
+                   const char *notes)
+{
   struct table_item *item = xmalloc (sizeof *item);
   *item = (struct table_item) {
     .output_item = OUTPUT_ITEM_INITIALIZER (&table_item_class),
-    .pt = pt,
+    .table = table,
+    .title = table_item_text_create (title),
+    .caption = table_item_text_create (caption),
+    .notes = notes ? xstrdup (notes) : NULL,
   };
   return item;
 }
 
+/* Returns the table contained by TABLE_ITEM.  The caller must not modify or
+   unref the returned table. */
+const struct table *
+table_item_get_table (const struct table_item *table_item)
+{
+  return table_item->table;
+}
+
+/* Returns ITEM's title, which is a null pointer if no title has been
+   set. */
+const struct table_item_text *
+table_item_get_title (const struct table_item *item)
+{
+  return item->title;
+}
+
+/* Sets ITEM's title to TITLE, replacing any previous title.  Specify NULL for
+   TITLE to clear any title from ITEM.  The caller retains ownership of TITLE.
+
+   This function may only be used on a table_item that is unshared. */
+void
+table_item_set_title (struct table_item *item,
+                      const struct table_item_text *title)
+{
+  assert (!table_item_is_shared (item));
+  table_item_text_destroy (item->title);
+  item->title = table_item_text_clone (title);
+}
+
+/* Returns ITEM's layers, which will be a null pointer if no layers have been
+   set. */
+const struct table_item_layers *
+table_item_get_layers (const struct table_item *item)
+{
+  return item->layers;
+}
+
+/* Sets ITEM's layers to LAYERS, replacing any previous layers.  Specify NULL
+   for LAYERS to clear any layers from ITEM.  The caller retains ownership of
+   LAYERS.
+
+   This function may only be used on a table_item that is unshared. */
+void
+table_item_set_layers (struct table_item *item,
+                       const struct table_item_layers *layers)
+{
+  assert (!table_item_is_shared (item));
+  table_item_layers_destroy (item->layers);
+  item->layers = table_item_layers_clone (layers);
+}
+
+/* Returns ITEM's caption, which is a null pointer if no caption has been
+   set. */
+const struct table_item_text *
+table_item_get_caption (const struct table_item *item)
+{
+  return item->caption;
+}
+
+/* Sets ITEM's caption to CAPTION, replacing any previous caption.  Specify
+   NULL for CAPTION to clear any caption from ITEM.  The caller retains
+   ownership of CAPTION.
+
+   This function may only be used on a table_item that is unshared. */
+void
+table_item_set_caption (struct table_item *item,
+                        const struct table_item_text *caption)
+{
+  assert (!table_item_is_shared (item));
+  table_item_text_destroy (item->caption);
+  item->caption = table_item_text_clone (caption);
+}
+
+/* Returns ITEM's notes, which is a null pointer if ITEM has no notes. */
+const char *
+table_item_get_notes (const struct table_item *item)
+{
+  return item->notes;
+}
+
+/* Sets ITEM's notes to NOTES, replacing any previous notes.  Specify NULL for
+   NOTES to clear any notes from ITEM.  The caller retains ownership of
+   NOTES.
+
+   This function may only be used on a table_item that is unshared.*/
+void
+table_item_set_notes (struct table_item *item, const char *notes)
+{
+  assert (!table_item_is_shared (item));
+  free (item->notes);
+  item->notes = notes ? xstrdup (notes) : NULL;
+}
+
 /* Submits TABLE_ITEM to the configured output drivers, and transfers ownership
    to the output subsystem. */
 void
@@ -58,26 +244,22 @@ table_item_submit (struct table_item *table_item)
 static const char *
 table_item_get_label (const struct output_item *output_item)
 {
-  struct table_item *item = to_table_item (output_item);
-
-  if (!item->cached_label)
-    {
-      if (!item->pt->title)
-        return _("Table");
-
-      item->cached_label = pivot_value_to_string (item->pt->title,
-                                                  SETTINGS_VALUE_SHOW_DEFAULT,
-                                                  SETTINGS_VALUE_SHOW_DEFAULT);
-    }
-  return item->cached_label;
+  const struct table_item *item = to_table_item (output_item);
+  return (item->title && item->title->content
+          ? item->title->content
+          : _("Table"));
 }
 
 static void
 table_item_destroy (struct output_item *output_item)
 {
   struct table_item *item = to_table_item (output_item);
+  table_item_text_destroy (item->title);
+  table_item_text_destroy (item->caption);
+  table_item_layers_destroy (item->layers);
+  free (item->notes);
   pivot_table_unref (item->pt);
-  free (item->cached_label);
+  table_unref (item->table);
   free (item);
 }
 
index 96394c4182eb7addf4ab21ed1e0ed30864d433e1..e4c40ab228c5ce959a90c828053cb70f24150528 100644 (file)
 #include "output/output-item.h"
 #include "output/table.h"
 
+/* Title or caption in a table item. */
+struct table_item_text
+  {
+    char *content;
+    const struct footnote **footnotes;
+    size_t n_footnotes;
+    struct table_area_style *style;
+  };
+
+struct table_item_text *table_item_text_create (const char *);
+struct table_item_text *table_item_text_clone (const struct table_item_text *);
+void table_item_text_destroy (struct table_item_text *);
+
+struct table_item_layer
+  {
+    char *content;
+    const struct footnote **footnotes;
+    size_t n_footnotes;
+  };
+
+void table_item_layer_copy (struct table_item_layer *,
+                            const struct table_item_layer *);
+void table_item_layer_uninit (struct table_item_layer *);
+
+struct table_item_layers
+  {
+    struct table_item_layer *layers;
+    size_t n_layers;
+    struct table_area_style *style;
+  };
+
+struct table_item_layers *table_item_layers_clone (
+  const struct table_item_layers *);
+void table_item_layers_destroy (struct table_item_layers *);
+
 /* A table item.
 
    The members of struct table_item should not be accessed directly.  Use one
 struct table_item
   {
     struct output_item output_item;   /* Superclass. */
-    struct pivot_table *pt;           /* The table to be rendered. */
-
-    char *cached_label;
+    struct table *table;              /* The table to be rendered. */
+    struct table_item_text *title;    /* Null if there is no title. */
+    struct table_item_text *caption;  /* Null if there is no caption. */
+    struct table_item_layers *layers; /* Null if there is no layer info. */
+    char *notes;                      /* Shown as tooltip. */
+    struct pivot_table *pt;
   };
 
-struct table_item *table_item_create (struct pivot_table *);
+struct table_item *table_item_create (struct table *, const char *title,
+                                      const char *caption, const char *notes);
+
+const struct table *table_item_get_table (const struct table_item *);
+
+const struct table_item_text *table_item_get_title (const struct table_item *);
+void table_item_set_title (struct table_item *,
+                           const struct table_item_text *);
+
+const struct table_item_layers *table_item_get_layers (
+  const struct table_item *);
+void table_item_set_layers (struct table_item *,
+                           const struct table_item_layers *);
+
+const struct table_item_text *table_item_get_caption (
+  const struct table_item *);
+void table_item_set_caption (struct table_item *,
+                             const struct table_item_text *);
+
+const char *table_item_get_notes (const struct table_item *);
+void table_item_set_notes (struct table_item *, const char *notes);
 \f
 /* This boilerplate for table_item, a subclass of output_item, was
    autogenerated by mk-class-boilerplate. */
index 70b62b1c5a4af42efddf81526a836693daea5c0c..cc00a05bdaa327f8188f43bdeb826bc311daa00c 100644 (file)
@@ -337,7 +337,7 @@ rerender (struct psppire_output_view *view)
       if (is_group_open_item (item->item))
         continue;
 
-      r = xr_fsm_create_for_scrolling (item->item, view->style, cr);
+      r = xr_fsm_create (item->item, view->style, cr);
       if (r == NULL)
         {
           g_warn_if_reached ();
@@ -451,7 +451,7 @@ psppire_output_view_put (struct psppire_output_view *view,
       if (view->y > 0)
         view->y += view->object_spacing;
 
-      struct xr_fsm *r = xr_fsm_create_for_scrolling (item, view->style, cr);
+      struct xr_fsm *r = xr_fsm_create (item, view->style, cr);
       if (r == NULL)
        {
          gdk_window_end_draw_frame (win, ctx);