Kaydet (Commit) c4cf8576 authored tarafından Michael Stahl's avatar Michael Stahl

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
üst 1848430d
...@@ -1172,12 +1172,40 @@ const SwTable* SwDoc::TextToTable( const std::vector< std::vector<SwNodeRange> > ...@@ -1172,12 +1172,40 @@ const SwTable* SwDoc::TextToTable( const std::vector< std::vector<SwNodeRange> >
++aRg.aEnd; ++aRg.aEnd;
} }
assert(aRg.aEnd == pEnd->nNode);
assert(aRg.aStart == pStt->nNode);
if( aRg.aEnd.GetIndex() == aRg.aStart.GetIndex() ) if( aRg.aEnd.GetIndex() == aRg.aStart.GetIndex() )
{ {
OSL_FAIL( "empty range" ); OSL_FAIL( "empty range" );
++aRg.aEnd; ++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 // We always use Upper to insert the Table
SwNode2Layout aNode2Layout( aRg.aStart.GetNode() ); SwNode2Layout aNode2Layout( aRg.aStart.GetNode() );
......
...@@ -2218,6 +2218,13 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception) ...@@ -2218,6 +2218,13 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
throw uno::RuntimeException(); 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 //at first collect the text ranges as SwPaMs
const uno::Sequence< uno::Sequence< uno::Reference< text::XTextRange > > >* const uno::Sequence< uno::Sequence< uno::Reference< text::XTextRange > > >*
pTableRanges = rTableRanges.getConstArray(); pTableRanges = rTableRanges.getConstArray();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment