include/animations/animationnodehelper.hxx | 59 ++++++++++++++++++++++++++ sd/source/ui/inc/SlideshowLayerRenderer.hxx | 1 sd/source/ui/tools/SlideshowLayerRenderer.cxx | 10 +++- sd/source/ui/unoidl/unomodel.cxx | 59 ++------------------------ 4 files changed, 74 insertions(+), 55 deletions(-)
New commits: commit 8203f31040e8f99196872e97456674d2f4a2bf83 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Thu Sep 12 11:22:10 2024 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri Dec 6 15:19:10 2024 +0100 slideshow: use unified hash for animations and layers Change-Id: I98d048f933469a63295776f689e96ce84d0c4f49 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177969 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/include/animations/animationnodehelper.hxx b/include/animations/animationnodehelper.hxx index c23ab25c140f..8c79342c789b 100644 --- a/include/animations/animationnodehelper.hxx +++ b/include/animations/animationnodehelper.hxx @@ -19,12 +19,18 @@ #pragma once +#include <o3tl/any.hxx> +#include <rtl/strbuf.hxx> +#include <sal/log.hxx> +#include <tools/helpers.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> +#include <com/sun/star/presentation/ParagraphTarget.hpp> #include <vector> @@ -108,6 +114,59 @@ namespace anim return false; } + + inline css::uno::Reference<css::uno::XInterface> getParagraphTarget( + const css::presentation::ParagraphTarget& pTarget) + { + try + { + css::uno::Reference<css::container::XEnumerationAccess> xParaEnumAccess( + pTarget.Shape, css::uno::UNO_QUERY_THROW); + + css::uno::Reference<css::container::XEnumeration> xEnumeration( + xParaEnumAccess->createEnumeration(), + css::uno::UNO_SET_THROW); + sal_Int32 nParagraph = pTarget.Paragraph; + + while (xEnumeration->hasMoreElements()) + { + css::uno::Reference<css::uno::XInterface> xRef( + xEnumeration->nextElement(), css::uno::UNO_QUERY); + if (nParagraph-- == 0) + return xRef; + } + } + catch (const css::uno::RuntimeException&) + { + SAL_WARN("animations", "getParagraphTarget"); + } + + css::uno::Reference<css::uno::XInterface> xRef; + return xRef; + } + + inline void convertTarget(OStringBuffer& sTmp, const css::uno::Any& rTarget) + { + if (!rTarget.hasValue()) + return; + + css::uno::Reference<css::uno::XInterface> xRef; + if (!(rTarget >>= xRef)) + { + if (auto pt = o3tl::tryAccess<css::presentation::ParagraphTarget>(rTarget)) + { + xRef = getParagraphTarget(*pt); + } + } + + SAL_WARN_IF(!xRef.is(), "animations", "convertTarget(), invalid target type!"); + if (xRef.is()) + { + const std::string aIdentifier(GetInterfaceHash(xRef)); + if (!aIdentifier.empty()) + sTmp.append(aIdentifier); + } + } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/inc/SlideshowLayerRenderer.hxx b/sd/source/ui/inc/SlideshowLayerRenderer.hxx index b6397ddc9fb8..5cd590e920e7 100644 --- a/sd/source/ui/inc/SlideshowLayerRenderer.hxx +++ b/sd/source/ui/inc/SlideshowLayerRenderer.hxx @@ -48,6 +48,7 @@ struct RenderState std::unordered_set<SdrObject*> maObjectsDone; std::unordered_set<SdrObject*> maInAnimation; + std::map<SdrObject*, OString> maAnimationTargetHash; std::map<SdrObject*, bool> maInitiallyVisible; sal_Int32 mnIndex[static_cast<unsigned>(RenderStage::Count)] = { 0, 0, 0, 0 }; SdrObject* mpCurrentTarget = nullptr; diff --git a/sd/source/ui/tools/SlideshowLayerRenderer.cxx b/sd/source/ui/tools/SlideshowLayerRenderer.cxx index 96f9000e69ad..bf5e34a65a6a 100644 --- a/sd/source/ui/tools/SlideshowLayerRenderer.cxx +++ b/sd/source/ui/tools/SlideshowLayerRenderer.cxx @@ -290,6 +290,14 @@ void SlideshowLayerRenderer::setupAnimations() maRenderState.maInitiallyVisible[pObject] = bVisible; } + + if (aAny.hasValue()) + { + OStringBuffer sTmp; + anim::convertTarget(sTmp, aAny); + maRenderState.maAnimationTargetHash[pObject] + = static_cast<OString>(sTmp); + } } } } @@ -361,7 +369,7 @@ void SlideshowLayerRenderer::writeJSON(OString& rJsonMsg) aJsonWriter.put("type", "animated"); { auto aContentNode = aJsonWriter.startNode("content"); - aJsonWriter.put("hash", RenderState::getObjectHash(pObject)); + aJsonWriter.put("hash", maRenderState.maAnimationTargetHash.at(pObject)); aJsonWriter.put("initVisible", maRenderState.isObjectInitiallyVisible(pObject)); aJsonWriter.put("type", "bitmap"); writeContentNode(aJsonWriter); diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index 12953834614c..98cf5fcc3ce0 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -61,6 +61,8 @@ #include <com/sun/star/embed/Aspects.hpp> +#include <animations/animationnodehelper.hxx> + #include <officecfg/Office/Common.hxx> #include <officecfg/Office/Impress.hxx> #include <comphelper/dispatchcommand.hxx> @@ -586,8 +588,6 @@ private: void exportAnimate(const Reference<XAnimate>& xAnimate); void convertValue(XMLTokenEnum eAttributeName, OStringBuffer& sTmp, const Any& rValue) const; - static void convertTarget(OStringBuffer& sTmp, const Any& rTarget); - static Reference<XInterface> getParagraphTarget( const ParagraphTarget& pTarget ); void convertTiming(OStringBuffer& sTmp, const Any& rValue) const; private: @@ -965,55 +965,6 @@ void AnimationsExporter::exportNodeImpl(const Reference<XAnimationNode>& xNode) } } -Reference<XInterface> AnimationsExporter::getParagraphTarget(const ParagraphTarget& pTarget) -{ - try - { - Reference<XEnumerationAccess> xParaEnumAccess(pTarget.Shape, UNO_QUERY_THROW); - - Reference<XEnumeration> xEnumeration(xParaEnumAccess->createEnumeration(), - css::uno::UNO_SET_THROW); - sal_Int32 nParagraph = pTarget.Paragraph; - - while (xEnumeration->hasMoreElements()) - { - Reference<XInterface> xRef(xEnumeration->nextElement(), UNO_QUERY); - if (nParagraph-- == 0) - return xRef; - } - } - catch (const RuntimeException&) - { - TOOLS_WARN_EXCEPTION("sd", "AnimationsExporter::getParagraphTarget"); - } - - Reference<XInterface> xRef; - return xRef; -} - -void AnimationsExporter::convertTarget(OStringBuffer& sTmp, const Any& rTarget) -{ - if (!rTarget.hasValue()) - return; - - Reference<XInterface> xRef; - if (!(rTarget >>= xRef)) - { - if (auto pt = o3tl::tryAccess<ParagraphTarget>(rTarget)) - { - xRef = getParagraphTarget(*pt); - } - } - - SAL_WARN_IF(!xRef.is(), "sd", "AnimationsExporter::convertTarget(), invalid target type!"); - if (xRef.is()) - { - const std::string aIdentifier(GetInterfaceHash(xRef)); - if (!aIdentifier.empty()) - sTmp.append(aIdentifier); - } -} - void AnimationsExporter::convertTiming(OStringBuffer& sTmp, const Any& rValue) const { if (!rValue.hasValue()) @@ -1056,7 +1007,7 @@ void AnimationsExporter::convertTiming(OStringBuffer& sTmp, const Any& rValue) c { if (pEvent->Source.hasValue()) { - convertTarget(sTmp, pEvent->Source); + anim::convertTarget(sTmp, pEvent->Source); sTmp.append('.'); } @@ -1219,7 +1170,7 @@ void AnimationsExporter::exportContainer(const Reference<XTimeContainer>& xConta Any aTemp(xIter->getTarget()); if (aTemp.hasValue()) { - convertTarget(sTmp, aTemp); + anim::convertTarget(sTmp, aTemp); mrWriter.put("targetElement", sTmp.makeStringAndClear()); } sal_Int16 nTemp = xIter->getSubItem(); @@ -1273,7 +1224,7 @@ void AnimationsExporter::exportAnimate(const Reference<XAnimate>& xAnimate) Any aTemp(xAnimate->getTarget()); if (aTemp.hasValue()) { - convertTarget(sTmp, aTemp); + anim::convertTarget(sTmp, aTemp); mrWriter.put("targetElement", sTmp.makeStringAndClear()); } nTemp = xAnimate->getSubItem();