ds_put_byte (&body, ',');
size_t idx = value->footnote_indexes[i];
- const struct pivot_footnote *f = pt->footnotes[idx];
- pivot_value_format (f->marker, pt, &body);
+ pivot_footnote_format_marker (pt->footnotes[idx], pt, &body);
}
/* Allow footnote markers to occupy the right margin. That way, numbers
size_t idx = cell->value->footnote_indexes[i];
const struct pivot_footnote *f = pt->footnotes[idx];
- char *marker = pivot_value_to_string (f->marker, pt);
+
+ char *marker = pivot_footnote_marker_string (f, pt);
escape_string (html->file, marker, " ", "<br>");
free (marker);
}
xmlTextWriterWriteAttribute (odt->content_wtr, _xml("text:style-name"),
_xml("superscript"));
const struct pivot_footnote *f = pt->footnotes[footnote_indexes[i]];
- char *s = pivot_value_to_string (f->marker, pt);
+ char *s = pivot_footnote_marker_string (f, pt);
write_xml_with_line_breaks (odt, s);
free (s);
xmlTextWriterEndElement (odt->content_wtr);
for (size_t i = 0; i < nf; i++)
{
struct string s = DS_EMPTY_INITIALIZER;
- pivot_value_format (f[i]->marker, pt, &s);
+ pivot_footnote_format_marker (f[i], pt, &s);
ds_put_cstr (&s, ". ");
pivot_value_format (f[i]->content, pt, &s);
fill_cell_owned (footnotes, 0, i, 0, i, PIVOT_AREA_FOOTER, &s,
NULL, content);
}
-static struct pivot_value *
-pivot_make_default_footnote_marker (int idx, bool show_numeric_markers)
-{
- char text[INT_BUFSIZE_BOUND (size_t)];
- if (show_numeric_markers)
- snprintf (text, sizeof text, "%d", idx + 1);
+void
+pivot_footnote_format_marker (const struct pivot_footnote *f,
+ const struct pivot_table *pt,
+ struct string *s)
+{
+ if (f->marker)
+ pivot_value_format_body (f->marker, pt, s);
+ else if (pt->look->show_numeric_markers)
+ ds_put_format (s, "%zu", f->idx + 1);
else
- str_format_26adic (idx + 1, false, text, sizeof text);
- return pivot_value_new_user_text (text, -1);
+ {
+ char text[INT_BUFSIZE_BOUND (size_t)];
+ str_format_26adic (f->idx + 1, false, text, sizeof text);
+ ds_put_cstr (s, text);
+ }
+}
+
+char *
+pivot_footnote_marker_string (const struct pivot_footnote *f,
+ const struct pivot_table *pt)
+{
+ struct string s = DS_EMPTY_INITIALIZER;
+ pivot_footnote_format_marker (f, pt, &s);
+ return ds_steal_cstr (&s);
}
/* Creates or modifies a footnote in TABLE with 0-based number IDX (and creates
while (idx >= table->n_footnotes)
{
struct pivot_footnote *f = xmalloc (sizeof *f);
- f->idx = table->n_footnotes;
- f->marker = pivot_make_default_footnote_marker (
- f->idx, table->look->show_numeric_markers);
- f->content = NULL;
- f->show = true;
-
+ *f = (struct pivot_footnote) {
+ .idx = table->n_footnotes,
+ .show = true,
+ };
table->footnotes[table->n_footnotes++] = f;
}
}
size_t idx = value->footnote_indexes[i];
const struct pivot_footnote *f = pt->footnotes[idx];
- pivot_value_format (f->marker, pt, out);
+ pivot_footnote_format_marker (f, pt, out);
ds_put_byte (out, ']');
}
struct pivot_table *, size_t idx,
struct pivot_value *marker, struct pivot_value *content);
+void pivot_footnote_format_marker (const struct pivot_footnote *,
+ const struct pivot_table *,
+ struct string *);
+char *pivot_footnote_marker_string (const struct pivot_footnote *,
+ const struct pivot_table *);
+
void pivot_footnote_destroy (struct pivot_footnote *);
/* Internals. */
for (size_t i = 0; i < n_footnotes; i++)
{
const struct pivot_footnote *f = pt->footnotes[footnote_indexes[i]];
- char *marker = pivot_value_to_string (f->marker, pt);
+ char *marker = pivot_footnote_marker_string (f, pt);
tex_escape_string (tex, marker, true);
free (marker);
}
for (int i = 0; i < n_footnotes; ++i)
{
- char *marker = pivot_value_to_string (footnotes[i]->marker, pt);
+ char *marker = pivot_footnote_marker_string (footnotes[i], pt);
char *content = pivot_value_to_string (footnotes[i]->content, pt);
shipout (&tex->token_list, "$^{");