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/>. */
17 #ifndef OUTPUT_TABLE_ITEM_H
18 #define OUTPUT_TABLE_ITEM_H 1
22 A table item is a subclass of an output item (see output-item.h) that
23 contains a table (see table.h) and some formatting properties. Currently
24 the formatting properties are an optional title (a brief description
25 typically displayed above the table) and an optional caption (a more verbose
26 description typically displayed below the table). */
28 #include "libpspp/compiler.h"
29 #include "output/output-item.h"
30 #include "output/table.h"
32 struct table_item_layer
35 struct footnote **footnotes;
39 void table_item_layer_copy (struct table_item_layer *,
40 const struct table_item_layer *);
41 void table_item_layer_uninit (struct table_item_layer *);
43 struct table_item_layers
45 struct table_item_layer *layers;
47 struct table_area_style *style;
50 struct table_item_layers *table_item_layers_clone (
51 const struct table_item_layers *);
52 void table_item_layers_destroy (struct table_item_layers *);
56 The members of struct table_item should not be accessed directly. Use one
57 of the accessor functions defined below. */
60 struct output_item output_item; /* Superclass. */
61 struct table *table; /* The table to be rendered. */
62 struct table_cell *title; /* Null if there is no title. */
63 struct table_cell *caption; /* Null if there is no caption. */
64 struct table_item_layers *layers; /* Null if there is no layer info. */
65 char *notes; /* Shown as tooltip. */
66 struct pivot_table *pt;
69 struct table_item *table_item_create (struct table *);
71 const struct table *table_item_get_table (const struct table_item *);
73 const struct table_cell *table_item_get_title (const struct table_item *);
74 void table_item_set_title (struct table_item *, const struct table_cell *);
76 const struct table_item_layers *table_item_get_layers (
77 const struct table_item *);
78 void table_item_set_layers (struct table_item *,
79 const struct table_item_layers *);
81 const struct table_cell *table_item_get_caption (const struct table_item *);
82 void table_item_set_caption (struct table_item *, const struct table_cell *);
84 const char *table_item_get_notes (const struct table_item *);
85 void table_item_set_notes (struct table_item *, const char *notes);
87 /* This boilerplate for table_item, a subclass of output_item, was
88 autogenerated by mk-class-boilerplate. */
91 #include "libpspp/cast.h"
93 extern const struct output_item_class table_item_class;
95 /* Returns true if SUPER is a table_item, otherwise false. */
97 is_table_item (const struct output_item *super)
99 return super->class == &table_item_class;
102 /* Returns SUPER converted to table_item. SUPER must be a table_item, as
103 reported by is_table_item. */
104 static inline struct table_item *
105 to_table_item (const struct output_item *super)
107 assert (is_table_item (super));
108 return UP_CAST (super, struct table_item, output_item);
111 /* Returns INSTANCE converted to output_item. */
112 static inline struct output_item *
113 table_item_super (const struct table_item *instance)
115 return CONST_CAST (struct output_item *, &instance->output_item);
118 /* Increments INSTANCE's reference count and returns INSTANCE. */
119 static inline struct table_item *
120 table_item_ref (const struct table_item *instance)
122 return to_table_item (output_item_ref (&instance->output_item));
125 /* Decrements INSTANCE's reference count, then destroys INSTANCE if
126 the reference count is now zero. */
128 table_item_unref (struct table_item *instance)
130 output_item_unref (&instance->output_item);
133 /* Returns true if INSTANCE's reference count is greater than 1,
136 table_item_is_shared (const struct table_item *instance)
138 return output_item_is_shared (&instance->output_item);
141 void table_item_submit (struct table_item *);
143 #endif /* output/table-item.h */