pivot_value_new_user_text_nocopy (ds_steal_cstr (&title)),
"Crosstabulation");
pivot_table_set_weight_format (table, &proc->weight_format);
- table->omit_empty = true;
+ table->look.omit_empty = true;
struct pivot_dimension *statistics = pivot_dimension_create (
table, PIVOT_AXIS_ROW, N_("Statistics"));
{
struct pivot_table *chisq = pivot_table_create (N_("Chi-Square Tests"));
pivot_table_set_weight_format (chisq, &xt->weight_format);
- chisq->omit_empty = true;
+ chisq->look.omit_empty = true;
pivot_dimension_create (
chisq, PIVOT_AXIS_ROW, N_("Statistics"),
{
struct pivot_table *sym = pivot_table_create (N_("Symmetric Measures"));
pivot_table_set_weight_format (sym, &xt->weight_format);
- sym->omit_empty = true;
+ sym->look.omit_empty = true;
pivot_dimension_create (
sym, PIVOT_AXIS_COLUMN, N_("Values"),
{
struct pivot_table *risk = pivot_table_create (N_("Risk Estimate"));
pivot_table_set_weight_format (risk, &xt->weight_format);
- risk->omit_empty = true;
+ risk->look.omit_empty = true;
struct pivot_dimension *values = pivot_dimension_create (
risk, PIVOT_AXIS_COLUMN, N_("Values"),
{
struct pivot_table *direct = pivot_table_create (N_("Directional Measures"));
pivot_table_set_weight_format (direct, &xt->weight_format);
- direct->omit_empty = true;
+ direct->look.omit_empty = true;
pivot_dimension_create (
direct, PIVOT_AXIS_COLUMN, N_("Values"),
percentiles_report (const struct examine *cmd, int iact_idx)
{
struct pivot_table *table = pivot_table_create (N_("Percentiles"));
- table->omit_empty = true;
+ table->look.omit_empty = true;
struct pivot_dimension *percentiles = pivot_dimension_create (
table, PIVOT_AXIS_COLUMN, N_("Percentiles"));
normality_report (const struct examine *cmd, int iact_idx)
{
struct pivot_table *table = pivot_table_create (N_("Tests of Normality"));
- table->omit_empty = true;
+ table->look.omit_empty = true;
struct pivot_dimension *test =
pivot_dimension_create (table, PIVOT_AXIS_COLUMN, N_("Shapiro-Wilk"),
descriptives_report (const struct examine *cmd, int iact_idx)
{
struct pivot_table *table = pivot_table_create (N_("Descriptives"));
- table->omit_empty = true;
+ table->look.omit_empty = true;
pivot_dimension_create (table, PIVOT_AXIS_COLUMN, N_("Aspect"),
N_("Statistic"), N_("Std. Error"));
extremes_report (const struct examine *cmd, int iact_idx)
{
struct pivot_table *table = pivot_table_create (N_("Extreme Values"));
- table->omit_empty = true;
+ table->look.omit_empty = true;
struct pivot_dimension *statistics = pivot_dimension_create (
table, PIVOT_AXIS_COLUMN, N_("Statistics"));
{
struct pivot_table *table = pivot_table_create (
N_("Case Processing Summary"));
- table->omit_empty = true;
+ table->look.omit_empty = true;
pivot_table_set_weight_var (table, dict_get_weight (cmd->dict));
pivot_dimension_create (table, PIVOT_AXIS_COLUMN, N_("Statistics"),
struct pivot_table *table = pivot_table_create (
N_("Total Variance Explained"));
- table->omit_empty = true;
+ table->look.omit_empty = true;
pivot_dimension_create (table, PIVOT_AXIS_COLUMN, N_("Statistics"),
N_("Total"), PIVOT_RC_OTHER,
const struct workspace *ws)
{
struct pivot_table *pt = pivot_table_create (N_("Report"));
- pt->omit_empty = true;
+ pt->look.omit_empty = true;
struct pivot_dimension *dim_cells =
pivot_dimension_create (pt, PIVOT_AXIS_COLUMN, N_("Statistics"));
}
struct pivot_table *pt = pivot_table_create (ds_cstr (&dss));
- pt->omit_empty = true;
+ pt->look.omit_empty = true;
ds_destroy (&dss);
struct pivot_dimension *dim_cells =
_("Multiple Comparisons (%s)"),
var_to_string (cmd->vars[v]))),
"Multiple Comparisons");
- table->omit_empty = true;
+ table->look.omit_empty = true;
struct pivot_dimension *statistics = pivot_dimension_create (
table, PIVOT_AXIS_COLUMN, N_("Statistics"),
{
struct pivot_table *table = pivot_table_create (
N_("Variables Created by RANK"));
- table->omit_empty = true;
+ table->look.omit_empty = true;
pivot_dimension_create (table, PIVOT_AXIS_COLUMN, N_("New Variable"),
N_("New Variable"), N_("Function"),
{
struct pivot_table *table = pivot_table_create (
N_("Coordinates of the Curve"));
- table->omit_empty = true;
+ table->look.omit_empty = true;
pivot_dimension_create (table, PIVOT_AXIS_COLUMN, N_("Statistics"),
N_("Positive if greater than or equal to"),
size_t body[TABLE_N_AXES];
size_t *column_enumeration = pivot_table_enumerate_axis (
- pt, PIVOT_AXIS_COLUMN, layer_indexes, pt->omit_empty, &body[H]);
+ pt, PIVOT_AXIS_COLUMN, layer_indexes, pt->look.omit_empty, &body[H]);
size_t *row_enumeration = pivot_table_enumerate_axis (
- pt, PIVOT_AXIS_ROW, layer_indexes, pt->omit_empty, &body[V]);
+ pt, PIVOT_AXIS_ROW, layer_indexes, pt->look.omit_empty, &body[V]);
int stub[TABLE_N_AXES] = {
[H] = pt->axes[PIVOT_AXIS_ROW].label_depth,
for (size_t i = 0; i < PIVOT_N_AREAS; i++)
table->styles[i] = table_area_style_override (
- table->container, &pt->areas[i], NULL, NULL);
+ table->container, &pt->look.areas[i], NULL, NULL);
for (size_t i = 0; i < PIVOT_N_BORDERS; i++)
{
- const struct table_border_style *in = &pt->borders[i];
+ const struct table_border_style *in = &pt->look.borders[i];
table->rule_colors[i] = pool_alloc (table->container,
sizeof *table->rule_colors[i]);
struct cell_color *out = table->rule_colors[i];
footnotes[i] = table_create_footnote (
table, i, content, marker,
table_area_style_override (table->container,
- &pt->areas[PIVOT_AREA_FOOTER],
+ &pt->look.areas[PIVOT_AREA_FOOTER],
pf->content->cell_style,
pf->content->font_style));
free (marker);
compose_headings (table,
&pt->axes[PIVOT_AXIS_COLUMN], H, &pt->axes[PIVOT_AXIS_ROW],
- pt->borders,
+ pt->look.borders,
PIVOT_BORDER_DIM_COL_HORZ,
PIVOT_BORDER_DIM_COL_VERT,
PIVOT_BORDER_CAT_COL_HORZ,
PIVOT_BORDER_CAT_COL_VERT,
column_enumeration, body[H],
- &pt->areas[PIVOT_AREA_COLUMN_LABELS],
+ &pt->look.areas[PIVOT_AREA_COLUMN_LABELS],
PIVOT_AREA_COLUMN_LABELS,
- &pt->areas[PIVOT_AREA_CORNER], footnotes,
+ &pt->look.areas[PIVOT_AREA_CORNER], footnotes,
pt->show_values, pt->show_variables,
pt->rotate_inner_column_labels, false);
compose_headings (table,
&pt->axes[PIVOT_AXIS_ROW], V, &pt->axes[PIVOT_AXIS_COLUMN],
- pt->borders,
+ pt->look.borders,
PIVOT_BORDER_DIM_ROW_VERT,
PIVOT_BORDER_DIM_ROW_HORZ,
PIVOT_BORDER_CAT_ROW_VERT,
PIVOT_BORDER_CAT_ROW_HORZ,
row_enumeration, body[V],
- &pt->areas[PIVOT_AREA_ROW_LABELS],
+ &pt->look.areas[PIVOT_AREA_ROW_LABELS],
PIVOT_AREA_ROW_LABELS,
- &pt->areas[PIVOT_AREA_CORNER], footnotes,
+ &pt->look.areas[PIVOT_AREA_CORNER], footnotes,
pt->show_values, pt->show_variables,
false, pt->rotate_outer_row_labels);
fill_cell (table,
x + stub[H], y + stub[V],
x + stub[H], y + stub[V],
- &pt->areas[PIVOT_AREA_DATA], PIVOT_AREA_DATA,
+ &pt->look.areas[PIVOT_AREA_DATA], PIVOT_AREA_DATA,
value, footnotes,
pt->show_values, pt->show_variables, false);
if (pt->corner_text && stub[H] && stub[V])
fill_cell (table, 0, 0, stub[H] - 1, stub[V] - 1,
- &pt->areas[PIVOT_AREA_CORNER], PIVOT_AREA_CORNER,
+ &pt->look.areas[PIVOT_AREA_CORNER], PIVOT_AREA_CORNER,
pt->corner_text, footnotes,
pt->show_values, pt->show_variables, false);
if (table_nc (table) && table_nr (table))
{
table_hline (
- table, get_table_rule (pt->borders, PIVOT_BORDER_INNER_TOP),
+ table, get_table_rule (pt->look.borders, PIVOT_BORDER_INNER_TOP),
0, table_nc (table) - 1, 0);
table_hline (
- table, get_table_rule (pt->borders, PIVOT_BORDER_INNER_BOTTOM),
+ table, get_table_rule (pt->look.borders, PIVOT_BORDER_INNER_BOTTOM),
0, table_nc (table) - 1, table_nr (table));
table_vline (
- table, get_table_rule (pt->borders, PIVOT_BORDER_INNER_LEFT),
+ table, get_table_rule (pt->look.borders, PIVOT_BORDER_INNER_LEFT),
0, 0, table_nr (table) - 1);
table_vline (
- table, get_table_rule (pt->borders, PIVOT_BORDER_INNER_RIGHT),
+ table, get_table_rule (pt->look.borders, PIVOT_BORDER_INNER_RIGHT),
table_nc (table), 0, table_nr (table) - 1);
if (stub[V])
table_hline (
- table, get_table_rule (pt->borders, PIVOT_BORDER_DATA_TOP),
+ table, get_table_rule (pt->look.borders, PIVOT_BORDER_DATA_TOP),
0, table_nc (table) - 1, stub[V]);
if (stub[H])
table_vline (
- table, get_table_rule (pt->borders, PIVOT_BORDER_DATA_LEFT),
+ table, get_table_rule (pt->look.borders, PIVOT_BORDER_DATA_LEFT),
stub[H], 0, table_nr (table) - 1);
}
if (pt->title)
{
struct table_item_text *title = pivot_value_to_table_item_text (
- pt->title, &pt->areas[PIVOT_AREA_TITLE], footnotes,
+ pt->title, &pt->look.areas[PIVOT_AREA_TITLE], footnotes,
pt->show_values, pt->show_variables);
table_item_set_title (ti, title);
table_item_text_destroy (title);
{
layers = xzalloc (sizeof *layers);
layers->style = table_area_style_override (
- NULL, &pt->areas[PIVOT_AREA_LAYERS], NULL, NULL);
+ NULL, &pt->look.areas[PIVOT_AREA_LAYERS], NULL, NULL);
layers->layers = xnmalloc (layer_axis->n_dimensions,
sizeof *layers->layers);
}
if (pt->caption && pt->show_caption)
{
struct table_item_text *caption = pivot_value_to_table_item_text (
- pt->caption, &pt->areas[PIVOT_AREA_CAPTION], footnotes,
+ pt->caption, &pt->look.areas[PIVOT_AREA_CAPTION], footnotes,
pt->show_values, pt->show_variables);
table_item_set_caption (ti, caption);
table_item_text_destroy (caption);
if (pt->decimal == '.' || pt->decimal == ',')
settings_set_decimal_char (pt->decimal);
- if (pt->print_all_layers)
+ if (pt->look.print_all_layers)
{
size_t *layer_indexes;
PIVOT_AXIS_FOR_EACH (layer_indexes, &pt->axes[PIVOT_AXIS_LAYER])
{
- if (pt->paginate_layers)
+ if (pt->look.paginate_layers)
text_item_submit (text_item_create (TEXT_ITEM_EJECT_PAGE, ""));
pivot_table_submit_layer (pt, layer_indexes);
}
}
}
\f
+/* Pivot table looks. */
+
+void
+pivot_table_look_init (struct pivot_table_look *look)
+{
+ memset (look, 0, sizeof *look);
+
+ look->omit_empty = false;
+ look->row_labels_in_corner = true;
+ look->width_ranges[TABLE_HORZ][0] = 50;
+ look->width_ranges[TABLE_HORZ][1] = 72;
+ look->width_ranges[TABLE_VERT][0] = 36;
+ look->width_ranges[TABLE_VERT][1] = 120;
+
+ for (size_t i = 0; i < PIVOT_N_AREAS; i++)
+ table_area_style_copy (NULL, &look->areas[i],
+ pivot_area_get_default_style (i));
+
+ static const enum table_stroke default_strokes[PIVOT_N_BORDERS] = {
+ [PIVOT_BORDER_TITLE] = TABLE_STROKE_NONE,
+ [PIVOT_BORDER_OUTER_LEFT] = TABLE_STROKE_NONE,
+ [PIVOT_BORDER_OUTER_TOP] = TABLE_STROKE_NONE,
+ [PIVOT_BORDER_OUTER_RIGHT] = TABLE_STROKE_NONE,
+ [PIVOT_BORDER_OUTER_BOTTOM] = TABLE_STROKE_NONE,
+ [PIVOT_BORDER_INNER_LEFT] = TABLE_STROKE_THICK,
+ [PIVOT_BORDER_INNER_TOP] = TABLE_STROKE_THICK,
+ [PIVOT_BORDER_INNER_RIGHT] = TABLE_STROKE_THICK,
+ [PIVOT_BORDER_INNER_BOTTOM] = TABLE_STROKE_THICK,
+ [PIVOT_BORDER_DATA_LEFT] = TABLE_STROKE_THICK,
+ [PIVOT_BORDER_DATA_TOP] = TABLE_STROKE_THICK,
+ [PIVOT_BORDER_DIM_ROW_HORZ] = TABLE_STROKE_SOLID,
+ [PIVOT_BORDER_DIM_ROW_VERT] = TABLE_STROKE_NONE,
+ [PIVOT_BORDER_DIM_COL_HORZ] = TABLE_STROKE_SOLID,
+ [PIVOT_BORDER_DIM_COL_VERT] = TABLE_STROKE_SOLID,
+ [PIVOT_BORDER_CAT_ROW_HORZ] = TABLE_STROKE_NONE,
+ [PIVOT_BORDER_CAT_ROW_VERT] = TABLE_STROKE_NONE,
+ [PIVOT_BORDER_CAT_COL_HORZ] = TABLE_STROKE_SOLID,
+ [PIVOT_BORDER_CAT_COL_VERT] = TABLE_STROKE_SOLID,
+ };
+ for (size_t i = 0; i < PIVOT_N_BORDERS; i++)
+ look->borders[i] = (struct table_border_style) {
+ .stroke = default_strokes[i],
+ .color = CELL_COLOR_BLACK,
+ };
+}
+
+void
+pivot_table_look_uninit (struct pivot_table_look *look)
+{
+ free (look->name);
+
+ for (size_t i = 0; i < PIVOT_N_AREAS; i++)
+ table_area_style_uninit (&look->areas[i]);
+
+ free (look->continuation);
+}
+
+static char *
+xstrdup_if_nonempty (const char *s)
+{
+ return s && s[0] ? xstrdup (s) : NULL;
+}
+
+void
+pivot_table_look_copy (struct pivot_table_look *dst,
+ const struct pivot_table_look *src)
+{
+ *dst = *src;
+ dst->name = xstrdup_if_nonempty (src->name);
+ for (size_t i = 0; i < PIVOT_N_AREAS; i++)
+ table_area_style_copy (NULL, &dst->areas[i], &src->areas[i]);
+ dst->continuation = xstrdup_if_nonempty (src->continuation);
+}
+\f
/* Axes. */
/* Returns the name of AXIS_TYPE. */
table->subtype = subtype ? pivot_value_new_text (subtype) : NULL;
table->command_c = output_get_command_name ();
- table->sizing[TABLE_HORZ].range[0] = 50;
- table->sizing[TABLE_HORZ].range[1] = 72;
- table->sizing[TABLE_VERT].range[0] = 36;
- table->sizing[TABLE_VERT].range[1] = 120;
-
- for (size_t i = 0; i < PIVOT_N_AREAS; i++)
- table_area_style_copy (NULL, &table->areas[i],
- pivot_area_get_default_style (i));
+ pivot_table_look_init (&table->look);
- /* Set default border styles. */
- static const enum table_stroke default_strokes[PIVOT_N_BORDERS] = {
- [PIVOT_BORDER_TITLE] = TABLE_STROKE_NONE,
- [PIVOT_BORDER_OUTER_LEFT] = TABLE_STROKE_NONE,
- [PIVOT_BORDER_OUTER_TOP] = TABLE_STROKE_NONE,
- [PIVOT_BORDER_OUTER_RIGHT] = TABLE_STROKE_NONE,
- [PIVOT_BORDER_OUTER_BOTTOM] = TABLE_STROKE_NONE,
- [PIVOT_BORDER_INNER_LEFT] = TABLE_STROKE_THICK,
- [PIVOT_BORDER_INNER_TOP] = TABLE_STROKE_THICK,
- [PIVOT_BORDER_INNER_RIGHT] = TABLE_STROKE_THICK,
- [PIVOT_BORDER_INNER_BOTTOM] = TABLE_STROKE_THICK,
- [PIVOT_BORDER_DATA_LEFT] = TABLE_STROKE_THICK,
- [PIVOT_BORDER_DATA_TOP] = TABLE_STROKE_THICK,
- [PIVOT_BORDER_DIM_ROW_HORZ] = TABLE_STROKE_SOLID,
- [PIVOT_BORDER_DIM_ROW_VERT] = TABLE_STROKE_NONE,
- [PIVOT_BORDER_DIM_COL_HORZ] = TABLE_STROKE_SOLID,
- [PIVOT_BORDER_DIM_COL_VERT] = TABLE_STROKE_SOLID,
- [PIVOT_BORDER_CAT_ROW_HORZ] = TABLE_STROKE_NONE,
- [PIVOT_BORDER_CAT_ROW_VERT] = TABLE_STROKE_NONE,
- [PIVOT_BORDER_CAT_COL_HORZ] = TABLE_STROKE_SOLID,
- [PIVOT_BORDER_CAT_COL_VERT] = TABLE_STROKE_SOLID,
- };
- for (size_t i = 0; i < PIVOT_N_BORDERS; i++)
- table->borders[i] = (struct table_border_style) {
- .stroke = default_strokes[i],
- .color = CELL_COLOR_BLACK,
- };
-
- table->row_labels_in_corner = true;
hmap_init (&table->cells);
return table;
return;
free (table->current_layer);
- free (table->table_look);
+ pivot_table_look_uninit (&table->look);
for (int i = 0; i < TABLE_N_AXES; i++)
pivot_table_sizing_uninit (&table->sizing[i]);
- free (table->continuation);
-
for (int i = 0; i < sizeof table->ccs / sizeof *table->ccs; i++)
free (table->ccs[i]);
pivot_value_destroy (table->corner_text);
pivot_value_destroy (table->caption);
- for (size_t i = 0; i < PIVOT_N_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]);
free (table->dimensions);
return table->ref_cnt > 1;
}
+const struct pivot_table_look *
+pivot_table_get_look (const struct pivot_table *table)
+{
+ return &table->look;
+}
+
+void
+pivot_table_set_look (struct pivot_table *table,
+ const struct pivot_table_look *look)
+{
+ pivot_table_look_uninit (&table->look);
+ pivot_table_look_copy (&table->look, look);
+}
+
/* Sets the format used for PIVOT_RC_COUNT cells to the one used for variable
WV, which should be the weight variable for the dictionary whose data or
statistics are being put into TABLE.
struct pivot_footnote *f = xmalloc (sizeof *f);
f->idx = table->n_footnotes;
f->marker = pivot_make_default_footnote_marker (
- f->idx, table->show_numeric_markers);
+ f->idx, table->look.show_numeric_markers);
f->content = NULL;
f->show = true;
{
pivot_axis_assign_label_depth (table, PIVOT_AXIS_COLUMN, false);
if (pivot_axis_assign_label_depth (
- table, PIVOT_AXIS_ROW, (table->row_labels_in_corner
+ table, PIVOT_AXIS_ROW, (table->look.row_labels_in_corner
&& !table->corner_text))
&& table->axes[PIVOT_AXIS_COLUMN].label_depth == 0)
table->axes[PIVOT_AXIS_COLUMN].label_depth = 1;
}
static void
-pivot_table_sizing_dump (const char *name, const struct pivot_table_sizing *s,
+pivot_table_sizing_dump (const char *name,
+ const int width_ranges[2],
+ const struct pivot_table_sizing *s,
int indentation)
{
indent (indentation);
- printf ("%ss: min=%d, max=%d\n", name, s->range[0], s->range[1]);
+ printf ("%ss: min=%d, max=%d\n", name, width_ranges[0], width_ranges[1]);
if (s->n_widths)
{
indent (indentation + 1);
pivot_table_dump_string (table->dataset, "dataset", indentation);
pivot_table_dump_string (table->datafile, "datafile", indentation);
pivot_table_dump_string (table->notes, "notes", indentation);
- pivot_table_dump_string (table->table_look, "table-look", indentation);
+ pivot_table_dump_string (table->look.name, "table-look", indentation);
if (table->date)
{
indent (indentation);
indent (indentation);
printf ("sizing:\n");
- pivot_table_sizing_dump ("column", &table->sizing[TABLE_HORZ],
- indentation + 1);
- pivot_table_sizing_dump ("row", &table->sizing[TABLE_VERT],
- indentation + 1);
+ pivot_table_sizing_dump ("column", table->look.width_ranges[TABLE_HORZ],
+ &table->sizing[TABLE_HORZ], indentation + 1);
+ pivot_table_sizing_dump ("row", table->look.width_ranges[TABLE_VERT],
+ &table->sizing[TABLE_VERT], indentation + 1);
indent (indentation);
printf ("areas:\n");
for (enum pivot_area area = 0; area < PIVOT_N_AREAS; area++)
- table_area_style_dump (area, &table->areas[area], indentation + 1);
+ table_area_style_dump (area, &table->look.areas[area], indentation + 1);
indent (indentation);
printf ("borders:\n");
for (enum pivot_border border = 0; border < PIVOT_N_BORDERS; border++)
- table_border_style_dump (border, &table->borders[border], indentation + 1);
+ table_border_style_dump (border, &table->look.borders[border],
+ indentation + 1);
for (size_t i = 0; i < table->n_dimensions; i++)
pivot_dimension_dump (table->dimensions[i], indentation);
putchar ('\n');
size_t *column_enumeration = pivot_table_enumerate_axis (
- table, PIVOT_AXIS_COLUMN, layer_indexes, table->omit_empty, NULL);
+ table, PIVOT_AXIS_COLUMN, layer_indexes, table->look.omit_empty, NULL);
size_t *row_enumeration = pivot_table_enumerate_axis (
- table, PIVOT_AXIS_ROW, layer_indexes, table->omit_empty, NULL);
+ table, PIVOT_AXIS_ROW, layer_indexes, table->look.omit_empty, NULL);
char ***column_headings = compose_headings (
&table->axes[PIVOT_AXIS_COLUMN], column_enumeration,
return value;
}
-static char *
-xstrdup_if_nonempty (const char *s)
-{
- return s && s[0] ? xstrdup (s) : NULL;
-}
-
/* Returns a new pivot_value that represents X.
The format to use for X is unspecified. Usually the easiest way to specify
heights. */
struct pivot_table_sizing
{
- /* Minimum and maximum column width, in 1/96" units. */
- int range[2];
-
/* Specific column widths, in 1/96" units. */
int *widths;
size_t n_widths;
bool pivot_result_class_change (const char *, const struct fmt_spec *);
\f
+/* Styling for a pivot table.
+
+ The division between this and the style information in struct pivot_table
+ seems fairly arbitrary. The ultimate reason for the division is simply
+ because that's how SPSS documentation and file formats do it. */
+struct pivot_table_look
+ {
+ char *name; /* May be null. */
+
+ /* General properties. */
+ bool omit_empty;
+ bool row_labels_in_corner;
+ int width_ranges[TABLE_N_AXES][2]; /* In 1/96" units. */
+
+ /* Footnote display settings. */
+ bool show_numeric_markers;
+ bool footnote_marker_superscripts;
+
+ /* Styles. */
+ struct table_area_style areas[PIVOT_N_AREAS];
+ struct table_border_style borders[PIVOT_N_BORDERS];
+
+ /* Print settings. */
+ bool print_all_layers;
+ bool paginate_layers;
+ bool shrink_to_fit[TABLE_N_AXES];
+ bool top_continuation, bottom_continuation;
+ char *continuation;
+ size_t n_orphan_lines;
+ };
+
+void pivot_table_look_init (struct pivot_table_look *);
+void pivot_table_look_uninit (struct pivot_table_look *);
+void pivot_table_look_copy (struct pivot_table_look *,
+ const struct pivot_table_look *);
+\f
/* A pivot table. See the top of this file for more information. */
struct pivot_table
{
the pivot_table must not be modified. */
int ref_cnt;
+ /* Styling. */
+ struct pivot_table_look look;
+
/* Display settings. */
bool rotate_inner_column_labels;
bool rotate_outer_row_labels;
- bool row_labels_in_corner;
bool show_grid_lines;
bool show_caption;
- bool omit_empty; /* Omit empty rows and columns? */
size_t *current_layer; /* axis[PIVOT_AXIS_LAYER].n_dimensions elements. */
- char *table_look; /* May be NULL. */
enum settings_value_show show_values;
enum settings_value_show show_variables;
struct fmt_spec weight_format;
- /* Footnote display settings. */
- bool show_numeric_markers;
- bool footnote_marker_superscripts;
-
/* Column and row sizing and page breaks.
sizing[TABLE_HORZ] is for columns, sizing[TABLE_VERT] is for rows. */
struct pivot_table_sizing sizing[TABLE_N_AXES];
- /* Print settings. */
- bool print_all_layers;
- bool paginate_layers;
- bool shrink_to_fit[TABLE_N_AXES];
- bool top_continuation, bottom_continuation;
- char *continuation;
- size_t n_orphan_lines;
-
/* Format settings. */
int epoch;
char decimal; /* Usually ',' or '.'. */
struct pivot_value *caption;
char *notes;
- /* Styles. */
- struct table_area_style areas[PIVOT_N_AREAS];
- struct table_border_style borders[PIVOT_N_BORDERS];
-
/* Dimensions. */
struct pivot_dimension **dimensions;
size_t n_dimensions;
void pivot_table_unref (struct pivot_table *);
bool pivot_table_is_shared (const struct pivot_table *);
+/* Styling. */
+const struct pivot_table_look *pivot_table_get_look (
+ const struct pivot_table *);
+void pivot_table_set_look (struct pivot_table *,
+ const struct pivot_table_look *);
+
/* Format of PIVOT_RC_COUNT cells. */
void pivot_table_set_weight_var (struct pivot_table *,
const struct variable *);
if (lf->label->purpose == SPVDX_PURPOSE_TITLE)
{
target = &table->title;
- area = &table->areas[PIVOT_AREA_TITLE];
+ area = &table->look.areas[PIVOT_AREA_TITLE];
}
else if (lf->label->purpose == SPVDX_PURPOSE_SUB_TITLE)
{
target = &table->caption;
- area = &table->areas[PIVOT_AREA_CAPTION];
+ area = &table->look.areas[PIVOT_AREA_CAPTION];
}
else if (lf->label->purpose == SPVDX_PURPOSE_FOOTNOTE)
{
&& lf->label->text[0]->uses_reference != INT_MIN)
{
target = NULL;
- area = &table->areas[PIVOT_AREA_FOOTER];
+ area = &table->look.areas[PIVOT_AREA_FOOTER];
}
else
return NULL;
else if (lf->label->purpose == SPVDX_PURPOSE_LAYER)
{
target = NULL;
- area = &table->areas[PIVOT_AREA_LAYERS];
+ area = &table->look.areas[PIVOT_AREA_LAYERS];
}
else
return NULL;
= find_facet_level (v, base_facet_level + n);
if (fl)
{
- 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);
+ struct table_area_style *area
+ = (axis_type == PIVOT_AXIS_COLUMN
+ ? &table->look.areas[PIVOT_AREA_COLUMN_LABELS]
+ : axis_type == PIVOT_AXIS_ROW
+ ? &table->look.areas[PIVOT_AREA_ROW_LABELS]
+ : NULL);
if (area && fl->axis->label)
{
table_area_style_uninit (area);
decode_spvdx_style_incremental (
fl2->axis->major_ticks->style,
fl2->axis->major_ticks->tick_frame_style,
- &table->areas[PIVOT_AREA_ROW_LABELS]);
+ &table->look.areas[PIVOT_AREA_ROW_LABELS]);
}
const struct spvdx_facet_level *fl3 = find_facet_level (v, base_facet_level);
/* Sets alt_fg_color and alt_bg_color. */
struct table_area_style area;
decode_spvdx_style (labeling, graph, &area);
- table->areas[PIVOT_AREA_DATA].font_style.fg[1]
+ table->look.areas[PIVOT_AREA_DATA].font_style.fg[1]
= area.font_style.fg[0];
- table->areas[PIVOT_AREA_DATA].font_style.bg[1]
+ table->look.areas[PIVOT_AREA_DATA].font_style.bg[1]
= area.font_style.bg[0];
table_area_style_uninit (&area);
}
{
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]);
+ ? &table->look.areas[PIVOT_AREA_ROW_LABELS]
+ : &table->look.areas[PIVOT_AREA_COLUMN_LABELS]);
apply_styles_to_value (table, c->name, set_format,
base_area_style, major_ticks, frame);
}
goto skip;
}
apply_styles_to_value (table, cell->value, set_format,
- &table->areas[PIVOT_AREA_DATA],
+ &table->look.areas[PIVOT_AREA_DATA],
labeling, interval);
skip: ;
struct pivot_cell *cell;
HMAP_FOR_EACH (cell, struct pivot_cell, hmap_node, &table->cells)
apply_styles_to_value (table, cell->value, set_format,
- &table->areas[PIVOT_AREA_DATA],
+ &table->look.areas[PIVOT_AREA_DATA],
NULL, NULL);
}
}
char * WARN_UNUSED_RESULT
decode_spvdx_table (const struct spvdx_visualization *v, const char *subtype,
- const struct spv_table_look *look,
+ const struct pivot_table_look *look,
struct spv_data *data, struct pivot_table **outp)
{
struct pivot_table *table = pivot_table_create__ (NULL, subtype);
- spv_table_look_install (look, table);
+ pivot_table_set_look (table, look);
struct hmap series_map = HMAP_INITIALIZER (series_map);
struct hmap format_map = HMAP_INITIALIZER (format_map);
&min_width, &max_width, &n)
&& v->graph->cell_style->width[n] == '\0')
{
- table->sizing[TABLE_HORZ].range[0] = min_width;
- table->sizing[TABLE_HORZ].range[1] = max_width;
+ table->look.width_ranges[TABLE_HORZ][0] = min_width;
+ table->look.width_ranges[TABLE_HORZ][1] = max_width;
}
}
}
if (v->graph->interval->labeling->style)
{
- table_area_style_uninit (&table->areas[PIVOT_AREA_DATA]);
+ table_area_style_uninit (&table->look.areas[PIVOT_AREA_DATA]);
decode_spvdx_style (v->graph->interval->labeling->style,
v->graph->cell_style,
- &table->areas[PIVOT_AREA_DATA]);
+ &table->look.areas[PIVOT_AREA_DATA]);
}
/* Decode all of the sourceVariable and derivedVariable */
struct pivot_table;
struct spvdx_visualization;
struct spv_data;
-struct spv_table_look;
+struct pivot_table_look;
char *decode_spvdx_table (const struct spvdx_visualization *,
const char *subtype,
- const struct spv_table_look *,
+ const struct pivot_table_look *,
struct spv_data *,
struct pivot_table **outp)
WARN_UNUSED_RESULT;
if (in->border_type >= PIVOT_N_BORDERS)
return xasprintf ("bad border type %"PRIu32, in->border_type);
- struct table_border_style *out = &table->borders[in->border_type];
+ struct table_border_style *out = &table->look.borders[in->border_type];
out->color = decode_spvlb_color_u32 (in->color);
return decode_spvlb_stroke (in->stroke_type, &out->stroke);
}
}
/* Display settings. */
- out->show_numeric_markers = !in->ts->show_alphabetic_markers;
+ out->look.show_numeric_markers = !in->ts->show_alphabetic_markers;
out->rotate_inner_column_labels = in->header->rotate_inner_column_labels;
out->rotate_outer_row_labels = in->header->rotate_outer_row_labels;
- out->row_labels_in_corner = in->ts->show_row_labels_in_corner;
+ out->look.row_labels_in_corner = in->ts->show_row_labels_in_corner;
out->show_grid_lines = in->borders->show_grid_lines;
out->show_caption = true;
- out->footnote_marker_superscripts = in->ts->footnote_marker_superscripts;
- out->omit_empty = in->ts->omit_empty;
+ out->look.footnote_marker_superscripts = in->ts->footnote_marker_superscripts;
+ out->look.omit_empty = in->ts->omit_empty;
const struct spvlb_x1 *x1 = in->formats->x1;
if (x1)
}
/* Column and row display settings. */
- out->sizing[TABLE_VERT].range[0] = in->header->min_row_height;
- out->sizing[TABLE_VERT].range[1] = in->header->max_row_height;
- out->sizing[TABLE_HORZ].range[0] = in->header->min_col_width;
- out->sizing[TABLE_HORZ].range[1] = in->header->max_col_width;
+ out->look.width_ranges[TABLE_VERT][0] = in->header->min_row_height;
+ out->look.width_ranges[TABLE_VERT][1] = in->header->max_row_height;
+ out->look.width_ranges[TABLE_HORZ][0] = in->header->min_col_width;
+ out->look.width_ranges[TABLE_HORZ][1] = in->header->max_col_width;
convert_widths (in->formats->widths, in->formats->n_widths,
&out->sizing[TABLE_HORZ].widths,
&out->sizing[TABLE_HORZ].n_keeps);
out->notes = to_utf8_if_nonempty (in->ts->notes, encoding);
- out->table_look = to_utf8_if_nonempty (in->ts->table_look, encoding);
+ out->look.name = to_utf8_if_nonempty (in->ts->table_look, encoding);
/* Print settings. */
- out->print_all_layers = in->ps->all_layers;
- out->paginate_layers = in->ps->paginate_layers;
- out->shrink_to_fit[TABLE_HORZ] = in->ps->fit_width;
- out->shrink_to_fit[TABLE_VERT] = in->ps->fit_length;
- out->top_continuation = in->ps->top_continuation;
- out->bottom_continuation = in->ps->bottom_continuation;
- out->continuation = xstrdup (in->ps->continuation_string);
- out->n_orphan_lines = in->ps->n_orphan_lines;
+ out->look.print_all_layers = in->ps->all_layers;
+ out->look.paginate_layers = in->ps->paginate_layers;
+ out->look.shrink_to_fit[TABLE_HORZ] = in->ps->fit_width;
+ out->look.shrink_to_fit[TABLE_VERT] = in->ps->fit_length;
+ out->look.top_continuation = in->ps->top_continuation;
+ out->look.bottom_continuation = in->ps->bottom_continuation;
+ out->look.continuation = xstrdup (in->ps->continuation_string);
+ out->look.n_orphan_lines = in->ps->n_orphan_lines;
/* Format settings. */
out->epoch = in->formats->y0->epoch;
/* Styles. */
for (size_t i = 0; i < PIVOT_N_AREAS; i++)
{
- error = decode_spvlb_area (in->areas->areas[i], &out->areas[i],
+ error = decode_spvlb_area (in->areas->areas[i], &out->look.areas[i],
encoding);
if (error)
goto error;
#include <string.h>
#include "output/spv/structure-xml-parser.h"
+#include "output/pivot-table.h"
+#include "output/table.h"
#include "gl/read-file.h"
#include "gl/xalloc.h"
char * WARN_UNUSED_RESULT
spv_table_look_decode (const struct spvsx_table_properties *in,
- struct spv_table_look **outp)
+ struct pivot_table_look **outp)
{
- struct spv_table_look *out = xzalloc (sizeof *out);
+ struct pivot_table_look *out = xzalloc (sizeof *out);
char *error = NULL;
out->name = in->name ? xstrdup (in->name) : NULL;
const struct spvsx_printing_properties *pp = in->printing_properties;
out->print_all_layers = pp->print_all_layers > 0;
out->paginate_layers = pp->print_each_layer_on_separate_page > 0;
- out->shrink_to_width = pp->rescale_wide_table_to_fit_page > 0;
- out->shrink_to_length = pp->rescale_long_table_to_fit_page > 0;
+ out->shrink_to_fit[TABLE_HORZ] = pp->rescale_wide_table_to_fit_page > 0;
+ out->shrink_to_fit[TABLE_VERT] = pp->rescale_long_table_to_fit_page > 0;
out->top_continuation = pp->continuation_text_at_top > 0;
out->bottom_continuation = pp->continuation_text_at_bottom > 0;
out->continuation = xstrdup (pp->continuation_text
return NULL;
error:
- spv_table_look_destroy (out);
+ pivot_table_look_uninit (out);
+ free (out);
*outp = NULL;
return error;
}
char * WARN_UNUSED_RESULT
-spv_table_look_read (const char *filename, struct spv_table_look **outp)
+spv_table_look_read (const char *filename, struct pivot_table_look **outp)
{
*outp = NULL;
}
char * WARN_UNUSED_RESULT
-spv_table_look_write (const char *filename, const struct spv_table_look *look)
+spv_table_look_write (const char *filename, const struct pivot_table_look *look)
{
FILE *file = fopen (filename, "w");
if (!file)
start_elem (xml, "printingProperties");
write_attr_bool (xml, "printAllLayers", look->print_all_layers);
- write_attr_bool (xml, "rescaleLongTableToFitPage", look->shrink_to_length);
- write_attr_bool (xml, "rescaleWideTableToFitPage", look->shrink_to_width);
+ write_attr_bool (xml, "rescaleLongTableToFitPage",
+ look->shrink_to_fit[TABLE_HORZ]);
+ write_attr_bool (xml, "rescaleWideTableToFitPage",
+ look->shrink_to_fit[TABLE_VERT]);
write_attr_format (xml, "windowOrphanLines", "%zu", look->n_orphan_lines);
if (look->continuation && look->continuation[0]
&& (look->top_continuation || look->bottom_continuation))
return NULL;
}
-
-void
-spv_table_look_destroy (struct spv_table_look *look)
-{
- if (look)
- {
- free (look->name);
- for (size_t i = 0; i < PIVOT_N_AREAS; i++)
- table_area_style_uninit (&look->areas[i]);
- free (look->continuation);
- free (look);
- }
-}
-
-void
-spv_table_look_install (const struct spv_table_look *look,
- struct pivot_table *table)
-{
- free (table->table_look);
- if (look->name)
- table->table_look = xstrdup (look->name);
-
- table->omit_empty = look->omit_empty;
-
- for (enum table_axis axis = 0; axis < TABLE_N_AXES; axis++)
- for (int i = 0; i < 2; i++)
- if (look->width_ranges[axis][i] > 0)
- table->sizing[axis].range[i] = look->width_ranges[axis][i];
- table->row_labels_in_corner = look->row_labels_in_corner;
-
- table->footnote_marker_superscripts = look->footnote_marker_superscripts;
- table->show_numeric_markers = look->show_numeric_markers;
-
- for (size_t i = 0; i < PIVOT_N_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];
-
- table->print_all_layers = look->print_all_layers;
- table->paginate_layers = look->paginate_layers;
- table->shrink_to_fit[TABLE_HORZ] = look->shrink_to_width;
- table->shrink_to_fit[TABLE_VERT] = look->shrink_to_length;
- table->top_continuation = look->top_continuation;
- table->bottom_continuation = look->bottom_continuation;
- table->continuation = xstrdup (look->continuation);
- table->n_orphan_lines = look->n_orphan_lines;
-}
-
-struct spv_table_look *
-spv_table_look_get (const struct pivot_table *table)
-{
- struct spv_table_look *look = xzalloc (sizeof *look);
-
- look->name = table->table_look ? xstrdup (table->table_look) : NULL;
-
- look->omit_empty = table->omit_empty;
-
- for (enum table_axis axis = 0; axis < TABLE_N_AXES; axis++)
- for (int i = 0; i < 2; i++)
- look->width_ranges[axis][i] = table->sizing[axis].range[i];
- look->row_labels_in_corner = table->row_labels_in_corner;
-
- look->footnote_marker_superscripts = table->footnote_marker_superscripts;
- look->show_numeric_markers = table->show_numeric_markers;
-
- for (size_t i = 0; i < PIVOT_N_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];
-
- look->print_all_layers = table->print_all_layers;
- look->paginate_layers = table->paginate_layers;
- look->shrink_to_width = table->shrink_to_fit[TABLE_HORZ];
- look->shrink_to_length = table->shrink_to_fit[TABLE_VERT];
- look->top_continuation = table->top_continuation;
- look->bottom_continuation = table->bottom_continuation;
- look->continuation = xstrdup (table->continuation);
- look->n_orphan_lines = table->n_orphan_lines;
-
- return look;
-}
#ifndef OUTPUT_SPV_TABLE_LOOK_H
#define OUTPUT_SPV_TABLE_LOOK_H 1
-/* TableLook decoder.
+/* TableLook file decoder.
A TableLook specifies styles for tables and other aspects of output. They
exist standalone as .stt files as well as embedded in structure XML, in
#include <stdbool.h>
#include "libpspp/compiler.h"
-#include "output/pivot-table.h"
-#include "output/table.h"
+struct pivot_table_look;
struct spvsx_table_properties;
-struct spv_table_look
- {
- char *name; /* May be null. */
-
- /* General properties. */
- bool omit_empty;
- int width_ranges[TABLE_N_AXES][2]; /* In 1/96" units. */
- bool row_labels_in_corner;
-
- /* Footnote display settings. */
- bool show_numeric_markers;
- bool footnote_marker_superscripts;
-
- /* Styles. */
- struct table_area_style areas[PIVOT_N_AREAS];
- struct table_border_style borders[PIVOT_N_BORDERS];
-
- /* Print settings. */
- bool print_all_layers;
- bool paginate_layers;
- bool shrink_to_width;
- bool shrink_to_length;
- bool top_continuation, bottom_continuation;
- char *continuation;
- size_t n_orphan_lines;
- };
-
-void spv_table_look_destroy (struct spv_table_look *);
-
char *spv_table_look_decode (const struct spvsx_table_properties *,
- struct spv_table_look **)
+ struct pivot_table_look **)
WARN_UNUSED_RESULT;
-char *spv_table_look_read (const char *, struct spv_table_look **)
+char *spv_table_look_read (const char *, struct pivot_table_look **)
WARN_UNUSED_RESULT;
-char *spv_table_look_write (const char *, const struct spv_table_look *)
+char *spv_table_look_write (const char *, const struct pivot_table_look *)
WARN_UNUSED_RESULT;
-void spv_table_look_install (const struct spv_table_look *,
- struct pivot_table *);
-struct spv_table_look *spv_table_look_get (const struct pivot_table *);
-
#endif /* output/spv/spv-table-look.h */
put_bool (buf, table->rotate_outer_row_labels);
put_bool (buf, true);
put_u32 (buf, 0x15);
- put_u32 (buf, table->sizing[H].range[0]);
- put_u32 (buf, table->sizing[H].range[1]);
- put_u32 (buf, table->sizing[V].range[0]);
- put_u32 (buf, table->sizing[V].range[1]);
+ put_u32 (buf, table->look.width_ranges[H][0]);
+ put_u32 (buf, table->look.width_ranges[H][1]);
+ put_u32 (buf, table->look.width_ranges[V][0]);
+ put_u32 (buf, table->look.width_ranges[V][1]);
put_u64 (buf, table_id);
/* Titles. */
/* Areas. */
for (size_t i = 0; i < PIVOT_N_AREAS; i++)
{
- const struct table_area_style *a = &table->areas[i];
+ const struct table_area_style *a = &table->look.areas[i];
put_byte (buf, i + 1);
put_byte (buf, 0x31);
put_string (buf, (a->font_style.typeface
put_be32 (buf, PIVOT_N_BORDERS);
for (size_t i = 0; i < PIVOT_N_BORDERS; i++)
{
- const struct table_border_style *b = &table->borders[i];
+ const struct table_border_style *b = &table->look.borders[i];
put_be32 (buf, i);
put_be32 (buf, (b->stroke == TABLE_STROKE_NONE ? 0
: b->stroke == TABLE_STROKE_SOLID ? 1
/* Print Settings. */
uint32_t ps_start = start_count (buf);
put_be32 (buf, 1);
- put_bool (buf, table->print_all_layers);
- put_bool (buf, table->paginate_layers);
- put_bool (buf, table->shrink_to_fit[H]);
- put_bool (buf, table->shrink_to_fit[V]);
- put_bool (buf, table->top_continuation);
- put_bool (buf, table->bottom_continuation);
- put_be32 (buf, table->n_orphan_lines);
- put_bestring (buf, table->continuation);
+ put_bool (buf, table->look.print_all_layers);
+ put_bool (buf, table->look.paginate_layers);
+ put_bool (buf, table->look.shrink_to_fit[H]);
+ put_bool (buf, table->look.shrink_to_fit[V]);
+ put_bool (buf, table->look.top_continuation);
+ put_bool (buf, table->look.bottom_continuation);
+ put_be32 (buf, table->look.n_orphan_lines);
+ put_bestring (buf, table->look.continuation);
end_count_u32 (buf, ps_start);
/* Table Settings. */
put_be32 (buf, 1);
put_be32 (buf, 4);
put_be32 (buf, 0); /* XXX current_layer */
- put_bool (buf, table->omit_empty);
- put_bool (buf, table->row_labels_in_corner);
- put_bool (buf, !table->show_numeric_markers);
- put_bool (buf, table->footnote_marker_superscripts);
+ put_bool (buf, table->look.omit_empty);
+ put_bool (buf, table->look.row_labels_in_corner);
+ put_bool (buf, !table->look.show_numeric_markers);
+ put_bool (buf, table->look.footnote_marker_superscripts);
put_byte (buf, 0);
uint32_t keep_start = start_count (buf);
put_be32 (buf, 0); /* n-row-breaks */
put_be32 (buf, 0); /* n-column-point-keeps */
end_count_be32 (buf, keep_start);
put_bestring (buf, table->notes);
- put_bestring (buf, table->table_look);
+ put_bestring (buf, table->look.name);
for (size_t i = 0; i < 82; i++)
put_byte (buf, 0);
end_count_u32 (buf, ts_start);
free (item->children);
pivot_table_unref (item->table);
- spv_table_look_destroy (item->table_look);
+ if (item->table_look)
+ {
+ pivot_table_look_uninit (item->table_look);
+ free (item->table_look);
+ }
free (item->bin_member);
free (item->xml_member);
free (item->subtype);
void
spv_item_set_table_look (struct spv_item *item,
- const struct spv_table_look *look)
+ const struct pivot_table_look *look)
{
/* If this is a table, install the table look in it.
(We can't just set item->table_look because light tables ignore it and
legacy tables sometimes override it.) */
if (spv_item_is_table (item))
- spv_table_look_install (look, spv_item_get_table (item));
+ pivot_table_set_look (spv_item_get_table (item), look);
for (size_t i = 0; i < item->n_children; i++)
spv_item_set_table_look (item->children[i], look);
/* SPV_ITEM_TABLE only. */
struct pivot_table *table; /* NULL if not yet loaded. */
- struct spv_table_look *table_look;
+ struct pivot_table_look *table_look;
char *bin_member;
char *xml_member;
char *subtype;
WARN_UNUSED_RESULT;
void spv_item_set_table_look (struct spv_item *,
- const struct spv_table_look *);
+ const struct pivot_table_look *);
char *spv_decode_fmt_spec (uint32_t u32, struct fmt_spec *) WARN_UNUSED_RESULT;
static bool force;
/* --table-look: TableLook to replace table style for conversion. */
-static struct spv_table_look *table_look;
+static struct pivot_table_look *table_look;
/* Number of warnings issued. */
static size_t n_warnings;
if (!table)
error (1, 0, "%s: no tables found", argv[1]);
- struct spv_table_look *look = spv_table_look_get (table);
- err = spv_table_look_write (argv[2], look);
+ err = spv_table_look_write (argv[2], pivot_table_get_look (table));
if (err)
error (1, 0, "%s", err);
- spv_table_look_destroy (look);
spv_close (spv);
}
c->run (argc, argv);
- spv_table_look_destroy (table_look);
+ if (table_look)
+ {
+ pivot_table_look_uninit (table_look);
+ free (table_look);
+ }
i18n_done ();
return n_warnings ? EXIT_FAILURE : EXIT_SUCCESS;
static void
parse_table_look (const char *arg)
{
- spv_table_look_destroy (table_look);
+ if (table_look)
+ {
+ pivot_table_look_uninit (table_look);
+ free (table_look);
+ }
+
char *error_s = spv_table_look_read (arg, &table_look);
if (error_s)
error (1, 0, "%s", error_s);