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 5e6d8efbf3fb456ca370df04b21d2e340d9831ad
Author:     László Németh <nem...@numbertext.org>
AuthorDate: Mon Apr 24 13:08:55 2023 +0200
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Mon Apr 24 17:22:39 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 <nem...@numbertext.org>

diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx
index 3015223ef451..272ba18393f1 100644
--- a/sw/inc/swtable.hxx
+++ b/sw/inc/swtable.hxx
@@ -426,6 +426,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 889f4820e0fd..523f14e0c46f 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -1892,19 +1892,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 d85c132c15bc..855685eda05d 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;
         }
     }
@@ -1450,7 +1446,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;

Reply via email to