Index: src/util/units.cpp =================================================================== --- src/util/units.cpp (revision 13320) +++ src/util/units.cpp (working copy) @@ -6,7 +6,6 @@ #include #include -#include "io/simple-sax.h" #include "util/units.h" #include "path-prefix.h" #include "streq.h" @@ -14,22 +13,6 @@ namespace Inkscape { namespace Util { -class UnitsSAXHandler : public Inkscape::IO::FlatSaxHandler -{ -public: - UnitsSAXHandler(UnitTable *table) : FlatSaxHandler(), tbl(table) {} - virtual ~UnitsSAXHandler() {} - - virtual void _startElement(xmlChar const *name, xmlChar const **attrs); - virtual void _endElement(xmlChar const *name); - - UnitTable *tbl; - bool primary; - bool skip; - Unit unit; -}; - - #define BUFSIZE (255) /** @@ -54,10 +37,8 @@ */ UnitTable::UnitTable() { - // if we swich to the xml file, don't forget to force locale to 'C' - // load("share/ui/units.xml"); // <-- Buggy gchar *filename = g_build_filename(INKSCAPE_UIDIR, "units.txt", NULL); - loadText(filename); + load(filename); g_free(filename); } @@ -139,7 +120,7 @@ possibly overwriting existing unit definitions. This loads from a text file */ bool -UnitTable::loadText(Glib::ustring const &filename) { +UnitTable::load(Glib::ustring const &filename) { char buf[BUFSIZE]; // Open file for reading @@ -221,21 +202,6 @@ return true; } -bool -UnitTable::load(Glib::ustring const &filename) { - UnitsSAXHandler handler(this); - - int result = handler.parseFile( filename.c_str() ); - if ( result != 0 ) { - // perhaps - g_warning("Problem loading units file '%s': %d\n", - filename.c_str(), result); - return false; - } - - return true; -} - /** Saves the current UnitTable to the given file. */ bool UnitTable::save(Glib::ustring const &filename) { @@ -271,63 +237,6 @@ } -void UnitsSAXHandler::_startElement(xmlChar const *name, xmlChar const **attrs) -{ - if (streq("unit", (char const *)name)) { - // reset for next use - unit.name.clear(); - unit.name_plural.clear(); - unit.abbr.clear(); - unit.description.clear(); - unit.type = UNIT_TYPE_DIMENSIONLESS; - unit.factor = 1.0; - primary = false; - skip = false; - - for ( int i = 0; attrs[i]; i += 2 ) { - char const *const key = (char const *)attrs[i]; - if (streq("type", key)) { - char const *type = (char const*)attrs[i+1]; - if (streq(type, "DIMENSIONLESS")) { - unit.type = UNIT_TYPE_DIMENSIONLESS; - } else if (streq(type, "LINEAR")) { - unit.type = UNIT_TYPE_LINEAR; - } else if (streq(type, "RADIAL")) { - unit.type = UNIT_TYPE_RADIAL; - } else if (streq(type, "FONT_HEIGHT")) { - unit.type = UNIT_TYPE_FONT_HEIGHT; - } else { - g_warning("Skipping unknown unit type '%s' for %s.\n", type, name); - skip = true; - } - } else if (streq("pri", key)) { - primary = attrs[i+1][0] == 'y' || attrs[i+1][0] == 'Y'; - } - } - } -} - -void UnitsSAXHandler::_endElement(xmlChar const *xname) -{ - char const *const name = (char const *) xname; - if (streq("name", name)) { - unit.name = data; - } else if (streq("plural", name)) { - unit.name_plural = data; - } else if (streq("abbr", name)) { - unit.abbr = data; - } else if (streq("factor", name)) { - // TODO make sure we use the right conversion - unit.factor = atol(data.c_str()); - } else if (streq("description", name)) { - unit.description = data; - } else if (streq("unit", name)) { - if (!skip) { - tbl->addUnit(unit, primary); - } - } -} - } // namespace Util } // namespace Inkscape Index: src/util/units.h =================================================================== --- src/util/units.h (revision 13320) +++ src/util/units.h (working copy) @@ -67,7 +67,6 @@ void setScale(); bool load(Glib::ustring const &filename); - bool loadText(Glib::ustring const &filename); bool save(Glib::ustring const &filename); protected: Index: share/ui/units.xml =================================================================== --- share/ui/units.xml (revision 13320) +++ share/ui/units.xml (working copy) @@ -1,101 +0,0 @@ - - - - % - % - % - 1.00 - Percentage - - - pixel - pixels - px - 1.00 - CSS Pixels (90/inch) - - - point - points - pt - 1.25 - PostScript points (72/inch) - - - pica - picas - pc - 15.0 - 12 points - - - inch - inches - in - 90.0 - Inches (90 px/in) - - - millimeter - millimeters - mm - 3.543307 - Millimeters (25.4 mm/in) - - - centimeter - centimeters - cm - 35.43307 - Centimeters (10 mm/cm) - - - meter - meters - m - 3543.307 - Meters (100 cm/m) - - - foot - feet - ft - 1080 - Feet (12 in/ft) - - - degree - degrees - deg - 1.00 - Degrees - - - radian - radians - rad - 57.296 - Radians (57.296 deg/rad) - - - font-height - font-heights - em - 1.00 - Font height - - - x-height - x-heights - ex - 0.50 - Height of letter 'x' - - - half-em - half-ems - en - 0.50 - Half of font height - - Index: share/ui/Makefile.am =================================================================== --- share/ui/Makefile.am (revision 13320) +++ share/ui/Makefile.am (working copy) @@ -5,7 +5,6 @@ keybindings.rc \ menus-bars.xml \ toolbox.xml \ - units.txt \ - units.xml + units.txt EXTRA_DIST = $(ui_DATA)