summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Hung <marklh9@gmail.com>2018-08-29 00:18:23 +0800
committerMark Hung <marklh9@gmail.com>2018-08-31 02:38:20 +0200
commit8fbf75895e92f179ecc8a90b90d076552a279285 (patch)
treedbc15594cb9888c9250481c63eebf0454030c70b
parent9216d1d7a699618e91c739b7c0b66395539681d8 (diff)
sd/pptx export: refactor WriteAnimationNode.
to get rid of function pointers. Change-Id: Iaea4782274c655484559118183397a3340d1d7cb Reviewed-on: https://gerrit.libreoffice.org/59734 Tested-by: Jenkins Reviewed-by: Mark Hung <marklh9@gmail.com>
-rw-r--r--sd/source/filter/eppt/pptx-animations.cxx101
1 files changed, 57 insertions, 44 deletions
diff --git a/sd/source/filter/eppt/pptx-animations.cxx b/sd/source/filter/eppt/pptx-animations.cxx
index 5e2854fadfb7..d9c98db90415 100644
--- a/sd/source/filter/eppt/pptx-animations.cxx
+++ b/sd/source/filter/eppt/pptx-animations.cxx
@@ -405,6 +405,48 @@ void WriteAnimationAttributeName(const FSHelperPtr& pFS, const OUString& rAttrib
pFS->endElementNS(XML_p, XML_attrNameLst);
}
+
+/// convert animation node type to corresponding ooxml element.
+sal_Int32 convertNodeType(sal_Int16 nType)
+{
+ sal_Int32 xmlNodeType = -1;
+ switch (nType)
+ {
+ case AnimationNodeType::ITERATE:
+ case AnimationNodeType::PAR:
+ xmlNodeType = XML_par;
+ break;
+ case AnimationNodeType::SEQ:
+ xmlNodeType = XML_seq;
+ break;
+ case AnimationNodeType::ANIMATE:
+ xmlNodeType = XML_anim;
+ break;
+ case AnimationNodeType::ANIMATEMOTION:
+ xmlNodeType = XML_animMotion;
+ break;
+ case AnimationNodeType::ANIMATETRANSFORM:
+ // could be XML_animScale or XML_animRot based on xTransform->getTransformType()
+ xmlNodeType = -1;
+ break;
+ case AnimationNodeType::ANIMATECOLOR:
+ xmlNodeType = XML_animClr;
+ break;
+ case AnimationNodeType::SET:
+ xmlNodeType = XML_set;
+ break;
+ case AnimationNodeType::TRANSITIONFILTER:
+ xmlNodeType = XML_animEffect;
+ break;
+ case AnimationNodeType::COMMAND:
+ xmlNodeType = XML_cmd;
+ break;
+ default:
+ SAL_WARN("sd.eppt", "unhandled animation node: " << nType);
+ break;
+ }
+ return xmlNodeType;
+}
}
void PowerPointExport::WriteAnimationTarget(const FSHelperPtr& pFS, const Any& rTarget)
@@ -965,27 +1007,18 @@ void PowerPointExport::WriteAnimationNode(const FSHelperPtr& pFS,
bool bMainSeqChild)
{
SAL_INFO("sd.eppt", "export node type: " << rXNode->getType());
- sal_Int32 xmlNodeType = -1;
- typedef void (PowerPointExport::*AnimationNodeWriteMethod)(
- const FSHelperPtr&, const Reference<XAnimationNode>&, sal_Int32, bool);
- AnimationNodeWriteMethod pMethod = nullptr;
+ sal_Int32 xmlNodeType = convertNodeType(rXNode->getType());
switch (rXNode->getType())
{
case AnimationNodeType::ITERATE:
case AnimationNodeType::PAR:
- xmlNodeType = XML_par;
+ pFS->startElementNS(XML_p, xmlNodeType, FSEND);
+ WriteAnimationNodeCommonPropsStart(pFS, rXNode, true, bMainSeqChild);
+ pFS->endElementNS(XML_p, xmlNodeType);
break;
case AnimationNodeType::SEQ:
- pMethod = &PowerPointExport::WriteAnimationNodeSeq;
- break;
- case AnimationNodeType::ANIMATE:
- xmlNodeType = XML_anim;
- pMethod = &PowerPointExport::WriteAnimationNodeAnimate;
- break;
- case AnimationNodeType::ANIMATEMOTION:
- xmlNodeType = XML_animMotion;
- pMethod = &PowerPointExport::WriteAnimationNodeAnimate;
+ WriteAnimationNodeSeq(pFS, rXNode, xmlNodeType, bMainSeqChild);
break;
case AnimationNodeType::ANIMATETRANSFORM:
{
@@ -993,53 +1026,33 @@ void PowerPointExport::WriteAnimationNode(const FSHelperPtr& pFS,
if (xTransform.is())
{
if (xTransform->getTransformType() == AnimationTransformType::SCALE)
- {
xmlNodeType = XML_animScale;
- pMethod = &PowerPointExport::WriteAnimationNodeAnimate;
- }
else if (xTransform->getTransformType() == AnimationTransformType::ROTATE)
- {
xmlNodeType = XML_animRot;
- pMethod = &PowerPointExport::WriteAnimationNodeAnimate;
- }
+
+ WriteAnimationNodeAnimate(pFS, rXNode, xmlNodeType, bMainSeqChild);
}
+ else
+ SAL_WARN("sd.eppt",
+ "XAnimateTransform not handled: " << xTransform->getTransformType());
}
break;
+ case AnimationNodeType::ANIMATE:
+ case AnimationNodeType::ANIMATEMOTION:
case AnimationNodeType::ANIMATECOLOR:
- xmlNodeType = XML_animClr;
- pMethod = &PowerPointExport::WriteAnimationNodeAnimate;
- break;
case AnimationNodeType::SET:
- xmlNodeType = XML_set;
- pMethod = &PowerPointExport::WriteAnimationNodeAnimate;
+ WriteAnimationNodeAnimate(pFS, rXNode, xmlNodeType, bMainSeqChild);
break;
case AnimationNodeType::TRANSITIONFILTER:
- xmlNodeType = XML_animEffect;
- pMethod = &PowerPointExport::WriteAnimationNodeEffect;
+ WriteAnimationNodeEffect(pFS, rXNode, xmlNodeType, bMainSeqChild);
break;
case AnimationNodeType::COMMAND:
- xmlNodeType = XML_cmd;
- pMethod = &PowerPointExport::WriteAnimationNodeCommand;
+ WriteAnimationNodeCommand(pFS, rXNode, xmlNodeType, bMainSeqChild);
break;
default:
SAL_WARN("sd.eppt", "unhandled animation node: " << rXNode->getType());
break;
}
-
- if (pMethod)
- {
- (this->*pMethod)(pFS, rXNode, xmlNodeType, bMainSeqChild);
- return;
- }
-
- if (xmlNodeType == -1)
- return;
-
- pFS->startElementNS(XML_p, xmlNodeType, FSEND);
-
- WriteAnimationNodeCommonPropsStart(pFS, rXNode, true, bMainSeqChild);
-
- pFS->endElementNS(XML_p, xmlNodeType);
}
void PowerPointExport::WriteAnimations(const FSHelperPtr& pFS)