build fix
[LibreOffice.git] / slideshow / source / engine / animationfactory.cxx
blobadfedb51215ac13a64b3c9b63336fd9bc0b24f3f
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 #include <tools/diagnose_ex.h>
23 #include <animationfactory.hxx>
24 #include <attributemap.hxx>
26 #include <com/sun/star/animations/AnimationAdditiveMode.hpp>
27 #include <com/sun/star/animations/AnimationTransformType.hpp>
28 #include <com/sun/star/beans/XPropertySet.hpp>
29 #include <com/sun/star/drawing/FillStyle.hpp>
30 #include <com/sun/star/drawing/LineStyle.hpp>
31 #include <com/sun/star/awt/FontSlant.hpp>
32 #include <com/sun/star/awt/FontUnderline.hpp>
33 #include <com/sun/star/awt/FontWeight.hpp>
35 #include <basegfx/polygon/b2dpolygon.hxx>
36 #include <basegfx/polygon/b2dpolygontools.hxx>
37 #include <basegfx/polygon/b2dpolypolygontools.hxx>
39 #include <functional>
42 using namespace ::com::sun::star;
45 namespace slideshow
47 namespace internal
49 namespace
51 // attention, there is a similar implementation of Animation in
52 // transitions/transitionfactory.cxx
54 template< typename ValueT > class TupleAnimation : public PairAnimation
56 public:
57 TupleAnimation( const ShapeManagerSharedPtr& rShapeManager,
58 int nFlags,
59 bool (ShapeAttributeLayer::*pIs1stValid)() const,
60 bool (ShapeAttributeLayer::*pIs2ndValid)() const,
61 const ValueT& rDefaultValue,
62 const ::basegfx::B2DSize& rReferenceSize,
63 double (ShapeAttributeLayer::*pGet1stValue)() const,
64 double (ShapeAttributeLayer::*pGet2ndValue)() const,
65 void (ShapeAttributeLayer::*pSetValue)( const ValueT& ) ) :
66 mpShape(),
67 mpAttrLayer(),
68 mpShapeManager( rShapeManager ),
69 mpIs1stValidFunc(pIs1stValid),
70 mpIs2ndValidFunc(pIs2ndValid),
71 mpGet1stValueFunc(pGet1stValue),
72 mpGet2ndValueFunc(pGet2ndValue),
73 mpSetValueFunc(pSetValue),
74 mnFlags( nFlags ),
75 maReferenceSize( rReferenceSize ),
76 maDefaultValue( rDefaultValue ),
77 mbAnimationStarted( false )
79 ENSURE_OR_THROW( rShapeManager,
80 "TupleAnimation::TupleAnimation(): Invalid ShapeManager" );
81 ENSURE_OR_THROW( pIs1stValid && pIs2ndValid && pGet1stValue && pGet2ndValue && pSetValue,
82 "TupleAnimation::TupleAnimation(): One of the method pointers is NULL" );
85 virtual ~TupleAnimation() override
87 end_();
90 // Animation interface
92 virtual void prefetch( const AnimatableShapeSharedPtr&,
93 const ShapeAttributeLayerSharedPtr& ) override
96 virtual void start( const AnimatableShapeSharedPtr& rShape,
97 const ShapeAttributeLayerSharedPtr& rAttrLayer ) override
99 OSL_ENSURE( !mpShape,
100 "TupleAnimation::start(): Shape already set" );
101 OSL_ENSURE( !mpAttrLayer,
102 "TupleAnimation::start(): Attribute layer already set" );
104 mpShape = rShape;
105 mpAttrLayer = rAttrLayer;
107 ENSURE_OR_THROW( rShape,
108 "TupleAnimation::start(): Invalid shape" );
109 ENSURE_OR_THROW( rAttrLayer,
110 "TupleAnimation::start(): Invalid attribute layer" );
112 if( !mbAnimationStarted )
114 mbAnimationStarted = true;
116 if( !(mnFlags & AnimationFactory::FLAG_NO_SPRITE) )
117 mpShapeManager->enterAnimationMode( mpShape );
121 virtual void end() override { end_(); }
122 void end_()
124 if( mbAnimationStarted )
126 mbAnimationStarted = false;
128 if( !(mnFlags & AnimationFactory::FLAG_NO_SPRITE) )
129 mpShapeManager->leaveAnimationMode( mpShape );
131 if( mpShape->isContentChanged() )
132 mpShapeManager->notifyShapeUpdate( mpShape );
136 // PairAnimation interface
139 virtual bool operator()( const ::basegfx::B2DTuple& rValue ) override
141 ENSURE_OR_RETURN_FALSE( mpAttrLayer && mpShape,
142 "TupleAnimation::operator(): Invalid ShapeAttributeLayer" );
144 ValueT aValue( rValue.getX(),
145 rValue.getY() );
147 // Activities get values from the expression parser,
148 // which returns _relative_ sizes/positions.
149 // Convert back relative to reference coordinate system
150 aValue *= maReferenceSize;
152 ((*mpAttrLayer).*mpSetValueFunc)( aValue );
154 if( mpShape->isContentChanged() )
155 mpShapeManager->notifyShapeUpdate( mpShape );
157 return true;
160 virtual ::basegfx::B2DTuple getUnderlyingValue() const override
162 ENSURE_OR_THROW( mpAttrLayer,
163 "TupleAnimation::getUnderlyingValue(): Invalid ShapeAttributeLayer" );
165 ::basegfx::B2DTuple aRetVal;
167 // deviated from the (*shared_ptr).*mpFuncPtr
168 // notation here, since gcc does not seem to parse
169 // that as a member function call anymore.
170 aRetVal.setX( (mpAttrLayer.get()->*mpIs1stValidFunc)() ?
171 (mpAttrLayer.get()->*mpGet1stValueFunc)() :
172 maDefaultValue.getX() );
173 aRetVal.setY( (mpAttrLayer.get()->*mpIs2ndValidFunc)() ?
174 (mpAttrLayer.get()->*mpGet2ndValueFunc)() :
175 maDefaultValue.getY() );
177 // Activities get values from the expression
178 // parser, which returns _relative_
179 // sizes/positions. Convert start value to the
180 // same coordinate space (i.e. relative to given
181 // reference size).
182 aRetVal /= maReferenceSize;
184 return aRetVal;
187 private:
188 AnimatableShapeSharedPtr mpShape;
189 ShapeAttributeLayerSharedPtr mpAttrLayer;
190 ShapeManagerSharedPtr mpShapeManager;
191 bool (ShapeAttributeLayer::*mpIs1stValidFunc)() const;
192 bool (ShapeAttributeLayer::*mpIs2ndValidFunc)() const;
193 double (ShapeAttributeLayer::*mpGet1stValueFunc)() const;
194 double (ShapeAttributeLayer::*mpGet2ndValueFunc)() const;
195 void (ShapeAttributeLayer::*mpSetValueFunc)( const ValueT& );
197 const int mnFlags;
199 const ::basegfx::B2DSize maReferenceSize;
200 const ValueT maDefaultValue;
201 bool mbAnimationStarted;
205 class PathAnimation : public NumberAnimation
207 public:
208 PathAnimation( const OUString& rSVGDPath,
209 sal_Int16 nAdditive,
210 const ShapeManagerSharedPtr& rShapeManager,
211 const ::basegfx::B2DVector& rSlideSize,
212 int nFlags ) :
213 maPathPoly(),
214 mpShape(),
215 mpAttrLayer(),
216 mpShapeManager( rShapeManager ),
217 maPageSize( rSlideSize ),
218 maShapeOrig(),
219 mnFlags( nFlags ),
220 mbAnimationStarted( false ),
221 mnAdditive( nAdditive )
223 ENSURE_OR_THROW( rShapeManager,
224 "PathAnimation::PathAnimation(): Invalid ShapeManager" );
226 ::basegfx::B2DPolyPolygon aPolyPoly;
228 ENSURE_OR_THROW( ::basegfx::tools::importFromSvgD( aPolyPoly, rSVGDPath, false, nullptr ),
229 "PathAnimation::PathAnimation(): failed to parse SVG:d path" );
230 ENSURE_OR_THROW( aPolyPoly.count() == 1,
231 "PathAnimation::PathAnimation(): motion path consists of multiple/zero polygon(s)" );
233 // TODO(F2): Since getPositionRelative() currently
234 // cannot handle beziers, have to subdivide.
235 // AW: Should be no longer necessary; getPositionRelative is now bezier-safe
236 maPathPoly = ::basegfx::tools::adaptiveSubdivideByAngle(aPolyPoly.getB2DPolygon(0) );
239 virtual ~PathAnimation() override
241 end_();
244 // Animation interface
246 virtual void prefetch( const AnimatableShapeSharedPtr&,
247 const ShapeAttributeLayerSharedPtr& ) override
250 virtual void start( const AnimatableShapeSharedPtr& rShape,
251 const ShapeAttributeLayerSharedPtr& rAttrLayer ) override
253 OSL_ENSURE( !mpShape,
254 "PathAnimation::start(): Shape already set" );
255 OSL_ENSURE( !mpAttrLayer,
256 "PathAnimation::start(): Attribute layer already set" );
258 mpShape = rShape;
259 mpAttrLayer = rAttrLayer;
261 ENSURE_OR_THROW( rShape,
262 "PathAnimation::start(): Invalid shape" );
263 ENSURE_OR_THROW( rAttrLayer,
264 "PathAnimation::start(): Invalid attribute layer" );
266 // TODO(F1): Check whether _shape_ bounds are correct here.
267 // Theoretically, our AttrLayer is way down the stack, and
268 // we only have to consider _that_ value, not the one from
269 // the top of the stack as returned by Shape::getBounds()
270 if( mnAdditive == animations::AnimationAdditiveMode::SUM )
271 maShapeOrig = mpShape->getBounds().getCenter();
272 else
273 maShapeOrig = mpShape->getDomBounds().getCenter();
275 if( !mbAnimationStarted )
277 mbAnimationStarted = true;
279 if( !(mnFlags & AnimationFactory::FLAG_NO_SPRITE) )
280 mpShapeManager->enterAnimationMode( mpShape );
284 virtual void end() override { end_(); }
285 void end_()
287 if( mbAnimationStarted )
289 mbAnimationStarted = false;
291 if( !(mnFlags & AnimationFactory::FLAG_NO_SPRITE) )
292 mpShapeManager->leaveAnimationMode( mpShape );
294 if( mpShape->isContentChanged() )
295 mpShapeManager->notifyShapeUpdate( mpShape );
299 // NumberAnimation interface
302 virtual bool operator()( double nValue ) override
304 ENSURE_OR_RETURN_FALSE( mpAttrLayer && mpShape,
305 "PathAnimation::operator(): Invalid ShapeAttributeLayer" );
307 ::basegfx::B2DPoint rOutPos = ::basegfx::tools::getPositionRelative( maPathPoly,
308 nValue );
310 // TODO(F1): Determine whether the path is
311 // absolute, or shape-relative.
313 // interpret path as page-relative. Scale up with page size
314 rOutPos *= maPageSize;
316 // TODO(F1): Determine whether the path origin is
317 // absolute, or shape-relative.
319 // interpret path as shape-originated. Offset to shape position
321 rOutPos += maShapeOrig;
323 mpAttrLayer->setPosition( rOutPos );
325 if( mpShape->isContentChanged() )
326 mpShapeManager->notifyShapeUpdate( mpShape );
328 return true;
331 virtual double getUnderlyingValue() const override
333 ENSURE_OR_THROW( mpAttrLayer,
334 "PathAnimation::getUnderlyingValue(): Invalid ShapeAttributeLayer" );
336 return 0.0; // though this should be used in concert with
337 // ActivitiesFactory::createSimpleActivity, better
338 // explicitly name our start value.
339 // Permissible range for operator() above is [0,1]
342 private:
343 ::basegfx::B2DPolygon maPathPoly;
344 AnimatableShapeSharedPtr mpShape;
345 ShapeAttributeLayerSharedPtr mpAttrLayer;
346 ShapeManagerSharedPtr mpShapeManager;
347 const ::basegfx::B2DSize maPageSize;
348 ::basegfx::B2DPoint maShapeOrig;
349 const int mnFlags;
350 bool mbAnimationStarted;
351 sal_Int16 mnAdditive;
355 /** GenericAnimation template
357 This template makes heavy use of SFINAE, only one of
358 the operator()() methods will compile for each of the
359 base classes.
361 Note that we omit the virtual keyword on the
362 operator()() overrides and getUnderlyingValue() methods on
363 purpose; those that actually do override baseclass
364 virtual methods inherit the property, and the others
365 won't increase our vtable. What's more, having all
366 those methods in the vtable actually creates POIs for
367 them, which breaks the whole SFINAE concept (IOW, this
368 template won't compile any longer).
370 @tpl AnimationBase
371 Type of animation to generate (determines the
372 interface GenericAnimation will implement). Must be
373 one of NumberAnimation, ColorAnimation,
374 StringAnimation, PairAnimation or BoolAnimation.
376 @tpl ModifierFunctor
377 Type of a functor object, which can optionally be used to
378 modify the getter/setter values.
380 template< typename AnimationBase, typename ModifierFunctor > class GenericAnimation : public AnimationBase
382 public:
383 typedef typename AnimationBase::ValueType ValueT;
385 /** Create generic animation
387 @param pIsValid
388 Function pointer to one of the is*Valid
389 methods. Used to either take the given getter
390 method, or the given default value for the start value.
392 @param rDefaultValue
393 Default value, to take as the start value if
394 is*Valid returns false.
396 @param pGetValue
397 Getter method, to fetch start value if valid.
399 @param pSetValue
400 Setter method. This one puts the current animation
401 value to the ShapeAttributeLayer.
403 @param rGetterModifier
404 Modifies up values retrieved from the pGetValue method.
405 Must provide operator()( const ValueT& ) method.
407 @param rSetterModifier
408 Modifies up values before passing them to the pSetValue method.
409 Must provide operator()( const ValueT& ) method.
411 GenericAnimation( const ShapeManagerSharedPtr& rShapeManager,
412 int nFlags,
413 bool (ShapeAttributeLayer::*pIsValid)() const,
414 const ValueT& rDefaultValue,
415 ValueT (ShapeAttributeLayer::*pGetValue)() const,
416 void (ShapeAttributeLayer::*pSetValue)( const ValueT& ),
417 const ModifierFunctor& rGetterModifier,
418 const ModifierFunctor& rSetterModifier ) :
419 mpShape(),
420 mpAttrLayer(),
421 mpShapeManager( rShapeManager ),
422 mpIsValidFunc(pIsValid),
423 mpGetValueFunc(pGetValue),
424 mpSetValueFunc(pSetValue),
425 maGetterModifier( rGetterModifier ),
426 maSetterModifier( rSetterModifier ),
427 mnFlags( nFlags ),
428 maDefaultValue(rDefaultValue),
429 mbAnimationStarted( false )
431 ENSURE_OR_THROW( rShapeManager,
432 "GenericAnimation::GenericAnimation(): Invalid ShapeManager" );
433 ENSURE_OR_THROW( pIsValid && pGetValue && pSetValue,
434 "GenericAnimation::GenericAnimation(): One of the method pointers is NULL" );
437 ~GenericAnimation()
439 end();
442 // Animation interface
444 virtual void prefetch( const AnimatableShapeSharedPtr&,
445 const ShapeAttributeLayerSharedPtr& )
448 virtual void start( const AnimatableShapeSharedPtr& rShape,
449 const ShapeAttributeLayerSharedPtr& rAttrLayer )
451 OSL_ENSURE( !mpShape,
452 "GenericAnimation::start(): Shape already set" );
453 OSL_ENSURE( !mpAttrLayer,
454 "GenericAnimation::start(): Attribute layer already set" );
456 mpShape = rShape;
457 mpAttrLayer = rAttrLayer;
459 ENSURE_OR_THROW( rShape,
460 "GenericAnimation::start(): Invalid shape" );
461 ENSURE_OR_THROW( rAttrLayer,
462 "GenericAnimation::start(): Invalid attribute layer" );
464 // only start animation once per repeated start() call,
465 // and only if sprites should be used for display
466 if( !mbAnimationStarted )
468 mbAnimationStarted = true;
470 if( !(mnFlags & AnimationFactory::FLAG_NO_SPRITE) )
471 mpShapeManager->enterAnimationMode( mpShape );
475 void end()
477 // TODO(Q2): Factor out common code (most
478 // prominently start() and end()) into base class
480 // only stop animation once per repeated end() call,
481 // and only if sprites are used for display
482 if( mbAnimationStarted )
484 mbAnimationStarted = false;
486 if( !(mnFlags & AnimationFactory::FLAG_NO_SPRITE) )
487 mpShapeManager->leaveAnimationMode( mpShape );
489 // Attention, this notifyShapeUpdate() is
490 // somewhat delicate here. Calling it
491 // unconditional (i.e. not guarded by
492 // mbAnimationStarted) will lead to shapes
493 // snapping back to their original state just
494 // before the slide ends. Not calling it at
495 // all might swallow final animation
496 // states. The current implementation relies
497 // on the fact that end() is either called by
498 // the Activity (then, the last animation
499 // state has been set, and corresponds to the
500 // shape's hold state), or by the animation
501 // node (then, it's a forced end, and we
502 // _have_ to snap back).
504 // To reiterate: normally, we're called from
505 // the Activity first, thus the
506 // notifyShapeUpdate() below will update to
507 // the last activity value.
509 // force shape update, activity might have changed
510 // state in the last round.
511 if( mpShape->isContentChanged() )
512 mpShapeManager->notifyShapeUpdate( mpShape );
516 // Derived Animation interface
519 /** For by-reference interfaces (B2DTuple, OUString)
521 bool operator()( const ValueT& x )
523 ENSURE_OR_RETURN_FALSE( mpAttrLayer && mpShape,
524 "GenericAnimation::operator(): Invalid ShapeAttributeLayer" );
526 ((*mpAttrLayer).*mpSetValueFunc)( maSetterModifier( x ) );
528 if( mpShape->isContentChanged() )
529 mpShapeManager->notifyShapeUpdate( mpShape );
531 return true;
534 /** For by-value interfaces (bool, double)
536 bool operator()( ValueT x )
538 ENSURE_OR_RETURN_FALSE( mpAttrLayer && mpShape,
539 "GenericAnimation::operator(): Invalid ShapeAttributeLayer" );
541 ((*mpAttrLayer).*mpSetValueFunc)( maSetterModifier( x ) );
543 if( mpShape->isContentChanged() )
544 mpShapeManager->notifyShapeUpdate( mpShape );
546 return true;
549 ValueT getUnderlyingValue() const
551 ENSURE_OR_THROW( mpAttrLayer,
552 "GenericAnimation::getUnderlyingValue(): Invalid ShapeAttributeLayer" );
554 // deviated from the (*shared_ptr).*mpFuncPtr
555 // notation here, since gcc does not seem to parse
556 // that as a member function call anymore.
557 if( (mpAttrLayer.get()->*mpIsValidFunc)() )
558 return maGetterModifier( ((*mpAttrLayer).*mpGetValueFunc)() );
559 else
560 return maDefaultValue;
563 private:
564 AnimatableShapeSharedPtr mpShape;
565 ShapeAttributeLayerSharedPtr mpAttrLayer;
566 ShapeManagerSharedPtr mpShapeManager;
567 bool (ShapeAttributeLayer::*mpIsValidFunc)() const;
568 ValueT (ShapeAttributeLayer::*mpGetValueFunc)() const;
569 void (ShapeAttributeLayer::*mpSetValueFunc)( const ValueT& );
571 ModifierFunctor maGetterModifier;
572 ModifierFunctor maSetterModifier;
574 const int mnFlags;
576 const ValueT maDefaultValue;
577 bool mbAnimationStarted;
580 //Current c++0x draft (apparently) has std::identity, but not operator()
581 template<typename T> struct SGI_identity : public std::unary_function<T,T>
583 T& operator()(T& x) const { return x; }
584 const T& operator()(const T& x) const { return x; }
587 /** Function template wrapper around GenericAnimation template
589 @tpl AnimationBase
590 Type of animation to generate (determines the
591 interface GenericAnimation will implement).
593 template< typename AnimationBase > ::std::shared_ptr< AnimationBase >
594 makeGenericAnimation( const ShapeManagerSharedPtr& rShapeManager,
595 int nFlags,
596 bool (ShapeAttributeLayer::*pIsValid)() const,
597 const typename AnimationBase::ValueType& rDefaultValue,
598 typename AnimationBase::ValueType (ShapeAttributeLayer::*pGetValue)() const,
599 void (ShapeAttributeLayer::*pSetValue)( const typename AnimationBase::ValueType& ) )
601 return ::std::shared_ptr< AnimationBase >(
602 new GenericAnimation< AnimationBase,
603 SGI_identity< typename AnimationBase::ValueType > >(
604 rShapeManager,
605 nFlags,
606 pIsValid,
607 rDefaultValue,
608 pGetValue,
609 pSetValue,
610 // no modification necessary, use identity functor here
611 SGI_identity< typename AnimationBase::ValueType >(),
612 SGI_identity< typename AnimationBase::ValueType >() ) );
615 class Scaler
617 public:
618 explicit Scaler( double nScale ) :
619 mnScale( nScale )
623 double operator()( double nVal ) const
625 return mnScale * nVal;
628 private:
629 double mnScale;
632 /** Overload for NumberAnimations which need scaling (width,height,x,y currently)
634 NumberAnimationSharedPtr makeGenericAnimation( const ShapeManagerSharedPtr& rShapeManager,
635 int nFlags,
636 bool (ShapeAttributeLayer::*pIsValid)() const,
637 double nDefaultValue,
638 double (ShapeAttributeLayer::*pGetValue)() const,
639 void (ShapeAttributeLayer::*pSetValue)( const double& ),
640 double nScaleValue )
642 return NumberAnimationSharedPtr(
643 new GenericAnimation< NumberAnimation, Scaler >( rShapeManager,
644 nFlags,
645 pIsValid,
646 nDefaultValue / nScaleValue,
647 pGetValue,
648 pSetValue,
649 Scaler( 1.0/nScaleValue ),
650 Scaler( nScaleValue ) ) );
654 uno::Any getShapeDefault( const AnimatableShapeSharedPtr& rShape,
655 const OUString& rPropertyName )
657 uno::Reference< drawing::XShape > xShape( rShape->getXShape() );
659 if( !xShape.is() )
660 return uno::Any(); // no regular shape, no defaults available
663 // extract relevant value from XShape's PropertySet
664 uno::Reference< beans::XPropertySet > xPropSet( xShape,
665 uno::UNO_QUERY );
667 ENSURE_OR_THROW( xPropSet.is(),
668 "getShapeDefault(): Cannot query property set from shape" );
670 return xPropSet->getPropertyValue( rPropertyName );
673 template< typename ValueType > ValueType getDefault( const AnimatableShapeSharedPtr& rShape,
674 const OUString& rPropertyName )
676 const uno::Any& rAny( getShapeDefault( rShape,
677 rPropertyName ) );
679 if( !rAny.hasValue() )
681 OSL_FAIL( "getDefault(): cannot get requested shape property" );
682 OSL_TRACE( "getDefault(): cannot get '%s' shape property",
683 OUStringToOString( rPropertyName,
684 RTL_TEXTENCODING_ASCII_US ).getStr() );
685 return ValueType();
687 else
689 ValueType aValue = ValueType();
691 if( !(rAny >>= aValue) )
693 OSL_FAIL( "getDefault(): cannot extract requested shape property" );
694 OSL_TRACE( "getDefault(): cannot extract '%s' shape property",
695 OUStringToOString( rPropertyName,
696 RTL_TEXTENCODING_ASCII_US ).getStr() );
697 return ValueType();
700 return aValue;
704 template<> RGBColor getDefault< RGBColor >( const AnimatableShapeSharedPtr& rShape,
705 const OUString& rPropertyName )
707 const uno::Any& rAny( getShapeDefault( rShape,
708 rPropertyName ) );
710 if( !rAny.hasValue() )
712 OSL_FAIL( "getDefault(): cannot get requested shape color property" );
713 OSL_TRACE( "getDefault(): cannot get '%s' shape color property",
714 OUStringToOString( rPropertyName,
715 RTL_TEXTENCODING_ASCII_US ).getStr() );
716 return RGBColor();
718 else
720 sal_Int32 nValue = 0;
722 if( !(rAny >>= nValue) )
724 OSL_FAIL( "getDefault(): cannot extract requested shape color property" );
725 OSL_TRACE( "getDefault(): cannot extract '%s' shape color property",
726 OUStringToOString( rPropertyName,
727 RTL_TEXTENCODING_ASCII_US ).getStr() );
728 return RGBColor();
731 // convert from 0xAARRGGBB API color to 0xRRGGBB00
732 // canvas color
733 return RGBColor( (nValue << 8U) & 0xFFFFFF00U );
738 AnimationFactory::AttributeClass AnimationFactory::classifyAttributeName( const OUString& rAttrName )
740 // ATTENTION: When changing this map, also the create*PropertyAnimation() methods must
741 // be checked and possibly adapted in their switch statements
743 // TODO(Q2): Since this map must be coherent with the various switch statements
744 // in the create*PropertyAnimation methods, try to unify into a single method or table
745 switch( mapAttributeName( rAttrName ) )
747 default:
748 // FALLTHROUGH intended
749 case ATTRIBUTE_INVALID:
750 return CLASS_UNKNOWN_PROPERTY;
752 case ATTRIBUTE_CHAR_COLOR:
753 // FALLTHROUGH intended
754 case ATTRIBUTE_COLOR:
755 // FALLTHROUGH intended
756 case ATTRIBUTE_DIMCOLOR:
757 // FALLTHROUGH intended
758 case ATTRIBUTE_FILL_COLOR:
759 // FALLTHROUGH intended
760 case ATTRIBUTE_LINE_COLOR:
761 return CLASS_COLOR_PROPERTY;
763 case ATTRIBUTE_CHAR_FONT_NAME:
764 return CLASS_STRING_PROPERTY;
766 case ATTRIBUTE_VISIBILITY:
767 return CLASS_BOOL_PROPERTY;
769 case ATTRIBUTE_CHAR_HEIGHT:
770 // FALLTHROUGH intended
771 case ATTRIBUTE_CHAR_WEIGHT:
772 // FALLTHROUGH intended
773 case ATTRIBUTE_CHAR_ROTATION:
774 // FALLTHROUGH intended
775 case ATTRIBUTE_HEIGHT:
776 // FALLTHROUGH intended
777 case ATTRIBUTE_OPACITY:
778 // FALLTHROUGH intended
779 case ATTRIBUTE_ROTATE:
780 // FALLTHROUGH intended
781 case ATTRIBUTE_SKEW_X:
782 // FALLTHROUGH intended
783 case ATTRIBUTE_SKEW_Y:
784 // FALLTHROUGH intended
785 case ATTRIBUTE_WIDTH:
786 // FALLTHROUGH intended
787 case ATTRIBUTE_POS_X:
788 // FALLTHROUGH intended
789 case ATTRIBUTE_POS_Y:
790 return CLASS_NUMBER_PROPERTY;
792 case ATTRIBUTE_CHAR_UNDERLINE:
793 // FALLTHROUGH intended
794 case ATTRIBUTE_FILL_STYLE:
795 // FALLTHROUGH intended
796 case ATTRIBUTE_LINE_STYLE:
797 // FALLTHROUGH intended
798 case ATTRIBUTE_CHAR_POSTURE:
799 return CLASS_ENUM_PROPERTY;
803 NumberAnimationSharedPtr AnimationFactory::createNumberPropertyAnimation( const OUString& rAttrName,
804 const AnimatableShapeSharedPtr& rShape,
805 const ShapeManagerSharedPtr& rShapeManager,
806 const ::basegfx::B2DVector& rSlideSize,
807 int nFlags )
809 // ATTENTION: When changing this map, also the classifyAttributeName() method must
810 // be checked and possibly adapted in their switch statement
811 switch( mapAttributeName( rAttrName ) )
813 default:
814 // FALLTHROUGH intended
815 case ATTRIBUTE_INVALID:
816 ENSURE_OR_THROW( false,
817 "AnimationFactory::createNumberPropertyAnimation(): Unknown attribute" );
818 break;
820 case ATTRIBUTE_CHAR_COLOR:
821 // FALLTHROUGH intended
822 case ATTRIBUTE_CHAR_FONT_NAME:
823 // FALLTHROUGH intended
824 case ATTRIBUTE_CHAR_POSTURE:
825 // FALLTHROUGH intended
826 case ATTRIBUTE_CHAR_UNDERLINE:
827 // FALLTHROUGH intended
828 case ATTRIBUTE_COLOR:
829 // FALLTHROUGH intended
830 case ATTRIBUTE_DIMCOLOR:
831 // FALLTHROUGH intended
832 case ATTRIBUTE_FILL_COLOR:
833 // FALLTHROUGH intended
834 case ATTRIBUTE_FILL_STYLE:
835 // FALLTHROUGH intended
836 case ATTRIBUTE_LINE_COLOR:
837 // FALLTHROUGH intended
838 case ATTRIBUTE_LINE_STYLE:
839 // FALLTHROUGH intended
840 case ATTRIBUTE_VISIBILITY:
841 ENSURE_OR_THROW( false,
842 "AnimationFactory::createNumberPropertyAnimation(): Attribute type mismatch" );
843 break;
845 case ATTRIBUTE_CHAR_HEIGHT:
846 return makeGenericAnimation<NumberAnimation>( rShapeManager,
847 nFlags,
848 &ShapeAttributeLayer::isCharScaleValid,
849 1.0, // CharHeight is a relative attribute, thus
850 // default is 1.0
851 &ShapeAttributeLayer::getCharScale,
852 &ShapeAttributeLayer::setCharScale );
854 case ATTRIBUTE_CHAR_WEIGHT:
855 return makeGenericAnimation<NumberAnimation>( rShapeManager,
856 nFlags,
857 &ShapeAttributeLayer::isCharWeightValid,
858 getDefault<double>( rShape, rAttrName ),
859 &ShapeAttributeLayer::getCharWeight,
860 &ShapeAttributeLayer::setCharWeight );
862 case ATTRIBUTE_CHAR_ROTATION:
863 return makeGenericAnimation<NumberAnimation>( rShapeManager,
864 nFlags,
865 &ShapeAttributeLayer::isCharRotationAngleValid,
866 getDefault<double>( rShape, rAttrName ),
867 &ShapeAttributeLayer::getCharRotationAngle,
868 &ShapeAttributeLayer::setCharRotationAngle );
870 case ATTRIBUTE_HEIGHT:
871 return makeGenericAnimation( rShapeManager,
872 nFlags,
873 &ShapeAttributeLayer::isHeightValid,
874 // TODO(F1): Check whether _shape_ bounds are correct here.
875 // Theoretically, our AttrLayer is way down the stack, and
876 // we only have to consider _that_ value, not the one from
877 // the top of the stack as returned by Shape::getBounds()
878 rShape->getBounds().getHeight(),
879 &ShapeAttributeLayer::getHeight,
880 &ShapeAttributeLayer::setHeight,
881 // convert expression parser value from relative page size
882 rSlideSize.getY() );
884 case ATTRIBUTE_OPACITY:
885 return makeGenericAnimation<NumberAnimation>( rShapeManager,
886 nFlags,
887 &ShapeAttributeLayer::isAlphaValid,
888 // TODO(F1): Provide shape default here (FillTransparency?)
889 1.0,
890 &ShapeAttributeLayer::getAlpha,
891 &ShapeAttributeLayer::setAlpha );
893 case ATTRIBUTE_ROTATE:
894 return makeGenericAnimation<NumberAnimation>( rShapeManager,
895 nFlags,
896 &ShapeAttributeLayer::isRotationAngleValid,
897 // NOTE: Since we paint the shape as-is from metafile,
898 // rotation angle is always 0.0, even for rotated shapes
899 0.0,
900 &ShapeAttributeLayer::getRotationAngle,
901 &ShapeAttributeLayer::setRotationAngle );
903 case ATTRIBUTE_SKEW_X:
904 return makeGenericAnimation<NumberAnimation>( rShapeManager,
905 nFlags,
906 &ShapeAttributeLayer::isShearXAngleValid,
907 // TODO(F1): Is there any shape property for skew?
908 0.0,
909 &ShapeAttributeLayer::getShearXAngle,
910 &ShapeAttributeLayer::setShearXAngle );
912 case ATTRIBUTE_SKEW_Y:
913 return makeGenericAnimation<NumberAnimation>( rShapeManager,
914 nFlags,
915 &ShapeAttributeLayer::isShearYAngleValid,
916 // TODO(F1): Is there any shape property for skew?
917 0.0,
918 &ShapeAttributeLayer::getShearYAngle,
919 &ShapeAttributeLayer::setShearYAngle );
921 case ATTRIBUTE_WIDTH:
922 return makeGenericAnimation( rShapeManager,
923 nFlags,
924 &ShapeAttributeLayer::isWidthValid,
925 // TODO(F1): Check whether _shape_ bounds are correct here.
926 // Theoretically, our AttrLayer is way down the stack, and
927 // we only have to consider _that_ value, not the one from
928 // the top of the stack as returned by Shape::getBounds()
929 rShape->getBounds().getWidth(),
930 &ShapeAttributeLayer::getWidth,
931 &ShapeAttributeLayer::setWidth,
932 // convert expression parser value from relative page size
933 rSlideSize.getX() );
935 case ATTRIBUTE_POS_X:
936 return makeGenericAnimation( rShapeManager,
937 nFlags,
938 &ShapeAttributeLayer::isPosXValid,
939 // TODO(F1): Check whether _shape_ bounds are correct here.
940 // Theoretically, our AttrLayer is way down the stack, and
941 // we only have to consider _that_ value, not the one from
942 // the top of the stack as returned by Shape::getBounds()
943 rShape->getBounds().getCenterX(),
944 &ShapeAttributeLayer::getPosX,
945 &ShapeAttributeLayer::setPosX,
946 // convert expression parser value from relative page size
947 rSlideSize.getX() );
949 case ATTRIBUTE_POS_Y:
950 return makeGenericAnimation( rShapeManager,
951 nFlags,
952 &ShapeAttributeLayer::isPosYValid,
953 // TODO(F1): Check whether _shape_ bounds are correct here.
954 // Theoretically, our AttrLayer is way down the stack, and
955 // we only have to consider _that_ value, not the one from
956 // the top of the stack as returned by Shape::getBounds()
957 rShape->getBounds().getCenterY(),
958 &ShapeAttributeLayer::getPosY,
959 &ShapeAttributeLayer::setPosY,
960 // convert expression parser value from relative page size
961 rSlideSize.getY() );
964 return NumberAnimationSharedPtr();
967 EnumAnimationSharedPtr AnimationFactory::createEnumPropertyAnimation( const OUString& rAttrName,
968 const AnimatableShapeSharedPtr& rShape,
969 const ShapeManagerSharedPtr& rShapeManager,
970 const ::basegfx::B2DVector& /*rSlideSize*/,
971 int nFlags )
973 // ATTENTION: When changing this map, also the classifyAttributeName() method must
974 // be checked and possibly adapted in their switch statement
975 switch( mapAttributeName( rAttrName ) )
977 default:
978 // FALLTHROUGH intended
979 case ATTRIBUTE_INVALID:
980 ENSURE_OR_THROW( false,
981 "AnimationFactory::createEnumPropertyAnimation(): Unknown attribute" );
982 break;
984 case ATTRIBUTE_CHAR_COLOR:
985 // FALLTHROUGH intended
986 case ATTRIBUTE_CHAR_FONT_NAME:
987 // FALLTHROUGH intended
988 case ATTRIBUTE_COLOR:
989 // FALLTHROUGH intended
990 case ATTRIBUTE_DIMCOLOR:
991 // FALLTHROUGH intended
992 case ATTRIBUTE_FILL_COLOR:
993 // FALLTHROUGH intended
994 case ATTRIBUTE_LINE_COLOR:
995 // FALLTHROUGH intended
996 case ATTRIBUTE_VISIBILITY:
997 // FALLTHROUGH intended
998 case ATTRIBUTE_CHAR_HEIGHT:
999 // FALLTHROUGH intended
1000 case ATTRIBUTE_CHAR_WEIGHT:
1001 // FALLTHROUGH intended
1002 case ATTRIBUTE_CHAR_ROTATION:
1003 // FALLTHROUGH intended
1004 case ATTRIBUTE_HEIGHT:
1005 // FALLTHROUGH intended
1006 case ATTRIBUTE_OPACITY:
1007 // FALLTHROUGH intended
1008 case ATTRIBUTE_ROTATE:
1009 // FALLTHROUGH intended
1010 case ATTRIBUTE_SKEW_X:
1011 // FALLTHROUGH intended
1012 case ATTRIBUTE_SKEW_Y:
1013 // FALLTHROUGH intended
1014 case ATTRIBUTE_WIDTH:
1015 // FALLTHROUGH intended
1016 case ATTRIBUTE_POS_X:
1017 // FALLTHROUGH intended
1018 case ATTRIBUTE_POS_Y:
1019 ENSURE_OR_THROW( false,
1020 "AnimationFactory::createEnumPropertyAnimation(): Attribute type mismatch" );
1021 break;
1024 case ATTRIBUTE_FILL_STYLE:
1025 return makeGenericAnimation<EnumAnimation>( rShapeManager,
1026 nFlags,
1027 &ShapeAttributeLayer::isFillStyleValid,
1028 sal::static_int_cast<sal_Int16>(
1029 getDefault<drawing::FillStyle>( rShape, rAttrName )),
1030 &ShapeAttributeLayer::getFillStyle,
1031 &ShapeAttributeLayer::setFillStyle );
1033 case ATTRIBUTE_LINE_STYLE:
1034 return makeGenericAnimation<EnumAnimation>( rShapeManager,
1035 nFlags,
1036 &ShapeAttributeLayer::isLineStyleValid,
1037 sal::static_int_cast<sal_Int16>(
1038 getDefault<drawing::LineStyle>( rShape, rAttrName )),
1039 &ShapeAttributeLayer::getLineStyle,
1040 &ShapeAttributeLayer::setLineStyle );
1042 case ATTRIBUTE_CHAR_POSTURE:
1043 return makeGenericAnimation<EnumAnimation>( rShapeManager,
1044 nFlags,
1045 &ShapeAttributeLayer::isCharPostureValid,
1046 sal::static_int_cast<sal_Int16>(
1047 getDefault<awt::FontSlant>( rShape, rAttrName )),
1048 &ShapeAttributeLayer::getCharPosture,
1049 &ShapeAttributeLayer::setCharPosture );
1051 case ATTRIBUTE_CHAR_UNDERLINE:
1052 return makeGenericAnimation<EnumAnimation>( rShapeManager,
1053 nFlags,
1054 &ShapeAttributeLayer::isUnderlineModeValid,
1055 getDefault<sal_Int16>( rShape, rAttrName ),
1056 &ShapeAttributeLayer::getUnderlineMode,
1057 &ShapeAttributeLayer::setUnderlineMode );
1060 return EnumAnimationSharedPtr();
1063 ColorAnimationSharedPtr AnimationFactory::createColorPropertyAnimation( const OUString& rAttrName,
1064 const AnimatableShapeSharedPtr& rShape,
1065 const ShapeManagerSharedPtr& rShapeManager,
1066 const ::basegfx::B2DVector& /*rSlideSize*/,
1067 int nFlags )
1069 // ATTENTION: When changing this map, also the classifyAttributeName() method must
1070 // be checked and possibly adapted in their switch statement
1071 switch( mapAttributeName( rAttrName ) )
1073 default:
1074 // FALLTHROUGH intended
1075 case ATTRIBUTE_INVALID:
1076 ENSURE_OR_THROW( false,
1077 "AnimationFactory::createColorPropertyAnimation(): Unknown attribute" );
1078 break;
1080 case ATTRIBUTE_CHAR_FONT_NAME:
1081 // FALLTHROUGH intended
1082 case ATTRIBUTE_CHAR_HEIGHT:
1083 // FALLTHROUGH intended
1084 case ATTRIBUTE_CHAR_POSTURE:
1085 // FALLTHROUGH intended
1086 case ATTRIBUTE_CHAR_ROTATION:
1087 // FALLTHROUGH intended
1088 case ATTRIBUTE_CHAR_UNDERLINE:
1089 // FALLTHROUGH intended
1090 case ATTRIBUTE_CHAR_WEIGHT:
1091 // FALLTHROUGH intended
1092 case ATTRIBUTE_FILL_STYLE:
1093 // FALLTHROUGH intended
1094 case ATTRIBUTE_HEIGHT:
1095 // FALLTHROUGH intended
1096 case ATTRIBUTE_LINE_STYLE:
1097 // FALLTHROUGH intended
1098 case ATTRIBUTE_OPACITY:
1099 // FALLTHROUGH intended
1100 case ATTRIBUTE_ROTATE:
1101 // FALLTHROUGH intended
1102 case ATTRIBUTE_SKEW_X:
1103 // FALLTHROUGH intended
1104 case ATTRIBUTE_SKEW_Y:
1105 // FALLTHROUGH intended
1106 case ATTRIBUTE_VISIBILITY:
1107 // FALLTHROUGH intended
1108 case ATTRIBUTE_WIDTH:
1109 // FALLTHROUGH intended
1110 case ATTRIBUTE_POS_X:
1111 // FALLTHROUGH intended
1112 case ATTRIBUTE_POS_Y:
1113 ENSURE_OR_THROW( false,
1114 "AnimationFactory::createColorPropertyAnimation(): Attribute type mismatch" );
1115 break;
1117 case ATTRIBUTE_CHAR_COLOR:
1118 return makeGenericAnimation<ColorAnimation>( rShapeManager,
1119 nFlags,
1120 &ShapeAttributeLayer::isCharColorValid,
1121 getDefault<RGBColor>( rShape, rAttrName ),
1122 &ShapeAttributeLayer::getCharColor,
1123 &ShapeAttributeLayer::setCharColor );
1125 case ATTRIBUTE_COLOR:
1126 // TODO(F2): This is just mapped to fill color to make it work
1127 return makeGenericAnimation<ColorAnimation>( rShapeManager,
1128 nFlags,
1129 &ShapeAttributeLayer::isFillColorValid,
1130 getDefault<RGBColor>( rShape, rAttrName ),
1131 &ShapeAttributeLayer::getFillColor,
1132 &ShapeAttributeLayer::setFillColor );
1134 case ATTRIBUTE_DIMCOLOR:
1135 return makeGenericAnimation<ColorAnimation>( rShapeManager,
1136 nFlags,
1137 &ShapeAttributeLayer::isDimColorValid,
1138 getDefault<RGBColor>( rShape, rAttrName ),
1139 &ShapeAttributeLayer::getDimColor,
1140 &ShapeAttributeLayer::setDimColor );
1142 case ATTRIBUTE_FILL_COLOR:
1143 return makeGenericAnimation<ColorAnimation>( rShapeManager,
1144 nFlags,
1145 &ShapeAttributeLayer::isFillColorValid,
1146 getDefault<RGBColor>( rShape, rAttrName ),
1147 &ShapeAttributeLayer::getFillColor,
1148 &ShapeAttributeLayer::setFillColor );
1150 case ATTRIBUTE_LINE_COLOR:
1151 return makeGenericAnimation<ColorAnimation>( rShapeManager,
1152 nFlags,
1153 &ShapeAttributeLayer::isLineColorValid,
1154 getDefault<RGBColor>( rShape, rAttrName ),
1155 &ShapeAttributeLayer::getLineColor,
1156 &ShapeAttributeLayer::setLineColor );
1159 return ColorAnimationSharedPtr();
1162 PairAnimationSharedPtr AnimationFactory::createPairPropertyAnimation( const AnimatableShapeSharedPtr& rShape,
1163 const ShapeManagerSharedPtr& rShapeManager,
1164 const ::basegfx::B2DVector& rSlideSize,
1165 sal_Int16 nTransformType,
1166 int nFlags )
1168 const ::basegfx::B2DRectangle& rBounds( rShape->getBounds() );
1170 switch( nTransformType )
1172 case animations::AnimationTransformType::SCALE:
1173 return PairAnimationSharedPtr(
1174 new TupleAnimation< ::basegfx::B2DSize >(
1175 rShapeManager,
1176 nFlags,
1177 &ShapeAttributeLayer::isWidthValid,
1178 &ShapeAttributeLayer::isHeightValid,
1179 // TODO(F1): Check whether _shape_ bounds are correct here.
1180 // Theoretically, our AttrLayer is way down the stack, and
1181 // we only have to consider _that_ value, not the one from
1182 // the top of the stack as returned by Shape::getBounds()
1183 rBounds.getRange(),
1184 rBounds.getRange(),
1185 &ShapeAttributeLayer::getWidth,
1186 &ShapeAttributeLayer::getHeight,
1187 &ShapeAttributeLayer::setSize ) );
1189 case animations::AnimationTransformType::TRANSLATE:
1190 return PairAnimationSharedPtr(
1191 new TupleAnimation< ::basegfx::B2DPoint >(
1192 rShapeManager,
1193 nFlags,
1194 &ShapeAttributeLayer::isPosXValid,
1195 &ShapeAttributeLayer::isPosYValid,
1196 // TODO(F1): Check whether _shape_ bounds are correct here.
1197 // Theoretically, our AttrLayer is way down the stack, and
1198 // we only have to consider _that_ value, not the one from
1199 // the top of the stack as returned by Shape::getBounds()
1200 rBounds.getCenter(),
1201 rSlideSize,
1202 &ShapeAttributeLayer::getPosX,
1203 &ShapeAttributeLayer::getPosY,
1204 &ShapeAttributeLayer::setPosition ) );
1206 default:
1207 ENSURE_OR_THROW( false,
1208 "AnimationFactory::createPairPropertyAnimation(): Attribute type mismatch" );
1209 break;
1212 return PairAnimationSharedPtr();
1215 StringAnimationSharedPtr AnimationFactory::createStringPropertyAnimation( const OUString& rAttrName,
1216 const AnimatableShapeSharedPtr& rShape,
1217 const ShapeManagerSharedPtr& rShapeManager,
1218 const ::basegfx::B2DVector& /*rSlideSize*/,
1219 int nFlags )
1221 // ATTENTION: When changing this map, also the classifyAttributeName() method must
1222 // be checked and possibly adapted in their switch statement
1223 switch( mapAttributeName( rAttrName ) )
1225 default:
1226 // FALLTHROUGH intended
1227 case ATTRIBUTE_INVALID:
1228 ENSURE_OR_THROW( false,
1229 "AnimationFactory::createStringPropertyAnimation(): Unknown attribute" );
1230 break;
1232 case ATTRIBUTE_CHAR_COLOR:
1233 // FALLTHROUGH intended
1234 case ATTRIBUTE_CHAR_HEIGHT:
1235 // FALLTHROUGH intended
1236 case ATTRIBUTE_CHAR_ROTATION:
1237 // FALLTHROUGH intended
1238 case ATTRIBUTE_CHAR_UNDERLINE:
1239 // FALLTHROUGH intended
1240 case ATTRIBUTE_COLOR:
1241 // FALLTHROUGH intended
1242 case ATTRIBUTE_DIMCOLOR:
1243 // FALLTHROUGH intended
1244 case ATTRIBUTE_FILL_COLOR:
1245 // FALLTHROUGH intended
1246 case ATTRIBUTE_HEIGHT:
1247 // FALLTHROUGH intended
1248 case ATTRIBUTE_LINE_COLOR:
1249 // FALLTHROUGH intended
1250 case ATTRIBUTE_OPACITY:
1251 // FALLTHROUGH intended
1252 case ATTRIBUTE_ROTATE:
1253 // FALLTHROUGH intended
1254 case ATTRIBUTE_SKEW_X:
1255 // FALLTHROUGH intended
1256 case ATTRIBUTE_SKEW_Y:
1257 // FALLTHROUGH intended
1258 case ATTRIBUTE_VISIBILITY:
1259 // FALLTHROUGH intended
1260 case ATTRIBUTE_WIDTH:
1261 // FALLTHROUGH intended
1262 case ATTRIBUTE_POS_X:
1263 // FALLTHROUGH intended
1264 case ATTRIBUTE_POS_Y:
1265 // FALLTHROUGH intended
1266 case ATTRIBUTE_CHAR_POSTURE:
1267 // FALLTHROUGH intended
1268 case ATTRIBUTE_CHAR_WEIGHT:
1269 // FALLTHROUGH intended
1270 case ATTRIBUTE_FILL_STYLE:
1271 // FALLTHROUGH intended
1272 case ATTRIBUTE_LINE_STYLE:
1273 ENSURE_OR_THROW( false,
1274 "AnimationFactory::createStringPropertyAnimation(): Attribute type mismatch" );
1275 break;
1277 case ATTRIBUTE_CHAR_FONT_NAME:
1278 return makeGenericAnimation<StringAnimation>( rShapeManager,
1279 nFlags,
1280 &ShapeAttributeLayer::isFontFamilyValid,
1281 getDefault< OUString >( rShape, rAttrName ),
1282 &ShapeAttributeLayer::getFontFamily,
1283 &ShapeAttributeLayer::setFontFamily );
1286 return StringAnimationSharedPtr();
1289 BoolAnimationSharedPtr AnimationFactory::createBoolPropertyAnimation( const OUString& rAttrName,
1290 const AnimatableShapeSharedPtr& /*rShape*/,
1291 const ShapeManagerSharedPtr& rShapeManager,
1292 const ::basegfx::B2DVector& /*rSlideSize*/,
1293 int nFlags )
1295 // ATTENTION: When changing this map, also the classifyAttributeName() method must
1296 // be checked and possibly adapted in their switch statement
1297 switch( mapAttributeName( rAttrName ) )
1299 default:
1300 // FALLTHROUGH intended
1301 case ATTRIBUTE_INVALID:
1302 ENSURE_OR_THROW( false,
1303 "AnimationFactory::createBoolPropertyAnimation(): Unknown attribute" );
1304 break;
1306 case ATTRIBUTE_CHAR_COLOR:
1307 // FALLTHROUGH intended
1308 case ATTRIBUTE_CHAR_FONT_NAME:
1309 // FALLTHROUGH intended
1310 case ATTRIBUTE_CHAR_HEIGHT:
1311 // FALLTHROUGH intended
1312 case ATTRIBUTE_CHAR_POSTURE:
1313 // FALLTHROUGH intended
1314 case ATTRIBUTE_CHAR_ROTATION:
1315 // FALLTHROUGH intended
1316 case ATTRIBUTE_CHAR_WEIGHT:
1317 // FALLTHROUGH intended
1318 case ATTRIBUTE_COLOR:
1319 // FALLTHROUGH intended
1320 case ATTRIBUTE_DIMCOLOR:
1321 // FALLTHROUGH intended
1322 case ATTRIBUTE_FILL_COLOR:
1323 // FALLTHROUGH intended
1324 case ATTRIBUTE_FILL_STYLE:
1325 // FALLTHROUGH intended
1326 case ATTRIBUTE_HEIGHT:
1327 // FALLTHROUGH intended
1328 case ATTRIBUTE_LINE_COLOR:
1329 // FALLTHROUGH intended
1330 case ATTRIBUTE_LINE_STYLE:
1331 // FALLTHROUGH intended
1332 case ATTRIBUTE_OPACITY:
1333 // FALLTHROUGH intended
1334 case ATTRIBUTE_ROTATE:
1335 // FALLTHROUGH intended
1336 case ATTRIBUTE_SKEW_X:
1337 // FALLTHROUGH intended
1338 case ATTRIBUTE_SKEW_Y:
1339 // FALLTHROUGH intended
1340 case ATTRIBUTE_WIDTH:
1341 // FALLTHROUGH intended
1342 case ATTRIBUTE_POS_X:
1343 // FALLTHROUGH intended
1344 case ATTRIBUTE_POS_Y:
1345 // FALLTHROUGH intended
1346 case ATTRIBUTE_CHAR_UNDERLINE:
1347 ENSURE_OR_THROW( false,
1348 "AnimationFactory::createBoolPropertyAnimation(): Attribute type mismatch" );
1349 break;
1351 case ATTRIBUTE_VISIBILITY:
1352 return makeGenericAnimation<BoolAnimation>( rShapeManager,
1353 nFlags,
1354 &ShapeAttributeLayer::isVisibilityValid,
1355 // TODO(F1): Is there a corresponding shape property?
1356 true,
1357 &ShapeAttributeLayer::getVisibility,
1358 &ShapeAttributeLayer::setVisibility );
1361 return BoolAnimationSharedPtr();
1364 NumberAnimationSharedPtr AnimationFactory::createPathMotionAnimation( const OUString& rSVGDPath,
1365 sal_Int16 nAdditive,
1366 const AnimatableShapeSharedPtr& /*rShape*/,
1367 const ShapeManagerSharedPtr& rShapeManager,
1368 const ::basegfx::B2DVector& rSlideSize,
1369 int nFlags )
1371 return NumberAnimationSharedPtr(
1372 new PathAnimation( rSVGDPath, nAdditive,
1373 rShapeManager,
1374 rSlideSize,
1375 nFlags ) );
1381 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */