20#include <com/sun/star/animations/XIterateContainer.hpp>
21#include <com/sun/star/presentation/ParagraphTarget.hpp>
22#include <com/sun/star/drawing/XShape.hpp>
23#include <com/sun/star/animations/AnimationNodeType.hpp>
24#include <com/sun/star/animations/XAnimate.hpp>
27#include <unordered_map>
39 typedef ::std::vector< beans::NamedValue > VectorOfNamedValues;
50 uno::Reference< drawing::XShape >
mxRef;
60 bool operator==(
const ShapeHashKey& rRHS )
const
69 ::std::size_t operator()(
const ShapeHashKey& rKey )
const
84 return reinterpret_cast< ::std::size_t
>(rKey.mxRef.get()) ^ (rKey.mnParagraphIndex << 16);
89 typedef std::unordered_map< ShapeHashKey, VectorOfNamedValues, ShapeKeyHasher > XShapeToNamedValuesMap;
96 XShapeToNamedValuesMap& rShapeHash,
105 NodeFunctor( XShapeToNamedValuesMap& rShapeHash,
106 uno::Reference< drawing::XShape > xTargetShape,
107 sal_Int16 nParagraphIndex,
116 void operator()(
const uno::Reference< animations::XAnimationNode >& xNode )
const
120 OSL_FAIL(
"AnimCore: NodeFunctor::operator(): invalid XAnimationNode" );
124 uno::Reference< drawing::XShape > xTargetShape(
mxTargetShape );
127 switch( xNode->getType() )
129 case animations::AnimationNodeType::ITERATE:
134 uno::Reference< animations::XIterateContainer > xIterNode( xNode,
138 if( !xIterNode->getTarget().hasValue() )
140 OSL_FAIL(
"animcore: NodeFunctor::operator(): no target on ITERATE node" );
144 xTargetShape.set( xIterNode->getTarget(),
147 if( !xTargetShape.is() )
149 css::presentation::ParagraphTarget aTarget;
152 if( !(xIterNode->getTarget() >>= aTarget) )
154 OSL_FAIL(
"animcore: NodeFunctor::operator(): could not extract any "
155 "target information" );
159 xTargetShape = aTarget.Shape;
160 nParagraphIndex = aTarget.Paragraph;
162 if( !xTargetShape.is() )
164 OSL_FAIL(
"animcore: NodeFunctor::operator(): invalid shape in ParagraphTarget" );
170 case animations::AnimationNodeType::PAR:
171 case animations::AnimationNodeType::SEQ:
180 OSL_FAIL(
"AnimCore: NodeFunctor::operator(): child node iteration failed, "
181 "or extraneous container nodes encountered" );
186 case animations::AnimationNodeType::CUSTOM:
187 case animations::AnimationNodeType::ANIMATE:
188 case animations::AnimationNodeType::ANIMATEMOTION:
189 case animations::AnimationNodeType::ANIMATECOLOR:
190 case animations::AnimationNodeType::ANIMATETRANSFORM:
191 case animations::AnimationNodeType::TRANSITIONFILTER:
192 case animations::AnimationNodeType::AUDIO:
197 case animations::AnimationNodeType::SET:
200 uno::Reference< animations::XAnimate > xAnimateNode( xNode,
203 if( !xAnimateNode.is() )
207 ShapeHashKey aTarget;
208 if( xTargetShape.is() )
211 aTarget.mxRef = xTargetShape;
212 aTarget.mnParagraphIndex = nParagraphIndex;
218 if( xAnimateNode->getTarget() >>= aTarget.mxRef )
222 aTarget.mnParagraphIndex = -1;
228 presentation::ParagraphTarget aUnoTarget;
230 if( !(xAnimateNode->getTarget() >>= aUnoTarget) )
232 OSL_FAIL(
"AnimCore: NodeFunctor::operator(): unknown target type encountered" );
236 aTarget.mxRef = aUnoTarget.Shape;
237 aTarget.mnParagraphIndex = aUnoTarget.Paragraph;
241 if( !aTarget.mxRef.is() )
243 OSL_FAIL(
"AnimCore: NodeFunctor::operator(): Found target, but XShape is NULL" );
261 if( xAnimateNode->getAttributeName().equalsIgnoreAsciiCase(
"visibility") )
264 uno::Any aAny( xAnimateNode->getTo() );
267 if( !(aAny >>= bVisible) )
271 if( aAny >>= aString )
275 if( aString.equalsIgnoreAsciiCase(
"true") ||
276 aString.equalsIgnoreAsciiCase(
"on") )
280 if( aString.equalsIgnoreAsciiCase(
"false") ||
281 aString.equalsIgnoreAsciiCase(
"off") )
328 XShapeToNamedValuesMap aShapeHash( 101 );
330 NodeFunctor aFunctor(
340 aFunctor( xRootNode );
344 auto aResRange = asNonConstRange(aRes);
346 ::std::size_t nCurrIndex(0);
347 for(
const auto& rIter : aShapeHash )
349 animations::TargetProperties& rCurrProps( aResRange[ nCurrIndex++ ] );
351 if( rIter.first.mnParagraphIndex == -1 )
353 rCurrProps.Target <<= rIter.first.mxRef;
357 rCurrProps.Target <<=
358 presentation::ParagraphTarget(
360 rIter.first.mnParagraphIndex );
363 rCurrProps.Properties = ::comphelper::containerToSequence( rIter.second );
uno::Sequence< animations::TargetProperties > createTargetProperties(const uno::Reference< animations::XAnimationNode > &rootNode, bool bInitial)
Generate shape property list - set bInitial to true for initial slide state.
bool operator==(const HSLColor &rLHS, const HSLColor &rRHS)
bool for_each_childNode(const css::uno::Reference< css::animations::XAnimationNode > &xNode, Functor &rFunctor)
Apply given functor to every animation node child.
uno::Reference< drawing::XShape > mxTargetShape
XShapeToNamedValuesMap & mrShapeHash
uno::Reference< drawing::XShape > mxRef
Shape target.
sal_Int16 mnParagraphIndex
Paragraph index.