diff options
author | Michael Stahl <mstahl@redhat.com> | 2017-12-14 14:17:03 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-12-18 13:46:08 +0100 |
commit | b8ba995f079add002ab9606168d31d5386993160 (patch) | |
tree | 662cf7028fe445a001023bac232b09807b2ec89f | |
parent | a1e377aff16ea7c4d434ab60d7ed946c82514684 (diff) |
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@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | editeng/source/editeng/impedit4.cxx | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx index f315141e9719..4b09582b99d1 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 (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++ ) @@ -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 )); } } @@ -392,16 +395,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 (sal_uInt32 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 ); |