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

New commits:
commit 8e17bc079fb43a119e423c74d2131d039e8973c3
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Thu Feb 20 19:00:04 2025 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Wed Apr 16 09:04:37 2025 +0200

    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>
    (cherry picked from commit f439448d21ef2feb03a9920d95d30f23795db6ac)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182153
    Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de>
    (cherry picked from commit b016c132eed47439fe96a1d9f933f3d6368a9718)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184236
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx
index a3c5081b8dae..06cf8109b9e4 100644
--- a/sw/source/core/crsr/crstrvl.cxx
+++ b/sw/source/core/crsr/crstrvl.cxx
@@ -1853,10 +1853,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