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

Fridrich Å trba fridrich.strba at bluewin.ch
Thu Apr 3 16:49:22 PDT 2014


 src/lib/CDRCollector.cpp |   10 ++++++++++
 src/lib/CDRParser.cpp    |   23 ++++++++++++++++++-----
 2 files changed, 28 insertions(+), 5 deletions(-)

New commits:
commit f06333217ad55e841c4bd5b20b4eebbf7a9ce2f6
Author: Fridrich Å trba <fridrich.strba at bluewin.ch>
Date:   Fri Apr 4 01:48:47 2014 +0200

    Working around a CorelDraw x7 bug + fixing palettes
    
    Change-Id: I56ce7bfd3a49923cbf6e989687f02cdcf287eecb

diff --git a/src/lib/CDRCollector.cpp b/src/lib/CDRCollector.cpp
index 40456cf..01d318b 100644
--- a/src/lib/CDRCollector.cpp
+++ b/src/lib/CDRCollector.cpp
@@ -477,6 +477,16 @@ unsigned libcdr::CDRParserState::_getRGBColor(const CDRColor &color)
     blue = col0;
     break;
   }
+  // YIQ
+  case 0x0a:
+  {
+    break;
+  }
+  // YIQ255
+  case 0x0b:
+  {
+    break;
+  }
   // Lab
   case 0x0c:
   {
diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp
index 2c5d231..853c5e0 100644
--- a/src/lib/CDRParser.cpp
+++ b/src/lib/CDRParser.cpp
@@ -688,7 +688,9 @@ libcdr::CDRColor libcdr::CDRParser::readColor(librevenge::RVNGInputStream *input
   if (m_version >= 500)
   {
     colorModel = readU16(input);
-    if (colorModel == 0x19)
+    if (colorModel == 0x01 && m_version >= 1300)
+      colorModel = 0x19;
+    if (colorModel == 0x19 || colorModel == 0x1e)
     {
       unsigned char r = 0;
       unsigned char g = 0;
@@ -697,8 +699,19 @@ libcdr::CDRColor libcdr::CDRParser::readColor(librevenge::RVNGInputStream *input
       unsigned char m = 0;
       unsigned char y = 0;
       unsigned char k = 100;
-      unsigned short paletteID = readU16(input);
-      input->seek(4, librevenge::RVNG_SEEK_CUR);
+      unsigned short paletteID = 0;
+      /* A bug in CorelDraw x7 creates a corrupted file. If we meet colorModel of 0x1e,
+       * it is actually colorModel 0x19 and paletteId 0x1e */
+      if (colorModel == 0x1e)
+      {
+        colorModel = 0x19;
+        paletteID = 0x1e;
+      }
+      else
+      {
+        paletteID = readU16(input);
+        input->seek(4, librevenge::RVNG_SEEK_CUR);
+      }
       unsigned short ix = readU16(input);
       unsigned short tint = readU16(input);
       switch (paletteID)
@@ -1018,11 +1031,11 @@ libcdr::CDRColor libcdr::CDRParser::readColor(librevenge::RVNGInputStream *input
         red /= 100;
         green /= 100;
         blue /= 100;
-        colorValue = (blue & 0xff);
+        colorValue = (red & 0xff);
         colorValue <<= 8;
         colorValue |= (green & 0xff);
         colorValue <<= 8;
-        colorValue |= (red & 0xff);
+        colorValue |= (blue & 0xff);
         break;
       }
       case 0x09:


More information about the Libreoffice-commits mailing list