diff options
| author | Matthew Petroff <matthew@mpetroff.net> | 2014-01-21 01:11:09 +0000 |
|---|---|---|
| committer | Matthew Petroff <matthew@mpetroff.net> | 2014-01-21 01:11:09 +0000 |
| commit | 77c9748e54f9170aac7c8b292377951f73da487f (patch) | |
| tree | 08cac9e4a803fb8910e2785338450e205f514367 /src/document.cpp | |
| parent | 1. make scaling of stroke of horizontal line the same as nearly horizontal li... (diff) | |
| download | inkscape-77c9748e54f9170aac7c8b292377951f73da487f.tar.gz inkscape-77c9748e54f9170aac7c8b292377951f73da487f.zip | |
Fix imprecise viewBox dimensions on page size change (bug #1235279).
Fixed bugs:
- https://launchpad.net/bugs/1235279
(bzr r12965)
Diffstat (limited to 'src/document.cpp')
| -rw-r--r-- | src/document.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/document.cpp b/src/document.cpp index e56adee68..8b956d5e7 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -585,6 +585,7 @@ Inkscape::Util::Quantity SPDocument::getWidth() const void SPDocument::setWidth(const Inkscape::Util::Quantity &width) { gdouble old_computed = root->width.computed; + gdouble old_value = root->width.value; root->width.computed = width.value("px"); /* SVG does not support meters as a unit, so we must translate meters to * cm when writing */ @@ -596,8 +597,14 @@ void SPDocument::setWidth(const Inkscape::Util::Quantity &width) root->width.unit = (SVGLength::Unit) width.unit->svgUnit(); } - if (root->viewBox_set) - root->viewBox.setMax(Geom::Point(root->viewBox.left() + (root->width.computed / old_computed) * root->viewBox.width(), root->viewBox.bottom())); + if (root->viewBox_set) { + if (abs(old_value - root->viewBox.width()) < 0.00001) { + root->viewBox.setMax(Geom::Point(root->viewBox.left() + root->width.value, root->viewBox.bottom())); + } + else { + root->viewBox.setMax(Geom::Point(root->viewBox.left() + (root->width.computed / old_computed) * root->viewBox.width(), root->viewBox.bottom())); + } + } root->updateRepr(); } @@ -622,6 +629,7 @@ Inkscape::Util::Quantity SPDocument::getHeight() const void SPDocument::setHeight(const Inkscape::Util::Quantity &height) { gdouble old_computed = root->height.computed; + gdouble old_value = root->height.value; root->height.computed = height.value("px"); /* SVG does not support meters as a unit, so we must translate meters to * cm when writing */ @@ -633,8 +641,14 @@ void SPDocument::setHeight(const Inkscape::Util::Quantity &height) root->height.unit = (SVGLength::Unit) height.unit->svgUnit(); } - if (root->viewBox_set) - root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + (root->height.computed / old_computed) * root->viewBox.height())); + if (root->viewBox_set) { + if (abs(old_value - root->viewBox.height()) < 0.00001) { + root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + root->height.value)); + } + else { + root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + (root->height.computed / old_computed) * root->viewBox.height())); + } + } root->updateRepr(); } |
