From d616b6a92665855d2ba0ebc2a3064505a4947e06 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 5 Mar 2020 16:11:12 +0000 Subject: restore calc navigator custom tooltip MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ic378364e0d6c5eb704872ec9a3c73f63c222855a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90049 Tested-by: Caolán McNamara Reviewed-by: Caolán McNamara --- sc/source/ui/navipi/content.cxx | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) (limited to 'sc/source/ui/navipi') diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx index 9f7bb3ef2696..d1b66b8f6f34 100644 --- a/sc/source/ui/navipi/content.cxx +++ b/sc/source/ui/navipi/content.cxx @@ -139,6 +139,7 @@ ScContentTree::ScContentTree(std::unique_ptr xTreeView, ScNaviga m_xTreeView->connect_mouse_release(LINK(this, ScContentTree, MouseReleaseHdl)); m_xTreeView->connect_key_press(LINK(this, ScContentTree, KeyInputHdl)); m_xTreeView->connect_popup_menu(LINK(this, ScContentTree, CommandHdl)); + m_xTreeView->connect_query_tooltip(LINK(this, ScContentTree, QueryTooltipHdl)); rtl::Reference xHelper(m_xTransferObj.get()); m_xTreeView->enable_drag_source(xHelper, DND_ACTION_COPYMOVE | DND_ACTION_LINK); @@ -235,7 +236,7 @@ void ScContentTree::InsertContent( ScContentId nType, const OUString& rValue ) } } -void ScContentTree::GetEntryIndexes(ScContentId& rnRootIndex, sal_uLong& rnChildIndex, weld::TreeIter* pEntry) const +void ScContentTree::GetEntryIndexes(ScContentId& rnRootIndex, sal_uLong& rnChildIndex, const weld::TreeIter* pEntry) const { rnRootIndex = ScContentId::ROOT; rnChildIndex = SC_CONTENT_NOCHILD; @@ -282,11 +283,11 @@ void ScContentTree::GetEntryIndexes(ScContentId& rnRootIndex, sal_uLong& rnChild } } -sal_uLong ScContentTree::GetChildIndex(weld::TreeIter* pEntry) const +sal_uLong ScContentTree::GetChildIndex(const weld::TreeIter* pEntry) const { ScContentId nRoot; sal_uLong nChild; - GetEntryIndexes( nRoot, nChild, pEntry ); + GetEntryIndexes(nRoot, nChild, pEntry); return nChild; } @@ -606,6 +607,39 @@ IMPL_LINK(ScContentTree, CommandHdl, const CommandEvent&, rCEvt, bool) return bDone; } +IMPL_LINK(ScContentTree, QueryTooltipHdl, const weld::TreeIter&, rEntry, OUString) +{ + OUString aHelpText; + + std::unique_ptr xParent(m_xTreeView->make_iterator(&rEntry)); + if (!m_xTreeView->iter_parent(*xParent)) + xParent.reset(); + + if (!xParent) // Top-Level ? + { + aHelpText = OUString::number(m_xTreeView->iter_n_children(rEntry)) + + " " + m_xTreeView->get_text(rEntry); + } + else if (m_xTreeView->iter_compare(*xParent, *m_aRootNodes[ScContentId::NOTE]) == 0) + { + aHelpText = m_xTreeView->get_text(rEntry); // notes as help text + } + else if (m_xTreeView->iter_compare(*xParent, *m_aRootNodes[ScContentId::AREALINK]) == 0) + { + auto nIndex = GetChildIndex(&rEntry); + if (nIndex != SC_CONTENT_NOCHILD) + { + const ScAreaLink* pLink = GetLink(nIndex); + if (pLink) + { + aHelpText = pLink->GetFile(); // source file as help text + } + } + } + + return aHelpText; +} + ScDocument* ScContentTree::GetSourceDocument() { if (bHiddenDoc) -- cgit