Re: errors during fo:external-graphic processing

Stefan Seefeld <[email protected]> Sat, 10 Sep 2005 10:56:11 -0400
Newsgroups gmane.text.xml.xmlroff.general
Message-ID <[email protected]>
Stefan Seefeld wrote:

> Now that looks like something I can contribute (as opposed to
> things such as how to split areas), so if you hold on a bit
> I may come up with a patch.

What about this one ?

Regards,
		Stefan
url.patch (text/x-patch, 3.8 KB)
Index: result-to-fo.c
===================================================================
RCS file: /cvsroot/xmlroff/xmlroff/result-to-fo.c,v
retrieving revision 1.25
diff -u -r1.25 result-to-fo.c
--- result-to-fo.c	13 Jun 2005 22:22:41 -0000	1.25
+++ result-to-fo.c	10 Sep 2005 14:54:33 -0000
@@ -216,7 +216,8 @@
     break; /* end 'd' */
   case 'e':
     if (strcmp (name, "external-graphic") == 0) {
-      fo_node = fo_external_graphic_new ();
+      xmlChar *base_uri = xmlNodeGetBase(node->doc, node);
+      fo_node = fo_external_graphic_new (base_uri);
       ok = TRUE;
     }
     break; /* end 'e' */
Index: fo/fo-external-graphic-private.h
===================================================================
RCS file: /cvsroot/xmlroff/xmlroff/fo/fo-external-graphic-private.h,v
retrieving revision 1.7
diff -u -r1.7 fo-external-graphic-private.h
--- fo/fo-external-graphic-private.h	9 Sep 2005 11:00:57 -0000	1.7
+++ fo/fo-external-graphic-private.h	10 Sep 2005 14:54:34 -0000
@@ -23,6 +23,7 @@
   FoFo        parent_instance;
 
   FoDoc      *fo_doc;
+  xmlChar    *base_url;
   FoImage    *fo_image;
   gdouble     area_width;
   gdouble     area_height;
Index: fo/fo-external-graphic.c
===================================================================
RCS file: /cvsroot/xmlroff/xmlroff/fo/fo-external-graphic.c,v
retrieving revision 1.19
diff -u -r1.19 fo-external-graphic.c
--- fo/fo-external-graphic.c	9 Sep 2005 11:00:57 -0000	1.19
+++ fo/fo-external-graphic.c	10 Sep 2005 14:54:36 -0000
@@ -84,6 +84,7 @@
 #include "fo-property-src.h"
 #include "fo-property-text-align.h"
 #include "fo-property-width.h"
+#include "libxml/uri.h"
 
 /* ORC = U+FFFC
  *     = 1111 1111 1111 1100 (UTF-16)
@@ -1290,9 +1291,17 @@
  * Return value: the new #FoExternalGraphic.
  **/
 FoFo*
-fo_external_graphic_new (void)
+fo_external_graphic_new (xmlChar *base_url)
 {
-  return FO_FO (g_object_new (fo_external_graphic_get_type (), NULL));
+  FoFo *fo_fo = FO_FO(g_object_new (fo_external_graphic_get_type (), NULL));
+  FO_EXTERNAL_GRAPHIC(fo_fo)->base_url = base_url;
+  return fo_fo;
+}
+
+xmlChar*
+fo_external_graphic_get_base_url (FoFo *fo_fo)
+{
+  return FO_EXTERNAL_GRAPHIC(fo_fo)->base_url;
 }
 
 /**
@@ -1403,7 +1412,8 @@
                               GError   **error)
 {
   FoExternalGraphic *fo_external_graphic;
-
+  gchar *src, *url;
+  
   g_return_if_fail (fo != NULL);
   g_return_if_fail (FO_IS_EXTERNAL_GRAPHIC (fo));
   g_return_if_fail (FO_IS_CONTEXT (current_context));
@@ -1419,8 +1429,9 @@
   fo_external_graphic_set_line_height (fo,
 				       fo_property_line_height_resolve (fo_external_graphic->line_height,
 									fo_context_get_font_size (fo->context)));
-  fo_external_graphic->fo_image =
-    fo_image_new_from_url (fo_uri_specification_get_value (fo_property_get_value (fo_external_graphic->src)));
+  src = fo_uri_specification_get_value (fo_property_get_value (fo_external_graphic->src));
+  url = xmlBuildURI(fo_external_graphic->base_url, src);
+  fo_external_graphic->fo_image = fo_image_new_from_url (url);
   fo_external_graphic_layout_resolve (fo_external_graphic);
 }
 
Index: fo/fo-external-graphic.h
===================================================================
RCS file: /cvsroot/xmlroff/xmlroff/fo/fo-external-graphic.h,v
retrieving revision 1.4
diff -u -r1.4 fo-external-graphic.h
--- fo/fo-external-graphic.h	30 Mar 2004 22:45:41 -0000	1.4
+++ fo/fo-external-graphic.h	10 Sep 2005 14:54:36 -0000
@@ -28,7 +28,9 @@
 
 
 GType         fo_external_graphic_get_type      (void) G_GNUC_CONST;
-FoFo *fo_external_graphic_new (void);
+FoFo *fo_external_graphic_new (xmlChar *base_uri);
+
+xmlChar*    fo_external_graphic_get_base_url (FoFo       *fo_fo);
 
 FoProperty* fo_external_graphic_get_alignment_adjust (FoFo       *fo_fo);
 void        fo_external_graphic_set_alignment_adjust (FoFo       *fo_fo,