Code

Merge and cleanup of GSoC C++-ification project.
[inkscape.git] / src / xml / rebase-hrefs.cpp
index cfe6bef7c66e28ea8d37b40d56679dac1784ce39..0655171606f213c6e90592b0ce2945c653d6f9a9 100644 (file)
@@ -21,7 +21,7 @@ href_needs_rebasing(char const *const href)
 {
     g_return_val_if_fail(href, false);
 
-    if (!*href) {
+    if (!*href || *href == '#') {
         return false;
         /* False (no change) is the right behaviour even when the base URI differs from the
          * document URI: RFC 3986 defines empty string relative URL as referring to the containing
@@ -201,7 +201,11 @@ Inkscape::XML::calc_abs_doc_base(gchar const *const doc_base)
  */
 void Inkscape::XML::rebase_hrefs(SPDocument *const doc, gchar const *const new_base, bool const spns)
 {
-    gchar *const old_abs_base = calc_abs_doc_base(doc->base);
+    if (!doc->getBase()) {
+        return;
+    }
+
+    gchar *const old_abs_base = calc_abs_doc_base(doc->getBase());
     gchar *const new_abs_base = calc_abs_doc_base(new_base);
 
     /* TODO: Should handle not just image but also:
@@ -224,7 +228,7 @@ void Inkscape::XML::rebase_hrefs(SPDocument *const doc, gchar const *const new_b
      *
      * Note also that Inkscape only supports fragment hrefs (href="#pattern257") for many of these
      * cases. */
-    GSList const *images = sp_document_get_resource_list(doc, "image");
+    GSList const *images = doc->getResourceList("image");
     for (GSList const *l = images; l != NULL; l = l->next) {
         Inkscape::XML::Node *ir = SP_OBJECT_REPR(l->data);