summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFridrich Štrba <fridrich.strba@bluewin.ch>2012-07-26 13:38:47 +0200
committerFridrich Štrba <fridrich.strba@bluewin.ch>2012-07-26 13:38:47 +0200
commit545f0adec7cbae3d04a2809d68850e10827fec84 (patch)
tree3def20352da28d2ccde5364a9a89e45b88651e15
parent0542f8229ec7cb5b887546b0db6996f6aa4e906b (diff)
A little refactoring of the level change handling
-rw-r--r--src/lib/VSDXContentCollector.cpp5
-rw-r--r--src/lib/VSDXContentCollector.h1
-rw-r--r--src/lib/VSDXParser.cpp7
-rw-r--r--src/lib/VSDXParser.h1
4 files changed, 9 insertions, 5 deletions
diff --git a/src/lib/VSDXContentCollector.cpp b/src/lib/VSDXContentCollector.cpp
index 8bc3b58..e59a257 100644
--- a/src/lib/VSDXContentCollector.cpp
+++ b/src/lib/VSDXContentCollector.cpp
@@ -131,7 +131,7 @@ libvisio::VSDXContentCollector::VSDXContentCollector(
m_stencils(stencils), m_stencilShape(0), m_isStencilStarted(false), m_currentGeometryCount(0),
m_backgroundPageID(0xffffffff), m_currentPageID(0), m_currentPage(), m_pages(),
m_splineControlPoints(), m_splineKnotVector(), m_splineX(0.0), m_splineY(0.0),
- m_splineLastKnot(0.0), m_splineDegree(0), m_splineLevel(0)
+ m_splineLastKnot(0.0), m_splineDegree(0), m_splineLevel(0), m_currentShapeLevel(0)
{
}
@@ -1919,6 +1919,7 @@ void libvisio::VSDXContentCollector::collectPage(unsigned /* id */, unsigned lev
void libvisio::VSDXContentCollector::collectShape(unsigned id, unsigned level, unsigned masterPage, unsigned masterShape, unsigned lineStyleId, unsigned fillStyleId, unsigned textStyleId)
{
_handleLevelChange(level);
+ m_currentShapeLevel = level;
m_foreignType = 0; // Tracks current foreign data type
m_foreignFormat = 0; // Tracks foreign data format
@@ -2316,7 +2317,7 @@ void libvisio::VSDXContentCollector::_handleLevelChange(unsigned level)
{
if (m_currentLevel == level)
return;
- if (level < 2)
+ if (level <= m_currentShapeLevel)
{
if (m_isShapeStarted)
{
diff --git a/src/lib/VSDXContentCollector.h b/src/lib/VSDXContentCollector.h
index 7413ab4..f0ae3e7 100644
--- a/src/lib/VSDXContentCollector.h
+++ b/src/lib/VSDXContentCollector.h
@@ -268,6 +268,7 @@ private:
double m_splineLastKnot;
unsigned m_splineDegree;
unsigned m_splineLevel;
+ unsigned m_currentShapeLevel;
};
} // namespace libvisio
diff --git a/src/lib/VSDXParser.cpp b/src/lib/VSDXParser.cpp
index 6ff537a..2db718f 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_stencilShape(), m_isStencilStarted(false), m_isInStyles(false), m_currentShapeLevel(0)
{}
libvisio::VSDXParser::~VSDXParser()
@@ -573,7 +573,7 @@ void libvisio::VSDXParser::_handleLevelChange(unsigned level)
{
if (level == m_currentLevel)
return;
- if (level < 3)
+ if (level <= m_currentShapeLevel+1)
{
m_geomListVector.push_back(m_geomList);
m_charListVector.push_back(m_charList);
@@ -585,7 +585,7 @@ void libvisio::VSDXParser::_handleLevelChange(unsigned level)
m_shapeList.handle(m_collector);
m_shapeList.clear();
}
- if (level < 2)
+ if (level <= m_currentShapeLevel)
{
for (std::vector<VSDXGeometryList *>::iterator iter = m_geomListVector.begin(); iter != m_geomListVector.end(); ++iter)
{
@@ -984,6 +984,7 @@ void libvisio::VSDXParser::readPageProps(WPXInputStream *input)
void libvisio::VSDXParser::readShape(WPXInputStream *input)
{
+ m_currentShapeLevel = m_header.level;
input->seek(0x12, WPX_SEEK_CUR);
unsigned masterPage = readU32(input);
input->seek(4, WPX_SEEK_CUR);
diff --git a/src/lib/VSDXParser.h b/src/lib/VSDXParser.h
index e0805cf..4093950 100644
--- a/src/lib/VSDXParser.h
+++ b/src/lib/VSDXParser.h
@@ -153,6 +153,7 @@ protected:
VSDXStencilShape m_stencilShape;
bool m_isStencilStarted;
bool m_isInStyles;
+ unsigned m_currentShapeLevel;
private:
VSDXParser();