[Libreoffice-commits] core.git: libreofficekit/qa sw/qa sw/sdi sw/source

Miklos Vajna vmiklos at collabora.co.uk
Thu Sep 15 15:04:34 UTC 2016


 libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx |    9 ++++--
 sw/qa/extras/uiwriter/uiwriter.cxx                  |   30 ++++++++++++++++++--
 sw/sdi/swriter.sdi                                  |    1 
 sw/source/uibase/uiview/view2.cxx                   |   16 +++++++++-
 4 files changed, 49 insertions(+), 7 deletions(-)

New commits:
commit 84e91157c674b0b78b792fc1d4f841fe50b1dd9b
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Sep 15 16:04:05 2016 +0200

    sw: allow select of redline by index
    
    Previously .uno:NextTrackedChange always worked by cursor position, but
    redlines are stored in the redline table, so they have a unique index.
    Allow specifying that index when invoking the command, and in that case
    ignore the cursor position.
    
    Change-Id: I7dbe8044feca8fcc48635482a22317b024f40ffa

diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 97b3350..2576f99 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -482,6 +482,8 @@ static void documentRedline(GtkWidget* pButton, gpointer /*pItem*/)
                                                      GTK_RESPONSE_YES,
                                                      "Reject",
                                                      GTK_RESPONSE_NO,
+                                                     "Jump",
+                                                     GTK_RESPONSE_APPLY,
                                                      nullptr);
     GtkWidget* pContentArea = gtk_dialog_get_content_area(GTK_DIALOG (pDialog));
 
@@ -518,7 +520,7 @@ static void documentRedline(GtkWidget* pButton, gpointer /*pItem*/)
     gint res = gtk_dialog_run(GTK_DIALOG(pDialog));
 
     // Dispatch the matching command, if necessary.
-    if (res == GTK_RESPONSE_YES || res == GTK_RESPONSE_NO)
+    if (res == GTK_RESPONSE_YES || res == GTK_RESPONSE_NO || res == GTK_RESPONSE_APPLY)
     {
         GtkTreeSelection* pSelection = gtk_tree_view_get_selection(GTK_TREE_VIEW(pTreeView));
         GtkTreeIter aTreeIter;
@@ -531,8 +533,11 @@ static void documentRedline(GtkWidget* pButton, gpointer /*pItem*/)
             std::string aCommand;
             if (res == GTK_RESPONSE_YES)
                 aCommand = ".uno:AcceptTrackedChange";
-            else
+            else if (res == GTK_RESPONSE_NO)
                 aCommand = ".uno:RejectTrackedChange";
+            else
+                // Just select the given redline, don't accept or reject it.
+                aCommand = ".uno:NextTrackedChange";
             // Without the '.uno:' prefix.
             std::string aKey = aCommand.substr(strlen(".uno:"));
 
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 8d0ed48..5080f37 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -3853,15 +3853,39 @@ void SwUiWriterTest::testRedlineParam()
     pWrtShell->EndDoc();
     pWrtShell->Insert("zzz");
 
-    // Move the cursor to the start again, and reject the second change.
+    // Select the first redline.
     pWrtShell->SttDoc();
     uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
     {
-        {"RejectTrackedChange", uno::makeAny(static_cast<sal_uInt16>(1))}
+        {"NextTrackedChange", uno::makeAny(static_cast<sal_uInt16>(0))}
     }));
-    lcl_dispatchCommand(mxComponent, ".uno:RejectTrackedChange", aPropertyValues);
+    lcl_dispatchCommand(mxComponent, ".uno:NextTrackedChange", aPropertyValues);
     Scheduler::ProcessEventsToIdle();
     SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false);
+    // This failed: the parameter wasn't handled so the next change (zzz) was
+    // selected, not the first one (aaa).
+    CPPUNIT_ASSERT_EQUAL(OUString("aaa"), pShellCursor->GetText());
+
+    // Select the second redline.
+    pWrtShell->SttDoc();
+    aPropertyValues = comphelper::InitPropertySequence(
+    {
+        {"NextTrackedChange", uno::makeAny(static_cast<sal_uInt16>(1))}
+    });
+    lcl_dispatchCommand(mxComponent, ".uno:NextTrackedChange", aPropertyValues);
+    Scheduler::ProcessEventsToIdle();
+    pShellCursor = pWrtShell->getShellCursor(false);
+    CPPUNIT_ASSERT_EQUAL(OUString("zzz"), pShellCursor->GetText());
+
+    // Move the cursor to the start again, and reject the second change.
+    pWrtShell->SttDoc();
+    aPropertyValues = comphelper::InitPropertySequence(
+    {
+        {"RejectTrackedChange", uno::makeAny(static_cast<sal_uInt16>(1))}
+    });
+    lcl_dispatchCommand(mxComponent, ".uno:RejectTrackedChange", aPropertyValues);
+    Scheduler::ProcessEventsToIdle();
+    pShellCursor = pWrtShell->getShellCursor(false);
 
     // This was 'middlezzz', the uno command rejected the redline under the
     // cursor, instead of the requested one.
diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi
index 96a05e1..c5c6568 100644
--- a/sw/sdi/swriter.sdi
+++ b/sw/sdi/swriter.sdi
@@ -7272,6 +7272,7 @@ SfxVoidItem RejectTrackedChange FN_REDLINE_REJECT_DIRECT
 ]
 
 SfxVoidItem NextTrackedChange FN_REDLINE_NEXT_CHANGE
+( SfxUInt16Item NextTrackedChange FN_REDLINE_NEXT_CHANGE )
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
diff --git a/sw/source/uibase/uiview/view2.cxx b/sw/source/uibase/uiview/view2.cxx
index 366641a..5d200ae 100644
--- a/sw/source/uibase/uiview/view2.cxx
+++ b/sw/source/uibase/uiview/view2.cxx
@@ -709,8 +709,20 @@ void SwView::Execute(SfxRequest &rReq)
 
         case FN_REDLINE_NEXT_CHANGE:
         {
+            // If a parameter is provided, try going to the nth change, not to
+            // the next one.
+            sal_uInt16 nRedline = USHRT_MAX;
+            if (pArgs && pArgs->GetItemState(nSlot, false, &pItem) == SfxItemState::SET)
+                nRedline = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
+
             const SwRangeRedline *pCurrent = m_pWrtShell->GetCurrRedline();
-            const SwRangeRedline *pNext = m_pWrtShell->SelNextRedline();
+            SwDoc* pDoc = m_pWrtShell->GetDoc();
+            const SwRedlineTable& rTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable();
+            const SwRangeRedline *pNext = nullptr;
+            if (nRedline < rTable.size())
+                pNext = m_pWrtShell->GotoRedline(nRedline, true);
+            else
+                pNext = m_pWrtShell->SelNextRedline();
 
             // FN_REDLINE_PREV_CHANGE leaves the selection point at the start of the redline.
             // In such cases, SelNextRedline (which starts searching from the selection point)
@@ -718,7 +730,7 @@ void SwView::Execute(SfxRequest &rReq)
 
             // This behavior means that PREV_CHANGE followed by NEXT_CHANGE would not change
             // the current redline, so we detect it and select the next redline again.
-            if (pCurrent && pCurrent == pNext)
+            if (pCurrent && pCurrent == pNext && nRedline == USHRT_MAX)
                 pNext = m_pWrtShell->SelNextRedline();
 
             if (pNext)


More information about the Libreoffice-commits mailing list