sd/source/ui/dlg/navigatr.cxx |    3 +--
 sd/source/ui/dlg/sdtreelb.cxx |   23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+), 2 deletions(-)

New commits:
commit afdeaa332557e3387abbb2db62d515ec25576222
Author:     Jim Raykowski <[email protected]>
AuthorDate: Mon Oct 6 23:46:31 2025 -0800
Commit:     Jim Raykowski <[email protected]>
CommitDate: Wed Oct 15 02:08:45 2025 +0200

    Resolves tdf#157118 Constant expansion of Navigator objects when single
    
    object is deleted in Draw
    
    Change-Id: I221e543d9272362ea2814879eb3db6c68268be76
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192005
    Tested-by: Jenkins
    Reviewed-by: Jim Raykowski <[email protected]>

diff --git a/sd/source/ui/dlg/navigatr.cxx b/sd/source/ui/dlg/navigatr.cxx
index 991228e39de2..dd736988bf56 100644
--- a/sd/source/ui/dlg/navigatr.cxx
+++ b/sd/source/ui/dlg/navigatr.cxx
@@ -208,7 +208,6 @@ void SdNavigatorWin::InitTreeLB( const SdDrawDocument* pDoc 
)
     if( !mxTlbObjects->IsEqualToDoc( pDoc ) )
     {
         OUString aDocName = pDocShell->GetMedium()->GetName();
-        mxTlbObjects->clear();
         mxTlbObjects->Fill( pDoc, false, aDocName ); // only normal pages
 
         RefreshDocumentLB();
@@ -843,7 +842,7 @@ void 
SdNavigatorControllerItem::StateChangedAtToolBoxControl( sal_uInt16 nSId,
     if (nState & NavState::TableUpdate)
     {
         // InitTlb; is initiated by Slot
-        if (maUpdateRequest && 
!pNavigatorWin->GetObjects().get_treeview().has_focus())
+        if (maUpdateRequest)
             maUpdateRequest();
     }
 }
diff --git a/sd/source/ui/dlg/sdtreelb.cxx b/sd/source/ui/dlg/sdtreelb.cxx
index b753458d30d7..6c5a1dc3ea33 100644
--- a/sd/source/ui/dlg/sdtreelb.cxx
+++ b/sd/source/ui/dlg/sdtreelb.cxx
@@ -63,6 +63,8 @@
 #include <svl/poolitem.hxx>
 #include <svl/stritem.hxx>
 
+#include <unordered_set>
+
 using namespace com::sun::star;
 
 namespace {
@@ -1255,6 +1257,18 @@ void SdPageObjsTLV::AddShapeList (
  */
 void SdPageObjsTLV::Fill(const SdDrawDocument* pInDoc, bool bAllPages, const 
OUString& rDocName)
 {
+    // record collapsed page/slide name entries to reset after the tree is 
refilled
+    std::unordered_set<OUString> aCollapsedEntriesSet;
+    std::unique_ptr<weld::TreeIter> xEntry(m_xTreeView->make_iterator());
+    if (m_xTreeView->get_iter_first(*xEntry))
+    {
+        do
+        {
+            if (!m_xTreeView->get_row_expanded(*xEntry))
+                aCollapsedEntriesSet.insert(m_xTreeView->get_text(*xEntry));
+        } while (m_xTreeView->iter_next_sibling(*xEntry));
+    }
+
     OUString aSelection = m_xTreeView->get_selected_text();
     clear();
 
@@ -1316,6 +1330,15 @@ void SdPageObjsTLV::Fill(const SdDrawDocument* pInDoc, 
bool bAllPages, const OUS
             return false;
         });
     }
+    // collapse page/slide entries
+    if (m_xTreeView->get_iter_first(*xEntry))
+    {
+        do
+        {
+            if (aCollapsedEntriesSet.contains(m_xTreeView->get_text(*xEntry)))
+                m_xTreeView->collapse_row(*xEntry);
+        } while (m_xTreeView->iter_next_sibling(*xEntry));
+    }
 }
 
 /**

Reply via email to