[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - desktop/source include/svl officecfg/registry sfx2/source sw/inc sw/qa sw/sdi sw/source sw/uiconfig

Henry Castro hcastro at collabora.com
Tue Nov 28 21:08:51 UTC 2017


 desktop/source/lib/init.cxx                                         |    4 
 include/svl/hint.hxx                                                |    1 
 officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu |   28 +++
 sfx2/source/control/unoctitm.cxx                                    |    5 
 sw/inc/IDocumentRedlineAccess.hxx                                   |    2 
 sw/inc/cmdid.h                                                      |    2 
 sw/qa/extras/tiledrendering/tiledrendering.cxx                      |   74 ++++++++++
 sw/sdi/docsh.sdi                                                    |   10 +
 sw/sdi/swriter.sdi                                                  |   36 ++++
 sw/source/core/doc/DocumentRedlineManager.cxx                       |   32 ++++
 sw/source/core/inc/DocumentRedlineManager.hxx                       |    2 
 sw/source/uibase/app/docsh.cxx                                      |    7 
 sw/source/uibase/app/docsh2.cxx                                     |   27 +++
 sw/source/uibase/uiview/view.cxx                                    |   16 ++
 sw/uiconfig/swriter/menubar/menubar.xml                             |    2 
 15 files changed, 246 insertions(+), 2 deletions(-)

New commits:
commit af44e1547121f0292cd43fb8db6545e44594020d
Author: Henry Castro <hcastro at collabora.com>
Date:   Sat Nov 4 12:18:53 2017 -0400

    sw lok: add Accept/Reject All tracked changes, tdf#101977
    
    Change-Id: I04d747343e24cb498a621c965d034d0791411d83
    Reviewed-on: https://gerrit.libreoffice.org/44311
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Henry Castro <hcastro at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/44486
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index fe046459751f..515e148c1f04 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1761,7 +1761,9 @@ static void doc_iniUnoCommands ()
         OUString(".uno:TrackChanges"),
         OUString(".uno:ShowTrackedChanges"),
         OUString(".uno:NextTrackedChange"),
-        OUString(".uno:PreviousTrackedChange")
+        OUString(".uno:PreviousTrackedChange"),
+        OUString(".uno:AcceptAllTrackedChanges"),
+        OUString(".uno:RejectAllTrackedChanges")
     };
 
     util::URL aCommandURL;
diff --git a/include/svl/hint.hxx b/include/svl/hint.hxx
index 70f5fc74e8d6..31404cf31748 100644
--- a/include/svl/hint.hxx
+++ b/include/svl/hint.hxx
@@ -31,6 +31,7 @@
 #define SFX_HINT_DEINITIALIZING     0x00000040
 #define SFX_HINT_MODECHANGED        0x00000080
 #define SFX_HINT_LANGUAGECHANGED    0x00000100
+#define SFX_HINT_REDLINECHANGED     0x00000200
     // unused, formerly SFX_HINT_CANCELLABLE
     // unused, formerly SFX_HINT_DATAAVAILABLE
     // unused, formerly SFX_HINT_SAVECOMPLETED
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu
index a93ed1e2318a..3e127c10d1ee 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu
@@ -236,6 +236,20 @@
           <value>1</value>
         </prop>
       </node>
+      <node oor:name=".uno:RejectAllTrackedChanges" oor:op="replace">
+        <prop oor:name="Label" oor:type="xs:string">
+          <value xml:lang="en-US">Reject All</value>
+        </prop>
+        <prop oor:name="TooltipLabel" oor:type="xs:string">
+          <value xml:lang="en-US">Reject All Tracked Changes</value>
+        </prop>
+        <prop oor:name="PopupLabel" oor:type="xs:string">
+          <value xml:lang="en-US">Reject 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>
@@ -250,6 +264,20 @@
           <value>1</value>
         </prop>
       </node>
+      <node oor:name=".uno:AcceptAllTrackedChanges" oor:op="replace">
+        <prop oor:name="Label" oor:type="xs:string">
+          <value xml:lang="en-US">Accept All</value>
+        </prop>
+        <prop oor:name="TooltipLabel" oor:type="xs:string">
+          <value xml:lang="en-US">Accept All Tracked Changes</value>
+        </prop>
+        <prop oor:name="PopupLabel" oor:type="xs:string">
+          <value xml:lang="en-US">Accept All Changes</value>
+        </prop>
+        <prop oor:name="Properties" oor:type="xs:int">
+          <value>1</value>
+        </prop>
+      </node>
       <node oor:name=".uno:NextTrackedChange" oor:op="replace">
         <prop oor:name="Label" oor:type="xs:string">
           <value xml:lang="en-US">Next</value>
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx
index 394653cd582f..c55005d8433d 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -1070,7 +1070,10 @@ static void InterceptLOKStateChangeEvent(const SfxViewFrame* pViewFrame, const c
              aEvent.FeatureURL.Path == "EntireColumn" ||
              aEvent.FeatureURL.Path == "EntireCell" ||
              aEvent.FeatureURL.Path == "SortAscending" ||
-             aEvent.FeatureURL.Path == "SortDescending")
+             aEvent.FeatureURL.Path == "SortDescending" ||
+             aEvent.FeatureURL.Path == "AcceptAllTrackedChanges" ||
+             aEvent.FeatureURL.Path == "RejectAllTrackedChanges")
+
     {
         aBuffer.append(aEvent.IsEnabled ? OUString("enabled") : OUString("disabled"));
     }
diff --git a/sw/inc/IDocumentRedlineAccess.hxx b/sw/inc/IDocumentRedlineAccess.hxx
index 5488f7fcd66d..647f0980e631 100644
--- a/sw/inc/IDocumentRedlineAccess.hxx
+++ b/sw/inc/IDocumentRedlineAccess.hxx
@@ -204,6 +204,8 @@ public:
 
     virtual const SwRangeRedline* SelPrevRedline(/*[in]*/SwPaM& rPam) const = 0;
 
+    virtual void AcceptAllRedline(/*[in]*/bool bAcceptReject) = 0;
+
     // Representation has changed, invalidate all Redlines.
     virtual void UpdateRedlineAttr() = 0;
 
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index 476b2decca02..347cbe7d39aa 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -143,6 +143,8 @@
 #define FN_COPY_HYPERLINK_LOCATION   (FN_EDIT2 + 40)    /* copy hyperlink URL to clipboard */
 #define FN_REDLINE_NEXT_CHANGE       (FN_EDIT2 + 41)    /* Go to the next change */
 #define FN_REDLINE_PREV_CHANGE       (FN_EDIT2 + 42)    /* Go to the previous change */
+#define FN_REDLINE_ACCEPT_ALL        (FN_EDIT2 + 43)    /* Redlining Accept All*/
+#define FN_REDLINE_REJECT_ALL        (FN_EDIT2 + 44)    /* Redlining Reject All*/
 
 // Region: Edit
 #define FN_REFRESH_VIEW         (FN_VIEW + 1)   /* Refresh/Redraw */
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index a1694ab269dc..0365ec10cc75 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -30,6 +30,8 @@
 #include <UndoManager.hxx>
 #include <cmdid.h>
 #include <sfx2/viewsh.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
 #include <sfx2/lokhelper.hxx>
 #include <redline.hxx>
 #include <IDocumentRedlineAccess.hxx>
@@ -84,6 +86,7 @@ public:
     void testUndoRepairResult();
     void testRedoRepairResult();
     void testDisableUndoRepair();
+    void testAllTrackedChanges();
 
 
     CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
@@ -130,6 +133,7 @@ public:
     CPPUNIT_TEST(testUndoRepairResult);
     CPPUNIT_TEST(testRedoRepairResult);
     CPPUNIT_TEST(testDisableUndoRepair);
+    CPPUNIT_TEST(testAllTrackedChanges);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -1802,6 +1806,76 @@ void SwTiledRenderingTest::testDisableUndoRepair()
     comphelper::LibreOfficeKit::setActive(false);
 }
 
+void SwTiledRenderingTest::testAllTrackedChanges()
+{
+    // Load a document.
+    comphelper::LibreOfficeKit::setActive();
+    createDoc("dummy.fodt");
+
+    uno::Reference<beans::XPropertySet> xPropSet(mxComponent, uno::UNO_QUERY);
+    xPropSet->setPropertyValue("RecordChanges", uno::makeAny(true));
+
+    // view #1
+    SwView* pView1 = dynamic_cast<SwView*>(SfxViewShell::Current());
+    SwWrtShell* pWrtShell1 = pView1->GetWrtShellPtr();
+
+    // view #2
+    SfxLokHelper::createView();
+    SwView* pView2 = dynamic_cast<SwView*>(SfxViewShell::Current());
+    CPPUNIT_ASSERT(pView1 != pView2);
+    SwWrtShell* pWrtShell2 = pView2->GetWrtShellPtr();
+    // Insert text and reject all
+    {
+        pWrtShell1->SttDoc();
+        pWrtShell1->Insert("hxx");
+
+        pWrtShell2->EndDoc();
+        pWrtShell2->Insert("cxx");
+    }
+
+    // Get the redline
+    const SwRedlineTable& rTable = pWrtShell2->GetDoc()->getIDocumentRedlineAccess().GetRedlineTable();
+    CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(2), rTable.size());
+    {
+        SfxVoidItem aItem(FN_REDLINE_REJECT_ALL);
+        pView1->GetViewFrame()->GetDispatcher()->ExecuteList(FN_REDLINE_REJECT_ALL,
+            SfxCallMode::SYNCHRON, { &aItem });
+    }
+
+    // The reject all was performed.
+    CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(0), rTable.size());
+    {
+        SwShellCursor* pShellCursor = pWrtShell1->getShellCursor(false);
+        CPPUNIT_ASSERT_EQUAL(OUString("Aaa bbb."), pShellCursor->GetPoint()->nNode.GetNode().GetTextNode()->GetText());
+    }
+
+    // Insert text and accept all
+    {
+        pWrtShell1->SttDoc();
+        pWrtShell1->Insert("hyy");
+
+        pWrtShell2->EndDoc();
+        pWrtShell2->Insert("cyy");
+    }
+
+    CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(2), rTable.size());
+    {
+        SfxVoidItem aItem(FN_REDLINE_ACCEPT_ALL);
+        pView1->GetViewFrame()->GetDispatcher()->ExecuteList(FN_REDLINE_ACCEPT_ALL,
+            SfxCallMode::SYNCHRON, { &aItem });
+    }
+
+    // The accept all was performed
+    CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(0), rTable.size());
+    {
+        SwShellCursor* pShellCursor = pWrtShell2->getShellCursor(false);
+        CPPUNIT_ASSERT_EQUAL(OUString("hyyAaa bbb.cyy"), pShellCursor->GetPoint()->nNode.GetNode().GetTextNode()->GetText());
+    }
+
+    comphelper::LibreOfficeKit::setActive(false);
+}
+
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/sdi/docsh.sdi b/sw/sdi/docsh.sdi
index 511823fbaeb9..503de5036f7c 100644
--- a/sw/sdi/docsh.sdi
+++ b/sw/sdi/docsh.sdi
@@ -61,6 +61,16 @@ interface TextDocument : BaseTextDocument
         ExecMethod = Execute;
         StateMethod = GetState;
     ]
+    FN_REDLINE_ACCEPT_ALL
+    [
+        ExecMethod = Execute;
+        StateMethod = GetState;
+    ]
+    FN_REDLINE_REJECT_ALL
+    [
+        ExecMethod = Execute;
+        StateMethod = GetState;
+    ]
 }
 
 shell SwDocShell
diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi
index 3226f27b24b3..2a2dc85e4728 100644
--- a/sw/sdi/swriter.sdi
+++ b/sw/sdi/swriter.sdi
@@ -7270,6 +7270,24 @@ SfxVoidItem AcceptTrackedChange FN_REDLINE_ACCEPT_DIRECT
     GroupId = GID_EDIT;
 ]
 
+SfxVoidItem AcceptAllTrackedChanges FN_REDLINE_ACCEPT_ALL
+[
+    AutoUpdate = FALSE,
+    FastCall = FALSE,
+    ReadOnlyDoc = FALSE,
+    Toggle = FALSE,
+    Container = FALSE,
+    RecordAbsolute = FALSE,
+    RecordPerSet;
+    Asynchron;
+
+
+    AccelConfig = TRUE,
+    MenuConfig = TRUE,
+    ToolBoxConfig = TRUE,
+    GroupId = GID_EDIT;
+]
+
 SfxVoidItem RejectTrackedChange FN_REDLINE_REJECT_DIRECT
 ( SfxUInt32Item RejectTrackedChange FN_REDLINE_REJECT_DIRECT )
 [
@@ -7289,6 +7307,24 @@ SfxVoidItem RejectTrackedChange FN_REDLINE_REJECT_DIRECT
     GroupId = GID_EDIT;
 ]
 
+SfxVoidItem RejectAllTrackedChanges FN_REDLINE_REJECT_ALL
+[
+    AutoUpdate = FALSE,
+    FastCall = FALSE,
+    ReadOnlyDoc = FALSE,
+    Toggle = FALSE,
+    Container = FALSE,
+    RecordAbsolute = FALSE,
+    RecordPerSet;
+    Asynchron;
+
+
+    AccelConfig = TRUE,
+    MenuConfig = TRUE,
+    ToolBoxConfig = TRUE,
+    GroupId = GID_EDIT;
+]
+
 SfxVoidItem NextTrackedChange FN_REDLINE_NEXT_CHANGE
 ( SfxUInt32Item NextTrackedChange FN_REDLINE_NEXT_CHANGE )
 [
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx
index a9fcfb984091..cc1be6ae1c3c 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -2343,6 +2343,38 @@ bool DocumentRedlineManager::RejectRedline( const SwPaM& rPam, bool bCallDelete
     // #TODO - add 'SwExtraRedlineTable' also ?
 }
 
+void DocumentRedlineManager::AcceptAllRedline(bool bAccept)
+{
+    OUString sUndoStr;
+    IDocumentUndoRedo& rUndoMgr = m_rDoc.GetIDocumentUndoRedo();
+
+    if (mpRedlineTable->size() > 1)
+    {
+        {
+            SwRewriter aRewriter;
+            aRewriter.AddRule(UndoArg1, OUString::number(mpRedlineTable->size()));
+            sUndoStr = aRewriter.Apply(SW_RES(STR_N_REDLINES));
+        }
+
+        SwRewriter aRewriter;
+        aRewriter.AddRule(UndoArg1, sUndoStr);
+        rUndoMgr.StartUndo(bAccept ? UNDO_ACCEPT_REDLINE : UNDO_REJECT_REDLINE, &aRewriter);
+    }
+
+    while (mpRedlineTable->size() > 0)
+    {
+        if (bAccept)
+            AcceptRedline(mpRedlineTable->size() - 1, true);
+        else
+            RejectRedline(mpRedlineTable->size() - 1, true);
+    }
+
+    if (!sUndoStr.isEmpty())
+    {
+        rUndoMgr.EndUndo(UNDO_EMPTY, nullptr);
+    }
+}
+
 const SwRangeRedline* DocumentRedlineManager::SelNextRedline( SwPaM& rPam ) const
 {
     rPam.DeleteMark();
diff --git a/sw/source/core/inc/DocumentRedlineManager.hxx b/sw/source/core/inc/DocumentRedlineManager.hxx
index bdcd45c5fc67..643e1c164687 100644
--- a/sw/source/core/inc/DocumentRedlineManager.hxx
+++ b/sw/source/core/inc/DocumentRedlineManager.hxx
@@ -89,6 +89,8 @@ public:
 
     virtual bool RejectRedline(/*[in]*/const SwPaM& rPam, /*[in]*/bool bCallDelete) override;
 
+    virtual void AcceptAllRedline(/*[in]*/bool bAcceptReject) override;
+
     virtual const SwRangeRedline* SelNextRedline(/*[in]*/SwPaM& rPam) const override;
 
     virtual const SwRangeRedline* SelPrevRedline(/*[in]*/SwPaM& rPam) const override;
diff --git a/sw/source/uibase/app/docsh.cxx b/sw/source/uibase/app/docsh.cxx
index 235c553c4f6d..ce71a05d9887 100644
--- a/sw/source/uibase/app/docsh.cxx
+++ b/sw/source/uibase/app/docsh.cxx
@@ -1078,6 +1078,13 @@ void SwDocShell::GetState(SfxItemSet& rSet)
             rSet.Put( SfxBoolItem( SID_NOTEBOOKBAR, bVisible ) );
         }
         break;
+        case FN_REDLINE_ACCEPT_ALL:
+        case FN_REDLINE_REJECT_ALL:
+        {
+            if (GetDoc()->getIDocumentRedlineAccess().GetRedlineTable().size() == 0)
+                rSet.DisableItem(nWhich);
+        }
+        break;
 
         default: OSL_ENSURE(false,"You cannot get here!");
 
diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx
index 55db8a619643..2fb1557bbd41 100644
--- a/sw/source/uibase/app/docsh2.cxx
+++ b/sw/source/uibase/app/docsh2.cxx
@@ -1207,6 +1207,33 @@ void SwDocShell::Execute(SfxRequest& rReq)
             }
         }
         break;
+        case FN_REDLINE_ACCEPT_ALL:
+        case FN_REDLINE_REJECT_ALL:
+        {
+            IDocumentRedlineAccess& rRedlineAccess = GetDoc()->getIDocumentRedlineAccess();
+            SwWrtShell *pWrtShell = dynamic_cast<SwWrtShell*>(GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell());
+
+            if (rRedlineAccess.GetRedlineTable().empty())
+            {
+                break;
+            }
+
+            if (pWrtShell)
+            {
+                pWrtShell->StartAllAction();
+            }
+
+            rRedlineAccess.AcceptAllRedline(nWhich == FN_REDLINE_ACCEPT_ALL);
+
+            if (pWrtShell)
+            {
+                pWrtShell->EndAllAction();
+            }
+
+            Broadcast(SfxHint(SFX_HINT_REDLINECHANGED));
+            rReq.Done();
+        }
+        break;
 
         default: OSL_FAIL("wrong Dispatcher");
     }
diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx
index 47b0154fd671..ea211cf616f5 100644
--- a/sw/source/uibase/uiview/view.cxx
+++ b/sw/source/uibase/uiview/view.cxx
@@ -1652,6 +1652,22 @@ void SwView::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
                     }
                 }
                 break;
+            case SFX_HINT_REDLINECHANGED:
+                {
+                    sal_uInt16 aSlotRedLine[] = {
+                        FN_REDLINE_NEXT_CHANGE,
+                        FN_REDLINE_PREV_CHANGE,
+                        FN_REDLINE_ACCEPT_DIRECT,
+                        FN_REDLINE_REJECT_DIRECT,
+                        FN_REDLINE_ACCEPT_ALL,
+                        FN_REDLINE_REJECT_ALL,
+                        0
+                    };
+                    GetViewFrame()->GetBindings().Invalidate(aSlotRedLine);
+                }
+                break;
+
+            default: break;
         }
     }
 
diff --git a/sw/uiconfig/swriter/menubar/menubar.xml b/sw/uiconfig/swriter/menubar/menubar.xml
index a9474f441cb7..bf0c145b1dc9 100644
--- a/sw/uiconfig/swriter/menubar/menubar.xml
+++ b/sw/uiconfig/swriter/menubar/menubar.xml
@@ -118,7 +118,9 @@
           <menu:menuitem menu:id=".uno:PreviousTrackedChange"/>
           <menu:menuitem menu:id=".uno:NextTrackedChange"/>
           <menu:menuitem menu:id=".uno:AcceptTrackedChange"/>
+          <menu:menuitem menu:id=".uno:AcceptAllTrackedChanges"/>
           <menu:menuitem menu:id=".uno:RejectTrackedChange"/>
+          <menu:menuitem menu:id=".uno:RejectAllTrackedChanges"/>
           <menu:menuseparator/>
           <menu:menuitem menu:id=".uno:CommentChangeTracking"/>
           <menu:menuitem menu:id=".uno:ProtectTraceChangeMode"/>


More information about the Libreoffice-commits mailing list