summaryrefslogtreecommitdiffstats
path: root/src/file.cpp
diff options
context:
space:
mode:
authorMarc Jeanmougin <marc@jeanmougin.fr>2016-10-26 23:59:42 +0000
committerMarc Jeanmougin <marcjeanmougin@free.fr>2016-10-26 23:59:42 +0000
commit19ba77af95bc8266f504817def29730aa030ee56 (patch)
tree63dea4545b92b198bb9c90fb3aadcb363d31c743 /src/file.cpp
parentFix signals (diff)
downloadinkscape-19ba77af95bc8266f504817def29730aa030ee56.tar.gz
inkscape-19ba77af95bc8266f504817def29730aa030ee56.zip
Prevent image drag/drop from grouping
(bzr r15192)
Diffstat (limited to 'src/file.cpp')
-rw-r--r--src/file.cpp13
1 files changed, 12 insertions, 1 deletions
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::vector<SPItem *>v;
+ 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