diff options
author | Jim Raykowski <raykowj@gmail.com> | 2024-08-15 09:43:13 -0800 |
---|---|---|
committer | Jim Raykowski <raykowj@gmail.com> | 2024-08-16 09:16:57 +0200 |
commit | dd93375dcebe4eb7d7cc9696c18728f83aaed86e (patch) | |
tree | 510ce38b337c25967aed993fd7ebab72d4eefa79 | |
parent | 0a9da9e43c53406c867fe95cdd5c7192ce08bcb6 (diff) |
related tdf#63967: Ability to Quickly Get Word Count of Sections
Using Navigator
Adds word count information of headings outline content to the
headings content tooltip.
Change-Id: I31163d95139cdc1ef770591684e9cb585ed49a8f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171920
Tested-by: Jenkins
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
-rw-r--r-- | sw/source/uibase/utlui/content.cxx | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index 82bd41151cca..9877ef40b676 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -5226,8 +5226,23 @@ IMPL_LINK(SwContentTree, QueryTooltipHdl, const weld::TreeIter&, rEntry, OUStrin sEntry = static_cast<SwPostItContent*>(pUserData)->GetName(); break; case ContentTypeId::OUTLINE: + { assert(dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pUserData))); - sEntry = static_cast<SwOutlineContent*>(pUserData)->GetName(); + SwOutlineContent* pOutlineContent = static_cast<SwOutlineContent*>(pUserData); + SwOutlineNodes::size_type nOutlinePos = pOutlineContent->GetOutlinePos(); + const SwNodes& rNodes = m_pActiveShell->GetDoc()->GetNodes(); + const SwOutlineNodes& rOutlineNodes = rNodes.GetOutLineNds(); + SwNode* pStartNode = rOutlineNodes[nOutlinePos]; + SwNode* pEndNode = &rNodes.GetEndOfContent(); + if (nOutlinePos + 1 < rOutlineNodes.size()) + pEndNode = rOutlineNodes[nOutlinePos + 1]; + SwPaM aPaM(*pStartNode, *pEndNode); + SwDocStat aDocStat; + SwDoc::CountWords(aPaM, aDocStat); + sEntry = pOutlineContent->GetName() + "\n" + SwResId(FLD_STAT_WORD) + ": " + + OUString::number(aDocStat.nWord) + "\n" + SwResId(FLD_STAT_CHAR) + ": " + + OUString::number(aDocStat.nChar); + } break; case ContentTypeId::GRAPHIC: assert(dynamic_cast<SwGraphicContent*>(static_cast<SwTypeNumber*>(pUserData))); |