- struct string s = DS_EMPTY_INITIALIZER;
- int options = format_cell (value, style_idx,
- show_values, show_variables, rotate_label, &s);
- table_joint_text (t, x1, y1, x2, y2, options, ds_cstr (&s));
- ds_destroy (&s);
-
- if (value)
- {
- if (value->cell_style || value->font_style || rotate_label)
- table_add_style (t, x1, y1,
- table_area_style_override (t->container, style,
- value->cell_style,
- value->font_style,
- rotate_label));
-
- for (size_t i = 0; i < value->n_footnotes; i++)
- {
- 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);
- }
-}
-
-static struct table_cell *
-pivot_value_to_table_cell (const struct pivot_value *value,
- const struct table_area_style *style, int style_idx,
- struct footnote **footnotes,
- enum settings_value_show show_values,
- enum settings_value_show show_variables)
-{
- if (!value)
- return NULL;
-
- struct string s = DS_EMPTY_INITIALIZER;
- int options = format_cell (value, style_idx,
- show_values, show_variables, false, &s);
-
- struct table_cell *cell = xmalloc (sizeof *cell);
- *cell = (struct table_cell) {
- .options = options,
- .text = ds_steal_cstr (&s),
- .style = table_area_style_override (
- NULL, style, value->cell_style, value->font_style, false),
- };
-
- if (value->n_subscripts)
- {
- cell->subscripts = xnmalloc (value->n_subscripts,
- sizeof *cell->subscripts);
- cell->n_subscripts = value->n_subscripts;
- for (size_t i = 0; i < value->n_subscripts; i++)
- cell->subscripts[i] = xstrdup (value->subscripts[i]);
- }
-
- if (value->n_footnotes)
- {
- cell->footnotes = xnmalloc (value->n_footnotes, sizeof *cell->footnotes);
- for (size_t i = 0; i < value->n_footnotes; i++)
- {
- struct footnote *f = footnotes[value->footnotes[i]->idx];
- if (f)
- cell->footnotes[cell->n_footnotes++] = f;
- }
- }