vcl/source/app/help.cxx |   90 ++++++++++++++++++++++--------------------------
 1 file changed, 43 insertions(+), 47 deletions(-)

New commits:
commit 4bb80847578fb85119d2ddb2008a90f916a5baf0
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Thu Jul 6 09:15:46 2023 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Thu Jul 6 13:18:24 2023 +0200

    Optimize a bit
    
    Change-Id: I1ac373bea06b946b3c51154dfcdbe6aa22eeae49
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154089
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/vcl/source/app/help.cxx b/vcl/source/app/help.cxx
index 2f995d0fce9f..2c6d020537e4 100644
--- a/vcl/source/app/help.cxx
+++ b/vcl/source/app/help.cxx
@@ -183,9 +183,11 @@ void Help::ShowQuickHelp( vcl::Window* pParent,
                           QuickHelpFlags nStyle )
 {
     sal_uInt16 nHelpWinStyle = ( nStyle & QuickHelpFlags::TipStyleBalloon ) ? 
HELPWINSTYLE_BALLOON : HELPWINSTYLE_QUICK;
+    Point aScreenPos = nStyle & QuickHelpFlags::NoAutoPos
+                           ? Point()
+                           : 
pParent->OutputToScreenPixel(pParent->GetPointerPosPixel());
     ImplShowHelpWindow( pParent, nHelpWinStyle, nStyle,
-                        rHelpText,
-                        pParent->OutputToScreenPixel( 
pParent->GetPointerPosPixel() ), rScreenRect );
+                        rHelpText, aScreenPos, rScreenRect );
 }
 
 void Help::HideBalloonAndQuickHelp()
@@ -491,9 +493,8 @@ void ImplShowHelpWindow( vcl::Window* pParent, sal_uInt16 
nHelpWinStyle, QuickHe
     if (rHelpText.isEmpty() && !aHelpData.mbRequestingHelp)
         return;
 
-    VclPtr<HelpTextWindow> pHelpWin = aHelpData.mpHelpWin;
     bool bNoDelay = false;
-    if ( pHelpWin )
+    if (VclPtr<HelpTextWindow> pHelpWin = aHelpData.mpHelpWin)
     {
         SAL_WARN_IF( pHelpWin == pParent, "vcl", "HelpInHelp ?!" );
 
@@ -512,27 +513,25 @@ void ImplShowHelpWindow( vcl::Window* pParent, sal_uInt16 
nHelpWinStyle, QuickHe
                 if( pHelpWin->IsVisible() )
                     pHelpWin->Invalidate();
             }
+            return;
         }
-        else
-        {
-            // remove help window if no HelpText or
-            // other help mode. but keep it if we are scrolling, ie not 
requesting help
-            bool bWasVisible = pHelpWin->IsVisible();
-            if ( bWasVisible )
-                bNoDelay = true; // display it quickly if we were already in 
quick help mode
-            pHelpWin = nullptr;
-            ImplDestroyHelpWindow( bWasVisible );
-        }
+
+        // remove help window if no HelpText or
+        // other help mode. but keep it if we are scrolling, ie not requesting 
help
+        bool bWasVisible = pHelpWin->IsVisible();
+        if ( bWasVisible )
+            bNoDelay = true; // display it quickly if we were already in quick 
help mode
+        ImplDestroyHelpWindow( bWasVisible );
     }
 
-    if (pHelpWin || rHelpText.isEmpty())
+    if (rHelpText.isEmpty())
         return;
 
     sal_uInt64 nCurTime = tools::Time::GetSystemTicks();
     if ( ( nCurTime - aHelpData.mnLastHelpHideTime ) < 
o3tl::make_unsigned(HelpSettings::GetTipDelay()) )
         bNoDelay = true;
 
-    pHelpWin = VclPtr<HelpTextWindow>::Create( pParent, rHelpText, 
nHelpWinStyle, nStyle );
+    VclPtr<HelpTextWindow> pHelpWin = VclPtr<HelpTextWindow>::Create( pParent, 
rHelpText, nHelpWinStyle, nStyle );
     aHelpData.mpHelpWin = pHelpWin;
     pHelpWin->SetHelpArea( rHelpArea );
 
@@ -544,7 +543,6 @@ void ImplShowHelpWindow( vcl::Window* pParent, sal_uInt16 
nHelpWinStyle, QuickHe
     if ( !aHelpData.mbRequestingHelp )
         bNoDelay = true;
     pHelpWin->ShowHelp(bNoDelay);
-
 }
 
 void ImplDestroyHelpWindow( bool bUpdateHideTime )
@@ -569,43 +567,19 @@ void ImplDestroyHelpWindow(ImplSVHelpData& rHelpData, 
bool bUpdateHideTime)
 void ImplSetHelpWindowPos( vcl::Window* pHelpWin, sal_uInt16 nHelpWinStyle, 
QuickHelpFlags nStyle,
                            const Point& rPos, const tools::Rectangle& 
rHelpArea )
 {
-    Point       aPos = rPos;
+    Point       aPos;
     Size        aSz = pHelpWin->GetSizePixel();
     tools::Rectangle   aScreenRect = 
pHelpWin->ImplGetFrameWindow()->GetDesktopRectPixel();
-    aPos = 
pHelpWin->GetParent()->ImplGetFrameWindow()->OutputToAbsoluteScreenPixel( aPos 
);
+    vcl::Window* pWindow = pHelpWin->GetParent()->ImplGetFrameWindow();
     // get mouse screen coords
-    Point aMousePos( 
pHelpWin->GetParent()->ImplGetFrameWindow()->GetPointerPosPixel() );
-    aMousePos = 
pHelpWin->GetParent()->ImplGetFrameWindow()->OutputToAbsoluteScreenPixel( 
aMousePos );
-
-    if ( nHelpWinStyle == HELPWINSTYLE_QUICK )
-    {
-        if ( !(nStyle & QuickHelpFlags::NoAutoPos) )
-        {
-            tools::Long nScreenHeight = aScreenRect.GetHeight();
-            aPos.AdjustX( -4 );
-            if ( aPos.Y() > aScreenRect.Top()+nScreenHeight-(nScreenHeight/4) )
-                aPos.AdjustY( -(aSz.Height()+4) );
-            else
-                aPos.AdjustY(21 );
-        }
-    }
-    else
-    {
-        // If it's the mouse position, move the window slightly
-        // so the mouse pointer does not cover it
-        if ( aPos == aMousePos )
-        {
-            aPos.AdjustX(12 );
-            aPos.AdjustY(16 );
-        }
-    }
+    Point 
aMousePos(pWindow->OutputToAbsoluteScreenPixel(pWindow->GetPointerPosPixel()));
 
     if ( nStyle & QuickHelpFlags::NoAutoPos )
     {
         // convert help area to screen coords
         tools::Rectangle devHelpArea(
-            
pHelpWin->GetParent()->ImplGetFrameWindow()->OutputToAbsoluteScreenPixel( 
rHelpArea.TopLeft() ),
-            
pHelpWin->GetParent()->ImplGetFrameWindow()->OutputToAbsoluteScreenPixel( 
rHelpArea.BottomRight() ) );
+            pWindow->OutputToAbsoluteScreenPixel( rHelpArea.TopLeft() ),
+            pWindow->OutputToAbsoluteScreenPixel( rHelpArea.BottomRight() ) );
 
         // which position of the rectangle?
         aPos = devHelpArea.Center();
@@ -635,6 +609,29 @@ void ImplSetHelpWindowPos( vcl::Window* pHelpWin, 
sal_uInt16 nHelpWinStyle, Quic
         else
             aPos.AdjustY( -(aSz.Height()/2) );
     }
+    else
+    {
+        aPos = pWindow->OutputToAbsoluteScreenPixel(rPos);
+        if ( nHelpWinStyle == HELPWINSTYLE_QUICK )
+        {
+            tools::Long nScreenHeight = aScreenRect.GetHeight();
+            aPos.AdjustX( -4 );
+            if ( aPos.Y() > aScreenRect.Top()+nScreenHeight-(nScreenHeight/4) )
+                aPos.AdjustY( -(aSz.Height()+4) );
+            else
+                aPos.AdjustY(21 );
+        }
+        else
+        {
+            // If it's the mouse position, move the window slightly
+            // so the mouse pointer does not cover it
+            if ( aPos == aMousePos )
+            {
+                aPos.AdjustX(12 );
+                aPos.AdjustY(16 );
+            }
+        }
+    }
 
     if ( aPos.X() < aScreenRect.Left() )
         aPos.setX( aScreenRect.Left() );
@@ -667,7 +664,6 @@ void ImplSetHelpWindowPos( vcl::Window* pHelpWin, 
sal_uInt16 nHelpWinStyle, Quic
         }
     }
 
-    vcl::Window* pWindow = pHelpWin->GetParent()->ImplGetFrameWindow();
     aPos = pWindow->AbsoluteScreenToOutputPixel( aPos );
     pHelpWin->SetPosPixel( aPos );
 }

Reply via email to