sd/source/ui/inc/ViewShell.hxx |    3 +
 sd/source/ui/view/viewshel.cxx |   80 ++++++++++++++++++++++++++---------------
 2 files changed, 54 insertions(+), 29 deletions(-)

New commits:
commit 614bcc594285c3badb26710d9b78e80bdeca0b81
Author:     Armin Le Grand (allotropia) <armin.le.grand.ext...@allotropia.de>
AuthorDate: Wed Apr 10 15:29:13 2024 +0200
Commit:     Armin Le Grand <armin.le.gr...@me.com>
CommitDate: Wed Apr 10 18:22:23 2024 +0200

    IASS: Support Mouse-Wheel Actions
    
    The support for MouseWheel was missing. That showed
    when using it in IASS the scroll commands were always
    feeded to the SlideShow. Thus it was not possible
    to e.g. scroll using MouseWheel in EditView when
    IASS was active and SlideShow running.
    
    This happens in ViewShell::HandleScrollCommand. It
    needs to be made focus-dependent when IASS is active.
    
    This is the same as already done for keyboard input,
    so I consolidated this now to a method called
    ViewShell::useInputForSlideShow() that does all the
    necessary stuff and answers as needed. Using that
    in various places: keyboard and MouseWheel, but also
    adapted other places where the same has to happen,
    mainly some gesture stuff.
    
    Change-Id: I1a697e4b35b195695f1a5ea2305a3cee8851fa8d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165929
    Tested-by: Jenkins
    Reviewed-by: Armin Le Grand <armin.le.gr...@me.com>

diff --git a/sd/source/ui/inc/ViewShell.hxx b/sd/source/ui/inc/ViewShell.hxx
index d9fd8564edd0..89332537e94c 100644
--- a/sd/source/ui/inc/ViewShell.hxx
+++ b/sd/source/ui/inc/ViewShell.hxx
@@ -547,6 +547,9 @@ private:
     /** Create the rulers.
     */
     void SetupRulers();
+
+    // IASS: Check if commands should be used for SlideShow
+    bool useInputForSlideShow() const;
 };
 
 SdrView* ViewShell::GetDrawView() const
diff --git a/sd/source/ui/view/viewshel.cxx b/sd/source/ui/view/viewshel.cxx
index 96a1a01463cd..9d0c7c98b7db 100644
--- a/sd/source/ui/view/viewshel.cxx
+++ b/sd/source/ui/view/viewshel.cxx
@@ -403,6 +403,34 @@ void ViewShell::Shutdown()
     Exit ();
 }
 
+// IASS: Check if commands should be used for SlideShow
+// This is the case when IASS is on, SlideShow is active
+// and the SlideShow Window has the focus
+bool ViewShell::useInputForSlideShow() const
+{
+    rtl::Reference< SlideShow > 
xSlideShow(SlideShow::GetSlideShow(GetViewShellBase()));
+
+    if (!xSlideShow.is())
+        // no SlideShow, do not use
+        return false;
+
+    if (!xSlideShow->isRunning())
+        // SlideShow not running, do not use
+        return false;
+
+    if(!xSlideShow->IsInteractiveSlideshow())
+        // if IASS is deactivated, do what was done before when
+        // SlideSHow is running: use for SlideShow
+        return true;
+
+    // else, check if SlideShow Window has the focus
+    OutputDevice* pShOut(xSlideShow->getShowWindow());
+    vcl::Window* pShWin(pShOut ? pShOut->GetOwnerWindow() : nullptr);
+
+    // return true if we got the SlideShow Window and it has the focus
+    return nullptr != pShWin && pShWin->HasFocus();
+}
+
 bool ViewShell::KeyInput(const KeyEvent& rKEvt, ::sd::Window* pWin)
 {
     bool bReturn(false);
@@ -418,20 +446,10 @@ bool ViewShell::KeyInput(const KeyEvent& rKEvt, 
::sd::Window* pWin)
     const size_t OriCount = GetView()->GetMarkedObjectList().GetMarkCount();
     if(!bReturn)
     {
-        rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( 
GetViewShellBase() ) );
-        const bool bSlideShowRunning(xSlideShow.is() && 
xSlideShow->isRunning());
-        bool bUseForSlideShow(bSlideShowRunning);
-
-        if(bSlideShowRunning && xSlideShow->IsInteractiveSlideshow())
-        {
-            // IASS
-            OutputDevice* pShOut(xSlideShow->getShowWindow());
-            vcl::Window* pShWin(pShOut ? pShOut->GetOwnerWindow() : nullptr);
-            bUseForSlideShow = pShWin && pShWin->HasFocus();
-        }
-
-        if(bUseForSlideShow) //IASS
+        if(useInputForSlideShow()) //IASS
         {
+            // use for SlideShow
+            rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( 
GetViewShellBase() ) );
             bReturn = xSlideShow->keyInput(rKEvt);
         }
         else
@@ -689,9 +707,10 @@ bool ViewShell::HandleScrollCommand(const CommandEvent& 
rCEvt, ::sd::Window* pWi
     {
         case CommandEventId::GestureSwipe:
             {
-                rtl::Reference< SlideShow > xSlideShow( 
SlideShow::GetSlideShow( GetViewShellBase() ) );
-                if (xSlideShow.is())
+                if(useInputForSlideShow()) //IASS
                 {
+                    // use for SlideShow
+                    rtl::Reference< SlideShow > xSlideShow( 
SlideShow::GetSlideShow( GetViewShellBase() ) );
                     const CommandGestureSwipeData* pSwipeData = 
rCEvt.GetGestureSwipeData();
                     bDone = xSlideShow->swipe(*pSwipeData);
                 }
@@ -699,9 +718,10 @@ bool ViewShell::HandleScrollCommand(const CommandEvent& 
rCEvt, ::sd::Window* pWi
             break;
         case CommandEventId::GestureLongPress:
             {
-                rtl::Reference< SlideShow > xSlideShow( 
SlideShow::GetSlideShow( GetViewShellBase() ) );
-                if (xSlideShow.is())
+                if(useInputForSlideShow()) //IASS
                 {
+                    // use for SlideShow
+                    rtl::Reference< SlideShow > xSlideShow( 
SlideShow::GetSlideShow( GetViewShellBase() ) );
                     const CommandGestureLongPressData* pLongPressData = 
rCEvt.GetLongPressData();
                     bDone = xSlideShow->longpress(*pLongPressData);
                 }
@@ -713,17 +733,21 @@ bool ViewShell::HandleScrollCommand(const CommandEvent& 
rCEvt, ::sd::Window* pWi
                 Reference< XSlideShowController > xSlideShowController( 
SlideShow::GetSlideShowController(GetViewShellBase() ) );
                 if( xSlideShowController.is() )
                 {
-                    // We ignore zooming with control+mouse wheel.
-                    const CommandWheelData* pData = rCEvt.GetWheelData();
-                    if( pData && !pData->GetModifier() && ( pData->GetMode() 
== CommandWheelMode::SCROLL ) && !pData->IsHorz() )
+                    if(useInputForSlideShow()) //IASS
                     {
-                        ::tools::Long nDelta = pData->GetDelta();
-                        if( nDelta > 0 )
-                            xSlideShowController->gotoPreviousSlide();
-                        else if( nDelta < 0 )
-                            xSlideShowController->gotoNextEffect();
+                        // use for SlideShow
+                        // We ignore zooming with control+mouse wheel.
+                        const CommandWheelData* pData = rCEvt.GetWheelData();
+                        if( pData && !pData->GetModifier() && ( 
pData->GetMode() == CommandWheelMode::SCROLL ) && !pData->IsHorz() )
+                        {
+                            ::tools::Long nDelta = pData->GetDelta();
+                            if( nDelta > 0 )
+                                xSlideShowController->gotoPreviousSlide();
+                            else if( nDelta < 0 )
+                                xSlideShowController->gotoNextEffect();
+                        }
+                        break;
                     }
-                    break;
                 }
             }
             [[fallthrough]];
@@ -782,8 +806,6 @@ bool ViewShell::HandleScrollCommand(const CommandEvent& 
rCEvt, ::sd::Window* pWi
         {
             const CommandGestureZoomData* pData = rCEvt.GetGestureZoomData();
 
-            Reference<XSlideShowController> 
xSlideShowController(SlideShow::GetSlideShowController(GetViewShellBase()));
-
             if (pData->meEventType == GestureEventZoomType::Begin)
             {
                 mfLastZoomScale = pData->mfScaleDelta;
@@ -796,7 +818,7 @@ bool ViewShell::HandleScrollCommand(const CommandEvent& 
rCEvt, ::sd::Window* pWi
                 double deltaBetweenEvents = (pData->mfScaleDelta - 
mfLastZoomScale) / mfLastZoomScale;
                 mfLastZoomScale = pData->mfScaleDelta;
 
-                if (!GetDocSh()->IsUIActive() && !xSlideShowController.is())
+                if (!GetDocSh()->IsUIActive() && !useInputForSlideShow()) 
//IASS
                 {
                     const ::tools::Long nOldZoom = 
GetActiveWindow()->GetZoom();
                     ::tools::Long nNewZoom;

Reply via email to