Update ooo320-m1
[ooovba.git] / slideshow / source / engine / animationfactory.cxx
blob2431b64f7aa8ac7b7d94b27c3928f02d2c402f6d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: animationfactory.cxx,v $
10 * $Revision: 1.16 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_slideshow.hxx"
34 // must be first
35 #include <canvas/debug.hxx>
36 #include <tools/diagnose_ex.h>
37 #include <canvas/verbosetrace.hxx>
39 #include <animationfactory.hxx>
40 #include <attributemap.hxx>
42 #include <com/sun/star/animations/AnimationAdditiveMode.hpp>
43 #include <com/sun/star/animations/AnimationTransformType.hpp>
44 #include <com/sun/star/beans/XPropertySet.hpp>
45 #include <com/sun/star/drawing/FillStyle.hpp>
46 #include <com/sun/star/drawing/LineStyle.hpp>
47 #include <com/sun/star/awt/FontSlant.hpp>
48 #include <com/sun/star/awt/FontUnderline.hpp>
49 #include <com/sun/star/awt/FontWeight.hpp>
51 #include <basegfx/polygon/b2dpolygon.hxx>
52 #include <basegfx/polygon/b2dpolygontools.hxx>
53 #include <basegfx/polygon/b2dpolypolygontools.hxx>
55 #include <functional>
58 using namespace ::com::sun::star;
61 namespace slideshow
63 namespace internal
65 namespace
67 // attention, there is a similar implementation of Animation in
68 // transitions/transitionfactory.cxx
70 template< typename ValueT > class TupleAnimation : public PairAnimation
72 public:
73 TupleAnimation( const ShapeManagerSharedPtr& rShapeManager,
74 int nFlags,
75 bool (ShapeAttributeLayer::*pIs1stValid)() const,
76 bool (ShapeAttributeLayer::*pIs2ndValid)() const,
77 const ValueT& rDefaultValue,
78 const ::basegfx::B2DSize& rReferenceSize,
79 double (ShapeAttributeLayer::*pGet1stValue)() const,
80 double (ShapeAttributeLayer::*pGet2ndValue)() const,
81 void (ShapeAttributeLayer::*pSetValue)( const ValueT& ) ) :
82 mpShape(),
83 mpAttrLayer(),
84 mpShapeManager( rShapeManager ),
85 mpIs1stValidFunc(pIs1stValid),
86 mpIs2ndValidFunc(pIs2ndValid),
87 mpGet1stValueFunc(pGet1stValue),
88 mpGet2ndValueFunc(pGet2ndValue),
89 mpSetValueFunc(pSetValue),
90 mnFlags( nFlags ),
91 maReferenceSize( rReferenceSize ),
92 maDefaultValue( rDefaultValue ),
93 mbAnimationStarted( false )
95 ENSURE_OR_THROW( rShapeManager,
96 "TupleAnimation::TupleAnimation(): Invalid ShapeManager" );
97 ENSURE_OR_THROW( pIs1stValid && pIs2ndValid && pGet1stValue && pGet2ndValue && pSetValue,
98 "TupleAnimation::TupleAnimation(): One of the method pointers is NULL" );
101 ~TupleAnimation()
103 end_();
106 // Animation interface
107 // -------------------
108 virtual void prefetch( const AnimatableShapeSharedPtr&,
109 const ShapeAttributeLayerSharedPtr& )
112 virtual void start( const AnimatableShapeSharedPtr& rShape,
113 const ShapeAttributeLayerSharedPtr& rAttrLayer )
115 OSL_ENSURE( !mpShape,
116 "TupleAnimation::start(): Shape already set" );
117 OSL_ENSURE( !mpAttrLayer,
118 "TupleAnimation::start(): Attribute layer already set" );
120 mpShape = rShape;
121 mpAttrLayer = rAttrLayer;
123 ENSURE_OR_THROW( rShape,
124 "TupleAnimation::start(): Invalid shape" );
125 ENSURE_OR_THROW( rAttrLayer,
126 "TupleAnimation::start(): Invalid attribute layer" );
128 if( !mbAnimationStarted )
130 mbAnimationStarted = true;
132 if( !(mnFlags & AnimationFactory::FLAG_NO_SPRITE) )
133 mpShapeManager->enterAnimationMode( mpShape );
137 virtual void end() { end_(); }
138 void end_()
140 if( mbAnimationStarted )
142 mbAnimationStarted = false;
144 if( !(mnFlags & AnimationFactory::FLAG_NO_SPRITE) )
145 mpShapeManager->leaveAnimationMode( mpShape );
147 if( mpShape->isContentChanged() )
148 mpShapeManager->notifyShapeUpdate( mpShape );
152 // PairAnimation interface
153 // -----------------------
155 virtual bool operator()( const ::basegfx::B2DTuple& rValue )
157 ENSURE_OR_RETURN( mpAttrLayer && mpShape,
158 "TupleAnimation::operator(): Invalid ShapeAttributeLayer" );
160 ValueT aValue( rValue.getX(),
161 rValue.getY() );
163 // Activitis get values from the expression parser,
164 // which returns _relative_ sizes/positions.
165 // Convert back relative to reference coordinate system
166 aValue *= maReferenceSize;
168 ((*mpAttrLayer).*mpSetValueFunc)( aValue );
170 if( mpShape->isContentChanged() )
171 mpShapeManager->notifyShapeUpdate( mpShape );
173 return true;
176 virtual ::basegfx::B2DTuple getUnderlyingValue() const
178 ENSURE_OR_THROW( mpAttrLayer,
179 "TupleAnimation::getUnderlyingValue(): Invalid ShapeAttributeLayer" );
181 ::basegfx::B2DTuple aRetVal;
183 // deviated from the (*shared_ptr).*mpFuncPtr
184 // notation here, since gcc does not seem to parse
185 // that as a member function call anymore.
186 aRetVal.setX( (mpAttrLayer.get()->*mpIs1stValidFunc)() ?
187 (mpAttrLayer.get()->*mpGet1stValueFunc)() :
188 maDefaultValue.getX() );
189 aRetVal.setY( (mpAttrLayer.get()->*mpIs2ndValidFunc)() ?
190 (mpAttrLayer.get()->*mpGet2ndValueFunc)() :
191 maDefaultValue.getY() );
193 // Activities get values from the expression
194 // parser, which returns _relative_
195 // sizes/positions. Convert start value to the
196 // same coordinate space (i.e. relative to given
197 // reference size).
198 aRetVal /= maReferenceSize;
200 return aRetVal;
203 private:
204 AnimatableShapeSharedPtr mpShape;
205 ShapeAttributeLayerSharedPtr mpAttrLayer;
206 ShapeManagerSharedPtr mpShapeManager;
207 bool (ShapeAttributeLayer::*mpIs1stValidFunc)() const;
208 bool (ShapeAttributeLayer::*mpIs2ndValidFunc)() const;
209 double (ShapeAttributeLayer::*mpGet1stValueFunc)() const;
210 double (ShapeAttributeLayer::*mpGet2ndValueFunc)() const;
211 void (ShapeAttributeLayer::*mpSetValueFunc)( const ValueT& );
213 const int mnFlags;
215 const ::basegfx::B2DSize maReferenceSize;
216 const ValueT maDefaultValue;
217 bool mbAnimationStarted;
221 class PathAnimation : public NumberAnimation
223 public:
224 PathAnimation( const ::rtl::OUString& rSVGDPath,
225 sal_Int16 nAdditive,
226 const ShapeManagerSharedPtr& rShapeManager,
227 const ::basegfx::B2DVector& rSlideSize,
228 int nFlags ) :
229 maPathPoly(),
230 mpShape(),
231 mpAttrLayer(),
232 mpShapeManager( rShapeManager ),
233 maPageSize( rSlideSize ),
234 maShapeOrig(),
235 mnFlags( nFlags ),
236 mbAnimationStarted( false ),
237 mnAdditive( nAdditive )
239 ENSURE_OR_THROW( rShapeManager,
240 "PathAnimation::PathAnimation(): Invalid ShapeManager" );
242 ::basegfx::B2DPolyPolygon aPolyPoly;
244 ENSURE_OR_THROW( ::basegfx::tools::importFromSvgD( aPolyPoly, rSVGDPath ),
245 "PathAnimation::PathAnimation(): failed to parse SVG:d path" );
246 ENSURE_OR_THROW( aPolyPoly.count() == 1,
247 "PathAnimation::PathAnimation(): motion path consists of multiple/zero polygon(s)" );
249 // TODO(F2): Since getPositionRelative() currently
250 // cannot handle beziers, have to subdivide.
251 // AW: Should be no longer necessary; getPositionRelative is now bezier-safe
252 maPathPoly = ::basegfx::tools::adaptiveSubdivideByAngle(aPolyPoly.getB2DPolygon(0) );
255 ~PathAnimation()
257 end_();
260 // Animation interface
261 // -------------------
262 virtual void prefetch( const AnimatableShapeSharedPtr&,
263 const ShapeAttributeLayerSharedPtr& )
266 virtual void start( const AnimatableShapeSharedPtr& rShape,
267 const ShapeAttributeLayerSharedPtr& rAttrLayer )
269 OSL_ENSURE( !mpShape,
270 "PathAnimation::start(): Shape already set" );
271 OSL_ENSURE( !mpAttrLayer,
272 "PathAnimation::start(): Attribute layer already set" );
274 mpShape = rShape;
275 mpAttrLayer = rAttrLayer;
277 ENSURE_OR_THROW( rShape,
278 "PathAnimation::start(): Invalid shape" );
279 ENSURE_OR_THROW( rAttrLayer,
280 "PathAnimation::start(): Invalid attribute layer" );
282 // TODO(F1): Check whether _shape_ bounds are correct here.
283 // Theoretically, our AttrLayer is way down the stack, and
284 // we only have to consider _that_ value, not the one from
285 // the top of the stack as returned by Shape::getBounds()
286 if( mnAdditive == animations::AnimationAdditiveMode::SUM )
287 maShapeOrig = mpShape->getBounds().getCenter();
288 else
289 maShapeOrig = mpShape->getDomBounds().getCenter();
291 if( !mbAnimationStarted )
293 mbAnimationStarted = true;
295 if( !(mnFlags & AnimationFactory::FLAG_NO_SPRITE) )
296 mpShapeManager->enterAnimationMode( mpShape );
300 virtual void end() { end_(); }
301 void end_()
303 if( mbAnimationStarted )
305 mbAnimationStarted = false;
307 if( !(mnFlags & AnimationFactory::FLAG_NO_SPRITE) )
308 mpShapeManager->leaveAnimationMode( mpShape );
310 if( mpShape->isContentChanged() )
311 mpShapeManager->notifyShapeUpdate( mpShape );
315 // NumberAnimation interface
316 // -----------------------
318 virtual bool operator()( double nValue )
320 ENSURE_OR_RETURN( mpAttrLayer && mpShape,
321 "PathAnimation::operator(): Invalid ShapeAttributeLayer" );
323 ::basegfx::B2DPoint rOutPos = ::basegfx::tools::getPositionRelative( maPathPoly,
324 nValue );
326 // TODO(F1): Determine whether the path is
327 // absolute, or shape-relative.
329 // interpret path as page-relative. Scale up with page size
330 rOutPos *= maPageSize;
332 // TODO(F1): Determine whether the path origin is
333 // absolute, or shape-relative.
335 // interpret path as shape-originated. Offset to shape position
337 rOutPos += maShapeOrig;
339 mpAttrLayer->setPosition( rOutPos );
341 if( mpShape->isContentChanged() )
342 mpShapeManager->notifyShapeUpdate( mpShape );
344 return true;
347 virtual double getUnderlyingValue() const
349 ENSURE_OR_THROW( mpAttrLayer,
350 "PathAnimation::getUnderlyingValue(): Invalid ShapeAttributeLayer" );
352 return 0.0; // though this should be used in concert with
353 // ActivitiesFactory::createSimpleActivity, better
354 // explicitely name our start value.
355 // Permissible range for operator() above is [0,1]
358 private:
359 ::basegfx::B2DPolygon maPathPoly;
360 AnimatableShapeSharedPtr mpShape;
361 ShapeAttributeLayerSharedPtr mpAttrLayer;
362 ShapeManagerSharedPtr mpShapeManager;
363 const ::basegfx::B2DSize maPageSize;
364 ::basegfx::B2DPoint maShapeOrig;
365 const int mnFlags;
366 bool mbAnimationStarted;
367 sal_Int16 mnAdditive;
371 /** GenericAnimation template
373 This template makes heavy use of SFINAE, only one of
374 the operator()() methods will compile for each of the
375 base classes.
377 Note that we omit the virtual keyword on the
378 operator()() overrides and getUnderlyingValue() methods on
379 purpose; those that actually do override baseclass
380 virtual methods inherit the property, and the others
381 won't increase our vtable. What's more, having all
382 those methods in the vtable actually creates POIs for
383 them, which breaks the whole SFINAE concept (IOW, this
384 template won't compile any longer).
386 @tpl AnimationBase
387 Type of animation to generate (determines the
388 interface GenericAnimation will implement). Must be
389 one of NumberAnimation, ColorAnimation,
390 StringAnimation, PairAnimation or BoolAnimation.
392 @tpl ModifierFunctor
393 Type of a functor object, which can optionally be used to
394 modify the getter/setter values.
396 template< typename AnimationBase, typename ModifierFunctor > class GenericAnimation : public AnimationBase
398 public:
399 typedef typename AnimationBase::ValueType ValueT;
401 /** Create generic animation
403 @param pIsValid
404 Function pointer to one of the is*Valid
405 methods. Used to either take the given getter
406 method, or the given default value for the start value.
408 @param rDefaultValue
409 Default value, to take as the start value if
410 is*Valid returns false.
412 @param pGetValue
413 Getter method, to fetch start value if valid.
415 @param pSetValue
416 Setter method. This one puts the current animation
417 value to the ShapeAttributeLayer.
419 @param rGetterModifier
420 Modifies up values retrieved from the pGetValue method.
421 Must provide operator()( const ValueT& ) method.
423 @param rSetterModifier
424 Modifies up values before passing them to the pSetValue method.
425 Must provide operator()( const ValueT& ) method.
427 GenericAnimation( const ShapeManagerSharedPtr& rShapeManager,
428 int nFlags,
429 bool (ShapeAttributeLayer::*pIsValid)() const,
430 const ValueT& rDefaultValue,
431 ValueT (ShapeAttributeLayer::*pGetValue)() const,
432 void (ShapeAttributeLayer::*pSetValue)( const ValueT& ),
433 const ModifierFunctor& rGetterModifier,
434 const ModifierFunctor& rSetterModifier ) :
435 mpShape(),
436 mpAttrLayer(),
437 mpShapeManager( rShapeManager ),
438 mpIsValidFunc(pIsValid),
439 mpGetValueFunc(pGetValue),
440 mpSetValueFunc(pSetValue),
441 maGetterModifier( rGetterModifier ),
442 maSetterModifier( rSetterModifier ),
443 mnFlags( nFlags ),
444 maDefaultValue(rDefaultValue),
445 mbAnimationStarted( false )
447 ENSURE_OR_THROW( rShapeManager,
448 "GenericAnimation::GenericAnimation(): Invalid ShapeManager" );
449 ENSURE_OR_THROW( pIsValid && pGetValue && pSetValue,
450 "GenericAnimation::GenericAnimation(): One of the method pointers is NULL" );
453 ~GenericAnimation()
455 end_();
458 // Animation interface
459 // -------------------
460 virtual void prefetch( const AnimatableShapeSharedPtr&,
461 const ShapeAttributeLayerSharedPtr& )
464 virtual void start( const AnimatableShapeSharedPtr& rShape,
465 const ShapeAttributeLayerSharedPtr& rAttrLayer )
467 OSL_ENSURE( !mpShape,
468 "GenericAnimation::start(): Shape already set" );
469 OSL_ENSURE( !mpAttrLayer,
470 "GenericAnimation::start(): Attribute layer already set" );
472 mpShape = rShape;
473 mpAttrLayer = rAttrLayer;
475 ENSURE_OR_THROW( rShape,
476 "GenericAnimation::start(): Invalid shape" );
477 ENSURE_OR_THROW( rAttrLayer,
478 "GenericAnimation::start(): Invalid attribute layer" );
480 // only start animation once per repeated start() call,
481 // and only if sprites should be used for display
482 if( !mbAnimationStarted )
484 mbAnimationStarted = true;
486 if( !(mnFlags & AnimationFactory::FLAG_NO_SPRITE) )
487 mpShapeManager->enterAnimationMode( mpShape );
491 virtual void end() { end_(); }
492 void end_()
494 // TODO(Q2): Factor out common code (most
495 // prominently start() and end()) into base class
497 // only stop animation once per repeated end() call,
498 // and only if sprites are used for display
499 if( mbAnimationStarted )
501 mbAnimationStarted = false;
503 if( !(mnFlags & AnimationFactory::FLAG_NO_SPRITE) )
504 mpShapeManager->leaveAnimationMode( mpShape );
506 // Attention, this notifyShapeUpdate() is
507 // somewhat delicate here. Calling it
508 // unconditional (i.e. not guarded by
509 // mbAnimationStarted) will lead to shapes
510 // snapping back to their original state just
511 // before the slide ends. Not calling it at
512 // all might swallow final animation
513 // states. The current implementation relies
514 // on the fact that end() is either called by
515 // the Activity (then, the last animation
516 // state has been set, and corresponds to the
517 // shape's hold state), or by the animation
518 // node (then, it's a forced end, and we
519 // _have_ to snap back).
521 // To reiterate: normally, we're called from
522 // the Activity first, thus the
523 // notifyShapeUpdate() below will update to
524 // the last activity value.
526 // force shape update, activity might have changed
527 // state in the last round.
528 if( mpShape->isContentChanged() )
529 mpShapeManager->notifyShapeUpdate( mpShape );
533 // Derived Animation interface
534 // ---------------------------
536 /** For by-reference interfaces (B2DTuple, OUString)
538 bool operator()( const ValueT& x )
540 ENSURE_OR_RETURN( mpAttrLayer && mpShape,
541 "GenericAnimation::operator(): Invalid ShapeAttributeLayer" );
543 ((*mpAttrLayer).*mpSetValueFunc)( maSetterModifier( x ) );
545 if( mpShape->isContentChanged() )
546 mpShapeManager->notifyShapeUpdate( mpShape );
548 return true;
551 /** For by-value interfaces (bool, double)
553 bool operator()( ValueT x )
555 ENSURE_OR_RETURN( mpAttrLayer && mpShape,
556 "GenericAnimation::operator(): Invalid ShapeAttributeLayer" );
558 ((*mpAttrLayer).*mpSetValueFunc)( maSetterModifier( x ) );
560 if( mpShape->isContentChanged() )
561 mpShapeManager->notifyShapeUpdate( mpShape );
563 return true;
566 ValueT getUnderlyingValue() const
568 ENSURE_OR_THROW( mpAttrLayer,
569 "GenericAnimation::getUnderlyingValue(): Invalid ShapeAttributeLayer" );
571 // deviated from the (*shared_ptr).*mpFuncPtr
572 // notation here, since gcc does not seem to parse
573 // that as a member function call anymore.
574 if( (mpAttrLayer.get()->*mpIsValidFunc)() )
575 return maGetterModifier( ((*mpAttrLayer).*mpGetValueFunc)() );
576 else
577 return maDefaultValue;
580 private:
581 AnimatableShapeSharedPtr mpShape;
582 ShapeAttributeLayerSharedPtr mpAttrLayer;
583 ShapeManagerSharedPtr mpShapeManager;
584 bool (ShapeAttributeLayer::*mpIsValidFunc)() const;
585 ValueT (ShapeAttributeLayer::*mpGetValueFunc)() const;
586 void (ShapeAttributeLayer::*mpSetValueFunc)( const ValueT& );
588 ModifierFunctor maGetterModifier;
589 ModifierFunctor maSetterModifier;
591 const int mnFlags;
593 const ValueT maDefaultValue;
594 bool mbAnimationStarted;
597 /** Function template wrapper around GenericAnimation template
599 @tpl AnimationBase
600 Type of animation to generate (determines the
601 interface GenericAnimation will implement).
603 template< typename AnimationBase > ::boost::shared_ptr< AnimationBase >
604 makeGenericAnimation( const ShapeManagerSharedPtr& rShapeManager,
605 int nFlags,
606 bool (ShapeAttributeLayer::*pIsValid)() const,
607 const typename AnimationBase::ValueType& rDefaultValue,
608 typename AnimationBase::ValueType (ShapeAttributeLayer::*pGetValue)() const,
609 void (ShapeAttributeLayer::*pSetValue)( const typename AnimationBase::ValueType& ) )
611 return ::boost::shared_ptr< AnimationBase >(
612 new GenericAnimation< AnimationBase,
613 ::std::identity< typename AnimationBase::ValueType > >(
614 rShapeManager,
615 nFlags,
616 pIsValid,
617 rDefaultValue,
618 pGetValue,
619 pSetValue,
620 // no modification necessary, use identity functor here
621 ::std::identity< typename AnimationBase::ValueType >(),
622 ::std::identity< typename AnimationBase::ValueType >() ) );
625 class Scaler
627 public:
628 Scaler( double nScale ) :
629 mnScale( nScale )
633 double operator()( double nVal ) const
635 return mnScale * nVal;
638 private:
639 double mnScale;
642 /** Overload for NumberAnimations which need scaling (width,height,x,y currently)
644 NumberAnimationSharedPtr makeGenericAnimation( const ShapeManagerSharedPtr& rShapeManager,
645 int nFlags,
646 bool (ShapeAttributeLayer::*pIsValid)() const,
647 double nDefaultValue,
648 double (ShapeAttributeLayer::*pGetValue)() const,
649 void (ShapeAttributeLayer::*pSetValue)( const double& ),
650 double nScaleValue )
652 return NumberAnimationSharedPtr(
653 new GenericAnimation< NumberAnimation, Scaler >( rShapeManager,
654 nFlags,
655 pIsValid,
656 nDefaultValue / nScaleValue,
657 pGetValue,
658 pSetValue,
659 Scaler( 1.0/nScaleValue ),
660 Scaler( nScaleValue ) ) );
664 uno::Any getShapeDefault( const AnimatableShapeSharedPtr& rShape,
665 const ::rtl::OUString& rPropertyName )
667 uno::Reference< drawing::XShape > xShape( rShape->getXShape() );
669 if( !xShape.is() )
670 return uno::Any(); // no regular shape, no defaults available
673 // extract relevant value from XShape's PropertySet
674 uno::Reference< beans::XPropertySet > xPropSet( xShape,
675 uno::UNO_QUERY );
677 ENSURE_OR_THROW( xPropSet.is(),
678 "getShapeDefault(): Cannot query property set from shape" );
680 return xPropSet->getPropertyValue( rPropertyName );
683 template< typename ValueType > ValueType getDefault( const AnimatableShapeSharedPtr& rShape,
684 const ::rtl::OUString& rPropertyName )
686 const uno::Any& rAny( getShapeDefault( rShape,
687 rPropertyName ) );
689 if( !rAny.hasValue() )
691 OSL_ENSURE( false, "getDefault(): cannot get requested shape property" );
692 OSL_TRACE( "getDefault(): cannot get '%s' shape property",
693 ::rtl::OUStringToOString( rPropertyName,
694 RTL_TEXTENCODING_ASCII_US ).getStr() );
695 return ValueType();
697 else
699 ValueType aValue = ValueType();
701 if( !(rAny >>= aValue) )
703 OSL_ENSURE( false, "getDefault(): cannot extract requested shape property" );
704 OSL_TRACE( "getDefault(): cannot extract '%s' shape property",
705 ::rtl::OUStringToOString( rPropertyName,
706 RTL_TEXTENCODING_ASCII_US ).getStr() );
707 return ValueType();
710 return aValue;
714 template<> RGBColor getDefault< RGBColor >( const AnimatableShapeSharedPtr& rShape,
715 const ::rtl::OUString& rPropertyName )
717 const uno::Any& rAny( getShapeDefault( rShape,
718 rPropertyName ) );
720 if( !rAny.hasValue() )
722 OSL_ENSURE( false, "getDefault(): cannot get requested shape color property" );
723 OSL_TRACE( "getDefault(): cannot get '%s' shape color property",
724 ::rtl::OUStringToOString( rPropertyName,
725 RTL_TEXTENCODING_ASCII_US ).getStr() );
726 return RGBColor();
728 else
730 sal_Int32 nValue = 0;
732 if( !(rAny >>= nValue) )
734 OSL_ENSURE( false, "getDefault(): cannot extract requested shape color property" );
735 OSL_TRACE( "getDefault(): cannot extract '%s' shape color property",
736 ::rtl::OUStringToOString( rPropertyName,
737 RTL_TEXTENCODING_ASCII_US ).getStr() );
738 return RGBColor();
741 // convert from 0xAARRGGBB API color to 0xRRGGBB00
742 // canvas color
743 return RGBColor( (nValue << 8U) & 0xFFFFFF00U );
748 AnimationFactory::AttributeClass AnimationFactory::classifyAttributeName( const ::rtl::OUString& rAttrName )
750 // ATTENTION: When changing this map, also the create*PropertyAnimation() methods must
751 // be checked and possibly adapted in their switch statements
753 // TODO(Q2): Since this map must be coherent with the various switch statements
754 // in the create*PropertyAnimation methods, try to unify into a single method or table
755 switch( mapAttributeName( rAttrName ) )
757 default:
758 // FALLTHROUGH intended
759 case ATTRIBUTE_INVALID:
760 return CLASS_UNKNOWN_PROPERTY;
762 case ATTRIBUTE_CHAR_COLOR:
763 // FALLTHROUGH intended
764 case ATTRIBUTE_COLOR:
765 // FALLTHROUGH intended
766 case ATTRIBUTE_DIMCOLOR:
767 // FALLTHROUGH intended
768 case ATTRIBUTE_FILL_COLOR:
769 // FALLTHROUGH intended
770 case ATTRIBUTE_LINE_COLOR:
771 return CLASS_COLOR_PROPERTY;
773 case ATTRIBUTE_CHAR_FONT_NAME:
774 return CLASS_STRING_PROPERTY;
776 case ATTRIBUTE_VISIBILITY:
777 return CLASS_BOOL_PROPERTY;
779 case ATTRIBUTE_CHAR_HEIGHT:
780 // FALLTHROUGH intended
781 case ATTRIBUTE_CHAR_WEIGHT:
782 // FALLTHROUGH intended
783 case ATTRIBUTE_CHAR_ROTATION:
784 // FALLTHROUGH intended
785 case ATTRIBUTE_HEIGHT:
786 // FALLTHROUGH intended
787 case ATTRIBUTE_OPACITY:
788 // FALLTHROUGH intended
789 case ATTRIBUTE_ROTATE:
790 // FALLTHROUGH intended
791 case ATTRIBUTE_SKEW_X:
792 // FALLTHROUGH intended
793 case ATTRIBUTE_SKEW_Y:
794 // FALLTHROUGH intended
795 case ATTRIBUTE_WIDTH:
796 // FALLTHROUGH intended
797 case ATTRIBUTE_POS_X:
798 // FALLTHROUGH intended
799 case ATTRIBUTE_POS_Y:
800 return CLASS_NUMBER_PROPERTY;
802 case ATTRIBUTE_CHAR_UNDERLINE:
803 // FALLTHROUGH intended
804 case ATTRIBUTE_FILL_STYLE:
805 // FALLTHROUGH intended
806 case ATTRIBUTE_LINE_STYLE:
807 // FALLTHROUGH intended
808 case ATTRIBUTE_CHAR_POSTURE:
809 return CLASS_ENUM_PROPERTY;
813 NumberAnimationSharedPtr AnimationFactory::createNumberPropertyAnimation( const ::rtl::OUString& rAttrName,
814 const AnimatableShapeSharedPtr& rShape,
815 const ShapeManagerSharedPtr& rShapeManager,
816 const ::basegfx::B2DVector& rSlideSize,
817 int nFlags )
819 // ATTENTION: When changing this map, also the classifyAttributeName() method must
820 // be checked and possibly adapted in their switch statement
821 switch( mapAttributeName( rAttrName ) )
823 default:
824 // FALLTHROUGH intended
825 case ATTRIBUTE_INVALID:
826 ENSURE_OR_THROW( false,
827 "AnimationFactory::createNumberPropertyAnimation(): Unknown attribute" );
828 break;
830 case ATTRIBUTE_CHAR_COLOR:
831 // FALLTHROUGH intended
832 case ATTRIBUTE_CHAR_FONT_NAME:
833 // FALLTHROUGH intended
834 case ATTRIBUTE_CHAR_POSTURE:
835 // FALLTHROUGH intended
836 case ATTRIBUTE_CHAR_UNDERLINE:
837 // FALLTHROUGH intended
838 case ATTRIBUTE_COLOR:
839 // FALLTHROUGH intended
840 case ATTRIBUTE_DIMCOLOR:
841 // FALLTHROUGH intended
842 case ATTRIBUTE_FILL_COLOR:
843 // FALLTHROUGH intended
844 case ATTRIBUTE_FILL_STYLE:
845 // FALLTHROUGH intended
846 case ATTRIBUTE_LINE_COLOR:
847 // FALLTHROUGH intended
848 case ATTRIBUTE_LINE_STYLE:
849 // FALLTHROUGH intended
850 case ATTRIBUTE_VISIBILITY:
851 ENSURE_OR_THROW( false,
852 "AnimationFactory::createNumberPropertyAnimation(): Attribute type mismatch" );
853 break;
855 case ATTRIBUTE_CHAR_HEIGHT:
856 return makeGenericAnimation<NumberAnimation>( rShapeManager,
857 nFlags,
858 &ShapeAttributeLayer::isCharScaleValid,
859 1.0, // CharHeight is a relative attribute, thus
860 // default is 1.0
861 &ShapeAttributeLayer::getCharScale,
862 &ShapeAttributeLayer::setCharScale );
864 case ATTRIBUTE_CHAR_WEIGHT:
865 return makeGenericAnimation<NumberAnimation>( rShapeManager,
866 nFlags,
867 &ShapeAttributeLayer::isCharWeightValid,
868 getDefault<double>( rShape, rAttrName ),
869 &ShapeAttributeLayer::getCharWeight,
870 &ShapeAttributeLayer::setCharWeight );
872 case ATTRIBUTE_CHAR_ROTATION:
873 return makeGenericAnimation<NumberAnimation>( rShapeManager,
874 nFlags,
875 &ShapeAttributeLayer::isCharRotationAngleValid,
876 getDefault<double>( rShape, rAttrName ),
877 &ShapeAttributeLayer::getCharRotationAngle,
878 &ShapeAttributeLayer::setCharRotationAngle );
880 case ATTRIBUTE_HEIGHT:
881 return makeGenericAnimation( rShapeManager,
882 nFlags,
883 &ShapeAttributeLayer::isHeightValid,
884 // TODO(F1): Check whether _shape_ bounds are correct here.
885 // Theoretically, our AttrLayer is way down the stack, and
886 // we only have to consider _that_ value, not the one from
887 // the top of the stack as returned by Shape::getBounds()
888 rShape->getBounds().getHeight(),
889 &ShapeAttributeLayer::getHeight,
890 &ShapeAttributeLayer::setHeight,
891 // convert expression parser value from relative page size
892 rSlideSize.getY() );
894 case ATTRIBUTE_OPACITY:
895 return makeGenericAnimation<NumberAnimation>( rShapeManager,
896 nFlags,
897 &ShapeAttributeLayer::isAlphaValid,
898 // TODO(F1): Provide shape default here (FillTransparency?)
899 1.0,
900 &ShapeAttributeLayer::getAlpha,
901 &ShapeAttributeLayer::setAlpha );
903 case ATTRIBUTE_ROTATE:
904 return makeGenericAnimation<NumberAnimation>( rShapeManager,
905 nFlags,
906 &ShapeAttributeLayer::isRotationAngleValid,
907 // NOTE: Since we paint the shape as-is from metafile,
908 // rotation angle is always 0.0, even for rotated shapes
909 0.0,
910 &ShapeAttributeLayer::getRotationAngle,
911 &ShapeAttributeLayer::setRotationAngle );
913 case ATTRIBUTE_SKEW_X:
914 return makeGenericAnimation<NumberAnimation>( rShapeManager,
915 nFlags,
916 &ShapeAttributeLayer::isShearXAngleValid,
917 // TODO(F1): Is there any shape property for skew?
918 0.0,
919 &ShapeAttributeLayer::getShearXAngle,
920 &ShapeAttributeLayer::setShearXAngle );
922 case ATTRIBUTE_SKEW_Y:
923 return makeGenericAnimation<NumberAnimation>( rShapeManager,
924 nFlags,
925 &ShapeAttributeLayer::isShearYAngleValid,
926 // TODO(F1): Is there any shape property for skew?
927 0.0,
928 &ShapeAttributeLayer::getShearYAngle,
929 &ShapeAttributeLayer::setShearYAngle );
931 case ATTRIBUTE_WIDTH:
932 return makeGenericAnimation( rShapeManager,
933 nFlags,
934 &ShapeAttributeLayer::isWidthValid,
935 // TODO(F1): Check whether _shape_ bounds are correct here.
936 // Theoretically, our AttrLayer is way down the stack, and
937 // we only have to consider _that_ value, not the one from
938 // the top of the stack as returned by Shape::getBounds()
939 rShape->getBounds().getWidth(),
940 &ShapeAttributeLayer::getWidth,
941 &ShapeAttributeLayer::setWidth,
942 // convert expression parser value from relative page size
943 rSlideSize.getX() );
945 case ATTRIBUTE_POS_X:
946 return makeGenericAnimation( rShapeManager,
947 nFlags,
948 &ShapeAttributeLayer::isPosXValid,
949 // TODO(F1): Check whether _shape_ bounds are correct here.
950 // Theoretically, our AttrLayer is way down the stack, and
951 // we only have to consider _that_ value, not the one from
952 // the top of the stack as returned by Shape::getBounds()
953 rShape->getBounds().getCenterX(),
954 &ShapeAttributeLayer::getPosX,
955 &ShapeAttributeLayer::setPosX,
956 // convert expression parser value from relative page size
957 rSlideSize.getX() );
959 case ATTRIBUTE_POS_Y:
960 return makeGenericAnimation( rShapeManager,
961 nFlags,
962 &ShapeAttributeLayer::isPosYValid,
963 // TODO(F1): Check whether _shape_ bounds are correct here.
964 // Theoretically, our AttrLayer is way down the stack, and
965 // we only have to consider _that_ value, not the one from
966 // the top of the stack as returned by Shape::getBounds()
967 rShape->getBounds().getCenterY(),
968 &ShapeAttributeLayer::getPosY,
969 &ShapeAttributeLayer::setPosY,
970 // convert expression parser value from relative page size
971 rSlideSize.getY() );
974 return NumberAnimationSharedPtr();
977 EnumAnimationSharedPtr AnimationFactory::createEnumPropertyAnimation( const ::rtl::OUString& rAttrName,
978 const AnimatableShapeSharedPtr& rShape,
979 const ShapeManagerSharedPtr& rShapeManager,
980 const ::basegfx::B2DVector& /*rSlideSize*/,
981 int nFlags )
983 // ATTENTION: When changing this map, also the classifyAttributeName() method must
984 // be checked and possibly adapted in their switch statement
985 switch( mapAttributeName( rAttrName ) )
987 default:
988 // FALLTHROUGH intended
989 case ATTRIBUTE_INVALID:
990 ENSURE_OR_THROW( false,
991 "AnimationFactory::createEnumPropertyAnimation(): Unknown attribute" );
992 break;
994 case ATTRIBUTE_CHAR_COLOR:
995 // FALLTHROUGH intended
996 case ATTRIBUTE_CHAR_FONT_NAME:
997 // FALLTHROUGH intended
998 case ATTRIBUTE_COLOR:
999 // FALLTHROUGH intended
1000 case ATTRIBUTE_DIMCOLOR:
1001 // FALLTHROUGH intended
1002 case ATTRIBUTE_FILL_COLOR:
1003 // FALLTHROUGH intended
1004 case ATTRIBUTE_LINE_COLOR:
1005 // FALLTHROUGH intended
1006 case ATTRIBUTE_VISIBILITY:
1007 // FALLTHROUGH intended
1008 case ATTRIBUTE_CHAR_HEIGHT:
1009 // FALLTHROUGH intended
1010 case ATTRIBUTE_CHAR_WEIGHT:
1011 // FALLTHROUGH intended
1012 case ATTRIBUTE_CHAR_ROTATION:
1013 // FALLTHROUGH intended
1014 case ATTRIBUTE_HEIGHT:
1015 // FALLTHROUGH intended
1016 case ATTRIBUTE_OPACITY:
1017 // FALLTHROUGH intended
1018 case ATTRIBUTE_ROTATE:
1019 // FALLTHROUGH intended
1020 case ATTRIBUTE_SKEW_X:
1021 // FALLTHROUGH intended
1022 case ATTRIBUTE_SKEW_Y:
1023 // FALLTHROUGH intended
1024 case ATTRIBUTE_WIDTH:
1025 // FALLTHROUGH intended
1026 case ATTRIBUTE_POS_X:
1027 // FALLTHROUGH intended
1028 case ATTRIBUTE_POS_Y:
1029 ENSURE_OR_THROW( false,
1030 "AnimationFactory::createEnumPropertyAnimation(): Attribute type mismatch" );
1031 break;
1034 case ATTRIBUTE_FILL_STYLE:
1035 return makeGenericAnimation<EnumAnimation>( rShapeManager,
1036 nFlags,
1037 &ShapeAttributeLayer::isFillStyleValid,
1038 sal::static_int_cast<sal_Int16>(
1039 getDefault<drawing::FillStyle>( rShape, rAttrName )),
1040 &ShapeAttributeLayer::getFillStyle,
1041 &ShapeAttributeLayer::setFillStyle );
1043 case ATTRIBUTE_LINE_STYLE:
1044 return makeGenericAnimation<EnumAnimation>( rShapeManager,
1045 nFlags,
1046 &ShapeAttributeLayer::isLineStyleValid,
1047 sal::static_int_cast<sal_Int16>(
1048 getDefault<drawing::LineStyle>( rShape, rAttrName )),
1049 &ShapeAttributeLayer::getLineStyle,
1050 &ShapeAttributeLayer::setLineStyle );
1052 case ATTRIBUTE_CHAR_POSTURE:
1053 return makeGenericAnimation<EnumAnimation>( rShapeManager,
1054 nFlags,
1055 &ShapeAttributeLayer::isCharPostureValid,
1056 sal::static_int_cast<sal_Int16>(
1057 getDefault<awt::FontSlant>( rShape, rAttrName )),
1058 &ShapeAttributeLayer::getCharPosture,
1059 &ShapeAttributeLayer::setCharPosture );
1061 case ATTRIBUTE_CHAR_UNDERLINE:
1062 return makeGenericAnimation<EnumAnimation>( rShapeManager,
1063 nFlags,
1064 &ShapeAttributeLayer::isUnderlineModeValid,
1065 getDefault<sal_Int16>( rShape, rAttrName ),
1066 &ShapeAttributeLayer::getUnderlineMode,
1067 &ShapeAttributeLayer::setUnderlineMode );
1070 return EnumAnimationSharedPtr();
1073 ColorAnimationSharedPtr AnimationFactory::createColorPropertyAnimation( const ::rtl::OUString& rAttrName,
1074 const AnimatableShapeSharedPtr& rShape,
1075 const ShapeManagerSharedPtr& rShapeManager,
1076 const ::basegfx::B2DVector& /*rSlideSize*/,
1077 int nFlags )
1079 // ATTENTION: When changing this map, also the classifyAttributeName() method must
1080 // be checked and possibly adapted in their switch statement
1081 switch( mapAttributeName( rAttrName ) )
1083 default:
1084 // FALLTHROUGH intended
1085 case ATTRIBUTE_INVALID:
1086 ENSURE_OR_THROW( false,
1087 "AnimationFactory::createColorPropertyAnimation(): Unknown attribute" );
1088 break;
1090 case ATTRIBUTE_CHAR_FONT_NAME:
1091 // FALLTHROUGH intended
1092 case ATTRIBUTE_CHAR_HEIGHT:
1093 // FALLTHROUGH intended
1094 case ATTRIBUTE_CHAR_POSTURE:
1095 // FALLTHROUGH intended
1096 case ATTRIBUTE_CHAR_ROTATION:
1097 // FALLTHROUGH intended
1098 case ATTRIBUTE_CHAR_UNDERLINE:
1099 // FALLTHROUGH intended
1100 case ATTRIBUTE_CHAR_WEIGHT:
1101 // FALLTHROUGH intended
1102 case ATTRIBUTE_FILL_STYLE:
1103 // FALLTHROUGH intended
1104 case ATTRIBUTE_HEIGHT:
1105 // FALLTHROUGH intended
1106 case ATTRIBUTE_LINE_STYLE:
1107 // FALLTHROUGH intended
1108 case ATTRIBUTE_OPACITY:
1109 // FALLTHROUGH intended
1110 case ATTRIBUTE_ROTATE:
1111 // FALLTHROUGH intended
1112 case ATTRIBUTE_SKEW_X:
1113 // FALLTHROUGH intended
1114 case ATTRIBUTE_SKEW_Y:
1115 // FALLTHROUGH intended
1116 case ATTRIBUTE_VISIBILITY:
1117 // FALLTHROUGH intended
1118 case ATTRIBUTE_WIDTH:
1119 // FALLTHROUGH intended
1120 case ATTRIBUTE_POS_X:
1121 // FALLTHROUGH intended
1122 case ATTRIBUTE_POS_Y:
1123 ENSURE_OR_THROW( false,
1124 "AnimationFactory::createColorPropertyAnimation(): Attribute type mismatch" );
1125 break;
1127 case ATTRIBUTE_CHAR_COLOR:
1128 return makeGenericAnimation<ColorAnimation>( rShapeManager,
1129 nFlags,
1130 &ShapeAttributeLayer::isCharColorValid,
1131 getDefault<RGBColor>( rShape, rAttrName ),
1132 &ShapeAttributeLayer::getCharColor,
1133 &ShapeAttributeLayer::setCharColor );
1135 case ATTRIBUTE_COLOR:
1136 // TODO(F2): This is just mapped to fill color to make it work
1137 return makeGenericAnimation<ColorAnimation>( rShapeManager,
1138 nFlags,
1139 &ShapeAttributeLayer::isFillColorValid,
1140 getDefault<RGBColor>( rShape, rAttrName ),
1141 &ShapeAttributeLayer::getFillColor,
1142 &ShapeAttributeLayer::setFillColor );
1144 case ATTRIBUTE_DIMCOLOR:
1145 return makeGenericAnimation<ColorAnimation>( rShapeManager,
1146 nFlags,
1147 &ShapeAttributeLayer::isDimColorValid,
1148 getDefault<RGBColor>( rShape, rAttrName ),
1149 &ShapeAttributeLayer::getDimColor,
1150 &ShapeAttributeLayer::setDimColor );
1152 case ATTRIBUTE_FILL_COLOR:
1153 return makeGenericAnimation<ColorAnimation>( rShapeManager,
1154 nFlags,
1155 &ShapeAttributeLayer::isFillColorValid,
1156 getDefault<RGBColor>( rShape, rAttrName ),
1157 &ShapeAttributeLayer::getFillColor,
1158 &ShapeAttributeLayer::setFillColor );
1160 case ATTRIBUTE_LINE_COLOR:
1161 return makeGenericAnimation<ColorAnimation>( rShapeManager,
1162 nFlags,
1163 &ShapeAttributeLayer::isLineColorValid,
1164 getDefault<RGBColor>( rShape, rAttrName ),
1165 &ShapeAttributeLayer::getLineColor,
1166 &ShapeAttributeLayer::setLineColor );
1169 return ColorAnimationSharedPtr();
1172 PairAnimationSharedPtr AnimationFactory::createPairPropertyAnimation( const AnimatableShapeSharedPtr& rShape,
1173 const ShapeManagerSharedPtr& rShapeManager,
1174 const ::basegfx::B2DVector& rSlideSize,
1175 sal_Int16 nTransformType,
1176 int nFlags )
1178 const ::basegfx::B2DRectangle& rBounds( rShape->getBounds() );
1180 switch( nTransformType )
1182 case animations::AnimationTransformType::SCALE:
1183 return PairAnimationSharedPtr(
1184 new TupleAnimation< ::basegfx::B2DSize >(
1185 rShapeManager,
1186 nFlags,
1187 &ShapeAttributeLayer::isWidthValid,
1188 &ShapeAttributeLayer::isHeightValid,
1189 // TODO(F1): Check whether _shape_ bounds are correct here.
1190 // Theoretically, our AttrLayer is way down the stack, and
1191 // we only have to consider _that_ value, not the one from
1192 // the top of the stack as returned by Shape::getBounds()
1193 rBounds.getRange(),
1194 rBounds.getRange(),
1195 &ShapeAttributeLayer::getWidth,
1196 &ShapeAttributeLayer::getHeight,
1197 &ShapeAttributeLayer::setSize ) );
1199 case animations::AnimationTransformType::TRANSLATE:
1200 return PairAnimationSharedPtr(
1201 new TupleAnimation< ::basegfx::B2DPoint >(
1202 rShapeManager,
1203 nFlags,
1204 &ShapeAttributeLayer::isPosXValid,
1205 &ShapeAttributeLayer::isPosYValid,
1206 // TODO(F1): Check whether _shape_ bounds are correct here.
1207 // Theoretically, our AttrLayer is way down the stack, and
1208 // we only have to consider _that_ value, not the one from
1209 // the top of the stack as returned by Shape::getBounds()
1210 rBounds.getCenter(),
1211 rSlideSize,
1212 &ShapeAttributeLayer::getPosX,
1213 &ShapeAttributeLayer::getPosY,
1214 &ShapeAttributeLayer::setPosition ) );
1216 default:
1217 ENSURE_OR_THROW( false,
1218 "AnimationFactory::createPairPropertyAnimation(): Attribute type mismatch" );
1219 break;
1222 return PairAnimationSharedPtr();
1225 StringAnimationSharedPtr AnimationFactory::createStringPropertyAnimation( const ::rtl::OUString& rAttrName,
1226 const AnimatableShapeSharedPtr& rShape,
1227 const ShapeManagerSharedPtr& rShapeManager,
1228 const ::basegfx::B2DVector& /*rSlideSize*/,
1229 int nFlags )
1231 // ATTENTION: When changing this map, also the classifyAttributeName() method must
1232 // be checked and possibly adapted in their switch statement
1233 switch( mapAttributeName( rAttrName ) )
1235 default:
1236 // FALLTHROUGH intended
1237 case ATTRIBUTE_INVALID:
1238 ENSURE_OR_THROW( false,
1239 "AnimationFactory::createStringPropertyAnimation(): Unknown attribute" );
1240 break;
1242 case ATTRIBUTE_CHAR_COLOR:
1243 // FALLTHROUGH intended
1244 case ATTRIBUTE_CHAR_HEIGHT:
1245 // FALLTHROUGH intended
1246 case ATTRIBUTE_CHAR_ROTATION:
1247 // FALLTHROUGH intended
1248 case ATTRIBUTE_CHAR_UNDERLINE:
1249 // FALLTHROUGH intended
1250 case ATTRIBUTE_COLOR:
1251 // FALLTHROUGH intended
1252 case ATTRIBUTE_DIMCOLOR:
1253 // FALLTHROUGH intended
1254 case ATTRIBUTE_FILL_COLOR:
1255 // FALLTHROUGH intended
1256 case ATTRIBUTE_HEIGHT:
1257 // FALLTHROUGH intended
1258 case ATTRIBUTE_LINE_COLOR:
1259 // FALLTHROUGH intended
1260 case ATTRIBUTE_OPACITY:
1261 // FALLTHROUGH intended
1262 case ATTRIBUTE_ROTATE:
1263 // FALLTHROUGH intended
1264 case ATTRIBUTE_SKEW_X:
1265 // FALLTHROUGH intended
1266 case ATTRIBUTE_SKEW_Y:
1267 // FALLTHROUGH intended
1268 case ATTRIBUTE_VISIBILITY:
1269 // FALLTHROUGH intended
1270 case ATTRIBUTE_WIDTH:
1271 // FALLTHROUGH intended
1272 case ATTRIBUTE_POS_X:
1273 // FALLTHROUGH intended
1274 case ATTRIBUTE_POS_Y:
1275 // FALLTHROUGH intended
1276 case ATTRIBUTE_CHAR_POSTURE:
1277 // FALLTHROUGH intended
1278 case ATTRIBUTE_CHAR_WEIGHT:
1279 // FALLTHROUGH intended
1280 case ATTRIBUTE_FILL_STYLE:
1281 // FALLTHROUGH intended
1282 case ATTRIBUTE_LINE_STYLE:
1283 ENSURE_OR_THROW( false,
1284 "AnimationFactory::createStringPropertyAnimation(): Attribute type mismatch" );
1285 break;
1287 case ATTRIBUTE_CHAR_FONT_NAME:
1288 return makeGenericAnimation<StringAnimation>( rShapeManager,
1289 nFlags,
1290 &ShapeAttributeLayer::isFontFamilyValid,
1291 getDefault< ::rtl::OUString >( rShape, rAttrName ),
1292 &ShapeAttributeLayer::getFontFamily,
1293 &ShapeAttributeLayer::setFontFamily );
1296 return StringAnimationSharedPtr();
1299 BoolAnimationSharedPtr AnimationFactory::createBoolPropertyAnimation( const ::rtl::OUString& rAttrName,
1300 const AnimatableShapeSharedPtr& /*rShape*/,
1301 const ShapeManagerSharedPtr& rShapeManager,
1302 const ::basegfx::B2DVector& /*rSlideSize*/,
1303 int nFlags )
1305 // ATTENTION: When changing this map, also the classifyAttributeName() method must
1306 // be checked and possibly adapted in their switch statement
1307 switch( mapAttributeName( rAttrName ) )
1309 default:
1310 // FALLTHROUGH intended
1311 case ATTRIBUTE_INVALID:
1312 ENSURE_OR_THROW( false,
1313 "AnimationFactory::createBoolPropertyAnimation(): Unknown attribute" );
1314 break;
1316 case ATTRIBUTE_CHAR_COLOR:
1317 // FALLTHROUGH intended
1318 case ATTRIBUTE_CHAR_FONT_NAME:
1319 // FALLTHROUGH intended
1320 case ATTRIBUTE_CHAR_HEIGHT:
1321 // FALLTHROUGH intended
1322 case ATTRIBUTE_CHAR_POSTURE:
1323 // FALLTHROUGH intended
1324 case ATTRIBUTE_CHAR_ROTATION:
1325 // FALLTHROUGH intended
1326 case ATTRIBUTE_CHAR_WEIGHT:
1327 // FALLTHROUGH intended
1328 case ATTRIBUTE_COLOR:
1329 // FALLTHROUGH intended
1330 case ATTRIBUTE_DIMCOLOR:
1331 // FALLTHROUGH intended
1332 case ATTRIBUTE_FILL_COLOR:
1333 // FALLTHROUGH intended
1334 case ATTRIBUTE_FILL_STYLE:
1335 // FALLTHROUGH intended
1336 case ATTRIBUTE_HEIGHT:
1337 // FALLTHROUGH intended
1338 case ATTRIBUTE_LINE_COLOR:
1339 // FALLTHROUGH intended
1340 case ATTRIBUTE_LINE_STYLE:
1341 // FALLTHROUGH intended
1342 case ATTRIBUTE_OPACITY:
1343 // FALLTHROUGH intended
1344 case ATTRIBUTE_ROTATE:
1345 // FALLTHROUGH intended
1346 case ATTRIBUTE_SKEW_X:
1347 // FALLTHROUGH intended
1348 case ATTRIBUTE_SKEW_Y:
1349 // FALLTHROUGH intended
1350 case ATTRIBUTE_WIDTH:
1351 // FALLTHROUGH intended
1352 case ATTRIBUTE_POS_X:
1353 // FALLTHROUGH intended
1354 case ATTRIBUTE_POS_Y:
1355 // FALLTHROUGH intended
1356 case ATTRIBUTE_CHAR_UNDERLINE:
1357 ENSURE_OR_THROW( false,
1358 "AnimationFactory::createBoolPropertyAnimation(): Attribute type mismatch" );
1359 break;
1361 case ATTRIBUTE_VISIBILITY:
1362 return makeGenericAnimation<BoolAnimation>( rShapeManager,
1363 nFlags,
1364 &ShapeAttributeLayer::isVisibilityValid,
1365 // TODO(F1): Is there a corresponding shape property?
1366 true,
1367 &ShapeAttributeLayer::getVisibility,
1368 &ShapeAttributeLayer::setVisibility );
1371 return BoolAnimationSharedPtr();
1374 NumberAnimationSharedPtr AnimationFactory::createPathMotionAnimation( const ::rtl::OUString& rSVGDPath,
1375 sal_Int16 nAdditive,
1376 const AnimatableShapeSharedPtr& /*rShape*/,
1377 const ShapeManagerSharedPtr& rShapeManager,
1378 const ::basegfx::B2DVector& rSlideSize,
1379 int nFlags )
1381 return NumberAnimationSharedPtr(
1382 new PathAnimation( rSVGDPath, nAdditive,
1383 rShapeManager,
1384 rSlideSize,
1385 nFlags ) );