ascii_output_text (struct ascii_driver *a, const char *text)
{
ascii_output_table_item_unref (
- a, table_item_create (table_from_string (text), NULL, NULL));
+ a, table_item_create (table_from_string (text), NULL, NULL, NULL));
}
static void
bool tfoot = false;
int y;
- fputs ("<table>\n", html->file);
+ fputs ("<table", html->file);
+ if (item->notes)
+ {
+ fputs (" title=\"", html->file);
+ escape_string (html->file, item->notes, " ", "\n");
+ putc ('"', html->file);
+ }
+ fputs (">\n", html->file);
const struct table_item_text *caption = table_item_get_caption (item);
if (caption)
free (column_enumeration);
free (row_enumeration);
- struct table_item *ti = table_item_create (table, NULL, NULL);
+ struct table_item *ti = table_item_create (table, NULL, NULL, pt->notes);
if (pt->title)
{
struct pivot_value *subtype; /* Same as spv_item's subtype. */
struct pivot_value *corner_text;
struct pivot_value *caption;
- char *notes;
+ char *notes; /* Shown as tooltip. */
/* Dimensions. */
struct pivot_dimension **dimensions;
}
/* Initializes ITEM as a table item for rendering TABLE. The new table item
- initially has the specified TITLE and CAPTION, which may each be NULL. The
- caller retains ownership of TITLE and CAPTION. */
+ 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)
+table_item_create (struct table *table, const char *title, const char *caption,
+ const char *notes)
{
struct table_item *item = xmalloc (sizeof *item);
output_item_init (&item->output_item, &table_item_class);
item->title = table_item_text_create (title);
item->layers = NULL;
item->caption = table_item_text_create (caption);
+ item->notes = notes ? xstrdup (notes) : NULL;
item->pt = NULL;
return item;
}
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
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);
table_unref (item->table);
free (item);
of the accessor functions defined below. */
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 *caption; /* Null if there is no caption. */
+ 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 *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 table *, const char *title,
- const char *caption);
+ const char *caption, const char *notes);
const struct table *table_item_get_table (const struct table_item *);
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. */
if (text_item->type == TEXT_ITEM_SYNTAX || text_item->type == TEXT_ITEM_LOG)
opts |= TAB_FIX;
table_text (tab, 0, 0, opts, text_item_get_text (text_item));
- struct table_item *table_item = table_item_create (tab, NULL, NULL);
+ struct table_item *table_item = table_item_create (tab, NULL, NULL, NULL);
text_item_unref (text_item);
return table_item;
}
}
table = tables[n_tables - 1];
- table_item_submit (table_item_create (table, NULL, NULL));
+ table_item_submit (table_item_create (table, NULL, NULL, NULL));
free (tables);
}
else