[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.0' - 3 commits - filter/source
Marco Cecchetti
marco.cecchetti at collabora.com
Wed Jan 13 08:41:18 PST 2016
filter/source/svg/presentation_engine.js | 204 +++++++++++++++++--------------
filter/source/svg/svgexport.cxx | 5
2 files changed, 119 insertions(+), 90 deletions(-)
New commits:
commit d8c69d313b717c5dcf158e8a9d1a9c8497ab8a68
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date: Wed Jan 13 17:27:56 2016 +0100
svg export: simultaneous move and zoom issue - fixed
Simultaneaous move and zoom of shapes did not work properly.
Fixed.
Change-Id: I445733c5ad3734966f6f5c08a5e5c798852cf74e
diff --git a/filter/source/svg/presentation_engine.js b/filter/source/svg/presentation_engine.js
index 46946a0..09bf196 100644
--- a/filter/source/svg/presentation_engine.js
+++ b/filter/source/svg/presentation_engine.js
@@ -8788,7 +8788,6 @@ AnimatedElement.prototype.initElement = function()
this.nCenterY = this.nBaseCenterY;
this.nScaleFactorX = 1.0;
this.nScaleFactorY = 1.0;
- this.setCTM();
// add a transform attribute of type matrix
this.aActiveElement.setAttribute( 'transform', makeMatrixString( 1, 0, 0, 1, 0, 0 ) );
@@ -9077,117 +9076,82 @@ AnimatedElement.prototype.getHeight = function()
return this.nScaleFactorY * this.getBaseBBox().height;
};
-AnimatedElement.prototype.setCTM = function()
-{
-
- this.aICTM.e = this.getBaseCenterX();
- this.aICTM.f = this.getBaseCenterY();
-
- this.aCTM.e = -this.aICTM.e;
- this.aCTM.f = -this.aICTM.f;
-};
-
AnimatedElement.prototype.updateTransformAttribute = function()
{
+ //this.aActiveElement.setAttribute( 'transform', matrixToString( this.aTMatrix ) );
this.aTransformAttrList = this.aActiveElement.transform.baseVal;
this.aTransformAttr = this.aTransformAttrList.getItem( 0 );
this.aTransformAttr.setMatrix( this.aTMatrix );
};
-AnimatedElement.prototype.setX = function( nXNewPos )
+AnimatedElement.prototype.setX = function( nNewCenterX )
{
+ if( nNewCenterX === this.nCenterX ) return;
+
this.aTransformAttrList = this.aActiveElement.transform.baseVal;
this.aTransformAttr = this.aTransformAttrList.getItem( 0 );
- this.aTransformAttr.matrix.e += ( nXNewPos - this.getX() );
- this.nCenterX = nXNewPos;
+ this.aTMatrix = this.aTransformAttr.matrix.translate( nNewCenterX - this.nCenterX, 0 );
+ this.aTransformAttr.setMatrix( this.aTMatrix );
+ this.nCenterX = nNewCenterX;
};
-AnimatedElement.prototype.setY = function( nYNewPos )
+AnimatedElement.prototype.setY = function( nNewCenterY )
{
+ if( nNewCenterY === this.nCenterY ) return;
+
this.aTransformAttrList = this.aActiveElement.transform.baseVal;
this.aTransformAttr = this.aTransformAttrList.getItem( 0 );
- this.aTransformAttr.matrix.f += ( nYNewPos - this.getY() );
- this.nCenterY = nYNewPos;
+ this.aTMatrix = this.aTransformAttr.matrix.translate( 0, nNewCenterY - this.nCenterY );
+ this.aTransformAttr.setMatrix( this.aTMatrix );
+ this.nCenterY = nNewCenterY;
};
AnimatedElement.prototype.setWidth = function( nNewWidth )
{
- var nBaseWidth = this.getBaseBBox().width;
- if( nBaseWidth <= 0 )
- return;
-
- this.nScaleFactorX = nNewWidth / nBaseWidth;
- this.implScale();
-};
-
-AnimatedElement.prototype.setHeight = function( nNewHeight )
-{
- var nBaseHeight = this.getBaseBBox().height;
- if( nBaseHeight <= 0 )
- return;
-
- this.nScaleFactorY = nNewHeight / nBaseHeight;
- this.implScale();
-};
-
-AnimatedElement.prototype.implScale = function( )
-{
- this.aTMatrix = document.documentElement.createSVGMatrix();
- this.aTMatrix.a = this.nScaleFactorX;
- this.aTMatrix.d = this.nScaleFactorY;
- this.aTMatrix = this.aICTM.multiply( this.aTMatrix.multiply( this.aCTM ) );
-
- var nDeltaX = this.getX() - this.getBaseCenterX();
- var nDeltaY = this.getY() - this.getBaseCenterY();
- this.aTMatrix = this.aTMatrix.translate( nDeltaX, nDeltaY );
- this.updateTransformAttribute();
-};
-
-AnimatedElement.prototype.setWidth2 = function( nNewWidth )
-{
+ ANIMDBG.print( 'AnimatedElement.setWidth: nNewWidth = ' + nNewWidth );
if( nNewWidth < 0 )
- log( 'AnimatedElement(' + this.getId() + ').setWidth: negative width!' );
- if( nNewWidth < 0.001 )
- nNewWidth = 0.001;
+ {
+ log('AnimatedElement(' + this.getId() + ').setWidth: negative height!');
+ nNewWidth = 0;
+ }
- this.setCTM();
+ var nBaseWidth = this.getBaseBBox().width;
+ var nScaleFactorX = nNewWidth / nBaseWidth;
- var nCurWidth = this.getWidth();
- if( nCurWidth <= 0 )
- nCurWidth = 0.001;
+ if( nScaleFactorX < 1e-5 ) nScaleFactorX = 1e-5;
+ if( nScaleFactorX == this.nScaleFactorX ) return;
- var nScaleFactor = nNewWidth / nCurWidth;
- if( nScaleFactor < 1e-5 )
- nScaleFactor = 1e-5;
- this.aTMatrix = document.documentElement.createSVGMatrix();
- this.aTMatrix.a = nScaleFactor;
- this.aTMatrix = this.aICTM.multiply( this.aTMatrix.multiply( this.aCTM ) );
+ this.aTMatrix = document.documentElement.createSVGMatrix()
+ .translate( this.nCenterX, this.nCenterY )
+ .scaleNonUniform( nScaleFactorX, this.nScaleFactorY )
+ .translate( -this.nBaseCenterX, -this.nBaseCenterY );
this.updateTransformAttribute();
+
+ this.nScaleFactorX = nScaleFactorX;
};
-AnimatedElement.prototype.setHeight2 = function( nNewHeight )
+AnimatedElement.prototype.setHeight = function( nNewHeight )
{
- ANIMDBG.print( 'AnimatedElement.setHeight: nNewHeight = ' + nNewHeight );
+ ANIMDBG.print( 'AnimatedElement.setWidth: nNewHeight = ' + nNewHeight );
if( nNewHeight < 0 )
- log( 'AnimatedElement(' + this.getId() + ').setWidth: negative height!' );
- if( nNewHeight < 0.001 )
- nNewHeight = 0.001;
+ {
+ log('AnimatedElement(' + this.getId() + ').setWidth: negative height!');
+ nNewHeight = 0;
+ }
- this.setCTM();
+ var nBaseHeight = this.getBaseBBox().height;
+ var nScaleFactorY = nNewHeight / nBaseHeight;
- var nCurHeight = this.getHeight();
- ANIMDBG.print( 'AnimatedElement.setHeight: nCurHeight = ' + nCurHeight );
- if( nCurHeight <= 0 )
- nCurHeight = 0.001;
+ if( nScaleFactorY < 1e-5 ) nScaleFactorY = 1e-5;
+ if( nScaleFactorY == this.nScaleFactorY ) return;
- var nScaleFactor = nNewHeight / nCurHeight;
- ANIMDBG.print( 'AnimatedElement.setHeight: nScaleFactor = ' + nScaleFactor );
- if( nScaleFactor < 1e-5 )
- nScaleFactor = 1e-5;
- this.aTMatrix = document.documentElement.createSVGMatrix();
- this.aTMatrix.d = nScaleFactor;
- this.aTMatrix = this.aICTM.multiply( this.aTMatrix.multiply( this.aCTM ) );
+ this.aTMatrix = document.documentElement.createSVGMatrix()
+ .translate( this.nCenterX, this.nCenterY )
+ .scaleNonUniform( this.nScaleFactorX, nScaleFactorY )
+ .translate( -this.nBaseCenterX, -this.nBaseCenterY );
this.updateTransformAttribute();
+
+ this.nScaleFactorY = nScaleFactorY;
};
AnimatedElement.prototype.getOpacity = function()
commit 86a1be7c4742828c706842eb87cc2091edaafb79
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date: Wed Jan 13 16:44:51 2016 +0100
svg export: added support for anim:formula attribute
Added support for formula attribute used from some effect such as spiral
in. Better support for parsing value list.
Change-Id: Ibf25482eba359acb279d9b212d7a829b3dc668b6
diff --git a/filter/source/svg/presentation_engine.js b/filter/source/svg/presentation_engine.js
index 757f4e1..46946a0 100644
--- a/filter/source/svg/presentation_engine.js
+++ b/filter/source/svg/presentation_engine.js
@@ -5986,6 +5986,7 @@ function AnimationBaseNode3( aAnimElem, aParentNode, aNodeContext )
this.aByValue = null;
this.aKeyTimes = null;
this.aValues = null;
+ this.aFormula= null;
}
extend( AnimationBaseNode3, AnimationBaseNode2 );
@@ -6036,6 +6037,9 @@ AnimationBaseNode3.prototype.parseElement = function()
this.aValues = [];
}
+ // formula attribute
+ this.aFormula = aAnimElem.getAttributeNS( NSS['anim'], 'formula' );
+
return bRet;
};
@@ -6069,6 +6073,11 @@ AnimationBaseNode3.prototype.getValues = function()
return this.aValues;
};
+AnimationBaseNode3.prototype.getFormula = function()
+{
+ return this.aFormula;
+};
+
AnimationBaseNode3.prototype.info = function( bVerbose )
{
var sInfo = AnimationBaseNode3.superclass.info.call( this, bVerbose );
@@ -6097,6 +6106,10 @@ AnimationBaseNode3.prototype.info = function( bVerbose )
// values
if( this.getKeyTimes().length )
sInfo += '; values: ' + this.getValues().join( ',' );
+
+ // formula
+ if( this.getFormula() )
+ sInfo += '; formula: ' + this.getFormula();
}
return sInfo;
@@ -10977,6 +10990,7 @@ function ActivityParamSet()
this.nDecelerationFraction = 0.0;
this.nSlideWidth = undefined;
this.nSlideHeight = undefined;
+ this.aFormula = null;
this.aDiscreteTimes = [];
}
@@ -11642,6 +11656,7 @@ function FromToByActivityTemplate( BaseType ) // template parameter
this.bDynamicStartValue = false;
this.nIteration = 0;
this.bCumulative = bAccumulate;
+ this.aFormula = aActivityParamSet.aFormula;
//this.initAnimatedElement();
@@ -11651,7 +11666,10 @@ function FromToByActivityTemplate( BaseType ) // template parameter
FromToByActivity.prototype.initAnimatedElement = function()
{
if( this.aAnimation && this.aFrom )
- this.aAnimation.perform( this.aFrom );
+ {
+ var aValue = this.aFormula ? this.aFormula( this.aFrom ) : this.aFrom;
+ this.aAnimation.perform(aValue);
+ }
};
FromToByActivity.prototype.startAnimation = function()
@@ -11790,6 +11808,7 @@ function FromToByActivityTemplate( BaseType ) // template parameter
aValue = this.add( this.scale( nRepeatCount, this.aEndValue ), aValue );
}
+ aValue = this.aFormula ? this.aFormula( aValue ) : aValue;
this.aAnimation.perform( aValue );
if( this.bDynamicStartValue )
@@ -11803,10 +11822,9 @@ function FromToByActivityTemplate( BaseType ) // template parameter
{
if( this.aAnimation )
{
- if( this.isAutoReverse() )
- this.aAnimation.perform( this.aStartValue );
- else
- this.aAnimation.perform( this.aEndValue );
+ var aValue = this.isAutoReverse() ? this.aStartValue : this.aEndValue;
+ aValue = this.aFormula ? this.aFormula( aValue ) : aValue;
+ this.aAnimation.perform( aValue );
}
};
@@ -11848,6 +11866,7 @@ function ValueListActivityTemplate( BaseType ) // template parameter
this.scale = aOperatorSet.scale;
this.bCumulative = bAccumulate;
this.aLastValue = this.aValueList[ this.aValueList.length - 1 ];
+ this.aFormula = aActivityParamSet.aFormula;
//this.initAnimatedElement();
}
@@ -11867,7 +11886,11 @@ function ValueListActivityTemplate( BaseType ) // template parameter
ValueListActivity.prototype.initAnimatedElement = function()
{
if( this.aAnimation )
- this.aAnimation.perform( this.aValueList[0] );
+ {
+ var aValue = this.aValueList[0];
+ aValue = this.aFormula ? this.aFormula( aValue ) : aValue;
+ this.aAnimation.perform(aValue);
+ }
};
ValueListActivity.prototype.startAnimation = function()
@@ -11912,6 +11935,8 @@ function ValueListActivityTemplate( BaseType ) // template parameter
aValue = this.add( aValue, this.scale( nRepeatCount, this.aLastValue ) );
//aValue = aValue + nRepeatCount * this.aLastValue;
}
+
+ aValue = this.aFormula ? this.aFormula( aValue ) : aValue;
this.aAnimation.perform( aValue );
};
@@ -11919,7 +11944,8 @@ function ValueListActivityTemplate( BaseType ) // template parameter
{
if( this.aAnimation )
{
- this.aAnimation.perform( this.aLastValue );
+ var aValue = this.aFormula ? this.aFormula( this.aLastValue ) : this.aLastValue;
+ this.aAnimation.perform( aValue );
}
};
@@ -11967,7 +11993,27 @@ function createActivity( aActivityParamSet, aAnimationNode, aAnimation, aInterpo
eValueType === STRING_PROPERTY ||
eValueType === ENUM_PROPERTY );
+ if( aAnimationNode.getFormula() )
+ {
+ var sFormula = aAnimationNode.getFormula();
+ var reMath = /abs|sqrt|asin|acos|atan|sin|cos|tan|exp|log|min|max/g;
+ sFormula = sFormula.replace(reMath, 'Math.$&');
+ sFormula = sFormula.replace(/pi(?!\w)/g, 'Math.PI');
+ sFormula = sFormula.replace(/e(?!\w)/g, 'Math.E');
+ sFormula = sFormula.replace(/\$/g, '__PARAM0__');
+
+ var aAnimatedElement = aAnimationNode.getAnimatedElement();
+ var aBBox = aAnimatedElement.getBaseBBox();
+ var width = aBBox.width / aActivityParamSet.nSlideWidth;
+ var height = aBBox.height / aActivityParamSet.nSlideHeight;
+ var x = ( aBBox.x + aBBox.width / 2 ) / aActivityParamSet.nSlideWidth;
+ var y = ( aBBox.y + aBBox.height / 2 ) / aActivityParamSet.nSlideHeight;
+ aActivityParamSet.aFormula = function( __PARAM0__ ) {
+
+ return eval(sFormula);
+ };
+ }
aActivityParamSet.aDiscreteTimes = aAnimationNode.getKeyTimes();
@@ -12156,9 +12202,15 @@ function evalValuesAttribute( aValueList, aValueSet, aBBox, nSlideWidth, nSlideH
var x = ( aBBox.x + aBBox.width / 2 ) / nSlideWidth;
var y = ( aBBox.y + aBBox.height / 2 ) / nSlideHeight;
+ var reMath = /abs|sqrt|asin|acos|atan|sin|cos|tan|exp|log|min|max/g;
+
for( var i = 0; i < aValueSet.length; ++i )
{
- var aValue = eval( aValueSet[i] );
+ var sValue = aValueSet[i];
+ sValue = sValue.replace(reMath, 'Math.$&');
+ sValue = sValue.replace(/pi(?!\w)/g, 'Math.PI');
+ sValue = sValue.replace(/e(?!\w)/g, 'Math.E');
+ var aValue = eval( sValue );
aValueList.push( aValue );
}
}
commit 800040426b62169524e532f0e11e147c93e6850e
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date: Tue Jan 12 17:15:16 2016 +0100
svg export - group shape + indefinite duration - fixed
Fixed two issues:
- group shapes were not animated
- when smil:dur=indefinite final state of shapes was not frozen
Now when an audio or command node is hit a log message is printed
informing that such a type of animation nodes are not implemented.
Change-Id: I81853c982e6a2b68c3644b2ebc09e2d565d706af
diff --git a/filter/source/svg/presentation_engine.js b/filter/source/svg/presentation_engine.js
index 56fec95..757f4e1 100644
--- a/filter/source/svg/presentation_engine.js
+++ b/filter/source/svg/presentation_engine.js
@@ -3876,7 +3876,9 @@ aAnimationNodeTypeInMap = {
'animatemotion' : ANIMATION_NODE_ANIMATEMOTION,
'animatecolor' : ANIMATION_NODE_ANIMATECOLOR,
'animatetransform' : ANIMATION_NODE_ANIMATETRANSFORM,
- 'transitionfilter' : ANIMATION_NODE_TRANSITIONFILTER
+ 'transitionfilter' : ANIMATION_NODE_TRANSITIONFILTER,
+ 'audio' : ANIMATION_NODE_AUDIO,
+ 'command' : ANIMATION_NODE_COMMAND
};
@@ -5246,7 +5248,7 @@ BaseNode.prototype.parseElement = function()
{
this.eFillMode = ( this.aEnd ||
( this.nReapeatCount != 1) ||
- this.aDuration )
+ ( this.aDuration && !this.aDuration.isIndefinite() ) )
? FILL_MODE_REMOVE
: FILL_MODE_FREEZE;
}
@@ -7158,6 +7160,12 @@ function createAnimationNode( aElement, aParentNode, aNodeContext )
case ANIMATION_NODE_TRANSITIONFILTER:
aCreatedNode = new AnimationTransitionFilterNode( aElement, aParentNode, aNodeContext );
break;
+ case ANIMATION_NODE_AUDIO:
+ log( 'createAnimationNode: AUDIO not implemented' );
+ return null;
+ case ANIMATION_NODE_COMMAND:
+ log( 'createAnimationNode: COMMAND not implemented' );
+ return null;
default:
log( 'createAnimationNode: invalid Animation Node Type: ' + eAnimationNodeType );
return null;
diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx
index e9b29dc..53f681b 100644
--- a/filter/source/svg/svgexport.cxx
+++ b/filter/source/svg/svgexport.cxx
@@ -1807,6 +1807,11 @@ bool SVGFilter::implExportShape( const Reference< XShape >& rxShape,
if( xShapes.is() )
{
mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "class", "Group" );
+ const OUString& rShapeId = implGetValidIDFromInterface( Reference<XInterface>(rxShape, UNO_QUERY) );
+ if( !rShapeId.isEmpty() )
+ {
+ mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", rShapeId );
+ }
SvXMLElementExport aExp( *mpSVGExport, XML_NAMESPACE_NONE, "g", true, true );
bRet = implExportShapes( xShapes, bMaster );
More information about the Libreoffice-commits
mailing list