summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlvin Penner <penner@vaxxine.com>2014-10-22 21:16:58 +0000
committerapenner <penner@vaxxine.com>2014-10-22 21:16:58 +0000
commit13aef9138410eeb3de3c6647a7201eb3dfeb3de7 (patch)
treeb653c7db7c95f662029d4785174bcb244b8bfb3c
parentUpdating translators list. (diff)
downloadinkscape-13aef9138410eeb3de3c6647a7201eb3dfeb3de7.tar.gz
inkscape-13aef9138410eeb3de3c6647a7201eb3dfeb3de7.zip
use double precision Quantity::convert for units conversion in viewBox, instead of single-precision SVGLength.computed.
(bzr r13632)
-rw-r--r--share/ui/units.xml6
-rw-r--r--src/document.cpp14
2 files changed, 13 insertions, 7 deletions
diff --git a/share/ui/units.xml b/share/ui/units.xml
index ef00aa9ce..286e9e62b 100644
--- a/share/ui/units.xml
+++ b/share/ui/units.xml
@@ -39,21 +39,21 @@
<name>millimeter</name>
<plural>millimeters</plural>
<abbr>mm</abbr>
- <factor>3.5433071</factor>
+ <factor>3.543307087</factor>
<description>Millimeters (25.4 mm/in)</description>
</unit>
<unit type="LINEAR" pri="n">
<name>centimeter</name>
<plural>centimeters</plural>
<abbr>cm</abbr>
- <factor>35.433071</factor>
+ <factor>35.43307087</factor>
<description>Centimeters (10 mm/cm)</description>
</unit>
<unit type="LINEAR" pri="n">
<name>meter</name>
<plural>meters</plural>
<abbr>m</abbr>
- <factor>3543.3071</factor>
+ <factor>3543.307087</factor>
<description>Meters (100 cm/m)</description>
</unit>
<unit type="LINEAR" pri="n">
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();
}