sw/source/uibase/inc/conttree.hxx  |    1 +
 sw/source/uibase/utlui/content.cxx |    8 ++++++++
 sw/source/uibase/utlui/navipi.cxx  |   11 +++++++----
 3 files changed, 16 insertions(+), 4 deletions(-)

New commits:
commit 61e2022110d3088bc1653713dc270beaacae4c74
Author:     Attila Szűcs <attila.sz...@collabora.com>
AuthorDate: Fri Jun 9 05:56:31 2023 +0200
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Fri Jun 9 07:29:30 2023 +0200

    LOK: fix for navigator: hide empty contentTypes
    
    fixed that opening heading by default, first check if headings
    are not hidden, because it blindly opened the 1. type, but
    from now, that can be an other type, or nothing
    
    Change-Id: I86cac472d8cba9a46befc5a84ef073c01fa7243d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152779
    Tested-by: Andras Timar <andras.ti...@collabora.com>
    Reviewed-by: Andras Timar <andras.ti...@collabora.com>

diff --git a/sw/source/uibase/inc/conttree.hxx 
b/sw/source/uibase/inc/conttree.hxx
index ec0dbc7c84e8..e2cf31028171 100644
--- a/sw/source/uibase/inc/conttree.hxx
+++ b/sw/source/uibase/inc/conttree.hxx
@@ -236,6 +236,7 @@ public:
         { return State::HIDDEN == m_eState ? m_pHiddenShell : m_pActiveShell; }
 
     bool            IsInDrag() const;
+    bool            HasHeadings() const;
 
     sal_uInt8       GetOutlineLevel()const {return m_nOutlineLevel;}
     void            SetOutlineLevel(sal_uInt8 nSet);
diff --git a/sw/source/uibase/utlui/content.cxx 
b/sw/source/uibase/utlui/content.cxx
index 6325347a930e..5367627cad03 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -1256,6 +1256,14 @@ bool SwContentTree::IsInDrag() const
     return m_xTreeView->get_drag_source() == m_xTreeView.get();
 }
 
+bool SwContentTree::HasHeadings() const
+{
+    const std::unique_ptr<SwContentType>& rpContentT = 
m_aActiveContentArr[ContentTypeId::OUTLINE];
+    if (rpContentT && rpContentT->GetMemberCount() > 0)
+        return true;
+    return false;
+}
+
 // QueryDrop will be executed in the navigator
 sal_Int8 SwContentTree::AcceptDrop(const AcceptDropEvent& rEvt)
 {
diff --git a/sw/source/uibase/utlui/navipi.cxx 
b/sw/source/uibase/utlui/navipi.cxx
index 61ada3408bbc..fb3f461f8f64 100644
--- a/sw/source/uibase/utlui/navipi.cxx
+++ b/sw/source/uibase/utlui/navipi.cxx
@@ -694,10 +694,13 @@ SwNavigationPI::SwNavigationPI(weld::Widget* pParent,
         m_xGlobalTree->HideTree();
 
         //Open Headings by default
-        auto& pTreeView = m_xContentTree->get_widget();
-        std::unique_ptr<weld::TreeIter> itEntry(pTreeView.make_iterator());
-        pTreeView.get_iter_first(*itEntry);
-        pTreeView.expand_row(*itEntry);
+        if (m_xContentTree->HasHeadings())
+        {
+            auto& pTreeView = m_xContentTree->get_widget();
+            std::unique_ptr<weld::TreeIter> itEntry(pTreeView.make_iterator());
+            pTreeView.get_iter_first(*itEntry);
+            pTreeView.expand_row(*itEntry);
+        }
     }
 }
 

Reply via email to