From 79df80b642179fdd621538e8a7894a2f055ba16a Mon Sep 17 00:00:00 2001 From: Jim Raykowski Date: Sun, 8 Oct 2023 23:13:51 -0800 Subject: [PATCH] SwNavigator: Fix Indexes tracking Restores Indexes tracking when the document cursor is in TOX content which was lost in commit ca34204a39716ec9aa621e60ea50fb3c058c55f6. Change-Id: Ib0fed4b7a20b5d08b5c52eef28d13cf0044d87d4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157693 Tested-by: Jenkins Reviewed-by: Jim Raykowski --- sw/source/uibase/utlui/content.cxx | 41 ++++++++++-------------------- 1 file changed, 14 insertions(+), 27 deletions(-) diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index 7456d2a28e12..9d96415c5c35 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -3981,36 +3981,23 @@ void SwContentTree::UpdateTracking() return; } // hyperlinks - if (SwContentAtPos aContentAtPos(IsAttrAtPos::InetAttr); - m_pActiveShell->GetContentAtPos(m_pActiveShell->GetCursorDocPos(), aContentAtPos) && - !(m_bIsRoot && m_nRootType != ContentTypeId::URLFIELD)) + // not in ToxContent tdf#148312 + if (const SwSection* pSection = m_pActiveShell->GetCurrSection(); !pSection + || (pSection && pSection->GetType() != SectionType::ToxContent)) { - // There is no need to search for hyperlinks in ToxContent tdf#148312 - if (const SwTextINetFormat* pTextINetFormat = - static_txtattr_cast(aContentAtPos.pFndTextAttr)) + if (SwContentAtPos aContentAtPos(IsAttrAtPos::InetAttr); + m_pActiveShell->GetContentAtPos(m_pActiveShell->GetCursorDocPos(), aContentAtPos) + && (!m_bIsRoot || m_nRootType == ContentTypeId::URLFIELD)) { - if (const SwTextNode* pTextNode = pTextINetFormat->GetpTextNode()) - { - if (const SwSectionNode* pSectNd = pTextNode->FindSectionNode()) - { - SectionType eType = pSectNd->GetSection().GetType(); - if (SectionType::ToxContent == eType) - { - m_xTreeView->set_cursor(-1); - Select(); - return; - } - } - } + // Because hyperlink item names do not need to be unique, finding the corresponding + // item in the tree by name may result in incorrect selection. Find the item in the + // tree by comparing the SwTextINetFormat pointer at the document cursor position to + // that stored in the item SwURLFieldContent. + if (mTrackContentType[ContentTypeId::URLFIELD]) + lcl_SelectByContentTypeAndAddress(this, *m_xTreeView, ContentTypeId::URLFIELD, + aContentAtPos.pFndTextAttr); + return; } - // Because hyperlink item names do not need to be unique, finding the corresponding item - // in the tree by name may result in incorrect selection. Find the item in the tree by - // comparing the SwTextINetFormat pointer at the document cursor position to that stored - // in the item SwURLFieldContent. - if (mTrackContentType[ContentTypeId::URLFIELD]) - lcl_SelectByContentTypeAndAddress(this, *m_xTreeView, ContentTypeId::URLFIELD, - aContentAtPos.pFndTextAttr); - return; } // fields, comments if (SwField* pField = m_pActiveShell->GetCurField(); pField &&