summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrisztian Pinter <pin.terminator@gmail.com>2014-07-28 16:21:35 +0200
committerKrisztian Pinter <pin.terminator@gmail.com>2014-07-28 16:21:35 +0200
commit1c5adcc87fd183282296f4f4ea84f3584525f228 (patch)
tree8883d1e4fa0839a2f39677983d909f4669dd462a
parent834554a743b5935a21abe2026325081f2807bb34 (diff)
Make it easier to add new color attributes to GetDocColors
Change-Id: I2098892fc44c7a8bde1eb30f6db1709e58925577
-rw-r--r--sc/source/core/data/document10.cxx5
-rw-r--r--sw/source/core/doc/docfmt.cxx6
2 files changed, 6 insertions, 5 deletions
diff --git a/sc/source/core/data/document10.cxx b/sc/source/core/data/document10.cxx
index e723a68076e6..902a447e61d5 100644
--- a/sc/source/core/data/document10.cxx
+++ b/sc/source/core/data/document10.cxx
@@ -242,6 +242,8 @@ void ScDocument::CopyCellValuesFrom( const ScAddress& rTopPos, const sc::CellVal
std::vector<Color> ScDocument::GetDocColors()
{
+ // list of color attributes to collect
+ const std::vector<sal_uInt16> aColAttrs({ATTR_FONT_COLOR, ATTR_BACKGROUND});
std::vector<Color> docColors;
for( unsigned int nTabIx = 0; nTabIx < maTabs.size(); ++nTabIx )
@@ -265,8 +267,7 @@ std::vector<Color> ScDocument::GetDocColors()
if( SFX_ITEM_SET == rItemSet.GetItemState( nWhich, false, &pItem ) )
{
sal_uInt16 aWhich = pItem->Which();
- if( ATTR_FONT_COLOR == aWhich ||
- ATTR_BACKGROUND == aWhich )
+ if( std::find(aColAttrs.begin(), aColAttrs.end(), aWhich) != aColAttrs.end() )
{
Color aColor( ((SvxColorItem*)pItem)->GetValue() );
if( COL_AUTO != aColor.GetColor() &&
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index 15086c1af823..9cbcd2c869ae 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -1889,6 +1889,8 @@ void SwDoc::RenameFmt(SwFmt & rFmt, const OUString & sNewName,
std::vector<Color> SwDoc::GetDocColors()
{
+ // list of color attributes to collect
+ const std::vector<sal_uInt16> aColAttrs({RES_CHRATR_COLOR, RES_CHRATR_HIGHLIGHT, RES_BACKGROUND});
std::vector<Color> docColors;
for(unsigned int i = 0; i < m_pNodes->Count(); ++i)
@@ -1909,9 +1911,7 @@ std::vector<Color> SwDoc::GetDocColors()
if( SFX_ITEM_SET == pItemSet->GetItemState( nWhich, false, &pItem ) )
{
sal_uInt16 aWhich = pItem->Which();
- if( RES_CHRATR_COLOR == aWhich ||
- RES_CHRATR_HIGHLIGHT == aWhich ||
- RES_BACKGROUND == aWhich )
+ if( std::find(aColAttrs.begin(), aColAttrs.end(), aWhich) != aColAttrs.end() )
{
Color aColor( ((SvxColorItem*)pItem)->GetValue() );
if( COL_AUTO != aColor.GetColor() &&