summaryrefslogtreecommitdiff
path: root/sc/source/ui
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-05-19 14:13:26 +0100
committerCaolán McNamara <caolanm@redhat.com>2020-05-19 16:37:56 +0200
commit47654bc44e4aff1b251e17c07d42f8beb8ce09c8 (patch)
treeda925232133599ec66d3478f7dd80b106c7fa737 /sc/source/ui
parent1a10f17768860b3871038b610caf00c8c9d0e967 (diff)
Related: tdf#133159 minimize jumping around if content doesn't change
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 <caolanm@redhat.com>
Diffstat (limited to 'sc/source/ui')
-rw-r--r--sc/source/ui/inc/content.hxx2
-rw-r--r--sc/source/ui/navipi/content.cxx15
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<weld::TreeIter> xEntry;
if (bExp && (nChildSel != SC_CONTENT_NOCHILD))
{