sw/qa/uitest/writer_tests/trackedChanges.py | 10 +++++++ sw/qa/uitest/writer_tests7/tdf90401.py | 2 + sw/source/uibase/misc/redlndlg.cxx | 36 ++++++++++++++++++++-------- 3 files changed, 38 insertions(+), 10 deletions(-)
New commits: commit de9a7a593630d3319e0e311b641c7c52c96b9e4a Author: Jim Raykowski <rayk...@gmail.com> AuthorDate: Tue Jul 16 21:58:37 2024 -0800 Commit: Jim Raykowski <rayk...@gmail.com> CommitDate: Sat Jul 20 20:48:23 2024 +0200 Resolves tdf#162018 Unexpected loss in focus in the "Manage Changes" window when adding a change in the document (Track changes mode), round 2 Addresses two situations where the list still jumps to the top: Situation 1: When an entry is added to the end of the changes list. Situation 2: After editing a comment for a change list entry with the 'Comment' dialog. Change-Id: I4a75e6bcba13fb9cc735cf78756fe736b9d4665d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170598 Reviewed-by: Jim Raykowski <rayk...@gmail.com> Tested-by: Jenkins diff --git a/sw/qa/uitest/writer_tests/trackedChanges.py b/sw/qa/uitest/writer_tests/trackedChanges.py index 8681140bb695..93b2374ed820 100644 --- a/sw/qa/uitest/writer_tests/trackedChanges.py +++ b/sw/qa/uitest/writer_tests/trackedChanges.py @@ -78,6 +78,8 @@ class trackedchanges(UITestCase): self.xUITest.executeCommand(".uno:ShowTrackedChanges") with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges", close_button="close") as xTrackDlg: + changesList = xTrackDlg.getChild("writerchanges") + changesList.getChild(0).executeAction("SELECT", tuple()) xRejBtn = xTrackDlg.getChild("reject") xRejBtn.executeAction("CLICK", tuple()) @@ -152,6 +154,8 @@ class trackedchanges(UITestCase): "The tennis ball is a small ball. The basketball is much bigger.", "The tennis ball is a small ball. The basketball is much bigger."] + changesList.getChild(0).executeAction("SELECT", tuple()) + for i in range(len(listText)): self.assertEqual(document.Text.String.strip(), resultsAccept[i]) self.assertEqual(get_state_as_dict(changesList.getChild('0'))["Text"], listText[i] ) @@ -176,6 +180,8 @@ class trackedchanges(UITestCase): "The tenis ball is a small bal. The baskedball is much bigger.", "The tenis ball is a small bal. The baskedball is much biger."] + changesList.getChild(0).executeAction("SELECT", tuple()) + for i in range(len(listText)): self.assertEqual(document.Text.String.strip(), resultsReject[i]) self.assertEqual(get_state_as_dict(changesList.getChild('0'))["Text"], listText[i] ) @@ -231,6 +237,8 @@ class trackedchanges(UITestCase): # Now: 4 changes (2 deleted/inserted rows and 2 deleted/inserted tables) self.assertEqual(4, len(changesList.getChildren())) + changesList.getChild(0).executeAction("SELECT", tuple()) + # Without the fix in place, it would have crashed here for i in (3, 2, 1, 0): xAccBtn = xTrackDlg.getChild("accept") @@ -521,6 +529,7 @@ class trackedchanges(UITestCase): # check and reject changes with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges", close_button="close") as xTrackDlg: changesList = xTrackDlg.getChild("writerchanges") + changesList.getChild(0).executeAction("SELECT", tuple()) # six changes, but only one visible in the Manage Changes dialog window state = get_state_as_dict(changesList) @@ -562,6 +571,7 @@ class trackedchanges(UITestCase): # check and reject changes with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges", close_button="close") as xTrackDlg: changesList = xTrackDlg.getChild("writerchanges") + changesList.getChild(0).executeAction("SELECT", tuple()) # six changes, but only one visible in the Manage Changes dialog window state = get_state_as_dict(changesList) diff --git a/sw/qa/uitest/writer_tests7/tdf90401.py b/sw/qa/uitest/writer_tests7/tdf90401.py index 95cc966e1dc7..6c29269a5880 100644 --- a/sw/qa/uitest/writer_tests7/tdf90401.py +++ b/sw/qa/uitest/writer_tests7/tdf90401.py @@ -79,6 +79,7 @@ class tdf90401(UITestCase): # check removed personal info on tracked changes with self.ui_test.execute_modeless_dialog_through_command('.uno:AcceptTrackedChanges', close_button="close") as xTrackDlg: xTreeList = xTrackDlg.getChild('writerchanges') + xTreeList.getChild('0').executeAction("SELECT", tuple()) state = get_state_as_dict(xTreeList) # This was 'NL 11/03/2020 19:19:05 ', containing personal info self.assertEqual(state['SelectEntryText'], 'Author1 01/01/1970 00:00:00 ') @@ -130,6 +131,7 @@ class tdf90401(UITestCase): with self.ui_test.execute_modeless_dialog_through_command('.uno:AcceptTrackedChanges', close_button="close") as xTrackDlg: xTreeList = xTrackDlg.getChild('writerchanges') + xTreeList.getChild('0').executeAction("SELECT", tuple()) state = get_state_as_dict(xTreeList) # This was 'NL 11/03/2020 19:19:05 ', containing personal info self.assertEqual(state['SelectEntryText'], 'Author1 01/01/1970 00:00:00 ') diff --git a/sw/source/uibase/misc/redlndlg.cxx b/sw/source/uibase/misc/redlndlg.cxx index 178c2bc0f2e5..5bbac52db74d 100644 --- a/sw/source/uibase/misc/redlndlg.cxx +++ b/sw/source/uibase/misc/redlndlg.cxx @@ -229,6 +229,15 @@ void SwRedlineAcceptDlg::Init(SwRedlineTable::size_type nStart) weld::TreeView& rTreeView = m_pTable->GetWidget(); m_aUsedSeqNo.clear(); + // tdf#162018 keep the selected entry selected + const OUString& rId = rTreeView.get_selected_id(); + auto reselect = [&rTreeView, &rId]() { + rTreeView.select_id(rId); + std::unique_ptr<weld::TreeIter> xEntry(rTreeView.make_iterator()); + if (rTreeView.get_selected(xEntry.get())) + rTreeView.set_cursor(*xEntry); + }; + rTreeView.freeze(); if (nStart) RemoveParents(nStart, m_RedlineParents.size() - 1); @@ -245,10 +254,7 @@ void SwRedlineAcceptDlg::Init(SwRedlineTable::size_type nStart) InsertParents(nStart); InitAuthors(); - // #i69618# this moves the list box to the right position, visually - std::unique_ptr<weld::TreeIter> xSelEntry(rTreeView.make_iterator()); - if (rTreeView.get_selected(xSelEntry.get())) - rTreeView.scroll_to_row(*xSelEntry); //#i70937#, force the scroll + reselect(); } void SwRedlineAcceptDlg::InitAuthors() @@ -416,6 +422,12 @@ void SwRedlineAcceptDlg::Activate() // tdf#162018 keep the selected entry selected weld::TreeView& rTreeView = m_pTable->GetWidget(); const OUString& rId = rTreeView.get_selected_id(); + auto reselect = [&rTreeView, &rId]() { + rTreeView.select_id(rId); + std::unique_ptr<weld::TreeIter> xEntry(rTreeView.make_iterator()); + if (rTreeView.get_selected(xEntry.get())) + rTreeView.set_cursor(*xEntry); + }; SwRedlineTable::size_type nCount = pSh->GetRedlineCount(); @@ -437,7 +449,10 @@ void SwRedlineAcceptDlg::Activate() // Redline-Parents were inserted, changed or deleted i = CalcDiff(i, false); if (i == SwRedlineTable::npos) + { + reselect(); return; + } continue; } @@ -449,7 +464,10 @@ void SwRedlineAcceptDlg::Activate() // Redline-Children were deleted i = CalcDiff(i, true); if (i == SwRedlineTable::npos) + { + reselect(); return; + } continue; } else @@ -461,7 +479,10 @@ void SwRedlineAcceptDlg::Activate() // Redline-Children were inserted, changed or deleted i = CalcDiff(i, true); if (i == SwRedlineTable::npos) + { + reselect(); return; + } // here was a continue; targetted to the outer loop // now a break will do, as there is nothing after it in the outer loop @@ -505,11 +526,7 @@ void SwRedlineAcceptDlg::Activate() InitAuthors(); - // tdf#162018 keep the selected entry selected - rTreeView.select_id(rId); - std::unique_ptr<weld::TreeIter> xEntry(rTreeView.make_iterator()); - if (rTreeView.get_selected(xEntry.get())) - rTreeView.set_cursor(*xEntry); + reselect(); } void SwRedlineAcceptDlg::Notify(SfxBroadcaster& /*rBC*/, const SfxHint& rHint) @@ -1470,7 +1487,6 @@ IMPL_LINK(SwRedlineAcceptDlg, CommandHdl, const CommandEvent&, rCEvt, bool) // insert / change comment pSh->SetRedlineComment(sMsg); rTreeView.set_text(*xEntry, sMsg.replace(' ', ' '), 3); - Init(); } SwViewShell::SetCareDialog(nullptr);