- if (csv->captions)
- csv_output_table_item_text (csv, table_item_get_caption (table_item),
- "Caption");
-
- const struct footnote **f;
- size_t n_footnotes = table_collect_footnotes (table_item, &f);
- if (n_footnotes)
- {
- fputs ("\nFootnotes:\n", csv->file);
+static void
+csv_output_table_layer (struct csv_driver *csv, const struct pivot_table *pt,
+ const size_t *layer_indexes)
+{
+ struct table *title, *layers, *body, *caption, *footnotes;
+ pivot_output (pt, layer_indexes, true, &title, &layers, &body,
+ &caption, &footnotes, NULL, NULL);
+
+ csv_put_separator (csv);
+ csv_output_table__ (csv, pt, title, "Table");
+ csv_output_table__ (csv, pt, layers, "Layer");
+ csv_output_table__ (csv, pt, body, NULL);
+ csv_output_table__ (csv, pt, caption, "Caption");
+ csv_output_table__ (csv, pt, footnotes, "Footnote");
+
+ table_unref (title);
+ table_unref (layers);
+ table_unref (body);
+ table_unref (caption);
+ table_unref (footnotes);
+}