/*SIE-SVGtoVML LGPL2.1 & GPL2.0 & Mozilla Public Lisence*/ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (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.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is the Mozilla SVG Cairo Renderer project. * * The Initial Developer of the Original Code is IBM Corporation. * Portions created by the Initial Developer are Copyright (C) 2004 * the Initial Developer. All Rights Reserved. * * Parts of this file contain code derived from the following files(s) * of the Mozilla SVG project (these parts are Copyright (C) by their * respective copyright-holders): * layout/svg/renderer/src/libart/nsSVGLibartBPathBuilder.cpp * * Contributor(s):DHRNAME * * Alternatively, the contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ var obje; var NAIBU = {}; /*@cc_on _d=document;eval('var document=_d')@*/ function svgtovml(){ var ienanoka = document.all && !(navigator.userAgent.indexOf("Opera")>=0); var ary = document.getElementsByTagName("script"); for(var i=0; i < ary.length; i++) { var hoge = ary[i].type; if(ary[i].type == "image/svg+xml") { var ait = ary[i].text; if(ienanoka){ setVMLNameSpace(); var da = {}; da.obj = new Array(i); da.obj[i] = ary[i]; da.num = i + 1; da.content = ait; da.success = true; ca(da); } else{ var s = textToSVG(ait,ary[i].getAttribute("width"),ary[i].getAttribute("height")); document.body.insertBefore(s,ary[i]); } } } if(ienanoka){ var st = setVMLNameSpace(); st.addRule("object","display: none;"); st.addRule("embed","display: none;"); var obj = document.getElementsByTagName("object"); var emd = document.getElementsByTagName("embed"); docme = new Array(obj.length+emd.length); getObject(obj,0); getEmbed(emd,0); success = true; } } function setVMLNameSpace(){ document.namespaces.add("v","urn:schemas-microsoft-com:vml"); document.namespaces.add("o","urn:schemas-microsoft-com:office:office"); document.namespaces.add("t","urn:schemas-microsoft-com:time"); var st = document.createStyleSheet(); st.addRule("v\\:*","behavior: url(#default#VML);"); st.addRule("o\\:*","behavior: url(#default#VML);"); st.addRule("t\\:*","behavior: url(#default#time);"); return st; } window.onload = svgtovml; function SVGtoVML(){ return this; } SVGtoVML.prototype.read = function stvread(obc){ this.rootElement = obc; this.vi = new STViewSpec(this.rootElement); var sh = obc.getElementsByTagName("shape"); this.shape = sh; var slen = 0, rlen = 0, clen = 0, elen = 0, pllen = 0, plen = 0, llen = 0; var s = new Array(slen), r = new Array(rlen), c = new Array(clen), e = new Array(elen), pl = new Array(pllen), p = new Array(plen), li = new Array(llen); try{ for(var i=0,shli=sh.length;i 4){ mf4 = F[F.length-4]; mf3 = F[F.length-3]; mf2 = F[F.length-2]; mf1 = F[F.length-1]; crx = 2*mf2 - mf4 + relx; cry = 2*mf1 - mf3 + rely; } for(var j=1,b=1;j 3){ var f2 = F[2]; F.splice(2,1,f2,"l"); } } D[i] = F; G[i] = F.join(" "); } if(minx != 0 || miny != 0){ G = D._minm(minx,miny); } if(!G[G.length-1].match(/e\s?$/)){G[G.length-1] += "e";} dat = G.join(" "); delete axe,big,small,aaa; } catch(e){} try{ this.tar.setAttribute("path",dat); this.tar.setAttribute("coordsize",w +" "+ h); this.tar.setAttribute("coordorgin","0 0"); this.paint.set(this.tar,w,h,ttm); if(minx != 0 || miny != 0){ this.tar.style.posLeft = minx; this.tar.style.posTop = miny; } } catch(e){} } NAIBU.nst = function (skip,F,crx,cry){ for(var w=1,n = (F.length-1)/skip;w<=n;w++){ var ski = skip + 2, sk = skip + 1; var it = ski * w - sk; var fit = F[it]; F.splice(it,1,crx,cry,fit); cry = 2*F[ski*w] - F[ski*w-2]; crx = 2*F[ski*w-1] - F[ski*w-3]; } return F; } NAIBU.vnst = function (skip,F,nox){ for(var w=1,n = F.length-1;w<=n;w++){ var it = 2 * w - 1; F.splice(it,1,nox,F[it]); } return F; } NAIBU.hnst = function (skip,F,noy){ for(var w=1,n = F.length-1;w<=n;w++){ var it = 2 * w - 1; F.splice(it,1,F[it],noy); } return F; } Array.prototype._minm = function(minx,miny){ var self = this; var g = new Array(self.length); try{ for(var i=0,ili=self.length;i 2){ var n = Math.ceil(parseFloat(fo)*10) / 10; fo = n + ""; } fillElement.setAttribute("opacity",this.fillopacity); } if(this.fill.match(/url\(#(\w+)/)){ gradfill = document.getElementById(RegExp.$1); ftype = gradfill.getAttribute("type"); this.gradient(gradfill,fillElement,ftype); } else{ fillElement.setAttribute("color",this.fill); } } catch(e){ fillElement.setAttribute("on","true"); fillElement.setAttribute("color","black");} } else{ fillElement.setAttribute("on","false"); } if(this.strokeon){ try{ strokeElement.setAttribute("joinstyle",this.strokejoin); if(this.strokedashstyle){ strokeElement.setAttribute("dashstyle",this.strokedashstyle); } strokeElement.setAttribute("miterlimit",this.strokemiterlimit); strokeElement.setAttribute("endcap",this.strokeendcap); var mswwhh = Math.sqrt(w*w + h*h); var msms = mswwhh / Math.SQRT2; var sw = new STLength(this.strokeweight,msms); var swx = sw.value * Math.sqrt(w*w*matrix.a*matrix.a + h*h*matrix.d*matrix.d) / mswwhh; var fo = swx + ""; if((fo.length - fo.lastIndexOf(".")) > 2){ var n = Math.ceil(parseFloat(fo)*10) / 10; fo = n + "px"; } strokeElement.setAttribute("weight",fo); if(this.strokeopacity){ var fo = this.fillopacity; if((fo.length - fo.lastIndexOf(".")) > 2){ var n = Math.ceil(parseFloat(fo)*10) / 10; fo = n + ""; } strokeElement.setAttribute("opacity",fo); } if(this.stroke.match(/url\(#(\w+)/)){ gradstroke = document.getElementById(RegExp.$1); stype = gradstroke.getAttribute("type"); this.gradient(gradstroke,strokeElement,stype); } else{ strokeElement.setAttribute("color",this.stroke); } } catch(e){ strokeElement.setAttribute("on","false"); } } else{ strokeElement.setAttribute("on","false"); } el.appendChild(fillElement); el.appendChild(strokeElement); } NAIBU.PaintColor.prototype.gradient = function pcgradient(gel,ele,type){ var tgc = gel; var pgs; var ang; var rsize; var rf; ele.setAttribute("method","sigma"); try{ if(type == "gradient"){ var x1 = parseFloat(gel.getAttribute("x1").replace(/%/,"")), y1 = parseFloat(gel.getAttribute("y1").replace(/%/,"")); var x2 = parseFloat(gel.getAttribute("x2").replace(/%/,"")), y2= parseFloat(gel.getAttribute("y2").replace(/%/,"")); ang = 270 - Math.atan2(y2-y1,x2-x1)*180/Math.PI; if(ang>=360){ang = ang-360;} ele.setAttribute("angle",ang+""); ele.setAttribute("focus","0%"); } else if(type == "gradientRadial"){ var cx = Math.round(parseFloat(gel.getAttribute("cx"))*100)/100, cy = Math.round(parseFloat(gel.getAttribute("cy"))*100)/100; var rx = Math.round(parseFloat(gel.getAttribute("rx"))*100)/100, ry = Math.round(parseFloat(gel.getAttribute("ry"))*100)/100; rsize = rx+ "," +ry; var x = cx - rx, y = cy - ry; rf = x+ "," +y; ele.setAttribute("focus","100%"); ele.setAttribute("focussize",rsize); ele.setAttribute("focusposition",rf); } } catch(e){if(ele){ele.setAttribute("angle","270");}} try{ ele.setAttribute("type",type); if(gel.getAttribute("xlink:href")){ pgs = document.getElementById(gel.getAttribute("xlink:href").match(/\w+/)); } else{ pgs = tgc; } var tc = pgs.getElementsByTagName("stop"); var ttc = new Array(tc.length), ttco = new Array(tc.length); for(var i=0,tci=tc.length;i 2){ var tgoff = tc[0].getAttribute("offset"); if(!tgoff.match(/%/)){tgoff = Math.round(parseFloat(tgoff)*100);} var cst = ""; ele.setAttribute("color",ttc[0]); ele.setAttribute("color2",ttc[ttc.length-1]); for(var i=0;i= ta){ var s = tb - ta; return s; } var s = 6.28318530718 - (ta-tb); return s; } STArc.prototype.set = function starcset(x1,y1,rx,ry,psai,fA,fS,x4,y4){ var fS = parseFloat(fS), rx = parseFloat(rx), ry = parseFloat(ry), psai = parseFloat(psai), x1 = parseFloat(x1), x4 = parseFloat(x4), y1 = parseFloat(y1), y4 = parseFloat(y4); if(rx == 0 || ry == 0){throw "line";} rx = Math.abs(rx); ry = Math.abs(ry); var ccx = (x1 - x4) / 2, ccy = (y1 - y4) / 2; var cpsi = Math.cos(psai*Math.PI/180), spsi = Math.sin(psai*Math.PI/180); var x1d = cpsi*ccx + spsi*ccy, y1d = -1*spsi*ccx + cpsi*ccy; var x1dd = Math.pow(x1d,2), y1dd = Math.pow(y1d,2); var rxx = Math.pow(rx,2), ryy = Math.pow(ry,2); var lamda = x1dd/rxx + y1dd/ryy; var sds; if(lamda > 1){ rx = Math.sqrt(lamda) * rx; ry = Math.sqrt(lamda) * ry; sds = 0; } else{ var seif = 1; if(fA == fS){ seif = -1; } sds = seif * Math.sqrt((rxx*ryy - rxx*y1dd - ryy*x1dd) / (rxx*y1dd + ryy*x1dd)); } var cxd = sds*rx*y1d / ry, cyd = -1 * sds*ry*x1d / rx; var cx = cpsi*cxd - spsi*cyd + (x1+x4)/2, cy = spsi*cxd + cpsi*cyd + (y1+y4)/2; var s1 = this.CVAngle(1,0,(x1d-cxd)/rx,(y1d-cyd)/ry); var dr = this.CVAngle((x1d-cxd)/rx,(y1d-cyd)/ry,(-x1d-cxd)/rx,(-y1d-cyd)/ry); if(!fS && dr > 0){ dr -= 2*Math.PI; } else if(fS && dr < 0){ dr += 2*Math.PI; } var sse = dr * 2 / Math.PI; var seg = Math.ceil(sse<0 ? -1*sse : sse); seg = seg; var segr = dr / seg; var s2 = s1 + segr; var nea = new Array(); var t = 8/3 * Math.sin(segr/4) * Math.sin(segr/4) / Math.sin(segr/2); for(var i=0,absseg=Math.abs(seg);i|\]>)/g,"-->").replace(//g,"").replace(/<\?.+\?>/g,"").replace(/xmlns="[^"]+"/,"").replace(//g,"").replace(//g,"").replace(/