From 19ba77af95bc8266f504817def29730aa030ee56 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Thu, 27 Oct 2016 01:59:42 +0200 Subject: Prevent image drag/drop from grouping (bzr r15192) --- src/file.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp index e5c7240dc..d39d8c6ce 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1193,12 +1193,23 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, // Count the number of top-level items in the imported document. guint items_count = 0; + SPObject *o = NULL; for (auto& child: doc->getRoot()->children) { if (SP_IS_ITEM(&child)) { items_count++; + o = &child; } } + //ungroup if necessary + bool did_ungroup = false; + while(items_count==1 && o && SP_IS_GROUP(o) && o->children.size()==1){ + std::vectorv; + sp_item_group_ungroup(SP_GROUP(o),v,false); + o = v.empty() ? NULL : v[0]; + did_ungroup=true; + } + // Create a new group if necessary. Inkscape::XML::Node *newgroup = NULL; if ((style && style->attributeList()) || items_count > 1) { @@ -1225,7 +1236,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, SPObject *new_obj = NULL; for (auto& child: doc->getRoot()->children) { if (SP_IS_ITEM(&child)) { - Inkscape::XML::Node *newitem = child.getRepr()->duplicate(xml_in_doc); + Inkscape::XML::Node *newitem = did_ungroup ? o->getRepr()->duplicate(xml_in_doc) : child.getRepr()->duplicate(xml_in_doc); // convert layers to groups, and make sure they are unlocked // FIXME: add "preserve layers" mode where each layer from -- cgit v1.2.3