+ struct cell_color color;
+ const char *css = border_to_css (
+ table_get_rule (table, axis, cell->d[H][h], cell->d[V][v], &color));
+ if (css)
+ {
+ next_style (style);
+ fprintf (style->file, "border-%s: %s", border_name, css);
+
+ char buf[32];
+ if (format_color (color, (struct cell_color) CELL_COLOR_BLACK,
+ buf, sizeof buf))
+ fprintf (style->file, " %s", buf);
+ }
+}
+
+static void
+html_put_table_cell (struct html_driver *html, const struct pivot_table *pt,
+ const struct table_cell *cell,
+ const char *tag, const struct table *t)
+{
+ fprintf (html->file, "<%s", tag);
+
+ struct css_style style;
+ style_start (&style, html->file);
+
+ struct string body = DS_EMPTY_INITIALIZER;
+ bool numeric = pivot_value_format_body (cell->value, pt, &body);
+
+ enum table_halign halign = table_halign_interpret (cell->cell_style->halign,
+ numeric);
+
+ switch (halign)
+ {
+ case TABLE_HALIGN_RIGHT:
+ put_style (&style, "text-align", "right");
+ break;
+ case TABLE_HALIGN_CENTER:
+ put_style (&style, "text-align", "center");
+ break;
+ default:
+ /* Do nothing */
+ break;
+ }
+
+ if (cell->options & TAB_ROTATE)
+ put_style (&style, "writing-mode", "sideways-lr");
+
+ if (cell->cell_style->valign != TABLE_VALIGN_TOP)
+ {
+ put_style (&style, "vertical-align",
+ (cell->cell_style->valign == TABLE_VALIGN_BOTTOM
+ ? "bottom" : "middle"));
+ }
+
+ const struct font_style *fs = cell->font_style;
+ char bgcolor[32];
+ if (format_color (fs->bg[cell->d[V][0] % 2],
+ (struct cell_color) CELL_COLOR_WHITE,
+ bgcolor, sizeof bgcolor))
+ put_style (&style, "background", bgcolor);
+
+ char fgcolor[32];
+ if (format_color (fs->fg[cell->d[V][0] % 2],
+ (struct cell_color) CELL_COLOR_BLACK,
+ fgcolor, sizeof fgcolor))
+ put_style (&style, "color", fgcolor);
+
+ if (fs->typeface)
+ {
+ put_style (&style, "font-family", "\"");
+ escape_string (html->file, fs->typeface, " ", "\n");
+ putc ('"', html->file);
+ }
+ if (fs->bold)
+ put_style (&style, "font-weight", "bold");
+ if (fs->italic)
+ put_style (&style, "font-style", "italic");
+ if (fs->underline)
+ put_style (&style, "text-decoration", "underline");
+ if (fs->size)
+ {
+ char buf[32];
+ snprintf (buf, sizeof buf, "%dpt", fs->size);
+ put_style (&style, "font-size", buf);
+ }
+
+ if (t && html->borders)
+ {
+ put_border (t, cell, &style, V, 0, 0, "top");
+ put_border (t, cell, &style, H, 0, 0, "left");
+
+ if (cell->d[V][1] == t->n[V])
+ put_border (t, cell, &style, V, 0, 1, "bottom");
+ if (cell->d[H][1] == t->n[H])
+ put_border (t, cell, &style, H, 1, 0, "right");
+ }
+ style_end (&style);
+
+ int colspan = table_cell_colspan (cell);
+ if (colspan > 1)
+ fprintf (html->file, " colspan=\"%d\"", colspan);
+
+ int rowspan = table_cell_rowspan (cell);
+ if (rowspan > 1)
+ fprintf (html->file, " rowspan=\"%d\"", rowspan);
+
+ putc ('>', html->file);
+
+ const char *s = ds_cstr (&body);
+ s += strspn (s, CC_SPACES);
+ escape_string (html->file, s, " ", "<br>");
+ ds_destroy (&body);