11#include <com/sun/star/animations/AnimationNodeType.hpp>
12#include <com/sun/star/animations/XAnimate.hpp>
13#include <com/sun/star/animations/XAnimationNode.hpp>
14#include <com/sun/star/animations/XCommand.hpp>
15#include <com/sun/star/animations/XAudio.hpp>
16#include <com/sun/star/animations/XIterateContainer.hpp>
17#include <com/sun/star/drawing/XShape.hpp>
18#include <com/sun/star/container/XEnumerationAccess.hpp>
19#include <com/sun/star/container/XEnumeration.hpp>
20#include <com/sun/star/presentation/EffectNodeType.hpp>
21#include <com/sun/star/presentation/EffectPresetClass.hpp>
22#include <com/sun/star/presentation/ParagraphTarget.hpp>
23#include <com/sun/star/beans/XPropertySet.hpp>
28using ::com::sun::star::beans::NamedValue;
29using ::com::sun::star::beans::XPropertySet;
30using ::com::sun::star::drawing::XShape;
42bool isValidTarget(
const Any& rTarget)
44 Reference<XShape> xShape;
46 if ((rTarget >>= xShape) && xShape.is())
49 ParagraphTarget aParagraphTarget;
51 return (rTarget >>= aParagraphTarget) && aParagraphTarget.Shape.is();
54bool IsAudioURL(std::u16string_view rURL)
63bool initCondList(
const Any& rAny, std::vector<Cond>& rList,
bool bIsMainSeqChild)
65 bool bEventTrigger =
false;
69 Sequence<Any> aCondSeq;
70 if (rAny >>= aCondSeq)
72 for (
const auto& rCond : std::as_const(aCondSeq))
74 Cond aCond(rCond, bIsMainSeqChild);
77 rList.push_back(aCond);
85 Cond aCond(rAny, bIsMainSeqChild);
88 rList.push_back(aCond);
101 , mbOnSubTnLst(false)
102 , mnEffectNodeType(-1)
103 , mnEffectPresetClass(css::presentation::EffectPresetClass::
CUSTOM)
109 initValid(initChildNodes(), bIsIterateChild);
113 mbOnSubTnLst = initCondList(getNodeForCondition()->getBegin(), maBeginCondList, bMainSeqChild)
114 && mxNode->getType() == AnimationNodeType::AUDIO;
116 initCondList(getNodeForCondition()->getEnd(), maEndCondList, bMainSeqChild);
119void NodeContext::initUserData()
123 Sequence<NamedValue> aUserData = mxNode->getUserData();
124 for (
const NamedValue& rProp : aUserData)
126 if (rProp.Name ==
"node-type")
128 rProp.Value >>= mnEffectNodeType;
130 else if (rProp.Name ==
"preset-class")
132 rProp.Value >>= mnEffectPresetClass;
134 else if (rProp.Name ==
"preset-id")
136 rProp.Value >>= msEffectPresetId;
138 else if (rProp.Name ==
"preset-sub-type")
140 rProp.Value >>= msEffectPresetSubType;
145void NodeContext::initValid(
bool bHasValidChild,
bool bIsIterateChild)
147 sal_Int16
nType = mxNode->getType();
149 if (
nType == AnimationNodeType::ITERATE)
151 Reference<XIterateContainer> xIterate(mxNode, UNO_QUERY);
152 mbValid = xIterate.is() && (bIsIterateChild || isValidTarget(xIterate->getTarget()))
153 && !maChildNodes.empty();
155 else if (
nType == AnimationNodeType::COMMAND)
157 Reference<XCommand> xCommand(mxNode, UNO_QUERY);
158 mbValid = xCommand.is() && (bIsIterateChild || isValidTarget(xCommand->getTarget()));
160 else if (
nType == AnimationNodeType::PAR ||
nType == AnimationNodeType::SEQ)
164 else if (
nType == AnimationNodeType::AUDIO)
166 Reference<XAudio> xAudio(mxNode, UNO_QUERY);
168 Reference<XShape> xShape;
172 if (xAudio->getSource() >>= sURL)
176 else if (xAudio->getSource() >>= xShape)
178 Reference<XPropertySet> xShapeProps(xShape, UNO_QUERY);
180 = xShapeProps->getPropertySetInfo()->hasPropertyByName(
"MediaURL");
181 if (bHasMediaURL && (xShapeProps->getPropertyValue(
"MediaURL") >>= sURL))
183 mbValid = IsAudioURL(sURL) || IsVideoURL(sURL);
190 Reference<XAnimate> xAnimate(mxNode, UNO_QUERY);
191 mbValid = xAnimate.is() && (bIsIterateChild || isValidTarget(xAnimate->getTarget()));
195bool NodeContext::initChildNodes()
198 Reference<XEnumerationAccess> xEnumerationAccess(mxNode, UNO_QUERY);
199 if (xEnumerationAccess.is())
201 Reference<XEnumeration> xEnumeration = xEnumerationAccess->createEnumeration();
202 bool bIsMainSeq = mnEffectNodeType == EffectNodeType::MAIN_SEQUENCE;
203 bool bIsIterateChild = mxNode->getType() == AnimationNodeType::ITERATE;
204 if (xEnumeration.is())
206 while (xEnumeration->hasMoreElements())
208 Reference<XAnimationNode> xChildNode(xEnumeration->nextElement(), UNO_QUERY);
212 = std::make_unique<NodeContext>(xChildNode, bIsMainSeq, bIsIterateChild);
213 if (pChildContext->isValid())
215 maChildNodes.push_back(std::move(pChildContext));
223const Reference<XAnimationNode>& NodeContext::getNodeForCondition()
const
226 = (mnEffectNodeType != EffectNodeType::INTERACTIVE_SEQUENCE || maChildNodes.empty());
227 const Reference<XAnimationNode>& rNode = bParent ? mxNode : maChildNodes[0]->getNode();
NodeContext(const css::uno::Reference< css::animations::XAnimationNode > &xNode, bool bMainSeqChild, bool bIsIterateChild)
bool endsWithIgnoreAsciiCase(std::u16string_view s1, std::u16string_view s2, std::u16string_view *rest=nullptr)