From abc0521ce024af29c7bf58cf404060f911e5b412 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sat, 5 Oct 2013 15:42:38 -0400 Subject: Fix EMF/WMF import scale (Bug #1229120). Fixed bugs: - https://launchpad.net/bugs/1229120 (bzr r12662) --- src/extension/internal/emf-inout.cpp | 26 ++++++++++++++++++++++++++ src/extension/internal/wmf-inout.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) (limited to 'src/extension/internal') 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; -- cgit v1.2.3 From 30422af227381c9aa900690586d25adec4fa262f Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 9 Oct 2013 21:09:49 +0200 Subject: Documentation/Translation. Fix for Bug #1236382 (Typos in comments and message, localization context needed) by Yuri Chornoivan. Fixed bugs: - https://launchpad.net/bugs/1236382 (bzr r12673) --- src/extension/internal/emf-inout.cpp | 6 +++--- src/extension/internal/text_reassemble.c | 2 +- src/extension/internal/wmf-inout.cpp | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/extension/internal') diff --git a/src/extension/internal/emf-inout.cpp b/src/extension/internal/emf-inout.cpp index 4bca9dfd9..90ab763e0 100644 --- a/src/extension/internal/emf-inout.cpp +++ b/src/extension/internal/emf-inout.cpp @@ -321,7 +321,7 @@ Emf::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar const *filena } -/* given the transformation matrix from worldTranform return the scale in the matrix part. Assumes that the +/* given the transformation matrix from worldTransform return the scale in the matrix part. Assumes that the matrix is not used to skew, invert, or make another distorting transformation. */ double Emf::current_scale(PEMF_CALLBACK_DATA d){ double scale = @@ -332,7 +332,7 @@ double Emf::current_scale(PEMF_CALLBACK_DATA d){ return(scale); } -/* given the transformation matrix from worldTranform and the current x,y position in inkscape coordinates, +/* given the transformation matrix from worldTransform and the current x,y position in inkscape coordinates, generate an SVG transform that gives the same amount of rotation, no scaling, and maps x,y back onto x,y. This is used for rotating objects when the location of at least one point in that object is known. Returns: "matrix(a,b,c,d,e,f)" (WITH the double quotes) @@ -359,7 +359,7 @@ std::string Emf::current_matrix(PEMF_CALLBACK_DATA d, double x, double y, int us return(cxform.str()); } -/* given the transformation matrix from worldTranform return the rotation angle in radians. +/* given the transformation matrix from worldTransform return the rotation angle in radians. counter clocwise from the x axis. */ double Emf::current_rotation(PEMF_CALLBACK_DATA d){ return -std::atan2(d->dc[d->level].worldTransform.eM12, d->dc[d->level].worldTransform.eM11); diff --git a/src/extension/internal/text_reassemble.c b/src/extension/internal/text_reassemble.c index 9ed6c9c3a..cd84910fc 100644 --- a/src/extension/internal/text_reassemble.c +++ b/src/extension/internal/text_reassemble.c @@ -1015,7 +1015,7 @@ int cxinfo_make_insertable(CX_INFO *cxi){ \brief Insert a complex into the CX_INFO structure. (Insert may be either TR_TEXT or TR_LINE.) \returns 0 on success, !0 on error. \param cxi pointer to the CX_INFO structure (complexes). - \param src index of the the complex to insert. + \param src index of the complex to insert. \param src_rt_tidx index of the bounding rectangle \param type TR_TEXT (index is for tpi->chunks[]) or TR_LINE (index is for cxi->kids[]) */ diff --git a/src/extension/internal/wmf-inout.cpp b/src/extension/internal/wmf-inout.cpp index 78fcdb66d..aab98dc87 100644 --- a/src/extension/internal/wmf-inout.cpp +++ b/src/extension/internal/wmf-inout.cpp @@ -320,12 +320,12 @@ Wmf::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar const *filena } -/* WMF has no worldTranform, so this always returns 1.0. Retain it to keep WMF and WMF in sync as much as possible.*/ +/* WMF has no worldTransform, so this always returns 1.0. Retain it to keep WMF and WMF in sync as much as possible.*/ double Wmf::current_scale(PWMF_CALLBACK_DATA d){ return 1.0; } -/* WMF has no worldTranform, so this always returns an Identity rotation matrix, but the offsets may have values.*/ +/* WMF has no worldTransform, so this always returns an Identity rotation matrix, but the offsets may have values.*/ std::string Wmf::current_matrix(PWMF_CALLBACK_DATA d, double x, double y, int useoffset){ std::stringstream cxform; double scale = current_scale(d); @@ -340,7 +340,7 @@ std::string Wmf::current_matrix(PWMF_CALLBACK_DATA d, double x, double y, int us return(cxform.str()); } -/* WMF has no worldTranform, so this always returns 0. Retain it to keep WMF and WMF in sync as much as possible.*/ +/* WMF has no worldTransform, so this always returns 0. Retain it to keep WMF and WMF in sync as much as possible.*/ double Wmf::current_rotation(PWMF_CALLBACK_DATA d){ return 0.0; } -- cgit v1.2.3 From a970dc423d59ea844bdb1af48d5d9419a5e2a287 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 13 Oct 2013 00:24:05 +0200 Subject: Units: stop newing Unit objects. pass around pointers to "undeletable" Unit objects in the UnitTable. I think we should move to using indexed units, and pass around the index of the unit in the unittable, or smth like that... ? (bzr r12679) --- src/extension/internal/emf-inout.cpp | 2 +- src/extension/internal/wmf-inout.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/extension/internal') diff --git a/src/extension/internal/emf-inout.cpp b/src/extension/internal/emf-inout.cpp index 90ab763e0..f1876c687 100644 --- a/src/extension/internal/emf-inout.cpp +++ b/src/extension/internal/emf-inout.cpp @@ -3504,7 +3504,7 @@ Emf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) 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); + double scale = Inkscape::Util::Quantity::convert(1, "px", doc->getWidth().unit); ShapeEditor::blockSetItem(true); doc->getRoot()->scaleChildItemsRec(Geom::Scale(scale), Geom::Point(0, SP_ACTIVE_DOCUMENT->getHeight().value("px"))); ShapeEditor::blockSetItem(false); diff --git a/src/extension/internal/wmf-inout.cpp b/src/extension/internal/wmf-inout.cpp index aab98dc87..d69d46f20 100644 --- a/src/extension/internal/wmf-inout.cpp +++ b/src/extension/internal/wmf-inout.cpp @@ -3192,7 +3192,7 @@ Wmf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) 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); + double scale = Inkscape::Util::Quantity::convert(1, "px", doc->getWidth().unit); ShapeEditor::blockSetItem(true); doc->getRoot()->scaleChildItemsRec(Geom::Scale(scale), Geom::Point(0, SP_ACTIVE_DOCUMENT->getHeight().value("px"))); ShapeEditor::blockSetItem(false); -- cgit v1.2.3