sw/source/uibase/inc/conttree.hxx | 2 ++ sw/source/uibase/utlui/content.cxx | 21 +++++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-)
New commits: commit a5ba8d94e6c36a7d79276416cc5acad9a1f6e54e Author: Jim Raykowski <rayk...@gmail.com> AuthorDate: Thu Oct 7 22:51:34 2021 -0800 Commit: Jim Raykowski <rayk...@gmail.com> CommitDate: Sat Oct 9 01:48:15 2021 +0200 tdf#142344 SwNavigator: Keep heading selected after navigating to headings in tables and sections Currently after navigating to a heading in a table or section from the Navigator the table or section is selected in the Navigator content tree. This patch makes the Navigator selection remain on the heading until the cursor is moved to another outline position which then makes the Navigator track tables and sections again. Change-Id: Idfcfd168fbbda541d07bbcadbaad62772ef156af Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123244 Tested-by: Jenkins Reviewed-by: Jim Raykowski <rayk...@gmail.com> diff --git a/sw/source/uibase/inc/conttree.hxx b/sw/source/uibase/inc/conttree.hxx index ce295c13a09a..d8afa2076252 100644 --- a/sw/source/uibase/inc/conttree.hxx +++ b/sw/source/uibase/inc/conttree.hxx @@ -115,6 +115,8 @@ class SwContentTree final : public SfxListener bool m_bTableTracking = true; bool m_bSectionTracking = true; + SwOutlineNodes::size_type m_nLastGotoContentWasOutlinePos = SwOutlineNodes::npos; + enum class State { ACTIVE, CONSTANT, HIDDEN } m_eState; bool m_bIsRoot :1; diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index ee9ab1114c9c..34588eee0dbe 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -3557,6 +3557,15 @@ void SwContentTree::UpdateTracking() return; } + bool bTrackTablesAndSections = true; + if (m_nLastGotoContentWasOutlinePos != SwOutlineNodes::npos) + { + if (m_pActiveShell->GetOutlinePos() == m_nLastGotoContentWasOutlinePos) + bTrackTablesAndSections = false; + else + m_nLastGotoContentWasOutlinePos = SwOutlineNodes::npos; + } + // footnotes and endnotes if (SwContentAtPos aContentAtPos(IsAttrAtPos::Ftn); m_pActiveShell->GetContentAtPos(m_pActiveShell->GetCursorDocPos(), aContentAtPos) && @@ -3684,7 +3693,7 @@ void SwContentTree::UpdateTracking() return; } // table - if (m_bTableTracking && m_pActiveShell->IsCursorInTable() && + if (bTrackTablesAndSections && m_bTableTracking && m_pActiveShell->IsCursorInTable() && !(m_bIsRoot && m_nRootType != ContentTypeId::TABLE)) { if(m_pActiveShell->GetTableFormat()) @@ -3704,8 +3713,8 @@ void SwContentTree::UpdateTracking() return; } // section - if (const SwSection* pSection = m_pActiveShell->GetCurrSection(); m_bSectionTracking && - pSection && !(m_bIsRoot && m_nRootType != ContentTypeId::REGION)) + if (const SwSection* pSection = m_pActiveShell->GetCurrSection(); bTrackTablesAndSections && + m_bSectionTracking && pSection && !(m_bIsRoot && m_nRootType != ContentTypeId::REGION)) { lcl_SelectByContentTypeAndName(this, *m_xTreeView, SwResId(STR_CONTENT_TYPE_REGION), pSection->GetSectionName()); @@ -4855,6 +4864,7 @@ static void lcl_AssureStdModeAtShell(SwWrtShell* pWrtShell) void SwContentTree::GotoContent(const SwContent* pCnt) { + m_nLastGotoContentWasOutlinePos = SwOutlineNodes::npos; lcl_AssureStdModeAtShell(m_pActiveShell); switch(pCnt->GetParent()->GetType()) { @@ -4866,7 +4876,10 @@ void SwContentTree::GotoContent(const SwContent* pCnt) break; case ContentTypeId::OUTLINE : { - m_pActiveShell->GotoOutline(static_cast<const SwOutlineContent*>(pCnt)->GetOutlinePos()); + const SwOutlineNodes::size_type nPos = + static_cast<const SwOutlineContent*>(pCnt)->GetOutlinePos(); + m_pActiveShell->GotoOutline(nPos); + m_nLastGotoContentWasOutlinePos = nPos; } break; case ContentTypeId::TABLE :