int *width, int *height, int *brk);
static void
-xr_set_source_rgba (cairo_t *cairo, const struct cell_color *color)
+xr_set_source_rgba (cairo_t *cairo, const struct cell_color color)
{
cairo_set_source_rgba (cairo,
- color->r / 255., color->g / 255., color->b / 255.,
- color->alpha / 255.);
+ color.r / 255., color.g / 255., color.b / 255.,
+ color.alpha / 255.);
}
static void
xr_draw_line (struct xr_fsm *xr, int x0, int y0, int x1, int y1, int style,
- const struct cell_color *color)
+ const struct cell_color color)
{
cairo_new_path (xr->cairo);
cairo_set_line_width (
xr->cairo,
- xr_to_pt (style == RENDER_LINE_THICK ? XR_LINE_WIDTH * 2
- : style == RENDER_LINE_THIN ? XR_LINE_WIDTH / 2
+ xr_to_pt (style == TABLE_STROKE_THICK ? XR_LINE_WIDTH * 2
+ : style == TABLE_STROKE_THIN ? XR_LINE_WIDTH / 2
: XR_LINE_WIDTH));
cairo_move_to (xr->cairo, xr_to_pt (x0), xr_to_pt (y0));
cairo_line_to (xr->cairo, xr_to_pt (x1), xr_to_pt (y1));
if (!xr->style->use_system_colors)
xr_set_source_rgba (xr->cairo, color);
- if (style == RENDER_LINE_DASHED)
+ if (style == TABLE_STROKE_DASHED)
cairo_set_dash (xr->cairo, (double[]) { 2 }, 1, 0);
cairo_stroke (xr->cairo);
- if (style == RENDER_LINE_DASHED)
+ if (style == TABLE_STROKE_DASHED)
cairo_set_dash (xr->cairo, NULL, 0, 0);
}
shortening it to X2...X3 if SHORTEN is true. */
static void
xr_draw_horz_line (struct xr_fsm *xr, int x0, int x1, int x2, int x3, int y,
- enum render_line_style left, enum render_line_style right,
- const struct cell_color *left_color,
- const struct cell_color *right_color,
+ enum table_stroke left, enum table_stroke right,
+ const struct cell_color left_color,
+ const struct cell_color right_color,
bool shorten)
{
- if (left != RENDER_LINE_NONE && right != RENDER_LINE_NONE && !shorten
+ if (left != TABLE_STROKE_NONE && right != TABLE_STROKE_NONE && !shorten
&& cell_color_equal (left_color, right_color))
xr_draw_line (xr, x0, y, x3, y, left, left_color);
else
{
- if (left != RENDER_LINE_NONE)
+ if (left != TABLE_STROKE_NONE)
xr_draw_line (xr, x0, y, shorten ? x1 : x2, y, left, left_color);
- if (right != RENDER_LINE_NONE)
+ if (right != TABLE_STROKE_NONE)
xr_draw_line (xr, shorten ? x2 : x1, y, x3, y, right, right_color);
}
}
shortening it to Y2...Y3 if SHORTEN is true. */
static void
xr_draw_vert_line (struct xr_fsm *xr, int y0, int y1, int y2, int y3, int x,
- enum render_line_style top, enum render_line_style bottom,
- const struct cell_color *top_color,
- const struct cell_color *bottom_color,
+ enum table_stroke top, enum table_stroke bottom,
+ const struct cell_color top_color,
+ const struct cell_color bottom_color,
bool shorten)
{
- if (top != RENDER_LINE_NONE && bottom != RENDER_LINE_NONE && !shorten
+ if (top != TABLE_STROKE_NONE && bottom != TABLE_STROKE_NONE && !shorten
&& cell_color_equal (top_color, bottom_color))
xr_draw_line (xr, x, y0, x, y3, top, top_color);
else
{
- if (top != RENDER_LINE_NONE)
+ if (top != TABLE_STROKE_NONE)
xr_draw_line (xr, x, y0, x, shorten ? y1 : y2, top, top_color);
- if (bottom != RENDER_LINE_NONE)
+ if (bottom != TABLE_STROKE_NONE)
xr_draw_line (xr, x, shorten ? y2 : y1, x, y3, bottom, bottom_color);
}
}
static void
xrr_draw_line (void *xr_, int bb[TABLE_N_AXES][2],
- enum render_line_style styles[TABLE_N_AXES][2],
- struct cell_color colors[TABLE_N_AXES][2])
+ const struct table_border_style styles[TABLE_N_AXES][2])
{
const int x0 = bb[H][0];
const int y0 = bb[V][0];
const int x3 = bb[H][1];
const int y3 = bb[V][1];
- const int top = styles[H][0];
- const int bottom = styles[H][1];
+ const enum table_stroke top = styles[H][0].stroke;
+ const enum table_stroke bottom = styles[H][1].stroke;
int start_side = render_direction_rtl();
int end_side = !start_side;
- const int start_of_line = styles[V][start_side];
- const int end_of_line = styles[V][end_side];
- const struct cell_color *top_color = &colors[H][0];
- const struct cell_color *bottom_color = &colors[H][1];
- const struct cell_color *start_color = &colors[V][start_side];
- const struct cell_color *end_color = &colors[V][end_side];
+ const int start_of_line = styles[V][start_side].stroke;
+ const int end_of_line = styles[V][end_side].stroke;
+ const struct cell_color top_color = styles[H][0].color;
+ const struct cell_color bottom_color = styles[H][1].color;
+ const struct cell_color start_color = styles[V][start_side].color;
+ const struct cell_color end_color = styles[V][end_side].color;
/* The algorithm here is somewhat subtle, to allow it to handle
all the kinds of intersections that we need.
/* Are the lines along each axis single or double?
(It doesn't make sense to have different kinds of line on the
same axis, so we don't try to gracefully handle that case.) */
- bool double_vert = top == RENDER_LINE_DOUBLE || bottom == RENDER_LINE_DOUBLE;
- bool double_horz = start_of_line == RENDER_LINE_DOUBLE || end_of_line == RENDER_LINE_DOUBLE;
+ bool double_vert = top == TABLE_STROKE_DOUBLE || bottom == TABLE_STROKE_DOUBLE;
+ bool double_horz = start_of_line == TABLE_STROKE_DOUBLE || end_of_line == TABLE_STROKE_DOUBLE;
/* When horizontal lines are doubled,
the left-side line along y1 normally runs from x0 to x2,
single. We actually choose to cut off the line anyhow, as
shown in the first diagram above.
*/
- bool shorten_y1_lines = top == RENDER_LINE_DOUBLE;
- bool shorten_y2_lines = bottom == RENDER_LINE_DOUBLE;
+ bool shorten_y1_lines = top == TABLE_STROKE_DOUBLE;
+ bool shorten_y2_lines = bottom == TABLE_STROKE_DOUBLE;
bool shorten_yc_line = shorten_y1_lines && shorten_y2_lines;
int horz_line_ofs = double_vert ? double_line_ofs : 0;
int xc = (x0 + x3) / 2;
int x1 = xc - horz_line_ofs;
int x2 = xc + horz_line_ofs;
- bool shorten_x1_lines = start_of_line == RENDER_LINE_DOUBLE;
- bool shorten_x2_lines = end_of_line == RENDER_LINE_DOUBLE;
+ bool shorten_x1_lines = start_of_line == TABLE_STROKE_DOUBLE;
+ bool shorten_x2_lines = end_of_line == TABLE_STROKE_DOUBLE;
bool shorten_xc_line = shorten_x1_lines && shorten_x2_lines;
int vert_line_ofs = double_horz ? double_line_ofs : 0;
int yc = (y0 + y3) / 2;
struct xr_fsm *xr = xr_;
int w, h, brk;
- const struct cell_color *bg = &cell->font_style->bg[color_idx];
- if ((bg->r != 255 || bg->g != 255 || bg->b != 255) && bg->alpha)
+ const struct cell_color bg = cell->font_style->bg[color_idx];
+ if ((bg.r != 255 || bg.g != 255 || bg.b != 255) && bg.alpha)
{
cairo_save (xr->cairo);
int bg_clip[TABLE_N_AXES][2];
}
cairo_save (xr->cairo);
if (!xr->style->use_system_colors)
- xr_set_source_rgba (xr->cairo, &cell->font_style->fg[color_idx]);
+ xr_set_source_rgba (xr->cairo, cell->font_style->fg[color_idx]);
bb[V][0] += valign_offset;
const struct cell_style *cell_style = cell->cell_style;
unsigned int options = cell->options;
- enum table_axis X = options & TAB_ROTATE ? V : H;
+ enum table_axis X = options & TABLE_CELL_ROTATE ? V : H;
enum table_axis Y = !X;
- int R = options & TAB_ROTATE ? 0 : 1;
+ int R = options & TABLE_CELL_ROTATE ? 0 : 1;
PangoFontDescription *desc = NULL;
if (font_style->typeface)
cell->cell_style->halign, numeric);
if (cell_style->halign == TABLE_HALIGN_DECIMAL
- && !(cell->options & TAB_ROTATE))
+ && !(cell->options & TABLE_CELL_ROTATE))
{
int margin_adjustment = -px_to_xr (cell_style->decimal_offset);
/* XXX should we report the error? */
}
}
- else if (options & TAB_ROTATE || bb[H][1] != INT_MAX)
+ else if (options & TABLE_CELL_ROTATE || bb[H][1] != INT_MAX)
{
const char *text = ds_cstr (&body);
const char *decimal = text + strcspn (text, ".,");
PANGO_UNDERLINE_SINGLE));
}
- const struct pivot_value *value = cell->value;
- if (value->n_footnotes || value->n_subscripts)
+ const struct pivot_value_ex *ex = pivot_value_ex (cell->value);
+ if (ex->n_footnotes || ex->n_subscripts)
{
size_t subscript_ofs = ds_length (&body);
- for (size_t i = 0; i < value->n_subscripts; i++)
+ for (size_t i = 0; i < ex->n_subscripts; i++)
{
if (i)
ds_put_byte (&body, ',');
- ds_put_cstr (&body, value->subscripts[i]);
+ ds_put_cstr (&body, ex->subscripts[i]);
}
size_t footnote_ofs = ds_length (&body);
size_t n_footnotes = 0;
- for (size_t i = 0; i < value->n_footnotes; i++)
+ for (size_t i = 0; i < ex->n_footnotes; i++)
{
const struct pivot_footnote *f
- = pt->footnotes[value->footnote_indexes[i]];
+ = pt->footnotes[ex->footnote_indexes[i]];
if (f->show)
{
if (n_footnotes++)
/* Allow footnote markers to occupy the right margin. That way, numbers
in the column are still aligned. */
- if (value->n_footnotes && halign == TABLE_HALIGN_RIGHT)
+ if (ex->n_footnotes && halign == TABLE_HALIGN_RIGHT)
{
/* Measure the width of the footnote marker, so we know how much we
need to make room for. */
int footnote_adjustment = MIN (footnote_width, right_margin);
/* Adjust the bounding box. */
- if (options & TAB_ROTATE)
+ if (options & TABLE_CELL_ROTATE)
footnote_adjustment = -footnote_adjustment;
bb[X][R] += footnote_adjustment;
PANGO_ATTR_INDEX_TO_TEXT_END);
add_attr (attrs, pango_attr_scale_new (PANGO_SCALE_SMALL),
subscript_ofs, PANGO_ATTR_INDEX_TO_TEXT_END);
- if (value->n_subscripts)
+ if (ex->n_subscripts)
add_attr (attrs, pango_attr_rise_new (-3000), subscript_ofs,
footnote_ofs - subscript_ofs);
- if (value->n_footnotes)
+ if (ex->n_footnotes)
{
bool superscript = pt->look->footnote_marker_superscripts;
add_attr (attrs, pango_attr_rise_new (superscript ? 3000 : -3000),
if (clip[H][0] != clip[H][1])
{
cairo_save (xr->cairo);
- if (!(options & TAB_ROTATE))
+ if (!(options & TABLE_CELL_ROTATE))
xr_clip (xr, clip);
- if (options & TAB_ROTATE)
+ if (options & TABLE_CELL_ROTATE)
{
int extra = bb[H][1] - bb[H][0] - size[V];
int halign_offset = extra > 0 ? extra / 2 : 0;
int h = pango_to_xr (size[Y]);
if (w > *widthp)
*widthp = w;
- if (bb[V][0] + h >= bb[V][1] && !(options & TAB_ROTATE))
+ if (bb[V][0] + h >= bb[V][1] && !(options & TABLE_CELL_ROTATE))
{
PangoLayoutIter *iter;
int best = 0;
if (best)
xr_draw_line (xr, 0, best,
xr->style->size[H], best,
- RENDER_LINE_SINGLE,
- &(struct cell_color) CELL_COLOR (0, 255, 0));
+ TABLE_STROKE_SOLID,
+ (struct cell_color) CELL_COLOR (0, 255, 0));
}
}
item = output_item_ref (item_);
break;
- case OUTPUT_ITEM_GROUP_OPEN:
- case OUTPUT_ITEM_GROUP_CLOSE:
- case OUTPUT_ITEM_PAGE_SETUP:
+ case OUTPUT_ITEM_GROUP:
return NULL;
case OUTPUT_ITEM_MESSAGE:
};
enum { LW = XR_LINE_WIDTH, LS = XR_LINE_SPACE };
- static const int xr_line_widths[RENDER_N_LINES] =
+ static const int xr_line_widths[TABLE_N_STROKES] =
{
- [RENDER_LINE_NONE] = 0,
- [RENDER_LINE_SINGLE] = LW,
- [RENDER_LINE_DASHED] = LW,
- [RENDER_LINE_THICK] = LW * 2,
- [RENDER_LINE_THIN] = LW / 2,
- [RENDER_LINE_DOUBLE] = 2 * LW + LS,
+ [TABLE_STROKE_NONE] = 0,
+ [TABLE_STROKE_SOLID] = LW,
+ [TABLE_STROKE_DASHED] = LW,
+ [TABLE_STROKE_THICK] = LW * 2,
+ [TABLE_STROKE_THIN] = LW / 2,
+ [TABLE_STROKE_DOUBLE] = 2 * LW + LS,
};
struct xr_fsm *fsm = xmalloc (sizeof *fsm);
fsm->cairo = NULL;
break;
- case OUTPUT_ITEM_GROUP_OPEN:
- case OUTPUT_ITEM_GROUP_CLOSE:
+ case OUTPUT_ITEM_GROUP:
case OUTPUT_ITEM_MESSAGE:
case OUTPUT_ITEM_PAGE_BREAK:
- case OUTPUT_ITEM_PAGE_SETUP:
case OUTPUT_ITEM_TEXT:
default:
NOT_REACHED ();
fsm->cairo = NULL;
break;
- case OUTPUT_ITEM_GROUP_OPEN:
- case OUTPUT_ITEM_GROUP_CLOSE:
+ case OUTPUT_ITEM_GROUP:
case OUTPUT_ITEM_MESSAGE:
case OUTPUT_ITEM_PAGE_BREAK:
- case OUTPUT_ITEM_PAGE_SETUP:
case OUTPUT_ITEM_TEXT:
NOT_REACHED ();
}
used = xr_fsm_draw_table (fsm, space);
break;
- case OUTPUT_ITEM_GROUP_OPEN:
- case OUTPUT_ITEM_GROUP_CLOSE:
+ case OUTPUT_ITEM_GROUP:
case OUTPUT_ITEM_MESSAGE:
- case OUTPUT_ITEM_PAGE_SETUP:
case OUTPUT_ITEM_TEXT:
default:
NOT_REACHED ();