summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2016-08-30 21:17:32 +0200
committerMichael Stahl <mstahl@redhat.com>2016-08-30 21:40:03 +0200
commitdc83b3ae470914dbcb08fe1f0a4a4e1a1d3d8e19 (patch)
tree336ebf0844785d11f8f26c6357dd914bcd435e79
parent424d48d347c317fa1a542d65e68327aea08cb1ed (diff)
Revert "fftester: non-contiguous cells"
This reverts commit 9accbfa0a52433cf03fe186fc69334d387981eb9. ... and the code change of "avoid crashing on load of fdo54724-1.rtf" commit 4ee3eabd0f058b26544c84b2b5aaf5478d921817. It's much simpler to detect early in convertToTable that there is a row with no cells in it, which should not be allowed. Change-Id: Iff6d235b29514edd57cc55addeefb24242595d88
-rw-r--r--sw/qa/core/data/rtf/fail/table-1.rtfbin849 -> 0 bytes
-rw-r--r--sw/source/core/docnode/ndtbl.cxx14
-rw-r--r--sw/source/core/unocore/unotext.cxx23
3 files changed, 15 insertions, 22 deletions
diff --git a/sw/qa/core/data/rtf/fail/table-1.rtf b/sw/qa/core/data/rtf/fail/table-1.rtf
deleted file mode 100644
index c333a1037887..000000000000
--- a/sw/qa/core/data/rtf/fail/table-1.rtf
+++ /dev/null
Binary files differ
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 216070ef2f98..0abfc39c6d3e 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -1181,7 +1181,6 @@ const SwTable* SwDoc::TextToTable( const std::vector< std::vector<SwNodeRange> >
++aRg.aEnd;
}
- bool bFailure = false;
{
// TODO: this is not Undo-able - only good enough for file import
@@ -1189,17 +1188,11 @@ const SwTable* SwDoc::TextToTable( const std::vector< std::vector<SwNodeRange> >
SwNodeIndex const prev(rTableNodes.begin()->begin()->aStart, -1);
SwNodeIndex const* pPrev(&prev);
// pPrev could point to non-textnode now
- for (auto row = rTableNodes.begin(); row != rTableNodes.end() && !bFailure; ++row)
+ for (auto row = rTableNodes.begin(); row != rTableNodes.end(); ++row)
{
for (auto cell = row->begin(); cell != row->end(); ++cell)
{
- bFailure = (SwNodeIndex(*pPrev, +1) != cell->aStart);
- if (bFailure)
- {
- SAL_WARN("sw.core", "cell start is not directly after previous cell end");
- break;
- }
-
+ assert(SwNodeIndex(*pPrev, +1) == cell->aStart);
SwPaM pam(cell->aStart, 0, *pPrev,
(pPrev->GetNode().IsContentNode())
? pPrev->GetNode().GetContentNode()->Len() : 0);
@@ -1219,9 +1212,6 @@ const SwTable* SwDoc::TextToTable( const std::vector< std::vector<SwNodeRange> >
GetIDocumentUndoRedo().DoUndo(bUndo);
- if (bFailure)
- return nullptr;
-
// Create the Box/Line/Table construct
SwTableBoxFormat* pBoxFormat = MakeTableBoxFormat();
SwTableLineFormat* pLineFormat = MakeTableLineFormat();
diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx
index 391fa0c2b624..24d0822ad9a9 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -2230,20 +2230,23 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
pTableRanges[nRow].getConstArray();
const sal_Int32 nCells(pTableRanges[nRow].getLength());
+ if (0 == nCells) // this would lead to no pLastCell below
+ { // and make it impossible to detect node gaps
+ bExcept = true;
+ break;
+ }
+
for (sal_Int32 nCell = 0; nCell < nCells; ++nCell)
{
- SwNodeRange *pLastCell;
- if (nCell == 0 && nRow == 0)
- {
- pLastCell = nullptr;
- }
- else
- {
- std::vector<SwNodeRange>& rRowOfPrevCell = nCell ? aRowNodes : *aTableNodes.rbegin();
- pLastCell = !rRowOfPrevCell.empty() ? &*rRowOfPrevCell.rbegin() : nullptr;
- }
+ SwNodeRange *const pLastCell(
+ (nCell == 0)
+ ? ((nRow == 0)
+ ? nullptr
+ : &*aTableNodes.rbegin()->rbegin())
+ : &*aRowNodes.rbegin());
m_pImpl->ConvertCell(pRow[nCell], aRowNodes, pLastCell, bExcept);
}
+ assert(bExcept || !aRowNodes.empty());
aTableNodes.push_back(aRowNodes);
}