[Libreoffice-commits] libmspub.git: 2 commits - src/lib
David Tardon
dtardon at redhat.com
Mon Dec 29 12:54:32 PST 2014
src/lib/MSPUBCollector.cpp | 17 +++++++----------
src/lib/MSPUBCollector.h | 4 ++--
src/lib/MSPUBParser.cpp | 7 +++++--
src/lib/ShapeInfo.h | 3 +--
4 files changed, 15 insertions(+), 16 deletions(-)
New commits:
commit 630ed6296456fe14c08a25dda703a221280a00c2
Author: David Tardon <dtardon at redhat.com>
Date: Mon Dec 29 21:53:11 2014 +0100
fix parsing of docs with multiple tables
Change-Id: I4f8141a6fe71db283b698b67819e5ed00aed3860
diff --git a/src/lib/MSPUBCollector.cpp b/src/lib/MSPUBCollector.cpp
index 98d34cc..71e3846 100644
--- a/src/lib/MSPUBCollector.cpp
+++ b/src/lib/MSPUBCollector.cpp
@@ -282,8 +282,6 @@ void MSPUBCollector::setShapeTableInfo(unsigned seqNum,
const TableInfo &ti)
{
m_shapeInfosBySeqNum[seqNum].m_tableInfo = ti;
- if (!m_tableCellTextEndsVector.empty())
- m_shapeInfosBySeqNum[seqNum].m_tableCellTextEnds = m_tableCellTextEndsVector.back();
}
void MSPUBCollector::setShapeNumColumns(unsigned seqNum,
@@ -380,7 +378,7 @@ MSPUBCollector::MSPUBCollector(librevenge::RVNGDrawingInterface *painter) :
m_shapeInfosBySeqNum(), m_masterPages(),
m_shapesWithCoordinatesRotated90(),
m_masterPagesByPageSeqNum(),
- m_tableCellTextEndsVector(), m_stringOffsetsByTextId(),
+ m_tableCellTextEndsByTextId(), m_stringOffsetsByTextId(),
m_calculationValuesSeen(), m_pageSeqNumsOrdered(),
m_encodingHeuristic(false), m_allText(),
m_calculatedEncoding()
@@ -393,10 +391,10 @@ void MSPUBCollector::setTextStringOffset(
m_stringOffsetsByTextId[textId] = offset;
}
-void MSPUBCollector::setNextTableCellTextEnds(
- const std::vector<unsigned> &ends)
+void MSPUBCollector::setTableCellTextEnds(
+ const unsigned textId, const std::vector<unsigned> &ends)
{
- m_tableCellTextEndsVector.push_back(ends);
+ m_tableCellTextEndsByTextId[textId] = ends;
}
void MSPUBCollector::useEncodingHeuristic()
@@ -1003,9 +1001,8 @@ boost::function<void(void)> MSPUBCollector::paintShape(const ShapeInfo &info, co
{
m_painter->startTableObject(props);
- std::vector<unsigned> tableCellTextEnds;
- if (bool(info.m_tableCellTextEnds))
- tableCellTextEnds = get(info.m_tableCellTextEnds);
+ const std::map<unsigned, std::vector<unsigned> >::const_iterator it = m_tableCellTextEndsByTextId.find(get(info.m_textId));
+ const std::vector<unsigned> &tableCellTextEnds = (it != m_tableCellTextEndsByTextId.end()) ? it->second : std::vector<unsigned>();
TableLayout tableLayout(boost::extents[get(info.m_tableInfo).m_numRows][get(info.m_tableInfo).m_numColumns]);
createTableLayout(get(info.m_tableInfo).m_cells, tableLayout);
diff --git a/src/lib/MSPUBCollector.h b/src/lib/MSPUBCollector.h
index b66e317..7e4b953 100644
--- a/src/lib/MSPUBCollector.h
+++ b/src/lib/MSPUBCollector.h
@@ -121,7 +121,7 @@ public:
void useEncodingHeuristic();
- void setNextTableCellTextEnds(const std::vector<unsigned> &ends);
+ void setTableCellTextEnds(unsigned textId, const std::vector<unsigned> &ends);
void setTextStringOffset(unsigned textId, unsigned offset);
bool go();
@@ -165,7 +165,7 @@ private:
std::set<unsigned> m_masterPages;
std::set<unsigned> m_shapesWithCoordinatesRotated90;
std::map<unsigned, unsigned> m_masterPagesByPageSeqNum;
- std::vector<std::vector<unsigned> > m_tableCellTextEndsVector;
+ std::map<unsigned, std::vector<unsigned> > m_tableCellTextEndsByTextId;
std::map<unsigned, unsigned> m_stringOffsetsByTextId;
mutable std::vector<bool> m_calculationValuesSeen;
std::vector<unsigned> m_pageSeqNumsOrdered;
diff --git a/src/lib/MSPUBParser.cpp b/src/lib/MSPUBParser.cpp
index d2f3baa..1810152 100644
--- a/src/lib/MSPUBParser.cpp
+++ b/src/lib/MSPUBParser.cpp
@@ -973,6 +973,7 @@ bool MSPUBParser::parseQuill(librevenge::RVNGInputStream *input)
std::vector<unsigned> textLengths;
std::vector<unsigned> textIDs;
std::vector<unsigned> textOffsets;
+ std::map<unsigned, std::vector<unsigned> > tableCellTextEnds;
unsigned textOffsetAccum = 0;
std::vector<TextSpanReference> spans;
std::vector<TextParagraphReference> paras;
@@ -1045,8 +1046,7 @@ bool MSPUBParser::parseQuill(librevenge::RVNGInputStream *input)
else if (i->name == "TCD ")
{
input->seek(i->offset, librevenge::RVNG_SEEK_SET);
- std::vector<unsigned> ends = parseTableCellDefinitions(input, *i);
- m_collector->setNextTableCellTextEnds(ends);
+ tableCellTextEnds[i->id] = parseTableCellDefinitions(input, *i);
}
}
if (parsedStrs && parsedSyid && parsedFdpc && parsedFdpp && parsedStsh && parsedFont && textChunkReference != chunkReferences.end())
@@ -1106,6 +1106,9 @@ bool MSPUBParser::parseQuill(librevenge::RVNGInputStream *input)
}
m_collector->addTextString(readParas, textIDs[j]);
m_collector->setTextStringOffset(textIDs[j], textOffsets[j]);
+ const std::map<unsigned, std::vector<unsigned> >::const_iterator it = tableCellTextEnds.find(j);
+ if (it != tableCellTextEnds.end())
+ m_collector->setTableCellTextEnds(textIDs[j], it->second);
}
textChunkReference = chunkReferences.end();
}
diff --git a/src/lib/ShapeInfo.h b/src/lib/ShapeInfo.h
index d960917..372191e 100644
--- a/src/lib/ShapeInfo.h
+++ b/src/lib/ShapeInfo.h
@@ -53,7 +53,6 @@ struct ShapeInfo
boost::optional<ColorReference> m_lineBackColor;
boost::optional<Dash> m_dash;
boost::optional<TableInfo> m_tableInfo;
- boost::optional<std::vector<unsigned> > m_tableCellTextEnds;
boost::optional<unsigned> m_numColumns;
unsigned m_columnSpacing;
boost::optional<Arrow> m_beginArrow;
@@ -71,7 +70,7 @@ struct ShapeInfo
m_rotation(), m_flips(), m_margins(), m_borderPosition(),
m_fill(), m_customShape(), m_stretchBorderArt(false),
m_lineBackColor(), m_dash(), m_tableInfo(),
- m_tableCellTextEnds(), m_numColumns(),
+ m_numColumns(),
m_columnSpacing(0), m_beginArrow(), m_endArrow(),
m_verticalAlign(), m_pictureRecolor(), m_shadow(), m_innerRotation(), m_clipPath(), m_pictureBrightness(), m_pictureContrast()
{
commit f2062c912b0deb340cb7d4c55d027e7d26cf0f59
Author: David Tardon <dtardon at redhat.com>
Date: Mon Dec 29 21:52:50 2014 +0100
astyle
Change-Id: Ifd955b803ca0ab6b1c3fb93c947320d846c537ed
diff --git a/src/lib/MSPUBCollector.cpp b/src/lib/MSPUBCollector.cpp
index 5bc7e62..98d34cc 100644
--- a/src/lib/MSPUBCollector.cpp
+++ b/src/lib/MSPUBCollector.cpp
@@ -1053,7 +1053,7 @@ boost::function<void(void)> MSPUBCollector::paintShape(const ShapeInfo &info, co
m_painter->closeSpan();
}
- m_painter->closeParagraph();
+ m_painter->closeParagraph();
}
}
More information about the Libreoffice-commits
mailing list