summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2019-01-04 11:40:39 +0100
committerLászló Németh <nemeth@numbertext.org>2019-01-04 18:43:30 +0100
commitdc8fa612054363e1a871b0e413a59889fbdb156a (patch)
tree105ab5164ec941102edbaadb92bf8aa0eea897e2 /writerfilter
parentee33372f6406d7352bc7e19914ec5fb0059c4e01 (diff)
tdf#122424 RTF import: ignore table row text outside the cells
instead of extending the next row with them. Change-Id: I09941e977d0036fcea07885ccc7b745d396619c2 Reviewed-on: https://gerrit.libreoffice.org/65852 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/rtftok/rtfdispatchsymbol.cxx10
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx21
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.hxx4
3 files changed, 32 insertions, 3 deletions
diff --git a/writerfilter/source/rtftok/rtfdispatchsymbol.cxx b/writerfilter/source/rtftok/rtfdispatchsymbol.cxx
index f7371ee7ac22..ed97ad5c9a15 100644
--- a/writerfilter/source/rtftok/rtfdispatchsymbol.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchsymbol.cxx
@@ -176,7 +176,16 @@ RTFError RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
case RTF_NESTCELL:
{
if (nKeyword == RTF_CELL)
+ {
m_bAfterCellBeforeRow = true;
+ if (m_nCellsInRow != -1)
+ m_nCellsInRow++;
+ }
+ else
+ {
+ // in the case of nested tables, disable ignoring row text outside of cell content
+ m_nCellsInRow = -1;
+ }
checkFirstRun();
if (m_bNeedPap)
@@ -232,6 +241,7 @@ RTFError RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
case RTF_ROW:
{
m_bAfterCellBeforeRow = false;
+ m_nActualCellInRow = 0;
if (m_aStates.top().nTableRowWidthAfter > 0)
{
// Add fake cellx / cell, RTF equivalent of
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 22b766889711..f3449254ebf7 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -300,6 +300,8 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x
, m_hasRFooter(false)
, m_hasFFooter(false)
, m_bAfterCellBeforeRow(false)
+ , m_nCellsInRow(0)
+ , m_nActualCellInRow(0)
{
OSL_ASSERT(xInputStream.is());
m_pInStream = utl::UcbStreamHelper::CreateStream(xInputStream, true);
@@ -1478,6 +1480,12 @@ void RTFDocumentImpl::text(OUString& rString)
RTFBuffer_t* pCurrentBuffer = m_aStates.top().pCurrentBuffer;
+ if (m_nActualCellInRow > 0)
+ {
+ m_nActualCellInRow = 0;
+ m_nCellsInRow = 0;
+ }
+
if (!pCurrentBuffer && m_aStates.top().eDestination != Destination::FOOTNOTE)
Mapper().startCharacterGroup();
else if (pCurrentBuffer)
@@ -1619,6 +1627,7 @@ void RTFDocumentImpl::replayBuffer(RTFBuffer_t& rBuffer, RTFSprms* const pSprms,
}
else if (std::get<0>(aTuple) == BUFFER_CELLEND)
{
+ m_nActualCellInRow++;
assert(pSprms && pAttributes);
auto pValue = new RTFValue(1);
pSprms->set(NS_ooxml::LN_tblCell, pValue);
@@ -1637,9 +1646,15 @@ void RTFDocumentImpl::replayBuffer(RTFBuffer_t& rBuffer, RTFSprms* const pSprms,
}
else if (std::get<0>(aTuple) == BUFFER_UTEXT)
{
- OUString const aString(std::get<1>(aTuple)->getString());
- Mapper().utext(reinterpret_cast<sal_uInt8 const*>(aString.getStr()),
- aString.getLength());
+ // ignore text outside the cell content in table rows
+ // except in the case of nested tables
+ if (m_nActualCellInRow == 0 || m_nActualCellInRow < m_nCellsInRow
+ || m_nCellsInRow == -1)
+ {
+ OUString const aString(std::get<1>(aTuple)->getString());
+ Mapper().utext(reinterpret_cast<sal_uInt8 const*>(aString.getStr()),
+ aString.getLength());
+ }
}
else if (std::get<0>(aTuple) == BUFFER_ENDRUN)
Mapper().endCharacterGroup();
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 6fe21351c5c8..11c8dc851a9d 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -720,6 +720,10 @@ private:
/// Are we after a \cell, but before a \row?
bool m_bAfterCellBeforeRow;
+ /// cells in row, to ignore extra text content of the row
+ int m_nCellsInRow;
+ /// actual cell in row
+ int m_nActualCellInRow;
};
} // namespace rtftok
} // namespace writerfilter