filter/source/svg/presentation_engine.js | 738 ++++--------------------------- 1 file changed, 98 insertions(+), 640 deletions(-)
New commits: commit 88042d437df72c9c36a39ca668c2f8f459a0d04a Author: Thorsten Behrens <tbehr...@suse.com> Date: Mon Mar 25 00:47:12 2013 +0100 Replace stdlib priority queue with own version. This is enough for our needs, and avoids the third license in one file. Change-Id: I5312ac9904406f013964a34d9167a32403fcb941 diff --git a/filter/source/svg/presentation_engine.js b/filter/source/svg/presentation_engine.js index 634033b..c77ff1d 100644 --- a/filter/source/svg/presentation_engine.js +++ b/filter/source/svg/presentation_engine.js @@ -679,202 +679,6 @@ function configureDetectionTools() /***** * @licstart * - * The following is the license notice for the part of JavaScript code of this - * page included between the '@stdlibstart' and the '@stdlibend' notes. - */ - -/***** ****************************************************************** - * - * Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 - * Free Software Foundation, Inc. - * - * The code included between the start note '@stdlibstart' and the end - * note '@stdlibend' is a derivative work of the GNU ISO C++ Library. - * This library is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Under Section 7 of GPL version 3, you are granted additional - * permissions described in the GCC Runtime Library Exception, version - * 3.1, as published by the Free Software Foundation. - * - * You should have received a copy of the GNU General Public License and - * a copy of the GCC Runtime Library Exception along with this program; - * see the files COPYING3 and COPYING.RUNTIME respectively. If not, see - * <http://www.gnu.org/licenses/>. - * - *************************************************************************/ - -/***** - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided 'as is' without express or implied warranty. - * - * - * Copyright (c) 1996,1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided 'as is' without express or implied warranty. - * - ************************************************************************/ - -/***** - * @licend - * - * The above is the license notice for the part of JavaScript code of this - * page included between the '@stdlibstart' and the '@stdlibend' notes. - */ - - - -/***** - * @stdlibstart - * - * The following code is a porting, performed on August 2011, of a part of - * the C++ code included into the source file stl_queue.h that is part of - * the GNU ISO C++ Library. - */ - - -function PriorityQueue( aCompareFunc ) -{ - this.aSequence = new Array(); - this.aCompareFunc = aCompareFunc; -} - -PriorityQueue.prototype.clone = function() -{ - var aCopy = new PriorityQueue( this.aCompareFunc ); - var src = this.aSequence; - var dest = []; - var i, l; - for( i = 0, l = src.length; i < l; ++i ) - { - if( i in src ) - { - dest.push( src[i] ); - } - } - aCopy.aSequence = dest; - - return aCopy; -}; - -PriorityQueue.prototype.top = function() -{ - return this.aSequence[0]; -}; - -PriorityQueue.prototype.isEmpty = function() -{ - return ( this.size() === 0 ); -}; - -PriorityQueue.prototype.size = function() -{ - return this.aSequence.length; -}; - -PriorityQueue.prototype.push = function( aValue ) -{ - this.implPushHeap( 0, this.aSequence.length, 0, aValue ); -}; - -PriorityQueue.prototype.clear = function() -{ - return this.aSequence = new Array(); -}; - - -PriorityQueue.prototype.pop = function() -{ - if( this.isEmpty() ) - return; - - var nLast = this.aSequence.length - 1; - var aValue = this.aSequence[ nLast ]; - this.aSequence[ nLast ] = this.aSequence[ 0 ]; - this.implAdjustHeap( 0, 0, nLast, aValue ); - this.aSequence.pop(); -}; - -PriorityQueue.prototype.implAdjustHeap = function( nFirst, nHoleIndex, nLength, aValue ) -{ - var nTopIndex = nHoleIndex; - var nSecondChild = nHoleIndex; - - while( nSecondChild < Math.floor( ( nLength - 1 ) / 2 ) ) - { - nSecondChild = 2 * ( nSecondChild + 1 ); - if( this.aCompareFunc( this.aSequence[ nFirst + nSecondChild ], - this.aSequence[ nFirst + nSecondChild - 1] ) ) - { - --nSecondChild; - } - this.aSequence[ nFirst + nHoleIndex ] = this.aSequence[ nFirst + nSecondChild ]; - nHoleIndex = nSecondChild; - } - - if( ( ( nLength & 1 ) === 0 ) && ( nSecondChild === Math.floor( ( nLength - 2 ) / 2 ) ) ) - { - nSecondChild = 2 * ( nSecondChild + 1 ); - this.aSequence[ nFirst + nHoleIndex ] = this.aSequence[ nFirst + nSecondChild - 1]; - nHoleIndex = nSecondChild - 1; - } - - this.implPushHeap( nFirst, nHoleIndex, nTopIndex, aValue ); -}; - -PriorityQueue.prototype.implPushHeap = function( nFirst, nHoleIndex, nTopIndex, aValue ) -{ - var nParent = Math.floor( ( nHoleIndex - 1 ) / 2 ); - - while( ( nHoleIndex > nTopIndex ) && - this.aCompareFunc( this.aSequence[ nFirst + nParent ], aValue ) ) - { - this.aSequence[ nFirst + nHoleIndex ] = this.aSequence[ nFirst + nParent ]; - nHoleIndex = nParent; - nParent = Math.floor( ( nHoleIndex - 1 ) / 2 ); - } - this.aSequence[ nFirst + nHoleIndex ] = aValue; -}; - - -/***** - * @stdlibend - * - * The above code is a porting, performed on August 2011, of a part of - * the C++ code included into the source file stl_queue.h that is part of - * the GNU ISO C++ Library. - */ - - - - - -/***** - * @licstart - * * The following is the license notice for the part of JavaScript code of * this page included between the '@libreofficestart' and the '@libreofficeend' * notes. @@ -3956,6 +3760,55 @@ function SVGPathMatrixTransform( aPath, aSVGMatrix ) } +/********************************************************************************************** + * simple PriorityQueue + **********************************************************************************************/ + +function PriorityQueue( aCompareFunc ) +{ + this.aSequence = new Array(); + this.aCompareFunc = aCompareFunc; + this.bSorted = true; +} + +PriorityQueue.prototype.top = function() +{ + if( !this.bSorted ) + { + this.aSequence.sort(this.aCompareFunc) + this.bSorted = true; + } + return this.aSequence[this.aSequence.length - 1]; +}; + +PriorityQueue.prototype.isEmpty = function() +{ + return ( this.aSequence.length === 0 ); +}; + +PriorityQueue.prototype.push = function( aValue ) +{ + this.bSorted = false; + this.aSequence.push( aValue ); +}; + +PriorityQueue.prototype.clear = function() +{ + this.bSorted = true; + this.aSequence = new Array(); +}; + +PriorityQueue.prototype.pop = function() +{ + if( !this.bSorted ) + { + this.aSequence.sort(this.aCompareFunc) + this.bSorted = true; + } + + return this.aSequence.pop(); +}; + /********************************************************************************************** * AnimationNode Class Hierarchy @@ -10516,8 +10369,7 @@ EventMultiplexer.prototype.getId = function() EventMultiplexer.prototype.hasRegisteredMouseClickHandlers = function() { - var nSize = this.aMouseClickHandlerSet.size(); - return ( nSize > 0 ); + return !this.aMouseClickHandlerSet.isEmpty(); } EventMultiplexer.prototype.registerMouseClickHandler = function( aHandler, nPriority ) commit 446b8cad0809a8b170d70b5c373212d8c0a50553 Author: Thorsten Behrens <tbehr...@suse.com> Date: Mon Mar 25 00:45:57 2013 +0100 Fix exception in javascript (missing placeholder rect) svg animation export was not working - seems there's not always a rect attribute. Change-Id: I227519e5923652652a806807ac90e5dd9507d649 diff --git a/filter/source/svg/presentation_engine.js b/filter/source/svg/presentation_engine.js index 0d8651f..634033b 100644 --- a/filter/source/svg/presentation_engine.js +++ b/filter/source/svg/presentation_engine.js @@ -1995,11 +1995,11 @@ PlaceholderShape.prototype.init = function() aPlaceholderElement.setAttribute( 'text-anchor', sTextAnchor ); if( sX ) aPlaceholderElement.setAttribute( 'x', sX ); - - this.element = aTextFieldElement; - this.textElement = aPlaceholderElement; } + this.element = aTextFieldElement; + this.textElement = aPlaceholderElement; + // We remove all text lines but the first one used as placeholder. var aTextLineGroupElem = this.textElement.parentNode.parentNode; if( aTextLineGroupElem ) commit 19ad7e8d70e683306c8a2a5cd86cf8fe0a70d5f8 Author: Thorsten Behrens <tbehr...@suse.com> Date: Mon Mar 25 00:40:44 2013 +0100 Editor file header and indent consolidation in preseng.js Change-Id: Ia30d7957b562e62535a8d3a3e328da8324072ca2 diff --git a/filter/source/svg/presentation_engine.js b/filter/source/svg/presentation_engine.js index 72173f7..0d8651f 100644 --- a/filter/source/svg/presentation_engine.js +++ b/filter/source/svg/presentation_engine.js @@ -1,3 +1,4 @@ +/* -*- Mode: JS; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - Presentation Engine - * @@ -8,6 +9,9 @@ * generating the C++ header file must start with a '/' and exactly 5 '*' * not striped examples: '/*****', '/***** *' * striped examples: '/** ***' (not contiguous), '/******' (more than 5) + * + * NOTE: This file combines several works, under different + * licenses. See the @licstart / @licend sections below. */ @@ -890,7 +894,7 @@ PriorityQueue.prototype.implPushHeap = function( nFirst, nHoleIndex, nTopIndex, * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file + * License, Version 2.0 (the 'License'); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . * @@ -2006,7 +2010,7 @@ PlaceholderShape.prototype.init = function() { var aChildSet = getElementChildren( aTextLineGroupElem ); if( aChildSet.length > 1 ) - var i = 1; + var i = 1; for( ; i < aChildSet.length; ++i ) { aTextLineGroupElem.removeChild( aChildSet[i] ); @@ -2156,8 +2160,8 @@ MasterPageView.prototype.createElement = function() aTextFieldContentProviderSet[aSlideNumberClassName] ) { this.aSlideNumberFieldHandler = - new SlideNumberFieldHandler( aPlaceholderShapeSet[aSlideNumberClassName], - aTextFieldContentProviderSet[aSlideNumberClassName] ); + new SlideNumberFieldHandler( aPlaceholderShapeSet[aSlideNumberClassName], + aTextFieldContentProviderSet[aSlideNumberClassName] ); this.aSlideNumberFieldHandler.update( this.aMetaSlide.nSlideNumber ); this.aSlideNumberFieldHandler.appendTo( this.aBackgroundObjectsElement ); } @@ -2168,9 +2172,9 @@ MasterPageView.prototype.createElement = function() if( this.aMetaSlide.nIsDateTimeVisible ) { this.aDateTimeFieldHandler = - this.initTextFieldHandler( aDateTimeClassName, aPlaceholderShapeSet, - aTextFieldContentProviderSet, aDefsElement, - aTextFieldHandlerSet, sMasterSlideId ); + this.initTextFieldHandler( aDateTimeClassName, aPlaceholderShapeSet, + aTextFieldContentProviderSet, aDefsElement, + aTextFieldHandlerSet, sMasterSlideId ); } } else if( sId === aFooterClassName ) @@ -2179,9 +2183,9 @@ MasterPageView.prototype.createElement = function() if( this.aMetaSlide.nIsFooterVisible ) { this.aFooterFieldHandler = - this.initTextFieldHandler( aFooterClassName, aPlaceholderShapeSet, - aTextFieldContentProviderSet, aDefsElement, - aTextFieldHandlerSet, sMasterSlideId ); + this.initTextFieldHandler( aFooterClassName, aPlaceholderShapeSet, + aTextFieldContentProviderSet, aDefsElement, + aTextFieldHandlerSet, sMasterSlideId ); } } else if( sId === aHeaderClassName ) @@ -2190,9 +2194,9 @@ MasterPageView.prototype.createElement = function() if( this.aMetaSlide.nIsHeaderVisible ) { this.aHeaderFieldHandler = - this.initTextFieldHandler( aHeaderClassName, aPlaceholderShapeSet, - aTextFieldContentProviderSet, aDefsElement, - aTextFieldHandlerSet, sMasterSlideId ); + this.initTextFieldHandler( aHeaderClassName, aPlaceholderShapeSet, + aTextFieldContentProviderSet, aDefsElement, + aTextFieldHandlerSet, sMasterSlideId ); } } else @@ -2216,8 +2220,8 @@ MasterPageView.prototype.createElement = function() }; MasterPageView.prototype.initTextFieldHandler = -function( sClassName, aPlaceholderShapeSet, aTextFieldContentProviderSet, - aDefsElement, aTextFieldHandlerSet, sMasterSlideId ) + function( sClassName, aPlaceholderShapeSet, aTextFieldContentProviderSet, + aDefsElement, aTextFieldHandlerSet, sMasterSlideId ) { var aTextFieldHandler = null; if( aPlaceholderShapeSet[sClassName] && @@ -2230,8 +2234,8 @@ function( sClassName, aPlaceholderShapeSet, aTextFieldContentProviderSet, if ( !aTextFieldHandlerSet[ sMasterSlideId ][ sTextFieldContentProviderId ] ) { aTextFieldHandlerSet[ sMasterSlideId ][ sTextFieldContentProviderId ] = - new TextFieldHandler( aPlaceholderShapeSet[sClassName], - aTextFieldContentProviderSet[sClassName] ); + new TextFieldHandler( aPlaceholderShapeSet[sClassName], + aTextFieldContentProviderSet[sClassName] ); aTextFieldHandler = aTextFieldHandlerSet[ sMasterSlideId ][ sTextFieldContentProviderId ]; aTextFieldHandler.update(); aTextFieldHandler.appendTo( aDefsElement ); @@ -2339,7 +2343,7 @@ TextFieldHandler.prototype.setTextContent = function( sText ) if( !this.aTextPlaceholderElement ) { log( 'PlaceholderShape.setTextContent: text element is not valid in placeholder of type ' - + this.className + ' that belongs to master slide ' + this.masterPage.id ); + + this.className + ' that belongs to master slide ' + this.masterPage.id ); return; } this.aTextPlaceholderElement.textContent = sText; @@ -3164,9 +3168,9 @@ function mem_fn( sMethodName ) function bind( aObject, aMethod ) { return function() - { - return aMethod.call( aObject, arguments[0] ); - }; + { + return aMethod.call( aObject, arguments[0] ); + }; } function bind2( aFunction ) @@ -13300,4 +13304,4 @@ ElapsedTime.prototype.getElapsedTimeImpl = function() * */ - +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 6f8cf107a16858b13d05f2f4ba9cf29522f2111f Author: Thorsten Behrens <tbehr...@suse.com> Date: Mon Mar 11 20:21:57 2013 +0100 re-base preseng.js on ALv2 code. Change-Id: I0dde612f0e2e1dbe5e7a28444e19137b76e29036 diff --git a/filter/source/svg/presentation_engine.js b/filter/source/svg/presentation_engine.js index a77e792..72173f7 100644 --- a/filter/source/svg/presentation_engine.js +++ b/filter/source/svg/presentation_engine.js @@ -878,28 +878,21 @@ PriorityQueue.prototype.implPushHeap = function( nFirst, nHoleIndex, nTopIndex, /***** ****************************************************************** * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * This file is part of the LibreOffice project. * - * Copyright 2000, 2010 Oracle and/or its affiliates. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. * - * OpenOffice.org - a multi-platform office productivity suite + * This file incorporates work covered by the following license notice: * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . * ************************************************************************/ @@ -917,8 +910,10 @@ PriorityQueue.prototype.implPushHeap = function( nFirst, nHoleIndex, nTopIndex, * @libreofficestart * * Several parts of the following code are the result of the porting, - * started on August 2011, of the C++ code included in the source files - * placed under the folder '/slideshow/source' and subfolders. + * started on August 2011, of the C++ code included in the source + * files placed under the folder '/slideshow/source' and + * subfolders. This got later rebased onto the AL2-licensed versions + * of those files in early 2013. * @source http://cgit.freedesktop.org/libreoffice/core/tree/slideshow/source * */ commit 0d82b464ba765ee17623ba691e1e740d30cacdc7 Author: Thorsten Behrens <tbehr...@suse.com> Date: Mon Mar 11 20:17:48 2013 +0100 Remove unused code from preseng.js Change-Id: Ia79bae4aab448a9c2e178ff5f7409cb91585e33a diff --git a/filter/source/svg/presentation_engine.js b/filter/source/svg/presentation_engine.js index 36f69c5..a77e792 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; -}; - - /***** commit 3047c9bcb2a33487b4c38119f2841bfa3f70b29f Author: Thorsten Behrens <tbehr...@suse.com> Date: Mon Mar 11 20:14:42 2013 +0100 Stick in obvious canonical radians conversion. Change-Id: I1b79844dd479de201ea30d0b1959303110efee34 diff --git a/filter/source/svg/presentation_engine.js b/filter/source/svg/presentation_engine.js index ddaf867..36f69c5 100644 --- a/filter/source/svg/presentation_engine.js +++ b/filter/source/svg/presentation_engine.js @@ -4101,7 +4101,8 @@ SVGMatrix.prototype.setToIdentity = function() SVGMatrix.prototype.setToRotationAroundPoint = function( nX, nY, nAngle ) { - nAngle = degToRad( nAngle ); + // convert to radians + nAngle = Math.PI * nAngle / 180; var nSin = Math.sin( nAngle ); var nCos = Math.cos( nAngle ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits