render: Fix up layer violation in add_footnote_page().
authorBen Pfaff <blp@cs.stanford.edu>
Thu, 26 Dec 2019 01:14:32 +0000 (01:14 +0000)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 29 Dec 2019 05:28:10 +0000 (05:28 +0000)
The layering violation came from having to look up the default style
for a footer, so we fix it by forbidding footnotes from using the
default style.

src/output/render.c
src/output/table.c
tests/output/render-test.c

index 423940b068eabaeff29b63e06ffea287820152c0..d26fc46ebcb494adf4eeaf86013c5d5c74880e27 100644 (file)
@@ -26,7 +26,6 @@
 #include "libpspp/hash-functions.h"
 #include "libpspp/hmap.h"
 #include "libpspp/pool.h"
-#include "output/pivot-table.h" /* XXX for PIVOT_AREA_FOOTER */
 #include "output/render.h"
 #include "output/table-item.h"
 #include "output/table.h"
@@ -1510,17 +1509,10 @@ add_footnote_page (struct render_pager *p, const struct table_item *item)
 
   struct table *t = table_create (1, n_footnotes, 0, 0, 0, 0);
 
-  const struct area_style *style = item->table->styles[PIVOT_AREA_FOOTER];
-  if (!style)
-    style = pivot_area_get_default_style (PIVOT_AREA_FOOTER);
-  t->styles[PIVOT_AREA_FOOTER] = area_style_clone (t->container, style);
-
   for (size_t i = 0; i < n_footnotes; i++)
     {
-      table_text_format (t, 0, i, PIVOT_AREA_FOOTER << TAB_STYLE_SHIFT,
-                         "%s. %s", f[i]->marker, f[i]->content);
-      if (f[i]->style)
-        table_add_style (t, 0, i, f[i]->style);
+      table_text_format (t, 0, i, 0, "%s. %s", f[i]->marker, f[i]->content);
+      table_add_style (t, 0, i, f[i]->style);
     }
   render_pager_add_table (p, t, 0);
 
index 2fa40c9091fda608304757134f70ed819b07b3a7..a4730f85e5a3219c0ed67acc2139cf2fb68c9bca 100644 (file)
@@ -644,6 +644,8 @@ struct footnote *
 table_create_footnote (struct table *table, size_t idx, const char *content,
                      const char *marker, struct area_style *style)
 {
+  assert (style);
+
   struct footnote *f = pool_alloc (table->container, sizeof *f);
   f->idx = idx;
   f->content = pool_strdup (table->container, content);
@@ -654,8 +656,10 @@ table_create_footnote (struct table *table, size_t idx, const char *content,
 
 void
 table_add_footnote (struct table *table, int x, int y,
-                  const struct footnote *f)
+                    const struct footnote *f)
 {
+  assert (f->style);
+
   int index = x + y * table_nc (table);
   unsigned short opt = table->ct[index];
   struct table_joined_cell *j;
index 90b5867f873f263df2938a1deff03b6ca9cc976b..49a76a66adaec574572f632ca76a64e5e68dfc06 100644 (file)
@@ -475,7 +475,8 @@ read_table (FILE *stream)
               {
                 char marker[2] = { 'a' + n_footnotes, '\0' };
                 struct footnote *f = table_create_footnote (
-                  tab, n_footnotes, content, marker, NULL);
+                  tab, n_footnotes, content, marker,
+                  area_style_clone (tab->container, &left_style));
                 table_add_footnote (tab, c, r, f);
                 n_footnotes++;
               }