[Libreoffice-commits] core.git: 2 commits - include/oox oox/source sc/source
Markus Mohrhard
markus.mohrhard at googlemail.com
Wed Apr 15 09:26:35 PDT 2015
include/oox/drawingml/clrscheme.hxx | 8 +++---
oox/source/drawingml/clrscheme.cxx | 37 +++++++++++++++++++++++-------
sc/source/filter/inc/themebuffer.hxx | 2 +
sc/source/filter/oox/condformatbuffer.cxx | 2 -
sc/source/filter/oox/themebuffer.cxx | 6 ++++
5 files changed, 42 insertions(+), 13 deletions(-)
New commits:
commit f3121049828596b369e3ea844355d61666e49795
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Wed Apr 15 18:19:47 2015 +0200
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
diff --git a/include/oox/drawingml/clrscheme.hxx b/include/oox/drawingml/clrscheme.hxx
index b4c12cf..00bf149 100644
--- a/include/oox/drawingml/clrscheme.hxx
+++ b/include/oox/drawingml/clrscheme.hxx
@@ -42,12 +42,15 @@ typedef std::shared_ptr< ClrMap > ClrMapPtr;
class OOX_DLLPUBLIC ClrScheme
{
- std::map < sal_Int32, sal_Int32 > maClrScheme;
+ std::vector< std::pair<sal_Int32, sal_Int32> > maClrScheme;
public:
bool getColor( sal_Int32 nSchemeClrToken, sal_Int32& rColor ) const;
void setColor( sal_Int32 nSchemeClrToken, sal_Int32 nColor );
+
+ bool getColorByIndex(size_t nIndex,
+ sal_Int32& rColor) const;
};
typedef std::shared_ptr< ClrScheme > ClrSchemePtr;
diff --git a/oox/source/drawingml/clrscheme.cxx b/oox/source/drawingml/clrscheme.cxx
index 52f78aa..9fb8382 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;
}
} }
diff --git a/sc/source/filter/inc/themebuffer.hxx b/sc/source/filter/inc/themebuffer.hxx
index 84ff9ea..21f560a 100644
--- a/sc/source/filter/inc/themebuffer.hxx
+++ b/sc/source/filter/inc/themebuffer.hxx
@@ -37,6 +37,8 @@ public:
/** Returns the theme color with the specified token identifier. */
sal_Int32 getColorByToken( sal_Int32 nToken ) const;
+ sal_Int32 getColorByIndex(size_t nIndex) const;
+
/** Returns the default font data for the current file type. */
inline const FontModel& getDefaultFontModel() const { return *mxDefFontModel; }
diff --git a/sc/source/filter/oox/condformatbuffer.cxx b/sc/source/filter/oox/condformatbuffer.cxx
index 2c04142..cfe4af2 100644
--- a/sc/source/filter/oox/condformatbuffer.cxx
+++ b/sc/source/filter/oox/condformatbuffer.cxx
@@ -245,7 +245,7 @@ void DataBarRule::importColor( const AttributeList& rAttribs )
else if( rAttribs.hasAttribute( XML_theme ) )
{
sal_uInt32 nThemeIndex = rAttribs.getUnsigned( XML_theme, 0 );
- nColor = getTheme().getColorByToken( nThemeIndex );
+ nColor = getTheme().getColorByIndex( nThemeIndex );
}
::Color aColor = RgbToRgbComponents( nColor );
diff --git a/sc/source/filter/oox/themebuffer.cxx b/sc/source/filter/oox/themebuffer.cxx
index 58ed242..a4dfc32 100644
--- a/sc/source/filter/oox/themebuffer.cxx
+++ b/sc/source/filter/oox/themebuffer.cxx
@@ -56,6 +56,12 @@ sal_Int32 ThemeBuffer::getColorByToken( sal_Int32 nToken ) const
return getClrScheme().getColor( nToken, nColor ) ? nColor : API_RGB_TRANSPARENT;
}
+sal_Int32 ThemeBuffer::getColorByIndex(size_t nIndex) const
+{
+ sal_Int32 nColor = 0;
+ return getClrScheme().getColorByIndex(nIndex, nColor) ? nColor : API_RGB_TRANSPARENT;
+}
+
} // namespace xls
} // namespace oox
commit b99a4b81f53aa406a98e167fc9b8e1f1347fa970
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Wed Apr 15 18:18:24 2015 +0200
remove empty constructor and destructor
Change-Id: Ia88d17a632f75b203823b66a5fdd261732c09ae4
diff --git a/include/oox/drawingml/clrscheme.hxx b/include/oox/drawingml/clrscheme.hxx
index d430374..b4c12cf 100644
--- a/include/oox/drawingml/clrscheme.hxx
+++ b/include/oox/drawingml/clrscheme.hxx
@@ -46,9 +46,6 @@ class OOX_DLLPUBLIC ClrScheme
public:
- ClrScheme();
- ~ClrScheme();
-
bool getColor( sal_Int32 nSchemeClrToken, sal_Int32& rColor ) const;
void setColor( sal_Int32 nSchemeClrToken, sal_Int32 nColor );
};
diff --git a/oox/source/drawingml/clrscheme.cxx b/oox/source/drawingml/clrscheme.cxx
index e4a7a8e..52f78aa 100644
--- a/oox/source/drawingml/clrscheme.cxx
+++ b/oox/source/drawingml/clrscheme.cxx
@@ -43,12 +43,6 @@ void ClrMap::setColorMap( sal_Int32 nClrToken, sal_Int32 nMappedClrToken )
maClrMap[ nClrToken ] = nMappedClrToken;
}
-ClrScheme::ClrScheme()
-{
-}
-ClrScheme::~ClrScheme()
-{
-}
bool ClrScheme::getColor( sal_Int32 nSchemeClrToken, sal_Int32& rColor ) const
{
More information about the Libreoffice-commits
mailing list