27#include <com/sun/star/animations/AnimationAdditiveMode.hpp>
28#include <com/sun/star/animations/AnimationTransformType.hpp>
29#include <com/sun/star/beans/XPropertySet.hpp>
30#include <com/sun/star/drawing/FillStyle.hpp>
31#include <com/sun/star/drawing/LineStyle.hpp>
32#include <com/sun/star/awt/FontSlant.hpp>
51 template<
typename ValueT >
class TupleAnimation :
public PairAnimation
56 bool (ShapeAttributeLayer::*pIs1stValid)()
const,
57 bool (ShapeAttributeLayer::*pIs2ndValid)()
const,
58 const ValueT& rDefaultValue,
59 const ::basegfx::B2DSize& rReferenceSize,
60 double (ShapeAttributeLayer::*pGet1stValue)()
const,
61 double (ShapeAttributeLayer::*pGet2ndValue)()
const,
62 void (ShapeAttributeLayer::*pSetValue)(
const ValueT& ) ) :
77 "TupleAnimation::TupleAnimation(): Invalid ShapeManager" );
78 ENSURE_OR_THROW( pIs1stValid && pIs2ndValid && pGet1stValue && pGet2ndValue && pSetValue,
79 "TupleAnimation::TupleAnimation(): One of the method pointers is NULL" );
82 virtual ~TupleAnimation()
override
89 virtual void prefetch()
override
96 "TupleAnimation::start(): Shape already set" );
98 "TupleAnimation::start(): Attribute layer already set" );
104 "TupleAnimation::start(): Invalid shape" );
106 "TupleAnimation::start(): Invalid attribute layer" );
117 virtual void end()
override { end_(); }
127 if(
mpShape->isContentChanged() )
135 virtual bool operator()( const ::basegfx::B2DTuple& rValue )
override
138 "TupleAnimation::operator(): Invalid ShapeAttributeLayer" );
140 ValueT aValue(rValue.getX(), rValue.getY());
149 if(
mpShape->isContentChanged() )
155 virtual ::basegfx::B2DTuple getUnderlyingValue()
const override
158 "TupleAnimation::getUnderlyingValue(): Invalid ShapeAttributeLayer" );
201 class PathAnimation :
public NumberAnimation
204 PathAnimation( std::u16string_view rSVGDPath,
207 const ::basegfx::B2DVector& rSlideSize,
214 maPageSize( rSlideSize.getX(), rSlideSize.getY() ),
223 "PathAnimation::PathAnimation(): Invalid ShapeManager" );
227 ENSURE_OR_THROW( ::basegfx::utils::importFromSvgD( aPolyPoly, rSVGDPath,
false,
nullptr ),
228 "PathAnimation::PathAnimation(): failed to parse SVG:d path" );
230 "PathAnimation::PathAnimation(): motion path consists of multiple/zero polygon(s)" );
235 virtual ~PathAnimation()
override
242 virtual void prefetch()
override
249 "PathAnimation::start(): Shape already set" );
251 "PathAnimation::start(): Attribute layer already set" );
257 "PathAnimation::start(): Invalid shape" );
259 "PathAnimation::start(): Invalid attribute layer" );
265 if(
mnAdditive == animations::AnimationAdditiveMode::SUM )
279 virtual void end()
override { end_(); }
290 if(
mpShape->isContentChanged() )
302 virtual bool operator()(
double nValue )
override
305 "PathAnimation::operator(): Invalid ShapeAttributeLayer" );
325 if(
mpShape->isContentChanged() )
343 virtual double getUnderlyingValue()
const override
346 "PathAnimation::getUnderlyingValue(): Invalid ShapeAttributeLayer" );
368 class PhysicsAnimation :
public NumberAnimation
372 const double fDuration,
374 const ::basegfx::B2DVector& rSlideSize,
375 const ::basegfx::B2DVector& rStartVelocity,
376 const double fDensity,
377 const double fBounciness,
395 "PhysicsAnimation::PhysicsAnimation(): Invalid ShapeManager" );
398 virtual ~PhysicsAnimation()
override
405 virtual void prefetch()
override
412 "PhysicsAnimation::start(): Shape already set" );
414 "PhysicsAnimation::start(): Attribute layer already set" );
420 "PhysicsAnimation::start(): Invalid shape" );
422 "PhysicsAnimation::start(): Invalid attribute layer" );
436 virtual void end()
override { end_(); }
453 if(
mpShape->isContentChanged() )
470 virtual bool operator()(
double nValue )
override
473 "PhysicsAnimation::operator(): Invalid ShapeAttributeLayer" );
492 if(
mpShape->isContentChanged() )
498 virtual double getUnderlyingValue()
const override
501 "PhysicsAnimation::getUnderlyingValue(): Invalid ShapeAttributeLayer" );
548 template<
typename AnimationBase,
typename ModifierFunctor >
class GenericAnimation :
public AnimationBase
551 typedef typename AnimationBase::ValueType ValueT;
581 bool (ShapeAttributeLayer::*pIsValid)()
const,
582 ValueT aDefaultValue,
583 ValueT (ShapeAttributeLayer::*pGetValue)()
const,
584 void (ShapeAttributeLayer::*pSetValue)(
const ValueT& ),
585 const ModifierFunctor& rGetterModifier,
586 const ModifierFunctor& rSetterModifier,
605 "GenericAnimation::GenericAnimation(): Invalid ShapeManager" );
607 "GenericAnimation::GenericAnimation(): One of the method pointers is NULL" );
617 virtual void prefetch()
624 "GenericAnimation::start(): Shape already set" );
626 "GenericAnimation::start(): Attribute layer already set" );
632 "GenericAnimation::start(): Invalid shape" );
634 "GenericAnimation::start(): Invalid attribute layer" );
690 if(
mpShape->isContentChanged() )
699 bool operator()(
const ValueT& x )
702 "GenericAnimation::operator(): Invalid ShapeAttributeLayer" );
706 if(
mpShape->isContentChanged() )
716 bool operator()( ValueT x )
719 "GenericAnimation::operator(): Invalid ShapeAttributeLayer" );
729 if(
mpShape->isContentChanged() )
737 ValueT getUnderlyingValue()
const
740 "GenericAnimation::getUnderlyingValue(): Invalid ShapeAttributeLayer" );
773 template<
typename T>
struct SGI_identity
775 T& operator()(T&
x)
const {
return x; }
776 const T& operator()(
const T& x)
const {
return x; }
785 template<
typename AnimationBase > ::std::shared_ptr< AnimationBase >
788 bool (ShapeAttributeLayer::*pIsValid)()
const,
789 const typename AnimationBase::ValueType& rDefaultValue,
790 typename AnimationBase::ValueType (ShapeAttributeLayer::*pGetValue)()
const,
791 void (ShapeAttributeLayer::*pSetValue)(
const typename AnimationBase::ValueType& ),
795 return std::make_shared<GenericAnimation< AnimationBase,
796 SGI_identity< typename AnimationBase::ValueType > >>(
804 SGI_identity< typename AnimationBase::ValueType >(),
805 SGI_identity< typename AnimationBase::ValueType >(),
813 explicit Scaler(
double nScale ) :
818 double operator()(
double nVal )
const
831 bool (ShapeAttributeLayer::*pIsValid)()
const,
832 double nDefaultValue,
833 double (ShapeAttributeLayer::*pGetValue)()
const,
834 void (ShapeAttributeLayer::*pSetValue)(
const double& ),
839 return std::make_shared<GenericAnimation< NumberAnimation, Scaler >>( rShapeManager,
842 nDefaultValue / nScaleValue,
845 Scaler( 1.0/nScaleValue ),
846 Scaler( nScaleValue ),
853 const OUString& rPropertyName )
855 uno::Reference< drawing::XShape > xShape( rShape->getXShape() );
862 uno::Reference< beans::XPropertySet > xPropSet( xShape,
866 "getShapeDefault(): Cannot query property set from shape" );
868 return xPropSet->getPropertyValue( rPropertyName );
872 const OUString& rPropertyName )
874 const uno::Any& rAny( getShapeDefault( rShape,
877 if( !rAny.hasValue() )
879 SAL_WARN(
"slideshow",
"getDefault(): cannot get shape property " << rPropertyName );
886 if( !(rAny >>= aValue) )
888 SAL_WARN(
"slideshow",
"getDefault(): cannot extract shape property " << rPropertyName);
897 const OUString& rPropertyName )
899 const uno::Any& rAny( getShapeDefault( rShape,
902 if( !rAny.hasValue() )
904 SAL_WARN(
"slideshow",
"getDefault(): cannot get shape color property " << rPropertyName);
911 if( !(rAny >>= nValue) )
913 SAL_INFO(
"slideshow",
"getDefault(): cannot extract shape color property " << rPropertyName);
919 return RGBColor( (nValue << 8U) & 0xFFFFFF00U );
973 const ::basegfx::B2DVector& rSlideSize,
985 "AnimationFactory::createNumberPropertyAnimation(): Unknown attribute" );
1000 "AnimationFactory::createNumberPropertyAnimation(): Attribute type mismatch" );
1004 return makeGenericAnimation<NumberAnimation>( rShapeManager,
1015 return makeGenericAnimation<NumberAnimation>( rShapeManager,
1018 getDefault<double>( rShape, rAttrName ),
1025 return makeGenericAnimation( rShapeManager,
1032 rShape->getBounds().getHeight(),
1041 return makeGenericAnimation<NumberAnimation>( rShapeManager,
1052 return makeGenericAnimation<NumberAnimation>( rShapeManager,
1064 return makeGenericAnimation<NumberAnimation>( rShapeManager,
1075 return makeGenericAnimation<NumberAnimation>( rShapeManager,
1086 return makeGenericAnimation( rShapeManager,
1093 rShape->getBounds().getWidth(),
1102 return makeGenericAnimation( rShapeManager,
1109 rShape->getBounds().getCenterX(),
1118 return makeGenericAnimation( rShapeManager,
1125 rShape->getBounds().getCenterY(),
1140 const ::basegfx::B2DVector& ,
1152 "AnimationFactory::createEnumPropertyAnimation(): Unknown attribute" );
1173 "AnimationFactory::createEnumPropertyAnimation(): Attribute type mismatch" );
1178 return makeGenericAnimation<EnumAnimation>( rShapeManager,
1181 sal::static_int_cast<sal_Int16>(
1182 getDefault<drawing::FillStyle>( rShape, rAttrName )),
1189 return makeGenericAnimation<EnumAnimation>( rShapeManager,
1192 sal::static_int_cast<sal_Int16>(
1193 getDefault<drawing::LineStyle>( rShape, rAttrName )),
1200 return makeGenericAnimation<EnumAnimation>( rShapeManager,
1203 sal::static_int_cast<sal_Int16>(
1204 getDefault<awt::FontSlant>( rShape, rAttrName )),
1211 return makeGenericAnimation<EnumAnimation>( rShapeManager,
1214 getDefault<sal_Int16>( rShape, rAttrName ),
1227 const ::basegfx::B2DVector& ,
1239 "AnimationFactory::createColorPropertyAnimation(): Unknown attribute" );
1259 "AnimationFactory::createColorPropertyAnimation(): Attribute type mismatch" );
1263 return makeGenericAnimation<ColorAnimation>( rShapeManager,
1266 getDefault<RGBColor>( rShape, rAttrName ),
1274 return makeGenericAnimation<ColorAnimation>( rShapeManager,
1277 getDefault<RGBColor>( rShape, rAttrName ),
1284 return makeGenericAnimation<ColorAnimation>( rShapeManager,
1287 getDefault<RGBColor>( rShape, rAttrName ),
1294 return makeGenericAnimation<ColorAnimation>( rShapeManager,
1297 getDefault<RGBColor>( rShape, rAttrName ),
1304 return makeGenericAnimation<ColorAnimation>( rShapeManager,
1307 getDefault<RGBColor>( rShape, rAttrName ),
1319 const ::basegfx::B2DVector& rSlideSize,
1320 sal_Int16 nTransformType,
1323 const ::basegfx::B2DRectangle& rBounds( rShape->getBounds() );
1325 switch( nTransformType )
1327 case animations::AnimationTransformType::SCALE:
1328 return std::make_shared<TupleAnimation< ::basegfx::B2DSize >>(
1343 case animations::AnimationTransformType::TRANSLATE:
1344 return std::make_shared<TupleAnimation< ::basegfx::B2DPoint >>(
1353 rBounds.getCenter(),
1361 "AnimationFactory::createPairPropertyAnimation(): Attribute type mismatch" );
1371 const ::basegfx::B2DVector& ,
1383 "AnimationFactory::createStringPropertyAnimation(): Unknown attribute" );
1407 "AnimationFactory::createStringPropertyAnimation(): Attribute type mismatch" );
1411 return makeGenericAnimation<StringAnimation>( rShapeManager,
1414 getDefault< OUString >( rShape, rAttrName ),
1427 const ::basegfx::B2DVector& ,
1439 "AnimationFactory::createBoolPropertyAnimation(): Unknown attribute" );
1463 "AnimationFactory::createBoolPropertyAnimation(): Attribute type mismatch" );
1467 return makeGenericAnimation<BoolAnimation>( rShapeManager,
1482 sal_Int16 nAdditive,
1485 const ::basegfx::B2DVector& rSlideSize,
1489 return std::make_shared<PathAnimation>( rSVGDPath, nAdditive,
1497 const double fDuration,
1499 const ::basegfx::B2DVector& rSlideSize,
1500 const ::basegfx::B2DVector& rStartVelocity,
1501 const double fDensity,
1502 const double fBounciness,
1505 return std::make_shared<PhysicsAnimation>( pBox2DWorld, fDuration,
const ::basegfx::B2DVector maStartVelocity
ShapeManagerSharedPtr mpShapeManager
bool mbIsBox2dWorldStepper
const ::basegfx::B2DSize maReferenceSize
AnimatableShapeSharedPtr mpShape
const double mfBounciness
const ValueT maDefaultValue
double(ShapeAttributeLayer::* mpGet1stValueFunc)() const
ShapeAttributeLayerSharedPtr mpAttrLayer
const ::basegfx::B2DSize maPageSize
ValueT(ShapeAttributeLayer::* mpGetValueFunc)() const
bool(ShapeAttributeLayer::* mpIs1stValidFunc)() const
box2d::utils::Box2DBodySharedPtr mpBox2DBody
bool(ShapeAttributeLayer::* mpIsValidFunc)() const
void(ShapeAttributeLayer::* mpSetValueFunc)(const ValueT &)
::basegfx::B2DPoint maShapeOrig
bool mbAnimationFirstUpdate
ModifierFunctor maSetterModifier
::basegfx::B2DPolygon maPathPoly
double mfPreviousElapsedTime
const AttributeType meAttrType
bool(ShapeAttributeLayer::* mpIs2ndValidFunc)() const
ModifierFunctor maGetterModifier
double(ShapeAttributeLayer::* mpGet2ndValueFunc)() const
box2d::utils::Box2DWorldSharedPtr mpBox2DWorld
B2DPolygon const & getB2DPolygon(sal_uInt32 nIndex) const
void setCharPosture(const sal_Int16 &rStyle)
Set the italic style globally for the whole shape.
void setWidth(const double &rNewWidth)
Set the new width of the shape.
OUString getFontFamily() const
Get the current text font family for the whole shape.
double getShearYAngle() const
Query the current shear angle at the y axis of the shape.
void setVisibility(const bool &bVisible)
Set the shape visibility.
void setShearYAngle(const double &rNewAngle)
Set the new shear angle at the y axis of the shape.
RGBColor getFillColor() const
Get the fill color for the whole shape.
RGBColor getDimColor() const
Get the dim color for the whole shape.
bool isUnderlineModeValid() const
Query whether the underline mode attribute is valid.
bool isShearXAngleValid() const
Query whether the shear x angle attribute is valid.
void setFontFamily(const OUString &rName)
Set the text font family name globally for the whole shape.
void setPosX(const double &rNewX)
Set the new x position of the shape.
void setLineStyle(const sal_Int16 &rStyle)
Set line style for the whole shape.
void setSize(const ::basegfx::B2DSize &rNewSize)
Set the new size of the shape.
bool isShearYAngleValid() const
Query whether the shear y angle attribute is valid.
double getCharWeight() const
Get the current char weight value for the whole shape.
void setCharWeight(const double &rStyle)
Set the char weight globally for the whole shape.
void setAlpha(const double &rNewValue)
Set the new alpha value of the shape.
bool isCharPostureValid() const
Query whether the italic mode attribute is valid.
void setPosition(const ::basegfx::B2DPoint &rNewPos)
Set the new position of the shape.
void setFillStyle(const sal_Int16 &rStyle)
Changes polygon fillings.
bool isFillColorValid() const
Query whether the fill color attribute is valid.
void setUnderlineMode(const sal_Int16 &bUnderline)
Set the underline status globally for the whole shape.
void setHeight(const double &rNewHeight)
Set the new height of the shape.
bool isLineColorValid() const
Query whether the line color attribute is valid.
bool isFontFamilyValid() const
Query whether the font family attribute is valid.
bool isVisibilityValid() const
Query whether the visibility state attribute is valid.
bool isRotationAngleValid() const
Query whether the rotation angle attribute is valid.
RGBColor getCharColor() const
Get the text color for the whole shape.
double getPosY() const
Query the current y position of the shape.
void setRotationAngle(const double &rNewAngle)
Set the new rotation angle of the shape.
bool isCharColorValid() const
Query whether the char color attribute is valid.
sal_Int16 getLineStyle() const
Get the current line mode for line drawing.
void setCharColor(const RGBColor &nNewColor)
Set the text color globally for the whole shape.
bool isCharScaleValid() const
Query whether the char scaling attribute is valid.
bool isPosXValid() const
Query whether the x position attribute is valid.
bool isDimColorValid() const
Query whether the dim color attribute is valid.
double getShearXAngle() const
Query the current shear angle at the x axis of the shape.
sal_Int16 getFillStyle() const
Get the current fill mode for polygon fillings.
double getAlpha() const
Query the current alpha value of the shape.
bool isWidthValid() const
Query whether the width attribute is valid.
void setFillColor(const RGBColor &nNewColor)
Set the fill color globally for the whole shape.
void setCharScale(const double &rNewScale)
Set the new char scale globally for the shape.
bool isPosYValid() const
Query whether the y position attribute is valid.
bool isAlphaValid() const
Query whether the alpha attribute is valid.
double getRotationAngle() const
Query the current rotation angle of the shape.
void setDimColor(const RGBColor &nNewColor)
Set the dim color globally for the whole shape.
bool isLineStyleValid() const
Query whether the line mode attribute is valid.
double getHeight() const
Query the current height of the shape.
double getWidth() const
Query the current width of the shape.
sal_Int16 getUnderlineMode() const
Get the current text underline status for the whole shape.
bool isFillStyleValid() const
Query whether the fill mode attribute is valid.
sal_Int16 getCharPosture() const
Get the current text italic style for the whole shape.
bool isCharWeightValid() const
Query whether the char weight attribute is valid.
bool getVisibility() const
Get the current shape visibility.
double getPosX() const
Query the current x position of the shape.
void setShearXAngle(const double &rNewAngle)
Set the new shear angle at the x axis of the shape.
double getCharScale() const
Query the current char scaling attribute globally for the shape.
void setLineColor(const RGBColor &nNewColor)
Set the line color globally for the whole shape.
RGBColor getLineColor() const
Get the line color for the whole shape.
bool isHeightValid() const
Query whether the height attribute is valid.
void setPosY(const double &rNewY)
Set the new y position of the shape.
#define ENSURE_OR_RETURN_FALSE(c, m)
#define ENSURE_OR_THROW(c, m)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
std::shared_ptr< box2DBody > Box2DBodySharedPtr
::std::shared_ptr< box2DWorld > Box2DWorldSharedPtr
@ FLAG_NO_SPRITE
Don't call enter/leaveAnimation for the Shape.
NumberAnimationSharedPtr createNumberPropertyAnimation(const OUString &rAttrName, const AnimatableShapeSharedPtr &rShape, const ShapeManagerSharedPtr &rShapeManager, const ::basegfx::B2DVector &rSlideSize, const box2d::utils::Box2DWorldSharedPtr &pBox2DWorld, int nFlags=0)
PairAnimationSharedPtr createPairPropertyAnimation(const AnimatableShapeSharedPtr &rShape, const ShapeManagerSharedPtr &rShapeManager, const ::basegfx::B2DVector &rSlideSize, sal_Int16 nTransformType, int nFlags)
Create scale or move animation.
NumberAnimationSharedPtr createPhysicsAnimation(const box2d::utils::Box2DWorldSharedPtr &pBox2DWorld, const double fDuration, const ShapeManagerSharedPtr &rShapeManager, const ::basegfx::B2DVector &rSlideSize, const ::basegfx::B2DVector &rStartVelocity, const double fDensity, const double fBounciness, int nFlags)
AttributeClass classifyAttributeName(const OUString &rAttrName)
ColorAnimationSharedPtr createColorPropertyAnimation(const OUString &rAttrName, const AnimatableShapeSharedPtr &rShape, const ShapeManagerSharedPtr &rShapeManager, const ::basegfx::B2DVector &rSlideSize, const box2d::utils::Box2DWorldSharedPtr &pBox2DWorld, int nFlags=0)
NumberAnimationSharedPtr createPathMotionAnimation(const OUString &rSVGDPath, sal_Int16 nAdditive, const AnimatableShapeSharedPtr &rShape, const ShapeManagerSharedPtr &rShapeManager, const ::basegfx::B2DVector &rSlideSize, const box2d::utils::Box2DWorldSharedPtr &pBox2DWorld, int nFlags)
AttributeClass
Classifies the attribute name.
@ CLASS_STRING_PROPERTY
Use createStringPropertyAnimation.
@ CLASS_UNKNOWN_PROPERTY
Unknown, prolly invalid name.
@ CLASS_COLOR_PROPERTY
Use createColorPropertyAnimation.
@ CLASS_BOOL_PROPERTY
Use createBoolPropertyAnimation.
@ CLASS_NUMBER_PROPERTY
Use createNumberPropertyAnimation.
@ CLASS_ENUM_PROPERTY
Use createEnumPropertyAnimation.
BoolAnimationSharedPtr createBoolPropertyAnimation(const OUString &rAttrName, const AnimatableShapeSharedPtr &rShape, const ShapeManagerSharedPtr &rShapeManager, const ::basegfx::B2DVector &rSlideSize, const box2d::utils::Box2DWorldSharedPtr &pBox2DWorld, int nFlags)
EnumAnimationSharedPtr createEnumPropertyAnimation(const OUString &rAttrName, const AnimatableShapeSharedPtr &rShape, const ShapeManagerSharedPtr &rShapeManager, const ::basegfx::B2DVector &rSlideSize, const box2d::utils::Box2DWorldSharedPtr &pBox2DWorld, int nFlags)
StringAnimationSharedPtr createStringPropertyAnimation(const OUString &rAttrName, const AnimatableShapeSharedPtr &rShape, const ShapeManagerSharedPtr &rShapeManager, const ::basegfx::B2DVector &rSlideSize, const box2d::utils::Box2DWorldSharedPtr &pBox2DWorld, int nFlags)
::std::shared_ptr< NumberAnimation > NumberAnimationSharedPtr
::std::shared_ptr< AnimatableShape > AnimatableShapeSharedPtr
::std::shared_ptr< ShapeAttributeLayer > ShapeAttributeLayerSharedPtr
::std::shared_ptr< PairAnimation > PairAnimationSharedPtr
::std::shared_ptr< BoolAnimation > BoolAnimationSharedPtr
::std::shared_ptr< EnumAnimation > EnumAnimationSharedPtr
::std::shared_ptr< StringAnimation > StringAnimationSharedPtr
AttributeType
Type of to-be-animated attribute.
std::shared_ptr< ShapeManager > ShapeManagerSharedPtr
::std::shared_ptr< ColorAnimation > ColorAnimationSharedPtr
AttributeType mapAttributeName(const OUString &rAttrName)
Map attribute name to AttributeType enum.