officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu |   14 ++++
 sw/inc/cmdid.h                                                      |    1 
 sw/qa/core/edit/edit.cxx                                            |   34 
++++++++++
 sw/sdi/docsh.sdi                                                    |    5 +
 sw/sdi/swriter.sdi                                                  |   18 
+++++
 sw/source/uibase/app/docsh.cxx                                      |    1 
 sw/source/uibase/app/docsh2.cxx                                     |   11 ++-
 sw/uiconfig/swriter/menubar/menubar.xml                             |    1 
 8 files changed, 84 insertions(+), 1 deletion(-)

New commits:
commit 4535698e0b16bf003e8a3705e28f7347f509eb12
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Mon Mar 31 09:02:59 2025 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Mon Mar 31 12:25:00 2025 +0200

    cool#11357 sw redline reinstate: add a reinstate-all command
    
    Accept and reject can be invoked for all redlines in a document, the
    same doesn't work with reinstate.
    
    Additional problem is that
    sw::DocumentRedlineManager::AcceptAllRedline() iterates over redlines by
    consuming them, but reinstate creates new redlines, so just naively
    doing the same would create an infinite loop.
    
    Fix the problem by reusing SwEditShell::ReinstateRedlinesInSelection()
    for reinstating all redlines: we can easily select the entire document
    and reinstate the selection's redlines.
    
    Change-Id: I24c84c1e5add59d94958bccff65261b5940d3104
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183530
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git 
a/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu 
b/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu
index 93270a3c1009..19a9b4ed7f20 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu
@@ -276,6 +276,20 @@
           <value>1</value>
         </prop>
       </node>
+      <node oor:name=".uno:ReinstateAllTrackedChanges" oor:op="replace">
+        <prop oor:name="Label" oor:type="xs:string">
+          <value xml:lang="en-US">Reinstate All</value>
+        </prop>
+        <prop oor:name="TooltipLabel" oor:type="xs:string">
+          <value xml:lang="en-US">Reinstate All Tracked Changes</value>
+        </prop>
+        <prop oor:name="PopupLabel" oor:type="xs:string">
+          <value xml:lang="en-US">Reinstate All Changes</value>
+        </prop>
+        <prop oor:name="Properties" oor:type="xs:int">
+          <value>1</value>
+        </prop>
+      </node>
       <node oor:name=".uno:AcceptTrackedChange" oor:op="replace">
         <prop oor:name="Label" oor:type="xs:string">
           <value xml:lang="en-US">Accept</value>
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index d2322244916a..2fc80a6e3956 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -154,6 +154,7 @@ class SwUINumRuleItem;
 #define FN_TRANSFORM_DOCUMENT_STRUCTURE (FN_EDIT2 + 47) /* overwrite text of 
content control, and more*/
 #define FN_COPY_FIELD                (FN_EDIT2 + 48)    /* show field content 
in readonly documents to copy content*/
 #define FN_CONVERT_SEL_FIELD         (FN_EDIT2 + 49)    /* convert selected 
field to text */
+#define FN_REDLINE_REINSTATE_ALL     (FN_EDIT2 + 50)    /* redlining reinstate 
all */
 
 // Region: View
 #define FN_DRAW_WRAP_DLG        TypedWhichId<SfxInt16Item>(FN_VIEW + 3)   /* 
Draw wrapping dlg */
diff --git a/sw/qa/core/edit/edit.cxx b/sw/qa/core/edit/edit.cxx
index cf96b865ac43..ce12c6ac3a72 100644
--- a/sw/qa/core/edit/edit.cxx
+++ b/sw/qa/core/edit/edit.cxx
@@ -367,6 +367,40 @@ CPPUNIT_TEST_FIXTURE(Test, testRedlineReinstateAndNext)
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), rRedlines.size());
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testRedlineReinstateAll)
+{
+    // Given a document with two deletions:
+    createSwDoc();
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
+    pWrtShell->Insert("abbcdde");
+    SwModule* pModule = SwModule::get();
+    pModule->SetRedlineAuthor("Alice");
+    RedlineFlags nMode = pWrtShell->GetRedlineFlags();
+    pWrtShell->SetRedlineFlags(nMode | RedlineFlags::On);
+    pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, 
/*bBasicCall=*/false);
+    pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/true, 2, 
/*bBasicCall=*/false);
+    pWrtShell->DelRight();
+    pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 3, 
/*bBasicCall=*/false);
+    pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/true, 2, 
/*bBasicCall=*/false);
+    pWrtShell->DelRight();
+    pWrtShell->SetRedlineFlags(nMode);
+
+    // When a 2nd user does reinstate-all:
+    pModule->SetRedlineAuthor("Bob");
+    pWrtShell->SttPara(/*bSelect=*/false);
+    dispatchCommand(mxComponent, ".uno:ReinstateAllTrackedChanges", {});
+
+    // Then make sure we have insertions for both deletions:
+    SwDoc* pDoc = pWrtShell->GetDoc();
+    IDocumentRedlineAccess& rIDRA = pDoc->getIDocumentRedlineAccess();
+    SwRedlineTable& rRedlines = rIDRA.GetRedlineTable();
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected: 4
+    // - Actual  : 2
+    // i.e. reinstate-all didn't create insert redlines.
+    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), rRedlines.size());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/sw/sdi/docsh.sdi b/sw/sdi/docsh.sdi
index 503de5036f7c..a6479ffbae96 100644
--- a/sw/sdi/docsh.sdi
+++ b/sw/sdi/docsh.sdi
@@ -71,6 +71,11 @@ interface TextDocument : BaseTextDocument
         ExecMethod = Execute;
         StateMethod = GetState;
     ]
+    FN_REDLINE_REINSTATE_ALL
+    [
+        ExecMethod = Execute;
+        StateMethod = GetState;
+    ]
 }
 
 shell SwDocShell
diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi
index cfd7451d2408..6e80a639c5ab 100644
--- a/sw/sdi/swriter.sdi
+++ b/sw/sdi/swriter.sdi
@@ -8117,6 +8117,24 @@ SfxVoidItem RejectAllTrackedChanges FN_REDLINE_REJECT_ALL
     GroupId = SfxGroupId::Edit;
 ]
 
+SfxVoidItem ReinstateAllTrackedChanges FN_REDLINE_REINSTATE_ALL
+[
+    AutoUpdate = FALSE,
+    FastCall = FALSE,
+    ReadOnlyDoc = FALSE,
+    Toggle = FALSE,
+    Container = FALSE,
+    RecordAbsolute = FALSE,
+    RecordPerSet;
+    Asynchron;
+
+
+    AccelConfig = TRUE,
+    MenuConfig = TRUE,
+    ToolBoxConfig = TRUE,
+    GroupId = SfxGroupId::Edit;
+]
+
 SfxVoidItem NextTrackedChange FN_REDLINE_NEXT_CHANGE
 ( SfxUInt32Item NextTrackedChange FN_REDLINE_NEXT_CHANGE )
 [
diff --git a/sw/source/uibase/app/docsh.cxx b/sw/source/uibase/app/docsh.cxx
index c4a5f02d8e2b..a95be1457362 100644
--- a/sw/source/uibase/app/docsh.cxx
+++ b/sw/source/uibase/app/docsh.cxx
@@ -1122,6 +1122,7 @@ void SwDocShell::GetState(SfxItemSet& rSet)
         break;
         case FN_REDLINE_ACCEPT_ALL:
         case FN_REDLINE_REJECT_ALL:
+        case FN_REDLINE_REINSTATE_ALL:
         {
             if 
(GetDoc()->getIDocumentRedlineAccess().GetRedlineTable().empty() ||
                 HasChangeRecordProtection()) // tdf#128229 Disable Accept / 
Reject all if redlines are password protected
diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx
index 207ec8769a71..ddd915880905 100644
--- a/sw/source/uibase/app/docsh2.cxx
+++ b/sw/source/uibase/app/docsh2.cxx
@@ -1297,6 +1297,7 @@ void SwDocShell::Execute(SfxRequest& rReq)
         break;
         case FN_REDLINE_ACCEPT_ALL:
         case FN_REDLINE_REJECT_ALL:
+        case FN_REDLINE_REINSTATE_ALL:
         {
             IDocumentRedlineAccess& rRedlineAccess = 
GetDoc()->getIDocumentRedlineAccess();
             SwWrtShell *pWrtShell = 
dynamic_cast<SwWrtShell*>(GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell());
@@ -1344,7 +1345,15 @@ void SwDocShell::Execute(SfxRequest& rReq)
                 pWrtShell->StartAllAction();
             }
 
-            rRedlineAccess.AcceptAllRedline(nWhich == FN_REDLINE_ACCEPT_ALL);
+            if (nWhich == FN_REDLINE_REINSTATE_ALL)
+            {
+                pWrtShell->SelAll();
+                pWrtShell->ReinstateRedlinesInSelection();
+            }
+            else
+            {
+                rRedlineAccess.AcceptAllRedline(nWhich == 
FN_REDLINE_ACCEPT_ALL);
+            }
 
             if (pWrtShell)
             {
diff --git a/sw/uiconfig/swriter/menubar/menubar.xml 
b/sw/uiconfig/swriter/menubar/menubar.xml
index 1c162b259913..35945f0713bf 100644
--- a/sw/uiconfig/swriter/menubar/menubar.xml
+++ b/sw/uiconfig/swriter/menubar/menubar.xml
@@ -140,6 +140,7 @@
           <menu:menuitem menu:id=".uno:RejectAllTrackedChanges"/>
           <menu:menuitem menu:id=".uno:ReinstateTrackedChange"/>
           <menu:menuitem menu:id=".uno:ReinstateTrackedChangeToNext"/>
+          <menu:menuitem menu:id=".uno:ReinstateAllTrackedChanges"/>
           <menu:menuseparator/>
           <menu:menuitem menu:id=".uno:CommentChangeTracking"/>
           <menu:menuitem menu:id=".uno:ProtectTraceChangeMode"/>

Reply via email to