/*
選択したテキストを行毎に分割します
2011-10-8 お披露目
2011-10-14 縦組みにも対応

*/
#include "doEx.jsx"
#targetengine "eng"
#target 'illustrator'
(function(){
if(app.documents.length < 1){
	alert('御用が無さそうなのでこれにて失礼致します。')
	return false;
}
var TF = doEx('selection').filter('textFrames');
if(!TF.length){
	alert("見るべき物は何もありませんね。");
	return false;
}
//
TF.each(textFrameDevide);
//
function textFrameDevide(T){
	var that = T , dup = T.duplicate() , first = true ,  L = 0;
	doEx(dup.lines).each(function(line){
		var copy = dup.duplicate();
		copy.contents = "";
		if(line.contents){
			line.duplicate(copy);
		}
		if(first == false){
			try{
				line.contents = "a";
				L += line.leading;
			}catch(e){
			}
		}else{
			first = false;
		}
		that.orientation == TextOrientation.VERTICAL ?  copy.translate(L*-1,0)  :  copy.translate(0,L*-1);		
	});
	dup.remove();
	T.remove();
}
})();

