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

Fridrich Štrba fridrich.strba at bluewin.ch
Sat Jul 2 16:57:59 UTC 2016


 src/lib/CMXParser.cpp |   57 +++++++++++++++++++++++++++++++++++++++++++++-----
 src/lib/CMXParser.h   |   31 +++++++++++++++++++++++++--
 2 files changed, 81 insertions(+), 7 deletions(-)

New commits:
commit 190f8ba5f6373381f667f680ec457712682288d2
Author: Fridrich Štrba <fridrich.strba at bluewin.ch>
Date:   Sat Jul 2 18:57:32 2016 +0200

    rpen reader
    
    Change-Id: Ibba0239f8fdcd1a8728b7c0acfa69405a7270347

diff --git a/src/lib/CMXParser.cpp b/src/lib/CMXParser.cpp
index 371b746..3ac725b 100644
--- a/src/lib/CMXParser.cpp
+++ b/src/lib/CMXParser.cpp
@@ -133,6 +133,9 @@ void libcdr::CMXParser::readRecord(unsigned fourCC, unsigned &length, librevenge
   case CDR_FOURCC_rott:
     readRott(input);
     break;
+  case CDR_FOURCC_rpen:
+    readRpen(input);
+    break;
   default:
     break;
   }
@@ -616,9 +619,7 @@ libcdr::CDRTransform libcdr::CMXParser::readMatrix(librevenge::RVNGInputStream *
 {
   CDRTransform matrix;
   unsigned short type = readU16(input, m_bigEndian);
-  switch (type)
-  {
-  case 2: // general matrix
+  if (type > 1)
   {
     double v0 = readDouble(input, m_bigEndian);
     double v3 = readDouble(input, m_bigEndian);
@@ -628,9 +629,8 @@ libcdr::CDRTransform libcdr::CMXParser::readMatrix(librevenge::RVNGInputStream *
     double y0 = readDouble(input, m_bigEndian);
     return libcdr::CDRTransform(v0, v1, x0, v3, v4, y0);
   }
-  default: // identity matrix for the while
+  else
     return matrix;
-  }
 }
 
 libcdr::CDRBox libcdr::CMXParser::readBBox(librevenge::RVNGInputStream *input)
@@ -1237,6 +1237,53 @@ void libcdr::CMXParser::readRott(librevenge::RVNGInputStream *input)
   }
 }
 
+void libcdr::CMXParser::readRpen(librevenge::RVNGInputStream *input)
+{
+  unsigned numRecords = readU16(input, m_bigEndian);
+  CDR_DEBUG_MSG(("CMXParser::readRpen - numRecords %i\n", numRecords));
+  for (unsigned j = 1; j < numRecords+1; ++j)
+  {
+    CMXPen pen;
+    if (m_precision == libcdr::PRECISION_32BIT)
+    {
+      unsigned char tagId = 0;
+      do
+      {
+        long offset = input->tell();
+        tagId = readU8(input, m_bigEndian);
+        if (tagId == CMX_Tag_EndTag)
+          break;
+        unsigned short tagLength = readU16(input, m_bigEndian);
+        switch (tagId)
+        {
+        case CMX_Tag_DescrSection_Pen:
+        {
+          pen.m_width = readCoordinate(input);
+          pen.m_aspect = readU16(input, m_bigEndian);
+          pen.m_angle = readAngle(input);
+          pen.m_matrix = readMatrix(input);
+          break;
+        }
+        default:
+          break;
+        }
+        input->seek(offset+tagLength, librevenge::RVNG_SEEK_SET);
+      }
+      while (tagId != CMX_Tag_EndTag);
+    }
+    else if (m_precision == libcdr::PRECISION_16BIT)
+    {
+      pen.m_width = readCoordinate(input);
+      pen.m_aspect = readU16(input, m_bigEndian);
+      pen.m_angle = readAngle(input);
+      pen.m_matrix = readMatrix(input);
+    }
+    else
+      return;
+    m_parserState.m_pens[j] = pen;
+  }
+}
+
 libcdr::CDRColor libcdr::CMXParser::getPaletteColor(unsigned id)
 {
   const std::map<unsigned, libcdr::CDRColor>::const_iterator iter = m_parserState.m_colorPalette.find(id);
diff --git a/src/lib/CMXParser.h b/src/lib/CMXParser.h
index b713fbb..48bc4e4 100644
--- a/src/lib/CMXParser.h
+++ b/src/lib/CMXParser.h
@@ -23,9 +23,32 @@ namespace libcdr
 
 class CDRCollector;
 
+struct CMXOutline
+{
+  CMXOutline()
+    : m_lineStyle(0), m_screen(0), m_color(0),
+      m_arrowHeads(0), m_pen(0), m_dotDash(0) {}
+  unsigned short m_lineStyle;
+  unsigned short m_screen;
+  unsigned short m_color;
+  unsigned short m_arrowHeads;
+  unsigned short m_pen;
+  unsigned short m_dotDash;
+};
+
+struct CMXPen
+{
+  CMXPen()
+    : m_width(0.0), m_aspect(100), m_angle(0.0), m_matrix() {}
+  double m_width;
+  unsigned short m_aspect;
+  double m_angle;
+  CDRTransform m_matrix;
+};
+
 struct CMXLineStyle
 {
-  CMXLineStyle() : m_spec(0), M_capAndJoin(0) {}
+  CMXLineStyle() : m_spec(0), m_capAndJoin(0) {}
   unsigned char m_spec;
   unsigned char m_capAndJoin;
 };
@@ -33,10 +56,13 @@ struct CMXLineStyle
 struct CMXParserState
 {
   CMXParserState()
-    : m_colorPalette(), m_dashArrays(), m_lineStyles() {}
+    : m_colorPalette(), m_dashArrays(), m_lineStyles(),
+      m_pens(), m_outlines() {}
   std::map<unsigned, CDRColor> m_colorPalette;
   std::map<unsigned, std::vector<unsigned> > m_dashArrays;
   std::map<unsigned, CMXLineStyle> m_lineStyles;
+  std::map<unsigned, CMXPen> m_pens;
+  std::map<unsigned, CMXOutline> m_outlines;
 };
 
 class CMXParser : protected CommonParser
@@ -60,6 +86,7 @@ private:
   void readRclr(librevenge::RVNGInputStream *input);
   void readRott(librevenge::RVNGInputStream *input);
   void readRdot(librevenge::RVNGInputStream *input);
+  void readRpen(librevenge::RVNGInputStream *input);
 
   // Command readers
   void readBeginPage(librevenge::RVNGInputStream *input);


More information about the Libreoffice-commits mailing list