summaryrefslogtreecommitdiffstats
path: root/src/document.cpp
diff options
context:
space:
mode:
authorLiam P. White <inkscapebrony@gmail.com>2014-10-17 20:03:14 +0000
committerLiam P. White <inkscapebrony@gmail.com>2014-10-17 20:03:14 +0000
commit4fc13b246c0c03c26c10c421c63c33331aa57d85 (patch)
tree82f8ceea42ace9c0512b6073935e4bd9c3d14f7a /src/document.cpp
parentSmall warning cleanup (diff)
parentPort inkscape to librevenge framework for WPG, CDR and VSD imports (diff)
downloadinkscape-4fc13b246c0c03c26c10c421c63c33331aa57d85.tar.gz
inkscape-4fc13b246c0c03c26c10c421c63c33331aa57d85.zip
Update to trunk r13621
(bzr r13341.1.278)
Diffstat (limited to 'src/document.cpp')
-rw-r--r--src/document.cpp33
1 files changed, 16 insertions, 17 deletions
diff --git a/src/document.cpp b/src/document.cpp
index b50fc9575..64ccb8c36 100644
--- a/src/document.cpp
+++ b/src/document.cpp
@@ -706,7 +706,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;
@@ -714,22 +719,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");
}
}
@@ -738,8 +737,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())