[Libreoffice-commits] libvisio.git: src/lib
Fridrich Štrba
fridrich.strba at bluewin.ch
Fri Dec 11 04:50:39 PST 2015
src/lib/VSDCollector.h | 2 -
src/lib/VSDContentCollector.cpp | 7 +++--
src/lib/VSDContentCollector.h | 4 ++-
src/lib/VSDParser.cpp | 47 +++++++++++++++++++++++++++-------------
src/lib/VSDParser.h | 2 -
src/lib/VSDStylesCollector.cpp | 2 -
src/lib/VSDStylesCollector.h | 2 -
src/lib/VSDXMLParserBase.cpp | 21 ++++++++++++++---
8 files changed, 60 insertions(+), 27 deletions(-)
New commits:
commit b689fb10a62927b4325661e7783c4f9cb670b000
Author: Fridrich Štrba <fridrich.strba at bluewin.ch>
Date: Fri Dec 11 13:50:12 2015 +0100
Some little changes to parse the layerlist the same way everywhere
Change-Id: Ie7814f465f8f62c5f921f2042c1c305d1a975713
diff --git a/src/lib/VSDCollector.h b/src/lib/VSDCollector.h
index 814e377..f118d14 100644
--- a/src/lib/VSDCollector.h
+++ b/src/lib/VSDCollector.h
@@ -102,7 +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;
+ virtual void collectLayer(unsigned id, unsigned level, const VSDLayer &layer) = 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 fdcf9fa..79e884a 100644
--- a/src/lib/VSDContentCollector.cpp
+++ b/src/lib/VSDContentCollector.cpp
@@ -60,7 +60,7 @@ libvisio::VSDContentCollector::VSDContentCollector(
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)
+ m_isBackgroundPage(false), m_currentLayerList()
{
}
@@ -2158,6 +2158,7 @@ void libvisio::VSDContentCollector::collectPageSheet(unsigned /* id */, unsigned
{
_handleLevelChange(level);
m_currentShapeLevel = level;
+ m_currentLayerList.clear();
}
void libvisio::VSDContentCollector::collectStyleSheet(unsigned id, unsigned level, unsigned lineStyleParent, unsigned fillStyleParent, unsigned textStyleParent)
@@ -2973,10 +2974,10 @@ void libvisio::VSDContentCollector::collectMisc(unsigned level, const VSDMisc &m
m_misc = misc;
}
-void libvisio::VSDContentCollector::collectLayerList(unsigned level, const VSDLayerList &layerList)
+void libvisio::VSDContentCollector::collectLayer(unsigned id, unsigned level, const VSDLayer &layer)
{
_handleLevelChange(level);
- m_layerList = layerList;
+ m_currentLayerList.addLayer(id, layer);
}
/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
diff --git a/src/lib/VSDContentCollector.h b/src/lib/VSDContentCollector.h
index 7836935..fc60a40 100644
--- a/src/lib/VSDContentCollector.h
+++ b/src/lib/VSDContentCollector.h
@@ -122,7 +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);
+ void collectLayer(unsigned id, unsigned level, const VSDLayer &layer);
// Style collectors
@@ -303,6 +303,8 @@ private:
unsigned m_splineLevel;
unsigned m_currentShapeLevel;
bool m_isBackgroundPage;
+
+ VSDLayerList m_currentLayerList;
};
} // namespace libvisio
diff --git a/src/lib/VSDParser.cpp b/src/lib/VSDParser.cpp
index 7d7ec48..cbb8192 100644
--- a/src/lib/VSDParser.cpp
+++ b/src/lib/VSDParser.cpp
@@ -27,7 +27,7 @@ libvisio::VSDParser::VSDParser(librevenge::RVNGInputStream *input, librevenge::R
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()
+ m_currentPageName()
{}
libvisio::VSDParser::~VSDParser()
@@ -676,10 +676,6 @@ 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())
@@ -913,7 +909,6 @@ void libvisio::VSDParser::readCharList(librevenge::RVNGInputStream *input)
m_shape.m_charList.setElementsOrder(characterOrder);
}
-
}
void libvisio::VSDParser::readParaList(librevenge::RVNGInputStream *input)
@@ -940,22 +935,44 @@ void libvisio::VSDParser::readPropList(librevenge::RVNGInputStream * /* input */
{
}
-void libvisio::VSDParser::readLayerList(librevenge::RVNGInputStream * /* input */)
+void libvisio::VSDParser::readLayerList(librevenge::RVNGInputStream *input)
{
- m_currentLayerListLevel = m_header.level;
- m_currentLayerList.clear();
+ // We want the collectors to still get the level information
+ if (!m_isStencilStarted)
+ m_collector->collectUnhandledChunk(m_header.id, m_header.level);
+
+ if (m_header.trailer)
+ {
+ uint32_t subHeaderLength = readU32(input);
+ uint32_t childrenListLength = readU32(input);
+ input->seek(subHeaderLength, librevenge::RVNG_SEEK_CUR);
+ std::vector<unsigned> layerOrder;
+ layerOrder.reserve(childrenListLength / sizeof(uint32_t));
+ for (unsigned i = 0; i < (childrenListLength / sizeof(uint32_t)); i++)
+ layerOrder.push_back(readU32(input));
+ }
}
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);
+ unsigned char colourId = readU8(input);
+ if (colourId == 0xff)
+ {
+ layer.m_colourId = MINUS_ONE;
+ input->seek(4, librevenge::RVNG_SEEK_CUR);
+ }
+ else
+ {
+ layer.m_colourId = colourId;
+ 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_collector->collectLayer(m_header.id, m_header.level, layer);
}
void libvisio::VSDParser::readPage(librevenge::RVNGInputStream *input)
diff --git a/src/lib/VSDParser.h b/src/lib/VSDParser.h
index 973b134..d43e52f 100644
--- a/src/lib/VSDParser.h
+++ b/src/lib/VSDParser.h
@@ -172,7 +172,7 @@ protected:
std::map<unsigned, VSDName> m_names;
std::map<unsigned, std::map<unsigned, VSDName> > m_namesMapMap;
VSDName m_currentPageName;
- VSDLayerList m_currentLayerList;
+
private:
VSDParser();
diff --git a/src/lib/VSDStylesCollector.cpp b/src/lib/VSDStylesCollector.cpp
index 0db64d2..f2bddc0 100644
--- a/src/lib/VSDStylesCollector.cpp
+++ b/src/lib/VSDStylesCollector.cpp
@@ -249,7 +249,7 @@ void libvisio::VSDStylesCollector::collectMisc(unsigned level, const VSDMisc & /
_handleLevelChange(level);
}
-void libvisio::VSDStylesCollector::collectLayerList(unsigned level, const VSDLayerList & /* layerList */)
+void libvisio::VSDStylesCollector::collectLayer(unsigned /* id */, unsigned level, const VSDLayer & /* layer */)
{
_handleLevelChange(level);
}
diff --git a/src/lib/VSDStylesCollector.h b/src/lib/VSDStylesCollector.h
index 5f91abb..f8b83c2 100644
--- a/src/lib/VSDStylesCollector.h
+++ b/src/lib/VSDStylesCollector.h
@@ -115,7 +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);
+ void collectLayer(unsigned id, unsigned level, const VSDLayer &layer);
// 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 257fddc..1394f15 100644
--- a/src/lib/VSDXMLParserBase.cpp
+++ b/src/lib/VSDXMLParserBase.cpp
@@ -1340,14 +1340,14 @@ void libvisio::VSDXMLParserBase::readLayerIX(xmlTextReaderPtr reader)
if (xmlTextReaderIsEmptyElement(reader))
return;
- // unsigned ix = getIX(reader);
+ unsigned ix = getIX(reader);
int ret = 1;
int tokenId = XML_TOKEN_INVALID;
int tokenType = -1;
- // int level = getElementDepth(reader);
+ int level = getElementDepth(reader);
- Colour colour;
+ VSDLayer layer;
do
{
@@ -1363,13 +1363,26 @@ void libvisio::VSDXMLParserBase::readLayerIX(xmlTextReaderPtr reader)
{
case XML_COLOR:
if (XML_READER_TYPE_ELEMENT == tokenType)
- ret = readExtendedColourData(colour, reader);
+ {
+ Colour colour;
+ long idx;
+ ret = readExtendedColourData(colour, idx, reader);
+ if (idx < 0 || idx >= 255)
+ layer.m_colourId = MINUS_ONE;
+ else
+ {
+ layer.m_colourId = idx;
+ layer.m_colour = colour;
+ }
+ }
break;
default:
break;
}
}
while (((XML_LAYER != tokenId && XML_ROW != tokenId) || XML_READER_TYPE_END_ELEMENT != tokenType) && 1 == ret && (!m_watcher || !m_watcher->isError()));
+
+ m_collector->collectLayer(ix, level, layer);
}
void libvisio::VSDXMLParserBase::readParaIX(xmlTextReaderPtr reader)
More information about the Libreoffice-commits
mailing list