sw/source/uibase/utlui/content.cxx |   17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

New commits:
commit dd93375dcebe4eb7d7cc9696c18728f83aaed86e
Author:     Jim Raykowski <[email protected]>
AuthorDate: Thu Aug 15 09:43:13 2024 -0800
Commit:     Jim Raykowski <[email protected]>
CommitDate: Fri Aug 16 09:16:57 2024 +0200

    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 <[email protected]>

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() + "
" + SwResId(FLD_STAT_WORD) + ": "
+                         + OUString::number(aDocStat.nWord) + "
" + SwResId(FLD_STAT_CHAR) + ": "
+                         + OUString::number(aDocStat.nChar);
+            }
             break;
             case ContentTypeId::GRAPHIC:
                 
assert(dynamic_cast<SwGraphicContent*>(static_cast<SwTypeNumber*>(pUserData)));

Reply via email to