From e64ebbb7ac530f82bf26a67fed0e1d22b254ff93 Mon Sep 17 00:00:00 2001 From: Jan Holesovsky Date: Fri, 1 Sep 2017 18:22:43 +0200 Subject: tdf#106867: Implement pptx export of AnimationNodeType::COMMAND. This is still not enough to make PowerPoint happy with the test file. Change-Id: Icadcb640b44100ffb3482de57723576e4d843e7a Reviewed-on: https://gerrit.libreoffice.org/41977 Tested-by: Jenkins Reviewed-by: Jan Holesovsky --- sd/source/filter/eppt/epptooxml.hxx | 1 + sd/source/filter/eppt/pptx-epptooxml.cxx | 54 ++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/sd/source/filter/eppt/epptooxml.hxx b/sd/source/filter/eppt/epptooxml.hxx index 41f7b393bf53..2780767230d6 100644 --- a/sd/source/filter/eppt/epptooxml.hxx +++ b/sd/source/filter/eppt/epptooxml.hxx @@ -108,6 +108,7 @@ protected: void WriteAnimationNodeAnimateInside( const ::sax_fastparser::FSHelperPtr& pFS, const css::uno::Reference< css::animations::XAnimationNode >& rXNode, bool bMainSeqChild, bool bSimple ); void WriteAnimationNodeSeq( const ::sax_fastparser::FSHelperPtr& pFS, const css::uno::Reference< css::animations::XAnimationNode >& rXNode, sal_Int32 nXmlNodeType, bool bMainSeqChild ); void WriteAnimationNodeEffect( const ::sax_fastparser::FSHelperPtr& pFS, const css::uno::Reference< css::animations::XAnimationNode >& rXNode, sal_Int32 nXmlNodeType, bool bMainSeqChild ); + void WriteAnimationNodeCommand(const ::sax_fastparser::FSHelperPtr& pFS, const css::uno::Reference< css::animations::XAnimationNode >& rXNode, sal_Int32 nXmlNodeType, bool bMainSeqChild ); void WriteAnimationNodeCommonPropsStart( const ::sax_fastparser::FSHelperPtr& pFS, const css::uno::Reference< css::animations::XAnimationNode >& rXNode, bool bSingle, bool bMainSeqChild ); static void WriteAnimationProperty( const ::sax_fastparser::FSHelperPtr& pFS, const css::uno::Any& rAny ); void WriteAnimationTarget( const ::sax_fastparser::FSHelperPtr& pFS, const css::uno::Any& rTarget ); diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx b/sd/source/filter/eppt/pptx-epptooxml.cxx index e8c3e851b413..28c1d2870ed4 100644 --- a/sd/source/filter/eppt/pptx-epptooxml.cxx +++ b/sd/source/filter/eppt/pptx-epptooxml.cxx @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -64,6 +65,7 @@ #include #include #include +#include #include #include #include @@ -1104,6 +1106,7 @@ void PowerPointExport::WriteAnimationCondition(const FSHelperPtr& pFS, Any const double fDelay = 0; Timing eTiming; Event aEvent; + Reference xShape; const char* pDelay = nullptr; const char* pEvent = nullptr; @@ -1175,6 +1178,15 @@ void PowerPointExport::WriteAnimationCondition(const FSHelperPtr& pFS, Any const SAL_INFO("sd.eppt", "event offset timing: " << (int)eTiming); } } + else if (rAny >>= xShape) + { + SAL_INFO("sd.eppt", "Got the xShape: " << xShape->getShapeType()); + if (xShape->getShapeType() == "com.sun.star.drawing.MediaShape" || xShape->getShapeType() == "com.sun.star.presentation.MediaShape") + { + // write the default + bHasFDelay = true; + } + } WriteAnimationCondition(pFS, pDelay, pEvent, fDelay, bHasFDelay); } @@ -1433,6 +1445,41 @@ void PowerPointExport::WriteAnimationNodeEffect(const FSHelperPtr& pFS, const Re } } +void PowerPointExport::WriteAnimationNodeCommand(const FSHelperPtr& pFS, const Reference< XAnimationNode >& rXNode, sal_Int32, bool bMainSeqChild) +{ + SAL_INFO("sd.eppt", "write animation node COMMAND"); + Reference xCommand(rXNode, UNO_QUERY); + if (xCommand.is()) + { + const char* pType = "call"; + const char* pCommand = nullptr; + switch (xCommand->getCommand()) + { + case EffectCommands::VERB: pType = "verb"; pCommand = "1"; /* FIXME hardcoded viewing */ break; + case EffectCommands::PLAY: pCommand = "play"; break; + case EffectCommands::TOGGLEPAUSE: pCommand = "togglePause"; break; + case EffectCommands::STOP: pCommand = "stop"; break; + default: + SAL_WARN("sd.eppt", "unknown command: " << xCommand->getCommand()); + break; + } + + pFS->startElementNS(XML_p, XML_cmd, + XML_type, pType, + XML_cmd, pCommand, + FSEND); + + WriteAnimationNodeAnimateInside(pFS, rXNode, bMainSeqChild, false); + pFS->startElementNS(XML_p, XML_cBhvr, + FSEND); + WriteAnimationNodeCommonPropsStart(pFS, rXNode, true, bMainSeqChild); + WriteAnimationTarget(pFS, xCommand->getTarget()); + pFS->endElementNS(XML_p, XML_cBhvr); + + pFS->endElementNS(XML_p, XML_cmd); + } +} + void PowerPointExport::WriteAnimationNode(const FSHelperPtr& pFS, const Reference< XAnimationNode >& rXNode, bool bMainSeqChild) { SAL_INFO("sd.eppt", "export node type: " << rXNode->getType()); @@ -1464,6 +1511,13 @@ void PowerPointExport::WriteAnimationNode(const FSHelperPtr& pFS, const Referenc xmlNodeType = XML_animEffect; pMethod = &PowerPointExport::WriteAnimationNodeEffect; break; + case AnimationNodeType::COMMAND: + xmlNodeType = XML_cmd; + pMethod = &PowerPointExport::WriteAnimationNodeCommand; + break; + default: + SAL_WARN("sd.eppt", "unhandled: " << rXNode->getType()); + break; } if (pMethod) -- cgit v1.2.3