fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / slideshow / source / engine / animationfactory.cxx
blob7804dfc3f440a0af21f88e649dfaa29d19010d6b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 // must be first
22 #include <canvas/debug.hxx>
23 #include <tools/diagnose_ex.h>
24 #include <canvas/verbosetrace.hxx>
26 #include <animationfactory.hxx>
27 #include <attributemap.hxx>
29 #include <com/sun/star/animations/AnimationAdditiveMode.hpp>
30 #include <com/sun/star/animations/AnimationTransformType.hpp>
31 #include <com/sun/star/beans/XPropertySet.hpp>
32 #include <com/sun/star/drawing/FillStyle.hpp>
33 #include <com/sun/star/drawing/LineStyle.hpp>
34 #include <com/sun/star/awt/FontSlant.hpp>
35 #include <com/sun/star/awt/FontUnderline.hpp>
36 #include <com/sun/star/awt/FontWeight.hpp>
38 #include <basegfx/polygon/b2dpolygon.hxx>
39 #include <basegfx/polygon/b2dpolygontools.hxx>
40 #include <basegfx/polygon/b2dpolypolygontools.hxx>
42 #include <functional>
45 using namespace ::com::sun::star;
48 namespace slideshow
50 namespace internal
52 namespace
54 // attention, there is a similar implementation of Animation in
55 // transitions/transitionfactory.cxx
57 template< typename ValueT > class TupleAnimation : public PairAnimation
59 public:
60 TupleAnimation( const ShapeManagerSharedPtr& rShapeManager,
61 int nFlags,
62 bool (ShapeAttributeLayer::*pIs1stValid)() const,
63 bool (ShapeAttributeLayer::*pIs2ndValid)() const,
64 const ValueT& rDefaultValue,
65 const ::basegfx::B2DSize& rReferenceSize,
66 double (ShapeAttributeLayer::*pGet1stValue)() const,
67 double (ShapeAttributeLayer::*pGet2ndValue)() const,
68 void (ShapeAttributeLayer::*pSetValue)( const ValueT& ) ) :
69 mpShape(),
70 mpAttrLayer(),
71 mpShapeManager( rShapeManager ),
72 mpIs1stValidFunc(pIs1stValid),
73 mpIs2ndValidFunc(pIs2ndValid),
74 mpGet1stValueFunc(pGet1stValue),
75 mpGet2ndValueFunc(pGet2ndValue),
76 mpSetValueFunc(pSetValue),
77 mnFlags( nFlags ),
78 maReferenceSize( rReferenceSize ),
79 maDefaultValue( rDefaultValue ),
80 mbAnimationStarted( false )
82 ENSURE_OR_THROW( rShapeManager,
83 "TupleAnimation::TupleAnimation(): Invalid ShapeManager" );
84 ENSURE_OR_THROW( pIs1stValid && pIs2ndValid && pGet1stValue && pGet2ndValue && pSetValue,
85 "TupleAnimation::TupleAnimation(): One of the method pointers is NULL" );
88 virtual ~TupleAnimation()
90 end_();
93 // Animation interface
95 virtual void prefetch( const AnimatableShapeSharedPtr&,
96 const ShapeAttributeLayerSharedPtr& ) SAL_OVERRIDE
99 virtual void start( const AnimatableShapeSharedPtr& rShape,
100 const ShapeAttributeLayerSharedPtr& rAttrLayer ) SAL_OVERRIDE
102 OSL_ENSURE( !mpShape,
103 "TupleAnimation::start(): Shape already set" );
104 OSL_ENSURE( !mpAttrLayer,
105 "TupleAnimation::start(): Attribute layer already set" );
107 mpShape = rShape;
108 mpAttrLayer = rAttrLayer;
110 ENSURE_OR_THROW( rShape,
111 "TupleAnimation::start(): Invalid shape" );
112 ENSURE_OR_THROW( rAttrLayer,
113 "TupleAnimation::start(): Invalid attribute layer" );
115 if( !mbAnimationStarted )
117 mbAnimationStarted = true;
119 if( !(mnFlags & AnimationFactory::FLAG_NO_SPRITE) )
120 mpShapeManager->enterAnimationMode( mpShape );
124 virtual void end() SAL_OVERRIDE { end_(); }
125 void end_()
127 if( mbAnimationStarted )
129 mbAnimationStarted = false;
131 if( !(mnFlags & AnimationFactory::FLAG_NO_SPRITE) )
132 mpShapeManager->leaveAnimationMode( mpShape );
134 if( mpShape->isContentChanged() )
135 mpShapeManager->notifyShapeUpdate( mpShape );
139 // PairAnimation interface
142 virtual bool operator()( const ::basegfx::B2DTuple& rValue ) SAL_OVERRIDE
144 ENSURE_OR_RETURN_FALSE( mpAttrLayer && mpShape,
145 "TupleAnimation::operator(): Invalid ShapeAttributeLayer" );
147 ValueT aValue( rValue.getX(),
148 rValue.getY() );
150 // Activitis get values from the expression parser,
151 // which returns _relative_ sizes/positions.
152 // Convert back relative to reference coordinate system
153 aValue *= maReferenceSize;
155 ((*mpAttrLayer).*mpSetValueFunc)( aValue );
157 if( mpShape->isContentChanged() )
158 mpShapeManager->notifyShapeUpdate( mpShape );
160 return true;
163 virtual ::basegfx::B2DTuple getUnderlyingValue() const SAL_OVERRIDE
165 ENSURE_OR_THROW( mpAttrLayer,
166 "TupleAnimation::getUnderlyingValue(): Invalid ShapeAttributeLayer" );
168 ::basegfx::B2DTuple aRetVal;
170 // deviated from the (*shared_ptr).*mpFuncPtr
171 // notation here, since gcc does not seem to parse
172 // that as a member function call anymore.
173 aRetVal.setX( (mpAttrLayer.get()->*mpIs1stValidFunc)() ?
174 (mpAttrLayer.get()->*mpGet1stValueFunc)() :
175 maDefaultValue.getX() );
176 aRetVal.setY( (mpAttrLayer.get()->*mpIs2ndValidFunc)() ?
177 (mpAttrLayer.get()->*mpGet2ndValueFunc)() :
178 maDefaultValue.getY() );
180 // Activities get values from the expression
181 // parser, which returns _relative_
182 // sizes/positions. Convert start value to the
183 // same coordinate space (i.e. relative to given
184 // reference size).
185 aRetVal /= maReferenceSize;
187 return aRetVal;
190 private:
191 AnimatableShapeSharedPtr mpShape;
192 ShapeAttributeLayerSharedPtr mpAttrLayer;
193 ShapeManagerSharedPtr mpShapeManager;
194 bool (ShapeAttributeLayer::*mpIs1stValidFunc)() const;
195 bool (ShapeAttributeLayer::*mpIs2ndValidFunc)() const;
196 double (ShapeAttributeLayer::*mpGet1stValueFunc)() const;
197 double (ShapeAttributeLayer::*mpGet2ndValueFunc)() const;
198 void (ShapeAttributeLayer::*mpSetValueFunc)( const ValueT& );
200 const int mnFlags;
202 const ::basegfx::B2DSize maReferenceSize;
203 const ValueT maDefaultValue;
204 bool mbAnimationStarted;
208 class PathAnimation : public NumberAnimation
210 public:
211 PathAnimation( const OUString& rSVGDPath,
212 sal_Int16 nAdditive,
213 const ShapeManagerSharedPtr& rShapeManager,
214 const ::basegfx::B2DVector& rSlideSize,
215 int nFlags ) :
216 maPathPoly(),
217 mpShape(),
218 mpAttrLayer(),
219 mpShapeManager( rShapeManager ),
220 maPageSize( rSlideSize ),
221 maShapeOrig(),
222 mnFlags( nFlags ),
223 mbAnimationStarted( false ),
224 mnAdditive( nAdditive )
226 ENSURE_OR_THROW( rShapeManager,
227 "PathAnimation::PathAnimation(): Invalid ShapeManager" );
229 ::basegfx::B2DPolyPolygon aPolyPoly;
231 ENSURE_OR_THROW( ::basegfx::tools::importFromSvgD( aPolyPoly, rSVGDPath, false, 0 ),
232 "PathAnimation::PathAnimation(): failed to parse SVG:d path" );
233 ENSURE_OR_THROW( aPolyPoly.count() == 1,
234 "PathAnimation::PathAnimation(): motion path consists of multiple/zero polygon(s)" );
236 // TODO(F2): Since getPositionRelative() currently
237 // cannot handle beziers, have to subdivide.
238 // AW: Should be no longer necessary; getPositionRelative is now bezier-safe
239 maPathPoly = ::basegfx::tools::adaptiveSubdivideByAngle(aPolyPoly.getB2DPolygon(0) );
242 virtual ~PathAnimation()
244 end_();
247 // Animation interface
249 virtual void prefetch( const AnimatableShapeSharedPtr&,
250 const ShapeAttributeLayerSharedPtr& ) SAL_OVERRIDE
253 virtual void start( const AnimatableShapeSharedPtr& rShape,
254 const ShapeAttributeLayerSharedPtr& rAttrLayer ) SAL_OVERRIDE
256 OSL_ENSURE( !mpShape,
257 "PathAnimation::start(): Shape already set" );
258 OSL_ENSURE( !mpAttrLayer,
259 "PathAnimation::start(): Attribute layer already set" );
261 mpShape = rShape;
262 mpAttrLayer = rAttrLayer;
264 ENSURE_OR_THROW( rShape,
265 "PathAnimation::start(): Invalid shape" );
266 ENSURE_OR_THROW( rAttrLayer,
267 "PathAnimation::start(): Invalid attribute layer" );
269 // TODO(F1): Check whether _shape_ bounds are correct here.
270 // Theoretically, our AttrLayer is way down the stack, and
271 // we only have to consider _that_ value, not the one from
272 // the top of the stack as returned by Shape::getBounds()
273 if( mnAdditive == animations::AnimationAdditiveMode::SUM )
274 maShapeOrig = mpShape->getBounds().getCenter();
275 else
276 maShapeOrig = mpShape->getDomBounds().getCenter();
278 if( !mbAnimationStarted )
280 mbAnimationStarted = true;
282 if( !(mnFlags & AnimationFactory::FLAG_NO_SPRITE) )
283 mpShapeManager->enterAnimationMode( mpShape );
287 virtual void end() SAL_OVERRIDE { end_(); }
288 void end_()
290 if( mbAnimationStarted )
292 mbAnimationStarted = false;
294 if( !(mnFlags & AnimationFactory::FLAG_NO_SPRITE) )
295 mpShapeManager->leaveAnimationMode( mpShape );
297 if( mpShape->isContentChanged() )
298 mpShapeManager->notifyShapeUpdate( mpShape );
302 // NumberAnimation interface
305 virtual bool operator()( double nValue ) SAL_OVERRIDE
307 ENSURE_OR_RETURN_FALSE( mpAttrLayer && mpShape,
308 "PathAnimation::operator(): Invalid ShapeAttributeLayer" );
310 ::basegfx::B2DPoint rOutPos = ::basegfx::tools::getPositionRelative( maPathPoly,
311 nValue );
313 // TODO(F1): Determine whether the path is
314 // absolute, or shape-relative.
316 // interpret path as page-relative. Scale up with page size
317 rOutPos *= maPageSize;
319 // TODO(F1): Determine whether the path origin is
320 // absolute, or shape-relative.
322 // interpret path as shape-originated. Offset to shape position
324 rOutPos += maShapeOrig;
326 mpAttrLayer->setPosition( rOutPos );
328 if( mpShape->isContentChanged() )
329 mpShapeManager->notifyShapeUpdate( mpShape );
331 return true;
334 virtual double getUnderlyingValue() const SAL_OVERRIDE
336 ENSURE_OR_THROW( mpAttrLayer,
337 "PathAnimation::getUnderlyingValue(): Invalid ShapeAttributeLayer" );
339 return 0.0; // though this should be used in concert with
340 // ActivitiesFactory::createSimpleActivity, better
341 // explicitly name our start value.
342 // Permissible range for operator() above is [0,1]
345 private:
346 ::basegfx::B2DPolygon maPathPoly;
347 AnimatableShapeSharedPtr mpShape;
348 ShapeAttributeLayerSharedPtr mpAttrLayer;
349 ShapeManagerSharedPtr mpShapeManager;
350 const ::basegfx::B2DSize maPageSize;
351 ::basegfx::B2DPoint maShapeOrig;
352 const int mnFlags;
353 bool mbAnimationStarted;
354 sal_Int16 mnAdditive;
358 /** GenericAnimation template
360 This template makes heavy use of SFINAE, only one of
361 the operator()() methods will compile for each of the
362 base classes.
364 Note that we omit the virtual keyword on the
365 operator()() overrides and getUnderlyingValue() methods on
366 purpose; those that actually do override baseclass
367 virtual methods inherit the property, and the others
368 won't increase our vtable. What's more, having all
369 those methods in the vtable actually creates POIs for
370 them, which breaks the whole SFINAE concept (IOW, this
371 template won't compile any longer).
373 @tpl AnimationBase
374 Type of animation to generate (determines the
375 interface GenericAnimation will implement). Must be
376 one of NumberAnimation, ColorAnimation,
377 StringAnimation, PairAnimation or BoolAnimation.
379 @tpl ModifierFunctor
380 Type of a functor object, which can optionally be used to
381 modify the getter/setter values.
383 template< typename AnimationBase, typename ModifierFunctor > class GenericAnimation : public AnimationBase
385 public:
386 typedef typename AnimationBase::ValueType ValueT;
388 /** Create generic animation
390 @param pIsValid
391 Function pointer to one of the is*Valid
392 methods. Used to either take the given getter
393 method, or the given default value for the start value.
395 @param rDefaultValue
396 Default value, to take as the start value if
397 is*Valid returns false.
399 @param pGetValue
400 Getter method, to fetch start value if valid.
402 @param pSetValue
403 Setter method. This one puts the current animation
404 value to the ShapeAttributeLayer.
406 @param rGetterModifier
407 Modifies up values retrieved from the pGetValue method.
408 Must provide operator()( const ValueT& ) method.
410 @param rSetterModifier
411 Modifies up values before passing them to the pSetValue method.
412 Must provide operator()( const ValueT& ) method.
414 GenericAnimation( const ShapeManagerSharedPtr& rShapeManager,
415 int nFlags,
416 bool (ShapeAttributeLayer::*pIsValid)() const,
417 const ValueT& rDefaultValue,
418 ValueT (ShapeAttributeLayer::*pGetValue)() const,
419 void (ShapeAttributeLayer::*pSetValue)( const ValueT& ),
420 const ModifierFunctor& rGetterModifier,
421 const ModifierFunctor& rSetterModifier ) :
422 mpShape(),
423 mpAttrLayer(),
424 mpShapeManager( rShapeManager ),
425 mpIsValidFunc(pIsValid),
426 mpGetValueFunc(pGetValue),
427 mpSetValueFunc(pSetValue),
428 maGetterModifier( rGetterModifier ),
429 maSetterModifier( rSetterModifier ),
430 mnFlags( nFlags ),
431 maDefaultValue(rDefaultValue),
432 mbAnimationStarted( false )
434 ENSURE_OR_THROW( rShapeManager,
435 "GenericAnimation::GenericAnimation(): Invalid ShapeManager" );
436 ENSURE_OR_THROW( pIsValid && pGetValue && pSetValue,
437 "GenericAnimation::GenericAnimation(): One of the method pointers is NULL" );
440 ~GenericAnimation()
442 end_();
445 // Animation interface
447 virtual void prefetch( const AnimatableShapeSharedPtr&,
448 const ShapeAttributeLayerSharedPtr& )
451 virtual void start( const AnimatableShapeSharedPtr& rShape,
452 const ShapeAttributeLayerSharedPtr& rAttrLayer )
454 OSL_ENSURE( !mpShape,
455 "GenericAnimation::start(): Shape already set" );
456 OSL_ENSURE( !mpAttrLayer,
457 "GenericAnimation::start(): Attribute layer already set" );
459 mpShape = rShape;
460 mpAttrLayer = rAttrLayer;
462 ENSURE_OR_THROW( rShape,
463 "GenericAnimation::start(): Invalid shape" );
464 ENSURE_OR_THROW( rAttrLayer,
465 "GenericAnimation::start(): Invalid attribute layer" );
467 // only start animation once per repeated start() call,
468 // and only if sprites should be used for display
469 if( !mbAnimationStarted )
471 mbAnimationStarted = true;
473 if( !(mnFlags & AnimationFactory::FLAG_NO_SPRITE) )
474 mpShapeManager->enterAnimationMode( mpShape );
478 virtual void end() { end_(); }
479 void end_()
481 // TODO(Q2): Factor out common code (most
482 // prominently start() and end()) into base class
484 // only stop animation once per repeated end() call,
485 // and only if sprites are used for display
486 if( mbAnimationStarted )
488 mbAnimationStarted = false;
490 if( !(mnFlags & AnimationFactory::FLAG_NO_SPRITE) )
491 mpShapeManager->leaveAnimationMode( mpShape );
493 // Attention, this notifyShapeUpdate() is
494 // somewhat delicate here. Calling it
495 // unconditional (i.e. not guarded by
496 // mbAnimationStarted) will lead to shapes
497 // snapping back to their original state just
498 // before the slide ends. Not calling it at
499 // all might swallow final animation
500 // states. The current implementation relies
501 // on the fact that end() is either called by
502 // the Activity (then, the last animation
503 // state has been set, and corresponds to the
504 // shape's hold state), or by the animation
505 // node (then, it's a forced end, and we
506 // _have_ to snap back).
508 // To reiterate: normally, we're called from
509 // the Activity first, thus the
510 // notifyShapeUpdate() below will update to
511 // the last activity value.
513 // force shape update, activity might have changed
514 // state in the last round.
515 if( mpShape->isContentChanged() )
516 mpShapeManager->notifyShapeUpdate( mpShape );
520 // Derived Animation interface
523 /** For by-reference interfaces (B2DTuple, OUString)
525 bool operator()( const ValueT& x )
527 ENSURE_OR_RETURN_FALSE( mpAttrLayer && mpShape,
528 "GenericAnimation::operator(): Invalid ShapeAttributeLayer" );
530 ((*mpAttrLayer).*mpSetValueFunc)( maSetterModifier( x ) );
532 if( mpShape->isContentChanged() )
533 mpShapeManager->notifyShapeUpdate( mpShape );
535 return true;
538 /** For by-value interfaces (bool, double)
540 bool operator()( ValueT x )
542 ENSURE_OR_RETURN_FALSE( mpAttrLayer && mpShape,
543 "GenericAnimation::operator(): Invalid ShapeAttributeLayer" );
545 ((*mpAttrLayer).*mpSetValueFunc)( maSetterModifier( x ) );
547 if( mpShape->isContentChanged() )
548 mpShapeManager->notifyShapeUpdate( mpShape );
550 return true;
553 ValueT getUnderlyingValue() const
555 ENSURE_OR_THROW( mpAttrLayer,
556 "GenericAnimation::getUnderlyingValue(): Invalid ShapeAttributeLayer" );
558 // deviated from the (*shared_ptr).*mpFuncPtr
559 // notation here, since gcc does not seem to parse
560 // that as a member function call anymore.
561 if( (mpAttrLayer.get()->*mpIsValidFunc)() )
562 return maGetterModifier( ((*mpAttrLayer).*mpGetValueFunc)() );
563 else
564 return maDefaultValue;
567 private:
568 AnimatableShapeSharedPtr mpShape;
569 ShapeAttributeLayerSharedPtr mpAttrLayer;
570 ShapeManagerSharedPtr mpShapeManager;
571 bool (ShapeAttributeLayer::*mpIsValidFunc)() const;
572 ValueT (ShapeAttributeLayer::*mpGetValueFunc)() const;
573 void (ShapeAttributeLayer::*mpSetValueFunc)( const ValueT& );
575 ModifierFunctor maGetterModifier;
576 ModifierFunctor maSetterModifier;
578 const int mnFlags;
580 const ValueT maDefaultValue;
581 bool mbAnimationStarted;
584 //Current c++0x draft (apparently) has std::identity, but not operator()
585 template<typename T> struct SGI_identity : public std::unary_function<T,T>
587 T& operator()(T& x) const { return x; }
588 const T& operator()(const T& x) const { return x; }
591 /** Function template wrapper around GenericAnimation template
593 @tpl AnimationBase
594 Type of animation to generate (determines the
595 interface GenericAnimation will implement).
597 template< typename AnimationBase > ::boost::shared_ptr< AnimationBase >
598 makeGenericAnimation( const ShapeManagerSharedPtr& rShapeManager,
599 int nFlags,
600 bool (ShapeAttributeLayer::*pIsValid)() const,
601 const typename AnimationBase::ValueType& rDefaultValue,
602 typename AnimationBase::ValueType (ShapeAttributeLayer::*pGetValue)() const,
603 void (ShapeAttributeLayer::*pSetValue)( const typename AnimationBase::ValueType& ) )
605 return ::boost::shared_ptr< AnimationBase >(
606 new GenericAnimation< AnimationBase,
607 SGI_identity< typename AnimationBase::ValueType > >(
608 rShapeManager,
609 nFlags,
610 pIsValid,
611 rDefaultValue,
612 pGetValue,
613 pSetValue,
614 // no modification necessary, use identity functor here
615 SGI_identity< typename AnimationBase::ValueType >(),
616 SGI_identity< typename AnimationBase::ValueType >() ) );
619 class Scaler
621 public:
622 Scaler( double nScale ) :
623 mnScale( nScale )
627 double operator()( double nVal ) const
629 return mnScale * nVal;
632 private:
633 double mnScale;
636 /** Overload for NumberAnimations which need scaling (width,height,x,y currently)
638 NumberAnimationSharedPtr makeGenericAnimation( const ShapeManagerSharedPtr& rShapeManager,
639 int nFlags,
640 bool (ShapeAttributeLayer::*pIsValid)() const,
641 double nDefaultValue,
642 double (ShapeAttributeLayer::*pGetValue)() const,
643 void (ShapeAttributeLayer::*pSetValue)( const double& ),
644 double nScaleValue )
646 return NumberAnimationSharedPtr(
647 new GenericAnimation< NumberAnimation, Scaler >( rShapeManager,
648 nFlags,
649 pIsValid,
650 nDefaultValue / nScaleValue,
651 pGetValue,
652 pSetValue,
653 Scaler( 1.0/nScaleValue ),
654 Scaler( nScaleValue ) ) );
658 uno::Any getShapeDefault( const AnimatableShapeSharedPtr& rShape,
659 const OUString& rPropertyName )
661 uno::Reference< drawing::XShape > xShape( rShape->getXShape() );
663 if( !xShape.is() )
664 return uno::Any(); // no regular shape, no defaults available
667 // extract relevant value from XShape's PropertySet
668 uno::Reference< beans::XPropertySet > xPropSet( xShape,
669 uno::UNO_QUERY );
671 ENSURE_OR_THROW( xPropSet.is(),
672 "getShapeDefault(): Cannot query property set from shape" );
674 return xPropSet->getPropertyValue( rPropertyName );
677 template< typename ValueType > ValueType getDefault( const AnimatableShapeSharedPtr& rShape,
678 const OUString& rPropertyName )
680 const uno::Any& rAny( getShapeDefault( rShape,
681 rPropertyName ) );
683 if( !rAny.hasValue() )
685 OSL_FAIL( "getDefault(): cannot get requested shape property" );
686 OSL_TRACE( "getDefault(): cannot get '%s' shape property",
687 OUStringToOString( rPropertyName,
688 RTL_TEXTENCODING_ASCII_US ).getStr() );
689 return ValueType();
691 else
693 ValueType aValue = ValueType();
695 if( !(rAny >>= aValue) )
697 OSL_FAIL( "getDefault(): cannot extract requested shape property" );
698 OSL_TRACE( "getDefault(): cannot extract '%s' shape property",
699 OUStringToOString( rPropertyName,
700 RTL_TEXTENCODING_ASCII_US ).getStr() );
701 return ValueType();
704 return aValue;
708 template<> RGBColor getDefault< RGBColor >( const AnimatableShapeSharedPtr& rShape,
709 const OUString& rPropertyName )
711 const uno::Any& rAny( getShapeDefault( rShape,
712 rPropertyName ) );
714 if( !rAny.hasValue() )
716 OSL_FAIL( "getDefault(): cannot get requested shape color property" );
717 OSL_TRACE( "getDefault(): cannot get '%s' shape color property",
718 OUStringToOString( rPropertyName,
719 RTL_TEXTENCODING_ASCII_US ).getStr() );
720 return RGBColor();
722 else
724 sal_Int32 nValue = 0;
726 if( !(rAny >>= nValue) )
728 OSL_FAIL( "getDefault(): cannot extract requested shape color property" );
729 OSL_TRACE( "getDefault(): cannot extract '%s' shape color property",
730 OUStringToOString( rPropertyName,
731 RTL_TEXTENCODING_ASCII_US ).getStr() );
732 return RGBColor();
735 // convert from 0xAARRGGBB API color to 0xRRGGBB00
736 // canvas color
737 return RGBColor( (nValue << 8U) & 0xFFFFFF00U );
742 AnimationFactory::AttributeClass AnimationFactory::classifyAttributeName( const OUString& rAttrName )
744 // ATTENTION: When changing this map, also the create*PropertyAnimation() methods must
745 // be checked and possibly adapted in their switch statements
747 // TODO(Q2): Since this map must be coherent with the various switch statements
748 // in the create*PropertyAnimation methods, try to unify into a single method or table
749 switch( mapAttributeName( rAttrName ) )
751 default:
752 // FALLTHROUGH intended
753 case ATTRIBUTE_INVALID:
754 return CLASS_UNKNOWN_PROPERTY;
756 case ATTRIBUTE_CHAR_COLOR:
757 // FALLTHROUGH intended
758 case ATTRIBUTE_COLOR:
759 // FALLTHROUGH intended
760 case ATTRIBUTE_DIMCOLOR:
761 // FALLTHROUGH intended
762 case ATTRIBUTE_FILL_COLOR:
763 // FALLTHROUGH intended
764 case ATTRIBUTE_LINE_COLOR:
765 return CLASS_COLOR_PROPERTY;
767 case ATTRIBUTE_CHAR_FONT_NAME:
768 return CLASS_STRING_PROPERTY;
770 case ATTRIBUTE_VISIBILITY:
771 return CLASS_BOOL_PROPERTY;
773 case ATTRIBUTE_CHAR_HEIGHT:
774 // FALLTHROUGH intended
775 case ATTRIBUTE_CHAR_WEIGHT:
776 // FALLTHROUGH intended
777 case ATTRIBUTE_CHAR_ROTATION:
778 // FALLTHROUGH intended
779 case ATTRIBUTE_HEIGHT:
780 // FALLTHROUGH intended
781 case ATTRIBUTE_OPACITY:
782 // FALLTHROUGH intended
783 case ATTRIBUTE_ROTATE:
784 // FALLTHROUGH intended
785 case ATTRIBUTE_SKEW_X:
786 // FALLTHROUGH intended
787 case ATTRIBUTE_SKEW_Y:
788 // FALLTHROUGH intended
789 case ATTRIBUTE_WIDTH:
790 // FALLTHROUGH intended
791 case ATTRIBUTE_POS_X:
792 // FALLTHROUGH intended
793 case ATTRIBUTE_POS_Y:
794 return CLASS_NUMBER_PROPERTY;
796 case ATTRIBUTE_CHAR_UNDERLINE:
797 // FALLTHROUGH intended
798 case ATTRIBUTE_FILL_STYLE:
799 // FALLTHROUGH intended
800 case ATTRIBUTE_LINE_STYLE:
801 // FALLTHROUGH intended
802 case ATTRIBUTE_CHAR_POSTURE:
803 return CLASS_ENUM_PROPERTY;
807 NumberAnimationSharedPtr AnimationFactory::createNumberPropertyAnimation( const OUString& rAttrName,
808 const AnimatableShapeSharedPtr& rShape,
809 const ShapeManagerSharedPtr& rShapeManager,
810 const ::basegfx::B2DVector& rSlideSize,
811 int nFlags )
813 // ATTENTION: When changing this map, also the classifyAttributeName() method must
814 // be checked and possibly adapted in their switch statement
815 switch( mapAttributeName( rAttrName ) )
817 default:
818 // FALLTHROUGH intended
819 case ATTRIBUTE_INVALID:
820 ENSURE_OR_THROW( false,
821 "AnimationFactory::createNumberPropertyAnimation(): Unknown attribute" );
822 break;
824 case ATTRIBUTE_CHAR_COLOR:
825 // FALLTHROUGH intended
826 case ATTRIBUTE_CHAR_FONT_NAME:
827 // FALLTHROUGH intended
828 case ATTRIBUTE_CHAR_POSTURE:
829 // FALLTHROUGH intended
830 case ATTRIBUTE_CHAR_UNDERLINE:
831 // FALLTHROUGH intended
832 case ATTRIBUTE_COLOR:
833 // FALLTHROUGH intended
834 case ATTRIBUTE_DIMCOLOR:
835 // FALLTHROUGH intended
836 case ATTRIBUTE_FILL_COLOR:
837 // FALLTHROUGH intended
838 case ATTRIBUTE_FILL_STYLE:
839 // FALLTHROUGH intended
840 case ATTRIBUTE_LINE_COLOR:
841 // FALLTHROUGH intended
842 case ATTRIBUTE_LINE_STYLE:
843 // FALLTHROUGH intended
844 case ATTRIBUTE_VISIBILITY:
845 ENSURE_OR_THROW( false,
846 "AnimationFactory::createNumberPropertyAnimation(): Attribute type mismatch" );
847 break;
849 case ATTRIBUTE_CHAR_HEIGHT:
850 return makeGenericAnimation<NumberAnimation>( rShapeManager,
851 nFlags,
852 &ShapeAttributeLayer::isCharScaleValid,
853 1.0, // CharHeight is a relative attribute, thus
854 // default is 1.0
855 &ShapeAttributeLayer::getCharScale,
856 &ShapeAttributeLayer::setCharScale );
858 case ATTRIBUTE_CHAR_WEIGHT:
859 return makeGenericAnimation<NumberAnimation>( rShapeManager,
860 nFlags,
861 &ShapeAttributeLayer::isCharWeightValid,
862 getDefault<double>( rShape, rAttrName ),
863 &ShapeAttributeLayer::getCharWeight,
864 &ShapeAttributeLayer::setCharWeight );
866 case ATTRIBUTE_CHAR_ROTATION:
867 return makeGenericAnimation<NumberAnimation>( rShapeManager,
868 nFlags,
869 &ShapeAttributeLayer::isCharRotationAngleValid,
870 getDefault<double>( rShape, rAttrName ),
871 &ShapeAttributeLayer::getCharRotationAngle,
872 &ShapeAttributeLayer::setCharRotationAngle );
874 case ATTRIBUTE_HEIGHT:
875 return makeGenericAnimation( rShapeManager,
876 nFlags,
877 &ShapeAttributeLayer::isHeightValid,
878 // TODO(F1): Check whether _shape_ bounds are correct here.
879 // Theoretically, our AttrLayer is way down the stack, and
880 // we only have to consider _that_ value, not the one from
881 // the top of the stack as returned by Shape::getBounds()
882 rShape->getBounds().getHeight(),
883 &ShapeAttributeLayer::getHeight,
884 &ShapeAttributeLayer::setHeight,
885 // convert expression parser value from relative page size
886 rSlideSize.getY() );
888 case ATTRIBUTE_OPACITY:
889 return makeGenericAnimation<NumberAnimation>( rShapeManager,
890 nFlags,
891 &ShapeAttributeLayer::isAlphaValid,
892 // TODO(F1): Provide shape default here (FillTransparency?)
893 1.0,
894 &ShapeAttributeLayer::getAlpha,
895 &ShapeAttributeLayer::setAlpha );
897 case ATTRIBUTE_ROTATE:
898 return makeGenericAnimation<NumberAnimation>( rShapeManager,
899 nFlags,
900 &ShapeAttributeLayer::isRotationAngleValid,
901 // NOTE: Since we paint the shape as-is from metafile,
902 // rotation angle is always 0.0, even for rotated shapes
903 0.0,
904 &ShapeAttributeLayer::getRotationAngle,
905 &ShapeAttributeLayer::setRotationAngle );
907 case ATTRIBUTE_SKEW_X:
908 return makeGenericAnimation<NumberAnimation>( rShapeManager,
909 nFlags,
910 &ShapeAttributeLayer::isShearXAngleValid,
911 // TODO(F1): Is there any shape property for skew?
912 0.0,
913 &ShapeAttributeLayer::getShearXAngle,
914 &ShapeAttributeLayer::setShearXAngle );
916 case ATTRIBUTE_SKEW_Y:
917 return makeGenericAnimation<NumberAnimation>( rShapeManager,
918 nFlags,
919 &ShapeAttributeLayer::isShearYAngleValid,
920 // TODO(F1): Is there any shape property for skew?
921 0.0,
922 &ShapeAttributeLayer::getShearYAngle,
923 &ShapeAttributeLayer::setShearYAngle );
925 case ATTRIBUTE_WIDTH:
926 return makeGenericAnimation( rShapeManager,
927 nFlags,
928 &ShapeAttributeLayer::isWidthValid,
929 // TODO(F1): Check whether _shape_ bounds are correct here.
930 // Theoretically, our AttrLayer is way down the stack, and
931 // we only have to consider _that_ value, not the one from
932 // the top of the stack as returned by Shape::getBounds()
933 rShape->getBounds().getWidth(),
934 &ShapeAttributeLayer::getWidth,
935 &ShapeAttributeLayer::setWidth,
936 // convert expression parser value from relative page size
937 rSlideSize.getX() );
939 case ATTRIBUTE_POS_X:
940 return makeGenericAnimation( rShapeManager,
941 nFlags,
942 &ShapeAttributeLayer::isPosXValid,
943 // TODO(F1): Check whether _shape_ bounds are correct here.
944 // Theoretically, our AttrLayer is way down the stack, and
945 // we only have to consider _that_ value, not the one from
946 // the top of the stack as returned by Shape::getBounds()
947 rShape->getBounds().getCenterX(),
948 &ShapeAttributeLayer::getPosX,
949 &ShapeAttributeLayer::setPosX,
950 // convert expression parser value from relative page size
951 rSlideSize.getX() );
953 case ATTRIBUTE_POS_Y:
954 return makeGenericAnimation( rShapeManager,
955 nFlags,
956 &ShapeAttributeLayer::isPosYValid,
957 // TODO(F1): Check whether _shape_ bounds are correct here.
958 // Theoretically, our AttrLayer is way down the stack, and
959 // we only have to consider _that_ value, not the one from
960 // the top of the stack as returned by Shape::getBounds()
961 rShape->getBounds().getCenterY(),
962 &ShapeAttributeLayer::getPosY,
963 &ShapeAttributeLayer::setPosY,
964 // convert expression parser value from relative page size
965 rSlideSize.getY() );
968 return NumberAnimationSharedPtr();
971 EnumAnimationSharedPtr AnimationFactory::createEnumPropertyAnimation( const OUString& rAttrName,
972 const AnimatableShapeSharedPtr& rShape,
973 const ShapeManagerSharedPtr& rShapeManager,
974 const ::basegfx::B2DVector& /*rSlideSize*/,
975 int nFlags )
977 // ATTENTION: When changing this map, also the classifyAttributeName() method must
978 // be checked and possibly adapted in their switch statement
979 switch( mapAttributeName( rAttrName ) )
981 default:
982 // FALLTHROUGH intended
983 case ATTRIBUTE_INVALID:
984 ENSURE_OR_THROW( false,
985 "AnimationFactory::createEnumPropertyAnimation(): Unknown attribute" );
986 break;
988 case ATTRIBUTE_CHAR_COLOR:
989 // FALLTHROUGH intended
990 case ATTRIBUTE_CHAR_FONT_NAME:
991 // FALLTHROUGH intended
992 case ATTRIBUTE_COLOR:
993 // FALLTHROUGH intended
994 case ATTRIBUTE_DIMCOLOR:
995 // FALLTHROUGH intended
996 case ATTRIBUTE_FILL_COLOR:
997 // FALLTHROUGH intended
998 case ATTRIBUTE_LINE_COLOR:
999 // FALLTHROUGH intended
1000 case ATTRIBUTE_VISIBILITY:
1001 // FALLTHROUGH intended
1002 case ATTRIBUTE_CHAR_HEIGHT:
1003 // FALLTHROUGH intended
1004 case ATTRIBUTE_CHAR_WEIGHT:
1005 // FALLTHROUGH intended
1006 case ATTRIBUTE_CHAR_ROTATION:
1007 // FALLTHROUGH intended
1008 case ATTRIBUTE_HEIGHT:
1009 // FALLTHROUGH intended
1010 case ATTRIBUTE_OPACITY:
1011 // FALLTHROUGH intended
1012 case ATTRIBUTE_ROTATE:
1013 // FALLTHROUGH intended
1014 case ATTRIBUTE_SKEW_X:
1015 // FALLTHROUGH intended
1016 case ATTRIBUTE_SKEW_Y:
1017 // FALLTHROUGH intended
1018 case ATTRIBUTE_WIDTH:
1019 // FALLTHROUGH intended
1020 case ATTRIBUTE_POS_X:
1021 // FALLTHROUGH intended
1022 case ATTRIBUTE_POS_Y:
1023 ENSURE_OR_THROW( false,
1024 "AnimationFactory::createEnumPropertyAnimation(): Attribute type mismatch" );
1025 break;
1028 case ATTRIBUTE_FILL_STYLE:
1029 return makeGenericAnimation<EnumAnimation>( rShapeManager,
1030 nFlags,
1031 &ShapeAttributeLayer::isFillStyleValid,
1032 sal::static_int_cast<sal_Int16>(
1033 getDefault<drawing::FillStyle>( rShape, rAttrName )),
1034 &ShapeAttributeLayer::getFillStyle,
1035 &ShapeAttributeLayer::setFillStyle );
1037 case ATTRIBUTE_LINE_STYLE:
1038 return makeGenericAnimation<EnumAnimation>( rShapeManager,
1039 nFlags,
1040 &ShapeAttributeLayer::isLineStyleValid,
1041 sal::static_int_cast<sal_Int16>(
1042 getDefault<drawing::LineStyle>( rShape, rAttrName )),
1043 &ShapeAttributeLayer::getLineStyle,
1044 &ShapeAttributeLayer::setLineStyle );
1046 case ATTRIBUTE_CHAR_POSTURE:
1047 return makeGenericAnimation<EnumAnimation>( rShapeManager,
1048 nFlags,
1049 &ShapeAttributeLayer::isCharPostureValid,
1050 sal::static_int_cast<sal_Int16>(
1051 getDefault<awt::FontSlant>( rShape, rAttrName )),
1052 &ShapeAttributeLayer::getCharPosture,
1053 &ShapeAttributeLayer::setCharPosture );
1055 case ATTRIBUTE_CHAR_UNDERLINE:
1056 return makeGenericAnimation<EnumAnimation>( rShapeManager,
1057 nFlags,
1058 &ShapeAttributeLayer::isUnderlineModeValid,
1059 getDefault<sal_Int16>( rShape, rAttrName ),
1060 &ShapeAttributeLayer::getUnderlineMode,
1061 &ShapeAttributeLayer::setUnderlineMode );
1064 return EnumAnimationSharedPtr();
1067 ColorAnimationSharedPtr AnimationFactory::createColorPropertyAnimation( const OUString& rAttrName,
1068 const AnimatableShapeSharedPtr& rShape,
1069 const ShapeManagerSharedPtr& rShapeManager,
1070 const ::basegfx::B2DVector& /*rSlideSize*/,
1071 int nFlags )
1073 // ATTENTION: When changing this map, also the classifyAttributeName() method must
1074 // be checked and possibly adapted in their switch statement
1075 switch( mapAttributeName( rAttrName ) )
1077 default:
1078 // FALLTHROUGH intended
1079 case ATTRIBUTE_INVALID:
1080 ENSURE_OR_THROW( false,
1081 "AnimationFactory::createColorPropertyAnimation(): Unknown attribute" );
1082 break;
1084 case ATTRIBUTE_CHAR_FONT_NAME:
1085 // FALLTHROUGH intended
1086 case ATTRIBUTE_CHAR_HEIGHT:
1087 // FALLTHROUGH intended
1088 case ATTRIBUTE_CHAR_POSTURE:
1089 // FALLTHROUGH intended
1090 case ATTRIBUTE_CHAR_ROTATION:
1091 // FALLTHROUGH intended
1092 case ATTRIBUTE_CHAR_UNDERLINE:
1093 // FALLTHROUGH intended
1094 case ATTRIBUTE_CHAR_WEIGHT:
1095 // FALLTHROUGH intended
1096 case ATTRIBUTE_FILL_STYLE:
1097 // FALLTHROUGH intended
1098 case ATTRIBUTE_HEIGHT:
1099 // FALLTHROUGH intended
1100 case ATTRIBUTE_LINE_STYLE:
1101 // FALLTHROUGH intended
1102 case ATTRIBUTE_OPACITY:
1103 // FALLTHROUGH intended
1104 case ATTRIBUTE_ROTATE:
1105 // FALLTHROUGH intended
1106 case ATTRIBUTE_SKEW_X:
1107 // FALLTHROUGH intended
1108 case ATTRIBUTE_SKEW_Y:
1109 // FALLTHROUGH intended
1110 case ATTRIBUTE_VISIBILITY:
1111 // FALLTHROUGH intended
1112 case ATTRIBUTE_WIDTH:
1113 // FALLTHROUGH intended
1114 case ATTRIBUTE_POS_X:
1115 // FALLTHROUGH intended
1116 case ATTRIBUTE_POS_Y:
1117 ENSURE_OR_THROW( false,
1118 "AnimationFactory::createColorPropertyAnimation(): Attribute type mismatch" );
1119 break;
1121 case ATTRIBUTE_CHAR_COLOR:
1122 return makeGenericAnimation<ColorAnimation>( rShapeManager,
1123 nFlags,
1124 &ShapeAttributeLayer::isCharColorValid,
1125 getDefault<RGBColor>( rShape, rAttrName ),
1126 &ShapeAttributeLayer::getCharColor,
1127 &ShapeAttributeLayer::setCharColor );
1129 case ATTRIBUTE_COLOR:
1130 // TODO(F2): This is just mapped to fill color to make it work
1131 return makeGenericAnimation<ColorAnimation>( rShapeManager,
1132 nFlags,
1133 &ShapeAttributeLayer::isFillColorValid,
1134 getDefault<RGBColor>( rShape, rAttrName ),
1135 &ShapeAttributeLayer::getFillColor,
1136 &ShapeAttributeLayer::setFillColor );
1138 case ATTRIBUTE_DIMCOLOR:
1139 return makeGenericAnimation<ColorAnimation>( rShapeManager,
1140 nFlags,
1141 &ShapeAttributeLayer::isDimColorValid,
1142 getDefault<RGBColor>( rShape, rAttrName ),
1143 &ShapeAttributeLayer::getDimColor,
1144 &ShapeAttributeLayer::setDimColor );
1146 case ATTRIBUTE_FILL_COLOR:
1147 return makeGenericAnimation<ColorAnimation>( rShapeManager,
1148 nFlags,
1149 &ShapeAttributeLayer::isFillColorValid,
1150 getDefault<RGBColor>( rShape, rAttrName ),
1151 &ShapeAttributeLayer::getFillColor,
1152 &ShapeAttributeLayer::setFillColor );
1154 case ATTRIBUTE_LINE_COLOR:
1155 return makeGenericAnimation<ColorAnimation>( rShapeManager,
1156 nFlags,
1157 &ShapeAttributeLayer::isLineColorValid,
1158 getDefault<RGBColor>( rShape, rAttrName ),
1159 &ShapeAttributeLayer::getLineColor,
1160 &ShapeAttributeLayer::setLineColor );
1163 return ColorAnimationSharedPtr();
1166 PairAnimationSharedPtr AnimationFactory::createPairPropertyAnimation( const AnimatableShapeSharedPtr& rShape,
1167 const ShapeManagerSharedPtr& rShapeManager,
1168 const ::basegfx::B2DVector& rSlideSize,
1169 sal_Int16 nTransformType,
1170 int nFlags )
1172 const ::basegfx::B2DRectangle& rBounds( rShape->getBounds() );
1174 switch( nTransformType )
1176 case animations::AnimationTransformType::SCALE:
1177 return PairAnimationSharedPtr(
1178 new TupleAnimation< ::basegfx::B2DSize >(
1179 rShapeManager,
1180 nFlags,
1181 &ShapeAttributeLayer::isWidthValid,
1182 &ShapeAttributeLayer::isHeightValid,
1183 // TODO(F1): Check whether _shape_ bounds are correct here.
1184 // Theoretically, our AttrLayer is way down the stack, and
1185 // we only have to consider _that_ value, not the one from
1186 // the top of the stack as returned by Shape::getBounds()
1187 rBounds.getRange(),
1188 rBounds.getRange(),
1189 &ShapeAttributeLayer::getWidth,
1190 &ShapeAttributeLayer::getHeight,
1191 &ShapeAttributeLayer::setSize ) );
1193 case animations::AnimationTransformType::TRANSLATE:
1194 return PairAnimationSharedPtr(
1195 new TupleAnimation< ::basegfx::B2DPoint >(
1196 rShapeManager,
1197 nFlags,
1198 &ShapeAttributeLayer::isPosXValid,
1199 &ShapeAttributeLayer::isPosYValid,
1200 // TODO(F1): Check whether _shape_ bounds are correct here.
1201 // Theoretically, our AttrLayer is way down the stack, and
1202 // we only have to consider _that_ value, not the one from
1203 // the top of the stack as returned by Shape::getBounds()
1204 rBounds.getCenter(),
1205 rSlideSize,
1206 &ShapeAttributeLayer::getPosX,
1207 &ShapeAttributeLayer::getPosY,
1208 &ShapeAttributeLayer::setPosition ) );
1210 default:
1211 ENSURE_OR_THROW( false,
1212 "AnimationFactory::createPairPropertyAnimation(): Attribute type mismatch" );
1213 break;
1216 return PairAnimationSharedPtr();
1219 StringAnimationSharedPtr AnimationFactory::createStringPropertyAnimation( const OUString& rAttrName,
1220 const AnimatableShapeSharedPtr& rShape,
1221 const ShapeManagerSharedPtr& rShapeManager,
1222 const ::basegfx::B2DVector& /*rSlideSize*/,
1223 int nFlags )
1225 // ATTENTION: When changing this map, also the classifyAttributeName() method must
1226 // be checked and possibly adapted in their switch statement
1227 switch( mapAttributeName( rAttrName ) )
1229 default:
1230 // FALLTHROUGH intended
1231 case ATTRIBUTE_INVALID:
1232 ENSURE_OR_THROW( false,
1233 "AnimationFactory::createStringPropertyAnimation(): Unknown attribute" );
1234 break;
1236 case ATTRIBUTE_CHAR_COLOR:
1237 // FALLTHROUGH intended
1238 case ATTRIBUTE_CHAR_HEIGHT:
1239 // FALLTHROUGH intended
1240 case ATTRIBUTE_CHAR_ROTATION:
1241 // FALLTHROUGH intended
1242 case ATTRIBUTE_CHAR_UNDERLINE:
1243 // FALLTHROUGH intended
1244 case ATTRIBUTE_COLOR:
1245 // FALLTHROUGH intended
1246 case ATTRIBUTE_DIMCOLOR:
1247 // FALLTHROUGH intended
1248 case ATTRIBUTE_FILL_COLOR:
1249 // FALLTHROUGH intended
1250 case ATTRIBUTE_HEIGHT:
1251 // FALLTHROUGH intended
1252 case ATTRIBUTE_LINE_COLOR:
1253 // FALLTHROUGH intended
1254 case ATTRIBUTE_OPACITY:
1255 // FALLTHROUGH intended
1256 case ATTRIBUTE_ROTATE:
1257 // FALLTHROUGH intended
1258 case ATTRIBUTE_SKEW_X:
1259 // FALLTHROUGH intended
1260 case ATTRIBUTE_SKEW_Y:
1261 // FALLTHROUGH intended
1262 case ATTRIBUTE_VISIBILITY:
1263 // FALLTHROUGH intended
1264 case ATTRIBUTE_WIDTH:
1265 // FALLTHROUGH intended
1266 case ATTRIBUTE_POS_X:
1267 // FALLTHROUGH intended
1268 case ATTRIBUTE_POS_Y:
1269 // FALLTHROUGH intended
1270 case ATTRIBUTE_CHAR_POSTURE:
1271 // FALLTHROUGH intended
1272 case ATTRIBUTE_CHAR_WEIGHT:
1273 // FALLTHROUGH intended
1274 case ATTRIBUTE_FILL_STYLE:
1275 // FALLTHROUGH intended
1276 case ATTRIBUTE_LINE_STYLE:
1277 ENSURE_OR_THROW( false,
1278 "AnimationFactory::createStringPropertyAnimation(): Attribute type mismatch" );
1279 break;
1281 case ATTRIBUTE_CHAR_FONT_NAME:
1282 return makeGenericAnimation<StringAnimation>( rShapeManager,
1283 nFlags,
1284 &ShapeAttributeLayer::isFontFamilyValid,
1285 getDefault< OUString >( rShape, rAttrName ),
1286 &ShapeAttributeLayer::getFontFamily,
1287 &ShapeAttributeLayer::setFontFamily );
1290 return StringAnimationSharedPtr();
1293 BoolAnimationSharedPtr AnimationFactory::createBoolPropertyAnimation( const OUString& rAttrName,
1294 const AnimatableShapeSharedPtr& /*rShape*/,
1295 const ShapeManagerSharedPtr& rShapeManager,
1296 const ::basegfx::B2DVector& /*rSlideSize*/,
1297 int nFlags )
1299 // ATTENTION: When changing this map, also the classifyAttributeName() method must
1300 // be checked and possibly adapted in their switch statement
1301 switch( mapAttributeName( rAttrName ) )
1303 default:
1304 // FALLTHROUGH intended
1305 case ATTRIBUTE_INVALID:
1306 ENSURE_OR_THROW( false,
1307 "AnimationFactory::createBoolPropertyAnimation(): Unknown attribute" );
1308 break;
1310 case ATTRIBUTE_CHAR_COLOR:
1311 // FALLTHROUGH intended
1312 case ATTRIBUTE_CHAR_FONT_NAME:
1313 // FALLTHROUGH intended
1314 case ATTRIBUTE_CHAR_HEIGHT:
1315 // FALLTHROUGH intended
1316 case ATTRIBUTE_CHAR_POSTURE:
1317 // FALLTHROUGH intended
1318 case ATTRIBUTE_CHAR_ROTATION:
1319 // FALLTHROUGH intended
1320 case ATTRIBUTE_CHAR_WEIGHT:
1321 // FALLTHROUGH intended
1322 case ATTRIBUTE_COLOR:
1323 // FALLTHROUGH intended
1324 case ATTRIBUTE_DIMCOLOR:
1325 // FALLTHROUGH intended
1326 case ATTRIBUTE_FILL_COLOR:
1327 // FALLTHROUGH intended
1328 case ATTRIBUTE_FILL_STYLE:
1329 // FALLTHROUGH intended
1330 case ATTRIBUTE_HEIGHT:
1331 // FALLTHROUGH intended
1332 case ATTRIBUTE_LINE_COLOR:
1333 // FALLTHROUGH intended
1334 case ATTRIBUTE_LINE_STYLE:
1335 // FALLTHROUGH intended
1336 case ATTRIBUTE_OPACITY:
1337 // FALLTHROUGH intended
1338 case ATTRIBUTE_ROTATE:
1339 // FALLTHROUGH intended
1340 case ATTRIBUTE_SKEW_X:
1341 // FALLTHROUGH intended
1342 case ATTRIBUTE_SKEW_Y:
1343 // FALLTHROUGH intended
1344 case ATTRIBUTE_WIDTH:
1345 // FALLTHROUGH intended
1346 case ATTRIBUTE_POS_X:
1347 // FALLTHROUGH intended
1348 case ATTRIBUTE_POS_Y:
1349 // FALLTHROUGH intended
1350 case ATTRIBUTE_CHAR_UNDERLINE:
1351 ENSURE_OR_THROW( false,
1352 "AnimationFactory::createBoolPropertyAnimation(): Attribute type mismatch" );
1353 break;
1355 case ATTRIBUTE_VISIBILITY:
1356 return makeGenericAnimation<BoolAnimation>( rShapeManager,
1357 nFlags,
1358 &ShapeAttributeLayer::isVisibilityValid,
1359 // TODO(F1): Is there a corresponding shape property?
1360 true,
1361 &ShapeAttributeLayer::getVisibility,
1362 &ShapeAttributeLayer::setVisibility );
1365 return BoolAnimationSharedPtr();
1368 NumberAnimationSharedPtr AnimationFactory::createPathMotionAnimation( const OUString& rSVGDPath,
1369 sal_Int16 nAdditive,
1370 const AnimatableShapeSharedPtr& /*rShape*/,
1371 const ShapeManagerSharedPtr& rShapeManager,
1372 const ::basegfx::B2DVector& rSlideSize,
1373 int nFlags )
1375 return NumberAnimationSharedPtr(
1376 new PathAnimation( rSVGDPath, nAdditive,
1377 rShapeManager,
1378 rSlideSize,
1379 nFlags ) );
1385 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */