From 209b7267fe77a04874519b6ac247651102fa1b47 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Wed, 19 Aug 2015 00:56:36 +0200 Subject: Allows for copying clones between inkscape instances. This patch puts the original of clones as children of _clipnode (). 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) --- src/file.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'src/file.cpp') 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 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 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 -- cgit v1.2.3 From c8b00b1e5db4cbb22e180b75efaa529cc7605c9a Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Thu, 20 Aug 2015 13:48:43 +0200 Subject: small fix for pasting svg that were not copied in inkscape Fixed bugs: - https://launchpad.net/bugs/1486927 (bzr r14311) --- src/file.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp index ed9caacf1..7ae7d238a 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1068,7 +1068,7 @@ void sp_import_document(SPDesktop *desktop, SPDocument *clipdoc, bool in_place) // copy definitions desktop->doc()->importDefs(clipdoc); - Inkscape::XML::Node* clipboard; + Inkscape::XML::Node* clipboard = NULL; // copy objects std::vector pasted_objects; for (Inkscape::XML::Node *obj = root->firstChild() ; obj ; obj = obj->next()) { @@ -1100,6 +1100,7 @@ void sp_import_document(SPDesktop *desktop, SPDocument *clipdoc, bool in_place) * */ std::vector pasted_objects_not; + if(clipboard) 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()); -- cgit v1.2.3 From 447b514a70131ba71e507c0ef4647b9101a57113 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Fri, 12 Feb 2016 09:52:13 -0500 Subject: if viewbox does not exist, create it from page size, only if page size exists. (Bug 1544016) Fixed bugs: - https://launchpad.net/bugs/1544016 (bzr r14648) --- src/file.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp index 7ae7d238a..9d390908e 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -142,7 +142,9 @@ SPDesktop *sp_file_new(const std::string &templ) } // Set viewBox if it doesn't exist - if (!doc->getRoot()->viewBox_set) { + if (!doc->getRoot()->viewBox_set + && (doc->getRoot()->width.unit != SVGLength::PERCENT) + && (doc->getRoot()->height.unit != SVGLength::PERCENT)) { DocumentUndo::setUndoSensitive(doc, false); doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDisplayUnit()), doc->getHeight().value(doc->getDisplayUnit()))); DocumentUndo::setUndoSensitive(doc, true); @@ -289,7 +291,9 @@ bool sp_file_open(const Glib::ustring &uri, if (doc) { // Set viewBox if it doesn't exist - if (!doc->getRoot()->viewBox_set) { + if (!doc->getRoot()->viewBox_set + && (doc->getRoot()->width.unit != SVGLength::PERCENT) + && (doc->getRoot()->height.unit != SVGLength::PERCENT)) { DocumentUndo::setUndoSensitive(doc, false); doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDisplayUnit()), doc->getHeight().value(doc->getDisplayUnit()))); DocumentUndo::setUndoSensitive(doc, true); -- cgit v1.2.3