[goffice] Update the EMF and WMF mime types (and some work on the EMF support).



commit 08a5de6d645fd8b46175ed414e600468437cad7f
Author: Jean Brefort <jean brefort normalesup org>
Date:   Mon Jun 15 19:42:42 2020 +0200

    Update the EMF and WMF mime types (and some work on the EMF support).

 ChangeLog                |  7 +++++++
 goffice/utils/go-emf.c   | 43 +++++++++++++++++++++++++++++++++++--------
 goffice/utils/go-image.c |  4 ++--
 3 files changed, 44 insertions(+), 10 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index df4768ce..77355b67 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2020-06-15  Jean Brefort  <jean brefort normalesup org>
+
+       * goffice/utils/go-emf.c (go_emf_bitblt): implement filling with a solid
+       brush.
+       * goffice/utils/go-image.c (go_mime_to_image_format): update the EMF and
+       WMF mime types.
+
 2020-06-13  Jean Brefort  <jean brefort normalesup org>
 
        * goffice/gtk/go-font-sel-dialog.c (gfsd_class_init): fix more
diff --git a/goffice/utils/go-emf.c b/goffice/utils/go-emf.c
index 017c8189..c1b1ad0e 100644
--- a/goffice/utils/go-emf.c
+++ b/goffice/utils/go-emf.c
@@ -4021,7 +4021,7 @@ go_emf_bitblt (GOEmfState *state)
        GOWmfRectL rect;
        gint32 xDest, yDest, cxDest, cyDest, xSrc, ySrc;
        guint32 Oper;
-       double m11, m12, m21, m22, dx, dy;
+       cairo_matrix_t m;
        d_(("bitblt\n"));
        go_wmf_read_rectl (&rect, state->data); /* do we need it? */
        xDest = GSF_LE_GET_GINT32 (state->data + 16);
@@ -4033,14 +4033,41 @@ go_emf_bitblt (GOEmfState *state)
        ySrc = GSF_LE_GET_GINT32 (state->data + 40);
        d_(("\tDestination: x=%d y=%d cx=%d cy=%d Operation: %X\n", xDest, yDest, cxDest, cyDest, Oper));
        d_(("\tSource: x=%d y=%d\n", xSrc, ySrc));
-       m11 = GSF_LE_GET_FLOAT (state->data + 44);
-       m12 = GSF_LE_GET_FLOAT (state->data + 48);
-       m21 = GSF_LE_GET_FLOAT (state->data + 52);
-       m22 = GSF_LE_GET_FLOAT (state->data + 56);
-       dx = GSF_LE_GET_FLOAT (state->data + 60);
-       dy = GSF_LE_GET_FLOAT (state->data + 64);
+       m.xx = GSF_LE_GET_FLOAT (state->data + 44);
+       m.yx = GSF_LE_GET_FLOAT (state->data + 48);
+       m.xy = GSF_LE_GET_FLOAT (state->data + 52);
+       m.yy = GSF_LE_GET_FLOAT (state->data + 56);
+       m.x0 = GSF_LE_GET_FLOAT (state->data + 60);
+       m.y0 = GSF_LE_GET_FLOAT (state->data + 64);
        d_(("\tXForm: m11=%g m12=%g dx=%g\n\t       m21=%g m22=%g dy=%g\n",
-           m11, m12, dx, m21, m22, dy));
+           m.xx, m.yx, m.xy, m.yy, m.x0, m.y0));
+       if (cxDest > 0 && cyDest > 0) {
+               switch (Oper) {
+               case 0x62: // black rectangle
+               case 0xFF0042: //white rectangle
+               case 0xF00021: { // fill with brush
+                       GOStyle *style = go_style_dup (state->curDC->style);
+                       style->interesting_fields = GO_STYLE_FILL;
+                       if (Oper != 0xF00021) {
+                               style->fill.type = GO_STYLE_FILL_PATTERN;
+                               style->fill.pattern.pattern = GO_PATTERN_SOLID;
+                               style->fill.pattern.back = (Oper == 0x62)? GO_COLOR_BLACK: GO_COLOR_WHITE;
+                       }
+                       goc_item_set_transform (goc_item_new (state->curDC->group, GOC_TYPE_RECTANGLE,
+                                                                     "x", (double) xDest,
+                                                             "y", (double) yDest,
+                                                             "width", (double) cxDest,
+                                                                     "height", (double) cyDest,
+                                                                     "style", style, NULL),
+                                                       &m);
+                       g_object_unref (style);
+                       break;
+               }
+               default:
+                       // TODO: implement, see https://wiki.winehq.org/Ternary_Raster_Ops
+                       break;
+               }
+       }
        return TRUE;
 }
 
diff --git a/goffice/utils/go-image.c b/goffice/utils/go-image.c
index d79eea8d..b532ba1a 100644
--- a/goffice/utils/go-image.c
+++ b/goffice/utils/go-image.c
@@ -89,8 +89,8 @@ go_mime_to_image_format (char const *mime_type)
                "image/svg-xml", "svg",
                "image/vnd.adobe.svg+xml", "svg",
                "text/xml-svg", "svg",
-               "image/x-wmf", "wmf",
-               "image/x-emf", "emf",
+               "image/wmf", "wmf",
+               "image/emf", "emf",
                "application/pdf", "pdf",
                "application/postscript", "ps",
                "image/x-eps", "eps",


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