[gnumeric] Fixed SVG images size. [#628472]



commit efff79199a628fed1be892dac0c7b0bb2fb86cac
Author: Jean Brefort <jean brefort normalesup org>
Date:   Thu Oct 27 20:12:44 2011 +0200

    Fixed SVG images size. [#628472]

 ChangeLog                |    6 ++++++
 NEWS                     |    1 +
 src/libgnumeric.c        |    5 +++++
 src/sheet-object-image.c |   44 ++++++++++++++++++++++++++------------------
 4 files changed, 38 insertions(+), 18 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 4c04e83..79cca7b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2011-10-27  Jean Brefort  <jean brefort normalesup org>
 
+	* src/libgnumeric.c (gnm_init): fixed SVG images size. [#628472]
+	* src/sheet-object-image.c (gnm_soi_get_target_list),
+	(gnm_soi_default_size): ditto.
+
+2011-10-27  Jean Brefort  <jean brefort normalesup org>
+
 	* src/sheet-object-image.c (sheet_object_image_set_image),
 	(gnm_soi_finalize), (gnm_soi_new_view), (content_end),
 	(gnm_soi_draw_cairo): add true support for SVG images.
diff --git a/NEWS b/NEWS
index 834baf3..28fb236 100644
--- a/NEWS
+++ b/NEWS
@@ -56,6 +56,7 @@ Jean:
 	* Don't use anymore the "allow-shrink" and "allow-grow" properties.
 	[#661720, #661855]
 	* Add support for SVG images using librsvg.
+	* Fixed SVG images size. [#628472]
 
 Mikko Rasa:
         * Fix ODF import of certain percentage formats. [Debian #642135]
diff --git a/src/libgnumeric.c b/src/libgnumeric.c
index 3242b4b..3bda506 100644
--- a/src/libgnumeric.c
+++ b/src/libgnumeric.c
@@ -281,6 +281,11 @@ gnm_init (void)
 	gnm_xml_sax_read_init ();
 	gnm_xml_sax_write_init ();
 	stf_init ();
+
+	/* Make sure that images will be displayed with the correct
+	 resolution, see #628472 */
+	go_image_set_default_dpi (gnm_app_display_dpi_get (TRUE),
+	                          gnm_app_display_dpi_get (FALSE));
 }
 
 /**
diff --git a/src/sheet-object-image.c b/src/sheet-object-image.c
index 0df5c96..db90248 100644
--- a/src/sheet-object-image.c
+++ b/src/sheet-object-image.c
@@ -371,10 +371,12 @@ gnm_soi_get_target_list (SheetObject const *so)
 {
 	SheetObjectImage *soi = SHEET_OBJECT_IMAGE (so);
 	GtkTargetList *tl = gtk_target_list_new (NULL, 0);
-	char *mime_str = go_image_format_to_mime (soi->type);
+	char *mime_str;
 	GSList *mimes, *ptr;
-	GdkPixbuf *pixbuf;
+	GdkPixbuf *pixbuf = soi_get_pixbuf (soi, 1.0);
+	/* FIXME: we should not need that if we have a GOImag,used to set the soi->type */
 
+	mime_str = go_image_format_to_mime (soi->type);
 	mimes = go_strsplit_to_slist (mime_str, ',');
 	for (ptr = mimes; ptr != NULL; ptr = ptr->next) {
 		const char *mime = ptr->data;
@@ -386,7 +388,7 @@ gnm_soi_get_target_list (SheetObject const *so)
 	g_free (mime_str);
 	go_slist_free_custom (mimes, g_free);
 	/* No need to eliminate duplicates. */
-	if ((pixbuf = soi_get_pixbuf (soi, 1.0)) != NULL) {
+	if (pixbuf != NULL) {
 		gtk_target_list_add_image_targets (tl, 0, TRUE);
 		g_object_unref (pixbuf);
 	}
@@ -603,25 +605,31 @@ gnm_soi_draw_cairo (SheetObject const *so, cairo_t *cr,
 static void
 gnm_soi_default_size (SheetObject const *so, double *w, double *h)
 {
-	GdkPixbuf *buf = soi_get_pixbuf (SHEET_OBJECT_IMAGE (so), 1.);
+	SheetObjectImage *soi = SHEET_OBJECT_IMAGE (so);
+	if (soi->image) {
+		*w = go_image_get_width (soi->image);
+		*h = go_image_get_height (soi->image);
+	} else {
+		GdkPixbuf *buf = soi_get_pixbuf (soi, 1.);
 
-	if (!buf) {
-		*w = *h = 5;
-		return;
-	}
+		if (!buf) {
+			*w = *h = 5;
+			return;
+		}
 
-	*w = gdk_pixbuf_get_width  (buf);
-	*h = gdk_pixbuf_get_height (buf);
+		*w = gdk_pixbuf_get_width  (buf);
+		*h = gdk_pixbuf_get_height (buf);
 
-	/* In case buf is invalid with size 0,0 or if the image is just too
-	 * small to be useful default to something slightly larger
-	 * http://bugzilla.gnome.org/show_bug.cgi?id=462787
-	 **/
-	if ((*w * *h) < 25.) {
-		if (*w < 5) *w = 25;
-		if (*h < 5) *h = 25;
+		/* In case buf is invalid with size 0,0 or if the image is just too
+		 * small to be useful default to something slightly larger
+		 * http://bugzilla.gnome.org/show_bug.cgi?id=462787
+		 **/
+		if ((*w * *h) < 25.) {
+			if (*w < 5) *w = 25;
+			if (*h < 5) *h = 25;
+		}
+		g_object_unref (buf);
 	}
-	g_object_unref (buf);
 }
 
 static void



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