emfio/source/reader/emfreader.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
New commits: commit 2f590d0b66eddc53abe775ab344a195489d0a031 Author: Hossein <[email protected]> AuthorDate: Mon Nov 8 22:24:51 2021 +0100 Commit: Mike Kaganski <[email protected]> CommitDate: Tue Nov 9 07:14:30 2021 +0100 Simplify conditions for EMR_STRETCHDIBITS (EMF) The variables xSrc, ySrc (x/y positions) and cxSrc, cySrc (x/y size) come from [MS-EMF] documentation, "EMR_STRETCHDIBITS Record" section. By calculating the difference between Bitmap x size and cxSrc (called nWidthDiff), and also Bitmap y size and cySrc (called nHeightDiff), the conditions used to test if it is OK to crop are simplified, and are better readable. Redundant checks (nWidthDiff >= 0) and (nHeightDiff >= 0) are removed because it is now obvious that when they are bigger than non-negative xSrc and ySrc, thus they themselves can not be negative. Change-Id: I8e82c3d469377f21d34b57f3d50f977cf71004ce Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124096 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx index 7a29571d4773..a75c0a49e57f 100644 --- a/emfio/source/reader/emfreader.cxx +++ b/emfio/source/reader/emfreader.cxx @@ -1794,13 +1794,13 @@ namespace emfio aTmp.Seek( 0 ); ReadDIB(aBitmap, aTmp, true); + const tools::Long nWidthDiff = aBitmap.GetSizePixel().Width() - cxSrc; + const tools::Long nHeightDiff = aBitmap.GetSizePixel().Height() - cySrc; + // test if it is sensible to crop if ( (cxSrc > 0) && (cySrc > 0) && (xSrc >= 0) && (ySrc >= 0) && - (aBitmap.GetSizePixel().Width() >= cxSrc) && - (xSrc <= aBitmap.GetSizePixel().Width() - cxSrc) && - (aBitmap.GetSizePixel().Height() >= cySrc) && - (ySrc <= aBitmap.GetSizePixel().Height() - cySrc) ) + (xSrc <= nWidthDiff) && (ySrc <= nHeightDiff) ) { tools::Rectangle aCropRect( Point( xSrc, ySrc ), Size( cxSrc, cySrc ) ); aBitmap.Crop( aCropRect );
