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 <raykowj@gmail.com>
This commit is contained in:
Jim Raykowski
2025-03-06 06:08:27 +01:00
parent e79e12484f
commit 90fdf50aa5
+21 -3
View File
@@ -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() + "\n" + SwResId(FLD_STAT_WORD) + ": "
sEntry = rOutlineName + "\n" + SwResId(FLD_STAT_WORD) + ": "
+ OUString::number(aDocStat.nWord) + "\n" + SwResId(FLD_STAT_CHAR) + ": "
+ OUString::number(aDocStat.nChar);
}