diff options
Diffstat (limited to 'src/util')
| -rw-r--r-- | src/util/units.cpp | 30 | ||||
| -rw-r--r-- | src/util/units.h | 4 |
2 files changed, 34 insertions, 0 deletions
diff --git a/src/util/units.cpp b/src/util/units.cpp index 7bc910fcc..e7be3f5e6 100644 --- a/src/util/units.cpp +++ b/src/util/units.cpp @@ -220,6 +220,36 @@ Unit UnitTable::getUnit(Glib::ustring const &unit_abbr) const return Unit(); } } +Unit UnitTable::getUnit(SVGLength::Unit const u) const +{ + Glib::ustring u_str; + switch(u) { + case 1: + u_str = "px"; break; + case 2: + u_str = "pt"; break; + case 3: + u_str = "pc"; break; + case 4: + u_str = "mm"; break; + case 5: + u_str = "cm"; break; + case 6: + u_str = "in"; break; + case 7: + u_str = "ft"; break; + case 8: + u_str = "em"; break; + case 9: + u_str = "ex"; break; + case 10: + u_str = "%"; break; + default: + u_str = ""; + } + + return getUnit(u_str); +} Quantity UnitTable::getQuantity(Glib::ustring const& q) const { diff --git a/src/util/units.h b/src/util/units.h index bb202b96a..c5ee87ae3 100644 --- a/src/util/units.h +++ b/src/util/units.h @@ -28,6 +28,7 @@ Need to review the Units support that's in Gtkmm already... #include <map> #include <glibmm/ustring.h> +#include "svg/svg.h" namespace Inkscape { namespace Util { @@ -132,6 +133,9 @@ class UnitTable { /** Retrieve a given unit based on its string identifier */ Unit getUnit(Glib::ustring const &name) const; + /** Retrieve a given unit based on its SVGLength unit */ + Unit getUnit(SVGLength::Unit const u) const; + /** Retrieve a quantity based on its string identifier */ Quantity getQuantity(Glib::ustring const &q) const; |
