output-item: Make label a part of every output_item.
[pspp.git] / src / output / spv / spv-output.c
blobcb4964a7f1d7bdf9d4c33b6fd661e366769684dd
1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2018 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/>. */
17 #include <config.h>
19 #include "output/spv/spv-output.h"
21 #include "output/pivot-table.h"
22 #include "output/spv/spv.h"
23 #include "output/text-item.h"
25 #include "gl/xalloc.h"
27 void
28 spv_text_submit (const struct spv_item *in)
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 (value, SETTINGS_VALUE_SHOW_DEFAULT,
37 SETTINGS_VALUE_SHOW_DEFAULT);
38 char *label = in->label ? xstrdup (in->label) : NULL;
39 struct text_item *item = text_item_create_nocopy (type, text, label);
40 const struct font_style *font = value->font_style;
41 if (font)
43 item->bold = font->bold;
44 item->italic = font->italic;
45 item->underline = font->underline;
46 item->markup = font->markup;
47 if (font->typeface)
48 item->typeface = xstrdup (font->typeface);
49 item->size = font->size;
51 text_item_submit (item);