[Libreoffice-commits] libvisio.git: src/lib

Fridrich Å trba fridrich.strba at bluewin.ch
Mon Feb 3 03:03:42 PST 2014


 src/lib/VSDXTheme.cpp |   59 ++++++++++++++++++++++++++++++++++++++++++++++++++
 src/lib/VSDXTheme.h   |    2 +
 2 files changed, 61 insertions(+)

New commits:
commit f20f0bed4e545355f37f008cf311833c7907506a
Author: Fridrich Å trba <fridrich.strba at bluewin.ch>
Date:   Mon Feb 3 12:03:00 2014 +0100

    Little changes to theme parsing
    
    Change-Id: Ie5e7b86799fda82611edf299952a8508efd7dc5f

diff --git a/src/lib/VSDXTheme.cpp b/src/lib/VSDXTheme.cpp
index 92142cf..5550857 100644
--- a/src/lib/VSDXTheme.cpp
+++ b/src/lib/VSDXTheme.cpp
@@ -35,6 +35,7 @@ libvisio::VSDXClrScheme::VSDXClrScheme()
   , m_accent6()
   , m_hlink()
   , m_folHlink()
+  , m_bkgnd()
   , m_variationClrSchemeLst()
 {
 }
@@ -185,6 +186,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;
@@ -302,4 +306,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 a30a1c2..4f251cb 100644
--- a/src/lib/VSDXTheme.h
+++ b/src/lib/VSDXTheme.h
@@ -47,6 +47,7 @@ struct VSDXClrScheme
   Colour m_accent6;
   Colour m_hlink;
   Colour m_folHlink;
+  Colour m_bkgnd;
   std::vector<VSDXVariationClrScheme> m_variationClrSchemeLst;
 
   VSDXClrScheme();
@@ -58,6 +59,7 @@ public:
   VSDXTheme();
   ~VSDXTheme();
   bool parse(librevenge::RVNGInputStream *input);
+  boost::optional<Colour> getThemeColour(unsigned value, unsigned variationIndex = 0) const;
 
 private:
   VSDXTheme(const VSDXTheme &);


More information about the Libreoffice-commits mailing list