diff options
author | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2012-07-24 12:03:25 +0200 |
---|---|---|
committer | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2012-07-24 12:03:25 +0200 |
commit | 750df6c2f72717ba09256a3bc509073a1c0f5b8d (patch) | |
tree | c0e8bb96005b95f3f47fe2a9f6cf040040fac5e7 | |
parent | 47e8a2c7824f6b0c1df8476e9236d1cfd870b545 (diff) |
Some more refactoring
-rw-r--r-- | src/lib/VSDXParser.cpp | 297 | ||||
-rw-r--r-- | src/lib/VSDXParser.h | 3 |
2 files changed, 147 insertions, 153 deletions
diff --git a/src/lib/VSDXParser.cpp b/src/lib/VSDXParser.cpp index 703fe2d..5ff7d8d 100644 --- a/src/lib/VSDXParser.cpp +++ b/src/lib/VSDXParser.cpp @@ -164,7 +164,7 @@ void libvisio::VSDXParser::handleStream(const Pointer &ptr) { case VSD_PAGE: // shouldn't happen case VSD_FONT_LIST: // ver6 stream contains chunk 0x18 (FontList) and chunks 0x19 (Font) - handlePage(&tmpInput); + handleChunks(&tmpInput); break; case VSD_PAGES: case VSD_FONTFACES: // ver11 stream contains streams 0xd7 (FontFace) @@ -184,8 +184,140 @@ void libvisio::VSDXParser::handleStream(const Pointer &ptr) } } -void libvisio::VSDXParser::handleChunks(WPXInputStream * /* input */, unsigned /* shift */) +void libvisio::VSDXParser::handleChunks(WPXInputStream *input) { + long endPos = 0; + + while (!input->atEOS()) + { + getChunkHeader(input); + endPos = m_header.dataLength+m_header.trailer+input->tell(); + + _handleLevelChange(m_header.level); + VSD_DEBUG_MSG(("Shape: parsing chunk type %x\n", m_header.chunkType)); + switch (m_header.chunkType) + { + case VSD_SHAPE_GROUP: + case VSD_SHAPE_GUIDE: + case VSD_SHAPE_SHAPE: + case VSD_SHAPE_FOREIGN: + readShape(input); + break; + case VSD_XFORM_DATA: + readXFormData(input); + break; + case VSD_TEXT_XFORM: + readTxtXForm(input); + break; + case VSD_SHAPE_LIST: + readShapeList(input); + break; + case VSD_SHAPE_ID: + readShapeId(input); + break; + case VSD_LINE: + readLine(input); + break; + case VSD_FILL_AND_SHADOW: + readFillAndShadow(input); + break; + case VSD_GEOM_LIST: + readGeomList(input); + break; + case VSD_GEOMETRY: + readGeometry(input); + break; + case VSD_MOVE_TO: + readMoveTo(input); + break; + case VSD_LINE_TO: + readLineTo(input); + break; + case VSD_ARC_TO: + readArcTo(input); + break; + case VSD_ELLIPSE: + readEllipse(input); + break; + case VSD_ELLIPTICAL_ARC_TO: + readEllipticalArcTo(input); + break; + case VSD_NURBS_TO: + readNURBSTo(input); + break; + case VSD_POLYLINE_TO: + readPolylineTo(input); + break; + case VSD_INFINITE_LINE: + readInfiniteLine(input); + break; + case VSD_SHAPE_DATA: + readShapeData(input); + break; + case VSD_FOREIGN_DATA_TYPE: + readForeignDataType(input); + break; + case VSD_FOREIGN_DATA: + readForeignData(input); + break; + case VSD_OLE_LIST: + readOLEList(input); + break; + case VSD_OLE_DATA: + readOLEData(input); + break; + case VSD_PAGE_PROPS: + readPageProps(input); + break; + case VSD_CHAR_LIST: + readCharList(input); + break; + case VSD_PARA_LIST: + readParaList(input); + break; + case VSD_TEXT: + readText(input); + break; + case VSD_CHAR_IX: + readCharIX(input); + break; + case VSD_PARA_IX: + readParaIX(input); + break; + case VSD_TEXT_BLOCK: + readTextBlock(input); + break; +// case VSD_FONT_LIST: // ver 6 only, don't need to handle that + case VSD_FONT_IX: // ver 6 only + readFontIX(input); + break; + case VSD_PAGE: + readPage(input); + break; + case VSD_SPLINE_START: + readSplineStart(input); + break; + case VSD_SPLINE_KNOT: + readSplineKnot(input); + break; + case VSD_NAME_LIST: + readNameList(input); + break; + case VSD_NAME: + readName(input); + break; + case VSD_FIELD_LIST: + readFieldList(input); + break; + case VSD_TEXT_FIELD: + readTextField(input); + break; + default: + m_collector->collectUnhandledChunk(m_header.id, m_header.level); + } + + input->seek(endPos, WPX_SEEK_SET); + } } void libvisio::VSDXParser::handlePages(WPXInputStream *input, unsigned shift) @@ -221,7 +353,18 @@ void libvisio::VSDXParser::handlePages(WPXInputStream *input, unsigned shift) case VSD_PAGE: m_currentPageID = i; numPages++; - handlePage(&tmpInput); + try + { + m_collector->startPage(); + handleChunks(&tmpInput); + _handleLevelChange(0); + m_collector->endPage(); + } + catch (EndOfStreamException) + { + _handleLevelChange(0); + m_collector->endPage(); + } break; case VSD_PAGES: // shouldn't happen handlePages(&tmpInput, shift); @@ -682,154 +825,6 @@ void libvisio::VSDXParser::_handleLevelChange(unsigned level) m_currentLevel = level; } -void libvisio::VSDXParser::handlePage(WPXInputStream *input) -{ - try - { - long endPos = 0; - - m_collector->startPage(); - - while (!input->atEOS()) - { - getChunkHeader(input); - endPos = m_header.dataLength+m_header.trailer+input->tell(); - - _handleLevelChange(m_header.level); - VSD_DEBUG_MSG(("Shape: parsing chunk type %x\n", m_header.chunkType)); - switch (m_header.chunkType) - { - case VSD_SHAPE_GROUP: - case VSD_SHAPE_GUIDE: - case VSD_SHAPE_SHAPE: - case VSD_SHAPE_FOREIGN: - readShape(input); - break; - case VSD_XFORM_DATA: - readXFormData(input); - break; - case VSD_TEXT_XFORM: - readTxtXForm(input); - break; - case VSD_SHAPE_LIST: - readShapeList(input); - break; - case VSD_SHAPE_ID: - readShapeId(input); - break; - case VSD_LINE: - readLine(input); - break; - case VSD_FILL_AND_SHADOW: - readFillAndShadow(input); - break; - case VSD_GEOM_LIST: - readGeomList(input); - break; - case VSD_GEOMETRY: - readGeometry(input); - break; - case VSD_MOVE_TO: - readMoveTo(input); - break; - case VSD_LINE_TO: - readLineTo(input); - break; - case VSD_ARC_TO: - readArcTo(input); - break; - case VSD_ELLIPSE: - readEllipse(input); - break; - case VSD_ELLIPTICAL_ARC_TO: - readEllipticalArcTo(input); - break; - case VSD_NURBS_TO: - readNURBSTo(input); - break; - case VSD_POLYLINE_TO: - readPolylineTo(input); - break; - case VSD_INFINITE_LINE: - readInfiniteLine(input); - break; - case VSD_SHAPE_DATA: - readShapeData(input); - break; - case VSD_FOREIGN_DATA_TYPE: - readForeignDataType(input); - break; - case VSD_FOREIGN_DATA: - readForeignData(input); - break; - case VSD_OLE_LIST: - readOLEList(input); - break; - case VSD_OLE_DATA: - readOLEData(input); - break; - case VSD_PAGE_PROPS: - readPageProps(input); - break; - case VSD_CHAR_LIST: - readCharList(input); - break; - case VSD_PARA_LIST: - readParaList(input); - break; - case VSD_TEXT: - readText(input); - break; - case VSD_CHAR_IX: - readCharIX(input); - break; - case VSD_PARA_IX: - readParaIX(input); - break; - case VSD_TEXT_BLOCK: - readTextBlock(input); - break; -// case VSD_FONT_LIST: // ver 6 only, don't need to handle that - case VSD_FONT_IX: // ver 6 only - readFontIX(input); - break; - case VSD_PAGE: - readPage(input); - break; - case VSD_SPLINE_START: - readSplineStart(input); - break; - case VSD_SPLINE_KNOT: - readSplineKnot(input); - break; - case VSD_NAME_LIST: - readNameList(input); - break; - case VSD_NAME: - readName(input); - break; - case VSD_FIELD_LIST: - readFieldList(input); - break; - case VSD_TEXT_FIELD: - readTextField(input); - break; - default: - m_collector->collectUnhandledChunk(m_header.id, m_header.level); - } - - input->seek(endPos, WPX_SEEK_SET); - } - _handleLevelChange(0); - m_collector->endPage(); - } - catch (EndOfStreamException) - { - _handleLevelChange(0); - m_collector->endPage(); - } -} - // --- READERS --- void libvisio::VSDXParser::readEllipticalArcTo(WPXInputStream *input) diff --git a/src/lib/VSDXParser.h b/src/lib/VSDXParser.h index 6ac7ee9..1194a97 100644 --- a/src/lib/VSDXParser.h +++ b/src/lib/VSDXParser.h @@ -122,10 +122,9 @@ protected: // Stream handlers void handleStreams(WPXInputStream *input, unsigned shift=0); void handleStream(const Pointer &ptr); - void handleChunks(WPXInputStream *input, unsigned shift=0); + void handleChunks(WPXInputStream *input); void handlePages(WPXInputStream *input, unsigned shift); - void handlePage(WPXInputStream *input); void handleStyles(WPXInputStream *input); void handleStencils(WPXInputStream *input, unsigned shift); void handleStencilPage(WPXInputStream *input, unsigned shift); |