[Libreoffice-commits] core.git: sc/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue May 19 14:38:43 UTC 2020


 sc/source/ui/inc/content.hxx    |    2 +-
 sc/source/ui/navipi/content.cxx |   15 +++++++++++++--
 2 files changed, 14 insertions(+), 3 deletions(-)

New commits:
commit 47654bc44e4aff1b251e17c07d42f8beb8ce09c8
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue May 19 14:13:26 2020 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue May 19 16:37:56 2020 +0200

    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 at redhat.com>

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))
                     {


More information about the Libreoffice-commits mailing list