diff options
| author | Matthew Petroff <matthew@mpetroff.net> | 2013-07-09 20:42:04 +0000 |
|---|---|---|
| committer | Matthew Petroff <matthew@mpetroff.net> | 2013-07-09 20:42:04 +0000 |
| commit | 9dc7b786c9ef31060012ea4ae13a8188548b4f62 (patch) | |
| tree | f8b063fe5b6da450ba252f2275aa342e2627b420 /src/sp-namedview.cpp | |
| parent | Switch setWidth and setHeight to use Quantity and switch to forward declarati... (diff) | |
| download | inkscape-9dc7b786c9ef31060012ea4ae13a8188548b4f62.tar.gz inkscape-9dc7b786c9ef31060012ea4ae13a8188548b4f62.zip | |
Ported sp-namedview.cpp (todo: fix a bunch of things).
(bzr r12380.1.8)
Diffstat (limited to 'src/sp-namedview.cpp')
| -rw-r--r-- | src/sp-namedview.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index 5184d37a9..c7301f9bd 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -22,7 +22,7 @@ #include "display/canvas-grid.h" #include "display/guideline.h" -#include "helper/units.h" +#include "util/units.h" #include "svg/svg-color.h" #include "xml/repr.h" #include "attributes.h" @@ -287,6 +287,8 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va { SPNamedView *nv = SP_NAMEDVIEW(object); + static Inkscape::Util::UnitTable unit_table; + switch (key) { case SP_ATTR_VIEWONLY: nv->editable = (!value); @@ -549,18 +551,19 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va * in that they aren't in general absolute units as currently required by * doc_units. */ - SPUnit const *new_unit = &sp_unit_get_by_id(SP_UNIT_PX); + static Inkscape::Util::Unit px = unit_table.getUnit("px"); + Inkscape::Util::Unit const *new_unit = &px; if (value) { - SPUnit const *const req_unit = sp_unit_get_by_abbreviation(value); - if ( req_unit == NULL ) { + Inkscape::Util::Unit u = unit_table.getUnit(value); + Inkscape::Util::Unit const *const req_unit = &u; + if ( !unit_table.hasUnit(value) ) { g_warning("Unrecognized unit `%s'", value); /* fixme: Document errors should be reported in the status bar or * the like (e.g. as per * http://www.w3.org/TR/SVG11/implnote.html#ErrorProcessing); g_log * should be only for programmer errors. */ - } else if ( req_unit->base == SP_UNIT_ABSOLUTE || - req_unit->base == SP_UNIT_DEVICE ) { + } else if ( req_unit->isAbsolute() ) { new_unit = req_unit; } else { g_warning("Document units must be absolute like `mm', `pt' or `px', but found `%s'", @@ -573,18 +576,18 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va break; } case SP_ATTR_UNITS: { - SPUnit const *new_unit = NULL; + Inkscape::Util::Unit const *new_unit = NULL; if (value) { - SPUnit const *const req_unit = sp_unit_get_by_abbreviation(value); - if ( req_unit == NULL ) { + Inkscape::Util::Unit u = unit_table.getUnit(value); + Inkscape::Util::Unit const *const req_unit = &u; + if ( !unit_table.hasUnit(value) ) { g_warning("Unrecognized unit `%s'", value); /* fixme: Document errors should be reported in the status bar or * the like (e.g. as per * http://www.w3.org/TR/SVG11/implnote.html#ErrorProcessing); g_log * should be only for programmer errors. */ - } else if ( req_unit->base == SP_UNIT_ABSOLUTE || - req_unit->base == SP_UNIT_DEVICE ) { + } else if ( req_unit->isAbsolute() ) { new_unit = req_unit; } else { g_warning("Document units must be absolute like `mm', `pt' or `px', but found `%s'", @@ -1130,7 +1133,7 @@ double SPNamedView::getMarginLength(gchar const * const key, SPMetric SPNamedView::getDefaultMetric() const { if (doc_units) { - return sp_unit_get_metric(doc_units); + return (SPMetric) doc_units->metric(); } else { return SP_PT; } |
