sw/qa/uitest/data/accept-all-overlap.docx   |binary
 sw/qa/uitest/writer_tests/trackedChanges.py |   17 +++++++++++++++++
 sw/source/uibase/misc/redlndlg.cxx          |    9 +++++++--
 3 files changed, 24 insertions(+), 2 deletions(-)

New commits:
commit 9f984931cea1c2827eed48f18532ca339e2baf44
Author:     Miklos Vajna <[email protected]>
AuthorDate: Thu Dec 11 08:27:09 2025 +0100
Commit:     Caolán McNamara <[email protected]>
CommitDate: Thu Dec 11 09:52:19 2025 +0100

    tdf#168737 sw interdependent redlines, direct: fix accept-all from dialog
    
    Open the bugdoc, open the manage changes dialog, accept all changes by
    clicking on the "accept all" button, not all changes are accepted.
    
    This went wrong in commit 55640f9f0a4741f8e4b5b98096af822cee71da2c
    (tdf#166319 sw interdependent redlines: allow accept/reject for fmt on
    ins/del, 2025-09-29), which made it possible to only accept the directly
    selectable part of a hierarchical redline (e.g. only the format of a
    format-on-insert construct). Notice how clicking on the "accept all"
    toolbar button works fine, since it doesn't enable the "direct" mode.
    
    Fix the problem by extending SwRedlineAcceptDlg::CallAcceptReject(), so
    it keeps asking Writer core to accept/reject changes directly when one
    or more redline is selected, but go back to the default non-direct mode
    when accepting or rejecting all redlines.
    
    Cover this with a UI test, since the problem here is not around how
    these redlines are rejected, but it's about how UI code invokes performs
    these operations using SwWrtShell.
    
    Change-Id: I8024d352b1512bd8d5c608087b684502624fd0a6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195423
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Caolán McNamara <[email protected]>

diff --git a/sw/qa/uitest/data/accept-all-overlap.docx 
b/sw/qa/uitest/data/accept-all-overlap.docx
new file mode 100644
index 000000000000..851d3b7edc2d
Binary files /dev/null and b/sw/qa/uitest/data/accept-all-overlap.docx differ
diff --git a/sw/qa/uitest/writer_tests/trackedChanges.py 
b/sw/qa/uitest/writer_tests/trackedChanges.py
index a256889a8a8b..32ba68964ac6 100644
--- a/sw/qa/uitest/writer_tests/trackedChanges.py
+++ b/sw/qa/uitest/writer_tests/trackedChanges.py
@@ -608,6 +608,23 @@ class trackedchanges(UITestCase):
 
                 self.assertEqual(0, len(changesList.getChildren()))
 
+    def test_accept_all_deletes_all_redlines(self):
+        # Given a document with overlapping changes:
+        with 
self.ui_test.load_file(get_url_for_data_file("accept-all-overlap.docx")) as 
document:
+            xWriterDoc = self.xUITest.getTopFocusWindow()
+            xWriterEdit = xWriterDoc.getChild("writer_edit")
+
+            # When accepting all changes using the manage changes dialog:
+            with 
self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges",
 close_button="close") as xTrackDlg:
+                xAccBtn = xTrackDlg.getChild("acceptall")
+                xAccBtn.executeAction("CLICK", tuple())
+
+            # Then make sure all changes are accepted:
+            # Without the accompanying fix in place, this failed with:
+            # AssertionError: 1 != 0
+            # i.e. a change was not accepted.
+            self.assertEqual(document.Redlines.Count, 0)
+
     def test_tdf155847_multiple_tracked_columns_crash(self):
         with 
self.ui_test.load_file(get_url_for_data_file("TC-table-del-add.docx")) as 
document:
 
diff --git a/sw/source/uibase/misc/redlndlg.cxx 
b/sw/source/uibase/misc/redlndlg.cxx
index efb886526a26..5050d4f1e8c0 100644
--- a/sw/source/uibase/misc/redlndlg.cxx
+++ b/sw/source/uibase/misc/redlndlg.cxx
@@ -1192,8 +1192,13 @@ void SwRedlineAcceptDlg::CallAcceptReject( bool bSelect, 
bool bAccept )
     for (const auto& rRedLine : aRedlines)
     {
         SwRedlineTable::size_type nPosition = GetRedlinePos( *rRedLine );
+
+        // bSelect is false for "accept/reject all", true when only 
accepting/rejecting one or more
+        // selected changes. Only use direct accept/reject for explicitly 
selected changes.
+        bool bDirect = bSelect;
+
         if( nPosition != SwRedlineTable::npos )
-            (pSh->*FnAccRej)( nPosition, /*bDirect=*/true );
+            (pSh->*FnAccRej)( nPosition, bDirect );
 
         // handle redlines of table rows, stored as children of the item 
associated
         // to the deleted/inserted table row(s)
@@ -1208,7 +1213,7 @@ void SwRedlineAcceptDlg::CallAcceptReject( bool bSelect, 
bool bAccept )
                 {
                     nPosition = GetRedlinePos( *xChild );
                     if( nPosition != SwRedlineTable::npos )
-                        (pSh->*FnAccRej)( nPosition, /*bDirect=*/true );
+                        (pSh->*FnAccRej)( nPosition, bDirect );
                 }
                 while ( rTreeView.iter_next_sibling(*xChild) );
             }

Reply via email to