[Libreoffice-commits] .: src/lib

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Dec 18 01:14:59 PST 2012


 src/lib/VSD6Parser.cpp |   44 ++++++++++++++++++++++++++++++++------------
 src/lib/VSDParser.cpp  |   45 +++++++++++++++++++++++++++++++++------------
 src/lib/VSDTypes.h     |   12 ++++++++++++
 3 files changed, 77 insertions(+), 24 deletions(-)

New commits:
commit 8e8bf14463dc2777c1cea49af1159adede727711
Author: Fridrich Å trba <fridrich.strba at bluewin.ch>
Date:   Tue Dec 18 10:14:24 2012 +0100

    When cached fg and bg colours are 0, trust index more

diff --git a/src/lib/VSD6Parser.cpp b/src/lib/VSD6Parser.cpp
index 335872c..645d569 100644
--- a/src/lib/VSD6Parser.cpp
+++ b/src/lib/VSD6Parser.cpp
@@ -206,31 +206,51 @@ void libvisio::VSD6Parser::readParaIX(WPXInputStream *input)
 
 void libvisio::VSD6Parser::readFillAndShadow(WPXInputStream *input)
 {
-  Colour colourFG = _colourFromIndex(readU8(input));
+  unsigned char colourFGIndex = readU8(input);
+  Colour colourFG;
   colourFG.r = readU8(input);
   colourFG.g = readU8(input);
   colourFG.b = readU8(input);
   colourFG.a = readU8(input);
-  double fillFGTransparency = (double)colourFG.a / 255.0;
-  Colour colourBG = _colourFromIndex(readU8(input));
+  unsigned char colourBGIndex = readU8(input);
+  Colour colourBG;
   colourBG.r = readU8(input);
   colourBG.g = readU8(input);
   colourBG.b = readU8(input);
   colourBG.a = readU8(input);
+  if (!colourFG && !colourBG)
+  {
+    colourFG = _colourFromIndex(colourFGIndex);
+    colourBG = _colourFromIndex(colourBGIndex);
+  }
+  double fillFGTransparency = (double)colourFG.a / 255.0;
   double fillBGTransparency = (double)colourBG.a / 255.0;
+
   unsigned char fillPattern = readU8(input);
-  input->seek(1, WPX_SEEK_CUR);
-  Colour shfgc;            // Shadow Foreground Colour
-  shfgc.r = readU8(input);
-  shfgc.g = readU8(input);
-  shfgc.b = readU8(input);
-  shfgc.a = readU8(input);
-  input->seek(5, WPX_SEEK_CUR); // Shadow Background Colour skipped
+
+  unsigned char shadowFGIndex = readU8(input);
+  Colour shadowFG;
+  shadowFG.r = readU8(input);
+  shadowFG.g = readU8(input);
+  shadowFG.b = readU8(input);
+  shadowFG.a = readU8(input);
+  unsigned char shadowBGIndex = readU8(input);
+  Colour shadowBG;
+  shadowBG.r = readU8(input);
+  shadowBG.g = readU8(input);
+  shadowBG.b = readU8(input);
+  shadowBG.a = readU8(input);
+  if (!shadowFG && !shadowBG)
+  {
+    shadowFG = _colourFromIndex(shadowFGIndex);
+    shadowBG = _colourFromIndex(shadowBGIndex);
+  }
+
   unsigned char shadowPattern = readU8(input);
 
   if (m_isInStyles)
     m_collector->collectFillStyle(m_header.level, colourFG, colourBG, fillPattern,
-                                  fillFGTransparency, fillBGTransparency, shadowPattern, shfgc);
+                                  fillFGTransparency, fillBGTransparency, shadowPattern, shadowFG);
   else
   {
     double shadowOffsetX = 0.0;
@@ -247,7 +267,7 @@ void libvisio::VSD6Parser::readFillAndShadow(WPXInputStream *input)
       shadowOffsetY = m_shadowOffsetY;
     }
     m_shape.m_fillStyle.override(VSDOptionalFillStyle(colourFG, colourBG, fillPattern, fillFGTransparency,
-                                 fillBGTransparency, shfgc, shadowPattern, shadowOffsetX, shadowOffsetY));
+                                 fillBGTransparency, shadowFG, shadowPattern, shadowOffsetX, shadowOffsetY));
   }
 }
 
diff --git a/src/lib/VSDParser.cpp b/src/lib/VSDParser.cpp
index e649c56..bab29b6 100644
--- a/src/lib/VSDParser.cpp
+++ b/src/lib/VSDParser.cpp
@@ -1668,27 +1668,48 @@ void libvisio::VSDParser::readParaIX(WPXInputStream *input)
 
 void libvisio::VSDParser::readFillAndShadow(WPXInputStream *input)
 {
-  Colour colourFG = _colourFromIndex(readU8(input));
+  unsigned char colourFGIndex = readU8(input);
+  Colour colourFG;
   colourFG.r = readU8(input);
   colourFG.g = readU8(input);
   colourFG.b = readU8(input);
   colourFG.a = readU8(input);
-  double fillFGTransparency = (double)colourFG.a / 255.0;
-  Colour colourBG = _colourFromIndex(readU8(input));
+  unsigned char colourBGIndex = readU8(input);
+  Colour colourBG;
   colourBG.r = readU8(input);
   colourBG.g = readU8(input);
   colourBG.b = readU8(input);
   colourBG.a = readU8(input);
+  if (!colourFG && !colourBG)
+  {
+    colourFG = _colourFromIndex(colourFGIndex);
+    colourBG = _colourFromIndex(colourBGIndex);
+  }
+  double fillFGTransparency = (double)colourFG.a / 255.0;
   double fillBGTransparency = (double)colourBG.a / 255.0;
+
   unsigned char fillPattern = readU8(input);
-  input->seek(1, WPX_SEEK_CUR);
-  Colour shfgc;            // Shadow Foreground Colour
-  shfgc.r = readU8(input);
-  shfgc.g = readU8(input);
-  shfgc.b = readU8(input);
-  shfgc.a = readU8(input);
-  input->seek(5, WPX_SEEK_CUR); // Shadow Background Colour skipped
+
+  unsigned char shadowFGIndex = readU8(input);
+  Colour shadowFG;
+  shadowFG.r = readU8(input);
+  shadowFG.g = readU8(input);
+  shadowFG.b = readU8(input);
+  shadowFG.a = readU8(input);
+  unsigned char shadowBGIndex = readU8(input);
+  Colour shadowBG;
+  shadowBG.r = readU8(input);
+  shadowBG.g = readU8(input);
+  shadowBG.b = readU8(input);
+  shadowBG.a = readU8(input);
+  if (!shadowFG && !shadowBG)
+  {
+    shadowFG = _colourFromIndex(shadowFGIndex);
+    shadowBG = _colourFromIndex(shadowBGIndex);
+  }
+
   unsigned char shadowPattern = readU8(input);
+
 // only version 11 after that point
   input->seek(2, WPX_SEEK_CUR); // Shadow Type and Value format byte
   double shadowOffsetX = readDouble(input);
@@ -1699,7 +1720,7 @@ void libvisio::VSDParser::readFillAndShadow(WPXInputStream *input)
 
   if (m_isInStyles)
     m_collector->collectFillStyle(m_header.level, colourFG, colourBG, fillPattern,
-                                  fillFGTransparency, fillBGTransparency, shadowPattern, shfgc,
+                                  fillFGTransparency, fillBGTransparency, shadowPattern, shadowFG,
                                   shadowOffsetX, shadowOffsetY);
   else
   {
@@ -1708,7 +1729,7 @@ void libvisio::VSDParser::readFillAndShadow(WPXInputStream *input)
       VSD_DEBUG_MSG(("Found stencil fill\n"));
     }
     m_shape.m_fillStyle.override(VSDOptionalFillStyle(colourFG, colourBG, fillPattern, fillFGTransparency,
-                                 fillBGTransparency, shfgc, shadowPattern, shadowOffsetX, shadowOffsetY));
+                                 fillBGTransparency, shadowFG, shadowPattern, shadowOffsetX, shadowOffsetY));
   }
 }
 
diff --git a/src/lib/VSDTypes.h b/src/lib/VSDTypes.h
index 0b0d299..ba90396 100644
--- a/src/lib/VSDTypes.h
+++ b/src/lib/VSDTypes.h
@@ -80,6 +80,18 @@ struct Colour
   Colour(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha)
     : r(red), g(green), b(blue), a(alpha) {}
   Colour() : r(0), g(0), b(0), a(0) {}
+  inline bool operator==(const Colour &col)
+  {
+    return ((r == col.r) && (g == col.g) && (b == col.b) && (a == col.a));
+  }
+  inline bool operator!=(const Colour &col)
+  {
+    return !operator==(col);
+  }
+  inline bool operator!()
+  {
+    return (!r && !g && !b && !a);
+  }
   unsigned char r;
   unsigned char g;
   unsigned char b;


More information about the Libreoffice-commits mailing list