diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/VSDXCollector.h | 2 | ||||
-rw-r--r-- | src/lib/VSDXContentCollector.cpp | 12 | ||||
-rw-r--r-- | src/lib/VSDXContentCollector.h | 2 | ||||
-rw-r--r-- | src/lib/VSDXGeometryList.cpp | 61 | ||||
-rw-r--r-- | src/lib/VSDXGeometryList.h | 2 | ||||
-rw-r--r-- | src/lib/VSDXParser.cpp | 44 | ||||
-rw-r--r-- | src/lib/VSDXParser.h | 3 | ||||
-rw-r--r-- | src/lib/VSDXStylesCollector.cpp | 10 | ||||
-rw-r--r-- | src/lib/VSDXStylesCollector.h | 2 |
9 files changed, 138 insertions, 0 deletions
diff --git a/src/lib/VSDXCollector.h b/src/lib/VSDXCollector.h index 99764d7..01d1856 100644 --- a/src/lib/VSDXCollector.h +++ b/src/lib/VSDXCollector.h @@ -66,6 +66,8 @@ public: virtual void collectPageProps(unsigned id, unsigned level, double pageWidth, double pageHeight, double shadowOffsetX, double shadowOffsetY) = 0; virtual void collectPage(unsigned id, unsigned level, unsigned backgroundPageID, unsigned currentPageID) = 0; virtual void collectShape(unsigned id, unsigned level, unsigned masterPage, unsigned masterShape, unsigned lineStyle, unsigned fillStyle, unsigned textStyle) = 0; + virtual void collectSplineStart(unsigned id, unsigned level, double x, double y, double secondKnot, double firstKnot, double lastKnot, unsigned degree) = 0; + virtual void collectSplineKnot(unsigned id, unsigned level, double x, double y, double knot) = 0; virtual void collectUnhandledChunk(unsigned id, unsigned level) = 0; diff --git a/src/lib/VSDXContentCollector.cpp b/src/lib/VSDXContentCollector.cpp index 07e960e..cd44025 100644 --- a/src/lib/VSDXContentCollector.cpp +++ b/src/lib/VSDXContentCollector.cpp @@ -1216,6 +1216,18 @@ void libvisio::VSDXContentCollector::collectFont(unsigned short fontID, const st } +void libvisio::VSDXContentCollector::collectSplineStart(unsigned /* id */, unsigned level, double /* x */, double /* y */, double /* secondKnot */, double /* firstKnot */, double /* lastKnot */, unsigned /* degree */) +{ + _handleLevelChange(level); +} + + +void libvisio::VSDXContentCollector::collectSplineKnot(unsigned /* id */, unsigned level, double /* x */, double /* y */, double /* knot */) +{ + _handleLevelChange(level); +} + + void libvisio::VSDXContentCollector::collectText(unsigned /*id*/, unsigned level, const std::vector<unsigned char> &textStream, TextFormat format) { _handleLevelChange(level); diff --git a/src/lib/VSDXContentCollector.h b/src/lib/VSDXContentCollector.h index 2aa50a2..aef7a0a 100644 --- a/src/lib/VSDXContentCollector.h +++ b/src/lib/VSDXContentCollector.h @@ -84,6 +84,8 @@ public: void collectPageProps(unsigned id, unsigned level, double pageWidth, double pageHeight, double shadowOffsetX, double shadowOffsetY); void collectPage(unsigned id, unsigned level, unsigned backgroundPageID, unsigned currentPageID); void collectShape(unsigned id, unsigned level, unsigned masterPage, unsigned masterShape, unsigned lineStyle, unsigned fillStyle, unsigned textStyle); + void collectSplineStart(unsigned id, unsigned level, double x, double y, double secondKnot, double firstKnot, double lastKnot, unsigned degree); + void collectSplineKnot(unsigned id, unsigned level, double x, double y, double knot); void collectUnhandledChunk(unsigned id, unsigned level); diff --git a/src/lib/VSDXGeometryList.cpp b/src/lib/VSDXGeometryList.cpp index 9aaa832..9429184 100644 --- a/src/lib/VSDXGeometryList.cpp +++ b/src/lib/VSDXGeometryList.cpp @@ -144,6 +144,35 @@ private: unsigned m_xType, m_yType; std::vector<std::pair<double, double> > m_points; }; + +class VSDXSplineStart : public VSDXGeometryListElement +{ +public: + VSDXSplineStart(unsigned id, unsigned level, double x, double y, double secondKnot, double firstKnot, double lastKnot, unsigned degree) : + m_id(id), m_level(level), m_x(x), m_y(y), m_secondKnot(secondKnot), m_firstKnot(firstKnot), m_lastKnot(lastKnot), m_degree(degree) {} + ~VSDXSplineStart() {} + void handle(VSDXCollector *collector); + VSDXGeometryListElement *clone(); +private: + unsigned m_id, m_level; + double m_x, m_y; + double m_secondKnot, m_firstKnot, m_lastKnot; + unsigned m_degree; +}; + +class VSDXSplineKnot : public VSDXGeometryListElement +{ +public: + VSDXSplineKnot(unsigned id, unsigned level, double x, double y, double knot) : + m_id(id), m_level(level), m_x(x), m_y(y), m_knot(knot) {} + ~VSDXSplineKnot() {} + void handle(VSDXCollector *collector); + VSDXGeometryListElement *clone(); +private: + unsigned m_id, m_level; + double m_x, m_y; + double m_knot; +}; } // namespace libvisio @@ -257,6 +286,28 @@ libvisio::VSDXGeometryListElement *libvisio::VSDXPolylineTo2::clone() } +void libvisio::VSDXSplineStart::handle(VSDXCollector *collector) +{ + collector->collectSplineStart(m_id, m_level, m_x, m_y, m_secondKnot, m_firstKnot, m_lastKnot, m_degree); +} + +libvisio::VSDXGeometryListElement *libvisio::VSDXSplineStart::clone() +{ + return new VSDXSplineStart(m_id, m_level, m_x, m_y, m_secondKnot, m_firstKnot, m_lastKnot, m_degree); +} + + +void libvisio::VSDXSplineKnot::handle(VSDXCollector *collector) +{ + collector->collectSplineKnot(m_id, m_level, m_x, m_y, m_knot); +} + +libvisio::VSDXGeometryListElement *libvisio::VSDXSplineKnot::clone() +{ + return new VSDXSplineKnot(m_id, m_level, m_x, m_y, m_knot); +} + + libvisio::VSDXGeometryList::VSDXGeometryList() { } @@ -334,6 +385,16 @@ void libvisio::VSDXGeometryList::addEllipticalArcTo(unsigned id, unsigned level, m_elements[id] = new VSDXEllipticalArcTo(id, level, x3, y3, x2, y2, angle, ecc); } +void libvisio::VSDXGeometryList::addSplineStart(unsigned id, unsigned level, double x, double y, double secondKnot, double firstKnot, double lastKnot, unsigned degree) +{ + m_elements[id] = new VSDXSplineStart(id, level, x, y, secondKnot, firstKnot, lastKnot, degree); +} + +void libvisio::VSDXGeometryList::addSplineKnot(unsigned id, unsigned level, double x, double y, double knot) +{ + m_elements[id] = new VSDXSplineKnot(id, level, x, y, knot); +} + void libvisio::VSDXGeometryList::setElementsOrder(const std::vector<unsigned> &elementsOrder) { m_elementsOrder.clear(); diff --git a/src/lib/VSDXGeometryList.h b/src/lib/VSDXGeometryList.h index 543caf7..f17d94d 100644 --- a/src/lib/VSDXGeometryList.h +++ b/src/lib/VSDXGeometryList.h @@ -56,6 +56,8 @@ public: void addPolylineTo(unsigned id , unsigned level, double x, double y, unsigned dataID); void addEllipse(unsigned id, unsigned level, double cx, double cy, double xleft, double yleft, double xtop, double ytop); void addEllipticalArcTo(unsigned id, unsigned level, double x3, double y3, double x2, double y2, double angle, double ecc); + void addSplineStart(unsigned id, unsigned level, double x, double y, double secondKnot, double firstKnot, double lastKnot, unsigned degree); + void addSplineKnot(unsigned id, unsigned level, double x, double y, double knot); void setElementsOrder(const std::vector<unsigned> &m_elementsOrder); void handle(VSDXCollector *collector) const; void clear(); diff --git a/src/lib/VSDXParser.cpp b/src/lib/VSDXParser.cpp index a874c30..518ed77 100644 --- a/src/lib/VSDXParser.cpp +++ b/src/lib/VSDXParser.cpp @@ -487,6 +487,12 @@ void libvisio::VSDXParser::handleStencilShape(WPXInputStream *input) case VSD_PAGE_PROPS: readPageProps(input); break; + case VSD_SPLINE_START: + readSplineStart(input); + break; + case VSD_SPLINE_KNOT: + readSplineKnot(input); + break; default: m_collector->collectUnhandledChunk(m_header.id, m_header.level); } @@ -630,6 +636,12 @@ void libvisio::VSDXParser::handlePage(WPXInputStream *input) case VSD_PAGE: readPage(input); break; + case VSD_SPLINE_START: + readSplineStart(input); + break; + case VSD_SPLINE_KNOT: + readSplineKnot(input); + break; default: m_collector->collectUnhandledChunk(m_header.id, m_header.level); } @@ -1294,6 +1306,38 @@ void libvisio::VSDXParser::readShapeData(WPXInputStream *input) } } +void libvisio::VSDXParser::readSplineStart(WPXInputStream *input) +{ + input->seek(1, WPX_SEEK_CUR); + double x = readDouble(input); + input->seek(1, WPX_SEEK_CUR); + double y = readDouble(input); + double secondKnot = readDouble(input); + double firstKnot = readDouble(input); + double lastKnot = readDouble(input); + unsigned degree = readU8(input); + + if (m_isStencilStarted) + m_stencilShape.m_geometries.back().addSplineStart(m_header.id, m_header.level, x, y, secondKnot, firstKnot, lastKnot, degree); + else + m_geomList->addSplineStart(m_header.id, m_header.level, x, y, secondKnot, firstKnot, lastKnot, degree); +} + +void libvisio::VSDXParser::readSplineKnot(WPXInputStream *input) +{ + input->seek(1, WPX_SEEK_CUR); + double x = readDouble(input); + input->seek(1, WPX_SEEK_CUR); + double y = readDouble(input); + double knot = readDouble(input); + + if (m_isStencilStarted) + m_stencilShape.m_geometries.back().addSplineKnot(m_header.id, m_header.level, x, y, knot); + else + m_geomList->addSplineKnot(m_header.id, m_header.level, x, y, knot); +} + + void libvisio::VSDXParser::readColours(WPXInputStream *input) { input->seek(6, WPX_SEEK_SET); diff --git a/src/lib/VSDXParser.h b/src/lib/VSDXParser.h index 0fe5135..8b96af2 100644 --- a/src/lib/VSDXParser.h +++ b/src/lib/VSDXParser.h @@ -89,6 +89,9 @@ protected: void readLineStyle(WPXInputStream *input); virtual void readFillStyle(WPXInputStream *input) = 0; virtual void readCharIXStyle(WPXInputStream *input) = 0; + + void readSplineStart(WPXInputStream *input); + void readSplineKnot(WPXInputStream *input); void readStencilShape(WPXInputStream *input); diff --git a/src/lib/VSDXStylesCollector.cpp b/src/lib/VSDXStylesCollector.cpp index e16b1be..4ab318a 100644 --- a/src/lib/VSDXStylesCollector.cpp +++ b/src/lib/VSDXStylesCollector.cpp @@ -131,6 +131,16 @@ void libvisio::VSDXStylesCollector::collectPolylineTo(unsigned /* id */, unsigne _handleLevelChange(level); } +void libvisio::VSDXStylesCollector::collectSplineStart(unsigned /* id */, unsigned level, double /* x */, double /* y */, double /* secondKnot */, double /* firstKnot */, double /* lastKnot */, unsigned /* degree */) +{ + _handleLevelChange(level); +} + +void libvisio::VSDXStylesCollector::collectSplineKnot(unsigned /* id */, unsigned level, double /* x */, double /* y */, double /* knot */) +{ + _handleLevelChange(level); +} + void libvisio::VSDXStylesCollector::collectShapeData(unsigned /* id */, unsigned level, unsigned /* xType */, unsigned /* yType */, unsigned /* degree */, double /*lastKnot*/, std::vector<std::pair<double, double> > /* controlPoints */, std::vector<double> /* knotVector */, std::vector<double> /* weights */) { _handleLevelChange(level); diff --git a/src/lib/VSDXStylesCollector.h b/src/lib/VSDXStylesCollector.h index 866d8c9..d2a4f55 100644 --- a/src/lib/VSDXStylesCollector.h +++ b/src/lib/VSDXStylesCollector.h @@ -75,6 +75,8 @@ public: void collectPageProps(unsigned id, unsigned level, double pageWidth, double pageHeight, double shadowOffsetX, double shadowOffsetY); void collectPage(unsigned id, unsigned level, unsigned backgroundPageID, unsigned currentPageID); void collectShape(unsigned id, unsigned level, unsigned masterPage, unsigned masterShape, unsigned lineStyle, unsigned fillStyle, unsigned textStyle); + void collectSplineStart(unsigned id, unsigned level, double x, double y, double secondKnot, double firstKnot, double lastKnot, unsigned degree); + void collectSplineKnot(unsigned id, unsigned level, double x, double y, double knot); void collectUnhandledChunk(unsigned id, unsigned level); void collectColours(const std::vector<Colour> &colours); |