work
[pspp] / src / output / cairo.c
index 975779bfa99f9555236dc292214bd553d874b283..80bca382a7f3159a9b8561e9ab54695c416ed431 100644 (file)
@@ -43,6 +43,7 @@
 #include "output/message-item.h"
 #include "output/options.h"
 #include "output/page-setup-item.h"
+#include "output/pivot-table.h"
 #include "output/render.h"
 #include "output/table-item.h"
 #include "output/table.h"
@@ -1483,7 +1484,7 @@ xr_layout_cell_text (struct xr_driver *xr, const struct table_cell *cell,
             dump_line (xr, -xr->left_margin, best,
                        xr->width + xr->right_margin, best,
                        RENDER_LINE_SINGLE,
-                       &CELL_COLOR (0, 255, 0));
+                       &(struct cell_color) CELL_COLOR (0, 255, 0));
         }
     }
 
@@ -1582,12 +1583,11 @@ xr_driver_destroy (struct xr_driver *xr)
 static struct xr_rendering *
 xr_rendering_create_text (struct xr_driver *xr, const char *text, cairo_t *cr)
 {
-  struct table_item *table_item;
-  struct xr_rendering *r;
-
-  table_item = table_item_create (table_from_string (TABLE_HALIGN_LEFT, text),
-                                  NULL, NULL);
-  r = xr_rendering_create (xr, &table_item->output_item, cr);
+  struct pivot_table *pt = pivot_table_create_for_text (
+    NULL, pivot_value_new_user_text (text, -1));
+  struct table_item *table_item = table_item_create (pt);
+  struct xr_rendering *r = xr_rendering_create (xr, &table_item->output_item,
+                                                cr);
   table_item_unref (table_item);
 
   return r;
@@ -1648,18 +1648,25 @@ xr_rendering_destroy (struct xr_rendering *r)
 }
 
 void
-xr_rendering_measure (struct xr_rendering *r, int *w, int *h)
+xr_rendering_measure (struct xr_rendering *r, int *wp, int *hp)
 {
+  int w, h;
+
   if (is_table_item (r->item))
     {
-      *w = render_pager_get_size (r->p, H) / XR_POINT;
-      *h = render_pager_get_size (r->p, V) / XR_POINT;
+      w = render_pager_get_size (r->p, H) / XR_POINT;
+      h = render_pager_get_size (r->p, V) / XR_POINT;
     }
   else
     {
-      *w = CHART_WIDTH;
-      *h = CHART_HEIGHT;
+      w = CHART_WIDTH;
+      h = CHART_HEIGHT;
     }
+
+  if (wp)
+    *wp = w;
+  if (hp)
+    *hp = h;
 }
 
 static void xr_draw_chart (const struct chart_item *, cairo_t *,