[Libreoffice-commits] .: filter/source

Fridrich Strba fridrich at kemper.freedesktop.org
Wed Mar 21 22:48:51 PDT 2012


 filter/source/svg/svgreader.cxx |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

New commits:
commit 11ccf88eeb8e4148ca532e3a42ddca356ebde811
Author: Christina Rossmanith <ChrRossmanith at web.de>
Date:   Sat Mar 17 22:06:22 2012 +0100

    SVG import: keep aspect ratio when transforming viewbox to viewport

diff --git a/filter/source/svg/svgreader.cxx b/filter/source/svg/svgreader.cxx
index 5d46c7c..cd5da23 100644
--- a/filter/source/svg/svgreader.cxx
+++ b/filter/source/svg/svgreader.cxx
@@ -293,12 +293,13 @@ struct AnnotatingVisitor
                     maCurrState.maViewBox.getWidth() != 0.0 &&
                     maCurrState.maViewBox.getHeight() != 0.0 )
                 {
-                    // transform aViewBox into viewport, such that they
-                    // coincide
+                    // transform aViewBox into viewport, keep aspect ratio
                     aLocalTransform.translate(-maCurrState.maViewBox.getMinX(),
                                               -maCurrState.maViewBox.getMinY());
-                    aLocalTransform.scale(maCurrState.maViewport.getWidth()/maCurrState.maViewBox.getWidth(),
-                                          maCurrState.maViewport.getHeight()/maCurrState.maViewBox.getHeight());
+                    double scaleW = maCurrState.maViewport.getWidth()/maCurrState.maViewBox.getWidth();
+                    double scaleH = maCurrState.maViewport.getHeight()/maCurrState.maViewBox.getHeight();
+                    double scale = (scaleW < scaleH) ? scaleW : scaleH;
+                    aLocalTransform.scale(scale,scale);
                 }
                 maCurrState.maCTM = maCurrState.maCTM*maCurrState.maTransform*aLocalTransform;
 


More information about the Libreoffice-commits mailing list