sw/source/core/doc/DocumentRedlineManager.cxx | 40 ++++++++++++-------------- sw/source/core/docnode/ndtbl.cxx | 28 ++++++++++++++++++ sw/source/core/unocore/unotext.cxx | 7 ++++ 3 files changed, 54 insertions(+), 21 deletions(-)
New commits: commit 6a37faafa545ccf0b242d4f3b179dcbe710a2814 Author: Michael Stahl <mst...@redhat.com> Date: Tue May 5 23:30:00 2015 +0200 sw: make SplitRedline() a little more readable Change-Id: Icd99c8d98ae4c5cd6c6552a929c28ad0f096c214 diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index eda5205..5659a96 100644 --- a/sw/source/core/doc/DocumentRedlineManager.cxx +++ b/sw/source/core/doc/DocumentRedlineManager.cxx @@ -1823,59 +1823,57 @@ bool DocumentRedlineManager::SplitRedline( const SwPaM& rRange ) { bool bChg = false; sal_uInt16 n = 0; - const SwPosition* pStt = rRange.Start(), - * pEnd = pStt == rRange.GetPoint() ? rRange.GetMark() - : rRange.GetPoint(); + const SwPosition* pStt = rRange.Start(); + const SwPosition* pEnd = rRange.End(); GetRedline( *pStt, &n ); - for( ; n < mpRedlineTbl->size() ; ++n ) + for ( ; n < mpRedlineTbl->size(); ++n) { - SwRangeRedline* pTmp = (*mpRedlineTbl)[ n ]; - SwPosition* pTStt = pTmp->Start(), - * pTEnd = pTStt == pTmp->GetPoint() ? pTmp->GetMark() - : pTmp->GetPoint(); - if( *pTStt <= *pStt && *pStt <= *pTEnd && - *pTStt <= *pEnd && *pEnd <= *pTEnd ) + SwRangeRedline * pRedline = (*mpRedlineTbl)[ n ]; + SwPosition *const pRedlineStart = pRedline->Start(); + SwPosition *const pRedlineEnd = pRedline->End(); + if (*pRedlineStart <= *pStt && *pStt <= *pRedlineEnd && + *pRedlineStart <= *pEnd && *pEnd <= *pRedlineEnd) { bChg = true; int nn = 0; - if( *pStt == *pTStt ) + if (*pStt == *pRedlineStart) nn += 1; - if( *pEnd == *pTEnd ) + if (*pEnd == *pRedlineEnd) nn += 2; SwRangeRedline* pNew = 0; switch( nn ) { case 0: - pNew = new SwRangeRedline( *pTmp ); - pTmp->SetEnd( *pStt, pTEnd ); + pNew = new SwRangeRedline( *pRedline ); + pRedline->SetEnd( *pStt, pRedlineEnd ); pNew->SetStart( *pEnd ); break; case 1: - *pTStt = *pEnd; + *pRedlineStart = *pEnd; break; case 2: - *pTEnd = *pStt; + *pRedlineEnd = *pStt; break; case 3: - pTmp->InvalidateRange(); + pRedline->InvalidateRange(); mpRedlineTbl->DeleteAndDestroy( n-- ); - pTmp = 0; + pRedline = nullptr; break; } - if( pTmp && !pTmp->HasValidRange() ) + if (pRedline && !pRedline->HasValidRange()) { // re-insert mpRedlineTbl->Remove( n ); - mpRedlineTbl->Insert( pTmp, n ); + mpRedlineTbl->Insert( pRedline, n ); } if( pNew ) mpRedlineTbl->Insert( pNew, n ); } - else if( *pEnd < *pTStt ) + else if (*pEnd < *pRedlineStart) break; } return bChg; commit c4cf85766453982f1aa94a7f2cb22af19ed100be Author: Michael Stahl <mst...@redhat.com> Date: Tue May 5 23:15:20 2015 +0200 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 diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index 208aefc..fe562d5 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 04bc9a2..d21a6f2 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(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits