[Libreoffice-commits] core.git: filter/source

Marco Cecchetti marco.cecchetti at collabora.com
Fri Jan 15 05:14:40 PST 2016


 filter/source/svg/presentation_engine.js |  124 +++++++++++--------------------
 1 file changed, 44 insertions(+), 80 deletions(-)

New commits:
commit 4791dec3258bd46747d4b0db07ed2311d6a4cc10
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
    Reviewed-on: https://gerrit.libreoffice.org/21448
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Marco Cecchetti <mrcekets at gmail.com>

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()


More information about the Libreoffice-commits mailing list