X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Foutput%2Fpivot-output.c;h=e469afb08150cf6e33121f25c8417c0a3113e55d;hb=3b54533821614d17afc61f1cd3b87d3a06fbf4da;hp=8226b35e47bdd67edbc4e6c923613da5438221ce;hpb=96994a54e60e9c95b8bba54c2281acf7059b1203;p=pspp diff --git a/src/output/pivot-output.c b/src/output/pivot-output.c index 8226b35e47..e469afb081 100644 --- a/src/output/pivot-output.c +++ b/src/output/pivot-output.c @@ -24,6 +24,7 @@ #include "libpspp/assertion.h" #include "libpspp/pool.h" #include "output/table.h" +#include "output/page-eject-item.h" #include "output/table-item.h" #include "output/text-item.h" #include "output/table-provider.h" @@ -53,19 +54,19 @@ find_category (const struct pivot_dimension *d, int dim_index, 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, @@ -91,7 +92,7 @@ area_style_override (struct pool *pool, 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, @@ -118,9 +119,9 @@ fill_cell (struct table *t, int x1, int y1, int x2, int y2, { 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++) { @@ -137,7 +138,7 @@ fill_cell (struct table *t, int x1, int y1, int x2, int y2, 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) @@ -152,7 +153,7 @@ pivot_value_to_table_item_text (const struct pivot_value *value, *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), }; @@ -195,8 +196,9 @@ compose_headings (struct table *t, 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, @@ -311,9 +313,9 @@ pivot_table_submit_layer (const struct pivot_table *pt, 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, @@ -324,12 +326,12 @@ pivot_table_submit_layer (const struct pivot_table *pt, 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->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]; @@ -339,7 +341,7 @@ pivot_table_submit_layer (const struct pivot_table *pt, out->b = in->color.b; } - struct footnote **footnotes = xcalloc (pt->n_footnotes, sizeof *footnotes); + struct footnote **footnotes = XCALLOC (pt->n_footnotes, struct footnote *); for (size_t i = 0; i < pt->n_footnotes; i++) { const struct pivot_footnote *pf = pt->footnotes[i]; @@ -353,42 +355,43 @@ pivot_table_submit_layer (const struct pivot_table *pt, 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->look.areas[PIVOT_AREA_FOOTER], + pf->content->cell_style, + pf->content->font_style)); free (marker); free (content); } 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); - size_t *dindexes = xcalloc (pt->n_dimensions, sizeof *dindexes); + size_t *dindexes = XCALLOC (pt->n_dimensions, size_t); size_t y = 0; PIVOT_ENUMERATION_FOR_EACH (pindexes[PIVOT_AXIS_ROW], row_enumeration, &pt->axes[PIVOT_AXIS_ROW]) @@ -403,7 +406,7 @@ pivot_table_submit_layer (const struct pivot_table *pt, 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); @@ -416,32 +419,32 @@ pivot_table_submit_layer (const struct pivot_table *pt, 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); } @@ -453,7 +456,7 @@ pivot_table_submit_layer (const struct pivot_table *pt, 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); @@ -469,8 +472,8 @@ pivot_table_submit_layer (const struct pivot_table *pt, if (!layers) { layers = xzalloc (sizeof *layers); - layers->style = area_style_override ( - NULL, &pt->areas[PIVOT_AREA_LAYERS], NULL, NULL); + layers->style = table_area_style_override ( + NULL, &pt->look.areas[PIVOT_AREA_LAYERS], NULL, NULL); layers->layers = xnmalloc (layer_axis->n_dimensions, sizeof *layers->layers); } @@ -502,7 +505,7 @@ pivot_table_submit_layer (const struct pivot_table *pt, 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); @@ -523,14 +526,14 @@ pivot_table_submit (struct pivot_table *pt) 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) - text_item_submit (text_item_create (TEXT_ITEM_EJECT_PAGE, "")); + if (pt->look.paginate_layers) + page_eject_item_submit (page_eject_item_create ()); pivot_table_submit_layer (pt, layer_indexes); } }