sw/qa/uitest/writer_tests/trackedChanges.py |    7 +--
 sw/source/uibase/inc/redlndlg.hxx           |    2 +
 sw/source/uibase/misc/redlndlg.cxx          |   54 +++++++++++++++-------------
 3 files changed, 34 insertions(+), 29 deletions(-)

New commits:
commit 7ae0542f7208573b18dadb0dee550f34ce8e41f4
Author:     Jim Raykowski <rayk...@gmail.com>
AuthorDate: Sat Aug 3 12:57:22 2024 -0800
Commit:     Jim Raykowski <rayk...@gmail.com>
CommitDate: Mon Aug 26 01:04:57 2024 +0200

    resolves: tdf#162337 Initial selection of tracked change when Manage
    
    Changes dialog is initially opened
    
    Restores behavior of tracked change selection in the document and tree
    entry selection in the Manage Changes dialog on opening to that of
    commit
    d9466e9e09f8aa618f722d9d7bef7469aa51dc14 with the exception that the
    tracked change selected when the cursor is after the last tracked change
    in the document is now wrapped to the first tracked change in the
    document, see commit 8e6203bd8f4390698f83a74a04f901437a9a61a3.
    
    Change-Id: Ic1be06bb99787393d7962bd19fc791959408956e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171451
    Tested-by: Jenkins
    Reviewed-by: Jim Raykowski <rayk...@gmail.com>

diff --git a/sw/qa/uitest/writer_tests/trackedChanges.py 
b/sw/qa/uitest/writer_tests/trackedChanges.py
index d013be0343e3..a256889a8a8b 100644
--- a/sw/qa/uitest/writer_tests/trackedChanges.py
+++ b/sw/qa/uitest/writer_tests/trackedChanges.py
@@ -279,7 +279,9 @@ class trackedchanges(UITestCase):
             self.assertEqual(3, len(tables))
 
             # goto to the start of the document to reject from the first 
tracked table row change
-            self.xUITest.executeCommand(".uno:GoToStartOfDoc")
+            self.xUITest.executeCommand(".uno:GoToStartOfDoc")  # start of cell
+            self.xUITest.executeCommand(".uno:GoToStartOfDoc")  # start of 
table
+            self.xUITest.executeCommand(".uno:GoToStartOfDoc")  # start of 
document
 
             # Reject
             with 
self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges",
 close_button="close") as xTrackDlg:
@@ -291,9 +293,6 @@ class trackedchanges(UITestCase):
 
                 changesList.getChild(0).executeAction("SELECT", tuple())
 
-                # jump to the parent to allow rejecting the table change
-                changesList.executeAction("TYPE", mkPropertyValues({"KEYCODE": 
"LEFT"}))
-
                 # Without the fix in place, it would have crashed here
                 for i in (3, 2, 1, 0):
                     xAccBtn = xTrackDlg.getChild("reject")
diff --git a/sw/source/uibase/inc/redlndlg.hxx 
b/sw/source/uibase/inc/redlndlg.hxx
index ef8c0cd8dce3..e38fd83f68b3 100644
--- a/sw/source/uibase/inc/redlndlg.hxx
+++ b/sw/source/uibase/inc/redlndlg.hxx
@@ -85,6 +85,8 @@ class SW_DLLPUBLIC SwRedlineAcceptDlg final : public 
SfxListener
     SvxTPView* m_pTPView;
     SvxRedlinTable* m_pTable; // PB 2006/02/02 #i48648 now SvHeaderTabListBox
 
+    bool m_bInitialSelect = true;
+
     DECL_DLLPRIVATE_LINK(SortByComboBoxChangedHdl, SvxTPView*, void);
 
     DECL_DLLPRIVATE_LINK( AcceptHdl,     SvxTPView*, void );
diff --git a/sw/source/uibase/misc/redlndlg.cxx 
b/sw/source/uibase/misc/redlndlg.cxx
index 028ca49873d0..2f758048d14b 100644
--- a/sw/source/uibase/misc/redlndlg.cxx
+++ b/sw/source/uibase/misc/redlndlg.cxx
@@ -266,7 +266,8 @@ SwRedlineAcceptDlg::~SwRedlineAcceptDlg()
 void SwRedlineAcceptDlg::Init(SwRedlineTable::size_type nStart)
 {
     std::optional<SwWait> oWait;
-    if (SwView *pView = GetActiveView())
+    SwView* pView = GetActiveView();
+    if (pView)
         oWait.emplace(*pView->GetDocShell(), false);
     weld::TreeView& rTreeView = m_pTable->GetWidget();
     m_aUsedSeqNo.clear();
@@ -274,6 +275,33 @@ void SwRedlineAcceptDlg::Init(SwRedlineTable::size_type 
nStart)
     // tdf#162018 keep the selected entry selected
     const SwRedlineData* pSelectedEntryRedlineData = 
lcl_get_selected_redlinedata(rTreeView);
 
+    // tdf#162337 tracked change selection when the Manage Changes dialog is 
initially opened
+    if (pView && m_bInitialSelect)
+    {
+        m_bInitialSelect = false;
+        SwWrtShell* pSh = pView->GetWrtShellPtr();
+        if (pSh)
+        {
+            const SwRangeRedline* pCurrRedline = pSh->GetCurrRedline();
+            if (pCurrRedline)
+            {
+                // Select current redline
+                SwRedlineTable::size_type nPos
+                    = pSh->FindRedlineOfData(pCurrRedline->GetRedlineData());
+                pSh->GotoRedline(nPos, true);
+                pSh->SetInSelect();
+            }
+            else
+            {
+                // Select the next redline if there is one
+                pSh->AssureStdMode();
+                pCurrRedline = pSh->SelNextRedline();
+            }
+            if (pCurrRedline)
+                pSelectedEntryRedlineData = &pCurrRedline->GetRedlineData();
+        }
+    }
+
     rTreeView.freeze();
     if (nStart)
         RemoveParents(nStart, m_RedlineParents.size() - 1);
@@ -885,21 +913,6 @@ void 
SwRedlineAcceptDlg::InsertParents(SwRedlineTable::size_type nStart, SwRedli
     weld::TreeView& rTreeView = m_pTable->GetWidget();
 
     SwRedlineDataParent* pRedlineParent;
-    const SwRangeRedline* pCurrRedline;
-    if (!nStart && !rTreeView.get_selected(nullptr))
-    {
-        pCurrRedline = pSh->GetCurrRedline();
-        if( !pCurrRedline )
-        {
-            pSh->SwCursorShell::Push();
-            pCurrRedline = pSh->SelNextRedline();
-            if( nullptr == pCurrRedline )
-                pCurrRedline = pSh->SelPrevRedline();
-            pSh->SwCursorShell::Pop(SwCursorShell::PopMode::DeleteCurrent);
-        }
-    }
-    else
-        pCurrRedline = nullptr;
 
     rTreeView.freeze();
     if (m_pTable->IsSorted())
@@ -1054,15 +1067,6 @@ void 
SwRedlineAcceptDlg::InsertParents(SwRedlineTable::size_type nStart, SwRedli
         rTreeView.set_text(*xParent, sDateEntry, 2);
         rTreeView.set_text(*xParent, sComment, 3);
 
-        if (pCurrRedline == &rRedln)
-        {
-            rTreeView.thaw();
-            rTreeView.set_cursor(*xParent);
-            rTreeView.select(*xParent);
-            rTreeView.scroll_to_row(*xParent);
-            rTreeView.freeze();
-        }
-
         pRedlineParent->xTLBParent = std::move(xParent);
 
         InsertChildren(pRedlineParent, rRedln, bHasRedlineAutoFormat);

Reply via email to