diff options
| author | Marc Jeanmougin <marc@jeanmougin.fr> | 2015-08-18 22:56:36 +0000 |
|---|---|---|
| committer | Marc Jeanmougin <marcjeanmougin@free.fr> | 2015-08-18 22:56:36 +0000 |
| commit | 209b7267fe77a04874519b6ac247651102fa1b47 (patch) | |
| tree | 71cf3f4e027a1de5fd2ee11d93e533f2605139fc /src/file.cpp | |
| parent | added a check that is present in surrounding code, but not on this particular... (diff) | |
| download | inkscape-209b7267fe77a04874519b6ac247651102fa1b47.tar.gz inkscape-209b7267fe77a04874519b6ac247651102fa1b47.zip | |
Allows for copying clones between inkscape instances.
This patch puts the original of clones as children of _clipnode (<inkscape:clipboard>).
Then, on paste, it checks for the presence of an element with the right id (so that it does not breaks copypaste clones in the same doc),
then pastes all, and deletes the original if needed (which automagically unlinks the clone if needed).
[an alternate solution is to put the original in the defs (which might cause edition problems) and not unlink.
Depending on whether people would be more interested in this behavior there could be a preference item to choose]
Fixed bugs:
- https://launchpad.net/bugs/167907
(bzr r14309)
Diffstat (limited to 'src/file.cpp')
| -rw-r--r-- | src/file.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/file.cpp b/src/file.cpp index 984bf7e08..ed9caacf1 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1068,6 +1068,7 @@ void sp_import_document(SPDesktop *desktop, SPDocument *clipdoc, bool in_place) // copy definitions desktop->doc()->importDefs(clipdoc); + Inkscape::XML::Node* clipboard; // copy objects std::vector<Inkscape::XML::Node*> pasted_objects; for (Inkscape::XML::Node *obj = root->firstChild() ; obj ; obj = obj->next()) { @@ -1082,6 +1083,7 @@ void sp_import_document(SPDesktop *desktop, SPDocument *clipdoc, bool in_place) continue; } if (!strcmp(obj->name(), "inkscape:clipboard")) { + clipboard = obj; continue; } Inkscape::XML::Node *obj_copy = obj->duplicate(target_document->getReprDoc()); @@ -1090,12 +1092,31 @@ void sp_import_document(SPDesktop *desktop, SPDocument *clipdoc, bool in_place) pasted_objects.push_back(obj_copy); } - // Change the selection to the freshly pasted objects + + /* take that stuff into account: + * if( use && selection->includes(use->get_original()) ){//we are copying something whose parent is also copied (!) + * transform = ((SPItem*)(use->get_original()->parent))->i2doc_affine().inverse() * transform; + * } + * + */ + std::vector<Inkscape::XML::Node*> pasted_objects_not; + for (Inkscape::XML::Node *obj = clipboard->firstChild() ; obj ; obj = obj->next()) { + if(target_document->getObjectById(obj->attribute("id"))) continue; + Inkscape::XML::Node *obj_copy = obj->duplicate(target_document->getReprDoc()); + target_parent->appendChild(obj_copy); + Inkscape::GC::release(obj_copy); + pasted_objects_not.push_back(obj_copy); + } Inkscape::Selection *selection = desktop->getSelection(); + selection->setReprList(pasted_objects_not); + Geom::Affine doc2parent = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse(); + sp_selection_apply_affine(selection, desktop->dt2doc() * doc2parent * desktop->doc2dt(), true, false, false); + sp_selection_delete(desktop); + + // Change the selection to the freshly pasted objects selection->setReprList(pasted_objects); // Apply inverse of parent transform - Geom::Affine doc2parent = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse(); sp_selection_apply_affine(selection, desktop->dt2doc() * doc2parent * desktop->doc2dt(), true, false, false); // Update (among other things) all curves in paths, for bounds() to work |
