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 <vmiklos@collabora.com>
This commit is contained in:
parent
cd983f0af4
commit
8203f31040
4 changed files with 74 additions and 55 deletions
|
@ -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: */
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue