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

Fridrich Štrba fridrich.strba at bluewin.ch
Wed Jul 20 09:15:00 UTC 2016


 src/conv/raw/cdr2raw.cpp   |   13 ++++++++++---
 src/conv/raw/cmx2raw.cpp   |   13 ++++++++++---
 src/conv/svg/cdr2xhtml.cpp |   18 ++++++++++++++----
 src/conv/svg/cmx2xhtml.cpp |   18 ++++++++++++++----
 src/conv/text/cdr2text.cpp |   17 +++++++++++++----
 src/conv/text/cmx2text.cpp |   21 +++++++++++++++------
 src/lib/CMXParser.cpp      |   26 +++++---------------------
 7 files changed, 81 insertions(+), 45 deletions(-)

New commits:
commit 3eb9b6eb8e9855661eb505ffeb29cd7860ed5b9d
Author: Fridrich Štrba <fridrich.strba at bluewin.ch>
Date:   Wed Jul 20 11:14:36 2016 +0200

    Full-Color and Imported Bitmap have similar structure
    
    Change-Id: I989bdc58eb88ce68e7fc3a64ddb7d3d46572b7ac

diff --git a/src/lib/CMXParser.cpp b/src/lib/CMXParser.cpp
index 4f04ca3..b4fbee5 100644
--- a/src/lib/CMXParser.cpp
+++ b/src/lib/CMXParser.cpp
@@ -1232,6 +1232,7 @@ bool libcdr::CMXParser::readFill(librevenge::RVNGInputStream *input)
     }
     break;
   case 9: // Imported Bitmap
+  case 10: // Full Color Pattern
     if (m_precision == libcdr::PRECISION_32BIT)
     {
       unsigned char tagId = 0;
@@ -1242,11 +1243,11 @@ bool libcdr::CMXParser::readFill(librevenge::RVNGInputStream *input)
         tagId = readU8(input, m_bigEndian);
         if (tagId == CMX_Tag_EndTag)
         {
-          CDR_DEBUG_MSG(("    Imported Bitmap fill - tagId %i\n", tagId));
+          CDR_DEBUG_MSG(("    %s fill - tagId %i\n", fillType == 9 ? "Imported Bitmap" : "Full Color Pattern", tagId));
           break;
         }
         tagLength = readU16(input, m_bigEndian);
-        CDR_DEBUG_MSG(("    Imported Bitmap fill - tagId %i, tagLength %u\n", tagId, tagLength));
+        CDR_DEBUG_MSG(("    %s fill - tagId %i, tagLength %u\n", fillType == 9 ? "Imported Bitmap" : "Full Color Pattern", tagId, tagLength));
         switch (tagId)
         {
         case CMX_Tag_RenderAttr_FillSpec_ColorBM:
@@ -1282,7 +1283,7 @@ bool libcdr::CMXParser::readFill(librevenge::RVNGInputStream *input)
     }
     else if (m_precision == libcdr::PRECISION_16BIT)
     {
-      CDR_DEBUG_MSG(("    Imported Bitmap fill\n"));
+      CDR_DEBUG_MSG(("    %s fill\n", fillType == 9 ? "Imported Bitmap" : "Full Color Pattern"));
       unsigned short patternId = readU16(input, m_bigEndian);
       int tmpWidth = readU16(input, m_bigEndian);
       int tmpHeight = readU16(input, m_bigEndian);
@@ -1303,23 +1304,6 @@ bool libcdr::CMXParser::readFill(librevenge::RVNGInputStream *input)
       imageFill = libcdr::CDRImageFill(patternId, patternWidth, patternHeight, isRelative, tileOffsetX, tileOffsetY, rcpOffset, flags);
     }
     break;
-  case 10:
-    CDR_DEBUG_MSG(("    Full-Color Pattern fill\n"));
-    if (m_precision == libcdr::PRECISION_32BIT)
-    {
-    }
-    else if (m_precision == libcdr::PRECISION_16BIT)
-    {
-      /* unsigned short pattern = */ readU16(input, m_bigEndian);
-      /* unsigned short width = */ readU16(input, m_bigEndian);
-      /* unsigned short height = */ readU16(input, m_bigEndian);
-      /* unsigned short xoff = */ readU16(input, m_bigEndian);
-      /* unsigned short yoff = */ readU16(input, m_bigEndian);
-      /* unsigned short inter = */ readU16(input, m_bigEndian);
-      /* unsigned short flags = */ readU16(input, m_bigEndian);
-      /* libcdr::CDRBox box = */ readBBox(input);
-    }
-    break;
   case 11:
     if (m_precision == libcdr::PRECISION_32BIT)
     {
@@ -2045,7 +2029,7 @@ void libcdr::CMXParser::readIxpc(librevenge::RVNGInputStream *input)
     {
       long oldOffset = input->tell();
       input->seek(procOffset, librevenge::RVNG_SEEK_SET);
-      m_collector->collectVect(1);
+      m_collector->collectVect(0);
       m_collector->collectSpnd(j);
       readProc(input);
       input->seek(oldOffset, librevenge::RVNG_SEEK_SET);
commit f568a1a6ecab5200f9c7443887dc7fb623beb060
Author: Fridrich Štrba <fridrich.strba at bluewin.ch>
Date:   Wed Jul 20 11:14:01 2016 +0200

    let the cmx2* and cdr2* handle both cdr and cmx
    
    Change-Id: I55d0cc0eeadd59a65d1141d9c9b7e14279072c7f

diff --git a/src/conv/raw/cdr2raw.cpp b/src/conv/raw/cdr2raw.cpp
index c5217ba..bd464ff 100644
--- a/src/conv/raw/cdr2raw.cpp
+++ b/src/conv/raw/cdr2raw.cpp
@@ -72,14 +72,21 @@ int main(int argc, char *argv[])
     return printUsage();
 
   librevenge::RVNGFileStream input(file);
+  librevenge::RVNGRawDrawingGenerator painter(printIndentLevel);
 
   if (!libcdr::CDRDocument::isSupported(&input))
   {
-    fprintf(stderr, "ERROR: Unsupported file format!\n");
-    return 1;
+    if (!libcdr::CMXDocument::isSupported(&input))
+    {
+      fprintf(stderr, "ERROR: Unsupported file format!\n");
+      return 1;
+    }
+
+    libcdr::CMXDocument::parse(&input, &painter);
+
+    return 0;
   }
 
-  librevenge::RVNGRawDrawingGenerator painter(printIndentLevel);
   libcdr::CDRDocument::parse(&input, &painter);
 
   return 0;
diff --git a/src/conv/raw/cmx2raw.cpp b/src/conv/raw/cmx2raw.cpp
index 62223cf..4ae0bf8 100644
--- a/src/conv/raw/cmx2raw.cpp
+++ b/src/conv/raw/cmx2raw.cpp
@@ -72,14 +72,21 @@ int main(int argc, char *argv[])
     return printUsage();
 
   librevenge::RVNGFileStream input(file);
+  librevenge::RVNGRawDrawingGenerator painter(printIndentLevel);
 
   if (!libcdr::CMXDocument::isSupported(&input))
   {
-    fprintf(stderr, "ERROR: Unsupported file format!\n");
-    return 1;
+    if (!libcdr::CDRDocument::isSupported(&input))
+    {
+      fprintf(stderr, "ERROR: Unsupported file format!\n");
+      return 1;
+    }
+
+    libcdr::CDRDocument::parse(&input, &painter);
+
+    return 0;
   }
 
-  librevenge::RVNGRawDrawingGenerator painter(printIndentLevel);
   libcdr::CMXDocument::parse(&input, &painter);
 
   return 0;
diff --git a/src/conv/svg/cdr2xhtml.cpp b/src/conv/svg/cdr2xhtml.cpp
index 082926f..c918e94 100644
--- a/src/conv/svg/cdr2xhtml.cpp
+++ b/src/conv/svg/cdr2xhtml.cpp
@@ -70,20 +70,30 @@ int main(int argc, char *argv[])
     return printUsage();
 
   librevenge::RVNGFileStream input(file);
+  librevenge::RVNGStringVector output;
+  librevenge::RVNGSVGDrawingGenerator generator(output, "svg");
 
   if (!libcdr::CDRDocument::isSupported(&input))
   {
-    std::cerr << "ERROR: Unsupported file format!" << std::endl;
-    return 1;
+    if (!libcdr::CMXDocument::isSupported(&input))
+    {
+      std::cerr << "ERROR: Unsupported file format!" << std::endl;
+      return 1;
+    }
+
+    if (!libcdr::CMXDocument::parse(&input, &generator))
+    {
+      std::cerr << "ERROR: SVG Generation failed!" << std::endl;
+      return 1;
+    }
   }
 
-  librevenge::RVNGStringVector output;
-  librevenge::RVNGSVGDrawingGenerator generator(output, "svg");
   if (!libcdr::CDRDocument::parse(&input, &generator))
   {
     std::cerr << "ERROR: SVG Generation failed!" << std::endl;
     return 1;
   }
+
   if (output.empty())
   {
     std::cerr << "ERROR: No SVG document generated!" << std::endl;
diff --git a/src/conv/svg/cmx2xhtml.cpp b/src/conv/svg/cmx2xhtml.cpp
index 524bd63..a399175 100644
--- a/src/conv/svg/cmx2xhtml.cpp
+++ b/src/conv/svg/cmx2xhtml.cpp
@@ -70,20 +70,30 @@ int main(int argc, char *argv[])
     return printUsage();
 
   librevenge::RVNGFileStream input(file);
+  librevenge::RVNGStringVector output;
+  librevenge::RVNGSVGDrawingGenerator generator(output, "svg");
 
   if (!libcdr::CMXDocument::isSupported(&input))
   {
-    std::cerr << "ERROR: Unsupported file format!" << std::endl;
-    return 1;
+    if (!libcdr::CDRDocument::isSupported(&input))
+    {
+      std::cerr << "ERROR: Unsupported file format!" << std::endl;
+      return 1;
+    }
+
+    if (!libcdr::CDRDocument::parse(&input, &generator))
+    {
+      std::cerr << "ERROR: SVG Generation failed!" << std::endl;
+      return 1;
+    }
   }
 
-  librevenge::RVNGStringVector output;
-  librevenge::RVNGSVGDrawingGenerator generator(output, "svg");
   if (!libcdr::CMXDocument::parse(&input, &generator))
   {
     std::cerr << "ERROR: SVG Generation failed!" << std::endl;
     return 1;
   }
+
   if (output.empty())
   {
     std::cerr << "ERROR: No SVG document generated!" << std::endl;
diff --git a/src/conv/text/cdr2text.cpp b/src/conv/text/cdr2text.cpp
index f8a5b41..f2ff22b 100644
--- a/src/conv/text/cdr2text.cpp
+++ b/src/conv/text/cdr2text.cpp
@@ -69,15 +69,24 @@ int main(int argc, char *argv[])
     return printUsage();
 
   librevenge::RVNGFileStream input(file);
+  librevenge::RVNGStringVector pages;
+  librevenge::RVNGTextDrawingGenerator painter(pages);
 
   if (!libcdr::CDRDocument::isSupported(&input))
   {
-    fprintf(stderr, "ERROR: Unsupported file format (unsupported version) or file is encrypted!\n");
-    return 1;
+    if (!libcdr::CMXDocument::isSupported(&input))
+    {
+      fprintf(stderr, "ERROR: Unsupported file format (unsupported version) or file is encrypted!\n");
+      return 1;
+    }
+
+    if (!libcdr::CMXDocument::parse(&input, &painter))
+    {
+      fprintf(stderr, "ERROR: Parsing of document failed!\n");
+      return 1;
+    }
   }
 
-  librevenge::RVNGStringVector pages;
-  librevenge::RVNGTextDrawingGenerator painter(pages);
   if (!libcdr::CDRDocument::parse(&input, &painter))
   {
     fprintf(stderr, "ERROR: Parsing of document failed!\n");
diff --git a/src/conv/text/cmx2text.cpp b/src/conv/text/cmx2text.cpp
index 1fa595e..a06da46 100644
--- a/src/conv/text/cmx2text.cpp
+++ b/src/conv/text/cmx2text.cpp
@@ -68,16 +68,25 @@ int main(int argc, char *argv[])
     return printUsage();
 
   librevenge::RVNGFileStream input(file);
+  librevenge::RVNGStringVector pages;
+  librevenge::RVNGTextDrawingGenerator painter(pages);
 
-  if (!libcdr::CDRDocument::isSupported(&input))
+  if (!libcdr::CMXDocument::isSupported(&input))
   {
-    fprintf(stderr, "ERROR: Unsupported file format (unsupported version) or file is encrypted!\n");
-    return 1;
+    if (!libcdr::CDRDocument::isSupported(&input))
+    {
+      fprintf(stderr, "ERROR: Unsupported file format (unsupported version) or file is encrypted!\n");
+      return 1;
+    }
+
+    if (!libcdr::CDRDocument::parse(&input, &painter))
+    {
+      fprintf(stderr, "ERROR: Parsing of document failed!\n");
+      return 1;
+    }
   }
 
-  librevenge::RVNGStringVector pages;
-  librevenge::RVNGTextDrawingGenerator painter(pages);
-  if (!libcdr::CDRDocument::parse(&input, &painter))
+  if (!libcdr::CMXDocument::parse(&input, &painter))
   {
     fprintf(stderr, "ERROR: Parsing of document failed!\n");
     return 1;


More information about the Libreoffice-commits mailing list