avoiding cppunit zerodiv correction
Lionel Elie Mamane
lionel at mamane.lu
Thu May 29 22:17:57 PDT 2014
About this commit:
--- a/sd/source/ui/dlg/docprev.cxx
+++ b/sd/source/ui/dlg/docprev.cxx
@@ -87,7 +87,7 @@ void SdDocPreviewWin::CalcSizeAndPos( GDIMetaFile* pFile, Size& rSize, Point& rP
void SdDocPreviewWin::CalcSizeAndPos( GDIMetaFile* pFile, Size& rSize, Point& rPoint )
{
Size aTmpSize = pFile ? pFile->GetPrefSize() : Size(1,1 );
long nWidth = rSize.Width() - 2*FRAME;
long nHeight = rSize.Height() - 2*FRAME;
if( nWidth < 0 ) nWidth = 0;
- if( nHeight < 0 ) nHeight = 0;
+ if( nHeight < 0 ) nHeight = 1;
double dRatio=((double)aTmpSize.Width())/aTmpSize.Height();
double dRatioPreV=((double) nWidth ) / nHeight;
if (dRatio>dRatioPreV)
{
rSize=Size(nWidth, (sal_uInt16)(nWidth/dRatio));
rPoint=Point( 0, (sal_uInt16)((nHeight-rSize.Height())/2));
}
else
{
rSize=Size((sal_uInt16)(nHeight*dRatio), nHeight);
rPoint=Point((sal_uInt16)((nWidth-rSize.Width())/2),0);
}
}
I wonder if we should not rather do something like:
double dRatioPreV;
if( nHeight < 0 )
{
nHeight = 0;
dRatioPreV = 1; // or rather zero? or +infinity? Do we want to
// "force" a branch of the next if/else?
}
else
dRatioPreV = ((double) nWidth ) / nHeight;
Anybody has a good idea, preferably based on an understanding of what
this function does?
--
Lionel
More information about the LibreOffice
mailing list