output: Add support for layer info in table output.
authorBen Pfaff <blp@cs.stanford.edu>
Fri, 23 Nov 2018 22:50:13 +0000 (14:50 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Tue, 25 Dec 2018 20:50:07 +0000 (12:50 -0800)
src/output/html.c
src/output/odt.c
src/output/render.c
src/output/table-item.c
src/output/table-item.h

index 7cc2fecab7d2704b3acfed8d00cf20ac939aadb0..0b61486bd6e39200d2d371c31cd2e853a23ff39c 100644 (file)
@@ -480,10 +480,16 @@ html_output_table (struct html_driver *html, const struct table_item *item)
   fputs ("<TBODY VALIGN=\"TOP\">\n", html->file);
 
   const struct table_item_text *title = table_item_get_title (item);
-  if (title)
+  const struct table_item_text *layers = table_item_get_layers (item);
+  if (title || layers)
     {
       fputs ("  <CAPTION>", html->file);
-      html_put_table_item_text (html, title);
+      if (title)
+        html_put_table_item_text (html, title);
+      if (title && layers)
+        fputs ("<BR>\n", html->file);
+      if (layers)
+        html_put_table_item_text (html, layers);
       fputs ("</CAPTION>\n", html->file);
     }
 
index 153cd393c116f357f615e3d113ea9e336d8292e5..1d430eac5a355b234bef250e95cc7464ee6e1b44 100644 (file)
@@ -467,6 +467,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"));
index bb4b4ad996304449d557fdf5a58886eb84853845..eb5f1cfe1aa213d1da56221fcc17e652e9fcf45c 100644 (file)
@@ -1481,6 +1481,9 @@ render_pager_create (const struct render_params *params,
   /* Title. */
   add_text_page (p, table_item_get_title (table_item), title_width);
 
+  /* Layers. */
+  add_text_page (p, table_item_get_layers (table_item), title_width);
+
   /* Body. */
   render_pager_add_table (p, table_ref (table_item_get_table (table_item)), 0);
 
index 6d4927326c3e6ea7f89e13de81c0d730b9b56fce..1308cb86503cddd887354bbdac1d13c9c6798555 100644 (file)
@@ -80,6 +80,7 @@ table_item_create (struct table *table, const char *title, const char *caption)
   output_item_init (&item->output_item, &table_item_class);
   item->table = table;
   item->title = table_item_text_create (title);
+  item->layers = NULL;
   item->caption = table_item_text_create (caption);
   return item;
 }
@@ -113,6 +114,28 @@ table_item_set_title (struct table_item *item,
   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_text *
+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_text *layers)
+{
+  assert (!table_item_is_shared (item));
+  table_item_text_destroy (item->layers);
+  item->layers = table_item_text_clone (layers);
+}
+
 /* Returns ITEM's caption, which is a null pointer if no caption has been
    set. */
 const struct table_item_text *
@@ -147,8 +170,9 @@ static void
 table_item_destroy (struct output_item *output_item)
 {
   struct table_item *item = to_table_item (output_item);
-  free (item->title);
-  free (item->caption);
+  table_item_text_destroy (item->title);
+  table_item_text_destroy (item->layers);
+  table_item_text_destroy (item->caption);
   table_unref (item->table);
   free (item);
 }
index 3b8c09d75909fb51a2efa1ef0f5a5d556e42a883..ffdc4b682c204ce8dc2be9e729f6fb438cc2640b 100644 (file)
@@ -51,6 +51,7 @@ struct table_item
     struct output_item output_item;  /* Superclass. */
     struct table *table;             /* The table to be rendered. */
     struct table_item_text *title;   /* Null if there is no title. */
+    struct table_item_text *layers;  /* Null if there is no layer info. */
     struct table_item_text *caption; /* Null if there is no caption. */
   };
 
@@ -63,6 +64,11 @@ 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_text *table_item_get_layers (
+  const struct table_item *);
+void table_item_set_layers (struct table_item *,
+                           const struct table_item_text *);
+
 const struct table_item_text *table_item_get_caption (
   const struct table_item *);
 void table_item_set_caption (struct table_item *,