[Libreoffice-commits] core.git: emfio/source

Bartosz Kosiorek (via logerrit) logerrit at kemper.freedesktop.org
Fri Jun 18 17:12:22 UTC 2021


 emfio/source/reader/emfreader.cxx |  165 ++++++++++++++++++--------------------
 1 file changed, 82 insertions(+), 83 deletions(-)

New commits:
commit e48463e81c7eb9a3938128b642d153917fcbbdae
Author:     Bartosz Kosiorek <gang65 at poczta.onet.pl>
AuthorDate: Fri Jun 18 13:03:09 2021 +0200
Commit:     Bartosz Kosiorek <gang65 at poczta.onet.pl>
CommitDate: Fri Jun 18 19:11:37 2021 +0200

    Resolves: ofz#34920 allow displaying only one text string
    
    Change-Id: I8bc4ed015dfad4fd99ca8cfce7fca0e7b411edf3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117443
    Tested-by: Jenkins
    Reviewed-by: Bartosz Kosiorek <gang65 at poczta.onet.pl>

diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx
index 4ad77dd3fb32..1b9e8ec34326 100644
--- a/emfio/source/reader/emfreader.cxx
+++ b/emfio/source/reader/emfreader.cxx
@@ -1826,112 +1826,111 @@ namespace emfio
                         {
                             mpInputStream->ReadUInt32( ncStrings );
                             SAL_INFO("emfio", "\t\t Number of Text objects: " << ncStrings);
+                            if ( ncStrings == 0 )
+                                break;
                         }
-                        for (sal_uInt32 nStringNo = 0; nStringNo < ncStrings && mpInputStream->good(); ++nStringNo)
+                        mpInputStream->ReadInt32( ptlReferenceX ).ReadInt32( ptlReferenceY ).ReadUInt32( nLen ).ReadUInt32( nOffString ).ReadUInt32( nOptions );
+                        SAL_INFO("emfio", "\t\tReference: (" << ptlReferenceX << ", " << ptlReferenceY << ")");
+
+                        mpInputStream->ReadInt32( nLeftRect ).ReadInt32( nTopRect ).ReadInt32( nRightRect ).ReadInt32( nBottomRect );
+                        const tools::Rectangle aRect( nLeftRect, nTopRect, nRightRect, nBottomRect );
+                        const BkMode mnBkModeBackup = mnBkMode;
+                        if ( nOptions & ETO_NO_RECT ) // Don't draw the background rectangle and text background
+                            mnBkMode = BkMode::Transparent;
+                        else if ( nOptions & ETO_OPAQUE )
+                            DrawRectWithBGColor( aRect );
+                        mpInputStream->ReadUInt32( offDx );
+
+                        ComplexTextLayoutFlags nTextLayoutMode = ComplexTextLayoutFlags::Default;
+                        if ( nOptions & ETO_RTLREADING )
+                            nTextLayoutMode = ComplexTextLayoutFlags::BiDiRtl | ComplexTextLayoutFlags::TextOriginLeft;
+                        SetTextLayoutMode( nTextLayoutMode );
+                        SAL_WARN_IF( ( nOptions & ( ETO_PDY | ETO_GLYPH_INDEX ) ) != 0, "emfio", "SJ: ETO_PDY || ETO_GLYPH_INDEX in EMF" );
+
+                        Point aPos( ptlReferenceX, ptlReferenceY );
+                        bool bOffStringSane = nOffString <= mnEndPos - nCurPos;
+                        if ( bOffStringSane )
                         {
-                            mpInputStream->ReadInt32( ptlReferenceX ).ReadInt32( ptlReferenceY ).ReadUInt32( nLen ).ReadUInt32( nOffString ).ReadUInt32( nOptions );
-                            SAL_INFO("emfio", "\t\tReference: (" << ptlReferenceX << ", " << ptlReferenceY << ")");
-
-                            mpInputStream->ReadInt32( nLeftRect ).ReadInt32( nTopRect ).ReadInt32( nRightRect ).ReadInt32( nBottomRect );
-                            const tools::Rectangle aRect( nLeftRect, nTopRect, nRightRect, nBottomRect );
-                            const BkMode mnBkModeBackup = mnBkMode;
-                            if ( nOptions & ETO_NO_RECT ) // Don't draw the background rectangle and text background
-                                mnBkMode = BkMode::Transparent;
-                            else if ( nOptions & ETO_OPAQUE )
-                                DrawRectWithBGColor( aRect );
-                            mpInputStream->ReadUInt32( offDx );
-
-                            ComplexTextLayoutFlags nTextLayoutMode = ComplexTextLayoutFlags::Default;
-                            if ( nOptions & ETO_RTLREADING )
-                                nTextLayoutMode = ComplexTextLayoutFlags::BiDiRtl | ComplexTextLayoutFlags::TextOriginLeft;
-                            SetTextLayoutMode( nTextLayoutMode );
-                            SAL_WARN_IF( ( nOptions & ( ETO_PDY | ETO_GLYPH_INDEX ) ) != 0, "emfio", "SJ: ETO_PDY || ETO_GLYPH_INDEX in EMF" );
-
-                            Point aPos( ptlReferenceX, ptlReferenceY );
-                            bool bOffStringSane = nOffString <= mnEndPos - nCurPos;
-                            if ( bOffStringSane )
+                            mpInputStream->Seek( nCurPos + nOffString );
+                            OUString aText;
+                            if ( bFlag )
                             {
-                                mpInputStream->Seek( nCurPos + nOffString );
-                                OUString aText;
-                                if ( bFlag )
+                                if ( nLen <= ( mnEndPos - mpInputStream->Tell() ) )
                                 {
-                                    if ( nLen <= ( mnEndPos - mpInputStream->Tell() ) )
-                                    {
-                                        std::unique_ptr<char[]> pBuf(new char[ nLen ]);
-                                        mpInputStream->ReadBytes(pBuf.get(), nLen);
-                                        aText = OUString(pBuf.get(), nLen, GetCharSet());
-                                    }
+                                    std::unique_ptr<char[]> pBuf(new char[ nLen ]);
+                                    mpInputStream->ReadBytes(pBuf.get(), nLen);
+                                    aText = OUString(pBuf.get(), nLen, GetCharSet());
                                 }
-                                else
+                            }
+                            else
+                            {
+                                if ( ( nLen * sizeof(sal_Unicode) ) <= ( mnEndPos - mpInputStream->Tell() ) )
                                 {
-                                    if ( ( nLen * sizeof(sal_Unicode) ) <= ( mnEndPos - mpInputStream->Tell() ) )
-                                    {
-                                        aText = read_uInt16s_ToOUString(*mpInputStream, nLen);
-                                    }
+                                    aText = read_uInt16s_ToOUString(*mpInputStream, nLen);
                                 }
+                            }
 
-                                SAL_INFO("emfio", "\t\tText: " << aText);
-                                SAL_INFO("emfio", "\t\tDxBuffer:");
+                            SAL_INFO("emfio", "\t\tText: " << aText);
+                            SAL_INFO("emfio", "\t\tDxBuffer:");
 
-                                std::unique_ptr<tools::Long[]> pDXAry, pDYAry;
+                            std::unique_ptr<tools::Long[]> pDXAry, pDYAry;
 
-                                sal_Int32 nDxSize;
-                                bool bOverflow = o3tl::checked_multiply<sal_Int32>(nLen, (nOptions & ETO_PDY) ? 8 : 4, nDxSize);
-                                if (!bOverflow && offDx && ((nCurPos + offDx + nDxSize) <= nNextPos ) && nNextPos <= mnEndPos)
+                            sal_Int32 nDxSize;
+                            bool bOverflow = o3tl::checked_multiply<sal_Int32>(nLen, (nOptions & ETO_PDY) ? 8 : 4, nDxSize);
+                            if (!bOverflow && offDx && ((nCurPos + offDx + nDxSize) <= nNextPos ) && nNextPos <= mnEndPos)
+                            {
+                                mpInputStream->Seek( nCurPos + offDx );
+                                pDXAry.reset( new tools::Long[aText.getLength()] );
+                                if (nOptions & ETO_PDY)
                                 {
-                                    mpInputStream->Seek( nCurPos + offDx );
-                                    pDXAry.reset( new tools::Long[aText.getLength()] );
-                                    if (nOptions & ETO_PDY)
-                                    {
-                                        pDYAry.reset( new tools::Long[aText.getLength()] );
-                                    }
+                                    pDYAry.reset( new tools::Long[aText.getLength()] );
+                                }
 
-                                    for (sal_Int32 i = 0; i < aText.getLength(); ++i)
+                                for (sal_Int32 i = 0; i < aText.getLength(); ++i)
+                                {
+                                    sal_Int32 nDxCount = 1;
+                                    if ( static_cast<sal_uInt32>( aText.getLength() ) !=  nLen )
                                     {
-                                        sal_Int32 nDxCount = 1;
-                                        if ( static_cast<sal_uInt32>( aText.getLength() ) !=  nLen )
-                                        {
-                                            sal_Unicode cUniChar = aText[i];
-                                            OString aTmp(&cUniChar, 1, GetCharSet());
-                                            if (aTmp.getLength() > 1)
-                                            {
-                                                nDxCount = aTmp.getLength();
-                                            }
-                                        }
-
-                                        sal_Int32 nDx = 0, nDy = 0;
-                                        while (nDxCount--)
+                                        sal_Unicode cUniChar = aText[i];
+                                        OString aTmp(&cUniChar, 1, GetCharSet());
+                                        if (aTmp.getLength() > 1)
                                         {
-                                            sal_Int32 nDxTmp = 0;
-                                            mpInputStream->ReadInt32(nDxTmp);
-                                            nDx += nDxTmp;
-                                            if (nOptions & ETO_PDY)
-                                            {
-                                                sal_Int32 nDyTmp = 0;
-                                                mpInputStream->ReadInt32(nDyTmp);
-                                                nDy += nDyTmp;
-                                            }
+                                            nDxCount = aTmp.getLength();
                                         }
+                                    }
 
-                                        SAL_INFO("emfio", "\t\t\tSpacing " << i << ": " << nDx);
-                                        pDXAry[i] = nDx;
+                                    sal_Int32 nDx = 0, nDy = 0;
+                                    while (nDxCount--)
+                                    {
+                                        sal_Int32 nDxTmp = 0;
+                                        mpInputStream->ReadInt32(nDxTmp);
+                                        nDx += nDxTmp;
                                         if (nOptions & ETO_PDY)
                                         {
-                                            pDYAry[i] = nDy;
+                                            sal_Int32 nDyTmp = 0;
+                                            mpInputStream->ReadInt32(nDyTmp);
+                                            nDy += nDyTmp;
                                         }
                                     }
+
+                                    SAL_INFO("emfio", "\t\t\tSpacing " << i << ": " << nDx);
+                                    pDXAry[i] = nDx;
+                                    if (nOptions & ETO_PDY)
+                                    {
+                                        pDYAry[i] = nDy;
+                                    }
                                 }
-                                if ( nOptions & ETO_CLIPPED )
-                                {
-                                    Push(); // Save the current clip. It will be restored after text drawing
-                                    IntersectClipRect( aRect );
-                                }
-                                DrawText(aPos, aText, pDXAry.get(), pDYAry.get(), mbRecordPath, nGfxMode);
-                                if ( nOptions & ETO_CLIPPED )
-                                    Pop();
                             }
-                            mnBkMode = mnBkModeBackup;
+                            if ( nOptions & ETO_CLIPPED )
+                            {
+                                Push(); // Save the current clip. It will be restored after text drawing
+                                IntersectClipRect( aRect );
+                            }
+                            DrawText(aPos, aText, pDXAry.get(), pDYAry.get(), mbRecordPath, nGfxMode);
+                            if ( nOptions & ETO_CLIPPED )
+                                Pop();
                         }
+                        mnBkMode = mnBkModeBackup;
                     }
                     break;
 


More information about the Libreoffice-commits mailing list