sw/source/uibase/docvw/edtwin2.cxx |   44 ++++++++++++++++++++++++++++---------
 vcl/source/app/help.cxx            |    6 ++++-
 2 files changed, 39 insertions(+), 11 deletions(-)

New commits:
commit 1396347c8e9b036f15bc646b9475073344e69e74
Author:     Tibor Nagy <tibor.nagy.ext...@allotropia.de>
AuthorDate: Thu May 23 01:14:21 2024 +0200
Commit:     Nagy Tibor <tibor.nagy.ext...@allotropia.de>
CommitDate: Thu May 23 13:04:06 2024 +0200

    tdf#159899 sw: show hyperlink name as tooltip
    
    Change-Id: I48f841d1c42f9541e03632a88e1a4f65975a5335
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167971
    Tested-by: Jenkins
    Reviewed-by: Nagy Tibor <tibor.nagy.ext...@allotropia.de>

diff --git a/sw/source/uibase/docvw/edtwin2.cxx 
b/sw/source/uibase/docvw/edtwin2.cxx
index a0a1016b114d..4107d2a05c0b 100644
--- a/sw/source/uibase/docvw/edtwin2.cxx
+++ b/sw/source/uibase/docvw/edtwin2.cxx
@@ -333,9 +333,10 @@ void SwEditWin::RequestHelp(const HelpEvent &rEvt)
     if(bQuickBalloon && !rSh.GetViewOptions()->IsShowContentTips())
         return;
     bool bContinue = true;
+    bool bScreenTip = false;
     CurrShell aCurr(&rSh);
     OUString sText;
-    Point aPos( PixelToLogic( ScreenToOutputPixel( rEvt.GetMousePosPixel() ) 
));
+    Point aPt( PixelToLogic( ScreenToOutputPixel( rEvt.GetMousePosPixel() ) ));
     bool bBalloon = bool(rEvt.GetMode() & HelpEventMode::BALLOON);
 
     SdrView *pSdrView = rSh.GetDrawView();
@@ -365,7 +366,7 @@ void SwEditWin::RequestHelp(const HelpEvent &rEvt)
                                     IsAttrAtPos::TableRedline |
                                     IsAttrAtPos::TableColRedline );
 
-        if( rSh.GetContentAtPos( aPos, aContentAtPos, false, &aFieldRect ) )
+        if( rSh.GetContentAtPos( aPt, aContentAtPos, false, &aFieldRect ) )
         {
             QuickHelpFlags nStyle = QuickHelpFlags::NONE; // style of quick 
help
             switch( aContentAtPos.eContentAtPos )
@@ -445,6 +446,27 @@ void SwEditWin::RequestHelp(const HelpEvent &rEvt)
                 if ( !bExecHyperlinks )
                 {
                     sText = SfxHelp::GetURLHelpText(sText);
+
+                    SwPosition aPos(rSh.GetDoc()->GetNodes());
+                    rSh.GetLayout()->GetModelPositionForViewPoint(&aPos, aPt);
+                    rtl::Reference<SwXTextRange> 
xRange(SwXTextRange::CreateXTextRange(
+                        *(m_rView.GetDocShell()->GetDoc()), aPos, &aPos));
+
+                    OUString sName;
+                    xRange->getPropertyValue("HyperLinkName") >>= sName;
+                    if (!sName.isEmpty())
+                    {
+                        bScreenTip = true;
+                        OUStringBuffer sStrBuffer(sName);
+                        sal_Int32 nTextLen = sText.getLength();
+                        sal_Int32 nNameLen = sName.getLength();
+                        if (nNameLen > nTextLen)
+                        {
+                            for (sal_Int32 i = nTextLen - 1; i < nNameLen; i 
+= nTextLen)
+                                sStrBuffer.insert(i + 1, std::u16string_view(u"
"));
+                        }
+                        sText = sStrBuffer.makeStringAndClear() + "
" + sText;
+                    }
                 }
                 break;
             }
@@ -620,7 +642,7 @@ void SwEditWin::RequestHelp(const HelpEvent &rEvt)
                         if ( bShowTrackChanges && bShowInlineTooltips )
                         {
                             aContentAtPos.eContentAtPos = IsAttrAtPos::Redline;
-                            if( rSh.GetContentAtPos( aPos, aContentAtPos, 
false, &aFieldRect ) )
+                            if( rSh.GetContentAtPos( aPt, aContentAtPos, 
false, &aFieldRect ) )
                                 sText = 
lcl_GetRedlineHelp(*aContentAtPos.aFnd.pRedl, bBalloon, /*bTableChange=*/false, 
/*bTableColChange=*/false);
                         }
                     }
@@ -636,12 +658,12 @@ void SwEditWin::RequestHelp(const HelpEvent &rEvt)
                 else
                 {
                     tools::Rectangle aRect(aFieldRect.SVRect());
-                    Point 
aPt(OutputToScreenPixel(LogicToPixel(aRect.TopLeft())));
-                    aRect.SetLeft(aPt.X());
-                    aRect.SetTop(aPt.Y());
-                    aPt = 
OutputToScreenPixel(LogicToPixel(aRect.BottomRight()));
-                    aRect.SetRight(aPt.X());
-                    aRect.SetBottom(aPt.Y());
+                    Point 
aRectPt(OutputToScreenPixel(LogicToPixel(aRect.TopLeft())));
+                    aRect.SetLeft(aRectPt.X());
+                    aRect.SetTop(aRectPt.Y());
+                    aRectPt = 
OutputToScreenPixel(LogicToPixel(aRect.BottomRight()));
+                    aRect.SetRight(aRectPt.X());
+                    aRect.SetBottom(aRectPt.Y());
 
                     // tdf#136336 ensure tooltip area surrounds the current 
mouse position with at least a pixel margin
                     aRect.Union(tools::Rectangle(rEvt.GetMousePosPixel(), 
Size(1, 1)));
@@ -655,7 +677,9 @@ void SwEditWin::RequestHelp(const HelpEvent &rEvt)
                     else
                     {
                         // the show the help
-                        OUString sDisplayText(ClipLongToolTip(sText));
+                        OUString sDisplayText(sText);
+                        if (!bScreenTip)
+                            sDisplayText = ClipLongToolTip(sText);
                         Help::ShowQuickHelp(this, aRect, sDisplayText, nStyle);
                     }
                 }
diff --git a/vcl/source/app/help.cxx b/vcl/source/app/help.cxx
index bbdb0ea3c6f1..8788b449bb2d 100644
--- a/vcl/source/app/help.cxx
+++ b/vcl/source/app/help.cxx
@@ -341,7 +341,11 @@ void HelpTextWindow::SetHelpText( const OUString& 
rHelpText )
     }
     else // HELPWINSTYLE_BALLOON
     {
-        sal_Int32 nCharsInLine = 35 + ((maHelpText.getLength()/100)*5);
+        sal_Int32 nCharsInLine;
+        if (mnHelpWinStyle == HELPWINSTYLE_QUICK)
+            nCharsInLine = maHelpText.getLength();
+        else
+            nCharsInLine = 35 + ((maHelpText.getLength() / 100) * 5);
         // average width to have all windows consistent
         OUStringBuffer aBuf(nCharsInLine);
         comphelper::string::padToLength(aBuf, nCharsInLine, 'x');

Reply via email to