From 7720f4e8ad3d3835720e707f9eeed099118b036d Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Tue, 26 Oct 2010 21:53:53 -0700 Subject: [PATCH] cairo: Always save output item in xr_rendering_create(). Currently xr_rendering_create() only saves the output item passed in if it is a chart. However an upcoming commit will have a need for table output items too, so this commit always saves them. --- src/output/cairo.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/output/cairo.c b/src/output/cairo.c index 5a310c61..e15acbb7 100644 --- a/src/output/cairo.c +++ b/src/output/cairo.c @@ -857,13 +857,12 @@ static const struct output_driver_class cairo_driver_class = struct xr_rendering { + struct output_item *item; + /* Table items. */ struct render_page *page; struct xr_driver *xr; int title_height; - - /* Chart items. */ - struct chart_item *chart; }; #define CHART_WIDTH 500 @@ -926,6 +925,7 @@ xr_rendering_create (struct xr_driver *xr, const struct output_item *item, else if (is_table_item (item)) { r = xzalloc (sizeof *r); + r->item = output_item_ref (item); r->xr = xr; xr_set_cairo (xr, cr); r->page = xr_render_table_item (xr, to_table_item (item), @@ -934,7 +934,7 @@ xr_rendering_create (struct xr_driver *xr, const struct output_item *item, else if (is_chart_item (item)) { r = xzalloc (sizeof *r); - r->chart = to_chart_item (output_item_ref (item)); + r->item = output_item_ref (item); } return r; @@ -943,7 +943,7 @@ xr_rendering_create (struct xr_driver *xr, const struct output_item *item, void xr_rendering_measure (struct xr_rendering *r, int *w, int *h) { - if (r->chart == NULL) + if (is_table_item (r->item)) { *w = render_page_get_size (r->page, H) / 1024; *h = (render_page_get_size (r->page, V) + r->title_height) / 1024; @@ -961,7 +961,7 @@ void xr_rendering_draw (struct xr_rendering *r, cairo_t *cr, int x, int y, int w, int h) { - if (r->chart == NULL) + if (is_table_item (r->item)) { struct xr_driver *xr = r->xr; @@ -971,7 +971,8 @@ xr_rendering_draw (struct xr_rendering *r, cairo_t *cr, x * 1024, y * 1024, w * 1024, h * 1024); } else - xr_draw_chart (r->chart, cr, 0, 0, CHART_WIDTH, CHART_HEIGHT); + xr_draw_chart (to_chart_item (r->item), cr, + 0, 0, CHART_WIDTH, CHART_HEIGHT); } void -- 2.30.2