diff options
author | Marco Cecchetti <marco.cecchetti@collabora.com> | 2016-01-13 17:27:56 +0100 |
---|---|---|
committer | Marco Cecchetti <mrcekets@gmail.com> | 2016-01-15 13:14:12 +0000 |
commit | 4791dec3258bd46747d4b0db07ed2311d6a4cc10 (patch) | |
tree | 64958168426309398ed76ece4b0dd1f4b0b08aaf /filter/source/svg/presentation_engine.js | |
parent | 0e4a65df5214f8c471b387a3c2e3076b171ca631 (diff) |
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@libreoffice.org>
Reviewed-by: Marco Cecchetti <mrcekets@gmail.com>
Diffstat (limited to 'filter/source/svg/presentation_engine.js')
-rw-r--r-- | filter/source/svg/presentation_engine.js | 124 |
1 files changed, 44 insertions, 80 deletions
diff --git a/filter/source/svg/presentation_engine.js b/filter/source/svg/presentation_engine.js index 46946a01b38c..09bf1960b95a 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() |