Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


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 <ChrRossmanith@web.de>
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


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.