summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/document.cpp26
-rw-r--r--src/svg/svg-length.cpp5
-rw-r--r--src/svg/svg-length.h1
-rw-r--r--src/util/units.cpp3
4 files changed, 14 insertions, 21 deletions
diff --git a/src/document.cpp b/src/document.cpp
index f69e830ff..e24af8fa8 100644
--- a/src/document.cpp
+++ b/src/document.cpp
@@ -630,17 +630,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;
- old_converted = Inkscape::Util::Quantity::convert(old_converted, "m", "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()));
@@ -672,17 +665,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;
- old_converted = Inkscape::Util::Quantity::convert(old_converted, "m", "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()));
diff --git a/src/svg/svg-length.cpp b/src/svg/svg-length.cpp
index b9b475f4b..ea235b2e4 100644
--- a/src/svg/svg-length.cpp
+++ b/src/svg/svg-length.cpp
@@ -520,7 +520,8 @@ gchar const *sp_svg_length_get_css_units(SVGLength::Unit unit)
case SVGLength::MM: return "mm";
case SVGLength::CM: return "cm";
case SVGLength::INCH: return "in";
- case SVGLength::FOOT: return ""; // Does not have a "foot" unit string in the SVG spec
+ case SVGLength::FOOT: return ""; // Not in SVG/CSS specification.
+ case SVGLength::MITRE: return ""; // Not in SVG/CSS specification.
case SVGLength::EM: return "em";
case SVGLength::EX: return "ex";
case SVGLength::PERCENT: return "%";
@@ -539,6 +540,8 @@ std::string sp_svg_length_write_with_units(SVGLength const &length)
os << 100*length.value << sp_svg_length_get_css_units(length.unit);
} else if (length.unit == SVGLength::FOOT) {
os << 12*length.value << sp_svg_length_get_css_units(SVGLength::INCH);
+ } else if (length.unit == SVGLength::MITRE) {
+ os << 100*length.value << sp_svg_length_get_css_units(SVGLength::CM);
} else {
os << length.value << sp_svg_length_get_css_units(length.unit);
}
diff --git a/src/svg/svg-length.h b/src/svg/svg-length.h
index c34905d07..1e6b4c96c 100644
--- a/src/svg/svg-length.h
+++ b/src/svg/svg-length.h
@@ -28,6 +28,7 @@ public:
CM,
INCH,
FOOT,
+ MITRE,
EM,
EX,
PERCENT,
diff --git a/src/util/units.cpp b/src/util/units.cpp
index 8ad3560dd..2c72ec3ae 100644
--- a/src/util/units.cpp
+++ b/src/util/units.cpp
@@ -16,6 +16,7 @@
#include <cmath>
#include <cerrno>
#include <iomanip>
+#include <iostream>
#include <glib.h>
#include <glibmm/regex.h>
#include <glibmm/fileutils.h>
@@ -46,6 +47,7 @@ enum UnitCode {
UNIT_CODE_CM = MAKE_UNIT_CODE('c','m'),
UNIT_CODE_IN = MAKE_UNIT_CODE('i','n'),
UNIT_CODE_FT = MAKE_UNIT_CODE('f','t'),
+ UNIT_CODE_MT = MAKE_UNIT_CODE('m',' '),
UNIT_CODE_EM = MAKE_UNIT_CODE('e','m'),
UNIT_CODE_EX = MAKE_UNIT_CODE('e','x'),
UNIT_CODE_PERCENT = MAKE_UNIT_CODE('%',0)
@@ -73,6 +75,7 @@ unsigned const svg_length_lookup[] = {
UNIT_CODE_CM,
UNIT_CODE_IN,
UNIT_CODE_FT,
+ UNIT_CODE_MT,
UNIT_CODE_EM,
UNIT_CODE_EX,
UNIT_CODE_PERCENT