[Libreoffice-commits] core.git: 2 commits - editeng/source
Michael Stahl
mstahl at redhat.com
Thu Dec 14 15:04:28 UTC 2017
editeng/source/editeng/impedit4.cxx | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
New commits:
commit 8ce353279caa84944971f22ec536433030e5d9c7
Author: Michael Stahl <mstahl at redhat.com>
Date: Thu Dec 14 14:34:35 2017 +0100
editeng: RTF export: another buggy GetItem2() loop, for fonts
Change-Id: Id25758cba59c1a3ac18ed9a63e73550fea1ee422
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index 000b6eaf56e6..448c6bafaf66 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -315,10 +315,15 @@ ErrCode 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 (std::remove_const_t<decltype(nFonts)> 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++ )
@@ -328,8 +333,6 @@ ErrCode ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel )
if ( !bAlreadyExist )
aFontTable.push_back( new SvxFontItem( *pFontItem ) );
-
- pFontItem = static_cast<const SvxFontItem*>(aEditDoc.GetItemPool().GetItem2( nWhich, ++i ));
}
}
commit 30504139af039d524ca0fd7158fc21ed38db2d9f
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.
Change-Id: I976c95387b4c45e5a4371254f130df6b24370eaa
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index 1114fee47b9a..000b6eaf56e6 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -392,16 +392,14 @@ ErrCode ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel )
{
aColorList.push_back(rDefault.GetValue());
}
- sal_uInt32 i = 0;
- SvxColorItem const* pColorItem = aEditDoc.GetItemPool().GetItem2( EE_CHAR_COLOR, i);
- while ( pColorItem )
+ auto const nColors(aEditDoc.GetItemPool().GetItemCount2(EE_CHAR_COLOR));
+ for (std::remove_const_t<decltype(nColors)> i = 0; i < nColors; ++i)
{
- ++i;
- if ( pColorItem->GetValue() != COL_AUTO )
+ SvxColorItem const*const pColorItem(aEditDoc.GetItemPool().GetItem2(EE_CHAR_COLOR, i));
+ if (pColorItem && pColorItem->GetValue() != COL_AUTO) // may be null!
{
aColorList.push_back(pColorItem->GetValue());
}
- pColorItem = aEditDoc.GetItemPool().GetItem2(EE_CHAR_COLOR, i);
}
rOutput.WriteChar( '{' ).WriteCharPtr( OOO_STRING_SVTOOLS_RTF_COLORTBL );
More information about the Libreoffice-commits
mailing list