summaryrefslogtreecommitdiff
path: root/sw/source/uibase/utlui
diff options
context:
space:
mode:
authorJim Raykowski <raykowj@gmail.com>2021-09-14 16:07:53 -0800
committerJim Raykowski <raykowj@gmail.com>2021-09-18 07:20:36 +0200
commit1f9a792a391f0811bbb5f570ad5c84d13312c539 (patch)
tree5425a43e0587e9ee8157925824064d3520c1a4d8 /sw/source/uibase/utlui
parent363d0e7e2875d0f99cf0442353202c96c097f5e2 (diff)
tdf#144349 Make Navigator global tree track sub-document sections
Master document relies on the Navigator listing all the sub-documents. However there is no connection between the currently selected section (containing the sub-document) and the entry in the Navigator making it very hard to see what file needs to be edited. This patch highlights the corresponding item in the Navigator at the current cursor position in the document. Change-Id: Iee32d1db0e40e302bfff7a879d47a5632ce4ed43 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122103 Tested-by: Jenkins Reviewed-by: Jim Raykowski <raykowj@gmail.com>
Diffstat (limited to 'sw/source/uibase/utlui')
-rw-r--r--sw/source/uibase/utlui/glbltree.cxx42
1 files changed, 39 insertions, 3 deletions
diff --git a/sw/source/uibase/utlui/glbltree.cxx b/sw/source/uibase/utlui/glbltree.cxx
index 8ea94f9680f8..81c351f7249a 100644
--- a/sw/source/uibase/utlui/glbltree.cxx
+++ b/sw/source/uibase/utlui/glbltree.cxx
@@ -773,8 +773,33 @@ void SwGlobalTree::ExecuteContextMenuAction(std::string_view rSelectedPopupEntry
IMPL_LINK_NOARG(SwGlobalTree, Timeout, Timer *, void)
{
- if (!m_xTreeView->has_focus() && Update(false))
- Display();
+ if (m_pActiveShell && m_pActiveShell->GetView().GetEditWin().HasFocus())
+ {
+ if (Update(false))
+ Display();
+ UpdateTracking();
+ }
+}
+
+void SwGlobalTree::UpdateTracking()
+{
+ if (!m_pActiveShell)
+ return;
+
+ // track section at cursor position in document
+ m_xTreeView->unselect_all();
+
+ const SwSection* pActiveShellCurrSection = m_pActiveShell->GetCurrSection();
+ if (pActiveShellCurrSection)
+ {
+ const SwSection* pSection = pActiveShellCurrSection;
+ SwSection* pParent;
+ while ((pParent = pSection->GetParent()) != nullptr)
+ pSection = pParent;
+
+ if (pSection)
+ m_xTreeView->select_text(pSection->GetSectionName());
+ }
}
void SwGlobalTree::GotoContent(const SwGlblDocContent* pCont)
@@ -803,6 +828,7 @@ void SwGlobalTree::ShowTree()
{
m_aUpdateTimer.Start();
m_xTreeView->show();
+ UpdateTracking();
}
void SwGlobalTree::HideTree()
@@ -854,10 +880,13 @@ bool SwGlobalTree::Update(bool bHard)
bool bRet = false;
if (pActView && pActView->GetWrtShellPtr())
{
- const SwWrtShell* pOldShell = m_pActiveShell;
+ SwWrtShell* pOldShell = m_pActiveShell;
m_pActiveShell = pActView->GetWrtShellPtr();
if(m_pActiveShell != pOldShell)
{
+ if (pOldShell)
+ EndListening(*pOldShell->GetView().GetDocShell());
+ StartListening(*m_pActiveShell->GetView().GetDocShell());
m_pSwGlblDocContents.reset();
}
if(!m_pSwGlblDocContents)
@@ -1090,4 +1119,11 @@ IMPL_LINK( SwGlobalTree, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg, vo
m_pDocContent.reset();
}
+void SwGlobalTree::Notify(SfxBroadcaster& rBC, SfxHint const& rHint)
+{
+ SfxListener::Notify(rBC, rHint);
+ if (rHint.GetId() == SfxHintId::SwNavigatorUpdateTracking)
+ UpdateTracking();
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */