Code

parent transformation on import and paste (Bug #376064, Bug #375499)
authorspeleo3 <speleo3@users.sourceforge.net>
Wed, 13 May 2009 17:41:26 +0000 (17:41 +0000)
committerspeleo3 <speleo3@users.sourceforge.net>
Wed, 13 May 2009 17:41:26 +0000 (17:41 +0000)
src/file.cpp
src/ui/clipboard.cpp

index f8d631455fd48d36e499e6748920f2a3ca550623..80b424f5d698bf2051dd1a1abb7595ddddf28aa7 100644 (file)
@@ -1011,6 +1011,12 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri,
             Inkscape::Selection *selection = sp_desktop_selection(desktop);
             selection->set(SP_ITEM(new_obj));
 
+            // preserve parent and viewBox transformations
+            // c2p is identity matrix at this point unless sp_document_ensure_up_to_date is called
+            sp_document_ensure_up_to_date(doc);
+            Geom::Matrix affine = SP_ROOT(SP_DOCUMENT_ROOT(doc))->c2p * sp_item_i2doc_affine(SP_ITEM(place_to_insert)).inverse();
+            sp_selection_apply_affine(selection, desktop->dt2doc() * affine * desktop->doc2dt(), true, false);
+
             // To move the imported object, we must temporarily set the "transform pattern with
             // object" option.
             {
index 2ee62cfec39df94c6df303362da11d8d41ada54e..7e41006bec7832908135b1423526b39a18d97e12 100644 (file)
@@ -799,7 +799,7 @@ void ClipboardManagerImpl::_pasteDocument(SPDocument *clipdoc, bool in_place)
 
     // invers apply parent transform
     Geom::Matrix doc2parent = sp_item_i2doc_affine(SP_ITEM(desktop->currentLayer())).inverse();
-    sp_selection_apply_affine(selection, doc2parent);
+    sp_selection_apply_affine(selection, desktop->dt2doc() * doc2parent * desktop->doc2dt(), true, false);
 
     // Update (among other things) all curves in paths, for bounds() to work
     sp_document_ensure_up_to_date(target_document);