diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index 174c20c797e8..2471d7c9a578 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -1443,6 +1443,9 @@ public: /// Iterate over all RES_CHRATR_BOX SvxBoxItem, if the function returns false, iteration is stopped SW_DLLPUBLIC void ForEachCharacterBoxItem(const std::function& ) const; + /// Iterate over all RES_CHRATR_COLOR SvxColorItem, if the function returns false, iteration is stopped + SW_DLLPUBLIC void ForEachCharacterColorItem(const std::function& ) const; + // Call into intransparent Basic; expect possible Return String. void ExecMacro( const SvxMacro& rMacro, OUString* pRet, SbxArray* pArgs ); diff --git a/sw/source/core/bastyp/init.cxx b/sw/source/core/bastyp/init.cxx index 99b8a8a45da9..796b4ae68780 100644 --- a/sw/source/core/bastyp/init.cxx +++ b/sw/source/core/bastyp/init.cxx @@ -279,7 +279,7 @@ ItemInfoPackage& getItemInfoPackageSwAttributes() // m_nWhich, m_pItem, m_nSlotID, m_nItemInfoFlags { RES_CHRATR_CASEMAP, new SvxCaseMapItem( SvxCaseMap::NotMapped, RES_CHRATR_CASEMAP), SID_ATTR_CHAR_CASEMAP, SFX_ITEMINFOFLAG_NONE }, { RES_CHRATR_CHARSETCOLOR, new SvxColorItem(RES_CHRATR_CHARSETCOLOR), SID_ATTR_CHAR_CHARSETCOLOR, SFX_ITEMINFOFLAG_NONE }, - { RES_CHRATR_COLOR, new SvxColorItem(RES_CHRATR_COLOR), SID_ATTR_CHAR_COLOR, SFX_ITEMINFOFLAG_SUPPORT_SURROGATE }, + { RES_CHRATR_COLOR, new SvxColorItem(RES_CHRATR_COLOR), SID_ATTR_CHAR_COLOR, SFX_ITEMINFOFLAG_NONE }, { RES_CHRATR_CONTOUR, new SvxContourItem( false, RES_CHRATR_CONTOUR ), SID_ATTR_CHAR_CONTOUR, SFX_ITEMINFOFLAG_NONE }, { RES_CHRATR_CROSSEDOUT, new SvxCrossedOutItem( STRIKEOUT_NONE, RES_CHRATR_CROSSEDOUT ), SID_ATTR_CHAR_STRIKEOUT, SFX_ITEMINFOFLAG_NONE }, { RES_CHRATR_ESCAPEMENT, new SvxEscapementItem( RES_CHRATR_ESCAPEMENT ), SID_ATTR_CHAR_ESCAPEMENT, SFX_ITEMINFOFLAG_NONE }, diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index eb43f3c30ab2..102eee83a852 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -52,6 +52,7 @@ #include #include #include +#include #include #include @@ -1430,6 +1431,28 @@ void SwDoc::ForEachCharacterBoxItem( const std::function& rFunc ) const +{ + for(SwCharFormat* pFormat : *GetCharFormats()) + { + const SwAttrSet& rAttrSet = pFormat->GetAttrSet(); + if (const SvxColorItem* pColorItem = rAttrSet.GetItemIfSet(RES_CHRATR_COLOR)) + if (!rFunc(*pColorItem)) + return; + } + std::vector> aStyles; + for (auto eFamily : { IStyleAccess::AUTO_STYLE_CHAR, IStyleAccess::AUTO_STYLE_RUBY, IStyleAccess::AUTO_STYLE_PARA, IStyleAccess::AUTO_STYLE_NOTXT }) + { + const_cast(this)->GetIStyleAccess().getAllStyles(aStyles, eFamily); + for (const auto & rxItemSet : aStyles) + if (const SvxColorItem* pColorItem = rxItemSet->GetItemIfSet(RES_CHRATR_COLOR)) + if (!rFunc(*pColorItem)) + return; + } +} + + void SwDoc::Summary(SwDoc& rExtDoc, sal_uInt8 nLevel, sal_uInt8 nPara, bool bImpress) { const SwOutlineNodes& rOutNds = GetNodes().GetOutLineNds(); diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx index 51870977c879..8191b36665e7 100644 --- a/sw/source/filter/ww8/rtfexport.cxx +++ b/sw/source/filter/ww8/rtfexport.cxx @@ -1325,12 +1325,10 @@ void RtfExport::OutColorTable() pCol = rPool.GetUserDefaultItem(RES_CHRATR_COLOR); if (pCol) InsColor(pCol->GetValue()); - rPool.GetItemSurrogates(aSurrogates, RES_CHRATR_COLOR); - for (const SfxPoolItem* pItem : aSurrogates) - { - pCol = &static_cast(*pItem); - InsColor(pCol->GetValue()); - } + m_rDoc.ForEachCharacterColorItem([this](const SvxColorItem& rColorItem) -> bool { + InsColor(rColorItem.GetValue()); + return true; + }); auto pUnder = GetDfltAttr(RES_CHRATR_UNDERLINE); InsColor(pUnder->GetColor());