summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorSarper Akdemir <q.sarperakdemir@gmail.com>2020-08-14 01:18:14 +0300
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2020-08-22 11:24:16 +0200
commit394f74e6f168f034f7ed73e3027e4ff07f6b94b9 (patch)
treeb4da98e1d95e6bd3bf0e0a1cf30a9a5769907dc3 /xmloff
parent8a360d04e43410e729c0ee270be5447ce6c1cd03 (diff)
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 <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/core/xmltoken.cxx4
-rw-r--r--xmloff/source/draw/animationexport.cxx36
-rw-r--r--xmloff/source/draw/animationimport.cxx33
-rw-r--r--xmloff/source/token/tokens.txt4
4 files changed, 75 insertions, 2 deletions
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 <com/sun/star/animations/Timing.hpp>
#include <com/sun/star/animations/Event.hpp>
#include <com/sun/star/animations/XAnimateMotion.hpp>
+#include <com/sun/star/animations/XAnimatePhysics.hpp>
#include <com/sun/star/animations/XAnimateTransform.hpp>
#include <com/sun/star/animations/XTransitionFilter.hpp>
#include <com/sun/star/animations/XIterateContainer.hpp>
@@ -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 <com/sun/star/animations/SequenceTimeContainer.hpp>
#include <com/sun/star/animations/XIterateContainer.hpp>
#include <com/sun/star/animations/XAnimateMotion.hpp>
+#include <com/sun/star/animations/XAnimatePhysics.hpp>
#include <com/sun/star/animations/XAnimateColor.hpp>
#include <com/sun/star/animations/XAnimateTransform.hpp>
#include <com/sun/star/animations/XTransitionFilter.hpp>
@@ -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