diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2024-09-09 23:40:05 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2024-09-10 11:09:15 +0200 |
commit | c7623db05279d95b51381538b932f43dde1c5a9b (patch) | |
tree | e04d1317595d3248d8203da1854e6a5343c8a2bf | |
parent | cc1cf3d93c841ebbaca9beb06ae11ae77f7619b6 (diff) |
slideshow: fix initVisible value
be sure we don't overwrite the real "visibility"
value when other property is read
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: Ied2285e8183665b5b48d10d74e1cc052cf8edcbe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173110
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r-- | include/animations/animationnodehelper.hxx | 9 | ||||
-rw-r--r-- | sd/qa/unit/tiledrendering/tiledrendering.cxx | 4 | ||||
-rw-r--r-- | sd/source/ui/inc/SlideshowLayerRenderer.hxx | 29 | ||||
-rw-r--r-- | sd/source/ui/tools/SlideshowLayerRenderer.cxx | 56 | ||||
-rw-r--r-- | slideshow/source/engine/slide/targetpropertiescreator.cxx | 3 |
5 files changed, 54 insertions, 47 deletions
diff --git a/include/animations/animationnodehelper.hxx b/include/animations/animationnodehelper.hxx index 9d978b76b552..5c03e2341294 100644 --- a/include/animations/animationnodehelper.hxx +++ b/include/animations/animationnodehelper.hxx @@ -75,12 +75,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 @@ -104,9 +103,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 d86220723f31..ada3b6582a65 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -3566,7 +3566,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); @@ -3598,7 +3598,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 30a8e94b262d..529eba5ed8ed 100644 --- a/sd/source/ui/inc/SlideshowLayerRenderer.hxx +++ b/sd/source/ui/inc/SlideshowLayerRenderer.hxx @@ -9,9 +9,13 @@ #pragma once +#include <rtl/string.hxx> +#include <sal/log.hxx> #include <sddllapi.h> +#include <svx/unoapi.hxx> #include <tools/gen.hxx> -#include <rtl/string.hxx> +#include <tools/helpers.hxx> + #include <deque> #include <map> #include <unordered_set> @@ -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<css::drawing::XShape> xShape = GetXShapeForSdrObject(pObject); + if (xShape.is()) + { + css::uno::Reference<css::uno::XInterface> 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 80a40c935353..90d4b9868231 100644 --- a/sd/source/ui/tools/SlideshowLayerRenderer.cxx +++ b/sd/source/ui/tools/SlideshowLayerRenderer.cxx @@ -12,14 +12,12 @@ #include <svx/svdpage.hxx> #include <svx/svdmodel.hxx> #include <svx/svdview.hxx> -#include <svx/unoapi.hxx> #include <svx/sdr/contact/viewobjectcontact.hxx> #include <svx/sdr/contact/viewcontact.hxx> #include <svx/sdr/contact/objectcontact.hxx> #include <svx/svdoutl.hxx> #include <svx/svdpagv.hxx> #include <vcl/virdev.hxx> -#include <tools/helpers.hxx> #include <tools/json_writer.hxx> #include <editeng/editeng.hxx> @@ -117,6 +115,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; @@ -167,9 +166,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; } @@ -280,14 +281,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; + } } } } @@ -339,43 +343,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<com::sun::star::drawing::XShape> xShape; - if (pObject) - { - xShape = GetXShapeForSdrObject(pObject); - - auto* pSdPage = dynamic_cast<SdPage*>(&mrPage); - if (pSdPage) - { - std::shared_ptr<sd::MainSequence> 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"); { ::tools::ScopedJsonWriterNode aContentNode = aJsonWriter.startNode("content"); - - if (xShape.is()) - { - 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("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 748480fb43e1..3702a7ce43a8 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 |