summaryrefslogtreecommitdiffstats
path: root/src/extension
diff options
context:
space:
mode:
authorMarkus Engel <markus.engel@tum.de>2013-09-24 22:17:24 +0000
committerMarkus Engel <markus.engel@tum.de>2013-09-24 22:17:24 +0000
commitbcca22a25ae98f70c36fff6292f0a8fe4e578d89 (patch)
treea18d382d32f471b7119b9b7b2782cec04d6da43f /src/extension
parentRefactored SPUse. (diff)
parentFix my email address through codebase (diff)
downloadinkscape-bcca22a25ae98f70c36fff6292f0a8fe4e578d89.tar.gz
inkscape-bcca22a25ae98f70c36fff6292f0a8fe4e578d89.zip
Merged from trunk (r12588).
(bzr r11608.1.129)
Diffstat (limited to 'src/extension')
-rw-r--r--src/extension/dbus/document-interface.cpp5
-rw-r--r--src/extension/init.cpp2
-rw-r--r--src/extension/internal/cairo-renderer-pdf-out.cpp2
-rw-r--r--src/extension/internal/cairo-renderer.cpp8
-rw-r--r--src/extension/internal/cdr-input.cpp6
-rw-r--r--src/extension/internal/emf-inout.cpp9
-rw-r--r--src/extension/internal/emf-print.cpp6
-rw-r--r--src/extension/internal/filter/filter-file.cpp2
-rw-r--r--src/extension/internal/gdkpixbuf-input.cpp6
-rw-r--r--src/extension/internal/grid.cpp5
-rw-r--r--src/extension/internal/image-resolution.cpp13
-rw-r--r--src/extension/internal/latex-pstricks.cpp8
-rw-r--r--src/extension/internal/latex-text-renderer.cpp4
-rw-r--r--src/extension/internal/odf.cpp3
-rw-r--r--src/extension/internal/pdf-input-cairo.cpp11
-rw-r--r--src/extension/internal/pdfinput/pdf-input.cpp6
-rw-r--r--src/extension/internal/pdfinput/pdf-parser.cpp6
-rw-r--r--src/extension/internal/pdfinput/svg-builder.cpp2
-rw-r--r--src/extension/internal/vsd-input.cpp7
-rw-r--r--src/extension/internal/wmf-inout.cpp9
-rw-r--r--src/extension/internal/wmf-print.cpp4
-rw-r--r--src/extension/internal/wpg-input.cpp8
-rw-r--r--src/extension/system.cpp2
23 files changed, 92 insertions, 42 deletions
diff --git a/src/extension/dbus/document-interface.cpp b/src/extension/dbus/document-interface.cpp
index 3cb03646a..ccc39fbef 100644
--- a/src/extension/dbus/document-interface.cpp
+++ b/src/extension/dbus/document-interface.cpp
@@ -43,6 +43,7 @@
#include "sp-object.h"
#include "sp-root.h"
#include "style.h" //style_write
+#include "util/units.h"
#include "extension/system.h" //IO
@@ -543,13 +544,13 @@ gchar *document_interface_node(DocumentInterface *doc_interface, gchar *type, GE
gdouble
document_interface_document_get_width (DocumentInterface *doc_interface)
{
- return doc_interface->target.getDocument()->getWidth();
+ return doc_interface->target.getDocument()->getWidth().value("px");
}
gdouble
document_interface_document_get_height (DocumentInterface *doc_interface)
{
- return doc_interface->target.getDocument()->getHeight();
+ return doc_interface->target.getDocument()->getHeight().value("px");
}
gchar *document_interface_document_get_css(DocumentInterface *doc_interface, GError ** error)
diff --git a/src/extension/init.cpp b/src/extension/init.cpp
index 1a163d4c2..2dde9eeb8 100644
--- a/src/extension/init.cpp
+++ b/src/extension/init.cpp
@@ -295,7 +295,7 @@ static void
build_module_from_dir(gchar const *dirname)
{
if (!dirname) {
- g_warning(_("Null external module directory name. Modules will not be loaded."));
+ g_warning("%s", _("Null external module directory name. Modules will not be loaded."));
return;
}
diff --git a/src/extension/internal/cairo-renderer-pdf-out.cpp b/src/extension/internal/cairo-renderer-pdf-out.cpp
index b9125582a..0c314a576 100644
--- a/src/extension/internal/cairo-renderer-pdf-out.cpp
+++ b/src/extension/internal/cairo-renderer-pdf-out.cpp
@@ -197,7 +197,7 @@ CairoRendererPdfOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc,
float new_bleedmargin_px = 0.;
try {
- new_bleedmargin_px = mod->get_param_float("bleed") * Inkscape::Util::Quantity::convert(1, "mm", "px");
+ new_bleedmargin_px = Inkscape::Util::Quantity::convert(mod->get_param_float("bleed"), "mm", "px");
}
catch(...) {
g_warning("Parameter <bleed> might not exist");
diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp
index cace251cf..0a4c86f0b 100644
--- a/src/extension/internal/cairo-renderer.cpp
+++ b/src/extension/internal/cairo-renderer.cpp
@@ -463,8 +463,8 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx)
}
// The width and height of the bitmap in pixels
- unsigned width = ceil(bbox->width() * (res / Inkscape::Util::Quantity::convert(1, "in", "px")));
- unsigned height = ceil(bbox->height() * (res / Inkscape::Util::Quantity::convert(1, "in", "px")));
+ unsigned width = ceil(bbox->width() * Inkscape::Util::Quantity::convert(res, "px", "in"));
+ unsigned height = ceil(bbox->height() * Inkscape::Util::Quantity::convert(res, "px", "in"));
if (width == 0 || height == 0) return;
@@ -638,9 +638,9 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page
Geom::Affine tp( Geom::Translate( bleedmargin_px, bleedmargin_px ) );
ctx->transform(tp);
} else {
- double high = doc->getHeight();
+ double high = doc->getHeight().value("px");
if (ctx->_vector_based_target)
- high *= Inkscape::Util::Quantity::convert(1, "px", "pt");
+ high = Inkscape::Util::Quantity::convert(high, "px", "pt");
// this transform translates the export drawing to a virtual page (0,0)-(width,height)
Geom::Affine tp(Geom::Translate(-d.left() * (ctx->_vector_based_target ? Inkscape::Util::Quantity::convert(1, "pt", "px") : 1.0),
diff --git a/src/extension/internal/cdr-input.cpp b/src/extension/internal/cdr-input.cpp
index e6c400fb5..517d6fb9c 100644
--- a/src/extension/internal/cdr-input.cpp
+++ b/src/extension/internal/cdr-input.cpp
@@ -51,6 +51,8 @@
#include "svg-view.h"
#include "svg-view-widget.h"
+#include "util/units.h"
+
namespace Inkscape {
namespace Extension {
namespace Internal {
@@ -254,6 +256,10 @@ SPDocument *CdrInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * u
}
SPDocument * doc = SPDocument::createNewDocFromMem(tmpSVGOutput[page_num-1].cstr(), strlen(tmpSVGOutput[page_num-1].cstr()), TRUE);
+ // Set viewBox if it doesn't exist
+ if (!doc->getRoot()->viewBox_set) {
+ doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity));
+ }
return doc;
}
diff --git a/src/extension/internal/emf-inout.cpp b/src/extension/internal/emf-inout.cpp
index b185d3348..d9489af31 100644
--- a/src/extension/internal/emf-inout.cpp
+++ b/src/extension/internal/emf-inout.cpp
@@ -1799,8 +1799,8 @@ std::cout << "BEFORE DRAW"
d->MMX = d->MM100InX / 100.0;
d->MMY = d->MM100InY / 100.0;
- d->PixelsOutX = d->MMX * Inkscape::Util::Quantity::convert(1, "mm", "px");
- d->PixelsOutY = d->MMY * Inkscape::Util::Quantity::convert(1, "mm", "px");
+ d->PixelsOutX = Inkscape::Util::Quantity::convert(d->MMX, "mm", "px");
+ d->PixelsOutY = Inkscape::Util::Quantity::convert(d->MMY, "mm", "px");
// Upper left corner, from header rclBounds, in device units, usually both 0, but not always
d->ulCornerInX = pEmr->rclBounds.left;
@@ -3483,6 +3483,11 @@ Emf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri )
d.tri = trinfo_release_except_FC(d.tri);
+ // Set viewBox if it doesn't exist
+ if (!doc->getRoot()->viewBox_set) {
+ doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity));
+ }
+
return doc;
}
diff --git a/src/extension/internal/emf-print.cpp b/src/extension/internal/emf-print.cpp
index 770257978..0df643130 100644
--- a/src/extension/internal/emf-print.cpp
+++ b/src/extension/internal/emf-print.cpp
@@ -138,8 +138,8 @@ unsigned int PrintEmf::begin(Inkscape::Extension::Print *mod, SPDocument *doc)
// width and height in px
- _width = doc->getWidth();
- _height = doc->getHeight();
+ _width = doc->getWidth().value("px");
+ _height = doc->getHeight().value("px");
// initialize a few global variables
hbrush = hbrushOld = hpen = 0;
@@ -243,7 +243,7 @@ unsigned int PrintEmf::begin(Inkscape::Extension::Print *mod, SPDocument *doc)
g_error("Fatal programming error in PrintEmf::begin at textcomment_set 1");
}
- snprintf(buff, sizeof(buff) - 1, "Drawing=%.1lfx%.1lfpx, %.1lfx%.1lfmm", _width, _height, dwInchesX * Inkscape::Util::Quantity::convert(1, "in", "mm"), dwInchesY * Inkscape::Util::Quantity::convert(1, "in", "mm"));
+ snprintf(buff, sizeof(buff) - 1, "Drawing=%.1lfx%.1lfpx, %.1lfx%.1lfmm", _width, _height, Inkscape::Util::Quantity::convert(dwInchesX, "in", "mm"), Inkscape::Util::Quantity::convert(dwInchesY, "in", "mm"));
rec = textcomment_set(buff);
if (!rec || emf_append((PU_ENHMETARECORD)rec, et, U_REC_FREE)) {
g_error("Fatal programming error in PrintEmf::begin at textcomment_set 1");
diff --git a/src/extension/internal/filter/filter-file.cpp b/src/extension/internal/filter/filter-file.cpp
index d569c6438..48e64f089 100644
--- a/src/extension/internal/filter/filter-file.cpp
+++ b/src/extension/internal/filter/filter-file.cpp
@@ -44,7 +44,7 @@ void
Filter::filters_load_dir (gchar const * dirname, gchar * menuname)
{
if (!dirname) {
- g_warning(_("Null external module directory name. Filters will not be loaded."));
+ g_warning("%s", _("Null external module directory name. Filters will not be loaded."));
return;
}
diff --git a/src/extension/internal/gdkpixbuf-input.cpp b/src/extension/internal/gdkpixbuf-input.cpp
index 87cf8a9cc..13267ee2b 100644
--- a/src/extension/internal/gdkpixbuf-input.cpp
+++ b/src/extension/internal/gdkpixbuf-input.cpp
@@ -102,6 +102,12 @@ GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri)
doc->getRoot()->appendChildRepr(image_node);
Inkscape::GC::release(image_node);
fit_canvas_to_drawing(doc);
+
+ // Set viewBox if it doesn't exist
+ if (!doc->getRoot()->viewBox_set) {
+ doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity));
+ }
+
// restore undo, as now this document may be shown to the user if a bitmap was opened
DocumentUndo::setUndoSensitive(doc, saved);
} else {
diff --git a/src/extension/internal/grid.cpp b/src/extension/internal/grid.cpp
index 820d1c9d3..2f9d0ff25 100644
--- a/src/extension/internal/grid.cpp
+++ b/src/extension/internal/grid.cpp
@@ -35,6 +35,7 @@
#include "extension/effect.h"
#include "extension/system.h"
+#include "util/units.h"
#include "grid.h"
@@ -97,14 +98,14 @@ Grid::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *doc
/* get page size */
SPDocument * doc = document->doc();
bounding_area = Geom::Rect( Geom::Point(0,0),
- Geom::Point(doc->getWidth(), doc->getHeight()) );
+ Geom::Point(doc->getWidth().value("px"), doc->getHeight().value("px")) );
} else {
Geom::OptRect bounds = selection->visualBounds();
if (bounds) {
bounding_area = *bounds;
}
- gdouble doc_height = (document->doc())->getHeight();
+ gdouble doc_height = (document->doc())->getHeight().value("px");
Geom::Rect temprec = Geom::Rect(Geom::Point(bounding_area.min()[Geom::X], doc_height - bounding_area.min()[Geom::Y]),
Geom::Point(bounding_area.max()[Geom::X], doc_height - bounding_area.max()[Geom::Y]));
diff --git a/src/extension/internal/image-resolution.cpp b/src/extension/internal/image-resolution.cpp
index a9d33e831..b38b0ddc7 100644
--- a/src/extension/internal/image-resolution.cpp
+++ b/src/extension/internal/image-resolution.cpp
@@ -11,6 +11,7 @@
# include <config.h>
#endif
+#include "util/units.h"
#include "image-resolution.h"
#define IR_TRY_PNG 1
@@ -341,15 +342,9 @@ void ImageResolution::readmagick(char const *fn) {
image.read(fn);
} catch (...) {}
Magick::Geometry geo = image.density();
- std::string type = image.magick();
-
- if (type == "PNG") { // PNG only supports pixelspercentimeter
- x_ = (double)geo.width() * 2.54;
- y_ = (double)geo.height() * 2.54;
- } else {
- x_ = (double)geo.width();
- y_ = (double)geo.height();
- }
+
+ x_ = Inkscape::Util::Quantity::convert((double)geo.width(), "pt", "px");
+ y_ = Inkscape::Util::Quantity::convert((double)geo.height(), "pt", "px");
ok_ = true;
}
diff --git a/src/extension/internal/latex-pstricks.cpp b/src/extension/internal/latex-pstricks.cpp
index 2ece1ba87..c8e8e2f2e 100644
--- a/src/extension/internal/latex-pstricks.cpp
+++ b/src/extension/internal/latex-pstricks.cpp
@@ -117,8 +117,8 @@ unsigned int PrintLatex::begin (Inkscape::Extension::Print *mod, SPDocument *doc
}
// width and height in pt
- _width = doc->getWidth() * Inkscape::Util::Quantity::convert(1, "px", "pt");
- _height = doc->getHeight() * Inkscape::Util::Quantity::convert(1, "px", "pt");
+ _width = doc->getWidth().value("pt");
+ _height = doc->getHeight().value("pt");
if (res >= 0) {
@@ -128,10 +128,10 @@ unsigned int PrintLatex::begin (Inkscape::Extension::Print *mod, SPDocument *doc
os << "\\psset{xunit=.5pt,yunit=.5pt,runit=.5pt}\n";
// from now on we can output px, but they will be treated as pt
- os << "\\begin{pspicture}(" << doc->getWidth() << "," << doc->getHeight() << ")\n";
+ os << "\\begin{pspicture}(" << doc->getWidth().value("px") << "," << doc->getHeight().value("px") << ")\n";
}
- m_tr_stack.push( Geom::Scale(1, -1) * Geom::Translate(0, doc->getHeight())); /// @fixme hardcoded doc2dt transform
+ m_tr_stack.push( Geom::Scale(1, -1) * Geom::Translate(0, doc->getHeight().value("px"))); /// @fixme hardcoded doc2dt transform
return fprintf(_stream, "%s", os.str().c_str());
}
diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp
index 7e6941232..398c9f061 100644
--- a/src/extension/internal/latex-text-renderer.cpp
+++ b/src/extension/internal/latex-text-renderer.cpp
@@ -633,7 +633,7 @@ LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, float bl
}
// flip y-axis
- push_transform( Geom::Scale(1,-1) * Geom::Translate(0, doc->getHeight()) ); /// @fixme hardcoded desktop transform!
+ push_transform( Geom::Scale(1,-1) * Geom::Translate(0, doc->getHeight().value("px")) ); /// @fixme hardcoded desktop transform!
// write the info to LaTeX
Inkscape::SVGOStringStream os;
@@ -642,7 +642,7 @@ LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, float bl
// scaling of the image when including it in LaTeX
os << " \\ifx\\svgwidth\\undefined%\n";
- os << " \\setlength{\\unitlength}{" << d.width() * Inkscape::Util::Quantity::convert(1, "px", "pt") << "bp}%\n"; // note: 'bp' is the Postscript pt unit in LaTeX, see LP bug #792384
+ os << " \\setlength{\\unitlength}{" << Inkscape::Util::Quantity::convert(d.width(), "px", "pt") << "bp}%\n"; // note: 'bp' is the Postscript pt unit in LaTeX, see LP bug #792384
os << " \\ifx\\svgscale\\undefined%\n";
os << " \\relax%\n";
os << " \\else%\n";
diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp
index a7c14387f..fcabcc4b2 100644
--- a/src/extension/internal/odf.cpp
+++ b/src/extension/internal/odf.cpp
@@ -75,6 +75,7 @@
#include "sp-flowtext.h"
#include "svg/svg.h"
#include "text-editing.h"
+#include "util/units.h"
//# DOM-specific includes
@@ -945,7 +946,7 @@ static Geom::Affine getODFTransform(const SPItem *item)
//### Get SVG-to-ODF transform
Geom::Affine tf (item->i2dt_affine());
//Flip Y into document coordinates
- double doc_height = SP_ACTIVE_DOCUMENT->getHeight();
+ double doc_height = SP_ACTIVE_DOCUMENT->getHeight().value("px");
Geom::Affine doc2dt_tf = Geom::Affine(Geom::Scale(1.0, -1.0)); /// @fixme hardcoded desktop transform
doc2dt_tf = doc2dt_tf * Geom::Affine(Geom::Translate(0, doc_height));
tf = tf * doc2dt_tf;
diff --git a/src/extension/internal/pdf-input-cairo.cpp b/src/extension/internal/pdf-input-cairo.cpp
index c2f2b43a5..adac0d6c9 100644
--- a/src/extension/internal/pdf-input-cairo.cpp
+++ b/src/extension/internal/pdf-input-cairo.cpp
@@ -23,6 +23,10 @@
#include "extension/input.h"
#include "dialogs/dialog-events.h"
#include "document.h"
+#include "sp-root.h"
+#include "util/units.h"
+
+#include <2geom/rect.h>
#include "inkscape.h"
@@ -491,7 +495,7 @@ bool PdfImportCairoDialog::_onDraw(const Cairo::RefPtr<Cairo::Context>& cr) {
*/
void PdfImportCairoDialog::_setPreviewPage(int page) {
- PopplerPage *_previewed_page = poppler_document_get_page(_poppler_doc, page);
+ PopplerPage *_previewed_page = poppler_document_get_page(_poppler_doc, page-1);
// Try to get a thumbnail from the PDF if possible
if (!_render_thumb) {
@@ -620,6 +624,11 @@ PdfInputCairo::open(Inkscape::Extension::Input * /*mod*/, const gchar * uri) {
SPDocument * doc = SPDocument::createNewDocFromMem(output->c_str(), output->length(), TRUE);
+ // Set viewBox if it doesn't exist
+ if (!doc->getRoot()->viewBox_set) {
+ doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity));
+ }
+
delete output;
g_object_unref(page);
g_object_unref(document);
diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp
index b04c9782f..213550688 100644
--- a/src/extension/internal/pdfinput/pdf-input.cpp
+++ b/src/extension/internal/pdfinput/pdf-input.cpp
@@ -46,6 +46,7 @@
#include "document-private.h"
#include "document-undo.h"
#include "inkscape.h"
+#include "util/units.h"
#include "dialogs/dialog-events.h"
#include <gtk/gtk.h>
@@ -747,6 +748,11 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) {
delete pdf_doc;
delete dlg;
+ // Set viewBox if it doesn't exist
+ if (!doc->getRoot()->viewBox_set) {
+ doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity));
+ }
+
// Restore undo
DocumentUndo::setUndoSensitive(doc, saved);
diff --git a/src/extension/internal/pdfinput/pdf-parser.cpp b/src/extension/internal/pdfinput/pdf-parser.cpp
index 6e57f6278..7edb758fd 100644
--- a/src/extension/internal/pdfinput/pdf-parser.cpp
+++ b/src/extension/internal/pdfinput/pdf-parser.cpp
@@ -279,14 +279,14 @@ PdfParser::PdfParser(XRef *xrefA, Inkscape::Extension::Internal::SvgBuilder *bui
ignoreUndef = 0;
operatorHistory = NULL;
builder = builderA;
- builder->setDocumentSize(state->getPageWidth()*Inkscape::Util::Quantity::convert(1, "pt", "px"),
- state->getPageHeight()*Inkscape::Util::Quantity::convert(1, "pt", "px"));
+ builder->setDocumentSize(Inkscape::Util::Quantity::convert(state->getPageWidth(), "pt", "px"),
+ Inkscape::Util::Quantity::convert(state->getPageHeight(), "pt", "px"));
double *ctm = state->getCTM();
double scaledCTM[6];
for (int i = 0; i < 6; ++i) {
baseMatrix[i] = ctm[i];
- scaledCTM[i] = Inkscape::Util::Quantity::convert(1, "pt", "px") * ctm[i];
+ scaledCTM[i] = Inkscape::Util::Quantity::convert(ctm[i], "pt", "px");
}
saveState();
builder->setTransform((double*)&scaledCTM);
diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp
index a1a309a87..b3f15bbff 100644
--- a/src/extension/internal/pdfinput/svg-builder.cpp
+++ b/src/extension/internal/pdfinput/svg-builder.cpp
@@ -793,7 +793,7 @@ gchar *SvgBuilder::_createGradient(GfxShading *shading, double *matrix, bool for
Geom::Affine pat_matrix(matrix[0], matrix[1], matrix[2], matrix[3],
matrix[4], matrix[5]);
if ( !for_shading && _is_top_level ) {
- Geom::Affine flip(1.0, 0.0, 0.0, -1.0, 0.0, _height * Inkscape::Util::Quantity::convert(1, "px", "pt"));
+ Geom::Affine flip(1.0, 0.0, 0.0, -1.0, 0.0, Inkscape::Util::Quantity::convert(_height, "px", "pt"));
pat_matrix *= flip;
}
gchar *transform_text = sp_svg_transform_write(pat_matrix);
diff --git a/src/extension/internal/vsd-input.cpp b/src/extension/internal/vsd-input.cpp
index 12e5150cb..42a9e3d41 100644
--- a/src/extension/internal/vsd-input.cpp
+++ b/src/extension/internal/vsd-input.cpp
@@ -39,6 +39,7 @@
#include "document-private.h"
#include "document-undo.h"
#include "inkscape.h"
+#include "util/units.h"
#include "dialogs/dialog-events.h"
#include <gtk/gtk.h>
@@ -254,6 +255,12 @@ SPDocument *VsdInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * u
}
SPDocument * doc = SPDocument::createNewDocFromMem(tmpSVGOutput[page_num-1].cstr(), strlen(tmpSVGOutput[page_num-1].cstr()), TRUE);
+
+ // Set viewBox if it doesn't exist
+ if (!doc->getRoot()->viewBox_set) {
+ doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity));
+ }
+
return doc;
}
diff --git a/src/extension/internal/wmf-inout.cpp b/src/extension/internal/wmf-inout.cpp
index 451d94c0e..e7dfa46d7 100644
--- a/src/extension/internal/wmf-inout.cpp
+++ b/src/extension/internal/wmf-inout.cpp
@@ -1742,8 +1742,8 @@ int Wmf::myMetaFileProc(const char *contents, unsigned int length, PWMF_CALLBACK
tmp_outdef << " version=\"1.0\"\n";
tmp_outdef <<
- " width=\"" << d->PixelsOutX/ Inkscape::Util::Quantity::convert(1, "mm", "px") << "mm\"\n" <<
- " height=\"" << d->PixelsOutY/ Inkscape::Util::Quantity::convert(1, "mm", "px") << "mm\">\n";
+ " width=\"" << Inkscape::Util::Quantity::convert(d->PixelsOutX, "px", "mm") << "mm\"\n" <<
+ " height=\"" << Inkscape::Util::Quantity::convert(d->PixelsOutY, "px", "mm") << "mm\">\n";
*(d->outdef) += tmp_outdef.str().c_str();
*(d->outdef) += "<defs>"; // temporary end of header
@@ -3171,6 +3171,11 @@ Wmf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri )
d.tri = trinfo_release_except_FC(d.tri);
+ // Set viewBox if it doesn't exist
+ if (!doc->getRoot()->viewBox_set) {
+ doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity));
+ }
+
return doc;
}
diff --git a/src/extension/internal/wmf-print.cpp b/src/extension/internal/wmf-print.cpp
index 99262b109..cf0302b38 100644
--- a/src/extension/internal/wmf-print.cpp
+++ b/src/extension/internal/wmf-print.cpp
@@ -138,8 +138,8 @@ unsigned int PrintWmf::begin(Inkscape::Extension::Print *mod, SPDocument *doc)
// WMF header the only things that can be set are the page size in inches (w,h) and the dpi
// width and height in px
- _width = doc->getWidth();
- _height = doc->getHeight();
+ _width = doc->getWidth().value("px");
+ _height = doc->getHeight().value("px");
// initialize a few global variables
hbrush = hpen = 0;
diff --git a/src/extension/internal/wpg-input.cpp b/src/extension/internal/wpg-input.cpp
index cb1677547..ac86a6171 100644
--- a/src/extension/internal/wpg-input.cpp
+++ b/src/extension/internal/wpg-input.cpp
@@ -48,6 +48,8 @@
#include "extension/system.h"
#include "extension/input.h"
#include "document.h"
+#include "sp-root.h"
+#include "util/units.h"
#include <cstring>
// Take a guess and fallback to 0.1.x if no configure has run
@@ -109,6 +111,12 @@ SPDocument *WpgInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * u
//printf("I've got a doc: \n%s", painter.document.c_str());
SPDocument * doc = SPDocument::createNewDocFromMem(output.cstr(), strlen(output.cstr()), TRUE);
+
+ // Set viewBox if it doesn't exist
+ if (!doc->getRoot()->viewBox_set) {
+ doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity));
+ }
+
delete input;
return doc;
}
diff --git a/src/extension/system.cpp b/src/extension/system.cpp
index f7fd48b3f..a4c370f4c 100644
--- a/src/extension/system.cpp
+++ b/src/extension/system.cpp
@@ -124,7 +124,7 @@ SPDocument *open(Extension *key, gchar const *filename)
if ( inkscape_use_gui() ) {
sp_ui_error_dialog(_("Format autodetect failed. The file is being opened as SVG."));
} else {
- g_warning(_("Format autodetect failed. The file is being opened as SVG."));
+ g_warning("%s", _("Format autodetect failed. The file is being opened as SVG."));
}
}