diff options
author | Michael Stahl <mstahl@redhat.com> | 2015-05-05 23:15:20 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2015-05-06 00:10:17 +0200 |
commit | c4cf85766453982f1aa94a7f2cb22af19ed100be (patch) | |
tree | 9bdab580f5e8e76ecd72574c7f24015bb063f1a7 | |
parent | 1848430d614e0f2f52e288363d0367c9207b0802 (diff) |
sw: fix crash due to redlines on tables on ooo121112-2.docx
Problem is that after import there are SwRangeRedline that start in the
first cell of a table and end in the paragraph following the table.
There are <w:del> elements covering every individual paragraph in the
table; all of these are merged into one SwRangeRedline.
This could possibly be fixed in writerfilter by buffering the
m_pParaMarkerRedline until after convertToTable() to prevent the
merging, but perhaps it's better to fix it in SwXText::convertToTable().
Change-Id: I853ae624fffedb59a48bd90decb0973bf33beb68
-rw-r--r-- | sw/source/core/docnode/ndtbl.cxx | 28 | ||||
-rw-r--r-- | sw/source/core/unocore/unotext.cxx | 7 |
2 files changed, 35 insertions, 0 deletions
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index 208aefcbdb25..fe562d5827cf 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -1172,12 +1172,40 @@ const SwTable* SwDoc::TextToTable( const std::vector< std::vector<SwNodeRange> > ++aRg.aEnd; } + assert(aRg.aEnd == pEnd->nNode); + assert(aRg.aStart == pStt->nNode); if( aRg.aEnd.GetIndex() == aRg.aStart.GetIndex() ) { OSL_FAIL( "empty range" ); ++aRg.aEnd; } + + { + // TODO: this is not Undo-able - only good enough for file import + IDocumentRedlineAccess & rIDRA(getIDocumentRedlineAccess()); + 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(); ++row) + { + for (auto cell = row->begin(); cell != row->end(); ++cell) + { + assert(SwNodeIndex(*pPrev, +1) == cell->aStart); + SwPaM pam(cell->aStart, 0, *pPrev, + (pPrev->GetNode().IsCntntNode()) + ? pPrev->GetNode().GetCntntNode()->Len() : 0); + rIDRA.SplitRedline(pam); + pPrev = &cell->aEnd; + } + } + // another one to break between last cell and node after table + SwPaM pam(SwNodeIndex(*pPrev, +1), 0, *pPrev, + (pPrev->GetNode().IsCntntNode()) + ? pPrev->GetNode().GetCntntNode()->Len() : 0); + rIDRA.SplitRedline(pam); + } + // We always use Upper to insert the Table SwNode2Layout aNode2Layout( aRg.aStart.GetNode() ); diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 04bc9a2f9cbe..d21a6f239480 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -2218,6 +2218,13 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception) throw uno::RuntimeException(); } + IDocumentRedlineAccess & rIDRA(m_pImpl->m_pDoc->getIDocumentRedlineAccess()); + if (!IDocumentRedlineAccess::IsShowChanges(rIDRA.GetRedlineMode())) + { + throw uno::RuntimeException( + "cannot convertToTable if tracked changes are hidden!"); + } + //at first collect the text ranges as SwPaMs const uno::Sequence< uno::Sequence< uno::Reference< text::XTextRange > > >* pTableRanges = rTableRanges.getConstArray(); |