1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2009, 2010, 2011 Free Sonftware 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 #ifndef OUTPUT_TEXT_ITEM_H
18 #define OUTPUT_TEXT_ITEM_H 1
22 A text item is a subclass of an output item (see
23 output/output-item.h).
25 A text item is just a text string. */
28 #include "libpspp/compiler.h"
29 #include "output/output-item.h"
33 TEXT_ITEM_PAGE_TITLE, /* TITLE and SUBTITLE commands. */
34 TEXT_ITEM_TITLE, /* Title. */
35 TEXT_ITEM_PARAGRAPH, /* Normal paragraph of text. */
38 TEXT_ITEM_SYNTAX, /* A single line of PSPP syntax. */
39 TEXT_ITEM_LOG, /* Other logging. */
41 /* Spacing. Some output drivers that are not based on lines and pages
42 (e.g. CSV, HTML) may ignore these. */
43 TEXT_ITEM_BLANK_LINE, /* Blank line. */
44 TEXT_ITEM_EJECT_PAGE /* Eject page. */
50 struct output_item output_item;
51 char *text; /* The content. */
52 enum text_item_type type; /* Type. */
55 bool bold, italic, underline, markup;
58 struct text_item *text_item_create (enum text_item_type, const char *text);
59 struct text_item *text_item_create_nocopy (enum text_item_type, char *text);
60 struct text_item *text_item_create_format (enum text_item_type,
61 const char *format, ...)
64 enum text_item_type text_item_get_type (const struct text_item *);
65 const char *text_item_get_text (const struct text_item *);
67 struct table_item *text_item_to_table_item (struct text_item *);
69 /* This boilerplate for text_item, a subclass of output_item, was
70 autogenerated by mk-class-boilerplate. */
73 #include "libpspp/cast.h"
75 extern const struct output_item_class text_item_class;
77 /* Returns true if SUPER is a text_item, otherwise false. */
79 is_text_item (const struct output_item *super)
81 return super->class == &text_item_class;
84 /* Returns SUPER converted to text_item. SUPER must be a text_item, as
85 reported by is_text_item. */
86 static inline struct text_item *
87 to_text_item (const struct output_item *super)
89 assert (is_text_item (super));
90 return UP_CAST (super, struct text_item, output_item);
93 /* Returns INSTANCE converted to output_item. */
94 static inline struct output_item *
95 text_item_super (const struct text_item *instance)
97 return CONST_CAST (struct output_item *, &instance->output_item);
100 /* Increments INSTANCE's reference count and returns INSTANCE. */
101 static inline struct text_item *
102 text_item_ref (const struct text_item *instance)
104 return to_text_item (output_item_ref (&instance->output_item));
107 /* Decrements INSTANCE's reference count, then destroys INSTANCE if
108 the reference count is now zero. */
110 text_item_unref (struct text_item *instance)
112 output_item_unref (&instance->output_item);
115 /* Returns true if INSTANCE's reference count is greater than 1,
118 text_item_is_shared (const struct text_item *instance)
120 return output_item_is_shared (&instance->output_item);
123 void text_item_submit (struct text_item *);
125 #endif /* output/text-item.h */