summaryrefslogtreecommitdiffstats
path: root/src/document.cpp
diff options
context:
space:
mode:
authorLiam P. White <inkscapebrony@gmail.com>2014-10-31 00:22:23 +0000
committerLiam P. White <inkscapebrony@gmail.com>2014-10-31 00:22:23 +0000
commita95976663a5d9ffe10fb39aa03f6ad42b067ae95 (patch)
tree73aa5717905b22abcb80d7134dc6fca4eb95c573 /src/document.cpp
parentUpdate to experimental r13619 (diff)
parentFix units.xml (diff)
downloadinkscape-a95976663a5d9ffe10fb39aa03f6ad42b067ae95.tar.gz
inkscape-a95976663a5d9ffe10fb39aa03f6ad42b067ae95.zip
Update to trunk r13648
(bzr r13341.5.19)
Diffstat (limited to 'src/document.cpp')
-rw-r--r--src/document.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/document.cpp b/src/document.cpp
index 70fec83d7..b3d606417 100644
--- a/src/document.cpp
+++ b/src/document.cpp
@@ -621,7 +621,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 */
@@ -634,7 +637,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();
}
@@ -659,7 +662,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 */
@@ -672,7 +678,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();
}