tdf#143547 SwNavigator: restore content tree scroll position
after promote, demote, and move chapter
Change-Id: Ie165fadf6154a019ad79a0fed489f63aa768c8f9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139823
Tested-by: Jenkins
Reviewed-by: Jim Raykowski <raykowj@gmail.com>
(cherry picked from commit a33b8ec923b4e86a2ca2075f9541e79a729b2ed7)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140875
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx
index 1461cd8..cf2c9eb 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -3356,9 +3356,16 @@ void SwContentTree::ExecCommand(std::string_view rCmd, bool bOutlineWithChildren
if (m_aActiveContentArr[ContentTypeId::OUTLINE])
m_aActiveContentArr[ContentTypeId::OUTLINE]->Invalidate();
// tdf#143547 LO Writer: navigator should stand still on promoting and demoting
// In addition to m_bIgnoreDocChange being true, selections are cleared before the Display
// call. Either of these conditions disable restore of scroll position happening in the
// Display function so it needs to be done here.
auto nOldScrollPos = m_xTreeView->vadjustment_get_value();
// clear all selections to prevent the Display function from trying to reselect selected entries
m_xTreeView->unselect_all();
Display(true);
m_xTreeView->vadjustment_set_value(nOldScrollPos);
// reselect entries
const SwOutlineNodes::size_type nCurrPos = pShell->GetOutlinePos(MAXLEVEL);