diff options
-rw-r--r-- | src/lib/VSDXCollector.h | 4 | ||||
-rw-r--r-- | src/lib/VSDXContentCollector.cpp | 6 | ||||
-rw-r--r-- | src/lib/VSDXContentCollector.h | 4 | ||||
-rw-r--r-- | src/lib/VSDXPages.cpp | 3 | ||||
-rw-r--r-- | src/lib/VSDXParser.cpp | 17 | ||||
-rw-r--r-- | src/lib/VSDXParser.h | 3 | ||||
-rw-r--r-- | src/lib/VSDXStylesCollector.cpp | 4 | ||||
-rw-r--r-- | src/lib/VSDXStylesCollector.h | 4 |
8 files changed, 25 insertions, 20 deletions
diff --git a/src/lib/VSDXCollector.h b/src/lib/VSDXCollector.h index 5bf198f..e1c7bc6 100644 --- a/src/lib/VSDXCollector.h +++ b/src/lib/VSDXCollector.h @@ -71,7 +71,7 @@ public: virtual void collectShapeId(unsigned id, unsigned level, unsigned shapeId) = 0; virtual void collectForeignDataType(unsigned id, unsigned level, unsigned foreignType, unsigned foreignFormat, double offsetX, double offsetY, double width, double height) = 0; virtual void collectPageProps(unsigned id, unsigned level, double pageWidth, double pageHeight, double shadowOffsetX, double shadowOffsetY, double scale) = 0; - virtual void collectPage(unsigned id, unsigned level, unsigned backgroundPageID, unsigned currentPageID) = 0; + virtual void collectPage(unsigned id, unsigned level, unsigned backgroundPageID) = 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; @@ -117,7 +117,7 @@ public: virtual void collectNumericField(unsigned id, unsigned level, unsigned short format, double number, int formatStringId) = 0; // Temporary hack - virtual void startPage() = 0; + virtual void startPage(unsigned pageId) = 0; virtual void endPage() = 0; virtual void endPages(const std::vector<unsigned> &pageOrder) = 0; diff --git a/src/lib/VSDXContentCollector.cpp b/src/lib/VSDXContentCollector.cpp index a13733e..03ba3c4 100644 --- a/src/lib/VSDXContentCollector.cpp +++ b/src/lib/VSDXContentCollector.cpp @@ -1910,11 +1910,10 @@ void libvisio::VSDXContentCollector::collectPageProps(unsigned /* id */, unsigne m_currentPage.m_pageHeight = m_scale*m_pageHeight; } -void libvisio::VSDXContentCollector::collectPage(unsigned /* id */, unsigned level, unsigned backgroundPageID, unsigned currentPageID) +void libvisio::VSDXContentCollector::collectPage(unsigned /* id */, unsigned level, unsigned backgroundPageID) { _handleLevelChange(level); m_currentPage.m_backgroundPageID = backgroundPageID; - m_currentPage.m_currentPageID = currentPageID; } void libvisio::VSDXContentCollector::collectShape(unsigned id, unsigned level, unsigned masterPage, unsigned masterShape, unsigned lineStyleId, unsigned fillStyleId, unsigned textStyleId) @@ -2360,7 +2359,7 @@ void libvisio::VSDXContentCollector::_handleLevelChange(unsigned level) m_currentLevel = level; } -void libvisio::VSDXContentCollector::startPage() +void libvisio::VSDXContentCollector::startPage(unsigned pageId) { if (m_isShapeStarted) { @@ -2384,6 +2383,7 @@ void libvisio::VSDXContentCollector::startPage() if (m_documentPageShapeOrders.size() >= m_currentPageNumber) m_pageShapeOrder = m_documentPageShapeOrders[m_currentPageNumber-1]; m_currentPage = libvisio::VSDXPage(); + m_currentPage.m_currentPageID = pageId; m_isPageStarted = true; } diff --git a/src/lib/VSDXContentCollector.h b/src/lib/VSDXContentCollector.h index b786a2a..922745f 100644 --- a/src/lib/VSDXContentCollector.h +++ b/src/lib/VSDXContentCollector.h @@ -93,7 +93,7 @@ public: void collectShapeId(unsigned id, unsigned level, unsigned shapeId); void collectForeignDataType(unsigned id, unsigned level, unsigned foreignType, unsigned foreignFormat, double offsetX, double offsetY, double width, double height); void collectPageProps(unsigned id, unsigned level, double pageWidth, double pageHeight, double shadowOffsetX, double shadowOffsetY, double scale); - void collectPage(unsigned id, unsigned level, unsigned backgroundPageID, unsigned currentPageID); + void collectPage(unsigned id, unsigned level, unsigned backgroundPageID); 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); @@ -137,7 +137,7 @@ public: void collectTextField(unsigned id, unsigned level, int nameId, int formatStringId); void collectNumericField(unsigned id, unsigned level, unsigned short format, double number, int formatStringId); - void startPage(); + void startPage(unsigned pageId); void endPage(); void endPages(const std::vector<unsigned> &pageOrder); diff --git a/src/lib/VSDXPages.cpp b/src/lib/VSDXPages.cpp index 3a4050c..7701ffa 100644 --- a/src/lib/VSDXPages.cpp +++ b/src/lib/VSDXPages.cpp @@ -115,6 +115,9 @@ void libvisio::VSDXPages::_drawPage(libwpg::WPGPaintInterface *painter, const li if (!painter) return; + if (page.m_pageWidth == 0.0 || page.m_pageHeight == 0.0) + return; + WPXPropertyList pageProps; pageProps.insert("svg:width", page.m_pageWidth); pageProps.insert("svg:height", page.m_pageHeight); diff --git a/src/lib/VSDXParser.cpp b/src/lib/VSDXParser.cpp index 8c0cd70..43584e6 100644 --- a/src/lib/VSDXParser.cpp +++ b/src/lib/VSDXParser.cpp @@ -46,7 +46,7 @@ libvisio::VSDXParser::VSDXParser(WPXInputStream *input, libwpg::WPGPaintInterfac m_geomListVector(), m_fieldList(), m_charList(new VSDXCharacterList()), m_paraList(new VSDXParagraphList()), m_charListVector(), m_paraListVector(), m_shapeList(), m_currentLevel(0), m_stencils(), m_currentStencil(0), - m_stencilShape(), m_isStencilStarted(false), m_isInStyles(false), m_currentPageID(0) + m_stencilShape(), m_isStencilStarted(false), m_isInStyles(false) {} libvisio::VSDXParser::~VSDXParser() @@ -172,8 +172,7 @@ void libvisio::VSDXParser::handleStream(const Pointer &ptr, unsigned idx, unsign m_isInStyles = true; break; case VSD_PAGE: - m_currentPageID = idx; - m_collector->startPage(); + m_collector->startPage(idx); break; case VSD_STENCILS: if (m_stencils.count()) @@ -196,16 +195,18 @@ void libvisio::VSDXParser::handleStream(const Pointer &ptr, unsigned idx, unsign } if ((ptr.Format >> 4) == 0xd) - handleChunks(&tmpInput); + handleChunks(&tmpInput, level+1); else if ((ptr.Format >> 4) == 0x5) handleStreams(&tmpInput, shift, level+1); switch (ptr.Type) { case VSD_STYLES: + _handleLevelChange(0); m_isInStyles = false; break; case VSD_PAGE: + _handleLevelChange(0); m_collector->endPage(); break; case VSD_PAGES: @@ -217,17 +218,19 @@ void libvisio::VSDXParser::handleStream(const Pointer &ptr, unsigned idx, unsign case VSD_STENCILS: m_isStencilStarted = false; break; +#if 0 case VSD_STENCIL_PAGE: m_stencils.addStencil(idx, *m_currentStencil); m_currentStencil = 0; break; +#endif default: break; } } -void libvisio::VSDXParser::handleChunks(WPXInputStream *input) +void libvisio::VSDXParser::handleChunks(WPXInputStream *input, unsigned /* level */) { long endPos = 0; @@ -407,7 +410,7 @@ void libvisio::VSDXParser::handleStencilPage(WPXInputStream *input, unsigned shi m_stencilShape = VSDXStencilShape(); try { - handleChunks(&tmpInput); + handleChunks(&tmpInput, 0); } catch (EndOfStreamException &) { @@ -785,7 +788,7 @@ void libvisio::VSDXParser::readPage(WPXInputStream *input) { input->seek(8, WPX_SEEK_CUR); //sub header length and children list length uint32_t backgroundPageID = readU32(input); - m_collector->collectPage(m_header.id, m_header.level, backgroundPageID, m_currentPageID); + m_collector->collectPage(m_header.id, m_header.level, backgroundPageID); } void libvisio::VSDXParser::readGeometry(WPXInputStream *input) diff --git a/src/lib/VSDXParser.h b/src/lib/VSDXParser.h index f9d0d5d..e0805cf 100644 --- a/src/lib/VSDXParser.h +++ b/src/lib/VSDXParser.h @@ -123,7 +123,7 @@ protected: // Stream handlers void handleStreams(WPXInputStream *input, unsigned shift, unsigned level); void handleStream(const Pointer &ptr, unsigned idx, unsigned level); - void handleChunks(WPXInputStream *input); + void handleChunks(WPXInputStream *input, unsigned level); void handleStencils(WPXInputStream *input, unsigned shift); void handleStencilPage(WPXInputStream *input, unsigned shift); @@ -153,7 +153,6 @@ protected: VSDXStencilShape m_stencilShape; bool m_isStencilStarted; bool m_isInStyles; - unsigned m_currentPageID; private: VSDXParser(); diff --git a/src/lib/VSDXStylesCollector.cpp b/src/lib/VSDXStylesCollector.cpp index 402cf62..41a8b37 100644 --- a/src/lib/VSDXStylesCollector.cpp +++ b/src/lib/VSDXStylesCollector.cpp @@ -206,7 +206,7 @@ void libvisio::VSDXStylesCollector::collectPageProps(unsigned /* id */, unsigned _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::collectPage(unsigned /* id */, unsigned level, unsigned /* backgroundPageID */, unsigned /* currentPageID */) +void libvisio::VSDXStylesCollector::collectPage(unsigned /* id */, unsigned level, unsigned /* backgroundPageID */) { _handleLevelChange(level); } @@ -365,7 +365,7 @@ void libvisio::VSDXStylesCollector::collectNumericField(unsigned /* id */, unsig _handleLevelChange(level); } -void libvisio::VSDXStylesCollector::startPage() +void libvisio::VSDXStylesCollector::startPage(unsigned /* pageId */) { m_groupXForms.clear(); m_groupMemberships.clear(); diff --git a/src/lib/VSDXStylesCollector.h b/src/lib/VSDXStylesCollector.h index 302d41f..23dc872 100644 --- a/src/lib/VSDXStylesCollector.h +++ b/src/lib/VSDXStylesCollector.h @@ -84,7 +84,7 @@ public: void collectShapeId(unsigned id, unsigned level, unsigned shapeId); void collectForeignDataType(unsigned id, unsigned level, unsigned foreignType, unsigned foreignFormat, double offsetX, double offsetY, double width, double height); void collectPageProps(unsigned id, unsigned level, double pageWidth, double pageHeight, double shadowOffsetX, double shadowOffsetY, double scale); - void collectPage(unsigned id, unsigned level, unsigned backgroundPageID, unsigned currentPageID); + void collectPage(unsigned id, unsigned level, unsigned backgroundPageID); 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); @@ -131,7 +131,7 @@ public: void collectNumericField(unsigned id, unsigned level, unsigned short format, double number, int formatStringId); // Temporary hack - void startPage(); + void startPage(unsigned pageID); void endPage(); void endPages(const std::vector<unsigned> &) {} |