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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sun Feb 9 15:48:12 UTC 2020


 src/lib/CDRParser.cpp |   35 +++++++++++++++++++++++------------
 1 file changed, 23 insertions(+), 12 deletions(-)

New commits:
commit a44d6bc1e586e3035431bdf68a53cf0b3f5c7579
Author:     Fridrich Štrba <fridrich.strba at bluewin.ch>
AuthorDate: Sun Feb 9 16:47:46 2020 +0100
Commit:     Fridrich Štrba <fridrich.strba at bluewin.ch>
CommitDate: Sun Feb 9 16:47:46 2020 +0100

    Some progress of reading palettes in x16+ text colours
    
    Change-Id: I6d08021d222b21c43cd0f29a1ed8d4aad21a45a5

diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp
index 1cac4d5..8d6ddba 100644
--- a/src/lib/CDRParser.cpp
+++ b/src/lib/CDRParser.cpp
@@ -105,9 +105,10 @@ 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 = true;
+  bool bRes = false;
 
-  boost::optional<unsigned> colourModel;
+  boost::optional<unsigned> colourModel, colourPalette;
+  std::vector<char> rest;
   std::vector<unsigned> val;
 
   if (colourString)
@@ -125,24 +126,31 @@ static int parseColourString(const char *colourString, libcdr::CDRColor &colour,
     ("REGCOLOR", 20)
     ("SPOT", 25)
     ;
+    symbols<char, unsigned> cpalette;
+    cpalette.add
+    ("USER", 5)
+    ("FOCTONE", 8)
+    ;
     auto it = colourString;
     const auto end = it + std::strlen(it);
     bRes = phrase_parse(it, end,
                         //  Begin grammar
                         (
                           (cmodel | omit[+alnum]) >> lit(',')
-                          >> omit[+alnum] >> lit(',')
+                          >> (cpalette | omit[+alnum]) >> lit(',')
                           >> *(uint_ >> lit(','))
-                          >> (repeat(8)[xdigit] >> '-' >> repeat(3)[repeat(4)[xdigit] >> '-'] >> repeat(12)[xdigit])
+                          >> omit[(repeat(8)[xdigit] >> '-' >> repeat(3)[repeat(4)[xdigit] >> '-'] >> repeat(12)[xdigit])]
+                          >> -(lit(',') >> *char_)
                         ),
                         //  End grammar
                         space,
-                        colourModel, val)
+                        colourModel, colourPalette, val, rest)
            && it == end;
   }
+  rest.push_back(0);
 
-  // if (bRes)
-  //  return -1;
+  if (!bRes)
+    return -1;
 
   if (colourModel)
     colour.m_colorModel = get(colourModel);
@@ -164,8 +172,13 @@ static int parseColourString(const char *colourString, libcdr::CDRColor &colour,
   }
   else if (val.size() >= 2)
   {
-    colour.m_colorValue = val[0];
-    opacity = (double)val[1] / 100.0;
+    if (colour.m_colorModel == 25)
+      colour.m_colorValue = (val[1] << 16) | val[0];
+    else
+    {
+      colour.m_colorValue = val[0];
+      opacity = (double)val[1] / 100.0;
+    }
   }
   else if (val.size() >= 1)
   {
@@ -1018,9 +1031,7 @@ libcdr::CDRColor libcdr::CDRParser::readColor(librevenge::RVNGInputStream *input
         }
         break;
       default:
-        colorValue = tint;
-        colorValue <<= 16;
-        colorValue |= ix;
+        colorValue = (tint << 16) | ix;
         break;
       }
 


More information about the Libreoffice-commits mailing list