summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFridrich Štrba <fridrich.strba@bluewin.ch>2015-12-16 10:34:20 +0100
committerFridrich Štrba <fridrich.strba@bluewin.ch>2015-12-16 10:34:20 +0100
commitcf26b74d7aba1f6e764c31cfb4c7009d4e16f762 (patch)
treecdc91701c86cee958890817afdeee99bd7d20fcf
parent577575d95a81777156639c8831cffcd20c335c8e (diff)
Parse tab sets in VDX parser
Change-Id: Ic2f735f02c99046798867dae8d6a60821bb148b2
-rw-r--r--src/lib/VDXParser.cpp84
-rw-r--r--src/lib/VDXParser.h2
2 files changed, 86 insertions, 0 deletions
diff --git a/src/lib/VDXParser.cpp b/src/lib/VDXParser.cpp
index d09aff1..b5f6b8c 100644
--- a/src/lib/VDXParser.cpp
+++ b/src/lib/VDXParser.cpp
@@ -273,6 +273,10 @@ void libvisio::VDXParser::processXmlNode(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
readLayerMem(reader);
break;
+ case XML_TABS:
+ if (XML_READER_TYPE_ELEMENT == tokenType)
+ readTabs(reader);
+ break;
default:
break;
}
@@ -985,6 +989,86 @@ void libvisio::VDXParser::readForeignInfo(xmlTextReaderPtr reader)
while ((XML_FOREIGN != tokenId || XML_READER_TYPE_END_ELEMENT != tokenType) && 1 == ret && (!m_watcher || !m_watcher->isError()));
}
+void libvisio::VDXParser::readTabs(xmlTextReaderPtr reader)
+{
+ int ret = 1;
+ int tokenId = XML_TOKEN_INVALID;
+ int tokenType = -1;
+ unsigned ix = getIX(reader);
+ m_currentTabSet = &(m_shape.m_tabSets[ix]);
+
+ if (xmlTextReaderIsEmptyElement(reader))
+ {
+ m_currentTabSet->clear();
+ }
+ else
+ {
+ do
+ {
+ ret = xmlTextReaderRead(reader);
+ tokenId = getElementToken(reader);
+ if (XML_TOKEN_INVALID == tokenId)
+ {
+ VSD_DEBUG_MSG(("VDXParser::readTabs: unknown token %s\n", xmlTextReaderConstName(reader)));
+ }
+ tokenType = xmlTextReaderNodeType(reader);
+ if (XML_TAB == tokenId && XML_READER_TYPE_ELEMENT == tokenType)
+ readTab(reader);
+ }
+ while ((XML_TABS != tokenId || XML_READER_TYPE_END_ELEMENT != tokenType) && 1 == ret && (!m_watcher || !m_watcher->isError()));
+ }
+ m_currentTabSet = 0;
+}
+
+void libvisio::VDXParser::readTab(xmlTextReaderPtr reader)
+{
+ int ret = 1;
+ int tokenId = XML_TOKEN_INVALID;
+ int tokenType = -1;
+ unsigned ix = getIX(reader);
+
+ if (xmlTextReaderIsEmptyElement(reader))
+ {
+ m_currentTabSet->erase(ix);
+ }
+ else
+ {
+ do
+ {
+ ret = xmlTextReaderRead(reader);
+ tokenId = getElementToken(reader);
+ if (XML_TOKEN_INVALID == tokenId)
+ {
+ VSD_DEBUG_MSG(("VDXParser::readTab: unknown token %s\n", xmlTextReaderConstName(reader)));
+ }
+ tokenType = xmlTextReaderNodeType(reader);
+ switch (tokenId)
+ {
+ case XML_POSITION:
+ if (XML_READER_TYPE_ELEMENT == tokenType)
+ {
+ ret = readDoubleData((*m_currentTabSet)[ix].m_position, reader);
+ }
+ break;
+ case XML_ALIGNMENT:
+ if (XML_READER_TYPE_ELEMENT == tokenType)
+ {
+ ret = readByteData((*m_currentTabSet)[ix].m_alignment, reader);
+ }
+ break;
+ case XML_LEADER:
+ if (XML_READER_TYPE_ELEMENT == tokenType)
+ {
+ ret = readByteData((*m_currentTabSet)[ix].m_leader, reader);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ while ((XML_TAB != tokenId || XML_READER_TYPE_END_ELEMENT != tokenType) && 1 == ret && (!m_watcher || !m_watcher->isError()));
+ }
+}
/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
diff --git a/src/lib/VDXParser.h b/src/lib/VDXParser.h
index a56954d..0293911 100644
--- a/src/lib/VDXParser.h
+++ b/src/lib/VDXParser.h
@@ -62,6 +62,8 @@ private:
void readTextBlock(xmlTextReaderPtr reader);
void readForeignInfo(xmlTextReaderPtr reader);
void readLayerMem(xmlTextReaderPtr reader);
+ void readTabs(xmlTextReaderPtr reader);
+ void readTab(xmlTextReaderPtr reader);
void getBinaryData(xmlTextReaderPtr reader);