[gnumeric] ods: simplify image handling.



commit 945b7f5c9f80c6927359acc0c1fb86f7a3751ef9
Author: Morten Welinder <terra gnome org>
Date:   Sat Feb 28 12:51:57 2015 -0500

    ods: simplify image handling.

 plugins/openoffice/ChangeLog         |    5 +++++
 plugins/openoffice/openoffice-read.c |   29 ++++++-----------------------
 2 files changed, 11 insertions(+), 23 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index cd1a65d..8ee632f 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,8 @@
+2015-02-28  Morten Welinder  <terra gnome org>
+
+       * openoffice-read.c (odf_apply_style_props): Simplify using
+       go_image_new_from_data.
+
 2015-02-26  Morten Welinder  <terra gnome org>
 
        * openoffice-read.c: Don't change the style of an object.  Copy,
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 401690a..57186a0 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -1102,34 +1102,17 @@ odf_apply_style_props (GsfXMLIn *xin, GSList *props, GOStyle *style, gboolean in
                                                    href_complete);
                                else {
                                        gsf_off_t len = gsf_input_size (input);
-                                       guint8 const *data = gsf_input_read
-                                               (input, len, NULL);
-                                       GdkPixbufLoader *loader
-                                               = gdk_pixbuf_loader_new ();
-                                       GdkPixbuf *pixbuf = NULL;
-
-                                       if (gdk_pixbuf_loader_write (loader,
-                                                                    (guchar *)data,
-                                                                    (gsize)len,
-                                                                    NULL)) {
-                                               gdk_pixbuf_loader_close (loader, NULL);
-                                               pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
-                                               g_object_ref (pixbuf);
-                                               if (style->fill.image.image != NULL)
-                                                       g_object_set
-                                                               (G_OBJECT (style->fill.image.image),
-                                                                "pixbuf", pixbuf, NULL);
-                                               else
-                                                       style->fill.image.image =
-                                                               go_pixbuf_new_from_pixbuf (pixbuf);
-                                               go_image_set_name (style->fill.image.image,
-                                                                  fill_image_name);
-                                               g_object_unref (loader);
+                                       guint8 const *data = gsf_input_read (input, len, NULL);
+                                       GOImage *image = go_image_new_from_data (NULL, data, len, NULL, NULL);
+                                       if (image) {
+                                               g_clear_object (&style->fill.image.image);
+                                               style->fill.image.image = image;
                                        } else {
                                                oo_warning (xin, _("Unable to load "
                                                                   "the file \'%s\'."),
                                                            href_complete);
                                        }
+
                                        g_object_unref (input);
                                }
                                g_free (href_complete);


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