#include "libpspp/pool.h"
#include "libpspp/u8-line.h"
#include "output/pivot-table.h"
-#include "output/tab.h"
+#include "output/table.h"
#include "output/text-item.h"
#include "gl/xalloc.h"
*u8_line_reserve (line, 0, 1, 1) = leader;
if (trns->writer == NULL)
- tab_output_text (TAB_FIX, ds_cstr (&line->s) + 1);
+ table_output_text (TAB_FIX, ds_cstr (&line->s) + 1);
else
{
size_t len = ds_length (&line->s);
src/output/pivot-table.h \
src/output/render.c \
src/output/render.h \
- src/output/tab.h \
src/output/table-item.c \
src/output/table-item.h \
src/output/table-provider.h \
#include "data/settings.h"
#include "libpspp/assertion.h"
#include "libpspp/pool.h"
-#include "output/tab.h"
#include "output/table.h"
#include "output/table-item.h"
#include "output/text-item.h"
if (rotate_label)
opts |= TAB_ROTATE;
}
- tab_joint_text (t, x1, y1, x2, y2, opts, ds_cstr (&s));
+ table_joint_text (t, x1, y1, x2, y2, opts, ds_cstr (&s));
ds_destroy (&s);
if (value)
{
if (value->cell_style || value->font_style)
- tab_add_style (t, x1, y1,
- area_style_override (t->container, style,
- value->cell_style,
- value->font_style));
-
+ table_add_style (t, x1, y1,
+ area_style_override (t->container, style,
+ value->cell_style,
+ value->font_style));
+
for (size_t i = 0; i < value->n_footnotes; i++)
- tab_add_footnote (t, x1, y1, footnotes[value->footnotes[i]->idx]);
+ table_add_footnote (t, x1, y1, footnotes[value->footnotes[i]->idx]);
}
}
{
int rule = get_table_rule (styles, style_idx);
if (axis == H)
- tab_hline (t, rule, b0, b1, a);
+ table_hline (t, rule, b0, b1, a);
else
- tab_vline (t, rule, a, b0, b1);
+ table_vline (t, rule, a, b0, b1);
}
static void
[H] = pt->axes[PIVOT_AXIS_ROW].label_depth,
[V] = pt->axes[PIVOT_AXIS_COLUMN].label_depth,
};
- struct table *table = tab_create (body[H] + stub[H],
- body[V] + stub[V],
- stub[H], 0, stub[V], 0);
+ struct table *table = table_create (body[H] + stub[H],
+ body[V] + stub[V],
+ stub[H], 0, stub[V], 0);
for (size_t i = 0; i < PIVOT_N_AREAS; i++)
table->styles[i] = area_style_override (table->container, &pt->areas[i],
pt->footnotes[i]->content, pt->show_values, pt->show_variables);
char *marker = pivot_value_to_string (
pt->footnotes[i]->marker, pt->show_values, pt->show_variables);
- footnotes[i] = tab_create_footnote (
+ footnotes[i] = table_create_footnote (
table, i, content, marker,
area_style_override (table->container, &pt->areas[PIVOT_AREA_FOOTER],
pt->footnotes[i]->content->cell_style,
if (table_nc (table) && table_nr (table))
{
- tab_hline (
+ table_hline (
table, get_table_rule (pt->borders, PIVOT_BORDER_INNER_TOP),
0, table_nc (table) - 1, 0);
- tab_hline (
+ table_hline (
table, get_table_rule (pt->borders, PIVOT_BORDER_INNER_BOTTOM),
0, table_nc (table) - 1, table_nr (table));
- tab_vline (
+ table_vline (
table, get_table_rule (pt->borders, PIVOT_BORDER_INNER_LEFT),
0, 0, table_nr (table) - 1);
- tab_vline (
+ table_vline (
table, get_table_rule (pt->borders, PIVOT_BORDER_INNER_RIGHT),
table_nc (table), 0, table_nr (table) - 1);
if (stub[V])
- tab_hline (
+ table_hline (
table, get_table_rule (pt->borders, PIVOT_BORDER_DATA_TOP),
0, table_nc (table) - 1, stub[V]);
if (stub[H])
- tab_vline (
+ table_vline (
table, get_table_rule (pt->borders, PIVOT_BORDER_DATA_LEFT),
stub[H], 0, table_nr (table) - 1);
#include "libpspp/hmap.h"
#include "libpspp/pool.h"
#include "output/render.h"
-#include "output/tab.h"
#include "output/table-item.h"
#include "output/table.h"
if (!n_footnotes)
return;
- struct table *t = tab_create (1, n_footnotes, 0, 0, 0, 0);
+ struct table *t = table_create (1, n_footnotes, 0, 0, 0, 0);
for (size_t i = 0; i < n_footnotes; i++)
{
- tab_text_format (t, 0, i, TAB_LEFT, "%s. %s",
- f[i]->marker, f[i]->content);
+ table_text_format (t, 0, i, TAB_LEFT, "%s. %s",
+ f[i]->marker, f[i]->content);
if (f[i]->style)
- tab_add_style (t, 0, i, f[i]->style);
+ table_add_style (t, 0, i, f[i]->style);
}
render_pager_add_table (p, t, 0);
if (!t)
return;
- struct table *tab = tab_create (1, 1, 0, 0, 0, 0);
- tab_text (tab, 0, 0, 0, t->content);
+ struct table *tab = table_create (1, 1, 0, 0, 0, 0);
+ table_text (tab, 0, 0, 0, t->content);
for (size_t i = 0; i < t->n_footnotes; i++)
- tab_add_footnote (tab, 0, 0, t->footnotes[i]);
+ table_add_footnote (tab, 0, 0, t->footnotes[i]);
if (t->style)
tab->styles[0] = area_style_clone (tab->container, t->style);
render_pager_add_table (p, tab, min_width);
if (!layers)
return;
- struct table *tab = tab_create (1, layers->n_layers, 0, 0, 0, 0);
+ struct table *tab = table_create (1, layers->n_layers, 0, 0, 0, 0);
for (size_t i = 0; i < layers->n_layers; i++)
{
const struct table_item_layer *layer = &layers->layers[i];
- tab_text (tab, 0, i, 0, layer->content);
+ table_text (tab, 0, i, 0, layer->content);
for (size_t j = 0; j < layer->n_footnotes; j++)
- tab_add_footnote (tab, 0, i, layer->footnotes[j]);
+ table_add_footnote (tab, 0, i, layer->footnotes[j]);
}
if (layers->style)
tab->styles[0] = area_style_clone (tab->container, layers->style);
+++ /dev/null
-/* PSPP - a program for statistical analysis.
- Copyright (C) 1997, 1998, 1999, 2000, 2009, 2011, 2014 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#ifndef OUTPUT_TAB_H
-#define OUTPUT_TAB_H
-
-/* Simple table class.
-
- This is a type of table (see output/table.h) whose content is composed
- manually by the code that generates it, by filling in cells one by one.
-*/
-
-#include "libpspp/compiler.h"
-#include "output/table.h"
-#include "data/format.h"
-
-/* Rule masks. */
-#define TAB_RULE_TYPE_MASK 7
-#define TAB_RULE_TYPE_SHIFT 0
-#define TAB_RULE_STYLE_MASK (31 << TAB_RULE_STYLE_SHIFT)
-#define TAB_RULE_STYLE_SHIFT 3
-
-/* Tables. */
-struct table *tab_create (int nc, int nr, int hl, int hr, int ht, int hb);
-
-/* Rules. */
-void tab_hline (struct table *, int style, int x1, int x2, int y);
-void tab_vline (struct table *, int style, int x, int y1, int y2);
-void tab_box (struct table *, int f_h, int f_v, int i_h, int i_v,
- int x1, int y1, int x2, int y2);
-
-/* Cells. */
-void tab_text (struct table *, int c, int r, unsigned opt, const char *);
-void tab_text_format (struct table *, int c, int r, unsigned opt,
- const char *, ...)
- PRINTF_FORMAT (5, 6);
-
-void tab_joint_text (struct table *, int x1, int y1, int x2, int y2,
- unsigned opt, const char *);
-
-struct footnote *tab_create_footnote (struct table *, size_t idx,
- const char *content, const char *marker,
- struct area_style *);
-void tab_add_footnote (struct table *, int x, int y,
- const struct footnote *);
-
-void tab_add_style (struct table *, int x, int y,
- const struct area_style *);
-
-bool tab_cell_is_empty (const struct table *, int c, int r);
-
-/* Simple output. */
-void tab_output_text (int options, const char *string);
-void tab_output_text_format (int options, const char *, ...)
- PRINTF_FORMAT (2, 3);
-
-#endif /* output/tab.h */
-
#include "libpspp/pool.h"
#include "libpspp/str.h"
#include "output/table-item.h"
-#include "output/tab.h"
+#include "output/table.h"
#include "output/text-item.h"
#include "gl/xalloc.h"
struct table *
table_from_string (const char *text)
{
- struct table *t = tab_create (1, 1, 0, 0, 0, 0);
- tab_text (t, 0, 0, TAB_LEFT, text);
+ struct table *t = table_create (1, 1, 0, 0, 0, 0);
+ table_text (t, 0, 0, TAB_LEFT, text);
return t;
}
\f
static const bool debugging = true;
/* Joined cell. */
-struct tab_joined_cell
+struct table_joined_cell
{
int d[TABLE_N_AXES][2]; /* Table region, same as struct table_cell. */
char *text;
The table's cells are initially empty. */
struct table *
-tab_create (int nc, int nr, int hl, int hr, int ht, int hb)
+table_create (int nc, int nr, int hl, int hr, int ht, int hb)
{
struct table *t;
/* Draws a vertical line to the left of cells at horizontal position X
from Y1 to Y2 inclusive in style STYLE, if style is not -1. */
void
-tab_vline (struct table *t, int style, int x, int y1, int y2)
+table_vline (struct table *t, int style, int x, int y1, int y2)
{
if (debugging)
{
/* Draws a horizontal line above cells at vertical position Y from X1
to X2 inclusive in style STYLE, if style is not -1. */
void
-tab_hline (struct table *t, int style, int x1, int x2, int y)
+table_hline (struct table *t, int style, int x1, int x2, int y)
{
if (debugging)
{
drawing those lines. This is distinct from 0, which draws a null
line. */
void
-tab_box (struct table *t, int f_h, int f_v, int i_h, int i_v,
- int x1, int y1, int x2, int y2)
+table_box (struct table *t, int f_h, int f_v, int i_h, int i_v,
+ int x1, int y1, int x2, int y2)
{
if (debugging)
{
/* Cells. */
static void
-do_tab_text (struct table *table, int c, int r, unsigned opt, char *text)
+do_table_text (struct table *table, int c, int r, unsigned opt, char *text)
{
assert (c >= 0);
assert (r >= 0);
{
if (c < 0 || r < 0 || c >= table_nc (table) || r >= table_nr (table))
{
- printf ("tab_text(): bad cell (%d,%d) in table size (%d,%d)\n",
+ printf ("table_text(): bad cell (%d,%d) in table size (%d,%d)\n",
c, r, table_nc (table), table_nr (table));
return;
}
/* Sets cell (C,R) in TABLE, with options OPT, to have text value
TEXT. */
void
-tab_text (struct table *table, int c, int r, unsigned opt,
+table_text (struct table *table, int c, int r, unsigned opt,
const char *text)
{
- do_tab_text (table, c, r, opt, pool_strdup (table->container, text));
+ do_table_text (table, c, r, opt, pool_strdup (table->container, text));
}
/* Sets cell (C,R) in TABLE, with options OPT, to have text value
FORMAT, which is formatted as if passed to printf. */
void
-tab_text_format (struct table *table, int c, int r, unsigned opt,
- const char *format, ...)
+table_text_format (struct table *table, int c, int r, unsigned opt,
+ const char *format, ...)
{
va_list args;
va_start (args, format);
- do_tab_text (table, c, r, opt,
- pool_vasprintf (table->container, format, args));
+ do_table_text (table, c, r, opt,
+ pool_vasprintf (table->container, format, args));
va_end (args);
}
-static struct tab_joined_cell *
+static struct table_joined_cell *
add_joined_cell (struct table *table, int x1, int y1, int x2, int y2,
unsigned opt)
{
- struct tab_joined_cell *j;
+ struct table_joined_cell *j;
assert (x1 >= 0);
assert (y1 >= 0);
|| x2 < x1 || x2 >= table_nc (table)
|| y2 < y1 || y2 >= table_nr (table))
{
- printf ("tab_joint_text(): bad cell "
+ printf ("table_joint_text(): bad cell "
"(%d,%d)-(%d,%d) in table size (%d,%d)\n",
x1, y1, x2, y2, table_nc (table), table_nr (table));
return NULL;
}
}
- tab_box (table, -1, -1, TAL_0, TAL_0, x1, y1, x2, y2);
+ table_box (table, -1, -1, TAL_0, TAL_0, x1, y1, x2, y2);
j = pool_alloc (table->container, sizeof *j);
j->d[TABLE_HORZ][0] = x1;
/* Joins cells (X1,X2)-(Y1,Y2) inclusive in TABLE, and sets them with
options OPT to have text value TEXT. */
void
-tab_joint_text (struct table *table, int x1, int y1, int x2, int y2,
- unsigned opt, const char *text)
+table_joint_text (struct table *table, int x1, int y1, int x2, int y2,
+ unsigned opt, const char *text)
{
char *s = pool_strdup (table->container, text);
if (x1 == x2 && y1 == y2)
- do_tab_text (table, x1, y1, opt, s);
+ do_table_text (table, x1, y1, opt, s);
else
add_joined_cell (table, x1, y1, x2, y2, opt)->text = s;
}
struct footnote *
-tab_create_footnote (struct table *table, size_t idx, const char *content,
+table_create_footnote (struct table *table, size_t idx, const char *content,
const char *marker, struct area_style *style)
{
struct footnote *f = pool_alloc (table->container, sizeof *f);
}
void
-tab_add_footnote (struct table *table, int x, int y,
+table_add_footnote (struct table *table, int x, int y,
const struct footnote *f)
{
int index = x + y * table_nc (table);
unsigned short opt = table->ct[index];
- struct tab_joined_cell *j;
+ struct table_joined_cell *j;
if (opt & TAB_JOIN)
j = table->cc[index];
}
void
-tab_add_style (struct table *table, int x, int y,
- const struct area_style *style)
+table_add_style (struct table *table, int x, int y,
+ const struct area_style *style)
{
int index = x + y * table_nc (table);
unsigned short opt = table->ct[index];
- struct tab_joined_cell *j;
+ struct table_joined_cell *j;
if (opt & TAB_JOIN)
j = table->cc[index];
}
bool
-tab_cell_is_empty (const struct table *table, int c, int r)
+table_cell_is_empty (const struct table *table, int c, int r)
{
return table->cc[c + r * table_nc (table)] == NULL;
}
This function is obsolete. Please do not add new uses of it. Instead, use
a text_item (see output/text-item.h). */
void
-tab_output_text (int options UNUSED, const char *string)
+table_output_text (int options UNUSED, const char *string)
{
text_item_submit (text_item_create (TEXT_ITEM_LOG, string));
}
-/* Same as tab_output_text(), but FORMAT is passed through printf-like
+/* Same as table_output_text(), but FORMAT is passed through printf-like
formatting before output. */
void
-tab_output_text_format (int options, const char *format, ...)
+table_output_text_format (int options, const char *format, ...)
{
va_list args;
char *text;
text = xvasprintf (format, args);
va_end (args);
- tab_output_text (options, text);
+ table_output_text (options, text);
free (text);
}
if (opt & TAB_JOIN)
{
- const struct tab_joined_cell *jc = cc;
+ const struct table_joined_cell *jc = cc;
cell->text = jc->text;
cell->footnotes = jc->footnotes;
broken across more than one page, those rows or columns are repeated on each
page.
- Every table is an instance of a particular table class that is responsible
- for keeping track of cell data. By far the most common table class is
- struct table (see output/tab.h). This header also declares some other
- kinds of table classes, near the end of the file.
-
A table is not itself an output_item, and thus a table cannot by itself be
used for output, but they can be embedded inside struct table_item (see
table-item.h) for that purpose. */
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
+#include "libpspp/compiler.h"
struct casereader;
struct fmt_spec;
{ return t->h[TABLE_VERT][0]; }
static inline int table_hb (const struct table *t)
{ return t->h[TABLE_VERT][1]; }
-\f
-/* Table classes. */
-/* Simple kinds of tables. */
+/* Simple kinds of output. */
struct table *table_from_string (const char *);
+void table_output_text (int options, const char *string);
+void table_output_text_format (int options, const char *, ...)
+ PRINTF_FORMAT (2, 3);
+
+/* Rule masks. */
+#define TAB_RULE_TYPE_MASK 7
+#define TAB_RULE_TYPE_SHIFT 0
+#define TAB_RULE_STYLE_MASK (31 << TAB_RULE_STYLE_SHIFT)
+#define TAB_RULE_STYLE_SHIFT 3
+
+/* Tables. */
+struct table *table_create (int nc, int nr, int hl, int hr, int ht, int hb);
+
+/* Rules. */
+void table_hline (struct table *, int style, int x1, int x2, int y);
+void table_vline (struct table *, int style, int x, int y1, int y2);
+void table_box (struct table *, int f_h, int f_v, int i_h, int i_v,
+ int x1, int y1, int x2, int y2);
+
+/* Cells. */
+void table_text (struct table *, int c, int r, unsigned opt, const char *);
+void table_text_format (struct table *, int c, int r, unsigned opt,
+ const char *, ...)
+ PRINTF_FORMAT (5, 6);
+
+void table_joint_text (struct table *, int x1, int y1, int x2, int y2,
+ unsigned opt, const char *);
+
+struct footnote *table_create_footnote (struct table *, size_t idx,
+ const char *content,
+ const char *marker,
+ struct area_style *);
+void table_add_footnote (struct table *, int x, int y,
+ const struct footnote *);
+
+void table_add_style (struct table *, int x, int y,
+ const struct area_style *);
+
+bool table_cell_is_empty (const struct table *, int c, int r);
#endif /* output/table.h */
#include "libpspp/pool.h"
#include "output/driver.h"
#include "output/output-item-provider.h"
-#include "output/tab.h"
+#include "output/table.h"
#include "output/table-item.h"
#include "output/table-provider.h"
struct table_item *
text_item_to_table_item (struct text_item *text_item)
{
- struct table *tab = tab_create (1, 1, 0, 0, 0, 0);
+ struct table *tab = table_create (1, 1, 0, 0, 0, 0);
struct area_style *style = pool_alloc (tab->container, sizeof *style);
*style = (struct area_style) { AREA_STYLE_INITIALIZER__,
opts |= TAB_MARKUP;
if (text_item->type == TEXT_ITEM_SYNTAX || text_item->type == TEXT_ITEM_LOG)
opts |= TAB_FIX;
- tab_text (tab, 0, 0, opts, text_item_get_text (text_item));
+ table_text (tab, 0, 0, opts, text_item_get_text (text_item));
struct table_item *table_item = table_item_create (tab, NULL, NULL);
text_item_unref (text_item);
return table_item;
#include "libpspp/string-map.h"
#include "output/ascii.h"
#include "output/driver.h"
-#include "output/tab.h"
+#include "output/table.h"
#include "output/table-item.h"
#include "gl/error.h"
ht = n_input >= 5 ? input[4] : 0;
hb = n_input >= 6 ? input[5] : 0;
- tab = tab_create (nc, nr, hl, hr, ht, hb);
+ tab = table_create (nc, nr, hl, hr, ht, hb);
for (r = 0; r < nr; r++)
for (c = 0; c < nc; c++)
- if (tab_cell_is_empty (tab, c, r))
+ if (table_cell_is_empty (tab, c, r))
{
unsigned int opt;
char *new_line;
switch (*text++)
{
case '<':
- tab_vline (tab, TAL_1, c, r, r + rs - 1);
+ table_vline (tab, TAL_1, c, r, r + rs - 1);
break;
case '>':
- tab_vline (tab, TAL_1, c + cs, r, r + rs - 1);
+ table_vline (tab, TAL_1, c + cs, r, r + rs - 1);
break;
case '^':
- tab_hline (tab, TAL_1, c, c + cs - 1, r);
+ table_hline (tab, TAL_1, c, c + cs - 1, r);
break;
case ',':
- tab_hline (tab, TAL_1, c, c + cs - 1, r + rs);
+ table_hline (tab, TAL_1, c, c + cs - 1, r + rs);
break;
case '@':
- tab_box (tab, TAL_1, TAL_1, -1, -1, c, r,
+ table_box (tab, TAL_1, TAL_1, -1, -1, c, r,
c + cs - 1, r + rs - 1);
break;
for (i = 0; (content = strsep (&pos, "#")) != NULL; i++)
if (!i)
- tab_joint_text (tab, c, r, c + cs - 1, r + rs - 1, opt,
- content);
+ table_joint_text (tab, c, r, c + cs - 1, r + rs - 1, opt,
+ content);
else
{
char marker[2] = { 'a' + n_footnotes, '\0' };
- struct footnote *f = tab_create_footnote (
+ struct footnote *f = table_create_footnote (
tab, n_footnotes, content, marker, NULL);
- tab_add_footnote (tab, c, r, f);
+ table_add_footnote (tab, c, r, f);
n_footnotes++;
}
}