sw/inc/strings.hrc | 2 + sw/source/uibase/utlui/content.cxx | 45 ++++++++++++++++++++++++++++++++----- 2 files changed, 41 insertions(+), 6 deletions(-)
New commits: commit d8b0567bb6d86ccba5387e2c6132d915e7c431d0 Author: Jim Raykowski <[email protected]> AuthorDate: Sun Sep 21 02:05:27 2025 -0800 Commit: Jim Raykowski <[email protected]> CommitDate: Tue Sep 23 17:46:37 2025 +0200 tdf#166048 Show pages from/to in the Navigator's heading tooltip Change-Id: If6501e55ee2fd35b4d379c13d789dea0c1d73747 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191306 Tested-by: Jenkins Reviewed-by: Jim Raykowski <[email protected]> diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc index 0303d4c509ae..70a339639f9e 100644 --- a/sw/inc/strings.hrc +++ b/sw/inc/strings.hrc @@ -1573,6 +1573,8 @@ #define STR_QUERY_CLOSE_TEXT NC_("STR_QUERY_CLOSE_TEXT", "The current index entry was modified.") #define STR_QUERY_CLOSE_QUESTION NC_("STR_QUERY_CLOSE_QUESTION", "Do you want to save changes?") +#define STR_PAGES NNC_("STR_PAGES", "Page: %1", "Pages: %1-%2") + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index 2186155012c7..c383efb93290 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -5680,11 +5680,20 @@ IMPL_LINK(SwContentTree, QueryTooltipHdl, const weld::TreeIter&, rEntry, OUStrin { assert(dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pUserData))); SwOutlineContent* pOutlineContent = static_cast<SwOutlineContent*>(pUserData); - SwOutlineNodes::size_type nOutlinePos = pOutlineContent->GetOutlinePos(); - const OUString& rOutlineName = pOutlineContent->GetName(); + + sEntry = pOutlineContent->GetName(); + const SwNodes& rNodes = m_pActiveShell->GetDoc()->GetNodes(); const SwOutlineNodes& rOutlineNodes = rNodes.GetOutLineNds(); - SwNode* pStartNode = rOutlineNodes[nOutlinePos]; + + SwNode* pStartNode = rOutlineNodes[pOutlineContent->GetOutlinePos()]; + + // Don't show additional info in the tooltip if the outline is in footnote/endnote. + const SwFrame* pFrame + = pStartNode->GetContentNode()->getLayoutFrame(m_pActiveShell->GetLayout()); + if (!pFrame || pFrame->IsInFootnote()) + break; + SwNode* pEndNode = &rNodes.GetEndOfContent(); // tdf#163646 - Show in the tooltip for heading entries in Writer Navigator the @@ -5708,9 +5717,33 @@ IMPL_LINK(SwContentTree, QueryTooltipHdl, const weld::TreeIter&, rEntry, OUStrin SwPaM aPaM(*pStartNode, *pEndNode); SwDocStat aDocStat; SwDoc::CountWords(aPaM, aDocStat); - sEntry = rOutlineName + " " + SwResId(FLD_STAT_WORD) + ": " - + OUString::number(aDocStat.nWord) + " " + SwResId(FLD_STAT_CHAR) + ": " - + OUString::number(aDocStat.nChar); + sEntry += " " + SwResId(FLD_STAT_WORD) + ": " + OUString::number(aDocStat.nWord) + + " " + SwResId(FLD_STAT_CHAR) + ": " + OUString::number(aDocStat.nChar); + + // tdf#166048 - Show pages from/to in the Navigator's heading tooltip + if (pEndNode != pStartNode) + { + SwNodeIndex aIdx(*pEndNode, -1); + while (aIdx.GetNode().GetEndNode()) + --aIdx; + pEndNode = &aIdx.GetNode(); + } + aPaM.GetPoint()->Assign( + *pEndNode, pEndNode->IsTextNode() ? pEndNode->GetTextNode()->Len() : 0); + + auto nFirstPage = aPaM.GetPageNum(false); + if (nFirstPage != 0) + { + auto nLastPage = aPaM.GetPageNum(); + sEntry += " " + SwResId(STR_PAGES, nLastPage ? nLastPage - nFirstPage + 1 : 1); + if (nLastPage != 0 && nFirstPage < nLastPage) + { + sEntry = sEntry.replaceFirst("%1", OUString::number(nFirstPage)); + sEntry = sEntry.replaceFirst("%2", OUString::number(nLastPage)); + } + else + sEntry = sEntry.replaceFirst("%1", OUString::number(nFirstPage)); + } } break; case ContentTypeId::GRAPHIC:
