Other, similarly situated data structures have a table_ prefix.
if (!a->file)
return;
- struct area_style style = {
+ struct table_area_style style = {
.cell_style.halign = TABLE_HALIGN_LEFT,
.font_style.bold = bold,
.font_style.underline = underline,
return NULL;
}
-static struct area_style *
-area_style_override (struct pool *pool,
- const struct area_style *in,
- const struct cell_style *cell_,
- const struct font_style *font_)
+static struct table_area_style *
+table_area_style_override (struct pool *pool,
+ const struct table_area_style *in,
+ const struct cell_style *cell_,
+ const struct font_style *font_)
{
const struct cell_style *cell = cell_ ? cell_ : &in->cell_style;
const struct font_style *font = font_ ? font_ : &in->font_style;
- struct area_style *out = (pool
+ struct table_area_style *out = (pool
? pool_alloc (pool, sizeof *out)
: xmalloc (sizeof *out));
- *out = (struct area_style) {
+ *out = (struct table_area_style) {
.cell_style.halign = cell->halign,
.cell_style.valign = cell->valign,
.cell_style.decimal_offset = cell->decimal_offset,
static void
fill_cell (struct table *t, int x1, int y1, int x2, int y2,
- const struct area_style *style, int style_idx,
+ const struct table_area_style *style, int style_idx,
const struct pivot_value *value, struct footnote **footnotes,
enum settings_value_show show_values,
enum settings_value_show show_variables,
{
if (value->cell_style || value->font_style)
table_add_style (t, x1, y1,
- area_style_override (t->container, style,
- value->cell_style,
- value->font_style));
+ table_area_style_override (t->container, style,
+ value->cell_style,
+ value->font_style));
for (size_t i = 0; i < value->n_footnotes; i++)
{
static struct table_item_text *
pivot_value_to_table_item_text (const struct pivot_value *value,
- const struct area_style *area,
+ const struct table_area_style *area,
struct footnote **footnotes,
enum settings_value_show show_values,
enum settings_value_show show_variables)
*text = (struct table_item_text) {
.content = ds_steal_cstr (&s),
.footnotes = xnmalloc (value->n_footnotes, sizeof *text->footnotes),
- .style = area_style_override (
+ .style = table_area_style_override (
NULL, area, value->cell_style, value->font_style),
};
enum pivot_border cat_col_horz,
enum pivot_border cat_col_vert,
const size_t *column_enumeration, size_t n_columns,
- const struct area_style *label_style, int label_style_idx,
- const struct area_style *corner_style,
+ const struct table_area_style *label_style,
+ int label_style_idx,
+ const struct table_area_style *corner_style,
struct footnote **footnotes,
enum settings_value_show show_values,
enum settings_value_show show_variables,
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],
- NULL, NULL);
+ table->styles[i] = table_area_style_override (
+ table->container, &pt->areas[i], NULL, NULL);
for (size_t i = 0; i < PIVOT_N_BORDERS; i++)
{
pt->show_variables);
footnotes[i] = table_create_footnote (
table, i, content, marker,
- area_style_override (table->container, &pt->areas[PIVOT_AREA_FOOTER],
- pf->content->cell_style,
- pf->content->font_style));
+ table_area_style_override (table->container,
+ &pt->areas[PIVOT_AREA_FOOTER],
+ pf->content->cell_style,
+ pf->content->font_style));
free (marker);
free (content);
}
if (!layers)
{
layers = xzalloc (sizeof *layers);
- layers->style = area_style_override (
+ layers->style = table_area_style_override (
NULL, &pt->areas[PIVOT_AREA_LAYERS], NULL, NULL);
layers->layers = xnmalloc (layer_axis->n_dimensions,
sizeof *layers->layers);
}
}
-const struct area_style *
+const struct table_area_style *
pivot_area_get_default_style (enum pivot_area area)
{
#define STYLE(BOLD, H, V, L, R, T, B) { \
.typeface = (char *) "Sans Serif", \
}, \
}
- static const struct area_style default_area_styles[PIVOT_N_AREAS] = {
+ static const struct table_area_style default_area_styles[PIVOT_N_AREAS] = {
[PIVOT_AREA_TITLE] = STYLE(true, CENTER, CENTER, 8,11,1,8),
[PIVOT_AREA_CAPTION] = STYLE(false, LEFT, TOP, 8,11,1,1),
[PIVOT_AREA_FOOTER] = STYLE(false, LEFT, TOP, 11, 8,2,3),
table->sizing[TABLE_VERT].range[1] = 120;
for (size_t i = 0; i < PIVOT_N_AREAS; i++)
- area_style_copy (NULL, &table->areas[i], pivot_area_get_default_style (i));
+ table_area_style_copy (NULL, &table->areas[i],
+ pivot_area_get_default_style (i));
/* Set default border styles. */
static const enum table_stroke default_strokes[PIVOT_N_BORDERS] = {
pivot_value_destroy (table->caption);
for (size_t i = 0; i < PIVOT_N_AREAS; i++)
- area_style_uninit (&table->areas[i]);
+ table_area_style_uninit (&table->areas[i]);
for (size_t i = 0; i < table->n_dimensions; i++)
pivot_dimension_destroy (table->dimensions[i]);
}
static void
-area_style_dump (enum pivot_area area, const struct area_style *a,
- int indentation)
+table_area_style_dump (enum pivot_area area, const struct table_area_style *a,
+ int indentation)
{
indent (indentation);
printf ("%s: ", pivot_area_to_string (area));
indent (indentation);
printf ("areas:\n");
for (enum pivot_area area = 0; area < PIVOT_N_AREAS; area++)
- area_style_dump (area, &table->areas[area], indentation + 1);
+ table_area_style_dump (area, &table->areas[area], indentation + 1);
indent (indentation);
printf ("borders:\n");
pivot_value_get_style (struct pivot_value *value,
const struct font_style *base_font_style,
const struct cell_style *base_cell_style,
- struct area_style *area)
+ struct table_area_style *area)
{
font_style_copy (NULL, &area->font_style, (value->font_style
? value->font_style
/* Copies AREA into VALUE's style. */
void
pivot_value_set_style (struct pivot_value *value,
- const struct area_style *area)
+ const struct table_area_style *area)
{
if (value->font_style)
font_style_uninit (value->font_style);
};
const char *pivot_area_to_string (enum pivot_area);
-const struct area_style *pivot_area_get_default_style (enum pivot_area);
+const struct table_area_style *pivot_area_get_default_style (enum pivot_area);
/* Table borders for styling purposes. */
enum pivot_border
char *notes;
/* Styles. */
- struct area_style areas[PIVOT_N_AREAS];
+ struct table_area_style areas[PIVOT_N_AREAS];
struct table_border_style borders[PIVOT_N_BORDERS];
/* Dimensions. */
void pivot_value_get_style (struct pivot_value *,
const struct font_style *base_font_style,
const struct cell_style *base_cell_style,
- struct area_style *);
-void pivot_value_set_style (struct pivot_value *, const struct area_style *);
+ struct table_area_style *);
+void pivot_value_set_style (struct pivot_value *,
+ const struct table_area_style *);
/* Template arguments. */
struct pivot_argument
for (size_t i = 0; i < t->n_footnotes; i++)
table_add_footnote (tab, 0, 0, t->footnotes[i]);
if (t->style)
- tab->styles[0] = area_style_clone (tab->container, t->style);
+ tab->styles[0] = table_area_style_clone (tab->container, t->style);
render_pager_add_table (p, tab, min_width);
}
table_add_footnote (tab, 0, i, layer->footnotes[j]);
}
if (layers->style)
- tab->styles[0] = area_style_clone (tab->container, layers->style);
+ tab->styles[0] = table_area_style_clone (tab->container, layers->style);
render_pager_add_table (p, tab, min_width);
}
static void
decode_spvdx_style_incremental (const struct spvdx_style *in,
const struct spvdx_style *bg,
- struct area_style *out)
+ struct table_area_style *out)
{
if (in && in->font_weight)
out->font_style.bold = in->font_weight == SPVDX_FONT_WEIGHT_BOLD;
static void
decode_spvdx_style (const struct spvdx_style *in,
const struct spvdx_style *bg,
- struct area_style *out)
+ struct table_area_style *out)
{
- *out = (struct area_style) AREA_STYLE_INITIALIZER;
+ *out = (struct table_area_style) TABLE_AREA_STYLE_INITIALIZER;
decode_spvdx_style_incremental (in, bg, out);
}
return NULL;
struct pivot_value **target;
- struct area_style *area;
+ struct table_area_style *area;
if (lf->label->purpose == SPVDX_PURPOSE_TITLE)
{
target = &table->title;
else
return NULL;
- area_style_uninit (area);
+ table_area_style_uninit (area);
decode_spvdx_style (lf->label->style, lf->label->text_frame_style, area);
if (target)
= find_facet_level (v, base_facet_level + n);
if (fl)
{
- struct area_style *area = (axis_type == PIVOT_AXIS_COLUMN
- ? &table->areas[PIVOT_AREA_COLUMN_LABELS]
- : axis_type == PIVOT_AXIS_ROW
- ? &table->areas[PIVOT_AREA_ROW_LABELS]
- : NULL);
+ struct table_area_style *area = (axis_type == PIVOT_AXIS_COLUMN
+ ? &table->areas[PIVOT_AREA_COLUMN_LABELS]
+ : axis_type == PIVOT_AXIS_ROW
+ ? &table->areas[PIVOT_AREA_ROW_LABELS]
+ : NULL);
if (area && fl->axis->label)
{
- area_style_uninit (area);
+ table_area_style_uninit (area);
decode_spvdx_style (fl->axis->label->style,
fl->axis->label->text_frame_style, area);
}
apply_styles_to_value (struct pivot_table *table,
struct pivot_value *value,
const struct spvdx_set_format *sf,
- const struct area_style *base_area_style,
+ const struct table_area_style *base_area_style,
const struct spvdx_style *fg,
const struct spvdx_style *bg)
{
}
if (fg || bg)
{
- struct area_style area;
+ struct table_area_style area;
pivot_value_get_style (
value,
value->font_style ? value->font_style : &base_area_style->font_style,
&area);
decode_spvdx_style_incremental (fg, bg, &area);
pivot_value_set_style (value, &area);
- area_style_uninit (&area);
+ table_area_style_uninit (&area);
}
}
&& !interval && !major_ticks && !frame && !set_format)
{
/* Sets alt_fg_color and alt_bg_color. */
- struct area_style area;
+ struct table_area_style area;
decode_spvdx_style (labeling, graph, &area);
table->areas[PIVOT_AREA_DATA].font_style.fg[1]
= area.font_style.fg[0];
table->areas[PIVOT_AREA_DATA].font_style.bg[1]
= area.font_style.bg[0];
- area_style_uninit (&area);
+ table_area_style_uninit (&area);
}
else if (graph
&& !labeling && !interval && !major_ticks && !frame && !set_format)
struct pivot_category *c = find_category (s, include);
if (c)
{
- const struct area_style *base_area_style
+ const struct table_area_style *base_area_style
= (c->dimension->axis_type == PIVOT_AXIS_ROW
? &table->areas[PIVOT_AREA_ROW_LABELS]
: &table->areas[PIVOT_AREA_COLUMN_LABELS]);
}
if (v->graph->interval->labeling->style)
{
- area_style_uninit (&table->areas[PIVOT_AREA_DATA]);
+ table_area_style_uninit (&table->areas[PIVOT_AREA_DATA]);
decode_spvdx_style (v->graph->interval->labeling->style,
v->graph->cell_style,
&table->areas[PIVOT_AREA_DATA]);
}
static char * WARN_UNUSED_RESULT
-decode_spvlb_area (const struct spvlb_area *in, struct area_style *out,
+decode_spvlb_area (const struct spvlb_area *in, struct table_area_style *out,
const char *encoding)
{
char *error;
if (error)
return error;
- *out = (struct area_style) {
+ *out = (struct table_area_style) {
.font_style = {
.bold = (in->style & 1) != 0,
.italic = (in->style & 2) != 0,
= (f->number_format == SPVSX_NUMBER_FORMAT_NUMERIC);
for (int i = 0; i < PIVOT_N_AREAS; i++)
- area_style_copy (NULL, &out->areas[i], pivot_area_get_default_style (i));
+ table_area_style_copy (NULL, &out->areas[i],
+ pivot_area_get_default_style (i));
const struct spvsx_cell_format_properties *cfp = in->cell_format_properties;
for (size_t i = 0; i < cfp->n_cell_style; i++)
goto error;
}
- struct area_style *a = &out->areas[area];
+ struct table_area_style *a = &out->areas[area];
const struct spvsx_style *s = c->style;
if (s->font_weight)
a->font_style.bold = s->font_weight == SPVSX_FONT_WEIGHT_BOLD;
start_elem (xml, "cellFormatProperties");
for (enum pivot_area a = 0; a < PIVOT_N_AREAS; a++)
{
- const struct area_style *area = &look->areas[a];
+ const struct table_area_style *area = &look->areas[a];
const struct font_style *font = &area->font_style;
const struct cell_style *cell = &area->cell_style;
{
free (look->name);
for (size_t i = 0; i < PIVOT_N_AREAS; i++)
- area_style_uninit (&look->areas[i]);
+ table_area_style_uninit (&look->areas[i]);
free (look->continuation);
free (look);
}
for (size_t i = 0; i < PIVOT_N_AREAS; i++)
{
- area_style_uninit (&table->areas[i]);
- area_style_copy (NULL, &table->areas[i], &look->areas[i]);
+ table_area_style_uninit (&table->areas[i]);
+ table_area_style_copy (NULL, &table->areas[i], &look->areas[i]);
}
for (size_t i = 0; i < PIVOT_N_BORDERS; i++)
table->borders[i] = look->borders[i];
look->show_numeric_markers = table->show_numeric_markers;
for (size_t i = 0; i < PIVOT_N_AREAS; i++)
- area_style_copy (NULL, &look->areas[i], &table->areas[i]);
+ table_area_style_copy (NULL, &look->areas[i], &table->areas[i]);
for (size_t i = 0; i < PIVOT_N_BORDERS; i++)
look->borders[i] = table->borders[i];
bool footnote_marker_superscripts;
/* Styles. */
- struct area_style areas[PIVOT_N_AREAS];
+ struct table_area_style areas[PIVOT_N_AREAS];
struct table_border_style borders[PIVOT_N_BORDERS];
/* Print settings. */
/* Areas. */
for (size_t i = 0; i < PIVOT_N_AREAS; i++)
{
- const struct area_style *a = &table->areas[i];
+ const struct table_area_style *a = &table->areas[i];
put_byte (buf, i + 1);
put_byte (buf, 0x31);
put_string (buf, (a->font_style.typeface
.footnotes = xmemdup (old->footnotes,
old->n_footnotes * sizeof *old->footnotes),
.n_footnotes = old->n_footnotes,
- .style = area_style_clone (NULL, old->style),
+ .style = table_area_style_clone (NULL, old->style),
};
return new;
}
{
free (text->content);
free (text->footnotes);
- area_style_free (text->style);
+ table_area_style_free (text->style);
free (text);
}
}
*new = (struct table_item_layers) {
.layers = xnmalloc (old->n_layers, sizeof *new->layers),
.n_layers = old->n_layers,
- .style = area_style_clone (NULL, old->style),
+ .style = table_area_style_clone (NULL, old->style),
};
for (size_t i = 0; i < new->n_layers; i++)
table_item_layer_copy (&new->layers[i], &old->layers[i]);
for (size_t i = 0; i < layers->n_layers; i++)
table_item_layer_uninit (&layers->layers[i]);
free (layers->layers);
- area_style_free (layers->style);
+ table_area_style_free (layers->style);
free (layers);
}
}
char *content;
const struct footnote **footnotes;
size_t n_footnotes;
- struct area_style *style;
+ struct table_area_style *style;
};
struct table_item_text *table_item_text_create (const char *);
{
struct table_item_layer *layers;
size_t n_layers;
- struct area_style *style;
+ struct table_area_style *style;
};
struct table_item_layers *table_item_layers_clone (
size_t idx;
char *content;
char *marker;
- struct area_style *style;
+ struct table_area_style *style;
};
/* A cell in a table. */
char *superscript;
const struct footnote **footnotes;
size_t n_footnotes;
- const struct area_style *style;
+ const struct table_area_style *style;
};
void table_cell_format_footnote_markers (const struct table_cell *,
return table->ref_cnt > 1;
}
\f
-struct area_style *
-area_style_clone (struct pool *pool, const struct area_style *old)
+struct table_area_style *
+table_area_style_clone (struct pool *pool, const struct table_area_style *old)
{
- struct area_style *new = pool_malloc (pool, sizeof *new);
+ struct table_area_style *new = pool_malloc (pool, sizeof *new);
*new = *old;
if (new->font_style.typeface)
new->font_style.typeface = pool_strdup (pool, new->font_style.typeface);
}
void
-area_style_free (struct area_style *style)
+table_area_style_free (struct table_area_style *style)
{
if (style)
{
{
struct table *t = table_create (1, 1, 0, 0, 0, 0);
t->styles[0] = pool_alloc (t->container, sizeof *t->styles[0]);
- *t->styles[0] = (struct area_style) {
- AREA_STYLE_INITIALIZER__,
+ *t->styles[0] = (struct table_area_style) {
+ TABLE_AREA_STYLE_INITIALIZER__,
.cell_style.halign = TABLE_HALIGN_LEFT,
.cell_style.valign = TABLE_VALIGN_TOP
};
}
void
-area_style_copy (struct pool *container,
- struct area_style *dst, const struct area_style *src)
+table_area_style_copy (struct pool *container, struct table_area_style *dst,
+ const struct table_area_style *src)
{
font_style_copy (container, &dst->font_style, &src->font_style);
dst->cell_style = src->cell_style;
}
void
-area_style_uninit (struct area_style *area)
+table_area_style_uninit (struct table_area_style *area)
{
if (area)
font_style_uninit (&area->font_style);
footnote later, so it is important for the caller to remember it. */
struct footnote *
table_create_footnote (struct table *table, size_t idx, const char *content,
- const char *marker, struct area_style *style)
+ const char *marker, struct table_area_style *style)
{
assert (style);
TABLE->container or have a lifetime that will outlive TABLE. */
void
table_add_style (struct table *table, int x, int y,
- const struct area_style *style)
+ const struct table_area_style *style)
{
get_joined_cell (table, x, y)->style = style;
}
unsigned short opt = t->ct[index];
const void *cc = t->cc[index];
- const struct area_style *style
+ const struct table_area_style *style
= t->styles[(opt & TAB_STYLE_MASK) >> TAB_STYLE_SHIFT];
if (opt & TAB_JOIN)
{
void font_style_uninit (struct font_style *);
void font_style_dump (const struct font_style *);
-struct area_style
+struct table_area_style
{
struct cell_style cell_style;
struct font_style font_style;
};
-#define AREA_STYLE_INITIALIZER { AREA_STYLE_INITIALIZER__ }
-#define AREA_STYLE_INITIALIZER__ \
+#define TABLE_AREA_STYLE_INITIALIZER { TABLE_AREA_STYLE_INITIALIZER__ }
+#define TABLE_AREA_STYLE_INITIALIZER__ \
.cell_style = CELL_STYLE_INITIALIZER, \
.font_style = FONT_STYLE_INITIALIZER
-struct area_style *area_style_clone (struct pool *, const struct area_style *);
-void area_style_copy (struct pool *,
- struct area_style *, const struct area_style *);
-void area_style_uninit (struct area_style *);
-void area_style_free (struct area_style *);
+struct table_area_style *table_area_style_clone (
+ struct pool *, const struct table_area_style *);
+void table_area_style_copy (struct pool *, struct table_area_style *,
+ const struct table_area_style *);
+void table_area_style_uninit (struct table_area_style *);
+void table_area_style_free (struct table_area_style *);
/* Properties of a table cell. */
enum
points to a struct table_cell. */
void **cc; /* Cell contents; void *[nr][nc]. */
unsigned short *ct; /* Cell types; unsigned short[nr][nc]. */
- struct area_style *styles[8];
+ struct table_area_style *styles[8];
/* Rules. */
unsigned char *rh; /* Horiz rules; unsigned char[nr+1][nc]. */
struct footnote *table_create_footnote (struct table *, size_t idx,
const char *content,
const char *marker,
- struct area_style *);
+ struct table_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 *);
+ const struct table_area_style *);
bool table_cell_is_empty (const struct table *, int c, int r);
{
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__,
- .cell_style.halign = TABLE_HALIGN_LEFT };
+ struct table_area_style *style = pool_alloc (tab->container, sizeof *style);
+ *style = (struct table_area_style) { TABLE_AREA_STYLE_INITIALIZER__,
+ .cell_style.halign = TABLE_HALIGN_LEFT };
struct font_style *font_style = &style->font_style;
if (text_item->typeface)
font_style->typeface = pool_strdup (tab->container, text_item->typeface);
cs = 1;
}
-#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
+#define S(H) { TABLE_AREA_STYLE_INITIALIZER__, .cell_style.halign = H }
+ static const struct table_area_style left_style
+ = S (TABLE_HALIGN_LEFT);
+ static const struct table_area_style right_style
+ = S (TABLE_HALIGN_RIGHT);
+ static const struct table_area_style center_style
= S (TABLE_HALIGN_CENTER);
- const struct area_style *style = &right_style;
+ const struct table_area_style *style = &right_style;
while (*text && strchr ("<>^,@()|", *text))
switch (*text++)
{
char marker[2] = { 'a' + n_footnotes, '\0' };
struct footnote *f = table_create_footnote (
tab, n_footnotes, content, marker,
- area_style_clone (tab->container, &left_style));
+ table_area_style_clone (tab->container, &left_style));
table_add_footnote (tab, c, r, f);
n_footnotes++;
}