diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2023-07-19 15:58:36 +0200 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2023-07-31 22:16:56 +0200 |
commit | 809e7f777aa58d38f6aca6105b1659a09d22579c (patch) | |
tree | 4288f371124bdee757b06b11d43df1c56d29604e | |
parent | 5f2c15fb652753fddf74c171abdf58295597366d (diff) |
tdf#153115 sw: SwDoc::TextToTable(), first remove all redlines
The problem is that there are redlines that overlap the created table
cell nodes.
For the writerfilter-import-API TextToTable() that was solved by
splitting the redlines, but that would take a lot of effort here as it's
not known ahead of time where the cells start and end, so just get rid
of the redlines.
Another issue is that the temporary SwPaM in
DocumentRedlineManager::AcceptRedline() caused ~SwIndexReg() assert.
(reportedly regression from commit 471212d464f54054f7419ef1890267d0def852d9)
Change-Id: I6b211b6c8e5c7e4bdab1dac858707d7d7fd85029
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154655
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
(cherry picked from commit cd20d9512aa4f9fbe39fce48b3c49cdb13cca6e6)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154621
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
-rw-r--r-- | sw/source/core/doc/DocumentRedlineManager.cxx | 13 | ||||
-rw-r--r-- | sw/source/core/docnode/ndtbl.cxx | 11 |
2 files changed, 19 insertions, 5 deletions
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index 60ddf9d62151..1d0e2b561859 100644 --- a/sw/source/core/doc/DocumentRedlineManager.cxx +++ b/sw/source/core/doc/DocumentRedlineManager.cxx @@ -2903,17 +2903,22 @@ bool DocumentRedlineManager::AcceptRedline( const SwPaM& rPam, bool bCallDelete // The Selection is only in the ContentSection. If there are Redlines // to Non-ContentNodes before or after that, then the Selections // expand to them. - SwPaM aPam( *rPam.GetMark(), *rPam.GetPoint() ); - lcl_AdjustRedlineRange( aPam ); + std::shared_ptr<SwUnoCursor> const pPam(m_rDoc.CreateUnoCursor(*rPam.GetPoint(), false)); + if (rPam.HasMark()) + { + pPam->SetMark(); + *pPam->GetMark() = *rPam.GetMark(); + } + lcl_AdjustRedlineRange(*pPam); if (m_rDoc.GetIDocumentUndoRedo().DoesUndo()) { m_rDoc.GetIDocumentUndoRedo().StartUndo( SwUndoId::ACCEPT_REDLINE, nullptr ); - m_rDoc.GetIDocumentUndoRedo().AppendUndo( std::make_unique<SwUndoAcceptRedline>( aPam )); + m_rDoc.GetIDocumentUndoRedo().AppendUndo(std::make_unique<SwUndoAcceptRedline>(*pPam)); } int nRet = lcl_AcceptRejectRedl( lcl_AcceptRedline, maRedlineTable, - bCallDelete, aPam ); + bCallDelete, *pPam ); if( nRet > 0 ) { CompressRedlines(); diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index 8b8e1b6af15e..a9d8494bf442 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -635,6 +635,16 @@ const SwTable* SwDoc::TextToTable( const SwInsertTableOptions& rInsTableOpts, return nullptr; } + if (GetIDocumentUndoRedo().DoesUndo()) + { + GetIDocumentUndoRedo().StartUndo(SwUndoId::TEXTTOTABLE, nullptr); + } + + // tdf#153115 first, remove all redlines; splitting them at cell boundaries + // would be tricky to implement, and it's unclear what the value of + // existing redlines is once it's been converted to a table + getIDocumentRedlineAccess().AcceptRedline(rRange, true); + // Save first node in the selection if it is a context node SwContentNode * pSttContentNd = pStt->GetNode().GetContentNode(); @@ -645,7 +655,6 @@ const SwTable* SwDoc::TextToTable( const SwInsertTableOptions& rInsTableOpts, SwUndoTextToTable* pUndo = nullptr; if( GetIDocumentUndoRedo().DoesUndo() ) { - GetIDocumentUndoRedo().StartUndo( SwUndoId::TEXTTOTABLE, nullptr ); pUndo = new SwUndoTextToTable( aOriginal, rInsTableOpts, cCh, o3tl::narrowing<sal_uInt16>(eAdjust), pTAFormat ); GetIDocumentUndoRedo().AppendUndo( std::unique_ptr<SwUndo>(pUndo) ); |