diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2016-03-14 16:37:50 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2016-03-14 16:37:50 +0000 |
| commit | b8d22beef5345210ad27cdc2685083aeae6f8f3b (patch) | |
| tree | d69b8bfd19d3627a8425a1b265c2abf229b05354 /src/file.cpp | |
| parent | fixes for update to trunk (diff) | |
| parent | "Relative to" option for node alignment. (diff) | |
| download | inkscape-b8d22beef5345210ad27cdc2685083aeae6f8f3b.tar.gz inkscape-b8d22beef5345210ad27cdc2685083aeae6f8f3b.zip | |
update to trunk
(bzr r13708.1.39)
Diffstat (limited to 'src/file.cpp')
| -rw-r--r-- | src/file.cpp | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/src/file.cpp b/src/file.cpp index 984bf7e08..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); @@ -1068,6 +1072,7 @@ void sp_import_document(SPDesktop *desktop, SPDocument *clipdoc, bool in_place) // copy definitions desktop->doc()->importDefs(clipdoc); + Inkscape::XML::Node* clipboard = NULL; // copy objects std::vector<Inkscape::XML::Node*> pasted_objects; for (Inkscape::XML::Node *obj = root->firstChild() ; obj ; obj = obj->next()) { @@ -1082,6 +1087,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 +1096,32 @@ 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; + 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()); + 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 |
