[goffice] Really implement canvas item transforms.



commit 28b17bebe89d7a5b9c1b1dced32c16573337b004
Author: Jean Brefort <jean brefort normalesup org>
Date:   Tue Mar 19 09:13:56 2013 +0100

    Really implement canvas item transforms.

 ChangeLog                      |   28 +++++++++++++++++
 goffice/canvas/goc-arc.c       |    1 +
 goffice/canvas/goc-canvas.c    |    2 +-
 goffice/canvas/goc-circle.c    |    2 +
 goffice/canvas/goc-component.c |   64 ++++++++++++++++++++++++++--------------
 goffice/canvas/goc-ellipse.c   |    3 +-
 goffice/canvas/goc-group.c     |    1 -
 goffice/canvas/goc-image.c     |    1 +
 goffice/canvas/goc-item.c      |   23 ++++++++++----
 goffice/canvas/goc-item.h      |    3 +-
 goffice/canvas/goc-line.c      |    2 +
 goffice/canvas/goc-path.c      |    1 +
 goffice/canvas/goc-pixbuf.c    |   22 ++++++++++---
 goffice/canvas/goc-polygon.c   |    3 ++
 goffice/canvas/goc-polyline.c  |    1 +
 goffice/canvas/goc-rectangle.c |    3 +-
 goffice/canvas/goc-text.c      |    8 +++--
 goffice/gtk/go-font-sel.c      |    6 ++--
 goffice/utils/go-emf.c         |   16 ++++++++--
 19 files changed, 143 insertions(+), 47 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b35d90a..004d741 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,31 @@
+2013-03-19  Jean Brefort  <jean brefort normalesup org>
+
+       * goffice/canvas/goc-arc.c (goc_arc_prepare_draw): make item transform work.
+       * goffice/canvas/goc-canvas.c (button_press_cb): typo.
+       * goffice/canvas/goc-circle.c (goc_circle_draw),
+       (goc_circle_update_bounds): make item transform work.
+       * goffice/canvas/goc-component.c (goc_component_draw),
+       (goc_component_update_bounds): ditto.
+       * goffice/canvas/goc-ellipse.c (goc_ellipse_prepare_draw): ditto.
+       * goffice/canvas/goc-group.c (goc_group_cairo_transform): ditto.
+       * goffice/canvas/goc-image.c (goc_image_draw): ditto.
+       * goffice/canvas/goc-item.c (goc_item_draw),
+       (goc_item_draw_region), (_goc_item_transform): ditto.
+       * goffice/canvas/goc-item.h: ditto.
+       * goffice/canvas/goc-line.c (goc_line_update_bounds),
+       (goc_line_draw): ditto.
+       * goffice/canvas/goc-path.c (goc_path_prepare_draw):
+       * goffice/canvas/goc-pixbuf.c (goc_pixbuf_update_bounds),
+       (goc_pixbuf_draw): ditto.
+       * goffice/canvas/goc-polygon.c (goc_polygon_update_bounds),
+       (goc_polygon_draw): ditto.
+       * goffice/canvas/goc-polyline.c (goc_polyline_prepare_draw): ditto.
+       * goffice/canvas/goc-rectangle.c (goc_rectangle_prepare_draw): ditto.
+       * goffice/canvas/goc-text.c (goc_text_prepare_draw),
+       (goc_text_update_bounds), (goc_text_distance), (goc_text_draw): ditto.
+       * goffice/utils/go-emf.c (go_emf_movetoex), (go_emf_exttextoutw): start work
+       on text support.
+
 2013-03-18  Morten Welinder  <terra gnome org>
 
        * goffice/gtk/go-font-sel.c (reload_families): Add more observed.
diff --git a/goffice/canvas/goc-arc.c b/goffice/canvas/goc-arc.c
index bd1d5e8..8b3eee1 100644
--- a/goffice/canvas/goc-arc.c
+++ b/goffice/canvas/goc-arc.c
@@ -275,6 +275,7 @@ goc_arc_prepare_draw (GocItem const *item, cairo_t *cr, gboolean flag)
                return FALSE;
 
        cairo_save (cr);
+       _goc_item_transform (item, cr, flag);
        if (1 == flag) {
                goc_group_cairo_transform (item->parent, cr, arc->xc, arc->yc);
                sign = 1;
diff --git a/goffice/canvas/goc-canvas.c b/goffice/canvas/goc-canvas.c
index d6ed50d..10a1eac 100644
--- a/goffice/canvas/goc-canvas.c
+++ b/goffice/canvas/goc-canvas.c
@@ -97,7 +97,7 @@ button_press_cb (GocCanvas *canvas, GdkEventButton *event, G_GNUC_UNUSED gpointe
                canvas->scroll_x1 +  (canvas->width - event->x) / canvas->pixels_per_unit:
                canvas->scroll_x1 +  event->x / canvas->pixels_per_unit;
        y = canvas->scroll_y1 + event->y / canvas->pixels_per_unit;
-       item = goc_canvas_get_item_at (canvas, x, y);;
+       item = goc_canvas_get_item_at (canvas, x, y);
        if (item) {
                gboolean result;
                canvas->cur_event = (GdkEvent *) event;
diff --git a/goffice/canvas/goc-circle.c b/goffice/canvas/goc-circle.c
index d849142..9643ec8 100644
--- a/goffice/canvas/goc-circle.c
+++ b/goffice/canvas/goc-circle.c
@@ -111,6 +111,7 @@ goc_circle_draw (GocItem const *item, cairo_t *cr)
        double scale = (circle->radius > 0.)? circle->radius: 1.e-10;
 
        cairo_save (cr);
+       _goc_item_transform (item, cr, TRUE);
        goc_group_cairo_transform (item->parent, cr, circle->x, circle->y);
        cairo_scale (cr, scale, scale);
        cairo_arc (cr, 0., 0., 1., 0., 2 * M_PI);
@@ -130,6 +131,7 @@ goc_circle_update_bounds (GocItem *item)
        GocCircle *circle = GOC_CIRCLE (item);
        GOStyle *style = go_styled_object_get_style (GO_STYLED_OBJECT (item));
        double r = circle->radius;
+       /* FIXME take transform into account */
        if (style->line.dash_type != GO_LINE_NONE)
                r += (style->line.width)? style->line.width / 2.: .5;
        item->x0 = circle->x - r;
diff --git a/goffice/canvas/goc-component.c b/goffice/canvas/goc-component.c
index b01e127..9179642 100644
--- a/goffice/canvas/goc-component.c
+++ b/goffice/canvas/goc-component.c
@@ -210,49 +210,69 @@ goc_component_draw (GocItem const *item, cairo_t *cr)
        if (goc_canvas_get_direction (item->canvas) == GOC_DIRECTION_RTL) {
                x0 = component->x + component->w;
                goc_group_adjust_coords (item->parent, &x0, &y0);
-               x0 = canvas->width - (int) (x0 - canvas->scroll_x1) * canvas->pixels_per_unit;
+               x0 = canvas->width - (int) (x0 - canvas->scroll_x1);
        } else {
                x0 = component->x;
                goc_group_adjust_coords (item->parent, &x0, &y0);
-               x0 = (int) (x0 - canvas->scroll_x1) * canvas->pixels_per_unit;
+               x0 = (int) (x0 - canvas->scroll_x1);
        }
        cairo_save (cr);
+       _goc_item_transform (item, cr, TRUE);
        if (component->rotation == 0.)
                cairo_translate (cr, x0,
-                                (int) (y0 - canvas->scroll_y1) * canvas->pixels_per_unit);
+                                (int) (y0 - canvas->scroll_y1));
        else {
-               cairo_translate (cr, x0 + component->w / 2 * canvas->pixels_per_unit,
-                                (int) (y0 - canvas->scroll_y1 + component->h / 2) * canvas->pixels_per_unit);
+               cairo_translate (cr, x0 + component->w / 2,
+                                (int) (y0 - canvas->scroll_y1 + component->h / 2));
                cairo_rotate (cr, -component->rotation);
-               cairo_translate (cr, -component->w / 2 * canvas->pixels_per_unit,
-                                -component->h / 2 * canvas->pixels_per_unit);
+               cairo_translate (cr, -component->w / 2, -component->h / 2);
        }
-       cairo_rectangle (cr, 0., 0., component->w * canvas->pixels_per_unit,
-                            component->h * canvas->pixels_per_unit);
+       cairo_rectangle (cr, 0., 0., component->w,
+                            component->h);
        cairo_clip (cr);
        go_component_render (component->component, cr,
-                            component->w * canvas->pixels_per_unit,
-                            component->h * canvas->pixels_per_unit);
+                            component->w,
+                            component->h);
        cairo_restore (cr);
 }
 
 static void
 goc_component_update_bounds (GocItem *item)
 {
+       cairo_surface_t *surface;
+       cairo_t *cr;
        GocComponent *component = GOC_COMPONENT (item);
-       if (component->rotation == 0.) {
-               item->x0 = component->x;
-               item->y0 = component->y;
-               item->x1 = component->x + component->w;
-               item->y1 = component->y + component->h;
+       double x0, y0 = component->y;
+       GocCanvas *canvas = item->canvas;
+
+       if (goc_canvas_get_direction (item->canvas) == GOC_DIRECTION_RTL) {
+               x0 = component->x + component->w;
+               goc_group_adjust_coords (item->parent, &x0, &y0);
+               x0 = canvas->width - (int) (x0 - canvas->scroll_x1) * canvas->pixels_per_unit;
        } else {
-               double cosr = cos (component->rotation), sinr = sin (component->rotation);
-               double w = fabs (component->w * cosr) + fabs (component->h * sinr), h = fabs (component->h * 
cosr) + fabs (component->w * sinr);
-               item->x0 = component->x + (component->w - w) / 2.;
-               item->x1 = item->x0 + w;
-               item->y0 = component->y + (component->h - h) / 2.;
-               item->y1 = item->y0 + h;
+               x0 = component->x;
+               goc_group_adjust_coords (item->parent, &x0, &y0);
+               x0 = (int) (x0 - canvas->scroll_x1) * canvas->pixels_per_unit;
        }
+       surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
+       cr = cairo_create (surface);
+       _goc_item_transform (item, cr, FALSE);
+       if (component->rotation == 0.)
+               cairo_translate (cr, x0,
+                                (int) (y0 - canvas->scroll_y1));
+       else {
+               cairo_translate (cr, x0 + component->w / 2,
+                                (int) (y0 - canvas->scroll_y1 + component->h / 2));
+               cairo_rotate (cr, -component->rotation);
+               cairo_translate (cr, -component->w / 2,
+                                -component->h / 2);
+       }
+       cairo_rectangle (cr, 0., 0., component->w,
+                            component->h);
+       cairo_fill_extents (cr, &item->x0, &item->y0, &item->x1, &item->y1);
+
+       cairo_destroy (cr);
+       cairo_surface_destroy (surface);
 }
 
 static void
diff --git a/goffice/canvas/goc-ellipse.c b/goffice/canvas/goc-ellipse.c
index 5bc5bdd..269463a 100644
--- a/goffice/canvas/goc-ellipse.c
+++ b/goffice/canvas/goc-ellipse.c
@@ -115,7 +115,8 @@ goc_ellipse_prepare_draw (GocItem const *item, cairo_t *cr, gboolean flag)
        if (0 == ellipse->width && 0 == ellipse->height)
                return FALSE;
 
-       cairo_save(cr);
+       cairo_save (cr);
+       _goc_item_transform (item, cr, flag);
        if (1 == flag) {
                goc_group_cairo_transform (item->parent, cr, ellipse->x + ellipse->width/2., ellipse->y + 
ellipse->height/2.);
        } else {
diff --git a/goffice/canvas/goc-group.c b/goffice/canvas/goc-group.c
index 5452014..fcbe086 100644
--- a/goffice/canvas/goc-group.c
+++ b/goffice/canvas/goc-group.c
@@ -448,7 +448,6 @@ goc_group_cairo_transform (GocGroup const *group, cairo_t *cr, double x, double
                goc_group_cairo_transform (parent, cr, x + group->x, y + group->y);
        else {
                GocCanvas *canvas = GOC_ITEM (group)->canvas;
-               cairo_scale (cr, canvas->pixels_per_unit, canvas->pixels_per_unit);
                if (canvas->direction == GOC_DIRECTION_RTL)
                        cairo_translate (cr, canvas->width / canvas->pixels_per_unit - (x - 
canvas->scroll_x1), y - canvas->scroll_y1);
                else
diff --git a/goffice/canvas/goc-image.c b/goffice/canvas/goc-image.c
index 9db8516..ce58977 100644
--- a/goffice/canvas/goc-image.c
+++ b/goffice/canvas/goc-image.c
@@ -234,6 +234,7 @@ goc_image_draw (GocItem const *item, cairo_t *cr)
                scaley = height / go_image_get_height (image->image) / (1 - image->crop_top 
-image->crop_bottom);
        }
        cairo_save (cr);
+       _goc_item_transform (item, cr, TRUE);
        x = (goc_canvas_get_direction (item->canvas) == GOC_DIRECTION_RTL)?
                image->x + image->width: image->x;
        goc_group_cairo_transform (item->parent, cr, x, (int) image->y);
diff --git a/goffice/canvas/goc-item.c b/goffice/canvas/goc-item.c
index 4659d9e..64beaf7 100644
--- a/goffice/canvas/goc-item.c
+++ b/goffice/canvas/goc-item.c
@@ -414,7 +414,11 @@ goc_item_draw (GocItem const *item, cairo_t *cr)
        GocItemClass *klass = GOC_ITEM_GET_CLASS (item);
        g_return_if_fail (klass != NULL);
 
-       if (klass->draw)
+       if (klass->draw == NULL)
+               return;
+       if (GOC_IS_GROUP (item))
+               klass->draw (item, cr);
+       else
                klass->draw (item, cr);
 }
 
@@ -441,8 +445,12 @@ goc_item_draw_region (GocItem const *item, cairo_t *cr,
        GocItemClass *klass = GOC_ITEM_GET_CLASS (item);
        g_return_val_if_fail (klass != NULL, FALSE);
 
-       return (klass->draw_region)?
-               klass->draw_region (item, cr, x0, y0, x1, y1): FALSE;
+       if (klass->draw_region == NULL)
+               return FALSE;
+       if (GOC_IS_GROUP (item))
+               return klass->draw_region (item, cr, x0, y0, x1, y1);
+       else
+               return klass->draw_region (item, cr, x0, y0, x1, y1);
 }
 
 static void
@@ -817,7 +825,7 @@ goc_item_set_transform (GocItem *item, cairo_matrix_t *m)
 }
 
 void
-_goc_item_transform (GocItem const *item, cairo_t *cr)
+_goc_item_transform (GocItem const *item, cairo_t *cr, gboolean scaled)
 {
        cairo_matrix_t m = item->transform, buf,
                sc = {item->canvas->pixels_per_unit, 0., 0., item->canvas->pixels_per_unit, 0., 0.};
@@ -826,6 +834,9 @@ _goc_item_transform (GocItem const *item, cairo_t *cr)
                        cairo_matrix_multiply (&buf, &m, &item->transform);
                        m = buf;
                }
-       cairo_matrix_multiply (&buf, &m, &sc);
-       cairo_set_matrix (cr, &buf);
+       if (scaled) {
+               cairo_matrix_multiply (&buf, &m, &sc);
+               m = buf;
+       }
+       cairo_transform (cr, &m);
 }
diff --git a/goffice/canvas/goc-item.h b/goffice/canvas/goc-item.h
index 4b2df64..e7f7590 100644
--- a/goffice/canvas/goc-item.h
+++ b/goffice/canvas/goc-item.h
@@ -110,7 +110,8 @@ void                 goc_item_lower_to_bottom (GocItem *item);
 void            goc_item_raise_to_top  (GocItem *item);
 void            _goc_item_realize      (GocItem *item);
 void            _goc_item_unrealize    (GocItem *item);
-void            _goc_item_transform    (GocItem const *item, cairo_t *cr);
+void            _goc_item_transform    (GocItem const *item, cairo_t *cr,
+                                            gboolean scaled);
 
 void            goc_item_set_operator  (GocItem *item, cairo_operator_t op);
 cairo_operator_t goc_item_get_operator  (GocItem *item);
diff --git a/goffice/canvas/goc-line.c b/goffice/canvas/goc-line.c
index 2bdefd1..174c41c 100644
--- a/goffice/canvas/goc-line.c
+++ b/goffice/canvas/goc-line.c
@@ -153,6 +153,7 @@ goc_line_update_bounds (GocItem *item)
        GocLine *line = GOC_LINE (item);
        GOStyle *style = go_styled_object_get_style (GO_STYLED_OBJECT (item));
        double extra_width = style->line.width /2.;
+       /* FIXME: take transform into account */
        if (extra_width <= 0.)
                extra_width = .5;
        if (style->line.cap == CAIRO_LINE_CAP_SQUARE)
@@ -273,6 +274,7 @@ goc_line_draw (GocItem const *item, cairo_t *cr)
                        hoffs = 0.;
 
        cairo_save (cr);
+       _goc_item_transform (item, cr, TRUE);
        goc_group_cairo_transform (item->parent, cr,
                                   hoffs + (int) line->startx,
                                   voffs + (int) line->starty);
diff --git a/goffice/canvas/goc-path.c b/goffice/canvas/goc-path.c
index 2003a4b..0d40ced 100644
--- a/goffice/canvas/goc-path.c
+++ b/goffice/canvas/goc-path.c
@@ -127,6 +127,7 @@ goc_path_prepare_draw (GocItem const *item, cairo_t *cr, gboolean flag)
        double rsign = sign;
 
        cairo_save (cr);
+       _goc_item_transform (item, cr, flag);
        if (1 == flag) {
                goc_group_cairo_transform (item->parent, cr, path->x , path->y);
                sign = 1;
diff --git a/goffice/canvas/goc-pixbuf.c b/goffice/canvas/goc-pixbuf.c
index 5c28ee1..2b8f391 100644
--- a/goffice/canvas/goc-pixbuf.c
+++ b/goffice/canvas/goc-pixbuf.c
@@ -134,13 +134,24 @@ static void
 goc_pixbuf_update_bounds (GocItem *item)
 {
        GocPixbuf *pixbuf = GOC_PIXBUF (item);
+       cairo_surface_t *surface;
+       cairo_t *cr;
+
        if (!pixbuf->pixbuf)
                return;
-       /* FIXME: take rotation into account */
-       item->x0 = floor (pixbuf->x);
-       item->y0 = floor (pixbuf->y);
-       item->x1 = ceil (pixbuf->x + ((pixbuf->width > 0.)? pixbuf->width: gdk_pixbuf_get_width 
(pixbuf->pixbuf)));
-       item->y1 = ceil (pixbuf->y + ((pixbuf->height > 0.)? pixbuf->height: gdk_pixbuf_get_height 
(pixbuf->pixbuf)));
+       surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
+       cr = cairo_create (surface);
+
+       cairo_save (cr);
+       _goc_item_transform (item, cr, FALSE);
+       cairo_rectangle (cr, pixbuf->x, pixbuf->y,
+                        ((pixbuf->width > 0.)? pixbuf->width: gdk_pixbuf_get_width (pixbuf->pixbuf)),
+                        ((pixbuf->height > 0.)? pixbuf->height: gdk_pixbuf_get_height (pixbuf->pixbuf)));
+       cairo_restore (cr);
+       cairo_fill_extents (cr, &item->x0, &item->y0, &item->x1, &item->y1);
+
+       cairo_destroy (cr);
+       cairo_surface_destroy (surface);
 }
 
 static double
@@ -197,6 +208,7 @@ goc_pixbuf_draw (GocItem const *item, cairo_t *cr)
                scaley = height / gdk_pixbuf_get_height (pixbuf->pixbuf);
        }
        cairo_save (cr);
+       _goc_item_transform (item, cr, TRUE);
        x = (goc_canvas_get_direction (item->canvas) == GOC_DIRECTION_RTL)?
                pixbuf->x + pixbuf->width: pixbuf->x;
        goc_group_cairo_transform (item->parent, cr, x, (int) pixbuf->y);
diff --git a/goffice/canvas/goc-polygon.c b/goffice/canvas/goc-polygon.c
index e30dec1..79f2b89 100644
--- a/goffice/canvas/goc-polygon.c
+++ b/goffice/canvas/goc-polygon.c
@@ -218,6 +218,8 @@ goc_polygon_update_bounds (GocItem *item)
 
        surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
        cr = cairo_create (surface);
+
+       _goc_item_transform (item, cr, FALSE);
        if (go_styled_object_set_cairo_line (GO_STYLED_OBJECT (item), cr))
                mode = 1;
        else if (go_style_is_fill_visible (go_styled_object_get_style (GO_STYLED_OBJECT (item))))
@@ -283,6 +285,7 @@ static void
 goc_polygon_draw (GocItem const *item, cairo_t *cr)
 {
        cairo_save (cr);
+       _goc_item_transform (item, cr, TRUE);
        if (goc_polygon_prepare_path (item, cr, 1)) {
                go_styled_object_fill (GO_STYLED_OBJECT (item), cr, TRUE);
 
diff --git a/goffice/canvas/goc-polyline.c b/goffice/canvas/goc-polyline.c
index 35dcaac..7738669 100644
--- a/goffice/canvas/goc-polyline.c
+++ b/goffice/canvas/goc-polyline.c
@@ -111,6 +111,7 @@ goc_polyline_prepare_draw (GocItem const *item, cairo_t *cr, gboolean flag)
        GocPolyline *polyline = GOC_POLYLINE (item);
        unsigned i;
 
+       _goc_item_transform (item, cr, flag);
        if (polyline->nb_points == 0)
                return FALSE;
 
diff --git a/goffice/canvas/goc-rectangle.c b/goffice/canvas/goc-rectangle.c
index 6e0e0a6..ae4ac37 100644
--- a/goffice/canvas/goc-rectangle.c
+++ b/goffice/canvas/goc-rectangle.c
@@ -143,7 +143,8 @@ goc_rectangle_prepare_draw (GocItem const *item, cairo_t *cr, gboolean flag)
        if (0 == rect->width && 0 == rect->height)
                return FALSE;
 
-       cairo_save(cr);
+       cairo_save (cr);
+       _goc_item_transform (item, cr, flag);
        if (1 == flag) {
                goc_group_cairo_transform (item->parent, cr, rect->x, rect->y);
        } else {
diff --git a/goffice/canvas/goc-text.c b/goffice/canvas/goc-text.c
index 580ba86..34a9ff7 100644
--- a/goffice/canvas/goc-text.c
+++ b/goffice/canvas/goc-text.c
@@ -253,7 +253,7 @@ goc_text_finalize (GObject *gobject)
 }
 
 static void
-goc_text_prepare_draw (GocItem *item, cairo_t *cr)
+goc_text_prepare_draw (GocItem *item, cairo_t *cr, gboolean flag)
 {
        GocText *text = GOC_TEXT (item);
        PangoRectangle rect;
@@ -304,6 +304,7 @@ goc_text_prepare_draw (GocItem *item, cairo_t *cr)
                break;
        }
        cairo_save (cr);
+       _goc_item_transform (item, cr, flag);
        cairo_translate (cr, item->x0, item->y0);
        cairo_rotate (cr, text->rotation * sign);
        if (text->clip_height > 0. && text->clip_width > 0.) {
@@ -326,7 +327,7 @@ goc_text_update_bounds (GocItem *item)
 
        surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
        cr = cairo_create (surface);
-       goc_text_prepare_draw (item, cr);
+       goc_text_prepare_draw (item, cr, FALSE);
        cairo_stroke_extents (cr, &item->x0, &item->y0, &item->x1, &item->y1);
        cairo_destroy (cr);
        cairo_surface_destroy (surface);
@@ -347,7 +348,7 @@ goc_text_distance (GocItem *item, double x, double y, GocItem **near_item)
 
        surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
        cr = cairo_create (surface);
-       goc_text_prepare_draw (item, cr);
+       goc_text_prepare_draw (item, cr, FALSE);
        if (cairo_in_fill (cr, x, y) || cairo_in_stroke (cr, x, y))
                res = 0;
        cairo_destroy (cr);
@@ -416,6 +417,7 @@ goc_text_draw (GocItem const *item, cairo_t *cr)
                break;
        }
        cairo_save (cr);
+       _goc_item_transform (item, cr, TRUE);
        cairo_set_source_rgb (cr, 0., 0., 0.);
        goc_group_cairo_transform (item->parent, cr, x, y);
        cairo_rotate (cr, text->rotation * sign);
diff --git a/goffice/gtk/go-font-sel.c b/goffice/gtk/go-font-sel.c
index 8731653..f9f0830 100644
--- a/goffice/gtk/go-font-sel.c
+++ b/goffice/gtk/go-font-sel.c
@@ -827,7 +827,7 @@ gfs_constructor (GType type,
        g_signal_connect (gfs->size_picker,
                          "changed",
                          G_CALLBACK (cb_size_picker_changed), gfs);
-       
+
        /* ---------------------------------------- */
 
        placeholder = go_gtk_builder_get_widget
@@ -835,7 +835,7 @@ gfs_constructor (GType type,
        if (!gfs->color_group)
                gfs->color_group = go_color_group_fetch (NULL, gfs);
        gfs->color_picker =
-               go_combo_color_new (NULL, "?", GO_COLOR_BLACK, 
+               go_combo_color_new (NULL, "?", GO_COLOR_BLACK,
                                    gfs->color_group);
        g_object_ref_sink (gfs->color_picker);
        gtk_widget_show_all (gfs->color_picker);
@@ -1257,7 +1257,7 @@ go_font_sel_set_family (GOFontSel *fs, char const *font_name)
 
 void
 go_font_sel_set_style (GOFontSel *fs, PangoWeight weight, PangoStyle style)
-{      
+{
        PangoFontFamily *family;
        int best_badness = G_MAXINT;
        PangoFontFace *best = NULL;
diff --git a/goffice/utils/go-emf.c b/goffice/utils/go-emf.c
index 5c6b3ea..17f595e 100644
--- a/goffice/utils/go-emf.c
+++ b/goffice/utils/go-emf.c
@@ -951,6 +951,7 @@ typedef struct {
        unsigned text_align;
        GOColor text_color;
        cairo_matrix_t m;
+       double xpos, ypos; /* current position used to emit text */
 } GOEmfDC;
 
 typedef struct {
@@ -3016,11 +3017,14 @@ go_emf_movetoex (GOEmfState *state)
 {
        double x, y;
        d_(("movetoex\n"));
-       if (state->curDC->path == NULL)
-               return FALSE;
        go_wmf_read_pointl (state->data, &x, &y);
        go_emf_convert_coords (state, &x, &y);
-       go_path_move_to (state->curDC->path, x, y);
+       if (state->curDC->path != NULL)
+               go_path_move_to (state->curDC->path, x, y);
+       else {
+               state->curDC->xpos = x;
+               state->curDC->ypos = y;
+       }
        d_(("\tMove to x=%g y=%g\n", x, y));
        return TRUE;
 }
@@ -4056,9 +4060,15 @@ static gboolean
 go_emf_exttextoutw (GOEmfState *state)
 {
        unsigned mode;
+       float xscale = 1., yscale = 1.;
        d_(("exttextoutw\n"));
        mode = GSF_LE_GET_GUINT32 (state->data + 16);
        d_(("\t graphic mode is %s\n", mode == 1? "compatible": "advanced"));
+       if (mode == 1) {
+               xscale = GSF_LE_GET_FLOAT (state->data + 20);
+               yscale = GSF_LE_GET_FLOAT (state->data + 24);
+               d_(("\t exScale = %g \t eyScale = %g\n", xscale, yscale));
+       }
        return TRUE;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]