summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e8ebaeb)
raw | patch | inline | side by side (parent: e8ebaeb)
author | speleo3 <speleo3@users.sourceforge.net> | |
Sun, 7 Dec 2008 21:25:14 +0000 (21:25 +0000) | ||
committer | speleo3 <speleo3@users.sourceforge.net> | |
Sun, 7 Dec 2008 21:25:14 +0000 (21:25 +0000) |
src/document.cpp | patch | blob | history |
diff --git a/src/document.cpp b/src/document.cpp
index d38d5423fde0fee95ba41a4966c36203e6613b5b..a2923c0864107d9f9b4069f9a14a1497eea448e5 100644 (file)
--- a/src/document.cpp
+++ b/src/document.cpp
if (root->width.unit == SVGLength::PERCENT && root->viewBox_set) { // set to viewBox=
root->viewBox.x1 = root->viewBox.x0 + sp_units_get_pixels (width, *unit);
} else { // set to width=
+ gdouble old_computed = root->width.computed;
root->width.computed = sp_units_get_pixels (width, *unit);
/* SVG does not support meters as a unit, so we must translate meters to
* cm when writing */
root->width.value = width;
root->width.unit = (SVGLength::Unit) sp_unit_get_svg_unit(unit);
}
+
+ if (root->viewBox_set)
+ root->viewBox.x1 = root->viewBox.x0 + (root->width.computed / old_computed) * (root->viewBox.x1 - root->viewBox.x0);
}
SP_OBJECT (root)->updateRepr();
@@ -532,6 +536,7 @@ void sp_document_set_height (SPDocument * document, gdouble height, const SPUnit
if (root->height.unit == SVGLength::PERCENT && root->viewBox_set) { // set to viewBox=
root->viewBox.y1 = root->viewBox.y0 + sp_units_get_pixels (height, *unit);
} else { // set to height=
+ gdouble old_computed = root->height.computed;
root->height.computed = sp_units_get_pixels (height, *unit);
/* SVG does not support meters as a unit, so we must translate meters to
* cm when writing */
@@ -542,6 +547,9 @@ void sp_document_set_height (SPDocument * document, gdouble height, const SPUnit
root->height.value = height;
root->height.unit = (SVGLength::Unit) sp_unit_get_svg_unit(unit);
}
+
+ if (root->viewBox_set)
+ root->viewBox.y1 = root->viewBox.y0 + (root->height.computed / old_computed) * (root->viewBox.y1 - root->viewBox.y0);
}
SP_OBJECT (root)->updateRepr();