struct page_paragraph
{
char *markup;
- int halign; /* TAB_LEFT, TAB_CENTER, TAB_RIGHT. */
+ enum table_halign halign;
};
struct page_heading
#include "libpspp/hash-functions.h"
#include "libpspp/hmap.h"
#include "libpspp/pool.h"
+#include "output/pivot-table.h" /* XXX for PIVOT_AREA_FOOTER */
#include "output/render.h"
#include "output/table-item.h"
#include "output/table.h"
return;
struct table *t = table_create (1, n_footnotes, 0, 0, 0, 0);
+
+ const struct area_style *style = item->table->styles[PIVOT_AREA_FOOTER];
+ if (!style)
+ style = pivot_area_get_default_style (PIVOT_AREA_FOOTER);
+ t->styles[PIVOT_AREA_FOOTER] = area_style_clone (t->container, style);
+
for (size_t i = 0; i < n_footnotes; i++)
{
- table_text_format (t, 0, i, TAB_LEFT, "%s. %s",
- f[i]->marker, f[i]->content);
+ table_text_format (t, 0, i, PIVOT_AREA_FOOTER << TAB_STYLE_SHIFT,
+ "%s. %s", f[i]->marker, f[i]->content);
if (f[i]->style)
table_add_style (t, 0, i, f[i]->style);
}
table_from_string (const char *text)
{
struct table *t = table_create (1, 1, 0, 0, 0, 0);
- table_text (t, 0, 0, TAB_LEFT, text);
+ t->styles[0] = xmalloc (sizeof *t->styles[0]);
+ *t->styles[0] = (struct area_style) {
+ AREA_STYLE_INITIALIZER__,
+ .cell_style.halign = TABLE_HALIGN_LEFT,
+ .cell_style.valign = TABLE_VALIGN_TOP
+ };
+ table_text (t, 0, 0, 0 << TAB_STYLE_SHIFT, text);
return t;
}
\f
cell->n_footnotes = 0;
int style_idx = (opt & TAB_STYLE_MASK) >> TAB_STYLE_SHIFT;
- const struct area_style *style = t->styles[style_idx];
- if (style)
- cell->style = style;
- else
- {
- static const struct area_style styles[3][3] = {
-#define S(H,V) [H][V] = { AREA_STYLE_INITIALIZER__, \
- .cell_style.halign = H, \
- .cell_style.valign = V }
- S(TABLE_HALIGN_LEFT, TABLE_VALIGN_TOP),
- S(TABLE_HALIGN_LEFT, TABLE_VALIGN_CENTER),
- S(TABLE_HALIGN_LEFT, TABLE_VALIGN_BOTTOM),
- S(TABLE_HALIGN_CENTER, TABLE_VALIGN_TOP),
- S(TABLE_HALIGN_CENTER, TABLE_VALIGN_CENTER),
- S(TABLE_HALIGN_CENTER, TABLE_VALIGN_BOTTOM),
- S(TABLE_HALIGN_RIGHT, TABLE_VALIGN_TOP),
- S(TABLE_HALIGN_RIGHT, TABLE_VALIGN_CENTER),
- S(TABLE_HALIGN_RIGHT, TABLE_VALIGN_BOTTOM),
- };
-
- enum table_halign halign
- = ((opt & TAB_HALIGN) == TAB_LEFT ? TABLE_HALIGN_LEFT
- : (opt & TAB_HALIGN) == TAB_CENTER ? TABLE_HALIGN_CENTER
- : TABLE_HALIGN_RIGHT);
- enum table_valign valign
- = ((opt & TAB_VALIGN) == TAB_TOP ? TABLE_VALIGN_TOP
- : (opt & TAB_VALIGN) == TAB_MIDDLE ? TABLE_VALIGN_CENTER
- : TABLE_VALIGN_BOTTOM);
-
- cell->style = &styles[halign][valign];
- }
+ cell->style = t->styles[style_idx];
if (opt & TAB_JOIN)
{
cell->d[TABLE_VERT][1] = y + 1;
cell->text = CONST_CAST (char *, cc ? cc : "");
}
+
+ assert (cell->style);
}
/* Returns one of the TAL_* enumeration constants (declared in output/table.h)
TAB_STYLE_SHIFT = 5,
TAB_STYLE_MASK = 7 << TAB_STYLE_SHIFT,
- /* Horizontal alignment of cell contents. */
- TAB_RIGHT = 0 << 10,
- TAB_LEFT = 1 << 10,
- TAB_CENTER = 2 << 10,
- TAB_HALIGN = 3 << 10, /* Alignment mask. */
-
- /* Vertical alignment of cell contents. */
- TAB_TOP = 0 << 12,
- TAB_MIDDLE = 1 << 12,
- TAB_BOTTOM = 2 << 12,
- TAB_VALIGN = 3 << 12, /* Alignment mask. */
-
/* Internal use by tab.c only. */
TAB_JOIN = 1 << 14,
};
for (c = 0; c < nc; c++)
if (table_cell_is_empty (tab, c, r))
{
- unsigned int opt;
char *new_line;
char *text;
int rs, cs;
cs = 1;
}
- opt = 0;
+#define S(H) { AREA_STYLE_INITIALIZER__, .cell_style.halign = H }
+ static const struct area_style left_style = S (TABLE_HALIGN_LEFT);
+ static const struct area_style right_style = S (TABLE_HALIGN_RIGHT);
+ static const struct area_style center_style
+ = S (TABLE_HALIGN_CENTER);
+
+ const struct area_style *style = &right_style;
while (*text && strchr ("<>^,@()|", *text))
switch (*text++)
{
break;
case '(':
- opt &= ~TAB_HALIGN;
- opt |= TAB_LEFT;
+ style = &left_style;
break;
case ')':
- opt &= ~TAB_HALIGN;
- opt |= TAB_RIGHT;
+ style = &right_style;
break;
case '|':
- opt &= ~TAB_HALIGN;
- opt |= TAB_CENTER;
+ style = ¢er_style;
break;
default:
for (i = 0; (content = strsep (&pos, "#")) != NULL; i++)
if (!i)
- table_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, 0,
+ content);
+ table_add_style (tab, c, r, style);
+ }
else
{
char marker[2] = { 'a' + n_footnotes, '\0' };