avoid some invalid Fraction objects

when loading spreadsheet with embedded OLE objects

Change-Id: Ib8fe88f0ffec03e8b92d8d8b69c8763164f4dd05
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152370
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2023-05-29 15:34:09 +02:00
parent 8783f5959c
commit 5316e32d72

View file

@ -1932,12 +1932,20 @@ bool SdrOle2Obj::CalculateNewScaling( Fraction& aScaleWidth, Fraction& aScaleHei
aObjAreaSize = mpImpl->mxObjRef.GetSize( &aMapMode );
Size aSize = getRectangle().GetSize();
aScaleWidth = Fraction(aSize.Width(), aObjAreaSize.Width() );
aScaleHeight = Fraction(aSize.Height(), aObjAreaSize.Height() );
// reduce to 10 binary digits
aScaleHeight.ReduceInaccurate(10);
aScaleWidth.ReduceInaccurate(10);
if (!aObjAreaSize.Width() || !aObjAreaSize.Height())
{
// avoid invalid fractions
aScaleWidth = Fraction(1,1);
aScaleHeight = Fraction(1,1);
}
else
{
aScaleWidth = Fraction(aSize.Width(), aObjAreaSize.Width() );
aScaleHeight = Fraction(aSize.Height(), aObjAreaSize.Height() );
// reduce to 10 binary digits
aScaleHeight.ReduceInaccurate(10);
aScaleWidth.ReduceInaccurate(10);
}
return true;
}