From 47654bc44e4aff1b251e17c07d42f8beb8ce09c8 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 19 May 2020 14:13:26 +0100 Subject: Related: tdf#133159 minimize jumping around if content doesn't change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit when navigator tree is updated Change-Id: Ie50ad0b4c24da15be575acb1172a28edb2fde05b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94502 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- sc/source/ui/inc/content.hxx | 2 +- sc/source/ui/navipi/content.cxx | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/sc/source/ui/inc/content.hxx b/sc/source/ui/inc/content.hxx index 6abf0fd11f19..7e02078129e7 100644 --- a/sc/source/ui/inc/content.hxx +++ b/sc/source/ui/inc/content.hxx @@ -165,7 +165,7 @@ public: const OUString& GetHiddenTitle() const { return aHiddenTitle; } /** Applies the navigator settings to the listbox. */ - void ApplyNavigatorSettings(); + void ApplyNavigatorSettings(bool bRestoreScrollPos = false, int nScrollPos = 0); /** Stores the current listbox state in the navigator settings. */ void StoreNavigatorSettings() const; }; diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx index edb574513b52..7feaee017a33 100644 --- a/sc/source/ui/navipi/content.cxx +++ b/sc/source/ui/navipi/content.cxx @@ -659,14 +659,22 @@ void ScContentTree::ObjectFresh(ScContentId nType, const weld::TreeIter* pEntry) { if (bHiddenDoc && !pHiddenDocument) return; // other document displayed + if (nType == ScContentId::GRAPHIC || nType == ScContentId::OLEOBJECT || nType == ScContentId::DRAWING) { + auto nOldChildren = m_aRootNodes[nType] ? m_xTreeView->iter_n_children(*m_aRootNodes[nType]) : 0; + auto nOldPos = m_xTreeView->vadjustment_get_value(); + freeze(); ClearType( nType ); GetDrawNames( nType/*, nId*/ ); thaw(); + + auto nNewChildren = m_aRootNodes[nType] ? m_xTreeView->iter_n_children(*m_aRootNodes[nType]) : 0; + bool bRestorePos = nOldChildren == nNewChildren; + if (!pEntry) - ApplyNavigatorSettings(); + ApplyNavigatorSettings(bRestorePos, nOldPos); if (pEntry) { weld::TreeIter* pParent = m_aRootNodes[nType].get(); @@ -1562,7 +1570,7 @@ void ScContentTree::SelectEntryByName(const ScContentId nRoot, const OUString& r } } -void ScContentTree::ApplyNavigatorSettings() +void ScContentTree::ApplyNavigatorSettings(bool bRestorePos, int nScrollPos) { const ScNavigatorSettings* pSettings = ScNavigatorDlg::GetNavigatorSettings(); if( pSettings ) @@ -1602,6 +1610,9 @@ void ScContentTree::ApplyNavigatorSettings() // select if( nRootSel == nEntry ) { + if (bRestorePos) + m_xTreeView->vadjustment_set_value(nScrollPos); + std::unique_ptr xEntry; if (bExp && (nChildSel != SC_CONTENT_NOCHILD)) { -- cgit v1.2.3