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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Feb 5 09:36:28 UTC 2020


 src/lib/CDRParser.cpp |   41 ++++++++++++++---------------------------
 1 file changed, 14 insertions(+), 27 deletions(-)

New commits:
commit 0e746ed7ac28c2c1f4d480f52b6b7792ef1ce867
Author:     Fridrich Štrba <fridrich.strba at bluewin.ch>
AuthorDate: Wed Feb 5 10:22:08 2020 +0100
Commit:     Fridrich Štrba <fridrich.strba at bluewin.ch>
CommitDate: Wed Feb 5 10:22:08 2020 +0100

    Simplify the parseColourString function a bit
    
    Change-Id: I000c8ad4dfdaa7cc250687d542284585e2a903ea

diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp
index 1b2b4ab..51434d1 100644
--- a/src/lib/CDRParser.cpp
+++ b/src/lib/CDRParser.cpp
@@ -105,7 +105,7 @@ static void processNameForEncoding(librevenge::RVNGString &name, unsigned short
 static int parseColourString(const char *colourString, libcdr::CDRColor &colour, double &opacity)
 {
   using namespace boost::spirit::qi;
-  bool bRes = false;
+  bool bRes = true;
 
   boost::optional<unsigned> colourModel;
   std::vector<unsigned> val;
@@ -140,34 +140,21 @@ static int parseColourString(const char *colourString, libcdr::CDRColor &colour,
   if (colourModel)
     colour.m_colorModel = get(colourModel);
 
-  switch (colour.m_colorModel)
+  if (val.size() >= 5)
   {
-  case 5:
-    if (val.size() >= 4)
-    {
-      colour.m_colorValue = val[0] | (val[1] << 8) | (val[2] << 16);
-      opacity = (double)val[3] / 100.0;
-      break;
-    }
-    else
-    {
-      CDR_DEBUG_MSG(("parseColourString error: not enough values read: %lu\n", val.size()));
-      return 0;
-    }
-  default:
-    if (val.size() >= 5)
-    {
-      colour.m_colorValue = val[0] | (val[1] << 8) | (val[2] << 16) | (val[3] << 24);
-      opacity = (double)val[4] / 100.0;
-      break;
-    }
-    else
-    {
-      CDR_DEBUG_MSG(("parseColourString error: not enough values read: %lu\n", val.size()));
-      return 0;
-    }
+    colour.m_colorValue = val[0] | (val[1] << 8) | (val[2] << 16) | (val[3] << 24);
+    opacity = (double)val[4] / 100.0;
+    return 1;
   }
-  return 1;
+
+  if (val.size() >= 4)
+  {
+    colour.m_colorValue = val[0] | (val[1] << 8) | (val[2] << 16);
+    opacity = (double)val[3] / 100.0;
+    return 1;
+  }
+
+  return 0;
 }
 
 void normalizeAngle(double &angle)


More information about the Libreoffice-commits mailing list