[Libreoffice-commits] core.git: filter/source

Caolán McNamara caolanm at redhat.com
Tue Oct 24 16:13:26 UTC 2017


 filter/source/graphicfilter/idxf/dxf2mtf.cxx |   29 ++++++++++++++-------------
 1 file changed, 16 insertions(+), 13 deletions(-)

New commits:
commit c204b7de9d6eda4a005ccf0e007348e1ddad03be
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Oct 24 12:10:01 2017 +0100

    ofz#3754 Divide-by-zero
    
    Change-Id: I2e8504dd67d2a7ad1e83a95d7be5a1d1086de5d5
    Reviewed-on: https://gerrit.libreoffice.org/43758
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/filter/source/graphicfilter/idxf/dxf2mtf.cxx b/filter/source/graphicfilter/idxf/dxf2mtf.cxx
index 692151d4012b..b06827c6d17e 100644
--- a/filter/source/graphicfilter/idxf/dxf2mtf.cxx
+++ b/filter/source/graphicfilter/idxf/dxf2mtf.cxx
@@ -761,7 +761,7 @@ DXF2GDIMetaFile::~DXF2GDIMetaFile()
 
 bool DXF2GDIMetaFile::Convert(const DXFRepresentation & rDXF, GDIMetaFile & rMTF, sal_uInt16 nminpercent, sal_uInt16 nmaxpercent)
 {
-    double fWidth,fHeight,fScale;
+    double fWidth,fHeight,fScale(0.0);
     DXFTransform aTransform;
     Size aPrefSize;
     const DXFLayer * pLayer;
@@ -824,13 +824,12 @@ bool DXF2GDIMetaFile::Convert(const DXFRepresentation & rDXF, GDIMetaFile & rMTF
             fHeight=pDXF->aBoundingBox.fMaxY-pDXF->aBoundingBox.fMinY;
             if (fWidth<=0 || fHeight<=0) {
                 bStatus=false;
-                fScale = 0;  // -Wall added this...
             }
             else {
-                    if (fWidth>fHeight)
-                        fScale=10000.0/fWidth;
-                    else
-                        fScale=10000.0/fHeight;
+                if (fWidth>fHeight)
+                    fScale=10000.0/fWidth;
+                else
+                    fScale=10000.0/fHeight;
                 aTransform=DXFTransform(fScale,-fScale,fScale,
                                         DXFVector(-pDXF->aBoundingBox.fMinX*fScale,
                                                    pDXF->aBoundingBox.fMaxY*fScale,
@@ -843,17 +842,21 @@ bool DXF2GDIMetaFile::Convert(const DXFRepresentation & rDXF, GDIMetaFile & rMTF
     else {
         fHeight=pVPort->fHeight;
         fWidth=fHeight*pVPort->fAspectRatio;
+        if (fWidth<=0 || fHeight<=0) {
+            bStatus=false;
+        } else {
             if (fWidth>fHeight)
                 fScale=10000.0/fWidth;
             else
                 fScale=10000.0/fHeight;
-        aTransform=DXFTransform(
-            DXFTransform(pVPort->aDirection,pVPort->aTarget),
-            DXFTransform(
-                DXFTransform(1.0,-1.0,1.0,DXFVector(fWidth/2-pVPort->fCenterX,fHeight/2+pVPort->fCenterY,0)),
-                DXFTransform(fScale,fScale,fScale,DXFVector(0,0,0))
-            )
-        );
+            aTransform=DXFTransform(
+                DXFTransform(pVPort->aDirection,pVPort->aTarget),
+                DXFTransform(
+                    DXFTransform(1.0,-1.0,1.0,DXFVector(fWidth/2-pVPort->fCenterX,fHeight/2+pVPort->fCenterY,0)),
+                    DXFTransform(fScale,fScale,fScale,DXFVector(0,0,0))
+                )
+            );
+        }
         aPrefSize.Width() =(long)(fWidth*fScale+1.5);
         aPrefSize.Height()=(long)(fHeight*fScale+1.5);
     }


More information about the Libreoffice-commits mailing list