diff --git a/include/animations/animationnodehelper.hxx b/include/animations/animationnodehelper.hxx index 820d79749b5d..c23ab25c140f 100644 --- a/include/animations/animationnodehelper.hxx +++ b/include/animations/animationnodehelper.hxx @@ -74,12 +74,11 @@ namespace anim } inline bool getVisibilityProperty( - const css::uno::Reference< css::animations::XAnimate >& xAnimateNode) + const css::uno::Reference< css::animations::XAnimate >& xAnimateNode, bool& bReturn) { - bool bVisible( false ); if( xAnimateNode->getAttributeName().equalsIgnoreAsciiCase("visibility") ) { - + bool bVisible( false ); css::uno::Any aAny( xAnimateNode->getTo() ); // try to extract bool value @@ -103,9 +102,11 @@ namespace anim } } } + bReturn = bVisible; + return true; } - return bVisible; + return false; } } diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 72fc3894dd2d..13b94ddfa435 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -3146,7 +3146,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSlideshowLayeredRendering_Animati CPPUNIT_ASSERT(rJsonMsg.indexOf(u"\"group\": \"DrawPage\"") >= 0); CPPUNIT_ASSERT(rJsonMsg.indexOf(u"\"index\": 1") >= 0); - CPPUNIT_ASSERT(rJsonMsg.indexOf(u"\"initVisible\": true") >= 0); + CPPUNIT_ASSERT(rJsonMsg.indexOf(u"\"initVisible\": false") >= 0); CPPUNIT_ASSERT(rJsonMsg.indexOf(u"\"type\": \"animated\"") >= 0); CPPUNIT_ASSERT(rJsonMsg.indexOf(u"\"type\": \"bitmap\"") >= 0); @@ -3178,7 +3178,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSlideshowLayeredRendering_Animati CPPUNIT_ASSERT(rJsonMsg.indexOf(u"\"group\": \"DrawPage\"") >= 0); CPPUNIT_ASSERT(rJsonMsg.indexOf(u"\"index\": 3") >= 0); - CPPUNIT_ASSERT(rJsonMsg.indexOf(u"\"initVisible\": true") >= 0); + CPPUNIT_ASSERT(rJsonMsg.indexOf(u"\"initVisible\": false") >= 0); CPPUNIT_ASSERT(rJsonMsg.indexOf(u"\"type\": \"animated\"") >= 0); CPPUNIT_ASSERT(rJsonMsg.indexOf(u"\"type\": \"bitmap\"") >= 0); diff --git a/sd/source/ui/inc/SlideshowLayerRenderer.hxx b/sd/source/ui/inc/SlideshowLayerRenderer.hxx index 5555ea8300e4..b6397ddc9fb8 100644 --- a/sd/source/ui/inc/SlideshowLayerRenderer.hxx +++ b/sd/source/ui/inc/SlideshowLayerRenderer.hxx @@ -9,9 +9,13 @@ #pragma once -#include -#include #include +#include +#include +#include +#include +#include + #include #include #include @@ -103,6 +107,29 @@ struct RenderState { return maInAnimation.find(pObject) != maInAnimation.end(); } + + bool isObjectInitiallyVisible(SdrObject* pObject) const + { + bool bInitiallyVisible = true; + if (maInitiallyVisible.contains(pObject)) + bInitiallyVisible = maInitiallyVisible.at(pObject); + return bInitiallyVisible; + } + + static std::string getObjectHash(SdrObject* pObject) + { + css::uno::Reference xShape = GetXShapeForSdrObject(pObject); + if (xShape.is()) + { + css::uno::Reference xRef; + css::uno::Any(xShape) >>= xRef; + if (xRef.is()) + return GetInterfaceHash(xRef); + } + + SAL_WARN("sd", "RenderState::getObjectHash: failed"); + return std::string(); + } }; /** Renders a slide */ diff --git a/sd/source/ui/tools/SlideshowLayerRenderer.cxx b/sd/source/ui/tools/SlideshowLayerRenderer.cxx index 54ad8d0a98e6..c244142f9d35 100644 --- a/sd/source/ui/tools/SlideshowLayerRenderer.cxx +++ b/sd/source/ui/tools/SlideshowLayerRenderer.cxx @@ -12,14 +12,12 @@ #include #include #include -#include #include #include #include #include #include #include -#include #include #include @@ -115,6 +113,7 @@ public: const sdr::contact::DisplayInfo& rDisplayInfo, drawinglayer::primitive2d::Primitive2DDecompositionVisitor& rVisitor) override { + // Generate single pass for background layer if (mrRenderState.meStage == RenderStage::Background) { mrRenderState.mbPassHasOutput = true; @@ -165,9 +164,11 @@ public: if (mrRenderState.isObjectInAnimation(pObject)) { + // Animated object cannot be attached to the previous object if (!mrRenderState.mbFirstObjectInPass) return; + // Animated object has to be only one in the render mrRenderState.mbSkipAllInThisPass = true; } @@ -278,14 +279,17 @@ void SlideshowLayerRenderer::setupAnimations() if (pObject) { - bool bVisible = anim::getVisibilityProperty(xAnimate); + bool bVisible; - // if initial anim sets shape visible, set it - // to invisible. If we're asked for the final - // state, don't do anything obviously - bVisible = !bVisible; + if (anim::getVisibilityProperty(xAnimate, bVisible)) + { + // if initial anim sets shape visible, set it + // to invisible. If we're asked for the final + // state, don't do anything obviously + bVisible = !bVisible; - maRenderState.maInitiallyVisible[pObject] = bVisible; + maRenderState.maInitiallyVisible[pObject] = bVisible; + } } } } @@ -337,43 +341,17 @@ void SlideshowLayerRenderer::writeJSON(OString& rJsonMsg) aJsonWriter.put("index", maRenderState.currentIndex()); aJsonWriter.put("slideHash", GetInterfaceHash(GetXDrawPageForSdrPage(&mrPage))); - bool bIsAnimation = false; SdrObject* pObject = maRenderState.currentTarget(); - com::sun::star::uno::Reference xShape; - if (pObject) - { - xShape = GetXShapeForSdrObject(pObject); - auto* pSdPage = dynamic_cast(&mrPage); - if (pSdPage) - { - std::shared_ptr pMainSequence(pSdPage->getMainSequence()); - if (pMainSequence && pMainSequence->hasEffect(xShape)) - bIsAnimation = true; - } - } - - if (bIsAnimation) + bool bIsAnimated = maRenderState.isObjectInAnimation(pObject); + if (bIsAnimated) { + assert(pObject); aJsonWriter.put("type", "animated"); { auto aContentNode = aJsonWriter.startNode("content"); - - if (xShape.is()) - { - com::sun::star::uno::Reference xRef; - com::sun::star::uno::Any(xShape) >>= xRef; - if (xRef.is()) - { - aJsonWriter.put("hash", GetInterfaceHash(xRef)); - - bool bInitiallyVisible = true; - if (maRenderState.maInitiallyVisible.contains(pObject)) - bInitiallyVisible = maRenderState.maInitiallyVisible[pObject]; - aJsonWriter.put("initVisible", bInitiallyVisible); - } - } - + aJsonWriter.put("hash", RenderState::getObjectHash(pObject)); + aJsonWriter.put("initVisible", maRenderState.isObjectInitiallyVisible(pObject)); aJsonWriter.put("type", "bitmap"); writeContentNode(aJsonWriter); } diff --git a/slideshow/source/engine/slide/targetpropertiescreator.cxx b/slideshow/source/engine/slide/targetpropertiescreator.cxx index 6ccf2374515a..ed3376cf97c8 100644 --- a/slideshow/source/engine/slide/targetpropertiescreator.cxx +++ b/slideshow/source/engine/slide/targetpropertiescreator.cxx @@ -258,7 +258,8 @@ namespace slideshow::internal // initially. This is currently the only place // where a shape effect influences shape // attributes outside it's effective duration. - bool bVisible = anim::getVisibilityProperty(xAnimateNode); + bool bVisible = false; + anim::getVisibilityProperty(xAnimateNode, bVisible); // if initial anim sets shape visible, set it // to invisible. If we're asked for the final