=== modified file 'src/document.cpp' --- src/document.cpp 2014-03-27 01:33:44 +0000 +++ src/document.cpp 2014-05-12 22:18:23 +0000 @@ -1597,7 +1597,15 @@ Inkscape::GC::release(dup); } } - + //DEBUG, this entire paragraph + for (Inkscape::XML::Node *def = defs->firstChild() ; def ; def = def->next()) { + SPObject *src = source->getObjectByRepr(def); + Glib::ustring id = src->getRepr()->attribute("id"); + if(id.find("linearGradient18282") != std::string::npos){ + Glib::ustring xr = src->getRepr()->attribute("xlink:href"); + std::cout << "DEBUG importDefs linearGradient18282 xlink:href is " << xr << std::endl; + } + } } /* === modified file 'src/file.cpp' --- src/file.cpp 2014-03-27 01:33:44 +0000 +++ src/file.cpp 2014-05-12 22:25:34 +0000 @@ -1058,6 +1058,7 @@ Inkscape::XML::Node *target_parent = desktop->currentLayer()->getRepr(); // copy definitions +std::cout << "DEBUG importDefs 1" << std::endl; desktop->doc()->importDefs(clipdoc); // copy objects @@ -1122,6 +1123,17 @@ sp_selection_move_relative(selection, offset); } + //DEBUG, this entire paragraph + for (Inkscape::XML::Node *def = root->firstChild() ; def ; def = def->next()) { + SPObject *src = target_document->getObjectByRepr(def); + if(src){ + Glib::ustring id = src->getRepr()->attribute("id"); + if(id.find("linearGradient18282") != std::string::npos){ + Glib::ustring xr = src->getRepr()->attribute("xlink:href"); + std::cout << "DEBUG sp_import_document linearGradient18282 xlink:href is " << xr << std::endl; + } + } + } g_slist_free(pasted_objects); } === modified file 'src/id-clash.cpp' --- src/id-clash.cpp 2014-04-25 05:46:24 +0000 +++ src/id-clash.cpp 2014-05-12 22:02:27 +0000 @@ -125,6 +125,7 @@ const char *attr = href_like_attributes[i]; const gchar *val = repr_elem->attribute(attr); if (val && val[0] == '#') { +std::cout << "DEBUG find_references xlink:href val " << val << std::endl; std::string id(val+1); IdReference idref = { REF_HREF, elem, attr }; (*refmap)[id].push_back(idref); @@ -297,6 +298,7 @@ void prevent_id_clashes(SPDocument *imported_doc, SPDocument *current_doc) { +std::cout << "DEBUG prevent_id_clashes" << std::endl; refmap_type *refmap = new refmap_type; id_changelist_type id_changes; SPObject *imported_root = imported_doc->getRoot(); @@ -319,15 +321,48 @@ SPDocument *current_doc = from_obj->document; std::string old_id(from_obj->getId()); +std::string to_id(to_obj->getId()); //DEBUG +std::cout << "DEBUG change_def_references before find_references looking for " << old_id +<< " to change to " << to_id << std::endl; + find_references(current_doc->getRoot(), refmap); +std::cout << "DEBUG change_def_references after find_references" << std::endl; refmap_type::const_iterator pos = refmap->find(old_id); if (pos != refmap->end()) { +std::cout << "DEBUG change_def_references found refernces to " << old_id << std::endl; std::list::const_iterator it; const std::list::const_iterator it_end = pos->second.end(); for (it = pos->second.begin(); it != it_end; ++it) { - if (it->type == REF_STYLE) { +std::cout << "DEBUG change_def_references for loop type " << it->type << std::endl; + if (it->type == REF_HREF) { + gchar *new_uri = g_strdup_printf("#%s", to_obj->getId()); +std::cout << "DEBUG change_def_references REF_HREF new_uri " << new_uri << " of attribute " << it->attr << std::endl; + it->elem->getRepr()->setAttribute(it->attr, new_uri); +std::cout << "DEBUG change_def_references changed element " << it->elem->getId() +<< " attribute " << it->attr +<< " new value " << it->elem->getRepr()->attribute(it->attr) +<< std::endl; + g_free(new_uri); + } else if (it->type == REF_STYLE) { +std::cout << "DEBUG change_def_references REF_STYLE " << std::endl; sp_style_set_property_url(it->elem, it->attr, to_obj, false); + } else if (it->type == REF_URL) { +std::cout << "DEBUG change_def_references REF_URL " << std::endl; + gchar *url = g_strdup_printf("url(#%s)", to_obj->getId()); + it->elem->getRepr()->setAttribute(it->attr, url); + g_free(url); + } else if (it->type == REF_CLIPBOARD) { +std::cout << "DEBUG change_def_references REF_CLIPBOARD " << std::endl; + SPCSSAttr *style = sp_repr_css_attr(it->elem->getRepr(), "style"); + gchar *url = g_strdup_printf("url(#%s)", to_obj->getId()); + sp_repr_css_set_property(style, it->attr, url); + g_free(url); + Glib::ustring style_string; + sp_repr_css_write_string(style, style_string); + it->elem->getRepr()->setAttribute("style", style_string.c_str()); + } else { + g_assert(0); // shouldn't happen } } }