Kaydet (Commit) c204b7de authored tarafından Caolán McNamara's avatar Caolán McNamara

ofz#3754 Divide-by-zero

Change-Id: I2e8504dd67d2a7ad1e83a95d7be5a1d1086de5d5
Reviewed-on: https://gerrit.libreoffice.org/43758Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 429cd1b7
...@@ -761,7 +761,7 @@ DXF2GDIMetaFile::~DXF2GDIMetaFile() ...@@ -761,7 +761,7 @@ DXF2GDIMetaFile::~DXF2GDIMetaFile()
bool DXF2GDIMetaFile::Convert(const DXFRepresentation & rDXF, GDIMetaFile & rMTF, sal_uInt16 nminpercent, sal_uInt16 nmaxpercent) 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; DXFTransform aTransform;
Size aPrefSize; Size aPrefSize;
const DXFLayer * pLayer; const DXFLayer * pLayer;
...@@ -824,7 +824,6 @@ bool DXF2GDIMetaFile::Convert(const DXFRepresentation & rDXF, GDIMetaFile & rMTF ...@@ -824,7 +824,6 @@ bool DXF2GDIMetaFile::Convert(const DXFRepresentation & rDXF, GDIMetaFile & rMTF
fHeight=pDXF->aBoundingBox.fMaxY-pDXF->aBoundingBox.fMinY; fHeight=pDXF->aBoundingBox.fMaxY-pDXF->aBoundingBox.fMinY;
if (fWidth<=0 || fHeight<=0) { if (fWidth<=0 || fHeight<=0) {
bStatus=false; bStatus=false;
fScale = 0; // -Wall added this...
} }
else { else {
if (fWidth>fHeight) if (fWidth>fHeight)
...@@ -843,6 +842,9 @@ bool DXF2GDIMetaFile::Convert(const DXFRepresentation & rDXF, GDIMetaFile & rMTF ...@@ -843,6 +842,9 @@ bool DXF2GDIMetaFile::Convert(const DXFRepresentation & rDXF, GDIMetaFile & rMTF
else { else {
fHeight=pVPort->fHeight; fHeight=pVPort->fHeight;
fWidth=fHeight*pVPort->fAspectRatio; fWidth=fHeight*pVPort->fAspectRatio;
if (fWidth<=0 || fHeight<=0) {
bStatus=false;
} else {
if (fWidth>fHeight) if (fWidth>fHeight)
fScale=10000.0/fWidth; fScale=10000.0/fWidth;
else else
...@@ -854,6 +856,7 @@ bool DXF2GDIMetaFile::Convert(const DXFRepresentation & rDXF, GDIMetaFile & rMTF ...@@ -854,6 +856,7 @@ bool DXF2GDIMetaFile::Convert(const DXFRepresentation & rDXF, GDIMetaFile & rMTF
DXFTransform(fScale,fScale,fScale,DXFVector(0,0,0)) DXFTransform(fScale,fScale,fScale,DXFVector(0,0,0))
) )
); );
}
aPrefSize.Width() =(long)(fWidth*fScale+1.5); aPrefSize.Width() =(long)(fWidth*fScale+1.5);
aPrefSize.Height()=(long)(fHeight*fScale+1.5); aPrefSize.Height()=(long)(fHeight*fScale+1.5);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment