tdf#125949 Allow the slide to continue with freezing animation.

Entrance (Zoom in, Spiral in, Sviwel, Stretchy) animations with
shapes freezes the presentation when OpenGL is enabled. As a
workaround, avoid playing these animations.

Change-Id: I054d87c4d3774339a9fe6fba42dea20bccd31bb1
Reviewed-on: https://gerrit.libreoffice.org/85201
Tested-by: Jenkins
Reviewed-by: Gülşah Köse <gulsah.kose@collabora.com>
(cherry picked from commit 8eb2d2972583b909a249f5b0f22a9b1fbf533d24)
Reviewed-on: https://gerrit.libreoffice.org/85251
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
diff --git a/slideshow/source/engine/effectrewinder.cxx b/slideshow/source/engine/effectrewinder.cxx
index d920bdd..5db91ff 100644
--- a/slideshow/source/engine/effectrewinder.cxx
+++ b/slideshow/source/engine/effectrewinder.cxx
@@ -29,7 +29,7 @@
#include <com/sun/star/animations/Event.hpp>
#include <com/sun/star/animations/EventTrigger.hpp>
#include <com/sun/star/container/XEnumerationAccess.hpp>

#include <com/sun/star/animations/XAnimate.hpp>
using ::com::sun::star::uno::Reference;
using namespace ::com::sun::star;

@@ -291,9 +291,64 @@ bool EffectRewinder::resetEffectCount()
    return false;
}

bool EffectRewinder::hasBlockedAnimation( const css::uno::Reference<css::animations::XAnimationNode>& xNode)
{
    bool isShapeTarget = false;;
    OUString preset_id;
    OUString preset_sub_type;
    OUString preset_property;

    if (xNode->getUserData().getLength())
    {
        for(int i = 0; i < xNode->getUserData().getLength(); i++)
        {
            if(xNode->getUserData()[i].Name == "preset-id")
                xNode->getUserData()[i].Value >>= preset_id;
            if(xNode->getUserData()[i].Name == "preset-sub-type")
                xNode->getUserData()[i].Value >>= preset_sub_type;
            if(xNode->getUserData()[i].Name == "preset-property")
                xNode->getUserData()[i].Value >>= preset_property;
        }
    }

    uno::Reference<container::XEnumerationAccess> xEnumerationAccess (xNode, uno::UNO_QUERY);
    if (xEnumerationAccess.is())
    {
        uno::Reference<container::XEnumeration> xEnumeration (
            xEnumerationAccess->createEnumeration());
        if (xEnumeration.is())
            while (xEnumeration->hasMoreElements())
            {
                uno::Reference<animations::XAnimationNode> xNext (xEnumeration->nextElement(), uno::UNO_QUERY);
                uno::Reference<animations::XAnimate> xAnimate( xNext, uno::UNO_QUERY );

                if(xAnimate.is())
                {
                    uno::Reference< drawing::XShape > xShape( xAnimate->getTarget(), uno::UNO_QUERY );

                    if (xShape.is() || xAnimate->getTarget().getValueType() == cppu::UnoType<void>::get())
                        isShapeTarget=true;
                }
            }
    }

    if(isShapeTarget &&
       ((preset_id == "ooo-entrance-zoom" && preset_sub_type == "in") || // Entrance Zoom In
        (preset_id == "ooo-entrance-swivel" )                         || // Entrance Swivel
        (preset_id == "ooo-entrance-spiral-in")                       || // Entrance Spiral-In
        (preset_id == "ooo-entrance-stretchy")))                         // Entrance Stretchy
        return true;

    return false;
}

bool EffectRewinder::notifyAnimationStart (const AnimationNodeSharedPtr& rpNode)
{
    Reference<animations::XAnimationNode> xNode (rpNode->getXAnimationNode());

    if(xNode.is() && hasBlockedAnimation(xNode) )
        skipSingleMainSequenceEffects();

    // This notification is only relevant for us when the rpNode belongs to
    // the main sequence.
    BaseNodeSharedPtr pBaseNode (::std::dynamic_pointer_cast<BaseNode>(rpNode));
@@ -308,7 +363,6 @@ bool EffectRewinder::notifyAnimationStart (const AnimationNodeSharedPtr& rpNode)
    // triggered.
    bool bIsUserTriggered (false);

    Reference<animations::XAnimationNode> xNode (rpNode->getXAnimationNode());
    if (xNode.is())
    {
        animations::Event aEvent;
diff --git a/slideshow/source/engine/effectrewinder.hxx b/slideshow/source/engine/effectrewinder.hxx
index 0a88409..f71f842 100644
--- a/slideshow/source/engine/effectrewinder.hxx
+++ b/slideshow/source/engine/effectrewinder.hxx
@@ -97,6 +97,9 @@ public:
    */
    void skipAllMainSequenceEffects();

    //FIXME: That is an opengl issue(it doesn't allow to animate somea animations), remove that function when opengl fixed.
    static bool hasBlockedAnimation( const css::uno::Reference<css::animations::XAnimationNode>& xNode);

private:
    EventMultiplexer& mrEventMultiplexer;
    EventQueue& mrEventQueue;