sd/source/filter/eppt/pptx-animations-nodectx.cxx |   27 ++++++++++++
 sd/source/filter/eppt/pptx-animations-nodectx.hxx |    5 ++
 sd/source/filter/eppt/pptx-animations.cxx         |   47 +++-------------------
 3 files changed, 40 insertions(+), 39 deletions(-)

New commits:
commit f640a0c5d295368e5c0e3247b3039054cccad7da
Author:     Mark Hung <mark...@gmail.com>
AuthorDate: Sat Jan 28 00:32:21 2023 +0800
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sun Jan 29 05:59:50 2023 +0000

    sd/filter/pptx-animations: store condition in NodeContext.
    
    Change-Id: I80cc7209f5347562560590554a8aa9a61e410179
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146294
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sd/source/filter/eppt/pptx-animations-nodectx.cxx 
b/sd/source/filter/eppt/pptx-animations-nodectx.cxx
index 0d5cabd49343..957301a5afd8 100644
--- a/sd/source/filter/eppt/pptx-animations-nodectx.cxx
+++ b/sd/source/filter/eppt/pptx-animations-nodectx.cxx
@@ -56,6 +56,29 @@ bool IsAudioURL(const OUString& rURL)
 
 /// Returns if rURL has an extension which is a video format.
 bool IsVideoURL(const OUString& rURL) { return 
rURL.endsWithIgnoreAsciiCase(".mp4"); }
+
+void initCondList(const Any& rAny, std::vector<Cond>& rList, bool 
bIsMainSeqChild)
+{
+    if (!rAny.hasValue())
+        return;
+
+    Sequence<Any> aCondSeq;
+    if (rAny >>= aCondSeq)
+    {
+        for (const auto& rCond : std::as_const(aCondSeq))
+        {
+            Cond aCond(rCond, bIsMainSeqChild);
+            if (aCond.isValid())
+                rList.push_back(aCond);
+        }
+    }
+    else
+    {
+        Cond aCond(rAny, bIsMainSeqChild);
+        if (aCond.isValid())
+            rList.push_back(aCond);
+    }
+}
 }
 
 NodeContext::NodeContext(const Reference<XAnimationNode>& xNode, bool 
bMainSeqChild,
@@ -71,6 +94,10 @@ NodeContext::NodeContext(const Reference<XAnimationNode>& 
xNode, bool bMainSeqCh
     initUserData();
 
     initValid(initChildNodes(), bIsIterateChild);
+
+    initCondList(getNodeForCondition()->getBegin(), maBeginCondList, 
mbMainSeqChild);
+
+    initCondList(getNodeForCondition()->getEnd(), maEndCondList, 
mbMainSeqChild);
 }
 
 void NodeContext::initUserData()
diff --git a/sd/source/filter/eppt/pptx-animations-nodectx.hxx 
b/sd/source/filter/eppt/pptx-animations-nodectx.hxx
index 46a97c5a40cc..e9f884063c2e 100644
--- a/sd/source/filter/eppt/pptx-animations-nodectx.hxx
+++ b/sd/source/filter/eppt/pptx-animations-nodectx.hxx
@@ -11,6 +11,7 @@
 #include <com/sun/star/uno/Reference.hxx>
 #include <com/sun/star/animations/XAnimationNode.hpp>
 #include <vector>
+#include "pptx-animations-cond.hxx"
 
 namespace oox::core
 {
@@ -24,6 +25,8 @@ class NodeContext
     const bool mbMainSeqChild;
 
     std::vector<NodeContextPtr> maChildNodes;
+    std::vector<Cond> maBeginCondList;
+    std::vector<Cond> maEndCondList;
     // if the node has valid target or contains at least one valid target.
     bool mbValid;
 
@@ -55,5 +58,7 @@ public:
     bool isValid() const { return mbValid; }
     const std::vector<NodeContextPtr>& getChildNodes() const { return 
maChildNodes; };
     const css::uno::Reference<css::animations::XAnimationNode>& 
getNodeForCondition() const;
+    const std::vector<Cond>& getBeginCondList() const { return 
maBeginCondList; }
+    const std::vector<Cond>& getEndCondList() const { return maEndCondList; }
 };
 }
diff --git a/sd/source/filter/eppt/pptx-animations.cxx 
b/sd/source/filter/eppt/pptx-animations.cxx
index bfe1079885e9..0cb6a5c72319 100644
--- a/sd/source/filter/eppt/pptx-animations.cxx
+++ b/sd/source/filter/eppt/pptx-animations.cxx
@@ -490,9 +490,8 @@ class PPTXAnimationExport
     void WriteAnimationNodeMedia();
     void WriteAnimationNodeCommonPropsStart();
     void WriteAnimationTarget(const Any& rTarget);
-    void WriteAnimationCondList(const Any& rAny, sal_Int32 nToken);
+    void WriteAnimationCondList(const std::vector<Cond>& rList, sal_Int32 
nToken);
     void WriteAnimationCond(const Cond& rCond);
-    bool isMainSeqChild() const;
     const Reference<XAnimationNode>& getCurrentNode() const;
 
     PowerPointExport& mrPowerPointExport;
@@ -535,12 +534,6 @@ PPTXAnimationExport::PPTXAnimationExport(PowerPointExport& 
rExport, const FSHelp
 {
 }
 
-bool PPTXAnimationExport::isMainSeqChild() const
-{
-    assert(mpContext);
-    return mpContext->isMainSeqChild();
-}
-
 const Reference<XAnimationNode>& PPTXAnimationExport::getCurrentNode() const
 {
     assert(mpContext);
@@ -589,37 +582,13 @@ void PPTXAnimationExport::WriteAnimationTarget(const Any& 
rTarget)
     mpFS->endElementNS(XML_p, XML_tgtEl);
 }
 
-void PPTXAnimationExport::WriteAnimationCondList(const Any& rAny, sal_Int32 
nToken)
+void PPTXAnimationExport::WriteAnimationCondList(const std::vector<Cond>& 
rList, sal_Int32 nToken)
 {
-    if (!rAny.hasValue())
-        return;
-
-    std::vector<Cond> aList;
-
-    bool bIsMainSeqChild = isMainSeqChild();
-
-    Sequence<Any> aCondSeq;
-    if (rAny >>= aCondSeq)
-    {
-        for (const auto& rCond : std::as_const(aCondSeq))
-        {
-            Cond aCond(rCond, bIsMainSeqChild);
-            if (aCond.isValid())
-                aList.push_back(aCond);
-        }
-    }
-    else
-    {
-        Cond aCond(rAny, bIsMainSeqChild);
-        if (aCond.isValid())
-            aList.push_back(aCond);
-    }
-
-    if (aList.size() > 0)
+    if (rList.size() > 0)
     {
         mpFS->startElementNS(XML_p, nToken);
 
-        for (const Cond& rCond : aList)
+        for (const Cond& rCond : rList)
             WriteAnimationCond(rCond);
 
         mpFS->endElementNS(XML_p, nToken);
@@ -954,8 +923,8 @@ void 
PPTXAnimationExport::WriteAnimationNodeCommonPropsStart()
         sax_fastparser::UseIf(OString::number(nPresetSubType), 
bPresetSubType), XML_repeatCount,
         sRepeatCount);
 
-    WriteAnimationCondList(mpContext->getNodeForCondition()->getBegin(), 
XML_stCondLst);
-    WriteAnimationCondList(mpContext->getNodeForCondition()->getEnd(), 
XML_endCondLst);
+    WriteAnimationCondList(mpContext->getBeginCondList(), XML_stCondLst);
+    WriteAnimationCondList(mpContext->getEndCondList(), XML_endCondLst);
 
     if (rXNode->getType() == AnimationNodeType::ITERATE)
     {
@@ -1140,8 +1109,8 @@ void PPTXAnimationExport::WriteAnimationNodeMedia()
     {
         mpFS->startElementNS(XML_p, XML_cTn);
     }
-    WriteAnimationCondList(mpContext->getNodeForCondition()->getBegin(), 
XML_stCondLst);
-    WriteAnimationCondList(mpContext->getNodeForCondition()->getEnd(), 
XML_endCondLst);
+    WriteAnimationCondList(mpContext->getBeginCondList(), XML_stCondLst);
+    WriteAnimationCondList(mpContext->getEndCondList(), XML_endCondLst);
     mpFS->endElementNS(XML_p, XML_cTn);
 
     mpFS->startElementNS(XML_p, XML_tgtEl);

Reply via email to