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

Fridrich Å trba fridrich.strba at bluewin.ch
Sat Jun 29 13:19:42 PDT 2013


 src/lib/CDRCollector.h          |    2 +-
 src/lib/CDRContentCollector.cpp |    4 ++--
 src/lib/CDRContentCollector.h   |    2 +-
 src/lib/CDRParser.cpp           |   28 ++++++++++++++++++++++------
 src/lib/CDRParser.h             |    1 +
 src/lib/CDRPath.cpp             |   14 ++++++++++++++
 src/lib/CDRPath.h               |    8 +++-----
 src/lib/CDRStylesCollector.h    |    2 +-
 src/lib/CDRTypes.h              |   12 ++++++------
 9 files changed, 51 insertions(+), 22 deletions(-)

New commits:
commit a15af9bca619989202c73d9d5ea436c0ac89294f
Author: Fridrich Å trba <fridrich.strba at bluewin.ch>
Date:   Sat Jun 29 22:19:17 2013 +0200

    Get the arrow information to the collector

diff --git a/src/lib/CDRCollector.h b/src/lib/CDRCollector.h
index 47aa00e..c26307b 100644
--- a/src/lib/CDRCollector.h
+++ b/src/lib/CDRCollector.h
@@ -94,7 +94,7 @@ public:
   virtual void collectFillStyle(unsigned short fillType, const CDRColor &color1, const CDRColor &color2, const CDRGradient &gradient, const CDRImageFill &imageFill) = 0;
   virtual void collectLineStyle(unsigned short lineType, unsigned short capsType, unsigned short joinType, double lineWidth,
                                 double stretch, double angle, const CDRColor &color, const std::vector<unsigned> &dashArray,
-                                unsigned startMarkerId, unsigned endMarkerId) = 0;
+                                const CDRPath &startMarker, const CDRPath &endMarker) = 0;
   virtual void collectRotate(double angle, double cx, double cy) = 0;
   virtual void collectFlags(unsigned flags, bool considerFlags) = 0;
   virtual void collectPageSize(double width, double height, double offsetX, double offsetY) = 0;
diff --git a/src/lib/CDRContentCollector.cpp b/src/lib/CDRContentCollector.cpp
index dd0b495..ee82c3a 100644
--- a/src/lib/CDRContentCollector.cpp
+++ b/src/lib/CDRContentCollector.cpp
@@ -569,9 +569,9 @@ void libcdr::CDRContentCollector::collectFillStyle(unsigned short fillType, cons
 
 void libcdr::CDRContentCollector::collectLineStyle(unsigned short lineType, unsigned short capsType, unsigned short joinType, double lineWidth,
     double stretch, double angle, const CDRColor &color, const std::vector<unsigned> &dashArray,
-    unsigned startMarkerId, unsigned endMarkerId)
+    const CDRPath &startMarker, const CDRPath &endMarker)
 {
-  m_currentLineStyle = CDRLineStyle(lineType, capsType, joinType, lineWidth, stretch, angle, color, dashArray, startMarkerId, endMarkerId);
+  m_currentLineStyle = CDRLineStyle(lineType, capsType, joinType, lineWidth, stretch, angle, color, dashArray, startMarker, endMarker);
 }
 
 void libcdr::CDRContentCollector::collectRotate(double angle, double cx, double cy)
diff --git a/src/lib/CDRContentCollector.h b/src/lib/CDRContentCollector.h
index 47f56aa..f65fb11 100644
--- a/src/lib/CDRContentCollector.h
+++ b/src/lib/CDRContentCollector.h
@@ -61,7 +61,7 @@ public:
   void collectFillStyle(unsigned short fillType, const CDRColor &color1, const CDRColor &color2, const CDRGradient &gradient, const CDRImageFill &imageFill);
   void collectLineStyle(unsigned short lineType, unsigned short capsType, unsigned short joinType, double lineWidth,
                         double stretch, double angle, const CDRColor &color, const std::vector<unsigned> &dashArray,
-                        unsigned startMarkerId, unsigned endMarkerId);
+                        const CDRPath &startMarker, const CDRPath &endMarker);
   void collectRotate(double angle, double cx, double cy);
   void collectFlags(unsigned flags, bool considerFlags);
   void collectPageSize(double, double, double, double) {}
diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp
index bff872b..c9bab09 100644
--- a/src/lib/CDRParser.cpp
+++ b/src/lib/CDRParser.cpp
@@ -254,7 +254,7 @@ static void _readX6StyleString(WPXInputStream *input, unsigned length, libcdr::C
 
 libcdr::CDRParser::CDRParser(const std::vector<WPXInputStream *> &externalStreams, libcdr::CDRCollector *collector)
   : CommonParser(collector), m_externalStreams(externalStreams),
-    m_fonts(), m_fillStyles(), m_lineStyles(), m_version(0) {}
+    m_fonts(), m_fillStyles(), m_lineStyles(), m_arrows(), m_version(0) {}
 
 libcdr::CDRParser::~CDRParser()
 {
@@ -1488,8 +1488,7 @@ void libcdr::CDRParser::readArrw(WPXInputStream *input, unsigned length)
   CDR_DEBUG_MSG(("CDRParser::readArrw\n"));
   if (!_redirectX6Chunk(&input, length))
     throw GenericException();
-  /* unsigned arrowId = */
-  readU32(input);
+  unsigned arrowId = readU32(input);
   input->seek(4, WPX_SEEK_CUR);
   unsigned short pointNum = readU16(input);
   input->seek(4, WPX_SEEK_CUR);
@@ -1506,6 +1505,7 @@ void libcdr::CDRParser::readArrw(WPXInputStream *input, unsigned length)
     pointTypes.push_back(readU8(input));
   CDRPath path;
   processPath(points, pointTypes, path);
+  m_arrows[arrowId] = path;
 }
 
 void libcdr::CDRParser::readBitmap(WPXInputStream *input)
@@ -1591,8 +1591,16 @@ void libcdr::CDRParser::readWaldoOutl(WPXInputStream *input)
   unsigned short joinType = readU16(input);
   unsigned short capsType = readU16(input);
   unsigned startMarkerId = readU32(input);
+  std::map<unsigned, CDRPath>::const_iterator iter = m_arrows.find(startMarkerId);
+  CDRPath startMarker;
+  if (iter != m_arrows.end())
+    startMarker = iter->second;
   unsigned endMarkerId = readU32(input);
-  m_collector->collectLineStyle(lineType, capsType, joinType, lineWidth, stretch, angle, color, dashArray, startMarkerId, endMarkerId);
+  iter = m_arrows.find(endMarkerId);
+  CDRPath endMarker;
+  if (iter != m_arrows.end())
+    endMarker = iter->second;
+  m_collector->collectLineStyle(lineType, capsType, joinType, lineWidth, stretch, angle, color, dashArray, startMarker, endMarker);
 }
 
 void libcdr::CDRParser::readWaldoFill(WPXInputStream *input)
@@ -2083,8 +2091,16 @@ void libcdr::CDRParser::readOutl(WPXInputStream *input, unsigned length)
   else
     input->seek(fixPosition + 22, WPX_SEEK_SET);
   unsigned startMarkerId = readU32(input);
+  std::map<unsigned, CDRPath>::const_iterator iter = m_arrows.find(startMarkerId);
+  CDRPath startMarker;
+  if (iter != m_arrows.end())
+    startMarker = iter->second;
   unsigned endMarkerId = readU32(input);
-  m_lineStyles[lineId] = CDRLineStyle(lineType, capsType, joinType, lineWidth, stretch, angle, color, dashArray, startMarkerId, endMarkerId);
+  iter = m_arrows.find(endMarkerId);
+  CDRPath endMarker;
+  if (iter != m_arrows.end())
+    endMarker = iter->second;
+  m_lineStyles[lineId] = CDRLineStyle(lineType, capsType, joinType, lineWidth, stretch, angle, color, dashArray, startMarker, endMarker);
 }
 
 void libcdr::CDRParser::readLoda(WPXInputStream *input, unsigned length)
@@ -2155,7 +2171,7 @@ void libcdr::CDRParser::readLoda(WPXInputStream *input, unsigned length)
         if (iter != m_lineStyles.end())
           m_collector->collectLineStyle(iter->second.lineType, iter->second.capsType, iter->second.joinType, iter->second.lineWidth,
                                         iter->second.stretch, iter->second.angle, iter->second.color, iter->second.dashArray,
-                                        iter->second.startMarkerId, iter->second.endMarkerId);
+                                        iter->second.startMarker, iter->second.endMarker);
       }
     }
     else if (argTypes[i] == 0x2af8)
diff --git a/src/lib/CDRParser.h b/src/lib/CDRParser.h
index 64f4b43..7b159f1 100644
--- a/src/lib/CDRParser.h
+++ b/src/lib/CDRParser.h
@@ -119,6 +119,7 @@ private:
   std::map<unsigned, CDRFont> m_fonts;
   std::map<unsigned, CDRFillStyle> m_fillStyles;
   std::map<unsigned, CDRLineStyle> m_lineStyles;
+  std::map<unsigned, CDRPath> m_arrows;
 
   unsigned m_version;
 
diff --git a/src/lib/CDRPath.cpp b/src/lib/CDRPath.cpp
index b7d42f2..2d3e0b5 100644
--- a/src/lib/CDRPath.cpp
+++ b/src/lib/CDRPath.cpp
@@ -29,6 +29,7 @@
 
 #include <math.h>
 #include "CDRPath.h"
+#include "CDRTypes.h"
 
 #ifndef M_PI
 #define M_PI 3.14159265358979323846
@@ -406,6 +407,19 @@ libcdr::CDRPath::CDRPath(const libcdr::CDRPath &path) : m_elements(), m_isClosed
   m_isClosed = path.isClosed();
 }
 
+libcdr::CDRPath &libcdr::CDRPath::operator=(const libcdr::CDRPath &path)
+{
+  // Check for self-assignment
+  if (this == &path)
+    return *this;
+  clear();
+  for (std::vector<CDRPathElement *>::const_iterator iter = path.m_elements.begin(); iter != path.m_elements.end(); ++iter)
+    m_elements.push_back((*iter)->clone());
+  m_isClosed = path.isClosed();
+  return *this;
+}
+
+
 libcdr::CDRPath::~CDRPath()
 {
   clear();
diff --git a/src/lib/CDRPath.h b/src/lib/CDRPath.h
index 44c1071..ccff6d2 100644
--- a/src/lib/CDRPath.h
+++ b/src/lib/CDRPath.h
@@ -33,12 +33,11 @@
 #include <vector>
 #include <libwpd/libwpd.h>
 
-#include "CDRTypes.h"
-
 namespace libcdr
 {
 
 class CDRTransform;
+class CDRTransforms;
 
 class CDRPathElement
 {
@@ -59,6 +58,8 @@ public:
   CDRPath(const CDRPath &path);
   ~CDRPath();
 
+  CDRPath &operator=(const CDRPath &path);
+
   void appendMoveTo(double x, double y);
   void appendLineTo(double x, double y);
   void appendCubicBezierTo(double x1, double y1, double x2, double y2, double x, double y);
@@ -78,9 +79,6 @@ public:
   bool isClosed() const;
 
 private:
-  CDRPath &operator=(const CDRPath &path);
-
-private:
   std::vector<CDRPathElement *> m_elements;
   bool m_isClosed;
 };
diff --git a/src/lib/CDRStylesCollector.h b/src/lib/CDRStylesCollector.h
index d037931..d206a4d 100644
--- a/src/lib/CDRStylesCollector.h
+++ b/src/lib/CDRStylesCollector.h
@@ -61,7 +61,7 @@ public:
   void collectTransform(const CDRTransforms &, bool) {}
   void collectFillStyle(unsigned short, const CDRColor &, const CDRColor &, const CDRGradient &, const CDRImageFill &) {}
   void collectLineStyle(unsigned short, unsigned short, unsigned short, double, double, double, const CDRColor &,
-                        const std::vector<unsigned> &, unsigned, unsigned) {}
+                        const std::vector<unsigned> &, const CDRPath &, const CDRPath &) {}
   void collectRotate(double,double,double) {}
   void collectFlags(unsigned, bool) {}
   void collectPageSize(double width, double height, double offsetX, double offsetY);
diff --git a/src/lib/CDRTypes.h b/src/lib/CDRTypes.h
index 6b1228b..9790338 100644
--- a/src/lib/CDRTypes.h
+++ b/src/lib/CDRTypes.h
@@ -33,11 +33,11 @@
 #include <math.h>
 #include <libwpd/libwpd.h>
 #include "CDRTransforms.h"
+#include "CDRPath.h"
 #include "libcdr_utils.h"
 
 namespace libcdr
 {
-class CDRPath;
 
 struct CDRBox
 {
@@ -138,18 +138,18 @@ struct CDRLineStyle
   double angle;
   CDRColor color;
   std::vector<unsigned> dashArray;
-  unsigned startMarkerId;
-  unsigned endMarkerId;
+  CDRPath startMarker;
+  CDRPath endMarker;
   CDRLineStyle()
     : lineType((unsigned short)-1), capsType(0), joinType(0), lineWidth(0.0),
       stretch(0.0), angle(0.0), color(), dashArray(),
-      startMarkerId(0), endMarkerId(0) {}
+      startMarker(), endMarker() {}
   CDRLineStyle(unsigned short lt, unsigned short ct, unsigned short jt,
                double lw, double st, double a, const CDRColor &c, const std::vector<unsigned> &da,
-               unsigned smi, unsigned emi)
+               const CDRPath &sm, const CDRPath &em)
     : lineType(lt), capsType(ct), joinType(jt), lineWidth(lw),
       stretch(st), angle(a), color(c), dashArray(da),
-      startMarkerId(smi), endMarkerId(emi) {}
+      startMarker(sm), endMarker(em) {}
 };
 
 struct CDRCharacterStyle


More information about the Libreoffice-commits mailing list