summaryrefslogtreecommitdiffstats
path: root/src/svg
diff options
context:
space:
mode:
authorMatthew Petroff <matthew@mpetroff.net>2013-08-06 18:54:40 +0000
committerMatthew Petroff <matthew@mpetroff.net>2013-08-06 18:54:40 +0000
commitbb88a2cb94ec34ee838a972bab17ca05ba92d1da (patch)
tree4b4580dbe1bec0968254d1b362611ab57ad3c223 /src/svg
parentinit SPStyle better: fixes a bunch of bugs resulting from improper re-init of... (diff)
parentFixed bug in page sizer. (diff)
downloadinkscape-bb88a2cb94ec34ee838a972bab17ca05ba92d1da.tar.gz
inkscape-bb88a2cb94ec34ee838a972bab17ca05ba92d1da.zip
Merge Google Summer of Code unit refactor.
(bzr r12471)
Diffstat (limited to 'src/svg')
-rw-r--r--src/svg/svg-length.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/svg/svg-length.cpp b/src/svg/svg-length.cpp
index d2f4332d8..ea438e91a 100644
--- a/src/svg/svg-length.cpp
+++ b/src/svg/svg-length.cpp
@@ -23,7 +23,7 @@
#include "svg.h"
#include "stringstream.h"
-#include "../unit-constants.h"
+#include "util/units.h"
static unsigned sp_svg_length_read_lff(gchar const *str, SVGLength::Unit *unit, float *val, float *computed, char **next);
@@ -330,6 +330,8 @@ static unsigned sp_svg_length_read_lff(gchar const *str, SVGLength::Unit *unit,
*next = (char *) e + 1;
}
return 1;
+ } else if (g_ascii_isspace(e[0])) {
+ return 0; // spaces are not allowed
} else {
/* Unitless */
if (unit) {
@@ -365,7 +367,7 @@ static unsigned sp_svg_length_read_lff(gchar const *str, SVGLength::Unit *unit,
*unit = SVGLength::PT;
}
if (computed) {
- *computed = v * PX_PER_PT;
+ *computed = v * Inkscape::Util::Quantity::convert(1, "pt", "px");
}
break;
case UVAL('p','c'):
@@ -373,7 +375,7 @@ static unsigned sp_svg_length_read_lff(gchar const *str, SVGLength::Unit *unit,
*unit = SVGLength::PC;
}
if (computed) {
- *computed = v * PX_PER_PC;
+ *computed = v * Inkscape::Util::Quantity::convert(1, "pc", "px");
}
break;
case UVAL('m','m'):
@@ -381,7 +383,7 @@ static unsigned sp_svg_length_read_lff(gchar const *str, SVGLength::Unit *unit,
*unit = SVGLength::MM;
}
if (computed) {
- *computed = v * PX_PER_MM;
+ *computed = v * Inkscape::Util::Quantity::convert(1, "mm", "px");
}
break;
case UVAL('c','m'):
@@ -389,7 +391,7 @@ static unsigned sp_svg_length_read_lff(gchar const *str, SVGLength::Unit *unit,
*unit = SVGLength::CM;
}
if (computed) {
- *computed = v * PX_PER_CM;
+ *computed = v * Inkscape::Util::Quantity::convert(1, "cm", "px");
}
break;
case UVAL('i','n'):
@@ -397,7 +399,7 @@ static unsigned sp_svg_length_read_lff(gchar const *str, SVGLength::Unit *unit,
*unit = SVGLength::INCH;
}
if (computed) {
- *computed = v * PX_PER_IN;
+ *computed = v * Inkscape::Util::Quantity::convert(1, "in", "px");
}
break;
case UVAL('f','t'):
@@ -405,7 +407,7 @@ static unsigned sp_svg_length_read_lff(gchar const *str, SVGLength::Unit *unit,
*unit = SVGLength::FOOT;
}
if (computed) {
- *computed = v * PX_PER_FT;
+ *computed = v * Inkscape::Util::Quantity::convert(1, "ft", "px");
}
break;
case UVAL('e','m'):