From 6b4730f5649c9d028b140168f92f1fc12c2fb2cb Mon Sep 17 00:00:00 2001 From: Hossein Date: Mon, 8 Nov 2021 02:29:36 +0100 Subject: Make usage of ETO_PDY flag more visible (EMF) * Make usage of ETO_PDY flag more visible with introducing nBytesEach variable * Add comments for reading OutputDx ETO_PDY flag indicates that we should read twice values compared to the number of characters in the output string. Values are stored in an array of 32-bit unsigned integers called OutputDx, so there will be either 8 bytes or 4 bytes each depending on ETO_PDY is set or not. Change-Id: I3892c95bd9ad80b3c414e2556f91bd5218b22c3e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124097 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- emfio/source/reader/emfreader.cxx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx index 83754ace1f2d..7a29571d4773 100644 --- a/emfio/source/reader/emfreader.cxx +++ b/emfio/source/reader/emfreader.cxx @@ -1907,6 +1907,7 @@ namespace emfio else if ( nOptions & ETO_OPAQUE ) DrawRectWithBGColor( aRect ); + // ETO_RTLREADING indicates that the characters are laid from right to left vcl::text::ComplexTextLayoutFlags nTextLayoutMode = vcl::text::ComplexTextLayoutFlags::Default; if ( nOptions & ETO_RTLREADING ) nTextLayoutMode = vcl::text::ComplexTextLayoutFlags::BiDiRtl | vcl::text::ComplexTextLayoutFlags::TextOriginLeft; @@ -1943,7 +1944,20 @@ namespace emfio std::unique_ptr pDYAry; sal_Int32 nDxSize; - bool bOverflow = o3tl::checked_multiply(nLen, (nOptions & ETO_PDY) ? 8 : 4, nDxSize); + sal_Int32 nBytesEach; + + // Reading OutputDx + // ETO_PDY flag indicates that we should read twice values + // compared to the number of characters in the output string. + // Values are stored in an array of 32-bit unsigned integers + // named OutputDx, so there will be either 8 bytes or 4 bytes + // each depending on ETO_PDY is set or not. + if (nOptions & ETO_PDY) + nBytesEach = 8; + else + nBytesEach = 4; + + bool bOverflow = o3tl::checked_multiply(nLen, nBytesEach, nDxSize); if (!bOverflow && offDx && ((nCurPos + offDx + nDxSize) <= nNextPos ) && nNextPos <= mnEndPos) { mpInputStream->Seek( nCurPos + offDx ); -- cgit