[Libreoffice-commits] libvisio.git: 8 commits - src/lib
Fridrich Štrba
fridrich.strba at bluewin.ch
Wed Dec 16 06:43:02 PST 2015
src/lib/VDXParser.cpp | 84 +++++++++++++++++++++++++++++++++++++
src/lib/VDXParser.h | 2
src/lib/VSDCollector.h | 1
src/lib/VSDContentCollector.cpp | 68 +++++++++++++++++++++++++++++-
src/lib/VSDContentCollector.h | 2
src/lib/VSDParser.cpp | 17 ++++---
src/lib/VSDParser.h | 1
src/lib/VSDStencils.cpp | 9 ++--
src/lib/VSDStencils.h | 3 -
src/lib/VSDStylesCollector.cpp | 5 ++
src/lib/VSDStylesCollector.h | 1
src/lib/VSDTypes.h | 16 +++++--
src/lib/VSDXMLParserBase.cpp | 13 +++++
src/lib/VSDXMLParserBase.h | 2
src/lib/VSDXParser.cpp | 89 ++++++++++++++++++++++++++++++++++++++++
src/lib/VSDXParser.h | 3 +
src/lib/tokens.txt | 1
17 files changed, 298 insertions(+), 19 deletions(-)
New commits:
commit 9593bbf3b9ea47ccc864536c94f154ce68bad22f
Author: Fridrich Štrba <fridrich.strba at bluewin.ch>
Date: Wed Dec 16 15:42:35 2015 +0100
Collect and output tab stops
Change-Id: I6ab0b673b1f11b204ab0fbd4087b8a4dddad6027
diff --git a/src/lib/VSDCollector.h b/src/lib/VSDCollector.h
index 81914b6..fd4adeb 100644
--- a/src/lib/VSDCollector.h
+++ b/src/lib/VSDCollector.h
@@ -104,6 +104,7 @@ public:
virtual void collectMisc(unsigned level, const VSDMisc &misc) = 0;
virtual void collectLayer(unsigned id, unsigned level, const VSDLayer &layer) = 0;
virtual void collectLayerMem(unsigned level, const VSDName &layerMem) = 0;
+ virtual void collectTabsDataList(unsigned level, const std::map<unsigned, VSDTabSet> &tabSets) = 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 be5fa13..c736f0e 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_currentLayerList(), m_currentLayerMem()
+ m_isBackgroundPage(false), m_currentLayerList(), m_currentLayerMem(), m_tabSets()
{
}
@@ -441,11 +441,22 @@ void libvisio::VSDContentCollector::_flushText()
m_paraFormats[iPara].charCount = numCharsInText;
}
+ numCharsInText = (unsigned)(m_textFormat == VSD_TEXT_UTF16 ? m_textStream.size() / 2 : m_textStream.size());
+
+ for (unsigned iTab = 0; iTab < m_tabSets.size(); iTab++)
+ {
+ if (m_tabSets[iTab].m_numChars)
+ numCharsInText -= m_tabSets[iTab].m_numChars;
+ else
+ m_tabSets[iTab].m_numChars = numCharsInText;
+ }
+
_appendVisibleAndPrintable(textBlockProps);
m_shapeOutputText->addStartTextObject(textBlockProps);
unsigned charIndex = 0;
+ unsigned tabIndex = 0;
unsigned paraCharCount = 0;
unsigned long textBufferPosition = 0;
const unsigned char *pTextBuffer = m_textStream.getDataBuffer();
@@ -492,10 +503,50 @@ void libvisio::VSDContentCollector::_flushText()
else
paraProps.insert("fo:line-height", -(*paraIt).spLine, librevenge::RVNG_PERCENT);
- m_shapeOutputText->addOpenParagraph(paraProps);
-
paraCharCount = (*paraIt).charCount;
+ if (!m_tabSets.empty())
+ {
+ if (paraCharCount < m_tabSets[tabIndex].m_numChars)
+ {
+ // Insert duplicate
+ std::vector<VSDTabSet>::iterator tabIt = m_tabSets.begin() + tabIndex;
+ VSDTabSet tmpTabSet = m_tabSets[tabIndex];
+ m_tabSets.insert(tabIt, tmpTabSet);
+ m_tabSets[tabIndex].m_numChars = paraCharCount;
+ m_tabSets[tabIndex+1].m_numChars -= paraCharCount;
+ }
+
+ librevenge::RVNGPropertyListVector tmpTabSet;
+ for (std::map<unsigned, VSDTabStop>::const_iterator iterTS = m_tabSets[tabIndex].m_tabStops.begin();
+ iterTS != m_tabSets[tabIndex].m_tabStops.end(); ++iterTS)
+ {
+ librevenge::RVNGPropertyList tmpTabStop;
+ tmpTabStop.insert("style:position", iterTS->second.m_position);
+ switch (iterTS->second.m_alignment)
+ {
+ case 0:
+ tmpTabStop.insert("style:type", "left");
+ break;
+ case 1:
+ tmpTabStop.insert("style:type", "center");
+ break;
+ case 2:
+ tmpTabStop.insert("style:type", "right");
+ break;
+ default:
+ tmpTabStop.insert("style:type", "char");
+ tmpTabStop.insert("style:char", ".");
+ break;
+ }
+ tmpTabSet.append(tmpTabStop);
+ }
+ if (!tmpTabSet.empty())
+ paraProps.insert("style:tab-stops", tmpTabSet);
+ }
+
+ m_shapeOutputText->addOpenParagraph(paraProps);
+
// Find char format that overlaps
while (charIndex < m_charFormats.size() && paraCharCount)
{
@@ -634,6 +685,7 @@ void libvisio::VSDContentCollector::_flushText()
charIndex++;
}
m_shapeOutputText->addCloseParagraph();
+ tabIndex++;
}
m_shapeOutputText->addEndTextObject();
@@ -2123,6 +2175,16 @@ void libvisio::VSDContentCollector::collectCharIX(unsigned /* id */ , unsigned l
m_charFormats.push_back(format);
}
+void libvisio::VSDContentCollector::collectTabsDataList(unsigned level, const std::map<unsigned, VSDTabSet> &tabSets)
+{
+ _handleLevelChange(level);
+
+ m_tabSets.clear();
+ for (std::map<unsigned, VSDTabSet>::const_iterator iter = tabSets.begin(); iter != tabSets.end(); ++iter)
+ if (tabSets.begin() == iter || iter->second.m_numChars)
+ m_tabSets.push_back(iter->second);
+}
+
void libvisio::VSDContentCollector::collectDefaultCharStyle(unsigned charCount,
const boost::optional<VSDName> &font, const boost::optional<Colour> &fontColour, const boost::optional<double> &fontSize, const boost::optional<bool> &bold,
const boost::optional<bool> &italic, const boost::optional<bool> &underline, const boost::optional<bool> &doubleunderline, const boost::optional<bool> &strikeout,
diff --git a/src/lib/VSDContentCollector.h b/src/lib/VSDContentCollector.h
index cb4a636..503cead 100644
--- a/src/lib/VSDContentCollector.h
+++ b/src/lib/VSDContentCollector.h
@@ -124,6 +124,7 @@ public:
void collectMisc(unsigned level, const VSDMisc &misc);
void collectLayer(unsigned id, unsigned level, const VSDLayer &layer);
void collectLayerMem(unsigned level, const VSDName &layerMem);
+ void collectTabsDataList(unsigned level, const std::map<unsigned, VSDTabSet> &tabSets);
// Style collectors
void collectStyleSheet(unsigned id, unsigned level, unsigned parentLineStyle, unsigned parentFillStyle, unsigned parentTextStyle);
@@ -307,6 +308,7 @@ private:
VSDLayerList m_currentLayerList;
std::vector<unsigned> m_currentLayerMem;
+ std::vector<VSDTabSet> m_tabSets;
};
} // namespace libvisio
diff --git a/src/lib/VSDParser.cpp b/src/lib/VSDParser.cpp
index c24227a..72dfe00 100644
--- a/src/lib/VSDParser.cpp
+++ b/src/lib/VSDParser.cpp
@@ -660,6 +660,8 @@ void libvisio::VSDParser::_flushShape()
if (m_shape.m_foreign && m_shape.m_foreign->data.size())
m_collector->collectForeignData(m_currentShapeLevel+1, m_shape.m_foreign->data);
+ m_collector->collectTabsDataList(m_currentShapeLevel+1, m_shape.m_tabSets);
+
if (!m_shape.m_fields.empty())
m_shape.m_fields.handle(m_collector);
diff --git a/src/lib/VSDStylesCollector.cpp b/src/lib/VSDStylesCollector.cpp
index 0fefbb7..5df617a 100644
--- a/src/lib/VSDStylesCollector.cpp
+++ b/src/lib/VSDStylesCollector.cpp
@@ -294,6 +294,11 @@ void libvisio::VSDStylesCollector::collectCharIX(unsigned /* id */, unsigned lev
_handleLevelChange(level);
}
+void libvisio::VSDStylesCollector::collectTabsDataList(unsigned level, const std::map<unsigned, VSDTabSet> & /* tabSets */)
+{
+ _handleLevelChange(level);
+}
+
void libvisio::VSDStylesCollector::collectDefaultCharStyle(unsigned /* charCount */,
const boost::optional<VSDName> & /* font */, const boost::optional<Colour> & /* fontColour */, const boost::optional<double> & /* fontSize */,
const boost::optional<bool> & /* bold */, const boost::optional<bool> & /* italic */, const boost::optional<bool> & /* underline */,
diff --git a/src/lib/VSDStylesCollector.h b/src/lib/VSDStylesCollector.h
index 65304fc..7457e2a 100644
--- a/src/lib/VSDStylesCollector.h
+++ b/src/lib/VSDStylesCollector.h
@@ -117,6 +117,7 @@ public:
void collectMisc(unsigned level, const VSDMisc &misc);
void collectLayer(unsigned id, unsigned level, const VSDLayer &layer);
void collectLayerMem(unsigned level, const VSDName &layerMem);
+ void collectTabsDataList(unsigned level, const std::map<unsigned, VSDTabSet> &tabSets);
// 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 f95ac87..a8a7b68 100644
--- a/src/lib/VSDXMLParserBase.cpp
+++ b/src/lib/VSDXMLParserBase.cpp
@@ -1084,6 +1084,7 @@ void libvisio::VSDXMLParserBase::readText(xmlTextReaderPtr reader)
unsigned cp = 0;
unsigned pp = 0;
+ unsigned tp = 0;
m_shape.m_text.clear();
m_shape.m_charList.resetCharCount();
m_shape.m_paraList.resetCharCount();
@@ -1109,6 +1110,9 @@ void libvisio::VSDXMLParserBase::readText(xmlTextReaderPtr reader)
case XML_PP:
pp = getIX(reader);
break;
+ case XML_TP:
+ tp = getIX(reader);
+ break;
default:
if (XML_READER_TYPE_TEXT == tokenType || XML_READER_TYPE_SIGNIFICANT_WHITESPACE == tokenType)
{
@@ -1152,6 +1156,8 @@ void libvisio::VSDXMLParserBase::readText(xmlTextReaderPtr reader)
m_shape.m_paraList.setCharCount(pp, charCount);
}
+ m_shape.m_tabSets[tp].m_numChars += (unsigned)tmpText.size();
+
m_shape.m_text.append(tmpText);
m_shape.m_textFormat = VSD_TEXT_UTF8;
}
@@ -1740,6 +1746,8 @@ void libvisio::VSDXMLParserBase::_flushShape()
if (m_shape.m_foreign && m_shape.m_foreign->data.size())
m_collector->collectForeignData(m_currentShapeLevel+1, m_shape.m_foreign->data);
+ m_collector->collectTabsDataList(m_currentShapeLevel+1, m_shape.m_tabSets);
+
if (!m_shape.m_fields.empty())
m_shape.m_fields.handle(m_collector);
diff --git a/src/lib/tokens.txt b/src/lib/tokens.txt
index d732a47..590944a 100644
--- a/src/lib/tokens.txt
+++ b/src/lib/tokens.txt
@@ -207,6 +207,7 @@ TextBlock
TextDirection
TextXForm
TopMargin
+tp
TxtAngle
TxtHeight
TxtLocPinX
commit 2004a9be46f6a2e31e3da9889d365b546feb63b0
Author: Fridrich Štrba <fridrich.strba at bluewin.ch>
Date: Wed Dec 16 11:04:57 2015 +0100
Parse the tabs in VSD and account for character count
Change-Id: I7e4f41cf87986ffa6a573ebe821ec0e87c3846a8
diff --git a/src/lib/VDXParser.cpp b/src/lib/VDXParser.cpp
index b5f6b8c..cc59b8b 100644
--- a/src/lib/VDXParser.cpp
+++ b/src/lib/VDXParser.cpp
@@ -995,7 +995,7 @@ void libvisio::VDXParser::readTabs(xmlTextReaderPtr reader)
int tokenId = XML_TOKEN_INVALID;
int tokenType = -1;
unsigned ix = getIX(reader);
- m_currentTabSet = &(m_shape.m_tabSets[ix]);
+ m_currentTabSet = &(m_shape.m_tabSets[ix].m_tabStops);
if (xmlTextReaderIsEmptyElement(reader))
{
diff --git a/src/lib/VSDParser.cpp b/src/lib/VSDParser.cpp
index 0429dd1..c24227a 100644
--- a/src/lib/VSDParser.cpp
+++ b/src/lib/VSDParser.cpp
@@ -771,17 +771,15 @@ void libvisio::VSDParser::readOLEData(librevenge::RVNGInputStream *input)
void libvisio::VSDParser::readTabsData(librevenge::RVNGInputStream *input)
{
- /* unsigned charCount = */ readU32(input);
+ m_shape.m_tabSets[m_header.id].m_numChars = readU32(input);
unsigned char numStops = readU8(input);
- std::vector<VSDTabStop> tabStops;
+ m_shape.m_tabSets[m_header.id].m_tabStops.clear();
for (unsigned char i = 0; i < numStops; ++i)
{
- VSDTabStop tabStop;
input->seek(1, librevenge::RVNG_SEEK_CUR);
- tabStop.m_position = readDouble(input);
- tabStop.m_alignment = readU8(input);
- tabStop.m_leader = readU8(input);
- tabStops.push_back(tabStop);
+ m_shape.m_tabSets[m_header.id].m_tabStops[i].m_position = readDouble(input);
+ m_shape.m_tabSets[m_header.id].m_tabStops[i].m_alignment = readU8(input);
+ m_shape.m_tabSets[m_header.id].m_tabStops[i].m_leader = readU8(input);
}
}
diff --git a/src/lib/VSDStencils.h b/src/lib/VSDStencils.h
index cad4b30..03dae0d 100644
--- a/src/lib/VSDStencils.h
+++ b/src/lib/VSDStencils.h
@@ -46,7 +46,7 @@ public:
VSDCharacterList m_charList;
VSDOptionalParaStyle m_paraStyle;
VSDParagraphList m_paraList;
- std::map<unsigned, std::map<unsigned, VSDTabStop> > m_tabSets;
+ std::map<unsigned, VSDTabSet> m_tabSets;
librevenge::RVNGBinaryData m_text;
std::map<unsigned, VSDName> m_names;
TextFormat m_textFormat;
diff --git a/src/lib/VSDTypes.h b/src/lib/VSDTypes.h
index 214db21..3a4fce4 100644
--- a/src/lib/VSDTypes.h
+++ b/src/lib/VSDTypes.h
@@ -11,6 +11,7 @@
#define VSDTYPES_H
#include <vector>
+#include <map>
#include <librevenge/librevenge.h>
#define FROM_OPTIONAL(t, u) !!t ? t.get() : u
@@ -220,6 +221,15 @@ struct VSDTabStop
m_leader(tabStop.m_leader) {}
};
+struct VSDTabSet
+{
+ unsigned m_numChars;
+ std::map<unsigned, VSDTabStop> m_tabStops;
+ VSDTabSet() : m_numChars(0), m_tabStops() {}
+ VSDTabSet(const VSDTabSet &tabSet) :
+ m_numChars(tabSet.m_numChars), m_tabStops(tabSet.m_tabStops) {}
+};
+
} // namespace libvisio
#endif /* VSDTYPES_H */
diff --git a/src/lib/VSDXParser.cpp b/src/lib/VSDXParser.cpp
index 22d20ac..22aa719 100644
--- a/src/lib/VSDXParser.cpp
+++ b/src/lib/VSDXParser.cpp
@@ -1372,7 +1372,7 @@ void libvisio::VSDXParser::readTabRow(xmlTextReaderPtr reader)
int tokenType = -1;
unsigned ix = getIX(reader);
- m_currentTabSet = &(m_shape.m_tabSets[ix]);
+ m_currentTabSet = &(m_shape.m_tabSets[ix].m_tabStops);
if (xmlTextReaderIsEmptyElement(reader))
{
commit 20237fd6975368400d97fbf7ac18eae4fce98239
Author: Fridrich Štrba <fridrich.strba at bluewin.ch>
Date: Wed Dec 16 10:36:19 2015 +0100
Parse tab sets in VSDX parser
Change-Id: Iffdf1981a525607d216daee0507775236dbd9593
diff --git a/src/lib/VSDXParser.cpp b/src/lib/VSDXParser.cpp
index 55b2d20..22d20ac 100644
--- a/src/lib/VSDXParser.cpp
+++ b/src/lib/VSDXParser.cpp
@@ -1279,6 +1279,10 @@ void libvisio::VSDXParser::readShapeProperties(xmlTextReaderPtr reader)
if (XML_READER_TYPE_ELEMENT == tokenType)
ret = readStringData(m_shape.m_layerMem, reader);
break;
+ case XML_TABS:
+ if (XML_READER_TYPE_ELEMENT == tokenType)
+ readTabs(reader);
+ break;
default:
if (XML_SECTION == tokenClass && XML_READER_TYPE_ELEMENT == tokenType)
ret = skipSection(reader);
@@ -1333,6 +1337,91 @@ void libvisio::VSDXParser::readParagraph(xmlTextReaderPtr reader)
while ((XML_SECTION != tokenId || XML_READER_TYPE_END_ELEMENT != tokenType) && 1 == ret && (!m_watcher || !m_watcher->isError()));
}
+void libvisio::VSDXParser::readTabs(xmlTextReaderPtr reader)
+{
+ int ret = 1;
+ int tokenId = XML_TOKEN_INVALID;
+ int tokenType = -1;
+
+ if (xmlTextReaderIsEmptyElement(reader))
+ {
+ m_shape.m_tabSets.clear();
+ }
+ else
+ {
+ do
+ {
+ ret = xmlTextReaderRead(reader);
+ tokenId = getElementToken(reader);
+ if (XML_TOKEN_INVALID == tokenId)
+ {
+ VSD_DEBUG_MSG(("VSDXParser::readTabs: unknown token %s\n", xmlTextReaderConstName(reader)));
+ }
+ tokenType = xmlTextReaderNodeType(reader);
+ if (XML_ROW == tokenId && XML_READER_TYPE_ELEMENT == tokenType)
+ readTabRow(reader);
+ }
+ while ((XML_SECTION != tokenId || XML_READER_TYPE_END_ELEMENT != tokenType) && 1 == ret && (!m_watcher || !m_watcher->isError()));
+ }
+}
+
+void libvisio::VSDXParser::readTabRow(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(("VSDXParser::readTabs: unknown token %s\n", xmlTextReaderConstName(reader)));
+ }
+ tokenType = xmlTextReaderNodeType(reader);
+ switch (tokenId)
+ {
+ case XML_POSITION:
+ if (XML_READER_TYPE_ELEMENT == tokenType)
+ {
+ const boost::shared_ptr<xmlChar> stringValue(xmlTextReaderGetAttribute(reader, BAD_CAST("N")), xmlFree);
+ if (stringValue)
+ {
+ unsigned idx = xmlStringToLong(stringValue.get()+8);
+ ret = readDoubleData((*m_currentTabSet)[idx].m_position, reader);
+ }
+ }
+ break;
+ case XML_ALIGNMENT:
+ if (XML_READER_TYPE_ELEMENT == tokenType)
+ {
+ const boost::shared_ptr<xmlChar> stringValue(xmlTextReaderGetAttribute(reader, BAD_CAST("N")), xmlFree);
+ if (stringValue)
+ {
+ unsigned idx = xmlStringToLong(stringValue.get()+9);
+ ret = readByteData((*m_currentTabSet)[idx].m_alignment, reader);
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ while ((XML_ROW != tokenId || XML_READER_TYPE_END_ELEMENT != tokenType) && 1 == ret && (!m_watcher || !m_watcher->isError()));
+ }
+ m_currentTabSet = 0;
+}
+
void libvisio::VSDXParser::readCharacter(xmlTextReaderPtr reader)
{
int ret = 1;
diff --git a/src/lib/VSDXParser.h b/src/lib/VSDXParser.h
index 661f128..53624dc 100644
--- a/src/lib/VSDXParser.h
+++ b/src/lib/VSDXParser.h
@@ -27,6 +27,7 @@ class VSDXParser : public VSDXMLParserBase
using VSDXMLParserBase::readLongData;
using VSDXMLParserBase::readStringData;
+
public:
explicit VSDXParser(librevenge::RVNGInputStream *input, librevenge::RVNGDrawingInterface *painter);
virtual ~VSDXParser();
@@ -75,6 +76,8 @@ private:
void readParagraph(xmlTextReaderPtr reader);
void readCharacter(xmlTextReaderPtr reader);
void readFonts(xmlTextReaderPtr reader);
+ void readTabs(xmlTextReaderPtr reader);
+ void readTabRow(xmlTextReaderPtr reader);
// Private data
commit cf26b74d7aba1f6e764c31cfb4c7009d4e16f762
Author: Fridrich Štrba <fridrich.strba at bluewin.ch>
Date: Wed Dec 16 10:34:20 2015 +0100
Parse tab sets in VDX parser
Change-Id: Ic2f735f02c99046798867dae8d6a60821bb148b2
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);
commit 577575d95a81777156639c8831cffcd20c335c8e
Author: Fridrich Štrba <fridrich.strba at bluewin.ch>
Date: Wed Dec 16 10:31:08 2015 +0100
Add some variables to VSDXMLParserBase
Change-Id: Iaeb3444d0fb9cc256744f8df6ac725b06ceffeec
diff --git a/src/lib/VSDXMLParserBase.cpp b/src/lib/VSDXMLParserBase.cpp
index 89e09d4..f95ac87 100644
--- a/src/lib/VSDXMLParserBase.cpp
+++ b/src/lib/VSDXMLParserBase.cpp
@@ -31,7 +31,8 @@ libvisio::VSDXMLParserBase::VSDXMLParserBase()
m_currentShapeLevel(0), m_colours(), m_fieldList(), m_shapeList(),
m_currentBinaryData(), m_shapeStack(), m_shapeLevelStack(),
m_isShapeStarted(false), m_isPageStarted(false), m_currentGeometryList(0),
- m_currentGeometryListIndex(MINUS_ONE), m_fonts(), m_watcher(0)
+ m_currentGeometryListIndex(MINUS_ONE), m_fonts(), m_currentTabSet(0),
+ m_watcher(0)
{
initColours();
}
@@ -973,7 +974,9 @@ void libvisio::VSDXMLParserBase::readShape(xmlTextReaderPtr reader)
m_shape.m_geometries = tmpShape->m_geometries;
m_shape.m_charList = tmpShape->m_charList;
m_shape.m_paraList = tmpShape->m_paraList;
+ m_shape.m_tabSets = tmpShape->m_tabSets;
m_shape.m_text = tmpShape->m_text;
+ m_shape.m_textFormat = tmpShape->m_textFormat;
m_shape.m_misc = tmpShape->m_misc;
}
}
diff --git a/src/lib/VSDXMLParserBase.h b/src/lib/VSDXMLParserBase.h
index 6116584..2ee13ec 100644
--- a/src/lib/VSDXMLParserBase.h
+++ b/src/lib/VSDXMLParserBase.h
@@ -60,6 +60,8 @@ protected:
std::map<unsigned, VSDName> m_fonts;
+ std::map<unsigned, VSDTabStop> *m_currentTabSet;
+
XMLErrorWatcher *m_watcher;
// Helper functions
commit ecd9ebd303cda2dd4ca9fac85823d69e2f24e93b
Author: Fridrich Štrba <fridrich.strba at bluewin.ch>
Date: Wed Dec 16 10:26:26 2015 +0100
Add some variables to VSDParser
Change-Id: I7ca310269244e0ee1db616847d27a847c26a4a0c
diff --git a/src/lib/VSDParser.cpp b/src/lib/VSDParser.cpp
index c935a59..0429dd1 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_currentPageName(), m_currentTabSet()
{}
libvisio::VSDParser::~VSDParser()
@@ -1278,6 +1278,7 @@ void libvisio::VSDParser::readShape(librevenge::RVNGInputStream *input)
{
if (tmpShape->m_foreign)
m_shape.m_foreign = new ForeignData(*(tmpShape->m_foreign));
+ m_shape.m_tabSets = tmpShape->m_tabSets;
m_shape.m_text = tmpShape->m_text;
m_shape.m_textFormat = tmpShape->m_textFormat;
m_shape.m_misc = tmpShape->m_misc;
diff --git a/src/lib/VSDParser.h b/src/lib/VSDParser.h
index 8cec7f3..df81d4f 100644
--- a/src/lib/VSDParser.h
+++ b/src/lib/VSDParser.h
@@ -176,6 +176,7 @@ protected:
std::map<unsigned, std::map<unsigned, VSDName> > m_namesMapMap;
VSDName m_currentPageName;
+ std::map<unsigned, VSDTabStop> *m_currentTabSet;
private:
VSDParser();
commit afd15e87c3a85d2c5e86d5703a5f3ccf50d97002
Author: Fridrich Štrba <fridrich.strba at bluewin.ch>
Date: Wed Dec 16 10:21:03 2015 +0100
m_lead -> m_leader to correspond to the Visio terminology
Change-Id: I0944e0f3329f6761720048b0c9d0cc0bce698647
diff --git a/src/lib/VSDParser.cpp b/src/lib/VSDParser.cpp
index c332963..c935a59 100644
--- a/src/lib/VSDParser.cpp
+++ b/src/lib/VSDParser.cpp
@@ -780,7 +780,7 @@ void libvisio::VSDParser::readTabsData(librevenge::RVNGInputStream *input)
input->seek(1, librevenge::RVNG_SEEK_CUR);
tabStop.m_position = readDouble(input);
tabStop.m_alignment = readU8(input);
- tabStop.m_lead = readU8(input);
+ tabStop.m_leader = readU8(input);
tabStops.push_back(tabStop);
}
}
diff --git a/src/lib/VSDTypes.h b/src/lib/VSDTypes.h
index 6790fa4..214db21 100644
--- a/src/lib/VSDTypes.h
+++ b/src/lib/VSDTypes.h
@@ -213,11 +213,11 @@ struct VSDTabStop
{
double m_position;
unsigned char m_alignment;
- unsigned char m_lead;
- VSDTabStop() : m_position(0.0), m_alignment(0), m_lead(0) {}
+ unsigned char m_leader;
+ VSDTabStop() : m_position(0.0), m_alignment(0), m_leader(0) {}
VSDTabStop(const VSDTabStop &tabStop) :
m_position(tabStop.m_position), m_alignment(tabStop.m_alignment),
- m_lead(tabStop.m_lead) {}
+ m_leader(tabStop.m_leader) {}
};
} // namespace libvisio
commit ccfc261d411d6be27967d28833bad633c06282eb
Author: Fridrich Štrba <fridrich.strba at bluewin.ch>
Date: Wed Dec 16 10:13:35 2015 +0100
Add tab sets to the VSDShape
Change-Id: I5648ab8d97cea6fd9ba1f5d2bcca796396cdf172
diff --git a/src/lib/VSDStencils.cpp b/src/lib/VSDStencils.cpp
index 099fcbf..20a3788 100644
--- a/src/lib/VSDStencils.cpp
+++ b/src/lib/VSDStencils.cpp
@@ -14,7 +14,7 @@ libvisio::VSDShape::VSDShape()
: m_geometries(), m_shapeList(), m_fields(), m_foreign(0), m_parent(0), m_masterPage(MINUS_ONE),
m_masterShape(MINUS_ONE), m_shapeId(MINUS_ONE), m_lineStyleId(MINUS_ONE), m_fillStyleId(MINUS_ONE),
m_textStyleId(MINUS_ONE), m_lineStyle(), m_fillStyle(), m_textBlockStyle(), m_charStyle(),
- m_themeRef(), m_charList(), m_paraStyle(), m_paraList(), m_text(), m_names(),
+ m_themeRef(), m_charList(), m_paraStyle(), m_paraList(), m_tabSets(), m_text(), m_names(),
m_textFormat(libvisio::VSD_TEXT_UTF16), m_nurbsData(), m_polylineData(), m_xform(), m_txtxform(0),
m_xform1d(0), m_misc(), m_layerMem()
{
@@ -27,8 +27,9 @@ libvisio::VSDShape::VSDShape(const libvisio::VSDShape &shape)
m_lineStyleId(shape.m_lineStyleId), m_fillStyleId(shape.m_fillStyleId), m_textStyleId(shape.m_textStyleId),
m_lineStyle(shape.m_lineStyle), m_fillStyle(shape.m_fillStyle), m_textBlockStyle(shape.m_textBlockStyle),
m_charStyle(shape.m_charStyle), m_themeRef(shape.m_themeRef), m_charList(shape.m_charList),
- m_paraStyle(shape.m_paraStyle), m_paraList(shape.m_paraList), m_text(shape.m_text), m_names(shape.m_names),
- m_textFormat(shape.m_textFormat), m_nurbsData(shape.m_nurbsData), m_polylineData(shape.m_polylineData),
+ m_paraStyle(shape.m_paraStyle), m_paraList(shape.m_paraList), m_tabSets(shape.m_tabSets),
+ m_text(shape.m_text), m_names(shape.m_names), m_textFormat(shape.m_textFormat),
+ m_nurbsData(shape.m_nurbsData), m_polylineData(shape.m_polylineData),
m_xform(shape.m_xform), m_txtxform(shape.m_txtxform ? new XForm(*(shape.m_txtxform)) : 0),
m_xform1d(shape.m_xform1d ? new XForm1D(*(shape.m_xform1d)) : 0), m_misc(shape.m_misc),
m_layerMem(shape.m_layerMem)
@@ -65,6 +66,7 @@ libvisio::VSDShape &libvisio::VSDShape::operator=(const libvisio::VSDShape &shap
m_charList = shape.m_charList;
m_paraStyle = shape.m_paraStyle;
m_paraList = shape.m_paraList;
+ m_tabSets = shape.m_tabSets;
m_text = shape.m_text;
m_names = shape.m_names;
m_textFormat = shape.m_textFormat;
@@ -106,6 +108,7 @@ void libvisio::VSDShape::clear()
m_charList.clear();
m_paraStyle = VSDOptionalParaStyle();
m_paraList.clear();
+ m_tabSets.clear();
m_text.clear();
m_names.clear();
m_nurbsData.clear();
diff --git a/src/lib/VSDStencils.h b/src/lib/VSDStencils.h
index c3596d5..cad4b30 100644
--- a/src/lib/VSDStencils.h
+++ b/src/lib/VSDStencils.h
@@ -46,8 +46,9 @@ public:
VSDCharacterList m_charList;
VSDOptionalParaStyle m_paraStyle;
VSDParagraphList m_paraList;
+ std::map<unsigned, std::map<unsigned, VSDTabStop> > m_tabSets;
librevenge::RVNGBinaryData m_text;
- std::map< unsigned, VSDName > m_names;
+ std::map<unsigned, VSDName> m_names;
TextFormat m_textFormat;
std::map<unsigned, NURBSData> m_nurbsData;
std::map<unsigned, PolylineData> m_polylineData;
More information about the Libreoffice-commits
mailing list