emfio/source/reader/emfreader.cxx |   16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

New commits:
commit 6b4730f5649c9d028b140168f92f1fc12c2fb2cb
Author:     Hossein <hoss...@libreoffice.org>
AuthorDate: Mon Nov 8 02:29:36 2021 +0100
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Mon Nov 8 06:34:27 2021 +0100

    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 <mike.kagan...@collabora.com>

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<tools::Long[]> pDYAry;
 
                                 sal_Int32 nDxSize;
-                                bool bOverflow = 
o3tl::checked_multiply<sal_Int32>(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<sal_Int32>(nLen, nBytesEach, nDxSize);
                                 if (!bOverflow && offDx && ((nCurPos + offDx + 
nDxSize) <= nNextPos ) && nNextPos <= mnEndPos)
                                 {
                                     mpInputStream->Seek( nCurPos + offDx );

Reply via email to