cairo: Always save output item in xr_rendering_create().
[pspp-builds.git] / src / output / cairo.c
index d4f31aad6a011f2459f941353c7e8f1a64ca8e4c..e15acbb7aa0f3029671f72137654082d6bf391ca 100644 (file)
@@ -190,7 +190,7 @@ parse_font (struct output_driver *d, struct string_map *options,
   desc = pango_font_description_from_string (string);
   if (desc == NULL)
     {
-      error (0, 0, _("\"%s\": bad font specification"), string);
+      error (0, 0, _("`%s': bad font specification"), string);
 
       /* Fall back to DEFAULT_VALUE, which had better be a valid font
          description. */
@@ -354,7 +354,7 @@ xr_create (const char *file_name, enum settings_output_devices device_type,
   status = cairo_surface_status (surface);
   if (status != CAIRO_STATUS_SUCCESS)
     {
-      error (0, 0, _("error opening output file \"%s\": %s"),
+      error (0, 0, _("error opening output file `%s': %s"),
              file_name, cairo_status_to_string (status));
       cairo_surface_destroy (surface);
       goto error;
@@ -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
@@ -1038,7 +1039,7 @@ xr_draw_png_chart (const struct chart_item *item,
 
   status = cairo_surface_write_to_png (surface, file_name);
   if (status != CAIRO_STATUS_SUCCESS)
-    error (0, 0, _("error writing output file \"%s\": %s"),
+    error (0, 0, _("error writing output file `%s': %s"),
            file_name, cairo_status_to_string (status));
 
   cairo_destroy (cr);