sw/source/uibase/utlui/content.cxx |   24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

New commits:
commit 90fdf50aa5dac4520893a98e52feb8d1ae8d9d7a
Author:     Jim Raykowski <rayk...@gmail.com>
AuthorDate: Thu Oct 31 20:16:34 2024 -0800
Commit:     Jim Raykowski <rayk...@gmail.com>
CommitDate: Thu Mar 6 06:08:27 2025 +0100

    tdf#163646 Writer Navigator enhancement to show in the tooltip for
    
    Headings entries the outline word and character count that includes
    all sub outline words and characters.
    
    Examples:
    
    FIRST_LEVEL_HEADING --> tooltip shows 30 words
    two three four five six seven eight nine ten
      SECOND_LEVEL_HEADING --> tooltip shows 20 words
      two three four five six seven eight nine ten
        THIRD_LEVEL_HEADING --> tooltip shows 10 words
        two three four five six seven eight nine ten
    
    FIRST_LEVEL_HEADING --> tooltip shows 17 words
    two three four five
      SECOND_LEVEL_HEADING --> tooltip shows 4 words
      two three four
      SECOND_LEVEL_HEADING --> tooltip shows 8 words
      two three
        THIRD_LEVEL_HEADING --> tooltip shows 5 words
        two three four five
    
    Change-Id: If2a40c14633889d6a38df77f017b73a0f038584d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175895
    Tested-by: Jenkins
    Reviewed-by: Jim Raykowski <rayk...@gmail.com>

diff --git a/sw/source/uibase/utlui/content.cxx 
b/sw/source/uibase/utlui/content.cxx
index e7b8aac22ec1..d1aa92b52a46 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -5495,16 +5495,34 @@ 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();
                 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];
+
+                // tdf#163646 - Show in the tooltip for heading entries in 
Writer Navigator the
+                // outline word and character count of the heading ncluding 
the outline word and
+                // character count of all sub headings
+                int nEntryDepth = m_xTreeView->get_iter_depth(rEntry);
+                std::unique_ptr<weld::TreeIter> xIter = 
m_xTreeView->make_iterator(&rEntry);
+                int nIterDepth;
+                while (m_xTreeView->iter_next(*xIter)
+                       && (nIterDepth = m_xTreeView->get_iter_depth(*xIter)))
+                {
+                    if (nIterDepth <= nEntryDepth)
+                    {
+                        pOutlineContent
+                            = 
weld::fromId<SwOutlineContent*>(m_xTreeView->get_id(*xIter));
+                        pEndNode = 
rOutlineNodes[pOutlineContent->GetOutlinePos()];
+                        break;
+                    }
+                }
+
                 SwPaM aPaM(*pStartNode, *pEndNode);
                 SwDocStat aDocStat;
                 SwDoc::CountWords(aPaM, aDocStat);
-                sEntry = pOutlineContent->GetName() + "
" + SwResId(FLD_STAT_WORD) + ": "
+                sEntry = rOutlineName + "
" + SwResId(FLD_STAT_WORD) + ": "
                          + OUString::number(aDocStat.nWord) + "
" + SwResId(FLD_STAT_CHAR) + ": "
                          + OUString::number(aDocStat.nChar);
             }

Reply via email to