output: Make table_item a pivot_table, table_cell a pivot_value.
[pspp] / src / output / spv / spv-output.c
1 /* PSPP - a program for statistical analysis.
2    Copyright (C) 2018 Free Software Foundation, Inc.
3
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.
8
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.
13
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/>. */
16
17 #include <config.h>
18
19 #include "output/spv/spv-output.h"
20
21 #include "output/pivot-table.h"
22 #include "output/spv/spv.h"
23 #include "output/text-item.h"
24
25 #include "gl/xalloc.h"
26
27 void
28 spv_text_submit (const struct spv_item *in)
29 {
30   enum spv_item_class class = spv_item_get_class (in);
31   enum text_item_type type
32     = (class == SPV_CLASS_HEADINGS ? TEXT_ITEM_TITLE
33        : class == SPV_CLASS_PAGETITLE ? TEXT_ITEM_PAGE_TITLE
34        : TEXT_ITEM_LOG);
35   const struct pivot_value *value = spv_item_get_text (in);
36   char *text = pivot_value_to_string_defaults (value);
37   char *label = in->label ? xstrdup (in->label) : NULL;
38   struct text_item *item = text_item_create_nocopy (type, text, label);
39
40   if (value->font_style)
41     {
42       font_style_uninit (&item->style);
43       font_style_copy (NULL, &item->style, value->font_style);
44     }
45   text_item_submit (item);
46 }