summaryrefslogtreecommitdiffstats
path: root/src/document.cpp
diff options
context:
space:
mode:
authorLiam P. White <inkscapebrony@gmail.com>2014-11-26 01:10:30 +0000
committerLiam P. White <inkscapebrony@gmail.com>2014-11-26 01:10:30 +0000
commit6c87088ed548a3da4388ea95bba82aea798c901a (patch)
treee4269aab0a32957163935ec6b828b25d00613d68 /src/document.cpp
parentUpdate to trunk r13750 (diff)
parentAdd CMake file to find LCMS2 (diff)
downloadinkscape-6c87088ed548a3da4388ea95bba82aea798c901a.tar.gz
inkscape-6c87088ed548a3da4388ea95bba82aea798c901a.zip
Update to trunk r13766
(bzr r13341.5.24)
Diffstat (limited to 'src/document.cpp')
-rw-r--r--src/document.cpp32
1 files changed, 14 insertions, 18 deletions
diff --git a/src/document.cpp b/src/document.cpp
index 2832536af..2625ef8fc 100644
--- a/src/document.cpp
+++ b/src/document.cpp
@@ -602,6 +602,14 @@ Inkscape::Util::Unit const* SPDocument::getDefaultUnit() const
return nv ? nv->getDefaultUnit() : unit_table.getUnit("pt");
}
+/// guaranteed not to return nullptr
+// returns 'px' units as default, like legacy Inkscape
+Inkscape::Util::Unit const& SPDocument::getSVGUnit() const
+{
+ SPNamedView const* nv = sp_document_namedview(this, NULL);
+ return nv ? nv->getSVGUnit() : *unit_table.getUnit("px");
+}
+
Inkscape::Util::Quantity SPDocument::getWidth() const
{
g_return_val_if_fail(this->priv != NULL, Inkscape::Util::Quantity(0.0, unit_table.getUnit("")));
@@ -625,16 +633,10 @@ void SPDocument::setWidth(const Inkscape::Util::Quantity &width)
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 */
- if (*width.unit == *unit_table.getUnit("m")) {
- root->width.value = width.value("cm");
- root->width.unit = SVGLength::CM;
- } else {
- root->width.value = width.quantity;
- root->width.unit = (SVGLength::Unit) width.unit->svgUnit();
- }
+ root->width.value = width.quantity;
+ root->width.unit = (SVGLength::Unit) width.unit->svgUnit();
if (root->viewBox_set)
root->viewBox.setMax(Geom::Point(root->viewBox.left() + (root->width.value / old_converted) * root->viewBox.width(), root->viewBox.bottom()));
@@ -666,16 +668,10 @@ void SPDocument::setHeight(const Inkscape::Util::Quantity &height)
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 */
- if (*height.unit == *unit_table.getUnit("m")) {
- root->height.value = height.value("cm");
- root->height.unit = SVGLength::CM;
- } else {
- root->height.value = height.quantity;
- root->height.unit = (SVGLength::Unit) height.unit->svgUnit();
- }
+ root->height.value = height.quantity;
+ root->height.unit = (SVGLength::Unit) height.unit->svgUnit();
if (root->viewBox_set)
root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + (root->height.value / old_converted) * root->viewBox.height()));