aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorUlf Jasper2014-12-17 20:50:12 +0100
committerUlf Jasper2014-12-17 20:50:12 +0100
commit197a9e0c9e0c73ea5e76c10980e6265dd99439d9 (patch)
tree3e2a399ef74884c79d47e1f3a3efb6bedb2fc382 /src
parent72ef8d7639ba08da81af661f42b8f592d736ce94 (diff)
downloademacs-197a9e0c9e0c73ea5e76c10980e6265dd99439d9.tar.gz
emacs-197a9e0c9e0c73ea5e76c10980e6265dd99439d9.zip
Fix problem with images referenced within svg files. (bug#19373)
Fixes: debbugs:19373 * src/image.c: Additional parameter 'filename' for svg_load_image. Include "buffer.h". Define library function rsvg_handle_set_base_uri for WINDOWSNT. (init_svg_functions): Initialize rsvg_handle_set_base_uri. (fn_rsvg_handle_set_base_uri): Define fn_rsvg_handle_set_base_uri. (svg_load): Pass a filename to svg_load_image: either name of actual file or of current buffer's file. (svg_load_image): New parameter 'filename', used for setting base_uri, necessary for loading referenced images.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog14
-rw-r--r--src/image.c23
2 files changed, 32 insertions, 5 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index aa8adabfede..1e10ffd8fcd 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,17 @@
12014-12-17 Ulf Jasper <ulf.jasper@web.de>
2
3 Fix problem with images referenced within svg files. (bug#19373)
4
5 * image.c: Additional parameter 'filename' for
6 svg_load_image. Include "buffer.h". Define library function
7 rsvg_handle_set_base_uri for WINDOWSNT.
8 (init_svg_functions): Initialize rsvg_handle_set_base_uri.
9 (fn_rsvg_handle_set_base_uri): Define fn_rsvg_handle_set_base_uri.
10 (svg_load): Pass a filename to svg_load_image: either name of
11 actual file or of current buffer's file.
12 (svg_load_image): New parameter 'filename', used for setting
13 base_uri, necessary for loading referenced images. (bug#19373)
14
12014-12-16 Paul Eggert <eggert@cs.ucla.edu> 152014-12-16 Paul Eggert <eggert@cs.ucla.edu>
2 16
3 * lread.c (init_obarray): Declare Qt as special. 17 * lread.c (init_obarray): Declare Qt as special.
diff --git a/src/image.c b/src/image.c
index 1a2c0e29dde..0bebd45d893 100644
--- a/src/image.c
+++ b/src/image.c
@@ -33,6 +33,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
33#include "lisp.h" 33#include "lisp.h"
34#include "frame.h" 34#include "frame.h"
35#include "window.h" 35#include "window.h"
36#include "buffer.h"
36#include "dispextern.h" 37#include "dispextern.h"
37#include "blockinput.h" 38#include "blockinput.h"
38#include "systime.h" 39#include "systime.h"
@@ -8600,7 +8601,7 @@ static bool svg_image_p (Lisp_Object object);
8600static bool svg_load (struct frame *f, struct image *img); 8601static bool svg_load (struct frame *f, struct image *img);
8601 8602
8602static bool svg_load_image (struct frame *, struct image *, 8603static bool svg_load_image (struct frame *, struct image *,
8603 unsigned char *, ptrdiff_t); 8604 unsigned char *, ptrdiff_t, char*);
8604 8605
8605/* The symbol `svg' identifying images of this type. */ 8606/* The symbol `svg' identifying images of this type. */
8606 8607
@@ -8688,6 +8689,7 @@ DEF_IMGLIB_FN (void, rsvg_handle_get_dimensions, (RsvgHandle *, RsvgDimensionDat
8688DEF_IMGLIB_FN (gboolean, rsvg_handle_write, (RsvgHandle *, const guchar *, gsize, GError **)); 8689DEF_IMGLIB_FN (gboolean, rsvg_handle_write, (RsvgHandle *, const guchar *, gsize, GError **));
8689DEF_IMGLIB_FN (gboolean, rsvg_handle_close, (RsvgHandle *, GError **)); 8690DEF_IMGLIB_FN (gboolean, rsvg_handle_close, (RsvgHandle *, GError **));
8690DEF_IMGLIB_FN (GdkPixbuf *, rsvg_handle_get_pixbuf, (RsvgHandle *)); 8691DEF_IMGLIB_FN (GdkPixbuf *, rsvg_handle_get_pixbuf, (RsvgHandle *));
8692DEF_IMGLIB_FN (void, rsvg_handle_set_base_uri, (RsvgHandle *, const char *));
8691 8693
8692DEF_IMGLIB_FN (int, gdk_pixbuf_get_width, (const GdkPixbuf *)); 8694DEF_IMGLIB_FN (int, gdk_pixbuf_get_width, (const GdkPixbuf *));
8693DEF_IMGLIB_FN (int, gdk_pixbuf_get_height, (const GdkPixbuf *)); 8695DEF_IMGLIB_FN (int, gdk_pixbuf_get_height, (const GdkPixbuf *));
@@ -8727,6 +8729,7 @@ init_svg_functions (void)
8727 LOAD_IMGLIB_FN (library, rsvg_handle_write); 8729 LOAD_IMGLIB_FN (library, rsvg_handle_write);
8728 LOAD_IMGLIB_FN (library, rsvg_handle_close); 8730 LOAD_IMGLIB_FN (library, rsvg_handle_close);
8729 LOAD_IMGLIB_FN (library, rsvg_handle_get_pixbuf); 8731 LOAD_IMGLIB_FN (library, rsvg_handle_get_pixbuf);
8732 LOAD_IMGLIB_FN (library, rsvg_handle_set_base_uri);
8730 8733
8731 LOAD_IMGLIB_FN (gdklib, gdk_pixbuf_get_width); 8734 LOAD_IMGLIB_FN (gdklib, gdk_pixbuf_get_width);
8732 LOAD_IMGLIB_FN (gdklib, gdk_pixbuf_get_height); 8735 LOAD_IMGLIB_FN (gdklib, gdk_pixbuf_get_height);
@@ -8754,6 +8757,7 @@ init_svg_functions (void)
8754#define fn_rsvg_handle_write rsvg_handle_write 8757#define fn_rsvg_handle_write rsvg_handle_write
8755#define fn_rsvg_handle_close rsvg_handle_close 8758#define fn_rsvg_handle_close rsvg_handle_close
8756#define fn_rsvg_handle_get_pixbuf rsvg_handle_get_pixbuf 8759#define fn_rsvg_handle_get_pixbuf rsvg_handle_get_pixbuf
8760#define fn_rsvg_handle_set_base_uri rsvg_handle_set_base_uri
8757 8761
8758#define fn_gdk_pixbuf_get_width gdk_pixbuf_get_width 8762#define fn_gdk_pixbuf_get_width gdk_pixbuf_get_width
8759#define fn_gdk_pixbuf_get_height gdk_pixbuf_get_height 8763#define fn_gdk_pixbuf_get_height gdk_pixbuf_get_height
@@ -8803,14 +8807,14 @@ svg_load (struct frame *f, struct image *img)
8803 return 0; 8807 return 0;
8804 } 8808 }
8805 /* If the file was slurped into memory properly, parse it. */ 8809 /* If the file was slurped into memory properly, parse it. */
8806 success_p = svg_load_image (f, img, contents, size); 8810 success_p = svg_load_image (f, img, contents, size, SSDATA(file));
8807 xfree (contents); 8811 xfree (contents);
8808 } 8812 }
8809 /* Else its not a file, its a lisp object. Load the image from a 8813 /* Else its not a file, its a lisp object. Load the image from a
8810 lisp object rather than a file. */ 8814 lisp object rather than a file. */
8811 else 8815 else
8812 { 8816 {
8813 Lisp_Object data; 8817 Lisp_Object data, original_filename;
8814 8818
8815 data = image_spec_value (img->spec, QCdata, NULL); 8819 data = image_spec_value (img->spec, QCdata, NULL);
8816 if (!STRINGP (data)) 8820 if (!STRINGP (data))
@@ -8818,7 +8822,9 @@ svg_load (struct frame *f, struct image *img)
8818 image_error ("Invalid image data `%s'", data, Qnil); 8822 image_error ("Invalid image data `%s'", data, Qnil);
8819 return 0; 8823 return 0;
8820 } 8824 }
8821 success_p = svg_load_image (f, img, SDATA (data), SBYTES (data)); 8825 original_filename = BVAR (current_buffer, filename);
8826 success_p = svg_load_image (f, img, SDATA (data), SBYTES (data),
8827 SDATA(original_filename));
8822 } 8828 }
8823 8829
8824 return success_p; 8830 return success_p;
@@ -8835,7 +8841,8 @@ static bool
8835svg_load_image (struct frame *f, /* Pointer to emacs frame structure. */ 8841svg_load_image (struct frame *f, /* Pointer to emacs frame structure. */
8836 struct image *img, /* Pointer to emacs image structure. */ 8842 struct image *img, /* Pointer to emacs image structure. */
8837 unsigned char *contents, /* String containing the SVG XML data to be parsed. */ 8843 unsigned char *contents, /* String containing the SVG XML data to be parsed. */
8838 ptrdiff_t size) /* Size of data in bytes. */ 8844 ptrdiff_t size, /* Size of data in bytes. */
8845 char *filename) /* Name of SVG file being loaded. */
8839{ 8846{
8840 RsvgHandle *rsvg_handle; 8847 RsvgHandle *rsvg_handle;
8841 RsvgDimensionData dimension_data; 8848 RsvgDimensionData dimension_data;
@@ -8860,6 +8867,12 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. *
8860 /* Make a handle to a new rsvg object. */ 8867 /* Make a handle to a new rsvg object. */
8861 rsvg_handle = fn_rsvg_handle_new (); 8868 rsvg_handle = fn_rsvg_handle_new ();
8862 8869
8870 /* Set base_uri for properly handling referenced images (via 'href').
8871 See rsvg bug 596114 - "image refs are relative to curdir, not .svg file"
8872 (https://bugzilla.gnome.org/show_bug.cgi?id=596114). */
8873 if (filename)
8874 fn_rsvg_handle_set_base_uri(rsvg_handle, filename);
8875
8863 /* Parse the contents argument and fill in the rsvg_handle. */ 8876 /* Parse the contents argument and fill in the rsvg_handle. */
8864 fn_rsvg_handle_write (rsvg_handle, contents, size, &err); 8877 fn_rsvg_handle_write (rsvg_handle, contents, size, &err);
8865 if (err) goto rsvg_error; 8878 if (err) goto rsvg_error;