X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Foutput%2Fpivot-output.c;h=158116117f02b0a10ee098d77e8c3d776798fdf8;hb=81dece3642da9bdcbdec4aa09b0c2008c86d6161;hp=f90a953e5d5758c30049e104de39313597320f6e;hpb=464a7a97da808da1d8a608e9254dfaad30c9de72;p=pspp diff --git a/src/output/pivot-output.c b/src/output/pivot-output.c index f90a953e5d..158116117f 100644 --- a/src/output/pivot-output.c +++ b/src/output/pivot-output.c @@ -121,9 +121,17 @@ fill_cell (struct table *t, int x1, int y1, int x2, int y2, area_style_override (t->container, style, value->cell_style, value->font_style)); - + for (size_t i = 0; i < value->n_footnotes; i++) - table_add_footnote (t, x1, y1, footnotes[value->footnotes[i]->idx]); + { + struct footnote *f = footnotes[value->footnotes[i]->idx]; + if (f) + table_add_footnote (t, x1, y1, f); + } + + if (value->n_subscripts) + table_add_subscripts (t, x1, y1, + value->subscripts, value->n_subscripts); } } @@ -144,13 +152,16 @@ 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), - .n_footnotes = value->n_footnotes, .style = area_style_override ( NULL, area, value->cell_style, value->font_style), }; for (size_t i = 0; i < value->n_footnotes; i++) - text->footnotes[i] = footnotes[value->footnotes[i]->idx]; + { + struct footnote *f = footnotes[value->footnotes[i]->idx]; + if (f) + text->footnotes[text->n_footnotes++] = f; + } return text; } @@ -208,7 +219,7 @@ compose_headings (struct table *t, for (int row_ofs = 0; row_ofs < d->label_depth; row_ofs++) { - for (size_t x1 = 0; x1 < n_columns; ) + for (size_t x1 = 0; x1 < n_columns;) { const struct pivot_category *c = find_category ( d, dim_index, column_enumeration + x1 * stride, row_ofs); @@ -328,18 +339,23 @@ 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++) { - char *content = pivot_value_to_string ( - 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); + const struct pivot_footnote *pf = pt->footnotes[i]; + + if (!pf->show) + continue; + + char *content = pivot_value_to_string (pf->content, pt->show_values, + pt->show_variables); + char *marker = pivot_value_to_string (pf->marker, pt->show_values, + pt->show_variables); 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, - pt->footnotes[i]->content->font_style)); + pf->content->cell_style, + pf->content->font_style)); free (marker); free (content); } @@ -372,7 +388,7 @@ pivot_table_submit_layer (const struct pivot_table *pt, 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]) @@ -466,11 +482,15 @@ pivot_table_submit_layer (const struct pivot_table *pt, pivot_value_format_body (name, pt->show_values, pt->show_variables, &s); layer->content = ds_steal_cstr (&s); - layer->n_footnotes = name->n_footnotes; - layer->footnotes = xnmalloc (layer->n_footnotes, + layer->n_footnotes = 0; + layer->footnotes = xnmalloc (name->n_footnotes, sizeof *layer->footnotes); for (size_t i = 0; i < name->n_footnotes; i++) - layer->footnotes[i] = footnotes[name->footnotes[i]->idx]; + { + struct footnote *f = footnotes[name->footnotes[i]->idx]; + if (f) + layer->footnotes[layer->n_footnotes++] = f; + } } } if (layers) @@ -479,7 +499,7 @@ pivot_table_submit_layer (const struct pivot_table *pt, table_item_layers_destroy (layers); } - if (pt->caption) + 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, @@ -489,6 +509,8 @@ pivot_table_submit_layer (const struct pivot_table *pt, } free (footnotes); + ti->pt = pivot_table_ref (pt); + table_item_submit (ti); }