From d1947e768272c703674129d5c583204ff2b59251 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Wed, 13 Jul 2016 13:36:19 +0200 Subject: Second part of new SPObject children list (bzr r14954.1.19) --- src/file.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp index 650ce5d0f..11e5f0a42 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1204,8 +1204,8 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, // Count the number of top-level items in the imported document. guint items_count = 0; - for ( SPObject *child = doc->getRoot()->firstChild(); child; child = child->getNext()) { - if (SP_IS_ITEM(child)) { + for (auto& child: doc->getRoot()->_children) { + if (SP_IS_ITEM(&child)) { items_count++; } } @@ -1234,9 +1234,9 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, // Construct a new object representing the imported image, // and insert it into the current document. SPObject *new_obj = NULL; - for ( SPObject *child = doc->getRoot()->firstChild(); child; child = child->getNext() ) { - if (SP_IS_ITEM(child)) { - Inkscape::XML::Node *newitem = child->getRepr()->duplicate(xml_in_doc); + for (auto& child: doc->getRoot()->_children) { + if (SP_IS_ITEM(&child)) { + Inkscape::XML::Node *newitem = 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 @@ -1249,10 +1249,10 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, } // don't lose top-level defs or style elements - else if (child->getRepr()->type() == Inkscape::XML::ELEMENT_NODE) { - const gchar *tag = child->getRepr()->name(); + else if (child.getRepr()->type() == Inkscape::XML::ELEMENT_NODE) { + const gchar *tag = child.getRepr()->name(); if (!strcmp(tag, "svg:style")) { - in_doc->getRoot()->appendChildRepr(child->getRepr()->duplicate(xml_in_doc)); + in_doc->getRoot()->appendChildRepr(child.getRepr()->duplicate(xml_in_doc)); } } } -- cgit v1.2.3 From 24d3f50003ca3cec6a03a7f5267cc4fe5588c69f Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Thu, 14 Jul 2016 13:17:21 +0200 Subject: Renamed children list in SPObject (bzr r14954.1.21) --- src/file.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp index 11e5f0a42..9ba180cb4 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1204,7 +1204,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, // Count the number of top-level items in the imported document. guint items_count = 0; - for (auto& child: doc->getRoot()->_children) { + for (auto& child: doc->getRoot()->children) { if (SP_IS_ITEM(&child)) { items_count++; } @@ -1234,7 +1234,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, // Construct a new object representing the imported image, // and insert it into the current document. SPObject *new_obj = NULL; - for (auto& child: doc->getRoot()->_children) { + for (auto& child: doc->getRoot()->children) { if (SP_IS_ITEM(&child)) { Inkscape::XML::Node *newitem = child.getRepr()->duplicate(xml_in_doc); -- cgit v1.2.3 From ff4fbbc93f67afd6cbf851691833a50d6c76b350 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Wed, 27 Jul 2016 12:19:03 +0200 Subject: Renamed some functions, fixed tests (bzr r14954.1.28) --- src/file.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp index 9ba180cb4..8743e3b67 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1129,14 +1129,14 @@ void sp_import_document(SPDesktop *desktop, SPDocument *clipdoc, bool in_place) 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_object_set_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 - sp_selection_apply_affine(selection, desktop->dt2doc() * doc2parent * desktop->doc2dt(), true, false, false); + sp_object_set_apply_affine(selection, desktop->dt2doc() * doc2parent * desktop->doc2dt(), true, false, false); // Update (among other things) all curves in paths, for bounds() to work target_document->ensureUpToDate(); @@ -1166,7 +1166,7 @@ void sp_import_document(SPDesktop *desktop, SPDocument *clipdoc, bool in_place) m.unSetup(); } - sp_selection_move_relative(selection, offset); + sp_object_set_move_relative(selection, offset); } } @@ -1271,7 +1271,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, // c2p is identity matrix at this point unless ensureUpToDate is called doc->ensureUpToDate(); Geom::Affine affine = doc->getRoot()->c2p * SP_ITEM(place_to_insert)->i2doc_affine().inverse(); - sp_selection_apply_affine(selection, desktop->dt2doc() * affine * desktop->doc2dt(), true, false, false); + sp_object_set_apply_affine(selection, desktop->dt2doc() * affine * desktop->doc2dt(), true, false, false); // move to mouse pointer { @@ -1279,7 +1279,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, Geom::OptRect sel_bbox = selection->visualBounds(); if (sel_bbox) { Geom::Point m( desktop->point() - sel_bbox->midpoint() ); - sp_selection_move_relative(selection, m, false); + sp_object_set_move_relative(selection, m, false); } } } -- cgit v1.2.3 From f35bb1f74a0ffeb5c6477a25e3c4cde87a97bcf1 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Thu, 28 Jul 2016 12:06:06 +0200 Subject: Removed unused includes, decrease compilation time (bzr r15025) --- src/file.cpp | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp index 650ce5d0f..a5e1c3d3b 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -33,14 +33,12 @@ #include "ui/dialog/ocaldialogs.h" #include "desktop.h" -#include "dir-util.h" #include "document-private.h" #include "document-undo.h" #include "ui/tools/tool-base.h" #include "extension/db.h" #include "extension/input.h" #include "extension/output.h" -#include "extension/system.h" #include "file.h" #include "helper/png-write.h" #include "id-clash.h" @@ -48,34 +46,23 @@ #include "inkscape-version.h" #include "ui/interface.h" #include "io/sys.h" -#include "message.h" #include "message-stack.h" #include "path-prefix.h" -#include "preferences.h" #include "print.h" #include "resource-manager.h" #include "rdf.h" #include "selection-chemistry.h" -#include "selection.h" #include "sp-namedview.h" #include "style.h" #include "ui/view/view-widget.h" -#include "uri.h" #include "xml/rebase-hrefs.h" #include "xml/sp-css-attr.h" #include "verbs.h" #include "event-log.h" #include "ui/dialog/font-substitution.h" -#include #include -#include -#include -#include - -#include - using Inkscape::DocumentUndo; #ifdef WITH_GNOME_VFS -- cgit v1.2.3 From 43b49e325db73cc19b1731db6c69545664ee8fbe Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Thu, 28 Jul 2016 13:26:17 +0200 Subject: Reverted changes to r15024 after many building problems (bzr r15027) --- src/file.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp index a5e1c3d3b..650ce5d0f 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -33,12 +33,14 @@ #include "ui/dialog/ocaldialogs.h" #include "desktop.h" +#include "dir-util.h" #include "document-private.h" #include "document-undo.h" #include "ui/tools/tool-base.h" #include "extension/db.h" #include "extension/input.h" #include "extension/output.h" +#include "extension/system.h" #include "file.h" #include "helper/png-write.h" #include "id-clash.h" @@ -46,23 +48,34 @@ #include "inkscape-version.h" #include "ui/interface.h" #include "io/sys.h" +#include "message.h" #include "message-stack.h" #include "path-prefix.h" +#include "preferences.h" #include "print.h" #include "resource-manager.h" #include "rdf.h" #include "selection-chemistry.h" +#include "selection.h" #include "sp-namedview.h" #include "style.h" #include "ui/view/view-widget.h" +#include "uri.h" #include "xml/rebase-hrefs.h" #include "xml/sp-css-attr.h" #include "verbs.h" #include "event-log.h" #include "ui/dialog/font-substitution.h" +#include #include +#include +#include +#include + +#include + using Inkscape::DocumentUndo; #ifdef WITH_GNOME_VFS -- cgit v1.2.3 From 35830f456cadaecf8b8e3944e3031a1a93f6cb41 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Wed, 3 Aug 2016 15:29:38 +0200 Subject: Removed unused includes, decreased compilation time. Once again (bzr r15034) --- src/file.cpp | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp index 650ce5d0f..56fdffb3c 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -33,14 +33,12 @@ #include "ui/dialog/ocaldialogs.h" #include "desktop.h" -#include "dir-util.h" #include "document-private.h" #include "document-undo.h" #include "ui/tools/tool-base.h" #include "extension/db.h" #include "extension/input.h" #include "extension/output.h" -#include "extension/system.h" #include "file.h" #include "helper/png-write.h" #include "id-clash.h" @@ -48,33 +46,24 @@ #include "inkscape-version.h" #include "ui/interface.h" #include "io/sys.h" -#include "message.h" #include "message-stack.h" #include "path-prefix.h" -#include "preferences.h" #include "print.h" #include "resource-manager.h" #include "rdf.h" #include "selection-chemistry.h" -#include "selection.h" #include "sp-namedview.h" #include "style.h" #include "ui/view/view-widget.h" -#include "uri.h" #include "xml/rebase-hrefs.h" #include "xml/sp-css-attr.h" #include "verbs.h" #include "event-log.h" #include "ui/dialog/font-substitution.h" -#include #include - -#include -#include #include - -#include +#include using Inkscape::DocumentUndo; -- cgit v1.2.3 From c7f5c676fa15f59f5f78c934263539981a26bbd2 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 10 Oct 2016 14:08:35 +0200 Subject: Fix some canvas problems and refactorization (bzr r15142.1.8) --- src/file.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp index 7c17a6158..5a51bbf52 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -259,8 +259,9 @@ bool sp_file_open(const Glib::ustring &uri, SPDesktop *desktop = SP_ACTIVE_DESKTOP; if (desktop) { desktop->setWaitingCursor(); + desktop->remove_temporary_canvasitem(sp_document_namedview(desktop->getDocument(), NULL)->page_border_rotated); } - + SPDocument *doc = NULL; bool cancelled = false; try { @@ -287,7 +288,6 @@ bool sp_file_open(const Glib::ustring &uri, doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDisplayUnit()), doc->getHeight().value(doc->getDisplayUnit()))); DocumentUndo::setUndoSensitive(doc, true); } - SPDocument *existing = desktop ? desktop->getDocument() : NULL; if (existing && existing->virgin && replace_empty) { -- cgit v1.2.3 From b949d0bdb9f751a94fd71f8bab7610d9a6a11a90 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 10 Oct 2016 16:06:22 +0200 Subject: Fix some canvas item problems and refresh items on rotate (bzr r15142.1.10) --- src/file.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp index 5a51bbf52..324998774 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -257,9 +257,10 @@ bool sp_file_open(const Glib::ustring &uri, bool replace_empty) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; + Inkscape::Display::TemporaryItem *page_border_rotated = NULL; if (desktop) { desktop->setWaitingCursor(); - desktop->remove_temporary_canvasitem(sp_document_namedview(desktop->getDocument(), NULL)->page_border_rotated); + page_border_rotated = sp_document_namedview(desktop->getDocument(), NULL)->page_border_rotated; } SPDocument *doc = NULL; @@ -295,6 +296,7 @@ bool sp_file_open(const Glib::ustring &uri, doc->ensureUpToDate(); // TODO this will trigger broken link warnings, etc. desktop->change_document(doc); doc->emitResizedSignal(doc->getWidth().value("px"), doc->getHeight().value("px")); + desktop->remove_temporary_canvasitem(page_border_rotated); } else { // create a whole new desktop and window SPViewWidget *dtw = sp_desktop_widget_new(sp_document_namedview(doc, NULL)); // TODO this will trigger broken link warnings, etc. -- cgit v1.2.3 From 532f77b14a76fc04e6bdeca3625f9a55b5f11bdf Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Tue, 25 Oct 2016 00:58:43 +0200 Subject: CPPification: almost all sp_object_set_whatever and sp_selection_whatever global functions are now methods of ObjectSet*, with these additional benefits: - They can now act on any SelectionSet, not just the current selection; - Whenever possible, they don't need a desktop anymore and can run if called from GUI. I hope I did not break too many things in the process. *: So instead of callink sp_selection_move(desktop,x,y), you call myobjectset->move(x,y) (bzr r15189) --- src/file.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp index 7c17a6158..e5c7240dc 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1118,14 +1118,14 @@ void sp_import_document(SPDesktop *desktop, SPDocument *clipdoc, bool in_place) Inkscape::Selection *selection = desktop->getSelection(); selection->setReprList(pasted_objects_not); Geom::Affine doc2parent = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse(); - sp_object_set_apply_affine(selection, desktop->dt2doc() * doc2parent * desktop->doc2dt(), true, false, false); - sp_selection_delete(desktop); + selection->applyAffine(desktop->dt2doc() * doc2parent * desktop->doc2dt(), true, false, false); + selection->deleteItems(); // Change the selection to the freshly pasted objects selection->setReprList(pasted_objects); // Apply inverse of parent transform - sp_object_set_apply_affine(selection, desktop->dt2doc() * doc2parent * desktop->doc2dt(), true, false, false); + selection->applyAffine(desktop->dt2doc() * doc2parent * desktop->doc2dt(), true, false, false); // Update (among other things) all curves in paths, for bounds() to work target_document->ensureUpToDate(); @@ -1155,7 +1155,7 @@ void sp_import_document(SPDesktop *desktop, SPDocument *clipdoc, bool in_place) m.unSetup(); } - sp_object_set_move_relative(selection, offset); + selection->moveRelative(offset); } } @@ -1260,7 +1260,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, // c2p is identity matrix at this point unless ensureUpToDate is called doc->ensureUpToDate(); Geom::Affine affine = doc->getRoot()->c2p * SP_ITEM(place_to_insert)->i2doc_affine().inverse(); - sp_object_set_apply_affine(selection, desktop->dt2doc() * affine * desktop->doc2dt(), true, false, false); + selection->applyAffine(desktop->dt2doc() * affine * desktop->doc2dt(), true, false, false); // move to mouse pointer { @@ -1268,7 +1268,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, Geom::OptRect sel_bbox = selection->visualBounds(); if (sel_bbox) { Geom::Point m( desktop->point() - sel_bbox->midpoint() ); - sp_object_set_move_relative(selection, m, false); + selection->moveRelative(m, false); } } } -- cgit v1.2.3 From 19ba77af95bc8266f504817def29730aa030ee56 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Thu, 27 Oct 2016 01:59:42 +0200 Subject: Prevent image drag/drop from grouping (bzr r15192) --- src/file.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/file.cpp') 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::vectorv; + 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 -- cgit v1.2.3 From 07212a0ac053f34a7a695a82690196b5f38d80ab Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Fri, 25 Nov 2016 14:17:44 +0100 Subject: Provide a way to update a legacy document to account for the 90 to 96 dpi change. This method relies on setting the 'viewBox'. (bzr r15273) --- src/file.cpp | 205 +++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 186 insertions(+), 19 deletions(-) (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp index d39d8c6ce..56d82d7bc 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -11,9 +11,10 @@ * Jon A. Cruz * Abhishek Sharma * David Xiong + * Tavmjong Bah * * Copyright (C) 2006 Johan Engelen - * Copyright (C) 1999-2012 Authors + * Copyright (C) 1999-2016 Authors * Copyright (C) 2004 David Turner * Copyright (C) 2001-2002 Ximian, Inc. * @@ -61,7 +62,12 @@ #include "event-log.h" #include "ui/dialog/font-substitution.h" -#include +// For updating old Inkscape SVG files +#include "display/canvas-grid.h" +#include "sp-guide.h" + +#include +//#include #include #include @@ -130,15 +136,6 @@ SPDesktop *sp_file_new(const std::string &templ) DocumentUndo::setUndoSensitive(doc, true); } - // Set viewBox if it doesn't exist - 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); - } - SPDesktop *olddesktop = SP_ACTIVE_DESKTOP; if (olddesktop) olddesktop->setWaitingCursor(); @@ -279,14 +276,6 @@ bool sp_file_open(const Glib::ustring &uri, } if (doc) { - // Set viewBox if it doesn't exist - 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); - } SPDocument *existing = desktop ? desktop->getDocument() : NULL; @@ -313,6 +302,184 @@ bool sp_file_open(const Glib::ustring &uri, root->original.inkscape = root->version.inkscape; root->original.svg = root->version.svg; + if (INKSCAPE.use_gui()) { + + // See if we need to offer the user a fix for the 90->96 px per inch change. + // std::cout << "SPFileOpen:" << std::endl; + // std::cout << " Version: " << sp_version_to_string(root->version.inkscape) << std::endl; + + if ( sp_version_inside_range( root->version.inkscape, 0, 1, 0, 92 ) ) { + + // std::cout << " SVG file from old Inkscape version detected: " + // << sp_version_to_string(root->version.inkscape) << std::endl; + + + static const double ratio = 90.0/96.0; + + bool need_fix_viewbox = false; + bool need_fix_units = false; + bool need_fix_guides = false; + bool need_fix_grid_mm = false; + + // Check if potentially need viewbox or unit fix + switch (root->width.unit) { + case SP_CSS_UNIT_PC: + case SP_CSS_UNIT_MM: + case SP_CSS_UNIT_CM: + case SP_CSS_UNIT_IN: + need_fix_viewbox = true; + break; + case SP_CSS_UNIT_NONE: + case SP_CSS_UNIT_PX: + need_fix_units = true; + default: + break; + // OK + } + + switch (root->height.unit) { + case SP_CSS_UNIT_PC: + case SP_CSS_UNIT_MM: + case SP_CSS_UNIT_CM: + case SP_CSS_UNIT_IN: + need_fix_viewbox = true; + break; + case SP_CSS_UNIT_NONE: + case SP_CSS_UNIT_PX: + need_fix_units = true; + default: + break; + // OK + } + + // std::cout << "Absolute SVG units in root? " << (need_fix_viewbox?"true":"false") << std::endl; + // std::cout << "User units in root? " << (need_fix_units ?"true":"false") << std::endl; + + if (!root->viewBox_set && need_fix_viewbox) { + + std::string msg = _( + "Old Inkscape files used 1in == 90px. CSS requires 1in == 96px.\n" + "Drawing elements may be too small. This can be corrected by\n" + "setting the SVG 'viewBox' to compensate." ); + // "either setting the SVG 'viewBox' to compensate or by scaling\n" + // "all the elements in the drawing." + Gtk::Dialog scaleDialog( _("Old Inkscape file detected (90 DPI)"), false); + Gtk::Label info; + info.set_markup(msg.c_str()); + info.show(); + scaleDialog.get_content_area()->pack_start(info, false, false, 20); + scaleDialog.add_button("Set 'viewBox'", 1); + // scaleDialog.add_button("Scale elements", 2); + scaleDialog.add_button("Ignore", 3); + + gint response = scaleDialog.run(); + if (response == 1) { + doc->setViewBox(Geom::Rect::from_xywh( + 0, 0, + doc->getWidth().value("px") * ratio, + doc->getHeight().value("px") * ratio)); + } else if (response == 2 ) { + // Insert DPISwitcher code + } + need_fix_guides = true; // Always fix guides + } + + if (need_fix_units) { + std::string msg = ( + "Old Inkscape files used 1in == 90px. CSS requires 1in == 96px.\n" + "Drawings meant to match a physical size (e.g. Letter or A4)\n" + "will be too small. Scaling the drawing can correct for this.\n" ); + // "Internal scaling can be handled either by setting the SVG 'viewBox'\n" + // "attribute to compensate or by scaling all objects in the drawing." + Gtk::Dialog scaleDialog( _("Old Inkscape file detected (90 DPI)"), false); + Gtk::Label info; + info.set_markup(msg.c_str()); + info.show(); + scaleDialog.get_content_area()->pack_start(info, false, false, 20); + scaleDialog.add_button("Scale drawing", 1); + // scaleDialog.add_button("Set 'viewBox'", 1); + // scaleDialog.add_button("Scale elements", 2); + scaleDialog.add_button("Ignore", 3); + + gint response = scaleDialog.run(); + if (response == 1) { + + if (!root->viewBox_set) { + doc->setViewBox(Geom::Rect::from_xywh( + 0, 0, + doc->getWidth().value("px"), + doc->getHeight().value("px"))); + } + Inkscape::Util::Quantity width = + Inkscape::Util::Quantity(doc->getWidth().value("px")/ratio, "px" ); + Inkscape::Util::Quantity height = + Inkscape::Util::Quantity(doc->getHeight().value("px")/ratio,"px" ); + doc->setWidthAndHeight( width, height, false ); + + need_fix_guides = true; // Only fix guides if drawing scaled + } else if (response == 2) { + // Insert DPISwitcher code + } else { + // Ignore + need_fix_grid_mm = true; + } + } + + // Fix guides and grids + for (SPObject *child = root->firstChild() ; child; child = child->getNext() ) { + SPNamedView *nv = dynamic_cast(child); + if (nv) { + if (need_fix_guides) { + // std::cout << "Fixing guides" << std::endl; + for (SPObject *child2 = nv->firstChild() ; child2; child2 = child2->getNext() ) { + SPGuide *gd = dynamic_cast(child2); + if (gd) { + gd->moveto( gd->getPoint() / ratio, true ); + } + } + } + + for(std::vector::const_iterator it=nv->grids.begin();it!=nv->grids.end();++it ) { + Inkscape::CanvasXYGrid *xy = dynamic_cast(*it); + if (xy) { + // std::cout << "A grid: " << xy->getSVGName() << std::endl; + // std::cout << " Origin: " << xy->origin + // << " Spacing: " << xy->spacing << std::endl; + // std::cout << (xy->isLegacy()?" Legacy":" Not Legacy") << std::endl; + Geom::Scale scale = doc->getDocumentScale(); + if (xy->isLegacy()) { + if (xy->isPixel()) { + if (need_fix_grid_mm) { + xy->Scale( Geom::Scale(1,1) ); // See note below + } else { + scale *= Geom::Scale(ratio,ratio); + xy->Scale( scale.inverse() ); /* *** */ + } + } else { + if (need_fix_grid_mm) { + xy->Scale( Geom::Scale(ratio,ratio) ); + } else { + xy->Scale( scale.inverse() ); /* *** */ + } + } + } else { + if (need_fix_guides) { + // HACK: Scaling the document does not seem to cause + // grids defined in document units to be updated. + // This forces an update. + xy->Scale( Geom::Scale(1,1) ); + } + } + } + } + } + } // Look for SPNamedView loop + + DocumentUndo::done(desktop->getDocument(), SP_VERB_NONE, _("Update Document")); + + } // If old Inkscape version + } // If use_gui + // resize the window to match the document properties sp_namedview_window_from_document(desktop); sp_namedview_update_layers_from_document(desktop); -- cgit v1.2.3 From 5113c265f595b8497e1c340e01177d425155ff3d Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Mon, 28 Nov 2016 23:07:00 +0100 Subject: update filter list when pasting and on import (bzr r15283) --- src/file.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp index 56d82d7bc..ee66cc162 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1324,6 +1324,7 @@ void sp_import_document(SPDesktop *desktop, SPDocument *clipdoc, bool in_place) selection->moveRelative(offset); } + target_document->emitReconstructionFinish(); } @@ -1423,6 +1424,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, } } } + in_doc->emitReconstructionFinish(); if (newgroup) new_obj = place_to_insert->appendChildRepr(newgroup); // release some stuff -- cgit v1.2.3 From 02e09f2b868edcfce47a53bf6bc556df6e5515bc Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 6 Dec 2016 13:27:53 +0100 Subject: Add dpiswitcher extension and option to scale legacy documents with it. (bzr r15301) --- src/file.cpp | 72 ++++++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 53 insertions(+), 19 deletions(-) (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp index ee66cc162..38c07311d 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -34,6 +34,7 @@ #include "ui/dialog/ocaldialogs.h" #include "desktop.h" +#include "extension/effect.h" #include "document-private.h" #include "document-undo.h" #include "ui/tools/tool-base.h" @@ -312,14 +313,13 @@ bool sp_file_open(const Glib::ustring &uri, // std::cout << " SVG file from old Inkscape version detected: " // << sp_version_to_string(root->version.inkscape) << std::endl; - - static const double ratio = 90.0/96.0; bool need_fix_viewbox = false; bool need_fix_units = false; bool need_fix_guides = false; bool need_fix_grid_mm = false; + bool is_extension = false; // Check if potentially need viewbox or unit fix switch (root->width.unit) { @@ -358,20 +358,18 @@ bool sp_file_open(const Glib::ustring &uri, if (!root->viewBox_set && need_fix_viewbox) { std::string msg = _( - "Old Inkscape files used 1in == 90px. CSS requires 1in == 96px.\n" + "Old Inkscape files use 1in == 90px. CSS requires 1in == 96px.\n" "Drawing elements may be too small. This can be corrected by\n" - "setting the SVG 'viewBox' to compensate." ); - // "either setting the SVG 'viewBox' to compensate or by scaling\n" - // "all the elements in the drawing." + "either setting the SVG 'viewBox' to compensate or by scaling\n" + "all the elements in the drawing."); Gtk::Dialog scaleDialog( _("Old Inkscape file detected (90 DPI)"), false); Gtk::Label info; info.set_markup(msg.c_str()); info.show(); scaleDialog.get_content_area()->pack_start(info, false, false, 20); scaleDialog.add_button("Set 'viewBox'", 1); - // scaleDialog.add_button("Scale elements", 2); + scaleDialog.add_button("Scale elements", 2); scaleDialog.add_button("Ignore", 3); - gint response = scaleDialog.run(); if (response == 1) { doc->setViewBox(Geom::Rect::from_xywh( @@ -379,27 +377,42 @@ bool sp_file_open(const Glib::ustring &uri, doc->getWidth().value("px") * ratio, doc->getHeight().value("px") * ratio)); } else if (response == 2 ) { - // Insert DPISwitcher code + std::list effects; + Inkscape::Extension::db.get_effect_list(effects); + std::list::iterator it = effects.begin(); + bool did = false; + while (it != effects.end()) { + if (strcmp((*it)->get_id(), "org.inkscape.dpi90to96") == 0) { + Inkscape::UI::View::View *view = desktop; + (*it)->effect(view); + did = true; + break; + } + ++it; + } + if (!did) { + std::cerr << "sp_file_open: Failed to find dpi90to96 extension." << std::endl; + } + is_extension = true; } need_fix_guides = true; // Always fix guides } if (need_fix_units) { std::string msg = ( - "Old Inkscape files used 1in == 90px. CSS requires 1in == 96px.\n" + "Old Inkscape files use 1in == 90px. CSS requires 1in == 96px.\n" "Drawings meant to match a physical size (e.g. Letter or A4)\n" - "will be too small. Scaling the drawing can correct for this.\n" ); - // "Internal scaling can be handled either by setting the SVG 'viewBox'\n" - // "attribute to compensate or by scaling all objects in the drawing." + "will be too small. Scaling the drawing can correct for this.\n" + "Internal scaling can be handled either by setting the SVG 'viewBox'\n" + "attribute to compensate or by scaling all objects in the drawing."); Gtk::Dialog scaleDialog( _("Old Inkscape file detected (90 DPI)"), false); Gtk::Label info; info.set_markup(msg.c_str()); info.show(); scaleDialog.get_content_area()->pack_start(info, false, false, 20); - scaleDialog.add_button("Scale drawing", 1); - // scaleDialog.add_button("Set 'viewBox'", 1); - // scaleDialog.add_button("Scale elements", 2); - scaleDialog.add_button("Ignore", 3); + scaleDialog.add_button("Set 'viewBox'", 1); + scaleDialog.add_button("Scale elements", 2); + scaleDialog.add_button("Ignore", 3); gint response = scaleDialog.run(); if (response == 1) { @@ -418,7 +431,24 @@ bool sp_file_open(const Glib::ustring &uri, need_fix_guides = true; // Only fix guides if drawing scaled } else if (response == 2) { - // Insert DPISwitcher code + std::list effects; + Inkscape::Extension::db.get_effect_list(effects); + std::list::iterator it = effects.begin(); + bool did = false; + while (it != effects.end()){ + if (strcmp((*it)->get_id(), "org.inkscape.dpi90to96") == 0) { + Inkscape::UI::View::View *view = desktop; + (*it)->effect(view); + did = true; + break; + } + ++it; + } + if (!did) { + std::cerr << "sp_file_open: Failed to find dpi90to96 extension." << std::endl; + } + need_fix_guides = true; // Only fix guides if drawing scaled + is_extension = true; } else { // Ignore need_fix_grid_mm = true; @@ -467,7 +497,11 @@ bool sp_file_open(const Glib::ustring &uri, // HACK: Scaling the document does not seem to cause // grids defined in document units to be updated. // This forces an update. - xy->Scale( Geom::Scale(1,1) ); + if(is_extension){ + xy->Scale( Geom::Scale(ratio,ratio).inverse() ); + } else { + xy->Scale( Geom::Scale(1,1) ); + } } } } -- cgit v1.2.3 From f54d446fabea020ac142939915aecb225508f56f Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Wed, 7 Dec 2016 14:38:25 +0100 Subject: Add option to save a backup when updating file for dpi change. (bzr r15307) --- src/file.cpp | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 67 insertions(+), 6 deletions(-) (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp index 38c07311d..55089209a 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -68,9 +68,6 @@ #include "sp-guide.h" #include -//#include -#include -#include using Inkscape::DocumentUndo; @@ -239,6 +236,43 @@ sp_file_exit() } +// Quick and dirty internal backup function +bool sp_file_save_backup( Glib::ustring uri ) { + + Glib::ustring out = uri; + out.insert(out.find(".svg"),"_backup"); + + FILE *filein = Inkscape::IO::fopen_utf8name(uri.c_str(), "rb"); + if (!filein) { + std::cerr << "sp_file_save_backup: failed to open: " << uri << std::endl; + return false; + } + + FILE *fileout = Inkscape::IO::fopen_utf8name(out.c_str(), "wb"); + if (!fileout) { + std::cerr << "sp_file_save_backup: failed to open: " << out << std::endl; + fclose( filein ); + return false; + } + + int ch; + while ((ch = fgetc(filein)) != EOF) { + fputc(ch, fileout); + } + fflush(fileout); + + bool return_value = true; + if (ferror(fileout)) { + std::cerr << "sp_file_save_backup: error when writing to: " << out << std::endl; + return_value = false; + } + + fclose(filein); + fclose(fileout); + + return return_value; +} + /*###################### ## O P E N ######################*/ @@ -357,26 +391,41 @@ bool sp_file_open(const Glib::ustring &uri, if (!root->viewBox_set && need_fix_viewbox) { - std::string msg = _( + Glib::ustring msg = _( "Old Inkscape files use 1in == 90px. CSS requires 1in == 96px.\n" "Drawing elements may be too small. This can be corrected by\n" "either setting the SVG 'viewBox' to compensate or by scaling\n" "all the elements in the drawing."); Gtk::Dialog scaleDialog( _("Old Inkscape file detected (90 DPI)"), false); + Gtk::Label info; info.set_markup(msg.c_str()); info.show(); + scaleDialog.get_content_area()->pack_start(info, false, false, 20); + Gtk::CheckButton backupButton( _("Create backup file (in same directory).") ); + backupButton.set_active(); + backupButton.show(); + + scaleDialog.get_content_area()->pack_start(backupButton, false, false, 20); scaleDialog.add_button("Set 'viewBox'", 1); scaleDialog.add_button("Scale elements", 2); scaleDialog.add_button("Ignore", 3); + gint response = scaleDialog.run(); + bool backup = backupButton.get_active(); if (response == 1) { + if (backup) { + sp_file_save_backup( uri ); + } doc->setViewBox(Geom::Rect::from_xywh( 0, 0, doc->getWidth().value("px") * ratio, doc->getHeight().value("px") * ratio)); } else if (response == 2 ) { + if (backup) { + sp_file_save_backup( uri ); + } std::list effects; Inkscape::Extension::db.get_effect_list(effects); std::list::iterator it = effects.begin(); @@ -399,24 +448,33 @@ bool sp_file_open(const Glib::ustring &uri, } if (need_fix_units) { - std::string msg = ( + Glib::ustring msg = ( "Old Inkscape files use 1in == 90px. CSS requires 1in == 96px.\n" "Drawings meant to match a physical size (e.g. Letter or A4)\n" "will be too small. Scaling the drawing can correct for this.\n" "Internal scaling can be handled either by setting the SVG 'viewBox'\n" "attribute to compensate or by scaling all objects in the drawing."); Gtk::Dialog scaleDialog( _("Old Inkscape file detected (90 DPI)"), false); + Gtk::Label info; info.set_markup(msg.c_str()); info.show(); scaleDialog.get_content_area()->pack_start(info, false, false, 20); + + Gtk::CheckButton backupButton( _("Create backup file (in same directory).") ); + scaleDialog.get_content_area()->pack_start(backupButton, false, false, 20); + backupButton.show(); + scaleDialog.add_button("Set 'viewBox'", 1); scaleDialog.add_button("Scale elements", 2); scaleDialog.add_button("Ignore", 3); gint response = scaleDialog.run(); + bool backup = backupButton.get_active(); if (response == 1) { - + if (backup) { + sp_file_save_backup( uri ); + } if (!root->viewBox_set) { doc->setViewBox(Geom::Rect::from_xywh( 0, 0, @@ -431,6 +489,9 @@ bool sp_file_open(const Glib::ustring &uri, need_fix_guides = true; // Only fix guides if drawing scaled } else if (response == 2) { + if (backup) { + sp_file_save_backup( uri ); + } std::list effects; Inkscape::Extension::db.get_effect_list(effects); std::list::iterator it = effects.begin(); -- cgit v1.2.3 From 5f912d8b81bc34d07b7e74930c2f60a71b791ed0 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 12 Dec 2016 09:49:35 +0100 Subject: Add missing 'pt' unit to test of legacy files. (bzr r15322) --- src/file.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp index 55089209a..2c0d927f5 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -358,6 +358,7 @@ bool sp_file_open(const Glib::ustring &uri, // Check if potentially need viewbox or unit fix switch (root->width.unit) { case SP_CSS_UNIT_PC: + case SP_CSS_UNIT_PT: case SP_CSS_UNIT_MM: case SP_CSS_UNIT_CM: case SP_CSS_UNIT_IN: @@ -366,13 +367,19 @@ bool sp_file_open(const Glib::ustring &uri, case SP_CSS_UNIT_NONE: case SP_CSS_UNIT_PX: need_fix_units = true; - default: break; + case SP_CSS_UNIT_EM: + case SP_CSS_UNIT_EX: + case SP_CSS_UNIT_PERCENT: // OK + break; + default: + std::cerr << "sp_file_open: Unhandled width unit!" << std::endl; } switch (root->height.unit) { case SP_CSS_UNIT_PC: + case SP_CSS_UNIT_PT: case SP_CSS_UNIT_MM: case SP_CSS_UNIT_CM: case SP_CSS_UNIT_IN: @@ -381,9 +388,14 @@ bool sp_file_open(const Glib::ustring &uri, case SP_CSS_UNIT_NONE: case SP_CSS_UNIT_PX: need_fix_units = true; - default: break; + case SP_CSS_UNIT_EM: + case SP_CSS_UNIT_EX: + case SP_CSS_UNIT_PERCENT: // OK + break; + default: + std::cerr << "sp_file_open: Unhandled height unit!" << std::endl; } // std::cout << "Absolute SVG units in root? " << (need_fix_viewbox?"true":"false") << std::endl; -- cgit v1.2.3 From 8b5b6e365b51947eb0936b6274ef8a748e4e71f7 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Wed, 14 Dec 2016 11:20:20 +0100 Subject: Add test internal scaling to account for DPI change. (bzr r15324) --- src/file.cpp | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 95 insertions(+), 7 deletions(-) (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp index 2c0d927f5..eae3ddd17 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -66,6 +66,9 @@ // For updating old Inkscape SVG files #include "display/canvas-grid.h" #include "sp-guide.h" +#include "selection-chemistry.h" +#include "persp3d.h" +#include "proj_pt.h" #include @@ -353,6 +356,7 @@ bool sp_file_open(const Glib::ustring &uri, bool need_fix_units = false; bool need_fix_guides = false; bool need_fix_grid_mm = false; + bool need_fix_box3d = false; bool is_extension = false; // Check if potentially need viewbox or unit fix @@ -420,9 +424,10 @@ bool sp_file_open(const Glib::ustring &uri, backupButton.show(); scaleDialog.get_content_area()->pack_start(backupButton, false, false, 20); - scaleDialog.add_button("Set 'viewBox'", 1); + scaleDialog.add_button("Set 'viewBox'", 1); scaleDialog.add_button("Scale elements", 2); - scaleDialog.add_button("Ignore", 3); + scaleDialog.add_button("Ignore", 3); + scaleDialog.add_button("Test", 4); gint response = scaleDialog.run(); bool backup = backupButton.get_active(); @@ -455,7 +460,27 @@ bool sp_file_open(const Glib::ustring &uri, std::cerr << "sp_file_open: Failed to find dpi90to96 extension." << std::endl; } is_extension = true; + } else if (response == 4) { + + if (backup) { + sp_file_save_backup( uri ); + } + + Inkscape::Selection *selection = desktop->getSelection(); + Inkscape::SelectionHelper::selectAllInAll( desktop ); + selection->group(); + SPItem * group = selection->singleItem(); + if (group) { + group->setAttribute("transform","scale(1.06666667,1.06666667)"); + } else { + std::cerr << "sp_file_open: Failed to get group!" << std::endl; + } + selection->ungroup(); + selection->clear(); + is_extension = true; } + + need_fix_box3d = true; need_fix_guides = true; // Always fix guides } @@ -480,6 +505,7 @@ bool sp_file_open(const Glib::ustring &uri, scaleDialog.add_button("Set 'viewBox'", 1); scaleDialog.add_button("Scale elements", 2); scaleDialog.add_button("Ignore", 3); + scaleDialog.add_button("Test", 4); gint response = scaleDialog.run(); bool backup = backupButton.get_active(); @@ -500,6 +526,7 @@ bool sp_file_open(const Glib::ustring &uri, doc->setWidthAndHeight( width, height, false ); need_fix_guides = true; // Only fix guides if drawing scaled + need_fix_box3d = true; } else if (response == 2) { if (backup) { sp_file_save_backup( uri ); @@ -522,13 +549,42 @@ bool sp_file_open(const Glib::ustring &uri, } need_fix_guides = true; // Only fix guides if drawing scaled is_extension = true; + } else if (response == 4) { + if (backup) { + sp_file_save_backup( uri ); + } + + Inkscape::Util::Quantity width = + Inkscape::Util::Quantity(doc->getWidth().value("px")/ratio, "px" ); + Inkscape::Util::Quantity height = + Inkscape::Util::Quantity(doc->getHeight().value("px")/ratio,"px" ); + doc->setWidthAndHeight( width, height, false ); + + if (!root->viewBox_set) { + Inkscape::Selection *selection = desktop->getSelection(); + Inkscape::SelectionHelper::selectAllInAll( desktop ); + selection->group(); + SPItem * group = selection->singleItem(); + if (group) { + group->setAttribute("transform","scale(1.06666667,1.06666667)"); + } else { + std::cerr << "sp_file_open: Failed to get group!" << std::endl; + } + selection->ungroup(); + selection->clear(); + is_extension = true; + } + + need_fix_box3d = true; + need_fix_guides = true; // Only fix guides if drawing scaled + } else { // Ignore need_fix_grid_mm = true; } } - // Fix guides and grids + // Fix guides and grids and perspective for (SPObject *child = root->firstChild() ; child; child = child->getNext() ) { SPNamedView *nv = dynamic_cast(child); if (nv) { @@ -567,21 +623,53 @@ bool sp_file_open(const Glib::ustring &uri, } } else { if (need_fix_guides) { - // HACK: Scaling the document does not seem to cause - // grids defined in document units to be updated. - // This forces an update. if(is_extension){ xy->Scale( Geom::Scale(ratio,ratio).inverse() ); } else { + // HACK: Scaling the document does not seem to cause + // grids defined in document units to be updated. + // This forces an update. xy->Scale( Geom::Scale(1,1) ); } } } } } + } // If SPNamedView + + SPDefs *defs = dynamic_cast(child); + if (defs && need_fix_box3d) { + for (SPObject *child = defs->firstChild() ; child; child = child->getNext() ) { + Persp3D* persp3d = dynamic_cast(child); + if (persp3d) { + std::vector tokens; + + const gchar* vp_x = persp3d->getAttribute("inkscape:vp_x"); + const gchar* vp_y = persp3d->getAttribute("inkscape:vp_y"); + const gchar* vp_z = persp3d->getAttribute("inkscape:vp_z"); + const gchar* vp_o = persp3d->getAttribute("inkscape:persp3d-origin"); + // std::cout << "Found Persp3d: " + // << " vp_x: " << vp_x + // << " vp_y: " << vp_y + // << " vp_z: " << vp_z << std::endl; + Proj::Pt2 pt_x (vp_x); + Proj::Pt2 pt_y (vp_y); + Proj::Pt2 pt_z (vp_z); + Proj::Pt2 pt_o (vp_o); + pt_x = pt_x * (1.0/ratio); + pt_y = pt_y * (1.0/ratio); + pt_z = pt_z * (1.0/ratio); + pt_o = pt_o * (1.0/ratio); + persp3d->setAttribute("inkscape:vp_x",pt_x.coord_string()); + persp3d->setAttribute("inkscape:vp_y",pt_y.coord_string()); + persp3d->setAttribute("inkscape:vp_z",pt_z.coord_string()); + persp3d->setAttribute("inkscape:persp3d-origin",pt_o.coord_string()); + } + } } - } // Look for SPNamedView loop + } // Look for SPNamedView and SPDefs loop + // desktop->getDocument()->ensureUpToDate(); // Does not update box3d! DocumentUndo::done(desktop->getDocument(), SP_VERB_NONE, _("Update Document")); } // If old Inkscape version -- cgit v1.2.3 From f63c3282a4eceddf5d0e585980c6d7369cb22c1b Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 15 Dec 2016 12:26:38 +0100 Subject: Fixes for internal document scaling and add a second test option. (bzr r15325) --- src/file.cpp | 157 ++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 124 insertions(+), 33 deletions(-) (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp index eae3ddd17..0ea6486e4 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -69,6 +69,7 @@ #include "selection-chemistry.h" #include "persp3d.h" #include "proj_pt.h" +#include "ui/shape-editor.h" #include @@ -357,7 +358,7 @@ bool sp_file_open(const Glib::ustring &uri, bool need_fix_guides = false; bool need_fix_grid_mm = false; bool need_fix_box3d = false; - bool is_extension = false; + bool did_scaling = false; // Check if potentially need viewbox or unit fix switch (root->width.unit) { @@ -424,25 +425,27 @@ bool sp_file_open(const Glib::ustring &uri, backupButton.show(); scaleDialog.get_content_area()->pack_start(backupButton, false, false, 20); - scaleDialog.add_button("Set 'viewBox'", 1); - scaleDialog.add_button("Scale elements", 2); - scaleDialog.add_button("Ignore", 3); - scaleDialog.add_button("Test", 4); + scaleDialog.add_button(_("Set 'viewBox'"), 1); + scaleDialog.add_button(_("Scale elements"), 2); + scaleDialog.add_button(_("Ignore"), 3); + scaleDialog.add_button("Scale test - group", 4); + scaleDialog.add_button("Scale test - children", 5); gint response = scaleDialog.run(); bool backup = backupButton.get_active(); + if ( backup && response != 3) { + sp_file_save_backup( uri ); + } + if (response == 1) { - if (backup) { - sp_file_save_backup( uri ); - } + doc->setViewBox(Geom::Rect::from_xywh( 0, 0, doc->getWidth().value("px") * ratio, doc->getHeight().value("px") * ratio)); + } else if (response == 2 ) { - if (backup) { - sp_file_save_backup( uri ); - } + std::list effects; Inkscape::Extension::db.get_effect_list(effects); std::list::iterator it = effects.begin(); @@ -459,12 +462,17 @@ bool sp_file_open(const Glib::ustring &uri, if (!did) { std::cerr << "sp_file_open: Failed to find dpi90to96 extension." << std::endl; } - is_extension = true; + did_scaling = true; + } else if (response == 4) { - if (backup) { - sp_file_save_backup( uri ); - } + // Save preferences + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive",true); + bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true); + + prefs->setBool("options/kbselection/onlysensitive", false); + prefs->setBool("options/kbselection/onlyvisible", false); Inkscape::Selection *selection = desktop->getSelection(); Inkscape::SelectionHelper::selectAllInAll( desktop ); @@ -475,16 +483,46 @@ bool sp_file_open(const Glib::ustring &uri, } else { std::cerr << "sp_file_open: Failed to get group!" << std::endl; } + selection->clear(); + selection->add( group ); selection->ungroup(); selection->clear(); - is_extension = true; + + prefs->setBool("options/kbselection/onlysensitive", onlysensitive); + prefs->setBool("options/kbselection/onlyvisible", onlyvisible ); + + did_scaling = true; + + } else if (response == 5) { + + // Save preferences + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + bool transform_stroke = prefs->getBool("/options/transform/stroke", true); + bool transform_rectcorners = prefs->getBool("/options/transform/rectcorners", true); + bool transform_pattern = prefs->getBool("/options/transform/pattern", true); + bool transform_gradient = prefs->getBool("/options/transform/gradient", true); + + prefs->setBool("/options/transform/stroke", true); + prefs->setBool("/options/transform/rectcorners", true); + prefs->setBool("/options/transform/pattern", true); + prefs->setBool("/options/transform/gradient", true); + + Inkscape::UI::ShapeEditor::blockSetItem(true); + doc->getRoot()->scaleChildItemsRec(Geom::Scale(1/ratio),Geom::Point(0, 0), false); + Inkscape::UI::ShapeEditor::blockSetItem(false); + + // Restore preferences + prefs->setBool("/options/transform/stroke", transform_stroke); + prefs->setBool("/options/transform/rectcorners", transform_rectcorners); + prefs->setBool("/options/transform/pattern", transform_pattern); + prefs->setBool("/options/transform/gradient", transform_gradient); } need_fix_box3d = true; need_fix_guides = true; // Always fix guides } - if (need_fix_units) { + else if (need_fix_units) { Glib::ustring msg = ( "Old Inkscape files use 1in == 90px. CSS requires 1in == 96px.\n" "Drawings meant to match a physical size (e.g. Letter or A4)\n" @@ -502,17 +540,20 @@ bool sp_file_open(const Glib::ustring &uri, scaleDialog.get_content_area()->pack_start(backupButton, false, false, 20); backupButton.show(); - scaleDialog.add_button("Set 'viewBox'", 1); - scaleDialog.add_button("Scale elements", 2); - scaleDialog.add_button("Ignore", 3); - scaleDialog.add_button("Test", 4); + scaleDialog.add_button(_("Set 'viewBox'"), 1); + scaleDialog.add_button(_("Scale elements"), 2); + scaleDialog.add_button(_("Ignore"), 3); + scaleDialog.add_button("Scale test - group", 4); + scaleDialog.add_button("Scale test - children", 5); gint response = scaleDialog.run(); bool backup = backupButton.get_active(); + if ( backup && response != 3) { + sp_file_save_backup( uri ); + } + if (response == 1) { - if (backup) { - sp_file_save_backup( uri ); - } + if (!root->viewBox_set) { doc->setViewBox(Geom::Rect::from_xywh( 0, 0, @@ -527,10 +568,9 @@ bool sp_file_open(const Glib::ustring &uri, need_fix_guides = true; // Only fix guides if drawing scaled need_fix_box3d = true; + } else if (response == 2) { - if (backup) { - sp_file_save_backup( uri ); - } + std::list effects; Inkscape::Extension::db.get_effect_list(effects); std::list::iterator it = effects.begin(); @@ -548,11 +588,9 @@ bool sp_file_open(const Glib::ustring &uri, std::cerr << "sp_file_open: Failed to find dpi90to96 extension." << std::endl; } need_fix_guides = true; // Only fix guides if drawing scaled - is_extension = true; + did_scaling = true; + } else if (response == 4) { - if (backup) { - sp_file_save_backup( uri ); - } Inkscape::Util::Quantity width = Inkscape::Util::Quantity(doc->getWidth().value("px")/ratio, "px" ); @@ -561,6 +599,15 @@ bool sp_file_open(const Glib::ustring &uri, doc->setWidthAndHeight( width, height, false ); if (!root->viewBox_set) { + + // Save preferences + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive",true); + bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true); + + prefs->setBool("options/kbselection/onlysensitive", false); + prefs->setBool("options/kbselection/onlyvisible", false); + Inkscape::Selection *selection = desktop->getSelection(); Inkscape::SelectionHelper::selectAllInAll( desktop ); selection->group(); @@ -570,9 +617,53 @@ bool sp_file_open(const Glib::ustring &uri, } else { std::cerr << "sp_file_open: Failed to get group!" << std::endl; } + selection->clear(); + selection->add( group ); selection->ungroup(); selection->clear(); - is_extension = true; + + prefs->setBool("options/kbselection/onlysensitive", onlysensitive); + prefs->setBool("options/kbselection/onlyvisible", onlyvisible ); + + did_scaling = true; + } + + need_fix_box3d = true; + need_fix_guides = true; // Only fix guides if drawing scaled + + } else if (response == 5) { + + Inkscape::Util::Quantity width = + Inkscape::Util::Quantity(doc->getWidth().value("px")/ratio, "px" ); + Inkscape::Util::Quantity height = + Inkscape::Util::Quantity(doc->getHeight().value("px")/ratio,"px" ); + doc->setWidthAndHeight( width, height, false ); + + if (!root->viewBox_set) { + + // Save preferences + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + bool transform_stroke = prefs->getBool("/options/transform/stroke", true); + bool transform_rectcorners = prefs->getBool("/options/transform/rectcorners", true); + bool transform_pattern = prefs->getBool("/options/transform/pattern", true); + bool transform_gradient = prefs->getBool("/options/transform/gradient", true); + + prefs->setBool("/options/transform/stroke", true); + prefs->setBool("/options/transform/rectcorners", true); + prefs->setBool("/options/transform/pattern", true); + prefs->setBool("/options/transform/gradient", true); + + Inkscape::UI::ShapeEditor::blockSetItem(true); + doc->getRoot()->scaleChildItemsRec(Geom::Scale(1/ratio),Geom::Point(0, 0), false); + Inkscape::UI::ShapeEditor::blockSetItem(false); + + // Restore preferences + prefs->setBool("/options/transform/stroke", transform_stroke); + prefs->setBool("/options/transform/rectcorners", transform_rectcorners); + prefs->setBool("/options/transform/pattern", transform_pattern); + prefs->setBool("/options/transform/gradient", transform_gradient); + + did_scaling = true; } need_fix_box3d = true; @@ -623,7 +714,7 @@ bool sp_file_open(const Glib::ustring &uri, } } else { if (need_fix_guides) { - if(is_extension){ + if(did_scaling){ xy->Scale( Geom::Scale(ratio,ratio).inverse() ); } else { // HACK: Scaling the document does not seem to cause -- cgit v1.2.3 From ed2be0e991ff7acd375f5b7ae0e51fa8a4b88a23 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 15 Dec 2016 12:46:41 +0100 Subject: Fix crash from last commit due to bad preference path. (bzr r15326) --- src/file.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp index 0ea6486e4..d499a0175 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -471,8 +471,8 @@ bool sp_file_open(const Glib::ustring &uri, bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive",true); bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true); - prefs->setBool("options/kbselection/onlysensitive", false); - prefs->setBool("options/kbselection/onlyvisible", false); + prefs->setBool("/options/kbselection/onlysensitive", false); + prefs->setBool("/options/kbselection/onlyvisible", false); Inkscape::Selection *selection = desktop->getSelection(); Inkscape::SelectionHelper::selectAllInAll( desktop ); @@ -488,8 +488,8 @@ bool sp_file_open(const Glib::ustring &uri, selection->ungroup(); selection->clear(); - prefs->setBool("options/kbselection/onlysensitive", onlysensitive); - prefs->setBool("options/kbselection/onlyvisible", onlyvisible ); + prefs->setBool("/options/kbselection/onlysensitive", onlysensitive); + prefs->setBool("/options/kbselection/onlyvisible", onlyvisible ); did_scaling = true; @@ -605,8 +605,8 @@ bool sp_file_open(const Glib::ustring &uri, bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive",true); bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true); - prefs->setBool("options/kbselection/onlysensitive", false); - prefs->setBool("options/kbselection/onlyvisible", false); + prefs->setBool("/options/kbselection/onlysensitive", false); + prefs->setBool("/options/kbselection/onlyvisible", false); Inkscape::Selection *selection = desktop->getSelection(); Inkscape::SelectionHelper::selectAllInAll( desktop ); @@ -622,8 +622,8 @@ bool sp_file_open(const Glib::ustring &uri, selection->ungroup(); selection->clear(); - prefs->setBool("options/kbselection/onlysensitive", onlysensitive); - prefs->setBool("options/kbselection/onlyvisible", onlyvisible ); + prefs->setBool("/options/kbselection/onlysensitive", onlysensitive); + prefs->setBool("/options/kbselection/onlyvisible", onlyvisible ); did_scaling = true; } -- cgit v1.2.3 From bab8da6749ec64e35e737e0fab5647f0b39f2519 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 15 Dec 2016 18:36:50 +0100 Subject: Save state of backup button. (bzr r15327) --- src/file.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp index d499a0175..8f283e1f8 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -406,6 +406,8 @@ bool sp_file_open(const Glib::ustring &uri, // std::cout << "Absolute SVG units in root? " << (need_fix_viewbox?"true":"false") << std::endl; // std::cout << "User units in root? " << (need_fix_units ?"true":"false") << std::endl; + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if (!root->viewBox_set && need_fix_viewbox) { Glib::ustring msg = _( @@ -418,13 +420,14 @@ bool sp_file_open(const Glib::ustring &uri, Gtk::Label info; info.set_markup(msg.c_str()); info.show(); - scaleDialog.get_content_area()->pack_start(info, false, false, 20); + Gtk::CheckButton backupButton( _("Create backup file (in same directory).") ); - backupButton.set_active(); + bool backup = prefs->getBool("/options/dpifixbackup", true); + backupButton.set_active( backup ); backupButton.show(); - scaleDialog.get_content_area()->pack_start(backupButton, false, false, 20); + scaleDialog.add_button(_("Set 'viewBox'"), 1); scaleDialog.add_button(_("Scale elements"), 2); scaleDialog.add_button(_("Ignore"), 3); @@ -432,7 +435,9 @@ bool sp_file_open(const Glib::ustring &uri, scaleDialog.add_button("Scale test - children", 5); gint response = scaleDialog.run(); - bool backup = backupButton.get_active(); + backup = backupButton.get_active(); + prefs->setBool("/options/dpifixbackup", backup); + if ( backup && response != 3) { sp_file_save_backup( uri ); } @@ -467,7 +472,6 @@ bool sp_file_open(const Glib::ustring &uri, } else if (response == 4) { // Save preferences - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive",true); bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true); @@ -496,7 +500,6 @@ bool sp_file_open(const Glib::ustring &uri, } else if (response == 5) { // Save preferences - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool transform_stroke = prefs->getBool("/options/transform/stroke", true); bool transform_rectcorners = prefs->getBool("/options/transform/rectcorners", true); bool transform_pattern = prefs->getBool("/options/transform/pattern", true); @@ -537,8 +540,10 @@ bool sp_file_open(const Glib::ustring &uri, scaleDialog.get_content_area()->pack_start(info, false, false, 20); Gtk::CheckButton backupButton( _("Create backup file (in same directory).") ); - scaleDialog.get_content_area()->pack_start(backupButton, false, false, 20); + bool backup = prefs->getBool("/options/dpifixbackup", true); + backupButton.set_active( backup ); backupButton.show(); + scaleDialog.get_content_area()->pack_start(backupButton, false, false, 20); scaleDialog.add_button(_("Set 'viewBox'"), 1); scaleDialog.add_button(_("Scale elements"), 2); @@ -547,7 +552,9 @@ bool sp_file_open(const Glib::ustring &uri, scaleDialog.add_button("Scale test - children", 5); gint response = scaleDialog.run(); - bool backup = backupButton.get_active(); + backup = backupButton.get_active(); + prefs->setBool("/options/dpifixbackup", backup); + if ( backup && response != 3) { sp_file_save_backup( uri ); } -- cgit v1.2.3 From 953f0452dacbd35f599916723549825e6b3d7f50 Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Wed, 21 Dec 2016 01:05:37 +0100 Subject: Add string translatable pointed by Maren (bzr r15345) --- src/file.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp index 8f283e1f8..6f7c52123 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -526,7 +526,7 @@ bool sp_file_open(const Glib::ustring &uri, } else if (need_fix_units) { - Glib::ustring msg = ( + Glib::ustring msg = _( "Old Inkscape files use 1in == 90px. CSS requires 1in == 96px.\n" "Drawings meant to match a physical size (e.g. Letter or A4)\n" "will be too small. Scaling the drawing can correct for this.\n" -- cgit v1.2.3 From 223ba2e5e0060a4fef243fb3249c946168698e59 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Mon, 26 Dec 2016 23:00:38 +0000 Subject: Fix header inclusion ordering (bzr r15365) --- src/file.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp index 6f7c52123..756bc55bb 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -31,6 +31,8 @@ # include "config.h" #endif +#include + #include "ui/dialog/ocaldialogs.h" #include "desktop.h" @@ -71,8 +73,6 @@ #include "proj_pt.h" #include "ui/shape-editor.h" -#include - using Inkscape::DocumentUndo; #ifdef WITH_GNOME_VFS -- cgit v1.2.3 From 66095b4a7c8d8c38ffe727490f90de088f488574 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Tue, 10 Jan 2017 13:44:57 +0100 Subject: Another scaling option to test. (bzr r15406) --- src/file.cpp | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 2 deletions(-) (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp index 756bc55bb..629e8205b 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -433,6 +433,7 @@ bool sp_file_open(const Glib::ustring &uri, scaleDialog.add_button(_("Ignore"), 3); scaleDialog.add_button("Scale test - group", 4); scaleDialog.add_button("Scale test - children", 5); + scaleDialog.add_button("Scale test - all", 6); gint response = scaleDialog.run(); backup = backupButton.get_active(); @@ -519,9 +520,34 @@ bool sp_file_open(const Glib::ustring &uri, prefs->setBool("/options/transform/rectcorners", transform_rectcorners); prefs->setBool("/options/transform/pattern", transform_pattern); prefs->setBool("/options/transform/gradient", transform_gradient); + + } else if (response == 6) { + + std::cout << "Respons 6a" << std::endl; + + // Save preferences + bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive",true); + bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true); + + prefs->setBool("/options/kbselection/onlysensitive", false); + prefs->setBool("/options/kbselection/onlyvisible", false); + + Inkscape::Selection *selection = desktop->getSelection(); + Inkscape::SelectionHelper::selectAllInAll( desktop ); + + double height = root->height.computed; + selection->setScaleRelative( Geom::Point(0,height), Geom::Scale(96.0/90.0,96.0/90.0) ); + std::cout << " scaling: " << 96.0/90.0 << std::endl; + selection->clear(); + + prefs->setBool("/options/kbselection/onlysensitive", onlysensitive); + prefs->setBool("/options/kbselection/onlyvisible", onlyvisible ); + + did_scaling = true; + } - need_fix_box3d = true; + need_fix_box3d = false; // setScaleRelative() handles box3d need_fix_guides = true; // Always fix guides } @@ -550,6 +576,7 @@ bool sp_file_open(const Glib::ustring &uri, scaleDialog.add_button(_("Ignore"), 3); scaleDialog.add_button("Scale test - group", 4); scaleDialog.add_button("Scale test - children", 5); + scaleDialog.add_button("Scale test - all", 6); gint response = scaleDialog.run(); backup = backupButton.get_active(); @@ -671,9 +698,47 @@ bool sp_file_open(const Glib::ustring &uri, prefs->setBool("/options/transform/gradient", transform_gradient); did_scaling = true; + } - need_fix_box3d = true; + } else if (response == 6) { + + std::cout << "Response 6b" << std::endl; + double old_height = root->height.computed; + Inkscape::Util::Quantity width = + Inkscape::Util::Quantity(doc->getWidth().value("px")/ratio, "px" ); + Inkscape::Util::Quantity height = + Inkscape::Util::Quantity(doc->getHeight().value("px")/ratio,"px" ); + doc->setWidthAndHeight( width, height, false ); + + if (!root->viewBox_set) { + + // Save preferences + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive",true); + bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true); + + prefs->setBool("/options/kbselection/onlysensitive", false); + prefs->setBool("/options/kbselection/onlyvisible", false); + + Inkscape::Selection *selection = desktop->getSelection(); + Inkscape::SelectionHelper::selectAllInAll( desktop ); + std::cout << " scaling: " << 96.0/90.0 << std::endl; + double height = root->height.computed; + + // So far we have just enlarged the drawing but due to the + // inverted coordinate system we must scale around the old + // height position. + selection->setScaleRelative( Geom::Point(0,old_height), Geom::Scale(96.0/90.0,96.0/90.0) ); + selection->clear(); + + prefs->setBool("/options/kbselection/onlysensitive", onlysensitive); + prefs->setBool("/options/kbselection/onlyvisible", onlyvisible ); + + did_scaling = true; + } + + need_fix_box3d = false; // setScaleRelative() handls box3s need_fix_guides = true; // Only fix guides if drawing scaled } else { -- cgit v1.2.3 From 3d488c4a3091d4e14c045e85aa20b1ec96b479c0 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Tue, 10 Jan 2017 13:55:18 +0100 Subject: Remove debugging lines from last commit. (bzr r15407) --- src/file.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp index 629e8205b..9e96361c3 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -523,8 +523,6 @@ bool sp_file_open(const Glib::ustring &uri, } else if (response == 6) { - std::cout << "Respons 6a" << std::endl; - // Save preferences bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive",true); bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true); @@ -537,7 +535,6 @@ bool sp_file_open(const Glib::ustring &uri, double height = root->height.computed; selection->setScaleRelative( Geom::Point(0,height), Geom::Scale(96.0/90.0,96.0/90.0) ); - std::cout << " scaling: " << 96.0/90.0 << std::endl; selection->clear(); prefs->setBool("/options/kbselection/onlysensitive", onlysensitive); @@ -703,7 +700,6 @@ bool sp_file_open(const Glib::ustring &uri, } else if (response == 6) { - std::cout << "Response 6b" << std::endl; double old_height = root->height.computed; Inkscape::Util::Quantity width = Inkscape::Util::Quantity(doc->getWidth().value("px")/ratio, "px" ); @@ -723,7 +719,6 @@ bool sp_file_open(const Glib::ustring &uri, Inkscape::Selection *selection = desktop->getSelection(); Inkscape::SelectionHelper::selectAllInAll( desktop ); - std::cout << " scaling: " << 96.0/90.0 << std::endl; double height = root->height.computed; // So far we have just enlarged the drawing but due to the -- cgit v1.2.3 From 8907ced418b6c40782d2d2c0f3f944edcb3c08df Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Fri, 20 Jan 2017 20:19:49 +0100 Subject: Fixes bugs in copy LPE's. #1656093:Paste path effect doesn't work on 0.92 and #1656527:Copy & paste of group with shaped path corrupts it, in v0.92 Fixed bugs: - https://launchpad.net/bugs/1656093 - https://launchpad.net/bugs/1656527 (bzr r15426) --- src/file.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp index 9e96361c3..e8248bb8e 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1631,8 +1631,12 @@ void sp_import_document(SPDesktop *desktop, SPDocument *clipdoc, bool in_place) 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); + SPObject * pasted = desktop->currentLayer()->appendChildRepr(obj_copy); Inkscape::GC::release(obj_copy); + SPLPEItem * pasted_lpe_item = dynamic_cast(pasted); + if (pasted_lpe_item){ + pasted_lpe_item->forkPathEffectsIfNecessary(1); + } pasted_objects_not.push_back(obj_copy); } Inkscape::Selection *selection = desktop->getSelection(); -- cgit v1.2.3 From 014489163050d8abe9e5c4949fb80f3c21b1c17b Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 13 Mar 2017 15:22:22 +0100 Subject: Replace rectangle based zooming by affine based zooming. This allows a rotation to be included in the drawing to window mapping. General code cleanup. Added documentation. Any change to zooming behavior is probably a bug. (bzr r15592) --- src/file.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp index 6613b1e65..fc9ce6b19 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -908,7 +908,7 @@ void sp_file_revert_dialog() reverted = sp_file_open(uri,NULL); if (reverted) { // restore zoom and view - desktop->zoom_absolute(c[Geom::X], c[Geom::Y], zoom); + desktop->zoom_absolute_center_point(c, zoom); } } else { reverted = false; -- cgit v1.2.3 From f47466c701b2256b2ce232f6d311d2be47136eab Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 20 Mar 2017 21:12:31 +0100 Subject: Implement rotation via desktop to window affine. Remove rotation via viewbox. Still some work to do... (bzr r15603) --- src/file.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp index fc9ce6b19..795df433d 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -293,12 +293,10 @@ bool sp_file_open(const Glib::ustring &uri, bool replace_empty) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; - Inkscape::Display::TemporaryItem *page_border_rotated = NULL; if (desktop) { desktop->setWaitingCursor(); - page_border_rotated = sp_document_namedview(desktop->getDocument(), NULL)->page_border_rotated; } - + SPDocument *doc = NULL; bool cancelled = false; try { @@ -317,6 +315,7 @@ bool sp_file_open(const Glib::ustring &uri, } if (doc) { + SPDocument *existing = desktop ? desktop->getDocument() : NULL; if (existing && existing->virgin && replace_empty) { @@ -324,7 +323,6 @@ bool sp_file_open(const Glib::ustring &uri, doc->ensureUpToDate(); // TODO this will trigger broken link warnings, etc. desktop->change_document(doc); doc->emitResizedSignal(doc->getWidth().value("px"), doc->getHeight().value("px")); - desktop->remove_temporary_canvasitem(page_border_rotated); } else { // create a whole new desktop and window SPViewWidget *dtw = sp_desktop_widget_new(sp_document_namedview(doc, NULL)); // TODO this will trigger broken link warnings, etc. -- cgit v1.2.3 From 9a1906ee1091744357b32e0159b6019dc6476544 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Mon, 5 Jun 2017 00:58:45 +0200 Subject: Porting the pre-92 file update message from 0.92.x to trunk: New dialog when opening pre-0.92 files (with 90 dpi). I implemented it mostly based on mizmo's UI proposal (thanks!), with additional inputs from su_v with a few bugfixes from jabiertxof Also adds a commandline option --convert-dpi-method=[none|scale-viewbox|scale-document] to be able to batch convert files. Fixed bugs: - https://launchpad.net/bugs/1659229 (bzr r15703.1.26) --- src/file.cpp | 536 +---------------------------------------------------------- 1 file changed, 4 insertions(+), 532 deletions(-) (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp index 795df433d..43a9c6f5b 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -65,13 +65,6 @@ #include "event-log.h" #include "ui/dialog/font-substitution.h" -// For updating old Inkscape SVG files -#include "display/canvas-grid.h" -#include "sp-guide.h" -#include "selection-chemistry.h" -#include "persp3d.h" -#include "proj_pt.h" -#include "ui/shape-editor.h" using Inkscape::DocumentUndo; @@ -240,42 +233,6 @@ sp_file_exit() } -// Quick and dirty internal backup function -bool sp_file_save_backup( Glib::ustring uri ) { - - Glib::ustring out = uri; - out.insert(out.find(".svg"),"_backup"); - - FILE *filein = Inkscape::IO::fopen_utf8name(uri.c_str(), "rb"); - if (!filein) { - std::cerr << "sp_file_save_backup: failed to open: " << uri << std::endl; - return false; - } - - FILE *fileout = Inkscape::IO::fopen_utf8name(out.c_str(), "wb"); - if (!fileout) { - std::cerr << "sp_file_save_backup: failed to open: " << out << std::endl; - fclose( filein ); - return false; - } - - int ch; - while ((ch = fgetc(filein)) != EOF) { - fputc(ch, fileout); - } - fflush(fileout); - - bool return_value = true; - if (ferror(fileout)) { - std::cerr << "sp_file_save_backup: error when writing to: " << out << std::endl; - return_value = false; - } - - fclose(filein); - fclose(fileout); - - return return_value; -} /*###################### ## O P E N @@ -342,497 +299,12 @@ bool sp_file_open(const Glib::ustring &uri, root->original.svg = root->version.svg; if (INKSCAPE.use_gui()) { - - // See if we need to offer the user a fix for the 90->96 px per inch change. - // std::cout << "SPFileOpen:" << std::endl; - // std::cout << " Version: " << sp_version_to_string(root->version.inkscape) << std::endl; - - if ( sp_version_inside_range( root->version.inkscape, 0, 1, 0, 92 ) ) { - - // std::cout << " SVG file from old Inkscape version detected: " - // << sp_version_to_string(root->version.inkscape) << std::endl; - static const double ratio = 90.0/96.0; - - bool need_fix_viewbox = false; - bool need_fix_units = false; - bool need_fix_guides = false; - bool need_fix_grid_mm = false; - bool need_fix_box3d = false; - bool did_scaling = false; - - // Check if potentially need viewbox or unit fix - switch (root->width.unit) { - case SP_CSS_UNIT_PC: - case SP_CSS_UNIT_PT: - case SP_CSS_UNIT_MM: - case SP_CSS_UNIT_CM: - case SP_CSS_UNIT_IN: - need_fix_viewbox = true; - break; - case SP_CSS_UNIT_NONE: - case SP_CSS_UNIT_PX: - need_fix_units = true; - break; - case SP_CSS_UNIT_EM: - case SP_CSS_UNIT_EX: - case SP_CSS_UNIT_PERCENT: - // OK - break; - default: - std::cerr << "sp_file_open: Unhandled width unit!" << std::endl; - } - - switch (root->height.unit) { - case SP_CSS_UNIT_PC: - case SP_CSS_UNIT_PT: - case SP_CSS_UNIT_MM: - case SP_CSS_UNIT_CM: - case SP_CSS_UNIT_IN: - need_fix_viewbox = true; - break; - case SP_CSS_UNIT_NONE: - case SP_CSS_UNIT_PX: - need_fix_units = true; - break; - case SP_CSS_UNIT_EM: - case SP_CSS_UNIT_EX: - case SP_CSS_UNIT_PERCENT: - // OK - break; - default: - std::cerr << "sp_file_open: Unhandled height unit!" << std::endl; - } - - // std::cout << "Absolute SVG units in root? " << (need_fix_viewbox?"true":"false") << std::endl; - // std::cout << "User units in root? " << (need_fix_units ?"true":"false") << std::endl; - - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - - if (!root->viewBox_set && need_fix_viewbox) { - - Glib::ustring msg = _( - "Old Inkscape files use 1in == 90px. CSS requires 1in == 96px.\n" - "Drawing elements may be too small. This can be corrected by\n" - "either setting the SVG 'viewBox' to compensate or by scaling\n" - "all the elements in the drawing."); - Gtk::Dialog scaleDialog( _("Old Inkscape file detected (90 DPI)"), false); - - Gtk::Label info; - info.set_markup(msg.c_str()); - info.show(); - scaleDialog.get_content_area()->pack_start(info, false, false, 20); - - Gtk::CheckButton backupButton( _("Create backup file (in same directory).") ); - bool backup = prefs->getBool("/options/dpifixbackup", true); - backupButton.set_active( backup ); - backupButton.show(); - scaleDialog.get_content_area()->pack_start(backupButton, false, false, 20); - - scaleDialog.add_button(_("Set 'viewBox'"), 1); - scaleDialog.add_button(_("Scale elements"), 2); - scaleDialog.add_button(_("Ignore"), 3); - scaleDialog.add_button("Scale test - group", 4); - scaleDialog.add_button("Scale test - children", 5); - scaleDialog.add_button("Scale test - all", 6); - - gint response = scaleDialog.run(); - backup = backupButton.get_active(); - prefs->setBool("/options/dpifixbackup", backup); - - if ( backup && response != 3) { - sp_file_save_backup( uri ); - } - - if (response == 1) { - - doc->setViewBox(Geom::Rect::from_xywh( - 0, 0, - doc->getWidth().value("px") * ratio, - doc->getHeight().value("px") * ratio)); - - } else if (response == 2 ) { - - std::list effects; - Inkscape::Extension::db.get_effect_list(effects); - std::list::iterator it = effects.begin(); - bool did = false; - while (it != effects.end()) { - if (strcmp((*it)->get_id(), "org.inkscape.dpi90to96") == 0) { - Inkscape::UI::View::View *view = desktop; - (*it)->effect(view); - did = true; - break; - } - ++it; - } - if (!did) { - std::cerr << "sp_file_open: Failed to find dpi90to96 extension." << std::endl; - } - did_scaling = true; - - } else if (response == 4) { - - // Save preferences - bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive",true); - bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true); - - prefs->setBool("/options/kbselection/onlysensitive", false); - prefs->setBool("/options/kbselection/onlyvisible", false); - - Inkscape::Selection *selection = desktop->getSelection(); - Inkscape::SelectionHelper::selectAllInAll( desktop ); - selection->group(); - SPItem * group = selection->singleItem(); - if (group) { - group->setAttribute("transform","scale(1.06666667,1.06666667)"); - } else { - std::cerr << "sp_file_open: Failed to get group!" << std::endl; - } - selection->clear(); - selection->add( group ); - selection->ungroup(); - selection->clear(); - - prefs->setBool("/options/kbselection/onlysensitive", onlysensitive); - prefs->setBool("/options/kbselection/onlyvisible", onlyvisible ); - - did_scaling = true; - - } else if (response == 5) { - - // Save preferences - bool transform_stroke = prefs->getBool("/options/transform/stroke", true); - bool transform_rectcorners = prefs->getBool("/options/transform/rectcorners", true); - bool transform_pattern = prefs->getBool("/options/transform/pattern", true); - bool transform_gradient = prefs->getBool("/options/transform/gradient", true); - - prefs->setBool("/options/transform/stroke", true); - prefs->setBool("/options/transform/rectcorners", true); - prefs->setBool("/options/transform/pattern", true); - prefs->setBool("/options/transform/gradient", true); - - Inkscape::UI::ShapeEditor::blockSetItem(true); - doc->getRoot()->scaleChildItemsRec(Geom::Scale(1/ratio),Geom::Point(0, 0), false); - Inkscape::UI::ShapeEditor::blockSetItem(false); - - // Restore preferences - prefs->setBool("/options/transform/stroke", transform_stroke); - prefs->setBool("/options/transform/rectcorners", transform_rectcorners); - prefs->setBool("/options/transform/pattern", transform_pattern); - prefs->setBool("/options/transform/gradient", transform_gradient); - - } else if (response == 6) { - - // Save preferences - bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive",true); - bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true); - - prefs->setBool("/options/kbselection/onlysensitive", false); - prefs->setBool("/options/kbselection/onlyvisible", false); - - Inkscape::Selection *selection = desktop->getSelection(); - Inkscape::SelectionHelper::selectAllInAll( desktop ); - - double height = root->height.computed; - selection->setScaleRelative( Geom::Point(0,height), Geom::Scale(96.0/90.0,96.0/90.0) ); - selection->clear(); - - prefs->setBool("/options/kbselection/onlysensitive", onlysensitive); - prefs->setBool("/options/kbselection/onlyvisible", onlyvisible ); - - did_scaling = true; - - } - - need_fix_box3d = false; // setScaleRelative() handles box3d - need_fix_guides = true; // Always fix guides - } - - else if (need_fix_units) { - Glib::ustring msg = _( - "Old Inkscape files use 1in == 90px. CSS requires 1in == 96px.\n" - "Drawings meant to match a physical size (e.g. Letter or A4)\n" - "will be too small. Scaling the drawing can correct for this.\n" - "Internal scaling can be handled either by setting the SVG 'viewBox'\n" - "attribute to compensate or by scaling all objects in the drawing."); - Gtk::Dialog scaleDialog( _("Old Inkscape file detected (90 DPI)"), false); - - Gtk::Label info; - info.set_markup(msg.c_str()); - info.show(); - scaleDialog.get_content_area()->pack_start(info, false, false, 20); - - Gtk::CheckButton backupButton( _("Create backup file (in same directory).") ); - bool backup = prefs->getBool("/options/dpifixbackup", true); - backupButton.set_active( backup ); - backupButton.show(); - scaleDialog.get_content_area()->pack_start(backupButton, false, false, 20); - - scaleDialog.add_button(_("Set 'viewBox'"), 1); - scaleDialog.add_button(_("Scale elements"), 2); - scaleDialog.add_button(_("Ignore"), 3); - scaleDialog.add_button("Scale test - group", 4); - scaleDialog.add_button("Scale test - children", 5); - scaleDialog.add_button("Scale test - all", 6); - - gint response = scaleDialog.run(); - backup = backupButton.get_active(); - prefs->setBool("/options/dpifixbackup", backup); - - if ( backup && response != 3) { - sp_file_save_backup( uri ); - } - - if (response == 1) { - - if (!root->viewBox_set) { - doc->setViewBox(Geom::Rect::from_xywh( - 0, 0, - doc->getWidth().value("px"), - doc->getHeight().value("px"))); - } - Inkscape::Util::Quantity width = - Inkscape::Util::Quantity(doc->getWidth().value("px")/ratio, "px" ); - Inkscape::Util::Quantity height = - Inkscape::Util::Quantity(doc->getHeight().value("px")/ratio,"px" ); - doc->setWidthAndHeight( width, height, false ); - - need_fix_guides = true; // Only fix guides if drawing scaled - need_fix_box3d = true; - - } else if (response == 2) { - - std::list effects; - Inkscape::Extension::db.get_effect_list(effects); - std::list::iterator it = effects.begin(); - bool did = false; - while (it != effects.end()){ - if (strcmp((*it)->get_id(), "org.inkscape.dpi90to96") == 0) { - Inkscape::UI::View::View *view = desktop; - (*it)->effect(view); - did = true; - break; - } - ++it; - } - if (!did) { - std::cerr << "sp_file_open: Failed to find dpi90to96 extension." << std::endl; - } - need_fix_guides = true; // Only fix guides if drawing scaled - did_scaling = true; - - } else if (response == 4) { - - Inkscape::Util::Quantity width = - Inkscape::Util::Quantity(doc->getWidth().value("px")/ratio, "px" ); - Inkscape::Util::Quantity height = - Inkscape::Util::Quantity(doc->getHeight().value("px")/ratio,"px" ); - doc->setWidthAndHeight( width, height, false ); - - if (!root->viewBox_set) { - - // Save preferences - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive",true); - bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true); - - prefs->setBool("/options/kbselection/onlysensitive", false); - prefs->setBool("/options/kbselection/onlyvisible", false); - - Inkscape::Selection *selection = desktop->getSelection(); - Inkscape::SelectionHelper::selectAllInAll( desktop ); - selection->group(); - SPItem * group = selection->singleItem(); - if (group) { - group->setAttribute("transform","scale(1.06666667,1.06666667)"); - } else { - std::cerr << "sp_file_open: Failed to get group!" << std::endl; - } - selection->clear(); - selection->add( group ); - selection->ungroup(); - selection->clear(); - - prefs->setBool("/options/kbselection/onlysensitive", onlysensitive); - prefs->setBool("/options/kbselection/onlyvisible", onlyvisible ); - - did_scaling = true; - } - - need_fix_box3d = true; - need_fix_guides = true; // Only fix guides if drawing scaled - - } else if (response == 5) { - - Inkscape::Util::Quantity width = - Inkscape::Util::Quantity(doc->getWidth().value("px")/ratio, "px" ); - Inkscape::Util::Quantity height = - Inkscape::Util::Quantity(doc->getHeight().value("px")/ratio,"px" ); - doc->setWidthAndHeight( width, height, false ); - - if (!root->viewBox_set) { - - // Save preferences - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - bool transform_stroke = prefs->getBool("/options/transform/stroke", true); - bool transform_rectcorners = prefs->getBool("/options/transform/rectcorners", true); - bool transform_pattern = prefs->getBool("/options/transform/pattern", true); - bool transform_gradient = prefs->getBool("/options/transform/gradient", true); - - prefs->setBool("/options/transform/stroke", true); - prefs->setBool("/options/transform/rectcorners", true); - prefs->setBool("/options/transform/pattern", true); - prefs->setBool("/options/transform/gradient", true); - - Inkscape::UI::ShapeEditor::blockSetItem(true); - doc->getRoot()->scaleChildItemsRec(Geom::Scale(1/ratio),Geom::Point(0, 0), false); - Inkscape::UI::ShapeEditor::blockSetItem(false); - - // Restore preferences - prefs->setBool("/options/transform/stroke", transform_stroke); - prefs->setBool("/options/transform/rectcorners", transform_rectcorners); - prefs->setBool("/options/transform/pattern", transform_pattern); - prefs->setBool("/options/transform/gradient", transform_gradient); - - did_scaling = true; - - } - - } else if (response == 6) { - - double old_height = root->height.computed; - Inkscape::Util::Quantity width = - Inkscape::Util::Quantity(doc->getWidth().value("px")/ratio, "px" ); - Inkscape::Util::Quantity height = - Inkscape::Util::Quantity(doc->getHeight().value("px")/ratio,"px" ); - doc->setWidthAndHeight( width, height, false ); - - if (!root->viewBox_set) { - - // Save preferences - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive",true); - bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true); - - prefs->setBool("/options/kbselection/onlysensitive", false); - prefs->setBool("/options/kbselection/onlyvisible", false); - - Inkscape::Selection *selection = desktop->getSelection(); - Inkscape::SelectionHelper::selectAllInAll( desktop ); - double height = root->height.computed; - - // So far we have just enlarged the drawing but due to the - // inverted coordinate system we must scale around the old - // height position. - selection->setScaleRelative( Geom::Point(0,old_height), Geom::Scale(96.0/90.0,96.0/90.0) ); - selection->clear(); - - prefs->setBool("/options/kbselection/onlysensitive", onlysensitive); - prefs->setBool("/options/kbselection/onlyvisible", onlyvisible ); - - did_scaling = true; - } - - need_fix_box3d = false; // setScaleRelative() handls box3s - need_fix_guides = true; // Only fix guides if drawing scaled - - } else { - // Ignore - need_fix_grid_mm = true; - } - } - - // Fix guides and grids and perspective - for (SPObject *child = root->firstChild() ; child; child = child->getNext() ) { - SPNamedView *nv = dynamic_cast(child); - if (nv) { - if (need_fix_guides) { - // std::cout << "Fixing guides" << std::endl; - for (SPObject *child2 = nv->firstChild() ; child2; child2 = child2->getNext() ) { - SPGuide *gd = dynamic_cast(child2); - if (gd) { - gd->moveto( gd->getPoint() / ratio, true ); - } - } - } - - for(std::vector::const_iterator it=nv->grids.begin();it!=nv->grids.end();++it ) { - Inkscape::CanvasXYGrid *xy = dynamic_cast(*it); - if (xy) { - // std::cout << "A grid: " << xy->getSVGName() << std::endl; - // std::cout << " Origin: " << xy->origin - // << " Spacing: " << xy->spacing << std::endl; - // std::cout << (xy->isLegacy()?" Legacy":" Not Legacy") << std::endl; - Geom::Scale scale = doc->getDocumentScale(); - if (xy->isLegacy()) { - if (xy->isPixel()) { - if (need_fix_grid_mm) { - xy->Scale( Geom::Scale(1,1) ); // See note below - } else { - scale *= Geom::Scale(ratio,ratio); - xy->Scale( scale.inverse() ); /* *** */ - } - } else { - if (need_fix_grid_mm) { - xy->Scale( Geom::Scale(ratio,ratio) ); - } else { - xy->Scale( scale.inverse() ); /* *** */ - } - } - } else { - if (need_fix_guides) { - if(did_scaling){ - xy->Scale( Geom::Scale(ratio,ratio).inverse() ); - } else { - // HACK: Scaling the document does not seem to cause - // grids defined in document units to be updated. - // This forces an update. - xy->Scale( Geom::Scale(1,1) ); - } - } - } - } - } - } // If SPNamedView - - SPDefs *defs = dynamic_cast(child); - if (defs && need_fix_box3d) { - for (SPObject *child = defs->firstChild() ; child; child = child->getNext() ) { - Persp3D* persp3d = dynamic_cast(child); - if (persp3d) { - std::vector tokens; - - const gchar* vp_x = persp3d->getAttribute("inkscape:vp_x"); - const gchar* vp_y = persp3d->getAttribute("inkscape:vp_y"); - const gchar* vp_z = persp3d->getAttribute("inkscape:vp_z"); - const gchar* vp_o = persp3d->getAttribute("inkscape:persp3d-origin"); - // std::cout << "Found Persp3d: " - // << " vp_x: " << vp_x - // << " vp_y: " << vp_y - // << " vp_z: " << vp_z << std::endl; - Proj::Pt2 pt_x (vp_x); - Proj::Pt2 pt_y (vp_y); - Proj::Pt2 pt_z (vp_z); - Proj::Pt2 pt_o (vp_o); - pt_x = pt_x * (1.0/ratio); - pt_y = pt_y * (1.0/ratio); - pt_z = pt_z * (1.0/ratio); - pt_o = pt_o * (1.0/ratio); - persp3d->setAttribute("inkscape:vp_x",pt_x.coord_string()); - persp3d->setAttribute("inkscape:vp_y",pt_y.coord_string()); - persp3d->setAttribute("inkscape:vp_z",pt_z.coord_string()); - persp3d->setAttribute("inkscape:persp3d-origin",pt_o.coord_string()); - } - } - } - } // Look for SPNamedView and SPDefs loop - - // desktop->getDocument()->ensureUpToDate(); // Does not update box3d! - DocumentUndo::done(desktop->getDocument(), SP_VERB_NONE, _("Update Document")); - - } // If old Inkscape version + if (sp_version_inside_range(root->version.inkscape, 0, 1, 0, 92)) { + sp_file_convert_dpi(doc); + } } // If use_gui + // resize the window to match the document properties sp_namedview_window_from_document(desktop); sp_namedview_update_layers_from_document(desktop); -- cgit v1.2.3