diff options
| author | Liam P. White <inkscapebrony@gmail.com> | 2014-10-18 21:44:39 +0000 |
|---|---|---|
| committer | Liam P. White <inkscapebrony@gmail.com> | 2014-10-18 21:44:39 +0000 |
| commit | 68136c8b24a6995976db963a790207858e9baba5 (patch) | |
| tree | 550e81af7c8d626ec80a2be5efec66dd10d84bc4 /src/document.cpp | |
| parent | Update to experimental r13598 (diff) | |
| parent | Update to trunk r13621 (diff) | |
| download | inkscape-68136c8b24a6995976db963a790207858e9baba5.tar.gz inkscape-68136c8b24a6995976db963a790207858e9baba5.zip | |
Update to experimental r13619
(bzr r13341.5.18)
Diffstat (limited to 'src/document.cpp')
| -rw-r--r-- | src/document.cpp | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/src/document.cpp b/src/document.cpp index 5aad4ca5e..70fec83d7 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -709,7 +709,12 @@ void SPDocument::fitToRect(Geom::Rect const &rect, bool with_margins) double const h = rect.height(); double const old_height = getHeight().value("px"); - Inkscape::Util::Unit const *px = unit_table.getUnit("px"); + Inkscape::Util::Unit const *nv_units = unit_table.getUnit("px"); + SPNamedView *nv = sp_document_namedview(this, NULL); + if (nv != NULL) { + if (nv->getAttribute("units")) + nv_units = unit_table.getUnit(nv->getAttribute("units")); + } /* in px */ double margin_top = 0.0; @@ -717,22 +722,16 @@ void SPDocument::fitToRect(Geom::Rect const &rect, bool with_margins) double margin_right = 0.0; double margin_bottom = 0.0; - SPNamedView *nv = sp_document_namedview(this, NULL); - if (with_margins && nv) { if (nv != NULL) { - gchar const * const units_abbr = nv->getAttribute("units"); - Inkscape::Util::Unit const *margin_units = NULL; - if (units_abbr) { - margin_units = unit_table.getUnit(units_abbr); - } - if (!margin_units) { - margin_units = px; - } - margin_top = nv->getMarginLength("fit-margin-top",margin_units, px, w, h, false); - margin_left = nv->getMarginLength("fit-margin-left",margin_units, px, w, h, true); - margin_right = nv->getMarginLength("fit-margin-right",margin_units, px, w, h, true); - margin_bottom = nv->getMarginLength("fit-margin-bottom",margin_units, px, w, h, false); + margin_top = nv->getMarginLength("fit-margin-top", nv_units, unit_table.getUnit("px"), w, h, false); + margin_left = nv->getMarginLength("fit-margin-left", nv_units, unit_table.getUnit("px"), w, h, true); + margin_right = nv->getMarginLength("fit-margin-right", nv_units, unit_table.getUnit("px"), w, h, true); + margin_bottom = nv->getMarginLength("fit-margin-bottom", nv_units, unit_table.getUnit("px"), w, h, false); + margin_top = Inkscape::Util::Quantity::convert(margin_top, nv_units, "px"); + margin_left = Inkscape::Util::Quantity::convert(margin_left, nv_units, "px"); + margin_right = Inkscape::Util::Quantity::convert(margin_right, nv_units, "px"); + margin_bottom = Inkscape::Util::Quantity::convert(margin_bottom, nv_units, "px"); } } @@ -741,8 +740,8 @@ void SPDocument::fitToRect(Geom::Rect const &rect, bool with_margins) rect.max() + Geom::Point(margin_right, margin_top)); - setWidth(Inkscape::Util::Quantity(rect_with_margins.width(), px)); - setHeight(Inkscape::Util::Quantity(rect_with_margins.height(), px)); + setWidth(Inkscape::Util::Quantity(Inkscape::Util::Quantity::convert(rect_with_margins.width(), "px", nv_units), nv_units)); + setHeight(Inkscape::Util::Quantity(Inkscape::Util::Quantity::convert(rect_with_margins.height(), "px", nv_units), nv_units)); Geom::Translate const tr( Geom::Point(0, old_height - rect_with_margins.height()) |
