sw/source/uibase/utlui/content.cxx | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-)
New commits: commit a76f0371596f0037444c40fe3dcad5b4fef18c24 Author: Jim Raykowski <[email protected]> AuthorDate: Sat Nov 29 14:00:23 2025 -0900 Commit: Jim Raykowski <[email protected]> CommitDate: Mon Dec 8 02:10:47 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]> diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index aa43f6731959..bf22a16bb209 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -7240,8 +7240,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()) @@ -7249,9 +7249,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; } }
