diff options
author | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2014-02-03 12:03:00 +0100 |
---|---|---|
committer | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2014-02-03 12:04:27 +0100 |
commit | 57210acffdc7953653f65be184897c0993555155 (patch) | |
tree | fa424bcc9839283d3ef0b223e480205da0589441 | |
parent | 410f564d9a728b983cf11ba9b3eadfc7d59c187c (diff) |
Little changes to theme parsing
(cherry picked from commit f20f0bed4e545355f37f008cf311833c7907506a)
Conflicts:
src/lib/VSDXTheme.h
Change-Id: Ie5e7b86799fda82611edf299952a8508efd7dc5f
-rw-r--r-- | src/lib/VSDXTheme.cpp | 59 | ||||
-rw-r--r-- | src/lib/VSDXTheme.h | 2 |
2 files changed, 61 insertions, 0 deletions
diff --git a/src/lib/VSDXTheme.cpp b/src/lib/VSDXTheme.cpp index 8ea6cf6..f2f094d 100644 --- a/src/lib/VSDXTheme.cpp +++ b/src/lib/VSDXTheme.cpp @@ -55,6 +55,7 @@ libvisio::VSDXClrScheme::VSDXClrScheme() , m_accent6() , m_hlink() , m_folHlink() + , m_bkgnd() , m_variationClrSchemeLst() { } @@ -205,6 +206,9 @@ void libvisio::VSDXTheme::readClrScheme(xmlTextReaderPtr reader) case XML_A_FOLHLINK: readThemeColour(reader, tokenId, m_clrScheme.m_folHlink); break; + case XML_VT_BKGND: + readThemeColour(reader, tokenId, m_clrScheme.m_bkgnd); + break; case XML_VT_VARIATIONCLRSCHEMELST: readVariationClrSchemeLst(reader); break; @@ -322,4 +326,59 @@ void libvisio::VSDXTheme::readVariationClrScheme(xmlTextReaderPtr reader, VSDXVa while ((XML_VT_VARIATIONSTYLESCHEME != tokenId || XML_READER_TYPE_END_ELEMENT != tokenType) && 1 == ret); } +boost::optional<libvisio::Colour> libvisio::VSDXTheme::getThemeColour(unsigned value, unsigned variationIndex) const +{ + if (value < 100) + { + switch (value) + { + case 0: + return m_clrScheme.m_dk1; + case 1: + return m_clrScheme.m_lt1; + case 2: + return m_clrScheme.m_accent1; + case 3: + return m_clrScheme.m_accent2; + case 4: + return m_clrScheme.m_accent3; + case 5: + return m_clrScheme.m_accent4; + case 6: + return m_clrScheme.m_accent5; + case 7: + return m_clrScheme.m_accent6; + case 8: + return m_clrScheme.m_bkgnd; + default: + break; + } + } + else if (!m_clrScheme.m_variationClrSchemeLst.empty()) + { + if (variationIndex >= m_clrScheme.m_variationClrSchemeLst.size()) + variationIndex = 0; + switch (value) + { + case 100: + return m_clrScheme.m_variationClrSchemeLst[variationIndex].m_varColor1; + case 101: + return m_clrScheme.m_variationClrSchemeLst[variationIndex].m_varColor2; + case 102: + return m_clrScheme.m_variationClrSchemeLst[variationIndex].m_varColor3; + case 103: + return m_clrScheme.m_variationClrSchemeLst[variationIndex].m_varColor4; + case 104: + return m_clrScheme.m_variationClrSchemeLst[variationIndex].m_varColor5; + case 105: + return m_clrScheme.m_variationClrSchemeLst[variationIndex].m_varColor6; + case 106: + return m_clrScheme.m_variationClrSchemeLst[variationIndex].m_varColor7; + default: + break; + } + } + return boost::optional<libvisio::Colour>(); +} + /* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/VSDXTheme.h b/src/lib/VSDXTheme.h index 15d152f..060a794 100644 --- a/src/lib/VSDXTheme.h +++ b/src/lib/VSDXTheme.h @@ -67,6 +67,7 @@ struct VSDXClrScheme Colour m_accent6; Colour m_hlink; Colour m_folHlink; + Colour m_bkgnd; std::vector<VSDXVariationClrScheme> m_variationClrSchemeLst; VSDXClrScheme(); @@ -78,6 +79,7 @@ public: VSDXTheme(); ~VSDXTheme(); bool parse(WPXInputStream *input); + boost::optional<Colour> getThemeColour(unsigned value, unsigned variationIndex = 0) const; private: VSDXTheme(const VSDXTheme &); |