summaryrefslogtreecommitdiffstats
path: root/src/util
diff options
context:
space:
mode:
authorMatthew Petroff <matthew@mpetroff.net>2013-08-25 23:42:22 +0000
committerMatthew Petroff <matthew@mpetroff.net>2013-08-25 23:42:22 +0000
commit77f61343ff18f29f05331131c2fe2bd810a64498 (patch)
tree9fe41722d2228560f34db2119ca4f6bed26c9704 /src/util
parentMerge bool fix and clean up the warning (diff)
downloadinkscape-77f61343ff18f29f05331131c2fe2bd810a64498.tar.gz
inkscape-77f61343ff18f29f05331131c2fe2bd810a64498.zip
Use real world units for page sizes.
(bzr r12475.1.1)
Diffstat (limited to 'src/util')
-rw-r--r--src/util/units.cpp30
-rw-r--r--src/util/units.h4
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;