sd/source/ui/animations/CustomAnimationPane.cxx |    3 
 sd/source/ui/animations/SlideTransitionPane.cxx |    2 
 sd/source/ui/inc/slideshow.hxx                  |    6 
 sd/source/ui/slideshow/slideshow.cxx            |   39 +++++
 sd/source/ui/slideshow/slideshowimpl.cxx        |  174 +++++++++++++++++++++++-
 sd/source/ui/slideshow/slideshowimpl.hxx        |   19 ++
 6 files changed, 240 insertions(+), 3 deletions(-)

New commits:
commit 69bac9b78ce7dcbe91da3d3552aa3dd7edaf2b4a
Author:     Armin Le Grand (allotropia) <armin.le.grand.ext...@allotropia.de>
AuthorDate: Tue Feb 20 20:03:51 2024 +0100
Commit:     Armin Le Grand <armin.le.gr...@me.com>
CommitDate: Wed Feb 21 10:34:42 2024 +0100

    IASS: Avoid more SlideShow shutdowns
    
    There are many ways the SlideShow may be stopped,
    but with IASS mode less are needed. Identified
    quite some and added needed code.
    Also added that for setting transitions or adding
    an effect to an Object when the SlideShow is up
    (the FullScreen one, makes no sense in-place)
    the Preview for that is show in the running
    SlideShow by switching to it, showing, and back.
    So this is used in this mode as a permanent
    preview for those changes.
    
    Change-Id: I5cc34e230358aecad30fec8aee05acfa937f9270
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163669
    Tested-by: Jenkins
    Reviewed-by: Armin Le Grand <armin.le.gr...@me.com>

diff --git a/sd/source/ui/animations/CustomAnimationPane.cxx 
b/sd/source/ui/animations/CustomAnimationPane.cxx
index 77607e06d033..35425a5dfea5 100644
--- a/sd/source/ui/animations/CustomAnimationPane.cxx
+++ b/sd/source/ui/animations/CustomAnimationPane.cxx
@@ -1879,7 +1879,8 @@ void CustomAnimationPane::onAdd()
 
     updateControls();
 
-    SlideShow::Stop( mrBase );
+    if (!SlideShow::IsInteractiveSlideshow()) // IASS
+        SlideShow::Stop( mrBase );
 }
 
 void CustomAnimationPane::onRemove()
diff --git a/sd/source/ui/animations/SlideTransitionPane.cxx 
b/sd/source/ui/animations/SlideTransitionPane.cxx
index e2c954623eaa..b83bb98087b0 100644
--- a/sd/source/ui/animations/SlideTransitionPane.cxx
+++ b/sd/source/ui/animations/SlideTransitionPane.cxx
@@ -884,7 +884,7 @@ void SlideTransitionPane::applyToSelectedPages(bool 
bPreview = true)
     {
         if (aEffect.mnType) // mnType = 0 denotes no transition
             playCurrentEffect();
-        else if( mxView.is() )
+        else if( mxView.is() && !SlideShow::IsInteractiveSlideshow()) // IASS
             SlideShow::Stop( mrBase );
     }
 
diff --git a/sd/source/ui/inc/slideshow.hxx b/sd/source/ui/inc/slideshow.hxx
index 81af4a52f4ee..2703d9611e31 100644
--- a/sd/source/ui/inc/slideshow.hxx
+++ b/sd/source/ui/inc/slideshow.hxx
@@ -106,6 +106,12 @@ public:
 
     // helper api
 
+    bool startInteractivePreview(
+        const css::uno::Reference< css::drawing::XDrawPage >& xDrawPage,
+        const css::uno::Reference< css::animations::XAnimationNode >& 
xAnimationNode );
+    bool isInteractiveSetup() const;
+    void endInteractivePreview();
+
     void startPreview(
         const css::uno::Reference< css::drawing::XDrawPage >& xDrawPage,
         const css::uno::Reference< css::animations::XAnimationNode >& 
xAnimationNode );
diff --git a/sd/source/ui/slideshow/slideshow.cxx 
b/sd/source/ui/slideshow/slideshow.cxx
index d0913569bd11..be3b95f27805 100644
--- a/sd/source/ui/slideshow/slideshow.cxx
+++ b/sd/source/ui/slideshow/slideshow.cxx
@@ -193,6 +193,16 @@ bool SlideShow::StartPreview( ViewShellBase const & rBase,
     if( !xSlideShow.is() )
         return false;
 
+    // end an already running IASS Preview (when someone is fast)
+    if (SlideShow::IsInteractiveSlideshow() && 
xSlideShow->isInteractiveSetup())
+        xSlideShow->endInteractivePreview();
+
+    // check if IASS re-use of running Slideshow can/should be done
+    // and do it
+    if (SlideShow::IsInteractiveSlideshow() && xSlideShow->isFullScreen()) // 
IASS
+        return xSlideShow->startInteractivePreview( xDrawPage, xAnimationNode 
);
+
+    // fallback to usual mode
     xSlideShow->startPreview( xDrawPage, xAnimationNode );
     return true;
 }
@@ -644,6 +654,13 @@ void SAL_CALL SlideShow::end()
 {
     SolarMutexGuard aGuard;
 
+    if (SlideShow::IsInteractiveSlideshow() && isInteractiveSetup())
+    {
+        // If IASS was active clean that up, but do not end SlideShow
+        endInteractivePreview();
+        return;
+    }
+
     // The mbIsInStartup flag should have been reset during the start of the
     // slide show.  Reset it here just in case that something has horribly
     // gone wrong.
@@ -909,6 +926,28 @@ void SlideShow::disposing(std::unique_lock<std::mutex>&)
     mpDoc = nullptr;
 }
 
+bool SlideShow::startInteractivePreview( const Reference< XDrawPage >& 
xDrawPage, const Reference< XAnimationNode >& xAnimationNode )
+{
+    if (!mxController.is())
+        return false;
+
+    mxController->startInteractivePreview(xDrawPage, xAnimationNode);
+    return mxController->isInteractiveSetup();
+}
+
+bool SlideShow::isInteractiveSetup() const
+{
+    if (!mxController.is())
+        return false;
+
+    return mxController->isInteractiveSetup();
+}
+
+void SlideShow::endInteractivePreview()
+{
+    mxController->endInteractivePreview();
+}
+
 void SlideShow::startPreview( const Reference< XDrawPage >& xDrawPage, const 
Reference< XAnimationNode >& xAnimationNode )
 {
     Sequence< PropertyValue > aArguments{
diff --git a/sd/source/ui/slideshow/slideshowimpl.cxx 
b/sd/source/ui/slideshow/slideshowimpl.cxx
index ca675e4509da..61e8bcf8f90a 100644
--- a/sd/source/ui/slideshow/slideshowimpl.cxx
+++ b/sd/source/ui/slideshow/slideshowimpl.cxx
@@ -167,6 +167,10 @@ public:
 
     bool hasSlides() const { return !maSlideNumbers.empty(); }
 
+    // for InteractiveSlideShow we need to temporarily change the program
+    // and mode, so allow save/restore that settings
+    void pushForPreview();
+    void popFromPreview();
 private:
     bool getSlideAPI( sal_Int32 nSlideNumber, Reference< XDrawPage >& xSlide, 
Reference< XAnimationNode >& xAnimNode );
     sal_Int32 findSlideIndex( sal_Int32 nSlideNumber ) const;
@@ -185,8 +189,40 @@ private:
     sal_Int32 mnCurrentSlideIndex;
     sal_Int32 mnHiddenSlideNumber;
     Reference< XIndexAccess > mxSlides;
+
+    // IASS data for push/pop
+    std::vector< sal_Int32 > maSlideNumbers2;
+    std::vector< bool > maSlideVisible2;
+    std::vector< bool > maSlideVisited2;
+    Reference< XAnimationNode > mxPreviewNode2;
+    Mode meMode2;
 };
 
+void AnimationSlideController::pushForPreview()
+{
+    maSlideNumbers2 = maSlideNumbers;
+    maSlideVisible2 = maSlideVisible;
+    maSlideVisited2 = maSlideVisited;
+    maSlideNumbers.clear();
+    maSlideVisible.clear();
+    maSlideVisited.clear();
+    mxPreviewNode2 = mxPreviewNode;
+    meMode2 = meMode;
+    meMode = AnimationSlideController::PREVIEW;
+}
+
+void AnimationSlideController::popFromPreview()
+{
+    maSlideNumbers = maSlideNumbers2;
+    maSlideVisible = maSlideVisible2;
+    maSlideVisited = maSlideVisited2;
+    maSlideNumbers2.clear();
+    maSlideVisible2.clear();
+    maSlideVisited2.clear();
+    mxPreviewNode = mxPreviewNode2;
+    meMode = meMode2;
+}
+
 Reference< XDrawPage > AnimationSlideController::getSlideByNumber( sal_Int32 
nSlideNumber ) const
 {
     Reference< XDrawPage > xSlide;
@@ -489,7 +525,9 @@ constexpr OUString gsBookmark( u"Bookmark"_ustr );
 constexpr OUString gsVerb( u"Verb"_ustr );
 
 SlideshowImpl::SlideshowImpl( const Reference< XPresentation2 >& 
xPresentation, ViewShell* pViewSh, ::sd::View* pView, SdDrawDocument* pDoc, 
vcl::Window* pParentWindow )
-: mxModel(pDoc->getUnoModel())
+: mxShow()
+, mxView()
+, mxModel(pDoc->getUnoModel())
 , maUpdateTimer("SlideShowImpl maUpdateTimer")
 , maInputFreezeTimer("SlideShowImpl maInputFreezeTimer")
 , maDeactivateTimer("SlideShowImpl maDeactivateTimer")
@@ -499,10 +537,14 @@ SlideshowImpl::SlideshowImpl( const Reference< 
XPresentation2 >& xPresentation,
 , mpDoc(pDoc)
 , mpParentWindow(pParentWindow)
 , mpShowWindow(nullptr)
+, mpSlideController()
 , mnRestoreSlide(0)
+, maPopupMousePos()
 , maPresSize( -1, -1 )
 , meAnimationMode(ANIMATIONMODE_SHOW)
+, maCharBuffer()
 , mpOldActiveWindow(nullptr)
+, maStarBASICGlobalErrorHdl()
 , mnChildMask( 0 )
 , mbDisposed(false)
 , mbAutoSaveWasOn(false)
@@ -515,11 +557,25 @@ SlideshowImpl::SlideshowImpl( const Reference< 
XPresentation2 >& xPresentation,
 , mnUserPaintColor( 0x80ff0000L )
 , mbUsePen(false)
 , mdUserPaintStrokeWidth ( 150.0 )
+, maShapeEventMap()
+, mxPreviewDrawPage()
+, mxPreviewAnimationNode()
+, mxPlayer()
+, mpPaneHider()
 , mnEndShowEvent(nullptr)
 , mnContextMenuEvent(nullptr)
 , mnEventObjectChange(nullptr)
 , mnEventPageOrderChange(nullptr)
 , mxPresentation( xPresentation )
+, mxListenerProxy()
+, mxShow2()
+, mxView2()
+, meAnimationMode2()
+, mbInterActiveSetup(false)
+, maPresSettings2()
+, mxPreviewDrawPage2()
+, mxPreviewAnimationNode2()
+, mnSlideIndex(0)
 {
     if( mpViewShell )
         mpOldActiveWindow = mpViewShell->GetActiveWindow();
@@ -742,6 +798,122 @@ void 
SlideshowImpl::disposing(std::unique_lock<std::mutex>&)
     mbDisposed = true;
 }
 
+bool SlideshowImpl::isInteractiveSetup() const
+{
+    return mbInterActiveSetup;
+}
+
+void SlideshowImpl::startInteractivePreview( const Reference< XDrawPage >& 
xDrawPage, const Reference< XAnimationNode >& xAnimationNode )
+{
+    // set flag that we are in IASS mode
+    mbInterActiveSetup = true;
+
+    // save stuff that will be replaced temporarily
+    mxShow2 = mxShow;
+    mxView2 = mxView;
+    mxPreviewDrawPage2 = mxPreviewDrawPage;
+    mxPreviewAnimationNode2 = mxPreviewAnimationNode;
+    meAnimationMode2 = meAnimationMode;
+    maPresSettings2 = maPresSettings;
+
+    // remember slide shown before preview
+    mnSlideIndex = getCurrentSlideIndex();
+
+    // set DrawPage/AnimationNode
+    mxPreviewDrawPage = xDrawPage;
+    mxPreviewAnimationNode = xAnimationNode;
+    meAnimationMode = ANIMATIONMODE_PREVIEW;
+
+    // set PresSettings for preview
+    maPresSettings.mbAll = false;
+    maPresSettings.mbEndless = false;
+    maPresSettings.mbCustomShow = false;
+    maPresSettings.mbManual = false;
+    maPresSettings.mbMouseVisible = false;
+    maPresSettings.mbMouseAsPen = false;
+    maPresSettings.mbLockedPages = false;
+    maPresSettings.mbAlwaysOnTop = false;
+    maPresSettings.mbFullScreen = false;
+    maPresSettings.mbAnimationAllowed = true;
+    maPresSettings.mnPauseTimeout = 0;
+    maPresSettings.mbShowPauseLogo = false;
+
+    // create a new temporary AnimationSlideController
+    mpSlideController->pushForPreview();
+    // Reference< XDrawPagesSupplier > xDrawPages( mpDoc->getUnoModel(), 
UNO_QUERY_THROW );
+    // Reference< XIndexAccess > xSlides( xDrawPages->getDrawPages(), 
UNO_QUERY_THROW );
+    // mpSlideController = std::make_shared<AnimationSlideController>( 
xSlides, AnimationSlideController::PREVIEW );
+    sal_Int32 nSlideNumber = 0;
+    Reference< XPropertySet > xSet( xDrawPage, UNO_QUERY_THROW );
+    xSet->getPropertyValue( "Number" ) >>= nSlideNumber;
+    mpSlideController->insertSlideNumber( nSlideNumber-1 );
+    mpSlideController->setPreviewNode( xAnimationNode );
+
+    // prepare properties
+    sal_Int32 nPropertyCount = 1;
+    if( xAnimationNode.is() )
+        nPropertyCount++;
+    Sequence< beans::PropertyValue > aProperties(nPropertyCount);
+    auto pProperties = aProperties.getArray();
+    pProperties[0].Name = "AutomaticAdvancement";
+    pProperties[0].Value <<= 1.0; // one second timeout
+
+    if( xAnimationNode.is() )
+    {
+        pProperties[1].Name = "NoSlideTransitions";
+        pProperties[1].Value <<= true;
+    }
+
+    // start preview
+    startShowImpl( aProperties );
+}
+
+void SlideshowImpl::endInteractivePreview()
+{
+    if (!mbInterActiveSetup)
+        // not in use, nothing to do
+        return;
+
+    // cleanup Show/View
+    try
+    {
+        if( mxView.is() )
+            mxShow->removeView( mxView );
+
+        Reference< XComponent > xComponent( mxShow, UNO_QUERY );
+        if( xComponent.is() )
+            xComponent->dispose();
+
+        if( mxView.is() )
+            mxView->dispose();
+    }
+    catch( Exception& )
+    {
+        TOOLS_WARN_EXCEPTION( "sd", "sd::SlideshowImpl::stop()" );
+    }
+    mxShow.clear();
+    mxView.clear();
+    mxView = mxView2;
+    mxShow = mxShow2;
+
+    // restore SlideController
+    mpSlideController->popFromPreview();
+
+    // restore other settings and cleanup temporary incarnations
+    maPresSettings = maPresSettings2;
+    meAnimationMode = meAnimationMode2;
+    mxPreviewAnimationNode = mxPreviewAnimationNode2;
+    mxPreviewAnimationNode2.clear();
+    mxPreviewDrawPage = mxPreviewDrawPage2;
+    mxPreviewDrawPage2.clear();
+
+    // go back to slide shown before preview
+    gotoSlideIndex(mnSlideIndex);
+
+    // reset IASS mode flag
+    mbInterActiveSetup = false;
+}
+
 bool SlideshowImpl::startPreview(
         const Reference< XDrawPage >& xDrawPage,
         const Reference< XAnimationNode >& xAnimationNode,
diff --git a/sd/source/ui/slideshow/slideshowimpl.hxx 
b/sd/source/ui/slideshow/slideshowimpl.hxx
index 155cdc329f03..80e44cb22f99 100644
--- a/sd/source/ui/slideshow/slideshowimpl.hxx
+++ b/sd/source/ui/slideshow/slideshowimpl.hxx
@@ -227,6 +227,14 @@ private:
         const css::uno::Reference< css::animations::XAnimationNode >& 
xAnimationNode,
         vcl::Window* pParent );
 
+    // methods for InterActiveSlideShow that support to
+    // re-use a running FullScreen presentation for previews IASS
+    void startInteractivePreview(
+        const css::uno::Reference< css::drawing::XDrawPage >& xDrawPage,
+        const css::uno::Reference< css::animations::XAnimationNode >& 
xAnimationNode);
+    void endInteractivePreview();
+    bool isInteractiveSetup() const;
+
         /** forces an async call to update in the main thread */
     void startUpdateTimer();
 
@@ -317,6 +325,7 @@ private:
     VclPtr< ::sd::Window>   mpOldActiveWindow;
     Link<StarBASIC*,bool>   maStarBASICGlobalErrorHdl;
     ::tools::ULong    mnChildMask;
+
     bool            mbDisposed;
     bool            mbAutoSaveWasOn;
     bool            mbRehearseTimings;
@@ -348,6 +357,16 @@ private:
 
     css::uno::Reference< css::presentation::XPresentation2 > mxPresentation;
     ::rtl::Reference< SlideShowListenerProxy > mxListenerProxy;
+
+    // local variables to support preview for a running SlideShow IASS
+    css::uno::Reference< css::presentation::XSlideShow > mxShow2;
+    rtl::Reference<sd::SlideShowView> mxView2;
+    AnimationMode   meAnimationMode2;
+    bool            mbInterActiveSetup;
+    PresentationSettings maPresSettings2;
+    css::uno::Reference< css::drawing::XDrawPage > mxPreviewDrawPage2;
+    css::uno::Reference< css::animations::XAnimationNode > 
mxPreviewAnimationNode2;
+    ::sal_Int32 mnSlideIndex;
 };
 
 } // namespace ::sd

Reply via email to