svx/source/svdraw/svdoole2.cxx | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)
New commits: commit 5316e32d72584a60054c4ba98c40067712058d26 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Mon May 29 15:34:09 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Mon May 29 21:35:07 2023 +0200 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.gran...@collabora.co.uk> diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx index 45235d8a9db3..58c0c5d8ff91 100644 --- a/svx/source/svdraw/svdoole2.cxx +++ b/svx/source/svdraw/svdoole2.cxx @@ -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; }