src/lib/CDRCollector.h | 1 + src/lib/CDRContentCollector.cpp | 6 ++++++ src/lib/CDRContentCollector.h | 1 + src/lib/CDRParser.cpp | 26 ++++++++++++++++++++++++++ src/lib/CDRParser.h | 1 + src/lib/CDRStylesCollector.h | 1 + src/lib/CommonParser.cpp | 24 ++++++++++++++++-------- src/lib/CommonParser.h | 2 ++ 8 files changed, 54 insertions(+), 8 deletions(-)
New commits: commit c5b8d15ce18f1ebd63a5c3774c44f5ca60a8b8fb Author: Fridrich Å trba <[email protected]> Date: Sat Jun 29 15:59:10 2013 +0200 Initial reading of arrw records diff --git a/src/lib/CDRCollector.h b/src/lib/CDRCollector.h index ffbb08e..68cc236 100644 --- a/src/lib/CDRCollector.h +++ b/src/lib/CDRCollector.h @@ -94,6 +94,7 @@ public: virtual void collectLineTo(double x, double y) = 0; virtual void collectArcTo(double rx, double ry, bool largeArc, bool sweep, double x, double y) = 0; virtual void collectClosePath() = 0; + virtual void collectPath(const CDRPath &path) = 0; virtual void collectLevel(unsigned level) = 0; virtual void collectTransform(const CDRTransforms &transforms, bool considerGroupTransform) = 0; virtual void collectFillStyle(unsigned short fillType, const CDRColor &color1, const CDRColor &color2, const CDRGradient &gradient, const CDRImageFill &imageFill) = 0; diff --git a/src/lib/CDRContentCollector.cpp b/src/lib/CDRContentCollector.cpp index 4076f56..07e1f58 100644 --- a/src/lib/CDRContentCollector.cpp +++ b/src/lib/CDRContentCollector.cpp @@ -189,6 +189,12 @@ void libcdr::CDRContentCollector::collectClosePath() m_currentPath.appendClosePath(); } +void libcdr::CDRContentCollector::collectPath(const CDRPath &path) +{ + CDR_DEBUG_MSG(("CDRContentCollector::collectPath\n")); + m_currentPath.appendPath(path); +} + void libcdr::CDRContentCollector::_flushCurrentPath() { CDR_DEBUG_MSG(("CDRContentCollector::collectFlushPath\n")); diff --git a/src/lib/CDRContentCollector.h b/src/lib/CDRContentCollector.h index 5bca65f..5242b1c 100644 --- a/src/lib/CDRContentCollector.h +++ b/src/lib/CDRContentCollector.h @@ -61,6 +61,7 @@ public: void collectLineTo(double x, double y); void collectArcTo(double rx, double ry, bool largeArc, bool sweep, double x, double y); void collectClosePath(); + void collectPath(const CDRPath &path); void collectLevel(unsigned level); void collectTransform(const CDRTransforms &transforms, bool considerGroupTransform); void collectFillStyle(unsigned short fillType, const CDRColor &color1, const CDRColor &color2, const CDRGradient &gradient, const CDRImageFill &imageFill); diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp index 9e1e8ed..9f024b8 100644 --- a/src/lib/CDRParser.cpp +++ b/src/lib/CDRParser.cpp @@ -717,6 +717,7 @@ void libcdr::CDRParser::readRecord(unsigned fourCC, unsigned length, WPXInputStr readFild(input, length); break; case CDR_FOURCC_arrw: + readArrw(input, length); break; case CDR_FOURCC_flgs: readFlags(input, length); @@ -1478,6 +1479,31 @@ void libcdr::CDRParser::readPath(WPXInputStream *input) outputPath(points, pointTypes); } +void libcdr::CDRParser::readArrw(WPXInputStream *input, unsigned length) +{ + CDR_DEBUG_MSG(("CDRParser::readArrw\n")); + if (!_redirectX6Chunk(&input, length)) + throw GenericException(); + /* unsigned arrowId = */ + readU32(input); + input->seek(4, WPX_SEEK_CUR); + unsigned short pointNum = readU16(input); + input->seek(4, WPX_SEEK_CUR); + std::vector<std::pair<double, double> > points; + std::vector<unsigned char> pointTypes; + for (unsigned j=0; j<pointNum; j++) + { + std::pair<double, double> point; + point.first = (double)readCoordinate(input); + point.second = (double)readCoordinate(input); + points.push_back(point); + } + for (unsigned k=0; k<pointNum; k++) + pointTypes.push_back(readU8(input)); + CDRPath path; + processPath(points, pointTypes, path); +} + void libcdr::CDRParser::readBitmap(WPXInputStream *input) { CDR_DEBUG_MSG(("CDRParser::readBitmap\n")); diff --git a/src/lib/CDRParser.h b/src/lib/CDRParser.h index fc9116c..64f4b43 100644 --- a/src/lib/CDRParser.h +++ b/src/lib/CDRParser.h @@ -88,6 +88,7 @@ private: void readFlags(WPXInputStream *input, unsigned length); void readMcfg(WPXInputStream *input, unsigned length); void readPath(WPXInputStream *input); + void readArrw(WPXInputStream *input, unsigned length); void readPolygonCoords(WPXInputStream *input); void readPolygonTransform(WPXInputStream *input); void readBmp(WPXInputStream *input, unsigned length); diff --git a/src/lib/CDRStylesCollector.h b/src/lib/CDRStylesCollector.h index e788e86..d7e26a9 100644 --- a/src/lib/CDRStylesCollector.h +++ b/src/lib/CDRStylesCollector.h @@ -62,6 +62,7 @@ public: void collectLineTo(double, double) {} void collectArcTo(double, double, bool, bool, double, double) {} void collectClosePath() {} + void collectPath(const CDRPath &) {} void collectLevel(unsigned) {} void collectTransform(const CDRTransforms &, bool) {} void collectFillStyle(unsigned short, const CDRColor &, const CDRColor &, const CDRGradient &, const CDRImageFill &) {} diff --git a/src/lib/CommonParser.cpp b/src/lib/CommonParser.cpp index 9a8bfaf..184be1e 100644 --- a/src/lib/CommonParser.cpp +++ b/src/lib/CommonParser.cpp @@ -90,6 +90,14 @@ double libcdr::CommonParser::readAngle(WPXInputStream *input, bool bigEndian) void libcdr::CommonParser::outputPath(const std::vector<std::pair<double, double> > &points, const std::vector<unsigned char> &types) { + CDRPath path; + processPath(points, types, path); + m_collector->collectPath(path); +} + +void libcdr::CommonParser::processPath(const std::vector<std::pair<double, double> > &points, + const std::vector<unsigned char> &types, CDRPath &path) +{ bool isClosedPath = false; std::vector<std::pair<double, double> >tmpPoints; for (unsigned k=0; k<points.size(); k++) @@ -114,25 +122,25 @@ void libcdr::CommonParser::outputPath(const std::vector<std::pair<double, double if (!(type & 0x40) && !(type & 0x80)) { tmpPoints.clear(); - m_collector->collectMoveTo(points[k].first, points[k].second); + path.appendMoveTo(points[k].first, points[k].second); } else if ((type & 0x40) && !(type & 0x80)) { tmpPoints.clear(); - m_collector->collectLineTo(points[k].first, points[k].second); + path.appendLineTo(points[k].first, points[k].second); if (isClosedPath) - m_collector->collectClosePath(); + path.appendClosePath(); } else if (!(type & 0x40) && (type & 0x80)) { if (tmpPoints.size() >= 2) - m_collector->collectCubicBezier(tmpPoints[0].first, tmpPoints[0].second, - tmpPoints[1].first, tmpPoints[1].second, - points[k].first, points[k].second); + path.appendCubicBezierTo(tmpPoints[0].first, tmpPoints[0].second, + tmpPoints[1].first, tmpPoints[1].second, + points[k].first, points[k].second); else - m_collector->collectLineTo(points[k].first, points[k].second); + path.appendLineTo(points[k].first, points[k].second); if (isClosedPath) - m_collector->collectClosePath(); + path.appendClosePath(); tmpPoints.clear(); } else if((type & 0x40) && (type & 0x80)) diff --git a/src/lib/CommonParser.h b/src/lib/CommonParser.h index 14d757b..f9c0cc0 100644 --- a/src/lib/CommonParser.h +++ b/src/lib/CommonParser.h @@ -31,6 +31,7 @@ #define __COMMONPARSER_H__ #include "CDRCollector.h" +#include "CDRPath.h" class WPXInputSTream; @@ -60,6 +61,7 @@ protected: int readInteger(WPXInputStream *input, bool bigEndian = false); double readAngle(WPXInputStream *input, bool bigEndian = false); + void processPath(const std::vector<std::pair<double, double> > &points, const std::vector<unsigned char> &types, CDRPath &path); void outputPath(const std::vector<std::pair<double, double> > &points, const std::vector<unsigned char> &types); CDRCollector *m_collector;
_______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
