Hi,

bug 47451 has a test doc (svg) attached which isn't imported correctly by LibreOffice. One problem is that the aspect ratio is changed because the viewbox is zoomed to be of identical size as the viewport. I've changed the zoom to be the same for width and height.

Christina

>From f4ec3728c66fafe01d153090678eb4c189cd7a84 Mon Sep 17 00:00:00 2001
From: Christina Rossmanith <[email protected]>
Date: Sat, 17 Mar 2012 22:06:22 +0100
Subject: [PATCH] SVG import: keep aspect ratio when transforming viewbox to viewport

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

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;
 
-- 
1.7.4.1

_______________________________________________
LibreOffice mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libreoffice

Reply via email to