diff options
author | Thorsten Behrens <tbehrens@suse.com> | 2013-03-11 20:17:48 +0100 |
---|---|---|
committer | Thorsten Behrens <tbehrens@suse.com> | 2013-03-25 00:52:11 +0100 |
commit | 0d82b464ba765ee17623ba691e1e740d30cacdc7 (patch) | |
tree | 444dfb29acba34870461a1b6af0aa30a1ba4ea82 | |
parent | 3047c9bcb2a33487b4c38119f2841bfa3f70b29f (diff) |
Remove unused code from preseng.js
Change-Id: Ia79bae4aab448a9c2e178ff5f7409cb91585e33a
-rw-r--r-- | filter/source/svg/presentation_engine.js | 398 |
1 files changed, 2 insertions, 396 deletions
diff --git a/filter/source/svg/presentation_engine.js b/filter/source/svg/presentation_engine.js index 36f69c54a863..a77e7922c64f 100644 --- a/filter/source/svg/presentation_engine.js +++ b/filter/source/svg/presentation_engine.js @@ -516,174 +516,9 @@ function indexSetPageSlide( nIndex ) * @dojostart * * The following code is a derivative work of some part of the dojox.gfx library. - * @source http://svn.dojotoolkit.org/src/dojox/trunk/gfx/arc.js + * @source http://svn.dojotoolkit.org/src/dojox/trunk/_base/sniff.js */ - -function degToRad( degree ) -{ - return (Math.PI * degree / 180); -} - -function radToDeg( radiant ) -{ - return (180 * radiant / Math.PI); -} - - -var PathTools = new Object(); - - -PathTools.unitArcAsBezier = function( alpha ) -{ - // summary: return a start point, 1st and 2nd control points, and an end point of - // a an arc, which is reflected on the x axis - // alpha: Number - // angle in radians, the arc will be 2 * angle size - var cosa = Math.cos(alpha); - var sina = Math.sin(alpha); - var p2 = {x: cosa + (4 / 3) * (1 - cosa), y: sina - (4 / 3) * cosa * (1 - cosa) / sina}; - - return { // Object - s: {x: cosa, y: -sina}, - c1: {x: p2.x, y: -p2.y}, - c2: p2, - e: {x: cosa, y: sina} - }; -}; - -PathTools.arcAsBezier = function( last, rx, ry, xRotg, large, sweep, x, y ) -{ - // summary: calculates an arc as a series of Bezier curves - // given the last point and a standard set of SVG arc parameters, - // it returns an array of arrays of parameters to form a series of - // absolute Bezier curves. - // last: Object - // a point-like object as a start of the arc - // rx: Number - // a horizontal radius for the virtual ellipse - // ry: Number - // a vertical radius for the virtual ellipse - // xRotg: Number - // a rotation of an x axis of the virtual ellipse in degrees - // large: Boolean - // which part of the ellipse will be used (the larger arc if true) - // sweep: Boolean - // direction of the arc (CW if true) - // x: Number - // the x coordinate of the end point of the arc - // y: Number - // the y coordinate of the end point of the arc - - // constants - var twoPI = 2 * Math.PI, pi4 = Math.PI / 4, pi8 = Math.PI / 8, - pi48 = pi4 + pi8, curvePI4 = PathTools.unitArcAsBezier(pi8); - - // calculate parameters - large = Boolean(large); - sweep = Boolean(sweep); - - var xRot = degToRad( xRotg ); - var rx2 = rx * rx, ry2 = ry * ry; - var m = document.documentElement.createSVGMatrix(); - m = m.rotate(-xRotg); - var p = document.documentElement.createSVGPoint(); - p.x = (last.x - x) / 2; p.y = (last.y - y) / 2; - var pa = p.matrixTransform( m ); - - var pax2 = pa.x * pa.x, pay2 = pa.y * pa.y; - var c1 = Math.sqrt((rx2 * ry2 - rx2 * pay2 - ry2 * pax2) / (rx2 * pay2 + ry2 * pax2)); - - if( isNaN(c1) ) { c1 = 0; } - - var ca = { - x: c1 * rx * pa.y / ry, - y: -c1 * ry * pa.x / rx - }; - - if( large == sweep ) - { - ca = {x: -ca.x, y: -ca.y}; - } - - // the center - m = document.documentElement.createSVGMatrix(); - m = m.translate( (last.x + x) / 2, (last.y + y) / 2 ).rotate( xRotg ); - p.x = ca.x; p.y = ca.y; - var c = p.matrixTransform( m ); - - // calculate the elliptic transformation - m = document.documentElement.createSVGMatrix(); - var elliptic_transform = m.translate( c.x, c.y ).rotate( xRotg ).scaleNonUniform( rx, ry ); - - // start, end, and size of our arc - var inversed = elliptic_transform.inverse(); - p.x = last.x; p.y = last.y; - var sp = p.matrixTransform( inversed ); - p.x = x; p.y = y; - var ep = p.matrixTransform( inversed ); - var startAngle = Math.atan2(sp.y, sp.x); - var endAngle = Math.atan2(ep.y, ep.x); - var theta = startAngle - endAngle; // size of our arc in radians - - if( sweep ) { theta = -theta; } - if( theta < 0 ) - { - theta += twoPI; - } - else if( theta > twoPI ) - { - theta -= twoPI; - } - - // draw curve chunks - var alpha = pi8, curve = curvePI4; - var step = sweep ? alpha : -alpha; - var result = []; - - var aPathElement = document.createElementNS( NSS['svg'], 'path' ); - - for(var angle = theta; angle > 0; angle -= pi4) - { - if( angle < pi48 ) - { - alpha = angle / 2; - curve = PathTools.unitArcAsBezier(alpha); - step = sweep ? alpha : -alpha; - angle = 0; // stop the loop - } - var c2, e; - var M = elliptic_transform.rotate( radToDeg( startAngle + step ) ); - - if( sweep ) - { - p.x = curve.c1.x; p.y = curve.c1.y; - c1 = p.matrixTransform( M ); - p.x = curve.c2.x; p.y = curve.c2.y; - c2 = p.matrixTransform( M ); - p.x = curve.e.x; p.y = curve.e.y; - e = p.matrixTransform( M ); - } - else - { - p.x = curve.c2.x; p.y = curve.c2.y; - c1 = p.matrixTransform( M ); - p.x = curve.c1.x; p.y = curve.c1.y; - c2 = p.matrixTransform( M ); - p.x = curve.s.x; p.y = curve.s.y; - e = p.matrixTransform( M ); - } - - // draw the curve - var aCubicBezierSeg = aPathElement.createSVGPathSegCurvetoCubicAbs( e.x, e.y, c1.x, c1.y, c2.x, c2.y ); - result.push( aCubicBezierSeg ); - - startAngle += 2 * step; - } - return result; // Array -}; - - function has( name ) { return has.cache[name]; @@ -829,241 +664,12 @@ function configureDetectionTools() return detect; } - - /***** * @dojoend * * The above code is a derivative work of some part of the dojox.gfx library. - * @source http://svn.dojotoolkit.org/src/dojox/trunk/gfx/arc.js - */ - - - - -/** normalizePath - * - * @param sPath - * A string representing a svg <path> element list of commands. - * @return {String} - * A string representing the same svg <path> passed as input defined by - * using only the following commands: M, L, Q, C. + * @source http://svn.dojotoolkit.org/src/dojox/trunk/_base/sniff.js */ -PathTools.normalizePath = function( sPath ) -{ - var PATHSEG_CLOSEPATH = 1; - var PATHSEG_MOVETO_ABS = 2; - var PATHSEG_MOVETO_REL = 3; - var PATHSEG_LINETO_ABS = 4; - var PATHSEG_LINETO_REL = 5; - var PATHSEG_CURVETO_CUBIC_ABS = 6; - var PATHSEG_CURVETO_CUBIC_REL = 7; - var PATHSEG_CURVETO_QUADRATIC_ABS = 8; - var PATHSEG_CURVETO_QUADRATIC_REL = 9; - var PATHSEG_ARC_ABS = 10; - var PATHSEG_ARC_REL = 11; - var PATHSEG_LINETO_HORIZONTAL_ABS = 12; - var PATHSEG_LINETO_HORIZONTAL_REL = 13; - var PATHSEG_LINETO_VERTICAL_ABS = 14; - var PATHSEG_LINETO_VERTICAL_REL = 15; - var PATHSEG_CURVETO_CUBIC_SMOOTH_ABS = 16; - var PATHSEG_CURVETO_CUBIC_SMOOTH_REL = 17; - var PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS = 18; - var PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL = 19; - - var aPath = document.createElementNS( NSS['svg'], 'path' ); - aPath.setAttribute( 'd', sPath ); - var aPathSegList = aPath.pathSegList; - if( !aPathSegList ) - { - log( 'normalizePath: no path segment list supported, abort.' ); - return ''; - } - var nSize = aPathSegList.numberOfItems; - - var aPreviousPathSeg = null; - var nCurrentX = 0; - var nCurrentY = 0; - var nInitialX = 0; - var nInitialY = 0; - var aPathSeg = null; - var aAbsPathSeg = null; - - var i; - for( i = 0; i < nSize; ++i ) - { - - aPathSeg = aPathSegList.getItem( i ); - switch( aPathSeg.pathSegType ) - { - case PATHSEG_CLOSEPATH: - aAbsPathSeg = aPath.createSVGPathSegLinetoAbs( nInitialX, nInitialY ); - aPathSegList.replaceItem( aAbsPathSeg, i ); - break; - case PATHSEG_MOVETO_ABS: - nInitialX = aPathSeg.x; - nInitialY = aPathSeg.y; - break; - case PATHSEG_MOVETO_REL: - nCurrentX += aPathSeg.x; - nCurrentY += aPathSeg.y; - aAbsPathSeg = aPath.createSVGPathSegMovetoAbs( nCurrentX, nCurrentY ); - aPathSegList.replaceItem( aAbsPathSeg, i ); - nInitialX = nCurrentX; - nInitialY = nCurrentY; - break; - case PATHSEG_LINETO_ABS: - break; - case PATHSEG_LINETO_REL: - nCurrentX += aPathSeg.x; - nCurrentY += aPathSeg.y; - aAbsPathSeg = aPath.createSVGPathSegLinetoAbs( nCurrentX, nCurrentY ); - aPathSegList.replaceItem( aAbsPathSeg, i ); - break; - case PATHSEG_CURVETO_CUBIC_ABS: - break; - case PATHSEG_CURVETO_CUBIC_REL: - var nX1 = nCurrentX + aPathSeg.x1; - var nY1 = nCurrentY + aPathSeg.y1; - var nX2 = nCurrentX + aPathSeg.x2; - var nY2 = nCurrentY + aPathSeg.y2; - var nX = nCurrentX + aPathSeg.x; - var nY = nCurrentY + aPathSeg.y; - aAbsPathSeg = aPath.createSVGPathSegCurvetoCubicAbs( nX, nY, nX1, nY1, nX2, nY2 ); - aPathSegList.replaceItem( aAbsPathSeg, i ); - break; - case PATHSEG_CURVETO_QUADRATIC_ABS: - break; - case PATHSEG_CURVETO_QUADRATIC_REL: - nX1 = nCurrentX + aPathSeg.x1; - nY1 = nCurrentY + aPathSeg.y1; - nX = nCurrentX + aPathSeg.x; - nY = nCurrentY + aPathSeg.y; - aAbsPathSeg = aPath.createSVGPathSegCurvetoQuadraticAbs( nX, nY, nX1, nY1 ); - aPathSegList.replaceItem( aAbsPathSeg, i ); - break; - case PATHSEG_ARC_REL: - aPathSeg.x += nCurrentX; - aPathSeg.y += nCurrentY; - case PATHSEG_ARC_ABS: - var aCubicBezierSegList - = PathTools.arcAsBezier( { x: nCurrentX, y: nCurrentY }, - aPathSeg.r1, aPathSeg.r2, - aPathSeg.angle, - aPathSeg.largeArcFlag, - aPathSeg.sweepFlag, - aPathSeg.x, aPathSeg.y ); - var nLength = aCubicBezierSegList.length; - if( nLength > 0 ) - { - var k; - for( k = 0; k < nLength; ++k ) - { - aPathSegList.insertItemBefore( aCubicBezierSegList[k], i ); - i += 1; - } - aPathSegList.removeItem( i ); - i -= 1; - nSize += ( nLength - 1 ); - } - break; - case PATHSEG_LINETO_HORIZONTAL_REL: - aPathSeg.x += nCurrentX; - // fall through intended - case PATHSEG_LINETO_HORIZONTAL_ABS: - aAbsPathSeg = aPath.createSVGPathSegLinetoAbs( aPathSeg.x, nCurrentY ); - aPathSegList.replaceItem( aAbsPathSeg, i ); - break; - case PATHSEG_LINETO_VERTICAL_REL: - aPathSeg.y += nCurrentY; - // fall through intended - case PATHSEG_LINETO_VERTICAL_ABS: - aAbsPathSeg = aPath.createSVGPathSegLinetoAbs( nCurrentX, aPathSeg.y ); - aPathSegList.replaceItem( aAbsPathSeg, i ); - break; - case PATHSEG_CURVETO_CUBIC_SMOOTH_REL: - aPathSeg.x += nCurrentX; - aPathSeg.y += nCurrentY; - aPathSeg.x2 += nCurrentX; - aPathSeg.y2 += nCurrentY; - // fall through intended - case PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: - if( aPreviousPathSeg.pathSegType == PATHSEG_CURVETO_CUBIC_ABS ) - { - nX1 = 2*nCurrentX - aPreviousPathSeg.x2; - nY1 = 2*nCurrentY - aPreviousPathSeg.y2; - } - else - { - nX1 = nCurrentX; - nY1 = nCurrentY; - } - aAbsPathSeg = aPath.createSVGPathSegCurvetoCubicAbs( aPathSeg.x, aPathSeg.y, - nX1, nY1, - aPathSeg.x2, aPathSeg.y2 ); - aPathSegList.replaceItem( aAbsPathSeg, i ); - break; - case PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: - aPathSeg.x += nCurrentX; - aPathSeg.y += nCurrentY; - // fall through intended - case PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: - if( aPreviousPathSeg.pathSegType == PATHSEG_CURVETO_QUADRATIC_ABS ) - { - nX1 = 2*nCurrentX - aPreviousPathSeg.x1; - nY1 = 2*nCurrentY - aPreviousPathSeg.y1; - } - else - { - nX1 = nCurrentX; - nY1 = nCurrentY; - } - aAbsPathSeg = aPath.createSVGPathSegCurvetoQuadraticAbs( aPathSeg.x, aPathSeg.y, nX1, nY1 ); - aPathSegList.replaceItem( aAbsPathSeg, i ); - break; - default: - log( 'normalizePath: unknown path segment, index: ' + String(i) ); - } - aPreviousPathSeg = aPathSegList.getItem( i ); - nCurrentX = aPreviousPathSeg.x; - nCurrentY = aPreviousPathSeg.y; - } - return aPath.getAttribute( 'd' ); -}; - - -/** createPathFromEllipse - * - * @param nCX - * The ellipse center x coordinate. - * @param nCY - * The ellipse center y coordinate. - * @param nXRay - * The ellipse x-ray. - * @param nYRay - * The ellipse y-ray. - * @return {String} - * A string representing a list of path commands that approximate - * the ellipse. - */ -PathTools.createPathFromEllipse = function( nCX, nCY, nXRay, nYRay ) -{ - var V1X = nCX, V1Y = nCY - nYRay; - var V2X = nCX + nXRay, V2Y = nCY; - var V3X = nCX, V3Y = nCY + nYRay; - var V4X = nCX - nXRay, V4Y = nCY; - - var sPathData = 'M ' + V1X + ' ' + V1Y + - ' A ' + nXRay + ' ' + nYRay + ' 0 0 1 ' + V2X + ' ' + V2Y + - ' A ' + nXRay + ' ' + nYRay + ' 0 0 1 ' + V3X + ' ' + V3Y + - ' A ' + nXRay + ' ' + nYRay + ' 0 0 1 ' + V4X + ' ' + V4Y + - ' A ' + nXRay + ' ' + nYRay + ' 0 0 1 ' + V1X + ' ' + V1Y; - - sPathData = PathTools.normalizePath( sPathData ); - return sPathData; -}; - - /***** |