From 394f74e6f168f034f7ed73e3027e4ff07f6b94b9 Mon Sep 17 00:00:00 2001 From: Sarper Akdemir Date: Fri, 14 Aug 2020 01:18:14 +0300 Subject: add bounciness velocity and density options to physics animations Adding new xml options to specify the starting velocity, bounciness, and density of the rigid body that physics animation control. Change-Id: Ifaba785e82c8ee17be00711a3e7a75257e7704ae Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101141 Tested-by: Jenkins Reviewed-by: Thorsten Behrens --- animations/source/animcore/animcore.cxx | 87 +++++++++++++++++++++- include/xmloff/xmltoken.hxx | 4 + offapi/UnoApi_offapi.mk | 1 + offapi/com/sun/star/animations/XAnimatePhysics.idl | 57 ++++++++++++++ .../OpenDocument-schema-v1.3+libreoffice.rng | 2 +- slideshow/source/engine/animationfactory.cxx | 17 ++++- .../engine/animationnodes/animationphysicsnode.cxx | 47 +++++++++++- .../engine/animationnodes/animationphysicsnode.hxx | 3 +- slideshow/source/engine/box2dtools.cxx | 47 ++++++++++-- slideshow/source/inc/animationfactory.hxx | 3 + slideshow/source/inc/box2dtools.hxx | 10 ++- xmloff/source/core/xmltoken.cxx | 4 + xmloff/source/draw/animationexport.cxx | 36 ++++++++- xmloff/source/draw/animationimport.cxx | 33 ++++++++ xmloff/source/token/tokens.txt | 4 + 15 files changed, 337 insertions(+), 18 deletions(-) create mode 100644 offapi/com/sun/star/animations/XAnimatePhysics.idl diff --git a/animations/source/animcore/animcore.cxx b/animations/source/animcore/animcore.cxx index 88e42772936a..107353cf327a 100644 --- a/animations/source/animcore/animcore.cxx +++ b/animations/source/animcore/animcore.cxx @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -104,6 +105,7 @@ namespace animcore namespace { class AnimationNodeBase : public XAnimateMotion, + public XAnimatePhysics, public XAnimateColor, public XTransitionFilter, public XAnimateSet, @@ -224,6 +226,16 @@ public: virtual Any SAL_CALL getOrigin() override; virtual void SAL_CALL setOrigin( const Any& _origin ) override; + // XAnimatePhysics + virtual Any SAL_CALL getStartVelocityX() override; + virtual void SAL_CALL setStartVelocityX( const Any& _startvelocityx ) override; + virtual Any SAL_CALL getStartVelocityY() override; + virtual void SAL_CALL setStartVelocityY( const Any& _startvelocityy ) override; + virtual Any SAL_CALL getDensity() override; + virtual void SAL_CALL setDensity( const Any& _density ) override; + virtual Any SAL_CALL getBounciness() override; + virtual void SAL_CALL setBounciness( const Any& _bounciness ) override; + // XAnimateTransform virtual sal_Int16 SAL_CALL getTransformType() override; virtual void SAL_CALL setTransformType( sal_Int16 _transformtype ) override; @@ -322,6 +334,9 @@ private: // attributes for XAnimateMotion Any maPath, maOrigin; + // attributes for XAnimatePhysics + Any maStartVelocityX, maStartVelocityY, maDensity, maBounciness; + // attributes for XAnimateTransform sal_Int16 mnTransformType; @@ -671,8 +686,8 @@ Any SAL_CALL AnimationNode::queryInterface( const Type& aType ) case AnimationNodeType::ANIMATEPHYSICS: aRet = ::cppu::queryInterface( aType, - static_cast< XAnimate * >( static_cast< XAnimateMotion * >(this) ), - static_cast< XAnimateMotion * >( this ) ); + static_cast< XAnimate * >( static_cast< XAnimatePhysics * >(this) ), + static_cast< XAnimatePhysics * >( this ) ); break; case AnimationNodeType::ANIMATECOLOR: aRet = ::cppu::queryInterface( @@ -767,7 +782,7 @@ void AnimationNode::initTypeProvider( sal_Int16 nNodeType ) throw() pTypeAr[nPos++] = cppu::UnoType::get(); break; case AnimationNodeType::ANIMATEPHYSICS: - pTypeAr[nPos++] = cppu::UnoType::get(); + pTypeAr[nPos++] = cppu::UnoType::get(); break; case AnimationNodeType::ANIMATECOLOR: pTypeAr[nPos++] = cppu::UnoType::get(); @@ -1584,6 +1599,72 @@ void SAL_CALL AnimationNode::setOrigin( const Any& _origin ) fireChangeListener(); } +// XAnimatePhysics +Any SAL_CALL AnimationNode::getStartVelocityX() +{ + Guard< Mutex > aGuard( maMutex ); + return maStartVelocityX; +} + + +// XAnimatePhysics +void SAL_CALL AnimationNode::setStartVelocityX( const Any& _startvelocityx ) +{ + Guard< Mutex > aGuard( maMutex ); + maStartVelocityX = _startvelocityx; + fireChangeListener(); +} + +// XAnimatePhysics +Any SAL_CALL AnimationNode::getStartVelocityY() +{ + Guard< Mutex > aGuard( maMutex ); + return maStartVelocityY; +} + + +// XAnimatePhysics +void SAL_CALL AnimationNode::setStartVelocityY( const Any& _startvelocityy ) +{ + Guard< Mutex > aGuard( maMutex ); + maStartVelocityY = _startvelocityy; + fireChangeListener(); +} + + +// XAnimatePhysics +Any SAL_CALL AnimationNode::getDensity() +{ + Guard< Mutex > aGuard( maMutex ); + return maDensity; +} + + +// XAnimatePhysics +void SAL_CALL AnimationNode::setDensity( const Any& _density ) +{ + Guard< Mutex > aGuard( maMutex ); + maDensity = _density; + fireChangeListener(); +} + + +// XAnimatePhysics +Any SAL_CALL AnimationNode::getBounciness() +{ + Guard< Mutex > aGuard( maMutex ); + return maBounciness; +} + + +// XAnimatePhysics +void SAL_CALL AnimationNode::setBounciness( const Any& _bounciness ) +{ + Guard< Mutex > aGuard( maMutex ); + maBounciness = _bounciness; + fireChangeListener(); +} + // XAnimateTransform sal_Int16 SAL_CALL AnimationNode::getTransformType() diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx index 842da16ad084..4e0385914cf3 100644 --- a/include/xmloff/xmltoken.hxx +++ b/include/xmloff/xmltoken.hxx @@ -1446,6 +1446,10 @@ namespace xmloff::token { XML_PERSPECTIVE, XML_PHDTHESIS, XML_PHONG, + XML_PHYSICS_ANIMATION_START_VELOCITY_X, + XML_PHYSICS_ANIMATION_START_VELOCITY_Y, + XML_PHYSICS_ANIMATION_DENSITY, + XML_PHYSICS_ANIMATION_BOUNCINESS, XML_PIE_OFFSET, XML_PLACEHOLDER, XML_PLACEHOLDER_TYPE, diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk index 8a4631dfa52a..23138250b9d4 100644 --- a/offapi/UnoApi_offapi.mk +++ b/offapi/UnoApi_offapi.mk @@ -1681,6 +1681,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/animations,\ XAnimate \ XAnimateColor \ XAnimateMotion \ + XAnimatePhysics \ XAnimateSet \ XAnimateTransform \ XAnimationListener \ diff --git a/offapi/com/sun/star/animations/XAnimatePhysics.idl b/offapi/com/sun/star/animations/XAnimatePhysics.idl new file mode 100644 index 000000000000..0b1ba7577335 --- /dev/null +++ b/offapi/com/sun/star/animations/XAnimatePhysics.idl @@ -0,0 +1,57 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +#ifndef __com_sun_star_animations_XAnimatePhysics_idl__ +#define __com_sun_star_animations_XAnimatePhysics_idl__ + +#include + + + module com { module sun { module star { module animations { + + +/** Interface for physics animation. + + @since LibreOffice 7.1 +*/ +interface XAnimatePhysics : XAnimate +{ + /** Specifies an optional horizontal starting velocity + + Expressed in 1/100 mm. + */ + [attribute] any StartVelocityX; + + /** Specifies an optional vertical starting velocity + + Expressed in 1/100 mm. + */ + [attribute] any StartVelocityY; + + /** Specifies an optional density value + + Expressed in kg/m^2. + Should be non-negative. + Has a default value of 1. + */ + [attribute] any Density; + + /** Specifies an optional bounciness value + + Takes a value between [0,1], 1 being no energy loss on collisions + Has a default value of 0.1 + */ + [attribute] any Bounciness; +}; + + +}; }; }; }; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng b/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng index b65dd74407a6..5141f9e0fbe4 100644 --- a/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng +++ b/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng @@ -2448,7 +2448,7 @@ xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1. - 0 + 0 1 diff --git a/slideshow/source/engine/animationfactory.cxx b/slideshow/source/engine/animationfactory.cxx index 8f6534a30539..327a048afeb1 100644 --- a/slideshow/source/engine/animationfactory.cxx +++ b/slideshow/source/engine/animationfactory.cxx @@ -362,6 +362,9 @@ namespace slideshow::internal const double fDuration, const ShapeManagerSharedPtr& rShapeManager, const ::basegfx::B2DVector& rSlideSize, + const ::basegfx::B2DVector& rStartVelocity, + const double fDensity, + const double fBounciness, int nFlags ) : mpShape(), mpAttrLayer(), @@ -372,6 +375,9 @@ namespace slideshow::internal mpBox2DBody(), mpBox2DWorld( pBox2DWorld ), mfDuration(fDuration), + maStartVelocity(rStartVelocity), + mfDensity(fDensity), + mfBounciness(fBounciness), mfPreviousElapsedTime(0.00f), mbIsBox2dWorldStepper(false) { @@ -411,7 +417,7 @@ namespace slideshow::internal ENSURE_OR_THROW( rAttrLayer, "PhysicsAnimation::start(): Invalid attribute layer" ); - mpBox2DBody = mpBox2DWorld->makeShapeDynamic( rShape ); + mpBox2DBody = mpBox2DWorld->makeShapeDynamic( rShape->getXShape(), maStartVelocity, mfDensity, mfBounciness ); if( !mbAnimationStarted ) { @@ -495,6 +501,9 @@ namespace slideshow::internal box2d::utils::Box2DBodySharedPtr mpBox2DBody; box2d::utils::Box2DWorldSharedPtr mpBox2DWorld; double mfDuration; + const ::basegfx::B2DVector maStartVelocity; + const double mfDensity; + const double mfBounciness; double mfPreviousElapsedTime; bool mbIsBox2dWorldStepper; }; @@ -1468,11 +1477,17 @@ namespace slideshow::internal const double fDuration, const ShapeManagerSharedPtr& rShapeManager, const ::basegfx::B2DVector& rSlideSize, + const ::basegfx::B2DVector& rStartVelocity, + const double fDensity, + const double fBounciness, int nFlags ) { return std::make_shared( pBox2DWorld, fDuration, rShapeManager, rSlideSize, + rStartVelocity, + fDensity, + fBounciness, nFlags ); } diff --git a/slideshow/source/engine/animationnodes/animationphysicsnode.cxx b/slideshow/source/engine/animationnodes/animationphysicsnode.cxx index 8f531ea24ed7..3c7c227f2d0c 100644 --- a/slideshow/source/engine/animationnodes/animationphysicsnode.cxx +++ b/slideshow/source/engine/animationnodes/animationphysicsnode.cxx @@ -19,6 +19,12 @@ #include "animationphysicsnode.hxx" #include +#include + +constexpr double fDefaultStartVelocityX(0.0); +constexpr double fDefaultStartVelocityY(0.0); +constexpr double fDefaultDensity(1.0); +constexpr double fDefaultBounciness(0.1); namespace slideshow::internal { @@ -34,12 +40,47 @@ AnimationActivitySharedPtr AnimationPhysicsNode::createActivity() const ENSURE_OR_THROW((mxPhysicsMotionNode->getDuration() >>= fDuration), "Couldn't get the animation duration."); + ::css::uno::Any aTemp; + double fStartVelocityX; + aTemp = mxPhysicsMotionNode->getStartVelocityX(); + if (aTemp.hasValue()) + aTemp >>= fStartVelocityX; + else + fStartVelocityX = fDefaultStartVelocityX; + + double fStartVelocityY; + aTemp = mxPhysicsMotionNode->getStartVelocityY(); + if (aTemp.hasValue()) + aTemp >>= fStartVelocityY; + else + fStartVelocityY = fDefaultStartVelocityY; + + double fDensity; + aTemp = mxPhysicsMotionNode->getDensity(); + if (aTemp.hasValue()) + { + aTemp >>= fDensity; + fDensity = (fDensity < 0.0) ? 0.0 : fDensity; + } + else + fDensity = fDefaultDensity; + + double fBounciness; + aTemp = mxPhysicsMotionNode->getBounciness(); + if (aTemp.hasValue()) + { + aTemp >>= fBounciness; + fBounciness = std::clamp(fBounciness, 0.0, 1.0); + } + else + fBounciness = fDefaultBounciness; + ActivitiesFactory::CommonParameters const aParms(fillCommonParameters()); return ActivitiesFactory::createSimpleActivity( aParms, - AnimationFactory::createPhysicsAnimation(getContext().mpBox2DWorld, fDuration, - getContext().mpSubsettableShapeManager, - getSlideSize(), 0), + AnimationFactory::createPhysicsAnimation( + getContext().mpBox2DWorld, fDuration, getContext().mpSubsettableShapeManager, + getSlideSize(), { fStartVelocityX, fStartVelocityY }, fDensity, fBounciness, 0), true); } diff --git a/slideshow/source/engine/animationnodes/animationphysicsnode.hxx b/slideshow/source/engine/animationnodes/animationphysicsnode.hxx index 8517dbbb803b..d9af6802a037 100644 --- a/slideshow/source/engine/animationnodes/animationphysicsnode.hxx +++ b/slideshow/source/engine/animationnodes/animationphysicsnode.hxx @@ -20,6 +20,7 @@ #include "animationbasenode.hxx" #include +#include namespace slideshow { @@ -46,7 +47,7 @@ private: virtual AnimationActivitySharedPtr createActivity() const override; virtual bool enqueueActivity() const override; - css::uno::Reference mxPhysicsMotionNode; + css::uno::Reference mxPhysicsMotionNode; }; } // namespace internal diff --git a/slideshow/source/engine/box2dtools.cxx b/slideshow/source/engine/box2dtools.cxx index bdeabc12e985..845363501ca4 100644 --- a/slideshow/source/engine/box2dtools.cxx +++ b/slideshow/source/engine/box2dtools.cxx @@ -20,6 +20,7 @@ #include #define BOX2D_SLIDE_SIZE_IN_METERS 100.00f +constexpr double fDefaultStaticBodyBounciness(0.1); namespace box2d::utils { @@ -551,6 +552,13 @@ void box2DWorld::queueShapeAnimationEndUpdate( } } +void box2DWorld::alertAnimationEndForShape(const slideshow::internal::ShapeSharedPtr& pShape) +{ + Box2DBodySharedPtr pBox2DBody = mpXShapeToBodyMap.find(pShape->getXShape())->second; + makeBodyStatic(pBox2DBody); + pBox2DBody->setRestitution(fDefaultStaticBodyBounciness); +} + void box2DWorld::step(const float fTimeStep, const int nVelocityIterations, const int nPositionIterations) { @@ -586,10 +594,15 @@ bool box2DWorld::isInitialized() return false; } -Box2DBodySharedPtr box2DWorld::makeShapeDynamic(const slideshow::internal::ShapeSharedPtr& pShape) +Box2DBodySharedPtr +box2DWorld::makeShapeDynamic(const css::uno::Reference& xShape, + const basegfx::B2DVector& rStartVelocity, const double fDensity, + const double fBounciness) { assert(mpBox2DWorld); - Box2DBodySharedPtr pBox2DBody = mpXShapeToBodyMap.find(pShape->getXShape())->second; + Box2DBodySharedPtr pBox2DBody = mpXShapeToBodyMap.find(xShape)->second; + pBox2DBody->setDensityAndRestitution(fDensity, fBounciness); + queueLinearVelocityUpdate(xShape, rStartVelocity, 1); return makeBodyDynamic(pBox2DBody); } @@ -679,15 +692,17 @@ Box2DBodySharedPtr box2DWorld::createStaticBody(const slideshow::internal::Shape } else { - addEdgeShapeToBody(rPolygon, pBody.get(), fDensity, fFriction, 0.1f, mfScaleFactor); + addEdgeShapeToBody(rPolygon, pBody.get(), fDensity, fFriction, + static_cast(fDefaultStaticBodyBounciness), mfScaleFactor); } } - addTriangleVectorToBody(aTriangleVector, pBody.get(), fDensity, fFriction, 0.1f, - mfScaleFactor); + addTriangleVectorToBody(aTriangleVector, pBody.get(), fDensity, fFriction, + static_cast(fDefaultStaticBodyBounciness), mfScaleFactor); } else { - addEdgeShapeToBody(aPolyPolygon, pBody.get(), fDensity, fFriction, 0.1f, mfScaleFactor); + addEdgeShapeToBody(aPolyPolygon, pBody.get(), fDensity, fFriction, + static_cast(fDefaultStaticBodyBounciness), mfScaleFactor); } return std::make_shared(pBody, mfScaleFactor); @@ -776,6 +791,26 @@ void box2DBody::setAngle(const double fAngle) mpBox2DBody->SetTransform(mpBox2DBody->GetPosition(), ::basegfx::deg2rad(-fAngle)); } +void box2DBody::setDensityAndRestitution(const double fDensity, const double fRestitution) +{ + for (b2Fixture* pFixture = mpBox2DBody->GetFixtureList(); pFixture; + pFixture = pFixture->GetNext()) + { + pFixture->SetDensity(static_cast(fDensity)); + pFixture->SetRestitution(static_cast(fRestitution)); + } + mpBox2DBody->ResetMassData(); +} + +void box2DBody::setRestitution(const double fRestitution) +{ + for (b2Fixture* pFixture = mpBox2DBody->GetFixtureList(); pFixture; + pFixture = pFixture->GetNext()) + { + pFixture->SetRestitution(static_cast(fRestitution)); + } +} + void box2DBody::setType(box2DBodyType eType) { mpBox2DBody->SetType(getBox2DInternalBodyType(eType)); diff --git a/slideshow/source/inc/animationfactory.hxx b/slideshow/source/inc/animationfactory.hxx index af3b9b9a4e49..3004c71308a9 100644 --- a/slideshow/source/inc/animationfactory.hxx +++ b/slideshow/source/inc/animationfactory.hxx @@ -137,6 +137,9 @@ namespace slideshow::internal const double fDuration, const ShapeManagerSharedPtr& rShapeManager, const ::basegfx::B2DVector& rSlideSize, + const ::basegfx::B2DVector& rStartVelocity, + const double fDensity, + const double fBounciness, int nFlags ); } diff --git a/slideshow/source/inc/box2dtools.hxx b/slideshow/source/inc/box2dtools.hxx index 08b0f4b557cf..0debf1da4ef0 100644 --- a/slideshow/source/inc/box2dtools.hxx +++ b/slideshow/source/inc/box2dtools.hxx @@ -221,7 +221,9 @@ public: @param pShape Pointer to the shape to alter the corresponding Box2D body of */ - Box2DBodySharedPtr makeShapeDynamic(const slideshow::internal::ShapeSharedPtr& pShape); + Box2DBodySharedPtr makeShapeDynamic(const css::uno::Reference& xShape, + const basegfx::B2DVector& rStartVelocity, + const double fDensity, const double fBounciness); /** Make the Box2D body corresponding to the given shape a static one @@ -267,6 +269,8 @@ public: void queueShapeAnimationEndUpdate(const css::uno::Reference& xShape, const slideshow::internal::AttributeType eAttrType); + + void alertAnimationEndForShape(const slideshow::internal::ShapeSharedPtr& pShape); }; /// Class that manages a single box2D Body @@ -327,6 +331,10 @@ public: void setAngle(const double fAngle); + void setDensityAndRestitution(const double fDensity, const double fRestitution); + + void setRestitution(const double fRestitution); + /// Set type of the body void setType(box2DBodyType eType); diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx index ce008e0cc370..b00d8f25985e 100644 --- a/xmloff/source/core/xmltoken.cxx +++ b/xmloff/source/core/xmltoken.cxx @@ -1452,6 +1452,10 @@ namespace xmloff::token { TOKEN( "perspective", XML_PERSPECTIVE ), TOKEN( "phdthesis", XML_PHDTHESIS ), TOKEN( "phong", XML_PHONG ), + TOKEN( "velocity-x", XML_PHYSICS_ANIMATION_START_VELOCITY_X ), + TOKEN( "velocity-y", XML_PHYSICS_ANIMATION_START_VELOCITY_Y ), + TOKEN( "density", XML_PHYSICS_ANIMATION_DENSITY ), + TOKEN( "bounciness", XML_PHYSICS_ANIMATION_BOUNCINESS ), TOKEN( "pie-offset", XML_PIE_OFFSET ), TOKEN( "placeholder", XML_PLACEHOLDER ), TOKEN( "placeholder-type", XML_PLACEHOLDER_TYPE ), diff --git a/xmloff/source/draw/animationexport.cxx b/xmloff/source/draw/animationexport.cxx index 2aa02c588ea3..c130f5a45919 100644 --- a/xmloff/source/draw/animationexport.cxx +++ b/xmloff/source/draw/animationexport.cxx @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -1245,9 +1246,40 @@ void AnimationsExporterImpl::exportAnimate( const Reference< XAnimate >& xAnimat case AnimationNodeType::ANIMATEPHYSICS: { eElementToken = XML_ANIMATEPHYSICS; + double fTemp; - Reference< XAnimateMotion > xAnimateMotion( xAnimate, UNO_QUERY_THROW ); - aTemp = xAnimateMotion->getOrigin(); + Reference< XAnimatePhysics > xAnimatePhysics( xAnimate, UNO_QUERY_THROW ); + aTemp = xAnimatePhysics->getStartVelocityX(); + if( aTemp.hasValue() ) + { + aTemp >>= fTemp; + ::sax::Converter::convertDouble( sTmp, fTemp ); + mxExport->AddAttribute( XML_NAMESPACE_LO_EXT, XML_PHYSICS_ANIMATION_START_VELOCITY_X, sTmp.makeStringAndClear() ); + } + + aTemp = xAnimatePhysics->getStartVelocityY(); + if( aTemp.hasValue() ) + { + aTemp >>= fTemp; + ::sax::Converter::convertDouble( sTmp, fTemp ); + mxExport->AddAttribute( XML_NAMESPACE_LO_EXT, XML_PHYSICS_ANIMATION_START_VELOCITY_Y, sTmp.makeStringAndClear() ); + } + + aTemp = xAnimatePhysics->getDensity(); + if( aTemp.hasValue() ) + { + aTemp >>= fTemp; + ::sax::Converter::convertDouble( sTmp, fTemp ); + mxExport->AddAttribute( XML_NAMESPACE_LO_EXT, XML_PHYSICS_ANIMATION_DENSITY, sTmp.makeStringAndClear() ); + } + + aTemp = xAnimatePhysics->getBounciness(); + if( aTemp.hasValue() ) + { + aTemp >>= fTemp; + ::sax::Converter::convertDouble( sTmp, fTemp ); + mxExport->AddAttribute( XML_NAMESPACE_LO_EXT, XML_PHYSICS_ANIMATION_BOUNCINESS, sTmp.makeStringAndClear() ); + } } break; diff --git a/xmloff/source/draw/animationimport.cxx b/xmloff/source/draw/animationimport.cxx index f8c9e743aa84..5076ff1d98be 100644 --- a/xmloff/source/draw/animationimport.cxx +++ b/xmloff/source/draw/animationimport.cxx @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -924,6 +925,38 @@ void AnimationNodeContext::init_node( const css::uno::Reference< css::xml::sax: } break; + case XML_ELEMENT(LO_EXT, XML_PHYSICS_ANIMATION_START_VELOCITY_X): + { + Reference< XAnimatePhysics > xAnimatePhysics( mxNode, UNO_QUERY ); + if( xAnimatePhysics.is() ) + xAnimatePhysics->setStartVelocityX( makeAny(rValue.toDouble()) ); + } + break; + + case XML_ELEMENT(LO_EXT, XML_PHYSICS_ANIMATION_START_VELOCITY_Y): + { + Reference< XAnimatePhysics > xAnimatePhysics( mxNode, UNO_QUERY ); + if( xAnimatePhysics.is() ) + xAnimatePhysics->setStartVelocityY( makeAny(rValue.toDouble()) ); + } + break; + + case XML_ELEMENT(LO_EXT, XML_PHYSICS_ANIMATION_DENSITY): + { + Reference< XAnimatePhysics > xAnimatePhysics( mxNode, UNO_QUERY ); + if( xAnimatePhysics.is() ) + xAnimatePhysics->setDensity( makeAny(rValue.toDouble()) ); + } + break; + + case XML_ELEMENT(LO_EXT, XML_PHYSICS_ANIMATION_BOUNCINESS): + { + Reference< XAnimatePhysics > xAnimatePhysics( mxNode, UNO_QUERY ); + if( xAnimatePhysics.is() ) + xAnimatePhysics->setBounciness( makeAny(rValue.toDouble()) ); + } + break; + case XML_ELEMENT(ANIMATION, XML_COLOR_INTERPOLATION): case XML_ELEMENT(ANIMATION_OOO, XML_COLOR_INTERPOLATION): { diff --git a/xmloff/source/token/tokens.txt b/xmloff/source/token/tokens.txt index 5e0f50bc53d2..259dd4ce9eac 100644 --- a/xmloff/source/token/tokens.txt +++ b/xmloff/source/token/tokens.txt @@ -1362,6 +1362,10 @@ percentage-style perspective phdthesis phong +velocity-x +velocity-y +density +bounciness pie-offset placeholder placeholder-type -- cgit