sw/inc/bitmaps.hlst                |    1 
 sw/source/uibase/inc/conttree.hxx  |    2 
 sw/source/uibase/utlui/content.cxx |   81 ++++++++++++++++---------------------
 3 files changed, 39 insertions(+), 45 deletions(-)

New commits:
commit 1c638b7ac46d8077994c8483e6becc4a33efd12b
Author:     Jim Raykowski <rayk...@gmail.com>
AuthorDate: Sat Jan 14 22:45:18 2023 -0900
Commit:     Jim Raykowski <rayk...@gmail.com>
CommitDate: Fri Jan 20 01:10:19 2023 +0000

    tdf#149073 SwNavigator: provide an indication for linked images
    
    Sets an image for image content entries that are of linked type
    
    Function 'InsertContent' added to replace duplicated code that
    inserts content.
    
    Change-Id: I25dec3f5765fa3dffe505743cd9c5fe044349ab0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145530
    Tested-by: Jenkins
    Reviewed-by: Jim Raykowski <rayk...@gmail.com>

diff --git a/sw/inc/bitmaps.hlst b/sw/inc/bitmaps.hlst
index 647d2fb2f073..9606076d3032 100644
--- a/sw/inc/bitmaps.hlst
+++ b/sw/inc/bitmaps.hlst
@@ -81,6 +81,7 @@ inline constexpr OUStringLiteral RID_BMP_NAVI_OUTLINE = 
u"sw/res/nc20000.png";
 inline constexpr OUStringLiteral RID_BMP_NAVI_TABLE = u"sw/res/nc20001.png";
 inline constexpr OUStringLiteral RID_BMP_NAVI_FRAME = u"sw/res/nc20002.png";
 inline constexpr OUStringLiteral RID_BMP_NAVI_GRAPHIC = u"sw/res/nc20003.png";
+inline constexpr OUStringLiteral RID_BMP_NAVI_GRAPHIC_LINK = 
u"sw/res/nc20007.png";
 inline constexpr OUStringLiteral RID_BMP_NAVI_OLE = u"sw/res/nc20004.png";
 inline constexpr OUStringLiteral RID_BMP_NAVI_BOOKMARK = u"sw/res/nc20005.png";
 inline constexpr OUStringLiteral RID_BMP_NAVI_REGION = u"sw/res/nc20006.png";
diff --git a/sw/source/uibase/inc/conttree.hxx 
b/sw/source/uibase/inc/conttree.hxx
index b4f352bb6950..c924241d0153 100644
--- a/sw/source/uibase/inc/conttree.hxx
+++ b/sw/source/uibase/inc/conttree.hxx
@@ -155,6 +155,8 @@ class SwContentTree final : public SfxListener
      */
     void                FindActiveTypeAndRemoveUserData();
 
+    void InsertContent(const weld::TreeIter& rParent);
+
     void insert(const weld::TreeIter* pParent, const OUString& rStr, const 
OUString& rId,
                 bool bChildrenOnDemand, weld::TreeIter* pRet);
 
diff --git a/sw/source/uibase/utlui/content.cxx 
b/sw/source/uibase/utlui/content.cxx
index d76b1103991e..1148689ce9d9 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -2063,6 +2063,34 @@ IMPL_LINK(SwContentTree, CommandHdl, const 
CommandEvent&, rCEvt, bool)
     return true;
 }
 
+void SwContentTree::InsertContent(const weld::TreeIter& rParent)
+{
+    
assert(dynamic_cast<SwContentType*>(weld::fromId<SwTypeNumber*>(m_xTreeView->get_id(rParent))));
+    SwContentType* pCntType = 
weld::fromId<SwContentType*>(m_xTreeView->get_id(rParent));
+    bool bGraphic = pCntType->GetType() == ContentTypeId::GRAPHIC;
+    bool bRegion = pCntType->GetType() == ContentTypeId::REGION;
+    std::unique_ptr<weld::TreeIter> xChild = m_xTreeView->make_iterator();
+    const size_t nCount = pCntType->GetMemberCount();
+    for(size_t i = 0; i < nCount; ++i)
+    {
+        const SwContent* pCnt = pCntType->GetMember(i);
+        if (pCnt)
+        {
+            OUString sEntry = pCnt->GetName();
+            if (sEntry.isEmpty())
+                sEntry = m_sSpace;
+            OUString sId(weld::toId(pCnt));
+            insert(&rParent, sEntry, sId, false, xChild.get());
+            m_xTreeView->set_sensitive(*xChild, !pCnt->IsInvisible());
+            if (bGraphic && !static_cast<const 
SwGraphicContent*>(pCnt)->GetLink().isEmpty())
+                m_xTreeView->set_image(*xChild, RID_BMP_NAVI_GRAPHIC_LINK);
+            else if (bRegion)
+                m_xTreeView->set_extra_row_indent(*xChild,
+                                    static_cast<const 
SwRegionContent*>(pCnt)->GetRegionLevel());
+        }
+    }
+}
+
 void SwContentTree::insert(const weld::TreeIter* pParent, const OUString& 
rStr, const OUString& rId,
                            bool bChildrenOnDemand, weld::TreeIter* pRet)
 {
@@ -2085,9 +2113,9 @@ void SwContentTree::remove(const weld::TreeIter& rIter)
 // Content will be integrated into the Box only on demand.
 bool SwContentTree::RequestingChildren(const weld::TreeIter& rParent)
 {
-    bool bChild = m_xTreeView->iter_has_child(rParent);
-    if (bChild || !m_xTreeView->get_children_on_demand(rParent))
-        return bChild;
+    // Does the parent already have children or is it not a 'children on 
demand' node?
+    if (m_xTreeView->iter_has_child(rParent) || 
!m_xTreeView->get_children_on_demand(rParent))
+        return false;
 
     // Is this a content type?
     if (lcl_IsContentType(rParent, *m_xTreeView))
@@ -2134,34 +2162,16 @@ bool SwContentTree::RequestingChildren(const 
weld::TreeIter& rParent)
 
                     // add this node as a parent candidate for any following 
nodes at a higher outline level
                     
aParentCandidates.emplace_back(m_xTreeView->make_iterator(xChild.get()));
-
-                    bChild = true;
                 }
             }
         }
         else
-        {
-            bool bRegion = pCntType->GetType() == ContentTypeId::REGION;
-            for(size_t i = 0; i < nCount; ++i)
-            {
-                const SwContent* pCnt = pCntType->GetMember(i);
-                if (pCnt)
-                {
-                    OUString sEntry = pCnt->GetName();
-                    if (sEntry.isEmpty())
-                        sEntry = m_sSpace;
-                    OUString sId(weld::toId(pCnt));
-                    insert(&rParent, sEntry, sId, false, xChild.get());
-                    m_xTreeView->set_sensitive(*xChild, !pCnt->IsInvisible());
-                    if (bRegion)
-                        m_xTreeView->set_extra_row_indent(*xChild, 
static_cast<const SwRegionContent*>(pCnt)->GetRegionLevel());
-                    bChild = true;
-                }
-            }
-        }
+            InsertContent(rParent);
+
+        return nCount != 0;
     }
 
-    return bChild;
+    return false;
 }
 
 SdrObject* SwContentTree::GetDrawingObjectsByContent(const SwContent *pCnt)
@@ -2586,26 +2596,7 @@ void SwContentTree::Display( bool bActive )
             xCntTypeEntry = m_xTreeView->make_iterator(xEntry.get());
 
             if (!bChOnDemand)
-            {
-                bool bRegion = rpRootContentT->GetType() == 
ContentTypeId::REGION;
-
-                std::unique_ptr<weld::TreeIter> xChild = 
m_xTreeView->make_iterator();
-                for (size_t i = 0; i < rpRootContentT->GetMemberCount(); ++i)
-                {
-                    const SwContent* pCnt = rpRootContentT->GetMember(i);
-                    if (pCnt)
-                    {
-                        OUString sEntry = pCnt->GetName();
-                        if(sEntry.isEmpty())
-                            sEntry = m_sSpace;
-                        OUString sSubId(weld::toId(pCnt));
-                        insert(xEntry.get(), sEntry, sSubId, false, 
xChild.get());
-                        m_xTreeView->set_sensitive(*xChild, 
!pCnt->IsInvisible());
-                        if (bRegion)
-                            m_xTreeView->set_extra_row_indent(*xChild, 
static_cast<const SwRegionContent*>(pCnt)->GetRegionLevel());
-                    }
-                }
-            }
+                InsertContent(*xEntry);
             else
             {
                 // fill contents of to-be expanded entries while frozen

Reply via email to