From 13aef9138410eeb3de3c6647a7201eb3dfeb3de7 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Wed, 22 Oct 2014 17:16:58 -0400 Subject: use double precision Quantity::convert for units conversion in viewBox, instead of single-precision SVGLength.computed. (bzr r13632) --- src/document.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index f7edf5ed3..8c5b25db7 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -618,7 +618,10 @@ Inkscape::Util::Quantity SPDocument::getWidth() const void SPDocument::setWidth(const Inkscape::Util::Quantity &width) { - gdouble old_computed = root->width.computed; + Inkscape::Util::Unit const *old_units = unit_table.getUnit("px"); + if (root->width.unit) + old_units = unit_table.getUnit(root->width.unit); + gdouble old_converted = Inkscape::Util::Quantity::convert(root->width.value, old_units, width.unit); root->width.computed = width.value("px"); /* SVG does not support meters as a unit, so we must translate meters to * cm when writing */ @@ -631,7 +634,7 @@ void SPDocument::setWidth(const Inkscape::Util::Quantity &width) } if (root->viewBox_set) - root->viewBox.setMax(Geom::Point(root->viewBox.left() + (root->width.computed / old_computed) * root->viewBox.width(), root->viewBox.bottom())); + root->viewBox.setMax(Geom::Point(root->viewBox.left() + (root->width.value / old_converted) * root->viewBox.width(), root->viewBox.bottom())); root->updateRepr(); } @@ -656,7 +659,10 @@ Inkscape::Util::Quantity SPDocument::getHeight() const void SPDocument::setHeight(const Inkscape::Util::Quantity &height) { - gdouble old_computed = root->height.computed; + Inkscape::Util::Unit const *old_units = unit_table.getUnit("px"); + if (root->height.unit) + old_units = unit_table.getUnit(root->height.unit); + gdouble old_converted = Inkscape::Util::Quantity::convert(root->height.value, old_units, height.unit); root->height.computed = height.value("px"); /* SVG does not support meters as a unit, so we must translate meters to * cm when writing */ @@ -669,7 +675,7 @@ void SPDocument::setHeight(const Inkscape::Util::Quantity &height) } if (root->viewBox_set) - root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + (root->height.computed / old_computed) * root->viewBox.height())); + root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + (root->height.value / old_converted) * root->viewBox.height())); root->updateRepr(); } -- cgit v1.2.3