1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2009, 2011, 2014 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 #include "output/table-provider.h"
23 #include "libpspp/assertion.h"
24 #include "libpspp/cast.h"
25 #include "output/driver.h"
26 #include "output/output-item-provider.h"
27 #include "output/pivot-table.h"
28 #include "output/table-item.h"
30 #include "gl/xalloc.h"
33 #define _(msgid) gettext (msgid)
35 /* Initializes ITEM as a table item for rendering PT. Takes ownership of
38 table_item_create (struct pivot_table *pt)
40 pivot_table_assign_label_depth (pt);
42 struct table_item *item = xmalloc (sizeof *item);
43 *item = (struct table_item) {
44 .output_item = OUTPUT_ITEM_INITIALIZER (&table_item_class),
50 /* Submits TABLE_ITEM to the configured output drivers, and transfers ownership
51 to the output subsystem. */
53 table_item_submit (struct table_item *table_item)
55 output_submit (&table_item->output_item);
59 table_item_get_label (const struct output_item *output_item)
61 struct table_item *item = to_table_item (output_item);
63 if (!item->cached_label)
68 item->cached_label = pivot_value_to_string (item->pt->title,
69 SETTINGS_VALUE_SHOW_DEFAULT,
70 SETTINGS_VALUE_SHOW_DEFAULT);
72 return item->cached_label;
76 table_item_destroy (struct output_item *output_item)
78 struct table_item *item = to_table_item (output_item);
79 pivot_table_unref (item->pt);
80 free (item->cached_label);
84 const struct output_item_class table_item_class =