From: johncoswell Date: Fri, 19 Oct 2007 02:48:37 +0000 (+0000) Subject: allow effects to modify namedview and document dimensions X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=87fd23b2432d3039ba84c8033ea13ca71508a7a3;p=inkscape.git allow effects to modify namedview and document dimensions --- diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index abc095b6b..bde0871ba 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -792,12 +792,21 @@ void Script::copy_doc (Inkscape::XML::Node * oldroot, Inkscape::XML::Node * newroot) { std::vector delete_list; + Inkscape::XML::Node * oldroot_namedview = NULL; + for (Inkscape::XML::Node * child = oldroot->firstChild(); child != NULL; child = child->next()) { - if (!strcmp("sodipodi:namedview", child->name())) - continue; - delete_list.push_back(child); + if (!strcmp("sodipodi:namedview", child->name())) { + oldroot_namedview = child; + for (Inkscape::XML::Node * oldroot_namedview_child = child->firstChild(); + oldroot_namedview_child != NULL; + oldroot_namedview_child = oldroot_namedview_child->next()) { + delete_list.push_back(oldroot_namedview_child); + } + } else { + delete_list.push_back(child); + } } for (unsigned int i = 0; i < delete_list.size(); i++) sp_repr_unparent(delete_list[i]); @@ -805,11 +814,22 @@ Script::copy_doc (Inkscape::XML::Node * oldroot, Inkscape::XML::Node * newroot) for (Inkscape::XML::Node * child = newroot->firstChild(); child != NULL; child = child->next()) { - if (!strcmp("sodipodi:namedview", child->name())) - continue; - oldroot->appendChild(child->duplicate(newroot->document())); + if (!strcmp("sodipodi:namedview", child->name())) { + if (oldroot_namedview != NULL) { + for (Inkscape::XML::Node * newroot_namedview_child = child->firstChild(); + newroot_namedview_child != NULL; + newroot_namedview_child = newroot_namedview_child->next()) { + oldroot_namedview->appendChild(newroot_namedview_child->duplicate(child->document())); + } + } + } else { + oldroot->appendChild(child->duplicate(newroot->document())); + } } + oldroot->setAttribute("width", newroot->attribute("width")); + oldroot->setAttribute("height", newroot->attribute("height")); + /** \todo Restore correct layer */ /** \todo Restore correct selection */ }