summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFridrich Štrba <fridrich.strba@bluewin.ch>2015-12-11 22:07:50 +0100
committerFridrich Štrba <fridrich.strba@bluewin.ch>2015-12-11 22:07:50 +0100
commit0099751db287f87e6d5b1dee5d2ef2479040d188 (patch)
tree410b6e940bdbdc061821bc575ec8917f0c4f1a8c
parent69ae3cb64d39575cb1875acc705763e3dabfb99a (diff)
Some layer in xml parsers WIP
Change-Id: Ic5a85349aeecfbc3885e61e668c50fb9e9c568f6
-rw-r--r--src/lib/VDXParser.cpp31
-rw-r--r--src/lib/VDXParser.h2
-rw-r--r--src/lib/VSDXMLParserBase.cpp22
-rw-r--r--src/lib/VSDXMLParserBase.h2
-rw-r--r--src/lib/VSDXParser.cpp4
-rw-r--r--src/lib/VSDXParser.h1
-rw-r--r--src/lib/tokens.txt2
7 files changed, 63 insertions, 1 deletions
diff --git a/src/lib/VDXParser.cpp b/src/lib/VDXParser.cpp
index e644999..b2da904 100644
--- a/src/lib/VDXParser.cpp
+++ b/src/lib/VDXParser.cpp
@@ -269,6 +269,10 @@ void libvisio::VDXParser::processXmlNode(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
readXForm1D(reader);
break;
+ case XML_LAYERMEM:
+ if (XML_READER_TYPE_ELEMENT == tokenType)
+ readLayerMem(reader);
+ break;
default:
break;
}
@@ -538,6 +542,33 @@ void libvisio::VDXParser::readXFormData(xmlTextReaderPtr reader)
while ((XML_XFORM != tokenId || XML_READER_TYPE_END_ELEMENT != tokenType) && 1 == ret && (!m_watcher || !m_watcher->isError()));
}
+void libvisio::VDXParser::readLayerMem(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(("VDXParser::readLayerMem: unknown token %s\n", xmlTextReaderConstName(reader)));
+ }
+ tokenType = xmlTextReaderNodeType(reader);
+ switch (tokenId)
+ {
+ case XML_LAYERMEMBER:
+ if (XML_READER_TYPE_ELEMENT == tokenType)
+ ret = readStringData(m_shape.m_layerMem, reader);
+ break;
+ default:
+ break;
+ }
+ }
+ while ((XML_LAYERMEM != tokenId || XML_READER_TYPE_END_ELEMENT != tokenType) && 1 == ret && (!m_watcher || !m_watcher->isError()));
+}
+
void libvisio::VDXParser::readTxtXForm(xmlTextReaderPtr reader)
{
int ret = 1;
diff --git a/src/lib/VDXParser.h b/src/lib/VDXParser.h
index 5bca33d..a56954d 100644
--- a/src/lib/VDXParser.h
+++ b/src/lib/VDXParser.h
@@ -24,6 +24,7 @@ class VDXParser : public VSDXMLParserBase
using VSDXMLParserBase::readDoubleData;
using VSDXMLParserBase::readBoolData;
using VSDXMLParserBase::readLongData;
+ using VSDXMLParserBase::readStringData;
public:
explicit VDXParser(librevenge::RVNGInputStream *input, librevenge::RVNGDrawingInterface *painter);
@@ -60,6 +61,7 @@ private:
void readFonts(xmlTextReaderPtr reader);
void readTextBlock(xmlTextReaderPtr reader);
void readForeignInfo(xmlTextReaderPtr reader);
+ void readLayerMem(xmlTextReaderPtr reader);
void getBinaryData(xmlTextReaderPtr reader);
diff --git a/src/lib/VSDXMLParserBase.cpp b/src/lib/VSDXMLParserBase.cpp
index 1394f15..2db6b39 100644
--- a/src/lib/VSDXMLParserBase.cpp
+++ b/src/lib/VSDXMLParserBase.cpp
@@ -1060,7 +1060,9 @@ void libvisio::VSDXMLParserBase::readPage(xmlTextReaderPtr reader)
const shared_ptr<xmlChar> id(xmlTextReaderGetAttribute(reader, BAD_CAST("ID")), xmlFree);
const shared_ptr<xmlChar> bgndPage(xmlTextReaderGetAttribute(reader, BAD_CAST("BackPage")), xmlFree);
const shared_ptr<xmlChar> background(xmlTextReaderGetAttribute(reader, BAD_CAST("Background")), xmlFree);
- const shared_ptr<xmlChar> pageName(xmlTextReaderGetAttribute(reader, BAD_CAST("Name")), xmlFree);
+ shared_ptr<xmlChar> pageName(xmlTextReaderGetAttribute(reader, BAD_CAST("Name")), xmlFree);
+ if (!pageName.get())
+ pageName.reset(xmlTextReaderGetAttribute(reader, BAD_CAST("NameU")), xmlFree);
if (id)
{
unsigned nId = (unsigned)xmlStringToLong(id);
@@ -1677,6 +1679,8 @@ void libvisio::VSDXMLParserBase::_flushShape()
m_collector->collectXFormData(m_currentShapeLevel+2, m_shape.m_xform);
+ m_collector->collectLayerMem(m_currentShapeLevel+2, m_shape.m_layerMem);
+
m_collector->collectMisc(m_currentShapeLevel+2, m_shape.m_misc);
if (m_shape.m_txtxform)
@@ -1971,6 +1975,22 @@ int libvisio::VSDXMLParserBase::readDoubleData(double &value, xmlTextReaderPtr r
return -1;
}
+int libvisio::VSDXMLParserBase::readStringData(libvisio::VSDName &text, xmlTextReaderPtr reader)
+{
+ const shared_ptr<xmlChar> stringValue(readStringData(reader), xmlFree);
+ if (stringValue)
+ {
+ VSD_DEBUG_MSG(("VSDXMLParserBase::readStringData stringValue %s\n", (const char *)stringValue.get()));
+ if (!xmlStrEqual(stringValue.get(), BAD_CAST("Themed")))
+ {
+ text.m_data = librevenge::RVNGBinaryData(stringValue.get(), xmlStrlen(stringValue.get()));
+ text.m_format = VSD_TEXT_UTF8;
+ }
+ return 1;
+ }
+ return -1;
+}
+
int libvisio::VSDXMLParserBase::readDoubleData(boost::optional<double> &value, xmlTextReaderPtr reader)
{
const shared_ptr<xmlChar> stringValue(readStringData(reader), xmlFree);
diff --git a/src/lib/VSDXMLParserBase.h b/src/lib/VSDXMLParserBase.h
index f60d920..6116584 100644
--- a/src/lib/VSDXMLParserBase.h
+++ b/src/lib/VSDXMLParserBase.h
@@ -78,6 +78,7 @@ protected:
int readExtendedColourData(boost::optional<Colour> &value, xmlTextReaderPtr reader);
int readNURBSData(boost::optional<NURBSData> &data, xmlTextReaderPtr reader);
int readPolylineData(boost::optional<PolylineData> &data, xmlTextReaderPtr reader);
+ int readStringData(VSDName &text, xmlTextReaderPtr reader);
virtual xmlChar *readStringData(xmlTextReaderPtr reader) = 0;
unsigned getIX(xmlTextReaderPtr reader);
@@ -112,6 +113,7 @@ protected:
void readCharIX(xmlTextReaderPtr reader);
void readParaIX(xmlTextReaderPtr reader);
void readLayerIX(xmlTextReaderPtr reader);
+ void readLayerMember(xmlTextReaderPtr reader);
void readStyleSheet(xmlTextReaderPtr reader);
void readPageSheet(xmlTextReaderPtr reader);
diff --git a/src/lib/VSDXParser.cpp b/src/lib/VSDXParser.cpp
index 43871db..fe8497e 100644
--- a/src/lib/VSDXParser.cpp
+++ b/src/lib/VSDXParser.cpp
@@ -1268,6 +1268,10 @@ void libvisio::VSDXParser::readShapeProperties(xmlTextReaderPtr reader)
m_shape.m_fillStyle.shadowFgColour = m_currentTheme.getThemeColour((unsigned)tmpValue);
}
break;
+ case XML_LAYERMEMBER:
+ if (XML_READER_TYPE_ELEMENT == tokenType)
+ ret = readStringData(m_shape.m_layerMem, reader);
+ break;
default:
if (XML_SECTION == tokenClass && XML_READER_TYPE_ELEMENT == tokenType)
ret = skipSection(reader);
diff --git a/src/lib/VSDXParser.h b/src/lib/VSDXParser.h
index fa1fca3..661f128 100644
--- a/src/lib/VSDXParser.h
+++ b/src/lib/VSDXParser.h
@@ -25,6 +25,7 @@ class VSDXParser : public VSDXMLParserBase
using VSDXMLParserBase::readDoubleData;
using VSDXMLParserBase::readBoolData;
using VSDXMLParserBase::readLongData;
+ using VSDXMLParserBase::readStringData;
public:
explicit VSDXParser(librevenge::RVNGInputStream *input, librevenge::RVNGDrawingInterface *painter);
diff --git a/src/lib/tokens.txt b/src/lib/tokens.txt
index 3a0bc69..7feb26d 100644
--- a/src/lib/tokens.txt
+++ b/src/lib/tokens.txt
@@ -105,6 +105,8 @@ IndLeft
IndRight
InfiniteLine
Layer
+LayerMem
+LayerMember
LeftMargin
Line
LineCap