diff options
author | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2012-07-24 11:16:34 +0200 |
---|---|---|
committer | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2012-07-24 11:16:34 +0200 |
commit | 47e8a2c7824f6b0c1df8476e9236d1cfd870b545 (patch) | |
tree | baca004fe5d41c628c58143e034c23554bb0d937 | |
parent | 6b60c867cd74d1eaad8a2f39e84f4c9b61491a54 (diff) |
Extracting individual stream handling into a separate function
-rw-r--r-- | src/lib/VSDXParser.cpp | 55 | ||||
-rw-r--r-- | src/lib/VSDXParser.h | 18 |
2 files changed, 37 insertions, 36 deletions
diff --git a/src/lib/VSDXParser.cpp b/src/lib/VSDXParser.cpp index 658c11a..703fe2d 100644 --- a/src/lib/VSDXParser.cpp +++ b/src/lib/VSDXParser.cpp @@ -149,38 +149,39 @@ void libvisio::VSDXParser::handleStreams(WPXInputStream *input, unsigned shift) ptr.Type, ptr.Offset, ptr.Length, ptr.Format)); ptr = PtrList[j]; - bool compressed = ((ptr.Format & 2) == 2); - m_input->seek(ptr.Offset, WPX_SEEK_SET); - VSDInternalStream tmpInput(m_input, ptr.Length, compressed); - shift = compressed ? 4 : 0; - switch (ptr.Type) - { - case VSD_PAGE: // shouldn't happen - case VSD_FONT_LIST: // ver6 stream contains chunk 0x18 (FontList) and chunks 0x19 (Font) - handlePage(&tmpInput); - break; - case VSD_PAGES: - case VSD_FONTFACES: // ver11 stream contains streams 0xd7 (FontFace) - handlePages(&tmpInput, shift); - break; - case VSD_COLORS: - readColours(&tmpInput); - break; - case VSD_STYLES: - handleStyles(&tmpInput); - break; - case VSD_STENCILS: - handleStencils(&tmpInput, shift); - break; - default: - break; - } + handleStream(ptr); } } -void libvisio::VSDXParser::handleStream(WPXInputStream * /* input */, unsigned /* shift */) +void libvisio::VSDXParser::handleStream(const Pointer &ptr) { + bool compressed = ((ptr.Format & 2) == 2); + m_input->seek(ptr.Offset, WPX_SEEK_SET); + VSDInternalStream tmpInput(m_input, ptr.Length, compressed); + unsigned shift = compressed ? 4 : 0; + switch (ptr.Type) + { + case VSD_PAGE: // shouldn't happen + case VSD_FONT_LIST: // ver6 stream contains chunk 0x18 (FontList) and chunks 0x19 (Font) + handlePage(&tmpInput); + break; + case VSD_PAGES: + case VSD_FONTFACES: // ver11 stream contains streams 0xd7 (FontFace) + handlePages(&tmpInput, shift); + break; + case VSD_COLORS: + readColours(&tmpInput); + break; + case VSD_STYLES: + handleStyles(&tmpInput); + break; + case VSD_STENCILS: + handleStencils(&tmpInput, shift); + break; + default: + break; + } } void libvisio::VSDXParser::handleChunks(WPXInputStream * /* input */, unsigned /* shift */) diff --git a/src/lib/VSDXParser.h b/src/lib/VSDXParser.h index a826d66..6ac7ee9 100644 --- a/src/lib/VSDXParser.h +++ b/src/lib/VSDXParser.h @@ -51,6 +51,14 @@ namespace libvisio class VSDXCollector; +struct Pointer +{ + unsigned Type; + unsigned Offset; + unsigned Length; + unsigned short Format; +}; + class VSDXParser { public: @@ -113,7 +121,7 @@ protected: // Stream handlers void handleStreams(WPXInputStream *input, unsigned shift=0); - void handleStream(WPXInputStream *input, unsigned shift=0); + void handleStream(const Pointer &ptr); void handleChunks(WPXInputStream *input, unsigned shift=0); void handlePages(WPXInputStream *input, unsigned shift); @@ -156,14 +164,6 @@ private: }; -struct Pointer -{ - unsigned Type; - unsigned Offset; - unsigned Length; - unsigned short Format; -}; - } // namespace libvisio #endif // __VSDXPARSER_H__ |