diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2015-04-15 18:19:47 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2015-04-15 18:23:35 +0200 |
commit | f3121049828596b369e3ea844355d61666e49795 (patch) | |
tree | 89dca766b999674508df2142d02353f0feaa7de6 /oox | |
parent | b99a4b81f53aa406a98e167fc9b8e1f1347fa970 (diff) |
use index as real index and not token, tdf#90511
At least in calc a theme index is a zero based index into the clrScheme.
A map is unsiutable for that task so let us use a vector and still allow
to get them by their tokens.
Change-Id: I09d56acaf22c3ed16387aae95c36382302c5a17e
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/drawingml/clrscheme.cxx | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/oox/source/drawingml/clrscheme.cxx b/oox/source/drawingml/clrscheme.cxx index 52f78aaf90c5..9fb838224a8a 100644 --- a/oox/source/drawingml/clrscheme.cxx +++ b/oox/source/drawingml/clrscheme.cxx @@ -43,6 +43,21 @@ void ClrMap::setColorMap( sal_Int32 nClrToken, sal_Int32 nMappedClrToken ) maClrMap[ nClrToken ] = nMappedClrToken; } +struct find_by_token +{ + find_by_token(sal_Int32 token): + m_token(token) + { + } + + bool operator()(const std::pair<sal_Int32, sal_Int32>& r) + { + return r.first == m_token; + } + +private: + sal_Int32 m_token; +}; bool ClrScheme::getColor( sal_Int32 nSchemeClrToken, sal_Int32& rColor ) const { @@ -54,15 +69,27 @@ bool ClrScheme::getColor( sal_Int32 nSchemeClrToken, sal_Int32& rColor ) const case XML_tx1 : nSchemeClrToken = XML_dk1; break; case XML_tx2 : nSchemeClrToken = XML_dk2; break; } - std::map < sal_Int32, sal_Int32 >::const_iterator aIter( maClrScheme.find( nSchemeClrToken ) ); + + auto aIter = std::find_if(maClrScheme.begin(), maClrScheme.end(), find_by_token(nSchemeClrToken) ); + if ( aIter != maClrScheme.end() ) - rColor = (*aIter).second; + rColor = aIter->second; + return aIter != maClrScheme.end(); } void ClrScheme::setColor( sal_Int32 nSchemeClrToken, sal_Int32 nColor ) { - maClrScheme[ nSchemeClrToken ] = nColor; + maClrScheme.push_back(std::pair<sal_Int32, sal_Int32>(nSchemeClrToken, nColor)); +} + +bool ClrScheme::getColorByIndex(size_t nIndex, sal_Int32& rColor) const +{ + if (nIndex >= maClrScheme.size()) + return false; + + rColor = maClrScheme[nIndex].second; + return true; } } } |