summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/source/uibase/inc/conttree.hxx5
-rw-r--r--sw/source/uibase/uiview/viewsrch.cxx2
-rw-r--r--sw/source/uibase/utlui/glbltree.cxx42
3 files changed, 45 insertions, 4 deletions
diff --git a/sw/source/uibase/inc/conttree.hxx b/sw/source/uibase/inc/conttree.hxx
index 4ac942e9ecd7..78e078cc78f3 100644
--- a/sw/source/uibase/inc/conttree.hxx
+++ b/sw/source/uibase/inc/conttree.hxx
@@ -282,7 +282,7 @@ public:
SwGlobalTreeDropTarget(SwGlobalTree& rTreeView);
};
-class SwGlobalTree final
+class SwGlobalTree final : public SfxListener
{
private:
std::unique_ptr<weld::TreeView> m_xTreeView;
@@ -368,6 +368,9 @@ public:
void ExecuteContextMenuAction(std::string_view rSelectedPopupEntry);
const SwWrtShell* GetActiveWrtShell() const {return m_pActiveShell;}
+
+ virtual void Notify(SfxBroadcaster& rBC, SfxHint const& rHint) override;
+ void UpdateTracking();
};
#endif
diff --git a/sw/source/uibase/uiview/viewsrch.cxx b/sw/source/uibase/uiview/viewsrch.cxx
index 66fb79ac3809..ba86732a82a3 100644
--- a/sw/source/uibase/uiview/viewsrch.cxx
+++ b/sw/source/uibase/uiview/viewsrch.cxx
@@ -257,6 +257,8 @@ void SwView::ExecSearch(SfxRequest& rReq)
m_pWrtShell->GetSfxViewShell()->setTiledSearching(false);
GetDocShell()->Broadcast(
+ SfxHint(SfxHintId::SwNavigatorUpdateTracking));
+ GetDocShell()->Broadcast(
SfxHint(SfxHintId::SwNavigatorSelectOutlinesWithSelections));
if( !bRet )
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: */