sw/source/uibase/utlui/content.cxx |   22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

New commits:
commit dd0c6d9277b22388b9c56682dcef0beef7fc1b97
Author:     Jim Raykowski <[email protected]>
AuthorDate: Tue Sep 23 17:30:01 2025 -0800
Commit:     Jim Raykowski <[email protected]>
CommitDate: Wed Sep 24 17:27:32 2025 +0200

    SwNavigator: Fix tooltip info when headings are ordered alphabetically
    
    Determining the outline end position from the Navigator content tree to
    calculate outline word count, character count, and page(s) shown in the
    heading entries tooltip gives incorrect results when headings are
    ordered alphabetically. This patch uses the outline level of outline
    nodes to determine the outline end position.
    
    Change-Id: Ibeb9ea0206450d8d9c7d605f981890d41a56e8cb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191419
    Reviewed-by: Jim Raykowski <[email protected]>
    Tested-by: Jenkins

diff --git a/sw/source/uibase/utlui/content.cxx 
b/sw/source/uibase/utlui/content.cxx
index c383efb93290..66d4088253ad 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -5685,8 +5685,8 @@ IMPL_LINK(SwContentTree, QueryTooltipHdl, const 
weld::TreeIter&, rEntry, OUStrin
 
                 const SwNodes& rNodes = m_pActiveShell->GetDoc()->GetNodes();
                 const SwOutlineNodes& rOutlineNodes = rNodes.GetOutLineNds();
-
-                SwNode* pStartNode = 
rOutlineNodes[pOutlineContent->GetOutlinePos()];
+                SwOutlineNodes::size_type nStartPos = 
pOutlineContent->GetOutlinePos();
+                SwNode* pStartNode = rOutlineNodes[nStartPos];
 
                 // Don't show additional info in the tooltip if the outline is 
in footnote/endnote.
                 const SwFrame* pFrame
@@ -5699,20 +5699,16 @@ IMPL_LINK(SwContentTree, QueryTooltipHdl, const 
weld::TreeIter&, rEntry, OUStrin
                 // tdf#163646 - Show in the tooltip for heading entries in 
Writer Navigator the
                 // outline word and character count of the heading including 
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)))
+                SwOutlineNodes::size_type nEndPos = nStartPos;
+                auto nStartNodeOutlineLevel = 
pStartNode->GetTextNode()->GetAttrOutlineLevel();
+                for (++nEndPos; nEndPos < rOutlineNodes.size(); ++nEndPos)
                 {
-                    if (nIterDepth <= nEntryDepth)
-                    {
-                        pOutlineContent
-                            = 
weld::fromId<SwOutlineContent*>(m_xTreeView->get_id(*xIter));
-                        pEndNode = 
rOutlineNodes[pOutlineContent->GetOutlinePos()];
+                    pEndNode = rOutlineNodes[nEndPos];
+                    if (pEndNode->GetTextNode()->GetAttrOutlineLevel() <= 
nStartNodeOutlineLevel)
                         break;
-                    }
                 }
+                if (nEndPos == rOutlineNodes.size())
+                    pEndNode = &rNodes.GetEndOfContent();
 
                 SwPaM aPaM(*pStartNode, *pEndNode);
                 SwDocStat aDocStat;

Reply via email to