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

Fridrich Štrba fridrich.strba at bluewin.ch
Mon Feb 6 09:17:00 UTC 2017


 src/lib/VDXParser.cpp           |    8 +-
 src/lib/VSD5Parser.cpp          |    3 
 src/lib/VSD6Parser.cpp          |    3 
 src/lib/VSDCollector.h          |   11 +--
 src/lib/VSDContentCollector.cpp |   84 +++++++++++--------------
 src/lib/VSDContentCollector.h   |   15 ++--
 src/lib/VSDParser.cpp           |    8 +-
 src/lib/VSDStencils.cpp         |   11 +--
 src/lib/VSDStencils.h           |    1 
 src/lib/VSDStyles.cpp           |   25 +------
 src/lib/VSDStyles.h             |  134 ++++++++++++++++++----------------------
 src/lib/VSDStylesCollector.cpp  |   24 ++-----
 src/lib/VSDStylesCollector.h    |   11 +--
 src/lib/VSDXMLParserBase.cpp    |    3 
 src/lib/VSDXParser.cpp          |   44 +++----------
 15 files changed, 161 insertions(+), 224 deletions(-)

New commits:
commit ed97f8fb2124f3b19645b3ad5f756cabe88510eb
Author: Fridrich Štrba <fridrich.strba at bluewin.ch>
Date:   Mon Feb 6 10:16:34 2017 +0100

    Theme fill and shadow colour
    
    Change-Id: I6659c65d0f940b3762b76dad01b3a353df59de9a

diff --git a/src/lib/VDXParser.cpp b/src/lib/VDXParser.cpp
index 9f39ada..cfdb1f1 100644
--- a/src/lib/VDXParser.cpp
+++ b/src/lib/VDXParser.cpp
@@ -453,7 +453,7 @@ void libvisio::VDXParser::readFillAndShadow(xmlTextReaderPtr reader)
 
   if (m_isInStyles)
     m_collector->collectFillStyle(level, fillColourFG, fillColourBG, fillPattern, fillFGTransparency,
-                                  fillBGTransparency, shadowPattern, shadowColourFG, shadowOffsetX, shadowOffsetY);
+                                  fillBGTransparency, shadowPattern, shadowColourFG, shadowOffsetX, shadowOffsetY, -1, -1);
   else
   {
     if (m_isStencilStarted)
@@ -461,7 +461,7 @@ void libvisio::VDXParser::readFillAndShadow(xmlTextReaderPtr reader)
       VSD_DEBUG_MSG(("Found stencil fill\n"));
     }
     m_shape.m_fillStyle.override(VSDOptionalFillStyle(fillColourFG, fillColourBG, fillPattern, fillFGTransparency, fillBGTransparency,
-                                                      shadowColourFG, shadowPattern, shadowOffsetX, shadowOffsetY));
+                                                      shadowColourFG, shadowPattern, shadowOffsetX, shadowOffsetY, -1, -1));
   }
 }
 
@@ -904,8 +904,8 @@ void libvisio::VDXParser::readTextBlock(xmlTextReaderPtr reader)
     m_collector->collectTextBlockStyle(level, leftMargin, rightMargin, topMargin, bottomMargin,
                                        verticalAlign, !!bgClrId, bgColour, defaultTabStop, textDirection);
   else
-    m_shape.m_textBlockStyle.override(VSDOptionalTextBlockStyle(leftMargin, rightMargin, topMargin, bottomMargin,
-                                                                verticalAlign, !!bgClrId, bgColour, defaultTabStop, textDirection));
+    m_shape.m_textBlockStyle.override(VSDOptionalTextBlockStyle(leftMargin, rightMargin, topMargin, bottomMargin, verticalAlign,
+                                                                !!bgClrId, bgColour, defaultTabStop, textDirection));
 }
 
 xmlChar *libvisio::VDXParser::readStringData(xmlTextReaderPtr reader)
diff --git a/src/lib/VSD5Parser.cpp b/src/lib/VSD5Parser.cpp
index 747be18..94dbbed 100644
--- a/src/lib/VSD5Parser.cpp
+++ b/src/lib/VSD5Parser.cpp
@@ -355,7 +355,8 @@ void libvisio::VSD5Parser::readFillAndShadow(librevenge::RVNGInputStream *input)
       shadowOffsetY = m_shadowOffsetY;
     }
     m_shape.m_fillStyle.override(VSDOptionalFillStyle(colourFG, colourBG, fillPattern, 0.0,
-                                                      0.0, shfgc, shadowPattern, shadowOffsetX, shadowOffsetY));
+                                                      0.0, shfgc, shadowPattern, shadowOffsetX,
+                                                      shadowOffsetY, -1, -1));
   }
 }
 
diff --git a/src/lib/VSD6Parser.cpp b/src/lib/VSD6Parser.cpp
index 34cde71..9979895 100644
--- a/src/lib/VSD6Parser.cpp
+++ b/src/lib/VSD6Parser.cpp
@@ -304,7 +304,8 @@ void libvisio::VSD6Parser::readFillAndShadow(librevenge::RVNGInputStream *input)
       shadowOffsetY = m_shadowOffsetY;
     }
     m_shape.m_fillStyle.override(VSDOptionalFillStyle(colourFG, colourBG, fillPattern, fillFGTransparency,
-                                                      fillBGTransparency, shadowFG, shadowPattern, shadowOffsetX, shadowOffsetY));
+                                                      fillBGTransparency, shadowFG, shadowPattern,
+                                                      shadowOffsetX, shadowOffsetY, -1, -1));
   }
 }
 
diff --git a/src/lib/VSDCollector.h b/src/lib/VSDCollector.h
index 6e16bc2..4012d37 100644
--- a/src/lib/VSDCollector.h
+++ b/src/lib/VSDCollector.h
@@ -23,6 +23,7 @@ public:
   VSDCollector() {};
   virtual ~VSDCollector() {}
 
+  virtual void collectDocumentTheme(const VSDXTheme *theme) = 0;
   virtual void collectEllipticalArcTo(unsigned id, unsigned level, double x3, double y3, double x2, double y2, double angle, double ecc) = 0;
   virtual void collectForeignData(unsigned level, const librevenge::RVNGBinaryData &binaryData) = 0;
   virtual void collectOLEList(unsigned id, unsigned level) = 0;
@@ -34,13 +35,12 @@ public:
   virtual void collectFillAndShadow(unsigned level, const boost::optional<Colour> &colourFG, const boost::optional<Colour> &colourBG,
                                     const boost::optional<unsigned char> &fillPattern, const boost::optional<double> &fillFGTransparency,
                                     const boost::optional<double> &fillBGTransparency, const boost::optional<unsigned char> &shadowPattern,
-                                    const boost::optional<Colour> &shfgc, const boost::optional<double> &shadowOffsetX, const boost::optional<double> &shadowOffsetY) = 0;
+                                    const boost::optional<Colour> &shfgc, const boost::optional<double> &shadowOffsetX, const boost::optional<double> &shadowOffsetY,
+                                    const boost::optional<long> &qsFc, const boost::optional<long> &qsSc) = 0;
   virtual void collectFillAndShadow(unsigned level, const boost::optional<Colour> &colourFG, const boost::optional<Colour> &colourBG,
                                     const boost::optional<unsigned char> &fillPattern, const boost::optional<double> &fillFGTransparency,
                                     const boost::optional<double> &fillBGTransparency, const boost::optional<unsigned char> &shadowPattern,
                                     const boost::optional<Colour> &shfgc) = 0;
-  virtual void collectThemeReference(unsigned level, const boost::optional<long> &lineColour, const boost::optional<long> &fillColour,
-                                     const boost::optional<long> &shadowColour, const boost::optional<long> &fontColour) = 0;
   virtual void collectGeometry(unsigned id, unsigned level, bool noFill, bool noLine, bool noShow) = 0;
   virtual void collectMoveTo(unsigned id, unsigned level, double x, double y) = 0;
   virtual void collectLineTo(unsigned id, unsigned level, double x, double y) = 0;
@@ -120,7 +120,8 @@ public:
   virtual void collectFillStyle(unsigned level, const boost::optional<Colour> &colourFG, const boost::optional<Colour> &colourBG,
                                 const boost::optional<unsigned char> &fillPattern, const boost::optional<double> &fillFGTransparency,
                                 const boost::optional<double> &fillBGTransparency, const boost::optional<unsigned char> &shadowPattern,
-                                const boost::optional<Colour> &shfgc, const boost::optional<double> &shadowOffsetX, const boost::optional<double> &shadowOffsetY) = 0;
+                                const boost::optional<Colour> &shfgc, const boost::optional<double> &shadowOffsetX, const boost::optional<double> &shadowOffsetY,
+                                const boost::optional<long> &qsFillColour, const boost::optional<long> &qsShadowColour) = 0;
   virtual void collectFillStyle(unsigned level, const boost::optional<Colour> &colourFG, const boost::optional<Colour> &colourBG,
                                 const boost::optional<unsigned char> &fillPattern, const boost::optional<double> &fillFGTransparency,
                                 const boost::optional<double> &fillBGTransparency, const boost::optional<unsigned char> &shadowPattern,
@@ -142,8 +143,6 @@ public:
                                      const boost::optional<unsigned char> &verticalAlign, const boost::optional<bool> &isBgFilled,
                                      const boost::optional<Colour> &bgColour, const boost::optional<double> &defaultTabStop,
                                      const boost::optional<unsigned char> &textDirection) = 0;
-  virtual void collectStyleThemeReference(unsigned level, const boost::optional<long> &lineColour, const boost::optional<long> &fillColour,
-                                          const boost::optional<long> &shadowColour, const boost::optional<long> &fontColour) = 0;
 
   // Field list
   virtual void collectFieldList(unsigned id, unsigned level) = 0;
diff --git a/src/lib/VSDContentCollector.cpp b/src/lib/VSDContentCollector.cpp
index e201809..56cf440 100644
--- a/src/lib/VSDContentCollector.cpp
+++ b/src/lib/VSDContentCollector.cpp
@@ -130,12 +130,12 @@ libvisio::VSDContentCollector::VSDContentCollector(
   m_pageShapeOrder(m_documentPageShapeOrders.begin()), m_isFirstGeometry(true), m_NURBSData(), m_polylineData(),
   m_currentText(), m_names(), m_stencilNames(), m_fields(), m_stencilFields(), m_fieldIndex(0),
   m_charFormats(), m_paraFormats(), m_lineStyle(), m_fillStyle(), m_textBlockStyle(),
-  m_themeReference(), m_defaultCharStyle(), m_defaultParaStyle(), m_currentStyleSheet(0), m_styles(styles),
+  m_defaultCharStyle(), m_defaultParaStyle(), m_currentStyleSheet(0), m_styles(styles),
   m_stencils(stencils), m_stencilShape(0), m_isStencilStarted(false), m_currentGeometryCount(0),
   m_backgroundPageID(MINUS_ONE), m_currentPageID(0), m_currentPage(), m_pages(), m_layerList(),
   m_splineControlPoints(), m_splineKnotVector(), m_splineX(0.0), m_splineY(0.0),
   m_splineLastKnot(0.0), m_splineDegree(0), m_splineLevel(0), m_currentShapeLevel(0),
-  m_isBackgroundPage(false), m_currentLayerList(), m_currentLayerMem(), m_tabSets()
+  m_isBackgroundPage(false), m_currentLayerList(), m_currentLayerMem(), m_tabSets(), m_documentTheme(0)
 {
 }
 
@@ -1310,6 +1310,12 @@ void libvisio::VSDContentCollector::_flushCurrentPage()
   m_pageOutputText.clear();
 }
 
+void libvisio::VSDContentCollector::collectDocumentTheme(const VSDXTheme *theme)
+{
+  if (theme)
+    m_documentTheme = theme;
+}
+
 #define LIBVISIO_EPSILON 1E-10
 void libvisio::VSDContentCollector::collectEllipticalArcTo(unsigned /* id */, unsigned level, double x3, double y3, double x2, double y2, double angle, double ecc)
 {
@@ -1608,16 +1614,17 @@ void libvisio::VSDContentCollector::collectLine(unsigned level, const boost::opt
                                                 const boost::optional<double> &rounding)
 {
   _handleLevelChange(level);
-  m_lineStyle.override(VSDOptionalLineStyle(strokeWidth, c, linePattern, startMarker, endMarker, lineCap, rounding));
+  m_lineStyle.override(VSDOptionalLineStyle(strokeWidth, c, linePattern, startMarker, endMarker, lineCap, rounding), m_documentTheme);
 }
 
 void libvisio::VSDContentCollector::collectFillAndShadow(unsigned level, const boost::optional<Colour> &colourFG, const boost::optional<Colour> &colourBG,
                                                          const boost::optional<unsigned char> &fillPattern, const boost::optional<double> &fillFGTransparency, const boost::optional<double> &fillBGTransparency,
                                                          const boost::optional<unsigned char> &shadowPattern, const boost::optional<Colour> &shfgc, const boost::optional<double> &shadowOffsetX,
-                                                         const boost::optional<double> &shadowOffsetY)
+                                                         const boost::optional<double> &shadowOffsetY, const boost::optional<long> &qsFillColour, const boost::optional<long> &qsShadowColour)
 {
   _handleLevelChange(level);
-  m_fillStyle.override(VSDOptionalFillStyle(colourFG, colourBG, fillPattern, fillFGTransparency, fillBGTransparency, shfgc, shadowPattern, shadowOffsetX, shadowOffsetY));
+  m_fillStyle.override(VSDOptionalFillStyle(colourFG, colourBG, fillPattern, fillFGTransparency, fillBGTransparency, shfgc,
+                                            shadowPattern, shadowOffsetX, shadowOffsetY, qsFillColour, qsShadowColour), m_documentTheme);
 }
 
 void libvisio::VSDContentCollector::collectFillAndShadow(unsigned level, const boost::optional<Colour> &colourFG, const boost::optional<Colour> &colourBG,
@@ -1625,14 +1632,7 @@ void libvisio::VSDContentCollector::collectFillAndShadow(unsigned level, const b
                                                          const boost::optional<double> &fillBGTransparency,
                                                          const boost::optional<unsigned char> &shadowPattern, const boost::optional<Colour> &shfgc)
 {
-  collectFillAndShadow(level, colourFG, colourBG, fillPattern, fillFGTransparency, fillBGTransparency, shadowPattern, shfgc, m_shadowOffsetX, m_shadowOffsetY);
-}
-
-void libvisio::VSDContentCollector::collectThemeReference(unsigned level, const boost::optional<long> &lineColour, const boost::optional<long> &fillColour,
-                                                          const boost::optional<long> &shadowColour, const boost::optional<long> &fontColour)
-{
-  _handleLevelChange(level);
-  m_themeReference.override(VSDOptionalThemeReference(lineColour, fillColour, shadowColour, fontColour));
+  collectFillAndShadow(level, colourFG, colourBG, fillPattern, fillFGTransparency, fillBGTransparency, shadowPattern, shfgc, m_shadowOffsetX, m_shadowOffsetY, -1, -1);
 }
 
 void libvisio::VSDContentCollector::collectForeignData(unsigned level, const librevenge::RVNGBinaryData &binaryData)
@@ -2582,38 +2582,38 @@ void libvisio::VSDContentCollector::collectShape(unsigned id, unsigned level, un
     }
 
     if (m_stencilShape->m_lineStyleId != MINUS_ONE)
-      m_lineStyle.override(m_styles.getOptionalLineStyle(m_stencilShape->m_lineStyleId));
+      m_lineStyle.override(m_styles.getOptionalLineStyle(m_stencilShape->m_lineStyleId), m_documentTheme);
 
-    m_lineStyle.override(m_stencilShape->m_lineStyle);
+    m_lineStyle.override(m_stencilShape->m_lineStyle, m_documentTheme);
 
     if (m_stencilShape->m_fillStyleId != MINUS_ONE)
-      m_fillStyle.override(m_styles.getOptionalFillStyle(m_stencilShape->m_fillStyleId));
+      m_fillStyle.override(m_styles.getOptionalFillStyle(m_stencilShape->m_fillStyleId), m_documentTheme);
 
-    m_fillStyle.override(m_stencilShape->m_fillStyle);
+    m_fillStyle.override(m_stencilShape->m_fillStyle, m_documentTheme);
 
     if (m_stencilShape->m_textStyleId != MINUS_ONE)
     {
-      m_defaultCharStyle.override(m_styles.getOptionalCharStyle(m_stencilShape->m_textStyleId));
-      m_defaultParaStyle.override(m_styles.getOptionalParaStyle(m_stencilShape->m_textStyleId));
-      m_textBlockStyle.override(m_styles.getOptionalTextBlockStyle(m_stencilShape->m_textStyleId));
+      m_defaultCharStyle.override(m_styles.getOptionalCharStyle(m_stencilShape->m_textStyleId), m_documentTheme);
+      m_defaultParaStyle.override(m_styles.getOptionalParaStyle(m_stencilShape->m_textStyleId), m_documentTheme);
+      m_textBlockStyle.override(m_styles.getOptionalTextBlockStyle(m_stencilShape->m_textStyleId), m_documentTheme);
     }
 
-    m_textBlockStyle.override(m_stencilShape->m_textBlockStyle);
-    m_defaultCharStyle.override(m_stencilShape->m_charStyle);
-    m_defaultParaStyle.override(m_stencilShape->m_paraStyle);
+    m_textBlockStyle.override(m_stencilShape->m_textBlockStyle, m_documentTheme);
+    m_defaultCharStyle.override(m_stencilShape->m_charStyle, m_documentTheme);
+    m_defaultParaStyle.override(m_stencilShape->m_paraStyle, m_documentTheme);
   }
 
   if (lineStyleId != MINUS_ONE)
-    m_lineStyle.override(m_styles.getOptionalLineStyle(lineStyleId));
+    m_lineStyle.override(m_styles.getOptionalLineStyle(lineStyleId), m_documentTheme);
 
   if (fillStyleId != MINUS_ONE)
-    m_fillStyle = m_styles.getFillStyle(fillStyleId);
+    m_fillStyle = m_styles.getFillStyle(fillStyleId, m_documentTheme);
 
   if (textStyleId != MINUS_ONE)
   {
-    m_defaultCharStyle.override(m_styles.getOptionalCharStyle(textStyleId));
-    m_defaultParaStyle.override(m_styles.getOptionalParaStyle(textStyleId));
-    m_textBlockStyle.override(m_styles.getOptionalTextBlockStyle(textStyleId));
+    m_defaultCharStyle.override(m_styles.getOptionalCharStyle(textStyleId), m_documentTheme);
+    m_defaultParaStyle.override(m_styles.getOptionalParaStyle(textStyleId), m_documentTheme);
+    m_textBlockStyle.override(m_styles.getOptionalTextBlockStyle(textStyleId), m_documentTheme);
   }
 
   m_currentGeometryCount = 0;
@@ -2683,7 +2683,7 @@ void libvisio::VSDContentCollector::collectParaIX(unsigned /* id */ , unsigned l
   _handleLevelChange(level);
   VSDParaStyle format(m_defaultParaStyle);
   format.override(VSDOptionalParaStyle(charCount, indFirst, indLeft, indRight, spLine, spBefore, spAfter, align,
-                                       bullet, bulletStr, bulletFont, bulletFontSize, textPosAfterBullet, flags));
+                                       bullet, bulletStr, bulletFont, bulletFontSize, textPosAfterBullet, flags), m_documentTheme);
   format.charCount = charCount;
   m_paraFormats.push_back(format);
 }
@@ -2697,7 +2697,7 @@ void libvisio::VSDContentCollector::collectDefaultParaStyle(unsigned charCount,
                                                             const boost::optional<double> &textPosAfterBullet, const boost::optional<unsigned> &flags)
 {
   m_defaultParaStyle.override(VSDOptionalParaStyle(charCount, indFirst, indLeft, indRight, spLine, spBefore, spAfter, align,
-                                                   bullet, bulletStr, bulletFont, bulletFontSize, textPosAfterBullet, flags));
+                                                   bullet, bulletStr, bulletFont, bulletFontSize, textPosAfterBullet, flags), m_documentTheme);
 }
 
 void libvisio::VSDContentCollector::collectCharIX(unsigned /* id */ , unsigned level, unsigned charCount,
@@ -2709,7 +2709,7 @@ void libvisio::VSDContentCollector::collectCharIX(unsigned /* id */ , unsigned l
   _handleLevelChange(level);
   VSDCharStyle format(m_defaultCharStyle);
   format.override(VSDOptionalCharStyle(charCount, font, fontColour, fontSize, bold, italic, underline, doubleunderline, strikeout, doublestrikeout,
-                                       allcaps, initcaps, smallcaps, superscript, subscript, scaleWidth));
+                                       allcaps, initcaps, smallcaps, superscript, subscript, scaleWidth), m_documentTheme);
   format.charCount = charCount;
   m_charFormats.push_back(format);
 }
@@ -2733,7 +2733,7 @@ void libvisio::VSDContentCollector::collectDefaultCharStyle(unsigned charCount,
                                                             const boost::optional<double> &scaleWidth)
 {
   m_defaultCharStyle.override(VSDOptionalCharStyle(charCount, font, fontColour, fontSize, bold, italic, underline, doubleunderline, strikeout, doublestrikeout,
-                                                   allcaps, initcaps, smallcaps, superscript, subscript, scaleWidth));
+                                                   allcaps, initcaps, smallcaps, superscript, subscript, scaleWidth), m_documentTheme);
 }
 
 void libvisio::VSDContentCollector::collectTextBlock(unsigned level, const boost::optional<double> &leftMargin, const boost::optional<double> &rightMargin,
@@ -2742,7 +2742,7 @@ void libvisio::VSDContentCollector::collectTextBlock(unsigned level, const boost
                                                      const boost::optional<unsigned char> &textDirection)
 {
   _handleLevelChange(level);
-  m_textBlockStyle.override(VSDOptionalTextBlockStyle(leftMargin, rightMargin, topMargin, bottomMargin, verticalAlign, isBgFilled, bgColour, defaultTabStop, textDirection));
+  m_textBlockStyle.override(VSDOptionalTextBlockStyle(leftMargin, rightMargin, topMargin, bottomMargin, verticalAlign, isBgFilled, bgColour, defaultTabStop, textDirection), m_documentTheme);
 }
 
 void libvisio::VSDContentCollector::collectNameList(unsigned /*id*/, unsigned level)
@@ -2801,9 +2801,11 @@ void libvisio::VSDContentCollector::collectFillStyle(unsigned /* level */, const
                                                      const boost::optional<unsigned char> &fillPattern, const boost::optional<double> &fillFGTransparency,
                                                      const boost::optional<double> &fillBGTransparency, const boost::optional<unsigned char> &shadowPattern,
                                                      const boost::optional<Colour> &shfgc, const boost::optional<double> &shadowOffsetX,
-                                                     const boost::optional<double> &shadowOffsetY)
+                                                     const boost::optional<double> &shadowOffsetY, const boost::optional<long> &qsFillColour,
+                                                     const boost::optional<long> &qsShadowColour)
 {
-  VSDOptionalFillStyle fillStyle(colourFG, colourBG, fillPattern, fillFGTransparency, fillBGTransparency, shfgc, shadowPattern, shadowOffsetX, shadowOffsetY);
+  VSDOptionalFillStyle fillStyle(colourFG, colourBG, fillPattern, fillFGTransparency, fillBGTransparency, shfgc, shadowPattern,
+                                 shadowOffsetX, shadowOffsetY, qsFillColour, qsShadowColour);
   m_styles.addFillStyle(m_currentStyleSheet, fillStyle);
 
 }
@@ -2813,7 +2815,8 @@ void libvisio::VSDContentCollector::collectFillStyle(unsigned level, const boost
                                                      const boost::optional<double> &fillBGTransparency, const boost::optional<unsigned char> &shadowPattern,
                                                      const boost::optional<Colour> &shfgc)
 {
-  collectFillStyle(level, colourFG, colourBG, fillPattern, fillFGTransparency, fillBGTransparency, shadowPattern, shfgc, m_shadowOffsetX, m_shadowOffsetY);
+  collectFillStyle(level, colourFG, colourBG, fillPattern, fillFGTransparency, fillBGTransparency, shadowPattern, shfgc,
+                   m_shadowOffsetX, m_shadowOffsetY, -1, -1);
 }
 
 void libvisio::VSDContentCollector::collectParaIXStyle(unsigned /* id */, unsigned /* level */, unsigned charCount,
@@ -3378,15 +3381,6 @@ void libvisio::VSDContentCollector::_fillAndShadowProperties(const VSDFillStyle
   }
 }
 
-void libvisio::VSDContentCollector::collectStyleThemeReference(unsigned /* level */, const boost::optional<long> &lineColour,
-                                                               const boost::optional<long> &fillColour, const boost::optional<long> &shadowColour,
-                                                               const boost::optional<long> &fontColour)
-{
-  VSDOptionalThemeReference themeReference(lineColour, fillColour, shadowColour, fontColour);
-  m_styles.addStyleThemeReference(m_currentStyleSheet, themeReference);
-}
-
-
 void libvisio::VSDContentCollector::collectFieldList(unsigned /* id */, unsigned level)
 {
   _handleLevelChange(level);
diff --git a/src/lib/VSDContentCollector.h b/src/lib/VSDContentCollector.h
index 2338e7a..55655eb 100644
--- a/src/lib/VSDContentCollector.h
+++ b/src/lib/VSDContentCollector.h
@@ -42,6 +42,7 @@ public:
     if (m_txtxform) delete(m_txtxform);
   };
 
+  void collectDocumentTheme(const VSDXTheme *theme);
   void collectEllipticalArcTo(unsigned id, unsigned level, double x3, double y3, double x2, double y2, double angle, double ecc);
   void collectForeignData(unsigned level, const librevenge::RVNGBinaryData &binaryData);
   void collectOLEList(unsigned id, unsigned level);
@@ -53,13 +54,12 @@ public:
   void collectFillAndShadow(unsigned level, const boost::optional<Colour> &colourFG, const boost::optional<Colour> &colourBG,
                             const boost::optional<unsigned char> &fillPattern, const boost::optional<double> &fillFGTransparency,
                             const boost::optional<double> &fillBGTransparency, const boost::optional<unsigned char> &shadowPattern,
-                            const boost::optional<Colour> &shfgc, const boost::optional<double> &shadowOffsetX, const boost::optional<double> &shadowOffsetY);
+                            const boost::optional<Colour> &shfgc, const boost::optional<double> &shadowOffsetX, const boost::optional<double> &shadowOffsetY,
+                            const boost::optional<long> &qsFc, const boost::optional<long> &qsSc);
   void collectFillAndShadow(unsigned level, const boost::optional<Colour> &colourFG, const boost::optional<Colour> &colourBG,
                             const boost::optional<unsigned char> &fillPattern, const boost::optional<double> &fillFGTransparency,
                             const boost::optional<double> &fillBGTransparency, const boost::optional<unsigned char> &shadowPattern,
                             const boost::optional<Colour> &shfgc);
-  void collectThemeReference(unsigned level, const boost::optional<long> &lineColour, const boost::optional<long> &fillColour,
-                             const boost::optional<long> &shadowColour, const boost::optional<long> &fontColour);
   void collectGeometry(unsigned id, unsigned level, bool noFill, bool noLine, bool noShow);
   void collectMoveTo(unsigned id, unsigned level, double x, double y);
   void collectLineTo(unsigned id, unsigned level, double x, double y);
@@ -140,7 +140,8 @@ public:
   void collectFillStyle(unsigned level, const boost::optional<Colour> &colourFG, const boost::optional<Colour> &colourBG,
                         const boost::optional<unsigned char> &fillPattern, const boost::optional<double> &fillFGTransparency,
                         const boost::optional<double> &fillBGTransparency, const boost::optional<unsigned char> &shadowPattern,
-                        const boost::optional<Colour> &shfgc, const boost::optional<double> &shadowOffsetX, const boost::optional<double> &shadowOffsetY);
+                        const boost::optional<Colour> &shfgc, const boost::optional<double> &shadowOffsetX, const boost::optional<double> &shadowOffsetY,
+                        const boost::optional<long> &qsFillColour, const boost::optional<long> &qsShadowColour);
   void collectFillStyle(unsigned level, const boost::optional<Colour> &colourFG, const boost::optional<Colour> &colourBG,
                         const boost::optional<unsigned char> &fillPattern, const boost::optional<double> &fillFGTransparency,
                         const boost::optional<double> &fillBGTransparency, const boost::optional<unsigned char> &shadowPattern,
@@ -162,8 +163,6 @@ public:
                              const boost::optional<unsigned char> &verticalAlign, const boost::optional<bool> &isBgFilled,
                              const boost::optional<Colour> &bgColour, const boost::optional<double> &defaultTabStop,
                              const boost::optional<unsigned char> &textDirection);
-  void collectStyleThemeReference(unsigned level, const boost::optional<long> &lineColour, const boost::optional<long> &fillColour,
-                                  const boost::optional<long> &shadowColour, const boost::optional<long> &fontColour);
 
   virtual void collectMetaData(const librevenge::RVNGPropertyList &metaData);
 
@@ -290,8 +289,6 @@ private:
   VSDFillStyle m_fillStyle;
   VSDTextBlockStyle m_textBlockStyle;
 
-  VSDThemeReference m_themeReference;
-
   VSDCharStyle m_defaultCharStyle;
   VSDParaStyle m_defaultParaStyle;
 
@@ -323,6 +320,8 @@ private:
   VSDLayerList m_currentLayerList;
   std::vector<unsigned> m_currentLayerMem;
   std::vector<VSDTabSet> m_tabSets;
+
+  const VSDXTheme *m_documentTheme;
 };
 
 } // namespace libvisio
diff --git a/src/lib/VSDParser.cpp b/src/lib/VSDParser.cpp
index 52f7d0d..822090c 100644
--- a/src/lib/VSDParser.cpp
+++ b/src/lib/VSDParser.cpp
@@ -635,7 +635,8 @@ void libvisio::VSDParser::_flushShape()
 
   m_collector->collectFillAndShadow(m_currentShapeLevel+2, m_shape.m_fillStyle.fgColour, m_shape.m_fillStyle.bgColour, m_shape.m_fillStyle.pattern,
                                     m_shape.m_fillStyle.fgTransparency, m_shape.m_fillStyle.bgTransparency, m_shape.m_fillStyle.shadowPattern,
-                                    m_shape.m_fillStyle.shadowFgColour, m_shape.m_fillStyle.shadowOffsetX, m_shape.m_fillStyle.shadowOffsetY);
+                                    m_shape.m_fillStyle.shadowFgColour, m_shape.m_fillStyle.shadowOffsetX, m_shape.m_fillStyle.shadowOffsetY,
+                                    m_shape.m_fillStyle.qsFillColour, m_shape.m_fillStyle.qsShadowColour);
 
   m_collector->collectTextBlock(m_currentShapeLevel+2, m_shape.m_textBlockStyle.leftMargin, m_shape.m_textBlockStyle.rightMargin,
                                 m_shape.m_textBlockStyle.topMargin, m_shape.m_textBlockStyle.bottomMargin, m_shape.m_textBlockStyle.verticalAlign,
@@ -2089,7 +2090,7 @@ void libvisio::VSDParser::readFillAndShadow(librevenge::RVNGInputStream *input)
   if (m_isInStyles)
     m_collector->collectFillStyle(m_header.level, colourFG, colourBG, fillPattern,
                                   fillFGTransparency, fillBGTransparency, shadowPattern, shadowFG,
-                                  shadowOffsetX, shadowOffsetY);
+                                  shadowOffsetX, shadowOffsetY, -1, -1);
   else
   {
     if (m_isStencilStarted)
@@ -2097,7 +2098,8 @@ void libvisio::VSDParser::readFillAndShadow(librevenge::RVNGInputStream *input)
       VSD_DEBUG_MSG(("Found stencil fill\n"));
     }
     m_shape.m_fillStyle.override(VSDOptionalFillStyle(colourFG, colourBG, fillPattern, fillFGTransparency,
-                                                      fillBGTransparency, shadowFG, shadowPattern, shadowOffsetX, shadowOffsetY));
+                                                      fillBGTransparency, shadowFG, shadowPattern,
+                                                      shadowOffsetX, shadowOffsetY, -1, -1));
   }
 }
 
diff --git a/src/lib/VSDStencils.cpp b/src/lib/VSDStencils.cpp
index 20a3788..1808240 100644
--- a/src/lib/VSDStencils.cpp
+++ b/src/lib/VSDStencils.cpp
@@ -14,7 +14,7 @@ libvisio::VSDShape::VSDShape()
   : m_geometries(), m_shapeList(), m_fields(), m_foreign(0), m_parent(0), m_masterPage(MINUS_ONE),
     m_masterShape(MINUS_ONE), m_shapeId(MINUS_ONE), m_lineStyleId(MINUS_ONE), m_fillStyleId(MINUS_ONE),
     m_textStyleId(MINUS_ONE), m_lineStyle(), m_fillStyle(), m_textBlockStyle(), m_charStyle(),
-    m_themeRef(), m_charList(), m_paraStyle(), m_paraList(), m_tabSets(), m_text(), m_names(),
+    m_charList(), m_paraStyle(), m_paraList(), m_tabSets(), m_text(), m_names(),
     m_textFormat(libvisio::VSD_TEXT_UTF16), m_nurbsData(), m_polylineData(), m_xform(), m_txtxform(0),
     m_xform1d(0), m_misc(), m_layerMem()
 {
@@ -26,10 +26,9 @@ libvisio::VSDShape::VSDShape(const libvisio::VSDShape &shape)
     m_masterPage(shape.m_masterPage), m_masterShape(shape.m_masterShape), m_shapeId(shape.m_shapeId),
     m_lineStyleId(shape.m_lineStyleId), m_fillStyleId(shape.m_fillStyleId), m_textStyleId(shape.m_textStyleId),
     m_lineStyle(shape.m_lineStyle), m_fillStyle(shape.m_fillStyle), m_textBlockStyle(shape.m_textBlockStyle),
-    m_charStyle(shape.m_charStyle), m_themeRef(shape.m_themeRef), m_charList(shape.m_charList),
-    m_paraStyle(shape.m_paraStyle), m_paraList(shape.m_paraList), m_tabSets(shape.m_tabSets),
-    m_text(shape.m_text), m_names(shape.m_names), m_textFormat(shape.m_textFormat),
-    m_nurbsData(shape.m_nurbsData), m_polylineData(shape.m_polylineData),
+    m_charStyle(shape.m_charStyle), m_charList(shape.m_charList), m_paraStyle(shape.m_paraStyle),
+    m_paraList(shape.m_paraList), m_tabSets(shape.m_tabSets), m_text(shape.m_text), m_names(shape.m_names),
+    m_textFormat(shape.m_textFormat), m_nurbsData(shape.m_nurbsData), m_polylineData(shape.m_polylineData),
     m_xform(shape.m_xform), m_txtxform(shape.m_txtxform ? new XForm(*(shape.m_txtxform)) : 0),
     m_xform1d(shape.m_xform1d ? new XForm1D(*(shape.m_xform1d)) : 0), m_misc(shape.m_misc),
     m_layerMem(shape.m_layerMem)
@@ -62,7 +61,6 @@ libvisio::VSDShape &libvisio::VSDShape::operator=(const libvisio::VSDShape &shap
     m_fillStyle = shape.m_fillStyle;
     m_textBlockStyle = shape.m_textBlockStyle;
     m_charStyle = shape.m_charStyle;
-    m_themeRef = shape.m_themeRef;
     m_charList = shape.m_charList;
     m_paraStyle = shape.m_paraStyle;
     m_paraList = shape.m_paraList;
@@ -104,7 +102,6 @@ void libvisio::VSDShape::clear()
   m_fillStyle = VSDOptionalFillStyle();
   m_textBlockStyle = VSDOptionalTextBlockStyle();
   m_charStyle = VSDOptionalCharStyle();
-  m_themeRef = VSDOptionalThemeReference();
   m_charList.clear();
   m_paraStyle = VSDOptionalParaStyle();
   m_paraList.clear();
diff --git a/src/lib/VSDStencils.h b/src/lib/VSDStencils.h
index 03dae0d..1b0a464 100644
--- a/src/lib/VSDStencils.h
+++ b/src/lib/VSDStencils.h
@@ -42,7 +42,6 @@ public:
   VSDOptionalFillStyle m_fillStyle;
   VSDOptionalTextBlockStyle m_textBlockStyle;
   VSDOptionalCharStyle m_charStyle;
-  VSDOptionalThemeReference m_themeRef;
   VSDCharacterList m_charList;
   VSDOptionalParaStyle m_paraStyle;
   VSDParagraphList m_paraList;
diff --git a/src/lib/VSDStyles.cpp b/src/lib/VSDStyles.cpp
index f8fd33d..3b2cf80 100644
--- a/src/lib/VSDStyles.cpp
+++ b/src/lib/VSDStyles.cpp
@@ -56,15 +56,14 @@ T getOptionalStyle(const std::map<unsigned, unsigned> &styleMasters, const std::
 
 libvisio::VSDStyles::VSDStyles() :
   m_lineStyles(), m_fillStyles(), m_textBlockStyles(), m_charStyles(), m_paraStyles(),
-  m_themeRefs(), m_lineStyleMasters(), m_fillStyleMasters(), m_textStyleMasters()
+  m_lineStyleMasters(), m_fillStyleMasters(), m_textStyleMasters()
 {
 }
 
 libvisio::VSDStyles::VSDStyles(const libvisio::VSDStyles &styles) :
   m_lineStyles(styles.m_lineStyles), m_fillStyles(styles.m_fillStyles), m_textBlockStyles(styles.m_textBlockStyles),
-  m_charStyles(styles.m_charStyles), m_paraStyles(styles.m_paraStyles), m_themeRefs(styles.m_themeRefs),
-  m_lineStyleMasters(styles.m_lineStyleMasters), m_fillStyleMasters(styles.m_fillStyleMasters),
-  m_textStyleMasters(styles.m_textStyleMasters)
+  m_charStyles(styles.m_charStyles), m_paraStyles(styles.m_paraStyles), m_lineStyleMasters(styles.m_lineStyleMasters),
+  m_fillStyleMasters(styles.m_fillStyleMasters), m_textStyleMasters(styles.m_textStyleMasters)
 {
 }
 
@@ -81,7 +80,6 @@ libvisio::VSDStyles &libvisio::VSDStyles::operator=(const libvisio::VSDStyles &s
     m_textBlockStyles = styles.m_textBlockStyles;
     m_charStyles = styles.m_charStyles;
     m_paraStyles = styles.m_paraStyles;
-    m_themeRefs = styles.m_themeRefs;
 
     m_lineStyleMasters = styles.m_lineStyleMasters;
     m_fillStyleMasters = styles.m_fillStyleMasters;
@@ -115,11 +113,6 @@ void libvisio::VSDStyles::addParaStyle(unsigned textStyleIndex, const VSDOptiona
   m_paraStyles[textStyleIndex] = paraStyle;
 }
 
-void libvisio::VSDStyles::addStyleThemeReference(unsigned styleIndex, const VSDOptionalThemeReference &themeRef)
-{
-  m_themeRefs[styleIndex] = themeRef;
-}
-
 void libvisio::VSDStyles::addLineStyleMaster(unsigned lineStyleIndex, unsigned lineStyleMaster)
 {
   m_lineStyleMasters[lineStyleIndex] = lineStyleMaster;
@@ -145,10 +138,10 @@ libvisio::VSDOptionalFillStyle libvisio::VSDStyles::getOptionalFillStyle(unsigne
   return getOptionalStyle(m_fillStyleMasters, m_fillStyles, fillStyleIndex);
 }
 
-libvisio::VSDFillStyle libvisio::VSDStyles::getFillStyle(unsigned fillStyleIndex) const
+libvisio::VSDFillStyle libvisio::VSDStyles::getFillStyle(unsigned fillStyleIndex, const libvisio::VSDXTheme *theme) const
 {
   VSDFillStyle fillStyle;
-  fillStyle.override(getOptionalFillStyle(fillStyleIndex));
+  fillStyle.override(getOptionalFillStyle(fillStyleIndex), theme);
   return fillStyle;
 }
 
@@ -167,12 +160,4 @@ libvisio::VSDOptionalParaStyle libvisio::VSDStyles::getOptionalParaStyle(unsigne
   return getOptionalStyle(m_textStyleMasters, m_paraStyles, textStyleIndex);
 }
 
-libvisio::VSDOptionalThemeReference libvisio::VSDStyles::getOptionalThemeReference(unsigned styleIndex) const
-{
-  VSDOptionalThemeReference themeReference;
-  if (MINUS_ONE == styleIndex)
-    return themeReference;
-  return themeReference;
-}
-
 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
diff --git a/src/lib/VSDStyles.h b/src/lib/VSDStyles.h
index 9c518d5..f50946e 100644
--- a/src/lib/VSDStyles.h
+++ b/src/lib/VSDStyles.h
@@ -14,59 +14,12 @@
 #include <vector>
 #include <boost/optional.hpp>
 #include "VSDTypes.h"
+#include "VSDXTheme.h"
+#include "libvisio_utils.h"
 
 namespace libvisio
 {
 
-struct VSDOptionalThemeReference
-{
-  VSDOptionalThemeReference() :
-    qsLineColour(), qsFillColour(), qsShadowColour(), qsFontColour() {}
-  VSDOptionalThemeReference(const boost::optional<long> &lineColour, const boost::optional<long> &fillColour,
-                            const boost::optional<long> &shadowColour, const boost::optional<long> &fontColour) :
-    qsLineColour(lineColour), qsFillColour(fillColour), qsShadowColour(shadowColour), qsFontColour(fontColour) {}
-  VSDOptionalThemeReference(const VSDOptionalThemeReference &themeRef) :
-    qsLineColour(themeRef.qsLineColour), qsFillColour(themeRef.qsFillColour),
-    qsShadowColour(themeRef.qsShadowColour), qsFontColour(themeRef.qsFontColour) {}
-  ~VSDOptionalThemeReference() {}
-  void override(const VSDOptionalThemeReference &themeRef)
-  {
-    ASSIGN_OPTIONAL(themeRef.qsLineColour, qsLineColour);
-    ASSIGN_OPTIONAL(themeRef.qsFillColour, qsFillColour);
-    ASSIGN_OPTIONAL(themeRef.qsShadowColour, qsShadowColour);
-    ASSIGN_OPTIONAL(themeRef.qsFontColour, qsFontColour);
-  }
-
-  boost::optional<long> qsLineColour;
-  boost::optional<long> qsFillColour;
-  boost::optional<long> qsShadowColour;
-  boost::optional<long> qsFontColour;
-};
-
-struct VSDThemeReference
-{
-  VSDThemeReference() :
-    qsLineColour(-1), qsFillColour(-1), qsShadowColour(-1), qsFontColour(-1) {}
-  VSDThemeReference(long lineColour, long fillColour, long shadowColour, long fontColour) :
-    qsLineColour(lineColour), qsFillColour(fillColour), qsShadowColour(shadowColour), qsFontColour(fontColour) {}
-  VSDThemeReference(const VSDThemeReference &themeRef) :
-    qsLineColour(themeRef.qsLineColour), qsFillColour(themeRef.qsFillColour),
-    qsShadowColour(themeRef.qsShadowColour), qsFontColour(themeRef.qsFontColour) {}
-  ~VSDThemeReference() {}
-  void override(const VSDOptionalThemeReference &themeRef)
-  {
-    ASSIGN_OPTIONAL(themeRef.qsLineColour, qsLineColour);
-    ASSIGN_OPTIONAL(themeRef.qsFillColour, qsFillColour);
-    ASSIGN_OPTIONAL(themeRef.qsShadowColour, qsShadowColour);
-    ASSIGN_OPTIONAL(themeRef.qsFontColour, qsFontColour);
-  }
-
-  long qsLineColour;
-  long qsFillColour;
-  long qsShadowColour;
-  long qsFontColour;
-};
-
 struct VSDOptionalLineStyle
 {
   VSDOptionalLineStyle() :
@@ -111,15 +64,22 @@ struct VSDLineStyle
     width(style.width), colour(style.colour), pattern(style.pattern), startMarker(style.startMarker),
     endMarker(style.endMarker), cap(style.cap), rounding(style.rounding) {}
   ~VSDLineStyle() {}
-  void override(const VSDOptionalLineStyle &style)
+  void override(const VSDOptionalLineStyle &style, const VSDXTheme *theme)
   {
     ASSIGN_OPTIONAL(style.width, width);
-    ASSIGN_OPTIONAL(style.colour, colour);
     ASSIGN_OPTIONAL(style.pattern, pattern);
     ASSIGN_OPTIONAL(style.startMarker, startMarker);
     ASSIGN_OPTIONAL(style.endMarker, endMarker);
     ASSIGN_OPTIONAL(style.cap, cap);
     ASSIGN_OPTIONAL(style.rounding, rounding);
+    if (!theme)
+    {
+      ASSIGN_OPTIONAL(style.colour, colour);
+    }
+    else
+    {
+      ASSIGN_OPTIONAL(style.colour, colour);
+    }
   }
 
   double width;
@@ -135,30 +95,35 @@ struct VSDOptionalFillStyle
 {
   VSDOptionalFillStyle() :
     fgColour(), bgColour(), pattern(), fgTransparency(), bgTransparency(), shadowFgColour(),
-    shadowPattern(), shadowOffsetX(), shadowOffsetY() {}
+    shadowPattern(), shadowOffsetX(), shadowOffsetY(), qsFillColour(), qsShadowColour() {}
   VSDOptionalFillStyle(const boost::optional<Colour> &fgc, const boost::optional<Colour> &bgc,
                        const boost::optional<unsigned char> &p, const boost::optional<double> &fga,
                        const boost::optional<double> &bga, const boost::optional<Colour> &sfgc,
                        const boost::optional<unsigned char> &shp, const boost::optional<double> &shX,
-                       const boost::optional<double> &shY) :
+                       const boost::optional<double> &shY, const boost::optional<long> &qsFc,
+                       const boost::optional<long> &qsSc) :
     fgColour(fgc), bgColour(bgc), pattern(p), fgTransparency(fga), bgTransparency(bga),
-    shadowFgColour(sfgc), shadowPattern(shp), shadowOffsetX(shX), shadowOffsetY(shY) {}
+    shadowFgColour(sfgc), shadowPattern(shp), shadowOffsetX(shX), shadowOffsetY(shY),
+    qsFillColour(qsFc), qsShadowColour(qsSc) {}
   VSDOptionalFillStyle(const VSDOptionalFillStyle &style) :
     fgColour(style.fgColour), bgColour(style.bgColour), pattern(style.pattern), fgTransparency(style.fgTransparency),
     bgTransparency(style.bgTransparency), shadowFgColour(style.shadowFgColour), shadowPattern(style.shadowPattern),
-    shadowOffsetX(style.shadowOffsetX), shadowOffsetY(style.shadowOffsetY) {}
+    shadowOffsetX(style.shadowOffsetX), shadowOffsetY(style.shadowOffsetY), qsFillColour(style.qsFillColour),
+    qsShadowColour(style.qsShadowColour) {}
   ~VSDOptionalFillStyle() {}
   void override(const VSDOptionalFillStyle &style)
   {
-    ASSIGN_OPTIONAL(style.fgColour, fgColour);
-    ASSIGN_OPTIONAL(style.bgColour, bgColour);
     ASSIGN_OPTIONAL(style.pattern, pattern);
     ASSIGN_OPTIONAL(style.fgTransparency, fgTransparency);
     ASSIGN_OPTIONAL(style.bgTransparency, bgTransparency);
-    ASSIGN_OPTIONAL(style.shadowFgColour, shadowFgColour);
     ASSIGN_OPTIONAL(style.shadowPattern, shadowPattern);
     ASSIGN_OPTIONAL(style.shadowOffsetX, shadowOffsetX);
     ASSIGN_OPTIONAL(style.shadowOffsetY, shadowOffsetY);
+    ASSIGN_OPTIONAL(style.qsFillColour, qsFillColour);
+    ASSIGN_OPTIONAL(style.qsShadowColour, qsShadowColour);
+    ASSIGN_OPTIONAL(style.fgColour, fgColour);
+    ASSIGN_OPTIONAL(style.bgColour, bgColour);
+    ASSIGN_OPTIONAL(style.shadowFgColour, shadowFgColour);
   }
 
   boost::optional<Colour> fgColour;
@@ -170,33 +135,57 @@ struct VSDOptionalFillStyle
   boost::optional<unsigned char> shadowPattern;
   boost::optional<double> shadowOffsetX;
   boost::optional<double> shadowOffsetY;
+  boost::optional<long> qsFillColour;
+  boost::optional<long> qsShadowColour;
 };
 
 struct VSDFillStyle
 {
   VSDFillStyle()
     : fgColour(), bgColour(0xff, 0xff, 0xff, 0), pattern(0), fgTransparency(0), bgTransparency(0), shadowFgColour(),
-      shadowPattern(0), shadowOffsetX(0), shadowOffsetY(0) {}
+      shadowPattern(0), shadowOffsetX(0), shadowOffsetY(0), qsFillColour(-1), qsShadowColour(-1) {}
   VSDFillStyle(const Colour &fgc, const Colour &bgc, unsigned char p, double fga, double bga, const Colour &sfgc,
-               unsigned char shp, double shX, double shY)
+               unsigned char shp, double shX, double shY, long qsFc, long qsSc)
     : fgColour(fgc), bgColour(bgc), pattern(p), fgTransparency(fga), bgTransparency(bga),
-      shadowFgColour(sfgc), shadowPattern(shp), shadowOffsetX(shX), shadowOffsetY(shY) {}
+      shadowFgColour(sfgc), shadowPattern(shp), shadowOffsetX(shX), shadowOffsetY(shY),
+      qsFillColour(qsFc), qsShadowColour(qsSc) {}
   VSDFillStyle(const VSDFillStyle &style) :
     fgColour(style.fgColour), bgColour(style.bgColour), pattern(style.pattern), fgTransparency(style.fgTransparency),
     bgTransparency(style.bgTransparency), shadowFgColour(style.shadowFgColour), shadowPattern(style.shadowPattern),
-    shadowOffsetX(style.shadowOffsetX), shadowOffsetY(style.shadowOffsetY) {}
+    shadowOffsetX(style.shadowOffsetX), shadowOffsetY(style.shadowOffsetY), qsFillColour(style.qsFillColour),
+    qsShadowColour(style.qsShadowColour) {}
   ~VSDFillStyle() {}
-  void override(const VSDOptionalFillStyle &style)
+  void override(const VSDOptionalFillStyle &style, const VSDXTheme *theme)
   {
-    ASSIGN_OPTIONAL(style.fgColour, fgColour);
-    ASSIGN_OPTIONAL(style.bgColour, bgColour);
     ASSIGN_OPTIONAL(style.pattern, pattern);
     ASSIGN_OPTIONAL(style.fgTransparency, fgTransparency);
     ASSIGN_OPTIONAL(style.bgTransparency, bgTransparency);
-    ASSIGN_OPTIONAL(style.shadowFgColour, shadowFgColour);
     ASSIGN_OPTIONAL(style.shadowPattern, shadowPattern);
     ASSIGN_OPTIONAL(style.shadowOffsetX, shadowOffsetX);
     ASSIGN_OPTIONAL(style.shadowOffsetY, shadowOffsetY);
+    ASSIGN_OPTIONAL(style.shadowOffsetY, shadowOffsetY);
+    ASSIGN_OPTIONAL(style.qsFillColour, qsFillColour);
+    ASSIGN_OPTIONAL(style.qsShadowColour, qsShadowColour);
+    if (theme)
+    {
+      if (!!style.qsFillColour && style.qsFillColour.get() >= 0)
+        ASSIGN_OPTIONAL(theme->getThemeColour(style.qsFillColour.get()), fgColour);
+      ASSIGN_OPTIONAL(style.fgColour, fgColour);
+
+      if (!!style.qsFillColour && style.qsFillColour.get() >= 0)
+        ASSIGN_OPTIONAL(theme->getThemeColour(style.qsFillColour.get()), bgColour);
+      ASSIGN_OPTIONAL(style.bgColour, bgColour);
+
+      if (!!style.qsShadowColour && style.qsShadowColour.get() >= 0)
+        ASSIGN_OPTIONAL(theme->getThemeColour(style.qsShadowColour.get()), shadowFgColour);
+      ASSIGN_OPTIONAL(style.shadowFgColour, shadowFgColour);
+    }
+    else
+    {
+      ASSIGN_OPTIONAL(style.fgColour, fgColour);
+      ASSIGN_OPTIONAL(style.bgColour, bgColour);
+      ASSIGN_OPTIONAL(style.shadowFgColour, shadowFgColour);
+    }
   }
 
   Colour fgColour;
@@ -208,6 +197,8 @@ struct VSDFillStyle
   unsigned char shadowPattern;
   double shadowOffsetX;
   double shadowOffsetY;
+  long qsFillColour;
+  long qsShadowColour;
 };
 
 struct VSDOptionalCharStyle
@@ -284,7 +275,7 @@ struct VSDCharStyle
     doublestrikeout(style.doublestrikeout), allcaps(style.allcaps), initcaps(style.initcaps), smallcaps(style.smallcaps),
     superscript(style.superscript), subscript(style.subscript), scaleWidth(style.scaleWidth) {}
   ~VSDCharStyle() {}
-  void override(const VSDOptionalCharStyle &style)
+  void override(const VSDOptionalCharStyle &style, const VSDXTheme * /* theme */)
   {
     ASSIGN_OPTIONAL(style.font, font);
     ASSIGN_OPTIONAL(style.colour, colour);
@@ -388,7 +379,7 @@ struct VSDParaStyle
     bullet(style.bullet), bulletStr(style.bulletStr), bulletFont(style.bulletFont),
     bulletFontSize(style.bulletFontSize), textPosAfterBullet(style.textPosAfterBullet), flags(style.flags) {}
   ~VSDParaStyle() {}
-  void override(const VSDOptionalParaStyle &style)
+  void override(const VSDOptionalParaStyle &style, const VSDXTheme * /* theme */)
   {
     ASSIGN_OPTIONAL(style.indFirst, indFirst);
     ASSIGN_OPTIONAL(style.indLeft, indLeft);
@@ -476,7 +467,7 @@ struct VSDTextBlockStyle
     bottomMargin(style.bottomMargin), verticalAlign(style.verticalAlign), isTextBkgndFilled(style.isTextBkgndFilled),
     textBkgndColour(style.textBkgndColour), defaultTabStop(style.defaultTabStop), textDirection(style.textDirection) {}
   ~VSDTextBlockStyle() {}
-  void override(const VSDOptionalTextBlockStyle &style)
+  void override(const VSDOptionalTextBlockStyle &style, const VSDXTheme * /* theme */)
   {
     ASSIGN_OPTIONAL(style.leftMargin, leftMargin);
     ASSIGN_OPTIONAL(style.rightMargin, rightMargin);
@@ -512,19 +503,17 @@ public:
   void addTextBlockStyle(unsigned textStyleIndex, const VSDOptionalTextBlockStyle &textBlockStyle);
   void addCharStyle(unsigned textStyleIndex, const VSDOptionalCharStyle &charStyle);
   void addParaStyle(unsigned textStyleIndex, const VSDOptionalParaStyle &paraStyle);
-  void addStyleThemeReference(unsigned styleIndex, const VSDOptionalThemeReference &themeRef);
 
   void addLineStyleMaster(unsigned lineStyleIndex, unsigned lineStyleMaster);
   void addFillStyleMaster(unsigned fillStyleIndex, unsigned fillStyleMaster);
   void addTextStyleMaster(unsigned textStyleIndex, unsigned textStyleMaster);
 
   VSDOptionalLineStyle getOptionalLineStyle(unsigned lineStyleIndex) const;
-  VSDFillStyle getFillStyle(unsigned fillStyleIndex) const;
+  VSDFillStyle getFillStyle(unsigned fillStyleIndex, const VSDXTheme *theme) const;
   VSDOptionalFillStyle getOptionalFillStyle(unsigned fillStyleIndex) const;
   VSDOptionalTextBlockStyle getOptionalTextBlockStyle(unsigned textStyleIndex) const;
   VSDOptionalCharStyle getOptionalCharStyle(unsigned textStyleIndex) const;
   VSDOptionalParaStyle getOptionalParaStyle(unsigned textStyleIndex) const;
-  VSDOptionalThemeReference getOptionalThemeReference(unsigned styleIndex) const;
 
 private:
   std::map<unsigned, VSDOptionalLineStyle> m_lineStyles;
@@ -532,7 +521,6 @@ private:
   std::map<unsigned, VSDOptionalTextBlockStyle> m_textBlockStyles;
   std::map<unsigned, VSDOptionalCharStyle> m_charStyles;
   std::map<unsigned, VSDOptionalParaStyle> m_paraStyles;
-  std::map<unsigned, VSDOptionalThemeReference> m_themeRefs;
   std::map<unsigned, unsigned> m_lineStyleMasters;
   std::map<unsigned, unsigned> m_fillStyleMasters;
   std::map<unsigned, unsigned> m_textStyleMasters;
diff --git a/src/lib/VSDStylesCollector.cpp b/src/lib/VSDStylesCollector.cpp
index aaddc09..2ba74d0 100644
--- a/src/lib/VSDStylesCollector.cpp
+++ b/src/lib/VSDStylesCollector.cpp
@@ -62,21 +62,18 @@ void libvisio::VSDStylesCollector::collectLine(unsigned level, const boost::opti
 
 void libvisio::VSDStylesCollector::collectFillAndShadow(unsigned level, const boost::optional<Colour> & /* colourFG */, const boost::optional<Colour> & /* colourBG */,
                                                         const boost::optional<unsigned char> & /* fillPattern */, const boost::optional<double> & /* fillFGTransparency */,
-                                                        const boost::optional<double> & /* fillBGTransparency */, const boost::optional<unsigned char> & /* shadowPattern */, const boost::optional<Colour> & /* shfgc */,
-                                                        const boost::optional<double> & /* shadowOffsetX */, const boost::optional<double> &/* shadowOffsetY */)
+                                                        const boost::optional<double> & /* fillBGTransparency */, const boost::optional<unsigned char> & /* shadowPattern */,
+                                                        const boost::optional<Colour> & /* shfgc */, const boost::optional<double> & /* shadowOffsetX */,
+                                                        const boost::optional<double> & /* shadowOffsetY */, const boost::optional<long> & /* qsFillColour */,
+                                                        const boost::optional<long> & /* qsShadowColour */)
 {
   _handleLevelChange(level);
 }
 
 void libvisio::VSDStylesCollector::collectFillAndShadow(unsigned level, const boost::optional<Colour> & /* colourFG */, const boost::optional<Colour> & /* colourBG */,
                                                         const boost::optional<unsigned char> & /* fillPattern */, const boost::optional<double> & /* fillFGTransparency */,
-                                                        const boost::optional<double> & /* fillBGTransparency */, const boost::optional<unsigned char> & /* shadowPattern */, const boost::optional<Colour> & /* shfgc */)
-{
-  _handleLevelChange(level);
-}
-
-void libvisio::VSDStylesCollector::collectThemeReference(unsigned level, const boost::optional<long> & /* lineColour */, const boost::optional<long> & /* fillColour */,
-                                                         const boost::optional<long> & /* shadowColour */, const boost::optional<long> & /* fontColour */)
+                                                        const boost::optional<double> & /* fillBGTransparency */, const boost::optional<unsigned char> & /* shadowPattern */,
+                                                        const boost::optional<Colour> & /* shfgc */)
 {
   _handleLevelChange(level);
 }
@@ -351,7 +348,8 @@ void libvisio::VSDStylesCollector::collectFillStyle(unsigned level, const boost:
                                                     const boost::optional<unsigned char> & /* fillPattern */, const boost::optional<double> & /* fillFGTransparency */,
                                                     const boost::optional<double> & /* fillBGTransparency */, const boost::optional<unsigned char> & /* shadowPattern */,
                                                     const boost::optional<Colour> & /* shfgc */, const boost::optional<double> & /* shadowOffsetX */,
-                                                    const boost::optional<double> & /* shadowOffsetY */)
+                                                    const boost::optional<double> & /* shadowOffsetY */, const boost::optional<long> & /* qsFillColour */,
+                                                    const boost::optional<long> & /* qsShadowColour */)
 {
   _handleLevelChange(level);
 }
@@ -397,12 +395,6 @@ void libvisio::VSDStylesCollector::collectTextBlockStyle(unsigned level, const b
   _handleLevelChange(level);
 }
 
-void libvisio::VSDStylesCollector::collectStyleThemeReference(unsigned level, const boost::optional<long> & /* lineColour */, const boost::optional<long> & /* fillColour */,
-                                                              const boost::optional<long> & /* shadowColour */, const boost::optional<long> & /* fontColour */)
-{
-  _handleLevelChange(level);
-}
-
 void libvisio::VSDStylesCollector::collectFieldList(unsigned /* id */, unsigned level)
 {
   _handleLevelChange(level);
diff --git a/src/lib/VSDStylesCollector.h b/src/lib/VSDStylesCollector.h
index 9e4534e..1c2458c 100644
--- a/src/lib/VSDStylesCollector.h
+++ b/src/lib/VSDStylesCollector.h
@@ -31,6 +31,7 @@ public:
   );
   virtual ~VSDStylesCollector() {}
 
+  void collectDocumentTheme(const VSDXTheme * /* theme */) {}
   void collectEllipticalArcTo(unsigned id, unsigned level, double x3, double y3, double x2, double y2, double angle, double ecc);
   void collectForeignData(unsigned level, const librevenge::RVNGBinaryData &binaryData);
   void collectOLEList(unsigned id, unsigned level)
@@ -45,13 +46,12 @@ public:
   void collectFillAndShadow(unsigned level, const boost::optional<Colour> &colourFG, const boost::optional<Colour> &colourBG,
                             const boost::optional<unsigned char> &fillPattern, const boost::optional<double> &fillFGTransparency,
                             const boost::optional<double> &fillBGTransparency, const boost::optional<unsigned char> &shadowPattern,
-                            const boost::optional<Colour> &shfgc, const boost::optional<double> &shadowOffsetX, const boost::optional<double> &shadowOffsetY);
+                            const boost::optional<Colour> &shfgc, const boost::optional<double> &shadowOffsetX, const boost::optional<double> &shadowOffsetY,
+                            const boost::optional<long> &qsFc, const boost::optional<long> &qsSc);
   void collectFillAndShadow(unsigned level, const boost::optional<Colour> &colourFG, const boost::optional<Colour> &colourBG,
                             const boost::optional<unsigned char> &fillPattern, const boost::optional<double> &fillFGTransparency,
                             const boost::optional<double> &fillBGTransparency, const boost::optional<unsigned char> &shadowPattern,
                             const boost::optional<Colour> &shfgc);
-  void collectThemeReference(unsigned level, const boost::optional<long> &lineColour, const boost::optional<long> &fillColour,
-                             const boost::optional<long> &shadowColour, const boost::optional<long> &fontColour);
   void collectGeometry(unsigned id, unsigned level, bool noFill, bool noLine, bool noShow);
   void collectMoveTo(unsigned id, unsigned level, double x, double y);
   void collectLineTo(unsigned id, unsigned level, double x, double y);
@@ -133,7 +133,8 @@ public:
   void collectFillStyle(unsigned level, const boost::optional<Colour> &colourFG, const boost::optional<Colour> &colourBG,
                         const boost::optional<unsigned char> &fillPattern, const boost::optional<double> &fillFGTransparency,
                         const boost::optional<double> &fillBGTransparency, const boost::optional<unsigned char> &shadowPattern,
-                        const boost::optional<Colour> &shfgc, const boost::optional<double> &shadowOffsetX, const boost::optional<double> &shadowOffsetY);
+                        const boost::optional<Colour> &shfgc, const boost::optional<double> &shadowOffsetX, const boost::optional<double> &shadowOffsetY,
+                        const boost::optional<long> &qsFillColour, const boost::optional<long> &qsShadowColour);
   void collectFillStyle(unsigned level, const boost::optional<Colour> &colourFG, const boost::optional<Colour> &colourBG,
                         const boost::optional<unsigned char> &fillPattern, const boost::optional<double> &fillFGTransparency,
                         const boost::optional<double> &fillBGTransparency, const boost::optional<unsigned char> &shadowPattern,
@@ -155,8 +156,6 @@ public:
                              const boost::optional<unsigned char> &verticalAlign, const boost::optional<bool> &isBgFilled,
                              const boost::optional<Colour> &bgColour, const boost::optional<double> &defaultTabStop,
                              const boost::optional<unsigned char> &textDirection);
-  void collectStyleThemeReference(unsigned level, const boost::optional<long> &lineColour, const boost::optional<long> &fillColour,
-                                  const boost::optional<long> &shadowColour, const boost::optional<long> &fontColour);
 
   // Field list
   void collectFieldList(unsigned id, unsigned level);
diff --git a/src/lib/VSDXMLParserBase.cpp b/src/lib/VSDXMLParserBase.cpp
index d1b8676..f6c531a 100644
--- a/src/lib/VSDXMLParserBase.cpp
+++ b/src/lib/VSDXMLParserBase.cpp
@@ -1767,7 +1767,8 @@ void libvisio::VSDXMLParserBase::_flushShape()
 
   m_collector->collectFillAndShadow(m_currentShapeLevel+2, m_shape.m_fillStyle.fgColour, m_shape.m_fillStyle.bgColour, m_shape.m_fillStyle.pattern,
                                     m_shape.m_fillStyle.fgTransparency, m_shape.m_fillStyle.bgTransparency, m_shape.m_fillStyle.shadowPattern,
-                                    m_shape.m_fillStyle.shadowFgColour, m_shape.m_fillStyle.shadowOffsetX, m_shape.m_fillStyle.shadowOffsetY);
+                                    m_shape.m_fillStyle.shadowFgColour, m_shape.m_fillStyle.shadowOffsetX, m_shape.m_fillStyle.shadowOffsetY,
+                                    m_shape.m_fillStyle.qsFillColour, m_shape.m_fillStyle.qsShadowColour);
 
   m_collector->collectTextBlock(m_currentShapeLevel+2, m_shape.m_textBlockStyle.leftMargin, m_shape.m_textBlockStyle.rightMargin,
                                 m_shape.m_textBlockStyle.topMargin, m_shape.m_textBlockStyle.bottomMargin, m_shape.m_textBlockStyle.verticalAlign,
diff --git a/src/lib/VSDXParser.cpp b/src/lib/VSDXParser.cpp
index 2f0167e..f9d5d61 100644
--- a/src/lib/VSDXParser.cpp
+++ b/src/lib/VSDXParser.cpp
@@ -132,7 +132,10 @@ bool libvisio::VSDXParser::parseDocument(librevenge::RVNGInputStream *input, con
     if (!parseTheme(input, rel->getTarget().c_str()))
     {
       VSD_DEBUG_MSG(("Could not parse theme\n"));
+      m_collector->collectDocumentTheme(0);
     }
+    else
+      m_collector->collectDocumentTheme(&m_currentTheme);
     input->seek(0, librevenge::RVNG_SEEK_SET);
   }
 
@@ -727,6 +730,8 @@ void libvisio::VSDXParser::readStyleProperties(xmlTextReaderPtr reader)
   boost::optional<unsigned char> shadowPattern;
   boost::optional<double> shadowOffsetX;
   boost::optional<double> shadowOffsetY;
+  boost::optional<long> qsFillColour;
+  boost::optional<long> qsShadowColour;
 
   // Text block properties
   boost::optional<double> leftMargin;
@@ -875,25 +880,11 @@ void libvisio::VSDXParser::readStyleProperties(xmlTextReaderPtr reader)
       break;
     case XML_QUICKSTYLEFILLCOLOR:
       if (XML_READER_TYPE_ELEMENT == tokenType)
-      {
-        long tmpValue;
-        ret = readLongData(tmpValue, reader);
-        if (!fillColourFG)
-          fillColourFG = m_currentTheme.getThemeColour((unsigned)tmpValue);
-        if (!fillColourBG)
-          fillColourBG = m_currentTheme.getThemeColour((unsigned)tmpValue);
-      }
+        ret = readLongData(qsFillColour, reader);
       break;
     case XML_QUICKSTYLESHADOWCOLOR:
       if (XML_READER_TYPE_ELEMENT == tokenType)
-      {
-        long tmpValue;
-        ret = readLongData(tmpValue, reader);
-        if (!shadowColourFG)
-          shadowColourFG = m_currentTheme.getThemeColour((unsigned)tmpValue);
-        if (!shadowColourBG)
-          shadowColourBG = m_currentTheme.getThemeColour((unsigned)tmpValue);
-      }
+        ret = readLongData(qsShadowColour, reader);
       break;
     default:
       break;
@@ -918,7 +909,8 @@ void libvisio::VSDXParser::readStyleProperties(xmlTextReaderPtr reader)
   {
     m_collector->collectLineStyle(level, strokeWidth, strokeColour, linePattern, startMarker, endMarker, lineCap, rounding);
     m_collector->collectFillStyle(level, fillColourFG, fillColourBG, fillPattern, fillFGTransparency,
-                                  fillBGTransparency, shadowPattern, shadowColourFG, shadowOffsetX, shadowOffsetY);
+                                  fillBGTransparency, shadowPattern, shadowColourFG, shadowOffsetX, shadowOffsetY,
+                                  qsFillColour, qsShadowColour);
     m_collector->collectTextBlockStyle(level, leftMargin, rightMargin, topMargin, bottomMargin,
                                        verticalAlign, bgClrId, bgColour, defaultTabStop, textDirection);
   }
@@ -926,7 +918,7 @@ void libvisio::VSDXParser::readStyleProperties(xmlTextReaderPtr reader)
   {
     m_shape.m_lineStyle.override(VSDOptionalLineStyle(strokeWidth, strokeColour, linePattern, startMarker, endMarker, lineCap, rounding));
     m_shape.m_fillStyle.override(VSDOptionalFillStyle(fillColourFG, fillColourBG, fillPattern, fillFGTransparency, fillBGTransparency, shadowColourFG,
-                                                      shadowPattern, shadowOffsetX, shadowOffsetY));
+                                                      shadowPattern, shadowOffsetX, shadowOffsetY, qsFillColour, qsShadowColour));
     m_shape.m_textBlockStyle.override(VSDOptionalTextBlockStyle(leftMargin, rightMargin, topMargin, bottomMargin, verticalAlign, !!bgClrId, bgColour,
                                                                 defaultTabStop, textDirection));
   }
@@ -1273,23 +1265,11 @@ void libvisio::VSDXParser::readShapeProperties(xmlTextReaderPtr reader)
       break;
     case XML_QUICKSTYLEFILLCOLOR:
       if (XML_READER_TYPE_ELEMENT == tokenType)
-      {
-        long tmpValue;
-        ret = readLongData(tmpValue, reader);
-        if (!m_shape.m_fillStyle.fgColour)
-          m_shape.m_fillStyle.fgColour = m_currentTheme.getThemeColour((unsigned)tmpValue);
-        if (!m_shape.m_fillStyle.bgColour)
-          m_shape.m_fillStyle.bgColour = m_currentTheme.getThemeColour((unsigned)tmpValue);
-      }
+        ret = readLongData(m_shape.m_fillStyle.qsFillColour, reader);
       break;
     case XML_QUICKSTYLESHADOWCOLOR:
       if (XML_READER_TYPE_ELEMENT == tokenType)
-      {
-        long tmpValue;
-        ret = readLongData(tmpValue, reader);
-        if (!m_shape.m_fillStyle.shadowFgColour)
-          m_shape.m_fillStyle.shadowFgColour = m_currentTheme.getThemeColour((unsigned)tmpValue);
-      }
+        ret = readLongData(m_shape.m_fillStyle.qsShadowColour, reader);
       break;
     case XML_LAYERMEMBER:
       if (XML_READER_TYPE_ELEMENT == tokenType)


More information about the Libreoffice-commits mailing list