svnno****@sourc*****
svnno****@sourc*****
2009年 12月 12日 (土) 21:53:22 JST
Revision: 1458 http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1458 Author: dhrname Date: 2009-12-12 21:53:22 +0900 (Sat, 12 Dec 2009) Log Message: ----------- 0.55統合 Modified Paths: -------------- trunk/sie.js Property Changed: ---------------- trunk/sie.js Modified: trunk/sie.js =================================================================== --- trunk/sie.js 2009-12-11 12:26:23 UTC (rev 1457) +++ trunk/sie.js 2009-12-12 12:53:22 UTC (rev 1458) @@ -100,6 +100,9 @@ } //他のページに移動する際に起動 function unsvgtovml() { + if (NAIBU.Clip.length > 0) { + clearInterval(NAIBU.stop); + } NAIBU = stlog = STLog = SIE = null; } @@ -243,7 +246,7 @@ //chset childNodesで要素を作成していく SVGtoVML.prototype.chset = function _s_chset( /*element*/ ele, /*Matrix*/ matrix, /*float*/w, /*float*/h){ var nods = ele.childNodes, s = null; - var name = "group|shape|defs|STOP|fill|stroke|DIV|SPAN|A|image|rect|USE|FONTFACEURI", gname = "DIV|group"; //要素名に合致させる文字列 + var name = "group|shape|defs|STOP|fill|stroke|DIV|SPAN|A|image|rect|USE|FONTFACEURI|set", gname = "DIV|group"; //要素名に合致させる文字列 var cmatrix = matrix; //子要素に継がせるCTM var te = nods[0]; if (te !== void 0) { @@ -289,6 +292,8 @@ cmatrix = s.transformable; } else if (te.nodeName === "image") { s = new STImage(te, matrix, w, h); + } else if (te.nodeName === "set") { + s = new STSetElement(te, matrix, w, h); } if (s) { this.children[this.children.length] = s; @@ -329,9 +334,24 @@ } catch(e) {stlog.add(e,185);this.next();} } else { //全要素の読み込みが終われば _ie_svgfont(); + if (NAIBU.Clip.length > 0) { + NAIBU.stop = setInterval( (function(){ + var ntc = NAIBU.Time.currentFrame++; + var nc = NAIBU.Clip; + for (var i=0,ncli=nc.length;i<ncli;++i) { + nc[i]._frame(ntc); + } + if (ntc > 7000) { + clearInterval(NAIBU.stop); + } + }), + 41 + ); + } } } catch(e) {stlog.add(e,293);this.onumber++;this.next();} }; +NAIBU.svgNameSpace = "http://www.w3.org/2000/svg"; //embed要素をobject要素に変える(Firefoxのみ) Objectembeds.prototype.ffnext = function(){ try{ @@ -345,6 +365,28 @@ tep.removeChild(tei); teli--; } + for (var i=0;i<this.obj.length;++i) { + var doc = (this.obj[i].getSVGDocument === void 0) ? this.obj[i].contentDocument : this.obj[i].getSVGDocument(); + var sets = doc.getElementsByTagNameNS(NAIBU.svgNameSpace, "set"), s; + for (var j=0;j<sets.length;++j) { + s = new _noie_STSetElement(sets[j]); + s.set(); + } + } + if (NAIBU.Clip.length > 0) { + NAIBU.stop = setInterval( (function(){ + var ntc = NAIBU.Time.currentFrame++; + var nc = NAIBU.Clip; + for (var i=0,ncli=nc.length;i<ncli;++i) { + nc[i]._frame(ntc); + } + if (ntc > 7000) { + clearInterval(NAIBU.stop); + } + }), + 41 + ); + } } catch(e) {stlog.add(e,294);} }; @@ -1947,7 +1989,6 @@ } } catch (e) {stlog.add(e,1847);} }; -NAIBU.svgNameSpace = "http://www.w3.org/2000/svg"; function _ie_font(data) { if (data.success) { //responsXMLはDTD処理を行う可能性があるため、ここでは使わない @@ -1983,13 +2024,23 @@ var advanceX = [], glyphData = []; for (var i=0,gli=glyphs.length;i<gli;++i) { var glyph = glyphs[i], unicode = glyph.getAttribute("unicode") || "なし"; //unicode属性に指定がない場合、処理させないようにする - //indexは該当する文字が何番目にあるかの数字 - var index = data.indexOf(unicode); - while (index > -1) { - advanceX[index] = parseFloat(glyph.getAttribute(horizOrVert) || advX); //字幅を収納 - glyphData[index] = glyph.getAttribute("d"); - index = data.indexOf(unicode, index+1); + var orientation = glyph.getAttribute("orientation"), isVert = true, isOrientationAttribute = true; + if (orientation) { + if (orientation === "h") { + isVert = false; + } + } else { + isOrientationAttribute = false; } + if ( (isTategaki && isVert) || !(isTategaki || isVert) || !isOrientationAttribute){ + //indexは該当する文字が何番目にあるかの数字 + var index = data.indexOf(unicode); + while (index > -1) { + advanceX[index] = parseFloat(glyph.getAttribute(horizOrVert) || advX); //字幅を収納 + glyphData[index] = glyph.getAttribute("d"); + index = data.indexOf(unicode, index+1); + } + } } for (var i=0,adv=0;i<data.length;++i) { if (advanceX[i] !== void 0) { //配列に含まれていれば @@ -2010,15 +2061,16 @@ adv += advanceX[i]; } } - advanceX = glyphData = null; + adv = advanceX = glyphData = null; } else { NAIBU._ie_createFont(node, font); } node = node.nextSibling; } ti.style.visibility = "hidden"; + data = isTategaki = horizOrVert = em = advX = dx = dy = fontSize = fe = null; }; -//IE以外、Firefox用 +//IE以外 function _noie_svgfont() { var obj = document.getElementsByTagName("object"); for (var i=0;i<obj.length;++i) { @@ -2031,8 +2083,9 @@ } NAIBU._fontSearchURI(s); } - NAIBU._fontSearchURI(document); } + NAIBU._fontSearchURI(document); + }; //font-face-uri要素に書かれたuriを手がかりに、Ajaxを使ってファイルを読み込む NAIBU._fontSearchURI = function(doc){ @@ -2083,14 +2136,24 @@ if (data !== void 0) { //dataがある場合 var advanceX = [], glyphData = []; for (var i=0,gli=glyphs.length;i<gli;++i) { - var glyph = glyphs[i], unicode = glyph.getAttributeNS(null, "unicode") || "なし"; //unicode属性に指定がない場合、処理させないようにする - //indexは該当する文字が何番目にあるかの数字 - var index = data.indexOf(unicode); - while (index > -1) { - advanceX[index] = parseFloat(glyph.getAttributeNS(null, horizOrVert) || advX); //字幅を収納 - glyphData[index] = glyph.getAttributeNS(null, "d"); - index = data.indexOf(unicode, index+1); + var glyph = glyphs[i], unicode = glyph.getAttributeNS(null, "unicode") || "なし"; //unicode属性に指定がない場合、処理させないようにする + var orientation = glyph.getAttributeNS(null, "orientation"), isVert = true, isOrientationAttribute = true; + if (orientation) { + if (orientation === "h") { + isVert = false; + } + } else { + isOrientationAttribute = false; } + if ( (isTategaki && isVert) || !(isTategaki || isVert) || !isOrientationAttribute){ + //indexは該当する文字が何番目にあるかの数字 + var index = data.indexOf(unicode); + while (index > -1) { + advanceX[index] = parseFloat(glyph.getAttributeNS(null, horizOrVert) || advX); //字幅を収納 + glyphData[index] = glyph.getAttributeNS(null, "d"); + index = data.indexOf(unicode, index+1); + } + } } for (var i=0,adv=0;i<data.length;++i) { if (advanceX[i] !== void 0) { //配列に含まれていれば @@ -2116,7 +2179,7 @@ matrix = null; } } - advanceX = glyphData = null; + adv = advanceX = glyphData = null; } else { NAIBU._noie_createFont(node, font); } @@ -2124,6 +2187,7 @@ } ti.style.opacity = "0"; } + data = isTategaki = horizOrVert = em = advX = dx = dy = fontSize = null; }; NAIBU.pathData = function(/*string*/ data, /*Element*/ p, /*boolean*/ t, /*float*/ w, h, /*Matrix*/ matrix) { //CTMでフォントを移動させておく @@ -2136,9 +2200,280 @@ p.setAttributeNS(null, "transform", "matrix(" +matrix.a+ "," +matrix.b+ "," +matrix.c+ "," +matrix.d+ "," +matrix.e+ "," +matrix.f+ ")"); p.setAttributeNS(null, "d", data); } - matrix = data = null; + matrix = data = t = null; }; +NAIBU.Time = { + currentFrame : 0 +}; +NAIBU.Clip = []; +function STSetElement(/*Element*/ ele, /*Matrix*/ matrix, /*float*/w, h) { + if (ele) { + var parent = ele.parentNode, s = {}; + if (parent.nodeName === "shape") { + switch (parent.getAttribute("tag")) { + case "path": + s = new STPath(parent, matrix); + break; + case "rect": + s = new STRectElement(parent, matrix, w, h); + break; + case "circle": + s = new STCircle(parent, matrix, w, h); + break; + case "ellipse": + s = new STEllipse(parent, matrix, w, h); + break; + case "polyline": + s = new STPolyline(parent, matrix); + break; + case "polygon": + s = new STPolygon(parent, matrix); + break; + case "line": + s = new STLine(parent, matrix, w, h); + break; + } + } else if (parent.nodeName === "DIV") { + s = new STText(parent, matrix, w, h); + } else if (parent.nodeName === "A") { + s = new STAElement(parent, matrix); + } else if (parent.nodeName === "image") { + s = new STImage(parent, matrix, w, h); + } + this.trnasformable = s.transformable; + this.target = s; + this.tar = ele; + this.paint = s.paint; + this.currentFrame = 0; + this.attributeName = ele.getAttribute("attributeName").replace(/(fill|stroke)\-/, "&1"); + this.begin = ele.getAttribute("begin") || "0ms"; + this.end = ele.getAttribute("end"); + this.dur = ele.getAttribute("dur"); + this.fill = ele.getAttribute("fill"); + this.w = w; + this.h = h; + this._begin = this._end = this.simpleDuration = null; + NAIBU.Clip[NAIBU.Clip.length] = this; + } + return this; +}; +STSetElement.prototype.set = function (w,h){ + this.to = this.tar.getAttribute("to"); + var offset, beginOffset = 0; + try { + var n = parseFloat(this.begin.match(/[\-\d\.]+(h|min|s|ms)/)); + offset = (!isNaN(n)) ? n * this._unit[RegExp.$1] : 0; + if ( /(mouse|activ|click)/.test(this.begin) ) { //イベントがある場合 + var tar; + if ( /\.\D/.test(this.begin) ) { + tar = this.tar.ownerDocument.getElementById( this.begin.substring(0, this.begin.indexOf(".")) ); + } else { + tar = this.target.tar; + } + (function(te, offse, ta) { + ta.attachEvent( "on" + te.begin.match(/(mouse|activ|clic)[a-z]+/)[0], + function(){te.beginElementAt(offse);}, false ); + })(this, offset, tar); + } else { + this.beginElementAt(offset); + beginOffset = offset; + } + if (this.dur) { + var n = parseFloat(this.dur.match(/[\-\d\.]+(h|min|s|ms)/)); + this.simpleDuration = (!isNaN(n)) ? n * this._unit[RegExp.$1] : 0; + } + if (this.end) { + var n = parseFloat(this.end.match(/[\-\d\.]+(h|min|s|ms)/)); + offset = (!isNaN(n)) ? n * this._unit[RegExp.$1] : 0; + if ( /(mouse|activ|click)/.test(this.end) ) { //イベントがある場合 + var tar; + if ( /\.\D/.test(this.end) ) { + tar = this.tar.ownerDocument.getElementById( this.end.substring(0,this.end.indexOf(".")) ); + } else { + tar = this.target.tar; + } + (function(te, offse, ta) { + ta.attachEvent( "on" + te.end.match(/(mouse|activ|clic)[a-z]+/)[0], + function(){te.endElementAt(offse);}, false ); + })(this, offset, tar); + } else { + this.endElementAt(offset); + } + } + } catch(e) {stlog.add(e, 2239);} +}; +STSetElement.prototype._unit = { + "h" : 2880000, + "min" : 48000, + "s" : 800, + "ms" : 0.8 +}; +//sは現在のフレーム数であることに気をつけること +STSetElement.prototype._frame = function (/*int*/ s){ + if (this._begin) { + if (this._begin <= s) { + if (this.currentFrame === 0) { + this.beginElement(); + } + this.currentFrame++; + } + if (this._end) { + if (this._end <= s && this.currentFrame !== 0) { + this.endElement(); + this.currentFrame = 0; + this._begin = null; + } + } + } +}; +STSetElement.prototype.beginElement = function (){ + var target = this.target; + var base = target[this.attributeName]; + try { + //fill要素とstroke要素はあらかじめ消しておく + if ( !(target instanceof STGroupElement) ) { + var tgebtfill = target.tar.getElementsByTagName("fill"), tgebtstroke = target.tar.getElementsByTagName("stroke"); + if (tgebtfill.length > 0) { + target.tar.removeChild(tgebtfill[0]); + } + if (tgebtstroke.length > 0) { + target.tar.removeChild(tgebtstroke[0]); + } + } + if (base !== void 0) { + if (typeof base === "string") { + target[this.attributeName] = this.to; + } else if (base instanceof STLength) { + var s = base.value; + base.newValueSpecifiedUnits(base.unitType, parseFloat(this.to)); + base = s; + } + } else if (target.paint.defaults[this.attributeName] !== void 0) { + base = target.paint[this.attributeName]; + target.paint[this.attributeName] = this.to; + } else { + base = ""; + target.tar.style[this.attributeName] = this.to; + } + target.set(this.w, this.h); + target.transformable = this.trnasformable; + target.paint = this.paint; + this.base = base; + if (this.simpleDuration) { + if (this._end) { + var offset = (this.simpleDuration > this._end - this._begin) ? this._end - this._begin : this.simpleDuration; + this.endElementAt(offset); + } else { + this.endElementAt(this.simpleDuration); + } + } + } catch(e) { + stlog.add(e, 23400); + } + return; +}; +STSetElement.prototype.endElement = function (){ + if (this.fill) { + if (this.fill === "freeze") { + return; + } + } + this.to = this.base; + this.beginElement(); + return; +}; +STSetElement.prototype.beginElementAt = function (offset){ + this._begin = Math.ceil(offset * 0.8 / 24 + NAIBU.Time.currentFrame); //フレーム数に変換(軽量化のために、1s = 800msで計算) +}; +STSetElement.prototype.endElementAt = function (offset){ + this._end = Math.ceil(offset * 0.8 / 24 + NAIBU.Time.currentFrame); +}; + +function _noie_STSetElement(/*Element*/ ele) { + if (ele) { + this.target = ele.parentNode; + this.tar = ele; + this.currentFrame = 0; + this.attributeName = ele.getAttributeNS(null, "attributeName"); + this.begin = ele.getAttributeNS(null, "begin") || "0ms"; + this.end = ele.getAttributeNS(null, "end"); + this.dur = ele.getAttributeNS(null, "dur"); + this.fill = ele.getAttributeNS(null, "fill"); + this._begin = this._end = this.simpleDuration = null; + NAIBU.Clip[NAIBU.Clip.length] = this; + } + return this; +}; +//プロトタイプチェーンで省略化を行う +_noie_STSetElement.prototype = new STSetElement(); +_noie_STSetElement.prototype.set = function (){ + this.to = this.tar.getAttributeNS(null, "to"); + var offset, beginOffset = 0; + try { + var n = parseFloat(this.begin.match(/[\-\d\.]+(h|min|s|ms)/)); + offset = (!isNaN(n)) ? n * this._unit[RegExp.$1] : 0; + if ( /(mouse|activ|click)/.test(this.begin) ) { //イベントがある場合 + var tar; + if ( /\.\D/.test(this.begin) ) { + tar = this.tar.ownerDocument.getElementById( this.begin.substring(0, this.begin.indexOf(".")) ); + } else { + tar = this.target.tar; + } + //クロージャを参照 + (function(te, offse, ta) { + ta.addEventListener( te.begin.match(/(mouse|activ|clic)[a-z]+/)[0], + function(){te.beginElementAt(offse);}, false ); + })(this, offset, tar); + } else { + this.beginElementAt(offset); + beginOffset = offset; + } + if (this.dur) { + var n = parseFloat(this.dur.match(/[\-\d\.]+(h|min|s|ms)/)); + this.simpleDuration = (!isNaN(n)) ? n * this._unit[RegExp.$1] : 0; + } + if (this.end) { + var n = parseFloat(this.end.match(/[\-\d\.]+(h|min|s|ms)/)); + offset = (!isNaN(n)) ? n * this._unit[RegExp.$1] : 0; + if ( /(mouse|activ|click)/.test(this.end) ) { //イベントがある場合 + var tar; + if ( /\.\D/.test(this.end) ) { + tar = this.tar.ownerDocument.getElementById( this.end.substring(0, this.end.indexOf(".")) ); + } else { + tar = this.target.tar; + } + //クロージャを参照 + (function(te, offse, ta) { + ta.addEventListener( te.end.match(/(mouse|activ|clic)[a-z]+/)[0], + function(){te.endElementAt(offse);}, false ); + })(this, offset, tar); + } else { + this.endElementAt(offset); + } + } + } catch(e) {stlog.add(e, 2239);} +}; +_noie_STSetElement.prototype.beginElement = function (){ + try { + var target = this.target, base = target.getAttributeNS(null, this.attributeName) || target.style.getPropertyValue(this.attributeName); + target.setAttributeNS(null, this.attributeName, this.to); + target.style.setProperty(this.attributeName, this.to, ""); //第三引数に関しては、W3CやMDCを参照 + this.base = base; + if (this.simpleDuration) { + if (this._end) { + var offset = (this.simpleDuration > this._end - this._begin) ? this._end - this._begin : this.simpleDuration; + this.endElementAt(offset); + } else { + this.endElementAt(this.simpleDuration); + } + } + } catch(e) { + stlog.add(e, 24370); + } + return; +}; + function utf16( /*string*/ s) { return unescape(s); } @@ -2243,7 +2578,8 @@ .replace(/<defs(?=\s|>)/g, "<dn:defs") .replace(/\/defs>/g, "/dn:defs>") .replace(/<font-face-?/g, "<fontface") - .replace(/<\/font-face-?/g, "</fontface"); + .replace(/<\/font-face-?/g, "</fontface") + .replace(/<set\s/g, "<dn:set "); var ob = document.createElement("v:group"); var obst = ob.style; ob.innerHTML = dc; Property changes on: trunk/sie.js ___________________________________________________________________ Modified: svn:mergeinfo - /branches/04x/040/sie.js:812-829 /branches/04x/041/sie.js:891-923 /branches/04x/042/sie.js:927-967 /branches/04x/043/sie.js:969-1013 /branches/04x/044/sie.js:1015-1067 /branches/04x/045/sie.js:1069-1078 /branches/04x/046/sie.js:1080-1129 /branches/04x/047/sie.js:1131-1164 /branches/04x/048/sie.js:1166-1180 /branches/04x/sie.js:830-1181 /branches/05x/050/sie.js:1183-1201 /branches/05x/051/sie.js:1207-1323 /branches/05x/052/sie.js:1325-1352 /branches/05x/053/sie.js:1354-1400 /branches/05x/054/sie.js:1403-1422 /branches/05x/sie.js:1183-1425 + /branches/04x/040/sie.js:812-829 /branches/04x/041/sie.js:891-923 /branches/04x/042/sie.js:927-967 /branches/04x/043/sie.js:969-1013 /branches/04x/044/sie.js:1015-1067 /branches/04x/045/sie.js:1069-1078 /branches/04x/046/sie.js:1080-1129 /branches/04x/047/sie.js:1131-1164 /branches/04x/048/sie.js:1166-1180 /branches/04x/sie.js:830-1181 /branches/05x/050/sie.js:1183-1201 /branches/05x/051/sie.js:1207-1323 /branches/05x/052/sie.js:1325-1352 /branches/05x/053/sie.js:1354-1400 /branches/05x/054/sie.js:1403-1422 /branches/05x/055/sie.js:1424-1454 /branches/05x/sie.js:1183-1457