diff options
author | Michael Stahl <mstahl@redhat.com> | 2017-12-14 14:17:03 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2017-12-14 15:59:23 +0100 |
commit | 30504139af039d524ca0fd7158fc21ed38db2d9f (patch) | |
tree | 16d9e02af1da5667ff234b34b855f97a68e6decb /editeng | |
parent | 4fbe04cd7fe280ddc57a8dc8a7c4f07e30a340ac (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.
Change-Id: I976c95387b4c45e5a4371254f130df6b24370eaa
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/editeng/impedit4.cxx | 10 |
1 files changed, 4 insertions, 6 deletions
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 ); |