sw/inc/swtable.hxx | 2 ++ sw/source/core/table/swtable.cxx | 10 ++++++++-- sw/source/uibase/shells/tabsh.cxx | 14 +++++--------- 3 files changed, 15 insertions(+), 11 deletions(-)
New commits: commit 1555ba4dd9e90f0dfd39df952c3d2fd5e755e2f5 Author: László Németh <[email protected]> AuthorDate: Mon Apr 24 13:08:55 2023 +0200 Commit: László Németh <[email protected]> CommitDate: Tue Apr 25 14:30:22 2023 +0200 tdf#154859 sw: fix deletion of tracked row insertion Row deletion of tracked row insertions resulted an empty, not tracked row. To fix this, disable row deletion on tracked row insertions, allowing only to manage changes for removing the row, e.g. by clicking on Reject Change of the context menu of the table row, like MSO does. This also avoids of clicking again on the row deletion to create an empty tracked row deletion from the empty not tracked row, and originally, from the tracked row insertion. Regression from commit 05366b8e6683363688de8708a3d88cf144c7a2bf "tdf#60382 sw offapi: add change tracking of table/row deletion". Follow-up to commit 0204c00f241313e1d292b4c3ea117d42af7dec69 "tdf#147453 sw: disable Delete Table functions on tracked deletions". See also commit 95c003d75e0f8b255344715a35358072b5eba99d "tdf#146145 sw: 1-click Accept/Reject of table row changes". Change-Id: Ied38860939359caa52e09987cf968953399611ec Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150938 Tested-by: Jenkins Reviewed-by: László Németh <[email protected]> (cherry picked from commit 926bc5eefa593d2a4a830709242ce3fe555f1e9a) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150922 diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx index 0ad1deffb42e..325b450b73ef 100644 --- a/sw/inc/swtable.hxx +++ b/sw/inc/swtable.hxx @@ -414,6 +414,8 @@ public: // Cache also the type of the redline associated to the changed table row. SwRedlineTable::size_type UpdateTextChangesOnly( SwRedlineTable::size_type& rRedlinePos, bool bUpdateProperty = true) const; + // is it a tracked row + bool IsTracked(SwRedlineTable::size_type& rRedlinePos, bool bOnlyDeleted = false) const; // is it a tracked deleted row bool IsDeleted(SwRedlineTable::size_type& rRedlinePos) const; // set/get (if it's possible, cached) redline type diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index 7fa3c3caea4d..de5d59bcf0c3 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -1766,19 +1766,25 @@ SwRedlineTable::size_type SwTableLine::UpdateTextChangesOnly( return nRet; } -bool SwTableLine::IsDeleted(SwRedlineTable::size_type& rRedlinePos) const +bool SwTableLine::IsTracked(SwRedlineTable::size_type& rRedlinePos, bool bOnlyDeleted) const { SwRedlineTable::size_type nPos = UpdateTextChangesOnly(rRedlinePos); if ( nPos != SwRedlineTable::npos ) { const SwRedlineTable& aRedlineTable = GetFrameFormat()->GetDoc()->getIDocumentRedlineAccess().GetRedlineTable(); - if ( RedlineType::Delete == aRedlineTable[nPos]->GetType() ) + if ( RedlineType::Delete == aRedlineTable[nPos]->GetType() || + ( !bOnlyDeleted && RedlineType::Insert == aRedlineTable[nPos]->GetType() ) ) return true; } return false; } +bool SwTableLine::IsDeleted(SwRedlineTable::size_type& rRedlinePos) const +{ + return IsTracked(rRedlinePos, true); +} + RedlineType SwTableLine::GetRedlineType() const { const SwRedlineTable& aRedlineTable = GetFrameFormat()->GetDoc()->getIDocumentRedlineAccess().GetRedlineTable(); diff --git a/sw/source/uibase/shells/tabsh.cxx b/sw/source/uibase/shells/tabsh.cxx index 519cdb90d16c..423898d3221f 100644 --- a/sw/source/uibase/shells/tabsh.cxx +++ b/sw/source/uibase/shells/tabsh.cxx @@ -446,17 +446,13 @@ static void lcl_TabGetMaxLineWidth(const SvxBorderLine* pBorderLine, SvxBorderLi rBorderLine.SetColor(pBorderLine->GetColor()); } -static bool lcl_BoxesInDeletedRows(SwWrtShell &rSh, const SwSelBoxes& rBoxes) +static bool lcl_BoxesInTrackedRows(SwWrtShell &rSh, const SwSelBoxes& rBoxes) { - // cursor and selection are there only in deleted rows in Show Changes mode - if ( rSh.GetLayout()->IsHideRedlines() ) - return false; - - // not selected or all selected rows are deleted + // cursor and selection are there only in tracked rows bool bRet = true; SwRedlineTable::size_type nRedlinePos = 0; if ( rBoxes.empty() ) - bRet = rSh.GetCursor()->GetPointNode().GetTableBox()->GetUpper()->IsDeleted(nRedlinePos); + bRet = rSh.GetCursor()->GetPointNode().GetTableBox()->GetUpper()->IsTracked(nRedlinePos); else { tools::Long nBoxes = rBoxes.size(); @@ -465,7 +461,7 @@ static bool lcl_BoxesInDeletedRows(SwWrtShell &rSh, const SwSelBoxes& rBoxes) { SwTableLine* pLine = rBoxes[i]->GetUpper(); if ( pLine != pPrevLine ) - bRet &= pLine->IsDeleted(nRedlinePos); + bRet &= pLine->IsTracked(nRedlinePos); pPrevLine = pLine; } } @@ -1451,7 +1447,7 @@ void SwTableShell::GetState(SfxItemSet &rSet) { SwSelBoxes aBoxes; ::GetTableSel( rSh, aBoxes, SwTableSearchType::Row ); - if( ::HasProtectedCells( aBoxes ) || lcl_BoxesInDeletedRows( rSh, aBoxes ) ) + if( ::HasProtectedCells( aBoxes ) || lcl_BoxesInTrackedRows( rSh, aBoxes ) ) rSet.DisableItem( nSlot ); } break;
