[Libreoffice-commits] libvisio.git: src/lib
Fridrich Štrba
fridrich.strba at bluewin.ch
Fri Dec 11 02:53:34 PST 2015
src/lib/VDXParser.cpp | 4 ++++
src/lib/VSDCollector.h | 1 +
src/lib/VSDContentCollector.cpp | 8 +++++++-
src/lib/VSDContentCollector.h | 3 +++
src/lib/VSDParser.cpp | 22 +++++++++++++++++++++-
src/lib/VSDParser.h | 3 +++
src/lib/VSDStylesCollector.cpp | 5 +++++
src/lib/VSDStylesCollector.h | 1 +
src/lib/VSDXMLParserBase.cpp | 37 +++++++++++++++++++++++++++++++++++++
src/lib/VSDXMLParserBase.h | 1 +
src/lib/VSDXParser.cpp | 25 +++++++++++++++++++++++++
src/lib/VSDXParser.h | 1 +
src/lib/tokens.txt | 1 +
13 files changed, 110 insertions(+), 2 deletions(-)
New commits:
commit b5c9438c238c17a7128cbd37249ff284a3e46f94
Author: Fridrich Štrba <fridrich.strba at bluewin.ch>
Date: Fri Dec 11 11:53:09 2015 +0100
Reading some of the layer information in xml parsers too
Change-Id: Ifae38d2131e3f9bae403f93f3f15cfe2bb9f7982
diff --git a/src/lib/VDXParser.cpp b/src/lib/VDXParser.cpp
index a409b11..e644999 100644
--- a/src/lib/VDXParser.cpp
+++ b/src/lib/VDXParser.cpp
@@ -241,6 +241,10 @@ void libvisio::VDXParser::processXmlNode(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
readGeometry(reader);
break;
+ case XML_LAYER:
+ if (XML_READER_TYPE_ELEMENT == tokenType)
+ readLayerIX(reader);
+ break;
case XML_PARA:
if (XML_READER_TYPE_ELEMENT == tokenType)
readParaIX(reader);
diff --git a/src/lib/VSDCollector.h b/src/lib/VSDCollector.h
index 594fcf0..814e377 100644
--- a/src/lib/VSDCollector.h
+++ b/src/lib/VSDCollector.h
@@ -102,6 +102,7 @@ public:
virtual void collectName(unsigned id, unsigned level, const librevenge::RVNGBinaryData &name, TextFormat format) = 0;
virtual void collectPageSheet(unsigned id, unsigned level) = 0;
virtual void collectMisc(unsigned level, const VSDMisc &misc) = 0;
+ virtual void collectLayerList(unsigned level, const VSDLayerList &layerList) = 0;
// Style collectors
virtual void collectStyleSheet(unsigned id, unsigned level,unsigned parentLineStyle, unsigned parentFillStyle, unsigned parentTextStyle) = 0;
diff --git a/src/lib/VSDContentCollector.cpp b/src/lib/VSDContentCollector.cpp
index 8f2759a..fdcf9fa 100644
--- a/src/lib/VSDContentCollector.cpp
+++ b/src/lib/VSDContentCollector.cpp
@@ -57,7 +57,7 @@ libvisio::VSDContentCollector::VSDContentCollector(
m_textFormat(VSD_TEXT_ANSI), m_charFormats(), m_paraFormats(), m_lineStyle(), m_fillStyle(), m_textBlockStyle(),
m_themeReference(), m_defaultCharStyle(), m_defaultParaStyle(), m_currentStyleSheet(0), m_styles(styles),
m_stencils(stencils), m_stencilShape(0), m_isStencilStarted(false), m_currentGeometryCount(0),
- m_backgroundPageID(MINUS_ONE), m_currentPageID(0), m_currentPage(), m_pages(),
+ m_backgroundPageID(MINUS_ONE), m_currentPageID(0), m_currentPage(), m_pages(), m_layerList(),
m_splineControlPoints(), m_splineKnotVector(), m_splineX(0.0), m_splineY(0.0),
m_splineLastKnot(0.0), m_splineDegree(0), m_splineLevel(0), m_currentShapeLevel(0),
m_isBackgroundPage(false)
@@ -2973,4 +2973,10 @@ void libvisio::VSDContentCollector::collectMisc(unsigned level, const VSDMisc &m
m_misc = misc;
}
+void libvisio::VSDContentCollector::collectLayerList(unsigned level, const VSDLayerList &layerList)
+{
+ _handleLevelChange(level);
+ m_layerList = layerList;
+}
+
/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
diff --git a/src/lib/VSDContentCollector.h b/src/lib/VSDContentCollector.h
index a7d148a..7836935 100644
--- a/src/lib/VSDContentCollector.h
+++ b/src/lib/VSDContentCollector.h
@@ -122,6 +122,7 @@ public:
void collectName(unsigned id, unsigned level, const librevenge::RVNGBinaryData &name, TextFormat format);
void collectPageSheet(unsigned id, unsigned level);
void collectMisc(unsigned level, const VSDMisc &misc);
+ void collectLayerList(unsigned level, const VSDLayerList &layerList);
// Style collectors
@@ -292,6 +293,8 @@ private:
VSDPage m_currentPage;
VSDPages m_pages;
+ VSDLayerList m_layerList;
+
std::vector<std::pair<double, double> > m_splineControlPoints;
std::vector<double> m_splineKnotVector;
double m_splineX, m_splineY;
diff --git a/src/lib/VSDParser.cpp b/src/lib/VSDParser.cpp
index b348cbf..7d7ec48 100644
--- a/src/lib/VSDParser.cpp
+++ b/src/lib/VSDParser.cpp
@@ -24,7 +24,7 @@
libvisio::VSDParser::VSDParser(librevenge::RVNGInputStream *input, librevenge::RVNGDrawingInterface *painter, librevenge::RVNGInputStream *container)
: m_input(input), m_painter(painter), m_container(container), m_header(), m_collector(0), m_shapeList(), m_currentLevel(0),
m_stencils(), m_currentStencil(0), m_shape(), m_isStencilStarted(false), m_isInStyles(false),
- m_currentShapeLevel(0), m_currentShapeID(MINUS_ONE), m_extractStencils(false), m_colours(),
+ m_currentShapeLevel(0), m_currentShapeID(MINUS_ONE), m_currentLayerListLevel(0), m_extractStencils(false), m_colours(),
m_isBackgroundPage(false), m_isShapeStarted(false), m_shadowOffsetX(0.0), m_shadowOffsetY(0.0),
m_currentGeometryList(0), m_currentGeomListCount(0), m_fonts(), m_names(), m_namesMapMap(),
m_currentPageName(), m_currentLayerList()
@@ -593,6 +593,9 @@ void libvisio::VSDParser::handleChunk(librevenge::RVNGInputStream *input)
case VSD_LAYER_LIST:
readLayerList(input);
break;
+ case VSD_LAYER:
+ readLayer(input);
+ break;
default:
m_collector->collectUnhandledChunk(m_header.id, m_header.level);
}
@@ -673,6 +676,10 @@ void libvisio::VSDParser::_handleLevelChange(unsigned level)
{
if (level == m_currentLevel)
return;
+ if (level <= m_currentLayerListLevel)
+ {
+ m_collector->collectLayerList(level, m_currentLayerList);
+ }
if (level <= m_currentShapeLevel+1)
{
if (!m_shape.m_geometries.empty() && m_currentGeometryList && m_currentGeometryList->empty())
@@ -935,9 +942,22 @@ void libvisio::VSDParser::readPropList(librevenge::RVNGInputStream * /* input */
void libvisio::VSDParser::readLayerList(librevenge::RVNGInputStream * /* input */)
{
+ m_currentLayerListLevel = m_header.level;
m_currentLayerList.clear();
}
+void libvisio::VSDParser::readLayer(librevenge::RVNGInputStream *input)
+{
+ VSDLayer layer;
+ input->seek(8, librevenge::RVNG_SEEK_CUR);
+ layer.m_colourId = readU8(input);
+ layer.m_colour.r = readU8(input);
+ layer.m_colour.g = readU8(input);
+ layer.m_colour.b = readU8(input);
+ layer.m_colour.a = readU8(input);
+ m_currentLayerList.addLayer(m_header.id, layer);
+}
+
void libvisio::VSDParser::readPage(librevenge::RVNGInputStream *input)
{
input->seek(8, librevenge::RVNG_SEEK_CUR); //sub header length and children list length
diff --git a/src/lib/VSDParser.h b/src/lib/VSDParser.h
index e879790..973b134 100644
--- a/src/lib/VSDParser.h
+++ b/src/lib/VSDParser.h
@@ -113,6 +113,7 @@ protected:
void readMisc(librevenge::RVNGInputStream *input);
virtual void readLayerList(librevenge::RVNGInputStream *input);
+ virtual void readLayer(librevenge::RVNGInputStream *input);
// parser of one pass
bool parseDocument(librevenge::RVNGInputStream *input, unsigned shift);
@@ -153,6 +154,8 @@ protected:
unsigned m_currentShapeLevel;
unsigned m_currentShapeID;
+ unsigned m_currentLayerListLevel;
+
bool m_extractStencils;
std::vector<Colour> m_colours;
diff --git a/src/lib/VSDStylesCollector.cpp b/src/lib/VSDStylesCollector.cpp
index 12e3643..0db64d2 100644
--- a/src/lib/VSDStylesCollector.cpp
+++ b/src/lib/VSDStylesCollector.cpp
@@ -249,6 +249,11 @@ void libvisio::VSDStylesCollector::collectMisc(unsigned level, const VSDMisc & /
_handleLevelChange(level);
}
+void libvisio::VSDStylesCollector::collectLayerList(unsigned level, const VSDLayerList & /* layerList */)
+{
+ _handleLevelChange(level);
+}
+
void libvisio::VSDStylesCollector::collectUnhandledChunk(unsigned /* id */, unsigned level)
{
_handleLevelChange(level);
diff --git a/src/lib/VSDStylesCollector.h b/src/lib/VSDStylesCollector.h
index 22f73a1..5f91abb 100644
--- a/src/lib/VSDStylesCollector.h
+++ b/src/lib/VSDStylesCollector.h
@@ -115,6 +115,7 @@ public:
void collectName(unsigned id, unsigned level, const librevenge::RVNGBinaryData &name, TextFormat format);
void collectPageSheet(unsigned id, unsigned level);
void collectMisc(unsigned level, const VSDMisc &misc);
+ void collectLayerList(unsigned level, const VSDLayerList &layerList);
// Style collectors
void collectStyleSheet(unsigned id, unsigned level,unsigned parentLineStyle, unsigned parentFillStyle, unsigned parentTextStyle);
diff --git a/src/lib/VSDXMLParserBase.cpp b/src/lib/VSDXMLParserBase.cpp
index 7f38bca..257fddc 100644
--- a/src/lib/VSDXMLParserBase.cpp
+++ b/src/lib/VSDXMLParserBase.cpp
@@ -1335,6 +1335,43 @@ void libvisio::VSDXMLParserBase::readCharIX(xmlTextReaderPtr reader)
}
}
+void libvisio::VSDXMLParserBase::readLayerIX(xmlTextReaderPtr reader)
+{
+ if (xmlTextReaderIsEmptyElement(reader))
+ return;
+
+ // unsigned ix = getIX(reader);
+
+ int ret = 1;
+ int tokenId = XML_TOKEN_INVALID;
+ int tokenType = -1;
+ // int level = getElementDepth(reader);
+
+ Colour colour;
+
+ do
+ {
+ ret = xmlTextReaderRead(reader);
+ tokenId = getElementToken(reader);
+ if (XML_TOKEN_INVALID == tokenId)
+ {
+ VSD_DEBUG_MSG(("VSDXMLParserBase::readLayerIX: unknown token %s\n", xmlTextReaderConstName(reader)));
+ }
+ tokenType = xmlTextReaderNodeType(reader);
+
+ switch (tokenId)
+ {
+ case XML_COLOR:
+ if (XML_READER_TYPE_ELEMENT == tokenType)
+ ret = readExtendedColourData(colour, reader);
+ break;
+ default:
+ break;
+ }
+ }
+ while (((XML_LAYER != tokenId && XML_ROW != tokenId) || XML_READER_TYPE_END_ELEMENT != tokenType) && 1 == ret && (!m_watcher || !m_watcher->isError()));
+}
+
void libvisio::VSDXMLParserBase::readParaIX(xmlTextReaderPtr reader)
{
if (xmlTextReaderIsEmptyElement(reader))
diff --git a/src/lib/VSDXMLParserBase.h b/src/lib/VSDXMLParserBase.h
index 6698a9d..f60d920 100644
--- a/src/lib/VSDXMLParserBase.h
+++ b/src/lib/VSDXMLParserBase.h
@@ -111,6 +111,7 @@ protected:
void readText(xmlTextReaderPtr reader);
void readCharIX(xmlTextReaderPtr reader);
void readParaIX(xmlTextReaderPtr reader);
+ void readLayerIX(xmlTextReaderPtr reader);
void readStyleSheet(xmlTextReaderPtr reader);
void readPageSheet(xmlTextReaderPtr reader);
diff --git a/src/lib/VSDXParser.cpp b/src/lib/VSDXParser.cpp
index 9a6a49d..43871db 100644
--- a/src/lib/VSDXParser.cpp
+++ b/src/lib/VSDXParser.cpp
@@ -845,6 +845,10 @@ void libvisio::VSDXParser::readStyleProperties(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
ret = readByteData(textDirection, reader);
break;
+ case XML_LAYER:
+ if (XML_READER_TYPE_ELEMENT == tokenType)
+ readLayer(reader);
+ break;
case XML_PARAGRAPH:
if (XML_READER_TYPE_ELEMENT == tokenType)
readParagraph(reader);
@@ -1276,6 +1280,27 @@ void libvisio::VSDXParser::readShapeProperties(xmlTextReaderPtr reader)
processXmlNode(reader);
}
+void libvisio::VSDXParser::readLayer(xmlTextReaderPtr reader)
+{
+ int ret = 1;
+ int tokenId = XML_TOKEN_INVALID;
+ int tokenType = -1;
+
+ do
+ {
+ ret = xmlTextReaderRead(reader);
+ tokenId = getElementToken(reader);
+ if (XML_TOKEN_INVALID == tokenId)
+ {
+ VSD_DEBUG_MSG(("VSDXParser::readLayer: unknown token %s\n", xmlTextReaderConstName(reader)));
+ }
+ tokenType = xmlTextReaderNodeType(reader);
+ if (XML_ROW == tokenId && XML_READER_TYPE_ELEMENT == tokenType)
+ readLayerIX(reader);
+ }
+ while ((XML_SECTION != tokenId || XML_READER_TYPE_END_ELEMENT != tokenType) && 1 == ret && (!m_watcher || !m_watcher->isError()));
+}
+
void libvisio::VSDXParser::readParagraph(xmlTextReaderPtr reader)
{
int ret = 1;
diff --git a/src/lib/VSDXParser.h b/src/lib/VSDXParser.h
index 9eef41e..fa1fca3 100644
--- a/src/lib/VSDXParser.h
+++ b/src/lib/VSDXParser.h
@@ -70,6 +70,7 @@ private:
void getBinaryData(xmlTextReaderPtr reader);
+ void readLayer(xmlTextReaderPtr reader);
void readParagraph(xmlTextReaderPtr reader);
void readCharacter(xmlTextReaderPtr reader);
void readFonts(xmlTextReaderPtr reader);
diff --git a/src/lib/tokens.txt b/src/lib/tokens.txt
index c165c0f..3a0bc69 100644
--- a/src/lib/tokens.txt
+++ b/src/lib/tokens.txt
@@ -104,6 +104,7 @@ IndFirst
IndLeft
IndRight
InfiniteLine
+Layer
LeftMargin
Line
LineCap
More information about the Libreoffice-commits
mailing list