sw/source/uibase/utlui/content.cxx |   24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

New commits:
commit 15f4b33aa9d4338009a19832188e3a086ac8b252
Author:     Jim Raykowski <[email protected]>
AuthorDate: Sat Nov 29 14:00:23 2025 -0900
Commit:     Adolfo Jayme Barrientos <[email protected]>
CommitDate: Sat Dec 13 07:11:37 2025 +0100

    SwNavigator: Improve Index bring-to-attention
    
    Currently a name comparison approach is used to bring index content
    to attention in the document when the mouse pointer is over an Indexes
    entry in the Navigator content tree. This doesn't work very well for
    user defined indexes which initially get "_Head" appended to the
    section name, e.g. "my user defined index1" is shown in the Navigator
    content tree for the index but "my user defined index1_Head" is the
    initial name of the section. This changes to "my user defined index1" if
    the index is deleted and then the delete is undone. Bring-to-attention
    then works as expected for the index. I haven't yet investigated why
    this happens. A seemingly better approach is to compare SwTOXBase
    pointers, which is the change made by this patch.
    
    Change-Id: I9ae7fc0c72d70f7f5b3445d02b562f2d344ce34f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194826
    Tested-by: Jenkins
    Reviewed-by: Jim Raykowski <[email protected]>
    (cherry picked from commit a76f0371596f0037444c40fe3dcad5b4fef18c24)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195547
    Reviewed-by: Adolfo Jayme Barrientos <[email protected]>

diff --git a/sw/source/uibase/utlui/content.cxx 
b/sw/source/uibase/utlui/content.cxx
index 7b877464fb63..36d6a3711595 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -7232,8 +7232,8 @@ void SwContentTree::BringEntryToAttention(const 
weld::TreeIter& rEntry)
             }
             else if (nType == ContentTypeId::REGION || nType == 
ContentTypeId::INDEX)
             {
-                size_t nSectionFormatCount = 
m_pActiveShell->GetSectionFormatCount();
-                for (size_t i = 0; i < nSectionFormatCount; ++i)
+                for (size_t i = 0, nSectionFormatCount = 
m_pActiveShell->GetSectionFormatCount();
+                     i < nSectionFormatCount; ++i)
                 {
                     const SwSectionFormat& rSectionFormat = 
m_pActiveShell->GetSectionFormat(i);
                     if (!rSectionFormat.IsInNodesArr())
@@ -7241,9 +7241,25 @@ void SwContentTree::BringEntryToAttention(const 
weld::TreeIter& rEntry)
                     const SwSection* pSection = rSectionFormat.GetSection();
                     if (!pSection)
                         continue;
-                    if (pCnt->GetName() == pSection->GetSectionName())
+                    if (nType == ContentTypeId::INDEX)
                     {
-                        
BringTypesWithFlowFramesToAttention({rSectionFormat.GetSectionNode()});
+                        if (const SwTOXBase* pTOXBase = pSection->GetTOXBase())
+                        {
+                            assert(dynamic_cast<SwTOXBaseContent*>(pCnt));
+                            const SwTOXBaseContent* pTOXBaseCnt
+                                = static_cast<const SwTOXBaseContent*>(pCnt);
+                            if (pTOXBaseCnt->GetTOXBase() == pTOXBase)
+                            {
+                                BringTypesWithFlowFramesToAttention(
+                                    { rSectionFormat.GetSectionNode() });
+                                break;
+                            }
+                        }
+                    }
+                    // nType == ContentTypeId::REGION
+                    else if (pSection->GetSectionName() == pCnt->GetName())
+                    {
+                        BringTypesWithFlowFramesToAttention({ 
rSectionFormat.GetSectionNode() });
                         break;
                     }
                 }

Reply via email to