sd/qa/unit/tiledrendering/tiledrendering.cxx | 32 +++++++++++++-- sd/source/ui/inc/SlideshowLayerRenderer.hxx | 17 +++++--- sd/source/ui/tools/SlideshowLayerRenderer.cxx | 54 ++++++++++++++++++++++++-- 3 files changed, 89 insertions(+), 14 deletions(-)
New commits: commit 72c88c2286400ec025d26925aa93f258d9655196 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Wed Sep 4 21:38:29 2024 +0200 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Fri Sep 6 16:40:49 2024 +0200 Identify layers so can be recognized as animation target it has to match convertTarget result from unomodel.cxx which is used on export of animations Change-Id: I61df0b82681628722516c17c110acd90ce25b881 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172875 Reviewed-by: Marco Cecchetti <marco.cecche...@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index fd654594c2b2..5d88600d076e 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -3376,7 +3376,13 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSlideshowLayeredRendering_Animati OUString rJsonMsg; CPPUNIT_ASSERT(!pXImpressDocument->renderNextSlideLayer(pBuffer.data(), bIsBitmapLayer, rJsonMsg)); CPPUNIT_ASSERT(bIsBitmapLayer); - // TODO - check JSON content + + 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(rJsonMsg.indexOf(u"\"type\": \"bitmap\"") >= 0); + CPPUNIT_ASSERT(rJsonMsg.indexOf(u"\"content\": { \"type\": \"%IMAGETYPE%\", \"checksum\": \"%IMAGECHECKSUM%\"}") >= 0); + debugWriteImageToFile(1, pBuffer, nViewWidth, nViewHeight, rJsonMsg.toUtf8().getStr()); } @@ -3386,7 +3392,13 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSlideshowLayeredRendering_Animati OUString rJsonMsg; CPPUNIT_ASSERT(!pXImpressDocument->renderNextSlideLayer(pBuffer.data(), bIsBitmapLayer, rJsonMsg)); CPPUNIT_ASSERT(bIsBitmapLayer); - // TODO - check JSON content + + 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"\"type\": \"animated\"") >= 0); + CPPUNIT_ASSERT(rJsonMsg.indexOf(u"\"content\": { \"type\": \"%IMAGETYPE%\", \"checksum\": \"%IMAGECHECKSUM%\"}") >= 0); + debugWriteImageToFile(2, pBuffer, nViewWidth, nViewHeight, rJsonMsg.toUtf8().getStr()); } @@ -3396,7 +3408,13 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSlideshowLayeredRendering_Animati OUString rJsonMsg; CPPUNIT_ASSERT(!pXImpressDocument->renderNextSlideLayer(pBuffer.data(), bIsBitmapLayer, rJsonMsg)); CPPUNIT_ASSERT(bIsBitmapLayer); - // TODO - check JSON content + + CPPUNIT_ASSERT(rJsonMsg.indexOf(u"\"group\": \"DrawPage\"") >= 0); + CPPUNIT_ASSERT(rJsonMsg.indexOf(u"\"index\": 0") >= 0); + CPPUNIT_ASSERT(rJsonMsg.indexOf(u"\"hash\"") >= 0); + CPPUNIT_ASSERT(rJsonMsg.indexOf(u"\"type\": \"animated\"") >= 0); + CPPUNIT_ASSERT(rJsonMsg.indexOf(u"\"content\": { \"type\": \"%IMAGETYPE%\", \"checksum\": \"%IMAGECHECKSUM%\"}") >= 0); + debugWriteImageToFile(3, pBuffer, nViewWidth, nViewHeight, rJsonMsg.toUtf8().getStr()); } @@ -3406,7 +3424,13 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSlideshowLayeredRendering_Animati OUString rJsonMsg; CPPUNIT_ASSERT(!pXImpressDocument->renderNextSlideLayer(pBuffer.data(), bIsBitmapLayer, rJsonMsg)); CPPUNIT_ASSERT(bIsBitmapLayer); - // TODO - check JSON content + + 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"\"type\": \"animated\"") >= 0); + CPPUNIT_ASSERT(rJsonMsg.indexOf(u"\"content\": { \"type\": \"%IMAGETYPE%\", \"checksum\": \"%IMAGECHECKSUM%\"}") >= 0); + debugWriteImageToFile(4, pBuffer, nViewWidth, nViewHeight, rJsonMsg.toUtf8().getStr()); } diff --git a/sd/source/ui/inc/SlideshowLayerRenderer.hxx b/sd/source/ui/inc/SlideshowLayerRenderer.hxx index d0b49398ce5b..3ccaf886258f 100644 --- a/sd/source/ui/inc/SlideshowLayerRenderer.hxx +++ b/sd/source/ui/inc/SlideshowLayerRenderer.hxx @@ -42,6 +42,7 @@ struct RenderState std::unordered_set<SdrObject*> maObjectsDone; std::unordered_set<SdrObject*> maInAnimation; sal_Int32 mnIndex = 0; + SdrObject* mpCurrentTarget = nullptr; bool mbFirstObjectInPass = true; bool mbPassHasOutput = false; @@ -59,7 +60,7 @@ struct RenderState } /// returns the current stage as string - OString stageString() + OString stageString() const { if (meStage == RenderStage::Master) return "MasterPage"_ostr; @@ -67,41 +68,45 @@ struct RenderState } /// returns the current index depending on the current render stage - sal_Int32 currentIndex() + sal_Int32 currentIndex() const { if (meStage == RenderStage::Master) return mnMasterIndex; return mnIndex; } + /// returns the current target element for which layer is created if any + SdrObject* currentTarget() const { return mpCurrentTarget; } + /// resets properties that are valid for one pass void resetPass() { mbFirstObjectInPass = true; mbPassHasOutput = false; mbSkipAllInThisPass = false; + mpCurrentTarget = nullptr; } /// return if there was no rendering output in the pass - bool noMoreOutput() + bool noMoreOutput() const { // no output and we don't skip anything return !mbPassHasOutput && !mbSkipAllInThisPass; } /// should include background in rendering - bool includeBackground() + bool includeBackground() const { // include background only if we are rendering the first pass return mnCurrentPass == 0; } - bool isObjectAlreadyRendered(SdrObject* pObject) + bool isObjectAlreadyRendered(SdrObject* pObject) const { return maObjectsDone.find(pObject) != maObjectsDone.end(); } - bool isObjectInAnimation(SdrObject* pObject) + bool isObjectInAnimation(SdrObject* pObject) const { return maInAnimation.find(pObject) != maInAnimation.end(); } diff --git a/sd/source/ui/tools/SlideshowLayerRenderer.cxx b/sd/source/ui/tools/SlideshowLayerRenderer.cxx index 32a8a5d7dea9..138e40933cb9 100644 --- a/sd/source/ui/tools/SlideshowLayerRenderer.cxx +++ b/sd/source/ui/tools/SlideshowLayerRenderer.cxx @@ -8,6 +8,7 @@ */ #include <SlideshowLayerRenderer.hxx> +#include <CustomAnimationEffect.hxx> #include <svx/svdpage.hxx> #include <svx/svdmodel.hxx> #include <svx/svdview.hxx> @@ -25,6 +26,7 @@ #include <com/sun/star/animations/XAnimate.hpp> #include <com/sun/star/animations/XAnimationNode.hpp> #include <com/sun/star/animations/AnimationNodeType.hpp> +#include <com/sun/star/drawing/XShape.hpp> #include <com/sun/star/presentation/ParagraphTarget.hpp> #include <animations/animationnodehelper.hxx> @@ -128,6 +130,8 @@ public: if (pPage == nullptr) return; + mrRenderState.mpCurrentTarget = pObject; + // is the object visible and not hidden by any option const bool bVisible = pObject->getSdrPageFromSdrObject()->checkVisibility(rOriginal, rDisplayInfo, true); @@ -298,6 +302,13 @@ void SlideshowLayerRenderer::createViewAndDraw(RenderContext& rRenderContext) aView.CompleteRedraw(rRenderContext.maVirtualDevice, aRegion, &aRedirector); } +static void writeContentNode(::tools::JsonWriter& aJsonWriter) +{ + ::tools::ScopedJsonWriterNode aContentNode = aJsonWriter.startNode("content"); + aJsonWriter.put("type", "%IMAGETYPE%"); + aJsonWriter.put("checksum", "%IMAGECHECKSUM%"); +} + void SlideshowLayerRenderer::writeJSON(OString& rJsonMsg) { ::tools::JsonWriter aJsonWriter; @@ -305,12 +316,47 @@ void SlideshowLayerRenderer::writeJSON(OString& rJsonMsg) aJsonWriter.put("index", maRenderState.currentIndex()); aJsonWriter.put("slideHash", GetInterfaceHash(GetXDrawPageForSdrPage(&mrPage))); - aJsonWriter.put("type", "bitmap"); + 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) { - ::tools::ScopedJsonWriterNode aContentNode = aJsonWriter.startNode("content"); - aJsonWriter.put("type", "%IMAGETYPE%"); - aJsonWriter.put("checksum", "%IMAGECHECKSUM%"); + 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)); + } + + aJsonWriter.put("initVisible", true); // TODO + aJsonWriter.put("type", "bitmap"); + writeContentNode(aJsonWriter); + } } + else + { + aJsonWriter.put("type", "bitmap"); + writeContentNode(aJsonWriter); + } + rJsonMsg = aJsonWriter.finishAndGetAsOString(); maRenderState.incrementIndex();