summaryrefslogtreecommitdiffstats
path: root/src/util
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2016-03-18 10:23:29 +0000
committertavmjong-free <tavmjong@free.fr>2016-03-18 10:23:29 +0000
commita714c688d60a3a62114591984f57f26cd41dbed9 (patch)
tree3ad1c84aaf1097272b8ee2d4fca5db70f9c4edd3 /src/util
parentRevert 14707 (diff)
downloadinkscape-a714c688d60a3a62114591984f57f26cd41dbed9.tar.gz
inkscape-a714c688d60a3a62114591984f57f26cd41dbed9.zip
Reverting 14701.
(bzr r14716.1.2)
Diffstat (limited to 'src/util')
-rw-r--r--src/util/units.cpp70
-rw-r--r--src/util/units.h8
2 files changed, 14 insertions, 64 deletions
diff --git a/src/util/units.cpp b/src/util/units.cpp
index 2e7a3b1d2..2c72ec3ae 100644
--- a/src/util/units.cpp
+++ b/src/util/units.cpp
@@ -81,21 +81,7 @@ unsigned const svg_length_lookup[] = {
UNIT_CODE_PERCENT
};
-/* From SP_CSS_UNIT_* to unit */
-unsigned const sp_css_unit_lookup[] = {
- 0,
- UNIT_CODE_PX,
- UNIT_CODE_PT,
- UNIT_CODE_PC,
- UNIT_CODE_MM,
- UNIT_CODE_CM,
- UNIT_CODE_IN,
- UNIT_CODE_EM,
- UNIT_CODE_EX,
- UNIT_CODE_PERCENT
- // UNIT_CODE_FT Missing,
- // UNIT_CODE_MT Missing,
-};
+
// maps unit codes obtained from their abbreviations to their SVGLength unit indexes
typedef INK_UNORDERED_MAP<unsigned, SVGLength::Unit> UnitCodeLookup;
@@ -227,10 +213,6 @@ bool Unit::compatibleWith(Glib::ustring const &u) const
{
return compatibleWith(unit_table.getUnit(u));
}
-bool Unit::compatibleWith(char const *u) const
-{
- return compatibleWith(unit_table.getUnit(u));
-}
bool Unit::operator==(Unit const &other) const
{
@@ -249,29 +231,7 @@ int Unit::svgUnit() const
return 0;
}
-double Unit::convert(double from_dist, Unit const *to) const
-{
- // Percentage
- if (to->type == UNIT_TYPE_DIMENSIONLESS) {
- return from_dist * to->factor;
- }
-
- // Incompatible units
- if (type != to->type) {
- return -1;
- }
-
- // Compatible units
- return from_dist * factor / to->factor;
-}
-double Unit::convert(double from_dist, Glib::ustring const &to) const
-{
- return convert(from_dist, unit_table.getUnit(to));
-}
-double Unit::convert(double from_dist, char const *to) const
-{
- return convert(from_dist, unit_table.getUnit(to));
-}
+
Unit UnitTable::_empty_unit;
@@ -323,19 +283,6 @@ Unit const *UnitTable::getUnit(SVGLength::Unit u) const
}
return &_empty_unit;
}
-/* SP_CSS_UNIT lookup */
-Unit const *UnitTable::getUnit(unsigned int u) const
-{
- if (u == 0 || u > 9) {
- return &_empty_unit;
- }
-
- UnitCodeMap::const_iterator f = _unit_map.find(sp_css_unit_lookup[u]);
- if (f != _unit_map.end()) {
- return &(*f->second);
- }
- return &_empty_unit;
-}
Unit const *UnitTable::findUnit(double factor, UnitType type) const
{
@@ -558,7 +505,18 @@ Glib::ustring Quantity::string() const {
double Quantity::convert(double from_dist, Unit const *from, Unit const *to)
{
- return from->convert(from_dist, to);
+ // Percentage
+ if (to->type == UNIT_TYPE_DIMENSIONLESS) {
+ return from_dist * to->factor;
+ }
+
+ // Incompatible units
+ if (from->type != to->type) {
+ return -1;
+ }
+
+ // Compatible units
+ return from_dist * from->factor / to->factor;
}
double Quantity::convert(double from_dist, Glib::ustring const &from, Unit const *to)
{
diff --git a/src/util/units.h b/src/util/units.h
index a840a37ec..13777fd1b 100644
--- a/src/util/units.h
+++ b/src/util/units.h
@@ -75,11 +75,6 @@ public:
/** Get SVG unit code. */
int svgUnit() const;
-
- /** Convert value from this unit **/
- double convert(double from_dist, Unit const *to) const;
- double convert(double from_dist, Glib::ustring const &to) const;
- double convert(double from_dist, char const *to) const;
};
class Quantity
@@ -152,9 +147,6 @@ public:
/** Retrieve a given unit based on its SVGLength unit */
Unit const *getUnit(SVGLength::Unit u) const;
-
- /** Retrieve a given unit based on its SP_CSS_UNIT */
- Unit const *getUnit(unsigned int u) const;
/** Retrieve a quantity based on its string identifier */
Quantity parseQuantity(Glib::ustring const &q) const;