From 8ce353279caa84944971f22ec536433030e5d9c7 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Thu, 14 Dec 2017 14:34:35 +0100 Subject: editeng: RTF export: another buggy GetItem2() loop, for fonts Change-Id: Id25758cba59c1a3ac18ed9a63e73550fea1ee422 --- editeng/source/editeng/impedit4.cxx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'editeng') 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(aEditDoc.GetItemPool().GetItem2( nWhich, i )); - while ( pFontItem ) + auto const nFonts(aEditDoc.GetItemPool().GetItemCount2(nWhich)); + for (std::remove_const_t i = 0; i < nFonts; ++i) { + SvxFontItem const*const pFontItem = static_cast( + 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(aEditDoc.GetItemPool().GetItem2( nWhich, ++i )); } } -- cgit