sw/source/core/crsr/crstrvl.cxx |   32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

New commits:
commit f439448d21ef2feb03a9920d95d30f23795db6ac
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Thu Feb 20 19:00:04 2025 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Tue Feb 25 10:52:03 2025 +0100

    tdf#165322 sw: prefer insert/delete redline in mouse-over tooltip
    
    Unfortunately SwCursorShell::GetContentAtPos() can only report 1 redline
    for a given position; in case there is a format and a insert/delete
    redline at the same position, the latter is more important.
    
    This is then used in SwEditWin::RequestHelp() to display a tooltip if
    the user moves the mouse cursor over a redline.
    
    Change-Id: I32af7a154873e3fa5775a711980bb3dab3e307ad
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181960
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx
index 04d08f60f8e0..657c4d97a542 100644
--- a/sw/source/core/crsr/crstrvl.cxx
+++ b/sw/source/core/crsr/crstrvl.cxx
@@ -1912,10 +1912,40 @@ bool SwCursorShell::GetContentAtPos( const Point& rPt,
 
             if( !bRet && IsAttrAtPos::Redline & rContentAtPos.eContentAtPos )
             {
-                const SwRangeRedline* pRedl = 
GetDoc()->getIDocumentRedlineAccess().GetRedline(aPos, nullptr);
+                SwRedlineTable::size_type index;
+                IDocumentRedlineAccess const& 
rIDRA{GetDoc()->getIDocumentRedlineAccess()};
+                const SwRangeRedline* pRedl{rIDRA.GetRedline(aPos, &index)};
 
                 if( pRedl )
                 {
+                    // treat insert/delete as more important than formatting
+                    for (; index < rIDRA.GetRedlineTable().size(); ++index)
+                    {
+                        SwRangeRedline const*const 
pTmp{rIDRA.GetRedlineTable()[index]};
+                        if (aPos < *pTmp->Start())
+                        {
+                            break;
+                        }
+                        switch (pRedl->GetType())
+                        {
+                            case RedlineType::Format:
+                            case RedlineType::FmtColl:
+                            case RedlineType::ParagraphFormat:
+                                switch (pTmp->GetType())
+                                {
+                                    case RedlineType::Insert:
+                                    case RedlineType::Delete:
+                                        pRedl = pTmp;
+                                        break;
+                                    default:
+                                        break;
+                                }
+                            break;
+                            default:
+                                break;
+                        }
+                    };
+
                     rContentAtPos.aFnd.pRedl = pRedl;
                     rContentAtPos.eContentAtPos = IsAttrAtPos::Redline;
                     rContentAtPos.pFndTextAttr = nullptr;

Reply via email to