summaryrefslogtreecommitdiffstats
path: root/src/document.cpp
diff options
context:
space:
mode:
authorAlvin Penner <penner@vaxxine.com>2015-02-09 15:30:34 +0000
committerapenner <penner@vaxxine.com>2015-02-09 15:30:34 +0000
commit8d3047dd42fbe6ce43ee6d4c7bdf7abef024a0c2 (patch)
tree60c0c490e498354ae1fa6a43abbe3fa5a0145043 /src/document.cpp
parentFix build failure on Windows (diff)
downloadinkscape-8d3047dd42fbe6ce43ee6d4c7bdf7abef024a0c2.tar.gz
inkscape-8d3047dd42fbe6ce43ee6d4c7bdf7abef024a0c2.zip
restore original behavior of 'Resize Page to Selection' for the special case where page size is in %. (Bug 1419122)
Fixed bugs: - https://launchpad.net/bugs/1419122 (bzr r13912)
Diffstat (limited to 'src/document.cpp')
-rw-r--r--src/document.cpp38
1 files changed, 27 insertions, 11 deletions
diff --git a/src/document.cpp b/src/document.cpp
index 2caefb4ed..11971e63d 100644
--- a/src/document.cpp
+++ b/src/document.cpp
@@ -637,7 +637,11 @@ void SPDocument::setWidthAndHeight(const Inkscape::Util::Quantity &width, const
Inkscape::Util::Unit const *old_width_units = unit_table.getUnit("px");
if (root->width.unit)
old_width_units = unit_table.getUnit(root->width.unit);
- gdouble old_width_converted = Inkscape::Util::Quantity::convert(root->width.value, old_width_units, width.unit);
+ gdouble old_width_converted; // old width converted to new units
+ if (root->width.unit == SVGLength::PERCENT)
+ old_width_converted = Inkscape::Util::Quantity::convert(root->width.computed, "px", width.unit);
+ else
+ old_width_converted = Inkscape::Util::Quantity::convert(root->width.value, old_width_units, width.unit);
root->width.computed = width.value("px");
root->width.value = width.quantity;
@@ -646,7 +650,11 @@ void SPDocument::setWidthAndHeight(const Inkscape::Util::Quantity &width, const
Inkscape::Util::Unit const *old_height_units = unit_table.getUnit("px");
if (root->height.unit)
old_height_units = unit_table.getUnit(root->height.unit);
- gdouble old_height_converted = Inkscape::Util::Quantity::convert(root->height.value, old_height_units, height.unit);
+ gdouble old_height_converted; // old height converted to new units
+ if (root->height.unit == SVGLength::PERCENT)
+ old_height_converted = Inkscape::Util::Quantity::convert(root->height.computed, "px", height.unit);
+ else
+ old_height_converted = Inkscape::Util::Quantity::convert(root->height.value, old_height_units, height.unit);
root->height.computed = height.value("px");
root->height.value = height.quantity;
@@ -678,17 +686,21 @@ Inkscape::Util::Quantity SPDocument::getWidth() const
void SPDocument::setWidth(const Inkscape::Util::Quantity &width, bool changeSize)
{
- Inkscape::Util::Unit const *old_units = unit_table.getUnit("px");
+ Inkscape::Util::Unit const *old_width_units = unit_table.getUnit("px");
if (root->width.unit)
- old_units = unit_table.getUnit(root->width.unit);
- gdouble old_converted = Inkscape::Util::Quantity::convert(root->width.value, old_units, width.unit);
+ old_width_units = unit_table.getUnit(root->width.unit);
+ gdouble old_width_converted; // old width converted to new units
+ if (root->width.unit == SVGLength::PERCENT)
+ old_width_converted = Inkscape::Util::Quantity::convert(root->width.computed, "px", width.unit);
+ else
+ old_width_converted = Inkscape::Util::Quantity::convert(root->width.value, old_width_units, width.unit);
root->width.computed = width.value("px");
root->width.value = width.quantity;
root->width.unit = (SVGLength::Unit) width.unit->svgUnit();
if (root->viewBox_set && changeSize)
- root->viewBox.setMax(Geom::Point(root->viewBox.left() + (root->width.value / old_converted) * root->viewBox.width(), root->viewBox.bottom()));
+ root->viewBox.setMax(Geom::Point(root->viewBox.left() + (root->width.value / old_width_converted) * root->viewBox.width(), root->viewBox.bottom()));
root->updateRepr();
}
@@ -713,17 +725,21 @@ Inkscape::Util::Quantity SPDocument::getHeight() const
void SPDocument::setHeight(const Inkscape::Util::Quantity &height, bool changeSize)
{
- Inkscape::Util::Unit const *old_units = unit_table.getUnit("px");
+ Inkscape::Util::Unit const *old_height_units = unit_table.getUnit("px");
if (root->height.unit)
- old_units = unit_table.getUnit(root->height.unit);
- gdouble old_converted = Inkscape::Util::Quantity::convert(root->height.value, old_units, height.unit);
+ old_height_units = unit_table.getUnit(root->height.unit);
+ gdouble old_height_converted; // old height converted to new units
+ if (root->height.unit == SVGLength::PERCENT)
+ old_height_converted = Inkscape::Util::Quantity::convert(root->height.computed, "px", height.unit);
+ else
+ old_height_converted = Inkscape::Util::Quantity::convert(root->height.value, old_height_units, height.unit);
root->height.computed = height.value("px");
root->height.value = height.quantity;
root->height.unit = (SVGLength::Unit) height.unit->svgUnit();
if (root->viewBox_set && changeSize)
- root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + (root->height.value / old_converted) * root->viewBox.height()));
+ root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + (root->height.value / old_height_converted) * root->viewBox.height()));
root->updateRepr();
}
@@ -761,7 +777,7 @@ void SPDocument::fitToRect(Geom::Rect const &rect, bool with_margins)
double const old_height = getHeight().value("px");
Inkscape::Util::Unit const *nv_units = unit_table.getUnit("px");
- if (root->height.unit)
+ if (root->height.unit && (root->height.unit != SVGLength::PERCENT))
nv_units = unit_table.getUnit(root->height.unit);
SPNamedView *nv = sp_document_namedview(this, NULL);