[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - editeng/source

Michael Stahl mstahl at redhat.com
Fri Jan 5 19:24:03 UTC 2018


 editeng/source/editeng/impedit4.cxx |   26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

New commits:
commit fedad0e8fd19b4a7b39476bbce7b8942ada97311
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Dec 14 14:17:03 2017 +0100

    editeng: fix RTF export of colors
    
    SfxItemPool may contain null pointers and return them from GetItem2(),
    even if non-null pointers follow, so have to use GetItemCount2() here.
    
    This later asserts when it can't find the items in aColorList.
    
    (cherry picked from commit 30504139af039d524ca0fd7158fc21ed38db2d9f)
    
    editeng: RTF export: another buggy GetItem2() loop, for fonts
    (cherry picked from commit 8ce353279caa84944971f22ec536433030e5d9c7)
    
    editeng: error: "remove_const_t" is not a member of "std"
    Manual type inference was an interesting oxymoronic curiosity that
    can probably only exist in C++, but it turns out our baseline
    compilers don't even support it yet.
    (cherry picked from commit 700e1e7fda6f0a415adbbd5bb190efa5c7435c4f)
    
    Change-Id: I976c95387b4c45e5a4371254f130df6b24370eaa
    Reviewed-on: https://gerrit.libreoffice.org/46469
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    (cherry picked from commit b8ba995f079add002ab9606168d31d5386993160)
    Reviewed-on: https://gerrit.libreoffice.org/46716

diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index 0715212ff856..d1e688aed165 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -340,10 +340,15 @@ sal_uInt32 ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel )
         else if ( nScriptType == 2 )
             nWhich = EE_CHAR_FONTINFO_CTL;
 
-        sal_uInt32 i = 0;
-        const SvxFontItem* pFontItem = static_cast<const SvxFontItem*>(aEditDoc.GetItemPool().GetItem2( nWhich, i ));
-        while ( pFontItem )
+        auto const nFonts(aEditDoc.GetItemPool().GetItemCount2(nWhich));
+        for (sal_uInt32 i = 0; i < nFonts; ++i)
         {
+            SvxFontItem const*const pFontItem = static_cast<const SvxFontItem*>(
+                    aEditDoc.GetItemPool().GetItem2(nWhich, i));
+            if (!pFontItem)
+            {
+                continue;
+            }
             bool bAlreadyExist = false;
             sal_uLong nTestMax = nScriptType ? aFontTable.size() : 1;
             for ( sal_uLong nTest = 0; !bAlreadyExist && ( nTest < nTestMax ); nTest++ )
@@ -353,8 +358,6 @@ sal_uInt32 ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel )
 
             if ( !bAlreadyExist )
                 aFontTable.push_back( new SvxFontItem( *pFontItem ) );
-
-            pFontItem = static_cast<const SvxFontItem*>(aEditDoc.GetItemPool().GetItem2( nWhich, ++i ));
         }
     }
 
@@ -418,18 +421,15 @@ sal_uInt32 ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel )
     {
         aColorList.push_back(rDefault.GetValue());
     }
-    sal_uInt32 i = 0;
-    SvxColorItem const* pColorItem = static_cast<SvxColorItem const*>(
-            aEditDoc.GetItemPool().GetItem2( EE_CHAR_COLOR, i));
-    while ( pColorItem )
+    auto const nColors(aEditDoc.GetItemPool().GetItemCount2(EE_CHAR_COLOR));
+    for (sal_uInt32 i = 0; i < nColors; ++i)
     {
-        ++i;
-        if ( pColorItem->GetValue() != COL_AUTO )
+        SvxColorItem const*const pColorItem(static_cast<SvxColorItem const*>(
+                    aEditDoc.GetItemPool().GetItem2(EE_CHAR_COLOR, i)));
+        if (pColorItem && pColorItem->GetValue() != COL_AUTO) // may be null!
         {
             aColorList.push_back(pColorItem->GetValue());
         }
-        pColorItem = static_cast<SvxColorItem const*>(
-                aEditDoc.GetItemPool().GetItem2(EE_CHAR_COLOR, i));
     }
 
     rOutput.WriteChar( '{' ).WriteCharPtr( OOO_STRING_SVTOOLS_RTF_COLORTBL );


More information about the Libreoffice-commits mailing list