summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFridrich Štrba <fridrich.strba@bluewin.ch>2015-12-15 17:10:46 +0100
committerFridrich Štrba <fridrich.strba@bluewin.ch>2015-12-15 17:10:46 +0100
commit28e14efb6e036b2e75052f219136658f99b18957 (patch)
tree648e24fc73bbdd207536f6f66b9e358cdc6c9321
parent067605a0cd9688ed31d77a85b292d81a501c5c16 (diff)
Some function to read tab stops in binary parsers
Change-Id: Ibfe37737600f2e8f61a3fca6839178b1812355ea
-rw-r--r--src/lib/VSD5Parser.cpp8
-rw-r--r--src/lib/VSD5Parser.h1
-rw-r--r--src/lib/VSDParser.cpp47
-rw-r--r--src/lib/VSDParser.h2
-rw-r--r--src/lib/VSDTypes.h11
5 files changed, 68 insertions, 1 deletions
diff --git a/src/lib/VSD5Parser.cpp b/src/lib/VSD5Parser.cpp
index 7a014be..be47174 100644
--- a/src/lib/VSD5Parser.cpp
+++ b/src/lib/VSD5Parser.cpp
@@ -109,7 +109,7 @@ void libvisio::VSD5Parser::handleChunkRecords(librevenge::RVNGInputStream *input
if (long(endOffset) > (headerPosition - startPosition))
endOffset = unsigned(headerPosition - startPosition); // try to read something anyway
std::map<unsigned, ChunkHeader> records;
- input->seek(endPosition-4*(numRecords+1), librevenge::RVNG_SEEK_SET);
+ input->seek(headerPosition, librevenge::RVNG_SEEK_SET);
unsigned i = 0;
for (i = 0; i < numRecords; ++i)
{
@@ -192,6 +192,12 @@ void libvisio::VSD5Parser::readNameList2(librevenge::RVNGInputStream *input)
readList(input);
}
+void libvisio::VSD5Parser::readTabsDataList(librevenge::RVNGInputStream *input)
+{
+ VSD_DEBUG_MSG(("VSD5Parser::readTabsDataList\n"));
+ readList(input);
+}
+
void libvisio::VSD5Parser::readLine(librevenge::RVNGInputStream *input)
{
input->seek(1, librevenge::RVNG_SEEK_CUR);
diff --git a/src/lib/VSD5Parser.h b/src/lib/VSD5Parser.h
index d312e44..08e8497 100644
--- a/src/lib/VSD5Parser.h
+++ b/src/lib/VSD5Parser.h
@@ -37,6 +37,7 @@ protected:
virtual void readPropList(librevenge::RVNGInputStream *input);
virtual void readFieldList(librevenge::RVNGInputStream *input);
virtual void readNameList2(librevenge::RVNGInputStream *input);
+ virtual void readTabsDataList(librevenge::RVNGInputStream *input);
virtual void readLine(librevenge::RVNGInputStream *input);
virtual void readFillAndShadow(librevenge::RVNGInputStream *input);
diff --git a/src/lib/VSDParser.cpp b/src/lib/VSDParser.cpp
index d3e6a0b..019b27a 100644
--- a/src/lib/VSDParser.cpp
+++ b/src/lib/VSDParser.cpp
@@ -599,6 +599,14 @@ void libvisio::VSDParser::handleChunk(librevenge::RVNGInputStream *input)
case VSD_LAYER_MEMBERSHIP:
readLayerMem(input);
break;
+ case VSD_TABS_DATA_LIST:
+ readTabsDataList(input);
+ break;
+ case VSD_TABS_DATA_1:
+ case VSD_TABS_DATA_2:
+ case VSD_TABS_DATA_3:
+ readTabsData(input);
+ break;
default:
m_collector->collectUnhandledChunk(m_header.id, m_header.level);
}
@@ -761,6 +769,22 @@ void libvisio::VSDParser::readOLEData(librevenge::RVNGInputStream *input)
}
+void libvisio::VSDParser::readTabsData(librevenge::RVNGInputStream *input)
+{
+ /* unsigned charCount = */ readU32(input);
+ unsigned char numStops = readU8(input);
+ std::vector<VSDTabStop> tabStops;
+ 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_lead = readU8(input);
+ tabStops.push_back(tabStop);
+ }
+}
+
void libvisio::VSDParser::readNameIDX(librevenge::RVNGInputStream *input)
{
std::map<unsigned, VSDName> names;
@@ -942,6 +966,29 @@ void libvisio::VSDParser::readPropList(librevenge::RVNGInputStream * /* input */
{
}
+void libvisio::VSDParser::readTabsDataList(librevenge::RVNGInputStream *input)
+{
+ // 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> tabsOrder;
+ tabsOrder.reserve(childrenListLength / sizeof(uint32_t));
+ printf("Fridrich");
+ for (unsigned i = 0; i < (childrenListLength / sizeof(uint32_t)); i++)
+ {
+ tabsOrder.push_back(readU32(input));
+ printf(" %i", tabsOrder.back());
+ }
+ printf("\n");
+ }
+}
+
void libvisio::VSDParser::readLayerList(librevenge::RVNGInputStream *input)
{
// We want the collectors to still get the level information
diff --git a/src/lib/VSDParser.h b/src/lib/VSDParser.h
index fbf167e..8cec7f3 100644
--- a/src/lib/VSDParser.h
+++ b/src/lib/VSDParser.h
@@ -86,6 +86,8 @@ protected:
virtual void readCharIX(librevenge::RVNGInputStream *input);
virtual void readParaIX(librevenge::RVNGInputStream *input);
virtual void readTextBlock(librevenge::RVNGInputStream *input);
+ virtual void readTabsDataList(librevenge::RVNGInputStream *input);
+ virtual void readTabsData(librevenge::RVNGInputStream *input);
void readNameList(librevenge::RVNGInputStream *input);
virtual void readName(librevenge::RVNGInputStream *input);
diff --git a/src/lib/VSDTypes.h b/src/lib/VSDTypes.h
index 9492844..6790fa4 100644
--- a/src/lib/VSDTypes.h
+++ b/src/lib/VSDTypes.h
@@ -209,6 +209,17 @@ struct VSDMisc
VSDMisc(const VSDMisc &misc) : m_hideText(misc.m_hideText) {}
};
+struct VSDTabStop
+{
+ double m_position;
+ unsigned char m_alignment;
+ unsigned char m_lead;
+ VSDTabStop() : m_position(0.0), m_alignment(0), m_lead(0) {}
+ VSDTabStop(const VSDTabStop &tabStop) :
+ m_position(tabStop.m_position), m_alignment(tabStop.m_alignment),
+ m_lead(tabStop.m_lead) {}
+};
+
} // namespace libvisio
#endif /* VSDTYPES_H */