diff options
author | Michael Stahl <mstahl@redhat.com> | 2015-05-11 23:47:54 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2015-05-12 00:13:15 +0200 |
commit | e4d4ee607efc8ec0e2284f661fd32f0e2ad99e76 (patch) | |
tree | a83506975106caa888d71b6ede94e64f280ff7b7 /sw | |
parent | 23c0e00b50f7fae7a82134ef064eabf9514a941b (diff) |
sw: fix assert on loading fdo48559-1.rtf
SwXText::convertToTable() is called with 8 cursors that all point to the
same empty paragraph; that causes the paragraph to be split but the
SwNodeIndex always point to the 2nd node after the split, so they all
end up pointing to the last node. So adjust the last cell's SwNodeIndex
after split.
Change-Id: I0fdcb19baf2fae840177fd621666c10f4f6f2a62
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/unocore/unotext.cxx | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index d21a6f239480..6f124fae8935 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -115,6 +115,7 @@ public: ::std::vector<SwNodeRange> & rRowNodes, ::std::unique_ptr< SwPaM > & rpFirstPaM, SwPaM & rLastPaM, + SwNodeRange *const pLastCell, bool & rbExcept); }; @@ -1821,6 +1822,7 @@ void SwXText::Impl::ConvertCell( ::std::vector<SwNodeRange> & rRowNodes, ::std::unique_ptr< SwPaM > & rpFirstPaM, SwPaM & rLastPaM, + SwNodeRange *const pLastCell, bool & rbExcept) { if (rCell.getLength() != 2) @@ -1929,7 +1931,23 @@ void SwXText::Impl::ConvertCell( } else { + // note: this may modify rLastPaM too! m_pDoc->getIDocumentContentOperations().SplitNode(*aStartCellPam.Start(), false); + sal_uLong const nNewIndex(aStartCellPam.Start()->nNode.GetIndex()); + if (nNewIndex != nStartCellNodeIndex) + { + // aStartCellPam now points to the 2nd node + // the last cell may *also* point to 2nd node now - fix it! + assert(nNewIndex == nStartCellNodeIndex + 1); + if (pLastCell->aEnd.GetIndex() == nNewIndex) + { + --pLastCell->aEnd; + if (pLastCell->aStart.GetIndex() == nNewIndex) + { + --pLastCell->aStart; + } + } + } } } else if (nStartCellNodeIndex == (nLastNodeEndIndex + 1)) @@ -1974,7 +1992,7 @@ void SwXText::Impl::ConvertCell( SwNodeRange aCellRange(aStartCellPam.Start()->nNode, aEndCellPam.End()->nNode); - rRowNodes.push_back(aCellRange); + rRowNodes.push_back(aCellRange); // note: invalidates pLastCell! if (bFirstCell) { rpFirstPaM.reset(new SwPaM(*aStartCellPam.Start())); @@ -2242,8 +2260,12 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception) for (sal_Int32 nCell = 0; nCell < nCells; ++nCell) { + SwNodeRange *const pLastCell( + (nCell == 0) + ? ((nRow == 0) ? nullptr : &*aTableNodes.rbegin()->rbegin()) + : &*aRowNodes.rbegin()); m_pImpl->ConvertCell((nCell == 0) && (nRow == 0), pRow[nCell], - aRowNodes, pFirstPaM, aLastPaM, bExcept); + aRowNodes, pFirstPaM, aLastPaM, pLastCell, bExcept); } aTableNodes.push_back(aRowNodes); } |