include/animations/animationnodehelper.hxx | 37 ++++++++++++++ sd/qa/unit/tiledrendering/tiledrendering.cxx | 3 + sd/source/ui/inc/SlideshowLayerRenderer.hxx | 2 sd/source/ui/tools/SlideshowLayerRenderer.cxx | 33 ++++++++++-- slideshow/source/engine/slide/targetpropertiescreator.cxx | 30 ----------- 5 files changed, 72 insertions(+), 33 deletions(-)
New commits: commit 7db8e37adcf5a5a48164077b487086a4580dc8f7 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Sun Sep 8 20:56:06 2024 +0200 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Mon Sep 9 15:22:57 2024 +0200 slideshow: extract initial visibility of the animation target Signed-off-by: Szymon Kłos <szymon.k...@collabora.com> Change-Id: I35ea503d254f36c8ab7307b157c87d5c2e0a8e1d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173050 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Marco Cecchetti <marco.cecche...@collabora.com> diff --git a/include/animations/animationnodehelper.hxx b/include/animations/animationnodehelper.hxx index eee41cd282be..9d978b76b552 100644 --- a/include/animations/animationnodehelper.hxx +++ b/include/animations/animationnodehelper.hxx @@ -20,7 +20,9 @@ #ifndef INCLUDED_ANIMATIONS_ANIMATIONNODEHELPER_HXX #define INCLUDED_ANIMATIONS_ANIMATIONNODEHELPER_HXX +#include <com/sun/star/uno/Any.hxx> #include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/animations/XAnimate.hpp> #include <com/sun/star/animations/XAnimationNode.hpp> #include <com/sun/star/container/XEnumerationAccess.hpp> #include <com/sun/star/container/XEnumeration.hpp> @@ -71,6 +73,41 @@ namespace anim { } } + + inline bool getVisibilityProperty( + const css::uno::Reference< css::animations::XAnimate >& xAnimateNode) + { + bool bVisible( false ); + if( xAnimateNode->getAttributeName().equalsIgnoreAsciiCase("visibility") ) + { + + css::uno::Any aAny( xAnimateNode->getTo() ); + + // try to extract bool value + if( !(aAny >>= bVisible) ) + { + // try to extract string + OUString aString; + if( aAny >>= aString ) + { + // we also take the strings "true" and "false", + // as well as "on" and "off" here + if( aString.equalsIgnoreAsciiCase("true") || + aString.equalsIgnoreAsciiCase("on") ) + { + bVisible = true; + } + if( aString.equalsIgnoreAsciiCase("false") || + aString.equalsIgnoreAsciiCase("off") ) + { + bVisible = false; + } + } + } + } + + return bVisible; + } } #endif /* INCLUDED_ANIMATIONS_ANIMATIONNODEHELPER_HXX */ diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 5d88600d076e..e2670232b9cc 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -3380,6 +3380,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSlideshowLayeredRendering_Animati CPPUNIT_ASSERT(rJsonMsg.indexOf(u"\"group\": \"MasterPage\"") >= 0); CPPUNIT_ASSERT(rJsonMsg.indexOf(u"\"index\": 0") >= 0); CPPUNIT_ASSERT_EQUAL(-1, rJsonMsg.indexOf(u"\"hash\"")); + CPPUNIT_ASSERT_EQUAL(-1, rJsonMsg.indexOf(u"\"initVisible\"")); CPPUNIT_ASSERT(rJsonMsg.indexOf(u"\"type\": \"bitmap\"") >= 0); CPPUNIT_ASSERT(rJsonMsg.indexOf(u"\"content\": { \"type\": \"%IMAGETYPE%\", \"checksum\": \"%IMAGECHECKSUM%\"}") >= 0); @@ -3396,6 +3397,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSlideshowLayeredRendering_Animati CPPUNIT_ASSERT(rJsonMsg.indexOf(u"\"group\": \"MasterPage\"") >= 0); CPPUNIT_ASSERT(rJsonMsg.indexOf(u"\"index\": 1") >= 0); CPPUNIT_ASSERT(rJsonMsg.indexOf(u"\"hash\"") >= 0); + CPPUNIT_ASSERT(rJsonMsg.indexOf(u"\"initVisible\": true") >= 0); CPPUNIT_ASSERT(rJsonMsg.indexOf(u"\"type\": \"animated\"") >= 0); CPPUNIT_ASSERT(rJsonMsg.indexOf(u"\"content\": { \"type\": \"%IMAGETYPE%\", \"checksum\": \"%IMAGECHECKSUM%\"}") >= 0); @@ -3428,6 +3430,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"\"hash\"") >= 0); + CPPUNIT_ASSERT(rJsonMsg.indexOf(u"\"initVisible\": false") >= 0); CPPUNIT_ASSERT(rJsonMsg.indexOf(u"\"type\": \"animated\"") >= 0); CPPUNIT_ASSERT(rJsonMsg.indexOf(u"\"content\": { \"type\": \"%IMAGETYPE%\", \"checksum\": \"%IMAGECHECKSUM%\"}") >= 0); diff --git a/sd/source/ui/inc/SlideshowLayerRenderer.hxx b/sd/source/ui/inc/SlideshowLayerRenderer.hxx index 3ccaf886258f..0ee0e3f1e147 100644 --- a/sd/source/ui/inc/SlideshowLayerRenderer.hxx +++ b/sd/source/ui/inc/SlideshowLayerRenderer.hxx @@ -13,6 +13,7 @@ #include <tools/gen.hxx> #include <rtl/string.hxx> #include <deque> +#include <map> #include <unordered_set> class SdrPage; @@ -41,6 +42,7 @@ struct RenderState std::unordered_set<SdrObject*> maObjectsDone; std::unordered_set<SdrObject*> maInAnimation; + std::map<SdrObject*, bool> maInitiallyVisible; sal_Int32 mnIndex = 0; SdrObject* mpCurrentTarget = nullptr; diff --git a/sd/source/ui/tools/SlideshowLayerRenderer.cxx b/sd/source/ui/tools/SlideshowLayerRenderer.cxx index 138e40933cb9..3c6a175ff9c1 100644 --- a/sd/source/ui/tools/SlideshowLayerRenderer.cxx +++ b/sd/source/ui/tools/SlideshowLayerRenderer.cxx @@ -242,12 +242,16 @@ void SlideshowLayerRenderer::setupAnimations() uno::Any aAny = xAnimate->getTarget(); uno::Reference<drawing::XShape> xShape; + SvxShape* pShape = nullptr; + SdrObject* pObject = nullptr; + if ((aAny >>= xShape) && xShape.is()) { - SvxShape* pShape = comphelper::getFromUnoTunnel<SvxShape>(xShape); + pShape = comphelper::getFromUnoTunnel<SvxShape>(xShape); if (pShape) { - maRenderState.maInAnimation.insert(pShape->GetSdrObject()); + pObject = pShape->GetSdrObject(); + maRenderState.maInAnimation.insert(pObject); } } else // if target is not a shape @@ -259,13 +263,26 @@ void SlideshowLayerRenderer::setupAnimations() xShape = aParagraphTarget.Shape; - SvxShape* pShape = comphelper::getFromUnoTunnel<SvxShape>(xShape); + pShape = comphelper::getFromUnoTunnel<SvxShape>(xShape); if (pShape) { - maRenderState.maInAnimation.insert(pShape->GetSdrObject()); + pObject = pShape->GetSdrObject(); + maRenderState.maInAnimation.insert(pObject); } } } + + if (pObject) + { + bool bVisible = anim::getVisibilityProperty(xAnimate); + + // 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; + } } } } @@ -343,10 +360,16 @@ void SlideshowLayerRenderer::writeJSON(OString& rJsonMsg) com::sun::star::uno::Reference<com::sun::star::uno::XInterface> 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("initVisible", true); // TODO aJsonWriter.put("type", "bitmap"); writeContentNode(aJsonWriter); } diff --git a/slideshow/source/engine/slide/targetpropertiescreator.cxx b/slideshow/source/engine/slide/targetpropertiescreator.cxx index 80f41cc4c795..748480fb43e1 100644 --- a/slideshow/source/engine/slide/targetpropertiescreator.cxx +++ b/slideshow/source/engine/slide/targetpropertiescreator.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <animations/animationnodehelper.hxx> #include <com/sun/star/animations/XIterateContainer.hpp> #include <com/sun/star/presentation/ParagraphTarget.hpp> #include <com/sun/star/drawing/XShape.hpp> @@ -257,34 +258,7 @@ namespace slideshow::internal // initially. This is currently the only place // where a shape effect influences shape // attributes outside it's effective duration. - bool bVisible( false ); - if( xAnimateNode->getAttributeName().equalsIgnoreAsciiCase("visibility") ) - { - - uno::Any aAny( xAnimateNode->getTo() ); - - // try to extract bool value - if( !(aAny >>= bVisible) ) - { - // try to extract string - OUString aString; - if( aAny >>= aString ) - { - // we also take the strings "true" and "false", - // as well as "on" and "off" here - if( aString.equalsIgnoreAsciiCase("true") || - aString.equalsIgnoreAsciiCase("on") ) - { - bVisible = true; - } - if( aString.equalsIgnoreAsciiCase("false") || - aString.equalsIgnoreAsciiCase("off") ) - { - bVisible = false; - } - } - } - } + bool bVisible = anim::getVisibilityProperty(xAnimateNode); // if initial anim sets shape visible, set it // to invisible. If we're asked for the final