summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthew Petroff <matthew@mpetroff.net>2013-10-05 19:42:38 +0000
committerMatthew Petroff <matthew@mpetroff.net>2013-10-05 19:42:38 +0000
commitabc0521ce024af29c7bf58cf404060f911e5b412 (patch)
treefecdefe71ae94d4f0ba96060c915e88393006b1d /src
parentRewrite the internals of the unit code for somewhat better performance (diff)
downloadinkscape-abc0521ce024af29c7bf58cf404060f911e5b412.tar.gz
inkscape-abc0521ce024af29c7bf58cf404060f911e5b412.zip
Fix EMF/WMF import scale (Bug #1229120).
Fixed bugs: - https://launchpad.net/bugs/1229120 (bzr r12662)
Diffstat (limited to 'src')
-rw-r--r--src/extension/internal/emf-inout.cpp26
-rw-r--r--src/extension/internal/wmf-inout.cpp26
2 files changed, 52 insertions, 0 deletions
diff --git a/src/extension/internal/emf-inout.cpp b/src/extension/internal/emf-inout.cpp
index d9489af31..4bca9dfd9 100644
--- a/src/extension/internal/emf-inout.cpp
+++ b/src/extension/internal/emf-inout.cpp
@@ -46,6 +46,10 @@
#include "clear-n_.h"
#include "document.h"
#include "util/units.h"
+#include "shape-editor.h"
+#include "sp-namedview.h"
+#include "document-undo.h"
+#include "inkscape.h"
#include "emf-print.h"
#include "emf-inout.h"
@@ -3485,7 +3489,29 @@ Emf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri )
// Set viewBox if it doesn't exist
if (!doc->getRoot()->viewBox_set) {
+ bool saved = Inkscape::DocumentUndo::getUndoSensitive(doc);
+ Inkscape::DocumentUndo::setUndoSensitive(doc, false);
+
+ doc->ensureUpToDate();
+
+ // Set document unit
+ Inkscape::XML::Node *repr = sp_document_namedview(doc, 0)->getRepr();
+ Inkscape::SVGOStringStream os;
+ os << doc->getWidth().unit->abbr;
+ repr->setAttribute("inkscape:document-units", os.str().c_str());
+
+ // Set viewBox
doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity));
+
+ // Scale and translate objects
+ double scale = Inkscape::Util::Quantity::convert(1, "px", doc->getWidth().unit->abbr);
+ ShapeEditor::blockSetItem(true);
+ doc->getRoot()->scaleChildItemsRec(Geom::Scale(scale), Geom::Point(0, SP_ACTIVE_DOCUMENT->getHeight().value("px")));
+ ShapeEditor::blockSetItem(false);
+
+ doc->ensureUpToDate();
+
+ Inkscape::DocumentUndo::setUndoSensitive(doc, saved);
}
return doc;
diff --git a/src/extension/internal/wmf-inout.cpp b/src/extension/internal/wmf-inout.cpp
index e7dfa46d7..78fcdb66d 100644
--- a/src/extension/internal/wmf-inout.cpp
+++ b/src/extension/internal/wmf-inout.cpp
@@ -46,6 +46,10 @@
#include "util/units.h"
#include "clear-n_.h"
#include "document.h"
+#include "shape-editor.h"
+#include "sp-namedview.h"
+#include "document-undo.h"
+#include "inkscape.h"
#include "wmf-inout.h"
@@ -3173,7 +3177,29 @@ Wmf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri )
// Set viewBox if it doesn't exist
if (!doc->getRoot()->viewBox_set) {
+ bool saved = Inkscape::DocumentUndo::getUndoSensitive(doc);
+ Inkscape::DocumentUndo::setUndoSensitive(doc, false);
+
+ doc->ensureUpToDate();
+
+ // Set document unit
+ Inkscape::XML::Node *repr = sp_document_namedview(doc, 0)->getRepr();
+ Inkscape::SVGOStringStream os;
+ os << doc->getWidth().unit->abbr;
+ repr->setAttribute("inkscape:document-units", os.str().c_str());
+
+ // Set viewBox
doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity));
+
+ // Scale and translate objects
+ double scale = Inkscape::Util::Quantity::convert(1, "px", doc->getWidth().unit->abbr);
+ ShapeEditor::blockSetItem(true);
+ doc->getRoot()->scaleChildItemsRec(Geom::Scale(scale), Geom::Point(0, SP_ACTIVE_DOCUMENT->getHeight().value("px")));
+ ShapeEditor::blockSetItem(false);
+
+ doc->ensureUpToDate();
+
+ Inkscape::DocumentUndo::setUndoSensitive(doc, saved);
}
return doc;