You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ha...@apache.org on 2017/03/16 13:37:21 UTC

[01/42] flex-asjs git commit: And here’s TLF…

Repository: flex-asjs
Updated Branches:
  refs/heads/tlf a77bfe4f2 -> fd08d137f


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/NavigationUtil.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/NavigationUtil.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/NavigationUtil.as
new file mode 100644
index 0000000..99ca853
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/NavigationUtil.as
@@ -0,0 +1,1232 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.utils
+{
+	import org.apache.flex.textLayout.elements.IFlowLeafElement;
+	import org.apache.flex.geom.Point;
+	import org.apache.flex.geom.Rectangle;
+	import org.apache.flex.text.engine.ITextLine;
+	import org.apache.flex.text.engine.TextRotation;
+	import org.apache.flex.textLayout.compose.IFlowComposer;
+	import org.apache.flex.textLayout.compose.ITextFlowLine;
+	import org.apache.flex.textLayout.compose.TextFlowTableBlock;
+	import org.apache.flex.textLayout.container.IContainerController;
+	import org.apache.flex.textLayout.container.ScrollPolicy;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.ParagraphElement;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.textLayout.elements.TextRange;
+	import org.apache.flex.textLayout.formats.BlockProgression;
+	import org.apache.flex.textLayout.formats.Direction;
+	import org.apache.flex.utils.PointUtils;
+
+	
+
+	
+
+	/** 
+	 * Utilities for manipulating a TextRange 
+	 * The methods of this class are static and must be called using
+	 * the syntax <code>NavigationUtil.method(<em>parameter</em>)</code>.
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	public final class NavigationUtil 
+	{
+		private static function validateTextRange(range:TextRange):Boolean
+		{ return range.textFlow != null && range.anchorPosition != -1 && range.activePosition != -1; }
+		
+		private static function doIncrement(flowRoot:ITextFlow, pos:int, incrementer:Function):int
+		{
+			var para:IParagraphElement = flowRoot.findAbsoluteParagraph(pos);
+			return incrementer(flowRoot, para, pos, para.getAbsoluteStart());			
+		}
+		
+		private static function previousAtomHelper(flowRoot:ITextFlow, para:ParagraphElement, pos:int, paraStart:int):int
+		{
+			if (pos - paraStart == 0)
+				return (pos > 0) ? pos - 1 : 0;
+			
+			// mjzhang : for fix bug 2835316, will force to compose to paragraph end to avoid invalid textLine
+			var paraEnd:Number = para.getAbsoluteStart() + para.textLength;
+			para.getTextFlow().flowComposer.composeToPosition(paraEnd);
+			
+			return para.findPreviousAtomBoundary(pos - paraStart) + paraStart;
+		}
+		
+		/** 
+		 * Returns the absolute position of the previous atom. 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public static function previousAtomPosition(flowRoot:ITextFlow, absolutePos:int):int
+		{
+			return doIncrement(flowRoot,absolutePos,previousAtomHelper);
+		}
+	
+		private static function nextAtomHelper(flowRoot:ITextFlow, para:ParagraphElement, pos:int, paraStart:int):int
+		{
+			if (pos - paraStart == para.textLength - 1)
+				return Math.min(flowRoot.textLength, pos + 1);
+			
+			// mjzhang : for fix bug 2835316, will force to compose to paragraph end to avoid invalid textLine
+			var paraEnd:Number = para.getAbsoluteStart() + para.textLength;
+			para.getTextFlow().flowComposer.composeToPosition(paraEnd);
+			
+			return para.findNextAtomBoundary(pos - paraStart) + paraStart;
+		}
+		
+		/** 
+		 * Returns the absolute position of the next atom.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public static function nextAtomPosition(flowRoot:ITextFlow, absolutePos:int):int
+		{
+			return doIncrement(flowRoot,absolutePos,nextAtomHelper);
+		}
+	
+		/** 
+		 * Returns absolute position of the beginning of the previous word.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public static function previousWordPosition(flowRoot:ITextFlow, absolutePos:int):int
+		{
+			if (isOverset(flowRoot, absolutePos))
+				return endOfLastController(flowRoot);
+			
+			var para:IParagraphElement = flowRoot.findAbsoluteParagraph(absolutePos);
+			var paraStart:int = para.getAbsoluteStart();
+			
+			// mjzhang : for fix bug 2835316, will force to compose to paragraph end to avoid invalid textLine
+			var paraEnd:Number = para.getAbsoluteStart() + para.textLength;
+			para.getTextFlow().flowComposer.composeToPosition(paraEnd);
+			
+			var prevWordPos:int = absolutePos - paraStart;
+			var nextWordPos:int = 0;
+			if (absolutePos - paraStart == 0)
+				return (absolutePos > 0) ? absolutePos - 1 : 0;
+			do
+			{
+				nextWordPos = para.findPreviousWordBoundary(prevWordPos);
+				if (prevWordPos == nextWordPos) prevWordPos = para.findPreviousWordBoundary(prevWordPos - 1);
+				else prevWordPos = nextWordPos;
+			} while (prevWordPos > 0 && CharacterUtil.isWhitespace(para.getCharCodeAtPosition(prevWordPos)));
+			return prevWordPos + paraStart;
+		}
+	
+		/** 
+		 * Returns the absolute position of the beginning of the next word.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public static function nextWordPosition(flowRoot:ITextFlow, absolutePos:int):int
+		{
+			var para:IParagraphElement = flowRoot.findAbsoluteParagraph(absolutePos);
+			var paraStart:int = para.getAbsoluteStart();
+			
+			// mjzhang : for fix bug 2835316, will force to compose to paragraph end to avoid invalid textLine
+			var paraEnd:Number = para.getAbsoluteStart() + para.textLength;
+			para.getTextFlow().flowComposer.composeToPosition(paraEnd);
+			
+			var nextWordPos:int = absolutePos - paraStart;
+			
+			if (absolutePos - paraStart == para.textLength - 1)
+				return Math.min(flowRoot.textLength, absolutePos + 1);
+			do
+			{
+				nextWordPos = para.findNextWordBoundary(nextWordPos);
+			} while (nextWordPos < (para.textLength - 1) && CharacterUtil.isWhitespace(para.getCharCodeAtPosition(nextWordPos)));
+			return nextWordPos + paraStart;
+		}
+
+//TODO Huh? These two methods seem to do nothing. 		
+		/** @private */
+		static public function updateStartIfInReadOnlyElement(textFlow:ITextFlow, idx:int):int
+		{
+			return idx;
+		}
+		
+		/** @private */
+		static public function updateEndIfInReadOnlyElement(textFlow:ITextFlow, idx:int):int
+		{
+			return idx; 
+		}
+		
+		static private function moveForwardHelper(range:TextRange, extendSelection:Boolean, incrementor:Function):Boolean
+		{
+			var textFlow:ITextFlow = range.textFlow;
+			var begIdx:int = range.anchorPosition;
+			var endIdx:int = range.activePosition;
+				
+			if (extendSelection) 
+				endIdx = incrementor(textFlow, endIdx);
+			else {
+				if (begIdx == endIdx) //no selection, just move insertion point
+				{
+					begIdx = incrementor(textFlow, begIdx);
+					endIdx = begIdx;
+				}
+				else if (endIdx > begIdx) //change selection to insertion point
+					begIdx = endIdx;
+				else
+					endIdx = begIdx;
+			}
+			
+			if (begIdx == endIdx)
+			{
+				begIdx = updateStartIfInReadOnlyElement(textFlow, begIdx);
+				endIdx = updateEndIfInReadOnlyElement(textFlow, endIdx);
+			} else {
+				endIdx = updateEndIfInReadOnlyElement(textFlow, endIdx);
+			} 
+					
+			if (!extendSelection && (range.anchorPosition == begIdx) && (range.activePosition == endIdx))
+			{
+				if (begIdx < endIdx)
+				{
+					begIdx = Math.min(endIdx + 1, textFlow.textLength - 1);
+					endIdx = begIdx;
+				}else {
+					endIdx = Math.min(begIdx + 1, textFlow.textLength - 1);
+					begIdx = endIdx;
+				}	
+			}
+			return range.updateRange(begIdx,endIdx);							 	
+		}
+		
+		static private function moveBackwardHelper(range:TextRange, extendSelection:Boolean, incrementor:Function):Boolean
+		{
+			var textFlow:ITextFlow = range.textFlow;
+			var begIdx:int = range.anchorPosition;
+			var endIdx:int = range.activePosition;
+				
+			if (extendSelection)	//shift key is pressed 
+				endIdx = incrementor(textFlow, endIdx);
+			else {
+				if (begIdx == endIdx) //no selection, just move insertion point
+				{
+					begIdx = incrementor(textFlow, begIdx);
+					endIdx = begIdx;
+				}
+				else if (endIdx > begIdx) //change selection to insertion point
+					endIdx = begIdx;
+				else
+					begIdx = endIdx;
+			}
+					
+			if (begIdx == endIdx)
+			{
+				begIdx = updateEndIfInReadOnlyElement(textFlow, begIdx);
+				endIdx = updateStartIfInReadOnlyElement(textFlow, endIdx);
+			} else {
+				endIdx = updateStartIfInReadOnlyElement(textFlow, endIdx);
+			} 
+					
+			if (!extendSelection && (range.anchorPosition == begIdx) && (range.activePosition == endIdx))
+			{
+				if (begIdx < endIdx)
+				{
+					endIdx = Math.max(begIdx - 1, 0);
+					begIdx = endIdx;
+				}else {
+					begIdx = Math.max(endIdx - 1, 0);
+					endIdx = begIdx;
+				}	
+			}
+			return range.updateRange(begIdx,endIdx);
+		 }
+		
+		/**
+		 * Sets the TextRange forward by one character.
+		 * @param extendSelection	Indicates that only activeIndex should move
+		 * @return true if selection changed.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */		 
+		static public function nextCharacter(range:TextRange, extendSelection:Boolean = false):Boolean
+		{
+			if (validateTextRange(range))
+			{
+				if (!adjustForOversetForward(range))
+					moveForwardHelper(range, extendSelection, nextAtomPosition);
+				return true;
+			}
+		 	return false;
+		}
+		 
+		/**
+		 * Sets the TextRange backward by one character.
+		 * @param extendSelection	Indicates that only activeIndex should move
+		 * @return true if selection changed.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */		 		 
+		static public function previousCharacter(range:TextRange, extendSelection:Boolean = false):Boolean
+		{
+			if (validateTextRange(range))
+			{
+				if (!adjustForOversetBack(range))
+					moveBackwardHelper(range, extendSelection, previousAtomPosition);
+				return true;
+			} 
+			return false;
+		} 
+		/**
+		 * Sets the TextRange forward by one word.
+		 * @param extendSelection	Indicates that only activeIndex should move
+		 * @return true if selection changed.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */		 		 		 
+		static public function nextWord(range:TextRange, extendSelection:Boolean = false):Boolean
+		{
+			if (validateTextRange(range))
+			{
+				if (!adjustForOversetForward(range))
+					moveForwardHelper(range, extendSelection, nextWordPosition);
+				return true;
+			}
+			return false;
+		}
+		 
+		/**
+		 * Sets the TextRange backward by one word.
+		 * @param extendSelection	Indicates that only activeIndex should move
+		 * @return true if selection changed.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */		 		 		 		 
+		static public function previousWord(range:TextRange, extendSelection:Boolean = false):Boolean
+		{
+			if (validateTextRange(range))
+			{
+				if (!adjustForOversetBack(range))
+		 			moveBackwardHelper(range, extendSelection, previousWordPosition);
+		 		return true;
+		 	}
+		 	return false;
+		} 
+		
+		/** @private */
+		static public function computeEndIdx(targetFlowLine:ITextFlowLine,curTextFlowLine:ITextFlowLine,blockProgression:String,isRTLDirection:Boolean,globalPoint:Point):int
+		{
+			var endIdx:int;
+			var targetTextLine:ITextLine = targetFlowLine.getTextLine(true);
+			var blockOffset:int = targetFlowLine.paragraph.getTextBlockAbsoluteStart(targetTextLine.textBlock);
+			var currentTextLine:ITextLine = curTextFlowLine.getTextLine(true);
+			
+			if (targetFlowLine.controller == curTextFlowLine.controller)
+			{
+				if(blockProgression != BlockProgression.RL)
+				{
+					globalPoint.y -= (currentTextLine.y - targetTextLine.y);
+				} else {
+					globalPoint.x += (targetTextLine.x - currentTextLine.x);
+				}
+			} else {
+				var firstAtomRect:Rectangle = targetTextLine.getAtomBounds(0);
+				var firstAtomPoint:Point = new Point();
+				firstAtomPoint.x = firstAtomRect.left;
+				firstAtomPoint.y = 0;
+				firstAtomPoint = PointUtils.localToGlobal(firstAtomPoint, targetTextLine);// targetTextLine.localToGlobal(firstAtomPoint);
+				if(blockProgression != BlockProgression.RL)
+				{
+					globalPoint.x -= curTextFlowLine.controller.container.x;
+					globalPoint.y = firstAtomPoint.y;
+				} else {
+					globalPoint.x = firstAtomPoint.x;
+					globalPoint.y -= curTextFlowLine.controller.container.y; 
+				}					
+			} 
+			
+			var atomIndex:int = targetTextLine.getAtomIndexAtPoint(globalPoint.x,globalPoint.y);
+//TODO I moved this below the above line to fix a warning. The atomIndex was originally wrong, but this fix might have broken something.
+			var bidiRightToLeft:Boolean = ((currentTextLine.getAtomBidiLevel(atomIndex) % 2) != 0); 				
+			if (atomIndex == -1)
+			{
+				if(blockProgression != BlockProgression.RL) {
+					if (!bidiRightToLeft)
+						endIdx = (globalPoint.x <= targetTextLine.x) ? targetFlowLine.absoluteStart : (targetFlowLine.absoluteStart + targetFlowLine.textLength - 1);
+					else
+						endIdx = (globalPoint.x <= targetTextLine.x) ? (targetFlowLine.absoluteStart + targetFlowLine.textLength - 1) : targetFlowLine.absoluteStart;						
+				} else {
+					if (!bidiRightToLeft)
+						endIdx = (globalPoint.y <= targetTextLine.y) ? targetFlowLine.absoluteStart : (targetFlowLine.absoluteStart + targetFlowLine.textLength - 1);
+					else
+						endIdx = (globalPoint.y <= targetTextLine.y)  ? (targetFlowLine.absoluteStart + targetFlowLine.textLength - 1) : targetFlowLine.absoluteStart;						
+				}
+			} 
+			else {
+				// get the character box and if check we are past the middle select past this character. 
+				var glyphRect:Rectangle = targetTextLine.getAtomBounds(atomIndex);
+				var leanRight:Boolean = false;
+				if(glyphRect)
+				{	
+					//if this is TTB and NOT TCY determine lean based on Y coordinates...
+					var glyphGlobalPoint:Point = new Point();
+					glyphGlobalPoint.x = glyphRect.x;
+					glyphGlobalPoint.y = glyphRect.y;
+					glyphGlobalPoint = PointUtils.localToGlobal(glyphGlobalPoint, targetTextLine);// targetTextLine.localToGlobal(glyphGlobalPoint);
+					
+					if((blockProgression == BlockProgression.RL) && targetTextLine.getAtomTextRotation(atomIndex) != TextRotation.ROTATE_0)
+						leanRight = (globalPoint.y > (glyphGlobalPoint.y + glyphRect.height/2));
+					else //use X..
+						leanRight = (globalPoint.x > (glyphGlobalPoint.x + glyphRect.width/2));
+				}
+				
+				var paraSelectionIdx:int;
+				if ((targetTextLine.getAtomBidiLevel(atomIndex) % 2) != 0) // Right to left case, right is "start" unicode
+					paraSelectionIdx = leanRight ? targetTextLine.getAtomTextBlockBeginIndex(atomIndex) : targetTextLine.getAtomTextBlockEndIndex(atomIndex);
+				else  {// Left to right case, right is "end" unicode
+					if (isRTLDirection) {
+						if ((leanRight == false) && (atomIndex > 0))
+						{
+							paraSelectionIdx = targetTextLine.getAtomTextBlockBeginIndex(atomIndex - 1);	
+						} else {
+							paraSelectionIdx = targetTextLine.getAtomTextBlockBeginIndex(atomIndex);
+						}
+					} else {
+						paraSelectionIdx = leanRight ? targetTextLine.getAtomTextBlockEndIndex(atomIndex) : targetTextLine.getAtomTextBlockBeginIndex(atomIndex);							
+					}
+				}
+				endIdx = blockOffset + paraSelectionIdx;
+			}
+			return endIdx;
+		}
+		/**
+		 * Sets the TextRange down one line
+		 * @param extendSelection	Indicates that only activeIndex should move
+		 * @return true if selection changed.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */		 		 		 		 		 
+		static public function nextLine(range:TextRange, extendSelection:Boolean = false):Boolean
+		{
+			if (!validateTextRange(range))
+				return false;
+		
+			if (adjustForOversetForward(range))
+				return true;
+				
+			var textFlow:ITextFlow = range.textFlow;
+			var blockProgression:String = textFlow.computedFormat.blockProgression;
+			var begIdx:int = range.anchorPosition;
+			var endIdx:int = range.activePosition;
+			var limitIdx:int = endOfLastController(textFlow);
+			
+			var curLine:int = textFlow.flowComposer.findLineIndexAtPosition(endIdx);
+			var isRTLDirection:Boolean = (textFlow.computedFormat.direction == Direction.RTL);			
+
+			if (curLine < textFlow.flowComposer.numLines-1)	//create, expand or shrink the selection
+			{
+				var curTextFlowLine:ITextFlowLine = textFlow.flowComposer.getLineAt(curLine);
+//				var lineStart:int = curTextFlowLine.absoluteStart;
+//				var lineDelta:int = endIdx - lineStart;
+				var currentTextLine:ITextLine = curTextFlowLine.getTextLine(true);
+				var blockOffset:int = curTextFlowLine.paragraph.getTextBlockAbsoluteStart(currentTextLine.textBlock);
+				var atomIndex:int = currentTextLine.getAtomIndexAtCharIndex(endIdx - blockOffset);
+//				var bidiRightToLeft:Boolean = ((currentTextLine.getAtomBidiLevel(atomIndex) % 2) != 0); 
+				var curPosRect:Rectangle = currentTextLine.getAtomBounds(atomIndex);
+				var currentTextLineX:Number = currentTextLine.x;
+				var curPosRectLeft:Number = curPosRect.left;
+				var curPosRectRight:Number = curPosRect.right;
+				if(blockProgression == BlockProgression.RL)
+				{
+					currentTextLineX = currentTextLine.y;
+					curPosRectLeft = curPosRect.top;
+					curPosRectRight = curPosRect.bottom;
+				}
+				
+				//find the atom
+				var globalPoint:Point = new Point();				
+						
+				if(blockProgression != BlockProgression.RL)
+				{
+					if (!isRTLDirection)
+						globalPoint.x = curPosRect.left;
+					else
+						globalPoint.x = curPosRect.right;
+					globalPoint.y = 0;
+				} else {						
+					globalPoint.x = 0;
+					if (!isRTLDirection)
+						globalPoint.y = curPosRect.top;
+					else
+						globalPoint.y = curPosRect.bottom;
+				}
+				
+				globalPoint = PointUtils.localToGlobal(globalPoint, currentTextLine);// currentTextLine.localToGlobal(globalPoint);
+				
+				//at this point, we have the global point of our current position.  Now adjust x or y to the
+				//baseline of the next line.
+				var lineInc:int = 1;
+				var nextFlowLine:ITextFlowLine = textFlow.flowComposer.getLineAt(curLine + lineInc);
+				while(nextFlowLine is TextFlowTableBlock)
+					nextFlowLine = textFlow.flowComposer.getLineAt(++lineInc + curLine);
+				if (!nextFlowLine || nextFlowLine.absoluteStart >= limitIdx)
+				{
+					if (!extendSelection)
+						range.activePosition = range.anchorPosition = textFlow.textLength - 1;
+					else
+						range.activePosition = textFlow.textLength;
+					return true;
+				}
+				
+				
+				// get the last container so that we can make sure the previous line is in view.
+				var controller:IContainerController = textFlow.flowComposer.getControllerAt(textFlow.flowComposer.numControllers-1);
+				var firstPosInContainer:int = controller.absoluteStart;
+				var lastPosInContainer:int = firstPosInContainer + controller.textLength;
+				if ((nextFlowLine.absoluteStart >= firstPosInContainer) && (nextFlowLine.absoluteStart < lastPosInContainer))
+				{
+					if (nextFlowLine.isDamaged())
+					{
+						textFlow.flowComposer.composeToPosition(nextFlowLine.absoluteStart+1);
+						nextFlowLine = textFlow.flowComposer.getLineAt(curLine + 1);
+						if (nextFlowLine.isDamaged())
+							return false;
+					}
+					// Scroll down one line, but allow scrolling only in the block progression direction
+					var curLogicalHorizontalScrollPos:Number = (blockProgression == BlockProgression.TB) ? controller.horizontalScrollPosition : controller.verticalScrollPosition;
+					controller.scrollToRange(nextFlowLine.absoluteStart, nextFlowLine.absoluteStart + nextFlowLine.textLength - 1);
+					if (blockProgression == BlockProgression.TB)
+						controller.horizontalScrollPosition = curLogicalHorizontalScrollPos;
+					else
+						controller.verticalScrollPosition = curLogicalHorizontalScrollPos; 
+				}
+				
+				endIdx = computeEndIdx(nextFlowLine,curTextFlowLine,blockProgression,isRTLDirection,globalPoint);
+
+				if (endIdx >= textFlow.textLength)
+					endIdx = textFlow.textLength;
+			}
+			else
+				endIdx = textFlow.textLength;
+				
+			if (!extendSelection)
+				begIdx = endIdx;
+											
+			if (begIdx == endIdx)
+			{
+				begIdx = updateStartIfInReadOnlyElement(textFlow, begIdx);
+				endIdx = updateEndIfInReadOnlyElement(textFlow, endIdx);
+			} else {
+				endIdx = updateEndIfInReadOnlyElement(textFlow, endIdx);
+			}
+			return range.updateRange(begIdx,endIdx);			
+		}
+		  
+		/**
+		 * Sets the TextRange up one line.
+		 * @param extendSelection	Indicates that only activeIndex should move
+		 * @return true if selection changed.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */		 		 		 		 		 		 
+		static public function previousLine(range:TextRange, extendSelection:Boolean = false):Boolean
+		{
+			if (!validateTextRange(range))
+				return false;
+			
+			if (adjustForOversetBack(range))
+				return true;
+				
+			var textFlow:ITextFlow = range.textFlow;
+			var blockProgression:String = textFlow.computedFormat.blockProgression;
+			var begIdx:int = range.anchorPosition;
+			var endIdx:int = range.activePosition;
+			
+			var curLine:int = textFlow.flowComposer.findLineIndexAtPosition(endIdx);
+			var isRTLDirection:Boolean = (textFlow.computedFormat.direction == Direction.RTL);			
+
+			if (curLine > 0)	//create, expand or shrink the selection
+			{
+				var curTextFlowLine:ITextFlowLine = textFlow.flowComposer.getLineAt(curLine);
+//				var lineStart:int = curTextFlowLine.absoluteStart;
+//				var lineDelta:int = endIdx - lineStart;
+				var currentTextLine:ITextLine = curTextFlowLine.getTextLine(true);
+				var blockOffset:int = curTextFlowLine.paragraph.getTextBlockAbsoluteStart(currentTextLine.textBlock);
+				var atomIndex:int = currentTextLine.getAtomIndexAtCharIndex(endIdx - blockOffset);
+				var curPosRect:Rectangle = currentTextLine.getAtomBounds(atomIndex);
+				var currentTextLineX:Number = currentTextLine.x;
+				var curPosRectLeft:Number = curPosRect.left;
+				var curPosRectRight:Number = curPosRect.right;
+				if(blockProgression == BlockProgression.RL)
+				{
+					currentTextLineX = currentTextLine.y;
+					curPosRectLeft = curPosRect.top;
+					curPosRectRight = curPosRect.bottom;
+				}
+				
+				//find the atom
+				var globalPoint:Point = new Point();				
+						
+				if(blockProgression != BlockProgression.RL)
+				{
+					if (!isRTLDirection)
+						globalPoint.x = curPosRect.left;
+					else
+						globalPoint.x = curPosRect.right;
+					globalPoint.y = 0;
+				} else {						
+					globalPoint.x = 0;
+					if (!isRTLDirection)
+						globalPoint.y = curPosRect.top;
+					else
+						globalPoint.y = curPosRect.bottom;
+				}
+				
+				globalPoint = PointUtils.localToGlobal(globalPoint, currentTextLine);// currentTextLine.localToGlobal(globalPoint);
+				
+				//at this point, we have the global point of our current position.  Now adjust x or y to the
+				//baseline of the next line.
+				var lineInc:int = 1;
+				var prevFlowLine:ITextFlowLine = textFlow.flowComposer.getLineAt(curLine - lineInc);
+				while(prevFlowLine is TextFlowTableBlock)
+					prevFlowLine = textFlow.flowComposer.getLineAt(curLine - (++lineInc));
+				if (!prevFlowLine)
+				{
+					if (!extendSelection)
+						range.activePosition = range.anchorPosition = 0;
+					else
+						range.activePosition = 0;
+					return true;
+				}
+
+				// get the last container so that we can make sure the previous line is in view.
+				var controller:IContainerController = textFlow.flowComposer.getControllerAt(textFlow.flowComposer.numControllers-1);
+				var firstPosInContainer:int = controller.absoluteStart;
+				var lastPosInContainer:int = firstPosInContainer + controller.textLength;
+				if ((prevFlowLine.absoluteStart >= firstPosInContainer) && (prevFlowLine.absoluteStart < lastPosInContainer))
+				{
+					// Scroll up one line, but allow scrolling only in the block progression direction
+					var curLogicalHorizontalScrollPos:Number = (blockProgression == BlockProgression.TB) ? controller.horizontalScrollPosition : controller.verticalScrollPosition;
+					controller.scrollToRange(prevFlowLine.absoluteStart,prevFlowLine.absoluteStart+prevFlowLine.textLength-1);
+					if (blockProgression == BlockProgression.TB)
+						controller.horizontalScrollPosition = curLogicalHorizontalScrollPos;
+					else
+						controller.verticalScrollPosition = curLogicalHorizontalScrollPos; 
+				}
+				
+				endIdx = computeEndIdx(prevFlowLine,curTextFlowLine,blockProgression,isRTLDirection,globalPoint);
+			}
+			else 
+			{
+				endIdx = 0;
+			}
+				
+			if (!extendSelection)
+				begIdx = endIdx;
+											
+			if (begIdx == endIdx)
+			{
+				begIdx = updateStartIfInReadOnlyElement(textFlow, begIdx);
+				endIdx = updateEndIfInReadOnlyElement(textFlow, endIdx);
+			} else {
+				endIdx = updateEndIfInReadOnlyElement(textFlow, endIdx);
+			}
+			return range.updateRange(begIdx,endIdx);			
+		}
+		 
+		/**
+		 * Sets the TextRange down one page.
+		 * @param extendSelection	Indicates that only activeIndex should move
+		 * @return true if selection changed.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */		 		 		 		 		 		 		 
+		static public function nextPage(range:TextRange, extendSelection:Boolean = false):Boolean
+		{
+			var controller:IContainerController;
+			
+			if (!validateTextRange(range))
+				return false;
+				
+			var textFlow:ITextFlow = range.textFlow;
+			
+			// if not the last container go to the beginning of the next container
+			var controllerIndex:int = textFlow.flowComposer.findControllerIndexAtPosition(range.activePosition);
+			if (controllerIndex != textFlow.flowComposer.numControllers-1)
+			{
+				range.activePosition = textFlow.flowComposer.getControllerAt(controllerIndex+1).absoluteStart;
+				if (!extendSelection)
+					range.anchorPosition = range.activePosition;
+				return true;
+			}
+			
+			if (!isScrollable(textFlow, range.activePosition))		// paging applies only to containers that scroll
+				return false;
+								
+			if (adjustForOversetForward(range))
+				return true;
+		 	
+			var begIdx:int = range.absoluteStart;
+			var endIdx:int = range.absoluteEnd;
+			var curLine:int = textFlow.flowComposer.findLineIndexAtPosition(endIdx);
+			var curTextFlowLine:ITextFlowLine = textFlow.flowComposer.getLineAt(curLine);
+			
+			var lineStart:int = textFlow.flowComposer.getLineAt(curLine).absoluteStart;
+			var linePos:int = endIdx - lineStart;
+ 			var nextLine:int;
+ 			var nextTextFlowLine:ITextFlowLine = curTextFlowLine;
+ 											
+			var isTTB:Boolean = textFlow.computedFormat.blockProgression == BlockProgression.RL;
+			var amount:Number;
+			
+			// get the last container
+			controller = textFlow.flowComposer.getControllerAt(textFlow.flowComposer.numControllers-1);
+
+			if (isTTB)
+			{
+				amount = controller.compositionWidth * textFlow.configuration.scrollPagePercentage;
+			} else {
+				amount = controller.compositionHeight * textFlow.configuration.scrollPagePercentage;
+			}
+  								
+ 			if (isTTB)
+ 			{
+				var contentWidth:Number = controller.contentWidth;
+ 				if ((controller.horizontalScrollPosition - amount) < -contentWidth)
+ 				{
+ 					controller.horizontalScrollPosition = -contentWidth;
+					nextLine = textFlow.flowComposer.numLines - 1;
+					nextTextFlowLine = textFlow.flowComposer.getLineAt(nextLine);								
+ 				} else
+ 				{
+ 					var oldHorzScrollPos:Number = controller.horizontalScrollPosition;
+ 					controller.horizontalScrollPosition -= amount;
+ 					var newHorzScrollPos:Number = controller.horizontalScrollPosition;
+ 					if (oldHorzScrollPos == newHorzScrollPos) {
+						nextLine = textFlow.flowComposer.numLines - 1;
+						nextTextFlowLine = textFlow.flowComposer.getLineAt(nextLine);													
+ 					} else {
+ 						nextLine = curLine;
+ 						while (nextLine < (textFlow.flowComposer.numLines - 1))
+ 						{
+ 							nextLine++;
+							nextTextFlowLine = textFlow.flowComposer.getLineAt(nextLine);
+							if ((curTextFlowLine.x - nextTextFlowLine.x) >= (oldHorzScrollPos - newHorzScrollPos))
+								break;
+ 						}
+ 					}
+ 				} 					
+ 			}
+ 			else
+ 			{
+				var contentHeight:Number = controller.contentHeight;
+ 				if ((controller.verticalScrollPosition + amount) > contentHeight)
+ 				{
+ 					controller.verticalScrollPosition = contentHeight;
+					nextLine = textFlow.flowComposer.numLines - 1;
+					nextTextFlowLine = textFlow.flowComposer.getLineAt(nextLine);								 						
+ 				} else
+ 				{
+ 					var oldVertScrollPos:Number = controller.verticalScrollPosition;
+ 					controller.verticalScrollPosition += amount;
+ 					var newVertScrollPos:Number = controller.verticalScrollPosition;
+ 					if (newVertScrollPos == oldVertScrollPos) {
+						nextLine = textFlow.flowComposer.numLines - 1;
+						nextTextFlowLine = textFlow.flowComposer.getLineAt(nextLine);								 											
+ 					} else {
+ 						nextLine = curLine;
+ 						while (nextLine < (textFlow.flowComposer.numLines - 1))
+ 						{
+ 							nextLine++;
+							nextTextFlowLine = textFlow.flowComposer.getLineAt(nextLine);
+							if ((nextTextFlowLine.y - curTextFlowLine.y) >= (newVertScrollPos - oldVertScrollPos))
+								break;
+ 						} 						
+ 					}
+ 				}
+ 			}
+ 			
+ 			endIdx = nextTextFlowLine.absoluteStart + linePos; 
+			var nextLineEnd:int = nextTextFlowLine.absoluteStart + nextTextFlowLine.textLength - 1;
+			if (endIdx > nextLineEnd)
+			{
+				endIdx = nextLineEnd;
+			}
+			
+			if (!extendSelection)
+				begIdx = endIdx;							
+			if (begIdx == endIdx)
+			{
+				begIdx = updateEndIfInReadOnlyElement(textFlow, begIdx);
+				endIdx = updateStartIfInReadOnlyElement(textFlow, endIdx);
+			} else {
+				endIdx = updateStartIfInReadOnlyElement(textFlow, endIdx);
+			}
+			
+			return range.updateRange(begIdx,endIdx);				
+		 }
+		  
+		/**
+		 * Sets the TextRange up one page.
+		 * @param extendSelection	Indicates that only activeIndex should move
+		 * @return true if selection changed.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */		 		 		 		 		 		 		 		 
+		static public function previousPage(range:TextRange, extendSelection:Boolean = false):Boolean
+		{
+			if (!validateTextRange(range))
+				return false;
+				
+			var textFlow:ITextFlow = range.textFlow;
+			
+			var controllerIndex:int = textFlow.flowComposer.findControllerIndexAtPosition(range.activePosition);
+			var controller:IContainerController = textFlow.flowComposer.getControllerAt(controllerIndex);
+			
+			// first line in container
+			var controllerFirstLine:ITextFlowLine = textFlow.flowComposer.findLineAtPosition(controller.absoluteStart);
+
+			// if on the first line of a controller go to the beginning of the previous controller
+			if (range.activePosition <= controller.absoluteStart+controllerFirstLine.textLength)
+			{
+				if (controllerIndex == 0)
+					return false;
+				range.activePosition = textFlow.flowComposer.getControllerAt(controllerIndex-1).absoluteStart;
+				if (!extendSelection)
+					range.anchorPosition = range.activePosition;
+				return true;
+			}
+			
+			// if not the last container go to the beginning of the current container
+			if (controllerIndex != textFlow.flowComposer.numControllers-1)
+			{
+				range.activePosition = controller.absoluteStart;
+				if (!extendSelection)
+					range.anchorPosition = range.activePosition;
+				return true;
+			}
+				
+			if (!isScrollable(textFlow, range.activePosition))		// paging applies only to containers that scroll
+				return false;
+								
+			if (adjustForOversetBack(range))
+				return true;
+			
+			var begIdx:int = range.absoluteStart;
+			var endIdx:int = range.absoluteEnd;
+			var curLine:int = textFlow.flowComposer.findLineIndexAtPosition(endIdx);
+			var curTextFlowLine:ITextFlowLine = textFlow.flowComposer.getLineAt(curLine);
+			
+			var lineStart:int = textFlow.flowComposer.getLineAt(curLine).absoluteStart;
+			var linePos:int = endIdx - lineStart;
+ 			var nextLine:int;
+ 			var nextTextFlowLine:ITextFlowLine = curTextFlowLine;
+ 											
+			var isTTB:Boolean = textFlow.computedFormat.blockProgression == BlockProgression.RL;
+			var amount:Number;
+			
+			// get the last container
+			controller = textFlow.flowComposer.getControllerAt(textFlow.flowComposer.numControllers-1);
+			
+			if (isTTB)
+			{
+				amount = controller.compositionWidth * textFlow.configuration.scrollPagePercentage;
+			} else {
+				amount = controller.compositionHeight * textFlow.configuration.scrollPagePercentage;
+			}
+  								
+ 			if (isTTB)
+ 			{
+ 				if ((controller.horizontalScrollPosition + amount + controller.compositionWidth) > 0)
+ 				{
+ 					controller.horizontalScrollPosition = 0;
+					nextLine = textFlow.flowComposer.findLineIndexAtPosition(controller.absoluteStart);
+					nextTextFlowLine = textFlow.flowComposer.getLineAt(nextLine);								
+ 				} else
+ 				{
+ 					var oldHorzPos:Number = controller.horizontalScrollPosition;
+ 					controller.horizontalScrollPosition += amount;
+ 					var newHorzPos:Number = controller.horizontalScrollPosition;
+ 					if (oldHorzPos == newHorzPos) {
+						nextLine = textFlow.flowComposer.findLineIndexAtPosition(controller.absoluteStart);
+						nextTextFlowLine = textFlow.flowComposer.getLineAt(nextLine);													
+ 					} else {
+ 						nextLine = curLine;
+ 						while (nextLine > 0)
+ 						{
+ 							nextLine--;
+							nextTextFlowLine = textFlow.flowComposer.getLineAt(nextLine);
+							if ((nextTextFlowLine.x - curTextFlowLine.x) >= (newHorzPos - oldHorzPos) || nextTextFlowLine.absoluteStart < controller.absoluteStart)
+								break;
+ 						}
+ 					}
+ 				} 					
+ 			}
+ 			else
+ 			{
+ 				if ((controller.verticalScrollPosition - amount + controller.compositionHeight) < 0)
+ 				{
+ 					controller.verticalScrollPosition = 0;
+					nextLine = textFlow.flowComposer.findLineIndexAtPosition(controller.absoluteStart);
+					nextTextFlowLine = textFlow.flowComposer.getLineAt(nextLine);								 						
+ 				} else
+ 				{
+ 					var oldVertPos:Number = controller.verticalScrollPosition;
+ 					controller.verticalScrollPosition -= amount;
+ 					var newVertPos:Number = controller.verticalScrollPosition;
+ 					if (oldVertPos == newVertPos) {
+						nextLine = textFlow.flowComposer.findLineIndexAtPosition(controller.absoluteStart);
+						nextTextFlowLine = textFlow.flowComposer.getLineAt(nextLine);								 											
+ 					} else {
+ 						nextLine = curLine;
+ 						while (nextLine > 0)
+ 						{
+ 							nextLine--;
+							nextTextFlowLine = textFlow.flowComposer.getLineAt(nextLine);
+							if ((curTextFlowLine.y - nextTextFlowLine.y) >= (oldVertPos - newVertPos) || nextTextFlowLine.absoluteStart < controller.absoluteStart)
+								break;
+ 						}
+ 					} 						
+ 				}
+ 			}
+ 			
+ 			endIdx = nextTextFlowLine.absoluteStart + linePos; 
+			var nextLineEnd:int = nextTextFlowLine.absoluteStart + nextTextFlowLine.textLength - 1;
+			if (endIdx > nextLineEnd)
+			{
+				endIdx = nextLineEnd;
+			}
+			
+			if (!extendSelection)
+				begIdx = endIdx;							
+			if (begIdx == endIdx)
+			{
+				begIdx = updateEndIfInReadOnlyElement(textFlow, begIdx);
+				endIdx = updateStartIfInReadOnlyElement(textFlow, endIdx);
+			} else {
+				endIdx = updateStartIfInReadOnlyElement(textFlow, endIdx);
+			}
+			return range.updateRange(begIdx,endIdx);						
+		} 
+		/**
+		 * Sets the TextRange at the end of the line.
+		 * @param extendSelection	Indicates that only activeIndex should move
+		 * @return true if selection changed.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */		 		 		 		 		 		 		 		 		 
+		static public function endOfLine(range:TextRange, extendSelection:Boolean = false):Boolean
+		{
+			if (!validateTextRange(range))
+				return false;
+			
+
+			var textFlow:ITextFlow = range.textFlow;
+			checkCompose(textFlow.flowComposer, range.absoluteEnd);
+
+			var begIdx:int = range.anchorPosition;
+			var endIdx:int = range.activePosition;
+			var curLine:int = textFlow.flowComposer.findLineIndexAtPosition(endIdx);
+			var lineStart:int = textFlow.flowComposer.getLineAt(curLine).absoluteStart;
+			var lineEnd:int = lineStart + textFlow.flowComposer.getLineAt(curLine).textLength - 1;
+			
+			var leaf:IFlowLeafElement = textFlow.findLeaf(endIdx);
+			var para:IParagraphElement = leaf.getParagraph();
+			if (CharacterUtil.isWhitespace(para.getCharCodeAtPosition(lineEnd - para.getAbsoluteStart())))
+			{
+				endIdx = lineEnd;
+			} else {
+				endIdx = lineEnd + 1;
+			}
+			if (!extendSelection)
+				begIdx = endIdx;							
+			if (begIdx == endIdx)
+			{
+				begIdx = updateEndIfInReadOnlyElement(textFlow, begIdx);
+				endIdx = updateStartIfInReadOnlyElement(textFlow, endIdx);
+			} else {
+				endIdx = updateStartIfInReadOnlyElement(textFlow, endIdx);
+			}
+			return range.updateRange(begIdx,endIdx);
+		 }
+		 
+		/**
+		 * Sets the TextRange at the beginning of the line.
+		 * @param extendSelection	Indicates that only activeIndex should move
+		 * @return true if selection changed.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */		 		 		 		 		 		 		 		 		 		 
+		static public function startOfLine(range:TextRange, extendSelection:Boolean = false):Boolean
+		{
+			if (!validateTextRange(range))
+				return false;
+				
+			var textFlow:ITextFlow = range.textFlow;
+			checkCompose(textFlow.flowComposer, range.absoluteEnd);
+			var begIdx:int = range.anchorPosition;
+			var endIdx:int = range.activePosition;
+		
+			var curLine:int = textFlow.flowComposer.findLineIndexAtPosition(endIdx);
+			var lineStart:int = textFlow.flowComposer.getLineAt(curLine).absoluteStart;
+			endIdx = lineStart;
+			if (!extendSelection)
+				begIdx = endIdx;							
+			if (begIdx == endIdx)
+			{
+				begIdx = updateEndIfInReadOnlyElement(textFlow, begIdx);
+				endIdx = updateStartIfInReadOnlyElement(textFlow, endIdx);
+			} else {
+				endIdx = updateStartIfInReadOnlyElement(textFlow, endIdx);
+			}
+			return range.updateRange(begIdx,endIdx);
+		} 
+		/**
+		 * Sets the TextRange at the end of the document.
+		 * @param extendSelection	Indicates that only activeIndex should move
+		 * @return true if selection changed.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */		 		 		 		 		 		 		 		 		 		 		 
+		static public function endOfDocument(range:TextRange, extendSelection:Boolean = false):Boolean
+		{
+			if (!validateTextRange(range))
+				return false;
+				
+			var textFlow:ITextFlow = range.textFlow;
+			var begIdx:int = range.anchorPosition;
+			var endIdx:int = range.activePosition;
+			endIdx = textFlow.textLength;
+			if (!extendSelection)
+				begIdx = endIdx;							
+			if (begIdx == endIdx)
+			{
+				begIdx = updateEndIfInReadOnlyElement(textFlow, begIdx);
+				endIdx = updateStartIfInReadOnlyElement(textFlow, endIdx);
+			} else {
+				endIdx = updateStartIfInReadOnlyElement(textFlow, endIdx);
+			}
+			return range.updateRange(begIdx,endIdx);				
+		}
+		
+		/**
+		 * Sets the TextRange at the beginning of the document.
+		 * @param extendSelection	Indicates that only activeIndex should move
+		 * @return true if selection changed.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */		 		 		 		 		 		 		 		 		 		 		 		 
+		static public function startOfDocument(range:TextRange, extendSelection:Boolean = false):Boolean
+		{
+			var begIdx:int = range.anchorPosition;
+			var endIdx:int = 0;
+
+			if (!extendSelection)
+				begIdx = endIdx;							
+			if (begIdx == endIdx)
+			{
+				begIdx = updateEndIfInReadOnlyElement(range.textFlow, begIdx);
+				endIdx = updateStartIfInReadOnlyElement(range.textFlow, endIdx);
+			} else {
+				endIdx = updateStartIfInReadOnlyElement(range.textFlow, endIdx);
+			}
+			return range.updateRange(begIdx,endIdx);				
+		}
+		 
+		/**
+		 * Sets the TextRange at the beginning of the paragraph.
+		 * @param extendSelection	Indicates that only activeIndex should move
+		 * @return true if selection changed.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */		 		 		 		 		 		 		 		 		 		 		 		 		 
+		static public function startOfParagraph(range:TextRange, extendSelection:Boolean = false):Boolean
+		{
+			var begIdx:int = range.anchorPosition;
+			var endIdx:int = range.activePosition;
+			var leaf:IFlowLeafElement = range.textFlow.findLeaf(endIdx);
+			var para:IParagraphElement = leaf.getParagraph();
+			
+			endIdx = para.getAbsoluteStart();
+			if (!extendSelection)
+				begIdx = endIdx;							
+
+			if (begIdx == endIdx)
+			{
+				begIdx = updateStartIfInReadOnlyElement(range.textFlow, begIdx);
+				endIdx = updateEndIfInReadOnlyElement(range.textFlow, endIdx);
+			} else {
+				endIdx = updateEndIfInReadOnlyElement(range.textFlow, endIdx);
+			}
+			return range.updateRange(begIdx,endIdx);
+		 }
+		 
+		/**
+		 * Sets the TextRange at the end of the paragraph.
+		 * @param extendSelection	Indicates that only activeIndex should move
+		 * @return true if selection changed.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */		 		 		 		 		 		 		 		 		 		 		 		 		 		 
+		static public function endOfParagraph(range:TextRange, extendSelection:Boolean = false):Boolean
+		{
+			if (!validateTextRange(range))
+				return false;
+				
+			var begIdx:int = range.anchorPosition;
+			var endIdx:int = range.activePosition;
+			var leaf:IFlowLeafElement = range.textFlow.findLeaf(endIdx);
+			var para:IParagraphElement = leaf.getParagraph();
+			
+			endIdx = para.getAbsoluteStart() + para.textLength - 1;
+			if (!extendSelection)
+				begIdx = endIdx;							
+			if (begIdx == endIdx)
+			{
+				begIdx = updateStartIfInReadOnlyElement(range.textFlow, begIdx);
+				endIdx = updateEndIfInReadOnlyElement(range.textFlow, endIdx);
+			} else {
+				endIdx = updateEndIfInReadOnlyElement(range.textFlow, endIdx);
+			}
+			return range.updateRange(begIdx,endIdx);
+		 }
+	
+		/** If the range is in overset text (after the last container in a non-scrolling flow), adjust the range so it is at the end of the flow. */
+		static private function adjustForOversetForward(range:TextRange):Boolean
+		{
+			var flowComposer:IFlowComposer = range.textFlow.flowComposer;
+			var controller:IContainerController = null;
+			checkCompose(flowComposer, range.absoluteEnd);
+			if (range.absoluteEnd >= flowComposer.damageAbsoluteStart - 1)
+			{
+				clampToFit(range, flowComposer.damageAbsoluteStart - 1);
+				return false;
+				//return true;
+			}
+			if (flowComposer && flowComposer.numControllers)
+			{
+				var controllerIndex:int = flowComposer.findControllerIndexAtPosition(range.absoluteEnd);
+				if (controllerIndex >= 0)
+					controller = flowComposer.getControllerAt(controllerIndex);
+				if (controllerIndex == flowComposer.numControllers-1)
+				{
+					if (controller.absoluteStart + controller.textLength <= range.absoluteEnd && controller.absoluteStart + controller.textLength != range.textFlow.textLength)
+						controller = null;
+				}
+			}
+
+			if (!controller)		// we're overset, or one position before overset
+			{
+				range.anchorPosition = range.textFlow.textLength;
+				range.activePosition = range.anchorPosition;
+				return true;
+			}
+			return false;
+		}
+		
+		static private function clampToFit(range:TextRange, endPos:int):void
+		{
+			if (endPos < 0)
+				endPos = 0;
+			range.anchorPosition = Math.min(range.anchorPosition, endPos);
+			range.activePosition = Math.min(range.activePosition, endPos); 
+		}
+		
+		/** If the range is in overset text (after the last container in a non-scrolling flow), adjust the range so it is at the end of the last controller in the flow. */
+		static private function adjustForOversetBack(range:TextRange):Boolean
+		{
+			var flowComposer:IFlowComposer = range.textFlow.flowComposer;
+			if (flowComposer)
+			{
+				checkCompose(flowComposer, range.absoluteEnd);
+				if (range.absoluteEnd > flowComposer.damageAbsoluteStart - 1)
+				{
+					clampToFit(range, flowComposer.damageAbsoluteStart - 1);
+					return true;
+				} 
+				if (flowComposer.findControllerIndexAtPosition(range.absoluteEnd) == -1)
+				{
+					range.anchorPosition = endOfLastController(range.textFlow);
+					range.activePosition = range.anchorPosition;
+					return true;
+				}				
+			}
+				
+			return false;
+		}
+		
+		private static function checkCompose(flowComposer:IFlowComposer, pos:int):void
+		{
+			if (flowComposer.damageAbsoluteStart <= pos)
+				flowComposer.composeToPosition(pos);
+		}
+		
+		// Returns absolute position of the last controller in the flow, or 0 if the flow has no controllers
+		private static function endOfLastController(flowRoot:ITextFlow):int
+		{
+			var flowComposer:IFlowComposer = flowRoot.flowComposer;
+			if (!flowComposer || flowComposer.numControllers <= 0)
+				return 0;
+				
+			var controller:IContainerController = flowComposer.getControllerAt(flowComposer.numControllers - 1);
+			return controller.absoluteStart + Math.max(controller.textLength - 1, 0);
+		}
+		
+		// Returns true if the position is in the overset text after the last container in the flow.
+		private static function isOverset(flowRoot:ITextFlow, absolutePos:int):Boolean
+		{
+			var flowComposer:IFlowComposer = flowRoot.flowComposer;
+			return (!flowComposer || flowComposer.findControllerIndexAtPosition(absolutePos) == -1);
+		}
+	
+		// Returns true if the position is in a scollable container
+		private static function isScrollable(flowRoot:ITextFlow, absolutePos:int):Boolean
+		{
+			var flowComposer:IFlowComposer = flowRoot.flowComposer;
+			if (!flowComposer)
+				return false;
+			var controllerIndex:int = flowComposer.findControllerIndexAtPosition(absolutePos);
+			if (controllerIndex >= 0)
+			{
+				var controller:IContainerController = flowComposer.getControllerAt(controllerIndex);
+				var blockProgression:String = controller.rootElement.computedFormat.blockProgression;
+				return ((blockProgression == BlockProgression.TB && controller.verticalScrollPolicy != ScrollPolicy.OFF) ||
+					(blockProgression == BlockProgression.RL && controller.horizontalScrollPolicy != ScrollPolicy.OFF));
+			}
+			return false;
+		}
+		
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/NumberFactoryUtil.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/NumberFactoryUtil.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/NumberFactoryUtil.as
new file mode 100644
index 0000000..4532c3d
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/NumberFactoryUtil.as
@@ -0,0 +1,30 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.utils
+{
+	import org.apache.flex.textLayout.factory.NumberLineFactory;
+	import org.apache.flex.textLayout.factory.INumberLineFactory;
+	public class NumberFactoryUtil
+	{
+		public static function getNumberFactory():INumberLineFactory
+		{
+			return new NumberLineFactory();
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/Twips.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/Twips.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/Twips.as
new file mode 100644
index 0000000..6f394dd
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/Twips.as
@@ -0,0 +1,76 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.utils
+{
+	// [ExcludeClass]
+	/** @private
+	 * Internally, we work with Twips, which we consider to be 1/20 of
+	 * a pixel. This is the same measurement as used within FTE (see the
+	 * kTwipsPerPixel constant in flash/core/edittext.h).
+	 * 
+	 * Note that conversion between Pixels and Twips does not round-trip
+	 * due to the loss of precision in the conversion to Twips.
+	 */
+	public final class Twips
+	{
+		/** One twip in pixels */
+		public static const ONE_TWIP:Number = .05;
+		/** Twips per pixels */
+		public static const TWIPS_PER_PIXEL:int = 20;
+		/** Largest Twip value */
+		public static const MAX_VALUE:int = 2147483647;
+		/** Smallest Twip value */
+		public static const MIN_VALUE:int = -2147483647;
+		
+		/** Convert Pixels to Twips (truncated). @return twips */
+		public static function to(n:Number):int
+		{
+			return int(n * 20);
+		}
+		
+		/** Convert Pixels to Twips (rounded). @return twips */
+		public static function roundTo(n:Number):int
+		{
+			return int(Math.round(n) * 20);
+		}
+		
+		/** Convert Twips to pixels. @return pixels */
+		public static function from(t:int):Number
+		{
+			return Number(t) / 20;
+		}
+
+		
+		/** ceil a number to the nearest twip. @return pixels */
+		public static function ceil(n:Number):Number
+		{
+			return Math.ceil(n*20.0)/20.0;
+		}
+		/** floor a number to the nearest twip. @return pixels */
+		public static function floor(n:Number):Number
+		{
+			return Math.floor(n*20.0)/20.0;
+		}
+		/** round a number to the nearest twip. @return pixels */
+		public static function round(n:Number):Number
+		{
+			return Math.round(n*20.0)/20.0;
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/resources/basic-as-manifest.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/resources/basic-as-manifest.xml b/frameworks/projects/TLF/src/main/resources/basic-as-manifest.xml
new file mode 100644
index 0000000..cd0f5b4
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/resources/basic-as-manifest.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<!--
+
+  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
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+-->
+
+
+<componentPackage>
+
+</componentPackage>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/resources/basic-manifest.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/resources/basic-manifest.xml b/frameworks/projects/TLF/src/main/resources/basic-manifest.xml
new file mode 100644
index 0000000..ea6db91
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/resources/basic-manifest.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<!--
+
+  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
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+-->
+
+
+<componentPackage>
+    <!--<component id="Application" class="org.apache.flex.core.Application"/>-->
+</componentPackage>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/resources/defaults.css
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/resources/defaults.css b/frameworks/projects/TLF/src/main/resources/defaults.css
new file mode 100644
index 0000000..1533355
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/resources/defaults.css
@@ -0,0 +1,21 @@
+/*
+*
+*  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
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*
+*/
+
+@namespace "library://ns.apache.org/flexjs/basic";
+

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/Text/build.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/Text/build.xml b/frameworks/projects/Text/build.xml
index 4130208..105dae7 100644
--- a/frameworks/projects/Text/build.xml
+++ b/frameworks/projects/Text/build.xml
@@ -20,7 +20,6 @@
 
 
 <project name="Text" default="main" basedir=".">
-    <!--<property name="FLEXJS_HOME" location="/FlexSDK/FlexJSNightly"/>-->
     <property name="FLEXJS_HOME" location="../../.."/>
     
     <property file="${FLEXJS_HOME}/env.properties"/>


[11/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/NumberLineFactory.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/NumberLineFactory.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/NumberLineFactory.as
new file mode 100644
index 0000000..42fc134
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/NumberLineFactory.as
@@ -0,0 +1,138 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.factory
+{
+	import org.apache.flex.textLayout.compose.utils.FactoryHelper;
+	import org.apache.flex.geom.Rectangle;
+	import org.apache.flex.text.engine.ITextBlock;
+	import org.apache.flex.text.engine.ITextLine;
+	import org.apache.flex.textLayout.compose.utils.NumberLineUserData;
+	import org.apache.flex.textLayout.debug.Debugging;
+	import org.apache.flex.textLayout.elements.IBackgroundManager;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.textLayout.formats.BlockProgression;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+
+	public class NumberLineFactory extends StringTextLineFactory implements INumberLineFactory
+	{
+		private var _listStylePosition:String;
+		private var _markerFormat:ITextLayoutFormat;
+		private var _backgroundManager:IBackgroundManager;
+
+		public function get listStylePosition():String
+		{
+			return _listStylePosition;
+		}
+
+		public function set listStylePosition(val:String):void
+		{
+			_listStylePosition = val;
+		}
+
+		public function get markerFormat():ITextLayoutFormat
+		{
+			return _markerFormat;
+		}
+
+		public function set markerFormat(val:ITextLayoutFormat):void
+		{
+			_markerFormat = val;
+			spanFormat = val;
+		}
+
+		public function get backgroundManager():IBackgroundManager
+		{
+			return _backgroundManager;
+		}
+
+		public function clearBackgroundManager():void
+		{
+			_backgroundManager = null;
+		}
+
+		/** @private */
+		static public function calculateInsideNumberLineWidth(numberLine:ITextLine, bp:String):Number
+		{
+			var minVal:Number = Number.MAX_VALUE;
+			var maxVal:Number = Number.MIN_VALUE;
+			var idx:int = 0;
+			var rect:Rectangle;
+
+			if (bp == BlockProgression.TB)
+			{
+				for (; idx < numberLine.atomCount; idx++)
+				{
+					// trace(idx,numberLine.getAtomTextBlockBeginIndex(idx),numberLine.getAtomBounds(idx));
+					if (numberLine.getAtomTextBlockBeginIndex(idx) != numberLine.rawTextLength - 1)
+					{
+						rect = numberLine.getAtomBounds(idx);
+						minVal = Math.min(minVal, rect.x);
+						maxVal = Math.max(maxVal, rect.right);
+					}
+				}
+			}
+			else
+			{
+				for (; idx < numberLine.atomCount; idx++)
+				{
+					// trace(idx,numberLine.getAtomTextBlockBeginIndex(idx),numberLine.getAtomBounds(idx));
+					if (numberLine.getAtomTextBlockBeginIndex(idx) != numberLine.rawTextLength - 1)
+					{
+						rect = numberLine.getAtomBounds(idx);
+						minVal = Math.min(minVal, rect.top);
+						maxVal = Math.max(maxVal, rect.bottom);
+					}
+				}
+			}
+			// numberLine.flushAtomData(); // Warning: Now does nothing
+			// trace("textWidth",numberLine.textWidth,maxVal-minVal);
+			return maxVal > minVal ? maxVal - minVal : 0;
+		}
+
+		protected override function callbackWithTextLines(callback:Function, delx:Number, dely:Number):void
+		{
+			for each (var textLine:ITextLine in FactoryHelper.staticComposer.lines)
+			{
+				textLine.userData = new NumberLineUserData(listStylePosition, calculateInsideNumberLineWidth(textLine, textFlowFormat.blockProgression), _markerFormat, paragraphFormat.direction);
+				var textBlock:ITextBlock = textLine.textBlock;
+				if (textBlock)
+				{
+					CONFIG::debug
+					{
+						Debugging.traceFTECall(null, textBlock, "releaseLines", textBlock.firstLine, textBlock.lastLine); }
+					textBlock.releaseLines(textBlock.firstLine, textBlock.lastLine);
+				}
+				textLine.x += delx;
+				textLine.y += dely;
+				textLine.validity = "static";
+				CONFIG::debug
+				{
+					Debugging.traceFTEAssign(textLine, "validity", "static"); }
+				callback(textLine);
+			}
+		}
+
+		// save the backgroundManager for later use.  generate the background when the ITextLine is placed
+		public override function processBackgroundColors(textFlow:ITextFlow, callback:Function, x:Number, y:Number, constrainWidth:Number, constrainHeight:Number):*
+		{
+			_backgroundManager = textFlow.backgroundManager;
+			textFlow.clearBackgroundManager();
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/StandardTLFFactory.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/StandardTLFFactory.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/StandardTLFFactory.as
new file mode 100644
index 0000000..2277f85
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/StandardTLFFactory.as
@@ -0,0 +1,48 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.factory {
+	import org.apache.flex.svg.GraphicContainer;
+	import org.apache.flex.core.IParentIUIBase;
+	import org.apache.flex.svg.Rect;
+	import org.apache.flex.svg.CompoundGraphic;
+	import org.apache.flex.textLayout.factory.ITLFFactory;
+	import org.apache.flex.graphics.ICompoundGraphic;
+	import org.apache.flex.graphics.IRect;
+	import org.apache.flex.text.engine.ITextFactory;
+
+	public class StandardTLFFactory implements ITLFFactory {
+		public function getRect() : IRect {
+			return new Rect();
+		}
+
+		public function getCompoundGraphic() : ICompoundGraphic {
+			return new CompoundGraphic();
+		}
+		
+		public function getContainer():IParentIUIBase
+		{
+			return new GraphicContainer();
+		}
+//TODO add a basic factory when it's ready		
+		private static var factory:ITextFactory;
+		public function get textFactory() : ITextFactory {
+			return factory;
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/StringTextLineFactory.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/StringTextLineFactory.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/StringTextLineFactory.as
new file mode 100644
index 0000000..21efec2
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/StringTextLineFactory.as
@@ -0,0 +1,469 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.factory
+{
+	import org.apache.flex.geom.Rectangle;
+	import org.apache.flex.text.engine.ITextLine;
+	import org.apache.flex.textLayout.compose.ISimpleCompose;
+	import org.apache.flex.textLayout.compose.utils.ContextUtil;
+	import org.apache.flex.textLayout.compose.utils.FactoryHelper;
+	import org.apache.flex.textLayout.container.ScrollPolicy;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.elements.Configuration;
+	import org.apache.flex.textLayout.elements.IConfiguration;
+	import org.apache.flex.textLayout.elements.ParagraphElement;
+	import org.apache.flex.textLayout.elements.SpanElement;
+	import org.apache.flex.textLayout.elements.TextFlow;
+	import org.apache.flex.textLayout.formats.BlockProgression;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.formats.LineBreak;
+	import org.apache.flex.textLayout.utils.FactoryUtil;
+
+
+
+
+/**
+ * The StringTextLineFactory class provides a simple way to create TextLines from a string. 
+ * 
+ * <p>The text lines are static and are created using a single format and a single paragraph. 
+ * The lines are created to fit in the specified bounding rectangle.</p>
+ * 
+ * <p>The StringTextLineFactory provides an efficient way to create TextLines, since it reuses single TextFlow,
+ * ParagraphElement, SpanElement, and ContainerController objects across many repeated invocations. You can create a
+ * single factory, and use it again and again. You can also reuse all the parts that are the same each time
+ * you call it; for instance, you can reuse the various formats and the bounds.</p> 
+ *
+ * <p><b>Note:</b> To create static lines that use multiple formats or paragraphs, or that include
+ * inline graphics, use a TextFlowTextLineFactory and a TextFlow object. </p>
+ * 
+ * <p><b>Note:</b> The StringTextLineFactory ignores the truncationIndicatorFormat property set in the truncationOptions when truncating text.</p>
+ *  
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @langversion 3.0
+ *
+ * @see org.apache.flex.textLayout.factory.TextFlowTextLineFactory TextFlowTextLineFactory
+	 */
+	public class StringTextLineFactory extends TextLineFactoryBase implements IStringTextLineFactory
+	{
+		private var _tf:TextFlow;
+		private var _para:ParagraphElement;
+		private var _span:SpanElement;
+		private var _formatsChanged:Boolean;
+
+		static private var _defaultConfiguration:IConfiguration = null;
+		
+		private var _configuration:IConfiguration;
+		
+		/** 
+		 * The configuration used by the internal TextFlow object.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get configuration():IConfiguration
+		{
+			return _configuration; 
+		}
+		
+		/** 
+		 * The default configuration used by this factory if none is specified. 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		static public function get defaultConfiguration():IConfiguration
+		{
+			if (!_defaultConfiguration)
+			{
+				_defaultConfiguration = Configuration.defaultConfiguration.clone();
+				_defaultConfiguration.flowComposerClass = FactoryUtil.getDefaultFlowComposerClass();
+				_defaultConfiguration.textFlowInitialFormat = null;
+			}
+			return _defaultConfiguration;
+		}
+		
+		/** 
+		 * Creates a StringTextLineFactory object.  
+		 * 
+		 * @param configuration The configuration object used to set the properties of the 
+		 * internal TextFlow object used to compose lines produced by this factory. 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function StringTextLineFactory(configuration:IConfiguration = null)
+		{
+			super();
+			initialize(configuration);
+		}
+		
+		private function initialize(config:IConfiguration):void
+		{	
+			_configuration = config ? config.getImmutableClone() : defaultConfiguration.getImmutableClone();
+			_tf = new TextFlow(TLFFactory.defaultTLFFactory, _configuration);
+			_para = new ParagraphElement();
+			_span = new SpanElement();
+			_para.replaceChildren(0, 0, _span);
+			_tf.replaceChildren(0, 0, _para);
+			
+			_tf.flowComposer.addController(containerController);
+			_formatsChanged = true;
+		}
+		
+		/** 
+		 * The character format. 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get spanFormat():ITextLayoutFormat
+		{
+			return _span.format;
+		}
+		public function set spanFormat(format:ITextLayoutFormat):void
+		{
+			_span.format = format;
+			_formatsChanged = true;
+		}
+		/** 
+		 * The paragraph format. 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get paragraphFormat():ITextLayoutFormat
+		{
+			return _para.format;
+		}
+		public function set paragraphFormat(format:ITextLayoutFormat):void
+		{
+			_para.format = format;
+			_formatsChanged = true;
+		}
+		
+		/** 
+		 * The text flow format.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get textFlowFormat():ITextLayoutFormat
+		{
+			return _tf.format;
+		}
+		public function set textFlowFormat(format:ITextLayoutFormat):void
+		{
+			_tf.format = format;
+			_formatsChanged = true;
+		}
+		
+		/** 
+		 * The text to convert into ITextLine objects.
+		 * 
+		 * <p>To produce TextLines, call <code>createTextLines()</code> after setting this
+		 * <code>text</code> property and the desired formats.</p> 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get text():String
+		{ return _span.text; }
+		public function set text(string:String):void
+		{
+			_span.text = string;
+		}
+		
+		/** @private  Used for measuring the truncation indicator */
+		static private var _measurementFactory:StringTextLineFactory = null;
+		static private function measurementFactory():StringTextLineFactory
+		{
+			if (_measurementFactory == null)
+				_measurementFactory = new StringTextLineFactory();
+			return _measurementFactory;
+		}
+		static private var _measurementLines:Array = null;
+		static private function measurementLines():Array
+		{
+			if (_measurementLines == null)
+				_measurementLines = new Array();
+			return _measurementLines;
+		}
+		
+		/** 
+		 * Creates ITextLine objects using the text currently assigned to this factory object.
+		 * 
+		 * <p>The text lines are created using the currently assigned text and formats and
+		 * are composed to fit the bounds assigned to the <code>compositionBounds</code> property.
+		 * As each line is created, the factory calls the function specified in the 
+		 * <code>callback</code> parameter. This function is passed the ITextLine object and
+		 * is responsible for displaying the line.</p>
+		 * 
+		 * <p>To create a different set of lines, change any properties desired and call
+		 * <code>createTextLines()</code> again.</p>
+		 *  
+		 * <p>Note that the scroll policies of the factory will control how many lines are generated.</p>
+		 * 
+		 * @param callback	The callback function called for each ITextLine object created.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function createTextLines(callback:Function):void
+		{
+			var saved:ISimpleCompose = TextLineFactoryBase.beginFactoryCompose();
+			try
+			{
+				createTextLinesInternal(callback);
+			}
+			finally
+			{
+				FactoryHelper.staticComposer.lines.splice(0);
+				if (_pass0Lines)
+					_pass0Lines.splice(0);
+				TextLineFactoryBase.endFactoryCompose(saved);
+			}
+		}
+		
+		/** Internal version preserves generated lines
+		 */
+		private function createTextLinesInternal(callback:Function):void
+		{
+			var measureWidth:Boolean  = !compositionBounds || isNaN(compositionBounds.width);
+			var measureHeight:Boolean = !compositionBounds || isNaN(compositionBounds.height);
+
+			CONFIG::debug { assert(_tf.flowComposer.numControllers == 1,"DisplayController bad number containers"); }
+			CONFIG::debug { assert(containerController == _tf.flowComposer.getControllerAt(0),"ContainerController mixup"); }
+			var bp:String = _tf.computedFormat.blockProgression;
+
+			containerController.setCompositionSize(compositionBounds.width, compositionBounds.height);
+			// override scroll policy if truncation options are set
+			containerController.verticalScrollPolicy = truncationOptions ? ScrollPolicy.OFF : verticalScrollPolicy;
+			containerController.horizontalScrollPolicy = truncationOptions ? ScrollPolicy.OFF : horizontalScrollPolicy;
+
+			_isTruncated = false;
+			_truncatedText = text;
+			
+			if (!_formatsChanged && ContextUtil.computeBaseSWFContext(_tf.flowComposer.swfContext) != ContextUtil.computeBaseSWFContext(swfContext))
+				_formatsChanged = true;
+
+			_tf.flowComposer.swfContext = swfContext;
+			
+			if (_formatsChanged)
+			{
+				_tf.normalize();
+				_formatsChanged = false;
+			}
+
+			_tf.flowComposer.compose();
+			
+			// Need truncation if all the following are true
+			// - truncation options exist
+			// - content doesn't fit		
+			if (truncationOptions)
+				doTruncation(bp, measureWidth, measureHeight);
+			
+			var xadjust:Number = compositionBounds.x;
+			// toptobottom sets zero to the right edge - adjust the locations
+			var controllerBounds:Rectangle = containerController.getContentBounds();
+			if (bp == BlockProgression.RL)
+				xadjust += (measureWidth ? controllerBounds.width : compositionBounds.width);
+				
+			// apply x and y adjustment to the bounds
+			controllerBounds.left += xadjust;
+			controllerBounds.right += xadjust;
+			controllerBounds.top += compositionBounds.y;
+			controllerBounds.bottom += compositionBounds.y;			
+			
+			if (_tf.backgroundManager)
+				processBackgroundColors(_tf,callback,xadjust,compositionBounds.y,containerController.compositionWidth,containerController.compositionHeight);				
+			callbackWithTextLines(callback,xadjust,compositionBounds.y);
+
+			setContentBounds(controllerBounds);
+			containerController.clearCompositionResults();
+		}
+		
+		// Need truncation if all the following are true
+		// - truncation options exist
+		// - content doesn't fit		
+		/** @private */
+		public function doTruncation(bp:String, measureWidth:Boolean, measureHeight:Boolean):void
+		{
+			var bpString:String = _tf.computedFormat.blockProgression;
+			if (!doesComposedTextFit(truncationOptions.lineCountLimit, _tf.textLength, bpString))
+			{
+				_isTruncated = true;
+				var somethingFit:Boolean = false; // were we able to fit something?
+				var originalText:String = _span.text;
+				
+				computeLastAllowedLineIndex (truncationOptions.lineCountLimit);	
+				if (_truncationLineIndex >= 0)
+				{
+					// Estimate the initial truncation position using the following steps 
+					
+					// 1. Measure the space that the truncation indicator will take
+					measureTruncationIndicator (compositionBounds, truncationOptions.truncationIndicator);
+					
+					// 2. Move target line for truncation higher by as many lines as the number of full lines taken by the truncation indicator
+					_truncationLineIndex -= (_measurementLines.length -1);
+					if (_truncationLineIndex >= 0)
+					{
+						var truncateAtCharPosition:int;
+						
+						if (_tf.computedFormat.lineBreak == LineBreak.EXPLICIT || (bpString == BlockProgression.TB ? measureWidth : measureHeight))
+						{
+							// 3., 4. Initial truncation position: end of the last allowed line 
+							var line:ITextLine = FactoryHelper.staticComposer.lines[_truncationLineIndex] as ITextLine; 
+							truncateAtCharPosition =  line.userData + line.rawTextLength;
+						}
+						else
+						{
+							// 3. Calculate allowed width (width left over from the last line of the truncation indicator)
+							var targetWidth:Number = (bpString == BlockProgression.TB ? compositionBounds.width : compositionBounds.height); 
+							if (paragraphFormat)
+							{
+								targetWidth -= (Number(paragraphFormat.paragraphSpaceAfter) + Number(paragraphFormat.paragraphSpaceBefore));
+								if (_truncationLineIndex == 0)
+									targetWidth -= paragraphFormat.textIndent;
+							}
+							
+							var allowedWidth:Number = targetWidth - (_measurementLines[_measurementLines.length-1] as ITextLine).unjustifiedTextWidth;
+							
+							// 4. Get the initial truncation position on the target line given this allowed width 
+							truncateAtCharPosition = getTruncationPosition(FactoryHelper.staticComposer.lines[_truncationLineIndex], allowedWidth);
+						}
+						
+						// Save off the original lines: used in getNextTruncationPosition
+						if (!_pass0Lines)
+							_pass0Lines = new Array();
+						_pass0Lines = FactoryHelper.staticComposer.swapLines(_pass0Lines);
+						
+						// Note that for the original lines to be valid when used, the containing text block should not be modified
+						// Cloning the paragraph ensures this 
+						_para = _para.deepCopy() as ParagraphElement; 
+						_span = _para.getChildAt(0) as SpanElement;
+						_tf.replaceChildren(0, 1, _para);
+						_tf.normalize();
+						
+						// Replace all content starting at the inital truncation position with the truncation indicator
+						_span.replaceText(truncateAtCharPosition, _span.textLength, truncationOptions.truncationIndicator);
+						
+						// The following loop executes repeatedly composing text until it fits
+						// In each iteration, an atoms's worth of characters of original content is dropped
+						do
+						{
+							_tf.flowComposer.compose();
+							
+							if (doesComposedTextFit(truncationOptions.lineCountLimit, _tf.textLength, bpString))
+							{
+								somethingFit = true;
+								break; 
+							}		
+							
+							if (truncateAtCharPosition == 0)
+								break; // no original content left to make room for truncation indicator
+							
+							// Try again by truncating at the beginning of the preceding atom
+							var newTruncateAtCharPosition:int = getNextTruncationPosition(truncateAtCharPosition);
+							_span.replaceText(newTruncateAtCharPosition, truncateAtCharPosition, null);
+							truncateAtCharPosition = newTruncateAtCharPosition;
+							
+						} while (true);
+					}
+					_measurementLines.splice(0);	// cleanup
+				}
+				
+				if (somethingFit)
+					_truncatedText = _span.text;
+				else
+				{
+					_truncatedText = "";
+					FactoryHelper.staticComposer.lines.splice(0); // return no lines
+				}
+				
+				_span.text = originalText;
+			}
+		}
+		
+		/** @private 
+		 * Gets the text that is composed in the preceding call to <code>createTextLines</code>
+		 * If no truncation is performed, a string equal to <code>text</code> is returned. 
+		 * If truncation is performed, but nothing fits, an empty string is returned.
+		 * Otherwise, a substring of <code>text</code> followed by the truncation indicator is returned. 
+		 */
+		public function get truncatedText():String
+		{ return _truncatedText; }
+		private var _truncatedText:String;
+		
+		/** 
+		 * Measures the truncation indicator using the same bounds and formats, but without truncation options
+		 * Resultant lines are added to _measurementLines
+		 */
+		private function measureTruncationIndicator (compositionBounds:Rectangle, truncationIndicator:String):void
+		{
+			var originalLines:Array = FactoryHelper.staticComposer.swapLines(measurementLines()); // ensure we don't overwrite original lines
+			var measureFactory:StringTextLineFactory = measurementFactory();
+			measureFactory.compositionBounds = compositionBounds;
+			measureFactory.text = truncationIndicator;
+			measureFactory.spanFormat = spanFormat;
+			measureFactory.paragraphFormat = paragraphFormat;
+			measureFactory.textFlowFormat = textFlowFormat;
+			measureFactory.truncationOptions = null;
+			measureFactory.createTextLinesInternal(noopfunction);
+			FactoryHelper.staticComposer.swapLines(originalLines); // restore
+		}
+		
+		static private function noopfunction(o:Object):void	// No PMD
+		{ }
+		
+
+		/** 
+		 * Gets the truncation position on a line given the allowed width 
+		 * - Must be at an atom boundary
+		 * - Must scan the line for atoms in logical order, not physical position order
+         * For example, given bi-di text AB\u05d0\u05d1CD
+		 * atoms must be scanned in this order 
+         * A, B, \u05d0
+         * \u05d2, C, D  
+		 */
+		private function getTruncationPosition (line:ITextLine, allowedWidth:Number):uint
+		{			
+			var consumedWidth:Number = 0;
+			var charPosition:int = line.userData; 						// start of line
+			
+			while (charPosition < line.userData + line.rawTextLength)	// end of line
+			{
+				var atomIndex:int = line.getAtomIndexAtCharIndex(charPosition);
+				var atomBounds:Rectangle = line.getAtomBounds(atomIndex); 
+				consumedWidth += atomBounds.width;
+				if (consumedWidth > allowedWidth)
+					break;
+					
+				charPosition = line.getAtomTextBlockEndIndex(atomIndex);
+			}
+			
+			// line.flushAtomData(); // Warning: Now does nothing
+			return charPosition;
+		}
+		
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/TCMTextFlowTextLineFactory.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/TCMTextFlowTextLineFactory.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/TCMTextFlowTextLineFactory.as
new file mode 100644
index 0000000..a8fdbf4
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/TCMTextFlowTextLineFactory.as
@@ -0,0 +1,50 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.factory
+{
+	import org.apache.flex.textLayout.compose.IFlowComposer;
+	import org.apache.flex.textLayout.compose.TCMFactoryComposer;
+	import org.apache.flex.textLayout.container.TextContainerManager;
+
+	public class TCMTextFlowTextLineFactory extends TextFlowTextLineFactory
+	{
+		private var _tcm:TextContainerManager;
+
+		public function TCMTextFlowTextLineFactory()
+		{
+			super();
+		}
+
+		/** @private */
+		public override function createFlowComposer():IFlowComposer
+		{
+			return new TCMFactoryComposer(_tcm);
+		}
+
+		public function get tcm():TextContainerManager
+		{
+			return _tcm;
+		}
+
+		public function set tcm(val:TextContainerManager):void
+		{
+			_tcm = val;
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/TLFFactory.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/TLFFactory.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/TLFFactory.as
new file mode 100644
index 0000000..98bccb3
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/TLFFactory.as
@@ -0,0 +1,10 @@
+package org.apache.flex.textLayout.factory
+{
+	public class TLFFactory
+	{
+		/**
+		 * Default ITLFFactory if one is not specified.
+		 */
+		public static var defaultTLFFactory:ITLFFactory = new StandardTLFFactory();
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/TextFlowTextLineFactory.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/TextFlowTextLineFactory.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/TextFlowTextLineFactory.as
new file mode 100644
index 0000000..de8e2a4
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/TextFlowTextLineFactory.as
@@ -0,0 +1,285 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.factory
+{
+	import org.apache.flex.core.UIBase;
+	import org.apache.flex.geom.Rectangle;
+	import org.apache.flex.text.engine.ITextLine;
+	import org.apache.flex.textLayout.compose.FloatCompositionData;
+	import org.apache.flex.textLayout.compose.IFlowComposer;
+	import org.apache.flex.textLayout.compose.ISimpleCompose;
+	import org.apache.flex.textLayout.compose.utils.FactoryHelper;
+	import org.apache.flex.textLayout.container.ScrollPolicy;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.elements.IFlowGroupElement;
+	import org.apache.flex.textLayout.elements.IFlowLeafElement;
+	import org.apache.flex.textLayout.elements.ParagraphElement;
+	import org.apache.flex.textLayout.elements.SpanElement;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.textLayout.formats.BlockProgression;
+	import org.apache.flex.textLayout.formats.Float;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+
+/**
+ * The TextFlowTextLineFactory class provides a simple way to create TextLines for displaying text from a text flow.
+ * 
+ * <p>The text lines are static and created fit in a single bounding rectangle, but can have multiple paragraphs and formats as well as
+ * inline graphics. To create ITextLine objects directly from a string, use StringTextLineFactory.</p> 
+ *
+ * <p><b>Note:</b> When using inline graphics, the <code>source</code> property of the InlineGraphicElement object 
+ * must either be an instance of a DisplayObject or a Class object representing an embedded asset. 
+ * URLRequest objects cannot be used. The width and height of the inline graphic at the time the line 
+ * is created is used to compose the flow. </p>
+ * 
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @langversion 3.0
+ *
+ * @see org.apache.flex.textLayout.elements.TextFlow TextFlow
+ * @see org.apache.flex.textLayout.factory.StringTextLineFactory StringTextLineFactory
+*/
+	public class TextFlowTextLineFactory extends TextLineFactoryBase
+	{
+		/** 
+		 * Creates a TextFlowTextLineFactory object. 
+		 * 
+ 		 * @playerversion Flash 10
+ 		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+ 		 */
+		public function TextFlowTextLineFactory()
+		{
+			super();
+		}
+
+		/**
+		 * Creates ITextLine objects from the specified text flow.
+		 * 
+		 * <p>The text lines are composed to fit the bounds assigned to the <code>compositionBounds</code> property.
+		 * As each line is created, the factory calls the function specified in the 
+		 * <code>callback</code> parameter. This function is passed the ITextLine object and
+		 * is responsible for displaying the line. If a line has a background color, the factory also calls the
+		 * callback function with a Shape object containing a rectangle of the background color.</p>
+		 * 
+		 * <p>Note that the scroll policies of the factory will control how many lines are generated.</p>
+		 * 
+		 * @param callback function to call with each generated ITextLine object.  
+		 * The callback will be called with a Shape object representing any background color (if present), 
+		 * and with ITextLine objects for the text.
+		 * @param textFlow The TextFlow from which the lines are created.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 */	
+		public function createTextLines(callback:Function,textFlow:ITextFlow):void
+		{
+			var saved:ISimpleCompose = TextLineFactoryBase.beginFactoryCompose();
+			try
+			{
+				createTextLinesInternal(callback,textFlow);
+			}
+			finally
+			{
+				textFlow.changeFlowComposer(null,false);
+				FactoryHelper.staticComposer.lines.splice(0);
+				if (_pass0Lines)
+					_pass0Lines.splice(0);
+				TextLineFactoryBase.endFactoryCompose(saved);
+			}
+		}
+		private  function createTextLinesInternal(callback:Function,textFlow:ITextFlow):void
+		{
+			var measureWidth:Boolean  = isNaN(compositionBounds.width);
+			
+			var bp:String = textFlow.computedFormat.blockProgression;
+						
+			var helper:IFlowComposer = createFlowComposer();
+			
+			helper.swfContext = swfContext;
+
+			helper.addController(containerController);
+			textFlow.flowComposer = helper; 
+			textFlow.clearBackgroundManager();
+			// this assertion is for TCM.  It's valid in other cases to use the factory but Links won't work and graphics may not load properly
+			CONFIG::debug { assert(!this.hasOwnProperty("tcm") || textFlow.mustUseComposer() == false,"Factory composing in TCM when interaction needed"); }
+			
+			_isTruncated = false;
+			
+			// compose
+			containerController.setCompositionSize(compositionBounds.width, compositionBounds.height);
+			containerController.verticalScrollPolicy = truncationOptions ? ScrollPolicy.OFF : verticalScrollPolicy;
+			containerController.horizontalScrollPolicy = truncationOptions ? ScrollPolicy.OFF : horizontalScrollPolicy;
+			textFlow.normalize();
+			textFlow.applyUpdateElements(true);
+
+			helper.compose();
+		
+			// Need truncation if all the following are true
+			// - truncation options exist
+			// - content doesn't fit		
+			if (truncationOptions && !doesComposedTextFit(truncationOptions.lineCountLimit, textFlow.textLength, bp))
+			{
+				_isTruncated = true;
+				var somethingFit:Boolean = false; // were we able to fit something?
+
+				computeLastAllowedLineIndex (truncationOptions.lineCountLimit);	
+				if (_truncationLineIndex >= 0)
+				{					
+					// Create a span for the truncation indicator
+					var truncationIndicatorSpan:SpanElement = new SpanElement();
+					truncationIndicatorSpan.text = truncationOptions.truncationIndicator; 
+					truncationIndicatorSpan.id = "truncationIndicator"; // prevents merging with other spans 
+					if (truncationOptions.truncationIndicatorFormat)
+						truncationIndicatorSpan.format = truncationOptions.truncationIndicatorFormat;
+					
+					var hostFormat:ITextLayoutFormat = textFlow.hostFormat;
+					
+					// Initial truncation position: end of the last allowed line
+					var line:ITextLine = FactoryHelper.staticComposer.lines[_truncationLineIndex] as ITextLine; 
+					var truncateAtCharPosition:int =  line.userData + line.rawTextLength;
+					
+					// Save off the original lines: used in getNextTruncationPosition
+					// Note that for the original lines to be valid when used, the containing text block should not be modified
+					// Cloning the text flow before modifying it ensures that
+					if (!_pass0Lines)
+						_pass0Lines = new Array();
+					_pass0Lines = FactoryHelper.staticComposer.swapLines(_pass0Lines); 
+
+					// The following loop executes repeatedly composing text until it fits
+					// In each iteration, an atoms's worth of characters of original content is dropped 
+					do
+					{
+						// Clone the part of the flow before the truncation position  
+						textFlow = textFlow.deepCopy(0, truncateAtCharPosition) as ITextFlow;
+						// TODO-2/18/2009-deepCopy does not copy hostTextLayoutFormat
+						if (hostFormat)
+							textFlow.hostFormat = hostFormat;
+						
+						// Find a parent for the truncation span
+						var parent:IFlowGroupElement;
+						var lastLeaf:IFlowLeafElement = textFlow.getLastLeaf();
+						if (lastLeaf)
+						{
+							parent = lastLeaf.parent;
+							// Set format to match the leaf if none specified 
+							if (!truncationOptions.truncationIndicatorFormat)
+								truncationIndicatorSpan.format = lastLeaf.format;
+						}
+						else
+						{
+							parent = new ParagraphElement();
+							textFlow.addChild(parent);
+						}
+					
+						// Append the truncation span (after severing it from the previous flow)
+						if (truncationIndicatorSpan.parent)
+							truncationIndicatorSpan.parent.removeChild(truncationIndicatorSpan);
+						parent.addChild(truncationIndicatorSpan);
+						
+						textFlow.flowComposer = helper;
+						textFlow.normalize();
+						
+						helper.compose();
+			
+						if (doesComposedTextFit(truncationOptions.lineCountLimit, textFlow.textLength, bp))
+						{
+							somethingFit = true;
+							break; 
+						}		
+						
+						if (truncateAtCharPosition == 0)
+							break; // no original content left to make room for truncation indicator
+						
+						// Try again by truncating at the beginning of the preceding atom
+						truncateAtCharPosition = getNextTruncationPosition(truncateAtCharPosition, true);
+
+					} while (true);
+				}
+				
+				if (_truncatedTextFlowCallback != null)
+					_truncatedTextFlowCallback (somethingFit ? textFlow : null);
+					
+				if (!somethingFit)
+					FactoryHelper.staticComposer.lines.splice(0); // return no lines
+			}
+			
+			var xadjust:Number = compositionBounds.x;
+			// toptobottom sets zero to the right edge - adjust the locations
+			var controllerBounds:Rectangle = containerController.getContentBounds();
+			if (bp == BlockProgression.RL)
+				xadjust += (measureWidth ? controllerBounds.width : compositionBounds.width);	
+			
+			// apply x and y adjustment to the bounds
+			controllerBounds.left += xadjust;
+			controllerBounds.right += xadjust;
+			controllerBounds.top += compositionBounds.y;
+			controllerBounds.bottom += compositionBounds.y;
+			
+			if (textFlow.backgroundManager)
+				processBackgroundColors(textFlow,callback,xadjust,compositionBounds.y,containerController.compositionWidth,containerController.compositionHeight);				
+			callbackWithTextLines(callback,xadjust,compositionBounds.y);
+
+			setContentBounds(controllerBounds);
+			containerController.clearCompositionResults();
+		}
+		
+		/** @private - documented in base class */
+		override protected function callbackWithTextLines(callback:Function,delx:Number,dely:Number):void
+		{
+			super.callbackWithTextLines(callback, delx, dely);
+			
+			// Handle floats and inlines as well
+			var numFloats:int = containerController.numFloats;
+			for (var i:int = 0; i < numFloats; ++i)
+			{
+				var floatInfo:FloatCompositionData = containerController.getFloatAt(i);
+				//TODO Figure out how to generalize this with interfaces
+				var inlineHolder:UIBase = new UIBase();	// NO PMD
+				inlineHolder.alpha = floatInfo.alpha;
+				//TODO handle transforms using beads.
+//				if (floatInfo.matrix)
+//					inlineHolder.transform.matrix = floatInfo.matrix;
+				inlineHolder.x += floatInfo.x;
+				inlineHolder.y += floatInfo.y;
+				inlineHolder.addElement(floatInfo.graphic);
+				if (floatInfo.floatType == Float.NONE)
+					floatInfo.parent.addElement(inlineHolder);
+				else 
+				{
+					inlineHolder.x += delx;
+					inlineHolder.y += dely;
+					callback(inlineHolder);
+				}
+			}
+		}
+		
+		/** @private 
+		 * Test hook: Sets a callback function for getting the truncated text flow.
+		 * This function is only called if truncation is performed. It takes a single parameter which will have the following value:
+		 * null, if nothing fits
+		 * A text flow representing the truncated text (containing inital text from the original text flow followed by the truncation indicator), otherwise 
+		 */
+		public function set truncatedTextFlowCallback(val:Function):void
+		{ _truncatedTextFlowCallback = val; }
+		
+		private var _truncatedTextFlowCallback:Function;
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/TextLineFactoryBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/TextLineFactoryBase.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/TextLineFactoryBase.as
new file mode 100644
index 0000000..cccf0b6
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/TextLineFactoryBase.as
@@ -0,0 +1,437 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.factory
+{
+	import org.apache.flex.textLayout.compose.ISimpleCompose;
+	import org.apache.flex.textLayout.compose.utils.FactoryHelper;
+	import org.apache.flex.core.IParentIUIBase;
+	import org.apache.flex.core.UIBase;
+	import org.apache.flex.geom.Rectangle;
+	import org.apache.flex.graphics.IGraphicShape;
+	import org.apache.flex.svg.GraphicShape;
+	import org.apache.flex.text.engine.ITextBlock;
+	import org.apache.flex.text.engine.ITextLine;
+	import org.apache.flex.textLayout.compose.IFactoryComposer;
+	import org.apache.flex.textLayout.compose.IFlowComposer;
+	import org.apache.flex.textLayout.compose.ISWFContext;
+	import org.apache.flex.textLayout.compose.SimpleCompose;
+	import org.apache.flex.textLayout.container.ContainerUtil;
+	import org.apache.flex.textLayout.container.IContainerController;
+	import org.apache.flex.textLayout.container.ScrollPolicy;
+	import org.apache.flex.textLayout.debug.Debugging;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+
+	
+
+
+	[Exclude(name="containerController",kind="property")]	
+	[Exclude(name="setContentBounds",kind="method")]
+	[Exclude(name="callbackWithTextLines",kind="method")]
+	[Exclude(name="doesComposedTextFit",kind="method")]
+	[Exclude(name="getNextTruncationPosition",kind="method")]
+
+
+/**
+ * The TextLineFactoryBase class serves as the base class for the Text Layout Framework text line factories.
+ * 
+ * <p><b>Note:</b> Application code does not typically need to create or use a TextLineFactoryBase object directly.
+ * Use one of the derived text factory classes instead.</p>
+ *  
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @langversion 3.0
+ *
+ * @see org.apache.flex.textLayout.elements.TextFlow
+*/
+	public class TextLineFactoryBase implements ITextLineFactory
+	{
+		/** Requested logical bounds to wrap to */
+		private var _compositionBounds:Rectangle;
+
+		/** Bounds of composition results - where the text landed */
+		private var _contentBounds:Rectangle;
+		
+		/** @private */
+		protected var _isTruncated:Boolean = false;
+		
+		private var _horizontalScrollPolicy:String;
+		private var _verticalScrollPolicy:String;
+		private var _truncationOptions:TruncationOptions;
+		private var _containerController:IContainerController;
+
+//TODO figure out what this should be
+		static private var _tc:IParentIUIBase = new UIBase();
+		
+		private var _swfContext:ISWFContext;
+		
+		/** @private */
+		static private      var _savedFactoryComposer:ISimpleCompose;
+
+		/** @private */		
+		protected var _truncationLineIndex:int; 	// used during truncation
+		/** @private */		
+		protected var _pass0Lines:Array; 		// used during truncation
+		
+		/** @private return the next factory composer that will be used */
+		static public function peekFactoryCompose():ISimpleCompose
+		{
+			if (_savedFactoryComposer == null)
+				_savedFactoryComposer = new SimpleCompose();
+			return _savedFactoryComposer;
+		}
+		
+		/** @private support recursive calls into the factory */
+		static public function beginFactoryCompose():ISimpleCompose
+		{
+			var rslt:ISimpleCompose = FactoryHelper.staticComposer;
+			FactoryHelper.staticComposer = peekFactoryCompose();
+			_savedFactoryComposer = null;
+			return rslt;
+		}
+		
+		/** @private support recursive calls into the factory */
+		static public function endFactoryCompose(prevComposer:ISimpleCompose):void
+		{
+			_savedFactoryComposer = FactoryHelper.staticComposer;
+			FactoryHelper.staticComposer = prevComposer;
+		}
+		
+		/** 
+		 * Base-class constructor for text line factories.
+		 *  
+ 		 * <p><b>Note:</b> Application code does not typically need to create or use a TextLineFactoryBase object directly.
+		 * Use one of the derived text factory classes instead.</p>
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function TextLineFactoryBase()
+		{
+			_containerController = ContainerUtil.getController(_tc);
+			_horizontalScrollPolicy = _verticalScrollPolicy = String(ScrollPolicy.scrollPolicyPropertyDefinition.defaultValue);
+		}
+		
+		/**
+		 * The rectangle within which text lines are created.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get compositionBounds():Rectangle
+		{
+			return _compositionBounds;
+		}
+		
+		public function set compositionBounds(value:Rectangle):void
+		{
+			_compositionBounds = value;
+		}
+		
+		/**
+		 * The smallest rectangle in which the layed-out content fits.
+		 * 
+		 * <p><b>Note:</b> Truncated lines are not included in the size calculation.</p>
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function getContentBounds():Rectangle
+		{
+			return _contentBounds;
+		}
+		
+		/** @private */
+		protected function setContentBounds(controllerBounds:Rectangle):void
+		{
+			_contentBounds = controllerBounds;
+			_contentBounds.offset(compositionBounds.left, compositionBounds.top);
+		}
+		
+		/** 
+		* The ISWFContext instance used to make FTE calls as needed. 
+		*
+		* <p>By default, the ISWFContext implementation is this FlowComposerBase object.
+		* Applications can provide a custom implementation to use fonts
+		* embedded in a different SWF file or to cache and reuse text lines.</p>
+		* 
+		* @see org.apache.flex.textLayout.compose.ISWFContext
+		* 
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0
+	 	*/
+ 	
+		public function get swfContext():ISWFContext
+		{
+			return _swfContext;
+		}
+		public function set swfContext(value:ISWFContext):void
+		{
+			_swfContext = value;
+		}
+		
+		/** 
+		 * Specifies the options for truncating the text if it doesn't fit in the composition bounds.
+		 *  
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get truncationOptions():TruncationOptions
+		{
+			return _truncationOptions;
+		}
+		public function set truncationOptions(value:TruncationOptions):void
+		{
+			_truncationOptions = value;
+		}
+		
+		/** 
+		 * Indicates whether text was truncated when lines were last created.
+		 *  
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get isTruncated():Boolean
+		{
+			return _isTruncated;
+		}
+
+		/** 
+		 * Specifies how lines are created when the composition bounds are not large enough.
+		 *  
+		 * <p>If set to <code>ScrollPolicy.ON</code> or <code>ScrollPolicy.AUTO</code>, all lines
+		 * are created. It is the your responsibility to scroll lines in the viewable area (and to
+		 * mask lines outside this area, if necessary). If set to <code>ScrollPolicy.OFF</code>, then 
+		 * only lines that fit within the composition bounds are created.</p>
+		 * 
+		 * <p>If the <code>truncationOptions</code> property is set, the scroll policy is ignored 
+		 * (and treated as <code>ScrollPolicy.OFF</code>).</p> 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 * @see org.apache.flex.textLayout.compose.StandardFlowComposer
+		 * @see org.apache.flex.textLayout.container.ScrollPolicy
+		 * @see #truncationOptions
+	 	 */
+	 	 
+	 	public function get horizontalScrollPolicy():String
+		{
+			return _horizontalScrollPolicy;
+		}
+		public function set horizontalScrollPolicy(scrollPolicy:String):void
+		{
+			_horizontalScrollPolicy =  scrollPolicy;
+		}
+		
+		/** 
+		 * Specifies how lines are created when the composition bounds are not large enough.
+		 *  
+		 * <p>If set to <code>ScrollPolicy.ON</code> or <code>ScrollPolicy.AUTO</code>, all lines
+		 * are created. It is the your responsibility to scroll lines in the viewable area (and to
+		 * mask lines outside this area, if necessary). If set to <code>ScrollPolicy.OFF</code>, then 
+		 * only lines that fit within the composition bounds are created.</p>
+		 * 
+		 * <p>If the <code>truncationOptions</code> property is set, the scroll policy is ignored 
+		 * (and treated as <code>ScrollPolicy.OFF</code>).</p> 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 * @see org.apache.flex.textLayout.compose.StandardFlowComposer
+		 * @see org.apache.flex.textLayout.container.ScrollPolicy
+		 * @see #truncationOptions
+	 	 */
+	 	 
+		public function get verticalScrollPolicy():String
+		{
+			return _verticalScrollPolicy;
+		}
+		public function set verticalScrollPolicy(scrollPolicy:String):void
+		{
+			_verticalScrollPolicy =  scrollPolicy;
+		}		
+				
+		/** @private */
+		protected function get containerController():IContainerController
+		{
+			return _containerController;
+		}
+		
+		/** 
+		 * Sends the created ITextLine objects to the client using the supplied callback function.
+		 * 
+		 * <p>This method sets the <code>x</code> and <code>y</code> properties of the line.</p>
+		 * 
+		 * @param callback the callback function supplied by the factory user
+		 * @param delx the horizontal offset
+		 * @param dely the vertical offset
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		protected function callbackWithTextLines(callback:Function,delx:Number,dely:Number):void
+		{
+			for each (var textLine:ITextLine in FactoryHelper.staticComposer.lines)
+			{
+				var textBlock:ITextBlock = textLine.textBlock;
+				if (textBlock)
+				{
+					CONFIG::debug { Debugging.traceFTECall(null,textBlock,"releaseLines",textBlock.firstLine, textBlock.lastLine); }	
+					textBlock.releaseLines(textBlock.firstLine,textBlock.lastLine);
+				}
+				textLine.userData = null;
+				textLine.x += delx;
+				textLine.y += dely;
+				textLine.validity = "static";
+				CONFIG::debug { Debugging.traceFTEAssign(textLine,"validity","static"); }
+				callback(textLine);
+			}
+		}
+		
+		/**
+		 * Indicates whether the composed text fits in the line count limit and includes all text
+		 *  
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */	
+		protected function doesComposedTextFit (lineCountLimit:int, textLength:uint, blockProgression:String):Boolean
+		{
+			if (lineCountLimit != TruncationOptions.NO_LINE_COUNT_LIMIT && FactoryHelper.staticComposer.lines.length > lineCountLimit)
+				return false; // Line count limit exceded
+			
+			var lines:Array = FactoryHelper.staticComposer.lines;
+		
+			if (!lines.length)
+				return textLength ? false /* something to compose, but no line could fit */ : true /* nothing to compose */; 
+				
+			// This code is only called when scrolling if OFF, so only lines that fit in bounds are generated
+			// Just check if the last line reaches the end of flow
+			var lastLine:ITextLine = lines[lines.length - 1] as ITextLine;
+			return lastLine.userData + lastLine.rawTextLength == textLength;
+		}
+		
+		/** 
+		 * Gets the next truncation position by shedding an atom's worth of characters.
+		 * 
+		 * @param truncateAtCharPosition the current truncation candidate position.
+		 * @param multiPara <code>true</code> if text has more than one paragraph.
+		 * 
+		 * @returns the next candidate truncation position.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		protected function getNextTruncationPosition(truncateAtCharPosition:int, multiPara:Boolean=false):int
+		{
+			// 1. Get the position of the last character of the preceding atom
+			truncateAtCharPosition--; // truncateAtCharPosition-1, because truncateAtCharPosition is an atom boundary
+			
+			// Note: The current set of lines may not contain the next truncation position because the truncation indicator
+			// could combine with original content to form a word that does not afford a suitable break opportunity. 
+			// The combined word would then move to the next line, which may not have been composed if the bounds were exceeded.
+			// Therefore, this function needs to use the original lines (from before truncation is attempted). 
+			CONFIG::debug 
+			{ 
+				assert(_pass0Lines != null, "getNextTruncationPosition called before saving off lines from the first pass at composition"); 
+				assert(_truncationLineIndex < _pass0Lines.length, "index out of range in getNextTruncationPosition");
+			}
+			
+			// 2. Find the new target line (i.e., the line that has the new truncation position) 
+			// If the last truncation position was at the beginning of the target line, the new position may have moved to a previous line
+			// In any case, the new truncation position lies in the vicinity of the previous target line, so a linear search suffices
+			var line:ITextLine = _pass0Lines[_truncationLineIndex] as ITextLine;
+			do
+			{
+				if (truncateAtCharPosition >= line.userData && truncateAtCharPosition < line.userData + line.rawTextLength)
+					break;
+				if (truncateAtCharPosition < line.userData)
+					line = _pass0Lines[--_truncationLineIndex] as ITextLine;
+				else
+				{
+					CONFIG::debug {	assert(false, "truncation position should decrease monotonically");	}
+				}	
+			}
+			while (true);
+
+			var paraStart:int = multiPara ?  line.userData - line.textBlockBeginIndex : 0;
+			
+			// 3. Get the line atom index at this position			
+			var atomIndex:int = line.getAtomIndexAtCharIndex(truncateAtCharPosition - paraStart);
+			
+			// 4. Get the char index for this atom index
+			var nextTruncationPosition:int = line.getAtomTextBlockBeginIndex(atomIndex) + paraStart;
+			
+			//line.flushAtomData(); // Warning: Now does nothing
+			
+			return nextTruncationPosition;
+		} 
+		/** @private */
+		public function createFlowComposer():IFlowComposer
+		{
+			return FactoryHelper.getComposer();
+		}			
+		
+		/** @private
+		 * Calculates the last line that fits in the line count limit
+		 * The result is stored in  _truncationLineIndex
+		 * 
+		 * Note: This code is only called when scrolling is OFF, so only lines that fit in bounds are generated
+		 */
+		public function computeLastAllowedLineIndex (lineCountLimit:int):void
+		{			
+			_truncationLineIndex = FactoryHelper.staticComposer.lines.length - 1;
+
+			// if line count limit is smaller, use that
+			if (lineCountLimit != TruncationOptions.NO_LINE_COUNT_LIMIT && lineCountLimit <= _truncationLineIndex)
+				_truncationLineIndex = lineCountLimit - 1;
+		}
+		
+		
+		/** @private helper to process the background colors.  default implementation creates a shape and passes it to the callback */
+		public function processBackgroundColors(textFlow:ITextFlow,callback:Function,x:Number,y:Number,constrainWidth:Number,constrainHeight:Number):*
+		{
+			CONFIG::debug { assert(textFlow.backgroundManager != null,"Bad call to processBackgroundColors"); }
+			var bgShape:IGraphicShape = new GraphicShape();
+			textFlow.backgroundManager.drawAllRects(textFlow,bgShape,constrainWidth,constrainHeight);
+			bgShape.x = x;
+			bgShape.y = y;
+			callback(bgShape);
+			textFlow.clearBackgroundManager();
+		}
+	}
+
+} // end package
+
+
+
+
+
+
+

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/TruncationOptions.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/TruncationOptions.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/TruncationOptions.as
new file mode 100644
index 0000000..5bb21cd
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/TruncationOptions.as
@@ -0,0 +1,154 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.factory
+{
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	
+	/** 
+	 * The TruncationOptions class specifies options for limiting the number of lines of text 
+	 * created by a text line factory and for indicating when lines have been left out.
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	public final class TruncationOptions
+	{
+		/** 
+		 * Creates a TruncationOptions object.
+		 * 
+		 * @param truncationIndicator the string used to indicate that text has been truncated. 
+		 * It appears at the end of the composed text. The default value is the horizontal ellipsis (U+2026).
+		 * @param lineCountLimit specifies a truncation criterion in the form of the maximum 
+		 * number of lines allowed. The default value of <code>NO_LINE_COUNT_LIMIT</code> 
+		 * indicates that there is no line count limit.
+		 * @param truncationIndicatorFormat specifies the format for the truncation indicator. 
+		 * A null format (the default value) specifies that the truncation indicator assume 
+		 * the format of content just before the truncation point. The <code>TextLineFactory</code> 
+		 * methods that take a simple string as input also ignore this parameter and implement 
+		 * the default behavior.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function TruncationOptions (truncationIndicator:String=HORIZONTAL_ELLIPSIS, lineCountLimit:int=NO_LINE_COUNT_LIMIT, truncationIndicatorFormat:ITextLayoutFormat=null)
+		{
+			this.truncationIndicator =  truncationIndicator;
+			this.truncationIndicatorFormat = truncationIndicatorFormat;
+			this.lineCountLimit = lineCountLimit;
+		}
+		
+		/** 
+		 * A string used to indicate that content could not be fully displayed
+		 * because of limits on the number of lines.
+		 * 
+		 * @return the truncation indicator
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get truncationIndicator():String
+		{
+			return _truncationIndicator ? _truncationIndicator : HORIZONTAL_ELLIPSIS;
+		}
+		/** 
+		 * Sets the truncation indicator
+		 * @param val the string used to indicate that text has been truncated
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function set truncationIndicator(val:String):void
+		{
+			_truncationIndicator = val;
+		}
+		
+		/** 
+		 * The style applied to the truncation indicator string.
+		 * @return the format truncation indicator
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get truncationIndicatorFormat():ITextLayoutFormat
+		{
+			return _truncationIndicatorFormat;
+		}
+		/** 
+		 * Sets the styles applied to the truncation indicator character
+		 * 
+		 * @param val specifies the format for the truncation indicator. A null format specifies that the truncation indicator assume the format of content
+		 * just before the truncation point. The <code>TextLineFactory</code> methods that take a simple string as input also ignore this parameter and implement the default behavior
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function set truncationIndicatorFormat(val:ITextLayoutFormat):void
+		{
+			_truncationIndicatorFormat = val;
+		}
+		
+		/** 
+		 * The maximum number of lines to create.
+		 * @return the line count limit
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get lineCountLimit():int
+		{
+			return _lineCountLimit < NO_LINE_COUNT_LIMIT ? 0 : _lineCountLimit;
+		}
+		/** 
+		 * Sets the maximum number of lines to create
+		 * @param val specifies the maximum number of lines allowed. 
+		 * A value of <code>NO_LINE_COUNT_LIMIT</code> indicates that there is no line count limit.
+		 */
+		public function set lineCountLimit(val:int):void
+		{
+			_lineCountLimit = val;
+		} 
+		
+		private var _truncationIndicator:String;
+		private var _truncationIndicatorFormat:ITextLayoutFormat;
+		private var _lineCountLimit:int;
+		
+		/**
+		 * Defines the <code>lineCountLimit</code> property value, <code>-1</code>, that represents no limit.
+		 *
+		 * @see #lineCountLimit
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public static const NO_LINE_COUNT_LIMIT:int = -1;
+
+		/**
+		 * Defines the <code>truncationIndicator</code> property value, <code>\u2026</code>, that represents a horizontal ellipsis.
+		 *
+		 * @see #truncationIndicator
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public static const HORIZONTAL_ELLIPSIS:String = "\u2026";
+	}	
+}
+
+

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/BackgroundColor.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/BackgroundColor.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/BackgroundColor.as
new file mode 100644
index 0000000..ced1ed4
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/BackgroundColor.as
@@ -0,0 +1,41 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.formats
+{
+	/**
+	 *  Defines a constant for specifying that the value of the <code>backgroundColor</code> property
+	 *  of the <code>TextLayoutFormat</code> class is "transparent".
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 * @see org.apache.flex.textLayout.formats.TextLayoutFormat#backgroundColor TextLayoutFormat.backgroundColor
+	 */
+	public final class BackgroundColor
+	{
+		/** Transparent - no background color is applied.
+		 *
+		 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		public static const TRANSPARENT:String = "transparent";
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/BaselineOffset.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/BaselineOffset.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/BaselineOffset.as
new file mode 100644
index 0000000..a8cf5c9
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/BaselineOffset.as
@@ -0,0 +1,68 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.formats
+{
+	/**
+	 *  Defines values for the <code>firstBaselineOffset</code> property
+	 *  of the <code>TextLayoutFormat</code> and <code>ContainerFormattedElement</code> classes. 
+	 *  Determines the offset from the top inset of the container
+	 *  to the baseline of the first line. Baseline offset may be specified as 
+	 *  the ascent of the line, the height of the line, or an auto generated amount.
+	 *  <p>
+	 *  <img src="../../../images/textLayout_FBO1.jpg" alt="firstBaselineOffset_1" border="0"/>
+	 *  <img src="../../../images/textLayout_FBO2.jpg" alt="firstBaselineOffset_2" border="0"/>
+	 *  <img src="../../../images/textLayout_FBO3.jpg" alt="firstBaselineOffset_3" border="0"/>
+	 *  <img src="../../../images/textLayout_FBO4.jpg" alt="firstBaselineOffset_4" border="0"/>
+	 *  </p>
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 *  @see TextLayoutFormat#firstBaselineOffset
+	 */
+	public final class BaselineOffset
+	{
+		/** Aligns the ascent of the line with the container top inset.
+		 *
+		 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		public static const AUTO:String = "auto";
+		
+		/** Specifies an offset equal to the ascent of the line, that is, the ascent of the tallest font in the line, accounting for inline graphics as having the bottom of the graphic on the baseline.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		 
+		public static const ASCENT:String = "ascent";
+		
+		/** Specifies an offset equal to the height of the line.
+		 *
+		 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		public static const LINE_HEIGHT:String = "lineHeight";		
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/BaselineShift.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/BaselineShift.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/BaselineShift.as
new file mode 100644
index 0000000..599a954
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/BaselineShift.as
@@ -0,0 +1,53 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.formats
+{
+	/**
+	 *  Defines constants for specifying subscript or superscript in the <code>baselineShift</code> property
+	 *  of the <code>TextLayoutFormat</code> class. You can specify baseline shift as an absolute pixel offset, 
+	 *  a percentage of the current point size, or the constants SUPERSCRIPT or 
+	 *  SUBSCRIPT. Positive values shift the line up for horizontal text (right for vertical) and negative values 
+	 *  shift it down for horizontal (left for vertical). 
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 *
+	 *  @see org.apache.flex.textLayout.formats.TextLayoutFormat#baselineShift TextLayoutFormat.baselineShift
+	 */
+	public final class BaselineShift
+	{
+		/** Shifts baseline to the current superscript position.
+		 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		public static const SUPERSCRIPT:String = "superscript";
+		
+		/** Shifts baseline to the current subscript position.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		 
+		public static const SUBSCRIPT:String = "subscript";		
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/BlockProgression.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/BlockProgression.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/BlockProgression.as
new file mode 100644
index 0000000..43d8877
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/BlockProgression.as
@@ -0,0 +1,58 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.formats
+{
+	/**
+	 *  Defines values for the <code>blockProgression</code> property
+	 *  of the <code>TextLayouFormat</code> class. BlockProgression specifies the direction in 
+	 *  which lines are placed in the container.
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 * 
+	 *  @see org.apache.flex.textLayout.formats.TextLayoutFormat#blockProgression TextLayoutFormat.blockProgression
+	 */
+	 
+	public final class BlockProgression
+	{
+		/** 
+		 *  Specifies right to left block progression. Lines are laid out vertically starting at the right 
+		 *  edge of the container and progressing leftward. Used for vertical text, for example, vertical 
+		 *  Chinese or Japanese text. 
+		 *
+		 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+	  	 * @langversion 3.0 
+	 	 */
+	 	 
+		public static const RL:String = "rl";
+		
+		/** 
+		 *  Specifies top to bottom block progression. Lines are laid out horizontally starting at the top of 
+		 *  the container and progressing down to the bottom. Used for horizontal text. 
+		 * 
+		 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+	  	 * @langversion 3.0 
+	  	 */
+	  	 
+		public static const TB:String = "tb";				
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/BorderColor.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/BorderColor.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/BorderColor.as
new file mode 100644
index 0000000..2992bfa
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/BorderColor.as
@@ -0,0 +1,41 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.formats
+{
+	/**
+	 *  Defines a constant for specifying that the value of the <code>borderColor</code> property
+	 *  of the <code>TextLayoutFormat</code> class is "transparent".
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 * @see org.apache.flex.textLayout.formats.TextLayoutFormat#borderColor TextLayoutFormat.borderColor
+	 */
+	public final class BorderColor
+	{
+		/** Transparent - no border color is applied.
+		 *
+		 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		public static const TRANSPARENT:String = "transparent";
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/BorderStyle.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/BorderStyle.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/BorderStyle.as
new file mode 100644
index 0000000..b1ac3c0
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/BorderStyle.as
@@ -0,0 +1,88 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.formats
+{
+	/**
+	 *  Defines a constant for specifying that the value of the <code>borderStyle</code> property
+	 *  of the <code>TextLayoutFormat</code> class.
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 * @see org.apache.flex.textLayout.formats.TextLayoutFormat#borderStyle TextLayoutFormat.borderStyle
+	 */
+	public final class BorderStyle
+	{
+		/** none - no border style is applied.
+		 *
+		 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		public static const NONE:String = "none";
+		
+		/** hidden - border is hidden.
+		 *
+		 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		public static const HIDDEN:String = "hidden";
+		
+		/** dotted - border is made up of dotted lines.
+		 *
+		 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		public static const DOTTED:String = "dotted";
+		
+		/** dashed - border is made up of dashed lines.
+		 *
+		 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		public static const DASHED:String = "dashed";
+		
+		/** solid - border is made up of solid lines.
+		 *
+		 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		public static const SOLID:String = "solid";
+		
+		/** double - border is made up of double lines.
+		 *
+		 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		public static const DOUBLE:String = "double";
+		
+		
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/BreakStyle.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/BreakStyle.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/BreakStyle.as
new file mode 100644
index 0000000..9413ead
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/BreakStyle.as
@@ -0,0 +1,47 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.formats
+{
+	/**
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 *
+	 */
+	public final class BreakStyle
+	{
+		/** 
+		 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		public static const AUTO:String = "auto";
+		
+		/** 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		 
+		public static const ALWAYS:String = "always";		
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/Category.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/Category.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/Category.as
new file mode 100644
index 0000000..f4859e5
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/Category.as
@@ -0,0 +1,42 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.formats
+{
+	// [ExcludeClass]
+	/**
+	 *  Property categories
+	 * @private
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	public final class Category
+	{
+		public static const PARAGRAPH:String = "Paragraph";
+		public static const CONTAINER:String = "Container";
+		public static const CHARACTER:String = "Character";
+		public static const LIST:String 	 = "List";
+		public static const TABSTOP:String   = "TabStop";
+		public static const STYLE:String     = "Style";
+		public static const TABLE:String     = "Table";
+		public static const TABLECELL:String     = "TableCell";
+		public static const TABLEROW:String     = "TableRow";
+		public static const TABLECOLUMN:String     = "TableColumn";
+	}
+}


[38/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/ITextFlowLine.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/ITextFlowLine.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/ITextFlowLine.as
new file mode 100644
index 0000000..6fe88e8
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/ITextFlowLine.as
@@ -0,0 +1,104 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.compose
+{
+	import org.apache.flex.core.IParentIUIBase;
+	import org.apache.flex.geom.Rectangle;
+	import org.apache.flex.graphics.ICompoundGraphic;
+	import org.apache.flex.text.engine.ITextBlock;
+	import org.apache.flex.text.engine.ITextLine;
+	import org.apache.flex.textLayout.container.IContainerController;
+	import org.apache.flex.textLayout.edit.SelectionFormat;
+	import org.apache.flex.textLayout.elements.IFlowLeafElement;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	
+	public interface ITextFlowLine extends IVerticalJustificationLine
+	{
+		function get composable():Boolean;
+		function initialize(paragraph:IParagraphElement, outerTargetWidth:Number = 0, lineOffset:Number = 0, absoluteStart:int = 0, numChars:int = 0, textLine:ITextLine = null):void;
+		function get heightTW():int;
+		function get outerTargetWidthTW():int;
+		function get ascentTW():int;
+		function get targetWidthTW():int;
+		function get textHeightTW():int;
+		function get lineOffsetTW():int;
+		function get lineExtentTW():int;
+		function get hasGraphicElement():Boolean;
+		function get hasNumberLine():Boolean;
+		function get numberLinePosition():Number;
+		function set numberLinePosition(position:Number):void;
+		function get textHeight():Number ;
+		function get xTW():int;
+		function get yTW():int;
+		function setXYAndHeight(lineX:Number,lineY:Number,lineHeight:Number):void;
+		function get location():int;
+		function get controller():IContainerController;
+		function get columnIndex():int;
+		function setController(cont:IContainerController,colNumber:int):void;
+		function get lineOffset():Number;
+		function get paragraph():IParagraphElement;
+		function get absoluteStart():int;
+		function setAbsoluteStart(val:int):void;
+		function get textLength():int;
+		function setTextLength(val:int):void;
+		function get spaceBefore():Number;
+		function get spaceAfter():Number;
+		function get outerTargetWidth():Number;
+		function set outerTargetWidth(val:Number):void;
+		function get targetWidth():Number;
+		function getBounds():Rectangle;
+		function get validity():String;
+		function get unjustifiedTextWidth():Number;
+		function get lineExtent():Number;
+		function set lineExtent(value:Number):void;
+		function get accumulatedLineExtent():Number;
+		function set accumulatedLineExtent(value:Number):void;
+		function get accumulatedMinimumStart():Number;
+		function set accumulatedMinimumStart(value:Number):void;
+		function get alignment():String;
+		function set alignment(value:String):void;
+		function isDamaged():Boolean;
+		function clearDamage():void;
+		function damage(damageType:String):void;
+		function testLineVisible(wmode:String, x:int, y:int, w:int, h:int):int;
+		function oldTestLineVisible(wmode:String, x:int, y:int, w:int, h:int):Boolean;
+		function cacheLineBounds(wmode:String, bndsx:Number, bndsy:Number, bndsw:Number, bndsh:Number):void;
+		function hasLineBounds():Boolean;
+		function get textLineExists():Boolean;
+		function peekTextLine():ITextLine;
+		function getTextLine(forceValid:Boolean = false):ITextLine;
+		function recreateTextLine(textBlock:ITextBlock, previousLine:ITextLine):ITextLine;
+		function createShape(bp:String, textLine:ITextLine):void;
+		function createAdornments(blockProgression:String,elem:IFlowLeafElement,elemStart:int, textLine:ITextLine, numberLine:ITextLine):void;
+		function getLineLeading(bp:String,elem:IFlowLeafElement,elemStart:int):Number;
+		function getLineTypographicAscent(elem:IFlowLeafElement,elemStart:int,textLine:ITextLine):Number;
+		function getCSSLineBox(bp:String, elem:IFlowLeafElement, elemStart:int, swfContext:ISWFContext, effectiveListMarkerFormat:ITextLayoutFormat=null, numberLine:ITextLine=null):Rectangle;
+		function calculateSelectionBounds(textLine:ITextLine, rectArray:Array, begIdx:int, endIdx:int, blockProgression:String, heightAndAdj:Array):void;
+		function getRomanSelectionHeightAndVerticalAdjustment (prevLine:ITextFlowLine, nextLine:ITextFlowLine):Array;
+		function convertLineRectToContainer(rect:Rectangle, constrainShape:Boolean):void;
+		function hiliteBlockSelection(selObj:ICompoundGraphic, selFormat:SelectionFormat, container:IParentIUIBase, begIdx:int,endIdx:int, prevLine:ITextFlowLine, nextLine:ITextFlowLine):void;
+		function hilitePointSelection(selFormat:SelectionFormat, idx:int, container:IParentIUIBase, prevLine:ITextFlowLine, nextLine:ITextFlowLine):void;
+		function computePointSelectionRectangle(idx:int, container:IParentIUIBase, prevLine:ITextFlowLine, nextLine:ITextFlowLine, constrainSelRect:Boolean):Rectangle;
+		function selectionWillIntersectScrollRect(scrollRect:Rectangle, begIdx:int, endIdx:int, prevLine:ITextFlowLine, nextLine:ITextFlowLine):int;
+
+		function get adornCount():int ;
+
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/ITextFlowTableBlock.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/ITextFlowTableBlock.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/ITextFlowTableBlock.as
new file mode 100644
index 0000000..6ad273a
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/ITextFlowTableBlock.as
@@ -0,0 +1,46 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.compose
+{
+	import org.apache.flex.textLayout.elements.CellCoordinates;
+	import org.apache.flex.textLayout.elements.ITableElement;
+	import org.apache.flex.textLayout.elements.TableBlockContainer;
+	import org.apache.flex.textLayout.elements.CellContainer;
+	import org.apache.flex.textLayout.elements.ITableCellElement;
+	import org.apache.flex.textLayout.elements.TableCellElement;
+
+	public interface ITextFlowTableBlock extends ITextFlowLine
+	{
+		function clear():void;
+
+		function getTableCells():Vector.<ITableCellElement>;
+
+		function addCell(container:CellContainer):void;
+
+		function get container():TableBlockContainer
+
+		function get parentTable():ITableElement;
+
+		function updateCompositionShapes():void;
+
+		function set parentTable(parentTable:ITableElement):void;
+
+		function getCellsInRange(startCoords:CellCoordinates, endCoords:CellCoordinates):Vector.<ITableCellElement>;
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/IVerticalJustificationLine.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/IVerticalJustificationLine.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/IVerticalJustificationLine.as
new file mode 100644
index 0000000..ee6a315
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/IVerticalJustificationLine.as
@@ -0,0 +1,95 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.compose {
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.text.engine.ITextLine;
+	
+	/** 
+	 * The IVerticalJustificationLine interface defines the methods and properties required to allow
+	 * the vertical justification of text lines.
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+ 	 * @langversion 3.0
+	 */
+	public interface IVerticalJustificationLine
+	{
+		/** 
+		 * The horizontal position of the line relative to its container, expressed as the offset in pixels from the 
+		 * left of the container.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 *
+	 	 * @see #y
+		 */
+		function get x():Number;
+		
+		/** Set X location for the line.  Used only during vertical justification. @private */
+		function set x(val:Number):void;
+		
+		/** 
+		 * The vertical position of the line relative to its container, expressed as the offset in pixels from the top 
+		 * of the container.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 * 
+	 	 * @see #x
+		 */
+		function get y():Number;
+		
+		/** Set Y location for the line.  Used only during vertical justification. @private */
+		function set y(val:Number):void;
+		
+		/** 
+		 * @copy org.apache.flex.text.engine.TextLine#ascent
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+		 */
+		function get ascent():Number;
+		
+		/** 
+		 * @copy org.apache.flex.text.engine.TextLine#descent
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+		 */
+		function get descent():Number;
+		
+		/** The height of the line in pixels.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 *
+		 */
+		function get height():Number;
+		
+
+		// TODO for TextFlowTableBloack
+		function set height(value:Number):void;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/Parcel.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/Parcel.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/Parcel.as
new file mode 100644
index 0000000..51fb80d
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/Parcel.as
@@ -0,0 +1,376 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.compose
+{
+	import org.apache.flex.text.engine.Constants;
+		
+	import org.apache.flex.textLayout.container.IContainerController;
+//	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.formats.ClearFloats;
+	import org.apache.flex.textLayout.formats.Direction;
+
+
+
+		
+	/** 
+	 * Helper class for implementations of IParcelList
+	 * 
+	 * @private
+	 */
+	public class Parcel 
+	{
+		public var x:Number;
+		public var y:Number;
+		public var width:Number;
+		public var height:Number;
+		public var logicalWidth:Number;
+
+		private var _controller:IContainerController;
+		private var _columnIndex:int;
+		private var _fitAny:Boolean;
+		private var _composeToPosition:Boolean;
+
+		private var _left:Edge;
+		private var _right:Edge;
+		private var _maxWidth:Number;
+		
+		private const EDGE_CACHE_MAX:int = 6;		// number of edges we cache
+		static private var edgeCache:Vector.<Edge>; // cache to prevent edge allocation/deallocation
+		
+		private var _verticalText:Boolean;
+		
+		/** Constructor. */
+		public function Parcel(verticalText:Boolean, x:Number, y:Number, width:Number, height:Number, controller:IContainerController, columnIndex:int)
+		{
+			initialize(verticalText, x, y, width, height, controller, columnIndex);
+		}
+		
+		public function initialize(verticalText:Boolean, x:Number, y:Number, width:Number, height:Number, controller:IContainerController, columnIndex:int):Parcel
+		{
+			this.x = x;
+			this.y = y;
+			this.width = width;
+			this.height = height;
+			this.logicalWidth = verticalText ? height : width;
+			this._verticalText = verticalText; 
+			
+			_controller   = controller;
+			_columnIndex  =  columnIndex;
+			_fitAny	  = false;
+			_composeToPosition = false;
+			
+			var xmin:Number;
+			if (verticalText)
+			{
+				xmin = y;
+				_maxWidth = height;
+			}
+			else
+			{
+				xmin = x;
+				_maxWidth = width;
+			}
+
+			_left = allocateEdge(xmin);
+			_right = allocateEdge(xmin + _maxWidth);		
+			return this;
+		}
+		
+		
+		/** prevent any leaks. @private */
+		public function releaseAnyReferences():void
+		{
+			_controller = null;
+			deallocateEdge(_left);
+			deallocateEdge(_right);
+		}
+		
+		private function allocateEdge(x:Number):Edge
+		{
+			if (!edgeCache)
+			 edgeCache = new Vector.<Edge>();
+			var edge:Edge = (edgeCache.length > 0) ? edgeCache.pop() : new Edge();
+			edge.initialize(x);
+			return edge;
+		}
+		
+		private function deallocateEdge(edge:Edge):void
+		{
+			if (edgeCache.length < EDGE_CACHE_MAX)
+				edgeCache.push(edge);
+		}
+		
+		public function get bottom():Number	{ return (y + height); }
+		public function get right():Number	{ return (x + width); }
+		
+		public function get controller():IContainerController
+		{ return _controller; }
+
+		/** column number in the container */
+		public function get columnIndex():int
+		{ return _columnIndex; }
+		public function get fitAny():Boolean
+		{ return _fitAny; }
+		public function set fitAny(value:Boolean):void
+		{ _fitAny = value; }
+		public function get composeToPosition():Boolean
+		{ return _composeToPosition; }
+		public function set composeToPosition(value:Boolean):void
+		{ _composeToPosition = value; }
+		/** Do explicit line breaking (no wrapping) */
+
+		private function getLogicalHeight():Number
+		{
+			if (_verticalText)
+			{
+				return _controller.measureWidth ? Constants.MAX_LINE_WIDTH : width;
+			}
+			else
+			{
+				return _controller.measureHeight ? Constants.MAX_LINE_WIDTH : height;
+			}
+		}
+		
+		// Returns the amount to move down to apply clear past any floats
+		public function applyClear(clear:String, depth:Number, direction:String):Number
+		{
+			var leftMargin:Number;
+			var rightMargin:Number;
+			var adjustedDepth:Number = depth;
+			
+			if (clear == ClearFloats.START)
+				clear = (direction == Direction.LTR) ? ClearFloats.LEFT : ClearFloats.RIGHT;
+			else if (clear == ClearFloats.END)
+				clear = (direction == Direction.RTL) ? ClearFloats.LEFT : ClearFloats.RIGHT;
+
+			while (adjustedDepth < Number.MAX_VALUE)
+			{
+				leftMargin = _left.getMaxForSpan(adjustedDepth, adjustedDepth + 1);	// getLeftForSpan
+				if (leftMargin > 0 && (clear == ClearFloats.BOTH || clear == ClearFloats.LEFT))
+				{
+					adjustedDepth = _left.findNextTransition(adjustedDepth);
+					continue;
+				}
+				rightMargin = _right.getMaxForSpan(adjustedDepth, adjustedDepth + 1);	// getRightForSpan
+				if (rightMargin > 0 && (clear == ClearFloats.BOTH || clear == ClearFloats.RIGHT))
+				{
+					adjustedDepth = _right.findNextTransition(adjustedDepth);
+					continue;
+				}
+				
+				return adjustedDepth - depth;
+			} 
+			
+			return (_verticalText ? this.width : this.height);	
+		}
+		
+		public function fitsInHeight(depth:Number, minimumHeight:Number):Boolean
+		{
+			return composeToPosition || depth + minimumHeight <= getLogicalHeight();
+		}
+		
+		// Given a current location, what is the longest longest line of a given height that can be placed there,
+		// that is at least as wide as the minimum width. Return false if there is no possible line in the parcel.
+		// May shift the line down if thee is more space below.
+		public function getLineSlug(slug:Slug, depth:Number, lineHeight:Number, minimumWidth:Number, minimumHeight:Number, leftMargin:Number, rightMargin:Number, textIndent:Number, directionLTR:Boolean, useExplicitLineBreaks:Boolean):Boolean
+		{
+			if (!fitsInHeight(depth, minimumHeight))
+				return false;
+			
+			slug.height = lineHeight;			
+
+			while (depth < Number.MAX_VALUE)
+			{
+				slug.depth = depth;
+
+				slug.leftMargin = _left.getMaxForSpan(slug.depth, slug.depth + lineHeight);	// getLeftForSpan
+				slug.wrapsKnockOut = slug.leftMargin != 0;
+				if (leftMargin > 0)
+					slug.leftMargin = Math.max(leftMargin, slug.leftMargin);
+				else
+					slug.leftMargin += leftMargin;		// negative indent, let it overlap
+				slug.rightMargin = _right.getMaxForSpan(slug.depth, slug.depth + lineHeight);	// getRightForSpan
+				slug.wrapsKnockOut = slug.wrapsKnockOut || (slug.rightMargin != 0);
+				if (rightMargin > 0)
+					slug.rightMargin = Math.max(rightMargin, slug.rightMargin);
+				else
+					slug.rightMargin += rightMargin;		// negative indent, let it overlap
+				if (textIndent)
+				{
+					if (directionLTR)
+						slug.leftMargin += textIndent;
+					else
+						slug.rightMargin += textIndent;
+				}
+
+				if (useExplicitLineBreaks || (_verticalText && _controller.measureHeight) || (!_verticalText && _controller.measureWidth))
+					slug.width = Constants.MAX_LINE_WIDTH;
+				else
+					slug.width = this.logicalWidth - (slug.leftMargin + slug.rightMargin);
+				if (!minimumWidth || slug.width >= minimumWidth)
+					break;
+				depth = findNextTransition(depth);
+			} 
+			
+			return (depth < Number.MAX_VALUE);
+		}
+
+		public function knockOut(knockOutWidth:Number, yMin:Number, yMax:Number, onLeft:Boolean):void
+		{
+			var edge:Edge = onLeft ? _left : _right;
+			edge.addSpan(knockOutWidth, yMin, yMax);	
+		}
+		
+		public function removeKnockOut(knockOutWidth:Number, yMin:Number, yMax:Number, onLeft:Boolean):void
+		{
+			var edge:Edge = onLeft ? _left : _right;
+			edge.removeSpan(knockOutWidth, yMin, yMax);	
+		}
+		
+		/** Returns true if the parcel has no knockouts */
+		public function isRectangular():Boolean
+		{
+			return (_left.numSpans <= 0 && _right.numSpans <= 0);
+		}
+		
+	/*	public function getLeftForSpan(ymin:Number, ymax:Number):Number
+		{
+			return _left.getMaxForSpan(ymin, ymax);
+		}
+		
+		public function getRightForSpan(ymin:Number, ymax:Number):Number
+		{
+			return _right.getMinForSpan(ymin, ymax);
+		} */
+		
+		public function findNextTransition(y:Number):Number
+		{
+			return Math.min(_left.findNextTransition(y), _right.findNextTransition(y));
+		}
+		
+	}
+}
+
+class Span
+{
+	public var x:Number;
+	public var ymin:Number;
+	public var ymax:Number;
+	
+	public function Span(x:Number, ymin:Number, ymax:Number)
+	{
+		this.x = x;
+		this.ymin = ymin;
+		this.ymax = ymax;
+	}
+		
+	public function overlapsInY(ymin:Number, ymax:Number):Boolean
+	{
+		return !(ymax < this.ymin || ymin >= this.ymax);
+	}
+	
+	public function equals(x:Number, ymin:Number, ymax:Number):Boolean
+	{
+		return x == this.x && ymin == this.ymin && ymax == this.ymax;
+	} 
+}
+
+//import org.apache.flex.textLayout.utils.Twips;
+
+class Edge
+{
+	private var _xbase:Number;
+	private var _spanList:Vector.<Span>;
+	
+	public function Edge()
+	{
+		_spanList = new Vector.<Span>();
+	}
+	
+	public function initialize(xbase:Number):void
+	{
+		_xbase = xbase;
+		_spanList.length = 0;
+	}
+	
+	public function get base():Number
+	{
+		return _xbase;
+	}
+	
+	public function addSpan(x:Number, ymin:Number, ymax:Number):void
+	{
+		_spanList.push(new Span(x, ymin, ymax));
+	}
+	
+	public function removeSpan(x:Number, ymin:Number, ymax:Number):void
+	{
+		for (var i:int=0; i < _spanList.length; ++i)
+		{
+			if (_spanList[i].equals(x, ymin, ymax))
+			{
+				_spanList.splice(i,1);
+				return;
+			}
+		}
+
+//		CONFIG::debug { org.apache.flex.textLayout.debug.assert(false, "Deleting a span not in list"); }			
+	} 
+	
+	public function get numSpans():int
+	{
+		return _spanList.length;
+	}
+	
+	public function getMaxForSpan(ymin:Number, ymax:Number):Number
+	{
+		var res:Number = 0;
+		for each (var span:Span in _spanList)
+		{
+			if (span.x > res && span.overlapsInY(ymin, ymax))
+				res = span.x;
+		}
+		return res;
+	}
+	
+	/*public function getMinForSpan(ymin:Number, ymax:Number):Number
+	{
+		var res:Number = _xbase;
+		for each (var span:Span in _spanList)
+		{
+			if (span.x < res && span.overlapsInY(ymin, ymax))
+				res = span.x;
+		}
+		return res;
+	} */
+	
+	public function findNextTransition(y:Number):Number
+	{
+		var res:Number = Number.MAX_VALUE;
+		for each (var s:Span in _spanList)
+		{
+			if (s.ymin > y && s.ymin < res)
+				res = s.ymin;
+			if (s.ymax > y && s.ymax < res)
+				res = s.ymax;
+		}
+		return res;
+	}
+}
+

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/ParcelList.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/ParcelList.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/ParcelList.as
new file mode 100644
index 0000000..9f2cfbb
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/ParcelList.as
@@ -0,0 +1,438 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.compose
+{
+	import org.apache.flex.text.engine.Constants;
+	import org.apache.flex.geom.Rectangle;
+	
+	import org.apache.flex.textLayout.container.ColumnState;
+	import org.apache.flex.textLayout.container.IContainerController;
+	import org.apache.flex.textLayout.container.ScrollPolicy;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.elements.TableCellElement;
+	import org.apache.flex.textLayout.formats.BlockProgression;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.formats.LineBreak;
+
+	
+
+			
+	/** @private
+	 * Used for composing text containers, keeps track of the areas that text in the 
+	 * flow is composed into.
+	 * 
+	 * ParcelList will always have one parcel, which corresponds to the container's
+	 * bounding box. 
+	 */
+	public class ParcelList
+	{
+		protected var _flowComposer:IFlowComposer;
+		
+		/** Current vertical position in the parcel. */
+		protected var _totalDepth:Number;
+		
+		/** whether the current parcel has any content */
+		protected var _hasContent:Boolean;
+		
+		/** The list of parcels that are available for text layout.
+			They are appear in the array in reading order: the first text goes in the
+			first parcel, when it gets filled later text is flowed into the second 
+			parcel, and so on.  */
+		protected var _parcelArray:Array;	/* of Parcel */
+		protected var _numParcels:int;
+		protected var _singleParcel:Parcel;
+		
+		/** Index of the "current" parcel. These next two variables must be kept in sync. */
+		protected var _currentParcelIndex:int;
+		protected var _currentParcel:Parcel;
+		
+		protected var _insideListItemMargin:Number;
+		
+		protected var _leftMargin:Number;
+		protected var _rightMargin:Number; 
+		
+		protected var _explicitLineBreaks:Boolean;
+			
+		/** True if text is vertical (as for some Japanese & Chinese, false otherwise */
+		protected var _verticalText:Boolean;
+		
+//		private static const MAX_HEIGHT:Number = 900000000;		// vertical scroll max - capped to prevent loss of precision - what should it be?
+//		private static const MAX_WIDTH:Number =  900000000;		// horizontal scroll max - capped to prevent loss of precision - what should it be?
+			
+		// a single parcellist that is checked out and checked in
+		static private var _sharedParcelList:ParcelList;
+
+		/** @private */
+		static public function getParcelList():ParcelList
+		{
+			var rslt:ParcelList = _sharedParcelList ? _sharedParcelList : new ParcelList();
+			_sharedParcelList = null;
+			return rslt;
+		}
+		
+		/** @private */
+		static public function releaseParcelList(list:ParcelList):void
+		{
+			if (_sharedParcelList == null)
+			{
+				_sharedParcelList = list as ParcelList;
+				if (_sharedParcelList)
+					_sharedParcelList.releaseAnyReferences();
+			}
+		}
+
+		/** Constructor. */
+		public function ParcelList()
+		{ _numParcels = 0;	}
+		
+		/** prevent any leaks. @private */
+		public function releaseAnyReferences():void
+		{
+			this._flowComposer = null;
+			
+			_numParcels = 0;
+			_parcelArray = null;
+			
+			if (_singleParcel)
+				_singleParcel.releaseAnyReferences();
+		}
+		
+		CONFIG::debug public function getBounds():Array
+		{
+			var boundsArray:Array = [];
+			for (var i:int = 0; i < _numParcels; ++i)
+				boundsArray.push(getParcelAt(i));
+			return boundsArray;
+		}
+		
+		public function getParcelAt(idx:int):Parcel
+		{ return _numParcels <= 1 ? _singleParcel : _parcelArray[idx]; }
+				
+		public function get currentParcelIndex():int
+		{ return _currentParcelIndex; }
+		
+		public function get explicitLineBreaks():Boolean
+		{ 
+			return _explicitLineBreaks;
+		}
+		
+		private function get measureLogicalWidth():Boolean
+		{
+			if (_explicitLineBreaks)
+				return true;
+			if (!_currentParcel)
+				return false;
+			var controller:IContainerController = _currentParcel.controller;
+			return _verticalText ? controller.measureHeight : controller.measureWidth;
+		}
+
+		private function get measureLogicalHeight():Boolean
+		{
+			if (!_currentParcel)
+				return false;
+			var controller:IContainerController = _currentParcel.controller;
+			return _verticalText ? controller.measureWidth : controller.measureHeight;
+		}
+		
+		public function get totalDepth():Number
+		{
+			return _totalDepth;
+		}
+		
+		public function addTotalDepth(value:Number):Number
+		{
+			_totalDepth += value;	
+		//	trace("addTotalDepth", value, "newDepth", totalDepth);
+			return _totalDepth;
+		}
+		
+		protected function reset():void
+		{
+			// Composition starts with an initial invalid parcel. It will start by calling next(), which will 
+			// advance to the first parcel.
+			_totalDepth = 0;
+			_hasContent = false;
+
+			_currentParcelIndex = -1;
+			_currentParcel = null;
+			
+			_leftMargin = 0;
+			_rightMargin = 0;
+			_insideListItemMargin = 0;
+		}
+		
+		public function addParcel(column:Rectangle, controller:IContainerController, columnIndex:int):Parcel
+		{
+			var newParcel:Parcel = _numParcels == 0 && _singleParcel 
+				? _singleParcel.initialize(_verticalText, column.x,column.y,column.width,column.height,controller,columnIndex) 
+				: new Parcel(_verticalText, column.x, column.y, column.width, column.height, controller, columnIndex);
+			if (_numParcels == 0)
+				_singleParcel = newParcel;
+			else if (_numParcels == 1)
+				_parcelArray = [  _singleParcel, newParcel ];
+			else
+				_parcelArray.push(newParcel);
+			_numParcels++;
+			return newParcel;
+		}
+		
+		// Return numbers of parcels in this parcel list
+		public function numParcels():int
+		{
+			return this._numParcels;
+		}
+		
+		// Pop up top most parcel
+		public function popParcel():Parcel
+		{
+			_numParcels -- ;
+			return _parcelArray.pop();
+		}
+		
+		public function addTableCell2ColumnState(controller:IContainerController, cell:TableCellElement):void
+		{
+			var columnState:ColumnState = controller.columnState;
+			if (columnState)
+				columnState.pushTableCell(cell);
+		}
+		protected function addOneControllerToParcelList(controllerToInitialize:IContainerController):void
+		{
+			// Initialize new parcels for columns
+			var columnState:ColumnState = controllerToInitialize.columnState;
+			columnState.clearCellList();
+			for (var columnIndex:int = 0; columnIndex < columnState.columnCount; columnIndex++)
+			{
+				var column:Rectangle = columnState.getColumnAt(columnIndex);
+				if (!column.isEmpty())
+					addParcel(column, controllerToInitialize, columnIndex);
+			}
+		}
+		
+		public function beginCompose(composer:IFlowComposer, controllerStartIndex:int, controllerEndIndex:int, composeToPosition:Boolean):void
+		{
+			_flowComposer = composer;
+			
+			var rootFormat:ITextLayoutFormat = composer.rootElement.computedFormat;
+			_explicitLineBreaks = rootFormat.lineBreak == LineBreak.EXPLICIT;
+			_verticalText   = (rootFormat.blockProgression == BlockProgression.RL);
+			
+			if (composer.numControllers != 0)
+			{
+				// if controllerEndIndex is not specified then assume we are composing to position and add all controllers
+				if (controllerEndIndex < 0)
+					controllerEndIndex = composer.numControllers-1;
+				else
+					controllerEndIndex = Math.min(controllerEndIndex,composer.numControllers-1);
+				var idx:int = controllerStartIndex;
+				do
+				{
+					addOneControllerToParcelList(IContainerController(composer.getControllerAt(idx)));
+				} while (idx++ != controllerEndIndex);
+				// adjust the last container for scrolling
+				if (controllerEndIndex == composer.numControllers-1)
+					adjustForScroll(composer.getControllerAt(composer.numControllers-1), composeToPosition);
+			}
+			reset();
+		}
+		
+		/** Adjust the size of the parcel corresponding to the last column of the containter, in 
+		 * order to account for scrolling.
+		 */
+		private function adjustForScroll(containerToInitialize:IContainerController, composeToPosition:Boolean):void
+		{			
+			// Expand the last parcel if scrolling could be enabled. Expand to twice what would fit in available space. 
+			// We will start composing from the top, so if we've scrolled down there will be more to compose.
+			// We turn on fitAny, so that lines will be included in the container even if only a tiny portion of the line
+			// fits. This makes lines that are only partially scrolling in appear. We turn on composeToPosition if we're
+			// forcing composition to go through a given position -- this will make all lines fit, and composition will
+			// continue until it is past the supplied position.
+			var p:Parcel;
+			if (_verticalText)
+			{
+				if (containerToInitialize.horizontalScrollPolicy != ScrollPolicy.OFF)
+				{
+					p = getParcelAt(_numParcels-1);
+					if (p)
+					{
+						var horizontalPaddingAmount:Number = containerToInitialize.getTotalPaddingRight() + containerToInitialize.getTotalPaddingLeft();
+						var right:Number = p.right;
+						p.x = containerToInitialize.horizontalScrollPosition - p.width - horizontalPaddingAmount;
+						p.width = right - p.x;
+						p.fitAny = true;
+						p.composeToPosition = composeToPosition;
+					}
+				}
+			}
+			else
+			{
+				if (containerToInitialize.verticalScrollPolicy != ScrollPolicy.OFF)
+				{
+					p = getParcelAt(_numParcels-1);
+					if (p)
+					{
+						var verticalPaddingAmount:Number = containerToInitialize.getTotalPaddingBottom() + containerToInitialize.getTotalPaddingTop();
+						p.height = (containerToInitialize.verticalScrollPosition + p.height + verticalPaddingAmount) - p.y;
+						p.fitAny = true;
+						p.composeToPosition = composeToPosition;
+					}
+				}
+			}
+		}
+
+		public function get leftMargin():Number
+		{
+			return _leftMargin;
+		}
+		
+		public function pushLeftMargin(leftMargin:Number):void
+		{
+			_leftMargin += leftMargin;	
+		}
+		
+		public function popLeftMargin(leftMargin:Number):void
+		{
+			_leftMargin -= leftMargin;	
+		}
+					
+		public function get rightMargin():Number
+		{
+			return _rightMargin;
+		}
+		
+		public function pushRightMargin(rightMargin:Number):void
+		{
+			_rightMargin += rightMargin;	
+		}
+		
+		public function popRightMargin(rightMargin:Number):void
+		{
+			_rightMargin -= rightMargin;	
+		}
+		
+		public function pushInsideListItemMargin(margin:Number):void
+		{ _insideListItemMargin += margin; }
+		public function popInsideListItemMargin(margin:Number):void
+		{ _insideListItemMargin -= margin; }	
+		public function get insideListItemMargin():Number
+		{ return _insideListItemMargin; }
+		
+		public		function getComposeXCoord(o:Rectangle):Number
+		{ 
+			// trace("LPL: getComposeXCoord");
+			return _verticalText ? o.right : o.left;
+		}
+		public		function getComposeYCoord(o:Rectangle):Number
+		{ 
+			// trace("LPL: getComposeYCoord");
+			return o.top;
+		}
+
+		public function getComposeWidth(o:Rectangle):Number
+		{ 
+			// trace("LPL: getComposeWidth");
+			if (measureLogicalWidth)
+				return Constants.MAX_LINE_WIDTH;
+			return _verticalText ? o.height : o.width; 
+		}
+
+		public function getComposeHeight(o:Rectangle):Number
+		{ 
+			// trace("LPL: getComposeHeight");
+			if (measureLogicalHeight)
+				return Constants.MAX_LINE_WIDTH;
+			return _verticalText ? o.width : o.height; 
+		}		
+
+		/** Returns true if the current parcel is the last.
+		*/
+		public function atLast():Boolean
+		{
+			return _numParcels == 0 || _currentParcelIndex == _numParcels -1;
+		}
+		
+		public function atEnd():Boolean
+		{
+			return _numParcels == 0 || _currentParcelIndex >= _numParcels;
+		}
+		
+		public function gotoParcel(index:int, depth:Number = 0):Boolean
+		{
+			if ( index < 0 || index >= _numParcels )
+				return false;
+			
+			_currentParcel = this.getParcelAt(index);
+			if ( _currentParcel == null )
+				return false;
+			_currentParcelIndex = index;
+			
+			_totalDepth = depth;
+			
+			return true;
+		}
+		
+		public function next():Boolean
+		{
+			CONFIG::debug { assert(_currentParcelIndex >= -1 && _currentParcelIndex < _numParcels, "invalid _currentParcelIndex in ParcelList"); }			
+			var nextParcelIsValid:Boolean = (_currentParcelIndex + 1) < _numParcels;
+
+			_currentParcelIndex += 1;
+			_totalDepth = 0;
+
+			if (nextParcelIsValid)
+			{
+				_currentParcel = getParcelAt(_currentParcelIndex);
+			}
+			else
+				_currentParcel = null;
+	
+			return nextParcelIsValid;
+		}
+		
+		public function get currentParcel():Parcel
+		{ return _currentParcel; }
+
+		/**Return the slug rectangle for a line that goes at the current vertical location,
+		 * and could extend down for at least height pixels. Note that this function
+		 * can change the current parcel, and the location within the parcel.
+		 * @param slugRect result rectangle where line was fit
+		 * @param height	amount of contiguous vertical space that must be available
+		 * @param minWidth	amount of contiguous horizontal space that must be available 
+		 * @return true if a line slug was fit horizontal space actually available
+		 */
+		public function getLineSlug(slug:Slug, height:Number, minWidth:Number, textIndent:Number, directionLTR:Boolean):Boolean
+		{
+			if (currentParcel.getLineSlug(slug, _totalDepth, height, minWidth, currentParcel.fitAny ? 1 : int(height), _leftMargin, _rightMargin, textIndent+_insideListItemMargin, directionLTR,  _explicitLineBreaks))
+			{
+				if (totalDepth != slug.depth)
+					_totalDepth = slug.depth;
+				return true;
+			}
+			return false;
+		}
+	
+		// Attempts to fit a float of the specified width and height in the current parcel. Float is considered to fit if it
+		// is alone on the line but exceeds the parcel width and fits within the logical height.
+		// Returns success or failure.
+		public function fitFloat(slug:Slug, totalDepth:Number, width:Number, height:Number):Boolean
+		{
+			return currentParcel.getLineSlug(slug, totalDepth, height, width, currentParcel.fitAny ? 1 : int(height), _leftMargin, _rightMargin, 0, true, _explicitLineBreaks);
+		}
+				
+	}	//end class
+} //end package

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/SWFContext.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/SWFContext.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/SWFContext.as
new file mode 100644
index 0000000..f3e2e8d
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/SWFContext.as
@@ -0,0 +1,85 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.compose {
+	import org.apache.flex.textLayout.compose.ISWFContext;
+
+	public class SWFContext implements ISWFContext {
+		public function callInContext(fn : Function, thisArg : Object, argArray : Array, returns : Boolean = true) : * {
+		}
+		public static function get globalSWFContext():ISWFContext
+		{ 
+			return GlobalSWFContext.globalSWFContext; 
+		}
+	}
+}
+import org.apache.flex.textLayout.compose.ISWFContext;
+import org.apache.flex.textLayout.debug.Debugging;
+class GlobalSWFContext implements ISWFContext
+{
+	public function GlobalSWFContext()
+	{ }
+
+	static public const globalSWFContext:GlobalSWFContext = new GlobalSWFContext();
+	
+	public function callInContext(fn:Function, thisArg:Object, argsArray:Array, returns:Boolean=true):*
+	{
+		CONFIG::debug
+		{
+			var rslt:*;
+			try
+			{
+				if (returns)
+					rslt = fn.apply(thisArg, argsArray);
+
+				else
+					fn.apply(thisArg, argsArray);
+					
+				if (thisArg)
+				{
+					var traceArgs:Array;
+					// later make this table driven
+					if (thisArg.hasOwnProperty("createTextLine") && fn == thisArg["createTextLine"])
+					{
+						traceArgs = [rslt,thisArg,"createTextLine"];
+						traceArgs.push.apply(traceArgs, argsArray);
+						Debugging.traceFTECall.apply(null,traceArgs);
+					}
+					else if (thisArg.hasOwnProperty("recreateTextLine") && fn == thisArg["recreateTextLine"])
+					{
+						traceArgs = [rslt,thisArg,"recreateTextLine"];
+						traceArgs.push.apply(traceArgs, argsArray);
+						Debugging.traceFTECall.apply(null,traceArgs);
+					}
+				}
+			}
+			catch(e:Error)
+			{
+				// trace(e);
+				throw(e);
+			}
+			return rslt;
+		}
+		CONFIG::release
+		{
+			if (returns)
+				return fn.apply(thisArg, argsArray);
+			fn.apply(thisArg, argsArray);
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/SimpleCompose.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/SimpleCompose.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/SimpleCompose.as
new file mode 100644
index 0000000..013532c
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/SimpleCompose.as
@@ -0,0 +1,442 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.compose
+{
+	import org.apache.flex.textLayout.compose.utils.NumberlineUtil;
+	import org.apache.flex.textLayout.compose.utils.TextLineUtil;
+	import org.apache.flex.text.engine.Constants;
+	import org.apache.flex.text.engine.ITextLine;
+	import org.apache.flex.textLayout.container.IContainerController;
+	import org.apache.flex.textLayout.debug.Debugging;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.elements.IFlowGroupElement;
+	import org.apache.flex.textLayout.elements.IFlowLeafElement;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.textLayout.formats.BlockProgression;
+	import org.apache.flex.textLayout.formats.Direction;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.formats.VerticalAlign;
+
+	
+
+
+	// [ExcludeClass]
+	/** Keeps track of internal state during composition. 
+	 * 
+	 * This is the simpler version, used when there are no floats, no wraps, no columns.
+	 * @private
+	 */
+	public class SimpleCompose extends BaseCompose implements ISimpleCompose	{
+		// reusable scratch TextFlowLine
+		protected var workingLine:ITextFlowLine = new TextFlowLine(null, null);
+		
+		// resulting TextLines
+		private var _lines:Array;
+		
+		// scratch aligns for VJ
+		private var _vjLines:Array;
+		
+		// for figuring out when to do VJ
+		private var vjBeginLineIndex:int = 0;
+		private var vjDisableThisParcel:Boolean = false;
+		private var vjType:String;
+		
+		// accumulator for absolute start computation to support truncation 
+		private var _totalLength:Number;
+		
+		/** Constructor. */
+		public function  SimpleCompose()
+		{	
+			super();
+			_lines = new Array();
+			_vjLines = new Array();
+		}
+		
+		/** @private */
+		protected override function createParcelList():ParcelList
+		{
+			return ParcelList.getParcelList();
+		}
+		/** @private */
+		protected override function releaseParcelList(list:ParcelList):void
+		{
+			ParcelList.releaseParcelList(list);
+		}	
+
+		protected override function  initializeForComposer(composer:IFlowComposer, composeToPosition:int, controllerStartIndex:int, controllerEndIndex:int):void
+		{
+			// Always compose from the start of the flow
+			_startController = composer.getControllerAt(0);
+			_startComposePosition = 0;
+			super.initializeForComposer(composer, composeToPosition, 0, controllerEndIndex);
+			
+			// vj support
+			_vjLines.splice(0);
+			vjBeginLineIndex = 0;
+			vjDisableThisParcel = false;
+			vjType =_startController.computedFormat.verticalAlign;
+		}
+
+		/** @private */
+		public override function composeTextFlow(textFlow:ITextFlow, composeToPosition:int, controllerEndIndex:int):int
+		{
+			_flowComposer = textFlow.flowComposer as IFlowComposer;
+			_curLine = workingLine;
+			CONFIG::debug { assert (_curLine != null, "_curLine is null"); }
+			// empty out lines array
+			_lines.splice(0);
+			// accumulator initialization
+			_totalLength = 0;
+			
+			return super.composeTextFlow(textFlow, composeToPosition, controllerEndIndex);
+		}
+		
+ 		override protected function doVerticalAlignment(canVerticalAlign:Boolean,nextParcel:Parcel):void
+ 		{
+			var vjParcel:Parcel = parcelList.currentParcel;
+
+			if (canVerticalAlign && vjType != VerticalAlign.TOP && vjBeginLineIndex != _lines.length &&  !vjDisableThisParcel)
+			{
+				var controller:IContainerController = _curParcel.controller;
+				var beginFloatIndex:int = 0;
+				var endFloatIndex:int = 0;
+				if (controller.numFloats > 0)
+				{
+					beginFloatIndex = controller.findFloatIndexAtOrAfter(_curParcelStart);
+					endFloatIndex = controller.findFloatIndexAfter(_curElementStart + _curElementOffset);
+				}
+				applyVerticalAlignmentToColumn(vjParcel.controller,vjType,_vjLines,0,_vjLines.length, beginFloatIndex, endFloatIndex);
+			}
+
+			_vjLines.splice(0);
+			vjBeginLineIndex = _lines.length;
+			vjDisableThisParcel = false;
+			if (nextParcel)
+				vjType = nextParcel.controller.computedFormat.verticalAlign;
+ 		}
+ 		
+		// all lines are visible in the factory
+		override protected function isLineVisible(textLine:ITextLine):Boolean
+		{ return textLine != null; }
+		
+		/** Called when we are finished composing a line. Handler for derived classes to override default behavior.  */
+		override protected function endLine(textLine:ITextLine):void
+		{
+			super.endLine(textLine);
+			
+			_curLine.createShape(_blockProgression, textLine);
+			
+			if (textFlow.backgroundManager)
+				textFlow.backgroundManager.finalizeLine(_curLine);
+				
+			textLine.userData = _totalLength; 		// store absolute start position in the userData field
+			_totalLength += textLine.rawTextLength; // update length accumulator
+			_lines.push(textLine);
+			if (vjType != VerticalAlign.TOP)
+				_vjLines.push(new VJHelper(textLine,_curLine.height));
+				
+			commitLastLineState(_curLine);	
+		}
+
+		public function get textFlow():ITextFlow
+		{ return _textFlow; }
+		
+		private var _resetLineHandler:Function;
+		
+		/** Callback to the client to reset a line when its being rebroken */
+		public function get resetLineHandler():Function
+		{ return _resetLineHandler; }
+		public function set resetLineHandler(val:Function):void
+		{ _resetLineHandler = val; }
+		
+		/** @private */
+		protected override function resetLine(textLine:ITextLine):void
+		{
+			super.resetLine(textLine);
+			if (_resetLineHandler != null)
+				_resetLineHandler(textLine);
+		}
+		
+		/** @private */
+		protected override function composeNextLine():ITextLine
+		{
+			CONFIG::debug { assert(!_previousLine || _previousLine.validity == "valid","Bad prevline: "+Debugging.getIdentity(_previousLine)); }
+			
+			var numberLine:ITextLine;
+			// create numberLine if in a listElement
+			if (_listItemElement && _listItemElement.getAbsoluteStart() == _curElementStart+_curElementOffset)
+			{
+				var isRTL:Boolean = _curParaElement.computedFormat.direction == Direction.RTL;
+				numberLine = NumberlineUtil.createNumberLine(_listItemElement, _curParaElement, _flowComposer.swfContext, isRTL ? _parcelList.rightMargin : _parcelList.leftMargin);				
+				pushInsideListItemMargins(numberLine);
+			}
+			
+			// space to palce a line?			
+			if (!_parcelList.getLineSlug(_lineSlug, 0, 0, _textIndent, _curParaFormat.direction == Direction.LTR))
+				return null;
+			
+			var textLine:ITextLine;
+			
+			for (;;) 
+			{
+				for (;;)
+				{	
+					// generate new line
+					CONFIG::debug { assert(!_parcelList.atEnd(), "failing to stop"); }
+					CONFIG::debug { assert(_curElement is IFlowLeafElement, "element must be leaf before calling composeLine"); }
+					
+					textLine = createTextLine(_lineSlug.width, !_lineSlug.wrapsKnockOut /* don't allow emergency breaks next to floats or padded elements */);
+					if (textLine)
+						break;
+
+					// force advance within the parcel to the next wider slug, or (if there are no more) to the next parcel
+					var newDepth:Number = _curParcel.findNextTransition(_lineSlug.depth);
+					if (newDepth < Number.MAX_VALUE)
+					{
+						_parcelList.addTotalDepth(newDepth - _lineSlug.depth);
+						_parcelList.getLineSlug(_lineSlug, 0, 1, _textIndent, _curParaFormat.direction == Direction.LTR);
+					}
+					else
+					{
+						advanceToNextParcel();
+						if (!_parcelList.atEnd())
+							if (_parcelList.getLineSlug(_lineSlug, 0, 1, _textIndent, _curParaFormat.direction == Direction.LTR))
+								continue;
+						popInsideListItemMargins(numberLine);
+						return null;
+					}
+				}
+
+				
+				// updates _lineSlug
+				if (fitLineToParcel(textLine, true, numberLine))	// TODO!!!!!!
+					break;		// we have a good line
+				if (resetLineHandler != null)
+					resetLineHandler(textLine);
+				if (_parcelList.atEnd())		// keep going
+				{
+					popInsideListItemMargins(numberLine);
+					return null;
+				}
+			}
+			
+			popInsideListItemMargins(numberLine);
+
+			CONFIG::debug { assert(textLine != null, "textLine != null"); }		
+			return textLine;
+		}
+        
+        /** @private */
+        public function swapLines(lines:Array):Array
+        {
+        	var current:Array = _lines;
+        	_lines = lines;
+        	return current;
+        }
+
+		/** Final adjustment on the content bounds. */
+ 		override protected function finalParcelAdjustment(controller:IContainerController):void
+ 		{
+			CONFIG::debug { assert(controller.absoluteStart == 0,"SimpleCompose: multiple controllers not supported"); }
+
+			var minX:Number = Constants.MAX_LINE_WIDTH;
+ 			var minY:Number = Constants.MAX_LINE_WIDTH;
+ 			var maxX:Number = -Constants.MAX_LINE_WIDTH;
+			
+			var verticalText:Boolean = _blockProgression == BlockProgression.RL;
+			
+			if (!isNaN(_parcelLogicalTop))
+			{
+				if (verticalText)
+					maxX = _parcelLogicalTop;
+				else
+					minY = _parcelLogicalTop;
+			}
+			
+			if (!_measuring)
+			{
+				if (verticalText)
+					minY = _accumulatedMinimumStart;
+				else
+					minX = _accumulatedMinimumStart;			
+			}
+			else
+			{
+	 			var textLine:ITextLine;
+	 			var startPos:int = 0;
+				
+				var firstLineAdjust:Number;
+				var effectiveIndent:Number;
+				var edgeAdjust:Number;
+				var curPara:IParagraphElement;
+				var curParaFormat:ITextLayoutFormat;
+				var paddingVerticalAdjust:Number = 0;		// logical vertical adjustment due to padding on paragraph & divs
+				var paddingHorizontalAdjust:Number = 0;		// logical horizontal adjustment due to padding on paragraph & divs
+				var previousParagraph:IParagraphElement = null;
+	
+				for each (textLine in _lines)
+				{
+					var leaf:IFlowLeafElement = controller.textFlow.findLeaf(startPos);
+					var para:IParagraphElement = leaf.getParagraph();
+					if (para != previousParagraph)
+					{
+						// Recalculate padding values for the new paragraph
+						paddingVerticalAdjust = 0;
+						paddingHorizontalAdjust = 0;
+						var fge:IFlowGroupElement = para;
+						while (fge && fge.parent)
+						{
+							if (verticalText)
+							{
+								paddingVerticalAdjust += (fge.getEffectivePaddingRight() + fge.getEffectiveBorderRightWidth() + fge.getEffectiveMarginRight());
+								paddingHorizontalAdjust += (fge.getEffectivePaddingTop() + fge.getEffectiveBorderTopWidth() + fge.getEffectiveMarginTop());
+							}
+							else
+							{
+								paddingVerticalAdjust += (fge.getEffectivePaddingTop() + fge.getEffectiveBorderTopWidth() + fge.getEffectiveMarginTop());
+								paddingHorizontalAdjust += (fge.getEffectivePaddingLeft() + fge.getEffectiveBorderLeftWidth() + fge.getEffectiveMarginLeft());
+							}
+							fge = fge.parent;
+						}
+						previousParagraph = para;
+					}
+	
+	            	// Check the logical vertical dimension first
+	            	// If the lines have children, they may be inlines. The origin of the ITextLine is the baseline, 
+	            	// which does not include the ascent of the inlines or the text. So we have to factor that in.
+					// var verticalAdjust:Number = verticalText ? textLine.descent : textLine.ascent;
+					var inlineAscent:Number = 0;
+					if (textLine.numElements > 0)		// adjustjust logical vertical coord to take into account inlines
+					{
+						var leafStart:int = leaf.getAbsoluteStart();
+						inlineAscent = TextLineUtil.getTextLineTypographicAscent(textLine, leaf, leafStart, startPos + textLine.rawTextLength);
+					}
+	
+					// Figure out the logical horizontal adjustment
+					CONFIG::debug { assert(curPara != para, "found it"); }
+					if (curPara != para)
+					{
+						curParaFormat = para.computedFormat;
+						if (curParaFormat.direction == Direction.LTR)
+						{
+							firstLineAdjust = Math.max(curParaFormat.textIndent, 0);
+							effectiveIndent = curParaFormat.paragraphStartIndent;
+						}
+						else
+						{
+							firstLineAdjust = 0;
+							effectiveIndent = curParaFormat.paragraphEndIndent;
+						}
+					}
+					effectiveIndent += paddingHorizontalAdjust;
+					
+					edgeAdjust = textLine.textBlockBeginIndex == 0 ? effectiveIndent + firstLineAdjust : effectiveIndent;
+					edgeAdjust = verticalText ? textLine.y - edgeAdjust : textLine.x - edgeAdjust;
+					
+					var numberLine:ITextLine = TextLineUtil.findNumberLine(textLine);
+					
+					if (numberLine)
+					{
+						var numberLineStart:Number = verticalText ? numberLine.y+textLine.y : numberLine.x+textLine.x;
+						edgeAdjust = Math.min(edgeAdjust,numberLineStart);
+					}
+					
+					if (verticalText)
+					{
+						minY = Math.min(edgeAdjust, minY);
+			            maxX = Math.max(textLine.x + Math.max(inlineAscent,textLine.ascent) + paddingVerticalAdjust, maxX);
+					}
+					else
+					{
+						minX = Math.min(edgeAdjust, minX);
+						if (inlineAscent < textLine.ascent)
+							inlineAscent = textLine.ascent;
+			           	minY = Math.min(textLine.y - (inlineAscent + paddingVerticalAdjust), minY);
+			  		}
+			  		startPos += textLine.rawTextLength;
+   				}
+			}
+			
+            // Don't make adjustments for tiny fractional values.
+            /*if (minX != _parcelLeft && Math.abs(minX-_parcelLeft) >= 1)
+         		_parcelLeft = minX;
+            if (maxX != _parcelRight && Math.abs(maxX-_parcelRight) >= 1)
+         		_parcelRight = maxX;
+         	if (minY != _parcelTop && Math.abs(minY-_parcelTop) >= 1)
+           		_parcelTop = minY;*/
+			if (minX != Constants.MAX_LINE_WIDTH && Math.abs(minX-_parcelLeft) >= 1)
+				_parcelLeft = minX;
+			if (maxX != -Constants.MAX_LINE_WIDTH && Math.abs(maxX-_parcelRight) >= 1)
+				_parcelRight = maxX;
+			if (minY != Constants.MAX_LINE_WIDTH && Math.abs(minY-_parcelTop) >= 1)
+				_parcelTop = minY;
+
+ 		}		
+		
+		public override function releaseAnyReferences():void
+		{
+			super.releaseAnyReferences();
+			workingLine.initialize(null,0,0,0,0,null);
+			resetLineHandler = null;
+			// parcelList.releaseAnyReferences();
+		}
+
+		public function get lines():Array
+		{
+			return _lines;
+		}
+	}
+}
+import org.apache.flex.text.engine.ITextLine;
+import org.apache.flex.textLayout.compose.IVerticalJustificationLine;
+
+class VJHelper implements IVerticalJustificationLine
+{
+	private var _line:ITextLine;
+	private var _height:Number;
+
+	public function VJHelper(line:ITextLine,h:Number)
+	{
+		_line = line;
+		_height = h;
+	}
+	public function get x():Number
+	{ return _line.x; }
+	public function set x(val:Number):void
+	{ _line.x = val; }
+		
+	public function get y():Number
+	{ return _line.y; }
+	public function set y(val:Number):void
+	{ _line.y = val; }
+		
+	public function get ascent():Number
+	{ return _line.ascent; }
+	public function get descent():Number
+	{ return _line.descent; }
+	public function get height():Number
+	{
+		return _height;
+	}
+
+	public function set height(value:Number):void
+	{
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/Slug.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/Slug.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/Slug.as
new file mode 100644
index 0000000..7fd0788
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/Slug.as
@@ -0,0 +1,32 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.compose
+{
+	/** A Slug is geomtrical line information, generated by a Parcel. It has data required for composition. */
+	// [ExcludeClass]
+	public class Slug
+	{
+		public var leftMargin:Number;
+		public var rightMargin:Number;
+		public var width:Number;	// logical width
+		public var depth:Number;
+		public var height:Number;	// logical height
+		public var wrapsKnockOut:Boolean;	// true if the slug is narrow because it encountered a knockout (e.g., for a float)
+	}
+}


[07/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/TextLayoutFormat.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/TextLayoutFormat.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/TextLayoutFormat.as
new file mode 100644
index 0000000..c2a0870
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/TextLayoutFormat.as
@@ -0,0 +1,3791 @@
+// //////////////////////////////////////////////////////////////////////////////
+//
+// 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
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// //////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.formats
+{
+	import org.apache.flex.text.engine.BreakOpportunity;
+	import org.apache.flex.text.engine.CFFHinting;
+	import org.apache.flex.text.engine.DigitCase;
+	import org.apache.flex.text.engine.DigitWidth;
+	import org.apache.flex.text.engine.FontLookup;
+	import org.apache.flex.text.engine.FontPosture;
+	import org.apache.flex.text.engine.FontWeight;
+	import org.apache.flex.text.engine.JustificationStyle;
+	import org.apache.flex.text.engine.Kerning;
+	import org.apache.flex.text.engine.LigatureLevel;
+	import org.apache.flex.text.engine.RenderingMode;
+	import org.apache.flex.text.engine.TextBaseline;
+	import org.apache.flex.text.engine.TextRotation;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.property.Property;
+	import org.apache.flex.textLayout.property.PropertyFactory;
+	import org.apache.flex.textLayout.property.PropertyUtil;
+
+	/**
+	 * The TextLayoutFormat class holds all of the text layout properties. These properties affect the format and style of a text flow at the container level, paragraph level, and text level.  Both the ContainerController class and the FlowElement base class have <code>format</code> properties that enable you to assign a TextLayoutFormat instance to them. Assign a TextLayoutFormat object to a container to affect the format of all of the container's content. Assign a TextLayoutFormat object to a FlowElement descendant to specify formatting for that particular element: TextFlow, ParagraphElement, DivElement, SpanElement, InlineGraphicElement, LinkElement, and TCYElement.
+	 * In addition to the <code>format</code> property, these classes also define each of the individual TextLayoutFormat properties so that you can override the setting of a particular style property for that element, if you wish. <p>Because you can set a given style at multiple levels, it is possible to have conflicts. For example, the color of the text at the TextFlow level could be set to black while a SpanElement object sets it to blue. The general rule is that the setting at the lowest level on the text flow tree takes precedence. So if the ligature level is set for a TextFlow instance and also set for a DivElement, the DivElement setting takes precedence. </p><p>Cascading styles refers to the process of adopting styles from a higher level in the text flow if a style value is undefined at a lower level. When a style is undefined on an element at the point it is about to be rendered, it either takes its default value or the value cascades or descends from the value on a parent ele
 ment. For example, if the transparency (<code>textAlpha</code> property) of the text is undefined on a SpanElement object, but is set on the TextFlow, the value of the <code>TextFlow.textAlpha</code> property cascades to the SpanElement object and is applied to the text for that span. The result of the cascade, or the sum of the styles that is applied to the element, is stored in the element's <code>computedFormat</code> property.</p><p>In the same way, you can apply user styles using the <code>userStyles</code> property of the ContainerController and FlowElement classes. This  property allows you to read or write a dictionary of user styles and apply its settings to a container or a text flow element. The user styles dictionary is an object that consists of <em>stylename-value</em> pairs. Styles specified by the <code>userStyles</code> property take precedence over all others.</p><p>Most styles that are undefined inherit the value of their immediate parent during a cascade. A small
  number of styles, however, do not inherit their parent\ufffds value and take on their default values instead.</p><p><strong>Style properties that adopt their default values, if undefined, include:</strong> <code>backgroundAlpha</code>, <code>backgroundColor</code>, <code>columnCount</code>, <code>columnGap</code>, <code>columnWidth</code>, <code>lineBreak</code>, <code>paddingBottom</code>, <code>paddingLeft</code>, <code>paddingRight</code>, <code>paddingTop</code>, <code>verticalAlign</code></p>.
+	 * @see org.apache.flex.textLayout.elements.FlowElement#format
+	 * @see org.apache.flex.textLayout.factory.TextFlowTextLineFactory
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5 
+	 * @langversion 3.0 
+	 */
+	public class TextLayoutFormat implements ITextLayoutFormat
+	{
+		/** @private */
+		static private var _columnBreakBeforeProperty:Property;
+
+		static public function get columnBreakBeforeProperty():Property
+		{
+			if (!_columnBreakBeforeProperty)
+				_columnBreakBeforeProperty = PropertyFactory.enumString("columnBreakBefore", BreakStyle.AUTO, false, Vector.<String>([Category.PARAGRAPH]), BreakStyle.AUTO, BreakStyle.ALWAYS);
+			return _columnBreakBeforeProperty;
+		}
+
+		/** @private */
+		static private var _columnBreakAfterProperty:Property;
+
+		static public function get columnBreakAfterProperty():Property
+		{
+			if (!_columnBreakAfterProperty)
+				_columnBreakAfterProperty = PropertyFactory.enumString("columnBreakAfter", BreakStyle.AUTO, false, Vector.<String>([Category.PARAGRAPH]), BreakStyle.AUTO, BreakStyle.ALWAYS);
+			return _columnBreakAfterProperty;
+		}
+
+		/** @private */
+		static private var _containerBreakBeforeProperty:Property;
+
+		static public function get containerBreakBeforeProperty():Property
+		{
+			if (!_containerBreakBeforeProperty)
+				_containerBreakBeforeProperty = PropertyFactory.enumString("containerBreakBefore", BreakStyle.AUTO, false, Vector.<String>([Category.PARAGRAPH]), BreakStyle.AUTO, BreakStyle.ALWAYS);
+			return _containerBreakBeforeProperty;
+		}
+
+		/** @private */
+		static private var _containerBreakAfterProperty:Property;
+
+		static public function get containerBreakAfterProperty():Property
+		{
+			if (!_containerBreakAfterProperty)
+				_containerBreakAfterProperty = PropertyFactory.enumString("containerBreakAfter", BreakStyle.AUTO, false, Vector.<String>([Category.PARAGRAPH]), BreakStyle.AUTO, BreakStyle.ALWAYS);
+			return _containerBreakAfterProperty;
+		}
+
+		/** @private */
+		static private var _colorProperty:Property;
+
+		static public function get colorProperty():Property
+		{
+			if (!_colorProperty)
+				_colorProperty = PropertyFactory.uintOrEnum("color", 0, true, Vector.<String>([Category.CHARACTER]), ColorName.BLACK, ColorName.GREEN, ColorName.GRAY, ColorName.BLUE, ColorName.SILVER, ColorName.LIME, ColorName.OLIVE, ColorName.WHITE, ColorName.YELLOW, ColorName.MAROON, ColorName.NAVY, ColorName.RED, ColorName.PURPLE, ColorName.TEAL, ColorName.FUCHSIA, ColorName.AQUA, ColorName.MAGENTA, ColorName.CYAN);
+			return _colorProperty;
+		}
+
+		/** @private */
+		static private var _backgroundColorProperty:Property;
+
+		static public function get backgroundColorProperty():Property
+		{
+			if (!_backgroundColorProperty)
+				_backgroundColorProperty = PropertyFactory.uintOrEnum("backgroundColor", BackgroundColor.TRANSPARENT, false, Vector.<String>([Category.CHARACTER, Category.PARAGRAPH, Category.CONTAINER, Category.TABLE, Category.TABLEROW, Category.TABLECOLUMN, Category.TABLECELL]), BackgroundColor.TRANSPARENT);
+			return _backgroundColorProperty;
+		}
+
+		/** @private */
+		static private var _lineThroughProperty:Property;
+
+		static public function get lineThroughProperty():Property
+		{
+			if (!_lineThroughProperty)
+				_lineThroughProperty = PropertyFactory.bool("lineThrough", false, true, Vector.<String>([Category.CHARACTER]));
+			return _lineThroughProperty;
+		}
+
+		/** @private */
+		static private var _textAlphaProperty:Property;
+
+		static public function get textAlphaProperty():Property
+		{
+			if (!_textAlphaProperty)
+				_textAlphaProperty = PropertyFactory.number("textAlpha", 1, true, Vector.<String>([Category.CHARACTER]), 0, 1);
+			return _textAlphaProperty;
+		}
+
+		/** @private */
+		static private var _backgroundAlphaProperty:Property;
+
+		static public function get backgroundAlphaProperty():Property
+		{
+			if (!_backgroundAlphaProperty)
+				_backgroundAlphaProperty = PropertyFactory.number("backgroundAlpha", 1, false, Vector.<String>([Category.CHARACTER]), 0, 1);
+			return _backgroundAlphaProperty;
+		}
+
+		/** @private */
+		static private var _fontSizeProperty:Property;
+
+		static public function get fontSizeProperty():Property
+		{
+			if (!_fontSizeProperty)
+				_fontSizeProperty = PropertyFactory.number("fontSize", 12, true, Vector.<String>([Category.CHARACTER]), 1, 720);
+			return _fontSizeProperty;
+		}
+
+		/** @private */
+		static private var _baselineShiftProperty:Property;
+
+		static public function get baselineShiftProperty():Property
+		{
+			if (!_baselineShiftProperty)
+				_baselineShiftProperty = PropertyFactory.numPercentEnum("baselineShift", 0.0, true, Vector.<String>([Category.CHARACTER]), -1000, 1000, "-1000%", "1000%", BaselineShift.SUPERSCRIPT, BaselineShift.SUBSCRIPT);
+			return _baselineShiftProperty;
+		}
+
+		/** @private */
+		static private var _trackingLeftProperty:Property;
+
+		static public function get trackingLeftProperty():Property
+		{
+			if (!_trackingLeftProperty)
+				_trackingLeftProperty = PropertyFactory.numPercent("trackingLeft", 0, true, Vector.<String>([Category.CHARACTER]), -1000, 1000, "-1000%", "1000%");
+			return _trackingLeftProperty;
+		}
+
+		/** @private */
+		static private var _trackingRightProperty:Property;
+
+		static public function get trackingRightProperty():Property
+		{
+			if (!_trackingRightProperty)
+				_trackingRightProperty = PropertyFactory.numPercent("trackingRight", 0, true, Vector.<String>([Category.CHARACTER]), -1000, 1000, "-1000%", "1000%");
+			return _trackingRightProperty;
+		}
+
+		/** @private */
+		static private var _lineHeightProperty:Property;
+
+		static public function get lineHeightProperty():Property
+		{
+			if (!_lineHeightProperty)
+				_lineHeightProperty = PropertyFactory.numPercent("lineHeight", "120%", true, Vector.<String>([Category.CHARACTER]), -720, 720, "-1000%", "1000%");
+			return _lineHeightProperty;
+		}
+
+		/** @private */
+		static private var _breakOpportunityProperty:Property;
+
+		static public function get breakOpportunityProperty():Property
+		{
+			if (!_breakOpportunityProperty)
+				_breakOpportunityProperty = PropertyFactory.enumString("breakOpportunity", BreakOpportunity.AUTO, true, Vector.<String>([Category.CHARACTER]), BreakOpportunity.ALL, BreakOpportunity.ANY, BreakOpportunity.AUTO, BreakOpportunity.NONE);
+			return _breakOpportunityProperty;
+		}
+
+		/** @private */
+		static private var _digitCaseProperty:Property;
+
+		static public function get digitCaseProperty():Property
+		{
+			if (!_digitCaseProperty)
+				_digitCaseProperty = PropertyFactory.enumString("digitCase", DigitCase.DEFAULT, true, Vector.<String>([Category.CHARACTER]), DigitCase.DEFAULT, DigitCase.LINING, DigitCase.OLD_STYLE);
+			return _digitCaseProperty;
+		}
+
+		/** @private */
+		static private var _digitWidthProperty:Property;
+
+		static public function get digitWidthProperty():Property
+		{
+			if (!_digitWidthProperty)
+				_digitWidthProperty = PropertyFactory.enumString("digitWidth", DigitWidth.DEFAULT, true, Vector.<String>([Category.CHARACTER]), DigitWidth.DEFAULT, DigitWidth.PROPORTIONAL, DigitWidth.TABULAR);
+			return _digitWidthProperty;
+		}
+
+		/** @private */
+		static private var _dominantBaselineProperty:Property;
+
+		static public function get dominantBaselineProperty():Property
+		{
+			if (!_dominantBaselineProperty)
+				_dominantBaselineProperty = PropertyFactory.enumString("dominantBaseline", FormatValue.AUTO, true, Vector.<String>([Category.CHARACTER]), FormatValue.AUTO, TextBaseline.ROMAN, TextBaseline.ASCENT, TextBaseline.DESCENT, TextBaseline.IDEOGRAPHIC_TOP, TextBaseline.IDEOGRAPHIC_CENTER, TextBaseline.IDEOGRAPHIC_BOTTOM);
+			return _dominantBaselineProperty;
+		}
+
+		/** @private */
+		static private var _kerningProperty:Property;
+
+		static public function get kerningProperty():Property
+		{
+			if (!_kerningProperty)
+				_kerningProperty = PropertyFactory.enumString("kerning", Kerning.AUTO, true, Vector.<String>([Category.CHARACTER]), Kerning.ON, Kerning.OFF, Kerning.AUTO);
+			return _kerningProperty;
+		}
+
+		/** @private */
+		static private var _ligatureLevelProperty:Property;
+
+		static public function get ligatureLevelProperty():Property
+		{
+			if (!_ligatureLevelProperty)
+				_ligatureLevelProperty = PropertyFactory.enumString("ligatureLevel", LigatureLevel.COMMON, true, Vector.<String>([Category.CHARACTER]), LigatureLevel.MINIMUM, LigatureLevel.COMMON, LigatureLevel.UNCOMMON, LigatureLevel.EXOTIC);
+			return _ligatureLevelProperty;
+		}
+
+		/** @private */
+		static private var _alignmentBaselineProperty:Property;
+
+		static public function get alignmentBaselineProperty():Property
+		{
+			if (!_alignmentBaselineProperty)
+				_alignmentBaselineProperty = PropertyFactory.enumString("alignmentBaseline", TextBaseline.USE_DOMINANT_BASELINE, true, Vector.<String>([Category.CHARACTER]), TextBaseline.ROMAN, TextBaseline.ASCENT, TextBaseline.DESCENT, TextBaseline.IDEOGRAPHIC_TOP, TextBaseline.IDEOGRAPHIC_CENTER, TextBaseline.IDEOGRAPHIC_BOTTOM, TextBaseline.USE_DOMINANT_BASELINE);
+			return _alignmentBaselineProperty;
+		}
+
+		/** @private */
+		static private var _localeProperty:Property;
+
+		static public function get localeProperty():Property
+		{
+			if (!_localeProperty)
+				_localeProperty = PropertyFactory.string("locale", "en", true, Vector.<String>([Category.CHARACTER, Category.PARAGRAPH]));
+			return _localeProperty;
+		}
+
+		/** @private */
+		static private var _typographicCaseProperty:Property;
+
+		static public function get typographicCaseProperty():Property
+		{
+			if (!_typographicCaseProperty)
+				_typographicCaseProperty = PropertyFactory.enumString("typographicCase", TLFTypographicCase.DEFAULT, true, Vector.<String>([Category.CHARACTER]), TLFTypographicCase.DEFAULT, TLFTypographicCase.CAPS_TO_SMALL_CAPS, TLFTypographicCase.UPPERCASE, TLFTypographicCase.LOWERCASE, TLFTypographicCase.LOWERCASE_TO_SMALL_CAPS);
+			return _typographicCaseProperty;
+		}
+
+		/** @private */
+		static private var _fontFamilyProperty:Property;
+
+		static public function get fontFamilyProperty():Property
+		{
+			if (!_fontFamilyProperty)
+				_fontFamilyProperty = PropertyFactory.string("fontFamily", "Arial", true, Vector.<String>([Category.CHARACTER]));
+			return _fontFamilyProperty;
+		}
+
+		/** @private */
+		static private var _textDecorationProperty:Property;
+
+		static public function get textDecorationProperty():Property
+		{
+			if (!_textDecorationProperty)
+				_textDecorationProperty = PropertyFactory.enumString("textDecoration", TextDecoration.NONE, true, Vector.<String>([Category.CHARACTER]), TextDecoration.NONE, TextDecoration.UNDERLINE);
+			return _textDecorationProperty;
+		}
+
+		/** @private */
+		static private var _fontWeightProperty:Property;
+
+		static public function get fontWeightProperty():Property
+		{
+			if (!_fontWeightProperty)
+				_fontWeightProperty = PropertyFactory.enumString("fontWeight", FontWeight.NORMAL, true, Vector.<String>([Category.CHARACTER]), FontWeight.NORMAL, FontWeight.BOLD);
+			return _fontWeightProperty;
+		}
+
+		/** @private */
+		static private var _fontStyleProperty:Property;
+
+		static public function get fontStyleProperty():Property
+		{
+			if (!_fontStyleProperty)
+				_fontStyleProperty = PropertyFactory.enumString("fontStyle", FontPosture.NORMAL, true, Vector.<String>([Category.CHARACTER]), FontPosture.NORMAL, FontPosture.ITALIC);
+			return _fontStyleProperty;
+		}
+
+		/** @private */
+		static private var _whiteSpaceCollapseProperty:Property;
+
+		static public function get whiteSpaceCollapseProperty():Property
+		{
+			if (!_whiteSpaceCollapseProperty)
+				_whiteSpaceCollapseProperty = PropertyFactory.enumString("whiteSpaceCollapse", WhiteSpaceCollapse.COLLAPSE, true, Vector.<String>([Category.CHARACTER]), WhiteSpaceCollapse.PRESERVE, WhiteSpaceCollapse.COLLAPSE);
+			return _whiteSpaceCollapseProperty;
+		}
+
+		/** @private */
+		static private var _renderingModeProperty:Property;
+
+		static public function get renderingModeProperty():Property
+		{
+			if (!_renderingModeProperty)
+				_renderingModeProperty = PropertyFactory.enumString("renderingMode", RenderingMode.CFF, true, Vector.<String>([Category.CHARACTER]), RenderingMode.NORMAL, RenderingMode.CFF);
+			return _renderingModeProperty;
+		}
+
+		/** @private */
+		static private var _cffHintingProperty:Property;
+
+		static public function get cffHintingProperty():Property
+		{
+			if (!_cffHintingProperty)
+				_cffHintingProperty = PropertyFactory.enumString("cffHinting", CFFHinting.HORIZONTAL_STEM, true, Vector.<String>([Category.CHARACTER]), CFFHinting.NONE, CFFHinting.HORIZONTAL_STEM);
+			return _cffHintingProperty;
+		}
+
+		/** @private */
+		static private var _fontLookupProperty:Property;
+
+		static public function get fontLookupProperty():Property
+		{
+			if (!_fontLookupProperty)
+				_fontLookupProperty = PropertyFactory.enumString("fontLookup", FontLookup.DEVICE, true, Vector.<String>([Category.CHARACTER]), FontLookup.DEVICE, FontLookup.EMBEDDED_CFF);
+			return _fontLookupProperty;
+		}
+
+		/** @private */
+		static private var _textRotationProperty:Property;
+
+		static public function get textRotationProperty():Property
+		{
+			if (!_textRotationProperty)
+				_textRotationProperty = PropertyFactory.enumString("textRotation", TextRotation.AUTO, true, Vector.<String>([Category.CHARACTER]), TextRotation.ROTATE_0, TextRotation.ROTATE_180, TextRotation.ROTATE_270, TextRotation.ROTATE_90, TextRotation.AUTO);
+			return _textRotationProperty;
+		}
+
+		/** @private */
+		static private var _textIndentProperty:Property;
+
+		static public function get textIndentProperty():Property
+		{
+			if (!_textIndentProperty)
+				_textIndentProperty = PropertyFactory.number("textIndent", 0, true, Vector.<String>([Category.PARAGRAPH]), -8000, 8000);
+			return _textIndentProperty;
+		}
+
+		/** @private */
+		static private var _paragraphStartIndentProperty:Property;
+
+		static public function get paragraphStartIndentProperty():Property
+		{
+			if (!_paragraphStartIndentProperty)
+				_paragraphStartIndentProperty = PropertyFactory.number("paragraphStartIndent", 0, true, Vector.<String>([Category.PARAGRAPH]), 0, 8000);
+			return _paragraphStartIndentProperty;
+		}
+
+		/** @private */
+		static private var _paragraphEndIndentProperty:Property;
+
+		static public function get paragraphEndIndentProperty():Property
+		{
+			if (!_paragraphEndIndentProperty)
+				_paragraphEndIndentProperty = PropertyFactory.number("paragraphEndIndent", 0, true, Vector.<String>([Category.PARAGRAPH]), 0, 8000);
+			return _paragraphEndIndentProperty;
+		}
+
+		/** @private */
+		static private var _paragraphSpaceBeforeProperty:Property;
+
+		static public function get paragraphSpaceBeforeProperty():Property
+		{
+			if (!_paragraphSpaceBeforeProperty)
+				_paragraphSpaceBeforeProperty = PropertyFactory.number("paragraphSpaceBefore", 0, true, Vector.<String>([Category.PARAGRAPH]), 0, 8000);
+			return _paragraphSpaceBeforeProperty;
+		}
+
+		/** @private */
+		static private var _paragraphSpaceAfterProperty:Property;
+
+		static public function get paragraphSpaceAfterProperty():Property
+		{
+			if (!_paragraphSpaceAfterProperty)
+				_paragraphSpaceAfterProperty = PropertyFactory.number("paragraphSpaceAfter", 0, true, Vector.<String>([Category.PARAGRAPH]), 0, 8000);
+			return _paragraphSpaceAfterProperty;
+		}
+
+		/** @private */
+		static private var _textAlignProperty:Property;
+
+		static public function get textAlignProperty():Property
+		{
+			if (!_textAlignProperty)
+				_textAlignProperty = PropertyFactory.enumString("textAlign", TextAlign.START, true, Vector.<String>([Category.PARAGRAPH, Category.TABLE, Category.TABLECELL, Category.TABLEROW, Category.TABLECOLUMN]), TextAlign.LEFT, TextAlign.RIGHT, TextAlign.CENTER, TextAlign.JUSTIFY, TextAlign.START, TextAlign.END);
+			return _textAlignProperty;
+		}
+
+		/** @private */
+		static private var _textAlignLastProperty:Property;
+
+		static public function get textAlignLastProperty():Property
+		{
+			if (!_textAlignLastProperty)
+				_textAlignLastProperty = PropertyFactory.enumString("textAlignLast", TextAlign.START, true, Vector.<String>([Category.PARAGRAPH]), TextAlign.LEFT, TextAlign.RIGHT, TextAlign.CENTER, TextAlign.JUSTIFY, TextAlign.START, TextAlign.END);
+			return _textAlignLastProperty;
+		}
+
+		/** @private */
+		static private var _textJustifyProperty:Property;
+
+		static public function get textJustifyProperty():Property
+		{
+			if (!_textJustifyProperty)
+				_textJustifyProperty = PropertyFactory.enumString("textJustify", TextJustify.INTER_WORD, true, Vector.<String>([Category.PARAGRAPH]), TextJustify.INTER_WORD, TextJustify.DISTRIBUTE);
+			return _textJustifyProperty;
+		}
+
+		/** @private */
+		static private var _justificationRuleProperty:Property;
+
+		static public function get justificationRuleProperty():Property
+		{
+			if (!_justificationRuleProperty)
+				_justificationRuleProperty = PropertyFactory.enumString("justificationRule", FormatValue.AUTO, true, Vector.<String>([Category.PARAGRAPH]), JustificationRule.EAST_ASIAN, JustificationRule.SPACE, FormatValue.AUTO);
+			return _justificationRuleProperty;
+		}
+
+		/** @private */
+		static private var _justificationStyleProperty:Property;
+
+		static public function get justificationStyleProperty():Property
+		{
+			if (!_justificationStyleProperty)
+				_justificationStyleProperty = PropertyFactory.enumString("justificationStyle", FormatValue.AUTO, true, Vector.<String>([Category.PARAGRAPH]), JustificationStyle.PRIORITIZE_LEAST_ADJUSTMENT, JustificationStyle.PUSH_IN_KINSOKU, JustificationStyle.PUSH_OUT_ONLY, FormatValue.AUTO);
+			return _justificationStyleProperty;
+		}
+
+		/** @private */
+		static private var _directionProperty:Property;
+
+		static public function get directionProperty():Property
+		{
+			if (!_directionProperty)
+				_directionProperty = PropertyFactory.enumString("direction", Direction.LTR, true, Vector.<String>([Category.PARAGRAPH, Category.TABLE, Category.TABLECELL, Category.TABLEROW, Category.TABLECOLUMN]), Direction.LTR, Direction.RTL);
+			return _directionProperty;
+		}
+
+		/** @private */
+		static private var _wordSpacingProperty:Property;
+
+		static public function get wordSpacingProperty():Property
+		{
+			if (!_wordSpacingProperty)
+				_wordSpacingProperty = PropertyFactory.spacingLimitProp("wordSpacing", "100%, 50%, 150%", true, Vector.<String>([Category.PARAGRAPH]), "-1000%", "1000%");
+			return _wordSpacingProperty;
+		}
+
+		/** @private */
+		static private var _tabStopsProperty:Property;
+
+		static public function get tabStopsProperty():Property
+		{
+			if (!_tabStopsProperty)
+				_tabStopsProperty = PropertyFactory.tabStopsProp("tabStops", null, true, Vector.<String>([Category.PARAGRAPH]));
+			return _tabStopsProperty;
+		}
+
+		/** @private */
+		static private var _leadingModelProperty:Property;
+
+		static public function get leadingModelProperty():Property
+		{
+			if (!_leadingModelProperty)
+				_leadingModelProperty = PropertyFactory.enumString("leadingModel", LeadingModel.AUTO, true, Vector.<String>([Category.PARAGRAPH]), LeadingModel.ROMAN_UP, LeadingModel.IDEOGRAPHIC_TOP_UP, LeadingModel.IDEOGRAPHIC_CENTER_UP, LeadingModel.IDEOGRAPHIC_TOP_DOWN, LeadingModel.IDEOGRAPHIC_CENTER_DOWN, LeadingModel.APPROXIMATE_TEXT_FIELD, LeadingModel.ASCENT_DESCENT_UP, LeadingModel.BOX, LeadingModel.AUTO);
+			return _leadingModelProperty;
+		}
+
+		/** @private */
+		static private var _columnGapProperty:Property;
+
+		static public function get columnGapProperty():Property
+		{
+			if (!_columnGapProperty)
+				_columnGapProperty = PropertyFactory.number("columnGap", 20, false, Vector.<String>([Category.CONTAINER]), 0, 1000);
+			return _columnGapProperty;
+		}
+
+		/** @private */
+		static private var _paddingLeftProperty:Property;
+
+		static public function get paddingLeftProperty():Property
+		{
+			if (!_paddingLeftProperty)
+				_paddingLeftProperty = PropertyFactory.numEnum("paddingLeft", FormatValue.AUTO, false, Vector.<String>([Category.CONTAINER, Category.PARAGRAPH]), -8000, 8000, FormatValue.AUTO);
+			return _paddingLeftProperty;
+		}
+
+		/** @private */
+		static private var _paddingTopProperty:Property;
+
+		static public function get paddingTopProperty():Property
+		{
+			if (!_paddingTopProperty)
+				_paddingTopProperty = PropertyFactory.numEnum("paddingTop", FormatValue.AUTO, false, Vector.<String>([Category.CONTAINER, Category.PARAGRAPH]), -8000, 8000, FormatValue.AUTO);
+			return _paddingTopProperty;
+		}
+
+		/** @private */
+		static private var _paddingRightProperty:Property;
+
+		static public function get paddingRightProperty():Property
+		{
+			if (!_paddingRightProperty)
+				_paddingRightProperty = PropertyFactory.numEnum("paddingRight", FormatValue.AUTO, false, Vector.<String>([Category.CONTAINER, Category.PARAGRAPH]), -8000, 8000, FormatValue.AUTO);
+			return _paddingRightProperty;
+		}
+
+		/** @private */
+		static private var _paddingBottomProperty:Property;
+
+		static public function get paddingBottomProperty():Property
+		{
+			if (!_paddingBottomProperty)
+				_paddingBottomProperty = PropertyFactory.numEnum("paddingBottom", FormatValue.AUTO, false, Vector.<String>([Category.CONTAINER, Category.PARAGRAPH]), -8000, 8000, FormatValue.AUTO);
+			return _paddingBottomProperty;
+		}
+
+		/** @private */
+		static private var _columnCountProperty:Property;
+
+		static public function get columnCountProperty():Property
+		{
+			if (!_columnCountProperty)
+				_columnCountProperty = PropertyFactory.intOrEnum("columnCount", FormatValue.AUTO, false, Vector.<String>([Category.CONTAINER]), 1, 50, FormatValue.AUTO);
+			return _columnCountProperty;
+		}
+
+		/** @private */
+		static private var _columnWidthProperty:Property;
+
+		static public function get columnWidthProperty():Property
+		{
+			if (!_columnWidthProperty)
+				_columnWidthProperty = PropertyFactory.numEnum("columnWidth", FormatValue.AUTO, false, Vector.<String>([Category.CONTAINER]), 0, 8000, FormatValue.AUTO);
+			return _columnWidthProperty;
+		}
+
+		/** @private */
+		static private var _firstBaselineOffsetProperty:Property;
+
+		static public function get firstBaselineOffsetProperty():Property
+		{
+			if (!_firstBaselineOffsetProperty)
+				_firstBaselineOffsetProperty = PropertyFactory.numEnum("firstBaselineOffset", BaselineOffset.AUTO, true, Vector.<String>([Category.CONTAINER]), 0, 1000, BaselineOffset.AUTO, BaselineOffset.ASCENT, BaselineOffset.LINE_HEIGHT);
+			return _firstBaselineOffsetProperty;
+		}
+
+		/** @private */
+		static private var _verticalAlignProperty:Property;
+
+		static public function get verticalAlignProperty():Property
+		{
+			if (!_verticalAlignProperty)
+				_verticalAlignProperty = PropertyFactory.enumString("verticalAlign", VerticalAlign.TOP, false, Vector.<String>([Category.CONTAINER, Category.TABLECELL, Category.TABLE, Category.TABLEROW, Category.TABLECOLUMN]), VerticalAlign.TOP, VerticalAlign.MIDDLE, VerticalAlign.BOTTOM, VerticalAlign.JUSTIFY);
+			return _verticalAlignProperty;
+		}
+
+		/** @private */
+		static private var _blockProgressionProperty:Property;
+
+		static public function get blockProgressionProperty():Property
+		{
+			if (!_blockProgressionProperty)
+				_blockProgressionProperty = PropertyFactory.enumString("blockProgression", BlockProgression.TB, true, Vector.<String>([Category.CONTAINER]), BlockProgression.RL, BlockProgression.TB);
+			return _blockProgressionProperty;
+		}
+
+		/** @private */
+		static private var _lineBreakProperty:Property;
+
+		static public function get lineBreakProperty():Property
+		{
+			if (!_lineBreakProperty)
+				_lineBreakProperty = PropertyFactory.enumString("lineBreak", LineBreak.TO_FIT, false, Vector.<String>([Category.CONTAINER, Category.TABLECELL]), LineBreak.EXPLICIT, LineBreak.TO_FIT);
+			return _lineBreakProperty;
+		}
+
+		/** @private */
+		static private var _listStyleTypeProperty:Property;
+
+		static public function get listStyleTypeProperty():Property
+		{
+			if (!_listStyleTypeProperty)
+				_listStyleTypeProperty = PropertyFactory.enumString("listStyleType", ListStyleType.DISC, true, Vector.<String>([Category.LIST]), ListStyleType.UPPER_ALPHA, ListStyleType.LOWER_ALPHA, ListStyleType.UPPER_ROMAN, ListStyleType.LOWER_ROMAN, ListStyleType.NONE, ListStyleType.DISC, ListStyleType.CIRCLE, ListStyleType.SQUARE, ListStyleType.BOX, ListStyleType.CHECK, ListStyleType.DIAMOND, ListStyleType.HYPHEN, ListStyleType.ARABIC_INDIC, ListStyleType.BENGALI, ListStyleType.DECIMAL, ListStyleType.DECIMAL_LEADING_ZERO, ListStyleType.DEVANAGARI, ListStyleType.GUJARATI, ListStyleType.GURMUKHI, ListStyleType.KANNADA, ListStyleType.PERSIAN, ListStyleType.THAI, ListStyleType.URDU, ListStyleType.CJK_EARTHLY_BRANCH, ListStyleType.CJK_HEAVENLY_STEM, ListStyleType.HANGUL, ListStyleType.HANGUL_CONSTANT, ListStyleType.HIRAGANA, ListStyleType.HIRAGANA_IROHA, ListStyleType.KATAKANA, ListStyleType.KATAKANA_IROHA, ListStyleType.LOWER_ALPHA, ListStyleType.LOWER_GREEK, ListStyleType.LOWER_LATIN, ListStyl
 eType.UPPER_ALPHA, ListStyleType.UPPER_GREEK, ListStyleType.UPPER_LATIN);
+			return _listStyleTypeProperty;
+		}
+
+		/** @private */
+		static private var _listStylePositionProperty:Property;
+
+		static public function get listStylePositionProperty():Property
+		{
+			if (!_listStylePositionProperty)
+				_listStylePositionProperty = PropertyFactory.enumString("listStylePosition", ListStylePosition.OUTSIDE, true, Vector.<String>([Category.LIST]), ListStylePosition.INSIDE, ListStylePosition.OUTSIDE);
+			return _listStylePositionProperty;
+		}
+
+		/** @private */
+		static private var _listAutoPaddingProperty:Property;
+
+		static public function get listAutoPaddingProperty():Property
+		{
+			if (!_listAutoPaddingProperty)
+				_listAutoPaddingProperty = PropertyFactory.number("listAutoPadding", 40, true, Vector.<String>([Category.CONTAINER]), -1000, 1000);
+			return _listAutoPaddingProperty;
+		}
+
+		/** @private */
+		static private var _clearFloatsProperty:Property;
+
+		static public function get clearFloatsProperty():Property
+		{
+			if (!_clearFloatsProperty)
+				_clearFloatsProperty = PropertyFactory.enumString("clearFloats", ClearFloats.NONE, false, Vector.<String>([Category.PARAGRAPH]), ClearFloats.START, ClearFloats.END, ClearFloats.LEFT, ClearFloats.RIGHT, ClearFloats.BOTH, ClearFloats.NONE);
+			return _clearFloatsProperty;
+		}
+
+		/** @private */
+		static private var _styleNameProperty:Property;
+
+		static public function get styleNameProperty():Property
+		{
+			if (!_styleNameProperty)
+				_styleNameProperty = PropertyFactory.string("styleName", null, false, Vector.<String>([Category.STYLE]));
+			return _styleNameProperty;
+		}
+
+		/** @private */
+		static private var _linkNormalFormatProperty:Property;
+
+		static public function get linkNormalFormatProperty():Property
+		{
+			if (!_linkNormalFormatProperty)
+				_linkNormalFormatProperty = PropertyFactory.tlfProp("linkNormalFormat", null, true, Vector.<String>([Category.STYLE]));
+			return _linkNormalFormatProperty;
+		}
+
+		/** @private */
+		static private var _linkActiveFormatProperty:Property;
+
+		static public function get linkActiveFormatProperty():Property
+		{
+			if (!_linkActiveFormatProperty)
+				_linkActiveFormatProperty = PropertyFactory.tlfProp("linkActiveFormat", null, true, Vector.<String>([Category.STYLE]));
+			return _linkActiveFormatProperty;
+		}
+
+		/** @private */
+		static private var _linkHoverFormatProperty:Property;
+
+		static public function get linkHoverFormatProperty():Property
+		{
+			if (!_linkHoverFormatProperty)
+				_linkHoverFormatProperty = PropertyFactory.tlfProp("linkHoverFormat", null, true, Vector.<String>([Category.STYLE]));
+			return _linkHoverFormatProperty;
+		}
+
+		/** @private */
+		static private var _listMarkerFormatProperty:Property;
+
+		static public function get listMarkerFormatProperty():Property
+		{
+			if (!_listMarkerFormatProperty)
+				_listMarkerFormatProperty = PropertyFactory.listMarkerFormatProp("listMarkerFormat", null, true, Vector.<String>([Category.STYLE]));
+			return _listMarkerFormatProperty;
+		}
+
+		/** @private */
+		static private var _borderLeftWidthProperty:Property;
+
+		static public function get borderLeftWidthProperty():Property
+		{
+			if (!_borderLeftWidthProperty)
+				_borderLeftWidthProperty = PropertyFactory.number("borderLeftWidth", 0, false, Vector.<String>([Category.CONTAINER, Category.PARAGRAPH]), 0, 128);
+			return _borderLeftWidthProperty;
+		}
+
+		/** @private */
+		static private var _borderRightWidthProperty:Property;
+
+		static public function get borderRightWidthProperty():Property
+		{
+			if (!_borderRightWidthProperty)
+				_borderRightWidthProperty = PropertyFactory.number("borderRightWidth", 0, false, Vector.<String>([Category.CONTAINER, Category.PARAGRAPH]), 0, 128);
+			return _borderRightWidthProperty;
+		}
+
+		/** @private */
+		static private var _borderTopWidthProperty:Property;
+
+		static public function get borderTopWidthProperty():Property
+		{
+			if (!_borderTopWidthProperty)
+				_borderTopWidthProperty = PropertyFactory.number("borderTopWidth", 0, false, Vector.<String>([Category.CONTAINER, Category.PARAGRAPH]), 0, 128);
+			return _borderTopWidthProperty;
+		}
+
+		/** @private */
+		static private var _borderBottomWidthProperty:Property;
+
+		static public function get borderBottomWidthProperty():Property
+		{
+			if (!_borderBottomWidthProperty)
+				_borderBottomWidthProperty = PropertyFactory.number("borderBottomWidth", 0, false, Vector.<String>([Category.CONTAINER, Category.PARAGRAPH]), 0, 128);
+			return _borderBottomWidthProperty;
+		}
+
+		/** @private */
+		static private var _borderLeftColorProperty:Property;
+
+		static public function get borderLeftColorProperty():Property
+		{
+			if (!_borderLeftColorProperty)
+				_borderLeftColorProperty = PropertyFactory.uintOrEnum("borderLeftColor", BorderColor.TRANSPARENT, false, Vector.<String>([Category.CONTAINER, Category.PARAGRAPH]), BorderColor.TRANSPARENT);
+			return _borderLeftColorProperty;
+		}
+
+		/** @private */
+		static private var _borderRightColorProperty:Property;
+
+		static public function get borderRightColorProperty():Property
+		{
+			if (!_borderRightColorProperty)
+				_borderRightColorProperty = PropertyFactory.uintOrEnum("borderRightColor", BorderColor.TRANSPARENT, false, Vector.<String>([Category.CONTAINER, Category.PARAGRAPH]), BorderColor.TRANSPARENT);
+			return _borderRightColorProperty;
+		}
+
+		/** @private */
+		static private var _borderTopColorProperty:Property;
+
+		static public function get borderTopColorProperty():Property
+		{
+			if (!_borderTopColorProperty)
+				_borderTopColorProperty = PropertyFactory.uintOrEnum("borderTopColor", BorderColor.TRANSPARENT, false, Vector.<String>([Category.CONTAINER, Category.PARAGRAPH]), BorderColor.TRANSPARENT);
+			return _borderTopColorProperty;
+		}
+
+		/** @private */
+		static private var _borderBottomColorProperty:Property;
+
+		static public function get borderBottomColorProperty():Property
+		{
+			if (!_borderBottomColorProperty)
+				_borderBottomColorProperty = PropertyFactory.uintOrEnum("borderBottomColor", BorderColor.TRANSPARENT, false, Vector.<String>([Category.CONTAINER, Category.PARAGRAPH]), BorderColor.TRANSPARENT);
+			return _borderBottomColorProperty;
+		}
+
+		/** @private */
+		static private var _borderLeftPriorityProperty:Property;
+
+		static public function get borderLeftPriorityProperty():Property
+		{
+			if (!_borderLeftPriorityProperty)
+				_borderLeftPriorityProperty = PropertyFactory.number("borderLeftPriority", 0, false, Vector.<String>([Category.TABLE, Category.TABLECELL, Category.TABLECOLUMN, Category.TABLEROW]), -8000, 8000);
+			return _borderLeftPriorityProperty;
+		}
+
+		/** @private */
+		static private var _borderRightPriorityProperty:Property;
+
+		static public function get borderRightPriorityProperty():Property
+		{
+			if (!_borderRightPriorityProperty)
+				_borderRightPriorityProperty = PropertyFactory.number("borderRightPriority", 0, false, Vector.<String>([Category.TABLE, Category.TABLECELL, Category.TABLECOLUMN, Category.TABLEROW]), -8000, 8000);
+			return _borderRightPriorityProperty;
+		}
+
+		/** @private */
+		static private var _borderTopPriorityProperty:Property;
+
+		static public function get borderTopPriorityProperty():Property
+		{
+			if (!_borderTopPriorityProperty)
+				_borderTopPriorityProperty = PropertyFactory.number("borderTopPriority", 0, false, Vector.<String>([Category.TABLE, Category.TABLECELL, Category.TABLECOLUMN, Category.TABLEROW]), -8000, 8000);
+			return _borderTopPriorityProperty;
+		}
+
+		/** @private */
+		static private var _borderBottomPriorityProperty:Property;
+
+		static public function get borderBottomPriorityProperty():Property
+		{
+			if (!_borderBottomPriorityProperty)
+				_borderBottomPriorityProperty = PropertyFactory.number("borderBottomPriority", 0, false, Vector.<String>([Category.TABLE, Category.TABLECELL, Category.TABLECOLUMN, Category.TABLEROW]), -8000, 8000);
+			return _borderBottomPriorityProperty;
+		}
+
+		/** @private */
+		static private var _marginLeftProperty:Property;
+
+		static public function get marginLeftProperty():Property
+		{
+			if (!_marginLeftProperty)
+				_marginLeftProperty = PropertyFactory.number("marginLeft", 0, false, Vector.<String>([Category.CONTAINER, Category.PARAGRAPH]), -8000, 8000);
+			return _marginLeftProperty;
+		}
+
+		/** @private */
+		static private var _marginRightProperty:Property;
+
+		static public function get marginRightProperty():Property
+		{
+			if (!_marginRightProperty)
+				_marginRightProperty = PropertyFactory.number("marginRight", 0, false, Vector.<String>([Category.CONTAINER, Category.PARAGRAPH]), -8000, 8000);
+			return _marginRightProperty;
+		}
+
+		/** @private */
+		static private var _marginTopProperty:Property;
+
+		static public function get marginTopProperty():Property
+		{
+			if (!_marginTopProperty)
+				_marginTopProperty = PropertyFactory.number("marginTop", 0, false, Vector.<String>([Category.CONTAINER, Category.PARAGRAPH]), -8000, 8000);
+			return _marginTopProperty;
+		}
+
+		/** @private */
+		static private var _marginBottomProperty:Property;
+
+		static public function get marginBottomProperty():Property
+		{
+			if (!_marginBottomProperty)
+				_marginBottomProperty = PropertyFactory.number("marginBottom", 0, false, Vector.<String>([Category.CONTAINER, Category.PARAGRAPH]), -8000, 8000);
+			return _marginBottomProperty;
+		}
+
+		/** @private */
+		static private var _cellSpacingProperty:Property;
+
+		static public function get cellSpacingProperty():Property
+		{
+			if (!_cellSpacingProperty)
+				_cellSpacingProperty = PropertyFactory.number("cellSpacing", 0, false, Vector.<String>([Category.TABLE]), 0, 1000);
+			return _cellSpacingProperty;
+		}
+
+		/** @private */
+		static private var _cellPaddingProperty:Property;
+
+		static public function get cellPaddingProperty():Property
+		{
+			if (!_cellPaddingProperty)
+				_cellPaddingProperty = PropertyFactory.numPercent("cellPadding", 0, true, Vector.<String>([Category.TABLE]), 0, 1000, "0%", "100%");
+			return _cellPaddingProperty;
+		}
+
+		/** @private */
+		static private var _tableWidthProperty:Property;
+
+		static public function get tableWidthProperty():Property
+		{
+			if (!_tableWidthProperty)
+				_tableWidthProperty = PropertyFactory.numPercent("tableWidth", "100%", false, Vector.<String>([Category.TABLE]), 0, 8000, "0%", "100%");
+			return _tableWidthProperty;
+		}
+
+		/** @private */
+		static private var _tableColumnWidthProperty:Property;
+
+		static public function get tableColumnWidthProperty():Property
+		{
+			if (!_tableColumnWidthProperty)
+				_tableColumnWidthProperty = PropertyFactory.numPercent("tableColumnWidth", 0, false, Vector.<String>([Category.TABLECOLUMN]), 0, 8000, "0%", "100%");
+			return _tableColumnWidthProperty;
+		}
+
+		/** @private */
+		static private var _minCellHeightProperty:Property;
+
+		static public function get minCellHeightProperty():Property
+		{
+			if (!_minCellHeightProperty)
+				_minCellHeightProperty = PropertyFactory.numEnum("minCellHeight", 2, false, Vector.<String>([Category.TABLE, Category.TABLECELL]), 2, 8000);
+			return _minCellHeightProperty;
+		}
+
+		/** @private */
+		static private var _maxCellHeightProperty:Property;
+
+		static public function get maxCellHeightProperty():Property
+		{
+			if (!_maxCellHeightProperty)
+				_maxCellHeightProperty = PropertyFactory.numEnum("maxCellHeight", 8000, false, Vector.<String>([Category.TABLE, Category.TABLECELL]), 2, 8000);
+			return _maxCellHeightProperty;
+		}
+
+		/** @private */
+		static private var _frameProperty:Property;
+
+		static public function get frameProperty():Property
+		{
+			if (!_frameProperty)
+				_frameProperty = PropertyFactory.enumString("frame", TableFrame.VOID, false, Vector.<String>([Category.TABLE]), TableFrame.VOID, TableFrame.ABOVE, TableFrame.BELOW, TableFrame.HSIDES, TableFrame.VSIDES, TableFrame.LHS, TableFrame.RHS, TableFrame.BOX, TableFrame.BORDER);
+			return _frameProperty;
+		}
+
+		/** @private */
+		static private var _rulesProperty:Property;
+
+		static public function get rulesProperty():Property
+		{
+			if (!_rulesProperty)
+				_rulesProperty = PropertyFactory.enumString("rules", TableRules.NONE, false, Vector.<String>([Category.TABLE]), TableRules.NONE, TableRules.GROUPS, TableRules.ROWS, TableRules.COLS, TableRules.ALL);
+			return _rulesProperty;
+		}
+
+		static private var _description:Object;
+
+		/** Property descriptions accessible by name. @private */
+		static public function get description():Object
+		{
+			if (!_description)
+			{
+				_description  = {
+					columnBreakBefore:columnBreakBeforeProperty
+					, columnBreakAfter:columnBreakAfterProperty
+					, containerBreakBefore:containerBreakBeforeProperty
+					, containerBreakAfter:containerBreakAfterProperty
+					, color:colorProperty
+					, backgroundColor:backgroundColorProperty
+					, lineThrough:lineThroughProperty
+					, textAlpha:textAlphaProperty
+					, backgroundAlpha:backgroundAlphaProperty
+					, fontSize:fontSizeProperty
+					, baselineShift:baselineShiftProperty
+					, trackingLeft:trackingLeftProperty
+					, trackingRight:trackingRightProperty
+					, lineHeight:lineHeightProperty
+					, breakOpportunity:breakOpportunityProperty
+					, digitCase:digitCaseProperty
+					, digitWidth:digitWidthProperty
+					, dominantBaseline:dominantBaselineProperty
+					, kerning:kerningProperty
+					, ligatureLevel:ligatureLevelProperty
+					, alignmentBaseline:alignmentBaselineProperty
+					, locale:localeProperty
+					, typographicCase:typographicCaseProperty
+					, fontFamily:fontFamilyProperty
+					, textDecoration:textDecorationProperty
+					, fontWeight:fontWeightProperty
+					, fontStyle:fontStyleProperty
+					, whiteSpaceCollapse:whiteSpaceCollapseProperty
+					, renderingMode:renderingModeProperty
+					, cffHinting:cffHintingProperty
+					, fontLookup:fontLookupProperty
+					, textRotation:textRotationProperty
+					, textIndent:textIndentProperty
+					, paragraphStartIndent:paragraphStartIndentProperty
+					, paragraphEndIndent:paragraphEndIndentProperty
+					, paragraphSpaceBefore:paragraphSpaceBeforeProperty
+					, paragraphSpaceAfter:paragraphSpaceAfterProperty
+					, textAlign:textAlignProperty
+					, textAlignLast:textAlignLastProperty
+					, textJustify:textJustifyProperty
+					, justificationRule:justificationRuleProperty
+					, justificationStyle:justificationStyleProperty
+					, direction:directionProperty
+					, wordSpacing:wordSpacingProperty
+					, tabStops:tabStopsProperty
+					, leadingModel:leadingModelProperty
+					, columnGap:columnGapProperty
+					, paddingLeft:paddingLeftProperty
+					, paddingTop:paddingTopProperty
+					, paddingRight:paddingRightProperty
+					, paddingBottom:paddingBottomProperty
+					, columnCount:columnCountProperty
+					, columnWidth:columnWidthProperty
+					, firstBaselineOffset:firstBaselineOffsetProperty
+					, verticalAlign:verticalAlignProperty
+					, blockProgression:blockProgressionProperty
+					, lineBreak:lineBreakProperty
+					, listStyleType:listStyleTypeProperty
+					, listStylePosition:listStylePositionProperty
+					, listAutoPadding:listAutoPaddingProperty
+					, clearFloats:clearFloatsProperty
+					, styleName:styleNameProperty
+					, linkNormalFormat:linkNormalFormatProperty
+					, linkActiveFormat:linkActiveFormatProperty
+					, linkHoverFormat:linkHoverFormatProperty
+					, listMarkerFormat:listMarkerFormatProperty
+					, borderLeftWidth:borderLeftWidthProperty
+					, borderRightWidth:borderRightWidthProperty
+					, borderTopWidth:borderTopWidthProperty
+					, borderBottomWidth:borderBottomWidthProperty
+					, borderLeftColor:borderLeftColorProperty
+					, borderRightColor:borderRightColorProperty
+					, borderTopColor:borderTopColorProperty
+					, borderBottomColor:borderBottomColorProperty
+					, marginLeft:marginLeftProperty
+					, marginRight:marginRightProperty
+					, marginTop:marginTopProperty
+					, marginBottom:marginBottomProperty
+					, cellSpacing:cellSpacingProperty
+					, cellPadding:cellPaddingProperty
+					, tableWidth:tableWidthProperty
+					, tableColumnWidth:tableColumnWidthProperty
+					, frame:frameProperty
+					, rules:rulesProperty
+					, borderLeftPriority:borderLeftPriorityProperty
+					, borderRightPriority:borderRightPriorityProperty
+					, borderTopPriority:borderTopPriorityProperty
+					, borderBottomPriority:borderBottomPriorityProperty
+					, minCellHeight:minCellHeightProperty
+					, maxCellHeight:maxCellHeightProperty
+				};
+			}
+			return _description;
+		}
+
+		/** @private */
+		static private var _emptyTextLayoutFormat:ITextLayoutFormat;
+
+		/**
+		 * Returns an ITextLayoutFormat instance with all properties set to <code>undefined</code>.
+		 * @private
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		static public function get emptyTextLayoutFormat():ITextLayoutFormat
+		{
+			if (_emptyTextLayoutFormat == null)
+				_emptyTextLayoutFormat = new TextLayoutFormat();
+			return _emptyTextLayoutFormat;
+		}
+
+		private static const _emptyStyles:Object = {};
+		/** _styles is never null */
+		private var _styles:Object;
+		private var _sharedStyles:Boolean;
+
+		/**
+		 * Creates a new TextLayoutFormat object. All settings are empty or, optionally, are initialized from the
+		 * supplied <code>initialValues</code> object.
+		 * 
+		 * @param initialValues optional instance from which to copy initial values.
+		 * 
+		 * @see #defaultFormat
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function TextLayoutFormat(initialValues:ITextLayoutFormat = null)
+		{
+			this.copy(initialValues);
+		}
+
+		private function writableStyles():void
+		{
+			if (_sharedStyles)
+			{
+				_styles = _styles == _emptyStyles ? {} : PropertyUtil.createObjectWithPrototype(_styles);
+				_sharedStyles = false;
+			}
+		}
+
+		/** @private Returns the internal styles object. */
+		public function getStyles():Object
+		{
+			return _styles == _emptyStyles ? null : _styles;
+		}
+
+		/** @private */
+		public function setStyles(val:Object, shared:Boolean):void
+		{
+			CONFIG::debug
+			{
+				assert(val, "BAD setStyles call"); }
+			if (_styles != val)
+			{
+				_styles = val;
+				_sharedStyles = shared;
+			}
+		}
+
+		/** @private */
+		public function clearStyles():void
+		{
+			_styles = _emptyStyles;
+			_sharedStyles = true;
+		}
+
+		/** Returns the <code>coreStyles</code> on this TextLayoutFormat.  
+		 * The coreStyles object includes the formats that are defined by TextLayoutFormat and are in TextLayoutFormat.description. The
+		 * returned <code>coreStyles</code> object consists of an array of <em>stylename-value</em> pairs.
+		 * 
+		 * @see org.apache.flex.textLayout.formats.TextLayoutFormat
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get coreStyles():Object
+		{
+			return _styles == _emptyStyles ? null : PropertyUtil.shallowCopyInFilter(_styles, description);
+		}
+
+		/** Returns the <code>userStyles</code> on this TextLayoutFormat.  
+		 * The userStyles object includes the formats that are defined by TextLayoutFormat and are not in TextLayoutFormat.description. The
+		 * returned <code>userStyles</code> object consists of an array of <em>stylename-value</em> pairs.
+		 * 
+		 * @see org.apache.flex.textLayout.formats.TextLayoutFormat
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get userStyles():Object
+		{
+			return _styles == _emptyStyles ? null : PropertyUtil.shallowCopyNotInFilter(_styles, description);
+		}
+
+		/** Returns the styles on this TextLayoutFormat.  Note that the getter makes a copy of the  
+		 * styles dictionary. The coreStyles object encapsulates all styles set in the format property including core and user styles. The
+		 * returned object consists of an array of <em>stylename-value</em> pairs.
+		 * 
+		 * @see org.apache.flex.textLayout.formats.TextLayoutFormat
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get styles():Object
+		{
+			return _styles == _emptyStyles ? null : PropertyUtil.shallowCopy(_styles);
+		}
+
+		/** @private */
+		public function setStyleByName(name:String, newValue:*):void
+		{
+			writableStyles();
+
+			if (newValue !== undefined)
+				_styles[name] = newValue;
+			else
+			{
+				delete _styles[name];
+				if (_styles[name] !== undefined)
+				{
+					_styles = PropertyUtil.shallowCopy(_styles);
+					delete _styles[name];
+				}
+			}
+		}
+
+		/** Intentionally hidden so that overriders can override individual property setters */
+		private function setStyleByProperty(styleProp:Property, newValue:*):void
+		{
+			var name:String = styleProp.name;
+			newValue = styleProp.setHelper(_styles[name], newValue);
+			setStyleByName(name, newValue);
+		}
+
+		/** Sets the style specified by the <code>styleProp</code> parameter to the value specified by the
+		 * <code>newValue</code> parameter. 
+		 *
+		 * @param styleProp The name of the style to set.
+		 * @param newValue The value to which to set the style.
+		 *.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+
+		 */
+		public function setStyle(styleProp:String, newValue:*):void
+		{
+			/** redirect to existing property setters for overriders*/
+			if (description.hasOwnProperty(styleProp))
+				this[styleProp] = newValue;
+			else
+				setStyleByName(styleProp, newValue);
+		}
+
+		/** Returns the value of the style specified by the <code>styleProp</code> parameter, which specifies
+		 * the style name.
+		 *
+		 * @param styleProp The name of the style whose value is to be retrieved.
+		 *
+		 * @return The value of the specified style. The type varies depending on the type of the style being
+		 * accessed. Returns <code>undefined</code> if the style is not set.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function getStyle(styleProp:String):*
+		{
+			return _styles[styleProp];
+		}
+
+		/**
+		 * Copies TextLayoutFormat settings from the <code>values</code> ITextLayoutFormat instance into this TextLayoutFormat object.
+		 * If <code>values</code> is <code>null</code>, this TextLayoutFormat object is initialized with undefined values for all properties.
+		 * @param values optional instance from which to copy values.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function copy(incoming:ITextLayoutFormat):void
+		{
+			if (this == incoming)
+				return;
+			var holder:TextLayoutFormat = incoming as TextLayoutFormat;
+			if (holder)
+			{
+				_styles = holder._styles;
+				_sharedStyles = true;
+				holder._sharedStyles = true;
+				return;
+			}
+
+			_styles = _emptyStyles;
+			_sharedStyles = true;
+
+			if (incoming)
+			{
+				for each (var prop:Property in TextLayoutFormat.description)
+				{
+					var val:* = incoming[prop.name];
+					if (val !== undefined)
+						this[prop.name] = val;
+				}
+			}
+		}
+
+		/**
+		 * Concatenates the values of properties in the <code>incoming</code> ITextLayoutFormat instance
+		 * with the values of this TextLayoutFormat object. In this (the receiving) TextLayoutFormat object, properties whose values are <code>FormatValue.INHERIT</code>,
+		 * and inheriting properties whose values are <code>undefined</code> will get new values from the <code>incoming</code> object.
+		 * Non-inheriting properties whose values are <code>undefined</code> will get their default values.
+		 * All other property values will remain unmodified.
+		 * 
+		 * @param incoming instance from which values are concatenated.
+		 * @see org.apache.flex.textLayout.formats.FormatValue#INHERIT
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function concat(incoming:ITextLayoutFormat):void
+		{
+			var holder:TextLayoutFormat = incoming as TextLayoutFormat;
+			var prop:Property;
+			if (holder)
+			{
+				var holderStyles:Object = holder._styles;
+				for (var key:String in holderStyles)
+				{
+					prop = description[key];
+					if (prop)
+						setStyleByProperty(prop, prop.concatHelper(_styles[key], holderStyles[key]));
+					else
+						setStyleByName(key, PropertyUtil.defaultConcatHelper(_styles[key], holderStyles[key]));
+				}
+				return;
+			}
+
+			// Ignores userStyles
+			for each (prop in TextLayoutFormat.description)
+			{
+				setStyleByProperty(prop, prop.concatHelper(_styles[prop.name], incoming[prop.name]));
+			}
+		}
+
+		/**
+		 * Concatenates the values of properties in the <code>incoming</code> ITextLayoutFormat instance
+		 * with the values of this TextLayoutFormat object. In this (the receiving) TextLayoutFormat object, properties whose values are <code>FormatValue.INHERIT</code>,
+		 * and inheriting properties whose values are <code>undefined</code> will get new values from the <code>incoming</code> object.
+		 * All other property values will remain unmodified.
+		 * 
+		 * @param incoming instance from which values are concatenated.
+		 * @see org.apache.flex.textLayout.formats.FormatValue#INHERIT
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function concatInheritOnly(incoming:ITextLayoutFormat):void
+		{
+			var holder:TextLayoutFormat = incoming as TextLayoutFormat;
+			var prop:Property;
+
+			if (holder)
+			{
+				var holderStyles:Object = holder._styles;
+				for (var key:String in holderStyles)
+				{
+					prop = description[key];
+					if (prop)
+						setStyleByProperty(prop, prop.concatInheritOnlyHelper(_styles[key], holderStyles[key]));
+					else
+						setStyleByName(key, PropertyUtil.defaultConcatHelper(_styles[key], holderStyles[key]));
+				}
+				return;
+			}
+
+			// Ignores userStyles
+			for each (prop in TextLayoutFormat.description)
+			{
+				setStyleByProperty(prop, prop.concatInheritOnlyHelper(_styles[prop.name], incoming[prop.name]));
+			}
+		}
+
+		/**
+		 * Replaces property values in this TextLayoutFormat object with the values of properties that are set in
+		 * the <code>incoming</code> ITextLayoutFormat instance. Properties that are <code>undefined</code> in the <code>incoming</code>
+		 * ITextLayoutFormat instance are not changed in this object.
+		 * 
+		 * @param incoming instance whose property values are applied to this TextLayoutFormat object.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function apply(incoming:ITextLayoutFormat):void
+		{
+			var holder:TextLayoutFormat = incoming as TextLayoutFormat;
+			var val:*;
+
+			if (holder)
+			{
+				var holderStyles:Object = holder._styles;
+				for (var key:String in holderStyles)
+				{
+					CONFIG::debug
+					{
+						assert(holderStyles[key] !== undefined, "bad value in apply"); }
+					val = holderStyles[key];
+					if (val !== undefined)
+						setStyle(key, val);
+				}
+				return;
+			}
+
+			for each (var prop:Property in TextLayoutFormat.description)
+			{
+				var name:String = prop.name;
+				val = incoming[name];
+				if (val !== undefined)
+					setStyle(name, val);
+			}
+		}
+
+		/**
+		 * Compares properties in ITextLayoutFormat instance <code>p1</code> with properties in ITextLayoutFormat instance <code>p2</code>
+		 * and returns <code>true</code> if all properties match.
+		 * 
+		 * @param p1 instance to compare to <code>p2</code>.
+		 * @param p2 instance to compare to <code>p1</code>.
+		 * 
+		 * @return true if all properties match, false otherwise.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		static public function isEqual(p1:ITextLayoutFormat, p2:ITextLayoutFormat):Boolean
+		{
+			if (p1 == null)
+				p1 = emptyTextLayoutFormat;
+			if (p2 == null)
+				p2 = emptyTextLayoutFormat;
+			if (p1 == p2)
+				return true;
+			var p1Holder:TextLayoutFormat = p1 as TextLayoutFormat;
+			var p2Holder:TextLayoutFormat = p2 as TextLayoutFormat;
+			if (p1Holder && p2Holder)
+				return PropertyUtil.equalStyles(p1Holder.getStyles(), p2Holder.getStyles(), TextLayoutFormat.description);
+
+			for each (var prop:Property in TextLayoutFormat.description)
+			{
+				if (!prop.equalHelper(p1[prop.name], p2[prop.name]))
+					return false;
+			}
+
+			return true;
+		}
+
+		/**
+		 * Sets properties in this TextLayoutFormat object to <code>undefined</code> if they match those in the <code>incoming</code>
+		 * ITextLayoutFormat instance.
+		 * 
+		 * @param incoming instance against which to compare this TextLayoutFormat object's property values.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function removeMatching(incoming:ITextLayoutFormat):void
+		{
+			if (incoming == null)
+				return;
+
+			var prop:Property;
+			var holder:TextLayoutFormat = incoming as TextLayoutFormat;
+			if (holder)
+			{
+				var holderStyles:Object = holder._styles;
+				for (var key:String in holderStyles)
+				{
+					prop = description[key];
+					if (prop)
+					{
+						if (prop.equalHelper(_styles[key], holderStyles[key]))
+							this[key] = undefined;
+					}
+					else if (_styles[key] == holderStyles[key])
+						setStyle(key, undefined);
+				}
+				return;
+			}
+
+			// ignore userStyles
+			for each (prop in TextLayoutFormat.description)
+			{
+				if (prop.equalHelper(_styles[prop.name], incoming[prop.name]))
+					this[prop.name] = undefined;
+			}
+		}
+
+		/**
+		 * Sets properties in this TextLayoutFormat object to <code>undefined</code> if they do not match those in the
+		 * <code>incoming</code> ITextLayoutFormat instance.
+		 * 
+		 * @param incoming instance against which to compare this TextLayoutFormat object's property values.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function removeClashing(incoming:ITextLayoutFormat):void
+		{
+			if (incoming == null)
+				return;
+
+			var prop:Property;
+			var holder:TextLayoutFormat = incoming as TextLayoutFormat;
+			if (holder)
+			{
+				var holderStyles:Object = holder._styles;
+				for (var key:String in holderStyles)
+				{
+					CONFIG::debug
+					{
+						assert(holderStyles[key] !== undefined, "bad value in removeClashing"); }
+					prop = description[key];
+					if (prop)
+					{
+						if (!prop.equalHelper(_styles[key], holderStyles[key]))
+							this[key] = undefined;
+					}
+					else if (_styles[key] != holderStyles[key])
+						setStyle(key, undefined);
+				}
+				return;
+			}
+			for each (prop in TextLayoutFormat.description)
+			{
+				if (!prop.equalHelper(_styles[prop.name], incoming[prop.name]))
+					this[prop.name] = undefined;
+			}
+		}
+
+
+		[Inspectable(enumeration="auto,always,inherit")]
+		/**
+		 * Controls column break before the element.
+		 * <p>Legal values are BreakStyle.AUTO, BreakStyle.ALWAYS, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of BreakStyle.AUTO.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.BreakStyle
+		 */
+		public function get columnBreakBefore():*
+		{
+			return _styles.columnBreakBefore;
+		}
+
+		public function set columnBreakBefore(value:*):void
+		{
+			setStyleByProperty(TextLayoutFormat.columnBreakBeforeProperty, value);
+		}
+
+
+		[Inspectable(enumeration="auto,always,inherit")]
+		/**
+		 * Controls column after before the element.
+		 * <p>Legal values are BreakStyle.AUTO, BreakStyle.ALWAYS, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of BreakStyle.AUTO.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.BreakStyle
+		 */
+		public function get columnBreakAfter():*
+		{
+			return _styles.columnBreakAfter;
+		}
+
+		public function set columnBreakAfter(value:*):void
+		{
+			setStyleByProperty(TextLayoutFormat.columnBreakAfterProperty, value);
+		}
+
+
+		[Inspectable(enumeration="auto,always,inherit")]
+		/**
+		 * Controls container break before the element.
+		 * <p>Legal values are BreakStyle.AUTO, BreakStyle.ALWAYS, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of BreakStyle.AUTO.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.BreakStyle
+		 */
+		public function get containerBreakBefore():*
+		{
+			return _styles.containerBreakBefore;
+		}
+
+		public function set containerBreakBefore(value:*):void
+		{
+			setStyleByProperty(TextLayoutFormat.containerBreakBeforeProperty, value);
+		}
+
+
+		[Inspectable(enumeration="auto,always,inherit")]
+		/**
+		 * Controls container after before the element.
+		 * <p>Legal values are BreakStyle.AUTO, BreakStyle.ALWAYS, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of BreakStyle.AUTO.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.BreakStyle
+		 */
+		public function get containerBreakAfter():*
+		{
+			return _styles.containerBreakAfter;
+		}
+
+		public function set containerBreakAfter(value:*):void
+		{
+			setStyleByProperty(TextLayoutFormat.containerBreakAfterProperty, value);
+		}
+
+		/**
+		 * Color of the text. A hexadecimal number that specifies three 8-bit RGB (red, green, blue) values; for example, 0xFF0000 is red and 0x00FF00 is green. It can also be enum value {BLACK, GREEN, GRAY, BLUE, SILVER, LIME, OLIVE, WHITE, YELLOW, MAROON, NAVY, RED, PURPLE, TEAL, FUCHSIA, AQUA, MAGENTA, CYAN}
+		 * <p>Legal values as a string are ColorName.BLACK, ColorName.GREEN, ColorName.GRAY, ColorName.BLUE, ColorName.SILVER, ColorName.LIME, ColorName.OLIVE, ColorName.WHITE, ColorName.YELLOW, ColorName.MAROON, ColorName.NAVY, ColorName.RED, ColorName.PURPLE, ColorName.TEAL, ColorName.FUCHSIA, ColorName.AQUA, ColorName.MAGENTA, ColorName.CYAN, FormatValue.INHERIT and uints from 0x0 to 0xffffffff.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.ColorName
+		 */
+		public function get color():*
+		{
+			return _styles.color;
+		}
+
+		public function set color(value:*):void
+		{
+			setStyleByProperty(TextLayoutFormat.colorProperty, value);
+		}
+
+		/**
+		 * Background color of the text (adopts default value if undefined during cascade). Can be either the constant value  <code>BackgroundColor.TRANSPARENT</code>, or a hexadecimal value that specifies the three 8-bit RGB (red, green, blue) values; for example, 0xFF0000 is red and 0x00FF00 is green.
+		 * <p>Legal values as a string are BackgroundColor.TRANSPARENT, FormatValue.INHERIT and uints from 0x0 to 0xffffffff.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of BackgroundColor.TRANSPARENT.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.BackgroundColor
+		 */
+		public function get backgroundColor():*
+		{
+			return _styles.backgroundColor;
+		}
+
+		public function set backgroundColor(value:*):void
+		{
+			setStyleByProperty(TextLayoutFormat.backgroundColorProperty, value);
+		}
+
+
+		[Inspectable(enumeration="true,false,inherit")]
+		/**
+		 * If <code>true</code>, applies strikethrough, a line drawn through the middle of the text.
+		 * <p>Legal values are true, false and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of false.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get lineThrough():*
+		{
+			return _styles.lineThrough;
+		}
+
+		public function set lineThrough(value:*):void
+		{
+			setStyleByProperty(TextLayoutFormat.lineThroughProperty, value);
+		}
+
+		/**
+		 * Alpha (transparency) value for the text. A value of 0 is fully transparent, and a value of 1 is fully opaque. Display objects with <code>textAlpha</code> set to 0 are active, even though they are invisible.
+		 * <p>Legal values are numbers from 0 to 1 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of 1.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get textAlpha():*
+		{
+			return _styles.textAlpha;
+		}
+
+		public function set textAlpha(value:*):void
+		{
+			setStyleByProperty(TextLayoutFormat.textAlphaProperty, value);
+		}
+
+		/**
+		 * Alpha (transparency) value for the background (adopts default value if undefined during cascade). A value of 0 is fully transparent, and a value of 1 is fully opaque. Display objects with alpha set to 0 are active, even though they are invisible.
+		 * <p>Legal values are numbers from 0 to 1 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of 1.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get backgroundAlpha():*
+		{
+			return _styles.backgroundAlpha;
+		}
+
+		public function set backgroundAlpha(value:*):void
+		{
+			setStyleByProperty(TextLayoutFormat.backgroundAlphaProperty, value);
+		}
+
+		/**
+		 * The size of the text in pixels.
+		 * <p>Legal values are numbers from 1 to 720 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of 12.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get fontSize():*
+		{
+			return _styles.fontSize;
+		}
+
+		public function set fontSize(value:*):void
+		{
+			setStyleByProperty(TextLayoutFormat.fontSizeProperty, value);
+		}
+
+		/**
+		 * Amount to shift the baseline from the <code>dominantBaseline</code> value. Units are in pixels, or a percentage of <code>fontSize</code> (in which case, enter a string value, like 140%).  Positive values shift the line up for horizontal text (right for vertical) and negative values shift it down for horizontal (left for vertical). 
+		 * <p>Legal values are BaselineShift.SUPERSCRIPT, BaselineShift.SUBSCRIPT, FormatValue.INHERIT.</p>
+		 * <p>Legal values as a number are from -1000 to 1000.</p>
+		 * <p>Legal values as a percent are numbers from -1000 to 1000.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of 0.0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.BaselineShift
+		 */
+		public function get baselineShift():*
+		{
+			return _styles.baselineShift;
+		}
+
+		public function set baselineShift(value:*):void
+		{
+			setStyleByProperty(TextLayoutFormat.baselineShiftProperty, value);
+		}
+
+		/**
+		 * Number in pixels (or percent of <code>fontSize</code>, like 120%) indicating the amount of tracking (manual kerning) to be applied to the left of each character. If kerning is enabled, the <code>trackingLeft</code> value is added to the values in the kerning table for the font. If kerning is disabled, the <code>trackingLeft</code> value is used as a manual kerning value. Supports both positive and negative values. 
+		 * <p>Legal values as a number are from -1000 to 1000.</p>
+		 * <p>Legal values as a percent are numbers from -1000% to 1000%.</p>
+		 * <p>Legal values include FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get trackingLeft():*
+		{
+			return _styles.trackingLeft;
+		}
+
+		public function set trackingLeft(value:*):void
+		{
+			setStyleByProperty(TextLayoutFormat.trackingLeftProperty, value);
+		}
+
+		/**
+		 * Number in pixels (or percent of <code>fontSize</code>, like 120%) indicating the amount of tracking (manual kerning) to be applied to the right of each character.  If kerning is enabled, the <code>trackingRight</code> value is added to the values in the kerning table for the font. If kerning is disabled, the <code>trackingRight</code> value is used as a manual kerning value. Supports both positive and negative values. 
+		 * <p>Legal values as a number are from -1000 to 1000.</p>
+		 * <p>Legal values as a percent are numbers from -1000% to 1000%.</p>
+		 * <p>Legal values include FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get trackingRight():*
+		{
+			return _styles.trackingRight;
+		}
+
+		public function set trackingRight(value:*):void
+		{
+			setStyleByProperty(TextLayoutFormat.trackingRightProperty, value);
+		}
+
+		/**
+		 * Leading controls for the text. The distance from the baseline of the previous or the next line (based on <code>LeadingModel</code>) to the baseline of the current line is equal to the maximum amount of the leading applied to any character in the line. This is either a number or a percent.  If specifying a percent, enter a string value, like 140%.<p><img src='../../../images/textLayout_lineHeight1.jpg' alt='lineHeight1' /><img src='../../../images/textLayout_lineHeight2.jpg' alt='lineHeight2' /></p>
+		 * <p>Legal values as a number are from -720 to 720.</p>
+		 * <p>Legal values as a percent are numbers from -1000% to 1000%.</p>
+		 * <p>Legal values include FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of 120%.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get lineHeight():*
+		{
+			return _styles.lineHeight;
+		}
+
+		public function set lineHeight(value:*):void
+		{
+			setStyleByProperty(TextLayoutFormat.lineHeightProperty, value);
+		}
+
+
+		[Inspectable(enumeration="all,any,auto,none,inherit")]
+		/**
+		 * Controls where lines are allowed to break when breaking wrapping text into multiple lines. Set to <code>BreakOpportunity.AUTO</code> to break text normally. Set to <code>BreakOpportunity.NONE</code> to <em>not</em> break the text unless the text would overrun the measure and there are no other places to break the line. Set to <code>BreakOpportunity.ANY</code> to allow the line to break anywhere, rather than just between words. Set to <code>BreakOpportunity.ALL</code> to have each typographic cluster put on a separate line (useful for text on a path).
+		 * <p>Legal values are BreakOpportunity.ALL, BreakOpportunity.ANY, BreakOpportunity.AUTO, BreakOpportunity.NONE, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of BreakOpportunity.AUTO.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.text.engine.BreakOpportunity
+		 */
+		public function get breakOpportunity():*
+		{
+			return _styles.breakOpportunity;
+		}
+
+		public function set breakOpportunity(value:*):void
+		{
+			setStyleByProperty(TextLayoutFormat.breakOpportunityProperty, value);
+		}
+
+
+		[Inspectable(enumeration="default,lining,oldStyle,inherit")]
+		/**
+		 * The type of digit case used for this text. Setting the value to <code>DigitCase.OLD_STYLE</code> approximates lowercase letterforms with varying ascenders and descenders. The figures are proportionally spaced. This style is only available in selected typefaces, most commonly in a supplemental or expert font. The <code>DigitCase.LINING</code> setting has all-cap height and is typically monospaced to line up in charts.<p><img src='../../../images/textLayout_digitcase.gif' alt='digitCase' /></p>
+		 * <p>Legal values are DigitCase.DEFAULT, DigitCase.LINING, DigitCase.OLD_STYLE, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of DigitCase.DEFAULT.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.text.engine.DigitCase
+		 */
+		public function get digitCase():*
+		{
+			return _styles.digitCase;
+		}
+
+		public function set digitCase(value:*):void
+		{
+			setStyleByProperty(TextLayoutFormat.digitCaseProperty, value);
+		}
+
+
+		[Inspectable(enumeration="default,proportional,tabular,inherit")]
+		/**
+		 * Type of digit width used for this text. This can be <code>DigitWidth.PROPORTIONAL</code>, which looks best for individual numbers, or <code>DigitWidth.TABULAR</code>, which works best for numbers in tables, charts, and vertical rows.<p><img src='../../../images/textLayout_digitwidth.gif' alt='digitWidth' /></p>
+		 * <p>Legal values are DigitWidth.DEFAULT, DigitWidth.PROPORTIONAL, DigitWidth.TABULAR, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of DigitWidth.DEFAULT.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.text.engine.DigitWidth
+		 */
+		public function get digitWidth():*
+		{
+			return _styles.digitWidth;
+		}
+
+		public function set digitWidth(value:*):void
+		{
+			setStyleByProperty(TextLayoutFormat.digitWidthProperty, value);
+		}
+
+
+		[Inspectable(enumeration="auto,roman,ascent,descent,ideographicTop,ideographicCenter,ideographicBottom,inherit")]
+		/**
+		 * Specifies which element baseline snaps to the <code>alignmentBaseline</code> to determine the vertical position of the element on the line. A value of <code>TextBaseline.AUTO</code> selects the dominant baseline based on the <code>locale</code> property of the parent paragraph.  For Japanese and Chinese, the selected baseline value is <code>TextBaseline.IDEOGRAPHIC_CENTER</code>; for all others it is <code>TextBaseline.ROMAN</code>. These baseline choices are determined by the choice of font and the font size.<p><img src='../../../images/textLayout_baselines.jpg' alt='baselines' /></p>
+		 * <p>Legal values are FormatValue.AUTO, TextBaseline.ROMAN, TextBaseline.ASCENT, TextBaseline.DESCENT, TextBaseline.IDEOGRAPHIC_TOP, TextBaseline.IDEOGRAPHIC_CENTER, TextBaseline.IDEOGRAPHIC_BOTTOM, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of FormatValue.AUTO.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.text.engine.TextBaseline
+		 */
+		public function get dominantBaseline():*
+		{
+			return _styles.dominantBaseline;
+		}
+
+		public function set dominantBaseline(value:*):void
+		{
+			setStyleByProperty(TextLayoutFormat.dominantBaselineProperty, value);
+		}
+
+
+		[Inspectable(enumeration="on,off,auto,inherit")]
+		/**
+		 * Kerning adjusts the pixels between certain character pairs to improve readability. Kerning is supported for all fonts with kerning tables.
+		 * <p>Legal values are Kerning.ON, Kerning.OFF, Kerning.AUTO, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of Kerning.AUTO.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.text.engine.Kerning
+		 */
+		public function get kerning():*
+		{
+			return _styles.kerning;
+		}
+
+		public function set kerning(value:*):void
+		{
+			setStyleByProperty(TextLayoutFormat.kerningProperty, value);
+		}
+
+
+		[Inspectable(enumeration="minimum,common,uncommon,exotic,inherit")]
+		/**
+		 * Controls which of the ligatures that are defined in the font may be used in the text. The ligatures that appear for each of these settings is dependent on the font. A ligature occurs where two or more letter-forms are joined as a single glyph. Ligatures usually replace consecutive characters sharing common components, such as the letter pairs 'fi', 'fl', or 'ae'. They are used with both Latin and Non-Latin character sets. The ligatures enabled by the values of the LigatureLevel class - <code>MINIMUM</code>, <code>COMMON</code>, <code>UNCOMMON</code>, and <code>EXOTIC</code> - are additive. Each value enables a new set of ligatures, but also includes those of the previous types.<p><b>Note: </b>When working with Arabic or Syriac fonts, <code>ligatureLevel</code> must be set to MINIMUM or above.</p><p><img src='../../../images/textLayout_ligatures.png' alt='ligatureLevel' /></p>
+		 * <p>Legal values are LigatureLevel.MINIMUM, LigatureLevel.COMMON, LigatureLevel.UNCOMMON, LigatureLevel.EXOTIC, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of LigatureLevel.COMMON.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.text.engine.LigatureLevel
+		 */
+		public function get ligatureLevel():*
+		{
+			return _styles.ligatureLevel;
+		}
+
+		public function set ligatureLevel(value:*):void
+		{
+			setStyleByProperty(TextLayoutFormat.ligatureLevelProperty, value);
+		}
+
+
+		[Inspectable(enumeration="roman,ascent,descent,ideographicTop,ideographicCenter,ideographicBottom,useDominantBaseline,inherit")]
+		/**
+		 * Specifies the baseline to which the dominant baseline aligns. For example, if you set <code>dominantBaseline</code> to ASCENT, setting <code>alignmentBaseline</code> to DESCENT aligns the top of the text with the DESCENT baseline, or below the line.  The largest element in the line generally determines the baselines.<p><img src='../../../images/textLayout_baselines.jpg' alt='baselines' /></p>
+		 * <p>Legal values are TextBaseline.ROMAN, TextBaseline.ASCENT, TextBaseline.DESCENT, TextBaseline.IDEOGRAPHIC_TOP, TextBaseline.IDEOGRAPHIC_CENTER, TextBaseline.IDEOGRAPHIC_BOTTOM, TextBaseline.USE_DOMINANT_BASELINE, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of TextBaseline.USE_DOMINANT_BASELINE.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.text.engine.TextBaseline
+		 */
+		public function get alignmentBaseline():*
+		{
+			return _styles.alignmentBaseline;
+		}
+
+		public function set alignmentBaseline(value:*):void
+		{
+			setStyleByProperty(TextLayoutFormat.alignmentBaselineProperty, value);
+		}
+
+		/**
+		 * The locale of the text. Controls case transformations and shaping. Standard locale identifiers as described in Unicode Technical Standard #35 are used. For example en, en_US and en-US are all English, ja is Japanese. 
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of en.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get locale():*
+		{
+			return _styles.locale;
+		}
+
+		public function set locale(value:*):void
+		{
+			setStyleByProperty(TextLayoutFormat.localeProperty, value);
+		}
+
+
+		[Inspectable(enumeration="default,capsToSmallCaps,uppercase,lowercase,lowercaseToSmallCaps,inherit")]
+		/**
+		 * The type of typographic case used for this text. Here are some examples:<p><img src='../../../images/textLayout_typographiccase.png' alt='typographicCase' /></p>
+		 * <p>Legal values are TLFTypographicCase.DEFAULT, TLFTypographicCase.CAPS_TO_SMALL_CAPS, TLFTypographicCase.UPPERCASE, TLFTypographicCase.LOWERCASE, TLFTypographicCase.LOWERCASE_TO_SMALL_CAPS, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of TLFTypographicCase.DEFAULT.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.TLFTypographicCase
+		 */
+		public function get typographicCase():*
+		{
+			return _styles.typographicCase;
+		}
+
+		public function set typographicCase(value:*):void
+		{
+			setStyleByProperty(TextLayoutFormat.typographicCaseProperty, value);
+		}
+
+		/**
+		 *  The name of the font to use, or a comma-separated list of font names. The Flash runtime renders the element with the first available font in the list. For example Arial, Helvetica, _sans causes the player to search for Arial, then Helvetica if Arial is not found, then _sans if neither is found.
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of Arial.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get fontFamily():*
+		{
+			return _styles.fontFamily;
+		}
+
+		public function set fontFamily(value:*):void
+		{
+			setStyleByProperty(TextLayoutFormat.fontFamilyProperty, value);
+		}
+
+
+		[Inspectable(enumeration="none,underline,inherit")]
+		/**
+		 * Decoration on text. Use to apply underlining; default is none.
+		 * <p>Legal values are TextDecoration.NO

<TRUNCATED>

[09/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/ITextLayoutFormat.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/ITextLayoutFormat.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/ITextLayoutFormat.as
new file mode 100644
index 0000000..3aa8177
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/ITextLayoutFormat.as
@@ -0,0 +1,1388 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.formats
+{
+	/**
+	 * This interface provides read access to FlowElements-related properties.
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	public interface ITextLayoutFormat
+	{
+		/**
+		 * Return the value of the style specified by the <code>styleProp</code> parameter
+		 * which specifies the style name.
+		 * 
+		 * @param styleProp The name of the style whose value is to be retrieved.
+		 * @return The value of the specified style.  The type varies depending on the type of the style being
+		 * accessed.  Returns <code>undefined</code> if the style is not set.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function getStyle(styleName:String):*;
+		/**
+		 * Controls column break before the element.
+		 * <p>Legal values are BreakStyle.AUTO, BreakStyle.ALWAYS, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of BreakStyle.AUTO.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.BreakStyle
+		 */
+		function get columnBreakBefore():*;
+
+		/**
+		 * Controls column after before the element.
+		 * <p>Legal values are BreakStyle.AUTO, BreakStyle.ALWAYS, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of BreakStyle.AUTO.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.BreakStyle
+		 */
+		function get columnBreakAfter():*;
+
+		/**
+		 * Controls container break before the element.
+		 * <p>Legal values are BreakStyle.AUTO, BreakStyle.ALWAYS, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of BreakStyle.AUTO.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.BreakStyle
+		 */
+		function get containerBreakBefore():*;
+
+		/**
+		 * Controls container after before the element.
+		 * <p>Legal values are BreakStyle.AUTO, BreakStyle.ALWAYS, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of BreakStyle.AUTO.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.BreakStyle
+		 */
+		function get containerBreakAfter():*;
+
+		/**
+		 * Color of the text. A hexadecimal number that specifies three 8-bit RGB (red, green, blue) values; for example, 0xFF0000 is red and 0x00FF00 is green. It can also be enum value {BLACK, GREEN, GRAY, BLUE, SILVER, LIME, OLIVE, WHITE, YELLOW, MAROON, NAVY, RED, PURPLE, TEAL, FUCHSIA, AQUA, MAGENTA, CYAN}
+		 * <p>Legal values as a string are ColorName.BLACK, ColorName.GREEN, ColorName.GRAY, ColorName.BLUE, ColorName.SILVER, ColorName.LIME, ColorName.OLIVE, ColorName.WHITE, ColorName.YELLOW, ColorName.MAROON, ColorName.NAVY, ColorName.RED, ColorName.PURPLE, ColorName.TEAL, ColorName.FUCHSIA, ColorName.AQUA, ColorName.MAGENTA, ColorName.CYAN, FormatValue.INHERIT and uints from 0x0 to 0xffffffff.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.ColorName
+		 */
+		function get color():*;
+
+		/**
+		 * Background color of the text (adopts default value if undefined during cascade). Can be either the constant value  <code>BackgroundColor.TRANSPARENT</code>, or a hexadecimal value that specifies the three 8-bit RGB (red, green, blue) values; for example, 0xFF0000 is red and 0x00FF00 is green.
+		 * <p>Legal values as a string are BackgroundColor.TRANSPARENT, FormatValue.INHERIT and uints from 0x0 to 0xffffffff.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of BackgroundColor.TRANSPARENT.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.BackgroundColor
+		 */
+		function get backgroundColor():*;
+
+		/**
+		 * If <code>true</code>, applies strikethrough, a line drawn through the middle of the text.
+		 * <p>Legal values are true, false and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of false.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get lineThrough():*;
+
+		/**
+		 * Alpha (transparency) value for the text. A value of 0 is fully transparent, and a value of 1 is fully opaque. Display objects with <code>textAlpha</code> set to 0 are active, even though they are invisible.
+		 * <p>Legal values are numbers from 0 to 1 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of 1.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get textAlpha():*;
+
+		/**
+		 * Alpha (transparency) value for the background (adopts default value if undefined during cascade). A value of 0 is fully transparent, and a value of 1 is fully opaque. Display objects with alpha set to 0 are active, even though they are invisible.
+		 * <p>Legal values are numbers from 0 to 1 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of 1.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get backgroundAlpha():*;
+
+		/**
+		 * The size of the text in pixels.
+		 * <p>Legal values are numbers from 1 to 720 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of 12.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get fontSize():*;
+
+		/**
+		 * Amount to shift the baseline from the <code>dominantBaseline</code> value. Units are in pixels, or a percentage of <code>fontSize</code> (in which case, enter a string value, like 140%).  Positive values shift the line up for horizontal text (right for vertical) and negative values shift it down for horizontal (left for vertical). 
+		 * <p>Legal values are BaselineShift.SUPERSCRIPT, BaselineShift.SUBSCRIPT, FormatValue.INHERIT.</p>
+		 * <p>Legal values as a number are from -1000 to 1000.</p>
+		 * <p>Legal values as a percent are numbers from -1000 to 1000.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of 0.0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.BaselineShift
+		 */
+		function get baselineShift():*;
+
+		/**
+		 * Number in pixels (or percent of <code>fontSize</code>, like 120%) indicating the amount of tracking (manual kerning) to be applied to the left of each character. If kerning is enabled, the <code>trackingLeft</code> value is added to the values in the kerning table for the font. If kerning is disabled, the <code>trackingLeft</code> value is used as a manual kerning value. Supports both positive and negative values. 
+		 * <p>Legal values as a number are from -1000 to 1000.</p>
+		 * <p>Legal values as a percent are numbers from -1000% to 1000%.</p>
+		 * <p>Legal values include FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get trackingLeft():*;
+
+		/**
+		 * Number in pixels (or percent of <code>fontSize</code>, like 120%) indicating the amount of tracking (manual kerning) to be applied to the right of each character.  If kerning is enabled, the <code>trackingRight</code> value is added to the values in the kerning table for the font. If kerning is disabled, the <code>trackingRight</code> value is used as a manual kerning value. Supports both positive and negative values. 
+		 * <p>Legal values as a number are from -1000 to 1000.</p>
+		 * <p>Legal values as a percent are numbers from -1000% to 1000%.</p>
+		 * <p>Legal values include FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get trackingRight():*;
+
+		/**
+		 * Leading controls for the text. The distance from the baseline of the previous or the next line (based on <code>LeadingModel</code>) to the baseline of the current line is equal to the maximum amount of the leading applied to any character in the line. This is either a number or a percent.  If specifying a percent, enter a string value, like 140%.<p><img src='../../../images/textLayout_lineHeight1.jpg' alt='lineHeight1' /><img src='../../../images/textLayout_lineHeight2.jpg' alt='lineHeight2' /></p>
+		 * <p>Legal values as a number are from -720 to 720.</p>
+		 * <p>Legal values as a percent are numbers from -1000% to 1000%.</p>
+		 * <p>Legal values include FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of 120%.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get lineHeight():*;
+
+		/**
+		 * Controls where lines are allowed to break when breaking wrapping text into multiple lines. Set to <code>BreakOpportunity.AUTO</code> to break text normally. Set to <code>BreakOpportunity.NONE</code> to <em>not</em> break the text unless the text would overrun the measure and there are no other places to break the line. Set to <code>BreakOpportunity.ANY</code> to allow the line to break anywhere, rather than just between words. Set to <code>BreakOpportunity.ALL</code> to have each typographic cluster put on a separate line (useful for text on a path).
+		 * <p>Legal values are BreakOpportunity.ALL, BreakOpportunity.ANY, BreakOpportunity.AUTO, BreakOpportunity.NONE, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of BreakOpportunity.AUTO.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.text.engine.BreakOpportunity
+		 */
+		function get breakOpportunity():*;
+
+		/**
+		 * The type of digit case used for this text. Setting the value to <code>DigitCase.OLD_STYLE</code> approximates lowercase letterforms with varying ascenders and descenders. The figures are proportionally spaced. This style is only available in selected typefaces, most commonly in a supplemental or expert font. The <code>DigitCase.LINING</code> setting has all-cap height and is typically monospaced to line up in charts.<p><img src='../../../images/textLayout_digitcase.gif' alt='digitCase' /></p>
+		 * <p>Legal values are DigitCase.DEFAULT, DigitCase.LINING, DigitCase.OLD_STYLE, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of DigitCase.DEFAULT.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.text.engine.DigitCase
+		 */
+		function get digitCase():*;
+
+		/**
+		 * Type of digit width used for this text. This can be <code>DigitWidth.PROPORTIONAL</code>, which looks best for individual numbers, or <code>DigitWidth.TABULAR</code>, which works best for numbers in tables, charts, and vertical rows.<p><img src='../../../images/textLayout_digitwidth.gif' alt='digitWidth' /></p>
+		 * <p>Legal values are DigitWidth.DEFAULT, DigitWidth.PROPORTIONAL, DigitWidth.TABULAR, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of DigitWidth.DEFAULT.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.text.engine.DigitWidth
+		 */
+		function get digitWidth():*;
+
+		/**
+		 * Specifies which element baseline snaps to the <code>alignmentBaseline</code> to determine the vertical position of the element on the line. A value of <code>TextBaseline.AUTO</code> selects the dominant baseline based on the <code>locale</code> property of the parent paragraph.  For Japanese and Chinese, the selected baseline value is <code>TextBaseline.IDEOGRAPHIC_CENTER</code>; for all others it is <code>TextBaseline.ROMAN</code>. These baseline choices are determined by the choice of font and the font size.<p><img src='../../../images/textLayout_baselines.jpg' alt='baselines' /></p>
+		 * <p>Legal values are FormatValue.AUTO, TextBaseline.ROMAN, TextBaseline.ASCENT, TextBaseline.DESCENT, TextBaseline.IDEOGRAPHIC_TOP, TextBaseline.IDEOGRAPHIC_CENTER, TextBaseline.IDEOGRAPHIC_BOTTOM, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of FormatValue.AUTO.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.text.engine.TextBaseline
+		 */
+		function get dominantBaseline():*;
+
+		/**
+		 * Kerning adjusts the pixels between certain character pairs to improve readability. Kerning is supported for all fonts with kerning tables.
+		 * <p>Legal values are Kerning.ON, Kerning.OFF, Kerning.AUTO, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of Kerning.AUTO.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.text.engine.Kerning
+		 */
+		function get kerning():*;
+
+		/**
+		 * Controls which of the ligatures that are defined in the font may be used in the text. The ligatures that appear for each of these settings is dependent on the font. A ligature occurs where two or more letter-forms are joined as a single glyph. Ligatures usually replace consecutive characters sharing common components, such as the letter pairs 'fi', 'fl', or 'ae'. They are used with both Latin and Non-Latin character sets. The ligatures enabled by the values of the LigatureLevel class - <code>MINIMUM</code>, <code>COMMON</code>, <code>UNCOMMON</code>, and <code>EXOTIC</code> - are additive. Each value enables a new set of ligatures, but also includes those of the previous types.<p><b>Note: </b>When working with Arabic or Syriac fonts, <code>ligatureLevel</code> must be set to MINIMUM or above.</p><p><img src='../../../images/textLayout_ligatures.png' alt='ligatureLevel' /></p>
+		 * <p>Legal values are LigatureLevel.MINIMUM, LigatureLevel.COMMON, LigatureLevel.UNCOMMON, LigatureLevel.EXOTIC, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of LigatureLevel.COMMON.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.text.engine.LigatureLevel
+		 */
+		function get ligatureLevel():*;
+
+		/**
+		 * Specifies the baseline to which the dominant baseline aligns. For example, if you set <code>dominantBaseline</code> to ASCENT, setting <code>alignmentBaseline</code> to DESCENT aligns the top of the text with the DESCENT baseline, or below the line.  The largest element in the line generally determines the baselines.<p><img src='../../../images/textLayout_baselines.jpg' alt='baselines' /></p>
+		 * <p>Legal values are TextBaseline.ROMAN, TextBaseline.ASCENT, TextBaseline.DESCENT, TextBaseline.IDEOGRAPHIC_TOP, TextBaseline.IDEOGRAPHIC_CENTER, TextBaseline.IDEOGRAPHIC_BOTTOM, TextBaseline.USE_DOMINANT_BASELINE, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of TextBaseline.USE_DOMINANT_BASELINE.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.text.engine.TextBaseline
+		 */
+		function get alignmentBaseline():*;
+
+		/**
+		 * The locale of the text. Controls case transformations and shaping. Standard locale identifiers as described in Unicode Technical Standard #35 are used. For example en, en_US and en-US are all English, ja is Japanese. 
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of en.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get locale():*;
+
+		/**
+		 * The type of typographic case used for this text. Here are some examples:<p><img src='../../../images/textLayout_typographiccase.png' alt='typographicCase' /></p>
+		 * <p>Legal values are TLFTypographicCase.DEFAULT, TLFTypographicCase.CAPS_TO_SMALL_CAPS, TLFTypographicCase.UPPERCASE, TLFTypographicCase.LOWERCASE, TLFTypographicCase.LOWERCASE_TO_SMALL_CAPS, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of TLFTypographicCase.DEFAULT.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.TLFTypographicCase
+		 */
+		function get typographicCase():*;
+
+		/**
+		 *  The name of the font to use, or a comma-separated list of font names. The Flash runtime renders the element with the first available font in the list. For example Arial, Helvetica, _sans causes the player to search for Arial, then Helvetica if Arial is not found, then _sans if neither is found.
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of Arial.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get fontFamily():*;
+
+		/**
+		 * Decoration on text. Use to apply underlining; default is none.
+		 * <p>Legal values are TextDecoration.NONE, TextDecoration.UNDERLINE, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of TextDecoration.NONE.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.TextDecoration
+		 */
+		function get textDecoration():*;
+
+
+		/**
+		 * Style of text. 
+		 * <p>Legal values style names specified byt the font.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of "Regular".</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.text.engine.FontPosture
+		 */
+		function get fontStyle():*;
+
+		/**
+		 * Collapses or preserves whitespace when importing text into a TextFlow. <code>WhiteSpaceCollapse.PRESERVE</code> retains all whitespace characters. <code>WhiteSpaceCollapse.COLLAPSE</code> removes newlines, tabs, and leading or trailing spaces within a block of imported text. Line break tags (<br/>) and Unicode line separator characters are retained.
+		 * <p>Legal values are WhiteSpaceCollapse.PRESERVE, WhiteSpaceCollapse.COLLAPSE, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of WhiteSpaceCollapse.COLLAPSE.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.WhiteSpaceCollapse
+		 */
+		function get whiteSpaceCollapse():*;
+
+		/**
+		 * The rendering mode used for this text.  Applies only to embedded fonts (<code>fontLookup</code> property is set to <code>FontLookup.EMBEDDED_CFF</code>).
+		 * <p>Legal values are RenderingMode.NORMAL, RenderingMode.CFF, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of RenderingMode.CFF.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.text.engine.RenderingMode
+		 */
+		function get renderingMode():*;
+
+		/**
+		 * The type of CFF hinting used for this text. CFF hinting determines whether the Flash runtime forces strong horizontal stems to fit to a sub pixel grid or not. This property applies only if the <code>renderingMode</code> property is set to <code>RenderingMode.CFF</code>, and the font is embedded (<code>fontLookup</code> property is set to <code>FontLookup.EMBEDDED_CFF</code>). At small screen sizes, hinting produces a clear, legible text for human readers.
+		 * <p>Legal values are CFFHinting.NONE, CFFHinting.HORIZONTAL_STEM, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of CFFHinting.HORIZONTAL_STEM.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.text.engine.CFFHinting
+		 */
+		function get cffHinting():*;
+
+		/**
+		 * Font lookup to use. Specifying <code>FontLookup.DEVICE</code> uses the fonts installed on the system that is running the SWF file. Device fonts result in a smaller movie size, but text is not always rendered the same across different systems and platforms. Specifying <code>FontLookup.EMBEDDED_CFF</code> uses font outlines embedded in the published SWF file. Embedded fonts increase the size of the SWF file (sometimes dramatically), but text is consistently displayed in the chosen font.
+		 * <p>Legal values are FontLookup.DEVICE, FontLookup.EMBEDDED_CFF, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of FontLookup.DEVICE.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.text.engine.FontLookup
+		 */
+		function get fontLookup():*;
+
+		/**
+		 * Determines the number of degrees to rotate this text.
+		 * <p>Legal values are TextRotation.ROTATE_0, TextRotation.ROTATE_180, TextRotation.ROTATE_270, TextRotation.ROTATE_90, TextRotation.AUTO, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of TextRotation.AUTO.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.text.engine.TextRotation
+		 */
+		function get textRotation():*;
+
+		/**
+		 * A Number that specifies, in pixels, the amount to indent the first line of the paragraph.
+		 * A negative indent will push the line into the margin, and possibly out of the container.
+		 * <p>Legal values are numbers from -8000 to 8000 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get textIndent():*;
+
+		/**
+		 * A Number that specifies, in pixels, the amount to indent the paragraph's start edge. Refers to the left edge in left-to-right text and the right edge in right-to-left text. 
+		 * <p>Legal values are numbers from 0 to 8000 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get paragraphStartIndent():*;
+
+		/**
+		 * A Number that specifies, in pixels, the amount to indent the paragraph's end edge. Refers to the right edge in left-to-right text and the left edge in right-to-left text. 
+		 * <p>Legal values are numbers from 0 to 8000 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get paragraphEndIndent():*;
+
+		/**
+		 * A Number that specifies the amount of space, in pixels, to leave before the paragraph. 
+		 * Collapses in tandem with <code>paragraphSpaceAfter</code>.
+		 * <p>Legal values are numbers from 0 to 8000 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get paragraphSpaceBefore():*;
+
+		/**
+		 * A Number that specifies the amount of space, in pixels, to leave after the paragraph.
+		 * Collapses in tandem with  <code>paragraphSpaceBefore</code>.
+		 * <p>Legal values are numbers from 0 to 8000 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get paragraphSpaceAfter():*;
+
+		/**
+		 * Alignment of lines in the paragraph relative to the container.
+		 * <code>TextAlign.LEFT</code> aligns lines along the left edge of the container. <code>TextAlign.RIGHT</code> aligns on the right edge. <code>TextAlign.CENTER</code> positions the line equidistant from the left and right edges. <code>TextAlign.JUSTIFY</code> spreads the lines out so they fill the space. <code>TextAlign.START</code> is equivalent to setting left in left-to-right text, or right in right-to-left text. <code>TextAlign.END</code> is equivalent to setting right in left-to-right text, or left in right-to-left text.
+		 * <p>Legal values are TextAlign.LEFT, TextAlign.RIGHT, TextAlign.CENTER, TextAlign.JUSTIFY, TextAlign.START, TextAlign.END, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of TextAlign.START.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.TextAlign
+		 */
+		function get textAlign():*;
+
+		/**
+		 * Alignment of the last (or only) line in the paragraph relative to the container in justified text.
+		 * If <code>textAlign</code> is set to <code>TextAlign.JUSTIFY</code>, <code>textAlignLast</code> specifies how the last line (or only line, if this is a one line block) is aligned. Values are similar to <code>textAlign</code>.
+		 * <p>Legal values are TextAlign.LEFT, TextAlign.RIGHT, TextAlign.CENTER, TextAlign.JUSTIFY, TextAlign.START, TextAlign.END, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of TextAlign.START.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.TextAlign
+		 */
+		function get textAlignLast():*;
+
+		/**
+		 * Specifies options for justifying text.
+		 * Default value is <code>TextJustify.INTER_WORD</code>, meaning that extra space is added to the space characters. <code>TextJustify.DISTRIBUTE</code> adds extra space to space characters and between individual letters. Used only in conjunction with a <code>justificationRule</code> value of <code>JustificationRule.SPACE</code>.
+		 * <p>Legal values are TextJustify.INTER_WORD, TextJustify.DISTRIBUTE, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of TextJustify.INTER_WORD.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.TextJustify
+		 */
+		function get textJustify():*;
+
+		/**
+		 * Rule used to justify text in a paragraph.
+		 * Default value is <code>FormatValue.AUTO</code>, which justifies text based on the paragraph's <code>locale</code> property. For all languages except Japanese and Chinese, <code>FormatValue.AUTO</code> becomes <code>JustificationRule.SPACE</code>, which adds extra space to the space characters.  For Japanese and Chinese, <code>FormatValue.AUTO</code> becomes <code>JustficationRule.EAST_ASIAN</code>. In part, justification changes the spacing of punctuation. In Roman text the comma and Japanese periods take a full character's width but in East Asian text only half of a character's width. Also, in the East Asian text the spacing between sequential punctuation marks becomes tighter, obeying traditional East Asian typographic conventions. Note, too, in the example below the leading that is applied to the second line of the paragraphs. In the East Asian version, the last two lines push left. In the Roman version, the second and following lines push left.<p><img src='../../../images/t
 extLayout_justificationrule.png' alt='justificationRule' /></p>
+		 * <p>Legal values are JustificationRule.EAST_ASIAN, JustificationRule.SPACE, FormatValue.AUTO, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of FormatValue.AUTO.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.JustificationRule
+		 */
+		function get justificationRule():*;
+
+		/**
+		 * The style used for justification of the paragraph. Used only in conjunction with a <code>justificationRule</code> setting of <code>JustificationRule.EAST_ASIAN</code>.
+		 * Default value of <code>FormatValue.AUTO</code> is resolved to <code>JustificationStyle.PUSH_IN_KINSOKU</code> for all locales.  The constants defined by the JustificationStyle class specify options for handling kinsoku characters, which are Japanese characters that cannot appear at either the beginning or end of a line. If you want looser text, specify <code>JustificationStyle.PUSH-OUT-ONLY</code>. If you want behavior that is like what you get with the  <code>justificationRule</code> of <code>JustificationRule.SPACE</code>, use <code>JustificationStyle.PRIORITIZE-LEAST-ADJUSTMENT</code>.
+		 * <p>Legal values are JustificationStyle.PRIORITIZE_LEAST_ADJUSTMENT, JustificationStyle.PUSH_IN_KINSOKU, JustificationStyle.PUSH_OUT_ONLY, FormatValue.AUTO, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of FormatValue.AUTO.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.text.engine.JustificationStyle
+		 */
+		function get justificationStyle():*;
+
+		/**
+		 * Specifies the default bidirectional embedding level of the text in the text block. 
+		 * Left-to-right reading order, as in Latin-style scripts, or right-to-left reading order, as in Arabic or Hebrew. This property also affects column direction when it is applied at the container level. Columns can be either left-to-right or right-to-left, just like text. Below are some examples:<p><img src='../../../images/textLayout_direction.gif' alt='direction' /></p>
+		 * <p>Legal values are Direction.LTR, Direction.RTL, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of Direction.LTR.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.Direction
+		 */
+		function get direction():*;
+
+		/**
+		 * Specifies the optimum, minimum, and maximum spacing (as a multiplier of the width of a normal space) between words to use during justification.
+		 * The optimum space is used to indicate the desired size of a space, as a fraction of the value defined in the font. The minimum and maximum values are the used when textJustify is distribute to determine how wide or narrow the spaces between the words may grow before letter spacing is used to justify the line.
+		 * <p>Legal values as a percent are numbers from -1000% to 1000%.</p>
+		 * <p>Legal values include FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of 100%, 50%, 150%.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get wordSpacing():*;
+
+		/**
+		 * Specifies the tab stops associated with the paragraph.
+		 * Setters can take an array of TabStopFormat, a condensed string representation, undefined, or <code>FormatValue.INHERIT</code>. The condensed string representation is always converted into an array of TabStopFormat. <p>The string-based format is a list of tab stops, where each tab stop is delimited by one or more spaces.</p><p>A tab stop takes the following form: &lt;alignment type&gt;&lt;alignment position&gt;|&lt;alignment token&gt;.</p><p>The alignment type is a single character, and can be S, E, C, or D (or lower-case equivalents). S or s for start, E or e for end, C or c for center, D or d for decimal. The alignment type is optional, and if its not specified will default to S.</p><p>The alignment position is a Number, and is specified according to FXG spec for Numbers (decimal or scientific notation). The alignment position is required.</p><p>The vertical bar is used to separate the alignment position from the alignment token, and should only be present if the alignment tok
 en is present.</p><p> The alignment token is optional if the alignment type is D, and should not be present if the alignment type is anything other than D. The alignment token may be any sequence of characters terminated by the space that ends the tab stop (for the last tab stop, the terminating space is optional; end of alignment token is implied). A space may be part of the alignment token if it is escaped with a backslash (\ ). A backslash may be part of the alignment token if it is escaped with another backslash (\\). If the alignment type is D, and the alignment token is not specified, it will take on the default value of null.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of null.</p>
+		 * @see org.apache.flex.textLayout.formats.TabStopFormat
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get tabStops():*;
+
+		/**
+		 * Specifies the leading model, which is a combination of leading basis and leading direction.
+		 * Leading basis is the baseline to which the <code>lineHeight</code> property refers. Leading direction determines whether the <code>lineHeight</code> property refers to the distance of a line's baseline from that of the line before it or the line after it. The default value of <code>FormatValue.AUTO</code> is resolved based on the paragraph's <code>locale</code> property.  For Japanese and Chinese, it is <code>LeadingModel.IDEOGRAPHIC_TOP_DOWN</code> and for all others it is <code>LeadingModel.ROMAN_UP</code>.<p><strong>Leading Basis:</strong></p><p><img src='../../../images/textLayout_LB1.png' alt='leadingBasis1' />    <img src='../../../images/textLayout_LB2.png' alt='leadingBasis2' />    <img src='../../../images/textLayout_LB3.png' alt='leadingBasis3' /></p><p><strong>Leading Direction:</strong></p><p><img src='../../../images/textLayout_LD1.png' alt='leadingDirection1' />    <img src='../../../images/textLayout_LD2.png' alt='leadingDirection2' />    <img src='../../../image
 s/textLayout_LD3.png' alt='leadingDirection3' /></p>
+		 * <p>Legal values are LeadingModel.ROMAN_UP, LeadingModel.IDEOGRAPHIC_TOP_UP, LeadingModel.IDEOGRAPHIC_CENTER_UP, LeadingModel.IDEOGRAPHIC_TOP_DOWN, LeadingModel.IDEOGRAPHIC_CENTER_DOWN, LeadingModel.APPROXIMATE_TEXT_FIELD, LeadingModel.ASCENT_DESCENT_UP, LeadingModel.BOX, LeadingModel.AUTO, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of LeadingModel.AUTO.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.LeadingModel
+		 */
+		function get leadingModel():*;
+
+		/**
+		 * Specifies the amount of gutter space, in pixels, to leave between the columns (adopts default value if undefined during cascade).
+		 * Value is a Number
+		 * <p>Legal values are numbers from 0 to 1000 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of 20.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get columnGap():*;
+
+		/**
+		 * Left inset in pixels.  Default of auto is zero except in lists which get a start side padding of 45. (adopts default value if undefined during cascade).
+		 * Space between the left edge of the container and the text.  Value is a Number or auto.<p> With vertical text, in scrollable containers with multiple columns, the first and following columns will show the padding as blank space at the end of the container, but for the last column, if the text doesn't all fit, you may have to scroll in order to see the padding.</p>
+		 * <p>Legal values as a string are FormatValue.AUTO, FormatValue.INHERIT and numbers from -8000 to 8000.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of FormatValue.AUTO.</p>
+		 * @see org.apache.flex.textLayout.elements.Configuration#autoListElementStartPadding
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.FormatValue
+		 */
+		function get paddingLeft():*;
+
+		/**
+		 * Top inset in pixels.  Default of auto is zero except in lists which get a start side padding of 45. (adopts default value if undefined during cascade).
+		 * Space between the top edge of the container and the text.  Value is a Number or auto.
+		 * <p>Legal values as a string are FormatValue.AUTO, FormatValue.INHERIT and numbers from -8000 to 8000.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of FormatValue.AUTO.</p>
+		 * @see org.apache.flex.textLayout.elements.Configuration#autoListElementStartPadding
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.FormatValue
+		 */
+		function get paddingTop():*;
+
+		/**
+		 * Right inset in pixels.  Default of auto is zero except in lists which get a start side padding of 45. (adopts default value if undefined during cascade).
+		 * Space between the right edge of the container and the text.  Value is a Number or auto. 
+		 * <p>Legal values as a string are FormatValue.AUTO, FormatValue.INHERIT and numbers from -8000 to 8000.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of FormatValue.AUTO.</p>
+		 * @see org.apache.flex.textLayout.elements.Configuration#autoListElementStartPadding
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.FormatValue
+		 */
+		function get paddingRight():*;
+
+		/**
+		 * Bottom inset in pixels.  Default of auto is zero except in lists which get a start side padding of 45.  (adopts default value if undefined during cascade).
+		 * Space between the bottom edge of the container and the text.  Value is a Number  or auto. <p> With horizontal text, in scrollable containers with multiple columns, the first and following columns will show the padding as blank space at the bottom of the container, but for the last column, if the text doesn't all fit, you may have to scroll in order to see the padding.</p>
+		 * <p>Legal values as a string are FormatValue.AUTO, FormatValue.INHERIT and numbers from -8000 to 8000.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of FormatValue.AUTO.</p>
+		 * @see org.apache.flex.textLayout.elements.Configuration#autoListElementStartPadding
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.FormatValue
+		 */
+		function get paddingBottom():*;
+
+		/**
+		 * Number of text columns (adopts default value if undefined during cascade).
+		 * The column number overrides the  other column settings. Value is an integer, or <code>FormatValue.AUTO</code> if unspecified. If <code>columnCount</code> is not specified,<code>columnWidth</code> is used to create as many columns as can fit in the container.
+		 * <p>Legal values as a string are FormatValue.AUTO, FormatValue.INHERIT and from ints from 1 to 50.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of FormatValue.AUTO.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.FormatValue
+		 */
+		function get columnCount():*;
+
+		/**
+		 * Column width in pixels (adopts default value if undefined during cascade).
+		 * If you specify the width of the columns, but not the count, TextLayout will create as many columns of that width as possible, given the  container width and <code>columnGap</code> settings. Any remainder space is left after the last column. Value is a Number.
+		 * <p>Legal values as a string are FormatValue.AUTO, FormatValue.INHERIT and numbers from 0 to 8000.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of FormatValue.AUTO.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.FormatValue
+		 */
+		function get columnWidth():*;
+
+		/**
+		 * Specifies the baseline position of the first line in the container. Which baseline this property refers to depends on the container-level locale.  For Japanese and Chinese, it is <code>TextBaseline.IDEOGRAPHIC_BOTTOM</code>; for all others it is <code>TextBaseline.ROMAN</code>.
+		 * The offset from the top inset (or right inset if <code>blockProgression</code> is RL) of the container to the baseline of the first line can be either <code>BaselineOffset.ASCENT</code>, meaning equal to the ascent of the line, <code>BaselineOffset.LINE_HEIGHT</code>, meaning equal to the height of that first line, or any fixed-value number to specify an absolute distance. <code>BaselineOffset.AUTO</code> aligns the ascent of the line with the container top inset.<p><img src='../../../images/textLayout_FBO1.png' alt='firstBaselineOffset1' /><img src='../../../images/textLayout_FBO2.png' alt='firstBaselineOffset2' /><img src='../../../images/textLayout_FBO3.png' alt='firstBaselineOffset3' /><img src='../../../images/textLayout_FBO4.png' alt='firstBaselineOffset4' /></p>
+		 * <p>Legal values as a string are BaselineOffset.AUTO, BaselineOffset.ASCENT, BaselineOffset.LINE_HEIGHT, FormatValue.INHERIT and numbers from 0 to 1000.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of BaselineOffset.AUTO.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.BaselineOffset
+		 */
+		function get firstBaselineOffset():*;
+
+		/**
+		 * Vertical alignment or justification (adopts default value if undefined during cascade).
+		 * Determines how TextFlow elements align within the container.
+		 * <p>Legal values are VerticalAlign.TOP, VerticalAlign.MIDDLE, VerticalAlign.BOTTOM, VerticalAlign.JUSTIFY, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of VerticalAlign.TOP.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.VerticalAlign
+		 */
+		function get verticalAlign():*;
+
+		/**
+		 * Specifies a vertical or horizontal progression of line placement.
+		 * Lines are either placed top-to-bottom (<code>BlockProgression.TB</code>, used for horizontal text) or right-to-left (<code>BlockProgression.RL</code>, used for vertical text).
+		 * <p>Legal values are BlockProgression.RL, BlockProgression.TB, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of BlockProgression.TB.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.BlockProgression
+		 */
+		function get blockProgression():*;
+
+		/**
+		 * Controls word wrapping within the container (adopts default value if undefined during cascade).
+		 * Text in the container may be set to fit the width of the container (<code>LineBreak.TO_FIT</code>), or can be set to break only at explicit return or line feed characters (<code>LineBreak.EXPLICIT</code>).
+		 * <p>Legal values are LineBreak.EXPLICIT, LineBreak.TO_FIT, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of LineBreak.TO_FIT.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.LineBreak
+		 */
+		function get lineBreak():*;
+
+		/**
+		 * <p>Legal values are ListStyleType.UPPER_ALPHA, ListStyleType.LOWER_ALPHA, ListStyleType.UPPER_ROMAN, ListStyleType.LOWER_ROMAN, ListStyleType.NONE, ListStyleType.DISC, ListStyleType.CIRCLE, ListStyleType.SQUARE, ListStyleType.BOX, ListStyleType.CHECK, ListStyleType.DIAMOND, ListStyleType.HYPHEN, ListStyleType.ARABIC_INDIC, ListStyleType.BENGALI, ListStyleType.DECIMAL, ListStyleType.DECIMAL_LEADING_ZERO, ListStyleType.DEVANAGARI, ListStyleType.GUJARATI, ListStyleType.GURMUKHI, ListStyleType.KANNADA, ListStyleType.PERSIAN, ListStyleType.THAI, ListStyleType.URDU, ListStyleType.CJK_EARTHLY_BRANCH, ListStyleType.CJK_HEAVENLY_STEM, ListStyleType.HANGUL, ListStyleType.HANGUL_CONSTANT, ListStyleType.HIRAGANA, ListStyleType.HIRAGANA_IROHA, ListStyleType.KATAKANA, ListStyleType.KATAKANA_IROHA, ListStyleType.LOWER_ALPHA, ListStyleType.LOWER_GREEK, ListStyleType.LOWER_LATIN, ListStyleType.UPPER_ALPHA, ListStyleType.UPPER_GREEK, ListStyleType.UPPER_LATIN, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of ListStyleType.DISC.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.ListStyleType
+		 */
+		function get listStyleType():*;
+
+		/**
+		 * <p>Legal values are ListStylePosition.INSIDE, ListStylePosition.OUTSIDE, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of ListStylePosition.OUTSIDE.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.ListStylePosition
+		 */
+		function get listStylePosition():*;
+
+		/**
+		 * This specifies an auto indent for the start edge of lists when the padding value of the list on that side is <code>auto</code>.
+		 * <p>Legal values are numbers from -1000 to 1000 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of 40.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get listAutoPadding():*;
+
+		/**
+		 * Controls how text wraps around a float. A value of none allows the text to wrap most closely around a float. A value of left causes the text to skip over any portion of the container that has a left float, and a value of right causes the text to skip over any portion of the container that has a right float. A value of both causes the text to skip over any floats.
+		 * <p>Legal values are ClearFloats.START, ClearFloats.END, ClearFloats.LEFT, ClearFloats.RIGHT, ClearFloats.BOTH, ClearFloats.NONE, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of ClearFloats.NONE.</p>
+		 * @see org.apache.flex.textLayout.formats.ClearFloats
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.ClearFloats
+		 */
+		function get clearFloats():*;
+
+		/**
+		 * Assigns an identifying class to the element, making it possible to set a style for the element by referencing the <code>styleName</code>.
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of null.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get styleName():*;
+//TODO remove this when the compiler is fixed...
+		function set styleName(value:*):void;
+
+		/**
+		 * Defines the formatting attributes used for links in normal state. This value will cascade down the hierarchy and apply to any links that are descendants.
+		 * Accepts <code>inherit</code>, an <code>ITextLayoutFormat</code> or converts an array of objects with key and value as members to a TextLayoutFormat.
+		 * <p>Legal values include FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of null.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get linkNormalFormat():*;
+
+		/**
+		 * Defines the formatting attributes used for links in normal state. This value will cascade down the hierarchy and apply to any links that are descendants.
+		 * Accepts <code>inherit</code>, an <code>ITextLayoutFormat</code> or converts an array of objects with key and value as members to a TextLayoutFormat.
+		 * <p>Legal values include FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of null.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get linkActiveFormat():*;
+
+		/**
+		 * Defines the formatting attributes used for links in hover state, when the mouse is within the bounds (rolling over) a link. This value will cascade down the hierarchy and apply to any links that are descendants.
+		 * Accepts <code>inherit</code>, an <code>ITextLayoutFormat</code> or converts an array of objects with key and value as members to a TextLayoutFormat.
+		 * <p>Legal values include FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of null.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get linkHoverFormat():*;
+
+		/**
+		 * Defines the formatting attributes list markers. This value will cascade down the hierarchy and apply to any links that are descendants.
+		 * Accepts <code>inherit</code>, an <code>IListMarkerFormat</code> or converts an array of objects with key and value as members to a ListMarkerFormat.
+		 * <p>Legal values include FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of null.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get listMarkerFormat():*;
+
+		/**
+		 * Left border width in pixels (adopts default value if undefined during cascade)
+		 * <p>Legal values are numbers from 0 to 128 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get borderLeftWidth():*;
+
+		/**
+		 * Right border width in pixels (adopts default value if undefined during cascade)
+		 * <p>Legal values are numbers from 0 to 128 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get borderRightWidth():*;
+
+		/**
+		 * Top border width in pixels (adopts default value if undefined during cascade)
+		 * <p>Legal values are numbers from 0 to 128 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get borderTopWidth():*;
+
+		/**
+		 * Bottom border width in pixels (adopts default value if undefined during cascade)
+		 * <p>Legal values are numbers from 0 to 128 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get borderBottomWidth():*;
+
+		/**
+		 * Color of the left border (adopts default value if undefined during cascade). Can be either the constant value <code>BorderColor.TRANSPARENT</code>, or a hexadecimal value that specifies the three 8-bit RGB (red, green, blue) values; for example, 0xFF0000 is red and 0x00FF00 is green.
+		 * <p>Legal values as a string are BorderColor.TRANSPARENT, FormatValue.INHERIT and uints from 0x0 to 0xffffffff.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of BorderColor.TRANSPARENT.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.BorderColor
+		 */
+		function get borderLeftColor():*;
+
+		/**
+		 * Color of the right border (adopts default value if undefined during cascade). Can be either the constant value <code>BorderColor.TRANSPARENT</code>, or a hexadecimal value that specifies the three 8-bit RGB (red, green, blue) values; for example, 0xFF0000 is red and 0x00FF00 is green.
+		 * <p>Legal values as a string are BorderColor.TRANSPARENT, FormatValue.INHERIT and uints from 0x0 to 0xffffffff.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of BorderColor.TRANSPARENT.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.BorderColor
+		 */
+		function get borderRightColor():*;
+
+		/**
+		 * Color of the top border (adopts default value if undefined during cascade). Can be either the constant value <code>BorderColor.TRANSPARENT</code>, or a hexadecimal value that specifies the three 8-bit RGB (red, green, blue) values; for example, 0xFF0000 is red and 0x00FF00 is green.
+		 * <p>Legal values as a string are BorderColor.TRANSPARENT, FormatValue.INHERIT and uints from 0x0 to 0xffffffff.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of BorderColor.TRANSPARENT.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.BorderColor
+		 */
+		function get borderTopColor():*;
+
+		/**
+		 * Color of the bottom border (adopts default value if undefined during cascade). Can be either the constant value <code>BorderColor.TRANSPARENT</code>, or a hexadecimal value that specifies the three 8-bit RGB (red, green, blue) values; for example, 0xFF0000 is red and 0x00FF00 is green.
+		 * <p>Legal values as a string are BorderColor.TRANSPARENT, FormatValue.INHERIT and uints from 0x0 to 0xffffffff.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of BorderColor.TRANSPARENT.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.BorderColor
+		 */
+		function get borderBottomColor():*;
+
+		/**
+		 * Specifies the priority when drawing cell boundaries. When settings between two adjacent cells conflict, the border with the higher priority wins. If the priorities are equal, the latter of the two cells takes priority.
+		 * <p>Legal values are any rational number. Conflicts are resolved with the properties of the higher number being drawn.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit, and default to 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get borderLeftPriority():*;
+		
+		/**
+		 * Specifies the priority when drawing cell boundaries. When settings between two adjacent cells conflict, the border with the higher priority wins. If the priorities are equal, the latter of the two cells takes priority.
+		 * <p>Legal values are any rational number. Conflicts are resolved with the properties of the higher number being drawn.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit, and default to 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get borderRightPriority():*;
+		
+		/**
+		 * Specifies the priority when drawing cell boundaries. When settings between two adjacent cells conflict, the border with the higher priority wins. If the priorities are equal, the latter of the two cells takes priority.
+		 * <p>Legal values are any rational number. Conflicts are resolved with the properties of the higher number being drawn.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit, and default to 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get borderTopPriority():*;
+		
+		/**
+		 * Specifies the priority when drawing cell boundaries. When settings between two adjacent cells conflict, the border with the higher priority wins. If the priorities are equal, the latter of the two cells takes priority.
+		 * <p>Legal values are any rational number. Conflicts are resolved with the properties of the higher number being drawn.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit, and default to 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get borderBottomPriority():*;
+
+		/**
+		 * left margin in pixels(adopts default value if undefined during cascade).
+		 * <p>Legal values are numbers from -8000 to 8000 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get marginLeft():*;
+
+		/**
+		 * right margin in pixels (adopts default value if undefined during cascade).
+		 * <p>Legal values are numbers from -8000 to 8000 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get marginRight():*;
+
+		/**
+		 * top margin in pixels (adopts default value if undefined during cascade).
+		 * <p>Legal values are numbers from -8000 to 8000 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get marginTop():*;
+
+		/**
+		 * bottom margin in pixels (adopts default value if undefined during cascade).
+		 * <p>Legal values are numbers from -8000 to 8000 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get marginBottom():*;
+
+		/**
+		 * cellSpacing specifies how much space the user agent should leave between the left side of the table and the left-hand side of the leftmost column, the top of the table and the top side of the topmost row, and so on for the right and bottom of the table. The attribute also specifies the amount of space to leave between cells.
+		 * <p>Legal values are numbers from 0 to 1000 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get cellSpacing():*;
+
+		/**
+		 * cellPadding specifies the amount of space between the border of the cell and its contents. If the value of this attribute is a pixel length, all four margins should be this distance from the contents. If the value of the attribute is a percentage length, the top and bottom margins should be equally separated from the content based on a percentage of the available vertical space, and the left and right margins should be equally separated from the content based on a percentage of the available horizontal space.
+		 * <p>Legal values as a number are from 0 to 1000.</p>
+		 * <p>Legal values as a percent are numbers from 0% to 100%.</p>
+		 * <p>Legal values include FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get cellPadding():*;
+		
+		/**
+		 * Width of table element specifies the desired width of the entire table and is intended for visual user agents. When the value is a percentage value, the value is relative to the user agent's available horizontal space.
+		 * <p>Legal values as a number are from 0 to 8000.</p>
+		 * <p>Legal values as a percent are numbers from 0% to 100%.</p>
+		 * <p>Legal values include FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of 100%.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get tableWidth():*;
+
+		/**
+		 * Width of table column specifies a default width for each column spanned by the current COL element.
+		 * <p>Legal values as a number are from 0 to 8000.</p>
+		 * <p>Legal values as a percent are numbers from 0% to 100%.</p>
+		 * <p>Legal values include FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get tableColumnWidth():*;
+		
+		/**
+		 * Minimum height of a table cell. If there is no maximum, the cell will grow in height to fit the content. Minimum and maximum of the same values will give the cell a fixed height.
+		 * <p>Legal values as a number are from 2 to 10000.</p>
+		 * <p>Legal values include FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of 2.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get minCellHeight():*;
+		
+		/**
+		 * Maximum height of a table cell. If there is no maximum, the cell will grow in height to fit the content. Minimum and maximum of the same values will give the cell a fixed height.
+		 * <p>Legal values as a number are from 2 to 10000.</p>
+		 * <p>Legal values include FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of 2.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get maxCellHeight():*;
+
+		/**
+		 * frame specifies which sides of the frame surrounding a table will be visible. Possible values:
+		 * <p>Legal values are TableFrame.VOID, TableFrame.ABOVE, TableFrame.BELOW, TableFrame.HSIDES, TableFrame.VSIDES, TableFrame.LHS, TableFrame.RHS, TableFrame.BOX, TableFrame.BORDER, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of TableFrame.VOID.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.TableFrame
+		 */
+		function get frame():*;
+
+		/**
+		 * rules specifies which rules will appear between cells within a table. The rendering of rules is user agent dependent. Possible values:
+		 * <p>Legal values are TableRules.NONE, TableRules.GROUPS, TableRules.ROWS, TableRules.COLS, TableRules.ALL, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of TableRules.NONE.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.TableRules
+		 */
+		function get rules():*;
+		
+		//TODO remove this once the compiler bug which prevents adding this downstream is fixed.
+		function set tableColumnWidth(tableColumnWidth:*):void;
+
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/JustificationRule.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/JustificationRule.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/JustificationRule.as
new file mode 100644
index 0000000..1290dcc
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/JustificationRule.as
@@ -0,0 +1,60 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.formats
+{
+	/**
+	 *  Defines values for setting the <code>justificationRule</code> property
+	 *  of the TextLayoutFormat class. Default value is SPACE, which accomplishes justification by adding 
+	 *  extra space to the space characters. When you use EAST_ASIAN, Japanese style leading is employed, which 
+	 *  applies bottom-down as opposed to top-up, which is used in Roman text. The spacing of punctuation is also 
+	 *  different. In the Roman version, the comma and Japanese periods take a full character's width but only half 
+	 *  in East Asian. Additionally, the spacing between sequential punctuation marks becomes tighter, obeying traditional 
+	 *  East Asian typographic conventions. Also note the leading, applied to the second line of the paragraphs in the 
+	 *  example below. In the East Asian version, the last two lines push left. In the Roman version, the second and 
+	 *  following lines push left.
+	 *  <p><img src="../../../images/textLayout_justificationrule.png" alt="justificationRule" /></p>
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 *
+	 * @see TextLayoutFormat#justificationRule
+	 */
+	public final class JustificationRule
+	{
+		/** Specifies East Asian justification rules. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		 
+		public static const EAST_ASIAN:String = "eastAsian";
+		
+		/** Specifies justification for Latin and other horizontal scripts that divide words using spaces. 
+		 *  Use this value for everything except East Asian text.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		 
+		public static const SPACE:String = "space";
+	}
+}


[24/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/ISelectionManager.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/ISelectionManager.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/ISelectionManager.as
new file mode 100644
index 0000000..1950519
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/ISelectionManager.as
@@ -0,0 +1,515 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.edit
+{
+	import org.apache.flex.textLayout.elements.CellCoordinates;
+	import org.apache.flex.textLayout.elements.CellRange;
+	import org.apache.flex.textLayout.elements.ITableElement;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.textLayout.elements.TextRange;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+
+	/** 
+	 * The ISelectionManager interface defines the interface for handling text selection.
+	 * 
+	 * <p>A SelectionManager keeps track of the selected text range and handles events for a TextFlow.</p>
+	 * 
+	 * <p>A selection can be either a point selection or a range selection. A point selection is the insertion point
+	 * and is indicated visually by drawing a cursor. A range
+	 * selection includes the text between an anchor point and an active point.</p>
+	 * 
+	 * @see org.apache.flex.textLayout.edit.SelectionManager
+	 * @see org.apache.flex.textLayout.edit.TextScrap
+	 * @see org.apache.flex.textLayout.elements.TextFlow
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+ 	 * @langversion 3.0
+	 */
+	public interface ISelectionManager extends IInteractionEventHandler
+	{		
+		/** 
+		 * The TextFlow object managed by this selection manager. 
+		 * 
+		 * <p>A selection manager manages a single text flow. A selection manager can also be
+		 * assigned to a text flow by setting the <code>interactionManager</code> property of the
+		 * TextFlow object.</p>
+		 * 
+		 * @see org.apache.flex.textLayout.elements.TextFlow#interactionManager
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */
+		function get textFlow():ITextFlow;
+		function set textFlow(flow:ITextFlow):void;
+
+		function get currentTable():ITableElement;
+		function set currentTable(table:ITableElement):void;
+		function hasCellRangeSelection():Boolean;
+		
+		function selectCellRange(anchorCoords:CellCoordinates,activeCoords:CellCoordinates):void;
+		
+		function getCellRange():CellRange;
+		function setCellRange(range:CellRange):void;
+
+		/** Anchor point of the current cell selection, as coordinates within the table. */
+		function get anchorCellPosition():CellCoordinates;
+		function set anchorCellPosition(value:CellCoordinates):void;
+		
+		/** Active end of the current cell selection, as coordinates within the table. */
+		function get activeCellPosition():CellCoordinates;
+		function set activeCellPosition(value:CellCoordinates):void;
+
+		/** 
+		 * The text position of the start of the selection, as an offset from the start of the text flow.
+		 *  
+		 * <p>The absolute start is the same as either the active or the anchor point of the selection, whichever comes
+		 * first in the text flow.</p>
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */
+		function get absoluteStart() : int;
+		/** 
+		 * The text position of the end of the selection, as an offset from the start of the text flow.
+		 *  
+		 * <p>The absolute end is the same as either the active or the anchor point of the selection, whichever comes
+		 * last in the text flow.</p>
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */
+		function get absoluteEnd() : int;
+
+		/**
+		 * Selects a range of text.
+		 * 
+		 * <p>If a negative number is passed as either of the parameters, then any existing selection is
+		 * removed.</p>
+		 * 
+		 * @param anchorPosition	The anchor point for the new selection, as an absolute position in the TextFlow 
+		 * @param activePosition	The active end of the new selection, as an absolute position in the TextFlow
+		 * 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */
+		function selectRange(anchorPosition:int, activePosition:int) : void
+		
+		/**
+		 * Selects the entire flow.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */
+		function selectAll() : void
+		
+		/**
+		 * Selects the last position in the entire flow.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */
+		function selectLastPosition() : void
+		
+		/**
+		 * Selects the first position in the entire flow.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */
+		function selectFirstPosition() : void
+
+		/**
+		 * Removes any selection from the text flow
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function deselect() : void
+
+		/** 
+		 * The anchor point of the selection. 
+		 * 
+		 * <p>An <em>anchor</em> point is the stable end of the selection. When the selection
+		 * is extended, the anchor point does not change. The anchor point can be at either the beginning 
+		 * or the end of the selection.</p>
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */								
+		function get anchorPosition() : int;
+
+		/** 
+		 * The active point of the selection.
+		 * 
+		 * <p>The <em>active</em> point is the volatile end of the selection. The active point is changed 
+		 * when the selection is modified. The active point can be at either the beginning 
+		 * or the end of the selection.</p>
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */										
+		function get activePosition() : int;
+		
+		/**
+		 * Indicates whether there is a text selection. 
+		 * 
+		 * <p>Returns <code>true</code> if there is either a range selection or a point selection. 
+		 * By default, when a selection manager is first set up, there is no selection (the start and end are -1).</p>
+		 * 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */
+		function hasSelection():Boolean;
+
+		/**
+		 * Indicates whether there is a text or cell selection. 
+		 * 
+		 * <p>Returns <code>true</code> if there is either a range selection or a point selection. 
+		 * By default, when a selection manager is first set up, there is no selection (the start and end are -1).</p>
+		 * 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function hasAnySelection():Boolean;
+
+		/**
+		 * Indicates the type of selection. 
+		 * 
+		 * <p>The <code>selectionType</code> describes the kind of selection. 
+		 * It can either be <code>SelectionType.TEXT</code> or <code>SelectionType.CELLS</code></p>
+		 * 
+		 * @see org.apache.flex.textLayout.edit.SelectionType
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get selectionType() : String;
+		
+		/**
+		 * Indicates whether the selection covers a range of text.
+		 * 
+		 * <p>Returns <code>true</code> if there is a selection that extends past a single position.</p> 
+		 * 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */
+		function isRangeSelection():Boolean;
+		
+		/**
+		 * Gets the SelectionState object of the current selection.
+		 * 
+		 * 
+		 * @see org.apache.flex.textLayout.edit.SelectionState
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */
+		function getSelectionState():SelectionState;
+		
+		/**
+		 * Sets the SelectionState object of the current selection.
+		 * 
+		 * @see org.apache.flex.textLayout.edit.SelectionState
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function setSelectionState(state:SelectionState):void;
+
+		/** 
+		 * Redisplays the selection shapes. 
+		 * 
+		 * <p><b>Note:</b> You do not need to call this method directly. It is called automatically.</p>	
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */	
+		function refreshSelection():void;
+
+		/** 
+		 * Clears the selection shapes. 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */	
+		function clearSelection():void;
+
+		/** 
+		 * Gives the focus to the first container in the selection.
+		 *  
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+ 		 */
+		function setFocus():void;
+		
+		/** 
+		 * Indicates whether a container in the text flow has the focus.
+		 * 
+		 * <p>The <code>focused</code> property is <code>true</code> 
+		 * if any of the containers in the text flow has key focus.</p> 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */
+		function get focused():Boolean;
+		
+		/** 
+		 * Indicates whether the window associated with the text flow is active.
+		 * 
+		 * <p>The <code>windowActive</code> property is <code>true</code> if the window 
+		 * displaying with the text flow is the active window.</p>
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */
+		function get windowActive():Boolean;
+		
+		/** 
+		 * The current SelectionFormat object.
+		 * 
+		 * <p>The current SelectionFormat object is chosen from the SelectionFormat objects assigned to the 
+		 * <code>unfocusedSelectionFormat</code>, <code>inactiveSelectionFormat</code> and <code>focusedSelectionFormat</code> 
+		 * properties based on the current state of the <code>windowActive</code> and <code>focused</code> properties.</p> 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */
+		function get currentSelectionFormat():SelectionFormat;
+
+		/** 
+		 * The current Cell SelectionFormat object.
+		 * 
+		 * <p>The current cell SelectionFormat object is chosen from the SelectionFormat objects assigned to the 
+		 * <code>unfocusedCellSelectionFormat</code>, <code>inactiveCellSelectionFormat</code> and <code>focusedCellSelectionFormat</code> 
+		 * properties based on the current state of the <code>windowActive</code> and <code>focused</code> properties.</p> 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get currentCellSelectionFormat():SelectionFormat;
+
+		/**
+		 * Gets the character format attributes that are common to all characters in the specified text range or current selection.
+		 * 
+		 * <p>Format attributes that do not have the same value for all characters in the specified element range or selection are set to 
+		 * <code>null</code> in the returned TextLayoutFormat instance.</p>
+		 * 
+		 * @param range The optional range of text for which common attributes are requested. If null, the current selection is used. 
+		 * @return The common character style settings
+		 * 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */
+		function getCommonCharacterFormat (range:TextRange=null):TextLayoutFormat;
+		 
+		 /**
+		 * Gets the paragraph format attributes that are common to all paragraphs in the specified text range or current selection.
+		 * 
+		 * <p>Format attributes that do not have the same value for all paragraphs in the specified element range or selection are set to 
+		 * <code>null</code> in the returned TextLayoutFormat instance.</p>
+		 * 
+		 * @param range The optional range of text for which common attributes are requested. If null, the current selection is used. 
+		 * @return The common paragraph style settings
+		 * 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */
+		function getCommonParagraphFormat (range:TextRange=null):TextLayoutFormat;
+		 
+		/**
+		 * Gets the container format attributes that are common to all containers in the specified text range or current selection.
+		 * 
+		 * <p>Format attributes that do not have the same value for all containers in the specified element range or selection are set to 
+		 * <code>null</code> in the returned TextLayoutFormat instance.</p>
+		 * 
+		 * @param range The optional range of text for which common attributes are requested. If null, the current selection is used. 
+		 * @return The common container style settings
+		 * 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */
+		function getCommonContainerFormat (range:TextRange=null):TextLayoutFormat;
+
+		/**
+		 * The editing mode. 
+		 * 
+		 * <p>The editing mode indicates whether the text flow supports selection, editing, or only reading.
+		 * A text flow is made selectable by assigning a selection manager and editable by assigning an edit manager.
+		 * Constants representing the editing modes are defined in the EditingMode class.</p>
+		 * 
+		 * @see org.apache.flex.textLayout.EditingMode
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */
+		 function get editingMode():String;		
+		
+		/**
+		 * The SelectionFormat object used to draw the selection in a focused container. 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */		 
+		 function get focusedSelectionFormat():SelectionFormat;
+		 function set focusedSelectionFormat(val:SelectionFormat):void;
+		 
+		/**
+		 * The SelectionFormat object used to draw the selection when it is not in a focused container, but is in
+		 * the active window.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */		 		 
+		 function get unfocusedSelectionFormat():SelectionFormat;
+		 function set unfocusedSelectionFormat(val:SelectionFormat):void;
+		 
+		/**
+		 * The SelectionFormat object used to draw the selection when it is not in the active window.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */		 		 
+		 function get inactiveSelectionFormat():SelectionFormat;
+		 function set inactiveSelectionFormat(val:SelectionFormat):void;		 		 
+
+		 /**
+		  * The SelectionFormat object used to draw cell selections in a focused container. 
+		  * 
+		  * @playerversion Flash 10
+		  * @playerversion AIR 1.5
+		  * @langversion 3.0
+		  */		 
+		 function get focusedCellSelectionFormat():SelectionFormat;
+		 function set focusedCellSelectionFormat(val:SelectionFormat):void;
+		 
+		 /**
+		  * The SelectionFormat object used to draw cell selections when they are not in a focused container, but are in
+		  * the active window.
+		  * 
+		  * @playerversion Flash 10
+		  * @playerversion AIR 1.5
+		  * @langversion 3.0
+		  */		 		 
+		 function get unfocusedCellSelectionFormat():SelectionFormat;
+		 function set unfocusedCellSelectionFormat(val:SelectionFormat):void;
+		 
+		 /**
+		  * The SelectionFormat object used to draw cell selections when they are not in the active window.
+		  * 
+		  * @playerversion Flash 10
+		  * @playerversion AIR 1.5
+		  * @langversion 3.0
+		  */		 		 
+		 function get inactiveCellSelectionFormat():SelectionFormat;
+		 function set inactiveCellSelectionFormat(val:SelectionFormat):void;		 		 
+
+		/**
+		 * Executes any pending FlowOperations. 
+		 * 
+		 * <p>The execution of some editing operations, such as text insertion, is delayed 
+		 * until the next enterFrame event. Calling <code>flushPendingOperations()</code> causes any deferred operations to be executed 
+		 * immediately.</p>
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 * 
+		 */
+		function flushPendingOperations():void;
+
+		/** 
+		 * Updates the selection manager when text is inserted or deleted.
+		 * 
+		 * <p>Operations must call <code>notifyInsertOrDelete</code> when changing the text in the text flow. 
+		 * The selection manager adjusts index-based position indicators accordingly. If you create a new Operation
+		 * class that changes text in a text flow directly (not using another operation) your operation must call this function 
+		 * to keep the selection up to date.</p>
+		 * 
+		 * @param absolutePosition	The point in the text where the change was made.
+		 * @param length A positive or negative number indicating how many characters were inserted or deleted.
+		 * 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */
+		function notifyInsertOrDelete(absolutePosition:int, length:int):void;		 
+		 
+		/**
+		 * The ISelectionManager object used to for cell selections nested within the TextFlow managed by this ISelectionManager.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */		 		 
+		function get subManager():ISelectionManager;
+		function set subManager(value:ISelectionManager):void;
+		
+		/**
+		 * The ISelectionManager object used to manage the parent TextFlow of this ISelectionManager (i.e. for cell ISelectionManagers).
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */		 		 
+		function get superManager():ISelectionManager;
+		function set superManager(value:ISelectionManager):void;
+		
+		function copy(sharedUndo:Boolean):ISelectionManager;
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/Mark.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/Mark.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/Mark.as
new file mode 100644
index 0000000..a4da370
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/Mark.as
@@ -0,0 +1,38 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.edit
+{
+// [ExcludeClass]
+
+	/** @private - not ready for prime time */
+	public class Mark
+	{
+		private var _position:int;
+
+		public function Mark(value:int = 0)
+		{
+			_position = value;
+		}
+		
+		public function get position():int
+			{ return _position; }
+		public function set position(value:int):void
+			{ _position = value; }
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/MementoList.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/MementoList.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/MementoList.as
new file mode 100644
index 0000000..1115b73
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/MementoList.as
@@ -0,0 +1,78 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.edit 
+{
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	
+	// [ExcludeClass]
+	/** 
+	 * The MementoList class is a meta-memento.  It encapuslates the concept of having a sequence of mementos behave as a memento.
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+
+	public class MementoList implements IMemento
+	{
+		private var _mementoList:Array;
+		/**
+		 * MementoList is a memento made of a list of other mementos
+		 */
+		public function MementoList(textFlow:ITextFlow)
+		{ 
+		}
+		
+		public function push(memento:IMemento):void
+		{
+			if (memento)
+				mementoList.push(memento);
+		}
+		
+		private function get mementoList():Array
+		{
+			if(!_mementoList)
+				_mementoList = [];
+			
+			return _mementoList;
+		}
+		
+		public function undo():*
+		{
+			var retVal:Array = [];
+			if(_mementoList)
+			{
+				_mementoList.reverse();
+				for each (var memento:IMemento in  _mementoList)
+					retVal.push(memento.undo());
+				_mementoList.reverse();
+			}
+			
+			return retVal; 
+		}
+		
+		public function redo():*
+		{
+			var retVal:Array = [];
+			for each (var memento:IMemento in  _mementoList)
+				retVal.push(memento.redo());
+			return retVal;	
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/ModelEdit.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/ModelEdit.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/ModelEdit.as
new file mode 100644
index 0000000..f7507c1
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/ModelEdit.as
@@ -0,0 +1,159 @@
+// //////////////////////////////////////////////////////////////////////////////
+//
+// 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
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// //////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.edit
+{
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.edit.mementos.AddElementMemento;
+	import org.apache.flex.textLayout.edit.mementos.DeleteTextMemento;
+	import org.apache.flex.textLayout.edit.mementos.JoinMemento;
+	import org.apache.flex.textLayout.edit.mementos.MoveElementMemento;
+	import org.apache.flex.textLayout.edit.mementos.RemoveElementsMemento;
+	import org.apache.flex.textLayout.edit.mementos.SplitMemento;
+	import org.apache.flex.textLayout.edit.mementos.TextRangeMemento;
+	import org.apache.flex.textLayout.elements.ElementHelper;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	import org.apache.flex.textLayout.elements.IFlowGroupElement;
+	import org.apache.flex.textLayout.elements.IFlowLeafElement;
+	import org.apache.flex.textLayout.elements.IListItemElement;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.ISpanElement;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+
+	// [ExcludeClass]
+	/** 
+	 * The ModelEdit class contains static functions for performing speficic suboperations.  Each suboperation returns a "memento" for undo/redo.
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	public class ModelEdit
+	{
+		public static function splitElement(textFlow:ITextFlow, elemToSplit:IFlowGroupElement, relativePosition:int):IMemento
+		{
+			return SplitMemento.perform(textFlow, elemToSplit, relativePosition, true);
+		}
+
+		public static function joinElement(textFlow:ITextFlow, element1:IFlowGroupElement, element2:IFlowGroupElement):IMemento
+		{
+			return JoinMemento.perform(textFlow, element1, element2, true);
+		}
+
+		public static function addElement(textFlow:ITextFlow, elemToAdd:IFlowElement, parent:IFlowGroupElement, index:int):IMemento
+		{
+			CONFIG::debug
+			{
+				assert(elemToAdd.parent == null, "Use moveElement"); }
+			return AddElementMemento.perform(textFlow, elemToAdd, parent, index, true);
+		}
+
+		public static function moveElement(textFlow:ITextFlow, elemToMove:IFlowElement, parent:IFlowGroupElement, index:int):IMemento
+		{
+			CONFIG::debug
+			{
+				assert(elemToMove.parent != null, "Use addElement"); }
+			return MoveElementMemento.perform(textFlow, elemToMove, parent, index, true);
+		}
+
+		public static function removeElements(textFlow:ITextFlow, elemtToRemoveParent:IFlowGroupElement, startIndex:int, numElements:int):IMemento
+		{
+			return RemoveElementsMemento.perform(textFlow, elemtToRemoveParent, startIndex, numElements, true);
+		}
+
+		public static function deleteText(textFlow:ITextFlow, absoluteStart:int, absoluteEnd:int, createMemento:Boolean):IMemento
+		{
+			var memento:MementoList;
+			var mergePara:IParagraphElement;
+
+			// Special case to see if the whole of the last element of the flow is selected. If so, force the terminator at the end to be deleted
+			// so that if there is a list or a div at the end, it will be entirely removed.
+			if (absoluteEnd == textFlow.textLength - 1)
+			{
+				var lastElement:IFlowElement = textFlow.getChildAt(textFlow.numChildren - 1);
+				if (absoluteStart <= lastElement.getAbsoluteStart())
+					absoluteEnd = textFlow.textLength;
+			}
+
+			// Special case for when the last paragraph in the flow is deleted. We clone the last paragraph
+			// before letting the delete get processed. This lets whatever hierarchy is associated with the
+			// old last paragraph die a natural death, but doesn't leave the flow with no terminator.
+			var newLastParagraph:IParagraphElement;
+			if (absoluteEnd >= textFlow.textLength)
+			{
+				var lastSpan:IFlowLeafElement = textFlow.getLastLeaf();
+				var lastParagraph:IParagraphElement = lastSpan.getParagraph();
+				newLastParagraph = ElementHelper.getParagraph();
+				var newLastSpan:ISpanElement = ElementHelper.getSpan();
+				newLastParagraph.replaceChildren(0, 0, newLastSpan);
+				newLastParagraph.format = lastParagraph.format;
+				newLastSpan.format = lastSpan.format;
+				absoluteEnd = textFlow.textLength;
+			}
+
+			if (createMemento)
+			{
+				memento = new MementoList(textFlow);
+				if (newLastParagraph)
+					memento.push(addElement(textFlow, newLastParagraph, textFlow, textFlow.numChildren));
+				var deleteTextMemento:DeleteTextMemento = new DeleteTextMemento(textFlow, absoluteStart, absoluteEnd);
+				memento.push(deleteTextMemento);
+
+				mergePara = TextFlowEdit.deleteRange(textFlow, absoluteStart, absoluteEnd);
+				memento.push(TextFlowEdit.joinNextParagraph(mergePara, false));
+				checkNormalize(textFlow, deleteTextMemento.commonRoot, memento);
+			}
+			else
+			{
+				if (newLastParagraph)
+					textFlow.replaceChildren(textFlow.numChildren, textFlow.numChildren, newLastParagraph);
+				mergePara = TextFlowEdit.deleteRange(textFlow, absoluteStart, absoluteEnd);
+				TextFlowEdit.joinNextParagraph(mergePara, false);
+			}
+
+			if (textFlow.interactionManager)
+				textFlow.interactionManager.notifyInsertOrDelete(absoluteStart, -(absoluteEnd - absoluteStart));
+
+			return memento;
+		}
+
+		/**
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.IFlowGroupElement
+		 */
+		private static function checkNormalize(textFlow:ITextFlow, commonRoot:IFlowGroupElement, mementoList:MementoList):void
+		{
+			if ((commonRoot is IListItemElement) && (commonRoot as IListItemElement).normalizeNeedsInitialParagraph())
+			{
+				var paragraph:IParagraphElement = ElementHelper.getParagraph();
+				paragraph.replaceChildren(0, 0, ElementHelper.getSpan());
+				mementoList.push(addElement(textFlow, paragraph, commonRoot, 0));
+			}
+			for (var index:int = 0; index < commonRoot.numChildren; ++index)
+			{
+				var child:IFlowGroupElement = commonRoot.getChildAt(index) as IFlowGroupElement;
+				if (child)
+					checkNormalize(textFlow, child, mementoList);
+			}
+		}
+
+		public static function saveCurrentState(textFlow:ITextFlow, absoluteStart:int, absoluteEnd:int):IMemento
+		{
+			return new TextRangeMemento(textFlow, absoluteStart, absoluteEnd);
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/ParaEdit.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/ParaEdit.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/ParaEdit.as
new file mode 100644
index 0000000..bdfbc88
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/ParaEdit.as
@@ -0,0 +1,673 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.edit
+{
+	import org.apache.flex.textLayout.container.IContainerController;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.elements.ElementHelper;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	import org.apache.flex.textLayout.elements.IFlowGroupElement;
+	import org.apache.flex.textLayout.elements.IFlowLeafElement;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.ISpanElement;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.textLayout.elements.IInlineGraphicElement;
+	import org.apache.flex.textLayout.elements.ISubParagraphGroupElementBase;
+	import org.apache.flex.textLayout.elements.ITableElement;
+	import org.apache.flex.textLayout.elements.ITableLeafElement;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+
+	// [ExcludeClass]
+	/**
+	 * Encapsulates all methods necessary for dynamic editing of a text.  The methods are all static member functions of this class.
+	 * @private - because we can't make it tlf_internal. Used by the operations package 
+	 */
+ 	public class ParaEdit
+	{
+		/**
+		 * Inserts text into specified paragraph
+		 * @param textFlow		ITextFlow to insert into
+		 * @param absoluteStart	index relative to beginning of the ITextFlow to insert text
+		 * @param text	actual text to insert 
+		 * @param createNewSpan	flag to force creation of a new span
+		 */
+		public static function insertText(textFlow:ITextFlow, absoluteStart:int,insertText:String, createNewSpan:Boolean):ISpanElement
+		{
+			if (insertText.length == 0)
+				return null;	// error? other sanity checks needed here?
+				
+			var sibling:IFlowElement = textFlow.findLeaf(absoluteStart);
+			var siblingIndex:int;
+			var paragraph:IParagraphElement = sibling.getParagraph();
+			var paraStart:int = paragraph.getAbsoluteStart();
+			var paraSelBegIdx:int = absoluteStart - paraStart;
+			
+			if (paraStart == absoluteStart)		// insert to start of paragraph
+				siblingIndex = 0;
+			else 
+			{
+				// If we're at the start a span, go to the previous span in the same paragraph, and insert at the end of it
+				if (paraSelBegIdx == sibling.getElementRelativeStart(paragraph))
+					sibling = IFlowLeafElement(sibling).getPreviousLeaf(paragraph);
+				if(sibling is ITableLeafElement)
+					siblingIndex = sibling.parent.parent.getChildIndex(sibling.parent) + 1;
+				else
+					siblingIndex = sibling.parent.getChildIndex(sibling) + 1;
+			}
+			var insertParent:IFlowGroupElement = sibling.parent;
+			if(insertParent is ITableElement)
+				insertParent = insertParent.parent;
+			
+			// If we are adding text to the start or end of a link, it doesn't allow the insertion to group with the link.
+			// So in that case, we will insert to the element beside the position that is *not* part of the link.
+			var curSPGElement:ISubParagraphGroupElementBase = sibling.getParentByType("SubParagraphGroupElementBase") as ISubParagraphGroupElementBase;
+			while (curSPGElement != null)
+			{
+				var subParInsertionPoint:int = paraSelBegIdx - curSPGElement.getElementRelativeStart(paragraph);
+				if (((subParInsertionPoint == 0) && (!curSPGElement.acceptTextBefore())) ||
+					((!curSPGElement.acceptTextAfter() && (subParInsertionPoint == curSPGElement.textLength || 
+					(subParInsertionPoint == curSPGElement.textLength - 1 && (sibling == paragraph.getLastLeaf()))))))
+				{
+					createNewSpan = true;
+					sibling = insertParent;
+					insertParent = insertParent.parent;
+					curSPGElement = curSPGElement.getParentByType("SubParagraphGroupElementBase") as ISubParagraphGroupElementBase;
+					siblingIndex = insertParent.getChildIndex(sibling) + 1;
+				} else {
+					break;
+				}
+			}
+			// adjust the flow so that we are in a span for the insertion
+			var insertSpan:ISpanElement = sibling as ISpanElement;
+			
+			// use the terminator span if it's empty
+			if(paragraph.terminatorSpan.textLength == 1 && paragraph.terminatorSpan == insertSpan)
+				createNewSpan = false;
+			
+			if (!insertSpan || createNewSpan)
+			{
+				var newSpan:ISpanElement = ElementHelper.getSpan();
+//				var insertIdx:int;
+				if (siblingIndex > 0)
+				{
+					var relativeStart:int = paraSelBegIdx - sibling.getElementRelativeStart(paragraph);
+					if (createNewSpan)
+					{
+						if (relativeStart == 0)
+							siblingIndex--;
+						else if (relativeStart != sibling.textLength)
+							sibling.splitAtPosition(relativeStart);		// we'll insert between the two elements
+					}
+				}
+				var nextLeaf:IFlowLeafElement = paragraph.findLeaf(paraSelBegIdx);
+				if(nextLeaf && nextLeaf.textLength == 1 && nextLeaf.parent == insertParent && nextLeaf == paragraph.terminatorSpan)
+				{
+					// use the terminator span instead of inserting a new one.
+					newSpan = ISpanElement(nextLeaf);
+				}
+				else {
+					insertParent.replaceChildren(siblingIndex, siblingIndex, newSpan);
+				}
+				var formatElem:IFlowLeafElement = newSpan.getPreviousLeaf(paragraph);
+				if (formatElem == null)
+					newSpan.format = newSpan.getNextLeaf(paragraph).format;
+				else
+					newSpan.format = formatElem.format;
+					
+				insertSpan = newSpan;
+			}
+			
+			var runInsertionPoint:int = paraSelBegIdx - insertSpan.getElementRelativeStart(paragraph);
+			
+				
+			insertSpan.replaceText(runInsertionPoint, runInsertionPoint, insertText);
+			return insertSpan;
+		}
+		
+		private static function deleteTextInternal(para:IParagraphElement, paraSelBegIdx:int, totalToDelete:int):void
+		{
+			var composeNode:IFlowElement;
+			var curSpan:ISpanElement;
+			
+			var curNumToDelete:int;
+			var curSpanDeletePos:int = 0;
+			
+			while (totalToDelete > 0)
+			{
+				composeNode = para.findLeaf(paraSelBegIdx);
+				CONFIG::debug { assert(composeNode is ISpanElement,"deleteTextInternal: leaf element is not a span"); }
+								
+				curSpan = composeNode as ISpanElement;
+				var curSpanRelativeStart:int = curSpan.getElementRelativeStart(para);
+				curSpanDeletePos = paraSelBegIdx - curSpanRelativeStart;
+				if (paraSelBegIdx > (curSpanRelativeStart + curSpan.textLength))
+				{
+					curNumToDelete = curSpan.textLength;
+				}
+				else
+				{
+					curNumToDelete = (curSpanRelativeStart + curSpan.textLength) - paraSelBegIdx;
+				}
+				
+				if (totalToDelete < curNumToDelete)
+				{
+					curNumToDelete = totalToDelete;
+				}
+				
+				curSpan.replaceText(curSpanDeletePos, curSpanDeletePos + curNumToDelete, "");
+				if (curSpan.textLength == 0)
+				{
+					var delIdx:int = curSpan.parent.getChildIndex(curSpan);
+					curSpan.parent.replaceChildren(delIdx,delIdx+1,null);						
+				}
+				totalToDelete -= curNumToDelete;
+			}			
+		}
+		
+		public static function deleteText(para:IParagraphElement, paraSelBegIdx:int, totalToDelete:int):void
+		{
+			var lastParPos:int = para.textLength - 1;
+			if ((paraSelBegIdx < 0) || (paraSelBegIdx > lastParPos))
+			{
+				//not much we can do. There's nothing to delete in this paragraph
+				return;
+			}
+			
+			if (totalToDelete <= 0)
+			{
+				//can't delete a negative number of characters... just return
+				return;
+			}
+			
+			var endPos:int = paraSelBegIdx + totalToDelete - 1;
+			if (endPos > lastParPos)
+			{
+				endPos = lastParPos;
+				totalToDelete = endPos - paraSelBegIdx + 1;
+			}
+			
+			deleteTextInternal(para,paraSelBegIdx,totalToDelete);
+		}
+		
+		/**
+		 * Creates image and inserts it into specified FlowGroupElement
+		 * @param flowBlock	FlowGroupElement to insert image into
+		 * @param flowSelBegIdx	index relative to beginning of the FlowGroupElement to insert image
+		 * @param urlString	the url of image to insert
+		 * @param width	the width of the image
+		 * @param height the height of the image
+		 * @param options none supported
+		 * @flexjsignorecoercion org.apache.flex.textLayout.element.ISpanElement
+		 */
+		public static function createImage(flowBlock:IFlowGroupElement, flowSelBegIdx:int,source:Object, width:Object, height:Object, options:Object, pointFormat:ITextLayoutFormat):IInlineGraphicElement
+		{
+			//first, split the element that we are on
+			var curComposeNode:IFlowElement = flowBlock.findLeaf(flowSelBegIdx);
+			var posInCurComposeNode:int = 0;
+			if (curComposeNode != null)
+			{
+				posInCurComposeNode = flowSelBegIdx - curComposeNode.getElementRelativeStart(flowBlock); // curComposeNode.parentRelativeStart;
+			}			
+			
+			if ((curComposeNode != null) && (posInCurComposeNode > 0) && (posInCurComposeNode < curComposeNode.textLength))
+			{
+				//it is a LeafElement, and not position 0. It has to be a Span 
+				(curComposeNode as ISpanElement).splitAtPosition(posInCurComposeNode);
+			}
+			
+			//the FlowElement or FlowGroupElement is now split.  Insert the image now.
+			var imgElem:IInlineGraphicElement = ElementHelper.getInline();
+			imgElem.height = height;
+			imgElem.width = width;
+			imgElem.float = options ? options.toString() : undefined;
+			
+			var src:Object = source;
+			var embedStr:String = "@Embed";
+			if (src is String && src.length > embedStr.length && src.substr(0, embedStr.length) == embedStr) {
+				// we should be dealing with an embedded asset. They are of the form "url=@Embed(source='path-to-asset')"
+				var searchStr:String = "source=";
+				var index:int = src.indexOf(searchStr, embedStr.length);
+				if (index > 0) {
+					index += searchStr.length;
+					index = src.indexOf("'", index);
+					src = src.substring(index+1, src.indexOf("'", index+1));
+				}
+			}
+			imgElem.source = src;
+			
+			while (curComposeNode && curComposeNode.parent != flowBlock)
+			{
+				curComposeNode = curComposeNode.parent;
+			}
+
+			var elementIdx:int = curComposeNode != null ? flowBlock.getChildIndex(curComposeNode) : flowBlock.numChildren;
+			if (curComposeNode && posInCurComposeNode > 0)
+				elementIdx++;
+			flowBlock.replaceChildren(elementIdx,elementIdx,imgElem);
+			
+			//clone characterFormat from the left OR iff the the first element the right
+			var p:IParagraphElement = imgElem.getParagraph();
+			var attrElem:IFlowLeafElement = imgElem.getPreviousLeaf(p);
+			if (!attrElem)
+				attrElem = imgElem.getNextLeaf(p);
+			CONFIG::debug { assert(attrElem != null, "no element to get attributes from"); }
+			
+			if (attrElem.format || pointFormat)
+			{
+				var imageElemFormat:TextLayoutFormat = new TextLayoutFormat(attrElem.format);
+				if (pointFormat)
+					imageElemFormat.apply(pointFormat);
+				imgElem.format = imageElemFormat;
+			}
+			return imgElem;			
+		}		
+		
+		/** Merge changed attributes into this
+		 */
+		static private function splitForChange(span:ISpanElement,begIdx:int,rangeLength:int):ISpanElement
+		{
+			var startOffset:int = span.getAbsoluteStart();
+			if (begIdx == startOffset && rangeLength == span.textLength)
+				return span;
+				
+			// element must be split into spans
+			var elemToUpdate:ISpanElement;
+			var origLength:int = span.textLength;
+			
+			var begRelativeIdx:int = begIdx - startOffset;
+			if (begRelativeIdx > 0)
+			{
+				// We create an initial span to hold the text before the new span, then
+				// a following span for the specified range.
+				elemToUpdate = span.splitAtPosition(begRelativeIdx) as ISpanElement;
+				if (begRelativeIdx + rangeLength < origLength)
+					elemToUpdate.splitAtPosition(rangeLength);
+			}
+			else
+			{
+				// The specified range falls at the start of the element, so this span is the 
+				// one that's getting the new format.
+				span.splitAtPosition(rangeLength);
+				elemToUpdate = span;
+			}
+
+			return elemToUpdate;
+		}
+		
+		private static function undefineDefinedFormats(target:TextLayoutFormat,undefineFormat:ITextLayoutFormat):void
+		{
+			if (undefineFormat)
+			{
+				// this is fairly rare so this operation is not optimizied
+				var tlfUndefineFormat:TextLayoutFormat;
+				if (undefineFormat is TextLayoutFormat)
+					tlfUndefineFormat = undefineFormat as TextLayoutFormat;
+				else 
+					tlfUndefineFormat = new TextLayoutFormat(undefineFormat);
+				for (var prop:String in tlfUndefineFormat.styles)
+					target.setStyle(prop, undefined);
+			}
+		}
+
+		/**
+		 * Apply formatting changes to a range of text in the FlowElement
+		 *
+		 * @param begIdx	text index of first text in span
+		 * @param rangeLength	number of characters to modify
+		 * @param applyFormat		Character Format to apply to content
+		 * @param undefineFormat	Character Format to undefine to content
+		 * @return begIdx + number of actual actual characters modified.
+		 */
+		static private function applyCharacterFormat(leaf:IFlowLeafElement, begIdx:int, rangeLength:int, applyFormat:ITextLayoutFormat, undefineFormat:ITextLayoutFormat):int
+		{
+			var newFormat:TextLayoutFormat = new TextLayoutFormat(leaf.format);
+			if (applyFormat)
+				newFormat.apply(applyFormat);
+			undefineDefinedFormats(newFormat,undefineFormat);
+			return setCharacterFormat(leaf, newFormat, begIdx, rangeLength);
+		}
+		
+		/**
+		 * Set formatting to a range of text in the FlowElement
+		 *
+		 * @param format	Character Format to apply to content
+		 * @param begIdx	text index of first text in span
+		 * @param rangeLength	number of characters to modify
+		 * @return starting position of following span
+		 */
+		static private function setCharacterFormat(leaf:IFlowLeafElement, format:ITextLayoutFormat, begIdx:int, rangeLength:int):int
+		{
+			var startOffset:int = leaf.getAbsoluteStart();
+			if (!(format is ITextLayoutFormat) || !TextLayoutFormat.isEqual(ITextLayoutFormat(format),leaf.format))
+			{				
+//				var para:IParagraphElement = leaf.getParagraph();
+//				var paraStartOffset:int = para.getAbsoluteStart();
+				
+				// clip rangeLength to the length of this span. Extend the rangeLength by one to include the terminator if
+				// it is in the span, and the end of the range abuts the terminator. That way the terminator will stay in the 
+				// last span.
+				var begRelativeIdx:int = begIdx - startOffset;
+				if (begRelativeIdx + rangeLength > leaf.textLength)
+					rangeLength = leaf.textLength - begRelativeIdx;
+				if (begRelativeIdx + rangeLength == leaf.textLength - 1 && (leaf is ISpanElement) && ISpanElement(leaf).hasParagraphTerminator)
+					++rangeLength;
+				
+				var elemToUpdate:IFlowLeafElement;
+				if (leaf is ISpanElement)
+					elemToUpdate = splitForChange(ISpanElement(leaf),begIdx,rangeLength);
+				else
+				{
+					CONFIG::debug { assert(rangeLength >= leaf.textLength,"unable to split non-span leaf"); }
+					elemToUpdate = leaf;
+				}
+				
+				if (format is ITextLayoutFormat)
+					elemToUpdate.format = ITextLayoutFormat(format);
+				else
+					elemToUpdate.setStylesInternal(format);
+				
+				return begIdx+rangeLength;
+			}
+			
+			rangeLength = leaf.textLength;
+			return startOffset+rangeLength;
+		}
+		
+		public static function applyTextStyleChange(flowRoot:ITextFlow,begChange:int,endChange:int,applyFormat:ITextLayoutFormat,undefineFormat:ITextLayoutFormat):void
+		{	
+			// TODO: this code only works for span's.  Revisit when new FlowLeafElement types enabled
+			var workIdx:int = begChange;
+			while (workIdx < endChange)
+			{
+				var elem:IFlowLeafElement = flowRoot.findLeaf(workIdx);
+				CONFIG::debug  { assert(elem != null,"null FlowLeafElement found"); }
+				workIdx = applyCharacterFormat(elem,workIdx,endChange-workIdx,applyFormat,undefineFormat); 
+			}
+		}
+		
+		// used for undo of operation
+		public static function setTextStyleChange(flowRoot:ITextFlow,begChange:int, endChange:int, coreStyle:ITextLayoutFormat):void
+		{
+			// TODO: this code only works for span's.  Revisit when new FlowLeafElement types enabled
+			var workIdx:int = begChange;
+			while (workIdx < endChange)
+			{
+				var elem:IFlowElement = flowRoot.findLeaf(workIdx);
+				CONFIG::debug  { assert(elem != null,"null FlowLeafElement found"); }
+				workIdx = setCharacterFormat(IFlowLeafElement(elem),coreStyle,workIdx,endChange-workIdx);
+			}
+		}
+		
+		/**
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.IFlowGroupElement
+		 */
+		public static function splitElement(elem:IFlowGroupElement, splitPos:int):IFlowGroupElement
+		{
+			CONFIG::debug { assert(splitPos >= 0 && splitPos <= elem.textLength, "Invalid call to ParaEdit.splitElement"); }
+			
+			var rslt:IFlowGroupElement = elem.splitAtPosition(splitPos) as IFlowGroupElement;
+			
+			// rslt always follows elem
+			
+
+			if (!(rslt is ISubParagraphGroupElementBase))
+			{
+				
+				// need to insure there is a paragraph and a span on each side
+				var rsltParagraph:IFlowGroupElement = rslt;
+				while (!(rsltParagraph is IParagraphElement) && rsltParagraph.numChildren)
+					rsltParagraph = rsltParagraph.getChildAt(0) as IFlowGroupElement;
+				
+				var elemParagraph:IFlowGroupElement = elem;
+				while (!(elemParagraph is IParagraphElement) && elemParagraph.numChildren)
+					elemParagraph = elemParagraph.getChildAt(elemParagraph.numChildren-1) as IFlowGroupElement;
+				
+				CONFIG::debug { assert (elemParagraph is IParagraphElement || rsltParagraph is IParagraphElement,"ParaEdit.splitElement didn't find at least one paragraph"); }
+				
+				var p:IParagraphElement;
+				
+				if (!(elemParagraph is IParagraphElement))
+				{
+					// clone rlstParagraph
+					p = rsltParagraph.shallowCopy() as IParagraphElement;
+					elemParagraph.addChild(p);
+					elemParagraph = p;
+				}
+				else if (!(rsltParagraph is IParagraphElement))
+				{
+					p = elemParagraph.shallowCopy() as IParagraphElement;
+					rsltParagraph.addChild(p);
+					rsltParagraph = p;						
+				}
+				
+				// if we have an empty before or after para need to make sure the formats got copied
+				if (elemParagraph.textLength <= 1)
+				{
+					elemParagraph.normalizeRange(0,elemParagraph.textLength);
+					elemParagraph.getLastLeaf().quickCloneTextLayoutFormat(rsltParagraph.getFirstLeaf());
+				}
+				else if (rsltParagraph.textLength <= 1)
+				{
+					rsltParagraph.normalizeRange(0,rsltParagraph.textLength);
+					rsltParagraph.getFirstLeaf().quickCloneTextLayoutFormat(elemParagraph.getLastLeaf());
+				}
+			}
+
+			return rslt;
+		}		
+		// TODO: rewrite this method by moving the elements.  This is buggy.
+		/**
+		 * @flexjsignorecoercion org.apache.flex.textLayout.element.IParagraphElement
+		 */
+		public static function mergeParagraphWithNext(para:IParagraphElement):Boolean
+		{
+			var indexOfPara:int = para.parent.getChildIndex(para);
+			
+			// last can't merge
+			if (indexOfPara == para.parent.numChildren-1)
+				return false;
+				
+			var nextPar:IParagraphElement  = para.parent.getChildAt(indexOfPara + 1) as IParagraphElement;
+			// next is not a paragraph
+			if (nextPar == null)
+				return false;
+				
+			// remove nextPar from its parent - do this first because it will require less updating of starts and lengths
+			para.parent.replaceChildren(indexOfPara+1,indexOfPara+2,null);
+			if (nextPar.textLength <= 1) 
+				return true;
+			
+			// move all the elements
+			while (nextPar.numChildren)
+			{
+				var elem:IFlowElement = nextPar.getChildAt(0);
+				nextPar.replaceChildren(0,1,null);
+				para.replaceChildren(para.numChildren,para.numChildren,elem);
+				if ((para.numChildren >  1) && (para.getChildAt(para.numChildren - 2).textLength == 0))
+				{
+					//bug 1658164
+					//imagine that the last element of para is only a kParaTerminator (like a single
+					//span of length 1 that only contains a kParaTerminator, and you merge with the
+					//next paragraph. That kParaTerminator will move, leaving an empty leaf element
+					para.replaceChildren(para.numChildren - 2, para.numChildren - 1, null);
+				}
+			}
+
+			return true;
+		}
+		
+		public static function cacheParagraphStyleInformation(flowRoot:ITextFlow,begSel:int,endSel:int,undoArray:Array):void
+		{
+			while (begSel <= endSel && begSel >= 0)
+			{
+				var para:IParagraphElement = flowRoot.findLeaf(begSel).getParagraph();
+				
+				// build an object holding the old style and format
+				var obj:Object = {};
+				obj.begIdx = para.getAbsoluteStart();
+				obj.endIdx = obj.begIdx + para.textLength - 1;
+				obj.attributes = new TextLayoutFormat(para.format);
+				undoArray.push(obj);
+
+				begSel = obj.begIdx + para.textLength;
+			}
+		}
+
+		/**
+		 * Replace the existing paragraph attributes with the incoming attributes.
+		 * 
+		 * @param flowRoot	text flow where paragraphs are
+		 * @param format	attributes to apply
+		 * @param beginIndex	text index within the first paragraph in the range
+		 * @param endIndex		text index within the last paragraph in the range
+		 */
+		// used for undo of operation
+		public static function setParagraphStyleChange(flowRoot:ITextFlow,begChange:int, endChange:int, format:ITextLayoutFormat):void
+		{
+			var beginPara:int = begChange;
+			while (beginPara <= endChange)
+			{
+				var para:IParagraphElement = flowRoot.findLeaf(beginPara).getParagraph();
+				
+				para.format = format ? new TextLayoutFormat(format) : null;
+				beginPara = para.getAbsoluteStart() + para.textLength;
+			}
+		}
+		
+		/**
+		 * Additively apply the paragraph formating attributes to the paragraphs in the specified range.
+		 * Each non-null field in the incoming format is copied into the existing paragraph attributes.
+		 * 
+		 * @param flowRoot	text flow where paragraphs are
+		 * @param format	attributes to apply
+		 * @param beginIndex	text index within the first paragraph in the range
+		 * @param endIndex		text index within the last paragraph in the range
+		 */
+		public static function applyParagraphStyleChange(flowRoot:ITextFlow,begChange:int,endChange:int,applyFormat:ITextLayoutFormat,undefineFormat:ITextLayoutFormat):void
+		{	
+			var curIndex:int = begChange;
+			while (curIndex <= endChange)
+			{
+				var leaf:IFlowLeafElement = flowRoot.findLeaf(curIndex);
+				if (!leaf)
+					break;
+				var para:IParagraphElement = leaf.getParagraph();
+				
+				// now, need to get the change from "format" and apply to para. We make
+				// a new ParagraphFormat object instead of changing the ParagraphFormat
+				// already in the paragraph so that if the object is shared, other uses
+				// in other paragraphs will not be affected.
+				var newFormat:TextLayoutFormat = new TextLayoutFormat(para.format);
+				if (applyFormat)
+					newFormat.apply(applyFormat);
+				undefineDefinedFormats(newFormat,undefineFormat);
+				para.format = newFormat;
+				
+				curIndex = para.getAbsoluteStart() + para.textLength;
+			}		
+		}
+
+		public static function cacheStyleInformation(flowRoot:ITextFlow,begSel:int,endSel:int,undoArray:Array):void
+		{
+			var elem:IFlowElement = flowRoot.findLeaf(begSel);
+			var elemLength:int = elem.getAbsoluteStart()+elem.textLength-begSel;
+			var countRemaining:int = endSel - begSel;
+			CONFIG::debug { assert(countRemaining != 0,"cacheStyleInformation called on point selection"); }
+			for (;;)
+			{
+				// build an object holding the old style and format
+				var obj:Object = {};
+
+				obj.begIdx = begSel;
+				var objLength:int = Math.min(countRemaining, elemLength);
+				obj.endIdx = begSel + objLength;
+				
+				// just the styles
+				obj.style = new TextLayoutFormat(elem.format);
+				undoArray.push(obj);
+				
+				countRemaining -= Math.min(countRemaining, elemLength);
+				if (countRemaining == 0)
+					break;
+				
+				// advance
+				begSel = obj.endIdx;
+				
+				elem = flowRoot.findLeaf(begSel);
+				elemLength = elem.textLength;
+			}
+		}
+		
+		public static function cacheContainerStyleInformation(flowRoot:ITextFlow,begIdx:int,endIdx:int,undoArray:Array):void
+		{
+			CONFIG::debug { assert(begIdx <= endIdx,"bad indexeds passed to ParaEdit.cacheContainerStyleInformation");  }
+			if (flowRoot.flowComposer)
+			{
+				var ctrlrBegIdx:int = flowRoot.flowComposer.findControllerIndexAtPosition(begIdx,false);
+				if (ctrlrBegIdx == -1)
+					return;
+				var ctrlrEndIdx:int = flowRoot.flowComposer.findControllerIndexAtPosition(endIdx,true);
+				if (ctrlrEndIdx == -1)
+					ctrlrEndIdx = flowRoot.flowComposer.numControllers-1;
+				while (ctrlrBegIdx <= ctrlrEndIdx)
+				{
+					var controller:IContainerController = flowRoot.flowComposer.getControllerAt(ctrlrBegIdx);
+					var obj:Object = {};
+					obj.container = controller;
+					// save just the styles
+					obj.attributes = new TextLayoutFormat(controller.format);
+					undoArray.push(obj);
+					ctrlrBegIdx++;
+				}
+			}
+		}
+
+		public static function applyContainerStyleChange(flowRoot:ITextFlow,begIdx:int,endIdx:int,applyFormat:ITextLayoutFormat,undefineFormat:ITextLayoutFormat):void
+		{
+			CONFIG::debug { assert(begIdx <= endIdx,"bad indexes passed to ParaEdit.cacheContainerStyleInformation");  }
+			if (flowRoot.flowComposer)
+			{
+				var ctrlrBegIdx:int = flowRoot.flowComposer.findControllerIndexAtPosition(begIdx,false);
+				if (ctrlrBegIdx == -1)
+					return;
+				var ctrlrEndIdx:int = flowRoot.flowComposer.findControllerIndexAtPosition(endIdx,true);
+				if (ctrlrEndIdx == -1)
+					ctrlrEndIdx = flowRoot.flowComposer.numControllers-1;
+//				var controllerIndex:int = flowRoot.flowComposer.findControllerIndexAtPosition(begIdx,false);
+				while (ctrlrBegIdx <= ctrlrEndIdx)
+				{
+					var controller:IContainerController = flowRoot.flowComposer.getControllerAt(ctrlrBegIdx);
+					var newFormat:TextLayoutFormat = new TextLayoutFormat(controller.format);
+					if (applyFormat)
+						newFormat.apply(applyFormat);
+					undefineDefinedFormats(newFormat,undefineFormat);
+					controller.format = newFormat;
+					ctrlrBegIdx++;
+				}
+			}
+		}
+
+		/** obj is created by cacheContainerStyleInformation */
+		public static function setContainerStyleChange(obj:Object):void
+		{
+			obj.container.format = obj.attributes as ITextLayoutFormat;
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/PointFormat.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/PointFormat.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/PointFormat.as
new file mode 100644
index 0000000..d860374
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/PointFormat.as
@@ -0,0 +1,148 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.edit
+{
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	import org.apache.flex.textLayout.elements.FlowElement;
+	import org.apache.flex.textLayout.elements.ILinkElement;
+	import org.apache.flex.textLayout.elements.ITCYElement;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+
+
+	
+	// [ExcludeClass]
+	/**
+	 * Contains the settings that apply to new text being typed.
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	public class PointFormat extends TextLayoutFormat implements ITextLayoutFormat
+	{
+		private var _id:*;
+		private var _linkElement:ILinkElement;
+		private var _tcyElement:ITCYElement;
+		
+		/** Constructor
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function PointFormat(initialValues:ITextLayoutFormat = null)
+		{
+			super(initialValues);
+		}
+		
+
+		static public function isEqual(p1:ITextLayoutFormat,p2:ITextLayoutFormat):Boolean
+		{
+			if (!TextLayoutFormat.isEqual(p1, p2))
+				return false;
+			if ((p1 is PointFormat) != (p2 is PointFormat))
+				return false;
+			if (p1 is PointFormat)
+			{
+				var pf1:PointFormat = p1 as PointFormat;
+				var pf2:PointFormat = p2 as PointFormat;
+				return pf1.id == pf2.id && isEqualLink(pf1.linkElement, pf2.linkElement) && 
+					(pf1.tcyElement == null) == (pf2.tcyElement == null);
+			}
+			return true;
+		}
+		
+		static private function isEqualLink(l1:ILinkElement, l2:ILinkElement):Boolean
+		{
+			if ((l1 == null) != (l2 == null))
+				return false;
+			if (l1 == null)
+				return true;
+			return l1.href == l2.href && l1.target == l2.target;
+		}
+		
+		
+		public function get linkElement():*
+		{
+			return _linkElement;
+		}
+		public function set linkElement(value:ILinkElement):void
+		{
+			_linkElement = value;
+		}
+
+		public function get tcyElement():*
+		{
+			return _tcyElement;
+		}
+		public function set tcyElement(value:ITCYElement):void
+		{
+			_tcyElement = value;
+		}
+		/**
+		 * Assigns an identifying name to the element, making it possible to set a style for the element
+		 * by referencing the <code>id</code>. 
+		 *
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 * @see FlowElement#id
+		 */
+		public function get id():*
+		{
+			return _id;
+		}
+		public function set id(value:*):void
+		{
+			_id = value;
+		}
+ 
+		
+		public static function clone(original:PointFormat):PointFormat
+		{
+			var cloneFormat:PointFormat = new PointFormat(original);
+			cloneFormat.id = original.id;
+			cloneFormat.linkElement = (original.linkElement === undefined || !original.linkElement) ? original.linkElement : original.linkElement.shallowCopy() as ILinkElement;
+			cloneFormat.tcyElement = (original.tcyElement === undefined || !original.tcyElement) ? original.tcyElement : original.tcyElement.shallowCopy() as ITCYElement;
+			return cloneFormat;
+		}
+		
+		public static function createFromFlowElement(element:IFlowElement):PointFormat
+		{
+			if (!element)
+				return new PointFormat();
+			
+			var format:PointFormat = new PointFormat(element.format);
+			
+
+			var linkElement:ILinkElement = element.getParentByType("LinkElement") as ILinkElement;
+			if (linkElement)
+				format.linkElement = linkElement.shallowCopy() as ILinkElement;
+
+			var tcyElement:ITCYElement = element.getParentByType("TCYElement") as ITCYElement;
+			if (tcyElement)
+				format.tcyElement = tcyElement.shallowCopy() as ITCYElement;
+			
+			return format;
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/SelectionFormat.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/SelectionFormat.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/SelectionFormat.as
new file mode 100644
index 0000000..a7b4652
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/SelectionFormat.as
@@ -0,0 +1,207 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.edit {
+	
+	/**
+	 * The SelectionFormat class defines the properties of a selection highlight.
+	 * 
+	 * @see org.apache.flex.textLayout.edit.ISelectionManager
+	 * @see org.apache.flex.textLayout.edit.SelectionManager
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+ 	 * @langversion 3.0
+	 */
+	public class SelectionFormat
+	{
+		private var _rangeColor:uint;
+		private var _rangeAlpha:Number;
+		private var _rangeBlendMode:String;
+		
+		private var _pointColor:uint;
+		private var _pointAlpha:Number;
+		private var _pointBlendMode:String;
+		private var _pointBlinkRate:Number;
+		
+		/** 
+		 * Creates a SelectionFormat object with the specified properties.
+		 * 
+		 * <p>A SelectionFormat created with the default values will use black for
+		 * the highlight colors, 1.0 for the alphas, and BlendMode.DIFFERENCE for the blending modes.
+		 * The cursor blink rate is 500 milliseconds.</p>
+		 *
+		 * <p>Setting the <code>pointAlpha</code> and <code>rangeAlpha</code> properties to zero disables selection highlighting.</p>
+		 * 
+		 * <p>Non-zero blink rate is only used when an EditManager is attached to the TextFlow.</p>
+		 * 
+		 * @param rangeColor The color for drawing the highlight.
+		 * @param rangeAlpha The transparency value for drawing the highlight. Valid values are between 0
+		 * (completely transparent) and 1 (completely opaque, which is the default).
+		 * @param rangeBlendMode The blend mode for drawing the highlight. Use constants defined in the BlendMode class
+		 * to set this parameter.
+		 * @param pointColor The color for the drawing cursor.
+		 * @param pointAlpha The transparency value for drawing the cursor. Valid values are between 0
+		 * (completely transparent) and 1 (completely opaque, which is the default).
+		 * @param pointBlendMode The blend mode for drawing the cursor. Use constants defined in the BlendMode class
+		 * to set this parameter.
+		 * @param pointBlinkRate The rate at which the cursor blinks, in milliseconds.
+		 * 
+		 * @see flash.display.BlendMode
+		 * @see #pointAlpha
+		 * @see #rangeAlpha
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */
+		public function SelectionFormat(rangeColor:uint=0xffffff, rangeAlpha:Number=1.0, rangeBlendMode:String="difference", pointColor:uint=0xffffff, pointAlpha:Number=1.0, pointBlendMode:String="difference", pointBlinkRate:Number = 500)
+		{ 
+			_rangeColor = rangeColor;
+			_rangeAlpha = rangeAlpha;
+			_rangeBlendMode = rangeBlendMode;
+			
+			_pointColor = pointColor;
+			_pointAlpha = pointAlpha;
+			_pointBlendMode = pointBlendMode;
+			_pointBlinkRate = pointBlinkRate;
+		}
+		
+		/**
+		 * The color for drawing the highlight of a range selection. 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */		
+		public function get rangeColor():uint
+		{
+			return _rangeColor;
+		}
+
+		/**
+		 * The alpha for drawing the highlight of a range selection. Valid values are between 0
+		 * (completely transparent) and 1 (completely opaque, which is the default).
+		 *
+		 * <p>Setting the <code>pointAlpha</code> and <code>rangeAlpha</code> properties to zero disables selection highlighting.</p>
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+ 	 	 *
+ 	 	 * @see #pointAlpha
+		 */						
+		public function get rangeAlpha():Number
+		{
+			return _rangeAlpha;
+		}
+
+		/**
+		 * The blending mode for drawing the highlight of a range selection. 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 * @see flash.display.BlendMode
+		 */						
+		public function get rangeBlendMode():String
+		{
+			return _rangeBlendMode;
+		}
+		
+		/**
+		 * The color for drawing the cursor.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */		
+		public function get pointColor():uint
+		{
+			return _pointColor;
+		}
+
+		/**
+		 * The alpha for drawing the cursor. Valid values are between 0
+		 * (completely transparent) and 1 (completely opaque, which is the default).
+		 *
+		 * <p>Setting the <code>pointAlpha</code> and <code>rangeAlpha</code> properties to zero disables selection highlighting.</p>
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+ 	 	 *
+ 	 	 * @see #rangeAlpha
+		 */						
+		public function get pointAlpha():Number
+		{
+			return _pointAlpha;
+		}
+		
+		/**
+		 * The rate at which the cursor blinks, in milliseconds.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */						
+		public function get pointBlinkRate():Number
+		{
+			return _pointBlinkRate;
+		}		
+
+		/**
+		 * The blend mode for drawing the cursor.
+		 * 
+		 * @see flash.display.BlendMode
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */						
+		public function get pointBlendMode():String
+		{
+			return _pointBlendMode;
+		}
+
+		/**
+		 * Determines whether this SelectionFormat object has the same property values
+		 * as another SelectionFormat object.
+		 *  
+		 * @return <code>true</code>, if the property values are identical; <code>false</code>, otherwise.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 * 
+		 * @param selectionFormat	the SelectionFormat to compare against.
+		 */								
+		public function equals(selectionFormat:SelectionFormat):Boolean
+		{
+			if ((_rangeBlendMode == selectionFormat.rangeBlendMode) &&
+				(_rangeAlpha == selectionFormat.rangeAlpha) &&
+				(_rangeColor == selectionFormat.rangeColor) &&
+				(_pointColor == selectionFormat.pointColor) &&
+				(_pointAlpha == selectionFormat.pointAlpha) &&
+				(_pointBlendMode == selectionFormat.pointBlendMode) &&
+				(_pointBlinkRate == selectionFormat.pointBlinkRate))
+				return true;
+			return false;
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/SelectionFormatState.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/SelectionFormatState.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/SelectionFormatState.as
new file mode 100644
index 0000000..f07356b
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/SelectionFormatState.as
@@ -0,0 +1,38 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.edit
+{
+	// [ExcludeClass]
+	/**
+	 *  Values for the selection background state
+	 *
+	 *  @see text.edit.SelectionFormat
+	 */
+ 	public final class SelectionFormatState 
+ 	{
+		/** default selection format state */
+    	public static const FOCUSED:String = "focused";
+    
+		/** selection state when selection doesn't have focus */    
+    	public static const UNFOCUSED:String = "unfocused";
+    
+		/** selection state when SelectionManager is inactive */        
+    	public static const INACTIVE:String = "inactive";
+	}
+}


[28/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/TextFieldHtmlImporter.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/TextFieldHtmlImporter.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/TextFieldHtmlImporter.as
new file mode 100644
index 0000000..042084c
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/TextFieldHtmlImporter.as
@@ -0,0 +1,1231 @@
+// //////////////////////////////////////////////////////////////////////////////
+//
+// 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
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// //////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion
+{
+	import org.apache.flex.text.engine.Kerning;
+	import org.apache.flex.textLayout.conversion.importers.CaseInsensitiveTLFFormatImporter;
+	import org.apache.flex.textLayout.conversion.importers.FontImporter;
+	import org.apache.flex.textLayout.conversion.importers.HtmlCustomParaFormatImporter;
+	import org.apache.flex.textLayout.conversion.importers.TextFormatImporter;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.elements.BreakElement;
+	import org.apache.flex.textLayout.elements.DivElement;
+	import org.apache.flex.textLayout.elements.ElementHelper;
+	import org.apache.flex.textLayout.elements.GlobalSettings;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	import org.apache.flex.textLayout.elements.IFlowGroupElement;
+	import org.apache.flex.textLayout.elements.IFlowLeafElement;
+	import org.apache.flex.textLayout.elements.IListElement;
+	import org.apache.flex.textLayout.elements.IListItemElement;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.InlineGraphicElement;
+	import org.apache.flex.textLayout.elements.LinkElement;
+	import org.apache.flex.textLayout.elements.SpanElement;
+	import org.apache.flex.textLayout.elements.SubParagraphGroupElement;
+	import org.apache.flex.textLayout.elements.SubParagraphGroupElementBase;
+	import org.apache.flex.textLayout.elements.TabElement;
+	import org.apache.flex.textLayout.elements.TextFlow;
+	import org.apache.flex.textLayout.factory.TLFFactory;
+	import org.apache.flex.textLayout.formats.Float;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.formats.LeadingModel;
+	import org.apache.flex.textLayout.formats.ListMarkerFormat;
+	import org.apache.flex.textLayout.formats.ListStyleType;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+	import org.apache.flex.textLayout.property.PropertyFactory;
+	import org.apache.flex.textLayout.property.PropertyUtil;
+	import org.apache.flex.utils.ObjectMap;
+
+	// [ExcludeClass]
+	/** 
+	 * @private
+	 * TextFieldHtmlImporter converts from HTML to TextLayout data structures
+	 */
+	public class TextFieldHtmlImporter extends BaseTextLayoutImporter implements IHTMLImporter {
+		// TLF formats to which <font/> attributes map directly
+		/** @private */
+		static public const _fontDescription:Object = {"color":TextLayoutFormat.colorProperty, "trackingRight":TextLayoutFormat.trackingRightProperty, "fontFamily":TextLayoutFormat.fontFamilyProperty};
+		// <font/> attributes that require custom logic for mapping to TLF formats
+		/** @private */
+		static public const _fontMiscDescription:Object = {"size":PropertyFactory.string("size", null, false, null), "kerning":PropertyFactory.string("kerning", null, false, null)};
+		// TLF formats to which <textformat/> attributes map directly
+		/** @private */
+		static public const _textFormatDescription:Object = {"paragraphStartIndent":TextLayoutFormat.paragraphStartIndentProperty, "paragraphEndIndent":TextLayoutFormat.paragraphEndIndentProperty, "textIndent":TextLayoutFormat.textIndentProperty, "lineHeight":TextLayoutFormat.lineHeightProperty, "tabStops":TextLayoutFormat.tabStopsProperty};
+		// <textformat/> attributes that require custom logic for mapping to TLF formats
+		/** @private */
+		static public const _textFormatMiscDescription:Object = {"blockIndent":PropertyFactory.string("blockIndent", null, false, null)};
+		/** @private */
+		static public const _paragraphFormatDescription:Object = {"textAlign":TextLayoutFormat.textAlignProperty};
+		/** @private */
+		static public const _linkHrefDescription:Object = {"href":PropertyFactory.string("href", null, false, null)};
+		/** @private */
+		static public const _linkTargetDescription:Object = {"target":PropertyFactory.string("target", null, false, null)};
+		/** @private */
+		static public const _imageDescription:Object = {"height":InlineGraphicElement.heightPropertyDefinition, "width":InlineGraphicElement.widthPropertyDefinition};
+		// Separate description because id value is case-sensitive unlike others
+		/** @private */
+		static public const _imageMiscDescription:Object = {"src":PropertyFactory.string("src", null, false, null), "align":PropertyFactory.string("align", null, false, null)};
+		/** @private Finish defining at run time because it has a member variable "CLASS" which is a reserved keyword. */
+		static public const _classAndIdDescription:Object = {"id":PropertyFactory.string("ID", null, false, null)};
+		// For some reason, the following can't be initialized here
+		/** @private */
+		static public var _fontImporter:FontImporter;
+		/** @private */
+		static public var _fontMiscImporter:CaseInsensitiveTLFFormatImporter;
+		/** @private */
+		static public var _textFormatImporter:TextFormatImporter;
+		/** @private */
+		static public var _textFormatMiscImporter:CaseInsensitiveTLFFormatImporter;
+		/** @private */
+		static public var _paragraphFormatImporter:HtmlCustomParaFormatImporter;
+		/** @private */
+		static public var _linkHrefImporter:CaseInsensitiveTLFFormatImporter;
+		/** @private */
+		static public var _linkTargetImporter:CaseInsensitiveTLFFormatImporter;
+		/** @private */
+		static public var _ilgFormatImporter:CaseInsensitiveTLFFormatImporter;
+		/** @private */
+		static public var _ilgMiscFormatImporter:CaseInsensitiveTLFFormatImporter;
+		/** @private */
+		static public var _classAndIdImporter:CaseInsensitiveTLFFormatImporter;
+		// Formats specified by formatting elements in the ancestry of the element being parsed currently
+		/** @private */
+		static public var _activeFormat:TextLayoutFormat = new TextLayoutFormat(); // to be applied to all flow elements
+		/** @private */
+		static public var _activeParaFormat:TextLayoutFormat = new TextLayoutFormat(); // to be applied to paras only
+		/** @private */
+		static public var _activeImpliedParaFormat:TextLayoutFormat = null;
+		// The basis for relative font size calculation
+		/** @private */
+		public var _baseFontSize:Number;
+		/** @private */
+		public static var _htmlImporterConfig:ImportExportConfiguration;
+		private var _imageSourceResolveFunction:Function;
+		private var _preserveBodyElement:Boolean = false;
+		private var _importHtmlElement:Boolean = false;
+
+		/** Constructor */
+		public function TextFieldHtmlImporter() {
+			createConfig();
+			super(null, _htmlImporterConfig);
+		}
+
+		/** @private */
+		public static function createConfig():void {
+			if (!_htmlImporterConfig) {
+				_htmlImporterConfig = new ImportExportConfiguration();
+
+				_htmlImporterConfig.addIEInfo("BR", BreakElement, BaseTextLayoutImporter.parseBreak, null);
+				_htmlImporterConfig.addIEInfo("P", IParagraphElement, TextFieldHtmlImporter.parsePara, null);
+				_htmlImporterConfig.addIEInfo("SPAN", SpanElement, TextFieldHtmlImporter.parseSpan, null);
+				_htmlImporterConfig.addIEInfo("A", LinkElement, TextFieldHtmlImporter.parseLink, null);
+				_htmlImporterConfig.addIEInfo("IMG", InlineGraphicElement, TextFieldHtmlImporter.parseInlineGraphic, null);
+				_htmlImporterConfig.addIEInfo("DIV", DivElement, TextFieldHtmlImporter.parseDiv, null);
+				_htmlImporterConfig.addIEInfo("HTML", null, TextFieldHtmlImporter.parseHtmlElement, null);
+				_htmlImporterConfig.addIEInfo("BODY", null, TextFieldHtmlImporter.parseBody, null);
+
+				// formatting elements
+				_htmlImporterConfig.addIEInfo("FONT", null, TextFieldHtmlImporter.parseFont, null);
+				_htmlImporterConfig.addIEInfo("TEXTFORMAT", null, TextFieldHtmlImporter.parseTextFormat, null);
+				_htmlImporterConfig.addIEInfo("U", null, TextFieldHtmlImporter.parseUnderline, null);
+				_htmlImporterConfig.addIEInfo("I", null, TextFieldHtmlImporter.parseItalic, null);
+				_htmlImporterConfig.addIEInfo("B", null, TextFieldHtmlImporter.parseBold, null);
+				_htmlImporterConfig.addIEInfo("S", null, TextFieldHtmlImporter.parseStrikeThrough, null);
+
+				// list stuff
+				_htmlImporterConfig.addIEInfo("UL", null, BaseTextLayoutImporter.parseList, null);
+				_htmlImporterConfig.addIEInfo("OL", null, BaseTextLayoutImporter.parseList, null);
+				_htmlImporterConfig.addIEInfo("LI", null, TextFieldHtmlImporter.parseListItem, null);
+			}
+
+			// create these here - can't be done above
+			if (_classAndIdDescription["CLASS"] === undefined) {
+				_classAndIdDescription["CLASS"] = PropertyFactory.string("CLASS", null, false, null);
+				_paragraphFormatImporter = new HtmlCustomParaFormatImporter(TextLayoutFormat, _paragraphFormatDescription);
+				_textFormatImporter = new TextFormatImporter(TextLayoutFormat, _textFormatDescription);
+				_fontImporter = new FontImporter(TextLayoutFormat, _fontDescription);
+				_fontMiscImporter = new CaseInsensitiveTLFFormatImporter(ObjectMap, _fontMiscDescription);
+				_textFormatMiscImporter = new CaseInsensitiveTLFFormatImporter(ObjectMap, _textFormatMiscDescription);
+				_linkHrefImporter = new CaseInsensitiveTLFFormatImporter(ObjectMap, _linkHrefDescription, false);
+				_linkTargetImporter = new CaseInsensitiveTLFFormatImporter(ObjectMap, _linkTargetDescription);
+				_ilgFormatImporter = new CaseInsensitiveTLFFormatImporter(ObjectMap, _imageDescription);
+				_ilgMiscFormatImporter = new CaseInsensitiveTLFFormatImporter(ObjectMap, _imageMiscDescription, false);
+				_classAndIdImporter = new CaseInsensitiveTLFFormatImporter(ObjectMap, _classAndIdDescription);
+			}
+		}
+
+		/** @copy IHTMLExporter#imageSourceResolveFunction
+		 * 
+		 * @playerversion Flash 10.0
+		 * @playerversion AIR 2.0
+		 * @langversion 3.0
+		 */
+		public function get imageSourceResolveFunction():Function {
+			return _imageSourceResolveFunction;
+		}
+
+		public function set imageSourceResolveFunction(resolver:Function):void {
+			_imageSourceResolveFunction = resolver;
+		}
+
+		/** @copy IHTMLExporter#preserveBodyElement
+		 * 
+		 * @playerversion Flash 10.0
+		 * @playerversion AIR 2.0
+		 * @langversion 3.0
+		 */
+		public function get preserveBodyElement():Boolean {
+			return _preserveBodyElement;
+		}
+
+		public function set preserveBodyElement(value:Boolean):void {
+			_preserveBodyElement = value;
+		}
+
+		/** @copy IHTMLExporter#preserveHTMLElement
+		 *
+		 * @playerversion Flash 10.0
+		 * @playerversion AIR 2.0
+		 * @langversion 3.0
+		 */
+		public function get preserveHTMLElement():Boolean {
+			return _importHtmlElement;
+		}
+
+		public function set preserveHTMLElement(value:Boolean):void {
+			_importHtmlElement = value;
+		}
+
+		/** Parse and convert input data
+		 * 
+		 * @param source - the HTML string
+		 */
+		protected override function importFromString(source:String):TextFlow {
+			var textFlow:TextFlow;
+
+			// Use toXML rather than the XML constructor because the latter expects
+			// well-formed XML, which source may not be
+			var xml:XML = toXML(source);
+			if (xml) {
+				textFlow = importFromXML(xml);
+				// TODO probably does not make sense to FlexJS 
+				// if (Configuration.playerEnablesArgoFeatures)
+				// System["disposeXML"](xml);
+			}
+			return textFlow;
+		}
+
+		/** Parse and convert input XML data
+		 */
+		protected override function importFromXML(xmlSource:XML):TextFlow {
+			var textFlow:TextFlow = new TextFlow(TLFFactory.defaultTLFFactory, _textFlowConfiguration);
+			// always set html typeName - the convertfromstring to xml code wraps the content in an HTML element.  this makes it all match
+			if (this.preserveHTMLElement)
+				textFlow.typeName = "html";
+
+			// Use font size specified in _textFlowConfiguration.textFlowInitialFormat as the base font size
+			// If not specified, use 12
+			_baseFontSize = textFlow.fontSize === undefined ? 12 : textFlow.fontSize;
+
+			// Unlike other markup formats, the HTML format for TLF does not have a fixed root XML element.
+			// <html> and <body> are optional, and flow elements may or may not be encapsulated in formatting
+			// elements like <i> or <textformat>. Use parseObject to handle any (expected) root element.
+			CONFIG::debug {
+				assert(xmlSource.name() != null, "Bad XML source"); }
+			parseObject(xmlSource.name().localName, xmlSource, textFlow);
+
+			// If the last para is implied, there is nothing following it that'll trigger a reset.
+			// For most importers, this is fine (clear will eventually reset it), but the HTML importer has
+			// some special behavior associated with the reset (replacing BreakElements with para splits).
+			// Explicitly do so now (must happen before normalization)
+			resetImpliedPara();
+
+			CONFIG::debug {
+				textFlow.debugCheckNormalizeAll() ; }
+			textFlow.normalize();
+			textFlow.applyWhiteSpaceCollapse(null);
+
+			return textFlow;
+		}
+
+		/** @copy ConverterBase#clear()
+		 * @private
+		 */
+		public override function clear():void {
+			// Reset active formats and base font size
+			_activeParaFormat.clearStyles();
+			_activeFormat.clearStyles();
+			super.clear();
+		}
+
+		/** @private */
+		public override function createImpliedParagraph():IParagraphElement {
+			var rslt:IParagraphElement;
+			var savedActiveFormat:TextLayoutFormat = _activeFormat;
+			if (_activeImpliedParaFormat)
+				_activeFormat = _activeImpliedParaFormat;
+			try {
+				rslt = super.createImpliedParagraph();
+			} finally {
+				_activeFormat = savedActiveFormat;
+			}
+			return rslt;
+		}
+
+		/** @private */
+		public override function createParagraphFromXML(xmlToParse:XML):IParagraphElement {
+			var paraElem:IParagraphElement = ElementHelper.getParagraph();
+
+			// Parse xml attributes for paragraph format
+			var formatImporters:Array = [_paragraphFormatImporter, _classAndIdImporter];
+			parseAttributes(xmlToParse, formatImporters);
+			var paragraphFormat:TextLayoutFormat = new TextLayoutFormat(_paragraphFormatImporter.result as ITextLayoutFormat);
+
+			// Apply paragraph format inherited from formatting elements
+			if (_activeParaFormat)
+				paragraphFormat.apply(_activeParaFormat);
+			if (_activeFormat)
+				paragraphFormat.apply(_activeFormat);
+
+			// A <FONT/> that is the only child of a <P/> specifies formats that apply to the paragraph itself
+			// Otherwise (i.e., if it has siblings), the formats apply to the elements nested within the <FONT/>
+			// Check for the former case here
+			var fontFormattingElement:XML = getSingleFontChild(xmlToParse);
+			if (fontFormattingElement)
+				paragraphFormat.apply(parseFontAttributes(fontFormattingElement));
+
+			if (paragraphFormat.lineHeight !== undefined)
+				paragraphFormat.leadingModel = LeadingModel.APPROXIMATE_TEXT_FIELD;
+
+			paraElem.format = paragraphFormat;
+
+			// Use the value of the 'class' attribute (if present) as styleName
+			paraElem.styleName = _classAndIdImporter.getFormatValue("CLASS");
+			paraElem.id = _classAndIdImporter.getFormatValue("ID");
+
+			return paraElem;
+		}
+
+		/** @private */
+		static public function parseListItem(importer:TextFieldHtmlImporter, xmlToParse:XML, parent:IFlowGroupElement):void {
+			if (!(parent is IListElement)) {
+				var list:IListElement = importer.createListFromXML(null);
+				importer.addChild(parent, list);
+				CONFIG::debug {
+					assert(list.parent == parent, "TextFieldHtmlImporter.parseListeItem: Bad call to addChild"); }
+				parent = list;
+			}
+
+			var listItem:IListItemElement = importer.createListItemFromXML(xmlToParse);
+			if (importer.addChild(parent, listItem)) {
+				importer.parseFlowGroupElementChildren(xmlToParse, listItem);
+				// if parsing an empty list item, create a Paragraph for it.
+				if (listItem.numChildren == 0)
+					listItem.addChild(ElementHelper.getParagraph());
+			}
+		}
+
+		/** @private */
+		public override function createListFromXML(xmlToParse:XML):IListElement	// No PMD
+		{
+			parseAttributes(xmlToParse, [_classAndIdImporter]);
+
+			// try and make lists look something like TextField but with a bit more - do ordered lists as well not just bullets
+			// textField indents lists on the left by 36 pixels.
+
+			var list:IListElement = ElementHelper.getList();
+			list.paddingLeft = 36;
+			var name:String = xmlToParse ? xmlToParse.name().localName : null;
+			list.listStyleType = name == "OL" ? ListStyleType.DECIMAL : ListStyleType.DISC;
+
+			// TextField does equivalent of a 18 pixel start indent but that doesnt look nice with numbered lists.
+			// default bullet is around 4 pixels. so place the marker 14 pixels from the right side
+			var lmf:ListMarkerFormat = new ListMarkerFormat();
+			lmf.paragraphEndIndent = 14;
+			list.listMarkerFormat = lmf;
+
+			list.styleName = _classAndIdImporter.getFormatValue("CLASS");
+			list.id = _classAndIdImporter.getFormatValue("ID");
+
+			return list;
+		}
+
+		/** @private */
+		public override function createListItemFromXML(xmlToParse:XML):IListItemElement	// No PMD
+		{
+			parseAttributes(xmlToParse, [_classAndIdImporter]);
+
+			var listItem:IListItemElement = ElementHelper.getListItem();
+			listItem.styleName = _classAndIdImporter.getFormatValue("CLASS");
+			listItem.id = _classAndIdImporter.getFormatValue("ID");
+
+			return listItem;
+		}
+
+		/** Parse the supplied XML into a paragraph. Parse the <p/> element and its children.
+		 * @private
+		 * @param importer	parser object
+		 * @param xmlToParse	content to parse
+		 * @param parent 		the parent for the new content
+		 */
+		static public function parsePara(importer:TextFieldHtmlImporter, xmlToParse:XML, parent:IFlowGroupElement):void {
+			var paraElem:IParagraphElement = importer.createParagraphFromXML(xmlToParse);
+
+			if (importer.addChild(parent, paraElem)) {
+				// Parse children, but if there is only one child, a <FONT/>, skip to *its* children.
+				// That's because the single <FONT/> chuld has already been parsed in createParagraphFromXML.
+				var fontFormattingElement:XML = getSingleFontChild(xmlToParse);
+				parseChildrenUnderNewActiveFormat(importer, fontFormattingElement ? fontFormattingElement : xmlToParse, paraElem, _activeFormat, null);
+
+				// if parsing an empty paragraph, create a Span for it.
+				if (paraElem.numChildren == 0)
+					paraElem.addChild(importer.createImpliedSpan(""));
+			}
+
+			// Replace break elements with paragraph splits
+			// This must happen before normalization else BreakElements may merge or become spans
+			replaceBreakElementsWithParaSplits(paraElem);
+		}
+
+		/** Parse the supplied XML into a DivElement. Parse the <p/> element and its children.
+		 * @private
+		 * @param importer	parser object
+		 * @param xmlToParse	content to parse
+		 * @param parent 		the parent for the new content
+		 */
+		static public function parseDiv(importer:TextFieldHtmlImporter, xmlToParse:XML, parent:IFlowGroupElement):void {
+			var elem:IFlowGroupElement;
+			if (parent.canOwnFlowElement(new DivElement()))
+				elem = importer.createDivFromXML(xmlToParse);
+			else {
+				elem = importer.createSPGEFromXML(xmlToParse);
+				elem.typeName = "div";
+			}
+
+			importer.addChild(parent, elem);
+			importer.parseFlowGroupElementChildren(xmlToParse, elem);
+		}
+
+		static public function parseHtmlElement(importer:TextFieldHtmlImporter, xmlToParse:XML, parent:IFlowGroupElement):void {
+			// skip the element and descent to the children
+			if (importer.preserveHTMLElement) {
+				if (!(parent is TextFlow)) {
+					var newParent:IFlowGroupElement = ((parent is IParagraphElement) || (parent is SubParagraphGroupElementBase)) ? new SubParagraphGroupElement() : new DivElement;
+					parent.addChild(newParent);
+					parent = newParent;
+				}
+				importer.parseAttributes(xmlToParse, [_classAndIdImporter]);
+				parent.typeName = "html";
+				parent.styleName = _classAndIdImporter.getFormatValue("CLASS");
+				parent.id = _classAndIdImporter.getFormatValue("ID");
+			}
+			importer.parseFlowGroupElementChildren(xmlToParse, parent, null, true);
+		}
+
+		static public function parseBody(importer:TextFieldHtmlImporter, xmlToParse:XML, parent:IFlowGroupElement):void {
+			// skip the element and descent to the children
+			if (importer.preserveBodyElement) {
+				var newParent:IFlowGroupElement = ((parent is IParagraphElement) || (parent is SubParagraphGroupElementBase)) ? new SubParagraphGroupElement() : new DivElement;
+				parent.addChild(newParent);
+				parent = newParent;
+
+				importer.parseAttributes(xmlToParse, [_classAndIdImporter]);
+				parent.typeName = "body";
+				parent.styleName = _classAndIdImporter.getFormatValue("CLASS");
+				parent.id = _classAndIdImporter.getFormatValue("ID");
+			}
+			importer.parseFlowGroupElementChildren(xmlToParse, parent, null, true);
+		}
+
+		public function createDivFromXML(xmlToParse:XML):DivElement {
+			parseAttributes(xmlToParse, [_classAndIdImporter]);
+
+			var divElement:DivElement = new DivElement();
+			divElement.styleName = _classAndIdImporter.getFormatValue("CLASS");
+			divElement.id = _classAndIdImporter.getFormatValue("ID");
+
+			return divElement;
+		}
+
+		public function createSPGEFromXML(xmlToParse:XML):SubParagraphGroupElement {
+			parseAttributes(xmlToParse, [_classAndIdImporter]);
+
+			var spge:SubParagraphGroupElement = new SubParagraphGroupElement();
+			spge.styleName = _classAndIdImporter.getFormatValue("CLASS");
+			spge.id = _classAndIdImporter.getFormatValue("ID");
+
+			return spge;
+		}
+
+		/** @private */
+		protected override function onResetImpliedPara(para:IParagraphElement):void {
+			// Replacing break elements with paragraph splits, even for implied paras
+			replaceBreakElementsWithParaSplits(para);
+		}
+
+		/** If the provided xml has a single child <FONT.../>, get it
+		 * @private
+		 */
+		static private function getSingleFontChild(xmlToParse:XML):XML {
+			var children:XMLList = xmlToParse.children();
+			if (children.length() == 1) {
+				var child:XML = children[0];
+				if (child.name() && child.name().localName.toUpperCase() == "FONT")
+					return child;
+			}
+
+			return null;
+		}
+
+		private function createLinkFromXML(xmlToParse:XML):LinkElement {
+			var linkElem:LinkElement = new LinkElement();
+
+			var formatImporters:Array = [_linkHrefImporter, _linkTargetImporter, _classAndIdImporter];
+			parseAttributes(xmlToParse, formatImporters);
+
+			linkElem.href = _linkHrefImporter.getFormatValue("HREF");
+			linkElem.target = _linkTargetImporter.getFormatValue("TARGET");
+
+			// Handle difference in defaults between TextField and TLF
+			// target "_self" vs. null (equivalent to "_blank")
+			if (!linkElem.target)
+				linkElem.target = "_self";
+
+			// Apply active format
+			linkElem.format = _activeFormat;
+
+			linkElem.styleName = _classAndIdImporter.getFormatValue("CLASS");
+			linkElem.id = _classAndIdImporter.getFormatValue("ID");
+
+			return linkElem;
+		}
+
+		/** Parse the supplied XML into a LinkElement. Parse the <a/> element and its children.
+		 * @private
+		 * @param importer	parser object
+		 * @param xmlToParse	content to parse
+		 * @param parent 		the parent for the new content
+		 */
+		static public function parseLink(importer:TextFieldHtmlImporter, xmlToParse:XML, parent:IFlowGroupElement):void {
+			var linkElem:LinkElement = importer.createLinkFromXML(xmlToParse);
+
+			if (importer.addChild(parent, linkElem)) {
+				parseChildrenUnderNewActiveFormat(importer, xmlToParse, linkElem, _activeFormat, null);
+			}
+		}
+
+		/** @private returns a string if its a simple span otherwise null */
+		public static function extractSimpleSpanText(xmlToParse:XML):String {
+			var elemList:XMLList = xmlToParse[0].children();
+			if (elemList.length() == 0)
+				return "";
+			if (elemList.length() != 1)
+				return null;
+			// sniff the first child and test if its a textelement
+			for each (var child:XML in elemList)
+				break;
+			var elemName:String = child.name() ? child.name().localName : null;
+			if (elemName != null)
+				return null;
+
+			var rslt:String = child.toString();
+			return rslt ? rslt : "";
+		}
+
+		/** Static method for constructing a span from XML. Parse the <span> ... </span> tag. 
+		 * Insert the new content into its parent
+		 * Note: Differs from BaseTextLayoutImporter.parseSpan in that it allows nested <span/> elements. 
+		 * @private
+		 * @param importer	parser object
+		 * @param xmlToParse	content to parse
+		 * @param parent 		the parent for the new content
+		 */
+		static public function parseSpan(importer:TextFieldHtmlImporter, xmlToParse:XML, parent:IFlowGroupElement):void {
+			// Use the value of the 'class' attribute (if present) as styleName
+			importer.parseAttributes(xmlToParse, [_classAndIdImporter]);
+
+			// if either class or id is set and its not a "simple" span then we need to create an SPGE and descend
+			var classFormatValue:* = _classAndIdImporter.getFormatValue("CLASS");
+			var idFormatValue:* = _classAndIdImporter.getFormatValue("ID");
+
+			var simpleSpanText:String = extractSimpleSpanText(xmlToParse);
+
+			if (simpleSpanText == null) {
+				// if its an interesting span make an SPGE otherwise just parse the children
+				if (classFormatValue !== undefined || idFormatValue !== undefined || !TextLayoutFormat.isEqual(_activeFormat, TextLayoutFormat.emptyTextLayoutFormat)) {
+					var spge:SubParagraphGroupElement = new SubParagraphGroupElement();
+					spge.format = _activeFormat;
+					spge.styleName = classFormatValue;
+					spge.id = idFormatValue;
+					spge.typeName = "span";
+					importer.addChild(parent, spge);
+					parent = spge;
+				}
+				parseChildrenUnderNewActiveFormat(importer, xmlToParse, parent, _activeFormat, null);
+				return;
+			}
+
+			var span:SpanElement = new SpanElement();
+			span.format = _activeFormat;
+			span.styleName = classFormatValue;
+			span.id = idFormatValue;
+			span.text = simpleSpanText;
+
+			importer.addChild(parent, span);
+		}
+
+		/** create an implied span with specified text */
+		public override function createImpliedSpan(text:String):SpanElement {
+			var span:SpanElement = super.createImpliedSpan(text);
+			span.format = _activeFormat;
+			return span;
+		}
+
+		/** @private */
+		protected function createInlineGraphicFromXML(xmlToParse:XML):InlineGraphicElement {
+			var imgElem:InlineGraphicElement = new InlineGraphicElement();
+
+			var formatImporters:Array = [_ilgFormatImporter, _ilgMiscFormatImporter, _classAndIdImporter];
+			parseAttributes(xmlToParse, formatImporters);
+
+			var source:String = _ilgMiscFormatImporter.getFormatValue("SRC");
+			imgElem.source = _imageSourceResolveFunction != null ? _imageSourceResolveFunction(source) : source;
+
+			// if not defined then let InlineGraphic set its own default
+			imgElem.height = InlineGraphicElement.heightPropertyDefinition.setHelper(imgElem.height, _ilgFormatImporter.getFormatValue("HEIGHT"));
+			imgElem.width = InlineGraphicElement.heightPropertyDefinition.setHelper(imgElem.width, _ilgFormatImporter.getFormatValue("WIDTH"));
+
+			var floatVal:String = _ilgMiscFormatImporter.getFormatValue("ALIGN");
+			// Handle difference in defaults between TextField and TLF
+			// float "left" vs. "none"
+			if (floatVal == Float.LEFT || floatVal == Float.RIGHT)
+				imgElem.float = floatVal;
+
+			// Apply active format
+			imgElem.format = _activeFormat;
+			imgElem.id = _classAndIdImporter.getFormatValue("ID");
+			imgElem.styleName = _classAndIdImporter.getFormatValue("CLASS");
+
+			return imgElem;
+		}
+
+		/** Parse the supplied XML into an InlineGraphicElement. Parse the <img/> element.
+		 * @private
+		 * @param importer	parser object
+		 * @param xmlToParse	content to parse
+		 * @param parent 		the parent for the new content
+		 */
+		static public function parseInlineGraphic(importer:TextFieldHtmlImporter, xmlToParse:XML, parent:IFlowGroupElement):void {
+			var ilg:InlineGraphicElement = importer.createInlineGraphicFromXML(xmlToParse);
+			importer.addChild(parent, ilg);
+		}
+
+		/** @private */
+		public override function createTabFromXML(xmlToParse:XML):TabElement {
+			return null; // no tabs in HTML
+		}
+
+		/** Parse the attributes of the <Font/> formatting element and returns the corresponding TLF format
+		 * @private
+		 */
+		protected function parseFontAttributes(xmlToParse:XML):ITextLayoutFormat {
+			var formatImporters:Array = [_fontImporter, _fontMiscImporter];
+			parseAttributes(xmlToParse, formatImporters);
+
+			var newFormat:TextLayoutFormat = new TextLayoutFormat(_fontImporter.result as ITextLayoutFormat);
+
+			var kerning:String = _fontMiscImporter.getFormatValue("KERNING");
+			if (kerning) {
+				var kerningVal:Number = Number(kerning);
+				newFormat.kerning = kerningVal == 0 ? Kerning.OFF : Kerning.AUTO;
+			}
+
+			var size:String = _fontMiscImporter.getFormatValue("SIZE");
+			if (size) {
+				var sizeVal:Number = TextLayoutFormat.fontSizeProperty.setHelper(NaN, size);
+				if (!isNaN(sizeVal)) {
+					if (size.search(/\s*(-|\+)/) != -1) // leading whitespace followed by + or -
+						sizeVal += _baseFontSize;		// implies relative font sizes
+					newFormat.fontSize = sizeVal;
+				}
+			}
+
+			return newFormat;
+		}
+
+		/** Parse the <Font/> formatting element
+		 * Calculates the new format to apply to _activeFormat and continues parsing down the hierarchy
+		 * @private
+		 */
+		static public function parseFont(importer:TextFieldHtmlImporter, xmlToParse:XML, parent:IFlowGroupElement):void {
+			var newFormat:ITextLayoutFormat = importer.parseFontAttributes(xmlToParse);
+			parseChildrenUnderNewActiveFormatWithImpliedParaFormat(importer, xmlToParse, parent, newFormat);
+		}
+
+		/** Parse the <TextFormat> formatting element
+		 * Calculates the new format to apply to _activeParaFormat and continues parsing down the hierarchy
+		 * @private
+		 */
+		static public function parseTextFormat(importer:TextFieldHtmlImporter, xmlToParse:XML, parent:IFlowGroupElement):void {
+			var formatImporters:Array = [_textFormatImporter, _textFormatMiscImporter];
+			importer.parseAttributes(xmlToParse, formatImporters);
+
+			var newFormat:TextLayoutFormat = new TextLayoutFormat(_textFormatImporter.result as ITextLayoutFormat);
+
+			var blockIndent:* = _textFormatMiscImporter.getFormatValue("BLOCKINDENT");
+			if (blockIndent !== undefined) {
+				// TODO: Nested <TextFormat/>?
+				blockIndent = TextLayoutFormat.paragraphStartIndentProperty.setHelper(undefined, blockIndent);
+				if (blockIndent !== undefined) {
+					var blockIndentVal:Number = Number(blockIndent);
+					newFormat.paragraphStartIndent = newFormat.paragraphStartIndent === undefined ? blockIndentVal : newFormat.paragraphStartIndent + blockIndentVal;
+				}
+			}
+
+			// lineHeight is the only textformat property that must be copied down into subparagraph elements
+			var saveLineHeight:* = _activeFormat.lineHeight;
+			if (parent is IParagraphElement) {
+				if (parent.numChildren == 0) {
+					// if <textFormat> is the first child then promote all the settings to the Paragraph
+					var format:TextLayoutFormat = new TextLayoutFormat(parent.format);
+					format.apply(newFormat);
+					// same as createParagraphFromXML
+					if (format.lineHeight !== undefined)
+						format.leadingModel = LeadingModel.APPROXIMATE_TEXT_FIELD;
+					parent.format = format;
+					newFormat.clearStyles();
+				} else if (newFormat.lineHeight !== undefined)
+					_activeFormat.lineHeight = newFormat.lineHeight;
+			}
+
+			parseChildrenUnderNewActiveFormat(importer, xmlToParse, parent, _activeParaFormat, newFormat, true);
+
+			_activeFormat.lineHeight = saveLineHeight;
+		}
+
+		/** Parse the <b> formatting element
+		 * Calculates the new format to apply to _activeFormat and continues parsing down the hierarchy
+		 * @private
+		 */
+		static public function parseBold(importer:TextFieldHtmlImporter, xmlToParse:XML, parent:IFlowGroupElement):void {
+			var newFormat:TextLayoutFormat = new TextLayoutFormat();
+			newFormat.fontWeight = org.apache.flex.text.engine.FontWeight.BOLD;
+
+			parseChildrenUnderNewActiveFormatWithImpliedParaFormat(importer, xmlToParse, parent, newFormat);
+		}
+
+		/** Parse the <i> formatting element
+		 * Calculates the new format to apply to _activeFormat and continues parsing down the hierarchy
+		 * @private
+		 */
+		static public function parseItalic(importer:TextFieldHtmlImporter, xmlToParse:XML, parent:IFlowGroupElement):void {
+			var newFormat:TextLayoutFormat = new TextLayoutFormat();
+			newFormat.fontStyle = org.apache.flex.text.engine.FontPosture.ITALIC;
+			parseChildrenUnderNewActiveFormatWithImpliedParaFormat(importer, xmlToParse, parent, newFormat);
+		}
+
+		/** Parse the <s> formatting element
+		 * Calculates the new format to apply to _activeFormat and continues parsing down the hierarchy
+		 * @private
+		 */
+		static public function parseStrikeThrough(importer:TextFieldHtmlImporter, xmlToParse:XML, parent:IFlowGroupElement):void {
+			var newFormat:TextLayoutFormat = new TextLayoutFormat();
+			newFormat.lineThrough = true;
+			parseChildrenUnderNewActiveFormatWithImpliedParaFormat(importer, xmlToParse, parent, newFormat);
+		}
+
+		/** Parse the <u> formatting element
+		 * Calculates the new format to apply to _activeFormat and continues parsing down the hierarchy
+		 * @private
+		 */
+		static public function parseUnderline(importer:TextFieldHtmlImporter, xmlToParse:XML, parent:IFlowGroupElement):void {
+			var newFormat:TextLayoutFormat = new TextLayoutFormat();
+			newFormat.textDecoration = org.apache.flex.textLayout.formats.TextDecoration.UNDERLINE;
+			parseChildrenUnderNewActiveFormatWithImpliedParaFormat(importer, xmlToParse, parent, newFormat);
+		}
+
+		/** @private */
+		static protected function parseChildrenUnderNewActiveFormatWithImpliedParaFormat(importer:TextFieldHtmlImporter, xmlToParse:XML, parent:IFlowGroupElement, newFormat:ITextLayoutFormat):void {
+			var oldActiveImpliedParaFormat:TextLayoutFormat = _activeImpliedParaFormat;
+			if (_activeImpliedParaFormat == null)
+				_activeImpliedParaFormat = new TextLayoutFormat(_activeFormat);
+			try {
+				parseChildrenUnderNewActiveFormat(importer, xmlToParse, parent, _activeFormat, newFormat, true);
+			} finally {
+				_activeImpliedParaFormat = oldActiveImpliedParaFormat;
+			}
+		}
+
+		/** Updates the current active format and base font size as specified, parses children, and restores the active format and base font size
+		 * There are two different use cases for this method:
+		 * - Parsing children of a formatting XML element like <Font/> or <TextFormat/>. In this case, the TLF format corresponding to the formatting element
+		 * (newFormat) is applied to the currently active format (_activeFormat in the case of <Font/> and _activeParaFormat in the case of <TextFormat/>). 
+		 * Children of the formatting element are parsed under this new active format.
+		 * - Parsing children of a flow XML element like <P/> or <A/>. In this case, newFormat is null and the currently active format (_activeFormat) is reset.
+		 * Children of the flow element are parsed under this newly reset format. This is to avoid redundancy (the format is already applied to the flow element). 
+		 * 
+		 * @param importer	parser object
+		 * @param xmlToParse	content to parse
+		 * @param parent 		the parent for the parsed children
+		 * @param currFormat	the active format (_activeFormat or _activeParaFormat)
+		 * @param newFormat		the format to apply to currFormat while the children are being parsed. If null, currFormat is to be reset.
+		 * @param chainedParent whether parent actually corresponds to xmlToParse or has been chained (such as when xmlToParse is a formatting element). See BaseTextLayoutImporter.parseFlowGroupElementChildren
+		 * @private
+		 */
+		static protected function parseChildrenUnderNewActiveFormat(importer:TextFieldHtmlImporter, xmlToParse:XML, parent:IFlowGroupElement, currFormat:TextLayoutFormat, newFormat:ITextLayoutFormat, chainedParent:Boolean = false):void {
+			// Remember the current state
+			var restoreBaseFontSize:Number = importer._baseFontSize;
+			var restoreStyles:Object = PropertyUtil.shallowCopy(currFormat.getStyles());
+
+			if (newFormat) {
+				// Update base font size based on the new format
+				if (newFormat.fontSize !== undefined)
+					importer._baseFontSize = newFormat.fontSize;
+
+				// Apply the new format
+				currFormat.apply(newFormat);
+			} else {
+				// Base font size remains unchanged
+
+				// Reset the new format
+				currFormat.clearStyles();
+			}
+
+			try {
+				var beforeCount:int = parent.numChildren;
+				importer.parseFlowGroupElementChildren(xmlToParse, parent, null, chainedParent);
+				// if nothing was added create something - otherwise this construct fails <p><b/></p>
+				if (beforeCount == parent.numChildren) {
+					var span:SpanElement = importer.createImpliedSpan("");
+					importer.addChild(parent, span);
+				}
+			} finally {
+				// Restore
+				currFormat.setStyles(restoreStyles, false);
+				importer._baseFontSize = restoreBaseFontSize;
+			}
+		}
+
+		/** @private */
+		protected override function handleUnknownAttribute(elementName:String, propertyName:String):void {
+			// A toss-up: report error or ignore? Ignore for now
+			// If we do end up reporting error, we should add exceptions for documented attributes that we don't handle
+			// like align on <img/>
+		}
+
+		/** @private */
+		protected override function handleUnknownElement(name:String, xmlToParse:XML, parent:IFlowGroupElement):void {
+			var newParent:IFlowGroupElement;	// scratch
+			// Not an error (it may be a styling element like <h1/>); continue parsing children
+
+			// a couple of cases
+			// 1) must make a div/spge - if activeFormat or id or stylename is set OR parent is a IListElement (otherwise we wind up trying to put ListItems in a Div which is not supported)
+			// 2) may make a div/spge - if more than one child is added to parent OR the added child has an id/stylename/typename
+			// 3) otherwise just set the typeName of the single added child
+
+			// Use the value of the 'class' attribute (if present) as styleName
+			parseAttributes(xmlToParse, [_classAndIdImporter]);
+
+			// if either class or id is set and its not a "simple" span then we need to create an SPGE and descend
+			var classFormatValue:* = _classAndIdImporter.getFormatValue("CLASS");
+			var idFormatValue:* = _classAndIdImporter.getFormatValue("ID");
+
+			if (classFormatValue !== undefined || idFormatValue !== undefined || !TextLayoutFormat.isEqual(_activeFormat, TextLayoutFormat.emptyTextLayoutFormat) || (parent is IListElement)) {
+				newParent = ((parent is IParagraphElement) || (parent is SubParagraphGroupElementBase)) ? new SubParagraphGroupElement() : new DivElement;
+				addChild(parent, newParent);
+
+				newParent.format = _activeFormat;
+				newParent.typeName = name.toLowerCase();
+				newParent.styleName = classFormatValue;
+				newParent.id = idFormatValue;
+				parseChildrenUnderNewActiveFormat(this, xmlToParse, newParent, _activeFormat, null);
+				return;
+			}
+
+			var befNumChildren:int = parent.numChildren;
+			parseFlowGroupElementChildren(xmlToParse, parent, null, true);
+
+			// nothing got added - the custom element will be normalized away so just ignore it
+			if (befNumChildren == parent.numChildren)
+				return;
+
+			if (befNumChildren + 1 == parent.numChildren) {
+				// exactly one child was added - just tag it with the typeName if possible
+				var addedChild:IFlowElement = parent.getChildAt(befNumChildren);
+				if (addedChild.id == null && addedChild.styleName == null && addedChild.typeName == addedChild.defaultTypeName) {
+					addedChild.typeName = name.toLowerCase();
+					return;
+				}
+			}
+
+			// have to make one - case 1)
+			newParent = ((parent is IParagraphElement) || (parent is SubParagraphGroupElementBase)) ? new SubParagraphGroupElement() : new DivElement;
+			newParent.typeName = name.toLowerCase();
+			newParent.replaceChildren(0, 0, parent.mxmlChildren.slice(befNumChildren));
+			addChild(parent, newParent);
+		}
+
+		public override function  parseObject(name:String, xmlToParse:XML, parent:IFlowGroupElement, exceptionElements:Object = null):void {
+			// override to allow upper case tag names
+			super.parseObject(name.toUpperCase(), xmlToParse, parent, exceptionElements);
+		}
+
+		/** @private */
+		protected override function checkNamespace(xmlToParse:XML):Boolean {
+			/* Ignore namespace */
+			return true;
+		}
+
+		/** Splits the paragraph wherever a break element occurs and removes the latter
+		 * This is to replicate TextField handling of <br/>: splits the containing paragraph (implied or otherwise)
+		 * The <br/> itself doesn't survive.
+		 * @private
+		 */
+		static protected function replaceBreakElementsWithParaSplits(para:IParagraphElement):void {
+			// performance: when splitting the paragraph into multiple paragraphs take it out of the TextFlow
+			var paraArray:Array;
+			var paraIndex:int;
+			var paraParent:IFlowGroupElement;
+
+			// Find each BreakElement and split into a new paragraph
+			var elem:IFlowLeafElement = para.getFirstLeaf();
+			while (elem) {
+				if (!(elem is BreakElement)) {
+					elem = elem.getNextLeaf(para);
+					continue;
+				}
+				if (!paraArray) {
+					paraArray = [para];
+					paraParent = para.parent;
+					paraIndex = paraParent.getChildIndex(para);
+					paraParent.removeChildAt(paraIndex);
+				}
+
+				// Split the para right after the BreakElement
+				// CONFIG::debug { assert(elem.textLength == 1,"Bad TextLength in BreakElement"); }
+				CONFIG::debug {
+					assert(para.getAbsoluteStart() == 0, "Bad paragraph in replaceBreakElementsWithParaSplits"); }
+				para = para.splitAtPosition(elem.getAbsoluteStart() + elem.textLength) as IParagraphElement;
+				paraArray.push(para);
+
+				// Remove the BreakElement
+				elem.parent.removeChild(elem);
+
+				// point elem to the first leaf of the new paragraph
+				elem = para.getFirstLeaf();
+			}
+
+			if (paraArray)
+				paraParent.replaceChildren(paraIndex, paraIndex, paraArray);
+		}
+
+		/** HTML parsing code
+		 *  Uses regular expressions for recognizing constructs like comments, tags etc.
+		 *  and a hand-coded parser to recognize the document structure and covert to well-formed xml
+		 *  TODO-1/16/2009:List caveats
+		 */
+		/* Regex for stuff to be stripped: a comment, processing instruction, or a declaration
+		 *
+		 * <!--.*?--> - comment
+		 *   <!-- - start comment
+		 *   .*? - anything (including newline character, thanks to the s flag); the ? prevents a greedy match (which could match a --> later in the string) 
+		 *  --> - end comment
+		 *  
+		 * <\?(".*?"|'.*?'|[^>]+)*> - processing instruction
+		 *   <\? - start processing instruction
+		 *   (".*?"|'.*?'|[^>]+)* - 0 or more of the following (interleaved in any order)
+		 *     ".*?" - anything (including >) so long as it is within double quotes; the ? prevents a greedy match (which could match everything until a later " in the string) 
+		 *     '.*?' - anything (including >) so long as it is within single quotes; the ? prevents a greedy match (which could match everything until a later ' in the string)
+		 *     [^>"']+ - one or more characters other than > (because > ends the processing instruction), " (handled above), ' (handled above) 
+		 *   > - end processing instruction
+		 *
+		 * <!(".*?"|'.*?'|[^>"']+)*> - declaration; 
+		 * TODO-1/15/2009:not sure if a declaration can contain > within quotes. Assuming it can, the regex is  
+		 *  is exactly like processing instruction above except it uses a ! instead of a ?
+		 * @private
+		 */
+		/** @private */
+		// TODO regex
+		public static const stripRegex:RegExp = /foo/;
+		// public static const stripRegex:RegExp = /<!--.*?-->|<\?(".*?"|'.*?'|[^>"']+)*>|<!(".*?"|'.*?'|[^>"']+)*>/sg;
+		/* Regular expression for an HTML tag
+		 * < - open
+		 *
+		 * (\/?) - start modifier; 0 or 1 occurance of one of /
+		 *
+		 * (\w+) - tag name; 1 or more name characters
+		 *
+		 * ((?:\s+\w+(?:\s*=\s*(?:".*?"|'.*?'|[\w\.]+))?)*) - attributes; 0 or more of the following
+		 *   (?:\s+\w+(?:\s*=\s*(?:".*?"|'.*?'|[\w\.]+))?) - attribute; 1 or more space, followed by 1 or more name characters optionally followed by
+		 *      \s*=\s*(?:".*?"|'.*?'|[\w\.]+) - attribute value assignment; optional space followed by = followed by more optional space followed by one of
+		 *         ".*?" - quoted attribute value (using double quotes); the ? prevents a greedy match (which could match everything until a later " in the string)
+		 *         '.*?' - quoted attribute value (using single quotes); the ? prevents a greedy match ((which could match everything until a later ' in the string)
+		 *         [\w\.]+ - unquoted attribute value; can only contain name characters or a period
+		 *  Note: ?: specifies a non-capturing group (i.e., match won't be recorded or used as a numbered back-reference)
+		 *
+		 * \s* - optional space
+		 *
+		 * (\/?) - end modifer (0 or 1 occurance of /)
+		 *
+		 * > - close
+		 * @private
+		 */
+		/** @private */
+		// TODO regex
+		public static const tagRegex:RegExp = /foo/;
+		// public static const tagRegex:RegExp = /<(\/?)(\w+)((?:\s+\w+(?:\s*=\s*(?:".*?"|'.*?'|[\w\.]+))?)*)\s*(\/?)>/sg;
+		/** Regular expression for an attribute. Except for grouping differences, this regex is the same as the one that appears in tagRegex
+		 * @private
+		 */
+		// TODO regex
+		public static const attrRegex:RegExp = /foo/;
+
+		// public static const attrRegex:RegExp = /\s+(\w+)(?:\s*=\s*(".*?"|'.*?'|[\w\.]+))?/sg;
+		/** Wrapper for core HTML parsing code that manages XML settings during the process
+		 * @private
+		 */
+		protected function toXML(source:String):XML {
+			var xml:XML;
+
+			var originalSettings:Object = XML.settings();
+			try {
+				XML.ignoreProcessingInstructions = false;
+				XML.ignoreWhitespace = false;
+
+				xml = toXMLInternal(source);
+			} finally {
+				XML.setSettings(originalSettings);
+			}
+
+			return xml;
+		}
+
+		/** Convert HTML string to well-formed xml, accounting for the following HTML oddities
+		 * 
+		 * 1) Start tags are optional for some elements.
+		 * Optional start tag not specified&lt;/html&gt;
+		 * TextField dialect: This is true for all elements. 
+		 * 
+		 * 2) End tags are optional for some elements. Elements with missing end tags may be implicitly closed by
+		 *    a) start-tag for a peer element
+		 *    &lt;p&gt;p element without end tag; closed by next p start tag
+		 *    &lt;p&gt;closes previous p element with missing end tag&lt;/p&gt;
+		 * 
+		 *    b) end-tag for an ancestor element 
+		 * 	  &lt;html&gt;&lt;p&gt;p element without end tag; closed by next end tag of an ancestor&lt;/html&gt;
+		 *     TextField dialect: This is true for all elements. 
+		 * 
+		 * 3) End tags are forbidden for some elements
+		 * &lt;br&gt; and &lt;br/&gt; are valid, but &lt;br&gt;&lt;/br&gt; is not
+		 * TextField dialect: Does not apply. 
+		 * 
+		 * 4) Element and attribute names may use any case
+		 * &lt;P ALign="left"&gt;&lt;/p&gt;
+		 * 
+		 * 5) Attribute values may be unquoted
+		 * &lt;p align=left/&gt;
+		 * 
+		 * 6) Boolean attributed may assume a minimized form
+		 * &lt;p selected/&gt; is equivalent to &lt;p selected="selected"/&gt;
+		 * @private
+		 */
+		protected function toXMLInternal(source:String):XML {
+			// Strip out comments, processing instructions and declaratins
+			source = source.replace(stripRegex, "");
+
+			// Parse the source, looking for tags and interleaved text content, creating an XML hierarchy in the process.
+			// At any given time, there is a chain of 'open' elements corresponding to unclosed tags, the innermost of which is
+			// tracked by the currElem. Content (element or text) parsed next is added as a child of currElem.
+
+			// Root of the XML hierarchy (set to <html/> because the html start tag is optional)
+			// Note that source may contain an html start tag, in which case we'll end up with two such elements
+			// This is not quite correct, but handled by the importer
+			var root:XML = <HTML/>;
+			var currElem:XML = root;
+
+			var lastIndex:int = tagRegex.lastIndex = 0;
+			var openElemName:String;
+
+			do {
+				var result:Object = tagRegex.exec(source);
+				if (!result) {
+					// No more tags: add text (starting at search index) as a child of the innermost open element and break out
+					appendTextChild(currElem, source.substring(lastIndex));
+					break;
+				}
+
+				if (result.index != lastIndex) {
+					// Add text between tags as a child of the innermost open element
+					appendTextChild(currElem, source.substring(lastIndex, result.index));
+				}
+
+				var tag:String = result[0]; // entire tag
+				var hasStartModifier:Boolean = (result[1] == "\/"); // modifier after < (/ for end tag)
+				var name:String = result[2].toUpperCase();  // name; use lower case
+				var attrs:String = result[3];  // attributes; including whitespace
+				var hasEndModifier:Boolean = (result[4] == "\/"); // modifier before > (/ for composite start and end tag)
+
+				if (!hasStartModifier) // start tag
+				{
+					// Special case for implicit closing of <p>
+					// TODO-12/23/2008: this will need to be handled more generically
+					if (name == "P" && currElem.name().localName == "P")
+						currElem = currElem.parent();
+
+					// Create an XML element by constructing a tag that can be fed to the XML constructor. Specifically, ensure
+					// - it is a composite tag (start and end tag together) using the terminating slash shorthand
+					// - element and attribute names are lower case (this is not required, but doesn't hurt)
+					// - attribute values are quoted
+					// - boolean attributes are fully specified (e.g., selected="selected" rather than selected)
+					tag = "<" + name;
+					do {
+						var innerResult:Object = attrRegex.exec(attrs);
+						if (!innerResult)
+							break;
+
+						var attrName:String = innerResult[1].toUpperCase();
+						tag += " " + attrName + "=";
+						var val:String = innerResult[2] ? innerResult[2] : attrName; /* boolean attribute with implied value equal to attribute name */
+						var startChar:String = val.charAt(0);
+						tag += ((startChar == "'" || startChar == "\"") ? val : ("\"" + val + "\""));
+					} while (true);
+					tag += "\/>";
+
+					// Add the corresponding element as a child of the innermost open element
+					currElem.appendChild(new XML(tag));
+
+					// The new element becomes the innermost open element unless it is already closed because
+					// - this is a composite start and end tag (i.e., has an end modifier)
+					// - the start tag itself implies closure
+					if (!hasEndModifier && !doesStartTagCloseElement(name))
+						currElem = currElem.children()[currElem.children().length() - 1];
+				} else // end tag
+				{
+					if (hasEndModifier || attrs.length) {
+						reportError(GlobalSettings.resourceStringFunction("malformedTag", [tag]));
+					} else {
+						/*
+						// Does not apply to TextField dialect
+						if (isEndTagForbidden(name))
+						{
+						xxxreportError("End tag is not allowed for element " + name); NOTE : MAKE A LOCALIZABLE ERROR IF THIS COMES BACK
+						return null;
+						}*/
+
+						// Move up the chain of open elements looking for a matching name
+						// The matching element is closed and its parent becomes the innermost open element
+						// Report error if matching element is not found and it requires a start tag
+						// All intermediate open elements are also closed provided they don't require end tags
+						// Report error if an intermediate element requires end tags
+						var openElem:XML = currElem;
+						do {
+							openElemName = openElem.name().localName;
+							openElem = openElem.parent();
+
+							if (openElemName == name) {
+								currElem = openElem;
+								break;
+							}
+							/*
+							// Does not apply to TextField dialect
+							else if (isEndTagRequired(openElemName))
+							{
+							xxxreportError("Missing end tag for element " + openElemName);
+							return null;
+							}*/
+
+							if (!openElem) {
+								// Does not apply to TextField dialect
+								/*if (isStartTagRequired(name))
+								{
+								xxxreportError("Unexpected end tag " + name);
+								return null;
+								}*/
+								break;
+							}
+						} while (true);
+					}
+				}
+
+				lastIndex = tagRegex.lastIndex;
+				if (lastIndex == source.length)
+					break; // string completely parsed
+			} while (currElem); // null currElem means <html/> has been closed, so ignore everything else
+
+			// No more string to parse, specifically, no more end tags.
+			// Validate that remaining open elements do not require end tags.
+			// Does not apply to TextField dialect
+			/* while (currElem)
+			{
+			openElemName = currElem.name().localName; 
+			if (isEndTagRequired(openElemName))
+			{
+			xxxreportError("Missing end tag for element " + openElemName);
+			return null;
+			}
+			currElem = currElem.parent();
+			}*/
+
+			return root;
+		}
+
+		/** @private */
+		protected function doesStartTagCloseElement(tagName:String):Boolean {
+			switch (tagName) {
+				case "BR":
+				case "IMG":
+					return true;
+				default:
+					return false;
+			}
+		}
+
+		/** @private */
+		// TODO regex
+		public static const anyPrintChar:RegExp = /foo/g;
+
+		// public static const anyPrintChar:RegExp = /[^\u0009\u000a\u000d\u0020]/g;
+		/** Adds text as a descendant of the specified XML element. Adds an intermediate <span> element is created if parent is not a <span>
+		 *  No action is taken for whitespace-only text
+		 * @private
+		 */
+		protected function appendTextChild(parent:XML, text:String):void {
+			// No whitespace collapse
+			// if (text.match(anyPrintChar).length != 0)
+			{
+				var parentIsSpan:Boolean = (parent.localName() == "SPAN");
+				var elemName:String = parentIsSpan ? "DUMMY" : "SPAN";
+
+				// var xml:XML = <{elemName}/>;
+				// xml.appendChild(text);
+				// The commented-out code above doesn't handle character entities like &lt;
+				// The following lets the XML constructor handle them
+				var xmlText:String = "<" + elemName + ">" + text + "<\/" + elemName + ">";
+				try {
+					var xml:XML = new XML(xmlText);
+					parent.appendChild(parentIsSpan ? xml.children()[0] : xml);
+				} catch (e:*) {
+					// Report malformed content like "<" instead of "&lt;"
+					reportError(GlobalSettings.resourceStringFunction("malformedMarkup", [text]));
+				}
+					
+			}
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/TextLayoutExporter.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/TextLayoutExporter.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/TextLayoutExporter.as
new file mode 100644
index 0000000..a0f0006
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/TextLayoutExporter.as
@@ -0,0 +1,297 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion
+{
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.elements.IDivElement;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	import org.apache.flex.textLayout.elements.InlineGraphicElement;
+	import org.apache.flex.textLayout.elements.LinkElement;
+	import org.apache.flex.textLayout.elements.ListElement;
+	import org.apache.flex.textLayout.elements.SubParagraphGroupElement;
+	import org.apache.flex.textLayout.elements.TCYElement;
+	import org.apache.flex.textLayout.elements.TableCellElement;
+	import org.apache.flex.textLayout.elements.TableElement;
+	import org.apache.flex.textLayout.elements.TableRowElement;
+	import org.apache.flex.textLayout.formats.FormatValue;
+	import org.apache.flex.textLayout.formats.ListMarkerFormat;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+	import org.apache.flex.textLayout.property.Property;
+	
+
+	
+	/** 
+	 * Export filter for TextLayout format. 
+	 */
+	internal class TextLayoutExporter extends BaseTextLayoutExporter
+	{	
+		static private var _formatDescription:Object= TextLayoutFormat.description;
+
+		public function TextLayoutExporter()
+		{
+			super(new Namespace("http://ns.adobe.com/textLayout/2008"), null, TextLayoutImporter.defaultConfiguration);
+		}
+		
+		static private const brTabRegEx:RegExp = new RegExp("[" + "\u2028" + "\t" + "]"); // Doesn't /\u2028\t/ work?
+		
+		/** Gets the regex that specifies characters to be replaced with XML elements
+		 *  Note: Each match is a single character 
+		 */
+		protected override function get spanTextReplacementRegex():RegExp
+		{
+			return brTabRegEx;
+		}
+		
+		/** Gets the xml element used to represent a character in the export format
+		 */
+		protected override function getSpanTextReplacementXML(ch:String):XML
+		{
+			var replacementXML:XML;
+			if (ch == '\u2028')
+				replacementXML = <br/>;
+			else if (ch == '\t')
+				replacementXML = <tab/>;
+			else
+			{
+				CONFIG::debug {assert(false, "Did not recognize character to be replaced with XML"); }
+				return null;			
+			}
+		
+			replacementXML.setNamespace(flowNS);
+			return replacementXML;	
+		}
+		
+		/** 
+		 * Helper function to export styles (core or user) in the form of xml attributes or xml children
+		 * 
+		 */
+		public function createStylesFromDescription(styles:Object, description:Object, includeUserStyles:Boolean, exclusions:Array):Array
+		{
+			var sortableStyles:Array = [];
+			for (var key:String in styles)
+			{
+				var val:Object = styles[key];
+				if (exclusions && exclusions.indexOf(val) != -1)
+					continue;
+				
+				var prop:Property = description[key];
+				if (!prop)
+				{
+					if (includeUserStyles)
+					{
+						// User style
+						if ((val is String) || val.hasOwnProperty("toString"))
+						{
+							// Is or can be converted to a String which will be used as an XML attribute value
+							sortableStyles.push({xmlName:key, xmlVal:val});
+						}						
+					}
+				}
+				else if (val is TextLayoutFormat)
+				{
+					// A style dictionary; Will be converted to an XMLList containing elements to be added as children 
+					var customDictProp:XMLList = exportObjectAsTextLayoutFormat(key,(val as TextLayoutFormat).getStyles());
+					if (customDictProp)
+						sortableStyles.push({xmlName:key, xmlVal:customDictProp});
+				}
+				else
+					sortableStyles.push({xmlName:key, xmlVal:prop.toXMLString(val)});		
+			}
+			return sortableStyles;  
+		}
+		
+		public function exportObjectAsTextLayoutFormat(key:String,styleDict:Object):XMLList
+		{
+			// link attributes and ListMarkerFormat
+			var elementName:String;
+			var description:Object;
+			if (key == "linkNormalFormat" || key == "linkActiveFormat" || key == "linkHoverFormat")
+			{
+				elementName = "TextLayoutFormat";
+				description = TextLayoutFormat.description;
+			}
+			else if (key == "ListMarkerFormat")
+			{
+				elementName = "ListMarkerFormat";
+				description = ListMarkerFormat.description;
+			}
+			
+			if (elementName == null)
+				return null;
+				
+			// create the  element
+			var formatXML:XML = <{elementName}/>;
+			formatXML.setNamespace(flowNS);
+			var sortableStyles:Array = createStylesFromDescription(styleDict, description, true, null);
+			exportStyles(XMLList(formatXML), sortableStyles);
+			
+			// create the link format element
+			var propertyXML:XMLList = XMLList(<{key}/>);
+			propertyXML.appendChild(formatXML);
+			return propertyXML;
+		}
+			
+		protected override function exportFlowElement(flowElement:IFlowElement):XMLList
+		{
+			var rslt:XMLList = super.exportFlowElement(flowElement);
+			
+			var allStyles:Object = flowElement.styles;
+			if (allStyles)
+			{
+				// WhiteSpaceCollapse attribute should never be exported (except on TextFlow -- handled separately)
+				delete allStyles[TextLayoutFormat.whiteSpaceCollapseProperty.name];
+				// To prevent "inherit" from getting exported for the root node, comment in the following line, and remove the one after that (only need one call to exportStyles
+				var sortableStyles:Array = createStylesFromDescription(allStyles,formatDescription,true,flowElement.parent ? null : [FormatValue.INHERIT]);
+				exportStyles(rslt, sortableStyles );
+			}
+			
+			// export id and typeName
+			if (flowElement.id != null)
+				rslt.@id = flowElement.id;
+			if (flowElement.typeName != flowElement.defaultTypeName)
+				rslt.@typeName = flowElement.typeName;
+				
+			return rslt;
+		}
+
+		/** 
+		 * Base functionality for exporting an Image. Exports as a FlowElement,
+		 * and exports image properties.
+		 * 
+		 * @param exporter	Root object for the export
+		 * @param image	Element to export
+		 * @return XMLList	XML for the element
+		 */
+		static public function exportImage(exporter:BaseTextLayoutExporter, image:InlineGraphicElement):XMLList
+		{
+			var output:XMLList = exportFlowElement(exporter, image);
+			
+			// output the img specific values
+			if (image.height !== undefined)
+				output.@height = image.height;
+			if (image.width !== undefined)
+				output.@width = image.width;
+		//	output.@rotation = image.rotation;  don't support rotation yet
+			if (image.source != null)
+				output.@source = image.source;
+			if (image.float != undefined)
+				output.@float = image.float;
+						
+			return output;
+		}
+
+		/** 
+		 * Base functionality for exporting a LinkElement. Exports as a FlowGroupElement,
+		 * and exports link properties.
+		 * 
+		 * @param exporter	Root object for the export
+		 * @param link	Element to export
+		 * @return XMLList	XML for the element
+		 */
+		static public function exportLink(exporter:BaseTextLayoutExporter, link:LinkElement):XMLList
+		{
+			var output:XMLList = exportFlowGroupElement(exporter, link);
+
+			if (link.href)
+				output.@href= link.href;
+				
+			if (link.target)
+				output.@target = link.target;
+				
+			return output;
+		}
+		
+		/** 
+		 * Base functionality for exporting a IDivElement. Exports as a FlowContainerFormattedElement
+		 * 
+		 * @param exporter	Root object for the export
+		 * @param div	Element to export
+		 * @return XMLList	XML for the element
+		 */
+		static public function exportDiv(exporter:BaseTextLayoutExporter, div:IDivElement):XMLList
+		{
+			return exportContainerFormattedElement(exporter, div);
+		}
+		
+		/** 
+		 * Base functionality for exporting a SubParagraphGroupElement. Exports as a FlowGroupElement
+		 * 
+		 * @param exporter	Root object for the export
+		 * @param elem	Element to export
+		 * @return XMLList	XML for the element
+		 */
+		static public function exportSPGE(exporter:BaseTextLayoutExporter, elem:SubParagraphGroupElement):XMLList
+		{
+			return exportFlowGroupElement(exporter, elem);
+		}
+		/** 
+		 * Base functionality for exporting a TCYElement. Exports as a FlowGroupElement
+		 * 
+		 * @param exporter	Root object for the export
+		 * @param tcy	Element to export
+		 * @return XMLList	XML for the element
+		 */
+		static public function exportTCY(exporter:BaseTextLayoutExporter, tcy:TCYElement):XMLList
+		{
+			return exportFlowGroupElement(exporter, tcy);
+		}
+		
+		/** 
+		 * Base functionality for exporting a TableElement. 
+		 * 
+		 * @param exporter	Root object for the export
+		 * @param table	Element to export
+		 * @return XMLList	XML for the element
+		 */
+		static public function exportTable(exporter:BaseTextLayoutExporter, table:TableElement):XMLList
+		{
+			return exportTableElement(exporter, table);
+		}
+		
+		/** 
+		 * Base functionality for exporting a TableRowElement. 
+		 * 
+		 * @param exporter	Root object for the export
+		 * @param table	Element to export
+		 * @return XMLList	XML for the element
+		 */
+		static public function exportTableRow(exporter:BaseTextLayoutExporter, tableRow:TableRowElement):XMLList
+		{
+			return exportTableRowElement(exporter, tableRow);
+		}
+		
+		/** 
+		 * Base functionality for exporting a TableCellElement. 
+		 * 
+		 * @param exporter	Root object for the export
+		 * @param table	Element to export
+		 * @return XMLList	XML for the element
+		 */
+		static public function exportTableCell(exporter:BaseTextLayoutExporter, tableCell:TableCellElement):XMLList
+		{
+			return exportTableCellElement(exporter, tableCell);
+		}
+		
+		override protected function get formatDescription():Object
+		{
+			return _formatDescription;
+		}		
+
+	}
+}


[25/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/ElementRange.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/ElementRange.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/ElementRange.as
new file mode 100644
index 0000000..f29f776
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/ElementRange.as
@@ -0,0 +1,426 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.edit
+{
+	import org.apache.flex.textLayout.container.IContainerController;
+	import org.apache.flex.textLayout.elements.IFlowLeafElement;
+	import org.apache.flex.textLayout.property.PropertyUtil;
+
+/**
+ * The ElementRange class represents the range of objects selected within a text flow.
+ * 
+ * <p>The beginning elements 
+ * (such as <code>firstLeaf</code>) are always less than or equal to the end elements (in this case, <code>lastLeaf</code>)
+ * for each pair of values in an element range.</p>
+ * 
+ * @see org.apache.flex.textLayout.elements.TextFlow
+ * 
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @langversion 3.0
+ */	
+public class ElementRange
+{
+	import org.apache.flex.textLayout.compose.IFlowComposer;
+	import org.apache.flex.textLayout.elements.IFlowLeafElement;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.ISubParagraphGroupElementBase;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.textLayout.formats.Category;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+	import org.apache.flex.textLayout.property.Property;
+
+	
+
+	
+	private var _absoluteStart:int;
+	private var _absoluteEnd:int;
+	private var _firstLeaf:IFlowLeafElement;
+	private var _lastLeaf:IFlowLeafElement;
+	private var _firstParagraph:IParagraphElement;
+	private var _lastParagraph:IParagraphElement;
+	private var _textFlow:ITextFlow;	
+	
+	/** 
+	 * The absolute text position of the IFlowLeafElement object that contains the start of the range.
+	 *  
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+ 	 * @langversion 3.0
+	 */
+	public function get absoluteStart():int
+	{
+		return _absoluteStart;
+	}
+	public function set absoluteStart(value:int):void
+	{
+		_absoluteStart = value;
+	}
+	
+	/** 
+	 * The absolute text position of the IFlowLeafElement object that contains the end of the range. 
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+ 	 * @langversion 3.0
+ 	 */
+	public function get absoluteEnd():int
+	{
+		return _absoluteEnd;
+	}
+	public function set absoluteEnd(value:int):void
+	{
+		_absoluteEnd = value;
+	}
+
+	/** 
+	 * The IFlowLeafElement object that contains the start of the range. 
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+ 	 * @langversion 3.0
+	 */
+	public function get firstLeaf():IFlowLeafElement
+	{
+		return _firstLeaf;
+	}
+	public function set firstLeaf(value:IFlowLeafElement):void
+	{
+		_firstLeaf = value;
+	}
+
+	/** 
+	 * The IFlowLeafElement object that contains the end of the range. 
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+ 	 * @langversion 3.0
+	*/
+	public function get lastLeaf():IFlowLeafElement
+	{
+		return _lastLeaf;
+	}
+	public function set lastLeaf(value:IFlowLeafElement):void
+	{
+		_lastLeaf = value;
+	}
+
+	/** 
+	 * The IParagraphElement object that contains the start of the range. 
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+ 	 * @langversion 3.0
+	 */
+	public function get firstParagraph():IParagraphElement
+	{
+		return _firstParagraph;
+	}
+	public function set firstParagraph(value:IParagraphElement):void
+	{
+		_firstParagraph = value;
+	}
+	
+	/** 
+	 * The IParagraphElement object that contains the end of the range. 
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+ 	 * @langversion 3.0
+	*/
+	public function get lastParagraph():IParagraphElement
+	{
+		return _lastParagraph;
+	}
+	public function set lastParagraph(value:IParagraphElement):void
+	{
+		_lastParagraph = value;
+	}
+	
+	/** 
+	 * The TextFlow object that contains the range. 
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+ 	 * @langversion 3.0
+	 */
+	public function get textFlow():ITextFlow
+	{
+		return _textFlow;
+	}	
+	public function set textFlow(value:ITextFlow):void
+	{
+		_textFlow = value;
+	}	
+	
+	// This constructor function is here just to silence a compile warning in Eclipse. There
+	// appears to be no way to turn the warning off selectively.
+	/** @private */
+	CONFIG::debug public function ElementRange()
+	{
+		super();
+	}
+	
+ 	// NOTE: We've been back and forth on this - should a range selection show null attributes or beginning of range attributes?
+	// After looking at this for a while I want it to show beginning of range attributes.  Two main reasons
+	// 1. If the range contains different objects but homogoneous settings we should show the attributes.
+	// 2. If we show null attributes on a range selection there's no way to, for example, turn BOLD off.
+	// Try this at home - restore the old code. Select the entire text.  Turn Bold on.  Can't turn bold off.
+	// Please don't revert this without further discussion.
+	// Ideally we would have a way of figuring out which attributes are homogoneous over the selection range
+	// and which were not and showing, for example, a "half-checked" bold item.  We'd have to work this out for all the properties.
+	
+	// OLD CODE that shows null attribute settings on a range selection
+	// var charAttr:ICharacterFormat = selRange.begElem == selRange.endElem ? selRange.begElem.computedCharacterFormat : new CharacterFormat();
+	// var paraAttr:IParagraphFormat = selRange.begPara == selRange.endPara ? selRange.begPara.computedParagraphFormat : new ParagraphFormat();
+
+
+	/** 
+	 * The format attributes of the container displaying the range. 
+	 * 
+	 * <p>If the range spans more than one container, the format of the first container is returned.</p>
+	 *  
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+ 	 * @langversion 3.0
+	 */
+	public function get containerFormat():ITextLayoutFormat
+	{
+		// see NOTE above before changing!!
+		var container:IContainerController;
+		var flowComposer:IFlowComposer = _textFlow.flowComposer;
+		if (flowComposer)
+		{
+			var idx:int = flowComposer.findControllerIndexAtPosition(absoluteStart);
+			if (idx != -1)
+				container = flowComposer.getControllerAt(idx);
+		}
+		return container ? container.computedFormat : _textFlow.computedFormat;
+	}
+		
+	/** 
+	 * The format attributes of the paragraph containing the range. 
+	 * 
+	 * <p>If the range spans more than one paragraph, the format of the first paragraph is returned.</p>
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+ 	 * @langversion 3.0
+	 */
+	public function get paragraphFormat():ITextLayoutFormat
+	{
+		// see NOTE above before changing!!
+  		return firstParagraph.computedFormat;
+ 	}
+		
+	/** 
+	 * The format attributes of the characters in the range. 
+	 * 
+	 * <p>If the range spans more than one FlowElement object, which means that more than one
+	 * character format may exist within the range, the format of the first FlowElement object is returned.</p>
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+ 	 * @langversion 3.0
+	 */
+	public function get characterFormat():ITextLayoutFormat
+	{
+		// see NOTE above before changing!!
+ 		return firstLeaf.computedFormat;
+	}
+	
+	/**
+	 * Gets the character format attributes that are common to all characters in the text range or current selection.
+	 * 
+	 * <p>Format attributes that do not have the same value for all characters in the element range are set to 
+	 * <code>null</code> in the returned TextLayoutFormat instance.</p>
+	 * 
+	 * @return The common character style settings
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	public function getCommonCharacterFormat():TextLayoutFormat
+	{		
+		var leaf:IFlowLeafElement = firstLeaf;
+		var attr:TextLayoutFormat = new TextLayoutFormat(leaf.computedFormat);
+		
+		for (;;)
+		{
+			if (leaf == lastLeaf)
+				break;
+			leaf = leaf.getNextLeaf();
+			attr.removeClashing(leaf.computedFormat);
+		}
+
+		return PropertyUtil.extractInCategory(TextLayoutFormat, TextLayoutFormat.description, attr, Category.CHARACTER, false) as TextLayoutFormat;
+	}
+	
+	/**
+	 * Gets the paragraph format attributes that are common to all paragraphs in the element range.
+	 * 
+	 * <p>Format attributes that do not have the same value for all paragraphs in the element range are set to 
+	 * <code>null</code> in the returned TextLayoutFormat instance.</p>
+	 * 	 
+	 * @return The common paragraph style settings
+	 * 
+	 * @see org.apache.flex.textLayout.edit.ISelectionManager#getCommonParagraphFormat
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	public function getCommonParagraphFormat():TextLayoutFormat
+	{
+		var para:IParagraphElement = firstParagraph;
+		var attr:TextLayoutFormat = new TextLayoutFormat(para.computedFormat);
+		for (;;)
+		{
+			if (para == lastParagraph)
+				break;
+			para = _textFlow.findAbsoluteParagraph(para.getAbsoluteStart()+para.textLength);
+			attr.removeClashing(para.computedFormat);
+		}
+		return PropertyUtil.extractInCategory(TextLayoutFormat,TextLayoutFormat.description,attr,Category.PARAGRAPH, false) as TextLayoutFormat;
+	}
+	
+	/**
+		 * Gets the container format attributes that are common to all containers in the element range.
+	 * 
+	 * <p>Format attributes that do not have the same value for all containers in the element range are set to 
+	 * <code>null</code> in the returned TextLayoutFormat instance.</p>
+	 * 	 
+	 * @return The common paragraph style settings
+	 * 
+	 * @see org.apache.flex.textLayout.edit.ISelectionManager#getCommonParagraphFormat	 * 
+		* @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	public function getCommonContainerFormat():TextLayoutFormat
+	{	
+		var flowComposer:IFlowComposer = _textFlow.flowComposer;
+		if (!flowComposer)
+			return null;
+
+		var index:int = flowComposer.findControllerIndexAtPosition(this.absoluteStart);
+		if (index == -1)
+			return null;
+		var controller:IContainerController = flowComposer.getControllerAt(index);
+		var attr:TextLayoutFormat = new TextLayoutFormat(controller.computedFormat);
+		while (controller.absoluteStart+controller.textLength < absoluteEnd)
+		{
+			index++;
+			if (index == flowComposer.numControllers)
+				break;
+			controller = flowComposer.getControllerAt(index);
+			attr.removeClashing(controller.computedFormat);
+		}
+		
+		return PropertyUtil.extractInCategory(TextLayoutFormat,TextLayoutFormat.description,attr,Category.CONTAINER, false) as TextLayoutFormat;
+	}
+	
+	/** 
+	 * Creates an ElementRange object.
+	 * 
+	 * @param textFlow	the text flow
+	 * @param beginIndex absolute text position of the first character in the text range
+	 * @param endIndex one beyond the absolute text position of the last character in the text range
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+ 	 * @langversion 3.0
+	 */
+	static public function createElementRange(textFlow:ITextFlow, absoluteStart:int, absoluteEnd:int):ElementRange
+	{
+		var rslt:ElementRange = new ElementRange();
+		if (absoluteStart == absoluteEnd)
+		{
+			rslt.absoluteStart = rslt.absoluteEnd = absoluteStart;
+			rslt.firstLeaf = textFlow.findLeaf(rslt.absoluteStart);
+			rslt.firstParagraph = rslt.firstLeaf.getParagraph();
+	//		rslt.begContainer = rslt.endContainer = selState.textFlow.findAbsoluteContainer(rslt.begElemIdx);
+			adjustForLeanLeft(rslt);
+			rslt.lastLeaf = rslt.firstLeaf;
+			rslt.lastParagraph = rslt.firstParagraph;
+		}
+		else
+		{
+			// order the selection points
+			if (absoluteStart < absoluteEnd)
+			{
+				rslt.absoluteStart  = absoluteStart;
+				rslt.absoluteEnd = absoluteEnd;
+			}
+			else
+			{
+				rslt.absoluteStart  = absoluteEnd;
+				rslt.absoluteEnd = absoluteStart;
+			}
+			rslt.firstLeaf = textFlow.findLeaf(rslt.absoluteStart);
+			rslt.lastLeaf = textFlow.findLeaf(rslt.absoluteEnd);
+			// back up one element if the end of the selection is the start of an element
+			// otherwise a block selection of a span looks like it includes discreet selection ranges
+			if (((rslt.lastLeaf == null) && (rslt.absoluteEnd == textFlow.textLength)) || (rslt.absoluteEnd == rslt.lastLeaf.getAbsoluteStart()))
+				rslt.lastLeaf = textFlow.findLeaf(rslt.absoluteEnd-1);
+				
+			rslt.firstParagraph = rslt.firstLeaf.getParagraph();
+			rslt.lastParagraph = rslt.lastLeaf.getParagraph();
+			
+	//		rslt.begContainer = selState.textFlow.findAbsoluteContainer(rslt.begElemIdx);
+	//		rslt.endContainer = selState.textFlow.findAbsoluteContainer(rslt.endElemIdx);
+	//		if (rslt.endElemIdx == rslt.endContainer.relativeStart)
+	//			rslt.endContainer = rslt.endContainer.preventextContainer;
+				
+			// if the end of the range includes the next to last character in a paragraph 
+			// expand it to include the paragraph teriminate character
+			if (rslt.absoluteEnd == rslt.lastParagraph.getAbsoluteStart() + rslt.lastParagraph.textLength - 1)
+			{
+				rslt.absoluteEnd++;
+				rslt.lastLeaf = rslt.lastParagraph.getLastLeaf();
+			}
+
+		}
+		rslt.textFlow = textFlow;
+			
+		return rslt;
+	}
+	
+	static private function adjustForLeanLeft(rslt:ElementRange):void
+	{		
+		// If we're at the start of a leaf element, look to the previous leaf element and see if it shares the same
+		// parent. If so, we're going to move the selection to the end of the previous element so it takes on
+		// the formatting of the character to the left. We don't want to do this if the previous element is in
+		// a different character, across link or tcy boundaries, etc.
+		if (rslt.firstLeaf.getAbsoluteStart() == rslt.absoluteStart)
+		{
+			var previousNode:IFlowLeafElement = rslt.firstLeaf.getPreviousLeaf(rslt.firstParagraph);
+			if (previousNode && previousNode.getParagraph() == rslt.firstLeaf.getParagraph())
+			{
+				if((!(previousNode.parent is ISubParagraphGroupElementBase) || (previousNode.parent as ISubParagraphGroupElementBase).acceptTextAfter())
+					&& (!(rslt.firstLeaf.parent is ISubParagraphGroupElementBase) || previousNode.parent === rslt.firstLeaf.parent))
+					rslt.firstLeaf = previousNode;
+			}
+				
+		}
+	}
+}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/IEditManager.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/IEditManager.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/IEditManager.as
new file mode 100644
index 0000000..7c99be5
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/IEditManager.as
@@ -0,0 +1,778 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.edit
+{
+	import org.apache.flex.textLayout.elements.IDivElement;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	import org.apache.flex.textLayout.elements.IFlowGroupElement;
+	import org.apache.flex.textLayout.elements.IInlineGraphicElement;
+	import org.apache.flex.textLayout.elements.ILinkElement;
+	import org.apache.flex.textLayout.elements.IListElement;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.ISubParagraphGroupElement;
+	import org.apache.flex.textLayout.elements.ITCYElement;
+	import org.apache.flex.textLayout.elements.ITableElement;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.operations.FlowOperation;
+	import org.apache.flex.utils.undo.IOperation;
+	import org.apache.flex.utils.undo.IUndoManager;
+    
+    [Exclude(name="delayedOperations",kind="property")]
+    /** 
+     * IEditManager defines the interface for handling edit operations of a text flow.
+     * 
+     * <p>To enable text flow editing, assign an IEditManager instance to the <code>interactionManager</code> 
+     * property of the TextFlow object. The edit manager handles changes to the text (such as insertions, 
+     * deletions, and format changes). Changes are reversible if the edit manager has an undo manager. The edit
+     * manager triggers the recomposition and display of the text flow, as necessary.</p>
+     * 
+     * @playerversion Flash 10
+     * @playerversion AIR 1.5
+     * @langversion 3.0
+     * 
+     * @see EditManager
+     * @see org.apache.flex.textLayout.elements.TextFlow
+     * @see flashx.undo.UndoManager
+     * 
+     */
+    public interface IEditManager extends ISelectionManager
+    {               
+
+        /** 
+         * The UndoManager object assigned to this EditManager instance, if there is one.
+         * 
+         * <p>An undo manager handles undo and redo operations.</p>
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */
+        function get undoManager():IUndoManager
+
+        /** 
+         * Changes the formats of the specified (or current) selection.
+         * 
+         * <p>Executes an undoable operation that applies the new formats.
+         * Only style attributes set for the TextLayoutFormat objects are applied.
+         * Undefined attributes in the format objects are not changed.
+         * </p>
+         * 
+         * @param leafFormat    The format to apply to leaf elements such as spans and inline graphics.
+         * @param paragraphFormat   The format to apply to paragraph elements.
+         * @param containerFormat   The format to apply to the containers.
+         * @param operationState    Specifies the text to which this operation applies; 
+         * if <code>null</code>, the operation applies to the current selection.
+         *
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */     
+        function applyFormat(leafFormat:ITextLayoutFormat, paragraphFormat:ITextLayoutFormat, containerFormat:ITextLayoutFormat, operationState:SelectionState = null):void
+
+        
+        /** 
+         * Undefines formats of the specified (or current) selection.
+         * 
+         * <p>Executes an undoable operation that undefines the specified formats.
+         * Only style attributes set for the TextLayoutFormat objects are applied.
+         * Undefined attributes in the format objects are not changed.
+         * </p>
+         * 
+         * @param leafFormat     The format whose set values indicate properties to undefine to LeafFlowElement objects in the selected range.
+         * @param paragraphFormat The format whose set values indicate properties to undefine to ParagraphElement objects in the selected range.
+         * @param containerFormat The format whose set values indicate properties to undefine to ContainerController objects in the selected range.
+         * @param operationState    Specifies the text to which this operation applies; 
+         * if <code>null</code>, the operation applies to the current selection.
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */     
+        function clearFormat(leafFormat:ITextLayoutFormat, paragraphFormat:ITextLayoutFormat, containerFormat:ITextLayoutFormat, operationState:SelectionState = null):void
+
+        /** 
+         * Changes the format applied to the leaf elements in the 
+         * specified (or current) selection.
+         * 
+         * <p>Executes an undoable operation that applies the new format to leaf elements such as
+         * SpanElement and InlineGraphicElement objects.
+         * Only style attributes set for the TextLayoutFormat objects are applied.
+         * Undefined attributes in the format object are changed.</p>
+         * 
+         * @param format    The format to apply.
+         * @param operationState    Specifies the text to which this operation applies; 
+         * if <code>null</code>, the operation applies to the current selection.
+         * 
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */     
+        function applyLeafFormat(format:ITextLayoutFormat, operationState:SelectionState = null):void;
+
+        /** 
+         * Transforms text into a TCY run, or a TCY run into non-TCY text. 
+         * 
+         * <p>TCY, or tate-chu-yoko, causes text to draw horizontally within a vertical line, and is 
+         * used to make small blocks of non-Japanese text or numbers, such as dates, more readable in vertical text.</p>
+         * 
+         * @param tcyOn Set to <code>true</code> to apply TCY to a text range, <code>false</code> to remove TCY. 
+         * @param operationState    Specifies the text to which this operation applies; 
+         * if <code>null</code>, the operation applies to the current selection.
+         * @return The TCYElement that was created.
+         * 
+         * @see org.apache.flex.textLayout.elements.TCYElement
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */         
+        function applyTCY(tcyOn:Boolean, operationState:SelectionState = null):ITCYElement;
+        
+        /** 
+         * Transforms a selection into a link, or a link into normal text.
+         * 
+         * <p>Executes an undoable operation that creates or removes the link.</p>
+         * 
+         *  <p>If a <code>target</code> parameter is specified, it must be one of the following values:</p>
+         * <ul>
+         *  <li>"_self"</li>
+         *  <li>"_blank"</li>
+         *  <li>"_parent"</li>
+         *  <li>"_top"</li>
+         * </ul>
+         * <p>In browser-hosted runtimes, a target of "_self" replaces the current html page.  
+         * So, if the SWF content containing the link is in a page within
+         * a frame or frameset, the linked content loads within that frame.  If the page 
+         * is at the top level, the linked content opens to replace the original page.  
+         * A target of "_blank" opens a new browser window with no name.  
+         * A target of "_parent" replaces the parent of the html page containing the SWF content.  
+         * A target of "_top" replaces the top-level page in the current browser window.</p>
+         * 
+         * <p>In other runtimes, such as Adobe AIR, the link opens in the user's default browser and the
+         * <code>target</code> parameter is ignored.</p>
+         * 
+         * <p>The <code>extendToLinkBoundary</code> parameter determines how the edit manager 
+         * treats a selection that intersects with one or more existing links. If the parameter is 
+         * <code>true</code>, then the operation is applied as a unit to the selection and the
+         * whole text of the existing links. Thus, a single link is created that spans from
+         * the beginning of the first link intersected to the end of the last link intersected.
+         * In contrast, if <code>extendToLinkBoundary</code> were <code>false</code> in this situation, 
+         * the existing partially selected links would be split into two links.</p>
+         *
+         * @param href The uri referenced by the link.
+         * @param target The target browser window of the link.
+         * @param extendToLinkBoundary Specifies whether to consolidate selection with any overlapping existing links, and then apply the change.
+         * @param operationState    Specifies the text to which this operation applies; 
+         * if <code>null</code>, the operation applies to the current selection.
+         * @return The LinkElement that was created.
+         * 
+         * @see org.apache.flex.textLayout.elements.LinkElement
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+		 */
+		function applyLink(href:String, target:String = null, extendToLinkBoundary:Boolean = false, operationState:SelectionState = null):ILinkElement;
+        
+        /**
+        * Changes the ID of an element.
+        * 
+         * <p>If the <code>relativeStart</code> or <code>relativeEnd</code> parameters are set (to
+         * anything other than the default values), then the element is split. The parts of the element
+         * outside this range retain the original ID. Setting both the <code>relativeStart</code> and 
+         * <code>relativeEnd</code> parameters creates elements with duplicate IDs.</p>
+         * 
+        * @param newID The new ID value.
+        * @param targetElement The element to modify.
+        * @param relativeStart An offset from the beginning of the element at which to split the element when assigning the new ID.
+        * @param relativeEnd An offset from the beginning of the element at which to split the element when assigning the new ID.
+        * @param operationState Specifies the selection to restore when undoing this operation; 
+        * if <code>null</code>, the operation saves the current selection.
+        * 
+         * 
+        * @playerversion Flash 10
+        * @playerversion AIR 1.5
+        * @langversion 3.0 
+        */
+        function changeElementID(newID:String, targetElement:IFlowElement, relativeStart:int = 0, relativeEnd:int = -1, operationState:SelectionState = null):void;
+        
+        [Deprecated(replacement="applyFormatToElement", deprecatedSince="2.0")]
+        /**
+        * Changes the styleName of an element or part of an element.
+         * 
+         * <p>If the <code>relativeStart</code> or <code>relativeEnd</code> parameters are set (to
+         * anything other than the default values), then the element is split. The parts of the element
+         * outside this range retain the original style.</p>
+         * 
+        * @param newName The name of the new style.
+        * @param targetElement Specifies the element to change.
+        * @param relativeStart An offset from the beginning of the element at which to split the element when assigning the new style.
+        * @param relativeEnd An offset from the end of the element at which to split the element when assigning the new style.
+        * @param operationState Specifies the selection to restore when undoing this operation; 
+        * if <code>null</code>, the operation saves the current selection.
+        * 
+        * @playerversion Flash 10
+        * @playerversion AIR 1.5
+        * @langversion 3.0 
+        */
+        function changeStyleName(newName:String, targetElement:IFlowElement, relativeStart:int = 0, relativeEnd:int = -1, operationState:SelectionState = null):void;
+
+        /**
+         * Changes the typeName of an element or part of an element.
+         * 
+         * <p>If the <code>relativeStart</code> or <code>relativeEnd</code> parameters are set (to
+         * anything other than the default values), then the element is split. The parts of the element
+         * outside this range retain the original style.</p>
+         * 
+         * @param newName The name of the new type.
+         * @param targetElement Specifies the element to change.
+         * @param relativeStart An offset from the beginning of the element at which to split the element when assigning the new style
+         * @param relativeEnd An offset from the end of the element at which to split the element when assigning the new style
+         * @param operationState    Specifies the selection to restore when undoing this operation; 
+         * if <code>null</code>, the operation saves the current selection.
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0 
+         */
+        function changeTypeName(newName:String, targetElement:IFlowElement, relativeStart:int = 0, relativeEnd:int = -1, operationState:SelectionState = null):void;
+
+        /** 
+         * Deletes a range of text, or, if a point selection is given, deletes the next character.
+         * 
+         * @param operationState    specifies the text to which this operation applies; 
+         * if <code>null</code>, the operation applies to the current selection.
+         * 
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */
+        function deleteNextCharacter(operationState:SelectionState = null):void;
+        
+        /** 
+         * Deletes a range of text, or, if a point selection is given, deletes the previous character.
+         * 
+         * @param operationState    Specifies the text to which this operation applies; 
+         * if <code>null</code>, the operation applies to the current selection.
+         * 
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */
+        function deletePreviousCharacter(operationState:SelectionState = null):void;
+        
+        /** 
+         * Deletes the next word.
+         * 
+         * <p>If a range is selected, the first word of the range is deleted.</p>
+         * 
+         * @param operationState Specifies the text to which this operation applies; 
+         * if <code>null</code>, the operation applies to the current selection.
+         * 
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */     
+        function deleteNextWord(operationState:SelectionState = null):void;
+        
+        /** 
+         * Deletes the previous word.
+         * 
+         * <p>If a range is selected, the first word of the range is deleted.</p>
+         * 
+         * @param operationState    Specifies the text to which this operation applies; 
+         * if <code>null</code>, the operation applies to the current selection.
+         * 
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */     
+        function deletePreviousWord(operationState:SelectionState = null):void;     
+        
+        /** 
+         * Deletes a range of text.
+         * 
+         * @param operationState    Specifies the text to which this operation applies; 
+         * if <code>null</code>, the operation applies to the current selection.
+         * 
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */
+        function deleteText(operationState:SelectionState = null):void
+
+        /** 
+         * Inserts an image.
+         * 
+         * <p>The source of the image can be a string containing a URI, URLRequest object, a Class object representing an embedded asset,
+         * or a DisplayObject instance.</p>
+         *  
+         * <p>The width and height values can be the number of pixels, a percent, or the string, 'auto', 
+         * in which case the actual dimension of the graphic is used.</p>
+         * 
+         * <p>Set the <code>float</code> to one of the constants defined in the Float class to specify whether
+         * the image should be displayed to the left or right of any text or inline with the text.</p>
+         * 
+         *  @param  source  Can be either a String interpreted as a uri, a Class interpreted as the class of an Embed DisplayObject, 
+         *                  a DisplayObject instance or a URLRequest. 
+         *  @param  width   The width of the image to insert (number, percent, or 'auto').
+         *  @param  height  The height of the image to insert (number, percent, or 'auto').
+         *  @param  options None supported.
+         * @param operationState    Specifies the text to which this operation applies; 
+         * if <code>null</code>, the operation applies to the current selection.
+         * 
+         * 
+         * @see org.apache.flex.textLayout.elements.InlineGraphicElement
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+		 */
+		function insertInlineGraphic(source:Object, width:Object, height:Object, options:Object = null, operationState:SelectionState = null):IInlineGraphicElement;
+		
+		function insertTableElement(table:ITableElement, operationState:SelectionState = null):void;
+        
+        /** 
+         * Modifies an existing inline graphic.
+         * 
+         * <p>Set unchanging properties to the values in the original graphic. (Modifying an existing graphic object
+         * is typically more efficient than deleting and recreating one.)</p>
+         * 
+         *  @param  source  Can be either a String interpreted as a uri, a Class interpreted as the class of an Embed DisplayObject, 
+         *                  a DisplayObject instance or a URLRequest. 
+         *  @param  width   The new width for the image (number or percent).
+         *  @param  height  The new height for the image (number or percent).
+         *  @param  options None supported.
+         * @param operationState    Specifies the text to which this operation applies; 
+         * if <code>null</code>, the operation applies to the current selection.
+         * 
+         * 
+         *  @see org.apache.flex.textLayout.elements.InlineGraphicElement
+         * 
+        * @playerversion Flash 10
+        * @playerversion AIR 1.5
+         * @langversion 3.0
+         */         
+        function modifyInlineGraphic(source:Object, width:Object, height:Object, options:Object = null, operationState:SelectionState = null):void;
+
+        /** 
+         * Inserts text.
+         * 
+         * <p>Inserts the text at a position or range in the text. If the location supplied in the 
+         * <code>operationState</code> parameter is a range (or the parameter is <code>null</code> and the
+         * current selection is a range), then the text currently in the range 
+         * is replaced by the inserted text.</p>
+         * 
+         * @param   text        The string to insert.
+         * @param operationState    Specifies the text in the flow to which this operation applies; 
+         * if <code>null</code>, the operation applies to the current selection.
+         * 
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */ 
+        function insertText(text:String, operationState:SelectionState = null):void;
+        
+        /** 
+         * Overwrites the selected text.
+         * 
+         * <p>If the selection is a point selection, the first character is overwritten by the new text.</p>
+         * 
+         * @param text The string to insert.
+         * @param operationState Specifies the text to which this operation applies; 
+         * if <code>null</code>, the operation applies to the current selection.
+         * 
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */ 
+        function overwriteText(text:String, operationState:SelectionState = null):void;
+
+        /** 
+         * Applies paragraph styles to any paragraphs in the selection.
+         * 
+         * <p>Any style properties in the format object that are <code>null</code> are left unchanged.</p> 
+         * 
+         * @param format The format to apply to the selected paragraphs.
+         * @param operationState    Specifies the text to which this operation applies; 
+         * if <code>null</code>, the operation applies to the current selection.
+         * 
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */     
+        function applyParagraphFormat(format:ITextLayoutFormat, operationState:SelectionState = null):void;
+
+        /** 
+         * Applies container styles to any containers in the selection.
+         * 
+         * <p>Any style properties in the format object that are <code>null</code> are left unchanged.</p> 
+         * 
+         * @param format    The format to apply to the containers in the range
+         * @param operationState    Specifies the text to which this operation applies; 
+         * if <code>null</code>, the operation applies to the current selection.
+         * 
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */     
+        function applyContainerFormat(format:ITextLayoutFormat, operationState:SelectionState = null):void;
+        
+        /** 
+         * Applies styles to the specified element.
+         * 
+         * <p>Any style properties in the format object that are <code>null</code> are left unchanged.
+         * Only styles that are relevant to the specified element are applied.</p> 
+         * 
+         * @param   targetElement The element to which the styles are applied.
+         * @param   format  The format containing the styles to apply.
+         * @param relativeStart An offset from the beginning of the element at which to split the element when assigning the new formatting.
+         * @param relativeEnd An offset from the beginning of the element at which to split the element when applying the new formatting.
+         * @param operationState    Specifies the text to which this operation applies; 
+         * if <code>null</code>, the operation applies to the current selection.
+         * 
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */ 
+        function applyFormatToElement(targetElement:IFlowElement, format:ITextLayoutFormat, relativeStart:int = 0, relativeEnd:int = -1, operationState:SelectionState = null):void;
+        
+        /** 
+         * Undefines styles to the specified element.
+         * 
+         * <p>Any style properties in the format object that are <code>undefined</code> are left unchanged.
+         * Any styles that are defined in the specififed format are undefined on the specified element.</p> 
+         * 
+         * @param   targetElement The element to which the styles are applied.
+         * @param   format  The format containing the styles to undefine.
+         * @param operationState    Specifies the text to which this operation applies; 
+         * if <code>null</code>, the operation applies to the current selection.
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */ 
+        function clearFormatOnElement(targetElement:IFlowElement, format:ITextLayoutFormat, operationState:SelectionState = null):void;
+        
+        /** 
+         * Splits the paragraph at the current position, creating a new paragraph after the current one.
+         *   
+         * <p>If a range of text is specified, the text 
+         * in the range is deleted.</p>
+         * 
+         * @param operationState    Specifies the text to which this operation applies; 
+         * if <code>null</code>, the operation applies to the current selection.
+         * 
+         * @return  The new paragraph that was created.
+         * 
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */
+        function splitParagraph(operationState:SelectionState = null):IParagraphElement;
+        
+        /** Splits the target element at the location specified, creating a new element after the current one.
+         * If the operationState is a range, the text within the range is deleted. The new element is created 
+         * after the text position specified by operationState. Note that splitting a SubParagraphGroupElement 
+         * will have no effect because they will automatically remerge with the adejacent elements.
+         * 
+         * <p>An example where you might want to use this is if you have a list, and you want to divide it into two lists.</p>
+         * 
+         * @param target  The element to be split.
+         * @param operationState    Specifies the text to which this operation applies; 
+         * if <code>null</code>, the operation applies to the current selection.
+         * @return The new paragraph that was created.
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+		 */
+		function splitElement(target : IFlowGroupElement, operationState : SelectionState = null) : IFlowGroupElement;
+        
+        /** Creates a new IDivElement that contains the entire range specified in the operationState at the lowest
+         * common parent element that contains both the start and end points of the range. If the start and end
+         * points are the same, a new IDivElement is created at that position with a single child paragraph.
+         * 
+         * @param parent    Specifies a parent element for the new IDivElement.
+         * If <code>null</code> the new parent will be lowest level that contains the SelectionState.
+         * @param format    Formatting attributes to apply to the new IDivElement.
+         * @param operationState    Specifies the text to which this operation applies; 
+         * if <code>null</code>, the operation applies to the current selection.
+         * @return  The new IDivElement that was created.
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+          */
+        function createDiv(parent:IFlowGroupElement = null, format:ITextLayoutFormat = null, operationState:SelectionState = null):IDivElement;
+        
+        /** Creates a new ListElement that contains the entire range specified in the operationState at the lowest
+         * common parent element that contains both the start and end points of the range. Each paragraph within the 
+         * range will become a ListItemElement in the new ListElement. If the start and end
+         * points are the same, a new ListElement is created at that position with a single ListItemElement child.
+         * 
+         * @param parent Optionally specifies a parent element for the new ListElement.  
+         * If <code>null</code> the new parent will be lowest level that contains the SelectionState.
+         * @param format Formatting attributes to apply to the new ListElement.
+         * @param operationState    Specifies the text to which this operation applies; 
+         * if <code>null</code>, the operation applies to the current selection.
+         * @return  The new ListElement that was created.
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+		 */
+		function createList(parent:IFlowGroupElement = null, format:ITextLayoutFormat = null, operationState:SelectionState = null):IListElement;
+
+        /** Move a set of FlowElements from one IFlowGroupElement to another. The desinationElement must be a legal parent type for the children being moved,
+         * or an exception is thrown.
+         * 
+         * @param source    The orginal parent of the elements to be moved.
+         * @param sourceIndex   The child index within the source of the first element to be moved.
+         * @param numChildren   The number of children being moved.
+         * @param destination   The new parent of elements after move.
+         * @param destinationIndex  The child index within the destination to where elements are moved to.
+         * @param operationState    Specifies the text to which this operation applies, and to which selection returns to upon undo.  
+         * If <code>null</code>, the operation applies to the current selection.  If there is no current selection, this parameter must be non-null.
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */
+        function moveChildren(source:IFlowGroupElement, sourceIndex:int, numChildren:int, destination:IFlowGroupElement, destinationIndex:int, operationState:SelectionState = null):void
+
+        /** Creates a new SubParagraphGroupElement that contains the entire range specified in the operationState at the lowest
+         * common parent element that contains both the start and end points of the range. If the start and end
+         * points are the same, nothing is done.
+         * 
+         * @param parent Specifies a parent element for the new SubParagraphGroupElement element.
+         * If <code>null</code> the new parent will be lowest level that contains the SelectionState.
+         * @param format    Formatting attributes to apply to the new SubParagraphGroupElement
+         * @param operationState    Specifies the text to which this operation applies; 
+         * if <code>null</code>, the operation applies to the current selection.
+         * @return  The new SubParagraphGroupElement that was created.
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */
+        function createSubParagraphGroup(parent:IFlowGroupElement = null, format:ITextLayoutFormat = null, operationState:SelectionState = null):ISubParagraphGroupElement;
+
+        /** 
+         * Deletes the selected area and returns the deleted area in a TextScrap object. 
+         * 
+         * <p>The resulting TextScrap can be posted to the system clipboard or used in a 
+         * subsequent <code>pasteTextOperation()</code> operation.</p>
+         * 
+         * @param operationState    Specifies the text to which this operation applies; 
+         * if <code>null</code>, the operation applies to the current selection.
+         * @return The TextScrap that was cut.
+         * 
+         * 
+         * @see org.apache.flex.textLayout.edit.IEditManager.pasteTextScrap
+         * @see org.apache.flex.textLayout.edit.TextClipboard.setContents
+         *  
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */
+        function cutTextScrap(operationState:SelectionState = null):TextScrap;
+        
+        /** 
+         * Pastes the TextScrap into the selected area.
+         * 
+         * <p>If a range of text is specified, the text 
+         * in the range is deleted.</p>
+         * 
+         * @param scrapToPaste  The TextScrap to paste.
+         * @param operationState    Specifies the text to which this operation applies; 
+         * if <code>null</code>, the operation applies to the current selection.
+         * 
+         * 
+         * @see org.apache.flex.textLayout.edit.IEditManager.cutTextScrap
+         * @see org.apache.flex.textLayout.edit.TextClipboard.getContents
+         * @see org.apache.flex.textLayout.edit.TextScrap
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */
+         function pasteTextScrap(scrapToPaste:TextScrap, operationState:SelectionState = null):void;        
+
+        /** 
+         * Begins a new group of operations. 
+         * 
+         * <p>All operations executed after the call to <code>beginCompositeOperation()</code>, and before the 
+         * matching call to <code>endCompositeOperation()</code> are executed and grouped together as a single 
+         * operation that can be undone as a unit.</p> 
+         * 
+         * <p>A <code>beginCompositeOperation</code>/<code>endCompositeOperation</code> block can be nested inside another 
+         * <code>beginCompositeOperation</code>/<code>endCompositeOperation</code> block.</p>
+         * 
+         * 
+         * @see org.apache.flex.textLayout.edit.IEditManager.endCompositeOperation
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */
+        function beginCompositeOperation():void;
+        
+        /** 
+         * Ends a group of operations. 
+         * 
+         * <p>All operations executed since the last call to <code>beginCompositeOperation()</code> are 
+         * grouped as a CompositeOperation that is then completed. This CompositeOperation object is added 
+         * to the undo stack or, if this composite operation is nested inside another composite operation, 
+         * added to the parent operation.</p>
+         * 
+         * @see org.apache.flex.textLayout.edit.IEditManager.beginCompositeOperation
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */
+        function endCompositeOperation():void;
+
+        /** 
+         * Executes a FlowOperation.  
+          * 
+          * <p>The <code>doOperation()</code> method is called by IEditManager functions that 
+          * update the text flow. You do not typically need to call this function directly unless 
+          * you create your own custom operations.</p>
+          * 
+          * <p>This function proceeds in the following steps:</p>
+          * <ol>
+          * <li>Flush any pending operations before performing this operation.</li>
+          * <li>Send a cancelable flowOperationBegin event.  If canceled this method returns immediately.</li>
+          * <li>Execute the operation.  The operation returns <code>true</code> or <code>false</code>.  
+          * <code>False</code> indicates that no changes were made.</li>
+          * <li>Push the operation onto the undo stack.</li>
+          * <li>Clear the redo stack.</li>
+          * <li>Update the display.</li>
+          * <li>Send a cancelable flowOperationEnd event.</li>
+          * </ol>
+          * <p>Exception handling:  If the operation throws an exception, it is caught and the error is 
+          * attached to the flowOperationEnd event.  If the event is not canceled the error is rethrown.</p>
+          * 
+          * @param operation a FlowOperation object
+          * 
+
+          * 
+          * @playerversion Flash 10
+          * @playerversion AIR 1.5
+          * @langversion 3.0
+          */
+        function doOperation(operation:FlowOperation):void;
+
+        /** 
+         * Reverses the previous operation. 
+         * 
+         * <p><b>Note:</b> If the IUndoManager associated with this IEditManager is also associated with 
+         * another IEditManager, then it is possible that the undo operation associated with the other 
+         * IEditManager is the one undone.  This can happen if the FlowOperation of another IEditManager 
+         * is on top of the undo stack.</p>  
+         * 
+         * <p>This function does nothing if undo is not turned on.</p>
+         * 
+         * 
+         * @see flashx.undo.IUndoManager#undo()
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */
+        function undo():void;
+
+        /** 
+         * Reperforms the previous undone operation.
+         * 
+         * <p><b>Note:</b> If the IUndoManager associated with this IEditManager is also associated with 
+         * another IEditManager, then it is possible that the redo operation associated with the other 
+         * IEditManager is the one redone. This can happen if the FlowOperation of another IEditManager 
+         * is on top of the redo stack.</p>  
+         * 
+         * <p>This function does nothing if undo is not turned on.</p>
+         * 
+         * 
+         * @see flashx.undo.IUndoManager#redo()
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */
+        function redo():void;
+        
+        /** @private */
+        function performUndo(operation:IOperation):void;
+
+        /** @private */
+        function performRedo(operation:IOperation):void;
+
+        /**
+         * By default, calls into IEditManager handle updates synchronously, so the requested change is made and the text recomposed 
+         * and added to the display list within the IEditManager method. To get a delayed redraw, set <code>delayUpdates</code> to <code>true</code>. This 
+         * causes the IEditManager to only update the model, and recompose and redraw on the next <code>enter_frame</code> event. 
+         * 
+         * @playerversion Flash 10.2
+         * @playerversion AIR 2.0
+         * @langversion 3.0
+         */
+        function get delayUpdates():Boolean;
+        function set delayUpdates(value:Boolean):void;
+
+        /** Controls whether operations can be queued up for later execution.
+         * 
+         * <p>Execution of some operations might be delayed as a performance optimization. For example, it is 
+         * convenient to be able to combine multiple keystrokes into a single insert operation. If 
+         * <code>allowDelayedOperations</code> is <code>true</code>, then operations may be queued up. If <code>false</code>, all operations are
+         * executed immediately. By default, it is <code>true</code>.</p>
+         * 
+         * @see flashx.edit.ISelectionManager#flushPendingOperations
+         * 
+         * @playerversion Flash 10.2
+         * @playerversion AIR 2.0
+         * @langversion 3.0
+         */
+        function get allowDelayedOperations():Boolean;
+        function set allowDelayedOperations(value:Boolean):void;
+        
+        /** Updates the display after an operation has modified it. Normally this is handled automatically, but call
+         * this method if <code>delayUpdates</code> is on, and the display should be updated before the next <code>enter_frame</code> event. 
+         * 
+         * @playerversion Flash 10.2
+         * @playerversion AIR 2.0
+         * @langversion 3.0
+         */
+        function updateAllControllers():void;
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/IInteractionEventHandler.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/IInteractionEventHandler.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/IInteractionEventHandler.as
new file mode 100644
index 0000000..c2e374c
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/IInteractionEventHandler.as
@@ -0,0 +1,220 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.edit
+{
+	import org.apache.flex.text.events.TextEvent;
+	import org.apache.flex.text.events.IMEEvent;
+	import org.apache.flex.textLayout.events.ContextMenuEvent;
+	import org.apache.flex.events.Event;
+	import org.apache.flex.events.KeyboardEvent;
+	import org.apache.flex.events.MouseEvent;
+	
+	/**
+	 * The IInteractionEventHandler interface defines the event handler functions that
+	 * are handled by a Text Layout Framework selection or edit manager.
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	public interface IInteractionEventHandler
+	{
+		/** 
+		 * Processes an edit event.
+		 * 
+		 * <p>Edit events are dispatched for cut, copy, paste, and selectAll commands.</p>
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */	
+		function editHandler(event:Event):void;
+		
+		/** 
+		* Processes a keyDown event.
+		*  
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+ 		* @langversion 3.0
+		*/	
+		function keyDownHandler(event:KeyboardEvent):void;
+		
+		/** 
+		* Processes a keyUp event.
+		* 
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+ 		* @langversion 3.0
+		*/	
+		function keyUpHandler(event:KeyboardEvent):void;		
+		
+		/** 
+		* Processes a keyFocusChange event.
+		* 
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+ 		* @langversion 3.0
+		*/	
+		function keyFocusChangeHandler(event:Event):void;
+		
+		/** 
+		 * Processes a TextEvent.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */
+		function textInputHandler(event:TextEvent):void;
+
+		/** 
+		 * Processes an imeStartComposition event
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */
+		function imeStartCompositionHandler(event:IMEEvent):void;
+		
+		/** 
+		 * Processes an softKeyboardActivating event
+		 * 
+		 * @playerversion Flash 10.2
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */
+		function softKeyboardActivatingHandler(event:Event):void;
+		
+		/** 
+		 * Processes a mouseDown event.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */	
+		function mouseDownHandler(event:MouseEvent):void;
+
+		/** 
+		 * Processes a mouseMove event.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */	
+		function mouseMoveHandler(event:MouseEvent):void;
+		
+		/** 
+		 * Processes a mouseUp event.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */	
+		function mouseUpHandler(event:MouseEvent):void;		
+		
+		/** 
+		 * Processes a mouseDoubleClick event.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */	
+		function mouseDoubleClickHandler(event:MouseEvent):void;
+
+		/** 
+		 * Processes a mouseOver event.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */			
+		function mouseOverHandler(event:MouseEvent):void;
+
+		/** 
+		 * Processes a mouseOut event.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */					
+		function mouseOutHandler(event:MouseEvent):void;
+		
+		/** 
+		 * Processes a focusIn event.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */
+		function focusInHandler(event:Event):void;
+		 
+		/** 
+		 * Processes a focusOut event.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */
+		function focusOutHandler(event:Event):void;
+
+		/** 
+		 * Processes an activate event.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */				
+		function activateHandler(event:Event):void;
+		
+		/** 
+		 * Processes a deactivate event.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */				
+		function deactivateHandler(event:Event):void;
+		
+		/** 
+		 * Processes a focusChange event.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */				
+		function focusChangeHandler(event:Event):void
+		
+		/** 
+		 * Processes a menuSelect event.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */				
+		function menuSelectHandler(event:ContextMenuEvent):void
+		
+		/** 
+		 * Processes a mouseWheel event.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+		 */				
+		function mouseWheelHandler(event:MouseEvent):void
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/IMEClient.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/IMEClient.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/IMEClient.as
new file mode 100644
index 0000000..4986273
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/IMEClient.as
@@ -0,0 +1,434 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.edit {
+	import org.apache.flex.textLayout.elements.IFlowLeafElement;
+	import org.apache.flex.utils.PointUtils;
+	import org.apache.flex.utils.undo.UndoManager;
+	import org.apache.flex.utils.undo.IOperation;
+	import org.apache.flex.text.ime.IIMEClient;
+	import org.apache.flex.geom.Point;
+	import org.apache.flex.geom.Rectangle;
+	import org.apache.flex.text.ime.IME;
+	import org.apache.flex.text.engine.ITextLine;
+	import org.apache.flex.text.ime.CompositionAttributeRange;
+	
+	import org.apache.flex.textLayout.compose.IFlowComposer;
+	import org.apache.flex.textLayout.compose.ITextFlowLine;
+	import org.apache.flex.textLayout.container.IContainerController;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.elements.FlowLeafElement;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.textLayout.elements.TextRange;
+	import org.apache.flex.textLayout.formats.BlockProgression;
+	import org.apache.flex.textLayout.formats.IMEStatus;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+	import org.apache.flex.textLayout.operations.ApplyFormatToElementOperation;
+	import org.apache.flex.textLayout.operations.FlowOperation;
+	import org.apache.flex.textLayout.operations.InsertTextOperation;
+
+	import org.apache.flex.textLayout.utils.GeometryUtil;
+	
+
+
+	internal class IMEClient implements IIMEClient
+	{
+		private var _editManager:EditManager;
+		private var _undoManager:UndoManager;
+
+		/** Maintain position of text we've inserted while in the middle of processing IME. */
+		private var _imeAnchorPosition:int;		// start of IME text
+		private var _imeLength:int;				// length of IME text
+		private var _controller:IContainerController;		// controller that had focus at the start of the IME session -- we want this one to keep focus
+		private var _closing:Boolean;
+		CONFIG::debug { 
+			private var _imeOperation:IOperation; 	// IME in-progress edits - used for debugging to confirm that operation we're undoing is the one we did via IME
+		}
+		
+		public function IMEClient(editManager:EditManager)
+		{
+			_editManager = editManager;
+			_imeAnchorPosition = _editManager.absoluteStart;
+			if (_editManager.textFlow)
+			{
+				var flowComposer:IFlowComposer = _editManager.textFlow.flowComposer;
+				if (flowComposer) 
+				{
+					var controllerIndex:int = flowComposer.findControllerIndexAtPosition(_imeAnchorPosition);
+					_controller = flowComposer.getControllerAt(controllerIndex);
+					if (_controller)
+						_controller.setFocus();
+				}
+			}
+			_closing = false;
+			if (_editManager.undoManager == null)
+			{
+				_undoManager = new UndoManager();
+				_editManager.setUndoManager(_undoManager);
+			}
+		}
+		
+		/** @private
+		 * Handler function called when the selection has been changed.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */
+		public function selectionChanged():void
+		{	
+		//	trace("IMEClient.selectionChanged", _editManager.anchorPosition, _editManager.activePosition);
+			
+			// If we change the selection to something outside the session, abort the 
+			// session. If we just moved the selection within the session, we tell the IME about the changes.
+			if (_editManager.absoluteStart > _imeAnchorPosition + _imeLength || _editManager.absoluteEnd < _imeAnchorPosition)
+			{
+				//trace("selection changed to out of IME session");
+				compositionAbandoned();
+			}
+			else 
+			{
+				// This code doesn't with current version of Argo, but should work in future
+				//trace("selection changed within IME session");
+			//	var imeCompositionSelectionChanged:Function = IME["compositionSelectionChanged"];
+			//	if (IME["compositionSelectionChanged"] !== undefined)
+			 //		imeCompositionSelectionChanged(_editManager.absoluteStart - _imeAnchorPosition, _editManager.absoluteEnd - (_imeAnchorPosition + _imeLength));
+			}
+		}
+
+		private function doIMEClauseOperation(selState:SelectionState, clause:int):void
+		{
+ 		    var leaf:IFlowLeafElement = _editManager.textFlow.findLeaf(selState.absoluteStart);;
+		    var leafAbsoluteStart:int = leaf.getAbsoluteStart();
+			var format:TextLayoutFormat = new TextLayoutFormat();
+			format.setStyle(IMEStatus.IME_CLAUSE, clause.toString());
+			_editManager.doOperation(new ApplyFormatToElementOperation(selState, leaf, format, selState.absoluteStart - leafAbsoluteStart, selState.absoluteEnd - leafAbsoluteStart));
+		}
+		
+		private function doIMEStatusOperation(selState:SelectionState, attrRange:CompositionAttributeRange):void
+		{
+			var imeStatus:String;
+			
+			// Get the IME status from the converted & selected flags
+			if (attrRange == null)
+				imeStatus = IMEStatus.DEAD_KEY_INPUT_STATE;
+    		else if (!attrRange.converted)
+    		{
+    			if(!attrRange.selected)
+    				imeStatus = IMEStatus.NOT_SELECTED_RAW;
+    			else
+    				imeStatus = IMEStatus.SELECTED_RAW;
+    		}
+    		else
+    		{
+    			if (!attrRange.selected)
+    				imeStatus = IMEStatus.NOT_SELECTED_CONVERTED;
+    			else
+    				imeStatus = IMEStatus.SELECTED_CONVERTED;
+    		}
+
+
+			// refind since the previous operation changed the spans
+    		var leaf:IFlowLeafElement = _editManager.textFlow.findLeaf(selState.absoluteStart);
+			CONFIG::debug { assert(	leaf != null, "found null FlowLeafELement at" + (selState.absoluteStart).toString()); }						    		
+    		var leafAbsoluteStart:int = leaf.getAbsoluteStart();
+			
+			var format:TextLayoutFormat = new TextLayoutFormat();
+			format.setStyle(IMEStatus.IME_STATUS, imeStatus);
+
+			_editManager.doOperation(new ApplyFormatToElementOperation(selState, leaf, format, selState.absoluteStart - leafAbsoluteStart, selState.absoluteEnd - leafAbsoluteStart));
+		}
+		
+		private function deleteIMEText(textFlow:ITextFlow):void
+		{
+			// Delete any leaves that have IME attributes applied
+			var leaf:IFlowLeafElement = textFlow.getFirstLeaf();
+			while (leaf)
+			{
+				if (leaf.getStyle(IMEStatus.IME_STATUS) !== undefined || leaf.getStyle(IMEStatus.IME_CLAUSE) !== undefined)
+				{
+					var leafFormat:TextLayoutFormat = new TextLayoutFormat(leaf.format);
+					leafFormat.setStyle(IMEStatus.IME_STATUS, undefined);
+					leafFormat.setStyle(IMEStatus.IME_CLAUSE, undefined);
+					leaf.format = leafFormat;
+					var absoluteStart:int = leaf.getAbsoluteStart();
+					ModelEdit.deleteText(textFlow, absoluteStart, absoluteStart + leaf.textLength, false);
+					leaf = textFlow.findLeaf(absoluteStart);
+				}
+				else
+					leaf = leaf.getNextLeaf();
+			}
+		}
+		
+		private function rollBackIMEChanges():void
+		{
+			// Undo the previous interim ime operation, if there is one. This deletes any text that came in a previous updateComposition call.
+			// Doing it via undo keeps the undo stack in sync. But if there's been an intervening direct model change, just delete the IME text
+			// directly. It won't restore what we selected at the beginning of the IME session, but it's the best we can do.
+			var previousIMEOperation:FlowOperation = _editManager.undoManager.peekUndo() as FlowOperation;
+			if (_imeLength > 0 && previousIMEOperation && previousIMEOperation.endGeneration == _editManager.textFlow.generation && previousIMEOperation.canUndo())
+			{
+				CONFIG::debug { assert(_editManager.undoManager.peekUndo() == _imeOperation, "Unexpected operation in undo stack at end of IME update"); }
+				if (_editManager.undoManager)
+					_editManager.undoManager.undo();
+				CONFIG::debug { assert(_editManager.undoManager.peekRedo() == _imeOperation, "Unexpected operation in redo stack at end of IME session"); }
+				_editManager.undoManager.popRedo();
+			}
+			else		// there's been a model change since the last IME change that blocks undo, just find IME text and delete it.
+			{
+				_editManager.undoManager.popUndo();		// remove the operation we can't undo
+				deleteIMEText(_editManager.textFlow);
+			}
+			_imeLength = 0; // prevent double deletion
+			CONFIG::debug {  _imeOperation = null; }
+		}
+		
+		// IME-related functions
+		public function updateComposition(text:String, attributes:Vector.<CompositionAttributeRange>, compositionStartIndex:int, compositionEndIndex:int):void
+	    {
+		//	CONFIG::debug { Debugging.traceOut("updateComposition ", compositionStartIndex, compositionEndIndex, text.length); }
+		//	CONFIG::debug { Debugging.traceOut("updateComposition selection ", _editManager.absoluteStart, _editManager.absoluteEnd); }
+			
+			// Undo the previous interim ime operation, if there is one. This deletes any text that came in a previous updateComposition call.
+			// Doing it via undo keeps the undo stack in sync.
+			if (_imeLength > 0)
+				rollBackIMEChanges();
+
+			if (text.length > 0)
+			{
+				// Insert the supplied string, using the current editing format.
+				var pointFormat:ITextLayoutFormat = _editManager.getSelectionState().pointFormat;
+				var selState:SelectionState = new SelectionState(_editManager.textFlow, _imeAnchorPosition, _imeAnchorPosition + _imeLength, pointFormat);
+				
+				_editManager.beginIMEOperation();
+				
+				if (_editManager.absoluteStart != _editManager.absoluteEnd)
+					_editManager.deleteText();		// delete current selection
+				
+				var insertOp:InsertTextOperation = new InsertTextOperation(selState, text);
+				_imeLength = text.length;
+				_editManager.doOperation(insertOp);
+				
+				if (attributes && attributes.length > 0)
+				{
+					var attrLen:int = attributes.length;
+					for (var i:int = 0; i < attrLen; i++)
+					{
+						var attrRange:CompositionAttributeRange = attributes[i];
+						var clauseSelState:SelectionState = new SelectionState(_editManager.textFlow, _imeAnchorPosition + attrRange.relativeStart, _imeAnchorPosition + attrRange.relativeEnd);
+						
+						doIMEClauseOperation(clauseSelState, i);
+						doIMEStatusOperation(clauseSelState, attrRange);
+					}
+				}
+				else // composing accented characters
+				{	
+					clauseSelState = new SelectionState(_editManager.textFlow, _imeAnchorPosition, _imeAnchorPosition + _imeLength, pointFormat);
+					doIMEClauseOperation(clauseSelState, 0);
+					doIMEStatusOperation(clauseSelState, null);
+				}
+				
+				var newSelectionStart:int = _imeAnchorPosition + compositionStartIndex;
+				var newSelectionEnd:int = _imeAnchorPosition + compositionEndIndex;
+				if (_editManager.absoluteStart != newSelectionStart || _editManager.absoluteEnd != newSelectionEnd)
+				{
+					_editManager.selectRange(_imeAnchorPosition + compositionStartIndex, _imeAnchorPosition + compositionEndIndex);
+				}
+
+				CONFIG::debug {  _imeOperation = null; }
+				_editManager.endIMEOperation();	
+				CONFIG::debug {  _imeOperation = _editManager.undoManager.peekUndo(); }
+			}
+	    }
+	    
+	    public function confirmComposition(text:String = null, preserveSelection:Boolean = false):void
+		{
+		//	trace("confirmComposition", text, preserveSelection);
+			endIMESession();
+		}
+		
+		public function compositionAbandoned():void
+		{
+		//	trace("compositionAbandoned");
+
+			// In Argo we could just do this:
+			// IME.compositionAbandoned();
+			// but for support in Astro/Squirt where this API is undefined we do this:
+			var imeCompositionAbandoned:Function = IME["compositionAbandoned"];
+			if (IME["compositionAbandoned"] !== undefined)
+				imeCompositionAbandoned();
+		}
+		
+		private function endIMESession():void
+		{
+			if (!_editManager || _closing)
+				return;
+			
+		//	trace("end IME session");
+			
+			_closing = true;
+			
+			// Undo the IME operation. We're going to re-add the text, without all the special attributes, as part of handling
+			// the textInput event that comes next.
+			if (_imeLength > 0)
+				rollBackIMEChanges();
+
+			if (_undoManager)
+				_editManager.setUndoManager(null);
+
+			// Clear IME state - tell EditManager to release IMEClient to finally close session
+			_editManager.endIMESession();
+			_editManager = null;
+		}
+		
+		// CONFIG::debug
+		// {		// debugging code for displaying IME bounds rectangle
+			
+		// 	private function displayRectInContainer(container:Sprite, r:Rectangle):void
+		// 	{
+		// 		var g:Graphics = container.graphics;
+		// 		g.beginFill(0xff0000);
+		// 		g.moveTo(r.x, r.y);
+		// 		g.lineTo(r.right, r.y);
+		// 		g.lineTo(r.right, r.bottom);
+		// 		g.lineTo(r.x, r.bottom);
+		// 		g.lineTo(r.x, r.y);
+		// 		g.endFill(); 
+		// 	}
+		// }
+		
+		public function getTextBounds(startIndex:int, endIndex:int):Rectangle
+		{
+			if(startIndex >= 0 && startIndex < _editManager.textFlow.textLength && endIndex >= 0 && endIndex < _editManager.textFlow.textLength)
+			{
+				if (startIndex != endIndex)
+				{
+					var boundsResult:Array = GeometryUtil.getHighlightBounds(new TextRange(_editManager.textFlow, startIndex, endIndex));
+				    //bail out if we don't have any results to show
+					if (boundsResult.length > 0)
+					{
+						var bounds:Rectangle = boundsResult[0].rect; 
+					    	var textLine:ITextLine = boundsResult[0].textLine; 
+					    	var resultTopLeft:Point = PointUtils.localToGlobal(bounds.topLeft, textLine);// textLine.localToGlobal(bounds.topLeft);
+					    	var resultBottomRight:Point = PointUtils.localToGlobal(bounds.bottomRight, textLine);// textLine.localToGlobal(bounds.bottomRight);
+						if (textLine.parent)
+						{
+							var containerTopLeft:Point = PointUtils.globalToLocal(resultTopLeft, textLine.parent);// textLine.parent.globalToLocal(resultTopLeft);
+							var containerBottomLeft:Point = PointUtils.globalToLocal(resultBottomRight, textLine.parent);// textLine.parent.globalToLocal(resultBottomRight);
+						//	CONFIG::debug { displayRectInContainer(Sprite(textLine.parent), new Rectangle(containerTopLeft.x, containerTopLeft.y, containerBottomLeft.x - containerTopLeft.x, containerBottomLeft.y - containerTopLeft.y));}
+							return new Rectangle(containerTopLeft.x, containerTopLeft.y, containerBottomLeft.x - containerTopLeft.x, containerBottomLeft.y - containerTopLeft.y);
+						}
+					}
+				}
+				else
+				{
+					var flowComposer:IFlowComposer = _editManager.textFlow.flowComposer;
+					var lineIndex:int = flowComposer.findLineIndexAtPosition(startIndex);
+	
+					// Stick to the end of the last line
+					if (lineIndex == flowComposer.numLines)
+						lineIndex--;
+					if (flowComposer.getLineAt(lineIndex).controller == _controller)
+					{
+						var line:ITextFlowLine = flowComposer.getLineAt(lineIndex);
+						var previousLine:ITextFlowLine = lineIndex != 0 ? flowComposer.getLineAt(lineIndex-1) : null;
+						var nextLine:ITextFlowLine = lineIndex != flowComposer.numLines-1 ? flowComposer.getLineAt(lineIndex+1) : null;
+					//	CONFIG::debug { displayRectInContainer(_controller.container, line.computePointSelectionRectangle(startIndex, _controller.container, previousLine, nextLine, true));}
+						return line.computePointSelectionRectangle(startIndex, _controller.container, previousLine, nextLine, true);
+					}
+				}
+			}
+			
+			return new Rectangle(0,0,0,0);
+		}
+		
+		public function get compositionStartIndex():int
+		{
+		//	trace("compositionStartIndex");
+			return _imeAnchorPosition;
+		}
+		
+		public function get compositionEndIndex():int
+		{
+		//	trace("compositionEndIndex");
+			return _imeAnchorPosition + _imeLength;
+		}
+		
+		public function get verticalTextLayout():Boolean
+		{
+		//	trace("verticalTextLayout ", _editManager.textFlow.computedFormat.blockProgression == BlockProgression.RL ? "true" : "false");
+			return _editManager.textFlow.computedFormat.blockProgression == BlockProgression.RL;
+		}
+
+		public function get selectionActiveIndex():int
+		{
+			//trace("selectionActiveIndex");
+			return _editManager.activePosition;
+		}
+		
+		public function get selectionAnchorIndex():int
+		{
+			//trace("selectionAnchorIndex");
+			return _editManager.anchorPosition;
+		}
+		
+		public function selectRange(anchorIndex:int, activeIndex:int):void
+		{
+			_editManager.selectRange(anchorIndex, activeIndex);
+		}
+
+		public function setFocus():void
+		{
+//TODO deal with stage and focus
+//			if (_controller && _controller.container && _controller.container.stage && _controller.container.stage.focus != _controller.container)
+//				_controller.setFocus();
+		}
+		
+		/** 
+		 * Gets the specified range of text from a component implementing ITextSupport.
+		 * To retrieve all text in the component, do not specify values for <code>startIndex</code> and <code>endIndex</code>.
+		 * Components which wish to support inline IME or web searchability should call into this method.
+		 * Components overriding this method should ensure that the default values of <code>-1</code> 
+		 * for <code>startIndex</code> and <code>endIndex</code> are supported.
+		 * 
+		 * @playerversion Flash 10.0
+		 * @langversion 3.0
+		 */
+		public function getTextInRange(startIndex:int, endIndex:int):String
+		{
+			//trace("getTextInRange");
+			// Check for valid indices
+			var textFlow:ITextFlow = _editManager.textFlow;
+			if (startIndex < -1 || endIndex < -1 || startIndex > (textFlow.textLength - 1) || endIndex > (textFlow.textLength - 1))
+				return null;
+			
+			// Make sure they're in the right order
+			if (endIndex < startIndex)
+			{
+				var tempIndex:int = endIndex;
+				endIndex = startIndex;
+				startIndex = tempIndex;
+			}
+			
+			if (startIndex == -1)
+				startIndex = 0;
+			
+			return textFlow.getText(startIndex, endIndex);
+		} 
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/IMemento.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/IMemento.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/IMemento.as
new file mode 100644
index 0000000..fdb31ff
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/IMemento.as
@@ -0,0 +1,34 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.edit 
+{
+	// [ExcludeClass]
+	/** 
+	 * The IMemento interface is returned by ModelEdit for undo of a specific action that represents part of an operation.
+	 * @prviate
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	public interface IMemento
+	{
+		function undo():*;
+		function redo():*;
+	}
+}


[40/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/BaseCompose.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/BaseCompose.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/BaseCompose.as
new file mode 100644
index 0000000..bd86156
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/BaseCompose.as
@@ -0,0 +1,2922 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.compose
+{
+	import org.apache.flex.textLayout.elements.IContainerFormattedElement;
+	import org.apache.flex.textLayout.utils.BackgroundUtil;
+	import org.apache.flex.textLayout.elements.ITableRowElement;
+	import org.apache.flex.textLayout.formats.BreakStyle;
+	import org.apache.flex.textLayout.elements.LeadingUtils;
+	import org.apache.flex.textLayout.compose.utils.TextLineUtil;
+	import org.apache.flex.textLayout.elements.ITableColElement;
+	import org.apache.flex.textLayout.elements.ITableElement;
+	import org.apache.flex.textLayout.elements.ITableCellElement;
+	import org.apache.flex.textLayout.elements.ISpanElement;
+	import org.apache.flex.textLayout.elements.IInlineGraphicElement;
+	import org.apache.flex.core.IParentIUIBase;
+	import org.apache.flex.geom.Matrix;
+	import org.apache.flex.geom.Rectangle;
+	import org.apache.flex.text.engine.Constants;
+	import org.apache.flex.text.engine.ITextBlock;
+	import org.apache.flex.text.engine.ITextLine;
+	import org.apache.flex.text.engine.TextBaseline;
+	import org.apache.flex.text.engine.TextLineCreationResult;
+	import org.apache.flex.textLayout.container.IContainerController;
+	import org.apache.flex.textLayout.debug.assert;
+	// import org.apache.flex.textLayout.elements.Configuration;
+	import org.apache.flex.textLayout.elements.GlobalSettings;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	import org.apache.flex.textLayout.elements.IFlowGroupElement;
+	import org.apache.flex.textLayout.elements.IFlowLeafElement;
+	import org.apache.flex.textLayout.elements.ILinkElement;
+	import org.apache.flex.textLayout.elements.IListElement;
+	import org.apache.flex.textLayout.elements.IListItemElement;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.OverflowPolicy;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.textLayout.formats.BaselineOffset;
+	import org.apache.flex.textLayout.formats.BlockProgression;
+	import org.apache.flex.textLayout.formats.ClearFloats;
+	import org.apache.flex.textLayout.formats.Direction;
+	import org.apache.flex.textLayout.formats.Float;
+	import org.apache.flex.textLayout.formats.FormatValue;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.formats.LeadingModel;
+	import org.apache.flex.textLayout.formats.ListStylePosition;
+	import org.apache.flex.textLayout.formats.TextAlign;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+	import org.apache.flex.textLayout.formats.VerticalAlign;
+	import org.apache.flex.textLayout.utils.LocaleUtil;
+	import org.apache.flex.textLayout.utils.Twips;
+	import org.apache.flex.utils.ObjectMap;
+	
+	/** 
+	 * Common composer base class 
+	 * */
+	public class BaseCompose implements IComposer	{
+		
+		// a one deep AlignData cache
+		static private var _savedAlignData:AlignData;
+		static private function createAlignData(tfl:ITextFlowLine):AlignData
+		{ 
+			if (_savedAlignData)
+			{
+				var rslt:AlignData = _savedAlignData; 
+				rslt.textFlowLine = tfl;
+				_savedAlignData = null;
+				return rslt;
+			}
+			return new AlignData(tfl);
+		}
+		static private function releaseAlignData(ad:AlignData):void
+		{ 
+			ad.textLine = null;	// don't hold on to it
+			ad.textFlowLine = null;
+			_savedAlignData = ad; 
+		}
+		
+		protected var _parcelList:ParcelList;
+		
+		/** List of areas we're composing into, matches the container's bounding box */
+		public function get parcelList():ParcelList
+		{ return _parcelList; }
+		
+		private var _correctTextLength:Boolean = false;
+		
+		/** Element of current location */
+		protected var _curElement:IFlowLeafElement;		
+		/** Absolute start position of _curElement */
+		protected var _curElementStart:int;		
+		/** Offset from element start to current location */
+		protected var _curElementOffset:int;		
+		/** ParagraphElement that contains the current location */
+		protected var _curParaElement:IParagraphElement;	
+		protected var _curParaFormat:ITextLayoutFormat;
+		/** Absolute start position of _curParaElement */
+		protected var _curParaStart:int;
+		/** Absolute start position of the current line */
+		protected var _curLineStart:int;
+		/** leading model for the current line's para (set when line is being composed and committed to _lastLineLeadingModel when line is finalized) */
+		private var _curLineLeadingModel:String = "";
+		/** leading factor calculated when composing the current line (committed to _lastLineLeading when line is finalized)
+		 * The factor has different meanings for different leading models. */
+		private var _curLineLeading:Number;
+		/** leading model for the last line's para */
+		protected var _lastLineLeadingModel:String = "";
+		/** leading factor calculated for the line composed last. 
+		 * The factor has different meanings for different leading models. */
+		protected var _lastLineLeading:Number;
+		/** effective descent of the last line. This is the distance between a line's Roman baseline and 
+		 * its Descent baseline (for leading models other than LeadingModel.BOX) or the bottom of its CSS line box (for LeadingModel.BOX) */
+		protected var _lastLineDescent:Number;
+		/** Amount of spaceAfter added to the previous line (used in calculating effective paragraphSpaceBefore/paragraphSpaceAfter */
+		protected var _paragraphSpaceCarried:Number;
+		/** Amount of vertical space added to the previous element (used in calculating vertical space collapse) **/
+		protected var _verticalSpaceCarried:Number;
+		/** BlockProgression - vertical horizontal etc. @see text.formats.BlockProgression */
+		protected var _blockProgression:String;
+		/** Are we at the top of the column? */
+		protected var _atColumnStart:Boolean;
+		/** Current textIndent amount, 0 if line is not the first */
+		protected var _textIndent:Number;
+		
+		/** Minimum left edge coordinate across all the parcels in a controller */
+		private var _controllerLeft:Number;
+		/** Minimum top edge across all the parcels in a controller */
+		private var _controllerTop:Number;
+		/** Maximum right edge coordinate across all the parcels in a controller */
+		private var _controllerRight:Number;
+		/** Maximum bottom edge coordinate across all the parcels in a controller */
+		private var _controllerBottom:Number;
+		
+		/** Maximum horizontal extension from left/right edge of the parcel.  Alignment width for the parcel when measuring. */
+		protected var _contentLogicalExtent:Number;
+		/** Commited extent any lines needing additional alignment must update this number */
+		protected var _contentCommittedExtent:Number;
+		/** Committed logical height from floats */
+		protected var _contentCommittedHeight:Number;
+		/** Maximum horizontal extension for the current line from left/right edge of the parcel.  */
+		protected var _workingContentLogicalExtent:Number;
+		/* Extent for the current line, accumulated into _contentCommitedExtent when the line is committed */
+		protected var _workingContentExtent:Number;
+		/* Height for the current line, accumulated into _contentCommittedHeight when the line is committed */
+		protected var _workingContentHeight:Number;
+		/* Total depth as of the start of the line */
+		protected var _workingTotalDepth:Number;
+		/* Current parcel when line was started */
+		protected var _workingParcelIndex:int;
+		/** logical top of the parcel, for the line in progress */
+		protected var _workingParcelLogicalTop:Number;
+		/** Minimum starting coord for parcel bounds */
+		protected var _accumulatedMinimumStart:Number;
+		/** Minimum starting coord for parcel bounds */
+		protected var _parcelLogicalTop:Number;
+		
+		/** Minimum left edge coordinate across all the parcels in a controller */
+		protected var _parcelLeft:Number;
+		/** Minimum top edge across all the parcels in a controller */
+		protected var _parcelTop:Number;
+		/** Maximum right edge coordinate across all the parcels in a controller */
+		protected var _parcelRight:Number;
+		/** Maximum bottom edge coordinate across all the parcels in a controller */
+		protected var _parcelBottom:Number;
+		
+		/** owning textFlow of current compose */
+		protected var _textFlow:ITextFlow;
+		private var _releaseLineCreationData:Boolean;
+		/** flowComposer of current compose */
+		protected var _flowComposer:IFlowComposer;
+		/** rootElement of current compose */
+		protected var _rootElement:IContainerFormattedElement;
+		/** position to stop composing at */
+		protected var _stopComposePos:int;
+		
+		/** First damaged controller to begin composing */
+		protected var _startController:IContainerController;
+		/** Beginning composition position.  Note this gets cleared once its been passed */
+		protected var _startComposePosition:int;
+		
+		/** Visible area of the current controller. Used to determine which lines are going to be in view. */	
+		protected var _controllerVisibleBoundsXTW:int;
+		protected var _controllerVisibleBoundsYTW:int;
+		protected var _controllerVisibleBoundsWidthTW:int;
+		protected var _controllerVisibleBoundsHeightTW:int; 
+		
+		protected var _forceILGs:Boolean;
+		protected var _lastGoodStart:int;		// used to group lines together in a single container when composing floats
+		protected var _linePass:int;			// count of how many times we've retried this line
+		protected var _paragraphContainsVisibleLines:Boolean;
+		
+		// save line slug for reuse - otherwise we're creating and discarding all the time
+		static protected var _savedLineSlug:Slug;
+		protected var _lineSlug:Slug = new Slug();
+		static protected var _floatSlug:Slug;
+		protected var _pushInFloats:Array;
+		
+		// scratch array for holding lines awaiting alignment
+		private var _alignLines:Array;
+		
+		/** Parcel we are composing - used for keeping track of when it changes b/c parcelList.parcel may have advanced */
+		protected var _curParcel:Parcel;
+		
+		/** Start position of _curParcel */
+		protected var _curParcelStart:int;
+		
+		/** For interactive objects */
+		protected var _curInteractiveObjects: ObjectMap = null;
+		
+		/** Are we measuring */
+		protected var _measuring:Boolean;
+		
+		protected var _curLine:ITextFlowLine;
+		protected var _previousLine:ITextLine;
+		
+		protected var _listItemElement:IListItemElement;
+		private var _firstLineDescentAndLeading:Number;
+		
+		protected function createParcelList():ParcelList
+		{ return null; }
+		protected function releaseParcelList(list:ParcelList):void	// No PMD
+		{ }
+		
+		/** Starting controller for skipping ahead */
+		public function get startController():IContainerController
+		{ return _startController; }
+		
+		/** prevent any leaks. @private */
+		public function releaseAnyReferences():void
+		{
+			_curElement = null;
+			_curParaElement = null;
+			_curParaFormat = null;
+			_flowComposer = null;
+			_parcelList = null;
+			_rootElement = null;
+			_startController = null;
+			_textFlow = null;
+			_previousLine = null;
+			_curLine = null;
+		}
+		
+		/** Initialize for a composition that will compose up through the controllerEndIndex, or all the way to the end of the flow
+		 * @param composer
+		 * @param composeToPosition 	-1 means not specified.  0 means request to compose nothing, >0 specifies a position to force compose to
+		 * @param controllerStartIndex	index of the first controller to compose for, derived class allows -1 for default 
+		 * @param controllerEndIndex	index of the last controller to compose for, or -1 to compose through all controllers
+		 */
+		protected function  initializeForComposer(composer:IFlowComposer, composeToPosition:int, controllerStartIndex:int, controllerEndIndex:int):void
+		{
+			CONFIG::debug 
+			{ 
+				var count:int = 0;
+				_textFlow.applyFunctionToElements(function (elem:IFlowElement):Boolean{ if (elem.defaultTypeName == "img") count++; return false; });
+				assert(count == _textFlow.graphicObjectCount,"BaseCompose mistmatched graphicObject count");
+				
+				count = 0;
+				_textFlow.applyFunctionToElements(function (elem:IFlowElement):Boolean{ if (elem.hasActiveEventMirror()) count++; if (elem is ILinkElement) count++; return false; });
+				assert(count == _textFlow.interactiveObjectCount,"BaseCompose mistmatched interactiveObject count");
+
+				assert(composer.getControllerIndex(_startController) == controllerStartIndex, "BaseCompose initializeForComposer expected derived class to set up _startController before now"); 
+				assert(controllerStartIndex >= 0, "BaseCompose initializeForComposer expected derived class to set controllerStartIndex to a valid controller"); 
+			}
+			if (!_savedLineSlug)
+				_lineSlug = new Slug();
+			else
+			{
+				_lineSlug = _savedLineSlug;
+				_savedLineSlug = null;
+			}
+			_parcelList = createParcelList();
+			
+			_paragraphSpaceCarried = 0;
+			_blockProgression = composer.rootElement.computedFormat.blockProgression;
+
+			// for a non-specified compose position the ParcelList handles the bail out - just set to textLength
+			_stopComposePos = composeToPosition >= 0 ? Math.min(_textFlow.textLength,composeToPosition) : _textFlow.textLength;
+			
+			if (controllerStartIndex < 0)
+				controllerStartIndex = 0;
+			
+			// this chains through the list - tell it if a "care about" composeToPosition was specified
+			_parcelList.beginCompose(composer, controllerStartIndex, controllerEndIndex, composeToPosition > 0);	
+			
+			_contentLogicalExtent = 0;
+			_contentCommittedExtent = 0;
+			_contentCommittedHeight = 0;
+			_accumulatedMinimumStart = Constants.MAX_LINE_WIDTH;
+			_parcelLogicalTop = NaN;
+			
+			_linePass = 0;
+			_lastGoodStart = -1;
+			if (_pushInFloats)
+				_pushInFloats.length = 0;
+			
+			_listItemElement = null;
+		}
+		
+		/**
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.IParagraphElement
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.ITextFlow
+		 */
+		private function composeBlockElement(elem:IFlowGroupElement, absStart:int, isInTable:Boolean=false, startChildIdx:int = -1):Boolean
+		{	
+			var child:IFlowElement;
+			var rslt:Boolean;	// scratch
+			var isInTableCell:Boolean = elem.className == "TextFlow" && ITextFlow(elem).parentElement.className == "TableCellElement" ? true : false;
+			var cellSpacing:Number = 0;
+			
+			if (isInTableCell) {
+				var tableCell:ITableCellElement = ITextFlow(elem).parentElement as ITableCellElement;
+				var table:ITableElement = tableCell.table;
+				cellSpacing = table.cellSpacing!=undefined ? table.cellSpacing : 0;
+			}
+			
+			// Iterate through the children, composing them. If we're starting in the middle of the element,
+			// make sure we advance to the starting child.
+			var idx:int = 0;
+			if ( startChildIdx != -1 )
+				idx = startChildIdx;
+			
+			if (absStart != _curElementStart + _curElementOffset) 	// starting partway in
+			{
+				idx = elem.findChildIndexAtPosition((_curElementStart + _curElementOffset) - absStart);
+				child = elem.getChildAt(idx);
+				absStart += child.parentRelativeStart;
+				
+				// Fix bug#2907691 When composition starts in middle of the container, paddingBottom for the previous paragraph is ignored
+				// add prevous paragraph's paddingBottom values to totalDepth
+				var previousElement:IFlowLeafElement = _textFlow.findLeaf(_startComposePosition - 1);
+				if (previousElement)
+				{
+					var previousParagraph:IParagraphElement = previousElement.getParagraph();
+					if (previousParagraph && previousParagraph != _curElement.getParagraph())
+						if (previousParagraph.paddingBottom != undefined)
+							_parcelList.addTotalDepth(previousParagraph.paddingBottom);
+				}
+				
+				// child is table means recompose starts in the middle of a table. 
+				// In this case, we finished compose the table, then continue
+				// Harbs - need to analize whether this makes sense at all...
+				/*
+				if ( child is TableElement )
+				{
+				// if it makes sense, we need to redo this logic.
+
+				}
+				*/
+			}
+			
+			var composeEntireElement:Boolean = (absStart == _curElementStart + _curElementOffset);
+
+			// Compose all the children, until all the containers are filled, or if we're on the last container, we've hit the stop compose text index			
+			for (; idx < elem.numChildren && (absStart <= _stopComposePos || ! parcelList.atLast()); idx++)
+			{
+				child = elem.getChildAt(idx);
+				
+				// If the element has clear applied, handle that now
+				if (child.computedFormat.clearFloats != ClearFloats.NONE)
+				{
+					var adjustedDepth:Number = _curParcel.applyClear(child.computedFormat.clearFloats, _parcelList.totalDepth, child.computedFormat.direction);
+					_parcelList.addTotalDepth(adjustedDepth);
+					_verticalSpaceCarried = 0;
+				}
+				
+				var boxLeftIndent:Number;		// logical with respect to horizontal/vertical text
+				var boxRightIndent:Number;		// logical with respect to horizontal/vertical text
+				var boxTopIndent:Number;		// logical with respect to horizontal/vertical text
+				var boxBottomIndent:Number;		// logical with respect to horizontal/vertical text
+				if (_blockProgression == BlockProgression.RL)
+				{
+					boxLeftIndent = child.getEffectivePaddingTop() + child.getEffectiveBorderTopWidth() + child.getEffectiveMarginTop();
+					boxRightIndent = child.getEffectivePaddingBottom() + child.getEffectiveBorderBottomWidth() + child.getEffectiveMarginBottom();
+					boxTopIndent = child.getEffectivePaddingRight() + child.getEffectiveBorderRightWidth() + child.getEffectiveMarginRight();
+					boxBottomIndent = child.getEffectivePaddingLeft() + child.getEffectiveBorderLeftWidth() + child.getEffectiveMarginLeft();
+				}
+				else
+				{
+					boxLeftIndent = child.getEffectivePaddingLeft() + child.getEffectiveBorderLeftWidth() + child.getEffectiveMarginLeft();
+					boxRightIndent = child.getEffectivePaddingRight() + child.getEffectiveBorderRightWidth() + child.getEffectiveMarginRight();
+					boxTopIndent = child.getEffectivePaddingTop() + child.getEffectiveBorderTopWidth() + child.getEffectiveMarginTop();
+					boxBottomIndent = child.getEffectivePaddingBottom() + child.getEffectiveBorderBottomWidth() + child.getEffectiveMarginBottom();
+					
+					if (isInTableCell) {
+						boxLeftIndent += cellSpacing;
+						boxRightIndent += cellSpacing;
+						boxTopIndent += cellSpacing;
+						boxBottomIndent += cellSpacing;
+					}
+				}
+				CONFIG::debug { assert(!isNaN(boxLeftIndent) && ! isNaN(boxRightIndent),"BAD indents"); }
+				_parcelList.pushLeftMargin(boxLeftIndent);
+				_parcelList.pushRightMargin(boxRightIndent);
+				if (composeEntireElement && boxTopIndent > _verticalSpaceCarried)
+					_parcelList.addTotalDepth(boxTopIndent - _verticalSpaceCarried);
+				_verticalSpaceCarried = Math.max(boxTopIndent, 0);
+								
+				
+				
+				if (child.className == "ParagraphElement")
+				{
+					var para:IParagraphElement = child as IParagraphElement;
+					if ( !_atColumnStart && para.computedFormat.columnBreakBefore == BreakStyle.ALWAYS)
+					{
+						advanceToNextParcel() ;
+					}
+					if ( !(_atColumnStart && _parcelList.currentParcel != null && _parcelList.currentParcel.columnIndex == 0) && para.computedFormat.containerBreakBefore == BreakStyle.ALWAYS)
+					{
+						advanceToNextContainer() ;
+					}
+					
+					if (!composeParagraphElement(para,absStart))
+					{
+						//for paragraph that has invisible text
+						BackgroundUtil.collectBlock(_textFlow, elem);
+						return false;	// done
+					}
+					
+					if (!(_atColumnStart && _parcelList.currentParcel != null && _parcelList.currentParcel.columnIndex == 0) && para.computedFormat.containerBreakAfter == BreakStyle.ALWAYS)
+					{
+						advanceToNextContainer() ;
+					}
+					if (!_atColumnStart && para.computedFormat.columnBreakAfter == BreakStyle.ALWAYS)
+					{
+						advanceToNextParcel() ;
+					}
+				}
+				else if (child is IListElement)
+				{						
+					rslt = composeBlockElement(IFlowGroupElement(child),absStart);
+					
+					if (!rslt)
+					{
+						//for list that has invisible text
+						BackgroundUtil.collectBlock(_textFlow, elem);
+						return false;
+					}
+				}
+				else if (child is IListItemElement)
+				{
+					var savedListItemElement:IListItemElement = _listItemElement;
+					_listItemElement = child as IListItemElement;
+					rslt = composeBlockElement(IFlowGroupElement(child),absStart);
+					_listItemElement = savedListItemElement;
+						
+					if (!rslt)
+					{
+						//for list item that has invisible text 
+						BackgroundUtil.collectBlock(_textFlow, elem);
+						return false;
+					}
+				}
+				else 
+				{
+					if ( ! composeBlockElement(IFlowGroupElement(child),absStart))
+					{
+						//for div that has invisible text
+						BackgroundUtil.collectBlock(_textFlow, elem);
+						return false;
+					}
+				}
+				
+				if (boxBottomIndent > _verticalSpaceCarried)
+					_parcelList.addTotalDepth(boxBottomIndent - _verticalSpaceCarried);
+				_verticalSpaceCarried = Math.max(boxBottomIndent, 0);
+				
+				// restore to original values
+				_parcelList.popLeftMargin(boxLeftIndent);
+				_parcelList.popRightMargin(boxRightIndent);
+				composeEntireElement = true;
+				
+				absStart += child.textLength;
+			}
+			
+			//for elements, whose text are all visible, except for TableElement, TableRowElement and TableCellElement
+			var className:String = elem.className;
+			if(!(className == "TableElement" || className == "TableRowElement" || className == "TableCellElement"))// (we don't process these...)
+				BackgroundUtil.collectBlock(_textFlow, elem);
+			
+			return true;
+		}
+		
+		/** @private
+		 * Compose a entire table element
+		 * In  : TableElement, table's absStart position, isInTable
+		 * Out : Boolean value, composition result, true - successful, false - failed
+		 */
+		private function composeTableElement(tableElement:ITableElement, absStart:int):Boolean
+		{
+			//TODO: remove any old existing cells in the _parcelList.currentParcel.controller from the position of the table and on.
+			// need to figure out the accounting needed for that.
+
+			// Space before does not apply to the first line, unless LeadingModel.BOX is used
+			// Space carried never applies to the first line
+			if(_curLine && _curLine.paragraph == _curParaElement)
+				var spaceBefore:Number = 0;
+			else
+				spaceBefore = isNaN(_curParaElement.computedFormat.paragraphSpaceBefore) ? 0 : _curParaElement.computedFormat.paragraphSpaceBefore;
+			
+			spaceBefore  = _atColumnStart ? 0 : spaceBefore;
+			var spaceCarried:Number = _atColumnStart ? 0 : _paragraphSpaceCarried;
+			if (spaceBefore != 0 || spaceCarried != 0)
+				_parcelList.addTotalDepth(Math.max(spaceBefore, spaceCarried));
+			
+			_paragraphSpaceCarried = 0;
+			if (_verticalSpaceCarried != 0)
+				_verticalSpaceCarried = 0;
+
+			// get a slug...
+			_parcelList.getLineSlug(_lineSlug, 0, 1, _textIndent, _curParaFormat.direction == Direction.LTR);
+			
+			// doesn't do anything yet.
+			tableElement.normalizeColumnWidths(_lineSlug.width);
+			
+			// step 1 -- make sure all cells are composed
+			tableElement.composeCells();
+			
+			// step 2 get header and footer heights
+			// I'm not sure if we need to calculate table padding/margin
+			//var baseTableHeight:Number = tableElement.getHeaderHeight() + tableElement.getFooterHeight();
+			//_parcelList.getLineSlug(_lineSlug, 0, 1, _textIndent, _curParaFormat.direction == Direction.LTR);
+			
+//			var headerHeight:Number = tableElement.getHeaderHeight();
+//			var footerHeight:Number = tableElement.getFooterHeight();
+			
+			// need to calculate margins and padding as well. (top, bottom and sides) It should inherit from the containing paragraph if necessary.
+			// I'm assuming tables can inherit proeprties from paragraphs.
+			
+			// step 3 loop through the cells and assign them to containers and set the positions
+
+			var totalRowHeight:Number = 0;
+//			var haveRealRows:Boolean = false;
+			//grab the headers and footers for use in each parcel
+//			var headerRows:Vector.< Vector.<TableCellElement> > = tableElement.getHeaderRows();
+//			var footerRows:Vector.< Vector.<TableCellElement> > = tableElement.getFooterRows();
+			
+			var curRow:Vector.<ITableCellElement> = tableElement.getNextRow();
+			var curTableBlock:ITextFlowTableBlock = tableElement.getFirstBlock();
+			curTableBlock.clear();
+			curTableBlock.y = _parcelList.totalDepth;
+			var adjustTop:Number = isNaN(_lastLineDescent) ? 0 : _lastLineDescent;
+			curTableBlock.y += adjustTop;
+			curTableBlock.x = _lineSlug.leftMargin;
+			var lineOffset:Number = (_curParaFormat.direction == Direction.LTR) ? _lineSlug.leftMargin : _lineSlug.rightMargin;
+			curTableBlock.initialize(_curParaElement, _lineSlug.width, lineOffset-_parcelList.insideListItemMargin, tableElement.getAbsoluteStart(),1);
+			var blockToAdd:Boolean = true;
+			
+			while(curRow){
+				
+				// I'm ignoring headers and footers for now. We need to add them in later.
+				var rIdx:int = curRow[0].rowIndex;
+				var curRowElem:ITableRowElement = tableElement.getRowAt(rIdx);
+				var rowHeight:Number = curRowElem.composedHeight;
+
+
+//TODO dead code. Is it needed? I think it's commented out because the logic to add in the rows was never finished.
+
+//				var minRowHeight:Number = curRowElem.totalHeight;
+				//_parcelList.addTotalDepth(tableElement.getEffectiveMarginBottom());
+
+//				while(
+//					false
+//					//!(_parcelList.currentParcel.fitsInHeight(_parcelList.totalDepth, minRowHeight + footerHeight))
+//				){
+//					//TODO: add in footer rows...
+//					
+//					curTableBlock.height = totalRowHeight;
+//					
+//					if(!haveRealRows)
+//						curTableBlock.clear();
+//					
+//					endTableBlock(curTableBlock);
+////					curTableBlock.setController(_parcelList.currentParcel.controller,_parcelList.currentParcel.columnIndex);
+//
+////					_parcelList.currentParcel.controller.addComposedTableBlock(curTableBlock.container);
+////					BackgroundManager.collectTableBlock(_textFlow,curTableBlock, _parcelList.currentParcel.controller);
+//					blockToAdd = false;
+//					
+//					if(!_parcelList.next())
+//					{ // current parcel not valid
+//						break;
+//					}
+//					_parcelList.getLineSlug(_lineSlug, 0, 1, _textIndent, _curParaFormat.direction == Direction.LTR);
+//					curTableBlock = tableElement.getNextBlock();
+//					blockToAdd = true;
+//					curTableBlock.clear();
+//					curTableBlock.y = _parcelList.totalDepth;
+//					curTableBlock.x = _lineSlug.leftMargin;
+//					curTableBlock.initialize(_curParaElement, _lineSlug.width, lineOffset-_parcelList.insideListItemMargin, tableElement.getAbsoluteStart(),1);
+//					totalRowHeight = 0;
+//					//TODO: remove any old existing cells in the _parcelList.currentParcel.controller
+//					
+//					//TODO: add in header rows. Collect them on the next iteration if no real rows fit.
+//					
+//					// not needed?
+//					if(_parcelList.currentParcel == null){
+//						blockToAdd = false;
+//						break;
+//					}
+//				}
+				
+				if(_parcelList.currentParcel == null){
+					blockToAdd = false;
+					break;
+				}
+				
+				// we have a parcel and a row. Let's add the cells.
+				for each(var cell:ITableCellElement in curRow) {
+					cell.y = totalRowHeight;
+					var col:ITableColElement = tableElement.getColumnAt(cell.colIndex);
+					
+					if (col) {
+						cell.x = col.x;
+					}
+					
+					tableElement.addCellToBlock(cell, curTableBlock);
+					//curTableBlock.addCell(cell.container);
+					// add the cells to _parcelList.currentParcel.controller
+					// need to figure out exactly how.
+					
+				}
+				
+				// add the row height
+				// we're assuming normal top to bottom tables -- not Japanese ones...
+				_parcelList.addTotalDepth(rowHeight);
+				
+				curRow = tableElement.getNextRow();
+				totalRowHeight += rowHeight;
+			}
+			
+			if(_parcelList.currentParcel && blockToAdd){
+				curTableBlock.height = totalRowHeight;
+				endTableBlock(curTableBlock);
+//				curTableBlock.setController(_curParcel.controller,_curParcel.columnIndex);
+//				_parcelList.currentParcel.controller.addComposedTableBlock(curTableBlock.container);
+//				BackgroundManager.collectTableBlock(_textFlow,curTableBlock, _parcelList.currentParcel.controller);
+			}
+			//reference ComposeState.composeNextLine() which creates the the ITextLine.
+			// We don't need getLineSlug() because tables can extend beyond the container width
+			// We do need to get the available height and push any cells that don't fit to the next Parcel/container
+			// Repeat until there's no more Parcels.
+			
+			// step 4 draw the backgrounds and borders
+			// handled by the BackgroundManager			
+			
+			return true;
+		}
+		/** Called when we are finished composing a line, and it is committed. Handler for derived classes to override default behavior.  */
+		protected function endTableBlock(block:ITextFlowTableBlock):void
+		{
+			_curLine = block;
+			block.setController(_curParcel.controller, _curParcel.columnIndex);
+			//				_parcelList.currentParcel.controller.addComposedTableBlock(curTableBlock.container);
+			BackgroundUtil.collectTableBlock(_textFlow, block, _parcelList.currentParcel.controller);
+
+			_contentCommittedExtent = Math.max(_contentCommittedExtent, _workingContentExtent);
+			_contentCommittedHeight = Math.max(_contentCommittedHeight, _workingContentHeight);
+			_contentLogicalExtent = Math.max(_contentLogicalExtent, _workingContentLogicalExtent);
+			
+			// if not measuring than contentLogicalExtent needs to match contentCommitedExtent so restarting composition in the middle gets the right extent
+			// don't need contentLogicalExtent to exclude things pushing beyond the right margin as alignment is happening as we go
+			if (!_measuring)
+				_contentLogicalExtent = _contentCommittedExtent;
+			if (_pushInFloats)
+				_pushInFloats.length = 0;	// zero it out for the next line
+			_atColumnStart = false;
+			_linePass = 0;
+			if (!isNaN(_workingParcelLogicalTop))
+				_parcelLogicalTop = _workingParcelLogicalTop;
+		}		
+
+		
+		/**
+		 * Compose the flow into the text container. Starts at the root element,
+		 * and composes elements until either there are no more elements, or the
+		 * text container is full. It will compose only the lines which are
+		 * marked invalid, so that existing lines that are unchanged are not
+		 * recomposed.
+		 */
+		public function composeTextFlow(textFlow:ITextFlow, composeToPosition:int, controllerEndIndex:int):int
+		{
+			_textFlow = textFlow;
+			
+			if(_textFlow && _textFlow.backgroundManager)
+				_textFlow.backgroundManager.clearBlockRecord();
+			
+			_releaseLineCreationData = textFlow.configuration.releaseLineCreationData;// && Configuration.playerEnablesArgoFeatures;
+			
+			_flowComposer = _textFlow.flowComposer;
+			_rootElement = textFlow;
+			_curElementOffset = 0;
+			_curElement = _rootElement.getFirstLeaf();	
+			
+			_curElementStart = 0;		// current position in the text (start of current line)
+			
+			_curParcel = null;
+
+			// must setup _startController and _startComposePosition
+			initializeForComposer(_flowComposer, composeToPosition, -1 /* use default */, controllerEndIndex);
+			
+			resetControllerBounds();
+			
+			// This is where we will start composing from
+			_curElement = _textFlow.findLeaf(_startComposePosition);
+			_curElementStart = _curElement.getAbsoluteStart();
+			_curElementOffset = _startComposePosition - _curElementStart;
+			
+			//clear interactiveObject 
+			var curInteractiveObjects:ObjectMap = _startController.interactiveObjects;
+			var interactiveObjects_lastTime:Array = _startController.oldInteractiveObjects;
+			var curElem:Object;
+			interactiveObjects_lastTime.splice(0);
+			for each(curElem in curInteractiveObjects)
+			{
+				if(curElem && (curElem as IFlowElement).getAbsoluteStart() >= _startComposePosition)
+				{
+					interactiveObjects_lastTime.push(curInteractiveObjects[curElem]);
+					delete curInteractiveObjects[curElem];
+				}
+			}
+			for(var cidx:int = _flowComposer.getControllerIndex(_startController) + 1; cidx <= controllerEndIndex; cidx ++)
+			{
+				curInteractiveObjects = _flowComposer.getControllerAt(cidx).interactiveObjects;
+				for each(curElem in curInteractiveObjects)
+					if(curElem)
+						delete curInteractiveObjects[curElem];
+					
+				// Clear previous composition results
+				_flowComposer.getControllerAt(cidx).clearCompositionResults();
+			}
+			// If we're starting composition from the middle of the container, we have to set up the composition
+			// state so that its the same as if we'd composed from the start.
+			if (_startComposePosition <= _startController.absoluteStart || !advanceToComposeStartPosition())
+			{
+				if (_startComposePosition > _startController.absoluteStart)
+				{
+					// We tried to start from the middle, but it didn't succeed. Reset from the start of the container
+					_startComposePosition = _startController.absoluteStart;
+					_curElement = _textFlow.findLeaf(_startComposePosition);
+					_curElementStart = _curElement.getAbsoluteStart();
+					_curElementOffset = _startComposePosition - _curElementStart;
+				} 
+				if (_startComposePosition == _curElement.getParagraph().getAbsoluteStart())
+					_previousLine = null;
+				else
+				{
+					var startLineIndex:int = _flowComposer.findLineIndexAtPosition(_startComposePosition - 1);
+					var line:ITextFlowLine = _flowComposer.getLineAt(startLineIndex);
+					_previousLine = line.getTextLine(true);
+				}
+				advanceToNextParcel();		// advance to first parcel
+				if (_curParcel)
+					_curParcel.controller.clearFloatsAt(0);
+			}
+			
+			_startController.clearComposedLines(_curElementStart + _curElementOffset);
+			
+			_curParcelStart = _startController.absoluteStart; 		// yuck! this gets set to where we're composing from in parcelHasChanged, set it back to start of parcel
+			
+			composeInternal(_rootElement,0);
+			
+			for (;;)
+			{
+				if (parcelList.atEnd())
+				{
+					parcelHasChanged(null);		// force end of composition accounting for the parcel
+					break;
+				}
+				
+				var nextParcel:Parcel = parcelList.getParcelAt(parcelList.currentParcelIndex + 1);
+		
+				advanceToNextParcel();
+				_correctTextLength = false;
+			}
+			releaseParcelList(_parcelList);
+			_parcelList = null;
+			
+			_savedLineSlug = _lineSlug;
+			
+			return _curElementStart + _curElementOffset;		// Return last composed position
+		}
+		
+		// If we're starting composition from the middle of the container, we have to set up the composition
+		// state so that its the same as if we'd composed from the start.
+		private function advanceToComposeStartPosition():Boolean
+		{
+			var startLineIndex:int = _flowComposer.findLineIndexAtPosition(_startComposePosition - 1);
+			var curLine:ITextFlowLine = _flowComposer.getLineAt(startLineIndex);
+			
+			// cannot start in the middle if we are measuring AND there are floats
+			if (curLine.controller && curLine.controller.numFloats)
+			{
+				CONFIG::debug { assert((_blockProgression == BlockProgression.TB && curLine.controller.measureWidth 
+					|| _blockProgression == BlockProgression.RL && curLine.controller.measureHeight) == _measuring,"Bad _measuring intialization"); }
+				if (_measuring)
+					return false;
+			}
+
+			_curLine = curLine;
+			var previousElement:IFlowLeafElement = (_curElementOffset == 0) ? _curElement.getPreviousLeaf() : _curElement;							
+			// set up previous line leading info, and paragraphSpaceCarried (in case previous line had spaceAfter).
+			_curLineLeadingModel = previousElement.getParagraph().getEffectiveLeadingModel();
+			var curElem:IFlowLeafElement = _textFlow.findLeaf(_curLine.absoluteStart);
+			var curElemStart:int = curElem.getAbsoluteStart();
+			calculateLeadingParameters(curElem, curElemStart, TextLineUtil.findNumberLine(_curLine.getTextLine())); 
+			if (_startComposePosition == _curElement.getParagraph().getAbsoluteStart())
+				_previousLine = null;
+			else
+				_previousLine = _curLine.getTextLine(true);
+			CONFIG::debug { assert(!_previousLine || _previousLine.userData != null, "previousLine has no user data"); }
+			CONFIG::debug { assert(!_previousLine || _previousLine.validity == "valid", "preivous line is invalid"); }
+			_paragraphSpaceCarried = _curLine.spaceAfter;
+			commitLastLineState(_curLine);
+			
+			// advance through the parcels to find the column where composition will start
+			var startParcel:int = _curLine.columnIndex == -1 ? 0 : _curLine.columnIndex;
+			_curParcel = _parcelList.currentParcel;
+			var floatIndex:int = 0;
+			for (var parcelIndex:int = -1; parcelIndex < startParcel; ++parcelIndex) 	// do this at least once!
+			{
+				advanceToNextParcel();
+
+				_curParcelStart = _curParcel.controller.absoluteStart;		// so that bounds will be updated in finishParcel correctly (parcel won't appear empty!)
+
+				// Process knockouts for floats that may be in the previously composed content, so that the parcel list will have
+				// whatever knockouts came before the text we're composing
+				var numFloats:int = _curParcel.controller.numFloats;
+				if (numFloats)
+				{
+					for  (; floatIndex < numFloats; ++floatIndex)
+					{
+						var floatInfo:FloatCompositionData = _curParcel.controller.getFloatAt(floatIndex);
+						if (floatInfo.columnIndex > _curParcel.columnIndex)
+							break;
+						if (floatInfo.floatType != Float.NONE && floatInfo.absolutePosition < _startComposePosition)
+						{
+							var ilg:IInlineGraphicElement = _textFlow.findLeaf(floatInfo.absolutePosition) as IInlineGraphicElement;
+							var logicalHeight:Number = (_blockProgression == BlockProgression.RL) ? ilg.elementWidthWithMarginsAndPadding() : ilg.elementHeightWithMarginsAndPadding();
+							_curParcel.knockOut(floatInfo.knockOutWidth, floatInfo.depth - _lastLineDescent, floatInfo.depth + logicalHeight, floatInfo.floatType == Float.LEFT);
+						}
+					}
+				}
+				_curParcel.controller.clearFloatsAt(_startComposePosition);
+			}
+			_curParcelStart = _curElementStart + _curElementOffset;	
+
+			// Set the depth of the parcel based on the starting line's position	
+			if (_blockProgression == BlockProgression.TB)
+				_parcelList.addTotalDepth(_curLine.y + _curLine.ascent - _curParcel.y);
+			else
+				_parcelList.addTotalDepth(_curParcel.right - _curLine.x);
+			_atColumnStart = false;
+			
+			// generate content bounds summary for the lines from the start of the container, to the startComposePosition
+			var lineIndex:int = _flowComposer.findLineIndexAtPosition(_startController.absoluteStart);
+			CONFIG::debug { assert(startLineIndex + 1 == _flowComposer.findLineIndexAtPosition(_startComposePosition), "startLineIndex not as expected"); }
+			initializeContentBounds(lineIndex, startLineIndex);
+			
+			return true;
+		}
+		
+		// Generate content bounds for the case where we're doing incremental composition (starting compose from middle of container)
+		// If we're aligning horizontally to the measured width, then any lines that are center or right will have to get
+		// realigned when we're done, even if they've already been composed. But, if the line is not aligned, or if it's
+		// been aligned during the previous composition to the absolute compositionWidth, then we don't have to align it again.
+		private function initializeContentBounds(lineIndex:int, lastLineToCheck:int):void
+		{
+			var columnIndex:int = -1;
+			var line:ITextFlowLine;
+			
+			// measuring for the line widths
+			CONFIG::debug { assert((_blockProgression == BlockProgression.TB && _curParcel.controller.measureWidth 
+				|| _blockProgression == BlockProgression.RL && _curParcel.controller.measureHeight) == _measuring,"Bad _measuring intialization"); }
+			
+			_parcelLogicalTop = computeTextFlowLineMinimumLogicalTop(_flowComposer.getLineAt(lineIndex),null);
+			if (_measuring)
+			{
+				for (; lineIndex <= lastLineToCheck; ++lineIndex)
+				{
+					line = _flowComposer.getLineAt(lineIndex);
+					
+					if (line.columnIndex != columnIndex)
+					{
+						columnIndex = line.columnIndex;
+						_contentLogicalExtent = 0;
+						_contentCommittedExtent = 0;
+						_accumulatedMinimumStart = Constants.MAX_LINE_WIDTH;
+					}
+					var lineExtent:Number = line.lineExtent;
+					_contentLogicalExtent = Math.max(_contentLogicalExtent, lineExtent);
+					// If we're aligning horizontally to the measured width, then any lines that are center or right will have to get
+					// realigned when we're done, even if they've already been composed. But, if the line is not aligned, or if it's
+					// been aligned during the previous composition to the absolute compositionWidth, then we don't have to align it again.
+
+					if (line.alignment == TextAlign.LEFT && !line.hasNumberLine)
+						_contentCommittedExtent = Math.max(_contentCommittedExtent, lineExtent);	
+					else
+					{
+						var alignData:AlignData = createAlignData(line);
+						alignData.textLine = line.getTextLine(true);
+						alignData.textAlign = line.alignment;
+						var paraFormat:ITextLayoutFormat = line.paragraph.computedFormat;
+						alignData.rightSideGap = getRightSideGap(line, line.alignment != TextAlign.LEFT);
+						alignData.leftSideGap = getLeftSideGap(line);
+						alignData.textIndent = paraFormat.textIndent;
+						alignData.lineWidth = lineExtent - (alignData.rightSideGap + alignData.leftSideGap);
+						if (!_alignLines)
+							_alignLines = [];
+						_alignLines.push(alignData);
+					}
+				}	
+				CONFIG::debug { assert(_flowComposer.getLineAt(lastLineToCheck).accumulatedLineExtent == _contentLogicalExtent,"Bad _contentLogicalExtent"); }
+			}
+			else
+			{
+				line = _flowComposer.getLineAt(lastLineToCheck);
+				_contentLogicalExtent = _contentCommittedExtent = line.accumulatedLineExtent;
+				_accumulatedMinimumStart = line.accumulatedMinimumStart;
+				// Assume any columns that came before this one are full. We don't want to take the time to iterate all previous lines in previous parcels/columns.
+				if (_parcelList.currentParcelIndex > 0 && _parcelList.currentParcel.columnIndex > 0)
+				{
+					if (_blockProgression == BlockProgression.TB)
+						_controllerBottom =  _curParcel.controller.compositionHeight;
+					else
+						_controllerLeft = 0 - _curParcel.controller.compositionWidth;
+					if (_textFlow.computedFormat.direction == Direction.RTL)		// columns are right to left
+						_controllerRight = _curParcel.controller.compositionWidth;
+				}
+			}
+		}
+		
+		/** @private */
+		public function computeTextFlowLineMinimumLogicalTop(line:ITextFlowLine,textLine:ITextLine):Number
+		{
+			if (line.hasGraphicElement)
+			{
+				var pos:int = line.absoluteStart;
+				var leafElement:IFlowLeafElement = _textFlow.findLeaf(pos);
+				var adjustedAscent:Number = line.getLineTypographicAscent(leafElement, leafElement.getAbsoluteStart(),textLine);
+				var parcelTop:Number = (_blockProgression == BlockProgression.RL) ? line.x + adjustedAscent : line.y + line.ascent - adjustedAscent;
+				var controller:IContainerController = line.controller;
+				var lineEnd:int = pos + line.textLength;
+				if (controller.numFloats > 0)		// adjust line upwards if it has a float that came before (e.g., landed on its own line before, and there was no room for text beside)
+				{
+					while (pos < lineEnd)
+					{
+						var floatInfo:FloatCompositionData = controller.getFloatAtPosition(pos);
+						if (floatInfo)
+						{
+							parcelTop = Math.min(parcelTop, floatInfo.depth);
+							pos = floatInfo.absolutePosition + 1;
+						}
+						else
+							break;
+					}
+				} 
+				return parcelTop;
+			}
+			// don't have one
+			return NaN;
+		}
+		
+		private function resetControllerBounds():void
+		{
+			_controllerLeft = Constants.MAX_LINE_WIDTH;
+			_controllerTop = Constants.MAX_LINE_WIDTH;
+			_controllerRight = -Constants.MAX_LINE_WIDTH;
+			_controllerBottom = -Constants.MAX_LINE_WIDTH;
+		}
+		
+		/** Release line creation data during this compose */
+		protected function get releaseLineCreationData():Boolean
+		{ return _releaseLineCreationData; }
+		
+		// Create new lines through composition. lines, wrap, etc.
+		protected function composeInternal(composeRoot:IFlowGroupElement,absStart:int):void
+		{
+			composeBlockElement(composeRoot,absStart);
+		}
+		
+		/** @private
+		 * Compose a single paragraph. If no lines in the paragraph are going to be visible, 
+		 * then the TextLines are released for later reuse.
+		 */
+		protected function composeParagraphElement(elem:IParagraphElement,absStart:int):Boolean
+		{
+			_curParaElement  = elem;
+			_curParaStart    = absStart;
+			_curLineStart    = absStart;
+			_curParaFormat = elem.computedFormat;
+			
+			CONFIG::debug { assert(_curParaStart == elem.getAbsoluteStart(),"composeParagraphElement: bad start"); }
+
+			// Initialize the flag so that if we are composing only part of the paragraph, we will consider it in view.
+			// We could examine the earlier part of the paragraph to see if its visible, but for now just assume it
+			// might be.
+			_paragraphContainsVisibleLines = (_curElementStart + _curElementOffset != _curParaStart) ;
+			if(_paragraphContainsVisibleLines)
+			{
+				//we're composing in midddle of a paragraph. Update the line start to match up with our current location
+				_curLineStart = _curElementStart + _curElementOffset;
+			}
+			var success:Boolean = composeParagraphElementIntoLines();
+			
+			var okToRelease:Boolean = true;
+
+			// If no lines in the paragraph are visible, release the paragraph's ITextBlock and its lines so they can be reused later
+			if (!_paragraphContainsVisibleLines)
+			{
+				// Lines that are now composed that would not be visible on update, might still be in the display list from
+				// a previous update. Don't release in that case.
+				var textBlocks:Vector.<ITextBlock> = elem.getTextBlocks();
+				var textLine:ITextLine;
+				for each(var textBlock:ITextBlock in textBlocks)
+				{
+					for (textLine = textBlock.lastLine; textLine && okToRelease; textLine = textLine.previousLine) 
+					{
+						if (textLine.parent)
+							okToRelease = false;
+					}
+					if (okToRelease)	// no textlines were in view, go ahead and release them all, starting at the end and working to the start
+					{
+						for (textLine = textBlock.lastLine; textLine; )
+						{
+							textBlock.releaseLines(textLine, textLine);
+							textLine.userData = null;
+							TextLineRecycler.addLineForReuse(textLine);
+							if (_textFlow.backgroundManager)
+								_textFlow.backgroundManager.removeLineFromCache(textLine);
+							textLine = textBlock.lastLine;
+						}
+						elem.releaseTextBlock(textBlock);
+					}
+				}
+			}
+
+			// If we didn't release the ITextBlock, flush it to save memory (at the cost of performance during editing).
+			// This saves a lot of memory in Argo, is a nop on older players. only newer players implement flush	
+			if (releaseLineCreationData && !okToRelease)
+				elem.releaseLineCreationData();
+			
+			//draw background and border for paragraph if any - start
+			BackgroundUtil.collectBlock(_textFlow, elem);
+			//end
+			
+			return success;
+		}
+		
+		protected function getFirstIndentCharPos(paragraph:IParagraphElement):int
+		{
+			var pos:int = 0;
+			var leaf:IFlowLeafElement = paragraph.getFirstLeaf();
+			while (leaf && (leaf.className == "InlineGraphicElement") && (IInlineGraphicElement(leaf).effectiveFloat != Float.NONE))
+			{
+				pos += leaf.textLength;
+				leaf = leaf.getNextLeaf();
+			}
+			return pos;
+		}
+		
+		/** Compose the lines in the paragraph. 
+		 * Updates the _paragraphContainsVisibleLines flag if the paragraph contains at least one visible line.
+		 * Returns true if composition should continue, false if all space is used and composition should stop. 
+		 */
+		protected function composeParagraphElementIntoLines():Boolean
+		{
+			// make sure TextBlocks are normalized
+			if(_curParaElement.getTextBlock().content == null)
+				_curParaElement.createContentElement();
+			
+			var result:Boolean = true;
+			var textLine:ITextLine;
+			
+			
+			var leftMargin:Number;
+			var rightMargin:Number;
+			
+			var firstLineIndent:Number = 0;
+			if (_curParaFormat.direction == Direction.LTR)
+			{
+				leftMargin = _curParaFormat.paragraphStartIndent;
+				rightMargin = _curParaFormat.paragraphEndIndent;
+			}
+			else
+			{
+				leftMargin = _curParaFormat.paragraphEndIndent;
+				rightMargin = _curParaFormat.paragraphStartIndent;
+			}	
+			_parcelList.pushLeftMargin(leftMargin);
+			_parcelList.pushRightMargin(rightMargin);
+			
+			var firstIndentCharPos:int = _curParaStart;
+			
+			if (preProcessILGs(_curElementStart - _curParaStart))
+				firstIndentCharPos = getFirstIndentCharPos(_curParaElement) + _curParaStart;
+
+			// loop creating lines_curParaStart
+			while (result)
+			{
+				if (_parcelList.atEnd())
+				{
+					result = false;
+					break;
+				}
+				
+				// Allow derived classes to do processing here
+				startLine();
+
+				if (!_forceILGs)		// floats will compose as inline graphics
+					processFloatsAtLineStart();
+				
+				_textIndent = (_curElementStart + _curElementOffset <= firstIndentCharPos) ? _curParaFormat.textIndent : 0;
+				
+				if (_parcelList.atEnd())
+				{
+					result = false;
+					break;
+				}
+
+				// do table here?
+				//_curElementStart == _curParaStart
+				//			var startCompose:int = _curElementStart + _curElementOffset - _curParaStart;
+				var curChild:IFlowElement = _curParaElement.getChildAt(_curParaElement.findChildIndexAtPosition(_curElementStart - _curParaStart));
+				if(curChild.className == "TableElement")
+				{
+					
+					if(!composeTableElement(curChild as ITableElement, _curElementStart))
+						return false;
+					
+					_curElementOffset = 0;
+					_curElementStart  += _curElement.textLength;
+					_curElement = _curElement.getNextLeaf();
+					_curLineStart++;
+					_previousLine = null;
+
+					// if the next span is the terminator bail out...
+					if(_curElement.className == "SpanElement" && ISpanElement(_curElement).hasParagraphTerminator && _curElement.textLength == 1)
+					{
+						_curElementOffset = 0;
+						_curElementStart  += _curElement.textLength;
+						_curElement = _curElement.getNextLeaf();
+						return true;
+					}
+					
+					//break;
+					//return true;
+				}
+				// Get the next line
+				textLine = composeNextLine();
+				if (textLine ==  null)
+				{
+					result = false;
+					break;
+				}
+				
+				CONFIG::debug { assert(_curLine != null, "curLine is null!"); }
+				
+				// Adjust the coordinates of the line for center/right.  The line is always left aligned.  ITextBlock handles justified cases
+				// If we're on the last line of a justified paragraph, use the textAlignLast value 
+				var textAlignment:String = _curParaFormat.textAlign;
+				if (textAlignment == TextAlign.JUSTIFY)
+				{
+					var location:int = _curLine.location;
+					if (location == TextFlowLineLocation.LAST || location == TextFlowLineLocation.ONLY)
+						textAlignment = _curParaFormat.textAlignLast;
+				}
+				switch(textAlignment)
+				{
+					case TextAlign.START:
+						textAlignment = (_curParaFormat.direction == Direction.LTR) ? TextAlign.LEFT : TextAlign.RIGHT;
+						break;
+					case TextAlign.END:
+						textAlignment = (_curParaFormat.direction == Direction.LTR) ? TextAlign.RIGHT : TextAlign.LEFT;
+						break; 
+				}
+				
+				// need alignData whenever there is a numberLine - alignData also computes contentBounds which need to take numberlines into account
+				var numberLine:ITextLine = TextLineUtil.findNumberLine(textLine);
+				var needAlignData:Boolean = (numberLine && TextLineUtil.getNumberLineListStylePosition(numberLine) == ListStylePosition.OUTSIDE) || textAlignment == TextAlign.CENTER || textAlignment == TextAlign.RIGHT;
+				
+				// in argo lines that have tabs must be either START or JUSTIFY
+				if (textLine.hasTabs)
+				{
+					if (_curParaFormat.direction == Direction.LTR)
+					{
+						if (!numberLine || TextLineUtil.getNumberLineListStylePosition(numberLine) == ListStylePosition.INSIDE)
+							needAlignData = false;	// don't align it - let it be left align
+						textAlignment = TextAlign.LEFT;
+					}
+					else
+					{
+						needAlignData = true;
+						textAlignment = TextAlign.RIGHT;
+					}
+				}
+
+				
+				var alignData:AlignData;
+				if (needAlignData)
+				{
+					alignData = createAlignData(_curLine);
+					alignData.textLine = textLine;
+					alignData.textAlign = textAlignment;
+				}
+
+				/* {
+				for (var idx:int = 0; idx < curLine.textLine.atomCount; idx++)
+				{
+				trace(idx.toString()+": beginIndex: " + curLine.textLine.getAtomTextBlockBeginIndex(idx)+ " bidiLevel: "+ curLine.textLine.getAtomBidiLevel(idx) + " bounds: " + curLine.textLine.getAtomBounds(idx));
+				}
+				} */
+				
+				// Space before does not apply to the first line, unless LeadingModel.BOX is used
+				// Space carried never applies to the first line
+				var spaceBefore:Number  = _atColumnStart && (_curParaFormat.leadingModel != LeadingModel.BOX) ? 0 : _curLine.spaceBefore;
+				var spaceCarried:Number = _atColumnStart ? 0 : _paragraphSpaceCarried;
+				if (spaceBefore != 0 || spaceCarried != 0)
+					_parcelList.addTotalDepth(Math.max(spaceBefore, spaceCarried));
+				
+				_paragraphSpaceCarried = 0;
+				if (_verticalSpaceCarried != 0)
+					_verticalSpaceCarried = 0;
+				_parcelList.addTotalDepth(_curLine.height);
+
+				alignData = calculateLineAlignmentAndBounds(textLine, numberLine, alignData);
+				
+				if (alignData)
+				{
+					if (!_alignLines)
+						_alignLines = [];
+					_alignLines.push(alignData);
+					_curLine.alignment = textAlignment;
+				}
+								
+				// textLength is the first character in the next line
+				CONFIG::debug { assert(_curParcel.controller.textLength >= 0, "frame has negative composition"); }
+				
+				if (firstLineIndent != 0)
+				{
+					if (_curParaFormat.direction == Direction.LTR)
+						_parcelList.popLeftMargin(firstLineIndent);
+					else
+						_parcelList.popRightMargin(firstLineIndent);
+					firstLineIndent = 0;
+				}
+
+				// The line didn't fit in the parcel when all the floats were factored in.
+				// If we're hitting this case, we are now in the next parcel, try laying out 
+				// the line there.
+				if (!processFloatsAtLineEnd(textLine) || !_curLine)	
+				{
+					resetLine(textLine);
+					continue;
+				}
+				
+				endLine(textLine);
+
+				_lastGoodStart = -1;		// everything committed
+				
+				// If the line is going to be visible, add it to the list of visible lines we will give to the container
+				if (isLineVisible(textLine))
+				{
+					_curParcel.controller.addComposedLine(textLine);
+					_paragraphContainsVisibleLines = true;
+				}
+				
+				if (_parcelList.atEnd())
+				{
+					result = false;
+					break;
+				}
+				
+				_previousLine = textLine;
+				
+				// advance to the next element, using the rootElement of the container as a limitNode
+				// to prevent going past the content bound to this container
+				_curElementOffset = _curLine.absoluteStart + _curLine.textLength - _curElementStart;
+				if (_curElementOffset >= _curElement.textLength)
+				{
+					// We may have composed ahead over several spans; skip until we match up
+					// Loop until we use catch up to where the line we just composed ended (pos).
+					// Stop if we run out of elements. Skip empty inline elements, and skip floats
+					// that came at the start of the line before any text -- they've already been 
+					// processed.
+					do{
+						if (_curParaElement.hasInteractiveChildren())
+						{
+							// Find link & interactive mirror element =
+							var curElement:IFlowElement = _curElement;
+							while (curElement && (curElement != _curParaElement))
+							{
+								// It's a link element?
+								if (curElement is ILinkElement)
+								{
+									_curInteractiveObjects[curElement] = curElement;
+								}
+								else if (curElement.hasActiveEventMirror())
+								{
+									_curInteractiveObjects[curElement] = curElement;
+								}
+								curElement = curElement.parent ;
+							}
+						}
+
+						_curElementOffset -= _curElement.textLength;
+						_curElementStart  += _curElement.textLength;
+						_curElement = _curElement.getNextLeaf();
+						if (_curElementStart == _curParaStart+_curParaElement.textLength)
+							break;
+
+						CONFIG::debug { assert(_curElement && _curElement.getParagraph() == _curParaElement,"composeParagraphElement: bad textLength in ITextLine"); }
+					} while (_curElementOffset >= _curElement.textLength || _curElement.textLength == 0 );
+				}
+				
+				_paragraphSpaceCarried = _curLine.spaceAfter;
+				
+				// We finished composing the paragraph
+				if (_curElementStart == _curParaStart + _curParaElement.textLength)
+					break;
+			}
+
+			_parcelList.popLeftMargin(leftMargin);
+			_parcelList.popRightMargin(rightMargin);
+			if (firstLineIndent != 0)		// first line indent pop
+			{
+				if (_curParaFormat.direction == Direction.LTR)
+					_parcelList.popLeftMargin(firstLineIndent);
+				else
+					_parcelList.popRightMargin(firstLineIndent);
+				firstLineIndent = 0;
+			}
+
+			_previousLine = null;
+			return result;
+		}
+		
+		/** @private */
+		protected function createTextLine(
+			targetWidth:Number,	// target width we're composing into
+			allowEmergencyBreaks:Boolean	// true to allow words to break in the middle of narrow columns, false to force overset
+		):ITextLine
+		{
+			var lineOffset:Number = (_curParaFormat.direction == Direction.LTR) ? _lineSlug.leftMargin : _lineSlug.rightMargin;     		
+			
+			var textLine:ITextLine = null;
+			textLine = TextLineRecycler.getLineForReuse();
+			var textBlock:ITextBlock = _curParaElement.getTextBlockAtPosition(_curElement.getElementRelativeStart(_curParaElement));
+			if (textLine)
+			{
+				CONFIG::debug { assert(_textFlow.backgroundManager == null || _textFlow.backgroundManager.getEntry(textLine) === undefined,"createTextLine - Bad ITextLine in recycler cache"); }
+				textLine = swfContext.callInContext(textBlock["recreateTextLine"],textBlock,[textLine, _previousLine, targetWidth, lineOffset, true]);
+			}
+			else
+			{
+				textLine = swfContext.callInContext(textBlock.createTextLine,textBlock,[_previousLine, targetWidth, lineOffset, true]);
+			}
+			CONFIG::debug { assert(!_previousLine || !textLine || _previousLine.textBlockBeginIndex + _previousLine.rawTextLength == textLine.textBlockBeginIndex, "FTE made non-contiguous ITextLine"); }
+			if (!allowEmergencyBreaks && textBlock.textLineCreationResult == TextLineCreationResult.EMERGENCY)
+				textLine = null;
+
+			// Unable to fit a new line
+			if (textLine == null)
+				return null;
+
+			CONFIG::debug { assert(_curParaStart == _curParaElement.getAbsoluteStart(),"bad _curParaStart"); }
+
+			_curLine.initialize(_curParaElement, targetWidth, lineOffset-_parcelList.insideListItemMargin, _curLineStart, textLine.rawTextLength, textLine);
+			CONFIG::debug { assert(_curLine.targetWidth == targetWidth,"Bad targetWidth"); }
+			return textLine;
+		}
+		
+		/** Called when we are about to compose a line. Handler for derived classes to override default behavior. */
+		protected function startLine():void
+		{
+			_workingContentExtent = 0;
+			_workingContentHeight = 0;
+			_workingContentLogicalExtent = 0;
+			_workingParcelIndex = _parcelList.currentParcelIndex;
+			_workingTotalDepth = parcelList.totalDepth;
+			_workingParcelLogicalTop = NaN;
+		}
+		
+		protected function isLineVisible(textLine:ITextLine):Boolean
+		{ 
+			// isLineVisible completes initializing textLine - so must call it even if we are _measuring
+			return _curParcel.controller.testLineVisible(_blockProgression, _controllerVisibleBoundsXTW, _controllerVisibleBoundsYTW, _controllerVisibleBoundsWidthTW, _controllerVisibleBoundsHeightTW, _curLine, textLine) is ITextLine; 
+		}
+		
+		/** Called when we are finished composing a line, and it is committed. Handler for derived classes to override default behavior.  */
+		protected function endLine(textLine:ITextLine):void	// No PMD
+		{
+			_curLineStart += _curLine.textLength;
+			_contentCommittedExtent = Math.max(_contentCommittedExtent, _workingContentExtent);
+			_contentCommittedHeight = Math.max(_contentCommittedHeight, _workingContentHeight);
+			_contentLogicalExtent = Math.max(_contentLogicalExtent, _workingContentLogicalExtent);
+
+			// if not measuring than contentLogicalExtent needs to match contentCommitedExtent so restarting composition in the middle gets the right extent
+			// don't need contentLogicalExtent to exclude things pushing beyond the right margin as alignment is happening as we go
+			if (!_measuring)
+				_contentLogicalExtent = _contentCommittedExtent;
+			if (_pushInFloats)
+				_pushInFloats.length = 0;	// zero it out for the next line
+			_atColumnStart = false;
+			_linePass = 0;
+			if (!isNaN(_workingParcelLogicalTop))
+				_parcelLogicalTop = _workingParcelLogicalTop;
+		}		
+		
+		protected function resetLine(textLine:ITextLine):void
+		{
+			// if there is a BG manager remove the textLine since it isn't used
+			if (_textFlow.backgroundManager)
+				_textFlow.backgroundManager.removeLineFromCache(textLine);
+			if (_workingParcelIndex != parcelList.currentParcelIndex)		// if we've moved to a new parcel, start over with the line
+			{
+				_linePass = 0;
+				if (_pushInFloats)
+					_pushInFloats.length = 0;
+			}	
+			else
+				++_linePass;
+			parcelList.addTotalDepth(_workingTotalDepth - _parcelList.totalDepth);
+			_workingTotalDepth = parcelList.totalDepth;
+		}
+		
+		protected function preProcessILGs(startPos:int):Boolean
+		{
+			if (!_curParcel)
+				return false;
+			
+			var foundFloat:Boolean = false;
+			
+			// Before composing, run through the inline graphics and make sure the content elements are set up correctly
+			// We don't support floats when we aren't wrapping the text
+			var verticalText:Boolean = (_blockProgression == BlockProgression.RL);
+			_forceILGs = (_parcelList.explicitLineBreaks || 
+				(verticalText && _curParcel.controller.measureHeight) || (!verticalText && _curParcel.controller.measureWidth));
+
+			for (var leaf:IFlowLeafElement = _curParaElement.findLeaf(startPos); leaf; leaf = leaf.getNextLeaf(_curParaElement))
+			{
+				if (leaf.className == "InlineGraphicElement")
+				{
+					var inlineGraphic:IInlineGraphicElement = leaf as IInlineGraphicElement;
+					inlineGraphic.setEffectiveFloat(_forceILGs ? Float.NONE : inlineGraphic.computedFloat);
+					foundFloat = true;
+				}
+			}
+			return foundFloat;
+		}
+		
+		// Called from composeParagraphElementIntoLines when we are starting to compose a line. Has hooks to handle floats.
+		protected function processFloatsAtLineStart():void
+		{
+			if (_forceILGs)
+				return;
+
+			// There are two possible passes through this code for each line. On pass one, all floats at the
+			// start of the line are processed, so they appear at the same level with the line (text in the 
+			// line will wrap the float). On this pass, processFloatsAtLineEnd may find floats that are in the
+			// middle of the line and "hoist" them by adding them to _pushInFloats. This will trigger a second
+			// pass through the line, that will call back into this function. On the second pass, the floats
+			// at the start have already been added to the parcel's knockout area, but we have to regenerate
+			// their impact to the content bounds. Also, we have to compose the floats that were hoisted.
+						
+			// On the second pass, all floats that are hoisted will be in the array
+			if (_pushInFloats && _pushInFloats.length > 0)
+			{
+				for (var i:int = 0; i < _pushInFloats.length; ++i)
+				{
+					var pos:int = _pushInFloats[i];
+					var leaf:IFlowLeafElement = _textFlow.findLeaf(pos);
+					CONFIG::debug { assert(leaf.className == "InlineGraphicElement", "pushed an element that is not a float"); }
+					if (!composeFloat(leaf as IInlineGraphicElement, false))	// If the float does not fit, cancel it and any following hoist requests
+						_pushInFloats.length = i;
+				}
+			} 
+		}
+		
+		// Return true if we tried to hoise some floats and need to retry the line
+		protected function processFloatsAtLineEnd(textLine:ITextLine):Boolean
+		{
+			// If there are no anchor points in the line, nothing to do
+			if (!textLine.hasGraphicElement && _linePass <= 0)
+				return true;
+			
+			// If the anchor point was pushed out, try again with one less float hoisted.
+			if (_pushInFloats && _pushInFloats.length > 0)
+			{
+				var floatPosition:int = _pushInFloats[_pushInFloats.length - 1];
+				if (_curLine.absoluteStart + _curLine.textLength <= floatPosition)
+				{
+					// Back out all the push in floats, remove the last push in float, and try again
+					for (var floatIndex:int = _pushInFloats.length - 1; floatIndex >= 0; --floatIndex)
+					{
+						floatPosition = _pushInFloats[floatIndex];
+						var elem:IInlineGraphicElement = _textFlow.findLeaf(floatPosition) as IInlineGraphicElement;
+						var logicalFloatHeight:Number = (_blockProgression == BlockProgression.RL) ?
+							elem.elementWidth + elem.getEffectivePaddingLeft() + elem.getEffectivePaddingRight() :
+							elem.elementHeightWithMarginsAndPadding();
+						var floatInfo:FloatCompositionData = _curLine.controller.getFloatAtPosition(floatPosition);
+						if (floatInfo && floatInfo.absolutePosition == floatPosition)		// check: float might have been skipped if it's not loaded yet, in which case nothing to back out
+						{
+							var adjustTop:Number = isNaN(_lastLineDescent) ? 0 : _lastLineDescent;
+							_curParcel.removeKnockOut(floatInfo.knockOutWidth, floatInfo.depth - adjustTop, floatInfo.depth + logicalFloatHeight, floatInfo.floatType == Float.LEFT);
+						}
+					}
+					_curLine.controller.clearFloatsAt(_pushInFloats[0]);
+					--_pushInFloats.length;
+					return false;			// we've changed the floats, need to reset the line
+				}
+			}			
+			
+			var elementStart:int = _curElementStart;
+			var element:IFlowLeafElement = _curElement;
+			var endPos:int = _curLine.absoluteStart + _curLine.textLength;
+			var skipCount:int = 0;
+						
+			// Advance through the elements in the line, composing any InlineGraphicElements we find
+			var hasInlines:Boolean = false;
+
+			while (elementStart < endPos)
+			{
+				if (element.className == "InlineGraphicElement")
+				{
+					var inlineGraphic:IInlineGraphicElement = IInlineGraphicElement(element);
+					if (inlineGraphic.computedFloat == Float.NONE || _forceILGs)
+						hasInlines = true;
+					else 
+					{
+						if (_linePass == 0)
+						{		// Hoist it. We will retry the line, composing this float at the start next time.
+							if (!_pushInFloats)
+								_pushInFloats = [];
+							_pushInFloats.push(elementStart);
+						}
+						else if (_pushInFloats.indexOf(elementStart) >= 0)	// we hoisted, so skip it
+							++skipCount;
+						else 	// not hoisted
+						{
+							if (!composeFloat(inlineGraphic, true))	// Add it in below the line
+							{
+								advanceToNextParcel();
+								return false;		// we need to start the line again in the next container; stop composing now 
+							}
+						}						
+					}
+				}
+				elementStart += element.textLength;
+				element = element.getNextLeaf();
+			}
+	
+			var completed:Boolean = (skipCount >= (_pushInFloats ? _pushInFloats.length : 0));	// true if no floats need to be hoisted
+			
+			// process inline graphics if we have some, and we're on the last pass
+			if (completed && hasInlines)
+				processInlinesAtLineEnd(textLine);
+
+			return completed;
+		}
+		
+		// Process inline graphics for our current line.
+		protected function processInlinesAtLineEnd(textLine:ITextLine):void
+		{
+			// process inline graphics if we have some, and we're on the last pass
+			var elementStart:int = _curElementStart;
+			var element:IFlowLeafElement = _curElement;
+			var endPos:int = _curLine.absoluteStart + _curLine.textLength;
+			while (elementStart < endPos)
+			{
+				if (element.className == "InlineGraphicElement")
+				{
+					var inlineGraphic:IInlineGraphicElement = element as IInlineGraphicElement;
+					if (inlineGraphic.computedFloat == Float.NONE || _forceILGs)
+						composeInlineGraphicElement(inlineGraphic, textLine);
+				}
+				elementStart += element.textLength;
+				element = element.getNextLeaf();
+			}
+		}
+		/**
+		 *  @flexjsignorecoercion org.apache.flex.core.IParentIUIBase
+		 */
+		protected function composeInlineGraphicElement(inlineGraphic:IInlineGraphicElement, textLine:ITextLine):Boolean
+		{
+			// Add the ILG to list of objects the container will update
+			
+			var marginAndPaddingX:Number = _blockProgression == BlockProgression.RL ? -inlineGraphic.getEffectivePaddingRight() : inlineGraphic.getEffectivePaddingLeft();
+			var marginAndPaddingY:Number = inlineGraphic.getEffectivePaddingTop();
+
+			// Get alpha and matrix values from FTE's inline placeholder
+			var fteInline:IParentIUIBase = inlineGraphic.placeholderGraphic.parent as IParentIUIBase;
+			
+			var matrix:Matrix;
+//TODO get the transform
+// matrix = fteInline ? fteInline.transform.matrix : null
+			_curParcel.controller.addFloatAt(_curParaStart + inlineGraphic.getElementRelativeStart(_curParaElement), inlineGraphic.graphic, Float.NONE, 
+				marginAndPaddingX, marginAndPaddingY, fteInline ? fteInline.alpha : 1, matrix, _parcelList.totalDepth, 0, 
+				_curParcel.columnIndex, textLine);
+			
+			// Check if interactive
+			if (_curParaElement.hasInteractiveChildren())
+			{
+				// Find link & interactive mirror element =
+				var curElement:IFlowElement = inlineGraphic;
+				while (curElement && (curElement != _curParaElement))
+				{
+					// It's a link element?
+					if (curElement is ILinkElement)
+					{
+						_curInteractiveObjects[curElement] = curElement;					
+					}
+					else if (curElement.hasActiveEventMirror())
+					{
+						_curInteractiveObjects[curElement] = curElement;
+					}
+					curElement = curElement.parent ;
+				}
+			}
+			return true;
+		}
+
+		/*
+		* Compose a floating graphic. Returns false if it doesn't fit in the parcel.
+		*
+		* @param elem	float we'e composing
+		*/
+		protected function composeFloat(elem:IInlineGraphicElement, afterLine:Boolean):Boolean
+		{
+			if (elem.elementHeight == 0 || elem.elementWidth == 0)		// can't compose yet -- graphic isn't ready
+				return true;
+					
+			if (_lastGoodStart == -1)
+				_lastGoodStart = _curElementStart + _curElementOffset;
+			
+			var verticalText:Boolean = (_blockProgression == BlockProgression.RL);
+			
+			// HACK!!!
+			//	if the baselineZero is set to ideographicTop, then the descent is the point size (measured from ideographic top)
+			//	but in this case we've already factored that into the line height, so we're adding twice. Very confusing.
+			var effectiveLastLineDescent:Number = 0;
+			if ((afterLine ||  !_atColumnStart) && !isNaN(_lastLineDescent))
+				effectiveLastLineDescent = _lastLineDescent;
+			
+			// If we're composing at the start of the paragraph, we may have spaceBefore (or spaceAfter from the previous paragraph)
+			// that we need to take into account when placing the float.
+			var spaceBefore:Number = 0;
+			if (_curLine && _curParaElement != _curLine.paragraph && !_atColumnStart)
+				spaceBefore = Math.max(_curParaElement.computedFormat.paragraphSpaceBefore, _paragraphSpaceCarried);
+			var totalDepth:Number = _parcelList.totalDepth + spaceBefore + effectiveLastLineDescent;
+			
+			if (!_floatSlug)
+				_floatSlug = new Slug();
+			
+			// See if it fits. If so, update the state to show the change. If not, remove the item.
+			var logicalFloatWidth:Number;
+			var logicalFloatHeight:Number;
+			if (verticalText)
+			{
+				logicalFloatWidth = elem.elementHeight + elem.getEffectivePaddingTop() + elem.getEffectivePaddingBottom();
+				logicalFloatHeight = elem.elementWidth + elem.getEffectivePaddingLeft() + elem.getEffectivePaddingRight();
+			}
+			else
+			{
+				logicalFloatWidth = elem.elementWidthWithMarginsAndPadding();
+				logicalFloatHeight = elem.elementHeightWithMarginsAndPadding();
+			}			
+			
+			var floatPosition:int = elem.getAbsoluteStart();
+			var floatFits:Boolean = _parcelList.fitFloat(_floatSlug, totalDepth, logicalFloatWidth, logicalFloatHeight);
+			
+			// If the float is too wide but it fits in height, AND there is no text or other floats before it, allow it to overlap
+			// the column so it doesn't go overset.
+			if (!floatFits && (_curParcel.fitAny || _curParcel.fitsInHeight(totalDepth, int(logicalFloatHeight))) && (!_curLine || _curLine.absoluteStart == floatPosition || afterLine))
+				floatFits = true;
+			
+			if (floatFits)
+			{
+				var floatType:String = elem.computedFloat;
+				if (floatType == Float.START)
+					floatType = (_curParaFormat.direction == Direction.LTR) ? Float.LEFT : Float.RIGHT;
+				else if (floatType == Float.END)
+					floatType = (_curParaFormat.direction == Direction.LTR) ? Float.RIGHT : Float.LEFT;
+				
+				var floatRect:Rectangle = calculateFloatBounds(elem, verticalText, floatType);
+				
+				// Take it into account for content bounds
+				if (verticalText)
+				{
+					// mjzhang : Fix for bug#2898924 TLF reports incorrect content height after composition when floats are used with padding
+					_workingContentExtent = Math.max(_workingContentExtent, floatRect.bottom + elem.getEffectivePaddingLeft() + elem.getEffectivePaddingRight());
+					_workingContentHeight = Math.max(_workingContentHeight, _floatSlug.depth + floatRect.width + elem.getEffectivePaddingTop() + elem.getEffectivePaddingBottom());
+					_workingContentLogicalExtent = Math.max(_workingContentLogicalExtent, floatRect.bottom);
+					_accumulatedMinimumStart = Math.min(_accumulatedMinimumStart, floatRect.y);
+				}
+				else
+				{
+					// mjzhang : Fix for bug#2898924 TLF reports incorrect content height after composition when floats are used with padding
+					_workingContentExtent = Math.max(_workingContentExtent, floatRect.right + elem.getEffectivePaddingLeft() + elem.getEffectivePaddingRight());
+					_workingContentHeight = Math.max(_workingContentHeight, _floatSlug.depth + floatRect.height + elem.getEffectivePaddingTop() + elem.getEffectivePaddingBottom());
+					_workingContentLogicalExtent = Math.max(_workingContentLogicalExtent, floatRect.right);
+					_accumulatedMinimumStart = Math.min(_accumulatedMinimumStart, floatRect.x);
+				}
+				if (floatPosition == _curParcelStart)
+					 _workingParcelLogicalTop = _floatSlug.depth;
+				
+				// floatRect is returned at new (x, y) location, sized to fit the column.
+				var knockOutWidth:Number = ((floatType == Float.LEFT) ? _floatSlug.leftMargin : _floatSlug.rightMargin) + logicalFloatWidth;
+				
+				var adjustTop:Number = isNaN(_lastLineDescent) ? 0 : _lastLineDescent;
+				_curParcel.knockOut(knockOutWidth, _floatSlug.depth - adjustTop, _floatSlug.depth + logicalFloatHeight, floatType == Float.LEFT);
+				
+				// Add info about the float so we can regenerate the knock out area if necessary for an incremental compose, as well as take care of update, etc.
+				_curParcel.controller.addFloatAt(floatPosition, elem.graphic, floatType, floatRect.x, floatRect.y, elem.computedFormat.textAlpha, null, 
+					_floatSlug.depth, knockOutWidth, _curParcel.columnIndex, _curParcel.controller.container);
+				
+				CONFIG::debug { _curParcel.controller.getFloatAt(_curParcel.controller.numFloats - 1).displacedVertically = totalDepth != _floatSlug.depth; } 
+			}
+			
+		return floatFits;
+		}
+		
+		private function calculateFloatBounds(elem:IInlineGraphicElement, verticalText:Boolean, floatType:String):Rectangle
+		{
+			// We need to place it on the left or right side, sized to fit the graphic
+			var floatRect:Rectangle = new Rectangle();
+			if (verticalText)
+			{
+				floatRect.x = ((_curParcel.right - _floatSlug.depth) - elem.elementWidth) - elem.getEffectivePaddingRight();
+				floatRect.y = (floatType == Float.LEFT) ? 
+					(_curParcel.y + _floatSlug.leftMargin + elem.getEffectivePaddingTop()) : 
+					(_curParcel.bottom - _floatSlug.rightMargin - elem.getEffectivePaddingBottom() - elem.elementHeight);
+				floatRect.width = elem.elementWidth;
+				floatRect.height = elem.elementHeight;
+			}
+			else
+			{
+				floatRect.x = (floatType == Float.LEFT) ? 
+					_curParcel.x + _floatSlug.leftMargin + elem.getEffectivePaddingLeft() : 
+					_curParcel.right - _floatSlug.rightMargin - elem.getEffectivePaddingRight() - elem.elementWidth;
+				floatRect.y = _curParcel.y + _floatSlug.depth + elem.getEffectivePaddingTop();
+				floatRect.width = elem.elementWidth;
+				floatRect.height = elem.elementHeight;
+			}
+			return floatRect;
+		}
+		
+		private function calculateLineWidthExplicit(textLine:ITextLine):Number
+			// Returns the content bounds width of a line set with explicit lineBreaks
+		{
+			var isRTL:Boolean = _curParaElement.computedFormat.direction == Direction.RTL;
+			var lastAtom:int = textLine.atomCount - 1;
+			// If we're at the end of the paragraph, don't count the terminator
+			var endOfParagraph:Boolean = _curLine.absoluteStart + _curLine.textLength == _curParaStart + _curParaElement.textLength;
+			if (endOfParagraph && !isRTL)
+				--lastAtom;	// can go negative if just the terminator.  in that case use left/top of atom zero
+			var bounds:Rectangle = textLine.getAtomBounds(lastAtom >= 0 ? lastAtom : 0);	// get rightmost atom bounds
+			var lineWidth:Number = (_blockProgression == BlockProgression.TB) 
+				? (lastAtom >= 0 ? bounds.right : bounds.left)
+				: (lastAtom >= 0 ? bounds.bottom : bounds.top);
+			if (isRTL)	// in right to left, get leftmost atom bounds, that has trailing space
+			{
+				// in RTL strip the width of the paragraph terminator from the front
+				bounds = textLine.getAtomBounds(lastAtom != 0 && endOfParagraph ? 1 : 0);						
+				lineWidth -= (_blockProgression == BlockProgression.TB) ? bounds.left : bounds.top;
+			}
+			//textLine.flushAtomData(); // Warning: Now does nothing
+			return lineWidth;
+		}
+
+		private function getRightSideGap(curLine:ITextFlowLine, aligned:Boolean):Number
+		{
+			var elem:IFlowGroupElement = curLine.paragraph;
+			var paraFormat:ITextLayoutFormat = elem.computedFormat;
+			
+			var rightSideGap:Number = paraFormat.direction == Direction.RTL ? paraFormat.paragraphStartIndent : paraFormat.paragraphEndIndent;
+			if (paraFormat.direction == Direction.RTL && (curLine.location & TextFlowLineLocation.FIRST))
+			{
+				// need to be careful because leftaligned paragraphs need to be exactly right coming out of this routine
+				// if (aligned && (_blockProgression == BlockProgression.TB && !curLine.controller.measureWidth || _blockProgression == BlockProgression.RL && !curLine.controller.measureHeight))
+				rightSideGap += paraFormat.textIndent;
+				
+				if (curLine.hasNumberLine && elem.getParentByType("ListItemElement").computedFormat.listStylePosition == ListStylePosition.INSIDE)
+				{
+					var textLine:ITextLine = curLine.getTextLine(true);
+					var numberLine:ITextLine = TextLineUtil.findNumberLine(textLine);
+					rightSideGap += TextLineUtil.getNumberLineInsideLineWidth(numberLine);
+				}
+			}
+
+			do 
+			{
+				rightSideGap += _blockProgression == BlockProgression.TB ? elem.getEffectivePaddingRight() + elem.getEffectiveBorderRightWidth() + elem.getEffectiveMarginRight() : elem.getEffectivePaddingBottom() + elem.getEffectiveBorderBottomWidth() + elem.getEffectiveMarginBottom();
+				elem = elem.parent;
+			} while (!(elem is ITextFlow));
+			return rightSideGap;
+		}
+		
+		private function getLeftSideGap(curLine:ITextFlowLine):Number
+		{
+			var elem:IFlowGroupElement = curLine.paragraph;
+			var paraFormat:ITextLayoutFormat = elem.computedFormat;
+			
+			var leftSideGap:Number = paraFormat.direction == Direction.LTR ? paraFormat.paragraphStartIndent : paraFormat.paragraphEndIndent;
+			
+			if (paraFormat.direction == Direction.LTR && (curLine.location & TextFlowLineLocation.FIRST))
+			{
+				// recording leftSideIndent is here because there is an extra alignment step for non-left aligned paragraphs
+				leftSideGap += paraFormat.textIndent;
+				
+				if (curLine.hasNumberLine && elem.getParentByType("ListItemElement").computedFormat.listStylePosition == ListStylePosition.INSIDE)
+				{
+					var textLine:ITextLine = curLine.getTextLine(true);
+					var numberLine:ITextLine = TextLineUtil.findNumberLine(textLine);
+					leftSideGap += TextLineUtil.getNumberLineInsideLineWidth(numberLine);
+				}
+			}
+			
+			do 
+			{
+				leftSideGap += _blockProgression == BlockProgression.TB ? elem.getEffectivePaddingLeft() + elem.getEffectiveBorderLeftWidth() +  elem.getEffectiveMarginLeft() : elem.getEffectivePaddingTop() + elem.getEffectiveBorderTopWidth() + elem.getEffectiveMarginTop();
+				elem = elem.parent;
+			} while (!(elem is ITextFlow));
+			return leftSideGap;
+		}
+		
+		/** @private */
+		private function calculateLineAlignmentAndBounds(textLine:ITextLine, numberLine:ITextLine, alignData:AlignData):AlignData
+		{
+			var lineWidth:Number = textLine.textWidth;
+			if (GlobalSettings.alwaysCalculateWhitespaceBounds || _parcelList.explicitLineBreaks)
+				lineWidth = calculateLineWidthExplicit(textLine);
+			
+			var rightSideGap:Number = _lineSlug.rightMargin;
+			var leftSideGap:Number = _lineSlug.leftMargin;
+			var delta:Number = 0;
+			
+			CONFIG::debug 
+			{ 
+				if (textLine.userData != null && _curParcel.controller.numFloats == 0 && ! _curLine.paragraph.isInTable())
+				{
+					var tmpRightGap:Number = getRightSideGap(_curLine, _curLine.alignment != TextAlign.LEFT);
+					assert(rightSideGap == getRightSideGap(_curLine, _curLine.alignment != TextAlign.LEFT),"mismatched rightSideGap"); 
+					
+					var tmpLeftGap:Number = getLeftSideGap(_curLine);
+					assert(leftSideGap  == getLeftSideGap(_curLine), "mismatched leftSideGap");
+				}
+			}
+			
+			CONFIG::debug { assert(textLine.userData == null || textLine.userData == _curLine,"Bad TextFlowLine in calculateLineAlignmentAndBounds"); }
+
+			if (alignData)
+			{
+				alignData.rightSideGap = rightSideGap;
+				alignData.leftSideGap = leftSideGap;
+				alignData.lineWidth = lineWidth;
+				alignData.textIndent = _curParaFormat.textIndent;
+				
+				var extraSpace:Number;
+				var coord:Number;
+//				var adjustedLogicalRight:Number;
+				
+				
+				if (_blockProgression == BlockProgression.TB)
+				{		
+					CONFIG::debug { assert(_curParcel.controller.measureWidth == _measuring,"Bad measuring initialization"); }
+					if (!_measuring)
+					{
+						var textLineWidth:Number = textLine.textWidth;
+						/*if (numberLine && TextLineUtil.getNumberLineListStylePosition(numberLine) == ListStylePosition.INSIDE)
+							textLineWidth += TextLineUtil.getNumberLineInsideLineWidth(numberLine);*/
+						extraSpace = _curParcel.width - leftSideGap - rightSideGap - textLineWidth;
+						if (alignData.textAlign != TextAlign.LEFT)
+						{
+							delta = (alignData.textAlign == TextAlign.CENTER ? extraSpace / 2 : extraSpace);
+							coord = _curParcel.x + leftSideGap + delta;
+						}
+						else	// used for RTL numberLine alignment of a left aligned textLine
+							coord = _curParcel.x + leftSideGap + extraSpace;
+						
+						if (alignData.textAlign != TextAlign.LEFT)
+						{
+							_curLine.x = coord;
+							textLine.x = coord;
+						}
+						else
+							textLine.x = _curLine.x;
+						
+						if (numberLine && TextLineUtil.getNumberLineListStylePosition(numberLine) == ListStylePosition.OUTSIDE)
+						{
+							numberLine.x = computeNumberLineAlignment(alignData,textLine.textWidth,textLine.x,numberLine,coord,delta,extraSpace);
+							CONFIG::debug { assert(alignData.textFlowLine == _curLine, "Mismatched alignData/curLine"); }
+							_curLine.numberLinePosition = numberLine.x;
+						}
+						
+						releaseAlignData(alignData);
+						alignData = null;
+					}
+				}
+				else 
+				{
+					CONFIG::debug { assert(_curParcel.controller.measureHeight == _measuring,"Bad measuring initialization"); }
+					
+					if (!_measuring)
+					{						
+						extraSpace = _curParcel.height - leftSideGap - rightSideGap -  textLine.textWidth;
+						if (alignData.textAlign != TextAlign.LEFT)
+						{
+							delta = (alignData.textAlign == TextAlign.CENTER ? extraSpace / 2 : extraSpace);
+							coord = _curParcel.y + leftSideGap + delta;
+						}
+						else	// used for RTL numberLine alignment of a left aligned textLine
+							coord = _curParcel.y + leftSideGap + extraSpace;							
+						
+						if (alignData.textAlign != TextAlign.LEFT)
+						{					
+							_curLine.y = coord;
+							textLine.y = coord;
+						}
+						else
+							textLine.y = _curLine.y;
+							
+						if (numberLine && TextLineUtil.getNumberLineListStylePosition(numberLine) == ListStylePosition.OUTSIDE)
+						{
+							numberLine.y = computeNumberLineAlignment(alignData,textLine.textWidth,textLine.y,numberLine,coord,delta,extraSpace);
+							CONFIG::debug { assert(alignData.textFlowLine == _curLine, "Mismatched alignData/curLine"); }
+							_curLine.numberLinePosition = numberLine.y;
+						}
+	
+						releaseAlignData(alignData);
+						alignData = null;
+					}	
+				}
+			}
+			
+			// extent from the left margin
+			var lineExtent:Number = lineWidth + leftSideGap + rightSideGap + delta;
+			// logical extent of the line
+			_curLine.lineExtent = lineExtent;
+			_workingContentLogicalExtent = Math.max(_workingContentLogicalExtent, lineExtent);
+			_curLine.accumulatedLineExtent = Math.max(_contentLogicalExtent, _workingContentLogicalExtent);
+			if (!alignData)
+			{				
+				// calculate this number - we're not measuring - otherwise its not really interesting
+				var edgeAdjust:Number = _curParaFormat.direction == Direction.LTR ? Math.max(_curLine.lineOffset, 0) : _curParaFormat.paragraphEndIndent;
+				edgeAdjust = _blockProgression == BlockProgression.RL ? _curLine.y - edgeAdjust : _curLine.x - edgeAdjust;
+				if (numberLine)
+				{
+					var numberLineStart:Number = _blockProgression == BlockProgression.TB ? numberLine.x+_curLine.x : numberLine.y+_curLine.y;
+					edgeAdjust = Math.min(edgeAdjust,numberLineStart);
+					
+					if (TextLineUtil.getNumberLineListStylePosition(numberLine) == ListStylePosition.OUTSIDE)
+					{
+						var numberLineMaxExtent:Number = numberLineStart + TextLineUtil.getNumberLineInsideLineWidth(numberLine);
+						numberLineMaxExtent -= lineExtent; //  + 2 * (_blockProgression == BlockProgression.RL ? _curLine.y : _curLine.x);
+						/*numberLineMaxExtent -= _blockProgression == BlockProgression.RL ? _curLine.y : _curLine.x;
+						numberLineMaxExtent -= lineExtent-_curLine.x;*/
+						if (numberLineMaxExtent > 0)
+							delta += numberLineMaxExtent;
+					}
+				}
+				_workingContentExtent = Math.max(_workingContentExtent, lineWidth + leftSideGap + Math.max(0,rightSideGap) + delta);
+
+				_curLine.accumulatedMinimumStart = _accumulatedMinimumStart = Math.min(_accumulatedMinimumStart, edgeAdjust);
+			}
+	
+			// first line
+			if (_curLine.absoluteStart == _curParcelStart && isNaN(_workingParcelLogicalTop))
+				_workingParcelLogicalTop = computeTextFlowLineMinimumLogicalTop(_curLine,textLine);
+
+			return alignData;
+		}
+		
+		/** @private - align the numberline so that its position is independent of the textAlign property */
+		public static function computeNumberLineAlignment(alignData:AlignData,textLineWidth:Number,textLineOffset:Number,numberLine:ITextLine,coord:Number,delta:Number,extraSpace:Number):Number
+		{
+			var rslt:Number;
+			
+			if (alignData.t

<TRUNCATED>

[10/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/ClearFloats.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/ClearFloats.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/ClearFloats.as
new file mode 100644
index 0000000..fb7ea8a
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/ClearFloats.as
@@ -0,0 +1,89 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.formats
+{
+	/**
+	 *  Defines values for setting the <code>clear</code> property
+     *  of the <code>TextLayoutFormat</code> class. This property controls 
+	 *  how text wraps around floats.
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+     * 
+     * @see org.apache.flex.textLayout.elements.InlineGraphicElement#float 
+	 * @see TextLayoutFormat#clear 
+	 */
+	public final class ClearFloats
+	{
+        /** Specifies that  text wraps closely around floats.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		
+		public static const NONE:String = "none";
+		
+        /** Specifies that text skips over left floats.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		
+		public static const LEFT:String = "left";
+		
+        /** Specifies that text skips over right floats.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		
+		public static const RIGHT:String = "right";
+		
+        /** Specifies that text skips over floats on the start side in reading order (left if direction is "ltr", right if direction is "rtl").
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		
+		public static const START:String = "start";
+
+        /** Specifies that text skips over floats on the start side in reading order (left if direction is "ltr", right if direction is "rtl").
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		
+		public static const END:String = "end";
+		
+        /** Specifies that text skips over any float.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		
+		public static const BOTH:String = "both";
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/ColorName.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/ColorName.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/ColorName.as
new file mode 100644
index 0000000..473a5c8
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/ColorName.as
@@ -0,0 +1,58 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.formats
+{
+	/**
+	 *  Defines a constant for specifying that the value of the <code>color</code> property
+	 *  of the <code>TextLayoutFormat</code> class is "transparent".
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 * @see org.apache.flex.textLayout.formats.TextLayoutFormat#color TextLayoutFormat.color
+	 */
+	public final class ColorName
+	{
+		/** Below are supported colorName values 
+		 *
+		 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	
+		public static const BLACK:String   = "black";  //0x000000;
+		public static const BLUE:String    = "blue";   //0x0000FF;
+		public static const GREEN:String   = "green";  //0x008000;
+		public static const GRAY:String    = "gray";   //0x808080;
+		public static const SILVER:String  = "silver"; //0xC0C0C0;
+		public static const LIME:String    = "lime";   //0x00FF00;
+		public static const OLIVE:String   = "olive";  //0x808000;
+		public static const WHITE:String   = "white";  //0xFFFFFF;
+		public static const YELLOW:String  = "yellow"; //0xFFFF00;
+		public static const MAROON:String  = "maroon"; //0x800000;
+		public static const NAVY:String    = "navy";   //0x000080;
+		public static const RED:String     = "red";    //0xFF0000;
+		public static const PURPLE:String  = "purple"; //0x800080;
+		public static const TEAL:String    = "teal";   //0x008080;
+		public static const FUCHSIA:String = "fuchsia";//0xFF00FF;
+		public static const AQUA:String    = "aqua";   //0x00FFFF;
+		public static const MAGENTA:String = "magenta";//0xFF00FF;
+		public static const CYAN:String    = "cyan";   //0x00FFFF;	
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/Direction.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/Direction.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/Direction.as
new file mode 100644
index 0000000..20e9101
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/Direction.as
@@ -0,0 +1,51 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.formats
+{
+	/**
+	 *  Defines values for setting the <code>direction</code> property
+	 *  of the <code>TextLayoutFormat</code> class. Left-to-right reading order 
+	 *  is used in Latin-style scripts. Right-to-left reading order is used with scripts such as Arabic or Hebrew. 
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 * @see TextLayoutFormat#direction 
+	 */
+	public final class Direction
+	{
+		/** Specifies left-to-right direction for text. 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		 
+		public static const LTR:String = "ltr";
+		
+		/** Specifies right-to-left direction for text. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		 
+		public static const RTL:String = "rtl";
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/Float.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/Float.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/Float.as
new file mode 100644
index 0000000..51bb1bb
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/Float.as
@@ -0,0 +1,47 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.formats
+{
+	/**
+     *  Defines values for the <code>float</code> property
+	 *  of the InlineGraphicElement class. 
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 * @see org.apache.flex.textLayout.elements.InlineGrapicElement
+	 */
+	public final class Float
+	{
+        /** Graphic appears inline in the text (doesn't float). */
+		public static const NONE:String = "none";		
+        /** Graphic floats on the left side of the text. */
+		public static const LEFT:String = "left";
+        /** Graphic floats on the right side of the text. */
+		public static const RIGHT:String = "right";
+        /** Graphic floats on the leading side of the text 
+         * (left if paragraph direction is "ltr", right if paragraph direction is "rtl"). 
+		 */
+		public static const START:String = "start";
+        /** Graphic floats on the trailing side of the text 
+        * (right if paragraph direction is "ltr", left if paragraph direction is "rtl"). 
+		*/
+		public static const END:String = "end";
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/FormatValue.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/FormatValue.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/FormatValue.as
new file mode 100644
index 0000000..1186213
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/FormatValue.as
@@ -0,0 +1,64 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.formats
+{
+	/**
+	 *  Defines values for specifying that a formatting property is to inherit its parent's value or have it's value
+	 *  generated automatically. The <code>INHERIT</code> constant specifies that a property inherits its parent's value 
+	 *  while the <code>AUTO</code> constant specifies that an internal algorithm automatically determine the property's 
+	 *  value. As one example, you can set <code>TextLayoutFormat.columnWidth</code> using these values. Typically, a 
+	 *  property's description indicates whether it accepts these constants.
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 *
+	 * @see org.apache.flex.textLayout.formats.TextLayoutFormat TextLayoutFormat
+	 */
+	 
+	public final class FormatValue
+	{
+		/** Specifies that a property's value is automatically generated. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		 
+		public static const AUTO:String = "auto";
+		
+		/** Specifies that a property is to inherit its parent's value.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		 
+		public static const INHERIT:String = "inherit";
+		
+		/** Specifies that a property's value is none. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		
+		public static const NONE:String = "none";
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/IListMarkerFormat.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/IListMarkerFormat.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/IListMarkerFormat.as
new file mode 100644
index 0000000..c19e327
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/IListMarkerFormat.as
@@ -0,0 +1,43 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.formats
+{
+	/**
+	 * This interface provides read access to ListMarkerFormat properties.
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	public interface IListMarkerFormat extends ITextLayoutFormat
+	{
+		/** @copy ListMarkerFormat#counterReset*/
+		function get counterReset():*;
+		/** @copy ListMarkerFormat#counterIncrement*/
+		function get counterIncrement():*;
+		/** @copy ListMarkerFormat#beforeContent*/
+		function get beforeContent():*;
+		/** @copy ListMarkerFormat#content*/
+		function get content():*;
+		/** @copy ListMarkerFormat#afterContent*/
+		function get afterContent():*;
+		/** @copy ListMarkerFormat#suffix*/
+		function get suffix():*;
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/IMEStatus.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/IMEStatus.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/IMEStatus.as
new file mode 100644
index 0000000..bd46366
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/IMEStatus.as
@@ -0,0 +1,103 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.formats
+{
+	// [ExcludeClass]
+	/**
+	 *  Used internally for specifying the status of clauses in IME text during an IME text entry session.
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	public final class IMEStatus
+	{
+		public function IMEStatus()
+		{
+		}
+		
+		/** The name of the IMEClause property. Value is an integer.
+		 *
+		 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		public static const IME_CLAUSE:String = "imeClause";
+		
+		/** The name of the IMEStatus property
+		 *
+		 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		public static const IME_STATUS:String = "imeStatus";
+		
+		// Following are all the possible values of imeStatus property:
+		
+		/** Selected raw - text has not been converted and is the current clause in the IME session
+		 *
+		 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		public static const SELECTED_RAW:String = "selectedRaw";
+
+		/** Selected coverted - text has been converted and is the current clause in the IME session
+		 *
+		 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		public static const SELECTED_CONVERTED:String = "selectedConverted";
+
+		/** Not selected raw - text has not been converted and is not part of the current clause 
+		 *  in the IME session
+		 *
+		 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		public static const NOT_SELECTED_RAW:String = "notSelectedRaw";
+		
+		/** Not selected converted - text has been converted and is not part of the current clause 
+		 * 	in the IME session
+		 *
+		 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		public static const NOT_SELECTED_CONVERTED:String = "notSelectedConverted";
+
+		/** Dead key input state - in the process of entering a multi-key character, such as an accented char
+		 *
+		 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		public static const DEAD_KEY_INPUT_STATE:String = "deadKeyInputState";
+
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/ITabStopFormat.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/ITabStopFormat.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/ITabStopFormat.as
new file mode 100644
index 0000000..e829145
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/ITabStopFormat.as
@@ -0,0 +1,87 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.formats
+{
+	/**
+	 * This interface provides read access to tab stop-related properties.
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	public interface ITabStopFormat
+	{
+		/**
+		 * Return the value of the style specified by the <code>styleProp</code> parameter
+		 * which specifies the style name.
+		 * 
+		 * @param styleProp The name of the style whose value is to be retrieved.
+		 * @return The value of the specified style.  The type varies depending on the type of the style being
+		 * accessed.  Returns <code>undefined</code> if the style is not set.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function getStyle(styleName:String):*;
+		/**
+		 * The position of the tab stop, in pixels, relative to the start edge of the column.
+		 * <p>Legal values are numbers from 0 to 10000 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of 0.</p>
+		 * @see FormatValue#INHERIT
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get position():*;
+
+		/**
+		 * The tab alignment for this tab stop. 
+		 * <p>Legal values are TabAlignment.START, TabAlignment.CENTER, TabAlignment.END, TabAlignment.DECIMAL, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of TabAlignment.START.</p>
+		 * @see FormatValue#INHERIT
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.text.engine.TabAlignment
+		 */
+		function get alignment():*;
+
+		/**
+		 * The alignment token to be used if the alignment is DECIMAL.
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of null.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get decimalAlignmentToken():*;
+	}
+}


[08/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/LeadingModel.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/LeadingModel.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/LeadingModel.as
new file mode 100644
index 0000000..ea6e883
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/LeadingModel.as
@@ -0,0 +1,152 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.formats
+{
+	/**
+	 *  Defines values for setting the <code>leadingModel</code> property
+	 *  of the <code>TextLayoutFormat</code> class, composed of valid combinations of leading basis and leading direction.
+	 *  Leading basis describes which baselines determine the leading (or <code>lineHeight</code>) of lines in a paragraph.
+	 *  Leading direction specifies whether the <code>lineHeight</code> property refers to the distance of a line's 
+	 *  baseline from that of the line before it or the line after it. 
+	 *  <p>
+	 *  <img src="../../../images/textLayout_baselines.jpg" alt="baselines" border="0"/>
+	 *  <img src="../../../images/textLayout_LD1.jpg" alt="leadingDirection_1" border="0"/>
+	 *  <img src="../../../images/textLayout_LD2.jpg" alt="leadingDirection_2" border="0"/>
+	 *  <img src="../../../images/textLayout_LD3.jpg" alt="leadingDirection_3" border="0"/>
+	 *  </p>
+	 *  @playerversion Flash 10
+	 *  @playerversion AIR 1.5
+	 *  @langversion 3.0 
+	 * 
+	 *  @see TextLayoutFormat#leadingModel
+	 *  @see TextLayoutFormat#lineHeight
+	 *  @see flash.text.TextField
+	 *  @see org.apache.flex.text.engine.TextLine 
+	 */
+	 
+	public final class LeadingModel
+	{
+		/** Specifies that leading basis is ROMAN and leading direction is UP. 
+		 * In other words, <code>lineHeight</code> refers to the distance of a line's Roman baseline from the 
+		 * previous line's Roman baseline.
+		 *
+		 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+	  	 * @langversion 3.0 
+	 	 */
+	 	 
+		public static const ROMAN_UP:String = "romanUp";
+		
+		/** Specifies that leading basis is IDEOGRAPHIC_TOP and leading direction is UP. 
+		 *  In other words, <code>lineHeight</code> refers to the distance of a line's ideographic top 
+		 *  baseline from the previous line's ideographic top baseline.
+		 *
+		 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+	 	 */
+	 	 
+		public static const IDEOGRAPHIC_TOP_UP:String = "ideographicTopUp";
+		
+		/** Specifies that leading basis is IDEOGRAPHIC_CENTER and leading direction is UP. 
+		 * In other words, <code>lineHeight</code> refers to the distance of a line's ideographic center 
+		 * baseline from the previous line's ideographic center baseline.
+		 *
+		 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		 
+		public static const IDEOGRAPHIC_CENTER_UP:String = "ideographicCenterUp";
+		
+		/** Specifies that leading basis is IDEOGRAPHIC_TOP and leading direction is DOWN.
+		 * In other words, <code>lineHeight</code> refers to the distance of a line's ideographic top baseline 
+		 * from the next line's ideographic top baseline.
+		 *
+		 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+	 	 */
+	 	 
+		public static const IDEOGRAPHIC_TOP_DOWN:String = "ideographicTopDown";
+		
+		/** Specifies that leading basis is IDEOGRAPHIC_CENTER and leading direction is down.
+		 *  In other words, <code>lineHeight</code> refers to the distance of a line's ideographic center 
+		 *  baseline from the next line's ideographic center baseline.
+		 *
+		 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+	 	 */
+	 	 
+		public static const IDEOGRAPHIC_CENTER_DOWN:String = "ideographicCenterDown";
+		
+		/** Specifies that leading basis is ASCENT/DESCENT and leading direction is UP. 
+		 *  In other words, <code>lineHeight</code> refers to the distance of a line's ascent baseline from the 
+		 *  previous line's descent baseline.
+		 *
+		 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+	  	 * @langversion 3.0 
+	 	 */
+	 	 
+		public static const ASCENT_DESCENT_UP:String = "ascentDescentUp";
+		
+		/** Specifies that leading model is chosen automatically based on the paragraph's <code>locale</code> property.  
+		 * For Japanese and Chinese, it is IDEOGRAPHIC_TOP_DOWN and for all others it is ROMAN_UP.
+		 *
+		 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+	 	 * 
+	 	 * #IDEOGRAPHIC_TOP_DOWN
+	 	 * #ROMAN_UP
+	 	 */
+	 	 
+		public static const AUTO:String = "auto";
+		
+		/** Specifies a leading model that approximates the line spacing behavior of <code>TextField</code>.
+		 * It is similar to <code>ASCENT_DESCENT_UP</code> in that <code>lineHeight</code> refers to the 
+		 * distance of a line's ascent baseline from the previous line's descent baseline. However, baseline 
+		 * positions approximate those determined by <code>TextField</code>, rather than using metrics 
+		 * offered by <code>TextLine</code>.  
+		 *
+		 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		public static const APPROXIMATE_TEXT_FIELD:String = "approximateTextField";
+		
+		/**  Specifies a leading model based on the CSS inline formatting model, which involves stacking <i>line boxes</i> contiguously.
+		 * A <i>line box</i> is defined as the bounding box around <i>inline boxes</i> for all leaf elements on the text line, after they have been aligned
+		 * using <code>baselineShift</code>, <code>dominantBaseline</code>, <code>alignmentBaseline</code> etc. For a span, the <i>inline box</i> 
+		 * is obtained by applying leading equally above and below the text content such that its height equals <code>lineHeight</code>.
+		 * For an inline graphic, <code>lineHeight</code> is ignored; the <i>inline box</i> is derived from its specified dimensions and padding values.
+		 * Also, <code>firstBaselineOffset</code> is ignored with this leading model.
+		 * 
+         * <p>For more information, see <a href='http://blogs.adobe.com/tlf/2010/11/box-leading-model.html'>Box leading model</a>.</p>
+         * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const BOX:String = "box";
+		
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/LineBreak.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/LineBreak.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/LineBreak.as
new file mode 100644
index 0000000..240a22b
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/LineBreak.as
@@ -0,0 +1,49 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.formats
+{
+	/** Defines values for setting the <code>lineBreak</code> property of <code>TextLayoutFormat</code> to
+	 *  specify how lines are broken within wrapping text.
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 * @see TextLayoutFormat#linebreak
+	 */
+	public final class LineBreak
+	{
+		/** Specifies that lines wrap to fit the container width. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	  	 * @langversion 3.0 
+		 */
+		 
+		public static const TO_FIT:String = "toFit";
+		
+		/** Specifies that lines break only at explicit return or line feed characters. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		 
+		public static const EXPLICIT:String = "explicit";
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/ListMarkerFormat.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/ListMarkerFormat.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/ListMarkerFormat.as
new file mode 100644
index 0000000..acf203c
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/ListMarkerFormat.as
@@ -0,0 +1,370 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.formats
+{
+	import org.apache.flex.textLayout.property.CounterContentHandler;
+	import org.apache.flex.textLayout.property.CounterPropHandler;
+	import org.apache.flex.textLayout.property.EnumPropertyHandler;
+	import org.apache.flex.textLayout.property.Property;
+	import org.apache.flex.textLayout.property.PropertyFactory;
+	import org.apache.flex.textLayout.property.PropertyUtil;
+
+	
+
+	
+	/** Defines the marker format in a ListItemElement.
+	 *  
+	 *  @playerversion Flash 10
+	 *  @playerversion AIR 1.5
+	 *  @langversion 3.0 
+	 * 
+	 *  @see org.apache.flex.textLayout.elements.ListItemElement
+	 */
+	public class ListMarkerFormat extends TextLayoutFormat implements IListMarkerFormat
+	{
+		/** @private */
+		public static function createCounterResetProperty(nameValue:String, defaultValue:String, inherited:Boolean, categories:Vector.<String>):Property
+		{
+			var rslt:Property = new Property(nameValue, defaultValue, inherited, categories);
+			rslt.addHandlers(PropertyFactory.sharedUndefinedHandler, new EnumPropertyHandler([ FormatValue.NONE ]),new CounterPropHandler(0));
+			return rslt;			
+		}
+		
+		/** @private */
+		public static function createCounterIncrementProperty(nameValue:String, defaultValue:String, inherited:Boolean, categories:Vector.<String>):Property
+		{
+			var rslt:Property = new Property(nameValue, defaultValue, inherited, categories);
+			rslt.addHandlers(PropertyFactory.sharedUndefinedHandler, new EnumPropertyHandler([ FormatValue.NONE ]),new CounterPropHandler(1));
+			return rslt;			
+		}
+		
+		/** @private */
+		public static function createCounterContentProperty(nameValue:String, defaultValue:String, inherited:Boolean, categories:Vector.<String>):Property
+		{
+			var rslt:Property = new Property(nameValue, defaultValue, inherited, categories);
+			rslt.addHandlers(PropertyFactory.sharedUndefinedHandler, new EnumPropertyHandler([ FormatValue.NONE ]),new CounterContentHandler());
+			return rslt;			
+		}
+
+		/** @private */
+		static public const counterResetProperty:Property = createCounterResetProperty("counterReset", FormatValue.NONE, false, Vector.<String>([Category.LIST]));
+		/** @private */
+		static public const counterIncrementProperty:Property = createCounterResetProperty("counterIncrement", "ordered 1", false, Vector.<String>([Category.LIST]));
+		/** @private */
+		static public const beforeContentProperty:Property = PropertyFactory.string("beforeContent", null, false, Vector.<String>([Category.LIST]));
+		/** @private */
+		static public const contentProperty:Property = createCounterContentProperty("content", "counter(ordered)", false, Vector.<String>([Category.LIST]));
+		/** @private */
+		static public const afterContentProperty:Property  = PropertyFactory.string("afterContent", null, false, Vector.<String>([Category.LIST]));
+		/** @private */
+		static public const suffixProperty:Property = PropertyFactory.enumString("suffix", Suffix.AUTO, false, Vector.<String>([Category.LIST]), Suffix.AUTO, Suffix.NONE);
+		
+		static private var _lmfDescription:Object = {
+			counterReset:counterResetProperty,
+			counterIncrement:counterIncrementProperty,
+			beforeContent:beforeContentProperty,
+			content:contentProperty,
+			afterContent:afterContentProperty,
+			suffix:suffixProperty
+		};
+		
+		// at this point we know that both TextLayoutFormat and ListMarkerFormat are initialized so can setup the Property objects
+		PropertyFactory.sharedTextLayoutFormatHandler.converter = TextLayoutFormat.createTextLayoutFormat;
+		PropertyFactory.sharedListMarkerFormatHandler.converter = ListMarkerFormat.createListMarkerFormat;
+
+		
+		/** Create a ListMarkerFormat that holds all the properties possible for a list marker.  
+		 * 
+		 *  @param initialValues An optional instance from which to copy initial values.
+		 * 
+		 *  @playerversion Flash 10
+		 *  @playerversion AIR 1.5
+		 *  @langversion 3.0 
+	 	 */
+		public function ListMarkerFormat(initialValues:IListMarkerFormat = null)
+		{
+			super(initialValues);
+		}
+		
+		/** @private */
+		private function setLMFStyle(styleProp:Property,newValue:*):void
+		{
+			var name:String = styleProp.name;
+			newValue = styleProp.setHelper(getStyle(name),newValue);
+			super.setStyleByName(name,newValue);
+		}
+		
+		/** @private */
+		public override function setStyle(styleProp:String,newValue:*):void
+		{
+			var lmfStyle:Property = _lmfDescription[styleProp];
+			if (lmfStyle)
+				setLMFStyle(lmfStyle,newValue);
+			else
+				super.setStyle(styleProp,newValue);
+		}
+		
+		/**
+		 * Controls resetting the value of the counter.  
+		 * <p>Legal values for this property are:
+		 *  <ul>
+		 * 	  <li><code>none</code> - No reset.</li>
+		 * 	  <li><code>ordered</code> - Reset the counter to zero.</li>
+		 * 	  <li><code>ordered <i>integer</i></code> - Reset the counter to <code><i>integer</i></code>.</li>
+		 *  </ul>
+		 * </p>
+		 * <p>If <code>undefined</code>, the default value of this property is "none".</p>
+		 * <p>Note: The <code>counterReset</code> property is applied before the <code>counterIncrement</code> property.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get counterReset():*
+		{ return getStyle(counterResetProperty.name); }
+		public function set counterReset(value:*):void
+		{ setLMFStyle(counterResetProperty,value); }
+		
+		/**
+		 * Controls incrementing the value of the counter.  
+		 * <p>Legal values for this string are:
+		 *  <ul>
+		 * 		<li><code>none</code> - No increment.</li>
+		 * 		<li><code>ordered</code> - Increment the counter by one.</li>
+		 * 		<li><code>ordered <i>integer</i></code> - Increment the counter by <code><i>integer</i></code>.</li>
+		 *  </ul>
+		 * </p>
+		 * <p>If undefined, the default vaule of this property is <code>"ordered 1"</code>.</p>
+		 * <p>Note: The <code>counterIncrement</code> property is applied before the <code>counterReset</code> property.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get counterIncrement():*
+		{ return getStyle(counterIncrementProperty.name); }
+		public function set counterIncrement(value:*):void
+		{ setLMFStyle(counterIncrementProperty,value); }
+		
+		/**
+		 * Controls the content of the marker. 
+		 * <p>Legal values for this string are:
+		 * <ul>
+		 * 	<li><code>none</code> - No marker.</li>
+		 * 	<li><code>counter(ordered)</code> - Display the marker.</li>
+		 * 	<li><code>counter(ordered,ListStyleType)</code> - Display the marker but change the listStyleType to the specified value.</li>
+		 * 	<li><code>counters(ordered)</code> - Starting from the top-most parent ListElement creating a string of values of the ordered counter in each counters specified listStyleType separated by the suffix for each.  This is used for outline number - for example I.1., I.2. etc.</li>
+		 * 	<li><code>counters(ordered,"&lt;string&gt;")</code> - Similar to the previous value, except the suffix for each ordered counter is replaced by &lt;string&gt;.</li>
+		 * 	<li><code>counters(ordered,"&lt;string&gt;",ListStyleType)</code> - Similar to the previous value, except each counter's <code>listStyleType</code> is replaced with the specified value.</li>
+		 * </ul>
+		 * </p>
+		 * <p>If undefined, the default vaule of this property is <code>"counter(ordered)"</code>.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */		
+		public function get content():*
+		{ return getStyle(contentProperty.name); }
+		public function set content(value:*):void
+		{ setLMFStyle(contentProperty,value); }
+		
+		/** Specifies a string that goes before the marker. Default is the empty string. 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0	
+		 */
+		public function get beforeContent():*
+		{ return getStyle(beforeContentProperty.name); }
+		public function set beforeContent(value:*):void
+		{ setLMFStyle(beforeContentProperty,value); }
+		
+		/** Specifies a string that goes after the marker. Default is the empty string. 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0	
+		 */
+		public function get afterContent():*
+		{ return getStyle(afterContentProperty.name); }
+		public function set afterContent(value:*):void
+		{ setLMFStyle(afterContentProperty,value); }
+		
+		/**
+		 * Controls the application of the suffix in the generated text in the ListItemElement.
+		 * <p>Legal values are:
+		 * <ul>
+		 *   <li><code>org.apache.flex.textLayout.formats.Suffix.NONE</code> - No suffix.</li>		 
+		 *   <li><code>org.apache.flex.textLayout.formats.Suffix.AUTO</code> - Follow CSS rules for adding a suffix.</li>
+		 * </ul> 
+		 * </p>
+		 * <p>Default value is <code>Suffix.AUTO</code>.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.Suffix
+		 */
+		public function get suffix():*
+		{ return getStyle(suffixProperty.name); }
+		public function set suffix(value:*):void
+		{ setLMFStyle(suffixProperty,value); }
+		
+		static private var _description:Object;
+		
+		/** Property descriptions accessible by name. @private */
+		static public function get description():Object
+		{ 
+			if (!_description)
+			{
+				// use prototype chaining
+				_description = PropertyUtil.createObjectWithPrototype(TextLayoutFormat.description);
+				for (var key:String in _lmfDescription)
+					_description[key] = _lmfDescription[key];
+			}
+			return _description; 
+		}
+		
+		/** @private */
+		public override function copy(incoming:ITextLayoutFormat):void
+		{
+			super.copy(incoming);
+			
+			var lmf:IListMarkerFormat = incoming as IListMarkerFormat;
+			if (lmf)
+			{
+				for (var key:String in _lmfDescription)
+					this[key] = lmf[key];
+			}
+		}
+		
+		/** @private */
+		public override function concat(incoming:ITextLayoutFormat):void
+		{
+			super.concat(incoming);
+			var lmf:IListMarkerFormat = incoming as IListMarkerFormat;
+			if (lmf)
+			{
+				for each (var prop:Property in _lmfDescription)
+				{
+					var name:String = prop.name;
+					setLMFStyle(prop,prop.concatHelper(this[name],lmf[name]));
+				}
+			}
+		}
+		
+		/** @private */
+		public override function concatInheritOnly(incoming:ITextLayoutFormat):void
+		{
+			super.concatInheritOnly(incoming);
+			var lmf:IListMarkerFormat = incoming as IListMarkerFormat;
+			if (lmf)
+			{
+				for each (var prop:Property in _lmfDescription)
+				{
+					var name:String = prop.name;
+					setLMFStyle(prop,prop.concatInheritOnlyHelper(this[name],lmf[name]));
+				}
+			}
+		}
+		
+		/** @private */
+		public override function apply(incoming:ITextLayoutFormat):void
+		{
+			super.apply(incoming);
+			var lmf:IListMarkerFormat = incoming as IListMarkerFormat;
+			if (lmf)
+			{
+				for each (var prop:Property in _lmfDescription)
+				{
+					var name:String = prop.name;
+					var val:* = lmf[name];
+					if (val !== undefined)
+						this[name] = val;
+				}
+			}
+		}
+		
+		/** @private */
+		public override function removeMatching(incoming:ITextLayoutFormat):void
+		{
+			super.removeMatching(incoming);
+			var lmf:IListMarkerFormat = incoming as IListMarkerFormat;
+			if (lmf)
+			{
+				for each (var prop:Property in _lmfDescription)
+				{
+					var name:String = prop.name;
+					if (prop.equalHelper(this[name],lmf[name]))
+						this[name] = undefined;
+				}
+			}
+
+		}
+		
+		/** @private */
+		public override function removeClashing(incoming:ITextLayoutFormat):void
+		{
+			super.removeClashing(incoming);
+			var lmf:IListMarkerFormat = incoming as IListMarkerFormat;
+			if (lmf)
+			{
+				for each (var prop:Property in _lmfDescription)
+				{
+					var name:String = prop.name;
+					if (!prop.equalHelper(this[name],lmf[name]))
+						this[name] = undefined;
+				}
+			}
+		}
+		
+		/**
+		 * Creates a new ListMarkerFormat object. All settings are empty or, optionally, are initialized from the
+		 * supplied <code>initialValues</code> object.
+		 * 
+		 * @param initialValues Optional instance from which to copy initial values. If the object is of type IListMarkerFormat or ITextLayoutFormat, the values are copied.  
+		 * Otherwise the <code>initialValues</code> parameter is treated like a ObjectMap or Object and iterated over.
+		 * 
+		 * @return The new ListMarkerFormat object.
+		 * 
+		 * @see #defaultFormat
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public static function createListMarkerFormat(initialValues:Object):ListMarkerFormat
+		{
+			var lmf:IListMarkerFormat = initialValues as IListMarkerFormat;
+			var rslt:ListMarkerFormat = new ListMarkerFormat(lmf);
+			if (lmf == null && initialValues)
+			{
+				for (var key:String in initialValues)
+					rslt.setStyle(key,initialValues[key]);
+			}
+			return rslt;
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/ListStylePosition.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/ListStylePosition.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/ListStylePosition.as
new file mode 100644
index 0000000..63cf916
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/ListStylePosition.as
@@ -0,0 +1,50 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.formats
+{
+	/**
+	 * Defines values for setting the <code>listStylePosition</code> property. These values control the placement
+	 * of a list item marker relative to the list item.
+	 *
+	 *  @playerversion Flash 10
+	 *  @playerversion AIR 1.5
+	 *  @langversion 3.0 
+	 * 
+	 *  @see TextLayoutFormat#listStylePosition
+	 */
+	 
+	public final class ListStylePosition
+	{
+		/** Marker will appear inline with the list item. This style position lets you include trailing spaces.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const INSIDE:String = "inside";
+
+		/** Marker will appear in the margin of the list. This style position does not recognize trailing spaces.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const OUTSIDE:String = "outside";
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/ListStyleType.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/ListStyleType.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/ListStyleType.as
new file mode 100644
index 0000000..a98e55d
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/ListStyleType.as
@@ -0,0 +1,314 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.formats
+{
+	/**
+	 * Defines values for setting the <code>listStyleType</code> property of a TextLayoutFormat object. These values are used for controlling
+	 * the appearance of items in a list.
+	 *
+	 *  @playerversion Flash 10
+	 *  @playerversion AIR 1.5
+	 *  @langversion 3.0 
+	 * 
+	 *  @see TextLayoutFormat#listStyleType
+	 */
+	 
+	public final class ListStyleType
+	{
+		/** Upper-case alphabetic "numbering": A-Z, AA-ZZ, and so on.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const UPPER_ALPHA:String = "upperAlpha";
+
+		/** Lower-case alphabetic "numbering": a-z, aa-zz, and so on.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const LOWER_ALPHA:String = "lowerAlpha";
+
+		/** Upper-case Roman numbering: I, II, III, IV, and so on.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const UPPER_ROMAN:String = "upperRoman";
+
+		/** Lower-case Roman numbering: i, ii, iii, iv, and so on.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const LOWER_ROMAN:String = "lowerRoman";
+
+		/** No content is generated for the marker.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const NONE:String = "none";
+
+		/** A bullet character marker (filled circle).
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const DISC:String = "disc";
+
+		/** A circle character marker that is not filled.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const CIRCLE:String = "circle";
+
+		/** A filled square marker.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const SQUARE:String = "square";
+
+		/** A square marker that is not filled.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const BOX:String = "box";
+
+		/** A check mark.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const CHECK:String = "check";
+
+		/** A filled diamond marker.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const DIAMOND:String = "diamond";
+
+		/** A dash mark.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const HYPHEN:String = "hyphen";
+
+		/** Numbering using Arabic script.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const ARABIC_INDIC:String = "arabicIndic";
+
+		/** Numbering using Bengali script.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const BENGALI:String = "bengali";
+
+		/** Numbering using decimals: 1, 2, 3, and so on.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const DECIMAL:String = "decimal";
+
+		/** Numbering using decimal with a leading zero: 01, 02, 03, and so on.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const DECIMAL_LEADING_ZERO:String = "decimalLeadingZero";
+
+		/** Numbering using Devangari.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const DEVANAGARI:String = "devanagari";
+
+		/** Numbering using Gujarati.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const GUJARATI:String = "gujarati";
+
+		/** Numbering using Gurmukhi.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const GURMUKHI:String = "gurmukhi";
+
+		/** Numbering using Kannada.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const KANNADA:String = "kannada";
+
+		/** Numbering using Persian.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const PERSIAN:String = "persian";
+
+		/** Numbering using Thai.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const THAI:String = "thai";
+
+		/** Numbering using Urdu.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const URDU:String = "urdu";
+
+		/** Numbering for CJK.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const CJK_EARTHLY_BRANCH:String = "cjkEarthlyBranch";
+
+		/** Numbering for CJK.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const CJK_HEAVENLY_STEM:String = "cjkHeavenlyStem";
+
+		/** Numbering for Hangul.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const HANGUL:String = "hangul";
+
+		/** Numbering for Hangul.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const HANGUL_CONSTANT:String = "hangulConstant";
+
+		/** Numbering for Hiragana.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const HIRAGANA:String = "hiragana";
+
+		/** Numbering for Hiragana.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const HIRAGANA_IROHA:String = "hiraganaIroha";
+
+		/** Numbering for Katagana.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const KATAKANA:String = "katakana";
+
+		/** Numbering for Katagana.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const KATAKANA_IROHA:String = "katakanaIroha";
+
+		/** Lower-case Greek alphabetic "numering".
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const LOWER_GREEK:String = "lowerGreek";
+
+		/** Lower-case alphabetic "numbering": a-z, aa-zz, and so on.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const LOWER_LATIN:String = "lowerLatin";
+
+		/** Upper-case Greek alphabetic "numering".
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const UPPER_GREEK:String = "upperGreek";
+
+		/** Upper-case alphabetic "numbering": A-Z, AA-ZZ, and so on.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const UPPER_LATIN:String = "upperLatin";
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/Suffix.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/Suffix.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/Suffix.as
new file mode 100644
index 0000000..3afecd2
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/Suffix.as
@@ -0,0 +1,51 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.formats
+{
+    /**
+     * Defines values for setting the <code>suffix</code> property of a ListMarkerFormat. 
+     *
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @langversion 3.0 
+     * 
+     *  @see ListMarkerFormat#suffix
+     */
+    public class Suffix
+    {
+        /** Specifies that the auto suffix is appended to the list marker after the content. 
+         *  See <a href="http://www.w3.org/TR/css3-lists/">http://www.w3.org/TR/css3-lists/</a> for the default suffixes.
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0 
+         */
+        
+        public static const AUTO:String = "auto";
+        
+        /** Specifies that no suffix is appended to a list marker after the content. 
+         *
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0 
+         */
+        
+        public static const NONE:String = "none";
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/TLFTypographicCase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/TLFTypographicCase.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/TLFTypographicCase.as
new file mode 100644
index 0000000..5bdf114
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/TLFTypographicCase.as
@@ -0,0 +1,79 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.formats
+{
+	/**
+	 *  Defines values for the <code>typographicCase</code> property of the TextLayoutFormat
+	 *  class. 
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 * 
+	 * @see TextLayoutFormat#typographicCase
+	 */
+	public final class TLFTypographicCase
+	{
+		/** Specifies default typographic case -- no special features applied. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		 
+ 		public static const DEFAULT:String = "default";
+ 		
+		/** Converts all lowercase characters to uppercase, then applies small caps to only the 
+		 * characters that the conversion changed. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		 
+  	 	public static const LOWERCASE_TO_SMALL_CAPS:String = "lowercaseToSmallCaps";
+  	 	
+  	 	/** Specifies that all characters use lowercase glyphs on output. 
+  	 	 *
+  	 	 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		 
+ 	 	public static const LOWERCASE:String = "lowercase";
+
+		/** Specifies that uppercase characters use small-caps glyphs on output. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		 
+ 	 	public static const CAPS_TO_SMALL_CAPS:String = "capsToSmallCaps";
+
+		/** Specifies that all characters use uppercase glyphs on output.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		 
+ 	 	public static const UPPERCASE:String = "uppercase";
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/TabStopFormat.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/TabStopFormat.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/TabStopFormat.as
new file mode 100644
index 0000000..7571d39
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/TabStopFormat.as
@@ -0,0 +1,397 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.formats
+{
+	import org.apache.flex.text.engine.TabAlignment;
+	import org.apache.flex.textLayout.property.Property;
+	import org.apache.flex.textLayout.property.PropertyFactory;
+	import org.apache.flex.textLayout.property.PropertyUtil;
+	/**
+	 * The TabStopFormat class represents the properties of a tab stop in a paragraph. You can set the <code>TextLayoutFormat.tabstops</code> property to an array of TabStopFormat objects.
+	 * @see org.apache.flex.textLayout.elements.TabElement 
+	 * @see org.apache.flex.textLayout.formats.TextLayoutFormat#tabStops
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	public class TabStopFormat implements ITabStopFormat
+	{
+		/** @private */
+		private static var _positionProperty:Property;
+		private static function get positionProperty():Property
+		{
+			if(!_positionProperty)
+				_positionProperty = PropertyFactory.number("position",0,false,Vector.<String>([Category.TABSTOP]),0,10000);
+			return _positionProperty;
+		}
+		// static public const positionProperty:Property = PropertyUtil.NewNumberProperty("position",0,false,Vector.<String>([Category.TABSTOP]),0,10000);
+		/** @private */
+		private static var _alignmentProperty:Property;
+		private static function get alignmentProperty():Property
+		{
+			if(_alignmentProperty == null)
+			{
+				_alignmentProperty = PropertyFactory.enumString(
+					"alignment",TabAlignment.START,false,Vector.<String>([Category.TABSTOP])
+					,TabAlignment.START
+					,TabAlignment.CENTER
+					,TabAlignment.END
+					,TabAlignment.DECIMAL
+				);
+			}
+			return _alignmentProperty;
+		}
+		// static public const alignmentProperty:Property = PropertyUtil.NewEnumStringProperty(
+		// 	"alignment",TabAlignment.START,false,Vector.<String>([Category.TABSTOP])
+		// 	,TabAlignment.START
+		// 	,TabAlignment.CENTER
+		// 	,TabAlignment.END
+		// 	,TabAlignment.DECIMAL
+		// );
+		/** @private */
+		private static var _decimalAlignmentTokenProperty:Property;
+		private static function get decimalAlignmentTokenProperty():Property
+		{
+			if(_decimalAlignmentTokenProperty == null)
+			{
+				_decimalAlignmentTokenProperty = PropertyFactory.string("decimalAlignmentToken",null,false,Vector.<String>([Category.TABSTOP]));
+			}
+			return _decimalAlignmentTokenProperty;
+		}
+		// static public const decimalAlignmentTokenProperty:Property = PropertyUtil.NewStringProperty("decimalAlignmentToken",null,false,Vector.<String>([Category.TABSTOP]));
+
+		static private var _description:Object;
+
+		/** Property descriptions accessible by name. @private */
+		static public function get description():Object
+		{
+			if(!_description)
+			{
+				_description = {
+					position:positionProperty
+					, alignment:alignmentProperty
+					, decimalAlignmentToken:decimalAlignmentTokenProperty
+				};
+			}
+			 return _description;
+		}
+
+		/** @private */
+		static private var _emptyTabStopFormat:ITabStopFormat;
+		/**
+		 * Returns an ITabStopFormat instance with all properties set to <code>undefined</code>.
+		 * @private
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		static public function get emptyTabStopFormat():ITabStopFormat
+		{
+			if (_emptyTabStopFormat == null)
+				_emptyTabStopFormat = new TabStopFormat();
+			return _emptyTabStopFormat;
+		}
+
+
+		private var _position:*;
+		private var _alignment:*;
+		private var _decimalAlignmentToken:*;
+
+		/**
+		 * Return the value of the style specified by the <code>styleProp</code> parameter
+		 * which specifies the style name.
+		 * 
+		 * @param styleProp The name of the style whose value is to be retrieved.
+		 * @return The value of the specified style.  The type varies depending on the type of the style being
+		 * accessed.  Returns <code>undefined</code> if the style is not set.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function getStyle(styleName:String):*
+		{ return this[styleName]; }
+
+		/**
+		 * Set the value of the style specified by the <code>styleProp</code> parameter
+		 * which specifies the style name to <code>value</code>.
+		 * 
+		 * @param styleProp The name of the style whose value is to be set.
+		 * @param value The value to set.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function setStyle(styleName:String,value:*):void
+		{ this[styleName] = value; }
+
+		/**
+		 * The position of the tab stop, in pixels, relative to the start edge of the column.
+		 * <p>Legal values are numbers from 0 to 10000 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of 0.</p>
+		 * @see FormatValue#INHERIT
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get position():*
+		{ return _position; }
+		public function set position(newValue:*):void
+		{ _position = positionProperty.setHelper(_position,newValue); }
+
+		[Inspectable(enumeration="start,center,end,decimal,inherit")]
+		/**
+		 * The tab alignment for this tab stop. 
+		 * <p>Legal values are TabAlignment.START, TabAlignment.CENTER, TabAlignment.END, TabAlignment.DECIMAL, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of TabAlignment.START.</p>
+		 * @see FormatValue#INHERIT
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.text.engine.TabAlignment
+		 */
+		public function get alignment():*
+		{ return _alignment; }
+		public function set alignment(newValue:*):void
+		{ _alignment = alignmentProperty.setHelper(_alignment,newValue); }
+
+		/**
+		 * The alignment token to be used if the alignment is DECIMAL.
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of null.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get decimalAlignmentToken():*
+		{ return _decimalAlignmentToken; }
+		public function set decimalAlignmentToken(newValue:*):void
+		{ _decimalAlignmentToken = decimalAlignmentTokenProperty.setHelper(_decimalAlignmentToken,newValue); }
+
+		/**
+		 * Creates a new TabStopFormat object. All settings are empty or, optionally, are initialized from the
+		 * supplied <code>initialValues</code> object.
+		 * 
+		 * @param initialValues optional instance from which to copy initial values.
+		 * 
+		 * @see #defaultFormat
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function TabStopFormat(initialValues:ITabStopFormat = null)
+		{
+			if (initialValues)
+				apply(initialValues);
+		}
+
+		/**
+		 * Copies TabStopFormat settings from the <code>values</code> ITabStopFormat instance into this TabStopFormat object.
+		 * If <code>values</code> is <code>null</code>, this TabStopFormat object is initialized with undefined values for all properties.
+		 * @param values optional instance from which to copy values.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function copy(values:ITabStopFormat):void
+		{
+			 if (values == null)
+				values = emptyTabStopFormat;
+			this.position = values.position;
+			this.alignment = values.alignment;
+			this.decimalAlignmentToken = values.decimalAlignmentToken;
+		}
+
+		/**
+		 * Concatenates the values of properties in the <code>incoming</code> ITabStopFormat instance
+		 * with the values of this TabStopFormat object. In this (the receiving) TabStopFormat object, properties whose values are <code>FormatValue.INHERIT</code>,
+		 * and inheriting properties whose values are <code>undefined</code> will get new values from the <code>incoming</code> object.
+		 * Non-inheriting properties whose values are <code>undefined</code> will get their default values.
+		 * All other property values will remain unmodified.
+		 * 
+		 * @param incoming instance from which values are concatenated.
+		 * @see org.apache.flex.textLayout.formats.FormatValue#INHERIT
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function concat(incoming:ITabStopFormat):void
+		{
+			this.position = positionProperty.concatHelper(this.position, incoming.position);
+			this.alignment = alignmentProperty.concatHelper(this.alignment, incoming.alignment);
+			this.decimalAlignmentToken = decimalAlignmentTokenProperty.concatHelper(this.decimalAlignmentToken, incoming.decimalAlignmentToken);
+		}
+
+		/**
+		 * Concatenates the values of properties in the <code>incoming</code> ITabStopFormat instance
+		 * with the values of this TabStopFormat object. In this (the receiving) TabStopFormat object, properties whose values are <code>FormatValue.INHERIT</code>,
+		 * and inheriting properties whose values are <code>undefined</code> will get new values from the <code>incoming</code> object.
+		 * All other property values will remain unmodified.
+		 * 
+		 * @param incoming instance from which values are concatenated.
+		 * @see org.apache.flex.textLayout.formats.FormatValue#INHERIT
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function concatInheritOnly(incoming:ITabStopFormat):void
+		{
+			this.position = positionProperty.concatInheritOnlyHelper(this.position, incoming.position);
+			this.alignment = alignmentProperty.concatInheritOnlyHelper(this.alignment, incoming.alignment);
+			this.decimalAlignmentToken = decimalAlignmentTokenProperty.concatInheritOnlyHelper(this.decimalAlignmentToken, incoming.decimalAlignmentToken);
+		}
+
+		/**
+		 * Replaces property values in this TabStopFormat object with the values of properties that are set in
+		 * the <code>incoming</code> ITabStopFormat instance. Properties that are <code>undefined</code> in the <code>incoming</code>
+		 * ITabStopFormat instance are not changed in this object.
+		 * 
+		 * @param incoming instance whose property values are applied to this TabStopFormat object.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function apply(incoming:ITabStopFormat):void
+		{
+			var val:*;
+
+			if ((val = incoming.position) !== undefined)
+				this.position = val;
+			if ((val = incoming.alignment) !== undefined)
+				this.alignment = val;
+			if ((val = incoming.decimalAlignmentToken) !== undefined)
+				this.decimalAlignmentToken = val;
+		}
+
+		/**
+		 * Compares properties in ITabStopFormat instance <code>p1</code> with properties in ITabStopFormat instance <code>p2</code>
+		 * and returns <code>true</code> if all properties match.
+		 * 
+		 * @param p1 instance to compare to <code>p2</code>.
+		 * @param p2 instance to compare to <code>p1</code>.
+		 * 
+		 * @return true if all properties match, false otherwise.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		static public function isEqual(p1:ITabStopFormat,p2:ITabStopFormat):Boolean
+		{
+			if (p1 == null)
+				p1 = emptyTabStopFormat;
+			if (p2 == null)
+				p2 = emptyTabStopFormat;
+			if (p1 == p2)
+				return true;
+
+			if (!positionProperty.equalHelper(p1.position, p2.position))
+				return false;
+			if (!alignmentProperty.equalHelper(p1.alignment, p2.alignment))
+				return false;
+			if (!decimalAlignmentTokenProperty.equalHelper(p1.decimalAlignmentToken, p2.decimalAlignmentToken))
+				return false;
+
+			return true;
+		}
+
+		/**
+		 * Sets properties in this TabStopFormat object to <code>undefined</code> if they match those in the <code>incoming</code>
+		 * ITabStopFormat instance.
+		 * 
+		 * @param incoming instance against which to compare this TabStopFormat object's property values.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function removeMatching(incoming:ITabStopFormat):void
+		{
+			if (incoming == null)
+				return;
+
+			if (positionProperty.equalHelper(this.position, incoming.position))
+				this.position = undefined;
+			if (alignmentProperty.equalHelper(this.alignment, incoming.alignment))
+				this.alignment = undefined;
+			if (decimalAlignmentTokenProperty.equalHelper(this.decimalAlignmentToken, incoming.decimalAlignmentToken))
+				this.decimalAlignmentToken = undefined;
+		}
+
+		/**
+		 * Sets properties in this TabStopFormat object to <code>undefined</code> if they do not match those in the
+		 * <code>incoming</code> ITabStopFormat instance.
+		 * 
+		 * @param incoming instance against which to compare this TabStopFormat object's property values.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function removeClashing(incoming:ITabStopFormat):void
+		{
+			if (incoming == null)
+				return;
+
+			if (!positionProperty.equalHelper(this.position, incoming.position))
+				this.position = undefined;
+			if (!alignmentProperty.equalHelper(this.alignment, incoming.alignment))
+				this.alignment = undefined;
+			if (!decimalAlignmentTokenProperty.equalHelper(this.decimalAlignmentToken, incoming.decimalAlignmentToken))
+				this.decimalAlignmentToken = undefined;
+		}
+
+		static private var _defaults:TabStopFormat;
+		/**
+		 * Returns a TabStopFormat object with default settings.
+		 * This function always returns the same object.
+		 * 
+		 * @return a singleton instance of ITabStopFormat that is populated with default values.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		static public function get defaultFormat():ITabStopFormat
+		{
+			if (_defaults == null)
+			{
+				_defaults = new TabStopFormat();
+				PropertyUtil.defaultsAllHelper(_description,_defaults);
+			}
+			return _defaults;
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/TableFrame.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/TableFrame.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/TableFrame.as
new file mode 100644
index 0000000..5270923
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/TableFrame.as
@@ -0,0 +1,113 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.formats
+{
+	/**
+	 *  Defines values for the <code>TableFrame</code> property of the TextLayoutFormat class. Specifies which 
+	 *  sides of the frame surrounding a table will be visible.  
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 *  @see TextLayoutFormat#TableFrame
+	 */
+	public final class TableFrame
+	{
+		/** No sides. This is the default value. 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		
+		public static const VOID:String = "void";
+		
+		/**  The top side only. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		
+		public static const ABOVE:String = "above";
+		
+		/** The bottom side only. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		
+		public static const BELOW:String = "below";
+		
+		/** The top and bottom sides only. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		
+		public static const HSIDES:String = "hsides";
+		
+		/**  The right and left sides only
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		
+		public static const VSIDES:String = "vsides";
+		
+		/** The left-hand side only. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		
+		public static const LHS:String = "lhs";
+		
+		/** The right-hand side only. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		
+		public static const RHS:String = "rhs";
+		
+		/** All four sides. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		
+		public static const BOX:String = "box";
+		
+		/** All four sides. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		
+		public static const BORDER:String = "border";
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/TableRules.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/TableRules.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/TableRules.as
new file mode 100644
index 0000000..f9a4bb4
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/TableRules.as
@@ -0,0 +1,77 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.formats
+{
+	/**
+	 *  Defines values for the <code>TableRules</code> property of the TextLayoutFormat class. Specifies which 
+	 *  rules will appear between cells within a table. The rendering of rules is user agent dependent.  
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 *  @see TextLayoutFormat#TableRules
+	 */
+	public final class TableRules
+	{
+		/** No sides. This is the default value. 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		
+		public static const NONE:String = "none";
+		
+		/**  Rules will appear between row groups (see THEAD, TFOOT, and TBODY) and column groups (see COLGROUP and COL) only. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		
+		public static const GROUPS:String = "groups";
+		
+		/** Rules will appear between rows only.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		
+		public static const ROWS:String = "rows";
+		
+		/** Rules will appear between columns only.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		
+		public static const COLS:String = "cols";
+		
+		/**  Rules will appear between all rows and columns.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		
+		public static const ALL:String = "all";
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/TextAlign.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/TextAlign.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/TextAlign.as
new file mode 100644
index 0000000..b97f07d
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/TextAlign.as
@@ -0,0 +1,91 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.formats
+{
+	/**
+	 *  Defines values for setting the <code>textAlign</code> and <code>textAlignLast</code> properties
+	 *  of the TextLayoutFormat class. The values describe the alignment of lines in the paragraph relative to the 
+	 *  container.
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 * @see TextLayoutFormat#textAlign 
+	 * @see TextLayoutFormat#textAlignLast 
+	 */
+	public final class TextAlign
+	{
+		/** Specifies start edge alignment - text is aligned to match the writing order. Equivalent to setting 
+		 * left in left-to-right text, or right in right-to-left text.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		 
+		public static const START:String = "start";
+		
+		/** Specifies end edge alignment - text is aligned opposite from the writing order. Equivalent to 
+		 *  specifying right in left-to-right text, or left in right-to-left text. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		 
+		public static const END:String = "end";
+		
+		/** Specifies left edge alignment. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		 
+		public static const LEFT:String = "left";
+		
+		/** Specifies right edge alignment. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		 
+		public static const RIGHT:String = "right";
+		
+		/** Specifies center alignment within the container.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		 
+		public static const CENTER:String = "center";
+		
+		/** Specifies that text is justified within the lines so they fill the container space.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		 
+		public static const JUSTIFY:String = "justify";
+		
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/TextDecoration.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/TextDecoration.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/TextDecoration.as
new file mode 100644
index 0000000..b0b8c62
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/TextDecoration.as
@@ -0,0 +1,53 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.formats
+{
+	/**
+	 *  Defines values for the <code>textDecoration</code> property
+	 *  of the TextLayoutFormat class. The values specify either normal text, with no decoration,
+	 *  or underline.
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 *  
+	 * @see TextLayoutFormat#textDecoration
+	 */
+	 
+	public final class TextDecoration
+	{
+		/** Specifies normal text - no decoration applied 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		 
+		public static const NONE:String = "none";
+		
+		/** Specifies that text is underlined. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		 
+		public static const UNDERLINE:String = "underline";
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/TextJustify.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/TextJustify.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/TextJustify.as
new file mode 100644
index 0000000..27f4a8f
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/TextJustify.as
@@ -0,0 +1,55 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.formats
+{
+	/**
+	 *  Defines values for setting the <code>textJustify</code> property of the TextLayoutFormat class. 
+	 *  Default value is INTER_WORD, meaning that extra space in justification is added to the space characters.
+	 *  DISTRIBUTE specifies that extra space is added both to space characters and between individual
+	 *  letters. Use these values only when setting <code>justificationRule</code> to SPACE.
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 *
+	 * @see TextLayoutFormat#textJustify
+	 * @see TextLayoutFormat#justificationRule
+	 */
+	public final class TextJustify
+	{
+		/** Specifies that justification is to add space both to space characters and 
+		 * between individual letters.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		 
+		public static const DISTRIBUTE:String = "distribute";
+		
+		/** Specifies that justification is to add space to space characters. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		 
+		public static const INTER_WORD:String = "interWord";
+	}
+}


[32/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/ContainerUtil.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/ContainerUtil.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/ContainerUtil.as
new file mode 100644
index 0000000..38b9bea
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/ContainerUtil.as
@@ -0,0 +1,30 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.container
+{
+	import org.apache.flex.core.IParentIUIBase;
+
+	public class ContainerUtil
+	{
+		static public function getController(container:IParentIUIBase,width:Number=100,height:Number=100):IContainerController
+		{
+			return new ContainerController(container,width,height);
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/IContainerController.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/IContainerController.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/IContainerController.as
new file mode 100644
index 0000000..66f34aa
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/IContainerController.as
@@ -0,0 +1,122 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.container
+{
+	import org.apache.flex.core.IUIBase;
+	import org.apache.flex.geom.Matrix;
+	import org.apache.flex.text.engine.ITextLine;
+	import org.apache.flex.textLayout.compose.ITextFlowLine;
+	import org.apache.flex.textLayout.edit.ISelectionManager;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.geom.Point;
+	import org.apache.flex.geom.Rectangle;
+	import org.apache.flex.textLayout.edit.SelectionFormat;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+	import org.apache.flex.textLayout.elements.IContainerFormattedElement;
+	import org.apache.flex.textLayout.compose.IFlowComposer;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.utils.ObjectMap;
+	import org.apache.flex.textLayout.elements.TableBlockContainer;
+	import org.apache.flex.textLayout.compose.ITextFlowTableBlock;
+	import org.apache.flex.textLayout.compose.TextFlowTableBlock;
+	import org.apache.flex.textLayout.elements.CellCoordinates;
+	import org.apache.flex.core.IParentIUIBase;
+	import org.apache.flex.textLayout.compose.FloatCompositionData;
+
+	public interface IContainerController
+	{
+		function get columnState():ColumnState;
+		function get columnCount():*;
+		function clearFloatsAt(absolutePosition:int):void;
+		function getFloatAtPosition(absolutePosition:int):FloatCompositionData;
+		function get numFloats():int;
+		function clearSelectionShapes():void;
+		function get horizontalScrollPosition():Number;
+		function get verticalScrollPosition():Number;
+		function get compositionWidth():Number;
+		function get compositionHeight():Number;
+		function get container():IParentIUIBase;
+		function get absoluteStart():int;
+		function get measureWidth():Boolean;
+		function get measureHeight():Boolean;
+		function addCellSelectionShapes(color:uint, tableBlock:ITextFlowTableBlock, startCoords:CellCoordinates, endCoords:CellCoordinates):void;
+		function get textLength():int;
+		function addComposedTableBlock(block:TableBlockContainer):void;
+		function clearCompositionResults():void;
+		function get interactiveObjects():ObjectMap;
+		function autoScrollIfNecessary(mouseX:int, mouseY:int):void;
+		function scrollToRange(activePosition:int, anchorPosition:int):void;
+		function get computedFormat():ITextLayoutFormat;
+		function get flowComposer():IFlowComposer;
+		function setTextLength(i:int):void;
+		function get contentWidth():Number;
+		function set horizontalScrollPosition(horizontalScrollPosition:Number):void;
+		function set verticalScrollPosition(verticalScrollPosition:Number):void;
+		function get contentHeight():Number;
+		function get rootElement():IContainerFormattedElement;
+		function get verticalScrollPolicy():String;
+
+		function get horizontalScrollPolicy():String;
+
+		function get format():ITextLayoutFormat;
+
+		function set format(format:ITextLayoutFormat):void;
+		function addSelectionShapes(selFormat:SelectionFormat, selectionAbsoluteStart:int, selectionAbsoluteEnd:int):void;
+		function getContentBounds():Rectangle;
+		function getTotalPaddingLeft():Number;
+		function getTotalPaddingTop():Number;
+		function getTotalPaddingRight():Number;
+		function getTotalPaddingBottom():Number;
+		function findCellAtPosition(localPoint:Point):CellCoordinates;
+		function setContentBounds(contentLeft:Number, contentTop:Number, contentWidth:Number, contentHeight:Number):void;
+		function clearComposedLines(absoluteStart:int):void;
+		function set finalParcelStart(finalParcelStart:int):void;
+		function get oldInteractiveObjects():Array;
+		function getFloatAt(floatIndex:int):FloatCompositionData;
+		function findFloatIndexAtOrAfter(absoluteStart:int):int;
+		function findFloatIndexAfter(i:int):int;
+		function get textFlow():ITextFlow;
+		function get composedLines():Array;
+		function setFocus():void;
+		function formatChanged(notifyModelChanged:Boolean = true):void;
+		function setRootElement(value:IContainerFormattedElement):void;
+		function dispose():void;
+		function interactionManagerChanged(newInteractionManager:ISelectionManager):void;
+		function updateCompositionShapes():void;
+		function getLastVisibleLine():ITextFlowLine;
+		function set shapesInvalid(shapesInvalid:Boolean):void;
+		function get shapesInvalid():Boolean;
+		function addComposedLine(textLine:ITextLine):void;
+		function addFloatAt(absolutePosition:int, float:IUIBase, floatType:String, x:Number, y:Number, alpha:Number, matrix:Matrix, depth:Number, knockOutWidth:Number, columnIndex:int, parent:IParentIUIBase):void
+		function testLineVisible(blockProgression:String, controllerVisibleBoundsXTW:int, controllerVisibleBoundsYTW:int, controllerVisibleBoundsWidthTW:int, controllerVisibleBoundsHeightTW:int, curLine:ITextFlowLine, textLine:ITextLine):*;
+		function get contentTop():Number;
+		function get contentLeft():Number;
+		function setTextLengthOnly(i:int):void;
+		function set paddingTop(paddingTop:*):void;
+		function set paddingBottom(paddingBottom:*):void;
+		function set paddingLeft(paddingLeft:*):void;
+		function set paddingRight(paddingRight:*):void;
+		function setCompositionSize(width:Number, compositionHeight:Number):void;
+		function getBackgroundShape():IUIBase;
+		function set verticalScrollPolicy(verticalScrollPolicy:String):void;
+		function set horizontalScrollPolicy(horizontalScrollPolicy:String):void;
+		function drawPointSelection(selFormat:SelectionFormat, x:Number, y:Number, width:Number, height:Number):void;
+
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/ISandboxSupport.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/ISandboxSupport.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/ISandboxSupport.as
new file mode 100644
index 0000000..b9a3445
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/ISandboxSupport.as
@@ -0,0 +1,72 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.container
+{
+	import org.apache.flex.events.Event;
+	/** Interface to support TLF content in a sub-application. When an application is loaded in an untrusted context,
+	 * mouse events that occur outside of the untrusted application's bounds are not delivered. Clients can handle this
+	 * by implementing ISandboxSupport. 
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 * 
+	 * @see org.apache.flex.textLayout.container.ContainerController
+	 * @see org.apache.flex.textLayout.container.TextContainerManager
+	 * @see org.apache.flex.textLayout.edit.SelectionManager
+	 * @see flash.system.SecurityDomain
+	 */
+	public interface ISandboxSupport
+	{
+		/** 
+		 * Called to request clients to begin the forwarding of mouseup and mousemove events from outside a security sandbox.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 */
+		function beginMouseCapture():void;
+		/** 
+		 * Called to inform clients that the the forwarding of mouseup and mousemove events from outside a security sandbox is no longer needed.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 */
+		function endMouseCapture():void;
+		/** Client call to forward a mouseUp event from outside a security sandbox.  Coordinates of the mouse up are not needed.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 */
+		function mouseUpSomewhere(event:Event):void;
+		/** Client call to forward a mouseMove event from outside a security sandbox.  Coordinates of the mouse move are not needed.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 */
+		function mouseMoveSomewhere(event:Event):void;
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/ITextContainerManager.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/ITextContainerManager.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/ITextContainerManager.as
new file mode 100644
index 0000000..173ba27
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/ITextContainerManager.as
@@ -0,0 +1,25 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.container
+{
+	public interface ITextContainerManager
+	{
+		function get compositionWidth():Number;
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/ScrollPolicy.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/ScrollPolicy.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/ScrollPolicy.as
new file mode 100644
index 0000000..0f391cf
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/ScrollPolicy.as
@@ -0,0 +1,84 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.container
+{
+	import org.apache.flex.textLayout.property.PropertyFactory;
+	import org.apache.flex.textLayout.property.Property;
+
+
+
+
+	/**
+	 *  The ScrollPolicy class is an enumeration class that defines values for setting the <code>horizontalScrollPolicy</code> and 
+	 *  <code>verticalScrollPolicy</code> properties of the ContainerController class, which defines a text flow 
+	 *  container. 
+	 *
+	 *  @see ContainerController#horizontalScrollPolicy
+	 *  @see ContainerController#verticalScrollPolicy
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	public final class ScrollPolicy
+	{
+		/** 
+		 * Specifies that scrolling is to occur if the content exceeds the container's dimension. The runtime calculates 
+		 * the number of lines that overflow the container and the user can navigate to them with cursor keys, by drag selecting,
+		 * or by rotating the mouse wheel. You can also cause scrolling to occur by setting the corresponding position value, 
+		 * either <code>ContainerController.horizontalScrollPosition</code> or <code>ContainerController.verticalScrollPosition</code>. Also, the runtime can automatically 
+		 * scroll the contents of the container during editing.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		public static const AUTO:String = "auto";
+		
+		/** 
+		 * Causes the runtime to not display overflow lines, which means that the user cannot navigate to them. 
+		 * In this case, setting the corresponding <code>ContainerController.horizontalScrollPosition</code> and 
+		 * <code>ContainerController.verticalScrollPosition</code> properties have no effect. 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		public static const OFF:String = "off";
+		
+		/** 
+		 * Specifies that scrolling is available to access content that exceeds the container's dimension. The runtime calculates the 
+		 * number of lines that overflow the container and allows the user to scroll them into view with the cursor keys, by drag selecting, 
+		 * or by rotating the mouse wheel. You can also scroll by setting the corresponding position value, either 
+		 * <code>ContainerController.horizontalScrollPosition</code> or <code>ContainerController.verticalScrollPosition</code>. Also, the runtime can automatically scroll the contents 
+		 * of the container during editing.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		public static const ON:String = "on";		
+		
+		/** Shared definition of the scrollPolicy property. @private */
+		static public const scrollPolicyPropertyDefinition:Property = PropertyFactory.enumString("scrollPolicy", ScrollPolicy.AUTO, false, null, 
+			ScrollPolicy.AUTO, ScrollPolicy.OFF, ScrollPolicy.ON);	
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/TMContainerController.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/TMContainerController.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/TMContainerController.as
new file mode 100644
index 0000000..ed7be1b
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/TMContainerController.as
@@ -0,0 +1,147 @@
+// //////////////////////////////////////////////////////////////////////////////
+//
+// 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
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// //////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.container
+{
+	import org.apache.flex.core.IParentIUIBase;
+	import org.apache.flex.core.IUIBase;
+	import org.apache.flex.text.engine.ITextLine;
+	import org.apache.flex.textLayout.dummy.ContextMenu;
+	import org.apache.flex.textLayout.edit.IInteractionEventHandler;
+	import org.apache.flex.textLayout.formats.BlockProgression;
+
+	public class TMContainerController extends ContainerController
+	{
+		private var _inputManager:TextContainerManager;
+
+		public function TMContainerController(container:IParentIUIBase, compositionWidth:Number, compositionHeight:Number, tm:TextContainerManager)
+		{
+			super(container, compositionWidth, compositionHeight);
+			_inputManager = tm;
+			verticalScrollPolicy = tm.verticalScrollPolicy;
+			horizontalScrollPolicy = tm.horizontalScrollPolicy;
+		}
+
+		public function get textContainerManager():TextContainerManager
+		{
+			return _inputManager;
+		}
+
+		/** Reroute to the TextContainerManger's override.  Reuse the one that's already been created. */
+		protected override function createContextMenu():ContextMenu
+		{
+			return _inputManager.getContextMenu();
+		}
+
+		/** @private */
+		protected override function get attachTransparentBackground():Boolean
+		{
+			return false;
+		}
+
+		/** @private */
+		public function doUpdateVisibleRectangle():void
+		{
+			updateVisibleRectangle();
+		}
+
+		/** @private. Override clones and enhances parent class functionality. */
+		protected override function updateVisibleRectangle():void
+		{
+			var xpos:Number;
+			var ypos:Number;
+			// see the adjustLines boolean in ContainerController.fillShapeChildren - this logic clones that and allows for skipping the scrollRect
+			xpos = horizontalScrollPosition;
+			if (effectiveBlockProgression == BlockProgression.RL && (verticalScrollPolicy != ScrollPolicy.OFF || horizontalScrollPolicy != ScrollPolicy.OFF))
+				xpos -= !isNaN(compositionWidth) ? compositionWidth : contentWidth;
+
+			ypos = verticalScrollPosition;
+
+			_hasScrollRect = _inputManager.drawBackgroundAndSetScrollRect(xpos, ypos);
+		}
+
+		/** @private */
+		public override function getInteractionHandler():IInteractionEventHandler
+		{
+			return _inputManager;
+		}
+
+		/** @private */
+		public override function attachContextMenu():void
+		{
+			if (_inputManager.getContextMenu() != null)
+				super.attachContextMenu();
+		}
+
+		/** @private */
+		public override function removeContextMenu():void
+		{
+			// otherwise client is managing it
+			if (_inputManager.getContextMenu())
+				super.removeContextMenu();
+		}
+
+		// ////////////////////////////////////////////////////////////////////////////
+		// push all these methods for manipulating the object list to the _inputmanager
+		// ////////////////////////////////////////////////////////////////////////////
+		protected override function getFirstTextLineChildIndex():int
+		{
+			return _inputManager.getFirstTextLineChildIndex();
+		}
+
+		protected override function addTextLine(textLine:ITextLine, index:int):void
+		{
+			_inputManager.addTextLine(textLine, index);
+		}
+
+		protected override function removeTextLine(textLine:ITextLine):void
+		{
+			_inputManager.removeTextLine(textLine);
+		}
+
+		protected override function addBackgroundShape(shape:IUIBase):void
+		{
+			_inputManager.addBackgroundShape(shape);
+		}
+
+		protected override function removeBackgroundShape(shape:IUIBase):void
+		{
+			_inputManager.removeBackgroundShape(shape);
+		}
+
+		protected override function addSelectionContainer(selectionContainer:IParentIUIBase):void
+		{
+			_inputManager.addSelectionContainer(selectionContainer);
+		}
+
+		protected override function removeSelectionContainer(selectionContainer:IParentIUIBase):void
+		{
+			_inputManager.removeSelectionContainer(selectionContainer);
+		}
+
+		protected override function addInlineGraphicElement(parent:IParentIUIBase, inlineGraphicElement:IUIBase, index:int):void
+		{
+			_inputManager.addInlineGraphicElement(parent, inlineGraphicElement, index);
+		}
+
+		protected override function removeInlineGraphicElement(parent:IParentIUIBase, inlineGraphicElement:IUIBase):void
+		{
+			_inputManager.removeInlineGraphicElement(parent, inlineGraphicElement);
+		}
+	}
+}
\ No newline at end of file


[30/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/BaseTextLayoutExporter.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/BaseTextLayoutExporter.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/BaseTextLayoutExporter.as
new file mode 100644
index 0000000..5437104
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/BaseTextLayoutExporter.as
@@ -0,0 +1,536 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion
+{
+	import org.apache.flex.reflection.getQualifiedClassName;
+	import org.apache.flex.textLayout.TextLayoutVersion;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.elements.FlowGroupElement;
+	import org.apache.flex.textLayout.elements.IContainerFormattedElement;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	import org.apache.flex.textLayout.elements.IParagraphFormattedElement;
+	import org.apache.flex.textLayout.elements.SpanElement;
+	import org.apache.flex.textLayout.elements.TableCellElement;
+	import org.apache.flex.textLayout.elements.TableElement;
+	import org.apache.flex.textLayout.elements.TableRowElement;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	
+	/** 
+	 * Base export converter for TextLayout format. 
+	 */
+	public class BaseTextLayoutExporter extends ConverterBase implements ITextExporter
+	{
+		private var _rootTag:XML;
+		private var _ns:Namespace;
+		
+		public function BaseTextLayoutExporter(ns:Namespace, rootTag:XML, configuration:ImportExportConfiguration)
+		{
+			config = configuration;
+			_ns = ns;
+			_rootTag = rootTag;
+		}
+		
+		/** 
+		 * @copy ITextExporter#export()
+		 */
+		public function export(source:ITextFlow, conversionType:String):Object
+		{
+			clear();
+			
+			var result:XML = exportToXML(source);
+			return conversionType == ConversionType.STRING_TYPE ? convertXMLToString(result) : result;
+		}
+		
+		/** 
+		 * Export text content of a TextFlow into XFL format.
+		 * 
+		 * @param source	the text to export
+		 * @return XML	the exported content
+		 */
+		protected function exportToXML(textFlow:ITextFlow) : XML
+		{
+			var result:XML;
+			if (_rootTag)
+			{
+				result = new XML(_rootTag);
+				result.addNamespace(_ns);
+				result.appendChild(exportChild(textFlow));
+			}
+			else
+			{
+				result = XML(exportTextFlow(this, textFlow));
+				result.addNamespace(_ns);
+			}
+			return result;
+		}
+		
+		/** 
+		 * Export text content as a string
+		 * 
+		 * @param xml	the XML to convert
+		 * @return String	the exported content
+		 * @private
+		 */
+		static public function convertXMLToString(xml:XML):String
+		{
+			var result:String;
+			// Adjust settings so that leading and trailing spaces in the XML don't get dropped when it is converted to a string
+			var originalSettings:Object = XML.settings();
+			try
+			{
+				XML.ignoreProcessingInstructions = false;		
+				XML.ignoreWhitespace = false;
+				XML.prettyPrinting = false;
+				result = xml.toXMLString();
+//TODO probably does not make sense for FlexJS
+//				if (Configuration.playerEnablesArgoFeatures)
+//					System["disposeXML"](xml);
+				XML.setSettings(originalSettings);
+			}
+			catch(e:Error)
+			{
+				XML.setSettings(originalSettings);
+				throw(e);
+			}		
+			return result;
+		}
+
+	
+		/** 
+		 * Base functionality for exporting a FlowElement.
+		 *  
+		 * @param exporter	Root object for the export
+		 * @param flowElement	Element to export
+		 * @return XMLList	XML for the element
+		 */
+		static public function exportFlowElement(exporter:BaseTextLayoutExporter, flowElement:IFlowElement):XMLList
+		{
+			return exporter.exportFlowElement(flowElement);
+		}
+		
+		/** 
+		 * Overridable worker method for exporting a FlowElement. Creates the XMLList.
+		 * 
+		 * @param flowElement	Element to export
+		 * @return XMLList	XML for the element
+		 */
+		protected function exportFlowElement (flowElement:IFlowElement):XMLList
+		{
+			var className:String = getQualifiedClassName(flowElement);
+			var elementName:String = config.lookupName(className);	// NO PMD
+			var output:XML = <{elementName}/>;
+			output.setNamespace(_ns);
+			return XMLList(output);
+		}
+		
+		static public function exportSpanText(destination:XML, span:SpanElement, replacementRegex:RegExp, replacementXMLCallback:Function):void
+		{
+			//get the text for this span
+			var spanText:String = span.text;
+
+			// Check to see if it has text that needs to be converted			
+			var matchLocation:Array = spanText.match(replacementRegex);
+			
+			if(matchLocation)	
+			{
+				var dummy:XML;
+				
+				// We have text that has characters to be converted. Break it up into runs of text interspersed with elements corresponding to match these characters
+				while(matchLocation != null)
+				{
+					var ix:int = matchLocation.index;
+					var tempStr:String = spanText.substr(0, ix);
+					
+					//if we have some text which does not need to be replaced, then write it now
+					if(tempStr.length > 0)
+					{
+						// output[0].appendChild(tempStr); // extraneous tags can appear around a string child added after an XML element: see bug 1852072  
+						
+						// workaround for above-mentioned bug
+						dummy = <dummy/>;
+						dummy.appendChild(tempStr); // no extraneous tags here since there is no preceding XML element sibling
+						destination.appendChild(dummy.text()[0]);
+					}
+					
+					var replacementXML:XML = replacementXMLCallback(spanText.charAt(ix));
+					CONFIG::debug{ assert(replacementXML != null, "Specified match regex, but provided null replacement XML"); }
+					destination.appendChild(replacementXML);
+					
+					//remove the text up to this point
+					spanText = spanText.slice(ix + 1, spanText.length);
+					
+					//look for another character to be replaced
+					matchLocation = spanText.match(replacementRegex);
+					
+					//if we don't have any more matches, but there is still text, write that out as the last span
+					if(!matchLocation && spanText.length > 0)
+					{
+						// output[0].appendChild(spanText); // extraneous tags can appear around a string child added after an XML element: see bug 1852072  
+						
+						// workaround for above-mentioned bug
+						dummy = <dummy/>;
+						dummy.appendChild(spanText); // no extraneous tags here since there is no preceding XML element sibling
+						destination.appendChild(dummy.text()[0]);
+					}
+				}
+			}
+			else
+			{
+				//this is the simple case where we don't have a character to replace
+				destination.appendChild(spanText);
+			}		
+		}  
+		
+		/** 
+		 * Base functionality for exporting a Span. Exports as a FlowElement,
+		 * and exports the text of the span.
+		 * 
+		 * @param exporter	Root object for the export
+		 * @param span	Element to export
+		 * @return XMLList	XML for the element
+		 */
+		static public function exportSpan(exporter:BaseTextLayoutExporter, span:SpanElement):XMLList
+		{
+			var output:XMLList = exportFlowElement(exporter, span);	
+			exportSpanText(output[0], span, exporter.spanTextReplacementRegex, exporter.getSpanTextReplacementXML);
+			return output;
+		}
+		
+//TODO regex
+		static private const brRegEx:RegExp = /foo/;// /\u2028/;
+		// static private const brRegEx:RegExp = /\u2028/;
+		
+		/** 
+		 * Gets the regex that specifies characters in span text to be replaced with XML elements.
+		 *  Note: Each match is a single character 
+		 */
+		protected function get spanTextReplacementRegex():RegExp
+		{
+			return brRegEx;
+		}
+
+		/** 
+		 * Gets the xml element used to represent a character in the export format
+		 */
+		protected function getSpanTextReplacementXML(ch:String):XML
+		{
+			CONFIG::debug {assert(ch == '\u2028', "Did not recognize character to be replaced with XML"); }
+			var breakXML:XML = <br/>;
+			breakXML.setNamespace(flowNS);
+			return breakXML;
+		}
+		
+		/** 
+		 * Base functionality for exporting a FlowGroupElement. Exports as a FlowElement,
+		 * and exports the children of a element.
+		 * 
+		 * @param exporter	Root object for the export
+		 * @param flowBlockElement	Element to export
+		 * @return XMLList	XML for the element
+		 */
+		static public function exportFlowGroupElement(exporter:BaseTextLayoutExporter, flowBlockElement:FlowGroupElement):XMLList
+		{
+			var output:XMLList = exportFlowElement(exporter, flowBlockElement);
+			var count:int = flowBlockElement.numChildren;
+			
+			// output each child
+			for(var index:int; index < count; ++index)
+			{
+				var flowChild:IFlowElement = flowBlockElement.getChildAt(index);
+				var childXML:XMLList = exporter.exportChild(flowChild);
+				
+				if (childXML) {
+					output.appendChild(childXML);
+				}
+			}
+			
+			return output;
+		}
+
+		/** 
+		 * Base functionality for exporting a IParagraphFormattedElement. Exports as a FlowGroupElement,
+		 * and exports paragraph attributes.
+		 * 
+		 * @param exporter	Root object for the export
+		 * @param flowParagraph	Element to export
+		 * @return XMLList	XML for the element
+		 */
+		static public function exportParagraphFormattedElement(exporter:BaseTextLayoutExporter, flowParagraph:IParagraphFormattedElement):XMLList
+		{
+			return exporter.exportParagraphFormattedElement(flowParagraph);
+		}
+		
+		static public function exportList(exporter:BaseTextLayoutExporter, flowParagraph:IParagraphFormattedElement):XMLList
+		{
+			return exporter.exportList(flowParagraph);
+		}
+		
+		protected function exportList(flowElement:IFlowElement):XMLList
+		{
+			var result:XMLList = exportFlowElement(flowElement);
+			var count:int = FlowGroupElement(flowElement).numChildren;
+			
+			// output each child
+			for(var index:int; index < count; ++index)
+			{
+				var flowChild:IFlowElement = FlowGroupElement(flowElement).getChildAt(index);
+				result.appendChild(exportChild(flowChild));
+			}
+			
+			return result;
+		}
+		
+		static public function exportListItem(exporter:BaseTextLayoutExporter, flowParagraph:IParagraphFormattedElement):XMLList
+		{
+			return exporter.exportListItem(flowParagraph);
+		}
+		
+		protected function exportListItem(flowElement:IFlowElement):XMLList
+		{
+			var result:XMLList = exportFlowElement(flowElement);
+			var count:int = FlowGroupElement(flowElement).numChildren;
+			
+			// output each child
+			for(var index:int; index < count; ++index)
+			{
+				var flowChild:IFlowElement = FlowGroupElement(flowElement).getChildAt(index);
+				result.appendChild(exportChild(flowChild));
+			}
+			
+			return result;
+		}
+		
+		/** 
+		 * Base functionality for exporting a IContainerFormattedElement. Exports as a IParagraphFormattedElement,
+		 * and exports container attributes.
+		 * 
+		 * @param exporter	Root object for the export
+		 * @param container	Element to export
+		 * @return XMLList	XML for the element
+		 */
+		static public function exportContainerFormattedElement(exporter:BaseTextLayoutExporter, container:IContainerFormattedElement):XMLList
+		{
+			return exporter.exportContainerFormattedElement(container);
+		}
+		
+		/** 
+		 * Overridable worker method for exporting a IParagraphFormattedElement. Creates the XMLList.
+		 * 
+		 * @param flowElement	Element to export
+		 * @return XMLList	XML for the element
+		 */
+		protected function exportContainerFormattedElement(flowElement:IFlowElement):XMLList
+		{
+			return exportParagraphFormattedElement(flowElement);
+		}
+		
+		/** 
+		 * Base functionality for exporting a TableElement. Exports as a TableElement,
+		 * and exports table attributes.
+		 * 
+		 * @param exporter	Root object for the export
+		 * @param container	Element to export
+		 * @return XMLList	XML for the element
+		 */
+		static public function exportTableElement(exporter:BaseTextLayoutExporter, table:TableElement):XMLList
+		{
+			return exporter.exportTableElement(table);
+		}
+		
+		/** 
+		 * Overridable worker method for exporting a TableElement. Creates the XMLList.
+		 * 
+		 * @param flowElement	Element to export
+		 * @return XMLList	XML for the element
+		 */
+		protected function exportTableElement(tableElement:TableElement):XMLList
+		{
+			var result:XMLList = exportFlowElement(tableElement);
+			var count:int = tableElement.numRows;
+			
+			// output each child
+			for(var index:int = 0; index < count; ++index)
+			{
+				var flowChild:IFlowElement = tableElement.getRowAt(index);
+				result.appendChild(exportChild(flowChild));
+			}
+			
+			return result;
+		}
+		
+		/** 
+		 * Base functionality for exporting a TableRowElement. Exports as a TableRowElement,
+		 * and exports table row attributes.
+		 * 
+		 * @param exporter	Root object for the export
+		 * @param container	Element to export
+		 * @return XMLList	XML for the element
+		 */
+		static public function exportTableRowElement(exporter:BaseTextLayoutExporter, tableRow:TableRowElement):XMLList
+		{
+			return exporter.exportTableRowElement(tableRow);
+		}
+		
+		/** 
+		 * Overridable worker method for exporting a TableRowElement. Creates the XMLList.
+		 * 
+		 * @param flowElement	Element to export
+		 * @return XMLList	XML for the element
+		 */
+		protected function exportTableRowElement(tableRowElement:TableRowElement):XMLList
+		{
+			var result:XMLList = exportFlowElement(tableRowElement);
+			var count:int = tableRowElement.numCells;
+			
+			// output each child
+			for(var index:int; index < count; ++index)
+			{
+				var flowChild:IFlowElement = tableRowElement.getCellAt(index);
+				result.appendChild(exportChild(flowChild));
+			}
+			
+			return result;
+		}
+		
+		/** 
+		 * Base functionality for exporting a TableCellElement. Exports as a TableCellElement,
+		 * and exports table cell attributes.
+		 * 
+		 * @param exporter	Root object for the export
+		 * @param container	Element to export
+		 * @return XMLList	XML for the element
+		 */
+		static public function exportTableCellElement(exporter:BaseTextLayoutExporter, tableCell:TableCellElement):XMLList
+		{
+			return exporter.exportTableCellElement(tableCell);
+		}
+		
+		/** 
+		 * Overridable worker method for exporting a TableCellElement. Creates the XMLList.
+		 * 
+		 * @param flowElement	Element to export
+		 * @return XMLList	XML for the element
+		 */
+		protected function exportTableCellElement(tableCellElement:TableCellElement):XMLList
+		{
+			var result:XMLList = exportFlowElement(tableCellElement);
+			
+			return result;
+		}
+		
+		/** 
+		 * Overridable worker method for exporting a IParagraphFormattedElement. Creates the XMLList.
+		 * 
+		 * @param flowElement	Element to export
+		 * @return XMLList	XML for the element
+		 */
+		protected function exportParagraphFormattedElement(flowElement:IFlowElement):XMLList
+		{
+			var result:XMLList = exportFlowElement(flowElement);
+			var count:int = IParagraphFormattedElement(flowElement).numChildren;
+			
+			// output each child
+			for(var index:int; index < count; ++index)
+			{
+				var flowChild:IFlowElement = IParagraphFormattedElement(flowElement).getChildAt(index);
+				result.appendChild(exportChild(flowChild));
+			}
+			
+			return result;
+		}
+		
+		/** 
+		 * Base functionality for exporting a TextFlow. Exports as a ContainerElement,
+		 * and exports container attributes.
+		 * 
+		 * @param exporter	Root object for the export
+		 * @param textFlow	Element to export
+		 * @return XMLList	XML for the element
+		 */
+		static public function exportTextFlow(exporter:BaseTextLayoutExporter, textFlow:ITextFlow):XMLList
+		{
+			var output:XMLList = exportContainerFormattedElement(exporter, textFlow);
+			
+			if (exporter.config.whiteSpaceCollapse) {
+				// TextLayout will use PRESERVE on output
+//TODO @
+				// output.@[TextLayoutFormat.whiteSpaceCollapseProperty.name] = exporter.config.whiteSpaceCollapse;
+			}
+			
+			// TextLayout adds version information
+			output.@version = TextLayoutVersion.getVersionString(TextLayoutVersion.CURRENT_VERSION);
+						
+			return output;
+		}
+
+
+		/** 
+		 * Exports the object. It will find the appropriate exporter and use it to 
+		 * export the object.
+		 * 
+		 * @param exporter	Root object for the export
+		 * @param flowElement	Element to export
+		 * @return XMLList	XML for the flowElement
+		 */
+		public function exportChild(flowElement:IFlowElement):XMLList
+		{
+			var className:String = getQualifiedClassName(flowElement);
+			var info:FlowElementInfo = config.lookupByClass(className);
+			if (info != null)
+				return info.exporter(this, flowElement);
+			return null;
+		}
+					
+		/** 
+		 * Helper function to export styles (core or user) in the form of xml attributes or xml children.
+		 * 
+		 * @param xml object to which attributes/children are added 
+		 * @param sortableStyles an array of objects (xmlName,xmlVal) members that is sorted and exported.
+		 */
+		protected function exportStyles(xml:XMLList, sortableStyles:Array):void
+		{
+			// Sort the styles based on name for predictable export order
+			sortableStyles.sortOn("xmlName");
+			
+			for each(var exportInfo:Object in sortableStyles)
+            {
+            	var xmlVal:Object = exportInfo.xmlVal;
+				CONFIG::debug{ assert(useClipboardAnnotations || exportInfo.xmlName != ConversionConstants.MERGE_TO_NEXT_ON_PASTE, "Found paste merge attribute in exported TextFlow"); }
+				/* Filter out paste attributes */
+				if (!useClipboardAnnotations && exportInfo.xmlName == ConversionConstants.MERGE_TO_NEXT_ON_PASTE)
+					continue;
+//TODO @
+            	// if (xmlVal is String)
+				// 	xml.@[exportInfo.xmlName] = xmlVal; // as an attribute
+				// else if (xmlVal is XMLList)
+					xml.appendChild(xmlVal);			// as a child 
+            }  
+		}
+
+		internal function get flowNS():Namespace
+		{
+			return _ns;
+		}
+
+		protected function get formatDescription():Object
+		{
+			return null;
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/BaseTextLayoutImporter.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/BaseTextLayoutImporter.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/BaseTextLayoutImporter.as
new file mode 100644
index 0000000..dc9cd2f
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/BaseTextLayoutImporter.as
@@ -0,0 +1,717 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion 
+{
+	import org.apache.flex.textLayout.utils.FactoryUtil;
+	import org.apache.flex.textLayout.TextLayoutVersion;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.elements.BreakElement;
+	import org.apache.flex.textLayout.elements.ElementHelper;
+	import org.apache.flex.textLayout.elements.FlowGroupElement;
+	import org.apache.flex.textLayout.elements.GlobalSettings;
+	import org.apache.flex.textLayout.elements.IConfiguration;
+	import org.apache.flex.textLayout.elements.IContainerFormattedElement;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	import org.apache.flex.textLayout.elements.IFlowGroupElement;
+	import org.apache.flex.textLayout.elements.IFlowLeafElement;
+	import org.apache.flex.textLayout.elements.IListElement;
+	import org.apache.flex.textLayout.elements.IListItemElement;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.IParagraphFormattedElement;
+	import org.apache.flex.textLayout.elements.ISpanElement;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.textLayout.elements.SpanElement;
+	import org.apache.flex.textLayout.elements.TabElement;
+	import org.apache.flex.textLayout.elements.TableCellElement;
+	import org.apache.flex.textLayout.elements.TextFlow;
+	import org.apache.flex.textLayout.factory.ITLFFactory;
+	import org.apache.flex.textLayout.factory.StandardTLFFactory;
+	import org.apache.flex.textLayout.property.Property;
+	import org.apache.flex.textLayout.property.PropertyUtil;
+
+	/**
+	 * BaseTextLayoutImporter is a base class for handling the import/export of TextLayout text 
+	 * in the native format.
+	 */ 
+	internal class BaseTextLayoutImporter extends ConverterBase implements ITextImporter
+	{	
+		private var _ns:Namespace;		// namespace of expected in imported/exported content
+		
+		private var _textFlowNamespace:Namespace; // namespace of the TextFlow element against which the namespaces of the following elements are validated
+				
+		protected var _config:ImportExportConfiguration;
+		protected var _textFlowConfiguration:IConfiguration = null;
+		protected var _importVersion:uint;
+		
+		// static private const anyPrintChar:RegExp = /[^\s]/g;
+		// Consider only tab, line feed, carriage return, and space as characters used for pretty-printing. 
+		// While debatable, this is consistent with what CSS does. 
+		static private const anyPrintChar:RegExp = /foo/;// = /[^\u0009\u000a\u000d\u0020]/g; 
+//TODO
+		// static private const anyPrintChar:RegExp = /[^\u0009\u000a\u000d\u0020]/g; 
+
+		public function BaseTextLayoutImporter(nsValue:Namespace, config:ImportExportConfiguration)
+		{
+			_ns = nsValue;
+			_config = config;
+		}
+		
+		public override function clear():void
+		{
+			super.clear();
+			_textFlowNamespace = null;
+			_impliedPara = null;
+		}
+		
+		/** @copy ITextImporter#importToFlow()
+		 */
+		public function importToFlow(source:Object):ITextFlow
+		{
+			clear();		// empty results of previous imports
+			
+			if (throwOnError)
+				return importToFlowCanThrow(source);
+			
+			var rslt:TextFlow = null;
+			var savedErrorHandler:Function = PropertyUtil.errorHandler;
+			try
+			{
+				PropertyUtil.errorHandler = importPropertyErrorHandler;
+				rslt = importToFlowCanThrow(source);
+			}
+			catch (e:Error)
+			{
+				reportError(e.toString());
+			}
+			PropertyUtil.errorHandler = savedErrorHandler;
+			return rslt;
+		}
+		
+		/** @copy ITextImporter#get configuration()
+		 */
+		public function get configuration():IConfiguration
+		{
+			return _textFlowConfiguration;
+		}
+		
+		public function set configuration(value:IConfiguration):void
+		{
+			_textFlowConfiguration = value;
+		}
+
+		/** @private */
+		protected function importPropertyErrorHandler(p:Property,value:Object):void
+		{
+			reportError(PropertyUtil.createErrorString(p,value));
+		}
+		
+		private function importToFlowCanThrow(source:Object):TextFlow
+		{
+			if (source is String)
+				return importFromString(String(source));
+			else if (source is XML)
+				return importFromXML(XML(source));
+			return null;
+		}
+		
+		/** Parse and convert input data.
+		 * 
+		 * @param source - a string which is in XFL format. String is applied to an XML object then passed
+		 * to importFromXML to be processed.  The source must be capable of being cast as an XML
+		 * object (E4X). 
+		 */
+		protected function importFromString(source:String):TextFlow
+		{
+			var originalSettings:Object = XML.settings();
+			try
+			{
+				XML.ignoreProcessingInstructions = false;		
+				XML.ignoreWhitespace = false;
+				var xmlTree:XML = new XML(source);				
+			}			
+			finally
+			{
+				XML.setSettings(originalSettings);
+			}	
+			
+			var textFlow:TextFlow = importFromXML(xmlTree);
+//TODO probably does not make sense for FlexJS
+//			if (Configuration.playerEnablesArgoFeatures)
+//				System["disposeXML"](xmlTree);
+			return textFlow;
+		}
+		
+		/** Parse and convert input data.
+		 * 
+		 * xflSource is a XFL formated object which must be capable of being cast as an XML
+		 * object (E4X). 
+		 */
+		protected function importFromXML(xmlSource:XML):TextFlow
+			// Parse an XFL hierarchy into a TextFlow, using the geometry supplied by a TextFrame
+			// to host child containers (e.g. tables). This is the main entry point into this class.
+		{
+			return parseContent(xmlSource[0]);
+		}
+		
+		// This routine imports a TextFlow
+		protected function parseContent(rootStory:XML):TextFlow
+		{
+			// If the root element isn't a textFlow we know how to parse, keep descending the hierarchy.
+			var child:XML = rootStory..*::TextFlow[0];
+			if (child)
+				return parseTextFlow(this, rootStory);
+			return null;
+		}
+		
+		/** Returns the namespace used in for writing XML/XFL
+		 * 
+		 * @return the Namespace being used.
+		 */
+		public function get ns(): Namespace
+		{
+			return _ns;
+		}
+		
+		// Remove double spaces, tabs, and newlines.
+		// If I have a sequence of different sorts of spaces (e.g., en quad, hair space), would I want them converted down to one space? Probably not.
+		// For now, u0020 is the only space character we consider for eliminating duplicates, though u00A0 (non-breaking space) is potentially eligible. 
+//		static private const dblSpacePattern:RegExp = /[\u0020]{2,}/g;
+		// Tab, line feed, and carriage return
+//TODO regex
+		static private const tabNewLinePattern:RegExp = /foo/g;
+		// static private const tabNewLinePattern:RegExp = /[\u0009\u000a\u000d]/g;
+		protected static function stripWhitespace(insertString:String):String
+		{
+			// Replace the newlines and tabs inside the element with spaces.
+			return insertString.replace(tabNewLinePattern, " ");
+		}
+
+		/** Parse XML and convert to  TextFlow. 
+		 * @param importer		parser object
+		 * @param xmlToParse	content to parse
+		 * @param parent always null - this parameter is only provided to match FlowElementInfo.importer signature
+		 * @return TextFlow	the new TextFlow created as a result of the parse
+		 */
+		static public function parseTextFlow(importer:BaseTextLayoutImporter, xmlToParse:XML, parent:Object=null):TextFlow
+		{
+			return importer.createTextFlowFromXML(xmlToParse, null);
+		}		
+		
+		/** 
+		 * Static method to parse the supplied XML into a paragrph. 
+		 * Parse the <p ...> tag and it's children.
+		 * 
+		 * @param importer	parser object
+		 * @param xmlToParse	content to parse
+		 * @param parent 		the parent for the new content
+		 */
+		static public function parsePara(importer:BaseTextLayoutImporter, xmlToParse:XML, parent:FlowGroupElement):void
+		{
+			var paraElem:IParagraphElement = importer.createParagraphFromXML(xmlToParse);
+			if (importer.addChild(parent, paraElem))
+			{
+				importer.parseFlowGroupElementChildren(xmlToParse, paraElem);
+				//if parsing an empty paragraph, create a Span for it.
+				if (paraElem.numChildren == 0)
+					paraElem.addChild(new SpanElement());
+			}
+		}
+		
+		static protected function copyAllStyleProps(dst:IFlowLeafElement,src:IFlowLeafElement):void
+		{
+			dst.format = src.format;
+			dst.typeName	= src.typeName;
+			dst.id          = src.id;
+		}
+		
+		/** 
+		 * Static method for constructing a span from XML. Parse the <span> ... </span> tag. 
+		 * Insert the span into its parent
+		 * 
+		 * @param importer	parser object
+		 * @param xmlToParse	content to parse
+		 * @param parent 		the parent for the new content
+		 */
+		static public function parseSpan(importer:BaseTextLayoutImporter, xmlToParse:XML, parent:IFlowGroupElement):void
+		{
+			var firstSpan:ISpanElement = importer.createSpanFromXML(xmlToParse);
+			
+			var elemList:XMLList = xmlToParse[0].children();
+			if(elemList.length() == 0)
+			{
+				// Empty span, but may have formatting, so don't strip it out. 
+				// Note: the normalizer may yet strip it out if it is not the last child, but that's the normalizer's business.
+				importer.addChild(parent, firstSpan); 
+				return;
+			}
+	
+			for each (var child:XML in elemList) 
+			{
+				var elemName:String = child.name() ? child.name().localName : null;
+					
+				if (elemName == null) // span text
+				{
+					if (firstSpan.parent == null)	// hasn't been used yet
+					{
+						firstSpan.text = child.toString();
+						importer.addChild(parent, firstSpan);
+					}
+					else
+					{
+						var s:SpanElement = new SpanElement();	// No PMD
+						copyAllStyleProps(s,firstSpan);
+						s.text = child.toString();
+						importer.addChild(parent, s);
+					}
+				}
+				else if (elemName == "br")
+				{
+					var brElem:BreakElement = importer.createBreakFromXML(child);	// may be null
+					if (brElem)
+					{
+						copyAllStyleProps(brElem,firstSpan);
+						importer.addChild(parent, brElem);
+					}
+					else
+						importer.reportError(GlobalSettings.resourceStringFunction("unexpectedXMLElementInSpan",[ elemName ]));
+				}
+				else if (elemName == "tab")
+				{
+					var tabElem:TabElement = importer.createTabFromXML(child);	// may be null
+					if (tabElem)
+					{
+						copyAllStyleProps(tabElem,firstSpan);
+						importer.addChild(parent, tabElem);
+					}
+					else
+						importer.reportError(GlobalSettings.resourceStringFunction("unexpectedXMLElementInSpan",[ elemName ]));
+				}
+				else
+					importer.reportError(GlobalSettings.resourceStringFunction("unexpectedXMLElementInSpan",[ elemName ]));				
+			}
+		}
+		
+		/** 
+		 * Static method for constructing a break element from XML. Validate the <br> ... </br> tag. 
+		 * Use "\u2028" as the text; Insert the new element into its parent 
+		 * 
+		 * @param importer	parser object
+		 * @param xmlToParse	content to parse
+		 * @param parent 		the parent for the new content
+		 */
+		static public function parseBreak(importer:BaseTextLayoutImporter, xmlToParse:XML, parent:IFlowGroupElement):void
+		{
+			var breakElem:BreakElement = importer.createBreakFromXML(xmlToParse);
+			importer.addChild(parent, breakElem);
+		}
+		
+		/** 
+		 * Static method for constructing a tab element from XML. Validate the <tab> ... </tab> tag. 
+		 * Use "\t" as the text; Insert the new element into its parent 
+		 * 
+		 * @param importer	parser object
+		 * @param xmlToParse	content to parse
+		 * @param parent 		the parent for the new content
+		 */
+		static public function parseTab(importer:BaseTextLayoutImporter, xmlToParse:XML, parent:IFlowGroupElement):void
+		{
+			var tabElem:TabElement = importer.createTabFromXML(xmlToParse);	// may be null
+			if (tabElem)
+				importer.addChild(parent, tabElem);
+		}
+		
+		/** 
+		 * Static method for constructing a list element from XML. 
+		 * 
+		 * @param importer	parser object
+		 * @param xmlToParse	content to parse
+		 * @param parent 		the parent for the new content
+		 */
+		static public function parseList(importer:BaseTextLayoutImporter, xmlToParse:XML, parent:IFlowGroupElement):void
+		{
+			var listElem:IListElement = importer.createListFromXML(xmlToParse);
+			if (importer.addChild(parent, listElem))
+			{
+				importer.parseFlowGroupElementChildren(xmlToParse, listElem);
+			}
+		}
+		
+		/** 
+		 * Static method for constructing a list item from XML. 
+		 * 
+		 * @param importer	parser object
+		 * @param xmlToParse	content to parse
+		 * @param parent 		the parent for the new content
+		 */
+		static public function parseListItem(importer:BaseTextLayoutImporter, xmlToParse:XML, parent:IFlowGroupElement):void
+		{
+			var listItem:IListItemElement = importer.createListItemFromXML(xmlToParse);
+			if (importer.addChild(parent, listItem))
+			{
+				importer.parseFlowGroupElementChildren(xmlToParse, listItem);
+				//if parsing an empty list item, create a Paragraph for it.
+				if (listItem.numChildren == 0)
+					listItem.addChild(ElementHelper.getParagraph());	
+			}
+		}
+		
+		protected function checkNamespace(xmlToParse:XML):Boolean
+		{
+			var elementNS:Namespace = xmlToParse.namespace();
+			if (!_textFlowNamespace) // Not set yet; must be parsing the TextFlow element
+			{
+				// TextFlow element: allow only empty namespace and flow namespace
+				if (elementNS != ns) 
+				{
+					reportError(GlobalSettings.resourceStringFunction("unexpectedNamespace", [elementNS.toString()]));
+					return false;
+				}
+				_textFlowNamespace = elementNS;
+			}
+			// Other elements: must match the namespace of the TextFlow element
+			// Specifically, can't be empty unless the TextFlow element's namespace is also empty 
+			else if (elementNS != _textFlowNamespace) 
+			{
+				reportError(GlobalSettings.resourceStringFunction("unexpectedNamespace", [elementNS.toString()]));
+				return false;
+			}
+			
+			return true;
+		}
+		
+		public function parseAttributes(xmlToParse:XML,formatImporters:Array):void
+		{
+			var importer:IFormatImporter;
+			// reset them all
+			for each (importer in formatImporters)
+				importer.reset();
+				
+			if (!xmlToParse)
+				return;
+			
+			for each (var item:XML in xmlToParse.attributes())
+			{
+				var propertyName:String = item.name().localName;
+				var propertyValue:String = item.toString();
+				var imported:Boolean = false;
+				
+				// Strip out padding properties from XML coming in before TLF 2.0, since they were ignored but are no longer. This preserves the look of the text.
+				if (xmlToParse.localName() == "TextFlow")
+				{
+					if (propertyName == "version")	// skip over the version attribute, we've already processed it
+						continue;
+				}
+				else if (_importVersion < TextLayoutVersion.VERSION_2_0 &&
+					 (propertyName == "paddingLeft" || propertyName == "paddingTop" || propertyName == "paddingRight" || propertyName == "paddingBottom"))
+					continue;
+				for each (importer in formatImporters)
+				{
+					if (importer.importOneFormat(propertyName,propertyValue))
+					{
+						imported = true;
+						break;
+					}
+				}
+				if (!imported)	// not a supported attribute
+					handleUnknownAttribute (xmlToParse.name().localName, propertyName);
+			}
+		}
+				
+		static protected function extractAttributesHelper(curAttrs:Object, importer:TLFormatImporter):Object
+		{
+			if (curAttrs == null)
+				return importer.result;
+			
+			if (importer.result == null)
+				return curAttrs;
+				
+			var workAttrs:Object = new importer.classType(curAttrs);
+			workAttrs.apply(importer.result);
+			return workAttrs;
+		}	
+		
+		/** 
+		 * Parse XML and convert to  TextFlow.
+		 * 
+		 * @param xmlToParse	content to parse
+		 * @param textFlow 		TextFlow we're parsing. If null, create or find a new TextFlow based on XML content
+		 * @return TextFlow	the new TextFlow created as a result of the parse
+		 */
+		public function createTextFlowFromXML(xmlToParse:XML, newFlow:TextFlow = null):TextFlow	// No PMD
+		{
+			CONFIG::debug { assert(false,"missing override for createTextFlowFromXML"); }
+			return null;
+		}
+
+		public function createParagraphFromXML(xmlToParse:XML):IParagraphElement	// No PMD
+		{
+			CONFIG::debug { assert(false,"missing override for createParagraphFromXML"); }
+			return null;
+		}
+		
+		public function createSpanFromXML(xmlToParse:XML):ISpanElement	// No PMD
+		{
+			CONFIG::debug { assert(false,"missing override for createSpanFromXML"); }
+			return null;
+		}
+		
+		public function createBreakFromXML(xmlToParse:XML):BreakElement
+		{
+			parseAttributes(xmlToParse,null);	// no attributes allowed - reports errors
+			return new BreakElement();
+		}
+		
+		public function createListFromXML(xmlToParse:XML):IListElement	// No PMD
+		{
+			CONFIG::debug { assert(false,"missing override for createListFromXML"); }
+			return null;
+		}
+
+		public function createListItemFromXML(xmlToParse:XML):IListItemElement	// No PMD
+		{
+			CONFIG::debug { assert(false,"missing override for createListItemFromXML"); }
+			return null;
+		}
+		
+		public function createTabFromXML(xmlToParse:XML):TabElement
+		{
+			parseAttributes(xmlToParse,null);	// reports errors
+			return new TabElement();
+		}
+		
+		/** 
+		 * Parse XML, convert to FlowElements and add to the parent.
+		 * 
+		 * @param xmlToParse	content to parse
+		 * @param parent 		the parent for the new content
+		 */
+		public function parseFlowChildren(xmlToParse:XML, parent:FlowGroupElement):void
+		{
+			parseFlowGroupElementChildren(xmlToParse, parent);
+		}
+		
+		/** 
+		 * Parse XML, convert to FlowElements and add to the parent.
+		 * 
+		 * @param xmlToParse	content to parse
+		 * @param parent 		the parent for the new content
+		 * @param chainedParent whether parent actually corresponds to xmlToParse or has been chained (such as when xmlToParse is a formatting element) 
+		 */
+		public function parseFlowGroupElementChildren(xmlToParse:XML, parent:IFlowGroupElement, exceptionElements:Object = null, chainedParent:Boolean=false):void
+		{
+			for each (var child:XML in xmlToParse.children())
+			{
+				if (child.nodeKind() == "element")
+				{
+					parseObject(child.name().localName, child, parent, exceptionElements);
+				}
+				// look for mixed content here
+ 				else if (child.nodeKind() == "text") 
+ 				{
+ 					var txt:String = child.toString();
+ 					// Strip whitespace-only text appearing as a child of a container-formatted element
+ 					var strip:Boolean = false;
+ 					if (parent is IContainerFormattedElement)
+ 					{
+						strip = txt.search(anyPrintChar) == -1;
+					}
+					
+ 					if (!strip) 
+						addChild(parent, createImpliedSpan(txt));
+				}
+			}
+			
+			// no implied paragraph should extend across container elements
+			if (!chainedParent && parent is IContainerFormattedElement)
+				resetImpliedPara();
+		}
+		
+		/** 
+		 * Parse XML, convert XML to FlowElements and TextFlow and add to the parent table cell
+		 * 
+		 * @param xmlToParse	content to parse
+		 * @param parent 		the parent for the new content
+		 * @param chainedParent whether parent actually corresponds to xmlToParse or has been chained (such as when xmlToParse is a formatting element) 
+		 */
+		public function parseTableCellElementChildren(xmlToParse:XML, parent:IFlowGroupElement, exceptionElements:Object = null, chainedParent:Boolean=false):void
+		{
+			var textFlow:TextFlow;
+			
+			for each (var child:XML in xmlToParse.children())
+			{
+				if (child.nodeKind() == "element")
+				{
+					if (child.name().localName=="p") {
+						textFlow = new TextFlow(FactoryUtil.defaultTLFFactory);
+						parseObject(child.name().localName, child, textFlow, exceptionElements);
+					}
+					else if (child.name().localName=="TextFlow") {
+						TableCellElement(parent).textFlow = createTextFlowFromXML(child);
+					}
+				}
+					// look for mixed content here
+				else if (child.nodeKind() == "text") 
+				{
+					var txt:String = child.toString();
+					// Strip whitespace-only text appearing as a child of a container-formatted element
+					var strip:Boolean = false;
+					if (parent is IContainerFormattedElement)
+					{
+						strip = txt.search(anyPrintChar) == -1;
+					}
+					
+					if (!strip) {
+						textFlow = new TextFlow(FactoryUtil.defaultTLFFactory);
+						parseObject(child.name().localName, child, textFlow, exceptionElements);
+						//addChild(textFlow, createImpliedSpan(txt));
+					}
+				}
+				
+				if (textFlow) {
+					TableCellElement(parent).textFlow = textFlow;
+					textFlow = null;
+				}
+			}
+		}
+		
+		/** create an implied span with specified text */
+		public function createImpliedSpan(text:String):SpanElement
+		{
+			var span:SpanElement = new SpanElement();	// No PMD
+			span.text = text;
+			return span;
+		}
+			
+		public function createParagraphFlowFromXML(xmlToParse:XML, newFlow:TextFlow = null):TextFlow	// No PMD
+		{
+			CONFIG::debug { assert(false,"missing override for createParagraphFlowFromXML"); }	// client must override
+			return null;
+		}
+		
+		public function parseObject(name:String, xmlToParse:XML, parent:IFlowGroupElement, exceptionElements:Object=null):void
+		{
+			if (!checkNamespace(xmlToParse))
+				return;
+
+			var info:FlowElementInfo = _config.lookup(name);
+			if (!info)
+			{
+				if (exceptionElements == null || exceptionElements[name] === undefined)
+					handleUnknownElement (name, xmlToParse, parent);		
+			}
+			else
+				info.parser(this, xmlToParse, parent);
+		}
+		
+		protected function handleUnknownElement(name:String, xmlToParse:XML, parent:IFlowGroupElement):void
+		{
+			reportError(GlobalSettings.resourceStringFunction("unknownElement", [ name ]));	
+		}
+		
+		protected function handleUnknownAttribute(elementName:String, propertyName:String):void
+		{
+			reportError(GlobalSettings.resourceStringFunction("unknownAttribute", [ propertyName, elementName ]));	
+		}
+		
+		protected function getElementInfo(xmlToParse:XML):FlowElementInfo
+		{
+			return _config.lookup(xmlToParse.name().localName);
+		}
+		
+		protected function GetClass(xmlToParse:XML):Class
+		{
+			var info:FlowElementInfo = _config.lookup(xmlToParse.name().localName);
+			return info ? info.flowClass : null;
+		}
+		
+		// In the text model, non-FlowParagraphElements (i.e. spans, images, links, TCY) cannot be children of a ContainerElement (TextFlow, Div etc.)
+		// They can only be children of paragraphs or subparagraph blocks. 
+		// In XML, however, <p> elements can be implied (for example, a <span> may appear as a direct child of <flow>).  
+		// So, while parsing the XML, if we enounter a non-FlowParagraphElement child of a ContainerElement 
+		// 1. an explicitly created paragraph is used as the parent instead
+		// 2. such explicitly created paragraphs are shared by adjacent flow elements provided there isn't an intervening FlowParagraphElement		
+		private var _impliedPara:IParagraphElement = null; 
+		
+		/** @private */
+		public function createImpliedParagraph():IParagraphElement
+		{
+			return createParagraphFromXML(<p/>);
+		}
+		
+		/**
+		 * @private
+		 * Helper function for adding a child flow element that honors throwOnError setting and uses the parent override
+		 * NOTE: You MUST NOT call addChild directly unless you are sure
+		 * - There is not possibility of an implied paragraph, and
+		 * - Parent is of type that can contain child
+		*/
+		public function addChild(parent:IFlowGroupElement, child:IFlowElement):Boolean
+		{
+			if (child is IParagraphFormattedElement)
+			{
+				// Reset due to possibly intervening FlowParagrahElement; See note 2. above
+				resetImpliedPara();
+			}
+			else if (parent is IContainerFormattedElement)
+			{
+				// See note 1. above
+				if (!_impliedPara)
+				{
+					// Derived classes may have special behavior for <p> tags. Implied paragraphs may need the same behavior.
+					// So call createParagraphFromXML, don't just instantiate a ParagraphElement 
+					_impliedPara = createImpliedParagraph();
+					parent.addChild(_impliedPara);
+				}
+				
+				parent = _impliedPara;
+			}	
+			
+			if (throwOnError)
+				parent.addChild(child);
+			else
+			{
+				try
+				{
+					parent.addChild(child);
+				}
+				catch (e:*)
+				{
+					reportError(e); 	
+					return false;
+				}
+			}
+			
+			return true;
+		} 
+		
+		public function resetImpliedPara():void
+		{
+			if (_impliedPara)
+			{
+				onResetImpliedPara(_impliedPara);
+				_impliedPara = null;
+			}
+		}
+		
+		protected function onResetImpliedPara(para:IParagraphElement):void
+		{
+		}
+	}
+}
+

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ConversionConstants.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ConversionConstants.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ConversionConstants.as
new file mode 100644
index 0000000..c20e9f4
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ConversionConstants.as
@@ -0,0 +1,45 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion
+{
+
+	public class ConversionConstants
+	{
+		/** A converter that converts clipboard data into a TextFlow should use the MERGE_TO_NEXT_ON_PASTE property
+		 * to control how the elements are treated when they are merged into an existing TextFlow on paste. This is useful
+		 * if you want special handling for the case where only part of the element is copied. For instance, wheh a list
+		 * is copied, if only part of the list is copied, and you paste it into another list, it merges into the list as
+		 * additional items. If the entire list is copied, it appears as a nested list. When TLF creates a TextFlow for use
+		 * on the clipboard, it decorates any partial elements with user properties that control whether the end of the element 
+		 * should be merged with the one after it. This user property is never pasted into the final TextFlow, but it may go 
+		 * on the elements in the TextScrap.textFlow. When copying text, the converter has the option to look for these properties 
+		 * to propagate them into the format that is posted on the clipboard. For instance, the plain text exporter checks the 
+		 * "mergeToNextOnPaste" property on paragraphs and supresses the paragraph terminator if it is found set to true. 
+		 * Likewise on import if the incoming String has no terminator, and useClipboardAnnotations is true, then it calls 
+		 * <code>setStyle(MERGE_TO_NEXT_ON_PASTE, "true")</code> on the corresponding paragraph so that when it is pasted 
+		 * it will blend into the paragraph where its pasted. This property should only be set on elements in a TextScrap, and
+		 * only on the last element in the scrap.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */
+		static public const MERGE_TO_NEXT_ON_PASTE:String = "mergeToNextOnPaste";
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ConversionType.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ConversionType.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ConversionType.as
new file mode 100644
index 0000000..f2a25cd
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ConversionType.as
@@ -0,0 +1,51 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion
+{
+	/**
+	 * Values for the format of exported text.
+	 * The values <code>STRING_TYPE</code> and <code>XML_TYPE</code> 
+	 * can be used for the <code>conversionType</code> parameter for 
+	 * the export() method in the ITextExporter interface and the
+	 * TextConverter class.
+	 *
+	 * @see org.apache.flex.textLayout.conversion.ITextExporter#export()
+	 * @see org.apache.flex.textLayout.conversion.TextConverter#export()
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	public final class ConversionType
+	{
+		/** 
+		 * Export as type String. 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+		 */
+		public static const STRING_TYPE:String = "stringType";		
+		/** 
+		 * Export as type XML.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+		 */
+		public static const XML_TYPE:String = "xmlType";				
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ConverterBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ConverterBase.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ConverterBase.as
new file mode 100644
index 0000000..c9281c4
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ConverterBase.as
@@ -0,0 +1,108 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion {
+
+
+	
+	/**
+	 * This is a base class for importers as well as exporters. It implements the error handling
+	 * plus property getters and setters that generate an error when invoked.
+	 * @playerversion Flash 10.2
+	 * @playerversion AIR 2.0
+	 * @langversion 3.0 
+	 */
+	public class ConverterBase
+	{
+		private var _errors:Vector.<String> = null;
+		private var _throwOnError:Boolean = false;
+		private var _useClipboardAnnotations:Boolean = false;
+		private var _config:ImportExportConfiguration;
+
+		
+		/** Errors encountered while parsing. 
+		 * Value is a vector of Strings.
+		 */
+		public function get errors():Vector.<String>
+		{
+			return _errors;
+		}
+		
+		/** @copy ITextImporter#throwOnError()
+		 */
+		public function get throwOnError():Boolean
+		{
+			return _throwOnError;
+		}
+		
+		public function set throwOnError(value:Boolean):void
+		{
+			_throwOnError = value;
+		}
+		
+		/** @private
+		 * Clear errors.
+		 */
+		public function clear():void
+		{
+			_errors = null;
+		}
+		
+		/** @private
+		 * Register an error that was encountered while parsing. If throwOnError
+		 * is true, the error causes an exception. Otherwise it is logged and parsing
+		 * continues.
+		 * @param error	the String that describes the error
+		 */
+		public function reportError(error:String):void
+		{
+			if (_throwOnError)
+				throw new Error(error);
+			
+			if (!_errors)
+				_errors = new Vector.<String>();
+			_errors.push(error);
+		}
+
+		/** @copy ITextImporter#useClipboardAnnotations()
+		 */
+		public function get useClipboardAnnotations():Boolean
+		{
+			return _useClipboardAnnotations;
+		}
+		public function set useClipboardAnnotations(value:Boolean):void
+		{
+			_useClipboardAnnotations = value;
+		}
+		
+		/**
+		 * Returns the import and export configuration. 
+		 **/
+		public function get config():ImportExportConfiguration {
+			return _config;
+		}
+		
+		/**
+		 * @private
+		 **/
+		public function set config(value:ImportExportConfiguration):void {
+			_config = value;
+		}
+		
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/CustomFormatImporter.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/CustomFormatImporter.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/CustomFormatImporter.as
new file mode 100644
index 0000000..fb0fed0
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/CustomFormatImporter.as
@@ -0,0 +1,45 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion
+{
+	import org.apache.flex.utils.ObjectMap;
+	
+	// [ExcludeClass]
+	/**
+	 * @private  
+	 */
+	internal class CustomFormatImporter implements IFormatImporter
+	{
+		private var _rslt:ObjectMap = null;
+		
+		public function CustomFormatImporter()
+		{ }
+		public function reset():void
+		{ _rslt = null; }
+		public function get result():Object
+		{ return _rslt; }
+		public function importOneFormat(key:String,val:String):Boolean
+		{
+			if (_rslt == null)
+				_rslt = new ObjectMap();
+			_rslt[key] = val;
+			return true; 
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/FlowElementInfo.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/FlowElementInfo.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/FlowElementInfo.as
new file mode 100644
index 0000000..9947f4a
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/FlowElementInfo.as
@@ -0,0 +1,66 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion {
+	import org.apache.flex.reflection.getQualifiedClassName;
+	
+	// [ExcludeClass]
+	/**
+	 * @private  
+	 * Contains configuration data about FlowElement types. 
+	 */
+	internal class FlowElementInfo
+	{
+		/** Class used for the FlowElement sub-type */
+		private var _flowClass:Class;
+		/** Fully qualified class name */
+		private var _flowClassName:String;
+		/** Parsing function used for reading in data on a FlowElement instance */
+		private var _parser:Function;
+		/** Class for the object's XFL import/export interface */
+		private var _exporter:Function;
+		
+		/** Construct a FlowElementInfo
+		 * @param	flowClass	Class used to represent the FlowElement
+		 * @param 	parser		Function used for parsing XML description of a FlowElement
+		 * @param 	exporter	Class used to represent the FlowElement's exporter
+		 * @param	isParagraphFormattedElement Boolean indicating if this class is a subclass of ParagraphFormattedElement
+		 */
+		public function FlowElementInfo(flowClass:Class, parser:Function, exporter:Function)
+		{
+			this._flowClass = flowClass;
+			this._parser = parser;
+			this._exporter = exporter;
+			this._flowClassName = getQualifiedClassName(flowClass);
+		}
+		
+		/** Class used for the FlowElement sub-type */
+		public function get flowClass():Class
+		{ return _flowClass; }
+		/** Fully qualified class name */
+		public function get flowClassName():String
+		{ return _flowClassName; }
+		/** Parsing function used for reading in data on a FlowElement instance */
+		public function get parser():Function
+		{ return _parser; }
+		/** Class for the object's XFL import/export interface */
+		public function get exporter():Function
+		{ return _exporter; }
+		/** Boolean indicating if flowClass is a subclass of ParagraphFormattedElement */
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/FormatDescriptor.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/FormatDescriptor.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/FormatDescriptor.as
new file mode 100644
index 0000000..5cb57d6
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/FormatDescriptor.as
@@ -0,0 +1,90 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion
+{
+    /** Contains information about a format.
+     * 
+     * @playerversion Flash 10.0
+     * @playerversion AIR 2.0
+     * @langversion 3.0
+     */
+    public class FormatDescriptor
+    {
+        private var _format:String;
+        private var _clipboardFormat:String;
+        private var _importerClass:Class;
+        private var _exporterClass:Class;
+        
+        /** Constructor.
+         * 
+         * @playerversion Flash 10.0
+         * @playerversion AIR 2.0
+         * @langversion 3.0
+        */
+        public function FormatDescriptor(format:String, importerClass:Class, exporterClass:Class, clipboardFormat:String)
+        {
+            _format = format;
+            _clipboardFormat = clipboardFormat;
+            _importerClass = importerClass;
+            _exporterClass = exporterClass;
+        }
+        
+        /** Returns the data format used by the converter.
+         * 
+         * @playerversion Flash 10.0
+         * @playerversion AIR 2.0
+         * @langversion 3.0     
+        */
+        public function get format():String
+        { return _format; }
+
+        /** Descriptor used when matching this format to the formats posted on the external clipboard. If the format supports importing, 
+         * (it's importerClass is not null), it will be called when pasting from the clipboard, if the clipboard contents include data 
+         * in this format. If the format supports exporting, it will be called when copying to the clipboard, and the output it creates 
+         * will be posted to the clipboard with this clipboardFormat.
+         * 
+         * @playerversion Flash 10.0
+         * @playerversion AIR 2.0
+         * @langversion 3.0
+         * 
+         * @see flash.desktop.Clipboard
+         * @see flash.desktop.ClipboardFormats
+         */
+        public function get clipboardFormat():String
+        { return _clipboardFormat; }
+
+        /** Returns the class used for converting data from the format. 
+         * 
+         * @playerversion Flash 10.0
+         * @playerversion AIR 2.0
+         * @langversion 3.0
+        */
+        public function get importerClass():Class
+        { return _importerClass; }
+
+        /** Returns the class used for converting to the format. 
+         * 
+         * @playerversion Flash 10.0
+         * @playerversion AIR 2.0
+         * @langversion 3.0
+        */
+        public function get exporterClass():Class
+        { return _exporterClass; }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/IFormatImporter.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/IFormatImporter.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/IFormatImporter.as
new file mode 100644
index 0000000..0374752
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/IFormatImporter.as
@@ -0,0 +1,29 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion {
+	
+	// [ExcludeClass]
+	/** Interface for exporting text content from a TextFlow to either a String or XML. */
+	public interface IFormatImporter
+	{	
+		function reset():void;
+		function get result():Object;
+		function importOneFormat(key:String,val:String):Boolean
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/IHTMLImporter.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/IHTMLImporter.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/IHTMLImporter.as
new file mode 100644
index 0000000..569f871
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/IHTMLImporter.as
@@ -0,0 +1,73 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion
+{
+	/** This interface should be implemented by converters that import HTML or HTML-structured data. Clients that have explicitly
+	 * created an importer using TextConverter.getImporter may control the import process by calling into these methods on the 
+	 * importer.
+	 * 
+	 * @playerversion Flash 10.0
+	 * @playerversion AIR 2.0
+	 * @langversion 3.0
+	 */
+	public interface IHTMLImporter extends ITextImporter
+	{
+		/** This property allows specification of a function to modify the source property supplied to an <code>&lt;img&gt;</code> element. 
+		 * Sample use would be to modify relative paths to some caller specified root path.  The function takes the string set in the markup and returns the actual string
+		 * to be used.  
+		 * 
+		 * <p>Note that by default relative paths are relative to the loaded SWF.  One use of this function is to make relative paths relative to some other location.</p>
+		 * 
+		 * <p>The resolver function should look like this:</p>
+		 * <code>function resolver(src:String):String</code>
+		 * <p>It takes as an input parameter the value of src on the incoming img element, and returns the adjusted value.</p>
+		 * 
+		 * @playerversion Flash 10.0
+		 * @playerversion AIR 2.0
+		 * @langversion 3.0
+		 */
+		function get imageSourceResolveFunction():Function;
+		function set imageSourceResolveFunction(resolver:Function):void;
+		
+		/** This property tells the importer to create an element for the <code>BODY</code> tag in HTML markup.
+		 * 
+		 * <p>The element will normally be a <code>DivElement</code> with <code>typeName</code> set to <code>BODY</code>.</p>
+		 * <p>This will also trigger parsing of <code>class</code> and <code>id</code> on the element.</p>
+		 * 
+		 * @playerversion Flash 10.0
+		 * @playerversion AIR 2.0
+		 * @langversion 3.0
+		 */		
+		function get preserveBodyElement():Boolean;
+		function set preserveBodyElement(value:Boolean):void;
+		
+		/** This property tells the importer to create an element for the <code>HTML</code> tag in HTML markup.
+		 * 
+		 * <p>The element will normally be the top-level <code>TextFlow</code> element with <code>typeName</code> set to <code>HTML</code>.</p>
+		 * <p>This will also trigger parsing of <code>class</code> and <code>id</code> on the element.</p>
+		 *
+		 * @playerversion Flash 10.0
+		 * @playerversion AIR 2.0
+		 * @langversion 3.0
+		 */		
+		function get preserveHTMLElement():Boolean;
+		function set preserveHTMLElement(value:Boolean):void;
+		
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/IPlainTextExporter.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/IPlainTextExporter.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/IPlainTextExporter.as
new file mode 100644
index 0000000..938c3e4
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/IPlainTextExporter.as
@@ -0,0 +1,57 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion
+{
+	/** This interface should be implemented by converters that export plain text. Clients that have explicitly
+	 * created an exporter using TextConverter.getExporter may control the export process by calling into these methods on the 
+	 * exporter.
+	 * 
+	 * @playerversion Flash 10.0
+	 * @playerversion AIR 2.0
+	 * @langversion 3.0
+	 */
+	public interface IPlainTextExporter extends ITextExporter
+	{
+		/** Specifies the character sequence used (in a text flow's plain-text equivalent) to separate paragraphs.
+		 * The paragraph separator is not added after the last paragraph. 
+		 * 
+		 * <p>This property applies to the <code>PLAIN_TEXT_FORMAT</code> exporter.</p>
+		 *
+		 * <p>The default value is "\n".</p> 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get paragraphSeparator():String;
+		function set paragraphSeparator(value:String):void;
+		
+		/** This property indicates whether discretionary hyphens in the text should be stripped during the export process.
+		 * Discretionary hyphens, also known as "soft hyphens", indicate where to break a word in case the word must be
+		 * split between two lines. The Unicode character for discretionary hyphens is <code>\u00AD</code>.
+		 * <p>If this property is set to <code>true</code>, discretionary hyphens that are in the original text will not be in the exported text, 
+		 * even if they are part of the original text. If <code>false</code>, discretionary hyphens will be in the exported text.</p>
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get stripDiscretionaryHyphens():Boolean;
+		function set stripDiscretionaryHyphens(value:Boolean):void;		
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ITextExporter.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ITextExporter.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ITextExporter.as
new file mode 100644
index 0000000..733368d
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ITextExporter.as
@@ -0,0 +1,102 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion {
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	
+	/** 
+	 * Interface for exporting text content from a TextFlow instance to a given format, 
+	 * which may for example be String or XML format, or a user-defined format. Exporters support the getting
+	 * and setting of properties to control the export of data. These properties are implemented
+	 * as public properties, but the direct access of these properties should be avoided, since
+	 * a user might replace the converter class in the TextConverter registry, causing a downcast
+	 * to fail.
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	public interface ITextExporter
+	{	
+		/** 
+		 * Export text content from a TextFlow instance in String, or XML, or a user defined format.
+		 * <p>Set the <code>conversionType</code> parameter to either of the following values,
+		 * or a user defined format in user-defined exporters.
+		 * <ul>
+		 *   <li><code>org.apache.flex.textLayout.conversion.ConversionType.STRING_TYPE</code>;</li>
+		 *   <li><code>org.apache.flex.textLayout.conversion.ConversionType.XML_TYPE</code>.</li>
+		 * </ul>
+		 * </p>
+		 * @param source	The TextFlow to export
+		 * @param conversionType 	Return a String (STRING_TYPE) or XML (XML_TYPE), or any user defined format.
+		 * @return Object	The exported content
+		 * @see org.apache.flex.textLayout.conversion.ConversionType
+	 	 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function export(source:ITextFlow, conversionType:String):Object;
+		
+		/** 
+		 * This property contains a vector of error messages as strings after a call
+		 * to an exporter method is the <code>throwOnError</code> property is set to
+		 * <code>false</code>, which is the default. If there were no errors, the
+		 * property returns <code>null</code>. The property is reset on each method
+		 * call.
+		 * @playerversion Flash 10.2
+		 * @playerversion AIR 2.0
+		 * @langversion 3.0
+		 */
+		function get errors():Vector.<String>;
+		
+		/** 
+		 * The throwOnError property controls how the exporter handles errors.
+		 * If set to <code>true</code>, methods throw an Error instance on errors. 
+		 * If set to <code>false</code>, which is the default, errors are collected
+		 * into a vector of strings and stored in the <code>errors</code> property, 
+		 * and the exporter does not throw.	
+		 * @playerversion Flash 10.2
+		 * @playerversion AIR 2.0
+		 * @langversion 3.0
+		 */
+		function get throwOnError():Boolean;
+		function set throwOnError(value:Boolean):void;
+
+		/** 
+		 * The <code>useClipboardAnnotations</code> property controls whether or not the 
+		 * importer should handle the extra information necessary for the clipboard. 
+		 * When data is in a TextFlow, paragraphs are always complete, and include a 
+		 * terminator character. When a range of text is pasted to the clipboard, it
+		 * will form paragraphs, but the range may not include in the final terminator.
+		 * In this case, the paragraph needs to be marked as a partial paragraph if it
+		 * is intended for the clipboard, so that if it is later pasted it will merge
+		 * into the new text correctly. If the content is intended for the clipboard, 
+		 * useClipboardAnnotations will be true.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get useClipboardAnnotations():Boolean;
+		function set useClipboardAnnotations(value:Boolean):void;
+		
+		/**
+		 * Accesses the config options for the exporter. 
+		 **/
+		function get config():ImportExportConfiguration;
+		function set config(value:ImportExportConfiguration):void;		
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ITextImporter.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ITextImporter.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ITextImporter.as
new file mode 100644
index 0000000..6d3e43e
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ITextImporter.as
@@ -0,0 +1,108 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion
+{
+	import org.apache.flex.textLayout.elements.ITextFlow;
+    import org.apache.flex.textLayout.elements.IConfiguration;
+    
+    /** 
+     * Interface for importing text content into a TextFlow from an external source. 
+     * The TextConverter class creates importers with no constructor arguments.
+     * 
+     * @see org.apache.flex.textLayout.elements.TextFlow
+     * 
+     * @playerversion Flash 10
+     * @playerversion AIR 1.5
+     * @langversion 3.0
+     */
+    public interface ITextImporter
+    {   
+        /** 
+         * Import text content from an external source and convert it into a TextFlow.
+         * @param source        The data to convert.
+         * @return TextFlow Created from the source.
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+		 */
+		function importToFlow(source:Object):ITextFlow;
+        
+        /** 
+         * This property contains a vector of error messages as strings after a call
+         * to an importer method is the <code>throwOnError</code> property is set to
+         * <code>false</code>, which is the default. If there were no errors, the
+         * property returns <code>null</code>. The property is reset on each method
+         * call.
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */
+        function get errors():Vector.<String>;
+        
+        /** 
+         * The <code>throwOnError</code> property controls how the importer handles errors.
+         * If set to <code>true</code>, methods throw an Error instance on errors. 
+         * If set to <code>false</code>, which is the default, errors are collected
+         * into a vector of strings and stored in the <code>errors</code> property, 
+         * and the importer does not throw. 
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */
+        function get throwOnError():Boolean;
+        function set throwOnError(value:Boolean):void;
+        
+        /** 
+         * Controls whether or not the 
+         * importer should handle the extra information necessary for the clipboard. 
+         * When data comes in from the clipboard, it might contain partial paragraphs; 
+         * paragraphs that are missing the terminator or newline character. If <code>useClipboardAnnotations</code> 
+         * is <code>true</code>, the importer marks these partial paragraphs with a 
+         * <code>ConverterBase.MERGE_TO_NEXT_ON_PASTE</code> attribute. This causes the paste
+         * operation to correctly handle merging of the pasted paragraph (and any list or div elements
+         * that may include the paragraph) into the text.
+         *  
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         *  
+         * @see org.apache.flex.textLayout.conversion.ConverterBase.MERGE_TO_NEXT_ON_PASTE
+         */
+        function get useClipboardAnnotations():Boolean;
+        function set useClipboardAnnotations(value:Boolean):void;
+
+        /**
+         * The <code>configuration</code> property contains the IConfiguration instance that
+         * the importer needs when creating new TextFlow instances. This property
+         * is initially set to <code>null</code>.
+         * 
+         * @see org.apache.flex.textLayout.elements.TextFlow
+         * 
+         * @playerversion Flash 10.2
+         * @playerversion AIR 2.0
+         * @langversion 3.0
+         */
+        function get configuration():IConfiguration;
+        function set configuration(value:IConfiguration):void;
+        
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ITextLayoutImporter.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ITextLayoutImporter.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ITextLayoutImporter.as
new file mode 100644
index 0000000..ac0bf75
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ITextLayoutImporter.as
@@ -0,0 +1,48 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion
+{
+	/** This interface should be implemented by converters that import TextLayout structured data. Clients that have explicitly
+	 * created an importer using TextConverter.getImporter may control the import process by calling into these methods on the 
+	 * importer.
+	 * 
+	 * @playerversion Flash 10.0
+	 * @playerversion AIR 2.0
+	 * @langversion 3.0
+	 */
+	public interface ITextLayoutImporter extends ITextImporter
+	{
+		/** This property allows specification of a function to modify the source property supplied to an <code>&lt;img&gt;</code> element. 
+		 * Sample use would be to modify relative paths to some caller specified root path.  The function takes the string set in the markup and returns the actual string
+		 * to be used.  
+		 * 
+		 * <p>Note that by default relative paths are relative to the loaded SWF.  One use of this function is to make relative paths relative to some other location.</p>
+		 * 
+		 * <p>The resolver function should look like this:</p>
+		 * <code>function resolver(src:String):String</code>
+		 * <p>It takes as an input parameter the value of src on the incoming img element, and returns the adjusted value.</p>
+		 * 
+		 * @playerversion Flash 10.0
+		 * @playerversion AIR 2.0
+		 * @langversion 3.0
+		 */
+		function get imageSourceResolveFunction():Function;
+		function set imageSourceResolveFunction(resolver:Function):void;
+	}
+}
\ No newline at end of file


[02/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/PropertyUtil.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/PropertyUtil.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/PropertyUtil.as
new file mode 100644
index 0000000..2a33c1d
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/PropertyUtil.as
@@ -0,0 +1,177 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.property
+{
+	import org.apache.flex.textLayout.elements.GlobalSettings;
+	public class PropertyUtil
+	{
+
+		public static var errorHandler:Function = defaultErrorHandler;
+		public static function defaultErrorHandler(p:Property,value:Object):void
+		{
+			throw(new RangeError(createErrorString(p,value)));
+		}
+		public static function createErrorString(p:Property,value:Object):String
+		{
+			return GlobalSettings.resourceStringFunction("badPropertyValue",[ p.name, value.toString() ]);
+		}
+		public static function defaultConcatHelper(currVal:*,concatVal:*):*
+		{ return currVal === undefined || currVal == "inherit" ? concatVal : currVal; }
+
+		// /////////////////////////////////////////////
+		// Following static functions are used by Format classes to 
+		// perform functions that iterate over all the attributes.
+		// They are driven by the attributes metadata object that contains
+		// definitions for all the properties.
+		// /////////////////////////////////////////////
+			
+		/** Helper function to initialize all property values from defaults. */
+		static public function defaultsAllHelper(description:Object,current:Object):void
+		{
+			for each (var prop:Property in description)
+				current[prop.name] = prop.defaultValue;
+		}
+		
+		/** Helper function to compare two sets of properties. */
+		static public function equalAllHelper(description:Object,p1:Object,p2:Object):Boolean
+		{
+			if (p1 == p2)
+				return true;
+			// these could be "equal" if all attributes of p1 or p2 are null
+			if (p1 == null || p2 == null)
+				return false;
+			for each (var prop:Property in description)
+			{
+				var name:String = prop.name;
+				if (!(prop.equalHelper(p1[name],p2[name])))
+					return false;
+			}
+			return true;
+		}
+
+		static public function extractInCategory(formatClass:Class,description:Object,props:Object,category:String,legacy:Boolean = true):Object
+		{
+			var rslt:Object = null;
+			for each (var prop:Property in description)
+			{
+				if (props[prop.name] == null)
+					continue;
+				
+				if (legacy)
+				{
+					if (prop.category != category)
+						continue;
+				}
+				else if (prop.categories.indexOf(category) == -1)
+					continue;
+				
+				if (rslt == null)
+					rslt = new formatClass();
+				rslt[prop.name] = props[prop.name];
+			}
+			return rslt;
+		}
+		
+		/** @private Copy an object */
+		static public function shallowCopy(src:Object):Object
+		{
+			// make a shallow copy
+			var rslt:Object = {};
+			for (var val:Object in src)
+				rslt[val] = src[val]; 
+			return rslt;
+		}
+		
+		/** @private Copy properties from src to result if a property of the same name exists in filter */
+		static public function shallowCopyInFilter(src:Object,filter:Object):Object
+		{
+			// make a shallow copy
+			var rslt:Object = {};
+			for (var val:Object in src)
+			{
+				if (filter.hasOwnProperty(val))
+					rslt[val] = src[val];
+			}
+			return rslt;
+		}
+		
+		/** @private Copy properties from src to result if a property of the same name exists in filter */
+		static public function shallowCopyNotInFilter(src:Object,filter:Object):Object
+		{
+			// make a shallow copy
+			var rslt:Object = {};
+			for (var val:Object in src)
+			{
+				if (!filter.hasOwnProperty(val))
+					rslt[val] = src[val];
+			}
+			return rslt;
+		}
+		
+		static private function compareStylesLoop(o1:Object,o2:Object,description:Object):Boolean
+		{
+			for (var val:String in o1)
+			{
+				var o1val:Object = o1[val];
+				var o2val:Object = o2[val];
+				if (o1val != o2val)
+				{
+					if (!(o1val is Array) || !(o2val is Array) || o1val.length != o2val.length || !description)
+						return false;	// different
+					var prop:ArrayProperty = description[val];
+					if (!prop || !equalAllHelper(prop.memberType["description"],o1val,o2val))
+						return false;
+				}
+			}
+			return true;
+		}
+		/** @private */
+		static public const nullStyleObject:Object = {};
+		/** @private */
+		static public function equalStyles(o1:Object,o2:Object,description:Object):Boolean
+		{
+			if (o1 == null)
+				o1 = nullStyleObject;
+			if (o2 == null)
+				o2 = nullStyleObject;
+			// Use of prototype chains and bug https://bugzilla.mozilla.org/show_bug.cgi?id=447673 requires this two way compare
+			return compareStylesLoop(o1,o2,description) && compareStylesLoop(o2,o1,description);
+		}
+		
+		/** @private */
+		static public function toNumberIfPercent(o:Object):Number
+		{
+			if (!(o is String))
+				return NaN;
+			var s:String = String(o);
+			var len:int = s.length;
+			
+			return len != 0 && s.charAt(len-1) == "%" ? parseFloat(s) : NaN;
+		}
+		
+		static private var prototypeFactory:Function = function():void{};
+		
+		/** @private Create an object with specified prototype parent */
+		static public function createObjectWithPrototype(parent:Object):Object
+		{
+			prototypeFactory.prototype = parent;
+			return new prototypeFactory();
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/SpacingLimitPropertyHandler.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/SpacingLimitPropertyHandler.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/SpacingLimitPropertyHandler.as
new file mode 100644
index 0000000..93c76d6
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/SpacingLimitPropertyHandler.as
@@ -0,0 +1,137 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.property {
+
+	
+
+	
+	// [ExcludeClass]
+	public class SpacingLimitPropertyHandler extends PropertyHandler
+	{
+		override public function get className():String
+		{
+			return "SpacingLimitPropertyHandler";
+		}
+		private var _minPercentValue:String;
+		private var _maxPercentValue:String;
+		
+		public function SpacingLimitPropertyHandler(minPercentValue:String, maxPercentValue:String)
+		{ 
+			_minPercentValue = minPercentValue; 
+			_maxPercentValue = maxPercentValue; 
+		}
+		
+		// check to see if this handler has a custom exporter that must be used when owningHandlerCheck is true
+		public override function get customXMLStringHandler():Boolean
+		{ return true; }
+		
+		public override function toXMLString(val:Object):String
+		{ 
+			if (val.hasOwnProperty("optimumSpacing") && val.hasOwnProperty("minimumSpacing") && val.hasOwnProperty("maximumSpacing"))
+				return val.optimumSpacing.toString() + ',' + val.minimumSpacing.toString() + ',' + val.maximumSpacing.toString();
+			return val.toString();
+		}
+		
+		/** matches a single spacing limit value */
+		static private  const _spacingLimitPattern:RegExp = /\d+%/g;
+		/** matches an array of 1-3 spacing limit values, separated by commas */
+		static private  const _spacingLimitArrayPattern:RegExp = /^\s*(\d+%)(\s*,\s*)(\d+%)?(\s*,\s*)(\d+%)?\s*$/;
+		
+		// return a value if this handler "owns" this property - otherwise return undefined
+		public override function owningHandlerCheck(newVal:*):*
+		{ 
+			if (newVal is String)
+			{
+				if (_spacingLimitArrayPattern.test(newVal))
+					return newVal;
+			}
+			
+			else if (newVal.hasOwnProperty("optimumSpacing") && newVal.hasOwnProperty("minimumSpacing") && newVal.hasOwnProperty("maximumSpacing"))
+				return newVal;
+
+			return undefined;
+		}
+		
+		private function checkValue(value:*):Boolean
+		{
+			var minLegalValue:Number = PropertyUtil.toNumberIfPercent(_minPercentValue);
+			var maxLegalValue:Number = PropertyUtil.toNumberIfPercent(_maxPercentValue);
+			
+			// Check that the 3 values don't exceed the minimum or maximum percentages allowed
+			var optValue:Number = PropertyUtil.toNumberIfPercent(value.optimumSpacing);
+			if (optValue < minLegalValue || optValue > maxLegalValue)
+				return false;
+			
+			var minValue:Number = PropertyUtil.toNumberIfPercent(value.minimumSpacing);
+			if (minValue < minLegalValue || minValue > maxLegalValue)
+				return false;
+
+			var maxValue:Number = PropertyUtil.toNumberIfPercent(value.maximumSpacing);
+			if (maxValue < minLegalValue || maxValue > maxLegalValue)
+				return false;
+			
+			// Check that optimum is between minimum & maximum
+			if (optValue < minValue || optValue > maxValue)
+				return false;
+			
+			// Check that minimum is below maximum
+			if (minValue > maxValue)
+				return false;
+			
+			return true;
+		}
+		
+		/** parse the input string and create a valid input value */
+		public override function setHelper(newVal:*):*
+		{ 
+			var s:String = newVal as String;
+			
+			if (s == null)
+				return newVal;	// assume its an object that's been parsed already
+			
+			if (_spacingLimitArrayPattern.test(newVal))
+			{
+				// Incoming string is comma-delimited list of 1-3 percentage values. 
+				// If the incoming string specifies just one value, its the optimumSpacing, and minimumSpacing and maximumSpacing get the default values.
+				// If the incoming string specifies two values, the first one is optimumSpacing and minimumSpacing and the second is maximumSpacing
+				// If the incoming string specifies three values, the first one is optimumSpacing and the second is minimumSpacing and the third is maximumSpacing
+				var result:Object = {};
+				var splits:Array = s.match(_spacingLimitPattern);
+				if (splits.length  == 1)
+				{
+					result.optimumSpacing = splits[0];
+					result.minimumSpacing = result.optimumSpacing;
+					result.maximumSpacing = result.optimumSpacing;
+				}
+				else if (splits.length == 3)
+				{
+					result.optimumSpacing = splits[0];
+					result.minimumSpacing = splits[1];
+					result.maximumSpacing = splits[2];
+				}
+				else 
+					return undefined;
+				if (checkValue(result))
+					return result;
+			}
+
+			return undefined;
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/StringPropertyHandler.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/StringPropertyHandler.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/StringPropertyHandler.as
new file mode 100644
index 0000000..e3e0185
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/StringPropertyHandler.as
@@ -0,0 +1,35 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.property {
+	
+	// [ExcludeClass]
+	/** A property handler with a String as its value @private */
+	public class StringPropertyHandler extends PropertyHandler
+	{
+		override public function get className():String
+		{
+			return "StringPropertyHandler";
+		}
+		/** @private */
+		public override function owningHandlerCheck(newVal:*):*
+		{ 
+			return newVal is String ? newVal : undefined;
+		}	
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/TabStopsProperty.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/TabStopsProperty.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/TabStopsProperty.as
new file mode 100644
index 0000000..9eb4223
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/TabStopsProperty.as
@@ -0,0 +1,202 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.property {
+	import org.apache.flex.textLayout.formats.FormatValue;
+	import org.apache.flex.textLayout.formats.TabStopFormat;
+		
+	// [ExcludeClass]
+	/** Property for tab stops. Extends ArrayProperty; setter takes a string representation of tab stops in addition to an array. @private */
+	public class TabStopsProperty extends ArrayProperty
+	{
+		public function TabStopsProperty(nameValue:String, defaultValue:Array, inherited:Boolean, categories:Vector.<String>)
+		{ 
+			super(nameValue, defaultValue, inherited, categories, TabStopFormat);
+		}
+			
+		/** Helper function when setting the property */
+		public override function setHelper(currVal:*,newVal:*):*
+		{
+			// null is a real value - DO NOT map to undefined like the others
+			
+			// null, undefined and INHERIT are all valid for arrays
+			if (newVal == null || newVal == FormatValue.INHERIT)
+				return newVal;
+				
+			// Accepts either an array or a string representation
+			var tabStops:Array = newVal as Array;
+			if (tabStops)
+			{
+				if (!checkArrayTypes(tabStops))
+				{
+					PropertyUtil.errorHandler(this,newVal);
+					return currVal;
+				}
+			}
+			else
+			{
+				var valString:String = newVal as String;
+				if (!valString)
+				{
+					PropertyUtil.errorHandler(this,newVal);
+					return currVal;
+				}
+					
+				// Parse the string representation and create an equivalent array
+				tabStops = new Array();
+				
+				// Replace escape sequences (\ followed by a space or \) with placeholder strings
+				// that can't naturally occur in the passed-in string 
+				valString = valString.replace(_escapeBackslashRegex, _backslashPlaceHolder);
+				valString = valString.replace(_escapeSpaceRegex, _spacePlaceHolder);
+				
+				_tabStopRegex.lastIndex = 0;
+				var lookup:Object = {
+					"s":"start",
+					"c":"center",
+					"e":"end",
+					"d":"decimal"
+				};
+				do
+				{
+					var result:Object = _tabStopRegex.exec(valString);
+					if (!result)
+						break; // no more matches
+						
+					var tabStop:TabStopFormat = new TabStopFormat();
+					tabStop.alignment = lookup[result[1].toLowerCase()] || "start";
+					// switch (result[1].toLowerCase())
+					// {
+					// 	case "s":
+					// 	case "": // START is the default
+					// 		tabStop.alignment = "start";
+					// 		break;
+					// 	case "c":
+					// 		tabStop.alignment = "center";
+					// 		break;
+					// 	case "e":
+					// 		tabStop.alignment = "end";
+					// 		break;
+					// 	case "d":
+					// 		tabStop.alignment = "decimal";
+					// 		break;
+					// }
+					
+					var position:Number = Number(result[2]); 
+					if (isNaN(position))
+					{
+						PropertyUtil.errorHandler(this,newVal);
+						return currVal;
+					}
+					tabStop.position = position;
+
+					if (tabStop.alignment == "decimal")
+					{
+						if (result[3] == "")
+							tabStop.decimalAlignmentToken = "."; //default
+						else
+						{
+							// strip the leading vertical bar and restore \ and space characters where intended
+							tabStop.decimalAlignmentToken = result[3].slice(1).replace(_backslashPlaceholderRegex, "\\");
+							tabStop.decimalAlignmentToken = tabStop.decimalAlignmentToken.replace(_spacePlaceholderRegex, " ");
+						}
+					}
+					else if (result[3] != "")
+					{
+						PropertyUtil.errorHandler(this,newVal);
+						return currVal; // if alignment is not decimal, the alignment token is not allowed
+					}
+						
+					tabStops.push(tabStop);
+				
+				} while (true);
+			
+			}
+
+			return tabStops.sort(compareTabStopFormats);
+		}
+		
+		/** @private */
+		public override function toXMLString(val:Object):String
+		{
+			var str:String = "";
+			var lookup:Object = {
+				"start":"s",
+				"center":"c",
+				"end":"e",
+				"decimal":"d"
+			};
+			var tabStops:Array = val as Array;
+			for each (var tabStop:TabStopFormat in tabStops)
+			{
+				if (str.length)
+					str += " ";
+				str += lookup[tabStop.alignment];
+				// switch (tabStop.alignment)
+				// {
+				// 	case TabAlignment.START:
+				// 		str += "s";
+				// 		break;
+				// 	case TabAlignment.CENTER:
+				// 		str += "c";
+				// 		break;
+				// 	case TabAlignment.END:
+				// 		str += "e";
+				// 		break;
+				// 	case TabAlignment.DECIMAL:
+				// 		str += "d";
+				// 		break;
+				// }
+				
+				str += tabStop.position.toString();
+				
+				if (tabStop.alignment == "decimal")
+				{
+					var escapedAlignmentToken:String = tabStop.decimalAlignmentToken.replace(_backslashRegex, "\\\\");
+					escapedAlignmentToken = escapedAlignmentToken.replace(_spaceRegex, "\\ ");
+					str += "|" + escapedAlignmentToken;
+				}
+			}
+			
+			return str;
+		}
+		
+		private static function compareTabStopFormats(a:TabStopFormat, b:TabStopFormat):Number
+		{
+			return a.position == b.position ? 0 : a.position < b.position ? -1 : 1;
+		}
+		
+		// Alignment type: [sScCeEdD]?  - Atmost 1 occurance of one of s/c/e/d (or upper-case equivalents)
+		// Position: [^| ]+ - At least character which is not a space or | (further validation is done by the Number constructor)
+		// Alignment token and separator:(|[^ ]*)? - Atmost one occurance of a | followed by 0 or more non-space characters
+		// Delimiter: ( |$) - A space or end-of-string
+		private static const _tabStopRegex:RegExp = /([sScCeEdD]?)([^| ]+)(|[^ ]*)?( |$)/g;
+		private static const _escapeBackslashRegex:RegExp = /\\\\/g;
+		private static const _escapeSpaceRegex:RegExp = /\\ /g;
+		private static const _backslashRegex:RegExp = /\\/g;
+		private static const _spaceRegex:RegExp = / /g;
+		private static const _backslashPlaceholderRegex:RegExp = /\uE000/g;
+		private static const _spacePlaceholderRegex:RegExp = /\uE001/g;
+		
+		// Replace escape sequences (\ followed by a space or \) with placeholder strings
+		// containing characters from Unicode private use area (won't naturally occur in the passed-in string) 
+		private static const _backslashPlaceHolder:String = String.fromCharCode(0xE000);
+		private static const _spacePlaceHolder:String = String.fromCharCode(0xE001);
+				
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/UintPropertyHandler.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/UintPropertyHandler.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/UintPropertyHandler.as
new file mode 100644
index 0000000..993072b
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/UintPropertyHandler.as
@@ -0,0 +1,75 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.property
+{
+
+		
+
+
+	// [ExcludeClass]
+	/** A property description with an unsigned integer as its value.  Typically used for color. @private */
+	public class UintPropertyHandler extends PropertyHandler
+	{	
+		override public function get className():String
+		{
+			return "UintPropertyHandler";
+		}
+		public override function get customXMLStringHandler():Boolean
+		{ return true; }
+		
+		public override function toXMLString(val:Object):String
+		{		
+			var result:String = val.toString(16);
+			if (result.length < 6)
+				result = "000000".substr(0, 6 - result.length) + result;
+			result = "#" + result;
+			return result;
+		}
+		
+		/** @private */
+		public override function owningHandlerCheck(newVal:*):*
+		{			
+			if (newVal is uint)
+				return newVal;
+			
+			var newRslt:Number;
+			if (newVal is String)
+			{
+				var str:String = String(newVal);
+				// Normally, we could just cast a string to a uint. However, the casting technique only works for
+				// normal numbers and numbers preceded by "0x". We can encounter numbers of the form "#ffffffff"					
+				if (str.substr(0, 1) == "#")
+					str = "0x" + str.substr(1, str.length-1);
+				newRslt = (str.toLowerCase().substr(0, 2) == "0x") ? parseInt(str) : NaN;
+			}
+			else if (newVal is Number || newVal is int)
+				newRslt = Number(newVal);
+			else
+				return undefined;
+			
+			if (isNaN(newRslt))
+				return undefined;
+
+			if (newRslt < 0 || newRslt > 0xffffffff)
+				return undefined;
+			
+			return newRslt;			
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/UndefinedPropertyHandler.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/UndefinedPropertyHandler.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/UndefinedPropertyHandler.as
new file mode 100644
index 0000000..8655df0
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/UndefinedPropertyHandler.as
@@ -0,0 +1,44 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.property
+{
+	import org.apache.flex.textLayout.debug.assert;
+		
+	// [ExcludeClass]
+	/** An property description with an enumerated string as its value. @private */
+	public class UndefinedPropertyHandler extends PropertyHandler
+	{
+		override public function get className():String
+		{
+			return "UndefinedPropertyHandler";
+		}
+		/** @private */
+		public override function owningHandlerCheck(newVal:*):*
+		{ 
+			return newVal === null || newVal === undefined ? true : undefined;
+		}
+
+		/** @private */
+		public override function setHelper(newVal:*):*
+		{ 
+			CONFIG::debug{ assert(newVal == true,"Bad call to UndefinedPropertyHandler.setHelper"); }
+			return undefined;
+		}	
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/tlf_internal.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/tlf_internal.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/tlf_internal.as
new file mode 100644
index 0000000..28b21e3
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/tlf_internal.as
@@ -0,0 +1,34 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout
+{
+
+	/**
+	 *  This namespace is used for undocumented APIs -- usually implementation
+	 *  details -- which can't be private because they need to visible
+	 *  to other classes.
+	 *  APIs in this namespace are completely unsupported and are likely to
+	 *  change in future versions of TextLayout.
+	 * 
+	 *  @private
+	 */
+	public namespace tlf_internal =
+		"http://ns.adobe.com/textLayout/internal/2008";
+}
+

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/BackgroundUtil.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/BackgroundUtil.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/BackgroundUtil.as
new file mode 100644
index 0000000..34def7c
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/BackgroundUtil.as
@@ -0,0 +1,262 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.utils
+{
+	import org.apache.flex.geom.Rectangle;
+	import org.apache.flex.text.engine.ITextBlock;
+	import org.apache.flex.text.engine.ITextLine;
+	import org.apache.flex.textLayout.compose.IFactoryComposer;
+	import org.apache.flex.textLayout.compose.IFlowComposer;
+	import org.apache.flex.textLayout.compose.ITextFlowLine;
+	import org.apache.flex.textLayout.compose.ITextFlowTableBlock;
+	import org.apache.flex.textLayout.compose.ParcelList;
+	import org.apache.flex.textLayout.container.IContainerController;
+	import org.apache.flex.textLayout.container.ITextContainerManager;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.elements.IBackgroundManager;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	import org.apache.flex.textLayout.elements.IFlowGroupElement;
+	import org.apache.flex.textLayout.elements.IFlowLeafElement;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.ITableCellElement;
+	import org.apache.flex.textLayout.elements.ITableRowElement;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.textLayout.elements.ITableElement;
+	import org.apache.flex.textLayout.formats.BackgroundColor;
+	import org.apache.flex.textLayout.formats.BorderColor;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+
+	public class BackgroundUtil
+	{
+		public static function collectTableBlock(_textFlow:ITextFlow, block:ITextFlowTableBlock, controller:IContainerController):void
+		{
+			// add block rect for each cell in table block
+
+			var bb:IBackgroundManager;
+			var r:Rectangle;
+			// var composer:IFlowComposer;
+
+			var cells:Vector.<ITableCellElement> = block.getTableCells();
+			for each (var cell:ITableCellElement in cells)
+			{
+				if (hasBorderOrBackground(cell))
+				{
+					if (!_textFlow.backgroundManager)
+						_textFlow.getBackgroundManager();
+					bb = _textFlow.backgroundManager;
+
+					bb.addBlockElement(cell);
+
+					var row:ITableRowElement = cell.getRow();
+					r = new Rectangle(cell.x, cell.y + block.y, cell.width, row.composedHeight);
+					bb.addBlockRect(cell, r, controller);
+				}
+			}
+			// block.y;
+		}
+		
+		/**
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.ITableElement
+		 */
+		public static function collectBlock(_textFlow:ITextFlow, elem:IFlowGroupElement, _parcelList:ParcelList = null, tableComposeNotFromBeginning:Boolean = false, tableOutOfView:Boolean = false):void
+		{
+			var bb:IBackgroundManager;
+			var r:Rectangle;
+			// var controller:IContainerController;
+			var composer:IFlowComposer;
+
+			if (elem)
+			{
+				if (hasBorderOrBackground(elem))
+				{
+					// mark the paragraph that has border or background
+					if (!_textFlow.backgroundManager)
+						_textFlow.getBackgroundManager();
+					bb = _textFlow.backgroundManager;
+
+					// IBackgroundManager should not be null here
+					CONFIG::debug
+					{
+						assert(_textFlow.backgroundManager != null, "IBackgroundManager should not be null");
+					}
+
+					bb.addBlockElement(elem);
+
+					composer = _textFlow.flowComposer;
+					if (composer && elem.textLength > 1)
+					{
+						if (elem is ITableElement)
+						{
+							// Do we need to do anything for table elements? Not sure...
+							var tab:ITableElement = elem as ITableElement;
+						}
+						else // for elements like ParagraphElement, DivElement, ListItemElement, ListElement, TextFlow
+						{
+							var tb:ITextBlock = null;
+							var p:IParagraphElement = elem.getFirstLeaf().getParagraph();
+							if (p)
+								tb = p.getTextBlock();
+							while (!tb && p)
+							{
+								p = p.getNextParagraph();
+								tb = p.getTextBlock();
+							}
+
+							if (composer is IFlowComposer && composer.numLines > 0)
+							{
+								// get the first line and the last line
+								var firstLine:ITextFlowLine = null;
+								var lastLine:ITextFlowLine = null;
+
+								if (tb && tb.firstLine)
+								{
+									firstLine = tb.firstLine.userData;
+
+									do
+									{
+										tb = p.getTextBlock();
+										if (tb && tb.lastLine)
+											lastLine = tb.lastLine.userData;
+										var leaf:IFlowLeafElement = p.getLastLeaf().getNextLeaf(elem);
+										if (leaf)
+											p = leaf.getParagraph();
+										else
+											p = null;
+									} while (p);
+								}
+								if (firstLine && lastLine)
+								{
+									var startColumnIndex:int = firstLine.columnIndex;
+									var startController:IContainerController = firstLine.controller;
+									var endColumnIndex:int = lastLine.columnIndex;
+									var endController:IContainerController = lastLine.controller;
+									if (startController && endController)
+									{
+										if (startController == endController && endColumnIndex == startColumnIndex)
+										{
+											r = startController.columnState.getColumnAt(startColumnIndex);
+											r.top = firstLine.y;
+											r.bottom = lastLine.y + lastLine.height;
+											bb.addBlockRect(elem, r, startController);
+										}
+										else
+										{
+											// start part
+											if (startController != endController)
+											{
+												for (var sIdx:int = startController.columnCount - 1; sIdx > startColumnIndex; sIdx--)
+												{
+													r = startController.columnState.getColumnAt(sIdx);
+													bb.addBlockRect(elem, r, startController);
+												}
+											}
+											if (endColumnIndex != startColumnIndex)
+											{
+												r = startController.columnState.getColumnAt(startColumnIndex);
+												r.top = firstLine.y;
+												bb.addBlockRect(elem, r, startController);
+											}
+											// center part, all parcel should be painted
+											var passFirstController:Boolean = false;
+											for (var aidx:Number = 0; aidx < composer.numControllers; aidx++)
+											{
+												var cc:IContainerController = composer.getControllerAt(aidx);
+												if (passFirstController)
+												{
+													for (var cidx:int = 0; cidx < cc.columnCount; cidx++)
+													{
+														r = cc.columnState.getColumnAt(cidx);
+														bb.addBlockRect(elem, r, cc);
+													}
+												}
+												if (cc == endController)
+													break;
+												if (cc == startController)
+													passFirstController = true;
+											}
+											// end part
+											if (startController != endController)
+											{
+												for (var eIdx:int = 0; eIdx < endColumnIndex; eIdx++)
+												{
+													r = endController.columnState.getColumnAt(eIdx);
+													bb.addBlockRect(elem, r, endController);
+												}
+											}
+											r = endController.columnState.getColumnAt(endColumnIndex);
+											r.bottom = lastLine.y + lastLine.height;
+											bb.addBlockRect(elem, r, endController);
+										}
+									}
+								}
+							}
+							// the first time display for TCM
+							else if (composer is IFactoryComposer)
+							{
+								var fLine:ITextLine = null;
+								var lLine:ITextLine = null;
+
+								if (tb && tb.firstLine)
+								{
+									fLine = tb.firstLine;
+
+									do
+									{
+										tb = p.getTextBlock();
+										if (tb && tb.lastLine)
+											lLine = tb.lastLine;
+										var leafF:IFlowLeafElement = p.getLastLeaf().getNextLeaf(elem);
+										if (leafF)
+											p = leafF.getParagraph();
+										else
+											p = null;
+									} while (p);
+								}
+								if (fLine && lLine)
+								{
+									if ((composer as Object).hasOwnProperty("tcm"))
+									{
+										var tcm:ITextContainerManager = (composer as Object).tcm;
+										if (tcm)
+										{
+											r = new Rectangle(0, fLine.y - fLine.height, tcm.compositionWidth, lLine.y - fLine.y + fLine.height);
+											bb.addBlockRect(elem, r, composer.getControllerAt(0));
+										}
+									}
+								}
+							}
+						}
+					}
+				}
+			}
+		}
+
+		public static function hasBorderOrBackground(elem:IFlowElement):Boolean
+		{
+			var format:ITextLayoutFormat = elem.computedFormat;
+			if (format.backgroundColor != BackgroundColor.TRANSPARENT)
+				return true;
+
+			if (format.borderLeftWidth != 0 || format.borderRightWidth != 0 || format.borderTopWidth != 0 || format.borderBottomWidth != 0)
+				if (format.borderLeftColor != BorderColor.TRANSPARENT || format.borderRightColor != BorderColor.TRANSPARENT || format.borderTopColor != BorderColor.TRANSPARENT || format.borderBottomColor != BorderColor.TRANSPARENT)
+					return true;
+			return false;
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/CharacterUtil.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/CharacterUtil.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/CharacterUtil.as
new file mode 100644
index 0000000..5d4b8a7
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/CharacterUtil.as
@@ -0,0 +1,167 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.utils
+{
+	/** 
+	 * Utilities for managing and getting information about characters.
+	 * The methods of this class are static and must be called using
+	 * the syntax <code>CharacterUtil.method(<em>parameter</em>)</code>.
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	public final class CharacterUtil
+	{
+		/** 
+		 * Returns <code>true</code> if the <code>charCode</code> argument is a high word in a surrogate pair. 
+		 * A surrogate pair represents a character with a code point that requires more
+		 * than sixteen bits to express and thus requires a combination
+		 * of two 16-bit words, a high surrogate and a low surrogate, to embody its code point.
+		 * <p>This method can be used when processing a series of characters to
+		 * ensure that you do not inadvertently divide a surrogate pair
+		 * into incomplete halves.</p>
+		 * 
+		 *
+		 * @param charCode An integer that represents a character code.
+		 * Character codes are usually represented in hexadecimal format.
+		 * For example, the space character's character code can be
+		 * represented by the number <code>0x0020</code>.
+		 * @return <code>true</code> if <code>charCode</code> is the high surrogate in a surrogate pair.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		static public function isHighSurrogate(charCode:int):Boolean
+		{
+			return (charCode >= 0xD800 && charCode <= 0xDBFF);
+		}
+		
+		/** 
+		 * Returns <code>true</code> if the <code>charCode</code> argument is a low word in a surrogate pair. 
+		 * A surrogate pair represents a character with a code point that requires more
+		 * than sixteen bits to express and thus requires a combination
+		 * of two 16-bit words, a high surrogate and a low surrogate, to embody its code point.
+		 * <p>This method can be used when processing a series of characters to
+		 * ensure that you do not inadvertently divide a surrogate pair
+		 * into incomplete halves.</p>
+		 *
+		 * @param charCode An integer that represents a character code.
+		 * Character codes are usually represented in hexadecimal format.
+		 * For example, the space character's character code can be
+		 * represented by the number <code>0x0020</code>.
+		 * @return <code>true</code> if <code>charCode</code> is the low surrogate in a surrogate pair.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		static public function isLowSurrogate (charCode:int):Boolean
+		{
+			return (charCode >= 0xDC00 && charCode <= 0xDFFF);
+		}
+
+		static private var whiteSpaceObject:Object = createWhiteSpaceObject();
+		
+		static private function createWhiteSpaceObject():Object
+		{
+			var rslt:Object = {};
+			//members of SpaceSeparator category
+			rslt[0x0020] =  true;  //SPACE
+			rslt[0x1680] =  true;  //OGHAM SPACE MARK
+			rslt[0x180E] =  true;  //MONGOLIAN VOWEL SEPARATOR
+			rslt[0x2000] =  true;  //EN QUAD
+			rslt[0x2001] =  true;  //EM QUAD
+			rslt[0x2002] =  true;  //EN SPACE
+			rslt[0x2003] =  true;  //EM SPACE
+			rslt[0x2004] =  true;  //THREE-PER-EM SPACE
+			rslt[0x2005] =  true;  //FOUR-PER-EM SPACE
+			rslt[0x2006] =  true;  //SIZE-PER-EM SPACE
+			rslt[0x2007] =  true;  //FIGURE SPACE
+			rslt[0x2008] =  true;  //PUNCTUATION SPACE
+			rslt[0x2009] =  true;  //THIN SPACE
+			rslt[0x200A] =  true;  //HAIR SPACE
+			rslt[0x202F] =  true;  //NARROW NO-BREAK SPACE
+			rslt[0x205F] =  true;  //MEDIUM MATHEMATICAL SPACE
+			rslt[0x3000] =  true;  //IDEOGRAPHIC SPACE
+			//members of LineSeparator category
+			rslt[0x2028] =  true;  //LINE SEPARATOR
+			//members of ParagraphSeparator category
+			rslt[0x2029] =  true;
+			//Other characters considered to be a space
+			rslt[0x0009] =  true; //CHARACTER TABULATION
+			rslt[0x000A] =  true; //LINE FEED
+			rslt[0x000B] =  true; //LINE TABULATION
+			rslt[0x000C] =  true; //FORM FEED
+			rslt[0x000D] =  true; //CARRIAGE RETURN
+			rslt[0x0085] =  true; //NEXT LINE
+			rslt[0x00A0] =  true; //NO-BREAK SPACE	
+			return rslt;
+		}
+		/** 
+		 * Returns <code>true</code> if <code>charCode</code> is a whitespace character. 
+		 * <p>The following table describes all characters that this
+		 * method considers a whitespace character.
+		 * </p>
+		 * <table class="innertable">
+		 *     <tr><th>Character Code</th><th>Unicode Character Name</th><th>Category</th></tr>
+		 *     <tr><td><code>0x0020</code></td><td>SPACE</td><td>Space Separator</td></tr>
+		 *     <tr><td><code>0x1680</code></td><td>OGHAM SPACE MARK</td><td>Space Separator</td></tr>
+		 *     <tr><td><code>0x180E</code></td><td>MONGOLIAN VOWEL SEPARATOR</td><td>Space Separator</td></tr>
+		 *     <tr><td><code>0x2000</code></td><td>EN QUAD</td><td>Space Separator</td></tr>
+		 *     <tr><td><code>0x2001</code></td><td>EM QUAD</td><td>Space Separator</td></tr>
+		 *     <tr><td><code>0x2002</code></td><td>EN SPACE</td><td>Space Separator</td></tr>
+		 *     <tr><td><code>0x2003</code></td><td>EM SPACE</td><td>Space Separator</td></tr>
+		 *     <tr><td><code>0x2004</code></td><td>THREE-PER-EM SPACE</td><td>Space Separator</td></tr>
+		 *     <tr><td><code>0x2005</code></td><td>FOUR-PER-EM SPACE</td><td>Space Separator</td></tr>
+		 *     <tr><td><code>0x2006</code></td><td>SIX-PER-EM SPACE</td><td>Space Separator</td></tr>
+		 *     <tr><td><code>0x2007</code></td><td>FIGURE SPACE</td><td>Space Separator</td></tr>
+		 *     <tr><td><code>0x2008</code></td><td>PUNCTUATION SPACE</td><td>Space Separator</td></tr>
+		 *     <tr><td><code>0x2009</code></td><td>THIN SPACE</td><td>Space Separator</td></tr>
+		 *     <tr><td><code>0x200A</code></td><td>HAIR SPACE</td><td>Space Separator</td></tr>
+		 *     <tr><td><code>0x202F</code></td><td>NARROW NO-BREAK SPACE</td><td>Space Separator</td></tr>
+		 *     <tr><td><code>0x205F</code></td><td>MEDIUM MATHEMATICAL SPACE</td><td>Space Separator</td></tr>
+		 *     <tr><td><code>0x3000</code></td><td>IDEOGRAPHIC SPACE</td><td>Space Separator</td></tr>
+		 *     <tr><td><code>0x2028</code></td><td>LINE SEPARATOR</td><td>Line Separator</td></tr>
+		 *     <tr><td><code>0x2029</code></td><td>PARAGRAPH SEPARATOR</td><td>Paragraph Separator</td></tr>
+		 *     <tr><td><code>0x0009</code></td><td>CHARACTER TABULATION</td><td>Other</td></tr>
+		 *     <tr><td><code>0x000A</code></td><td>LINE FEED</td><td>Other</td></tr>
+		 *     <tr><td><code>0x000B</code></td><td>LINE TABULATION</td><td>Other</td></tr>
+		 *     <tr><td><code>0x000C</code></td><td>FORM FEED</td><td>Other</td></tr>
+		 *     <tr><td><code>0x000D</code></td><td>CARRIAGE RETURN</td><td>Other</td></tr>
+		 *     <tr><td><code>0x0085</code></td><td>NEXT LINE</td><td>Other</td></tr>
+		 *     <tr><td><code>0x00A0</code></td><td>NO-BREAK SPACE</td><td>Other</td></tr>
+		 *  </table>
+
+		 *
+		 * @param charCode An integer that represents a character code.
+		 * Character codes are usually represented in hexadecimal format.
+		 * For example, the space character's character code can be
+		 * represented by the number <code>0x0020</code>.
+		 *
+		 * @return <code>true</code> if <code>charCode</code> is a whitespace character. 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		static public function isWhitespace(charCode:int):Boolean
+		{			
+			return whiteSpaceObject[charCode];
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/ComposeUtils.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/ComposeUtils.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/ComposeUtils.as
new file mode 100644
index 0000000..8a1bc66
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/ComposeUtils.as
@@ -0,0 +1,48 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.utils
+{
+	import org.apache.flex.textLayout.compose.ComposeState;
+	import org.apache.flex.textLayout.compose.IComposer;
+	public class ComposeUtils
+	{
+		
+		// a single ComposeState that is checked out and checked in
+		static private var _sharedComposeState:IComposer;
+
+		/** @private */
+		static public function getComposeState():IComposer
+		{
+			var rslt:IComposer = _sharedComposeState;
+			if (rslt)
+			{
+				_sharedComposeState = null;
+				return rslt;
+			}
+			return new ComposeState();
+		}
+		
+		/** @private */
+		static public function releaseComposeState(state:IComposer):void
+		{
+			state.releaseAnyReferences();
+			_sharedComposeState = state;
+		}				
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/ConfigUtils.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/ConfigUtils.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/ConfigUtils.as
new file mode 100644
index 0000000..eb158b3
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/ConfigUtils.as
@@ -0,0 +1,24 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.utils
+{
+	public class ConfigUtils
+	{
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/CreateTLFUtil.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/CreateTLFUtil.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/CreateTLFUtil.as
new file mode 100644
index 0000000..4fc8d88
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/CreateTLFUtil.as
@@ -0,0 +1,197 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.utils
+{
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.formats.FormatValue;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+	import org.apache.flex.textLayout.property.Property;
+	import org.apache.flex.textLayout.property.PropertyUtil;
+	public class CreateTLFUtil
+	{
+		public static function createTLF(localStyles:ITextLayoutFormat, parentPrototype:TextLayoutFormat):TextLayoutFormat
+		{
+			var parentPrototypeUsable:Boolean = true;
+			var hasStylesSet:Boolean = false;
+			// the actual prototype to use
+			var parentStylesPrototype:Object;
+			// create a new stylesObject with a parentPrototype
+			if (parentPrototype)
+			{
+				parentStylesPrototype = parentPrototype.getStyles();
+				if (parentStylesPrototype.hasNonInheritedStyles !== undefined)
+				{
+					// its either a boolean or if its been used once an object that has the non-inheriting styles reset
+					if (parentStylesPrototype.hasNonInheritedStyles === true)
+					{
+						// create a modified prototype and give it all default non-inherited values
+						var noInheritParentStylesPrototype:Object = PropertyUtil.createObjectWithPrototype(parentStylesPrototype);
+						TextLayoutFormat.resetModifiedNoninheritedStyles(noInheritParentStylesPrototype);
+						// now save it in the parent for reuse
+						parentStylesPrototype.hasNonInheritedStyles = noInheritParentStylesPrototype;
+						parentStylesPrototype = noInheritParentStylesPrototype;
+					}
+					else
+					{
+						parentStylesPrototype = parentStylesPrototype.hasNonInheritedStyles;
+					}
+					parentPrototypeUsable = false;	// can't use it
+				}
+			}
+			else
+			{
+				parentPrototype = TextLayoutFormat.defaultFormat as TextLayoutFormat;
+				parentStylesPrototype = parentPrototype.getStyles();
+			}
+
+			var stylesObject:Object = PropertyUtil.createObjectWithPrototype(parentStylesPrototype);
+
+			var key:String;
+			var val:*;
+			var prop:Property;
+			// has nonInherited Styles that are *different* from the default
+			var hasNonInheritedStyles:Boolean = false;
+
+			// two cases depending on how localStyles are supplied
+			if (localStyles != null)
+			{
+				var lvh:TextLayoutFormat = localStyles as TextLayoutFormat;
+				if (lvh)
+				{
+					var coreStyles:Object = lvh.getStyles();
+
+					for (key in coreStyles)
+					{
+						val = coreStyles[key];
+						if (val == FormatValue.INHERIT)
+						{
+							if (parentPrototype)
+							{
+								prop = TextLayoutFormat.description[key];
+								if (prop && !prop.inherited)
+								{
+									// actually do the inheritance - might have been wiped out above!
+									val = parentPrototype[key];
+									if (stylesObject[key] != val)
+									{
+										stylesObject[key] = val;
+										hasNonInheritedStyles = true;
+										hasStylesSet = true;
+										// CONFIG::debug { assert(val != prop.defaultValue,"Unexpected non-inheritance"); }
+									}
+								}
+							}
+						}
+						else
+						{
+							if (stylesObject[key] != val)
+							{
+								prop = TextLayoutFormat.description[key];
+								if (prop && !prop.inherited)
+								{
+									// CONFIG::debug { assert(val != prop.defaultValue,"Unexpected non-inheritance"); }
+									hasNonInheritedStyles = true;
+								}
+								stylesObject[key] = val;
+								hasStylesSet = true;	// doesn't matter if inherited or not
+							}
+						}
+					}
+				}
+				else
+				{
+					for each (prop in TextLayoutFormat.description)
+					{
+						key = prop.name;
+						val = localStyles[key];
+						if (val !== undefined)
+						{
+							if (val == FormatValue.INHERIT)
+							{
+								if (parentPrototype)
+								{
+									if (!prop.inherited)
+									{
+										// actually do the inheritance - might have been wiped out above!
+										val = parentPrototype[key];
+										if (stylesObject[key] != val)
+										{
+											stylesObject[key] = val;
+											hasNonInheritedStyles = true;
+											hasStylesSet = true;
+											// CONFIG::debug { assert(val != prop.defaultValue,"Unexpected non-inheritance"); }
+										}
+									}
+								}
+							}
+							else
+							{
+								if (stylesObject[key] != val)
+								{
+									if (!prop.inherited)
+									{
+										// CONFIG::debug { assert(val != prop.defaultValue,"Unexpected non-inheritance"); }
+										hasNonInheritedStyles = true;
+									}
+									stylesObject[key] = val;
+									hasStylesSet = true;	// doesn't matter if inherited or not
+								}
+							}
+						}
+					}
+				}
+			}
+
+			var rslt:TextLayoutFormat;
+
+			if (!hasStylesSet)
+			{
+				// nothing has changed from the parent so just reuse it
+				CONFIG::debug{ assert(hasNonInheritedStyles == false, "stylesCount mismatch with hasNonInheritedStyles"); }
+				if (parentPrototypeUsable)
+					return parentPrototype;
+				// we can use the parentStylesPrototype but not the parentPrototype
+				rslt = new TextLayoutFormat();
+				rslt.setStyles(stylesObject, true);
+				return rslt;
+			}
+
+			if (hasNonInheritedStyles)
+			{
+				// if its not identical in stylesObject need to set it
+				CONFIG::debug
+				{
+					assert(stylesObject.hasNonInheritedStyles !== hasNonInheritedStyles, "unexpected nonInheritedStyles"); }
+				stylesObject.hasNonInheritedStyles = true;
+				stylesObject.setPropertyIsEnumerable("hasNonInheritedStyles", false);
+			}
+			else if (stylesObject.hasNonInheritedStyles !== undefined)
+			{
+				stylesObject.hasNonInheritedStyles = undefined;
+				stylesObject.setPropertyIsEnumerable("hasNonInheritedStyles", false);
+			}
+
+			rslt = new TextLayoutFormat();
+			rslt.setStyles(stylesObject, false);
+			return rslt;
+		}
+		
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/FactoryUtil.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/FactoryUtil.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/FactoryUtil.as
new file mode 100644
index 0000000..6819b86
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/FactoryUtil.as
@@ -0,0 +1,46 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.utils
+{
+	import org.apache.flex.textLayout.compose.FactoryComposer;
+	import org.apache.flex.textLayout.factory.ITLFFactory;
+	import org.apache.flex.textLayout.factory.StandardTLFFactory;
+	public class FactoryUtil
+	{
+		/** @private */
+		public static function getDefaultFlowComposerClass():Class
+		{
+			return FactoryComposer;
+		}
+		
+		private static var _defaultTLFFactory:ITLFFactory;
+		
+		public static function get defaultTLFFactory():ITLFFactory
+		{
+			if(!_defaultTLFFactory)
+				_defaultTLFFactory = new StandardTLFFactory();
+			return _defaultTLFFactory; 
+		}
+
+		public static function set defaultTLFFactory(value:ITLFFactory):void
+		{
+			_defaultTLFFactory = value;
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/GeometryUtil.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/GeometryUtil.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/GeometryUtil.as
new file mode 100644
index 0000000..628ef70
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/GeometryUtil.as
@@ -0,0 +1,128 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.utils
+{
+	import org.apache.flex.geom.Rectangle;
+	import org.apache.flex.text.engine.ITextLine;
+	
+	import org.apache.flex.textLayout.compose.IFlowComposer;
+	import org.apache.flex.textLayout.compose.ITextFlowLine;
+	import org.apache.flex.textLayout.elements.TextRange;
+
+	
+
+	/** 
+	 * Utilities for getting information about text geometry and bounds.
+	 * The methods of this class are static and must be called using
+	 * the syntax <code>GeometryUtil.method(<em>parameter</em>)</code>.
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	//  [ExcludeClass]
+	public final class GeometryUtil
+	{
+		/**
+		 * Returns an array of line/rectangle object pairs describing the highlight area of the text 
+		 * based on the content bounded within the indicies. The rectangles are the same as those which would be 
+		 * created if the text were selected. May return one or more pair per line.
+		 * 
+		 * 
+		 * @param range	- a TextRange describing the TextFlow as well as the beginning and end indicies
+		 * @return Array - An array of TextLine and Rectangle pairs. The objects can be referenced as:
+		 * 		obj.textLine - to access the TextLine object
+		 *		obj.rect - to access the rectangle describing the selection in TextLine coordinates
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 * Example Usage:
+		 *  var theRect:Rectangle = returnArray[0].rect.clone(); 
+		 *  var textLine:TextLine = returnArray[0].textLine; 
+		 * 	var globalStart:Point = new Point(theRect.x, theRect.y);
+		 *  globalStart = textLine.localToGlobal(globalStart);
+		 *  globalStart = textLine.parent.globalToLocal(globalStart);
+		 *  theRect.x = globalStart.x;
+		 *  theRect.y = globalStart.y;
+		 * 
+		 *  [Make a new shape and draw the path into it. See flash.display.graphics]
+		 *  textLine.parent.addChild(newShape);
+		 */
+		public static function getHighlightBounds(range:TextRange):Array
+		{
+			var flowComposer:IFlowComposer = range.textFlow.flowComposer;
+			if (!flowComposer)
+				return null;
+			
+			
+			var resultShapes:Array = new Array();
+			
+			var begLine:int = flowComposer.findLineIndexAtPosition(range.absoluteStart);
+			var endLine:int = range.absoluteStart == range.absoluteEnd ? begLine : flowComposer.findLineIndexAtPosition(range.absoluteEnd);
+			
+			// watch for going past the end
+			if (endLine >= flowComposer.numLines)
+				endLine = flowComposer.numLines-1;
+					
+			var prevLine:ITextFlowLine = begLine > 0 ? flowComposer.getLineAt(begLine-1) : null;
+			var nextLine:ITextFlowLine;
+
+			var line:ITextFlowLine = flowComposer.getLineAt(begLine); 			
+			
+			var mainRects:Array = [];
+			
+			for (var curLineIndex:int = begLine; curLineIndex <= endLine; curLineIndex++)
+			{
+				nextLine = curLineIndex != (flowComposer.numLines - 1) ? flowComposer.getLineAt(curLineIndex + 1) : null;
+				
+				
+				var heightAndAdj:Array = line.getRomanSelectionHeightAndVerticalAdjustment(prevLine, nextLine);
+				
+				var textLine:ITextLine = line.getTextLine(true);
+
+				line.calculateSelectionBounds(textLine, mainRects, 
+					range.absoluteStart < line.absoluteStart ? line.absoluteStart - line.paragraph.getAbsoluteStart()
+ 															 : range.absoluteStart - line.paragraph.getAbsoluteStart(), 
+					range.absoluteEnd > (line.absoluteStart + line.textLength) ? line.absoluteStart + line.textLength - line.paragraph.getAbsoluteStart()
+																			   : range.absoluteEnd - line.paragraph.getAbsoluteStart(), 
+					range.textFlow.computedFormat.blockProgression, heightAndAdj);
+				
+					
+				for each(var rect:Rectangle in mainRects)
+				{
+					var obj:Object = {};	// NO PMD
+					obj.textLine = textLine;
+					obj.rect = rect.clone();
+					
+					resultShapes.push(obj);
+				}
+				mainRects.length = 0;
+				
+				var temp:ITextFlowLine = line;
+				line = nextLine;
+				prevLine = temp;
+			}
+			
+			return resultShapes;
+		}
+	}
+	
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/HitTestArea.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/HitTestArea.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/HitTestArea.as
new file mode 100644
index 0000000..4eba8b9
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/HitTestArea.as
@@ -0,0 +1,287 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.utils {
+	import org.apache.flex.geom.Rectangle;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.elements.FlowElement;
+
+	
+
+	
+	// [ExcludeClass]
+	/**
+	 * The HitTestArea class is a lightweight implementation of the Warnock
+	 * algorithm for rectangles. It is used for hit-testing in FlowElements, which 
+	 * may contain multiple child elements. The algorithm attempts to set the logical
+	 * midpoint to be outside of a bounding rectangle to avoid having to split too many rectangles.
+	 * Note that the code is optimized for non-overlapping rectangles;
+	 * the determination of the logical midpoint does not work well for overlapping
+	 * rectangles because the algorithm breaks once it found a rectangle that contains
+	 * the geometric midpoint.
+	 * 
+	 * The pseudocode for this algorithm is:
+	 * 
+	 * if !(point in this rectangle) return false;
+	 * if !(hasKids) return true;
+	 * determine the quadrant where the point is in (top left "tl", top right "tr",
+	 * bottom left "bl", or bottom right "br");
+	 * if this[quadrant] == null, return false; // no rectangle covers this area
+	 * else return this[quadrant].hitTest(x,y);
+	 * 
+	 * To avoid having to create a 4-element array for the four quadrants, the code
+	 * constructs the property name and accesses the property with dynamic lookup.
+	 */
+	public class HitTestArea
+	{
+//		private var tl:HitTestArea = null;	// top left quadrant	// NO PMD
+//		private var tr:HitTestArea = null;	// top right quadrant	// NO PMD
+//		private var bl:HitTestArea = null;	// bottom left quadrant	// NO PMD
+//		private var br:HitTestArea = null;	// bottom right quadrant	// NO PMD
+		
+		private var _rect:Rectangle;	// the bounding rectangle
+		private var _xm:Number;			// logical midpoint
+		private var _ym:Number;
+		
+		/**
+		 * The owning FlowElement is the element whose area this HitTestArea
+		 * covers. This variable is set for a rectangle if the structure passed
+		 * in to the constructor contains an "owner" property. If it is null,
+		 * the instance has child quadrants.
+		 */
+		private var _owner:FlowElement = null;
+		
+		CONFIG::debug
+		{
+//			static private var _depth:int = 0;
+			/**
+			 * This array takes the counts for recursion depths on hit testing.
+			 */
+			static public const depths:Array = [];	
+		}		
+		/**
+		 * Create a HitTestArea with an object containing enumerable property objects as a rectangle
+		 * in a "rect" property, and a a FlowElement in its "owner" property. First, 
+		 * determine the bounding rectangle; then, determine the midpoint, and fill
+		 * in each quadrant with the intersecting rectangles.
+		 * @param obj    An object containing {rect:Rectangle, owner:FlowElement} objects as property values.
+		 */
+		public function HitTestArea(objects:Object)
+		{
+			initialize(objects);
+		}
+		
+		/** @private */
+		public function initialize(objects:Object):void
+		{
+			var obj:Object;
+			// determine the number of objects; all we need to know is 0, 1, or more
+			var count:int = 0;
+			if (objects)
+			{
+				for (obj in objects)
+				{
+					if (++count > 1)
+						break;
+				}
+			}
+			
+			if (count == 0)
+			{
+				_rect = new Rectangle();
+				_xm = _ym = 0;
+				return;
+			}
+			
+			// Determine the bounding rectangle
+			// if the object only has one element, it is easy
+			if (count == 1)
+			{
+				for each (obj in objects)
+				{
+					_rect = obj.rect;
+					_xm = _rect.left;
+					_ym = _rect.top;
+					_owner = obj.owner;
+					CONFIG::debug { assert(_owner != null, "No owner given"); }
+					return;
+				}
+			}
+			
+			var r:Rectangle;
+			// if more than one element, we need to calulate and fill
+			for each (obj in objects)
+			{
+				r = obj.rect;
+				if (!_rect)
+					_rect = r;
+				else
+					_rect = _rect.union(r);
+			}
+			
+			// Set the geometric midpoint
+			_xm = Math.ceil(_rect.left + _rect.width / 2);
+			_ym = Math.ceil(_rect.top + _rect.height / 2);
+			
+			// Hard stop here: if the bounding rectangle is < 3 pixels in any direction,
+			// we consider it to be a single rectangle.
+			if (_rect.width <= 3 || _rect.height <= 3)
+			{
+				// Here, we set the owner to the first element's owner
+				for each (obj in objects)
+				{
+					_owner = obj.owner;
+					CONFIG::debug { assert(_owner != null, "No owner given"); }
+					return;
+				}
+			}
+			
+			// Determine the logical midpoint. This point is as close to
+			// the geometric midpoint as possible. If the midpoint is inside 
+			// a rectangle, the midpoint is adjusted to the nearest point 
+			// outside of the rectangle if possible to avoid excessive 
+			// splitting of rectangles. The first point is used as the new
+			// midpoint to avoid having to deal with overlapping rectangles,
+			// which should usually not appear at all.
+			for each (obj in objects)
+			{
+				r = obj.rect;
+				if (r.equals(_rect))
+					continue;
+				
+				if (r.contains(_xm, _ym))
+				{
+					// The midpoint is over a rectangle; find the closest
+					// rectangle boundary and move the midpoint there
+					var dxLower:Number = _xm - r.left;
+					var dxUpper:Number = r.right - _xm;
+					var dyLower:Number = _ym - r.top;
+					var dyUpper:Number = r.bottom - _ym;
+					// this may lead to _xm and/or _ym being equal to left/top
+					_xm = (dxLower > dxUpper) ? _xm + dxUpper : _xm - dxLower;
+					_ym = (dyLower > dyUpper) ? _ym + dyUpper : _ym - dyLower;
+					// this should be changed if overlapping rectangles need to be supported
+					// in that case, all rectangles that have a hit shouldd be checked to
+					// determine the closest boundary
+					break;
+				}
+			}
+			
+			// Insert all rectangles into the respective quadrants
+			var quadrant:Rectangle = new Rectangle(_rect.left, _rect.top, _xm - _rect.left, _ym - _rect.top);
+			addQuadrant(objects, "tl", quadrant);
+			quadrant.left = _xm;
+			quadrant.right = _rect.right;
+			addQuadrant(objects, "tr", quadrant);
+			quadrant.left = _rect.left;
+			quadrant.top = _ym;
+			quadrant.right = _xm;
+			quadrant.bottom = _rect.bottom;
+			addQuadrant(objects, "bl", quadrant);
+			quadrant.left = _xm;
+			quadrant.right = _rect.right;
+			addQuadrant(objects, "br", quadrant);
+		}
+		
+		/**
+		 * Do a hit test. If the point is within this rectangle, determine
+		 * the quadrant of the point. If the quadrant is empty, the hit test
+		 * is true. If not, recurse into that quadrant.
+		 * @param x    the X coordinate
+		 * @param y    the Y coordinate
+		 * @return     the owner if the hit test succeeds, null otherwise
+		 */
+		public function hitTest(x:Number, y:Number):FlowElement
+		{
+			if (!_rect.contains(x, y))
+				return null;
+			// if there are no kids (the owner is set), the rectangle has been hit
+			// no need to attempt to retrieve the quadrant
+			if (_owner)
+				return _owner;
+			// determine quadrant
+			var quadrantName:String = (y < _ym) ? "t" : "b";
+			quadrantName += (x < _xm) ? "l" : "r";
+			var quadrant:HitTestArea = this[quadrantName];
+			// there is no child rectangle here: no hit
+			if (quadrant == null)
+				return null;
+			// ask the child
+			return quadrant.hitTest(x, y);
+		}
+
+		/* Use this version to track hit testing in debug code
+		public function hitTest(x:Number, y:Number, depth:int=1):FlowElement
+		{
+			if (!_rect.contains(x, y))
+			{
+				trace("Depth " + depth + ": " + x + "," + y);
+				return null;
+			}
+			// if there are no kids (the owner is set), the rectangle has been hit
+			// no need to attempt to retrieve the quadrant
+			if (_owner)
+			{
+				trace("Depth " + depth + ": " + x + "," + y + ": " + _owner);
+				if (depths[depth] == undefined)
+					depths[depth] = 0;
+				depths[depth]++;
+				return _owner;
+			}
+			// determine quadrant
+			var quadrantName:String = (y < _ym) ? "t" : "b";
+			quadrantName += (x < _xm) ? "l" : "r";
+			var quadrant:HitTestArea = this[quadrantName];
+			// there is no child rectangle here: no hit
+			if (quadrant == null)
+			{
+				trace("Depth " + depth + ": " + x + "," + y);
+				return null;
+			}
+			// ask the child
+			return quadrant.hitTest(x, y, depth+1);
+		}
+		*/
+		/** @private
+		 * Add the given objects of rectangles to the given quadrant. Create an array of
+		 * intersecting rectangles, and, if that array if not empty, create a new
+		 * HitTestArea covering these rectangles, and store it into the quadrant
+		 * property. Note that this method is recursive.
+		 * @param arr        An object of rectangle objects.
+		 * @param propName   The name of the quadrant property (tl, tr, bl, br).
+		 * @param quadrant   The bounding rectangle for this quadrant.
+		 */
+		private function addQuadrant(objects:Object, propName:String, quadrant:Rectangle):void
+		{
+			if (quadrant.isEmpty())
+				return;
+			
+			// Collect the objects of intersecting rectangles
+			var qrects:Object = {};
+			var i:int = 0;
+			for each (var obj:Object in objects)
+			{
+				var intersect:Rectangle = obj.rect.intersection(quadrant);
+				if (!intersect.isEmpty())
+					qrects[i++] = {owner:obj.owner, rect:intersect};
+			}
+			if (i > 0)
+				this[propName] = new HitTestArea(qrects);
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/LocaleUtil.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/LocaleUtil.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/LocaleUtil.as
new file mode 100644
index 0000000..c0e3fe0
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/utils/LocaleUtil.as
@@ -0,0 +1,211 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.utils
+{
+	import org.apache.flex.text.engine.JustificationStyle;
+	
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.formats.JustificationRule;
+	import org.apache.flex.textLayout.formats.LeadingModel;
+
+	
+	
+
+	/** 
+	 * Utilities for managing and getting information about Locale based defaults.
+	 * The methods of this class are static and must be called using
+	 * the syntax <code>LocaleUtil.method(<em>parameter</em>)</code>.
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	// [ExcludeClass]
+	public final class LocaleUtil
+	{
+		public function LocaleUtil()
+		{
+		}
+		
+		
+		/** @private */
+		static private var _localeSettings:Object = null;
+		static private var _lastLocaleKey:String = "";
+		static private var _lastLocale:LocaleSettings = null;
+		
+		static public function justificationRule(locale:String):String 
+		{
+			var localeSet:LocaleSettings = fetchLocaleSet(locale);
+			CONFIG::debug{ assert(localeSet != null, "Failed to get LocaleSettings from locale! locale = " + locale); }
+			
+			return localeSet.justificationRule;
+		}
+		
+		static public function justificationStyle(locale:String):String
+		{
+			var localeSet:LocaleSettings = fetchLocaleSet(locale);
+			CONFIG::debug{ assert(localeSet != null, "Failed to get LocaleSettings from locale! locale = " + locale); }
+			
+			return localeSet.justificationStyle;
+		}
+		
+		static public function leadingModel(locale:String):String
+		{
+			var localeSet:LocaleSettings = fetchLocaleSet(locale);
+			CONFIG::debug{ assert(localeSet != null, "Failed to get LocaleSettings from locale! locale = " + locale); }
+			
+			return localeSet.leadingModel;
+		}
+		
+		
+		static public function dominantBaseline(locale:String):String
+		{
+			var localeSet:LocaleSettings = fetchLocaleSet(locale);
+			CONFIG::debug{ assert(localeSet != null, "Failed to get LocaleSettings from locale! locale = " + locale); }
+			
+			return localeSet.dominantBaseline;
+		}
+		
+		
+		/** @private */
+		static private function addLocale(locale:String):LocaleSettings
+		{
+			CONFIG::debug{ assert(_localeSettings[locale] == null, "Cannot add a new locale property set when it already exists.  Locale == " + locale); }
+			_localeSettings[locale] = new LocaleSettings();
+			return _localeSettings[locale];
+		}
+		
+		/** @private */
+		static private function initializeDefaultLocales():void
+		{
+			CONFIG::debug{ assert(_localeSettings == null, "Should not call initializeDefaultLocales when dictionary exists!"); }
+			_localeSettings = {};
+			
+			{
+				var locale:LocaleSettings = addLocale("en");
+				CONFIG::debug{ assert(locale != null, "Failed to create new locale for 'en'!"); }
+	
+				locale.justificationRule = JustificationRule.SPACE;
+				locale.justificationStyle = JustificationStyle.PUSH_IN_KINSOKU;
+				locale.leadingModel = LeadingModel.ROMAN_UP;
+				locale.dominantBaseline = "roman";
+				
+				locale = addLocale("ja");
+				CONFIG::debug{ assert(locale != null, "Failed to create new locale for 'ja'!"); }
+	
+				locale.justificationRule = JustificationRule.EAST_ASIAN;
+				locale.justificationStyle = JustificationStyle.PUSH_IN_KINSOKU;
+				locale.leadingModel = LeadingModel.IDEOGRAPHIC_TOP_DOWN;
+				locale.dominantBaseline = "ideographicCenter";
+				
+				locale = addLocale("zh");
+				CONFIG::debug{ assert(locale != null, "Failed to create new locale for 'zh'!"); }
+	
+				locale.justificationRule = JustificationRule.EAST_ASIAN;
+				locale.justificationStyle = JustificationStyle.PUSH_IN_KINSOKU;
+				locale.leadingModel = LeadingModel.IDEOGRAPHIC_TOP_DOWN;
+				locale.dominantBaseline = "ideographicCenter";
+			}		
+		}
+		
+		/** @private */
+		static private function getLocale(locale:String):LocaleSettings
+		{
+			var lowerLocale:String = locale.toLowerCase().substr(0,2);
+			var rslt:LocaleSettings = _localeSettings[lowerLocale];
+			return rslt == null ? _localeSettings["en"] : rslt;
+		}
+		
+		/** @private */
+		static private function fetchLocaleSet(locale:String):LocaleSettings
+		{
+			if(_localeSettings == null)
+				initializeDefaultLocales();
+			
+			if(locale == _lastLocaleKey)
+				return _lastLocale;
+			
+			var localeSet:LocaleSettings = getLocale(locale);
+			
+			//update the last locale data
+			_lastLocale = localeSet;
+			_lastLocaleKey = locale;
+			return localeSet;
+		}
+	}
+}
+
+
+import org.apache.flex.textLayout.debug.assert;
+
+import org.apache.flex.textLayout.formats.TextLayoutFormat;
+
+
+
+class LocaleSettings
+{
+	public function LocaleSettings()
+	{}
+	
+	private var _justificationRule:String = null;
+	private var _justificationStyle:String = null;
+	private var _leadingModel:String = null;
+	private var _dominantBaseline:String = null;
+	
+	public function get justificationRule():String { return _justificationRule; }
+	public function set justificationRule(newValue:String):void 
+	{ 
+		var setValue:Object = TextLayoutFormat.justificationRuleProperty.setHelper(_justificationRule,newValue);
+		//don't assert if the newValue is null, only if it is invalid
+		CONFIG::debug{ assert(newValue == null || setValue != null, "LocaleUtil should never be providing an invalid JustificationRule!"); }
+		
+		_justificationRule = setValue == null ? null : (setValue as String);
+	}
+	
+	public function get justificationStyle():String { return _justificationStyle; }
+	public function set justificationStyle(newValue:String):void 
+	{ 
+		var setValue:Object = TextLayoutFormat.justificationStyleProperty.setHelper(_justificationStyle,newValue);
+		//don't assert if the newValue is null, only if it is invalid
+		CONFIG::debug{ assert(newValue == null || setValue != null, "LocaleUtil should never be providing an invalid LeadingDirection!"); }
+		
+		_justificationStyle = setValue == null ? null : (setValue as String);
+	}
+	
+	public function get leadingModel():String { return _leadingModel; }
+	public function set leadingModel(newValue:String):void 
+	{ 
+		var setValue:Object = TextLayoutFormat.leadingModelProperty.setHelper(_leadingModel,newValue);
+		//don't assert if the newValue is null, only if it is invalid
+		CONFIG::debug{ assert(newValue == null || setValue != null, "LocaleUtil should never be providing an invalid JustificationStyle!"); }
+		
+		_leadingModel = setValue == null ? null : (setValue as String);
+	}
+	
+	
+	public function get dominantBaseline():String { return _dominantBaseline; }
+	public function set dominantBaseline(newValue:String):void 
+	{ 
+		var setValue:Object = TextLayoutFormat.dominantBaselineProperty.setHelper(_dominantBaseline,newValue);
+		//don't assert if the newValue is null, only if it is invalid
+		CONFIG::debug{ assert(newValue == null || setValue != null, "LocaleUtil should never be providing an invalid TextBaseline!"); }
+		
+		_dominantBaseline = setValue == null ? null : (setValue as String);
+	}
+}
\ No newline at end of file


[05/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/VerticalAlign.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/VerticalAlign.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/VerticalAlign.as
new file mode 100644
index 0000000..56708bd
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/VerticalAlign.as
@@ -0,0 +1,68 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.formats
+{
+	/**
+	 *  Defines values for the <code>verticalAlign</code> property of the TextLayoutFormat class. Specifies how 
+	 *  TextFlow elements align with their containers.  
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 *  @see TextLayoutFormat#verticalAlign
+	 */
+	public final class VerticalAlign
+	{
+		/** Specifies alignment with the top edge of the frame. 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		 
+		public static const TOP:String = "top";
+		
+		/** Specifies alignment with the bottom edge of the frame. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		 
+		public static const BOTTOM:String = "bottom";
+		
+		/** Specifies alignment with the middle of the frame. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		 
+		public static const MIDDLE:String = "middle";
+		
+		/** Specifies vertical line justification within the frame 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		
+		public static const JUSTIFY:String = "justify";		
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/WhiteSpaceCollapse.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/WhiteSpaceCollapse.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/WhiteSpaceCollapse.as
new file mode 100644
index 0000000..a5e6d9e
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/WhiteSpaceCollapse.as
@@ -0,0 +1,51 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.formats
+{
+	/**
+	 *  Defines values for setting the <code>whiteSpaceCollapse</code> property
+	 *  of the <code>TextLayoutFormat</code> class. 
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 *  
+	 *  @see TextLayoutFormat#whiteSpaceCollapse
+	 */
+	public final class WhiteSpaceCollapse
+	{
+		/** 
+		 * Collapse whitespace when importing text (default).
+		 * Within a block of imported text, removes newlines, tabs, and leading and trailing
+		 * spaces. Retains line break tags (br/) and Unicode line
+		 * separator characters.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public static const COLLAPSE:String = "collapse";
+		
+		/** Preserves whitespace when importing text. 
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+		* @langversion 3.0
+		*/ 
+		public static const PRESERVE:String = "preserve";
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ApplyElementIDOperation.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ApplyElementIDOperation.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ApplyElementIDOperation.as
new file mode 100644
index 0000000..edecec7
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ApplyElementIDOperation.as
@@ -0,0 +1,103 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.operations
+{
+	import org.apache.flex.textLayout.edit.SelectionState;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+
+
+
+	
+	/**
+	 * The ChangeElementIDOperation class encapsulates an element ID change.
+	 *
+	 * @see org.apache.flex.textLayout.elements.FlowElement
+	 * @see org.apache.flex.textLayout.edit.EditManager
+	 * @see org.apache.flex.textLayout.events.FlowOperationEvent
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	public class ApplyElementIDOperation extends FlowElementOperation
+	{	
+		private var _origID:String;
+		private var _newID:String;
+		
+		/** 
+		 * Creates a ChangeElementIDOperation object. 
+		 * 
+		 * <p>If the <code>relativeStart</code> or <code>relativeEnd</code> parameters are set, then the existing
+		 * element is split into two elements, one using the existing ID and the other
+		 * using the new ID. If both parameters are set, then the existing element is split into three elements.
+		 * The first and last elements of the set are both assigned the original ID.</p>
+		 * 
+		 * @param operationState Specifies the selection state before the operation
+		 * @param targetElement Specifies the element to change
+		 * @param newID The ID to assign
+		 * @param relativeStart An offset from the beginning of the target element.
+		 * @param relativeEnd An offset from the end of the target element.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		*/
+		public function ApplyElementIDOperation(operationState:SelectionState, targetElement:IFlowElement, newID:String, relativeStart:int = 0, relativeEnd:int = -1)
+		{
+			_newID = newID;
+			super(operationState,targetElement,relativeStart,relativeEnd);
+		}
+		
+		/** 
+		 * The ID assigned by this operation.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		public function get newID():String
+		{ return _newID; }
+		public function set newID(val:String):void
+		{ _newID = val; }
+
+		/** @private */
+		public override function doOperation():Boolean
+		{
+			var targetElement:IFlowElement = getTargetElement();
+			_origID = targetElement.id;
+
+			adjustForDoOperation(targetElement);
+			
+			targetElement.id = _newID;
+			return true;
+		}	
+		
+		/** @private */
+		public override function undo():SelectionState
+		{
+			var targetElement:IFlowElement = getTargetElement();
+			targetElement.id = _origID;
+			
+			adjustForUndoOperation(targetElement);
+			
+			return originalSelectionState;
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ApplyElementStyleNameOperation.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ApplyElementStyleNameOperation.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ApplyElementStyleNameOperation.as
new file mode 100644
index 0000000..f50e84b
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ApplyElementStyleNameOperation.as
@@ -0,0 +1,98 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.operations
+{
+	import org.apache.flex.textLayout.edit.SelectionState;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	
+	/**
+	 * The ApplyElementStyleNameOperation class encapsulates a style name change.
+	 *
+	 * @see org.apache.flex.textLayout.elements.FlowElement#styleName
+	 * @see org.apache.flex.textLayout.edit.EditManager
+	 * @see org.apache.flex.textLayout.events.FlowOperationEvent
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	public class ApplyElementStyleNameOperation extends FlowElementOperation
+	{	
+		private var _origStyleName:String;
+		private var _newStyleName:String;
+		
+		/** 
+		 * Creates a ApplyElementStyleNameOperation object. 
+		 * 
+		 * <p>If the <code>relativeStart</code> and <code>relativeEnd</code> parameters are set, then the existing
+		 * element is split into multiple elements, the selected portion using the new 
+		 * style name and the rest using the existing style name.</p>
+		 * 
+		 * @param operationState Describes the current selection.
+		 * @param targetElement Specifies the element to change.
+		 * @param newStyleName The style name to assign.
+		 * @param relativeStart An offset from the beginning of the target element.
+		 * @param relativeEnd An offset from the end of the target element.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		*/
+		public function ApplyElementStyleNameOperation(operationState:SelectionState, targetElement:IFlowElement, newStyleName:String, relativeStart:int = 0, relativeEnd:int = -1)
+		{
+			_newStyleName = newStyleName;
+			super(operationState,targetElement,relativeStart,relativeEnd);
+		}
+		
+		/** 
+		 * The style name assigned by this operation.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		public function get newStyleName():String
+		{ return _newStyleName; }
+		public function set newStyleName(val:String):void
+		{ _newStyleName = val; }
+
+		/** @private */
+		public override function doOperation():Boolean
+		{
+			var targetElement:IFlowElement = getTargetElement();
+			_origStyleName = targetElement.styleName;
+			
+			adjustForDoOperation(targetElement);
+			
+			targetElement.styleName = _newStyleName;
+			return true;
+		}	
+		
+		/** @private */
+		public override function undo():SelectionState
+		{
+			var targetElement:IFlowElement = getTargetElement();
+			targetElement.styleName = _origStyleName;
+			
+			adjustForUndoOperation(targetElement);
+			
+			return originalSelectionState;
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ApplyElementTypeNameOperation.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ApplyElementTypeNameOperation.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ApplyElementTypeNameOperation.as
new file mode 100644
index 0000000..82d20a8
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ApplyElementTypeNameOperation.as
@@ -0,0 +1,101 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.operations {
+	import org.apache.flex.textLayout.edit.SelectionState;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+
+
+
+	
+	/**
+	 * The ApplyElementTypeNameOperation class encapsulates a type name change.
+	 *
+	 * @see org.apache.flex.textLayout.elements.FlowElement#typeName
+	 * @see org.apache.flex.textLayout.edit.EditManager
+	 * @see org.apache.flex.textLayout.events.FlowOperationEvent
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	public class ApplyElementTypeNameOperation extends FlowElementOperation
+	{	
+		private var _undoTypeName:String;
+		private var _typeName:String;
+		
+		/** 
+		 * Creates a ApplyElementTypeNameOperation object. 
+		 * 
+		 * <p>If the <code>relativeStart</code> and <code>relativeEnd</code> parameters are set, then the existing
+		 * element is split into multiple elements, the selected portion using the new 
+		 * type name and the rest using the existing type name.</p>
+		 * 
+		 * @param operationState Describes the current selection.
+		 * @param targetElement Specifies the element to change.
+		 * @param newTypeName The type name to assign.
+		 * @param relativeStart An offset from the beginning of the target element.
+		 * @param relativeEnd An offset from the end of the target element.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		*/
+		public function ApplyElementTypeNameOperation(operationState:SelectionState, targetElement:IFlowElement, typeName:String, relativeStart:int = 0, relativeEnd:int = -1)
+		{
+			_typeName = typeName;
+			super(operationState,targetElement,relativeStart,relativeEnd);
+		}
+		
+		/** 
+		 * The type name assigned by this operation.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		public function get typeName():String
+		{ return _typeName; }
+		public function set typeName(val:String):void
+		{ _typeName = val; }
+
+		/** @private */
+		public override function doOperation():Boolean
+		{
+			var targetElement:IFlowElement = getTargetElement();
+			_undoTypeName = targetElement.typeName;
+			
+			adjustForDoOperation(targetElement);
+			
+			targetElement.typeName = _typeName;
+			return true;
+		}	
+		
+		/** @private */
+		public override function undo():SelectionState
+		{
+			var targetElement:IFlowElement = getTargetElement();
+			targetElement.typeName = _undoTypeName;
+			
+			adjustForUndoOperation(targetElement);
+			
+			return originalSelectionState;
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ApplyElementUserStyleOperation.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ApplyElementUserStyleOperation.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ApplyElementUserStyleOperation.as
new file mode 100644
index 0000000..cf9c918
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ApplyElementUserStyleOperation.as
@@ -0,0 +1,118 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.operations {
+	import org.apache.flex.textLayout.edit.SelectionState;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+
+
+
+	
+	/**
+	 * The ApplyElementUserStyleOperation class encapsulates a change in a style value of an element.
+	 *
+	 * @see org.apache.flex.textLayout.elements.FlowElement#userStyles
+	 * @see org.apache.flex.textLayout.edit.EditManager
+	 * @see org.apache.flex.textLayout.events.FlowOperationEvent
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	public class ApplyElementUserStyleOperation extends FlowElementOperation
+	{	
+		private var _styleName:String;
+		
+		private var _origValue:*;
+		private var _newValue:*;
+		
+		/** 
+		 * Creates a ApplyElementUserStyleOperation object.
+		 * 
+		 * <p>If the <code>relativeStart</code> and <code>relativeEnd</code> parameters are set, then the existing
+		 * element is split into multiple elements, the selected portion using the new 
+		 * style value and the rest using the existing style value.</p>
+		 * 
+		 * @param operationState Describes the range of text to style.
+		 * @param targetElement Specifies the element to change.
+		 * @param styleName The name of the style to change.
+		 * @param value The new style value.
+		 * @param relativeStart An offset from the beginning of the target element.
+		 * @param relativeEnd An offset from the end of the target element.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		*/
+		public function ApplyElementUserStyleOperation(operationState:SelectionState, targetElement:IFlowElement, styleName:String, value:*, relativeStart:int = 0, relativeEnd:int = -1)
+		{
+			_styleName = styleName;
+			_newValue = value;
+			
+			super(operationState,targetElement,relativeStart,relativeEnd);
+		}
+		
+		/** 
+		 * The name of the style changed. 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		public function get styleName():String
+		{ return _styleName; }
+		public function set styleName(val:String):void
+		{ _styleName = val; }
+		
+		/** 
+		 * The new style value.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		public function get newValue():*
+		{ return _newValue; }
+		public function set newValue(val:*):void
+		{ _newValue = val; }
+
+		/** @private */
+		public override function doOperation():Boolean
+		{
+			var targetElement:IFlowElement = getTargetElement();
+			_origValue = targetElement.getStyle(_styleName);
+			
+			adjustForDoOperation(targetElement);
+			
+			targetElement.setStyle(_styleName,_newValue);
+			return true;
+		}	
+		
+		/** @private */
+		public override function undo():SelectionState
+		{
+			var targetElement:IFlowElement = getTargetElement();
+			targetElement.setStyle(_styleName,_origValue);
+			
+			adjustForUndoOperation(targetElement);
+			
+			return originalSelectionState;
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ApplyFormatOperation.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ApplyFormatOperation.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ApplyFormatOperation.as
new file mode 100644
index 0000000..ea9fcfa
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ApplyFormatOperation.as
@@ -0,0 +1,249 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.operations
+{
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.edit.ElementRange;
+	import org.apache.flex.textLayout.edit.ParaEdit;
+	import org.apache.flex.textLayout.edit.PointFormat;
+	import org.apache.flex.textLayout.edit.SelectionState;
+	import org.apache.flex.textLayout.elements.ParagraphElement;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+
+
+
+		
+	/**
+	 * The ApplyFormatOperation class encapsulates a style change.
+	 * 
+	 * <p>An ApplyFormatOperation applies the leaf format to the text in the 
+	 * specified range (no change is made if the specified range is a single point). 
+	 * It applies the paragraph format to any paragraphs at least partially within the range 
+	 * (or a single paragraph if the range is a single point). 
+	 * And it applies the container format to any containers at least partially within the range 
+	 * (or a single container if the range is a single point).</p>
+	 *
+	 * @see org.apache.flex.textLayout.edit.EditManager
+	 * @see org.apache.flex.textLayout.events.FlowOperationEvent
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	public class ApplyFormatOperation extends FlowTextOperation
+	{
+		private var applyLeafFormat:ITextLayoutFormat;
+		private var applyParagraphFormat:ITextLayoutFormat;
+		private var applyContainerFormat:ITextLayoutFormat;
+
+		// helper array of styles to revert
+		// each entry has a begIdx, endIdx, ContainerFormat
+		private var undoLeafArray:Array;	
+		private var undoParagraphArray:Array;	
+		private var undoContainerArray:Array;	
+		
+		/** 
+		 * Creates an ApplyFormatOperation object.
+		 *
+		 *  @param operationState	Defines the text range to which the format is applied.
+		 *  @param leafFormat	 The format to apply to LeafFlowElement objects in the selected range.
+		 *  @param paragraphFormat The format to apply to ParagraphElement objects in the selected range.
+		 *  @param containerFormat The format to apply to containers in the selected range.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */		
+		public function ApplyFormatOperation(operationState:SelectionState, leafFormat:ITextLayoutFormat, paragraphFormat:ITextLayoutFormat, containerFormat:ITextLayoutFormat = null)
+		{
+			super(operationState);
+			this.leafFormat = leafFormat;
+			this.paragraphFormat = paragraphFormat;
+			this.containerFormat = containerFormat;
+		}
+
+		/** 
+		 * The format properties to apply to the leaf elements in the range.
+		 * 
+		 * <p>If the range of this operation is a point, or if <code>leafFormat</code> is <code>null</code>,
+		 * then no leaf element formats are changed.</p>
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		*/
+		public function get leafFormat():ITextLayoutFormat
+		{
+			return applyLeafFormat;
+		}
+		public function set leafFormat(value:ITextLayoutFormat):void
+		{
+			applyLeafFormat = value ? new TextLayoutFormat(value) : null;
+		}
+		
+		/** 
+		 * The format properties to apply to the paragraphs in the range.
+		 * 
+		 * <p>The formats of any paragraphs at least partially within the range are updated. 
+		 * If the range of this operation is a point, then a single paragraph is updated.
+		 * If <code>paragraphFormat</code> is <code>null</code>, then no paragraph formats are changed.</p>
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		*/
+		public function get paragraphFormat():ITextLayoutFormat
+		{
+			return applyParagraphFormat;
+		}
+		public function set paragraphFormat(value:ITextLayoutFormat):void
+		{
+			applyParagraphFormat = value ? new TextLayoutFormat(value) : null;
+		}
+		
+		/** 
+		 * The format properties to apply to the containers in the range.
+		 * 
+		 * <p>The formats of any containers at least partially within the range are updated. 
+		 * If the range of this operation is a point, then a single container is updated.
+		 * If <code>containerFormat</code> is <code>null</code>, then no container formats are changed.</p>
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		*/
+		public function get containerFormat():ITextLayoutFormat
+		{
+			return applyContainerFormat;
+		}
+		public function set containerFormat(value:ITextLayoutFormat):void
+		{
+			applyContainerFormat = value ? new TextLayoutFormat(value) : null;
+		}
+		
+		private function doInternal():SelectionState
+		{
+			var anyNewSelectionState:SelectionState;
+			
+			// Apply character format
+			if (applyLeafFormat)
+			{
+				var begSel:int = absoluteStart;
+				var endSel:int = absoluteEnd;
+				
+				if (absoluteStart == absoluteEnd)
+				{
+					// On a caret selection, apply the leaf format to the SelectionManager's pointFormat, so it will be applied to the next insert.
+					// But if the paragraph is empty, go ahead and apply it now to the paragraph terminator.
+					var paragraph:IParagraphElement = textFlow.findLeaf(absoluteStart).getParagraph();
+					if (paragraph.textLength <= 1)
+					{
+						endSel++;
+						anyNewSelectionState = originalSelectionState.clone();
+						anyNewSelectionState.pointFormat = null;
+					}
+					else if (originalSelectionState.selectionManagerOperationState && textFlow.interactionManager)
+					{
+						// on point selection remember pendling leaf formats for next char typed
+						
+						anyNewSelectionState = originalSelectionState.clone();
+						var newFormat:PointFormat = new PointFormat(anyNewSelectionState.pointFormat);
+						newFormat.apply(applyLeafFormat);
+						anyNewSelectionState.pointFormat = newFormat;
+					}
+				}
+				if (begSel != endSel)
+				{
+					var range:ElementRange = ElementRange.createElementRange(textFlow, begSel,endSel);
+					
+					begSel = range.absoluteStart;
+					endSel = range.absoluteEnd;
+					if(endSel == textFlow.textLength - 1)
+						++endSel;
+						
+				//	CONFIG::debug { if (begSel != absoluteStart || endSel != absoluteEnd) trace("found mismatch ApplyFormatOperation"); }
+					if (!undoLeafArray)
+					{
+						undoLeafArray = new Array();
+						ParaEdit.cacheStyleInformation(textFlow,begSel,endSel,undoLeafArray);
+					}
+					ParaEdit.applyTextStyleChange(textFlow,begSel,endSel,applyLeafFormat,null);
+				}
+			}
+
+			if (applyParagraphFormat)
+			{
+				if (!undoParagraphArray)
+				{
+					undoParagraphArray = new Array();
+					ParaEdit.cacheParagraphStyleInformation(textFlow,absoluteStart, absoluteEnd,undoParagraphArray);
+				}
+				ParaEdit.applyParagraphStyleChange(textFlow,absoluteStart, absoluteEnd,applyParagraphFormat,null);
+			}
+			if (applyContainerFormat)
+			{
+				if (!undoContainerArray)
+				{
+					undoContainerArray = new Array();
+					ParaEdit.cacheContainerStyleInformation(textFlow,absoluteStart,absoluteEnd,undoContainerArray);
+				}
+				ParaEdit.applyContainerStyleChange(textFlow,absoluteStart,absoluteEnd,applyContainerFormat,null);
+			}
+			return anyNewSelectionState;
+		}
+		
+		/** @private */
+		public override function doOperation():Boolean
+		{ 
+			var newSelectionState:SelectionState = doInternal();
+			if (newSelectionState && textFlow.interactionManager)
+				textFlow.interactionManager.setSelectionState(newSelectionState);
+			return true;
+		}	
+		
+		/** @private */
+		override public function redo():SelectionState
+		{
+			var newSelectionState:SelectionState = doInternal();
+			return newSelectionState? newSelectionState : originalSelectionState;
+		}
+		
+		/** @private */
+		public override function undo():SelectionState
+		{ 
+			var obj:Object;
+			
+			// Undo character format changes
+			for each (obj in undoLeafArray)
+				ParaEdit.setTextStyleChange(textFlow,obj.begIdx,obj.endIdx,obj.style);
+
+			// Undo paragraph format changes
+			for each (obj in undoParagraphArray)
+				ParaEdit.setParagraphStyleChange(textFlow,obj.begIdx,obj.endIdx,obj.attributes);
+
+			// Undo container format changes
+			for each (obj in undoContainerArray)
+				ParaEdit.setContainerStyleChange(obj);
+
+			return originalSelectionState;
+		}
+		
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ApplyFormatToElementOperation.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ApplyFormatToElementOperation.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ApplyFormatToElementOperation.as
new file mode 100644
index 0000000..cb70533
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ApplyFormatToElementOperation.as
@@ -0,0 +1,115 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.operations {
+	import org.apache.flex.textLayout.edit.SelectionState;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+
+
+
+	
+	/**
+	 * The ApplyFormatToElementOperation class encapsulates a style change to an element.
+	 *
+	 * <p>This operation applies one or more formats to a flow element.</p>
+	 * 
+	 * @see org.apache.flex.textLayout.edit.EditManager
+	 * @see org.apache.flex.textLayout.formats.TextLayoutFormat
+	 * @see org.apache.flex.textLayout.events.FlowOperationEvent
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	public class ApplyFormatToElementOperation extends FlowElementOperation
+	{
+		private var _format:ITextLayoutFormat;
+		
+		private var _undoStyles:TextLayoutFormat;
+				
+		/** 
+		* Creates an ApplyFormatToElementOperation object. 
+		* 
+		* @param operationState Specifies the text flow containing the element to which this operation is applied.
+		* @param targetElement specifies the element to which this operation is applied.
+		* @param format The formats to apply in this operation.
+		 * 
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0 
+		*/
+		public function ApplyFormatToElementOperation(operationState:SelectionState, targetElement:IFlowElement, format:ITextLayoutFormat, relativeStart:int = 0, relativeEnd:int = -1)
+		{
+			super(operationState,targetElement,relativeStart,relativeEnd);
+				
+			// split up the properties by category
+			_format = format;
+		}
+				
+		/** 
+		 * The character formats applied in this operation.
+		 * 
+		 * <p>If <code>null</code> no character formats are changed.</p> 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		*/
+		public function get format():ITextLayoutFormat
+		{
+			return _format;
+		}
+		public function set format(value:ITextLayoutFormat):void
+		{
+			_format = value;
+		}
+		
+		/** @private */
+		public override function doOperation():Boolean
+		{
+			var targetElement:IFlowElement = getTargetElement();
+			
+			adjustForDoOperation(targetElement);
+			
+			_undoStyles = new TextLayoutFormat(targetElement.format);
+			
+			if (_format)
+			{
+				var newFormat:TextLayoutFormat = new TextLayoutFormat(targetElement.format);
+				newFormat.apply(_format);
+				targetElement.format = newFormat;
+			}
+			
+			return true;
+		}	
+		
+		/** @private */
+		public override function undo():SelectionState
+		{
+			var targetElement:IFlowElement = getTargetElement();
+			
+			targetElement.format = new TextLayoutFormat(_undoStyles);
+			
+			adjustForUndoOperation(targetElement);
+			
+			return originalSelectionState;
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ApplyLinkOperation.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ApplyLinkOperation.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ApplyLinkOperation.as
new file mode 100644
index 0000000..b2c3c6d
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ApplyLinkOperation.as
@@ -0,0 +1,206 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.operations
+{
+	import org.apache.flex.textLayout.edit.IMemento;
+	import org.apache.flex.textLayout.edit.ModelEdit;
+	import org.apache.flex.textLayout.edit.SelectionState;
+	import org.apache.flex.textLayout.edit.TextFlowEdit;
+	import org.apache.flex.textLayout.elements.IFlowLeafElement;
+	import org.apache.flex.textLayout.elements.LinkElement;
+	
+	/**
+	 * The ApplyLinkOperation class encapsulates a link creation or modification operation.
+	 *
+	 * @see org.apache.flex.textLayout.elements.LinkElement
+	 * @see org.apache.flex.textLayout.edit.EditManager
+	 * @see org.apache.flex.textLayout.events.FlowOperationEvent
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */			
+	public class ApplyLinkOperation extends FlowTextOperation
+	{
+		private var _hrefString:String;
+		private var _target:String;
+		private var _extendToLinkBoundary:Boolean;
+		private var _memento:IMemento;
+		private var _linkElement:LinkElement;
+
+		/** 
+		 * Creates an ApplyLinkOperation object.
+		 * 
+		 * @param operationState	The text range to which the operation is applied.
+		 * @param href The URI to be associated with the link.  If href is an empty string, 
+		 * the URI of links in the selection are removed.
+		 * @param target The target of the link.
+		 * @param extendToLinkBoundary Whether to extend the selection to include the entire 
+		 * text of any existing links overlapped by the selection, and then apply the change.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		function ApplyLinkOperation(operationState:SelectionState, href:String, target:String, extendToLinkBoundary:Boolean)
+		{
+			super(operationState);
+		
+			_hrefString = href;
+			_target = target;
+			_extendToLinkBoundary = extendToLinkBoundary;
+		}
+		
+		/** 
+		 * The URI to be associated with the link.  If href is an empty string, 
+		 * the URI of links in the selection are removed.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		*/
+		public function get href():String
+		{
+			return _hrefString;
+		}
+		public function set href(value:String):void
+		{
+			_hrefString = value;
+		}
+		
+		/**
+		 * The target of the link.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		*/
+		public function get target():String
+		{
+			return _target;
+		}
+		public function set target(value:String):void
+		{
+			_target = value;
+		}
+		
+		/**
+		 * Whether to extend the selection to include the entire 
+		 * text of any existing links overlapped by the selection, and then apply the change.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		*/
+		public function get extendToLinkBoundary():Boolean
+		{
+			return _extendToLinkBoundary;
+		}
+		public function set extendToLinkBoundary(value:Boolean):void
+		{
+			_extendToLinkBoundary = value;
+		}
+
+		/** 
+		 * The LinkElement that was created by doOperation.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 2.0
+		 * @langversion 3.0 
+		 */
+		public function get newLinkElement():LinkElement
+		{
+			return _linkElement;
+		}
+		
+
+		
+		/** @private */
+		public override function doOperation():Boolean
+		{
+			var leaf:IFlowLeafElement;
+			if (absoluteStart == absoluteEnd)
+				return false;
+			
+			if (_extendToLinkBoundary)
+			{
+				leaf = textFlow.findLeaf(absoluteStart);
+				var link:LinkElement = leaf.getParentByType("LinkElement") as LinkElement;
+				if (link)
+				{
+					absoluteStart = link.getAbsoluteStart();
+				}
+				
+				leaf = textFlow.findLeaf(absoluteEnd-1);
+				link = leaf.getParentByType("LinkElement") as LinkElement;
+				if (link)
+				{
+					absoluteEnd = link.getAbsoluteStart() + link.textLength;
+				}
+			}
+			//save off so that we can restore the flow on undo			
+			_memento = ModelEdit.saveCurrentState(textFlow, absoluteStart, absoluteEnd);
+				
+			if (_hrefString && _hrefString != "")
+			{
+				var madeLink:Boolean = TextFlowEdit.makeLink(textFlow, absoluteStart, absoluteEnd, _hrefString, _target);
+				if (!madeLink) 
+				{
+					_memento = null;
+					return false;
+				}
+				else
+				{
+					leaf = textFlow.findLeaf(absoluteStart);
+					_linkElement = leaf.getParentByType("LinkElement") as LinkElement;
+				}
+			}
+			else
+			{
+				TextFlowEdit.removeLink(textFlow, absoluteStart, absoluteEnd);				
+			} 
+			return true;
+		}
+		
+		/** @private */
+		public override function undo():SelectionState
+		{
+			if (_memento)
+				_memento.undo();
+			return originalSelectionState;				
+		}
+	
+		/** @private */
+		public override function redo():SelectionState
+		{
+			if (absoluteStart != absoluteEnd && _memento)
+			{
+				if (_hrefString != "")
+				{
+					TextFlowEdit.makeLink(textFlow, absoluteStart, absoluteEnd, _hrefString, _target);
+				}
+				else
+				{
+					TextFlowEdit.removeLink(textFlow, absoluteStart, absoluteEnd);				
+				} 
+			}
+			return originalSelectionState;	
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ApplyTCYOperation.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ApplyTCYOperation.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ApplyTCYOperation.as
new file mode 100644
index 0000000..c6a17a9
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ApplyTCYOperation.as
@@ -0,0 +1,190 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.operations
+{
+	import org.apache.flex.textLayout.elements.IFlowLeafElement;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.edit.IMemento;
+	import org.apache.flex.textLayout.edit.ModelEdit;
+	import org.apache.flex.textLayout.edit.SelectionState;
+	import org.apache.flex.textLayout.edit.TextFlowEdit;
+	import org.apache.flex.textLayout.elements.FlowLeafElement;
+	import org.apache.flex.textLayout.elements.TCYElement;
+
+	
+
+	
+	/** 
+	 * The ApplyTCYOperation class encapsulates a TCY transformation.
+	 *
+	 * @see org.apache.flex.textLayout.elements.TCYElement
+	 * @see org.apache.flex.textLayout.edit.EditManager
+	 * @see org.apache.flex.textLayout.events.FlowOperationEvent
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	public class ApplyTCYOperation extends FlowTextOperation
+	{
+		
+		private var makeBegIdx:int;
+		private var makeEndIdx:int;
+		private var removeBegIdx:int;
+		private var removeEndIdx:int;
+		private var removeRedoBegIdx:int;
+		private var removeRedoEndIdx:int;
+		
+		private var _memento:IMemento;
+		private var _tcyOn:Boolean;
+		private var _tcyElement:TCYElement;
+
+		/** 
+		 * Creates an ApplyTCYOperation object.
+		 * 
+		 * @param operationState Describes the range of text to which the operation is applied.
+		 * @param tcyValue Specifies whether to apply TCY (<code>true</code>), or remove TCY (<code>false</code>).
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		public function ApplyTCYOperation(operationState:SelectionState, tcyOn:Boolean)
+		{
+			super(operationState);
+			
+			if(tcyOn)
+			{
+				makeBegIdx = operationState.absoluteStart;
+				makeEndIdx = operationState.absoluteEnd;
+			}
+			else
+			{
+				removeBegIdx = operationState.absoluteStart;
+				removeEndIdx = operationState.absoluteEnd;
+			}
+			
+			_tcyOn = tcyOn;
+		}
+
+		/** 
+		 * Indicates whether the operation applies or removes TCY formatting.
+		 * 
+		 * <p>If <code>true</code>, then the operation transforms the range into a 
+		 * TCY element. If <code>false</code>, then the operation removes TCY formatting from
+		 * the first TCY element in the range.</p>
+		 * 
+		 * @see org.apache.flex.textLayout.elements.TCYElement
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		public function get tcyOn():Boolean
+		{
+			return _tcyOn;
+		}
+		
+		public function set tcyOn(val:Boolean):void
+		{
+			_tcyOn = val;
+		}
+		
+		/** 
+		 * The TCYElement that was created by doOperation.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 2.0
+		 * @langversion 3.0 
+		 */
+		public function get newTCYElement():TCYElement
+		{
+			return _tcyElement;
+		}
+		
+		/** @private */
+		public override function doOperation():Boolean
+		{
+			var leaf:IFlowLeafElement;
+			var tcyElem:TCYElement;
+			if (_tcyOn && makeEndIdx <= makeBegIdx)
+			{
+				return false;
+			}
+			else if(!_tcyOn && removeEndIdx <= removeBegIdx)
+			{
+				return false;
+			}
+			
+			if (_tcyOn)
+			{
+				//save it off so that we can restore the flow on undo - make and remove need different scraps		
+				_memento = ModelEdit.saveCurrentState(textFlow, makeBegIdx, makeEndIdx);
+				if (TextFlowEdit.makeTCY(textFlow, makeBegIdx, makeEndIdx))
+				{
+					leaf = textFlow.findLeaf(makeBegIdx);
+					_tcyElement = leaf.getParentByType("TCYElement") as TCYElement;
+				}
+			}
+			else
+			{
+				leaf = textFlow.findLeaf(removeBegIdx);
+				tcyElem = leaf.getParentByType("TCYElement") as TCYElement;
+				CONFIG::debug{ assert(tcyElem != null, "Trying to remove TCY from a non-TCY element!"); }
+				
+				//collect the bounds for redo of removal - redo bounds are only the selection, while do bounds are the whole
+				//tcyElement
+				removeRedoBegIdx = removeBegIdx;
+				removeRedoEndIdx = removeEndIdx;
+				
+				//now reset the beg and end idx's	
+				removeBegIdx = tcyElem.getAbsoluteStart();
+				removeEndIdx = removeBegIdx + tcyElem.textLength;
+				
+				//create the scrap of the whole TCY element
+				_memento = ModelEdit.saveCurrentState(textFlow, removeBegIdx, removeEndIdx);
+			
+				//use the removeRedoBegIdx/removeRedoEndIdx
+				TextFlowEdit.removeTCY(textFlow, removeRedoBegIdx, removeRedoEndIdx);
+			} 
+			return true;				
+		}
+		
+		/** @private */
+		public override function undo():SelectionState
+		{
+			_memento.undo();
+			return originalSelectionState;				
+		}
+	
+		/** @private */
+		public override function redo():SelectionState
+		{
+			if (_tcyOn)
+			{
+				TextFlowEdit.makeTCY(textFlow, makeBegIdx, makeEndIdx);
+			}
+			else
+			{
+				TextFlowEdit.removeTCY(textFlow, removeRedoBegIdx, removeRedoEndIdx);				
+			} 
+			return originalSelectionState;
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ClearFormatOnElementOperation.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ClearFormatOnElementOperation.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ClearFormatOnElementOperation.as
new file mode 100644
index 0000000..3ef67e2
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ClearFormatOnElementOperation.as
@@ -0,0 +1,123 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.operations {
+	import org.apache.flex.textLayout.edit.SelectionState;
+	import org.apache.flex.textLayout.elements.FlowElement;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+
+
+
+	
+	/**
+	 * The ClearFormatOnElementOperation class encapsulates a style change to an element.
+	 *
+	 * <p>This operation undefines one or more formats to a flow element.</p>
+	 * 
+	 * @see org.apache.flex.textLayout.edit.EditManager
+	 * @see org.apache.flex.textLayout.formats.TextLayoutFormat
+	 * @see org.apache.flex.textLayout.events.FlowOperationEvent
+
+	 * @see ApplyFormatToElementOperation
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	public class ClearFormatOnElementOperation extends FlowElementOperation
+	{
+		private var _format:ITextLayoutFormat;
+		
+		private var _undoStyles:TextLayoutFormat;
+				
+		/** 
+		* Creates an ClearFormatOnElementOperation object. 
+		* 
+		* @param operationState Specifies the text flow containing the element to which this operation is applied.
+		* @param targetElement specifies the element to which this operation is applied.
+		* @param format The formats to apply in this operation.
+		 * 
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0 
+		*/
+		public function ClearFormatOnElementOperation(operationState:SelectionState, targetElement:IFlowElement, format:ITextLayoutFormat, relativeStart:int = 0, relativeEnd:int = -1)
+		{
+			super(operationState,targetElement,relativeStart,relativeEnd);
+				
+			// split up the properties by category
+			_format = format;
+		}
+				
+		/** 
+		 * The character formats applied in this operation.
+		 * 
+		 * <p>If <code>null</code> no character formats are changed.</p> 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		*/
+		public function get format():ITextLayoutFormat
+		{
+			return _format;
+		}
+		public function set format(value:ITextLayoutFormat):void
+		{
+			_format = value;
+		}
+		
+		/** @private */
+		public override function doOperation():Boolean
+		{
+			var targetElement:IFlowElement = getTargetElement();
+			
+			adjustForDoOperation(targetElement);
+			
+			_undoStyles = new TextLayoutFormat(targetElement.format);
+			
+			if (_format)
+			{
+				var newFormat:TextLayoutFormat = new TextLayoutFormat(targetElement.format);
+				// this is fairly rare so this operation is not optimizied
+				for (var prop:String in TextLayoutFormat.description)
+				{
+					if (_format[prop] !== undefined)
+						newFormat[prop] = undefined;
+				} 
+				targetElement.format = newFormat;
+			}
+			
+			return true;
+		}	
+		
+		/** @private */
+		public override function undo():SelectionState
+		{
+			var targetElement:IFlowElement = getTargetElement();
+			
+			targetElement.format = new TextLayoutFormat(_undoStyles);
+			
+			adjustForUndoOperation(targetElement);
+			
+			return originalSelectionState;
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ClearFormatOperation.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ClearFormatOperation.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ClearFormatOperation.as
new file mode 100644
index 0000000..092359c
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ClearFormatOperation.as
@@ -0,0 +1,237 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.operations
+{
+	import org.apache.flex.textLayout.edit.ElementRange;
+	import org.apache.flex.textLayout.edit.ParaEdit;
+	import org.apache.flex.textLayout.edit.PointFormat;
+	import org.apache.flex.textLayout.edit.SelectionState;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+
+
+		
+	/**
+	 * The ClearFormatOperation class encapsulates a way to undefine formats.
+	 * 
+	 * <p>An UndefineFormatOperation undefines properties set in the leaf format to the text in the 
+	 * specified range (no change is made if the specified range is a single point). 
+	 * It undefines properties set in the paragraph format to any paragraphs at least partially within the range 
+	 * (or a single paragraph if the range is a single point). 
+	 * And it undefines properties set in the container format to any containers at least partially within the range 
+	 * (or a single container if the range is a single point).</p>
+	 *
+	 * @see org.apache.flex.textLayout.edit.EditManager
+	 * @see org.apache.flex.textLayout.events.FlowOperationEvent
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	public class ClearFormatOperation extends FlowTextOperation
+	{
+		private var applyLeafFormat:ITextLayoutFormat;
+		private var applyParagraphFormat:ITextLayoutFormat;
+		private var applyContainerFormat:ITextLayoutFormat;
+
+		// helper array of styles to revert
+		// each entry has a begIdx, endIdx, ContainerFormat
+		private var undoLeafArray:Array;	
+		private var undoParagraphArray:Array;	
+		private var undoContainerArray:Array;	
+		
+		/** 
+		 * Creates an ClearFormatOperation object.
+		 *
+		 *  @param operationState	Defines the text range to which the format is applied.
+		 *  @param leafFormat	 The format whose set values indicate properties to undefine to LeafFlowElement objects in the selected range.
+		 *  @param paragraphFormat The format whose set values indicate properties to undefine to ParagraphElement objects in the selected range.
+		 *  @param containerFormat The format whose set values indicate properties to undefine to ContainerController objects in the selected range.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */		
+		public function ClearFormatOperation(operationState:SelectionState, leafFormat:ITextLayoutFormat, paragraphFormat:ITextLayoutFormat, containerFormat:ITextLayoutFormat = null)
+		{
+			super(operationState);
+			this.leafFormat = leafFormat;
+			this.paragraphFormat = paragraphFormat;
+			this.containerFormat = containerFormat;
+		}
+
+		/** 
+		 * The format properties to undefine on the leaf elements in the range.
+		 * 
+		 * <p>If the range of this operation is a point, or if <code>leafFormat</code> is <code>null</code>,
+		 * then no leaf element formats are changed.</p>
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		*/
+		public function get leafFormat():ITextLayoutFormat
+		{
+			return applyLeafFormat;
+		}
+		public function set leafFormat(value:ITextLayoutFormat):void
+		{
+			applyLeafFormat = value ? new TextLayoutFormat(value) : null;
+		}
+		
+		/** 
+		 * The format properties to undefine on the paragraphs in the range.
+		 * 
+		 * <p>The formats of any paragraphs at least partially within the range are updated. 
+		 * If the range of this operation is a point, then a single paragraph is updated.
+		 * If <code>paragraphFormat</code> is <code>null</code>, then no paragraph formats are changed.</p>
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		*/
+		public function get paragraphFormat():ITextLayoutFormat
+		{
+			return applyParagraphFormat;
+		}
+		public function set paragraphFormat(value:ITextLayoutFormat):void
+		{
+			applyParagraphFormat = value ? new TextLayoutFormat(value) : null;
+		}
+		
+		/** 
+		 * The format properties to undefine on the containers in the range.
+		 * 
+		 * <p>The formats of any containers at least partially within the range are updated. 
+		 * If the range of this operation is a point, then a single container is updated.
+		 * If <code>containerFormat</code> is <code>null</code>, then no container formats are changed.</p>
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		*/
+		public function get containerFormat():ITextLayoutFormat
+		{
+			return applyContainerFormat;
+		}
+		public function set containerFormat(value:ITextLayoutFormat):void
+		{
+			applyContainerFormat = value ? new TextLayoutFormat(value) : null;
+		}
+		
+		private function doInternal():SelectionState
+		{
+			var anyNewSelectionState:SelectionState;
+
+			// Apply character format
+			if (applyLeafFormat)
+			{
+				if (absoluteStart != absoluteEnd)
+				{
+					var range:ElementRange = ElementRange.createElementRange(textFlow, absoluteStart,absoluteEnd);
+					
+					var begSel:int = range.absoluteStart;
+					var endSel:int = range.absoluteEnd;
+					if(endSel == textFlow.textLength - 1)
+						++endSel;
+						
+				//	CONFIG::debug { if (begSel != absoluteStart || endSel != absoluteEnd) trace("found mismatch ApplyFormatOperation"); }
+					if (!undoLeafArray)
+					{
+						undoLeafArray = new Array();
+						ParaEdit.cacheStyleInformation(textFlow,begSel,endSel,undoLeafArray);
+					}
+					ParaEdit.applyTextStyleChange(textFlow,begSel,endSel,null,applyLeafFormat);
+				}
+				else if (originalSelectionState.selectionManagerOperationState && textFlow.interactionManager)
+				{
+					// on point selection remember pendling leaf formats for next char typed
+					
+					anyNewSelectionState = originalSelectionState.clone();
+					// This is only a partial implementation - see watson bug 
+					// here if the format is pending we can clear it
+					// The bug is that we don't remember any pending clear that's not set in pointFormat on the next character typed
+					var newFormat:PointFormat = new PointFormat(anyNewSelectionState.pointFormat);
+					for (var prop:String in TextLayoutFormat.description)
+					{
+						if (applyLeafFormat[prop] !== undefined)
+							newFormat[prop] = undefined;
+					}
+					anyNewSelectionState.pointFormat = newFormat;
+				}				
+			}
+
+			if (applyParagraphFormat)
+			{
+				if (!undoParagraphArray)
+				{
+					undoParagraphArray = new Array();
+					ParaEdit.cacheParagraphStyleInformation(textFlow,absoluteStart, absoluteEnd,undoParagraphArray);
+				}
+				ParaEdit.applyParagraphStyleChange(textFlow,absoluteStart, absoluteEnd, null, applyParagraphFormat);
+			}
+			if (applyContainerFormat)
+			{
+				if (!undoContainerArray)
+				{
+					undoContainerArray = new Array();
+					ParaEdit.cacheContainerStyleInformation(textFlow,absoluteStart,absoluteEnd,undoContainerArray);
+				}
+				ParaEdit.applyContainerStyleChange(textFlow,absoluteStart,absoluteEnd, null, applyContainerFormat);
+			}
+			return anyNewSelectionState;
+		}
+		
+		/** @private */
+		public override function doOperation():Boolean
+		{ 
+			var newSelectionState:SelectionState = doInternal();
+			if (newSelectionState && textFlow.interactionManager)
+				textFlow.interactionManager.setSelectionState(newSelectionState);
+			return true;
+		}
+
+		override public function redo():SelectionState
+		{
+			var newSelectionState:SelectionState = doInternal();
+			return newSelectionState? newSelectionState : originalSelectionState;
+		}		
+
+		/** @private */
+		public override function undo():SelectionState
+		{ 
+			var obj:Object;
+			
+			// Undo character format changes
+			for each (obj in undoLeafArray)
+				ParaEdit.setTextStyleChange(textFlow,obj.begIdx,obj.endIdx,obj.style);
+
+			// Undo paragraph format changes
+			for each (obj in undoParagraphArray)
+				ParaEdit.setParagraphStyleChange(textFlow,obj.begIdx,obj.endIdx,obj.attributes);
+
+			// Undo container format changes
+			for each (obj in undoContainerArray)
+				ParaEdit.setContainerStyleChange(obj);
+
+			return originalSelectionState;
+		}
+		
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/CompositeOperation.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/CompositeOperation.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/CompositeOperation.as
new file mode 100644
index 0000000..9c5f9ed
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/CompositeOperation.as
@@ -0,0 +1,221 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.operations
+{
+	import org.apache.flex.textLayout.edit.SelectionState;
+
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.textLayout.debug.assert;
+
+
+
+	/**
+	 * The CompositeOperation class encapsulates a group of transformations managed as a unit.
+	 *
+	 * <p>The CompositeOperation class provides a grouping mechanism for combining multiple FlowOperations 
+	 * into a single atomic operation. Grouping operations allows them to be undone and redone as a unit. 
+	 * For example, several single character inserts followed by several backspaces can be undone together as if 
+	 * they were a single operation. Grouping also provides a mechanism for representing
+	 * complex operations. For example, a replace operation that modifies more than one text ranges
+	 * can be represented and managed as a single composite operation.</p>
+	 * 
+	 * <p><b>Note:</b> It can be more efficient to merge individual atomic operations
+	 *  rather than to combine separate operations into a group. For example, several sequential
+	 *  character inserts can easily be represented as a single insert operation,
+	 *  and undoing or redoing that single operation is more efficient than
+	 *  undoing or redoing a group of insert operations.</p>
+	 * 
+	 * @see org.apache.flex.textLayout.edit.EditManager
+	 * @see org.apache.flex.textLayout.events.FlowOperationEvent
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	public class CompositeOperation extends FlowOperation
+	{
+		private var _operations:Array;
+		
+		/** 
+		 * Creates a CompositeOperation object.
+		 * 
+		 * @param operations The operations to group.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		public function CompositeOperation(operations:Array = null)
+		{
+			super(null);
+			this.operations = operations;
+			if (_operations.length)
+				setGenerations(_operations[0].beginGeneration,_operations[_operations.length-1].endGeneration);
+		}
+
+		/** @private */
+		override public function get textFlow():ITextFlow
+		{ return _operations.length > 0 ? _operations[0].textFlow : null; }
+		
+		/**
+		 * An array containing the operations grouped by this composite operation.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		public function get operations():Array
+		{
+			return _operations;
+		}
+		public function set operations(value:Array):void
+		{
+			_operations = value ? value.slice() : [];	// make a copy
+		}
+		
+		/** 
+		 * Adds an additional operation to the end of the list. 
+		 * 
+		 * <p>The new operation must operate on the same TextFlow object as 
+		 * the other operations in the list.</p>
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		public function addOperation(operation:FlowOperation):void
+		{
+			// Can't handle operations from other TextFlows
+			if (_operations.length > 0 && operation.textFlow != textFlow)
+				return;
+				
+			CONFIG::debug { assert(_operations.length <= 0 || operation.beginGeneration == _operations[_operations.length - 1].endGeneration,
+				"adding non-contiguous operation to composite operation"); }
+			_operations.push(operation);
+		}
+		
+		/** @private */
+		public override function doOperation():Boolean
+		{
+			// execute all the operations in order
+			var success:Boolean = true;
+			for (var i:int = 0; i < _operations.length; i++)
+				success = success && FlowOperation(_operations[i]).doOperation();
+			
+			// return selectionState from last operation
+			return true;
+		}
+		
+		/** @private */
+		public override function undo():SelectionState
+		{
+			// undo all the operations in reverse order
+			var selState:SelectionState;
+			for (var i:int = _operations.length - 1; i >= 0; i--)
+				selState = FlowOperation(_operations[i]).undo();
+			
+			// return selectionState from last performed
+			// (i.e., the first in the set of operations)
+			return selState;
+		}
+		
+		/** @private */
+		public override function redo():SelectionState
+		{
+			// execute all the operations in order
+			var selState:SelectionState;
+			for (var i:int = 0; i < _operations.length; i++)
+				selState = FlowOperation(_operations[i]).redo();
+			
+			// return selectionState from last operation
+			return selState;
+		}		
+		
+		/** @private */
+		public override function canUndo():Boolean
+		{ 
+			// All operations within the CompositeOperation must have matching generation numbers, and be undoable
+			var undoable:Boolean = true;
+			var generation:int = beginGeneration;
+			var opCount:int = _operations.length;
+			for (var i:int = 0; i < opCount && undoable; i++)
+			{
+				var op:FlowOperation = _operations[i];
+				if (op.beginGeneration != generation || !op.canUndo())
+					undoable = false;
+				generation = op.endGeneration;
+			}
+			if (opCount > 0 && _operations[opCount - 1].endGeneration != endGeneration)
+				undoable = false;
+			
+			return undoable; 
+		}
+		
+		
+		/** @private */
+		public override function merge(operation:FlowOperation):FlowOperation
+		{
+			if (operation is InsertTextOperation || operation is SplitParagraphOperation || operation is DeleteTextOperation)
+			{
+				if (this.endGeneration != operation.beginGeneration)
+					return null;
+				// For efficiency, try to combine the last low-level operation
+				// with the new operation. If that's not possible, we just add it 
+				// as an additional operation.
+				// Note that we are making various assumptions here about the technical
+				// feasability and appropriateness of merging the individual operations (e.g.,
+				// that the selection hasn't changed), relying on SelectionManager to
+				// guarantee that these are satisfied.
+				var mergedOp:FlowOperation;
+				var lastOp:FlowOperation = (_operations && _operations.length) ? 
+										FlowOperation(_operations[_operations.length - 1]) :
+										null;
+				if (lastOp) 
+					mergedOp = lastOp.merge(operation);
+				
+				if (mergedOp && !(mergedOp is CompositeOperation))
+					_operations[_operations.length - 1] = mergedOp;
+				else
+					_operations.push(operation);
+				setGenerations(beginGeneration,operation.endGeneration);
+				return this;
+			}
+			return null;
+		}
+		
+//		/**
+//		 *  Add an additional operation to the end of this operation.
+//		 *  If the additional operation is itself a CompositeOperation, 
+//		 *  its child operations are just added to this operation's 
+//		 *  set of child operations.
+//		 * 	
+//		 * @param operation The operation to be merged.
+//		 * 
+//		 */
+//		private function mergeOperationViaConcatenation(operation:FlowOperation):void
+//		{
+//			var compositeOp:CompositeOperation = operation as CompositeOperation;
+//			if (compositeOp)
+//				operations = operations.concat(compositeOp.operations);
+//			else
+//				operations.push(operation);
+//		}
+
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/CopyOperation.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/CopyOperation.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/CopyOperation.as
new file mode 100644
index 0000000..d6b0be3
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/CopyOperation.as
@@ -0,0 +1,86 @@
+
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.operations
+{
+	import org.apache.flex.textLayout.edit.SelectionState;
+	import org.apache.flex.textLayout.edit.TextClipboard;
+	import org.apache.flex.textLayout.edit.TextScrap;
+
+
+
+
+	
+	/**
+	 * The CopyOperation class encapsulates a copy operation.
+	 * 
+	 * <p><b>Note:</b> The operation is responsible for copying the 
+	 * text scrap to the clipboard. Undonig a copy operation does not restore
+	 * the original clipboard state.</p>
+	 * 
+	 * @see org.apache.flex.textLayout.edit.EditManager
+	 * @see org.apache.flex.textLayout.events.FlowOperationEvent
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	public class CopyOperation extends FlowTextOperation
+	{		
+		/** 
+		 * Creates a CopyOperation object.
+		 * 
+		 * @param operationState The range of text to be copied.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		public function CopyOperation(operationState:SelectionState)
+		{
+			super(operationState);
+		}
+		
+		
+		/** @private */
+		public override function doOperation():Boolean
+		{
+			if (originalSelectionState.activePosition != originalSelectionState.anchorPosition)
+				TextClipboard.setContents(TextScrap.createTextScrap(originalSelectionState));		
+			return true;
+		}
+		
+		/** @private */
+		public override function undo():SelectionState
+		{				
+			return originalSelectionState;	
+		}
+	
+		/** @private */
+		public override function redo():SelectionState
+		{
+			return originalSelectionState;	
+
+		}		
+		
+		/** @private */
+		public override function canUndo():Boolean
+		{ return false; }
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/CreateDivOperation.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/CreateDivOperation.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/CreateDivOperation.as
new file mode 100644
index 0000000..48c48ca
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/CreateDivOperation.as
@@ -0,0 +1,263 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.operations
+{
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.edit.ElementMark;
+	import org.apache.flex.textLayout.edit.MementoList;
+	import org.apache.flex.textLayout.edit.ModelEdit;
+	import org.apache.flex.textLayout.edit.SelectionState;
+	import org.apache.flex.textLayout.elements.DivElement;
+	import org.apache.flex.textLayout.elements.IDivElement;
+	import org.apache.flex.textLayout.elements.ElementHelper;
+	import org.apache.flex.textLayout.elements.IFlowGroupElement;
+	import org.apache.flex.textLayout.elements.IListItemElement;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.ISubParagraphGroupElementBase;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+
+	/**
+	 * The CreateDivOperation class encapsulates creating IDivElement
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	public class CreateDivOperation extends FlowTextOperation
+	{
+		// describes the target
+		private var _divParentMarker:ElementMark;
+		private var _mementoList:MementoList;
+
+		private var _format:ITextLayoutFormat;
+		private var _divElement:IDivElement;		// the element that gets created
+		
+		private var _postOpSelectionState:SelectionState;
+		
+		/** 
+		 * Creates an CreateDivOperation object.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		public function CreateDivOperation(operationState:SelectionState, parent:IFlowGroupElement = null, format:ITextLayoutFormat = null)
+		{
+			super(operationState);
+			
+			this.parent = parent;
+			_format = format;
+			_mementoList = new MementoList(operationState.textFlow);
+		}
+		
+		/** 
+		 * Specifies the parent element for the new IDivElement
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.IFlowGroupElement
+		 */
+		public function get parent():IFlowGroupElement
+		{
+			return _divParentMarker ? _divParentMarker.findElement(originalSelectionState.textFlow) as IFlowGroupElement : null;
+		}
+		
+		/**
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.IFlowGroupElement
+		 */
+		public function set parent(value:IFlowGroupElement):void
+		{
+			if (!value)
+			{
+				// descend to the lowest level non-paragraph element that contains both positions
+				// effectively make the new div as close to the spans as possible
+				value = textFlow;
+				
+				var begPos:int = this.absoluteStart;
+				var endPos:int = this.absoluteEnd;
+				for (;;)
+				{
+					var begChildIdx:int = value.findChildIndexAtPosition(begPos);
+					var elem:IFlowGroupElement = value.getChildAt(begChildIdx) as IFlowGroupElement;
+					if (elem is IParagraphElement)
+						break;
+					begPos -= elem.parentRelativeStart;
+					endPos -= elem.parentRelativeStart;
+					if (endPos >= elem.textLength)	// end pos is in the next element
+						break;
+					value = elem;
+				}
+			}
+			else if (value is ISubParagraphGroupElementBase)
+				value = value.getParagraph().parent;
+			
+			_divParentMarker = new ElementMark(value,0);
+		}
+		
+		/** TextLayoutFormat to be applied to the new IDivElement. 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */	
+		public function get format():ITextLayoutFormat
+		{ return _format; }
+		public function set format(value:ITextLayoutFormat):void
+		{ _format = value; }
+		
+		/** The new IDivElement. 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */	
+		public function get newDivElement():IDivElement
+		{ return _divElement; }
+		
+		/**
+		 *  @private
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.IFlowGroupElement
+		 */
+		public override function doOperation():Boolean
+		{
+			var target:IFlowGroupElement = parent;
+			
+			// do nothing if target is a paragraphElement or below
+			if (!target || (target is IParagraphElement) || (target is ISubParagraphGroupElementBase))
+				return false;
+			
+			// find the starting child that's going to be in the div and 
+			var begChildIndex:int = 0;
+			var begStart:int = absoluteStart - target.getAbsoluteStart();
+			CONFIG::debug { assert(begStart >= 0 && begStart < target.textLength,"CreateDivOperation: bad target"); }
+			
+			var endChildIndex:int;
+			var endStart:int = absoluteEnd - target.getAbsoluteStart();
+			CONFIG::debug { assert(endStart >= 0 && endStart <= target.textLength,"CreateDivOperation: bad target"); }
+			
+			// scratch vars
+			var child:IFlowGroupElement;
+			
+			if (begStart > 0)
+			{
+				// figure out the starting child
+				begChildIndex = target.findChildIndexAtPosition(begStart);
+				child = target.getChildAt(begChildIndex) as IFlowGroupElement;
+				if (child.parentRelativeStart != begStart)
+				{					
+					_mementoList.push(ModelEdit.splitElement(textFlow,child,begStart-child.parentRelativeStart));
+					
+					if (child is IParagraphElement)
+						endStart++;
+					begChildIndex++;
+				}
+			}
+			
+			if (endStart >= 0)
+			{
+				if (endStart >= target.textLength - 1)
+					endChildIndex = target.numChildren;
+				else
+				{
+					// figure out the starting child
+					endChildIndex = target.findChildIndexAtPosition(endStart);
+					child = target.getChildAt(endChildIndex) as IFlowGroupElement;
+					if (child.parentRelativeStart != endStart)			
+					{
+						_mementoList.push(ModelEdit.splitElement(textFlow,child,endStart-child.parentRelativeStart));
+						endChildIndex++;
+					}
+				}
+			}
+			else
+				endChildIndex = begChildIndex+1;
+			
+			_divElement = new DivElement();
+			_divElement.format = format;
+						
+			if (begChildIndex == target.numChildren)
+			{
+				// new div at the end of target
+				child = target.getChildAt(target.numChildren-1) as IFlowGroupElement;
+				
+				_mementoList.push(ModelEdit.splitElement(textFlow,child,child.textLength));
+				_mementoList.push(ModelEdit.addElement(textFlow,_divElement,target,target.numChildren));
+
+
+				_mementoList.push(ModelEdit.moveElement(textFlow,child,_divElement,_divElement.numChildren));
+			}
+			else
+			{
+				_mementoList.push(ModelEdit.addElement(textFlow,_divElement,target,endChildIndex));
+
+
+				if (begChildIndex == endChildIndex)
+				{
+					_mementoList.push(ModelEdit.addElement(textFlow,ElementHelper.getParagraph(),_divElement,0));					
+				}
+				else
+				{
+					while (begChildIndex < endChildIndex)
+					{
+						child = target.getChildAt(begChildIndex) as IFlowGroupElement;
+						if (child is IListItemElement)
+						{
+							// move all the children up and delete the IListItemElement
+							while (child.numChildren)
+								_mementoList.push(ModelEdit.moveElement(textFlow,child.getChildAt(0),_divElement,_divElement.numChildren));
+							_mementoList.push(ModelEdit.removeElements(textFlow,target,begChildIndex,1));
+						}
+						else
+						{
+							_mementoList.push(ModelEdit.moveElement(textFlow,child,_divElement,_divElement.numChildren));
+							child.normalizeRange(0,child.textLength);
+						}
+						endChildIndex--;
+					}
+				}
+				// normalize does this
+				if ((target is IListItemElement) && (target as IListItemElement).normalizeNeedsInitialParagraph())
+					_mementoList.push(ModelEdit.addElement(textFlow,ElementHelper.getParagraph(),target,0));
+			}
+			
+			if (originalSelectionState.selectionManagerOperationState && textFlow.interactionManager)
+			{
+				textFlow.normalize();
+				_postOpSelectionState = new SelectionState(textFlow,_divElement.getAbsoluteStart(),_divElement.getAbsoluteStart()+_divElement.textLength-1);
+				textFlow.interactionManager.setSelectionState(_postOpSelectionState);
+			}
+			
+			return true;
+		}
+
+		/** @private */
+		public override function undo():SelectionState
+		{
+			_mementoList.undo();
+			return originalSelectionState; 
+		}
+		
+		/** @private */
+		public override function redo():SelectionState
+		{
+			_mementoList.redo();
+			return _postOpSelectionState; 
+			
+		}
+	}
+}


[06/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/TextLayoutFormatBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/TextLayoutFormatBase.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/TextLayoutFormatBase.as
new file mode 100644
index 0000000..04091c7
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/formats/TextLayoutFormatBase.as
@@ -0,0 +1,2260 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.formats
+{
+
+	
+
+	
+	import org.apache.flex.textLayout.elements.FlowValueHolder;
+	public class TextLayoutFormatBase implements ITextLayoutFormat
+	{
+
+		/** @private */
+		public function writableTextLayoutFormat():FlowValueHolder
+		{
+			if (_format == null)
+				_format = new FlowValueHolder();
+			return _format;
+		}
+
+		/** format settings on this FlowElement. @private */
+		protected var _format:FlowValueHolder;
+		
+		/** TextLayoutFormat properties applied directly to this element.
+		 * <p>Each element may have properties applied to it as part of its format. Properties applied to this element override properties inherited from the parent. Properties applied to this element will in turn be inherited by element's children if they are not overridden on the child. If no properties are applied to the element, this will be null.</p>
+		 * @see org.apache.flex.textLayout.formats.ITextLayoutFormat
+		 */
+		public function get format():ITextLayoutFormat
+		{ return _format; }
+		public function set format(value:ITextLayoutFormat):void
+		{
+			if (value == _format)
+				return;
+			
+			var oldStyleName:String = this.styleName;
+			
+			if (value == null)
+				_format.clearStyles();
+			else
+				writableTextLayoutFormat().copy(value);
+			formatChanged();
+			
+			if (oldStyleName != this.styleName)
+				styleSelectorChanged();
+		}
+
+		/** This gets called when an element has changed its attributes. This may happen because an
+		 * ancestor element changed it attributes.
+		 * @private 
+		 */
+		public function formatChanged(notifyModelChanged:Boolean = true):void
+		{
+			throw new Error("This must be overridden!");
+		}
+		
+		/** This gets called when an element has changed its style selection related attributes. This may happen because an
+		 * ancestor element changed it attributes.
+		 * @private 
+		 */		
+		public function styleSelectorChanged():void
+		{
+			throw new Error("This must be overridden!");
+		}
+		public function getStyle(styleProp:String):*
+		{
+			throw new Error("This must be overridden!");
+		}
+
+		[Inspectable(enumeration="auto,always,inherit")]
+		/**
+		 * TextLayoutFormat:
+		 * Controls column break before the element.
+		 * <p>Legal values are BreakStyle.AUTO, BreakStyle.ALWAYS, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of BreakStyle.AUTO.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.BreakStyle
+		 */
+		public function get columnBreakBefore():*
+		{
+			return _format ? _format.columnBreakBefore : undefined;
+		}
+		public function set columnBreakBefore(columnBreakBeforeValue:*):void
+		{
+			writableTextLayoutFormat().columnBreakBefore = columnBreakBeforeValue;
+			formatChanged();
+		}
+
+		[Inspectable(enumeration="auto,always,inherit")]
+		/**
+		 * TextLayoutFormat:
+		 * Controls column after before the element.
+		 * <p>Legal values are BreakStyle.AUTO, BreakStyle.ALWAYS, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of BreakStyle.AUTO.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.BreakStyle
+		 */
+		public function get columnBreakAfter():*
+		{
+			return _format ? _format.columnBreakAfter : undefined;
+		}
+		public function set columnBreakAfter(columnBreakAfterValue:*):void
+		{
+			writableTextLayoutFormat().columnBreakAfter = columnBreakAfterValue;
+			formatChanged();
+		}
+
+		[Inspectable(enumeration="auto,always,inherit")]
+		/**
+		 * TextLayoutFormat:
+		 * Controls container break before the element.
+		 * <p>Legal values are BreakStyle.AUTO, BreakStyle.ALWAYS, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of BreakStyle.AUTO.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.BreakStyle
+		 */
+		public function get containerBreakBefore():*
+		{
+			return _format ? _format.containerBreakBefore : undefined;
+		}
+		public function set containerBreakBefore(containerBreakBeforeValue:*):void
+		{
+			writableTextLayoutFormat().containerBreakBefore = containerBreakBeforeValue;
+			formatChanged();
+		}
+
+		[Inspectable(enumeration="auto,always,inherit")]
+		/**
+		 * TextLayoutFormat:
+		 * Controls container after before the element.
+		 * <p>Legal values are BreakStyle.AUTO, BreakStyle.ALWAYS, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of BreakStyle.AUTO.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.BreakStyle
+		 */
+		public function get containerBreakAfter():*
+		{
+			return _format ? _format.containerBreakAfter : undefined;
+		}
+		public function set containerBreakAfter(containerBreakAfterValue:*):void
+		{
+			writableTextLayoutFormat().containerBreakAfter = containerBreakAfterValue;
+			formatChanged();
+		}
+
+		/**
+		 * TextLayoutFormat:
+		 * Color of the text. A hexadecimal number that specifies three 8-bit RGB (red, green, blue) values; for example, 0xFF0000 is red and 0x00FF00 is green. It can also be enum value {BLACK, GREEN, GRAY, BLUE, SILVER, LIME, OLIVE, WHITE, YELLOW, MAROON, NAVY, RED, PURPLE, TEAL, FUCHSIA, AQUA, MAGENTA, CYAN}
+		 * <p>Legal values as a string are ColorName.BLACK, ColorName.GREEN, ColorName.GRAY, ColorName.BLUE, ColorName.SILVER, ColorName.LIME, ColorName.OLIVE, ColorName.WHITE, ColorName.YELLOW, ColorName.MAROON, ColorName.NAVY, ColorName.RED, ColorName.PURPLE, ColorName.TEAL, ColorName.FUCHSIA, ColorName.AQUA, ColorName.MAGENTA, ColorName.CYAN, FormatValue.INHERIT and uints from 0x0 to 0xffffffff.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.ColorName
+		 */
+		public function get color():*
+		{
+			return _format ? _format.color : undefined;
+		}
+		public function set color(colorValue:*):void
+		{
+			writableTextLayoutFormat().color = colorValue;
+			formatChanged();
+		}
+
+		/**
+		 * TextLayoutFormat:
+		 * Background color of the text (adopts default value if undefined during cascade). Can be either the constant value  <code>BackgroundColor.TRANSPARENT</code>, or a hexadecimal value that specifies the three 8-bit RGB (red, green, blue) values; for example, 0xFF0000 is red and 0x00FF00 is green.
+		 * <p>Legal values as a string are BackgroundColor.TRANSPARENT, FormatValue.INHERIT and uints from 0x0 to 0xffffffff.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of BackgroundColor.TRANSPARENT.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.BackgroundColor
+		 */
+		public function get backgroundColor():*
+		{
+			return _format ? _format.backgroundColor : undefined;
+		}
+		public function set backgroundColor(backgroundColorValue:*):void
+		{
+			writableTextLayoutFormat().backgroundColor = backgroundColorValue;
+			formatChanged();
+		}
+
+		[Inspectable(enumeration="true,false,inherit")]
+		/**
+		 * TextLayoutFormat:
+		 * If <code>true</code>, applies strikethrough, a line drawn through the middle of the text.
+		 * <p>Legal values are true, false and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of false.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get lineThrough():*
+		{
+			return _format ? _format.lineThrough : undefined;
+		}
+		public function set lineThrough(lineThroughValue:*):void
+		{
+			writableTextLayoutFormat().lineThrough = lineThroughValue;
+			formatChanged();
+		}
+
+		/**
+		 * TextLayoutFormat:
+		 * Alpha (transparency) value for the text. A value of 0 is fully transparent, and a value of 1 is fully opaque. Display objects with <code>textAlpha</code> set to 0 are active, even though they are invisible.
+		 * <p>Legal values are numbers from 0 to 1 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of 1.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get textAlpha():*
+		{
+			return _format ? _format.textAlpha : undefined;
+		}
+		public function set textAlpha(textAlphaValue:*):void
+		{
+			writableTextLayoutFormat().textAlpha = textAlphaValue;
+			formatChanged();
+		}
+
+		/**
+		 * TextLayoutFormat:
+		 * Alpha (transparency) value for the background (adopts default value if undefined during cascade). A value of 0 is fully transparent, and a value of 1 is fully opaque. Display objects with alpha set to 0 are active, even though they are invisible.
+		 * <p>Legal values are numbers from 0 to 1 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of 1.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get backgroundAlpha():*
+		{
+			return _format ? _format.backgroundAlpha : undefined;
+		}
+		public function set backgroundAlpha(backgroundAlphaValue:*):void
+		{
+			writableTextLayoutFormat().backgroundAlpha = backgroundAlphaValue;
+			formatChanged();
+		}
+
+		/**
+		 * TextLayoutFormat:
+		 * The size of the text in pixels.
+		 * <p>Legal values are numbers from 1 to 720 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of 12.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get fontSize():*
+		{
+			return _format ? _format.fontSize : undefined;
+		}
+		public function set fontSize(fontSizeValue:*):void
+		{
+			writableTextLayoutFormat().fontSize = fontSizeValue;
+			formatChanged();
+		}
+
+		/**
+		 * TextLayoutFormat:
+		 * Amount to shift the baseline from the <code>dominantBaseline</code> value. Units are in pixels, or a percentage of <code>fontSize</code> (in which case, enter a string value, like 140%).  Positive values shift the line up for horizontal text (right for vertical) and negative values shift it down for horizontal (left for vertical). 
+		 * <p>Legal values are BaselineShift.SUPERSCRIPT, BaselineShift.SUBSCRIPT, FormatValue.INHERIT.</p>
+		 * <p>Legal values as a number are from -1000 to 1000.</p>
+		 * <p>Legal values as a percent are numbers from -1000 to 1000.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of 0.0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.BaselineShift
+		 */
+		public function get baselineShift():*
+		{
+			return _format ? _format.baselineShift : undefined;
+		}
+		public function set baselineShift(baselineShiftValue:*):void
+		{
+			writableTextLayoutFormat().baselineShift = baselineShiftValue;
+			formatChanged();
+		}
+
+		/**
+		 * TextLayoutFormat:
+		 * Number in pixels (or percent of <code>fontSize</code>, like 120%) indicating the amount of tracking (manual kerning) to be applied to the left of each character. If kerning is enabled, the <code>trackingLeft</code> value is added to the values in the kerning table for the font. If kerning is disabled, the <code>trackingLeft</code> value is used as a manual kerning value. Supports both positive and negative values. 
+		 * <p>Legal values as a number are from -1000 to 1000.</p>
+		 * <p>Legal values as a percent are numbers from -1000% to 1000%.</p>
+		 * <p>Legal values include FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get trackingLeft():*
+		{
+			return _format ? _format.trackingLeft : undefined;
+		}
+		public function set trackingLeft(trackingLeftValue:*):void
+		{
+			writableTextLayoutFormat().trackingLeft = trackingLeftValue;
+			formatChanged();
+		}
+
+		/**
+		 * TextLayoutFormat:
+		 * Number in pixels (or percent of <code>fontSize</code>, like 120%) indicating the amount of tracking (manual kerning) to be applied to the right of each character.  If kerning is enabled, the <code>trackingRight</code> value is added to the values in the kerning table for the font. If kerning is disabled, the <code>trackingRight</code> value is used as a manual kerning value. Supports both positive and negative values. 
+		 * <p>Legal values as a number are from -1000 to 1000.</p>
+		 * <p>Legal values as a percent are numbers from -1000% to 1000%.</p>
+		 * <p>Legal values include FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get trackingRight():*
+		{
+			return _format ? _format.trackingRight : undefined;
+		}
+		public function set trackingRight(trackingRightValue:*):void
+		{
+			writableTextLayoutFormat().trackingRight = trackingRightValue;
+			formatChanged();
+		}
+
+		/**
+		 * TextLayoutFormat:
+		 * Leading controls for the text. The distance from the baseline of the previous or the next line (based on <code>LeadingModel</code>) to the baseline of the current line is equal to the maximum amount of the leading applied to any character in the line. This is either a number or a percent.  If specifying a percent, enter a string value, like 140%.<p><img src='../../../images/textLayout_lineHeight1.jpg' alt='lineHeight1' /><img src='../../../images/textLayout_lineHeight2.jpg' alt='lineHeight2' /></p>
+		 * <p>Legal values as a number are from -720 to 720.</p>
+		 * <p>Legal values as a percent are numbers from -1000% to 1000%.</p>
+		 * <p>Legal values include FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of 120%.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get lineHeight():*
+		{
+			return _format ? _format.lineHeight : undefined;
+		}
+		public function set lineHeight(lineHeightValue:*):void
+		{
+			writableTextLayoutFormat().lineHeight = lineHeightValue;
+			formatChanged();
+		}
+
+		[Inspectable(enumeration="all,any,auto,none,inherit")]
+		/**
+		 * TextLayoutFormat:
+		 * Controls where lines are allowed to break when breaking wrapping text into multiple lines. Set to <code>BreakOpportunity.AUTO</code> to break text normally. Set to <code>BreakOpportunity.NONE</code> to <em>not</em> break the text unless the text would overrun the measure and there are no other places to break the line. Set to <code>BreakOpportunity.ANY</code> to allow the line to break anywhere, rather than just between words. Set to <code>BreakOpportunity.ALL</code> to have each typographic cluster put on a separate line (useful for text on a path).
+		 * <p>Legal values are BreakOpportunity.ALL, BreakOpportunity.ANY, BreakOpportunity.AUTO, BreakOpportunity.NONE, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of BreakOpportunity.AUTO.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.text.engine.BreakOpportunity
+		 */
+		public function get breakOpportunity():*
+		{
+			return _format ? _format.breakOpportunity : undefined;
+		}
+		public function set breakOpportunity(breakOpportunityValue:*):void
+		{
+			writableTextLayoutFormat().breakOpportunity = breakOpportunityValue;
+			formatChanged();
+		}
+
+		[Inspectable(enumeration="default,lining,oldStyle,inherit")]
+		/**
+		 * TextLayoutFormat:
+		 * The type of digit case used for this text. Setting the value to <code>DigitCase.OLD_STYLE</code> approximates lowercase letterforms with varying ascenders and descenders. The figures are proportionally spaced. This style is only available in selected typefaces, most commonly in a supplemental or expert font. The <code>DigitCase.LINING</code> setting has all-cap height and is typically monospaced to line up in charts.<p><img src='../../../images/textLayout_digitcase.gif' alt='digitCase' /></p>
+		 * <p>Legal values are DigitCase.DEFAULT, DigitCase.LINING, DigitCase.OLD_STYLE, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of DigitCase.DEFAULT.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.text.engine.DigitCase
+		 */
+		public function get digitCase():*
+		{
+			return _format ? _format.digitCase : undefined;
+		}
+		public function set digitCase(digitCaseValue:*):void
+		{
+			writableTextLayoutFormat().digitCase = digitCaseValue;
+			formatChanged();
+		}
+
+		[Inspectable(enumeration="default,proportional,tabular,inherit")]
+		/**
+		 * TextLayoutFormat:
+		 * Type of digit width used for this text. This can be <code>DigitWidth.PROPORTIONAL</code>, which looks best for individual numbers, or <code>DigitWidth.TABULAR</code>, which works best for numbers in tables, charts, and vertical rows.<p><img src='../../../images/textLayout_digitwidth.gif' alt='digitWidth' /></p>
+		 * <p>Legal values are DigitWidth.DEFAULT, DigitWidth.PROPORTIONAL, DigitWidth.TABULAR, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of DigitWidth.DEFAULT.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.text.engine.DigitWidth
+		 */
+		public function get digitWidth():*
+		{
+			return _format ? _format.digitWidth : undefined;
+		}
+		public function set digitWidth(digitWidthValue:*):void
+		{
+			writableTextLayoutFormat().digitWidth = digitWidthValue;
+			formatChanged();
+		}
+
+		[Inspectable(enumeration="auto,roman,ascent,descent,ideographicTop,ideographicCenter,ideographicBottom,inherit")]
+		/**
+		 * TextLayoutFormat:
+		 * Specifies which element baseline snaps to the <code>alignmentBaseline</code> to determine the vertical position of the element on the line. A value of <code>TextBaseline.AUTO</code> selects the dominant baseline based on the <code>locale</code> property of the parent paragraph.  For Japanese and Chinese, the selected baseline value is <code>TextBaseline.IDEOGRAPHIC_CENTER</code>; for all others it is <code>TextBaseline.ROMAN</code>. These baseline choices are determined by the choice of font and the font size.<p><img src='../../../images/textLayout_baselines.jpg' alt='baselines' /></p>
+		 * <p>Legal values are FormatValue.AUTO, TextBaseline.ROMAN, TextBaseline.ASCENT, TextBaseline.DESCENT, TextBaseline.IDEOGRAPHIC_TOP, TextBaseline.IDEOGRAPHIC_CENTER, TextBaseline.IDEOGRAPHIC_BOTTOM, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of FormatValue.AUTO.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.text.engine.TextBaseline
+		 */
+		public function get dominantBaseline():*
+		{
+			return _format ? _format.dominantBaseline : undefined;
+		}
+		public function set dominantBaseline(dominantBaselineValue:*):void
+		{
+			writableTextLayoutFormat().dominantBaseline = dominantBaselineValue;
+			formatChanged();
+		}
+
+		[Inspectable(enumeration="on,off,auto,inherit")]
+		/**
+		 * TextLayoutFormat:
+		 * Kerning adjusts the pixels between certain character pairs to improve readability. Kerning is supported for all fonts with kerning tables.
+		 * <p>Legal values are Kerning.ON, Kerning.OFF, Kerning.AUTO, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of Kerning.AUTO.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.text.engine.Kerning
+		 */
+		public function get kerning():*
+		{
+			return _format ? _format.kerning : undefined;
+		}
+		public function set kerning(kerningValue:*):void
+		{
+			writableTextLayoutFormat().kerning = kerningValue;
+			formatChanged();
+		}
+
+		[Inspectable(enumeration="minimum,common,uncommon,exotic,inherit")]
+		/**
+		 * TextLayoutFormat:
+		 * Controls which of the ligatures that are defined in the font may be used in the text. The ligatures that appear for each of these settings is dependent on the font. A ligature occurs where two or more letter-forms are joined as a single glyph. Ligatures usually replace consecutive characters sharing common components, such as the letter pairs 'fi', 'fl', or 'ae'. They are used with both Latin and Non-Latin character sets. The ligatures enabled by the values of the LigatureLevel class - <code>MINIMUM</code>, <code>COMMON</code>, <code>UNCOMMON</code>, and <code>EXOTIC</code> - are additive. Each value enables a new set of ligatures, but also includes those of the previous types.<p><b>Note: </b>When working with Arabic or Syriac fonts, <code>ligatureLevel</code> must be set to MINIMUM or above.</p><p><img src='../../../images/textLayout_ligatures.png' alt='ligatureLevel' /></p>
+		 * <p>Legal values are LigatureLevel.MINIMUM, LigatureLevel.COMMON, LigatureLevel.UNCOMMON, LigatureLevel.EXOTIC, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of LigatureLevel.COMMON.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.text.engine.LigatureLevel
+		 */
+		public function get ligatureLevel():*
+		{
+			return _format ? _format.ligatureLevel : undefined;
+		}
+		public function set ligatureLevel(ligatureLevelValue:*):void
+		{
+			writableTextLayoutFormat().ligatureLevel = ligatureLevelValue;
+			formatChanged();
+		}
+
+		[Inspectable(enumeration="roman,ascent,descent,ideographicTop,ideographicCenter,ideographicBottom,useDominantBaseline,inherit")]
+		/**
+		 * TextLayoutFormat:
+		 * Specifies the baseline to which the dominant baseline aligns. For example, if you set <code>dominantBaseline</code> to ASCENT, setting <code>alignmentBaseline</code> to DESCENT aligns the top of the text with the DESCENT baseline, or below the line.  The largest element in the line generally determines the baselines.<p><img src='../../../images/textLayout_baselines.jpg' alt='baselines' /></p>
+		 * <p>Legal values are TextBaseline.ROMAN, TextBaseline.ASCENT, TextBaseline.DESCENT, TextBaseline.IDEOGRAPHIC_TOP, TextBaseline.IDEOGRAPHIC_CENTER, TextBaseline.IDEOGRAPHIC_BOTTOM, TextBaseline.USE_DOMINANT_BASELINE, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of TextBaseline.USE_DOMINANT_BASELINE.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.text.engine.TextBaseline
+		 */
+		public function get alignmentBaseline():*
+		{
+			return _format ? _format.alignmentBaseline : undefined;
+		}
+		public function set alignmentBaseline(alignmentBaselineValue:*):void
+		{
+			writableTextLayoutFormat().alignmentBaseline = alignmentBaselineValue;
+			formatChanged();
+		}
+
+		/**
+		 * TextLayoutFormat:
+		 * The locale of the text. Controls case transformations and shaping. Standard locale identifiers as described in Unicode Technical Standard #35 are used. For example en, en_US and en-US are all English, ja is Japanese. 
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of en.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get locale():*
+		{
+			return _format ? _format.locale : undefined;
+		}
+		public function set locale(localeValue:*):void
+		{
+			writableTextLayoutFormat().locale = localeValue;
+			formatChanged();
+		}
+
+		[Inspectable(enumeration="default,capsToSmallCaps,uppercase,lowercase,lowercaseToSmallCaps,inherit")]
+		/**
+		 * TextLayoutFormat:
+		 * The type of typographic case used for this text. Here are some examples:<p><img src='../../../images/textLayout_typographiccase.png' alt='typographicCase' /></p>
+		 * <p>Legal values are TLFTypographicCase.DEFAULT, TLFTypographicCase.CAPS_TO_SMALL_CAPS, TLFTypographicCase.UPPERCASE, TLFTypographicCase.LOWERCASE, TLFTypographicCase.LOWERCASE_TO_SMALL_CAPS, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of TLFTypographicCase.DEFAULT.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.TLFTypographicCase
+		 */
+		public function get typographicCase():*
+		{
+			return _format ? _format.typographicCase : undefined;
+		}
+		public function set typographicCase(typographicCaseValue:*):void
+		{
+			writableTextLayoutFormat().typographicCase = typographicCaseValue;
+			formatChanged();
+		}
+
+		/**
+		 * TextLayoutFormat:
+		 *  The name of the font to use, or a comma-separated list of font names. The Flash runtime renders the element with the first available font in the list. For example Arial, Helvetica, _sans causes the player to search for Arial, then Helvetica if Arial is not found, then _sans if neither is found.
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of Arial.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get fontFamily():*
+		{
+			return _format ? _format.fontFamily : undefined;
+		}
+		public function set fontFamily(fontFamilyValue:*):void
+		{
+			writableTextLayoutFormat().fontFamily = fontFamilyValue;
+			formatChanged();
+		}
+
+		[Inspectable(enumeration="none,underline,inherit")]
+		/**
+		 * TextLayoutFormat:
+		 * Decoration on text. Use to apply underlining; default is none.
+		 * <p>Legal values are TextDecoration.NONE, TextDecoration.UNDERLINE, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of TextDecoration.NONE.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.TextDecoration
+		 */
+		public function get textDecoration():*
+		{
+			return _format ? _format.textDecoration : undefined;
+		}
+		public function set textDecoration(textDecorationValue:*):void
+		{
+			writableTextLayoutFormat().textDecoration = textDecorationValue;
+			formatChanged();
+		}
+
+
+		/**
+		 * TextLayoutFormat:
+		 * Style of text.
+		 * <p>Legal values style names specified byt the font.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of "Regular".</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.text.engine.FontPosture
+		 */
+		public function get fontStyle():*
+		{
+			return _format ? _format.fontStyle : undefined;
+		}
+		public function set fontStyle(fontStyleValue:*):void
+		{
+			writableTextLayoutFormat().fontStyle = fontStyleValue;
+			formatChanged();
+		}
+
+		[Inspectable(enumeration="preserve,collapse,inherit")]
+		/**
+		 * TextLayoutFormat:
+		 * Collapses or preserves whitespace when importing text into a TextFlow. <code>WhiteSpaceCollapse.PRESERVE</code> retains all whitespace characters. <code>WhiteSpaceCollapse.COLLAPSE</code> removes newlines, tabs, and leading or trailing spaces within a block of imported text. Line break tags (<br/>) and Unicode line separator characters are retained.
+		 * <p>Legal values are WhiteSpaceCollapse.PRESERVE, WhiteSpaceCollapse.COLLAPSE, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of WhiteSpaceCollapse.COLLAPSE.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.WhiteSpaceCollapse
+		 */
+		public function get whiteSpaceCollapse():*
+		{
+			return _format ? _format.whiteSpaceCollapse : undefined;
+		}
+		public function set whiteSpaceCollapse(whiteSpaceCollapseValue:*):void
+		{
+			writableTextLayoutFormat().whiteSpaceCollapse = whiteSpaceCollapseValue;
+			formatChanged();
+		}
+
+		[Inspectable(enumeration="normal,cff,inherit")]
+		/**
+		 * TextLayoutFormat:
+		 * The rendering mode used for this text.  Applies only to embedded fonts (<code>fontLookup</code> property is set to <code>FontLookup.EMBEDDED_CFF</code>).
+		 * <p>Legal values are RenderingMode.NORMAL, RenderingMode.CFF, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of RenderingMode.CFF.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.text.engine.RenderingMode
+		 */
+		public function get renderingMode():*
+		{
+			return _format ? _format.renderingMode : undefined;
+		}
+		public function set renderingMode(renderingModeValue:*):void
+		{
+			writableTextLayoutFormat().renderingMode = renderingModeValue;
+			formatChanged();
+		}
+
+		[Inspectable(enumeration="none,horizontalStem,inherit")]
+		/**
+		 * TextLayoutFormat:
+		 * The type of CFF hinting used for this text. CFF hinting determines whether the Flash runtime forces strong horizontal stems to fit to a sub pixel grid or not. This property applies only if the <code>renderingMode</code> property is set to <code>RenderingMode.CFF</code>, and the font is embedded (<code>fontLookup</code> property is set to <code>FontLookup.EMBEDDED_CFF</code>). At small screen sizes, hinting produces a clear, legible text for human readers.
+		 * <p>Legal values are CFFHinting.NONE, CFFHinting.HORIZONTAL_STEM, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of CFFHinting.HORIZONTAL_STEM.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.text.engine.CFFHinting
+		 */
+		public function get cffHinting():*
+		{
+			return _format ? _format.cffHinting : undefined;
+		}
+		public function set cffHinting(cffHintingValue:*):void
+		{
+			writableTextLayoutFormat().cffHinting = cffHintingValue;
+			formatChanged();
+		}
+
+		[Inspectable(enumeration="device,embeddedCFF,inherit")]
+		/**
+		 * TextLayoutFormat:
+		 * Font lookup to use. Specifying <code>FontLookup.DEVICE</code> uses the fonts installed on the system that is running the SWF file. Device fonts result in a smaller movie size, but text is not always rendered the same across different systems and platforms. Specifying <code>FontLookup.EMBEDDED_CFF</code> uses font outlines embedded in the published SWF file. Embedded fonts increase the size of the SWF file (sometimes dramatically), but text is consistently displayed in the chosen font.
+		 * <p>Legal values are FontLookup.DEVICE, FontLookup.EMBEDDED_CFF, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of FontLookup.DEVICE.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.text.engine.FontLookup
+		 */
+		public function get fontLookup():*
+		{
+			return _format ? _format.fontLookup : undefined;
+		}
+		public function set fontLookup(fontLookupValue:*):void
+		{
+			writableTextLayoutFormat().fontLookup = fontLookupValue;
+			formatChanged();
+		}
+
+		[Inspectable(enumeration="rotate0,rotate180,rotate270,rotate90,auto,inherit")]
+		/**
+		 * TextLayoutFormat:
+		 * Determines the number of degrees to rotate this text.
+		 * <p>Legal values are TextRotation.ROTATE_0, TextRotation.ROTATE_180, TextRotation.ROTATE_270, TextRotation.ROTATE_90, TextRotation.AUTO, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of TextRotation.AUTO.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.text.engine.TextRotation
+		 */
+		public function get textRotation():*
+		{
+			return _format ? _format.textRotation : undefined;
+		}
+		public function set textRotation(textRotationValue:*):void
+		{
+			writableTextLayoutFormat().textRotation = textRotationValue;
+			formatChanged();
+		}
+
+		/**
+		 * TextLayoutFormat:
+		 * A Number that specifies, in pixels, the amount to indent the first line of the paragraph.
+		 * A negative indent will push the line into the margin, and possibly out of the container.
+		 * <p>Legal values are numbers from -8000 to 8000 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get textIndent():*
+		{
+			return _format ? _format.textIndent : undefined;
+		}
+		public function set textIndent(textIndentValue:*):void
+		{
+			writableTextLayoutFormat().textIndent = textIndentValue;
+			formatChanged();
+		}
+
+		/**
+		 * TextLayoutFormat:
+		 * A Number that specifies, in pixels, the amount to indent the paragraph's start edge. Refers to the left edge in left-to-right text and the right edge in right-to-left text. 
+		 * <p>Legal values are numbers from 0 to 8000 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get paragraphStartIndent():*
+		{
+			return _format ? _format.paragraphStartIndent : undefined;
+		}
+		public function set paragraphStartIndent(paragraphStartIndentValue:*):void
+		{
+			writableTextLayoutFormat().paragraphStartIndent = paragraphStartIndentValue;
+			formatChanged();
+		}
+
+		/**
+		 * TextLayoutFormat:
+		 * A Number that specifies, in pixels, the amount to indent the paragraph's end edge. Refers to the right edge in left-to-right text and the left edge in right-to-left text. 
+		 * <p>Legal values are numbers from 0 to 8000 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get paragraphEndIndent():*
+		{
+			return _format ? _format.paragraphEndIndent : undefined;
+		}
+		public function set paragraphEndIndent(paragraphEndIndentValue:*):void
+		{
+			writableTextLayoutFormat().paragraphEndIndent = paragraphEndIndentValue;
+			formatChanged();
+		}
+
+		/**
+		 * TextLayoutFormat:
+		 * A Number that specifies the amount of space, in pixels, to leave before the paragraph. 
+		 * Collapses in tandem with <code>paragraphSpaceAfter</code>.
+		 * <p>Legal values are numbers from 0 to 8000 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get paragraphSpaceBefore():*
+		{
+			return _format ? _format.paragraphSpaceBefore : undefined;
+		}
+		public function set paragraphSpaceBefore(paragraphSpaceBeforeValue:*):void
+		{
+			writableTextLayoutFormat().paragraphSpaceBefore = paragraphSpaceBeforeValue;
+			formatChanged();
+		}
+
+		/**
+		 * TextLayoutFormat:
+		 * A Number that specifies the amount of space, in pixels, to leave after the paragraph.
+		 * Collapses in tandem with  <code>paragraphSpaceBefore</code>.
+		 * <p>Legal values are numbers from 0 to 8000 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get paragraphSpaceAfter():*
+		{
+			return _format ? _format.paragraphSpaceAfter : undefined;
+		}
+		public function set paragraphSpaceAfter(paragraphSpaceAfterValue:*):void
+		{
+			writableTextLayoutFormat().paragraphSpaceAfter = paragraphSpaceAfterValue;
+			formatChanged();
+		}
+
+		[Inspectable(enumeration="left,right,center,justify,start,end,inherit")]
+		/**
+		 * TextLayoutFormat:
+		 * Alignment of lines in the paragraph relative to the container.
+		 * <code>TextAlign.LEFT</code> aligns lines along the left edge of the container. <code>TextAlign.RIGHT</code> aligns on the right edge. <code>TextAlign.CENTER</code> positions the line equidistant from the left and right edges. <code>TextAlign.JUSTIFY</code> spreads the lines out so they fill the space. <code>TextAlign.START</code> is equivalent to setting left in left-to-right text, or right in right-to-left text. <code>TextAlign.END</code> is equivalent to setting right in left-to-right text, or left in right-to-left text.
+		 * <p>Legal values are TextAlign.LEFT, TextAlign.RIGHT, TextAlign.CENTER, TextAlign.JUSTIFY, TextAlign.START, TextAlign.END, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of TextAlign.START.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.TextAlign
+		 */
+		public function get textAlign():*
+		{
+			return _format ? _format.textAlign : undefined;
+		}
+		public function set textAlign(textAlignValue:*):void
+		{
+			writableTextLayoutFormat().textAlign = textAlignValue;
+			formatChanged();
+		}
+
+		[Inspectable(enumeration="left,right,center,justify,start,end,inherit")]
+		/**
+		 * TextLayoutFormat:
+		 * Alignment of the last (or only) line in the paragraph relative to the container in justified text.
+		 * If <code>textAlign</code> is set to <code>TextAlign.JUSTIFY</code>, <code>textAlignLast</code> specifies how the last line (or only line, if this is a one line block) is aligned. Values are similar to <code>textAlign</code>.
+		 * <p>Legal values are TextAlign.LEFT, TextAlign.RIGHT, TextAlign.CENTER, TextAlign.JUSTIFY, TextAlign.START, TextAlign.END, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of TextAlign.START.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.TextAlign
+		 */
+		public function get textAlignLast():*
+		{
+			return _format ? _format.textAlignLast : undefined;
+		}
+		public function set textAlignLast(textAlignLastValue:*):void
+		{
+			writableTextLayoutFormat().textAlignLast = textAlignLastValue;
+			formatChanged();
+		}
+
+		[Inspectable(enumeration="interWord,distribute,inherit")]
+		/**
+		 * TextLayoutFormat:
+		 * Specifies options for justifying text.
+		 * Default value is <code>TextJustify.INTER_WORD</code>, meaning that extra space is added to the space characters. <code>TextJustify.DISTRIBUTE</code> adds extra space to space characters and between individual letters. Used only in conjunction with a <code>justificationRule</code> value of <code>JustificationRule.SPACE</code>.
+		 * <p>Legal values are TextJustify.INTER_WORD, TextJustify.DISTRIBUTE, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of TextJustify.INTER_WORD.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.TextJustify
+		 */
+		public function get textJustify():*
+		{
+			return _format ? _format.textJustify : undefined;
+		}
+		public function set textJustify(textJustifyValue:*):void
+		{
+			writableTextLayoutFormat().textJustify = textJustifyValue;
+			formatChanged();
+		}
+
+		[Inspectable(enumeration="eastAsian,space,auto,inherit")]
+		/**
+		 * TextLayoutFormat:
+		 * Rule used to justify text in a paragraph.
+		 * Default value is <code>FormatValue.AUTO</code>, which justifies text based on the paragraph's <code>locale</code> property. For all languages except Japanese and Chinese, <code>FormatValue.AUTO</code> becomes <code>JustificationRule.SPACE</code>, which adds extra space to the space characters.  For Japanese and Chinese, <code>FormatValue.AUTO</code> becomes <code>JustficationRule.EAST_ASIAN</code>. In part, justification changes the spacing of punctuation. In Roman text the comma and Japanese periods take a full character's width but in East Asian text only half of a character's width. Also, in the East Asian text the spacing between sequential punctuation marks becomes tighter, obeying traditional East Asian typographic conventions. Note, too, in the example below the leading that is applied to the second line of the paragraphs. In the East Asian version, the last two lines push left. In the Roman version, the second and following lines push left.<p><img src='../../../images/t
 extLayout_justificationrule.png' alt='justificationRule' /></p>
+		 * <p>Legal values are JustificationRule.EAST_ASIAN, JustificationRule.SPACE, FormatValue.AUTO, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of FormatValue.AUTO.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.JustificationRule
+		 */
+		public function get justificationRule():*
+		{
+			return _format ? _format.justificationRule : undefined;
+		}
+		public function set justificationRule(justificationRuleValue:*):void
+		{
+			writableTextLayoutFormat().justificationRule = justificationRuleValue;
+			formatChanged();
+		}
+
+		[Inspectable(enumeration="prioritizeLeastAdjustment,pushInKinsoku,pushOutOnly,auto,inherit")]
+		/**
+		 * TextLayoutFormat:
+		 * The style used for justification of the paragraph. Used only in conjunction with a <code>justificationRule</code> setting of <code>JustificationRule.EAST_ASIAN</code>.
+		 * Default value of <code>FormatValue.AUTO</code> is resolved to <code>JustificationStyle.PUSH_IN_KINSOKU</code> for all locales.  The constants defined by the JustificationStyle class specify options for handling kinsoku characters, which are Japanese characters that cannot appear at either the beginning or end of a line. If you want looser text, specify <code>JustificationStyle.PUSH-OUT-ONLY</code>. If you want behavior that is like what you get with the  <code>justificationRule</code> of <code>JustificationRule.SPACE</code>, use <code>JustificationStyle.PRIORITIZE-LEAST-ADJUSTMENT</code>.
+		 * <p>Legal values are JustificationStyle.PRIORITIZE_LEAST_ADJUSTMENT, JustificationStyle.PUSH_IN_KINSOKU, JustificationStyle.PUSH_OUT_ONLY, FormatValue.AUTO, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of FormatValue.AUTO.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.text.engine.JustificationStyle
+		 */
+		public function get justificationStyle():*
+		{
+			return _format ? _format.justificationStyle : undefined;
+		}
+		public function set justificationStyle(justificationStyleValue:*):void
+		{
+			writableTextLayoutFormat().justificationStyle = justificationStyleValue;
+			formatChanged();
+		}
+
+		[Inspectable(enumeration="ltr,rtl,inherit")]
+		/**
+		 * TextLayoutFormat:
+		 * Specifies the default bidirectional embedding level of the text in the text block. 
+		 * Left-to-right reading order, as in Latin-style scripts, or right-to-left reading order, as in Arabic or Hebrew. This property also affects column direction when it is applied at the container level. Columns can be either left-to-right or right-to-left, just like text. Below are some examples:<p><img src='../../../images/textLayout_direction.gif' alt='direction' /></p>
+		 * <p>Legal values are Direction.LTR, Direction.RTL, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of Direction.LTR.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.Direction
+		 */
+		public function get direction():*
+		{
+			return _format ? _format.direction : undefined;
+		}
+		public function set direction(directionValue:*):void
+		{
+			writableTextLayoutFormat().direction = directionValue;
+			formatChanged();
+		}
+
+		/**
+		 * TextLayoutFormat:
+		 * Specifies the optimum, minimum, and maximum spacing (as a multiplier of the width of a normal space) between words to use during justification.
+		 * The optimum space is used to indicate the desired size of a space, as a fraction of the value defined in the font. The minimum and maximum values are the used when textJustify is distribute to determine how wide or narrow the spaces between the words may grow before letter spacing is used to justify the line.
+		 * <p>Legal values as a percent are numbers from -1000% to 1000%.</p>
+		 * <p>Legal values include FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of 100%, 50%, 150%.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get wordSpacing():*
+		{
+			return _format ? _format.wordSpacing : undefined;
+		}
+		public function set wordSpacing(wordSpacingValue:*):void
+		{
+			writableTextLayoutFormat().wordSpacing = wordSpacingValue;
+			formatChanged();
+		}
+
+		/**
+		 * TextLayoutFormat:
+		 * Specifies the tab stops associated with the paragraph.
+		 * Setters can take an array of TabStopFormat, a condensed string representation, undefined, or <code>FormatValue.INHERIT</code>. The condensed string representation is always converted into an array of TabStopFormat. <p>The string-based format is a list of tab stops, where each tab stop is delimited by one or more spaces.</p><p>A tab stop takes the following form: &lt;alignment type&gt;&lt;alignment position&gt;|&lt;alignment token&gt;.</p><p>The alignment type is a single character, and can be S, E, C, or D (or lower-case equivalents). S or s for start, E or e for end, C or c for center, D or d for decimal. The alignment type is optional, and if its not specified will default to S.</p><p>The alignment position is a Number, and is specified according to FXG spec for Numbers (decimal or scientific notation). The alignment position is required.</p><p>The vertical bar is used to separate the alignment position from the alignment token, and should only be present if the alignment tok
 en is present.</p><p> The alignment token is optional if the alignment type is D, and should not be present if the alignment type is anything other than D. The alignment token may be any sequence of characters terminated by the space that ends the tab stop (for the last tab stop, the terminating space is optional; end of alignment token is implied). A space may be part of the alignment token if it is escaped with a backslash (\ ). A backslash may be part of the alignment token if it is escaped with another backslash (\\). If the alignment type is D, and the alignment token is not specified, it will take on the default value of null.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of null.</p>
+		 * @see org.apache.flex.textLayout.formats.TabStopFormat
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get tabStops():*
+		{
+			return _format ? _format.tabStops : undefined;
+		}
+		public function set tabStops(tabStopsValue:*):void
+		{
+			writableTextLayoutFormat().tabStops = tabStopsValue;
+			formatChanged();
+		}
+
+		[Inspectable(enumeration="romanUp,ideographicTopUp,ideographicCenterUp,ideographicTopDown,ideographicCenterDown,approximateTextField,ascentDescentUp,box,auto,inherit")]
+		/**
+		 * TextLayoutFormat:
+		 * Specifies the leading model, which is a combination of leading basis and leading direction.
+		 * Leading basis is the baseline to which the <code>lineHeight</code> property refers. Leading direction determines whether the <code>lineHeight</code> property refers to the distance of a line's baseline from that of the line before it or the line after it. The default value of <code>FormatValue.AUTO</code> is resolved based on the paragraph's <code>locale</code> property.  For Japanese and Chinese, it is <code>LeadingModel.IDEOGRAPHIC_TOP_DOWN</code> and for all others it is <code>LeadingModel.ROMAN_UP</code>.<p><strong>Leading Basis:</strong></p><p><img src='../../../images/textLayout_LB1.png' alt='leadingBasis1' />    <img src='../../../images/textLayout_LB2.png' alt='leadingBasis2' />    <img src='../../../images/textLayout_LB3.png' alt='leadingBasis3' /></p><p><strong>Leading Direction:</strong></p><p><img src='../../../images/textLayout_LD1.png' alt='leadingDirection1' />    <img src='../../../images/textLayout_LD2.png' alt='leadingDirection2' />    <img src='../../../image
 s/textLayout_LD3.png' alt='leadingDirection3' /></p>
+		 * <p>Legal values are LeadingModel.ROMAN_UP, LeadingModel.IDEOGRAPHIC_TOP_UP, LeadingModel.IDEOGRAPHIC_CENTER_UP, LeadingModel.IDEOGRAPHIC_TOP_DOWN, LeadingModel.IDEOGRAPHIC_CENTER_DOWN, LeadingModel.APPROXIMATE_TEXT_FIELD, LeadingModel.ASCENT_DESCENT_UP, LeadingModel.BOX, LeadingModel.AUTO, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of LeadingModel.AUTO.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.LeadingModel
+		 */
+		public function get leadingModel():*
+		{
+			return _format ? _format.leadingModel : undefined;
+		}
+		public function set leadingModel(leadingModelValue:*):void
+		{
+			writableTextLayoutFormat().leadingModel = leadingModelValue;
+			formatChanged();
+		}
+
+		/**
+		 * TextLayoutFormat:
+		 * Specifies the amount of gutter space, in pixels, to leave between the columns (adopts default value if undefined during cascade).
+		 * Value is a Number
+		 * <p>Legal values are numbers from 0 to 1000 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of 20.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get columnGap():*
+		{
+			return _format ? _format.columnGap : undefined;
+		}
+		public function set columnGap(columnGapValue:*):void
+		{
+			writableTextLayoutFormat().columnGap = columnGapValue;
+			formatChanged();
+		}
+
+		/**
+		 * TextLayoutFormat:
+		 * Left inset in pixels.  Default of auto is zero except in lists which get a start side padding of 45. (adopts default value if undefined during cascade).
+		 * Space between the left edge of the container and the text.  Value is a Number or auto.<p> With vertical text, in scrollable containers with multiple columns, the first and following columns will show the padding as blank space at the end of the container, but for the last column, if the text doesn't all fit, you may have to scroll in order to see the padding.</p>
+		 * <p>Legal values as a string are FormatValue.AUTO, FormatValue.INHERIT and numbers from -8000 to 8000.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of FormatValue.AUTO.</p>
+		 * @see org.apache.flex.textLayout.elements.Configuration#autoListElementStartPadding
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.FormatValue
+		 */
+		public function get paddingLeft():*
+		{
+			return _format ? _format.paddingLeft : undefined;
+		}
+		public function set paddingLeft(paddingLeftValue:*):void
+		{
+			writableTextLayoutFormat().paddingLeft = paddingLeftValue;
+			formatChanged();
+		}
+
+		/**
+		 * TextLayoutFormat:
+		 * Top inset in pixels.  Default of auto is zero except in lists which get a start side padding of 45. (adopts default value if undefined during cascade).
+		 * Space between the top edge of the container and the text.  Value is a Number or auto.
+		 * <p>Legal values as a string are FormatValue.AUTO, FormatValue.INHERIT and numbers from -8000 to 8000.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of FormatValue.AUTO.</p>
+		 * @see org.apache.flex.textLayout.elements.Configuration#autoListElementStartPadding
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.FormatValue
+		 */
+		public function get paddingTop():*
+		{
+			return _format ? _format.paddingTop : undefined;
+		}
+		public function set paddingTop(paddingTopValue:*):void
+		{
+			writableTextLayoutFormat().paddingTop = paddingTopValue;
+			formatChanged();
+		}
+
+		/**
+		 * TextLayoutFormat:
+		 * Right inset in pixels.  Default of auto is zero except in lists which get a start side padding of 45. (adopts default value if undefined during cascade).
+		 * Space between the right edge of the container and the text.  Value is a Number or auto. 
+		 * <p>Legal values as a string are FormatValue.AUTO, FormatValue.INHERIT and numbers from -8000 to 8000.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of FormatValue.AUTO.</p>
+		 * @see org.apache.flex.textLayout.elements.Configuration#autoListElementStartPadding
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.FormatValue
+		 */
+		public function get paddingRight():*
+		{
+			return _format ? _format.paddingRight : undefined;
+		}
+		public function set paddingRight(paddingRightValue:*):void
+		{
+			writableTextLayoutFormat().paddingRight = paddingRightValue;
+			formatChanged();
+		}
+
+		/**
+		 * TextLayoutFormat:
+		 * Bottom inset in pixels.  Default of auto is zero except in lists which get a start side padding of 45.  (adopts default value if undefined during cascade).
+		 * Space between the bottom edge of the container and the text.  Value is a Number  or auto. <p> With horizontal text, in scrollable containers with multiple columns, the first and following columns will show the padding as blank space at the bottom of the container, but for the last column, if the text doesn't all fit, you may have to scroll in order to see the padding.</p>
+		 * <p>Legal values as a string are FormatValue.AUTO, FormatValue.INHERIT and numbers from -8000 to 8000.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of FormatValue.AUTO.</p>
+		 * @see org.apache.flex.textLayout.elements.Configuration#autoListElementStartPadding
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.FormatValue
+		 */
+		public function get paddingBottom():*
+		{
+			return _format ? _format.paddingBottom : undefined;
+		}
+		public function set paddingBottom(paddingBottomValue:*):void
+		{
+			writableTextLayoutFormat().paddingBottom = paddingBottomValue;
+			formatChanged();
+		}
+
+		/**
+		 * TextLayoutFormat:
+		 * Number of text columns (adopts default value if undefined during cascade).
+		 * The column number overrides the  other column settings. Value is an integer, or <code>FormatValue.AUTO</code> if unspecified. If <code>columnCount</code> is not specified,<code>columnWidth</code> is used to create as many columns as can fit in the container.
+		 * <p>Legal values as a string are FormatValue.AUTO, FormatValue.INHERIT and from ints from 1 to 50.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of FormatValue.AUTO.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.FormatValue
+		 */
+		public function get columnCount():*
+		{
+			return _format ? _format.columnCount : undefined;
+		}
+		public function set columnCount(columnCountValue:*):void
+		{
+			writableTextLayoutFormat().columnCount = columnCountValue;
+			formatChanged();
+		}
+
+		/**
+		 * TextLayoutFormat:
+		 * Column width in pixels (adopts default value if undefined during cascade).
+		 * If you specify the width of the columns, but not the count, TextLayout will create as many columns of that width as possible, given the  container width and <code>columnGap</code> settings. Any remainder space is left after the last column. Value is a Number.
+		 * <p>Legal values as a string are FormatValue.AUTO, FormatValue.INHERIT and numbers from 0 to 8000.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of FormatValue.AUTO.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.FormatValue
+		 */
+		public function get columnWidth():*
+		{
+			return _format ? _format.columnWidth : undefined;
+		}
+		public function set columnWidth(columnWidthValue:*):void
+		{
+			writableTextLayoutFormat().columnWidth = columnWidthValue;
+			formatChanged();
+		}
+
+		/**
+		 * TextLayoutFormat:
+		 * Specifies the baseline position of the first line in the container. Which baseline this property refers to depends on the container-level locale.  For Japanese and Chinese, it is <code>TextBaseline.IDEOGRAPHIC_BOTTOM</code>; for all others it is <code>TextBaseline.ROMAN</code>.
+		 * The offset from the top inset (or right inset if <code>blockProgression</code> is RL) of the container to the baseline of the first line can be either <code>BaselineOffset.ASCENT</code>, meaning equal to the ascent of the line, <code>BaselineOffset.LINE_HEIGHT</code>, meaning equal to the height of that first line, or any fixed-value number to specify an absolute distance. <code>BaselineOffset.AUTO</code> aligns the ascent of the line with the container top inset.<p><img src='../../../images/textLayout_FBO1.png' alt='firstBaselineOffset1' /><img src='../../../images/textLayout_FBO2.png' alt='firstBaselineOffset2' /><img src='../../../images/textLayout_FBO3.png' alt='firstBaselineOffset3' /><img src='../../../images/textLayout_FBO4.png' alt='firstBaselineOffset4' /></p>
+		 * <p>Legal values as a string are BaselineOffset.AUTO, BaselineOffset.ASCENT, BaselineOffset.LINE_HEIGHT, FormatValue.INHERIT and numbers from 0 to 1000.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of BaselineOffset.AUTO.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.BaselineOffset
+		 */
+		public function get firstBaselineOffset():*
+		{
+			return _format ? _format.firstBaselineOffset : undefined;
+		}
+		public function set firstBaselineOffset(firstBaselineOffsetValue:*):void
+		{
+			writableTextLayoutFormat().firstBaselineOffset = firstBaselineOffsetValue;
+			formatChanged();
+		}
+
+		[Inspectable(enumeration="top,middle,bottom,justify,inherit")]
+		/**
+		 * TextLayoutFormat:
+		 * Vertical alignment or justification (adopts default value if undefined during cascade).
+		 * Determines how TextFlow elements align within the container.
+		 * <p>Legal values are VerticalAlign.TOP, VerticalAlign.MIDDLE, VerticalAlign.BOTTOM, VerticalAlign.JUSTIFY, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of VerticalAlign.TOP.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.VerticalAlign
+		 */
+		public function get verticalAlign():*
+		{
+			return _format ? _format.verticalAlign : undefined;
+		}
+		public function set verticalAlign(verticalAlignValue:*):void
+		{
+			writableTextLayoutFormat().verticalAlign = verticalAlignValue;
+			formatChanged();
+		}
+
+		[Inspectable(enumeration="rl,tb,inherit")]
+		/**
+		 * TextLayoutFormat:
+		 * Specifies a vertical or horizontal progression of line placement.
+		 * Lines are either placed top-to-bottom (<code>BlockProgression.TB</code>, used for horizontal text) or right-to-left (<code>BlockProgression.RL</code>, used for vertical text).
+		 * <p>Legal values are BlockProgression.RL, BlockProgression.TB, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of BlockProgression.TB.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.BlockProgression
+		 */
+		public function get blockProgression():*
+		{
+			return _format ? _format.blockProgression : undefined;
+		}
+		public function set blockProgression(blockProgressionValue:*):void
+		{
+			writableTextLayoutFormat().blockProgression = blockProgressionValue;
+			formatChanged();
+		}
+
+		[Inspectable(enumeration="explicit,toFit,inherit")]
+		/**
+		 * TextLayoutFormat:
+		 * Controls word wrapping within the container (adopts default value if undefined during cascade).
+		 * Text in the container may be set to fit the width of the container (<code>LineBreak.TO_FIT</code>), or can be set to break only at explicit return or line feed characters (<code>LineBreak.EXPLICIT</code>).
+		 * <p>Legal values are LineBreak.EXPLICIT, LineBreak.TO_FIT, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of LineBreak.TO_FIT.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.LineBreak
+		 */
+		public function get lineBreak():*
+		{
+			return _format ? _format.lineBreak : undefined;
+		}
+		public function set lineBreak(lineBreakValue:*):void
+		{
+			writableTextLayoutFormat().lineBreak = lineBreakValue;
+			formatChanged();
+		}
+
+		[Inspectable(enumeration="upperAlpha,lowerAlpha,upperRoman,lowerRoman,none,disc,circle,square,box,check,diamond,hyphen,arabicIndic,bengali,decimal,decimalLeadingZero,devanagari,gujarati,gurmukhi,kannada,persian,thai,urdu,cjkEarthlyBranch,cjkHeavenlyStem,hangul,hangulConstant,hiragana,hiraganaIroha,katakana,katakanaIroha,lowerAlpha,lowerGreek,lowerLatin,upperAlpha,upperGreek,upperLatin,inherit")]
+		/**
+		 * TextLayoutFormat:
+		 * <p>Legal values are ListStyleType.UPPER_ALPHA, ListStyleType.LOWER_ALPHA, ListStyleType.UPPER_ROMAN, ListStyleType.LOWER_ROMAN, ListStyleType.NONE, ListStyleType.DISC, ListStyleType.CIRCLE, ListStyleType.SQUARE, ListStyleType.BOX, ListStyleType.CHECK, ListStyleType.DIAMOND, ListStyleType.HYPHEN, ListStyleType.ARABIC_INDIC, ListStyleType.BENGALI, ListStyleType.DECIMAL, ListStyleType.DECIMAL_LEADING_ZERO, ListStyleType.DEVANAGARI, ListStyleType.GUJARATI, ListStyleType.GURMUKHI, ListStyleType.KANNADA, ListStyleType.PERSIAN, ListStyleType.THAI, ListStyleType.URDU, ListStyleType.CJK_EARTHLY_BRANCH, ListStyleType.CJK_HEAVENLY_STEM, ListStyleType.HANGUL, ListStyleType.HANGUL_CONSTANT, ListStyleType.HIRAGANA, ListStyleType.HIRAGANA_IROHA, ListStyleType.KATAKANA, ListStyleType.KATAKANA_IROHA, ListStyleType.LOWER_ALPHA, ListStyleType.LOWER_GREEK, ListStyleType.LOWER_LATIN, ListStyleType.UPPER_ALPHA, ListStyleType.UPPER_GREEK, ListStyleType.UPPER_LATIN, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of ListStyleType.DISC.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.ListStyleType
+		 */
+		public function get listStyleType():*
+		{
+			return _format ? _format.listStyleType : undefined;
+		}
+		public function set listStyleType(listStyleTypeValue:*):void
+		{
+			writableTextLayoutFormat().listStyleType = listStyleTypeValue;
+			formatChanged();
+		}
+
+		[Inspectable(enumeration="inside,outside,inherit")]
+		/**
+		 * TextLayoutFormat:
+		 * <p>Legal values are ListStylePosition.INSIDE, ListStylePosition.OUTSIDE, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of ListStylePosition.OUTSIDE.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.ListStylePosition
+		 */
+		public function get listStylePosition():*
+		{
+			return _format ? _format.listStylePosition : undefined;
+		}
+		public function set listStylePosition(listStylePositionValue:*):void
+		{
+			writableTextLayoutFormat().listStylePosition = listStylePositionValue;
+			formatChanged();
+		}
+
+		/**
+		 * TextLayoutFormat:
+		 * This specifies an auto indent for the start edge of lists when the padding value of the list on that side is <code>auto</code>.
+		 * <p>Legal values are numbers from -1000 to 1000 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of 40.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get listAutoPadding():*
+		{
+			return _format ? _format.listAutoPadding : undefined;
+		}
+		public function set listAutoPadding(listAutoPaddingValue:*):void
+		{
+			writableTextLayoutFormat().listAutoPadding = listAutoPaddingValue;
+			formatChanged();
+		}
+
+		[Inspectable(enumeration="start,end,left,right,both,none,inherit")]
+		/**
+		 * TextLayoutFormat:
+		 * Controls how text wraps around a float. A value of none allows the text to wrap most closely around a float. A value of left causes the text to skip over any portion of the container that has a left float, and a value of right causes the text to skip over any portion of the container that has a right float. A value of both causes the text to skip over any floats.
+		 * <p>Legal values are ClearFloats.START, ClearFloats.END, ClearFloats.LEFT, ClearFloats.RIGHT, ClearFloats.BOTH, ClearFloats.NONE, FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of ClearFloats.NONE.</p>
+		 * @see org.apache.flex.textLayout.formats.ClearFloats
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.formats.ClearFloats
+		 */
+		public function get clearFloats():*
+		{
+			return _format ? _format.clearFloats : undefined;
+		}
+		public function set clearFloats(clearFloatsValue:*):void
+		{
+			writableTextLayoutFormat().clearFloats = clearFloatsValue;
+			formatChanged();
+		}
+
+		/**
+		 * TextLayoutFormat:
+		 * Assigns an identifying class to the element, making it possible to set a style for the element by referencing the <code>styleName</code>.
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of null.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get styleName():*
+		{
+			return _format ? _format.styleName : undefined;
+		}
+		public function set styleName(styleNameValue:*):void
+		{
+			writableTextLayoutFormat().styleName = styleNameValue;
+			styleSelectorChanged();
+		}
+
+		/**
+		 * TextLayoutFormat:
+		 * Defines the formatting attributes used for links in normal state. This value will cascade down the hierarchy and apply to any links that are descendants.
+		 * Accepts <code>inherit</code>, an <code>ITextLayoutFormat</code> or converts an array of objects with key and value as members to a TextLayoutFormat.
+		 * <p>Legal values include FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of null.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get linkNormalFormat():*
+		{
+			return _format ? _format.linkNormalFormat : undefined;
+		}
+		public function set linkNormalFormat(linkNormalFormatValue:*):void
+		{
+			writableTextLayoutFormat().linkNormalFormat = linkNormalFormatValue;
+			formatChanged();
+		}
+
+		/**
+		 * TextLayoutFormat:
+		 * Defines the formatting attributes used for links in normal state. This value will cascade down the hierarchy and apply to any links that are descendants.
+		 * Accepts <code>inherit</code>, an <code>ITextLayoutFormat</code> or converts an array of objects with key and value as members to a TextLayoutFormat.
+		 * <p>Legal values include FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of null.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get linkActiveFormat():*
+		{
+			return _format ? _format.linkActiveFormat : undefined;
+		}
+		public function set linkActiveFormat(linkActiveFormatValue:*):void
+		{
+			writableTextLayoutFormat().linkActiveFormat = linkActiveFormatValue;
+			formatChanged();
+		}
+
+		/**
+		 * TextLayoutFormat:
+		 * Defines the formatting attributes used for links in hover state, when the mouse is within the bounds (rolling over) a link. This value will cascade down the hierarchy and apply to any links that are descendants.
+		 * Accepts <code>inherit</code>, an <code>ITextLayoutFormat</code> or converts an array of objects with key and value as members to a TextLayoutFormat.
+		 * <p>Legal values include FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of null.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get linkHoverFormat():*
+		{
+			return _format ? _format.linkHoverFormat : undefined;
+		}
+		public function set linkHoverFormat(linkHoverFormatValue:*):void
+		{
+			writableTextLayoutFormat().linkHoverFormat = linkHoverFormatValue;
+			formatChanged();
+		}
+
+		/**
+		 * TextLayoutFormat:
+		 * Defines the formatting attributes list markers. This value will cascade down the hierarchy and apply to any links that are descendants.
+		 * Accepts <code>inherit</code>, an <code>IListMarkerFormat</code> or converts an array of objects with key and value as members to a ListMarkerFormat.
+		 * <p>Legal values include FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will inherit its value from an ancestor. If no ancestor has set this property, it will have a value of null.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get listMarkerFormat():*
+		{
+			return _format ? _format.listMarkerFormat : undefined;
+		}
+		public function set listMarkerFormat(listMarkerFormatValue:*):void
+		{
+			writableTextLayoutFormat().listMarkerFormat = listMarkerFormatValue;
+			formatChanged();
+		}
+
+		/**
+		 * TextLayoutFormat:
+		 * Left border width in pixels (adopts default value if undefined during cascade)
+		 * <p>Legal values are numbers from 0 to 128 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get borderLeftWidth():*
+		{
+			return _format ? _format.borderLeftWidth : undefined;
+		}
+		public function set borderLeftWidth(borderLeftWidthValue:*):void
+		{
+			writableTextLayoutFormat().borderLeftWidth = borderLeftWidthValue;
+			formatChanged();
+		}
+
+		/**
+		 * TextLayoutFormat:
+		 * Right border width in pixels (adopts default value if undefined during cascade)
+		 * <p>Legal values are numbers from 0 to 128 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get borderRightWidth():*
+		{
+			return _format ? _format.borderRightWidth : undefined;
+		}
+		public function set borderRightWidth(borderRightWidthValue:*):void
+		{
+			writableTextLayoutFormat().borderRightWidth = borderRightWidthValue;
+			formatChanged();
+		}
+
+		/**
+		 * TextLayoutFormat:
+		 * Top border width in pixels (adopts default value if undefined during cascade)
+		 * <p>Legal values are numbers from 0 to 128 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get borderTopWidth():*
+		{
+			return _format ? _format.borderTopWidth : undefined;
+		}
+		public function set borderTopWidth(borderTopWidthValue:*):void
+		{
+			writableTextLayoutFormat().borderTopWidth = borderTopWidthValue;
+			formatChanged();
+		}
+
+		/**
+		 * TextLayoutFormat:
+		 * Bottom border width in pixels (adopts default value if undefined during cascade)
+		 * <p>Legal values are numbers from 0 to 128 and FormatValue.INHERIT.</p>
+		 * <p>Default value is undefined indicating not set.</p>
+		 * <p>If undefined during the cascade this property will have a value of 0.</p>
+		 * 
+		 * @throws RangeError when set value is not within range for this property
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get borderBottomWidth():*
+		{
+			return _format ? _format.borderBottomWidth : undefined;
+		}
+		public function set borderBottomWidth(borderBottomWidthValue:*):void
+		{
+			writableTextLayoutFormat().borderBottomWidth = borderBottomWidthValue;
+			formatChanged();
+		}
+
+		/**
+		 * TextLayoutFormat:
+		 * Color of the left border (adopts default value if undefined during cascade). Can be either the constant value <code>BorderColor.TRANSPARENT</code>, or a hexadecimal value that specifies the three 8-bit RGB (red, green, blue) values; for example, 0xFF0000 is red and 0x00FF00 is green.
+		 * <p>Legal values as a string are BorderColor.TRANSPARENT, FormatValue.INHERIT and uints from 0x0 to 0xffffffff.</p

<TRUNCATED>

[23/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/SelectionManager.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/SelectionManager.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/SelectionManager.as
new file mode 100644
index 0000000..fb0dd74
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/SelectionManager.as
@@ -0,0 +1,3045 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.edit {
+	import org.apache.flex.textLayout.container.IContainerController;
+	import org.apache.flex.textLayout.compose.ITextFlowTableBlock;
+	import org.apache.flex.textLayout.elements.ITableColElement;
+	import org.apache.flex.textLayout.dummy.Clipboard;
+	import org.apache.flex.core.IApplicationView;
+	import org.apache.flex.core.IParentIUIBase;
+	import org.apache.flex.events.Event;
+	import org.apache.flex.events.KeyboardEvent;
+	import org.apache.flex.events.MouseEvent;
+	import org.apache.flex.events.utils.NavigationKeys;
+	import org.apache.flex.events.utils.UIKeys;
+	import org.apache.flex.geom.Matrix;
+	import org.apache.flex.geom.Point;
+	import org.apache.flex.geom.Rectangle;
+	import org.apache.flex.reflection.getQualifiedClassName;
+	import org.apache.flex.text.engine.ITextLine;
+	import org.apache.flex.text.engine.TextRotation;
+	import org.apache.flex.text.events.IMEEvent;
+	import org.apache.flex.text.events.TextEvent;
+	import org.apache.flex.textLayout.compose.IFlowComposer;
+	import org.apache.flex.textLayout.compose.ITextFlowLine;
+	import org.apache.flex.textLayout.compose.TextFlowTableBlock;
+	import org.apache.flex.textLayout.container.ColumnState;
+	import org.apache.flex.textLayout.container.IContainerController;
+	import org.apache.flex.textLayout.debug.Debugging;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.dummy.BitmapData;
+	import org.apache.flex.textLayout.dummy.BoundsUtil;
+	import org.apache.flex.textLayout.dummy.ContextMenu;
+	import org.apache.flex.textLayout.dummy.IBitmapDrawable;
+	import org.apache.flex.textLayout.dummy.Mouse;
+	import org.apache.flex.textLayout.dummy.MouseCursor;
+	import org.apache.flex.textLayout.dummy.MouseCursorData;
+	import org.apache.flex.textLayout.elements.CellContainer;
+	import org.apache.flex.textLayout.elements.CellCoordinates;
+	import org.apache.flex.textLayout.elements.CellRange;
+	import org.apache.flex.textLayout.elements.Configuration;
+	import org.apache.flex.textLayout.elements.GlobalSettings;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.ITableCellElement;
+	import org.apache.flex.textLayout.elements.TableColElement;
+	import org.apache.flex.textLayout.elements.ITableElement;
+	import org.apache.flex.textLayout.elements.ITableRowElement;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.textLayout.elements.TextRange;
+	import org.apache.flex.textLayout.events.ContextMenuEvent;
+	import org.apache.flex.textLayout.events.EditEvent;
+	import org.apache.flex.textLayout.events.FlowOperationEvent;
+	import org.apache.flex.textLayout.events.SelectionEvent;
+	import org.apache.flex.textLayout.formats.BlockProgression;
+	import org.apache.flex.textLayout.formats.Direction;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+	import org.apache.flex.textLayout.operations.CopyOperation;
+	import org.apache.flex.textLayout.operations.FlowOperation;
+
+	import org.apache.flex.textLayout.utils.NavigationUtil;
+	import org.apache.flex.utils.PointUtils;
+    
+
+    
+    /** 
+     * The SelectionManager class manages text selection in a text flow.
+     * 
+     * <p>The selection manager keeps track of the selected text range, manages its formatting, 
+     * and can handle events affecting the selection. To allow a user to make selections in
+     * a text flow, assign a SelectionManager object to the <code>interactionManager</code>
+     * property of the flow. (To allow editing, assign an instance of the EditManager class,
+     * which extends SelectionManager.)</p>
+     *
+     * <p>The following table describes how the SelectionManager class handles keyboard shortcuts:</p>
+     *
+     * <table class="innertable" width="100%">
+     * <thead>
+     * <tr><th></th><th></th><th align = "center">TB,LTR</th><th align = "right"></th><th></th><th align = "center">TB,RTL</th><th></th><th></th><th align = "center">TL,LTR</th><th></th><th></th><th align = "center">RL,RTL</th><th></th></tr>
+     * <tr><th></th><th>none</th><th>ctrl</th><th>alt|ctrl+alt</th><th>none</th><th>ctrl</th><th>alt|ctrl+alt</th><th>none</th><th>ctrl</th><th>alt|ctrl+alt</th><th>none</th><th>ctrl</th><th>alt|ctrl+alt</th></tr>
+     * </thead>
+     * <tr><td>leftarrow</td><td>previousCharacter</td><td>previousWord</td><td>previousWord</td><td>nextCharacter</td><td>nextWord</td><td>nextWord</td><td>nextLine</td><td>endOfDocument</td><td>endOfParagraph</td><td>nextLine</td><td>endOfDocument</td><td>endOfParagraph</td></tr>
+     * <tr><td>uparrow</td><td>previousLine</td><td>startOfDocument</td><td>startOfParagraph</td><td>previousLine</td><td>startOfDocument</td><td>startOfParagraph</td><td>previousCharacter</td><td>previousWord</td><td>previousWord</td><td>nextCharacter</td><td>nextWord</td><td>nextWord</td></tr>
+     * <tr><td>rightarrow</td><td>nextCharacter</td><td>nextWord</td><td>nextWord</td><td>previousCharacter</td><td>previousWord</td><td>previousWord</td><td>previousLine</td><td>startOfDocument</td><td>startOfParagraph</td><td>previousLine</td><td>startOfDocument</td><td>startOfParagraph</td></tr>
+     * <tr><td>downarrow</td><td>nextLine</td><td>endOfDocument</td><td>endOfParagraph</td><td>nextLine</td><td>endOfDocument</td><td>endOfParagraph</td><td>nextCharacter</td><td>nextWord</td><td>nextWord</td><td>previousCharacter</td><td>previousWord</td><td>previousWord</td></tr>
+     * <tr><td>home</td><td>startOfLine</td><td>startOfDocument</td><td>startOfLine</td><td>startOfLine</td><td>startOfDocument</td><td>startOfLine</td><td>startOfLine</td><td>startOfDocument</td><td>startOfLine</td><td>startOfLine</td><td>startOfDocument</td><td>startOfLine</td></tr>
+     * <tr><td>end</td><td>endOfLine</td><td>endOfDocument</td><td>endOfLine</td><td>endOfLine</td><td>endOfDocument</td><td>endOfLine</td><td>endOfLine</td><td>endOfDocument</td><td>endOfLine</td><td>endOfLine</td><td>endOfDocument</td><td>endOfLine</td></tr>
+     * <tr><td>pagedown</td><td>nextPage</td><td>nextPage</td><td>nextPage</td><td>nextPage</td><td>nextPage</td><td>nextPage</td><td>nextPage</td><td>nextPage</td><td>nextPage</td><td>nextPage</td><td>nextPage</td><td>nextPage</td></tr>
+     * <tr><td>pageup</td><td>previousPage</td><td>previousPage</td><td>previousPage</td><td>previousPage</td><td>previousPage</td><td>previousPage</td><td>previousPage</td><td>previousPage</td><td>previousPage</td><td>previousPage</td><td>previousPage</td><td>previousPage</td></tr>
+     * </table>
+     *
+     * <p><strong>Key:</strong>
+     * <ul>
+     *  <li>none = no modifier</li>
+     *  <li>ctrl, shift, alt = modifiers</li>
+     *  <li>alt-key and ctrl+alt-key are the same on all platforms (on some platforms alt-key does not get to the Text Layout Framework (TLF)</li>
+     *  <li>shift key modifes to extend the active end of the selection in the specified manner</li>            
+     *  <li>TB (top-to-bottom),RL (right-to-left) are textFlow level <code>blockProgression</code> settings</li>                        
+     *  <li>LTR (left-to-right),RTL (right-to-left) are textFlow level <code>direction</code> settings</li>                 
+     *  <li>next and prev in logical order in the textFlow - the effect in RTL text is that the selection moves in the physical direction</li>
+     * </ul></p>
+     * 
+     * @see EditManager
+     * @see flashx.elements.ITextFlow
+     * 
+     * @playerversion Flash 10
+     * @playerversion AIR 1.5
+     * @langversion 3.0
+     */
+    public class SelectionManager implements ISelectionManager
+    {
+		static public var useTableSelectionCursors:Boolean = false;
+		/**
+		 * Cursor for selection of table
+		 **/
+		public static var SelectTable:String = "selectTable";
+		
+		/**
+		 * Cursor for selection of table row
+		 **/
+		public static var SelectTableRow:String = "selectTableRow";
+		
+		/**
+		 * Cursor for selection of table column
+		 **/
+		public static var SelectTableColumn:String = "selectTableColumn";
+		
+        private var _focusedSelectionFormat:SelectionFormat;
+        private var _unfocusedSelectionFormat:SelectionFormat;
+        private var _inactiveSelectionFormat:SelectionFormat;
+		private var _focusedCellSelectionFormat:SelectionFormat;
+		private var _unfocusedCellSelectionFormat:SelectionFormat;
+		private var _inactiveCellSelectionFormat:SelectionFormat;
+        private var _selFormatState:String = SelectionFormatState.UNFOCUSED;
+        private var _isActive:Boolean;
+        
+        /** The ITextFlow of the selection. */
+        private var _textFlow:ITextFlow;
+		
+		protected var _subManager:ISelectionManager;
+		protected var _superManager:ISelectionManager;
+		
+		private var _currentTable:ITableElement;
+		
+		// this should probably be produced dynamically rather than keep a reference.
+		private var _cellRange:CellRange;
+		
+		//TODO the following functions need proper comments and should be moved to a logical location within the class.
+		
+		public function get currentTable():ITableElement
+		{
+			return _currentTable;
+		}
+		public function set currentTable(table:ITableElement):void
+		{
+			_currentTable = table;
+		}
+		
+		public function hasCellRangeSelection():Boolean
+		{
+			if (!_currentTable) {
+				return false;
+			}
+			
+			//we should really check the anchorCellPosition and activeCellPosition instead
+			if (!_cellRange) {
+				return false;
+			}
+			
+			return true;
+		}
+		
+		/**
+		 * Select a table cell text flow
+		 **/
+		public function selectCellTextFlow(cell:ITableCellElement):void {
+			
+			if (cell && cell.table) {
+				var selectionManager:SelectionManager = cell.textFlow.interactionManager as SelectionManager;
+				
+				clear();
+				
+				if (selectionManager) {
+					selectionManager.currentTable = cell.table;
+					selectionManager.selectAll();
+					
+					// this seems to be required to work but it should not be
+					selectionManager.setFocus(); 
+				}
+			}
+		}
+		
+		/**
+		 * Select a table cell. 
+		 **/
+		public function selectCell(cell:ITableCellElement):void {
+			var beginCoordinates:CellCoordinates;
+			var endCoordinates:CellCoordinates;
+			
+			if (cell) {
+				beginCoordinates = new CellCoordinates(cell.rowIndex, cell.colIndex);
+				endCoordinates = new CellCoordinates(cell.rowIndex, cell.colIndex);
+				
+				if (beginCoordinates.isValid()) {
+					selectCellRange(beginCoordinates, endCoordinates);
+				}
+			}
+		}
+		
+		/**
+		 * Select table cells at the specified index.
+		 **/
+		public function selectCellAt(table:ITableElement, rowIndex:int, colIndex:int):void {
+			var cell:ITableCellElement = table.getCellAt(rowIndex, colIndex);
+			
+			if (cell) {
+				selectCell(cell);
+			}
+		}
+		
+		/**
+		 * Select table cells at the specified index
+		 **/
+		public function selectCells(cells:Vector.<ITableCellElement>):void {
+            var max:int = 2147483647;
+            var min:int = -2147483647;
+			var startX:int = max;
+			var startY:int = max;
+			var endX:int = min;
+			var endY:int = min;
+			var cell:ITableCellElement;
+			var table:ITableElement;
+			for each(cell in cells)
+			{
+				if(cell)
+				{
+					if(table == null)
+						table = cell.table;
+					
+					var col:int = cell.colIndex;
+					var row:int = cell.rowIndex;
+					if(col < startX)
+						startX = col;
+					if(col > endX)
+						endX = col;
+					if(row < startY)
+						startY = row;
+					if(row > endY)
+						endY = row;
+				}
+			}
+			if(startX <= endX && startY <= endY)
+				selectCellRange(
+					new CellCoordinates(startY,startX,table),
+					new CellCoordinates(endY,endX,table)
+				);
+		}
+		
+		/**
+		 * Select the specified table row. 
+		 **/
+		public function selectRow(row:ITableRowElement):void {
+			var beginCoordinates:CellCoordinates;
+			var endCoordinates:CellCoordinates;
+			
+			if (row) {
+				beginCoordinates = new CellCoordinates(row.rowIndex, 0);
+				endCoordinates = new CellCoordinates(row.rowIndex, row.numCells);
+				
+				if (beginCoordinates.isValid() && endCoordinates.isValid()) {
+					selectCellRange(beginCoordinates, endCoordinates);
+				}
+			}
+		}
+		
+		/**
+		 * Select a table row at the specified index
+		 **/
+		public function selectRowAt(table:ITableElement, index:int):void {
+			var row:ITableRowElement = table ? table.getRowAt(index) : null;
+			
+			if (row) {
+				selectRow(row);
+			}
+		}
+		
+		/**
+		 * Selects the table rows provided
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.ITableRowElement
+		 **/
+		public function selectRows(rows:Array):void {
+			var cells:Vector.<ITableCellElement> = new Vector.<ITableCellElement>();
+//			var table:ITableElement;
+			var cell:ITableCellElement;
+			
+			if (rows && rows.length) {
+				
+				for (var i:int;i<rows.length;i++) 
+				{
+					var row:ITableRowElement = rows[i] as ITableRowElement;
+					
+					if (row)
+					{
+						for each(cell in row.cells)
+						cells.push(cell);
+					}
+				}
+				
+				selectCells(cells);
+			}
+		}
+		
+		/**
+		 * Select a table column. 
+		 **/
+		public function selectColumn(column:ITableColElement):void {
+			var table:ITableElement = column.table;
+			
+			if (column && table) {
+				selectCells(table.getCellsForColumn(column));
+			}
+		}
+		
+		/**
+		 * Select a table column at the specified index 
+		 **/
+		public function selectColumnAt(table:ITableElement, index:int):void {
+			var column:ITableColElement = table.getColumnAt(index);
+			
+			if (column && table) {
+				return selectColumn(column);
+			}
+		}
+		
+		/**
+		 * Selects the table columns provided
+		 **/
+		public function selectColumns(columns:Array):void {
+			var cells:Vector.<ITableCellElement> = new Vector.<ITableCellElement>();
+			var cell:ITableCellElement;
+			
+			if (columns && columns.length) {
+				
+				for (var i:int;i<columns.length;i++) 
+				{
+					var column:ITableColElement = columns[i] as TableColElement;
+					
+					if (column)
+					{
+						for each(cell in column.cells)
+							cells.push(cell);
+					}
+					
+				}
+				
+				selectCells(cells);
+			}
+		}
+		
+		/**
+		 * Select all cells in a table. 
+		 **/
+		public function selectTable(table:ITableElement):void {
+			
+			if (table)
+			{
+				var startCoords:CellCoordinates = new CellCoordinates(0,0,table);
+				var endCoords:CellCoordinates = new CellCoordinates(table.numRows-1,table.numColumns-1,table);
+				selectCellRange(startCoords,endCoords);
+			}
+			
+		}
+		
+		/**
+		 * Select a range of table cells. 
+		 **/
+		public function selectCellRange(anchorCoords:CellCoordinates, activeCoords:CellCoordinates):void
+		{
+			var blocks:Vector.<ITextFlowTableBlock>;
+			var block:TextFlowTableBlock;
+//			var controller:IContainerController;
+			
+			if (selectionType == SelectionType.TEXT) {
+				clear();
+			}
+			clearCellSelections();
+			
+			if (anchorCoords && activeCoords) {
+				_cellRange = new CellRange(_currentTable, anchorCoords, activeCoords);
+				activeCellPosition = activeCoords;
+				blocks = _currentTable.getTableBlocksInRange(anchorCoords, activeCoords);
+				
+				for each(block in blocks) {
+					block.controller.clearSelectionShapes();
+					block.controller.addCellSelectionShapes(currentCellSelectionFormat.rangeColor, block, anchorCoords, activeCoords);
+				}
+				if(subManager)
+				{
+					subManager.selectRange(-1,-1);
+					subManager = null;
+				}
+			}
+			else
+			{
+				_cellRange = null;
+				activeCellPosition.column = -1;
+				activeCellPosition.row = -1;
+			}
+			selectionChanged();
+		}
+		
+		public function getCellRange():CellRange
+		{
+			// not really a good implementation. We'll fix this later
+			return _cellRange;
+		}
+		public function setCellRange(range:CellRange):void
+		{
+			selectCellRange(range.anchorCoordinates,range.activeCoordinates);
+			//_cellRange = range;
+			// do something about actually drawing the selection.
+		}
+        
+        // current range of selection
+        /** Anchor point of the current selection, as an index into the ITextFlow. */
+        private var anchorMark:Mark;
+        /** Active end of the current selection, as an index into the ITextFlow. */
+        private var activeMark:Mark;
+        private var _anchorCellPosition:CellCoordinates;
+		private var _activeCellPosition:CellCoordinates;
+
+		// used to save pending attributes at a point selection
+        private var _pointFormat:ITextLayoutFormat;
+        /** 
+         * The format that will be applied to inserted text. 
+         * 
+         * TBD: pointFormat needs to be extended to remember user styles and "undefine" of formats from calls to IEditManager.undefineFormat with leafFormat values on a point selection.
+         */
+        protected function get pointFormat():ITextLayoutFormat
+        { return _pointFormat; }
+
+        
+        /** @private
+         * Ignore the next text input event. This is needed because the player may send a text input event
+         * following by a key down event when ctrl+key is entered. 
+         */
+        protected var ignoreNextTextEvent:Boolean = false;
+        
+        /**
+         *  @private
+         *  For usability reasons, operations are sometimes grouped (merged) so they 
+         *  can be undone together. Certain events, such as changing the selection, may make merging 
+         *  inappropriate. This flag is used to keep track of when operation merging
+         *  is appropriate.  This might need to be moved to SelectionManager later. I'm keeping it
+         *  here for now since I'm unsure if other regular selection operations that we add can
+         *  be undone.
+         */
+        protected var allowOperationMerge:Boolean = false;
+        
+        private var _mouseOverSelectionArea:Boolean = false;    
+
+        CONFIG::debug 
+        {
+            protected var id:String;
+            static private var smCount:int = 0;
+        }
+        
+        /** 
+         * 
+         * Creates a SelectionManager object.
+         * 
+         * <p>Assign a SelectionManager object to the <code>interactionManager</code> property of
+         * a text flow to enable text selection.</p>
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */
+        public function SelectionManager()
+        {
+            _textFlow = null;
+            anchorMark = createMark();
+            activeMark = createMark();
+			anchorCellPosition = createCellMark();
+			activeCellPosition = createCellMark();
+            _pointFormat = null;
+            _isActive = false;
+            CONFIG::debug 
+            {
+                this.id = smCount.toString();
+                smCount++;
+            }
+			
+			Mouse.registerCursor(SelectTable, createSelectTableCursor());
+			Mouse.registerCursor(SelectTableRow, createSelectTableRowCursor());
+			Mouse.registerCursor(SelectTableColumn, createSelectTableColumnCursor());
+        }
+		
+        /**
+         * @copy ISelectionManager#getSelectionState()
+         * 
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         * 
+         * @see org.apache.flex.textLayout.edit.SelectionState
+         */
+        public function getSelectionState():SelectionState
+        {
+			if(subManager)
+				return subManager.getSelectionState();
+			
+            return new SelectionState(_textFlow, anchorMark.position, activeMark.position, pointFormat, _cellRange);
+        }
+                
+        /**
+         * @copy ISelectionManager#setSelectionState()
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         * 
+         * @see org.apache.flex.textLayout.edit.SelectionState
+         */
+        public function setSelectionState(sel:SelectionState):void
+        {
+            internalSetSelection(sel.textFlow, sel.anchorPosition, sel.activePosition, sel.pointFormat);
+        }
+
+        /**
+         *  @copy ISelectionManager#hasSelection()
+         * 
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */
+        public function hasSelection():Boolean
+        {
+			return selectionType == SelectionType.TEXT;
+		}
+
+		/**
+		 *  @copy ISelectionManager#hasAnySelection()
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function hasAnySelection():Boolean
+		{
+			return selectionType != SelectionType.NONE;
+		}
+
+		/**
+		 * Indicates the type of selection. 
+		 * 
+		 * <p>The <code>selectionType</code> describes the kind of selection. 
+		 * It can either be <code>SelectionType.TEXT</code> or <code>SelectionType.CELLS</code></p>
+		 * 
+		 * @see org.apache.flex.textLayout.edit.SelectionType
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get selectionType() : String
+		{
+			if(anchorMark.position != -1)
+				return SelectionType.TEXT;
+			else if(anchorCellPosition.isValid())
+				return SelectionType.CELLS;
+			
+			return SelectionType.NONE;
+		}
+        /** 
+         *  @copy ISelectionManager#isRangeSelection()
+         * 
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */             
+        public function isRangeSelection():Boolean
+        { return anchorMark.position != -1 && anchorMark.position != activeMark.position; }
+        
+        /**
+         * The ITextFlow object managed by this selection manager. 
+         * 
+         * <p>A selection manager manages a single text flow. A selection manager can also be
+         * assigned to a text flow by setting the <code>interactionManager</code> property of the
+         * ITextFlow object.</p>
+         * 
+         * @see org.apache.flex.textLayout.elements.ITextFlow#interactionManager
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */
+        public function get textFlow():ITextFlow
+        {
+            return _textFlow;
+        }
+        public function set textFlow(value:ITextFlow):void
+        {
+            if (_textFlow != value)
+            {
+                if (_textFlow)
+                    flushPendingOperations();
+                
+                clear();
+				clearCellSelections();
+				_cellRange = null;
+                
+                // If we switch into read-only mode, make sure the cursor isn't showing a text selection IBeam
+                if (!value) // see Watson 2637162
+                    setMouseCursor(MouseCursor.AUTO);
+        
+                _textFlow = value;
+                
+                if (_textFlow && _textFlow.interactionManager != this)
+                    _textFlow.interactionManager = this;
+            }
+        }  
+        
+        /**
+         *  @copy ISelectionManager#editingMode
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         * 
+         * @see org.apache.flex.textLayout.edit.EditingMode
+         */
+         public function get editingMode():String
+         {
+            return EditingMode.READ_SELECT;
+         }               
+         
+        /** 
+         *  @copy ISelectionManager#windowActive
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */
+         public function get windowActive():Boolean
+         {
+            return _selFormatState != SelectionFormatState.INACTIVE;
+         }
+         
+        /** 
+         *  @copy ISelectionManager#focused
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+        */
+         public function get focused():Boolean
+         {
+            return _selFormatState == SelectionFormatState.FOCUSED;
+         }
+         
+        /**
+         *  @copy ISelectionManager#currentSelectionFormat
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         * 
+         * @see org.apache.flex.textLayout.edit.SelectionFormat
+         */
+         public function get currentSelectionFormat():SelectionFormat
+         { 
+            if (_selFormatState == SelectionFormatState.UNFOCUSED)
+            {
+                return unfocusedSelectionFormat;
+            }
+            else if (_selFormatState == SelectionFormatState.INACTIVE)
+            {
+                return inactiveSelectionFormat;
+            }
+            return focusedSelectionFormat;
+         }
+
+		 /**
+		  *  @copy ISelectionManager#currentCellSelectionFormat
+		  * 
+		  * @playerversion Flash 10
+		  * @playerversion AIR 1.5
+		  * @langversion 3.0
+		  * 
+		  * @see org.apache.flex.textLayout.edit.SelectionFormat
+		  */
+		 public function get currentCellSelectionFormat():SelectionFormat
+		 { 
+			 if (_selFormatState == SelectionFormatState.UNFOCUSED)
+			 {
+				 return unfocusedCellSelectionFormat;
+			 }
+			 else if (_selFormatState == SelectionFormatState.INACTIVE)
+			 {
+				 return inactiveCellSelectionFormat;
+			 }
+			 return focusedCellSelectionFormat;
+		 }
+
+        /**
+         *  @copy ISelectionManager#focusedSelectionFormat
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         * 
+         * @see org.apache.flex.textLayout.edit.SelectionFormat
+         */
+         public function set focusedSelectionFormat(val:SelectionFormat):void
+         { 
+            _focusedSelectionFormat = val;
+            if (this._selFormatState == SelectionFormatState.FOCUSED)
+                refreshSelection();
+         }
+         
+        /**
+         * @private - docs on setter
+         */
+         public function get focusedSelectionFormat():SelectionFormat
+         { 
+            return _focusedSelectionFormat ? _focusedSelectionFormat : (_textFlow ? _textFlow.configuration.focusedSelectionFormat : null);
+         }       
+
+        /**
+         *  @copy ISelectionManager#unfocusedSelectionFormat
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         * 
+         * @see org.apache.flex.textLayout.edit.SelectionFormat
+         */
+         public function set unfocusedSelectionFormat(val:SelectionFormat):void
+         { 
+            _unfocusedSelectionFormat = val;
+            if (this._selFormatState == SelectionFormatState.UNFOCUSED)
+                refreshSelection();
+         }          
+         
+        /**
+         *  @private - docs on setter
+         */
+         public function get unfocusedSelectionFormat():SelectionFormat
+         { 
+            return _unfocusedSelectionFormat ? _unfocusedSelectionFormat : (_textFlow ? _textFlow.configuration.unfocusedSelectionFormat : null);
+         }
+         
+        /**
+         *  @copy ISelectionManager#inactiveSelectionFormat
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         * 
+         * @see org.apache.flex.textLayout.edit.SelectionFormat
+         */
+         public function set inactiveSelectionFormat(val:SelectionFormat):void
+         { 
+            _inactiveSelectionFormat = val;
+            if (this._selFormatState == SelectionFormatState.INACTIVE)
+                refreshSelection();
+         }          
+         
+        /**
+         * @private - docs on setter
+         */
+         public function get inactiveSelectionFormat():SelectionFormat
+         { 
+            return _inactiveSelectionFormat ? _inactiveSelectionFormat : (_textFlow ? _textFlow.configuration.inactiveSelectionFormat : null);
+         }       
+
+		 /**
+		  *  @copy ISelectionManager#focusedCellSelectionFormat
+		  * 
+		  * @playerversion Flash 10
+		  * @playerversion AIR 1.5
+		  * @langversion 3.0
+		  * 
+		  * @see org.apache.flex.textLayout.edit.SelectionFormat
+		  */
+		 public function set focusedCellSelectionFormat(val:SelectionFormat):void
+		 { 
+			 _focusedCellSelectionFormat = val;
+			 if (this._selFormatState == SelectionFormatState.FOCUSED)
+				 refreshSelection();
+		 }
+		 
+		 /**
+		  * @private - docs on setter
+		  */
+		 public function get focusedCellSelectionFormat():SelectionFormat
+		 { 
+			 return _focusedCellSelectionFormat ? _focusedCellSelectionFormat : (_textFlow ? _textFlow.configuration.focusedSelectionFormat : null);
+		 }       
+		 
+		 /**
+		  *  @copy ISelectionManager#unfocusedCellSelectionFormat
+		  * 
+		  * @playerversion Flash 10
+		  * @playerversion AIR 1.5
+		  * @langversion 3.0
+		  * 
+		  * @see org.apache.flex.textLayout.edit.SelectionFormat
+		  */
+		 public function set unfocusedCellSelectionFormat(val:SelectionFormat):void
+		 { 
+			 _unfocusedCellSelectionFormat = val;
+			 if (this._selFormatState == SelectionFormatState.UNFOCUSED)
+				 refreshSelection();
+		 }          
+		 
+		 /**
+		  *  @private - docs on setter
+		  */
+		 public function get unfocusedCellSelectionFormat():SelectionFormat
+		 { 
+			 return _unfocusedCellSelectionFormat ? _unfocusedCellSelectionFormat : (_textFlow ? _textFlow.configuration.unfocusedSelectionFormat : null);
+		 }
+		 
+		 /**
+		  *  @copy ISelectionManager#inactiveCellSelectionFormat
+		  * 
+		  * @playerversion Flash 10
+		  * @playerversion AIR 1.5
+		  * @langversion 3.0
+		  * 
+		  * @see org.apache.flex.textLayout.edit.SelectionFormat
+		  */
+		 public function set inactiveCellSelectionFormat(val:SelectionFormat):void
+		 { 
+			 _inactiveCellSelectionFormat = val;
+			 if (this._selFormatState == SelectionFormatState.INACTIVE)
+				 refreshSelection();
+		 }          
+		 
+		 /**
+		  * @private - docs on setter
+		  */
+		 public function get inactiveCellSelectionFormat():SelectionFormat
+		 { 
+			 return _inactiveCellSelectionFormat ? _inactiveCellSelectionFormat : (_textFlow ? _textFlow.configuration.inactiveSelectionFormat : null);
+		 }       
+		 
+         /** @private - returns the selectionFormatState.  @see org.apache.flex.textLayout.edit.SelectionFormatState */
+         public function get selectionFormatState():String
+         { return _selFormatState; }
+         
+         /** @private - sets the SelectionFormatState. @see org.apache.flex.textLayout.edit.SelectionFormatState */
+         public function setSelectionFormatState(selFormatState:String):void
+         {
+            if (selFormatState != _selFormatState)
+            {                   
+            //  trace("changing selection state: was", _selFormatState, "switching to", selFormatState, "on selectionManager", id);
+                var oldSelectionFormat:SelectionFormat = currentSelectionFormat;
+                _selFormatState = selFormatState;
+                var newSelectionFormat:SelectionFormat = currentSelectionFormat;
+                if (!newSelectionFormat.equals(oldSelectionFormat))
+                {
+                    refreshSelection();
+                }
+             }
+         }
+         
+         /** @private */
+         public function cloneSelectionFormatState(oldISelectionManager:ISelectionManager):void
+         {
+            var oldSelectionManager:SelectionManager = oldISelectionManager as SelectionManager;
+            if (oldSelectionManager)
+            {
+                _isActive = oldSelectionManager._isActive;
+                _mouseOverSelectionArea = oldSelectionManager._mouseOverSelectionArea;
+                setSelectionFormatState(oldSelectionManager.selectionFormatState);
+            }
+         }
+         
+        /**
+         * Gets the SelectionState at the specified mouse position.
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         * @see org.apache.flex.textLayout.edit.SelectionState
+         * @param currentTarget     The object that is actively processing the Event object with an event listener.
+         * @param target            The InteractiveObject instance under the pointing device. The target is not always the object in the display list that registered the event listener. Use the currentTarget property to access the object in the display list that is currently processing the event.
+         * @param localX            The horizontal coordinate at which the event occurred relative to the containing sprite.
+         * @param localY            The vertical coordinate at which the event occurred relative to the containing sprite.
+         * @param extendSelection   Indicates that only activeIndex should move
+         * @return the resulting SelectionState
+         */                                                                                                              
+         private function selectionPoint(currentTarget:Object, target:Object, localX:Number, localY:Number, extendSelection:Boolean = false):SelectionState
+         {
+            //trace("selectionPoint");
+            if (!_textFlow) 
+                return null;
+            if (!hasSelection()) 
+                extendSelection = false;
+            
+            var begIdx:int = anchorMark.position;
+            var endIdx:int = activeMark.position;
+            
+            endIdx = computeSelectionIndex(_textFlow, target, currentTarget, localX, localY);
+            if (endIdx == -1)
+                return null;    // ignore
+                        
+            // make sure we aren't selecting after the flow terminating character
+            endIdx = Math.min(endIdx, _textFlow.textLength - 1);
+            
+            if (!extendSelection)
+                begIdx = endIdx;                            
+
+            if (begIdx == endIdx)
+            {
+                begIdx = NavigationUtil.updateStartIfInReadOnlyElement(_textFlow, begIdx);
+                endIdx = NavigationUtil.updateEndIfInReadOnlyElement(_textFlow, endIdx);
+            } else {
+                endIdx = NavigationUtil.updateEndIfInReadOnlyElement(_textFlow, endIdx);
+            }           
+            return new SelectionState(textFlow, begIdx, endIdx);
+         }                       
+         
+        /** 
+         *  @copy ISelectionManager#setFocus()
+         * 
+         * 
+        * @playerversion Flash 10
+        * @playerversion AIR 1.5
+         * @langversion 3.0
+        */
+         public function setFocus():void
+         {
+             if (!_textFlow)
+                 return;
+             
+            //  trace("setFocus sm", id);
+
+            // container with the activePosition gets the key focus
+            if (_textFlow.flowComposer)
+                _textFlow.flowComposer.setFocus(activePosition,false);
+            setSelectionFormatState(SelectionFormatState.FOCUSED);
+         }
+         
+        /** 
+         * Set the Mouse cursor. 
+         * @param cursor    New cursor value, MouseCursor.AUTO if mouse is going off text, MouseCursor.IBEAM if mouse is going into text
+         * 
+         * @playerversion Flash 10.2
+         * @playerversion AIR 2.0
+         * @langversion 3.0
+         */
+        protected function setMouseCursor(cursor:String):void
+        {
+			Mouse.cursor = Configuration.getCursorString(textFlow.configuration, cursor);
+        }
+        
+        /**
+         *  @copy ISelectionManager#anchorPosition
+         */
+        public function get anchorPosition() : int
+        {
+            return anchorMark.position;
+        }
+        /**
+         *  @copy ISelectionManager#activePosition
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */
+        public function get activePosition() : int
+        {
+            return activeMark.position;         
+        }
+        /**
+         *  @copy ISelectionManager#absoluteStart
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */
+        public function get absoluteStart() : int
+        {
+            return (anchorMark.position < activeMark.position) ? anchorMark.position : activeMark.position;
+        }
+        /**
+         *  @copy ISelectionManager#absoluteEnd
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */
+        public function get absoluteEnd() : int
+        {
+            return (anchorMark.position > activeMark.position) ? anchorMark.position : activeMark.position;
+        }
+        
+        /** 
+         *  @copy ISelectionManager#selectAll
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         * 
+         * @see org.apache.flex.textLayout.compose.IFlowComposer
+         */
+        public function selectAll() : void
+        {
+			if(subManager)
+				subManager.selectAll();
+			else
+			{
+				var lastSelectablePos:int = (_textFlow.textLength > 0) ? _textFlow.textLength - 1 : 0;
+				selectRange(0, lastSelectablePos);
+			}
+        }
+        
+        /** 
+         * @copy ISelectionManager#selectRange
+         * 
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         * 
+         * @see org.apache.flex.textLayout.compose.IFlowComposer
+         */
+        public function selectRange(anchorPosition:int, activePosition:int) : void
+        {
+            flushPendingOperations();
+			
+			if(subManager && (anchorPosition != -1 || activePosition != -1))
+			{
+				subManager.selectRange(-1,-1);
+				subManager = null;
+			}
+			if(textFlow.nestedInTable())
+			{
+				var cell:ITableCellElement = textFlow.parentElement as ITableCellElement;
+				superManager = cell.getTextFlow().interactionManager;
+				superManager.currentTable = cell.table;
+				superManager.deselect();
+				superManager.anchorCellPosition.column = cell.colIndex;
+				superManager.anchorCellPosition.row = cell.rowIndex;
+				superManager.subManager = this;
+			}
+
+            
+            // anchor and active can be in any order
+            // TODO: range check and clamp anchor,active
+            if (anchorPosition != anchorMark.position || activePosition != activeMark.position)
+            {   
+                clearSelectionShapes();
+				clearCellSelections();
+				_cellRange = null;
+                    
+                internalSetSelection(_textFlow, anchorPosition, activePosition, _pointFormat);
+                
+                // selection changed
+                selectionChanged();
+                
+                allowOperationMerge = false;
+            }
+        }
+		
+		/** 
+		 * @copy ISelectionManager#selectFirstPosition
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 * @see org.apache.flex.textLayout.compose.IFlowComposer
+		 */
+		public function selectFirstPosition():void
+		{
+			selectRange(0, 0);
+		}
+		
+		/** 
+		 * @copy ISelectionManager#selectLastPosition
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 * @see org.apache.flex.textLayout.compose.IFlowComposer
+		 */
+		public function selectLastPosition():void
+		{
+            var max:int = 2147483647;
+			selectRange(max, max);
+		}
+
+		/** 
+		 * @copy ISelectionManager#deselect
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 * @see org.apache.flex.textLayout.compose.IFlowComposer
+		 */
+		public function deselect():void
+		{
+			if (hasAnySelection())
+			{
+				clearSelectionShapes();
+				clearCellSelections();
+				addSelectionShapes();
+			}
+			selectRange(-1,-1);
+			_cellRange = null;
+		}
+
+        private function internalSetSelection(root:ITextFlow,anchorPosition:int,activePosition:int,format:ITextLayoutFormat = null) : void
+        {
+            _textFlow = root;
+            
+            // clamp anchor/active
+            if (anchorPosition < 0 || activePosition < 0)
+            {
+                anchorPosition = -1;
+                activePosition = -1;
+            }
+			else if(subManager)
+			{
+				subManager.flushPendingOperations();
+				subManager = null;
+			}
+            
+            var lastSelectablePos:int = (_textFlow.textLength > 0) ? _textFlow.textLength - 1 : 0;
+            
+            if (anchorPosition != -1 && activePosition != -1)
+            {
+                if (anchorPosition > lastSelectablePos)
+                    anchorPosition = lastSelectablePos;
+                
+                if (activePosition > lastSelectablePos)
+                    activePosition = lastSelectablePos;
+            }
+
+            _pointFormat = format;
+            anchorMark.position = anchorPosition; // NavigationUtil.updateStartIfInReadOnlyElement(root, anchorPosition);
+            activeMark.position = activePosition; // NavigationUtil.updateEndIfInReadOnlyElement(root, activePosition);
+        //  trace("Selection ", anchorMark, "to", activeMark.position);
+        }       
+        
+        /** 
+		 * Clear any active selections.
+         */
+        private function clear(): void
+        {
+            if (hasSelection())
+            {
+                flushPendingOperations();
+                clearSelectionShapes();
+                internalSetSelection(_textFlow, -1, -1);
+                // selection cleared
+                selectionChanged();
+                allowOperationMerge = false;
+            }
+        }
+        /**
+		 * Clear any cell selections
+		 * */
+		private function clearCellSelections():void
+		{
+			var blocks:Vector.<ITextFlowTableBlock>;
+			var block:ITextFlowTableBlock;
+			var controller:IContainerController;
+			
+			if (_cellRange) {
+				blocks = _cellRange.table.getTableBlocksInRange(_cellRange.anchorCoordinates, _cellRange.activeCoordinates);
+				
+				for each (block in blocks) {
+					if (controller != block.controller) {
+						block.controller.clearSelectionShapes();
+					}
+					
+					controller = block.controller;
+				}
+				
+			}
+			if(block)
+				block.controller.clearSelectionShapes();
+			
+			//_cellRange = null;
+		}
+        private function addSelectionShapes():void
+        {
+            if (_textFlow.flowComposer)
+            {
+                // selection may need to be constrained due to model changes that weren't done with the EditManager
+                internalSetSelection(_textFlow, anchorMark.position, activeMark.position, _pointFormat);
+                
+                // zero alpha means nothing is drawn so skip it
+                if (currentSelectionFormat && 
+                    (((absoluteStart == absoluteEnd) &&  (currentSelectionFormat.pointAlpha != 0)) ||
+                     ((absoluteStart != absoluteEnd) && (currentSelectionFormat.rangeAlpha != 0))))
+                {
+                    var containerIter:int = 0;
+                    while(containerIter < _textFlow.flowComposer.numControllers)
+                    {
+                        _textFlow.flowComposer.getControllerAt(containerIter++).addSelectionShapes(currentSelectionFormat, absoluteStart, absoluteEnd);
+                    }
+                }
+            }
+        }
+        
+        private function clearSelectionShapes():void
+        {
+            var flowComposer:IFlowComposer = _textFlow ? _textFlow.flowComposer : null; 
+            if (flowComposer)
+            {
+                var containerIter:int = 0;
+                while(containerIter < flowComposer.numControllers)
+                {
+                    flowComposer.getControllerAt(containerIter++).clearSelectionShapes();
+                }
+            }
+        }
+		
+		/** 
+		 *  @copy ISelectionManager#refreshSelection()
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function refreshSelection(): void
+		{
+			if (hasAnySelection())
+			{
+				clearSelectionShapes();
+				clearCellSelections();
+				addSelectionShapes();
+			}
+		}
+		
+		/** 
+		 *  @copy ISelectionManager#clearSelection()
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function clearSelection(): void
+		{
+			if (hasAnySelection())
+			{
+				clearSelectionShapes();
+				clearCellSelections();
+			}
+		}
+        
+        /** Verifies that the selection is in a legal state. @private */
+        CONFIG::debug public function debugCheckSelectionManager():int
+        {
+            var rslt:int = 0;
+            if (hasSelection())
+            {
+                // both points must be within the flow - may not include trailing \n in final paragraph
+                var lastPosition:int = _textFlow.textLength > 0 ? _textFlow.textLength - 1 : 0;
+                rslt += assert(anchorMark.position >= 0 && anchorMark.position <= lastPosition,"SelectionManager:validate selBegIdx is out of range");
+                rslt += assert(activeMark.position >= 0 && activeMark.position <= lastPosition,"SelectionManager:validate selEndIdx is out of range");
+            }
+            return rslt;
+        }
+        
+        // ////////////////////////////////////
+        // internal selection handling methods
+        // ////////////////////////////////////
+        
+        /** @private
+         * Handler function called when the selection has been changed.
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         * @param doDispatchEvent   true if a selection changed event will be sent
+         * @param resetPointFormat  true if the attributes associated with the caret should be discarded
+         */
+        public function selectionChanged(doDispatchEvent:Boolean = true, resetPointFormat:Boolean=true):void
+        {
+            CONFIG::debug { debugCheckSelectionManager(); } // validates the selection
+            
+            // clear any remembered attributes for the next character
+            if (resetPointFormat) 
+                _pointFormat = null;
+            
+            if (doDispatchEvent && _textFlow)
+			{
+				if(textFlow.parentElement && textFlow.parentElement.getTextFlow())
+					textFlow.parentElement.getTextFlow().dispatchEvent(new SelectionEvent(SelectionEvent.SELECTION_CHANGE, false, false, hasSelection() ? getSelectionState() : null));
+				else
+					textFlow.dispatchEvent(new SelectionEvent(SelectionEvent.SELECTION_CHANGE, false, false, hasSelection() ? getSelectionState() : null));
+			}
+        }
+
+        // TODO: this routine could be much more efficient - instead of iterating over all lines in the ITextFlow it should iterate over 
+        // the visible lines in the container.  Todo that move this routine into ContainerController and use the shapeChildren along with the logic in fillShapeChildren
+        static private function computeSelectionIndexInContainer(textFlow:ITextFlow, controller:IContainerController, localX:Number, localY:Number):int
+        {
+			var result:int;
+            //var origX:Number = localX;
+            //var origY:Number = localY;
+            var lineIndex:int = -1;
+            
+            var firstCharVisible:int = controller.absoluteStart;
+            var length:int  = controller.textLength;
+            
+            // try to find a point on the line
+            var bp:String = textFlow.computedFormat.blockProgression;
+            var isTTB:Boolean = (bp == BlockProgression.RL);
+            var isDirectionRTL:Boolean = (textFlow.computedFormat.direction == Direction.RTL);
+            
+            //Establish perpendicular the coordinate for use with TTB or LTR/RTL lines
+            var perpCoor:Number = isTTB ? localX : localY;
+            
+            //get the nearest column so we can ignore lines which aren't in the column we're looking for.
+            //if we don't do this, we won't be able to select across column boundaries.
+            var nearestColIdx:int = locateNearestColumn(controller, localX, localY, textFlow.computedFormat.blockProgression,textFlow.computedFormat.direction);
+
+			var prevLineBounds:Rectangle = null;
+			var previousLineIndex:int = -1;
+
+			/*
+			//For the table feature, we are trying to make sure if the current point is in the table and which cell it is in
+			var nearestCell:ITableCellElement = locateNearestCell(controller, localX, localY, textFlow.computedFormat.blockProgression,textFlow.computedFormat.direction);
+            
+			
+			if(nearestCell)
+			{
+				//To-Do: Need to update the codes to be a real paragraph search sequence
+				var cellPara:IParagraphElement = nearestCell.getLastLeaf().getParagraph();
+				if(cellPara.getTextFlow() == textFlow)
+				{
+					//textLine = cellPara.getTextBlock().lastLine;
+					
+					//result = computeSelectionIndexInLine(textFlow, textLine, localX, localY);
+					// trace("computeSelectionIndexInContainer:(",origX,origY,")",textFlow.flowComposer.getControllerIndex(controller).toString(),lineIndex.toString(),result.toString());
+					return cellPara.getAbsoluteStart() + cellPara.textLength - 1;
+				}
+			}
+            */
+            var lastLineIndexInColumn:int = -1;
+            
+            // Matching ITextFlowLine and ITextLine - they are not necessarily valid
+            var rtline:ITextFlowLine;
+            var rtTextLine:ITextLine;
+            
+            for (var testIndex:int = textFlow.flowComposer.numLines - 1; testIndex >= 0; testIndex--)
+            {
+                rtline = textFlow.flowComposer.getLineAt(testIndex);
+                if (rtline.controller != controller || rtline.columnIndex != nearestColIdx)
+                {
+                    // use last line in previous column
+                    if (lastLineIndexInColumn != -1)
+                    {
+                        lineIndex = testIndex+1;
+                        break;
+                    }
+                    continue;
+                }
+                    
+                // is this line even displayed?
+                if (rtline.absoluteStart < firstCharVisible || rtline.absoluteStart >= firstCharVisible+length)
+                    continue;
+                rtTextLine = rtline.getTextLine();
+                if (rtTextLine == null || rtTextLine.parent == null)
+                    continue;
+                
+                if (lastLineIndexInColumn == -1)
+                    lastLineIndexInColumn = testIndex;
+                    
+                var bounds:Rectangle = BoundsUtil.getBounds(rtTextLine, controller.container);// rtTextLine.getBounds(DisplayObject(controller.container));
+                // trace(testIndex.toString(),":",bounds.toString());
+                
+                var linePerpCoor:Number = isTTB ? bounds.left : bounds.bottom;
+                var midPerpCoor:Number = -1;//will be a positive value if prevLineBounds is not null
+                
+                //if this is not the first test loop, use the prevLineBounds to find the mid-point between the current
+                //line, which will be logically up from the previous line - we're walking back-to-front
+                if(prevLineBounds)
+                {
+                    //if it's ttb, use the right bounds (ie the top of the line)...
+                    var prevPerpCoor:Number = (isTTB ? prevLineBounds.right : prevLineBounds.top);
+                    //calculate the midpoint
+                    midPerpCoor = (linePerpCoor + prevPerpCoor)/2;
+                }
+                
+                //if the current line is below the click, then this OR the previous line, is the line we're looking for
+                var isLineBelow:Boolean = (isTTB ? linePerpCoor > perpCoor : linePerpCoor < perpCoor);
+                if(isLineBelow || testIndex == 0)
+                {
+                    //if we haven't calculated the midPerpCoor (-1), then this is the first loop and we want to use the 
+                    //current line,. Otherwise, if the click's perpendicular coordinate is below the mid point between the current
+                    //line or below it, then we want to use the line below (ie the previous line, but logically the one after the current)
+                    var inPrevLine:Boolean = midPerpCoor != -1 && (isTTB ? perpCoor < midPerpCoor : perpCoor > midPerpCoor);
+					/*
+					if(rtline.paragraph.isInTable())
+					{
+						//if rtline is the last line of the cell and the isPrevLine is true, find the cell of the column in next row
+						//and try to set the line to be 
+						if ( inPrevLine && testIndex != lastLineIndexInColumn )
+						{
+							var rtPara:IParagraphElement = rtline.paragraph;
+							var rtCell:ITableCellElement = rtPara.getParentCellElement();
+							//get the last element of the cell
+							var lastElement:FlowElement = rtCell.getLastLeaf();
+							var rtLastTbLine:ITextFlowLine = lastElement ? lastElement.getParagraph().getTextBlock().lastLine.userData : null;
+							if( rtline == rtLastTbLine )
+							{
+								//temproray codes, need to be updated when the column apis are ready
+								var rtTable:ITableElement = rtCell.table;
+								var rtRow:ITableRowElement = rtCell.parent as ITableRowElement;
+								var nextRow:ITableRowElement = rtRow.getNextSibling() as ITableRowElement;
+								if ( nextRow && rtCell )
+								{
+									var nextCell:ITableCellElement = nextRow.getChildAt(rtCell.colIndex) as ITableCellElement;
+									lineIndex = textFlow.flowComposer.findLineIndexAtPosition(nextCell.getFirstLeaf().getParagraph().getAbsoluteStart());
+								}
+							}
+							else
+								lineIndex = testIndex + 1;
+						}
+						else
+							lineIndex = testIndex;
+					}
+					else
+					*/
+                    	lineIndex = inPrevLine && testIndex != lastLineIndexInColumn ? testIndex+1 : testIndex;
+					break;
+                }
+                else
+                {
+                    //this line is below the click, so set the prevLineBounds to bounds of the current line and move on...
+                    prevLineBounds = bounds;
+                    previousLineIndex = testIndex;
+                }
+            }
+
+            if (lineIndex == -1)
+            {
+                lineIndex = previousLineIndex;
+                if (lineIndex == -1)
+                    return -1;  // no lines in container
+            }   
+                
+            //Get a valid textLine -- check to make sure line is valid, regenerate if necessary, make sure it has correct container relative coordinates
+            var textFlowLine:ITextFlowLine = textFlow.flowComposer.getLineAt(lineIndex);
+			if(textFlowLine is TextFlowTableBlock)
+			{
+				result = TextFlowTableBlock(textFlowLine).absoluteStart;
+			}
+			else
+			{
+				var textLine:ITextLine = textFlowLine.getTextLine(true);
+				
+				// adjust localX,localY to be relative to the textLine.  
+				// Can't use localToGlobal/globalToLocal because textLine may not be on the display list due to virtualization
+				// we may need to bring this back if textline's can be rotated or placed by any mechanism other than a translation
+				// but then we'll need to provisionally place a virtualized ITextLine in its parent container
+				localX -= textLine.x;
+				localY -= textLine.y;
+				/* var localPoint:Point = DisplayObject(controller.container).localToGlobal(new Point(localX,localY));
+				localPoint = textLine.globalToLocal(localPoint);
+				localX = localPoint.x;
+				localY = localPoint.y; */
+				
+				
+				var startOnNextLineIfNecessary:Boolean = false;
+				
+				var lastAtom:int = -1;
+				if (isDirectionRTL) {
+					lastAtom = textLine.atomCount - 1;
+				} else {
+					if ((textFlowLine.absoluteStart + textFlowLine.textLength) >= textFlowLine.paragraph.getAbsoluteStart() + textFlowLine.paragraph.textLength) {
+						if (textLine.atomCount > 1) lastAtom = textLine.atomCount - 2;
+					} else {
+						var lastLinePosInPar:int = textFlowLine.absoluteStart + textFlowLine.textLength - 1;
+						var lastChar:String = textLine.textBlock.content.rawText.charAt(lastLinePosInPar);
+						if (lastChar == " ") {
+							if (textLine.atomCount > 1) lastAtom = textLine.atomCount - 2;
+						} else {
+							startOnNextLineIfNecessary = true;
+							if (textLine.atomCount > 0) lastAtom = textLine.atomCount - 1;
+						}
+					}
+				}
+				var lastAtomRect:Rectangle = (lastAtom > 0) ? textLine.getAtomBounds(lastAtom) : new Rectangle(0, 0, 0, 0);
+				
+				if (!isTTB)
+				{
+					if (localX < 0)
+						localX = 0;
+					else if (localX > (lastAtomRect.x + lastAtomRect.width))
+					{
+						if (startOnNextLineIfNecessary) 
+							return textFlowLine.absoluteStart + textFlowLine.textLength - 1;
+						if (lastAtomRect.x + lastAtomRect.width > 0)
+							localX = lastAtomRect.x + lastAtomRect.width;
+					}
+				}
+				else
+				{   
+					if (localY < 0) 
+						localY = 0;
+					else if (localY > (lastAtomRect.y + lastAtomRect.height))
+					{
+						if (startOnNextLineIfNecessary) 
+							return textFlowLine.absoluteStart + textFlowLine.textLength - 1;    
+						if (lastAtomRect.y + lastAtomRect.height > 0)
+							localY = lastAtomRect.y + lastAtomRect.height;
+					}
+				}
+				
+				result = computeSelectionIndexInLine(textFlow, textLine, localX, localY);
+			}
+
+            // trace("computeSelectionIndexInContainer:(",origX,origY,")",textFlow.flowComposer.getControllerIndex(controller).toString(),lineIndex.toString(),result.toString());
+            return result != -1 ? result : firstCharVisible + length;   
+        }
+		/*
+		static private function locateNearestCell(container:ContainerController, localX:Number, localY:Number, wm:String, direction:String):ITableCellElement
+		{
+			var cellIdx:int = 0;
+			//if we only have 1 column, no need to perform calculation...
+			var columnState:ColumnState = container.columnState;
+			
+			var isFound:Boolean = false;
+			var curCell:ITableCellElement = null;
+			
+			//we need to compare the current column to the nextColmn
+			while(cellIdx < columnState.cellCount - 1)
+			{
+				curCell = columnState.getCellAt(cellIdx);
+				var curRect:Rectangle = new Rectangle(curCell.x, curCell.y, curCell.width, curCell.height);
+				
+				if(curRect.contains(localX, localY)) //in current column
+				{
+					isFound = true;
+					break;
+				}
+				++cellIdx;
+			}
+			return isFound? curCell : null;
+		}
+        */
+        static private function locateNearestColumn(container:IContainerController, localX:Number, localY:Number, wm:String, direction:String):int
+        {
+            var colIdx:int = 0;
+            //if we only have 1 column, no need to perform calculation...
+            var columnState:ColumnState = container.columnState;
+
+            //we need to compare the current column to the nextColmn
+            while(colIdx < columnState.columnCount - 1)
+            {
+                var curCol:Rectangle  = columnState.getColumnAt(colIdx);
+                var nextCol:Rectangle = columnState.getColumnAt(colIdx + 1);
+                
+                if(curCol.contains(localX, localY)) //in current column
+                    break;
+                
+                if(nextCol.contains(localX, localY))//in next column
+                {
+                    ++colIdx;
+                    break;
+                }
+                else
+                {
+                    if(wm == BlockProgression.RL)
+                    {
+                        //if localY is above curCol || between columns, but close to current
+                        if(localY < curCol.top || localY < nextCol.top && Math.abs(curCol.bottom - localY) <= Math.abs(nextCol.top - localY))
+                            break;
+                        
+                        if(localY > nextCol.top)//between but closer to nextCol
+                        {
+                            ++colIdx;
+                            break;
+                        }
+                    }
+                    else
+                    {
+                        if(direction  == Direction.LTR)
+                        {
+                            //if localX is left of curCol || between columns but closer to current, break here
+                            if(localX < curCol.left || localX < nextCol.left && Math.abs(curCol.right - localX) <= Math.abs(nextCol.left - localX)) 
+                                break;
+                            if(localX < nextCol.left) // between, but closer to next column
+                            {
+                                ++colIdx;
+                                break;
+                            }
+                        }
+                        else
+                        {
+                            //if localX is right of curCol || between columns, but closer to current
+                            if(localX > curCol.right || localX > nextCol.right && Math.abs(curCol.left - localX) <= Math.abs(nextCol.right - localX))
+                                break;
+                            
+                            if(localX > nextCol.right) // between, but closer to next column
+                            {
+                                ++colIdx;
+                                break;
+                            }
+                        } 
+                    }
+                }
+                
+                //increment colIdx.  If this is the last pass through, then the conditions above were never met
+                //so we want the last column
+                ++colIdx;
+            }
+
+            
+            return colIdx;
+        }
+        
+        static private function computeSelectionIndexInLine(textFlow:ITextFlow, textLine:ITextLine,localX:Number,localY:Number):int
+        {
+            if (!(textLine.userData is ITextFlowLine))
+                return -1;  // not a TextLayout generated line
+                
+            var rtline:ITextFlowLine = ITextFlowLine(textLine.userData);
+            if (rtline.validity == "invalid")
+                return -1;  // not currently composed 
+            textLine = rtline.getTextLine(true);    // make sure the ITextLine is not released
+            
+                
+            var isTTB:Boolean = textFlow.computedFormat.blockProgression == BlockProgression.RL;
+            var perpCoor:Number = isTTB ? localX : localY;
+            
+            // new code for builds 385 and later
+            var pt:Point = new Point();
+            pt.x = localX;
+            pt.y = localY;
+            
+            // in most cases, we want to "fixup" the coordiates of the x and y coordinates
+            //because we could be getting a positive results for a click in the line, but the
+            //coordinates do not match any particular glyph.  However, there are cases where the 
+            //fix leads to bad results. For example, if there is a TCY run, this code will always cause
+            //a selection to be created in the middle of the run, meaning idividual glyphs cannot be selected.
+            //
+            //As a result, we need to be performing the less common case check prior to adjusting the 
+            //coordinates.
+            pt = PointUtils.localToGlobal(pt, textLine);// textLine.localToGlobal(pt);
+            var elemIdx:int = textLine.getAtomIndexAtPoint(pt.x,pt.y);
+            //trace("global point: " + pt);
+            //trace("elemIdx: " + elemIdx);
+            if(elemIdx == -1)
+            {
+                //reset the pt
+                pt.x = localX;
+                pt.y = localY;
+                
+                //make adjustments
+                if (pt.x < 0 || (isTTB && perpCoor > textLine.ascent))
+                    pt.x = 0;
+                if (pt.y < 0 || (!isTTB && perpCoor > textLine.descent))
+                    pt.y = 0;
+                
+                //get the global again and get try for the element again
+                pt = PointUtils.localToGlobal(pt, textLine);// textLine.localToGlobal(pt);
+                elemIdx = textLine.getAtomIndexAtPoint(pt.x,pt.y);
+                //trace("global point (second): " + pt);
+                //trace("elemIdx (second): " + elemIdx);
+            }
+            
+            //now we REALLY don't have a glyph, so return the head or tail of the line.
+            if (elemIdx == -1)
+            {
+                //we need to use global coordinates here.  reset pt and get conversion...
+                pt.x = localX;
+                pt.y = localY;
+                pt = PointUtils.localToGlobal(pt, textLine);// textLine.localToGlobal(pt);
+                if (textLine.parent)
+                    pt = PointUtils.globalToLocal(pt, textLine.parent);// textLine.parent.globalToLocal(pt);
+                
+                if(!isTTB)
+                    return (pt.x <= textLine.x) ? rtline.absoluteStart : (rtline.absoluteStart + rtline.textLength - 1);
+                else
+                    return (pt.y <= textLine.y) ? rtline.absoluteStart : (rtline.absoluteStart + rtline.textLength - 1);
+            }
+            
+            // get the character box and if check we are past the middle select past this character. 
+            var glyphRect:Rectangle = textLine.getAtomBounds(elemIdx);
+            // trace("idx",elemIdx,"x",glyphRect.x,"y",glyphRect.y,"width",glyphRect.width,"height",glyphRect.height,"localX",localX,"localY",localY,"textLine.x",textLine.x);
+            var leanRight:Boolean = false;
+            if(glyphRect)
+            {   
+                //if this is TTB and NOT TCY determine lean based on Y coordinates...
+                if(isTTB && textLine.getAtomTextRotation(elemIdx) != TextRotation.ROTATE_0)
+                    leanRight = (localY > (glyphRect.y + glyphRect.height/2));
+                else //use X..
+                    leanRight = (localX > (glyphRect.x + glyphRect.width/2));
+            }
+            
+            var paraSelectionIdx:int;
+            if ((textLine.getAtomBidiLevel(elemIdx) % 2) != 0) // Right to left case, right is "start" unicode
+                paraSelectionIdx = leanRight ? textLine.getAtomTextBlockBeginIndex(elemIdx) : textLine.getAtomTextBlockEndIndex(elemIdx);
+            else  // Left to right case, right is "end" unicode
+                paraSelectionIdx = leanRight ? textLine.getAtomTextBlockEndIndex(elemIdx) : textLine.getAtomTextBlockBeginIndex(elemIdx);
+
+			//we again need to do some fixup here.  Unfortunately, we don't have the index into the paragraph until
+            return rtline.paragraph.getTextBlockAbsoluteStart(textLine.textBlock) + paraSelectionIdx;
+        }
+        
+		/**
+		 *  @flexjsignorecoercion org.apache.flex.core.IParentIUIBase
+		 */
+        static private function checkForDisplayed(container:IParentIUIBase):Boolean
+        {
+            try
+            {
+                while (container)
+                {
+                    if (!container.visible)
+                        return false;
+                    container = container.parent as IParentIUIBase;
+//TODO is this performant enough? Can we check for null instead?
+                    if (container is IApplicationView)
+                        return true;                    
+                }
+            }
+            catch (e:Error)
+            { return true; }
+            return false;   // not on the stage
+
+        }
+		/** @private - find a controller and adjusts the x and y values of localPoint if necessary */
+		private static function findController(textFlow:ITextFlow, target:Object, currentTarget:Object, localPoint:Point):IContainerController
+		{
+			var localX:Number = localPoint.x;
+			var localY:Number = localPoint.y;
+			var controller:IContainerController;
+			var containerPoint:Point; // scratch
+			
+			var globalPoint:Point = PointUtils.localToGlobal(new Point(localX, localY), target);// DisplayObject(target).localToGlobal(new Point(localX, localY));
+
+			for (var idx:int = 0; idx < textFlow.flowComposer.numControllers; idx++)
+			{
+				var testController:IContainerController = textFlow.flowComposer.getControllerAt(idx); 
+				if (testController.container == target || testController.container == currentTarget)
+				{
+					controller = testController;
+					break;
+				}
+			}
+			if (controller)
+			{   
+				if (target != controller.container)
+				{
+					containerPoint = PointUtils.globalToLocal(globalPoint, controller.container);// DisplayObject(controller.container).globalToLocal(globalPoint);
+					localPoint.x = containerPoint.x;
+					localPoint.y = containerPoint.y;
+				}
+				return controller;         
+			} 
+			
+			//the point is someplace else on stage.  Map the target 
+			//to the textFlow.container.
+			CONFIG::debug { assert(textFlow.flowComposer && textFlow.flowComposer.numControllers,"findController: invalid textFlow"); }
+			
+			
+			
+			// result of the search
+			var controllerCandidate:IContainerController = null;
+			var candidateLocalX:Number;
+			var candidateLocalY:Number;
+			var relDistance:Number = Number.MAX_VALUE;
+			
+			for (var containerIndex:int = 0; containerIndex < textFlow.flowComposer.numControllers; containerIndex++)
+			{
+				var curContainerController:IContainerController = textFlow.flowComposer.getControllerAt(containerIndex);
+				
+				// displayed??
+				if (!checkForDisplayed(curContainerController.container))
+					continue;
+				
+				// handle measured containers??
+				var bounds:Rectangle = curContainerController.getContentBounds();
+				var containerWidth:Number = isNaN(curContainerController.compositionWidth) ? curContainerController.getTotalPaddingLeft()+bounds.width : curContainerController.compositionWidth;
+				var containerHeight:Number = isNaN(curContainerController.compositionHeight) ? curContainerController.getTotalPaddingTop()+bounds.height : curContainerController.compositionHeight;
+				
+				containerPoint = PointUtils.globalToLocal(globalPoint, curContainerController.container);// DisplayObject(curContainerController.container).globalToLocal(globalPoint);
+				
+				// remove scrollRect effects for the distance test but add it back in for the result
+				var adjustX:Number = 0;
+				var adjustY:Number = 0;
+
+//TODO deal with scrollRect
+//				if (curContainerController.hasScrollRect)
+//				{
+//					containerPoint.x -= (adjustX = curContainerController.container.scrollRect.x);
+//					containerPoint.y -= (adjustY = curContainerController.container.scrollRect.y);
+//				}
+				
+				if ((containerPoint.x >= 0) && (containerPoint.x <= containerWidth) &&
+					(containerPoint.y >= 0) && (containerPoint.y <= containerHeight))
+				{
+					controllerCandidate = curContainerController;
+					candidateLocalX = containerPoint.x+adjustX;
+					candidateLocalY = containerPoint.y+adjustY;
+					break;
+				}
+				
+				// figure minimum distance of containerPoint to curContainerController - 8 cases
+				var relDistanceX:Number = 0;
+				var relDistanceY:Number = 0;
+				
+				if (containerPoint.x < 0)
+				{
+					relDistanceX = containerPoint.x;
+					if (containerPoint.y < 0)
+						relDistanceY = containerPoint.y;
+					else if (containerPoint.y > containerHeight)
+						relDistanceY = containerPoint.y-containerHeight;
+				}
+				else if (containerPoint.x > containerWidth)
+				{
+					relDistanceX = containerPoint.x-containerWidth;
+					if (containerPoint.y < 0)
+						relDistanceY = containerPoint.y;
+					else if (containerPoint.y > containerHeight)
+						relDistanceY = containerPoint.y-containerHeight;
+				}
+				else if (containerPoint.y < 0)
+					relDistanceY = -containerPoint.y;
+				else
+					relDistanceY = containerPoint.y-containerHeight;
+				var tempDist:Number = relDistanceX*relDistanceX + relDistanceY*relDistanceY;    // could do sqrt but why bother - there is no Math.hypot function
+				if (tempDist <= relDistance)
+				{
+					relDistance = tempDist;
+					controllerCandidate = curContainerController;
+					candidateLocalX = containerPoint.x+adjustX;
+					candidateLocalY = containerPoint.y+adjustY;
+				}
+			}
+			localPoint.x = candidateLocalX;
+			localPoint.y = candidateLocalY;
+			return controllerCandidate;
+
+		}
+		/** @private - given a target and location compute the CellCoordinates */
+		static public function computeCellCoordinates(textFlow:ITextFlow, target:Object, currentTarget:Object, localX:Number, localY:Number):CellCoordinates
+		{
+//			var rslt:CellCoordinates;
+//			var containerPoint:Point; // scratch
+			
+
+			if (target is ITextLine)
+				return null;
+			if(target is CellContainer)
+			{
+				var cell:ITableCellElement = (target as CellContainer).cellElement;
+				return new CellCoordinates(cell.rowIndex, cell.colIndex, cell.table);
+			}
+			var localPoint:Point = new Point(localX, localY);
+			var controller:IContainerController = findController(textFlow, target, currentTarget, localPoint);
+			if(!controller)
+				return null;
+			
+			return controller.findCellAtPosition(localPoint);
+		}
+
+        /** @private - given a target and location compute the selectionIndex */
+        static public function computeSelectionIndex(textFlow:ITextFlow, target:Object, currentTarget:Object, localX:Number,localY:Number):int
+        {           
+            //trace("computeSelectionIndex");
+            var rslt:int = 0;
+//            var containerPoint:Point; // scratch
+            
+            //Make sure that if the target is a line, that it is part of THIS textFlow and not another.  Can happen
+            //when holding down mouse and moving out of one flow and over another. Could also happen when moving over
+            //TextLines that are either non-TLF or generated from a factory. 
+            var useTargetedTextLine:Boolean = false;
+            if (target is ITextLine)
+            {
+                var tfl:ITextFlowLine = ITextLine(target).userData as ITextFlowLine;
+                if (tfl)
+                {
+                    var para:IParagraphElement = tfl.paragraph;
+                    if(para.getTextFlow() == textFlow)
+                        useTargetedTextLine = true;
+                }
+            }
+            /* trace("got target class", target.toString(), "at (", localX, localY, ")");
+            trace("Mapping",localX,localY,"for",target);
+            containerPoint = DisplayObject(target).localToGlobal(new Point(localX, localY));
+            trace("... Global",containerPoint.x,containerPoint.y);
+            containerPoint = DisplayObject(currentTarget).globalToLocal(containerPoint);
+            trace("... container Local",containerPoint.x,containerPoint.y); */
+            
+            if (useTargetedTextLine)
+                rslt = computeSelectionIndexInLine(textFlow, ITextLine(target), localX, localY);
+            else
+            {
+				var localPoint:Point = new Point(localX,localY);
+                var controller:IContainerController = findController(textFlow, target, currentTarget, localPoint);
+				rslt = controller ? computeSelectionIndexInContainer(textFlow, controller, localPoint.x, localPoint.y) : -1;
+            }
+            
+            if (rslt >= textFlow.textLength)
+                rslt = textFlow.textLength-1;
+            return rslt;
+        }
+        
+        /** initialize a new point selection at click point @private */
+        public function setNewSelectionPoint(currentTarget:Object, target:Object, localX:Number, localY:Number, extendSelection:Boolean = false):Boolean
+        {
+            var selState:SelectionState = selectionPoint(currentTarget, target, localX, localY, extendSelection);
+            if (selState == null)
+                return false;   // ignore
+            
+            if (selState.anchorPosition != anchorMark.position || selState.activePosition != activeMark.position)
+            {
+            //  clear(false);
+            //  internalSetSelection(_textFlow, selState.anchorPosition, selState.activePosition);
+                selectRange(selState.anchorPosition, selState.activePosition);
+                return true;
+            }
+            return false;
+        }
+        
+        // ///////////////////////////////////
+        // Mouse and keyboard methods 
+        // ///////////////////////////////////
+        
+        /** 
+         *  @copy IInteractionEventHandler#mouseDownHandler()
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         * @flexjsignorecoercion org.apache.flex.textLayout.elements.ITableCellElement
+         */ 
+        public function mouseDownHandler(event:MouseEvent):void
+        {
+			if(subManager)
+				subManager.selectRange(-1,-1);
+			
+			var cell:ITableCellElement = _textFlow.parentElement as ITableCellElement;
+			var coords:CellCoordinates;
+			if(!cell)
+				coords = computeCellCoordinates(textFlow,event.target,event.currentTarget,event.localX, event.localY);
+			if(cell || coords)
+			{
+				if(coords)
+					cell = coords.table.findCell(coords);
+				
+				superManager = cell.getTextFlow().interactionManager;
+				if(event.shiftKey && cell.table == superManager.currentTable)
+				{
+					flushPendingOperations();
+
+					// expand cell selection if applicable
+					coords = new CellCoordinates(cell.rowIndex,cell.colIndex);
+					if(
+						!CellCoordinates.areEqual(coords,superManager.anchorCellPosition) ||
+						superManager.activeCellPosition.isValid()
+					){
+						superManager.selectCellRange(superManager.anchorCellPosition,coords);
+						superManager.subManager = null;
+						allowOperationMerge = false;
+						event.stopPropagation();
+						return;
+					}
+				}
+				if(superManager == this)
+				{
+					if(cell.textFlow.interactionManager)
+					{
+						cell.textFlow.interactionManager.mouseDownHandler(event);
+					}
+					return;
+				}
+				superManager.currentTable = cell.table;
+				superManager.deselect();
+				//superManager.setSelectionState(new SelectionState(superManager.textFlow,-1,-1) );
+				superManager.anchorCellPosition.column = cell.colIndex;
+				superManager.anchorCellPosition.row = cell.rowIndex;
+				superManager.subManager = this;
+			}
+            handleMouseEventForSelection(event, event.shiftKey, cell != null);
+        }
+        
+        /**
+         * @copy IInteractionEventHandler#mouseMoveHandler()
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */ 
+        public function mouseMoveHandler(event:MouseEvent):void {
+            var wmode:String = textFlow.computedFormat.blockProgression;            
+			
+			if (wmode != BlockProgression.RL) {
+                setMouseCursor(MouseCursor.IBEAM);
+			}
+			
+			
+            if (event.buttonDown)
+			{
+				var cell:ITableCellElement = _textFlow.parentElement as ITableCellElement;
+				
+				// if the event is owned by a cell, we need to check if the mouse is now above another cell to select a cell range.
+				if (cell) {
+					
+					do {
+						var cellCoords:CellCoordinates = new CellCoordinates(cell.rowIndex, cell.colIndex, cell.table);
+						var coords:CellCoordinates = computeCellCoordinates(cell.getTextFlow(), event.target, event.currentTarget, event.localX, event.localY);
+						if(!coords)
+							break;
+						if(CellCoordinates.areEqual(cellCoords, coords) &&
+							(!superManager.activeCellPosition.isValid() || CellCoordinates.areEqual(coords, superManager.activeCellPosition))
+						)
+							break;
+						if(coords.table != cellCoords.table)
+							break;
+						
+						superManager = cell.getTextFlow().interactionManager;
+						if(
+							!CellCoordinates.areEqual(coords, superManager.activeCellPosition)
+						){
+							allowOperationMerge = false;
+							superManager.selectCellRange(superManager.anchorCellPosition, coords);
+							event.stopPropagation();
+							return;
+						}
+
+						
+					}while(0);
+				}
+				if(superManager && superManager.getCellRange())
+					return;
+				
+				handleMouseEventForSelection(event, true, _textFlow.parentElement != null);
+
+			}
+        }
+        
+        /** @private */
+        public function handleMouseEventForSelection(event:MouseEvent, allowExtend:Boolean,stopPropogate:Boolean=false):void
+        {
+            var startSelectionActive:Boolean = hasSelection();
+            
+            if (setNewSelectionPoint(event.currentTarget, event.target, event.localX, event.localY, startSelectionActive && allowExtend))
+            {
+                if (startSelectionActive)
+                    clearSelectionShapes();
+
+                if (hasSelection())
+                    addSelectionShapes();
+            }       
+            allowOperationMerge = false;
+			if(stopPropogate)
+				event.stopPropagation();
+        }
+        
+        /** 
+         * @copy IInteractionEventHandler#mouseUpHandler()
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */ 
+        public function mouseUpHandler(event:MouseEvent):void
+        {
+            if (!_mouseOverSelectionArea)
+            {
+                setMouseCursor(MouseCursor.AUTO);
+            }
+        }
+        
+        private function atBeginningWordPos(activePara:IParagraphElement, pos:int):Boolean
+        {
+            if (pos == 0) return true;
+			
+			// mjzhang : for fix bug 2835316, will force to compose to paragraph end to avoid invalid textLine
+			var paraEnd:Number = activePara.getAbsoluteStart() + activePara.textLength;
+			activePara.getTextFlow().flowComposer.composeToPosition(paraEnd);
+			
+            var nextPos:int = activePara.findNextWordBoundary(pos);
+            nextPos = activePara.findPreviousWordBoundary(nextPos);
+            return (pos == nextPos);
+        }
+                
+        
+        /** 
+         * @copy IInteractionEventHandler#mouseDoubleClickHandler()
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */ 
+        public function mouseDoubleClickHandler(event:MouseEvent):void
+        {
+            if (!hasSelection())
+                return;
+
+            // We got a previous single click event that set the selection.
+            // Extend it into a selection for the entire word.
+
+            // Adjust the active end to the beginning or end of the nearest word, depending on which end of the selection is active
+            var activePara:IParagraphElement = _textFlow.findAbsoluteParagraph(activeMark.position);
+            var activeParaStart:int = activePara.getAbsoluteStart();
+            var newActiveIndex:int; // adjusted active index
+            if (anchorMark.position <= activeMark.position)
+                newActiveIndex = activePara.findNextWordBoundary(activeMark.position - activeParaStart) + activeParaStart;
+            else
+                newActiveIndex = activePara.findPreviousWordBoundary(activeMark.position - activeParaStart) + activeParaStart;
+                
+            // don't include end of paragraph marker
+            if (newActiveIndex == activeParaStart+activePara.textLength)
+                newActiveIndex--;
+
+            // Adjust the anchor end. If we're doing a dbl-click shift select to extend the selection, the anchor point stays the same.
+            // Otherwise adjust it to the beginning or end of the nearest word, depending on which end of the selection is active
+            var newAnchorIndex:int; // adjusted anchor index
+            if (event.shiftKey) 
+                newAnchorIndex = anchorMark.position;
+            else
+            {
+                var anchorPara:IParagraphElement = _textFlow.findAbsoluteParagraph(anchorMark.position);
+                var anchorParaStart:int = anchorPara.getAbsoluteStart();
+                if (atBeginningWordPos(anchorPara, anchorMark.position - anchorParaStart))
+                {
+                    newAnchorIndex = anchorMark.position;                   
+                }
+                else
+                {
+                    if (anchorMark.position <= activeMark.position)
+                        newAnchorIndex = anchorPara.findPreviousWordBoundary(anchorMark.position - anchorParaStart) + anchorParaStart;
+                    else
+                        newAnchorIndex = anchorPara.findNextWordBoundary(anchorMark.position - anchorParaStart) + anchorParaStart;
+                    // don't include end of paragraph marker
+                    if (newAnchorIndex == anchorParaStart+anchorPara.textLength)
+                        newAnchorIndex--;
+                }   
+            }
+            
+            if (newAnchorIndex != anchorMark.position || newActiveIndex != activeMark.position)
+            {
+                internalSetSelection(_textFlow, newAnchorIndex, newActiveIndex, null);              
+                selectionChanged();
+                clearSelectionShapes();
+
+                if (hasSelection())
+                    addSelectionShapes();
+            }
+            
+            allowOperationMerge = false;
+        }
+
+        /** 
+         * @copy IInteractionEventHandler#mouseOverHandler()
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */                         
+        public function mouseOverHandler(event:MouseEvent):void
+        {
+            _mouseOverSelectionArea = true;
+            var wmode:String = textFlow.computedFormat.blockProgression;
+			
+            if (wmode != BlockProgression.RL) {
+				var cell:ITableCellElement = _textFlow.parentElement as ITableCellElement;
+				
+				// set the cursor if around the edge of the table
+				if (cell) {
+					var leftEdge:int = 5;
+					var topEdge:int = 5;
+					var globalPoint:Point = new Point(event.stageX, event.stageY);
+					var cellContainer:CellContainer = event.currentTarget as CellContainer;
+					var point:Point;
+					
+					if (cellContainer) {
+						var cellContainerPoint:Point = PointUtils.localToGlobal(new Point(), cellContainer);// cellContainer.localToGlobal(new Point);
+						point = globalPoint.subtract(cellContainerPoint);
+					}
+					if(useTableSelectionCursors)
+					{
+						// set cursor for row, table or column
+						if (cell.colIndex==0 && point.x<leftEdge && point.y>topEdge)
+						{
+							event.stopPropagation();
+							event.stopImmediatePropagation();
+							setMouseCursor(SelectTableRow);
+						}
+						else if (cell.rowIndex==0 && cell.colIndex==0 &&
+							point.x<leftEdge && point.y<topEdge)
+						{
+							event.stopPropagation();
+							event.stopImmediatePropagation();
+							setMouseCursor(SelectTable);
+						}
+						else if (cell.rowIndex==0 && point.x>leftEdge && point.y<topEdge)
+						{
+							event.stopPropagation();
+							event.stopImmediatePropagation();
+							setMouseCursor(SelectTableColumn);
+						}
+						else {
+							setMouseCursor(MouseCursor.IBEAM);
+						}
+						
+					}
+					else {
+						setMouseCursor

<TRUNCATED>

[13/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TextFlow.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TextFlow.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TextFlow.as
new file mode 100644
index 0000000..5ccd042
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TextFlow.as
@@ -0,0 +1,1247 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	import org.apache.flex.events.Event;
+	import org.apache.flex.events.EventDispatcher;
+	import org.apache.flex.textLayout.compose.IFlowComposer;
+	import org.apache.flex.textLayout.compose.ISWFContext;
+	import org.apache.flex.textLayout.compose.ITextFlowLine;
+	import org.apache.flex.textLayout.compose.utils.ContextUtil;
+	import org.apache.flex.textLayout.container.IContainerController;
+	import org.apache.flex.textLayout.debug.Debugging;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.edit.ISelectionManager;
+	import org.apache.flex.textLayout.elements.utils.BackgroundHelper;
+	import org.apache.flex.textLayout.events.DamageEvent;
+	import org.apache.flex.textLayout.events.ModelChange;
+	import org.apache.flex.textLayout.factory.ITLFFactory;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+	import org.apache.flex.textLayout.utils.CreateTLFUtil;
+	import org.apache.flex.utils.ObjectMap;
+
+		
+
+	
+	/**
+	 *
+	 *  @eventType org.apache.flex.textLayout.events.FlowOperationEvent.FLOW_OPERATION_BEGIN
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	 
+	[Event(name="flowOperationBegin", type="org.apache.flex.textLayout.events.FlowOperationEvent")]
+	
+	/**
+	 * 
+	 * @eventType org.apache.flex.textLayout.events.FlowOperationEvent.FLOW_OPERATION_END
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	 
+	[Event(name="flowOperationEnd", type="org.apache.flex.textLayout.events.FlowOperationEvent")]
+	
+	/**
+	 * 
+	 * @eventType org.apache.flex.textLayout.events.FlowOperationEvent.FLOW_OPERATION_COMPLETE
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	
+	[Event(name="flowOperationComplete", type="org.apache.flex.textLayout.events.FlowOperationEvent")]
+	
+	/** Dispatched whenever the selection is changed.  Primarily used to update selection-dependent user interface. 
+	 * It can also be used to alter the selection, but cannot be used to alter the TextFlow itself.
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	
+	[Event(name="selectionChange", type="org.apache.flex.textLayout.events.SelectionEvent")]
+	
+	/** Dispatched after every recompose. 
+	*
+	* @playerversion Flash 10
+	* @playerversion AIR 1.5
+	* @langversion 3.0
+	*/
+	
+	[Event(name="compositionComplete", type="org.apache.flex.textLayout.events.CompositionCompleteEvent")]
+	
+	/** Dispatched when the mouse is pressed down over any link. 
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	
+	[Event(name="mouseDown", type="org.apache.flex.textLayout.events.FlowElementMouseEvent")]
+	
+	/** Dispatched when the mouse is released over any link. 
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	
+	[Event(name="mouseUp", type="org.apache.flex.textLayout.events.FlowElementMouseEvent")]
+	
+	/** Dispatched when the mouse passes over any link. 
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	
+	[Event(name="mouseMove", type="org.apache.flex.textLayout.events.FlowElementMouseEvent")]	
+	
+	/** Dispatched when the mouse first enters any link. 
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	
+	[Event(name="rollOver", type="org.apache.flex.textLayout.events.FlowElementMouseEvent")]
+	
+	/** Dispatched when the mouse goes out of any link. 
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	
+	[Event(name="rollOut", type="org.apache.flex.textLayout.events.FlowElementMouseEvent")]	
+	
+	/** Dispatched when any link is clicked. 
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	
+	[Event(name="click", type="org.apache.flex.textLayout.events.FlowElementMouseEvent")]
+	
+	/** Dispatched when a InlineGraphicElement is resized due to having width or height as auto or percent 
+	 * and the graphic has finished loading. 
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	
+	[Event(name="inlineGraphicStatusChanged", type="org.apache.flex.textLayout.events.StatusChangeEvent")]
+	
+	/** Dispatched by a TextFlow object after text is scrolled within a controller container.  
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	
+	[Event(name="scroll", type="org.apache.flex.textLayout.events.TextLayoutEvent")]
+	
+	/** Dispatched by a TextFlow object each time it is damaged 
+	 * 
+	 * You can use this event to find out that the TextFlow has changed, but do not access the TextFlow itself when this event 
+	 * is sent out. This event is sent when TextFlow changes are partially complete, so it can be in an inconsistent state: 
+	 * some changes have been mad already, and other changes are still pending. Get the information you need from the event, and make 
+	 * required changes after control returns to your application.
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	
+	[Event(name="damage", type="org.apache.flex.textLayout.events.DamageEvent")]
+
+	/** Dispatched by a TextFlow object each time a container has had new DisplayObjects added or updated as a result of composition.
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	
+	[Event(name="updateComplete", type="org.apache.flex.textLayout.events.UpdateCompleteEvent")]
+
+
+	/**
+	 * The TextFlow class is responsible for managing all the text content of a story. In TextLayout, text is stored in a 
+	 * hierarchical tree of elements. TextFlow is the root object of the element tree. All elements on the tree
+	 * derive from the base class, FlowElement. 
+	 *
+	 * <p>A TextFlow object can have ParagraphElement, ListElement and DivElement objects as children. A div (DivElement
+	 * object) represents a group of paragraphs (ParagraphElement objects). A ListElement contains ListItemElement objects
+	 * which in turn contain one or more ParagraphElement objects. A paragraph can have SpanElement, InlineGraphicElement, 
+	 * LinkElement, and TCYElement objects as children.</p>
+	 * 
+	 * <p>A span (SpanElement) is a range of text in a paragraph that has the same attributes. An image
+	 * (InlineGraphicElement) represents an arbitrary graphic that appears as a single character in a line of text. A 
+	 * LinkElement represents a hyperlink, or HTML <code>a</code> tag, and it can contain multiple spans. A TCYElement object
+	 * is used in Japanese text when there is a small run of text that appears perpendicular to the line, as in a horizontal
+	 * run within a vertical line. A TCYElement also can contain multiple spans.</p>
+	 
+	 * <p>TextFlow also derives from the ContainerFormattedElement class, which is the root class for all container-level block 
+	 * elements.</p>
+ 	 * <p>The following illustration shows the relationship of other elements, such as spans and paragraphs, to the TextFlow 
+ 	 * object.</p>
+ 	 * <p><img src="../../../images/textLayout_textFlowHierarchy.gif" alt="example TextFlow hierarchy"></img></p>
+ 	 *
+ 	 * <p>Each TextFlow object has a corresponding Configuration object that allows you to specify initial character and 
+ 	 * paragraph formats and the initial container format. It also allows you to specify attributes for selection, links, 
+ 	 * focus, and scrolling. When you supply a Configuration object as parameter to the <code>TextFlow()</code>
+ 	 * constructor, it creates a read-only snapshot that you can access through the <code>TextFlow.configuration</code>
+ 	 * property. After creation, you can't change the TextFlow's configuration. If you do not specify a Configuration, you 
+ 	 * can access the default configuration through the <code>TextFlow.defaultConfiguration</code> property.</p>
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 *
+	 * @see #configuration
+	 * @see IConfiguration
+	 * @see DivElement
+	 * @see FlowElement
+	 * @see IFlowGroupElement
+	 * @see FlowLeafElement
+	 * @see org.apache.flex.textLayout.compose.IFlowComposer IFlowComposer
+	 * @see ParagraphElement
+	 * @see SpanElement
+	 */
+	public class TextFlow extends ContainerFormattedElement implements ITextFlow
+	{		
+		private var _flowComposer:IFlowComposer;
+		
+		/** References the Selection manager attached to this TextFlow object. */
+		private var _interactionManager:ISelectionManager;
+		
+		/** References the Configuration object for this TextFlow object. */
+		
+		private var _configuration:IConfiguration;
+		
+		/** Manages computing and drawing backgroundColor attribute */
+		private var _backgroundManager:IBackgroundManager;
+		
+		/** Default configuration for all new TextFlow objects if the configuration is not specified. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 *
+	 	 * @see Configuration
+		 */
+								
+		// normalize support
+		private var normalizeStart:int = 0;
+		private var normalizeLen:int = 0;
+		
+		// event dispatch support; lazy initialization
+		private var _eventDispatcher:EventDispatcher;
+		
+		// textflow specific generation support - used to validate undo
+		private var _generation:uint;
+		// next generation number to hand out - these just have to be unique so share one.
+		// 0 is reserved to mean "not set"
+		static private var _nextGeneration:uint = 1;
+		
+		// styling support
+		private var _formatResolver:IFormatResolver;
+		
+		// interactive object count - now LinkElements later add in elements with eventMirrors
+		private var _interactiveObjectCount:int;
+		
+		// ILG count
+		private var _graphicObjectCount:int;
+		
+		// nested TextFlow support
+		private var _parentElement:IFlowGroupElement;
+				
+		/** 
+		 * Constructor - creates a new TextFlow instance.
+		 *
+		 * <p>If you provide a <code>config</code> parameter, the contents of the Configuration object are copied and
+		 * you cannot make changes. You can access configuration settings, however, through the 
+		 * <code>configuration</code> property. If the <code>config</code> parameter is null, you can access the default
+		 * configuration settings through the <code>defaultConfiguration</code> property.</p> 
+		 *
+		 * <p>The Configuration object provides a mechanism for setting configurable default attributes on a TextFlow.  
+		 * While you can't make changes to the Configuration object, you can override default attributes, if necessary, 
+		 * by setting the attributes of TextFlow and its children.</p>
+		 * 
+		 * @param config Specifies the configuration to use for this TextFlow object. If it's null, use 
+		 * <code>TextFlow.defaultConfiguration</code> to access configuration values. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 * 
+	 	 * @see Configuration
+	 	 * @see #configuration
+	 	 * @see #defaultConfiguration
+		 * 
+		 */
+		 
+		public function TextFlow(tlfFactory:ITLFFactory,config:IConfiguration = null)
+		{
+			_tlfFactory = tlfFactory;
+			super();
+			initializeForConstructor(config);
+		}
+		
+		override public function get className():String
+		{
+			return "TextFlow";
+		}
+		private var _tlfFactory:ITLFFactory;
+		public function get tlfFactory() : ITLFFactory {
+			return _tlfFactory;
+		}
+		
+		private function initializeForConstructor(config:IConfiguration):void
+		{
+			if (config == null)
+				config = ConfigurationHelper.defaultConfiguration;
+			// read only non changing copy of current state
+			_configuration = config.getImmutableClone();
+			// do not set up the event dispatcher yet
+			
+			format = _configuration.textFlowInitialFormat;
+			
+			// initialize the flowComposer
+			if (_configuration.flowComposerClass)
+				flowComposer = new _configuration.flowComposerClass();
+			
+			_generation = _nextGeneration++;
+			_interactiveObjectCount = 0;
+			_graphicObjectCount = 0;
+		}
+		
+		/** @private */
+		public override function shallowCopy(startPos:int = 0, endPos:int = -1):IFlowElement
+		{		
+			var retFlow:TextFlow = super.shallowCopy(startPos, endPos) as TextFlow;
+			retFlow._configuration = _configuration;
+			retFlow._generation = _nextGeneration++;
+			if (formatResolver)
+				retFlow.formatResolver = formatResolver.getResolverForNewFlow(this,retFlow);
+			// TODO: preserve the hostFormat??
+			// preserve the swfContext
+			if (retFlow.flowComposer && flowComposer)
+				retFlow.flowComposer.swfContext = flowComposer.swfContext;
+			return retFlow;						
+		}
+		
+		/** @private - count of interactive objects */
+		public function get interactiveObjectCount():int
+		{ return _interactiveObjectCount; }
+		
+		/** @private - increment the count */
+		public function incInteractiveObjectCount():void
+		{ _interactiveObjectCount++; } 
+		
+		/** @private - decrement the count */
+		public function decInteractiveObjectCount():void
+		{ _interactiveObjectCount--; }
+		
+		/** @private - count of interactive objects */
+		public function get graphicObjectCount():int
+		{ return _graphicObjectCount; }
+		
+		/** @private - increment the count */
+		public function incGraphicObjectCount():void
+		{ _graphicObjectCount++; } 
+		
+		/** @private - decrement the count */
+		public function decGraphicObjectCount():void
+		{ _graphicObjectCount--; }
+		
+		/** 
+		* The Configuration object for this TextFlow object. The Configuration object specifies the initial character 
+		* and paragraph formats, the initial container format, and attributes for selection highlighting, 
+		* links, focus, and scrolling.
+		*
+		* <p>If you do not specify a Configuration object, Text Layout Framework uses a default Configuration object, which
+		* is referenced by the <code>defaultConfiguration</code> property.</p>
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0
+	 	*
+	 	* @see Configuration
+	 	* @see #defaultConfiguration
+	 	*/
+		public function get configuration():IConfiguration
+		{ return _configuration; }
+
+		/**
+		 * The InteractionManager associated with this TextFlow object.
+		 * <p>Controls all selection and editing on the text. If the TextFlow is not selectable, 
+		 * the interactionManager is null. To make the TextFlow editable, assign a interactionManager
+		 * that is both an ISelectionManager and an IEditManager. To make a TextFlow that is read-only
+		 * and allows selection, assign a interactionManager that is an ISelectionManager only. </p>
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 *
+		 * @see org.apache.flex.textLayout.edit.ISelectionManager ISelectionManager
+		 * @see org.apache.flex.textLayout.edit.IEditManager IEditManager
+		 */
+		public function get interactionManager():ISelectionManager
+		{
+			return _interactionManager;
+		}
+		public function set interactionManager(newInteractionManager:ISelectionManager):void
+		{
+			// detatch old interactionManager
+			if (_interactionManager != newInteractionManager)
+			{
+				if (_interactionManager)
+					_interactionManager.textFlow = null;
+				_interactionManager = newInteractionManager;
+				if (_interactionManager)
+				{
+					_interactionManager.textFlow = this;
+					normalize();
+				}
+				if (flowComposer)
+					flowComposer.interactionManagerChanged(newInteractionManager);
+			}
+		}
+		
+		/** Manages the containers for this element.
+		 * 
+		 * <p>The TextLines that are created from the element appear as children of the container.
+		 * The flowComposer manages the containers, and as the text is edited it adds lines to and removes lines
+		 * from the containers. The flowComposer also keeps track of some critical attributes, such as the
+		 * width and height to compose to, whether scrolling is on, and so on.</p>
+		 * 
+		 * <p>The container and <code>flowComposer</code> are closely related. If you reset <code>flowComposer</code>, 
+		 * the container is reset to the new flowComposer's container. Likewise if the container is reset, 
+		 * <code>flowComposer</code> is reset to the container's new flowComposer.</p>
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 *
+	 	 * @see org.apache.flex.textLayout.compose.IFlowComposer FlowComposer
+		 */
+		public override function get flowComposer():IFlowComposer
+		{ 
+			return _flowComposer; 
+		}
+		
+		public function set flowComposer(composer:IFlowComposer):void
+		{
+			changeFlowComposer(composer,true);
+		}
+		
+		/** @private use this function directly if you want to clear the flowcomposer but not unload the graphics.  */
+		public function changeFlowComposer(newComposer:IFlowComposer,okToUnloadGraphics:Boolean):void
+		{
+			var origComposer:IFlowComposer = _flowComposer;
+			if (_flowComposer != newComposer)
+			{
+				var oldSWFContext:ISWFContext = ContextUtil.computeBaseSWFContext(_flowComposer ? _flowComposer.swfContext : null);
+				var newSWFContext:ISWFContext = ContextUtil.computeBaseSWFContext(newComposer ? newComposer.swfContext : null);					
+				
+				// Clear out old settings
+				if (_flowComposer)
+				{
+					//hideSelection is no longer on IFlowComposer, so do it manually
+					var containerIter:int = 0;
+					while(containerIter < _flowComposer.numControllers)
+						_flowComposer.getControllerAt(containerIter++).clearSelectionShapes();
+					
+					_flowComposer.setRootElement(null); 	// clear event listeners
+				}
+
+				_flowComposer = newComposer;
+	
+				if (_flowComposer)
+					_flowComposer.setRootElement(this);
+					
+				// Mark flow as damaged
+				if (textLength)
+					damage(getAbsoluteStart(), textLength, "invalid", false);
+				
+				if (oldSWFContext != newSWFContext)
+					invalidateAllFormats();
+	
+				// containers *may* have changed requiring reinherit of columnDirection/blockProgression
+				// but that's only in the case when we have ContainerFormattedElements that can have containers -- if then
+				// this call is really expensive for long flows and needs to be optimized for cases when nothing changes
+				// containerFormatChanged(false);
+
+				// no longer visible shut down all the InlineGraphicElements
+				if (_flowComposer == null)
+				{
+					if (okToUnloadGraphics)
+						unloadGraphics();
+				}
+				else if (origComposer == null)
+					prepareGraphicsForLoad();
+			}
+		}
+		
+		/** @private - use to unload ILGs.  Generally TLF manage this for you but TLF errs on the side of letting the graphics run once they are started.  There may
+		 * be cases where the client will want to unload the graphics. */
+		public function unloadGraphics():void
+		{
+//TODO we probably do not need graphic unloading
+//			if (_graphicObjectCount)
+//				applyFunctionToElements(function (elem:FlowElement):Boolean{ if (elem is InlineGraphicElement) (elem as InlineGraphicElement).stop(true); return false; });			
+		}
+		
+		/** @private - use to queue ILGs for loading.  Generally TLF manage this for you.  However, this function exists so that clients may initiate a load in edge cases. 
+		 * Graphics aren't loaded until the next updateAllControllers call.  */
+		public function prepareGraphicsForLoad():void
+		{
+			// queue for start/restart any graphics that are not loaded but have a URL or CLASS source
+			if (_graphicObjectCount)
+				appendElementsForDelayedUpdate(this,null);			
+		}
+		
+		/** Returns an element whose <code>id</code> property matches the <code>idName</code> parameter. Provides
+		 * the ability to apply a style based on the <code>id</code>. 
+		 *
+		 * <p>For example, the following line sets the style "color" to 0xFF0000 (red), for the
+		 * element having the <code>id</code> span1.</p>
+		 *
+		 * <listing version="3.0" >
+		 * textFlow.getElementByID("span1").setStyle("color", 0xFF0000);
+		 * </listing>
+		 *
+		 * <p><strong>Note:</strong> In the following code, <code>p.addChild(s)</code> <em>removes</em> <code>s</code> 
+		 * from its original parent and adds it to <code>p</code>, the new parent.</p>
+		 *
+		 * <listing version="3.0" >
+		 * var s:SpanElement = new SpanElement();
+		 * var p:ParagraphElement = new ParagraphElement();
+		 * ...
+		 * s = textFlow.getElementByID("span3") as SpanElement;
+		 * p.addChild(s);
+		 * textFlow.addChild(p);
+		 * </listing>
+		 *
+		 * @param idName The <code>id</code> value of the element to find.
+		 *
+		 * @return The element whose id matches <code>idName</code>.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+		 *
+		 * @see FlowElement#id 
+		 */
+		
+		public function getElementByID(idName:String):IFlowElement
+		{
+			var rslt:IFlowElement;
+			applyFunctionToElements(function (elem:IFlowElement):Boolean{ if (elem.id == idName) { rslt = elem; return true; } return false; });
+			return rslt;
+		}
+
+		/** Returns all elements that have <code>styleName</code> set to <code>styleNameValue</code>.
+		 *
+		 * @param styleNameValue The name of the style for which to find elements that have it set.
+		 *
+		 * @return An array of the elements whose <code>styleName</code> value matches <code>styleNameValue</code>. For example,
+		 * all elements that have the style name "color".
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+		 *
+		 * @see FlowElement#styleName 
+		 */
+		public function getElementsByStyleName(styleNameValue:String):Array
+		{
+			var a:Array = new Array;
+			applyFunctionToElements(function (elem:FlowElement):Boolean{ if (elem.styleName == styleNameValue) a.push(elem); return false; });
+			return a;
+		}
+		
+		/** Returns all elements that have <code>typeName</code> set to <code>typeNameValue</code>.
+		 *
+		 * @param styleNameValue The name of the style for which to find elements that have it set.
+		 *
+		 * @return An array of the elements whose <code>typeName</code> value matches <code>typeNameValue</code>. For example,
+		 * all elements that have the type name "foo". A <code>typeName</code> is the TextFlow markup tag (such as the
+		 * <code>&lt;p&gt;</code> tag for ParagraphElements).
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * @see FlowElement#styleName 
+		 */
+		public function getElementsByTypeName(typeNameValue:String):Array
+		{
+			var a:Array = new Array;
+			applyFunctionToElements(function (elem:IFlowElement):Boolean{ if (elem.typeName == typeNameValue) a.push(elem); return false; });
+			return a;
+		}
+
+		/** @private */
+		override protected function get abstract():Boolean
+		{ return false; }
+		
+		/** @private */
+		public override function get defaultTypeName():String
+		{ return "TextFlow"; }
+		
+		/** @private */
+		public override function updateLengths(startIdx:int,len:int,updateLines:Boolean):void
+		{
+			if (normalizeStart != -1)
+			{
+				var newNormalizeStart:int = startIdx < normalizeStart ? startIdx : normalizeStart;
+
+				if (newNormalizeStart < normalizeStart)
+					normalizeLen += (normalizeStart-newNormalizeStart);
+				normalizeLen += len;
+				normalizeStart = newNormalizeStart;
+			}
+			else
+			{
+				normalizeStart = startIdx;
+				normalizeLen   = len;
+			}
+			// never go below zero
+			if (normalizeLen < 0)
+				normalizeLen = 0;
+			
+			// fix the lines
+			if (updateLines && _flowComposer)
+			{
+				_flowComposer.updateLengths(startIdx,len);
+				super.updateLengths(startIdx,len, false);
+			}
+			else
+				super.updateLengths(startIdx,len,updateLines);
+		}
+		
+		[RichTextContent]
+		/** @private NOTE: all FlowElement implementers and overrides of mxmlChildren must specify [RichTextContent] metadata */
+		public override function set mxmlChildren(array:Array):void
+		{
+			super.mxmlChildren = array; 
+			normalize();
+			applyWhiteSpaceCollapse(null);
+		} 
+		
+		/** @private Update any elements that have a delayed updated.  Normally used to stop foreignelements when they 
+		 * are either displayed the first time or removed from the stage
+		 */
+		public function applyUpdateElements(okToUnloadGraphics:Boolean):Boolean
+		{
+			if (_elemsToUpdate)
+			{
+				var hasController:Boolean = flowComposer && flowComposer.numControllers != 0;
+				for (var child:Object in _elemsToUpdate)
+					(child as FlowElement).applyDelayedElementUpdate(this,okToUnloadGraphics,hasController);
+				// if there is a controller then done with this list.  
+				// if no controller have to keep the list around because they may be in the list waiting for load on a future compose 
+				// the scenario that preserving the list fixes is a compose with no controllers followed by a compose with controllers
+				if (hasController)
+				{
+					_elemsToUpdate = null;
+					return true;
+				}
+			}
+			return false;
+		}
+		
+		/** @private */
+		public override function preCompose():void
+		{
+			// normalizes the flow
+			do 
+			{
+				normalize();
+			}	
+				// starts or stops any FEs that have been modified, removed or deleted
+			while (applyUpdateElements(true));
+			
+			// need to call normalize again in case any of the element updates have modified the hierarchy
+			// normalize();
+		}
+	
+		/**
+		 * Mark the a range of text as invalid - needs to be recomposed.
+		 * <p>The text classes are self damaging.  This is only used when modifying the container chain.</p>
+		 * <p>Warning: Plan to evaulate a way to hide this method totally.</p>
+		 * @param start		text index of first character to marked invalid
+		 * @param damageLen	number of characters to mark invalid
+		 * @param needNormalize optional parameter (true is default) - normalize should include this range.
+		 * @private
+		 */
+		public function damage(damageStart:int, damageLen:int, damageType:String, needNormalize:Boolean = true):void
+		{
+			// CONFIG::debug { assert(damageLen > 0,"must have at least 1 char in damageLen"); }
+				
+			if (needNormalize)
+			{
+				if (normalizeStart == -1)
+				{
+					normalizeStart = damageStart;
+					normalizeLen   = damageLen;
+				}
+				else
+				{
+					if (damageStart < normalizeStart)
+					{
+						var newNormalizeLen:uint = normalizeLen;
+						newNormalizeLen = normalizeStart+normalizeLen - damageStart;
+						if (damageLen > newNormalizeLen)
+							newNormalizeLen = damageLen;
+						normalizeStart = damageStart;
+						normalizeLen = newNormalizeLen;
+					}
+					else if ((normalizeStart+normalizeLen) > damageStart)
+					{
+						if (damageStart+damageLen > normalizeStart+normalizeLen)
+							normalizeLen = damageStart+damageLen-normalizeStart;
+					}
+					else
+						normalizeLen = damageStart+damageLen-normalizeStart;
+				}
+				
+				// clamp to textLength
+				CONFIG::debug { assert(normalizeStart <= textLength,"damage bad length"); }
+				if (normalizeStart+normalizeLen > textLength)
+					normalizeLen = textLength-normalizeStart;
+				// trace("damage damageStart:" + damageStart.toString() + " damageLen:" + damageLen.toString() + " textLength:" + this.textLength + " normalizeStart:" + normalizeStart.toString() + " normalizeLen:"  + normalizeLen.toString() );
+			}
+			
+			if (_flowComposer)
+				_flowComposer.damage(damageStart, damageLen, damageType);
+				
+			if (hasEventListener(DamageEvent.DAMAGE))
+				dispatchEvent(new DamageEvent(DamageEvent.DAMAGE,false,false,this,damageStart,damageLen));
+		}
+			
+		/**
+		 * Find the paragraph at the specified absolute position
+		 * @private
+		 */
+		public function findAbsoluteParagraph(pos:int):IParagraphElement
+		{
+			var elem:IFlowElement = findLeaf(pos);
+			return elem ? elem.getParagraph() : null;
+		}
+
+		/**
+		 * Find the IFlowGroupElement at the absolute position,
+		 * could be synonymous with the paragraph OR a subBlockElement
+		 * @private
+		 */
+		 public function findAbsoluteFlowGroupElement(pos:int):IFlowGroupElement
+		 {
+		 	var elem:IFlowElement = findLeaf(pos);
+		 	return elem.parent;
+		 }
+		
+		/** @private */
+		CONFIG::debug public override function debugCheckFlowElement(depth:int = 0, extraData:String = ""):int
+		{
+			// debugging function that asserts if the flow element tree is in an invalid state
+			
+			var rslt:int = super.debugCheckFlowElement(depth,extraData);
+			
+			// describe the lines
+			if (Debugging.verbose && flowComposer)
+			{
+				for ( var lineIdx:int = 0; lineIdx < flowComposer.numLines; lineIdx++)
+				{
+					var workLine:ITextFlowLine = flowComposer.getLineAt(lineIdx);
+					var containerIdx:int = flowComposer.getControllerIndex(workLine.controller);
+					// trace("line:",lineIdx,"controller:",containerIdx,workLine.toString());
+				}
+				
+				for (var idx:int = 0; idx < flowComposer.numControllers; idx++)
+				{
+					var controller:IContainerController = flowComposer.getControllerAt(idx);
+					trace("controller:",idx,Debugging.getIdentity(controller),controller.absoluteStart,controller.textLength,controller.compositionWidth,controller.compositionHeight,controller.getContentBounds());
+				}
+			}
+			
+			rslt += assert(parent == null, "TextFlow should not have a parent");
+			rslt += assert(parentRelativeStart == 0, "TextFlow start not zero");
+
+			return rslt;		
+		}
+		
+		/**
+		 * Check the internal consistency of the flow's FlowElement tree.
+		 * @private
+		 * Asserts if the data structures in the flow are invalid.
+		 */
+		CONFIG::debug public function debugCheckTextFlow(validateControllers:Boolean=true):int
+		{
+			if (!Debugging.debugCheckTextFlow)
+				return 0;
+			
+			var rslt:int = debugCheckFlowElement();
+			
+			if (_flowComposer && validateControllers)
+			{
+				var idx:int;
+				var endPrevController:int = 0;
+				for (idx = 0; idx < flowComposer.numControllers; idx++)
+				{
+					var controller:IContainerController = flowComposer.getControllerAt(idx);
+					if (Debugging.verbose)
+					{
+						trace("controller:",idx,"absoluteStart:",controller.absoluteStart,"textLength:",controller.textLength);
+					}
+					
+					rslt += assert(controller.absoluteStart == endPrevController, "controller has bad start");
+					rslt += assert(controller.textLength >= 0, "controller has bad textLength");
+					endPrevController = controller.absoluteStart+controller.textLength;
+					rslt += assert(endPrevController <= textLength, "textLength may not extend past end of root element!");
+				}
+			}
+			
+			rslt += flowComposer.debugCheckTextFlowLines(validateControllers);
+			return rslt;
+		}
+		
+		/**
+		 * Called after an import to validate that the entire flow textLength needs normalize.
+		 * @private
+		 */
+		 CONFIG::debug public function debugCheckNormalizeAll():void
+		{
+			assert(normalizeStart == 0,"normalizeStart: bad normailzeStart");
+			assert(normalizeLen == textLength,"debugCheckNormalizeAll: bad normalizeLen");
+		}
+		
+		/**
+		 * @copy org.apache.flex.events.IEventDispatcher#addEventListener()
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+ 		 */
+ 		 
+		public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false): void
+		{
+			if (!_eventDispatcher)
+				_eventDispatcher = new EventDispatcher();
+//TODO is the target necessary?
+//				_eventDispatcher = new EventDispatcher(this);
+			_eventDispatcher.addEventListener(type, listener, useCapture, priority, useWeakReference);
+		}
+
+		/**
+		 * @copy org.apache.flex.events.IEventDispatcher#dispatchEvent()
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+ 		 */
+ 		 
+		public function dispatchEvent(event:Event):Boolean
+		{
+			if (!_eventDispatcher)
+				return true;
+			return _eventDispatcher.dispatchEvent(event);
+		}
+
+		/**
+		 * @copy org.apache.flex.events.IEventDispatcher#hasEventListener()
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+ 		 */
+ 		 
+		public function hasEventListener(type:String):Boolean
+		{
+			if (!_eventDispatcher)
+				return false;
+			return _eventDispatcher.hasEventListener(type);
+		}
+		
+		/**
+		 * @copy org.apache.flex.events.IEventDispatcher#removeEventListener().
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+ 		 */						
+		public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false): void
+		{
+			if (!_eventDispatcher)
+				return;
+			
+			_eventDispatcher.removeEventListener(type, listener, useCapture);
+		}
+
+		/**
+		 * @copy org.apache.flex.events.IEventDispatcher#willTrigger()
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+ 		 */								
+		public function willTrigger(type:String):Boolean
+		{
+			if (!_eventDispatcher)
+				return false;
+			return _eventDispatcher.willTrigger(type);
+		}
+		
+		// elements which are images or blocks that *may* have children requiring activation or deactivation
+		private var _elemsToUpdate:ObjectMap;
+		
+		/** @private */
+		public function appendOneElementForUpdate(elem:IFlowElement):void
+		{
+			if (_elemsToUpdate == null)
+				_elemsToUpdate = new ObjectMap();
+			_elemsToUpdate[elem] = null;
+		}
+		
+		/** @private */
+		public function mustUseComposer():Boolean
+		{ 
+			if (_interactiveObjectCount != 0)
+				return true;
+
+			if (_elemsToUpdate == null)
+				return false; 
+
+			normalize();
+			
+			// anything that doesn't normalize completely forces use of the compser
+			var rslt:Boolean = false;
+			for (var elem:Object in _elemsToUpdate)
+			{
+				if ((elem as FlowElement).updateForMustUseComposer(this))
+					rslt = true;
+			}
+			
+			return rslt;
+		}
+		
+		/** @private */
+		public function processModelChanged(changeType:String, elem:Object, changeStart:int, changeLen:int, needNormalize:Boolean, bumpGeneration:Boolean):void
+		{
+			// track elements that may need an update before the next compose
+			if (elem is IFlowElement)
+				(elem as FlowElement).appendElementsForDelayedUpdate(this,changeType);
+			
+			if (bumpGeneration)
+				_generation = _nextGeneration++;
+			
+			if (changeLen > 0 || changeType == ModelChange.ELEMENT_ADDED)
+				damage(changeStart, changeLen, "invalid", needNormalize);
+			
+			if (formatResolver)
+			{
+				switch(changeType)
+				{
+					case ModelChange.ELEMENT_REMOVAL:
+					case ModelChange.ELEMENT_ADDED:
+					case ModelChange.STYLE_SELECTOR_CHANGED:
+						formatResolver.invalidate(elem);
+						elem.formatChanged(false);
+						break;
+				}
+			}
+		}
+		
+		/** 
+		* The generation number for this TextFlow object. The undo and redo operations use the generation number to validate that 
+		* it's legal to undo or redo an operation. The generation numbers must match. 
+		* 
+		* <p>Each model change increments <code>generation</code> so if the generation number changes, you know the 
+		* TextFlow model has changed.</p>
+		* 
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0
+	 	*/
+	 	
+		public function get generation():uint
+		{
+			return _generation;
+		}
+		
+		/** used to reset the number backwards after an undo or redo. @private */
+		public function setGeneration(num:uint):void
+		{
+			_generation = num;
+		}
+		
+		/** @private */
+		public function processAutoSizeImageLoaded(elem:InlineGraphicElement):void
+		{
+			if (flowComposer)
+				elem.appendElementsForDelayedUpdate(this,null);
+		}
+		
+		/**
+		 * Examine the damaged textLength of the TextFlow and put it in a normal form.  This includes adding spans to empty paragraph and
+		 * merging sibling spans that have the same attributes.
+		 * @private 
+		 */
+		public function normalize():void
+		{
+			//trace("NORMALIZE");
+			
+			if (normalizeStart != -1)
+			{
+				var normalizeEnd:int = normalizeStart + (normalizeLen==0?1:normalizeLen);
+				normalizeRange(normalizeStart==0?normalizeStart:normalizeStart-1,normalizeEnd);
+
+				normalizeStart = -1;
+				normalizeLen = 0;				
+			}
+			CONFIG::debug { debugCheckTextFlow(false); }
+		}
+		
+		private var _hostFormatHelper:HostFormatHelper;
+		
+		/** The TextLayoutFormat object for this TextFlow object. This enables several optimizations for reusing 
+		* host formats. For example;
+		*
+		* <listing>
+		* textFlowA.hostFormat = textFlowB.hostFormat
+		* </listing>
+		* 
+		* You must set format values before assigning the TextLayoutFormat object to <code>hostFormat</code>.
+		* For example, the following lines do <em>not</em> set the font size to 24 because
+		* the font size is set <em>after</em> the TextLayoutFormat object has been assigned to <code>hostFormat</code>.
+		*
+		* <listing>
+		* format = new TextLayoutFormat()
+		* textFlow.hostFormat = format
+		* format.fontSize = 24;
+		* </listing>
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0
+	 	*
+	 	* @see org.apache.flex.textLayout.formats.ITextLayoutFormat ITextLayoutFormat
+	 	*/
+	 	
+		public function get hostFormat():ITextLayoutFormat
+		{ return _hostFormatHelper ? _hostFormatHelper.format : null; }
+		public function set hostFormat(value:ITextLayoutFormat):void
+		{
+			if (value == null)
+				_hostFormatHelper = null;
+			else
+			{
+				if (_hostFormatHelper == null)
+					_hostFormatHelper = new HostFormatHelper();
+				_hostFormatHelper.format = value;
+			}
+			formatChanged();
+		}
+		
+		/** @private */
+		public override function doComputeTextLayoutFormat():TextLayoutFormat
+		{
+			var parentPrototype:TextLayoutFormat = _hostFormatHelper ? _hostFormatHelper.getComputedPrototypeFormat() : null;
+			return CreateTLFUtil.createTLF(formatForCascade,parentPrototype);
+		}
+		
+		
+		/** Use the formatResolver to get the character "before style" of an Object.
+		 * @param elem is either a FlowElement or a ContainerController(doesn't happen for characterformat)
+		 * @return any styled CharacterFormat for that element
+		 * @private
+		 */
+		public function getTextLayoutFormatStyle(elem:Object):TextLayoutFormat
+		{
+			if (_formatResolver == null)
+				return null;
+			var rslt:ITextLayoutFormat = _formatResolver.resolveFormat(elem);
+			if (rslt == null)
+				return null;
+			// optimization!
+			var tlfvh:TextLayoutFormat = rslt as TextLayoutFormat;
+			return tlfvh ? tlfvh : new TextLayoutFormat(rslt);
+		}
+		
+		/** Use the formatResolver to get the character "after style" of an Object.
+		 * @param elem is either a FlowElement or a ContainerController(doesn't happen for characterformat)
+		 * @return any styled CharacterFormat for that element
+		 * @private
+		 */
+		public function getExplicitStyle(elem:Object):TextLayoutFormat
+		{
+			if (_formatResolver == null)
+				return null;
+			if(_formatResolver is IExplicitFormatResolver)
+			{
+				var rslt:ITextLayoutFormat = (_formatResolver as IExplicitFormatResolver).resolveExplicitFormat(elem);
+				if (rslt == null)
+					return null;
+				
+				var tlfvh:TextLayoutFormat = rslt as TextLayoutFormat;
+				return tlfvh ? tlfvh : new TextLayoutFormat(rslt);
+			}
+			return null;
+		}
+		
+		/** @private This API peeks at the background manager.  Use when removing data as things go out of view or are recomposed.  */
+		public function get backgroundManager():IBackgroundManager
+		{ return _backgroundManager; }
+		
+		/** @private */
+		public function clearBackgroundManager():void
+		{
+			//store cache for being deleted IBackgroundManager
+			if(_backgroundManager)
+			{
+				if(!BackgroundHelper.BACKGROUND_MANAGER_CACHE)
+					BackgroundHelper.BACKGROUND_MANAGER_CACHE = new ObjectMap();
+				BackgroundHelper.BACKGROUND_MANAGER_CACHE[this] = _backgroundManager.getShapeRectArray().concat();
+			}
+			//end
+			_backgroundManager = null; 
+		}
+		
+		/** @private.  Returns the existing backgroundManager - creating it if it doesn't exist.  Use when adding backgrounds to draw.  */
+		public function getBackgroundManager():IBackgroundManager
+		{
+			if (!_backgroundManager)
+				_backgroundManager = flowComposer.createBackgroundManager();
+			return _backgroundManager;
+		}
+				
+		/** A callback function for resolving element styles. You can use this to provide styling using CSS or 
+		 * named styles, for example. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 *
+	 	 * @see IFormatResolver
+		 */
+		 
+		public function get formatResolver(): IFormatResolver
+		{ 
+			return _formatResolver; 
+		}
+		public function set formatResolver(val:IFormatResolver):void
+		{
+			if (_formatResolver != val)
+			{
+				if (_formatResolver)
+					_formatResolver.invalidateAll(this);
+				_formatResolver = val;
+				if (_formatResolver)
+					_formatResolver.invalidateAll(this);
+					
+				formatChanged(true);
+			}
+		}
+		
+		/** Invalidates all formatting information for the TextFlow, forcing it to be recomputed.
+		 * Call this method when styles have changed.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+	 	 * @see IFormatResolver#invalidateAll()
+		 */
+		 
+		public function invalidateAllFormats():void
+		{
+			if (_formatResolver)
+				_formatResolver.invalidateAll(this);
+			formatChanged(true);
+		}
+
+		/** The parent element is the element that the TextFlow is nested inside (such as a TableCellElement).
+		 * This property is for support of nested TextFlows to handle things like selection and editing.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 */		
+		public function get parentElement():IFlowGroupElement
+		{
+			return _parentElement;
+		}
+
+		public function set parentElement(value:IFlowGroupElement):void
+		{
+			_parentElement = value;
+		}
+		
+		public function nestedInTable():Boolean{
+			return parentElement && parentElement is ITableCellElement;
+		}
+
+
+	} // end TextFlow class
+}
+
+import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+import org.apache.flex.textLayout.formats.TextLayoutFormat;
+import org.apache.flex.textLayout.utils.CreateTLFUtil;
+
+
+
+
+/** @private.  Expected usage is that all values are set. */
+class HostFormatHelper
+{
+	private var _format:ITextLayoutFormat;
+	private var _computedPrototypeFormat:TextLayoutFormat;
+	
+	public function get format():ITextLayoutFormat
+	{ return _format; }
+	public function set format(value:ITextLayoutFormat):void
+	{ _format = value;  _computedPrototypeFormat = null; }
+
+	public function getComputedPrototypeFormat():TextLayoutFormat
+	{
+		if (_computedPrototypeFormat == null)
+		{
+			var useFormat:ITextLayoutFormat;
+			if (_format is TextLayoutFormat || _format is TextLayoutFormat)
+				useFormat = _format;
+			else
+				useFormat = new TextLayoutFormat(_format);
+			_computedPrototypeFormat = CreateTLFUtil.createTLF(useFormat,null);
+		}
+		return _computedPrototypeFormat;
+	}		
+		
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TextRange.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TextRange.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TextRange.as
new file mode 100644
index 0000000..e354116
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TextRange.as
@@ -0,0 +1,171 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+
+	
+
+
+	/**
+	 * A read only class that describes a range of contiguous text. Such a range occurs when you select a
+	 * section of text. The range consists of the anchor point of the selection, <code>anchorPosition</code>,
+	 * and the point that is to be modified by actions, <code>activePosition</code>.  As block selections are 
+	 * modified and extended <code>anchorPosition</code> remains fixed and <code>activePosition</code> is modified.  
+	 * The anchor position may be placed in the text before or after the active position.
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+ 	 * @langversion 3.0
+	 *
+	 * @see org.apache.flex.textLayout.elements.TextFlow TextFlow
+	 * @see org.apache.flex.textLayout.edit.SelectionState SelectionState
+	 */
+	public class TextRange
+	{
+		/** The TextFlow of the selection.
+ 	 	 */
+		private var _textFlow:ITextFlow;
+		
+		// current range of selection
+		/** Anchor point of the current selection, as an absolute position in the TextFlow. */
+		private var _anchorPosition:int;
+		/** Active end of the current selection, as an absolute position in the TextFlow. */
+		private var _activePosition:int;
+		
+		private function clampToRange(index:int):int
+		{
+			if (index < 0)
+				return 0;
+			if (index > _textFlow.textLength)
+				return _textFlow.textLength;
+			return index;
+		}
+		
+		/** Constructor - creates a new TextRange instance.  A TextRange can be (-1,-1), indicating no range, or a pair of 
+		* values from 0 to <code>TextFlow.textLength</code>.
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 * @param	root	the TextFlow associated with the selection.
+		 * @param anchorIndex	the index position of the anchor in the selection. The first position in the text is position 0.
+		 * @param activeIndex	the index position of the active location in the selection. The first position in the text is position 0. 
+		 *
+		 * @see FlowElement#textLength
+		 */		
+		public function TextRange(root:ITextFlow,anchorIndex:int,activeIndex:int)
+		{
+			_textFlow = root;
+			
+			if (anchorIndex != -1 || activeIndex != -1)
+			{
+				anchorIndex = clampToRange(anchorIndex);
+				activeIndex = clampToRange(activeIndex);
+			}
+			
+			_anchorPosition = anchorIndex;
+			_activePosition = activeIndex;
+		}
+		
+		/** Update the range with new anchor or active position values.
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 *  @param newAnchorPosition	the anchor index of the selection.
+		 *  @param newActivePosition	the active index of the selection.
+		 *  @return true if selection is changed.
+		 */
+		public function updateRange(newAnchorPosition:int,newActivePosition:int):Boolean
+		{
+			if (newAnchorPosition != -1 || newActivePosition != -1)
+			{
+				newAnchorPosition = clampToRange(newAnchorPosition);
+				newActivePosition = clampToRange(newActivePosition);
+			}
+			
+			if (_anchorPosition != newAnchorPosition || _activePosition != newActivePosition)
+			{
+				_anchorPosition = newAnchorPosition;
+				_activePosition = newActivePosition;
+				return true;
+			}
+			return false;
+		}
+		
+		/** Returns the TextFlow associated with the selection.
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */						
+		public function get textFlow():ITextFlow
+		{ return _textFlow; }
+		public function set textFlow(value:ITextFlow):void
+		{ _textFlow = value; }
+		
+		/** Anchor position of the selection, as an absolute position in the TextFlow.
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */								
+		public function get anchorPosition():int
+		{ return _anchorPosition; }
+		public function set anchorPosition(value:int):void
+		{ _anchorPosition = value; }
+		
+		/** Active position of the selection, as an absolute position in the TextFlow.
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */										
+		public function get activePosition():int
+		{ return _activePosition; }
+		public function set activePosition(value:int):void
+		{ _activePosition = value; }
+		
+		/** Start of the selection, as an absolute position in the TextFlow.
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */										
+		public function get absoluteStart():int
+		{ return _activePosition < _anchorPosition ? _activePosition : _anchorPosition; }
+		public function set absoluteStart(value:int):void
+		{
+			if (_activePosition < _anchorPosition)
+				_activePosition = value;
+			else
+				_anchorPosition = value;
+		}
+		
+		/** End of the selection, as an absolute position in the TextFlow.
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */								
+		public function get absoluteEnd():int
+		{ return _activePosition > _anchorPosition ? _activePosition : _anchorPosition; }
+		public function set absoluteEnd(value:int):void
+		{
+			if (_activePosition > _anchorPosition)
+				_activePosition = value;
+			else
+				_anchorPosition = value;
+		}		
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/utils/BackgroundHelper.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/utils/BackgroundHelper.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/utils/BackgroundHelper.as
new file mode 100644
index 0000000..aa51fbe
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/utils/BackgroundHelper.as
@@ -0,0 +1,26 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements.utils
+{
+	import org.apache.flex.utils.ObjectMap;
+	public class BackgroundHelper
+	{
+		public static var BACKGROUND_MANAGER_CACHE:ObjectMap = null;
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/utils/GeometricElementUtils.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/utils/GeometricElementUtils.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/utils/GeometricElementUtils.as
new file mode 100644
index 0000000..b31a6c0
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/utils/GeometricElementUtils.as
@@ -0,0 +1,287 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements.utils
+{
+	import org.apache.flex.geom.Rectangle;
+	import org.apache.flex.text.engine.ElementFormat;
+	import org.apache.flex.text.engine.FontDescription;
+	import org.apache.flex.text.engine.FontMetrics;
+	import org.apache.flex.text.engine.ITextLine;
+	import org.apache.flex.text.engine.TextBaseline;
+	import org.apache.flex.text.engine.TextRotation;
+	import org.apache.flex.text.engine.TypographicCase;
+	import org.apache.flex.textLayout.compose.ISWFContext;
+	import org.apache.flex.textLayout.debug.Debugging;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.formats.BaselineShift;
+	import org.apache.flex.textLayout.formats.ColorName;
+	import org.apache.flex.textLayout.formats.FormatValue;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.formats.TLFTypographicCase;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+	import org.apache.flex.textLayout.utils.LocaleUtil;
+	public class GeometricElementUtils
+	{
+		/** @private */
+		public static function resolveDomBaseline(computedFormat:ITextLayoutFormat, para:IParagraphElement):String
+		{
+			CONFIG::debug { assert(computedFormat != null,"bad call to resolveDomBaseline"); }
+			
+			var domBase:String = computedFormat.dominantBaseline;
+			if(domBase == FormatValue.AUTO)
+			{
+				if(computedFormat.textRotation == TextRotation.ROTATE_270 /*|| 
+					this.computedFormat.blockProgression == BlockProgression.RL*/)
+					domBase = TextBaseline.IDEOGRAPHIC_CENTER;
+				else
+				{
+					//otherwise, avoid using the locale of the element and use the paragraph's locale
+					if(para != null)
+						domBase = para.getEffectiveDominantBaseline();
+					else
+						domBase = LocaleUtil.dominantBaseline(computedFormat.locale);
+				}
+			}
+			
+			return domBase;
+		}
+		/** @private 
+		 * Get the "inline box" for an element with the specified computed format as defined by the CSS visual formatting model (http://www.w3.org/TR/CSS2/visuren.html)
+		 * For a span, leading is applied equally above and below the em-box such that the box's height equals lineHeight. 
+		 * Alignment relative to the baseline (using baselineShift, dominantBaseline, alignmentBaseline) is taken into account.
+		 * @param	textLine		The containing text line
+		 * @param	para			The containing para. Only used for resolving AUTO dominantBaseline value. 
+		 * 							May be null, in which case the AUTO dominantBaseline value is resolved based on other attributes (such as the element's computed locale). 	
+		 * @return 	A rectangle representing the inline box. Top and Bottom are relative to the line's Roman baseline. Left and Right are ignored.
+		 */
+		static public function getCSSInlineBoxHelper(computedFormat:ITextLayoutFormat, metrics:FontMetrics, textLine:ITextLine, para:IParagraphElement=null):Rectangle
+		{
+			var emBox:Rectangle 	= metrics.emBox;
+			
+			var ascent:Number 		= -emBox.top;
+			var descent:Number 		= emBox.bottom;
+			var textHeight:Number	= emBox.height;
+			
+			var fontSize:Number 	= computedFormat.fontSize;
+			var lineHeight:Number 	= TextLayoutFormat.lineHeightProperty.computeActualPropertyValue(computedFormat.lineHeight, fontSize);
+			var halfLeading:Number	= (lineHeight - textHeight) / 2;
+			
+			// Apply half leading equally above and below the em box
+			emBox.top -= halfLeading;
+			emBox.bottom += halfLeading;
+			
+			// Account for the effect of dominantBaseline
+			var computedDominantBaseline:String = resolveDomBaseline(computedFormat, para);
+			switch (computedDominantBaseline)
+			{
+				case TextBaseline.ASCENT:
+				case TextBaseline.IDEOGRAPHIC_TOP:
+					emBox.offset(0, ascent); 
+					break;
+				
+				case TextBaseline.IDEOGRAPHIC_CENTER:
+					emBox.offset(0, ascent - textHeight/2);
+					break;
+				
+				case TextBaseline.ROMAN:
+					break;
+				
+				case TextBaseline.DESCENT:
+				case TextBaseline.IDEOGRAPHIC_BOTTOM:
+					emBox.offset(0, -descent);
+			}
+			
+			// Account for the effect of alignmentBaseline
+			var computedAlignmentBaseline:String = (computedFormat.alignmentBaseline == TextBaseline.USE_DOMINANT_BASELINE ? computedDominantBaseline : computedFormat.alignmentBaseline);
+			emBox.offset(0, textLine.getBaselinePosition(computedAlignmentBaseline));
+			
+			// Account for the effect of baselineShift
+			var baselineShift:Number;
+			if (computedFormat.baselineShift == BaselineShift.SUPERSCRIPT)
+				baselineShift = metrics.superscriptOffset * fontSize;
+			else if (computedFormat.baselineShift == BaselineShift.SUBSCRIPT)
+				baselineShift = metrics.subscriptOffset * fontSize;
+			else
+				baselineShift = -computedFormat.baselineShift;
+			
+			emBox.offset(0, baselineShift);
+			
+			return emBox;
+		}
+				/** @private */
+		static public function computeElementFormatHelper(computedFormat:ITextLayoutFormat, para:IParagraphElement, swfContext:ISWFContext):ElementFormat
+		{
+			// compute the cascaded elementFormat
+			var format:ElementFormat = new ElementFormat();
+			CONFIG::debug { Debugging.traceFTECall(format,null,"new ElementFormat()"); }
+			
+			format.alignmentBaseline	= computedFormat.alignmentBaseline;
+			format.alpha				= Number(computedFormat.textAlpha);
+			format.breakOpportunity		= computedFormat.breakOpportunity;
+			format.color				= (computedFormat.color is String) ? translateColor(computedFormat.color) : uint(computedFormat.color);
+			format.dominantBaseline		= GeometricElementUtils.resolveDomBaseline(computedFormat, para);
+			
+			format.digitCase			= computedFormat.digitCase;
+			format.digitWidth			= computedFormat.digitWidth;
+			format.ligatureLevel		= computedFormat.ligatureLevel;
+			format.fontSize				= Number(computedFormat.fontSize);
+			format.kerning				= computedFormat.kerning;
+			format.locale				= computedFormat.locale;
+			format.trackingLeft			= TextLayoutFormat.trackingLeftProperty.computeActualPropertyValue(computedFormat.trackingLeft,format.fontSize);
+			format.trackingRight		= TextLayoutFormat.trackingRightProperty.computeActualPropertyValue(computedFormat.trackingRight,format.fontSize);
+			format.textRotation			= computedFormat.textRotation;
+			format.baselineShift 		= -(TextLayoutFormat.baselineShiftProperty.computeActualPropertyValue(computedFormat.baselineShift, format.fontSize));
+			switch (computedFormat.typographicCase)
+			{
+				case TLFTypographicCase.LOWERCASE_TO_SMALL_CAPS:
+					format.typographicCase = TypographicCase.CAPS_AND_SMALL_CAPS;
+					break;
+				case TLFTypographicCase.CAPS_TO_SMALL_CAPS:
+					format.typographicCase = TypographicCase.SMALL_CAPS;
+					break;
+				/* Others map directly so handle it in the default case */
+				default:
+					format.typographicCase = computedFormat.typographicCase;
+					break;
+			}
+			
+			CONFIG::debug { Debugging.traceFTEAssign(format,"alignmentBaseline",format.alignmentBaseline); }
+			CONFIG::debug { Debugging.traceFTEAssign(format,"alpha",format.alpha); }
+			CONFIG::debug { Debugging.traceFTEAssign(format,"breakOpportunity",format.breakOpportunity); }
+			CONFIG::debug { Debugging.traceFTEAssign(format,"color",format.color); }
+			CONFIG::debug { Debugging.traceFTEAssign(format,"dominantBaseline",format.dominantBaseline); }
+			CONFIG::debug { Debugging.traceFTEAssign(format,"digitCase",format.digitCase); }
+			CONFIG::debug { Debugging.traceFTEAssign(format,"digitWidth",format.digitWidth); }
+			CONFIG::debug { Debugging.traceFTEAssign(format,"ligatureLevel",format.ligatureLevel); }
+			CONFIG::debug { Debugging.traceFTEAssign(format,"fontSize",format.fontSize); }
+			CONFIG::debug { Debugging.traceFTEAssign(format,"kerning",format.kerning); }
+			CONFIG::debug { Debugging.traceFTEAssign(format,"locale",format.locale); }
+			CONFIG::debug { Debugging.traceFTEAssign(format,"trackingLeft",format.trackingLeft); }
+			CONFIG::debug { Debugging.traceFTEAssign(format,"trackingRight",format.trackingRight); }
+			CONFIG::debug { Debugging.traceFTEAssign(format,"typographicCase",format.typographicCase); }
+			CONFIG::debug { Debugging.traceFTEAssign(format,"textRotation",format.textRotation); }
+			CONFIG::debug { Debugging.traceFTEAssign(format,"baselineShift",format.baselineShift);	 }	
+			
+			// set the fontDesription in the cascadedFormat
+			var fd:FontDescription = new FontDescription();
+			fd.fontStyle = computedFormat.fontStyle;
+			fd.fontName = computedFormat.fontFamily;
+//			fd.renderingMode = computedFormat.renderingMode;
+//			fd.cffHinting = computedFormat.cffHinting;
+			
+			// the fontLookup may be override by the resolveFontLookupFunction
+//			if (GlobalSettings.resolveFontLookupFunction == null)
+//				fd.fontLookup = computedFormat.fontLookup;
+//			else
+//			{
+//				fd.fontLookup = GlobalSettings.resolveFontLookupFunction(swfContext ? FlowComposerBase.computeBaseSWFContext(swfContext) : null, computedFormat);
+//			}
+			// and now give the fontMapper a shot at rewriting the FontDescription
+//			var fontMapper:Function = GlobalSettings.fontMapperFunction;
+//			if (fontMapper != null)
+//				fontMapper(fd);
+			CONFIG::debug { Debugging.traceFTECall(fd,null,"new FontDescription()"); }
+//			CONFIG::debug { Debugging.traceFTEAssign(fd,"fontWeight",fd.fontWeight);	 }
+			CONFIG::debug { Debugging.traceFTEAssign(fd,"fontStyle",fd.fontStyle);	 }
+			CONFIG::debug { Debugging.traceFTEAssign(fd,"fontName",fd.fontName);	 }
+//			CONFIG::debug { Debugging.traceFTEAssign(fd,"renderingMode",fd.renderingMode);	 }
+//			CONFIG::debug { Debugging.traceFTEAssign(fd,"cffHinting",fd.cffHinting);	 }
+//			CONFIG::debug { Debugging.traceFTEAssign(fd,"fontLookup",fd.fontLookup);	 }
+			
+			format.fontDescription = fd;
+			CONFIG::debug { Debugging.traceFTEAssign(format,"fontDescription",fd); }
+			
+			//Moved code here because original code tried to access fontMetrics prior to setting the elementFormat.
+			//Since getFontMetrics returns the value of blockElement.elementFormat.getFontMetrics(), we cannot call this
+			//until after the element has been set. Watson 1820571 - gak 06.11.08
+			// Adjust format for superscript/subscript
+			if (computedFormat.baselineShift == BaselineShift.SUPERSCRIPT || 
+				computedFormat.baselineShift == BaselineShift.SUBSCRIPT)
+			{
+				var fontMetrics:FontMetrics;
+				if (swfContext)
+					fontMetrics = swfContext.callInContext(format.getFontMetrics,format,null,true);
+				else	
+					fontMetrics = format.getFontMetrics();	
+				if (computedFormat.baselineShift == BaselineShift.SUPERSCRIPT)
+				{
+					format.baselineShift = (fontMetrics.superscriptOffset * format.fontSize);
+					format.fontSize = fontMetrics.superscriptScale * format.fontSize;
+				}
+				else // it's subscript
+				{
+					format.baselineShift = (fontMetrics.subscriptOffset * format.fontSize);
+					format.fontSize = fontMetrics.subscriptScale * format.fontSize;
+				}
+				CONFIG::debug { Debugging.traceFTEAssign(format,"baselineShift",format.baselineShift); }
+				CONFIG::debug { Debugging.traceFTEAssign(format,"fontSize",format.fontSize); }
+			}			
+			return format;
+		}
+				// mjzhang : fix for bug# 2758977 <s:p color="red"/> throws out of range error - can you do color lookup like Flex SDK
+		/** @private */
+		static private function translateColor(color:String):Number
+		{
+			var ret:Number = NaN;
+			switch ( color.toLowerCase() )
+			{
+				case ColorName.BLACK:
+					ret = 0x000000; break;
+				case ColorName.BLUE:
+					ret = 0x0000FF; break;
+				case ColorName.GREEN:
+					ret = 0x008000; break;
+				case ColorName.GRAY: 
+					ret = 0x808080; break;
+				case ColorName.SILVER: 
+					ret = 0xC0C0C0; break;
+				case ColorName.LIME: 
+					ret = 0x00FF00; break;
+				case ColorName.OLIVE: 
+					ret = 0x808000; break;
+				case ColorName.WHITE: 
+					ret = 0xFFFFFF; break;
+				case ColorName.YELLOW: 
+					ret = 0xFFFF00; break;
+				case ColorName.MAROON: 
+					ret = 0x800000; break;
+				case ColorName.NAVY: 
+					ret = 0x000080; break;
+				case ColorName.RED: 
+					ret = 0xFF0000; break;
+				case ColorName.PURPLE: 
+					ret = 0x800080; break;
+				case ColorName.TEAL: 
+					ret = 0x008080; break;
+				case ColorName.FUCHSIA: 
+					ret = 0xFF00FF; break;
+				case ColorName.AQUA: 
+					ret = 0x00FFFF; break;
+				case ColorName.MAGENTA: 
+					ret = 0xFF00FF; break;
+				case ColorName.CYAN: 
+					ret = 0x00FFFF; break;
+				default : break;
+			}
+			
+			return ret;
+		}		
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/utils/ParagraphHelper.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/utils/ParagraphHelper.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/utils/ParagraphHelper.as
new file mode 100644
index 0000000..14e33fd
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/utils/ParagraphHelper.as
@@ -0,0 +1,30 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements.utils
+{
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.ParagraphElement;
+	public class ParagraphHelper
+	{
+				public static function getParagraph():IParagraphElement
+		{
+			return new ParagraphElement();
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/ActivateEvent.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/ActivateEvent.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/ActivateEvent.as
new file mode 100644
index 0000000..e1bdca4
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/ActivateEvent.as
@@ -0,0 +1,26 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.events {
+	public class ActivateEvent {
+
+		public static const ACTIVATE:String = "activate";
+		public static const DEACTIVATE:String = "deactivate";
+		
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/CompositionCompleteEvent.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/CompositionCompleteEvent.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/CompositionCompleteEvent.as
new file mode 100644
index 0000000..fdc776a
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/CompositionCompleteEvent.as
@@ -0,0 +1,126 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.events
+{
+	import org.apache.flex.events.IFlexJSEvent;
+	import org.apache.flex.events.Event;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	
+	/** 
+	 * A ITextFlow instance dispatches this event after a compose operation completes. 
+	 * Each text container has two states: composition and display. This event notifies
+	 * you when the composition phase has ended. This provides an opportunity to make any
+	 * necessary and appropriate changes to the container before you display the text. 
+	 * For example, you can use this event to add highlighting of certain words or
+	 * characters in the text flow before the text is displayed.
+	 * 
+	 * <p>The three main methods that dispatch this event are <code>compose()</code>, 
+	 * <code>updateToController()</code>, and <code>updateAllControllers()</code>.
+	 * All three of these methods are in the StandardFlowComposer class.</p>
+	 *
+	 * <p><strong>Note: </strong>If the event is dispatched by the
+	 * <code>updateAllControllers()</code> method, do not call 
+	 * <code>updateAllControllers()</code> again in your event handler function.
+	 * Such a call would be a recursive call because the <code>updateAllControllers()</code> 
+	 * method executes both the composition and display steps. The <code>updateAllControllers()</code>
+	 * dispatches this event after composition completes, but before the display step executes.
+	 * The same reasoning applies to the <code>updateToController()</code> method.
+	 * </p>
+	 *
+	 * @see org.apache.flex.textLayout.elements.ITextFlow 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	public class CompositionCompleteEvent extends Event
+	{
+	    /** 
+	     * Defines the value of the <code>type</code> property of a <code>compositionComplete</code> event object 
+	     * @playerversion Flash 10
+	     * @playerversion AIR 1.5
+	     * @langversion 3.0 
+	     */
+	    public static const COMPOSITION_COMPLETE:String = "compositionComplete";
+		
+		
+		//temporary removal of params until Flex removes references to old CompositionCompletionEvent
+		private var _compositionStart:int;
+		private var _compositionLength:int;
+		private var _textFlow:ITextFlow;	
+		
+		/** Constructor
+		 * @param type event type - use the static property COMPOSITION_COMPLETE.
+		 * @param bubbles Indicates whether an event is a bubbling event. This event does not bubble.
+		 * @param cancelable Indicates whether the behavior associated with the event can be prevented.
+		 * This event cannot be cancelled.
+		 * @param textFlow The ITextFlow which was composed
+		 * @param compositionStart start of composition, in terms of an index into the text flow.
+		 * @param compositionLength length number of characters composed
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 **/
+		public function CompositionCompleteEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, textFlow:ITextFlow =  null, compositionStart:int=0, compositionLength:int=0)
+		{
+			_compositionStart = compositionStart;
+			_compositionLength = compositionLength;
+			_textFlow = textFlow;
+			super(type, bubbles, cancelable);
+		}
+		
+      	/** @private */
+		override public function cloneEvent():IFlexJSEvent
+		{
+			return new CompositionCompleteEvent(type, bubbles, cancelable, textFlow, compositionStart, compositionLength);
+		}
+		
+		/** 
+		 * The start location of the text range affected by the composition, expressed as an index into the text flow.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 		 
+		 */
+		public function get compositionStart():int
+		{ return _compositionStart; }		
+		public function set compositionStart(value:int):void
+		{ _compositionStart = value; }		
+		
+		/** 
+		 * The number of characters composed.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public function get compositionLength():int
+		{ return _compositionLength; }
+		public function set compositionLength(value:int):void
+		{ _compositionLength = value; }
+		
+		/**
+		 * ITextFlow on which composition has been completed. 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get textFlow():ITextFlow
+		{ return _textFlow; }
+		public function set textFlow(value:ITextFlow):void
+		{ _textFlow = value; }
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/ContextMenuEvent.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/ContextMenuEvent.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/ContextMenuEvent.as
new file mode 100644
index 0000000..c2505b4
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/ContextMenuEvent.as
@@ -0,0 +1,31 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.events {
+	import org.apache.flex.events.Event;
+
+	public class ContextMenuEvent extends Event {
+		
+		public static const MENU_ITEM_SELECT:String = "menuItemSelect";
+		public static const MENU_SELECT:String = "menuSelect";
+
+		public function ContextMenuEvent(type : String, bubbles : Boolean = false, cancelable : Boolean = false) {
+			super(type, bubbles, cancelable);
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/DamageEvent.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/DamageEvent.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/DamageEvent.as
new file mode 100644
index 0000000..06b6e97
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/DamageEvent.as
@@ -0,0 +1,93 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.events {
+	import org.apache.flex.events.IFlexJSEvent;
+	import org.apache.flex.events.Event;
+	import org.apache.flex.textLayout.elements.TextFlow;
+	
+	/** 
+	 * A TextFlow instance dispatches this each time it is marked as damaged.  Damage can be caused by changes to the model or changes to the layout.
+	 * 
+	 * @see org.apache.flex.textLayout.elements.TextFlow 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	public class DamageEvent extends Event
+	{
+		/** Event type for DamageEvent */
+	    public static const DAMAGE:String = "damage";
+
+		private var _textFlow:TextFlow;
+		private var _damageAbsoluteStart:int;
+		private var _damageLength:int;	
+		
+		/** Constructor
+		 * @param damageAbsoluteStart text index of the start of the damage
+		 * @param damageLength length of text that was damaged
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function DamageEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, textFlow:TextFlow =  null, damageAbsoluteStart:int = 0, damageLength:int = 0)
+		{
+			_textFlow = textFlow;
+			_damageAbsoluteStart = damageAbsoluteStart;
+			_damageLength = damageLength;
+			super(type, bubbles, cancelable);
+		}
+		
+      	/** @private */
+		override public function cloneEvent():IFlexJSEvent
+		{
+			return new DamageEvent(type, bubbles, cancelable, _textFlow, _damageAbsoluteStart, _damageLength);
+		}
+		
+		/**
+		 * TextFlow owning the damage 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+
+		public function get textFlow():TextFlow
+		{ return _textFlow; }
+		
+		/**
+		 * Absolute start of the damage 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+
+		public function get damageAbsoluteStart():int
+		{ return _damageAbsoluteStart; }
+		
+		/**
+		 * Length of the damage 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+
+		public function get damageLength():int
+		{ return _damageLength; }
+	}
+}
+

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/EditEvent.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/EditEvent.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/EditEvent.as
new file mode 100644
index 0000000..a75fca1
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/EditEvent.as
@@ -0,0 +1,26 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.events {
+	public class EditEvent {
+		public static const CLEAR:String = "clear";
+		public static const COPY:String = "copy";
+		public static const CUT:String = "cut";
+		public static const PASTE:String = "paste";
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/FlowElementEventDispatcher.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/FlowElementEventDispatcher.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/FlowElementEventDispatcher.as
new file mode 100644
index 0000000..b298750
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/FlowElementEventDispatcher.as
@@ -0,0 +1,93 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.events
+{
+	import org.apache.flex.events.EventDispatcher;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	
+	// [ExcludeClass]
+	/** The ElementEventDispatcher class adds a simple tracking counter for event listeners
+	 * to the core EventDispatcher class. This variable is tlf_internal, so internal code
+	 * can check quickly if an EventDispatcher has any listeners attached at all.
+	 */
+	
+	public class FlowElementEventDispatcher extends EventDispatcher
+	{
+		/** @private
+		 * Internal code can check this counter to quickly determine if there are any
+		 * listeners attached to this dispatcher at all.
+		 */
+		public var _listenerCount:int = 0;
+		
+		/** @private
+		 * The element used by this dispatcher
+		 */
+		public var _element:IFlowElement;
+		
+		/** @private 
+		 * The constructor is the same as the supeclass constructor.
+		 */
+		public function FlowElementEventDispatcher(element:IFlowElement)
+		{
+			_element = element;
+			super(null);
+		}
+		
+		/** @private 
+		 * The addEventListener() method increments a counter.
+		 */
+		public override function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
+		{
+			super.addEventListener(type, listener, useCapture, priority, useWeakReference);
+			_listenerCount++;
+			if (_listenerCount == 1)
+			{
+				var tf:ITextFlow = _element.getTextFlow();
+				if (tf)
+					tf.incInteractiveObjectCount();
+				
+				var pg:IParagraphElement = _element.getParagraph() ;
+				if (pg)
+					pg.incInteractiveChildrenCount() ;
+			}
+			_element.modelChanged(ModelChange.ELEMENT_MODIFIED,_element,0,_element.textLength);
+		}
+		
+		/** @private 
+		 * The removeEventListener() method decrements a counter.
+		 */
+		public override function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
+		{
+			super.removeEventListener(type, listener, useCapture);
+			_listenerCount--;			
+			if (_listenerCount == 0)
+			{
+				var tf:ITextFlow = _element.getTextFlow();
+				if (tf)
+					tf.decInteractiveObjectCount();
+				var pg:IParagraphElement = _element.getParagraph() ;
+				if (pg)
+					pg.decInteractiveChildrenCount() ;
+			}
+			_element.modelChanged(ModelChange.ELEMENT_MODIFIED,_element,0,_element.textLength);
+		}
+	}
+}


[36/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/TextFlowLine.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/TextFlowLine.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/TextFlowLine.as
new file mode 100644
index 0000000..6f417c1
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/TextFlowLine.as
@@ -0,0 +1,2552 @@
+// //////////////////////////////////////////////////////////////////////////////
+//
+// 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
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// //////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.compose
+{
+	import org.apache.flex.core.IParentIUIBase;
+	import org.apache.flex.core.UIBase;
+	import org.apache.flex.geom.Point;
+	import org.apache.flex.geom.Rectangle;
+	import org.apache.flex.graphics.ICompoundGraphic;
+	import org.apache.flex.graphics.PathBuilder;
+	import org.apache.flex.graphics.SolidColor;
+	import org.apache.flex.text.engine.Constants;
+	import org.apache.flex.text.engine.ElementFormat;
+	import org.apache.flex.text.engine.FontMetrics;
+	import org.apache.flex.text.engine.ITextBlock;
+	import org.apache.flex.text.engine.ITextLine;
+	import org.apache.flex.text.engine.TextRotation;
+	import org.apache.flex.textLayout.compose.utils.AdornmentUtils;
+	import org.apache.flex.textLayout.compose.utils.TextLineUtil;
+	import org.apache.flex.textLayout.container.IContainerController;
+	import org.apache.flex.textLayout.debug.Debugging;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.dummy.BoundsUtil;
+	import org.apache.flex.textLayout.edit.ISelectionManager;
+	import org.apache.flex.textLayout.edit.SelectionFormat;
+	import org.apache.flex.textLayout.elements.ElementConstants;
+	import org.apache.flex.textLayout.elements.IBackgroundManager;
+	import org.apache.flex.textLayout.elements.IContainerFormattedElement;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	import org.apache.flex.textLayout.elements.IFlowLeafElement;
+	import org.apache.flex.textLayout.elements.IInlineGraphicElement;
+	import org.apache.flex.textLayout.elements.IListItemElement;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.ISubParagraphGroupElementBase;
+	import org.apache.flex.textLayout.elements.ITableLeafElement;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.textLayout.elements.LeadingUtils;
+	import org.apache.flex.textLayout.elements.utils.GeometricElementUtils;
+	import org.apache.flex.textLayout.formats.BlockProgression;
+	import org.apache.flex.textLayout.formats.Direction;
+	import org.apache.flex.textLayout.formats.Float;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.formats.JustificationRule;
+	import org.apache.flex.textLayout.formats.LeadingModel;
+	import org.apache.flex.textLayout.formats.LineBreak;
+	import org.apache.flex.textLayout.formats.ListStylePosition;
+	import org.apache.flex.textLayout.formats.TextAlign;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+	import org.apache.flex.textLayout.utils.CharacterUtil;
+	import org.apache.flex.textLayout.utils.Twips;
+	import org.apache.flex.utils.ObjectMap;
+	import org.apache.flex.utils.PointUtils;
+
+	/** 
+	 * The TextFlowLine class represents a single line of text in a text flow.
+	 * 
+	 * <p>Use this class to access information about how a line of text has been composed: its position, 
+	 * height, width, and so on. When the text flow (TextFlow) is modified, the lines immediately before and at the  
+	 * site of the modification are marked as invalid because they need to be recomposed. Lines after
+	 * the site of the modification might not be damaged immediately, but they might be regenerated once the
+	 * text is composed. You can access a TextFlowLine that has been damaged, but any values you access
+	 * reflect the old state of the TextFlow. When the TextFlow is recomposed, it generates new lines and you can 
+	 * get the new line for a given position by calling <code>TextFlow.flowComposer.findLineAtPosition()</code>.</p>
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	public class TextFlowLine implements ITextFlowLine
+	{
+		// TODO temp setter
+		public function set height(value:Number):void
+		{
+		}
+
+		/** @private - the selection block cache */
+		static private var _selectionBlockCache:ObjectMap = new ObjectMap(true);
+
+		public function get composable():Boolean
+		{
+			return true;
+		}
+
+		private var _absoluteStart:int;		// text-offset of start of line - from beginning of the TextFlow
+		private var _textLength:int;		// number of chars to next line (incl trailing spaces, etc.)
+		private var _x:Number = 0;			// left edge of line; left as Number because it is user-settable
+		private var _y:Number = 0;			// top edge of line; left as Number because it is user-settable
+		private var _height:Number = 0;				// y advance
+		private var _outerTargetWidth:Number = 0;	// width line is composed to, excluding indents
+		private var _boundsLeftTW:int = 2;			// text line bounds: logical left
+		private var _boundsRightTW:int = 1;			// text line bounds: logical right (if left > right, then it is not set)
+		private var _para:IParagraphElement;				// owning paragraph
+		private var _controller:IContainerController;	// what frame the line was composed into
+		private var _columnIndex:int;					// column number in the container
+		private var _adornCount:int = 0;
+		static private const VALIDITY_MASK:uint = 7;		// 3 bits
+		static private const ALIGNMENT_SHIFT:uint = 3;
+		static private const ALIGNMENT_MASK:uint = 24; 		// 2 bits
+		static private const NUMBERLINE_MASK:uint = 32;		// 1 bit
+		static private const GRAPHICELEMENT_MASK:uint = 64;	// 1 bit
+		private var _flags:uint;
+		// added to support TextFlowLine when ITextLine not available
+		protected var _ascent:Number;
+		protected var _descent:Number;
+		private var _targetWidth:Number;
+		protected var _lineOffset:Number;
+		private var _lineExtent:Number;	// content bounds logical width for the line
+		private var _accumulatedLineExtent:Number;
+		private var _accumulatedMinimumStart:Number;
+		private var _numberLinePosition:int;
+
+		/** Constructor - creates a new TextFlowLine instance. 
+		 *  <p><strong>Note</strong>: No client should call this. It's exposed for writing your own composer.</p>
+		 *
+		 * @param textLine The ITextLine display object to use for this line.
+		 * @param paragraph The paragraph (ParagraphElement) in which to place the line.
+		 * @param outerTargetWidth The width the line is composed to, excluding indents.
+		 * @param lineOffset The line's offset in pixels from the appropriate container inset (as dictated by paragraph direction and container block progression), prior to alignment of lines in the paragraph. 
+		 * @param absoluteStart	The character position in the text flow at which the line begins.
+		 * @param numChars	The number of characters in the line.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * @see org.apache.flex.text.engine.ITextLine
+		 * @see org.apache.flex.textLayout.elements.ParagraphElement
+		 * @see #absoluteStart
+		 */
+		public function TextFlowLine(textLine:ITextLine, paragraph:IParagraphElement, outerTargetWidth:Number = 0, lineOffset:Number = 0, absoluteStart:int = 0, numChars:int = 0)
+		{
+			initialize(paragraph, outerTargetWidth, lineOffset, absoluteStart, numChars, textLine);
+		}
+
+		/** @private */
+		public function initialize(paragraph:IParagraphElement, outerTargetWidth:Number = 0, lineOffset:Number = 0, absoluteStart:int = 0, numChars:int = 0, textLine:ITextLine = null):void
+		{
+			_para = paragraph;
+			_outerTargetWidth = outerTargetWidth;
+			_absoluteStart = absoluteStart;
+			_textLength = numChars;
+
+			_adornCount = 0;
+			_lineExtent = 0;
+			_accumulatedLineExtent = 0;
+			_accumulatedMinimumStart = Constants.MAX_LINE_WIDTH;
+
+			_flags = 0;
+			_controller = null;
+
+			if (textLine)
+			{
+				textLine.userData = this;
+				_targetWidth = textLine.specifiedWidth;
+				_ascent = textLine.ascent;
+				_descent = textLine.descent;
+				// the docs say this is true
+				CONFIG::debug
+				{
+					assert(textLine.textHeight == textLine.ascent + textLine.descent, "bad textheight"); }
+				_lineOffset = lineOffset;
+				setValidity(textLine.validity);
+				CONFIG::debug
+				{
+					assert(textLine.validity == "valid", "Initializing TextFlowLine to invalid ITextLine"); }
+				setFlag(textLine.hasGraphicElement ? GRAPHICELEMENT_MASK : 0, GRAPHICELEMENT_MASK);
+			}
+			else
+				setValidity("invalid");
+		}
+
+		private function setFlag(value:uint, mask:uint):void
+		{
+			CONFIG::debug
+			{
+				assert((value | mask) == mask, "TFL:setFlag bad value"); }
+			_flags = (_flags & ~mask) | value;
+		}
+
+		private function getFlag(mask:uint):uint
+		{
+			return _flags & mask;
+		}
+
+		/** @private */
+		public function get heightTW():int
+		{
+			return Twips.to(_height);
+		}
+
+		/** @private */
+		public function get outerTargetWidthTW():int
+		{
+			return Twips.to(_outerTargetWidth);
+		}
+
+		/** @private */
+		public function get ascentTW():int
+		{
+			return Twips.to(_ascent);
+		}
+
+		/** @private */
+		public function get targetWidthTW():int
+		{
+			return Twips.to(_targetWidth);
+		}
+
+		/** @private */
+		public function get textHeightTW():int
+		{
+			return Twips.to(textHeight);
+		}
+
+		/** @private */
+		public function get lineOffsetTW():int
+		{
+			return Twips.to(_lineOffset);
+		}
+
+		/** @private */
+		public function get lineExtentTW():int
+		{
+			return Twips.to(_lineExtent);
+		}
+
+		/** @private */
+		public function get hasGraphicElement():Boolean
+		{
+			return getFlag(GRAPHICELEMENT_MASK) != 0;
+		}
+
+		/** @private */
+		public function get hasNumberLine():Boolean
+		{
+			return getFlag(NUMBERLINE_MASK) != 0;
+		}
+
+		/** @private */
+		public function get numberLinePosition():Number
+		{
+			return Twips.from(_numberLinePosition);
+		}
+
+		/** @private */
+		public function set numberLinePosition(position:Number):void
+		{
+			CONFIG::debug
+			{
+				assert(Twips.from(Twips.to(position)) == position, "Bad numberLinePosition"); }
+			_numberLinePosition = Twips.to(position);
+		}
+
+		/**
+		 * The height of the text line, which is equal to <code>ascent</code> plus <code>descent</code>. The 
+		 * value is calculated based on the difference between the baselines that bound the line, either 
+		 * ideographic top and bottom or ascent and descent depending on whether the baseline at y=0 
+		 * is ideographic (for example, TextBaseline.IDEOGRAPHIC_TOP) or not. 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * @see org.apache.flex.text.engine.TextBaseline TextBaseline
+		 */
+		public function get textHeight():Number
+		{
+			return _ascent + _descent;
+		}
+
+		/** 
+		 * The horizontal position of the line relative to its container, expressed as the offset in pixels from the 
+		 * left of the container.
+		 * <p><strong>Note: </strong>Although this property is technically <code>read-write</code>, 
+		 * you should treat it as <code>read-only</code>. The setter exists only to satisfy the
+		 * requirements of the IVerticalJustificationLine interface that defines both a getter and setter for this property.
+		 * Use of the setter, though possible, will lead to unpredictable results.
+		 * </p>
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * @see #y
+		 */
+		public function get x():Number
+		{
+			return _x;
+		}
+
+		/** 
+		 * This comment is ignored, but the setter should not be used and exists only to satisfy
+		 * the IVerticalJustificationLine interface.
+		 * @see org.apache.flex.textLayout.compose.IVerticalJustificationLine 
+		 * @private 
+		 */
+		public function set x(lineX:Number):void
+		{
+			_x = lineX;
+			// invalidate bounds
+			_boundsLeftTW = 2;
+			_boundsRightTW = 1;
+		}
+
+		/** @private */
+		public function get xTW():int
+		{
+			return Twips.to(_x);
+		}
+
+		/** 
+		 * The vertical position of the line relative to its container, expressed as the offset in pixels from the top 
+		 * of the container.
+		 * <p><strong>Note: </strong>Although this property is technically <code>read-write</code>, 
+		 * you should treat it as <code>read-only</code>. The setter exists only to satisfy the
+		 * requirements of the IVerticalJustificationLine interface that defines both a getter and setter for this property.
+		 * Use of the setter, though possible, will lead to unpredictable results.
+		 * </p>
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 * @see #x
+		 */
+		public function get y():Number
+		{
+			return _y;
+		}
+
+		/** @private */
+		public function get yTW():int
+		{
+			return Twips.to(_y);
+		}
+
+		/** This comment is ignored, but the setter should not be used and exists only to satisfy
+		 * the IVerticalJustificationLine interface.
+		 * @see org.apache.flex.textLayout.compose.IVerticalJustificationLine
+		 * @private
+		 */
+		public function set y(lineY:Number):void
+		{
+			_y = lineY;
+			// invalidate bounds
+			_boundsLeftTW = 2;
+			_boundsRightTW = 1;
+		}
+
+		/** @private */
+		public function setXYAndHeight(lineX:Number, lineY:Number, lineHeight:Number):void
+		{
+			_x = lineX;
+			_y = lineY;
+			_height = lineHeight;
+			// invalidate bounds
+			_boundsLeftTW = 2;
+			_boundsRightTW = 1;
+		}
+
+		/** 
+		 * One of the values from TextFlowLineLocation for specifying a line's location within a paragraph.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * @see org.apache.flex.textLayout.elements.ParagraphElement
+		 * @see TextFlowLineLocation
+		 */
+		public function get location():int
+		{
+			if (_para)
+			{
+				var lineStart:int;
+
+				// Harbs 8-31-14 added handling of multiple textBlocks might need more work to handle end?
+				var textLine:ITextLine = peekTextLine();
+				if (textLine)
+					lineStart = _absoluteStart - _para.getTextBlockAbsoluteStart(textLine.textBlock);
+				else
+					lineStart = _absoluteStart - _para.getAbsoluteStart();
+				// Initialize settings for location
+				if (lineStart == 0)		// we're at the start of the paragraph
+					return _textLength == _para.textLength ? TextFlowLineLocation.ONLY : TextFlowLineLocation.FIRST;
+				if (lineStart + textLength == _para.textLength)	// we're at the end of the para
+					return TextFlowLineLocation.LAST;
+			}
+			return TextFlowLineLocation.MIDDLE;
+		}
+
+		/** 
+		 * The controller (ContainerController object) for the container in which the line has been placed.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 * @see org.apache.flex.textLayout.container.ContainerController 
+		 */
+		public function get controller():IContainerController
+		{
+			return _controller;
+		}
+
+		/** The number of the column in which the line has been placed, with the first column being 0.
+		 *		
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get columnIndex():int
+		{
+			return _columnIndex;
+		}
+
+		/**
+		 *  @private 
+		 * @flexjsignorecoercion org.apache.flex.textLayout.container.ContainerController
+		 */
+		public function setController(cont:IContainerController, colNumber:int):void
+		{
+			_controller = cont;
+			_columnIndex = colNumber;
+		}
+
+		/** The height of the line in pixels.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 */
+		public function get height():Number
+		{
+			return _height;
+		}
+
+		/** 
+		 * @copy org.apache.flex.text.engine.ITextLine#ascent
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get ascent():Number
+		{
+			return _ascent;
+		}
+
+		/** 
+		 * @copy org.apache.flex.text.engine.ITextLine#descent
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get descent():Number
+		{
+			return _descent;
+		}
+
+		/** 
+		 * The line's offset in pixels from the appropriate container inset (as dictated by paragraph direction and container block progression), 
+		 * prior to alignment of lines in the paragraph.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get lineOffset():Number
+		{
+			return _lineOffset;
+		}
+
+		/** 
+		 * The paragraph (ParagraphElement) in which the line resides.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 * @see org.apache.flex.textLayout.elements.ParagraphElement
+		 */
+		public function get paragraph():IParagraphElement
+		{
+			return _para;
+		}
+
+		/** 
+		 * The location of the line as an absolute character position in the TextFlow object.
+		 * 
+		 * @return 	the character position in the text flow at which the line begins.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * @see org.apache.flex.textLayout.elements.TextFlow
+		 */
+		public function get absoluteStart():int
+		{
+			return _absoluteStart;
+		}
+
+		/** @private */
+		public function setAbsoluteStart(val:int):void
+		{
+			_absoluteStart = val;
+		}
+
+		/** 
+		 * The number of characters to the next line, including trailing spaces. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get textLength():int
+		{
+			return _textLength;
+		}
+
+		/** @private */
+		public function setTextLength(val:int):void
+		{
+			_textLength = val;
+			// assert(_validity == "invalid", "not already damaged");
+			damage("invalid");
+		}
+
+		/** 
+		 * The amount of space to leave before the line.
+		 * <p>If the line is the first line of a paragraph that has a space-before applied, the line will have
+		 * a <code>spaceBefore</code> value. If the line comes at the top of a column, <code>spaceBefore</code> is ignored. 
+		 * Otherwise, the line follows another line in the column, and it is positioned vertically to insure that there is
+		 * at least this much space left between this line and the last line of the preceding paragraph.</p> 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * @see org.apache.flex.textLayout.formats.TextLayoutFormat#paragraphSpaceBefore TextLayoutFormat.paragraphSpaceBefore
+		 */
+		public function get spaceBefore():Number
+		{
+			return (this.location & TextFlowLineLocation.FIRST) ? _para.computedFormat.paragraphSpaceBefore : 0;
+		}
+
+		/** 
+		 * The amount of space to leave after the line.
+		 * <p>If the line is the last line of a paragraph that has a space-after, the line will have
+		 * a <code>spaceAfter</code> value. If the line comes at the bottom of a column, then the <code>spaceAfter</code>
+		 * is ignored. Otherwise, the line comes before another line in the column, and the following line must be positioned vertically to
+		 * insure that there is at least this much space left between this last line of the paragraph and the first
+		 * line of the following paragraph.</p> 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * @see org.apache.flex.textLayout.formats.TextLayoutFormat#paragraphSpaceAfter TextLayoutFormat.paragraphSpaceAfter
+		 */
+		public function get spaceAfter():Number
+		{
+			return ((this.location & TextFlowLineLocation.LAST) ? _para.computedFormat.paragraphSpaceAfter : 0);
+		}
+
+		/** @private 
+		 * Target width not including paragraph indents */
+		public function get outerTargetWidth():Number
+		{
+			return _outerTargetWidth;
+		}
+
+		/** @private */
+		public function set outerTargetWidth(val:Number):void
+		{
+			_outerTargetWidth = val;
+		}
+
+		/** @private  
+		 * Amount of space used to break the line
+		 * <p>The target width is the amount of space allowed for the line, including the space required for indents.</p>
+		 */
+		public function get targetWidth():Number
+		{
+			return _targetWidth;
+		}
+
+		/** 
+		 * Returns the bounds of the line as a rectangle.
+		 *
+		 * @return a rectangle that represents the boundaries of the line.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function getBounds():Rectangle
+		{
+			var textLine:ITextLine = getTextLine(true);
+			if (!textLine)
+				return new Rectangle();
+
+			// TODO: just use the textLine.x and textLine.y - after all getTextLine now sets them.
+			// not going to change this right now though
+			var bp:String = paragraph.getAncestorWithContainer().computedFormat.blockProgression;
+			var shapeX:Number = this.x;
+			var shapeY:Number = createShapeY(bp);
+			if (bp == BlockProgression.TB)
+				shapeY += descent - textLine.height;
+			return new Rectangle(shapeX, shapeY, textLine.width, textLine.height);
+		}
+
+		private const _validities:Array = ["invalid", "possiblyInvalid", "static", "valid", FlowDamageType.GEOMETRY];
+
+		private function setValidity(value:String):void
+		{
+			CONFIG::debug
+			{
+				assert(_validities.indexOf(value) != -1, "Bad alignment passed to TextFlowLine"); }
+			setFlag(_validities.indexOf(value), VALIDITY_MASK);
+		}
+
+		/** The validity of the line. 
+		 * <p>A line can be invalid if the text, the attributes applied to it, or the controller settings have
+		 * changed since the line was created. An invalid line can still be displayed, and you can use it, but the values
+		 * used will be the values at the time it was created. The line returned by <code>getTextLine()</code> also will be in an
+		 * invalid state. </p>
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * @see #getTextLine()
+		 * @see org.apache.flex.text.engine.ITextLine#validity ITextLine.validity
+		 * @see FlowDamageType#GEOMETRY
+		 */
+		public function get validity():String
+		{
+			return _validities[getFlag(VALIDITY_MASK)];
+		}
+
+		/** 
+		 * The width of the line if it was not justified. For unjustified text, this value is the same as <code>textLength</code>. 
+		 * For justified text, this value is what the length would have been without justification, and <code>textLength</code> 
+		 * represents the actual line width. For example, when the following String is justified and assigned a width of 500, it 
+		 * has an actual width of 500 but an unjustified width of 268.9921875. 
+		 *
+		 * @internal TBD: add graphic of justified line
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get unjustifiedTextWidth():Number
+		{
+			// hack - outerTargetWidth holds value from the factory
+			var textLine:ITextLine = getTextLine(true);
+			return textLine.unjustifiedTextWidth + (_outerTargetWidth - targetWidth);
+		}
+
+		/** @private */
+		public function get lineExtent():Number
+		{
+			return _lineExtent;
+		}
+
+		/** @private */
+		public function set lineExtent(value:Number):void
+		{
+			_lineExtent = value;
+		}
+
+		/** @private */
+		public function get accumulatedLineExtent():Number
+		{
+			return _accumulatedLineExtent;
+		}
+
+		/** @private */
+		public function set accumulatedLineExtent(value:Number):void
+		{
+			_accumulatedLineExtent = value;
+		}
+
+		/** @private */
+		public function get accumulatedMinimumStart():Number
+		{
+			return _accumulatedMinimumStart;
+		}
+
+		/** @private */
+		public function set accumulatedMinimumStart(value:Number):void
+		{
+			_accumulatedMinimumStart = value;
+		}
+
+		static private const _alignments:Array = [TextAlign.LEFT, TextAlign.CENTER, TextAlign.RIGHT];
+
+		/** @private */
+		public function get alignment():String
+		{
+			return _alignments[getFlag(ALIGNMENT_MASK) >> ALIGNMENT_SHIFT];
+		}
+
+		/** @private */
+		public function set alignment(value:String):void
+		{
+			CONFIG::debug
+			{
+				assert(_alignments.indexOf(value) != -1, "Bad alignment passed to TextFlowLine"); }
+			setFlag(_alignments.indexOf(value) << ALIGNMENT_SHIFT, ALIGNMENT_MASK);
+		}
+
+		/** @private 
+		 * True if the line needs composing. */
+		public function isDamaged():Boolean
+		{
+			return (validity != "valid");
+		}
+
+		/** @private
+		 * Mark the line as valid */
+		public function clearDamage():void
+		{
+			CONFIG::debug
+			{
+				assert(validity == FlowDamageType.GEOMETRY, "can't clear damage other than geometry"); }
+			setValidity("valid");
+		}
+
+		/** @private
+		 * Mark the line as damaged */
+		public function damage(damageType:String):void
+		{
+			// trace("TextFlowLine.damage ", this.start.toString(), this.textLength.toString());
+			var current:String = validity;
+			if (current == damageType || current == "invalid")
+				return;	// totally damaged
+			setValidity(damageType);
+		}
+
+		/** @private */
+		/**
+		 * Check if the line is visible by comparing a set rectangle to the supplied
+		 * rectangle (all values in Twips).
+		 * -1 BEFORE visible bounds
+		 * 0 Visible
+		 * 1 AFTER visible bounds
+		 * @private
+		 */
+		public function testLineVisible(wmode:String, x:int, y:int, w:int, h:int):int
+		{
+			CONFIG::debug
+			{
+				assert(hasLineBounds(), "Bad call to TextFlowLine.isLineVisible"); }
+
+			if (wmode == BlockProgression.RL)
+			{
+				if (_boundsRightTW >= x && _boundsLeftTW < x + w)
+					return 0;
+				return x < _boundsRightTW ? 1 : -1;
+			}
+
+			if (_boundsRightTW >= y && _boundsLeftTW < y + h)
+				return 0;
+			return y < _boundsRightTW ? -1 : 1;
+		}
+
+		public function oldTestLineVisible(wmode:String, x:int, y:int, w:int, h:int):Boolean
+		{
+			CONFIG::debug
+			{
+				assert(hasLineBounds(), "Bad call to TextFlowLine.isLineVisible"); }
+
+			if (wmode == BlockProgression.RL)
+				return _boundsRightTW >= x && _boundsLeftTW < x + w;
+
+			return _boundsRightTW >= y && _boundsLeftTW < y + h;
+		}
+
+		/** @private
+		 * Set the text line bounds rectangle, all values in Twips.
+		 * If left > right, the rectangle is considered not to be set.
+		 * @private
+		 */
+		public function cacheLineBounds(wmode:String, bndsx:Number, bndsy:Number, bndsw:Number, bndsh:Number):void
+		{
+			if (wmode == BlockProgression.RL)
+			{
+				_boundsLeftTW = Twips.to(bndsx);
+				_boundsRightTW = Twips.to(bndsx + bndsw);
+			}
+			else
+			{
+				_boundsLeftTW = Twips.to(bndsy);
+				_boundsRightTW = Twips.to(bndsy + bndsh);
+			}
+		}
+
+		/** @private
+		 * Check if the text line bounds are set. If the stored left
+		 * value is > the right value, then the rectangle is not set.
+		 * @private
+		 */
+		public function hasLineBounds():Boolean
+		{
+			return (_boundsLeftTW <= _boundsRightTW);
+		}
+		/** @private */
+		CONFIG::debug
+		public function toString():String
+		{
+			return "x:" + x + " y: " + y + " absoluteStart:" + absoluteStart + " textLength:" + textLength + " location: " + location + " validity: " + validity;
+		}
+
+		/** 
+		 * Indicates whether the <code>org.apache.flex.text.engine.ITextLine</code> object for this TextFlowLine exists.  
+		 * The value is <code>true</code> if the ITextLine object has <em>not</em> been garbage collected and 
+		 * <code>false</code> if it has been.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * @see org.apache.flex.text.engine.ITextLine ITextLine
+		 */
+		public function get textLineExists():Boolean
+		{
+			return peekTextLine() != null;
+		}
+
+		/** @private
+		 * Returns the associated ITextLine if there is one. Finds it by looking up in the ITextBlock.
+		 */
+		public function peekTextLine():ITextLine
+		{
+			var textLine:ITextLine;
+
+			if (!paragraph)
+				return null;
+
+			// Look it up in the textBlock
+			var textBlocks:Vector.<ITextBlock> = paragraph.getTextBlocks();
+			for each (var textBlock:ITextBlock in textBlocks)
+			{
+				for (textLine = textBlock.firstLine; textLine; textLine = textLine.nextLine)
+				{
+					if (textLine.userData == this) // found it
+						return textLine;
+				}
+			}
+			return null;
+		}
+
+		/** 
+		 * Returns the <code>org.apache.flex.text.engine.ITextLine</code> object for this line, which might be recreated 
+		 * if it does not exist due to garbage collection. Set <code>forceValid</code> to <code>true</code>
+		 * to cause the ITextLine to be regenerated. Returns null if the ITextLine cannot be recreated.
+		 *.
+		 * @param forceValid	if true, the ITextLine is regenerated, if it exists but is invalid.
+		 *
+		 * @return object for this line or <code>null</code> if the ITextLine object cannot be 
+		 * recreated.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * @see org.apache.flex.text.engine.ITextLine ITextLine
+		 */
+		public function getTextLine(forceValid:Boolean = false):ITextLine
+		{
+			var textLine:ITextLine = peekTextLine();
+			if (textLine && textLine.validity == FlowDamageType.GEOMETRY)
+				createShape(paragraph.getTextFlow().computedFormat.blockProgression, textLine);
+			else if (!textLine || (textLine.validity == "invalid" && forceValid))
+			{
+				/*	if (!textLine)
+				{
+				trace("text line does not exist: regenerating");
+				textLine = peekTextLine();
+				}
+				else
+				trace("textline is invalid: regenerated"); */
+				if (isDamaged() && validity != FlowDamageType.GEOMETRY)
+					return null;
+
+				textLine = getTextLineInternal();
+			}
+
+			return textLine;
+		}
+
+		private function getTextLineInternal():ITextLine
+		{
+			// 8-31-14 Do we need to change this to handle multiple textBlocks?
+			// Look it up in the textBlock
+			var paraAbsStart:int = paragraph.getAbsoluteStart();
+
+			// If we haven't found it yet, we need to regenerate it.
+			// Regenerate the whole paragraph at once, up to the current position.
+			var textBlock:ITextBlock = paragraph.getTextBlockAtPosition(absoluteStart - paraAbsStart);
+			var currentLine:ITextLine = textBlock.firstLine;
+			var flowComposer:IFlowComposer = paragraph.getTextFlow().flowComposer;
+			var lineIndex:int = flowComposer.findLineIndexAtPosition(paraAbsStart);
+			var previousLine:ITextLine = null;
+			var textLine:ITextLine;
+			do
+			{
+				var line:ITextFlowLine = flowComposer.getLineAt(lineIndex);
+				CONFIG::debug
+				{
+					assert(line && line.paragraph == paragraph, "Expecting line in same paragraph"); }
+				if (currentLine != null && currentLine.validity == "valid" && (line != this || currentLine.userData == line))
+				{
+					textLine = currentLine;
+					currentLine = currentLine.nextLine;
+				}
+				else if (!line.composable)// TextFlowTableBlock
+				{
+					textLine = null;
+					currentLine = null;
+				}
+				else
+				{
+					textLine = line.recreateTextLine(textBlock, previousLine);
+					currentLine = null;
+				}
+				previousLine = textLine;
+				++lineIndex;
+			} while (line != this);
+
+			// Put it in the cache, so we can find it there next time
+			// textLineCache[this] = textLine;
+
+			return textLine;
+		}
+
+		/**
+		 *  @private Regenerate the ITextLine -- called when textLine has been gc'ed 
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.IListItemElement
+		 */
+		public function recreateTextLine(textBlock:ITextBlock, previousLine:ITextLine):ITextLine
+		{
+			var textLine:ITextLine;
+
+			var textFlow:ITextFlow = _para.getTextFlow();
+			var bp:String = textFlow.computedFormat.blockProgression;
+			var flowComposer:IFlowComposer = textFlow.flowComposer;
+			var swfContext:ISWFContext = flowComposer.swfContext ? flowComposer.swfContext : SWFContext.globalSWFContext;
+
+			var numberLine:ITextLine;
+			var effLineOffset:Number = _lineOffset;
+			if (hasNumberLine)
+			{
+				var boxStartTotalIndent:Number = this._lineOffset - _para.computedFormat.textIndent;
+				numberLine = flowComposer.createNumberLine(_para.getParentByType("ListItemElement") as IListItemElement, _para, flowComposer.swfContext, boxStartTotalIndent);
+				if (numberLine)
+				{
+					if (TextLineUtil.getNumberLineListStylePosition(numberLine) == ListStylePosition.INSIDE)
+						effLineOffset += TextLineUtil.getNumberLineInsideLineWidth(numberLine);
+				}
+			}
+
+			// trace("Recreating line from", absoluteStart, "to", absoluteStart + textLength);
+			textLine = TextLineRecycler.getLineForReuse();
+			if (textLine)
+			{
+				CONFIG::debug
+				{
+					assert(textFlow.backgroundManager == null || textFlow.backgroundManager.getEntry(textLine) === undefined, "Bad ITextLine in recycler cache"); }
+				textLine = swfContext.callInContext(textBlock["recreateTextLine"], textBlock, [textLine, previousLine, _targetWidth, effLineOffset, true]);
+			}
+			else
+				textLine = swfContext.callInContext(textBlock.createTextLine, textBlock, [previousLine, _targetWidth, effLineOffset, true]);
+
+			if (textLine == null)
+				return null;
+
+			textLine.x = this.x;
+			CONFIG::debug
+			{
+				Debugging.traceFTEAssign(textLine, "x", this.x);  }
+			textLine.y = createShapeY(bp);
+			CONFIG::debug
+			{
+				Debugging.traceFTEAssign(textLine, "y", createShapeY(bp));  }
+			textLine.doubleClickEnabled = true;
+			textLine.userData = this;
+
+			// Regenerate adornments (e.g., underline & strikethru)
+			if (_adornCount > 0)
+			{
+				var paraStart:int = _para.getAbsoluteStart();
+				var elem:IFlowLeafElement = _para.findLeaf(this.absoluteStart - paraStart);
+				var elemStart:int = elem.getAbsoluteStart();
+
+				CONFIG::debug
+				{
+					assert(textLine.userData == this, "textLine doesn't point back to TextFlowLine"); }
+				if (numberLine)
+				{
+					var listItemElement:IListItemElement = _para.getParentByType("ListItemElement") as IListItemElement;
+					TextLineUtil.initializeNumberLinePosition(numberLine, listItemElement, _para, textLine.textWidth);
+				}
+
+				createAdornments(_para.getAncestorWithContainer().computedFormat.blockProgression, elem, elemStart, textLine, numberLine);
+
+				if (numberLine && TextLineUtil.getNumberLineListStylePosition(numberLine) == ListStylePosition.OUTSIDE)
+				{
+					if (bp == BlockProgression.TB)
+						numberLine.x = this.numberLinePosition;
+					else
+						numberLine.y = this.numberLinePosition;
+				}
+			}
+
+			return textLine;
+		}
+
+		/** @private */
+		public function createShape(bp:String, textLine:ITextLine):void
+		{
+			var newX:Number = this.x;
+			// if (int(newX*20) != int(textLine.x*20))
+			{
+				textLine.x = newX;
+				CONFIG::debug
+				{
+					Debugging.traceFTEAssign(textLine, "x", newX);  }
+			}
+			var newY:Number = createShapeY(bp);
+			// if (int(newY*20) != int(textLine.y*20))
+			{
+				textLine.y = newY;
+				CONFIG::debug
+				{
+					Debugging.traceFTEAssign(textLine, "y", newY);  }
+			}
+		}
+
+		private function createShapeY(bp:String):Number
+		{
+			return bp == BlockProgression.RL ? y : y + _ascent;
+		}
+
+		/** @private 
+		 * Scan through the format runs within the line, and draw any underline or strikethrough that might need it
+		 */
+		public function createAdornments(blockProgression:String, elem:IFlowLeafElement, elemStart:int, textLine:ITextLine, numberLine:ITextLine):void
+		{
+			CONFIG::debug
+			{
+				assert(elemStart == elem.getAbsoluteStart(), "bad elemStart passed to createAdornments"); }
+			var endPos:int = _absoluteStart + _textLength;
+
+			CONFIG::debug
+			{
+				assert(textLine.validity == "valid", "createAdornments: bad ITextLine validity"); }
+			/*if (textLine.validity != "valid")
+			{
+			// This can happen if we are scrolling through text and lines have been released, 
+			// then scrolled back into view before they're gc'ed. Then we have an invalid line in the TextFlowLine
+			// cache, so we create a valid text line to calculate where the adornment shapes should go. The 
+			// actual shapes will be added to the invalid (original) ITextLine in the TextFlowLine cache.
+			textLine = getTextLineInternal();
+			}*/
+
+			// init adornments back to 0 - may be redoing the line in a new position
+			// This can happen if there was damage earlier in the paragraph, so that the ITextLine was damaged (because all lines in block were damaged)
+			// but the TextFlowLine is still considered OK (didn't cause a line break change).
+			// CONFIG::debug { assert(_adornCount == 0 && _hasNumberLine == false,"createAdornments: adornments applied twice?"); }
+			_adornCount = 0;
+
+			if (numberLine)
+			{
+				_adornCount++;
+				setFlag(NUMBERLINE_MASK, NUMBERLINE_MASK);
+				textLine.addElement(numberLine);
+				CONFIG::debug
+				{
+					Debugging.traceFTECall(null, textLine, "addChildNumberLine", numberLine); }
+
+				// handle background on the numberLine
+				if (TextLineUtil.getNumberLineBackground(numberLine) != null)
+				{
+					var bgm:IBackgroundManager = elem.getTextFlow().getBackgroundManager();
+					if (bgm)
+						bgm.addNumberLine(textLine, numberLine);
+				}
+			}
+			else
+				setFlag(0, NUMBERLINE_MASK);
+
+			for (;;)
+			{
+				_adornCount += AdornmentUtils.updateAdornments(elem, textLine, blockProgression);
+
+				var elemFormat:ITextLayoutFormat = elem.format;
+				var imeStatus:* = elemFormat ? elemFormat.getStyle("imeStatus") : undefined;
+				if (imeStatus)
+				{
+					AdornmentUtils.updateIMEAdornments(elem, textLine, blockProgression, imeStatus as String);
+				}
+				elemStart += elem.textLength;
+				if (elemStart >= endPos)
+					break;
+				elem = elem.getNextLeaf(_para);
+				CONFIG::debug
+				{
+					assert(elem != null, "bad nextLeaf"); }
+			}
+		}
+
+		/** @private 
+		 * Scan through the format runs within the line, and figure out what the leading for the overall line is.
+		 * The line's leading is equal to the maximum leading of any individual run within the line.
+		 * The leading in an individual format run is calculated by looking at the leading attribute in the
+		 * CharacterFormat. If it is set to a value, we just use that value. Otherwise, if it is set to AUTO,
+		 * we calculate the leading based on the point size and the auto leading percentage from the ParagraphFormat.
+		 */
+		public function getLineLeading(bp:String, elem:IFlowLeafElement, elemStart:int):Number
+		{
+			CONFIG::debug
+			{
+				assert(elemStart == elem.getAbsoluteStart(), "bad elemStart passed to getLineLeading"); }
+			var endPos:int = _absoluteStart + _textLength;
+			var totalLeading:Number = 0;
+			CONFIG::debug
+			{
+				assert(elem.getAncestorWithContainer() != null, "element with no container"); }
+			for (;;)
+			{
+				// If there's only one element in the line, and it has 0 leading, try resetting the leading using the default algorithm. Important
+				// for lines that contain only a float (which can otherwise recurse infinitely), and TCY spans in vertical text.
+				var elemLeading:Number = elem.getEffectiveLineHeight(bp);
+				if (!elemLeading && elem.textLength == this.textLength)
+					elemLeading = TextLayoutFormat.lineHeightProperty.computeActualPropertyValue(elem.computedFormat.lineHeight, elem.computedFormat.fontSize);
+				totalLeading = Math.max(totalLeading, elemLeading);
+				elemStart += elem.textLength;
+				if (elemStart >= endPos)
+					break;
+				elem = elem.getNextLeaf(_para);
+				CONFIG::debug
+				{
+					assert(elem != null, "bad nextLeaf"); }
+				if (elem == null)
+					break;
+			}
+			return totalLeading;
+		}
+
+		/** @private 
+		 * Scan through the format runs within the line, and figure out what the typographic ascent (i.e. ascent relative to the 
+		 * Roman baseline) for the overall line is. Normally it is the distance between the Roman and Ascent baselines, 
+		 * but it may be adjusted upwards by the width/height of the GraphicElement.
+		 */
+		public function getLineTypographicAscent(elem:IFlowLeafElement, elemStart:int, textLine:ITextLine):Number
+		{
+			CONFIG::debug
+			{
+				assert(elemStart == elem.getAbsoluteStart(), "bad elemStart passed to getLineTypographicAscent"); }
+			return TextLineUtil.getTextLineTypographicAscent(textLine ? textLine : getTextLine(), elem, elemStart, absoluteStart + textLength);
+		}
+
+		/** @private 
+		 * Get the "line box" for the line as defined by the CSS visual formatting model (http://www.w3.org/TR/CSS2/visuren.html)
+		 * Essentially, the union of all "inline boxes" on the line.
+		 * @return A rectangle representing the line box. Top and Bottom are relative to the Roman baseline. Left and Right are ignored.
+		 * May return null, for example, if the line only contains a float.
+		 */
+		public function getCSSLineBox(bp:String, elem:IFlowLeafElement, elemStart:int, swfContext:ISWFContext, effectiveListMarkerFormat:ITextLayoutFormat = null, numberLine:ITextLine = null):Rectangle
+		{
+			CONFIG::debug
+			{
+				assert(elem.getAncestorWithContainer() != null, "element with no container"); }
+			CONFIG::debug
+			{
+				assert(elemStart == elem.getAbsoluteStart(), "bad elemStart passed to getCSSLineBox"); }
+
+			var lineBox:Rectangle;
+
+			var endPos:int = _absoluteStart + _textLength;
+			var textLine:ITextLine = getTextLine();
+
+			for (;;)
+			{
+				addToLineBox(elem.getCSSInlineBox(bp, textLine, _para, swfContext));
+
+				elemStart += elem.textLength;
+				if (elemStart >= endPos)
+					break;
+
+				elem = elem.getNextLeaf(_para);
+				CONFIG::debug
+				{
+					assert(elem != null, "bad nextLeaf"); }
+			}
+
+			if (effectiveListMarkerFormat && numberLine)
+			{
+				// Para not available for number line, but the methods below handle null para correctly.
+				var para:IParagraphElement = null;
+
+				var ef:ElementFormat = GeometricElementUtils.computeElementFormatHelper(effectiveListMarkerFormat, para, swfContext);
+				var metrics:FontMetrics = swfContext ? swfContext.callInContext(ef.getFontMetrics, ef, null, true) : ef.getFontMetrics();
+
+				addToLineBox(GeometricElementUtils.getCSSInlineBoxHelper(effectiveListMarkerFormat, metrics, numberLine, para));
+			}
+
+			function addToLineBox(inlineBox:Rectangle):void
+			{
+				if (inlineBox)
+					lineBox = lineBox ? lineBox.union(inlineBox) : inlineBox;
+			}
+
+			return lineBox;
+		}
+
+		// helper method to determine which subset of line is underlined
+		// I believe this will be replaced by the eventSink mechanism
+		// private function isTextlineSubsetOfSpan(element:FlowLeafElement): Boolean
+		// {
+		// var spanStart:int = element.getAbsoluteStart();
+		// var spanEnd:int = spanStart + element.textLength;
+		//
+		// var lineStart:int = this.absoluteStart;
+		// var lineEnd:int = this.absoluteStart + this._textLength;
+		//
+		// return spanStart <= lineStart && spanEnd >= lineEnd;
+		// }
+		// TODO remove reference to UIBase
+		/**
+		 *  Create a rectangle for selection
+		 * @flexjsignorecoercion org.apache.flex.core.UIBase
+		 */
+		static private function createSelectionRect(selObj:ICompoundGraphic, color:uint, x:Number, y:Number, width:Number, height:Number):UIBase
+		{
+			// selObj.graphics.beginFill(color);
+			selObj.fill = new SolidColor(color);
+			// var cmds:Vector.<int> = new Vector.<int>();
+			// var pathPoints:Vector.<Number> = new Vector.<Number>();
+
+			var builder:PathBuilder = new PathBuilder(true);
+
+			// set the start point - topLeft
+			builder.moveTo(x, y);
+
+			// line to topRight
+			builder.lineTo(x + width, y);
+
+			// line to botRight
+			builder.lineTo(x + width, y + height);
+
+			// line to botLeft
+			builder.lineTo(x, y + height);
+
+			// line to close the path - topLeft
+			// Should auto-close in the ICompoundGraphic
+
+			selObj.drawPathCommands(builder);
+
+			return selObj as UIBase;
+		}
+
+		/** @private getSelectionShapesCacheEntry
+		 * 
+		 * creates and adds block selection(s) to the text container.  In most circumstances,
+		 * this method will produce and add a single UIBase, but in certain circumstances,
+		 * such as TCY in TTB text, will need to make multiple selection rectangles.
+		 * 
+		 * Examples:
+		 * 1) horizontal - ABCDE
+		 * 2) vertical - ABCDE
+		 * 3) horizontal - ABcdE
+		 * 4) vertical:		A
+		 * 					B
+		 * 				   cde
+		 * 					F
+		 * 
+		 */
+		private function getSelectionShapesCacheEntry(begIdx:int, endIdx:int, prevLine:ITextFlowLine, nextLine:ITextFlowLine, blockProgression:String):SelectionCache
+		{
+			if (isDamaged())
+				return null;
+
+			// 8-31-14 Do we need to adjust this for paras with multiple textBlocks?
+			// get the absolute start of the paragraph.  Calculation is expensive, so just do this once.
+			// var paraAbsStart:int = _para.getAbsoluteStart();
+			var textLine:ITextLine = getTextLine();
+			var paraAbsStart:int = _para.getTextBlockAbsoluteStart(textLine.textBlock);
+
+			// if the indexes are identical and are equal to the start of the line, then
+			// don't draw anything.  This prevents a bar being drawn on a following line when
+			// selecting accross line boundaries
+			// with exception for a selection that includes just the first character of an empty last line in the TextFlow
+			if (begIdx == endIdx && paraAbsStart + begIdx == absoluteStart)
+			{
+				if (absoluteStart != _para.getTextFlow().textLength - 1)
+					return null;
+				endIdx++;
+			}
+
+			// the cached selection bounds and rects
+			var selectionCache:SelectionCache = _selectionBlockCache[this];
+			if (selectionCache && selectionCache.begIdx == begIdx && selectionCache.endIdx == endIdx)
+				return selectionCache;
+
+			var drawRects:Array = new Array();
+			// an array to store any tcy rectangles which need separate processing and may not exist
+			var tcyDrawRects:Array = new Array();
+
+			if (selectionCache == null)
+			{
+				selectionCache = new SelectionCache();
+				_selectionBlockCache[this] = selectionCache;
+			}
+			else
+			{
+				selectionCache.clear();
+			}
+			selectionCache.begIdx = begIdx;
+			selectionCache.endIdx = endIdx;
+
+			var heightAndAdj:Array = getRomanSelectionHeightAndVerticalAdjustment(prevLine, nextLine);
+			calculateSelectionBounds(textLine, drawRects, begIdx, endIdx, blockProgression, heightAndAdj);
+
+			// iterate the blocks and create DisplayObjects to draw...
+			for each (var drawRect:Rectangle in drawRects)
+			{
+				CONFIG::debug
+				{
+					assert(selectionCache != null, "If we're caching, selectionArray should never be null!"); }
+				// we have to make new rectangles or the convertLineRectToGlobal will alter the cached ones!
+				selectionCache.pushSelectionBlock(drawRect);
+			}
+
+			// allow the atoms to be garbage collected.
+			// if (textLine) {
+			// textLine.flushAtomData(); // Warning: Now does nothing
+			// }
+
+			return selectionCache;
+		}
+
+		/** @private - helper method to calculate all selection blocks within a line.
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.ISubParagraphGroupElementBase
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.IInlineGraphicElement
+		 */
+		public function calculateSelectionBounds(textLine:ITextLine, rectArray:Array, begIdx:int, endIdx:int, blockProgression:String, heightAndAdj:Array):void
+		{
+			// the direction of the text
+			var direction:String = _para.computedFormat.direction;
+			// get the absolute start of the paragraph.  Calculation is expensive, so just do this once.
+			// var paraAbsStart:int = _para.getAbsoluteStart();
+			var paraAbsStart:int = _para.getTextBlockAbsoluteStart(textLine.textBlock);
+			// the current index.  used to iterate to the next element
+			var curIdx:int = begIdx;
+			// the current FlowLeafElement as determined by curIdx
+			var curElem:IFlowLeafElement = null;
+			// the highest glyph. Needed to normalize the rectangles we'll be building
+			var largestRise:Number = 0;
+
+			// blockRectArray holds each leaf's blocks which could be 1 or more
+			var blockRectArray:Array = [];
+			// floatRectArray holds the selection rects for any floats in the range.
+			var floatRectArray:Array = null;
+			// tcyDrawRects:Array
+			var tcyDrawRects:Array = null;
+
+			// do this loop and only afterwards perform the normalization and addition to the rectArr
+			while (curIdx < endIdx)
+			{
+				curElem = _para.findLeaf(curIdx);
+				// if we somehow got a 0 length element, then increment the index and continue
+				if (curElem.textLength == 0)
+				{
+					++curIdx;
+					continue;
+				}
+				else if (curElem is IInlineGraphicElement && (curElem as IInlineGraphicElement).computedFloat != Float.NONE)
+				{
+					if (floatRectArray == null)
+						floatRectArray = [];
+
+					var ilg:IInlineGraphicElement = curElem as IInlineGraphicElement;
+					var floatInfo:FloatCompositionData = controller.getFloatAtPosition(paraAbsStart + curIdx);
+					if (floatInfo)
+					{
+						var blockRect:Rectangle = new Rectangle(floatInfo.x - textLine.x, floatInfo.y - textLine.y, ilg.elementWidth, ilg.elementHeight);
+						floatRectArray.push(blockRect);
+					}
+					++curIdx;
+					continue;
+				}
+				// the number of potential glyphs to highlight. Could be larger than needed if we are only selecting part of it.
+				var numCharsSelecting:int = curElem.textLength + curElem.getElementRelativeStart(_para) - curIdx;
+				// special handling for TableLeafElements (do nothing)
+				if (curElem is ITableLeafElement)
+				{
+					// if(floatRectArray == null)
+					// floatRectArray = new Array();
+
+					// var block:TextFlowTableBlock = TableElement(TableLeafElement(curElem).parent).getFirstBlock();
+					// var blockRect:Rectangle = new Rectangle(floatInfo.x - textLine.x, floatInfo.y - textLine.y, ilg.elementWidth, ilg.elementHeight);
+					// floatRectArray.push(new Rectangle(0,0,block.width,block.height));
+					++curIdx;
+					continue;
+				}
+				// the index of the last glyph to highlight. If a partial selection, use endIdx
+				var endPos:int = (numCharsSelecting + curIdx) > endIdx ? endIdx : (numCharsSelecting + curIdx);
+
+				// if this is not a TCY in vertical, the blocks should all be running in the same direction
+				if (blockProgression != BlockProgression.RL || (textLine.getAtomTextRotation(textLine.getAtomIndexAtCharIndex(curIdx)) != TextRotation.ROTATE_0))
+				{
+					var leafBlockArray:Array = makeSelectionBlocks(textLine, curIdx, endPos, paraAbsStart, blockProgression, direction, heightAndAdj);
+					// copy all the blocks into the blockRectArray - we'll normalize them later
+					for (var leafBlockIter:int = 0; leafBlockIter < leafBlockArray.length; ++leafBlockIter)
+					{
+						blockRectArray.push(leafBlockArray[leafBlockIter]);
+					}
+				}
+				else
+				{
+					var tcyBlock:IFlowElement = curElem.getParentByType("TCYElement");
+					CONFIG::debug
+					{
+						assert(tcyBlock != null, "What kind of object is this that is ROTATE_0, but not TCY?");}
+
+					// if this element is still encompassed by a SubParagraphGroupElementBase of some kind (either a link or a TCYBlock)
+					// keep moving up to the parent.  Otherwise, the below code will go into an infinite loop.  bug 1905734
+					var tcyParentRelativeEnd:int = tcyBlock.parentRelativeEnd;
+					var subParBlock:ISubParagraphGroupElementBase = tcyBlock.getParentByType("SubParagraphGroupElementBase") as ISubParagraphGroupElementBase;
+					while (subParBlock)
+					{
+						tcyParentRelativeEnd += subParBlock.parentRelativeStart;
+						subParBlock = subParBlock.getParentByType("SubParagraphGroupElementBase") as ISubParagraphGroupElementBase;
+					}
+
+					var largestTCYRise:Number = 0;
+					var lastTCYIdx:int = endIdx < tcyParentRelativeEnd ? endIdx : tcyParentRelativeEnd;
+					var tcyRects:Array = new Array();
+
+					while (curIdx < lastTCYIdx)
+					{
+						curElem = _para.findLeaf(curIdx);
+						numCharsSelecting = curElem.textLength + curElem.getElementRelativeStart(_para) - curIdx;
+						endPos = numCharsSelecting + curIdx > endIdx ? endIdx : numCharsSelecting + curIdx;
+						var tcyRectArray:Array = makeSelectionBlocks(textLine, curIdx, endPos, paraAbsStart, blockProgression, direction, heightAndAdj);
+
+						for (var tcyBlockIter:int = 0; tcyBlockIter < tcyRectArray.length; ++tcyBlockIter)
+						{
+							var tcyRect:Rectangle = tcyRectArray[tcyBlockIter];
+
+							if (tcyRect.height > largestTCYRise)
+							{
+								largestTCYRise = tcyRect.height;
+							}
+
+							tcyRects.push(tcyRect);
+						}
+						curIdx = endPos;
+					}
+
+					if (!tcyDrawRects)
+						tcyDrawRects = new Array();
+
+					normalizeRects(tcyRects, tcyDrawRects, largestTCYRise, BlockProgression.TB, direction);
+					continue;
+				}
+
+				// set the curIdx to the last char in the block
+				curIdx = endPos;
+			}
+
+			// adding check for an empty set of draw rects.  If there are not recangles, skip this.
+			// this can happen is there are ONLY TCY blocks and the whole line is selected.
+			// Watson 2273832. - gak 02.09.09
+			// if the whole line is selected
+			if (blockRectArray.length > 0 && (paraAbsStart + begIdx) == absoluteStart && (paraAbsStart + endIdx) == (absoluteStart + textLength))
+			{
+				curElem = _para.findLeaf(begIdx);
+				// if we have the entire line selected, but the first element is NOT the last, then
+				// we will land up with a selection which is 1 character wider than it should be.
+				if (((curElem.getAbsoluteStart() + curElem.textLength) < (absoluteStart + textLength)) && endPos >= 2)
+				{
+					// make sure that this is a white char and that we aren't deselecting the last
+					// char in a line - esp important for scripts which don't use spaces ie Japanese
+					var charCode:int = _para.getCharCodeAtPosition(endPos - 1);
+					if (charCode != ElementConstants.kParagraphTerminator.charCodeAt(0) && CharacterUtil.isWhitespace(charCode))
+					{
+						var lastElemBlockArray:Array = makeSelectionBlocks(textLine, endPos - 1, endPos - 1, paraAbsStart, blockProgression, direction, heightAndAdj);
+						var lastRect:Rectangle = lastElemBlockArray[lastElemBlockArray.length - 1];
+						var modifyRect:Rectangle = blockRectArray[blockRectArray.length - 1] as Rectangle;
+
+						if (blockProgression != BlockProgression.RL)
+						{
+							// if they have the same width, simply remove the last block
+							if (modifyRect.width == lastRect.width)
+							{
+								blockRectArray.pop();
+							}
+							else
+							{
+								modifyRect.width -= lastRect.width;
+
+								// if this is RTL, we need to shift the selection block over by the amount
+								// we reduced it.
+								if (direction == Direction.RTL)
+									modifyRect.left -= lastRect.width;
+							}
+						}
+						else
+						{
+							// if they have the same height, simply remove the last block
+							if (modifyRect.height == lastRect.height)
+							{
+								blockRectArray.pop();
+							}
+							else
+							{
+								modifyRect.height -= lastRect.height;
+
+								// if this is RTL, we need to shift the selection block down by the amount
+								// we reduced it.
+								if (direction == Direction.RTL)
+									modifyRect.top += lastRect.height;
+							}
+						}
+					}
+				}
+			}
+
+			normalizeRects(blockRectArray, rectArray, largestRise, blockProgression, direction);
+			// add in the TCY Rects
+			if (tcyDrawRects && tcyDrawRects.length > 0)
+			{
+				for (var tcyIter:int = 0; tcyIter < tcyDrawRects.length; ++tcyIter)
+				{
+					rectArray.push(tcyDrawRects[tcyIter]);
+				}
+			}
+
+			// float selections do not normalize, put them into the rect array now
+			if (floatRectArray)
+			{
+				for (var floatIter:int = 0; floatIter < floatRectArray.length; ++floatIter)
+				{
+					rectArray.push(floatRectArray[floatIter]);
+				}
+			}
+		}
+
+		// TODO remove reference to UIBase
+		private function createSelectionShapes(selObj:ICompoundGraphic, selFormat:SelectionFormat, container:IParentIUIBase, begIdx:int, endIdx:int, prevLine:ITextFlowLine, nextLine:ITextFlowLine):void
+		{
+			var contElement:IContainerFormattedElement = _para.getAncestorWithContainer();
+			CONFIG::debug
+			{
+				assert(contElement != null, "para with no container"); }
+			var blockProgression:String = contElement.computedFormat.blockProgression;
+
+			var selCache:SelectionCache = getSelectionShapesCacheEntry(begIdx, endIdx, prevLine, nextLine, blockProgression);
+			if (!selCache)
+				return;
+
+			// iterate the blocks and create DisplayObjects to draw...
+			var drawRect:Rectangle;
+			var color:uint = selFormat.rangeColor;
+
+			if (_para && _para.getTextFlow())
+			{
+				var selMgr:ISelectionManager = _para.getTextFlow().interactionManager;
+				if (selMgr && (selMgr.anchorPosition == selMgr.activePosition))
+					color = selFormat.pointColor;
+			}
+
+			for each (drawRect in selCache.selectionBlocks)
+			{
+				drawRect = drawRect.clone();
+				convertLineRectToContainer(drawRect, true);
+				createSelectionRect(selObj, color, drawRect.x, drawRect.y, drawRect.width, drawRect.height);
+			}
+		}
+
+		/** @private 
+		 * Get the height and vertical adjustment for the line's selection shape, assuming Western typographic rules
+		 * where leading is included in selection.
+		 * @return An array with two elements
+		 * [0] height
+		 * [1] vertical adjustment to counter 'align bottom' behavior. The remainder of the selection code assumes selection shape
+		 * bottom is to be aligned with line descent. If this is not the case, vertical adjustment is set to an appropriate non-zero value. 
+		 */
+		public function getRomanSelectionHeightAndVerticalAdjustment(prevLine:ITextFlowLine, nextLine:ITextFlowLine):Array
+		{
+			var rectHeight:Number = 0;
+			var verticalAdj:Number = 0; // Default to 'align bottom'.
+
+			// This code erroneously assumed that it would only be called with a SPACE justifier and that AUTO would be up.  That is incorrect
+			// because some scripts, like Korean, use an up leading model and the EAST_ASIAN justifier.  New code just performs the check
+			if (LeadingUtils.useUpLeadingDirection(_para.getEffectiveLeadingModel()))
+			{
+				// "Space above, align bottom"
+				// 1) Space above as dictated by first baseline offset for the first line or line leading otherwise (both obtained from the 'height' data member)
+				// 2) Selection rectangle must at least include all of the text area
+				rectHeight = Math.max(height, textHeight);
+
+				// 3) Selection rectangle's bottom aligned with line descent; verticalAdj remains 0
+			}
+			else
+			{
+				// TODO-9/4/08-Is this the right way to check for first/last lines?
+				var isFirstLine:Boolean = !prevLine || prevLine.controller != controller || prevLine.columnIndex != columnIndex;
+				var isLastLine:Boolean = !nextLine || nextLine.controller != controller || nextLine.columnIndex != columnIndex || nextLine.paragraph.getEffectiveLeadingModel() == LeadingModel.ROMAN_UP;
+				// I'm removing this line as it makes the assumption that AUTO leading dir is UP only for Roman text, which is incorrect.
+				// Korean also uses UP leading but uses the EastAsian justifier. - gak 01.22.09
+				// ||(nextLine.paragraph.computedFormat.leadingDirection == LeadingDirection.AUTO && nextLine.paragraph.computedFormat.justificationRule == JustificationRule.SPACE);
+
+				if (isLastLine)
+				{
+					// There is no line after this one, or there is one which uses leading UP, so leading DOWN does not apply
+
+					if (!isFirstLine)
+					{
+						// "Space above None, align bottom" (eqivalently, "Space below None, align top"):
+						// 1) Only the text area should be selected
+						rectHeight = textHeight;
+
+						// 2) Selection rectangle's bottom aligned with line descent; verticalAdj remains 0
+					}
+					else
+					{
+						// "Space above, align bottom"
+						// 1) Space above as dictated by first baseline offset
+						// 2) Selection rectangle must at least include all of the text area
+						rectHeight = Math.max(height, textHeight);
+						// 3) Selection rectangle's bottom aligned with line descent; verticalAdj remains 0
+					}
+				}
+				else
+				{
+					// There is a line after this one, so leading DOWN applies
+
+					if (!isFirstLine)
+					{
+						// "Space below, align top"
+						// 1) Space below as dictated by line leading (obtained from 'height' member of next line)
+						// 2) Selection rectangle must at least include all of the text area
+						rectHeight = Math.max(nextLine.height, textHeight);
+
+						// 3) Selection rectangle's top to be aligned with line ascent, so its bottom to be at rectHeight - textLine.ascent,
+						// not textLine.descent, set verticalAdj accordingly
+						verticalAdj = rectHeight - textHeight; // same as rectHeight - textLine.ascent - textLine.descent
+					}
+					else
+					{
+						// Union of
+						// 1) first line, leading up: In this case, rectangle height is the larger of line height and text height,
+						// and the rectangle is shifted down by descent amount to align bottoms. So, top of rectangle is at:
+						var top:Number = _descent - Math.max(height, textHeight);
+
+						// 2) interior line, leading down: In this case, rectangle height is the larger of line leading and text height,
+						// and the rectangle is shifted up by ascent amount to align tops. So, bottom of rectangle is at:
+						var bottom:Number = Math.max(nextLine.height, textHeight) - _ascent;
+
+						rectHeight = bottom - top;
+
+						// 3) Selection rectangle's bottom to be at 'bottom', not the line's descent; set verticalAdj accordingly
+						verticalAdj = bottom - _descent;
+					}
+				}
+			}
+
+			// If we don't have a line above us, then we need to pad the line a bit as well as make it shift up.
+			// If we don't, then it overlaps the line below too much OR clips the top of the glyphs.
+			if (!prevLine || prevLine.columnIndex != this.columnIndex || prevLine.controller != this.controller)
+			{
+				// make it taller - this is kinda a fudge, but we have no info to determine a good top.
+				// if we don't do this, the selection rectangle will clip to the top of the glyphs and even
+				// let parts stick out a bit.  So, re-add the descent and offset the rect by 50% so that
+				// it appears to balance the top and bottom.
+				rectHeight += this.descent;
+				verticalAdj = Math.floor(this.descent / 2);
+			}
+			return [rectHeight, verticalAdj];
+		}
+
+		/** @private 
+		 * 
+		 * ? Get a list of rects of the characters in the given textline? Used to show selection? JF 
+		 */
+		private function makeSelectionBlocks(textLine:ITextLine, begIdx:int, endIdx:int, paraAbsStart:int, blockProgression:String, direction:String, heightAndAdj:Array):Array
+		{
+			CONFIG::debug
+			{
+				assert(begIdx <= endIdx, "Selection indexes are reversed!  How can this happen?!"); }
+
+			var blockArray:Array = [];
+			var blockRect:Rectangle = new Rectangle();
+			var startElem:IFlowLeafElement = _para.findLeaf(begIdx);
+			var startMetrics:Rectangle = startElem.getComputedFontMetrics().emBox;
+
+			if (!textLine)
+				textLine = getTextLine(true);
+
+			// ++makeBlockPassCounter;
+			// trace(makeBlockPassCounter + ") direction = " + direction + " blockProgression = " + blockProgression);
+
+			// CNW: removed whole line optimization 5/18/10 - was yielding different results than code below and was no faster
+
+			// trace(makeBlockPassCounter + ") begIdx = " + begIdx.toString() + " endIdx = " +  endIdx.toString());
+			var begAtomIndex:int = textLine.getAtomIndexAtCharIndex(begIdx);
+			var endAtomIndex:int = adjustEndElementForBidi(textLine, begIdx, endIdx, begAtomIndex, direction);
+
+			// trace(makeBlockPassCounter + ") begAtomIndex = " + begAtomIndex.toString() + " endAtomIndex = " +  endAtomIndex.toString());
+			CONFIG::debug
+			{
+				assert(begAtomIndex >= 0, "Invalid start index! begIdx = " + begIdx);}
+			CONFIG::debug
+			{
+				assert(endAtomIndex >= 0, "Invalid end index! begIdx = " + endIdx);}
+
+			if (direction == Direction.RTL && textLine.getAtomBidiLevel(endAtomIndex) % 2 != 0)
+			{
+				// if we are in RTL, anchoring the LTR text gets tricky.  Because the endElement is before the first
+				// element - which is why we're in this code - the result can be a zero-width rectangle if the span of LTR
+				// text breaks across line boundaries.  If that is the case, then the endAtomIndex value will be 0.  As
+				// this is the less common case, assume that it isn't and make all other cases come first
+				if (endAtomIndex == 0 && begIdx < endIdx - 1)
+				{
+					// since the endAtomIndex is 0, meaning that the LTR spans lines,
+					// we want to grab the glyph before the endIdx which represents the last LTR glyph for the selection.
+					// Make a recursive call into makeSelectionBlocks using and endIdx decremented by 1.
+					blockArray = makeSelectionBlocks(textLine, begIdx, endIdx - 1, paraAbsStart, blockProgression, direction, heightAndAdj);
+					var bidiBlock:Array = makeSelectionBlocks(textLine, endIdx - 1, endIdx - 1, paraAbsStart, blockProgression, direction, heightAndAdj);
+					var bidiBlockIter:int = 0;
+					while (bidiBlockIter < bidiBlock.length)
+					{
+						blockArray.push(bidiBlock[bidiBlockIter]);
+						++bidiBlockIter;
+					}
+					return blockArray;
+				}
+			}
+
+			var begIsBidi:Boolean = begAtomIndex != -1 ? isAtomBidi(textLine, begAtomIndex, direction) : false;
+			var endIsBidi:Boolean = endAtomIndex != -1 ? isAtomBidi(textLine, endAtomIndex, direction) : false;
+
+			if (begIsBidi || endIsBidi)
+			{
+				// this code needs to iterate over the glyphs starting at the begAtomIndex and going forward.
+				// It doesn't matter is beg is bidi or not, we need to find a boundary, create a rect on it, then proceded.
+				// use the value of begIsBidi for testing the consistency of the selection.
+
+				// Example bidi text.  Note that the period comes at the left end of the line:
+				//
+				// Bidi state:		f f t t t t t	(true/false)
+				// Element Index:0 1 2 3 4 5 6		(0 is the para terminator)
+				// Chars:			. t o _ b e
+				// Flow Index:	   6 0 1 2 3 4 (5) 	Note that these numbers represent the space between glyphs AND
+				// 5(f)			that index 5 is both the space after the e and before the period.
+				// but, the position 5 is not a valid cursor location.
+
+				// the original code I implemented used the beg and endElement indexes however that fails because when the text
+				// is mixed bidi/non-bidi, the indexes are only 1 char apart. This resulted in, for example, only the period in
+				// a line getting selected when the text was bidi.   Instead, we're going to use the begIdx and endIdx and
+				// recalculate the element indexes each time.  This is expensive, but I don't see an alternative. - gak 09.05.08
+				var curIdx:int = begIdx;
+				var incrementor:int = begIdx != endIdx ? 1 : 0;
+
+				// the indexes used to draw the seleciton.  activeStart/End represent the
+				// beginning of the selection shape atoms, while cur is the one we are testing.
+				var activeStartIndex:int = begAtomIndex;
+				var activeEndIndex:int = begAtomIndex;
+				var curElementIndex:int = begAtomIndex;
+
+				// when activeEndIsBidi no longer matches the bidi setting for the activeStartIndex, we will create the shape
+				var activeEndIsBidi:Boolean = begIsBidi;
+
+				do
+				{
+					// increment the index
+					curIdx += incrementor;
+					// get the next atom index
+					curElementIndex = textLine.getAtomIndexAtCharIndex(curIdx);
+
+					// calculate the bidi level for the - kinda cludgy, but if the bidi-text wraps, curElementIndex == -1
+					// so just set it to false if this is the case.  It will get ignored in the subsequent check and curIdx
+					// will == endIdx as this is the last glyph in the line - which is why the next is -1 - gak 09.12.08
+					var curIsBidi:Boolean = (curElementIndex != -1) ? isAtomBidi(textLine, curElementIndex, direction) : false;
+
+					if (curElementIndex != -1 && curIsBidi != activeEndIsBidi)
+					{
+						blockRect = makeBlock(textLine, curIdx, activeStartIndex, activeEndIndex, startMetrics, blockProgression, direction, heightAndAdj);
+						blockArray.push(blockRect);
+
+						// shift the activeStart/End indexes to the current
+						activeStartIndex = curElementIndex;
+						activeEndIndex = curElementIndex;
+						// update the bidi setting
+						activeEndIsBidi = curIsBidi;
+					}
+					else
+					{
+						// we don't get another chance to make a block, so if this is the last char, make the block before we bail out.
+						// we have to check both equality and equality plus the incrementor because if we don't, then we'll miss a
+						// character in the selection.
+						if (curIdx == endIdx)
+						{
+							blockRect = makeBlock(textLine, curIdx, activeStartIndex, activeEndIndex, startMetrics, blockProgression, direction, heightAndAdj);
+							blockArray.push(blockRect);
+						}
+
+						activeEndIndex = curElementIndex;
+					}
+				} while (curIdx < endIdx);
+			}
+			else
+			{
+				var testILG:IInlineGraphicElement = startElem as IInlineGraphicElement;
+				if (!testILG || testILG.effectiveFloat == Float.NONE || begIdx == endIdx)
+				{
+					blockRect = makeBlock(textLine, begIdx, begAtomIndex, endAtomIndex, startMetrics, blockProgression, direction, heightAndAdj);
+					if (testILG && testILG.elementWidthWithMarginsAndPadding() != testILG.elementWidth)
+					{	// Don't include margins or padding around inlines in the bounds
+						var verticalText:Boolean = testILG.getTextFlow().computedFormat.blockProgression == BlockProgression.RL;
+						var ilgFormat:ITextLayoutFormat = testILG.computedFormat;
+						if (verticalText)
+						{
+							var paddingTop:Number = testILG.getEffectivePaddingTop();
+							blockRect.top += paddingTop;	// don't include the left side indent in the selected area
+							var paddingBottom:Number = testILG.getEffectivePaddingBottom();
+							blockRect.bottom -= paddingBottom;
+						}
+						else
+						{
+							var paddingLeft:Number = testILG.getEffectivePaddingLeft();
+							blockRect.left += paddingLeft;	// don't include the left side indent in the selected area
+							var paddingRight:Number = testILG.getEffectivePaddingRight();
+							blockRect.right -= paddingRight;
+						}
+					}
+				}
+				else
+				{
+					blockRect = BoundsUtil.getBounds(testILG.graphic, textLine);// testILG.graphic.getBounds(textLine);
+				}
+
+				blockArray.push(blockRect);
+			}
+
+			return blockArray;
+		}
+
+		/** @private 
+		 * 
+		 * ? Get the bounds of the supplied range of characters in the given textline? Used to show selection? JF 
+		 */
+		private function makeBlock(textLine:ITextLine, begTextIndex:int, begAtomIndex:int, endAtomIndex:int, startMetrics:Rectangle, blockProgression:String, direction:String, heightAndAdj:Array):Rectangle
+		{
+			var blockRect:Rectangle = new Rectangle();
+			var globalStart:Point = new Point(0, 0);
+
+			if (begAtomIndex > endAtomIndex)
+			{
+				// swap the start and end
+				var tempEndIdx:int = endAtomIndex;
+				endAtomIndex = begAtomIndex;
+				begAtomIndex = tempEndIdx;
+			}
+			if (!textLine)
+				textLine = getTextLine(true);
+
+			// now that we have elements and they are in the right order for drawing, get their rectangles
+			var begCharRect:Rectangle = textLine.getAtomBounds(begAtomIndex);
+			// trace(makeBlockPassCounter + ") begCharRect = " + begCharRect.toString());
+
+			var endCharRect:Rectangle = textLine.getAtomBounds(endAtomIndex);
+			// trace(makeBlockPassCounter + ") endCharRect = " + endCharRect.toString());
+
+			// Calculate the justificationRule value
+			var justRule:String = _para.getEffectiveJustificationRule();
+			// If this is TTB text and NOT TCY, as indicated by TextRotation.rotate0...
+			if (blockProgression == BlockProgression.RL && textLine.getAtomTextRotation(begAtomIndex) != TextRotation.ROTATE_0)
+			{
+				globalStart.y = begCharRect.y;
+				blockRect.height = begAtomIndex != endAtomIndex ? endCharRect.bottom - begCharRect.top : begCharRect.height;
+
+				// re-ordered this code.  EAST_ASIAN is more common in vertical and should be the first option.
+				if (justRule == JustificationRule.EAST_ASIAN)
+				{
+					blockRect.width = begCharRect.width;
+				}
+				else
+				{
+					blockRect.width = heightAndAdj[0];
+					globalStart.x -= heightAndAdj[1];
+				}
+			}
+			else
+			{
+				// given bidi text alternations, the endCharRect could be left of the begCharRect,
+				// use whichever is farther left.
+				globalStart.x = Math.min(begCharRect.x, endCharRect.x);
+				// if we're here and the BlockProgression is TTB, then we're TCY.  Less frequent case, so make non-TCY
+				// the first option...
+				// NB - Never use baseline adjustments for TCY.  They don't make sense here.(I think) - gak 06.03.08
+				if (blockProgression == BlockProgression.RL)
+					globalStart.y = begCharRect.y + (startMetrics.width / 2); // TODO-9/5/8:Behavior for leading down TBD
+
+				if (justRule != JustificationRule.EAST_ASIAN)
+				{
+					blockRect.height = heightAndAdj[0];
+					if (blockProgression == BlockProgression.RL)
+						globalStart.x -= heightAndAdj[1];
+					else
+						globalStart.y += heightAndAdj[1];
+					// changed the width from a default of 2 to use the begCharRect.width so that point seletion
+					// can choose to use the right or left side of the glyph when drawing a caret Watson 1876415/1876953- gak 08.19.09
+					blockRect.width = begAtomIndex != endAtomIndex ? Math.abs(endCharRect.right - begCharRect.left) : begCharRect.width;
+				}
+				else
+				{
+					blockRect.height = begCharRect.height;
+
+					// changed the width from a default of 2 to use the begCharRect.width so that point seletion
+					// can choose to use the right or left side of the glyph when drawing a caret Watson 1876415/1876953- gak 08.19.09
+					blockRect.width = begAtomIndex != endAtomIndex ? Math.abs(endCharRect.right - begCharRect.left) : begCharRect.width;
+				}
+			}
+
+			blockRect.x = globalStart.x;
+			blockRect.y = globalStart.y;
+			if (blockProgression == BlockProgression.RL)
+			{
+				if (textLine.getAtomTextRotation(begAtomIndex) != TextRotation.ROTATE_0)
+					blockRect.x -= textLine.descent;
+				else // it's TCY
+					blockRect.y -= (blockRect.height / 2);
+			}
+			else
+			{
+				blockRect.y += (textLine.descent - blockRect.height);
+			}
+
+			var tfl:ITextFlowLine = textLine.userData as ITextFlowLine;
+			var curElem:IFlowLeafElement = _para.findLeaf(begTextIndex);
+			var rotation:String;
+			if (!curElem)
+			{
+				if (begTextIndex < 0)
+					curElem = _para.getFirstLeaf();
+				else if (begTextIndex >= _para.textLength)
+					curElem = _para.getLastLeaf();
+				rotation = curElem ? curElem.computedFormat.textRotation : TextRotation.ROTATE_0;
+			}
+			else
+				rotation = curElem.computedFormat.textRotation;
+
+			// handle rotation.  For horizontal text, rotations of 90 or 180 cause the text
+			// to draw under the baseline in a cosistent location.  Vertical text is a bit more complicated
+			// in that a 90 rotation puts it immediately to the left of the Em Box, whereas 180 is one quarter
+			// of the way in the Em Box. Fix for Watson 1915930 - gak 02.17.09
+			if (rotation == TextRotation.ROTATE_180 || rotation == TextRotation.ROTATE_90)
+			{
+				if (blockProgression != BlockProgression.RL)
+					blockRect.y += (blockRect.height / 2);
+				else
+				{
+					if (curElem.getParentByType("TCYElement") == null)
+					{
+						if (rotation == TextRotation.ROTATE_90)
+							blockRect.x -= blockRect.width;
+						else
+							blockRect.x -= (blockRect.width * .75);
+					}
+					else
+					{
+						if (rotation == TextRotation.ROTATE_90)
+							blockRect.y += blockRect.height;
+						else
+							blockRect.y += (blockRect.height * .75);
+					}
+				}
+			}
+
+			return blockRect;
+		}
+
+		/** @private
+		 * 
+		 * 
+		 */
+		public function convertLineRectToContainer(rect:Rectangle, constrainShape:Boolean):void
+		{
+			var textLine:ITextLine = getTextLine();
+
+			/* var globalStart:Point = new Point(rect.x, rect.y);
+			
+			// convert to controller coordinates...
+			// //trace(makeBlockPassCounter + ") globalStart = " + globalStart.toString());
+			globalStart = textLine.localToGlobal(globalStart);
+			// //trace(makeBlockPassCounter + ") localToGlobal.globalStart = " + globalStart.toString());
+			globalStart = container.globalToLocal(globalStart);
+			// //trace(makeBlockPassCounter + ") globalToLocal.globalStart = " + globalStart.toString());
+			rect.x = globalStart.x;
+			rect.y = globalStart.y; */
+
+			// this is much simpler and actually more accurate - localToGlobal/globalToLocal does some rounding
+			rect.x += textLine.x;
+			rect.y += textLine.y;
+
+			if (constrainShape)
+			{
+				var tf:ITextFlow = _para.getTextFlow();
+				var columnRect:Rectangle = controller.columnState.getColumnAt(this.columnIndex);
+				constrainRectToColumn(tf, rect, columnRect, controller.horizontalScrollPosition, controller.verticalScrollPosition, controller.compositionWidth, controller.compositionHeight);
+			}
+		}
+
+		/** @private */
+		static public function constrainRectToColumn(tf:ITextFlow, rect:Rectangle, columnRect:Rectangle, hScrollPos:Number, vScrollPos:Number, compositionWidth:Number, compositionHeight:Number):void
+		{
+			if (columnRect == null)
+				return;
+			if (tf.computedFormat.lineBreak == LineBreak.EXPLICIT)
+				return;
+
+			var bp:String = tf.computedFormat.blockProgression;
+			var direction:String = tf.computedFormat.direction;
+
+			if (bp == BlockProgression.TB && !isNaN(compositionWidth))
+			{
+				if (direction == Direction.LTR)
+				{
+					// make sure is doesn't go past the end of the container
+					if (rect.left > (columnRect.x + columnRect.width + hScrollPos))
+						rect.left = (columnRect.x + columnRect.width + hScrollPos);
+
+					// make sure that if this is a selection and not a point selection, that
+					// we don't go beyond the end of the container...
+					if (rect.right > (columnRect.x + columnRect.width + hScrollPos))
+						rect.right = (columnRect.x + columnRect.width + hScrollPos);
+				}
+				else
+				{
+					if (rect.right < (columnRect.x + hScrollPos))
+						rect.right = (columnRect.x + hScrollPos);
+
+					if (rect.left < (columnRect.x + hScrollPos))
+						rect.left = (columnRect.x + hScrollPos);
+				}
+			}
+			else if (bp == BlockProgression.RL && !isNaN(compositionHeight))
+			{
+				if (direction == Direction.LTR)
+				{
+					// make sure is doesn't go past the end of the container
+					if (rect.top > (columnRect.y + columnRect.height + vScrollPos))
+						rect.top = (columnRect.y + columnRect.height + vScrollPos);
+
+					// make sure that if this is a selection and not a point selection, that
+					// we don't go beyond the end of the container...
+					if (rect.bottom > (columnRect.y + columnRect.height + vScrollPos))
+						rect.bottom = (columnRect.y + columnRect.height + vScrollPos);
+				}
+				else
+				{
+					if (rect.bottom < (columnRect.y + vScrollPos))
+						rect.bottom = (columnRect.y + vScrollPos);
+
+					if (rect.top < (columnRect.y + vScrollPos))
+						rect.top = (columnRect.y + vScrollPos);
+				}
+			}
+		}
+
+		// TODO remove reference to UIBase
+		/** @private
+		 * Helper method to hilight the portion of a block selection on this ITextLine.  A selection display is created and added to the line's TextFrame with ContainerController addSelectionShape.
+		 * @param begIdx absolute index of start of selection on this line.
+		 * @param endIdx absolute index of end of selection on this line.
+		 */
+		public function hiliteBlockSelection(selObj:ICompoundGraphic, selFormat:SelectionFormat, container:IParentIUIBase, begIdx:int, endIdx:int, prevLine:ITextFlowLine, nextLine:ITextFlowLine):void
+		{
+			// no container for overflow lines, or lines scrolled out
+			if (isDamaged() || !_controller)
+				return;
+
+			var textLine:ITextLine = peekTextLine();
+			if (!textLine || !textLine.parent)
+				return;
+
+			var paraStart:int = _para.getTextBlockAbsoluteStart(textLine.textBlock);
+			begIdx -= paraStart;
+			endIdx -= paraStart;
+
+			createSelectionShapes(selObj, selFormat, container, begIdx, endIdx, prevLine, nextLine);
+		}
+
+		// TODO remove reference to UIBase
+		/** @private
+		 * Helper method to hilight a point selection on this ITextLine.  x,y,w,h of the selection are calculated and ContainerController.drawPointSelection is called 
+		 * @param idx absolute index of the point selection.
+		 */
+		public function hilitePointSelection(selFormat:SelectionFormat, idx:int, container:IParentIUIBase, prevLine:ITextFlowLine, nextLine:ITextFlowLine):void
+		{
+			var rect:Rectangle = computePointSelectionRectangle(idx, container, prevLine, nextLine, true);
+			if (rect)
+				_controller.drawPointSelection(selFormat, rect.x, rect.y, rect.width, rect.height);
+		}
+
+		static private function setRectangleValues(rect:Rectangle, x:Number, y:Number, width:Number, height:Number):void
+		{
+			rect.x = x;
+			rect.y = y;
+			rect.width = width;
+			rect.height = height;
+		}
+
+		static private const localZeroPoint:Point = new Point(0, 0);
+		static private const localOnePoint:Point = new Point(1, 0);
+		static private const rlLocalOnePoint:Point = new Point(0, 1);
+
+		// TODO generalize this so we're not relying on UIBase
+		/** @private */
+		public function computePointSelectionRectangle(idx:int, container:IParentIUIBase, prevLine:ITextFlowLine, nextLine:ITextFlowLine, constrainSelRect:Boolean):Rectangle
+		{
+			if (isDamaged() || !_controller)
+				return null;
+
+			// no container for overflow lines, or lines scrolled out
+			var textLine:ITextLine = peekTextLine();
+			if (!textLine || !textLine.parent)
+				return null;
+			// adjust to this paragraph's ITextBlock
+			// I'm assuming this needs to be relative to the ITextBlock and not the paragraph -- Harbs
+			idx -= _para.getTextBlockAbsoluteStart(textLine.textBlock);
+			// idx -= _para.getAbsoluteStart();
+
+			textLine = getTextLine(true);
+
+			// endIdx will only differ if idx is altered when detecting TCY bounds
+			var endIdx:int = idx;
+			var elementIndex:int = textLine.getAtomIndexAtCharIndex(idx);
+			CONFIG::debug
+			{
+				assert(elementIndex != -1, "Invalid point selection index! idx = " + idx); }
+
+			var isTCYBounds:Boolean = false;
+			var paraLeadingTCY:Boolean = false;
+
+			var contElement:IContainerFormattedElement = _para.getAncestorWithContainer();
+			CONFIG::debug
+			{
+				assert(contElement != null, "para with no container"); }
+			var blockProgression:String = contElement.computedFormat.blockProgression;
+			var direction:String = _para.computedFormat.direction;
+
+			// need to check for TCY.  TCY cannot take input into it's head, but can in it's tail.
+			if (blockProgression == BlockProgression.RL)
+			{
+				if (idx == 0)
+				{
+					if (textLine.getAtomTextRotation(0) == TextRotation.ROTATE_0)
+						paraLeadingTCY = true;
+				}
+				else
+				{
+					var prevElementIndex:int = textLine.getAtomIndexAtCharIndex(idx - 1);
+					if (prevElementIndex != -1)
+					{
+						// if this elem is TCY, then we need to back up one space and use the right bounds
+						if (textLine.getAtomTextRotation(elementIndex) == TextRotation.ROTATE_0 && textLine.getAtomTextRotation(prevElementIndex) != TextRotation.ROTATE_0)
+						{
+							elementIndex = prevElementIndex;
+							--idx;
+							isTCYBounds = true;
+						}
+						else if (textLine.getAtomTextRotation(prevElementIndex) == TextRotation.ROTATE_0)
+						{
+							elementIndex = prevElementIndex;
+							--idx;
+							isTCYBounds = true;
+						}
+					}
+				}
+			}
+
+			var heightAndAdj:Array = getRomanSelectionHeightAndVerticalAdjustment(prevLine, nextLine);
+			var blockRectArray:Array = makeSelectionBlocks(textLine, idx, endIdx, _para.getTextBlockAbsoluteStart(textLine.textBlock), blockProgression, direction, heightAndAdj);
+			CONFIG::debug
+			{
+				assert(blockRectArray.length == 1, "A point selection should return a single selection rectangle!"); }
+			var rect:Rectangle = blockRectArray[0];
+
+			convertLineRectToContainer(rect, constrainSelRect);
+
+			var drawOnRight:Boolean = (direction == Direction.RTL);
+
+			if ((drawOnRight && textLine.getAtomBidiLevel(elementIndex) % 2 == 0) || (!drawOnRight && textLine.getAtomBidiLevel(elementIndex) % 2 != 0))
+			{
+				drawOnRight = !drawOnRight;
+			}
+
+			// compute a width so that cursor is visually one pixel wide independent of scaling
+			var zeroPoint:Point = PointUtils.localToGlobal(localZeroPoint, container);// container.localToGlobal(localZeroPoint);
+			var cursorWidth:Number;
+
+			if (blockProgression == BlockProgression.RL && textLine.getAtomTextRotation(elementIndex) != TextRotation.ROTATE_0)
+			{
+				var rlOnePoint:Point = PointUtils.localToGlobal(rlLocalOnePoint, container);// container.localToGlobal(rlLocalOnePoint);
+				cursorWidth = zeroPoint.y - rlOnePoint.y;
+				cursorWidth = cursorWidth == 0 ? 1 : Math.abs(1.0 / cursorWidth);
+				// trace(zeroPoint,onePoint,cursorSize);
+				if (!drawOnRight)
+					setRectangleValues(rect, rect.x, !isTCYBounds ? rect.y : rect.y + rect.height, rect.width, cursorWidth);
+				else
+					setRectangleValues(rect, rect.x, !isTCYBounds ? rect.y + rect.height : rect.y, rect.width, cursorWidth);
+			}
+			else
+			{
+				var onePoint:Point = PointUtils.localToGlobal(localOnePoint, container);// container.localToGlobal(localOnePoint);
+				cursorWidth = zeroPoint.x - onePoint.x;
+				cursorWidth = cursorWidth == 0 ? 1 : Math.abs(1.0 / cursorWidth);
+				// trace(zeroPoint,onePoint,cursorSize);
+				// choose to use the right or left side of the glyph based on Direction when drawing a caret Watson 1876415/1876953
+				// if the direction is ltr, then the cursor should be on the left side
+				if (!drawOnRight)
+					setRectangleValues(rect, !isTCYBounds ? rect.x : rect.x + rect.width, rect.y, cursorWidth, rect.height);
+				else // otherwise, it should be on the right, unless it is TCY
+					setRectangleValues(rect, !isTCYBounds ? rect.x + rect.width : rect.x, rect.y, cursorWidth, rect.height);
+			}
+
+			// allow the atoms to be garbage collected.
+			// textLine.flushAtomData(); // Warning: Now does nothing
+
+			return rect;
+		}
+
+		/** @private
+		 * Three states.  Disjoint(0), Intersects(1), HeightContainedIn(2),  
+		 */
+		public function selectionWillIntersectScrollRect(scrollRect:Rectangle, begIdx:int, endIdx:int, prevLine:ITextFlowLine, nextLine:ITextFlowLine):int
+		{
+			var contElement:IContainerFormattedElement = _para.getAncestorWithContainer();
+			CONFIG::debug
+			{
+				assert(contElement != null, "para with no container"); }
+			var blockProgression:String = contElement.computedFormat.blockProgression;
+			var textLine:ITextLine = getTextLine(true);
+
+			if (begIdx == endIdx)
+			{
+				var pointSelRect:Rectangle = computePointSelectionRectangle(begIdx, UIBase(controller.container), prevLine, nextLine, false);
+				if (pointSelRect)
+				{
+					if (scrollRect.containsRect(pointSelRect))
+						return 2;
+					if (scrollRect.intersects(pointSelRect))
+						return 1;
+				}
+			}
+			else
+			{
+				var paraStart:int;
+				// 8-31-14 Assuming this should be from the textBlock. Keeping getAbsoluteStart() in case there's no textLine -- not sure if that's needed
+				if (textLine)
+					paraStart = _para.getTextBlockAbsoluteStart(textLine.textBlock);
+				else
+					paraStart = _para.getAbsoluteStart();
+				var selCache:SelectionCache = this.getSelectionShapesCacheEntry(begIdx - paraStart, endIdx - paraStart, prevLine, nextLine, blockProgression);
+				if (selCache)
+				{
+					// iterate the blocks and check for intersections
+					var drawRect:Rectangle;
+					for each (drawRect in selCache.selectionBlocks)
+					{
+						drawRect = drawRect.clone();
+						// convertLineRectToContainer(container, drawRect);
+						drawRect.x += textLine.x;
+						drawRect.y += textLine.y;
+						if (scrollRect.intersects(drawRect))
+						{
+							if (blockProgression == BlockProgression.RL)
+							{
+								// see if width is entirely contained in scrollRect
+								if (drawRect.left >= scrollRect.left && drawRect.right <= scrollRect.right)
+									return 2;
+							}
+							else
+							{
+								if (drawRect.top >= 

<TRUNCATED>

[35/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/TextFlowLineLocation.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/TextFlowLineLocation.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/TextFlowLineLocation.as
new file mode 100644
index 0000000..e6483dc
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/TextFlowLineLocation.as
@@ -0,0 +1,71 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.compose
+{	
+	/** 
+	 * The TextFlowLineLocation class is an enumeration class that defines constants for specifying the location
+	 * of a line within a paragraph.
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 *
+	 * @see ParagraphElement
+	 * @see TextFlow
+	 */
+	 
+	public final class TextFlowLineLocation
+	{ 
+		/** Specifies the first line in a paragraph. 
+		 *
+		 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		public static const FIRST:uint = 1;
+		
+		/** Specifies a middle line in a paragraph - neither the first nor the last line. 
+		 *
+		 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		public static const MIDDLE:uint = 2;
+		
+		/** Specifies the last line in a paragraph.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+		 */
+		 
+		public static const LAST:uint = 4;
+		
+		/** Specifies both the first and last lines in a paragraph.
+		 *
+		 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		public static const ONLY:uint = 5;
+	};
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/TextFlowTableBlock.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/TextFlowTableBlock.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/TextFlowTableBlock.as
new file mode 100644
index 0000000..a1189c2
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/TextFlowTableBlock.as
@@ -0,0 +1,266 @@
+// //////////////////////////////////////////////////////////////////////////////
+//
+// 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
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// //////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.compose
+{
+	import org.apache.flex.textLayout.container.IContainerController;
+	import org.apache.flex.core.IParentIUIBase;
+	import org.apache.flex.graphics.ICompoundGraphic;
+	import org.apache.flex.text.engine.ITextLine;
+	import org.apache.flex.textLayout.edit.SelectionFormat;
+	import org.apache.flex.textLayout.elements.CellContainer;
+	import org.apache.flex.textLayout.elements.CellCoordinates;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.ITableCellElement;
+	import org.apache.flex.textLayout.elements.ITableElement;
+	import org.apache.flex.textLayout.elements.TableBlockContainer;
+
+	/**
+	 * 
+	 **/
+	public class TextFlowTableBlock extends TextFlowLine implements ITextFlowTableBlock
+	{
+		private var _textHeight:Number;
+
+		/** Constructor - creates a new TextFlowTableBlock instance. 
+		 *  <p><strong>Note</strong>: No client should call this. It's exposed for writing your own composer.</p>
+		 *
+		 * @param index The index in the Table text flow.
+		 * */
+		public function TextFlowTableBlock(index:uint)
+		{
+			blockIndex = index;
+			_container = new TableBlockContainer();
+			super(null, null);
+		}
+
+		override public function get composable():Boolean
+		{
+			return false;
+		}
+
+		/**
+		 * @inheritDoc
+		 **/
+		override public function initialize(paragraph:IParagraphElement, outerTargetWidth:Number = 0, lineOffset:Number = 0, absoluteStart:int = 0, numChars:int = 0, textLine:ITextLine = null):void
+		{
+			_container.userData = this;
+			_lineOffset = lineOffset;
+
+			super.initialize(paragraph, outerTargetWidth, lineOffset, absoluteStart, numChars, textLine);
+		}
+
+		override public function setController(cont:IContainerController, colNumber:int):void
+		{
+			super.setController(cont, colNumber);
+			if (cont)
+				controller.addComposedTableBlock(container);
+		}
+
+		/**
+		 * The table that owns this table block
+		 **/
+		private var _parentTable:ITableElement;
+		/**
+		 * The index of this block in the table text flow layout
+		 **/
+		public var blockIndex:uint = 0;
+		/**
+		 * @private
+		 **/
+		private var _container:TableBlockContainer;
+		private var _cells:Array;
+
+		/**
+		 * Returns an array of table cells. 
+		 * @private
+		 **/
+		private function getCells():Array
+		{
+			if (_cells == null)
+			{
+				_cells = [];
+			}
+			return _cells;
+		}
+
+		/**
+		 * Returns a vector of table cell elements in the given cell range. 
+		 **/
+		public function getCellsInRange(anchorCoords:CellCoordinates, activeCoords:CellCoordinates):Vector.<ITableCellElement>
+		{
+			if (!parentTable)
+				return null;
+			return parentTable.getCellsInRange(anchorCoords, activeCoords, this);
+		}
+
+		/**
+		 * Clears the cells in the table block. Wraps clearCells(). 
+		 **/
+		public function clear():void
+		{
+			clearCells();
+		}
+
+		/**
+		 * Clears the cells in the table block
+		 **/
+		public function clearCells():void
+		{
+			while (_container.numElements)
+			{
+				_container.removeElement(_container.getElementAt(0));
+			}
+			getCells().length = 0;
+		}
+
+		/**
+		 * Adds a cell container to table container. This adds it to the display list. 
+		 * If the cell is already added it does not add it twice. 
+		 **/
+		public function addCell(cell:CellContainer):void
+		{
+			var cells:Array = getCells();
+			if (cells.indexOf(cell) < 0)
+			{
+				cells.push(cell);
+				_container.addElement(cell);
+			}
+		}
+
+		public function drawBackground(backgroundInfo:*):void
+		{
+			// TODO: need to figure this out...
+		}
+
+		/**
+		 * Container that displays this collection of cells
+		 **/
+		public function get container():TableBlockContainer
+		{
+			return _container;
+		}
+
+		/**
+		 * Triggers drawing of composed cell contents
+		 **/
+		public function updateCompositionShapes():void
+		{
+			var cells:Array = getCells();
+			for each (var cell:CellContainer in cells)
+			{
+				cell.cellElement.updateCompositionShapes();
+			}
+		}
+
+		/**
+		 * Sets the height of the container 
+		 **/
+		override public function set height(value:Number):void
+		{
+			// _container.height = value;
+			_textHeight = value;
+		}
+
+		/**
+		 * @inheritDoc
+		 **/
+		override public function get height():Number
+		{
+			return _textHeight;
+		}
+
+		/**
+		 * Sets the width of the container 
+		 **/
+		public function set width(value:Number):void
+		{
+			_container.width = value;
+		}
+
+		/**
+		 * Gets the width of the container 
+		 **/
+		public function get width():Number
+		{
+			return _container.width;
+		}
+
+		/**
+		 * Sets the x position of the container
+		 **/
+		override public function set x(value:Number):void
+		{
+			super.x = _container.x = value;
+		}
+
+		override public function get x():Number
+		{
+			return _container.x;
+		}
+
+		/**
+		 * Sets the y value of the container
+		 **/
+		override public function set y(value:Number):void
+		{
+			super.y = _container.y = value;
+		}
+
+		override public function get y():Number
+		{
+			return _container.y;
+		}
+
+		/**
+		 * Returns a vector of table cell elements.
+		 **/
+		public function getTableCells():Vector.<ITableCellElement>
+		{
+			var tCells:Vector.<ITableCellElement> = new Vector.<ITableCellElement>();
+			var cells:Array = getCells();
+
+			for each (var cellContainer:CellContainer in cells)
+			{
+				tCells.push(cellContainer.cellElement);
+			}
+
+			return tCells;
+		}
+
+		public override function get textHeight():Number
+		{
+			return _textHeight;
+		}
+
+		public override function hiliteBlockSelection(selObj:ICompoundGraphic, selFormat:SelectionFormat, container:IParentIUIBase, begIdx:int, endIdx:int, prevLine:ITextFlowLine, nextLine:ITextFlowLine):void
+		{
+			// do nothing for now...
+		}
+
+		public function get parentTable():ITableElement
+		{
+			return _parentTable;
+		}
+
+		public function set parentTable(parentTable:ITableElement):void
+		{
+			this._parentTable = parentTable;
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/TextLineRecycler.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/TextLineRecycler.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/TextLineRecycler.as
new file mode 100644
index 0000000..e2ae145
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/TextLineRecycler.as
@@ -0,0 +1,129 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.compose
+{	
+	import org.apache.flex.text.engine.ITextLine;
+	import org.apache.flex.utils.ObjectMap;
+	
+	CONFIG::debug { import org.apache.flex.textLayout.debug.assert; }
+
+	
+
+	
+	
+	/** 
+	 * The TextLineRecycler class provides support for recycling of TextLines.  Some player versions support a recreateTextLine.  Passing TextLines
+	 * to the recycler makes them available for reuse.  This improves Player performance.
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */ 
+	public class TextLineRecycler
+	{
+		static private const _textLineRecyclerCanBeEnabled:Boolean = true;
+		static private var _textLineRecyclerEnabled:Boolean = _textLineRecyclerCanBeEnabled;
+		
+		/** Controls if the TLF recycler enabled.   It can only be enabled in 10.1 or later players.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		static public function get textLineRecyclerEnabled():Boolean
+		{ return _textLineRecyclerEnabled; }
+		static public function set textLineRecyclerEnabled(value:Boolean):void
+		{ _textLineRecyclerEnabled = value ? _textLineRecyclerCanBeEnabled : false; }
+		
+		// manage a cache of ITextLine's that can be reused
+		// This version uses a dictionary that holds the TextLines as weak references
+		static private var reusableLineCache:ObjectMap = new ObjectMap(true);
+		
+		/**
+		 * Add a ITextLine to the pool for reuse. TextLines for reuse should have null userData and null parent. 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+
+		static public function addLineForReuse(textLine:ITextLine):void
+		{
+			CONFIG::debug { assert(textLine.parent == null && textLine.userData == null && (textLine.validity == "invalid" || textLine.validity == "static"),"textLine not ready for reuse"); }
+			if (_textLineRecyclerEnabled)
+			{
+				CONFIG::debug 
+				{
+					for each (var line:ITextLine in reusableLineCache)
+					{
+						 assert(line != textLine,"READDING LINE TO CACHE");
+					}
+				}
+				CONFIG::debug { cacheTotal++; }
+				reusableLineCache[textLine] = null;
+			}
+		} 
+		CONFIG::debug
+		{
+			/** @private */
+			static public var cacheTotal:int = 0;
+			/** @private */
+			static public var fetchTotal:int = 0;
+			/** @private */
+			static public var hitTotal:int = 0;		
+			
+			static private function recordFetch(hit:int):void
+			{
+				fetchTotal++;
+				hitTotal += hit;
+				
+				/*if ((fetchTotal%100) == 0)
+					trace(fetchTotal,hitTotal,cacheTotal);*/
+			}
+		}
+		
+		/**
+		 * Return a ITextLine from the pool for reuse. 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+
+		static public function getLineForReuse():ITextLine
+		{
+			if (_textLineRecyclerEnabled)
+			{
+				for (var obj:Object in reusableLineCache)
+				{
+					// remove from the cache
+					delete reusableLineCache[obj];
+					CONFIG::debug { assert(reusableLineCache[obj] === undefined,"Bad delete"); }
+					CONFIG::debug { recordFetch(1); }
+					return obj as ITextLine;
+				}
+				CONFIG::debug { recordFetch(0); }
+			}
+			return null;
+		}
+		
+		/** @private empty the reusableLineCache */
+		static public function emptyReusableLineCache():void
+		{
+			reusableLineCache = new ObjectMap(true);
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/VerticalJustifier.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/VerticalJustifier.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/VerticalJustifier.as
new file mode 100644
index 0000000..0adee48
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/VerticalJustifier.as
@@ -0,0 +1,351 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.compose
+{
+	import org.apache.flex.textLayout.container.IContainerController;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.formats.BlockProgression;
+	import org.apache.flex.textLayout.formats.Float;
+	import org.apache.flex.textLayout.formats.VerticalAlign;
+
+	
+
+	
+	/** @private
+	 * Adjust line positions according to verticalAlign settings.  Vertical alignment is perpendicular
+	 * to the linebreak direction.
+	 */
+	public final class VerticalJustifier
+	{
+		[ ArrayElementType("org.apache.flex.textLayout.compose.IVerticalJustificationLine") ] 
+		/** Vertical justify the subset of lines from startIndext to startIndex to numLines according to the rule specified by verticalAlignAttr.  
+		 * The assumption is that they are all the lines in a single column of cont. 
+		 * @see text.formats.VerticalAlign
+		 * @return adjustment applied to the first line in the column.
+		 * */
+		static public function applyVerticalAlignmentToColumn(controller:IContainerController, verticalAlignAttr:String, lines:Array, startIndex:int, numLines:int,beginFloatIndex:int,endFloatIndex:int):Number
+		{
+			var helper:IVerticalAdjustmentHelper;
+			if (controller.rootElement.computedFormat.blockProgression == BlockProgression.RL)
+				helper = new RL_VJHelper(controller);
+			else
+				helper = new TB_VJHelper(controller);
+				
+			CONFIG::debug { assert(startIndex + numLines <= lines.length && numLines > 0,"applyVerticalAlignmentToColumn: bad indices"); }
+									
+			var i:int;
+			var rslt:Number;
+			
+			switch(verticalAlignAttr) 
+			{
+				case VerticalAlign.MIDDLE:
+				case VerticalAlign.BOTTOM:
+					var lastLine:IVerticalJustificationLine = lines[(startIndex + numLines) - 1];
+					var bottom:Number = helper.getBottom(lastLine, controller, beginFloatIndex, endFloatIndex);
+					rslt = (verticalAlignAttr == VerticalAlign.MIDDLE) ? helper.computeMiddleAdjustment(bottom) : helper.computeBottomAdjustment(bottom);
+					for (i = startIndex; i < startIndex + numLines; i++)	// Adjust line positions
+						helper.applyAdjustment(lines[i]);
+					for (var floatIndex:int = beginFloatIndex; floatIndex < endFloatIndex; floatIndex++)	// Adjust float positions
+					{
+						var floatInfo:FloatCompositionData = controller.getFloatAt(floatIndex);
+						if (floatInfo.floatType != Float.NONE)
+							helper.applyAdjustmentToFloat(floatInfo);	
+					}
+					break;
+				case VerticalAlign.JUSTIFY:
+					rslt = helper.computeJustifyAdjustment(lines, startIndex, numLines);
+					helper.applyJustifyAdjustment(lines, startIndex, numLines);
+					break;
+			}
+
+			//for (i = startIndex; i < startIndex + numLines; i++)
+			//	trace("x=", sc[i].x, "y=", sc[i].y, "yAdj=", yAdj);
+			return rslt;
+		}
+	}
+}
+
+import org.apache.flex.textLayout.compose.FloatCompositionData;
+import org.apache.flex.textLayout.compose.IVerticalJustificationLine;
+import org.apache.flex.textLayout.compose.ITextFlowLine;
+import org.apache.flex.textLayout.container.IContainerController;
+import org.apache.flex.textLayout.elements.IInlineGraphicElement;
+import org.apache.flex.textLayout.formats.Float;
+
+interface IVerticalAdjustmentHelper
+{
+	function getBottom(line:IVerticalJustificationLine, controller:IContainerController, beginFloat:int, endFloat:int):Number;
+	
+	function computeMiddleAdjustment(bottom:Number):Number;
+	function applyAdjustment(line:IVerticalJustificationLine):void;
+	function applyAdjustmentToFloat(floatInfo:FloatCompositionData):void;
+	
+	function computeBottomAdjustment(bottom:Number):Number;
+	
+	function computeJustifyAdjustment(lineArray:Array, firstLine:int, numLines:int):Number;
+	function applyJustifyAdjustment(lineArray:Array, firstLine:int, numLines:int):void;
+}
+
+class TB_VJHelper implements IVerticalAdjustmentHelper
+{
+	
+
+	
+	private var _textFrame:IContainerController;
+	private var adj:Number;
+	
+	public function TB_VJHelper(tf:IContainerController):void
+	{
+		_textFrame = tf;
+	}
+	
+	public function getBottom(line:IVerticalJustificationLine, controller:IContainerController, beginFloat:int, endFloat:int):Number
+	{
+		var maxBottom:Number = getBaseline(line) + line.descent;
+		for (var i:int = beginFloat; i < endFloat; ++i)
+		{
+			var floatInfo:FloatCompositionData = controller.getFloatAt(i);
+			if (floatInfo.floatType != Float.NONE)
+			{
+				var ilg:IInlineGraphicElement = controller.rootElement.findLeaf(floatInfo.absolutePosition) as IInlineGraphicElement;
+				maxBottom = Math.max(maxBottom, floatInfo.y + ilg.elementHeightWithMarginsAndPadding());
+			}
+		}
+		return maxBottom;
+	}
+	
+	public function getBottomOfLine(line:IVerticalJustificationLine):Number
+	{
+		return getBaseline(line) + line.descent;
+	}
+	
+	private function getBaseline(line:IVerticalJustificationLine):Number
+	{
+		if (line is ITextFlowLine)
+			return line.y + line.ascent;
+		else
+			return line.y;
+	}
+	
+	private function setBaseline(line:IVerticalJustificationLine, pos:Number):void
+	{
+		if (line is ITextFlowLine)
+			line.y = pos - line.ascent;
+		else
+			line.y = pos;
+	}
+	
+	// half of the available adjustment added to each y to shift the lines half way down the frame
+	public function computeMiddleAdjustment(contentBottom:Number):Number
+	{
+		var frameBottom:Number = _textFrame.compositionHeight - Number(_textFrame.getTotalPaddingBottom());
+		adj = (frameBottom - contentBottom) / 2;
+		if (adj < 0)
+			adj = 0; // no space available to redistribute
+		return adj;
+	}
+	// the baseline of the last line should be at the bottom of the frame - paddingBottom.
+	public function computeBottomAdjustment(contentBottom:Number):Number
+	{
+		var frameBottom:Number = _textFrame.compositionHeight - Number(_textFrame.getTotalPaddingBottom());
+		adj = frameBottom - contentBottom;
+		if (adj < 0)
+			adj = 0; // no space available to redistribute
+		return adj;
+	}
+
+	public function applyAdjustment(line:IVerticalJustificationLine):void
+	{
+		line.y = line.y + adj;
+	}
+	
+	public function applyAdjustmentToFloat(floatInfo:FloatCompositionData):void
+	{
+		floatInfo.y += adj;
+	}
+	
+	// one line: untouched, two lines: first line untouched and descent of last line at the bottom of the frame, 
+	// and more than two lines: line spacing increased proportionally, with first line untouched and descent of last line at the bottom of the frame
+	[ ArrayElementType("org.apache.flex.textLayout.compose.IVerticalJustificationLine") ]
+	public function computeJustifyAdjustment(lineArray:Array, firstLineIndex:int, numLines:int):Number
+	{
+		adj = 0;
+		
+		if (numLines == 1)
+		{
+			return 0;	// do nothing
+		}
+		
+		// first line unchanged	
+		var firstLine:IVerticalJustificationLine = lineArray[firstLineIndex];
+		var firstBaseLine:Number =  getBaseline(firstLine);
+
+		// descent of the last line on the bottom of the frame	
+		var lastLine:IVerticalJustificationLine = lineArray[firstLineIndex + numLines - 1];
+		var frameBottom:Number = _textFrame.compositionHeight - Number(_textFrame.getTotalPaddingBottom());
+		var allowance:Number = frameBottom - getBottomOfLine(lastLine);
+		if (allowance < 0)
+		{
+			return 0; // Some text scrolled out; don't justify
+		}
+		var lastBaseLine:Number = getBaseline(lastLine); 
+	
+		adj = allowance/(lastBaseLine - firstBaseLine); // multiplicative factor by which the space between consecutive lines is increased 
+		return adj;
+	}
+	
+	[ ArrayElementType("org.apache.flex.textLayout.compose.IVerticalJustificationLine") ]
+	public function applyJustifyAdjustment(lineArray:Array, firstLineIndex:int, numLines:int):void
+	{ 
+		if (numLines == 1 || adj == 0)
+			return;	// do nothing
+			
+		var firstLine:IVerticalJustificationLine = lineArray[firstLineIndex];
+		var prevBaseLine:Number = getBaseline(firstLine);
+		var prevBaseLineUnjustified:Number = prevBaseLine;
+		
+		var line:IVerticalJustificationLine;
+		var currBaseLine:Number;
+		var currBaseLineUnjustified:Number;
+		
+		for (var i:int = 1; i < numLines; i++)
+		{
+			line = lineArray[i + firstLineIndex];
+			currBaseLineUnjustified = getBaseline(line);
+			
+			// Space between consecutive baselines scaled up by the calculated factor
+			currBaseLine = prevBaseLine  + (currBaseLineUnjustified - prevBaseLineUnjustified)*(1 + adj);
+			setBaseline(line, currBaseLine);
+			
+			prevBaseLineUnjustified = currBaseLineUnjustified;
+			prevBaseLine = currBaseLine;
+		}
+	}
+}
+
+class RL_VJHelper implements IVerticalAdjustmentHelper
+{
+	
+
+
+	private var _textFrame:IContainerController;
+	private var adj:Number = 0;
+	
+	public function RL_VJHelper(tf:IContainerController):void
+	{
+		_textFrame = tf;
+	}
+	
+	public function getBottom(lastLine:IVerticalJustificationLine, controller:IContainerController, beginFloat:int, endFloat:int):Number
+	{
+		var frameWidth:Number = _textFrame.compositionWidth - Number(_textFrame.getTotalPaddingLeft());
+		var maxLeft:Number = (frameWidth + lastLine.x - lastLine.descent);
+		for (var i:int = beginFloat; i < endFloat; ++i)
+		{
+			var floatInfo:FloatCompositionData = controller.getFloatAt(i);
+			if (floatInfo.floatType != Float.NONE)
+				maxLeft = Math.min(maxLeft, floatInfo.x + frameWidth);
+		}
+		return maxLeft;
+	}
+	
+	// half of the available adjustment added to each x to shift the lines half way left across the frame
+	public function computeMiddleAdjustment(contentLeft:Number):Number
+	{
+		adj = contentLeft / 2;
+		if (adj < 0)
+			adj = 0; // no space available to redistribute
+		return -adj;
+	}
+	// the baseline of the last line should be at the bottom of the frame - paddingLeft.
+	public function computeBottomAdjustment(contentLeft:Number):Number
+	{
+		adj = contentLeft;
+		if (adj < 0)
+			adj = 0; // no space available to redistribute
+		return -adj;
+	}
+	
+	public function applyAdjustment(line:IVerticalJustificationLine):void
+	{
+		line.x = (line.x - adj);
+	}
+	
+	public function applyAdjustmentToFloat(floatInfo:FloatCompositionData):void
+	{
+		floatInfo.x -= adj;
+	}
+	
+	// one line: untouched, two lines: first line untouched and descent of last line at the bottom of the frame, 
+	// and more than two lines: line spacing increased proportionally, with first line untouched and descent of last line at the bottom of the frame
+	[ ArrayElementType("org.apache.flex.textLayout.compose.IVerticalJustificationLine") ]
+	public function computeJustifyAdjustment(lineArray:Array, firstLineIndex:int, numLines:int):Number
+	{ 
+		adj = 0;
+		
+		if (numLines == 1)
+			return 0;	// do nothing
+			
+		// first line unchanged
+		var firstLine:IVerticalJustificationLine = lineArray[firstLineIndex];
+		var firstBaseLine:Number =  firstLine.x;
+		
+		// descent of the last line on the left of the frame	
+		var lastLine:IVerticalJustificationLine = lineArray[firstLineIndex + numLines - 1];
+		var frameLeft:Number =  Number(_textFrame.getTotalPaddingLeft()) - _textFrame.compositionWidth;
+		var allowance:Number = (lastLine.x - lastLine.descent) - frameLeft;
+		if (allowance < 0)
+		{
+			return 0; // Some text scrolled out; don't justify
+		}
+		var lastBaseLine:Number = lastLine.x;  
+		
+		adj = allowance/(firstBaseLine - lastBaseLine);  // multiplicative factor by which the space between consecutive lines is increased 
+		return -adj;
+	}
+	
+	[ ArrayElementType("org.apache.flex.textLayout.compose.IVerticalJustificationLine") ]
+	public function applyJustifyAdjustment(lineArray:Array, firstLineIndex:int, numLines:int):void
+	{
+		if (numLines == 1 || adj == 0)
+			return;	// do nothing
+			
+		var firstLine:IVerticalJustificationLine = lineArray[firstLineIndex];
+		var prevBaseLine:Number = firstLine.x;
+		var prevBaseLineUnjustified:Number = prevBaseLine;
+		
+		var line:IVerticalJustificationLine;
+		var currBaseLine:Number;
+		var currBaseLineUnjustified:Number;
+		
+		for (var i:int = 1; i < numLines; i++)
+		{
+			line = lineArray[i + firstLineIndex];
+			currBaseLineUnjustified = line.x;
+			
+			// Space between consecutive baselines scaled up by the calculated factor
+			currBaseLine = prevBaseLine - (prevBaseLineUnjustified - currBaseLineUnjustified)*(1 + adj);
+			line.x = currBaseLine;
+			
+			prevBaseLineUnjustified = currBaseLineUnjustified;
+			prevBaseLine = currBaseLine;
+		}		
+	}
+	
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/utils/AdornmentUtils.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/utils/AdornmentUtils.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/utils/AdornmentUtils.as
new file mode 100644
index 0000000..477e386
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/utils/AdornmentUtils.as
@@ -0,0 +1,685 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.compose.utils
+{
+	import org.apache.flex.textLayout.elements.utils.GeometricElementUtils;
+	import org.apache.flex.core.IUIBase;
+	import org.apache.flex.textLayout.dummy.BoundsUtil;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	import org.apache.flex.textLayout.elements.ISubParagraphGroupElementBase;
+	import org.apache.flex.textLayout.formats.Float;
+	import org.apache.flex.graphics.SolidColor;
+	import org.apache.flex.textLayout.elements.ITCYElement;
+	import org.apache.flex.text.engine.TextBaseline;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.graphics.SolidColorStroke;
+	import org.apache.flex.textLayout.formats.JustificationRule;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.graphics.PathBuilder;
+	import org.apache.flex.graphics.ICompoundGraphic;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.formats.BackgroundColor;
+	import org.apache.flex.textLayout.formats.TextDecoration;
+	import org.apache.flex.text.engine.TextRotation;
+	import org.apache.flex.textLayout.compose.ITextFlowLine;
+	import org.apache.flex.textLayout.formats.BlockProgression;
+	import org.apache.flex.core.IParentIUIBase;
+	import org.apache.flex.textLayout.elements.InlineGraphicElementStatus;
+	import org.apache.flex.textLayout.elements.IInlineGraphicElement;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+	import org.apache.flex.textLayout.formats.BaselineShift;
+	import org.apache.flex.geom.Rectangle;
+	import org.apache.flex.textLayout.formats.IMEStatus;
+	import org.apache.flex.text.engine.FontMetrics;
+	import org.apache.flex.textLayout.utils.CharacterUtil;
+	import org.apache.flex.text.engine.ITextLine;
+	import org.apache.flex.textLayout.elements.IFlowLeafElement;
+
+	public class AdornmentUtils
+	{
+				/** @private */
+		public static function getSpanBoundsOnLine(element:IFlowLeafElement,textLine:ITextLine, blockProgression:String):Array
+		{
+			var line:ITextFlowLine = ITextFlowLine(textLine.userData);
+			var paraStart:int = line.paragraph.getAbsoluteStart();
+			var lineEnd:int = (line.absoluteStart + line.textLength) - paraStart;
+			var spanStart:int = element.getAbsoluteStart() - paraStart;		// get start pos relative to the paragraph (which might not be the parent)
+			var endPos:int = spanStart + element.text.length;		// so we don't include the paragraph terminator character, if present
+		
+			// Clip to start of line	
+			var startPos:int = Math.max(spanStart, line.absoluteStart - paraStart);
+			
+			// Clip to end of line	
+			// Heuristic for detecting spaces at the end of the line and eliminating them from the range so they won't be underlined.
+			if (endPos >= lineEnd)
+			{
+				endPos = lineEnd;
+				var spanText:String = element.text;
+				while (endPos > startPos && CharacterUtil.isWhitespace(spanText.charCodeAt(endPos - spanStart - 1)))
+					--endPos;
+			}
+
+			var mainRects:Array = [];
+			line.calculateSelectionBounds(textLine, mainRects, startPos, endPos, blockProgression, [ line.textHeight,0]);
+			return mainRects;
+		}
+		
+				/** @private */
+		static public function calculateStrikeThrough(element:IFlowLeafElement, textLine:ITextLine, blockProgression:String, metrics:FontMetrics):Number
+		{
+			if(element.className == "InlineGraphicElement" && IInlineGraphicElement(element).graphic && IInlineGraphicElement(element).status == InlineGraphicElementStatus.READY)
+				return calculateGraphicStrikeThrough(IInlineGraphicElement(element), textLine, blockProgression, metrics);
+			else
+				return calculateLeafStrikeThrough(element, textLine, blockProgression, metrics);
+			
+		}
+		/**
+		 * @flexjsignorecoercion org.apache.flex.core.IParentIUIBase
+		 * @flexjsignorecoercion org.apache.flex.textLayout.compose.ITextFlowLine
+		 */
+		static private function calculateGraphicStrikeThrough(element:IInlineGraphicElement, textLine:ITextLine, blockProgression:String, metrics:FontMetrics):Number
+		{
+			var stOffset:Number = 0;
+            var inlineHolder:IParentIUIBase = element.placeholderGraphic.parent as IParentIUIBase;
+            if (inlineHolder)
+            {
+                if(blockProgression != BlockProgression.RL)
+                    stOffset = Object(element.placeholderGraphic.parent).y + (element.elementHeight/2 + Number(element.getEffectivePaddingTop()));
+                else
+                {
+                    var paddingRight:Number = element.getEffectivePaddingRight();
+                    var line:ITextFlowLine = textLine.userData as ITextFlowLine;
+                    var elemIdx:int = element.getAbsoluteStart() - line.absoluteStart;
+                    if(textLine.getAtomTextRotation(elemIdx) != TextRotation.ROTATE_0)
+                        stOffset = Object(element.placeholderGraphic.parent).x - (element.elementHeight/2 + paddingRight);
+                    else
+                        stOffset = Object(element.placeholderGraphic.parent).x - (element.elementWidth/2 + paddingRight);
+                }
+            }
+            
+            return blockProgression == BlockProgression.TB ? stOffset : -stOffset;
+		}
+		static private function calculateLeafStrikeThrough(element:IFlowLeafElement, textLine:ITextLine, blockProgression:String, metrics:FontMetrics):Number
+		{
+			var underlineAndStrikeThroughShift:int = 0;	
+			var effectiveFontSize:Number = element.getEffectiveFontSize();
+			if (element.computedFormat.baselineShift == BaselineShift.SUPERSCRIPT)
+			{
+				underlineAndStrikeThroughShift = -(metrics.superscriptOffset * effectiveFontSize);
+			} else if (element.computedFormat.baselineShift == BaselineShift.SUBSCRIPT)
+			{
+				underlineAndStrikeThroughShift = -(metrics.subscriptOffset * (effectiveFontSize / metrics.subscriptScale));
+			} else {
+				underlineAndStrikeThroughShift = TextLayoutFormat.baselineShiftProperty.computeActualPropertyValue(element.computedFormat.baselineShift, effectiveFontSize);
+			}
+			
+			//grab the dominantBaseline and alignmentBaseline strings
+			var domBaselineString:String = GeometricElementUtils.resolveDomBaseline(element.computedFormat, element.getParagraph());
+			var alignmentBaselineString:String = element.computedFormat.alignmentBaseline;
+			
+			//this value represents the position of the baseline used to align this text
+			var alignDomBaselineAdjustment:Number = textLine.getBaselinePosition(domBaselineString);
+			
+			//if the alignment baseline differs from the dominant, then we need to apply the delta between the
+			//dominant and the alignment to determine the line along which the glyphs are lining up...
+			if(alignmentBaselineString != org.apache.flex.text.engine.TextBaseline.USE_DOMINANT_BASELINE && 
+				alignmentBaselineString != domBaselineString)
+			{
+				alignDomBaselineAdjustment = textLine.getBaselinePosition(alignmentBaselineString);
+				//take the alignmentBaseline offset and make it relative to the dominantBaseline
+			}
+			
+			
+			//first, establish the offset relative to the glyph based in fontMetrics data
+			var stOffset:Number = metrics.strikethroughOffset;
+			
+			
+			//why are we using the stOffset?  Well, the stOffset effectively tells us where the mid-point
+			//of the glyph is.  By using this value, we can determine how we need to offset the underline.
+			//now adjust the value.  If it is center, then the glyphs are aligned along the ST position already
+			if(domBaselineString == org.apache.flex.text.engine.TextBaseline.IDEOGRAPHIC_CENTER)
+			{
+				stOffset = 0;
+			}
+			else if(domBaselineString == org.apache.flex.text.engine.TextBaseline.IDEOGRAPHIC_TOP || 
+				domBaselineString == org.apache.flex.text.engine.TextBaseline.ASCENT)
+			{
+				stOffset *= -2;  //if the glyphs are top or ascent, then we need to invert and double the offset
+				stOffset -= (2 * metrics.strikethroughThickness);
+			}
+			else if(domBaselineString == org.apache.flex.text.engine.TextBaseline.IDEOGRAPHIC_BOTTOM || 
+				domBaselineString == org.apache.flex.text.engine.TextBaseline.DESCENT)
+			{
+				stOffset *= 2; //if they're bottom, then we need to simply double it
+				stOffset += (2 * metrics.strikethroughThickness);
+			}
+			else //Roman
+			{
+				stOffset -= metrics.strikethroughThickness;
+			}
+			
+			
+			//Now apply the actual dominant baseline position to the offset
+			stOffset += (alignDomBaselineAdjustment - underlineAndStrikeThroughShift);
+			return stOffset;
+		}
+				/** @private return number of shapes added */
+		static public function updateAdornments(element:IFlowLeafElement, tLine:ITextLine, blockProgression:String):int
+		{
+			CONFIG::debug { assert(element.computedFormat != null,"invalid call to updateAdornments"); }
+			
+			// Don't underline for floats
+			if(element.className == "InlineGraphicElement" && Object(element).effectiveFloat != Float.NONE)
+				return 0;
+			if(element.className == "TableLeafElement")
+				return 0;
+
+			// Only work on lines with strikethrough or underline
+			if (element.computedFormat.textDecoration == TextDecoration.UNDERLINE || element.computedFormat.lineThrough || element.computedFormat.backgroundAlpha > 0 && element.computedFormat.backgroundColor != BackgroundColor.TRANSPARENT)
+			{
+				var spanBoundsArray:Array = getSpanBoundsOnLine(element, tLine, blockProgression);
+				for (var i:int = 0; i < spanBoundsArray.length; i++)
+					updateAdornmentsOnBounds(element, tLine, blockProgression, spanBoundsArray[i]);
+				return spanBoundsArray.length ;
+			}
+			return 0;
+		}
+		
+		/**
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.IParagraphElement
+		 */
+		static private function updateAdornmentsOnBounds(element:IFlowLeafElement, tLine:ITextLine, blockProgression:String, spanBounds:Rectangle):void
+		{
+			CONFIG::debug { assert(element.computedFormat != null,"invalid call to updateAdornmentsOnBounds"); }
+
+			var metrics:FontMetrics = element.getComputedFontMetrics();
+
+
+			var backgroundOnly:Boolean = !(element.computedFormat.textDecoration == TextDecoration.UNDERLINE || element.computedFormat.lineThrough);
+				
+			if (!backgroundOnly)
+			{
+				var shape:ICompoundGraphic;
+				shape = element.getTextFlow().tlfFactory.getCompoundGraphic();
+				shape.alpha = Number(element.computedFormat.textAlpha);
+				var builder:PathBuilder = new PathBuilder();
+				shape.stroke = new SolidColorStroke();
+						
+				var stOffset:Number = calculateStrikeThrough(element,tLine, blockProgression, metrics);
+				var ulOffset:Number = calculateUnderlineOffset(element, stOffset, blockProgression, metrics, tLine);
+			}
+						
+			if (blockProgression != BlockProgression.RL)
+			{
+				addBackgroundRect (element, tLine, metrics, spanBounds, true); 
+
+				if (element.computedFormat.textDecoration == TextDecoration.UNDERLINE)
+				{
+					shape.stroke.setLineStyle(metrics.underlineThickness, element.computedFormat.color as uint);
+					builder.moveTo(spanBounds.topLeft.x, ulOffset);
+					builder.lineTo(spanBounds.topLeft.x + spanBounds.width, ulOffset);
+					shape.drawPathCommands(builder);
+					builder.clear();
+//					g.lineStyle(metrics.underlineThickness, _computedFormat.color as uint);
+//					g.moveTo(spanBounds.topLeft.x, ulOffset);
+//					g.lineTo(spanBounds.topLeft.x + spanBounds.width, ulOffset);
+				}
+				
+				if((element.computedFormat.lineThrough))
+				{
+					shape.stroke.setLineStyle(metrics.strikethroughThickness, element.computedFormat.color as uint);
+					builder.moveTo(spanBounds.topLeft.x, stOffset);
+					builder.lineTo(spanBounds.topLeft.x + spanBounds.width, stOffset);
+					shape.drawPathCommands(builder);
+					builder.clear();
+					
+//					g.lineStyle(metrics.strikethroughThickness, _computedFormat.color as uint);
+//					g.moveTo(spanBounds.topLeft.x, stOffset);
+//					g.lineTo(spanBounds.topLeft.x + spanBounds.width, stOffset);
+				}
+			}
+			else
+			{
+				//is this TCY?
+				var line:ITextFlowLine = tLine.userData as ITextFlowLine;
+				var elemIdx:int = element.getAbsoluteStart() - line.absoluteStart;
+				
+				//elemIdx can sometimes be negative if the text is being wrapped due to a
+				//resize gesture - in which case the tLine has not necessarily been updated.
+				//If the elemIdx is invalid, just treat it like it's normal ttb text - gak 07.08.08
+				if (elemIdx < 0 || tLine.atomCount <= elemIdx || tLine.getAtomTextRotation(elemIdx) != TextRotation.ROTATE_0)
+				{
+					addBackgroundRect (element, tLine, metrics, spanBounds, false);
+
+					if (element.computedFormat.textDecoration == TextDecoration.UNDERLINE)
+					{
+						shape.stroke.setLineStyle(metrics.underlineThickness, element.computedFormat.color as uint);
+						builder.moveTo(ulOffset, spanBounds.topLeft.y);
+						builder.lineTo(ulOffset, spanBounds.topLeft.y + spanBounds.height);
+						shape.drawPathCommands(builder);
+						builder.clear();
+						
+//						g.lineStyle(metrics.underlineThickness, _computedFormat.color as uint);
+//						g.moveTo(ulOffset, spanBounds.topLeft.y);
+//						g.lineTo(ulOffset, spanBounds.topLeft.y + spanBounds.height);
+					}
+					
+					if (element.computedFormat.lineThrough == true)
+					{
+						shape.stroke.setLineStyle(metrics.strikethroughThickness, element.computedFormat.color as uint);
+						builder.moveTo(-stOffset, spanBounds.topLeft.y);
+						builder.lineTo(-stOffset, spanBounds.topLeft.y + spanBounds.height);
+						shape.drawPathCommands(builder);
+						builder.clear();
+	
+//						g.lineStyle(metrics.strikethroughThickness, _computedFormat.color as uint);
+//						g.moveTo(-stOffset, spanBounds.topLeft.y);
+//						g.lineTo(-stOffset, spanBounds.topLeft.y + spanBounds.height);															
+					}
+				}
+				else
+				{
+					addBackgroundRect (element, tLine, metrics, spanBounds, true, true); 
+					
+					if (!backgroundOnly)
+					{
+						//it is TCY!
+						var tcyParent:ITCYElement =  element.getParentByType("TCYElement") as ITCYElement;
+						CONFIG::debug{ assert(tcyParent != null, "What kind of object is this that is ROTATE_0, but not TCY?");}
+						
+						//if the locale of the paragraph is Chinese, we need to adorn along the left and not right side.
+						var tcyPara:IParagraphElement = element.getParentByType("ParagraphElement") as IParagraphElement;
+						var lowerLocale:String = tcyPara.computedFormat.locale.toLowerCase();
+						var adornRight:Boolean = (lowerLocale.indexOf("zh") != 0);
+						
+						
+						//only perform calculations for TCY adornments when we are on the last leaf.  ONLY the last leaf matters
+						if((element.getAbsoluteStart() + element.textLength) == (tcyParent.getAbsoluteStart() + tcyParent.textLength))
+						{
+							var tcyAdornBounds:Rectangle = new Rectangle();
+							calculateAdornmentBounds(tcyParent, tLine, blockProgression, tcyAdornBounds);
+							
+							if (element.computedFormat.textDecoration == TextDecoration.UNDERLINE)
+							{
+								shape.stroke.setLineStyle(metrics.underlineThickness, element.computedFormat.color as uint);
+//								g.lineStyle(metrics.underlineThickness, _computedFormat.color as uint);
+								var baseULAdjustment:Number = metrics.underlineOffset + (metrics.underlineThickness/2);
+								var xCoor:Number = adornRight ? spanBounds.right : spanBounds.left;
+								if(!adornRight)
+									baseULAdjustment = -baseULAdjustment;
+								
+								builder.moveTo(xCoor + baseULAdjustment, tcyAdornBounds.top);
+								builder.lineTo(xCoor + baseULAdjustment, tcyAdornBounds.bottom);
+								shape.drawPathCommands(builder);
+								builder.clear();
+								
+//								g.moveTo(xCoor + baseULAdjustment, tcyAdornBounds.top);
+//								g.lineTo(xCoor + baseULAdjustment, tcyAdornBounds.bottom);
+							}
+	
+							if (element.computedFormat.lineThrough == true)
+							{
+								var tcyMid:Number = spanBounds.bottomRight.x - tcyAdornBounds.x;
+								tcyMid /= 2;
+								tcyMid += tcyAdornBounds.x;
+								
+								shape.stroke.setLineStyle(metrics.strikethroughThickness, element.computedFormat.color as uint);
+								builder.moveTo(tcyMid, tcyAdornBounds.top);
+								builder.lineTo(tcyMid, tcyAdornBounds.bottom);
+								shape.drawPathCommands(builder);
+								builder.clear();
+								
+//								g.lineStyle(metrics.strikethroughThickness, _computedFormat.color as uint);
+//								g.moveTo(tcyMid, tcyAdornBounds.top);
+//								g.lineTo(tcyMid, tcyAdornBounds.bottom);
+							}
+						}
+					}
+				}
+			}
+			
+		 	// Add the shape as a child of the ITextLine. In some cases, the textLine we passed through may not be the same one that's
+			// in the TextFlowLine textLineCache. This can happen if the TextFlowLine's textLine is invalid and a child of the 
+			// container. In that case, we generated a valid ITextLine and passed it in as tLine so that we have correct metrics 
+			// for generating the adornment shapes.
+			if (shape)
+			{
+	 			var peekLine:ITextLine = (tLine.userData as ITextFlowLine).peekTextLine();
+				CONFIG::debug{ assert(peekLine == null || peekLine == tLine || peekLine.validity == "invalid", "Valid/invalid mismatch"); }
+				// CONFIG::debug{ assert(peekLine == null || peekLine == TextFlowLine(tLine.userData).getTextLine(false), "Valid/invalid mismatch"); }
+				if (peekLine && tLine != peekLine)
+				{
+					// belief is that this line of code is never hit
+					CONFIG::debug { assert(false,"updateAdornmentsOnBounds: peekLine doesn't match textLine"); }
+					tLine = peekLine;
+				}
+				tLine.addElement(shape);
+			}
+		}
+		
+		/**
+		 * @flexjsignorecoercion org.apache.flex.textLayout.compose.ITextFlowLine
+		 */
+		public static function updateIMEAdornments(element:IFlowLeafElement,tLine:ITextLine, blockProgression:String, imeStatus:String):void
+		{
+			// Don't underline for floats
+			if(element.className == "InlineGraphicElement" && Object(element).effectiveFloat != Float.NONE)
+				return;
+
+			if(element.className == "TableLeafElement")
+				return ;
+
+			var metrics:FontMetrics = element.getComputedFontMetrics();
+			var spanBoundsArray:Array = getSpanBoundsOnLine(element,tLine, blockProgression);
+			//this is pretty much always going to have a length of 1, but just to be sure...
+			for (var i:int = 0; i < spanBoundsArray.length; i++)
+			{
+				//setup ime variables
+				var imeLineThickness:int = 1;
+				var imeLineColor:uint = 0x000000;
+				var imeLineStartX:Number = 0;
+				var imeLineStartY:Number = 0;
+				var imeLineEndX:Number = 0;
+				var imeLineEndY:Number = 0;
+				
+				//selected text draws with 2 px
+				if(imeStatus == IMEStatus.SELECTED_CONVERTED || imeStatus == IMEStatus.SELECTED_RAW)
+				{
+					imeLineThickness = 2;
+				}
+				//Raw or deadkey text draws with grey
+				if(imeStatus == IMEStatus.SELECTED_RAW || imeStatus == IMEStatus.NOT_SELECTED_RAW
+					|| imeStatus == IMEStatus.DEAD_KEY_INPUT_STATE)
+				{
+					imeLineColor = 0xA6A6A6;
+				}
+				
+				var spanBounds:Rectangle = spanBoundsArray[i] as Rectangle;
+				var stOffset:Number = calculateStrikeThrough(element, tLine, blockProgression, metrics);
+				var ulOffset:Number = calculateUnderlineOffset(element, stOffset, blockProgression, metrics, tLine);
+				
+				if (blockProgression != BlockProgression.RL)
+				{
+					imeLineStartX = spanBounds.topLeft.x + 1;
+					imeLineEndX = spanBounds.topLeft.x + spanBounds.width - 1;
+					imeLineStartY = ulOffset;
+					imeLineEndY = ulOffset;
+				}
+				else
+				{
+					//is this TCY?
+					var line:ITextFlowLine = tLine.userData as ITextFlowLine;
+					var elemIdx:int = element.getAbsoluteStart() - line.absoluteStart;
+					imeLineStartY = spanBounds.topLeft.y + 1;
+					imeLineEndY = spanBounds.topLeft.y + spanBounds.height - 1;
+					
+					//elemIdx can sometimes be negative if the text is being wrapped due to a
+					//resize gesture - in which case the tLine has not necessarily been updated.
+					//If the elemIdx is invalid, just treat it like it's normal ttb text - gak 07.08.08
+					if(elemIdx < 0 || tLine.atomCount <= elemIdx || tLine.getAtomTextRotation(elemIdx) != TextRotation.ROTATE_0)
+					{
+						imeLineStartX = ulOffset;
+						imeLineEndX = ulOffset;
+					}
+					else
+					{
+						//it is TCY!
+						var tcyParent:ITCYElement =  element.getParentByType("TCYElement") as ITCYElement;
+						CONFIG::debug{ assert(tcyParent != null, "What kind of object is this that is ROTATE_0, but not TCY?");}
+						
+						//only perform calculations for TCY adornments when we are on the last leaf.  ONLY the last leaf matters
+						if((element.getAbsoluteStart() + element.textLength) == (tcyParent.getAbsoluteStart() + tcyParent.textLength))
+						{
+							var tcyAdornBounds:Rectangle = new Rectangle();	// NO PMD
+							calculateAdornmentBounds(tcyParent, tLine, blockProgression, tcyAdornBounds);
+							var baseULAdjustment:Number = metrics.underlineOffset + (metrics.underlineThickness/2);
+							
+							imeLineStartY = tcyAdornBounds.top + 1;
+							imeLineEndY = tcyAdornBounds.bottom - 1;
+							imeLineStartX = spanBounds.bottomRight.x + baseULAdjustment;
+							imeLineEndX = spanBounds.bottomRight.x + baseULAdjustment;
+						}
+					}
+				}
+				
+				//Build the shape
+				var selObj:ICompoundGraphic = element.getTextFlow().tlfFactory.getCompoundGraphic();	// NO PMD
+				//TODO - this is probably going to need to be overridable in the full implementation
+				selObj.alpha = 1;
+				selObj.fill = new SolidColor(imeLineColor);
+//				selObj.graphics.beginFill(imeLineColor);
+				
+				selObj.stroke = new SolidColorStroke(imeLineColor,imeLineThickness,selObj.alpha);
+//				selObj.graphics.lineStyle(imeLineThickness, imeLineColor, selObj.alpha);
+//				selObj.graphics.moveTo(imeLineStartX, imeLineStartY);
+//				selObj.graphics.lineTo(imeLineEndX, imeLineEndY);
+				var builder:PathBuilder = new PathBuilder(true);
+				builder.moveTo(imeLineStartX, imeLineStartY);
+				builder.lineTo(imeLineEndX, imeLineEndY);
+				selObj.drawPathCommands(builder);
+//				selObj.graphics.endFill();
+				tLine.addElement(selObj);
+			}
+		}
+	
+		static public function calculateUnderlineOffset(element:IFlowLeafElement, stOffset:Number, blockProgression:String, metrics:FontMetrics, textLine:ITextLine):Number
+		{
+			if(element.className == "InlineGraphicElement" && IInlineGraphicElement(element).graphic && IInlineGraphicElement(element).status == InlineGraphicElementStatus.READY)
+				return calculateGraphicUnderlineOffset(IInlineGraphicElement(element), stOffset, blockProgression, metrics, textLine);
+			else
+				return calculateLeafUnderlineOffset(element, stOffset, blockProgression, metrics, textLine);
+		
+		}
+		
+		static private function calculateLeafUnderlineOffset(element:IFlowLeafElement, stOffset:Number, blockProgression:String, metrics:FontMetrics, textLine:ITextLine):Number
+		{
+			var ulOffset:Number = metrics.underlineOffset + metrics.underlineThickness;
+			var baseSTAdjustment:Number = metrics.strikethroughOffset;
+			
+			//based on the stOffset - which really represents the middle of the glyph, set the ulOffset
+			//which will always be relative.  Note that simply using the alignDomBaselineAdjustment is not enough
+			if(blockProgression != BlockProgression.RL)
+				ulOffset += (stOffset - baseSTAdjustment) + metrics.underlineThickness/2;
+			else
+			{	
+				var para:IParagraphElement = element.getParagraph();
+
+				if (para.computedFormat.locale.toLowerCase().indexOf("zh") == 0)
+				{
+					ulOffset = -ulOffset;
+					ulOffset -= (stOffset - baseSTAdjustment + (metrics.underlineThickness*2));
+				}
+				else
+					ulOffset -= (-ulOffset + stOffset + baseSTAdjustment + (metrics.underlineThickness/2));
+			}
+			
+			return ulOffset;
+		}
+	
+	        /**
+         *  @private 
+         *  @flexjsignorecoercion org.apache.flex.core.IParentIUIBase
+         */
+        static private function calculateGraphicUnderlineOffset(element:IInlineGraphicElement, stOffset:Number, blockProgression:String, metrics:FontMetrics, tLine:ITextLine):Number
+        {
+            var para:IParagraphElement = element.getParagraph();
+            var ulOffset:Number = 0;
+            var inlineHolder:IParentIUIBase = element.placeholderGraphic.parent as IParentIUIBase;
+            if (inlineHolder)
+            {
+                if(blockProgression == BlockProgression.TB)
+                    ulOffset = inlineHolder.y + element.elementHeightWithMarginsAndPadding();
+                else
+                {                   
+                    if (para.computedFormat.locale.toLowerCase().indexOf("zh") == 0)
+                    {
+                        ulOffset = inlineHolder.x - element.elementHeightWithMarginsAndPadding();
+                        ulOffset -= metrics.underlineOffset + (metrics.underlineThickness/2);
+                        return ulOffset;
+                    }
+                    else
+                        ulOffset = inlineHolder.x - element.getEffectivePaddingLeft();
+                }
+            }   
+            ulOffset += metrics.underlineOffset + (metrics.underlineThickness/2);
+            
+            var justRule:String = para.getEffectiveJustificationRule();
+            if(justRule == JustificationRule.EAST_ASIAN)
+                ulOffset += 1;
+        
+            return ulOffset;
+        }
+		
+				/** @private
+		 * Adds the background rectangle (if needed), making adjustments for glyph shifting as appropriate
+		 */
+		 static private function addBackgroundRect(element:IFlowLeafElement, tLine:ITextLine, metrics:FontMetrics, spanBounds:Rectangle, horizontalText:Boolean, isTCY:Boolean=false):void
+		 {
+			if(element.computedFormat.backgroundAlpha == 0 || element.computedFormat.backgroundColor == BackgroundColor.TRANSPARENT)
+				return;
+				
+			var tf:ITextFlow = element.getTextFlow();
+			// ensure the TextFlow has a background manager - but its only supported with the StandardFlowComposer at this time			
+			if (!tf.getBackgroundManager())
+				return;
+					
+			// The background rectangle usually needs to coincide with the passsed-in span bounds.
+			var r:Rectangle = spanBounds.clone();
+			
+			// With constrained glyph shifting (such as when superscript/subscript are in use), we'd like the
+			// background rectangle to follow the glyphs. Not so for arbitrary glyph shifting (such as when 
+			// baseline shift or baseline alignment are in use)	 	
+			// TODO-06/12/2009: Need to figure out adjustment for TCY background rect. No adjustment for now.
+			if (!isTCY && (element.computedFormat.baselineShift == BaselineShift.SUPERSCRIPT || element.computedFormat.baselineShift == BaselineShift.SUBSCRIPT))
+			{	
+				// The atom bounds returned by FTE do not reflect the effect of glyph shifting.
+				// We approximate this effect by making the following assumptions (strikethrough/underline code does the same)
+				// - The strike-through adornment runs through the center of the glyph
+				// - The Roman baseline is halfway between the center and bottom (descent)
+				// Effectively, the glyph's descent equals the strike-through offset, and its ascent is three times that
+				
+				var desiredExtent:Number; // The desired extent of the rectangle in the block progression direction
+				var baselineShift:Number; 
+				var fontSize:Number = element.getEffectiveFontSize();
+				var baseStrikethroughOffset:Number = metrics.strikethroughOffset + metrics.strikethroughThickness/2;
+				
+				if (element.computedFormat.baselineShift == BaselineShift.SUPERSCRIPT)
+				{
+					// The rectangle needs to sit on the line's descent and must extend far enough to accommodate the
+					// ascender of the glyph (that has moved up because of superscript)
+					
+					var glyphAscent:Number = -3 * baseStrikethroughOffset; // see assumptions above
+					baselineShift = -metrics.superscriptOffset * fontSize;
+					var lineDescent:Number = tLine.getBaselinePosition(TextBaseline.DESCENT) - tLine.getBaselinePosition(TextBaseline.ROMAN);
+					
+					desiredExtent = glyphAscent  + baselineShift + lineDescent;
+					if (horizontalText)
+					{
+						if (desiredExtent > r.height)
+						{
+							r.y -= desiredExtent - r.height;
+							r.height = desiredExtent;
+						}
+					}
+					else
+					{
+						if (desiredExtent > r.width)
+							r.width = desiredExtent;
+					}
+				}
+				else
+				{
+					// The rectangle needs to hang from the line's ascent and must extend far enough to accommodate the
+					// descender of the glyph (that has moved down because of superscript)
+					
+					var glyphDescent:Number = -baseStrikethroughOffset; // see assumptions above
+					baselineShift = metrics.subscriptOffset * fontSize; 
+					var lineAscent:Number = tLine.getBaselinePosition(TextBaseline.ROMAN) - tLine.getBaselinePosition(TextBaseline.ASCENT);
+					
+					desiredExtent = lineAscent + baselineShift + glyphDescent;
+					if (horizontalText)
+					{
+						if (desiredExtent > r.height)
+							r.height = desiredExtent;
+					}
+					else
+					{
+						if (desiredExtent > r.width)
+						{
+							r.x -= desiredExtent - r.width;
+							r.width = desiredExtent;
+						}
+					}
+				}
+			}
+			
+			tf.backgroundManager.addRect(tLine, element, r, element.computedFormat.backgroundColor, element.computedFormat.backgroundAlpha);	 
+		}
+		
+				/**
+		 *  @private
+		 *  @flexjsignorecoercion org.apache.flex.core.IUIBase
+		 *  @flexjsignorecoercion org.apache.flex.textLayout.elements.IFlowLeafElement
+		 */
+		static public function calculateAdornmentBounds(spg:ISubParagraphGroupElementBase, tLine:ITextLine, blockProgression:String, spgRect:Rectangle):void
+		{
+			var childCount:int = 0;
+			while(childCount < spg.numChildren)
+			{
+				var curChild:IFlowElement = spg.getChildAt(childCount) as IFlowElement;
+				var curFlowLeaf:IFlowLeafElement = curChild as IFlowLeafElement;
+				if(!curFlowLeaf && curChild is ISubParagraphGroupElementBase)
+				{
+					calculateAdornmentBounds(curChild as ISubParagraphGroupElementBase, tLine, blockProgression, spgRect);
+					++childCount;
+					continue;
+				}
+				
+				CONFIG::debug{ assert(curFlowLeaf != null, "The TCY contains a non-FlowLeafElement!  Cannot calculate mirror!");}
+				var curBounds:Rectangle = null;
+				if(!(curFlowLeaf is IInlineGraphicElement))
+					curBounds = getSpanBoundsOnLine(curFlowLeaf, tLine, blockProgression)[0];
+				else
+				{
+					curBounds = BoundsUtil.getBounds(curFlowLeaf as IUIBase, tLine);// (curFlowLeaf as InlineGraphicElement).graphic.getBounds(tLine);
+				}
+				
+				if(childCount != 0)
+				{
+					if(curBounds.top < spgRect.top)
+						spgRect.top = curBounds.top;
+						
+					if(curBounds.bottom > spgRect.bottom)
+						spgRect.bottom = curBounds.bottom;
+					
+					if(spgRect.x > curBounds.x)
+						spgRect.x = curBounds.x;
+				}
+				else
+				{
+					spgRect.top = curBounds.top;
+					spgRect.bottom = curBounds.bottom;
+					spgRect.x = curBounds.x;
+				}
+				++childCount;
+			}
+		}
+		
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/utils/ContextUtil.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/utils/ContextUtil.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/utils/ContextUtil.as
new file mode 100644
index 0000000..5feb5b1
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/utils/ContextUtil.as
@@ -0,0 +1,31 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.compose.utils
+{
+	import org.apache.flex.textLayout.compose.ISWFContext;
+
+	public class ContextUtil
+	{
+				/** @private - helper function for finding a base swf context from a swf context */
+		public static function computeBaseSWFContext(context:ISWFContext):ISWFContext
+		{
+			return context && Object(context).hasOwnProperty("getBaseSWFContext") ? context["getBaseSWFContext"]() : context;
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/utils/FactoryHelper.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/utils/FactoryHelper.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/utils/FactoryHelper.as
new file mode 100644
index 0000000..4bb96b4
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/utils/FactoryHelper.as
@@ -0,0 +1,36 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.compose.utils
+{
+	import org.apache.flex.textLayout.compose.IFactoryComposer;
+	import org.apache.flex.textLayout.compose.ISimpleCompose;
+	import org.apache.flex.textLayout.utils.FactoryUtil;
+	public class FactoryHelper
+	{
+		static public function getComposer():IFactoryComposer
+		{
+			if(!composerClass)
+				composerClass = FactoryUtil.getDefaultFlowComposerClass();
+
+			return new composerClass();
+		}
+		static public var composerClass:Class;
+		static public var staticComposer:ISimpleCompose;
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/utils/NumberLineUserData.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/utils/NumberLineUserData.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/utils/NumberLineUserData.as
new file mode 100644
index 0000000..831c753
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/utils/NumberLineUserData.as
@@ -0,0 +1,42 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.compose.utils
+{
+	import org.apache.flex.textLayout.elements.IBackgroundManager;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+
+	public class NumberLineUserData
+	{
+		public function NumberLineUserData(listStylePosition:String, insideLineWidth:Number, spanFormat:ITextLayoutFormat, paraDirection:String)
+		{
+			this.listStylePosition = listStylePosition;
+			// added by yong
+			this.insideLineWidth = insideLineWidth;
+			this.spanFormat = spanFormat;
+			this.paragraphDirection = paraDirection;
+		}
+
+		public var listStylePosition:String;
+		public var insideLineWidth:Number;
+		public var spanFormat:ITextLayoutFormat;
+		public var paragraphDirection:String;
+		public var listEndIndent:Number;
+		public var backgroundManager:IBackgroundManager;
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/utils/NumberlineUtil.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/utils/NumberlineUtil.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/utils/NumberlineUtil.as
new file mode 100644
index 0000000..d82bca3
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/utils/NumberlineUtil.as
@@ -0,0 +1,160 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.compose.utils
+{
+	import org.apache.flex.textLayout.utils.NumberFactoryUtil;
+	import org.apache.flex.core.UIBase;
+	import org.apache.flex.geom.Rectangle;
+	import org.apache.flex.text.engine.ITextLine;
+	import org.apache.flex.textLayout.compose.ISWFContext;
+	import org.apache.flex.textLayout.compose.SWFContext;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.elements.IFlowLeafElement;
+	import org.apache.flex.textLayout.elements.ILinkElement;
+	import org.apache.flex.textLayout.elements.IListElement;
+	import org.apache.flex.textLayout.elements.IListItemElement;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.LinkState;
+	import org.apache.flex.textLayout.factory.INumberLineFactory;
+	import org.apache.flex.textLayout.formats.Direction;
+	import org.apache.flex.textLayout.formats.FormatValue;
+	import org.apache.flex.textLayout.formats.IListMarkerFormat;
+	import org.apache.flex.textLayout.formats.ListStylePosition;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+
+	public class NumberlineUtil
+	{
+		static private var numberLineFactory:INumberLineFactory;
+
+		/**
+		*
+		* @private Logic to generate and position the ITextLine containing the numbering for a listElement's first line 
+		* @flexjsignorecoercion org.apache.flex.textLayout.elements.ILinkElement
+		* @flexjsignorecoercion org.apache.flex.textLayout.elements.IListElement
+		 */
+		static public function createNumberLine(listItemElement:IListItemElement, curParaElement:IParagraphElement, swfContext:ISWFContext, totalStartIndent:Number):ITextLine
+		{
+			CONFIG::debug
+			{
+				assert(swfContext != SWFContext.globalSWFContext, "TextFlowLine.createNumberLine: don't pass globalswfcontext"); }
+			if (numberLineFactory == null)
+			{
+				numberLineFactory = NumberFactoryUtil.getNumberFactory();
+				numberLineFactory.compositionBounds = new Rectangle(0, 0, NaN, NaN);
+			}
+			numberLineFactory.swfContext = swfContext;
+
+			var listMarkerFormat:IListMarkerFormat = listItemElement.computedListMarkerFormat();
+
+			// use the listStylePosition on the ListItem (not the list)
+			numberLineFactory.listStylePosition = listItemElement.computedFormat.listStylePosition;
+
+			var listElement:IListElement = listItemElement.parent as IListElement;
+			var paragraphFormat:TextLayoutFormat = new TextLayoutFormat(curParaElement.computedFormat);
+			var boxStartIndent:Number = paragraphFormat.direction == Direction.LTR ? listElement.getEffectivePaddingLeft() + listElement.getEffectiveBorderLeftWidth() + listElement.getEffectiveMarginLeft() : listElement.getEffectivePaddingRight() + listElement.getEffectiveBorderRightWidth() + listElement.getEffectiveMarginRight();
+			// this just gets the first line but that's the only one we use.  could have used paragraphStartIndent or padding/margins.
+			// do it this way so that negative indents are supported.  TODO revisit when box model work is complete
+			paragraphFormat.apply(listMarkerFormat);
+			// Fix bug 2800975 ListMarkerFormat.paragraphStartIndent not applied properly in Inside lists.
+			paragraphFormat.textIndent += totalStartIndent;
+			if (numberLineFactory.listStylePosition == ListStylePosition.OUTSIDE)
+				paragraphFormat.textIndent -= boxStartIndent;
+			numberLineFactory.paragraphFormat = paragraphFormat; // curParaElement.computedFormat;
+			numberLineFactory.textFlowFormat = curParaElement.getTextFlow().computedFormat;
+
+			// suppress the formatting of any links
+			var firstLeaf:IFlowLeafElement = curParaElement.getFirstLeaf();
+			var parentLink:ILinkElement = firstLeaf.getParentByType("LinkElement") as ILinkElement;
+			// record the topmost parent link
+			var highestParentLinkLinkElement:ILinkElement;
+			var linkStateArray:Array = [];
+			while (parentLink)
+			{
+				highestParentLinkLinkElement = parentLink;
+				linkStateArray.push(parentLink.linkState);
+				parentLink.chgLinkState(LinkState.SUPPRESSED);
+				parentLink = parentLink.getParentByType("LinkElement") as ILinkElement;
+			}
+
+			// spanFormat to use for the markers
+			var spanFormat:TextLayoutFormat = new TextLayoutFormat(firstLeaf.computedFormat);
+
+			// now restore the formatting of any links
+			parentLink = firstLeaf.getParentByType("LinkElement") as ILinkElement;
+			while (parentLink)
+			{
+				linkStateArray.push(parentLink.linkState);
+				parentLink.chgLinkState(linkStateArray.shift());
+				parentLink = parentLink.getParentByType("LinkElement") as ILinkElement;
+			}
+
+			// forces recompute of computedFormat of all leaf nodes of highestParentLinkLinkElement
+			if (highestParentLinkLinkElement)
+			{
+				var leaf:IFlowLeafElement = highestParentLinkLinkElement.getFirstLeaf();
+				while (leaf)
+				{
+					leaf.calculateComputedFormat();
+					leaf = leaf.getNextLeaf(highestParentLinkLinkElement);
+				}
+			}
+
+			// finalize the spanFormat for the marker
+			var markerFormat:TextLayoutFormat = new TextLayoutFormat(spanFormat);
+			TextLayoutFormat.resetModifiedNoninheritedStyles(markerFormat);
+			var holderStyles:Object = (listMarkerFormat as TextLayoutFormat).getStyles();
+			for (var key:String in holderStyles)
+			{
+				// only copy TextLayoutFormat properties
+				if (TextLayoutFormat.description[key] !== undefined)
+				{
+					var val:* = holderStyles[key];
+					markerFormat[key] = (val !== FormatValue.INHERIT) ? val : spanFormat[key];
+				}
+			}
+			numberLineFactory.markerFormat = markerFormat;
+			numberLineFactory.text = listElement.computeListItemText(listItemElement, listMarkerFormat);
+
+			// expect one or zero lines - technically with beforeContent and afterContent more than one line can be generated.  This could be more like a float!!
+			// also need to expect a backgroundColor
+			var rslt:Array = [];
+			numberLineFactory.createTextLines(function(o:UIBase):void
+			{
+				rslt.push(o);
+			});
+
+			// position it relative to the parent line - later need to take inside/outside into account
+			var numberLine:ITextLine = rslt[0] as ITextLine;
+			if (numberLine)
+			{
+				CONFIG::debug
+				{
+					assert(numberLine.validity == "static", "Invalid validity on numberLine"); }
+				// TODO deal with mouseEnabled and mouseChildren
+				// numberLine.mouseEnabled = false;
+				// numberLine.mouseChildren = false;
+				TextLineUtil.setNumberLineBackground(numberLine, numberLineFactory.backgroundManager);
+			}
+			numberLineFactory.clearBackgroundManager();
+
+			return numberLine;
+		}
+		
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/utils/StandardHelper.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/utils/StandardHelper.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/utils/StandardHelper.as
new file mode 100644
index 0000000..c197b22
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/utils/StandardHelper.as
@@ -0,0 +1,35 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.compose.utils
+{
+	import org.apache.flex.textLayout.compose.IFlowComposer;
+	import org.apache.flex.textLayout.compose.StandardFlowComposer;
+
+	public class StandardHelper
+	{
+		static public function getStandardClass():Class
+		{
+			return StandardFlowComposer;
+		}
+		static public function getNewComposer():IFlowComposer
+		{
+			return new StandardFlowComposer();
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/utils/TextLineUtil.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/utils/TextLineUtil.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/utils/TextLineUtil.as
new file mode 100644
index 0000000..52a0bd2
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/utils/TextLineUtil.as
@@ -0,0 +1,172 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.compose.utils
+{
+	import org.apache.flex.text.engine.ITextLine;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.elements.IBackgroundManager;
+	import org.apache.flex.textLayout.elements.IFlowLeafElement;
+	import org.apache.flex.textLayout.elements.IInlineGraphicElement;
+	import org.apache.flex.textLayout.elements.IListItemElement;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.formats.BlockProgression;
+	import org.apache.flex.textLayout.formats.Direction;
+	import org.apache.flex.textLayout.formats.FormatValue;
+	import org.apache.flex.textLayout.formats.IListMarkerFormat;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.formats.ListStylePosition;
+
+	public class TextLineUtil
+	{
+		/** @private */
+		static public function findNumberLine(textLine:ITextLine):ITextLine
+		{
+			if (textLine == null)
+				return null;
+			// not always going to be a numberLine - listStyleType may be "none"
+			// have to hunt for it because inlinegraphics get pushed at the beginning
+			// risk here is that clients decorate TextLines with other TextLines.
+			for (var idx:int = 0; idx < textLine.numElements; idx++)
+			{
+				var numberLine:ITextLine = textLine.getElementAt(idx) as ITextLine;
+				if (numberLine && (numberLine.userData is NumberLineUserData))
+					break;
+			}
+			return numberLine;
+		}
+
+		/** @private */
+		static public function getNumberLineListStylePosition(numberLine:ITextLine):String
+		{
+			return (numberLine.userData as NumberLineUserData).listStylePosition;
+		}
+
+		/** @private */
+		static public function getNumberLineInsideLineWidth(numberLine:ITextLine):Number
+		{
+			return (numberLine.userData as NumberLineUserData).insideLineWidth;
+		}
+
+		/** @private */
+		static public function getNumberLineSpanFormat(numberLine:ITextLine):ITextLayoutFormat
+		{
+			return (numberLine.userData as NumberLineUserData).spanFormat;
+		}
+
+		/** @private */
+		static public function getNumberLineParagraphDirection(numberLine:ITextLine):String
+		{
+			return (numberLine.userData as NumberLineUserData).paragraphDirection;
+		}
+
+		/** @private */
+		static public function setListEndIndent(numberLine:ITextLine, listEndIndent:Number):void
+		{
+			(numberLine.userData as NumberLineUserData).listEndIndent = listEndIndent;
+		}
+
+		/** @private */
+		static public function getListEndIndent(numberLine:ITextLine):Number
+		{
+			return (numberLine.userData as NumberLineUserData).listEndIndent;
+		}
+
+		/** @private */
+		static public function setNumberLineBackground(numberLine:ITextLine, background:IBackgroundManager):void
+		{
+			(numberLine.userData as NumberLineUserData).backgroundManager = background;
+		}
+
+		/** @private */
+		static public function getNumberLineBackground(numberLine:ITextLine):IBackgroundManager
+		{
+			return (numberLine.userData as NumberLineUserData).backgroundManager;
+		}
+
+		/** @private */
+		static public function initializeNumberLinePosition(numberLine:ITextLine, listItemElement:IListItemElement, curParaElement:IParagraphElement, totalWidth:Number):void
+		{
+			// use the listStylePosition on the ListItem (not the list)
+			var listMarkerFormat:IListMarkerFormat = listItemElement.computedListMarkerFormat();
+			var paragraphFormat:ITextLayoutFormat = curParaElement.computedFormat;
+			// only applies on outside list markers
+			var listEndIndent:Number = listMarkerFormat.paragraphEndIndent === undefined || listItemElement.computedFormat.listStylePosition == ListStylePosition.INSIDE ? 0 : (listMarkerFormat.paragraphEndIndent == FormatValue.INHERIT ? paragraphFormat.paragraphEndIndent : listMarkerFormat.paragraphEndIndent);
+
+			TextLineUtil.setListEndIndent(numberLine, listEndIndent);
+
+			// no more work needed for OUTSIDE positioning - its all done in the applyTextAlign code
+			if (listItemElement.computedFormat.listStylePosition == ListStylePosition.OUTSIDE)
+			{
+				numberLine.x = numberLine.y = 0;
+				return;
+			}
+
+			var bp:String = curParaElement.getTextFlow().computedFormat.blockProgression;
+			var numberLineWidth:Number = TextLineUtil.getNumberLineInsideLineWidth(numberLine);
+
+			if (bp == BlockProgression.TB)
+			{
+				if (paragraphFormat.direction == Direction.LTR)
+					numberLine.x = -numberLineWidth;
+				else
+					numberLine.x = totalWidth + numberLineWidth - numberLine.textWidth;
+				numberLine.y = 0;	// assumes same baseline as parent!!
+			}
+			else
+			{
+				if (paragraphFormat.direction == Direction.LTR)
+					numberLine.y = -numberLineWidth;
+				else
+					numberLine.y = totalWidth + numberLineWidth - numberLine.textWidth;
+				numberLine.x = 0;	// assumes same baseline as parent!!
+			}
+		}
+
+		/** @private 
+		 * Scan through the format runs within the line, and figure out what the typographic ascent (i.e. ascent relative to the 
+		 * Roman baseline) for the overall line is. Normally it is the distance between the Roman and Ascent baselines, 
+		 * but it may be adjusted upwards by the width/height of the GraphicElement.
+		 */
+		static public function getTextLineTypographicAscent(textLine:ITextLine, elem:IFlowLeafElement, elemStart:int, textLineEnd:int):Number
+		{
+			CONFIG::debug
+			{
+				assert(!elem || elemStart == elem.getAbsoluteStart(), "bad elemStart passed to getTextLineTypographicAscent"); }
+			var rslt:Number = textLine.getBaselinePosition(org.apache.flex.text.engine.TextBaseline.ROMAN) - textLine.getBaselinePosition(org.apache.flex.text.engine.TextBaseline.ASCENT);
+
+			if (textLine.hasGraphicElement)
+			{
+				for (;;)
+				{
+					if (elem is IInlineGraphicElement)
+						rslt = Math.max(rslt, IInlineGraphicElement(elem).getTypographicAscent(textLine));
+					elemStart += elem.textLength;
+					if (elemStart >= textLineEnd)
+						break;
+					elem = elem.getNextLeaf();
+					CONFIG::debug
+					{
+						assert(elem != null, "bad nextLeaf"); }
+				}
+			}
+			return rslt;
+		}
+
+	}
+}
\ No newline at end of file


[17/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/InlineGraphicElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/InlineGraphicElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/InlineGraphicElement.as
new file mode 100644
index 0000000..68de1ba
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/InlineGraphicElement.as
@@ -0,0 +1,1165 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements 
+{
+    import org.apache.flex.textLayout.property.PropertyFactory;
+    import org.apache.flex.core.IParentIUIBase;
+    import org.apache.flex.core.IUIBase;
+    import org.apache.flex.core.UIBase;
+    import org.apache.flex.geom.Rectangle;
+    import org.apache.flex.text.engine.ContentElement;
+    import org.apache.flex.text.engine.ElementFormat;
+    import org.apache.flex.text.engine.FontMetrics;
+    import org.apache.flex.text.engine.GraphicElement;
+    import org.apache.flex.text.engine.TextBaseline;
+    import org.apache.flex.text.engine.ITextLine;
+    import org.apache.flex.text.engine.TextRotation;
+    
+    import org.apache.flex.textLayout.compose.ISWFContext;
+    import org.apache.flex.textLayout.debug.Debugging;
+    import org.apache.flex.textLayout.debug.assert;
+    import org.apache.flex.textLayout.events.ModelChange;
+    import org.apache.flex.textLayout.events.StatusChangeEvent;
+    import org.apache.flex.textLayout.formats.BlockProgression;
+    import org.apache.flex.textLayout.formats.Float;
+    import org.apache.flex.textLayout.formats.FormatValue;
+    import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+    import org.apache.flex.textLayout.formats.JustificationRule;
+    import org.apache.flex.textLayout.property.Property;
+
+
+//    import org.apache.flex.utils.OSUtils;
+    
+
+
+    /** The InlineGraphicElement class handles graphic objects that display inline in the text. 
+     * 
+     * <p>You can embed a graphic or any DisplayObject or specify a URl for the location of the graphic. 
+     * The <code>height</code> and <code>width</code> properties of InlineGraphicElement control the actual size 
+     * of the graphic to display.  These values also control how much space to allocate
+     * for the graphic in the ITextLine object that contains the graphic.
+     * The <code>height</code> and <code>width</code> properties each can be one of:</p>
+     * <ol>
+     * <li>A number of pixels</li>
+     * <li>A percent of the measured size of the image</li>
+     * <li>The constant, "auto", which computes the size (Default value)</li>
+     * </ol>
+     * There are three properties, or accessors, pertaining to the width and height of a graphic:
+     * <ul>
+     * <li>The <code>width</code> and <code>height</code> properties</li>
+     * <li>The <code>measuredWidth</code> and <code>measuredHeight</code> properties, which are the width or height of the graphic at load time</li>
+     * <li>The <code>actualWidth</code> and <code>actualHeight</code> properties, which are the actual display and compose width and height of the graphic as computed from <code>width</code> or <code>height</code> and <code>measuredWidth</code> or <code>measuredHeight</code></li>
+     * </ul>
+     * <p>The values of the <code>actualWidth</code> and <code>actualHeight</code> properties are always zero until the graphic 
+     * is loaded.</p>
+     *
+     * <p>If <code>source</code> is specified as a URI, the graphic is loaded asynchronously. If it's a DisplayObject, TextLayout uses the <code>width</code> and 
+     * <code>height</code> at the time the graphic is set into the InlineGraphicElement object as <code>measuredHeight</code> and <code>measuredWidth</code>; 
+     * its width and height are read immediately.</p>
+     * <p><strong>Notes</strong>: For graphics that are loaded asynchronously the user must listen for a 
+     * StatusChangeEvent.INLINE_GRAPHIC_STATUS_CHANGE event on the TextFlow and call <code>IFlowComposer.updateAllControllers()</code> to have the 
+     * graphic appear. The value of <code>measuredWidth</code> and <code>measuredHeight</code> for graphics that are in the 
+     * process of loading is zero.</p>
+     *
+     * <p>Some inline graphics are animations or videos that possibly have audio. They begin to run the first time they are composed after they finish loading.  
+     * They don't stop running until the flowComposer on the TextFlow is set to null.  At that time they are stopped and unloaded.</p>
+     * 
+     * The following restrictions apply to InLineGraphicElement objects:
+     * <ol>
+     *  <li>On export of TLFMarkup, source is converted to a string. If the graphic element is 
+     *      a class, the Text Layout Framework can't export it properly</li>.
+     *  <li>When doing a copy/paste operation of an InlineGraphicElement, if source can't be 
+     *      used to create a new InLineGraphicElement, it won't be pasted.  For example if 
+     *      source is a DisplayObject, or if the graphic is set directly, it can't be 
+     *      duplicated.  Best results are obtained if the source is the class of an embedded graphic 
+     *      though that doesn't export/import.</li>
+     *  <li>InLineGraphicElement objects work in the factory (TextFlowTextLineFactory) only if 
+     *      the source is a class or if you explicitly set the graphic to a loaded graphic. 
+     *      InlineGraphic objects that require delayed loads generally do not show up.</li>
+     * </ol>
+     *
+     * @playerversion Flash 10
+     * @playerversion AIR 1.5
+     * @langversion 3.0
+     *
+     * @see #actualHeight
+     * @see #actualWidth
+     * @see flash.display.DisplayObject DisplayObject
+     * @see org.apache.flex.textLayout.compose.IFlowComposer#updateAllControllers()
+     * @see org.apache.flex.textLayout.events.StatusChangeEvent StatusChangeEvent
+     * @see TextFlow
+	 */
+	public final class InlineGraphicElement extends FlowLeafElement implements IInlineGraphicElement
+    {   
+        private var _source:Object;
+        private var _graphic:IUIBase;
+        private var _placeholderGraphic:IParentIUIBase;     // a fake IUIBase we put in the ITextLine so it generates an atom
+        
+        private var _elementWidth:Number;
+        private var _elementHeight:Number;
+
+        // internal status of the graphic.  there are more status here than publicly shown
+        private var _graphicStatus:Object;
+        
+        // set when its ok - must delay until on the stage for dynamically loaded images
+        private var okToUpdateHeightAndWidth:Boolean;
+        
+        private var _width:*;
+        private var _height:*;
+        
+        // stash away the actual width and height of the graphic
+        private var _measuredWidth:Number;
+        private var _measuredHeight:Number;
+        
+        private var _float:*;
+        
+        static private const graphicElementText:String = "\FDEF";
+
+        /** Constructor - create new InlineGraphicElement object
+         *
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */
+         
+        public function InlineGraphicElement()
+        {
+            super();
+            // The width/height on the FE.fe don't actually take until the InlineGraphicElement is loaded.
+            okToUpdateHeightAndWidth = false;
+            _measuredWidth = 0;
+            _measuredHeight = 0;
+            internalSetWidth(undefined);
+            internalSetHeight(undefined);
+            _graphicStatus = InlineGraphicElementStatus.LOAD_PENDING;
+            setTextLength(1);
+            _text = graphicElementText;     // echo text property we get from FTE
+        }
+		override public function get className():String{
+			return "InlineGraphicElement";
+		}
+        
+        /** @private */
+        override public function createContentElement():void
+        {
+            if (_blockElement)
+                return;
+                
+            calculateComputedFormat(); // BEFORE creating the element
+            var graphicElement:GraphicElement = new GraphicElement();           
+            _blockElement = graphicElement;
+            CONFIG::debug { Debugging.traceFTECall(_blockElement,null,"new GraphicElement()"); }
+            
+            updateContentElement();
+
+            super.createContentElement();
+        }
+        
+        private function updateContentElement():void
+        {
+            var graphicElement:GraphicElement = _blockElement as GraphicElement;            
+            // Setting textRotation throws if any of the parent GroupElements have textRotation other than ROTATE_0
+            CONFIG::debug { assert(_blockElement.textRotation == TextRotation.ROTATE_0,"invalid text Rotation in ILG"); }
+            // CONFIG::debug { Debugging.traceFTEAssign(_blockElement,"textRotation",String(rotationPropertyDefinition.defaultValue)); }
+
+            //we need to keep a place holder in the ge.graphic in order to be able to navigate
+            //to the element.  Without it, the FTE model will remove the atom and selection will not be
+            //possible. - gak 12.12.08
+            if (!_placeholderGraphic)
+                _placeholderGraphic = new UIBase();
+            graphicElement.graphic = _placeholderGraphic;
+
+            if (effectiveFloat != Float.NONE)
+            {
+                if (graphicElement.elementHeight != 0)
+                    graphicElement.elementHeight = 0 ;
+                if (graphicElement.elementWidth != 0)
+                    graphicElement.elementWidth = 0;
+            }
+            else
+            {
+                var height:Number = elementHeightWithMarginsAndPadding();
+                if (graphicElement.elementHeight != height)
+                    graphicElement.elementHeight = height;
+                var width:Number = elementWidthWithMarginsAndPadding();
+                if (graphicElement.elementWidth != width)
+                    graphicElement.elementWidth = width;
+            }
+            CONFIG::debug { Debugging.traceFTEAssign(_blockElement,"elementHeight",graphicElement.elementHeight); }
+            CONFIG::debug { Debugging.traceFTEAssign(_blockElement,"elementWidth",graphicElement.elementWidth); }
+            CONFIG::debug { Debugging.traceFTEAssign(graphicElement,"graphic",graphic); }   // needs float fix
+        }
+        
+        // Recalculate graphicElement width & height after a format change
+        /** @private */
+        public override function get computedFormat():ITextLayoutFormat
+        {
+            var updateGraphicElement:Boolean = _computedFormat == null;
+            super.computedFormat;
+            if (updateGraphicElement && _blockElement)
+                updateContentElement();
+
+            return _computedFormat;
+        }
+        
+        /** @private */
+        public function elementWidthWithMarginsAndPadding():Number
+        {
+            // no textflow is no padding
+            var textFlow:ITextFlow = getTextFlow();
+            if (!textFlow)
+                return elementWidth;
+            var paddingAmount:Number = textFlow.computedFormat.blockProgression == BlockProgression.RL ? 
+                getEffectivePaddingTop()  + getEffectivePaddingBottom() :
+                getEffectivePaddingLeft() + getEffectivePaddingRight();
+            return elementWidth + paddingAmount;
+        }
+        
+        /** @private */
+        public function elementHeightWithMarginsAndPadding():Number
+        {
+            // no textflow is no padding
+            var textFlow:ITextFlow = getTextFlow();
+            if (!textFlow)
+				return elementHeight;
+            var paddingAmount:Number = textFlow.computedFormat.blockProgression == BlockProgression.RL ? 
+                getEffectivePaddingLeft() + getEffectivePaddingRight() :
+                getEffectivePaddingTop() + getEffectivePaddingBottom();
+            return elementHeight + paddingAmount;
+        }
+        
+        // internal values for _graphicStatus.  It can also be an error code.
+        /** load initiated */
+        static private const LOAD_INITIATED:String = "loadInitiated";
+        /** public status string for open event received status.  @see flash.display.LoaderInfo.Events.open */
+        static private const OPEN_RECEIVED:String = "openReceived";
+        /** load complete received status.  @see flash.display.LoaderInfo.Events.open */
+        static private const LOAD_COMPLETE:String = "loadComplete";
+        /** loaded from embed */
+        static private const EMBED_LOADED:String = "embedLoaded";
+        /** specified as a DisplayObject */
+        static private const DISPLAY_OBJECT:String = "displayObject";
+        /** null graphic */
+        static private const NULL_GRAPHIC:String = "nullGraphic";
+        
+        
+//        private static var isMac:Boolean = OSUtils.getOS() ==  OSUtils.MAC_OS;
+        
+        /** The embedded graphic. 
+        *
+        * @playerversion Flash 10
+        * @playerversion AIR 1.5
+        * @langversion 3.0
+        */
+        
+        public function get graphic():IUIBase
+        {
+            return _graphic;
+        }
+        private function setGraphic(value:IUIBase):void
+        {
+            _graphic = value;
+        // I think this should do a model change. But it will break paste because when we paste we do a reimport,
+        // which will cause a delayed update, which will bump the generation number *after* the command. Which 
+        // will cause undo of the command not to work.
+        //  modelChanged(ModelChange.ELEMENT_MODIFIED,0,textLength);
+        }
+        
+        
+        /** @private */
+        public function get placeholderGraphic():IParentIUIBase
+        {
+            return _placeholderGraphic;
+        }
+        
+        /** Width used by composition for laying out text around the graphic. @private */
+        public function get elementWidth():Number
+        {
+            return _elementWidth;           
+        }
+        /** Width used by composition for laying out text around the graphic. @private */
+        public function set elementWidth(value:Number):void
+        {
+            _elementWidth = value;
+
+            if (_blockElement)
+            {
+                (_blockElement as GraphicElement).elementWidth = (effectiveFloat != Float.NONE) ? 0 : elementWidthWithMarginsAndPadding();
+                CONFIG::debug { Debugging.traceFTEAssign(GraphicElement(_blockElement as GraphicElement),"elementWidth",GraphicElement(_blockElement).elementWidth); }
+                
+            }
+
+            modelChanged(ModelChange.ELEMENT_MODIFIED,this,0,textLength,true,false);
+        }
+        
+        /** Height used by composition for laying out text around the graphic. @private */
+        public function get elementHeight():Number
+        {
+            return _elementHeight;          
+        }
+        /** Height used by composition for laying out text around the graphic. @private */
+        public function set elementHeight(value:Number):void
+        {
+            _elementHeight = value;
+
+            if (_blockElement)
+            {
+                (_blockElement as GraphicElement).elementHeight = (effectiveFloat != Float.NONE) ? 0 : elementHeightWithMarginsAndPadding();    
+                CONFIG::debug { Debugging.traceFTEAssign((_blockElement as GraphicElement),"elementHeight",GraphicElement(_blockElement).elementHeight); }
+            }
+            modelChanged(ModelChange.ELEMENT_MODIFIED,this,0,textLength,true,false);
+        }
+        
+        /** Definition of the height property @private */
+        static public const heightPropertyDefinition:Property = PropertyFactory.numPercentEnum("height", "auto", false, null, 0, 32000, "0%", "1000000%", "auto" );
+        
+        /** Definition of the width property @private */
+        static public const widthPropertyDefinition:Property = PropertyFactory.numPercentEnum("width", "auto", false, null, 0, 32000, "0%", "1000000%", "auto" );
+
+        /** Disabled due to player bug.  @private */
+        static public const rotationPropertyDefinition:Property = PropertyFactory.enumString("rotation", "rotate0", false, null, 
+            "rotate0", "rotate90", "rotate180", "rotate270");       
+        
+        /** Definition of the float property @private */
+        static public const floatPropertyDefinition:Property = PropertyFactory.enumString("float", "none", false, null, 
+             "none", "left", "right", "start", "end");
+            
+        /** The current status of the image. On each status change the owning TextFlow sends a StatusChangeEvent.
+         *
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         *
+         * @return one of LOAD_PENDING, LOADING, SIZE_PENDING, READY, ERROR
+         * @see org.apache.flex.textLayout.elements.InlineGraphicElementStatus
+         * @see org.apache.flex.textLayout.events.StatusChangeEvent
+         */
+         
+        public function get status():String
+        {
+            switch(_graphicStatus)
+            {
+                case LOAD_INITIATED:
+                case OPEN_RECEIVED:
+                    return InlineGraphicElementStatus.LOADING;
+                case LOAD_COMPLETE:
+                case EMBED_LOADED:
+                case DISPLAY_OBJECT:
+                case NULL_GRAPHIC:
+                    return InlineGraphicElementStatus.READY;
+                case InlineGraphicElementStatus.LOAD_PENDING:
+                case InlineGraphicElementStatus.SIZE_PENDING:
+                    return String(_graphicStatus);
+            }
+//            CONFIG::debug { assert(_graphicStatus is ErrorEvent,"unexpected _graphicStatus"); }
+            return InlineGraphicElementStatus.ERROR; 
+        }
+
+		/** @private
+		 */
+		public override function getText(relativeStart:int=0, relativeEnd:int=-1, paragraphSeparator:String="\n"):String
+		{
+			if(relativeEnd == -1)
+				relativeEnd = textLength;
+			
+			// We could probably just return _text (U+FDEF), but this allows clients to change _text to some other value
+			// and getText() will still work. (Of course, I cannot think of a reason you'd want to do that...)
+			return _text ? _text.substring(relativeStart, relativeEnd) : "";
+		}
+
+        private function changeGraphicStatus(stat:Object):void
+        {
+            var oldStatus:String = status;
+            _graphicStatus = stat;
+            var newStatus:String = status;
+            if (oldStatus != newStatus)//TODO do we need this?  || stat is ErrorEvent
+            {
+                var tf:ITextFlow = getTextFlow();
+                if (tf)
+                {
+                    if (newStatus == InlineGraphicElementStatus.SIZE_PENDING)
+                        tf.processAutoSizeImageLoaded(this);
+                    tf.dispatchEvent(new StatusChangeEvent(StatusChangeEvent.INLINE_GRAPHIC_STATUS_CHANGE, false, false, this, newStatus));//TODO removed the following: stat as ErrorEvent (instead of null)
+                }
+            }
+        }
+                
+        /** The width of the graphic. The value can be 'auto', a number of pixels or a percent of the measured width of the image.
+         * 
+         * <p>Legal values are org.apache.flex.textLayout.formats."auto" and org.apache.flex.textLayout.formats.FormatValue.INHERIT.</p>
+         * <p>Legal values as a number are from 0 to 32000.</p>
+         * <p>Legal values as a percent are numbers from 0 to 1000000.</p>
+         * <p>Default value is undefined indicating not set.</p>
+         * <p>If undefined or "inherit" the InlineGraphicElement will use the default value of "auto".</p>
+         * 
+         * @throws RangeError when set value is not within range for this property
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         *
+         * @see #actualWidth
+         * @see #measuredWidth
+         */
+        public function get width():*
+        { return _width; }
+        public function set width(w:*):void
+        { 
+            internalSetWidth(w);
+            modelChanged(ModelChange.ELEMENT_MODIFIED,this,0,textLength);
+        }
+        
+        /** The natural width of the graphic. This is the width of the graphic at load time.
+        *
+        * @playerversion Flash 10
+        * @playerversion AIR 1.5
+        * @langversion 3.0
+        *
+        * @see #actualWidth
+        * @see #width
+        */
+        
+        public function get measuredWidth():Number
+        { return _measuredWidth; }
+        
+        /** The actual width in effect. This is the display and compose width that's computed from the
+        * <code>width</code> and <code>measuredWidth</code> properties.
+        *
+        * <p>The values of the <code>actualWidth</code>property are computed according to the 
+        * following table:</p>
+        * <table class="innertable" width="100%">
+        * <tr>
+        *   <th>width property</th> 
+        *   <th>actualWidth</th>
+        * </tr>
+        * <tr>
+        *   <td>auto</td>
+        *   <td>measuredWidth</td>
+        * </tr>
+        * <tr>
+        *   <td>w a Percent</td>
+        *   <td>w percent of measuredWidth</td>
+        * </tr>
+        * <tr>
+        *   <td>w a Number</td>
+        *   <td>w</td>
+        * </tr>
+        * </table>
+        *
+        * <p><strong>Notes</strong>: If the inline graphic is a IUIBase, its width and height are read immediately.
+        * If <code>measuredWidth</code> or <code>measuredHeight</code> are zero, then any auto calculations that would cause a divide by zero sets the result to zero.</p>
+        *
+        * @playerversion Flash 10
+        * @playerversion AIR 1.5
+        * @langversion 3.0
+        *
+        * @see #measuredWidth
+        * @see #width
+        *
+        */
+        
+        public function get actualWidth():Number
+        { return elementWidth; }
+        
+        private function widthIsComputed():Boolean
+        { return internalWidth is String; }
+        
+        private function get internalWidth():Object
+        { return _width === undefined ? widthPropertyDefinition.defaultValue : _width; }        
+
+        private function computeWidth():Number
+        {
+            CONFIG::debug { assert(widthIsComputed(),"bad call to InlineGraphicElement.computeWidth"); }
+            if (internalWidth == "auto")
+            {
+                if (internalHeight == "auto")
+                    return _measuredWidth;
+                if (_measuredHeight == 0 || _measuredWidth == 0)
+                    return 0;
+                // can't rely on height being calculated yet
+                var effHeight:Number = heightIsComputed() ? computeHeight(): Number(internalHeight);
+                return effHeight/_measuredHeight * _measuredWidth;
+            }
+            return widthPropertyDefinition.computeActualPropertyValue(internalWidth,_measuredWidth); 
+        }
+        
+        private function internalSetWidth(w:*):void
+        {
+            _width = widthPropertyDefinition.setHelper(width,w);
+            elementWidth = widthIsComputed() ? 0 : Number(internalWidth);
+            if (okToUpdateHeightAndWidth && graphic)
+            {
+                if (widthIsComputed())
+                    elementWidth =  computeWidth();
+                graphic.width = elementWidth;
+                CONFIG::debug { Debugging.traceFTEAssign(graphic,"width",elementWidth); }
+                if (internalHeight == "auto")
+                {
+                    elementHeight =  computeHeight();
+                    graphic.height = elementHeight;
+                    CONFIG::debug { Debugging.traceFTEAssign(graphic,"height",elementHeight); }
+                }
+            }
+        }
+
+        /** The height of the image. May be 'auto', a number of pixels or a percent of the measured height. 
+         *
+         * <p>Legal values are org.apache.flex.textLayout.formats."auto" and org.apache.flex.textLayout.formats.FormatValue.INHERIT.</p>
+         * <p>Legal values as a number are from 0 to 32000.</p>
+         * <p>Legal values as a percent are numbers from 0 to 1000000.</p>
+         * <p>Default value is undefined indicating not set.</p>
+         * <p>If undefined or "inherit" the InlineGraphicElement will use the default value of "auto".</p>
+         * 
+         * @throws RangeError when set value is not within range for this property
+         * 
+          * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         *
+         * @see #actualHeight
+         * @see #measuredHeight
+         */
+        public function get height():*
+        { return _height; }
+        public function set height(h:*):void
+        {
+            internalSetHeight(h);
+            modelChanged(ModelChange.ELEMENT_MODIFIED,this,0,textLength);
+        }
+        
+        private function get internalHeight():Object
+        { return _height === undefined ? heightPropertyDefinition.defaultValue : _height; }
+        
+        /** @private */
+        public function get computedFloat():*
+        {
+            if (_float === undefined)
+                return floatPropertyDefinition.defaultValue;
+            return _float;
+        }
+        
+        private var _effectiveFloat:String;     // how it was last composed
+        /** @private */
+        public function get effectiveFloat():*
+        {
+            return _effectiveFloat ? _effectiveFloat : computedFloat;
+        }
+        /** @private */
+        public function setEffectiveFloat(floatValue:String):void
+        {
+            if (_effectiveFloat != floatValue)
+            {
+                _effectiveFloat = floatValue;
+                if (_blockElement)
+                    updateContentElement();
+            }
+        }
+        
+        [Inspectable(enumeration="none,left,right,start,end")]
+        /** 
+         * Controls the placement of the graphic relative to the text. It can be part of the line, or can be beside the line with the text 
+         * wrapped around it. 
+         * <p>Legal values are <code>org.apache.flex.textLayout.formats.Float.NONE</code>, <code>org.apache.flex.textLayout.formats.Float.LEFT</code>, 
+         * <code>org.apache.flex.textLayout.formats.Float.RIGHT</code>, <code>org.apache.flex.textLayout.formats.Float.START</code>, and <code>org.apache.flex.textLayout.formats.Float.END</code>.</p>
+         * <p>Default value is undefined indicating not set.</p>
+         * <p>If undefined will be treated as <code>Float.NONE</code>.</p>
+         * 
+         * @throws RangeError when set value is not within range for this property
+         * 
+         * @see org.apache.flex.textLayout.formats.Float
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 2.0
+         * @langversion 3.0
+         */
+        public function get float():*
+        {
+            return _float;
+        }
+        public function set float(value:*):void
+        {
+            value = floatPropertyDefinition.setHelper(float, value) as String;
+            if (_float != value)
+            {
+                _float = value;
+                if (_blockElement)
+                    updateContentElement();
+                modelChanged(ModelChange.ELEMENT_MODIFIED,this,0,textLength);
+            }                   
+        }
+        
+        /** The natural height of the graphic. This is the height of the graphic at load time.
+        *
+        * @playerversion Flash 10
+        * @playerversion AIR 1.5
+        * @langversion 3.0
+        * 
+        * @see #actualHeight
+        * @see #height
+        */
+        
+        public function get measuredHeight():Number
+        { return _measuredHeight; }
+            
+        /** The actual height in effect. This is the display and compose height that's computed from the
+        * <code>height</code> and <code>measuredHeight</code> properties.
+        *
+        * <p>The values of the <code>actualHeight</code> property are computed according to the following table:</p>
+        * <table class="innertable" width="100%">
+        * <tr>
+        *   <th>height property</th>
+        *   <th>actualHeight</th>
+        * </tr>
+        * <tr>
+        *   <td>auto</td>
+        *   <td>measuredheight</td>
+        * </tr>
+        * <tr>
+        *   <td>h a Percent</td>
+        *   <td>h percent of measuredheight</td>
+        * </tr>
+        * <tr>
+        *   <td>h a Number</td>
+        *   <td>h</td>
+        * </tr>
+        * </table>
+        * <p><strong>Notes</strong>: If the inline graphic is a IUIBase, its width and height are read immmediately.
+        * If <code>measuredWidth</code> or <code>measuredHeight</code> are zero, then any auto calculations that would cause a divide by zero sets the result to zero.</p>
+        *
+        * @playerversion Flash 10
+        * @playerversion AIR 1.5
+        * @langversion 3.0
+        *
+        * @see #height
+        * @see #measuredHeight
+        */
+        
+        public function get actualHeight():Number
+        { return elementHeight; }
+        
+        private function heightIsComputed():Boolean
+        { return internalHeight is String; }
+        
+        private function computeHeight():Number
+        {
+            CONFIG::debug { assert(heightIsComputed(),"bad call to InlineGraphicElement.computeWidth"); }
+            if (internalHeight == "auto")
+            {
+                if (internalWidth == "auto")
+                    return _measuredHeight;
+                if (_measuredHeight == 0 || _measuredWidth == 0)
+                    return 0;
+                // can't rely on width being calculated yet
+                var effWidth:Number = widthIsComputed() ? computeWidth(): Number(internalWidth);
+                return effWidth/_measuredWidth * _measuredHeight;
+            }
+            return heightPropertyDefinition.computeActualPropertyValue(internalHeight,_measuredHeight); 
+        }
+        
+        private function internalSetHeight(h:*):void
+        {
+            _height = heightPropertyDefinition.setHelper(height,h);
+            elementHeight = heightIsComputed() ? 0 : Number(internalHeight);
+            if (okToUpdateHeightAndWidth && graphic != null)
+            {
+                if (heightIsComputed())
+                    elementHeight =  computeHeight();
+                graphic.height = elementHeight;
+                CONFIG::debug { Debugging.traceFTEAssign(graphic,"height",elementHeight); }
+
+                if (internalWidth == "auto")
+                {
+                    elementWidth =  computeWidth();
+                    graphic.width = elementWidth;
+                    CONFIG::debug { Debugging.traceFTEAssign(graphic,"width",elementWidth); }
+                }
+            }
+        }
+        
+//        private function loadCompleteHandler(e:Event):void
+//        {           
+//            CONFIG::debug { Debugging.traceFTECall(null,null,"loadCompleteHandler",this); }
+//            removeDefaultLoadHandlers(graphic as Loader);
+//            CONFIG::debug { assert(okToUpdateHeightAndWidth == false,"invalid call to loadCompleteHandler"); }
+//            okToUpdateHeightAndWidth = true;
+//			
+//            var g:IUIBase = graphic;
+//            _measuredWidth = g.width;
+//            _measuredHeight = g.height;
+//            
+//			//bug #2931005 TLF cannot show Flex SWF after loading it as an ILG
+//			if(graphic is Loader && Loader(graphic).contentLoaderInfo.contentType == "application/x-shockwave-flash" && Loader(graphic).content != null && Loader(graphic).content.hasOwnProperty("setActualSize") && (!widthIsComputed() || !heightIsComputed()) )
+//				Object(Loader(graphic).content).setActualSize(elementWidth, elementHeight);
+//			else
+//			{
+//				if (!widthIsComputed())
+//                	g.width  = elementWidth;
+//            	if (!heightIsComputed())
+//                	g.height = elementHeight;
+//			}
+//			
+//            if (e is IOErrorEvent)
+//                changeGraphicStatus(e);
+//            else if (widthIsComputed() || heightIsComputed())
+//            {
+//                g.visible = false;
+//                // triggers a delayedElementUpdate
+//                changeGraphicStatus(InlineGraphicElementStatus.SIZE_PENDING);
+//            }
+//            else
+//                changeGraphicStatus(LOAD_COMPLETE);
+//        }
+//                
+//        private function openHandler(e:Event):void
+//        {
+//            changeGraphicStatus(OPEN_RECEIVED);
+//        }
+        
+//        private function addDefaultLoadHandlers(loader:Loader):void
+//        {
+//            var loaderInfo:LoaderInfo = loader.contentLoaderInfo;
+//            CONFIG::debug { Debugging.traceFTECall(loaderInfo,loader,"contentLoaderInfo"); }
+//            
+//            loaderInfo.addEventListener(Event.OPEN, openHandler, false, 0, true);
+//            CONFIG::debug { Debugging.traceFTECall(null,loaderInfo,"addEventListener",Event.OPEN, "openHandler", false, 0, true); }
+//            loaderInfo.addEventListener(Event.COMPLETE,loadCompleteHandler,false,0,true);   
+//            CONFIG::debug { Debugging.traceFTECall(null,loaderInfo,"addEventListener",Event.COMPLETE, "loadCompleteHandler", false, 0, true); }
+//            loaderInfo.addEventListener(IOErrorEvent.IO_ERROR,loadCompleteHandler,false,0,true);    
+//            CONFIG::debug { Debugging.traceFTECall(null,loaderInfo,"addEventListener",IOErrorEvent.IO_ERROR, "loadCompleteHandler", false, 0, true); }
+//        }
+        
+/*        private function removeDefaultLoadHandlers(loader:Loader):void
+        {
+            CONFIG::debug{ assert(loader != null,"bad call to removeDefaultLoadHandlers"); }
+            loader.contentLoaderInfo.removeEventListener(Event.OPEN, openHandler);
+            loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, loadCompleteHandler);
+            loader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, loadCompleteHandler);
+        }
+*/        
+        /** Sets the source for the graphic. 
+         * 
+         * The value can be either a String that is interpreted as a URI, a Class that's interpreted as the class of an 
+         * embeddded IUIBase, a IUIBase instance, or a URLRequest. Creates a IUIBase and,
+         * if the InlineGraphicElement object is added into a ParagraphElement in a TextFlow object, causes it to appear
+         * inline in the text.
+         *
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */
+         
+        public function get source():Object
+        {
+            return _source;
+        }
+        public function set source(value:Object):void
+        {
+//            stop(true);
+            _source = value;
+            changeGraphicStatus(InlineGraphicElementStatus.LOAD_PENDING);
+            modelChanged(ModelChange.ELEMENT_MODIFIED,this,0,textLength);
+        }
+    
+        /** @private This method starts and stops ILGs.  Generally TLF delays starting an ILG until the first compose.  It shuts them down when they
+         * are deleted from the TextFlow or the TextFlow has its flowComposer removed.  Some cases are ambigious, for example removeAllControllers doesn't stop ILGs
+         * but the client may desire it too.  In cases where ILGs don't get stopped or started there are two public functions on TextFlow:
+         * unloadGraphics - unloads and stops all ILGs
+         * prepareGraphicsForLoad - puts all ILGs that are not loaded in a list so that they are loaded on the next compose.
+         * This function is also called when an auto-size or percentage sized graphic is loaded.  In that case the same list as prepareGraphicsForLoad is used.
+         * */
+        public override function applyDelayedElementUpdate(textFlow:ITextFlow,okToUnloadGraphics:Boolean,hasController:Boolean):void
+        {
+            if (textFlow != this.getTextFlow())
+                hasController = false;
+            
+  //TODO fix this
+ /*
+   * I commented this whole thing out because it has lots of Flash dependencies. 
+   * It will take time figuring out how to migrate this functionality to FlexJS
+   *  
+             CONFIG::debug { assert(textFlow != null,"ILG:applyDelayedElementUpdate: null textFlow"); }      
+            if (_graphicStatus == InlineGraphicElementStatus.LOAD_PENDING)
+            {
+                // trace("FEX LOADING", this.toString());
+                if (hasController)
+                {
+                    var source:Object = _source;
+                    if (source is String)
+                    {
+                        var inlineGraphicResolver:Function = textFlow.configuration.inlineGraphicResolverFunction;
+                        if (inlineGraphicResolver != null)
+                            source = inlineGraphicResolver(this);
+                    }
+                    
+                    var elem:DisplayObject;
+					//change the bug#2929161
+					var cILGStatus:String = null;
+                    if (source is String || source is URLRequest)
+                    {
+                        okToUpdateHeightAndWidth = false;
+                        var loader:Loader = new Loader();
+                        CONFIG::debug { Debugging.traceFTECall(loader,null,"new Loader()"); }
+
+                        // set the width/height on COMPLETE or IOError
+                        try
+                        {
+                            addDefaultLoadHandlers(loader);
+                            if (source is String)
+                            {
+                                var myPattern:RegExp = /\\/g;                           
+                                var src:String = source as String;
+                                src = src.replace(myPattern, "/");
+                                //workaround for Watson bug 1896186.  FlashPlayer requres that file
+                                //names be encoded on Macintosh, but not on Windows.  Grouped this
+                                //bug with FlashPlayer Watson bug 1899687
+                                var pictURLReq:URLRequest;
+                                if (isMac)
+                                {
+                                    pictURLReq = new URLRequest(encodeURI(src));
+                                    CONFIG::debug { Debugging.traceFTECall(pictURLReq,null,"new URLRequest",encodeURI(src)); }
+                                }
+                                else
+                                {
+                                    pictURLReq = new URLRequest(src);   
+                                    CONFIG::debug { Debugging.traceFTECall(pictURLReq,null,"new URLRequest",src); }                                 
+                                }
+                                
+                                loader.load(pictURLReq);
+                                CONFIG::debug { Debugging.traceFTECall(null,loader,"load",pictURLReq); }                                    
+                            }
+                            else
+                                loader.load(URLRequest(source));
+                                    
+							setGraphic(loader);     
+                            changeGraphicStatus(LOAD_INITIATED);
+							cILGStatus = LOAD_INITIATED;
+                        }
+                        catch(e:Error)
+                        {
+                            // the load didn't initiate
+                            removeDefaultLoadHandlers(loader);
+                            elem = new Shape();
+                            changeGraphicStatus(NULL_GRAPHIC);
+							cILGStatus = NULL_GRAPHIC;
+                        }
+                    }
+                    else if (source is Class)   // value is class --> it is an Embed
+                    {
+                        var cls:Class = source as Class;
+                        elem = DisplayObject(new cls());
+						//change the bug#2929161
+						cILGStatus = EMBED_LOADED;
+                    }
+                    else if (source is DisplayObject)
+                    {
+                        elem = DisplayObject(source);
+						//change the bug#2929161
+						cILGStatus = DISPLAY_OBJECT;
+                    }
+                    else
+                    {
+                        elem = new Shape();
+						//change the bug#2929161
+						cILGStatus = NULL_GRAPHIC;
+                    }
+                    
+                    // complete setup of width and height
+                    if (cILGStatus != LOAD_INITIATED)
+                    {
+                        okToUpdateHeightAndWidth = true;
+                        _measuredWidth = elem ? elem.width : 0;
+                        _measuredHeight = elem ? elem.height : 0;
+
+                        if (widthIsComputed())
+                        {
+                            if (elem)
+                            {
+                                elem.width = elementWidth = computeWidth();
+                                CONFIG::debug { Debugging.traceFTEAssign(elem,"width",elem.width); }
+                            }
+                            else
+                                elementWidth = 0;
+                        }
+                        else
+                        {
+                            elem.width = Number(width);
+                            CONFIG::debug { Debugging.traceFTEAssign(elem,"width",elem.width); }
+                        }
+                            
+                        if (heightIsComputed())
+                        {
+                            if (elem)
+                            {
+                                elem.height = elementHeight = computeHeight();
+                                CONFIG::debug { Debugging.traceFTEAssign(elem,"height",elem.height); }
+                            }
+                            else
+                                elementHeight = 0;
+                        }
+                        else
+                        {
+                            elem.height = Number(height);
+                            CONFIG::debug { Debugging.traceFTEAssign(elem,"height",elem.height); }
+                        }
+                        
+						setGraphic(elem);
+						//change the bug#2929161
+						if(cILGStatus!=null)
+							changeGraphicStatus(cILGStatus);
+                    }
+                }
+            }
+            else
+            {
+                if (_graphicStatus == InlineGraphicElementStatus.SIZE_PENDING)
+                {
+                    // this is width/height auto case hasn't been set yet - the graphic is hidden!
+                    updateAutoSizes();
+                    graphic.visible = true;
+                    changeGraphicStatus(LOAD_COMPLETE);
+                }
+                if (!hasController)
+                {
+                    // shutdown the audio on any movie clips
+                    stop(okToUnloadGraphics);
+                }
+            }*/
+        }
+        
+        /** @private This API supports the inputmanager */
+        public override function updateForMustUseComposer(textFlow:ITextFlow):Boolean
+        { 
+            applyDelayedElementUpdate(textFlow,false,true);
+            return status != InlineGraphicElementStatus.READY;
+        }
+        
+        /** This function updates the size of the graphic element when the size is expressed as a percentage of the graphic's actual size. */
+        private function updateAutoSizes():void
+        {
+            if (widthIsComputed())
+            {
+                elementWidth = computeWidth();
+                graphic.width = elementWidth;
+            }
+            if (heightIsComputed())
+            {
+                elementHeight = computeHeight();
+                graphic.height = elementHeight;
+            }
+        }
+        
+        
+//        /** @private Stop this inlinegraphicelement - if its a movieclip will stop noise and playing - if a load is in process it cancels the load */
+//        public function stop(okToUnloadGraphics:Boolean):Boolean
+//        {
+//            
+//            // watch for changing the source while we've got an event listener on the current graphic
+//            // if so cancel the load and remove the listeners
+//            if (_graphicStatus == OPEN_RECEIVED || _graphicStatus == LOAD_INITIATED)
+//            {
+//                var loader:Loader = graphic as Loader;
+//                try
+//                {
+//                    loader.close(); // cancels in process load
+//                }
+//                catch (e:Error)
+//                { /* ignore */ }
+//                removeDefaultLoadHandlers(loader);
+//            }
+//
+//            // shutdown any running movieclips - this graphic will no longer be referenced
+//            // for graphics that the client has passed us - just ignore they own the responsibliity
+//            if (_graphicStatus != DISPLAY_OBJECT)
+//            {
+//                if (okToUnloadGraphics)
+//                {
+//                    recursiveShutDownGraphic(graphic);
+//                    setGraphic(null);
+//                }
+//                if (widthIsComputed())
+//                    elementWidth = 0;
+//                if (heightIsComputed())
+//                    elementHeight = 0;
+//                changeGraphicStatus(InlineGraphicElementStatus.LOAD_PENDING);
+//            }
+//            return true;
+//        }
+
+			//This entire function is probably not needed as it seems specific to Flash movies
+        
+        // searches through the graphic and stops any playing grpahics
+//        private static function recursiveShutDownGraphic(graphic:IUIBase):void
+//        {
+//            if (graphic is Loader)
+//                Loader(graphic).unloadAndStop();
+//            else if (graphic)
+//            {
+//                var container:DisplayObjectContainer = graphic as DisplayObjectContainer;
+//                if (container)
+//                {
+//                    for (var idx:int = 0; idx < container.numChildren; idx++)
+//                    {
+//                        recursiveShutDownGraphic(container.getChildAt(idx));
+//                    }
+//                }
+//
+//                if (graphic is MovieClip)
+//                    MovieClip(graphic).stop();
+//            }
+//      
+//		}
+        
+        /** @private */
+        public override function getEffectiveFontSize():Number
+        {
+            if (effectiveFloat != Float.NONE)
+                return 0;
+            var defaultLeading:Number = super.getEffectiveFontSize();
+            return Math.max(defaultLeading, elementHeightWithMarginsAndPadding());
+        }
+        
+        /** Returns the calculated lineHeight from this element's properties.  @private */
+        public override function getEffectiveLineHeight(blockProgression:String):Number
+        {
+            if (effectiveFloat != Float.NONE)
+                return 0;
+            return super.getEffectiveLineHeight(blockProgression);
+        }
+        
+        /** Returns the typographic ascent of the image (i.e. relative to the line's Roman baseline). @private */
+        public function getTypographicAscent(textLine:ITextLine):Number
+        {
+            if (effectiveFloat != Float.NONE)
+                return 0;
+                
+            var effectiveHeight:Number = elementHeightWithMarginsAndPadding();
+            
+            var dominantBaselineString:String;
+            if(this._computedFormat.dominantBaseline != "auto")
+            {
+                dominantBaselineString = this._computedFormat.dominantBaseline;
+            }
+            else
+            {
+                dominantBaselineString = this.getParagraph().getEffectiveDominantBaseline();
+            }
+            
+            var elementFormat:ElementFormat = _blockElement ? _blockElement.elementFormat : computeElementFormat();
+            var alignmentBaseline:String = (elementFormat.alignmentBaseline == org.apache.flex.text.engine.TextBaseline.USE_DOMINANT_BASELINE ? dominantBaselineString : elementFormat.alignmentBaseline);
+                
+            var top:Number=0;
+
+            // Calcluate relative to dominant baseline; remains 0 for ASCENT and IDEOGRAPHIC_TOP
+            if (dominantBaselineString == org.apache.flex.text.engine.TextBaseline.IDEOGRAPHIC_CENTER)
+                top += effectiveHeight/2;
+            else if (dominantBaselineString == org.apache.flex.text.engine.TextBaseline.IDEOGRAPHIC_BOTTOM || dominantBaselineString == org.apache.flex.text.engine.TextBaseline.DESCENT || dominantBaselineString == org.apache.flex.text.engine.TextBaseline.ROMAN)
+                top += effectiveHeight;
+                
+            // re-jig to be relative to the ROMAN baseline rather than whatever baseline is used for alignment
+            top += textLine.getBaselinePosition(org.apache.flex.text.engine.TextBaseline.ROMAN) - textLine.getBaselinePosition(alignmentBaseline);
+            
+            // finally, account for baseline shift
+            top += elementFormat.baselineShift; 
+            
+            return top;
+        }
+        
+        /** @private 
+         * Get the "inline box" for the element as defined by the CSS visual formatting model (http://www.w3.org/TR/CSS2/visuren.html)
+         * For an inline graphic, lineHeight is ignored. The box dimensions are governed by the element height with padding. 
+         * Alignment relative to the baseline (using baselineShift, dominantBaseline, alignmentBaseline) is taken into account.
+         * @return Null if the element is not "inline" (i.e., is a float). Otherwise, a rectangle representing the inline box. 
+         * Top and Bottom are relative to the line's Roman baseline. Left and Right are ignored.
+         */
+        override public function getCSSInlineBox(blockProgression:String, textLine:ITextLine, para:IParagraphElement=null, swfContext:ISWFContext=null):Rectangle
+        {
+            if (effectiveFloat != Float.NONE)
+                return null;
+            
+            var inlineBox:Rectangle = new Rectangle();
+            inlineBox.top = -(getTypographicAscent(textLine));
+            inlineBox.height = elementHeightWithMarginsAndPadding();
+            inlineBox.width = elementWidth;
+            
+            return inlineBox;
+        }
+        
+        /** @private */
+         public override function shallowCopy(startPos:int = 0, endPos:int = -1):IFlowElement
+        {
+            if (endPos == -1)
+                endPos = textLength;
+                
+            var retFlow:InlineGraphicElement = super.shallowCopy(startPos, endPos) as InlineGraphicElement;
+            retFlow.source = source;
+            retFlow.width = width;
+            retFlow.height = height;
+            retFlow.float = float;
+            
+            return retFlow;
+        }
+
+         /** @private */
+         override protected function get abstract():Boolean
+         { return false; }
+         
+         /** @private */
+         public override function get defaultTypeName():String
+         { return "img"; }      
+        
+        /** @private */
+        public override function appendElementsForDelayedUpdate(tf:ITextFlow,changeType:String):void
+        { 
+            if (changeType == ModelChange.ELEMENT_ADDED)
+                tf.incGraphicObjectCount();
+            else if (changeType == ModelChange.ELEMENT_REMOVAL)
+                tf.decGraphicObjectCount();
+            
+            if (status != InlineGraphicElementStatus.READY || changeType == ModelChange.ELEMENT_REMOVAL)
+                tf.appendOneElementForUpdate(this);
+        }
+        
+
+    
+
+        // **************************************** 
+        // Begin debug support code
+        // **************************************** 
+        
+        /** @private */
+        CONFIG::debug public override function toString():String
+        {
+            return super.toString() + " " + source;
+        }
+        
+        /** @private */
+        CONFIG::debug public override function debugCheckFlowElement(depth:int = 0, extraData:String = ""):int
+        {
+            // debugging function that asserts if the flow element tree is in an invalid state
+            
+            var rslt:int = super.debugCheckFlowElement(depth,extraData+" url:"+source);
+
+            if (_blockElement)
+                rslt += assert(textLength == (_blockElement as GraphicElement).rawText.length,"image is different than its textElement");
+            rslt += assert(this != getParagraph().getLastLeaf(),"last Leaf in paragraph cannot be image");
+
+            return rslt;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/InlineGraphicElementStatus.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/InlineGraphicElementStatus.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/InlineGraphicElementStatus.as
new file mode 100644
index 0000000..180c3cd
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/InlineGraphicElementStatus.as
@@ -0,0 +1,78 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+    /** The InlineGraphicElementStatus class defines a set of constants for checking the value of
+     * <code>InlineGraphicElement.status</code>.
+     *
+     * @playerversion Flash 10
+     * @playerversion AIR 1.5
+     * @langversion 3.0
+     *
+     * @see InlineGraphicElement#status
+     */
+    public final class InlineGraphicElementStatus
+    {
+    	/** Graphic element is an URL that has not been loaded.  
+    	 *
+    	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+        public static const LOAD_PENDING:String = "loadPending";
+        
+        /** Load has been initiated (but not completed) on a graphic element that is a URL.  
+         *
+         * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	 
+        public static const LOADING:String  	= "loading";
+        
+        /** 
+         * Graphic element with auto or percentage width/height has completed loading but has not been recomposed.  At the next 
+         * recompose the actual size of the graphic element is calculated. 
+         *
+         * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	 
+        public static const SIZE_PENDING:String = "sizePending";
+        
+	/** Graphic is completely loaded and properly sized. 
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	 
+        public static const READY:String = "ready";
+        
+        /** An error occurred during loading of a referenced graphic. 
+         *
+         * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	 
+        public static const ERROR:String = "error";
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/LeadingUtils.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/LeadingUtils.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/LeadingUtils.as
new file mode 100644
index 0000000..67c61d0
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/LeadingUtils.as
@@ -0,0 +1,72 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	import org.apache.flex.text.engine.TextBaseline;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.formats.LeadingModel;
+
+	public class LeadingUtils
+	{
+		/** @private */
+		public static function getLeadingBasis(leadingModel:String):String
+		{
+			switch (leadingModel)
+			{
+				default:
+					CONFIG::debug
+					{
+						assert(false, "Unsupported parameter to ParagraphElement.getLeadingBasis"); } // In particular, AUTO is not supported by this method. Must be mapped to one of the above
+				case LeadingModel.ASCENT_DESCENT_UP:
+				case LeadingModel.APPROXIMATE_TEXT_FIELD:
+				case LeadingModel.BOX:
+				case LeadingModel.ROMAN_UP:
+					return org.apache.flex.text.engine.TextBaseline.ROMAN;
+				case LeadingModel.IDEOGRAPHIC_TOP_UP:
+				case LeadingModel.IDEOGRAPHIC_TOP_DOWN:
+					return org.apache.flex.text.engine.TextBaseline.IDEOGRAPHIC_TOP;
+				case LeadingModel.IDEOGRAPHIC_CENTER_UP:
+				case LeadingModel.IDEOGRAPHIC_CENTER_DOWN:
+					return org.apache.flex.text.engine.TextBaseline.IDEOGRAPHIC_CENTER;
+			}
+		}
+
+		/** @private */
+		public static function useUpLeadingDirection(leadingModel:String):Boolean
+		{
+			switch (leadingModel)
+			{
+				default:
+					CONFIG::debug
+					{
+						assert(false, "Unsupported parameter to ParagraphElement.useUpLeadingDirection"); } // In particular, AUTO is not supported by this method. Must be mapped to one of the above
+				case LeadingModel.ASCENT_DESCENT_UP:
+				case LeadingModel.APPROXIMATE_TEXT_FIELD:
+				case LeadingModel.BOX:
+				case LeadingModel.ROMAN_UP:
+				case LeadingModel.IDEOGRAPHIC_TOP_UP:
+				case LeadingModel.IDEOGRAPHIC_CENTER_UP:
+					return true;
+				case LeadingModel.IDEOGRAPHIC_TOP_DOWN:
+				case LeadingModel.IDEOGRAPHIC_CENTER_DOWN:
+					return false;
+			}
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/LinkElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/LinkElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/LinkElement.as
new file mode 100644
index 0000000..7f216e1
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/LinkElement.as
@@ -0,0 +1,611 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	import org.apache.flex.core.BrowserWindow;
+	import org.apache.flex.events.Event;
+	import org.apache.flex.events.IEventDispatcher;
+	import org.apache.flex.events.MouseEvent;
+	
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.events.FlowElementMouseEventManager;
+	import org.apache.flex.textLayout.events.ModelChange;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+
+	
+
+	
+	/** 
+	 * Dispatched when the mouse is pressed down over a link.
+	 * @eventType org.apache.flex.textLayout.events.FlowElementMouseEvent.MOUSE_DOWN
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	[Event(name="mouseDown", type="org.apache.flex.textLayout.events.FlowElementMouseEvent")]
+	
+	/** 
+	 * Dispatched when the mouse is released over a link. 
+	 * @eventType org.apache.flex.textLayout.events.FlowElementMouseEvent.MOUSE_UP
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	[Event(name="mouseUp", type="org.apache.flex.textLayout.events.FlowElementMouseEvent")]	
+	/** 
+	 * Dispatched when the mouse passes over the link. 
+	 * @eventType org.apache.flex.textLayout.events.FlowElementMouseEvent.MOUSE_MOVE
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	[Event(name="mouseMove", type="org.apache.flex.textLayout.events.FlowElementMouseEvent")]	
+	/**
+	 * Dispatched when the mouse first enters the link. 
+	 * @eventType org.apache.flex.textLayout.events.FlowElementMouseEvent.ROLL_OVER
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */			
+	[Event(name="rollOver", type="org.apache.flex.textLayout.events.FlowElementMouseEvent")]
+	/** 
+	 * Dispatched when the mouse goes out of the link. 
+	 * @eventType org.apache.flex.textLayout.events.FlowElementMouseEvent.ROLL_OUT
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	[Event(name="rollOut", type="org.apache.flex.textLayout.events.FlowElementMouseEvent")]	
+	/** 
+	 * Dispatched when the link is clicked. 
+	 * Clients may override how the link handles the event by handling it themselves, and calling preventDefault().
+	 * @eventType org.apache.flex.textLayout.events.FlowElementMouseEvent.CLICK
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */	
+	[Event(name="click", type="org.apache.flex.textLayout.events.FlowElementMouseEvent")]
+	
+	/** The LinkElement class defines a link to a URI (Universal Resource Identifier), which is executed when the user clicks it.
+	 * The LinkElement class is a subclass of the SubParagraphGroupElementBase class and it can contain
+	 * one or more FlowElement objects, such as a SpanElement object that stores the link text. An empty
+	 * LinkElement, which does not contain a FlowElement object, is ignored. 
+	 * 
+	 * <p>Normally when clicked the LinkElement will call the <code>flash.net.navigateToURL()</code> method.  A special URI scheme <code>event:</code>
+	 * is also supported.  This scheme will generate a ITextFlow event that the user may listen to in order to execute AS3 code.  An example is included below.</p>
+	 * 
+	 * <p>If you specify a target, it must be one of the following values:
+	 * <table class="innertable" width="100%">
+	 * <tr>
+	 *   <th>Target value</th> 
+	 *   <th>description</th>
+	 * </tr>
+	 * <tr>
+	 *   <td>_self</td>
+	 *   <td>Replaces the current HTML page. If it is in a frame or frameset, it will load within that frame. If it is
+	 *       the full browser, it opens to replace the page from which it came.</td>
+	 * </tr>
+	 * <tr>
+	 *   <td>_blank</td>
+	 *   <td>Opens a new browser name with no name.</td>
+	 * </tr>
+	 * <tr>
+	 *   <td>_parent</td>
+	 *   <td>Replaces the HTML page from which it came.</td>
+	 * </tr>
+	 * <tr>
+	 *   <td>_top</td>
+	 *   <td>Loads in the current browser, replacing anything within it, such as a frameset.</td>
+	 * </tr>
+	 * </table>
+	 * </p>
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 *
+	 * @see LinkState
+	 * @see FlowElement#linkActiveFormat FlowElement.linkActiveFormat
+	 * @see FlowElement#linkHoverFormat FlowElement.linkHoverFormat
+	 * @see FlowElement#linkNormalFormat FlowElement.linkNormalFormat
+	 * @see ITextFlow
+	 *
+	 */ 
+	
+	public final class LinkElement extends SubParagraphGroupElementBase implements ILinkElement
+	{
+		private var _uriString:String;
+		private var _targetString:String;
+		private var _linkState:String;
+		
+		/** Constructor - creates a new LinkElement instance.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function LinkElement()
+		{
+			super();
+			
+			_linkState = LinkState.LINK;
+		}
+		override public function get className():String{
+			return "LinkElement";
+		}
+		
+		/** @private */
+		public override function get precedence():uint 
+		{ return 800; }
+		
+		/**
+		 * @param type The type of event.
+		 * @param listener The listener function that processes the event. This function must accept an event object 
+		 * as its only parameter and must return nothing, as this example shows:
+		 * <p><code>function(evt:Event):void</code></p>
+		 * The function can have any name.
+		 * @param useCapture Determines whether the listener works in the capture phase or the target 
+		 * and bubbling phases. If <code>useCapture</code> is set to <code>true</code>, the  
+		 * listener processes the event only during the capture phase and not in the target or 
+		 * bubbling phase. If <code>useCapture</code> is <code>false</code>, the listener processes the event only
+		 * during the target or bubbling phase. To listen for the event in all three phases, call 
+		 * <code>addEventListener()</code> twice, once with <code>useCapture</code> set to <code>true</code>, 
+		 * then again with <code>useCapture</code> set to <code>false</code>.
+		 * @param priority 	The priority level of the event listener. Priorities are designated by a 32-bit integer. 
+		 * 					The higher the number, the higher the priority. All listeners with priority <em>n</em> 
+		 * 					are processed before listeners of priority <em>n-1</em>. If two or more listeners share 
+		 * 					the same priority, they are processed in the order in which they were added. The default priority is 0. 
+		 * @param useWeakReference Determines whether the reference to the listener is strong or weak. A strong 
+		 * reference (the default) prevents your listener from being garbage-collected. A weak 
+		 * reference does not. <p>Class-level member functions are not subject to garbage 
+		 * collection, so you can set <code>useWeakReference</code> to <code>true</code> for 
+		 * class-level member functions without subjecting them to garbage collection. If you set
+		 * <code>useWeakReference</code> to <code>true</code> for a listener that is a nested inner 
+		 * function, the function will be garbge-collected and no longer persistent. If you create 
+		 * references to the inner function (save it in another variable) then it is not 
+		 * garbage-collected and stays persistent.</p>
+		 *
+		 * @copy org.apache.flex.events.IEventDispatcher#addEventListener()
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		
+		public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false): void
+		{
+			getEventMirror().addEventListener(type, listener, useCapture, priority, useWeakReference);
+		}
+		
+		/**
+		 * @copy org.apache.flex.events.IEventDispatcher#dispatchEvent()
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		
+		public function dispatchEvent(evt:Event):Boolean
+		{
+			if (!hasActiveEventMirror())
+				return false;
+			return _eventMirror.dispatchEvent(evt);
+		}
+		
+		/**
+		 * @copy org.apache.flex.events.IEventDispatcher#hasEventListener()
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		
+		public function hasEventListener(type:String):Boolean
+		{
+			if (!hasActiveEventMirror())
+				return false;
+			return _eventMirror.hasEventListener(type);
+		}
+		
+		/**
+		 *
+		 * @param type The type of event.
+		 * @param listener The listener object to remove.
+		 * @param useCapture Specifies whether the listener was registered for the capture phase or the target and bubbling phases. If the listener was registered for both the capture phase and the target and bubbling phases, two calls to <code>removeEventListener()</code> are required to remove both: one call with <code>useCapture</code> set to <code>true</code>, and another call with <code>useCapture</code> set to <code>false</code>. 
+		 *
+		 * @copy org.apache.flex.events.IEventDispatcher#removeEventListener().
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		
+		public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false): void
+		{
+			if (hasActiveEventMirror())
+				_eventMirror.removeEventListener(type, listener, useCapture);
+		}
+		
+		/**
+		 * @copy org.apache.flex.events.IEventDispatcher#willTrigger()
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		
+		public function willTrigger(type:String):Boolean
+		{
+			if (!hasActiveEventMirror())
+				return false;
+			return _eventMirror.willTrigger(type);
+		}
+		// end of IEventDispatcher functions
+		
+		/** @private */
+		override protected function get abstract():Boolean
+		{ return false; }
+		
+		/** @private */
+		public override function get defaultTypeName():String
+		{ return "a"; }	
+		
+		
+		/**
+		 * The Uniform Resource Identifier (URI) associated with the LinkElement object.  The URI can be any URI 
+		 * supported by the <code>flash.net.navigateToURL()</code> method. This property maps
+		 * to the <code>request</code> parameter for that method.  
+		 * 
+		 * The URI may also be of the form <code>event:eventType</code>.  When clicked the ITextFlow will generate an event of type <code>eventType</code>.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 *
+	 	 * @see ../../../flash/net/package.html#navigateToURL() flash.net.navigateToURL()
+		 */
+		
+		public function get href():String
+		{
+			return _uriString;
+		}
+		
+		public function set href(newUriString:String):void
+		{
+			_uriString = newUriString;
+			modelChanged(ModelChange.ELEMENT_MODIFIED,this,0,textLength);
+		}
+		
+		/**
+		 * The Target value associated with the LinkElement. Possible values are "_self", "_blank",
+		 * "_parent", and "_top". This value maps to the <code>window</code> parameter of the
+		 * <code>flash.net.navigateToURL()</code> method.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 *
+	 	 * @see ../../../flash/net/package.html#navigateToURL() flash.net.navigateToURL()
+		 */
+		
+		public function get target():String
+		{
+			return _targetString;
+		}
+		public function set target(newTargetString:String):void
+		{
+			_targetString = newTargetString;
+			modelChanged(ModelChange.ELEMENT_MODIFIED,this,0,textLength);
+		}
+		
+		/**
+		 * The current state of the link.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * @see LinkState
+		 */
+		
+		public function get linkState():String
+		{ return _linkState; }
+		
+		/**
+		 *  @private
+		 *  @flexjsignorecoercion org.apache.flex.textLayout.elements.LinkElement
+		 */
+		public override function shallowCopy(startPos:int = 0, endPos:int = -1):IFlowElement
+		{
+			if (endPos == -1)
+				endPos = textLength;
+			
+			var retFlow:LinkElement = super.shallowCopy(startPos, endPos) as LinkElement;
+			retFlow.href = href;
+			retFlow.target = target;
+			return retFlow;
+		}
+		
+		/** @private */
+		public override function mergeToPreviousIfPossible():Boolean
+		{		
+			// In links the eventMirror exists.  TLF ignores that when merging.  
+			// The risk is that everything matches but the user has added a custom listener to the eventMirror.
+			if (parent && !bindableElement)
+			{
+				var myidx:int = parent.getChildIndex(this);
+				if (textLength == 0)
+				{
+					parent.replaceChildren(myidx, myidx + 1, null);
+					return true;
+				}
+				
+				if (myidx != 0 && !hasActiveEventMirror())
+				{
+					var sib:LinkElement = parent.getChildAt(myidx-1) as LinkElement;
+					if (sib != null && !sib.hasActiveEventMirror())
+					{
+						if ((this.href == sib.href) && (this.target == sib.target) && equalStylesForMerge(sib))
+						{							
+							parent.removeChildAt(myidx);
+							if (numChildren > 0)
+								sib.replaceChildren(sib.numChildren,sib.numChildren,this.mxmlChildren);
+							return true;
+						}
+					}
+				}
+			} 
+			return false;
+		}
+		
+		/** 
+		 * Specifies the name of the text format element of a LinkElement when the link is in the normal state.
+		 * @private
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		static public const LINK_NORMAL_FORMAT_NAME:String = "linkNormalFormat";
+		
+		/** 
+		 * Specifies the name of the text format element of a LinkElement when the link is in the active state. 
+		 * @private
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		static public const LINK_ACTIVE_FORMAT_NAME:String = "linkActiveFormat";
+		
+		/** Specifies the name of the text format element of a LinkElement when the cursor is hovering over the link. 
+		 * @private
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		static public const LINK_HOVER_FORMAT_NAME:String  = "linkHoverFormat";
+		
+		private function computeLinkFormat(formatName:String):ITextLayoutFormat
+		{
+			var linkStyle:ITextLayoutFormat = getUserStyleWorker(formatName) as ITextLayoutFormat;
+			if (linkStyle == null)
+			{
+				var tf:ITextFlow = getTextFlow();
+				if (tf)
+					linkStyle = tf.configuration["defaultL" + formatName.substr(1)];
+			}
+			
+			return linkStyle;
+		}
+		/** 
+		 * The state-dependent character attributes for the link.
+		 * @private
+		 */
+		
+		public function get effectiveLinkElementTextLayoutFormat():ITextLayoutFormat
+		{	
+			var cf:ITextLayoutFormat;
+
+			if (_linkState == LinkState.SUPPRESSED)
+				return null;
+			else if (_linkState == LinkState.ACTIVE)
+			{
+				cf = computeLinkFormat("linkActiveFormat");
+				if (cf)
+					return cf;
+			}
+			else if (_linkState == LinkState.HOVER)
+			{
+				cf = computeLinkFormat("linkHoverFormat");
+				if (cf)
+					return cf;
+			}
+			
+			return computeLinkFormat("linkNormalFormat");
+		}
+		
+		/** @private TODO: Possible optimization - replace this with prototype chaining?? */
+		public override function get formatForCascade():ITextLayoutFormat
+		{
+			var superFormat:TextLayoutFormat = TextLayoutFormat(format);
+			var effectiveFormat:ITextLayoutFormat = effectiveLinkElementTextLayoutFormat;
+			if (effectiveFormat || superFormat)
+			{
+				if (effectiveFormat && superFormat)
+				{
+					var resultingTextLayoutFormat:TextLayoutFormat = new TextLayoutFormat(effectiveFormat);
+					if (superFormat)
+						resultingTextLayoutFormat.concatInheritOnly(superFormat);
+					return resultingTextLayoutFormat;
+				}
+				return superFormat ? superFormat : effectiveFormat;
+			}
+			return null;
+		}
+		
+		/** @private */
+		CONFIG::debug public override function setParentAndRelativeStart(newParent:IFlowGroupElement,newStart:int):void
+		{
+			
+			if (groupElement)
+			{
+				var groupTextLength:int = groupElement.rawText ? groupElement.rawText.length : null;
+				assert(groupTextLength == this.textLength, "LinkElement - gc = " + this.groupElement.rawText + " this.textLength = " + this.textLength);
+			}
+			
+			super.setParentAndRelativeStart(newParent,newStart);
+			
+		}
+		
+		/** @private */
+		private function setToState(linkState:String):void
+		{
+			if (_linkState != linkState)
+			{
+				var oldCharAttrs:ITextLayoutFormat = effectiveLinkElementTextLayoutFormat;
+				_linkState = linkState;
+				var newCharAttrs:ITextLayoutFormat = effectiveLinkElementTextLayoutFormat;
+				if (!(TextLayoutFormat.isEqual(oldCharAttrs, newCharAttrs)))
+				{
+					formatChanged(true);
+					var tf:ITextFlow = getTextFlow();
+					if (tf && tf.flowComposer)
+						tf.flowComposer.updateAllControllers();
+				}		
+			}
+		}
+		
+		/** @private */
+		public function chgLinkState(linkState:String):void
+		{
+			if (_linkState != linkState)
+			{
+				_linkState = linkState;
+				formatChanged(false);
+			}
+		}
+		
+		/** @private
+		 * The ElementMouseEventManager calls this method directly. Note that the mouse
+		 * coordinates are unrelated to any coordinate in the container or this element.
+		 */
+		public function mouseDownHandler(mgr:FlowElementMouseEventManager, evt:MouseEvent):void
+		{
+			mgr.setHandCursor(true);
+			setToState(LinkState.ACTIVE);
+			evt.stopImmediatePropagation();								
+		}
+		
+		/** @private
+		 * The ElementMouseEventManager calls this method directly. Note that the mouse
+		 * coordinates are unrelated to any coordinate in the container or this element.
+		 */
+		public function mouseMoveHandler(mgr:FlowElementMouseEventManager, evt:MouseEvent):void
+		{
+			mgr.setHandCursor(true);
+			setToState(evt.buttonDown ? LinkState.ACTIVE : LinkState.HOVER);
+		}
+		
+		/** @private
+		 * The ElementMouseEventManager calls this method directly. Note that the mouse
+		 * coordinates are unrelated to any coordinate in the container or this element.
+		 */
+		public function mouseOutHandler(mgr:FlowElementMouseEventManager, evt:MouseEvent):void
+		{
+			mgr.setHandCursor(false);
+			setToState(LinkState.LINK);
+		}
+		
+		/** @private
+		 * The ElementMouseEventManager calls this method directly. Note that the mouse
+		 * coordinates are unrelated to any coordinate in the container or this element.
+		 */
+		public function mouseOverHandler(mgr:FlowElementMouseEventManager, evt:MouseEvent):void
+		{
+			mgr.setHandCursor(true);
+			setToState(evt.buttonDown ? LinkState.ACTIVE : LinkState.HOVER);
+		}
+		
+		/** @private
+		 * The ElementMouseEventManager calls this method directly. Note that the mouse
+		 * coordinates are unrelated to any coordinate in the container or this element.
+		 */
+		public function mouseUpHandler(mgr:FlowElementMouseEventManager, evt:MouseEvent):void
+		{
+			mgr.setHandCursor(true);				
+			setToState(LinkState.HOVER);
+			evt.stopImmediatePropagation();
+		}
+		
+		/** @private
+		 * The ElementMouseEventManager calls this method directly. Note that the mouse
+		 * coordinates are unrelated to any coordinate in the container or this element.
+		 */
+		public function mouseClickHandler(mgr:FlowElementMouseEventManager, evt:MouseEvent):void
+		{
+			if (_uriString != null)
+			{
+				if ((_uriString.length > 6) && (_uriString.substr(0, 6) == "event:"))
+				{
+					mgr.dispatchFlowElementMouseEvent(_uriString.substring(6, _uriString.length), evt);
+				} 
+				else 
+				{
+					BrowserWindow.open(_uriString, target);
+//					var u:URLRequest = new URLRequest(encodeURI(_uriString));
+//					flash.net.navigateToURL(u, target);
+				}
+			}
+			evt.stopImmediatePropagation();		
+		}
+				
+		/** @private */
+		public override function acceptTextBefore():Boolean 
+		{ return false; }
+		
+		/** @private */
+		public override function acceptTextAfter():Boolean
+		{ return false; }
+		
+		/** @private This is done so that the TextContainerManager can discover LinkElements in a ITextFlow. 
+		 * Links don't use the mouseeventdispatcher for link related events - that's a bug that should be fixed.
+		 * A link may increment the interactiveObjectCount twice - once as as Link and once if it has listeners attached via getEventMirror  */
+		public override function appendElementsForDelayedUpdate(tf:ITextFlow,changeType:String):void
+		{ 
+			if (changeType == ModelChange.ELEMENT_ADDED)
+			{
+				tf.incInteractiveObjectCount();
+				// This is to detect if current paragraph has interactive child
+				getParagraph().incInteractiveChildrenCount() ;
+			}
+			else if (changeType == ModelChange.ELEMENT_REMOVAL)
+			{
+				tf.decInteractiveObjectCount();
+				// This is to detect if current paragraph has interactive child
+				getParagraph().decInteractiveChildrenCount() ;
+			}
+			super.appendElementsForDelayedUpdate(tf,changeType);
+		}
+		
+		/** @private This API supports the inputmanager */
+		public override function updateForMustUseComposer(textFlow:ITextFlow):Boolean
+		{ return true; }
+		
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/LinkState.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/LinkState.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/LinkState.as
new file mode 100644
index 0000000..6392daf
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/LinkState.as
@@ -0,0 +1,69 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+
+	
+	/**
+	 *  The LinkState class defines a set of constants for the <code>linkState</code> property
+	 *  of the LinkElement class. 
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 *
+	 *  @see LinkElement#linkState
+	 */
+	 
+ 	public final class LinkState {
+ 	
+	/** 
+	 * Value for the normal, default link state. 
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	 
+    	public static const LINK:String = "link";
+    
+	/** 
+	 * Value for the hover state, which occurs when you drag the mouse over a link. 
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */ 
+	 
+    	public static const HOVER:String = "hover";
+    
+	/** 
+	 * Value for the active state, which occurs when you hold the mouse down over a link. 
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	 
+    	public static const ACTIVE:String = "active";
+		
+		/** @private Used to turn the link specific formatting off temporarily for markerFormat computations */
+		public static const SUPPRESSED:String = "supressed";
+	}
+}


[15/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ParagraphFormattedElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ParagraphFormattedElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ParagraphFormattedElement.as
new file mode 100644
index 0000000..aff7df7
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ParagraphFormattedElement.as
@@ -0,0 +1,49 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements {
+
+	
+
+	
+	/** The ParagraphFormattedElement class is an abstract base class for FlowElement classes that have paragraph properties.
+	*
+	* <p>You cannot create a ParagraphFormattedElement object directly. Invoking <code>new ParagraphFormattedElement()</code> 
+	* throws an error exception.</p> 
+	*
+	* @playerversion Flash 10
+	* @playerversion AIR 1.5
+	* @langversion 3.0
+	*
+	* @see ContainerFormattedElement
+	* @see ParagraphElement
+	* 
+	*/
+	public class ParagraphFormattedElement extends FlowGroupElement implements IParagraphFormattedElement
+	{
+		/** @private TODO: DELETE THIS CLASS */
+		public override function shallowCopy(startPos:int = 0, endPos:int = -1):IFlowElement
+		{
+			return super.shallowCopy(startPos, endPos) as ParagraphFormattedElement;
+		}
+		override public function get className():String{
+			return "ParagraphFormattedElement";
+		}
+
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/SpanElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/SpanElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/SpanElement.as
new file mode 100644
index 0000000..57887f2
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/SpanElement.as
@@ -0,0 +1,608 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	import org.apache.flex.text.engine.GroupElement;
+	import org.apache.flex.text.engine.TextElement;
+	
+	import org.apache.flex.textLayout.container.IContainerController;
+	import org.apache.flex.textLayout.debug.Debugging;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.events.ModelChange;
+	import org.apache.flex.textLayout.formats.FormatValue;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+	import org.apache.flex.textLayout.formats.WhiteSpaceCollapse;
+
+	import org.apache.flex.textLayout.utils.CharacterUtil;
+	
+
+			
+	[DefaultProperty("mxmlChildren")]
+	
+	/** 
+	* The SpanElement class represents a run of text that has a single set of formatting attributes applied. SpanElement 
+	* objects contain the text in a paragraph. A simple paragraph (ParagraphElement) includes one or more SpanElement objects. 
+	*
+	* <p>A ParagraphElement will have a single SpanElement object if all the text in the paragraph shares the same set of 
+	* attributes. It has multiple SpanElement objects if the text in the paragraph has multiple formats.</p>
+	*
+	* @playerversion Flash 10
+	* @playerversion AIR 1.5
+	* @langversion 3.0
+	*
+	* @see FlowElement
+	* @see ParagraphElement
+	* @see TextFlow
+     	*/
+	public class SpanElement extends FlowLeafElement implements ISpanElement
+	{	
+		
+		/** Constructor - creates a SpanElement object to hold a run of text in a paragraph.
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0
+	 	*/
+	 	
+		public function SpanElement()
+		{
+			super();
+		}
+		override public function get className():String
+		{
+			return "SpanElement";
+		}
+		
+		/** @private */
+		override public function createContentElement():void
+		{
+			if (_blockElement && _blockElement.textBlock)
+				return;
+			
+			calculateComputedFormat();	// BEFORE creating the element
+			_blockElement = new TextElement(_text,null);			
+			CONFIG::debug { Debugging.traceFTECall(_blockElement,null,"new TextElement()"); }
+			CONFIG::debug { Debugging.traceFTEAssign(_blockElement, "text", _text); }
+			super.createContentElement();
+		}
+		
+		/** @private */
+		public override function shallowCopy(startPos:int = 0, endPos:int = -1):IFlowElement
+		{
+			if (endPos == -1)
+				endPos = textLength;
+				
+			// Note to callers: If you are calling this function outside a try/catch, do ensure that the 
+			// state of the model is coherent before the call.
+			var retFlow:SpanElement = super.shallowCopy(startPos, endPos) as SpanElement;
+						
+			var startSpan:int = 0;
+			var endSpan:int = startSpan + textLength;
+			
+			var leafElStartPos:int = startSpan >= startPos ? startSpan : startPos;
+			var leafElEndPos:int =  endSpan < endPos ? endSpan : endPos;
+			if (leafElEndPos == textLength && hasParagraphTerminator)
+				--leafElEndPos;
+				
+			if (leafElStartPos > leafElEndPos)
+				throw RangeError(GlobalSettings.resourceStringFunction("badShallowCopyRange"));
+			
+			if (((leafElStartPos != endSpan) && CharacterUtil.isLowSurrogate(_text.charCodeAt(leafElStartPos))) ||
+				((leafElEndPos != 0) && CharacterUtil.isHighSurrogate(_text.charCodeAt(leafElEndPos-1))))
+					throw RangeError(GlobalSettings.resourceStringFunction("badSurrogatePairCopy"));
+			
+			if (leafElStartPos != leafElEndPos)
+				retFlow.replaceText(0, retFlow.textLength,  _text.substring(leafElStartPos, leafElEndPos));
+			
+			return retFlow;
+		}	
+	
+		/** @private */
+		override protected function get abstract():Boolean
+		{ return false; }		
+		
+		/** @private */
+		public override function get defaultTypeName():String
+		{ return "span"; }
+
+		/** @private */
+		public override function get text():String
+		{
+			// test textLength cause this is a property and the debugger may run this calculation in intermediate states
+			if (textLength == 0)
+				return "";
+			
+			return hasParagraphTerminator ? _text.substr(0,textLength-1) : _text;
+		}
+		/** 
+		 * Receives the String of text that this SpanElement object holds.
+		 *
+		 * <p>The text of a span does not include the carriage return (CR) at the end of the paragraph
+		 * but it is included in the value of <code>textLength</code>.</p>
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	
+//TODO this is only override because we temporarily added a setter to FlowLeafElement
+	 	override public function set text(textValue:String):void
+		{
+			//original code stripped breaking and tab characters.  new code moved to collapseWhitevar newLineTabPattern:RegExp = /[\n\r\t]/g;
+			replaceText(0,textLength, textValue); 
+		} 
+		
+		/** @private */
+		public override function getText(relativeStart:int=0, relativeEnd:int=-1, paragraphSeparator:String="\n"):String
+		{
+			if (relativeEnd == -1)
+				relativeEnd = textLength;
+			
+			if (textLength && relativeEnd == textLength && hasParagraphTerminator)
+				--relativeEnd;		// don't include terminator
+			return _text ? _text.substring(relativeStart, relativeEnd) : "";
+		}
+
+		[RichTextContent]
+		/** 
+		 * Sets text based on content within span tags; always deletes existing children.
+		 * This property is intended for use during MXML compiled import in Flex. Flash Professional ignores this property.
+         * When TLF markup elements have other
+		 * TLF markup elements as children, the children are assigned to this property.
+		 *
+		 * @throws TypeError If array element is not a SpecialCharacterElement or a String.
+		 * @param array - an array of elements within span tags. Each element of array must be a SpecialCharacterElement or a String.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+		public function get mxmlChildren():Array
+		{
+			return [ text ];
+		}
+		public function set mxmlChildren(array:Array):void
+		{
+			/* NOTE: all FlowElement implementers and overrides of mxmlChildren must specify [RichTextContent] metadata */
+
+			var str:String = ElementHelper.getSpanText(array);
+			replaceText(0,textLength, str); 
+		}
+		
+		
+		/** 
+		 * Specifies whether this SpanElement object terminates the paragraph. The SpanElement object that terminates a 
+		 * paragraph has an extra, hidden character at the end. This character is added automatically by the component and is
+		 * included in the value of the <code>textLength</code> property.
+		 * 
+		 * @private */
+		 
+		public function get hasParagraphTerminator():Boolean
+		{
+			var p:IParagraphElement = getParagraph();
+			return (p && p.getLastLeaf() == this); 
+		}
+		
+		/** @private */
+		CONFIG::debug public function verifyParagraphTerminator():void
+		{
+			assert(_text && _text.length && _text.charAt(_text.length-1) == ElementConstants.kParagraphTerminator,
+				"attempting to remove para terminator when it doesn't exist");
+		}
+		
+		
+		/**
+		 * Makes a shallow copy of this SpanElement between 2 character positions
+		 * and returns it as a FlowElement.  Unlike deepCopy, shallowCopy does
+		 * not copy any of the children of this SpanElement.
+		 * 
+		 */
+		 
+		 // If I have a sequence of different sorts of spaces (e.g., en quad, hair space), would I want them converted down to one space? Probably not.
+		 // For now, u0020 is the only space character we consider for eliminating duplicates, though u00A0 (non-breaking space) is potentially eligible. 
+		 private static const _dblSpacePattern:RegExp = /[\u0020]{2,}/g;
+		 // Tab, line feed, and carriage return
+//TODO regex
+		 private static const _newLineTabPattern:RegExp = /foo/g;
+		//  private static const _newLineTabPattern:RegExp = /[\u0009\u000a\u000d]/g;
+		 private static const _tabPlaceholderPattern:RegExp = /\uE000/g;
+		 
+		 // static private const anyPrintChar:RegExp = /[^\s]/g;
+		 // Consider only tab, line feed, carriage return, and space as characters used for pretty-printing. 
+		 // While debatable, this is consistent with what CSS does. 
+//TODO regex
+		 static private const anyPrintChar:RegExp = /foo/g; 
+//		 static private const anyPrintChar:RegExp = /[^\u0009\u000a\u000d\u0020]/g; 
+
+		 /** @private */
+		public override function applyWhiteSpaceCollapse(collapse:String):void
+		{
+			var ffc:ITextLayoutFormat = this.formatForCascade;
+			var wsc:* = ffc ? ffc.whiteSpaceCollapse : undefined;
+			if (wsc !== undefined && wsc != FormatValue.INHERIT)
+				collapse = wsc;
+				
+			var origTxt:String = text;
+			var tempTxt:String = origTxt;
+				
+			if (!collapse /* null == default value == COLLAPSE */ || collapse == WhiteSpaceCollapse.COLLAPSE)
+			{
+				// The span was added automatically when a String was passed to replaceChildren.
+				// If it contains only whitespace, we remove the text.
+				if (impliedElement && parent != null)
+				{
+					// var matchArray:Array = tempTxt.search(anyPrintChar);
+					if (tempTxt.search(anyPrintChar) == -1)
+					{
+						parent.removeChild(this);
+						return;
+					}
+				}
+				
+				// For now, replace the newlines and tabs inside the element with a space.
+				// This is necessary for support of compiled mxml files that have newlines and tabs, because
+				// these are most likely not intended to be part of the text content, but only there so the
+				// text can be conveniently edited in the mxml file. Later on we need to add standalone elements
+				// for <br/> and <tab/>. Note that tab character is not supported in HTML.	
+				tempTxt = tempTxt.replace(_newLineTabPattern, " ");
+
+				// Replace sequences of 2 or more whitespace characters with single space
+				tempTxt = tempTxt.replace(_dblSpacePattern, " ");
+			}
+			
+			// Replace tab placeholders (used for tabs that are expected to survive whitespace collapse) with '\t'
+			tempTxt = tempTxt.replace(_tabPlaceholderPattern, '\t');
+			if (tempTxt != origTxt)
+				replaceText(0, textLength, tempTxt);
+
+			super.applyWhiteSpaceCollapse(collapse);
+		}
+		
+		/** 
+		 * Updates the text in text span based on the specified start and end positions. To insert text, set the end position
+		 * equal to the start position. To append text to the existing text in the span, set the start position and the
+		 * end position equal to the length of the existing text.
+		 *
+		 * <p>The replaced text includes the start character and up to but not including the end character.</p>
+		 * 
+		 *  @param relativeStartPosition The index position of the beginning of the text to be replaced, 
+		 *   relative to the start of the span. The first character in the span is at position 0.
+		 *  @param relativeEndPosition The index one position after the last character of the text to be replaced, 
+		 *   relative to the start of the span. Set this value equal to <code>relativeStartPos</code>
+		 *   for an insert. 
+		 *  @param textValue The replacement text or the text to add, as the case may be.
+		 * 
+		 *  @throws RangeError The <code>relativeStartPosition</code> or <code>relativeEndPosition</code> specified is out of 
+		 * range or a surrogate pair is being split as a result of the replace.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 *
+		 */
+		 
+		public function replaceText(relativeStartPosition:int, relativeEndPosition:int, textValue:String):void
+		{
+			// Note to callers: If you are calling this function outside a try/catch, do ensure that the 
+			// state of the model is coherent before the call.
+			if (relativeStartPosition < 0 || relativeEndPosition > textLength || relativeEndPosition < relativeStartPosition)
+				throw RangeError(GlobalSettings.resourceStringFunction("invalidReplaceTextPositions"));	
+
+
+			if ((relativeStartPosition != 0 && relativeStartPosition != textLength && CharacterUtil.isLowSurrogate(_text.charCodeAt(relativeStartPosition))) ||
+				(relativeEndPosition != 0 && relativeEndPosition != textLength && CharacterUtil.isHighSurrogate(_text.charCodeAt(relativeEndPosition-1))))
+					throw RangeError (GlobalSettings.resourceStringFunction("invalidSurrogatePairSplit"));
+				
+			if (hasParagraphTerminator)
+			{
+				CONFIG::debug { assert(textLength > 0,"invalid span"); }
+				if (relativeStartPosition == textLength)
+					relativeStartPosition--;
+				if (relativeEndPosition == textLength)
+					relativeEndPosition--;
+			}
+			
+			if (relativeEndPosition != relativeStartPosition)
+				modelChanged(ModelChange.TEXT_DELETED,this,relativeStartPosition,relativeEndPosition-relativeStartPosition);
+			
+			replaceTextInternal(relativeStartPosition,relativeEndPosition,textValue);
+			
+			if (textValue && textValue.length)
+				modelChanged(ModelChange.TEXT_INSERTED,this,relativeStartPosition,textValue.length);
+		}
+		private function replaceTextInternal(startPos:int, endPos:int, textValue:String):void
+		{			
+			var textValueLength:int = textValue == null ? 0 : textValue.length;
+			var deleteTotal:int = endPos-startPos;
+			var deltaChars:int =  textValueLength - deleteTotal;
+			if (_blockElement)
+			{
+				(_blockElement as TextElement).replaceText(startPos,endPos,textValue);
+				_text = _blockElement.rawText;
+				CONFIG::debug { Debugging.traceFTECall(null,_blockElement as TextElement,"replaceText",startPos,endPos,textValue); }
+			}
+			else if (_text)
+			{
+				if (textValue)
+					_text = _text.slice(0, startPos) + textValue + _text.slice(endPos, _text.length);
+				else
+					_text = _text.slice(0, startPos) + _text.slice(endPos, _text.length);
+			}
+			else
+				_text = textValue;
+			
+			if (deltaChars != 0)
+			{
+				updateLengths(getAbsoluteStart() + startPos, deltaChars, true);
+				deleteContainerText(endPos,deleteTotal);
+				
+				if (textValueLength != 0)
+				{
+					var enclosingContainer:IContainerController = getEnclosingController(startPos);
+					if (enclosingContainer)
+						enclosingContainer.setTextLength(enclosingContainer.textLength + textValueLength);
+				}
+			}
+
+			CONFIG::debug { 
+				assert(textLength == (_text ? _text.length : 0),"span textLength doesn't match the length of the text property, text property length is " + _text.length.toString() + " textLength property is " + textLength.toString());
+				assert(_blockElement == null || _blockElement.rawText == _text,"mismatched text");
+			}
+		}
+	
+		/** @private */
+		public function addParaTerminator():void
+		{
+			CONFIG::debug 
+			{ 
+				// TODO: Is this assert valid? Do we prevent users from adding para terminators themselves? 
+				if (_blockElement && _blockElement.rawText && _blockElement.rawText.length)
+					assert(_blockElement.rawText.charAt(_blockElement.rawText.length-1) != ElementConstants.kParagraphTerminator,"adding para terminator twice");
+			}
+
+			if(_text && _text.substr(-1) == ElementConstants.kParagraphTerminator)// terminator exists. Bail out.
+				return;
+			replaceTextInternal(textLength,textLength,ElementConstants.kParagraphTerminator);
+			
+			CONFIG::debug 
+			{ 
+				// TODO: Is this assert valid? Do we prevent users from adding para terminators themselves? 
+				if (_blockElement)
+					assert(_blockElement.rawText.charAt(_blockElement.rawText.length-1) == ElementConstants.kParagraphTerminator,"adding para terminator failed");
+			}			
+			
+			modelChanged(ModelChange.TEXT_INSERTED,this,textLength-1,1);
+		}
+		/** @private */
+		public function removeParaTerminator():void
+		{
+			CONFIG::debug 
+			{ 
+				assert(_text && _text.length && _text.charAt(_text.length-1) == ElementConstants.kParagraphTerminator,
+					"attempting to remove para terminator when it doesn't exist");
+			}
+			if(!_text || _text.substr(-1) != ElementConstants.kParagraphTerminator)// no terminator exists. Bail out.
+				return;
+
+			replaceTextInternal(textLength-1,textLength,"");
+			modelChanged(ModelChange.TEXT_DELETED,this,textLength > 0 ? textLength-1 : 0,1);
+		}
+		// **************************************** 
+		// Begin tree modification support code
+		// ****************************************
+
+		/** 
+		 * Splits this SpanElement object at the specified position and returns a new SpanElement object for the content
+		 * that follows the specified position. 
+		 *
+		 * <p>This method throws an error if you attempt to split a surrogate pair. In Unicode UTF-16, a surrogate pair is a pair of 
+		 * 16-bit code units (a high code unit and a low code unit) that represent one of the abstract Unicode characters 
+		 * that cannot be represented in a single 16-bit word. The 16-bit high code unit is in the range of D800 to DBFF. The
+		 * 16-bit low code unit is in the range of DC00 to DFFF.</p>
+		 * 
+		 * @param relativePosition - relative position in the span to create the split
+		 * @return - the newly created span. 
+		 * @throws RangeError <code>relativePosition</code> is less than 0 or greater than textLength or a surrogate pair is being split.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 * 
+	 	 * @private
+	 	 */
+	 	 
+		public override function splitAtPosition(relativePosition:int):IFlowElement
+		{
+			// Note to callers: If you are calling this function outside a try/catch, do ensure that the 
+			// state of the model is coherent before the call.
+			if (relativePosition < 0 || relativePosition > textLength)
+				throw RangeError(GlobalSettings.resourceStringFunction("invalidSplitAtPosition"));
+			
+			if ((relativePosition < textLength) && CharacterUtil.isLowSurrogate(String(text).charCodeAt(relativePosition)))
+				throw RangeError (GlobalSettings.resourceStringFunction("invalidSurrogatePairSplit"));
+			
+			var newSpan:ISpanElement = new SpanElement();
+			// clone styling information
+			newSpan.id = this.id;
+			newSpan.typeName = this.typeName;			
+			
+			if (parent)
+			{
+				var newBlockElement:TextElement;
+				var newSpanLength:int = textLength - relativePosition;
+				if (_blockElement)
+				{
+					// optimized version leverages player APIs
+					// TODO: Jeff to add split on TextElement so we don't have to go find a group every time
+					var group:GroupElement = parent.createContentAsGroup(getElementRelativeStart(parent));
+					
+					var elementIndex:int = group.getElementIndex(_blockElement);
+					
+					CONFIG::debug { assert(elementIndex == parent.getChildIndex(this),"bad group index"); }
+					CONFIG::debug { assert(elementIndex != -1 && elementIndex < group.elementCount,"bad span split"); }
+					//trace("GROUP BEFORE: " + group.rawText);
+					//trace("BLOCK BEFORE: " + group.block.content.rawText);
+					//trace("calling group.splitTextElement("+elementIndex.toString()+","+relativePosition.toString()+")");
+					group.splitTextElement(elementIndex, relativePosition);
+					CONFIG::debug { Debugging.traceFTECall(null,group,"splitTextElement",elementIndex,relativePosition); }
+
+					//trace("GROUP AFTER: " + group.rawText);
+					//trace("BLOCK AFTER: " + group.block.content.rawText);
+					
+					// no guarantee on how the split works
+					_blockElement = group.getElementAt(elementIndex);
+					_text = _blockElement.rawText;
+					CONFIG::debug { Debugging.traceFTECall(_blockElement,group,"getElementAt",elementIndex); }
+					newBlockElement = group.getElementAt(elementIndex+1) as TextElement;
+					CONFIG::debug { Debugging.traceFTECall(newBlockElement,group,"getElementAt",elementIndex+1); }
+				}
+				else if (relativePosition < textLength)
+				{
+					newSpan.text = _text.substr(relativePosition);
+					_text = _text.substring(0, relativePosition);
+				}
+
+				// Split this span at the offset, into two equivalent spans
+				modelChanged(ModelChange.TEXT_DELETED,this,relativePosition,newSpanLength);
+				newSpan.quickInitializeForSplit(this, newSpanLength, newBlockElement);
+
+				setTextLength(relativePosition);
+			
+				// slices it in, sets the parent and the start
+				parent.addChildAfterInternal(this,newSpan);	
+				
+				var p:IParagraphElement = this.getParagraph();
+				p.updateTerminatorSpan(this,newSpan);
+				
+				parent.modelChanged(ModelChange.ELEMENT_ADDED,newSpan,newSpan.parentRelativeStart,newSpan.textLength);
+			}
+			else
+			{
+				// this version also works if para is non-null but may not be as efficient.
+				newSpan.format = format;
+
+				// could be we are splitting 
+				if (relativePosition < textLength)
+				{
+					newSpan.text = String(this.text).substr(relativePosition);
+					replaceText(relativePosition,textLength,null);
+				}
+			}
+			
+			return newSpan;
+		}
+		
+		/** @private */
+		public override function normalizeRange(normalizeStart:uint,normalizeEnd:uint):void
+		{
+			if (this.textLength == 1 && !bindableElement)
+			{
+				var p:IParagraphElement = getParagraph();
+				if (p && p.getLastLeaf() == this)
+				{
+					var prevLeaf:IFlowLeafElement = getPreviousLeaf(p);
+					if (prevLeaf)
+					{
+						if (!TextLayoutFormat.isEqual(this.format, prevLeaf.format))
+							this.format = prevLeaf.format;
+					}
+				}
+			}
+			super.normalizeRange(normalizeStart,normalizeEnd);
+		}
+
+		/** @private */
+		public override function mergeToPreviousIfPossible():Boolean
+		{
+			if (parent && !bindableElement)
+			{
+				var myidx:int = parent.getChildIndex(this);
+				if (myidx != 0)
+				{
+					var sib:SpanElement = parent.getChildAt(myidx-1) as SpanElement;
+					
+					// If the element we're checking for merge has only the terminator, and the previous element
+					// is not a Span, then we always merge with the previous span (NOT the previous sib). 
+					// We just remove this span, and add the terminator to the previous span.
+					if (!sib && this.textLength == 1 && this.hasParagraphTerminator)
+					{
+						var p:IParagraphElement = getParagraph();
+						if (p)
+						{
+							var prevLeaf:IFlowLeafElement = getPreviousLeaf(p) as SpanElement;
+							if (prevLeaf)
+							{
+								parent.removeChildAt(myidx);
+								return true;
+							}
+						}
+					}
+
+					if (sib == null)
+						return false;
+					
+					
+					// If this has an active event mirror do not merge
+					if (this.hasActiveEventMirror())
+						return false;
+					var thisIsSimpleTerminator:Boolean = textLength == 1 && hasParagraphTerminator;
+					// if sib has an active event mirror still merge if this is a simple terminator span
+					if (sib.hasActiveEventMirror() && !thisIsSimpleTerminator)
+						return false;
+					
+					// always merge if this is just a terminator
+					if (thisIsSimpleTerminator || equalStylesForMerge(sib))
+					{
+						CONFIG::debug { assert(this.parent == sib.parent, "Should never merge two spans with different parents!"); }
+						CONFIG::debug { assert(TextLayoutFormat.isEqual(this.formatForCascade,sib.formatForCascade) || (this.textLength == 1 && this.hasParagraphTerminator), "Bad merge!"); }
+
+						// Merge the spans
+						var siblingInsertPosition:int = sib.textLength;
+						sib.replaceText(siblingInsertPosition, siblingInsertPosition, this.text);
+						parent.removeChildAt(myidx);
+						return true;
+					}
+				}
+			} 
+			return false;
+		}
+		
+		// **************************************** 
+		// Begin debug support code
+		// ****************************************	
+		
+		/** @private */
+		CONFIG::debug public override function debugCheckFlowElement(depth:int = 0, extraData:String = ""):int
+		{
+			// debugging function that asserts if the flow element tree is in an invalid state
+			
+			var rslt:int = super.debugCheckFlowElement(depth,"text:"+String(text).substr(0,32)+" "+extraData);
+
+			assert(_blockElement == null || _blockElement.rawText == _text,"debugCheckFlowElement: mismatched text");
+			var textLen:int = textLength;
+			if (_text)
+				rslt += assert(textLen == _text.length,"span is different than its textElement, span text length is " + _text.length.toString() + " expecting " + textLen.toString());
+			else	
+				rslt += assert(textLen == 0,"span is different than its textElement, span text length is null expecting " + textLen.toString());
+			rslt += assert(this != getParagraph().getLastLeaf() || (_text.length >= 1 && _text.substr(_text.length-1,1) == ElementConstants.kParagraphTerminator),"last span in paragraph must end with terminator");
+			return rslt;
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/SpecialCharacterElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/SpecialCharacterElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/SpecialCharacterElement.as
new file mode 100644
index 0000000..d63a065
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/SpecialCharacterElement.as
@@ -0,0 +1,96 @@
+// //////////////////////////////////////////////////////////////////////////////
+//
+// 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
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// //////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+	import org.apache.flex.textLayout.formats.WhiteSpaceCollapse;
+	import org.apache.flex.textLayout.debug.assert;
+
+	/** The SpecialCharacterElement class is an abstract base class for elements that represent special characters.
+	 *
+	 * <p>You cannot create a SpecialCharacterElement object directly. Invoking <code>new SpecialCharacterElement()</code>
+	 * throws an error exception.</p>
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 *
+	 * @see BreakElement
+	 * @see TabElement
+	 */
+	public class SpecialCharacterElement extends SpanElement implements ISpecialCharacterElement
+	{
+		/**  
+		 * Base class - invoking <code>new SpecialCharacterElement()</code> throws an error exception.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public function SpecialCharacterElement()
+		{
+			super();
+			// blockElement = new TextElement(null, null);
+
+			// Set WhiteSpaceCollapse.PRESERVE to prevent merging with a sibling span with WhiteSpaceCollapse.COLLAPSE setting
+			// (during normalization). Otherwise the '\t' will be removed during the call to applyWhiteSpaceCollapse (following normalization).
+			// Once applyWhiteSpaceCollapse has been called, we can allow merging.
+			whiteSpaceCollapse = WhiteSpaceCollapse.PRESERVE;
+		}
+		override public function get className():String{
+			return "SpecialCharacterElement";
+		}
+
+		/**
+		 *  @private
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.ISpanElement
+		 */
+		public override function mergeToPreviousIfPossible():Boolean
+		{
+			if (parent)
+			{
+				var myidx:int = parent.getChildIndex(this);
+				if (myidx != 0)
+				{
+					var sib:ISpanElement = parent.getChildAt(myidx - 1) as ISpanElement;
+					if (sib != null && (sib is SpanElement) && TextLayoutFormat.isEqual(sib.format, format))
+					{
+						CONFIG::debug
+						{
+							assert(this.parent == sib.parent, "Should never merge two spans with different parents!"); }
+
+						// Merge them in the Player's TextBlock structure
+						var siblingInsertPosition:int = sib.textLength;
+						sib.replaceText(siblingInsertPosition, siblingInsertPosition, this.text);
+						parent.replaceChildren(myidx, myidx + 1);
+						return true;
+					}
+				}
+				// make a span and replace ourself
+				var newSib:ISpanElement = ElementHelper.getSpan();
+				newSib.text = this.text;
+				newSib.format = format;
+				parent.replaceChildren(myidx, myidx + 1, newSib);
+				newSib.normalizeRange(0, newSib.textLength);
+				return false;
+			}
+			return false;
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/SubParagraphGroupElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/SubParagraphGroupElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/SubParagraphGroupElement.as
new file mode 100644
index 0000000..816d1e3
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/SubParagraphGroupElement.as
@@ -0,0 +1,95 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+
+	
+
+	
+	/** 
+     * The SubParagraphGroupElement is a grouping element for FlowLeafElements and other classes that extend SubParagraphGroupElementBase.
+	 *
+     * @see org.apache.flex.textLayout.elements.SubParagraphGroupElement
+     * @see org.apache.flex.textLayout.elements.SubParagraphGroupElementBase
+     * @see org.apache.flex.textLayout.elements.FlowLeafElement
+     *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 *
+	 */
+	public final class SubParagraphGroupElement extends SubParagraphGroupElementBase implements ISubParagraphGroupElement
+	{
+        /** Constructor. 
+         * For information on using this class, see <a href='http://blogs.adobe.com/tlf/2011/01/tlf-2-0-changes-subparagraphgroupelements-and-typename-applied-to-textfieldhtmlimporter-and-cssformatresolver.html'>TLF 2.0 SubParagraphGroupElement and typeName</a>.
+		 *
+		 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 *
+	 	 */
+		public function SubParagraphGroupElement()
+		{ super(); }
+		override public function get className():String{
+			return "SubParagraphGroupElement";
+		}
+		
+		/** @private */
+		override protected function get abstract():Boolean
+		{ return false; }
+		
+		/** @private */
+		public override function get defaultTypeName():String
+		{ return "g"; }
+		
+		/** @private Lowest level of precedence. */
+		public override function get precedence():uint 
+		{ return kMinSPGEPrecedence; }
+		
+		/** @private */
+		override public function get allowNesting():Boolean
+		{ return true; }
+		
+		/** @private */
+		public override function mergeToPreviousIfPossible():Boolean
+		{
+			if (parent && !bindableElement && !hasActiveEventMirror())
+			{
+				var myidx:int = parent.getChildIndex(this);
+				if (myidx != 0)
+				{
+					var sib:SubParagraphGroupElement = parent.getChildAt(myidx-1) as SubParagraphGroupElement;
+					// if only one element has an event mirror use that event mirror
+					// for the merged element; if both have active mirrors, do not merge
+					if (sib == null || sib.hasActiveEventMirror())
+						return false;
+					
+					if (equalStylesForMerge(sib))
+					{						
+						parent.removeChildAt(myidx);
+						if (numChildren > 0)
+							sib.replaceChildren(sib.numChildren,sib.numChildren,this.mxmlChildren);
+						return true;
+					}
+				}
+			} 
+			return false;
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/SubParagraphGroupElementBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/SubParagraphGroupElementBase.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/SubParagraphGroupElementBase.as
new file mode 100644
index 0000000..7e22474
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/SubParagraphGroupElementBase.as
@@ -0,0 +1,387 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	import org.apache.flex.events.IEventDispatcher;
+	import org.apache.flex.text.engine.ContentElement;
+	import org.apache.flex.text.engine.GroupElement;
+	import org.apache.flex.textLayout.debug.Debugging;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.events.FlowElementEventDispatcher;
+	import org.apache.flex.textLayout.events.ModelChange;
+	
+
+	
+
+	
+	/** 
+	 * The SubParagraphGroupElementBase class groups FlowLeafElements together. A SubParagraphGroupElementBase is a child of a 
+	 * ParagraphElement object and it can contain one or more FlowLeafElement objects as children.
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 * 
+	 * @see FlowLeafElement
+	 * @see LinkElement
+	 * @see ParagraphElement
+	 * @see TCYElement
+	 */
+	public class SubParagraphGroupElementBase extends FlowGroupElement implements ISubParagraphGroupElementBase
+	{
+		private var _groupElement:GroupElement;
+		
+		/** Maximum precedence value @private */
+		public static const kMaxSPGEPrecedence:uint = 1000;
+		/** Minimum precedence value @private */
+		public static const kMinSPGEPrecedence:uint = 0;
+		
+		/** @private the event dispatcher that acts as an event mirror */
+		public var _eventMirror:FlowElementEventDispatcher = null;
+
+		/** Constructor - creates a new SubParagraphGroupElementBase instance.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		 
+		public function SubParagraphGroupElementBase()
+		{ super(); }
+
+		/** @private */
+		override public function createContentElement():void
+		{
+			if (_groupElement)
+				return;
+				
+			calculateComputedFormat();	// BEFORE creating the element
+			_groupElement = new GroupElement(null);
+			CONFIG::debug { Debugging.traceFTECall(_groupElement,null,"new GroupElement",null); }  
+			for (var i:int = 0; i < numChildren; i++)
+			{
+				var child:IFlowElement = getChildAt(i);
+				child.createContentElement();
+			}			
+			if (parent)
+				parent.insertBlockElement(this, _groupElement);
+		}
+		
+		/** @private */
+		override public function releaseContentElement():void
+		{
+			if (_groupElement == null)
+				return;
+			for (var i:int = 0; i < numChildren; i++)
+			{
+				var child:IFlowElement = getChildAt(i);
+				child.releaseContentElement();
+			}			
+			_groupElement = null;
+			_computedFormat = null;
+		}
+		
+		/**
+		 * @public getter to return the precedence value of this SubParagraphGroupElementBase
+		 * Precedence is used to determine which SPGE element will be the container element
+		 * when two or more SPGEs of the same textLength are inside one another.
+		 * 
+		 * Precedence is used to determine which SubParagraphGroupElementBase is the owner when two or 
+		 * more elements have the same text and are embedded within each other.
+		 * 
+		 * Note: model permits any order and does not enforce precedence.  This is only a feature used by the EditManager
+		 * 
+		 * Example: SPGEs A(precedence 900), B(precedence 400), C(precedence 600)
+		 * Editing Result when all wrap SpanElement "123"
+		 * 
+		 * <A><C><B>123</B></C></A>
+		 * 
+		 * If two or more SPGE's have the same precedence value, then the alphabetic order is used:
+		 * Example: SPGE A(precedence 400), B(precedence 400), C(precedence 600)
+		 * 
+		 * <C><A><B>123</B></A></C>
+		 * 
+		 * Current values for SubParagraphGroupElementBase are:
+		 * 	LinkElement - 800
+		 * 	TCYElement - 100
+		 * 
+		 * If the value is not overriden by descendents of SPGE, then value is kMaxSPGEPrecedence;
+		 * @private
+		 */
+		public function get precedence():uint 
+		{ return kMaxSPGEPrecedence; }
+		
+		 
+		/** @private */
+		public function get groupElement():GroupElement
+		{ return _groupElement; }
+		
+		/** @private
+		 * Gets the EventDispatcher associated with this FlowElement.  Use the functions
+		 * of EventDispatcher such as <code>setEventHandler()</code> and <code>removeEventHandler()</code> 
+		 * to capture events that happen over this FlowLeafElement object.  The
+		 * event handler that you specify will be called after this FlowElement object does
+		 * the processing it needs to do.
+		 * 
+		 * Note that the event dispatcher will only dispatch FlowElementMouseEvent events.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * @see org.apache.flex.events.EventDispatcher
+		 * @see org.apache.flex.textLayout.events.FlowElementMouseEvent
+		 */
+		public override function getEventMirror():IEventDispatcher
+		{
+			if (!_eventMirror)
+				_eventMirror = new FlowElementEventDispatcher(this);
+			return _eventMirror;
+		}
+		
+		/** @private
+		 * Checks whether an event dispatcher is attached, and if so, if the event dispatcher
+		 * has any active listeners.
+		 */
+		public override function hasActiveEventMirror():Boolean
+		{ return _eventMirror && (_eventMirror._listenerCount != 0); }
+		
+		
+		/** @private This is done so that the TextContainerManager can discover EventMirrors in a TextFlow. */
+		public override function appendElementsForDelayedUpdate(tf:ITextFlow, changeType:String):void
+		{ 
+			if (changeType == ModelChange.ELEMENT_ADDED)
+			{
+				if (this.hasActiveEventMirror())
+				{
+					tf.incInteractiveObjectCount();
+					getParagraph().incInteractiveChildrenCount() ;
+				}
+			}
+			else if (changeType == ModelChange.ELEMENT_REMOVAL)
+			{
+				if (this.hasActiveEventMirror())
+				{
+					tf.decInteractiveObjectCount();
+					getParagraph().decInteractiveChildrenCount() ;
+				}
+			}
+			super.appendElementsForDelayedUpdate(tf,changeType);
+		}
+		
+		/** @private */
+		public override function createContentAsGroup(pos:int=0):GroupElement
+		{ return groupElement; }
+
+		/** @private */
+		public override function removeBlockElement(child:IFlowElement, block:ContentElement):void
+		{
+			var idx:int = this.getChildIndex(child);
+			groupElement.replaceElements(idx,idx+1,null);
+			CONFIG::debug { Debugging.traceFTECall(null,groupElement,"replaceElements",idx,idx+1,null); }
+		}
+		
+		/** @private */
+		public override function insertBlockElement(child:IFlowElement, block:ContentElement):void
+		{
+			if (groupElement)
+			{
+				var idx:int = this.getChildIndex(child);
+				var gc:Vector.<ContentElement> = new Vector.<ContentElement>();
+				CONFIG::debug { Debugging.traceFTECall(gc,null,"new Vector.<ContentElement>()"); }
+				gc.push(block);
+				CONFIG::debug { Debugging.traceFTECall(null,gc,"push",block); }
+				groupElement.replaceElements(idx,idx,gc);
+				CONFIG::debug { Debugging.traceFTECall(null,groupElement,"replaceElements",idx,idx,gc); }
+			}
+			else
+			{
+				child.releaseContentElement();
+				
+				var para:IParagraphElement = getParagraph();
+				if (para)
+					para.createTextBlock();
+			}
+		}
+		
+
+		/** @private */
+		public override function hasBlockElement():Boolean
+		{ return groupElement != null; }
+		
+		/** @private */
+		override public function setParentAndRelativeStart(newParent:IFlowGroupElement,newStart:int):void
+		{
+			if (newParent == parent)
+				return;
+		
+			// remove textElement from the parent content
+			if (parent && parent.hasBlockElement() && groupElement)
+				parent.removeBlockElement(this,groupElement);
+			if (newParent && !newParent.hasBlockElement() && groupElement)
+				newParent.createContentElement();
+					
+			super.setParentAndRelativeStart(newParent,newStart);
+			
+			// Update the FTE ContentElement structure. If the parent has FTE elements, then create FTE elements for the leaf node 
+			// if it doesn't already have them, and add them in. If the parent does not have FTE elements, release the leaf's FTE
+			// elements also so they match.
+			if (parent && parent.hasBlockElement())
+			{
+				if (!groupElement)
+					createContentElement();
+				else
+					parent.insertBlockElement(this,groupElement);
+			}
+		}
+		
+		/** @private */
+		public override function replaceChildren(beginChildIndex:int,endChildIndex:int,...rest):void
+		{
+				
+			var applyParams:Array = [beginChildIndex, endChildIndex];
+//TODO fix super
+			super.replaceChildren.apply(this, applyParams.concat(rest));
+			
+			var p:IParagraphElement = this.getParagraph();
+			if (p)
+				p.ensureTerminatorAfterReplace();
+		}
+		
+		/** @private */
+		public override function normalizeRange(normalizeStart:uint,normalizeEnd:uint):void
+		{
+			var idx:int = findChildIndexAtPosition(normalizeStart);
+			if (idx != -1 && idx < numChildren)
+			{
+				var child:IFlowElement = getChildAt(idx);
+				normalizeStart = normalizeStart-child.parentRelativeStart;
+				
+				CONFIG::debug { assert(normalizeStart >= 0, "bad normalizeStart in normalizeRange"); }
+				for (;;)
+				{
+					// watch out for changes in the length of the child
+					var origChildEnd:int = child.parentRelativeStart+child.textLength;
+					child.normalizeRange(normalizeStart,normalizeEnd-child.parentRelativeStart);
+					var newChildEnd:int = child.parentRelativeStart+child.textLength;
+					normalizeEnd += newChildEnd-origChildEnd;	// adjust
+					
+					// no zero length children
+					if (child.textLength == 0 && !child.bindableElement)
+						replaceChildren(idx,idx+1);
+					else if (child.mergeToPreviousIfPossible())
+					{
+						var prevElement:IFlowElement = this.getChildAt(idx-1);
+						// possibly optimize the start to the length of prevelement before the merge
+						prevElement.normalizeRange(0,prevElement.textLength);
+					}
+					else
+						idx++;
+
+					if (idx == numChildren)
+						break;
+					
+					// next child
+					child = getChildAt(idx);
+					
+					if (child.parentRelativeStart > normalizeEnd)
+						break;
+						
+					normalizeStart = 0;		// for the next child	
+				}
+			}
+			ElementHelper.normalizeSubParagraphRange(this);
+		}
+
+		/** @private 
+		 * SubParagraphGroupElement allow deep nesting, but LinkElements and TCYElements do not allow nesting (you can't have a link inside another
+		 * link no matter how many group elements are in between). This function is called only from within the class hierarchy to find out whether 
+		 * a sub-class allows nesting or not. */
+		public function get allowNesting():Boolean
+		{
+			return false;
+		}
+		
+		/** A LinkElement cannot be nested in another LinkElement, regardless of what elements are in between in the hierarchy.
+		 * Likewise a TCYElemen may not be nested. This function checks an incoming element to see if any of its children would
+		 * be disallowed if added to this. */
+		private function checkForNesting(element:SubParagraphGroupElementBase):Boolean
+		{
+			if (element)
+			{
+				if (!element.allowNesting)
+				{
+					if (this.className == element.className || this.getParentByType(element.className))
+						return false;
+				}
+				for (var i:int = element.numChildren - 1; i >= 0; --i)
+					if (!checkForNesting(element.getChildAt(i) as SubParagraphGroupElementBase))
+						return false;
+			}
+			return true;
+		}
+		
+		/** @private */
+		public override function canOwnFlowElement(elem:IFlowElement):Boolean
+		{
+			// Only allow sub-paragraph group elements (with restrictions) and leaf elements 
+			if (elem is IFlowLeafElement)
+				return true;
+			
+			if (elem is SubParagraphGroupElementBase && checkForNesting(elem as SubParagraphGroupElementBase))
+				return true;
+			
+			return false;
+		}
+		
+		/** Helper function for determination of where text should be inserted.  In the case of LinkElements,
+		 * text inserted before the LinkElement and text inserted after the LinkElement should not become
+		 * par of the link.  However, for most other SubParagraphGroupElementBase, inserted text should become
+		 * part of the SubParagraphGroupElementBase.
+		 * @private
+		 * */
+		public function acceptTextBefore():Boolean 
+		{ return true; }
+		
+		/** Helper function for determination of where text should be inserted.  In the case of LinkElements,
+		 * text inserted before the LinkElement and text inserted after the LinkElement should not become
+		 * par of the link.  However, for most other SubParagraphGroupElementBase, inserted text should become
+		 * part of the SubParagraphGroupElementBase.
+		 * @private
+		 * */
+		public function acceptTextAfter():Boolean
+		{ return true; }
+		
+		/** @private */
+		CONFIG::debug public override function debugCheckFlowElement(depth:int = 0, extraData:String = ""):int
+		{
+			// debugging function that asserts if the flow element tree is in an invalid state
+			var rslt:int = super.debugCheckFlowElement(depth," fte:"+getDebugIdentity(groupElement)+" "+extraData);
+			rslt += assert(getParagraph() != null && (parent is IParagraphElement || parent is SubParagraphGroupElementBase), "SubParagraphGroupElementBase must be nested in a pargraph");
+			
+			//groupElement can be null if the Paragraph is overset or not yet composed.  Don't check elementCount - Watson 2283828
+			if(this.groupElement)
+				rslt += assert(this.groupElement.elementCount == this.numChildren,"Bad element count in SubParagraphGroupElementBase");
+				
+			if (parent is IParagraphElement)
+				rslt += assert(this.groupElement != IParagraphElement(parent).getTextBlock().content,"Bad group");
+			return rslt; 
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TCYElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TCYElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TCYElement.as
new file mode 100644
index 0000000..3139c0b
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TCYElement.as
@@ -0,0 +1,141 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	import org.apache.flex.text.engine.TextRotation;
+	import org.apache.flex.textLayout.debug.Debugging;
+	import org.apache.flex.textLayout.formats.BlockProgression;
+	
+	/** 
+	 * The TCYElement (Tatechuuyoko - ta-tae-chu-yo-ko) class is a subclass of SubParagraphGroupElementBase that causes
+	 * text to draw horizontally within a vertical line.  Traditionally, it is used to make small
+	 * blocks of non-Japanese text or numbers, such as dates, more readable.  TCY can be applied to 
+	 * horizontal text, but has no effect on drawing style unless and until it is turned vertically.
+	 * 
+	 * TCY blocks which contain no text will be removed from the text flow during the normalization process.
+	 * <p>
+	 * In the example below, the image on the right shows TCY applied to the number 57, while the
+	 * image on the left has no TCY formatting.</p>
+	 * <p><img src="../../../images/textLayout_TCYElement.png" alt="TCYElement" border="0"/>
+	 * </p>
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 *
+	 * @see TextFlow
+	 * @see ParagraphElement
+	 * @see SpanElement
+	 */
+	public final class TCYElement extends SubParagraphGroupElementBase implements ITCYElement
+	{
+		/** Constructor - creates a new TCYElement instance.
+		 *
+		 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 *
+	 	 */
+		public function TCYElement()
+		{
+			super();
+		}
+		override public function get className():String{
+			return "TCYElement";
+		}
+		
+		/** @private */
+		override public function createContentElement():void
+		{
+			super.createContentElement();
+			updateTCYRotation();
+		}
+		
+		/** @private */
+		override protected function get abstract():Boolean
+		{ return false; }
+		
+		/** @private */
+		public override function get defaultTypeName():String
+		{ return "tcy"; }
+		
+		/** @private */
+        public override function get precedence():uint { return 100; }
+		
+		/** @private */
+		public override function mergeToPreviousIfPossible():Boolean
+		{	
+			if (parent && !bindableElement)
+			{
+				var myidx:int = parent.getChildIndex(this);
+				if (myidx != 0)
+				{
+					var prevEl:TCYElement = parent.getChildAt(myidx - 1) as TCYElement;
+					if(prevEl)
+					{
+						while(this.numChildren > 0)
+						{
+							var xferEl:IFlowElement = this.getChildAt(0);
+							replaceChildren(0, 1);
+							prevEl.replaceChildren(prevEl.numChildren, prevEl.numChildren, xferEl);
+						}
+						parent.replaceChildren(myidx, myidx + 1);								
+						return true;
+					}		
+				}
+			}
+			
+			return false;
+		}
+		
+		/** @private */
+		public override function acceptTextBefore():Boolean 
+		{ 
+			return false; 
+		}
+		
+		/** @private */
+		public override function setParentAndRelativeStart(newParent:IFlowGroupElement,newStart:int):void
+		{
+			super.setParentAndRelativeStart(newParent,newStart);
+			updateTCYRotation();
+		}
+		
+		/** @private */
+		public override function formatChanged(notifyModelChanged:Boolean = true):void
+		{
+			super.formatChanged(notifyModelChanged);
+			updateTCYRotation();
+		}
+		
+		
+		/** @private */
+		private function updateTCYRotation():void
+		{
+			var contElement:IContainerFormattedElement = getAncestorWithContainer();
+			if (groupElement)
+			{
+				groupElement.textRotation = (contElement && contElement.computedFormat.blockProgression == BlockProgression.RL) ? TextRotation.ROTATE_270 : TextRotation.ROTATE_0;
+				CONFIG::debug { Debugging.traceFTEAssign(groupElement,"textRotation",groupElement.textRotation); }
+			}
+		}
+	}
+	
+	
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TabElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TabElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TabElement.as
new file mode 100644
index 0000000..2879cae
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TabElement.as
@@ -0,0 +1,69 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{	
+
+
+	
+	/** 
+	 * The TabElement class represents a &lt;tab/&gt; in the text flow. You assign tab stops as an array of TabStopFormat objects to the 
+	 * <code>ParagraphElement.tabStops</code> property.
+	 * 
+	 * <p><strong>Note</strong>:This class exists primarily to support &lt;tab/&gt; in MXML markup. You can add tab characters (\t) directly 
+	 * into the text like this:</p>
+	 *
+	 * <listing version="3.0" >
+	 * spanElement1.text += '\t';
+	 * </listing>
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 *
+	 * @see org.apache.flex.textLayout.formats.TabStopFormat
+	 * @see FlowElement#tabStops
+	 * @see SpanElement
+	 */
+	 
+	public final class TabElement extends SpecialCharacterElement
+	{
+		/** Constructor - creates a new TabElement instance. 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function TabElement()
+		{
+			super();
+			this.text = '\t';
+		}
+		override public function get className():String{
+			return "TabElement";
+		}
+		
+		/** @private */
+		override protected function get abstract():Boolean
+		{ return false; }
+
+		/** @private */
+		public override function get defaultTypeName():String
+		{ return "tab"; }
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableBlockContainer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableBlockContainer.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableBlockContainer.as
new file mode 100644
index 0000000..5f3f39c
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableBlockContainer.as
@@ -0,0 +1,50 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	import org.apache.flex.core.UIBase;
+	import org.apache.flex.textLayout.compose.ITextFlowTableBlock;
+	
+	/**
+	 * The sprite that contains the table cells. 
+	 **/
+	public class TableBlockContainer extends UIBase
+	{
+//TODO this should probably be an interface to support multiple UI implementations.
+// It's probably not going to work with either SVG or Canvas without hacks.
+		
+		public function TableBlockContainer()
+		{
+			super();
+		}
+		
+		/**
+		 * A reference to the TextFlowTableBlock
+		 **/
+		public var userData:ITextFlowTableBlock;
+		public function getTableWidth():Number
+		{
+			if(!userData)
+				return NaN;
+			if(!userData.parentTable)
+				return NaN;
+			return userData.parentTable.width;
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableBodyElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableBodyElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableBodyElement.as
new file mode 100644
index 0000000..4268118
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableBodyElement.as
@@ -0,0 +1,63 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+
+	
+
+	
+	/** 
+	 * <p> TableBodyElement is an item in a TableElement. It most commonly contains one or more TableRowElement objects, 
+	 * A TableBodyElement always appears within a TableElement.</p>
+	 *
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 *
+	 */
+	public final class TableBodyElement extends TableFormattedElement
+	{		
+		override public function get className():String{
+			return "TableBodyElement";
+		}
+		public var height:Number;
+		
+		/** @private */
+		override protected function get abstract():Boolean
+		{ return false; }
+		
+		/** @private */
+		public override function get defaultTypeName():String
+		{ return "tbody"; }
+		
+		/** @private */
+		public override function canOwnFlowElement(elem:IFlowElement):Boolean
+		{
+			return (elem is ITableRowElement);
+		}
+		
+		/** @private if its in a numbered list expand the damage to all list items - causes the numbers to be regenerated */
+		public override function modelChanged(changeType:String, elem:IFlowElement, changeStart:int, changeLen:int, needNormalize:Boolean = true, bumpGeneration:Boolean = true):void
+		{
+			super.modelChanged(changeType,elem,changeStart,changeLen,needNormalize,bumpGeneration);
+		}
+
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableCellElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableCellElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableCellElement.as
new file mode 100644
index 0000000..45f0de5
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableCellElement.as
@@ -0,0 +1,457 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	import org.apache.flex.textLayout.container.ContainerUtil;
+	import org.apache.flex.textLayout.factory.TLFFactory;
+	import org.apache.flex.textLayout.factory.ITLFFactory;
+	import org.apache.flex.reflection.getDefinitionByName;
+	import org.apache.flex.reflection.getQualifiedClassName;
+	
+	import org.apache.flex.textLayout.compose.ITextFlowLine;
+	import org.apache.flex.textLayout.container.IContainerController;
+	import org.apache.flex.textLayout.events.DamageEvent;
+	import org.apache.flex.textLayout.formats.BlockProgression;
+
+	
+
+	
+	/** 
+	 * TableCellElement is an item in a TableElement. It most commonly contains one or more ParagraphElement objects.
+	 *
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 *
+	 */
+	public final class TableCellElement extends TableFormattedElement implements ITableCellElement
+	{		
+		private var _width:Number;
+		private var _height:Number;
+
+		private var _parcelIndex:int;
+		private var _container:CellContainer;
+		private var _enableIME:Boolean = true;
+		private var _damaged:Boolean = true;
+		private var _controller:IContainerController;
+
+		private var _rowSpan:uint = 1;
+		private var _columnSpan:uint = 1;
+		private var _rowIndex:int = -1;
+		private var _colIndex:int = -1;
+		private var _includeDescentInCellBounds:Boolean;
+		
+		public function TableCellElement()
+		{
+			super();
+			_controller = ContainerUtil.getController(container, NaN, NaN);
+		}
+		override public function get className():String{
+			return "TableCellElement";
+		}
+
+		/** @private */
+		override protected function get abstract():Boolean
+		{ return false; }
+		
+		/** @private */
+		public override function get defaultTypeName():String
+		{ return "td"; }
+		
+		/** @private */
+		public override function canOwnFlowElement(elem:IFlowElement):Boolean
+		{// Table cells have no TLF children. Instead it contains its own TextFlow.
+			return (elem is IFlowElement);
+		}
+
+		public function isDamaged():Boolean {
+			return _damaged || (_textFlow && _textFlow.flowComposer.isPotentiallyDamaged(_textFlow.textLength));
+		}
+		
+		private var _savedPaddingTop:Number = 0;
+		private var _savedPaddingBottom:Number = 0;
+		private var _savedPaddingLeft:Number = 0;
+		private var _savedPaddingRight:Number = 0;
+		
+		public function compose():Boolean {
+			
+			var pt:Number = getEffectivePaddingTop();
+			var pb:Number = getEffectivePaddingBottom();
+			var pl:Number = getEffectivePaddingLeft();
+			var pr:Number = getEffectivePaddingRight();
+
+			if(pt != _savedPaddingTop)
+			{
+				_controller.paddingTop = _savedPaddingTop = pt;
+			}
+			if(pb != _savedPaddingBottom)
+			{
+				_controller.paddingBottom = _savedPaddingBottom = pb;
+			}
+			if(pl != _savedPaddingLeft)
+			{
+				_controller.paddingLeft = _savedPaddingLeft = pl;
+			}
+			if(pr != _savedPaddingRight)
+			{
+				_controller.paddingRight = _savedPaddingRight = pr;
+			}
+
+			var table:ITableElement = this.table;
+			
+			_damaged = false;
+			
+			var compWidth:Number = 0;
+			for(var i:int=0;i<columnSpan;i++)
+			{
+				if (table && table.getColumnAt(colIndex+i)) {
+					compWidth += table.getColumnAt(colIndex+i).columnWidth;
+				}
+				
+			}
+			width = compWidth;
+
+			if (_textFlow && _textFlow.flowComposer) {
+				return _textFlow.flowComposer.compose();
+			}
+			
+			return false;
+		}
+		
+		public function update():Boolean
+		{
+			if(_textFlow && _textFlow.flowComposer){
+				return _textFlow.flowComposer.updateAllControllers();
+			}
+			return false;
+		}
+		
+		public function get parcelIndex():int
+		{
+			return _parcelIndex;
+		}
+		
+		public function set parcelIndex(value:int):void
+		{
+			_parcelIndex = value;
+		}
+		
+		public function get rowIndex():int
+		{
+			return _rowIndex;
+		}
+		
+		public function set rowIndex(value:int):void
+		{
+			_rowIndex = value;
+		}
+		
+		public function get colIndex():int
+		{
+			return _colIndex;
+		}
+		
+		public function set colIndex(value:int):void
+		{
+			_colIndex = value;
+		}
+		
+		protected var _textFlow:ITextFlow;
+		
+		public function get textFlow():ITextFlow {
+			
+			if (_textFlow == null) {
+				var tf:ITextFlow = getTextFlow();
+				var tlfFactory:ITLFFactory;
+				if(tf)
+					tlfFactory = tf.tlfFactory;
+
+				var flow:ITextFlow = ElementHelper.getDefaultTextFlow(tlfFactory);
+				
+				if (table && table.getTextFlow() && table.getTextFlow().interactionManager) {
+					flow.interactionManager = _textFlow.interactionManager.copy(true);
+				}
+				else if(table && table.getTextFlow() && table.getTextFlow().interactionManager) {
+					var im:Class = getDefinitionByName(getQualifiedClassName(table.getTextFlow().interactionManager)) as Class;
+					flow.interactionManager = new im();
+				}
+				else {
+					flow.normalize();
+				}
+				
+				_textFlow = flow;
+
+			}
+			
+			return _textFlow;
+		}
+		
+		public function set textFlow(value:ITextFlow):void
+		{
+			if (_textFlow) {
+				_textFlow.removeEventListener(DamageEvent.DAMAGE, handleCellDamage);
+				_textFlow.flowComposer.removeAllControllers();
+			}
+			
+			_textFlow = value;
+			_textFlow.parentElement = this;
+			_textFlow.flowComposer.addController(_controller);
+			_textFlow.addEventListener(DamageEvent.DAMAGE, handleCellDamage);
+			
+		}
+		
+		public function get controller():IContainerController {
+			return _controller;
+		}
+		
+		private function handleCellDamage(ev:DamageEvent):void{
+			damage();
+		}
+
+		public function get enableIME():Boolean
+		{
+			return _enableIME;
+		}
+
+		public function set enableIME(value:Boolean):void
+		{
+			_enableIME = value;
+		}
+		
+		public function get container():CellContainer{
+			if(!_container){
+				_container = new CellContainer(enableIME);
+				_container.cellElement = this;
+			}
+			
+			return _container;
+		}
+
+		/**
+		 * Gets the width.
+		 **/
+		public function get width():Number
+		{
+			return _width;
+		}
+
+		/**
+		 * @private
+		 **/
+		public function set width(value:Number):void
+		{
+			if(_width != value) {
+				_damaged = true;
+			}
+			
+			_width = value;
+			
+			_controller.setCompositionSize(_width, _controller.compositionHeight);
+		}
+		
+		/**
+		 * Returns the height of the cell. 
+		 **/
+		public function get height():Number
+		{
+			//return getRowHeight(); not sure if we should always use row height
+			return _height;
+		}
+
+		/**
+		 * @private
+		 **/
+		public function set height(value:Number):void
+		{
+			if (_height != value) {
+				_damaged = true;
+			}
+			
+			_height = value;
+			
+			_controller.setCompositionSize(_controller.compositionWidth, _height);
+		}
+		
+		public function getComposedHeight():Number
+		{
+			var descent:Number = 0;
+			if(!includeDescentInCellBounds)
+			{
+				if(_textFlow.flowComposer && _textFlow.flowComposer.numLines)
+				{
+					var lastLine:ITextFlowLine = _textFlow.flowComposer.getLineAt(_textFlow.flowComposer.numLines-1);
+					if(lastLine)
+						descent = lastLine.descent;
+				}
+			}
+			return (_controller.getContentBounds().height - descent);
+		}
+		
+		public function getRowHeight():Number
+		{
+			return getRow() ? getRow().composedHeight : NaN;
+		}
+
+		public function get rowSpan():uint
+		{
+			return _rowSpan;
+		}
+
+		public function set rowSpan(value:uint):void
+		{
+			if(value >= 1)
+				_rowSpan = value;
+		}
+
+		public function get columnSpan():uint
+		{
+			return _columnSpan;
+		}
+
+		public function set columnSpan(value:uint):void
+		{
+			if(value >= 1)
+				_columnSpan = value;
+		}
+		
+		public function updateCompositionShapes():void{
+			_controller.updateCompositionShapes();
+		}
+		
+		/**
+		 * Return the row that this cell is part of or null 
+		 * if not part of a row.
+		 **/
+		public function getRow():ITableRowElement
+		{
+			return table ? table.getRowAt(rowIndex) : null;
+		}
+		
+		/**
+		 * Returns the next cell in the table or null if not part of a
+		 * table or no cells exist after this cell.
+		 **/
+		public function getNextCell():ITableCellElement {
+			return table ? table.getNextCell(this) : null;
+		}
+		
+		/**
+		 * Returns the previous cell in the table or null if not part of a
+		 * table or no cells exist before this cell.
+		 **/
+		public function getPreviousCell():ITableCellElement {
+			return table ? table.getPreviousCell(this) : null;
+		}
+
+		public function get x():Number
+		{
+			return container.x;
+		}
+
+		public function set x(value:Number):void
+		{
+			container.x = value;
+		}
+
+		public function get y():Number
+		{
+			return container.y;
+		}
+
+		public function set y(value:Number):void
+		{
+			container.y = value;
+		}
+
+		public function damage():void
+		{
+			if (table) {
+				table.hasCellDamage = true;
+			}
+			
+			_damaged = true;
+		}
+		
+		/**
+		 * Adds in the table cell spacing, border stroke width. 
+		 * We may be able to set this value when the format changes. 
+		 * For now we just want to get it to work. 
+		 **/
+		public function getTotalPaddingWidth():Number {
+			var paddingAmount:Number = 0;
+			
+			// no textflow is no padding
+			if (!textFlow) {
+				return 0;
+			}
+			
+			if (table && table.cellSpacing!=undefined) {
+				paddingAmount += table.cellSpacing;
+			}
+			
+			if (textFlow.computedFormat.blockProgression == BlockProgression.RL) {
+				paddingAmount += Math.max(getEffectivePaddingTop() + getEffectivePaddingBottom(), getEffectiveBorderTopWidth() + getEffectiveBorderBottomWidth());
+			}
+			else {
+				paddingAmount += Math.max(getEffectivePaddingLeft() + getEffectivePaddingRight(), getEffectiveBorderLeftWidth() + getEffectiveBorderRightWidth());
+			}
+			
+			return paddingAmount;
+		}
+		
+		/**
+		 * Adds in the table cell spacing, border stroke height. 
+		 * We may be able to set this value when the format changes. 
+		 **/
+		public function getTotalPaddingHeight():Number {
+			var paddingAmount:Number = 0;
+			
+			// no textflow is no padding
+			if (!textFlow) {
+				return 0;
+			}
+			
+			if (table && table.cellSpacing!=undefined) {
+				paddingAmount += table.cellSpacing;
+			}
+			
+			if (textFlow.computedFormat.blockProgression == BlockProgression.RL) {
+				paddingAmount += Math.max(getEffectivePaddingLeft() + getEffectivePaddingRight(), getEffectiveBorderLeftWidth() + getEffectiveBorderRightWidth());
+			}
+			else {
+				paddingAmount += Math.max(getEffectivePaddingTop() + getEffectivePaddingBottom(), getEffectiveBorderTopWidth() + getEffectiveBorderBottomWidth());
+			}
+			
+			return paddingAmount;
+		}
+
+		public function get includeDescentInCellBounds():Boolean
+		{
+			return _includeDescentInCellBounds;
+		}
+
+		public function set includeDescentInCellBounds(value:Boolean):void
+		{
+			_includeDescentInCellBounds = value;
+		}
+
+		
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableColElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableColElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableColElement.as
new file mode 100644
index 0000000..449d1a3
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableColElement.as
@@ -0,0 +1,116 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+
+	
+
+	
+	/** 
+	 * <p> TableColElement is an item in a TableElement. It only contains the information of the column formats, 
+	 * A TableColElement always appears within a TableElement, TableColGroupElement.</p>
+	 *
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 *
+	 */
+	public final class TableColElement extends TableFormattedElement implements ITableColElement
+	{		
+		// public var height:Number;
+		private var _x:Number;
+		private var _colIndex:int;
+		
+		public function TableColElement(format:ITextLayoutFormat=null)
+		{
+			super();
+			if(format)
+				this.format = format;
+		}
+
+		override public function get className():String{
+			return "TableColElement";
+		}
+		/** @private */
+		override protected function get abstract():Boolean
+		{ return false; }
+		
+		/** @private */
+		public override function get defaultTypeName():String
+		{ return "col"; }
+		
+		/** @private */
+		public override function canOwnFlowElement(elem:IFlowElement):Boolean
+		{
+			return false;
+		}
+		
+		/** @private if its in a numbered list expand the damage to all list items - causes the numbers to be regenerated */
+		public override function modelChanged(changeType:String, elem:IFlowElement, changeStart:int, changeLen:int, needNormalize:Boolean = true, bumpGeneration:Boolean = true):void
+		{
+			super.modelChanged(changeType,elem,changeStart,changeLen,needNormalize,bumpGeneration);
+		}
+		
+		/**
+		 * Get a Vector of cells or null if the column contains no cells
+		 **/
+		public function get cells():Vector.<ITableCellElement> {
+			
+			if (!table) {
+				return null;
+			}
+			
+			return table.getCellsForColumn(this);
+		}
+		
+		/**
+		 * Returns the number of cells in this column. 
+		 **/
+		public function get numCells():int {
+			
+			if (!table) {
+				return 0;
+			}
+			
+			return table.getCellsForColumn(this).length;
+		}
+
+		public function get x():Number
+		{
+			return _x;
+		}
+
+		public function set x(x:Number):void
+		{
+			this._x = x;
+		}
+
+		public function get colIndex():int
+		{
+			return _colIndex;
+		}
+
+		public function set colIndex(colIndex:int):void
+		{
+			this._colIndex = colIndex;
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableColGroupElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableColGroupElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableColGroupElement.as
new file mode 100644
index 0000000..92f3770
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableColGroupElement.as
@@ -0,0 +1,63 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+
+	
+
+	
+	/** 
+	 * <p> TableColGroupElement is an item in a TableElement. It most commonly contains one or more ParagraphElement objects, 
+	 * A TableRowElement always appears within a TableElement.</p>
+	 *
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 *
+	 */
+	public final class TableColGroupElement extends TableFormattedElement
+	{
+		override public function get className():String{
+			return "TableColGroupElement";
+		}
+		public var height:Number;
+		
+		/** @private */
+		override protected function get abstract():Boolean
+		{ return false; }
+		
+		/** @private */
+		public override function get defaultTypeName():String
+		{ return "colgroup"; }
+		
+		/** @private */
+		public override function canOwnFlowElement(elem:IFlowElement):Boolean
+		{
+			return (elem is ITableColElement);
+		}
+		
+		/** @private if its in a numbered list expand the damage to all list items - causes the numbers to be regenerated */
+		public override function modelChanged(changeType:String, elem:IFlowElement, changeStart:int, changeLen:int, needNormalize:Boolean = true, bumpGeneration:Boolean = true):void
+		{
+			super.modelChanged(changeType,elem,changeStart,changeLen,needNormalize,bumpGeneration);
+		}
+
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableDataCellElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableDataCellElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableDataCellElement.as
new file mode 100644
index 0000000..c31435b
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableDataCellElement.as
@@ -0,0 +1,126 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	
+
+	
+
+	
+	/** 
+	 * <p> TableDataCellElement is an item in a TableRowElement. It most commonly contains one or more IParagraphElement objects, 
+	 * A TableDataCellElement always appears within a TableRowElement.</p>
+	 *
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 *
+	 */
+	public final class TableDataCellElement extends TableFormattedElement
+	{		
+		public var x:Number;
+		public var y:Number;
+		public var width:Number;
+		public var height:Number;
+		private var _parcelIndex:int;
+		
+		private var _rowIndex:int;
+		private var _colIndex:int;
+
+		override public function get className():String{
+			return "TableDataCellElement";
+		}
+		
+		/** @private */
+		override protected function get abstract():Boolean
+		{ return false; }
+		
+		/** @private */
+		public override function get defaultTypeName():String
+		{ return "td"; }
+		
+		/** @private if its in a numbered list expand the damage to all list items - causes the numbers to be regenerated */
+		public override function modelChanged(changeType:String, elem:IFlowElement, changeStart:int, changeLen:int, needNormalize:Boolean = true, bumpGeneration:Boolean = true):void
+		{
+			super.modelChanged(changeType,elem,changeStart,changeLen,needNormalize,bumpGeneration);
+		}
+		
+		/** @private ListItems must begin with zero or more divs with a paragraph */
+		public function normalizeNeedsInitialParagraph():Boolean
+		{
+			var p:FlowGroupElement = this;
+			while (p)
+			{
+				p = p.getChildAt(0) as FlowGroupElement;
+				if (p is IParagraphElement)
+					return false;
+				if (!(p is IDivElement))
+					return true;
+			}
+			return true;
+		}
+		
+		/** @private */
+		public override function normalizeRange(normalizeStart:uint,normalizeEnd:uint):void
+		{
+			super.normalizeRange(normalizeStart,normalizeEnd);
+			
+			// A TableDataCellElement must have a Paragraph at the start. 
+			// note not all browsers behave this way.
+			if (normalizeNeedsInitialParagraph())
+			{
+				var p:IParagraphElement = ElementHelper.getParagraph();
+				replaceChildren(0,0,p);	
+				p.normalizeRange(0,p.textLength);	
+			}
+		}
+		
+		public function get parcelIndex():int
+		{
+			return _parcelIndex;
+		}
+		
+		public function set parcelIndex(value:int):void
+		{
+			_parcelIndex = value;
+		}
+		
+		public function get rowIndex():int
+		{
+			return _rowIndex;
+		}
+		
+		public function set rowIndex(value:int):void
+		{
+			_rowIndex = value;
+		}
+		
+		public function get colIndex():int
+		{
+			return _colIndex;
+		}
+		
+		public function set colIndex(value:int):void
+		{
+			_colIndex = value;
+		}
+		
+	}
+}


[21/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/mementos/DeleteTextMemento.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/mementos/DeleteTextMemento.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/mementos/DeleteTextMemento.as
new file mode 100644
index 0000000..c65802b
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/mementos/DeleteTextMemento.as
@@ -0,0 +1,126 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.edit.mementos {
+	import org.apache.flex.textLayout.elements.FlowElement;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	import org.apache.flex.textLayout.elements.IFlowGroupElement;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.textLayout.elements.IFlowLeafElement;
+	import org.apache.flex.textLayout.edit.ElementMark;
+	import org.apache.flex.textLayout.edit.IMemento;
+
+// Use this for operations that undo using copy & paste
+/**
+ * @flexjsignorecoercion org.apache.flex.textLayout.elements.IFlowGroupElement
+ */
+public class DeleteTextMemento extends BaseMemento implements IMemento
+{
+	private var _commonRootMark:ElementMark;
+	private var _startChildIndex:int;
+	private var _endChildIndex:int;
+	private var _originalChildren:Array;
+	private var _absoluteStart:int;
+		
+	protected var scrapChildren:Array;
+	protected var replaceCount:int;
+
+	public function DeleteTextMemento(textFlow:ITextFlow, absoluteStart:int, absoluteEnd:int)
+	{
+		super(textFlow);
+		
+		// Find the lowest possible common root that contains both start and end, and is at least one paragraph
+		// We move the common root to the paragraph level so that we don't have to worry on undo about spans that have merged.
+		var startLeaf:IFlowLeafElement = textFlow.findLeaf(absoluteStart);
+		//var cRoot:IFlowGroupElement = startLeaf.parent;
+		var cRoot:IFlowGroupElement = startLeaf.getParagraph().parent;
+		while (cRoot && cRoot.parent && (cRoot.getAbsoluteStart() + cRoot.textLength < absoluteEnd || (cRoot.getAbsoluteStart() == absoluteStart && cRoot.getAbsoluteStart() + cRoot.textLength == absoluteEnd)))
+			cRoot = cRoot.parent;
+		
+		// Find even element boundaries smallest amount that contains the entire range
+		if (cRoot)
+		{
+			var rootStart:int = cRoot.getAbsoluteStart();
+			_startChildIndex = cRoot.findChildIndexAtPosition(absoluteStart - rootStart);
+			_endChildIndex = cRoot.findChildIndexAtPosition(absoluteEnd - rootStart - 1);
+			if (_endChildIndex < 0)
+				_endChildIndex = cRoot.numChildren - 1;
+			
+			var startChild:IFlowElement = cRoot.getChildAt(_startChildIndex);
+			var absoluteStartAdjusted:int = startChild.getAbsoluteStart();
+			var endChild:IFlowElement = cRoot.getChildAt(_endChildIndex);
+			var absoluteEndAdjusted:int = endChild.getAbsoluteStart() + endChild.textLength;
+
+			// Set how many elements we expect to replace on undo. Although the delete does a merge at the end if a CR was deleted, the merge
+			// (if there was one) will have been undone before DeleteTextMemento.undo() is called. 
+			// Basic rule is that if there was content before the delete range in the common root, then there will be an element after the delete
+			// with that content that should get replaced. Likewise for if there's content after the delete range in the common root. The exception
+			// to the rule is if the common root is a grandparent of the range to be deleted, then there will be just one element getting replaced.
+			replaceCount = 0;		// how many original (post-do) elements we're replacing
+			if (_startChildIndex == _endChildIndex)
+			{
+				if (absoluteStartAdjusted < absoluteStart || absoluteEndAdjusted > absoluteEnd)	// if we're deleting the entire element, nothing to replace
+					replaceCount = 1;
+			}
+			else
+			{
+				if (absoluteStartAdjusted < absoluteStart)
+					replaceCount++;
+				if (absoluteEndAdjusted > absoluteEnd)
+					replaceCount++;
+			}
+
+			var scrapRoot:IFlowGroupElement = cRoot.deepCopy(absoluteStartAdjusted - rootStart, absoluteEndAdjusted - rootStart) as IFlowGroupElement;
+			scrapChildren = scrapRoot.mxmlChildren;
+		}
+		
+		_commonRootMark = new ElementMark(cRoot, 0);
+		_absoluteStart = absoluteStart;
+	}
+		
+	public function undo():*
+	{ 
+		var root:IFlowGroupElement = commonRoot;
+		
+		// Save off the original children for later redo
+		_originalChildren = [];
+		for (var childIndex:int = _startChildIndex; childIndex < _startChildIndex + replaceCount; ++childIndex)
+			_originalChildren.push(root.getChildAt(childIndex));
+		
+		// Make copies of the scrapChildren, and add the copies to the main flow
+		var addToFlow:Array = [];
+		for each (var element:FlowElement in scrapChildren)
+			addToFlow.push(element.deepCopy());
+		root.replaceChildren(_startChildIndex, _startChildIndex + replaceCount, addToFlow);
+	}
+	
+	public function redo():*
+	{ 
+		commonRoot.replaceChildren(_startChildIndex, _startChildIndex + scrapChildren.length, _originalChildren);
+	}
+	
+	/**
+	 * @flexjsignorecoercion org.apache.flex.textLayout.elements.IFlowGroupElement
+	 */
+	public function get commonRoot():IFlowGroupElement
+	{
+		return _commonRootMark.findElement(_textFlow) as IFlowGroupElement;
+	}
+	
+}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/mementos/InternalSplitFGEMemento.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/mementos/InternalSplitFGEMemento.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/mementos/InternalSplitFGEMemento.as
new file mode 100644
index 0000000..e13017f
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/mementos/InternalSplitFGEMemento.as
@@ -0,0 +1,131 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.edit.mementos {
+	import org.apache.flex.reflection.getQualifiedClassName;
+	import org.apache.flex.textLayout.elements.IFlowLeafElement;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.IFlowGroupElement;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	import org.apache.flex.textLayout.elements.ISubParagraphGroupElementBase;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.textLayout.elements.FlowGroupElement;
+	import org.apache.flex.textLayout.edit.ElementMark;
+	import org.apache.flex.textLayout.edit.IMemento;
+
+	public class InternalSplitFGEMemento extends BaseMemento implements IMemento
+{
+	private var _target:ElementMark;
+	private var _undoTarget:ElementMark;
+	private var _newSibling:FlowGroupElement;
+	private var _skipUndo:Boolean;
+	
+	public function InternalSplitFGEMemento(textFlow:ITextFlow, target:ElementMark, undoTarget:ElementMark, newSibling:FlowGroupElement)
+	{ 
+		super(textFlow); 
+		_target = target;
+		_undoTarget = undoTarget;
+		_newSibling = newSibling;
+		_skipUndo = (newSibling is ISubParagraphGroupElementBase);
+	}
+	
+	public function get newSibling():FlowGroupElement
+	{
+		return _newSibling;
+	}
+	
+	static public function perform(textFlow:ITextFlow, elemToSplit:IFlowElement, relativePosition:int, createMemento:Boolean):*
+	{
+		var target:ElementMark = new ElementMark(elemToSplit,relativePosition);
+		var newSib:FlowGroupElement = performInternal(textFlow, target);
+
+		if (createMemento)
+		{
+			var undoTarget:ElementMark = new ElementMark(newSib,0);
+			return new InternalSplitFGEMemento(textFlow, target, undoTarget, newSib);
+		}
+		else
+			return newSib;
+	}
+	
+	/**
+	 * @flexjsignorecoercion org.apache.flex.textLayout.elements.IFlowGroupElement
+	 */
+	static public function performInternal(textFlow:ITextFlow, target:ElementMark):*
+	{
+		var targetElement:IFlowGroupElement = target.findElement(textFlow) as IFlowGroupElement;
+		var childIdx:int = target.elemStart == targetElement.textLength ? targetElement.numChildren-1 : targetElement.findChildIndexAtPosition(target.elemStart);
+		var child:IFlowElement = targetElement.getChildAt(childIdx);
+		var newSib:IFlowGroupElement;
+		if (child.parentRelativeStart == target.elemStart)
+			newSib = targetElement.splitAtIndex(childIdx);
+		else
+			newSib = targetElement.splitAtPosition(target.elemStart) as IFlowGroupElement;
+		
+		if (targetElement is IParagraphElement)
+		{
+			if (targetElement.textLength <= 1)
+			{
+				targetElement.normalizeRange(0,targetElement.textLength);
+				targetElement.getLastLeaf().quickCloneTextLayoutFormat(newSib.getFirstLeaf());
+			}
+			else if (newSib.textLength <= 1)
+			{
+				newSib.normalizeRange(0,newSib.textLength);
+				newSib.getFirstLeaf().quickCloneTextLayoutFormat(targetElement.getLastLeaf());
+			}
+		}
+		// debugCheckTextFlow("After InternalSplitFGEMemento.perform");
+		
+		return newSib;
+		
+	}
+	
+	/**
+	 * @flexjsignorecoercion org.apache.flex.textLayout.elements.IFlowGroupElement
+	 */
+	public function undo():*
+	{ 
+		// debugCheckTextFlow("Before InternalSplitFGEMemento.undo");
+		if (_skipUndo)
+			return;
+		
+		var target:IFlowGroupElement = _undoTarget.findElement(_textFlow) as IFlowGroupElement;
+		// move all children of target into previoussibling and delete target
+		CONFIG::debug { assert(target != null,"Missing IFlowGroupElement from undoTarget"); }
+		var prevSibling:IFlowGroupElement = target.getPreviousSibling() as IFlowGroupElement;
+		CONFIG::debug { assert(getQualifiedClassName(target) == getQualifiedClassName(prevSibling),"Mismatched class in InternalSplitFGEMemento"); }
+
+		target.parent.removeChild(target);
+		var lastLeaf:IFlowLeafElement = prevSibling.getLastLeaf();
+		prevSibling.replaceChildren(prevSibling.numChildren,prevSibling.numChildren,target.mxmlChildren);
+		
+		// paragraphs only - watch out for trailing empty spans that need to be removed
+		// Harbs 12-24-14 Added check that lastLeaf still exists in the paragraph
+		if (prevSibling is IParagraphElement && lastLeaf.parent && lastLeaf.textLength == 0)
+			prevSibling.removeChild(lastLeaf);
+		
+		// debugCheckTextFlow("After InternalSplitFGEMemento.undo");
+	}
+	
+	public function redo():*
+	{ return performInternal(_textFlow, _target ); }
+}
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/mementos/JoinMemento.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/mementos/JoinMemento.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/mementos/JoinMemento.as
new file mode 100644
index 0000000..c1391f1
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/mementos/JoinMemento.as
@@ -0,0 +1,91 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.edit.mementos {
+	import org.apache.flex.textLayout.edit.ElementMark;
+	import org.apache.flex.textLayout.edit.IMemento;
+	import org.apache.flex.textLayout.edit.TextFlowEdit;
+	import org.apache.flex.textLayout.elements.IFlowGroupElement;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+
+	public class JoinMemento extends BaseMemento implements IMemento {
+		private var _element1:ElementMark;
+		private var _element2:ElementMark;
+		private var _joinPosition:int;
+		private var _removeParentChain:IMemento;
+
+		public function JoinMemento(textFlow:ITextFlow, element1:ElementMark, element2:ElementMark, joinPosition:int, removeParentChain:IMemento) {
+			super(textFlow);
+			_element1 = element1;
+			_element2 = element2;
+			_joinPosition = joinPosition;
+			_removeParentChain = removeParentChain;
+		}
+
+		static public function perform(textFlow:ITextFlow, element1:IFlowGroupElement, element2:IFlowGroupElement, createMemento:Boolean):* {
+			var joinPosition:int = element1.textLength - 1;
+
+			var element1Mark:ElementMark = new ElementMark(element1, 0);
+			var element2Mark:ElementMark = new ElementMark(element2, 0);
+			performInternal(textFlow, element1Mark, element2Mark);
+			var removeParentChain:IMemento = TextFlowEdit.removeEmptyParentChain(element2);
+
+			if (createMemento) {
+				return new JoinMemento(textFlow, element1Mark, element2Mark, joinPosition, removeParentChain);
+			}
+
+			return null;
+		}
+
+		/**
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.IFlowGroupElement
+		 */
+		static public function performInternal(textFlow:ITextFlow, element1Mark:ElementMark, element2Mark:ElementMark):void {
+			var element1:IFlowGroupElement = element1Mark.findElement(textFlow) as IFlowGroupElement;
+			var element2:IFlowGroupElement = element2Mark.findElement(textFlow) as IFlowGroupElement;
+
+			moveChildren(element2, element1);
+		}
+
+		static private function moveChildren(elementSource:IFlowGroupElement, elementDestination:IFlowGroupElement):void {
+			// move children of elementSource to end of elementDestination
+			var childrenToMove:Array = elementSource.mxmlChildren;
+			elementSource.replaceChildren(0, elementSource.numChildren);
+			elementDestination.replaceChildren(elementDestination.numChildren, elementDestination.numChildren, childrenToMove);
+		}
+
+		/**
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.IFlowGroupElement
+		 */
+		public function undo():* {
+			_removeParentChain.undo();
+
+			var element1:IFlowGroupElement = _element1.findElement(_textFlow) as IFlowGroupElement;
+			var element2:IFlowGroupElement = _element2.findElement(_textFlow) as IFlowGroupElement;
+			var tmpElement:IFlowGroupElement = element1.splitAtPosition(_joinPosition) as IFlowGroupElement;
+			// everything after the split moves to element2
+			moveChildren(tmpElement, element2);
+			tmpElement.parent.removeChild(tmpElement);
+		}
+
+		public function redo():* {
+			performInternal(_textFlow, _element1, _element2);
+			_removeParentChain.redo();
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/mementos/MoveElementMemento.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/mementos/MoveElementMemento.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/mementos/MoveElementMemento.as
new file mode 100644
index 0000000..7fa85ea
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/mementos/MoveElementMemento.as
@@ -0,0 +1,77 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.edit.mementos {
+	import org.apache.flex.textLayout.edit.ElementMark;
+	import org.apache.flex.textLayout.edit.IMemento;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	import org.apache.flex.textLayout.elements.IFlowGroupElement;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+
+	public class MoveElementMemento extends BaseMemento implements IMemento {
+		private var _target:ElementMark;
+		private var _targetIndex:int;
+		private var _elemBeforeMove:ElementMark;
+		private var _elemAfterMove:ElementMark;
+		private var _source:ElementMark;		// original parent
+		private var _sourceIndex:int; 			// original index
+
+		public function MoveElementMemento(textFlow:ITextFlow, elemBeforeMove:ElementMark, elemAfterMove:ElementMark, target:ElementMark, targetIndex:int, source:ElementMark, sourceIndex:int) {
+			super(textFlow);
+			_elemBeforeMove = elemBeforeMove;
+			_elemAfterMove = elemAfterMove;
+			_target = target;
+			_targetIndex = targetIndex;
+			_source = source;
+			_sourceIndex = sourceIndex;
+		}
+
+		static public function perform(textFlow:ITextFlow, elem:IFlowElement, newParent:IFlowGroupElement, newIndex:int, createMemento:Boolean):* {
+			var target:ElementMark = new ElementMark(newParent, 0);
+			var elemBeforeMove:ElementMark = new ElementMark(elem, 0);
+
+			var source:IFlowGroupElement = elem.parent;
+			var sourceIndex:int = source.getChildIndex(elem);
+			var sourceMark:ElementMark = new ElementMark(source, 0);
+
+			newParent.addChildAt(newIndex, elem);
+			if (createMemento)
+				return new MoveElementMemento(textFlow, elemBeforeMove, new ElementMark(elem, 0), target, newIndex, sourceMark, sourceIndex);
+			return elem;
+		}
+
+		/**
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.IFlowGroupElement
+		 */
+		public function undo():* {
+			var elem:IFlowElement = _elemAfterMove.findElement(_textFlow);
+			elem.parent.removeChildAt(elem.parent.getChildIndex(elem));
+			var source:IFlowGroupElement = _source.findElement(_textFlow) as IFlowGroupElement;
+			source.addChildAt(_sourceIndex, elem);
+		}
+
+		/**
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.IFlowGroupElement
+		 */
+		public function redo():* {
+			var target:IFlowGroupElement = _target.findElement(_textFlow) as IFlowGroupElement;
+			var elem:IFlowElement = _elemBeforeMove.findElement(_textFlow) as IFlowElement;
+			return perform(_textFlow, elem, target, _targetIndex, false);
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/mementos/RemoveElementsMemento.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/mementos/RemoveElementsMemento.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/mementos/RemoveElementsMemento.as
new file mode 100644
index 0000000..a564792
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/mementos/RemoveElementsMemento.as
@@ -0,0 +1,75 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.edit.mementos {
+	import org.apache.flex.textLayout.edit.ElementMark;
+	import org.apache.flex.textLayout.edit.IMemento;
+	import org.apache.flex.textLayout.elements.IFlowGroupElement;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+
+	public class RemoveElementsMemento extends BaseMemento implements IMemento {
+		private var _elements:Array;
+		private var _elemParent:ElementMark;
+		private var _startIndex:int;
+		private var _numElements:int;
+
+		/**
+		 * RemoveElements from the ITextFlow,
+		 * @param parent parent of elements to rmeove
+		 * @param startIndex index of first child to remove
+		 * @param numElements number of elements to remove
+		 */
+		public function RemoveElementsMemento(textFlow:ITextFlow, elementParent:ElementMark, startIndex:int, numElements:int, elements:Array) {
+			super(textFlow);
+			_elemParent = elementParent;
+			_startIndex = startIndex;
+			_numElements = numElements;
+			_elements = elements;
+		}
+
+		static public function perform(textFlow:ITextFlow, parent:IFlowGroupElement, startIndex:int, numElements:int, createMemento:Boolean):* {
+			var elemParent:ElementMark = new ElementMark(parent, 0);
+
+			// hold on to elements for undo
+			var elements:Array = parent.mxmlChildren.slice(startIndex, startIndex + numElements);
+			// now remove them
+			parent.replaceChildren(startIndex, startIndex + numElements);
+			if (createMemento)
+				return new RemoveElementsMemento(textFlow, elemParent, startIndex, numElements, elements);
+			return elements;
+		}
+
+		/**
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.IFlowGroupElement
+		 */
+		public function undo():* {
+			var parent:IFlowGroupElement = _elemParent.findElement(_textFlow) as IFlowGroupElement;
+			parent.replaceChildren(_startIndex, _startIndex, _elements);
+			_elements = null;	// release the saved elements array
+			return parent.mxmlChildren.slice(_startIndex, _startIndex + _numElements);
+		}
+
+		/**
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.IFlowGroupElement
+		 */
+		public function redo():* {
+			var parent:IFlowGroupElement = _elemParent.findElement(_textFlow) as IFlowGroupElement;
+			_elements = perform(_textFlow, parent, _startIndex, _numElements, false);
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/mementos/SplitMemento.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/mementos/SplitMemento.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/mementos/SplitMemento.as
new file mode 100644
index 0000000..e17ed06
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/mementos/SplitMemento.as
@@ -0,0 +1,126 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.edit.mementos
+{
+	import org.apache.flex.textLayout.edit.ElementMark;
+	import org.apache.flex.textLayout.edit.IMemento;
+	import org.apache.flex.textLayout.edit.ModelEdit;
+	import org.apache.flex.textLayout.elements.FlowGroupElement;
+	import org.apache.flex.textLayout.elements.IContainerFormattedElement;
+	import org.apache.flex.textLayout.elements.IFlowGroupElement;
+	import org.apache.flex.textLayout.elements.IListItemElement;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.textLayout.elements.ElementHelper;
+
+	public class SplitMemento extends BaseMemento implements IMemento {
+		private var _mementoList:Array;
+		private var _target:ElementMark;
+
+		public function SplitMemento(textFlow:ITextFlow, target:ElementMark, mementoList:Array) {
+			super(textFlow);
+			_target = target;
+			_mementoList = mementoList;
+		}
+
+		static public function perform(textFlow:ITextFlow, elemToSplit:IFlowGroupElement, relativePosition:int, createMemento:Boolean):* {
+			var target:ElementMark = new ElementMark(elemToSplit, relativePosition);
+			var mementoList:Array = [];
+
+			var newChild:IFlowGroupElement = performInternal(textFlow, target, createMemento ? mementoList : null);
+
+			if (createMemento)
+				return new SplitMemento(textFlow, target, mementoList);
+
+			return newChild;
+		}
+
+		/**
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.IFlowGroupElement
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.IListItemElement
+		 */
+		static private function testValidLeadingParagraph(elem:IFlowGroupElement):Boolean {
+			// listitems have to have the very first item as a paragraph
+			if (elem.className == "ListItemElement")
+				return !(elem as IListItemElement).normalizeNeedsInitialParagraph();
+
+			while (elem && !(elem.className == "ParagraphElement"))
+				elem = elem.getChildAt(0) as IFlowGroupElement;
+			return elem.className == "ParagraphElement";
+		}
+
+		/**
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.IFlowGroupElement
+		 */
+		static public function performInternal(textFlow:ITextFlow, target:ElementMark, mementoList:Array):FlowGroupElement {
+			// split all the way up the chain and then do a move
+			var targetElement:IFlowGroupElement = target.findElement(textFlow) as IFlowGroupElement;
+			var child:IFlowGroupElement = (target.elemStart == targetElement.textLength ? targetElement.getLastLeaf() : targetElement.findLeaf(target.elemStart)).parent;
+			var newChild:FlowGroupElement;
+
+			var splitStart:int = target.elemStart;
+			var memento:IMemento;
+
+			for (;;) {
+				var splitPos:int = splitStart - (child.getAbsoluteStart() - targetElement.getAbsoluteStart());
+				// if (splitPos != 0)
+				{
+					var splitMemento:InternalSplitFGEMemento = InternalSplitFGEMemento.perform(textFlow, child, splitPos, true);
+					if (mementoList)
+						mementoList.push(splitMemento);
+					newChild = splitMemento.newSibling;
+
+					if (child is IParagraphElement && !(target.elemStart == targetElement.textLength)) {
+						// count the terminator
+						splitStart++;
+					} else if (child is IContainerFormattedElement) {
+						// if its a IContainerFormattedElement there needs to be a paragraph at position zero on each side
+						if (!testValidLeadingParagraph(child)) {
+							memento = ModelEdit.addElement(textFlow, ElementHelper.getParagraph(), child, 0);
+							if (mementoList)
+								mementoList.push(memento);
+							splitStart++;
+						}
+						if (!testValidLeadingParagraph(newChild)) {
+							memento = ModelEdit.addElement(textFlow, ElementHelper.getParagraph(), newChild, 0);
+							if (mementoList)
+								mementoList.push(memento);
+						}
+					}
+				}
+				if (child == targetElement)
+					break;
+				child = child.parent;
+			}
+
+			return newChild;
+		}
+
+		public function undo():* {
+			_mementoList.reverse();
+			for each (var memento:IMemento in  _mementoList)
+				memento.undo();
+			_mementoList.reverse();
+		}
+
+		public function redo():* {
+			return performInternal(_textFlow, _target, null);
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/mementos/TextRangeMemento.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/mementos/TextRangeMemento.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/mementos/TextRangeMemento.as
new file mode 100644
index 0000000..7d8ed98
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/mementos/TextRangeMemento.as
@@ -0,0 +1,30 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.edit.mementos {
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.textLayout.edit.IMemento;
+
+	// Use this for operations that undo using copy & paste
+	public class TextRangeMemento extends DeleteTextMemento implements IMemento {
+		public function TextRangeMemento(textFlow:ITextFlow, absoluteStart:int, absoluteEnd:int) {
+			super(textFlow, absoluteStart, absoluteEnd);
+			replaceCount = scrapChildren.length;
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/BackgroundManager.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/BackgroundManager.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/BackgroundManager.as
new file mode 100644
index 0000000..1a8e325
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/BackgroundManager.as
@@ -0,0 +1,378 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	import org.apache.flex.core.IParentIUIBase;
+	import org.apache.flex.core.IUIBase;
+	import org.apache.flex.geom.Rectangle;
+	import org.apache.flex.graphics.IGraphicShape;
+	import org.apache.flex.text.engine.ITextLine;
+	import org.apache.flex.textLayout.compose.ITextFlowLine;
+	import org.apache.flex.textLayout.container.IContainerController;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.utils.ObjectMap;
+	
+
+	
+	/** @private Manages bounds calculation and rendering of backgroundColor character format. */
+	public class BackgroundManager implements IBackgroundManager	{
+		public static var BACKGROUND_MANAGER_CACHE:ObjectMap = null;
+		
+		public static var TOP_EXCLUDED:String = "topExcluded";
+		public static var BOTTOM_EXCLUDED:String = "bottomExcluded";
+		public static var TOP_AND_BOTTOM_EXCLUDED:String = "topAndBottomExcluded";
+		protected var _lineDict:ObjectMap;
+		protected var _blockElementDict:ObjectMap;
+		protected var _rectArray:Array;
+		
+		public function BackgroundManager()
+		{ 
+			_lineDict = new ObjectMap(true);
+			_blockElementDict = new ObjectMap(true);
+			_rectArray = new Array();
+		}		
+		
+		//clear _rectArray, at the beginning of compose TextFlow
+		public function clearBlockRecord():void
+		{
+			_rectArray.splice(0, _rectArray.length);
+		}
+		
+		//insert the background or border rectangle into the front of _rectArray, to make sure the elements that have 
+		//larger z-index will be drawn later
+		public function addBlockRect(elem:IFlowElement, r:Rectangle, cc:IContainerController = null, style:String = null):void
+		{
+			var rect:Object = {};
+			rect.r = r;
+			rect.elem = elem;
+			rect.cc = cc;
+			rect.style = style;
+			_rectArray.unshift(rect);
+		}
+		
+		//register the elements that have background or border to _blockElementDict
+		public function addBlockElement(elem:IFlowElement):void
+		{
+			//register the elements that have never been registered
+			if(!_blockElementDict.hasOwnProperty(elem))
+			{
+				var format:ITextLayoutFormat = elem.computedFormat;
+				var record:Object = {};
+				record.backgroundColor = format.backgroundColor;
+				record.backgroundAlpha = format.backgroundAlpha;
+				
+				record.borderLeftWidth = format.borderLeftWidth;
+				record.borderRightWidth = format.borderRightWidth;
+				record.borderTopWidth = format.borderTopWidth;
+				record.borderBottomWidth = format.borderBottomWidth;
+			
+
+				record.borderLeftColor = format.borderLeftColor;
+				record.borderRightColor = format.borderRightColor;
+				record.borderTopColor = format.borderTopColor;
+				record.borderBottomColor = format.borderBottomColor;
+				
+				_blockElementDict[elem] = record;
+			}
+		}
+		
+		
+		public function addRect(tl:ITextLine, fle:IFlowLeafElement, r:Rectangle, color:uint, alpha:Number):void
+		{
+			var entry:Array = _lineDict[tl];
+			if (entry == null)
+				entry = _lineDict[tl] = new Array();
+			
+			var record:Object = {};
+			record.rect = r;
+			record.fle = fle;
+			record.color = color;
+			record.alpha = alpha;
+			var fleAbsoluteStart:int = fle.getAbsoluteStart();
+			
+			for (var i:int = 0; i < entry.length; ++i)
+			{
+				var currRecord:Object = entry[i];
+				if (currRecord.hasOwnProperty("fle") && currRecord.fle.getAbsoluteStart() == fleAbsoluteStart)
+				{
+					// replace it
+					entry[i] = record;
+					return;
+				}
+			}
+			entry.push(record);
+		}
+		
+		public function addNumberLine(tl:ITextLine, numberLine:ITextLine):void
+		{
+			var entry:Array = _lineDict[tl];
+			if (entry == null)
+				entry = _lineDict[tl] = new Array();
+			entry.push({numberLine:numberLine});
+		}
+
+		
+		public function finalizeLine(line:ITextFlowLine):void
+		{ return; }	// nothing to do here
+		
+		/** @private */
+		public function getEntry(line:ITextLine):*
+		{
+			return _lineDict ? _lineDict[line] : undefined; 
+		}
+		
+		// This version is used for the TextLineFactory
+		public function drawAllRects(textFlow:ITextFlow, bgShape:IGraphicShape, constrainWidth:Number, constrainHeight:Number):void
+		{
+//IGraphicShape is not approriate we need something more capable
+			//draw background or border for block elements
+//			var block:Object;
+//			var rec:Rectangle;
+//			var style:Object;
+//			for(var idx:int = 0; idx < _rectArray.length; idx++)
+//			{
+//				block = _rectArray[idx];
+//				rec = block.r;
+//				style = _blockElementDict[block.elem];
+//				
+//				if(rec && style)
+//				{
+//					var g:Graphics = bgShape.graphics;
+//					//draw background
+//					if(style.backgroundColor != BackgroundColor.TRANSPARENT)
+//					{
+//						// The value 0 indicates hairline thickness; 
+//						g.lineStyle(NaN, style.backgroundColor, style.backgroundAlpha, true);
+//						g.beginFill(style.backgroundColor, style.backgroundAlpha);
+//						g.drawRect(rec.x, rec.y, rec.width, rec.height);
+//						g.endFill();
+//					}
+//					//draw top border
+//					g.moveTo(rec.x + Math.floor(style.borderLeftWidth/2), rec.y + Math.floor(style.borderTopWidth/2));
+//					if((block.style != BackgroundManager.TOP_EXCLUDED && block.style != BackgroundManager.TOP_AND_BOTTOM_EXCLUDED) &&
+//						style.borderTopWidth != 0 && style.borderTopColor != BorderColor.TRANSPARENT)
+//					{
+//						g.lineStyle(style.borderTopWidth, style.borderTopColor, style.backgroundAlpha, true, "normal", CapsStyle.SQUARE);
+//						g.lineTo(rec.x + rec.width - Math.floor(style.borderLeftWidth/2), rec.y + Math.floor(style.borderTopWidth/2));
+//					}
+//					//draw right border
+//					g.moveTo(rec.x + rec.width - Math.floor(style.borderRightWidth/2), rec.y + Math.floor(style.borderTopWidth/2));
+//					if(style.borderRightWidth != 0 && style.borderRightColor != BorderColor.TRANSPARENT)
+//					{
+//						g.lineStyle(style.borderRightWidth, style.borderRightColor, style.backgroundAlpha, true, "normal", CapsStyle.SQUARE);
+//						g.lineTo(rec.x + rec.width - Math.floor(style.borderRightWidth/2), rec.y + rec.height- Math.floor(style.borderTopWidth/2));
+//					}
+//					//draw bottom border
+//					g.moveTo(rec.x + rec.width - Math.floor(style.borderLeftWidth/2), rec.y + rec.height - Math.floor(style.borderBottomWidth/2));
+//					if((block.style != BackgroundManager.BOTTOM_EXCLUDED && block.style != BackgroundManager.TOP_AND_BOTTOM_EXCLUDED) &&
+//						style.borderBottomWidth != 0 && style.borderBottomColor != BorderColor.TRANSPARENT)
+//					{
+//						g.lineStyle(style.borderBottomWidth, style.borderBottomColor, style.backgroundAlpha, true, "normal", CapsStyle.SQUARE);
+//						g.lineTo(rec.x + Math.floor(style.borderLeftWidth/2), rec.y + rec.height - Math.floor(style.borderBottomWidth/2));
+//					}
+//					//draw left border
+//					g.moveTo(rec.x + Math.floor(style.borderLeftWidth/2), rec.y + rec.height - Math.floor(style.borderTopWidth/2));
+//					if(style.borderLeftWidth != 0 && style.borderLeftColor != BorderColor.TRANSPARENT)
+//					{
+//						g.lineStyle(style.borderLeftWidth, style.borderLeftColor, style.backgroundAlpha, true, "normal", CapsStyle.SQUARE);
+//						g.lineTo(rec.x + Math.floor(style.borderLeftWidth/2), rec.y + Math.floor(style.borderTopWidth/2));
+//					}
+//				}
+//			}
+//			//draw background for span
+//			for (var line:Object in _lineDict)
+//			{
+//				var entry:Array = _lineDict[line];
+//				if (entry.length)
+//				{
+//					var columnRect:Rectangle = entry[0].columnRect;	// set in TextLineFactoryBase.finalizeLine
+//					var r:Rectangle;
+//					var record:Object;
+//					for(var i:int = 0; i<entry.length; ++i)
+//					{
+//						record = entry[i];
+//						if (record.hasOwnProperty("numberLine"))
+//						{
+//							var numberLine:ITextLine = record.numberLine;
+//							var backgroundManager:BackgroundManager = TextFlowLine.getNumberLineBackground(numberLine);
+//							var numberEntry:Array = backgroundManager._lineDict[numberLine];
+//							for (var ii:int = 0; ii < numberEntry.length; ii++)
+//							{
+//								var numberRecord:Object = numberEntry[ii];
+//								r = numberRecord.rect;
+//								r.x += line.x + numberLine.x;
+//								r.y += line.y + numberLine.y;
+//								TextFlowLine.constrainRectToColumn(textFlow, r, columnRect, 0, 0, constrainWidth, constrainHeight)						
+//								
+//								bgShape.graphics.beginFill(numberRecord.color, numberRecord.alpha);
+//								bgShape.graphics.drawRect(r.x,r.y,r.width,r.height);
+//								bgShape.graphics.endFill();
+//							}
+//						}
+//						else
+//						{
+//							r = record.rect;
+//							r.x += line.x;
+//							r.y += line.y;
+//							TextFlowLine.constrainRectToColumn(textFlow, r, columnRect, 0, 0, constrainWidth, constrainHeight)						
+//							
+//							bgShape.graphics.beginFill(record.color, record.alpha);
+//							bgShape.graphics.drawRect(r.x,r.y,r.width,r.height);
+//							bgShape.graphics.endFill();
+//						}
+//					}
+//				}
+//			}
+		}		
+		
+		public function removeLineFromCache(tl:ITextLine):void
+		{
+			delete _lineDict[tl];
+		}
+
+		// This version is used for the TextFlow/flowComposer standard model
+		public function onUpdateComplete(controller:IContainerController):void
+		{
+			var container:IParentIUIBase = controller.container;
+			var bgShape:IUIBase;
+			
+			if(container && container.numElements)
+			{
+				bgShape = controller.getBackgroundShape();
+//				bgShape.graphics.clear();
+//				
+//				//draw background or border for block elements
+//				var rec:Rectangle;
+//				var style:Object;
+//				var block:Object;
+//				for(var idx:int = 0; idx < _rectArray.length; idx++)
+//				{
+//					block = _rectArray[idx];
+//					if(block.cc == controller)
+//					{
+//						style = _blockElementDict[block.elem];
+//						if(style != null)
+//						{
+//							rec = block.r;
+//							var g:Graphics = bgShape.graphics;
+//							//draw background
+//							if(style.backgroundColor != BackgroundColor.TRANSPARENT)
+//							{
+//								// The value 0 indicates hairline thickness; NaN removes line
+//								g.lineStyle(NaN, style.backgroundColor, style.backgroundAlpha, true);
+//								g.beginFill(style.backgroundColor, style.backgroundAlpha);
+//								g.drawRect(rec.x, rec.y, rec.width, rec.height);
+//								g.endFill();
+//							}
+//							//draw top border
+//							g.moveTo(rec.x + Math.floor(style.borderLeftWidth/2), rec.y + Math.floor(style.borderTopWidth/2));
+//							if((block.style != BackgroundManager.TOP_EXCLUDED && block.style != BackgroundManager.TOP_AND_BOTTOM_EXCLUDED) &&
+//								style.borderTopWidth != 0 && style.borderTopColor != BorderColor.TRANSPARENT)
+//							{
+//								g.lineStyle(style.borderTopWidth, style.borderTopColor, style.backgroundAlpha, true, "normal", CapsStyle.SQUARE);
+//								g.lineTo(rec.x + rec.width - Math.floor(style.borderLeftWidth/2), rec.y + Math.floor(style.borderTopWidth/2));
+//							}
+//							//draw right border
+//							g.moveTo(rec.x + rec.width - Math.floor(style.borderRightWidth/2), rec.y + Math.floor(style.borderTopWidth/2));
+//							if(style.borderRightWidth != 0 && style.borderRightColor != BorderColor.TRANSPARENT)
+//							{
+//								g.lineStyle(style.borderRightWidth, style.borderRightColor, style.backgroundAlpha, true, "normal", CapsStyle.SQUARE);
+//								g.lineTo(rec.x + rec.width - Math.floor(style.borderRightWidth/2), rec.y + rec.height- Math.floor(style.borderTopWidth/2));
+//							}
+//							//draw bottom border
+//							g.moveTo(rec.x + rec.width - Math.floor(style.borderLeftWidth/2), rec.y + rec.height - Math.floor(style.borderBottomWidth/2));
+//							if((block.style != BackgroundManager.BOTTOM_EXCLUDED && block.style != BackgroundManager.TOP_AND_BOTTOM_EXCLUDED) &&
+//								style.borderBottomWidth != 0 && style.borderBottomColor != BorderColor.TRANSPARENT)
+//							{
+//								g.lineStyle(style.borderBottomWidth, style.borderBottomColor, style.backgroundAlpha, true, "normal", CapsStyle.SQUARE);
+//								g.lineTo(rec.x + Math.floor(style.borderLeftWidth/2), rec.y + rec.height - Math.floor(style.borderBottomWidth/2));
+//							}
+//							//draw left border
+//							g.moveTo(rec.x + Math.floor(style.borderLeftWidth/2), rec.y + rec.height - Math.floor(style.borderTopWidth/2));
+//							if(style.borderLeftWidth != 0 && style.borderLeftColor != BorderColor.TRANSPARENT)
+//							{
+//								g.lineStyle(style.borderLeftWidth, style.borderLeftColor, style.backgroundAlpha, true, "normal", CapsStyle.SQUARE);
+//								g.lineTo(rec.x + Math.floor(style.borderLeftWidth/2), rec.y + Math.floor(style.borderTopWidth/2));
+//							}
+//						}
+//					}
+//				}
+//				//draw background for span	
+//				for(var childIdx:int = 0; childIdx<controller.textLines.length; ++childIdx)
+//				{
+//					var line:* = controller.textLines[childIdx];
+//					// skip TextFlowTableBlocks
+//					if(!(line is ITextLine))
+//						continue;
+//					var tl:ITextLine = line;
+//					var entry:Array = _lineDict[tl];
+//		
+//					if (entry)
+//					{
+//						var r:Rectangle;
+//						var tfl:TextFlowLine = tl.userData as TextFlowLine;
+//						// assert we actually got a tlf from the userData
+//						CONFIG::debug { assert(tfl != null, "BackgroundManager missing TextFlowLine!"); }
+//						
+//						for(var i:int = 0; i < entry.length; i++)
+//						{
+//							var record:Object = entry[i];
+//							// two kinds of records - numberLines and regular
+//							if (record.hasOwnProperty("numberLine"))
+//							{
+//								var numberLine:ITextLine = record.numberLine;
+//								var backgroundManager:BackgroundManager = TextFlowLine.getNumberLineBackground(numberLine);
+//								var numberEntry:Array = backgroundManager._lineDict[numberLine];
+//								if(numberEntry)
+//								{
+//									for (var ii:int = 0; ii < numberEntry.length; ii++)
+//									{
+//										var numberRecord:Object = numberEntry[ii];
+//										r = numberRecord.rect.clone();
+//										r.x += numberLine.x;
+//										r.y += numberLine.y;
+//										tfl.convertLineRectToContainer(r, true);
+//										
+//										bgShape.graphics.beginFill(numberRecord.color, numberRecord.alpha);
+//										bgShape.graphics.drawRect(r.x,r.y,r.width,r.height);
+//										bgShape.graphics.endFill();
+//									}
+//								}
+//							}
+//							else
+//							{
+//								r = record.rect.clone();
+//								tfl.convertLineRectToContainer(r, true);
+//								
+//								bgShape.graphics.beginFill(record.color, record.alpha);
+//								bgShape.graphics.drawRect(r.x,r.y,r.width,r.height);
+//								bgShape.graphics.endFill();
+//							}
+//						}
+//					}
+//				}
+			}
+		}
+		
+		public function getShapeRectArray():Array
+		{
+			return _rectArray;
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/BreakElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/BreakElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/BreakElement.as
new file mode 100644
index 0000000..cce9d03
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/BreakElement.as
@@ -0,0 +1,66 @@
+// //////////////////////////////////////////////////////////////////////////////
+//
+// 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
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// //////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements {
+	/** 
+	 * The BreakElement class defines a line break, which provides for creating a line break in the text without 
+	 * creating a new paragraph. It inserts a U+2028 character in the text of the paragraph.
+	 *
+	 * <p><strong>Note</strong>: This class exists primarily to support break <br/> tags in MXML markup. To create line breaks, 
+	 * you can add newline characters (\n) directly into the text like this:</p>
+	 *
+	 * <listing version="3.0" >
+	 * spanElement1.text += '\n';
+	 * </listing>
+	 *
+	 * In markup, either FXG, TEXT_LAYOUT_FORMAT or MXML, you can simply insert a <br/> where you want the break.
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 *
+	 * @see ParagraphElement
+	 * @see SpanElement
+	 */
+	public final class BreakElement extends SpecialCharacterElement implements IBreakElement
+	{
+		/** Constructor. 
+		 *
+		 * @playerversion Flash 10 
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function BreakElement() {
+			super();
+			this.text = '\u2028';
+		}
+		override public function get className():String{
+			return "BreakElement";
+		}
+
+		/** @private */
+		override protected function get abstract():Boolean {
+			return false;
+		}
+
+		/** @private */
+		public override function get defaultTypeName():String {
+			return "br";
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/CellContainer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/CellContainer.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/CellContainer.as
new file mode 100644
index 0000000..20311e9
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/CellContainer.as
@@ -0,0 +1,57 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	import org.apache.flex.core.UIBase;
+	
+	//import mx.core.IIMESupport;
+	//TODO support different UIBase classes
+	public class CellContainer extends UIBase// implements IIMESupport
+	{
+		private var _imeMode:String;
+		private var _enableIME:Boolean;
+		//TODO check that "element" was not used for the TableCellElement anywhere because this had to be renamed.
+		public var cellElement:ITableCellElement;
+
+		public function CellContainer(imeEnabled:Boolean = true)
+		{
+			_enableIME = imeEnabled;
+		}
+		
+		public function get enableIME():Boolean
+		{
+			return false;
+		}
+		
+		public function set enableIME(value:Boolean):void
+		{
+			_enableIME = value;
+		}
+		
+		public function get imeMode():String
+		{
+			return _imeMode;
+		}
+		
+		public function set imeMode(value:String):void
+		{
+			_imeMode = value;
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/CellCoordinates.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/CellCoordinates.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/CellCoordinates.as
new file mode 100644
index 0000000..c9e9c56
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/CellCoordinates.as
@@ -0,0 +1,89 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	/**
+	 * Describes the location of table cell by row and column 
+	 **/
+	public class CellCoordinates
+	{
+		private var _column:int;
+		private var _row:int;
+		
+		/**
+		 * @constructor
+		 **/
+		public function CellCoordinates(row:int, column:int, table:ITableElement = null)
+		{
+			_row = row;
+			_column = column;
+			this.table = table;
+		}
+
+		/**
+		 * The column the cell belongs to
+		 **/
+		public function get column():int
+			{return _column;}
+		
+		/**
+		 * @private
+		 **/
+		public function set column(value:int):void
+			{_column = value;}
+
+		/**
+		 * The row the cell belongs to
+		 **/
+		public function get row():int
+			{return _row;}
+		
+		/**
+		 * @private
+		 **/
+		public function set row(value:int):void
+			{_row = value;}
+		
+		/**
+		 * Checks if two coordiates are in the same location
+		 **/
+		public static function areEqual(coords1:CellCoordinates, coords2:CellCoordinates):Boolean
+		{
+			return coords1.row == coords2.row && coords1.column == coords2.column;
+		}
+		
+		/**
+		 * Returns true if the column and row are greater than -1
+		 **/
+		public function isValid():Boolean
+		{
+			return column > -1 && row > -1;
+		}
+		
+		/**
+		 * Creates a new CellCoordinates with the same row and column values
+		 **/
+		public function clone():CellCoordinates
+		{
+			return new CellCoordinates(row, column);
+		}
+
+		public var table:ITableElement;
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/CellRange.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/CellRange.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/CellRange.as
new file mode 100644
index 0000000..fc9ad21
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/CellRange.as
@@ -0,0 +1,150 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package org.apache.flex.textLayout.elements
+{
+
+	
+
+	
+	/**
+	 * A read only class that describes a range of contiguous table cells. Such a range occurs when you select a
+	 * section of table cells. The range consists of the anchor point of the selection, <code>anchorPosition</code>,
+	 * and the point that is to be modified by actions, <code>activePosition</code>.  As block selections are 
+	 * modified and extended <code>anchorPosition</code> remains fixed and <code>activePosition</code> is modified.  
+	 * The anchor position may be placed in the text before or after the active position.
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 *
+	 * @see org.apache.flex.textLayout.elements.TextFlow TextFlow
+	 * @see org.apache.flex.textLayout.edit.SelectionState SelectionState
+	 */
+	public class CellRange
+	{
+		
+		private var _table:ITableElement;
+		
+		// current range of selection
+		private var _anchorCoords:CellCoordinates;
+		private var _activeCoords:CellCoordinates;
+		
+		/**
+		 * Limits the row and column values to 0 or the number of rows or column. 
+		 **/
+		private function clampToRange(coords:CellCoordinates):CellCoordinates
+		{
+			if(coords == null)
+				return null;
+			if (coords.row < 0)
+				coords.row = 0;
+			if (coords.column < 0)
+				coords.column = 0;
+			if(_table == null)
+				return coords;
+			
+			if (coords.row >= _table.numRows)
+				coords.row = _table.numRows-1;
+			if (coords.column >= _table.numColumns)
+				coords.column = _table.numColumns-1;
+			return coords;
+		}
+
+		public function CellRange(table:ITableElement, anchorCoords:CellCoordinates, activeCoords:CellCoordinates)
+		{
+			_table = table;
+			_anchorCoords = clampToRange(anchorCoords);
+			_activeCoords = clampToRange(activeCoords);
+			
+		}
+		
+		/** 
+		 * Update the range with new anchor or active position values.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *  @param newAnchorPosition	the anchor index of the selection.
+		 *  @param newActivePosition	the active index of the selection.
+		 *  @return true if selection is changed.
+		 */
+		public function updateRange(newAnchorCoordinates:CellCoordinates, newActiveCoordinates:CellCoordinates):Boolean
+		{
+			clampToRange(newAnchorCoordinates);
+			clampToRange(newActiveCoordinates);
+			
+			if (!CellCoordinates.areEqual(_anchorCoords, newAnchorCoordinates) || !CellCoordinates.areEqual(_activeCoords, newActiveCoordinates))
+			{
+				_anchorCoords = newAnchorCoordinates;
+				_activeCoords = newActiveCoordinates;
+				return true;
+			}
+			return false;
+		}
+
+		/** The TableElement of the selection.
+		 */
+		public function get table():ITableElement
+		{
+			return _table;
+		}
+
+		/**
+		 * @private
+		 */
+		public function set table(value:ITableElement):void
+		{
+			_table = value;
+		}
+
+		/** 
+		 * Anchor point of the current selection, as a CellCoordinates in the TableElement. 
+		 */
+		public function get anchorCoordinates():CellCoordinates
+		{
+			return _anchorCoords;
+		}
+
+		/**
+		 * @private
+		 */
+		public function set anchorCoordinates(value:CellCoordinates):void
+		{
+			_anchorCoords = value;
+		}
+
+		/** 
+		 * Active end of the current selection, as a CellCoordinates in the TableElement. 
+		 */
+		public function get activeCoordinates():CellCoordinates
+		{
+			return _activeCoords;
+		}
+
+		/**
+		 * @private
+		 */
+		public function set activeCoordinates(value:CellCoordinates):void
+		{
+			_activeCoords = value;
+		}
+
+
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ConfigSettings.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ConfigSettings.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ConfigSettings.as
new file mode 100644
index 0000000..c42c75c
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ConfigSettings.as
@@ -0,0 +1,25 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	public class ConfigSettings
+	{
+		static public var usesDiscretionaryHyphens:Boolean = true;
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/Configuration.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/Configuration.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/Configuration.as
new file mode 100644
index 0000000..9b6171d
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/Configuration.as
@@ -0,0 +1,623 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements {
+	import org.apache.flex.textLayout.compose.utils.StandardHelper;
+	import org.apache.flex.textLayout.edit.SelectionFormat;
+	import org.apache.flex.textLayout.formats.FormatValue;
+	import org.apache.flex.textLayout.formats.IListMarkerFormat;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.formats.ListMarkerFormat;
+	import org.apache.flex.textLayout.formats.TextDecoration;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+
+	
+
+	
+	/** 
+	* The Configuration class is a primary point of integration between the Text Layout Framework and an application. You can 
+	* include a Configuration object as a parameter to the <code>TextFlow()</code> constructor when you create a new TextFlow
+	* instance. It allows the application to initially control how the Text Layout Framework behaves.
+	* 
+	* <p>The Configuration class allows you to specify initial, paragraph and container formats for the text flow 
+	* through the <code>textFlowInitialFormat</code> property. It also allows you to specify initial format attributes for links, selection,
+	* scrolling, and for handling the Tab and Enter keys.</p>
+	*
+	* @playerversion Flash 10
+	* @playerversion AIR 1.5
+	* @langversion 3.0
+	* 
+	* @see org.apache.flex.textLayout.formats.ITextLayoutFormat ITextLayoutFormat
+	* @see org.apache.flex.textLayout.edit.SelectionFormat SelectionFormat
+	* @see TextFlow
+	*/
+	
+	public class Configuration implements IConfiguration
+	{
+		/** @private */
+		static public function versionIsAtLeast(major:int,minor:int):Boolean
+		{ 
+//TODO do we need this?
+			var versionData:Array = ["11","4","0"];//Capabilities.version.split(" ")[1].split(","); 
+			return int(versionData[0]) > major || (int(versionData[0]) == major && int(versionData[1]) >= minor);
+		}
+		
+		static public const DIFFERENCE:String = "difference";
+		
+		/** @private The player may disable the feature for older swfs.  */
+	//	static public const playerEnablesArgoFeatures:Boolean = versionIsAtLeast(10,1); 
+		
+		/** @private The player may disable the feature for older swfs, so its not enough to check
+		the Player version number, the SWF must also be marked as a version 11 SWF to use Spicy features.  */
+		
+		static public const SHIFT_RETURN_AS_HARD:int = 0;
+		static public const SHIFT_RETURN_AS_HARD_IN_LIST:int = 1;
+		static public const SHIFT_RETURN_AS_SOFT:int = 2;
+		
+		static public var defaultShiftEnterLevel:int = SHIFT_RETURN_AS_SOFT;
+		
+		/** If manageTabKey and manageEnterKey are false, the client must handle those keys on their own. */
+		private var _manageTabKey:Boolean;
+		private var _manageEnterKey:Boolean;
+		
+		private var _shiftEnterLevel:int = defaultShiftEnterLevel;
+		
+		private var _overflowPolicy:String;
+		
+		private var _enableAccessibility:Boolean;
+		private var _releaseLineCreationData:Boolean;
+		
+		private var _defaultLinkNormalFormat:ITextLayoutFormat;
+		private var _defaultLinkActiveFormat:ITextLayoutFormat;
+		private var _defaultLinkHoverFormat:ITextLayoutFormat;
+		
+		private var _defaultListMarkerFormat:IListMarkerFormat;
+		
+		private var _textFlowInitialFormat:ITextLayoutFormat;
+		
+		private var _focusedSelectionFormat:SelectionFormat;
+		private var _unfocusedSelectionFormat:SelectionFormat;
+		private var _inactiveSelectionFormat:SelectionFormat;	
+		
+		// scrolling vars
+		private var _scrollDragDelay:Number;
+		private var _scrollDragPixels:Number;
+		private var _scrollPagePercentage:Number;
+		private var _scrollMouseWheelMultiplier:Number;
+		
+		private var _flowComposerClass:Class;
+		private var _inlineGraphicResolverFunction:Function;
+		private var _cursorFunction:Function;
+		
+		/** Constructor - creates a default configuration. 
+		*
+		* @param initializeWithDefaults Specifies whether to initialize the configuration with
+		* the default values. Default is <code>true</code>. If set to <code>false</code>, initializes
+		* without default values, thereby saving some objects. The <code>clone()</code> method sets this
+		* to <code>false</code> and copies the properties from the original object.
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0
+	 	* 
+		* @see org.apache.flex.textLayout.edit.SelectionFormat SelectionFormat
+		* @see org.apache.flex.textLayout.compose.StandardFlowComposer StandardFlowComposer
+		*/
+		public function Configuration(initializeWithDefaults:Boolean = true)
+		{
+			if (initializeWithDefaults)
+				initialize();
+		}
+		
+		private function initialize():void
+		{
+			var scratchFormat:TextLayoutFormat;
+	
+			_manageTabKey = false;
+			_manageEnterKey = true;
+			_overflowPolicy = OverflowPolicy.FIT_DESCENDERS;
+			_enableAccessibility = false;
+			_releaseLineCreationData = false;
+			
+			_focusedSelectionFormat = new SelectionFormat(0xffffff, 1.0, DIFFERENCE);
+			_unfocusedSelectionFormat = new SelectionFormat(0xffffff, 0, DIFFERENCE, 0xffffff, 0.0, DIFFERENCE, 0);
+			_inactiveSelectionFormat  = _unfocusedSelectionFormat;
+				
+			scratchFormat = new TextLayoutFormat();
+			scratchFormat.textDecoration = TextDecoration.UNDERLINE;
+			scratchFormat.color = 0x0000FF;//default link color is blue
+			_defaultLinkNormalFormat = scratchFormat;
+			
+			var listMarkerFormat:ListMarkerFormat = new ListMarkerFormat();
+			listMarkerFormat.paragraphEndIndent = 4;
+			_defaultListMarkerFormat = listMarkerFormat;
+				
+			scratchFormat = new TextLayoutFormat();
+			scratchFormat.lineBreak = FormatValue.INHERIT;
+			scratchFormat.paddingLeft = FormatValue.INHERIT;
+			scratchFormat.paddingRight = FormatValue.INHERIT;
+			scratchFormat.paddingTop = FormatValue.INHERIT;
+			scratchFormat.paddingBottom = FormatValue.INHERIT;
+			scratchFormat.marginLeft = FormatValue.INHERIT;
+			scratchFormat.marginRight = FormatValue.INHERIT;
+			scratchFormat.marginTop = FormatValue.INHERIT;
+			scratchFormat.marginBottom = FormatValue.INHERIT;
+			scratchFormat.borderLeftWidth = FormatValue.INHERIT;
+			scratchFormat.borderRightWidth = FormatValue.INHERIT;
+			scratchFormat.borderTopWidth = FormatValue.INHERIT;
+			scratchFormat.borderBottomWidth = FormatValue.INHERIT;
+			scratchFormat.verticalAlign = FormatValue.INHERIT;
+			scratchFormat.columnCount = FormatValue.INHERIT;
+			scratchFormat.columnCount = FormatValue.INHERIT;
+			scratchFormat.columnGap = FormatValue.INHERIT;
+			scratchFormat.columnWidth = FormatValue.INHERIT;
+			_textFlowInitialFormat = scratchFormat;
+					
+			_scrollDragDelay = 35;
+			_scrollDragPixels = 20;
+			_scrollPagePercentage = 7.0/8.0;
+			_scrollMouseWheelMultiplier = 20;
+				
+			_flowComposerClass = StandardHelper.getStandardClass();
+		}
+		
+		private var _immutableClone:IConfiguration;
+		
+		/**
+		 *  TextFlows are configured with an immutable clone of a Configuration.  Once a TextFlow is create it uses an immutable configuration.
+		 *  @private
+		 *  @flexjsignorecoercion org.apache.flex.textLayout.elements.Configuration
+		 */
+		public function getImmutableClone():IConfiguration
+		{
+			if (!_immutableClone)
+			{
+				var clonedConifg:Configuration = clone() as Configuration;
+				_immutableClone = clonedConifg;
+				// an immutable clone is its own immutable clone
+				clonedConifg._immutableClone = clonedConifg;
+			}
+			return _immutableClone; 
+		}
+		
+		/** Creates a clone of the Configuration object.
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0
+	 	*/
+		public function clone():IConfiguration
+		{
+			var config:Configuration = new Configuration(false);
+			// must copy all values
+			config.defaultLinkActiveFormat = defaultLinkActiveFormat;
+			config.defaultLinkHoverFormat  = defaultLinkHoverFormat;
+			config.defaultLinkNormalFormat = defaultLinkNormalFormat;
+			config.defaultListMarkerFormat = defaultListMarkerFormat;
+			config.textFlowInitialFormat = _textFlowInitialFormat;
+			config.focusedSelectionFormat = _focusedSelectionFormat;
+			config.unfocusedSelectionFormat = _unfocusedSelectionFormat;
+			config.inactiveSelectionFormat = _inactiveSelectionFormat;
+			
+			config.manageTabKey = _manageTabKey;
+			config.manageEnterKey = _manageEnterKey;
+			config.overflowPolicy = _overflowPolicy;
+			config.enableAccessibility = _enableAccessibility;
+			config.releaseLineCreationData = _releaseLineCreationData;
+			
+			config.scrollDragDelay = _scrollDragDelay;
+			config.scrollDragPixels = _scrollDragPixels;
+			config.scrollPagePercentage = _scrollPagePercentage;
+			config.scrollMouseWheelMultiplier = _scrollMouseWheelMultiplier;
+			
+			config.flowComposerClass = _flowComposerClass;
+			config._inlineGraphicResolverFunction = _inlineGraphicResolverFunction;
+			config._cursorFunction = _cursorFunction;
+			return config; 
+		}
+		
+		/** @copy IConfiguration#manageTabKey
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0
+		*/
+		
+		public function get manageTabKey():Boolean
+		{ return _manageTabKey; }
+		public function set manageTabKey(value:Boolean):void
+		{ _manageTabKey = value; _immutableClone = null; }
+
+		/** 
+		* @copy IConfiguration#manageEnterKey
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0
+		*/
+		
+		public function get manageEnterKey():Boolean
+		{ return _manageEnterKey; }
+		public function set manageEnterKey(value:Boolean):void
+		{ _manageEnterKey = value; _immutableClone = null; }
+		
+		/** 
+		 * @copy IConfiguration#shiftEnterLevel
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		
+		public function get shiftEnterLevel():int
+		{ return _shiftEnterLevel; }
+		public function set shiftEnterLevel(value:int):void
+		{ _shiftEnterLevel = value; }
+		
+		/** 
+		* @copy IConfiguration#overflowPolicy
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0
+	 	*
+		* @see OverflowPolicy
+		*/
+
+		public function get overflowPolicy():String
+		{ 	return _overflowPolicy; }
+		public function set overflowPolicy(value:String):void
+		{ 	_overflowPolicy = value; }
+				
+		/** 
+		* @copy IConfiguration#defaultLinkNormalFormat
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0
+	 	*
+		* @see FlowElement#linkNormalFormat
+		* @see org.apache.flex.textLayout.formats.ITextLayoutFormat ITextLayoutFormat
+		* @see LinkElement
+		*/
+		
+		public function get defaultLinkNormalFormat():ITextLayoutFormat
+		{ return _defaultLinkNormalFormat; }
+		public function set defaultLinkNormalFormat(value:ITextLayoutFormat):void
+		{ _defaultLinkNormalFormat = value; _immutableClone = null; }
+
+		/** 
+		 * @copy IConfiguration#defaultListMarkerFormat
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * @see FlowElement#listMarkerFormat
+		 * @see org.apache.flex.textLayout.formats.IListMarkerFormat IListMarkerFormat
+		 * @see LinkElement
+		 */
+		
+		public function get defaultListMarkerFormat():IListMarkerFormat
+		{ return _defaultListMarkerFormat; }
+		public function set defaultListMarkerFormat(value:IListMarkerFormat):void
+		{ _defaultListMarkerFormat = value; _immutableClone = null; }
+		
+		/** 
+		* @copy IConfiguration#defaultLinkHoverFormat  
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0
+	 	*
+		* @see  FlowElement#linkHoverFormat
+		* @see org.apache.flex.textLayout.formats.ITextLayoutFormat ITextLayoutFormat
+		* @see LinkElement
+		*/
+		
+		public function get defaultLinkHoverFormat():ITextLayoutFormat
+		{ return _defaultLinkHoverFormat; }	
+		public function set defaultLinkHoverFormat(value:ITextLayoutFormat):void
+		{ _defaultLinkHoverFormat = value; _immutableClone = null; }
+			
+		/** 
+		* @copy IConfiguration#defaultLinkActiveFormat
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0
+	 	*
+		* @see FlowElement#linkActiveFormat 
+		* @see org.apache.flex.textLayout.formats.ITextLayoutFormat ITextLayoutFormat
+		* @see LinkElement
+		*/
+		
+		public function get defaultLinkActiveFormat():ITextLayoutFormat
+		{ return _defaultLinkActiveFormat; }
+		public function set defaultLinkActiveFormat(value:ITextLayoutFormat):void
+		{ _defaultLinkActiveFormat = value; _immutableClone = null; }
+		
+		/** 
+		* @copy IConfiguration#textFlowInitialFormat
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0
+	 	*
+		* @see TextFlow
+		* @see org.apache.flex.textLayout.formats.ITextLayoutFormat ITextLayoutFormat
+		*/
+		
+		public function get textFlowInitialFormat():ITextLayoutFormat
+		{ return _textFlowInitialFormat; }
+		public function set textFlowInitialFormat(value:ITextLayoutFormat):void
+		{ _textFlowInitialFormat = value; _immutableClone = null; }
+		
+
+		
+		/** 
+		* @copy IConfiguration#focusedSelectionFormat 
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0
+	 	*
+	 	* @see org.apache.flex.textLayout.edit.SelectionFormat SelectionFormat
+		* @see org.apache.flex.textLayout.edit.SelectionManager#focusedSelectionFormat SelectionManager.focusedSelectionFormat
+		* @see TextFlow
+		*/
+		
+		public function get focusedSelectionFormat():SelectionFormat
+		{ return _focusedSelectionFormat; }
+		public function set focusedSelectionFormat(value:SelectionFormat):void
+		{	if (value != null)
+			{	
+				_focusedSelectionFormat = value; 
+				_immutableClone = null;
+			} 
+		}
+		
+		/** 
+		* @copy IConfiguration#unfocusedSelectionFormat
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0
+	 	*
+	 	* @see org.apache.flex.textLayout.edit.SelectionFormat SelectionFormat
+		* @see org.apache.flex.textLayout.edit.SelectionManager#unfocusedSelectionFormat SelectionManager.unfocusedSelectionFormat
+		* @see TextFlow
+		*/
+		
+		public function get unfocusedSelectionFormat():SelectionFormat
+		{ return _unfocusedSelectionFormat; }
+		public function set unfocusedSelectionFormat(value:SelectionFormat):void
+		{	if (value != null)
+			{	
+				_unfocusedSelectionFormat = value; 
+				_immutableClone = null;
+			} 
+		}		
+		
+		/** 
+		* @copy IConfiguration#inactiveSelectionFormat
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0
+	 	*
+	 	* @see org.apache.flex.textLayout.edit.SelectionFormat SelectionFormat
+		* @see org.apache.flex.textLayout.edit.SelectionManager#inactiveSelectionFormat SelectionManager.inactiveSelectionFormat
+		* @see TextFlow
+		*/
+		
+		public function get inactiveSelectionFormat():SelectionFormat
+		{ return _inactiveSelectionFormat; }
+		public function set inactiveSelectionFormat(value:SelectionFormat):void
+		{	
+			if (value != null)
+			{
+				_inactiveSelectionFormat = value; 
+				_immutableClone = null; 
+			}
+		}												
+		
+		/** 
+		* @copy IConfiguration#scrollDragDelay
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0
+		*/
+		
+		public function get scrollDragDelay():Number
+		{ return _scrollDragDelay; }
+		public function set scrollDragDelay(value:Number):void
+		{
+			if (value > 0) {
+				_scrollDragDelay = value;
+				_immutableClone = null;
+			}
+		}
+		
+		/** 
+		* @copy IConfiguration#scrollDragPixels
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0
+		*/
+		
+		public function get scrollDragPixels():Number
+		{ return _scrollDragPixels; }
+		public function set scrollDragPixels(value:Number):void
+		{
+			if (value > 0) {
+				_scrollDragPixels = value;
+				_immutableClone = null;
+			}
+		}
+
+		/**
+		* @copy IConfiguration#scrollPagePercentage
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0
+		*/
+		
+		public function get scrollPagePercentage(): Number
+		{ return _scrollPagePercentage; }
+		public function set scrollPagePercentage(value:Number):void
+		{
+			if (value > 0) {
+				_scrollPagePercentage = value;
+				_immutableClone = null;
+			}
+		}
+		
+		/** 
+		* @copy IConfiguration#scrollMouseWheelMultiplier
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0
+		*/
+		
+		public function get scrollMouseWheelMultiplier(): Number
+		{ return _scrollMouseWheelMultiplier; }
+		public function set scrollMouseWheelMultiplier(value:Number):void
+		{
+			if (value > 0) {
+				_scrollMouseWheelMultiplier = value;
+				_immutableClone = null;
+			}
+		}
+		
+		/** 
+		* @copy IConfiguration#flowComposerClass
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0
+	 	*
+	 	* @see org.apache.flex.textLayout.compose.StandardFlowComposer StandardFlowComposer
+		* @see org.apache.flex.textLayout.elements.TextFlow TextFlow
+		*/
+		
+		public function get flowComposerClass(): Class
+		{ return _flowComposerClass; }
+		public function set flowComposerClass(value:Class):void
+		{
+			_flowComposerClass = value;
+			_immutableClone = null;
+		}
+	
+		/** 
+		* @copy IConfiguration#enableAccessibility
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0
+	 	*
+	 	* @see TextFlow
+		*/
+		
+		public function get enableAccessibility():Boolean
+		{ return _enableAccessibility; }
+		public function set enableAccessibility(value:Boolean):void
+		{
+			_enableAccessibility = value;
+			_immutableClone = null;
+		}
+		
+		/** 
+		* @copy IConfiguration#releaseLineCreationData
+		* 
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+		* @langversion 3.0
+		*
+		* @see org.apache.flex.textLayout.compose.StandardFlowComposer StandardFlowComposer
+		* @see org.apache.flex.text.engine.TextBlock#releaseLineCreationData() TextBlock.releaseLineCreationData()
+		*/
+		
+		public function get releaseLineCreationData():Boolean
+		{ return _releaseLineCreationData; }
+		public function set releaseLineCreationData(value:Boolean):void
+		{
+			_releaseLineCreationData = value;
+			_immutableClone = null;
+		}
+
+		public static var defaultConfiguration:IConfiguration = new Configuration();		
+		
+		/** Returns true if the ActionScript text engine was built with debugging code enabled. @private */
+		static public function get debugCodeEnabled():Boolean
+		{
+			CONFIG::debug   { return true; }
+			CONFIG::release { return false; }
+		}
+		
+		/** 
+		* @copy IConfiguration#inlineGraphicResolverFunction
+		* 
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+		* @langversion 3.0
+		*
+		* @see org.apache.flex.textLayout.elements.InlineGraphicElement InlineGraphicElement
+		*/		
+		public function get inlineGraphicResolverFunction():Function
+		{ 
+			return _inlineGraphicResolverFunction; 
+		}
+		public function set inlineGraphicResolverFunction(value:Function):void
+		{
+			_inlineGraphicResolverFunction = value;
+			_immutableClone = null;
+		}
+		
+		/** 
+		 * @copy IConfiguration#cursorFunction
+		 * 
+		 * @playerversion Flash 10.2
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 */		
+		public function get cursorFunction():Function
+		{ 
+			return _cursorFunction; 
+		}
+		public function set cursorFunction(value:Function):void
+		{
+			_cursorFunction = value;
+			_immutableClone = null;
+		}
+		
+		
+		
+		/** @private */
+		static public function getCursorString(config:IConfiguration, cursorString:String):String
+		{
+			return config.cursorFunction == null ? cursorString : config.cursorFunction(cursorString);
+		}
+		
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ConfigurationHelper.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ConfigurationHelper.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ConfigurationHelper.as
new file mode 100644
index 0000000..e86e642
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ConfigurationHelper.as
@@ -0,0 +1,31 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	public class ConfigurationHelper
+	{
+		private static var _defaultConfiguration:IConfiguration;
+		public static function get defaultConfiguration():IConfiguration
+		{
+			if(!_defaultConfiguration)
+				_defaultConfiguration = new Configuration();
+			return _defaultConfiguration;
+		}
+	}
+}
\ No newline at end of file


[16/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ListElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ListElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ListElement.as
new file mode 100644
index 0000000..76acbb8
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ListElement.as
@@ -0,0 +1,645 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.events.ModelChange;
+	import org.apache.flex.textLayout.formats.BlockProgression;
+	import org.apache.flex.textLayout.formats.Direction;
+	import org.apache.flex.textLayout.formats.FormatValue;
+	import org.apache.flex.textLayout.formats.IListMarkerFormat;
+	import org.apache.flex.textLayout.formats.ListStyleType;
+	import org.apache.flex.textLayout.formats.Suffix;
+
+	
+
+	/** 
+	 * The List class is used for grouping together items into a numbered or unnumbered list. A ListElement's children may be of type ListItemElement,
+	 * ListElement, ParagraphElement, or DivElement. 
+	 * 
+	 * <p>Each ListElement creates a scope with an implicit counter 'ordered'.</p>
+	 * 
+	 * @see org.apache.flex.textLayout.formats.ITextLayoutFormat#listStyleType
+	 * @see org.apache.flex.textLayout.formats.ITextLayoutFormat#listStylePosition
+	 * @see org.apache.flex.textLayout.formats.ListMarkerFormat
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 *
+	 */
+	public class ListElement extends ContainerFormattedElement implements IListElement
+	{
+		/** 
+		 * Specifies the name of the ListMarker format
+		 * @private
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		static public const LIST_MARKER_FORMAT_NAME:String = "listMarkerFormat";
+		
+		override public function get className():String{
+			return "ListElement";
+		}
+		/** @private */
+		override protected function get abstract():Boolean
+		{ return false; }
+		
+		/** @private */
+		public override function get defaultTypeName():String
+		{ return "list"; }
+		
+		/** @private */
+		public override function canOwnFlowElement(elem:IFlowElement):Boolean
+		{
+			return !(elem is ITextFlow) && !(elem is IFlowLeafElement) && !(elem is ISubParagraphGroupElementBase);
+		}
+		
+		/** @private if its in a numbered list expand the damage to all list items - causes the numbers to be regenerated */
+		public override function modelChanged(changeType:String, elem:IFlowElement, changeStart:int, changeLen:int, needNormalize:Boolean = true, bumpGeneration:Boolean = true):void
+		{
+			// this is a bit aggressive - could damage with a new damage type (LIST_MARKER_DAMAGE) if we wanted to really optimize list item addition/removal
+			if ((changeType == ModelChange.ELEMENT_ADDED || changeType == ModelChange.ELEMENT_REMOVAL) && (elem is ListItemElement) && this.isNumberedList())
+			{
+				// for list renumbering
+				changeStart = elem.parentRelativeStart;
+				changeLen = textLength-elem.parentRelativeStart;
+			}
+			super.modelChanged(changeType,elem,changeStart,changeLen,needNormalize,bumpGeneration);
+		}
+		
+		/** @private */
+		public override function getEffectivePaddingLeft():Number
+		{ 
+			if (computedFormat.paddingLeft != FormatValue.AUTO)
+				return computedFormat.paddingLeft;
+			
+			var tf:ITextFlow = getTextFlow();
+			if (!tf || tf.computedFormat.blockProgression != BlockProgression.TB || computedFormat.direction != Direction.LTR)
+				return 0;
+			
+			return computedFormat.listAutoPadding;
+		}
+		
+		/** @private */
+		public override function getEffectivePaddingRight():Number
+		{ 
+			if (computedFormat.paddingRight != FormatValue.AUTO)
+				return computedFormat.paddingRight;
+			
+			var tf:ITextFlow = getTextFlow();
+			if (!tf || tf.computedFormat.blockProgression != BlockProgression.TB || computedFormat.direction != Direction.RTL)
+				return 0;
+			
+			return computedFormat.listAutoPadding;
+		}
+		/** @private */
+		public override function getEffectivePaddingTop():Number
+		{ 
+			if (computedFormat.paddingTop != FormatValue.AUTO)
+				return computedFormat.paddingTop;
+			
+			var tf:ITextFlow = getTextFlow();
+			if (!tf || tf.computedFormat.blockProgression != BlockProgression.RL || computedFormat.direction != Direction.LTR)
+				return 0;
+			
+			return computedFormat.listAutoPadding;
+		}
+		
+		/** @private */
+		public override function getEffectivePaddingBottom():Number
+		{ 
+			if (computedFormat.paddingBottom != FormatValue.AUTO)
+				return computedFormat.paddingBottom;
+			
+			var tf:ITextFlow = getTextFlow();
+			if (!tf || tf.computedFormat.blockProgression != BlockProgression.RL || computedFormat.direction != Direction.RTL)
+				return 0;
+			
+			return computedFormat.listAutoPadding;
+		}
+
+		/** avoid switches and if-else statements.  switches behave like if-else
+		 * http://www.w3.org/Style/CSS/Test/CSS1/current/sec563.htm
+		 * http://en.wikipedia.org/wiki/Unicode_Geometric_Shapes
+		 * @private
+		 */
+		public static const constantListStyles:Object = {
+			none:	"",
+			disc:	"\u2022",	// black bullet
+			circle:	"\u25e6",	// white bullet
+			square:	"\u25a0",	// black square
+			box:	"\u25a1",	// white square
+			check:	"\u2713",	// check mark
+			diamond:"\u25c6",	// black diamond
+			hyphen:	"\u2043"	// hyphen bullet
+		};
+
+		private static const romanDigitFunction:Vector.<Function> = Vector.<Function>([
+			function (o:String,f:String,t:String):String { return ""; },
+			function (o:String,f:String,t:String):String { return o; },
+			function (o:String,f:String,t:String):String { return o+o; },
+			function (o:String,f:String,t:String):String { return o+o+o; },
+			function (o:String,f:String,t:String):String { return o+f; },
+			function (o:String,f:String,t:String):String { return f; },
+			function (o:String,f:String,t:String):String { return f+o; },
+			function (o:String,f:String,t:String):String { return f+o+o; },
+			function (o:String,f:String,t:String):String { return f+o+o+o; },
+			function (o:String,f:String,t:String):String { return o+t; }
+		]);
+		
+		/** @private roman string support - doesn't follow the CSS spec for numbers > 4000.  The lines above aren't that interesting. In fact doesn't follow CSS spec at all. */
+		public static function createRomanString(n:int,data:Vector.<String>):String
+		{
+			var leading:String = "";
+			
+			// there are other ways to handle values > 4000 - this works
+			while (n >= 1000)
+			{
+				leading += data[6];
+				n -= 1000;
+			}
+			
+			// avoid switches and loops - add in the suffix
+			return leading + romanDigitFunction[int(n / 100)](data[4],data[5],data[6])
+			     + romanDigitFunction[int((n/10) % 10)](data[2],data[3],data[4])
+			     + romanDigitFunction[int(n % 10)](data[0],data[1],data[2]);
+		}
+		
+		private static const upperRomanData:Vector.<String> = Vector.<String>(['I', 'V', 'X', 'L', 'C', 'D', 'M']);
+		/** @private 
+		 * From http://www.w3.org/TR/css3-lists/#list-content
+		 * upper-roman
+		    Numbers are converted to roman numerals using the steps described below. The phrase "take the three least significant numbers" means divide by 1000, truncate (drop the fractional part), multiply by one thousand, and subtract this from the original number. So the three least significant figures of 1004 is 4.
+		
+		       1. If the number is in the range 0 to 1000 inclusive, use the following steps:
+		             1. If the number is 1000, add \u216f U+216F and skip to the end.
+		             2. If the number is 900 or more, add \u216d\u216f U+216D U+216F and subtract 900.
+		             3. If the number is 500 or more, add \u216e U+216E and subtract 500.
+		             4. If the number is 400 or more, add \u216d\u216e U+216D U+216E and subtract 400.
+		             5. While the number is greater than or equal to 100, add \u216d U+216D and subtract 100.
+		             6. If the number is 90 or more, add \u2169\u216d U+2169 U+216D and subtract 90.
+		             7. If the number is 50 or more, add \u216c U+216C and subtract 50.
+		             8. If the number is 40 or more, add \u2169\u216c U+2169 U+216C and subtract 40.
+		             9. While the number is greater than 12, add \u2169 U+2169 and subtract 10.
+		            10. If the number is greater than 0, then add the appropriate roman numeral from \u2160 U+2160 (1) to \u216b U+216B (12). For example, if the number is 8, add \u2167 U+2167. 
+		       2. If the number is in the range 1000 to 40000 exclusive, then take the three least significant numbers and convert them using step 1. Then convert the remainder using the following steps and prepend it to the result.
+		             1. While the number is greater than or equal to 10000, add \u2182 U+2182 and subtract 10000.
+		             2. If the number is 9000, add \u216f\u2182 U+216F U+2182 and skip to the end.
+		             3. If the number is 4000, add \u216f\u2181 U+216F U+2181 and skip to the end.
+		             4. If the number is 5000 or more, add \u2181 U+2181 and subtract 5000.
+		             5. While the number is greater than 0, add \u216f U+216F and subtract 1000. 
+		       3. If the number is greater than 40000, then take the three least significant figures and convert them using step 1, calling that the result. Then convert the remainder by dividing it by 1000, passing it through the entire algorithm starting at the top, adding an overbar to it, and prepending it to the current result. For very large numbers, this step may be entered several times, resulting in the first few characters of the result having multiple overbars. 
+		
+		    The suffix for roman numerals is a dot . U+002E.
+		
+		    Zero and negative numbers are rendered using the decimal numbering style. 
+			 
+			Modified as follows:
+			 * The letterspacing behavior of <U+2169 \u2169 ROMAN NUMERAL TEN, U+2161 \u2161 ROMAN NUMERAL TWO> is probably not what we want
+			 * while that of <X, I, I> is the one you want.
+				(Of course, keep using U+2180 \u2180 ROMAN NUMERAL ONE THOUSAND C D and similar.)
+	 	*/
+		public static function upperRomanString(n:int):String
+		{ 
+			if (n <= 0)
+				return decimalString(n);
+			
+			// normal case - just do it and be done
+			if (n <= 1000)
+				return createRomanString(n,upperRomanData);
+				
+			// not to spec but overbars are too complicated for a non-intersting case with TLF 2.0 numbering
+			if (n >= 40000)
+				return decimalString(n);
+			
+			// the more complex case defined as bove
+			var lowerString:String = createRomanString(n%1000,upperRomanData);
+			var highString:String = "";
+			
+			n -= n%1000;
+			
+			while (n >= 10000)
+			{
+				highString += String.fromCharCode(0x2182);
+				n -= 10000;
+			}
+			if (n == 9000)
+				highString += "M" + String.fromCharCode(0x2182);
+			else if (n == 4000)
+				highString += "M" + String.fromCharCode(0x2181);
+			else
+			{
+				if (n >= 5000)
+				{
+					highString += String.fromCharCode(0x2181);
+					n -= 5000;
+				}
+				while (n > 0)
+				{
+					highString += "M";
+					n -= 1000;
+				}
+			}
+
+			return highString+lowerString; 
+		}	// INCORRECT
+		
+		private static const lowerRomanData:Vector.<String> = Vector.<String>(['i', 'v', 'x', 'l', 'c', 'd', 'm']);
+		/** @private 
+		 * The algorithm for this numbering style is identical to the upper-roman  style but using \u2170-\u217f U+2170-U+217F instead of \u2160-\u216f U+2160-U+216F, 
+		 * and ignoring step 2 (i.e. not treating numbers 1000-40000 in a special way, since there are no lowercase equivalents to \u2181 U+2181 and \u2182 U+2182). 
+		 * Numbers up to 3999 convert and over 4000 are going to go to decimal.
+		 */
+		public static function lowerRomanString(n:int):String
+		{ return n> 0 && n < 4000 ? createRomanString(n,lowerRomanData) : decimalString(n); }
+		
+		/** @private */
+		public static function decimalString(n:int):String
+		{ return n.toString(); }
+		/** @private */
+		public static function decimalLeadingZeroString(n:int):String
+		{ return n <= 9 && n >= -9 ? "0"+n.toString() : n.toString(); }
+		
+		
+		// Supports "Numeric" style base 10 lists 
+		// http://www.w3.org/TR/css3-lists/#numeric
+		// NOTE: easy to pass in a base if other than base 10 is needed
+		// NOTE: easy to add non-positive number support 
+		// (from above link: "For all these systems, negative numbers are first converted as if they were positive numbers, then have - U+002D prefixed.")
+		// n is the number.  zero is the charChode of zero and is used as an offset
+		// see http://www.w3.org/TR/css3-lists/#list-content
+		/** @private */
+		public static function createNumericBaseTenString(n:int,zero:int):String
+		{
+			CONFIG::debug { assert(n >= 0,"Bad number passed to createBaseTenString"); }
+			
+			if (n == 0)
+				return String.fromCharCode(zero);
+			
+			var rslt:String = "";
+			while (n > 0)
+			{
+				rslt = String.fromCharCode((n%10)+zero) + rslt;
+				n = n / 10;
+			}
+			return rslt;
+		}
+		
+		/** @private */
+		public static function arabicIndicString(n:int):String
+		{ return createNumericBaseTenString(n,0x660); }
+		/** @private */
+		public static function bengaliString(n:int):String
+		{ return createNumericBaseTenString(n,0x9E6); }
+		/** @private */
+		public static function devanagariString(n:int):String
+		{ return createNumericBaseTenString(n,0x0966); }
+		/** @private */
+		public static function gujaratiString(n:int):String
+		{ return createNumericBaseTenString(n,0xAE6); }
+		/** @private */
+		public static function gurmukhiString(n:int):String
+		{ return createNumericBaseTenString(n,0xA66); }
+		/** @private */
+		public static function kannadaString(n:int):String
+		{ return createNumericBaseTenString(n,0xCE6); }
+		/** @private */
+		public static function persianString(n:int):String
+		{ return createNumericBaseTenString(n,0x6F0); }	// same as urdu
+		/** @private */
+		public static function thaiString(n:int):String
+		{ return createNumericBaseTenString(n,0xE50); }
+		/** @private */
+		public static function urduString(n:int):String
+		{ return createNumericBaseTenString(n,0x6F0); }	// same as persian
+		
+		/** @private */
+		public static function createContinuousAlphaString(n:int,first:int,base:int):String
+		{
+			CONFIG::debug { assert(n > 0,"Bad number passed to createContinuousAlphaString"); }
+			var rslt:String = "";
+			
+			while (n > 0)
+			{
+				rslt = String.fromCharCode(((n-1)%base)+first) + rslt;
+				n = (n-1) / base;
+			}
+			return rslt;
+		}
+	
+		// continuous alphabetic
+		/** @private */
+		public static function lowerAlphaString(n:int):String 
+		{ return createContinuousAlphaString(n,0x61,26); }
+		/** @private */
+		public static function upperAlphaString(n:int):String 
+		{ return createContinuousAlphaString(n,0x41,26); }
+		/** @private */
+		public static function lowerLatinString(n:int):String
+		{ return createContinuousAlphaString(n,0x61,26); }		// same as alpha
+		/** @private */
+		public static function upperLatinString(n:int):String
+		{ return createContinuousAlphaString(n,0x41,26); }		// same as alpha
+		
+		// see http://www.w3.org/TR/css3-lists/#alphabetic for the table definitions
+		/** @private */
+		public static function createTableAlphaString(n:int,table:Vector.<int>):String
+		{
+			CONFIG::debug { assert(n > 0,"Bad number passed to createTableAlphaString"); }
+			var rslt:String = "";
+			var base:int = table.length;
+			
+			while (n > 0)
+			{
+				rslt = String.fromCharCode(table[(n-1)%base]) + rslt;
+				n = (n-1) / base;
+			}
+			return rslt;
+		}
+		
+		// table alphabetic
+		
+		/** @private */
+		public static const cjkEarthlyBranchData:Vector.<int> = Vector.<int>([
+			0x5B50, 0x4E11, 0x5BC5, 0x536F, 0x8FB0, 0x5DF3, 0x5348, 0x672A, 
+			0x7533, 0x9149, 0x620C, 0x4EA5]);
+		/** @private */
+		public static function cjkEarthlyBranchString(n:int):String
+		{ return createTableAlphaString(n,cjkEarthlyBranchData); }
+		
+		/** @private */
+		public static const cjkHeavenlyStemData:Vector.<int> = Vector.<int>([
+			0x7532, 0x4E59, 0x4E19, 0x4E01, 0x620A, 0x5DF1, 0x5E9A, 0x8F9B, 
+			0x58EC, 0x7678 ]);
+		/** @private */
+		public static function cjkHeavenlyStemString(n:int):String
+		{ return createTableAlphaString(n,cjkHeavenlyStemData); }
+
+		/** @private */
+		public static const hangulData:Vector.<int> = Vector.<int>([
+			0xAC00, 0xB098, 0xB2E4, 0xB77C, 0xB9C8, 0xBC14, 0xC0AC, 0xC544, 
+			0xC790, 0xCC28, 0xCE74, 0xD0C0, 0xD30C, 0xD558]);
+		/** @private */
+		public static function hangulString(n:int):String
+		{ return createTableAlphaString(n,hangulData); }
+		
+		/** @private */
+		public static const hangulConstantData:Vector.<int> = Vector.<int>([
+			0x3131, 0x3134, 0x3137, 0x3139, 0x3141, 0x3142, 0x3145, 0x3147, 
+			0x3148, 0x314A, 0x314B, 0x314C, 0x314D, 0x314E]);
+		/** @private */
+		public static function hangulConstantString(n:int):String
+		{ return createTableAlphaString(n,hangulConstantData); }
+		
+		/** @private */
+		public static const hiraganaData:Vector.<int> = Vector.<int>([
+			0x3042, 0x3044, 0x3046, 0x3048, 0x304A, 0x304B, 0x304D, 0x304F, 
+			0x3051, 0x3053, 0x3055, 0x3057, 0x3059, 0x305B, 0x305D, 0x305F, 
+			0x3061, 0x3064, 0x3066, 0x3068, 0x306A, 0x306B, 0x306C, 0x306D, 
+			0x306E, 0x306F, 0x3072, 0x3075, 0x3078, 0x307B, 0x307E, 0x307F, 
+			0x3080, 0x3081, 0x3082, 0x3084, 0x3086, 0x3088, 0x3089, 0x308A, 
+			0x308B, 0x308C, 0x308D, 0x308F, 0x3090, 0x3091, 0x3092, 0x3093]);
+		/** @private */
+		public static function hiraganaString(n:int):String
+		{ return createTableAlphaString(n,hiraganaData); }
+		
+		/** @private */
+		public static const hiraganaIrohaData:Vector.<int> = Vector.<int>([
+			0x3044, 0x308D, 0x306F, 0x306B, 0x307B, 0x3078, 0x3068, 0x3061, 
+			0x308A, 0x306C, 0x308B, 0x3092, 0x308F, 0x304B, 0x3088, 0x305F, 
+			0x308C, 0x305D, 0x3064, 0x306D, 0x306A, 0x3089, 0x3080, 0x3046, 
+			0x3090, 0x306E, 0x304A, 0x304F, 0x3084, 0x307E, 0x3051, 0x3075, 
+			0x3053, 0x3048, 0x3066, 0x3042, 0x3055, 0x304D, 0x3086, 0x3081, 
+			0x307F, 0x3057, 0x3091, 0x3072, 0x3082, 0x305B, 0x3059 ]);
+		/** @private */
+		public static function hiraganaIrohaString(n:int):String
+		{ return createTableAlphaString(n,hiraganaIrohaData); }
+		
+		/** @private */
+		public static const katakanaData:Vector.<int> = Vector.<int>([
+			0x30A2, 0x30A4, 0x30A6, 0x30A8, 0x30AA, 0x30AB, 0x30AD, 0x30AF, 
+			0x30B1, 0x30B3, 0x30B5, 0x30B7, 0x30B9, 0x30BB, 0x30BD, 0x30BF, 
+			0x30C1, 0x30C4, 0x30C6, 0x30C8, 0x30CA, 0x30CB, 0x30CC, 0x30CD, 
+			0x30CE, 0x30CF, 0x30D2, 0x30D5, 0x30D8, 0x30DB, 0x30DE, 0x30DF, 
+			0x30E0, 0x30E1, 0x30E2, 0x30E4, 0x30E6, 0x30E8, 0x30E9, 0x30EA, 
+			0x30EB, 0x30EC, 0x30ED, 0x30EF, 0x30F0, 0x30F1, 0x30F2, 0x30F3]);
+		/** @private */
+		public static function katakanaString(n:int):String
+		{ return createTableAlphaString(n,katakanaData); }
+		
+		/** @private */
+		public static const katakanaIrohaData:Vector.<int> = Vector.<int>([
+			0x30A4, 0x30ED, 0x30CF, 0x30CB, 0x30DB, 0x30D8, 0x30C8, 0x30C1, 
+			0x30EA, 0x30CC, 0x30EB, 0x30F2, 0x30EF, 0x30AB, 0x30E8, 0x30BF, 
+			0x30EC, 0x30BD, 0x30C4, 0x30CD, 0x30CA, 0x30E9, 0x30E0, 0x30A6, 
+			0x30F0, 0x30CE, 0x30AA, 0x30AF, 0x30E4, 0x30DE, 0x30B1, 0x30D5, 
+			0x30B3, 0x30A8, 0x30C6, 0x30A2, 0x30B5, 0x30AD, 0x30E6, 0x30E1, 
+			0x30DF, 0x30B7, 0x30F1, 0x30D2, 0x30E2, 0x30BB, 0x30B9 ]);
+		/** @private */
+		public static function katakanaIrohaString(n:int):String
+		{ return createTableAlphaString(n,katakanaIrohaData); }
+		
+		/** @private */
+		public static const lowerGreekData:Vector.<int> = Vector.<int>([
+			0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, 0x03B8, 
+			0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 
+			0x03C1, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8, 0x03C9  ]);
+		/** @private */
+		public static function lowerGreekString(n:int):String
+		{ return createTableAlphaString(n,lowerGreekData); }
+		
+		/** @private */
+		public static const upperGreekData:Vector.<int> = Vector.<int>([
+			0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398,
+			0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, 0x03A0,
+			0x03A1, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9 ]);
+		/** @private */
+		public static function upperGreekString(n:int):String
+		{ return createTableAlphaString(n,upperGreekData); }
+		
+		/** @private */
+		public static const algorithmicListStyles:Object = {
+			upperRoman:upperRomanString,
+			lowerRoman:lowerRomanString
+		};
+		
+		/** @private */
+		public static const numericListStyles:Object = {
+			arabicIndic:arabicIndicString,
+			bengali:bengaliString,				
+			decimal:decimalString,
+			decimalLeadingZero:decimalLeadingZeroString,
+			devanagari:devanagariString,
+			gujarati:gujaratiString,
+			gurmukhi:gurmukhiString,
+			kannada:kannadaString,
+			persian:persianString,
+			thai:thaiString,
+			urdu:urduString
+		};
+		
+		/** @private */
+		public static const alphabeticListStyles:Object = {
+			upperAlpha:upperAlphaString,
+			lowerAlpha:lowerAlphaString,
+			cjkEarthlyBranch:cjkEarthlyBranchString,
+			cjkHeavenlyStem:cjkHeavenlyStemString,
+			hangul:hangulString,
+			hangulConstant:hangulConstantString,
+			hiragana:hiraganaString,
+			hiraganaIroha:hiraganaIrohaString,
+			katakana:katakanaString,
+			katakanaIroha:katakanaIrohaString,
+			lowerGreek:lowerGreekString,
+			lowerLatin:lowerLatinString,
+			upperGreek:upperGreekString,
+			upperLatin:upperLatinString			
+		};
+
+		// they're all "." right now.  could remove this till its needed
+		/** @private */
+		public static const listSuffixes:Object = {
+			upperAlpha:"\u002E",
+			lowerAlpha:"\u002E",
+			upperRoman:"\u002E",
+			lowerRoman:"\u002E",
+			arabicIndic:"\u002E",
+			bengali:"\u002E",
+			decimal:"\u002E",
+			decimalLeadingZero:"\u002E",
+			devanagari:"\u002E",
+			gujarati:"\u002E",
+			gurmukhi:"\u002E",
+			kannada:"\u002E",
+			persian:"\u002E",
+			thai:"\u002E",
+			urdu:"\u002E",
+			cjkEarthlyBranch:"\u002E",
+			cjkHeavenlyStem:"\u002E",
+			hangul:"\u002E",
+			hangulConstant:"\u002E",
+			hiragana:"\u002E",
+			hiraganaIroha:"\u002E",
+			katakana:"\u002E",
+			katakanaIroha:"\u002E",
+			lowerGreek:"\u002E",
+			lowerLatin:"\u002E",
+			upperGreek:"\u002E",
+			upperLatin:"\u002E"
+		};
+
+		/** @private This function returns the string representing the list item's marker text */
+		public function computeListItemText(child:IListItemElement,listMarkerFormat:IListMarkerFormat):String
+		{
+			CONFIG::debug { assert(child.parent == this,"computeListItemText: bad child"); }
+
+			var listStyleType:String;
+			var rslt:String;
+			
+			if (listMarkerFormat.content && listMarkerFormat.content.hasOwnProperty("counters"))
+			{
+				// chapter style numbering
+				rslt = "";
+				listStyleType = listMarkerFormat.content.ordered;				// may be null
+				var suffixOverride:String = listMarkerFormat.content.suffix;	// may be null
+				
+				var list:ListElement = this;
+				var childListMarkerFormat:IListMarkerFormat = listMarkerFormat;
+				for (;;)
+				{
+					rslt = list.computeListItemTextSpecified(child,childListMarkerFormat,listStyleType == null ? list.computedFormat.listStyleType : listStyleType,suffixOverride) + rslt;
+					// now look up
+					child = list.getParentByType("ListItemElement") as IListItemElement;
+					if (!child)
+						break;
+					list = child.parent as ListElement;
+					childListMarkerFormat = child.computedListMarkerFormat();
+				}
+			}
+			else
+			{
+				if (listMarkerFormat.content !== undefined)
+				{
+					if (listMarkerFormat.content == FormatValue.NONE)
+						listStyleType = ListStyleType.NONE;
+					else 
+					{
+						CONFIG::debug { assert(listMarkerFormat.content.hasOwnProperty("counter"),"Bad ListMarkerFormat.content property"); };
+						listStyleType = listMarkerFormat.content.ordered;
+					}
+				}
+
+				if (listStyleType == null)
+					listStyleType = computedFormat.listStyleType;
+				
+				rslt = computeListItemTextSpecified(child,listMarkerFormat,listStyleType,null);
+			}			
+			var beforeContent:String = listMarkerFormat.beforeContent ? listMarkerFormat.beforeContent : "";
+			var afterContent:String = listMarkerFormat.afterContent ? listMarkerFormat.afterContent : "";
+			return beforeContent + rslt + afterContent;
+		}
+		
+		/** @private - does the work with a known listStyleType and optional suffixOverride. */
+		public function computeListItemTextSpecified(child:IListItemElement,listMarkerFormat:IListMarkerFormat,listStyleType:String,suffixOverride:String):String
+		{
+			var rslt:String;
+			var val:* = constantListStyles[listStyleType];
+			if (val !== undefined)
+				rslt = val as String;
+			else
+			{
+				CONFIG::debug { assert(listSuffixes[listStyleType] !== undefined,"missing suffix"); }
+				
+				var n:int = child.getListItemNumber(listMarkerFormat);
+				var f:Function;
+				
+				// look in the the styles objects
+				f = numericListStyles[listStyleType];
+				if (f != null)
+				{
+					rslt = n < 0 ? "\u002d" + f(-n) : f(n);
+				}
+				else if (n <= 0)
+				{
+					rslt = n == 0 ? "0" : "\u002d" + decimalString(-n);
+				}
+				else
+				{
+					f = alphabeticListStyles[listStyleType];
+					if (f != null)
+						rslt = f(n);
+					else
+						rslt = algorithmicListStyles[listStyleType](n);
+				}
+				if (suffixOverride != null)
+					rslt += suffixOverride;
+				else if (listMarkerFormat.suffix != Suffix.NONE)
+					rslt += listSuffixes[listStyleType];
+			}
+			
+			return rslt;
+		}
+		
+		/** @private */
+		public function isNumberedList():Boolean
+		{ return constantListStyles[computedFormat.listStyleType] === undefined; }
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ListItemElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ListItemElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ListItemElement.as
new file mode 100644
index 0000000..666ac11
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ListItemElement.as
@@ -0,0 +1,275 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements {
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.formats.BlockProgression;
+	import org.apache.flex.textLayout.formats.FormatValue;
+	import org.apache.flex.textLayout.formats.IListMarkerFormat;
+
+	
+
+	
+	/** 
+	 * <p> ListItemElement is an item in a list. It most commonly contains one or more ParagraphElement objects, but could
+	 * also have children of type DivElement or ListElement. A ListItemElement always appears within a ListElement.</p>
+	 *
+	 * <p>A ListItemElement has automatically generated content that appears before the regular content of the list. This is called
+	 * the <i>marker</i>, and it is what visually distinguishes the list item. The listStyleType property governs how the marker
+	 * is generated and allows the user to control whether the list item is marked with a bullet, a number, or alphabetically.
+	 * The listStylePosition governs where the marker appears relative to the list item; specifically it may appear outside, in the 
+	 * margin of the list, or inside, beside the list item itself. The ListMarkerFormat defines the TextLayoutFormat of the marker
+	 * (by default this will be the same as the list item), as well as an optional suffix that goes at the end of the marker. For 
+	 * instance, for a numbered list, it is common to have a "." as a suffix that appears after the number. The ListMarkerFormat also
+	 * allows specification of text that goes at the start of the marker, and for numbered lists allows control over the numbering.</p>
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 *
+	 * @see ParagraphElement
+	 * @see org.apache.flex.textLayout.formats.ITextLayoutFormat#listStyleType
+	 * @see org.apache.flex.textLayout.formats.ITextLayoutFormat#listStylePosition
+	 * @see org.apache.flex.textLayout.formats.ListMarkerFormat
+	 */
+	public final class ListItemElement extends ContainerFormattedElement implements IListItemElement
+	{	
+		private const MAX_VALUE:int = 2147483647;
+		/** @private Helps figure out the list number.  Use MAX_VALUE when not set */
+		public var _listNumberHint:int = MAX_VALUE;
+		
+		/** @private */
+		override protected function get abstract():Boolean
+		{ return false; }
+		
+		/** @private */
+		public override function get defaultTypeName():String
+		{ return "li"; }
+		
+		override public function get className():String{
+			return "ListItemElement";
+		}
+
+		/** @private - make more efficient? save and damage results as need be */
+		public function computedListMarkerFormat():IListMarkerFormat
+		{
+			var format:IListMarkerFormat = this.getUserStyleWorker("ListMarkerFormat") as IListMarkerFormat;
+			if (format == null)
+			{
+				var tf:ITextFlow = this.getTextFlow();
+				if (tf)
+					format = tf.configuration.defaultListMarkerFormat;
+			}
+
+			return format;
+		}
+		
+		/**
+		 *  @private ListItems must begin with zero or more divs with a paragraph
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.IFlowGroupElement
+		 */
+		public function normalizeNeedsInitialParagraph():Boolean
+		{
+			var p:IFlowGroupElement = this;
+			while (p)
+			{
+				p = p.getChildAt(0) as IFlowGroupElement;
+				if (p is IParagraphElement)
+					return false;
+				if (!(p is IDivElement))
+					return true;
+			}
+			return true;
+		}
+		
+		/** @private */
+		public override function normalizeRange(normalizeStart:uint,normalizeEnd:uint):void
+		{
+			super.normalizeRange(normalizeStart,normalizeEnd);
+			
+			_listNumberHint = MAX_VALUE;
+			
+			// A listItem must have a Paragraph at the start. 
+			// note not all browsers behave this way.
+			if (normalizeNeedsInitialParagraph())
+			{
+				var p:IParagraphElement = ElementHelper.getParagraph();
+				replaceChildren(0,0,p);	
+				p.normalizeRange(0,p.textLength);	
+			}
+		}
+		
+		/** @private */
+		public function getListItemNumber(listMarkerFormat:IListMarkerFormat = null):int
+		{
+			CONFIG::debug { assert(parent != null,"invalid call to ListItemElement.getListItemNumber"); }
+			
+			if (_listNumberHint == MAX_VALUE)
+			{
+				if (listMarkerFormat == null)
+					listMarkerFormat = 	computedListMarkerFormat();
+				
+				var counterReset:Object = listMarkerFormat.counterReset;
+					
+				if (counterReset && counterReset.hasOwnProperty("ordered"))
+					_listNumberHint = counterReset.ordered;
+				else
+				{
+					// search backwards for a ListItemElement and call getListItemNumber on it
+					var idx:int = parent.getChildIndex(this);
+					
+					_listNumberHint = 0;	// if none is found this is zero
+								
+					while (idx > 0)
+					{
+						idx--;
+						var sibling:ListItemElement = parent.getChildAt(idx) as ListItemElement;
+						if (sibling)
+						{
+							_listNumberHint = sibling.getListItemNumber();
+							break;
+						}
+					}
+				}
+				
+				// increment the counter
+				var counterIncrement:Object = listMarkerFormat.counterIncrement;
+				_listNumberHint += (counterIncrement && counterIncrement.hasOwnProperty("ordered")) ? counterIncrement.ordered : 1;
+			}
+
+			return _listNumberHint;
+		}
+		
+		// Fix bug 2800975 ListMarkerFormat.paragraphStartIndent not applied properly in Inside lists.
+		/** @private */
+		public override function getEffectivePaddingLeft():Number
+		{
+			if(getTextFlow().computedFormat.blockProgression == BlockProgression.TB)
+			{
+				if(computedFormat.paddingLeft == FormatValue.AUTO)
+				{
+						if (computedFormat.listMarkerFormat !==undefined && computedFormat.listMarkerFormat.paragraphStartIndent !== undefined)
+						{
+							return  computedFormat.listMarkerFormat.paragraphStartIndent;
+						}
+					return 0;
+						
+				}
+				else
+				{
+					if (computedFormat.listMarkerFormat !==undefined && computedFormat.listMarkerFormat.paragraphStartIndent !== undefined)
+					{
+						return computedFormat.paddingLeft+computedFormat.listMarkerFormat.paragraphStartIndent;
+					}
+					return computedFormat.paddingLeft;
+				}
+			}
+			else
+			{
+				return 0;
+			}
+		}
+		/** @private */
+		public override function getEffectivePaddingTop():Number
+		{
+			if(getTextFlow().computedFormat.blockProgression == BlockProgression.RL)
+			{
+				if(computedFormat.paddingTop == FormatValue.AUTO)
+				{
+					if (computedFormat.listMarkerFormat !==undefined && computedFormat.listMarkerFormat.paragraphStartIndent !== undefined)
+					{
+						return  computedFormat.listMarkerFormat.paragraphStartIndent;
+					}
+					return 0;
+					
+				}
+				else
+				{
+					if (computedFormat.listMarkerFormat !==undefined && computedFormat.listMarkerFormat.paragraphStartIndent !== undefined)
+					{
+						return computedFormat.paddingTop+computedFormat.listMarkerFormat.paragraphStartIndent;
+					}
+					return computedFormat.paddingTop;
+				}
+			}
+			else
+			{
+				return 0;
+			}
+		}
+		/** @private */
+		public override function getEffectivePaddingRight():Number
+		{
+			if(getTextFlow().computedFormat.blockProgression == BlockProgression.TB)
+			{
+				if(computedFormat.paddingRight == FormatValue.AUTO)
+				{
+					if (computedFormat.listMarkerFormat !==undefined && computedFormat.listMarkerFormat.paragraphStartIndent !== undefined)
+					{
+						return  computedFormat.listMarkerFormat.paragraphStartIndent;
+					}
+					return 0;
+					
+				}
+				else
+				{
+					if (computedFormat.listMarkerFormat !==undefined && computedFormat.listMarkerFormat.paragraphStartIndent !== undefined)
+					{
+						return computedFormat.paddingRight+computedFormat.listMarkerFormat.paragraphStartIndent;
+					}
+					return computedFormat.paddingRight;
+				}
+			}
+			else
+			{
+				return 0;
+			}
+		}
+		
+		/** @private */
+		public override function getEffectivePaddingBottom():Number
+		{
+			if(getTextFlow().computedFormat.blockProgression == BlockProgression.RL)
+			{
+				if(computedFormat.paddingBottom == FormatValue.AUTO)
+				{
+					if (computedFormat.listMarkerFormat !==undefined && computedFormat.listMarkerFormat.paragraphStartIndent !== undefined)
+					{
+						return  computedFormat.listMarkerFormat.paragraphStartIndent;
+					}
+					return 0;
+					
+				}
+				else
+				{
+					if (computedFormat.listMarkerFormat !==undefined && computedFormat.listMarkerFormat.paragraphStartIndent !== undefined)
+					{
+						return computedFormat.paddingBottom+computedFormat.listMarkerFormat.paragraphStartIndent;
+					}
+					return computedFormat.paddingBottom;
+				}
+			}
+			else
+			{
+				return 0;
+			}
+		}
+		
+		
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/OverflowPolicy.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/OverflowPolicy.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/OverflowPolicy.as
new file mode 100644
index 0000000..50a3f3c
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/OverflowPolicy.as
@@ -0,0 +1,63 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	/**
+	 *  The OverflowPolicy class defines a set of constants for the <code>overflowPolicy</code> property
+	 *  of the IConfiguration class. This defines how the composer will treat lines at the end of the composition area.
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	 
+ 	public final class OverflowPolicy {
+ 	
+	/** 
+	 * Fit the line in the composition area if any part of the line fits.
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	 
+     public static const FIT_ANY:String = "fitAny";
+    
+	/*
+	 * Fit the line in the composition area if the area from the top to the baseline fits.
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	 
+ //    public static const FIT_BASELINE:String = "fitAny";
+    
+	/** 
+	 * Fit the line in the composition area if the area from the top to the baseline fits.
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	 
+     public static const FIT_DESCENDERS:String = "fitDescenders";
+    
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ParagraphElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ParagraphElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ParagraphElement.as
new file mode 100644
index 0000000..d72d869
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ParagraphElement.as
@@ -0,0 +1,1358 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements 
+{
+	import org.apache.flex.reflection.getQualifiedClassName;
+	import org.apache.flex.text.engine.ContentElement;
+	import org.apache.flex.text.engine.EastAsianJustifier;
+	import org.apache.flex.text.engine.GroupElement;
+	import org.apache.flex.text.engine.ITextBlock;
+	import org.apache.flex.text.engine.ITextLine;
+	import org.apache.flex.text.engine.LineJustification;
+	import org.apache.flex.text.engine.SpaceJustifier;
+	import org.apache.flex.text.engine.TabAlignment;
+	import org.apache.flex.text.engine.TabStop;
+	import org.apache.flex.text.engine.TextRotation;
+	import org.apache.flex.textLayout.compose.ITextFlowLine;
+	import org.apache.flex.textLayout.debug.Debugging;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.formats.BlockProgression;
+	import org.apache.flex.textLayout.formats.Direction;
+	import org.apache.flex.textLayout.formats.FormatValue;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.formats.JustificationRule;
+	import org.apache.flex.textLayout.formats.LeadingModel;
+	import org.apache.flex.textLayout.formats.LineBreak;
+	import org.apache.flex.textLayout.formats.TabStopFormat;
+	import org.apache.flex.textLayout.formats.TextAlign;
+	import org.apache.flex.textLayout.formats.TextJustify;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+	import org.apache.flex.textLayout.property.PropertyUtil;
+	import org.apache.flex.textLayout.utils.CharacterUtil;
+	import org.apache.flex.textLayout.utils.LocaleUtil;
+	
+
+
+	/** 
+	 * The ParagraphElement class represents a paragraph in the text flow hierarchy. Its parent
+	 * is a ParagraphFormattedElement, and its children can include spans (SpanElement), images 
+	 * (inLineGraphicElement), links (LinkElement) and TCY (Tatechuuyoko - ta-tae-chu-yo-ko) elements (TCYElement). The 
+	 * paragraph text is stored in one or more SpanElement objects, which define ranges of text that share the same attributes. 
+	 * A TCYElement object defines a small run of Japanese text that runs perpendicular to the line, as in a horizontal run of text in a 
+	 * vertical line. A TCYElement can also contain multiple spans.
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 * 
+	 * @see InlineGraphicElement
+	 * @see LinkElement
+	 * @see SpanElement
+	 * @see TCYElement
+	 * @see ITextFlow
+	 */
+	 
+	public final class ParagraphElement extends ParagraphFormattedElement implements IParagraphElement	{
+		//private var _textBlock:ITextBlock;
+		private var _terminatorSpan:ISpanElement;
+		
+		private var _interactiveChildrenCount:int;
+		/** Constructor - represents a paragraph in a text flow. 
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0
+	 	*/
+	 	
+		public function ParagraphElement()
+		{
+			super();
+			_terminatorSpan = null;
+			_interactiveChildrenCount = 0 ;
+		}
+		override public function get className():String
+		{
+			return "ParagraphElement";
+		}
+		public function get interactiveChildrenCount():int
+		{
+			return _interactiveChildrenCount;
+		}
+		
+		/** @private */
+		public function createTextBlock():void
+		{
+//			CONFIG::debug { assert(_textBlock == null,"createTextBlock called when there is already a textblock"); }
+			calculateComputedFormat();	// recreate the format BEFORE the _textBlock is created
+			var tbs:Vector.<ITextBlock> = getTextBlocks();
+			//tbs.length = 0;
+			var tableCount:int = 0;
+			if(tbs.length == 0 && !(getChildAt(0) is ITableElement) )
+				tbs.push(getTextFlow().tlfFactory.textFactory.getTextBlock());
+			//getTextBlocks()[0] = new ITextBlock();
+//			CONFIG::debug { Debugging.traceFTECall(_textBlock,null,"new ITextBlock()"); }
+			for (var i:int = 0; i < numChildren; i++)
+			{
+				var child:IFlowElement = getChildAt(i);
+				if(child is ITableElement)
+					tableCount++;
+//					tbs.push(new ITextBlock());
+				else
+				{
+					//child.releaseContentElement();
+					//child.createContentElement();
+				}
+			}
+			while(tableCount >= tbs.length)
+				tbs.push(getTextFlow().tlfFactory.textFactory.getTextBlock());
+			
+			for (i = 0; i < numChildren; i++)
+			{
+				child = getChildAt(i);
+				child.createContentElement();
+			}
+			tbs.length = tableCount + 1;
+			var tb:ITextBlock;
+			for each(tb in tbs){
+				updateTextBlock(tb);
+			}
+		}
+		private function updateTextBlockRefs():void
+		{
+			var tbs:Vector.<ITextBlock> = getTextBlocks();
+			if(tbs.length == 0)
+				return;//nothing to do
+			var tbIdx:int = 0;
+			var tb:ITextBlock = tbs[tbIdx];
+			var items:Array = [];
+			var child:IFlowElement;
+			for (var i:int = 0; i < numChildren; i++)
+			{
+				child = getChildAt(i);
+				if(child is ITableElement)
+				{
+					tb.userData = items;
+					if(++tbIdx == tbs.length)
+						return;
+					tb = tbs[tbIdx];
+					tb.userData = null;
+
+					//Advance to the next one.
+					if(++tbIdx == tbs.length)
+						return;
+					tb = tbs[tbIdx];
+					items = [];
+					continue;
+				}
+				items.push(child);
+			}
+			tb.userData = items;
+		}
+		private function removeTextBlock(tb:ITextBlock):void
+		{
+			var tbs:Vector.<ITextBlock> = getTextBlocks();
+			if(tbs)
+			{
+				var idx:int = getTextBlocks().indexOf(tb);
+				if(idx > -1)
+				{
+					tbs.splice(idx,1);
+				}
+			}
+		}
+		
+		/**
+		 * @flexjsignorecoercion org.apache.flex.textLayout.compose.ITextFlowLine
+		 */
+		private function releaseTextBlockInternal(tb:ITextBlock):void
+		{
+			if (!tb)
+				return;
+			
+			if (tb.firstLine)	// A ITextBlock may have no firstLine if it has previously been released.
+			{
+				for (var textLineTest:ITextLine = tb.firstLine; textLineTest != null; textLineTest = textLineTest.nextLine)
+				{	
+					if(textLineTest.numElements != 0)
+					{	
+						//if the number of adornments added does not match the number of children on the textLine
+						//then a third party has added adornments.  Don't recycle the line or the adornment will be
+						//lost.
+						var tfl:ITextFlowLine = textLineTest.userData as ITextFlowLine;
+						if(tfl.adornCount != textLineTest.numElements)
+							return;
+					}
+				}
+				
+				CONFIG::debug { Debugging.traceFTECall(null,tb,"releaseLines",tb.firstLine, tb.lastLine); }				
+				tb.releaseLines(tb.firstLine, tb.lastLine);	
+			}	
+			var items:Array = tb.userData;
+			if(items)
+			{
+				var len:int = items.length;
+				for (var i:int = 0; i < len; i++)
+				{
+					var child:FlowElement = items[i];
+					child.releaseContentElement();
+				}
+				items.length = 0;
+			}
+			tb.content = null;
+			removeTextBlock(tb);
+		}
+		/** @private */
+		public function releaseTextBlock(tb:ITextBlock=null):void
+		{
+			updateTextBlockRefs();
+			if(tb)
+			{
+				releaseTextBlockInternal(tb);
+				return;
+			}
+			var tbs:Vector.<ITextBlock> = getTextBlocks();
+			for each(var textBlock:ITextBlock in tbs)
+			{
+				releaseTextBlockInternal(textBlock);
+			}
+			//_textBlock = null;
+			if (_computedFormat)
+				_computedFormat = null;
+		}
+		private var _textBlocks:Vector.<ITextBlock>;
+		public function getTextBlocks():Vector.<ITextBlock>
+		{
+			if(_textBlocks == null)
+				_textBlocks = new Vector.<ITextBlock>();
+			return _textBlocks;
+		}
+		/** ITextBlock where the text of the paragraph is kept. @private */
+		public function getTextBlock():ITextBlock
+		{
+			if (!getTextBlocks().length)
+				createTextBlock();
+			
+			return getTextBlocks()[0]; 
+		}
+		/** Last ITextBlock where the text of the paragraph is kept. @private */
+		public function getLastTextBlock():ITextBlock
+		{
+			var tbs:Vector.<ITextBlock> = getTextBlocks();
+			if(!tbs.length)
+				createTextBlock();
+			
+			return tbs[tbs.length-1];
+		}
+
+		/** Get ITextBlock at specified position. @private */
+		public function getTextBlockAtPosition(pos:int):ITextBlock
+		{
+			var curPos:int = 0;
+			var posShift:int = 0;
+			var tables:Vector.<ITableElement> = getTables();
+			if(!tables.length)
+				return getTextBlock();
+			
+			for each(var table:ITableElement in tables)
+			{
+				if(table.getElementRelativeStart(this) < pos)
+					posShift++;
+			}
+			var tbs:Vector.<ITextBlock> = getTextBlocks();
+			for each(var tb:ITextBlock in tbs)
+			{
+				if(tb.content == null)
+					return tb;
+				curPos += tb.content.rawText.length;
+				if(curPos + posShift > pos)
+				{
+					if(getTextBlockStart(tb) > pos)
+						return null;
+					return tb;
+				}
+			}
+			return null;
+		}
+		
+		public function getTextBlockAbsoluteStart(tb:ITextBlock):int
+		{
+			var start:int = getTextBlockStart(tb);
+			if(start < 0)
+				start = 0;
+			return getAbsoluteStart() + start;
+		}
+		public function getTextBlockStart(tb:ITextBlock):int
+		{
+//			var i:int;
+			var curPos:int = 0;
+			var tbs:Vector.<ITextBlock> = getTextBlocks();
+			if(tbs.length == 0)
+				return -1;
+			var tables:Vector.<ITableElement> = getTables();
+			for each(var curTB:ITextBlock in tbs)
+			{
+				for each(var table:ITableElement in tables)
+				{
+					if(table.getElementRelativeStart(this) <= curPos)
+					{
+						curPos++;
+						tables.splice(tables.indexOf(table),1);
+					}
+				}
+				if(tb == curTB)
+					return curPos;
+				if(tb.content)
+					curPos += curTB.content.rawText.length;
+			}
+			
+			return -1;
+		}
+		
+		private function getTables():Vector.<ITableElement>
+		{
+			var tables:Vector.<ITableElement> = new Vector.<ITableElement>();
+			for (var i:int = 0; i < numChildren; i++)
+			{
+				var child:IFlowElement = getChildAt(i);
+				if(child is ITableElement)
+					tables.push(child as ITableElement);
+			}
+			return tables;
+		}
+
+		/** ITextBlock where the text of the paragraph is kept, or null if we currently don't have one. @private */
+		public function peekTextBlock():ITextBlock
+		{ 
+			return getTextBlocks().length == 0 ? null : getTextBlocks()[0];
+		}
+		
+		/** @private */
+		public function releaseLineCreationData():void
+		{
+			// CONFIG::debug { assert(Configuration.playerEnablesArgoFeatures,"bad call to releaseLineCreationData"); }
+			var tbs:Vector.<ITextBlock> = getTextBlocks();
+			for each(var tb:ITextBlock in tbs)
+			{
+				tb["releaseLineCreationData"]();
+			}
+		}
+		
+		/** @private */
+		public override function createContentAsGroup(pos:int=0):GroupElement
+		{
+			var tb:ITextBlock = getTextBlockAtPosition(pos);
+			if(!tb)
+				tb = getTextBlockAtPosition(pos-1);
+			var group:GroupElement = tb.content as GroupElement;
+			if (!group)
+			{
+				var originalContent:ContentElement = tb.content;
+				
+				group = new GroupElement();
+				CONFIG::debug { Debugging.traceFTECall(group,null,"new GroupElement()"); }
+				tb.content = group;
+				CONFIG::debug { Debugging.traceFTEAssign(tb,"content",group); }
+
+				if (originalContent)
+				{
+					var gc:Vector.<ContentElement> = new Vector.<ContentElement>();
+					CONFIG::debug { Debugging.traceFTECall(gc,null,"new Vector.<ContentElement>()"); }
+					gc.push(originalContent);
+					CONFIG::debug { Debugging.traceFTECall(null,gc,"push",originalContent); }
+					group.replaceElements(0,0,gc);
+					CONFIG::debug { Debugging.traceFTECall(null,group,"replaceElements",0,0,gc); }
+				}
+				
+				// Now we've got to force damage the entire paragraph, because we restructured it in FTE.
+				if (tb.firstLine && textLength)
+				{
+					var textFlow:ITextFlow = getTextFlow();
+					if (textFlow)
+						textFlow.damage(getAbsoluteStart(), textLength, "invalid", false);
+				}
+			}
+			return group;
+ 		}
+ 		
+ 		/** @private */
+		public override function removeBlockElement(child:IFlowElement, block:ContentElement):void
+		{
+			var tb:ITextBlock = getTextBlockAtPosition(child.getElementRelativeStart(this));
+			if(!tb)
+				tb = getTextBlock();
+			
+			if(tb.content == null)
+				return;
+			var relativeStart:int = child.getElementRelativeStart(this);
+
+			if (getChildrenInTextBlock(relativeStart).length < 2)
+			{
+				if (block is GroupElement)
+				{
+					// see insertBlockElement
+//					CONFIG::debug { assert(_textBlock.content != block,"removeBlockElement: bad call to removeBlockElement"); }
+//					CONFIG::debug { assert(_textBlock.content is GroupElement,"removeBlockElement: bad content"); }
+//					CONFIG::debug { assert(GroupElement(_textBlock.content).elementCount == 1,"removeBlockElement: bad element count"); }
+//					CONFIG::debug { assert(GroupElement(_textBlock.content).getElementAt(0) == block,"removeBlockElement: bad group content"); }
+					GroupElement(tb.content).replaceElements(0,1,null);
+//					CONFIG::debug { Debugging.traceFTECall(null,_textBlock.content,"replaceElements",0,1,null); }
+				}
+				tb.content = null;
+//				CONFIG::debug { Debugging.traceFTEAssign(_textBlock,"content",null); }
+			}
+			else if(block.groupElement)
+			{
+				var idx:int = getChildIndexInBlock(child);
+				var group:GroupElement = GroupElement(tb.content);
+				CONFIG::debug { assert(group.elementCount == numChildren,"Mismatched group and elementCount"); }
+				group.replaceElements(idx,idx+1,null);
+				if(group.elementCount == 0)
+					return;
+				CONFIG::debug { Debugging.traceFTECall(null,group,"replaceElements",idx,idx+1,null); }
+				if (numChildren == 2)	// its going to be one so ungroup
+				{
+					// ungroup - need to take it out first as inlinelements can only have one parent
+					var elem:ContentElement = group.getElementAt(0);
+					CONFIG::debug { Debugging.traceFTECall(elem,group,"getElementAt",0); }
+					if (!(elem is GroupElement))
+					{
+						group.replaceElements(0,1,null);
+						CONFIG::debug { Debugging.traceFTECall(null,group,"replaceElements",0,1,null); }
+						tb.content = elem;
+						CONFIG::debug { Debugging.traceFTEAssign(tb,"content",elem); }
+					}
+				}
+			}
+			else {
+				//trace("1");
+				//tb.content = null;
+			}
+		}
+		
+		
+		/** @private */
+		public override function hasBlockElement():Boolean
+		{
+			return getTextBlocks().length > 0;
+		}
+		
+		/** @private */
+		override public function createContentElement():void
+		{
+			createTextBlock();
+		}
+		
+		/** @private */
+		private function getChildrenInTextBlock(pos:int):Array
+		{
+			var retVal:Array = [];
+			if(numChildren == 0)
+				return retVal;
+			if(numChildren == 1)
+			{
+				retVal.push(getChildAt(0));
+				return retVal;
+			}
+			var chldrn:Array = mxmlChildren.slice();
+			for(var i:int = 0; i<chldrn.length;i++)
+			{
+				if(chldrn[i] is ITableElement)
+				{
+					if(chldrn[i].parentRelativeStart < pos)
+					{
+						retVal.length = 0;
+						continue;
+					}
+					if(chldrn[i].parentRelativeStart >= pos)
+						break;
+				}
+				retVal.push(chldrn[i]);		
+			}
+			return retVal;
+		}
+		
+		/** @private */
+		public override function insertBlockElement(child:IFlowElement, block:ContentElement):void
+		{
+			var relativeStart:int = child.getElementRelativeStart(this);
+			var tb:ITextBlock = getTextBlockAtPosition(relativeStart);
+			if(!tb)
+				tb = getTextBlockAtPosition(relativeStart-1);
+			
+			if(!tb)
+			{
+				child.releaseContentElement();
+				return;
+			}
+			if (getTextBlocks().length == 0)
+			{
+				child.releaseContentElement();
+				createTextBlock();	// does the whole tree
+				return;
+			}
+			var gc:Vector.<ContentElement>;	// scratch var
+			var group:GroupElement;			// scratch
+			if (getChildrenInTextBlock(relativeStart).length < 2)
+			{
+				if (block is GroupElement)
+				{
+					// this case forces the Group to be in a Group so that following FlowLeafElements aren't in a SubParagraphGroupElementBase's group
+					gc = new Vector.<ContentElement>();
+					CONFIG::debug { Debugging.traceFTECall(gc,null,"new Vector.<ContentElement>()"); }
+					gc.push(block);
+					CONFIG::debug { Debugging.traceFTECall(null,gc,"push",block); }
+					group = new GroupElement(gc);
+					CONFIG::debug { Debugging.traceFTECall(group,null,"new GroupElement",gc); }
+					tb.content = group;
+//					CONFIG::debug { Debugging.traceFTEAssign(_textBlock,"content",group); }
+				}
+				else
+				{
+//TODO commented this out. Was there any reason it was here?
+					// if(block.groupElement)
+					// {
+					// 	block.groupElement.elementCount;
+					// }
+					tb.content = block;
+//					CONFIG::debug { Debugging.traceFTEAssign(_textBlock,"content",block);  }
+				}
+			}
+			else
+			{
+				group = createContentAsGroup(relativeStart);
+				var idx:int = getChildIndexInBlock(child);
+				gc = new Vector.<ContentElement>();
+				CONFIG::debug { Debugging.traceFTECall(gc,null,"new Vector.<ContentElement>"); }
+				gc.push(block);
+				CONFIG::debug { Debugging.traceFTECall(null,gc,"push",block); }
+				// If elements in the middle (i.e. ones in the process of being added) were missed, the idx can be too high.
+				// The missed ones will be inserted later.
+				if(idx > group.elementCount)
+					idx = group.elementCount;
+				group.replaceElements(idx,idx,gc);
+				CONFIG::debug { Debugging.traceFTECall(null,group,"replaceElements",idx,idx,gc); }
+			}
+		}
+		
+		private function getChildIndexInBlock(elem:IFlowElement):int
+		{
+			var relIdx:int = 0;
+			for (var i:int = 0; i < numChildren; i++)
+			{
+				var child:IFlowElement = getChildAt(i);
+				if(child == elem)
+					return relIdx;
+				relIdx++;
+				if(child is ITableElement)
+					relIdx = 0;
+			}
+			return -1;
+		}
+		
+		/** @private */
+		override protected function get abstract():Boolean
+		{ return false;	}	
+		
+		/** @private */
+		public override function get defaultTypeName():String
+		{ return "p"; }
+
+		public function removeEmptyTerminator():void
+		{
+			if(numChildren == 1 && _terminatorSpan && _terminatorSpan.textLength == 1)
+			{
+				_terminatorSpan.removeParaTerminator();
+				super.replaceChildren(0, 1);
+				this._terminatorSpan = null;
+			}
+		}
+		/** @private */
+		public override function replaceChildren(beginChildIndex:int,endChildIndex:int,...rest):void
+		{
+			var applyParams:Array;
+
+			do{
+				if(_terminatorSpan)
+				{
+					var termIdx:int = getChildIndex(_terminatorSpan);
+					if(termIdx > 0 && termIdx < beginChildIndex && _terminatorSpan.textLength == 1)
+					{
+						super.replaceChildren(termIdx, termIdx+1);
+						_terminatorSpan = null;
+						if(beginChildIndex >= termIdx)
+						{
+							beginChildIndex--;
+							if(rest.length == 0) // delete of terminator was already done.
+								break;
+						}
+						if(endChildIndex >= termIdx && beginChildIndex != endChildIndex)
+							endChildIndex--;
+					}
+				}
+				
+				// makes a measurable difference - rest.length zero and one are the common cases
+				if (rest.length == 1)
+					applyParams = [beginChildIndex, endChildIndex, rest[0]];
+				else
+				{
+					applyParams = [beginChildIndex, endChildIndex];
+					if (rest.length != 0)
+						applyParams = applyParams.concat.apply(applyParams, rest);
+				}
+//TODO fix super				
+				super.replaceChildren.apply(this, applyParams);
+				
+			}while(false);
+			
+			ensureTerminatorAfterReplace();
+			// ensure correct text blocks
+			createTextBlock();
+		}
+		
+		public override function splitAtPosition(relativePosition:int):IFlowElement
+		{
+			// need to handle multiple TextBlocks
+			// maybe not. It might be handled in replaceChildren().
+			return super.splitAtPosition(relativePosition);
+		}
+		/**
+		 *  @private
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.ISpanElement
+		 */
+		public function ensureTerminatorAfterReplace():void
+		{
+			//lose reference to terminator if it was removed or not a direct child.
+			if(_terminatorSpan && _terminatorSpan.parent != this)
+			{
+				_terminatorSpan.removeParaTerminator();
+				_terminatorSpan = null;
+			}
+			
+			var newLastLeaf:IFlowLeafElement = getLastLeaf();
+			if (_terminatorSpan != newLastLeaf)
+			{
+				if(_terminatorSpan)
+					_terminatorSpan.removeParaTerminator();
+				if (newLastLeaf && _terminatorSpan)
+				{
+					if(_terminatorSpan.textLength == 0 && !_terminatorSpan.id)
+					{
+						var termIdx:int = getChildIndex(_terminatorSpan);
+						super.replaceChildren(termIdx, termIdx+1);
+					}
+					this._terminatorSpan = null;
+				}
+				if(newLastLeaf)
+				{
+					if (newLastLeaf is ISpanElement)
+					{
+						(newLastLeaf as ISpanElement).addParaTerminator();
+						this._terminatorSpan = newLastLeaf as ISpanElement;
+					}
+					else
+					{
+						var s:ISpanElement = ElementHelper.getTerminator(this, newLastLeaf);
+						super.replaceChildren(numChildren,numChildren,s);
+						this._terminatorSpan = s;
+					}
+				}
+				else
+					_terminatorSpan = null;
+			}
+			//merge terminator span to previous if possible
+			if(_terminatorSpan && _terminatorSpan.textLength == 1)
+			{
+				var prev:IFlowLeafElement = _terminatorSpan.getPreviousLeaf(this);
+				if(prev && prev.parent == this && prev is ISpanElement)
+				{
+					_terminatorSpan.mergeToPreviousIfPossible();
+				}
+			}
+		}
+		
+		/** @private */
+		public function updateTerminatorSpan(splitSpan:ISpanElement,followingSpan:ISpanElement):void
+		{
+			if (_terminatorSpan == splitSpan)
+				_terminatorSpan = followingSpan;
+		}
+
+		[RichTextContent]
+		/** @private NOTE: all FlowElement implementers and overrides of mxmlChildren must specify [RichTextContent] metadata */
+		public override function set mxmlChildren(array:Array):void
+		{
+			// remove all existing children
+			replaceChildren(0,numChildren);
+			
+			for each (var child:Object in array)
+			{
+				if (child is IFlowElement)
+				{
+					if ((child is ISpanElement) || (child is ISubParagraphGroupElementBase))
+						child.bindableElement = true;
+					
+					// Note: calling super.replaceChildren because we don't want to transfer para terminator each time
+					super.replaceChildren(numChildren, numChildren, child as IFlowElement);
+				}
+				else if (child is String)
+				{
+					var s:ISpanElement = ElementHelper.getSpan();
+					s.text = String(child);
+					s.bindableElement = true;
+					
+					// Note: calling super.replaceChildren because we don't want to transfer para terminator each time
+					super.replaceChildren(numChildren, numChildren, s);
+				}
+				else if (child != null)
+					throw new TypeError(GlobalSettings.resourceStringFunction("badMXMLChildrenArgument",[ getQualifiedClassName(child) ]));
+			}
+			
+			// Now ensure para terminator
+			ensureTerminatorAfterReplace();
+			
+			// recreate text blocks to handle possible TableElement changes
+			createTextBlock();
+		}
+		
+		/** @private
+ 		 */
+		public override function getText(relativeStart:int=0, relativeEnd:int=-1, paragraphSeparator:String="\n"):String
+		{
+			// Optimization for getting text of the entire paragraph
+			if (relativeStart == 0 && (relativeEnd == -1 || relativeEnd >= textLength-1) && getTextBlocks().length)
+			{
+				var tb:ITextBlock;
+				var tbs:Vector.<ITextBlock> = getTextBlocks();
+				var text:String = "";
+				for each(tb in tbs)
+				{
+					text = text + getTextInBlock(tb);
+				}
+				if(tb.content && tb.content.rawText)
+					return text.substring(0, text.length - 1);
+				return text;
+			}
+			return super.getText(relativeStart, relativeEnd, paragraphSeparator);
+		}
+		private function getTextInBlock(tb:ITextBlock):String{
+			if(!tb.content || !tb.content.rawText)
+				return "";
+			return tb.content.rawText;
+		}
+		
+		/** Returns the paragraph that follows this one, or null if there are no more paragraphs. 
+		 *
+		 * @return the next paragraph or null if there are no more paragraphs.
+		 *
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 * 
+	 	 * @see #getPreviousParagraph()
+		 *  @flexjsignorecoercion org.apache.flex.textLayout.elements.ParagraphElement
+		 */
+		public function getNextParagraph():IParagraphElement
+		{
+			var nextLeaf:IFlowLeafElement = getLastLeaf().getNextLeaf();
+			return nextLeaf ? nextLeaf.getParagraph() as ParagraphElement : null;
+		}
+	
+		/** Returns the paragraph that precedes this one, or null, if this paragraph is the first one 
+		 * in the ITextFlow. 
+		 *
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 *
+	 	 * @see #getNextParagraph()
+	 	 */
+		public function getPreviousParagraph():IParagraphElement
+		{
+			var previousLeaf:IFlowLeafElement = getFirstLeaf().getPreviousLeaf();
+			return previousLeaf ? previousLeaf.getParagraph() : null;
+		}
+	
+		/** 
+		 * Scans backward from the supplied position to find the location
+		 * in the text of the previous atom and returns the index. The term atom refers to 
+		 * both graphic elements and characters (including groups of combining characters), the 
+		 * indivisible entities that make up a text line.
+		 * 
+		 * @param relativePosition  position in the text to start from, counting from 0
+		 * @return index in the text of the previous cluster
+		 *
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 *
+	 	 * @see org.apache.flex.text.engine.ITextLine
+		 */
+		 
+		public function findPreviousAtomBoundary(relativePosition:int):int
+		{
+			var tb:ITextBlock = getTextBlockAtPosition(relativePosition);
+			if(!tb || !tb.content)
+				return relativePosition-1;
+			
+			var tbStart:int = getTextBlockStart(tb);
+			var textBlockPos:int = relativePosition - tbStart;
+            var tl:ITextLine = tb.getTextLineAtCharIndex(textBlockPos);
+			if (ConfigSettings.usesDiscretionaryHyphens && tl != null)
+			{
+				var currentAtomIndex:int = tl.getAtomIndexAtCharIndex(textBlockPos);
+                //trace("relpos", relativePosition, "atomIndex", currentAtomIndex);
+                var isRTL:Boolean = tl.getAtomBidiLevel(currentAtomIndex) == 1;
+                if (isRTL)
+                {
+//                   var foo:int = tb.findPreviousAtomBoundary(textBlockPos);
+                   if (currentAtomIndex == 0)
+                   {
+                       // when cursor is left of all characters (end of line)
+                       // atomIndex is 0, so compensate
+                       if (tl.atomCount > 0)
+                       {
+                           while (--textBlockPos)
+                           {
+							   --relativePosition;
+                               if (tl.getAtomIndexAtCharIndex(textBlockPos) != currentAtomIndex)
+                                   break;
+                           }
+                       }
+                   }
+                   else
+                   {
+                       while (--relativePosition && --textBlockPos)
+                       {
+                           if (tl.getAtomIndexAtCharIndex(textBlockPos) != currentAtomIndex)
+                               break;
+                       }
+                   }
+                   if (CharacterUtil.isLowSurrogate(getText(relativePosition, relativePosition + 1).charCodeAt(0)))
+				   {
+					   relativePosition--;
+					   textBlockPos--;
+				   }
+				   
+                   //trace("previous", relativePosition, foo);
+                }
+                else
+                {
+    				if (currentAtomIndex == 0)
+    				{
+    					tl = tl.previousLine;
+    					if (!tl)
+						{
+							if(tb != _textBlocks[0])
+								return relativePosition-1;
+							return -1;
+						}
+    					// need this when 0x2028 line separator in use
+    					if (tl.textBlockBeginIndex + tl.rawTextLength == textBlockPos)
+    						return tl.textBlockBeginIndex + tl.rawTextLength - 1 + tbStart;
+    					return tl.textBlockBeginIndex + tl.rawTextLength + tbStart;
+    				}
+    				while (--relativePosition && --textBlockPos)
+    				{
+    					if (tl.getAtomIndexAtCharIndex(textBlockPos) < currentAtomIndex)
+    						break;
+    				}
+                    if (CharacterUtil.isLowSurrogate(getText(relativePosition, relativePosition + 1).charCodeAt(0)))
+					{
+						relativePosition--;
+						textBlockPos--;
+					}
+                }
+				return relativePosition;
+			}
+            var pos:int = tb.findPreviousAtomBoundary(textBlockPos);
+			if(pos >= 0)
+				pos += tbStart;
+            //trace("previous", relativePosition, pos);
+			return pos;
+		}
+
+		/** 
+		 * Scans ahead from the supplied position to find the location
+		 * in the text of the next atom and returns the index. The term atom refers to 
+		 * both graphic elements and characters (including groups of combining characters), the 
+		 * indivisible entities that make up a text line.
+		 * 
+		 * @param relativePosition  position in the text to start from, counting from 0
+		 * @return index in the text of the following atom
+		 *
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 *
+	 	 * @see org.apache.flex.text.engine.ITextLine
+		 */
+		 
+		public function findNextAtomBoundary(relativePosition:int):int
+		{
+			var tb:ITextBlock = getTextBlockAtPosition(relativePosition);
+			if(!tb || !tb.content)
+				return relativePosition+1;
+			var tbStart:int = getTextBlockStart(tb);
+			var textBlockPos:int = relativePosition - tbStart;
+            var tl:ITextLine = tb.getTextLineAtCharIndex(textBlockPos);
+			if (ConfigSettings.usesDiscretionaryHyphens && tl != null)
+			{
+				var currentAtomIndex:int = tl.getAtomIndexAtCharIndex(textBlockPos);
+                //trace("relpos", relativePosition, "atomIndex", currentAtomIndex);
+                var isRTL:Boolean = tl.getAtomBidiLevel(currentAtomIndex) == 1;
+                if (isRTL)
+                {
+//                    var foo:int = tb.findNextAtomBoundary(textBlockPos);
+                    if (currentAtomIndex == 0)
+                    {
+                        while (++textBlockPos)
+                        {
+							++relativePosition;
+                            if (tl.getAtomIndexAtCharIndex(textBlockPos) != currentAtomIndex)
+                                break;
+                        }
+                    }
+                    else
+                    {
+                        while (++textBlockPos)
+                        {
+							++relativePosition;
+                            if (tl.getAtomIndexAtCharIndex(textBlockPos) != currentAtomIndex)
+                                break;
+                        }
+                    }
+                    if (CharacterUtil.isHighSurrogate(getText(relativePosition, relativePosition + 1).charCodeAt(0)))
+					{
+						relativePosition++;
+						textBlockPos++;
+					}
+                    //trace("next", relativePosition, foo);
+                }
+                else
+                {
+    				if (currentAtomIndex == tl.atomCount - 1)
+    				{
+    					tl = tl.nextLine;
+    					if (!tl)
+						{
+							if(tb != _textBlocks[_textBlocks.length-1])
+								return relativePosition+1;
+							return -1;
+						}
+    					return tl.textBlockBeginIndex + tbStart;
+    				}
+    				while (++textBlockPos)
+    				{
+						++relativePosition;
+    					if (tl.getAtomIndexAtCharIndex(textBlockPos) > currentAtomIndex)
+    						break;
+    				}
+                    if (CharacterUtil.isHighSurrogate(getText(relativePosition, relativePosition + 1).charCodeAt(0)))
+					{
+						relativePosition++;
+						textBlockPos++;
+					}
+                }
+				return relativePosition;
+			}
+			var pos:int = tb.findNextAtomBoundary(textBlockPos);
+			if(pos >= 0)
+				pos += tbStart;
+            //trace("next", relativePosition, pos);
+            return pos;
+		}
+		
+		/** @private */
+		public override function getCharAtPosition(relativePosition:int):String
+		{
+			var foundTB:ITextBlock = getTextBlockAtPosition(relativePosition);
+			if(!foundTB)
+				return "\u0016";
+			var tables:Vector.<ITableElement> = getTables();
+			var pos:int = relativePosition;
+			for each(var table:ITableElement in tables)
+			{
+				if(table.getElementRelativeStart(this) < pos)
+					relativePosition--;
+			}
+			var tbs:Vector.<ITextBlock> = getTextBlocks();
+			for each(var tb:ITextBlock in tbs)
+			{
+				if(foundTB == tb)
+					break;
+				if(tb)
+					relativePosition -= tb.content.rawText.length;
+				else
+					relativePosition -= 1;//TODO was this needed? this.getText()
+			}
+			return foundTB.content.rawText.charAt(relativePosition);
+		} 
+
+		/** 
+		 * Returns the index of the previous word boundary in the text.
+		 * 
+		 * <p>Scans backward from the supplied position to find the previous position
+		 * in the text that starts or ends a word. </p>
+		 * 
+		 * @param relativePosition  position in the text to start from, counting from 0
+		 * @return index in the text of the previous word boundary
+		 *
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+		 */
+		 
+		public function findPreviousWordBoundary(relativePosition:int):int
+		{	
+			if (relativePosition == 0)
+				return 0;
+			var prevCharCode:int = getCharCodeAtPosition(relativePosition - 1);
+			if (CharacterUtil.isWhitespace(prevCharCode))
+			{				
+				while (CharacterUtil.isWhitespace(prevCharCode) && ((relativePosition - 1) > 0))
+				{
+					relativePosition--;
+					prevCharCode = getCharCodeAtPosition(relativePosition - 1);
+				}
+				return relativePosition;
+			}
+			var block:ITextBlock = getTextBlockAtPosition(relativePosition);
+			if(block == null)
+				block = getTextBlockAtPosition(--relativePosition);
+			var pos:int = getTextBlockStart(block);
+			if(pos < 0)
+				pos = 0;
+			return relativePosition == pos ? pos : pos + block.findPreviousWordBoundary(relativePosition - pos);
+		}
+
+		/** 
+		 * Returns the index of the next word boundary in the text.
+		 * 
+		 * <p>Scans ahead from the supplied position to find the next position
+		 * in the text that starts or ends a word. </p>
+		 * 
+		 * @param relativePosition  position in the text to start from, counting from 0
+		 * @return  index in the text of the next word boundary
+		 * 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+		 */
+		 
+		public function findNextWordBoundary(relativePosition:int):int
+		{	
+			if (relativePosition == textLength) 
+				return textLength;
+			var curCharCode:int = getCharCodeAtPosition(relativePosition);
+			if (CharacterUtil.isWhitespace(curCharCode))
+			{
+				while (CharacterUtil.isWhitespace(curCharCode) && relativePosition < (textLength - 1))
+				{
+					relativePosition++;
+					curCharCode = getCharCodeAtPosition(relativePosition);
+				}
+				return relativePosition;
+			}
+			var block:ITextBlock = getTextBlockAtPosition(relativePosition);
+			if(block == null)
+				block = getTextBlockAtPosition(--relativePosition);
+			var pos:int = getTextBlockStart(block);
+			if(pos < 0)
+				pos = 0;
+			return pos + block.findNextWordBoundary(relativePosition - pos);
+		}
+		
+		static private var _defaultTabStops:Vector.<TabStop>;
+		static private const defaultTabWidth:int = 48;		// matches default tabs setting in Argo
+		static private const defaultTabCount:int = 20;
+		
+		static private function initializeDefaultTabStops():void
+		{
+			_defaultTabStops = new Vector.<TabStop>(defaultTabCount, true);
+			for (var i:int = 0; i < defaultTabCount; ++i)
+				_defaultTabStops[i] = new TabStop(TextAlign.START, defaultTabWidth * i);
+		}
+		
+		private function updateTextBlock(textBlock:ITextBlock=null):void
+		{
+			if(!textBlock)
+				textBlock = getTextBlock();
+			// find the ancestor with a container and use its format for various settings
+			var containerElement:IContainerFormattedElement = getAncestorWithContainer();
+			if (!containerElement)
+				return;
+				
+			var containerElementFormat:ITextLayoutFormat = containerElement ? containerElement.computedFormat : TextLayoutFormat.defaultFormat;
+			
+			var lineJust:String;
+			if (computedFormat.textAlign == TextAlign.JUSTIFY)
+			{
+				lineJust = (_computedFormat.textAlignLast == TextAlign.JUSTIFY) ?
+					LineJustification.ALL_INCLUDING_LAST :
+					LineJustification.ALL_BUT_LAST;
+					
+				// We don't allow explicit line breaks and justification together because it results in very strange (invisible) lines
+				if (containerElementFormat.lineBreak == LineBreak.EXPLICIT)
+					lineJust = LineJustification.UNJUSTIFIED;
+			}
+			else
+				lineJust = LineJustification.UNJUSTIFIED;
+		
+			
+			var makeJustRuleStyle:String = this.getEffectiveJustificationStyle();
+			
+			var justRule:String = this.getEffectiveJustificationRule();
+				
+			// set the justifier in the ITextBlock
+			if (justRule == JustificationRule.SPACE)
+			{
+				var spaceJustifier:SpaceJustifier = new SpaceJustifier(_computedFormat.locale,lineJust,false);
+				spaceJustifier.letterSpacing = _computedFormat.textJustify == TextJustify.DISTRIBUTE ? true : false;
+
+				// These three properties have to be set in the correct order so that consistency checks done
+				// in the Player on set are never violated
+				var newMinimumSpacing:Number = PropertyUtil.toNumberIfPercent(_computedFormat.wordSpacing.minimumSpacing)/100;
+				var newMaximumSpacing:Number = PropertyUtil.toNumberIfPercent(_computedFormat.wordSpacing.maximumSpacing)/100;
+				var newOptimumSpacing:Number = PropertyUtil.toNumberIfPercent(_computedFormat.wordSpacing.optimumSpacing)/100; 
+				spaceJustifier.minimumSpacing = Math.min(newMinimumSpacing, spaceJustifier.minimumSpacing);
+				spaceJustifier.maximumSpacing = Math.max(newMaximumSpacing, spaceJustifier.maximumSpacing);
+				spaceJustifier.optimumSpacing = newOptimumSpacing;
+				spaceJustifier.minimumSpacing = newMinimumSpacing;
+				spaceJustifier.maximumSpacing = newMaximumSpacing;
+
+				CONFIG::debug { Debugging.traceFTECall(spaceJustifier,null,"new SpaceJustifier",_computedFormat.locale,lineJust,spaceJustifier.letterSpacing); }
+				textBlock.textJustifier = spaceJustifier;
+				CONFIG::debug { Debugging.traceFTEAssign(textBlock,"textJustifier",spaceJustifier); }
+				textBlock.baselineZero = LeadingUtils.getLeadingBasis(this.getEffectiveLeadingModel());
+				CONFIG::debug { Debugging.traceFTEAssign(textBlock,"baselineZero",textBlock.baselineZero);  }
+			}
+			else
+			{
+				var eastAsianJustifier:Object = new EastAsianJustifier(_computedFormat.locale,lineJust, makeJustRuleStyle);
+				if( /*Configuration.versionIsAtLeast(10,3) &&*/ eastAsianJustifier.hasOwnProperty("composeTrailingIdeographicSpaces")){
+					eastAsianJustifier.composeTrailingIdeographicSpaces = true;
+				}
+				CONFIG::debug { Debugging.traceFTECall(eastAsianJustifier,null,"new EastAsianJustifier",_computedFormat.locale,lineJust,makeJustRuleStyle); }
+				textBlock.textJustifier = eastAsianJustifier as EastAsianJustifier;
+				CONFIG::debug { Debugging.traceFTEAssign(textBlock,"textJustifier",eastAsianJustifier);  }
+				textBlock.baselineZero = LeadingUtils.getLeadingBasis(this.getEffectiveLeadingModel());
+				CONFIG::debug { Debugging.traceFTEAssign(textBlock,"baselineZero",textBlock.baselineZero);  }
+			}
+			
+			textBlock.bidiLevel = _computedFormat.direction == Direction.LTR ? 0 : 1;
+			CONFIG::debug { Debugging.traceFTEAssign(textBlock,"bidiLevel",textBlock.bidiLevel);  }
+
+			textBlock.lineRotation = containerElementFormat.blockProgression == BlockProgression.RL ? TextRotation.ROTATE_90 : TextRotation.ROTATE_0;
+			CONFIG::debug { Debugging.traceFTEAssign(textBlock,"lineRotation",textBlock.lineRotation);  }
+			
+			if (_computedFormat.tabStops && _computedFormat.tabStops.length != 0)
+			{
+				//create a vector of TabStops and assign it to tabStops in textBlock
+				var tabStops:Vector.<TabStop> = new Vector.<TabStop>();
+				CONFIG::debug { Debugging.traceFTECall(tabStops,null,"new Vector.<TabStop>()"); }
+				for each(var tsa:TabStopFormat in _computedFormat.tabStops)
+				{
+					var token:String = tsa.decimalAlignmentToken==null ? "" : tsa.decimalAlignmentToken;
+					var alignment:String = tsa.alignment==null ? TabAlignment.START : tsa.alignment;
+					var tabStop:TabStop = new TabStop(alignment,Number(tsa.position),token);
+					// this next line when uncommented works around bug 1912782
+					if (tsa.decimalAlignmentToken != null) var garbage:String = "x" + tabStop.decimalAlignmentToken;
+					CONFIG::debug { Debugging.traceFTECall(tabStop,null,"new TabStop",tabStop.alignment,tabStop.position,tabStop.decimalAlignmentToken); }
+					tabStops.push(tabStop);
+					CONFIG::debug { Debugging.traceFTECall(null,tabStops,"push",tabStop); }
+				}
+				textBlock.tabStops = tabStops;
+				CONFIG::debug { Debugging.traceFTEAssign(textBlock,"tabStops",tabStops);  }
+			} //TODO make sure the Text Engine sets default tab stops
+			// else if (GlobalSettings.enableDefaultTabStops && !Configuration.playerEnablesArgoFeatures)
+			// {
+			// 	// 	Player versions prior to 10.1 do not set up any default tabStops. As a workaround, if enableDefaultTabs
+			// 	//	is true, TLF will set up default tabStops in the case where there are no tabs defined. 
+			// 	if (_defaultTabStops == null)
+			// 		initializeDefaultTabStops();
+			// 	textBlock.tabStops = _defaultTabStops;
+			// 	CONFIG::debug { Debugging.traceFTEAssign(textBlock,"tabStops",_defaultTabStops);  }
+			// }
+			else
+			{
+				textBlock.tabStops = null;
+				CONFIG::debug { Debugging.traceFTEAssign(textBlock,"tabStops",null);  }
+			}		 
+		}
+		
+		/** @private */
+		public override function get computedFormat():ITextLayoutFormat
+		{
+			if (!_computedFormat)
+			{
+				super.computedFormat;
+				var tbs:Vector.<ITextBlock> = getTextBlocks();
+				for each(var tb:ITextBlock in tbs)
+					updateTextBlock(tb);
+					
+			}
+			return _computedFormat;
+		}
+
+		/** @private */
+		public override function canOwnFlowElement(elem:IFlowElement):Boolean
+		{
+			return elem is IFlowLeafElement || elem is ISubParagraphGroupElementBase || elem is ITableElement;
+		}
+		
+		/** @private */
+		public override function normalizeRange(normalizeStart:uint,normalizeEnd:uint):void
+		{
+			var idx:int = findChildIndexAtPosition(normalizeStart);
+			if (idx != -1 && idx < numChildren)
+			{
+				var child:IFlowElement = getChildAt(idx);
+				normalizeStart = normalizeStart-child.parentRelativeStart;
+				
+				CONFIG::debug { assert(normalizeStart >= 0, "bad normalizeStart in normalizeRange"); }
+				for (;;)
+				{
+					// watch out for changes in the length of the child
+					var origChildEnd:int = child.parentRelativeStart+child.textLength;
+					child.normalizeRange(normalizeStart,normalizeEnd-child.parentRelativeStart);
+					var newChildEnd:int = child.parentRelativeStart+child.textLength;
+					normalizeEnd += newChildEnd-origChildEnd;	// adjust
+					
+					// no zero length children
+					if (child.textLength == 0 && !child.bindableElement)
+						replaceChildren(idx,idx+1);
+					else if (child.mergeToPreviousIfPossible())
+					{
+						var prevElement:IFlowElement = this.getChildAt(idx-1);
+						// possibly optimize the start to the length of prevelement before the merge
+						prevElement.normalizeRange(0,prevElement.textLength);
+					}
+					else
+						idx++;
+
+					if (idx == numChildren)
+					{
+						// check if last child is an empty SubPargraphBlock and remove it
+						if (idx != 0)
+						{
+							var lastChild:IFlowElement = this.getChildAt(idx-1);
+							if (lastChild is ISubParagraphGroupElementBase && lastChild.textLength == 1 && !lastChild.bindableElement)
+								replaceChildren(idx-1,idx);
+						}
+						break;
+					}
+					
+					// next child
+					child = getChildAt(idx);
+					
+					if (child.parentRelativeStart > normalizeEnd)
+						break;
+						
+					normalizeStart = 0;		// for the next child	
+				}
+			}
+			
+			// empty paragraphs not allowed after normalize
+			if (numChildren == 0 || textLength == 0)
+			{
+				var s:ISpanElement = ElementHelper.getSpan();
+				replaceChildren(0,0,s);
+				s.normalizeRange(0,s.textLength);
+			}
+		}
+		
+		/** @private */
+		public function getEffectiveLeadingModel():String
+		{
+			return computedFormat.leadingModel == LeadingModel.AUTO ? LocaleUtil.leadingModel(computedFormat.locale) : computedFormat.leadingModel;
+		}
+		
+		/** @private */
+		public function getEffectiveDominantBaseline():String
+		{
+			return computedFormat.dominantBaseline == FormatValue.AUTO ? LocaleUtil.dominantBaseline(computedFormat.locale) : computedFormat.dominantBaseline;
+		}
+		
+		/** @private */
+		public function getEffectiveJustificationRule():String
+		{
+			return computedFormat.justificationRule == FormatValue.AUTO ? LocaleUtil.justificationRule(computedFormat.locale) : computedFormat.justificationRule;
+		}
+		
+		/** @private */
+		public function getEffectiveJustificationStyle():String
+		{
+			return computedFormat.justificationStyle == FormatValue.AUTO ? LocaleUtil.justificationStyle(computedFormat.locale) : computedFormat.justificationStyle;
+		}
+		
+		
+		/** @private */
+		CONFIG::debug public override function debugCheckFlowElement(depth:int = 0, extraData:String = ""):int
+		{
+			var tb:ITextBlock = getTextBlock();
+			var rslt:int = super.debugCheckFlowElement(depth," fte:"+getDebugIdentity(tb)+" "+extraData);
+			
+			// now check the character count and then the last character 
+			
+			if (tb)
+			{
+				var contentLength:int = tb.content && tb.content.rawText ? tb.content.rawText.length : 0;
+				rslt += assert(contentLength == textLength,"Bad paragraph length mode:"+textLength.toString()+" _textBlock:" + contentLength.toString());
+
+				var groupElement:GroupElement = tb.content as GroupElement;
+				if (groupElement)
+					assert(groupElement.elementCount == numChildren,"Mismatched group and elementCount"); 
+				else if (tb.content)
+					assert(1 == numChildren,"Mismatched group and elementCount"); 
+				else 
+					assert(0 == numChildren,"Mismatched group and elementCount"); 
+			}
+			rslt += assert(numChildren == 0 || textLength > 0,"Para must have at least one text char");
+			return rslt;
+		}
+		
+
+		
+		public function incInteractiveChildrenCount() : void
+		{
+			++ _interactiveChildrenCount ;
+		}
+		public function decInteractiveChildrenCount() : void
+		{
+			-- _interactiveChildrenCount ;
+		}
+		
+		public function hasInteractiveChildren() : Boolean
+		{
+			return _interactiveChildrenCount != 0 ;
+		}
+
+		public function get terminatorSpan():ISpanElement
+		{
+			return _terminatorSpan;
+		}
+
+	}
+}


[03/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/MoveChildrenOperation.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/MoveChildrenOperation.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/MoveChildrenOperation.as
new file mode 100644
index 0000000..dac768c
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/MoveChildrenOperation.as
@@ -0,0 +1,199 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.operations {
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.edit.MementoList;
+	import org.apache.flex.textLayout.edit.ModelEdit;
+	import org.apache.flex.textLayout.edit.SelectionState;
+	import org.apache.flex.textLayout.elements.IFlowGroupElement;
+	import org.apache.flex.textLayout.elements.ListElement;
+	import org.apache.flex.textLayout.elements.ListItemElement;
+	import org.apache.flex.textLayout.elements.TextFlow;
+	
+	/**
+	 * The MoveChildrenOperation class allows moving a set of siblings out of its immediate parent chain, and the operation removes any empty ancestor chain left behind.
+	 *
+	 * @see org.apache.flex.textLayout.elements.FlowElement
+	 * @see org.apache.flex.textLayout.edit.EditManager
+	 * @see org.apache.flex.textLayout.events.FlowOperationEvent
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	public class MoveChildrenOperation extends FlowTextOperation
+	{	
+		private var _source:IFlowGroupElement;
+		private var _sourceIndex:int;
+		private var _numChildren:int;
+		private var _destination:IFlowGroupElement;
+		private var _destinationIndex:int;
+		private var _mementoList:MementoList;
+		
+		/** 
+		 * Creates a MoveChildrenOperation object. 
+		 * 
+		 * <p>This operation moves a consecutive number of children of source into the destination
+		 * context.  Also, if moving the children leaves the source element with no children, then
+		 * source will be removed.  The removal is done recursively such that if source's parent
+		 * becomes empty from the removal of source, it too will be deleted, and on up the parent chain.</p>
+		 * 
+		 * @param operationState Specifies the SelectionState of this operation
+		 * @param source Specifies the parent of the item(s) to move.
+		 * @param sourceIndex Specifies the index of the first item to move.
+		 * @param numChildren Specifies the number of children to move.
+		 * @param destination Specifies the new parent of the items.
+		 * @param destinationIndex Specifies the new child index of the first element.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		*/
+		public function MoveChildrenOperation(operationState:SelectionState, source:IFlowGroupElement, sourceIndex:int, numChildren:int, destination:IFlowGroupElement, destinationIndex:int)
+		{
+			super(operationState);
+			_source = source;
+			_sourceIndex = sourceIndex;
+			_numChildren = numChildren;
+			_destination = destination;
+			_destinationIndex = destinationIndex;
+			_mementoList = new MementoList(operationState.textFlow);
+		}
+		
+		/** Specifies the parent of the item(s) to move.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		*/
+		public function get source():IFlowGroupElement
+		{ return _source; }
+		public function set source(val:IFlowGroupElement):void
+		{ _source = val; }
+		
+		/** Specifies the number of children to move.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public function get sourceIndex():int
+		{ return _sourceIndex; }
+		public function set sourceIndex(val:int):void
+		{ _sourceIndex = val; }
+		
+		/** Specifies the index of the first item to move.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public function get numChildren():int
+		{ return _numChildren; }
+		public function set numChildren(val:int):void
+		{ _numChildren = val; }
+		
+		/** Specifies the new parent of the items.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public function get destination():IFlowGroupElement
+		{ return _destination; }
+		public function set destination(val:IFlowGroupElement):void
+		{ _destination = val; }
+		
+		/** Specifies the new child index of the first element.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public function get destinationIndex():int
+		{ return _destinationIndex; }
+		public function set destinationIndex(val:int):void
+		{ _destinationIndex = val; }
+		
+		/**
+		 *  @private
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.IFlowGroupElement
+		 */
+		public override function doOperation():Boolean
+		{
+
+			CONFIG::debug
+			{
+				assert(_destination != null, "MoveChildrenOperation attempted on a null target");
+				assert(_source != null, "MoveChildrenOperation attempted on a null element");
+			}
+
+			var insertContext:IFlowGroupElement;
+			
+			for(var count:int = 0; count < _numChildren; count++)
+			{
+				// special case for list items moving into non-list parent - move the children of the item and remove the item
+				if(_source.getChildAt(_sourceIndex) is ListItemElement && !(_destination is ListElement))
+				{
+					for(var count2:int = 0; count2 = (_source.getChildAt(_sourceIndex) as IFlowGroupElement).numChildren; count2++)
+					{
+						_mementoList.push(ModelEdit.moveElement(textFlow, (_source.getChildAt(_sourceIndex) as IFlowGroupElement).getChildAt(0), _destination, _destinationIndex++));
+					}
+					_mementoList.push(ModelEdit.removeElements(textFlow, _source, _sourceIndex, 1));
+				}
+				else
+				{
+					_mementoList.push(ModelEdit.moveElement(textFlow, _source.getChildAt(_sourceIndex), _destination, _destinationIndex++));
+				}
+			}
+			
+			var parent:IFlowGroupElement = _source;
+			var idx:int;
+			while(parent.numChildren == 0 && !(parent is TextFlow))
+			{
+				idx = parent.parent.getChildIndex(parent);
+				parent = parent.parent;
+				_mementoList.push(ModelEdit.removeElements(textFlow, parent, idx, 1));
+				insertContext = parent;
+			}
+			
+			if(parent is ListElement)
+			{
+				insertContext = parent.parent;
+				idx = parent.parent.getChildIndex(parent);
+			}
+			
+			return true;
+		}
+		
+		/** @private */ 
+		public override function undo():SelectionState
+		{
+			_mementoList.undo();
+			return originalSelectionState; 
+		}
+		
+		/** @private */ 
+		public override function redo():SelectionState
+		{
+			_mementoList.redo();
+			return originalSelectionState; 
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/PasteOperation.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/PasteOperation.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/PasteOperation.as
new file mode 100644
index 0000000..d0eda48
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/PasteOperation.as
@@ -0,0 +1,196 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.operations
+{
+	import org.apache.flex.textLayout.conversion.ConversionConstants;
+	import org.apache.flex.textLayout.edit.ModelEdit;
+	import org.apache.flex.textLayout.edit.SelectionState;
+	import org.apache.flex.textLayout.edit.TextFlowEdit;
+	import org.apache.flex.textLayout.edit.TextScrap;
+	import org.apache.flex.textLayout.elements.IFlowLeafElement;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+
+
+
+
+
+
+	/**
+	 * The PasteOperation class encapsulates a paste operation.
+	 *
+	 * <p>The specified range is replaced by the new content.</p>
+	 * 
+	 * <p><b>Note:</b> The edit manager is responsible for copying the 
+	 * contents of the clipboard.</p>
+	 * 
+	 * @see org.apache.flex.textLayout.edit.EditManager
+	 * @see org.apache.flex.textLayout.events.FlowOperationEvent
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */			
+	public class PasteOperation extends FlowTextOperation
+	{
+		private var _textScrap:TextScrap;
+		private var _numCharsAdded:int = 0;
+		private var _deleteTextOperation:DeleteTextOperation;
+		private var _applyParagraphSettings:Array;
+		private var _pointFormat:ITextLayoutFormat;
+		private var _applyPointFormat:ApplyFormatOperation;
+		
+		/** 
+		 * Creates a PasteOperation object.
+		 * 
+		 * @param operationState Describes the insertion point or a range of text 
+		 * to replace.
+		 * @param textScrap The content to paste into the text flow.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		public function PasteOperation(operationState:SelectionState, textScrap:TextScrap)
+		{
+			_pointFormat = operationState.pointFormat;
+			super(operationState);
+			_textScrap = textScrap;
+		}
+		
+		/** @private */
+		public override function doOperation():Boolean
+		{
+			if (_textScrap != null)
+			{
+				if (absoluteStart != absoluteEnd)	
+				{
+					_deleteTextOperation = new DeleteTextOperation(originalSelectionState);
+					_deleteTextOperation.doOperation();
+				}
+				
+				var preserveScrapParagraph:Boolean = false;
+				var plainText:Boolean = _textScrap.isPlainText();
+				if (!plainText)
+				{
+					// If we're pasting formatted text into an empty paragraph, apply the paragraph settings from the scrap to the paragraph in the TextFlow
+					var leaf:IFlowLeafElement = textFlow.findLeaf(absoluteStart);
+					var paragraph:IParagraphElement = leaf.getParagraph();
+					if (paragraph.textLength == 1)
+						preserveScrapParagraph = true;
+				}
+				var nextInsertPosition:int = TextFlowEdit.insertTextScrap(textFlow, absoluteStart, _textScrap, plainText);
+				if (textFlow.interactionManager)
+					textFlow.interactionManager.notifyInsertOrDelete(absoluteStart, nextInsertPosition - absoluteStart);				
+				_numCharsAdded = (nextInsertPosition - absoluteStart);
+				
+				if (preserveScrapParagraph)
+				{
+					applyPreserveSettings();
+				} 
+				else if (_pointFormat && plainText)
+				{
+					_applyPointFormat = new ApplyFormatOperation(new SelectionState(textFlow, absoluteStart, absoluteStart + _numCharsAdded), _pointFormat, null, null);
+					_applyPointFormat.doOperation();
+				}
+
+				
+				
+			}
+			return true;	
+		}
+		
+		private function applyPreserveSettings():void
+		{
+			var scrap:ITextFlow = _textScrap.textFlow;
+			var scrapParagraph:IParagraphElement = scrap.getFirstLeaf().getParagraph();
+			
+			_applyParagraphSettings = [];
+			var format:TextLayoutFormat = new TextLayoutFormat(scrapParagraph.format);
+			format.setStyle(ConversionConstants.MERGE_TO_NEXT_ON_PASTE, undefined);
+			var applyParagraphFormat:ApplyFormatToElementOperation = new ApplyFormatToElementOperation(originalSelectionState, textFlow.findLeaf(absoluteStart).getParagraph(), format);
+			applyParagraphFormat.doOperation();
+			_applyParagraphSettings.push(applyParagraphFormat);			
+			
+			//bug #2826905
+			if(scrap.numChildren > 1){
+				var scrapEndParagraph:IParagraphElement = scrap.getLastLeaf().getParagraph();
+				format = new TextLayoutFormat(scrapEndParagraph.format);
+				format.setStyle(ConversionConstants.MERGE_TO_NEXT_ON_PASTE, undefined);
+				var applyEndParagraphFormat:ApplyFormatToElementOperation = new ApplyFormatToElementOperation(originalSelectionState, textFlow.findLeaf(absoluteStart + scrap.textLength - 1).getParagraph(), format);
+				applyEndParagraphFormat.doOperation();
+				_applyParagraphSettings.push(applyEndParagraphFormat);
+			}
+		}
+		
+		/** @private */
+		public override function undo():SelectionState
+		{
+			if (_textScrap != null)
+			{
+				if (_applyPointFormat)
+					_applyPointFormat.undo(); 
+				if (_applyParagraphSettings)
+				{
+					for (var i:int = _applyParagraphSettings.length - 1; i >= 0; --i)
+						_applyParagraphSettings[i].undo();
+				}
+				ModelEdit.deleteText(textFlow, absoluteStart, absoluteStart + _numCharsAdded, false);
+				if (_deleteTextOperation)
+					_deleteTextOperation.undo();
+			}
+			return originalSelectionState;	
+		}
+	
+		/** @private */
+		public override function redo():SelectionState
+		{
+			if (_textScrap != null)
+			{
+				if (_deleteTextOperation)
+					_deleteTextOperation.redo();
+				var nextInsertPosition:int = TextFlowEdit.insertTextScrap(textFlow, absoluteStart, _textScrap, _textScrap.isPlainText());
+				if (textFlow.interactionManager)
+					textFlow.interactionManager.notifyInsertOrDelete(absoluteStart, nextInsertPosition - absoluteStart);		
+				if (_applyParagraphSettings)
+				{
+					for (var i:int = _applyParagraphSettings.length - 1; i >= 0; --i)
+						_applyParagraphSettings[i].redo();
+				}
+				if (_applyPointFormat)
+					_applyPointFormat.redo(); 
+			}
+			return new SelectionState(textFlow, absoluteStart + _numCharsAdded, absoluteStart + _numCharsAdded,null);	
+		}		
+
+		/** 
+		 * textScrap the text being pasted
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		public function get textScrap():TextScrap
+		{ return _textScrap; }
+		public function set textScrap(val:TextScrap):void
+		{ _textScrap = val; }		
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/RedoOperation.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/RedoOperation.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/RedoOperation.as
new file mode 100644
index 0000000..17ac4e4
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/RedoOperation.as
@@ -0,0 +1,70 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.operations {
+
+
+
+
+	/** 
+	 * The RedoOperation class encapsulates a redo operation.
+	 *
+	 * @see org.apache.flex.textLayout.edit.EditManager
+	 * @see org.apache.flex.textLayout.events.FlowOperationEvent
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	public class RedoOperation extends FlowOperation
+	{
+		private var _operation:FlowOperation;	/** Operation to be undone - here so listeners on FlowOperationEvent can see. */
+		
+		/** 
+		 * Creates a RedoOperation object.
+		 * 
+		 * @param operation	The operation to redo.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public function RedoOperation(operation:FlowOperation)
+		{ 
+			super(operation.textFlow);
+			_operation = operation;
+		}
+
+
+		/** 
+		 * The operation to redo.
+		 *  
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		*/
+		public function get operation():FlowOperation
+		{
+			return _operation;
+		}
+		public function set operation(value:FlowOperation):void
+		{
+			_operation = value;
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/SplitElementOperation.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/SplitElementOperation.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/SplitElementOperation.as
new file mode 100644
index 0000000..eeedaa7
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/SplitElementOperation.as
@@ -0,0 +1,191 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.operations {
+	import org.apache.flex.textLayout.elements.IFlowGroupElement;
+	import org.apache.flex.textLayout.edit.ElementMark;
+	import org.apache.flex.textLayout.edit.IMemento;
+	import org.apache.flex.textLayout.edit.ModelEdit;
+	import org.apache.flex.textLayout.edit.SelectionState;
+	import org.apache.flex.textLayout.elements.IFlowGroupElement;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.IListItemElement;
+	import org.apache.flex.textLayout.elements.ISubParagraphGroupElementBase;
+	import org.apache.flex.textLayout.formats.ListMarkerFormat;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+
+	
+
+
+
+
+
+	/**
+	 * The SplitElementOperation class encapsulates a change that splits any IFlowGroupElement into two elements.
+	 *
+	 * This operation splits target at operationState.absoluteStart.
+	 * 
+	 * @see org.apache.flex.textLayout.elements.ParagraphElement
+	 * @see org.apache.flex.textLayout.edit.EditManager
+	 * @see org.apache.flex.textLayout.events.FlowOperationEvent
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */			
+	public class SplitElementOperation extends FlowTextOperation
+	{
+		//range for block delete
+		private var delSelOp:DeleteTextOperation;		
+
+		// describes the target
+		private var _targetMark:ElementMark;
+		
+		// moment to undo
+		private var _memento:IMemento;
+		
+		// new element to return to client
+		private var _newElement:IFlowGroupElement;
+		/** 
+		 * Creates a SplitElementOperation object.  This operation deletes a block selection and then splits the target at absoluteStart.  The block selection should not cause target to be deleted.
+		 * Target is a IFlowGroupElement but may not be a LinkElement, TCYElement or SubParagraphGroupElement.
+		 * 
+		 * @param operationState Describes the point at which to split the element.
+		 * If a range of text is specified, the contents of the range are deleted.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		public function SplitElementOperation(operationState:SelectionState, targetElement:IFlowGroupElement)
+		{
+			super(operationState);
+			this.targetElement = targetElement;
+		}
+		
+		/** 
+		 * Specifies the element this operation modifies.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public function get targetElement():IFlowGroupElement
+		{
+			return _targetMark.findElement(originalSelectionState.textFlow) as IFlowGroupElement;
+		}
+		public function set targetElement(value:IFlowGroupElement):void
+		{
+			_targetMark = new ElementMark(value,0);
+		}
+		
+		/** 
+		 * Returns the new element created by doOperation.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public function get newElement():IFlowGroupElement
+		{ return _newElement; }
+		
+		/** @private */
+		public override function doOperation():Boolean
+		{ 
+			var target:IFlowGroupElement = targetElement;
+			
+			if (absoluteStart < absoluteEnd)
+			{
+				// watch out for total deletion of target
+				var targStart:int = target.getAbsoluteStart();
+				var targEnd:int   = targStart + target.textLength;
+				
+				delSelOp = new DeleteTextOperation(originalSelectionState);
+				delSelOp.doOperation();
+				
+				if (absoluteStart <= targStart && targEnd <= absoluteEnd)
+				{
+					// completely deleted
+					if (target is IParagraphElement)
+						target = textFlow.findAbsoluteParagraph(absoluteStart);
+					else
+						target = null;	
+				}
+				else
+					target = targetElement;	// recalculate
+				
+			}
+			
+			// SubParagraphGroupElements don't split as the target - they just merge again in normalize.  
+			// Consider some sort of way to do this.  Generally has to be combined with another operation or somehow marked as don't merge
+			// make sure it hasn't been deleted during the delete phase
+			if (target != null && !(target is ISubParagraphGroupElementBase) && target.getTextFlow() == textFlow)
+			{
+				var oldLength:int = textFlow.textLength;
+				var relativePosition:int = absoluteStart-target.getAbsoluteStart();
+				_memento = ModelEdit.splitElement(textFlow,target,relativePosition);
+				_newElement = target.parent.getChildAt(target.parent.getChildIndex(target)+1) as IFlowGroupElement;
+
+				// fix for 2702736 - when splitting a IListItemElement, make sure not to clone the counterReset marker format - it creates unexpected results, new items don't increment
+				if(_newElement is IListItemElement && 
+					_newElement.listMarkerFormat && 
+					_newElement.listMarkerFormat.counterReset !== undefined)
+				{
+					var listMarkerFormat:ListMarkerFormat = new ListMarkerFormat(_newElement.listMarkerFormat);
+					listMarkerFormat.counterReset = undefined;
+					_newElement.listMarkerFormat = listMarkerFormat;
+				}
+				
+				
+				if( target is IParagraphElement )
+				{
+					// fix for bug#2948473 - when splitting, the contain/column break settings will not be copied to the
+					// new paragraph element
+					var newFormat:TextLayoutFormat = new TextLayoutFormat(_newElement.format);
+					newFormat.containerBreakAfter = undefined;
+					newFormat.containerBreakBefore = undefined;
+					newFormat.columnBreakAfter = undefined;
+					newFormat.columnBreakBefore = undefined;
+					_newElement.format = newFormat;
+					
+					if (textFlow.interactionManager && oldLength != textFlow.textLength)
+						textFlow.interactionManager.notifyInsertOrDelete(absoluteStart, textFlow.textLength-oldLength);
+				}
+						
+					
+			}
+
+			return true;
+		}
+	
+		/** @private */
+		public override function undo():SelectionState
+		{ 
+			if (_memento)
+				_memento.undo();	
+			_newElement = null;
+			
+			return absoluteStart < absoluteEnd ? delSelOp.undo() : originalSelectionState;
+		}
+		
+		/** @private */
+		public override function redo():SelectionState
+		{
+			super.redo();
+			return textFlow.interactionManager.getSelectionState();
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/SplitParagraphOperation.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/SplitParagraphOperation.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/SplitParagraphOperation.as
new file mode 100644
index 0000000..5b3bbdd
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/SplitParagraphOperation.as
@@ -0,0 +1,73 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.operations {
+	import org.apache.flex.textLayout.edit.SelectionState;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+
+	
+
+
+
+
+
+	/**
+	 * The SplitParagraphOperation class encapsulates a change that splits a paragraph into two elements.
+	 *
+	 * <p>The operation creates a new paragraph containing the text from 
+	 * the specified position to the end of the paragraph. If a range of text is specified, the text 
+	 * in the range is deleted first.</p>
+	 * 
+	 * @see org.apache.flex.textLayout.elements.ParagraphElement
+	 * @see org.apache.flex.textLayout.edit.EditManager
+	 * @see org.apache.flex.textLayout.events.FlowOperationEvent
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */			
+	public class SplitParagraphOperation extends SplitElementOperation
+	{		
+		/** 
+		 * Creates a SplitParagraphOperation object.
+		 * 
+		 * @param operationState Describes the point at which to split the paragraph.
+		 * If a range of text is specified, the contents of the range are deleted.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		public function SplitParagraphOperation(operationState:SelectionState)
+		{
+			var para:IParagraphElement = operationState.textFlow.findLeaf(operationState.absoluteStart).getParagraph();
+			super(operationState, para);
+		}
+		
+		/** @private */
+		public override function merge(operation:FlowOperation):FlowOperation
+		{
+			if (this.endGeneration != operation.beginGeneration)
+				return null;
+			// TODO we could probably do something a bit more efficient for a backspace
+			if ((operation is SplitParagraphOperation) || (operation is InsertTextOperation))
+				return new CompositeOperation([this,operation]);
+			return null;
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/UndoOperation.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/UndoOperation.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/UndoOperation.as
new file mode 100644
index 0000000..0b86013
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/UndoOperation.as
@@ -0,0 +1,71 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.operations
+{
+	import org.apache.flex.textLayout.edit.SelectionState;
+
+
+
+
+	/** 
+	 * The UndoOperation class encapsulates an undo operation.
+	 *
+	 * @see org.apache.flex.textLayout.edit.EditManager
+	 * @see org.apache.flex.textLayout.events.FlowOperationEvent
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	public class UndoOperation extends FlowOperation
+	{
+		private var _operation:FlowOperation;	/** Operation to be undone - here so listeners on FlowOperationEvent can see. */
+		
+		/** 
+		 * Creates an UndoOperation object.
+		 * 
+		 * @param op	The operation to undo.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public function UndoOperation(op:FlowOperation)
+		{ 
+			super(null);
+			_operation = op;
+		}
+		
+		/** 
+		 * The operation to undo. 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		public function get operation():FlowOperation
+		{
+			return _operation;
+		}
+		public function set operation(value:FlowOperation):void
+		{
+			_operation = value;
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/ArrayProperty.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/ArrayProperty.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/ArrayProperty.as
new file mode 100644
index 0000000..bf84731
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/ArrayProperty.as
@@ -0,0 +1,201 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.property
+{
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.formats.FormatValue;
+
+		
+
+		
+	// [ExcludeClass]
+	/** A property description with an Array value.@private */
+	public class ArrayProperty extends Property
+	{
+		private var _memberType:*;
+		
+		public function ArrayProperty(nameValue:String, defaultValue:Array, inherited:Boolean, categories:Vector.<String>, mType:Class)
+		{
+			super(nameValue, defaultValue, inherited, categories); 
+			_memberType = mType;
+			CONFIG::debug { assert(_memberType.description != null,"Array member class must have description"); }
+			// can defaultValue be INHERIT?
+			CONFIG::debug { assert(checkArrayTypes(defaultValue),"Array has bad defaultValue"); }
+		}
+		
+		/** The type the members of the array are required to be. */
+		public function get memberType():*
+		{ return _memberType; }
+		
+		protected function checkArrayTypes(val:Object):Boolean
+		{
+			if (val == null)
+				return true;
+			if (!(val is Array))
+				return false;
+			if (_memberType == null)
+				return true;
+			for each (var obj:Object in (val as Array))
+			{
+				if (!(obj is _memberType))
+					return false;
+			}
+			return true;
+		}
+		
+		/** @private */
+		public override function get defaultValue():*
+		{ return super.defaultValue == null ? null : (super.defaultValue as Array).slice();	}
+				
+		/** @private */
+		public override function setHelper(currVal:*,newVal:*):*
+		{
+			if (newVal === null)
+				newVal = undefined;
+			
+			if (newVal == undefined || newVal == FormatValue.INHERIT)
+				return newVal;
+
+			if (newVal is String)
+				newVal = this.valueFromString(String(newVal));
+			
+			if (!checkArrayTypes(newVal))
+			{
+				PropertyUtil.errorHandler(this,newVal);
+				return currVal;
+			}
+			return (newVal as Array).slice(); 
+		}
+
+		/** @private */
+		public override function concatInheritOnlyHelper(currVal:*,concatVal:*):*
+		{
+			return (inherited && currVal === undefined) || currVal == FormatValue.INHERIT ? ((concatVal is Array) ? (concatVal as Array).slice() : concatVal) : currVal;
+
+		}	
+		/** @private */
+		public override function concatHelper(currVal:*,concatVal:*):*
+		{
+			if (inherited)
+				return currVal === undefined || currVal == FormatValue.INHERIT ? ((concatVal is Array) ? (concatVal as Array).slice() : concatVal) : currVal;
+			if (currVal === undefined)
+				return defaultValue;
+			return currVal == FormatValue.INHERIT ? ((concatVal is Array) ? (concatVal as Array).slice() : concatVal) : currVal;
+
+		}	
+		/** @private */
+		public override function equalHelper(v1:*,v2:*):Boolean
+		{
+			if (_memberType != null)
+			{			
+				var v1Array:Array = v1 as Array;
+				var v2Array:Array = v2 as Array;
+		
+				if (v1Array && v2Array)
+				{			
+					if (v1Array.length == v2Array.length)
+					{
+						var desc:Object = _memberType.description;
+						for (var i:int=0; i < v1Array.length; ++i)
+						{
+							if (!PropertyUtil.equalAllHelper(desc, v1[i], v2[i]))
+								return false;
+						}
+						return true;
+					}
+				}
+			}
+			return v1 == v2;				
+		}
+		
+		/** @private */
+		public override function toXMLString(val:Object):String
+		{
+			if (val == FormatValue.INHERIT)
+				return String(val);
+			// TODO-7/7/2008-The XML format for array properties (as implemented below)
+			// is appropriate for what it is currently used, but can be ambiguous.
+			// For example, what if XML representations of contained elements contain the delimiters used here? 
+			 
+			// TODO: Check for description?
+			var desc:Object = _memberType.description;
+			var rslt:String = "";
+			var addSemi:Boolean = false;
+			for each (var member:Object in val)
+			{
+				if (addSemi)
+					rslt += "; ";
+				// export each element ',' separated
+				var addComma:Boolean = false;
+				for each (var prop:Property in desc)
+				{
+					var memberVal:Object = member[prop.name];
+					if (memberVal != null)
+					{
+						if (addComma)
+							rslt += ", ";
+						rslt += prop.name + ":" + prop.toXMLString(memberVal);
+						addComma = true;
+					}
+				}
+				addSemi = true;
+			}
+			return rslt;
+		}
+		
+		/** @private */
+		private function valueFromString(str:String):*
+		{ 	
+			// TODO-7/7/2008-The XML format for array properties can be ambiguous.
+			// See comment in toXMLString.
+			if ((str == null) || (str == "")) 
+				return null;
+			if (str == FormatValue.INHERIT)
+				return str;
+			var result:Array = new Array();
+			var desc:Object = _memberType.description;
+			
+			var attrsAll:Array = str.split('; '); 
+			for each (var attrs:String in attrsAll)
+			{
+			 	var obj:Object = new _memberType();	// NO PMD
+			 	
+			 	var attrsOne:Array = attrs.split(', ');
+			 	for each (var attr:String in attrsOne)
+			 	{
+			 		var nameValArr:Array = attr.split(':');
+			 		var propName:String = nameValArr[0];
+			 		var propVal:String = nameValArr[1];
+			 	
+				 	for each (var prop:Property in desc)
+				 	{
+				 		if (prop.name == propName)
+				 		{
+				 			obj[propName] = prop.setHelper(propVal,obj[propName]);
+				 			break;
+				 		}
+			 		}
+			 	}
+			 	result.push(obj);
+			}
+				
+			return result; 
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/BooleanPropertyHandler.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/BooleanPropertyHandler.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/BooleanPropertyHandler.as
new file mode 100644
index 0000000..a41e478
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/BooleanPropertyHandler.as
@@ -0,0 +1,43 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.property {
+
+		
+
+		
+	// [ExcludeClass]
+	/** A property description with a Boolean value. @private */
+	public class BooleanPropertyHandler extends PropertyHandler
+	{
+		override public function get className():String
+		{
+			return "BooleanPropertyHandler";
+		}
+		public override function owningHandlerCheck(newVal:*):*
+		{ 
+			if (newVal is Boolean)
+				return newVal;
+			
+			if (newVal == "true" || newVal == "false")
+				return newVal == "true";
+			
+			return undefined;	
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/CounterContentHandler.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/CounterContentHandler.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/CounterContentHandler.as
new file mode 100644
index 0000000..aca117e
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/CounterContentHandler.as
@@ -0,0 +1,214 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.property
+{
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.elements.ListElement;	
+	
+	// [ExcludeClass]
+	public class CounterContentHandler extends PropertyHandler
+	{
+		override public function get className():String
+		{
+			return "CounterContentHandler";
+		}
+		// check to see if this handler has a custom exporter that must be used when owningHandlerCheck is true
+		public override function get customXMLStringHandler():Boolean
+		{ return true; }
+		
+		public override function toXMLString(val:Object):String
+		{ 
+			if (val.hasOwnProperty("counter"))
+				return val.ordered == null ? "counter(ordered)" : "counter(ordered," + val.ordered + ")";
+			if (val.hasOwnProperty("counters"))
+			{
+				var rslt:String = "counters(ordered";
+				if (val.suffix != null)
+				{
+					rslt += ",\"" + val.suffix + "\"";
+					if (val.ordered)
+						rslt += "," + val.ordered;
+				}
+				rslt += ")";
+				return rslt;
+			}
+			return val.toString();
+		}
+		
+		/** matches counter(ordered) */
+		static private  const _counterContentPattern1:RegExp = /^\s*counter\s*\(\s*ordered\s*\)\s*$/;
+		/** matches counter(ordered,ListStyleType) */
+		static private  const _counterContentPattern2:RegExp = /^\s*counter\s*\(\s*ordered\s*,\s*\S+\s*\)\s*$/;
+		
+		/** matches counters(ordered) */
+		static private  const _countersContentPattern1:RegExp = /^\s*counters\s*\(\s*ordered\s*\)\s*$/;
+		/** matches counters(ordered,"suffix") */
+		static private  const _countersContentPattern2:RegExp = /^\s*counters\s*\(\s*ordered\s*,\s*".*"\s*\)\s*$/;
+		/** matches counters(ordered,"suffix",ListStyleType) */
+		static private  const _countersContentPattern3:RegExp = /^\s*counters\s*\(\s*ordered\s*,\s*".*"\s*,\s*\S+\s*\)\s*$/;
+		
+		// return a value if this handler "owns" this property - otherwise return undefined
+		public override function owningHandlerCheck(newVal:*):*
+		{ 
+			var listStyleType:String;
+			
+			// check for the more efficient parsed representation
+			if (!(newVal is String))
+				return newVal.hasOwnProperty("counter") || newVal.hasOwnProperty("counters") ? newVal : undefined;
+			
+			if (_counterContentPattern1.test(newVal))
+				return newVal;
+			
+			if (_counterContentPattern2.test(newVal))
+			{
+				// need to validate the specified listStyleType
+				listStyleType = extractListStyleTypeFromCounter(newVal);
+				return ListElement.listSuffixes[listStyleType] !== undefined ? newVal : undefined;
+			}
+			
+			if (_countersContentPattern1.test(newVal))
+				return newVal;
+			
+			if (_countersContentPattern2.test(newVal))
+				return newVal;
+			
+			if (_countersContentPattern3.test(newVal))
+			{
+				listStyleType = extractListStyleTypeFromCounters(newVal);
+				return ListElement.listSuffixes[listStyleType] !== undefined ? newVal : undefined;
+			}
+			
+			return undefined;
+		}
+		
+		static private const _counterBeginPattern:RegExp = /^\s*counter\s*\(\s*ordered\s*,\s*/g;
+		static private const _trailingStuff:RegExp = /\s*\)\s*/g;
+			
+		/** @private - from _counterContentPattern2  counters(ordered,"suffix") */
+		static public function extractListStyleTypeFromCounter(s:String):String
+		{
+			CONFIG::debug { assert(_counterContentPattern2.test(s),"Bad Parameter to extractListStyleTypeFromCounter"); }
+			_counterBeginPattern.lastIndex = 0;
+			_counterBeginPattern.test(s);
+			s = s.substr(_counterBeginPattern.lastIndex);
+
+			_trailingStuff.lastIndex = 0;
+			_trailingStuff.test(s);
+			s = s.substr(0,_trailingStuff.lastIndex-1);
+
+			return s;
+		}
+		
+		static private const _countersTillSuffixPattern:RegExp = /^\s*counters\s*\(\s*ordered\s*,\s*"/g;
+		static private const _afterSuffixPattern2:RegExp = /^"\s*\)\s*$/;
+
+		/** @private - from _countersContentPattern2  */
+		static public function extractSuffixFromCounters2(s:String):String
+		{
+			CONFIG::debug { assert(_countersContentPattern2.test(s),"Bad Parameter to extractListStyleTypeFromCounter2"); }
+			_countersTillSuffixPattern.lastIndex = 0;
+			_countersTillSuffixPattern.test(s);
+			s = s.substr(_countersTillSuffixPattern.lastIndex);
+			
+			var rslt:String = "";
+			while (!_afterSuffixPattern2.test(s))
+			{
+				rslt += s.substr(0,1);
+				s = s.substr(1);
+			}
+			
+			return rslt;
+		}	
+		
+		static private const _afterSuffixPattern3:RegExp = /^"\s*,\s*\S+\s*\)\s*$/;
+		
+		static public function extractSuffixFromCounters3(s:String):String
+		{
+			CONFIG::debug { assert(_countersContentPattern3.test(s),"Bad Parameter to extractListStyleTypeFromCounter2"); }
+			_countersTillSuffixPattern.lastIndex = 0;
+			_countersTillSuffixPattern.test(s);
+			s = s.substr(_countersTillSuffixPattern.lastIndex);
+			
+			var rslt:String = "";
+			while (!_afterSuffixPattern3.test(s))
+			{
+				rslt += s.substr(0,1);
+				s = s.substr(1);
+			}
+			
+			return rslt;
+		}
+		
+		static private const _countersTillListStyleTypePattern:RegExp = /^\s*counters\s*\(\s*ordered\s*,\s*".*"\s*,\s*/g;
+		
+		/** @private - from _countersContentPattern2 */
+		static public function extractListStyleTypeFromCounters(s:String):String
+		{
+			CONFIG::debug { assert(_countersContentPattern3.test(s),"Bad Parameter to extractListStyleTypeFromCounter"); }
+			_countersTillListStyleTypePattern.lastIndex = 0;
+			_countersTillListStyleTypePattern.test(s);
+			s = s.substr(_countersTillListStyleTypePattern.lastIndex);
+			
+			_trailingStuff.lastIndex = 0;
+			_trailingStuff.test(s);
+			s = s.substr(0,_trailingStuff.lastIndex-1);
+			
+			return s;
+		}
+			
+		/** parse the input string and create a valid input value */
+		public override function setHelper(newVal:*):*
+		{ 
+			var s:String = newVal as String;
+			
+			var listStyleType:String;
+			var suffix:String;
+			
+			if (s == null)
+				return newVal;	// assume its an object that's been parsed already
+			
+			if (_counterContentPattern1.test(newVal))
+				return { counter:"ordered" }; 
+
+			if (_counterContentPattern2.test(newVal))
+			{
+				listStyleType = extractListStyleTypeFromCounter(newVal);
+				return { counter:"ordered", ordered:listStyleType };
+			}
+			
+			if (_countersContentPattern1.test(newVal))
+				return { counters:"ordered" }; 
+			
+			if (_countersContentPattern2.test(newVal))
+			{
+				suffix = extractSuffixFromCounters2(newVal);
+				return { counters:"ordered", suffix:suffix }; 
+			}
+			
+			if (_countersContentPattern3.test(newVal))
+			{
+				listStyleType = extractListStyleTypeFromCounters(newVal);
+				suffix = extractSuffixFromCounters3(newVal);
+				return { counters:"ordered", suffix:suffix, ordered:listStyleType };
+			}
+			
+			return undefined;
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/CounterPropHandler.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/CounterPropHandler.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/CounterPropHandler.as
new file mode 100644
index 0000000..c5c5fe7
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/CounterPropHandler.as
@@ -0,0 +1,65 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.property
+{
+	// [ExcludeClass]
+	public class CounterPropHandler extends PropertyHandler
+	{
+		override public function get className():String
+		{
+			return "CounterPropHandler";
+		}
+		private var _defaultNumber:int;
+		
+		public function CounterPropHandler(defaultNumber:int)
+		{ _defaultNumber = defaultNumber; }
+		
+		public function get defaultNumber():int
+		{ return _defaultNumber; }
+		
+		// check to see if this handler has a custom exporter that must be used when owningHandlerCheck is true
+		public override function get customXMLStringHandler():Boolean
+		{ return true; }
+		
+		public override function toXMLString(val:Object):String
+		{ return val["ordered"] == 1 ? "ordered" : "ordered " + val["ordered"]; }
+		
+		static private  const _orderedPattern:RegExp = /^\s*ordered(\s+-?\d+){0,1}\s*$/;
+		
+		// return a value if this handler "owns" this property - otherwise return undefined
+		public override function owningHandlerCheck(newVal:*):*
+		{ return newVal is String && _orderedPattern.test(newVal) || newVal.hasOwnProperty("ordered") ? newVal : undefined; }
+		
+		static private const _orderedBeginPattern:RegExp = /^\s*ordered\s*/g;
+		
+		// returns a new val based on - assumes owningHandlerCheck(newval) is true
+		public override function setHelper(newVal:*):*
+		{ 
+			var s:String = newVal as String;
+			if (s == null)
+				return newVal;	// assume its an object that's been parsed already
+
+			_orderedBeginPattern.lastIndex = 0;
+			_orderedBeginPattern.test(s);
+			var number:int = (_orderedBeginPattern.lastIndex != s.length) ? parseInt(s.substr(_orderedBeginPattern.lastIndex)) : _defaultNumber; 
+				
+			return { ordered:number }; 
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/EnumPropertyHandler.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/EnumPropertyHandler.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/EnumPropertyHandler.as
new file mode 100644
index 0000000..6b8fb21
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/EnumPropertyHandler.as
@@ -0,0 +1,49 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.property {
+		
+	// [ExcludeClass]
+	/** An property description with an enumerated string as its value. @private */
+	public class EnumPropertyHandler extends PropertyHandler
+	{
+		override public function get className():String
+		{
+			return "EnumPropertyHandler";
+		}
+		private var _range:Object;
+		
+		public function EnumPropertyHandler(propArray:Array)
+		{
+			_range = PropertyHandler.createRange(propArray);
+		}
+
+		
+		/** Returns object whose properties are the legal enum values */
+		public function get range():Object
+		{
+			return PropertyUtil.shallowCopy(_range); 
+		}		
+		
+		/** @private */
+		public override function owningHandlerCheck(newVal:*):*
+		{ 
+			return _range.hasOwnProperty(newVal) ? newVal : undefined;
+		}	
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/FormatPropertyHandler.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/FormatPropertyHandler.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/FormatPropertyHandler.as
new file mode 100644
index 0000000..3d4eb06
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/FormatPropertyHandler.as
@@ -0,0 +1,45 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.property
+{
+	
+	// [ExcludeClass]
+	public class FormatPropertyHandler extends PropertyHandler
+	{
+		override public function get className():String
+		{
+			return "FormatPropertyHandler";
+		}
+		private var _converter:Function;
+		
+		public function get converter():Function
+		{ return _converter; }
+		
+		public function set converter(val:Function):void
+		{ _converter = val; }
+
+		/** Attempts to handle Object as key value pairs - strings fail */
+		public override function owningHandlerCheck(newVal:*):*
+		{ return newVal is String ? undefined : newVal; }
+				
+		public override function setHelper(newVal:*):*
+		{ return _converter(newVal); }
+	}
+}
+

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/IntPropertyHandler.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/IntPropertyHandler.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/IntPropertyHandler.as
new file mode 100644
index 0000000..046e98d
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/IntPropertyHandler.as
@@ -0,0 +1,76 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.property
+{
+
+		
+
+
+	// [ExcludeClass]
+	/** A property description with a Number as its value. @private */
+	public class IntPropertyHandler extends PropertyHandler
+	{
+		override public function get className():String
+		{
+			return "IntPropertyHandler";
+		}
+		private const ALL_LIMITS:String = "allLimits";
+		private const LOWER_LIMIT:String ="lowerLimit";
+		private const UPPER_LIMIT:String = "upperLimit";
+		private var _minValue:int;
+		private var _maxValue:int;
+		private var _limits:String;
+		
+		public function IntPropertyHandler(minValue:int,maxValue:int,limits:String = ALL_LIMITS)
+		{
+			_minValue = minValue;
+			_maxValue = maxValue;
+			_limits = limits;
+		}
+		
+		override public function get minValue():Number
+		{ return _minValue; }
+		override public function get maxValue():Number
+		{ return _maxValue; } 
+
+		/** not yet enabled.  @private */
+		public function checkLowerLimit():Boolean
+		{ return _limits == ALL_LIMITS || _limits == LOWER_LIMIT; }
+		
+		/** not yet enabled.  @private */
+		public function checkUpperLimit():Boolean
+		{ return _limits == ALL_LIMITS || _limits == UPPER_LIMIT; }	
+		
+		// return true if this handler can "own" this property
+		public override function owningHandlerCheck(newVal:*):*
+		{			
+			var newNumber:Number = newVal is String ? parseInt(newVal) : int(newVal);
+			if (isNaN(newNumber))
+				return undefined;
+
+			var newInt:int = int(newNumber);
+			if (checkLowerLimit() && newInt < _minValue)
+				return undefined;
+			if (checkUpperLimit() && newInt > _maxValue)
+				return undefined;
+			return newInt;	
+		}
+				
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/NumberPropertyHandler.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/NumberPropertyHandler.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/NumberPropertyHandler.as
new file mode 100644
index 0000000..5d08142
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/NumberPropertyHandler.as
@@ -0,0 +1,81 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.property {
+
+		
+
+
+	// [ExcludeClass]
+	/** A property description with a Number as its value. @private */
+	public class NumberPropertyHandler extends PropertyHandler
+	{
+		override public function get className():String
+		{
+			return "NumberPropertyHandler";
+		}
+		private const ALL_LIMITS:String = "allLimits";
+		private const LOWER_LIMIT:String ="lowerLimit";
+		private const UPPER_LIMIT:String = "upperLimit";
+		private var _minValue:Number;
+		private var _maxValue:Number;
+		private var _limits:String;
+		
+		public function NumberPropertyHandler(minValue:Number,maxValue:Number,limits:String = ALL_LIMITS)
+		{
+			_minValue = minValue;
+			_maxValue = maxValue;
+			_limits = limits;
+		}
+		
+		override public function get minValue():Number
+		{ return _minValue; }
+		override public function get maxValue():Number
+		{ return _maxValue; } 
+
+		/** not yet enabled.  @private */
+		public function checkLowerLimit():Boolean
+		{ return _limits == ALL_LIMITS || _limits == LOWER_LIMIT; }
+		
+		/** not yet enabled.  @private */
+		public function checkUpperLimit():Boolean
+		{ return _limits == ALL_LIMITS || _limits == UPPER_LIMIT; }	
+		
+		// return true if this handler can "own" this property
+		public override function owningHandlerCheck(newVal:*):*
+		{			
+			var newNumber:Number = newVal is String ? parseFloat(newVal) : Number(newVal);
+			if (isNaN(newNumber))
+				return undefined;
+			if (checkLowerLimit() && newNumber < _minValue)
+				return undefined;
+			if (checkUpperLimit() && newNumber > _maxValue)
+				return undefined;
+			return newNumber;	
+		}
+
+		public function clampToRange(val:Number):Number
+		{
+			if (checkLowerLimit() && val < _minValue)
+				return _minValue;
+			if (checkUpperLimit() && val > _maxValue)
+				return _maxValue;
+			return val;			
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/PercentPropertyHandler.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/PercentPropertyHandler.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/PercentPropertyHandler.as
new file mode 100644
index 0000000..d348a85
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/PercentPropertyHandler.as
@@ -0,0 +1,72 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.property {
+
+		
+
+	
+	// [ExcludeClass]
+	/** A property description with a Number or a Percent as its value. @private */
+	public class PercentPropertyHandler extends PropertyHandler
+	{
+		override public function get className():String
+		{
+			return "PercentPropertyHandler";
+		}
+		private const ALL_LIMITS:String = "allLimits";
+		private const LOWER_LIMIT:String ="lowerLimit";
+		private const UPPER_LIMIT:String = "upperLimit";
+		private var _minValue:Number;
+		private var _maxValue:Number;
+		private var _limits:String;
+		
+		public function PercentPropertyHandler(minValue:String,maxValue:String,limits:String = ALL_LIMITS)
+		{
+			_minValue = PropertyUtil.toNumberIfPercent(minValue);
+			_maxValue = PropertyUtil.toNumberIfPercent(maxValue);
+			_limits = limits;
+		}
+
+		override public function get minValue():Number
+		{ return _minValue; }
+		override public function get maxValue():Number
+		{ return _maxValue; } 
+
+		/** not yet enabled.  @private */
+		public function checkLowerLimit():Boolean
+		{ return _limits == ALL_LIMITS || _limits == LOWER_LIMIT; }
+		
+		/** not yet enabled.  @private */
+		public function checkUpperLimit():Boolean
+		{ return _limits == ALL_LIMITS || _limits == UPPER_LIMIT; }	
+		
+		// return true if this handler can "own" this property
+		public override function owningHandlerCheck(newVal:*):*
+		{			
+			var newNumber:Number = PropertyUtil.toNumberIfPercent(newVal);
+			if (isNaN(newNumber))
+				return undefined;
+			if (checkLowerLimit() && newNumber < _minValue)
+				return undefined;
+			if (checkUpperLimit() && newNumber > _maxValue)
+				return undefined;
+			return newVal;
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/PropConst.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/PropConst.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/PropConst.as
new file mode 100644
index 0000000..415898f
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/PropConst.as
@@ -0,0 +1,24 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.property
+{
+	public class PropConst
+	{
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/Property.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/Property.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/Property.as
new file mode 100644
index 0000000..fdeef86
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/Property.as
@@ -0,0 +1,181 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.property
+{
+	import org.apache.flex.textLayout.elements.GlobalSettings;
+	import org.apache.flex.textLayout.formats.FormatValue;
+		
+	// [ExcludeClass]
+	/** Base class of property metadata.  Each property in the various TextLayout attributes structures has a metadata singletion Property class instance.  The instance
+	 * can be used to process the property to and from xml, find out range information and help with the attribute cascade.  The Property class also contains static functions
+	 * for processing all the properties collected in a TextLayout Format object. @private  */
+	public class Property
+	{		
+		
+	
+		// storing name here is redundant but is more efficient 
+		private var _name:String;
+		private var _default:*;
+		private var _inherited:Boolean;
+		private var _categories:Vector.<String>;
+		private var _hasCustomExporterHandler:Boolean;
+		private var _numberPropertyHandler:Object;
+		
+		protected var _handlers:Vector.<PropertyHandler>;
+		
+		/** Initializer.  Each property has a name and a default. */
+		public function Property(nameValue:String,defaultValue:*,inherited:Boolean,categories:Vector.<String>)
+		{ 
+			_name = nameValue;
+			_default = defaultValue;
+			_inherited = inherited;
+			_categories = categories;
+			_hasCustomExporterHandler = false;
+		}
+		
+		/** The name of the property */
+		public function get name():String
+		{ return _name; }
+		
+		/** The default value of this property */
+		public function get defaultValue():*
+		{ return _default; }
+		
+		/** Is this property inherited */
+		public function get inherited():Object
+		{ return _inherited; }
+		
+		/** First listed Category of this property. This is the legacy category from when Properties could only be in one category.  */
+		public function get category():String
+		{ return _categories[0]; }
+		
+		/** Return the list of categories */
+		public function get categories():Vector.<String>
+		{ return _categories; }
+				
+		public function addHandlers(... rest):void
+		{
+			_handlers = new Vector.<PropertyHandler>(rest.length,true);
+			for (var idx:int = 0; idx < rest.length; idx++)
+			{
+				var handler:PropertyHandler = rest[idx];
+				_handlers[idx] = handler;
+				if (handler.customXMLStringHandler)
+					_hasCustomExporterHandler = true;
+				if (handler.className == "NumberPropertyHandler")
+					_numberPropertyHandler = handler;
+			}
+		}
+		
+		public function findHandler(handlerClass:String):PropertyHandler
+		{
+			for each (var prop:PropertyHandler in _handlers)
+			{
+				if (prop.className == handlerClass)
+					return prop;
+			}
+			return null;
+		}
+
+		/** Helper function when setting the property */
+		public function setHelper(currVal:*,newVal:*):*
+		{
+			for each (var handler:PropertyHandler in _handlers)
+			{
+				var checkRslt:* = handler.owningHandlerCheck(newVal);
+				if (checkRslt !== undefined)
+					return handler.setHelper(checkRslt);
+			}
+			
+			PropertyUtil.errorHandler(this,newVal);
+			return currVal;	
+		}
+				
+		/** Helper function when merging the property to compute actual attributes */
+		public function concatInheritOnlyHelper(currVal:*,concatVal:*):*
+		{ return (_inherited && currVal === undefined) || currVal == FormatValue.INHERIT ? concatVal : currVal; }
+
+		/** Helper function when merging the property to compute actual attributes */
+		public function concatHelper(currVal:*,concatVal:*):*
+		{
+			if (_inherited)
+				return currVal === undefined || currVal == FormatValue.INHERIT ? concatVal : currVal;
+			if (currVal === undefined)
+				return defaultValue;
+			return currVal == FormatValue.INHERIT ? concatVal : currVal;
+		}
+		
+		/** Helper function when comparing the property */
+		public function equalHelper(v1:*,v2:*):Boolean
+		{ return v1 == v2; }
+		
+		/** Convert the value of this property to a string appropriate for XML export */
+		public function toXMLString(val:Object):String
+		{
+			if (_hasCustomExporterHandler)
+			{
+				for each (var prop:PropertyHandler in _handlers)
+				{
+					if (prop.customXMLStringHandler && prop.owningHandlerCheck(val) !== undefined)
+						return prop.toXMLString(val);
+				}				
+			}
+			return val.toString();
+		}
+		
+		public function get maxPercentValue():Number
+		{
+			var handler:PropertyHandler = findHandler("PercentPropertyHandler");
+			return handler ? handler.maxValue : NaN;
+		}
+		public function get minPercentValue():Number
+		{
+			var handler:PropertyHandler = findHandler("PercentPropertyHandler");
+			return handler ? handler.minValue : NaN;
+		}
+		public function get minValue():Number
+		{
+			var numberHandler:PropertyHandler = findHandler("NumberPropertyHandler");
+			if (numberHandler)
+				return numberHandler.minValue;
+			var intHandler:PropertyHandler = findHandler("IntPropertyHandler");
+			return intHandler ? intHandler.minValue : NaN;
+		}
+		public function get maxValue():Number
+		{
+			var numberHandler:PropertyHandler = findHandler("NumberPropertyHandler");
+			if (numberHandler)
+				return numberHandler.maxValue;
+			var intHandler:PropertyHandler = findHandler("IntPropertyHandler");
+			return intHandler ? intHandler.maxValue : NaN;
+		}
+		
+		public function computeActualPropertyValue(propertyValue:Object,percentInput:Number):Number
+		{				
+			var percent:Number = PropertyUtil.toNumberIfPercent(propertyValue);
+			if (isNaN(percent))
+				return Number(propertyValue);
+			
+			// its a percent - calculate and clamp
+			var rslt:Number =  percentInput * (percent / 100);
+			return _numberPropertyHandler ? _numberPropertyHandler.clampToRange(rslt) : rslt;
+		}
+
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/PropertyFactory.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/PropertyFactory.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/PropertyFactory.as
new file mode 100644
index 0000000..36904fc
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/PropertyFactory.as
@@ -0,0 +1,133 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.property {
+	import org.apache.flex.textLayout.formats.FormatValue;
+	public class PropertyFactory {
+		// shared propertyHandler instances
+		/** @private */
+		public static const sharedStringHandler:StringPropertyHandler = new StringPropertyHandler();
+		/** @private */
+		public static const sharedInheritEnumHandler:EnumPropertyHandler = new EnumPropertyHandler([ FormatValue.INHERIT ]);
+		/** @private */
+		public static const sharedUndefinedHandler:UndefinedPropertyHandler = new UndefinedPropertyHandler();
+		/** @private */
+		public static const sharedUintHandler:UintPropertyHandler = new UintPropertyHandler();
+		/** @private */
+		public static const sharedBooleanHandler:BooleanPropertyHandler = new BooleanPropertyHandler();
+		
+		/** @private */
+		public static const sharedTextLayoutFormatHandler:FormatPropertyHandler = new FormatPropertyHandler();
+		/** @private */
+		public static const sharedListMarkerFormatHandler:FormatPropertyHandler = new FormatPropertyHandler();
+		
+		public static function bool(nameValue:String, defaultValue:Boolean, inherited:Boolean, categories:Vector.<String>):Property
+		{			
+			var rslt:Property = new Property(nameValue, defaultValue, inherited, categories);
+			rslt.addHandlers(sharedUndefinedHandler,sharedBooleanHandler,sharedInheritEnumHandler);
+			return rslt;
+		}
+		
+		public static function string(nameValue:String, defaultValue:String, inherited:Boolean, categories:Vector.<String>):Property
+		{
+			var rslt:Property = new Property(nameValue, defaultValue, inherited, categories);
+			rslt.addHandlers(sharedUndefinedHandler,sharedStringHandler);
+			return rslt;			
+		}
+		public static function uintProp(nameValue:String, defaultValue:uint, inherited:Boolean, categories:Vector.<String>):Property
+		{
+			var rslt:Property = new Property(nameValue, defaultValue, inherited, categories);
+			rslt.addHandlers(sharedUndefinedHandler,sharedUintHandler,sharedInheritEnumHandler);
+			return rslt;
+		}
+
+		public static function enumString(nameValue:String, defaultValue:String, inherited:Boolean, categories:Vector.<String>, ... rest):Property
+		{
+			var rslt:Property = new Property(nameValue, defaultValue, inherited, categories);
+			rslt.addHandlers(sharedUndefinedHandler,new EnumPropertyHandler(rest),sharedInheritEnumHandler);
+			return rslt;
+		}
+		
+		public static function intOrEnum(nameValue:String, defaultValue:Object, inherited:Boolean, categories:Vector.<String>, minValue:int, maxValue:int, ... rest):Property
+		{		
+			var rslt:Property = new Property(nameValue, defaultValue, inherited, categories);
+			rslt.addHandlers(sharedUndefinedHandler,new EnumPropertyHandler(rest),new IntPropertyHandler(minValue,maxValue),sharedInheritEnumHandler);
+			return rslt;
+		}
+		
+		public static function uintOrEnum(nameValue:String, defaultValue:Object, inherited:Boolean, categories:Vector.<String>,  ... rest):Property
+		{			
+			var rslt:Property = new Property(nameValue, defaultValue, inherited, categories);
+			rslt.addHandlers(sharedUndefinedHandler,new EnumPropertyHandler(rest),sharedUintHandler,sharedInheritEnumHandler);
+			return rslt;
+		}
+
+		public static function number(nameValue:String, defaultValue:Number, inherited:Boolean, categories:Vector.<String>, minValue:Number, maxValue:Number):Property
+		{
+			var rslt:Property = new Property(nameValue, defaultValue, inherited, categories);
+			rslt.addHandlers(sharedUndefinedHandler,new NumberPropertyHandler(minValue,maxValue),sharedInheritEnumHandler);
+			return rslt;
+		}
+		public static function 	numPercentEnum(nameValue:String, defaultValue:Object, inherited:Boolean, categories:Vector.<String>, minValue:Number, maxValue:Number, minPercentValue:String, maxPercentValue:String, ... rest):Property
+		{
+			var rslt:Property = new Property(nameValue, defaultValue, inherited, categories);
+			rslt.addHandlers(sharedUndefinedHandler,new EnumPropertyHandler(rest),new PercentPropertyHandler(minPercentValue,maxPercentValue),new NumberPropertyHandler(minValue,maxValue),sharedInheritEnumHandler);
+			return rslt;
+		}
+		public static function numPercent(nameValue:String, defaultValue:Object, inherited:Boolean, categories:Vector.<String>, minValue:Number, maxValue:Number, minPercentValue:String, maxPercentValue:String):Property
+		{			
+			var rslt:Property = new Property(nameValue, defaultValue, inherited, categories);
+			rslt.addHandlers(sharedUndefinedHandler,new PercentPropertyHandler(minPercentValue,maxPercentValue),new NumberPropertyHandler(minValue,maxValue),sharedInheritEnumHandler);
+			return rslt;
+		}
+		public static function numEnum(nameValue:String, defaultValue:Object, inherited:Boolean, categories:Vector.<String>, minValue:Number, maxValue:Number, ... rest):Property
+		{			
+			var rslt:Property = new Property(nameValue, defaultValue, inherited, categories);
+			rslt.addHandlers(sharedUndefinedHandler,new EnumPropertyHandler(rest),new NumberPropertyHandler(minValue,maxValue),sharedInheritEnumHandler);
+			return rslt;
+		}
+		public static function tabStopsProp(nameValue:String, defaultValue:Array, inherited:Boolean, categories:Vector.<String>):Property
+		{
+			return new TabStopsProperty(nameValue,defaultValue,inherited,categories);
+		}
+		public static function spacingLimitProp(nameValue:String, defaultValue:Object, inherited:Boolean, categories:Vector.<String>, minPercentValue:String, maxPercentValue:String):Property
+		{
+			var rslt:Property = new Property(nameValue,defaultValue,inherited,categories);
+			rslt.addHandlers(sharedUndefinedHandler, new SpacingLimitPropertyHandler(minPercentValue, maxPercentValue), sharedInheritEnumHandler);
+			return rslt;
+		}
+		
+		private static const undefinedValue:* = undefined;
+		
+		public static function tlfProp(nameValue:String, defaultValue:Object, inherited:Boolean, categories:Vector.<String>):Property
+		{
+			// passing undefined as a value seems to confuse the compiler
+			var rslt:Property = new Property(nameValue, undefinedValue, inherited, categories);
+			rslt.addHandlers(sharedUndefinedHandler,sharedTextLayoutFormatHandler,sharedInheritEnumHandler);
+			return rslt;
+		}
+		public static function listMarkerFormatProp(nameValue:String, defaultValue:Object, inherited:Boolean, categories:Vector.<String>):Property
+		{
+			// passing undefined as a value seems to confuse the compiler
+			var rslt:Property = new Property(nameValue, undefinedValue, inherited, categories);
+			rslt.addHandlers(sharedUndefinedHandler,sharedListMarkerFormatHandler,sharedInheritEnumHandler);
+			return rslt;
+		}		
+	
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/PropertyHandler.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/PropertyHandler.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/PropertyHandler.as
new file mode 100644
index 0000000..284377c
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/property/PropertyHandler.as
@@ -0,0 +1,63 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.property
+{
+	// [ExcludeClass]
+	public class PropertyHandler
+	{
+		public static function createRange(rest:Array):Object
+		{
+			var range:Object = {};
+			// rest is the list of possible values
+			for (var i:int = 0; i < rest.length; i++)
+				range[rest[i]] = null;
+			return range;
+		}
+		public function get className():String
+		{
+			return "PropertyHandler";
+		}
+		
+		// check to see if this handler has a custom exporter that must be used when owningHandlerCheck is true
+		public function get customXMLStringHandler():Boolean
+		{ return false; }
+	
+		public function toXMLString(val:Object):String	// No PMD
+		{ return null; }
+
+		// return a value if this handler "owns" this property - otherwise return undefined
+		public function owningHandlerCheck(newVal:*):*	// No PMD
+		{ return undefined; }
+		
+			
+		// returns a new val based on - assumes owningHandlerCheck(newval) is true
+		public function setHelper(newVal:*):*
+		{ return newVal; }
+
+		public function get maxValue():Number
+		{
+			return NaN;
+		}
+		public function get minValue():Number
+		{
+			return NaN;
+		}
+	}
+
+}


[29/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ImportExportConfiguration.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ImportExportConfiguration.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ImportExportConfiguration.as
new file mode 100644
index 0000000..84d328c
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ImportExportConfiguration.as
@@ -0,0 +1,125 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion
+{
+
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.formats.WhiteSpaceCollapse;
+
+
+
+	/** 
+	 * Configure for import/export of standard components.
+	 * Configures the import/export package so it can export all the standard FlowElements.
+	 *  
+	 * @see org.apache.flex.textLayout.elements.Configuration
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	public class ImportExportConfiguration 
+	{
+		/** 
+		 * array of FlowElementInfo objects (key = name, value = FlowElementInfo) 
+		 * */	
+		public var flowElementInfoList:Object = {};	
+		public var flowElementClassList:Object= {};	
+		public var classToNameMap:Object = {};
+		
+		/**
+		 * Whitespace collapse export setting
+		 * @default WhiteSpaceCollapse.PRESERVE
+		 **/
+		public var whiteSpaceCollapse:String = WhiteSpaceCollapse.PRESERVE;
+
+		/** 
+		 * Constructor.
+		 * 
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0
+		 */
+		public function ImportExportConfiguration()
+		{
+		}
+		
+		/** 
+		 * Add a parser for a new FlowElement type. This allows FlowElements to be added from outside the main system,
+		 * and still have the main system be able to import them from XML.
+		 * 
+		 * @param name		the name of the FlowElement class, as it appear in the XML
+		 * @param flowClass	the class of the FlowElement
+		 * @param parser	function fpr importing the XML into a FlowElement
+		 * @param exporter  function for exporting a FlowElement into XML
+		 * @private
+		 */
+		public function addIEInfo(name:String, flowClass:Class, parser:Function, exporter:Function):void
+		{
+			var info:FlowElementInfo = new FlowElementInfo(flowClass, parser, exporter);
+			if (name)
+			{
+				CONFIG::debug { assert (lookup(name) == null, "FlowElementInfo already exists");}
+				flowElementInfoList[name] = info;
+			}
+			if (flowClass)
+			{
+				CONFIG::debug { assert (lookupByClass(info.flowClassName) == null, "FlowElementInfo already exists");}
+				flowElementClassList[info.flowClassName] = info;				
+			}
+			if (name && flowClass)
+				classToNameMap[info.flowClassName] = name;
+		}
+		
+		/** 
+		 * Return the information being held about the FlowElement, as a FlowElementInfo.
+		 * 
+		 * @param name				the name of the FlowElement class, as it appears in the XML
+		 * @return FlowElementInfo	the information being held, as it was supplied to addParseInfo
+		 * @private
+		 */
+		public function lookup(name:String):FlowElementInfo
+		{
+			return flowElementInfoList[name];
+		}
+
+		/** 
+		 * Return the element name for the class
+		 * 
+		 * @param classToMatch		fully qualified class name of the FlowElement
+		 * @return name				export name to use for class
+		 * @private
+		 */
+		public function lookupName(classToMatch:String):String
+		{
+			return classToNameMap[classToMatch];
+		}
+
+		/** 
+		 * Return the information being held about the FlowElement, as a FlowElementInfo.
+		 * 
+		 * @param classToMatch		fully qualified class name of the FlowElement
+		 * @return FlowElementInfo	the information being held, as it was supplied to addParseInfo
+		 * @private
+		 */
+		public function lookupByClass(classToMatch:String):FlowElementInfo
+		{
+			return flowElementClassList[classToMatch];
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/PlainTextExporter.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/PlainTextExporter.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/PlainTextExporter.as
new file mode 100644
index 0000000..a746cfd
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/PlainTextExporter.as
@@ -0,0 +1,142 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion
+{
+	import org.apache.flex.textLayout.elements.IFlowLeafElement;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+
+	
+
+	
+	/** 
+	 * Export converter for plain text format. This class provides an alternative to
+	 * the <code>TextConverter.export()</code> static method for exporting plain text.
+	 *  The PlainTextExporter class's <code>export()</code> method results in the 
+	 * same output string as the <code>TextConverter.export()</code> static method 
+	 * if the two properties of the PlainTextExporter class, the <code>PARAGRAPH_SEPARATOR_PROPERTY</code>
+	 * and the <code>STRIP_DISCRETIONARY_HYPHENS_PROPERTY</code> properties, contain their
+	 * default values of <code>"\n"</code> and <code>true</code>, respectively.
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	public class PlainTextExporter extends ConverterBase implements IPlainTextExporter	
+	{
+		private var _stripDiscretionaryHyphens:Boolean;
+		private var _paragraphSeparator:String;
+		
+		static private var _discretionaryHyphen:String = String.fromCharCode(0x00AD);
+		
+
+		
+		/**
+		 * Constructor 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+
+		public function PlainTextExporter()
+		{
+			_stripDiscretionaryHyphens = true;
+			_paragraphSeparator = "\n";
+		}
+		 
+		/** @copy IPlainTextExporter#stripDiscretionaryHyphens
+  		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0-
+		 */
+		public function get stripDiscretionaryHyphens():Boolean
+		{ return _stripDiscretionaryHyphens; }
+		public function set stripDiscretionaryHyphens(value:Boolean):void
+		{ _stripDiscretionaryHyphens = value; }
+
+		/** @copy IPlainTextExporter#paragraphSeparator
+ 		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get paragraphSeparator():String
+		{ return _paragraphSeparator; }
+		public function set paragraphSeparator(value:String):void
+		{ _paragraphSeparator = value; }
+
+		/** @copy ITextExporter#export()
+		 */
+		public function export(source:ITextFlow, conversionType:String):Object
+		{
+			clear();
+			if (conversionType == ConversionType.STRING_TYPE)
+				return exportToString(source);
+			return null;
+		}
+		
+		/** Export text content as a string
+		 * @param source	the text to export
+		 * @return String	the exported content
+		 * 
+  		 * @private
+		 */
+		protected function exportToString(source:ITextFlow):String
+		{
+			var rslt:String = "";
+			var leaf:IFlowLeafElement = source.getFirstLeaf(); 
+			
+			while (leaf)
+			{
+            	var p:IParagraphElement = leaf.getParagraph();
+            	while (true)
+            	{
+            		var curString:String = leaf.text;
+            		
+            		//split out discretionary hyphen and put string back together
+            		if (_stripDiscretionaryHyphens)
+            		{
+						var temparray:Array = curString.split(_discretionaryHyphen);
+						curString = temparray.join("");
+            		}
+					
+	               	rslt += curString;
+					var nextLeaf:IFlowLeafElement = leaf.getNextLeaf(p);
+					if (!nextLeaf)
+						break; // end of para
+					
+					leaf = nextLeaf;
+            	}
+            	
+            	leaf = leaf.getNextLeaf();
+            	if (leaf) // not the last para
+                   	rslt += _paragraphSeparator; 
+   			}
+			
+			if (useClipboardAnnotations)
+			{
+				// Append a final paragraph separator if the last paragraph is not marked as a partial element
+				var lastPara:IParagraphElement = source.getLastLeaf().getParagraph();
+				if (lastPara.getStyle(ConversionConstants.MERGE_TO_NEXT_ON_PASTE) != "true")
+					rslt += _paragraphSeparator;
+				
+			}
+   			return rslt;
+		}
+	}
+		
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/PlainTextImporter.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/PlainTextImporter.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/PlainTextImporter.as
new file mode 100644
index 0000000..b98c43d
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/PlainTextImporter.as
@@ -0,0 +1,116 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion {
+	import org.apache.flex.textLayout.factory.TLFFactory;
+	import org.apache.flex.textLayout.elements.IFlowLeafElement;
+	import org.apache.flex.textLayout.elements.IConfiguration;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.ISpanElement;
+	import org.apache.flex.textLayout.elements.TextFlow;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.textLayout.elements.ElementHelper;
+
+
+	// import container.TextFrame;
+	
+
+
+	// [ExcludeClass]
+	/** 
+	 * @private
+	 * PlainText import converter. Use this to import simple unformatted Unicode text.
+	 * Newlines will be converted to paragraphs. Using the PlainTextImporter directly
+	 * is equivalent to calling TextConverter.importToFlow(TextConverter.PLAIN_TEXT_FORMAT).
+	 */
+	internal class PlainTextImporter extends ConverterBase implements ITextImporter
+	{
+		protected var _config:IConfiguration = null;
+		
+		/** Constructor */
+		public function PlainTextImporter()
+		{
+		}
+		
+		/** @copy ITextImporter#importToFlow()
+		 */
+		public function importToFlow(source:Object):ITextFlow
+		{
+			if (source is String)
+				return importFromString(String(source));
+			return null;
+		}
+		
+		/**
+		 * The <code>configuration</code> property contains the IConfiguration instance that
+		 * the importerd needs when creating new ITextFlow instances. This property
+		 * is initially set to <code>null</code>.
+		 * @see ITextFlow constructor
+		 * @playerversion Flash 10.2
+		 * @playerversion AIR 2.0
+		 * @langversion 3.0
+		 */
+		public function get configuration():IConfiguration
+		{
+			return _config;
+		}
+		
+		public function set configuration(value:IConfiguration):void
+		{
+			_config = value;
+		}
+		
+		
+		// LF or CR or CR+LF. Equivalently, LF or CR, the latter optionally followed by LF
+//TODO regex
+		private static const _newLineRegex:RegExp = /foo/;// /\u000A|\u000D\u000A?/g;
+		// private static const _newLineRegex:RegExp = /\u000A|\u000D\u000A?/g;
+		
+		/** Import text content, from an external source, and convert it into a ITextFlow.
+		 * @param source		source data to convert
+		 * @return textFlows[]	an array of ITextFlow objects that were created from the source.
+		 */
+		protected function importFromString(source:String):ITextFlow
+		{
+			var paragraphStrings:Array = source.split(_newLineRegex);
+
+			var textFlow:ITextFlow = new TextFlow(TLFFactory.defaultTLFFactory,_config);
+			var paraText:String;
+			for each (paraText in paragraphStrings)
+			{
+				var paragraph:IParagraphElement  = ElementHelper.getParagraph();	// No PMD
+				var span:ISpanElement = ElementHelper.getSpan();	// No PMD
+				span.replaceText(0, 0, paraText);
+				paragraph.replaceChildren(0, 0, span);			
+				textFlow.replaceChildren(textFlow.numChildren, textFlow.numChildren, paragraph);
+			}
+
+			// Mark partial last paragraph (string doesn't end in paragraph terminator)
+			if (useClipboardAnnotations && 
+				source.lastIndexOf('\u000A', source.length - 1) != source.length - 1)
+			{
+				var lastLeaf:IFlowLeafElement = textFlow.getLastLeaf();
+				lastLeaf.setStyle(ConversionConstants.MERGE_TO_NEXT_ON_PASTE, "true");
+				lastLeaf.parent.setStyle(ConversionConstants.MERGE_TO_NEXT_ON_PASTE, "true");
+				textFlow.setStyle(ConversionConstants.MERGE_TO_NEXT_ON_PASTE, "true");
+			}
+			return textFlow;			
+		}
+
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/SingletonAttributeImporter.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/SingletonAttributeImporter.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/SingletonAttributeImporter.as
new file mode 100644
index 0000000..e5db66b
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/SingletonAttributeImporter.as
@@ -0,0 +1,46 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion
+{
+	// [ExcludeClass]
+	/**
+	 * @private  
+	 */
+	internal class SingletonAttributeImporter implements IFormatImporter
+	{
+		private var _keyToMatch:String;
+		private var _rslt:String = null;
+		
+		public function SingletonAttributeImporter(key:String)
+		{ _keyToMatch =  key; }
+		public function reset():void
+		{ _rslt = null; }
+		public function get result():Object
+		{ return _rslt; }
+		public function importOneFormat(key:String,val:String):Boolean
+		{
+			if (key == _keyToMatch)
+			{
+				_rslt = val;
+				return true;
+			}
+			return false; 
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/TLFormatImporter.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/TLFormatImporter.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/TLFormatImporter.as
new file mode 100644
index 0000000..1a2df81
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/TLFormatImporter.as
@@ -0,0 +1,65 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion
+{
+	import org.apache.flex.textLayout.property.Property;
+	import org.apache.flex.textLayout.debug.assert;
+	// [ExcludeClass]
+	/**
+	 * @private  
+	 */
+	public class TLFormatImporter implements IFormatImporter
+	{
+		private var _classType:Class;
+		private var _description:Object;
+		
+		private var _rslt:Object;
+		
+		public function TLFormatImporter(classType:Class,description:Object)
+		{ 
+			_classType = classType;
+			_description = description;
+		}
+		
+		public function get classType():Class
+		{ return _classType; }
+				
+		public function reset():void
+		{ 
+			_rslt = null;
+		}
+		public function get result():Object
+		{ 
+			return _rslt; 
+		}
+		public function importOneFormat(key:String,val:String):Boolean
+		{ 
+			if (_description.hasOwnProperty(key))
+			{
+				if (_rslt == null)
+					_rslt = new _classType();
+	
+				CONFIG::debug { assert((_description[key] as Property) != null,"Bad description in TLFormatImporter"); }
+				_rslt[key] =  _description[key].setHelper(undefined,val);
+				return true;
+			}
+			return false; 
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/TextConverter.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/TextConverter.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/TextConverter.as
new file mode 100644
index 0000000..21c12db
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/TextConverter.as
@@ -0,0 +1,649 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion
+{
+	import org.apache.flex.textLayout.elements.IConfiguration;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.textLayout.elements.TextFlow;
+
+	
+
+	
+	/** 
+	 * This is the gateway class for handling import and export. It serves as a unified access point to the 
+	 * conversion functionality in the Text Layout Framework. It contains a registry for predefined as well
+	 * as user defined input and/or output converters, plus a set of conversion methods.
+	 * <p>
+	 * The format of the converted data is not predefined; user written converters are free to accept and return
+	 * any format of their choice. Common formats are strings, XML, and ByteArray instances. Converter authors 
+	 * should document which formats are supported.
+	 * </p>
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	public class TextConverter
+	{
+		/** 
+		 * HTML format.
+		 * Use this for importing from, or exporting to, a TextFlow using the HTML fomat.
+		 * The Text Layout Framework HTML supports a subset of the tags and attributes supported by
+		 * the TextField class in the <code>flash.text</code> package.
+		 * <p>The following table lists the HTML tags and attributes supported for the import
+		 * and export process (tags and attributes supported by TextField, but not supported by 
+		 * the Text Layout Framework are specifically described as not supported):</p>
+		 * 
+		 * 
+		 * <table class="innertable" width="640">
+		 * 
+		 * <tr>
+		 * 
+		 * <th>
+		 * Tag
+		 * </th>
+		 * 
+		 * <th>
+		 * Description
+		 * </th>
+		 * 
+		 * </tr>
+		 * 
+		 * <tr>
+		 * 
+		 * <td>
+		 * Anchor tag
+		 * </td>
+		 * 
+		 * <td>
+		 * The <code>&lt;a&gt;</code> tag creates a hypertext link and supports the following attributes:
+		 * <ul>
+		 * 
+		 * <li>
+		 * <code>target</code>: Specifies the name of the target window where you load the page. 
+		 * Options include <code>_self</code>, <code>_blank</code>, <code>_parent</code>, and 
+		 * <code>_top</code>. The <code>_self</code> option specifies the current frame in the current window, 
+		 * <code>_blank</code> specifies a new window, <code>_parent</code> specifies the parent of the 
+		 * current frame, and <code>_top</code> specifies the top-level frame in the current window. 
+		 * </li>
+		 *
+		 * <li>
+		 * <code>href</code>: Specifies a URL. The URL can 
+		 * be either absolute or relative to the location of the SWF file that 
+		 * is loading the page. An example of an absolute reference to a URL is 
+		 * <code>http://www.adobe.com</code>; an example of a relative reference is 
+		 * <code>/index.html</code>. Absolute URLs must be prefixed with 
+		 * http://; otherwise, Flash treats them as relative URLs. 
+		 * <strong>Note: Unlike the TextField class, </strong>ActionScript <code>link</code> events 
+		 * are not supported. Neither are
+		 * <code>a:link</code>, <code>a:hover</code>, and <code>a:active</code> styles.
+		 * </li>
+		 * 
+		 * </ul>
+		 * 
+		 * </td>
+		 * </tr>
+		 * 
+		 * <tr>
+		 * 
+		 * <td>
+		 * Bold tag
+		 * </td>
+		 * 
+		 * <td>
+		 * The <code>&lt;b&gt;</code> tag renders text as bold. A bold typeface must be available for the font used.
+		 * </td>
+		 * </tr>
+		 * 
+		 * <tr>
+		 * 
+		 * <td>
+		 * Break tag
+		 * </td>
+		 * <td>
+		 * The <code>&lt;br&gt;</code> tag creates a line break in the text.
+		 * </td>
+		 * </tr>
+		 * 
+		 * <tr>
+		 * 
+		 * <td>
+		 * Font tag
+		 * </td>
+		 * 
+		 * <td>
+		 * The <code>&lt;font&gt;</code> tag specifies a font or list of fonts to display the text.The font tag 
+		 * supports the following attributes:
+		 * <ul>
+		 * 
+		 * <li>
+		 * <code>color</code>: Only hexadecimal color (<code>#FFFFFF</code>) values are supported. 
+		 * </li>
+		 * 
+		 * <li>
+		 * <code>face</code>: Specifies the name of the font to use. As shown in the following example, 
+		 * you can specify a list of comma-delimited font names, in which case Flash Player selects the first available 
+		 * font. If the specified font is not installed on the local computer system or isn't embedded in the SWF file, 
+		 * Flash Player selects a substitute font. 
+		 * </li>
+		 * 
+		 * <li>
+		 * <code>size</code>: Specifies the size of the font. You can use absolute pixel sizes, such as 16 or 18 
+		 * or relative point sizes, such as +2 or -4. 
+		 * </li>
+		 * 
+		 * <li>
+		 * <code>letterspacing</code>: Specifies the tracking (manual kerning) in pixels to be applied to the right of each character. 
+		 * </li>
+		 * 
+		 * <li>
+		 * <code>kerning</code>: Specifies whether kerning is enabled or disabled. A non-zero value enables kerning, while zero disables it.  
+		 * </li>
+		 * 
+		 * </ul>
+		 * 
+		 * </td>
+		 * </tr>
+		 * 
+		 * <tr>
+		 * 
+		 * <td>
+		 * Image tag
+		 * </td>
+		 * 
+		 * <td>
+		 * The <code>&lt;img&gt;</code> tag lets you embed external image files (JPEG, GIF, PNG), SWF files, and 
+		 * movie clips inside text.  
+		 * 
+		 *  <p>The <code>&lt;img&gt;</code> tag supports the following attributes: </p>
+		 * 
+		 * <ul >
+		 * 
+		 * <li>
+		 * <code>src</code>: Specifies the URL to an image or SWF file, or the linkage identifier for a movie clip 
+		 * symbol in the library. This attribute is required; all other attributes are optional. External files (JPEG, GIF, PNG, 
+		 * and SWF files) do not show until they are downloaded completely. 
+		 * </li>
+		 * 
+		 * <li>
+		 * <code>width</code>: The width of the image, SWF file, or movie clip being inserted, in pixels. 
+		 * </li>
+		 * 
+		 * <li>
+		 * <code>height</code>: The height of the image, SWF file, or movie clip being inserted, in pixels. 
+		 * </li>
+		 * </ul>
+		 * <p><strong>Note: </strong> Unlike the TextField class, the following attributes are not supported:
+		 * <code>align</code>, <code>hspace</code>, <code>vspace</code>,  <code>id</code>, and <code>checkPolicyFile</code>.</p>
+		 *
+		 * </td>
+		 * </tr>
+		 * 
+		 * <tr>
+		 * 
+		 * <td>
+		 * Italic tag
+		 * </td>
+		 * 
+		 * <td>
+		 * The <code>&lt;i&gt;</code> tag displays the tagged text in italics. An italic typeface must be available 
+		 * for the font used.
+		 * </td>
+		 * </tr>
+		 * 
+		 * <tr>
+		 * 
+		 * <td>
+		 * <em>List item tag</em>
+		 * </td>
+		 * 
+		 * <td>
+		 * <strong>Note: </strong> Unlike the TextField class, the List item tag is not supported.
+		 * </td>
+		 * </tr>
+		 * 
+		 * <tr>
+		 * 
+		 * <td>
+		 * Paragraph tag
+		 * </td>
+		 * 
+		 * <td>
+		 * The <code>&lt;p&gt;</code> tag creates a new paragraph. 
+		 * 
+		 * The <code>&lt;p&gt;</code> tag supports the following attributes:
+		 * <ul >
+		 * 
+		 * <li>
+		 * align: Specifies alignment of text within the paragraph; valid values are <code>left</code>, <code>right</code>, <code>justify</code>, and <code>center</code>. 
+		 * </li>
+		 * 
+		 * <li>
+		 * class: Specifies a class name that can be used for styling 
+		 * </li>
+		 * 
+		 * </ul>
+		 * 
+		 * </td>
+		 * </tr>
+		 * 
+		 * <tr>
+		 * 
+		 * <td>
+		 * Span tag
+		 * </td>
+		 * 
+		 * <td>
+		 * 
+		 * The <code>&lt;span&gt;</code> tag supports the following attributes:
+		 * 
+		 * <ul>
+		 * 
+		 * <li>
+		 * class: Specifies a class name that can be used for styling. While span tags are often used to set a style defined in a style sheet,
+		 * TLFTextField instances do not support style sheets. The span tag is available for TLFTextField instances to refer to a class with 
+		 * style properties.</li>
+		 * <li> You can also put properties directly in the span tag: 
+		 * <code>&lt;span fontFamily="Arial"&gt;Hi there&lt;/span&gt;</code>. However, nested span tags are not supported.
+		 * </li>
+		 * 
+		 * </ul>
+		 * 
+		 * </td>
+		 * </tr>
+		 * 
+		 * <tr>
+		 * 
+		 * <td>
+		 * Text format tag
+		 * </td>
+		 * 
+		 * <td>
+		 *  <p>The <code>&lt;textformat&gt;</code> tag lets you use a subset of paragraph formatting 
+		 * properties of the TextFormat class within text fields, including line leading, indentation, 
+		 * margins, and tab stops. You can combine <code>&lt;textformat&gt;</code> tags with the 
+		 * built-in HTML tags. </p>
+		 * 
+		 *  <p>The <code>&lt;textformat&gt;</code> tag has the following attributes: </p>
+		 * <ul >
+		 * 
+		 * 
+		 * <li>
+		 * <code>indent</code>: Specifies the indentation from the left margin to the first character 
+		 * in the paragraph; corresponds to <code>TextFormat.indent</code>. Both positive and negative 
+		 * numbers are acceptable. 
+		 * </li>
+		 * 
+		 * <li>
+		 * <code>blockindent</code>: Specifies the indentation applied to all lines of the paragraph.
+		 * </li>
+		 * 
+		 * <li>
+		 * <code>leftmargin</code>: Specifies the left margin of the paragraph, in points; corresponds 
+		 * to <code>TextFormat.leftMargin</code>. 
+		 * </li>
+		 * 
+		 * <li>
+		 * <code>rightmargin</code>: Specifies the right margin of the paragraph, in points; corresponds 
+		 * to <code>TextFormat.rightMargin</code>. 
+		 * </li>
+		 * 
+		 * 	<li>
+		 * <code>leading</code>: Specifies the leading (line height) measured in pixels between a line's ascent and the previous line's descent
+		 * </li>
+		 * 
+		 * 	<li>
+		 * <code>tabstops</code>: Specifies a comma-separated list of tab stop positions for the paragraph. 
+		 * </li>
+		 * </ul>
+		 * 
+		 * </td>
+		 * </tr>
+		 * 
+		 * <tr>
+		 * 
+		 * <td>
+		 * Underline tag
+		 * </td>
+		 * 
+		 * <td>
+		 * The <code>&lt;u&gt;</code> tag underlines the tagged text.
+		 * </td>
+		 * </tr>
+		 * 
+		 * </table>
+		 * 
+		 * <p>When an unknown tag is imported the <code>textFieldHTMLFormat</code> importer will either set a single FlowElement's typeName property to that tag name
+		 * or create a DivElement or a SubParagraphGroupElement with its typeName property set to the tag name.</p>
+		 * <p>The <code>textFieldHTMLFormat</code> exporter will export <code>typeName</code> as the XML tag when it is different from the default.</p>
+		 * 
+		 * @see org.apache.flex.textLayout.elements.FlowElement#typeName
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		public static const TEXT_FIELD_HTML_FORMAT:String = "textFieldHTMLFormat";
+
+		/** 
+		 * Plain text format.
+		 * Use this for creating a TextFlow from a simple, unformatted String, 
+		 * or for creating a simple, unformatted String from a TextFlow.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		public static const PLAIN_TEXT_FORMAT:String = "plainTextFormat";
+
+		/** 
+		 * TextLayout Format.
+		 * Use this for importing from, or exporting to, a TextFlow using the TextLayout markup format.
+		 * Text Layout format will detect the following errors:
+		 * <ul>
+		 * <li>Unexpected namespace</li>
+		 * <li>Unknown element</li>
+		 * <li>Unknown attribute</li>
+		 * </ul>
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		public static const TEXT_LAYOUT_FORMAT:String = "textLayoutFormat";
+		
+		// Descriptors - ordered list of all FormatDescriptors
+		/** @private */
+		static public var _descriptors:Array = [];
+
+		// register standard importers and exporters
+		setFormatsToDefault();
+		
+		/** @private */
+		static public function setFormatsToDefault():void	// No PMD
+		{
+			_descriptors = [];
+			addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter, TextLayoutExporter, TEXT_LAYOUT_FORMAT);
+			addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  TextFieldHtmlExporter, null);
+			addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter, PlainTextExporter, "air:text");
+		}
+		
+		/** 
+		 * Creates a TextFlow from source content in a specified format.
+		 * <p>Use one of the static constants supplied with this class, a MIME type,
+		 * to specify the <code>format</code> parameter, or use a user defined
+		 * value for user-registered importers:
+		 * <ul>
+		 * <li>TextConverter.TEXT_FIELD_HTML_FORMAT</li>
+		 * <li>TextConverter.PLAIN_TEXT_FORMAT</li>
+		 * <li>TextConverter.TEXT_LAYOUT_FORMAT</li>
+		 * </ul>
+		 * </p>
+		 * @param source	Source content
+		 * @param format	Format of source content
+		 * @param config    IConfiguration to use when creating new TextFlows
+		 * @return TextFlow that was created from the source, or null on errors.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 * @see #TEXT_FIELD_HTML_FORMAT
+		 * @see #PLAIN_TEXT_FORMAT
+		 * @see #TEXT_LAYOUT_FORMAT
+		 */
+		public static function importToFlow(source:Object, format:String, config:IConfiguration = null):ITextFlow
+		{
+			var parser:ITextImporter = getImporter(format, config);
+			if (!parser)
+				return null;
+			parser.throwOnError = false;
+			return parser.importToFlow(source);
+		}
+		
+		/** 
+		 * Exports a TextFlow to a specified format. 
+		 * <p>Use one of the static constants supplied with this class, a MIME type,
+		 * or a user defined format for user defined exporters to specify 
+		 * the <code>format</code> parameter:
+		 * <ul>
+		 * <li>TextConverter.TEXT_FIELD_HTML_FORMAT</li>
+		 * <li>TextConverter.PLAIN_TEXT_FORMAT</li>
+		 * <li>TextConverter.TEXT_LAYOUT_FORMAT</li>
+		 * </ul>
+		 * </p>
+		 * <p>Specify the type of the exported data in the <code>conversionType</code> parameter 
+		 * with one of the static constants supplied by the ConversionType class, or a user defined
+		 * data type for user defined exporters:
+		 * <ul>
+		 * <li>ConversionType.STRING_TYPE</li>
+		 * <li>ConversionType.XML_TYPE</li>
+		 * </ul>
+		 * </p>
+		 * 
+		 * Returns a representation of the TextFlow in the specified format, or null on errors.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 * @param source	Source content
+		 * @param format	Output format
+		 * @param conversionType	Type of exported data
+		 * @return Object	Exported form of the TextFlow, or null on errors
+		 * @see #TEXT_FIELD_HTML_FORMAT
+		 * @see #PLAIN_TEXT_FORMAT
+		 * @see #TEXT_LAYOUT_FORMAT
+		 * @see org.apache.flex.textLayout.conversion.ConversionType
+		 */
+		public static function export(source:TextFlow, format:String, conversionType:String) : Object
+		{
+			var exporter:ITextExporter = getExporter(format);
+			if (!exporter)
+				return null;
+			exporter.throwOnError = false;
+			return exporter.export(source, conversionType);
+		}
+		
+		/** 
+		 * Creates and returns an import converter, which you can then use to import from a 
+		 * source string, an XML object, or any user defined data formats to a TextFlow. 
+		 * Use this method if you have many separate imports to perform, or if you want to 
+		 * handle errors during import. It is equivalent to calling 
+		 * <code>org.apache.flex.textLayout.conversion.TextConverter.importToFlow()</code>.
+		 * <p>Use one of the static constants supplied with this class
+		 * to specify the <code>format</code> parameter, a MIME type, or a user defined
+		 * data format.
+		 * <ul>
+		 * <li>TextConverter.TEXT_FIELD_HTML_FORMAT</li>
+		 * <li>TextConverter.PLAIN_TEXT_FORMAT</li>
+		 * <li>TextConverter.TEXT_LAYOUT_FORMAT</li>
+		 * </ul>
+		 * </p>
+		 * <p>If the format has been added multiple times, the first one found will be used.</p>
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 * @param format	Format of source content. Use constants from 
+		 * 					org.apache.flex.textLayout.conversion.TextConverter.TEXT_LAYOUT_FORMAT, PLAIN_TEXT_FORMAT, TEXT_FIELD_HTML_FORMAT etc,
+		 * 					a MIME type, or a user defined format.
+		 * @param config    configuration to use during this import. null means take the current default.
+		 * 					You can also set the configuration via the <code>ITextImporter.configuration</code>
+		 * 					property.
+		 * @return ITextImporter	Text importer that can import the source data
+		 * @see #TEXT_FIELD_HTML_FORMAT
+		 * @see #PLAIN_TEXT_FORMAT
+		 * @see #TEXT_LAYOUT_FORMAT
+		 */
+		public static function getImporter(format:String,config:IConfiguration =  null): ITextImporter
+		{
+			var importer:ITextImporter = null;
+			var i:int = findFormatIndex(format);
+			if (i >= 0)
+			{
+				var descriptor:FormatDescriptor = _descriptors[i];
+				if (descriptor && descriptor.importerClass)
+				{
+					importer = new descriptor.importerClass();
+					importer.configuration = config;
+				}
+			}
+			return importer;
+		}
+
+		/** 
+		 * Creates and returns an export converter, which you can then use to export from 
+		 * a TextFlow to a source string or XML object. Use this function if 
+		 * you have many separate exports to perform. It is equivalent to calling 
+		 * <code>org.apache.flex.textLayout.conversion.TextConverter.export()</code>.
+		 * <p>Use one of the static constants supplied with this class
+		 * to specify the <code>format</code> parameter:
+		 * <ul>
+		 * <li>TextConverter.TEXT_FIELD_HTML_FORMAT</li>
+		 * <li>TextConverter.PLAIN_TEXT_FORMAT</li>
+		 * <li>TextConverter.TEXT_LAYOUT_FORMAT</li>
+		 * </ul>
+		 * </p>
+		 * <p>If the format has been added multiple times, the first one found will be used.</p>
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 * @param format	Target format for exported data
+		 * @return ITextExporter	Text exporter that can export in the specified format
+		 * @see #TEXT_FIELD_HTML_FORMAT
+		 * @see #PLAIN_TEXT_FORMAT
+		 * @see #TEXT_LAYOUT_FORMAT
+		 */
+		public static function getExporter(format:String) : ITextExporter
+		{
+			var exporter:ITextExporter = null;
+			var i:int = findFormatIndex(format);
+			if (i >= 0)
+			{
+				var descriptor:FormatDescriptor = _descriptors[i];
+				if (descriptor && descriptor.exporterClass)
+					exporter = new descriptor.exporterClass();
+			}
+			return exporter;
+		}
+
+		/**
+		 * Register a new format for import/export, at the specified location.
+		 * Location can be significant for clients that have multiple 
+		 * choices for which format to use, such as when importing from the external clipboard. 
+		 * Lower numbers indicate higher priority; these converters will be tried first.
+		 * The new format may support importing and/or exporting.
+		 * If the format has already been added, then it will be present in multiple locations. The 
+		 * first one found will be used.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 * @param importClass    The import converter class to register or null
+		 * @param exportClass    The export converter class to register or null
+		 * @param format         The format string tagging the converter classes
+		 * @param clipboardFormat	The string used as the clipboard format when converting to/from the clipboard. Make this null if the format doesn't support clipboard access.
+		 */
+		public static function addFormatAt(index:int, format:String, importerClass:Class, exporterClass:Class = null, clipboardFormat:String = null):void
+		{
+			var descriptor:FormatDescriptor = new FormatDescriptor(format, importerClass, exporterClass, clipboardFormat);
+			_descriptors.splice(index, 0, descriptor);
+		}
+		
+		/**
+		 * Register a new format for import/export. The new format will be added at the end,
+		 * as the lowest priority. Location can be significant for clients that have multiple 
+		 * choices for which format to use, such as when importing from the external clipboard. 
+		 * The new format may support importing and/or exporting.
+		 * If the format has already been added, then it will be present in multiple locations. The 
+		 * first one found will be used.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 * @param importClass    The import converter class to register or null
+		 * @param exportClass    The export converter class to register or null
+		 * @param format         The format string tagging the converter classes. Formats can be any name, but must be unique. 
+		 * @param clipboardFormat	The string used as the clipboard format when converting to/from the clipboard. Make this null if the format doesn't support clipboard access.
+		 */
+		public static function addFormat(format:String, importerClass:Class, exporterClass:Class, clipboardFormat:String):void
+		{
+			addFormatAt(_descriptors.length, format, importerClass, exporterClass, clipboardFormat);
+		}
+		
+		/**
+		 * Remove the format at the index location. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 * @param index     The format to remove
+		 */
+		public static function removeFormatAt(index:int):void
+		{
+			if (index >= 0 && index < _descriptors.length)
+				_descriptors.splice(index, 1);
+		}
+
+		private static function findFormatIndex(format:String):int
+		{
+			for (var i:int = 0; i < numFormats; i++)
+			{
+				if (_descriptors[i].format == format)
+					return i;
+			}
+			return -1;
+		}
+		/**
+		 * Remove the format. 
+		 * If a format was added multiple times, only the first one found is removed.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 * @param format     The converter format string to remove
+		 */
+		public static function removeFormat(format:String):void
+		{
+			removeFormatAt(findFormatIndex(format));
+		}
+		
+		/** Returns the format name for the index'th format.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+	     */
+		public static function getFormatAt(index:int):String
+		{
+			return _descriptors[index].format;
+		}
+
+		/** Returns the FormatDescriptor for the index'th format. 
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+		* @langversion 3.0 
+		*/
+		public static function getFormatDescriptorAt(index:int):FormatDescriptor
+		{
+			return _descriptors[index];
+		}
+	
+		/** Number of formats.
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+		* @langversion 3.0 
+		*/
+		public static function get numFormats():int
+		{
+			return _descriptors.length;
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/TextFieldHtmlExporter.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/TextFieldHtmlExporter.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/TextFieldHtmlExporter.as
new file mode 100644
index 0000000..2587649
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/TextFieldHtmlExporter.as
@@ -0,0 +1,580 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion
+{
+	import org.apache.flex.textLayout.elements.ListElement;
+	import org.apache.flex.textLayout.elements.IFlowGroupElement;
+	import org.apache.flex.reflection.getQualifiedClassName;
+	import org.apache.flex.text.engine.Kerning;
+	import org.apache.flex.text.engine.TabAlignment;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.elements.BreakElement;
+	import org.apache.flex.textLayout.elements.DivElement;
+	import org.apache.flex.textLayout.elements.FlowGroupElement;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	import org.apache.flex.textLayout.elements.IFlowLeafElement;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.InlineGraphicElement;
+	import org.apache.flex.textLayout.elements.LinkElement;
+	import org.apache.flex.textLayout.elements.IListElement;
+	import org.apache.flex.textLayout.elements.ListItemElement;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.SpanElement;
+	import org.apache.flex.textLayout.elements.SubParagraphGroupElement;
+	import org.apache.flex.textLayout.elements.SubParagraphGroupElementBase;
+	import org.apache.flex.textLayout.elements.TCYElement;
+	import org.apache.flex.textLayout.elements.TabElement;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.textLayout.formats.Direction;
+	import org.apache.flex.textLayout.formats.Float;
+	import org.apache.flex.textLayout.formats.FormatValue;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.formats.LeadingModel;
+	import org.apache.flex.textLayout.formats.TabStopFormat;
+	import org.apache.flex.textLayout.formats.TextAlign;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+
+	// [ExcludeClass]
+	/** 
+	* @private
+	* Export converter for HTML format. 
+	*/
+	public class TextFieldHtmlExporter extends ConverterBase implements ITextExporter	
+	{
+		/** @private */
+		public static var _config:ImportExportConfiguration;
+		
+		public function TextFieldHtmlExporter()
+		{
+			if (!_config)
+			{
+				_config = new ImportExportConfiguration();
+				_config.addIEInfo(null, DivElement, null, exportDiv);
+				_config.addIEInfo(null, IParagraphElement, null, exportParagraph);
+				_config.addIEInfo(null, LinkElement, null, exportLink);
+				_config.addIEInfo(null, TCYElement, null, exportTCY);
+				_config.addIEInfo(null, SubParagraphGroupElement, null, exportSPGE);
+				_config.addIEInfo(null, SpanElement, null, exportSpan);
+				_config.addIEInfo(null, InlineGraphicElement, null, exportImage);
+				_config.addIEInfo(null, TabElement, null, exportTab);
+				_config.addIEInfo(null, BreakElement, null, exportBreak);
+				_config.addIEInfo(null, ListElement, null, exportList);
+				_config.addIEInfo(null, ListItemElement, null, exportListItem);
+			}
+		}
+		 
+		/** @copy ITextExporter#export()
+		 */
+		public function export(source:ITextFlow, conversionType:String):Object
+		{
+			var result:XML = exportToXML(source);
+			return conversionType == ConversionType.STRING_TYPE ? BaseTextLayoutExporter.convertXMLToString(result) : result;
+		}
+		
+		/** Export text content of a TextFlow into HTML format.
+		 * @param source	the text to export
+		 * @return XML	the exported content
+		 * @private
+		 */
+		public function exportToXML(textFlow:ITextFlow) : XML
+		{
+			var html:XML = <HTML/>;
+			
+			if (textFlow.numChildren != 0)
+			{
+				if (textFlow.getChildAt(0).typeName != "BODY")
+				{
+					var body:XML = <BODY/>;
+					html.appendChild(body);
+					exportChildren(textFlow,body);
+				}
+				else
+					exportChildren(textFlow,html);
+			}
+			
+			return html;
+		}
+		
+		/** create the XMl tag for an element. @private */
+		static public function makeTaggedTypeName(elem:IFlowElement,defaultTag:String):XML
+		{
+			if (elem.typeName == elem.defaultTypeName)
+				return <{defaultTag}/>;
+			return <{elem.typeName.toUpperCase()}/>;
+		}
+		
+		/** export styleName and id @private */
+		public static function exportStyling(elem:IFlowElement, xml:XML):void
+		{
+			if (elem.id != null)
+				xml.@id = elem.id;
+//TODO @
+			// if (elem.styleName != null)
+			// 	xml.@["class"] = elem.styleName;
+		}
+		
+		/** export FlowGroupElement children into parentXML. @private */
+		public function exportChildren(elem:IFlowGroupElement,parentXML:XML):void
+		{
+			for (var idx:int = 0; idx < elem.numChildren; idx++)
+			{
+				var child:IFlowElement = elem.getChildAt(idx);
+				exportElement(child,parentXML);
+			}
+		}
+		
+		/** Export a List @private */
+		public function exportList(list:IListElement, parentXML:XML):void
+		{
+			var xml:XML;
+			if (list.isNumberedList())
+				xml = <OL/>;
+			else
+				xml = <UL/>;
+			exportStyling(list, xml);
+			exportChildren(list, xml);
+			
+			if (list.typeName != list.defaultTypeName)
+			{
+				var typeNameXML:XML = <{list.typeName}/>;
+				typeNameXML.appendChild(xml);
+				parentXML.appendChild(typeNameXML);
+			}
+			else
+				parentXML.appendChild(xml);
+		}
+
+		
+		/** Export a ListItem @private */
+		public function exportListItem(li:ListItemElement, parentXML:XML):void
+		{
+			// WARNING: no solution for a listitem with a custom typeName - loose the typeName
+			var xml:XML = <LI/>;
+			exportStyling(li, xml);
+			exportChildren(li, xml);
+			
+			// if we've got exactly one P promote its child directly into the LI.  It causes TextField to add an extra paragraph.  Ugly.
+			var children:XMLList = xml.children();
+			if (children.length() == 1)
+			{
+				var child:XML = children[0];
+				if (child.name().localName == "P")
+				{
+					var paraChildren:XMLList = child.children();
+					if (paraChildren.length() == 1)
+					{
+						xml = <LI/>;
+						xml.appendChild(paraChildren[0]);
+					}
+				}
+			}
+			parentXML.appendChild(xml);
+		}
+		
+		/** Export a DIV element */
+		public function exportDiv(div:DivElement, parentXML:XML):void
+		{
+			var xml:XML = makeTaggedTypeName(div,"DIV");			
+			exportStyling(div, xml);
+			exportChildren(div, xml);
+			parentXML.appendChild(xml);			
+		}
+		
+		/** Export a paragraph
+		 * @private
+		 */
+		public function exportParagraph(para:IParagraphElement, parentXML:XML):void
+		{
+			// Exported as a <P/>
+			// Some paragraph-level formats (such as textAlign) are exported as attributes of <P/>, 
+			// Others (such as textIndent) are exported as attributes of the <TEXTFORMAT/> parent of <P/>
+			// Some character-level formats (such as fontSize) are exported as attributes of the <FONT/> child of <P/>
+			// Children of the IParagraphElement are nested inside the <FONT/>
+			var xml:XML = makeTaggedTypeName(para,"P");
+			exportStyling(para, xml);
+			
+			var fontXML:XML = exportFont(para.computedFormat);
+			CONFIG::debug { assert(fontXML != null, "Expect exportFont to return non-null xml if second parameter (ifDifferentFromFormat) is null"); }
+			exportSubParagraphChildren(para, fontXML);
+			nest(xml, fontXML);
+			
+			parentXML.appendChild(exportParagraphFormat(xml, para));
+		}
+		
+		/** Export a link
+		 * @private
+		 */
+		public function exportLink(link:LinkElement, parentXML:XML):void
+		{
+			// Exported as an <A/> with HREF and TARGET attributes
+			// Children of the LinkElement are nested inside the <A/>
+			// If the computed values of certain character-level formats differ from the corresponding computed values for the
+			// containing paragraph, these are exported as attributes of a <FONT/> which (in this case) parents the <A/>.
+			var xml:XML = <A/>;
+
+			if (link.href)
+				xml.@HREF= link.href;
+			if (link.target)
+				xml.@TARGET = link.target;
+			else
+			{
+				// TextField uses _self as the default target  
+				// while TLF uses null (funcionally identical to _blank). Account for this difference.
+				xml.@TARGET = "_blank";
+			}
+			exportSubParagraphElement(link, xml, parentXML);
+		}
+		
+		/** Export a tcy element
+		 * @private
+		 */
+		public function exportTCY(tcy:TCYElement, parentXML:XML):void
+		{
+			// make it a custom element - this will round trip it
+			// note if the element has a custom typeName that typeName is going to be built as a parent
+			var xml:XML = <TCY/>;
+			exportSubParagraphElement(tcy, xml, parentXML);
+		}
+		
+		
+		/** Export a SubParagraphGroupElement
+		 * @private
+		 */
+		public function exportSPGE(spge:SubParagraphGroupElement, parentXML:XML):void
+		{
+			var xml:XML = spge.typeName != spge.defaultTypeName ? <{spge.typeName}/> : <SPAN/>;
+			exportSubParagraphElement(spge, xml, parentXML, false);
+		}
+		
+		public function exportSubParagraphElement(elem:SubParagraphGroupElementBase, xml:XML, parentXML:XML, checkTypeName:Boolean=true):void
+		{
+			exportStyling(elem, xml);
+			exportSubParagraphChildren(elem, xml);
+			
+			var format:ITextLayoutFormat = elem.computedFormat;
+			var ifDifferentFromFormat:ITextLayoutFormat = elem.parent.computedFormat;
+			
+			var font:XML = exportFont(format, ifDifferentFromFormat);	
+			var childXML:XML = font ? nest(font, xml) : xml;
+			
+			if (checkTypeName && elem.typeName != elem.defaultTypeName)
+			{
+				var typeNameXML:XML = <{elem.typeName}/>;
+				typeNameXML.appendChild(childXML);
+				parentXML.appendChild(typeNameXML);				
+			}
+			else
+				parentXML.appendChild(childXML);
+		}
+		
+		/** @private */
+//TODO regex
+		static public const brRegEx:RegExp = /foo/;
+		// static public const brRegEx:RegExp = /\u2028/;
+		
+		/** Gets the xml element used to represent a character in the export format
+		 * @private
+		 */
+		static public function getSpanTextReplacementXML(ch:String):XML
+		{
+			CONFIG::debug {assert(ch == '\u2028', "Did not recognize character to be replaced with XML"); }
+			return <BR/>;
+		}
+		
+		/** Export a span
+		 * @private
+		 */
+		public function exportSpan(span:SpanElement, parentXML:XML):void
+		{
+			// Span text is exported as a text node (or text nodes delimited by <BR/> elements for any occurences of U+2028)
+			// These text nodes and <BR/> elements are optionally nested in formatting elements
+			var xml:XML  = makeTaggedTypeName(span, "SPAN"); 
+			exportStyling(span, xml);
+			BaseTextLayoutExporter.exportSpanText(xml, span, brRegEx, getSpanTextReplacementXML);
+			
+			// for brevity, do not export attribute-less <span> tags; export just their children
+			if (span.id == null && span.styleName == null && span.typeName == span.defaultTypeName)
+			{
+				var children:Object = xml.children();
+					
+				// Workaround for bug 1852072 : extraneous tags can appear around a string child added after an XML element 
+				if (children.length() == 1 && children[0].nodeKind() == "text")
+					children = xml.text()[0];
+					
+				parentXML.appendChild(exportSpanFormat(children, span));
+			}
+			else
+				parentXML.appendChild(exportSpanFormat(xml, span));
+		}
+		
+		/** Export an inline graphic
+		 * @private
+		 */
+		public function exportImage(image:InlineGraphicElement, parentXML:XML):void
+		{
+			// Exported as an <IMG/> with SRC, WIDTH, HEIGHT and ALIGN attributes
+			var xml:XML = <IMG/>;
+			exportStyling(image, xml);
+			if (image.source)
+				xml.@SRC = image.source;
+			if (image.width !== undefined && image.width != FormatValue.AUTO) 
+				xml.@WIDTH = image.width;
+			// xml.@WIDTH = image.actualWidth;
+			if (image.height !== undefined && image.height != FormatValue.AUTO) 
+				xml.@HEIGHT = image.height;
+			// xml.@HEIGHT = image.actualHeight;	
+			if (image.computedFloat != Float.NONE)
+				xml.@ALIGN = image.float;
+			
+			if (image.typeName != image.defaultTypeName)
+			{
+				var typeNameXML:XML = <{image.typeName}/>;
+				typeNameXML.appendChild(xml);
+				parentXML.appendChild(typeNameXML);
+			}
+			else
+				parentXML.appendChild(xml);
+		}
+	
+		/** Export a break
+		 * Is this ever called: BreakElements are either merged with adjacent spans or become spans? 
+		 * @private
+		 */		
+		public function exportBreak(breakElement:BreakElement,parentXML:XML):void
+		{
+			parentXML.appendChild(<BR/>);
+		}
+		
+		/** Export a tab
+		 * Is this ever called: TabElements are either merged with adjacent spans or become spans? 
+		 * @private
+		 */	
+		public function exportTab(tabElement:TabElement, parentXML:XML):void
+		{
+			// Export as a span
+			exportSpan(tabElement, parentXML);
+		}
+		
+		/** @private */
+		public function exportTextFormatAttribute (textFormatXML:XML, attrName:String, attrVal:*):XML
+		{
+			if (!textFormatXML)
+				textFormatXML = <TEXTFORMAT/>;
+
+//TODO @
+			// textFormatXML.@[attrName] = attrVal;
+			
+			return textFormatXML;	
+		}
+		
+		/** Exports the paragraph-level format for a paragraph  
+		 * @param xml xml to decorate with attributes or add nest in formatting elements
+		 * @para the paragraph
+		 * @return XML	the outermost XML element after exporting 
+		 * @private
+		 */	
+		public function exportParagraphFormat(xml:XML, para:IParagraphElement):XML
+		{	
+			var paraFormat:ITextLayoutFormat = para.computedFormat;
+			
+			var textAlignment:String;
+			switch(paraFormat.textAlign)
+			{
+				case TextAlign.START:
+					textAlignment = (paraFormat.direction == Direction.LTR) ? TextAlign.LEFT : TextAlign.RIGHT;
+					break;
+				case TextAlign.END:
+					textAlignment = (paraFormat.direction == Direction.LTR) ? TextAlign.RIGHT : TextAlign.LEFT;
+					break;
+				default:
+					textAlignment = paraFormat.textAlign;
+			}
+			xml.@ALIGN = textAlignment;
+					
+			var textFormat:XML;
+			
+			if (paraFormat.paragraphStartIndent != 0)
+				textFormat = exportTextFormatAttribute (textFormat, paraFormat.direction == Direction.LTR ? "LEFTMARGIN" : "RIGHTMARGIN", paraFormat.paragraphStartIndent);
+			
+			if (paraFormat.paragraphEndIndent != 0)
+				 textFormat = exportTextFormatAttribute (textFormat, paraFormat.direction == Direction.LTR ? "RIGHTMARGIN" : "LEFTMARGIN", paraFormat.paragraphEndIndent);
+			
+			if (paraFormat.textIndent != 0)
+				textFormat = exportTextFormatAttribute(textFormat, "INDENT", paraFormat.textIndent);
+				
+			if (paraFormat.leadingModel == LeadingModel.APPROXIMATE_TEXT_FIELD)
+			{
+				var firstLeaf:IFlowLeafElement = para.getFirstLeaf();
+				if (firstLeaf)
+				{
+					var lineHeight:Number = TextLayoutFormat.lineHeightProperty.computeActualPropertyValue(firstLeaf.computedFormat.lineHeight,firstLeaf.getEffectiveFontSize());
+					if (lineHeight != 0)
+						textFormat = exportTextFormatAttribute(textFormat, "LEADING", lineHeight);
+				}
+			}
+			
+			var tabStops:Array = paraFormat.tabStops;
+			if (tabStops)
+			{
+				var tabStopsString:String = "";
+				for each (var tabStop:TabStopFormat in tabStops)
+				{
+					if (tabStop.alignment != TabAlignment.START)
+						break;
+					
+					if (tabStopsString.length)
+						tabStopsString += ", ";
+					
+					tabStopsString += tabStop.position;
+				}
+				
+				if (tabStopsString.length)
+					textFormat = exportTextFormatAttribute(textFormat, "TABSTOPS", tabStopsString);
+			}
+			
+			return textFormat ? nest(textFormat, xml) : xml;
+		}
+		
+		/** Exports the character-level format for a span  
+		 * @param xml xml/xmlList to nest in formatting elements
+		 * @span the span
+		 * @return XML	the outermost XML element after exporting 
+		 * @private
+		 */	
+		public function exportSpanFormat(xml:Object, span:SpanElement):Object
+		{
+			// These are optionally nested in a <FONT/> with appopriate attributes ,			 
+			
+			var format:ITextLayoutFormat = span.computedFormat;
+			var outerElement:Object = xml;
+			
+			// Nest in <B/>, <I/>, or <U/> if applicable
+			if (format.textDecoration.toString() == org.apache.flex.textLayout.formats.TextDecoration.UNDERLINE)
+				outerElement = nest (<U/>, outerElement);
+//TODO get HTML based on styles
+//			if (format.fontStyle.toString() == org.apache.flex.text.engine.FontPosture.ITALIC)
+//				outerElement = nest (<I/>, outerElement);
+//			if (format.fontWeight.toString() == org.apache.flex.text.engine.FontWeight.BOLD)
+//				outerElement = nest (<B/>, outerElement);
+				
+			// Nest in <FONT/> if the computed values of certain character-level formats 
+			// differ from the corresponding computed values for the containing parent that's exported
+			// A span can be contained in a TCY, link, or paragraph. Of these, TCY is not exported, so only
+			// check link and paragraph.
+			var exportedParent:IFlowElement = span.getParentByType("LinkElement");
+			if (!exportedParent)
+				exportedParent = span.getParagraph();
+	
+			var font:XML = exportFont(format, exportedParent.computedFormat);	
+			if (font)
+				outerElement = nest(font, outerElement);	
+
+			return outerElement;			   	
+		}	
+		
+		/** @private */
+		public function exportFontAttribute (fontXML:XML, attrName:String, attrVal:*):XML
+		{
+			if (!fontXML)
+				fontXML = <FONT/>;
+				
+//TODO @
+			// fontXML.@[attrName] = attrVal;
+			
+			return fontXML;	
+		}
+		
+		/**  
+		 * Exports certain character level formats as a <FONT/> with appropriate attributes
+		 * @param format format to export
+		 * @param ifDifferentFromFormat if non-null, a value in format is exported only if it differs from the corresponding value in ifDifferentFromFormat
+		 * @return XML	the populated XML element
+		 * @private
+		 */	
+		public function exportFont(format:ITextLayoutFormat, ifDifferentFromFormat:ITextLayoutFormat=null):XML
+		{
+			var font:XML;
+			if (!ifDifferentFromFormat || ifDifferentFromFormat.fontFamily != format.fontFamily)
+				font = exportFontAttribute(font, "FACE", format.fontFamily);
+			if (!ifDifferentFromFormat || ifDifferentFromFormat.fontSize != format.fontSize)
+				font = exportFontAttribute(font, "SIZE", format.fontSize);
+			if (!ifDifferentFromFormat || ifDifferentFromFormat.color != format.color)
+			{
+				var rgb:String = format.color.toString(16);
+				while (rgb.length < 6) 
+					rgb = "0" + rgb; // pad with leading zeros
+				rgb = "#" + rgb;
+				font = exportFontAttribute(font, "COLOR", rgb);
+			}
+			if (!ifDifferentFromFormat || ifDifferentFromFormat.trackingRight != format.trackingRight)
+				font = exportFontAttribute(font, "LETTERSPACING", format.trackingRight); 
+			if (!ifDifferentFromFormat || ifDifferentFromFormat.kerning != format.kerning)
+				font = exportFontAttribute(font, "KERNING", format.kerning == Kerning.OFF ? "0" : "1");
+						
+			return font;				
+		}
+			
+		/** Exports the flow element by finding the appropriate exporter
+		 * @param flowElement	Element to export
+		 * @return Object	XML/XMLList for the flowElement
+		 * @private
+		 */
+		public function exportElement(flowElement:IFlowElement, parentXML:XML):void
+		{
+			var className:String = getQualifiedClassName(flowElement);
+			var info:FlowElementInfo = _config.lookupByClass(className);
+			if (info)
+				info.exporter(flowElement, parentXML);
+			else 
+			{
+				CONFIG::debug { assert(flowElement is FlowGroupElement,"Bad element in HtmlExport.exportElement"); }
+				var xml:XML = <{flowElement.typeName.toUpperCase()}/>;
+				exportChildren(flowElement as FlowGroupElement, xml);
+				parentXML.appendChild(xml);
+			}
+		}
+		
+		/** Exports the children of a flow group element
+		 * @param xml XML to append children to
+		 * @param flowGroupElement	the flow group element
+		 * @private
+		 */
+		public function exportSubParagraphChildren(flowGroupElement:IFlowGroupElement, parentXML:XML):void
+		{
+			for(var i:int=0; i < flowGroupElement.numChildren; ++i)
+			{
+				exportElement(flowGroupElement.getChildAt(i),parentXML);
+			}
+		}
+		
+		/** Helper to establish a parent-child relationship between two xml elements
+		 * and return the parent
+		 * @param parent the intended parent
+		 * @param children the intended children (XML or XMLList)
+		 * @return the parent
+		 * @private
+		 */
+		static public function nest (parent:XML, children:Object):XML
+		{
+			parent.setChildren(children);
+			return parent;
+		}
+		
+ 	}
+}
\ No newline at end of file


[41/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/EditClasses.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/EditClasses.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/EditClasses.as
new file mode 100644
index 0000000..1f94edf
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/EditClasses.as
@@ -0,0 +1,69 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout
+{
+	internal class EditClasses
+	{
+		import org.apache.flex.textLayout.container.TextContainerManager; TextContainerManager;
+		
+		import org.apache.flex.textLayout.events.FlowOperationEvent; FlowOperationEvent;
+		import org.apache.flex.textLayout.events.SelectionEvent; SelectionEvent;
+ 
+		import org.apache.flex.textLayout.edit.EditManager; EditManager;
+		import org.apache.flex.textLayout.edit.ElementRange; ElementRange;
+		import org.apache.flex.textLayout.edit.IEditManager; IEditManager;
+		import org.apache.flex.textLayout.edit.Mark; Mark;
+		import org.apache.flex.textLayout.edit.SelectionManager; SelectionManager;
+		import org.apache.flex.textLayout.edit.ModelEdit; ModelEdit;
+		import org.apache.flex.textLayout.edit.IMemento; IMemento;
+		import org.apache.flex.textLayout.edit.ElementMark; ElementMark;
+
+		import org.apache.flex.textLayout.edit.TextScrap; TextScrap;
+
+		import org.apache.flex.textLayout.operations.ApplyFormatOperation; ApplyFormatOperation;
+		import org.apache.flex.textLayout.operations.ApplyFormatToElementOperation; ApplyFormatToElementOperation;
+		import org.apache.flex.textLayout.operations.ApplyLinkOperation; ApplyLinkOperation;
+		import org.apache.flex.textLayout.operations.ApplyTCYOperation; ApplyTCYOperation;
+		import org.apache.flex.textLayout.operations.ApplyElementIDOperation; ApplyElementIDOperation;
+		import org.apache.flex.textLayout.operations.ApplyElementStyleNameOperation; ApplyElementStyleNameOperation;
+		import org.apache.flex.textLayout.operations.ApplyElementTypeNameOperation; ApplyElementTypeNameOperation;
+		import org.apache.flex.textLayout.operations.CreateDivOperation; CreateDivOperation;
+		import org.apache.flex.textLayout.operations.ClearFormatOperation; ClearFormatOperation;
+		import org.apache.flex.textLayout.operations.ClearFormatOnElementOperation; ClearFormatOnElementOperation;
+		import org.apache.flex.textLayout.operations.CreateListOperation; CreateListOperation;
+		import org.apache.flex.textLayout.operations.CreateSubParagraphGroupOperation; CreateSubParagraphGroupOperation;
+		import org.apache.flex.textLayout.operations.CompositeOperation; CompositeOperation;
+		import org.apache.flex.textLayout.operations.CopyOperation; CopyOperation;
+		import org.apache.flex.textLayout.operations.CutOperation; CutOperation;
+		import org.apache.flex.textLayout.operations.DeleteTextOperation; DeleteTextOperation;
+		import org.apache.flex.textLayout.operations.FlowOperation; FlowOperation;
+		import org.apache.flex.textLayout.operations.InsertInlineGraphicOperation; InsertInlineGraphicOperation;
+		import org.apache.flex.textLayout.operations.InsertTextOperation; InsertTextOperation;
+		import org.apache.flex.textLayout.operations.PasteOperation; PasteOperation;
+		import org.apache.flex.textLayout.operations.RedoOperation; RedoOperation;
+		import org.apache.flex.textLayout.operations.ApplyElementUserStyleOperation; ApplyElementUserStyleOperation;
+		import org.apache.flex.textLayout.operations.SplitParagraphOperation; SplitParagraphOperation;
+		import org.apache.flex.textLayout.operations.SplitElementOperation; SplitElementOperation;
+		import org.apache.flex.textLayout.operations.UndoOperation; UndoOperation;
+
+		import org.apache.flex.textLayout.utils.NavigationUtil; NavigationUtil;
+		
+
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/TextLayoutVersion.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/TextLayoutVersion.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/TextLayoutVersion.as
new file mode 100644
index 0000000..6f9aec1
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/TextLayoutVersion.as
@@ -0,0 +1,135 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout 
+{	
+
+	/** 
+	 *  This class controls the backward-compatibility of the framework.
+	 *  With every new release, some aspects of the framework are changed which can affect your application.
+	 *  
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10
+	 *  @playerversion AIR 2.0
+	 */
+	public class TextLayoutVersion 
+	{		
+		
+		//--------------------------------------------------------------------------
+		//
+		//  Class constants
+		//
+		//--------------------------------------------------------------------------
+		
+		/** 
+		 *  The current released version of the Text Layout Framework, encoded as a uint.
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10
+		 *  @playerversion AIR 2.0
+		 */
+		public static const CURRENT_VERSION:uint = 0x03000000;
+		
+		/** 
+		 *  The version number value of TLF 3.0,
+		 *  encoded numerically as a <code>uint</code>.
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10
+		 *  @playerversion AIR 2.0
+		 */
+		public static const VERSION_3_0:uint = 0x03000000;
+		
+		/** 
+		 *  The version number value of TLF 2.0,
+		 *  encoded numerically as a <code>uint</code>.
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10
+		 *  @playerversion AIR 2.0
+		 */
+		public static const VERSION_2_0:uint = 0x02000000;
+		
+		/** 
+		 *  The version number value of TLF 1.0,
+		 *  encoded numerically as a <code>uint</code>.
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10
+		 *  @playerversion AIR 2.0
+		 */
+		public static const VERSION_1_0:uint = 0x01000000;
+
+		/** 
+		 *  The version number value of TLF 1.1,
+		 *  encoded numerically as a <code>uint</code>.
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10
+		 *  @playerversion AIR 2.0
+		 */
+		public static const VERSION_1_1:uint = 0x01010000;
+		
+		/** @private
+		 * Contains the current build number. 
+		 * It is static and can be called with <code>TextLayoutVersion.BUILD_NUMBER</code>
+		 * <p>String Format: "BuildNumber (Changelist)"</p>
+		 */
+		public static const BUILD_NUMBER:String = "31 (763429)";
+		
+		/** @private
+		 * Contains the branch name. 
+		 */
+		public static const BRANCH:String = "main";
+		
+		/**
+		 * @private 
+		 */
+		public static const AUDIT_ID:String = "<AdobeIP 0000486>";
+		
+		/**
+		 * @private 
+		 */
+		public function dontStripAuditID():String
+		{
+			return AUDIT_ID;
+		}
+
+		/** @private
+		 *  The version as a string of the form "X.X.X".
+		 *  Converts the version number to a more
+		 *  human-readable String version.
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10
+		 *  @playerversion AIR 2.0
+		 */
+		public static function getVersionString(version:uint):String
+		{
+			var major:uint = (version >> 24) & 0xFF;
+			var minor:uint = (version >> 16) & 0xFF;
+			var update:uint = version & 0xFFFF;
+			
+			return major.toString() + "." +
+				minor.toString() + "." +
+				update.toString();
+		}
+
+	}
+	
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/accessibility/TextAccImpl.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/accessibility/TextAccImpl.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/accessibility/TextAccImpl.as
new file mode 100644
index 0000000..d8d7fc1
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/accessibility/TextAccImpl.as
@@ -0,0 +1,426 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.accessibility
+{
+	import flash.accessibility.Accessibility;
+	import flash.accessibility.AccessibilityImplementation;
+	import flash.accessibility.AccessibilityProperties;
+	import flash.display.DisplayObject;
+	import org.apache.flex.events.Event;
+	
+	import org.apache.flex.textLayout.edit.EditingMode;
+	import org.apache.flex.textLayout.edit.ISelectionManager;
+	import org.apache.flex.textLayout.elements.IFlowLeafElement;
+	import org.apache.flex.textLayout.elements.GlobalSettings;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.TextFlow;
+	import org.apache.flex.textLayout.events.CompositionCompleteEvent;
+	
+
+    //TODO this is in text_edit... which violates MVC yet again... what to do?
+    //import org.apache.flex.textLayout.events.SelectionEvent;
+    
+	//TODO handle selectable text when FP implements the new selection API:
+	//     http://frpbugapp.macromedia.com/bugapp/detail.asp?id=217540
+	//     To catch the selection changes reliably, listen for SelectionEvent,
+	//     which is dispatched on the TextFlow whenever the selection changes.
+
+    //TODO handle scrolling? might need to expose scrolling in here
+    
+	//TODO handle hyperlinks? I don't know if MSAA has a concept for this
+	//    (what other text advanced features must be accessible? graphics?)
+	//TODO what if there is HTML in it? strip it, or read it? we don't have an
+	//     htmlText property, do we?
+
+    // TODO Do we want to read the contents of each sprite and stop, even if the
+    // text flows into other sprite, meaning we read text in taborder; or do we
+    // want to read the entire model and not worry about the presentation
+    // (simpler)? Not sure if I can get the contents of each sprite separately.
+    
+    // TODO TESTING:
+    //   * Test that JAWS reads when setting the focus programmatically.
+    //   * Tests for changing every part of the model programmatically -- role
+    //     and state should update accordingly, visibility, and text contents.
+    //   * Test that setting tabOrder reads as expected. What happens if you set
+    //     tabOrder on multiple flowComposers?
+    
+    //TODO update this comment after integration
+	/**
+	 * @private
+	 * The TextAccImpl class adds accessibility for text components.
+	 * This hooks into DisplayObjects when TextFlow.container is set.
+	 */
+	public class TextAccImpl extends AccessibilityImplementation
+	{
+	    //TODO might want to put these constants in a new class if they are
+	    //     used anywhere else.
+	    
+		/** Default state */
+		protected static const STATE_SYSTEM_NORMAL:uint = 0x00000000;
+		
+		/** Read-only text */
+		protected static const STATE_SYSTEM_READONLY:uint = 0x00000040;
+		
+		/** Inivisible text */
+		//TODO unused, but supported state for text in MSAA
+		protected static const STATE_SYSTEM_INVISIBLE:uint = 0x00008000;
+		
+		/** Default role -- read-only, unselectable text. */
+		protected static const ROLE_SYSTEM_STATICTEXT:uint = 0x29;
+		
+		/** Editable OR read-only, selectable text. */
+		protected static const ROLE_SYSTEM_TEXT:uint = 0x2a;
+		
+		/* When the name changes (name is the text conent in STATICTEXT). */
+		protected static const EVENT_OBJECT_NAMECHANGE:uint = 0x800c;
+		
+		/* When the value changes (value is the text content in TEXT). */
+		protected static const EVENT_OBJECT_VALUECHANGE:uint = 0x800e;
+	
+		/**
+		 *  A reference to the DisplayObject that is hosting accessible text.
+		 */
+		//TODO for now this assumes only the first DO in a flow is accessible
+		//     in the future each flow DO should host its own accimpl and read
+		//     the text only for its own box.
+		//
+		//     Or... perhaps we use getChildIDArray to manage all the text
+		//     flows if they are linked below some master component (but I don't
+		//     think this is the way it will happen).
+		protected var textContainer:DisplayObject;
+		
+		/**
+		 *  A reference to the TextFlow where our text originates.
+		 */
+		protected var textFlow:TextFlow;
+		
+		/**
+		 *  Constructor.
+		 * 
+		 *  @param textContainer The DisplayObject instance that this
+		 *                       TextAccImpl instance is making accessible.
+		 *  @param textFlow The TextFlow that is hosting the textContainer.
+		 */
+		public function TextAccImpl(textCont:DisplayObject, textFlow:TextFlow)
+		{
+			super();
+	
+			this.textContainer = textCont;
+			this.textFlow = textFlow;
+			
+			// stub is true when you are NOT providing an acc implementation
+			// reports to reader as graphic
+			stub = false;
+			
+			if (textCont.accessibilityProperties == null)
+			{
+    			textCont.accessibilityProperties =
+    			    new AccessibilityProperties();
+			}
+
+            //TODO
+            // setup event listeners for text selection and model changes
+            //textFlow.addEventListener(SelectionEvent.SELECTION_CHANGE,
+            //                          eventHandler);
+            textFlow.addEventListener(CompositionCompleteEvent.COMPOSITION_COMPLETE, eventHandler);
+		}
+		
+		public function detachListeners():void
+		{
+			textFlow.removeEventListener(CompositionCompleteEvent.COMPOSITION_COMPLETE, eventHandler);
+		}
+		
+		/**
+		 *  Returns the system role for the text.
+		 *
+		 *  @param childID uint.
+		 *  @return Role associated with the text.
+		 */
+		override public function get_accRole(childID:uint):uint
+		{
+		    // trace("get_accRole()");
+		    
+		    const iManager:ISelectionManager = textFlow.interactionManager;
+		    if (iManager == null)
+		    {
+		        // non-selectable, non-editable text is STATICTEXT
+		        return ROLE_SYSTEM_STATICTEXT;
+		    }
+		    else // iManager is an IEditManager and/or ISelectionManager
+		    {
+		        // read-only selectable or editable selectable text are TEXT
+		        return ROLE_SYSTEM_TEXT;
+		    }
+		}
+		
+		/**
+		 *  Returns the state of the text.
+		 *
+		 *  @param childID uint.
+		 *  @return Role associated with the text.
+		 */
+		override public function get_accState(childID:uint):uint
+		{
+		    // trace("get_accState()");
+		    
+		    const iManager:ISelectionManager = textFlow.interactionManager;
+		    
+		    //TODO handle STATE_SYSTEM_INVISIBLE for all cases below
+		    //     and add an event to detect changes--does Flash support this?
+		    
+		    //TODO handle STATE_SYSTEM_PROTECTED for all cases below
+		    //     if vellum gets a concept of password fields, then it needs to 
+		    //     emit this value if the field is converted to a password;
+		    //     otherwise the Flex framework will need to be sure to emit
+		    //     this state in a text input component.
+		    
+		    // note: focus-related states are handled by the player
+		    
+		    if (iManager == null)
+		    {
+		        // non-selectable, non-editable text
+		        return STATE_SYSTEM_READONLY;
+		    }
+		    // must check IEditManager before ISelectionManager (it can be both)
+		    else if (iManager.editingMode == EditingMode.READ_WRITE)
+		    {
+		        // editable selectable text
+		        return STATE_SYSTEM_NORMAL;
+		    }
+		    else // if (iManager instanceof ISelectionManager)
+		    {
+		        // read-only selectable text
+		        return STATE_SYSTEM_READONLY;
+		    }
+		}
+		
+		/**
+		 *  Returns the name of the text.
+		 *
+		 *  @param childID uint.
+		 *  @return Name of the text.
+		 */
+		override public function get_accName(childID:uint):String
+		{
+		    // trace("get_accName()");
+		    
+		    switch (get_accRole(childID))
+		    {
+    		    case ROLE_SYSTEM_STATICTEXT:
+    		    {
+        		    //TODO this SHOULD come from TextConverter, but then there is a
+        		    //     circular build dependency since importExport builds
+        		    //     against model, and it probably violates mvc
+        			//return TextConverter.export(textFlow,
+        			//                         TextConverter.PLAIN_TEXT_FORMAT);
+        			
+        			//TODO this is probably expensive. is there a way to cache
+        			//      this and know when dirty?
+        			//TODO  look at the generation and determine when it's dirty
+        			return exportToString(textFlow);
+    		    }
+    		    
+		        case ROLE_SYSTEM_TEXT:
+		        default:
+            		return null;
+    		}
+		}
+		
+		/**
+		 *  Returns the value of the text.
+		 *
+		 *  @param childID uint.
+		 *  @return Name of the text.
+		 */
+		override public function get_accValue(childID:uint):String
+		{
+		    // trace("get_accValue()");
+		    
+		    switch (get_accRole(childID))
+		    {
+		        case ROLE_SYSTEM_TEXT:
+    		    {
+        		    //TODO this SHOULD come from TextConverter, but then there is a
+        		    //     circular build dependency since importExport builds
+        		    //     against model, and it probably violates mvc
+        			//return TextConverter.export(textFlow,
+        			//                         TextConverter.PLAIN_TEXT_FORMAT);
+        			
+        			// TODO this is probably expensive. is there a way to cache
+        			//      this and know when dirty?
+        			//TODO  look at the generation and determine when it's dirty
+        			return exportToString(textFlow);
+    		    }
+    		    
+    		    case ROLE_SYSTEM_STATICTEXT:
+		        default:
+            		return null;
+    		}
+		}
+
+		/**
+		 * Handles COMPOSITION_COMPLETE and SELECTION_CHANGE events,
+		 * updates the MSAA model.
+    	 */
+    	protected function eventHandler(event:Event):void
+    	{
+    		switch (event.type)
+    		{
+                // This updates the entire accessibility DOM.
+                // get_accName is probably expensive here, it happens ONLY if
+                // JAWS is running, otherwise Accessibility.* calls are NOOP.
+                //
+                // Event does NOT fire when interactionManager changes; ideally
+                // we'd want to tell MSAA the role changed, but apparently roles
+                // are typically static and that's not a supported workflow.
+                // instead, Flash occasionally polls the displaylist, e.g. when
+                // you mouseover. calling updateProperties() doesn't necessarily
+                // trigger role updates (calls to get_acc*()).
+    			case CompositionCompleteEvent.COMPOSITION_COMPLETE:
+    			{
+    			    // TODO change childID from 0 if we use getChildIDArray
+    			    //      otherwise delete this comment
+	 				try {
+	    				Accessibility.sendEvent(textContainer, 0,
+    					                        EVENT_OBJECT_NAMECHANGE);
+    					Accessibility.sendEvent(textContainer, 0,
+    					                        EVENT_OBJECT_VALUECHANGE);
+    					Accessibility.updateProperties();
+					} catch (e_err:Error) {
+	 					// generic error occurred.
+                        // this can happen in the SA player since there is no
+                        // Accessibility implementation.
+	 				}
+    				break;
+    			}
+    			
+                //TODO when we have the FP selection APIs
+    			// case SelectionEvent.SELECTION_CHANGE:
+    			// {
+                //   // this is just stubbed code, I don't know what *needs* to
+                //   // be done for SELECTION_CHANGE
+    			// 	Accessibility.sendEvent(textContainer, 0,
+    			//                          EVENT_OBJECT_TEXTSELECTIONCHANGED);
+    			// 	Accessibility.updateProperties();
+    			// 	break;
+    			// }
+    		}
+    	}
+		
+		/**
+		 * TODO HACK, remove and refactor.
+		 * 
+		 * This is copied from PlainTextExportFilter, which I would prefer to
+		 * access through TextConverter.export(textFlow,
+		 *                                  TextConverter.PLAIN_TEXT_FORMAT);
+		 * 
+		 * But, PTEF is in importExport, which builds against text_model,
+		 * which is a circular dependency.
+		 * 
+		 * Also, it seems to be adding a trailing newline, which is bad for
+		 * accessibility unless it is really there.
+		 * 
+		 * Might want to export and strip out hyphens.
+		 * Move it to the model?
+		 */
+		private static function exportToString(source:TextFlow):String
+		{
+			var leaf:IFlowLeafElement = source.getFirstLeaf();
+			var rslt:String = "";
+			var curString:String = "";
+			var discretionaryHyphen:String = String.fromCharCode(0x00AD);
+			while (leaf)
+			{
+            	var p:IParagraphElement = leaf.getParagraph();
+            	while (true)
+            	{
+            		curString = leaf.text;
+            		
+            		//split out discretionary hyphen and put string back together
+					var temparray:Array = curString.split(discretionaryHyphen);
+					curString = temparray.join("");
+					
+	               	rslt += curString;
+					leaf = leaf.getNextLeaf(p);
+					if (!leaf)
+                    {
+                        // we want newlines between paragraphs but not at the end
+                    	rslt += "\n";
+						break;
+					}
+            	}
+            	leaf = p.getLastLeaf().getNextLeaf();
+   			}
+   			return rslt;
+		}
+		
+		/** 
+		 * The zero-based character index value of the first character in the current selection.
+		 * Components which wish to support inline IME or Accessibility should call into this method.
+		 *
+		 * @return the index of the character at the anchor end of the selection, or <code>-1</code> if no text is selected.
+		 * 
+		 * @playerversion Flash 10.0
+		 * @langversion 3.0
+		 */
+		public function get selectionActiveIndex():int
+		{
+			var selMgr:ISelectionManager = textFlow.interactionManager;
+			var selIndex:int = -1;
+			if(selMgr && selMgr.editingMode != EditingMode.READ_ONLY)
+			{
+				selIndex = selMgr.activePosition;
+			}
+			
+			return selIndex;
+		}
+		
+		/** 
+		 * The zero-based character index value of the last character in the current selection.
+		 * Components which wish to support inline IME or Accessibility should call into this method.
+		 *
+		 * @return the index of the character at the active end of the selection, or <code>-1</code> if no text is selected.
+		 * 
+		 * @playerversion Flash 10.0
+		 * @langversion 3.0
+		 */
+		public function get selectionAnchorIndex():int
+		{
+			var selMgr:ISelectionManager = textFlow.interactionManager;
+			var selIndex:int = -1;
+			if(selMgr && selMgr.editingMode != EditingMode.READ_ONLY)
+			{
+				selIndex = selMgr.anchorPosition;
+			}
+			
+			return selIndex;
+		}
+		
+		/** Enable search index for Ichabod
+		 * Returns the entire text of the TextFlow, or null if search index is not enabled
+		 * @see GlobalSettings.searchIndexEnabled
+		 */
+		public function get searchText():String
+		{
+			return GlobalSettings.enableSearch ? textFlow.getText() : null;
+		}
+		
+	}
+}
+


[27/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/TextLayoutImporter.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/TextLayoutImporter.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/TextLayoutImporter.as
new file mode 100644
index 0000000..dca3eb3
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/TextLayoutImporter.as
@@ -0,0 +1,674 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion 
+{
+	import org.apache.flex.textLayout.TextLayoutVersion;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.elements.BreakElement;
+	import org.apache.flex.textLayout.elements.DivElement;
+	import org.apache.flex.textLayout.elements.ElementHelper;
+	import org.apache.flex.textLayout.elements.FlowGroupElement;
+	import org.apache.flex.textLayout.elements.GlobalSettings;
+	import org.apache.flex.textLayout.elements.IDivElement;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	import org.apache.flex.textLayout.elements.IListElement;
+	import org.apache.flex.textLayout.elements.IListItemElement;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.ISpanElement;
+	import org.apache.flex.textLayout.elements.ITableElement;
+	import org.apache.flex.textLayout.elements.InlineGraphicElement;
+	import org.apache.flex.textLayout.elements.LinkElement;
+	import org.apache.flex.textLayout.elements.ListElement;
+	import org.apache.flex.textLayout.elements.ListItemElement;
+	import org.apache.flex.textLayout.elements.SpanElement;
+	import org.apache.flex.textLayout.elements.SubParagraphGroupElement;
+	import org.apache.flex.textLayout.elements.TCYElement;
+	import org.apache.flex.textLayout.elements.TabElement;
+	import org.apache.flex.textLayout.elements.TableCellElement;
+	import org.apache.flex.textLayout.elements.TableElement;
+	import org.apache.flex.textLayout.elements.TableRowElement;
+	import org.apache.flex.textLayout.elements.TextFlow;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+	import org.apache.flex.textLayout.property.PropertyFactory;
+	import org.apache.flex.textLayout.utils.FactoryUtil;
+	import org.apache.flex.utils.ObjectMap;
+	
+
+
+	/** 
+	 * @private
+	 * TextLayoutImporter converts from XML to TextLayout data structures and back.
+	 */ 	
+	public class TextLayoutImporter extends BaseTextLayoutImporter implements ITextLayoutImporter
+	{
+		private static var _defaultConfiguration:ImportExportConfiguration;
+		
+		/** Default ImportExportConfiguration to use when none specified 
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0 
+		*/
+		public static function get defaultConfiguration():ImportExportConfiguration
+		{
+			// The first call will force the import/export to include the standard components
+			if (!_defaultConfiguration)
+			{
+				_defaultConfiguration = new ImportExportConfiguration();
+				// elements
+	 			_defaultConfiguration.addIEInfo("TextFlow", TextFlow,        BaseTextLayoutImporter.parseTextFlow,	BaseTextLayoutExporter.exportTextFlow);
+				_defaultConfiguration.addIEInfo("br", BreakElement,          BaseTextLayoutImporter.parseBreak,		BaseTextLayoutExporter.exportFlowElement);
+				_defaultConfiguration.addIEInfo("p", IParagraphElement,       BaseTextLayoutImporter.parsePara,		BaseTextLayoutExporter.exportParagraphFormattedElement);
+				_defaultConfiguration.addIEInfo("span", SpanElement,         BaseTextLayoutImporter.parseSpan,		BaseTextLayoutExporter.exportSpan);
+				_defaultConfiguration.addIEInfo("tab", TabElement,           BaseTextLayoutImporter.parseTab,		BaseTextLayoutExporter.exportFlowElement);
+				_defaultConfiguration.addIEInfo("list", ListElement,  		 BaseTextLayoutImporter.parseList,		BaseTextLayoutExporter.exportList);
+				_defaultConfiguration.addIEInfo("li", ListItemElement,       BaseTextLayoutImporter.parseListItem,	BaseTextLayoutExporter.exportListItem);
+				_defaultConfiguration.addIEInfo("g", SubParagraphGroupElement, TextLayoutImporter.parseSPGE, 		TextLayoutExporter.exportSPGE);
+				_defaultConfiguration.addIEInfo("tcy", TCYElement,           TextLayoutImporter.parseTCY, 			TextLayoutExporter.exportTCY);
+				_defaultConfiguration.addIEInfo("a", LinkElement,            TextLayoutImporter.parseLink, 			TextLayoutExporter.exportLink);
+	 			_defaultConfiguration.addIEInfo("div", DivElement,           TextLayoutImporter.parseDivElement, 	TextLayoutExporter.exportDiv);
+				_defaultConfiguration.addIEInfo("img", InlineGraphicElement, TextLayoutImporter.parseInlineGraphic, TextLayoutExporter.exportImage);	
+				_defaultConfiguration.addIEInfo("table", TableElement, 		 TextLayoutImporter.parseTable,     	TextLayoutExporter.exportTable);	
+				_defaultConfiguration.addIEInfo("tr", TableRowElement, 	     TextLayoutImporter.parseTableRow,	    TextLayoutExporter.exportTableRow);	
+				_defaultConfiguration.addIEInfo("th", TableCellElement, 	 TextLayoutImporter.parseTableCell,  	TextLayoutExporter.exportTableCell);	
+				_defaultConfiguration.addIEInfo("td", TableCellElement, 	 TextLayoutImporter.parseTableCell,  	TextLayoutExporter.exportTableCell);	
+				
+				// validate the defaultTypeName values.  They are to match the TLF format export xml names
+				CONFIG::debug 
+				{
+					for (var name:String in _defaultConfiguration.flowElementInfoList)
+					{
+						var info:FlowElementInfo = _defaultConfiguration.flowElementInfoList[name];
+						assert(name == (new info.flowClass).defaultTypeName,"Bad defaultTypeName in "+info.flowClass);
+					}
+				}
+				// customized link formats
+				_defaultConfiguration.addIEInfo("linkNormalFormat",null,TextLayoutImporter.parseLinkNormalFormat,null);
+				_defaultConfiguration.addIEInfo("linkActiveFormat",null,TextLayoutImporter.parseLinkActiveFormat,null);
+				_defaultConfiguration.addIEInfo("linkHoverFormat", null,TextLayoutImporter.parseLinkHoverFormat, null);
+				// list marker format
+				_defaultConfiguration.addIEInfo("ListMarkerFormat",null,TextLayoutImporter.parseListMarkerFormat,null);
+			}
+			
+			return _defaultConfiguration;
+		}
+		
+		/** Set the default configuration back to its original value 
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0
+	 	*/
+		public static function restoreDefaults():void
+		{
+			_defaultConfiguration = null;
+		}
+				
+		static private const _formatImporter:TLFormatImporter = new TLFormatImporter(TextLayoutFormat,TextLayoutFormat.description);
+		static private const _idImporter:SingletonAttributeImporter = new SingletonAttributeImporter("id");
+		static private const _typeNameImporter:SingletonAttributeImporter = new SingletonAttributeImporter("typeName");
+		static private const _customFormatImporter:CustomFormatImporter = new CustomFormatImporter();
+		
+		static private const _flowElementFormatImporters:Array = [ _formatImporter,_idImporter,_typeNameImporter,_customFormatImporter ];
+		
+		private var _imageSourceResolveFunction:Function;
+
+		/** Constructor */
+		public function TextLayoutImporter()
+		{
+			super(new Namespace("flow", "http://ns.adobe.com/textLayout/2008"), defaultConfiguration);
+		}
+		
+		/** @copy ITextLayoutImporter#imageSourceResolveFunction
+		 * 
+		 * @playerversion Flash 10.0
+		 * @playerversion AIR 2.0
+		 * @langversion 3.0
+		 */
+		public function get imageSourceResolveFunction():Function
+		{ return _imageSourceResolveFunction; }
+		public function set imageSourceResolveFunction(resolver:Function):void
+		{ _imageSourceResolveFunction = resolver; }
+		
+		
+		/**  @private */
+		override protected function parseContent(rootStory:XML):TextFlow
+		{
+			// Capture all the top-level tags of interest that can be "bound"
+			// We have to do this because the attributes are applied at the point
+			// of calling something like:
+			// span.charAttrs = characterAttrs;
+			// At one time, we just set the variable to the parameter (in the setter),
+			// but now we're copying the data into a new object. This change does
+			// not allow for us to parse the bindings in any order. Hence, we
+			// will process the potential bindings objects first, then the
+			// TextFlow objects.
+			//
+			// Also note the use of "..*" below. We are using this to traverse the
+			// XML structure looking for particular tags and at the same time allow for
+			// any namespace. So, you might see something like <flow:TextContainer> or
+			// <TextContainer> and this code will capture both cases.
+			
+			var rootName:String = rootStory.name().localName;
+			var textFlowElement:XML = rootName == "TextFlow" ? rootStory : rootStory..*::TextFlow[0];
+			if (!textFlowElement)
+			{
+				reportError(GlobalSettings.resourceStringFunction("missingTextFlow")); 
+				return null;
+			}
+			if (!checkNamespace(textFlowElement))
+				return null;
+	
+			return parseTextFlow(this, textFlowElement);
+		}
+		
+		private function parseStandardFlowElementAttributes(flowElem:IFlowElement,xmlToParse:XML,importers:Array = null):void
+		{
+			if (importers == null)
+				importers = _flowElementFormatImporters;
+			// all the standard ones have to be in importers - some check needed
+			parseAttributes(xmlToParse,importers);
+			
+			var textFormat:TextLayoutFormat = extractTextFormatAttributesHelper(flowElem.format,_formatImporter) as TextLayoutFormat;
+			if (textFormat)
+			{
+				CONFIG::debug { assert(textFormat.getStyles() != null,"Bad TextFormat in parseStandardFlowElementAttributes"); }
+				flowElem.format = textFormat;
+			}
+
+			if (_idImporter.result)
+				flowElem.id = _idImporter.result as String;
+			if (_typeNameImporter.result)
+				flowElem.typeName = _typeNameImporter.result as String;
+			if (_customFormatImporter.result)
+			{
+				for (var styleName:String in _customFormatImporter.result)
+					flowElem.setStyle(styleName,_customFormatImporter.result[styleName]);
+			}
+		}
+		
+
+		override public function createTextFlowFromXML(xmlToParse:XML, textFlow:TextFlow = null):TextFlow
+		{
+			// allocate the TextFlow and set the TextContainer's rootElement to it.
+			var newFlow:TextFlow = null;
+
+			if (!checkNamespace(xmlToParse))
+				return newFlow;
+
+//TODO @
+			if (xmlToParse.hasOwnProperty("@version"))
+			{
+				var version:String = xmlToParse.@version;
+				if (version == "3.0.0")
+					_importVersion = TextLayoutVersion.VERSION_3_0;
+				else if (version == "2.0.0")
+					_importVersion = TextLayoutVersion.VERSION_2_0;
+				else if (version == "1.1.0" || version == "1.0.0")
+					_importVersion = TextLayoutVersion.VERSION_1_0;
+				else
+				{
+					reportError(GlobalSettings.resourceStringFunction("unsupportedVersion",[ xmlToParse.@version ]));
+					_importVersion = TextLayoutVersion.CURRENT_VERSION;
+				}
+			}
+			else		// we must be the first version
+				_importVersion = TextLayoutVersion.VERSION_1_0;
+				
+			// allocate the TextFlow and initialize the container attributes
+			if (!newFlow)
+				newFlow = new TextFlow(FactoryUtil.defaultTLFFactory);
+	
+			// parse formatting
+			parseStandardFlowElementAttributes(newFlow,xmlToParse);
+			
+			// descend into children
+			parseFlowGroupElementChildren(xmlToParse, newFlow);
+			
+			CONFIG::debug { newFlow.debugCheckNormalizeAll() ; }
+			newFlow.normalize();
+			
+			newFlow.applyWhiteSpaceCollapse(null);
+			
+			return newFlow;
+		}
+		
+		public function createDivFromXML(xmlToParse:XML):IDivElement
+		{
+			// add the div element to the parent
+			var divElem:IDivElement = new DivElement();
+			
+			parseStandardFlowElementAttributes(divElem,xmlToParse);
+
+			return divElem;
+		}
+		
+		/**
+		 * Create a table element from XML
+		 **/
+		public function createTableFromXML(xmlToParse:XML):ITableElement
+		{
+			// add the table element to the parent
+			var tableElement:TableElement = new TableElement();
+			
+			parseStandardFlowElementAttributes(tableElement, xmlToParse);
+
+			return tableElement;
+		}
+		
+		/**
+		 * Create a table row element from XML
+		 **/
+		public function createTableRowFromXML(xmlToParse:XML):TableRowElement
+		{
+			// add the table row element to the parent
+			var tableRowElement:TableRowElement = new TableRowElement();
+			
+			parseStandardFlowElementAttributes(tableRowElement, xmlToParse);
+			
+			return tableRowElement;
+		}
+		
+		/**
+		 * Create a table cell element from XML
+		 **/
+		public function createTableCellFromXML(xmlToParse:XML):TableCellElement
+		{
+			// add the table cell element to the parent
+			var tableCellElement:TableCellElement = new TableCellElement();
+			
+			parseStandardFlowElementAttributes(tableCellElement, xmlToParse);
+			
+			return tableCellElement;
+		}
+		
+		/**
+		 * Create a paragraph element from XML
+		 **/
+		public override function createParagraphFromXML(xmlToParse:XML):IParagraphElement
+		{
+			var paraElem:IParagraphElement = ElementHelper.getParagraph();
+			parseStandardFlowElementAttributes(paraElem,xmlToParse);
+			return paraElem;
+		}
+		
+		/**
+		 * Create a sub paragraph group element from XML
+		 **/
+		public function createSubParagraphGroupFromXML(xmlToParse:XML):SubParagraphGroupElement
+		{
+			var elem:SubParagraphGroupElement = new SubParagraphGroupElement();
+			parseStandardFlowElementAttributes(elem,xmlToParse);
+			return elem;
+		}
+		
+		/**
+		 * Create a tate chu yoko element from XML
+		 **/
+		public function createTCYFromXML(xmlToParse:XML):TCYElement
+		{
+			var tcyElem:TCYElement = new TCYElement();
+			parseStandardFlowElementAttributes(tcyElem,xmlToParse);
+			return tcyElem;
+		}
+		
+		
+		static internal const _linkDescription:Object = {
+			"href" : PropertyFactory.string("href",null, false, null),
+			"target" : PropertyFactory.string("target",null, false, null)
+		};
+		static private const _linkFormatImporter:TLFormatImporter = new TLFormatImporter(ObjectMap,_linkDescription);
+		static private const _linkElementFormatImporters:Array = [ _linkFormatImporter, _formatImporter,_idImporter,_typeNameImporter,_customFormatImporter ];
+
+		/** 
+		 * Parse a LinkElement Block.
+		 * 
+		 * @param - importFilter:BaseTextLayoutImporter - parser object
+		 * @param - xmlToParse:XML - the xml describing the Link
+		 * @param - parent:FlowBlockElement - the parent of the new Link
+		 * @return LinkElement - a new LinkElement and its children
+		 */
+		public function createLinkFromXML(xmlToParse:XML):LinkElement
+		{
+			var linkElem:LinkElement = new LinkElement();
+			parseStandardFlowElementAttributes(linkElem,xmlToParse,_linkElementFormatImporters);
+			if (_linkFormatImporter.result)
+			{
+				linkElem.href = _linkFormatImporter.result["href"] as String;
+				linkElem.target = _linkFormatImporter.result["target"] as String;
+			}
+
+			return linkElem;
+		}
+		
+		/**
+		 * Create a span element from XML
+		 **/
+		public override function createSpanFromXML(xmlToParse:XML):ISpanElement
+		{
+			var spanElem:SpanElement = new SpanElement();
+			
+			parseStandardFlowElementAttributes(spanElem,xmlToParse);
+
+			return spanElem;
+		}
+		
+		static private const _imageDescription:Object = {
+			"height":InlineGraphicElement.heightPropertyDefinition,
+			"width":InlineGraphicElement.widthPropertyDefinition,
+			"source": PropertyFactory.string("source", null, false, null),
+			"float": PropertyFactory.string("float", null, false, null),
+			"rotation": InlineGraphicElement.rotationPropertyDefinition };
+		
+		static private const _ilgFormatImporter:TLFormatImporter = new TLFormatImporter(ObjectMap,_imageDescription);
+		static private const _ilgElementFormatImporters:Array = [ _ilgFormatImporter, _formatImporter, _idImporter, _typeNameImporter, _customFormatImporter ];
+
+		/**
+		 * Create an inline graphic from XML
+		 **/
+		public function createInlineGraphicFromXML(xmlToParse:XML):InlineGraphicElement
+		{				
+			var imgElem:InlineGraphicElement = new InlineGraphicElement();
+			
+			parseStandardFlowElementAttributes(imgElem,xmlToParse,_ilgElementFormatImporters);
+			
+			if (_ilgFormatImporter.result)
+			{
+				var source:String = _ilgFormatImporter.result["source"];
+				imgElem.source = _imageSourceResolveFunction != null ? _imageSourceResolveFunction(source) : source;
+				
+				// if not defined then let InlineGraphic set its own default
+				imgElem.height = _ilgFormatImporter.result["height"];
+				imgElem.width  = _ilgFormatImporter.result["width"];
+				/*	We don't support rotation yet because of bugs in the player. */		
+				// imgElem.rotation  = InlineGraphicElement.heightPropertyDefinition.setHelper(imgElem.rotation,_ilgFormatImporter.result["rotation"]);
+				imgElem.float = _ilgFormatImporter.result["float"];
+			}
+			
+			return imgElem;
+		}
+	
+		/**
+		 * Create a list element from XML
+		 **/
+		public override function createListFromXML(xmlToParse:XML):IListElement
+		{
+			var rslt:IListElement = ElementHelper.getList();
+			parseStandardFlowElementAttributes(rslt,xmlToParse);
+			return rslt;
+		}
+
+		/**
+		 * Create a list item element from XML
+		 **/
+		public override function createListItemFromXML(xmlToParse:XML):IListItemElement
+		{
+			var rslt:IListItemElement = ElementHelper.getListItem();
+			parseStandardFlowElementAttributes(rslt,xmlToParse);
+			return rslt;
+		}
+		
+		/**
+		 * Extract text format attributes
+		 **/
+		public function extractTextFormatAttributesHelper(curAttrs:Object, importer:TLFormatImporter):Object
+		{
+			return extractAttributesHelper(curAttrs,importer);
+		}
+		
+		/** 
+		 * Parse an SPGE element
+		 * 
+		 * @param - importFilter:BaseTextLayoutImporter - parser object
+		 * @param - xmlToParse:XML - the xml describing the TCY Block
+		 * @param - parent:FlowBlockElement - the parent of the new TCY Block
+		 * @return SubParagraphGroupElement - a new TCYBlockElement and its children
+		 */
+		static public function parseSPGE(importFilter:BaseTextLayoutImporter, xmlToParse:XML, parent:FlowGroupElement):void
+		{
+			var elem:SubParagraphGroupElement = TextLayoutImporter(importFilter).createSubParagraphGroupFromXML(xmlToParse);
+			if (importFilter.addChild(parent, elem))
+			{
+				importFilter.parseFlowGroupElementChildren(xmlToParse, elem);
+				//if parsing an empty tcy, create a Span for it.
+				if (elem.numChildren == 0)
+					elem.addChild(new SpanElement());
+			}
+		}
+
+		/** 
+		 * Parse a TCY Block.
+		 * 
+		 * @param - importFilter:BaseTextLayoutImporter - parser object
+		 * @param - xmlToParse:XML - the xml describing the TCY Block
+		 * @param - parent:FlowBlockElement - the parent of the new TCY Block
+		 * @return TCYBlockElement - a new TCYBlockElement and its children
+		 */
+		static public function parseTCY(importFilter:BaseTextLayoutImporter, xmlToParse:XML, parent:FlowGroupElement):void
+		{
+			var tcyElem:TCYElement = TextLayoutImporter(importFilter).createTCYFromXML(xmlToParse);
+			if (importFilter.addChild(parent, tcyElem))
+			{
+				importFilter.parseFlowGroupElementChildren(xmlToParse, tcyElem);
+				//if parsing an empty tcy, create a Span for it.
+				if (tcyElem.numChildren == 0)
+					tcyElem.addChild(new SpanElement());
+			}
+		}
+		
+				
+		/** 
+		 * Parse a LinkElement Block.
+		 * 
+		 * @param - importFilter:BaseTextLayoutImporter - parser object
+		 * @param - xmlToParse:XML - the xml describing the Link
+		 * @param - parent:FlowBlockElement - the parent of the new Link
+		 * @return LinkElement - a new LinkElement and its children
+		 */
+		static public function parseLink(importFilter:BaseTextLayoutImporter, xmlToParse:XML, parent:FlowGroupElement):void
+		{
+			var linkElem:LinkElement = TextLayoutImporter(importFilter).createLinkFromXML(xmlToParse);
+			if (importFilter.addChild(parent, linkElem))
+			{
+				importFilter.parseFlowGroupElementChildren(xmlToParse, linkElem);
+				//if parsing an empty link, create a Span for it.
+				if (linkElem.numChildren == 0)
+					linkElem.addChild(new SpanElement());
+			}
+		}
+		
+		public function createDictionaryFromXML(xmlToParse:XML):ObjectMap
+		{
+			var formatImporters:Array = [ _customFormatImporter ];
+
+			// parse the TextLayoutFormat child object		
+			var formatList:XMLList = xmlToParse..*::TextLayoutFormat;
+			if (formatList.length() != 1)
+				reportError(GlobalSettings.resourceStringFunction("expectedExactlyOneTextLayoutFormat",[ xmlToParse.name() ]));
+			
+			var parseThis:XML = formatList.length() > 0 ? formatList[0] : xmlToParse;
+			parseAttributes(parseThis,formatImporters);
+			return _customFormatImporter.result as ObjectMap;
+		}
+
+		static public function parseLinkNormalFormat(importFilter:BaseTextLayoutImporter, xmlToParse:XML, parent:FlowGroupElement):void
+		{ parent.linkNormalFormat = TextLayoutImporter(importFilter).createDictionaryFromXML(xmlToParse); }
+		static public function parseLinkActiveFormat(importFilter:BaseTextLayoutImporter, xmlToParse:XML, parent:FlowGroupElement):void
+		{ parent.linkActiveFormat = TextLayoutImporter(importFilter).createDictionaryFromXML(xmlToParse); }
+		static public function parseLinkHoverFormat(importFilter:BaseTextLayoutImporter, xmlToParse:XML, parent:FlowGroupElement):void
+		{ parent.linkHoverFormat = TextLayoutImporter(importFilter).createDictionaryFromXML(xmlToParse); }
+		
+		public function createListMarkerFormatDictionaryFromXML(xmlToParse:XML):ObjectMap
+		{
+			var formatImporters:Array = [ _customFormatImporter ];
+			
+			// parse the TextLayoutFormat child object		
+			var formatList:XMLList = xmlToParse..*::ListMarkerFormat;
+			if (formatList.length() != 1)
+				reportError(GlobalSettings.resourceStringFunction("expectedExactlyOneListMarkerFormat",[ xmlToParse.name() ]));
+			
+			var parseThis:XML = formatList.length() > 0 ? formatList[0] : xmlToParse;
+			parseAttributes(parseThis,formatImporters);
+			return _customFormatImporter.result as ObjectMap;
+		}
+		
+		static public function parseListMarkerFormat(importFilter:BaseTextLayoutImporter, xmlToParse:XML, parent:FlowGroupElement):void
+		{ parent.listMarkerFormat = TextLayoutImporter(importFilter).createListMarkerFormatDictionaryFromXML(xmlToParse); }
+
+		/** 
+		 * Parse the <div ...> tag and all its children
+		 * 
+		 * @param - importFilter:BaseTextLayoutImportFilter - parser object
+		 * @param - xmlToParse:XML - the xml describing the Div
+		 * @param - parent:FlowBlockElement - the parent of the new Div
+		 */
+		static public function parseDivElement(importFilter:BaseTextLayoutImporter, xmlToParse:XML, parent:FlowGroupElement):void
+		{
+			var divElem:IDivElement = TextLayoutImporter(importFilter).createDivFromXML(xmlToParse);
+			if (importFilter.addChild(parent, divElem))
+			{
+				importFilter.parseFlowGroupElementChildren(xmlToParse, divElem);
+				// we can't have a <div> tag w/no children... so, add an empty paragraph
+				if (divElem.numChildren == 0)
+					divElem.addChild(ElementHelper.getParagraph());
+			}
+		}
+
+		/** 
+		 * Parse a leaf element, the <img ...>  tag.
+		 * 
+		 * @param - importFilter:BaseTextLayoutImporter - parser object
+		 * @param - xmlToParse:XML - the xml describing the InlineGraphic FlowElement
+		 * @param - parent:FlowBlockElement - the parent of the new image FlowElement
+		 */
+		static public function parseInlineGraphic(importFilter:BaseTextLayoutImporter, xmlToParse:XML, parent:FlowGroupElement):void
+		{
+			var ilg:InlineGraphicElement = TextLayoutImporter(importFilter).createInlineGraphicFromXML(xmlToParse);
+			importFilter.addChild(parent, ilg);
+		}
+		
+		/** 
+		 * Parse the <table ...> tag and all its children
+		 * 
+		 * @param - importFilter:BaseTextLayoutImportFilter - parser object
+		 * @param - xmlToParse:XML - the xml describing the Table
+		 * @param - parent:FlowBlockElement - the parent of the new Table
+		 */
+		static public function parseTable(importFilter:BaseTextLayoutImporter, xmlToParse:XML, parent:FlowGroupElement):void
+		{
+			var tableElement:ITableElement = TextLayoutImporter(importFilter).createTableFromXML(xmlToParse);
+			
+			if (importFilter.addChild(parent, tableElement)) 
+			{
+				importFilter.parseFlowGroupElementChildren(xmlToParse, tableElement);
+				
+			}
+		}
+		
+		/** 
+		 * Parse the <tr ...> tag (TableRowElement) and all its children
+		 * 
+		 * @param - importFilter:BaseTextLayoutImportFilter - parser object
+		 * @param - xmlToParse:XML - the xml describing the Table
+		 * @param - parent:FlowBlockElement - the parent of the new Table
+		 */
+		static public function parseTableRow(importFilter:BaseTextLayoutImporter, xmlToParse:XML, parent:FlowGroupElement):void
+		{
+			var tableRowElement:TableRowElement = TextLayoutImporter(importFilter).createTableRowFromXML(xmlToParse);
+			var table:ITableElement;
+			
+			if (importFilter.addChild(parent, tableRowElement))
+			{
+				
+				importFilter.parseFlowGroupElementChildren(xmlToParse, tableRowElement);
+				
+				table = tableRowElement.table;
+				
+				var columnCount:int = tableRowElement.getColumnCount();
+				
+				if (table.numColumns<columnCount) {
+					table.numColumns = columnCount;
+				}
+				
+				table.insertRow(tableRowElement, tableRowElement.mxmlChildren);
+				
+			}
+		}
+		
+		/** 
+		 * Parse the <td ...> or <th ...> tag (TableCellElement) and all its children
+		 * 
+		 * @param - importFilter:BaseTextLayoutImportFilter - parser object
+		 * @param - xmlToParse:XML - the xml describing the Table
+		 * @param - parent:FlowBlockElement - the parent of the new Table
+		 */
+		static public function parseTableCell(importFilter:BaseTextLayoutImporter, xmlToParse:XML, parent:FlowGroupElement):void
+		{
+			var tableCellElement:TableCellElement = TextLayoutImporter(importFilter).createTableCellFromXML(xmlToParse);
+			
+			if (importFilter.addChild(parent, tableCellElement))
+			{
+				importFilter.parseTableCellElementChildren(xmlToParse, tableCellElement);
+			}
+			
+			//tableCellElement.textFlow = getTextFlowContent("test cell");
+			
+			TableRowElement(parent).addCell(tableCellElement);
+			//TableRowElement(parent).getTable().addChild(tableCellElement);
+			//importFilter.parseFlowGroupElementChildren(xmlToParse, tableCellElement);
+			
+			// we can't have a <td> tag w/no children... so, add an empty text flow
+			//if (tableCellElement.numChildren == 0) {
+			//	tableCellElement.addChild(new TextFlow());
+			//}
+				
+		}
+		
+		/**
+		 * Creates default text flow from the text value passed in. Used for table cell text flows. 
+		 * Used for testing. May be removed in the future. 
+		 **/
+		static public function getTextFlowContent(text:String = null, selectable:Boolean = false, editable:Boolean = false):TextFlow {
+			var textFlowContent:TextFlow = new TextFlow(FactoryUtil.defaultTLFFactory);
+			var paragraph:IParagraphElement = ElementHelper.getParagraph();
+			var span:SpanElement = new SpanElement();
+			
+			if (text) {
+				span.text = text;
+			}
+			else {
+				span.text = "";
+			}
+			
+			paragraph.backgroundAlpha = 0.2;
+			paragraph.backgroundColor = 0xFF0000;
+			paragraph.addChild(span);
+			
+			if (editable) {
+				//textFlowContent.interactionManager = new EditManager(new UndoManager);
+			}
+			else if (selectable) {
+				//textFlowContent.interactionManager = new SelectionManager();
+			}
+			
+			textFlowContent.addChild(paragraph);
+			
+			return textFlowContent;
+		}
+	}
+}
+

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/importers/CaseInsensitiveTLFFormatImporter.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/importers/CaseInsensitiveTLFFormatImporter.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/importers/CaseInsensitiveTLFFormatImporter.as
new file mode 100644
index 0000000..69893e1
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/importers/CaseInsensitiveTLFFormatImporter.as
@@ -0,0 +1,54 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion.importers {
+	import org.apache.flex.textLayout.conversion.TLFormatImporter;
+
+/** Specialized to provide case insensitivity (as required by TEXT_FIELD_HTML_FORMAT)
+ *  Keys need to be lower-cased. Values may or may not based on a flag passed to the constructor. 
+ */
+public class CaseInsensitiveTLFFormatImporter extends TLFormatImporter
+{
+	private var _convertValuesToLowerCase:Boolean;
+
+	public function CaseInsensitiveTLFFormatImporter(classType:Class,description:Object, convertValuesToLowerCase:Boolean=true)
+	{
+		_convertValuesToLowerCase = convertValuesToLowerCase;
+		
+		var lowerCaseDescription:Object = {};
+		for (var prop:Object in description)
+		{
+			lowerCaseDescription[prop.toUpperCase()] = description[prop];
+		}
+		
+		super(classType, lowerCaseDescription);
+	}
+	
+	public override function importOneFormat(key:String,val:String):Boolean
+	{
+		return super.importOneFormat(key.toUpperCase(), _convertValuesToLowerCase ? val.toLowerCase() : val);  
+	} 
+	
+	public function getFormatValue (key:String):*
+	{
+		return result ? result[key.toUpperCase()] : undefined;
+	}
+	
+}
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/importers/FontImporter.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/importers/FontImporter.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/importers/FontImporter.as
new file mode 100644
index 0000000..1325567
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/importers/FontImporter.as
@@ -0,0 +1,38 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion.importers {
+	import org.apache.flex.textLayout.conversion.TLFormatImporter;
+
+	public class FontImporter extends TLFormatImporter {
+		public function FontImporter(classType:Class, description:Object) {
+			super(classType, description);
+		}
+
+		public override function importOneFormat(key:String, val:String):Boolean {
+			key = key.toUpperCase();
+			if (key == "LETTERSPACING")
+				key = "trackingRight";
+			else if (key == "FACE")
+				key = "fontFamily";
+			else if (key == "COLOR")
+				key = "color";
+			return super.importOneFormat(key, val);  // no case-coversion required, values for these formats in TLF are case-insensitive
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/importers/HtmlCustomParaFormatImporter.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/importers/HtmlCustomParaFormatImporter.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/importers/HtmlCustomParaFormatImporter.as
new file mode 100644
index 0000000..29eaf2c
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/importers/HtmlCustomParaFormatImporter.as
@@ -0,0 +1,35 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion.importers {
+	import org.apache.flex.textLayout.conversion.TLFormatImporter;
+
+	public class HtmlCustomParaFormatImporter extends TLFormatImporter {
+		public function HtmlCustomParaFormatImporter(classType:Class, description:Object) {
+			super(classType, description);
+		}
+
+		public override function importOneFormat(key:String, val:String):Boolean {
+			key = key.toUpperCase();
+
+			if (key == "ALIGN")
+				key = "textAlign";
+			return super.importOneFormat(key, val.toLowerCase()); // covert val to lowercase because TLF won't accept, say, "RIGHT"
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/importers/TextFormatImporter.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/importers/TextFormatImporter.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/importers/TextFormatImporter.as
new file mode 100644
index 0000000..1dc35a4
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/importers/TextFormatImporter.as
@@ -0,0 +1,46 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion.importers {
+	import org.apache.flex.textLayout.conversion.TLFormatImporter;
+
+	public class TextFormatImporter extends TLFormatImporter {
+		public function TextFormatImporter(classType:Class, description:Object) {
+			super(classType, description);
+		}
+
+		public override function importOneFormat(key:String, val:String):Boolean {
+			key = key.toUpperCase();
+
+			if (key == "LEFTMARGIN")
+				key = "paragraphStartIndent"; // assumed to be left-to-right text since we don't handle DIR attribute
+			else if (key == "RIGHTMARGIN")
+				key = "paragraphEndIndent";   // assumed to be left-to-right text since we don't handle DIR attribute
+			else if (key == "INDENT")
+				key = "textIndent";
+			else if (key == "LEADING")
+				key = "lineHeight";
+			else if (key == "TABSTOPS") {
+				key = "tabStops";
+				// Comma-delimited in TextField HTML format, space delimited in TLF
+				val = val.replace(/,/g, ' ');
+			}
+			return super.importOneFormat(key, val); // no case-coversion required, values for these formats in TLF are case-insensitive
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/BitmapData.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/BitmapData.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/BitmapData.as
new file mode 100644
index 0000000..6301b20
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/BitmapData.as
@@ -0,0 +1,31 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.dummy {
+	import org.apache.flex.geom.Rectangle;
+	import org.apache.flex.geom.Matrix;
+	public class BitmapData {
+		public function BitmapData(width:int, height:int, transparent:Boolean = true, fillColor:uint = 0xFFFFFFFF){
+
+		}
+
+		public function draw(source : IBitmapDrawable, matrix : Matrix = null, colorTransform : ColorTransform = null, blendMode : String = null, clipRect : Rectangle = null, smoothing : Boolean = false) : void {
+
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/BoundsUtil.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/BoundsUtil.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/BoundsUtil.as
new file mode 100644
index 0000000..a3409c9
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/BoundsUtil.as
@@ -0,0 +1,29 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.dummy {
+	import org.apache.flex.geom.Rectangle;
+	import org.apache.flex.core.IUIBase;
+	public class BoundsUtil {
+		static public function getBounds(child:IUIBase,parent:IUIBase):Rectangle{
+			//TODO implement getting bounds
+			child;parent;
+			return null;
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/Clipboard.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/Clipboard.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/Clipboard.as
new file mode 100644
index 0000000..ca0fed1
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/Clipboard.as
@@ -0,0 +1,36 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.dummy {
+	public class Clipboard {
+		public static var generalClipboard : Clipboard;
+
+		public function hasFormat(format : String) : Boolean {
+			return false;
+		}
+
+		public function getData(clipboardFormat : String) : void {
+		}
+
+		public function clear() : void {
+		}
+
+		public function setData(clipboardFormat : String, clipboardData : String) : void {
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/ColorTransform.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/ColorTransform.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/ColorTransform.as
new file mode 100644
index 0000000..d654275
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/ColorTransform.as
@@ -0,0 +1,22 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.dummy {
+	public class ColorTransform {
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/ContextMenu.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/ContextMenu.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/ContextMenu.as
new file mode 100644
index 0000000..f79776c
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/ContextMenu.as
@@ -0,0 +1,28 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.dummy {
+	public class ContextMenu {
+		public var builtInItems:ContextMenuBuiltInItems;
+		public var clipboardItems:ContextMenuClipboardItems;
+		public var clipboardMenu:Boolean;
+		public var customItems:Array;
+		public var isSupported:Boolean;
+		public var items:Array;
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/ContextMenuBuiltInItems.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/ContextMenuBuiltInItems.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/ContextMenuBuiltInItems.as
new file mode 100644
index 0000000..68e179a
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/ContextMenuBuiltInItems.as
@@ -0,0 +1,31 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.dummy {
+	public class ContextMenuBuiltInItems {
+
+		public var forwardAndBack:Boolean;
+		public var loop:Boolean;
+		public var play:Boolean;
+		public var print:Boolean;
+		public var quality:Boolean;
+		public var rewind:Boolean;
+		public var save:Boolean;
+		public var zoom:Boolean;
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/ContextMenuClipboardItems.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/ContextMenuClipboardItems.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/ContextMenuClipboardItems.as
new file mode 100644
index 0000000..83346b9
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/ContextMenuClipboardItems.as
@@ -0,0 +1,28 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.dummy {
+	public class ContextMenuClipboardItems {
+			
+		public var clear:Boolean;
+		public var copy:Boolean;
+		public var cut:Boolean;
+		public var paste:Boolean;
+		public var selectAll:Boolean;
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/IBitmapDrawable.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/IBitmapDrawable.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/IBitmapDrawable.as
new file mode 100644
index 0000000..245b2b4
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/IBitmapDrawable.as
@@ -0,0 +1,22 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.dummy {
+	public class IBitmapDrawable {
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/Mouse.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/Mouse.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/Mouse.as
new file mode 100644
index 0000000..21a9b14
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/Mouse.as
@@ -0,0 +1,29 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.dummy {
+	public class Mouse {
+		public static var cursor : String;
+
+		public static function registerCursor(name : String, cursor : MouseCursorData) : void {
+			
+		}
+
+	}
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/MouseCursor.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/MouseCursor.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/MouseCursor.as
new file mode 100644
index 0000000..993527e
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/MouseCursor.as
@@ -0,0 +1,28 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.dummy {
+	public class MouseCursor {
+
+		public static const ARROW:String = "arrow";
+		public static const AUTO:String = "auto";
+		public static const BUTTON:String = "button";
+		public static const HAND:String = "hand";
+		public static const IBEAM:String = "ibeam";
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/MouseCursorData.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/MouseCursorData.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/MouseCursorData.as
new file mode 100644
index 0000000..3691075
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/dummy/MouseCursorData.as
@@ -0,0 +1,26 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.dummy {
+	import org.apache.flex.geom.Point;
+	public class MouseCursorData {
+		public var data : Vector.<BitmapData>;
+		public var frameRate : Number;
+		public var hotSpot : Point;
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/ClipboardFormats.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/ClipboardFormats.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/ClipboardFormats.as
new file mode 100644
index 0000000..960b8cc
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/ClipboardFormats.as
@@ -0,0 +1,23 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.edit {
+	public class ClipboardFormats {
+		public static const TEXT_FORMAT : String = "TEXT_FORMAT";
+	}
+}
\ No newline at end of file


[33/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/ContainerController.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/ContainerController.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/ContainerController.as
new file mode 100644
index 0000000..3460da5
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/ContainerController.as
@@ -0,0 +1,5222 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.container 
+{
+	import org.apache.flex.textLayout.elements.GlobalSettings;
+	import org.apache.flex.textLayout.elements.IInlineGraphicElement;
+	import org.apache.flex.textLayout.compose.ITextFlowTableBlock;
+	import org.apache.flex.textLayout.elements.ITableRowElement;
+	import org.apache.flex.textLayout.utils.CreateTLFUtil;
+	import org.apache.flex.textLayout.elements.ITableCellElement;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.IFlowLeafElement;
+	import org.apache.flex.core.IChild;
+	import org.apache.flex.core.IParentIUIBase;
+	import org.apache.flex.core.IUIBase;
+	import org.apache.flex.events.Event;
+	import org.apache.flex.events.IEventDispatcher;
+	import org.apache.flex.events.KeyboardEvent;
+	import org.apache.flex.events.MouseEvent;
+	import org.apache.flex.geom.Matrix;
+	import org.apache.flex.geom.Point;
+	import org.apache.flex.geom.Rectangle;
+	import org.apache.flex.graphics.ICompoundGraphic;
+	import org.apache.flex.graphics.IRect;
+	import org.apache.flex.graphics.SolidColor;
+	import org.apache.flex.text.engine.ITextBlock;
+	import org.apache.flex.text.engine.ITextLine;
+	import org.apache.flex.text.events.IMEEvent;
+	import org.apache.flex.text.events.TextEvent;
+	import org.apache.flex.textLayout.compose.FloatCompositionData;
+	import org.apache.flex.textLayout.compose.FlowDamageType;
+	import org.apache.flex.textLayout.compose.IFlowComposer;
+	import org.apache.flex.textLayout.compose.ITextFlowLine;
+	import org.apache.flex.textLayout.compose.TextLineRecycler;
+	import org.apache.flex.textLayout.debug.Debugging;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.dummy.BoundsUtil;
+	import org.apache.flex.textLayout.dummy.ContextMenu;
+	import org.apache.flex.textLayout.edit.EditingMode;
+	import org.apache.flex.textLayout.edit.IInteractionEventHandler;
+	import org.apache.flex.textLayout.edit.ISelectionManager;
+	import org.apache.flex.textLayout.edit.SelectionFormat;
+	import org.apache.flex.textLayout.elements.IBackgroundManager;
+	import org.apache.flex.textLayout.elements.CellCoordinates;
+	import org.apache.flex.textLayout.elements.IContainerFormattedElement;
+	import org.apache.flex.textLayout.elements.TableBlockContainer;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.textLayout.events.ActivateEvent;
+	import org.apache.flex.textLayout.events.ContextMenuEvent;
+	import org.apache.flex.textLayout.events.EditEvent;
+	import org.apache.flex.textLayout.events.FlowElementMouseEventManager;
+	import org.apache.flex.textLayout.events.FocusEvent;
+	import org.apache.flex.textLayout.events.ModelChange;
+	import org.apache.flex.textLayout.events.ScrollEvent;
+	import org.apache.flex.textLayout.events.ScrollEventDirection;
+	import org.apache.flex.textLayout.events.SelectionEvent;
+	import org.apache.flex.textLayout.events.TextLayoutEvent;
+	import org.apache.flex.textLayout.events.UpdateCompleteEvent;
+	import org.apache.flex.textLayout.formats.BlockProgression;
+	import org.apache.flex.textLayout.formats.Float;
+	import org.apache.flex.textLayout.formats.FormatValue;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+	import org.apache.flex.textLayout.formats.TextLayoutFormatBase;
+
+	import org.apache.flex.textLayout.utils.Twips;
+	import org.apache.flex.utils.DisplayUtils;
+	import org.apache.flex.utils.ObjectMap;
+	import org.apache.flex.utils.PointUtils;
+	import org.apache.flex.utils.Timer;
+
+
+
+	/**
+	 * The ContainerController class defines the relationship between a TextFlow object and a container.
+	 * A TextFlow may have one or more rectangular areas that can hold text; the text is said to be flowing
+	 * through the containers. Each container is a Sprite that is the parent DisplayObject for the TextLines.
+	 * Each container has a ContainerController that manages the container; the controller holds the target 
+	 * width and height for the text area, populates the container with TextLines, and handles scrolling. A
+	 * controller also has a format associated with it that allows some formatting attributes to be applied 
+	 * to the text in the container. This allows, for instance, a TextFlow to have one container where the
+	 * text appears in a single column, and a second container in the same TextFlow with two column text. Not
+	 * all formatting attributes that can be applied to the container will affect the text; only the ones that
+	 * affect container-level layout. The diagram below illustrates the relationship between the TextFlow,
+	 * its flowComposer, and the display list.
+	 *
+	 * <p><img src="../../../images/textLayout_multiController.gif" alt="IContainerController"></img></p>
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 *
+	 * @see org.apache.flex.textLayout.compose.IFlowComposer
+	 * @see org.apache.flex.textLayout.elements.TextFlow
+	 * @see org.apache.flex.text.engine.ITextLine
+	 */
+	public class ContainerController extends TextLayoutFormatBase implements IInteractionEventHandler, ISandboxSupport, IContainerController
+	{		
+		
+		private var _textFlowCache:ITextFlow;
+		private var _rootElement:IContainerFormattedElement;
+		
+		private var _absoluteStart:int;
+		private var _textLength:int;
+		
+		private var _container:IParentIUIBase;
+		private var _mouseEventManager:FlowElementMouseEventManager;
+		
+		// note must be protected - subclass sets or gets this variable but can't be public
+		/** computed container attributes.  @private */
+		protected var _computedFormat:TextLayoutFormat;
+		
+		// Generated column information
+		// Generated column information
+		private var _columnState:ColumnState;
+		
+		/** Container size to be composed */
+		private var _compositionWidth:Number = 0;
+		private var _compositionHeight:Number = 0;
+		private var _measureWidth:Boolean; // true if we're measuring (isNaN(compositionWidth) optimization so we don't call isNaN too much
+		private var _measureHeight:Boolean; // true if we're measuring (isNaN(compositionHeight) optimization so we don't call isNaN too much
+		
+		/* Text bounds after composition */
+		private var _contentLeft:Number;
+		private var _contentTop:Number;
+		private var _contentWidth:Number;
+		private var _contentHeight:Number;
+		
+		private var _uncomposedTextLength:int;	// 0 if composition was complete when contentHeight, etc registered, greater than one otherwise
+		private var _finalParcelStart:int;
+		
+		// Scroll policy -- determines whether scrolling is enabled or not
+		private var _horizontalScrollPolicy:String;
+		private var _verticalScrollPolicy:String;
+		
+		// x, y location of the text in the container relative to the underlying scrollable area
+		private var _xScroll:Number;
+		private var _yScroll:Number;
+		
+		/** Are event listeners attached to the container */
+		private var _minListenersAttached:Boolean = false;
+		private var _allListenersAttached:Boolean = false;
+		private var _selectListenersAttached:Boolean = false;
+		public var _mouseWheelListenerAttached:Boolean = false;
+		
+		/** @private */
+		public function get allListenersAttached():Boolean
+		{ return _allListenersAttached; }
+		
+		/** Are the displayed shapes out of date? */
+		private var _shapesInvalid:Boolean = false;
+		
+		private var _backgroundShape:IUIBase;
+		
+		private var _scrollTimer:Timer = null;
+		
+		/**
+		 * @private use this boolean to determine if container.scrollRect is set.  Accessing scrollRect when null changes the rendering behavior of flash player.	
+		 */
+		protected var _hasScrollRect:Boolean;
+		
+		private var _linesInView:Array;	// lines that were in view according to the previous compose(). Empty if the lines have already been posted to the display list.
+		private var _updateStart:int;
+		private var _tableBlocksInView:Array; // // table blocks that were in view according to the previous compose(). Empty if the lines have already been posted to the display list.
+		
+		private var _composedFloats:Array;  // floats that were composed into the controller -- array of FloatCompositionData
+		private var _floatsInContainer:Array;  // floats are currently in view -- array of DisplayObject
+		
+		/** Interactive Objects **/
+		private var _interactiveObjects:ObjectMap = new ObjectMap(true);
+		private var _oldInteractiveObjects:Array = new Array();
+		
+		public function get interactiveObjects():ObjectMap
+		{
+			return _interactiveObjects ;
+		}
+		
+		public function get oldInteractiveObjects():Array
+		{
+			return _oldInteractiveObjects ;
+		}
+		
+		/** 
+		 * @private
+		 * 
+		 * <p>This property enables a client to test for a ScrollRect object without accessing 
+		 * the DisplayObject.scrollRect property, which can have side effects in some cases.</p> 
+		 *
+		 * @return true if the controller has attached a ScrollRect instance.
+		 */
+		public function get hasScrollRect():Boolean
+		{ return _hasScrollRect; }
+		
+		CONFIG::debug
+		{
+			protected var id:String;
+			private static var contCount:int = 0;
+		}
+		
+		private var _shapeChildren:Array;
+				
+		private var _containerRoot:IParentIUIBase;
+		
+		/* Controller have a non-zero default width and height so that if you construct a text example with a container and don't
+		* specify width and height you will still see some text so that you can then have a clue what to do to correct its appearance.
+		*/
+		
+		/** 
+		 * Constructor - creates a ContainerController instance. The ContainerController has a default <code>compositionWidth</code>
+		 * and <code>compositionHeight</code> so that some text appears in the container if you don't specify its width
+		 * height.
+		 *
+		 * @param container The DisplayObjectContainer in which to manage the text lines.
+		 * @param compositionWidth The initial width for composing text in the container.
+		 * @param compositionHeight The initial height for composing text in the container.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		
+		public function ContainerController(container:IParentIUIBase,compositionWidth:Number=100,compositionHeight:Number=100)
+		{
+			initialize(container,compositionWidth,compositionHeight);
+		}
+		
+		private function initialize(container:IParentIUIBase,compositionWidth:Number,compositionHeight:Number):void
+		{
+			_container = container;
+			_containerRoot =  null;
+			
+			_textLength = 0;
+			_absoluteStart = -1;
+			
+			_columnState = new ColumnState(null/*blockProgression*/, null/*columnDirection*/, null/*controller*/, 0/*compositionWidth*/, 0/*compositionHeight*/);
+			//_visibleRect = new Rectangle();
+			_xScroll = _yScroll = 0;
+			_contentWidth = _contentHeight = 0;
+			_uncomposedTextLength = 0;
+			
+			// We have to set the flag so that we will get double click events. This
+			// is a change to the container we are given, but a minor one.
+
+//TODO doubleClickEnabled
+//			_container.doubleClickEnabled = true;
+			
+			_horizontalScrollPolicy = _verticalScrollPolicy = String(ScrollPolicy.scrollPolicyPropertyDefinition.defaultValue);
+			_hasScrollRect = false;
+			
+			CONFIG::debug { id = contCount.toString(); ++contCount; }
+			
+			_shapeChildren = [ ];
+			_linesInView = [ ];
+			_tableBlocksInView = [];
+			
+			setCompositionSize(compositionWidth, compositionHeight);
+			format = _containerControllerInitialFormat;
+		}
+		
+		/** @private */
+		public function get effectiveBlockProgression():String
+		{
+			return _rootElement ? _rootElement.computedFormat.blockProgression : BlockProgression.TB;
+		}
+
+//TODO we probably need platform specific methods to attach events to the root		
+		/** @private  Determine containerRoot in case the stage is not accessible. Normally the root is the stage. */
+//		public function getContainerRoot():DisplayObject
+//		{
+//			// safe to test for stage existence
+//			if (_containerRoot == null && _container && _container.stage)
+//			{
+//				// if the stage is accessible lets use it.
+//				// trace("BEFORE COMPUTING CONTAINERROOT");
+//				try
+//				{
+//					var x:int = _container.stage.numChildren;
+//					_containerRoot = _container.stage;
+//				}
+//				catch(e:Error)
+//				{
+//					// TODO: some way to find the highest level accessible root???
+//					_containerRoot = _container.root;
+//				}
+//				// trace("AFTER COMPUTING CONTAINERROOT");
+//			}
+//			return _containerRoot;
+//		}
+		
+		/** 
+		 * Returns the flow composer object that composes and highlights text into the container that this 
+		 * controller manages. 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 * @see org.apache.flex.textLayout.compose.IFlowComposer
+		 */
+		
+		public function get flowComposer():IFlowComposer
+		{ return textFlow ? textFlow.flowComposer : null; }
+		
+		/** @private */
+		public function get shapesInvalid():Boolean
+		{ return _shapesInvalid; }
+		/** @private */
+		public function set shapesInvalid(val:Boolean):void
+		{ _shapesInvalid = val;	}
+		
+		/** 
+		 * Returns a ColumnState object, which describes the number and characteristics of columns in
+		 * the container. These values are updated when the text is recomposed, either as a result
+		 * of <code>IFlowComposer.compose()</code> or <code>IFlowComposer.updateAllControllers()</code>.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * @see ColumnState
+		 */
+		
+		public function get columnState():ColumnState
+		{
+			if (_rootElement == null)
+				return null;
+			
+			if (_computedFormat == null)
+				calculateComputedFormat();
+			
+			_columnState.computeColumns();
+			
+			return _columnState; 
+		}
+		
+		/** 
+		 * Returns the container display object that holds the text lines for this ContainerController instance. 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * @see #ContainerController()
+		 */
+		
+		public function get container():IParentIUIBase
+		{ return _container; }
+		
+		/** 
+		 * Returns the horizontal extent allowed for text inside the container. The value is specified in pixels.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * @see #setCompositionSize()
+		 */
+		
+		public function get compositionWidth():Number
+		{ return _compositionWidth; }
+		
+		/** 
+		 * Returns the vertical extent allowed for text inside the container. The value is specified in pixels.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * @see #setCompositionSize()
+		 */
+		
+		public function get compositionHeight():Number
+		{ return _compositionHeight; }
+		
+		/** @private */
+		public function get measureWidth():Boolean
+		{ return _measureWidth; }
+		
+		/** @private */
+		public function get measureHeight():Boolean
+		{ return _measureHeight; }
+		
+		/** 
+		 * Sets the width and height allowed for text in the container. Width and height can be specified in pixels or <code>NaN</code> can be used for either value.  <code>NaN</code> indicates measure that value. 
+		 * This can be used to find the widest line and/or the total height of all the content.  When NaN is specified as the width lines are broken with a maximum width of <code>ITextLine.MAX_LINE_WIDTH</code>. 
+		 * When <code>NaN</code> is specified as the height the container is assumed to have unlimited height.  The actual measured values can be read back in <code>getContentBounds</code>.  
+		 * When the computed <code>blockProgression</code> property of <code>TextFlow</code>
+		 * is <code>BlockProgression.RL</code> the meanings of width and height are exchanged.
+		 *
+		 * @param w The width in pixels that's available for text in the container.  <code>NaN</code> indicates no specified width.  
+		 * @param h The height in pixels that's available for text in the container.   <code>NaN</code> indicates no specified height.  
+		 *
+		 * 
+		 * @see org.apache.flex.text.engine.ITextLine#MAX_LINE_WIDTH
+		 * @see org.apache.flex.textLayout.formats.BlockProgression
+		 * @see #getContentBounds()
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		
+		public function setCompositionSize(w:Number, h:Number):void
+		{
+		//	trace("setCompositionSize(" + w + ", " + h + ")");
+			
+			// note: NaN == NaN is always false
+			var widthChanged:Boolean  =  !(_compositionWidth == w || (isNaN(_compositionWidth) && isNaN(w)));
+			var heightChanged:Boolean =  !(_compositionHeight == h || (isNaN(_compositionHeight) && isNaN(h)));
+			
+			if (widthChanged || heightChanged)
+			{
+				_compositionHeight = h;
+				_measureHeight = isNaN(_compositionHeight);
+				_compositionWidth = w;
+				_measureWidth = isNaN(_compositionWidth);
+				// otherwise the reset will happen when the cascade is done
+				if (_computedFormat)
+					resetColumnState();
+				// Invalidate all the lines, forcing FTE rebuild if they changed in the logical width direction
+				if (effectiveBlockProgression == BlockProgression.TB ? widthChanged : heightChanged)
+				{
+					if (textFlow && _textLength)
+						textFlow.damage(absoluteStart, _textLength, "invalid", false);
+				}
+				else
+					invalidateContents();		 // don't need to rebuild FTE lines, just reflow them
+				attachTransparentBackgroundForHit(false);
+			}
+		}
+		
+		/** 
+		 * Returns the TextFlow object whose content appears in the container. Either the <code>textFlow</code> and  
+		 * <code>rootElement</code> values are the same, or this is the root element's TextFlow object. For example,
+		 * if the container's root element is a DivElement, the value would be the TextFlow object to which the
+		 * DivElement belongs.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 * 
+	 	 * @see org.apache.flex.textLayout.elements.TextFlow TextFlow
+	 	 */		 
+		public function get textFlow():ITextFlow
+		{ 
+			if (!_textFlowCache && _rootElement)
+				_textFlowCache = _rootElement.getTextFlow();
+			return _textFlowCache;
+		}
+		
+		// Reserve possibility for future use as a IContainerFormattedElement within the TextFlow.
+		
+		/** 
+		 * Returns the root element that appears in the container. The root element could be a DivElement or TextFlow
+		 * instance, for example.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 * @see org.apache.flex.textLayout.elements.IContainerFormattedElement
+		 * @see org.apache.flex.textLayout.elements.DivElement
+		 * @see org.apache.flex.textLayout.elements.TextFlow
+		 */
+		
+		public function get rootElement():IContainerFormattedElement
+		{ return _rootElement; }
+		
+		/** Protected method used when updating the rootElement. 
+		 * @param value new container to be controlled
+		 * 
+		 * @private
+		 */
+		public function setRootElement(value:IContainerFormattedElement):void
+		{
+			if (_rootElement != value)
+			{
+				if (_mouseEventManager)
+					_mouseEventManager.stopHitTests();
+				if (!value)
+					_mouseEventManager = null;
+				else if (!_mouseEventManager)
+				{
+					// Currently, the manager listens to all events itself.
+					// TODO: forward at least mouseOver and mouseDown events without
+					// causing side effects
+					_mouseEventManager = new FlowElementMouseEventManager(container, null);
+					//				[MouseEvent.MOUSE_DOWN, MouseEvent.MOUSE_UP, MouseEvent.MOUSE_MOVE, MouseEvent.MOUSE_DOWN, MouseEvent.MOUSE_OUT,
+					//				 KeyboardEvent.KEY_DOWN, KeyboardEvent.KEY_UP]);
+				}
+
+				clearCompositionResults();
+				detachContainer();
+				_rootElement = value;
+				_textFlowCache = null;
+				_textLength = 0;
+				_absoluteStart = -1;
+				attachContainer();
+				if (_rootElement)
+					formatChanged();
+
+				if (GlobalSettings.playerEnablesSpicyFeatures)
+					_container["needsSoftKeyboard"] = (interactionManager && interactionManager.editingMode == EditingMode.READ_WRITE);
+			}
+		}
+		
+		/** 
+		 * @copy org.apache.flex.textLayout.elements.TextFlow#interactionManager
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 * @see org.apache.flex.textLayout.elements.TextFlow#interactionManager
+		 */
+		
+		public function get interactionManager():ISelectionManager
+		{
+			return textFlow ? textFlow.interactionManager : null;
+		}
+		
+		
+		/** @private */
+		public function get uncomposedTextLength():int
+		{ return _uncomposedTextLength; }
+
+		/** @private */
+		public function get finalParcelStart():int
+		{ return _finalParcelStart; }
+		
+		/** @private */
+		public function set finalParcelStart(val:int):void
+		{ _finalParcelStart = val; }
+		
+		//--------------------------------------------------------------------------
+		//
+		//  Start and length
+		//
+		//--------------------------------------------------------------------------
+		
+		/** 
+		 * Returns the first character in the container. If this is not the first container in the flow,
+		 * this value is updated when the text is composed, that is when the IFlowComposer's <code>compose()</code> or 
+		 * <code>updateAllControllers()</code> methods are called.
+		 * 
+		 * @see org.apache.flex.textLayout.compose.IFlowComposer
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		
+		public function get absoluteStart():int
+		{
+			if (_absoluteStart != -1)
+				return _absoluteStart;
+			
+			var rslt:int = 0;
+			var composer:IFlowComposer = flowComposer;
+			if (composer)
+			{
+				var stopIdx:int = composer.getControllerIndex(this);
+				if (stopIdx != 0)
+				{
+					var prevController:IContainerController = composer.getControllerAt(stopIdx-1);
+					rslt = prevController.absoluteStart + prevController.textLength;
+				}
+			}
+			_absoluteStart = rslt;
+			
+			return rslt;
+		}
+		
+		/** Returns the total number of characters in the container. This can include text that is not currently in view,
+		 * if the container is scrollable. This value is updated when the text is composed (when the IFlowComposer's <code>compose()</code> 
+		 * or <code>updateAllControllers()</code> methods are called).
+		 * 
+		 * @see org.apache.flex.textLayout.compose.IFlowComposer
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		
+		public function get textLength():int
+		{
+			return _textLength;
+		}
+		/**
+		 *  @private
+		 * @flexjsignorecoercion org.apache.flex.textLayout.container.ContainerController
+		 */
+		public function setTextLengthOnly(numChars:int):void
+		{ 
+			if (_textLength != numChars)
+			{
+				_textLength = numChars; 
+				_uncomposedTextLength = 0;
+				// all following containers must have absoluteStart invalidated
+				if (_absoluteStart != -1)
+				{
+					var composer:IFlowComposer = flowComposer;
+					if (composer)
+					{
+						var idx:int = composer.getControllerIndex(this)+1;
+						while (idx < flowComposer.numControllers)
+						{
+							var controller:ContainerController = composer.getControllerAt(idx++) as ContainerController;
+							if (controller._absoluteStart == -1)
+								break;
+							controller._absoluteStart = -1;
+							controller._uncomposedTextLength = 0;
+						}
+					}
+				}
+			}
+		}
+		
+		/** @private */
+		public function setTextLength(numChars:int):void
+		{
+			CONFIG::debug { assert(numChars >= 0,"bad set textLength"); }
+			
+			// If its a scrollable container, and it is the last one, then it gets all the characters even though we might not have composed them all
+			var uncomposedTextLength:int = 0;
+			if (textFlow)
+			{
+				var verticalText:Boolean = effectiveBlockProgression == BlockProgression.RL;
+				var flowComposer:IFlowComposer = textFlow.flowComposer;
+				if (numChars != 0 && flowComposer.getControllerIndex(this) == flowComposer.numControllers - 1 &&
+					((!verticalText && _verticalScrollPolicy != ScrollPolicy.OFF)||
+						(verticalText && _horizontalScrollPolicy != ScrollPolicy.OFF)))
+				{
+					var containerAbsoluteStart:int = absoluteStart;
+					CONFIG::debug { assert(textFlow.textLength >= containerAbsoluteStart,"ContainerController.setTextLength bad absoluteStart"); }
+					uncomposedTextLength = textFlow.textLength-(numChars+containerAbsoluteStart);
+					// _composeCompleteRatio = (textFlow.textLength-containerAbsoluteStart) == numChars ? 1 : 1.1;
+					// var scaledContentHeight:Number = _composeCompleteRatio * _contentHeight;
+					// trace("composeCompleteRatio:",_composeCompleteRatio,"composedContentHeight",_contentHeight,"scaledContentHeight",scaledContentHeight,"textLength",textFlow.textLength,"numChars",numChars);
+					// include all remaining characters in this container when scroll enabled
+					numChars = textFlow.textLength - containerAbsoluteStart;
+				}
+			}
+			
+			// this call clears uncomposedTextLength - set it immediately afterwards
+			setTextLengthOnly(numChars); 	
+			_uncomposedTextLength = uncomposedTextLength;
+
+			CONFIG::debug
+			{
+				if (Debugging.debugOn && textFlow)
+					assert(Math.min(textFlow.textLength, absoluteStart)+_textLength <= textFlow.textLength, "container textLength may not extend past end of root element!");
+			}			
+		}
+		
+		/** 
+		 * Determines whether the container has text that requires composing. 
+		 *
+		 * @return 	true if the container requires composing.
+		 *
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		
+		public function isDamaged():Boolean
+		{
+			return flowComposer.isPotentiallyDamaged(absoluteStart + _textLength);
+		}
+		
+		/** called whenever the container attributes are changed.  Mark computed attributes and columnstate as out of date. 
+		 * @private
+		 */
+		public override function formatChanged(notifyModelChanged:Boolean = true):void
+		{
+			//has no meaning in ContainerController, but we're inheriting from TextLayoutFormatBase
+			// The associated container, if there is one, inherits its container
+			// attributes from here. So we need to tell it that these attributes
+			// have changed.
+			_computedFormat = null;
+			invalidateContents();
+		}
+		
+		/** This gets called when an element has changed its style selection related attributes. This may happen because an
+		 * ancestor element changed it attributes.
+		 * @private 
+		 */		
+		public override function styleSelectorChanged():void
+		{
+			modelChanged(ModelChange.STYLE_SELECTOR_CHANGED,this,0,this._textLength);
+			_computedFormat = null;
+		}
+		
+		/** @private */
+		public function modelChanged(changeType:String, element:ContainerController, changeStart:int, changeLen:int, needNormalize:Boolean = true, bumpGeneration:Boolean = true):void
+		{
+			var tf:ITextFlow = _rootElement.getTextFlow();
+			if (tf)
+				tf.processModelChanged(changeType, element, absoluteStart+changeStart, changeLen, needNormalize, bumpGeneration);
+		}
+		
+		/** @private */
+		public function gatherVisibleLines(wmode:String, createShape:Boolean):void
+		{
+			CONFIG::debug { assert(_linesInView.length == 0,"gatherVisibleLines: bad _linesInView"); }
+			if (_textLength != 0)
+			{
+				// Similar computations also done in BaseCompose.getControllerVisibleBounds
+				var width:Number = _measureWidth ? _contentWidth : _compositionWidth;
+				var height:Number = _measureHeight ? _contentHeight : _compositionHeight;
+				var adjustX:Number = (wmode == BlockProgression.RL) ? _xScroll - width : _xScroll;
+				var adjustY:Number = _yScroll;
+				var scrollAdjustXTW:int = Twips.roundTo(adjustX);
+				var scrollAdjustYTW:int = Twips.roundTo(adjustY);
+				var scrollAdjustWidthTW:int = Twips.to(width);
+				var scrollAdjustHeightTW:int = Twips.to(height);
+				
+				var flowComposer:IFlowComposer = this.flowComposer;
+	
+				// Iterate over the lines in the container, setting the x and y positions and 
+				// adding them to the list to go into the container. Keep track of the width 
+				// and height of the actual text in the container.
+				var firstLine:int = flowComposer.findLineIndexAtPosition(absoluteStart);
+				var lastLine:int = flowComposer.findLineIndexAtPosition(absoluteStart + _textLength - 1);
+				
+				var curLine:ITextFlowLine;
+				var textLine:ITextLine;
+				var lineIndex:int;
+				var testRslt:*;
+				
+				//Use binary search when there is one single column
+				if(columnCount == 1)
+				{
+					// First just test the firstLine - normal unscrolled case
+					var testPos:int = firstLine;
+					curLine = flowComposer.getLineAt(testPos++);
+					while(curLine && curLine is ITextFlowTableBlock)
+						curLine = flowComposer.getLineAt(testPos++);
+					
+					testRslt = testLineVisible(wmode, scrollAdjustXTW, scrollAdjustYTW, scrollAdjustWidthTW, scrollAdjustHeightTW, curLine, null);
+					textLine = testRslt as ITextLine;
+					firstLine++;	// its been tested
+					if (textLine)
+					{
+						if (createShape)
+							curLine.createShape(wmode, textLine);
+						_linesInView.push(textLine);
+					}
+					else
+					{
+						var hi:int = lastLine;
+						while (firstLine <= hi)
+						{
+							var mid:int = (firstLine+hi)/2;
+							CONFIG::debug { assert(mid != 0,"ContainerController:gatherVisibleLines: bad mid"); }
+							curLine = flowComposer.getLineAt(mid);
+							testRslt = testLineVisible(wmode, scrollAdjustXTW, scrollAdjustYTW, scrollAdjustWidthTW, scrollAdjustHeightTW, curLine, null);
+							
+							if (testRslt && testRslt is ITextLine)
+							{
+								textLine = testRslt as ITextLine;
+								// note that we tested firstLine above so going to mid-1 is always valid
+								var tempLine:ITextFlowLine = flowComposer.getLineAt(mid-1);
+								if (!(testLineVisible(wmode, scrollAdjustXTW, scrollAdjustYTW, scrollAdjustWidthTW, scrollAdjustHeightTW, tempLine, null) is ITextLine))
+								{
+									// Got the start
+									if (createShape)
+										curLine.createShape(wmode, textLine);
+									_linesInView.push(textLine);
+									firstLine = mid+1;
+									break;
+								}
+								testRslt = -1;	// past the start
+							}
+							// need to deal with TextFlowTableBlocks
+							
+							if (testRslt < 0 || testRslt == 2)
+								hi = mid-1;
+							else
+								firstLine = mid+1;
+						}
+					}
+					
+					for (lineIndex = firstLine; lineIndex <= lastLine; lineIndex++)
+					{
+						curLine = flowComposer.getLineAt(lineIndex);
+						testRslt = testLineVisible(wmode, scrollAdjustXTW, scrollAdjustYTW, scrollAdjustWidthTW, scrollAdjustHeightTW, curLine, null);
+						
+						if(testRslt is TableBlockContainer)
+							continue;
+						textLine = testRslt as ITextLine;
+						if (!textLine)
+							break;
+		
+						if (createShape)
+							curLine.createShape(wmode, textLine);
+						_linesInView.push(textLine);
+					}
+				}
+				else //multiple columns
+				{
+					for (lineIndex = firstLine; lineIndex <= lastLine; lineIndex++)
+					{
+						curLine = flowComposer.getLineAt(lineIndex);	
+						if (curLine == null || curLine.controller != this)
+							continue;
+						
+						textLine = oldTestLineVisible(wmode, scrollAdjustXTW, scrollAdjustYTW, scrollAdjustWidthTW, scrollAdjustHeightTW, curLine, null);
+						if (textLine)
+						{
+							if (createShape)
+								curLine.createShape(wmode, textLine);
+							_linesInView.push(textLine);
+						}
+					}
+				}
+			}
+			_updateStart = absoluteStart;	// we collected all lines from the start of the container
+		}
+		
+		/** determines the shapechildren in the container and applies VJ. @private */
+		public function fillShapeChildren():void
+		{ 
+			if (_textLength == 0)
+				return;	// none				
+			
+			var wmode:String = effectiveBlockProgression;
+			
+			if (_linesInView.length == 0)		// no preexisting concpetion of what lines are in view: recalculate
+				gatherVisibleLines(wmode, true);
+			
+			// If scrolling is turned off, and flow is vertical, then we need to adjust the positions of all the lines. With
+			// scrolling turned on, we don't need to do this because the adjustment is done in the Player when the scrollRect
+			// is set up correctly. But with the scrollRect, we also get clipping, and if scrolling is turned off we want to
+			// have the clipping turned off as well. So in this case we do the adjustment manually so the scrollRect can be null.
+			// NOTE: similar adjustments are made in TextContainerManager
+			var adjustLines:Boolean = (wmode == BlockProgression.RL) &&
+				(_horizontalScrollPolicy == ScrollPolicy.OFF && 
+					_verticalScrollPolicy == ScrollPolicy.OFF);
+			
+			if (adjustLines)
+			{			
+				var width:Number = _measureWidth ? _contentWidth : _compositionWidth;
+//				var height:Number = _measureHeight ? _contentHeight : _compositionHeight;
+				var adjustX:Number = _xScroll - width;		// vertical text: blockProgression is rl
+				var adjustY:Number = _yScroll;
+				
+				// Iterate over the lines in the container, setting the x and y positions. Keep track of the width 
+				// and height of the actual text in the container.
+				if (adjustX != 0 || adjustY != 0)
+				{
+					for each (var textLine:ITextLine in _linesInView)
+					{
+						if (!textLine)
+							continue;
+						
+						if (adjustLines)
+						{
+							textLine.x -= adjustX;
+							textLine.y -= adjustY;
+						}
+					}
+					_contentLeft -= adjustX;
+					_contentTop  -= adjustY;
+				}
+			}
+			
+			
+		}
+		
+		//--------------------------------------------------------------------------
+		//
+		//  Scrolling
+		//
+		//--------------------------------------------------------------------------
+		
+		/** 
+		 * Specifies the horizontal scrolling policy, which you can set by assigning one of the constants of
+		 * the ScrollPolicy class: ON, OFF, or AUTO.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 * @see ScrollPolicy
+		 */
+		
+		public function get horizontalScrollPolicy():String
+		{
+			return _horizontalScrollPolicy;
+		}
+		public function set horizontalScrollPolicy(scrollPolicy:String):void
+		{
+			var newScrollPolicy:String = ScrollPolicy.scrollPolicyPropertyDefinition.setHelper(_horizontalScrollPolicy, scrollPolicy) as String;
+			
+			if (newScrollPolicy != _horizontalScrollPolicy)
+			{
+				_horizontalScrollPolicy = newScrollPolicy;
+				if (_horizontalScrollPolicy == ScrollPolicy.OFF)
+					horizontalScrollPosition = 0;
+				formatChanged();	// scroll policy affects composition
+			}
+		}
+		
+		/** @private */
+		public function checkScrollBounds():void
+		{
+			var newHeight:Number;
+			var visibleHeight:Number;
+			var measuring:Boolean;
+			
+			// If we've either grown the content past the composition bounds in the logical vertical direction, 
+			// or shrunk it down under the composition bounds, signal a scrolling change
+			// If we're measuring we never scroll.
+			if (effectiveBlockProgression == BlockProgression.RL)
+			{
+				newHeight = _contentWidth;
+				visibleHeight = compositionWidth;
+				measuring = _measureWidth;
+			}
+			else
+			{
+				newHeight = _contentHeight;
+				visibleHeight = compositionHeight;
+				measuring = _measureHeight;
+			}
+
+			// Called when the bounds have changed and they now exceed the composition area, to see if we need to attach a mouse wheel listener for scrolling
+			if (textFlow && !_minListenersAttached)
+			{
+				var needToScroll:Boolean = !measuring && newHeight > visibleHeight;
+				if (needToScroll != _mouseWheelListenerAttached)
+				{
+					if (_mouseWheelListenerAttached)
+						removeMouseWheelListener();
+					else
+						addMouseWheelListener();
+				}
+			}
+			
+		}
+		
+		/** Specifies the vertical scrolling policy, which you can set by assigning one of the constants of the ScrollPolicy
+		 * class: ON, OFF, or, AUTO.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * @see ScrollPolicy
+		 */
+		
+		public function get verticalScrollPolicy():String
+		{
+			return _verticalScrollPolicy;
+		}
+		public function set verticalScrollPolicy(scrollPolicy:String):void
+		{
+			var newScrollPolicy:String = ScrollPolicy.scrollPolicyPropertyDefinition.setHelper(_verticalScrollPolicy, scrollPolicy) as String;
+			if (newScrollPolicy != _verticalScrollPolicy)
+			{
+				_verticalScrollPolicy = newScrollPolicy;
+				if (_verticalScrollPolicy == ScrollPolicy.OFF)
+					verticalScrollPosition = 0;
+				formatChanged();	// scroll policy affects composition
+			}
+		}
+		
+		/** Specifies the current horizontal scroll location on the stage. The value specifies the number of
+		 * pixels from the left.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		
+		public function get horizontalScrollPosition():Number
+		{
+			return _xScroll;
+		}
+		
+		public function set horizontalScrollPosition(x:Number):void
+		{
+			if (!_rootElement)
+				return;
+			
+			if (_horizontalScrollPolicy == ScrollPolicy.OFF)
+			{
+				_xScroll = 0;
+				return;
+			}
+			var oldScroll:Number = _xScroll;
+			var newScroll:Number = computeHorizontalScrollPosition(x,true);
+			
+			if (newScroll != oldScroll)
+			{	
+				_shapesInvalid = true;
+				_xScroll = newScroll;
+				updateForScroll(ScrollEventDirection.HORIZONTAL, newScroll - oldScroll);
+			}
+		}
+		
+		static private function pinValue(value:Number, minimum:Number, maximum:Number):Number
+		{
+			return Math.min(Math.max(value, minimum), maximum);						
+		}
+		
+		private function computeHorizontalScrollPosition(x:Number,okToCompose:Boolean):Number
+		{
+			var wmode:String = effectiveBlockProgression;
+			var curEstimatedWidth:Number = contentWidth;
+			var newScroll:Number = 0;
+			
+			if (curEstimatedWidth > _compositionWidth && !_measureWidth)
+			{
+				// Pin the lower and upper bounds of _x. If we're doing vertical text, then the right edge is 0 and the left edge is negative
+				// We may not have composed all the way to the indicated position. If not, force composition so that we can be sure we're at
+				// a legal position.
+				if (wmode == BlockProgression.RL)
+				{
+					newScroll = pinValue(x, _contentLeft + _compositionWidth, _contentLeft + curEstimatedWidth);
+					if (okToCompose && _uncomposedTextLength != 0 && newScroll != _xScroll)
+					{
+						// in order to compose have to set _xScroll
+						_xScroll = x;
+						if (_xScroll > _contentLeft + _contentWidth)
+							_xScroll = _contentLeft + _contentWidth;
+						flowComposer.composeToController(flowComposer.getControllerIndex(this));
+						newScroll = pinValue(x, _contentLeft + _compositionWidth, _contentLeft + _contentWidth);
+					}
+				}
+				else
+					newScroll = pinValue(x, _contentLeft, (_contentLeft + curEstimatedWidth) - _compositionWidth);
+			}
+			return newScroll;
+		}
+		
+		
+		/** Specifies the current vertical scroll location on the stage. The value specifies the number of 
+		 * pixels from the top.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		
+		public function get verticalScrollPosition():Number
+		{
+			return _yScroll;
+		}
+		
+		public function set verticalScrollPosition(y:Number):void
+		{
+			if (!_rootElement)
+				return;
+			
+			if (_verticalScrollPolicy == ScrollPolicy.OFF)
+			{
+				_yScroll = 0;
+				return;
+			}
+			
+			var oldScroll:Number = _yScroll;
+			var newScroll:Number = computeVerticalScrollPosition(y,true);
+			
+			if (newScroll != oldScroll)
+			{			
+				_shapesInvalid = true;
+				_yScroll = newScroll;
+				updateForScroll(ScrollEventDirection.VERTICAL, newScroll - oldScroll);
+			}
+		}	
+		
+		private function computeVerticalScrollPosition(y:Number,okToCompose:Boolean):Number
+		{
+			var newScroll:Number = 0;
+			var curcontentHeight:Number = contentHeight;
+			var wmode:String = effectiveBlockProgression;
+			
+			// Only try to scroll if the content height is greater than the composition height, then there is text that is not visible to scroll to
+			if (curcontentHeight > _compositionHeight)
+			{
+				// new scroll value is somewhere between the topmost content, and the top of the last containerfull
+				newScroll = pinValue(y, _contentTop, _contentTop + (curcontentHeight - _compositionHeight));
+				
+				// if we're not composed to the end, compose further so we can scroll to it. Sets the scroll position and then 
+				// recomposes the container, which will compose through the end of the screenfull that starts at the requested position.
+				if (okToCompose && _uncomposedTextLength != 0 && wmode == BlockProgression.TB)
+				{
+					_yScroll = y;
+					if (_yScroll < _contentTop)
+						_yScroll = _contentTop;
+					flowComposer.composeToController(flowComposer.getControllerIndex(this));
+					newScroll = pinValue(y, _contentTop, _contentTop + (curcontentHeight - _compositionHeight));
+				}
+			}
+			return newScroll;
+		}
+		
+		/** 
+		 * Returns the area that the text occupies, as reflected by the last compose or update operation. 
+		 * The width and the height might be estimated, if the container is scrollable and the text exceeds the 
+		 * visible area.
+		 * 
+		 * @return describes the area that the text occupies.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 *
+		 * @see org.apache.flex.geom.Rectangle Rectangle
+		 */
+		public function getContentBounds():Rectangle
+		{
+			return new Rectangle(_contentLeft, _contentTop, contentWidth, contentHeight);
+		}
+		
+		/**
+		 * @private
+		 */
+		
+		public function get contentLeft():Number
+		{
+			return _contentLeft;
+		}
+		
+		/**
+		 * @private
+		 */
+		
+		public function get contentTop():Number
+		{
+			return _contentTop;
+		}
+		
+		/** @private */
+		public function computeScaledContentMeasure(measure:Number):Number
+		{
+			CONFIG::debug { assert(_finalParcelStart != -1 && _finalParcelStart >= this.absoluteStart && _finalParcelStart <= textFlow.textLength-_uncomposedTextLength,"computeScaledContentMeasure bad _finalParcelStart"); }
+			var charsInFinalParcel:int = textFlow.textLength-_finalParcelStart;
+			var composeCompleteRatio:Number = charsInFinalParcel / (charsInFinalParcel-_uncomposedTextLength);
+			// trace(measure*composeCompleteRatio,charsInFinalParcel,_uncomposedTextLength,measure,composeCompleteRatio);
+			return measure * composeCompleteRatio;
+		}
+		
+		/** 
+		 * @private
+		 *
+		 * Returns the vertical extent of the text. For horizontal text, it includes space taken for descenders on the last line. 
+		 * If not all the text is composed, this returns an estimated value based on how much text is already composed; the
+		 * more text that is composed, the more accurate s the estimate. To get a completely accurate value, recompose
+		 * with the rootElement's flowComposer before accessing contentHeight.
+		 * You can get the composed bounds of the text by getting the contentLeft, contentTop, contentWidth, contentHeight properties.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		
+		public function get contentHeight():Number
+		{
+			if (_uncomposedTextLength == 0 || effectiveBlockProgression != BlockProgression.TB)
+				return _contentHeight;
+			return computeScaledContentMeasure(_contentHeight);
+		}
+		
+		/** 
+		 * @private
+		 *
+		 * Returns the horizontal extent of the text. For vertical text, it includes space taken for descenders on the last line. 
+		 * If not all the text is composed, this returns an estimated value based on how much text is already composed; the
+		 * more text that is composed, the more accurate is the estimate. To get a completely accurate value, recompose
+		 * with the rootElement's flowComposer before accessing contentWidth.
+		 * You can get the composed bounds of the text by getting the contentLeft, contentTop, contentWidth, contentHeight properties.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		
+		public function get contentWidth():Number
+		{			
+			if (_uncomposedTextLength == 0 || effectiveBlockProgression != BlockProgression.RL)
+				return _contentWidth;
+			return computeScaledContentMeasure(_contentWidth);
+		}
+		
+		/** @private */
+		public function setContentBounds(contentLeft:Number, contentTop:Number, contentWidth:Number, contentHeight:Number):void
+		{
+			_contentWidth = contentWidth;
+			_contentHeight = contentHeight;
+			_contentLeft = contentLeft;
+			_contentTop = contentTop;
+			checkScrollBounds();
+		}
+		
+		private function updateForScroll(direction:String, delta:Number):void
+		{
+			_linesInView.length = 0;		// zero out array of previously gathered up lines; its invalid because we've changed the visible area
+			var flowComposer:IFlowComposer = textFlow.flowComposer;
+			flowComposer.updateToController(flowComposer.getControllerIndex(this));
+			
+			attachTransparentBackgroundForHit(false);
+			
+			// notify client that we scrolled.
+			if (textFlow.hasEventListener(TextLayoutEvent.SCROLL))
+				textFlow.dispatchEvent(new ScrollEvent(TextLayoutEvent.SCROLL, false, false, direction, delta));
+			
+			//	trace("contentHeight", contentHeight, "contentWidth", contentWidth);
+			//	trace("contentHeight", contentHeight, "contentWidth", contentWidth);
+		}
+		
+		/** @private */
+		CONFIG::debug public function validateLines():void
+		{
+			if (!Debugging.containerLineValidation)
+				return;
+			
+			// Optimally we would recalculate which lines are in view and make sure they are parented
+			// to the container... but that causes side-effects (like creating TextLines) that affect
+			// regular execution. So we don't try that.
+			
+			// Check all the children of the container. Verify that adornments go before or after lines, that lines are at the expected z-order position
+			// And that extraneous lines are not parented to the container.
+			var firstLineIndex:int = -1;
+			var lastLineIndex:int = -1;
+			var numChildren:int = _container.numElements;
+			for (var childIndex:int = 0; childIndex < numChildren; ++childIndex)
+			{
+				var child:IChild = _container.getElementAt(childIndex);
+				if (_shapeChildren.indexOf(child) < 0 && (!_floatsInContainer || _floatsInContainer.indexOf(child) < 0))
+				{
+					// the very last thing can be the selection sprite
+					if (childIndex == numChildren - 1)
+						assert(child == getSelectionSprite(false),"expected selectionsprite but not found");
+					
+					assert(firstLineIndex == -1 || lastLineIndex == childIndex - 1, "Found adornment in the middle of ITextLine children");
+					continue;		// it's an adornment: skip
+				}
+				else 
+				{
+					if (firstLineIndex == -1)
+						firstLineIndex = childIndex;
+					lastLineIndex = childIndex;
+				}
+				if (_floatsInContainer && _floatsInContainer.indexOf(child) >= 0)	// it's a float
+					continue;
+				assert(child is ITextLine, "Expected child to be a ITextLine");
+				
+				// Check that the line comes after previous lines, in z-order
+				var lineIndex:int = _shapeChildren.indexOf(child);
+				if (lineIndex > 0)
+					assert(_container.getElementIndex(_shapeChildren[lineIndex - 1]) < childIndex, "Line is visible but not at expected z-order position: earlier line is later in z-order");
+				else if (lineIndex < 0)
+					assert(false, "Found line that should not be in the container (its not considered visible)");
+			}
+		}
+		
+		private function get containerScrollRectLeft():Number
+		{
+			var rslt:Number;
+			if (horizontalScrollPolicy == ScrollPolicy.OFF && verticalScrollPolicy == ScrollPolicy.OFF)
+				rslt = 0;
+			else
+				rslt= effectiveBlockProgression == BlockProgression.RL ? horizontalScrollPosition - compositionWidth : horizontalScrollPosition;
+			//CONFIG::debug { assert(container.scrollRect == null && rslt == 0 || int(rslt) == container.scrollRect.left,"Bad containerScrollRectLeft"); }
+			return rslt;
+		}
+		
+		private function get containerScrollRectRight():Number
+		{
+			var rslt:Number = containerScrollRectLeft+compositionWidth;
+			//CONFIG::debug { assert(container.scrollRect == null && rslt == compositionWidth || int(rslt) == container.scrollRect.right,"Bad containerScrollRectRight"); }
+			return rslt;
+		}
+		
+		private function get containerScrollRectTop():Number
+		{
+			var rslt:Number;
+			if (horizontalScrollPolicy == ScrollPolicy.OFF && verticalScrollPolicy == ScrollPolicy.OFF)
+				rslt = 0;
+			else
+				rslt = verticalScrollPosition;
+			//CONFIG::debug { assert(container.scrollRect == null && rslt == 0 || int(rslt) == container.scrollRect.top,"Bad containerScrollRectTop"); }
+			return rslt;
+		}
+		
+		private function get containerScrollRectBottom():Number
+		{
+			var rslt:Number = containerScrollRectTop+compositionHeight;
+			//CONFIG::debug { assert(container.scrollRect == null && rslt == compositionHeight || int(rslt) == container.scrollRect.bottom,"Bad containerScrollRectBottom"); }
+			return rslt;
+		}
+		
+		/** 
+		 * Scrolls so that the text range is visible in the container.
+		 *
+		 * @param activePosition	The end of the selection that is changed when you extend the selection. It can be
+		 * 	either the start or the end of the selection, expressed as an offset from the start of the text flow.
+		 * @param anchorPosition   	The stable end of the selection when you extend the selection. It can be either 
+		 * 	the start or the end of the selection.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		
+		public function scrollToRange(activePosition:int,anchorPosition:int):void
+		{
+			
+			// return if we're not scrolling, or if it's not the last controller
+			if (!_hasScrollRect || !flowComposer || flowComposer.getControllerAt(flowComposer.numControllers-1) != this)
+				return;
+			
+			// clamp values to range absoluteStart,absoluteStart+_textLength
+			var controllerStart:int = absoluteStart;
+			var lastPosition:int = Math.min(controllerStart+_textLength, textFlow.textLength - 1);
+			activePosition = Math.max(controllerStart,Math.min(activePosition,lastPosition));
+			anchorPosition = Math.max(controllerStart,Math.min(anchorPosition,lastPosition));
+			
+			var verticalText:Boolean = effectiveBlockProgression == BlockProgression.RL;
+			var begPos:int = Math.min(activePosition,anchorPosition);
+			var endPos:int = Math.max(activePosition,anchorPosition);
+			
+			// is part of the selection in view?
+			var begLineIndex:int = flowComposer.findLineIndexAtPosition(begPos,(begPos == textFlow.textLength));
+			var endLineIndex:int = flowComposer.findLineIndexAtPosition(endPos,(endPos == textFlow.textLength));
+			
+			// no scrolling if any part of the selection is in view			
+			var scrollRectLeft:Number = containerScrollRectLeft;
+			var scrollRectTop:Number  = containerScrollRectTop;
+			var scrollRectRight:Number = containerScrollRectRight;
+			var scrollRectBottom:Number = containerScrollRectBottom;
+			
+			if (flowComposer.damageAbsoluteStart <= endPos)
+			{
+				endPos = Math.min(begPos + 100, endPos + 1);
+				flowComposer.composeToPosition(endPos);
+				begLineIndex = flowComposer.findLineIndexAtPosition(begPos,(begPos == textFlow.textLength));
+				endLineIndex = flowComposer.findLineIndexAtPosition(endPos,(endPos == textFlow.textLength));
+			}
+			var rect:Rectangle = rangeToRectangle(begPos, endPos, begLineIndex, endLineIndex);
+			if (rect) 
+			{
+//				var lastVisibleLine:ITextFlowLine;
+				var horizontalScrollOK:Boolean;
+				var verticalScrollOK:Boolean;
+				
+				// vertical scroll
+				if (verticalText) {					
+					// horizontal scroll
+					horizontalScrollOK = (rect.left < scrollRectLeft || rect.right > scrollRectLeft);
+					if (horizontalScrollOK)
+					{
+						if (rect.left < scrollRectLeft)
+							horizontalScrollPosition = rect.left + _compositionWidth;
+						if (rect.right > scrollRectRight)
+							horizontalScrollPosition = rect.right;
+					}
+					
+					// If we're showing a blinking insertion point, we need to scroll far enough that
+					// we can see the insertion point, and it comes just after the character.
+					if (rect.top < scrollRectTop)
+						verticalScrollPosition = rect.top;
+					if (activePosition == anchorPosition)
+						rect.bottom += 2;							
+					// vertical scroll
+					if (rect.bottom > scrollRectBottom)
+						verticalScrollPosition = rect.bottom - _compositionHeight;
+				}
+				else 
+				{
+					// vertical scroll
+					
+					// Don't scroll if the range extends both above and below
+					verticalScrollOK = (rect.top > scrollRectTop || rect.bottom < scrollRectBottom);
+					
+					// vertical scroll
+					if (verticalScrollOK)
+					{
+						if (rect.top < scrollRectTop)
+							verticalScrollPosition = rect.top;
+	
+						if (rect.bottom > scrollRectBottom)
+							verticalScrollPosition = rect.bottom - _compositionHeight;
+					}
+					
+					// horizontal scroll
+
+					// If we're showing a blinking insertion point, we need to scroll far enough to see the
+					// insertion point, and it comes up to the right
+					if (activePosition == anchorPosition)
+						rect.right += 2;
+
+					// Don't scroll if range extends both to the left and right
+					horizontalScrollOK = (rect.left > scrollRectLeft || rect.right < scrollRectRight);
+					if (horizontalScrollOK && rect.left < scrollRectLeft)
+						horizontalScrollPosition = rect.left - _compositionWidth / 2;
+					if (horizontalScrollOK && rect.right > scrollRectRight)
+						horizontalScrollPosition = rect.right - _compositionWidth / 2;
+				}
+			}
+		}		
+		
+		private function rangeToRectangle(start:int, end:int, startLineIndex:int, endLineIndex:int):Rectangle
+		{
+			var bbox:Rectangle;
+			var blockProgression:String = effectiveBlockProgression;		
+			var flowComposer:IFlowComposer = textFlow.flowComposer;
+			
+			if (!container || !flowComposer)
+				return null;
+			
+			if (startLineIndex == endLineIndex)
+			{
+				var line:ITextFlowLine = flowComposer.getLineAt(startLineIndex); 
+				if (line.isDamaged())
+					return null;
+				var textLine:ITextLine = line.getTextLine(true);
+				var paragraphStart:int = line.paragraph.getAbsoluteStart();
+				
+				var isTCY:Boolean = false;
+				if (blockProgression == BlockProgression.RL)
+				{
+					var leafElement:IFlowLeafElement = _rootElement.getTextFlow().findLeaf(start);
+					isTCY =  leafElement.getParentByType("TCYElement") != null;
+				}
+				
+				var minAtomIndex:int = textLine.atomCount;
+				var maxAtomIndex:int = 0;
+				if (start == end)
+				{
+					minAtomIndex = textLine.getAtomIndexAtCharIndex(start - paragraphStart);
+					maxAtomIndex = minAtomIndex;
+				}
+				else
+				{
+					var atomIndex:int;
+					var lastPosition:int = end - paragraphStart;
+					for (var pos:int = start - paragraphStart; pos < lastPosition; ++pos)
+					{
+						atomIndex = textLine.getAtomIndexAtCharIndex(pos);
+						if (atomIndex < minAtomIndex)
+							minAtomIndex = atomIndex;
+						if (atomIndex > maxAtomIndex)
+							maxAtomIndex = atomIndex;
+					}
+				}
+				bbox = atomToRectangle(minAtomIndex, line, textLine, blockProgression, isTCY);
+				if (minAtomIndex != maxAtomIndex)
+					bbox = bbox.union(atomToRectangle(maxAtomIndex, line, textLine, blockProgression, isTCY));
+			}
+			else
+			{
+				bbox = new Rectangle(_contentLeft, _contentTop, _contentWidth, _contentHeight);
+				var startLine:ITextFlowLine = flowComposer.getLineAt(startLineIndex); 
+				var endLine:ITextFlowLine = flowComposer.getLineAt(endLineIndex); 
+				if (blockProgression == BlockProgression.TB)
+				{
+					bbox.top = startLine.y;
+					bbox.bottom = endLine.y + endLine.textHeight;
+				}
+				else
+				{
+					bbox.right = startLine.x + startLine.textHeight;
+					bbox.left = endLine.x;
+				}
+			}
+			return bbox;
+		}
+		
+		
+		private function atomToRectangle(atomIdx:int, line:ITextFlowLine, textLine:ITextLine, blockProgression:String, isTCY:Boolean):Rectangle
+		{
+			var atomBounds:Rectangle;
+			CONFIG::debug { assert(atomIdx > -1, "How'd we get here?"); }
+			if (atomIdx > -1) 
+				atomBounds = textLine.getAtomBounds(atomIdx);
+			
+			// special handling for TCY - no line height adjustments TCY is perpendicular to the height direction
+			if (blockProgression == BlockProgression.RL)
+			{
+				if (isTCY)
+					return new Rectangle(line.x+atomBounds.x,line.y+atomBounds.y,atomBounds.width,atomBounds.height);
+				return new Rectangle(line.x, line.y + atomBounds.y, line.height, atomBounds.height);
+			}
+			return new Rectangle(line.x + atomBounds.x, line.y-line.height+line.ascent, atomBounds.width, line.height+textLine.descent);
+		}
+		
+		/**
+		 * @private
+		 */
+		
+		public function resetColumnState():void
+		{
+			if (_rootElement)
+				_columnState.updateInputs(effectiveBlockProgression, _rootElement.computedFormat.direction, this, _compositionWidth, _compositionHeight);
+		}
+		
+		/** 
+		 * Marks all the text in this container as needing composing. 
+		 *
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 */
+		
+		public function invalidateContents():void
+		{
+			if (textFlow)
+				textFlow.damage(absoluteStart, Math.min(_textLength, 1), FlowDamageType.GEOMETRY, false);
+		}
+		
+		/** @private */
+		private var _transparentBGX:Number;
+		/** @private */
+		private var _transparentBGY:Number;
+		/** @private */
+		private var _transparentBGWidth:Number;
+		/** @private */
+		private var _transparentBGHeight:Number;
+		
+		/** No mouse clicks or moves will be generated for the container unless it has a background covering its area.  Text Layout Framework
+		 * wants those events so that clicking on a container will select the text in it.  This code
+		 * adds or updates (on size change) that background for Sprite containers only. This may cause clients problems 
+		 * - definitely no hits is a problem - add this code to explore the issues - expect feedback.  
+		 * We may have to make this configurable. @private */
+		
+		
+		public function attachTransparentBackgroundForHit(justClear:Boolean):void
+		{
+			if ((_minListenersAttached || _mouseWheelListenerAttached) && attachTransparentBackground)
+			{
+				var s:IParentIUIBase = _container;
+                if (justClear)
+                {
+//TODO deal with graphics
+//                    s.graphics.clear();
+                    CONFIG::debug { Debugging.traceFTECall(null,s,"clearTransparentBackground()"); }
+                    _transparentBGX = _transparentBGY = _transparentBGWidth = _transparentBGHeight = NaN;
+                }
+                else
+                {
+                    var bgwidth:Number = _measureWidth ? _contentWidth : _compositionWidth;
+                    var bgheight:Number = _measureHeight ? _contentHeight : _compositionHeight;
+
+                    var adjustHorizontalScroll:Boolean = effectiveBlockProgression == BlockProgression.RL && _horizontalScrollPolicy != ScrollPolicy.OFF;
+                    var bgx:Number = adjustHorizontalScroll ? _xScroll - bgwidth : _xScroll;
+                    var bgy:Number = _yScroll;
+
+                    CONFIG::debug { assert(!isNaN(bgx) && !isNaN(bgy) && !isNaN(bgwidth) && ! isNaN(bgheight),"Bad background rectangle"); }
+
+                    if (bgx != _transparentBGX || bgy != _transparentBGY || bgwidth != _transparentBGWidth || bgheight != _transparentBGHeight)
+                    {
+//TODO graphics
+//                        s.graphics.clear();
+//                        CONFIG::debug { Debugging.traceFTECall(null,s,"clearTransparentBackground()"); }
+//                        if (bgwidth != 0 && bgheight != 0 )
+//                        {
+//                            s.graphics.beginFill(0, 0);
+//                            s.graphics.drawRect(bgx, bgy, bgwidth, bgheight);
+//                            s.graphics.endFill();
+//                            CONFIG::debug { Debugging.traceFTECall(null,s,"drawTransparentBackground",bgx, bgy, bgwidth, bgheight); }
+//                        }
+                        _transparentBGX = bgx;
+                        _transparentBGY = bgy;
+                        _transparentBGWidth = bgwidth;
+                        _transparentBGHeight = bgheight;
+                    }
+                }
+			}
+		}
+		
+		/** @private */
+		public	function interactionManagerChanged(newInteractionManager:ISelectionManager):void
+		{
+			if (!newInteractionManager)
+				detachContainer();
+			attachContainer();
+			checkScrollBounds();
+			// Need to forward whether the Ctrl key is needed to have
+			// hit-tested FlowElements emit events
+			if (_mouseEventManager)
+				_mouseEventManager.needsCtrlKey	= 
+					(interactionManager != null && interactionManager.editingMode == EditingMode.READ_WRITE);
+
+			// We have to tell the Player to bring up the soft keyboard on a
+			// keyboard edit gesture. Note that needsSoftKeyboard is new with 10.2, so 
+			// have to check for it. This is a change to the container, but unavoidable
+			if (GlobalSettings.playerEnablesSpicyFeatures)
+				_container["needsSoftKeyboard"] = (interactionManager && interactionManager.editingMode == EditingMode.READ_WRITE);
+		}
+		
+		//--------------------------------------------------------------------------
+		//  Event handlers for editing
+		//  Listeners are attached on first compose
+		//--------------------------------------------------------------------------
+		
+		/** @private */
+		public function attachContainer():void
+		{
+			if (!_minListenersAttached && textFlow && textFlow.interactionManager)
+			{
+				_minListenersAttached = true;
+				
+                _container.addEventListener(FocusEvent.FOCUS_IN, requiredFocusInHandler);
+                _container.addEventListener(MouseEvent.MOUSE_OVER, requiredMouseOverHandler);
+
+                attachTransparentBackgroundForHit(false);
+
+//TODO deal with reference to stage
+                // If the container already has focus, we have to attach all listeners
+//                if (_container.stage && _container.stage.focus == _container)
+//                    attachAllListeners();
+			}
+		}
+		
+		/** @private */
+		public function attachInteractionHandlers():void
+		{
+			// the receiver is either this or another class that is going to handle the methods.
+			var receiver:IInteractionEventHandler = getInteractionHandler();
+			
+			// the required handlers are implemented here and forwarded to the receiver
+			_container.addEventListener(MouseEvent.MOUSE_DOWN, requiredMouseDownHandler);
+			_container.addEventListener(FocusEvent.FOCUS_OUT, requiredFocusOutHandler);
+			_container.addEventListener(MouseEvent.DOUBLE_CLICK, receiver.mouseDoubleClickHandler);
+			_container.addEventListener(ActivateEvent.ACTIVATE, receiver.activateHandler);
+			_container.addEventListener(FocusEvent.MOUSE_FOCUS_CHANGE, receiver.focusChangeHandler);
+			_container.addEventListener(FocusEvent.KEY_FOCUS_CHANGE, receiver.focusChangeHandler);
+			_container.addEventListener(TextEvent.TEXT_INPUT, receiver.textInputHandler);
+			_container.addEventListener(MouseEvent.MOUSE_OUT, receiver.mouseOutHandler);
+			addMouseWheelListener();
+			_container.addEventListener(ActivateEvent.DEACTIVATE, receiver.deactivateHandler);
+			// attach by literal event name to avoid Argo dependency
+			// normally this would be IMEEvent.START_COMPOSITION
+			_container.addEventListener("imeStartComposition", receiver.imeStartCompositionHandler);
+			
+//TODO context menu
+//			if (_container.contextMenu)
+//				_container.contextMenu.addEventListener(ContextMenuEvent.MENU_SELECT, receiver.menuSelectHandler);
+			_container.addEventListener(EditEvent.COPY, receiver.editHandler);
+			_container.addEventListener(SelectionEvent.SELECT_ALL, receiver.editHandler);
+			_container.addEventListener(EditEvent.CUT, receiver.editHandler);
+			_container.addEventListener(EditEvent.PASTE, receiver.editHandler);
+			_container.addEventListener(EditEvent.CLEAR, receiver.editHandler);
+		}
+		
+		/** @private */
+		public function removeInteractionHandlers():void
+		{
+			var receiver:IInteractionEventHandler = getInteractionHandler();
+			
+			_container.removeEventListener(MouseEvent.MOUSE_DOWN, requiredMouseDownHandler);
+			_container.removeEventListener(FocusEvent.FOCUS_OUT, requiredFocusOutHandler);
+			_container.removeEventListener(MouseEvent.DOUBLE_CLICK, receiver.mouseDoubleClickHandler);
+			_container.removeEventListener(ActivateEvent.ACTIVATE, receiver.activateHandler);
+			_container.removeEventListener(FocusEvent.MOUSE_FOCUS_CHANGE, receiver.focusChangeHandler);
+			_container.removeEventListener(FocusEvent.KEY_FOCUS_CHANGE, receiver.focusChangeHandler);
+			_container.removeEventListener(TextEvent.TEXT_INPUT, receiver.textInputHandler);
+			_container.removeEventListener(MouseEvent.MOUSE_OUT, receiver.mouseOutHandler);
+			removeMouseWheelListener();
+			_container.removeEventListener(ActivateEvent.DEACTIVATE, receiver.deactivateHandler);
+			//	_container.removeEventListener(IMEEvent.IME_START_COMPOSITION, receiver.imeStartCompositionHandler); 
+			// attach by literal event name to avoid Argo dependency
+			_container.removeEventListener("imeStartComposition", receiver.imeStartCompositionHandler); 
+			
+//TODO context menu
+//			if (_container.contextMenu) 
+//				_container.contextMenu.removeEventListener(ContextMenuEvent.MENU_SELECT, receiver.menuSelectHandler);
+			_container.removeEventListener(EditEvent.COPY, receiver.editHandler); 
+			_container.removeEventListener(SelectionEvent.SELECT_ALL, receiver.editHandler);
+			_container.removeEventListener(EditEvent.CUT, receiver.editHandler);
+			_container.removeEventListener(EditEvent.PASTE, receiver.editHandler);
+			_container.removeEventListener(EditEvent.CLEAR, receiver.editHandler);
+			
+			clearSelectHandlers();	
+		}
+		
+		/** @private */
+		private function detachContainer():void
+		{
+			if (_minListenersAttached)
+			{
+                _container.removeEventListener(FocusEvent.FOCUS_IN, requiredFocusInHandler);
+                _container.removeEventListener(MouseEvent.MOUSE_OVER, requiredMouseOverHandler);
+
+                if(_allListenersAttached)
+                {
+                    removeInteractionHandlers();
+                    removeContextMenu();
+
+                    attachTransparentBackgroundForHit(true);
+                    _allListenersAttached = false;
+                }
+				_minListenersAttached = false;
+			}
+			removeMouseWheelListener();
+		}
+		
+		
+		private function attachAllListeners():void
+		{	
+			if (!_allListenersAttached && textFlow && textFlow.interactionManager)
+			{
+				CONFIG::debug { assert(_minListenersAttached,"Bad call to attachAllListeners - won't detach"); }
+				_allListenersAttached = true;
+                attachContextMenu();
+                attachInteractionHandlers();
+			}
+		}
+		
+		/** @private */
+		public function addMouseWheelListener():void
+		{
+			if (!_mouseWheelListenerAttached)
+			{
+				_container.addEventListener(MouseEvent.WHEEL, getInteractionHandler().mouseWheelHandler);
+				_mouseWheelListenerAttached = true;
+			}
+		}
+		
+		/** @private */
+		public function removeMouseWheelListener():void
+		{
+			if (_mouseWheelListenerAttached)
+			{
+				_container.removeEventListener(MouseEvent.WHEEL, getInteractionHandler().mouseWheelHandler);
+				_mouseWheelListenerAttached = false;
+			}
+		}
+		
+		/** @private */
+		public function attachContextMenu():void
+		{
+//TODO deal with context menu
+//			_container.contextMenu = createContextMenu();
+		}
+		
+		/** @private */
+		public function removeContextMenu():void
+		{
+//TODO deal with context menu
+//			 _container.contextMenu = null;
+		}
+
+		
+		/** @private  
+		 *
+		 * Shared so that TextContainerManager can create the same ContextMenu. 
+		 */
+		static public function createDefaultContextMenu():ContextMenu
+		{
+			var contextMenu:ContextMenu = new ContextMenu();
+			contextMenu.clipboardMenu = true;
+			contextMenu.clipboardItems.clear = true;
+			contextMenu.clipboardItems.copy = true;
+			contextMenu.clipboardItems.cut = true;
+			contextMenu.clipboardItems.paste = true;
+			contextMenu.clipboardItems.selectAll = true;
+			return contextMenu;
+		}
+		
+		/** 
+		 * Creates a context menu for the ContainerController. Use the methods of the ContextMenu class to 
+		 * add items to the menu.
+		 * <p>You can override this method to define a custom context menu.</p>
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * @see flash.ui.ContextMenu ContextMenu
+		 */
+		protected function createContextMenu():ContextMenu
+		{
+			return createDefaultContextMenu();
+		}
+		
+        public function dispose():void
+        {
+            stopMouseSelectionScrolling();
+            clearSelectionShapes();
+            setRootElement(null);
+        }
+
+        private function stopMouseSelectionScrolling(containerRoot:IEventDispatcher = null):void
+        {
+            if(_scrollTimer)
+            {
+                _scrollTimer.stop();
+                _scrollTimer.removeEventListener(Timer.TIMER, scrollTimerHandler);
+
+//TODO fix this for FlexJS
+//                if(!containerRoot)
+//                {
+//                    containerRoot = getContainerRoot();
+//                }
+
+                if(containerRoot)
+                {
+                    containerRoot.removeEventListener(MouseEvent.MOUSE_UP, scrollTimerHandler);
+                }
+
+                _scrollTimer = null;
+            }
+        }
+		/** @private */
+		public function scrollTimerHandler(event:Event):void
+		{
+			// trace("BEGIN scrollTimerHandler");
+			if (!_scrollTimer)
+				return;
+			
+			// shut it down if not in this container
+			if (textFlow.interactionManager == null || textFlow.interactionManager.activePosition < absoluteStart || textFlow.interactionManager.activePosition > absoluteStart+textLength)
+				event = null;
+			
+			
+			// We're listening for MOUSE_UP so we can cancel autoscrolling
+			if (event is MouseEvent)
+			{
+				stopMouseSelectionScrolling(event.currentTarget as IEventDispatcher);
+//				CONFIG::debug { assert(_container.stage ==  null || getContainerRoot() == event.currentTarget,"scrollTimerHandler bad target"); }
+			}
+			else if (!event)
+			{
+                stopMouseSelectionScrolling();
+			}
+//TODO deal with stage
+//			else if (_container.stage)
+//			{
+//				var containerPoint:Point = new Point(_container.stage.mouseX, _container.stage.mouseY);
+//				containerPoint = _container.globalToLocal(containerPoint);
+//				var scrollChange:int = autoScrollIfNecessaryInternal(containerPoint);
+//				if (scrollChange != 0 && interactionManager)		// force selection update if we actually scrolled and we have a selection manager
+//				{
+//					var mouseEvent:MouseEvent = new PsuedoMouseEvent(MouseEvent.MOUSE_MOVE,false,false,_container.stage.mouseX, _container.stage.mouseY,_container.stage,false,false,false,true);
+//					var stashedScrollTimer:Timer = _scrollTimer;	
+//					try
+//					{
+//						_scrollTimer =  null;
+//						interactionManager.mouseMoveHandler(mouseEvent);
+//					}
+//					catch (e:Error)
+//					{
+//						throw(e);
+//					}
+//					finally
+//					{
+//						_scrollTimer = stashedScrollTimer;
+//					}
+//				}
+//			}
+			// trace("AFTER scrollTimerHandler");
+		}
+		
+		/** 
+		 * Handle a scroll event during a "drag" selection. 
+		 *
+		 * @param mouseX	The horizontal position of the mouse cursor on the stage.
+		 * @param mouseY	The vertical position of the mouse cursor  on the stage.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		
+		public function autoScrollIfNecessary(mouseX:int, mouseY:int):void
+		{ 			
+			if (flowComposer.getControllerAt(flowComposer.numControllers-1) != this)
+			{
+				var verticalText:Boolean = (effectiveBlockProgression == BlockProgression.RL);
+				var lastController:IContainerController = flowComposer.getControllerAt(flowComposer.numControllers - 1);
+				if ((verticalText && _horizontalScrollPolicy == ScrollPolicy.OFF) ||
+					(!verticalText && _verticalScrollPolicy == ScrollPolicy.OFF))
+					return;
+				var r:Rectangle = DisplayUtils.getScreenBoundingRect(lastController.container);// lastController.container.getBounds(_container.stage);
+				if (verticalText)
+				{
+					if (mouseY >= r.top && mouseY <= r.bottom)
+						lastController.autoScrollIfNecessary(mouseX, mouseY);
+				}
+				else
+				{
+					if (mouseX >= r.left && mouseX <= r.right)
+						lastController.autoScrollIfNecessary(mouseX, mouseY);
+				}
+			}
+			
+			// even if not the last container - may scroll if there are explicit linebreaks
+			if (!_hasScrollRect)
+				return;
+			var containerPoint:Point = new Point(mouseX, mouseY);
+			containerPoint = PointUtils.globalToLocal(containerPoint, _container);// _container.globalToLocal(containerPoint); 			
+			autoScrollIfNecessaryInternal(containerPoint);
+		}
+		
+		/** 
+		 * Handle a scroll event during a "drag" selection. 
+		 *
+		 * @param mouseX	The horizontal position of the mouse cursor on the stage.
+		 * @param mouseY	The vertical position of the mouse cursor  on the stage.
+		 * @returns positive number if scroll went forward in reading order, negative number if it went backwards, and 0 if no scroll
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		
+		private function autoScrollIfNecessaryInternal(extreme:Point):int
+		{
+			CONFIG::debug 
+			{ 
+				assert(_hasScrollRect, "internal scrolling function called on non-scrollable container");
+			}
+			
+			
+			var scrollDirection:int = 0;
+			
+			if (extreme.y - containerScrollRectBottom > 0) {
+				verticalScrollPosition += textFlow.configuration.scrollDragPixels;
+				scrollDirection = 1;
+			}
+			else if (extreme.y - containerScrollRectTop < 0) {
+				verticalScrollPosition -= textFlow.configuration.scrollDragPixels;
+				scrollDirection = -1;
+			}
+			
+			if (extreme.x - containerScrollRectRight > 0) {
+				horizontalScrollPosition += textFlow.configuration.scrollDragPixels;
+				scrollDirection = -1;
+			}
+			else if (extreme.x - containerScrollRectLeft < 0) {
+				horizontalScrollPosition -= textFlow.configuration.scrollDragPixels;
+				scrollDirection = 1;
+			}
+			
+			// we need a timer so that the mouse doesn't have to continue moving when the mouse is outside the content area
+			if (scrollDirection != 0 && !_scrollTimer) 
+			{
+				_scrollTimer = new Timer(textFlow.configuration.scrollDragDelay);	// 35 ms is the default auto-repeat interval for ScrollBars.
+				_scrollTimer.addEventListener(Timer.TIMER, scrollTimerHandler, false, 0, true);
+//TODO deal with platform specific events
+//				if (getContainerRoot())
+//				{
+//					getContainerRoot().addEventListener(MouseEvent.MOUSE_UP, scrollTimerHandler, false, 0, true);
+//					beginMouseCapture(); // TELL CLIENTS WE WANT mouseUpSomewhere events
+//				}
+				_scrollTimer.start();
+			}
+			
+			return scrollDirection;
+		}
+		
+		/** @private */ 
+		public function getFirstVisibleLine():ITextFlowLine
+		{ return _shapeChildren.length ? _shapeChildren[0].userData : null; }
+		/** @private */
+		public function getLastVisibleLine():ITextFlowLine
+		{ return _shapeChildren.length ? _shapeChildren[_shapeChildren.length-1].userData : null; }
+		
+		/** 
+		 * Figure out the scroll distance required to scroll up or down by the specified number of lines.
+		 * Negative numbers scroll upward, bringing more of the top of the TextFlow into view. Positive numbers 
+		 * scroll downward, bringing the next line from the bottom into full view.
+		 * 
+		 * <p>When scrolling up, for example, the method makes the next line fully visible. If the next line is partially
+		 * obscured and the number of lines specified is 1, the partially obscured line becomes fully visible.</p>
+		 *
+		 * @param nLines	The number of lines to scroll.
+		 *
+		 * @return 	the delta amount of space to scroll
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		
+		public function getScrollDelta(numLines:int):Number
+		{
+			var flowComposer:IFlowComposer = textFlow.flowComposer;
+			
+			if (flowComposer.numLines == 0)
+				return 0;
+			
+			// Now we want to calculate the top & bottom lines within the scrollRect. It's ok if they're just partially
+			// visible. Once we determine these lines, we figure out how much we need to scroll in order to bring the
+			// lines completely into view.
+			
+			var firstVisibleLine:ITextFlowLine = getFirstVisibleLine();
+			if (!firstVisibleLine)
+				return 0;
+
+			var lastVisibleLine:ITextFlowLine = getLastVisibleLine();
+			CONFIG::debug { assert(lastVisibleLine != null,"Expect lastVisibleLine when there is a firstVisibleLine"); }
+				
+			// trace("    // findFirstAndLastVisibleLine ",flowComposer.findLineIndexAtPosition(firstVisibleLine.absoluteStart),flowComposer.findLineIndexAtPosition(lastVisibleLine.absoluteStart));
+			
+			var newLineIndex:int;
+			var lineIndex:int;
+			if (numLines > 0) 
+			{
+				lineIndex = flowComposer.findLineIndexAtPosition(lastVisibleLine.absoluteStart);
+				// If the last visible line is only partly visible, don't count it as visible. But make sure it overlaps by
+				// at least two pixels, otherwise it doesn't look like its clipped.
+
+				var lastTextLine:ITextLine = lastVisibleLine.getTextLine(true);
+				if (effectiveBlockProgression == BlockProgression.TB)
+				{
+					if ((lastTextLine.y + lastTextLine.descent) - containerScrollRectBottom > 2)
+						--lineIndex;
+				}
+				else if (containerScrollRectLeft - (lastTextLine.x - lastTextLine.descent)  > 2)
+					--lineIndex;
+				
+				// if we hit the end, force composition so that we get more lines - I picked a random amount to scroll forward, if its not enough, it will keep going
+				while (lineIndex + numLines > flowComposer.numLines - 1 && flowComposer.damageAbsoluteStart < textFlow.textLength)	
+				{
+					var previousDamageStart:int = flowComposer.damageAbsoluteStart;
+					flowComposer.composeToPosition(flowComposer.damageAbsoluteStart + 1000);
+					// if we've made no progress, abort
+					if (flowComposer.damageAbsoluteStart == previousDamageStart)
+						return 0;
+				}
+				newLineIndex = Math.min(flowComposer.numLines-1, lineIndex + numLines);
+			}
+			if (numLines < 0) 
+			{
+				lineIndex = flowComposer.findLineIndexAtPosition(firstVisibleLine.absoluteStart);
+				
+				// If the first visible line is only partly visible, don't count it as visible. But make sure it overlaps by
+				// at least two pixels, otherwise it doesn't look like its clipped.
+				if (effectiveBlockProgression == BlockProgression.TB)
+				{
+					if (firstVisibleLine.y + 2 < containerScrollRectTop)
+						++lineIndex;
+				}
+				else if (firstVisibleLine.x + firstVisibleLine.ascent > containerScrollRectRight + 2)
+					++lineIndex;
+				
+				newLineIndex = Math.max(0, lineIndex + numLines);
+			}
+			
+			var line:ITextFlowLine = flowComposer.getLineAt(newLineIndex);
+			if (line.absoluteStart < absoluteStart)		// don't scroll past the start of this controller -- previous text is in previous controller
+				return 0;
+			if (line.validity != "valid")
+			{
+				var leaf:IFlowLeafElement = textFlow.findLeaf(line.absoluteStart);
+				var paragraph:IParagraphElement = leaf.getParagraph();
+				textFlow.flowComposer.composeToPosition(paragraph.getAbsoluteStart() + paragraph.textLength);
+				line = flowComposer.getLineAt(newLineIndex);
+				CONFIG::debug { assert(line.validity == "valid", "expected valid line after recomposing"); }
+			}
+			
+			var verticalText:Boolean = effectiveBlockProgression == BlockProgression.RL;
+			
+			var newScrollPosition:Number;
+			if (verticalText)
+			{
+				
+				newScrollPosition =  numLines < 0 ? line.x + line.textHeight : line.x - line.descent + _compositionWidth;
+				return newScrollPosition - horizontalScrollPosition;
+			}
+			
+			newScrollPosition = numLines < 0 ? line.y : line.y + line.textHeight - _compositionHeight;
+			return newScrollPosition - verticalScrollPosition;
+		}
+		
+		/** 
+		 * Processes the <code>MouseEvent.MOUSE_OVER</code> event when the client manages events. 
+		 *
+		 * @param event The MouseEvent object.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 *
+		 * @see org.apache.flex.events.MouseEvent#MOUSE_OVER MouseEvent.MOUSE_OVER
+		 */
+		
+		public function mouseOverHandler(event:MouseEvent):void
+		{
+			if (interactionManager && !event.isDefaultPrevented())
+				interactionManager.mouseOverHandler(event);
+		}
+		
+		/** @private Does required mouseOver handling.  Calls mouseOverHandler.  @see #mouseOverHandler */
+		public function requiredMouseOverHandler(event:MouseEvent):void
+		{
+			attachAllListeners();
+			getInteractionHandler().mouseOverHandler(event);
+		}
+		
+		/** Processes the <code>MouseEvent.MOUSE_OUT</code> event when the client manages events.
+		 *
+		 * @param event The MouseEvent object.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * @see org.apache.flex.events.MouseEvent#MOUSE_OUT MouseEvent.MOUSE_OUT
+		 */				
+		public function mouseOutHandler(event:MouseEvent):void
+		{
+			if (interactionManager && !event.isDefaultPrevented())
+				interactionManager.mouseOutHandler(event);
+		}
+		
+		/** Processes the <code>MouseEvent.MOUSE_WHEEL</code> event when the client manages events.
+		 *
+		 * @param event The MouseEvent object.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * @see org.apache.flex.events.MouseEvent#MOUSE_WHEEL MouseEvent.MOUSE_WHEEL
+		 */
+		public function mouseWheelHandler(event:MouseEvent):void
+		{
+			if (event.isDefaultPrevented())
+				return;
+			
+			// Do the scroll and call preventDefault only if the there is enough text to scroll. Otherwise
+			// we let the event bubble up and cause scrolling at the next level up in the client's container hierarchy.
+			var verticalText:Boolean = effectiveBlockProgression == BlockProgression.RL;
+			if (verticalText)
+			{
+				if (contentWidth > _compositionWidth && !_measureWidth)
+				{
+					horizontalScrollPosition += event.delta * textFlow.configuration.scrollMouseWheelMultiplier;
+					event.preventDefault();
+				}
+			}
+			else if (contentHeight > _compositionHeight && !_measureHeight)
+			{
+				verticalScrollPosition -= event.delta * textFlow.configuration.scrollMouseWheelMultiplier;
+				event.preventDefault();
+			}
+		}
+		
+		
+		/** Processes the <code>MouseEvent.MOUSE_DOWN</code> event when the client manages events. 
+		 *
+		 * @param event The MouseEvent object.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * @see org.apache.flex.events.MouseEvent#MOUSE_DOWN MouseEvent.MOUSE_DOWN
+		 */
+		
+		public function mouseDownHandler(event:MouseEvent):void
+		{
+			if (interactionManager && !event.isDefaultPrevented())
+			{
+				interactionManager.mouseDownHandler(event);
+				// grab the focus - alternative is to listen to keyevents on the Application
+				// is this necessary?
+				if ( interactionManager.hasSelection())
+					setFocus();
+			}
+		}
+		
+		/** @private Does required mouseDown handling.  Calls mouseDownHandler.  @see #mouseDownHandler */
+		public function requiredMouseDownHandler(event:MouseEvent):void
+		{
+			if (!_selectListenersAttached)
+			{
+//TODO fix root events
+//				var containerRoot:DisplayObject = getContainerRoot();
+//				if (containerRoot)
+//				{
+//					containerRoot.addEventListener(MouseEvent.MOUSE_MOVE, rootMouseMoveHandler, false, 0, true); 
+//					containerRoot.addEventListener(MouseEvent.MOUSE_UP,   rootMouseUpHandler, false, 0, true);
+//					
+//					beginMouseCapture(); // TELL CLIENTS THAT WE WANT moueUpSomewhere EVENTS
+//					
+//					
+//					_selectListenersAttached = true;
+//				}
+			}
+			getInteractionHandler().mouseDownHandler(event); 
+		}
+		
+		/** 
+		 * Processes the <code>MouseEvent.MOUSE_UP</code> event when the client manages events.
+		 *
+		 * @param event The MouseEvent object.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * @see org.apache.flex.events.MouseEvent#MOUSE_UP MouseEvent.MOUSE_UP
+		 *
+		 */
+		public function mouseUpHandler(event:MouseEvent):void
+		{
+			if (interactionManager && event && !event.isDefaultPrevented())
+			{
+				interactionManager.mouseUpHandler(event);
+			}
+		}		
+		
+		/** @private */
+		public function rootMouseUpHandler(event:MouseEvent):void
+		{
+			clearSelectHandlers();
+			getInteractionHandler().mouseUpHandler(event);
+		}
+		
+		
+		private function clearSelectHandlers():void
+		{	
+			if (_selectListenersAttached)
+			{
+//TODO fix root events
+//				CONFIG::debug { assert(getContainerRoot() != null,"No container root"); }
+//				getContainerRoot().removeEventListener(MouseEvent.MOUSE_MOVE, rootMouseMoveHandler); 					
+//				getContainerRoot().removeEventListener(MouseEvent.MOUSE_UP,   rootMouseUpHandler);
+//				endMouseCapture(); // TELL CLIENTS WE NO LONGER WANT mouseUpSomewhere EVENTS
+//				_selectListenersAttached = false;
+			}
+		}
+		
+		/** 
+		 * Called to request clients to begin the forwarding of mouseup and mousemove events from outside a security sandbox.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 */
+		public function beginMouseCapture():void
+		{
+			// trace("BEGIN MOUSECAPTURE");
+			var sandboxManager:ISandboxSupport = getInteractionHandler() as ISandboxSupport;
+			if (sandboxManager && sandboxManager != this)
+				sandboxManager.beginMouseCapture();
+		}
+		/** 
+		 * Called to inform clients that the the forwarding of mouseup and mousemove events from outside a security sandbox is no longer needed.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 */
+		public function endMouseCapture():void
+		{
+			// trace("END MOUSECAPTURE");
+			var sandboxManager:ISandboxSupport = getInteractionHandler() as ISandboxSupport;
+			if (sandboxManager && sandboxManager != this)
+				sandboxManager.endMouseCapture();
+		}
+		/** Client call to forward a mouseUp event from outside a security sandbox.  Coordinates of the mouse up are not needed.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 */
+		public function mouseUpSomewhere(event:Event):void
+		{
+			rootMouseUpHandler(null);
+			scrollTimerHandler(null);
+		}
+		/** Client call to forward a mouseMove event from outside a security sandbox.  Coordinates of the mouse move are not needed.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 */
+		public function mouseMoveSomewhere(event:Event):void
+		{
+			return;	// do nothing right now
+		}
+		
+		// What'd I hit???
+		private function hitOnMyFlowExceptLastContainer(event:MouseEvent):Boolean
+		{
+			if (event.target is ITextLine)
+			{
+				var tfl:ITextFlowLine = ITextLine(event.target).userData as ITextFlowLine;
+				if (tfl)
+				{
+					var para:IParagraphElement = tfl.paragraph;
+					if(para.getTextFlow() == textFlow)
+						return true;
+				}
+			}
+//TODO how to properly check

<TRUNCATED>

[37/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/StandardFlowComposer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/StandardFlowComposer.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/StandardFlowComposer.as
new file mode 100644
index 0000000..bf7d081
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/StandardFlowComposer.as
@@ -0,0 +1,879 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.compose
+{
+	import org.apache.flex.core.IParentIUIBase;
+	import org.apache.flex.textLayout.container.IContainerController;
+	import org.apache.flex.textLayout.container.ScrollPolicy;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.edit.ISelectionManager;
+	import org.apache.flex.textLayout.elements.BackgroundManager;
+	import org.apache.flex.textLayout.elements.IBackgroundManager;
+	import org.apache.flex.textLayout.elements.IContainerFormattedElement;
+	import org.apache.flex.textLayout.elements.ITableCellElement;
+	import org.apache.flex.textLayout.elements.ITableElement;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.textLayout.events.CompositionCompleteEvent;
+	import org.apache.flex.textLayout.events.ModelChange;
+	import org.apache.flex.textLayout.formats.BlockProgression;
+	import org.apache.flex.textLayout.utils.ComposeUtils;
+    
+	// import org.apache.flex.textLayout.accessibility.TextAccImpl;
+
+
+
+	
+	/** 
+	* The StandardFlowComposer class provides a standard composer and container manager. 
+	*
+	* <p>Each call to <code>compose()</code> or <code>updateAllControllers()</code> normalizes the text flow as a first step.  
+	* The normalizing process checks the parts of the TextFlow object that were modified and takes the following steps:
+	* <ol>
+	* <li> Deletes empty FlowLeafElement and SubParagraphGroupElement objects.</li>
+	* <li> Merges sibling spans that have identical attributes.</li>
+	* <li> Adds an empty paragraph if a flow is empty.</li>
+ 	* </ol>
+ 	* </p>
+	*
+	* <p>To use a StandardFlowComposer, assign it to the
+	* <code>flowComposer</code> property of a TextFlow object. Call the <code>updateAllControllers()</code>
+	* method to lay out and display the text in the containers attached to the flow composer.</p>
+	* 
+	* <p><b>Note:</b> For simple, static text flows, you can also use the one of the text line factory classes.
+	* These factory classes will typically create lines with less overhead than a flow composer, but do not
+	* support editing, dynamic changes, or user interaction.</p>
+	* 
+	* @see org.apache.flex.textLayout.elements.TextFlow#flowComposer
+	* @playerversion Flash 10
+	* @playerversion AIR 1.5
+	* @langversion 3.0
+	*/
+	
+	public class StandardFlowComposer extends FlowComposerBase implements IFlowComposer
+	{
+		/** @private */
+		protected var _rootElement:IContainerFormattedElement;
+		private var _controllerList:Array;
+		private var _composing:Boolean;
+
+		
+		/** 
+		* Creates a StandardFlowComposer object. 
+		*
+		* <p>To use an StandardFlowComposer object, assign it to the
+		* <code>flowComposer</code> property of a TextFlow object. Call the <code>updateAllControllers()</code>
+		* method to lay out and display the text in the containers attached to the flow composer.</p>
+		* 
+
+		* 
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0
+	 	*/
+	 	
+		public function StandardFlowComposer()
+		{
+			super();
+			_controllerList = [];
+			_composing = false;
+		}
+
+		/** 
+		 * True, if the flow composer is currently performing a composition operation. 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get composing():Boolean
+		{ return _composing; }
+		
+		/** 
+		 * Returns the absolute position of the first content element in the specified ContainerController object.
+		 *
+		 * <p>A position is calculated by counting the division between two characters or other elements of a text flow. 
+		 * The position preceding the first element of a flow is zero. An absolute position is the position
+		 * counting from the beginning of the flow.</p>
+		 * 
+		 * @param controller A ContainerController object associated with this flow composer.
+		 * @return the position before the first character or graphic in the ContainerController.
+		 *
+		 *  
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+		 
+		public function getAbsoluteStart(controller:IContainerController):int
+		{
+			// don't look at controller's relativeStart property - it uses this method.  hmmmm 
+			// TODO: that does seem odd - clean the above implementation up.
+			var stopIdx:int = getControllerIndex(controller);
+			CONFIG::debug { assert(stopIdx != -1,"bad controller to LayoutFlowComposer.getRelativeStart"); }
+			var rslt:int = _rootElement.getAbsoluteStart();
+			for (var idx:int = 0; idx < stopIdx; idx++)
+				rslt += _controllerList[idx].textLength;
+				
+			return rslt;
+		}
+		
+		/** @copy IFlowComposer#rootElement
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+		 */
+		
+		public function get rootElement():IContainerFormattedElement
+		{ return _rootElement; }
+		
+		
+		/** @copy IFlowComposer#setRootElement()
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 * @flexjsignorecoercion org.apache.flex.textLayout.elements.ITextFlow
+		 */
+		public function setRootElement(newRootElement:IContainerFormattedElement):void
+		{
+
+			if (_rootElement != newRootElement)
+			{
+				if (newRootElement is ITextFlow && (newRootElement as ITextFlow).flowComposer != this)
+					(newRootElement as ITextFlow).flowComposer = this;
+				else
+				{
+					clearCompositionResults();
+
+					detachAllContainers();
+					_rootElement = newRootElement;
+					_textFlow = _rootElement ? _rootElement.getTextFlow() :  null;
+					attachAllContainers();
+				}
+			}
+		}
+		
+		/** @private */
+		public function detachAllContainers():void
+		{
+			
+			// detatch accessibility from the containers
+			// Why only the first container?
+			// No accessibility yet...
+			// if (_controllerList.length > 0 && _textFlow)
+			// {
+			// 	var firstContainerController:ContainerController = getControllerAt(0);
+			// 	var firstContainer:Sprite = firstContainerController.container;
+			// 	if (firstContainer)
+			// 		clearContainerAccessibilityImplementation(firstContainer);
+		  	// }
+		  	
+		  	var cont:IContainerController;
+			for each (cont in _controllerList)
+			{
+				cont.dispose();
+			}
+		}
+		
+		// static private function clearContainerAccessibilityImplementation(cont:Sprite):void
+		// {
+		// 	if (cont.accessibilityImplementation)
+		// 	{
+		// 		if (cont.accessibilityImplementation is TextAccImpl)
+		// 			TextAccImpl(cont.accessibilityImplementation).detachListeners();
+		// 		cont.accessibilityImplementation = null;
+		// 	}
+		// }
+		
+		/** @private */
+		public function attachAllContainers():void
+		{
+			var cont:IContainerController;
+			for each (cont in _controllerList)
+				cont.setRootElement(_rootElement);
+			
+
+			if (_controllerList.length > 0 && _textFlow)
+			{
+				// attach accessibility to the containers
+				// Why only the first container?  There are workflows that this will fail
+				// for example: a pagination workflow that has a composed chain of containers but only displays one at a time.
+				//TODO No accessibility yet...
+				// if (textFlow.configuration.enableAccessibility && Capabilities.hasAccessibility)
+				// {
+				// 	var firstContainer:Sprite = getControllerAt(0).container;
+				// 	if (firstContainer)
+				// 	{
+				// 		clearContainerAccessibilityImplementation(firstContainer);
+				// 		firstContainer.accessibilityImplementation = new TextAccImpl(firstContainer, _textFlow);
+				// 	}
+				// }
+				
+				var curContainer:IParentIUIBase;
+				// turn off focusRect on all containers
+				for (var i:int = 0; i < _controllerList.length; ++i)
+				{
+					curContainer = getControllerAt(i).container;
+//TODO
+//					if (curContainer)
+//						curContainer.focusRect = false;
+				} 
+		  	}
+
+			// TODO: can be more efficient? - just damage all
+			clearCompositionResults();				
+		}
+		
+		/** @copy IFlowComposer#numControllers
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0
+		*/
+		
+		public function get numControllers():int
+		{ return _controllerList ? _controllerList.length : 0; }
+		
+		/** @copy IFlowComposer#addController()
+		 *
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+		 */
+		 
+		public function addController(controller:IContainerController):void
+		{
+			CONFIG::debug { assert (_controllerList.indexOf(controller) < 0, "adding controller twice"); }
+			_controllerList.push(IContainerController(controller));
+			if (this.numControllers == 1)
+			{				
+				attachAllContainers();
+			}
+			else
+			{
+				controller.setRootElement(_rootElement);
+//TODO
+//				var curContainer:IParentIUIBase = controller.container;
+//				if (curContainer)
+//					curContainer.focusRect = false;
+				if (textFlow)
+				{
+					// mark the previous container as geometry damaged - this is more than is needed
+					controller = this.getControllerAt(this.numControllers-2);
+					var damageStart:int = controller.absoluteStart;
+					var damageLen:int = controller.textLength;
+					// watch out for an empty previous container
+					if (damageLen == 0)
+					{
+						if (damageStart != textFlow.textLength)
+							damageLen++;
+						else if (damageStart != 0)
+						{
+							damageStart--;
+							damageLen++;
+						}
+					}
+					if (damageLen)
+						textFlow.damage(damageStart,damageLen,FlowDamageType.GEOMETRY,false);
+				}
+			}
+		}
+		/** @copy IFlowComposer#addControllerAt()
+		 *
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+		 */
+		 
+		public function addControllerAt(controller:IContainerController, index:int):void
+		{
+			CONFIG::debug { assert (_controllerList.indexOf(controller) == -1, "adding controller twice"); }
+			detachAllContainers();
+			_controllerList.splice(index,0,IContainerController(controller));
+			attachAllContainers();
+		}
+		
+		/** Removes a trailing controller with no content without doing any damage */
+		private function fastRemoveController(index:int):Boolean
+		{
+			if (index == -1)
+				return true;
+			var cont:IContainerController = _controllerList[index];
+			if (!cont)
+				return true;
+			if (!_textFlow || cont.absoluteStart == _textFlow.textLength)
+			{
+//TODO Accessibility
+//				if (index == 0)
+//				{
+//					var firstContainer:IParentIUIBase = cont.container;
+//					if (firstContainer)
+//						clearContainerAccessibilityImplementation(firstContainer);				
+//				}
+				cont.setRootElement(null);
+				_controllerList.splice(index,1);
+				return true;
+			} 	
+			return false;
+		}
+		
+		/** @copy IFlowComposer#removeController()
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+		 */
+		 
+		public function removeController(controller:IContainerController):void
+		{ 
+			var index:int = getControllerIndex(controller);
+			if (!fastRemoveController(index))
+			{
+				detachAllContainers();
+				_controllerList.splice(index,1);
+				attachAllContainers();
+			}
+		}
+		/** @copy IFlowComposer#removeControllerAt()
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+		 
+		public function removeControllerAt(index:int):void
+		{ 
+			if (!fastRemoveController(index))
+			{
+				detachAllContainers();
+				_controllerList.splice(index,1);
+				attachAllContainers();
+			}
+		}
+		/** @copy IFlowComposer#removeAllControllers()
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+		 */
+		 
+		public function removeAllControllers():void
+		{
+			detachAllContainers();
+			_controllerList.splice(0,_controllerList.length);
+		}
+		
+		/** @copy IFlowComposer#getControllerAt()  
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+		
+		public function getControllerAt(index:int):IContainerController
+		{
+			return _controllerList[index];
+		}
+		
+		/** @copy IFlowComposer#getControllerIndex()  
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		public function getControllerIndex(controller:IContainerController):int
+		{
+			// TODO: binary search? 
+			for (var idx:int = 0; idx < _controllerList.length; idx++)
+			{
+				if (_controllerList[idx] == controller)
+					return idx;
+			}
+			return -1; 
+		}
+		
+		/** 
+		 * Returns the index of the controller containing the content at the specified position. 
+		 * 
+		 * <p>A position can be considered to be the division between two characters or other elements of a text flow. If 
+		 * the value in <code>absolutePosition</code> is a position between the last character of one 
+		 * container and the first character of the next, then the preceding container is returned if
+		 * the <code>preferPrevious</code> parameter is set to <code>true</code> and the later container is returned if
+		 * the <code>preferPrevious</code> parameter is set to <code>false</code>.</p>
+		 *
+		 * <p>The method returns -1 if the content at the specified position is not in any container or is outside
+		 * the range of positions in the text flow.</p>
+		 * 
+		 * @param absolutePosition The position of the content for which the container index is sought.
+		 * @param preferPrevious Specifies which container index to return when the position is between the last element in 
+		 * one container and the first element in the next.
+		 * 
+		 * @return 	the index of the container controller or -1 if not found.
+		 *
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+		 */
+		
+		public function findControllerIndexAtPosition(absolutePosition:int,preferPrevious:Boolean=false):int
+		{
+			
+			var lo:int = 0;
+			var hi:int = _controllerList.length-1;
+			while (lo <= hi)
+			{
+				var mid:int = (lo+hi)/2;
+				var cont:IContainerController = _controllerList[mid];
+				if (cont.absoluteStart <= absolutePosition)
+				{
+					if (preferPrevious)
+					{
+						if (cont.absoluteStart + cont.textLength >= absolutePosition)
+						{
+							// find first container or first one with non-zero textLength
+							while (mid != 0 && cont.absoluteStart == absolutePosition)
+							{
+								mid--;
+								cont = _controllerList[mid];
+							}
+							return mid;
+						}
+					}
+					else
+					{
+
+						if (cont.absoluteStart == absolutePosition && cont.textLength != 0)
+						{
+							while (mid != 0)
+							{
+								cont = _controllerList[mid-1];
+								if (cont.textLength != 0)
+									break;
+								mid--;
+							}
+							return mid;
+						}
+						if (cont.absoluteStart + cont.textLength > absolutePosition)
+							return mid;
+					}
+					lo = mid+1;
+				}
+				else
+					hi = mid-1;
+			}
+			return -1;
+		}
+
+		/** Clear whatever computed values are left from the last composition, in the flow composer and
+		 * in each of its controllers. @private
+		 */
+		 
+		public function clearCompositionResults():void
+		{
+			initializeLines();
+			for each (var cont:IContainerController in _controllerList)
+				cont.clearCompositionResults();
+		}
+
+		/** 
+		 * Composes the content of the root element and updates the display.  
+		 *
+		 * <p>Text layout is conducted in two phases: composition and display. In the composition phase,
+		 * the flow composer calculates how many lines are necessary to display the content as well as the position of these 
+		 * lines in the flow's display containers. In the display phase, 
+		 * the flow composer updates the display object children of its containers. The <code>updateAllControllers()</code>
+		 * method initiates both phases in sequence. The StandardFlowComposer keeps track of changes to content
+		 * so that a full cycle of composition and display is only performed when necessary.</p>
+		 * 
+		 * <p>This method updates all the text lines and the display list immediately and synchronously.</p>
+		 *
+		 * <p>If the contents of any container is changed, the method returns <code>true</code>.</p>
+		 * 
+		 * @return true if anything changed.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 * 
+		 */
+		 
+		public function updateAllControllers():Boolean
+		{
+			return updateToController();
+		}
+		
+		/** 
+		 * Composes and updates the display up to and including the container at the specified index.
+		 * 
+		 * <p>The <code>updateToController()</code> method composes the content and 
+		 * updates the display of all containers up to and including the container at the specified index.
+		 * For example, if you have a chain of 20 containers and specify an index of 10, 
+		 * <code>updateToController()</code> ensures that the first through the tenth (indexes 0-9) 
+		 * containers are composed and displayed. Composition stops at that point. If <code>controllerIndex</code> 
+		 * is -1 (or not specified), then all containers are updated.</p>
+		 *
+		 * <p>This method updates all the text lines and the display list immediately and synchronously.</p>
+		 * 
+		 * <p>If the contents of any container is changed, the method returns <code>true</code>.</p>
+		 * 
+		 * @param index index of the last container to update (by default updates all containers)
+		 * @return <code>true</code>, if anything changed.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 * @flexjsignorecoercion org.apache.flex.textLayout.elements.ITableCellElement
+	 	 *
+		 */
+		 
+		public function updateToController(index:int = 2147483647):Boolean
+		{
+			//CONFIG::debug { assert(!_composing,"updateToController: compose in process"); }
+			if (_composing)
+				return false;
+			
+			var cellHeight:Number = 0;
+			if(textFlow.nestedInTable())
+			{
+				var controller:IContainerController = getControllerAt(0);
+				if (controller)
+					cellHeight = controller.container.height;
+
+			}
+			//note that this will always update the display AND update the
+			//selection.  So, even if nothing has changed that would cause
+			//a recompose, the selection would still be redrawn.
+			var sm:ISelectionManager = textFlow.interactionManager;
+			if (sm)
+				sm.flushPendingOperations();
+			CONFIG::debug { assert(!_composing, "Didn't expect to be composing here"); }
+			internalCompose(-1, index);	
+			var shapesDamaged:Boolean = areShapesDamaged();
+			if (shapesDamaged)
+				updateCompositionShapes();
+
+			// recompose the containing table if the cell height changed.
+			// This should be ok because updateAllControllers() should be ignored if the parent textFlow is in middle of a compose.
+			if(cellHeight && controller.container.height != cellHeight)
+			{
+				var table:ITableElement = (textFlow.parentElement as ITableCellElement).table;
+				table.modelChanged(ModelChange.ELEMENT_MODIFIED, table, 0, table.textLength);
+				table.getTextFlow().flowComposer.updateAllControllers();
+				if(sm && sm.focused)
+					controller.setFocus();
+			}
+
+			if (sm)
+				sm.refreshSelection();
+			return shapesDamaged;
+		}
+		
+		/** 
+		 * Sets the focus to the container that contains the location specified by the <code>absolutePosition</code>
+		 * parameter. 
+		 *
+		 * <p>The StandardFlowComposer calls the <code>setFocus()</code> method of the ContainerController object
+		 * containing the specified text flow position.</p>
+		 * 
+		 * @param absolutePosition Specifies the position in the text flow of the container to receive focus.
+		 * @param leanLeft If true and the position is before the first character in a container, sets focus to the end of
+		 *  the previous container.
+		 * 
+		 * @see flash.display.Stage#focus
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		public function setFocus(absolutePosition:int,leanLeft:Boolean=false):void
+		{
+			var idx:int = findControllerIndexAtPosition(absolutePosition,leanLeft);
+			if (idx == -1)
+				idx = this.numControllers-1;
+			if (idx != -1)
+				_controllerList[idx].setFocus();
+		}
+		
+		/**
+		 * Called by the TextFlow when the interaction manager changes. 
+		 * 
+		 * <p>This function is called automatically. Your code does not typically need to call this
+		 * method. Classes that extend StandardFlowComposer can override this method to update
+		 * event listeners and other properties that depend on the interaction manager.</p>
+		 * 
+		 * @param newInteractionManager The new ISelectionManager instance.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public	function interactionManagerChanged(newInteractionManager:ISelectionManager):void
+		{
+			for each (var controller:IContainerController in _controllerList)
+				controller.interactionManagerChanged(newInteractionManager);
+		}
+
+		
+		private function updateCompositionShapes():void
+		{
+			for each (var controller:IContainerController in _controllerList)
+				controller.updateCompositionShapes(); 
+		}
+		
+		//--------------------------------------------------------------------------
+		//
+		//  Composition
+		//
+		//--------------------------------------------------------------------------
+		
+		/** @private Override required because we may be damaged if the last container has scrolling */
+		public override function isPotentiallyDamaged(absolutePosition:int):Boolean
+		{
+			// Returns true if any text from _damageAbsoluteStart through absolutePosition needs to be recomposed
+			if (!super.isPotentiallyDamaged(absolutePosition))
+			{	
+				if (absolutePosition == _textFlow.textLength)
+				{
+					var container:IContainerController = getControllerAt(numControllers-1);
+					if (container && (container.verticalScrollPolicy != ScrollPolicy.OFF || container.horizontalScrollPolicy != ScrollPolicy.OFF))
+						return true;
+				}
+				return false;
+			}
+				
+			return true;
+		}
+
+		/** Returns true if composition is necessary, false otherwise */
+		protected function preCompose():Boolean
+		{
+			CONFIG::debug { checkFirstDamaged(); }
+			rootElement.preCompose();
+			
+			// No content, nothing to compose - TextFlow isn't loaded  or connected
+			CONFIG::debug { assert(rootElement.textLength != 0,"bad TextFlow after normalize"); }
+			
+			// brand new content
+			if (numLines == 0)
+				initializeLines();
+				
+			return isDamaged(rootElement.getAbsoluteStart() + rootElement.textLength);
+		}
+		
+		/** @private */
+		public function getComposeState():IComposer
+		{ return ComposeUtils.getComposeState(); }
+		
+		/** @private */
+		public function releaseComposeState(state:IComposer):void
+		{ ComposeUtils.releaseComposeState(state); }
+		
+		/** @private Return the first damaged controller */
+		public function callTheComposer(composeToPosition:int, controllerEndIndex:int):IContainerController
+		{
+			
+			if (_damageAbsoluteStart == rootElement.getAbsoluteStart()+rootElement.textLength)
+				return getControllerAt(numControllers-1);
+				
+			var state:IComposer = getComposeState();
+			
+			var lastComposedPosition:int = state.composeTextFlow(textFlow, composeToPosition, controllerEndIndex);
+			if (_damageAbsoluteStart < lastComposedPosition)
+				_damageAbsoluteStart = lastComposedPosition;
+			CONFIG::debug { checkFirstDamaged(); }
+			
+			// make sure there is an empty TextFlowLine covering any trailing content
+			finalizeLinesAfterCompose();
+			var startController:IContainerController = state.startController;
+			
+			releaseComposeState(state);
+			
+			if (textFlow.hasEventListener(CompositionCompleteEvent.COMPOSITION_COMPLETE))
+				textFlow.dispatchEvent(new CompositionCompleteEvent(CompositionCompleteEvent.COMPOSITION_COMPLETE,false,false,textFlow, 0,lastComposedPosition));
+
+			CONFIG::debug { textFlow.debugCheckTextFlow(); }
+			return startController;
+		}
+		
+		private var lastBPDirectionScrollPosition:Number = Number.NEGATIVE_INFINITY;
+		
+		static private function getBPDirectionScrollPosition(bp:String,cont:IContainerController):Number
+		{
+			return bp == BlockProgression.TB ? cont.verticalScrollPosition : cont.horizontalScrollPosition;
+		}
+		
+		/** Bottleneck function for all types of compose. Does the work of compose, no matter how it is called. @private 
+		 * @return first controller with changed shapes
+		 */
+		private function internalCompose(composeToPosition:int = -1, composeToControllerIndex:int = -1):IContainerController
+		{
+			var bp:String;
+
+				// Flush pending events (e.g. insert events)
+			var sm:ISelectionManager = textFlow.interactionManager;
+			if (sm)
+				sm.flushPendingOperations();
+			
+			CONFIG::debug { assert(_composing == false,"internalCompose: Recursive call"); }
+				
+			_composing = true;
+
+			var startController:IContainerController;
+			try
+			{	
+				if (preCompose())
+				{
+					if (textFlow && numControllers != 0)
+					{
+						// This code should really be in preCompose, but we cannot add new parameters to it without breaking the API.
+						var damageLimit:int = _textFlow.textLength;		// If we aren't composed up to this point, we'll have to force composition
+						// If the container index is above the range, set it to the last container
+						composeToControllerIndex = Math.min(composeToControllerIndex,numControllers-1);
+						if (composeToPosition != -1 || composeToControllerIndex != -1)
+						{
+							if (composeToControllerIndex < 0)
+							{
+								if (composeToPosition >= 0)
+									damageLimit = composeToPosition;
+							}
+							else 
+							{
+								// We're composing the container, make sure the entire container is composed
+								var controller:IContainerController = getControllerAt(composeToControllerIndex);
+								if (controller.textLength != 0)
+									damageLimit = controller.absoluteStart+controller.textLength;
+	
+								// If we're composing the last container, and its scrollable, only require valid composition to the end of the scrolled position
+								if (composeToControllerIndex == numControllers - 1)
+								{
+									bp = rootElement.computedFormat.blockProgression;
+	
+										// skip it if damageAbsoluteStart is past the end of the controller.  are there risks here? AND scrollpositions haven't changed since last composeToControllerIndex
+									var lastVisibleLine:ITextFlowLine = controller.getLastVisibleLine();
+									if (lastVisibleLine && getBPDirectionScrollPosition(bp,controller) == this.lastBPDirectionScrollPosition)
+										damageLimit = lastVisibleLine.absoluteStart+lastVisibleLine.textLength;
+								}
+	
+							}
+						}
+						
+						lastBPDirectionScrollPosition = Number.NEGATIVE_INFINITY;
+				
+						if (_damageAbsoluteStart < damageLimit)
+						{
+							startController = callTheComposer(composeToPosition, composeToControllerIndex);
+							if (startController)
+							{
+								var idx:int = this.getControllerIndex(startController);
+								while (idx < numControllers)
+									getControllerAt(idx++).shapesInvalid = true;
+							}
+						}
+					}
+				}
+			}
+			catch (e:Error)
+			{
+				_composing = false;
+				throw(e);
+			}
+			_composing = false;
+			
+			if (controller && composeToControllerIndex == numControllers - 1)
+			{
+				lastBPDirectionScrollPosition = getBPDirectionScrollPosition(bp,controller);
+			}
+			
+			return startController;
+		}
+		
+		
+		/** @private */
+		public function areShapesDamaged():Boolean
+		{
+			var cont:IContainerController;	// scratch
+			// TODO: a flag on this?
+			for each (cont in _controllerList)
+			{
+				if (cont.shapesInvalid)
+					return true;
+			}
+			return false;
+		}
+		
+		/** 
+		 * Calculates how many lines are necessary to display the content in the root element of the flow and the positions of these 
+		 * lines in the flow's display containers.
+		 * 
+		 * <p>The <code>compose()</code> method only composes content if it has changed since the last composition operation. 
+		 * Results are saved so that subsequent
+		 * calls to <code>compose()</code> or <code>updateAllControllers()</code> do not perform an additional recomposition
+		 * if the flow content has not changed.</p>
+		 * 
+		 * <p>If the contents of any container have changed, the method returns <code>true</code>.</p>
+		 * 
+		 * @return true if anything changed.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 *
+	 	 * @see #updateAllControllers()
+	 	 * @see #updateToController()
+		 */
+		public function compose():Boolean
+		{
+			//CONFIG::debug { assert(!_composing,"compose: compose in process"); }
+			return _composing ? false : internalCompose() != null;
+		}
+		
+		/** @copy IFlowComposer#composeToPosition()
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+		 */
+		public function composeToPosition(absolutePosition:int = 2147483647):Boolean
+		{
+			//CONFIG::debug { assert(!_composing,"composeToPosition: compose in process"); }
+			return _composing ? false : internalCompose(absolutePosition, -1) != null;
+		}
+		
+		/** @copy IFlowComposer#composeToController()
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+		 */
+		public function composeToController(index:int = 2147483647):Boolean
+		{
+			//CONFIG::debug { assert(!_composing,"composeToController: compose in process"); }
+			return _composing ? false : internalCompose(-1, index) != null;
+		}
+		
+		/** @private */
+		override public function createBackgroundManager():IBackgroundManager
+		{ return new BackgroundManager(); }
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/TCMFactoryComposer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/TCMFactoryComposer.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/TCMFactoryComposer.as
new file mode 100644
index 0000000..2271a6a
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/TCMFactoryComposer.as
@@ -0,0 +1,47 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.compose
+{
+	import org.apache.flex.textLayout.compose.utils.FactoryHelper;
+	import org.apache.flex.textLayout.container.IContainerController;
+	import org.apache.flex.textLayout.container.TextContainerManager;
+	import org.apache.flex.textLayout.factory.TextLineFactoryBase;
+
+	public class TCMFactoryComposer extends FactoryComposer
+	{
+		public var _tcm:TextContainerManager;
+
+		public function TCMFactoryComposer(tcm:TextContainerManager)
+		{
+			_tcm = tcm;
+		}
+
+		public override function callTheComposer(absoluteEndPosition:int, controllerEndIndex:int):IContainerController
+		{
+			// always do a full compose
+			clearCompositionResults();
+
+			var state:ISimpleCompose = FactoryHelper.staticComposer;
+			state.resetLineHandler = _tcm.resetLine;
+			state.composeTextFlow(textFlow, -1, -1);
+			state.releaseAnyReferences();
+			return getControllerAt(0);
+		}
+	}
+}
\ No newline at end of file


[19/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/FlowGroupElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/FlowGroupElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/FlowGroupElement.as
new file mode 100644
index 0000000..671876a
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/FlowGroupElement.as
@@ -0,0 +1,1111 @@
+// //////////////////////////////////////////////////////////////////////////////
+//
+// 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
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// //////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	import org.apache.flex.text.engine.ContentElement;
+	import org.apache.flex.text.engine.GroupElement;
+	import org.apache.flex.textLayout.compose.FlowDamageType;
+	import org.apache.flex.textLayout.container.IContainerController;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.events.ModelChange;
+	import org.apache.flex.textLayout.formats.FormatValue;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+
+	[DefaultProperty("mxmlChildren")]
+	/** 
+	 * The FlowGroupElement class is the base class for FlowElement objects that can have an array of children. These classes include
+	 * TextFlow, ParagraphElement, DivElement, and LinkElement.
+	 *
+	 * <p>You cannot create a FlowGroupElement object directly. Invoking <code>new FlowGroupElement()</code> throws an error 
+	 * exception.</p>
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 *
+	 * @see DivElement
+	 * @see LinkElement
+	 * @see ParagraphElement
+	 * @see TextFlow
+	 */
+	public class FlowGroupElement extends FlowElement implements IFlowGroupElement
+	{
+		/** children of the FlowGroupElement.  They must all be FlowElements. Depending on _numChildren either store a single child in _singleChild or multiple children in the array. */
+		private var _childArray:Array;
+		private var _singleChild:IFlowElement;
+		private var _numChildren:int;
+
+		/** Base class - invoking <code>new FlowGroupElement()</code> throws an error exception.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function FlowGroupElement()
+		{
+			_numChildren = 0;
+		}
+
+		override public function get className():String
+		{
+			return "FlowGroupElement";
+		}
+
+		/**
+		 *  @private 
+		 *  @flexjsignorecoercion org.apache.flex.textLayout.elements.IFlowGroupElement
+		 */
+		public override function deepCopy(startPos:int = 0, endPos:int = -1):IFlowElement
+		{
+			if (endPos == -1)
+				endPos = textLength;
+
+			var retFlow:IFlowGroupElement = shallowCopy(startPos, endPos) as IFlowGroupElement;
+			var newFlowElement:IFlowElement;
+			for (var idx:int = 0; idx < _numChildren; idx++)
+			{
+				var child:IFlowElement = getChildAt(idx);
+				if (((startPos - child.parentRelativeStart) < child.textLength) && ((endPos - child.parentRelativeStart) > 0))
+				{
+					// child is in Selected area
+					newFlowElement = child.deepCopy(startPos - child.parentRelativeStart, endPos - child.parentRelativeStart);
+					retFlow.replaceChildren(retFlow.numChildren, retFlow.numChildren, newFlowElement);
+					if (retFlow.numChildren > 1)
+					{
+						var possiblyEmptyFlowElement:IFlowElement = retFlow.getChildAt(retFlow.numChildren - 2);
+						if (possiblyEmptyFlowElement.textLength == 0)
+						{
+							retFlow.replaceChildren(retFlow.numChildren - 2, retFlow.numChildren - 1);
+						}
+					}
+				}
+			}
+			return retFlow;
+		}
+
+		/* @private */
+		public override function getText(relativeStart:int = 0, relativeEnd:int = -1, paragraphSeparator:String = "\n"):String
+		{
+			var text:String = super.getText();
+			return FlowGroupHelper.getText(this, text, relativeStart, relativeEnd, paragraphSeparator);
+		}
+
+		// ****************************************
+		// Begin TextLayoutFormat Related code
+		// ****************************************
+		/** @private */
+		public override function formatChanged(notifyModelChanged:Boolean = true):void
+		{
+			super.formatChanged(notifyModelChanged);
+			for (var idx:int = 0; idx < _numChildren; idx++)
+			{
+				var child:IFlowElement = getChildAt(idx);
+				child.formatChanged(false);
+			}
+		}
+
+		/** This gets called when an element has changed its style selection related attributes. This may happen because an
+		 * ancestor element changed it attributes.
+		 * @private 
+		 */
+		public override function styleSelectorChanged():void
+		{
+			super.styleSelectorChanged();
+			formatChanged(false);
+		}
+
+
+		// ****************************************
+		// End TLFFormat Related code
+		// ****************************************
+		// ****************************************
+		// Begin import helper code
+		// ****************************************
+		[RichTextContent]
+		/** 
+		 * Appends an array of children to this object. Uses the <code>replaceChildren()</code> method to append each 
+		 * element in the array. Intended for use during an mxml compiled import.
+		 * 
+		 * @throws TypeError if array element is not a FlowElement or String
+		 * @param array - array of children to attach.  Each element of the array must be a FlowElement object or a String.
+		 * @see FlowGroupElement#replaceChildren()
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public function get mxmlChildren():Array
+		{
+			return _numChildren == 0 ? null : (_numChildren == 1 ? [this._singleChild] : _childArray.slice() );
+		}
+
+		public function set mxmlChildren(array:Array):void
+		{
+			FlowGroupHelper.setMxmlChildren(this, array);
+		}
+
+		// ****************************************
+		// End import helper code
+		// ****************************************
+		// ****************************************
+		// Begin tree navigation code
+		// ****************************************
+		/** 
+		 * Returns the number of FlowElement children that this FlowGroupElement object has.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get numChildren():int
+		{
+			return _numChildren;
+		}
+
+		/** 
+		 * Searches in children for the specified FlowElement object and returns its index position.
+		 *
+		 * @param child	The FlowElement object item to locate among the children.
+		 * @return The index position of the specified chilc.  If <code>child</code> is not found, returns -1.
+		 *  
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function getChildIndex(child:IFlowElement):int
+		{
+			var hi:int = _numChildren - 1;
+			// one hole here - if child is null and this has no children then we'll return 0
+			if (hi <= 0)
+				return _singleChild == child ? 0 : -1;
+
+			var lo:int = 0;
+			while (lo <= hi)
+			{
+				var mid:int = (lo + hi) / 2;
+				var p:IFlowElement = _childArray[mid];
+				if (p.parentRelativeStart == child.parentRelativeStart)
+				{
+					// during intermediate caluclations there are zero length elements lurking about
+					if (p == child)
+					{
+						CONFIG::debug
+						{
+							assert(_childArray.indexOf(child) == mid, "Bad getChildIndex"); }
+						return mid;
+					}
+					var testmid:int;
+					if (p.textLength == 0)
+					{
+						// look forward for a match
+						for (testmid = mid; testmid < _numChildren; testmid++)
+						{
+							p = _childArray[testmid];
+							if (p == child)
+							{
+								CONFIG::debug
+								{
+									assert(_childArray.indexOf(child) == testmid, "Bad getChildIndex"); }
+								return testmid;
+							}
+							if (p.textLength != 0)
+								break;
+						}
+					}
+
+					// look backwards
+					while (mid > 0)
+					{
+						mid--;
+						p = _childArray[mid];
+						if (p == child)
+						{
+							CONFIG::debug
+							{
+								assert(_childArray.indexOf(child) == mid, "Bad getChildIndex"); }
+							return mid;
+						}
+						if (p.textLength != 0)
+							break;
+					}
+					CONFIG::debug
+					{
+						assert(_childArray.indexOf(child) == -1, "Bad getChildIndex"); }
+					return -1;
+				}
+				if (p.parentRelativeStart < child.parentRelativeStart)
+					lo = mid + 1;
+				else
+					hi = mid - 1;
+			}
+			CONFIG::debug
+			{
+				assert(_childArray.indexOf(child) == -1, "Bad getChildIndex"); }
+			return -1;
+		}
+
+		/** 
+		 * Returns the FlowElement child at the specified index.
+		 * 
+		 * @param index the position at which to find the FlowElement object.
+		 *
+		 * @return  the child FlowElement object at the specified position.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function getChildAt(index:int):IFlowElement
+		{
+			if (_numChildren > 1)
+				return _childArray[index];
+			return index == 0 ? _singleChild : null;
+		}
+
+		/** @private */
+		public function getNextLeafHelper(limitElement:IFlowGroupElement, child:IFlowElement):IFlowLeafElement
+		{
+			var idx:int = getChildIndex(child);
+			if (idx == -1)
+				return null;	// bug?
+
+			if (idx == _numChildren - 1)
+			{
+				if (limitElement == this || !parent)
+					return null;
+
+				return parent.getNextLeafHelper(limitElement, this);
+			}
+
+			var childFlowElement:IFlowElement = getChildAt(idx + 1);
+			return (childFlowElement is IFlowLeafElement) ? IFlowLeafElement(childFlowElement) : FlowGroupElement(childFlowElement).getFirstLeaf();
+		}
+
+		/** @private */
+		public function getPreviousLeafHelper(limitElement:IFlowGroupElement, child:IFlowElement):IFlowLeafElement
+		{
+			var idx:int = getChildIndex(child);
+			if (idx == -1)
+				return null;	// bug?
+
+			if (idx == 0)
+			{
+				if (limitElement == this || !parent)
+					return null;
+
+				return parent.getPreviousLeafHelper(limitElement, this);
+			}
+
+			var childFlowElement:IFlowElement = getChildAt(idx - 1);
+			return (childFlowElement is IFlowLeafElement) ? IFlowLeafElement(childFlowElement) : FlowGroupElement(childFlowElement).getLastLeaf();
+		}
+
+		/**
+		 * Given a relative text position, find the leaf element that contains the position. 
+		 *
+		 * <p>Looks down the flow element hierarchy to find the IFlowLeafElement that 
+		 * contains the specified position. The specified position 
+		 * is relative to this FlowElement object.</p>
+		 *
+		 * @param relativePosition	relative text index to look up.
+		 * @return	the leaf element containing the relative position.
+		 *
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function findLeaf(relativePosition:int):IFlowLeafElement
+		{
+			var found:IFlowLeafElement = null;
+			var childIdx:int = findChildIndexAtPosition(relativePosition);
+			if (childIdx != -1)
+			{
+				// childIdx is index of the first child containing pos. Many of its following siblings
+				// may also contain pos if their respective previous siblings are zero-length.
+				// Check them all until a leaf containing pos is found.
+				do
+				{
+					var child:IFlowElement = this.getChildAt(childIdx++);
+					if (!child)
+						break;
+
+					var childRelativePos:int = relativePosition - child.parentRelativeStart;
+					if (child is FlowGroupElement)
+						found = IFlowGroupElement(child).findLeaf(childRelativePos);
+					else
+					{
+						// if its not a FlowGroupElement than it must be a FlowLeafElement
+						CONFIG::debug
+						{
+							assert(child is IFlowLeafElement, "Invalid child in FlowGroupElement.findLeaf"); }
+						if (childRelativePos >= 0 && childRelativePos < child.textLength || (child.textLength == 0 && _numChildren == 1))
+							found = IFlowLeafElement(child);
+					}
+				} while (!found && !child.textLength);
+			}
+			return found;
+		}
+
+		/**
+		 * Given a relative text position, find the index of the first child FlowElement that contains the relative position. 
+		 * More than one child can contain relative position because of zero length FlowElements.
+		 *  
+		 * <p>Examine the children to find the FlowElement that contains the relative position. The supplied relative position 
+		 * is relative to this FlowElement.</p>
+		 *
+		 * @param relativePosition 	the position relative to this element
+		 * @return 	index of first child element containing <code>relativePosition</code>
+		 *
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function findChildIndexAtPosition(relativePosition:int):int
+		{
+			var lo:int = 0;
+			var hi:int = _numChildren - 1;
+			while (lo <= hi)
+			{
+				var mid:int = (lo + hi) / 2;
+				var child:IFlowElement = getChildAt(mid);
+				if (child.parentRelativeStart <= relativePosition)
+				{
+					// always return the first zero length element in the list
+					if (child.parentRelativeStart == relativePosition)
+					{
+						while (mid != 0)
+						{
+							child = getChildAt(mid - 1);
+							if (child.textLength != 0)
+								break;
+							mid--;
+						}
+						return mid;
+					}
+					if (child.parentRelativeStart + child.textLength > relativePosition)
+						return mid;
+					lo = mid + 1;
+				}
+				else
+					hi = mid - 1;
+			}
+			return -1;
+		}
+
+		/**
+		 * Returns the first FlowLeafElement descendant of this group.
+		 *
+		 * @return the first FlowLeafElement object.
+		 *
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function getFirstLeaf():IFlowLeafElement
+		{
+			if (_numChildren > 1)
+			{
+				for (var idx:int = 0; idx < _numChildren; idx++)
+				{
+					var child:IFlowElement = _childArray[idx];
+					var leaf:IFlowLeafElement = (child is FlowGroupElement) ? FlowGroupElement(child).getFirstLeaf() : IFlowLeafElement(child);
+					if (leaf)
+						return leaf;
+				}
+				return null;
+			}
+			return _numChildren == 0 ? null : ((_singleChild is FlowGroupElement) ? FlowGroupElement(_singleChild).getFirstLeaf() : IFlowLeafElement(_singleChild));
+		}
+
+		/**
+		 * Returns the last FlowLeafElement descendent of this group.
+		 *
+		 * @return the last FlowLeafElement object.
+		 *
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function getLastLeaf():IFlowLeafElement
+		{
+			if (_numChildren > 1)
+			{
+				for (var idx:int = _numChildren; idx != 0; idx--)
+				{
+					var child:IFlowElement = _childArray[idx - 1];
+					var leaf:IFlowLeafElement = (child is FlowGroupElement) ? FlowGroupElement(child).getLastLeaf() : IFlowLeafElement(child) ;
+					if (leaf)
+						return leaf;
+				}
+				return null;
+			}
+			return _numChildren == 0 ? null : ((_singleChild is FlowGroupElement) ? FlowGroupElement(_singleChild).getLastLeaf() : IFlowLeafElement(_singleChild));
+		}
+
+		/** @private */
+		public override function getCharAtPosition(relativePosition:int):String
+		{
+			var leaf:IFlowLeafElement = findLeaf(relativePosition);
+			return leaf ? leaf.getCharAtPosition(relativePosition - leaf.getElementRelativeStart(this)) : "";
+		}
+
+		/** @private apply func to all elements until func says stop */
+		public override function applyFunctionToElements(func:Function):Boolean
+		{
+			if (func(this))
+				return true;
+			for (var idx:int = 0; idx < _numChildren; idx++)
+			{
+				if (getChildAt(idx).applyFunctionToElements(func))
+					return true;
+			}
+			return false;
+		}
+
+		// ****************************************
+		// End tree navigation code
+		// ****************************************
+		// ****************************************
+		// Begin tree modification support code
+		// ****************************************
+		/** @private */
+		public function removeBlockElement(child:IFlowElement, block:ContentElement):void
+		{
+			// when Image's are moved into ParagraphElement's this assertion should always fire
+			CONFIG::debug
+			{
+				assert(child is InlineGraphicElement, "invalid call to removeBlockElement"); }
+		}
+
+		/** @private */
+		public function insertBlockElement(child:IFlowElement, block:ContentElement):void
+		{
+			// when Image's are moved into ParagraphElement's this assertion should always fire
+			CONFIG::debug
+			{
+				assert(child is InlineGraphicElement, "invalid call to insertBlockElement"); }
+		}
+
+		/** @private 
+		 * True if there is a corresponding FTE data structure currently instantiated.
+		 */
+		public function hasBlockElement():Boolean
+		{
+			CONFIG::debug
+			{
+				assert(false, "invalid call to hasBlockElement"); }
+			return false;
+		}
+
+		/** @private */
+		public function createContentAsGroup(pos:int = 0):GroupElement
+		{
+			CONFIG::debug
+			{
+				assert(false, "invalid call to createContentAsGroup"); }
+			return null;
+		}
+
+		/** @private This is only called from SpanElement.splitAtPosition */
+		public function addChildAfterInternal(child:IFlowElement, newChild:IFlowElement):void
+		{
+			// this function was kept for efficiency purposes. It is used by splitForChange
+			// which in turn is used by applyCharacterFormat, when changing the
+			// attributes applied to characters.  In the end, the length of the document
+			// will be the same. So, without this fnction, we would be creating a new
+			// span, updating the lengths, and then removing a part of the span and updating
+			// the lengths again (getting the same exact lengths we had before). This can be
+			// inefficient. So, this function does everything addChildAfter does, without
+			// updating the lengths. This is an internal function since the user really has
+			// to know what they're doing and will not be exposed as a public API
+			CONFIG::debug
+			{
+				assert(_numChildren != 0, "addChildAfter must have children"); }
+			CONFIG::debug
+			{
+				assert(getChildIndex(child) != -1, "addChildAfter: before child must be in array"); }
+			if (_numChildren > 1)
+			{
+				// TODO: binary search for indexOf child
+				CONFIG::debug
+				{
+					assert(_childArray.indexOf(child) != -1, "Bad call to addChildAfterInternal"); }
+				_childArray.splice(_childArray.indexOf(child) + 1, 0, newChild);
+			}
+			else
+			{
+				// not found returns above returns -1 so behave the same
+				CONFIG::debug
+				{
+					assert(_singleChild == child, "Bad call to addChildAfterInternal"); }
+				_childArray = [_singleChild, newChild];
+				_singleChild = null;
+			}
+			_numChildren++;
+			newChild.setParentAndRelativeStartOnly(this, child.parentRelativeEnd);
+		}
+
+		/**
+		 * Helper for replaceChildren.  Determines if elem can legally be a child of this.
+		 * @return true --> ok, false--> not a legal child
+		 * @private 
+		 */
+		public function canOwnFlowElement(elem:IFlowElement):Boolean
+		{
+			return !(elem is ITextFlow) && !(elem is IFlowLeafElement) && !(elem is ISubParagraphGroupElementBase) && !(elem is IListItemElement) && !(elem is ITableElement);
+		}
+
+		/** @private */
+		private static function getNestedArgCount(obj:Object):uint
+		{
+			return (obj is Array) ? obj.length : 1;
+		}
+
+		/** @private */
+		private static function getNestedArg(obj:Object, index:uint):FlowElement
+		{
+			CONFIG::debug
+			{
+				assert(index < getNestedArgCount(obj), "bad index to getNestedArg"); }
+			return ((obj is Array) ? obj[index] : obj) as FlowElement;
+		}
+
+		/**
+		 * Replaces child elements in the group with the specified new elements. Use the <code>beginChildIndex</code> and
+		 * <code>endChildIndex</code> parameters to govern the operation as follows:
+		 * <p><ul>
+		 * <li>To delete elements, do not pass any replacement elements.</li>
+		 * <li>To insert elements, pass the same value for <code>beginChildIndex</code> and <code>endChildIndex</code>.  
+		 * The new elements is inserted before the specified index.</li>
+		 * <li>To append elements, pass <code>numChildren</code> for <code>beginChildIndex</code> and <code>endChildIndex</code>.</li>
+		 * </ul></p>
+		 * <p>Otherwise, this method replaces the specified elements, starting with the element at <code>beginChildIndex</code> 
+		 * and up to but not including <code>endChildIndex</code>.</p>
+		 * 
+		 * @param beginChildIndex The index value for the start position of the replacement range in the children array.
+		 * @param endChildIndex The index value following the end position of the replacement range in the children array.
+		 * @param rest The elements to replace the specified range of elements. Can be a sequence containing flow elements or
+		 * arrays or vectors thereof.
+		 *	 
+		 * @throws RangeError The <code>beginChildIndex</code> or <code>endChildIndex</code> specified is out of range.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function replaceChildren(beginChildIndex:int, endChildIndex:int, ...rest):void
+		{
+			if (beginChildIndex > _numChildren || endChildIndex > _numChildren)
+				throw RangeError(GlobalSettings.resourceStringFunction("badReplaceChildrenIndex"));
+
+			var thisAbsStart:int = getAbsoluteStart();
+			var absStartIdx:int = thisAbsStart + (beginChildIndex == _numChildren ? textLength : getChildAt(beginChildIndex).parentRelativeStart);
+			var relStartIdx:int = beginChildIndex == _numChildren ? textLength : getChildAt(beginChildIndex).parentRelativeStart;
+
+			// deletion phase
+			if (beginChildIndex < endChildIndex)
+			{
+				var child:IFlowElement;	// scratch variable
+				var len:int = 0;
+
+				while (beginChildIndex < endChildIndex)
+				{
+					child = this.getChildAt(beginChildIndex);
+					this.modelChanged(ModelChange.ELEMENT_REMOVAL, child, child.parentRelativeStart, child.textLength);
+					child.removed();
+					len += child.textLength;
+
+					child.setParentAndRelativeStart(null, 0);
+					if (_numChildren == 1)
+					{
+						_singleChild = null;
+						_numChildren = 0;
+					}
+					else
+					{
+						_childArray.splice(beginChildIndex, 1);
+						_numChildren--;
+						if (_numChildren == 1)
+						{
+							_singleChild = _childArray[0];
+							_childArray = null;
+						}
+					}
+					endChildIndex--;
+				}
+				if (len)
+				{
+					// TODO: this code should move into updateLengths.  updateLengths needs a rewrite
+					// as it assumes that any element that is removed has its length set to zero and updateLengths
+					// is called on that element first.  replaceChildren doesn't do that - it just removes the element
+
+					// until rewrite reuse endChildIndex and update start of all following elements
+					while (endChildIndex < _numChildren)
+					{
+						child = getChildAt(endChildIndex);
+						child.setParentRelativeStart(child.parentRelativeStart - len);
+						endChildIndex++;
+					}
+
+					// update lengths
+					updateLengths(absStartIdx, -len, true);
+
+					deleteContainerText(relStartIdx + len, len);
+				}
+			}
+			CONFIG::debug
+			{
+				assert(thisAbsStart == getAbsoluteStart(), "replaceChildren: Bad thisAbsStart"); }
+			var childrenToAdd:int = 0;		// number of children to add
+			var flatNewChildList:Array;		// stores number of children when > 1
+			var newChildToAdd:IFlowElement;	// stores a single child to add - avoids creating an Array for the 99% case
+
+			var newChild:IFlowElement; 		// scratch
+			var idx:int;					// scratch
+
+			for each (var obj:Object in rest)
+			{
+				if (!obj)
+					continue;
+
+				var numNestedArgs:int = getNestedArgCount(obj);
+				for (idx = 0; idx < numNestedArgs; idx++)
+				{
+					newChild = getNestedArg(obj, idx);
+					if (newChild)
+					{
+						var newChildParent:IFlowGroupElement = newChild.parent;
+						if (newChildParent)
+						{
+							if (newChildParent == this)
+							{
+								// special handling in this case
+								var childIndex:int = getChildIndex(newChild);
+								newChildParent.removeChild(newChild);
+								thisAbsStart = getAbsoluteStart();	// is it in the same flow?
+								if (childIndex <= beginChildIndex)
+								{
+									beginChildIndex--;
+									absStartIdx = thisAbsStart + (beginChildIndex == _numChildren ? textLength : getChildAt(beginChildIndex).parentRelativeStart);
+									relStartIdx = beginChildIndex == _numChildren ? textLength : getChildAt(beginChildIndex).parentRelativeStart;
+								}
+							}
+							else
+							{
+								newChildParent.removeChild(newChild);
+								thisAbsStart = getAbsoluteStart();	// is it in the same flow?
+								absStartIdx = thisAbsStart + (beginChildIndex == _numChildren ? textLength : getChildAt(beginChildIndex).parentRelativeStart);
+								relStartIdx = beginChildIndex == _numChildren ? textLength : getChildAt(beginChildIndex).parentRelativeStart;
+							}
+						}
+
+						if (!canOwnFlowElement(newChild))
+						{
+							throw ArgumentError(GlobalSettings.resourceStringFunction("invalidChildType") + ". " + defaultTypeName + " cannot own " + newChild.defaultTypeName);
+						}
+
+						// manage as an array or a single child
+						if (childrenToAdd == 0)
+							newChildToAdd = newChild;
+						else if (childrenToAdd == 1)
+							flatNewChildList = [newChildToAdd, newChild];
+						else
+							flatNewChildList.push(newChild);
+						childrenToAdd++;
+					}
+				}
+			}
+
+			if (childrenToAdd)
+			{
+				// TODO-9/18/2008-ideally, do the following in one shot, but insertBlockElement
+				// called from setParentAndRelativeStart in the loop below has different behavior
+				// based on the size of _children (zero vs. non-zero)
+				// _children.splice(beginChildIndex,0,flatNewChildList);
+				var addedTextLength:uint = 0;
+				for (idx = 0; idx < childrenToAdd; idx++)
+				{
+					newChild = childrenToAdd == 1 ? newChildToAdd : flatNewChildList[idx];
+
+					if (_numChildren == 0)
+						_singleChild = newChild;
+					else if (_numChildren > 1)
+						_childArray.splice(beginChildIndex, 0, newChild);
+					else
+					{
+						_childArray = beginChildIndex == 0 ? [newChild, _singleChild] : [_singleChild, newChild];
+						_singleChild = null;
+					}
+					_numChildren++;
+					newChild.setParentAndRelativeStart(this, relStartIdx + addedTextLength);
+					addedTextLength += newChild.textLength;
+					beginChildIndex++;	// points to the next slot
+				}
+				CONFIG::debug
+				{
+					assert(thisAbsStart == getAbsoluteStart(), "replaceChildren: Bad thisAbsStart"); }
+				if (addedTextLength)
+				{
+					// update following elements - see comment above.
+					// it would be best if this loop only ran once
+					while (beginChildIndex < _numChildren)
+					{
+						child = getChildAt(beginChildIndex++);
+						child.setParentRelativeStart(child.parentRelativeStart + addedTextLength);
+					}
+					updateLengths(absStartIdx, addedTextLength, true);
+					var enclosingContainer:IContainerController = getEnclosingController(relStartIdx);
+					if (enclosingContainer)
+						enclosingContainer.setTextLength(enclosingContainer.textLength + addedTextLength);
+				}
+				for (idx = 0; idx < childrenToAdd; idx++)
+				{
+					newChild = childrenToAdd == 1 ? newChildToAdd : flatNewChildList[idx];
+					this.modelChanged(ModelChange.ELEMENT_ADDED, newChild, newChild.parentRelativeStart, newChild.textLength);
+				}
+			}
+			else
+			{
+				var tFlow:ITextFlow = getTextFlow();
+				if (tFlow != null)
+				{
+					// beginChildIndex points to the next element
+					// use scratch idx as "damageStart"
+					if (beginChildIndex < _numChildren)
+					{
+						// first, look for the next element and damage the beginning.
+						idx = thisAbsStart + getChildAt(beginChildIndex).parentRelativeStart;
+					}
+					else if (beginChildIndex > 1)
+					{
+						// damage the end of the previous element
+						newChild = getChildAt(beginChildIndex - 1);
+						idx = thisAbsStart + newChild.parentRelativeStart + newChild.textLength - 1;
+					}
+					else
+					{
+						// damage the very end of the textFlow
+						idx = thisAbsStart;
+						if (idx >= tFlow.textLength)
+							idx--;
+					}
+					tFlow.damage(idx, 1, FlowDamageType.INVALID, false);
+				}
+			}
+		}
+
+		/** 
+		 * Appends a child FlowElement object. The new child is added to the end of the children list.
+		 * 
+		 * @param child The child element to append.
+		 *
+		 * @return  the added child FlowElement 
+		 * 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function addChild(child:IFlowElement):IFlowElement
+		{
+			replaceChildren(_numChildren, _numChildren, child);
+			return child;
+		}
+
+		/** 
+		 * Adds a child FlowElement object at the specified index position.
+		 *
+		 * @param The index of the position at which to add the child element, with the first position being 0.
+		 * @param child The child element to add.
+		 * @throws RangeError The <code>index</code> is out of range.
+		 *
+		 * @return  the added child FlowElement 
+		 *
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 */
+		public function addChildAt(index:uint, child:IFlowElement):IFlowElement
+		{
+			replaceChildren(index, index, child);
+			return child;
+		}
+
+		/** 
+		 * Removes the specified child FlowElement object from the group.
+		 *
+		 * @param child The child element to remove.
+		 * @throws ArgumentError The <code>child</code> is not found.
+		 *
+		 * @return  the removed child FlowElement object 
+		 *
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 */
+		public function removeChild(child:IFlowElement):IFlowElement
+		{
+			var index:int = getChildIndex(child);
+			if (index == -1)
+				throw ArgumentError(GlobalSettings.resourceStringFunction("badRemoveChild"));
+
+			removeChildAt(index);
+			return child;
+		}
+
+		/** 
+		 * Removes the child FlowElement object at the specified index position.
+		 *
+		 * @param index position at which to remove the child element.
+		 * @throws RangeError The <code>index</code> is out of range.
+		 *
+		 * @return  the child FlowElement object removed from the specified position.
+		 *
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function removeChildAt(index:uint):IFlowElement
+		{
+			var childToReplace:IFlowElement = getChildAt(index);
+			replaceChildren(index, index + 1);
+			return childToReplace;
+		}
+
+		/** 
+		 * Splits this object at the position specified by the <code>childIndex</code> parameter. If this group element has 
+		 * a parent, creates a shallow copy of this object and replaces its children with the elements up to the index. Moves 
+		 * elements following <code>childIndex</code> into the copy.
+		 * 
+		 * @return the new FlowGroupElement object.
+		 * @throws RangeError if <code>childIndex</code> is greater than the length of the children.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function splitAtIndex(childIndex:int):IFlowGroupElement
+		{
+			if (childIndex > _numChildren)
+				throw RangeError(GlobalSettings.resourceStringFunction("invalidSplitAtIndex"));
+
+			var newSibling:FlowGroupElement = shallowCopy() as FlowGroupElement;
+
+			var numChildrenToMove:int = _numChildren - childIndex;
+			if (numChildrenToMove == 1)
+				newSibling.addChild(removeChildAt(childIndex));
+			else if (numChildrenToMove != 0)
+			{
+				var childArray:Array = _childArray.slice(childIndex);
+				this.replaceChildren(childIndex, _numChildren - 1);
+				newSibling.replaceChildren(0, 0, childArray);
+			}
+
+			if (parent)
+			{
+				var myidx:int = parent.getChildIndex(this);
+				parent.replaceChildren(myidx + 1, myidx + 1, newSibling);
+			}
+
+			// This causes errors in operations that assume zero children. Normalizing makes this assumption not valid.
+			// newSibling.normalizeRange(0,newSibling.textLength);
+			return newSibling;
+		}
+
+		/** 
+		 * Splits this object at the position specified by the <code>relativePosition</code> parameter, where 
+		 * the relative position is a relative text position in this element.
+		 * 
+		 * @throws RangeError if relativePosition is greater than textLength, or less than 0.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 * @private
+		 */
+		public override function splitAtPosition(relativePosition:int):IFlowElement
+		{
+			// Creates a shallowCopy of this and adds it to parent after this.
+			// Moves elements from characterIndex forward into the copy
+			// returns the new shallowCopy
+			if ((relativePosition < 0) || (relativePosition > textLength))
+				throw RangeError(GlobalSettings.resourceStringFunction("invalidSplitAtPosition"));
+
+			var curElementIdx:int;
+
+			if (relativePosition == textLength)
+				curElementIdx = _numChildren;
+			else
+			{
+				curElementIdx = findChildIndexAtPosition(relativePosition);
+				var curFlowElement:IFlowElement = getChildAt(curElementIdx);
+
+				if (curFlowElement.parentRelativeStart != relativePosition)
+				{
+					if (curFlowElement.className == "FlowGroupElement")
+					{
+						FlowGroupElement(curFlowElement).splitAtPosition(relativePosition - curFlowElement.parentRelativeStart);
+					}
+					else
+					{
+						// I would imagine that it has to be a span.  That's the only non-FlowGroupElement
+						// type that can take up more than a textLength of 1.
+						CONFIG::debug
+						{
+							assert(curFlowElement.className == "SpanElement", "SpanElements are the only leaf elements that can currently have > 1 textLength");	}
+						ISpanElement(curFlowElement).splitAtPosition(relativePosition - curFlowElement.parentRelativeStart);
+					}
+					// increase by one. It's the new element that we want to move over.
+					curElementIdx++;
+				}
+			}
+
+			// increase by one. It's the new element that we want to move over.
+			return splitAtIndex(curElementIdx);
+		}
+
+		/** @private */
+		public override function normalizeRange(normalizeStart:uint, normalizeEnd:uint):void
+		{
+			var idx:int = findChildIndexAtPosition(normalizeStart);
+			if (idx != -1 && idx < _numChildren)
+			{
+				// backup over zero length children
+				var child:IFlowElement = getChildAt(idx);
+				normalizeStart = normalizeStart - child.parentRelativeStart;
+
+				CONFIG::debug
+				{
+					assert(normalizeStart >= 0, "bad normalizeStart in normalizeRange"); }
+				for (;;)
+				{
+					// watch out for changes in the length of the child
+					var origChildEnd:int = child.parentRelativeStart + child.textLength;
+					child.normalizeRange(normalizeStart, normalizeEnd - child.parentRelativeStart);
+					var newChildEnd:int = child.parentRelativeStart + child.textLength;
+					normalizeEnd += newChildEnd - origChildEnd;	// adjust
+
+					// no zero length children
+					if (child.textLength == 0 && !child.bindableElement)
+						replaceChildren(idx, idx + 1);
+					else
+						idx++;
+
+					if (idx == _numChildren)
+						break;
+
+					// next child
+					child = getChildAt(idx);
+
+					if (child.parentRelativeStart > normalizeEnd)
+						break;
+
+					normalizeStart = 0;		// for the next child
+				}
+			}
+		}
+
+		/** @private */
+		public override function applyWhiteSpaceCollapse(collapse:String):void
+		{
+			if (collapse == null)
+				collapse = this.computedFormat.whiteSpaceCollapse;	// top of the cascade?
+			else
+			{
+				var ffc:ITextLayoutFormat = this.formatForCascade;
+				var wsc:* = ffc ? ffc.whiteSpaceCollapse : undefined;
+				if (wsc !== undefined && wsc != FormatValue.INHERIT)
+					collapse = wsc;
+			}
+			for (var idx:int = 0; idx < _numChildren;)
+			{
+				var child:IFlowElement = getChildAt(idx);
+				child.applyWhiteSpaceCollapse(collapse);
+				if (child.parent == this)	// check to see if child was removed (could have been
+					++idx;
+			}
+
+			// If the element was added automatically, it may now have no content and needs to be removed
+			// This can happen with whitespace between paragraphs that is added by set mxmlChildren
+			if (textLength == 0 && impliedElement && parent != null)
+				parent.removeChild(this);
+
+			super.applyWhiteSpaceCollapse(collapse);
+		}
+
+		/** @private */
+		public override function appendElementsForDelayedUpdate(tf:ITextFlow, changeType:String):void
+		{
+			for (var idx:int = 0; idx < _numChildren; idx++)
+			{
+				var child:IFlowElement = getChildAt(idx);
+				child.appendElementsForDelayedUpdate(tf, changeType);
+			}
+		}
+		// ****************************************
+		// End tree modification support code
+		// ****************************************
+		// ****************************************
+		// Begin debug support code
+		// ****************************************
+		/** @private */
+		CONFIG::debug
+		public override function debugCheckFlowElement(depth:int = 0, extraData:String = ""):int
+		{
+			var rslt:int = super.debugCheckFlowElement(depth, extraData);
+
+			// debugging function that asserts if the flow element is in an invalid state
+			var totalChildLength:int = 0;
+			if (_numChildren)
+			{
+				for (var childIndex:int = 0; childIndex < _numChildren; ++childIndex)
+				{
+					var child:IFlowElement = getChildAt(childIndex);
+					rslt += assert(child.parent == this, "child doesn't point to parent");
+
+					// totalChildLength is relative offset to child
+					rslt += assert(child.parentRelativeStart == totalChildLength, "child start offset wrong");
+					rslt += child.debugCheckFlowElement(depth + 1);
+					totalChildLength += child.textLength;
+				}
+			}
+			else
+			{
+				// only spans may own text
+				rslt += assert(this is ISpanElement || textLength == 0, "only spans may have text");
+				totalChildLength = textLength;
+			}
+			assert(totalChildLength == textLength, "child total textLength wrong");
+			return rslt;
+		}
+		// **************************************** 
+		// End debug support code
+		// ****************************************
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/FlowGroupHelper.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/FlowGroupHelper.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/FlowGroupHelper.as
new file mode 100644
index 0000000..195458f
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/FlowGroupHelper.as
@@ -0,0 +1,103 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	import org.apache.flex.reflection.getQualifiedClassName;
+	
+	public class FlowGroupHelper
+	{
+		public static function setMxmlChildren(group:IFlowGroupElement,array:Array):void
+		{
+						/* NOTE: all FlowElement implementers and overrides of mxmlChildren must specify [RichTextContent] metadata */
+
+			// remove all existing children
+			group.replaceChildren(0,group.numChildren);
+			
+			// In the text model, non-ParagraphFormattedElements (i.e. spans, images, links, TCY) cannot be children of a ContainerFormattedElement (TextFlow, IDivElement etc.)
+			// They can only be children of paragraphs or subparagraph blocks. 
+			// In XML, however, <p> elements can be implied (for example, a <span> may appear as a direct child of <flow>).  
+			// So, while parsing the XML, if we enounter a non-ParagraphFormattedElement child of a ContainerFormattedElement 
+			// 1. an explicitly created paragraph is used as the parent instead
+			// 2. such explicitly created paragraphs are shared by adjacent flow elements provided there isn't an intervening ParagraphFormattedElement
+			var effectiveParent:IFlowGroupElement = group; 
+			
+			// append them on the end		
+			for each (var child:Object in array)
+			{
+				if (child is IFlowElement)
+				{
+					if (child is IParagraphFormattedElement)
+					{
+						// Reset due to possibly intervening FlowParagrpahElement; See note 2. above
+						effectiveParent = group; 
+					}
+					else if (effectiveParent is IContainerFormattedElement)
+					{
+						// See note 1. above
+						effectiveParent = ElementHelper.getParagraph();	// NO PMD
+						effectiveParent.impliedElement = true;
+						group.replaceChildren(group.numChildren, group.numChildren, effectiveParent);
+					}
+					if ( (child is ISpanElement) || (child is ISubParagraphGroupElementBase))
+						child.bindableElement = true;
+					effectiveParent.replaceChildren(effectiveParent.numChildren, effectiveParent.numChildren, IFlowElement(child) );
+				}
+				else if (child is String)
+				{
+					var s:ISpanElement = ElementHelper.getSpan();	// NO PMD
+					s.text = String(child);
+					s.bindableElement = true;
+					s.impliedElement = true;
+					
+					if (effectiveParent is IContainerFormattedElement)
+					{
+						// See note 1. above
+	 					effectiveParent = ElementHelper.getParagraph();	// No PMD
+						group.replaceChildren(group.numChildren, group.numChildren, effectiveParent);
+						effectiveParent.impliedElement = true;
+					}
+					effectiveParent.replaceChildren(effectiveParent.numChildren, effectiveParent.numChildren, s);
+				}
+				else if (child != null)
+					throw new TypeError(GlobalSettings.resourceStringFunction("badMXMLChildrenArgument",[ getQualifiedClassName(child) ]));	// NO PMD
+			}
+		}
+		public static function getText(group:IFlowGroupElement,text:String,relativeStart:int=0, relativeEnd:int=-1, paragraphSeparator:String="\n"):String{
+			if (relativeEnd == -1 || relativeEnd >group. textLength)
+				relativeEnd = group.textLength;
+			
+			if (relativeStart < 0)
+				relativeStart = 0;
+				
+			var pos:int = relativeStart;
+			for (var idx:int = group.findChildIndexAtPosition(relativeStart); idx >= 0 && idx < group.numChildren && pos < relativeEnd; idx++)
+			{
+				var child:IFlowElement = group.getChildAt(idx);
+				var copyStart:int = pos - child.parentRelativeStart;
+				var copyEnd:int = Math.min(relativeEnd - child.parentRelativeStart, child.textLength);
+				text += child.getText(copyStart, copyEnd, paragraphSeparator);
+				pos += copyEnd - copyStart;
+				if (paragraphSeparator && child is IParagraphFormattedElement && pos < relativeEnd)
+					text += paragraphSeparator;
+			}
+			return text;
+			
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/FlowLeafElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/FlowLeafElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/FlowLeafElement.as
new file mode 100644
index 0000000..891ee35
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/FlowLeafElement.as
@@ -0,0 +1,441 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements {
+	import org.apache.flex.textLayout.elements.utils.GeometricElementUtils;
+	import org.apache.flex.graphics.PathBuilder;
+	import org.apache.flex.graphics.SolidColorStroke;
+	import org.apache.flex.graphics.SolidColor;
+	import org.apache.flex.graphics.ICompoundGraphic;
+	import org.apache.flex.events.IEventDispatcher;
+	import org.apache.flex.geom.Rectangle;
+	import org.apache.flex.text.engine.ContentElement;
+	import org.apache.flex.text.engine.ElementFormat;
+	import org.apache.flex.text.engine.FontDescription;
+	import org.apache.flex.text.engine.FontMetrics;
+	import org.apache.flex.text.engine.ITextLine;
+	import org.apache.flex.text.engine.TextBaseline;
+	import org.apache.flex.text.engine.TextElement;
+	import org.apache.flex.text.engine.TextRotation;
+	import org.apache.flex.text.engine.TypographicCase;
+	import org.apache.flex.textLayout.compose.ISWFContext;
+	import org.apache.flex.textLayout.debug.Debugging;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.events.FlowElementEventDispatcher;
+	import org.apache.flex.textLayout.events.ModelChange;
+	import org.apache.flex.textLayout.formats.BackgroundColor;
+	import org.apache.flex.textLayout.formats.BaselineShift;
+	import org.apache.flex.textLayout.formats.BlockProgression;
+	import org.apache.flex.textLayout.formats.ColorName;
+	import org.apache.flex.textLayout.formats.FormatValue;
+	import org.apache.flex.textLayout.formats.IMEStatus;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.formats.TLFTypographicCase;
+	import org.apache.flex.textLayout.formats.TextDecoration;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+
+	import org.apache.flex.textLayout.utils.CharacterUtil;
+	import org.apache.flex.textLayout.utils.LocaleUtil;
+
+
+		
+	
+	/** Base class for FlowElements that appear at the lowest level of the flow hierarchy. FlowLeafElement objects have
+	* no children and include InlineGraphicElement objects and SpanElement objects.
+	*
+	* @playerversion Flash 10
+	* @playerversion AIR 1.5
+	* @langversion 3.0
+	*
+	* @see InlineGraphicElement
+	* @see SpanElement
+	*/
+	public class FlowLeafElement extends FlowElement implements IFlowLeafElement	{				
+		/** Holds the content of the leaf @private */
+		protected var _blockElement:ContentElement;
+		
+		/** @private
+		 * Holds the text for the leaf element - unless there's a valid blockElement, 
+		 * in which case the text is in the rawText field of the blockElement.
+		 */
+		protected var _text:String;	// holds the text property if the blockElement is null
+		private var _hasAttachedListeners:Boolean;	// true if FTE eventMirror may be in use
+		
+		/** @private The event dispatcher that acts as an event mirror */
+		public var _eventMirror:FlowElementEventDispatcher = null;
+		
+		/** 
+		 * Base class - invoking new FlowLeafElement() throws an error exception. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 */
+		public function FlowLeafElement()
+		{
+			_hasAttachedListeners = false;
+			super();
+		}
+		override public function get className():String
+		{
+			return "FlowLeafElement";
+		}
+
+		//TODO this should not be here!
+		public function set text(value:String):void{
+			// do nothing        
+		}
+		
+		/** @private */
+		override public function createContentElement():void
+		{
+			CONFIG::debug { assert(_blockElement != null, "_blockElement not allocated in derived class"); }
+			if (_computedFormat)
+			{
+				_blockElement.elementFormat = computeElementFormat();
+				CONFIG::debug { Debugging.traceFTEAssign(_blockElement,"elementFormat",_blockElement.elementFormat); }
+			}
+			if (parent)
+				parent.insertBlockElement(this,_blockElement);
+		}
+		/** @private */
+		override public function releaseContentElement():void
+		{
+			_blockElement = null;
+			_computedFormat = null;
+		}
+		
+//		private function blockElementExists():Boolean
+//		{
+//			return _blockElement != null;
+//		}
+
+		/** @private */
+		public function getBlockElement():ContentElement
+		{ 
+			if (!_blockElement)
+				createContentElement();
+			return _blockElement; 
+		}
+		
+		/** @private
+		 * Gets the EventDispatcher associated with this FlowElement.  Use the functions
+		 * of EventDispatcher such as <code>setEventHandler()</code> and <code>removeEventHandler()</code> 
+		 * to capture events that happen over this FlowLeafElement object.  The
+		 * event handler that you specify will be called after this FlowElement object does
+		 * the processing it needs to do.
+		 * 
+		 * Note that the event dispatcher will only dispatch FlowElementMouseEvent events.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * @see org.apache.flex.events.EventDispatcher
+		 * @see org.apache.flex.textLayout.events.FlowElementMouseEvent
+		 */
+		public override function getEventMirror():IEventDispatcher
+		{
+			if (!_eventMirror)
+				_eventMirror = new FlowElementEventDispatcher(this);
+			return _eventMirror;
+		}
+		
+		/** @private
+		 * Checks whether an event dispatcher is attached, and if so, if the event dispatcher
+		 * has any active listeners.
+		 */
+		public override function hasActiveEventMirror():Boolean
+		{
+			return _eventMirror && (_eventMirror._listenerCount != 0);
+		}
+		
+		/** @private This is done so that the TextContainerManager can discover EventMirrors in a TextFlow. */
+		public override function appendElementsForDelayedUpdate(tf:ITextFlow,changeType:String):void
+		{ 
+			if (changeType == ModelChange.ELEMENT_ADDED)
+			{
+				if (this.hasActiveEventMirror())
+				{
+					tf.incInteractiveObjectCount();
+					getParagraph().incInteractiveChildrenCount() ;
+				}
+			}
+			else if (changeType == ModelChange.ELEMENT_REMOVAL)
+			{
+				if (this.hasActiveEventMirror())
+				{
+					tf.decInteractiveObjectCount();
+					getParagraph().decInteractiveChildrenCount() ;
+				}
+			}
+			super.appendElementsForDelayedUpdate(tf,changeType);
+		}
+		
+		/**
+		 * The text associated with the FlowLeafElement:
+		 * <p><ul>
+		 * <li>The value for SpanElement subclass will be one character less than <code>textLength</code> if this is the last span in a ParagraphELement.</li>
+		 * <li>The value for BreakElement subclass is a U+2028</li>
+		 * <li>The value for TabElement subclass is a tab</li>
+		 * <li>The value for InlineGraphicElement subclass is U+FDEF</li>
+		 * </ul></p>
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 *
+	 	 * @see org.apache.flex.textLayout.elements.SpanElement#replaceText()
+		 */
+		public function get text():String
+		{
+			return _text;
+		}
+		
+		/** @private */
+		public function getElementFormat():ElementFormat
+		{ 			
+			if (!_blockElement)
+				createContentElement();
+			return _blockElement.elementFormat; 
+ 		}
+		
+		/** @private */
+		public override function setParentAndRelativeStart(newParent:IFlowGroupElement,newStart:int):void
+		{
+			if (newParent == parent)
+				return;
+		
+			var hasBlock:Boolean = _blockElement != null;
+			
+			if (_blockElement && parent && parent.hasBlockElement())	// remove textElement from the parent content
+				parent.removeBlockElement(this,_blockElement);
+			if (newParent && !newParent.hasBlockElement() && _blockElement)
+				newParent.createContentElement();
+					
+			super.setParentAndRelativeStart(newParent,newStart);
+			
+			// Update the FTE ContentElement structure. If the parent has FTE elements, then create FTE elements for the leaf node 
+			// if it doesn't already have them, and add them in. If the parent does not have FTE elements, release the leaf's FTE
+			// elements also so they match.
+			if (parent)
+			{
+				if (parent.hasBlockElement())
+				{
+					if (!_blockElement)
+						createContentElement();
+					else if (hasBlock)	// don't do this if the _blockElement was constructed as side-effect of setParentAndRelativeStart; in that case, it's already attached
+						parent.insertBlockElement(this,_blockElement);
+				}
+				else if (_blockElement)
+					releaseContentElement();
+			}
+		}
+	
+		/** @private Only used by SpanElement.splitAtPosition */
+		public function quickInitializeForSplit(sibling:FlowLeafElement,newSpanLength:int,newSpanTextElement:TextElement):void
+		{
+			setTextLength(newSpanLength);
+			_blockElement = newSpanTextElement;
+			if (_blockElement)
+				_text = _blockElement.text;
+			quickCloneTextLayoutFormat(sibling);
+			var tf:ITextFlow = sibling.getTextFlow();
+			if (tf == null || tf.formatResolver == null)
+			{
+				_computedFormat = sibling._computedFormat;
+				if (_blockElement)
+					_blockElement.elementFormat = sibling.getElementFormat();
+			}
+		}
+		
+		/**
+		 * Returns the next FlowLeafElement object.  
+		 * 
+		 * @param limitElement	Specifies FlowGroupElement on whose last leaf to stop looking. A value of null (default) 
+		 * 	means search till no more elements.
+		 * @return 	next FlowLeafElement or null if at the end
+		 *
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 *
+		 */
+		 
+		 public function getNextLeaf(limitElement:IFlowGroupElement=null):IFlowLeafElement
+		{
+			if (!parent)
+				return null;
+			return parent.getNextLeafHelper(limitElement,this);
+		}
+		
+		/**
+		 * Returns the previous FlowLeafElement object.  
+		 * 
+		 * @param limitElement	Specifies the FlowGroupElement on whose first leaf to stop looking.   null (default) means search till no more elements.
+		 * @return 	previous leafElement or null if at the end
+		 *
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 *
+		 */
+		 
+		public function getPreviousLeaf(limitElement:IFlowGroupElement=null):IFlowLeafElement
+		{
+			if (!parent)
+				return null;
+			return parent.getPreviousLeafHelper(limitElement,this);
+		}
+		
+		/** @private */
+		public override function getCharAtPosition(relativePosition:int):String
+		{
+			return _text ?  _text.charAt(relativePosition) : "";
+		} 
+		
+		/** @private */
+		public override function normalizeRange(normalizeStart:uint,normalizeEnd:uint):void
+		{
+			// this does the cascade - potential optimization to skip it if the _blockElement isn't attached
+			if (_blockElement)
+				calculateComputedFormat();
+		}
+		
+		/** Returns the FontMetrics object for the span. The properties of the FontMetrics object describe the 
+		 * emBox, strikethrough position, strikethrough thickness, underline position, 
+		 * and underline thickness for the specified font. 
+		 *
+ 		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 *
+		 * @see org.apache.flex.text.engine.FontMetrics
+		 * @see org.apache.flex.text.engine.ElementFormat#getFontMetrics()
+		 *
+		 * @return font metrics associated with the span
+		 */
+		public function getComputedFontMetrics():FontMetrics
+		{
+			if (!_blockElement)
+				createContentElement();
+			if(!_blockElement)
+				return null;
+			var ef:ElementFormat = _blockElement.elementFormat;
+			if (!ef)
+				return null;
+				
+			var tf:ITextFlow = getTextFlow();
+			if (tf && tf.flowComposer && tf.flowComposer.swfContext)
+				return tf.flowComposer.swfContext.callInContext(ef.getFontMetrics,ef,null,true);
+			return ef.getFontMetrics();
+		}
+		
+
+		/** @private */
+		public function computeElementFormat():ElementFormat
+		{
+			CONFIG::debug { assert(_computedFormat != null,"bad call to computeElementFormat"); }
+
+			var tf:ITextFlow = getTextFlow();
+			return GeometricElementUtils.computeElementFormatHelper (_computedFormat, getParagraph(), tf && tf.flowComposer ? tf.flowComposer.swfContext : null);
+		}
+		
+		
+		/** 
+		 * The computed text format attributes that are in effect for this element.
+		 * Takes into account the inheritance of attributes.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 *
+		 * @see org.apache.flex.textLayout.formats.ITextLayoutFormat
+		 */
+		public override function get computedFormat():ITextLayoutFormat
+		{		
+			if (!_computedFormat)
+			{
+				_computedFormat = doComputeTextLayoutFormat();
+
+				if (_blockElement)
+				{
+					_blockElement.elementFormat = computeElementFormat();
+					CONFIG::debug { Debugging.traceFTEAssign(_blockElement,"elementFormat",_blockElement.elementFormat); }
+				}
+
+			}
+			return _computedFormat;
+		}
+		
+		/** Returns the calculated lineHeight from this element's properties.  @private */
+		public function getEffectiveLineHeight(blockProgression:String):Number
+		{
+			//ignore the leading on a TCY Block. If the element is in a TCYBlock, it has no leading
+			if (blockProgression == BlockProgression.RL && (parent.className == "TCYElement"))
+				return 0;
+			CONFIG::debug { assert(_computedFormat != null,"Missing _computedFormat in FlowLeafElement.getEffectiveLineHeight"); }
+			return TextLayoutFormat.lineHeightProperty.computeActualPropertyValue(computedFormat.lineHeight, getEffectiveFontSize());
+		}
+		
+		/** @private 
+		 * Get the "inline box" for the element as defined by the CSS visual formatting model (http://www.w3.org/TR/CSS2/visuren.html)
+		 * @param	blockProgression	Block progression
+		 * @param	textLine			The containing text line
+		 * @param	para				The containing para. Only used for resolving AUTO dominantBaseline value. 
+		 * 								May be null, in which case the AUTO dominantBaseline value is resolved based on other attributes (such as the element's computed locale). 	
+		 * @param	swfContext			The SWF context in which certain method calls (such as the one used to get font metrics) are made
+		 * 								May be null in which case the current SWF context is used.
+		 * @return 						Null if the element is not "inline"
+		 * 								Otherwise, a rectangle representing the inline box. Top and Bottom are relative to the line's Roman baseline. Left and Right are ignored.
+		 */
+		public function getCSSInlineBox(blockProgression:String, textLine:ITextLine, para:IParagraphElement=null, swfContext:ISWFContext=null):Rectangle
+		{
+			// TODO-9/27/10: TCYs typically don't affect leading, but this may not be appropriate for LeadingModel.BOX 
+			if (blockProgression == BlockProgression.RL && (parent.className == "TCYElement"))
+				return null;
+			
+			return GeometricElementUtils.getCSSInlineBoxHelper (computedFormat, getComputedFontMetrics(), textLine, para);
+		}
+		
+		/** Returns the fontSize from this element's properties.  @private */
+		public function getEffectiveFontSize():Number
+		{
+			return Number(computedFormat.fontSize);
+		}
+
+		/** @private */
+		CONFIG::debug public override function debugCheckFlowElement(depth:int = 0, extraData:String = ""):int
+		{
+			// debugging function that asserts if the flow element tree is in an invalid state
+			
+			var rslt:int = super.debugCheckFlowElement(depth," fte:"+getDebugIdentity(_blockElement)+" "+extraData);
+			
+			// TODO: eventually these tests will be valid for InlineGraphicElement elements as well
+			if (!(IFlowLeafElement is InlineGraphicElement))
+			{
+				rslt += assert(textLength != 0 || bindableElement || (parent is ISubParagraphGroupElementBase && parent.numChildren == 1), "FlowLeafElement with zero textLength must be deleted"); 
+				rslt += assert(parent is IParagraphElement || parent is ISubParagraphGroupElementBase, "FlowLeafElement must have a ParagraphElement or SubParagraphGroupElementBase parent");
+			}
+			return rslt;
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/FlowValueHolder.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/FlowValueHolder.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/FlowValueHolder.as
new file mode 100644
index 0000000..8e73d6f
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/FlowValueHolder.as
@@ -0,0 +1,71 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements {
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+
+	
+
+
+	// [ExcludeClass]
+	/** This class extends TextLayoutFormat and add capabilities to hold privateData and userStyles.  @private */
+	public class FlowValueHolder extends TextLayoutFormat
+	{
+		private var _privateData:Object;
+		
+		public function FlowValueHolder(initialValues:FlowValueHolder = null)
+		{
+			super(initialValues);
+			initialize(initialValues);
+		}
+		
+		private function initialize(initialValues:FlowValueHolder):void
+		{
+			if (initialValues)
+			{
+				var s:String;
+				for (s in initialValues.privateData)
+					setPrivateData(s, initialValues.privateData[s]);
+			}
+		}
+
+
+		public function get privateData():Object
+		{ return _privateData; }
+		public function set privateData(val:Object):void
+		{ _privateData = val; }
+
+		public function getPrivateData(styleProp:String):*
+		{ return _privateData ? _privateData[styleProp] : undefined; }
+
+		public function setPrivateData(styleProp:String,newValue:*):void
+		{
+			if (newValue === undefined)
+			{
+				if (_privateData)
+					delete _privateData[styleProp];
+			}
+			else
+			{
+				if (_privateData == null)
+					_privateData = {};
+				_privateData[styleProp] = newValue;
+			}
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/GlobalSettings.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/GlobalSettings.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/GlobalSettings.as
new file mode 100644
index 0000000..87f21dc
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/GlobalSettings.as
@@ -0,0 +1,245 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+
+
+    
+    /** Configuration that applies to all TextFlow objects.
+     * @playerversion Flash 10
+     * @playerversion AIR 1.5
+     */
+    public class GlobalSettings 
+    {
+        /** 
+        * Specifies the callback used for font mapping.
+        * The callback takes a <code>org.apache.flex.text.engine.FontDescription</code> object and updates it as needed.
+        * 
+        * After setting a new font mapping callback, or changing the behavior of the exisiting font mapping callback, 
+        * the client must explicitly call <code>org.apache.flex.textLayout.elements.TextFlow.invalidateAllFormats</code> for each impacted text flow.
+        * This ensures that whenever a leaf element in the text flow is next recomposed, the FontDescription applied to it is recalculated, and the the callback is invoked. 
+        * 
+        * @see org.apache.flex.text.engine.FontDescription FontDescription
+        * @see TextFlow.invalidateAllFormats invalidateAllFormats
+        * 
+        * @playerversion Flash 10
+        * @playerversion AIR 1.5
+        * @langversion 3.0
+        */
+        public static function get fontMapperFunction():Function
+        { 
+            return _fontMapperFunction; 
+        }
+        public static function set fontMapperFunction(val:Function):void
+        {
+            _fontMapperFunction = val;
+        }
+        
+        private static var _fontMapperFunction:Function;
+        
+        /** Controls whether the text will be visible to a search engine indexer. Defaults to <code>true</code>.
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */
+        public static function get enableSearch():Boolean
+        {
+            return _enableSearch;
+        }
+        public static function set enableSearch(value:Boolean):void
+        {
+            _enableSearch = value;
+        }
+        
+        private static var _enableSearch:Boolean = true;
+    
+        /** 
+         * Specifies the callback used for changing the FontLookup based on swfcontext.  The function will be called each time an ElementFormat is computed.
+         * It gives the client the opportunity to modify the FontLookup setting.  The function is called with two parameters an ISWFContext and an ITextLayoutFormat.
+         * It must return a valid FontLookup.
+         * 
+         * @see org.apache.flex.textLayout.compose.ISWFContext
+         * @see org.apache.flex.textLayout.formats.ITextLayoutFormat
+         * @see org.apache.flex.text.engine.ElementFormat
+         * @see org.apache.flex.text.engine.FontLookup
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */
+        public static function get resolveFontLookupFunction():Function
+        { 
+            return _resolveFontLookupFunction; 
+        }
+        public static function set resolveFontLookupFunction(val:Function):void
+        {
+            _resolveFontLookupFunction = val;
+        }
+        private static var _resolveFontLookupFunction:Function;
+        
+        /** Function that takes two parameters, a resource id and an optional array of parameters to substitute into the string.
+         * The string is of form "Content {0} more content {1}".  The parameters are read from the optional array and substituted for the bracketed substrings.
+         * TLF provides a default implementation with
+         * default strings.  Clients may replace this function with their own implementation for localization.
+         * 
+         * @playerversion Flash 10
+         * @playerversion AIR 1.5
+         * @langversion 3.0
+         */
+        public static function get resourceStringFunction():Function
+        { 
+            return _resourceStringFunction; 
+        }
+        public static function set resourceStringFunction(val:Function):void
+        {
+            _resourceStringFunction = val;
+        }
+        
+        private static var _resourceStringFunction:Function = defaultResourceStringFunction;
+        
+        /** @private */
+        
+        private static const resourceDict:Object = 
+        {
+            missingStringResource:          "No string for resource {0}",
+            // core errors
+            invalidFlowElementConstruct:    "Attempted construct of invalid FlowElement subclass",
+            invalidSplitAtPosition:         "Invalid parameter to splitAtPosition",
+            badMXMLChildrenArgument:        "Bad element of type {0} passed to mxmlChildren",
+            badReplaceChildrenIndex:        "Out of range index to FlowGroupElement.replaceChildren",
+            invalidChildType:               "NewElement not of a type that this can be parent of",
+            badRemoveChild:                 "Child to remove not found",
+            invalidSplitAtIndex:            "Invalid parameter to splitAtIndex",
+            badShallowCopyRange:            "Bad range in shallowCopy",
+            badSurrogatePairCopy:           "Copying only half of a surrogate pair in SpanElement.shallowCopy",
+            invalidReplaceTextPositions:    "Invalid positions passed to SpanElement.replaceText",
+            invalidSurrogatePairSplit:      "Invalid splitting of a surrogate pair",
+            badPropertyValue:               "Property {0} value {1} is out of range",
+            // selection/editing
+            illegalOperation:               "Illegal attempt to execute {0} operation",
+            // shared import errors
+            unexpectedXMLElementInSpan:     "Unexpected element {0} within a span",
+            unexpectedNamespace:            "Unexpected namespace {0}",
+            unknownElement:                 "Unknown element {0}",
+            unknownAttribute:               "Attribute {0} not permitted in element {1}",
+            // html format import errors
+            malformedTag:                   "Malformed tag {0}",
+            malformedMarkup:                "Malformed markup {0}",
+            // textlayoutformat import errors
+            missingTextFlow:                "No TextFlow to parse",
+            expectedExactlyOneTextLayoutFormat: "Expected one and only one TextLayoutFormat in {0}",    
+            expectedExactlyOneListMarkerFormat: "Expected one and only one ListMarkerFormat in {0}",
+            unsupportedVersion:         "Version {0} is unsupported",
+            // shared import/export errors
+            unsupportedProperty:            "Property {0} is unsupported"
+        };
+        
+        /** @private */
+        public static function defaultResourceStringFunction(resourceName:String, parameters:Array = null):String
+        {
+            var value:String = String(resourceDict[resourceName]);
+            
+            if (value == null)
+            {
+                value = String(resourceDict["missingStringResource"]);
+                parameters = [ resourceName ];
+            }
+            
+            if (parameters)
+                value = substitute(value, parameters);
+            
+            return value;
+        }
+        
+        /** @private */
+        public static function substitute(str:String, ... rest):String
+        {
+            if (str == null) 
+                return '';
+            
+            // Replace all of the parameters in the msg string.
+            var len:uint = rest.length;
+            var args:Array;
+            if (len == 1 && rest[0] is Array)
+            {
+                args = rest[0] as Array;
+                len = args.length;
+            }
+            else
+            {
+                args = rest;
+            }
+            
+            for (var i:int = 0; i < len; i++)
+            {
+                str = str.replace(new RegExp("\\{"+i+"\\}", "g"), args[i]);
+            }
+            
+            return str;
+        }
+        
+
+        private static var _enableDefaultTabStops:Boolean = false;
+        /** 
+         * @private Player versions prior to 10.1 do not set up any default tabStops. As a workaround, if enableDefaultTabs
+         * is true, TLF will set up default tabStops in the case where there are no tabs defined.
+         * 
+         */     
+        public static function get enableDefaultTabStops():Boolean
+        {
+            return _enableDefaultTabStops;
+        }
+        /** 
+         * @private 
+         */         
+        public static function set enableDefaultTabStops(val:Boolean):void
+        {
+            _enableDefaultTabStops = val;
+        }
+		
+		private static var _alwaysCalculateWhitespaceBounds:Boolean = false;
+		/** 
+		 * @private If this is true, we will always calculate whitespace width in line bounds.
+		 * if this is false, we will see if lineBreak="explicit" or when the logical width is NaN, 
+		 * the content bounds includes the spaces at the end of the line. With lineBreak="toFit" 
+		 * the spaces are not included. 
+		 * 
+		 */     
+		public static function get alwaysCalculateWhitespaceBounds():Boolean
+		{
+			return _alwaysCalculateWhitespaceBounds;
+		}
+		/** 
+		 * @private 
+		 */         
+		public static function set alwaysCalculateWhitespaceBounds(val:Boolean):void
+		{
+			_alwaysCalculateWhitespaceBounds = val;
+		}
+		
+		//		static public const playerEnablesSpicyFeatures:Boolean = versionIsAtLeast(10,2) && (new Sprite).hasOwnProperty("needsSoftKeyboard"); 
+//		static public const hasTouchScreen:Boolean = playerEnablesArgoFeatures && Capabilities["touchScreenType"] != "none";
+
+//TODO make these meaningful. How???
+		static public const playerEnablesSpicyFeatures:Boolean = false; 
+		static public const hasTouchScreen:Boolean = false;
+		
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IBackgroundManager.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IBackgroundManager.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IBackgroundManager.as
new file mode 100644
index 0000000..eab6d06
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IBackgroundManager.as
@@ -0,0 +1,54 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	import org.apache.flex.geom.Rectangle;
+	import org.apache.flex.textLayout.container.IContainerController;
+	import org.apache.flex.text.engine.ITextLine;
+	import org.apache.flex.textLayout.elements.IFlowLeafElement;
+	import org.apache.flex.textLayout.compose.ITextFlowLine;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.graphics.IGraphicShape;
+
+	public interface IBackgroundManager
+	{
+		function clearBlockRecord():void;
+
+		function addBlockRect(elem:IFlowElement, r:Rectangle, cc:IContainerController = null, style:String = null):void;
+
+		function addBlockElement(elem:IFlowElement):void;
+
+		function addRect(tl:ITextLine, fle:IFlowLeafElement, r:Rectangle, color:uint, alpha:Number):void;
+
+		function addNumberLine(tl:ITextLine, numberLine:ITextLine):void;
+
+		function finalizeLine(line:ITextFlowLine):void;
+
+		function getEntry(line:ITextLine):*;
+
+		function drawAllRects(textFlow:ITextFlow, bgShape:IGraphicShape, constrainWidth:Number, constrainHeight:Number):void;
+
+		function removeLineFromCache(tl:ITextLine):void;
+
+		function onUpdateComplete(controller:IContainerController):void;
+
+		function getShapeRectArray():Array;
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IBreakElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IBreakElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IBreakElement.as
new file mode 100644
index 0000000..f7098b2
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IBreakElement.as
@@ -0,0 +1,24 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	public interface IBreakElement extends ISpecialCharacterElement
+	{
+	}
+}
\ No newline at end of file


[31/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/TextContainerManager.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/TextContainerManager.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/TextContainerManager.as
new file mode 100644
index 0000000..df03373
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/TextContainerManager.as
@@ -0,0 +1,2578 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.container
+{
+	import org.apache.flex.core.IChild;
+	import org.apache.flex.core.IParentIUIBase;
+	import org.apache.flex.core.IUIBase;
+	import org.apache.flex.events.Event;
+	import org.apache.flex.events.EventDispatcher;
+	import org.apache.flex.events.KeyboardEvent;
+	import org.apache.flex.events.MouseEvent;
+	import org.apache.flex.geom.Rectangle;
+	import org.apache.flex.text.engine.ITextBlock;
+	import org.apache.flex.text.engine.ITextLine;
+	import org.apache.flex.text.events.IMEEvent;
+	import org.apache.flex.text.events.TextEvent;
+	import org.apache.flex.textLayout.compose.ISWFContext;
+	import org.apache.flex.textLayout.compose.ISimpleCompose;
+	import org.apache.flex.textLayout.compose.SWFContext;
+	import org.apache.flex.textLayout.compose.ITextFlowLine;
+	import org.apache.flex.textLayout.compose.TextLineRecycler;
+	import org.apache.flex.textLayout.compose.utils.FactoryHelper;
+	import org.apache.flex.textLayout.compose.utils.StandardHelper;
+	import org.apache.flex.textLayout.debug.Debugging;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.dummy.ContextMenu;
+	import org.apache.flex.textLayout.dummy.Mouse;
+	import org.apache.flex.textLayout.dummy.MouseCursor;
+	import org.apache.flex.textLayout.edit.EditManager;
+	import org.apache.flex.textLayout.edit.EditingMode;
+	import org.apache.flex.textLayout.edit.IEditManager;
+	import org.apache.flex.textLayout.edit.IInteractionEventHandler;
+	import org.apache.flex.textLayout.edit.ISelectionManager;
+	import org.apache.flex.textLayout.edit.SelectionFormat;
+	import org.apache.flex.textLayout.edit.SelectionManager;
+	import org.apache.flex.textLayout.edit.SelectionState;
+	import org.apache.flex.textLayout.elements.Configuration;
+	import org.apache.flex.textLayout.elements.ElementHelper;
+	import org.apache.flex.textLayout.elements.IConfiguration;
+	import org.apache.flex.textLayout.elements.IFlowLeafElement;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.ISpanElement;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.textLayout.elements.TextFlow;
+	import org.apache.flex.textLayout.events.CompositionCompleteEvent;
+	import org.apache.flex.textLayout.events.ContextMenuEvent;
+	import org.apache.flex.textLayout.events.DamageEvent;
+	import org.apache.flex.textLayout.events.FlowOperationEvent;
+	import org.apache.flex.textLayout.events.FocusEvent;
+	import org.apache.flex.textLayout.events.SelectionEvent;
+	import org.apache.flex.textLayout.events.StatusChangeEvent;
+	import org.apache.flex.textLayout.events.TextLayoutEvent;
+	import org.apache.flex.textLayout.events.UpdateCompleteEvent;
+	import org.apache.flex.textLayout.factory.StringTextLineFactory;
+	import org.apache.flex.textLayout.factory.TCMTextFlowTextLineFactory;
+	import org.apache.flex.textLayout.factory.TLFFactory;
+	import org.apache.flex.textLayout.factory.TextLineFactoryBase;
+	import org.apache.flex.textLayout.formats.BlockProgression;
+	import org.apache.flex.textLayout.formats.FormatValue;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+	import org.apache.flex.textLayout.property.Property;
+	import org.apache.flex.textLayout.property.PropertyFactory;
+	import org.apache.flex.textLayout.utils.FactoryUtil;
+	import org.apache.flex.utils.ObjectMap;
+	import org.apache.flex.utils.undo.IUndoManager;
+	import org.apache.flex.utils.undo.UndoManager;
+
+	/**
+	 *
+	 *  @eventType org.apache.flex.textLayout.events.FlowOperationEvent.FLOW_OPERATION_BEGIN
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	 
+	[Event(name="flowOperationBegin", type="org.apache.flex.textLayout.events.FlowOperationEvent")]
+	
+	/**
+	 * 
+	 * @eventType org.apache.flex.textLayout.events.FlowOperationEvent.FLOW_OPERATION_END
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	 
+	[Event(name="flowOperationEnd", type="org.apache.flex.textLayout.events.FlowOperationEvent")]
+	
+	
+	/**
+	 * 
+	 * @eventType org.apache.flex.textLayout.events.FlowOperationEvent.FLOW_OPERATION_COMPLETE
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	
+	[Event(name="flowOperationComplete", type="org.apache.flex.textLayout.events.FlowOperationEvent")]
+	
+	/** Dispatched whenever the selection is changed.  Primarily used to update selection-dependent user interface. 
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	
+	[Event(name="selectionChange", type="org.apache.flex.textLayout.events.SelectionEvent")]
+	
+	/** Dispatched after every recompose. 
+	*
+	* @playerversion Flash 10
+	* @playerversion AIR 1.5
+	* @langversion 3.0
+	*/
+	
+	[Event(name="compositionComplete", type="org.apache.flex.textLayout.events.CompositionCompleteEvent")]
+	
+	/** Dispatched when the mouse is pressed down over any link. 
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	
+	[Event(name="mouseDown", type="org.apache.flex.textLayout.events.FlowElementMouseEvent")]
+	
+	/** Dispatched when the mouse is released over any link. 
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	
+	[Event(name="mouseUp", type="org.apache.flex.textLayout.events.FlowElementMouseEvent")]
+	
+	/** Dispatched when the mouse passes over any link. 
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	
+	[Event(name="mouseMove", type="org.apache.flex.textLayout.events.FlowElementMouseEvent")]	
+	
+	/** Dispatched when the mouse first enters any link. 
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	
+	[Event(name="rollOver", type="org.apache.flex.textLayout.events.FlowElementMouseEvent")]
+	
+	/** Dispatched when the mouse goes out of any link. 
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	
+	[Event(name="rollOut", type="org.apache.flex.textLayout.events.FlowElementMouseEvent")]	
+	
+	/** Dispatched when any link is clicked. 
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	
+	[Event(name="click", type="org.apache.flex.textLayout.events.FlowElementMouseEvent")]
+	
+	/** Dispatched when a InlineGraphicElement is resized due to having width or height as auto or percent 
+	 * and the graphic has finished loading. 
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	
+	[Event(name="inlineGraphicStatusChanged", type="org.apache.flex.textLayout.events.StatusChangeEvent")]
+	
+	/** Dispatched by a ITextFlow object after text is scrolled within a controller container.  
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	
+	[Event(name="scroll", type="org.apache.flex.textLayout.events.TextLayoutEvent")]
+	
+	/** Dispatched by a ITextFlow object each time it is damaged 
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	
+	[Event(name="damage", type="org.apache.flex.textLayout.events.DamageEvent")]
+
+	/** Dispatched by a ITextFlow object each time a container has had new DisplayObjects added or updated as a result of composition.
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	
+	[Event(name="updateComplete", type="org.apache.flex.textLayout.events.UpdateCompleteEvent")]
+		
+	[Exclude(name="getBaseSWFContext",kind="method")]
+	
+	[Exclude(name="callInContext",kind="method")]
+	/** Manages text in a container. Assumes that it manages all children of the container. 
+	 * Consider using TextContainerManager for better performance in cases where there is a 
+	 * one container per ITextFlow, and the ITextFlow is not the main focus, is static text, or
+	 * is infrequently selected. Good for text in form fields, for example.
+	 * 
+ 	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 * 
+	 * @see ContainerController
+	 */
+	public class TextContainerManager extends EventDispatcher implements ISWFContext, IInteractionEventHandler, ISandboxSupport, ITextContainerManager
+	{		
+		// all events that are listened for need to be in this list.
+		static private const eventList:Array = [ 
+			FlowOperationEvent.FLOW_OPERATION_BEGIN,
+			FlowOperationEvent.FLOW_OPERATION_END,
+			FlowOperationEvent.FLOW_OPERATION_COMPLETE,
+			SelectionEvent.SELECTION_CHANGE,
+			CompositionCompleteEvent.COMPOSITION_COMPLETE,
+			MouseEvent.CLICK,		//from FlowElementMouseEvent
+			MouseEvent.MOUSE_DOWN,	//from FlowElementMouseEvent
+			MouseEvent.MOUSE_OUT,	//from FlowElementMouseEvent
+			MouseEvent.MOUSE_UP,	//from FlowElementMouseEvent
+			MouseEvent.MOUSE_OVER,	//from FlowElementMouseEvent
+			MouseEvent.MOUSE_OUT,	//from FlowElementMouseEvent
+			StatusChangeEvent.INLINE_GRAPHIC_STATUS_CHANGE,
+		 	TextLayoutEvent.SCROLL,
+			DamageEvent.DAMAGE,
+			UpdateCompleteEvent.UPDATE_COMPLETE
+		];
+		
+		/** Configuration to be used by the TextContainerManager.  This can only be set once and before the inputmanager is used.  */
+		static private var _defaultConfiguration:IConfiguration = null;
+
+		/** The default configuration for this TextContainerManager. Column and padding attributes
+		 * are set to <code>FormatValue.INHERIT</code>.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 * 
+	 	 * @see org.apache.flex.textLayout.elements.IConfiguration IConfiguration
+	 	 * @see org.apache.flex.textLayout.formats.FormatValue#INHERIT FormatValue.INHERIT
+		 */
+		static public function get defaultConfiguration():IConfiguration
+		{
+			if (_defaultConfiguration == null)
+				_defaultConfiguration = customizeConfiguration(null);
+			return _defaultConfiguration; 
+		}
+		
+		/** @private Make a configuration acceptable to the TCM */
+		static public function customizeConfiguration(config:IConfiguration):IConfiguration
+		{
+			var newConfig:IConfiguration;
+			if (config)
+			{
+				if (config.flowComposerClass == FactoryUtil.getDefaultFlowComposerClass())
+					return config;
+				newConfig = config.clone();
+			}
+			else
+				newConfig = new Configuration();
+			newConfig.flowComposerClass = FactoryUtil.getDefaultFlowComposerClass();
+			return newConfig;
+		}
+		
+		static private var _inputManagerTextFlowFactory:TCMTextFlowTextLineFactory;
+		static private function inputManagerTextFlowFactory():TCMTextFlowTextLineFactory
+		{
+			if (!_inputManagerTextFlowFactory)
+				_inputManagerTextFlowFactory  = new TCMTextFlowTextLineFactory();
+			return _inputManagerTextFlowFactory;
+		}
+
+		// dictionary of stringfactories so that they can share a configuration
+		static private var stringFactoryDictionary:ObjectMap;
+		static private function inputManagerStringFactory(config:IConfiguration):StringTextLineFactory
+		{
+			if (!stringFactoryDictionary)
+				stringFactoryDictionary = new ObjectMap(true);
+			var factory:StringTextLineFactory = stringFactoryDictionary[config];
+			if (factory == null)
+			{
+				factory = new StringTextLineFactory(config);
+				stringFactoryDictionary[config] = factory;
+			}
+			return factory;
+		}
+		
+		/** @private Method to release all references to factories so they can be gc'ed, for example when Flex unloads a module. */
+		static public function releaseReferences():void
+		{
+			stringFactoryDictionary = null;
+			_inputManagerTextFlowFactory = null;
+		}
+		
+		/** Shared definition of the scrollPolicy property. @private */
+		static public const editingModePropertyDefinition:Property = PropertyFactory.enumString("editingMode", EditingMode.READ_WRITE, false, null, 
+			EditingMode.READ_WRITE, EditingMode.READ_ONLY, EditingMode.READ_SELECT);	
+		
+		private var _container:IParentIUIBase;
+		private var _compositionWidth:Number;
+		private var _compositionHeight:Number;
+		
+		private var _text:String;
+		private var _textDamaged:Boolean;				// indicates the _text property needs updating when sourceState is SOURCE_TEXTFLOW
+		private var _lastSeparator:String;
+		
+		private var _hostFormat:ITextLayoutFormat;
+		// textFlow format to be used by a string factory - combination of config.initialTextLayoutFormat and hostFormat
+		private var _stringFactoryTextFlowFormat:ITextLayoutFormat;
+		
+		private var _contentTop:Number;
+		private var _contentLeft:Number;
+		private var _contentHeight:Number;
+		private var _contentWidth:Number;
+		
+		private var _horizontalScrollPolicy:String;
+		private var _verticalScrollPolicy:String;
+		
+		private var _swfContext:ISWFContext;
+		private var _config:IConfiguration;
+		
+		//Decide whether to preserve the selection state when calling setText() [bug #2931406 from Flex SDK]
+		private var _preserveSelectionOnSetText:Boolean = false;
+		
+		/** @private */
+		static public const SOURCE_STRING:int = 0;
+		/** @private */
+		static public const SOURCE_TEXTFLOW:int = 1;
+		
+		/** @private */
+		static public const COMPOSE_FACTORY:int = 0;
+		/** @private */
+		static public const COMPOSE_COMPOSER:int = 1;
+		
+		/** @private */
+		static public const HANDLERS_NOTADDED:int  = 0;
+		/** @private */
+		static public const HANDLERS_NONE:int      = 1;
+		/** @private */
+		static public const HANDLERS_CREATION:int  = 2;
+		/** @private */
+		static public const HANDLERS_ACTIVE:int    = 3;
+		/** @private */
+		static public const HANDLERS_MOUSEWHEEL:int = 4;
+		
+		private var _sourceState:int;
+		private var _composeState:int;
+		private var _handlersState:int;
+		// track hasFocus.  Depending on various factors focus and mouseDown can occur in different order
+		private var _hasFocus:Boolean;
+		private var _editingMode:String;
+		private var _ibeamCursorSet:Boolean;
+		private var _interactionCount:int;
+		
+		/** @private */
+		public function get sourceState():int
+		{ return _sourceState; }
+		/** @private */
+		public function get composeState():int
+		{ return _composeState; }
+		/** @private */
+		public function get handlersState():int
+		{ return _handlersState; }
+	
+		// Tracks damage when sourceState is SOURCE_STRING. TODO - Might be worthwhile to always set and clear this
+		private var _damaged:Boolean;			
+		private var _textFlow:ITextFlow;
+		private var _needsRedraw:Boolean;
+		
+		/** Constructor function - creates a TextContainerManager instance.
+		 *
+		 * For best results:
+		 * <ol>
+		 *	<li>Start with TextContainerManager.defaultConfiguration and modify it</li>   
+		 *	<li>Share the same Configuration among many InputManagers</li>
+		 * </ol>
+		 *
+		 * @param container The DisplayObjectContainer in which to manage the text lines.
+		 * @param config - The IConfiguration instance to use with this TextContainerManager instance. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0	 	
+		 */
+		public function TextContainerManager(container:IParentIUIBase,configuration:IConfiguration =  null)
+		{
+			_container = container;
+			_compositionWidth = 100;
+			_compositionHeight = 100;
+			
+			_config = configuration ? customizeConfiguration(configuration) : defaultConfiguration;				
+			_config = _config.getImmutableClone();
+
+			_horizontalScrollPolicy = _verticalScrollPolicy = String(ScrollPolicy.scrollPolicyPropertyDefinition.defaultValue);
+
+			_damaged = true;
+			_needsRedraw = false;
+			_text = "";
+			_textDamaged = false;
+			
+			_sourceState = SOURCE_STRING;
+			_composeState = COMPOSE_FACTORY;
+			_handlersState = HANDLERS_NOTADDED;
+			_hasFocus = false;
+			
+			_editingMode = editingModePropertyDefinition.defaultValue as String;
+			_ibeamCursorSet = false;
+			_interactionCount = 0;
+
+//TODO deal with Flash properties below.
+			
+//			if (_container is InteractiveObject)
+//			{
+//				_container.doubleClickEnabled = true;
+//				// so the textlines can be swapped on the first click and a double click still works
+//				_container.mouseChildren = false;
+//				_container.focusRect = false;
+//			}
+		}
+
+		/** Returns the container (DisplayObjectContainer) that holds the text that this TextContainerManager manages.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 *
+	 	 * @see ContainerController#container
+	 	 */
+	 	 
+		public function get container():IParentIUIBase
+		{ return _container; }
+		
+		/** Returns <code>true</code> if the content needs composing. 
+		 * 
+		 * @return	<code>true</code> if the content needs composing; <code>false</code> otherwise.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+		public function isDamaged():Boolean
+		{ return _composeState == COMPOSE_FACTORY ? _damaged : _textFlow.flowComposer.isPotentiallyDamaged(_textFlow.textLength); }
+		
+		/** Editing mode of this TextContainerManager. Modes are reading only, reading and selection permitted, 
+		 * and editing (reading, selection, and writing)  permitted. Use the constant values of the EditingMode
+		 * class to set this property. 
+		 * <p>Default value is READ_WRITE.</p>
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 *
+		 * @see org.apache.flex.textLayout.edit.EditingMode EditingMode
+		 */
+		public function get editingMode():String
+		{ return _editingMode; }
+		public function set editingMode(val:String):void
+		{
+			var newMode:String = editingModePropertyDefinition.setHelper(_editingMode, val) as String;
+			
+			if (newMode != _editingMode)
+			{
+				if (composeState == COMPOSE_COMPOSER)
+				{
+					_editingMode = newMode;
+					invalidateInteractionManager();
+				}
+				else
+				{
+					removeActivationEventListeners();
+					_editingMode = newMode;
+					// there is no way to turn it on here if going from READ_ONLY to editable and mouse is over the inputmanager field
+					if (_editingMode == EditingMode.READ_ONLY)
+						removeIBeamCursor();
+					addActivationEventListeners();
+				}
+			}
+		}
+		
+		/**
+		 * Returns the current text using a separator between paragraphs.
+		 * The separator can be specified with the <code>separator</code>
+		 * argument. The default value of the <code>separator</code> argument
+		 * is the Unicode character <code>'PARAGRAPH SEPARATOR' (U+2029)</code>.
+		 *
+		 * <p>Calling the setter discards any attached ITextFlow. Any selection is lost.</p>
+		 * 
+		 * @param separator String to set between paragraphs.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+	 	 */
+		public function getText(separator:String = '\u2029'):String
+		{
+			if (_sourceState == SOURCE_STRING)
+				return _text;
+
+			if (_textDamaged || _lastSeparator != separator)
+			{
+				_text = "";
+				var firstLeaf:IFlowLeafElement = _textFlow.getFirstLeaf();
+				if (firstLeaf != null)
+				{
+					var para:IParagraphElement = firstLeaf.getParagraph();
+					while (para)
+					{
+						var nextPara:IParagraphElement = para.getNextParagraph();
+						_text += para.getText();
+						_text += nextPara ? separator : "";
+						para = nextPara;
+					}
+				}
+				_textDamaged = false;
+				_lastSeparator = separator;
+			}
+			return _text;
+		}
+		/**
+		 * Sets the <code>text</code> property to the specified String.
+		 *
+		 * Discards any attached ITextFlow. Any selection is lost.
+		 * 
+		 * @param str the String to set
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+	 	 */
+		public function setText(text:String):void
+		{
+			var hadPreviousSelection:Boolean = false;
+			var selectionChanged:Boolean = false;
+//			var selectionState:SelectionState = null;
+            
+            var oldAnchorPosition:int = -1;
+            var oldActivePosition:int = -1;
+            
+			if (_sourceState == SOURCE_TEXTFLOW)
+			{
+				if (_textFlow.interactionManager && _textFlow.interactionManager.hasSelection()){
+					hadPreviousSelection = true;
+					
+					//preserve the selection state [bug #2931406 from Flex SDK]
+					if (_preserveSelectionOnSetText && text != null)
+                    {
+                        oldAnchorPosition = Math.min(_textFlow.interactionManager.anchorPosition, text.length);
+                        oldActivePosition = Math.min(_textFlow.interactionManager.activePosition, text.length);
+						if(oldAnchorPosition != _textFlow.interactionManager.anchorPosition || oldActivePosition != _textFlow.interactionManager.activePosition)
+							selectionChanged = true;
+					}
+				}
+				
+				removeTextFlowListeners();
+				if (_textFlow.flowComposer)
+					_textFlow.flowComposer.removeAllControllers();
+				_textFlow.unloadGraphics();
+				_textFlow = null;
+				_sourceState = SOURCE_STRING;
+				_composeState = COMPOSE_FACTORY;
+				//TODO do we need to fix this?
+//				if (_container is InteractiveObject)
+//					_container.mouseChildren = false;
+				addActivationEventListeners();
+			}
+			_text = text ? text : ""; 
+			_damaged = true;
+			_textDamaged = false;
+			
+			// Generate a damage event 
+			if (hasEventListener(DamageEvent.DAMAGE))
+				dispatchEvent(new DamageEvent(DamageEvent.DAMAGE, false, false, null, 0, _text.length));
+			
+            // If the original tcm had selection, the selection needs to be preserved after setText.
+            if (hadPreviousSelection)
+            {
+                if (_preserveSelectionOnSetText)
+                {
+					if (_composeState != COMPOSE_COMPOSER)
+                    	convertToTextFlowWithComposer();
+                    if (_textFlow.interactionManager)
+					{
+						_textFlow.interactionManager.setSelectionState(new SelectionState(_textFlow, oldAnchorPosition, oldActivePosition));
+						if(selectionChanged)
+							_textFlow.dispatchEvent(new SelectionEvent(SelectionEvent.SELECTION_CHANGE, false, false, _textFlow.interactionManager.getSelectionState()));
+					}
+                }
+                else if (hasEventListener(SelectionEvent.SELECTION_CHANGE))
+                {
+                    // generate a selection changed event.
+                    dispatchEvent(new SelectionEvent(SelectionEvent.SELECTION_CHANGE, false, false, null));
+                }
+            }    
+
+			if (_hasFocus)
+				requiredFocusInHandler(null);
+		}
+				
+		/** Sets the format when display just a string.  If displaying a ITextFlow this has no immediate effect.  The supplied ITextLayoutFormat is not copied.  Modifying it without calling this setter has indeterminate effects. */
+		public function get hostFormat():ITextLayoutFormat
+		{ return _hostFormat; }
+		public function set hostFormat(val:ITextLayoutFormat):void
+		{
+			_hostFormat = val;
+			_stringFactoryTextFlowFormat = null;
+			
+			if (_sourceState == SOURCE_TEXTFLOW)
+				_textFlow.hostFormat = _hostFormat;
+			if (_composeState == COMPOSE_FACTORY)
+				_damaged = true;
+		}
+		
+		/** Returns the horizontal extent allowed for text inside the container. The value is specified in pixels.
+		 * 
+		 * <p>After setting this property, the text in the container is damaged and requires composing.</p>
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0  
+	 	 */
+		public function get compositionWidth():Number
+		{ return _compositionWidth; }
+		public function set compositionWidth(val:Number):void
+		{
+			if (_compositionWidth == val || (isNaN(_compositionWidth) && isNaN(val)))
+				return;
+			_compositionWidth = val; 
+			if (_composeState == COMPOSE_COMPOSER)
+			{
+				getController().setCompositionSize(_compositionWidth,_compositionHeight);
+			}
+			else
+			{
+				_damaged = true; 
+			}
+		}
+	
+		/** Returns the vertical extent allowed for text inside the container. The value is specified in pixels. 
+		 * <p>After setting this property, the text in the container is damaged and requires composing.</p>
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		public function get compositionHeight():Number
+		{ return _compositionHeight; }
+		public function set compositionHeight(val:Number):void
+		{
+			if (_compositionHeight == val || (isNaN(_compositionHeight) && isNaN(val)))
+				return;
+			_compositionHeight = val; 
+			if (_composeState == COMPOSE_COMPOSER)
+			{
+				getController().setCompositionSize(_compositionWidth,_compositionHeight);
+			}
+			else
+			{
+				_damaged = true; 
+			}
+		}
+		
+		/** The Configuration object for this TextContainerManager. 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 *
+	 	 * @see org.apache.flex.textLayout.IConfiguration IConfiguration
+	 	 */
+		public function get configuration():IConfiguration
+		{ return _config; }
+			
+		/** Creates a rectangle that shows where the last call to either the <code>compose()</code> 
+		 * method or the <code>updateContainer()</code> method placed the text.
+		 *
+		 * @return  the bounds of the content
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 *
+	 	 * @see #compose()
+	 	 * @see #updateContainer()
+		 */
+		public function getContentBounds():Rectangle
+		{
+			if (_composeState == COMPOSE_FACTORY)
+				return new Rectangle(_contentLeft, _contentTop, _contentWidth, _contentHeight);
+			var controller:IContainerController = getController();
+			return controller.getContentBounds();
+		}	
+		
+		/** The current ITextFlow. Converts this to a full ITextFlow representation if it 
+		 * isn't already one. 
+		 *
+		 * @return 	the current ITextFlow object
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+		public function getTextFlow():ITextFlow
+		{
+			if (_sourceState != SOURCE_TEXTFLOW)
+			{
+				var wasDamaged:Boolean = isDamaged();
+				convertToTextFlow();
+				if (!wasDamaged)
+					updateContainer();
+			}
+			return _textFlow;
+		}
+
+		/** Sets a ITextFlow into this TextContainerManager replacing any existing ITextFlow and discarding the 
+		 * current text. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+		public function setTextFlow(textFlow:ITextFlow):void
+		{
+			if (textFlow == _textFlow)
+				return;
+			
+			if (textFlow == null)
+			{
+				setText(null);
+				return;
+			}
+						
+			// Remove the old textFlow from its TextContainerManager, if it has one
+			if (textFlow.flowComposer && textFlow.flowComposer.numControllers > 0 && textFlow.flowComposer.getControllerAt(0) is TMContainerController)
+			{
+				var controller:TMContainerController = textFlow.flowComposer.getControllerAt(0) as TMContainerController;
+				if (controller.textContainerManager && controller.textContainerManager.getTextFlow() == textFlow)
+					controller.textContainerManager.setTextFlow(null);
+			}  
+
+			if (_sourceState == SOURCE_TEXTFLOW)
+			{
+				removeTextFlowListeners();
+				if (_textFlow.flowComposer)
+					_textFlow.flowComposer.removeAllControllers();
+				_textFlow.unloadGraphics();
+				_textFlow = null;
+			}
+				
+			_textFlow = textFlow;
+			// damages the entire flow
+			_textFlow.hostFormat = hostFormat;
+			_sourceState = SOURCE_TEXTFLOW;
+			_composeState = textFlow.interactionManager || textFlow.mustUseComposer() ? COMPOSE_COMPOSER : COMPOSE_FACTORY;
+			_textDamaged = true;
+			addTextFlowListeners();
+			
+			if (_composeState == COMPOSE_COMPOSER)
+			{
+				// Possible issue - this clear call could be delayed until updateToController
+				//TODO mouseChildren
+//				_container.mouseChildren = true;
+				clearContainerChildren(true);
+				clearComposedLines();
+				_textFlow.flowComposer = StandardHelper.getNewComposer();
+				_textFlow.flowComposer.swfContext = _swfContext;
+				_textFlow.flowComposer.addController(new TMContainerController(_container,_compositionWidth,_compositionHeight,this));
+				
+				invalidateInteractionManager();
+				
+				// always start with an empty selection
+				if (_textFlow.interactionManager)
+					_textFlow.interactionManager.selectRange(-1,-1);
+			}
+			else
+				_damaged = true;
+			
+			if (_hasFocus)
+				requiredFocusInHandler(null);
+			
+			addActivationEventListeners();
+		}
+		
+		/** 
+		 * Controls whether the factory generates all text lines or stops when the container bounds are filled.
+		 * 
+		 * @copy org.apache.flex.textLayout.container.ContainerController#horizontalScrollPolicy 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+	 	 */
+	 	public function get horizontalScrollPolicy():String
+		{
+			return _horizontalScrollPolicy;
+		}
+		public function set horizontalScrollPolicy(scrollPolicy:String):void
+		{
+			_horizontalScrollPolicy = ScrollPolicy.scrollPolicyPropertyDefinition.setHelper(_horizontalScrollPolicy, scrollPolicy) as String;
+			if (_composeState == COMPOSE_COMPOSER)
+				getController().horizontalScrollPolicy = _horizontalScrollPolicy;
+			else
+				_damaged = true;
+		}
+		
+		/** 
+		 * Controls whether the factory generates all text lines or stops when the container bounds are filled.
+		 * 
+		 * @copy org.apache.flex.textLayout.container.ContainerController#verticalScrollPolicy 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+	 	 */
+	 	 
+		public function get verticalScrollPolicy():String
+		{
+			return _verticalScrollPolicy;
+		}
+		public function set verticalScrollPolicy(scrollPolicy:String):void
+		{
+			_verticalScrollPolicy = ScrollPolicy.scrollPolicyPropertyDefinition.setHelper(_verticalScrollPolicy, scrollPolicy) as String;
+			if (_composeState == COMPOSE_COMPOSER)
+				getController().verticalScrollPolicy = _verticalScrollPolicy;
+			else
+				_damaged = true;
+		}
+			
+		/** 
+		 * @copy org.apache.flex.textLayout.container.ContainerController#horizontalScrollPosition
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+	 	 */
+		public function get horizontalScrollPosition():Number
+		{ return _composeState == COMPOSE_COMPOSER ? getController().horizontalScrollPosition : 0; }
+		public function set horizontalScrollPosition(val:Number):void
+		{ 
+			if (val == 0 && _composeState == COMPOSE_FACTORY)
+				return;
+			if (_composeState != COMPOSE_COMPOSER)
+				convertToTextFlowWithComposer();
+			getController().horizontalScrollPosition = val;
+		}
+		
+		/** 
+		 * @copy org.apache.flex.textLayout.container.ContainerController#verticalScrollPosition 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+	 	 */
+		public function get verticalScrollPosition():Number
+		{ return _composeState == COMPOSE_COMPOSER ? getController().verticalScrollPosition : 0; }
+		public function set verticalScrollPosition(val:Number):void
+		{
+			if (val == 0 && _composeState == COMPOSE_FACTORY)
+				return;
+			if (_composeState != COMPOSE_COMPOSER)
+				convertToTextFlowWithComposer();
+			getController().verticalScrollPosition = val;
+		}
+
+		/** 
+		* @copy org.apache.flex.textLayout.container.ContainerController#getScrollDelta() 
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+		* @langversion 3.0
+	 	*/
+		public function getScrollDelta(numLines:int):Number
+		{
+			if (_composeState != COMPOSE_COMPOSER)
+				convertToTextFlowWithComposer();
+			return getController().getScrollDelta(numLines);
+		}
+		
+		/** 
+		* @copy org.apache.flex.textLayout.container.ContainerController#scrollToRange() 
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+		* @langversion 3.0
+	 	*/
+	 	public function scrollToRange(activePosition:int,anchorPosition:int):void
+	 	{
+			if (_composeState != COMPOSE_COMPOSER)
+				convertToTextFlowWithComposer();
+			getController().scrollToRange(activePosition,anchorPosition);	 		
+	 	}
+
+		/** 
+		* Optional ISWFContext instance used to make FTE calls as needed in the proper swf context. 
+		*
+		* 
+		* @see org.apache.flex.textLayout.compose.ISWFContext
+		* 
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0
+	 	*/
+ 	
+		public function get swfContext():ISWFContext
+		{ return _swfContext; }
+		public function set swfContext(context:ISWFContext):void
+		{ 
+			_swfContext = context;
+			if (_composeState == COMPOSE_COMPOSER)
+				_textFlow.flowComposer.swfContext = _swfContext;
+			else
+				_damaged = true;
+		}
+		
+		/** @private - TextContainerManager wraps an underlying swfcontext - tell it to FlowComposerBase so it can avoid extra invalidation */
+		public function getBaseSWFContext():ISWFContext
+		{ return _swfContext; }
+				
+		/** @private - this is part of a performance optimziation for reusing existing TextLines in place iff recreateTextLine is available. */
+	    public function callInContext(fn:Function, thisArg:Object, argsArray:Array, returns:Boolean=true):*
+		{
+			var textBlock:ITextBlock = thisArg as ITextBlock;
+			if (textBlock && _expectedFactoryCompose == FactoryHelper.staticComposer)
+			{
+			 	if (fn == textBlock.createTextLine)
+					return createTextLine(textBlock,argsArray);
+				// if (Configuration.playerEnablesArgoFeatures && fn == thisArg["recreateTextLine"])
+					return recreateTextLine(textBlock,argsArray);
+			}
+
+			var swfContext:ISWFContext = _swfContext ? _swfContext : SWFContext.globalSWFContext;
+	        if (returns)
+	            return swfContext.callInContext(fn,thisArg,argsArray,returns);
+			swfContext.callInContext(fn,thisArg,argsArray,returns);
+		}
+		
+		public function resetLine(textLine:ITextLine):void
+		{
+			// this line is being reset
+			if (textLine == _composedLines[_composeRecycledInPlaceLines-1])
+				_composeRecycledInPlaceLines--;
+		}
+		
+		/** 
+		 * Uses the <code>textBlock</code> parameter, and calls the <code>ITextBlock.createTextLine()</code> method on it 
+		 * using the remaining parameters.
+		 * WARNING: modifies argsArray
+		 *  
+		 * @copy org.apache.flex.text.engine.ITextBlock
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+		private function createTextLine(textBlock:ITextBlock, argsArray:Array):ITextLine
+		{
+			var swfContext:ISWFContext = _swfContext ? _swfContext : SWFContext.globalSWFContext;
+			// CONFIG::debug { assert(Configuration.playerEnablesArgoFeatures,"Bad call to createTextLine"); }
+
+			if (_composeRecycledInPlaceLines < _composedLines.length && _expectedFactoryCompose == FactoryHelper.staticComposer)
+			{
+				var textLine:ITextLine = _composedLines[_composeRecycledInPlaceLines++];
+
+				argsArray.splice(0,0,textLine);
+				return swfContext.callInContext(textBlock["recreateTextLine"],textBlock,argsArray);
+			}
+
+			return swfContext.callInContext(textBlock.createTextLine,textBlock,argsArray);
+		}
+
+		/** 
+		 * Uses the <code>textBlock</code> parameter, and calls the <code>FlowComposerBase.recreateTextLine()</code> method on it 
+		 * using the remaining parameters.
+		 *
+		 * @param textBlock The ITextBlock to which the ITextLine belongs.
+		 * @param textLine  The ITextLine to be recreated.
+		 * @param previousLine Specifies the previously broken line after 
+		 *	which breaking is to commence. Can be null when breaking the first line.  
+		 * @param width Specifies the desired width of the line in pixels. The 
+		 * 	actual width may be less.  
+		 * @param lineOffset An optional parameter which specifies the difference in 
+		 *	pixels between the origin of the line and the origin of the tab stops. This can be used when lines are not aligned, 
+		 * 	but it is desirable for their tabs to be so. 
+		 * @param fitSomething An optional parameter that instructs the runtime to fit at least one 
+		 * 	character into the text line, no matter what width has been specified (even if width is zero or negative, which 
+		 * 	would otherwise result in an exception being thrown).  
+		 * @return The recreated ITextLine instance.
+		 *  
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+		private function recreateTextLine(textBlock:ITextBlock, argsArray:Array):ITextLine
+		{
+			var swfContext:ISWFContext = _swfContext ? _swfContext : SWFContext.globalSWFContext;
+			// CONFIG::debug { assert(Configuration.playerEnablesArgoFeatures,"Bad call to createTextLine"); }
+
+			if (_composeRecycledInPlaceLines < _composedLines.length)
+			{
+				CONFIG::debug {assert(argsArray[0] != _composedLines[_composeRecycledInPlaceLines],"Bad args"); }
+				TextLineRecycler.addLineForReuse(argsArray[0]);	// not going to use this one
+				argsArray[0] = _composedLines[_composeRecycledInPlaceLines++];
+			}
+			return swfContext.callInContext(textBlock["recreateTextLine"],textBlock,argsArray);
+		}
+
+		
+		/** Returns the current ISelectionManager instance. Converts to ITextFlow instance and creates one if necessary. 
+		 *
+		 * @return  the interaction manager for this TextContainerManager instance.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 *
+	 	 * @see org.apache.flex.textLayout.edit.ISelectionManager ISelectionManager
+	 	 */
+		public function beginInteraction():ISelectionManager
+		{
+			++_interactionCount;
+			if (_composeState != COMPOSE_COMPOSER)
+				convertToTextFlowWithComposer();
+			return _textFlow.interactionManager;
+		}
+		
+		/** Terminates interaction. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * @see org.apache.flex.textLayout.edit.ISelectionManager ISelectionManager
+	 	 */
+		
+		public function endInteraction():void
+		{
+			--_interactionCount;
+		}
+		
+		/** Call this if you are editing, and want to reset the undo manager used for editing.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 */
+		public function invalidateUndoManager():void
+		{
+			if (_editingMode == EditingMode.READ_WRITE)
+				invalidateInteractionManager(true);
+		}
+		
+		
+		/** Call this if you change the selection formats (SelectionFormat) and want the interactionManager 
+		 * to update. 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+	 	 */
+		public function invalidateSelectionFormats():void
+		{
+			invalidateInteractionManager();
+		}
+		
+		/** The interactionManager is invalid - update it. Clients should call this if they change the 
+		 * selectionFormats.  Its called automatically if editingMode is changed. */
+		private function invalidateInteractionManager(alwaysRecreateManager:Boolean = false):void
+		{
+			if (_composeState == COMPOSE_COMPOSER)
+			{
+				var interactionManager:ISelectionManager = _textFlow.interactionManager;
+				var activePos:int = interactionManager ? interactionManager.activePosition : -1;
+				var anchorPos:int = interactionManager ? interactionManager.anchorPosition : -1;
+
+				if (_editingMode == EditingMode.READ_ONLY)
+				{
+					if (interactionManager)
+						_textFlow.interactionManager = null;
+				}
+				else if (_editingMode == EditingMode.READ_WRITE)
+				{
+					if (alwaysRecreateManager || interactionManager == null || interactionManager.editingMode == EditingMode.READ_SELECT)
+					{
+						_textFlow.interactionManager = createEditManager(getUndoManager());
+						if (_textFlow.interactionManager is SelectionManager)
+							SelectionManager(_textFlow.interactionManager).cloneSelectionFormatState(interactionManager);
+					}
+				}
+				else if (_editingMode == EditingMode.READ_SELECT)
+				{
+					if (alwaysRecreateManager || interactionManager == null || interactionManager.editingMode == EditingMode.READ_WRITE)
+					{
+						_textFlow.interactionManager = createSelectionManager();
+						if (_textFlow.interactionManager is SelectionManager)
+							SelectionManager(_textFlow.interactionManager).cloneSelectionFormatState(interactionManager);
+					}
+				}
+				
+				interactionManager = _textFlow.interactionManager;
+				if (interactionManager)
+				{
+					interactionManager.unfocusedSelectionFormat  = getUnfocusedSelectionFormat();
+					interactionManager.focusedSelectionFormat    = getFocusedSelectionFormat();
+					interactionManager.inactiveSelectionFormat = getInactiveSelectionFormat();
+					interactionManager.selectRange(anchorPos,activePos);
+				}				
+			}
+		}
+		
+		/**Create a selection manager to use for selection. Override this method if you have a custom SelectionManager that you
+		 * want to use in place of the default.
+		 *
+		 * @return	a new SelectionManager instance.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+		 */
+		protected function createSelectionManager():ISelectionManager
+		{
+			return new SelectionManager();
+		}
+		
+		/**Create an edit manager to use for editing. Override this method if you have a custom EditManager that you
+		 * want to use in place of the default.
+		 *
+		 * @param  an IUndoManager instance for the EditManager being created.
+		 * @return	the editing manager for this TextContainerManager instance.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+		 */
+		protected function createEditManager(undoManager:IUndoManager):IEditManager
+		{
+			return new EditManager(undoManager);
+		}
+		
+		private function getController():TMContainerController
+		{ return _textFlow.flowComposer.getControllerAt(0) as TMContainerController; }
+
+		/** @private */
+		public var _composedLines:Array = [];
+		
+		/** Return the ITextLine at the index from array of composed lines.
+		 *
+		 * @param index	Finds the line at this index position in the text.
+		 *
+		 * @return 	the ITextLine that occurs at the specified index.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+		 */
+		public function getLineAt(index:int):ITextLine
+		{ 
+			// note: this method is not reliable for damaged text
+			if (_composeState == COMPOSE_FACTORY)
+			{
+				// watch out for the empty TCM optimization and make a ITextLine
+				if (_sourceState == SOURCE_STRING && _text.length == 0 && !_damaged && _composedLines.length == 0)
+				{					
+					if (_needsRedraw)
+						compose();
+					else
+						updateContainer();
+					CONFIG::debug { assert(_composeState == COMPOSE_FACTORY,"no longer a factory??"); }
+				}
+				return _composedLines[index];
+			}
+			var tfl:ITextFlowLine = _textFlow.flowComposer.getLineAt(index);
+			return tfl ? tfl.getTextLine(true) : null;
+		}
+		
+		/** @copy org.apache.flex.textLayout.compose.IFlowComposer#numLines 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+		public function get numLines():int
+		{ 
+			// note: this method is not reliable for damaged text
+			if (_composeState == COMPOSE_COMPOSER)
+				return _textFlow.flowComposer.numLines;
+			// watch out for possibly optimized zero length text
+			if (_sourceState == SOURCE_STRING && _text.length == 0)
+				return 1;
+			return _composedLines.length; 
+		}
+		
+		/** @private 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function getActualNumLines():int
+		{ 
+			if (_composeState != COMPOSE_COMPOSER)
+				convertToTextFlowWithComposer();
+			// composes all lines
+			_textFlow.flowComposer.composeToPosition();
+			return _textFlow.flowComposer.numLines;
+		}
+		
+		/** @private */
+		public function clearComposedLines():void
+		{
+			if (_composedLines)
+				_composedLines.length = 0;
+		}
+		
+		private function populateComposedLines(displayObject:ITextLine):void
+		{
+			_composedLines.push(displayObject);
+		}
+		
+		// TODO FOR ARGO - think about moving these variables into a separate helper class 
+		private var _composeRecycledInPlaceLines:int;
+		private var _composePushedLines:int;
+		private function populateAndRecycleComposedLines(object:Object):void
+		{
+			var textLine:ITextLine = object as ITextLine;
+			if (textLine)
+			{
+				CONFIG::debug { assert(_composePushedLines >= _composedLines.length || _composedLines[_composePushedLines] == textLine,"mismatched recycled textline"); }
+				if (_composePushedLines >= _composedLines.length)
+					_composedLines.push(textLine);
+			}
+			else	// this is the background color and goes at the head of the list
+				_composedLines.splice(0,0,object);
+			_composePushedLines++;
+		}		
+		
+		static private var _expectedFactoryCompose:ISimpleCompose;
+
+		
+		/** Composes the container text; calls either the factory or <code>updateAllControllers()</code>.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+		public function compose():void
+		{
+			if (_composeState == COMPOSE_COMPOSER)
+				_textFlow.flowComposer.compose();
+			else if (_damaged)
+			{
+				if (_sourceState == SOURCE_TEXTFLOW && _textFlow.mustUseComposer())
+				{
+					convertToTextFlowWithComposer(false);
+					_textFlow.flowComposer.compose();
+					return;
+				}
+				else
+				{
+					var callback:Function;
+					// if (Configuration.playerEnablesArgoFeatures)
+					// {
+						// while the first thing in the array is not a ITextLine its the background color OR its some floats OR something else from the last compose - remove it
+						for (;;)
+						{
+							var firstObj:Object = _composedLines[0];
+							if (firstObj == null || (firstObj is ITextLine))
+								break;
+							_composedLines.splice(0,1);
+						}
+						_composeRecycledInPlaceLines = 0;
+						_composePushedLines = 0;
+						callback = populateAndRecycleComposedLines;
+					// }
+					// else
+					// {
+					// 	clearComposedLines();
+					// 	callback = populateComposedLines;
+					// }
+					var inputManagerFactory:TextLineFactoryBase = (_sourceState == SOURCE_STRING) ? inputManagerStringFactory(_config) : inputManagerTextFlowFactory();
+					inputManagerFactory.verticalScrollPolicy = _verticalScrollPolicy;
+					inputManagerFactory.horizontalScrollPolicy = _horizontalScrollPolicy;
+					inputManagerFactory.compositionBounds = new Rectangle(0,0,_compositionWidth,_compositionHeight);
+					inputManagerFactory.swfContext = this;//Configuration.playerEnablesArgoFeatures ? this : _swfContext;
+					
+					// compose can recurse for composing.  this sets up the swfContext so it doesn't recycle a line into a numberline
+					_expectedFactoryCompose = TextLineFactoryBase.peekFactoryCompose();
+					if (_sourceState == SOURCE_STRING)
+					{
+						var stringFactory:StringTextLineFactory = inputManagerFactory as StringTextLineFactory;
+						if (!_stringFactoryTextFlowFormat)
+						{
+							if (_hostFormat == null)
+								_stringFactoryTextFlowFormat = _config.textFlowInitialFormat;
+							else
+							{
+								// mini cascade of initialFormat onto the hostFormat
+								var format:TextLayoutFormat = new TextLayoutFormat(_hostFormat);
+								TextLayoutFormat.resetModifiedNoninheritedStyles(format);
+								var holderStyles:Object = (_config.textFlowInitialFormat as TextLayoutFormat).getStyles();
+								for (var key:String in holderStyles)
+								{
+									var val:* = holderStyles[key];
+									format[key] = (val !== FormatValue.INHERIT) ? val : _hostFormat[key];
+								}
+								_stringFactoryTextFlowFormat = format;
+							}
+						}
+						if (!TextLayoutFormat.isEqual(stringFactory.textFlowFormat,_stringFactoryTextFlowFormat))
+							stringFactory.textFlowFormat = _stringFactoryTextFlowFormat;
+						stringFactory.text = _text;
+						stringFactory.createTextLines(callback);
+					}
+					else
+					{
+						var factory:TCMTextFlowTextLineFactory = inputManagerFactory as TCMTextFlowTextLineFactory;
+						factory.tcm = this;
+						factory.createTextLines(callback,_textFlow);
+						factory.tcm = null;
+					}
+					inputManagerFactory.swfContext = null;	// release any references to the swfContext
+					_expectedFactoryCompose = null;
+							
+					// if (Configuration.playerEnablesArgoFeatures)
+						_composedLines.length = _composePushedLines;
+
+					var bounds:Rectangle = inputManagerFactory.getContentBounds();
+					
+					_contentLeft   = bounds.x;
+					_contentTop    = bounds.y;
+					_contentWidth  = bounds.width;
+					_contentHeight = bounds.height;
+					_damaged = false;
+					
+					// generate a compositionComplete event.  Note that the last composed position isn't known
+					if (hasEventListener(CompositionCompleteEvent.COMPOSITION_COMPLETE))
+						dispatchEvent(new CompositionCompleteEvent(CompositionCompleteEvent.COMPOSITION_COMPLETE,false,false,_textFlow,0,-1));						
+				}
+				_needsRedraw = true;
+			}
+
+		}
+		
+		/** Updates the display; calls either the factory or updateAllControllers().
+		 * 
+		 * @return true if anything changed.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+		public function updateContainer():Boolean
+		{
+			if (_composeState == COMPOSE_COMPOSER)
+				return _textFlow.flowComposer.updateAllControllers();
+			
+			compose();
+			
+			// depending on edits the Flow may now have a composer
+			if (_composeState == COMPOSE_COMPOSER)
+			{
+				_textFlow.flowComposer.updateAllControllers();
+				return true;
+			}
+				
+			if (!_needsRedraw)
+				return false;
+			
+			factoryUpdateContainerChildren();									
+			drawBackgroundAndSetScrollRect(0,0);
+					
+			if (_handlersState == HANDLERS_NOTADDED)
+				addActivationEventListeners();
+	
+			// generate a updateComplete event.  Note that the controller isn't known
+			if (hasEventListener(UpdateCompleteEvent.UPDATE_COMPLETE))
+				dispatchEvent(new UpdateCompleteEvent(UpdateCompleteEvent.UPDATE_COMPLETE,false,false,null));	
+			
+			_needsRedraw = false;
+			return true;	// things changed
+		}
+		
+		/** @private */
+		public function factoryUpdateContainerChildren():void
+		{
+			var textObject:IChild; 	// scratch - TextLines and background shapes
+			// if (Configuration.playerEnablesArgoFeatures)
+			// {
+				// while the first child in the container is a Shape - its the background color OR a Float OR something else - lose it
+				while (_container.numElements != 0)
+				{
+					textObject = _container.getElementAt(0);
+					if (textObject is ITextLine)
+						break;
+					_container.removeElement(textObject);
+				}
+				
+				// add leading children _composedLines that are not TextLines into the Container
+				for (var idx:int = 0; idx < _composedLines.length; idx++)
+				{
+					textObject = _composedLines[idx];
+					if (textObject is ITextLine)
+						break;
+					_container.addElementAt(textObject,idx);
+				}
+				
+				// expect the leading lines are reused
+				while (_container.numElements < _composedLines.length)
+					_container.addElement(_composedLines[_container.numElements]);
+				// recycle any trailing lines
+				while (_container.numElements > _composedLines.length)
+				{
+					var textLine:ITextLine = _container.getElementAt(_composedLines.length) as ITextLine;
+					_container.removeElement(textLine);
+					if (textLine)
+					{
+						// lines were rebroken but aren't being displayed
+						if (textLine.validity == "valid")
+							textLine.textBlock.releaseLines(textLine,textLine.textBlock.lastLine);
+						textLine.userData = null;
+						TextLineRecycler.addLineForReuse(textLine);
+					}
+				}
+			// }
+			// else
+			// {
+			// 	clearContainerChildren(false);
+				
+			// 	for each (textObject in _composedLines)
+			// 		_container.addElement(textObject);
+				
+			// 	clearComposedLines();
+			// }
+		}
+		
+		private function addActivationEventListeners():void
+		{	
+			var newState:int =  HANDLERS_NONE;
+			
+			if (_composeState == COMPOSE_FACTORY)
+			{
+				if (_editingMode == EditingMode.READ_ONLY)
+					newState = HANDLERS_MOUSEWHEEL;
+				else
+					newState = _handlersState == HANDLERS_NOTADDED ? HANDLERS_CREATION : HANDLERS_ACTIVE;
+			}
+			
+			if (newState == _handlersState)
+				return;
+			
+			removeActivationEventListeners();
+				
+			if (newState == HANDLERS_CREATION)
+			{
+				_container.addEventListener(FocusEvent.FOCUS_IN, requiredFocusInHandler);				
+				_container.addEventListener(MouseEvent.MOUSE_OVER, requiredMouseOverHandler);
+			}
+			else if (newState == HANDLERS_ACTIVE)
+			{
+				_container.addEventListener(FocusEvent.FOCUS_IN, requiredFocusInHandler);				
+				_container.addEventListener(MouseEvent.MOUSE_OVER, requiredMouseOverHandler);
+				_container.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
+				_container.addEventListener(MouseEvent.MOUSE_OUT,  mouseOutHandler);
+				_container.addEventListener(MouseEvent.WHEEL, mouseWheelHandler);
+			//	_container.addEventListener(IMEEvent.IME_START_COMPOSITION, imeStartCompositionHandler);
+			// attach by literal event name to avoid Argo dependency
+				_container.addEventListener("imeStartComposition", imeStartCompositionHandler);
+				
+				//TODO deal with contxt menus
+				// If TCM's getContextMenu returns null assume client has control of the contextMenu
+//				if (getContextMenu() != null)
+//					_container.contextMenu = _contextMenu;
+//				if (_container.contextMenu)
+//					_container.contextMenu.addEventListener(ContextMenuEvent.MENU_SELECT, menuSelectHandler);
+		            
+		        _container.addEventListener(SelectionEvent.SELECT_ALL, editHandler);
+			}
+			else if (newState == HANDLERS_MOUSEWHEEL)
+				_container.addEventListener(MouseEvent.WHEEL, mouseWheelHandler);				
+			
+			_handlersState = newState;
+		}
+		
+		// The ContextMenu to be used.  The idea is that this is undefined until createContextMenu is called and then 
+		// createContextMenu is only called once and the result is shared with the ContainerController when it gets created
+		private var _contextMenu:*;
+		
+		/** @private  Returns the already created contextMenu.  If not created yet create it.  */
+		public function getContextMenu():ContextMenu
+		{
+			if (_contextMenu === undefined)
+				_contextMenu = createContextMenu();
+			return _contextMenu;
+		}
+
+		private function removeActivationEventListeners():void
+		{
+			if (_handlersState == HANDLERS_CREATION)
+			{
+				CONFIG::debug { assert(_composeState != COMPOSE_COMPOSER,"Bad call to removeActivationEventListeners"); }
+				_container.removeEventListener(FocusEvent.FOCUS_IN, requiredFocusInHandler);				
+				_container.removeEventListener(MouseEvent.MOUSE_OVER, requiredMouseOverHandler);
+			}
+			else if (_handlersState == HANDLERS_ACTIVE)
+			{
+				CONFIG::debug { assert(_composeState != COMPOSE_COMPOSER,"Bad call to removeActivationEventListeners"); }
+				_container.removeEventListener(FocusEvent.FOCUS_IN, requiredFocusInHandler);				
+				_container.removeEventListener(MouseEvent.MOUSE_OVER, requiredMouseOverHandler);
+				_container.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
+				_container.removeEventListener(MouseEvent.MOUSE_OUT,  mouseOutHandler);
+				_container.removeEventListener(MouseEvent.WHEEL, mouseWheelHandler);
+			//	_container.removeEventListener(IMEEvent.IME_START_COMPOSITION, imeStartCompositionHandler);
+			// detach by literal event name to avoid Argo dependency
+				_container.removeEventListener("imeStartComposition", imeStartCompositionHandler);
+				// if _contextMenu is set then this TCM created the contextMenu and is manging it
+				//TODO deal with context menus
+//				if (_container.contextMenu)
+//					_container.contextMenu.removeEventListener(ContextMenuEvent.MENU_SELECT, menuSelectHandler);
+//				// otherwise client is managing it
+//				if (_contextMenu)	
+//					_container.contextMenu = null;
+
+		        _container.removeEventListener(SelectionEvent.SELECT_ALL, editHandler);
+			}
+			else if (_handlersState == HANDLERS_MOUSEWHEEL)
+			{
+				CONFIG::debug { assert(_composeState != COMPOSE_COMPOSER,"Bad call to removeActivationEventListeners"); }
+				_container.removeEventListener(MouseEvent.WHEEL, mouseWheelHandler);		
+			}
+
+			_handlersState = HANDLERS_NOTADDED;
+		}
+		
+		private function addTextFlowListeners():void
+		{
+			for each (var event:String in eventList)			
+				_textFlow.addEventListener(event,dispatchEvent);
+		}
+		
+		private function removeTextFlowListeners():void
+		{
+			for each (var event:String in eventList)			
+				_textFlow.removeEventListener(event,dispatchEvent);
+			_handlersState = HANDLERS_NONE;
+		}
+		
+		/**
+		 * @copy org.apache.flex.events.IEventDispatcher#dispatchEvent()
+		 * @private
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+ 		 */
+//TODO is this really needed?
+//		public override function dispatchEvent(event:Event):Boolean
+//		{
+//			if (event.type == DamageEvent.DAMAGE)
+//			{
+//				_textDamaged = true;
+//				if (_composeState == COMPOSE_FACTORY)
+//					_damaged = true;
+//			}
+//			else if (event.type == FlowOperationEvent.FLOW_OPERATION_BEGIN)
+//			{
+//				//TODO fix mouseChildren
+////				if (_container.mouseChildren == false)
+////					_container.mouseChildren = true;
+//			}
+//			var result:Boolean = super.dispatchEvent(event);
+//			if (!result)
+//				event.preventDefault();
+//			return result;
+//		}
+		
+		/** @private */
+		public function clearContainerChildren(recycle:Boolean):void
+		{
+			while(_container.numElements)
+			{
+				var textLine:ITextLine = _container.getElementAt(0) as ITextLine;
+				_container.removeElement(textLine);
+				if (textLine)
+				{
+					// releasing all textLines so release each still connected textBlock
+					if (textLine.validity != "invalid" && textLine.validity != "static")
+					{
+						var textBlock:ITextBlock = textLine.textBlock;
+						CONFIG::debug { Debugging.traceFTECall(null,textBlock,"releaseLines",textBlock.firstLine, textBlock.lastLine); }	
+						textBlock.releaseLines(textBlock.firstLine,textBlock.lastLine);
+					}					
+					if (recycle)
+					{
+						textLine.userData = null;	// clear any userData
+						TextLineRecycler.addLineForReuse(textLine);
+					}
+				}
+			}
+		}
+		
+		private function convertToTextFlow():void
+		{
+			CONFIG::debug { assert(_sourceState != SOURCE_TEXTFLOW,"bad call to convertToTextFlow"); }
+									
+			_textFlow = new TextFlow(TLFFactory.defaultTLFFactory, _config);
+			_textFlow.hostFormat = _hostFormat;
+			if(_swfContext)
+			{
+				_textFlow.flowComposer.swfContext = _swfContext;
+			}
+	
+			var p:IParagraphElement = ElementHelper.getParagraph();
+			_textFlow.addChild(p);
+			var s:ISpanElement = ElementHelper.getSpan();
+			s.text = _text;
+			p.addChild(s);
+			_sourceState = SOURCE_TEXTFLOW;
+			addTextFlowListeners();			
+		}
+				
+		/** @private */
+		public function convertToTextFlowWithComposer(callUpdateContainer:Boolean = true):void
+		{
+			removeActivationEventListeners();
+			
+			if (_sourceState != SOURCE_TEXTFLOW)
+				convertToTextFlow();
+			
+			if (_composeState != COMPOSE_COMPOSER)
+			{
+				clearContainerChildren(true);
+				clearComposedLines();
+				var controller:TMContainerController = new TMContainerController(_container,_compositionWidth,_compositionHeight,this);
+				_textFlow.flowComposer = StandardHelper.getNewComposer();
+				_textFlow.flowComposer.addController(controller);
+				_textFlow.flowComposer.swfContext = _swfContext;
+				_composeState = COMPOSE_COMPOSER;
+				
+				invalidateInteractionManager();
+				if (callUpdateContainer)
+					updateContainer();
+			}
+		}
+		
+		private function get effectiveBlockProgression():String
+		{
+			if (_textFlow)
+				return _textFlow.computedFormat.blockProgression;
+			return _hostFormat && _hostFormat.blockProgression && _hostFormat.blockProgression != FormatValue.INHERIT ? _hostFormat.blockProgression : BlockProgression.TB;
+		}
+		
+		/* CONFIG::debug private static function doTrace(msg:String):void
+		{ trace(msg); } */
+		
+		private function removeIBeamCursor():void
+		{
+			if (_ibeamCursorSet)
+			{
+				Mouse.cursor = Configuration.getCursorString(configuration, MouseCursor.AUTO);
+				_ibeamCursorSet = false;
+			}
+		}
+		
+		private var _hasScrollRect:Boolean = false;
+		
+		/** 
+		 * Specifies whether this container has attached a ScrollRect object. Value is <code>true</code>
+		 * or <code>false</code>. A display object is cropped to the size defined by the scroll rectangle, and 
+		 * it scrolls within the rectangle when you change the x and y properties of the scrollRect object. 
+		 *
+		 * <p>This property enables a client to test for a ScrollRect object without accessing 
+		 * the DisplayObject.scrollRect property, which can have side effects in some cases.</p> 
+		 *
+		 * @return true if the controller has attached a ScrollRect instance.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 *
+		 * @see #drawBackgroundAndSetScrollRect 
+		 */
+		private function get hasScrollRect():Boolean
+		{ return _hasScrollRect; }
+		private function set hasScrollRect(value:Boolean):void
+		{ _hasScrollRect = value; }
+		
+		/**   
+		 * Returns <code>true</code> if it has filled in the container's scrollRect property.  
+		 * This method enables you to test whether <code>scrollRect</code> is set without actually accessing the <code>scrollRect</code> property 
+		 * which can possibly create a  performance issue. 
+		 * <p>Override this method to draw a background or a border.  Overriding this method can be tricky as the scrollRect <bold>must</bold> 
+		 * be set as specified.</p>
+		 * 
+		 * @param scrollX The starting horizontal position of the scroll rectangle.
+		 * @param scrollY The starting vertical position of the scroll rectangle.
+		 * 
+		 * @return 	<code>true</code> if it has created the <code>scrollRect</code> object.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+		public function drawBackgroundAndSetScrollRect(scrollX:Number,scrollY:Number):Boolean
+		{
+//			var cont:IParentIUIBase = this.container;
+
+ 			var contentWidth:Number;
+			var contentHeight:Number;
+			if (_composeState == COMPOSE_FACTORY)
+			{
+				contentWidth = _contentWidth;
+				contentHeight = _contentHeight;
+			}
+			else
+			{
+				var controller:IContainerController = getController();
+				contentWidth = controller.contentWidth;
+				contentHeight = controller.contentHeight;
+			}
+			var width:Number;
+			if (isNaN(compositionWidth))
+			{
+				var contentLeft:Number = (_composeState == COMPOSE_FACTORY) ? _contentLeft : controller.contentLeft;
+				width = contentLeft + contentWidth - scrollX;
+			}
+			else
+				width = compositionWidth;
+			var height:Number;
+			if (isNaN(compositionHeight))
+			{ 
+				var contentTop:Number = (_composeState == COMPOSE_FACTORY) ? _contentTop : controller.contentTop;
+				height = contentTop + contentHeight - scrollY;
+			}
+			else
+				height = compositionHeight;
+			
+			//TODO fix scrollRect logic commented out below
+			if (scrollX == 0 && scrollY == 0 && contentWidth <= width && contentHeight <= height)
+			{
+				// skip the scrollRect
+				if (_hasScrollRect)
+				{
+//					cont.scrollRect = null;
+					_hasScrollRect = false;					
+				}
+			}
+			else
+			{
+//				cont.scrollRect = new Rectangle(scrollX, scrollY, width, height);
+				_hasScrollRect = true;
+				
+				// adjust to the values actually in the scrollRect
+//				scrollX = cont.scrollRect.x;
+//				scrollY = cont.scrollRect.y;
+//				width = cont.scrollRect.width;
+//				height = cont.scrollRect.height;
+			}
+			//TODO convert Sprite logic to FLexJS
+	        // NOTE: must draw a background for interaction support - even it if is 100% transparent
+//	        var s:Sprite = cont as Sprite;
+//	        if (s)
+//	        {
+//				s.graphics.clear();
+//				s.graphics.beginFill(0, 0); 
+//		       	s.graphics.drawRect(scrollX,scrollY,width,height);
+//		        s.graphics.endFill();
+//		    }
+	
+	        return _hasScrollRect;
+		}
+		
+		/** Returns the focusedSelectionFormat - by default get it from the configuration.
+		 * This can be overridden in the subclass to supply a different SelectionFormat
+		 */
+		protected function getFocusedSelectionFormat():SelectionFormat
+		{
+			return _config.focusedSelectionFormat;
+		}
+		
+		/** Returns the inactiveSelectionFormat - by default get it from the configuration 
+		 * This can be overridden in the subclass to supply a different SelectionFormat
+		 */
+		protected function getInactiveSelectionFormat():SelectionFormat
+		{
+			return _config.inactiveSelectionFormat;
+		}
+		
+		/** Returns the unfocusedSelectionFormat - by default get it from the configuration 
+		 * You can override this method in the subclass to supply a different SelectionFormat.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		protected function getUnfocusedSelectionFormat():SelectionFormat
+		{
+			return _config.unfocusedSelectionFormat;
+		}
+		
+		/** 
+		 * Returns the undo manager to use. By default, creates a unique undo manager. 
+		 * You can override this method in the subclass if you want to customize the undo manager
+		 * (for example, to use a shared undo manager for multiple TextContainerManager instances).
+		 *
+		 * @return 	new IUndoManager instance.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+	 	 */
+		 
+		protected function getUndoManager():IUndoManager
+		{
+			return new UndoManager();
+		}
+						
+		/** Creates a ContextMenu for the TextContainerManager. Use the methods of the ContextMenu 
+		 *  class to add items to the menu. 
+		 * <p>You can override this method to define a custom context menu.</p>
+		 *
+		 * @return 	the created context menu.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * @see flash.ui.ContextMenu ContextMenu
+		 */
+		protected function createContextMenu():ContextMenu
+		{
+			return ContainerController.createDefaultContextMenu();
+		}
+		/** @copy org.apache.flex.textLayout.container.ContainerController#editHandler()
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 		 * @langversion 3.0
+ 		 *
+ 		 * @see org.apache.flex.events.Event Event
+		 */	
+		public function editHandler(event:Event):void
+		{
+			if (_composeState == COMPOSE_FACTORY)
+			{
+				convertToTextFlowWithComposer();
+				getController().editHandler(event);
+				_textFlow.interactionManager.setFocus();
+			}
+			else
+				getController().editHandler(event);
+		}
+		
+		/** @copy org.apache.flex.textLayout.container.ContainerController#keyDownHandler() 
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+ 		* @langversion 3.0
+ 		* @see org.apache.flex.events.KeyboardEvent#KEY_DOWN KeyboardEvent.KEY_DOWN
+		*/	
+		public function keyDownHandler(event:KeyboardEvent):void
+		{
+			if (_composeState == COMPOSE_COMPOSER)
+				getController().keyDownHandler(event);
+		}
+		
+		/** @copy org.apache.flex.textLayout.container.ContainerController#keyUpHandler().
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+ 		* @langversion 3.0
+ 		* @see org.apache.flex.events.KeyboardEvent#KEY_UP KeyboardEvent.KEY_UP
+		*/	
+		public function keyUpHandler(event:KeyboardEvent):void
+		{
+			if (_composeState == COMPOSE_COMPOSER)
+				getController().keyUpHandler(event);
+		}
+
+		/** @copy org.apache.flex.textLayout.container.ContainerController#keyFocusChangeHandler().
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 * 	@param	event	the FocusChange event
+		 */	
+		public function keyFocusChangeHandler(event:Event):void
+		{
+			if (_composeState == COMPOSE_COMPOSER)
+				getController().keyFocusChangeHandler(event);
+		}
+		
+		/** @copy org.apache.flex.textLayout.container.ContainerController#textInputHandler()
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+ 		* @langversion 3.0
+ 		* @see org.apache.flex.events.TextEvent#TEXT_INPUT TextEvent.TEXT_INPUT
+		*/
+		public function textInputHandler(event:TextEvent):void
+		{
+			if (_composeState == COMPOSE_COMPOSER)
+				getController().textInputHandler(event);
+		}
+
+		/** Processes the <code>IME_START_COMPOSITION</code> event when the client manages events.
+		 *
+		 * @param event  The IMEEvent object.
+		 *
+		 * @playerversion Flash 10.1
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 *
+		 * @see org.apache.flex.events.IMEEvent#IME_START_COMPOSITION IMEEvent.IME_START_COMPOSITION
+		 */
+		public function imeStartCompositionHandler(event:IMEEvent):void
+		{
+			if (_composeState == COMPOSE_COMPOSER)
+				getController().imeStartCompositionHandler(event);
+		}
+		
+		/** Processes the <code>SOFT_KEYBOARD_ACTIVATING</code> event when the client manages events.
+		 *
+		 * @param event  The SoftKeyboardEvent object.
+		 *
+		 * @playerversion Flash 10.2
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 *
+		 * @see org.apache.flex.events.SoftKeyboardEvent#SOFT_KEYBOARD_ACTIVATING SoftKeyboardEvent.SOFT_KEYBOARD_ACTIVATING
+		 */
+		public function softKeyboardActivatingHandler(event:Event):void
+		{
+			if (_composeState == COMPOSE_COMPOSER)
+				getController().softKeyboardActivatingHandler(event);
+		}
+		
+		/** @copy org.apache.flex.textLayout.container.ContainerController#mouseDownHandler()
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+ 		* @langversion 3.0
+ 		* @see org.apache.flex.events.MouseEvent#MOUSE_DOWN MouseEvent.MOUSE_DOWN
+		*/	
+		public function mouseDownHandler(event:MouseEvent):void
+		{
+			// doTrace("IM:mouseDownHandler");
+			// before the mouseDown do a mouseOver
+			if (_composeState == COMPOSE_FACTORY)
+			{
+				CONFIG::debug { assert(event.currentTarget == this.container,"TextContainerManager:mouseDownHandler - unexpected currentTarget"); }
+				convertToTextFlowWithComposer();
+				getController().requiredFocusInHandler(null);
+				getController().requiredMouseOverHandler(event.target != container ? new RemappedMouseEvent(event) : event);
+				if (_hasFocus)
+					getController().requiredFocusInHandler(null);
+				getController().requiredMouseDownHandler(event);
+			}
+			else
+				getController().mouseDownHandler(event);
+		}
+
+		/** @copy org.apache.flex.textLayout.container.ContainerController#mouseMoveHandler()
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+ 		* @langversion 3.0
+ 		* @see org.apache.flex.events.MouseEvent#MOUSE_MOVE MouseEvent.MOUSE_MOVE
+		*/	
+		public function mouseMoveHandler(event:MouseEvent):void
+		{
+			if (_composeState == COMPOSE_COMPOSER)
+				getController().mouseMoveHandler(event);
+		}
+		
+		/** @copy org.apache.flex.textLayout.container.ContainerController#mouseUpHandler()
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+ 		* @langversion 3.0
+ 		* @see org.apache.flex.events.MouseEvent#MOUSE_UP MouseEvent.MOUSE_UP
+		*/	
+		public function mouseUpHandler(event:MouseEvent):void
+		{
+			if (_composeState == COMPOSE_COMPOSER)
+				getController().mouseUpHandler(event);
+		}
+		
+		/** @copy org.apache.flex.textLayout.container.ContainerController#mouseDoubleClickHandler()
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+ 		* @langversion 3.0
+ 		* @see org.apache.flex.events.MouseEvent#DOUBLE_CLICK MouseEvent.DOUBLE_CLICK
+		*/	
+		public function mouseDoubleClickHandler(event:MouseEvent):void
+		{
+			if (_composeState == COMPOSE_COMPOSER)
+				getController().mouseDoubleClickHandler(event);
+		}
+
+		/** @private Process a mouseOver event.
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+ 		* @langversion 3.0
+		*/			
+		public final function requiredMouseOverHandler(event:MouseEvent):void
+		{
+			if (_composeState == COMPOSE_FACTORY)
+				mouseOverHandler(event);
+			if (_composeState == COMPOSE_COMPOSER)
+				getController().requiredMouseOverHandler(event);
+		}
+		
+
+		/** Process a mouseOver event.
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+ 		* @langversion 3.0
+ 		* @see org.apache.flex.events.MouseEvent#MOUSE_OVER MouseEvent.MOUSE_OVER
+		*/			
+		public function mouseOverHandler(event:MouseEvent):void
+		{
+			if (_composeState == COMPOSE_COMPOSER)
+				getController().mouseOverHandler(event);
+			else
+			{
+				// doTrace("IM:mouseOverHandler");
+				if (effectiveBlockProgression != BlockProgression.RL)
+				{
+					//TODO Cursor management
+//					Mouse.cursor = MouseCursor.IBEAM;
+					_ibeamCursorSet = true;
+				}	
+				addActivationEventListeners();
+			}
+		}
+		/** @copy org.apache.flex.textLayout.container.ContainerController#mouseOutHandler()
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+ 		* @langversion 3.0
+ 		* @see org.apache.flex.events.MouseEvent#MOUSE_OUT MouseEvent.MOUSE_OUT
+		*/					
+		public function mouseOutHandler(event:MouseEvent):void
+		{
+			// doTrace("IM:mouseOutHandler");
+			if (_composeState == COMPOSE_FACTORY)
+				removeIBeamCursor();
+			else
+				getController().mouseOutHandler(event);
+		}		
+		/** @copy org.apache.flex.textLayout.container.ContainerController#focusInHandler()
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+ 		* @langversion 3.0
+ 		* @see org.apache.flex.events.FocusEvent#FOCUS_IN FocusEvent.FOCUS_IN
+		*/
+
+		
+		/** Process a focusIn event.
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+ 		* @langversion 3.0
+		*/
+		public function focusInHandler(event:Event):void
+		{
+			_hasFocus = true;
+			if (_composeState == COMPOSE_COMPOSER)
+				getController().focusInHandler(event);
+		}
+		
+		/** @private hook to get at requiredFocusOutHandler as needed */
+		public function requiredFocusOutHandler(event:Event):void
+		{
+			if (_composeState == COMPOSE_COMPOSER)
+				getController().requiredFocusOutHandler(event);
+		}
+		/** @copy org.apache.flex.textLayout.container.ContainerController#focusOutHandler()
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+ 		* @langversion 3.0
+ 		* @see org.apache.flex.events.FocusEvent#FOCUS_OUT FocusEvent.FOCUS_OUT
+		*/
+		public function focusOutHandler(event:Event):void
+		{
+			_hasFocus = false;
+			if (_composeState == COMPOSE_COMPOSER)
+				getController().focusOutHandler(event);
+		}
+
+		/** @copy org.apache.flex.textLayout.container.ContainerController#activateHandler()
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+ 		* @langversion 3.0
+ 		* @see org.apache.flex.events.Event#ACTIVATE Event.ACTIVATE
+		*/				
+		public function activateHandler(event:Event):void
+		{
+			if (_composeState == COMPOSE_COMPOSER)
+				getController().activateHandler(event);
+		}		
+		/** @copy org.apache.flex.textLayout.container.ContainerController#deactivateHandler()
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+ 		* @langversion 3.0
+ 		* @see org.apache.flex.events.Event#DEACTIVATE Event.DEACTIVATE
+		*/				
+		public function deactivateHandler(event:Event):void
+		{
+			if (_composeState == COMPOSE_COMPOSER)
+				getController().deactivateHandler(event);
+		}
+		
+		/** @copy org.apache.flex.textLayout.container.ContainerController#focusChangeHandler()
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+ 		* @langversion 3.0
+ 		*
+ 		* @see org.apache.flex.events.FocusEvent#KEY_FOCUS_CHANGE FocusEvent.KEY_FOCUS_CHANGE
+		* @see org.apache.flex.events.FocusEvent#MOUSE_FOCUS_CHANGE FocusEvent.MOUSE_FOCUS_CHANGE
+		*/				
+		public function focusChangeHandler(event:Event):void
+		{
+			if (_composeState == COMPOSE_COMPOSER)
+				getController().focusChangeHandler(event);
+		}
+		
+		/** @copy org.apache.flex.textLayout.container.ContainerController#menuSelectHandler()
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+ 		* @langversion 3.0
+ 		*
+ 		* @see org.apache.flex.events.ContextMenuEvent#MENU_SELECT ContextMenuEvent.MENU_SELECT
+		*/				
+		public function menuSelectHandler(event:ContextMenuEvent):void
+		{
+			if (_composeState == COMPOSE_FACTORY)
+			{
+//TODO context menus
+				// there is no selection
+//				var contextMenu:ContextMenu = _container.contextMenu as ContextMenu;
+//				if (contextMenu)
+//				{
+//					var cbItems:ContextMenuClipboardItems = contextMenu.clipboardItems;
+//					cbItems.selectAll = _editingMode != EditingMode.READ_ONLY;
+//					cbItems.clear = false;
+//					cbItems.copy = false;
+//					cbItems.cut = false;
+//					cbItems.paste = false;
+//				}
+			}
+			else
+				getController().menuSelectHandler(event);			
+		}
+		
+		/** @copy org.apache.flex.textLayout.container.ContainerController#mouseWheelHandler()
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+ 		* @langversion 3.0
+ 		*
+ 		* @see org.apache.flex.events.MouseEvent#MOUSE_WHEEL MouseEvent.MOUSE_WHEEL
+		*/				
+		public function mouseWheelHandler(event:MouseEvent):void
+		{
+			if (event.isDefaultPrevented())
+				return;
+
+			if (_composeState == COMPOSE_FACTORY)
+			{
+				convertToTextFlowWithComposer();
+				getController().requiredMouseOverHandler(event);
+			}
+			getController().mouseWheelHandler(event);
+		}
+
+		
+		/** @private required FocusIn handler.  Clients override focusInHandler
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+ 		* @langversion 3.0
+		*/
+		public final function requiredFocusInHandler(event:Event):void
+		{			
+			// doTrace("IM:focusInHandler");
+			if (_composeState == COMPOSE_FACTORY)
+			{
+				addActivationEventListeners();
+				focusInHandler(event);
+			}			
+			if (_composeState == COMPOSE_COMPOSER)
+				getController().requiredFocusInHandler(event);
+		}
+		
+		/** 
+		 * Called to request clients to begin the forwarding of mouseup and mousemove events from outside a security sandbox.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 */
+		public function beginMouseCapture():void
+		{ }
+		/** 
+		 * Called to inform clients that the the forwarding of mouseup and mousemove events from outside a security sandbox is no longer needed.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 */
+		public function endMouseCapture():void
+		{ }
+		/** Client call to forward a mouseUp event from outside a security sandbox.  Coordinates of the mouse up are not needed.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 */
+		public function mouseUpSomewhere(e:Event):void
+		{
+			if (_composeState == COMPOSE_COMPOSER)
+				getController().mouseUpSomewhere(e);
+		}
+		/** Client call to forward a mouseMove event from outside a security sandbox.  Coordinates of the mouse move are not needed.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 */		
+		public function mouseMoveSomewhere(e:Event):void
+		{ 
+			if (_composeState == COMPOSE_COMPOSER)
+				getController().mouseUpSomewhere(e);
+		}
+	
+		/** @private
+		 * Gets the index at which the first text line must appear in its parent.
+		 * The default implementation of this method, which may be overriden, returns the child index 
+		 * of the first <code>org.apache.flex.text.engine.ITextLine</code> child of <code>container</code>
+		 * if one exists, and that of the last child of <code>container</code> otherwise. 
+		 * 
+		 * @return the index at which the first text line must appear in its parent.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 * @see org.apache.flex.text.engine.ITextLine
+		 * @see #container
+		 */	
+		public function getFirstTextLineChildIndex():int
+		{			
+			// skip past any non-ITextLine children below the text in the container,
+			// This also means that in a container devoid of text, we will always
+			// populate the text starting at index container.numChildren, which is intentional.
+			var firstTextLine:int;
+			for(firstTextLine = 0; firstTextLine<_container.numElements; ++firstTextLine)
+			{
+				if(_container.getElementAt(firstTextLine) is ITextLine)
+				{
+					break;
+				}
+			}
+			return firstTextLine;
+		}
+		
+		/** @private
+		 * Adds a <code>org.apache.flex.text.engine.ITextLine</code> object as a descendant of <code>container</code>.
+		 * The default implementation of this method, which may be overriden, adds the object
+		 * as a direct child of <code>container</code> at the specified index.
+		 * 
+		 * @param textLine the <code>org.apache.flex.text.engine.ITextLine</code> object to add
+		 * @param index insertion index of the text line in its parent 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 * @see org.apache.flex.text.engine.ITextLine
+		 * @see #container
+		 * 
+		 */	
+		public function addTextLine(textLine:ITextLine, index:int):void
+		{ 
+			_container.addElementAt(textLine, index);
+		}
+		
+		/** @private
+		 * Removes a <code>org.apache.flex.text.engine.ITextLine</code> object from its parent. 
+		 * The default implementation of this method, which may be overriden, removes the object
+		 * from <code>container</code> if it is a direct child of the latter.
+		 * 
+		 * This method may be called even if the object is not a descendant of <code>container</code>.
+		 * Any implementation of this method must ensure that no action is taken in this case.
+		 * 
+		 * @param textLine the <code>org.apache.flex.text.engine.ITextLine</code> object to remove 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 * @see org.apache.flex.text.engine.ITextLine
+		 * @see #container
+		 * 
+		 */	
+		public function removeTextLine(textLine:ITextLine):void
+		{
+			if (_container.getElementIndex(textLine)>-1)
+				_container.removeElement(textLine);
+		}
+		
+		/** @private
+		 * Adds a <code>flash.display.Shape</code> object on which background shapes (such as background color) are drawn.
+		 * The default implementation of this method, which may be overriden, adds the object to <code>container</code>
+		 * just before the first <code>org.apache.flex.text.engine.ITextLine</code> child, if one exists, and after the last exisiting
+		 * child otherwise. 
+		 * 
+		 * @param shape <code>flash.display.Shape</code> object to add
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 * @see flash.display.Shape
+		 * @see org.apache.flex.text.engine.ITextLine
+		 * @see #container
+		 * 
+		 */
+		public function addBackgroundShape(shape:IUIBase):void	// No PMD
+		{
+			_container.addElementAt(shape, getFirstTextLineChildIndex());
+		}
+		
+		/** @private
+		 * Removes a <code>flash.display.Shape</code> object on which background shapes (such as background color) are drawn.
+		 * The default implementation of this method, which may be overriden, removes the object from its <code>parent</code>.
+		 * 
+		 * @param shape <code>flash.display.Shape</code> object to remove
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 * @see flash.display.Shape
+		 * @see org.apache.flex.text.engine.ITextLine
+		 * @see #container
+		 * 
+		 */
+		public function removeBackgroundShape(shape:IUIBase):void	
+		{
+			if (shape.parent)
+				shape.parent.removeElement(shape);
+		}
+		
+		/** @private
+		 * Adds a <code>flash.display.DisplayObjectContainer</code> object to which selection shapes (such as block selection highlight, cursor etc.) are added.
+		 * The default implementation of this method, which may be overriden, has the following behavior:
+		 * The object is added just before first <code>org.apache.flex.text.engine.ITextLine</code> child of <code>container</code> if one exists 
+		 * and the object is opaque and has normal blend mode. 
+		 * In all other cases, it is added as the last child of <code>container</code>.
+		 * 
+		 * @param selectionContainer <code>flash.display.DisplayObjectContainer</code> object to add
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 * @see flash.display.DisplayObjectContainer
+		 * @see org.apache.flex.text.engine.ITextLine
+		 * @see #container
+		 */
+		public function addSelectionContainer(selectionContainer:IParentIUIBase):void
+		{
+			//TODO deal with selection blend modes
+//			if (selectionContainer.blendMode == BlendMode.NORMAL && selectionContainer.alpha == 1)
+//			{
+//				// don't put selection behind background color or existing content in container, put it behind first text line
+				_container.addElementAt(selectionContainer, getFirstTextLineChildIndex());
+//			}
+//			else
+//				_container.addElement(selectionContainer);
+		}
+		
+		/** @private
+		 * Removes the <code>flash.display.DisplayObjectContainer</code> object which contains selection shapes (such as block selection highlight, cursor etc.).
+		 * The default implementation of this method, which may be overriden, removes the object from its parent if one exists.
+		 * 
+		 * @param selectionContainer <code>flash.display.DisplayObjectContainer</code> object to remove
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 * @see flash.display.DisplayObjectContainer
+		 * @see #container
+		 * 
+		 */
+		public function removeSelectionContainer(selectionContainer:IParentIUIBase):void
+		{	
+			selectionContainer.parent.removeElement(selectionContainer);
+		}
+		
+		/** @private
+		 * Adds a <code>flash.display.DisplayObject</code> object as a descendant of <code>parent</code>.
+		 * The default implementation of this method, which may be overriden, adds the object
+		 * as a direct child of <code>parent</code> at the specified index. This is called to add 
+		 * InlineGraphicElements to the ITextLine or container.
+		 * 
+		 * @param parent the <code>flash.display.DisplayObjectContainer</code> object to add the inlineGraphicElement to
+		 * @param inlineGraphicElement the <code>flash.display.DisplayObject</code> object to add
+		 * @param index insertion index of the float in its parent 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 2.0
+		 * @langversion 3.0
+		 * 
+		 * @see flash.display.DisplayObjectContainer
+		 * @see flash.display.DisplayObject
+		 * @see #container
+		 * 
+		 */	
+		public function addInlineGraphicElement(parent:IParentIUIBase, inlineGraphicElement:IUIBase, index:int):void
+		{
+			if (parent)
+				parent.addElementAt(inlineGraphicElement, index);
+		}
+		
+		/** @private
+		 * Removes a <code>flash.display.DisplayObject</code> object from its parent. 
+		 * The default implementation of this method, which may be overriden, removes the object
+		 * from <code>container</code> if it is a direct child of the latter.
+		 * 
+		 * This method may be called even if the object is not a descendant of <code>parent</code>.
+		 * Any implementation of this method must ensure that no action is taken in this case.
+		 * 
+		 * @param float the <code>flash.display.DisplayObject</code> object to remove 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 2.0
+		 * @langversion 3.0
+		 * 
+		 * @see flash.display.DisplayObjectContainer
+		 * @see flash.display.DisplayObject
+		 * @see #container
+		 * 
+		 */	
+		public function removeInlineGraphicElement(parent:IParentIUIBase, inlineGraphicElement:IUIBase):void
+		{
+			if (parent && inlineGraphicElement.parent == parent)
+				parent.removeElement(inlineGraphicElement);
+		}
+
+		/** @public
+		 * It's <code>_preserveSelectionOnSetText</code> to decide whether or not TLF preserve selection state during setText().
+		 * 
+		 * The default value is false, which means <code>setText()</code> does not preserve original selection sta

<TRUNCATED>

[12/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/FlowElementMouseEvent.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/FlowElementMouseEvent.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/FlowElementMouseEvent.as
new file mode 100644
index 0000000..c3083dc
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/FlowElementMouseEvent.as
@@ -0,0 +1,216 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.events
+{
+	import org.apache.flex.events.Event;
+	import org.apache.flex.events.IFlexJSEvent;
+	import org.apache.flex.events.MouseEvent;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+			
+	/** A link element dispatches this event when it detects mouse activity.
+	 * The Text Layout Framework includes this special version of mouse events
+	 * because mouse events are generally unwanted when a flow element is
+	 * embedded in an editable text flow, and because link elements are not in
+	 * the display list (they are not DisplayObjects).
+	 * <p>You can add an event listener to a link element to listen for this
+	 * type of event. If you choose to cancel the event by calling
+	 * <code>Event.preventDefault()</code>, the default behavior associated
+	 * with the event will not occur.
+	 * </p>
+	 * <p>If you choose not to add an event listener to the link element, or
+	 * your event listener function does not cancel the behavior, the 
+	 * event is again dispatched, but this time by the link element's
+	 * associated TextFlow instance rather than by the link element itself. 
+	 * This provides a second opportunity to listen for this event with
+	 * an event listener attached to the TextFlow. 
+	 * </p>
+	 * <p>FlowElementMouseEvents are
+	 * dispatched only when the text cannot be edited or when the control key 
+	 * is pressed concurrently with the mouse activity.</p>
+	 * <p>
+	 * The following six event types are dispatched only when the text
+	 * cannot be edited or when the control key is pressed:
+	 * <ul>
+	 *   <li><code>FlowElementMouseEvent.CLICK</code></li>
+	 *   <li><code>FlowElementMouseEvent.MOUSE_DOWN</code></li>
+	 *   <li><code>FlowElementMouseEvent.MOUSE_UP</code></li>
+	 *   <li><code>FlowElementMouseEvent.MOUSE_MOVE</code></li>
+	 *   <li><code>FlowElementMouseEvent.ROLL_OVER</code></li>
+	 *   <li><code>FlowElementMouseEvent.ROLL_OUT</code></li>
+	 * </ul>
+	 * </p>
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 * @see org.apache.flex.textLayout.elements.LinkElement
+     * @see org.apache.flex.events.MouseEvent
+	 */
+	public class FlowElementMouseEvent extends Event
+	{
+		/**
+		 * Defines the value of the <code>type</code> property of a <code>mouseDown</code> event object. 
+		 * 
+		 * @see org.apache.flex.events.MouseEvent#MOUSE_DOWN
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const MOUSE_DOWN:String = "mouseDown";
+		/**
+		 * Defines the value of the <code>type</code> property of a <code>mouseUp</code> event object. 
+		 * 
+		 * @see org.apache.flex.events.MouseEvent#MOUSE_UP
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const MOUSE_UP:String = "mouseUp";	
+		/**
+		 * Defines the value of the <code>type</code> property of a <code>mouseMove</code> event object. 
+		 * 
+		 * @see org.apache.flex.events.MouseEvent#MOUSE_MOVE
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const MOUSE_MOVE:String = "mouseMove";
+		/**
+		 * Defines the value of the <code>type</code> property of a <code>rollOver</code> event object. 
+		 * 
+		 * @see org.apache.flex.events.MouseEvent#ROLL_OVER
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const ROLL_OVER:String = "rollOver";
+		/**
+		 * Defines the value of the <code>type</code> property of a <code>rollOut</code> event object. 
+		 * 
+		 * @see org.apache.flex.events.MouseEvent#ROLL_OUT
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const ROLL_OUT:String = "rollOut";	
+		/**
+		 * Defines the value of the <code>type</code> property of a <code>click</code> event object. 
+		 * 
+		 * @see org.apache.flex.events.MouseEvent#CLICK
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const CLICK:String = "click";
+
+		private var _flowElement:IFlowElement;
+		private var _originalEvent:MouseEvent;
+		
+		/** 
+		 * The FlowElement that dispatched the event.
+		 *
+		 * @see org.apache.flex.textLayout.elements.FlowElement
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public function get flowElement():IFlowElement
+		{ return _flowElement; }		
+		public function set flowElement(value:IFlowElement):void
+		{ _flowElement = value; }
+		
+		/** 
+		 * The original mouse event generated by the mouse activity. 
+		 * This property can contain any of the following values:
+		 * <ul>
+		 *   <li><code>MouseEvent.CLICK</code></li>
+		 *   <li><code>MouseEvent.MOUSE_DOWN</code></li>
+		 *   <li><code>MouseEvent.MOUSE_UP</code></li>
+		 *   <li><code>MouseEvent.MOUSE_MOVE</code></li>
+		 *   <li><code>MouseEvent.MOUSE_OVER</code></li>
+		 *   <li><code>MouseEvent.MOUSE_OUT</code></li>
+		 * </ul>
+		 * <p>
+		 * In most cases the original event matches the event that the
+		 * link element dispatches. The events match for the <code>click</code>,
+		 * <code>mouseDown</code>, <code>mouseOut</code>, and <code>mouseOver</code>
+		 * events. There are two cases, however, in which the original event
+		 * is converted by the link element to a related event. 
+		 * If a link element detects a <code>mouseOver</code> event, it dispatches
+		 * a <code>rollOver</code> event. Likewise, if a link element detects
+		 * a <code>mouseOut</code> event, it dispatches a <code>rollOut</code> event.
+		 * Usually, the event target and the mouse coordinates are related to
+		 * the TextLine instance containing the link element.
+		 * </p>
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 * @see org.apache.flex.events.MouseEvent
+		 */
+		public function get originalEvent():MouseEvent
+		{ return _originalEvent; }		
+		public function set originalEvent(value:MouseEvent):void
+		{ _originalEvent = value; }
+				
+		/** 
+		 * Creates an event object that contains information about mouse activity.
+		 * Event objects are passed as parameters to event listeners. Use the
+		 * constructor if you plan to manually dispatch an event. You do not need
+		 * to use the constructor to listen for FlowElementMouseEvent objects
+		 * generated by a FlowElement.
+		 * @param type  The type of the event. Event listeners can access this information through the
+		 * inherited <code>type</code> property. There are six types:
+		 * <code>FlowElementMouseEvent.CLICK</code>; <code>FlowElementMouseEvent.MOUSE_DOWN</code>; <code>FlowElementMouseEvent.MOUSE_MOVE</code>;
+		 * <code>FlowElementMouseEvent.MOUSE_UP</code>; <code>FlowElementMouseEvent.ROLL_OVER</code>; and <code>FlowElementMouseEvent.ROLL_OUT</code>.
+		 * @param bubbles Determines whether the Event object participates in the bubbling phase of the
+		 * event flow. FlowElementMouseEvent objects do not bubble.
+		 * @param cancelable Determines whether the Event object can be canceled. Event listeners can
+		 * access this information through the inherited <code>cancelable</code> property. FlowElementMouseEvent
+		 * objects can be cancelled. You can cancel the default behavior associated with this event
+		 * by calling the <code>preventDefault()</code> method in your event listener.
+		 * @param flowElement The instance of FlowElement, currently a LinkElement, associated with this
+		 * event. Event listeners can access this information through the <code>flowElement</code> property.
+		 * @param originalEvent The original mouse event that occurred on the flowElement. Event listeners can 
+		 * access this information through the <code>originalEvent</code> property.
+
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public function FlowElementMouseEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = true, flowElement:IFlowElement = null, originalEvent:MouseEvent = null)
+		{
+			super(type, bubbles, cancelable);
+			_flowElement = flowElement;
+			_originalEvent = originalEvent;
+        }
+        
+        /** @private */
+        override public function cloneEvent():IFlexJSEvent
+        {
+        	return new FlowElementMouseEvent(type, bubbles, cancelable, flowElement, originalEvent);
+        }
+        
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/FlowElementMouseEventManager.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/FlowElementMouseEventManager.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/FlowElementMouseEventManager.as
new file mode 100644
index 0000000..855dc12
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/FlowElementMouseEventManager.as
@@ -0,0 +1,732 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.events
+{
+	import org.apache.flex.core.IParentIUIBase;
+	import org.apache.flex.core.IUIBase;
+	import org.apache.flex.events.Event;
+	import org.apache.flex.events.KeyboardEvent;
+	import org.apache.flex.events.MouseEvent;
+	import org.apache.flex.geom.Point;
+	import org.apache.flex.geom.Rectangle;
+	import org.apache.flex.textLayout.container.IContainerController;
+	import org.apache.flex.textLayout.container.ScrollPolicy;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.elements.IFlowGroupElement;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.textLayout.elements.ILinkElement;
+	import org.apache.flex.textLayout.elements.TextRange;
+	import org.apache.flex.textLayout.formats.BlockProgression;
+	import org.apache.flex.textLayout.utils.GeometryUtil;
+	import org.apache.flex.textLayout.utils.HitTestArea;
+	import org.apache.flex.utils.ObjectMap;
+
+
+	
+	// [ExcludeClass]
+	/**
+	 * The ElementMouseEventManager class provides mouse element processing for visible
+	 * FlowElements. The caller calls updateHitTests(), which traverses the FlowElement
+	 * tree in the given character range, and collects hit test rectangles for FlowElements 
+	 * with active event mirrors, and LinkElements. The latter class exposes a number of
+	 * mouse event handlers that this class calls directly. If no character range is
+	 * supplied, the class makes an educated guess about the visible character range by 
+	 * inspecting the TextLine instances connected to the container widget as children.
+	 * 
+	 * In edit mode, moving the mouse over the element and clicking it should not activate
+	 * it, but rather allow for editing. Passing in the value true as an argument
+	 * to updateHitTests() requires the Ctrl key to be held down in order to pass mouse 
+	 * events on the FlowElements. If the user presses or releases the Ctrl key while the
+	 * mouse is over the container widget (and the pressing of the Ctrl key is required
+	 * for activation, the class simulates mouseOut and mouseOver events to inform the 
+	 * FlowElement underneath about the change. The class dispatches only FlowElementMouseEvents.
+	 * 
+	 * This class emits click events if the main mouse button is pressed and released over the
+	 * same FlowElement.
+	 * 
+	 * The owner may choose to forward several mouse and keyboard events to this class so it
+	 * does not need to listen to these events at the container itself. The constructor takes
+	 * an array of event names that this class needs to listen to itself. The events that this
+	 * class needs to listen to are MouseEvent.MOUSE_OVER, MouseEvent.MOUSE_OUT, MouseEvent.MOUSE_DOWN,
+	 * MouseEvent.MOUSE_UP, MouseEvent.MOUSE_MOVE, KeyboardEvent.KEY_DOWN, and KeyboardEvent.KEY_UP.
+	 * Note that MouseEvent.CLICK is not needed.
+	 */
+	public class FlowElementMouseEventManager
+	{
+		// The container that emits the mouse events, and that contains the TextLines as children.
+		private var _container:IParentIUIBase;
+		// the hit test rectangles if there is anything to hit test.
+		private var _hitTests:HitTestArea = null;
+		// The current element that has been identified as being hit.
+		private var _currentElement:IFlowElement = null;
+		// The element that has received the last museDown event.
+		private var _mouseDownElement:IFlowElement = null;
+		// If true, the Ctrl key is needed to send mouse events to a FlowElement.
+		private var _needsCtrlKey:Boolean = false;
+		// Reflects the state of the Ctrl key.
+		private var _ctrlKeyState:Boolean = false;
+		// The last mouse event serves as a template for fake mouse events (x, y, buttonDown)
+		private var _lastMouseEvent:MouseEvent = null;
+		/**
+		 * @private
+		 * Applies only if Ctrl key is needed: if the mouse entered the FlowElement
+		 * with the button wodn and the Ctrl key down, ignore the state of the Ctrl
+		 * key and treat it as not set. You do not want any reaction if the FlowElement
+		 * was e.g. entered during a mark operation.
+		 */
+		private var _blockInteraction:Boolean = false;
+		// Owner handles the event and calls dispatchEvent()
+		private const OWNER_HANDLES_EVENT:int = 0;
+		// This instance handles the event, but no event listener is registered.
+		private const THIS_HANDLES_EVENT:int = 1;
+		// This instance handles the event, and an an event listener is registered with the container/stage.
+		private const THIS_LISTENS_FOR_EVENTS:int = 2;
+		/** @private
+		 * This object contains the event states that this class must
+		 * register on its own behalf. The property name is the event name, 
+		 * and the property value is one of the above three constants.
+		 */
+		private var _eventListeners:Object;
+		/** @private
+		 * This object contains objects that hold a bounding rectangle in its "rect",
+		 * and a FlowElement in its "owner" property. The key is the toString() value
+		 * of the rectangle. Every time updateHitTests() is called, the object is 
+		 * checked for rectangles that still intersect with a given clip area, and 
+		 * these rectangles are removed from the object before the new rectangles 
+		 * are added. After that, the new hit test structure is built using this 
+		 * object. The code that adds rectangles uses the key to store rectangles
+		 * so updated rectangles are neatly overwritten.
+		 */
+		private var _hitRects:Object = null;
+		/**
+		 * The constructor needs the container that contains the TextLines to be checked
+		 * for visible, clicked elements. The container is also used as the event dispatcher 
+		 * for mouse events.
+		 * 
+		 * @param	container		The container holding the TextLines and emitting mouse events
+		 * @param	eventNames		An array of event names that the owner supplies itself.
+		 */
+		public function FlowElementMouseEventManager(container:IParentIUIBase, eventNames:Array)
+		{
+			_container = container;
+			_eventListeners = {};
+			_eventListeners[MouseEvent.MOUSE_OVER] =
+			_eventListeners[MouseEvent.MOUSE_OUT] =
+			_eventListeners[MouseEvent.MOUSE_DOWN] =
+			_eventListeners[MouseEvent.MOUSE_UP] =
+			_eventListeners[MouseEvent.MOUSE_MOVE] =
+			_eventListeners[KeyboardEvent.KEY_DOWN] =
+			_eventListeners[KeyboardEvent.KEY_UP] = THIS_HANDLES_EVENT;
+			// change the state for any event that the owner will supply
+			for each (var name:String in eventNames)
+				_eventListeners[name] = OWNER_HANDLES_EVENT;
+		}
+		
+		/**
+		 * Convert local mouse event coordinates, which are relative to the container
+		 * or one of its children (the event's target is the current element) to
+		 * container coordinates.
+		 * 
+		 * TODO: This is temporary code.
+		 * 
+		 * @param	evt				The mouse event containing the point to be converted.
+		 * @return					A new Point instance containing the converted coordinates.
+		 */
+		public function mouseToContainer(evt:MouseEvent):Point
+		{
+			// we have to use localX and localY because the UnitTests generate
+			// fake mouse events that are relative to a TextLine
+			var obj:Object = evt.target;
+			CONFIG::debug { assert(obj != null, "Event target is not a DisplayObject"); }
+			var containerPoint:Point = new Point(evt.localX, evt.localY);
+			while (obj != _container)
+			{
+//TODO resolve matrices
+//				var m:Matrix = obj.transform.matrix;
+//				containerPoint.offset(m.tx, m.ty);
+				containerPoint.offset(obj.x, obj.y);
+				// TextLines sometimes do not have a parent for some reason
+				obj = obj.parent;
+				if (!obj)
+					break;
+			}
+			return containerPoint;
+		}
+		
+		/**
+		 * Retrieve the status of the flag that controls whether the Ctrl key is needed
+		 * to activate event generation.
+		 */
+		public function get needsCtrlKey():Boolean
+		{
+			return _needsCtrlKey;
+		}
+		
+		/**
+		 * Set the status of the flag that controls whether the Ctrl key is needed
+		 * to activate event generation.
+		 */
+		public function set needsCtrlKey(k:Boolean):void
+		{
+			_needsCtrlKey = k;
+		}
+		
+		/**
+		 * Create an array of all FlowElements that are currently visible and that have an active
+		 * event mirror, plus all LinkElements by default, and update the hit test area for these
+		 * FlowElements. Clip the elements against the given clipping rectangle. All coordinates 
+		 * are assumed to be container coordinates.
+		 * 
+		 * <p>If the start index is -1 and or the end index is -1, the method attempts to make an educated 
+		 * guess about the visible part of the text by inspecting the visible TextLine instances, and
+		 * using their textBlockBeginIndex values as character offsets into the TextFlow tree. Note that
+		 * this method may be slow if the container contains an entire tree of DisplayObjects, because
+		 * the tree must be scanned recursively. It is always better to supply the start and end positions.</p>
+		 * 
+		 * @param	clipRect		The clipping rectangle, in container coordinates.
+		 * @param	textFlow		The TextFlow instance containing the elements to be tracked
+		 * @param	startPos		The character start position. If -1, the method attempts to
+		 * 							determine the first visible character.
+		 * @param	endPos			The character end position. If -1, the method attempts to
+		 * 							determine the last visible character.
+		 * @param	needsCtrlKey	If true, the event handler does not emit events unless
+		 * 							the Ctrl key is down. If the text is editable, simple clicks 
+		 * 							and moves should remain in the container rather than be
+		 * 							forwarded to the element.
+		 */
+		public function updateHitTests(xoffset:Number, clipRect:Rectangle, 
+									  textFlow:ITextFlow,
+									  startPos:int, endPos:int, 
+									   container:IContainerController,
+									  needsCtrlKey:Boolean=false):void
+		{
+			_needsCtrlKey = needsCtrlKey;
+			
+			var rect:Rectangle;
+			var obj:Object;
+			
+			var elements:Array = [];
+			if (textFlow.interactiveObjectCount != 0 && startPos != endPos)	// check for empty container
+			{
+				//New algorithm here to improve performance when there are link elements 
+				var uniqueDictionary:ObjectMap = container.interactiveObjects;
+				var o:Object ;
+				var f:IFlowElement;
+				for each (o in uniqueDictionary)
+				{
+					f = o as IFlowElement ;
+					if (f && f.getAbsoluteStart() < endPos && f.getAbsoluteStart() + f.textLength >= startPos)
+						elements.push(o) ;
+				}
+				//ensure there is no bug when you paste many words, which causes the link across containers
+				var interactiveObjects_LastTime:Array = container.oldInteractiveObjects;
+				for each (o in interactiveObjects_LastTime)
+				{
+					f = o as IFlowElement ;
+					if (f && f.getAbsoluteStart() < endPos && f.getAbsoluteStart() + f.textLength >= startPos)
+					{
+						elements.push(o) ;
+						uniqueDictionary[o] = o;//push back the interactive object, make sure the total number is correct 
+					}
+					
+				}
+				
+				CONFIG::debug
+				{
+					if (elements.length)
+					{
+						for each (var elem:IFlowElement in elements)
+						{
+							// trace(startPos,endPos,elem.defaultTypeName,elem.getAbsoluteStart(),elem.textLength);
+							assert(elem.getAbsoluteStart() < endPos,"updateHitTests bad absoluteStart");
+							assert(elem.getAbsoluteStart()+elem.textLength >= startPos,"updateHitTests bad absoluteEnd"); 
+						}
+					}
+				}
+			}
+			
+			var newHitRects:Object;
+			var rectCount:int = 0;
+			
+			if (elements.length != 0)
+			{		
+				newHitRects = {};
+	
+				for each (var element:IFlowElement in elements)
+				{
+					var elemStart:int = element.getAbsoluteStart();
+					var elemEnd:int = Math.min(elemStart + element.textLength, endPos);
+					var tf:ITextFlow = element.getTextFlow();
+					//Previously make sure the textflow of element is not null. No logic changes within the curly braces below.
+					if(tf)
+					{
+						var elemRects:Array = GeometryUtil.getHighlightBounds(new TextRange(tf, elemStart, elemEnd));
+						// this is an array of objects with textLine and rect properties
+						// Create an array of rectangle and owner objects to feed into a HitTestArea
+						for each (obj in elemRects)
+						{
+							rect = obj.rect;
+							//Fix for bug#2990689, handle the blockProgression == RL and direction == RTL case
+							var leftEdge:Number = clipRect.x;
+							var topEdge:Number = clipRect.y;
+													
+							//Fix for bug#2990689, 1st step:
+							//			When the blockProgression == RL and scrollPolicy.OFF case,
+							//			There will be a left/top adjust in ContainerController.fillShapeChildren()
+							//			The code change tried to find the real left boundary of container
+							//			by equalizing the adjustment in ContainerController.fillShapeChildren()
+							var wmode:String = element.computedFormat.blockProgression;
+							var adjustLines:Boolean = false;
+													
+							adjustLines = (wmode == BlockProgression.RL) &&
+								(container.horizontalScrollPolicy == ScrollPolicy.OFF && 
+									container.verticalScrollPolicy == ScrollPolicy.OFF);
+							if (adjustLines)
+							{
+								var width:Number = container.measureWidth? clipRect.width: container.compositionWidth;
+								leftEdge = clipRect.x - width + container.horizontalScrollPosition + clipRect.width;
+							}
+							
+							//Fix for bug#2990689, 2nd step:
+							//			When the direction == RTL case, the left/top edge of he text boundary will be the 
+							//			text width to the right edge rather than
+							//			the left boundary of container.
+							//			The code change tried to find the real left/top boundary of container
+							//			by setting the leftEdge to be the container's x and the topEdge to be container's y
+							if(wmode == BlockProgression.TB)
+							{
+								leftEdge = 0;
+								topEdge = 0;
+							}
+							else
+							{
+								topEdge = 0;
+							}
+													
+							rect.x = leftEdge + obj.textLine.x + rect.x + xoffset;
+							rect.y = topEdge + obj.textLine.y + rect.y;
+							//Fix for bug#2990689 end
+							// Only use the visible parts of the rectangle if any
+							rect = rect.intersection(clipRect);
+							if (!rect.isEmpty())
+							{
+								// use integer rectangles for better toString() representation
+								// this decreases the number of stored rectangles due to FP errors
+								rect.x = int(rect.x);
+								rect.y = int(rect.y);
+								rect.width = int(rect.width);
+								rect.height = int(rect.height);
+								var name:String = rect.toString();
+								var oldObj:Object = newHitRects[name];
+								if (!oldObj || oldObj.owner != element)
+								{
+									// replace or add operation
+									newHitRects[name] = { "rect": rect, "owner": element };
+									rectCount++;
+								}
+							}
+						}
+					}
+				}
+			}
+
+			if (rectCount > 0)
+			{
+				if (!_hitTests)
+					startHitTests();
+				_hitRects = newHitRects;
+				_hitTests = new HitTestArea(newHitRects);
+			}
+			else
+				stopHitTests();
+		}
+		
+		/** @private Start hit testing. */
+		public function startHitTests():void
+		{
+			_currentElement = null;
+			_mouseDownElement = null;
+			_ctrlKeyState = false;
+			// conditionally attach required event listeners
+			addEventListener(MouseEvent.MOUSE_OVER, false);
+			addEventListener(MouseEvent.MOUSE_OUT, false);
+			addEventListener(MouseEvent.MOUSE_DOWN, false);
+			addEventListener(MouseEvent.MOUSE_UP, false);
+			addEventListener(MouseEvent.MOUSE_MOVE, false);
+		}
+		
+		/**
+		 * Stop hit testing altogether. You must call this method if the
+		 * FlowElement structure of the visible area has changed; you should
+		 * also call this method if the visible area is rebuilt completely.
+		 */
+		public function stopHitTests():void
+		{
+			// conditionally remove required event listeners
+			removeEventListener(MouseEvent.MOUSE_OVER, false);
+			removeEventListener(MouseEvent.MOUSE_OUT, false);
+			removeEventListener(MouseEvent.MOUSE_DOWN, false);
+			removeEventListener(MouseEvent.MOUSE_UP, false);
+			removeEventListener(MouseEvent.MOUSE_MOVE, false);
+			removeEventListener(KeyboardEvent.KEY_DOWN, true);
+			removeEventListener(KeyboardEvent.KEY_UP, true);
+			_hitRects = null;
+			_hitTests = null;
+			_currentElement = null;
+			_mouseDownElement = null;
+			_ctrlKeyState = false;
+		}
+		
+		private function addEventListener(name:String, kbdEvent:Boolean = false):void
+		{
+			if (_eventListeners[name] === THIS_HANDLES_EVENT)
+			{
+				var target:IUIBase;
+				var listener:Function;
+				if (kbdEvent)
+				{
+//TODO
+//					target = _container.stage;
+//					if (!target)
+						target = _container;
+					listener = hitTestKeyEventHandler;
+				}
+				else
+				{
+					target = _container;
+					listener = hitTestMouseEventHandler;
+				}
+				target.addEventListener(name, listener, false, 1);
+				_eventListeners[name] = THIS_LISTENS_FOR_EVENTS;
+			}
+		}
+		
+		private function removeEventListener(name:String, kbdEvent:Boolean):void
+		{
+			if (_eventListeners[name] === THIS_LISTENS_FOR_EVENTS)
+			{
+				var target:IUIBase;
+				var listener:Function;
+				if (kbdEvent)
+				{
+//TODO
+//					target = _container.stage;
+//					if (!target)
+						target = _container;
+					listener = hitTestKeyEventHandler;
+				}
+				else
+				{
+					target = _container;
+					listener = hitTestMouseEventHandler;
+				}
+				target.removeEventListener(name, listener);
+				_eventListeners[name] = THIS_HANDLES_EVENT;
+			}
+		}
+
+		/**
+		 *  @private
+		 * Collect all FlowElements with an active event mirror plus all LinkElements in to the given
+		 * array. This method is recursive so it can iterate over child FlowElements.
+		 * 
+		 * @param	parent		The parent element to scan.
+		 * @param	startPosition	The starting character position.
+		 * @param	endPosition	The ending character position.
+		 * @param	results		The array to fill with FlowElements that match.
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.IFlowGroupElement
+		 */
+		public function collectElements(parent:IFlowGroupElement, startPosition:int, endPosition:int, results:Array):void
+		{
+			CONFIG::debug { assert(startPosition >= 0,"Bad startPosition parameter"); }
+			CONFIG::debug { assert(endPosition >= startPosition,"Bad endPosition parameter"); }
+
+			var i:int = parent.findChildIndexAtPosition(startPosition);
+			for (; i < parent.numChildren; i++)
+			{
+				var child:IFlowElement = parent.getChildAt(i);
+				if (child.parentRelativeStart >= endPosition)
+					// behind end
+					break;
+				if (child.hasActiveEventMirror() || (child is ILinkElement))
+					results.push(child);
+				var group:IFlowGroupElement = child as IFlowGroupElement;
+				if (group)
+					collectElements(group, Math.max(startPosition-group.parentRelativeStart,0), endPosition-group.parentRelativeStart, results);
+			}
+		}
+		
+		/**
+		 * Dispatch the mouse and keyboard events that the owner sends.
+		 */
+		public function dispatchEvent(evt:Event):void
+		{
+			var mouseEvt:MouseEvent = evt as MouseEvent;
+			if (mouseEvt)
+				hitTestMouseEventHandler(mouseEvt);
+			else
+			{
+				var keyEvt:KeyboardEvent = evt as KeyboardEvent;
+				if (keyEvt)
+					hitTestKeyEventHandler(keyEvt);
+			}
+		}
+		
+		/** @private
+		 * Process the key down/key up messages for the Ctrl key. This handler
+		 * is required to make a visual change for the element if the Ctrl key is
+		 * pressed or released while not moving the mouse. If a Ctrl key change
+		 * is detected, and the owner signalled that the Ctrl key is required,
+		 * there will be a mouseOver element if the Ctrl key is pressed, and a
+		 * mouseOut event if the Ctrl key is released.
+		 */
+		private function hitTestKeyEventHandler(evt:KeyboardEvent):void
+		{
+			if (!_blockInteraction)
+				checkCtrlKeyState(evt.ctrlKey);
+		}
+		
+		/**
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.ILinkElement
+		 */
+		private function checkCtrlKeyState(curState:Boolean):void
+		{
+			// currently, support only LinkElements
+			var link:ILinkElement = _currentElement as ILinkElement;
+			// do nothing if the Ctrl key is not needed, or the key state did not change
+			// we also need the last mouse event for the button state to pass in to the link
+			if(!link || !_needsCtrlKey || !_lastMouseEvent || (curState == _ctrlKeyState))
+				return;
+			_ctrlKeyState = curState;
+
+			// the event type is irrelevant here - only the buttonDown state is relevant
+			if (_ctrlKeyState)
+				link.mouseOverHandler(this, _lastMouseEvent);
+			else
+				link.mouseOutHandler(this, _lastMouseEvent);
+		}
+		
+		/** @private
+		 * Process mouse events.
+		 * 
+		 * For event mirroring, hasActiveEventMirror() must be true; if so, the event mirror
+		 * dispatches a FlowElementMouseEvent. The method generates fake rollOut and rollOver
+		 * events; the original mouseOut and mouseOver events are container and/or TextLine events.
+		 */		
+		private function hitTestMouseEventHandler(evt:MouseEvent):void
+		{
+			if (!_hitTests)
+				return;
+			
+			// note that mouseOver and mouseOut are used for hit-testing only
+			// need the last mouse event's button state to pass in to LinkElement
+			// in case the state of the Ctrl key changes (see hitTestKeyEventHandler())
+			_lastMouseEvent = evt;
+			
+			var containerPoint:Point = mouseToContainer(evt);
+			var hitElement:IFlowElement = _hitTests.hitTest(containerPoint.x, containerPoint.y);
+			if (hitElement != _currentElement)
+			{
+				_mouseDownElement = null;
+				if (_currentElement)
+					// generate a mouseOut event
+					localDispatchEvent(FlowElementMouseEvent.ROLL_OUT, evt);
+				else if (evt.buttonDown)
+					// do not interact if the button is down to not disturb e.g. 
+					// a mark operation in the container
+					_blockInteraction = true;
+				_currentElement = hitElement;
+				if (_currentElement)
+					// generate a mouseOver event
+					localDispatchEvent(FlowElementMouseEvent.ROLL_OVER, evt);
+				else
+					// no FlowElement underneathmouse: reset interaction blocker
+					_blockInteraction = false;
+			}
+
+			var isClick:Boolean = false;
+			var eventType:String = null;
+			switch (evt.type)
+			{
+				case MouseEvent.MOUSE_MOVE:
+					eventType = FlowElementMouseEvent.MOUSE_MOVE;
+					// Need to check the state of the event's Ctrl key in case
+					// the container lost focus, and the mouse was moved
+					if (!_blockInteraction)
+						checkCtrlKeyState(evt.ctrlKey);
+					break;
+				case MouseEvent.MOUSE_DOWN: 
+					_mouseDownElement = _currentElement;
+					eventType = FlowElementMouseEvent.MOUSE_DOWN;
+					break;
+				case MouseEvent.MOUSE_UP:
+					eventType = FlowElementMouseEvent.MOUSE_UP;
+					isClick = (_currentElement == _mouseDownElement);
+					_mouseDownElement = null;
+					break;
+			}
+			
+			if (_currentElement && eventType)
+			{
+				localDispatchEvent(eventType, evt);
+				if (isClick)
+					localDispatchEvent(FlowElementMouseEvent.CLICK, evt);
+			}
+		}
+		
+		/** @private
+		 * Dispatch a FlowElementMouseEvent with the given type. First, attempt to
+		 * dispatch to an event mirror if attached and listening. If there was nobody
+		 * listening at the event mirror, or the event did not stop propagation, dispatch
+		 * the event to the TextFlow as well.
+		 * 
+		 * @param	type			The event type, should be a constant defind in FlowElementMouseEvent.
+		 * @param	originalEvent	The original mouse event.
+		 * @return					true if the event was dispatched and shgould not be distributed further.
+		 */
+		public function dispatchFlowElementMouseEvent(type:String, originalEvent:MouseEvent):Boolean
+		{
+			// Mimick old behavior, and emit only rollOut events if Ctrl key is not down
+			if (_needsCtrlKey && !originalEvent.ctrlKey && type != FlowElementMouseEvent.ROLL_OUT)
+				return false;
+			
+			var locallyListening:Boolean = _currentElement.hasActiveEventMirror();
+			var textFlow:ITextFlow = _currentElement.getTextFlow();
+			var textFlowListening:Boolean = false;
+			if (textFlow)
+				textFlowListening = textFlow.hasEventListener(type);
+			if (!locallyListening && !textFlowListening)
+			{
+				return false;
+			}
+			
+			var event:FlowElementMouseEvent = new FlowElementMouseEvent(type, false, true, _currentElement, originalEvent);
+			if (locallyListening)
+			{
+				_currentElement.getEventMirror().dispatchEvent(event);
+				if (event.isDefaultPrevented())
+					return true;
+			}
+			if (textFlowListening)
+			{
+				textFlow.dispatchEvent(event);
+				if (event.isDefaultPrevented())
+					return true;
+			}
+			return false;
+		}
+		
+		/** @private
+		 * Dispatch a FlowElementMouseEvent, and call the correct LinkElement
+		 * event handler if the current element is a LinkElement.
+		 * 
+		 * LinkElements implement several mouse handlers; these are called directly
+		 * so LinkElements do not needs to register themselves with their own 
+		 * event mirror.
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.ILinkElement
+		 */
+		
+		private function localDispatchEvent(type:String, evt:MouseEvent):void
+		{
+			if (_blockInteraction || !_currentElement)
+				return;
+			
+			// Attach or detach listeners for the Ctrl key if needed
+			if (_needsCtrlKey)
+				switch (type)
+			{
+				case FlowElementMouseEvent.ROLL_OVER:
+					addEventListener(KeyboardEvent.KEY_DOWN, true);
+					addEventListener(KeyboardEvent.KEY_UP, true);
+					break;
+				case FlowElementMouseEvent.ROLL_OUT:
+					removeEventListener(KeyboardEvent.KEY_DOWN, true);
+					removeEventListener(KeyboardEvent.KEY_UP, true);
+					break;
+			}
+			
+			if (dispatchFlowElementMouseEvent(type, evt))
+				return;
+			
+			// dispatch to a LinkElement only if Ctrl key conditions fit
+			var link:ILinkElement = (!_needsCtrlKey || evt.ctrlKey) ? (_currentElement as ILinkElement) : null;
+			if (!link)
+				return;
+			
+			// use the FlowElementMouseEvent type - the mouse event type may be unrelated
+			switch (type)
+			{
+				case FlowElementMouseEvent.MOUSE_DOWN: 
+					link.mouseDownHandler(this, evt); 
+					break;
+				case FlowElementMouseEvent.MOUSE_MOVE:
+					link.mouseMoveHandler(this, evt); 
+					break;
+				case FlowElementMouseEvent.ROLL_OUT:
+					link.mouseOutHandler(this, evt); 
+					break;
+				case FlowElementMouseEvent.ROLL_OVER:
+					link.mouseOverHandler(this, evt); 
+					break;
+				case FlowElementMouseEvent.MOUSE_UP:
+					link.mouseUpHandler(this, evt); 
+					break;
+				case FlowElementMouseEvent.CLICK:
+					link.mouseClickHandler(this, evt);
+					break;
+			}
+		}
+
+		/** @private
+		 * Utility method for LinkElement (and other elements in the future that
+		 * might implement the same mouse handlers) to set and reset the Hand cursor.
+		 */
+		public function setHandCursor(state:Boolean=true):void
+		{
+			if (_currentElement == null)
+				return;
+// state;
+//TODO set hand cursor
+			
+//			var tf:ITextFlow = _currentElement.getTextFlow();
+// 			if (tf != null && tf.flowComposer && tf.flowComposer.numControllers)
+// 			{
+//				var sprite:Sprite = _container as Sprite;
+//				if (sprite)
+//				{
+//					sprite.buttonMode = state;
+//					sprite.useHandCursor = state;
+//				}
+//				if (state)
+//					Mouse.cursor = MouseCursor.BUTTON;
+//				else
+//				{
+//					var wmode:String = tf.computedFormat.blockProgression;									
+//					if (tf.interactionManager && (wmode != BlockProgression.RL))
+//						Mouse.cursor = MouseCursor.IBEAM;
+//					else
+//						Mouse.cursor = Configuration.getCursorString(tf.configuration, MouseCursor.AUTO);
+//				}
+//				Mouse.hide();
+//				Mouse.show();
+//			}
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/FlowOperationEvent.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/FlowOperationEvent.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/FlowOperationEvent.as
new file mode 100644
index 0000000..ee584fd
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/FlowOperationEvent.as
@@ -0,0 +1,168 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.events
+{
+	import org.apache.flex.events.IFlexJSEvent;
+	import org.apache.flex.events.Event;
+	
+	import org.apache.flex.textLayout.operations.FlowOperation; 
+	
+	/** A TextFlow instance dispatches this event just before an operation commences
+	 * and again just after an operation completes. Although the event object
+	 * dispatched in both cases is an instance of FlowOperationEvent, the events
+	 * dispatched before and after an operation differ in significant ways.
+	 *
+	 * <p>Before any operation is carried out, a TextFlow object dispatches a FlowOperationEvent
+	 * with its <code>type</code> property set to <code>FlowOperationEvent.FLOW_OPERATION_BEGIN.</code>
+	 * You can determine what type of operation is about to commence by checking
+	 * the <code>operation</code> property. Events of type FLOW_OPERATION_BEGIN are
+	 * cancellable, which means that if you decide that the operation should not proceed,
+	 * you can call <code>Event.PreventDefault()</code> to cancel the operation.
+	 * If you cancel the operation, the operation is not performed and the 
+	 * FLOW_OPERATION_END event is not dispatched. You may also choose to call back into the
+	 * EditManager to do another operation before the operation that triggered the event is done. If you do
+	 * this, the operations you initiate in your event handler will be undone as a single
+	 * operation with the operation that triggered the event.</p>
+	 *
+	 * <p>If you allow the operation to proceed, TextFlow will dispatch a FlowOperationEvent
+	 * upon completion of the operation with its <code>type</code> property set to
+	 * <code>FlowOperationEvent.FLOW_OPERATION_END</code>. This event is dispatched
+	 * before Flash Player throws any errors that may have occurred as a result of the
+	 * operation. This gives you an opportunity to process the error before Flash Player
+	 * throws the error. You can access the error through the event's <code>error</code>
+	 * property. If you choose to handle the error in your event handler, you can prevent
+	 * Flash Player from throwing the error by cancelling the FLOW_OPERATION_END event
+	 * by calling <code>Event.preventDefault()</code>. You may also choose to call back into the
+	 * EditManager to do some additional operations. If you do this, the operations that result
+	 * will be undone as a unit with the operation that triggered the event.
+	 * </p> 
+	 *
+	 * @see org.apache.flex.textLayout.operations.FlowOperation
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	public class FlowOperationEvent extends Event
+	{
+		/** 
+		 * Defines the value of the <code>type</code> property of a <code>flowOperationBegin</code> event object.
+		 * Dispatched before an operation is executed.   Cancelling this event blocks the operation. 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		
+		public static const FLOW_OPERATION_BEGIN:String = "flowOperationBegin";
+		
+		/**  
+		 * Defines the value of the <code>type</code> property of a <code>flowOperationEnd</code> event object.
+		 * Dispatched after an operation completes. Any errors are stored in <code>OperationEvent.error</code>.
+	 	 * If there is an error, cancelling this event blocks the rethrow of the error.
+	 	 * Generally speaking all errors are likely to be fatal.
+	 	 * <p>Changing an operation at this time (after it has been executed) may fail.</p> 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+	 	 */
+	 	
+		public static const FLOW_OPERATION_END:String = "flowOperationEnd";
+
+		/**  
+		 * Defines the value of the <code>type</code> property of a <code>flowOperationComplete</code> event object.
+		 * Dispatched after all operations including pending and composite operations are completed, composition is finished and the display is scrolled.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		
+		public static const FLOW_OPERATION_COMPLETE:String = "flowOperationComplete";
+				
+		private var _op:FlowOperation;
+		private var _e:Error;
+		private var _level:int;
+
+		/** 
+		 * The operation that is about to begin or has just ended.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+	         * @see org.apache.flex.textLayout.operations.FlowOperation
+		 */		
+		public function get operation():FlowOperation
+		{ return _op; }	
+		public function set operation(value:FlowOperation):void
+		{ _op = value; }	
+
+		/** 
+		 * The error thrown, if any, during an operation.  
+		 * If an error occurs during an operation, a reference to the error object is attached to the 
+		 * FLOW_OPERATION_END event. This give you the opportunity to deal with the error
+		 * before Flash Player throws the error. If you cancel the event, Flash Player will not throw the error.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public function get error():Error
+		{ return _e; }
+		public function set error(value:Error):void
+		{ _e = value; }
+		
+		/** 
+		 * Operations may be merged into composite operations through nesting.  This flag describes the nesting level of the operation.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public function get level():int
+		{ return _level; }
+		public function set level(value:int):void
+		{ _level = value; }		
+		
+		/** Creates an event object that contains information about a flow operation.
+		 * @param type			The type of the event. Event listeners can access this information through the
+		 * inherited <code>type</code> property. There are two types: 
+		 * <code>FlowOperationEvent.FLOW_OPERATION_BEGIN</code>; 
+		 * <code>FlowOperationEvent.FLOW_OPERATION_END</code>.
+		 * @param bubbles 		Indicates whether an event is a bubbling event.This event does not bubble.
+		 * @param cancelable 	Indicates whether the behavior associated with the event can be prevented.
+		 * This event can be cancelled by calling the <code>Event.preventDefault()</code> method in
+		 * your event handler function.
+		 * @param operation		The FlowOperation that is about to commence or that has just ended.
+		 * @param error			Any Error generating during the operation.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public function FlowOperationEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, operation:FlowOperation = null, level:int = 0, error:Error = null)
+		{
+			_op = operation;
+			_e  = error;
+			_level = level;
+			super(type, bubbles, cancelable);
+		}
+		
+       	/** @private */
+		override public function cloneEvent():IFlexJSEvent
+		{
+			return new FlowOperationEvent(type, bubbles, cancelable, _op, _level, _e);
+		}
+		
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/FocusEvent.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/FocusEvent.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/FocusEvent.as
new file mode 100644
index 0000000..45811c9
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/FocusEvent.as
@@ -0,0 +1,28 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.events {
+
+	public class FocusEvent {
+
+		public static const FOCUS_IN:String = "focusIn";
+		public static const FOCUS_OUT:String = "focusOut";
+		public static const KEY_FOCUS_CHANGE:String = "keyFocusChange";
+		public static const MOUSE_FOCUS_CHANGE:String = "mouseFocusChange";
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/ModelChange.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/ModelChange.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/ModelChange.as
new file mode 100644
index 0000000..4f0249f
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/ModelChange.as
@@ -0,0 +1,38 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.events
+{
+	
+	/** ModelChange values.  These are various types of model change. @private */
+	public final class ModelChange
+	{
+		public static const ELEMENT_ADDED:String    = "elementAdded";
+		public static const ELEMENT_REMOVAL:String  = "elementRemoval";
+		public static const ELEMENT_MODIFIED:String = "elementModified";		
+		
+		public static const TEXTLAYOUT_FORMAT_CHANGED:String = "formatChanged";
+		
+		public static const TEXT_INSERTED:String = "textInserted";
+		public static const TEXT_DELETED:String  = "textDeleted";
+		
+		public static const STYLE_SELECTOR_CHANGED:String = "styleSelectorChanged";
+		
+		public static const USER_STYLE_CHANGED:String = "userStyleChanged";
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/ScrollEvent.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/ScrollEvent.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/ScrollEvent.as
new file mode 100644
index 0000000..6190f4d
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/ScrollEvent.as
@@ -0,0 +1,124 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.events
+{
+	
+	import org.apache.flex.events.IFlexJSEvent;
+	import org.apache.flex.events.Event;
+	
+	/**
+	 *  Represents events that are dispatched when the TextFlow does automatic scrolling.
+	 *
+	 *  @langversion 3.0
+	 *  @playerversion Flash 9
+	 *  @playerversion AIR 1.1
+	 *  @productversion Flex 3
+	 */
+	public class ScrollEvent extends TextLayoutEvent
+	{
+		//--------------------------------------------------------------------------
+		//
+		// Constructor
+		//
+		//--------------------------------------------------------------------------
+		
+		/**
+		 *  Constructor.
+		 * 
+		 *  Scroll events are dispatched when a container has scrolled. 
+		 *
+		 *  @param type The event type; indicates the action that caused the event.
+		 *
+		 *  @param bubbles Specifies whether the event can bubble
+		 *  up the display list hierarchy.
+		 *
+		 *  @param cancelable Specifies whether the behavior associated with the event
+		 *  can be prevented.
+		 *
+		 *
+		 *  @param delta The change in scroll position, expressed in pixels.
+		 *  
+		 */
+		public function ScrollEvent(type:String, bubbles:Boolean = false,
+									cancelable:Boolean = false,
+									direction:String = null, delta:Number = NaN)
+		{
+			super(type, bubbles, cancelable);
+			
+			this.direction = direction;
+			this.delta = delta;
+		}
+		
+		//--------------------------------------------------------------------------
+		//
+		//  Properties
+		//
+		//--------------------------------------------------------------------------
+		
+		//----------------------------------
+		//  delta
+		//----------------------------------
+		
+		/**
+		 *  The change in the scroll position value that resulted from 
+		 *  the scroll. The value is expressed in pixels. A positive value indicates the 
+		 *  scroll was down or to the right. A negative value indicates the scroll  
+		 * 	was up or to the left.
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 9
+		 *  @playerversion AIR 1.1
+		 *  @productversion Flex 3
+		 */
+		public var delta:Number;
+		
+		//----------------------------------
+		//  direction
+		//----------------------------------
+		
+		/**
+		 *  The direction of motion.
+		 *  The possible values are <code>ScrollEventDirection.VERTICAL</code>
+		 *  or <code>ScrollEventDirection.HORIZONTAL</code>.
+		 *
+		 *  @see org.apache.flex.textLayout.events.ScrollEventDirection
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 9
+		 *  @playerversion AIR 1.1
+		 *  @productversion Flex 3
+		 */
+		public var direction:String;
+		
+		//--------------------------------------------------------------------------
+		//
+		//  Overridden methods: Event
+		//
+		//--------------------------------------------------------------------------
+		
+		/**
+		 *  @private
+		 */
+		override public function cloneEvent():IFlexJSEvent
+		{
+			return new ScrollEvent(type, bubbles, cancelable, direction, delta);
+		}
+	}
+	
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/ScrollEventDirection.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/ScrollEventDirection.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/ScrollEventDirection.as
new file mode 100644
index 0000000..f39033d
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/ScrollEventDirection.as
@@ -0,0 +1,59 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.events
+{
+    
+    /**
+     *  Constants for the values of the <code>direction</code> property
+     *  of a ScrollEvent.
+     *
+     *  @see org.apache.flex.textLayout.events.ScrollEvent
+     * 
+     * @playerversion Flash 10.0
+     * @playerversion AIR 2.0
+     * @langversion 3.0
+     */
+    public final class ScrollEventDirection
+    {
+        //--------------------------------------------------------------------------
+        //
+        //  Class constants
+        //
+        //--------------------------------------------------------------------------
+        
+        /**
+         *  The user scrolled horizontally.
+         * 
+         * @playerversion Flash 10.0
+         * @playerversion AIR 2.0
+         * @langversion 3.0
+         */
+        public static const HORIZONTAL:String = "horizontal";
+        
+        /**
+         *  The user scrolled vertically.
+         * 
+         * @playerversion Flash 10.0
+         * @playerversion AIR 2.0
+         * @langversion 3.0
+         */
+        public static const VERTICAL:String = "vertical";
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/SelectionEvent.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/SelectionEvent.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/SelectionEvent.as
new file mode 100644
index 0000000..48c74f0
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/SelectionEvent.as
@@ -0,0 +1,107 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.events
+{
+	import org.apache.flex.events.IFlexJSEvent;
+	import org.apache.flex.events.Event;
+	import org.apache.flex.textLayout.edit.SelectionState;
+	
+	/** 
+	 * A TextFlow instance dispatches a SelectionEvent object when
+	 * an EditManager or SelectionManager changes or selects a range of text. 
+	 * For example, this event is dispatched not only when a range of text is
+	 * selected, but also when the selection changes because the
+	 * user clicks elsewhere in the text flow. Moreover, this
+	 * event is also dispatched when an EditManager changes
+	 * the text or text formatting within a range of text.
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	public class SelectionEvent extends Event
+	{
+		/** 
+		 * The SelectionEvent.SELECTION_CHANGE constant defines the value of the 
+		 * type property of the event object for a selection event. 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public static const SELECTION_CHANGE:String = "selectionChange";
+		public static const SELECT_ALL:String = "selectAll";
+		
+		private var _selectionState:SelectionState;
+		
+		/** 
+		 * Creates an event object that contains information about a flow operation.
+		 * @param type		The type of the event. Event listeners can access this information through the
+		 * inherited <code>type</code> property. There is only one type of SelectionEvent: 
+		 * <code>SelectionEvent.SELECTION_CHANGE</code>; 
+		 * @param bubbles 	Indicates whether an event is a bubbling event.This event does not bubble.
+		 * @param cancelable 	Indicates whether the behavior associated with the event can be prevented.
+		 * @param range		An object of type ElementRange that describes the range of text selected.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public function SelectionEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, selectionState:SelectionState=null)
+		{
+			_selectionState = selectionState;
+			super(type, bubbles, cancelable);
+		}
+
+		/** 
+		 * An object of type SelectionState that represents the selected range associated with this SelectionEvent.
+		 * 
+		 * <p>You can use this property, along with the ElementRange class, to create an ElementRange
+		 * instance that represents the range of selected text.
+		 * You can use the following line of code to create an instance of the
+		 * ElementRange class that represents the range of selected text
+		 * (the <code>ev</code> variable represents the event object, and the conditional operator 
+		 * is used to guard against a <code>null</code> value for the <code>selectionState</code>
+		 * property):</p>
+		 * <listing>
+		 * // Find selected element range
+		 * var range:ElementRange = ev.selectionState ?  
+		 * 	ElementRange.createElementRange(ev.selectionState.textFlow,
+		 * 	ev.selectionState.absoluteStart, ev.selectionState.absoluteEnd) : null;</listing>
+		 * 
+		 * 
+		 * 
+		 * @see org.apache.flex.textLayout.edit.ElementRange
+		 * @see org.apache.flex.textLayout.edit.SelectionState
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */		
+		public function get selectionState():SelectionState
+		{ return _selectionState; }	
+		public function set selectionState(value:SelectionState):void
+		{ _selectionState = value; }	
+		
+		
+		/** @private */
+		override public function cloneEvent():IFlexJSEvent
+		{
+			return new SelectionEvent(type, bubbles, cancelable, _selectionState);
+		}
+		
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/StatusChangeEvent.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/StatusChangeEvent.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/StatusChangeEvent.as
new file mode 100644
index 0000000..5decce8
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/StatusChangeEvent.as
@@ -0,0 +1,124 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.events
+{
+	import org.apache.flex.events.Event;
+	import org.apache.flex.events.IFlexJSEvent;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+//	import org.apache.flex.events.ErrorEvent;
+	
+	/** 
+	 * A TextFlow instance dispatches this event when the status of a FlowElement changes. 
+	 * This event can be used to detect when an inline graphic element has
+	 * completed loading. You can use your event handler to recompose the text flow
+	 * based on the presence of the newly loaded inline graphic element.
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	public class StatusChangeEvent extends Event
+	{
+	    /** 
+	     * Defines the value of the <code>type</code> property of a <code>inlineGraphicStatusChanged</code> event object.
+	     * @playerversion Flash 10
+	     * @playerversion AIR 1.5
+	     * @langversion 3.0 
+	     */
+	    public static const INLINE_GRAPHIC_STATUS_CHANGE:String = "inlineGraphicStatusChange";
+	    
+	    private var _element:IFlowElement;
+	    private var _status:String;
+//	    private var _errorEvent:ErrorEvent;
+
+		/** Creates an event object that contains information about a status change.
+		 * @param type		The type of the event. Event listeners can access this information through the
+		 * inherited <code>type</code> property. There is only one type of StatusChangeEvent: 
+		 * <code>StatusChangeEvent.INLINE_GRAPHIC_STATUS_CHANGE</code>; 
+		 * @param bubbles 	Indicates whether an event is a bubbling event.This event does not bubble.
+		 * @param cancelable 	Indicates whether the behavior associated with the event can be prevented.
+		 * This event cannot be cancelled.
+		 * @param element The FlowElement instance that has experienced a change in status.
+		 * @param newStatus The FlowElement instance's new status.
+		 * @param e The ErrorEvent object, if any, associated with the status.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 **/
+		public function StatusChangeEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, element:IFlowElement = null,status:String = null)//,errorEvent:ErrorEvent = null
+		{
+			_element = element;
+			_status = status;
+//			_errorEvent = errorEvent;
+			super(type, bubbles, cancelable);
+		}
+		
+      	/** @private */
+		override public function cloneEvent():IFlexJSEvent
+		{
+			return new StatusChangeEvent(type,bubbles,cancelable,_element,_status);//,_errorEvent
+		}
+		
+		/** 
+		 * The FlowElement instance that has experienced a change in status. 
+		 * @see org.apache.flex.textLayout.elements.FlowElement
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public function get element():IFlowElement
+		{ return _element; }		
+		public function set element(value:IFlowElement):void
+		{ _element = value; }		
+		
+		/**
+		 * The FlowElement's new status. The possible values of this property are
+		 * defined by the InlineGraphicElementStatus class. There are five static constants
+		 * available in the InlineGraphicElementStatus class:
+		 * <ul>
+		 *   <li>ERROR : String = "error". An error occurred during loading of a referenced graphic.</li>
+		 *   <li>LOADING : String = "loading". Load has been initiated (but not completed) on a graphic element that is a URL.</li>
+		 *   <li>LOAD_PENDING : String = "loadPending". Graphic element is an URL that has not been loaded.</li>
+		 *   <li>READY : String = "ready". Graphic is completely loaded and properly sized.</li>
+		 *   <li>SIZE_PENDING : String = "sizePending". Graphic element with auto or percentage width/height has completed loading but has not been recomposed.</li>
+		 * </ul>
+		 *
+		 * @see org.apache.flex.textLayout.elements.InlineGraphicElementStatus
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public function get status():String
+		{ return _status; }
+		public function set status(value:String):void
+		{ _status = value; }
+		
+		/** 
+		 * The ErrorEvent object that was dispatched as a result of the status change. 
+		 * @see org.apache.flex.events.ErrorEvent
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+//		public function get errorEvent():ErrorEvent
+//		{ return _errorEvent; }
+//		public function set errorEvent(value:ErrorEvent):void
+//		{ _errorEvent = value; }
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/TextLayoutEvent.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/TextLayoutEvent.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/TextLayoutEvent.as
new file mode 100644
index 0000000..cfd5c09
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/TextLayoutEvent.as
@@ -0,0 +1,72 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.events
+{
+	import org.apache.flex.events.IFlexJSEvent;
+	import org.apache.flex.events.Event;
+	
+	/**
+	 * A TextLayoutEvent instance represents an event, such as the 
+	 * <code>TextLayoutEvent.SCROLL</code> event, that does not require
+	 * custom properties. 
+	 * <p>A scroll event is represented by a TextLayoutEvent instance with its 
+	 * <code>type</code> property set to <code>TextLayoutEvent.SCROLL</code>.
+	 * A class specifically for scroll events is not necessary because there are
+	 * no custom properties for a scroll event, as there are for the other
+	 * events that have specific event classes.
+	 * If a new text layout event is needed, and the event does not require
+	 * custom properties, the new event will also be represented by a
+	 * TextLayoutEvent object, but with its <code>type</code> property
+	 * set to a new static constant.
+	 * </p>
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	public class TextLayoutEvent extends Event
+	{
+	    /**
+	     *  The <code>TextLayoutEvent.SCROLL</code> constant defines the value of the
+	     *  <code>type</code> property of the event object for a <code>scroll</code> event.
+	     * @playerversion Flash 10
+	     * @playerversion AIR 1.5
+	     * @langversion 3.0
+	     */
+	    public static const SCROLL:String = "scroll";
+	    
+		/**
+		 *  The TextLayoutEvent class represents the event object passed to
+		 *  the event listener for many Text Layout events.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function TextLayoutEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false)
+		{
+			super(type, bubbles, cancelable);
+		}
+		
+        /** @private */
+        override public function cloneEvent():IFlexJSEvent
+        {
+        	return new TextLayoutEvent(type, bubbles, cancelable);
+        }		
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/UpdateCompleteEvent.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/UpdateCompleteEvent.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/UpdateCompleteEvent.as
new file mode 100644
index 0000000..3607206
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/UpdateCompleteEvent.as
@@ -0,0 +1,106 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.events
+{
+	import org.apache.flex.events.IFlexJSEvent;
+	import org.apache.flex.events.Event;
+	
+	import org.apache.flex.textLayout.container.IContainerController;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+
+	/** 
+	 * A TextFlow instance dispatches this event after any of its containers completes 
+	 * an update. Each text container has two states: composition and display. This 
+	 * event notifies you when the display phase has ended. This provides an 
+	 * opportunity to make any necessary changes to the container when it is ready to
+	 * be displayed, but hasn't yet been painted to the screen.
+	 * 
+	 * @internal Note: the DamageEvent_example class contains a good example of 
+	 * using the UpdateCompleteEvent, so I have included it as the class example
+	 * instead of creating a new example. I've updated the description of the
+	 * DamageEvent_example file to include prominent mention of the UpdateCompleteEvent.
+	 *
+	 * @see org.apache.flex.textLayout.elements.TextFlow 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	public class UpdateCompleteEvent extends Event
+	{
+	    /** 
+	     * Defines the value of the <code>type</code> property of an <code>UpdateCompleteEvent</code> object 
+	     * @playerversion Flash 10
+	     * @playerversion AIR 1.5
+	     * @langversion 3.0 
+	     */
+	    public static const UPDATE_COMPLETE:String = "updateComplete";
+	    
+	    /** @private */
+	    private var _controller:IContainerController;
+	    /** @private */
+		private var _textFlow:ITextFlow;
+		
+		/** Constructor
+		 * @param type event type - use the static property UPDATE_COMPLETE.
+		 * @param bubbles Indicates whether an event is a bubbling event. This event does not bubble.
+		 * @param cancelable Indicates whether the behavior associated with the event can be prevented.
+		 * This event cannot be cancelled.
+		 * @param controller The ContainerController whose container was updated
+		 * @param textFlow The TextFlow which was updated
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 **/
+		public function UpdateCompleteEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, textFlow:ITextFlow =  null, controller:IContainerController=null)
+		{
+			super(type, bubbles, cancelable);
+			this.controller = controller;
+			_textFlow = textFlow;
+		}
+
+      	/** @private */
+		override public function cloneEvent():IFlexJSEvent
+		{
+			return new UpdateCompleteEvent(type, bubbles, cancelable, _textFlow, _controller);
+		}
+
+		/** 
+		 * The controller of the container being updated
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 		 
+		 */
+		public function get controller():IContainerController
+		{ return _controller; }
+		public function set controller(c:IContainerController):void
+		{ _controller = c; }
+		
+		
+		/**
+		 * TextFlow which has been updated. 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public  function get textFlow():ITextFlow
+		{ return _textFlow; }
+		public  function set textFlow(value:ITextFlow):void
+		{ _textFlow = value; }
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/INumberLineFactory.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/INumberLineFactory.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/INumberLineFactory.as
new file mode 100644
index 0000000..3d619a1
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/INumberLineFactory.as
@@ -0,0 +1,39 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.factory
+{
+	import org.apache.flex.geom.Rectangle;
+	import org.apache.flex.textLayout.compose.ISWFContext;
+	import org.apache.flex.textLayout.elements.IBackgroundManager;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	public interface INumberLineFactory extends IStringTextLineFactory
+	{
+		function set compositionBounds(compositionBounds:Rectangle):void;
+		function set swfContext(swfContext:ISWFContext):void;
+		function set listStylePosition(listStylePosition:String):void;
+		function get listStylePosition():String;
+		function set paragraphFormat(paragraphFormat:ITextLayoutFormat):void;
+		function set textFlowFormat(textFlowFormat:ITextLayoutFormat):void;
+		function set markerFormat(val:ITextLayoutFormat):void;
+		function set text(text:String):void;
+		function createTextLines(arg:Function):void;
+		function clearBackgroundManager():void;
+		function get backgroundManager():IBackgroundManager;
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/IStringTextLineFactory.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/IStringTextLineFactory.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/IStringTextLineFactory.as
new file mode 100644
index 0000000..5f6c41d
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/IStringTextLineFactory.as
@@ -0,0 +1,24 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.factory
+{
+	public interface IStringTextLineFactory extends ITextLineFactory
+	{
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/ITLFFactory.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/ITLFFactory.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/ITLFFactory.as
new file mode 100644
index 0000000..4b204b5
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/ITLFFactory.as
@@ -0,0 +1,30 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.factory {
+	import org.apache.flex.core.IParentIUIBase;
+	import org.apache.flex.graphics.ICompoundGraphic;
+	import org.apache.flex.graphics.IRect;
+	import org.apache.flex.text.engine.ITextFactory;
+	public interface ITLFFactory {
+		function get textFactory():ITextFactory;
+		function getRect():IRect;
+		function getCompoundGraphic():ICompoundGraphic;
+		function getContainer():IParentIUIBase;		
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/ITextLineFactory.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/ITextLineFactory.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/ITextLineFactory.as
new file mode 100644
index 0000000..854db9c
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/factory/ITextLineFactory.as
@@ -0,0 +1,24 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.factory
+{
+	public interface ITextLineFactory
+	{
+	}
+}
\ No newline at end of file


[26/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/EditManager.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/EditManager.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/EditManager.as
new file mode 100644
index 0000000..2831b32
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/EditManager.as
@@ -0,0 +1,2050 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.edit
+{
+	import org.apache.flex.core.IUIBase;
+	import org.apache.flex.events.Event;
+	import org.apache.flex.events.KeyboardEvent;
+	import org.apache.flex.events.MouseEvent;
+	import org.apache.flex.events.utils.EditingKeys;
+	import org.apache.flex.events.utils.KeyConverter;
+	import org.apache.flex.events.utils.WhitespaceKeys;
+	import org.apache.flex.reflection.getQualifiedClassName;
+	import org.apache.flex.text.events.IMEEvent;
+	import org.apache.flex.text.events.TextEvent;
+	import org.apache.flex.textLayout.compose.IFlowComposer;
+	import org.apache.flex.textLayout.container.IContainerController;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.elements.GlobalSettings;
+	import org.apache.flex.textLayout.elements.IDivElement;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	import org.apache.flex.textLayout.elements.IFlowGroupElement;
+	import org.apache.flex.textLayout.elements.IFlowLeafElement;
+	import org.apache.flex.textLayout.elements.IInlineGraphicElement;
+	import org.apache.flex.textLayout.elements.ILinkElement;
+	import org.apache.flex.textLayout.elements.IListElement;
+	import org.apache.flex.textLayout.elements.IListItemElement;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.ISubParagraphGroupElement;
+	import org.apache.flex.textLayout.elements.ITCYElement;
+	import org.apache.flex.textLayout.elements.ITableCellElement;
+	import org.apache.flex.textLayout.elements.ITableElement;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.textLayout.events.EditEvent;
+	import org.apache.flex.textLayout.events.FlowOperationEvent;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+	import org.apache.flex.textLayout.operations.ApplyElementIDOperation;
+	import org.apache.flex.textLayout.operations.ApplyElementTypeNameOperation;
+	import org.apache.flex.textLayout.operations.ApplyFormatOperation;
+	import org.apache.flex.textLayout.operations.ApplyFormatToElementOperation;
+	import org.apache.flex.textLayout.operations.ApplyLinkOperation;
+	import org.apache.flex.textLayout.operations.ApplyTCYOperation;
+	import org.apache.flex.textLayout.operations.ClearFormatOnElementOperation;
+	import org.apache.flex.textLayout.operations.ClearFormatOperation;
+	import org.apache.flex.textLayout.operations.CompositeOperation;
+	import org.apache.flex.textLayout.operations.CreateDivOperation;
+	import org.apache.flex.textLayout.operations.CreateListOperation;
+	import org.apache.flex.textLayout.operations.CreateSubParagraphGroupOperation;
+	import org.apache.flex.textLayout.operations.CutOperation;
+	import org.apache.flex.textLayout.operations.DeleteTextOperation;
+	import org.apache.flex.textLayout.operations.FlowOperation;
+	import org.apache.flex.textLayout.operations.InsertInlineGraphicOperation;
+	import org.apache.flex.textLayout.operations.InsertTableElementOperation;
+	import org.apache.flex.textLayout.operations.InsertTextOperation;
+	import org.apache.flex.textLayout.operations.ModifyInlineGraphicOperation;
+	import org.apache.flex.textLayout.operations.MoveChildrenOperation;
+	import org.apache.flex.textLayout.operations.PasteOperation;
+	import org.apache.flex.textLayout.operations.RedoOperation;
+	import org.apache.flex.textLayout.operations.SplitElementOperation;
+	import org.apache.flex.textLayout.operations.SplitParagraphOperation;
+	import org.apache.flex.textLayout.operations.UndoOperation;
+	import org.apache.flex.textLayout.utils.CharacterUtil;
+	import org.apache.flex.textLayout.utils.NavigationUtil;
+	import org.apache.flex.utils.AnimationUtil;
+	import org.apache.flex.utils.undo.IOperation;
+	import org.apache.flex.utils.undo.IUndoManager;
+//	import flash.errors.IllegalOperationError;
+		
+
+	
+	/** 
+	 * The EditManager class manages editing changes to a TextFlow. 
+	 * 
+	 * <p>To enable text flow editing, assign an EditManager object to the <code>interactionManager</code> 
+	 * property of the TextFlow object. The edit manager handles changes to the text (such as insertions, 
+	 * deletions, and format changes). Changes are reversible if the edit manager has an undo manager. The edit
+	 * manager triggers the recomposition and display of the text flow, as necessary.</p>
+	 *
+	 * <p>The EditManager class supports the following keyboard shortcuts:</p>
+	 * 
+	 * <table class="innertable" width="100%">
+	 *  <tr><th>Keys</th><th>Result</th></tr>
+	 *  <tr><td>ctrl-z</td><td>undo</td></tr>					
+	 * 	<tr><td>ctrl-y</td><td>redo</td></tr>					
+	 * 	<tr><td>ctrl-backspace</td><td>deletePreviousWord</td></tr>					
+	 * 	<tr><td>ctrl-delete</td><td>deleteNextWord</td></tr>					
+	 * 	<tr><td>alt+delete</td><td>deleteNextWord</td></tr>					
+	 * 	<tr><td>ctrl+alt-delete</td><td>deleteNextWord</td></tr>					
+	 * 	<tr><td>ctrl-shift-hyphen</td><td>insert discretionary hyphen</td></tr>					
+	 * 	<tr><td>ctrl+backspace</td><td>deletePreviousWord</td></tr>					
+	 * 	<tr><td>alt+backspace</td><td>deletePreviousWord</td></tr>					
+	 * 	<tr><td>ctrl+alt-backspace</td><td>deletePreviousWord</td></tr>					
+	 * 	<tr><td>INSERT</td><td>toggles overWriteMode</td></tr>					
+	 * 	<tr><td>backspace</td><td>deletePreviousCharacter</td></tr>					
+	 * 	<tr><td>ENTER</td><td>if textFlow.configuration.manageEnterKey in a list it creates a new list item, otherwise creates a new paragraph</td></tr>					
+	 * 	<tr><td>shift-ENTER</td><td>if textFlow.configuration.manageEnterKey creates a new paragraph</td></tr>					
+	 * 	<tr><td>TAB</td><td>if textFlow.configuration.manageTabKey in a list it creates nested list, otherwise inserts a TAB or overwrites next character with a TAB</td></tr>    
+	 * 	<tr><td>shift-TAB</td><td>if textFlow.configuration.manageTabKey in the first item of a list it moves the item out of the list (promotes it)</td></tr>    
+	 * </table>
+	 *
+	 * <p><strong>Note:</strong> The following keys do not work on Windows: alt-backspace, alt-delete, ctrl+alt-backspace,
+	 * and ctrl+alt-delete. These keys do not generate an event for the runtime.</p>						
+ 	 * 
+ 	 * @see org.apache.flex.textLayout.elements.TextFlow
+ 	 * @see flashx.undo.UndoManager
+	 *
+	 *  examples\EditManager_example.as -noswf
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+ 	 * @langversion 3.0
+	 */			
+	public class EditManager extends SelectionManager implements IEditManager
+	{
+		static public var handleShiftAsSoftReturn:Boolean = true;
+		 /**
+		 *  To minimize expensive recompositions during fast typing, inserts
+		 *  don't necessarily take place immediately. An insert operation that
+		 *  hasn't yet executed is held here.
+		 */
+		private var pendingInsert:InsertTextOperation;
+		
+		/* 
+		 * The object that has the ENTER_FRAME event listener attached to perform pending inserts.
+		 */
+//		private var enterFrameListener:DisplayObjectContainer;
+
+		/* True if updates get handled on enter_frame, and not immediately. */
+		private var _delayUpdates:Boolean = false;
+		
+		/* True if some operations (e.g., handling of text events) can be delayed to next enterFrame by default. False for immediate handling */
+		private var _allowDelayedOperations:Boolean = true;
+		
+		/*
+		 * The object that has the ENTER_FRAME event listener attached to perform pending updates.
+		 */
+		private var redrawListener:IUIBase;
+
+		/*
+		 *  Some operations can be undone & redone. The undoManager keeps track
+		 *  of the operations that have been done or undone so that they can be undone or
+		 *  redone.  I'm not sure if only text operations can be undone. If so, the undoManager
+		 *  should probably be moved to EditManager.
+		 */
+		private var _undoManager:IUndoManager;
+		
+		private var _imeSession:IMEClient;
+		private var _imeOperationInProgress:Boolean;
+		
+		/** 
+		 * Indicates whether overwrite mode is on or off.
+		 * 
+		 * <p>If <code>true</code>, then a keystroke overwrites the character following the cursor.
+		 * If <code>false</code>, then a keystroke is inserted at the cursor location.</p> 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		*/		
+		public static var overwriteMode:Boolean = false;
+		
+		/** 
+		 * Creates an EditManager object.
+		 * 
+		 * <p>Assign an EditManager object to the <code>interactionManager</code> property
+		 * of a text flow to enable editing of that text flow. </p>
+		 *
+		 * <p>To enable support for undoing and redoing changes, pass an 
+		 * IUndoManager instance to the EditManager constructor. You can use
+		 * the <code>flashx.undo.UndoManager</code> class
+		 * or create a custom IUndoManager instance. Use a custom IUndoManager instance
+		 * to integrate Text Layout Framework changes with an existing
+		 * undo manager that is not an instance of the UndoManager class.
+		 * To create a custom IUndoManager instance, ensure that the class
+		 * you use to define the undo manager 
+		 * implements the IUndoManager interface.</p>
+		 * 
+		 * 
+		 * @param undo	The UndoManager for the application
+		 * 
+		 * @see org.apache.flex.textLayout.elements.TextFlow#interactionManager
+		 * @see flashx.undo.IUndoManager
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */
+		public function EditManager(undoManager:IUndoManager = null)
+		{
+			super();
+			_undoManager = undoManager;
+		}
+
+		/**  
+		 * The IUndoManager assigned to this edit manager.
+		 * 
+		 * <p>To allow edits to be undone (and redone), pass an IUndoManager instance to the EditManager
+		 * constructor. The undo manager maintains a stack of operations that have been executed, and it can 
+		 * undo or redo individual operations. </p>
+		 * 
+		 * <p><b>Note:</b> If the TextFlow is modified directly (not via
+		 * calls to the EditManager, but directly via calls to the managed FlowElement objects), then the EditManager
+		 * clears the undo stack to prevent the stack from getting out of sync with the current state.</p>
+		 * 
+	 	 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */	
+		public function get undoManager():IUndoManager
+		{
+			return _undoManager;
+		}
+		
+		// Backdoor provided so that IMEClient can temporarily use an undo manager to maintain the IME session state.
+		/** @private */
+		public function setUndoManager(undoManager:IUndoManager):void
+		{
+			_undoManager = undoManager;
+		}
+		
+		/** @private */
+		override public function editHandler(event:Event):void
+		{
+			if (event.isDefaultPrevented())
+				return;
+
+			super.editHandler(event);
+			switch (event.type)
+			{
+				case EditEvent.CUT: 
+				case EditEvent.CLEAR:
+					if (activePosition != anchorPosition)
+					{
+						if (event.type == EditEvent.CUT)
+							TextClipboard.setContents(cutTextScrap());
+						else
+							deleteText(null);
+						event.preventDefault();
+					}
+					break;
+				case EditEvent.PASTE:
+					pasteTextScrap(TextClipboard.getContents());
+					event.preventDefault();
+					break;
+			}
+		}
+
+		// ///////////////////////////////////
+		// keyboard methods 
+		// ///////////////////////////////////
+		
+		/**
+		 * @private
+		 * @flexjsignorecoercion org.apache.flex.textLayout.element.IListItemElement
+		 */
+		public override function keyDownHandler(event:KeyboardEvent):void
+		{
+			var listItem:IListItemElement;
+			var operationState:SelectionState;
+			
+			if (!hasSelection() || event.isDefaultPrevented())
+				return;
+			
+			if (redrawListener)		// pending redraw; handle this before anything else so TextLines on screen will be up to date
+				updateAllControllers();
+			
+			super.keyDownHandler(event);
+			
+			if (event.ctrlKey)
+			{
+				// The player subsequently sends a text input event (which should be ignored) as listed below:
+				// CTRL/CMD+z: Only on Mac when using a pre-Argo player version
+				// CTRL/CMD+y: On all platforms (the exact char code for the text input event is platform dependent) 
+				if (!event.altKey)
+				{
+					if (_imeSession != null && ((event.code == "KeyZ") || (event.code == "KeyY")))
+						_imeSession.compositionAbandoned();		// must be done before undo or redo start b/c IME session uses undo also for its own rollback
+					// do Operation will also cancel the session.
+					
+					switch(event.code)
+					{
+						case "KeyZ":	// small z
+							/* pre-Argo and on the mac then ignoreNextTextEvent */ 
+							// if (!Configuration.versionIsAtLeast(10,1) && (Capabilities.os.search("Mac OS") > -1)) 
+								ignoreNextTextEvent = true;
+							if(event.shiftKey){
+								redo();
+								event.preventDefault();
+
+							} else {
+								undo();
+								event.preventDefault();
+							}
+							break;
+						case "KeyZ":	// small y
+							ignoreNextTextEvent = true;
+							redo();
+							event.preventDefault();
+							break;
+						case EditingKeys.BACKSPACE:
+							if (_imeSession)
+								_imeSession.compositionAbandoned();
+							deletePreviousWord();
+							event.preventDefault();
+							break;
+					}
+					if (event.code == EditingKeys.DELETE)
+					{
+						if (_imeSession)
+							_imeSession.compositionAbandoned();
+						deleteNextWord();
+						event.preventDefault();
+					}
+					
+					if (event.shiftKey)
+					{
+						// detect ctrl-shift-"-" (cnd-shift-"-" on mac) and insert a DH
+						if (event.code == "Minus")
+						{
+							if (_imeSession)
+								_imeSession.compositionAbandoned();
+							
+							//a discretionary hyphen is being inserted. 
+							var discretionaryHyphenString:String = String.fromCharCode(0x000000AD);
+							overwriteMode ? overwriteText(discretionaryHyphenString) : insertText(discretionaryHyphenString);
+							event.preventDefault();
+						}
+					}
+				}
+			} 
+			else if (event.altKey)
+			{
+				if (event.code == EditingKeys.BACKSPACE)
+				{
+					deletePreviousWord();
+					event.preventDefault();
+				}
+				else if (event.code == EditingKeys.DELETE)
+				{
+					deleteNextWord();
+					event.preventDefault();
+				}
+			}
+			// not ctrl key or alt key
+			else if (event.code == EditingKeys.DELETE) //del
+			{
+				deleteNextCharacter();
+				event.preventDefault();
+			}
+			else if (event.code == EditingKeys.INSERT) //insert
+			{
+				overwriteMode = !overwriteMode;				
+				event.preventDefault();
+			}
+			else switch(event.code) {
+				case EditingKeys.BACKSPACE:
+					deletePreviousCharacter();
+					event.preventDefault();
+					break;
+				case WhitespaceKeys.ENTER:
+					if (textFlow.configuration.manageEnterKey) 
+					{
+						var firstLeaf:IFlowLeafElement = textFlow.findLeaf(absoluteStart);
+						listItem = firstLeaf.getParentByType("ListItemElement") as IListItemElement;
+						// if the listitem has a IListElement child then treat this as a regular Paragraph
+						if (listItem && firstLeaf.getParentByType("ListElement") != listItem.getParentByType("ListElement"))
+							listItem = null;
+						
+						// inside a list shift-enter splits a paragraph and enter splits the listitem
+						if (listItem && !event.shiftKey)
+						{
+							// if on last item of list and it's empty, remove it and put cursor on a new para immediatly following the list (new para should be wrapped in a new list item if parent of list is another list).
+							if(listItem.textLength == 1 && listItem.parent.getChildIndex(listItem) == listItem.parent.numChildren - 1)
+							{
+								operationState = defaultOperationState();
+								if (!operationState)
+									return;
+								
+								doOperation(new MoveChildrenOperation(operationState, listItem.parent, listItem.parent.getChildIndex(listItem), 1, listItem.parent.parent, listItem.parent.parent.getChildIndex(listItem.parent) + 1));
+							}
+							else
+							{
+								splitElement(listItem);
+								// push cursor past the marker
+								selectRange(absoluteStart+1,absoluteStart+1);
+								refreshSelection();
+							}
+						}
+						else if(event.shiftKey &&
+							((!listItem && textFlow.configuration.shiftEnterLevel > 0) ||
+							textFlow.configuration.shiftEnterLevel > 1)
+						)
+						{
+							overwriteMode ? overwriteText("\u2028") : insertText("\u2028");
+						}
+						else
+							splitParagraph();
+						event.preventDefault();
+						event.stopImmediatePropagation();
+					}
+					break;
+				case WhitespaceKeys.TAB:
+					if (textFlow.configuration.manageTabKey) 
+					{
+						listItem  = textFlow.findLeaf(absoluteStart).getParentByType("ListItemElement") as IListItemElement;
+						if (listItem && listItem.getAbsoluteStart() == absoluteStart)
+						{
+							operationState = defaultOperationState();
+							if (!operationState)
+								return;
+							
+							if(event.shiftKey)
+							{
+								// unindent by moving list element(s) out of parent into grandparent
+								
+								// first make sure there is a grandparent
+								if(listItem.parent.parent is IListElement && listItem.parent.getChildIndex(listItem) == 0)
+								{
+									var source:IFlowGroupElement;
+									var target:IFlowGroupElement;
+									var numElements:int;
+									var sourceIndex:int;
+									var targetIndex:int;
+									
+									{
+										source = listItem.parent;
+										target = listItem.parent.parent;
+										numElements = listItem.parent.numChildren;
+										sourceIndex = 0;
+										targetIndex = listItem.parent.parent.getChildIndex(listItem.parent);
+									}
+									doOperation(new MoveChildrenOperation(operationState, source, sourceIndex, numElements, target, targetIndex));
+								}
+							}
+							else
+							{
+								// create new list from list element(s)
+								var element:IFlowGroupElement = listItem;
+								if(listItem.parent.getChildIndex(listItem) == 0) 
+									element = listItem.parent;
+								
+								doOperation(new CreateListOperation(new SelectionState(textFlow, element.getAbsoluteStart(), element.getAbsoluteStart() + element.textLength), listItem.parent));
+							}
+						}
+						else if (textFlow.nestedInTable()) {
+							var cell:ITableCellElement;
+							
+							if (event.shiftKey) {
+								cell = (textFlow.parentElement as ITableCellElement).getPreviousCell();
+							}
+							else {
+								cell = (textFlow.parentElement as ITableCellElement).getNextCell();
+							}
+							
+							// select next cell in table
+							if (cell && cell.textFlow && cell.textFlow.interactionManager is EditManager) {
+								//cell.textFlow.interactionManager.selectLastPosition();
+								deselect();
+								cell.textFlow.interactionManager.selectAll();
+								cell.textFlow.interactionManager.setFocus();
+							}
+						}
+						else
+						{
+							var str:String = KeyConverter.convertKey(event.key);
+							overwriteMode ? overwriteText(str) : insertText(str);
+						}
+						event.preventDefault();
+					}
+					break;
+			}
+		}
+		
+		/** @private */
+		public override function keyUpHandler(event:KeyboardEvent):void
+		{
+			if (!hasSelection() || event.isDefaultPrevented())
+				return;
+				
+			super.keyUpHandler(event);
+			
+			if ((textFlow.configuration.manageEnterKey && event.code == WhitespaceKeys.ENTER) || (textFlow.configuration.manageTabKey && event.code == WhitespaceKeys.TAB)) {
+				event.stopImmediatePropagation();
+			}
+		}
+		
+		/** @private */	
+		public override function keyFocusChangeHandler(event:Event):void
+		{
+			if (textFlow.configuration.manageTabKey) 
+				event.preventDefault();
+		}
+	
+		/** @private */
+		public override function mouseDownHandler(event:MouseEvent):void
+		{
+			if (redrawListener)
+				updateAllControllers();
+			super.mouseDownHandler(event);
+		}
+		
+		/** @private */
+		public override function textInputHandler(event:TextEvent):void
+		{
+			if (!ignoreNextTextEvent)
+			{
+				var charCode:int = event.text.charCodeAt(0);
+				// only if its a space or larger - ignore control characters here
+				if (charCode >=  32)
+					overwriteMode ? overwriteText(event.text) : insertText(event.text);
+			}
+			ignoreNextTextEvent = false;
+			// if the manager is nested inside another one, do not handle it again in the outer one
+			if(superManager)
+				event.preventDefault();
+				
+		}
+		
+		/** @private */
+		override public function focusOutHandler(event:Event):void
+		{
+			super.focusOutHandler(event);
+			if (_imeSession && selectionFormatState != SelectionFormatState.FOCUSED)
+				_imeSession.compositionAbandoned();
+		}
+		
+		/** @private */
+		override public function deactivateHandler(event:Event):void
+		{
+			super.deactivateHandler(event);
+			if (_imeSession)
+				_imeSession.compositionAbandoned();
+		}
+		
+		/** @private */
+		override public function imeStartCompositionHandler(event:IMEEvent):void
+		{
+			CONFIG::debug{ assert(!_imeSession, "IME session already in progress: IME not reentrant!"); }
+		//	CONFIG::debug { Debugging.traceOut("imeStartComposition event"); }
+
+			// any pending operations must be executed first, to
+			// preserve operation order.
+			flushPendingOperations();
+			
+			// Coded to avoid dependency on Argo (10.1). 
+			if (!(event["imeClient"]))
+			{
+				_imeSession = new IMEClient(this);
+				_imeOperationInProgress = false;
+				event["imeClient"] = _imeSession;
+			}
+		}
+		
+		/** @private */
+		override public function setFocus():void
+		{
+			var flowComposer:IFlowComposer = textFlow ? textFlow.flowComposer : null;
+			if (_imeSession && flowComposer && flowComposer.numControllers > 1)
+			{
+				// container with the ime start position gets the key focus
+				_imeSession.setFocus();
+
+				setSelectionFormatState(SelectionFormatState.FOCUSED);
+			}
+			else
+				super.setFocus();
+			
+			/* CONFIG::debug
+			{
+				if (textFlow.flowComposer.getControllerAt(0).container.stage)
+				{
+					var focusDI:DisplayObject = textFlow.flowComposer.getControllerAt(0).container.stage.focus;
+					trace("set focus to ", focusDI.hasOwnProperty("name") ? focusDI["name"] : focusDI.toString());
+				}
+			} */
+		}
+		/** @private */		
+		public function endIMESession():void
+		{
+			_imeSession = null;
+			var flowComposer:IFlowComposer = textFlow ? textFlow.flowComposer : null;
+			if (flowComposer && flowComposer.numControllers > 1)
+				setFocus();
+		}
+		/** @private */
+		public function beginIMEOperation():void
+		{
+			_imeOperationInProgress = true;
+			beginCompositeOperation();
+		}
+		/** @private */
+		public function endIMEOperation():void
+		{
+			endCompositeOperation();
+			_imeOperationInProgress = false;
+		}
+
+		/** @private We track the nesting level of the doOperation, because in finalize we need to know if
+		we are at the outermost level and need to push the operation on the undo stack and redraw
+		the screen, or if we're in a nested level and need to append the operation to the next
+		level up. */
+		public var captureLevel:int = 0;
+
+		/** 
+		  * @copy IEditManager#doOperation()
+		  * 
+		  * 
+		  * @playerversion Flash 10
+		  * @playerversion AIR 1.5
+ 	 	  * @langversion 3.0
+		  */
+		public override function doOperation(operation:FlowOperation):void
+		{
+			CONFIG::debug { assert(operation.textFlow == this.textFlow,"Operation from a different TextFlow"); }
+			
+			// If we get any operation during an IME session that is not owned by the session, we cancel the IME
+			if (_imeSession && !_imeOperationInProgress)
+				_imeSession.compositionAbandoned();
+			
+			// any pending operations must be executed first, to
+			// preserve operation order.
+			flushPendingOperations();
+			
+			try
+			{
+				captureLevel++;
+				operation = doInternal(operation);
+			}
+			catch(e:Error)
+			{
+				captureLevel--;
+				throw(e);
+			}
+			captureLevel--;
+			
+			if (operation)			// don't finalize if operation was cancelled
+				finalizeDo(operation);
+		}
+
+		private function finalizeDo(op:FlowOperation):void
+		{
+			// Handle operation if we're in a beginCompositeOperation/endCompositeOperation context
+			// In this case any nested commands we do will get added to the composite operation when 
+			// they're done instead of added to the undo stack.
+			var parentOperation:CompositeOperation;
+			if (parentStack && parentStack.length > 0)
+			{
+				var parent:Object = parentStack[parentStack.length - 1];
+				if (parent.captureLevel == captureLevel)
+					parentOperation = parent.operation as CompositeOperation;
+			}
+
+	//		CONFIG::debug { assert(captureLevel == 0 || parentOperation != null, "missing parent for nested operation"); }
+			
+			if (parentOperation)
+				parentOperation.addOperation(op);
+			
+			else if (captureLevel == 0)
+			{
+				captureOperations.length = 0; 
+				if (_undoManager)
+				{
+					if (_undoManager.canUndo() && allowOperationMerge)
+					{
+						var lastOp:FlowOperation = _undoManager.peekUndo() as FlowOperation;
+						if (lastOp)
+						{
+							// Try to merge the last operation on the stack with the current
+							// operation. This may modify lastOp, or return a new operation
+							var combinedOp:FlowOperation = lastOp.merge(op);
+							if (combinedOp)
+							{
+								CONFIG::debug { assert(combinedOp.endGeneration == textFlow.generation,"Who did what?"); }
+								CONFIG::debug { assert(combinedOp.canUndo() && combinedOp.endGeneration == op.endGeneration,"Bad operation merge in EditManager"); }
+								_undoManager.popUndo();
+								op = combinedOp;
+							}
+						}
+					}
+					if (op.canUndo())
+						_undoManager.pushUndo(op);
+					allowOperationMerge = true;
+
+					// following operations are no longer redoable
+					_undoManager.clearRedo();
+				}
+
+				handleUpdate();			
+
+				if (!_imeSession)
+				{	
+					var opEvent:FlowOperationEvent = new FlowOperationEvent(FlowOperationEvent.FLOW_OPERATION_COMPLETE,false,false,op,0,null);
+					textFlow.dispatchEvent(opEvent);
+				}
+			}	
+		}
+		
+		private var captureOperations:Array = [];
+
+		/** Internal guts of a dooperation - Execute a FlowOperation.  This function proceeds in steps.
+		  * <p>Step 2. Send a canceallable OperationEvent.  If cancelled this method returns immediately.</p>
+		  * If it is not cancelled, the listener may "do" other operations by calling back into the EditManager. This will result
+		  * in a nested call to do which will post additional commands to the captureOperations array.
+		  * <p>Step 3. Execute the operation.  The operation returns true or false.  false indicates no changes were made.</p>
+		  * <p>Step 7. Send a OperationEvent. </p>
+		  * The listener may "do" other operations by calling back into the EditManager. This will result
+		  * in a nested call to do which will post additional commands to the captureOperations array.
+		  * <p>Exception handling.  If the operation throws the exception is caught and the error is attached to the event dispatched
+		  * at step 7.  If the event is not cancelled the error is rethrown.</p>
+		  */
+		private function doInternal(op:FlowOperation):FlowOperation
+		{
+			CONFIG::debug { assert(op.textFlow == this.textFlow,"Operation from a different TextFlow"); }
+			
+			var captureStart:int = captureOperations.length;
+			var success:Boolean = false;
+			var opEvent:FlowOperationEvent;
+			
+			// tell any listeners about the operation
+			if (!_imeSession)
+			{
+				opEvent = new FlowOperationEvent(FlowOperationEvent.FLOW_OPERATION_BEGIN,false,true,op,captureLevel-1,null);
+				textFlow.dispatchEvent(opEvent);
+				if (opEvent.isDefaultPrevented())
+					return null;
+				// user may replace the operation - TODO: WHAT IF SWITCH TO UNDO/REDO????
+				op = opEvent.operation;
+				if ((op is UndoOperation) || (op is RedoOperation))
+					throw new Error(GlobalSettings.resourceStringFunction("illegalOperation",[ getQualifiedClassName(op) ]));
+			}
+				
+			var opError:Error = null;
+			try
+			{
+				// begin this op after pending ops are flushed
+				CONFIG::debug 
+				{ 
+					if (captureLevel <= 1)
+						debugCheckTextFlow(); 
+				}
+				
+				// null return implies no operation was done - just discard it
+				var beforeGeneration:uint = textFlow.generation;
+				op.setGenerations(beforeGeneration,0);
+	
+				captureOperations.push(op);
+				success = op.doOperation();
+				if (success)		// operation succeeded
+				{
+					textFlow.normalize();   //force normalization at this point. Don't compose unless the captureLevel is 0
+					
+					// This has to be done after the normalize, because normalize increments the generation number
+					op.setGenerations(beforeGeneration,textFlow.generation);					
+				} 
+				else 
+				{
+					var index:int = captureOperations.indexOf(op);
+					if (index >= 0) 
+						captureOperations.splice(index, 1);
+				}
+			}
+			catch(e:Error)
+			{
+				opError = e;
+			}
+			
+			// operation completed - send event whether it succeeded or not.
+			// client can check generation number for changes
+			if (!_imeSession)
+			{
+				opEvent = new FlowOperationEvent(FlowOperationEvent.FLOW_OPERATION_END,false,true,op,captureLevel-1,opError);
+				textFlow.dispatchEvent(opEvent);
+				opError = opEvent.isDefaultPrevented() ? null : opEvent.error;
+			}
+
+			if (opError)
+				throw (opError);
+				
+			// If we fired off any subsidiary operations, create a composite operation to hold them all
+		 	if (captureOperations.length - captureStart > 1)
+		 	{
+				op = new CompositeOperation(captureOperations.slice(captureStart));
+				op.setGenerations(FlowOperation(CompositeOperation(op).operations[0]).beginGeneration,textFlow.generation);
+				allowOperationMerge = false;
+				captureOperations.length = captureStart;		
+		 	}
+			 	
+			return success ? op : null;
+		}
+
+		/** @private **/
+		override public function set textFlow(value:ITextFlow):void
+		{
+			flushPendingOperations();
+			if (redrawListener)	// detach handler if there is one
+				updateAllControllers();
+			super.textFlow = value;
+		}  
+		
+		/**
+		 * @copy IEditManager.delayUpdates
+		 */
+		public function get delayUpdates():Boolean
+		{
+			return _delayUpdates;
+		}
+		public function set delayUpdates(value:Boolean):void
+		{
+			_delayUpdates = value;
+		}
+		
+		private function redrawHandler(stamp:int):void
+		{
+			// This is here because it has to take an argument
+			updateAllControllers();
+		}
+
+		/** @copy IEditManager.updateAllControllers
+		 */
+		public function updateAllControllers():void
+		{
+			flushPendingOperations();
+
+			if (redrawListener)	// detach handler if there is one
+			{
+//				redrawListener.removeEventListener(Event.ENTER_FRAME, redrawHandler);
+				redrawListener = null;
+			}
+
+			if (textFlow.flowComposer)
+			{
+				 textFlow.flowComposer.updateAllControllers(); 
+
+				// Scroll to selection
+				if (hasSelection())
+				{
+					var controllerIndex:int = textFlow.flowComposer.findControllerIndexAtPosition(activePosition);
+					if (controllerIndex >= 0)
+						textFlow.flowComposer.getControllerAt(controllerIndex).scrollToRange(activePosition,anchorPosition);	
+				}
+			}
+
+			selectionChanged(true, false);
+				
+			CONFIG::debug { debugCheckTextFlow(); }
+		}
+
+		// By default, the EditManager will update in response to a model change immediately.
+		// Client may also request a delayed update; in this case, we schedule an update on the
+		// next enter frame event.
+		private function handleUpdate():void
+		{
+			if (_delayUpdates)
+			{
+				if (!redrawListener)	// only need to attach if we're not already
+				{
+					var controller:IContainerController = textFlow.flowComposer.getControllerAt(0);
+					if (controller)
+					{
+						redrawListener = controller.container;
+						if (redrawListener)
+							AnimationUtil.requestFrame(redrawHandler, redrawListener);
+//							redrawListener.addEventListener(Event.ENTER_FRAME, redrawHandler, false, 1.0, true);			
+					}
+				}
+			}
+			else		// redraw now
+			{
+				updateAllControllers();
+			}
+		}
+			
+		/** @copy IEditManager#allowDelayedOperations() */
+		public function get allowDelayedOperations():Boolean
+		{
+			return _allowDelayedOperations;
+		}
+		public function set allowDelayedOperations(value:Boolean):void
+		{
+			if (!value)
+				flushPendingOperations();
+			_allowDelayedOperations = value;
+		}
+		
+		/** @private */
+		public override function flushPendingOperations():void
+		{
+			super.flushPendingOperations();
+			if (pendingInsert)
+			{
+				var pi0:InsertTextOperation = pendingInsert;
+				pendingInsert = null;
+// Should not be needed
+//				if (enterFrameListener)
+//				{
+//					enterFrameListener.removeEventListener(Event.ENTER_FRAME, enterFrameHandler);
+//					enterFrameListener = null;
+//				}
+				doOperation(pi0);
+			}
+		}
+
+		/** 
+		 * @copy IEditManager#undo()
+		 * 
+		 * @see flashx.undo.IUndoManager#undo()
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */
+		public function undo():void
+		{
+			// Cancel out of an IME session if there is one. 
+			// Some IMEs are on all the time, and so the undo has to win over the IME, 
+			// otherwise you would never be able to undo in Korean.
+			if (_imeSession)
+				_imeSession.compositionAbandoned();
+			
+			if (undoManager)
+				undoManager.undo();
+		}
+		 			
+		/** @private */
+		public function performUndo(theop:IOperation):void
+		{
+			var operation:FlowOperation = theop as FlowOperation;
+			if ((!operation) || (operation.textFlow != textFlow)) 
+				return;			
+			// tell any listeners about the operation
+			if (!_imeSession)
+			{
+				var undoPsuedoOp:UndoOperation = new UndoOperation(operation);
+				var opEvent:FlowOperationEvent = new FlowOperationEvent(FlowOperationEvent.FLOW_OPERATION_BEGIN,false,true,undoPsuedoOp,0,null);
+				textFlow.dispatchEvent(opEvent);
+				if (opEvent.isDefaultPrevented())
+				{
+					//operation cancelled by user. Push the operation back onto the undo stack
+					undoManager.pushUndo(operation);
+					return;
+				}
+				undoPsuedoOp = opEvent.operation as UndoOperation;
+				if (!undoPsuedoOp)
+					throw new Error(GlobalSettings.resourceStringFunction("illegalOperation",[ getQualifiedClassName(opEvent.operation) ]));
+				operation = undoPsuedoOp.operation;
+			}
+					
+			if (operation.endGeneration != textFlow.generation)
+			{
+				//CONFIG::debug { trace("EditManager.undo: skipping undo due to mismatched generation numbers. textFlow",textFlow.generation,org.apache.flex.reflection.getQualifiedClassName(operation),operation.endGeneration); }
+				return;
+			}
+				
+			var opError:Error = null;
+			try
+			{
+				CONFIG::debug { debugCheckTextFlow(); }
+	
+				var rslt:SelectionState;
+				rslt = operation.undo();
+	
+				CONFIG::debug { assert(rslt != null,"undoable operations must return a SelectionState"); }
+				setSelectionState(rslt);
+				if (_undoManager)
+					_undoManager.pushRedo(operation);
+
+			}
+			catch(e:Error)
+			{
+				opError = e;
+			}
+				
+			// tell user its complete and give them a chance to cancel the rethrow
+			if (!_imeSession)
+			{
+				opEvent = new FlowOperationEvent(FlowOperationEvent.FLOW_OPERATION_END,false,true,undoPsuedoOp,0,opError);
+				textFlow.dispatchEvent(opEvent);
+				opError = opEvent.isDefaultPrevented() ? null : opEvent.error;
+			}
+
+			if (opError)
+				throw (opError);
+			
+			handleUpdate();
+			
+			// push the generation of the textFlow backwards - must be done after update which does a normalize
+			textFlow.setGeneration(operation.beginGeneration);
+			
+			if (!_imeSession)
+			{
+				opEvent = new FlowOperationEvent(FlowOperationEvent.FLOW_OPERATION_COMPLETE,false,false,undoPsuedoOp,0,null);
+				textFlow.dispatchEvent(opEvent);
+			}
+		}
+		
+		/** 
+		 * @copy IEditManager#redo()
+		 * 
+		 * @see flashx.undo.IUndoManager#redo()
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */
+		public function redo():void
+		{
+			// Cancel out of an IME session if there is one. 
+			// Some IMEs are on all the time, and so the undo has to win over the IME, 
+			// otherwise you would never be able to undo in Korean.
+			if (_imeSession)
+				_imeSession.compositionAbandoned();
+			
+			if (undoManager)
+				undoManager.redo();
+		}
+		
+		/** @private */
+		public function performRedo(theop:IOperation):void
+		{
+			var opEvent:FlowOperationEvent;
+			var op:FlowOperation = theop as FlowOperation;
+			if ((!op) || (op.textFlow != textFlow)) 
+				return;
+			// tell any listeners about the operation
+			if (!_imeSession)
+			{
+				var redoPsuedoOp:RedoOperation = new RedoOperation(op);
+				opEvent = new FlowOperationEvent(FlowOperationEvent.FLOW_OPERATION_BEGIN,false,true,redoPsuedoOp,0,null);
+				textFlow.dispatchEvent(opEvent);
+				if (opEvent.isDefaultPrevented() && _undoManager)
+				{
+					//user cancelled the event. Push the operation back onto the redo stack
+					_undoManager.pushRedo(op);
+					return;
+				}
+				redoPsuedoOp = opEvent.operation as RedoOperation;
+				if (!redoPsuedoOp)
+					throw new Error(GlobalSettings.resourceStringFunction("illegalOperation",[ getQualifiedClassName(opEvent.operation) ]));
+				op = redoPsuedoOp.operation;
+			}
+					
+			if (op.beginGeneration != textFlow.generation)
+			{
+				//CONFIG::debug { trace("EditManager.redo: skipping redo due to mismatched generation numbers."); }
+				return;
+			}
+				
+			var opError:Error = null;
+			try
+			{
+				CONFIG::debug { debugCheckTextFlow(); }					
+				var rslt:SelectionState;
+				rslt = op.redo();
+					
+				CONFIG::debug { assert(rslt != null,"redoable operations must return a SelectionState"); }
+				setSelectionState(rslt);
+				if (_undoManager)
+					_undoManager.pushUndo(op);
+
+			
+			}
+			catch(e:Error)
+			{
+				opError = e;
+			}
+				
+			// tell user its complete and give them a chance to cancel the rethrow
+			if (!_imeSession)
+			{
+				opEvent = new FlowOperationEvent(FlowOperationEvent.FLOW_OPERATION_END,false,true,redoPsuedoOp,0,opError);
+				textFlow.dispatchEvent(opEvent);
+				opError = opEvent.isDefaultPrevented() ? null : opEvent.error;
+			}
+			if (opError)
+				throw (opError);
+			
+			handleUpdate();
+			
+			// push the generation of the textFlow backwards - must be done after update which does a normalize
+			// set the generation of the textFlow to end of redoOp.
+			textFlow.setGeneration(op.endGeneration);
+			
+			if (hasSelection())
+			{
+				var controllerIndex:int = textFlow.flowComposer.findControllerIndexAtPosition(activePosition);
+				if (controllerIndex >= 0)
+					textFlow.flowComposer.getControllerAt(controllerIndex).scrollToRange(activePosition,anchorPosition);						
+			}	
+			if (!_imeSession)
+			{
+				opEvent = new FlowOperationEvent(FlowOperationEvent.FLOW_OPERATION_COMPLETE,false,false,redoPsuedoOp,0,null);
+				textFlow.dispatchEvent(opEvent);			
+			}
+		}
+		
+		/**
+		 * @private
+		 * Returns the editing mode (READ_ONLY, READ_SELECT, or READ_WRITE) of the EditManager.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 * @see org.apache.flex.textLayout.edit.EditingMode.
+		 */
+		 public override function get editingMode():String
+		 {
+		 	return EditingMode.READ_WRITE;
+		 }				 		
+		
+		// Resolve the operationState.
+		//		If the operation state is null...
+		//			Return the active selection
+		//			If there's no active selection, return null. The caller will have to check
+		//		Otherwise (operation not null)
+		//			just return it
+		/** @private */
+		public function defaultOperationState(operationState:SelectionState = null):SelectionState
+		{
+			if (operationState)
+			{
+				// flush any pending operations and use marks to preserve the operationState positions
+				var markActive:Mark = createMark();
+				var markAnchor:Mark = createMark();
+				try
+				{
+					markActive.position = operationState.activePosition;
+					markAnchor.position = operationState.anchorPosition;
+					flushPendingOperations();
+				}
+				finally
+				{
+					removeMark(markActive);
+					removeMark(markAnchor);
+					operationState.activePosition = markActive.position;
+					operationState.anchorPosition = markAnchor.position;
+				}
+			}
+			else
+			{
+				flushPendingOperations();
+				if (hasSelection())
+				{
+					// tell the operation that the state is from the SelectionManager so it will update pending point formats
+					operationState = getSelectionState();
+					operationState.selectionManagerOperationState = true;
+				}
+			}
+			return operationState;
+		}
+
+		/** 
+		 * @copy IEditManager#splitParagraph()
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */
+		public function splitParagraph(operationState:SelectionState = null):IParagraphElement
+		{
+			operationState = defaultOperationState(operationState);
+			if (!operationState)
+				return null;
+
+			var op:SplitElementOperation = new SplitParagraphOperation(operationState);
+			doOperation(op);
+			return op.newElement as IParagraphElement;
+		}
+		
+		
+		/** @copy IEditManager#splitElement() */
+		public function splitElement(target:IFlowGroupElement, operationState:SelectionState = null):IFlowGroupElement
+		{ 
+			operationState = defaultOperationState(operationState);
+			if (!operationState)
+				return null;
+			var op:SplitElementOperation = new SplitElementOperation(operationState, target);
+			doOperation(op);
+			return op.newElement;
+		}
+		
+		/** @copy IEditManager#createDiv() */
+		public function createDiv(parent:IFlowGroupElement = null, format:ITextLayoutFormat = null, operationState:SelectionState = null):IDivElement
+		{ 
+			operationState = defaultOperationState(operationState);
+			if (!operationState)
+				return null;
+			
+			var operation:CreateDivOperation = new CreateDivOperation(operationState, parent, format);
+			doOperation(operation);
+			return operation.newDivElement;
+		}		
+		
+		/** @copy IEditManager#createList() */
+		public function createList(parent:IFlowGroupElement = null, format:ITextLayoutFormat = null, operationState:SelectionState = null):IListElement
+		{ 
+			operationState = defaultOperationState(operationState);
+			if (!operationState)
+				return null;
+			
+			var operation:CreateListOperation = new CreateListOperation(operationState, parent, format);
+			doOperation(operation);
+			return operation.newListElement;
+		}
+		
+		/** @copy IEditManager#moveChildren() */
+		public function moveChildren(source:IFlowGroupElement, sourceIndex:int, numChildren:int, destination:IFlowGroupElement, destinationIndex:int, selectionState:SelectionState = null):void
+		{ 
+			selectionState = defaultOperationState(selectionState);
+			if (!selectionState)
+				return;
+
+			var operation:MoveChildrenOperation = new MoveChildrenOperation(selectionState, source, sourceIndex, numChildren, destination, destinationIndex);
+			doOperation(operation);
+		}
+		
+		/** @copy IEditManager#createSubParagraphGroup() */
+		public function createSubParagraphGroup(parent:IFlowGroupElement = null, format:ITextLayoutFormat = null, operationState:SelectionState = null):ISubParagraphGroupElement
+		{ 
+			operationState = defaultOperationState(operationState);
+			if (!operationState)
+				return null;
+			
+			var operation:CreateSubParagraphGroupOperation = new CreateSubParagraphGroupOperation(operationState, parent, format);
+			doOperation(operation);
+			return operation.newSubParagraphGroupElement;
+		}
+
+		/** 
+		 * @copy IEditManager#deleteText()
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */
+		public function deleteText(operationState:SelectionState = null):void
+		{
+			// handle when a table cells is active.
+			if(subManager && subManager is IEditManager)
+			{
+				(subManager as IEditManager).deleteText(operationState);
+				return;
+			}
+			operationState = defaultOperationState(operationState);
+			if (!operationState)
+				return;
+
+			doOperation(new DeleteTextOperation(operationState, operationState, false /* don't allow merge when deleting by range */));				
+		}		
+		
+		/**
+		 * @copy IEditManager#deleteNextCharacter()
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */
+		public function deleteNextCharacter(operationState:SelectionState = null):void
+		{
+			// handle when a table cells is active.
+			if(subManager && subManager is IEditManager)
+			{
+				(subManager as IEditManager).deleteNextCharacter(operationState);
+				return;
+			}
+			operationState = defaultOperationState(operationState);
+			if (!operationState)
+				return;
+
+			/*
+			This should not be necessary...
+			// mjzhang : fix for table
+			var leaf:FlowLeafElement = textFlow.findLeaf(operationState.absoluteStart);
+			var para:IParagraphElement = leaf.getParagraph();
+			if ( para.isInTable() )
+				return;
+			*/
+			// Delete the next character if it's a caret selection, and allow adejacent delete next's to merge
+			// If it's a range selection, delete the range and disallow merge
+			var deleteOp:DeleteTextOperation;
+			if (operationState.absoluteStart == operationState.absoluteEnd)
+			{
+				var nextPosition:int = NavigationUtil.nextAtomPosition(textFlow, absoluteStart);
+				deleteOp = new DeleteTextOperation(operationState, new SelectionState(textFlow, absoluteStart, nextPosition, pointFormat), true /* allowMerge for deleteForward */);	
+			}
+			else 
+				deleteOp = new DeleteTextOperation(operationState, operationState, false /* don't allow merge when deleting by range */);			
+			doOperation(deleteOp);			
+
+		}
+
+		/** 
+		 * @copy IEditManager#deleteNextWord()
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */		
+		public function deleteNextWord(operationState:SelectionState = null):void
+		{
+			// handle when a table cells is active.
+			if(subManager && subManager is IEditManager)
+			{
+				(subManager as IEditManager).deleteNextWord(operationState);
+				return;
+			}
+			operationState = defaultOperationState(operationState);
+			if ((!operationState) || ((operationState.anchorPosition == operationState.activePosition) && (operationState.anchorPosition >= textFlow.textLength - 1)))
+				return;
+				
+			var nextWordSelState:SelectionState = getNextWordForDelete(operationState.absoluteStart);
+			if (nextWordSelState.anchorPosition == nextWordSelState.activePosition)
+				//nothing to delete. No operation required.
+				return;			
+
+			setSelectionState(new SelectionState(textFlow, operationState.absoluteStart, operationState.absoluteStart, new TextLayoutFormat(textFlow.findLeaf(operationState.absoluteStart).format)));
+			doOperation(new DeleteTextOperation(operationState, nextWordSelState, false));						
+		}
+
+		// Sadly, this is NOT the same as the cursor key movement - specialized for delete forward one word
+		private function getNextWordForDelete(absoluteStart:int):SelectionState
+		{
+			var leafEl:IFlowLeafElement = textFlow.findLeaf(absoluteStart);
+			var paraEl:IParagraphElement = leafEl.getParagraph();
+			var paraElAbsStart:int = paraEl.getAbsoluteStart();
+			
+			var nextPosition:int = -1;
+			
+			if ((absoluteStart - paraElAbsStart) >= (paraEl.textLength - 1))
+			{
+				// We're at the end of the paragraph, delete the following newline
+				nextPosition = NavigationUtil.nextAtomPosition(textFlow, absoluteStart);
+			}
+			else
+			{
+				var curPos:int = absoluteStart - paraElAbsStart;			
+				var curPosCharCode:int = paraEl.getCharCodeAtPosition(curPos);
+				var prevPosCharCode:int = -1;
+				if (curPos > 0) prevPosCharCode = paraEl.getCharCodeAtPosition(curPos - 1);
+//				var nextPosCharCode:int = paraEl.getCharCodeAtPosition(curPos + 1);
+				if (!CharacterUtil.isWhitespace(curPosCharCode) && ((curPos == 0) || ((curPos > 0) && CharacterUtil.isWhitespace(prevPosCharCode)))) {
+					nextPosition = NavigationUtil.nextWordPosition(textFlow, absoluteStart);
+				} else {
+					if (CharacterUtil.isWhitespace(curPosCharCode) && ((curPos > 0) && !CharacterUtil.isWhitespace(prevPosCharCode))) {
+						//if at beginning of space word then get through all the spaces					
+						curPos = paraEl.findNextWordBoundary(curPos);
+					}
+					nextPosition = paraElAbsStart + paraEl.findNextWordBoundary(curPos);
+				}
+			}
+			return new SelectionState(textFlow, absoluteStart, nextPosition, pointFormat);
+		}
+		
+		/**
+		 * @copy IEditManager#deletePreviousCharacter()
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */		
+		public function deletePreviousCharacter(operationState:SelectionState = null):void
+		{
+			// handle when a table cells is active.
+			if(subManager && subManager is IEditManager)
+			{
+				(subManager as IEditManager).deletePreviousCharacter(operationState);
+				return;
+			}
+			operationState = defaultOperationState(operationState);
+			if (!operationState)
+				return;
+
+			var deleteOp:DeleteTextOperation;
+			if (operationState.absoluteStart == operationState.absoluteEnd)
+			{	
+				// with a caret selection, generally delete the previous character, but also check whether to move the paragraph out of its parent chain (like backspacing at the beginning of a list)
+				var leaf:IFlowLeafElement = textFlow.findLeaf(operationState.absoluteStart);
+				var para:IParagraphElement = leaf.getParagraph();
+				var parent:IFlowGroupElement = para.parent;
+				
+				var movePara:Boolean = false;
+				if(!(parent is ITextFlow))
+				{
+					if(operationState.absoluteStart == para.getAbsoluteStart() && parent.getChildIndex(para) == 0 && // cursor is at start of this paragraph AND para is at beginning of parent AND
+						(!(parent is IListItemElement) || parent.parent.getChildIndex(parent) == 0)) // if parent is a listItem, it's the first item in the list
+					{
+						movePara = true;
+					}
+				}
+				if(movePara)
+				{
+					/*
+					should not be necessary...
+					// mjzhang: fix for table feature
+					if ( para.isInTable() )
+						return;
+					*/
+					var source:IFlowGroupElement;
+					var target:IFlowGroupElement;
+					var numElementsToMove:int;
+					var targetIndex:int;
+					
+					if(parent is IListItemElement)
+					{
+						if(parent.parent.parent is IListElement)
+						{
+							// move the whole list item to grandparent list
+							source = parent.parent;
+							numElementsToMove = 1;
+							target = parent.parent.parent;
+							targetIndex = parent.parent.parent.getChildIndex(parent.parent);
+						}
+						else
+						{
+							// move everything inside the list item out into grandparent
+							source = para.parent;
+							numElementsToMove = para.parent.numChildren;
+							target = parent.parent.parent;
+							targetIndex = parent.parent.parent.getChildIndex(parent.parent);
+						}
+					}
+					else
+					{
+						// move just the first paragraph out into grandparent
+						source = para.parent;
+						numElementsToMove = 1;
+						target = parent.parent;
+						targetIndex = parent.parent.getChildIndex(parent);
+					}
+					doOperation(new MoveChildrenOperation(operationState, source, 0, numElementsToMove, target, targetIndex));
+				}
+				else
+				{
+					var beginPrevious:int = NavigationUtil.previousAtomPosition(textFlow, operationState.absoluteStart);
+					deleteOp = new DeleteTextOperation(operationState, new SelectionState(textFlow, beginPrevious, operationState.absoluteStart), true /* allowMerge */);
+					doOperation(deleteOp);
+				}
+			}
+			else	// just delete the range
+			{
+				deleteOp = new DeleteTextOperation(operationState);
+				doOperation(deleteOp);
+			}
+		}
+		
+		/** 
+		 * @copy IEditManager#deletePreviousWord()
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */		
+		public function deletePreviousWord(operationState:SelectionState = null):void
+		{
+			// handle when a table cells is active.
+			if(subManager && subManager is IEditManager)
+			{
+				(subManager as IEditManager).deletePreviousWord(operationState);
+				return;
+			}
+			operationState = defaultOperationState(operationState);
+			if (!operationState)
+				return;
+				
+			var prevWordSelState:SelectionState = getPreviousWordForDelete(operationState.absoluteStart);
+			if (prevWordSelState.anchorPosition == prevWordSelState.activePosition)
+				//there is nothing to delete.  No operation required
+				return;			
+				
+			setSelectionState(new SelectionState(textFlow, operationState.absoluteStart, operationState.absoluteStart, new TextLayoutFormat(textFlow.findLeaf(operationState.absoluteStart).format)));
+			doOperation(new DeleteTextOperation(operationState, prevWordSelState, false /* don't allow merge */));						
+		}		
+		
+		// Sadly, this is NOT the same as the cursor key movement - specialized for delete backward one word
+		private function getPreviousWordForDelete(absoluteStart:int):SelectionState
+		{
+			var leafEl:IFlowLeafElement = textFlow.findLeaf(absoluteStart);
+			var paraEl:IParagraphElement = leafEl.getParagraph();
+			var paraElAbsStart:int = paraEl.getAbsoluteStart();
+
+			if (absoluteStart == paraElAbsStart)		// at the start of the paragraph, delete the previous newline. Should insert a space after punctuation.
+			{
+				var beginPrevious:int = NavigationUtil.previousAtomPosition(textFlow, absoluteStart);
+				return new SelectionState(textFlow, beginPrevious, absoluteStart);				
+			}
+
+			var curPos:int = absoluteStart - paraElAbsStart;
+			var curPosCharCode:int = paraEl.getCharCodeAtPosition(curPos);
+			var prevPosCharCode:int = paraEl.getCharCodeAtPosition(curPos - 1);
+			var curAbsStart:int = absoluteStart;
+			
+			if (CharacterUtil.isWhitespace(curPosCharCode) && (curPos != (paraEl.textLength - 1)))
+			{
+				if (CharacterUtil.isWhitespace(prevPosCharCode)) //this will get you past the spaces
+				{
+					curPos = paraEl.findPreviousWordBoundary(curPos);
+				}
+				if (curPos > 0) {
+					curPos = paraEl.findPreviousWordBoundary(curPos); //this will get you to the beginning of the word before the space.
+					if (curPos > 0) {
+						prevPosCharCode = paraEl.getCharCodeAtPosition(curPos - 1);
+						if (CharacterUtil.isWhitespace(prevPosCharCode)) {
+							curPos = paraEl.findPreviousWordBoundary(curPos);
+						}
+					}
+				}
+			} else { //you are here if you are not on a space
+				if (CharacterUtil.isWhitespace(prevPosCharCode))
+				{
+					curPos = paraEl.findPreviousWordBoundary(curPos); //this will get you past the spaces
+					if (curPos > 0) {
+						curPos = paraEl.findPreviousWordBoundary(curPos);
+						// mjzhang : Fix for bug#2821844 Text controls make bad assumptions with Ctrl Backspace
+						//if (curPos > 0) {
+						//	prevPosCharCode = paraEl.getCharCodeAtPosition(curPos - 1);
+						//	if (!CharacterUtil.isWhitespace(prevPosCharCode)) {
+						//		curAbsStart--; //Microsoft Word insists on keeping the original space
+						//		               //if the ending position does not have a space.
+						//	}
+						//}
+					}
+				} else { //just delete to the previous word boundary
+					curPos = paraEl.findPreviousWordBoundary(curPos);
+				}
+			}
+			return new SelectionState(textFlow, paraElAbsStart + curPos, curAbsStart);
+		}		
+
+		public function insertTableElement(table:ITableElement, operationState:SelectionState = null):void
+		{
+			// handle insertions when a table cells is active. (nested tables probably do not work now though...)
+			if(subManager && subManager is IEditManager)
+			{
+				(subManager as IEditManager).insertTableElement(table, operationState);
+				return;
+			}
+			operationState = defaultOperationState(operationState);
+			if (!operationState)
+				return;
+			
+			var operation:InsertTableElementOperation = new InsertTableElementOperation(operationState, table);
+			doOperation(operation);
+		}
+		
+		/** 
+		 * @copy IEditManager#insertText()
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */	
+		public function insertText(text:String, origOperationState:SelectionState = null):void
+		{
+			// handle insertions when a table cells is active.
+			if(subManager && subManager is IEditManager)
+			{
+				(subManager as IEditManager).insertText(text, origOperationState);
+				return;
+			}
+			// if there's another insert operation waiting to be executed, 
+			// just add to it, if possible
+			if (origOperationState == null && pendingInsert)
+				pendingInsert.text += text;
+			else 
+			{
+				var operationState:SelectionState = defaultOperationState(origOperationState);
+				if (!operationState)
+					return;
+				
+				// rather than execute the insert immediately, create
+				// it and wait for the next frame, in order to batch
+				// keystrokes.
+				pendingInsert = new InsertTextOperation(operationState, text);
+				
+				var controller:IContainerController = textFlow.flowComposer.getControllerAt(0);
+				if (captureLevel == 0 && origOperationState == null && controller && controller.container && allowDelayedOperations)
+				{
+					AnimationUtil.requestFrame(enterFrameHandler, controller.container);
+//					enterFrameListener = controller.container;
+//					enterFrameListener.addEventListener(Event.ENTER_FRAME, enterFrameHandler, false, 1.0, true);
+				}
+				else
+					flushPendingOperations();
+			}
+		}
+				
+
+		
+		/** 
+		 * @copy IEditManager#overwriteText()
+		 * 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */	
+		public function overwriteText(text:String, operationState:SelectionState = null):void
+		{
+			// handle overwrites when a table cells is active.
+			if(subManager && subManager is IEditManager)
+			{
+				(subManager as IEditManager).overwriteText(text, operationState);
+				return;
+			}
+			operationState = defaultOperationState(operationState);
+			if (!operationState)
+				return;
+			var selState:SelectionState = getSelectionState();
+			NavigationUtil.nextCharacter(selState,true);
+			doOperation(new InsertTextOperation(operationState, text, selState));
+		}
+
+		/** 
+		 * @copy IEditManager#insertInlineGraphic()
+		 * Returns the new InlineGraphicElement that was created.
+		 * 
+		 * @playerversion Flash 10 + 10.2
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 * @see org.apache.flex.text.engine.TextRotation
+		 */			
+		public function insertInlineGraphic(source:Object, width:Object, height:Object, options:Object = null, operationState:SelectionState = null):IInlineGraphicElement
+		{
+			// handle when a table cells is active.
+			if(subManager && subManager is IEditManager)
+				return (subManager as IEditManager).insertInlineGraphic(source, width, height, options, operationState);
+
+			operationState = defaultOperationState(operationState);
+			if (!operationState)
+				return null;
+
+			var operation:InsertInlineGraphicOperation = new InsertInlineGraphicOperation(operationState, source, width, height, options);
+			doOperation(operation);
+			return operation.newInlineGraphicElement;
+		}	
+		
+		/** 
+		 * @copy IEditManager#modifyInlineGraphic()
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */			
+		public function modifyInlineGraphic(source:Object, width:Object, height:Object, options:Object = null, operationState:SelectionState = null):void
+		{
+			// handle when a table cells is active.
+			if(subManager && subManager is IEditManager)
+			{
+				(subManager as IEditManager).modifyInlineGraphic(source, width, height, options, operationState);
+				return;
+			}
+			operationState = defaultOperationState(operationState);
+			if (!operationState)
+				return;
+
+			doOperation(new ModifyInlineGraphicOperation(operationState, source, width, height, options));
+		}					
+		
+		/** 
+		 * @copy IEditManager#applyFormat()
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */		
+		public function applyFormat(leafFormat:ITextLayoutFormat, paragraphFormat:ITextLayoutFormat, containerFormat:ITextLayoutFormat, operationState:SelectionState = null):void
+		{
+			// handle when a table cells is active.
+			if(subManager && subManager is IEditManager)
+			{
+				(subManager as IEditManager).applyFormat(leafFormat, paragraphFormat, containerFormat, operationState);
+				return;
+			}
+			operationState = defaultOperationState(operationState);
+			if (!operationState)
+				return;
+
+			// apply to the current selection else remember new format for next char typed
+			doOperation(new ApplyFormatOperation(operationState, leafFormat, paragraphFormat, containerFormat));
+		}
+		/** 
+		 * @copy IEditManager#clearFormat()
+		 * 
+		 * Known issue is that undefines of leafFormat values with a point selection are not applied at the next insertion.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function clearFormat(leafFormat:ITextLayoutFormat, paragraphFormat:ITextLayoutFormat, containerFormat:ITextLayoutFormat, operationState:SelectionState = null):void
+		{
+			// handle when a table cells is active.
+			if(subManager && subManager is IEditManager)
+			{
+				(subManager as IEditManager).clearFormat(leafFormat, paragraphFormat, containerFormat, operationState);
+				return;
+			}
+			operationState = defaultOperationState(operationState);
+			if (!operationState)
+				return;
+			
+			// apply to the current selection else remember new format for next char typed
+			doOperation(new ClearFormatOperation(operationState, leafFormat, paragraphFormat, containerFormat));
+		}
+		/** 
+		 * @copy IEditManager#applyLeafFormat()
+		 * 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */		
+		public function applyLeafFormat(characterFormat:ITextLayoutFormat, operationState:SelectionState = null):void
+		{
+			// handle when a table cells is active.
+			if(subManager && subManager is IEditManager)
+				(subManager as IEditManager).applyLeafFormat(characterFormat, operationState);
+			else 
+				applyFormat(characterFormat, null, null, operationState);
+		}
+
+		/** 
+		 * @copy IEditManager#applyParagraphFormat()
+		 * 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+ 		 */		
+		public function applyParagraphFormat(paragraphFormat:ITextLayoutFormat, operationState:SelectionState = null):void
+		{
+			// handle when a table cells is active.
+			if(subManager && subManager is IEditManager)
+				(subManager as IEditManager).applyParagraphFormat(paragraphFormat, operationState);
+			else
+				applyFormat(null, paragraphFormat, null, operationState);
+		}
+
+		/** 
+		 * @copy IEditManager#applyContainerFormat()
+		 * 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */		
+		public function applyContainerFormat(containerFormat:ITextLayoutFormat, operationState:SelectionState = null):void
+		{
+			// handle when a table cells is active.
+			if(subManager && subManager is IEditManager)
+				(subManager as IEditManager).applyContainerFormat(containerFormat, operationState);
+			else
+				applyFormat(null, null, containerFormat, operationState);
+		}
+		
+		/** 
+		 * @copy IEditManager#applyFormatToElement()
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */	
+		public function applyFormatToElement(targetElement:IFlowElement, format:ITextLayoutFormat, relativeStart:int = 0, relativeEnd:int = -1, operationState:SelectionState = null):void
+		{
+			operationState = defaultOperationState(operationState);
+			if (!operationState)
+				return;
+
+			doOperation(new ApplyFormatToElementOperation(operationState, targetElement, format, relativeStart, relativeEnd));
+		}
+
+		/** 
+		 * @copy IEditManager#clearFormatOnElement()
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */	
+		public function clearFormatOnElement(targetElement:IFlowElement, format:ITextLayoutFormat, operationState:SelectionState = null):void
+		{
+			operationState = defaultOperationState(operationState);
+			if (!operationState)
+				return;
+			
+			doOperation(new ClearFormatOnElementOperation(operationState, targetElement, format));
+		}
+		
+		/** 
+		 * @copy IEditManager#cutTextScrap()
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+ 	 	 * 
+		 *  @see org.apache.flex.textLayout.edit.TextScrap
+		 */
+		public function cutTextScrap(operationState:SelectionState = null):TextScrap
+		{
+			// handle when a table cells is active.
+			if(subManager && subManager is IEditManager)
+				return (subManager as IEditManager).cutTextScrap(operationState);
+			
+			operationState = defaultOperationState(operationState);
+			if (!operationState)
+				return null;
+				
+			if (operationState.anchorPosition == operationState.activePosition)
+				return null;
+
+			var tScrap:TextScrap = TextScrap.createTextScrap(operationState);			
+			var beforeOpLen:int = textFlow.textLength;						
+			doOperation(new CutOperation(operationState, tScrap));
+			if (operationState.textFlow.textLength != beforeOpLen)
+			{
+				return tScrap;
+			}									
+			return null;			
+		}
+		
+		/** 
+		 * @copy IEditManager#pasteTextScrap()
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+ 	 	 * 
+		 *  @see org.apache.flex.textLayout.edit.TextScrap
+		 */
+		public function pasteTextScrap(scrapToPaste:TextScrap, operationState:SelectionState = null):void
+		{
+			// handle when a table cells is active.
+			if(subManager && subManager is IEditManager)
+			{
+				(subManager as IEditManager).pasteTextScrap(scrapToPaste, operationState);
+				return;
+			}
+			operationState = defaultOperationState(operationState);
+			if (!operationState)
+				return;
+
+			doOperation(new PasteOperation(operationState, scrapToPaste));	
+		}
+		
+		/** 
+		 * @copy IEditManager#applyTCY()
+		 * Returns the new TCYElement that was created.
+		 * 
+		 * @playerversion Flash 10 + 10.2
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */			
+		public function applyTCY(tcyOn:Boolean, operationState:SelectionState = null):ITCYElement
+		{
+			// handle when a table cells is active.
+			if(subManager && subManager is IEditManager)
+				return (subManager as IEditManager).applyTCY(tcyOn, operationState);
+
+			operationState = defaultOperationState(operationState);
+			if (!operationState)
+				return null;
+
+			var operation:ApplyTCYOperation = new ApplyTCYOperation(operationState, tcyOn);
+			doOperation(operation);
+			return operation.newTCYElement;
+		}
+		
+		/** 
+		 * @copy IEditManager#applyLink()
+		 * Returns the new ILinkElement that was created.
+		 * 
+		 * @playerversion Flash 10 + 10.2
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */			
+		public function applyLink(href:String, targetString:String = null, extendToLinkBoundary:Boolean=false, operationState:SelectionState = null):ILinkElement
+		{
+			operationState = defaultOperationState(operationState);
+			if (!operationState)
+				return null;
+				
+			if (operationState.absoluteStart == operationState.absoluteEnd)
+				return null;
+
+			var operation:ApplyLinkOperation = new ApplyLinkOperation(operationState, href, targetString, extendToLinkBoundary);
+			doOperation(operation);
+			return operation.newLinkElement;
+		}
+		
+		/**
+		 * @copy IEditManager#changeElementID()
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+	 	*/
+		public function changeElementID(newID:String, targetElement:IFlowElement, relativeStart:int = 0, relativeEnd:int = -1, operationState:SelectionState = null):void
+		{
+			operationState = defaultOperationState(operationState);
+			if (!operationState)
+				return;
+				
+			if (operationState.absoluteStart == operationState.absoluteEnd)
+				return;
+
+			doOperation(new ApplyElementIDOperation(operationState, targetElement, newID, relativeStart, relativeEnd));
+		}
+		
+		[Deprecated(replacement="applyFormatToElement", deprecatedSince="2.0")]
+		/**
+		 * @copy IEditManager#changeStyleName()
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public function changeStyleName(newName:String, targetElement:IFlowElement, relativeStart:int = 0, relativeEnd:int = -1, operationState:SelectionState = null):void
+		{
+			operationState = defaultOperationState(operationState);
+			if (!operationState)
+				return;
+			
+			var format:TextLayoutFormat = new TextLayoutFormat();
+			format.styleName = newName;
+			doOperation(new ApplyFormatToElementOperation(operationState, targetElement, format, relativeStart, relativeEnd));
+		}
+		
+		/**
+		 * @copy IEditManager#changeTypeName()
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public function changeTypeName(newName:String, targetElement:IFlowElement, relativeStart:int = 0, relativeEnd:int = -1, operationState:SelectionState = null):void
+		{
+			operationState = defaultOperationState(operationState);
+			if (!operationState)
+				return;
+			
+			doOperation(new ApplyElementTypeNameOperation(operationState, targetElement, newName, relativeStart, relativeEnd));
+		}
+		
+		/* CompositeOperations
+			Normally when you call doOperation, it gets executed immediately. By calling beginCompositeOperation, you can instead accumulate the
+			operations into a CompositeOperation. The CompositeOperation is completed and returned when you call endCompositeOperation, and 
+			processing returns to normal state. The client code can then either call doOperation on the CompositeOperation that was returned, 
+			or just drop it if the operation should be aborted.
+			
+			The parentStack is a stack of pending CompositeOperations. 
+		*/
+		private var parentStack:Array;
+		
+		/** 
+		 * @copy IEditManager#beginCompositeOperation()
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+ 	 	 * 
+		 */
+		public function beginCompositeOperation():void
+		{
+			// not sure if there's issues with composite operations and tables
+			flushPendingOperations();
+			
+			if (!parentStack)
+				parentStack = [];
+			var operation:CompositeOperation = new CompositeOperation();
+			
+			if (!_imeSession)
+			{	
+				var opEvent:FlowOperationEvent = new FlowOperationEvent(FlowOperationEvent.FLOW_OPERATION_BEGIN,false,false,operation,captureLevel,null);
+				textFlow.dispatchEvent(opEvent);
+			}
+			
+			CONFIG::debug { assert(!operation.operations  || operation.operations.length == 0, "opening a composite operation that already has operations"); }
+			operation.setGenerations(textFlow.generation, 0);
+			++captureLevel;
+			var parent:Object = {};
+			parent.operation = operation;
+			parent.captureLevel = captureLevel;
+			parentStack.push(parent);
+		}
+		
+		/** 
+		 * @copy IEditManager#endCompositeOperation()
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+ 	 	 * 
+		 */
+		public function endCompositeOperation():void
+		{
+			// not sure if there's issues with composite operations and tables
+			CONFIG::debug { assert( parentStack.length > 0 || captureLevel <= 0, "EditManager.endOperation - no composite operation in progress"); }
+			
+			--captureLevel;
+			
+			var parent:Object = parentStack.pop();
+			var operation:FlowOperation = parent.operation;
+			if (!_imeSession)
+			{	
+				var opEvent:FlowOperationEvent = new FlowOperationEvent(FlowOperationEvent.FLOW_OPERATION_END,false,false,operation,captureLevel,null);
+				textFlow.dispatchEvent(opEvent);
+			}
+			operation.setGenerations(operation.beginGeneration, textFlow.generation);
+			finalizeDo(operation);
+		}
+		
+		/** @private
+		 * Handler function called when the selection has been changed.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 * @param doDispatchEvent	true if a selection changed event will be sent
+		 * @param resetPointFormat	true if the attributes associated with the caret should be discarded
+		 */
+		public override function selectionChanged(doDispatchEvent:Boolean = true, resetPointFormat:Boolean=true):void
+		{	
+			if (_imeSession)
+				_imeSession.selectionChanged();
+			
+			super.selectionChanged(doDispatchEvent, resetPointFormat);
+		}
+		override public function copy(sharedUndo:Boolean):ISelectionManager
+		{
+			if(sharedUndo)
+				return new EditManager(undoManager);
+			else
+				return new EditManager();
+		}
+
+
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/EditingMode.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/EditingMode.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/EditingMode.as
new file mode 100644
index 0000000..72e21d3
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/EditingMode.as
@@ -0,0 +1,60 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.edit
+{
+	/** 
+	 * The EditingMode class defines constants used with EditManager class to represent the 
+	 * read, select, and edit permissions of a document.
+	 * 
+	 * @see org.apache.flex.textLayout.edit.EditManager
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+ 	 * @langversion 3.0
+	 */
+	public final class EditingMode
+	{
+		/** 
+		 * The document is read-only.
+		 * 
+		 * <p>Neither selection nor editing is allowed.</p> 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */
+		public static const READ_ONLY:String = "readOnly";
+		/** 
+		 * The document can be edited.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */
+		public static const READ_WRITE:String = "readWrite";
+		/** 
+		 * The text in the document can be selected and copied, but not edited. 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */
+		public static const READ_SELECT:String = "readSelect";			
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/ElementMark.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/ElementMark.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/ElementMark.as
new file mode 100644
index 0000000..e658f1d
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/ElementMark.as
@@ -0,0 +1,86 @@
+// //////////////////////////////////////////////////////////////////////////////
+//
+// 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
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// //////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.edit
+{
+	import org.apache.flex.textLayout.debug.Debugging;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	import org.apache.flex.textLayout.elements.IFlowGroupElement;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+
+	// [ExcludeClass]
+	/** @private - Marks an element by its position in the hierarchy. */
+	public class ElementMark
+	{
+		/** @private */
+		public var _elemStart:int;
+		/** @private */
+		public var _indexChain:Array;
+		CONFIG::debug
+		{
+			private var _originalElement:String; }
+		public function ElementMark(elem:IFlowElement, relativeStartPosition:int)
+		{
+			_elemStart = relativeStartPosition;
+			_indexChain = [];
+
+			CONFIG::debug
+			{
+				var origElem:IFlowElement = elem; }
+			CONFIG::debug
+			{
+				_originalElement = Debugging.getIdentity(origElem); }
+
+			var p:IFlowGroupElement = elem.parent;
+			while (p != null)
+			{
+				_indexChain.splice(0, 0, p.getChildIndex(elem));
+				elem = p;
+				p = p.parent;
+			}
+
+			CONFIG::debug
+			{
+				var foundElem:IFlowElement = findElement(origElem.getTextFlow());
+				assert(origElem == findElement(origElem.getTextFlow()), "Bad ElementMarker"); 
+			}
+		}
+
+		public function get elemStart():int
+		{
+			return _elemStart;
+		}
+
+		/**
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.IFlowGroupElement
+		 */
+		public function findElement(textFlow:ITextFlow):IFlowElement
+		{
+			var element:IFlowElement = textFlow;
+			for each (var idx:int in _indexChain)
+				element = (element as IFlowGroupElement).getChildAt(idx);
+
+			CONFIG::debug
+			{
+				assert(element != null, "ElementMarker:findElement No element found"); }
+
+			return element;
+		}
+	}
+}
\ No newline at end of file


[04/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/CreateListOperation.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/CreateListOperation.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/CreateListOperation.as
new file mode 100644
index 0000000..1cb5011
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/CreateListOperation.as
@@ -0,0 +1,288 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.operations
+{
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.edit.ElementMark;
+	import org.apache.flex.textLayout.edit.MementoList;
+	import org.apache.flex.textLayout.edit.ModelEdit;
+	import org.apache.flex.textLayout.edit.SelectionState;
+	import org.apache.flex.textLayout.elements.ElementHelper;
+	import org.apache.flex.textLayout.elements.IFlowGroupElement;
+	import org.apache.flex.textLayout.elements.IListElement;
+	import org.apache.flex.textLayout.elements.IListItemElement;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.ISubParagraphGroupElementBase;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+
+	/**
+	 * The CreateListOperation class encapsulates creating list
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	public class CreateListOperation extends FlowTextOperation
+	{
+		// describes the target
+		private var _listParentMarker:ElementMark;
+		private var _mementoList:MementoList;
+
+		private var _listFormat:ITextLayoutFormat;
+		private var _listElement:IListElement;		// the element that gets created
+		
+		private var _postOpSelectionState:SelectionState;
+		
+		/** 
+		 * Creates an CreateListOperation object.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		public function CreateListOperation(operationState:SelectionState, parent:IFlowGroupElement = null, listFormat:ITextLayoutFormat = null)
+		{
+			super(operationState);
+			
+			this.parent = parent;
+			_listFormat = listFormat;
+			_mementoList = new MementoList(operationState.textFlow);
+		}
+		
+		/** 
+		 * Specifies the element this operation adds a new IListElement to.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.IFlowGroupElement
+		 */
+		public function get parent():IFlowGroupElement
+		{
+			return _listParentMarker ? _listParentMarker.findElement(originalSelectionState.textFlow) as IFlowGroupElement : null;
+		}
+		
+		/**
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.IFlowGroupElement
+		 */
+		public function set parent(value:IFlowGroupElement):void
+		{
+			if (!value)
+			{
+				// descend to the lowest level non-paragraph element that contains both positions
+				// effectively make the new list as close to the spans as possible
+				value = textFlow;
+				
+				var begPos:int = this.absoluteStart;
+				var endPos:int = this.absoluteEnd;
+				for (;;)
+				{
+					var begChildIdx:int = value.findChildIndexAtPosition(begPos);
+					var elem:IFlowGroupElement = value.getChildAt(begChildIdx) as IFlowGroupElement;
+					if (elem is IParagraphElement)
+						break;
+					begPos -= elem.parentRelativeStart;
+					endPos -= elem.parentRelativeStart;
+					if (endPos >= elem.textLength)	// end pos is in the next element
+						break;
+					value = elem;
+				}
+			}
+			else if (value is ISubParagraphGroupElementBase)
+				value = value.getParagraph().parent;
+			
+			_listParentMarker = new ElementMark(value,0);
+		}
+
+		/** TextLayoutFormat to be applied to the new IListElement. 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */	
+		public function get listFormat():ITextLayoutFormat
+		{ return _listFormat; }
+		public function set listFormat(value:ITextLayoutFormat):void
+		{ _listFormat = value; }
+		
+		/** The new IListElement. 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */	
+		public function get newListElement():IListElement
+		{ return _listElement; }
+		
+		/**
+		 *  @private
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.IFlowGroupElement
+		 */
+		public override function doOperation():Boolean
+		{
+			var target:IFlowGroupElement = parent;
+			
+			// find the starting child that's going to be in the list and 
+			var begChildIndex:int = 0;
+			var begStart:int = absoluteStart - target.getAbsoluteStart();
+			CONFIG::debug { assert(begStart >= 0 && begStart < target.textLength,"CreateListOperation: bad target"); }
+			
+			var endChildIndex:int;
+			var endStart:int = absoluteEnd - target.getAbsoluteStart();
+			CONFIG::debug { assert(endStart >= 0 && endStart <= target.textLength,"CreateListOperation: bad target"); }
+			
+			// scratch vars
+			var child:IFlowGroupElement;
+			
+			if (begStart > 0)
+			{
+				// figure out the starting child
+				begChildIndex = target.findChildIndexAtPosition(begStart);
+				child = target.getChildAt(begChildIndex) as IFlowGroupElement;
+				if (child.parentRelativeStart != begStart)
+				{					
+					_mementoList.push(ModelEdit.splitElement(textFlow,child,begStart-child.parentRelativeStart));
+					
+					if (child is IParagraphElement)
+						endStart++;
+					begChildIndex++;
+				}
+			}
+			
+			if (endStart >= 0)
+			{
+				if (endStart >= target.textLength - 1)
+					endChildIndex = target.numChildren;
+				else
+				{
+					// figure out the starting child
+					endChildIndex = target.findChildIndexAtPosition(endStart);
+					child = target.getChildAt(endChildIndex) as IFlowGroupElement;
+					if (child.parentRelativeStart != endStart)			
+					{
+						_mementoList.push(ModelEdit.splitElement(textFlow,child,endStart-child.parentRelativeStart));
+						endChildIndex++;
+					}
+				}
+			}
+			else
+				endChildIndex = begChildIndex+1;
+			
+			_listElement = ElementHelper.getList();
+			_listElement.format = listFormat;
+			
+			var listItem:IListItemElement;
+			
+			if (begChildIndex == target.numChildren)
+			{
+				// new list at the end of target
+				child = target.getChildAt(target.numChildren-1) as IFlowGroupElement;
+				
+				_mementoList.push(ModelEdit.splitElement(textFlow,child,child.textLength));
+				_mementoList.push(ModelEdit.addElement(textFlow,_listElement,target,target.numChildren));
+
+				if (!(child is IListItemElement))
+				{
+					listItem = ElementHelper.getListItem();	// NO PMD
+					_mementoList.push(ModelEdit.addElement(textFlow,listItem,_listElement,_listElement.numChildren));
+					_mementoList.push(ModelEdit.moveElement(textFlow,child,listItem,listItem.numChildren));
+					// normalize does this
+					if (listItem.normalizeNeedsInitialParagraph())
+						_mementoList.push(ModelEdit.addElement(textFlow,ElementHelper.getParagraph(),listItem,0));
+				}
+				else
+					_mementoList.push(ModelEdit.moveElement(textFlow,child,_listElement,_listElement.numChildren));
+			}
+			else
+			{
+				_mementoList.push(ModelEdit.addElement(textFlow,_listElement,target,endChildIndex));
+				
+				// normalize does this
+				if ((target is IListItemElement) && (target as IListItemElement).normalizeNeedsInitialParagraph())
+				{
+					_mementoList.push(ModelEdit.addElement(textFlow,ElementHelper.getParagraph(),target,0));
+					begChildIndex++;
+					endChildIndex++;
+				}
+
+				if (begChildIndex == endChildIndex)
+				{
+					listItem = ElementHelper.getListItem();	// No PMD
+					_mementoList.push(ModelEdit.addElement(textFlow,listItem,_listElement,0));
+					_mementoList.push(ModelEdit.addElement(textFlow,ElementHelper.getParagraph(),listItem,0));					
+				}
+				else
+				{
+					while (begChildIndex < endChildIndex)
+					{
+						child = target.getChildAt(begChildIndex) as IFlowGroupElement;
+						if (child is IListItemElement)
+						{
+							listItem = child as IListItemElement;
+							_mementoList.push(ModelEdit.moveElement(textFlow,listItem,_listElement,_listElement.numChildren));
+							if (!(listItem.getChildAt(0) is IParagraphElement))
+								_mementoList.push(ModelEdit.addElement(textFlow,ElementHelper.getParagraph(),listItem,0));
+						}
+						else
+						{
+							listItem = ElementHelper.getListItem();	// No PMD
+							_mementoList.push(ModelEdit.addElement(textFlow,listItem,_listElement,_listElement.numChildren));
+							_mementoList.push(ModelEdit.moveElement(textFlow,child,listItem,listItem.numChildren));
+							// normalize does this
+							if (listItem.normalizeNeedsInitialParagraph())
+								_mementoList.push(ModelEdit.addElement(textFlow,ElementHelper.getParagraph(),listItem,0));
+	
+							child = listItem;
+						}
+						child.normalizeRange(0,child.textLength);
+						endChildIndex--;
+					}
+				}
+				// normalize does this
+				var testListItem:IListItemElement = target as IListItemElement;
+				if (testListItem && testListItem.normalizeNeedsInitialParagraph())
+					_mementoList.push(ModelEdit.addElement(textFlow,ElementHelper.getParagraph(),testListItem,0));
+				testListItem = target.parent as IListItemElement;
+				if (testListItem && testListItem.normalizeNeedsInitialParagraph())
+					_mementoList.push(ModelEdit.addElement(textFlow,ElementHelper.getParagraph(),testListItem,0));
+			}
+			
+			if (originalSelectionState.selectionManagerOperationState && textFlow.interactionManager)
+			{
+				textFlow.normalize();
+				_postOpSelectionState = new SelectionState(textFlow,_listElement.getAbsoluteStart(),_listElement.getAbsoluteStart()+_listElement.textLength-1);
+				textFlow.interactionManager.setSelectionState(_postOpSelectionState);
+			}
+			
+			return true;
+		}
+
+		/** @private */
+		public override function undo():SelectionState
+		{
+			_mementoList.undo();
+			return originalSelectionState; 
+		}
+		
+		/** @private */
+		public override function redo():SelectionState
+		{
+			_mementoList.redo();
+			return _postOpSelectionState; 
+			
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/CreateSubParagraphGroupOperation.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/CreateSubParagraphGroupOperation.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/CreateSubParagraphGroupOperation.as
new file mode 100644
index 0000000..e33450b
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/CreateSubParagraphGroupOperation.as
@@ -0,0 +1,271 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.operations {
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.edit.ElementMark;
+	import org.apache.flex.textLayout.edit.MementoList;
+	import org.apache.flex.textLayout.edit.ModelEdit;
+	import org.apache.flex.textLayout.edit.SelectionState;
+	import org.apache.flex.textLayout.elements.IFlowGroupElement;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.ISpanElement;
+	import org.apache.flex.textLayout.elements.SubParagraphGroupElement;
+	import org.apache.flex.textLayout.elements.ISubParagraphGroupElementBase;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+
+
+
+
+	/**
+	 * The CreateSPGEOperation class encapsulates creating a SubPargraphGroupElement
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	public class CreateSubParagraphGroupOperation extends FlowTextOperation
+	{
+		// describes the target
+		private var _spgeParentMarker:ElementMark;
+		private var _format:ITextLayoutFormat;
+
+		private var _mementoList:MementoList;
+
+		// the element that gets created
+		private var _spgeElement:SubParagraphGroupElement;		
+		private var _postOpSelectionState:SelectionState;
+		
+		/** 
+		 * Constructor.
+		 * 
+		 * This operation creates a single SubParagraphGroupElement in the first paragraph of the selection range.  That paragraph must have at least one character selected the paragraph terminator does not count towards that selection.
+		 * Specifying the spgeParent creates an SubParagraphGroupElement int he part of the selection range included by that spgeParent.
+		 * 
+		 * @param operationState selection over which to apply the operation.  
+		 * @param spgeParent optional parent for the spge element.  If not specified one is chosen based on the selection
+		 * @param spgeFormat optional format to set in the new spge element.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		public function CreateSubParagraphGroupOperation(operationState:SelectionState, parent:IFlowGroupElement = null, format:ITextLayoutFormat = null)
+		{
+			super(operationState);
+			
+			_format = format;
+			this.parent = parent;
+			_mementoList = new MementoList(operationState.textFlow);
+		}
+		
+		/** 
+		 * Specifies the element this operation modifies.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.IFlowGroupElement
+		 */
+		public function get parent():IFlowGroupElement
+		{
+			return _spgeParentMarker ? _spgeParentMarker.findElement(originalSelectionState.textFlow) as IFlowGroupElement : null;
+		}
+		public function set parent(value:IFlowGroupElement):void
+		{
+			if (!value)
+			{
+				// descend to the lowest level non-paragraph element that contains both positions
+				// effectively make the new spge as close to the spans as possible
+				
+				var begPos:int = this.absoluteStart;
+				var endPos:int = this.absoluteEnd;
+				
+				// start with the ParagraphElement
+				var para:IParagraphElement = textFlow.findLeaf(begPos).getParagraph();
+				var paraStart:int = para.getAbsoluteStart();
+				
+				// can't be just the terminator
+				if (begPos < paraStart+para.textLength-1)
+				{
+					// Only work in this ParagraphElement - include the terminator if it was excluded
+					if (endPos >= paraStart+para.textLength-1)
+						endPos = paraStart+para.textLength;
+					
+					value = para;
+					
+					for (;;)
+					{
+						var begChildIdx:int = value.findChildIndexAtPosition(begPos);
+						var elem:IFlowGroupElement = value.getChildAt(begChildIdx) as IFlowGroupElement;
+						if (elem == null)
+							break;
+						begPos -= elem.parentRelativeStart;
+						endPos -= elem.parentRelativeStart;
+						if (endPos > elem.textLength)	// end pos is in the next element.  can be at the beginning
+							break;
+						value = elem;
+					}
+				}
+			}
+			else if (!(value is ISubParagraphGroupElementBase) || !(value is IParagraphElement))
+				value = null;
+			
+			_spgeParentMarker = value ? new ElementMark(value,0) : null;
+		}
+		
+		/** Format to be applied to the new SubParagraphGroupElement
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */		
+		public function get format():ITextLayoutFormat
+		{ return _format; }
+		public function set format(value:ITextLayoutFormat):void
+		{ _format = value; }
+		
+		/** The new SubParagraphGroupElement. 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */	
+		public function get newSubParagraphGroupElement():SubParagraphGroupElement
+		{ return _spgeElement; }
+		
+		/**
+		 *  @private
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.IFlowGroupElement
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.ISpanElement
+		 */
+		public override function doOperation():Boolean
+		{
+			if (absoluteStart == absoluteEnd)
+				return false;
+			
+			var target:IFlowGroupElement = this.parent;
+			if (!target)
+				return false;
+			
+			// find the starting child that's going to be in the list and 
+			var begChildIndex:int = 0;
+			var begStart:int = absoluteStart - target.getAbsoluteStart();
+			CONFIG::debug { assert(begStart >= 0 && begStart < target.textLength,"CreateSPGEOperation: bad target"); }
+			
+			var endChildIndex:int;
+			var endStart:int = absoluteEnd - target.getAbsoluteStart();
+			if (endStart >= target.getAbsoluteStart()+target.textLength-1)
+				endStart = target.getAbsoluteStart()+target.textLength;
+			
+			// scratch vars
+			var child:IFlowElement;
+			
+			if (begStart > 0)
+			{
+				// figure out the starting child
+				begChildIndex = target.findChildIndexAtPosition(begStart);
+				child = target.getChildAt(begChildIndex);
+				if (child.parentRelativeStart != begStart)
+				{				
+					if (child is IFlowGroupElement)
+						_mementoList.push(ModelEdit.splitElement(textFlow,child as IFlowGroupElement,begStart-child.parentRelativeStart));
+					else
+						child.splitAtPosition(begStart-child.parentRelativeStart);
+					begChildIndex++;
+				}
+			}
+			
+			if (endStart >= 0)
+			{
+				if (endStart >= target.textLength - 1)
+				{
+					endChildIndex = target.numChildren;
+					// if last element in target is a span with just a terminator than go before it
+					if (endChildIndex != 0)
+					{
+						var lastChild:IFlowElement = target.getChildAt(endChildIndex-1);
+						if (lastChild is ISpanElement && lastChild.textLength == 1 && (lastChild as ISpanElement).hasParagraphTerminator)
+							endChildIndex--;
+					}
+				}
+				else
+				{
+					// figure out the starting child
+					endChildIndex = target.findChildIndexAtPosition(endStart);
+					child = target.getChildAt(endChildIndex);
+					if (child.parentRelativeStart != endStart)			
+					{
+						if (child is IFlowGroupElement)
+							_mementoList.push(ModelEdit.splitElement(textFlow,child as IFlowGroupElement,endStart-child.parentRelativeStart));
+						else
+							child.splitAtPosition(endStart-child.parentRelativeStart);
+						endChildIndex++;
+					}
+				}
+			}
+			else
+				endChildIndex = begChildIndex+1;
+			
+			_spgeElement = new SubParagraphGroupElement;
+			_spgeElement.format = format;
+			
+			
+			CONFIG::debug { assert(begChildIndex != target.numChildren,"Invalid begChildIndex in CreateSPGEOperation"); }
+
+			_mementoList.push(ModelEdit.addElement(textFlow,_spgeElement,target,endChildIndex));
+			{
+				while (begChildIndex < endChildIndex)
+				{
+					child = target.getChildAt(begChildIndex);
+					if (child.textLength == 0)
+					{
+						// skip it
+						begChildIndex++;
+					}
+					else
+					{
+						_mementoList.push(ModelEdit.moveElement(textFlow,child,_spgeElement,_spgeElement.numChildren));
+						endChildIndex--;
+					}
+				}
+			}
+			
+			if (originalSelectionState.selectionManagerOperationState && textFlow.interactionManager)
+			{
+				textFlow.normalize();
+				_postOpSelectionState = new SelectionState(textFlow,_spgeElement.getAbsoluteStart(),_spgeElement.getAbsoluteStart()+_spgeElement.textLength);
+				textFlow.interactionManager.setSelectionState(_postOpSelectionState);
+			}
+			
+			return true;
+		}
+
+		/** @private */
+		public override function undo():SelectionState
+		{
+			_mementoList.undo();
+			return originalSelectionState; 
+		}
+		
+		/** @private */
+		public override function redo():SelectionState
+		{
+			_mementoList.redo();
+			return _postOpSelectionState; 
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/CutOperation.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/CutOperation.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/CutOperation.as
new file mode 100644
index 0000000..1844cce
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/CutOperation.as
@@ -0,0 +1,98 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.operations {
+	import org.apache.flex.textLayout.edit.SelectionState;
+	import org.apache.flex.textLayout.edit.TextScrap;
+
+
+
+
+	
+	/**
+	 * The CutOperation class encapsulates a cut operation.
+	 *
+	 * <p>The specified range is removed from the text flow.</p>
+	 * 
+	 * <p><b>Note:</b> The edit manager is responsible for copying the 
+	 * text scrap to the clipboard. Undoing a cut operation does not restore
+	 * the original clipboard state.</p>
+	 * 
+	 * @see org.apache.flex.textLayout.edit.EditManager
+	 * @see org.apache.flex.textLayout.events.FlowOperationEvent
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	public class CutOperation extends FlowTextOperation
+	{
+		private var _tScrap:TextScrap;
+		private var _deleteTextOperation:DeleteTextOperation;
+		
+		/** 
+		 * Creates a CutOperation object.
+		 * 
+		 * @param operationState The range of text to be cut.
+		 * @param scrapToCut A copy of the deleted text.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		function CutOperation(operationState:SelectionState, scrapToCut:TextScrap)
+		{
+			super(operationState);
+			if (absoluteStart < absoluteEnd)
+				_tScrap = scrapToCut;
+		}
+		
+		
+		/** @private */
+		public override function doOperation():Boolean
+		{
+			_deleteTextOperation = new DeleteTextOperation(originalSelectionState);
+			return _deleteTextOperation.doOperation();
+		}
+		
+		/** @private */
+		public override function undo():SelectionState
+		{
+			return _deleteTextOperation.undo();
+		}
+	
+		/** @private */
+		public override function redo():SelectionState
+		{
+			return _deleteTextOperation.redo();
+		}
+		
+		/** 
+		 * scrapToCut the original removed text
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		public function get scrapToCut():TextScrap
+		{ return _tScrap; }
+		public function set scrapToCut(val:TextScrap):void
+		{ _tScrap = val; }
+		
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/DeleteTextOperation.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/DeleteTextOperation.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/DeleteTextOperation.as
new file mode 100644
index 0000000..ccaf729
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/DeleteTextOperation.as
@@ -0,0 +1,159 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.operations {
+	import org.apache.flex.textLayout.edit.IMemento;
+	import org.apache.flex.textLayout.edit.ModelEdit;
+	import org.apache.flex.textLayout.edit.PointFormat;
+	import org.apache.flex.textLayout.edit.SelectionState;
+
+	
+
+
+	/**
+	 * The DeleteTextOperation class encapsulates the deletion of a range of text.
+	 *
+	 * @see org.apache.flex.textLayout.edit.EditManager
+	 * @see org.apache.flex.textLayout.events.FlowOperationEvent
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	public class DeleteTextOperation extends FlowTextOperation
+	{
+		private var _memento:IMemento;
+		private var _allowMerge:Boolean;
+		private var _pendingFormat:PointFormat;
+		
+		private var _deleteSelectionState:SelectionState = null;
+		/** 
+		 * Creates a DeleteTextOperation operation.
+		 * 
+		 * @param operationState The original range of text.
+		 * @param deleteSelectionState The range of text to delete, if different from the range 
+		 * described by <code>operationState</code>. (Set to <code>null</code> to delete the range
+		 * described by <code>operationState</code>.)
+		 * @param allowMerge Set to <code>true</code> if this operation can be merged with the next or previous operation.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		public function DeleteTextOperation(operationState:SelectionState, deleteSelectionState:SelectionState = null, allowMerge:Boolean = false)
+		{
+			_deleteSelectionState = deleteSelectionState ? deleteSelectionState : operationState;				
+			
+			super(_deleteSelectionState);
+			originalSelectionState = operationState;
+			_allowMerge = allowMerge;
+		}
+		
+		/** 
+		 * Indicates whether this operation can be merged with operations executed before or after it.
+		 * 
+		 * <p>Some delete operations, for example, a sequence of backspace keystrokes, can be fruitfully 
+		 * merged into one operation so that undoing the operation reverses the entire sequence.</p>
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		*/
+		public function get allowMerge():Boolean
+		{
+			return _allowMerge;
+		}
+		public function set allowMerge(value:Boolean):void
+		{
+			_allowMerge = value;
+		}
+		
+		/** 
+		 * deleteSelectionState The range of text to delete
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		*/
+		public function get deleteSelectionState():SelectionState
+		{
+			return _deleteSelectionState;
+		}
+		public function set deleteSelectionState(value:SelectionState):void
+		{
+			_deleteSelectionState = value;
+		}
+		
+		/** @private */
+		public override function doOperation():Boolean
+		{
+			// Nothing to delete
+			if (absoluteStart == absoluteEnd)
+				return false;
+				
+			_pendingFormat = PointFormat.createFromFlowElement(textFlow.findLeaf(absoluteStart));
+			if (_pendingFormat.linkElement)		// don't propagate links or tcy from deleted text
+				_pendingFormat.linkElement = null;
+			if (_pendingFormat.tcyElement)		// don't propagate links or tcy from deleted text
+				_pendingFormat.tcyElement = null;
+						
+			_memento = ModelEdit.deleteText(textFlow, absoluteStart, absoluteEnd, true);
+			
+			if (originalSelectionState.selectionManagerOperationState && textFlow.interactionManager)
+			{
+				// set pointFormat from leafFormat
+				var state:SelectionState = textFlow.interactionManager.getSelectionState();
+				if (state.anchorPosition == state.activePosition)
+				{
+					state.pointFormat = PointFormat.clone(_pendingFormat);
+					textFlow.interactionManager.setSelectionState(state);
+				}
+			}
+
+			return true;	
+		}
+		
+		/** @private */
+		public override function undo():SelectionState
+		{
+			if (_memento)
+				_memento.undo();
+			return originalSelectionState;				
+		}
+	
+		/** @private */
+		public override function redo():SelectionState
+		{
+			if (_memento)
+				_memento.redo();
+			return new SelectionState(textFlow,absoluteStart,absoluteStart,_pendingFormat);	
+		}
+
+		/** @private */
+		public override function merge(op2:FlowOperation):FlowOperation
+		{
+			if (this.endGeneration != op2.beginGeneration)
+					return null;
+			var delOp:DeleteTextOperation = op2 as DeleteTextOperation;
+			if ((delOp == null) || !delOp.allowMerge || !_allowMerge)
+				return null;
+				
+			return new CompositeOperation([this, op2]);
+		}	
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/FlowElementOperation.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/FlowElementOperation.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/FlowElementOperation.as
new file mode 100644
index 0000000..444cf65
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/FlowElementOperation.as
@@ -0,0 +1,236 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.operations {
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.edit.SelectionState;
+	import org.apache.flex.textLayout.elements.FlowGroupElement;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	import org.apache.flex.textLayout.elements.SpanElement;
+	
+	/**
+	 * The FlowElementOperation class is the base class for operations that transform a FlowElement.
+	 *
+	 * @see org.apache.flex.textLayout.formats.TextLayoutFormat
+	 * @see org.apache.flex.textLayout.edit.EditManager
+	 * @see org.apache.flex.textLayout.events.FlowOperationEvent
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	public class FlowElementOperation extends FlowTextOperation
+	{	
+		private var nestLevel:int;
+		private var absStart:int;
+		private var absEnd:int;
+		
+		private var origAbsStart:int;
+		private var origAbsEnd:int;
+		
+		private var firstTime:Boolean = true;
+		private var splitAtStart:Boolean = false;
+		private var splitAtEnd:Boolean = false;
+		
+		private var _relStart:int = 0;
+		private var _relEnd:int = -1;
+		
+		/** 
+		 * Creates a FlowElementOperation object.
+		 *  
+		 * @param operationState Specifies the TextFlow object this operation acts upon.
+		 * @param targetElement Specifies the element this operation modifies.
+		 * @param relativeStart An offset from the beginning of the <code>targetElement</code>.
+		 * @param relativeEnd An offset from the end of the <code>targetElement</code>.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		*/
+		public function FlowElementOperation(operationState:SelectionState, targetElement:IFlowElement, relativeStart:int = 0, relativeEnd:int = -1)
+		{
+			super(operationState);
+			initialize(targetElement,relativeStart,relativeEnd);
+			
+			CONFIG::debug { assert(targetElement.getTextFlow() == operationState.textFlow, "ChangeElementIdOperation element is not part of selectionState TextFlow"); }
+		}
+		
+		
+		private function initialize(targetElement:IFlowElement, relativeStart:int, relativeEnd:int ):void
+		{
+			this.targetElement = targetElement;
+			this.relativeEnd = relativeEnd;
+			this.relativeStart = relativeStart;
+			
+			if (relativeEnd == -1)
+				relativeEnd = targetElement.textLength;
+				
+			CONFIG::debug { assert(relativeStart >= 0 && relativeStart <= targetElement.textLength,"ChangeElementIdOperation bad relativeStart"); } 
+			CONFIG::debug { assert(relativeEnd >= 0 && relativeEnd <= targetElement.textLength,"ChangeElementIdOperation bad relativeEnd"); } 
+			CONFIG::debug { assert(relativeStart <= relativeEnd,"ChangeElementIdOperation relativeStart not before relativeEnd"); } 
+
+			// If we're changing the format of the text right before the terminator, change the terminator to match.
+			// This will make it so that when the format change is undone, the terminator will be restored to previous state. Also
+			// prevents unnecessary split & join of spans (split for apply, joined during normalize).
+			if (targetElement is SpanElement && SpanElement(targetElement).hasParagraphTerminator && relativeEnd == targetElement.textLength - 1)
+				relativeEnd += 1;
+				
+			origAbsStart = absStart = targetElement.getAbsoluteStart() + relativeStart;
+			origAbsEnd   = absEnd   = absStart - relativeStart + relativeEnd;
+
+			
+		}
+		
+		/** 
+		 * Specifies the element this operation modifies.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		*/
+		public function get targetElement():IFlowElement
+		{
+			var element:IFlowElement = originalSelectionState.textFlow;
+			for (var i:int = nestLevel; i > 0; i--)
+			{
+				var groupElement:FlowGroupElement = element as FlowGroupElement;
+				element = groupElement.getChildAt(groupElement.findChildIndexAtPosition(absStart - element.getAbsoluteStart()));
+			}
+			return element;
+		}
+		public function set targetElement(value:IFlowElement):void
+		{
+			nestLevel = 0;
+			for (var element:IFlowElement = value; element.parent != null; element = element.parent)
+				++nestLevel;
+		}
+		
+	
+		/** 
+		 * An offset from the beginning of the <code>targetElement</code>.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		*/
+		public function get relativeStart():int
+		{
+			return _relStart;
+		}
+		public function set relativeStart(value:int):void
+		{
+			_relStart = value;
+		}
+		
+		/** 
+		 * An offset from the start of the <code>targetElement</code>.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		*/
+		public function get relativeEnd():int
+		{
+			return _relEnd;
+		}
+		public function set relativeEnd(value:int):void
+		{
+			_relEnd = value;
+		}
+		
+		
+		/** @private */
+		protected function getTargetElement():IFlowElement
+		{
+			var element:IFlowElement = this.targetElement;
+			
+			var elemStart:int = element.getAbsoluteStart();
+			var splitElement:IFlowElement;	// scratch
+			// split at the back and then split at the start - that way paragraph terminators don't get in the way
+			if (absEnd != elemStart + element.textLength)
+			{
+				splitElement = element.splitAtPosition(absEnd - elemStart);
+				if (firstTime && splitElement != element)
+					splitAtEnd = true;
+			}
+				
+			if (absStart != elemStart)
+			{
+				splitElement = element.splitAtPosition(absStart-elemStart);
+				if (splitElement != element)
+				{
+					if (firstTime)
+						splitAtStart = true;
+					element = splitElement;
+				}
+			}
+			
+			firstTime = false;	
+			return element;
+		}
+		
+		
+		/** @private */
+		protected function adjustForDoOperation(targetElement:IFlowElement):void
+		{
+			// adjust for undo
+			absStart = targetElement.getAbsoluteStart();
+			absEnd   = absStart + targetElement.textLength;
+		}	
+		
+		/** @private */
+		protected function adjustForUndoOperation(targetElement:IFlowElement):void
+		{
+			// need to do manual merging
+			if ((splitAtEnd || splitAtStart) && (targetElement is FlowGroupElement))
+			{
+				var targetIdx:int = targetElement.parent.getChildIndex(targetElement);
+				var workElem:FlowGroupElement;
+				var child:IFlowElement;
+				
+				if (splitAtEnd)
+				{
+					// merge next to targetElement
+					workElem = targetElement.parent.getChildAt(targetIdx+1) as FlowGroupElement;
+					while (workElem.numChildren)
+					{
+						child = workElem.getChildAt(0);
+						workElem.removeChildAt(0);
+						FlowGroupElement(targetElement).addChild(child);
+					}
+					targetElement.parent.removeChildAt(targetIdx+1);
+				}
+				if (splitAtStart)
+				{
+					// merge targetElement to prevElement
+					workElem = targetElement.parent.getChildAt(targetIdx-1) as FlowGroupElement;
+					while (FlowGroupElement(targetElement).numChildren)
+					{
+						child = FlowGroupElement(targetElement).getChildAt(0);
+						FlowGroupElement(targetElement).removeChildAt(0);
+						workElem.addChild(child);
+					}
+					targetElement.parent.removeChildAt(targetIdx);
+				}
+			}
+			
+			absStart = origAbsStart;
+			absEnd   = origAbsEnd;
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/FlowOperation.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/FlowOperation.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/FlowOperation.as
new file mode 100644
index 0000000..249ca60
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/FlowOperation.as
@@ -0,0 +1,241 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.operations
+{
+	import org.apache.flex.utils.undo.IOperation;
+	import org.apache.flex.textLayout.edit.SelectionState;
+
+
+
+
+	//
+	// Considered several ways of doing undo/redo
+	// 1 - object model level - stashing copies of all changed objects in the model and restoring them
+	// 2 - cookies - saving an audit trail of every modified property of the model objects
+	// 3 - operations - each operation creates an object that knows how to do/undo/redo itself
+	// going with # 3 for now
+	//
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.textLayout.edit.IEditManager;
+
+	/** 
+	 * The FlowOperation class is the base class for all Text Layout Framework operations. 
+	 * 
+	 * <p>Operations are transformations of a text flow. An Operation class defines the
+	 * logic for performing and undoing the transformation. Operations are executed by an
+	 * edit manager. Most applications do not need to create or manage operations directly
+	 * (unless implementing a custom edit manager).</p>
+	 * 
+	 * <p>When an operation is performed, the edit manager dispatches an Operation object 
+	 * within the FlowOperationEvent object. You can query 
+	 * this Operation object to decide whether or not to allow the operation, to decide whether 
+	 * to perform some other operation as well, or to update related user-interface elements.</p>
+	 * 
+	 * @see org.apache.flex.textLayout.events.FlowOperationEvent
+	 * @see org.apache.flex.textLayout.edit.EditManager
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	public class FlowOperation implements IOperation
+	{
+		/** 
+		 * Arbitrary data associated with an element. 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		public var userData:*;
+		
+		// uint or null
+		private var _beginGeneration:uint;
+		private var _endGeneration:uint;
+		
+		private var _textFlow:ITextFlow;		// target of the operation
+
+		/** 
+		 * Creates the FlowOperation object.
+		 * 
+		 * @param textFlow	The text flow to which this operation is applied.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		public function FlowOperation(textFlow:ITextFlow)
+		{
+			_textFlow = textFlow;
+		}
+		
+		/** 
+		 * The ITextFlow object to which this operation is applied.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		public function get textFlow():ITextFlow
+		{ return _textFlow; }
+		public function set textFlow(value:ITextFlow):void
+		{ _textFlow = value; }
+		
+		/** 
+		 * Executes the operation. 
+		 * 
+		 * <p>This method must be overridden in derived classes. The base class method does nothing.
+		 * You should not call <code>doOperation()</code> directly. The edit manager 
+		 * calls the method when it executes the operation. </p>
+		 * 
+		 * @return Boolean <code>true</code>, if the operation succeeded. Otherwise, <code>false</code>.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		public function doOperation():Boolean
+		{
+			return false;
+		}
+		
+		/**	
+		 * Reverses the operation. 
+		 * 
+		 * <p>This method must be overridden in derived classes. The base class method does nothing.
+		 * You should not call <code>undo()</code> directly. The edit manager 
+		 * calls the method when it reverses the operation. </p>
+		 * 
+		 * @return The SelectionState object passed to the operation when it was performed. This
+		 * SelectionState object can be the current selection or a selection created specifically
+		 * for the operation. 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		public function undo():SelectionState
+		{
+			return null;
+		}
+		
+		/**	
+		 * Test if this operation be placed on the undo stack.
+		 * 
+		 * @return true means to push the operation onto the undo stack.  false means do not push this operation.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public function canUndo():Boolean
+		{ return true; }
+		
+		/**	
+		 * Re-executes the operation. 
+		 * 
+		 * <p>This method must be overridden in derived classes. The base class method does nothing.
+		 * You should not call <code>redo()</code> directly. The edit manager 
+		 * calls the method when it re-executes the operation. </p>
+		 * 
+		 * @return The SelectionState object passed to the operation when it was performed. This
+		 * SelectionState object can be the current selection or a selection created specifically
+		 * for the operation. 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		public function redo():SelectionState
+		{
+			return null;
+		}
+		
+		// Generation numbers
+		
+		/**
+		 * The text flow generation before the operation.
+		 *   
+		 * <p>A generation of 0 indicates that the operation did not complete.</p>
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		*/
+		public function get beginGeneration():uint
+		{ return _beginGeneration; }
+		/** 
+		 * The text flow generation after the operation.
+		 * 
+		 * <p>A generation of 0 indicates that the operation did not complete.</p>
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		*/
+		public function get endGeneration():uint
+		{ return _endGeneration; }
+
+		/** @private */
+		public function performUndo():void
+		{
+			var editManager:IEditManager = textFlow ? textFlow.interactionManager as IEditManager : null;
+			if (editManager != null)
+			{
+				editManager.performUndo(this);
+			}
+		}
+
+		/** @private */
+		public function performRedo():void
+		{
+			var editManager:IEditManager = textFlow ? textFlow.interactionManager as IEditManager : null;
+			if (editManager != null)
+			{
+				editManager.performRedo(this);
+			}
+		}
+		
+		/** @private -- Sets the generation numbers into the operation.  */
+		public function setGenerations(beginGeneration:uint,endGeneration:uint):void
+		{
+			_beginGeneration = beginGeneration;
+			_endGeneration   = endGeneration;
+		}
+		
+		/**
+		 * @private
+		 * 
+		 *  Combine this operation with another operation if the result can 
+		 *  be represented as a single operation.  In general, operations cannot be 
+		 *  merged. But sequential inserts or deletes may be mergeable.
+		 * 
+		 *  Merging may occur through updating the properties of the operation
+		 *  on which this method is called, by creating a new operation.
+		 * 
+		 *  @param operation 	The FlowOperation to merge against
+		 *  @return A FlowOperation representing the combined operation if 
+		 *  the merge was successful, null otherwise.
+		 */
+		public function merge(operation:FlowOperation):FlowOperation	// No PMD
+		{
+			return null;
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/FlowTextOperation.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/FlowTextOperation.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/FlowTextOperation.as
new file mode 100644
index 0000000..7e21be2
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/FlowTextOperation.as
@@ -0,0 +1,122 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.operations {
+	import org.apache.flex.textLayout.edit.SelectionState;
+
+
+
+
+	//
+	// Considered several ways of doing undo/redo
+	// 1 - object model level - stashing copies of all changed objects in the model and restoring them
+	// 2 - cookies - saving an audit trail of every modified property of the model objects
+	// 3 - operations - each operation creates an object that knows how to do/undo/redo itself
+	// going with # 3 for now
+	//
+
+	/** 
+	 * The FlowTextOperation is the base class for operations that transform a range of text.
+	 * 
+	 * @see org.apache.flex.textLayout.edit.EditManager
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	public class FlowTextOperation extends FlowOperation
+	{
+		private var _originalSelectionState:SelectionState;
+		private var _absoluteStart:int;
+		private var _absoluteEnd:int;
+
+		/** 
+		 * Creates the FlowTextOperation object.
+		 * 
+		 * @param operationState Specifies the relevant selection. If relevant to the operation, the 
+		 * <code>operationState</code> describes the text range to which this operation applies.
+		 * Otherwise, <code>operationState</code> is used to save the current selection state so that
+		 * it can be restored when the operation is undone.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		public function FlowTextOperation(operationState:SelectionState)
+		{
+			super(operationState.textFlow);
+			_absoluteStart = operationState.absoluteStart;
+			_absoluteEnd = operationState.absoluteEnd;
+			_originalSelectionState = operationState;
+		}
+				
+		/** 
+		 * The absolute start point of the range of text to which this operation is applied.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		*/
+		public function get absoluteStart():int
+		{ return _absoluteStart; }
+		public function set absoluteStart(value:int):void
+		{ _absoluteStart = value; }
+		
+		/** 
+		 * The absolute end point of the range of text to which this operation is applied. 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		*/
+		public function get absoluteEnd():int
+		{ return _absoluteEnd; }
+		public function set absoluteEnd(value:int):void
+		{ _absoluteEnd = value; }
+		
+		/** 
+		 * The selection state at the start of the operation. 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		*/
+		public function get originalSelectionState():SelectionState
+		{
+			return _originalSelectionState;
+		}
+		public function set originalSelectionState(value:SelectionState):void
+		{
+			_originalSelectionState = value;
+		}
+		
+		/**	
+		 * @inheritDoc
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		override public function redo():SelectionState
+		{
+			doOperation();
+			return _originalSelectionState;
+		}
+		
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/InsertInlineGraphicOperation.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/InsertInlineGraphicOperation.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/InsertInlineGraphicOperation.as
new file mode 100644
index 0000000..bb5d9f5
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/InsertInlineGraphicOperation.as
@@ -0,0 +1,232 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.operations {
+	import org.apache.flex.textLayout.edit.ElementRange;
+	import org.apache.flex.textLayout.edit.ParaEdit;
+	import org.apache.flex.textLayout.edit.PointFormat;
+	import org.apache.flex.textLayout.edit.SelectionState;
+	import org.apache.flex.textLayout.elements.IFlowGroupElement;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	import org.apache.flex.textLayout.elements.IFlowLeafElement;
+	import org.apache.flex.textLayout.elements.IInlineGraphicElement;
+	import org.apache.flex.textLayout.elements.ISubParagraphGroupElementBase;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+
+
+
+
+	
+
+	/**
+	 * The InsertInlineGraphicOperation class encapsulates the insertion of an inline
+	 * graphic into a text flow.
+	 *
+	 * @see org.apache.flex.textLayout.elements.IInlineGraphicElement
+	 * @see org.apache.flex.textLayout.edit.EditManager
+	 * @see org.apache.flex.textLayout.events.FlowOperationEvent
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	public class InsertInlineGraphicOperation extends FlowTextOperation
+	{
+		private var delSelOp:DeleteTextOperation; 
+		private var _source:Object;
+		private var imageWidth:Object;
+		private var imageHeight:Object;
+		private var _options:Object;
+		private var selPos:int = 0;
+		private var _inlineGraphicElement:IInlineGraphicElement;
+		
+		/** 
+		 * Creates an InsertInlineGraphicsOperation object.
+		 * 
+		 * @param operationState Describes the insertion point. 
+		 * If a range is selected, the operation deletes the contents of that range.
+		 * @param	source	The graphic source (uri string, URLRequest, DisplayObject, or Class of an embedded asset). 
+		 * @param	width	The width to assign (number of pixels, percent, or the string 'auto')
+		 * @param	height	The height to assign (number of pixels, percent, or the string 'auto')
+		 * @param	options	The float to assign (String value, none for inline with text, left/right/start/end for float)
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		public function InsertInlineGraphicOperation(operationState:SelectionState, source:Object, width:Object, height:Object, options:Object = null)
+		{
+			super(operationState);
+			
+			if (absoluteStart != absoluteEnd)
+				delSelOp = new DeleteTextOperation(operationState);
+				
+			_source = source;
+			_options = options;
+			imageWidth = width;
+			imageHeight = height;
+		}
+		
+		/**	
+		 * @copy org.apache.flex.textLayout.elements.IInlineGraphicElement#source
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+ 		 */
+		public function get source():Object
+		{
+			return _source;
+		}
+		public function set source(value:Object):void
+		{
+			_source = value;
+		}
+
+		/** 
+		 * @copy org.apache.flex.textLayout.elements.IInlineGraphicElement#width
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		public function get width():Object
+		{
+			return imageWidth;
+		}
+		public function set width(value:Object):void
+		{
+			imageWidth = value;
+		}
+
+		/** 
+		 * @copy org.apache.flex.textLayout.elements.IInlineGraphicElement#height
+		 * 
+		 * @see org.apache.flex.textLayout.IInlineGraphicElement#height
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		*/
+		public function get height():Object
+		{
+			return imageHeight;
+		}
+		public function set height(value:Object):void
+		{
+			imageHeight = value;
+		}
+		
+		/** 
+		 * @copy org.apache.flex.textLayout.elements.IInlineGraphicElement#float
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		*/
+		public function get options():Object
+		{
+			return _options;
+		}
+		public function set options(value:Object):void
+		{
+			_options = value;
+		}
+
+		/** 
+		 * The IInlineGraphicElement that was created by doOperation.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public function get newInlineGraphicElement():IInlineGraphicElement
+		{
+			return _inlineGraphicElement;
+		}
+		
+		/** @private */
+		public override function doOperation():Boolean
+		{
+			var pointFormat:ITextLayoutFormat;
+			
+			selPos = absoluteStart;
+			if (delSelOp) 
+			{
+				var leafEl:IFlowLeafElement = textFlow.findLeaf(absoluteStart);
+				var deleteFormat:PointFormat = new PointFormat(textFlow.findLeaf(absoluteStart).format);
+				if (delSelOp.doOperation())
+					pointFormat = deleteFormat;
+			}
+			else
+				pointFormat = originalSelectionState.pointFormat;
+				
+			// lean left logic included
+			var range:ElementRange = ElementRange.createElementRange(textFlow,selPos, selPos);		
+			var leafNode:IFlowElement = range.firstLeaf;
+			var leafNodeParent:IFlowGroupElement = leafNode.parent;
+			while (leafNodeParent is ISubParagraphGroupElementBase)
+			{
+				var subParInsertionPoint:int = selPos - leafNodeParent.getAbsoluteStart();
+				if (((subParInsertionPoint == 0) && (!(leafNodeParent as ISubParagraphGroupElementBase).acceptTextBefore())) ||
+					((subParInsertionPoint == leafNodeParent.textLength) && (!(leafNodeParent as ISubParagraphGroupElementBase).acceptTextAfter())))
+				{
+					leafNodeParent = leafNodeParent.parent;
+				} else {
+					break;
+				}
+			}
+			
+			_inlineGraphicElement = ParaEdit.createImage(leafNodeParent, selPos - leafNodeParent.getAbsoluteStart(), _source, imageWidth, imageHeight, options, pointFormat);
+			if (textFlow.interactionManager)
+				textFlow.interactionManager.notifyInsertOrDelete(absoluteStart, 1);
+			
+			return true;
+		}
+	
+		/** @private */
+		public override function undo():SelectionState
+		{
+			var leafNode:IFlowElement = textFlow.findLeaf(selPos);
+			var leafNodeParent:IFlowGroupElement = leafNode.parent;
+			var elementIdx:int = leafNode.parent.getChildIndex(leafNode);
+			leafNodeParent.replaceChildren(elementIdx, elementIdx + 1, null);			
+					
+			if (textFlow.interactionManager)
+				textFlow.interactionManager.notifyInsertOrDelete(absoluteStart, -1);
+
+			return delSelOp ? delSelOp.undo() : originalSelectionState; 
+		}
+
+		/**
+		 * Re-executes the operation after it has been undone.
+		 * 
+		 * <p>This function is called by the edit manager, when necessary.</p>
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		public override function redo():SelectionState
+		{ 
+			doOperation();
+			return new SelectionState(textFlow,selPos+1,selPos+1,null);
+		}
+
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/InsertTableElementOperation.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/InsertTableElementOperation.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/InsertTableElementOperation.as
new file mode 100644
index 0000000..81e487e
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/InsertTableElementOperation.as
@@ -0,0 +1,134 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.operations {
+	import org.apache.flex.textLayout.elements.IFlowGroupElement;
+	import org.apache.flex.textLayout.edit.MementoList;
+	import org.apache.flex.textLayout.edit.ModelEdit;
+	import org.apache.flex.textLayout.edit.PointFormat;
+	import org.apache.flex.textLayout.edit.SelectionState;
+	import org.apache.flex.textLayout.elements.FlowGroupElement;
+	import org.apache.flex.textLayout.elements.ITableElement;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+
+	
+
+	
+	public class InsertTableElementOperation extends FlowTextOperation
+	{
+//		private var delSelOp:DeleteTextOperation; 
+		private var _table:ITableElement;
+		private var selPos:int = 0;
+		private var _mementoList:MementoList;
+		private var _postOpSelectionState:SelectionState;
+//		private var _listParentMarker:ElementMark;
+		
+		public function InsertTableElementOperation(operationState:SelectionState, table:ITableElement)
+		{
+			super(operationState);
+			
+			_mementoList = new MementoList(operationState.textFlow);
+			_table = table;
+		}
+		
+		/** @private */
+		public override function doOperation():Boolean
+		{
+			var pointFormat:ITextLayoutFormat;
+			
+			selPos = absoluteStart;
+			if (absoluteStart != absoluteEnd) 
+			{
+//				var leafEl:FlowLeafElement = textFlow.findLeaf(absoluteStart);
+				var deleteFormat:PointFormat = new PointFormat(textFlow.findLeaf(absoluteStart).format);
+				
+				_mementoList.push(ModelEdit.deleteText(textFlow,absoluteStart,absoluteEnd,true));
+				pointFormat = deleteFormat;
+			}
+			else
+				pointFormat = originalSelectionState.pointFormat;
+			
+			
+			var target:IFlowGroupElement = textFlow;
+			
+			var begStart:int = absoluteStart;
+			var begChildIndex:int = 0;
+			var endChildIndex:int;
+			
+			// scratch vars
+			var child:FlowGroupElement;
+			
+			if(begStart >= 0)
+			{
+				// figure out the starting child
+				begChildIndex = target.findChildIndexAtPosition(begStart);
+				child = target.getChildAt(begChildIndex) as FlowGroupElement;
+				_mementoList.push(ModelEdit.splitElement(textFlow,child,begStart-child.parentRelativeStart));
+			}
+			
+			if (begStart >= target.textLength - 1)
+				endChildIndex = target.numChildren;
+			else
+				endChildIndex = begChildIndex+1;
+			
+			
+			if (begChildIndex == target.numChildren)
+			{
+				// new list at the end of target
+				child = target.getChildAt(target.numChildren-1) as FlowGroupElement;
+				
+				_mementoList.push(ModelEdit.addElement(textFlow,_table,target,target.numChildren));
+			}
+			else
+			{
+				_mementoList.push(ModelEdit.addElement(textFlow,_table,target,endChildIndex));
+			}
+			
+			if (originalSelectionState.selectionManagerOperationState && textFlow.interactionManager)
+			{
+				textFlow.normalize();
+				_postOpSelectionState = new SelectionState(textFlow,_table.getAbsoluteStart(),_table.getAbsoluteStart()+_table.textLength-1);
+				textFlow.interactionManager.setSelectionState(_postOpSelectionState);
+			}
+			
+			return true;
+		}
+		
+		/** @private */
+		public override function undo():SelectionState
+		{
+			_mementoList.undo();
+			return originalSelectionState;  
+		}
+		
+		/**
+		 * Re-executes the operation after it has been undone.
+		 * 
+		 * <p>This function is called by the edit manager, when necessary.</p>
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0 
+		 */
+		public override function redo():SelectionState
+		{ 
+			_mementoList.redo();
+			return _postOpSelectionState;
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/InsertTextOperation.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/InsertTextOperation.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/InsertTextOperation.as
new file mode 100644
index 0000000..9ac121c
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/InsertTextOperation.as
@@ -0,0 +1,299 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.operations {
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	import org.apache.flex.textLayout.elements.IFlowLeafElement;
+	import org.apache.flex.textLayout.edit.ModelEdit;
+	import org.apache.flex.textLayout.edit.ParaEdit;
+	import org.apache.flex.textLayout.edit.PointFormat;
+	import org.apache.flex.textLayout.edit.SelectionState;
+	import org.apache.flex.textLayout.edit.TextFlowEdit;
+	import org.apache.flex.textLayout.elements.ISpanElement;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+
+
+
+
+
+	/**
+	 * The InsertTextOperation class encapsulates a text insertion operation.
+	 *
+	 * @see org.apache.flex.textLayout.edit.EditManager
+	 * @see org.apache.flex.textLayout.events.FlowOperationEvent
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	public class InsertTextOperation extends FlowTextOperation
+	{
+		private var _deleteSelectionState:SelectionState;
+		private var delSelOp:DeleteTextOperation = null; 
+		/** @private - this should be private but too late for code changes on Labs */
+		public var _text:String;
+		
+		private var _pointFormat:ITextLayoutFormat;
+			
+		/** 
+		 * Creates an InsertTextOperation object.
+		 * 
+		 * @param operationState Describes the insertion point or range of text.
+		 * @param text The string to insert.
+		 * @param deleteSelectionState Describes the range of text to delete before doing insertion, 
+		 * if different than the range described by <code>operationState</code>.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */	
+		public function InsertTextOperation(operationState:SelectionState, text:String, deleteSelectionState:SelectionState = null)
+		{
+			super(operationState);
+			
+			_pointFormat = operationState.pointFormat;
+			_text = text;
+			
+			initialize(deleteSelectionState);
+		}
+		
+		private function initialize(deleteSelectionState:SelectionState):void
+		{	
+			if (deleteSelectionState == null)
+				deleteSelectionState = originalSelectionState;
+			if (deleteSelectionState.anchorPosition != deleteSelectionState.activePosition)
+			{
+				_deleteSelectionState = deleteSelectionState;
+				delSelOp = new DeleteTextOperation(_deleteSelectionState);
+			}
+		}
+		
+		/** 
+		 * The text inserted by this operation. 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		*/
+		public function get text():String
+		{
+			return _text;
+		}
+		public function set text(value:String):void
+		{
+			_text = value;
+		}
+		
+		/** 
+		 * The text deleted by this operation, if any.
+		 * 
+		 * <p><code>null</code> if no text is deleted.</p>
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		*/
+		public function get deleteSelectionState():SelectionState
+		{
+			return _deleteSelectionState;
+		}
+		public function set deleteSelectionState(value:SelectionState):void
+		{
+			_deleteSelectionState = value;
+		}
+		
+		/** 
+		 * The character format applied to the inserted text.
+		 *  
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		*/
+		public function get characterFormat():ITextLayoutFormat
+		{
+			return _pointFormat;
+		}
+		public function set characterFormat(value:ITextLayoutFormat):void
+		{
+			_pointFormat = new PointFormat(value);
+		}
+		
+		private function doDelete(leaf:IFlowLeafElement):ITextLayoutFormat
+		{			
+			// User selected a range of text and is replacing it. We're doing the delete here.
+			// We preserve the format from the deleted text, and apply it to the text insert,
+			// unless the user has specified an alternate format.
+			var deleteFormat:PointFormat = PointFormat.createFromFlowElement(textFlow.findLeaf(absoluteStart));
+			var beforeDeleteFormat:PointFormat = absoluteStart == leaf.getParagraph().getAbsoluteStart() ? null : PointFormat.createFromFlowElement(textFlow.findLeaf(absoluteStart - 1));
+
+			if (delSelOp.doOperation())		// figure out what to do here
+			{
+				//do not change characterFormat if user specified one already, or if its the same as in the surrounding text.
+				// If the surrounding text is the same, forcing the point format requires more composition because it inserts
+				// the text in its own span.
+				if (!_pointFormat && (absoluteStart < absoluteEnd) && PointFormat.isEqual(deleteFormat, beforeDeleteFormat))
+					deleteFormat = null;
+				else 
+				{
+					// If the leaf element is empty, remove it now
+					if (leaf.textLength == 0) 
+						leaf.parent.removeChild(leaf);
+				}
+			} 
+			return deleteFormat;
+		}
+				
+		private function applyPointFormat(span:ISpanElement, pointFormat:ITextLayoutFormat):void
+		{
+			if (!TextLayoutFormat.isEqual(pointFormat, span.format))
+			{
+				var spanFormat:TextLayoutFormat = new TextLayoutFormat(span.format);
+				spanFormat.apply(pointFormat);
+				span.format = spanFormat;
+			}
+			if (pointFormat is PointFormat)
+			{
+				var pf:PointFormat = pointFormat as PointFormat;
+				if (pf.linkElement)
+				{
+					if (pf.linkElement.href)
+					{
+						TextFlowEdit.makeLink(textFlow, absoluteStart, absoluteStart + _text.length, pf.linkElement.href, pf.linkElement.target);
+						var linkLeaf:IFlowLeafElement = textFlow.findLeaf(absoluteStart);
+						var linkElement:IFlowElement = linkLeaf.getParentByType("LinkElement");
+						linkElement.format = pf.linkElement.format;
+					}
+				}
+				if (pf.tcyElement)
+				{
+						TextFlowEdit.makeTCY(textFlow, absoluteStart, absoluteStart + _text.length);
+						var tcyLeaf:IFlowLeafElement = textFlow.findLeaf(absoluteStart);
+						var tcyElement:IFlowElement = tcyLeaf.getParentByType("TCYElement");
+						tcyElement.format = pf.tcyElement.format;
+				}
+				else if (span.getParentByType("TCYElement"))
+					TextFlowEdit.removeTCY(textFlow, absoluteStart, absoluteStart + _text.length);
+			}
+		}
+		private function doInternal():void
+		{
+			var deleteFormat:ITextLayoutFormat;
+			
+			if (delSelOp != null) 
+				deleteFormat = doDelete(textFlow.findLeaf(absoluteStart));
+						
+			var span:ISpanElement = ParaEdit.insertText(textFlow, absoluteStart, _text, _pointFormat != null || deleteFormat != null/* createNewSpan */);
+			if (textFlow.interactionManager)
+				textFlow.interactionManager.notifyInsertOrDelete(absoluteStart, _text.length);
+			
+			if (span != null)
+			{
+				if (deleteFormat)
+				{
+					span.format = deleteFormat;
+					applyPointFormat(span, deleteFormat);
+					if ((deleteFormat is PointFormat) && PointFormat(deleteFormat).linkElement && PointFormat(deleteFormat).linkElement.href && originalSelectionState.selectionManagerOperationState && textFlow.interactionManager)
+					{
+						// set pointFormat from leafFormat, to insure link attributes are propagated from replaced text to next insertion
+						// if I select a range of text in a link, and type over it to replace, the new text should be in a link with the same settings.
+						var state:SelectionState = textFlow.interactionManager.getSelectionState();
+						state.pointFormat = PointFormat.clone(deleteFormat as PointFormat);
+						textFlow.interactionManager.setSelectionState(state);
+					}
+				}
+				if (_pointFormat)
+					applyPointFormat(span, _pointFormat);
+			}
+		}
+		
+		/** @private */
+		public override function doOperation():Boolean
+		{
+			doInternal();
+			return true;
+		}
+	
+		/** @private */
+		public override function undo():SelectionState
+		{ 
+			ModelEdit.deleteText(textFlow, absoluteStart, absoluteStart + _text.length, false);
+			
+			var newSelectionState:SelectionState = originalSelectionState;
+			if (delSelOp != null)
+				newSelectionState = delSelOp.undo();
+			
+			return originalSelectionState;
+		}
+		
+		/**
+		 * Re-executes the operation after it has been undone.
+		 * 
+		 * <p>This function is called by the edit manager, when necessary.</p>
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		public override function redo():SelectionState
+		{ 
+			doInternal();
+			return new SelectionState(textFlow,absoluteStart+_text.length,absoluteStart+_text.length,null);
+		}
+
+		/** @private */
+		public override function merge(op2:FlowOperation):FlowOperation
+		{
+			if (absoluteStart < absoluteEnd)
+				return null;
+			if (this.endGeneration != op2.beginGeneration)
+				return null;
+			// We are assuming here that these operations are contiguous, because
+			// SelectionManager doesn't try to merge operations if the selection
+			// has changed
+			var insertOp:InsertTextOperation = null;
+			if (op2 is InsertTextOperation)
+				insertOp = op2 as InsertTextOperation;
+			if (insertOp)
+			{
+				if (insertOp.deleteSelectionState != null || deleteSelectionState != null)
+					return null;
+				if ((insertOp.originalSelectionState.pointFormat == null) && (originalSelectionState.pointFormat != null))
+					return null;
+				if ((originalSelectionState.pointFormat == null) && (insertOp.originalSelectionState.pointFormat != null))
+					return null;
+				if (originalSelectionState.absoluteStart + _text.length != insertOp.originalSelectionState.absoluteStart)
+					return null;
+				if (((originalSelectionState.pointFormat == null) && (insertOp.originalSelectionState.pointFormat == null)) ||
+					(PointFormat.isEqual(originalSelectionState.pointFormat, insertOp.originalSelectionState.pointFormat)))
+				{
+					_text += insertOp.text;
+					setGenerations(beginGeneration,insertOp.endGeneration);
+				}
+				else
+					return null;
+				setGenerations(beginGeneration,insertOp.endGeneration);
+				return this;
+			}
+			
+			if (op2 is SplitParagraphOperation)
+				return new CompositeOperation([this,op2]);
+
+			return null;
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ModifyInlineGraphicOperation.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ModifyInlineGraphicOperation.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ModifyInlineGraphicOperation.as
new file mode 100644
index 0000000..ca73633
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/operations/ModifyInlineGraphicOperation.as
@@ -0,0 +1,166 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.operations {
+	import org.apache.flex.textLayout.edit.SelectionState;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	import org.apache.flex.textLayout.elements.IFlowGroupElement;
+	import org.apache.flex.textLayout.elements.InlineGraphicElement;
+
+	/**
+	 * The InsertInlineGraphicOperation class encapsulates the modification of an existing inline graphic.
+	 *
+	 * @see org.apache.flex.textLayout.elements.InlineGraphicElement
+	 * @see org.apache.flex.textLayout.edit.EditManager
+	 * @see org.apache.flex.textLayout.events.FlowOperationEvent
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0 
+	 */
+	public class ModifyInlineGraphicOperation extends FlowTextOperation
+	{ 
+		private var _source:Object;
+		private var imageWidth:Object;
+		private var imageHeight:Object;
+		private var _options:Object;
+		private var oldImage:IFlowElement;
+		private var selPos:int = 0;
+		
+		/** 
+		 * Creates a ModifyInlineGraphicsOperation object.
+		 * 
+		 * @param operationState Describes the insertion point. 
+		 * If a range is selected, the operation deletes the contents of that range.
+		 * @param	source	The graphic source (uri string, URLRequest, DisplayObject, or Class of an embedded asset). 
+		 * @param	width	The width to assign (number of pixels, percent, or the string 'auto')
+		 * @param	height	The height to assign (number of pixels, percent, or the string 'auto')
+		 * @param	options	None supported
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		 */
+		function ModifyInlineGraphicOperation(operationState:SelectionState, source:Object, width:Object, height:Object, options:Object = null)
+		{
+			super(operationState);
+							
+			_source = source;
+			_options = options;
+			imageWidth = width;
+			imageHeight = height;
+		}
+		
+		/**	
+		 * @copy org.apache.flex.textLayout.elements.InlineGraphicElement#source
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+ 		 */
+		public function get source():Object
+		{
+			return _source;
+		}
+		public function set source(value:Object):void
+		{
+			_source = value;
+		}
+
+		/** 
+		 * @copy org.apache.flex.textLayout.elements.InlineGraphicElement#width
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		*/
+		public function get width():Object
+		{
+			return imageWidth;
+		}
+		public function set width(value:Object):void
+		{
+			imageWidth = value;
+		}
+
+		/** 
+		 * @copy org.apache.flex.textLayout.elements.InlineGraphicElement#height
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		*/
+		public function get height():Object
+		{
+			return imageHeight;
+		}
+		public function set height(value:Object):void
+		{
+			imageHeight = value;
+		}
+		
+		/** 
+		 * options are not supported
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0 
+		*/
+		public function get options():Object
+		{
+			return _options;
+		}
+		public function set options(value:Object):void
+		{
+			_options = value;
+		}
+		
+		/** @private */
+		public override function doOperation():Boolean
+		{
+			selPos = absoluteStart;
+			var img:InlineGraphicElement = textFlow.findLeaf(selPos) as InlineGraphicElement;
+			if (img)
+			{
+				oldImage = img.shallowCopy(0,1);
+				// only update changed things
+				if (img.width != imageWidth)
+					img.width = imageWidth;
+				if (img.height != imageHeight)
+					img.height = imageHeight;
+				if (img.source != _source)
+					img.source = _source;
+				if (options && img.float != options.toString())
+					img.float = options.toString();
+			}
+			
+			return true;	
+		}
+	
+		/** @private */
+		public override function undo():SelectionState
+		{
+			var leafNode:IFlowElement = textFlow.findLeaf(selPos);
+			var leafNodeParent:IFlowGroupElement = leafNode.parent;
+			var elementIdx:int = leafNode.parent.getChildIndex(leafNode);
+			leafNodeParent.replaceChildren(elementIdx, elementIdx + 1, oldImage);			
+
+			return originalSelectionState; 
+		}
+	}
+}
\ No newline at end of file


[14/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableElement.as
new file mode 100644
index 0000000..d759bbe
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableElement.as
@@ -0,0 +1,1582 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements {
+	import org.apache.flex.textLayout.compose.ITextFlowTableBlock;
+	import org.apache.flex.textLayout.compose.TextFlowTableBlock;
+	import org.apache.flex.textLayout.events.ModelChange;
+	import org.apache.flex.textLayout.formats.FormatValue;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+
+	import org.apache.flex.utils.ObjectMap;
+	import org.apache.flex.textLayout.elements.ITableCellElement;
+	
+	/** 
+	 * The TableElement class is used for grouping together items into a table. 
+	 * A TableElement's children must be of type TableRowElement, TableColElement, TableColGroupElement, TableBodyElement.
+	 * 
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 *
+	 */
+	public class TableElement extends TableFormattedElement implements ITableElement
+	{
+		
+		private var _computedWidth:Number;
+		
+		public var x:Number;
+		public var y:Number;
+		
+		private var columns:Vector.<ITableColElement> = new Vector.<ITableColElement>();
+		private var rows:Vector.<ITableRowElement> = new Vector.<ITableRowElement>();
+//		private var damagedColumns:Vector.<TableColElement> = new Vector.<TableColElement>();
+//		private var damageRows:Vector.<ITableRowElement> = new Vector.<ITableRowElement>();
+		private var _hasCellDamage:Boolean = true;
+		
+		private var _headerRowCount:uint = 0;
+		private var _footerRowCount:uint = 0;
+		private var _tableRowsComputed:Boolean;
+		
+		private var _headerRows:Vector.< Vector.<ITableCellElement> >;
+		private var _footerRows:Vector.< Vector.<ITableCellElement> >;
+		private var _bodyRows:Vector.< Vector.<ITableCellElement> >;
+		private var _composedRowIndex:uint = 0;
+		
+		private var _tableBlocks:Vector.<ITextFlowTableBlock>;
+		private var _tableBlockIndex:uint = 0;
+		private var _tableBlockDict:ObjectMap;
+		
+		private var _leaf:TableLeafElement;
+		
+		public function TableElement()
+		{
+			super();
+		}
+		
+		override public function get className():String
+		{
+			return "TableElement";
+		}
+		
+		/** @private */
+		override protected function get abstract():Boolean
+		{ return false; }
+		
+		/** @private */
+		public override function get defaultTypeName():String
+		{ return "table"; }
+		
+		/** @private */
+		public override function canOwnFlowElement(elem:IFlowElement):Boolean
+		{
+			return (elem is ITableCellElement) || (elem is ITableRowElement) || (elem is ITableColElement);// || (elem is TableBodyElement) || (elem is TableColGroupElement);
+		}
+		
+		/** @private if its in a numbered list expand the damage to all list items - causes the numbers to be regenerated */
+		public override function modelChanged(changeType:String, elem:IFlowElement, changeStart:int, changeLen:int, needNormalize:Boolean = true, bumpGeneration:Boolean = true):void
+		{
+			if (changeType==ModelChange.ELEMENT_ADDED) {
+				
+			}
+			else if (changeType==ModelChange.ELEMENT_REMOVAL) {
+				if (headerRowCount > 0 || footerRowCount > 0) {
+					
+				}
+			}
+			
+			super.modelChanged(changeType,elem,changeStart,changeLen,needNormalize,bumpGeneration);
+		}
+		
+		override public function set cellSpacing(cellSpacingValue:*):void
+		{
+			
+			markCellsDamaged();
+			hasCellDamage = true;
+			normalizeCells();
+			
+			super.cellSpacing = cellSpacingValue;
+		}
+		
+		public function get numRows():int
+		{
+			return rows.length;
+		}
+		
+		public function get numColumns():int
+		{
+			return columns.length;
+		}
+		
+		/**
+		 * Total number of cells
+		 **/
+		public function get numCells():int
+		{
+			return getCells().length;
+		}
+		
+		/**
+		 * Total number of rows in the table. If set to a value lower than
+		 * the current number of rows the rows at the end of the table are removed. 
+		 * If the set to a value greater than the current number of rows additional
+		 * rows are added to the table. 
+		 **/
+		public function set numRows(value:int):void
+		{
+			while(value < numRows){
+				rows.pop();
+			}
+			var num:int = numRows;
+			for(var i:int = num;i<value;i++) {
+				var row:ITableRowElement = createRowElement(i, defaultRowFormat);
+				rows.push(row);
+			}
+		}
+
+		/**
+		 * Total number of columns in the table. If set to a value lower than
+		 * the current number of columns the columns at the end of the table are removed. 
+		 * If the set to a value greater than the current number of columns additional
+		 * columns are added to the table. 
+		 **/
+		public function set numColumns(value:int):void
+		{
+			while(value < numColumns){
+				columns.pop();
+			}
+			var num:int = numColumns;
+			for(var i:int = num;i<value;i++) {
+				var column:TableColElement = createColumnElement(i, defaultColumnFormat);
+				columns.push(column);
+			}
+		}
+		private var _defaultRowFormat:ITextLayoutFormat;
+
+		/**
+		 * Gets the row format for new rows. 
+		 **/
+		public function get defaultRowFormat():ITextLayoutFormat
+		{
+			if(!_defaultRowFormat)
+				_defaultRowFormat = new TextLayoutFormat(computedFormat);
+			return _defaultRowFormat;
+		}
+
+		public function set defaultRowFormat(value:ITextLayoutFormat):void
+		{
+			_defaultRowFormat = value;
+		}
+		
+		private var _defaultColumnFormat:ITextLayoutFormat;
+
+		/**
+		 * Gets the column format for new columns. 
+		 **/
+		public function get defaultColumnFormat():ITextLayoutFormat
+		{
+			if(!_defaultColumnFormat)
+				_defaultColumnFormat = new TextLayoutFormat(computedFormat);
+			return _defaultColumnFormat;
+		}
+
+		public function set defaultColumnFormat(value:ITextLayoutFormat):void
+		{
+			_defaultColumnFormat = value;
+		}
+		
+		/**
+		 * Adds a table cell element to the table. 
+		 * @inheritDoc
+		 **/
+		override public function addChild(child:IFlowElement):IFlowElement
+		{
+			
+			if (child is TableFormattedElement) {
+				TableFormattedElement(child).table = this;
+			}
+			
+			super.addChild(child);
+			
+			return child;
+		}
+		
+		/**
+		 * Removes a table cell element from the table. 
+		 * @inheritDoc
+		 **/
+		override public function removeChild(child:IFlowElement):IFlowElement
+		{
+			super.removeChild(child);
+			
+			if (child is TableFormattedElement) {
+				TableFormattedElement(child).table = null;
+			}
+			
+			return child;
+		}
+		
+		/**
+		 * Add a row at the end of the table. You would use this if you want to add a row
+		 * without changing the table cells. 
+		 * @see addRowAt
+		 * @see insertRow
+		 * @see insertRowAt
+		 **/
+		public function addRow(format:ITextLayoutFormat=null):void{
+			addRowAt(rows.length,format);
+		}
+		
+		/**
+		 * Add a row at the index specified. 
+		 * @see addRow
+		 * @see insertRow
+		 * @see insertRowAt
+		 **/
+		public function addRowAt(idx:int, format:ITextLayoutFormat=null):void{
+			if(idx < 0 || idx > rows.length)
+				throw RangeError(GlobalSettings.resourceStringFunction("badPropertyValue"));
+			
+			var row:ITableRowElement = createRowElement(idx, format);
+			rows.splice(idx, 0, row);
+			row.composedHeight = row.computedFormat.minCellHeight;
+			row.isMaxHeight = row.computedFormat.minCellHeight == row.computedFormat.maxCellHeight;
+			row.setParentAndRelativeStartOnly(this, 1);
+		}
+
+		/**
+		 * Adds a column. You would use this if you want to add a column without changing the table cells. 
+		 * The cells would reflow, so a cell in row 2 might move up to row 1.
+		 * @see addColumnAt
+		 * @see insertColumn
+		 * @see insertColumnAt
+		 **/
+		public function addColumn(format:ITextLayoutFormat=null):void{
+			addColumnAt(columns.length,format);
+		}
+		
+		/**
+		 * Adds a column at the index specified. 
+		 * @see addColumn
+		 * @see insertColumn
+		 * @see insertColumnAt
+		 **/
+		public function addColumnAt(idx:int, format:ITextLayoutFormat=null):void{
+			if(idx < 0 || idx > columns.length)
+				throw RangeError(GlobalSettings.resourceStringFunction("badPropertyValue"));
+			if(!format) {
+				format = defaultColumnFormat;
+			}
+			var column:TableColElement = createColumnElement(idx, format);
+			
+			columns.splice(idx, 0, column);
+		}
+
+		/**
+		 * Returns the column at the index specified or null if the index is out of range. 
+		 **/
+		public function getColumnAt(columnIndex:int):ITableColElement
+		{
+			if ( columnIndex < 0 || columnIndex >= numColumns )
+				return null;
+			return columns[columnIndex];
+		}
+		
+		/**
+		 * Returns the row at the index specified or null if the index is out of range. 
+		 **/
+		public function getRowAt(rowIndex:int):ITableRowElement
+		{
+			if ( rowIndex < 0 || rowIndex >= numRows )
+				return null;
+			return rows[rowIndex];
+		}
+		
+		/**
+		 * Return the index of the row provided or -1 if the row is not found. 
+		 **/
+		public function getRowIndex(row:ITableRowElement):int
+		{
+			for(var i:int=0;i<rows.length;i++)
+			{
+				if(rows[i] == row)
+					return i;
+			}
+			return -1;
+		}
+		
+		/**
+		 * Returns a vector of the cells for the row specified. 
+		 **/
+		public function getCellsForRow(row:ITableRowElement):Vector.<ITableCellElement>{
+			
+			return getCellsForRowAt(row.rowIndex);
+		}
+		
+		/**
+		 * Returns a vector of the cells for the row specified. 
+		 **/
+		public function getCellsForRowArray(row:ITableRowElement):Array {
+			
+			return getCellsForRowAtArray(row.rowIndex);
+		}
+		
+		/**
+		 * Returns a vector of the cells for the row at the specified index. 
+		 **/
+		public function getCellsForRowAt(index:int):Vector.<ITableCellElement>{
+			var cells:Vector.<ITableCellElement> = new Vector.<ITableCellElement>();
+			
+			if (index < 0) {
+				return cells;
+			}
+			
+			for each(var cell:ITableCellElement in mxmlChildren){
+				if (cell.rowIndex == index) {
+					cells.push(cell);
+				}
+			}
+			
+			return cells;
+		}
+		
+		/**
+		 * Returns an array of the cells for the row specified. 
+		 **/
+		public function getCellsForRowAtArray(index:int):Array {
+			var cells:Array = [];
+			
+			if (index < 0) {
+				return cells;
+			}
+			
+			for each(var cell:ITableCellElement in mxmlChildren){
+				if (cell.rowIndex == index) {
+					cells.push(cell);
+				}
+			}
+			
+			return cells;
+		}
+		
+		/**
+		 * Returns a Vector of the TableCellElements for the column specified. 
+		 **/
+		public function getCellsForColumn(column:ITableColElement):Vector.<ITableCellElement> {
+			if(columns.indexOf(column) < 0)
+				return null;
+			
+			return getCellsForColumnAt(column.colIndex);
+		}
+		
+		/**
+		 * Returns a Vector of the TableCellElements for the column at the specified index. 
+		 **/
+		public function getCellsForColumnAt(index:int):Vector.<ITableCellElement> {
+			var cells:Vector.<ITableCellElement> = new Vector.<ITableCellElement>();
+			
+			if (index < 0) {
+				return cells;
+			}
+			
+			for each(var cell:ITableCellElement in mxmlChildren){
+				if (cell.colIndex == index) {
+					cells.push(cell);
+				}
+			}
+			
+			return cells;
+		}
+		
+		/**
+		 * Convenience method for checking if table has merged cells
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.ITableCellElement
+		 */
+		public function hasMergedCells():Boolean
+		{
+			var cell:ITableCellElement;
+			var child:*;
+			if(mxmlChildren == null)
+				return false;
+			for each(child in mxmlChildren)
+			{
+				cell = child as ITableCellElement;
+				if( cell && (cell.columnSpan > 1 || cell.rowSpan > 1) )
+					return true;
+			}
+			return false;
+		}
+		
+		/**
+		 * Inserts a column at the end of the table. If a column is not provided one is created. 
+		 * 
+		 * @see addColumn
+		 * @see addColumnAt
+		 * @see insertColumnAt
+		 **/
+		public function insertColumn(column:TableColElement=null,cells:Array = null):Boolean{
+			return insertColumnAt(numColumns,column,cells);
+		}
+		
+		/**
+		 * Inserts a column at the column specified. If the column is not provided it
+		 * creates a new column containing the cells supplied or creates the cells
+		 * based on the number of rows in the table. 
+		 * @see addColumn
+		 * @see addColumnAt
+		 * @see insertColumn
+		 **/
+		public function insertColumnAt(idx:int,column:TableColElement=null,cells:Array = null):Boolean{
+			
+			if (idx < 0 || idx > columns.length) {
+				throw RangeError(GlobalSettings.resourceStringFunction("badPropertyValue"));
+			}
+			
+			if (!column) {
+				column = createColumnElement(idx, defaultColumnFormat);
+			}
+			
+			columns.splice(idx,0,column);
+			
+			var blockedCoords:Vector.<CellCoords> = getBlockedCoords(-1,idx);
+			var cellIdx:int = getCellIndex(0,idx);
+			if(cellIdx < 0)
+				cellIdx = numChildren;
+			var rowIdx:int = 0;
+			
+			if (cells==null) cells = []; 
+			
+			while(cells.length < numRows){
+				cells.push(ElementHelper.getTableCell());
+			}
+			
+			for each(var cell:ITableCellElement in cells){
+				while(blockedCoords.length && blockedCoords[0].row == rowIdx){
+					rowIdx++;
+					blockedCoords.shift();
+				}
+				cellIdx = getCellIndex(rowIdx,idx);
+				if(cellIdx < 0)
+				{
+					cellIdx = getCellIndex(rowIdx,idx-1);
+					cellIdx++;
+				}
+				
+				if(rowIdx < numRows){
+					addChildAt(cellIdx,cell);
+				}
+				rowIdx++;
+			}
+
+
+			return true;
+		}
+		
+		/**
+		 * Inserts a row at the end of the table. If a row is not provided one is created. 
+		 * @see insertRowAt
+		 **/
+		public function insertRow(row:ITableRowElement=null,cells:Array = null):Boolean{
+			return insertRowAt(numRows,row,cells);
+		}
+		
+		/**
+		 * Inserts a row at the index specified. If the row is not provided it
+		 * creates a new row containing the cells supplied or creates the cells
+		 * based on the number of columns in the table. 
+		 **/
+		public function insertRowAt(idx:int,row:ITableRowElement=null,cells:Array = null):Boolean{
+			if (idx < 0 || idx > rows.length) {
+				throw RangeError(GlobalSettings.resourceStringFunction("badPropertyValue"));
+			}
+			
+			if (!row) {
+				row = createRowElement(idx, defaultRowFormat);
+			}
+			
+			rows.splice(idx,0,row);
+			row.composedHeight = row.computedFormat.minCellHeight;
+			row.isMaxHeight = row.computedFormat.minCellHeight == row.computedFormat.maxCellHeight;
+
+			var cellIdx:int = getCellIndex(idx,0);
+			if(cellIdx < 0)
+				cellIdx = numChildren;
+
+			var colIdx:int = 0;
+			
+			if (cells==null) cells = [];
+			
+			var cell:ITableCellElement;
+			// create more cells while tracking occupied columns of merged cells
+			var occupiedColumns:int = 0;
+			for each(cell in cells)
+				occupiedColumns += cell.columnSpan;
+
+			while(occupiedColumns < numColumns)
+			{
+				cells.push(ElementHelper.getTableCell());
+				occupiedColumns++;
+			}
+			
+			for each(cell in cells)
+			{
+				if(colIdx < numColumns)
+				{
+					addChildAt(cellIdx++,cell);
+					cell.damage();
+				}
+				colIdx += (cell.columnSpan-1);
+			}
+			return true;
+		}
+		
+		/**
+		 * Removes the row
+		 **/
+		public function removeRow(row:ITableRowElement):ITableRowElement {
+			var i:int = rows.indexOf(row);
+			if(i < 0)
+				return null;
+			return removeRowAt(i);
+		}
+		
+		/**
+		 * Removes the row and the cells it contains.
+		 **/
+		public function removeRowWithContent(row:ITableRowElement):Array
+		{
+			var i:int = rows.indexOf(row);
+			if(i < 0)
+				return null;
+			return removeRowWithContentAt(i);
+		}
+		
+		/**
+		 * Removes the row at the index specified.
+		 * @see removeRowWithContentAt
+		 **/
+		public function removeRowAt(idx:int):ITableRowElement {
+			if(idx < 0 || idx > rows.length - 1)
+				return null;
+			
+			var row:ITableRowElement = ITableRowElement(rows.splice(idx,1)[0]);
+			normalizeCells();
+			hasCellDamage = true;
+			return row;
+			
+		}
+		
+		/**
+		 * Removes the row at the index specified and the cells it contains.
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.ITableCellElement
+		 **/
+		public function removeRowWithContentAt(idx:int):Array
+		{
+
+			var removedCells:Array = [];
+			
+			if(mxmlChildren){
+				for (var i:int = mxmlChildren.length-1;i>=0;i--){
+					var child:* = mxmlChildren[i];
+					if(!(child is ITableCellElement))
+						continue;
+					var cell:ITableCellElement = child as ITableCellElement;
+					if(cell.rowIndex == idx){
+						removedCells.unshift(removeChild(cell));
+					}
+				}
+			}
+			
+			removeRowAt(idx);
+			return removedCells;
+		}
+		
+		/**
+		 * Removes all the rows and the cells.
+		 **/
+		public function removeAllRowsWithContent():void
+		{
+			var rowCount:int;
+//			var cellCount:int;
+			
+			if (numRows>-1) {
+				rowCount = numRows-1;
+				
+				for (;rowCount>-1;) {
+					removeRowWithContentAt(rowCount--);
+				}
+				
+			}
+		}
+		
+		/**
+		 * Removes all the rows. Does not remove the cells.
+		 * @see removeAllRowsWithContent
+		 **/
+		public function removeAllRows():void
+		{
+			var rowCount:int;
+//			var cellCount:int;
+			
+			if (numRows>-1) {
+				rowCount = numRows;
+				
+				for (var i:int; i < rowCount; i++) {
+					removeRowAt(i);
+				}
+				
+			}
+		}
+		
+		/**
+		 * Removes the column
+		 **/
+		public function removeColumn(column:ITableColElement):ITableColElement {
+			var i:int = columns.indexOf(column);
+			if(i < 0)
+				return null;
+			return removeColumnAt(i);
+		}
+		
+		/**
+		 * Removes the column and the cells it contains.
+		 **/
+		public function removeColumnWithContent(column:ITableColElement):Array
+		{
+			var i:int = columns.indexOf(column);
+			if(i < 0)
+				return null;
+			return removeColumnWithContentAt(i);
+		}
+
+		/**
+		 * Removes the column at the index specified
+		 **/
+		public function removeColumnAt(idx:int):ITableColElement {
+			if(idx < 0 || idx > columns.length - 1)
+				return null;
+			
+			var col:ITableColElement = columns.splice(idx,1)[0];
+			normalizeCells();
+			hasCellDamage = true;
+			return col;
+		}
+		
+		/**
+		 * Removes the column at the index specified and the cells it contains. 
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.ITableCellElement
+		 **/
+		public function removeColumnWithContentAt(idx:int):Array
+		{
+			
+			var removedCells:Array = [];
+			if(mxmlChildren){
+				for (var i:int = mxmlChildren.length-1;i>=0;i--){
+					var child:* = mxmlChildren[i];
+					if(!(child is ITableCellElement))
+						continue;
+					var cell:ITableCellElement = child as ITableCellElement;
+					if(cell.colIndex == idx){
+						removedCells.unshift(removeChild(cell));
+					}
+				}
+			}
+			removeColumnAt(idx);
+
+			return removedCells;
+		}
+		
+		/**
+		 * Remove all cells
+		 * @inheritDoc
+		 **/
+		override public function removed():void
+		{
+			hasCellDamage = true;
+			//removeAllRowsWithContent();
+		}
+		
+		/**
+		 * @private
+		 * Gets table coordinates which represents the space occupied by cells spanning rows or columns
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.ITableCellElement
+		 **/
+		private function getBlockedCoords(inRow:int = -1, inColumn:int = -1):Vector.<CellCoords>{
+			var coords:Vector.<CellCoords> = new Vector.<CellCoords>();
+			var curColumn:int = 0;
+			if(mxmlChildren) {
+				for each(var child:* in mxmlChildren){
+					var cell:ITableCellElement = child as ITableCellElement;
+					if (cell==null) continue;
+					if(cell.columnSpan == 1 && cell.rowSpan == 1)
+						continue;
+					var curRow:int = cell.rowIndex;
+					if(inRow >= 0 && curRow != inRow)
+						continue;
+					if(inColumn >= 0 && inColumn != curColumn)
+						continue;
+					curColumn = cell.colIndex;
+					var endRow:int = curRow + cell.rowSpan - 1;
+					var endColumn:int = curColumn + cell.columnSpan -1;
+					for(var rowIdx:int = curRow;rowIdx <= endRow;rowIdx++){
+						for(var colIdx:int = curColumn;colIdx <=endColumn;colIdx++){
+							if(rowIdx == curRow && colIdx == curColumn){
+								continue;
+							}
+							coords.push( new CellCoords(colIdx, rowIdx) );
+						}
+					}
+
+				}
+			}
+			return coords;
+		}
+		
+		/**
+		 * Sets the row and column indices of the cells in the table to match their logical position as described by the table columns and rows
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.ITableCellElement
+		 **/
+		public function normalizeCells():void
+		{
+			this.numColumns;this.numRows;
+			var i:int;
+			var blockedCoords:Vector.<CellCoords> = new Vector.<CellCoords>();
+			
+			if (!mxmlChildren) {
+				return;
+			}
+			
+			var curRow:int = 0;
+			var curColumn:int = 0;
+			
+			for each(var child:* in mxmlChildren) {
+				
+				if (!(child is ITableCellElement)) {
+					continue;
+				}
+				
+				var cell:ITableCellElement = child as ITableCellElement;
+				
+				if (cell.rowIndex != curRow || cell.colIndex != curColumn) {
+					cell.rowIndex = curRow;
+					cell.colIndex = curColumn;
+					cell.damage();
+				}
+				
+				// add blocked coords if the cell spans rows or columns
+				var endRow:int = curRow + cell.rowSpan - 1;
+				var endColumn:int = curColumn + cell.columnSpan -1;
+				
+				for(var rowIdx:int = curRow;rowIdx <= endRow;rowIdx++){
+					for(var colIdx:int = curColumn;colIdx <=endColumn;colIdx++){
+						if(rowIdx == curRow && colIdx == curColumn){
+							continue;
+						}
+						blockedCoords.push(new CellCoords(colIdx,rowIdx) );
+					}
+				}
+				
+				// advance coordinates while checking blocked ones from spans
+				do {
+					curColumn++;
+					
+					if (curColumn >= numColumns){
+						curColumn = 0;
+						curRow++;
+					}
+					
+					var advanced:Boolean = true;
+					
+					for (i=0;i<blockedCoords.length;i++){
+						if(blockedCoords[i].column == curColumn && blockedCoords[i].row == curRow){
+							advanced = false;
+							blockedCoords.splice(i,1);
+						}
+					}
+					
+					if (advanced) {
+						break;
+					}
+					
+				} while(1);
+				
+			}
+			
+		}
+		
+		/**
+		 * Set the width of the specified column. The value can be a number or percent. 
+		 **/
+		public function setColumnWidth(columnIndex:int, value:*):Boolean
+		{
+			//TODO: changing the column width probably requires a recompose of all cells in that column. Mark the cells in that row damaged.
+			var tableColElement:ITableColElement = getColumnAt(columnIndex);
+			if ( ! tableColElement )
+				return false;
+			
+			tableColElement.tableColumnWidth = value;
+			return true;
+		}
+		
+		/**
+		 * Set the height of the specified row. The value can be a number or percent. 
+		 **/
+		public function setRowHeight(rowIdx:int, value:*):Boolean{
+			//TODO: setting the row height might change the composition height of the cells. We'll need to do some housekeeping here.
+			// I'm not sure this function makes sense. We need to handle both min and max values to allow for expanding cells.
+			var row:ITableRowElement = getRowAt(rowIdx);
+			if(!row)
+				return false;
+			
+			return true;
+		}
+		
+		/**
+		 * Get the width of the column. 
+		 **/
+		public function getColumnWidth(columnIndex:int):*
+		{
+			var tableColElement:TableColElement = getColumnAt(columnIndex) as TableColElement;
+			if ( tableColElement )
+				return tableColElement.tableColumnWidth;
+			return 0;
+        }
+		
+		/**
+		 * Sizes and positions the cells in the table. 
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.ITableCellElement
+		 **/
+		public function composeCells():void{
+			normalizeCells();
+			_composedRowIndex = 0;
+			
+			// make sure the height that defines the row height did not change. If it did we might need to change the row height.
+			if(!hasCellDamage)
+				return;
+			var damagedCells:Vector.<ITableCellElement> = getDamagedCells();
+			var cell:ITableCellElement;
+			
+			for each(cell in damagedCells){
+				// recompose the cells while tracking row height if necessary
+				cell.compose();
+			}
+			
+			// set row heights to minimum
+			for each (var row:ITableRowElement in rows){
+				var minH:Number = row.computedFormat.minCellHeight;
+				var maxH:Number = row.computedFormat.maxCellHeight;
+				row.totalHeight = row.composedHeight = minH;
+				if(maxH > minH)
+					row.isMaxHeight = false;
+				else
+					row.isMaxHeight = true;
+				
+			}
+			
+			// set column positions...
+			var xPos:Number = 0;
+			for each (var col:TableColElement in columns){
+				col.x = xPos;
+				xPos += col.columnWidth;
+			}
+			
+			if (mxmlChildren) {
+				for(var i:int=0;i<mxmlChildren.length;i++){
+					if( !(mxmlChildren[i] is ITableCellElement) )
+						continue;
+					cell = mxmlChildren[i] as ITableCellElement;
+					while(rows.length < cell.rowIndex+1){
+						addRow(defaultRowFormat);
+					}
+					row = getRowAt(cell.rowIndex);
+					if(!row)
+						throw new Error("this should not happen...");
+					if(row.isMaxHeight) {
+						continue;
+					}
+					
+					var cellHeight:Number = cell.getComposedHeight();
+					if(cell.rowSpan > 1)
+					{
+						// figure out the total height taking into account fixed height rows and the total span.
+						
+						// for now, we're taking the easy way out assuming the rows are not fixed...
+						row.totalHeight = Math.max(row.totalHeight, cellHeight);
+						
+					}
+					else
+					{
+						row.composedHeight = Math.max(row.composedHeight, cellHeight);
+						row.composedHeight = Math.min(row.composedHeight, row.computedFormat.maxCellHeight);
+						row.totalHeight = Math.max(row.composedHeight, row.totalHeight);
+					}
+					if(row.composedHeight == row.computedFormat.maxCellHeight)
+						row.isMaxHeight = true;
+				}
+			}
+			
+			
+			if(!_tableRowsComputed)
+			{
+				// create arrays or rows to make table composition simpler
+				// For now we're assuming all cells have the correct row and column indices.
+				// For this assumption to remain valid, the interaction manager will have to update all indices when inserting rows and columns.
+				// actually, it probably makes sense for TableElement to handle that when adding rows and columns.
+				// we need to think this through.
+				_bodyRows = new Vector.< Vector.<ITableCellElement> >();
+				
+				if (mxmlChildren) {
+					for(i=0;i<mxmlChildren.length;i++){
+						
+						if ( !(mxmlChildren[i] is ITableCellElement) ) {
+							continue;
+						}
+						
+						cell = mxmlChildren[i] as ITableCellElement;
+						
+						while(cell.rowIndex >= _bodyRows.length)
+							_bodyRows.push(new Vector.<ITableCellElement>());
+							
+						var rowVec:Vector.<ITableCellElement> = _bodyRows[cell.rowIndex] as Vector.<ITableCellElement>;
+						
+						if(!rowVec){
+							rowVec = new Vector.<ITableCellElement>();
+							_bodyRows[cell.rowIndex] = rowVec;
+						}
+						
+						if(rowVec.length > cell.colIndex && rowVec[cell.colIndex]) {
+							throw new Error("Two cells cannot have the same coordinates");
+						}
+						
+						rowVec.push(cell);
+					}
+				}
+				
+				if(headerRowCount > 0){
+					_headerRows = _bodyRows.splice(0,headerRowCount);
+				} else {
+					_headerRows = null;
+				}
+				
+				if(footerRowCount > 0){
+					_footerRows = _bodyRows.splice(-footerRowCount,Number.MAX_VALUE);
+				} else {
+					_footerRows = null;
+				}
+			}
+		}
+		
+		/**
+		 * returns the header rows for composition
+		 **/
+		public function getHeaderRows():Vector.< Vector.<ITableCellElement> >{
+			return _headerRows;
+		}
+		
+		/**
+		 * returns the footer rows for composition
+		 **/
+		public function getFooterRows():Vector.< Vector.<ITableCellElement> >{
+			return _footerRows;
+		}
+		
+		/**
+		 * returns the body rows (sans header and footer cells) for composition
+		 **/
+		public function getBodyRows():Vector.< Vector.<ITableCellElement> >{
+			return _bodyRows;
+		}
+		
+		/**
+		 * returns a vector of table cells in the next row during composition
+		 **/
+		public function getNextRow():Vector.<ITableCellElement>{
+			if(_composedRowIndex >= _bodyRows.length)
+				return null;
+			return _bodyRows[_composedRowIndex++];
+		}
+		
+		/**
+		 * Returns the next table cell after the supplied table cell
+		 **/
+		public function getNextCell(tableCell:ITableCellElement):ITableCellElement {
+			var cell:ITableCellElement;
+			
+			for each (var element:IFlowElement in mxmlChildren) {
+				cell = element as ITableCellElement;
+				
+				if (cell) {
+					
+					// get next cell in same row 
+					if (cell.rowIndex==tableCell.rowIndex && cell.colIndex-1==tableCell.colIndex) {
+						return cell;
+					}
+					
+					// get first cell in next row
+					if (cell.rowIndex-1==tableCell.rowIndex && cell.colIndex==0) {
+						return cell;
+					}
+					
+				}
+			}
+			
+			return null;
+		}
+		
+		/**
+		 * Returns the previous table cell after the supplied table cell
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.ITableCellElement
+		 **/
+		public function getPreviousCell(tableCell:ITableCellElement):ITableCellElement {
+			var cell:ITableCellElement;
+			var highestCellIndex:int = -1;
+			var rowIndex:int = -1;
+			
+			for each (var element:IFlowElement in mxmlChildren) {
+				
+				if (element.className == "TableCellElement") {
+					cell = element as ITableCellElement;
+					// get previous cell in same row 
+					if (cell.rowIndex==tableCell.rowIndex && cell.colIndex+1==tableCell.colIndex) {
+						return cell;
+					}
+					
+					// get last cell in previous row
+					if (cell.rowIndex+1==tableCell.rowIndex) {
+						rowIndex = cell.rowIndex;
+						
+						if (highestCellIndex<cell.colIndex) {
+							highestCellIndex = cell.colIndex;
+						}
+					}
+					
+				}
+			}
+			
+			if (rowIndex>-1 && highestCellIndex>-1) {
+				return getCellAt(rowIndex, highestCellIndex);
+			}
+			
+			return null;
+		}
+		
+		/**
+		 * Returns the table cell at the row and column specified.
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.ITableCellElement
+		 **/
+		public function getCellAt(rowIndex:int, columnIndex:int):ITableCellElement {
+			var cell:ITableCellElement;
+			
+			for each (var element:IFlowElement in mxmlChildren) {
+				cell = element as ITableCellElement;
+				
+				if (cell && cell.rowIndex==rowIndex && cell.colIndex==columnIndex) {
+					return cell;
+				}
+			}
+			
+			return null;
+		}
+		
+		/**
+		 * Computed height of the header cells
+		 **/
+		public function getHeaderHeight():Number{
+			//TODO: compute the header height from the header cells
+			return 0;
+		}
+		
+		/**
+		 * Computed height of the footer cells
+		 **/
+		public function getFooterHeight():Number{
+			//TODO: compute the footer height from the footer cells
+			return 0;
+			
+		}
+		
+		/**
+		 * Accepts a suggested table width and calculates the column widths. 
+		 **/
+		public function normalizeColumnWidths(suggestedWidth:Number = 600):void{
+			//TODO: before composition make sure all column widths are rational numbers
+			// We feed in a width to use if there's no width otherwise specified.
+			
+			// quick and dirty...
+			var setCount:* = computedFormat.columnCount;
+			if(!setCount){
+				// we need to figure this out...
+			} else if(setCount == FormatValue.AUTO){
+				// figure out...
+			} else {
+				var cCount:Number = computedFormat.columnCount;
+			}
+			
+			while (cCount > columns.length){
+				addColumn();
+			}
+			
+			var w:Number;
+			switch(typeof(computedFormat.tableWidth)){
+				case "number":
+					w = suggestedWidth;
+					break;
+				case "string":
+					if(computedFormat.tableWidth.indexOf("%") > 0){
+						w = suggestedWidth / (parseFloat(computedFormat.tableWidth)/100);
+						break;
+					}
+				default:
+					w = suggestedWidth;
+					break;
+			}
+			if(isNaN(w))
+				w = 600;
+			if(w > 20000)
+				w = 600;
+			
+			_computedWidth = w;
+
+			var numNonsetColumns:int = numColumns;
+			var col:TableColElement;
+			for each(col in columns){
+				// simply stomp on the settings. (need to finesse this...)
+				if(typeof(col.columnWidth) == "number")
+				{
+					w-= col.columnWidth;
+					numNonsetColumns--;
+				}
+			}
+
+			for each(col in columns)
+			{
+				// simply stomp on the settings. (need to finesse this...)
+				if(typeof(col.columnWidth) == "number")
+					continue;
+				col.columnWidth = w / numNonsetColumns;
+			}
+		}
+		
+		/**
+		 * Returns a vector of all the damaged cells in the table.
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.ITableCellElement
+		 **/
+		private function getDamagedCells():Vector.<ITableCellElement>{
+			var cells:Vector.<ITableCellElement> = new Vector.<ITableCellElement>();
+			for each (var cell:* in this.mxmlChildren){
+				if((cell is ITableCellElement) && cell.isDamaged())
+					cells.push(cell as ITableCellElement);
+			}
+			return cells;
+		}
+		
+		/**
+		 * Marks all of the cells in the table as damaged.
+		 **/
+		private function markCellsDamaged():void {
+			if (!mxmlChildren) return;
+			
+			for each (var cell:* in this.mxmlChildren){
+				if (cell is ITableCellElement) {
+					cell.damage();
+				}
+			}
+		}
+		
+		/**
+		 * Returns a vector of all the table cell elements in the table.
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.ITableCellElement
+		 **/
+		public function getCells():Vector.<ITableCellElement> {
+			var cells:Vector.<ITableCellElement> = new Vector.<ITableCellElement>();
+			
+			for each (var cell:* in mxmlChildren){
+				if (cell is ITableCellElement) {
+					cells.push(cell as ITableCellElement);
+				}
+			}
+			
+			return cells;
+		}
+		
+		/**
+		 * Returns an array of all the table cells.
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.ITableCellElement
+		 **/
+		public function getCellsArray():Array {
+			var cells:Array = [];
+			
+			for each (var cell:* in mxmlChildren){
+				if (cell is ITableCellElement) {
+					cells.push(cell as ITableCellElement);
+				}
+			}
+			
+			return cells;
+		}
+		
+		/**
+		 * Returns the table width
+		 **/
+		public function get width():Number
+		{
+			return _computedWidth;
+		}
+		
+		/**
+		 * Sets the table width
+		 **/
+		public function set width(value:Number):void
+		{
+			normalizeColumnWidths(value);
+		}
+		
+		
+		/**
+		 * Indicates elements in the table have been modified and the table must be recomposed.
+		 **/
+		public function get hasCellDamage():Boolean
+		{
+			return _hasCellDamage;
+		}
+
+		public function set hasCellDamage(value:Boolean):void
+		{
+			_hasCellDamage = value;
+		}
+
+		/**
+		 * Returns the number of header rows in the table
+		 **/
+		public function get headerRowCount():uint
+		{
+			return _headerRowCount;
+		}
+
+		/**
+		 * Sets the number of header rows in the table
+		 **/
+		public function set headerRowCount(value:uint):void
+		{
+			if(value != _headerRowCount)
+				_tableRowsComputed = false;
+			_headerRowCount = value;
+		}
+
+		/**
+		 * Returns the number of footer rows in the table
+		 **/
+		public function get footerRowCount():uint
+		{
+			return _footerRowCount;
+		}
+
+		/**
+		 * Sets the number of footer rows in the table
+		 **/
+		public function set footerRowCount(value:uint):void
+		{
+			if(value != _footerRowCount)
+				_tableRowsComputed = false;
+			_footerRowCount = value;
+		}
+		
+		/**
+		 * Gets the first TextFlowTableBlock in the table. 
+		 **/
+		public function getFirstBlock():ITextFlowTableBlock{
+			if(_tableBlocks == null)
+				_tableBlocks = new Vector.<ITextFlowTableBlock>();
+			if(_tableBlocks.length == 0)
+				_tableBlocks.push(new TextFlowTableBlock(0));
+			_tableBlockIndex = 0;
+			_tableBlocks[0].parentTable = this;
+			
+			return _tableBlocks[0];
+		}
+		
+		/**
+		 * Gets the next TextFlowTableBlock. 
+		 **/
+		public function getNextBlock():ITextFlowTableBlock{
+			if(_tableBlocks == null)
+				_tableBlocks = new Vector.<ITextFlowTableBlock>();
+			_tableBlockIndex++;
+			while(_tableBlocks.length <= _tableBlockIndex){
+				_tableBlocks.push( new TextFlowTableBlock(_tableBlocks.length) );
+			}
+			_tableBlocks[_tableBlockIndex].parentTable = this;
+			
+			return _tableBlocks[_tableBlockIndex];
+		}
+		
+		/**
+		 * Gets the total atom length of this flow element in the text flow.  
+		 * 
+		 * @inheritDoc
+		 **/
+		override public function get textLength():int{
+			return 1;
+		}
+		
+		/**
+		 * Returns the cell at the specified row and column.
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.ITableCellElement
+		 **/
+		private function getCellIndex(rowIdx:int,columnIdx:int):int{
+			if(rowIdx == 0 && columnIdx == 0)
+				return 0;
+			for (var i:int=0;i<mxmlChildren.length;i++){
+				var item:* = mxmlChildren[i];
+				if(!(item is ITableCellElement))
+					continue;
+				var cell:ITableCellElement = item as ITableCellElement;
+				if(cell.rowIndex == rowIdx && cell.colIndex == columnIdx)
+					return i;
+			}
+			return -1;
+			
+		}
+		
+		/**
+		 * Returns a vector of table cell elements in the given cell range. 
+		 **/
+		public function getCellsInRange(anchorCoords:CellCoordinates, activeCoords:CellCoordinates, block:ITextFlowTableBlock=null):Vector.<ITableCellElement>
+		{
+			var firstCoords:CellCoordinates = anchorCoords.clone();
+			var lastCoords:CellCoordinates = activeCoords.clone();
+			if(
+				lastCoords.row < firstCoords.row ||
+				(lastCoords.row == firstCoords.row && lastCoords.column < firstCoords.column)
+			)
+			{
+				firstCoords = activeCoords.clone();
+				lastCoords = anchorCoords.clone();
+			}
+			
+			// make sure the rectangle is not inversed
+			if(lastCoords.column < firstCoords.column)
+			{
+				var col:int = firstCoords.column;
+				firstCoords.column = lastCoords.column;
+				lastCoords.column = col;
+			}
+			var firstCell:ITableCellElement = findCell(firstCoords);
+			var cells:Vector.<ITableCellElement> = new Vector.<ITableCellElement>();
+			if(!block || getCellBlock(firstCell) == block)
+				cells.push(firstCell);
+			var idx:int = mxmlChildren.indexOf(firstCell);
+			while(++idx < mxmlChildren.length)
+			{
+				var nextCell:ITableCellElement = mxmlChildren[idx];
+				if(nextCell.rowIndex > lastCoords.row || (nextCell.rowIndex == lastCoords.row && nextCell.colIndex > lastCoords.column))
+					break;
+				// skip cells outside rectangle
+				if(nextCell.colIndex > lastCoords.column || nextCell.colIndex < firstCoords.column)
+					continue;
+				if(!block || getCellBlock(nextCell) == block)
+					cells.push(nextCell);
+			}
+			return cells;
+		}
+		
+		/**
+		 * Finds the cell at the specified cell coordinates or null if no cell is found. 
+		 **/
+		public function findCell(coords:CellCoordinates):ITableCellElement
+		{
+			// get a guess of the cell location. If there's no holes (such as spans), it should theoretically pinpoint the index.
+			var idx:int = (coords.row+1) * (coords.column+1) -1;
+			if(idx >= numChildren)
+				idx = numChildren-1;
+			
+			var cell:ITableCellElement = mxmlChildren[idx];
+			// look ahead to see if we're short (not sure if this is needed).
+			do
+			{
+				if(idx == numChildren-1)
+					break;
+				var nextCell:ITableCellElement = mxmlChildren[idx+1];
+				if(nextCell.rowIndex > coords.row || (nextCell.rowIndex == coords.row && nextCell.colIndex > coords.column))
+					break;
+				
+				cell = nextCell;
+				idx++;
+				
+			}while(true);
+			// look behind accounting for spans
+			do
+			{
+				//check if the coords fall within the row and column span
+				if(
+					cell.colIndex <= coords.column && cell.colIndex + cell.columnSpan - 1 >= coords.column &&
+					cell.rowIndex <= coords.row && cell.rowIndex + cell.rowSpan - 1 >= coords.row
+				)
+					break;
+				//oops we hit the first cell without finding anything. At least return that...
+				if(cell.colIndex == 0 && cell.rowIndex == 0)
+					break;
+				if(idx == 0)
+					break;
+				var prevCell:ITableCellElement = mxmlChildren[idx-1];
+				cell = prevCell;
+				idx--;
+			}while(true);
+			
+			return cell;
+		}
+		
+		/**
+		 * Adds the table cell container to the table block specified. 
+		 **/
+		public function addCellToBlock(cell:ITableCellElement, block:ITextFlowTableBlock):void
+		{
+			block.addCell(cell.container);
+			tableBlockDict[cell] = block;
+		}
+		
+		/**
+		 * Returns the table block for the given table cell. 
+		 **/
+		public function getCellBlock(cell:ITableCellElement):ITextFlowTableBlock
+		{
+			return tableBlockDict[cell];
+		}
+
+		/**
+		 * Keeps a reference to all the table blocks belonging to this table. 
+		 **/
+		private function get tableBlockDict():ObjectMap
+		{
+			if(_tableBlockDict == null)
+				_tableBlockDict = new ObjectMap();
+			return _tableBlockDict;
+		}
+		
+		/**
+		 * Returns a vector of the table blocks.
+		 **/
+		public function get tableBlocks():Vector.<ITextFlowTableBlock>
+		{
+			return _tableBlocks;
+		}
+		
+		/**
+		 * Returns a vector of the table blocks in the specified cell range.
+		 **/
+		public function getTableBlocksInRange(start:CellCoordinates,end:CellCoordinates):Vector.<ITextFlowTableBlock>
+		{
+			var coords:CellCoordinates = start.clone();
+			if(end.column < start.column)
+			{
+				coords = end.clone();
+				end = start.clone();
+			}
+			var blocks:Vector.<ITextFlowTableBlock> = new Vector.<ITextFlowTableBlock>();
+			var block:ITextFlowTableBlock = getCellBlock(findCell(coords));
+			if(block)
+				blocks.push(block);
+			while(block)
+			{
+				coords.row++;
+				if(coords.row > end.row)
+					break;
+				if(getCellBlock(findCell(coords)) == block)
+					continue;
+				block = getCellBlock(findCell(coords));
+				if(block)
+					blocks.push(block);
+			}
+			return blocks;
+		}
+
+		/** @private */
+		public override function getNextLeafHelper(limitElement:IFlowGroupElement,child:IFlowElement):IFlowLeafElement
+		{
+			return parent.getNextLeafHelper(limitElement,this);
+		}
+		
+		/** @private */
+		public override function getPreviousLeafHelper(limitElement:IFlowGroupElement,child:IFlowElement):IFlowLeafElement
+		{
+			return parent.getPreviousLeafHelper(limitElement,this);
+		}
+
+		private function getLeaf():TableLeafElement
+		{
+			if(_leaf == null)
+				_leaf = new TableLeafElement(this);
+			return _leaf;
+		}
+		
+		public override function findLeaf(relativePosition:int):IFlowLeafElement
+		{
+			return getLeaf();
+		}
+		public override function getLastLeaf(): IFlowLeafElement
+		{
+			return getLeaf();
+		}
+		public override function getFirstLeaf():IFlowLeafElement
+		{
+			return getLeaf();
+		}
+
+		public override function createContentElement():void{}
+		/** @private 
+		 * Release the FTE data structure that corresponds to the FlowElement, so it can be gc'ed
+		 */
+		public override function releaseContentElement():void{}
+
+		/**
+		 * Creates and returns a default row 
+		 **/
+		public function createRowElement(index:int, defaultRowFormat:ITextLayoutFormat):ITableRowElement {
+			var row:ITableRowElement = ElementHelper.getTableRow(defaultRowFormat);
+			row.rowIndex = index;
+			row.table = this;
+			return row;
+		}
+
+		/**
+		 * Creates and returns a default column 
+		 **/
+		public function createColumnElement(index:int, defaultColumnFormat:ITextLayoutFormat):TableColElement {
+			var column:TableColElement = new TableColElement(defaultColumnFormat);
+			column.colIndex = index;
+			column.table = this;
+			return column;
+		}
+		public override function normalizeRange(normalizeStart:uint,normalizeEnd:uint):void
+		{
+			
+		}
+	}
+}
+class CellCoords
+{
+	public var column:int;
+	public var row:int;
+	public function CellCoords(colIdx:int,rowIdx:int)
+	{
+		column = colIdx;
+		row = rowIdx;
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableFormattedElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableFormattedElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableFormattedElement.as
new file mode 100644
index 0000000..44bc6cb
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableFormattedElement.as
@@ -0,0 +1,59 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	public class TableFormattedElement extends ContainerFormattedElement implements ITableFormattedElement
+	{
+		public function TableFormattedElement()
+		{
+			super();
+		}
+		
+		private var _table:ITableElement;
+		
+		/**
+		 * Returns a reference to the table. For this to work we need to set the 
+		 * table to null when it's removed.
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.ITableElement
+		 **/
+		public function get table():ITableElement {
+			
+			if (_table) return _table;
+			
+			// find the root element entry and either return null or the containing textFlow
+			var elem:IFlowGroupElement = this;
+			
+			while ((elem.parent) != null && elem.parent.className != "TableElement") {
+				elem = elem.parent;
+			}
+			
+			_table = elem.parent as ITableElement;
+			
+			return _table;
+		}
+		
+		/**
+		 * @private
+		 **/
+		public function set table(element:ITableElement):void {
+			_table = element;
+		}
+	}
+}
+

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableLeafElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableLeafElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableLeafElement.as
new file mode 100644
index 0000000..14e258a
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableLeafElement.as
@@ -0,0 +1,139 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements {
+	import org.apache.flex.textLayout.elements.utils.GeometricElementUtils;
+	import org.apache.flex.text.engine.ElementFormat;
+	import org.apache.flex.text.engine.ITextLine;
+	import org.apache.flex.text.engine.TextElement;
+	import org.apache.flex.textLayout.compose.IFlowComposer;
+	import org.apache.flex.textLayout.compose.ISWFContext;
+	import org.apache.flex.textLayout.compose.SWFContext;
+	import org.apache.flex.textLayout.debug.Debugging;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+
+	public class TableLeafElement extends FlowLeafElement implements ITableLeafElement
+	{
+		private var _table:TableElement;
+		public function TableLeafElement(table:TableElement)
+		{
+			super();
+			_table = table;
+		}
+		override public function get className():String{
+			return "TableLeafElement";
+		}
+
+		/** @private */
+		override public function createContentElement():void
+		{
+			// not sure if this makes sense...
+			if (_blockElement)
+				return;
+			
+			computedFormat;	// BEFORE creating the element
+			var flowComposer:IFlowComposer = getTextFlow().flowComposer;
+			var swfContext:ISWFContext = flowComposer && flowComposer.swfContext ? flowComposer.swfContext : SWFContext.globalSWFContext;
+
+			var format:ElementFormat = GeometricElementUtils.computeElementFormatHelper (_table.computedFormat, _table.getParagraph(), swfContext); 
+			_blockElement = new TextElement(_text,format);
+			CONFIG::debug { Debugging.traceFTECall(_blockElement,null,"new TextElement()"); }
+			CONFIG::debug { Debugging.traceFTEAssign(_blockElement, "text", _text); }
+			super.createContentElement();
+
+		}
+
+		/** @private */
+		override protected function get abstract():Boolean
+		{ return false; }		
+		
+		/** @private */
+		public override function get defaultTypeName():String
+		{ return "table"; }
+		
+		/** @private */
+		public override function get text():String
+		{
+			return String.fromCharCode(0x16);
+		}
+		
+		/** @private */
+		public override function getText(relativeStart:int=0, relativeEnd:int=-1, paragraphSeparator:String="\n"):String
+		{
+			return _table.getText(relativeStart, relativeEnd, paragraphSeparator);
+		}
+		
+		/** @private */
+		public override function normalizeRange(normalizeStart:uint,normalizeEnd:uint):void
+		{
+			// not sure what to do here (see SpanElement)...
+			super.normalizeRange(normalizeStart,normalizeEnd);
+		}
+		
+		/** @private */
+		public override function mergeToPreviousIfPossible():Boolean
+		{
+			// not sure what to do here (see SpanElement)...
+			return false;
+		}
+		
+		public override function getNextLeaf(limitElement:IFlowGroupElement=null):IFlowLeafElement
+		{
+			return _table.getNextLeafHelper(limitElement,this);
+		}
+		
+		public override function getPreviousLeaf(limitElement:IFlowGroupElement=null):IFlowLeafElement
+		{
+			return _table.getPreviousLeafHelper(limitElement,this);
+		}
+		/** @private */
+		public override function getCharAtPosition(relativePosition:int):String
+		{
+			return getText(relativePosition,relativePosition);
+		}
+		public override function get computedFormat():ITextLayoutFormat
+		{
+			return _table.computedFormat;
+		}
+		public override function get textLength():int
+		{
+			return _table.textLength;
+		}
+
+		override public function get parent():IFlowGroupElement
+		{ 
+			return _table; 
+		}
+
+		override public function getTextFlow():ITextFlow
+		{
+			return _table.getTextFlow();
+		}
+		
+		override public function getParagraph():IParagraphElement
+		{
+			return _table.getParagraph();
+		}
+		
+		override public function getElementRelativeStart(ancestorElement:IFlowElement):int
+		{
+			return _table.getElementRelativeStart(ancestorElement);
+		}
+
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableRowElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableRowElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableRowElement.as
new file mode 100644
index 0000000..a45a570
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/TableRowElement.as
@@ -0,0 +1,224 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements {
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+
+	
+	
+
+	
+	/** 
+	 * TableRowElement is an item in a TableElement. It most commonly contains one or more TableCellElement objects, 
+	 * A TableRowElement always appears within a TableElement, TableBodyElement.
+	 *
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 *
+	 */
+	public class TableRowElement extends TableFormattedElement implements ITableRowElement
+	{		
+		public var x:Number;
+		public var y:Number;
+		public var height:Number;
+		private var _rowIndex:int;
+		
+		// This is used for background drawing
+		public var parcelIndex:int;
+		
+		public var columnIndex:Number = 0;
+		public var iMaxRowDepth:Number = 0;
+		public var beyondParcel:Boolean = false;
+		private var _composedHeight:Number = 0;
+		private var _totalHeight:Number = 0;// used to compute if a row will fit in parcel. Need a separate value for cells that span rows.
+		private var _isMaxHeight:Boolean = false;
+		
+		public function TableRowElement(format:ITextLayoutFormat=null)
+		{
+			super();
+			
+			if (format) {
+				this.format = format;
+			}
+		}
+		override public function get className():String{
+			return "TableRowElement";
+		}
+
+		
+		/** @private */
+		override protected function get abstract():Boolean
+		{ return false; }
+		
+		/** @private */
+		public override function get defaultTypeName():String
+		{ return "tr"; }
+		
+		/** @private */
+		public override function canOwnFlowElement(elem:IFlowElement):Boolean
+		{
+			return (elem is ITableCellElement);
+		}
+		
+		/** @private if its in a numbered list expand the damage to all list items - causes the numbers to be regenerated */
+		public override function modelChanged(changeType:String, elem:IFlowElement, changeStart:int, changeLen:int, needNormalize:Boolean = true, bumpGeneration:Boolean = true):void
+		{
+			super.modelChanged(changeType,elem,changeStart,changeLen,needNormalize,bumpGeneration);
+		}
+		
+		/**
+		 * Returns a vector of table cell elements or null if the row contains no cells
+		 **/
+		public function getCells():Vector.<ITableCellElement>
+		{
+			var table:ITableElement = this.table;
+			
+			if(!table) {
+				return null;
+			}
+
+			return table.getCellsForRow(this);
+		}
+		
+		/**
+		 * Get an array of cells or null if the row contains no cells
+		 **/
+		public function get cells():Array
+		{
+			var table:ITableElement = this.table;
+			
+			if (!table) {
+				return null;
+			}
+			
+			return table.getCellsForRowArray(this);
+		}
+		
+		/**
+		 * Returns the number of cells in this row. 
+		 **/
+		public function get numCells():int
+		{
+			var table:ITableElement = this.table;
+			
+			if (!table) {
+				return 0;
+			}
+			
+			return table.getCellsForRow(this).length;
+		}
+		
+		/**
+		 * Returns the cell at the specified index or null if out of range. 
+		 **/
+		public function getCellAt(index:int):ITableCellElement
+		{
+			var cells:Vector.<ITableCellElement> = getCells();
+			
+			if(!cells || index<0 || index>=cells.length)
+				return null;
+			return cells[index];
+		}
+		
+		/**
+		 * Adds a table cell to the row
+		 **/
+		public function addCell(cell:ITableCellElement):ITableCellElement
+		{
+			var table:ITableElement = this.table;
+			var cellLength:int = numChildren;
+			
+			if (!table) {
+				throw new Error("Table must be set");
+			}
+			
+			cell.rowIndex = rowIndex;
+			
+			if (cell.colIndex==-1) {
+				cell.colIndex = cellLength;
+			}
+			
+			cells.push(cell);
+			//var selectable:Boolean = textFlow.interactionManager is SelectionManager;
+			//var editable:Boolean = textFlow.interactionManager is EditManager;
+			
+			return cell;
+		}
+		
+		/**
+		 * Adds a table cell to the row
+		 **/
+		public function addCellAt(index:int):ITableCellElement
+		{
+			throw new Error("Add cell at is not implemented");
+		}
+		
+		/**
+		 * Get an estimate column count for this row.
+		 * This is temporary. TODO loop through cells and check for column span.
+		 **/
+		public function getColumnCount():int
+		{
+			return numCells || numChildren;
+		}
+
+		public function get composedHeight():Number
+		{
+			return _composedHeight;
+		}
+
+		public function set composedHeight(composedHeight:Number):void
+		{
+			this._composedHeight = composedHeight;
+		}
+
+		public function get rowIndex():int
+		{
+			return _rowIndex;
+		}
+
+		public function set rowIndex(rowIndex:int):void
+		{
+			this._rowIndex = rowIndex;
+		}
+
+		public function get isMaxHeight():Boolean
+		{
+			return _isMaxHeight;
+		}
+
+		public function set isMaxHeight(isMaxHeight:Boolean):void
+		{
+			this._isMaxHeight = isMaxHeight;
+		}
+
+		public function get totalHeight():Number
+		{
+			return _totalHeight;
+		}
+
+		public function set totalHeight(totalHeight:Number):void
+		{
+			this._totalHeight = totalHeight;
+		}
+
+
+	}
+}


[39/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/ComposeState.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/ComposeState.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/ComposeState.as
new file mode 100644
index 0000000..e8947d8
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/ComposeState.as
@@ -0,0 +1,466 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.compose
+{
+	import org.apache.flex.textLayout.compose.utils.NumberlineUtil;
+	import org.apache.flex.textLayout.elements.ConfigSettings;
+	import org.apache.flex.textLayout.elements.IFlowGroupElement;
+	import org.apache.flex.textLayout.compose.utils.TextLineUtil;
+	import org.apache.flex.text.engine.Constants;
+	import org.apache.flex.text.engine.ITextLine;
+	import org.apache.flex.textLayout.container.IContainerController;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.elements.IFlowLeafElement;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.textLayout.formats.BlockProgression;
+	import org.apache.flex.textLayout.formats.Direction;
+	import org.apache.flex.textLayout.formats.Float;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.formats.VerticalAlign;
+	import org.apache.flex.textLayout.utils.Twips;
+	
+
+
+	/** Keeps track of internal state during composition. 
+	 * 
+	 * This is the simpler version, used when there are no floats, no wraps, no columns.
+	 * @private
+	 */
+	public class ComposeState extends BaseCompose implements IComposeState	{
+		/** Index of current line */
+		protected var _curLineIndex:int;	
+		
+		// for figuring out when to do VJ
+		protected var vjBeginLineIndex:int;
+		protected var vjDisableThisParcel:Boolean;
+		
+		protected var _useExistingLine:Boolean;
+		
+		/** @private */
+		protected override function createParcelList():ParcelList
+		{
+			return ParcelList.getParcelList();
+		}
+		/** @private */
+		protected override function releaseParcelList(list:ParcelList):void
+		{
+			ParcelList.releaseParcelList(list);
+		}
+		
+		/**
+		 *  @private
+		 */
+		public override function composeTextFlow(textFlow:ITextFlow, composeToPosition:int, controllerEndIndex:int):int
+		{
+			CONFIG::debug { assert(textFlow.flowComposer is IFlowComposer,"ComposeState.composeTextFlow requires textFlow with a StandardFlowComposer"); }
+			_curLineIndex    = -1;		// unitialized: this will get set in composeParagraphElement
+			_curLine = null;
+					
+			vjBeginLineIndex = 0;
+			vjDisableThisParcel = false;
+			
+ 			return super.composeTextFlow(textFlow, composeToPosition, controllerEndIndex);
+		}
+		
+		protected override function initializeForComposer(composer:IFlowComposer,composeToPosition:int,controllerStartIndex:int, controllerEndIndex:int):void
+		{
+			           
+			// start composing from the first damaged position. Update internal composition state as if we'd composed to here already.
+			_startComposePosition = composer.damageAbsoluteStart;
+			if (controllerStartIndex == -1)
+			{
+				var controllerIndex:int = composer.findControllerIndexAtPosition(_startComposePosition);
+				if (controllerIndex == -1)
+				{
+					controllerIndex = composer.numControllers-1;
+					// if off the end in the overflow - find the last non-zero controller
+					while (controllerIndex != 0 && composer.getControllerAt(controllerIndex).textLength == 0)
+						controllerIndex--;
+				}
+			}
+			
+			// if damage is in overflow after last controller we could get smart about that
+			_startController = composer.getControllerAt(controllerIndex);
+			CONFIG::debug { assert(_startController != null,"Bad start start controller"); }
+
+			// Disable partial container composition if we have to vertically align the lines.
+			if (_startController.computedFormat.verticalAlign != VerticalAlign.TOP)
+				_startComposePosition = _startController.absoluteStart; 
+
+			// Comment this line in to disable composing from the middle of a container.
+		//	_startComposePosition = _startController.absoluteStart; 
+
+			super.initializeForComposer(composer,composeToPosition, controllerIndex, controllerEndIndex);
+		}
+		
+		/** @private */
+		protected override function composeInternal(composeRoot:IFlowGroupElement,absStart:int):void
+		{
+			super.composeInternal(composeRoot,absStart);
+			
+			// mark all overflow lines as not being in any container or column
+			if (_curElement)
+			{
+				var lineIndex:int = _curLineIndex;
+				CONFIG::debug { assert(_curLineIndex == _flowComposer.findLineIndexAtPosition(_curElementStart + _curElementOffset),"bad _curLineIndex"); }
+				while (lineIndex < _flowComposer.numLines)
+					_flowComposer.getLineAt(lineIndex++).setController(null,-1);
+			}
+		}
+
+ 		override protected function doVerticalAlignment(canVerticalAlign:Boolean,nextParcel:Parcel):void
+		{
+			if (canVerticalAlign && _curParcel && vjBeginLineIndex != _curLineIndex &&  !vjDisableThisParcel)
+			{
+				var controller:IContainerController = _curParcel.controller;
+				var vjtype:String = controller.computedFormat.verticalAlign;
+				// Don't allow vertical justification if the line contains floats, since we don't support recomposing when lines are moved.
+				if (vjtype == VerticalAlign.JUSTIFY)
+				{
+					for  (var i:int = controller.numFloats - 1; i >= 0 && canVerticalAlign; --i)
+					{
+						var floatInfo:FloatCompositionData = controller.getFloatAt(i);
+						if (floatInfo.floatType != Float.NONE)
+							canVerticalAlign = false;
+							
+					}
+				}
+				if (canVerticalAlign && vjtype != VerticalAlign.TOP)
+				{	
+					// Exclude overset lines
+					var end:int = _flowComposer.findLineIndexAtPosition(_curElementStart + _curElementOffset);
+
+					if (vjBeginLineIndex < end)
+					{
+						var beginFloatIndex:int = 0;
+						var endFloatIndex:int = 0;
+						var lines:Array = _flowComposer.lines;
+						if (controller.numFloats > 0)
+						{
+							beginFloatIndex = controller.findFloatIndexAtOrAfter(lines[vjBeginLineIndex].absoluteStart);
+							endFloatIndex = controller.findFloatIndexAfter(_curElementStart + _curElementOffset);
+						}
+						applyVerticalAlignmentToColumn(controller,vjtype,lines,vjBeginLineIndex,end-vjBeginLineIndex, beginFloatIndex, endFloatIndex);
+					}
+				}
+			}
+			
+			// always reset these variables
+			vjDisableThisParcel = false;
+			vjBeginLineIndex = _curLineIndex;	
+		}
+		
+		
+		/** apply vj and adjust the parcel bounds */
+		override protected function applyVerticalAlignmentToColumn(controller:IContainerController,vjType:String,lines:Array,beginIndex:int,numLines:int,beginFloatIndex:int,endFloatIndex:int):void
+		{
+			super.applyVerticalAlignmentToColumn(controller, vjType, lines, beginIndex, numLines, beginFloatIndex, endFloatIndex);
+			
+			// Reposition lines in case they got aligned after being added to _linesInView
+			for each (var composedLine:Object in controller.composedLines)
+			{
+				if( !(composedLine is ITextLine) )
+				{
+					//only deal with TextLines. Not TableBlocks
+					continue;
+				}
+				var textLine:ITextLine = composedLine as ITextLine;
+				var line:ITextFlowLine = textLine.userData as ITextFlowLine;
+				CONFIG::debug
+				{
+					for (var i:int = 0; i < _textFlow.flowComposer.numLines; ++i)
+					{
+						var tfl:ITextFlowLine = _textFlow.flowComposer.getLineAt(i);
+						if (tfl == line)
+							break;
+					}
+					assert(i < _textFlow.flowComposer.numLines, "Creating shape for unknown (old) line");
+				}
+				line.createShape(_blockProgression, textLine);
+			}
+		}
+		
+		/** Final adjustment on the content bounds. */
+ 		override protected function finalParcelAdjustment(controller:IContainerController):void
+ 		{
+			CONFIG::debug { assert(_flowComposer.getLineAt(_flowComposer.findLineIndexAtPosition(_curParcelStart)).absoluteStart == _curParcelStart,"finalParcelAdjustment: bad _curParcelStart"); }
+
+ 			var minX:Number = Constants.MAX_LINE_WIDTH;
+ 			var minY:Number = Constants.MAX_LINE_WIDTH;
+ 			var maxX:Number = -Constants.MAX_LINE_WIDTH;
+ 			
+ 			var verticalText:Boolean = _blockProgression == BlockProgression.RL;
+			
+			if (!isNaN(_parcelLogicalTop))
+			{
+				if (verticalText)
+					maxX = _parcelLogicalTop;
+				else
+					minY = _parcelLogicalTop;
+			}
+			
+			if (!_measuring)
+			{
+				if (verticalText)
+					minY = _accumulatedMinimumStart;
+				else
+					minX = _accumulatedMinimumStart;			
+			}
+			else
+			{
+				var edgeAdjust:Number;
+				var curPara:IParagraphElement;
+				var curParaFormat:ITextLayoutFormat;
+				var curParaDirection:String;
+				
+				for (var lineIndex:int = _flowComposer.findLineIndexAtPosition(_curParcelStart); lineIndex < _curLineIndex; lineIndex++)
+	            {
+					var line:ITextFlowLine = _flowComposer.getLineAt(lineIndex);
+					
+					// Now check the logical horizontal dimension
+					CONFIG::debug { assert(line != null && line.paragraph != null, "found it");}
+					
+					if (line.paragraph != curPara)
+					{
+						curPara = line.paragraph;
+						curParaFormat = curPara.computedFormat;
+						curParaDirection = curParaFormat.direction;
+						if (curParaDirection != Direction.LTR)
+							edgeAdjust = curParaFormat.paragraphEndIndent;
+					}
+					
+					if (curParaDirection == Direction.LTR)
+						edgeAdjust = Math.max(line.lineOffset, 0);
+					
+					edgeAdjust = verticalText ? line.y - edgeAdjust : line.x - edgeAdjust;
+					
+					var numberLine:ITextLine = TextLineUtil.findNumberLine(line.getTextLine(true));
+					
+					if (numberLine)
+					{
+						var numberLineStart:Number = verticalText ? numberLine.y+line.y : numberLine.x+line.x;
+						edgeAdjust = Math.min(edgeAdjust,numberLineStart);
+					}
+					
+	             	if (verticalText)
+	           			minY = Math.min(edgeAdjust, minY);
+	             	else 
+	           			minX = Math.min(edgeAdjust, minX);
+	            }
+			}
+            
+            // Don't make adjustments for tiny fractional values.
+            if (minX != Constants.MAX_LINE_WIDTH && Math.abs(minX-_parcelLeft) >= 1)
+         		_parcelLeft = minX;
+            if (maxX != -Constants.MAX_LINE_WIDTH && Math.abs(maxX-_parcelRight) >= 1)
+         		_parcelRight = maxX;
+         	if (minY != Constants.MAX_LINE_WIDTH && Math.abs(minY-_parcelTop) >= 1)
+           		_parcelTop = minY;
+ 		}
+ 			
+		/**
+		 *  @flexjsignorecoercion org.apache.flex.textLayout.compose.IFlowComposer
+		 */
+		protected override function endTableBlock(block:ITextFlowTableBlock):void
+		{
+			super.endTableBlock(block);
+			_flowComposer.addLine(block,_curLineIndex);
+			
+			commitLastLineState (_curLine);
+			_curLineIndex++;
+		}
+		/** Called when we are finished composing a line. Handler for derived classes to override default behavior.  */
+		/**
+		 */
+		override protected function endLine(textLine:ITextLine):void
+		{
+			super.endLine(textLine);
+
+			if ( !_useExistingLine ) 		
+				_flowComposer.addLine(_curLine,_curLineIndex);
+			
+			commitLastLineState (_curLine);
+			_curLineIndex++;
+		}		
+		
+		protected override function composeParagraphElement(elem:IParagraphElement, absStart:int):Boolean
+		{				
+			if (_curLineIndex < 0)
+				_curLineIndex = _flowComposer.findLineIndexAtPosition(_curElementStart + _curElementOffset);
+
+			return super.composeParagraphElement(elem, absStart);
+		}
+		
+		/**
+		 *  @private
+		 */
+		protected override function composeNextLine():ITextLine
+		{			
+			// mjzhang: this code adds for recompose a table row, we need to recorrect _curLineIndex parameter based on _curElementStart and _curElementOffset.
+			//Harbs: I don't see a need for this now that I changed the table logic.
+			//_curLineIndex = _flowComposer.findLineIndexAtPosition(_curElementStart + _curElementOffset);
+			
+			CONFIG::debug { assert(_curLineIndex == _flowComposer.findLineIndexAtPosition(_curElementStart + _curElementOffset),"bad _curLineIndex"); }
+
+			// Find out how long a zero-logical height line can be in the parcel at the current position (depth). 
+			// See if there is an existing line that is composed up-to-date matching the parcel width. If there is,
+			// we try to reuse it, otherwise we create a new line. Once we have placed a line, we will recheck the
+			// width in fitLineToParcel to make sure it fits at the (possibly changed) line height.
+			var startCompose:int = _curElementStart + _curElementOffset - _curParaStart;
+			var line:ITextFlowLine = _curLineIndex < _flowComposer.numLines ? _flowComposer.lines[_curLineIndex] : null;
+			var useExistingLine:Boolean = line && (!line.isDamaged() || line.validity == FlowDamageType.GEOMETRY);
+			if (ConfigSettings.usesDiscretionaryHyphens)
+			{
+				// if the line ends with a hyphen, don't use existing line because the player seems to mis-handle
+				// starting the next line.
+				if (useExistingLine && line.textLength > 0 &&
+					line.paragraph.getCharCodeAtPosition(line.absoluteStart + line.textLength - 1) == 0xAD)
+					useExistingLine = false;
+			}
+			var numberLine:ITextLine;
+			
+			// create numberLine if in a listElement
+			if (_listItemElement && _listItemElement.getAbsoluteStart() == _curElementStart+_curElementOffset)
+			{
+				var peekLine:ITextLine;
+				if (useExistingLine && (peekLine = line.peekTextLine()) != null)
+				{
+					// may be null
+					numberLine = TextLineUtil.findNumberLine(peekLine);
+				}
+				else
+				{
+					var isRTL:Boolean = _curParaElement.computedFormat.direction == Direction.RTL;
+					numberLine = NumberlineUtil.createNumberLine(_listItemElement, _curParaElement, _flowComposer.swfContext, isRTL ? _parcelList.rightMargin : _parcelList.leftMargin);
+				}
+				
+				pushInsideListItemMargins(numberLine);
+			}
+			
+			_parcelList.getLineSlug(_lineSlug, 0, 1, _textIndent, _curParaFormat.direction == Direction.LTR);
+			
+			if (useExistingLine && Twips.to(_lineSlug.width) != line.outerTargetWidthTW)
+				useExistingLine = false;
+
+			_curLine = useExistingLine ? line : null;
+			var textLine:ITextLine;
+			
+			for (;;) 
+			{
+				while (!_curLine)
+				{	
+					useExistingLine = false;
+					// generate new line
+					CONFIG::debug { assert(!_parcelList.atEnd(), "failing to stop"); }
+					CONFIG::debug { assert(_curElement is IFlowLeafElement, "element must be leaf before calling composeLine"); }					
+					CONFIG::debug { validateLineStart(_previousLine, startCompose, _curParaElement); }
+					
+					textLine = createTextLine(_lineSlug.width, !_lineSlug.wrapsKnockOut /* don't allow emergency breaks next to floats or padded elements */);
+					if (textLine)
+						break;
+
+					// force advance within the parcel to the next wider slug, or (if there are no more) to the next parcel
+					var newDepth:Number = _curParcel.findNextTransition(_lineSlug.depth);
+					if (newDepth < Number.MAX_VALUE)
+					{
+						_parcelList.addTotalDepth(newDepth - _lineSlug.depth);
+						if (!_parcelList.getLineSlug(_lineSlug, 0, 1, _textIndent, _curParaFormat.direction == Direction.LTR))
+							return null;
+					}
+					else 
+					{
+						advanceToNextParcel();
+						if (!_parcelList.atEnd())
+						{
+							if (_parcelList.getLineSlug(_lineSlug, 0, 1, _textIndent, _curParaFormat.direction == Direction.LTR))
+								continue;
+						}
+						popInsideListItemMargins(numberLine);
+						return null;
+					}						
+				}
+				
+				// updates _lineSlug
+				CONFIG::debug { assert(textLine || useExistingLine, "expected non-null textLine because we had to regenerate the line"); }
+				if (!textLine)
+					textLine = _curLine.getTextLine(true);
+				if (fitLineToParcel(textLine, !useExistingLine, numberLine))
+					break;	// we have a good line
+				_curLine = null;	// keep looking
+				if (_parcelList.atEnd())
+				{
+					popInsideListItemMargins(numberLine);
+					return null;
+				}
+			}
+			
+			// Clear up user_invalid
+			if (_curLine.validity == FlowDamageType.GEOMETRY)
+				_curLine.clearDamage(); 
+								
+			_useExistingLine = useExistingLine;
+			
+			popInsideListItemMargins(numberLine);
+
+			CONFIG::debug { assert(textLine != null, "textLine != null"); }			
+			return textLine;
+		}
+		
+		/** @private */
+		override protected function createTextLine(
+			targetWidth:Number,	// target width we're composing into
+			allowEmergencyBreaks:Boolean	// true to allow words to break in the middle of narrow columns, false to force overset
+			):ITextLine
+        {		
+			_curLine = new TextFlowLine(null, null);		// it will be initialized in BaseCompose.createTextLine
+			var textLine:ITextLine = super.createTextLine(targetWidth, allowEmergencyBreaks);
+			
+			if (textLine)
+	 			textLine.doubleClickEnabled = true;		// allow line to be the target of a double click event
+			else
+				_curLine = null;
+ 			
+ 			return textLine;
+        }
+        
+        /** @private */
+		CONFIG::debug private static function validateLineStart(previousLine:ITextLine, lineStart:int, paraNode:IParagraphElement):void
+		{
+			// If the lines have been released, don't validate
+			if (lineStart != 0 && paraNode.getTextBlock().firstLine == null)
+				return;
+				
+	       	var testStart:int = 0;
+	    	var testLine:ITextLine = previousLine;
+	    	while (testLine)
+	    	{
+				CONFIG::debug { assert(testLine.validity == "valid", "previous line in paragraph is not valid!"); }
+	    		testStart += testLine.rawTextLength;
+	    		testLine = testLine.previousLine;
+	    	}
+	    	assert(testStart == lineStart, "Bad lines");
+			
+      		assert(paraNode is IParagraphElement,"composeLine: paraNode must be a para"); 
+			var prevLine:ITextFlowLine = previousLine ? previousLine.userData as ITextFlowLine : null;
+			assert(!previousLine || prevLine != null, "prevLine null");
+      		assert(!previousLine || !(prevLine.location & TextFlowLineLocation.LAST),"prevLine may not be from a different para"); 
+		} 
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/FactoryComposer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/FactoryComposer.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/FactoryComposer.as
new file mode 100644
index 0000000..16da8ec
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/FactoryComposer.as
@@ -0,0 +1,84 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.compose
+{
+	
+	import org.apache.flex.textLayout.compose.utils.FactoryHelper;
+	import org.apache.flex.textLayout.container.IContainerController;
+	import org.apache.flex.textLayout.elements.IBackgroundManager;
+	import org.apache.flex.textLayout.factory.TextLineFactoryBase;
+
+
+
+	
+	// [ExcludeClass]
+	/** @private
+     * FactoryDisplayComposer - overridable
+	 */
+	public class FactoryComposer extends StandardFlowComposer implements IFactoryComposer	{
+		public function FactoryComposer()
+		{ super(); }
+		
+		public override function callTheComposer(absoluteEndPosition:int, controllerEndIndex:int):IContainerController
+		{
+			// always do a full compose
+			clearCompositionResults();
+			
+			var state:ISimpleCompose = FactoryHelper.staticComposer;
+			state.composeTextFlow(textFlow, -1, -1);
+			state.releaseAnyReferences();
+			return getControllerAt(0);
+		}
+		
+		/** Returns true if composition is necessary, false otherwise */
+		protected override function preCompose():Boolean
+		{
+			return true;
+		}
+		
+		/** @private */
+		public override function createBackgroundManager():IBackgroundManager
+		{ return new FactoryBackgroundManager(); }
+	}
+}
+
+import org.apache.flex.textLayout.compose.ITextFlowLine;
+import org.apache.flex.text.engine.ITextLine;
+
+import org.apache.flex.textLayout.elements.BackgroundManager;
+
+
+class FactoryBackgroundManager extends BackgroundManager
+{
+	
+	public override function finalizeLine(line:ITextFlowLine):void
+	{
+		var textLine:ITextLine = line.getTextLine();
+		
+		var array:Array = _lineDict[textLine];
+		if (array)
+		{
+			// attach the columnRect and the ITextLine to the first object in the Array
+			var obj:Object = array[0];
+			
+			if (obj)	// check not needed?
+				obj.columnRect = line.controller.columnState.getColumnAt(line.columnIndex);
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/FloatCompositionData.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/FloatCompositionData.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/FloatCompositionData.as
new file mode 100644
index 0000000..a8efdad
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/FloatCompositionData.as
@@ -0,0 +1,58 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.compose
+{
+	import org.apache.flex.core.IParentIUIBase;
+	import org.apache.flex.geom.Matrix;
+	import org.apache.flex.core.IUIBase;
+	
+	/** Contains information about the float that was generated by composition, and is used for composing and updating */
+	public class FloatCompositionData
+	{
+		//TODO make sure IUIBase makes sense for both the child and parent.
+		public var graphic:IUIBase;		// display object used for float
+		public var columnIndex:int;				// parcel index float was composed into
+		public var floatType:String;			// float type @see org.apache.flex.textLayout.formats.Float)
+		public var x:Number;					// x position of DisplayObject origin, in parent object coords
+		public var y:Number;					// y position of DisplayObject origin, in parent object coords
+		public var alpha:Number; 				// alpha value from fte-inline placeholder
+		public var matrix:Matrix;				// matrix value from fte-inline placeholder
+		public var absolutePosition:int;		// location of the float in the text flow
+		public var depth:Number;
+		public var knockOutWidth:Number;
+		public var parent:IParentIUIBase;
+		CONFIG::debug { public var displacedVertically:Boolean; }
+		
+		public function FloatCompositionData(absolutePosition:int, graphic:IUIBase, floatType:String, x:Number, y:Number, alpha:Number, matrix:Matrix, depth:Number, 
+			knockOutWidth:Number, columnIndex:int, parent:IParentIUIBase)
+		{
+			this.absolutePosition = absolutePosition;
+			this.graphic = graphic;
+			this.floatType = floatType;
+			this.x = x;
+			this.y = y;
+			this.alpha = alpha;
+			this.matrix = matrix;
+			this.depth = depth;
+			this.knockOutWidth = knockOutWidth;
+			this.columnIndex = columnIndex;
+			this.parent = parent;
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/FlowComposerBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/FlowComposerBase.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/FlowComposerBase.as
new file mode 100644
index 0000000..dc4f0e1
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/FlowComposerBase.as
@@ -0,0 +1,685 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.compose
+{
+	import org.apache.flex.text.engine.ITextBlock;
+	import org.apache.flex.text.engine.ITextLine;
+	import org.apache.flex.textLayout.compose.utils.ContextUtil;
+	import org.apache.flex.textLayout.compose.utils.NumberlineUtil;
+	import org.apache.flex.textLayout.container.IContainerController;
+	import org.apache.flex.textLayout.debug.Debugging;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.elements.ConfigSettings;
+	import org.apache.flex.textLayout.elements.IBackgroundManager;
+	import org.apache.flex.textLayout.elements.IFlowLeafElement;
+	import org.apache.flex.textLayout.elements.IListItemElement;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	
+
+
+
+	
+	[Exclude(name="initializeLines",kind="method")]
+	[Exclude(name="addLine",kind="method")]
+	[Exclude(name="lines",kind="property")]
+	[Exclude(name="debugCheckTextFlowLines",kind="method")]
+	[Exclude(name="checkFirstDamage",kind="method")]
+	
+	/** 
+	 * The FlowComposerBase class is the base class for Text Layout Framework flow composer classes, which control the 
+	 * composition of text lines in ContainerController objects.
+	 *
+	 * <p>FlowComposerBase is a utility class that implements methods and properties that are common
+	 * to several types of flow composer. Application code would not typically instantiate or use this class
+	 * (unless extending it to create a custom flow composer).</p>
+	 * 
+	 * @see org.apache.flex.textLayout.elements.TextFlow#flowComposer
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	 
+	public class FlowComposerBase
+	{
+				// Composition data
+		[ ArrayElementType("org.apache.flex.textLayout.compose.TextFlowLine") ]
+		private var _lines:Array;	
+		
+		/** @private */
+		protected var _textFlow:ITextFlow;
+		
+		/** Absolute start of the damage area -- first character in the flow that is dirty and needs to be recomposed. @private */
+		protected var _damageAbsoluteStart:int;
+		
+		/** @private */
+		protected var _swfContext:ISWFContext;
+		
+		/** Constructor. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		public function FlowComposerBase()
+		{
+			_lines = new Array();
+			_swfContext = null;
+		}
+		
+		/** Returns the array of lines. @private */
+		public function get lines():Array
+		{ return _lines; }
+		
+		/** 
+		 * @copy IFlowComposer#getLineAt()
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+		 */
+		 
+		public function getLineAt(index:int):ITextFlowLine
+		{ return _lines[index]; }
+		
+		/** @copy IFlowComposer#numLines 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		public function get numLines():int
+		{ return _lines.length; }
+		
+		/** 
+		* The TextFlow object to which this flow composer is attached. 
+		*
+		* @see org.apache.flex.textLayout.elements.TextFlow
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0
+	 	*/
+	 	
+		public function get textFlow():ITextFlow
+		{ return _textFlow; }
+		
+		/**
+		 * The absolute position immediately preceding the first element in the text
+		 * flow that requires composition and updating.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+		 */
+		public function get damageAbsoluteStart():int
+		{
+			return _damageAbsoluteStart;
+		}
+		
+		/**
+		 * Initialize the lines for the TextFlow.  Creates a single ITextFlowLine with no content. @private
+		 */ 
+		protected function initializeLines():void
+		{
+			var backgroundManager:IBackgroundManager = _textFlow ? _textFlow.backgroundManager : null;
+			// remove all the lines we have now - cache for reuse
+			if (TextLineRecycler.textLineRecyclerEnabled)
+			{
+				for each (var line:ITextFlowLine in _lines)
+				{
+					var textLine:ITextLine = line.peekTextLine();
+					if (textLine && !textLine.parent)
+					{
+						// releasing all textLines so release each still connected textBlock
+						if (textLine.validity != "invalid")
+						{
+							var textBlock:ITextBlock = textLine.textBlock;
+							CONFIG::debug { Debugging.traceFTECall(null,textBlock,"releaseLines",textBlock.firstLine,textBlock.lastLine); }
+							textBlock.releaseLines(textBlock.firstLine,textBlock.lastLine);
+						}
+						textLine.userData = null;
+						TextLineRecycler.addLineForReuse(textLine);
+						if (backgroundManager)
+							backgroundManager.removeLineFromCache(textLine);
+					}
+				}
+			}
+			_lines.splice(0);
+			_damageAbsoluteStart = 0;
+			
+			CONFIG::debug { checkFirstDamaged(); }
+		}
+		
+		/** Make sure that there is a ITextFlowLine for all the content - even if compose has stopped early. @private */
+		protected function finalizeLinesAfterCompose():void
+		{
+			var line:ITextFlowLine;
+			if (_lines.length == 0)
+			{
+				// create a new line, with damage, that covers the entire area
+				line = new TextFlowLine(null,null);
+				line.setTextLength(textFlow.textLength);
+				_lines.push(line);
+			}
+			else
+			{
+				line = _lines[_lines.length-1];
+				var lineEnd:int = line.absoluteStart + line.textLength;
+				if (lineEnd < textFlow.textLength)
+				{
+					line = new TextFlowLine(null,null);
+					line.setAbsoluteStart(lineEnd);
+					line.setTextLength(textFlow.textLength-lineEnd);
+					_lines.push(line);
+				}
+			}			
+		}
+		
+		/** 
+		 * @copy IFlowComposer#updateLengths()
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+		 */
+		public function updateLengths(startPosition:int,deltaLength:int):void
+		{
+			var MAX_VALUE:int = 2147483647;
+			// no lines yet - skip it
+			if (numLines == 0)
+				return;
+				
+			var line:ITextFlowLine;	// sratch line variable
+			var lineIdx:int = findLineIndexAtPosition(startPosition);
+				
+			var damageStart:int = MAX_VALUE;			
+			if (deltaLength > 0)
+			{
+				if (lineIdx == _lines.length)
+				{
+					line = _lines[_lines.length-1];
+					CONFIG::debug { assert(line.absoluteStart+line.textLength == startPosition,"updateLengths bad startIdx"); }
+					line.setTextLength(line.textLength + deltaLength);
+				}
+				else
+				{
+					line = _lines[lineIdx++];
+					line.setTextLength(line.textLength + deltaLength);
+				}
+				damageStart = line.absoluteStart;
+			}
+			else
+			{
+				var lenToDel:int = -deltaLength;
+				var curPos:int = 0;
+				
+				while (true)
+				{
+					line = _lines[lineIdx];
+					// An empty span following a table can cause this.
+					//if(line == null)
+					//	break;
+					
+					line.setAbsoluteStart(line.absoluteStart + lenToDel + deltaLength);
+					curPos = (startPosition > line.absoluteStart ? startPosition : line.absoluteStart);
+					
+					var lineEndIdx:int = line.absoluteStart + line.textLength;
+					var deleteChars:int = 0;
+					
+					if (curPos + lenToDel <= lineEndIdx)		
+					{
+						if (curPos == line.absoluteStart)
+							deleteChars = lenToDel;				//delete from begin of line to end of selection
+						else if (curPos == startPosition)
+							deleteChars = lenToDel;				//delete is all included in one line
+						else
+						{
+							CONFIG::debug { assert(false, "insertText: should never happen");  }
+						}								
+					}
+					else //(curPos + lenToDel > lineEndIdx)		//multiline delete
+					{
+						if (curPos == line.absoluteStart)
+							deleteChars = line.textLength; 		//delete the whole line
+						else
+							deleteChars = lineEndIdx-curPos;	//delete from middle of line to end of line
+					}		
+						
+					if (curPos == line.absoluteStart && curPos + deleteChars == lineEndIdx)		//the whole line is selected
+					{
+						lenToDel -= deleteChars;
+						_lines.splice(lineIdx,1);			//lineIdx now points to the next line
+					}
+					else 									//partial line
+					{
+						if (damageStart > line.absoluteStart)
+							damageStart = line.absoluteStart;
+						line.setTextLength(line.textLength - deleteChars);
+						lenToDel -= deleteChars;
+						lineIdx++;
+					}
+					CONFIG::debug { assert(lenToDel >= 0,"updateLengths deleted too much"); }
+					if (lenToDel <= 0)
+							break;						
+				}
+			}
+			
+			for ( ; lineIdx < _lines.length; lineIdx++)
+			{
+				line = _lines[lineIdx];
+				if (deltaLength >= 0)
+					line.setAbsoluteStart(line.absoluteStart  + deltaLength);
+				else
+					line.setAbsoluteStart(line.absoluteStart > -deltaLength ? line.absoluteStart+deltaLength : 0);
+			}
+			
+			if (_damageAbsoluteStart > damageStart)
+				_damageAbsoluteStart = damageStart;
+		}
+		
+		/** 
+		 * @copy IFlowComposer#damage()
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+		 */
+		public function damage(startPosition:int, damageLength:int, damageType:String):void
+		{
+			if (ConfigSettings.usesDiscretionaryHyphens)
+			{
+				// damage everything from the beginning.  
+				// The player tends to screw up if you start
+				// composition in the middle and there are lines above broken on
+				// hyphens.
+				damageLength += startPosition;
+				startPosition = 0;
+			}
+			
+			if (_lines.length == 0 || textFlow.textLength == 0)
+				return;
+				
+			// This case the damageStart is at the end of the text.  This can happen if the last paragraph is deleted
+			if (startPosition == textFlow.textLength)
+				return;
+				
+			CONFIG::debug { assert(startPosition + damageLength <= textFlow.textLength, "Damaging past end of flow!"); }
+
+            // find the line at damageStart
+            var lineIndex:int = findLineIndexAtPosition(startPosition);
+
+            // Start damaging one line before the startPosition location in case some of the first "damaged" line will fit on the previous line.
+            var leaf:IFlowLeafElement = textFlow.findLeaf(startPosition);
+			if (leaf && lineIndex > 0)
+				lineIndex--;
+
+			if (lines[lineIndex].absoluteStart < _damageAbsoluteStart)
+				_damageAbsoluteStart = _lines[lineIndex].absoluteStart;
+				
+			CONFIG::debug { assert(lineIndex < _lines.length && _lines[lineIndex].absoluteStart <= startPosition + damageLength, "Missing line"); }
+			
+			while (lineIndex < _lines.length)
+			{
+				var line:ITextFlowLine = _lines[lineIndex];
+				
+				// Changed to >= from >, as > seemed to damage too
+				// many lines when editing tables. 
+				// Should verify the correctness of this.
+				if (line.absoluteStart >= startPosition+damageLength)
+					break;
+				
+				line.damage(damageType);
+				lineIndex++;
+			}
+		}
+		
+		/**
+		 * @copy IFlowComposer#isDamaged()
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+		 */
+		 
+		public function isDamaged(absolutePosition:int):Boolean
+		{
+			// Returns true if any text from _damageAbsoluteStart through absolutePosition needs to be recomposed
+			
+			// no lines - damaged
+			if (_lines.length == 0)
+				return true;
+				
+			CONFIG::debug { checkFirstDamaged(); }
+
+			return _damageAbsoluteStart <= absolutePosition && _damageAbsoluteStart != textFlow.textLength;
+		}
+
+
+		/**
+		 * @copy IFlowComposer#isPotentiallyDamaged()
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+		 */
+
+		public function isPotentiallyDamaged(absolutePosition:int):Boolean
+		{
+			return isDamaged(absolutePosition);
+		}
+
+		/** @private */
+		CONFIG::debug public function checkFirstDamaged():void
+		{
+			// find the line at start
+			if (_lines.length == 0)
+				return;
+				
+			var lineIndex:int = findLineIndexAtPosition(0);
+			while (lineIndex < _lines.length)
+			{
+				if (_lines[lineIndex].isDamaged())
+				{
+				//	trace("is damaged");
+					CONFIG::debug { assert(_lines[lineIndex].absoluteStart >= _damageAbsoluteStart, "_damageAbsoluteStart doesn't match actual line value"); } 
+					return;
+				}
+				++lineIndex;				
+			}
+		//	trace("not damaged");
+			return;
+		}
+		/** 
+		 * @copy IFlowComposer#findLineIndexAtPosition()
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		public function findLineIndexAtPosition(absolutePosition:int,preferPrevious:Boolean = false):int
+		{	
+			var lo:int = 0;
+			var hi:int = _lines.length-1;
+			while (lo <= hi)
+			{
+				var mid:int = (lo+hi)/2;
+				var line:ITextFlowLine = _lines[mid];
+				if (line.absoluteStart <= absolutePosition)
+				{
+					if (preferPrevious)
+					{
+						if (line.absoluteStart + line.textLength >= absolutePosition)
+							return mid;
+					}
+					else
+					{
+						if (line.absoluteStart + line.textLength > absolutePosition)
+							return mid;
+					}
+					lo = mid+1;
+				}
+				else
+					hi = mid-1;
+			}
+			return _lines.length;
+		}
+		
+		/**
+		 * @copy IFlowComposer#findLineAtPosition()
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+		 */
+		 
+		public function findLineAtPosition(absolutePosition:int,preferPrevious:Boolean = false):ITextFlowLine
+		{
+			return _lines[findLineIndexAtPosition(absolutePosition,preferPrevious)];
+		}
+		
+		/**
+		 * add a new line 
+		 * Add a new line to the list of composed lines for the frame. Lines are sorted
+		 * by the start location, and each line has a span. The start of the next line
+		 * has to match the start of the previous line + the span of the previous line.
+		 * The last line needs to end at the end of the text. Therefore, when we add a
+		 * new line, we may need to adjust the span and/or start locations of other lines 
+		 * in the text.
+		 * @private
+		 */
+		public function addLine(newLine:ITextFlowLine,workIndex:int):void
+		{
+			var MAX_VALUE:int = 2147483647;
+			CONFIG::debug { assert(workIndex == findLineIndexAtPosition(newLine.absoluteStart),"bad workIndex to TextFlow.addLine"); }
+			CONFIG::debug { assert (!newLine.isDamaged(), "adding damaged line"); }
+			var workLine:ITextFlowLine = _lines[workIndex];
+			var afterLine:ITextFlowLine;
+			var damageStart:int = MAX_VALUE;
+			if (_damageAbsoluteStart == newLine.absoluteStart)
+				_damageAbsoluteStart = newLine.absoluteStart + newLine.textLength;
+				
+			if (workLine == null)
+				lines.push(newLine);
+			else if((workLine is TextFlowTableBlock) && workLine != newLine)
+				_lines.splice(workIndex,1,newLine);
+			else if(newLine is TextFlowTableBlock)
+			{
+				if(workLine != newLine)
+				{
+					_lines.splice(workIndex,0,newLine);
+					// set the next line absolute start to be rational for the next line...
+					if(workLine.absoluteStart == newLine.absoluteStart)
+						workLine.setAbsoluteStart(workLine.absoluteStart+1);
+				}
+			}
+								
+			else if (workLine.absoluteStart != newLine.absoluteStart)
+			{
+				if (workLine.absoluteStart + workLine.textLength > newLine.absoluteStart + newLine.textLength)
+				{
+					// Making a new line in the middle of an old one. Need to split the old one.
+					afterLine = new TextFlowLine(null,newLine.paragraph);
+					afterLine.setAbsoluteStart(newLine.absoluteStart + newLine.textLength);
+					var oldCharCount:int = workLine.textLength;
+					workLine.setTextLength(newLine.absoluteStart - workLine.absoluteStart);
+					CONFIG::debug { assert(workLine.textLength != 0, "0 width line"); }
+					afterLine.setTextLength((oldCharCount - newLine.textLength) - workLine.textLength);
+					CONFIG::debug { assert(afterLine.textLength != 0, "0 width line"); }
+					_lines.splice(workIndex + 1, 0, newLine, afterLine);
+				}
+				else
+				{
+					// We're composing ahead, so we need to split the line where we're at
+					// This can happen if a table is getting composed, some cells can be composed before 
+					// others that go before. 
+					CONFIG::debug { assert(workLine.isDamaged(), "Uneven line boundary, but lines marked up to date"); }
+					workLine.setTextLength(newLine.absoluteStart - workLine.absoluteStart);
+					CONFIG::debug { assert(workLine.textLength != 0, "0 width line"); }
+					afterLine = _lines[workIndex+1];
+					afterLine.setTextLength((newLine.absoluteStart + newLine.textLength) - afterLine.absoluteStart);
+					CONFIG::debug { assert(_lines[workIndex + 1].textLength != 0, "0 width line"); }
+					afterLine.setAbsoluteStart(newLine.absoluteStart + newLine.textLength);
+					_lines.splice(workIndex + 1, 0, newLine);
+				}
+				damageStart = workLine.absoluteStart;
+			}
+			else if (workLine.textLength > newLine.textLength)
+			{
+				// New line partially overlaps old line.
+				// Keep the old line, but resize it so it comes after the new line.
+				// Insert the new line at the old line's position
+				workLine.setTextLength(workLine.textLength - newLine.textLength);
+				CONFIG::debug { assert(workLine.textLength != 0, "0 width line"); }
+				workLine.setAbsoluteStart(newLine.absoluteStart + newLine.textLength);
+				workLine.damage("invalid");
+				_lines.splice(workIndex, 0, newLine);
+				damageStart = workLine.absoluteStart;
+			}
+			else 
+			{
+				var deleteCount:int = 1;
+				// The new line completely overlaps the old line.
+				// Insert the new line over the old line. If the line extents don't match,
+				// fix-up the starting position & extent of the following line.
+				if (workLine.textLength != newLine.textLength)
+				{
+					var amtRemaining:int = (newLine.textLength - workLine.textLength);
+					var nextLine:int = workIndex + 1;
+					while (amtRemaining > 0)
+					{
+						afterLine = _lines[nextLine];
+						if (amtRemaining < afterLine.textLength)
+						{
+							afterLine.setTextLength(afterLine.textLength - amtRemaining);
+							afterLine.damage("invalid");
+							break;
+						}
+						else
+						{
+							deleteCount++;
+							amtRemaining -= afterLine.textLength;
+							nextLine++;
+							afterLine = nextLine < _lines.length ? _lines[nextLine] : null;
+						}
+					}
+					if (afterLine && afterLine.absoluteStart != newLine.absoluteStart + newLine.textLength)
+					{
+						afterLine.setAbsoluteStart(newLine.absoluteStart + newLine.textLength);
+						afterLine.damage("invalid");
+						CONFIG::debug { assert(afterLine.textLength != 0, "0 width line"); }
+					}
+					damageStart = newLine.absoluteStart + newLine.textLength;
+				}
+				// remove userData on the deleted lines so they can be recycled
+				if (TextLineRecycler.textLineRecyclerEnabled)
+				{
+					var backgroundManager:IBackgroundManager = textFlow.backgroundManager;
+					for (var recycleIdx:int = workIndex; recycleIdx < workIndex+deleteCount; recycleIdx++)
+					{
+						var textLine:ITextLine = ITextFlowLine(_lines[recycleIdx]).peekTextLine();
+						if (textLine && !textLine.parent)
+						{
+							// lines shouldn't be valid here but lets check anyhow
+							CONFIG::debug { assert(textLine.validity != "valid","caught a bug here"); }
+							if (textLine.validity != "valid")	// recycle immediately if not parented
+							{
+								textLine.userData = null;
+								TextLineRecycler.addLineForReuse(textLine);
+								if (backgroundManager)
+									backgroundManager.removeLineFromCache(textLine);
+							}
+						}
+					}
+				}
+				_lines.splice(workIndex, deleteCount, newLine);
+			}
+	
+			if (_damageAbsoluteStart > damageStart)
+				_damageAbsoluteStart = damageStart;
+			// CONFIG::debug { debugCheckTextFlowLines(false); }
+	//		CONFIG::debug { checkFirstDamaged(); }	 enabling this will cause false positives due to _damageAbsoluteStart during composition not updated	when GEOMETRY_DAMAGE lines are cleared
+		}
+		
+		/** 
+		* The ISWFContext instance used to make FTE calls as needed. 
+		*
+		* <p>By default, the ISWFContext implementation is this FlowComposerBase object.
+		* Applications can provide a custom implementation to use fonts
+		* embedded in a different SWF file or to cache and reuse text lines.</p>
+		* 
+		* @see org.apache.flex.textLayout.compose.ISWFContext
+		* 
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0
+	 	*/
+ 	
+		public function get swfContext():ISWFContext
+		{
+			return _swfContext;
+		}
+		public function set swfContext(context:ISWFContext):void
+		{
+			if (context != _swfContext)
+			{
+				// swf contexts can be wrappers for other swf contexts - we're going to let the swfcontext give us a hint here
+				if (textFlow)
+				{
+					var newBaseContext:ISWFContext =  ContextUtil.computeBaseSWFContext(context);
+					var oldBaseContext:ISWFContext =  ContextUtil.computeBaseSWFContext(_swfContext);
+	
+					_swfContext = context;
+
+					if (newBaseContext != oldBaseContext)
+					{
+						damage(0,textFlow.textLength,FlowDamageType.INVALID);
+						textFlow.invalidateAllFormats();
+					}
+				}
+				else
+					_swfContext = context;				
+			}
+		}
+		/** @private */
+		public function createBackgroundManager():IBackgroundManager{ return null; }
+		
+		public function createNumberLine(listItemElement:IListItemElement, curParaElement:IParagraphElement, swfContext:ISWFContext, totalStartIndent:Number):ITextLine
+		{
+			return NumberlineUtil.createNumberLine(listItemElement, curParaElement, swfContext, totalStartIndent);
+		}
+		
+		/**
+		 * Validate that the lines associated with the flow are internally consistent. 
+		 * @private
+		 * The start of the next line has to match the start of the previous line + the 
+		 * span of the previous line. The last line needs to end at the end of the flow,
+		 * and the first line must be at the start of the text.
+		 */
+		CONFIG::debug public function debugCheckTextFlowLines(validateControllers:Boolean=true):int
+		{
+			var rslt:int = 0;
+			var position:int = 0;
+			var overflow:Boolean = false;
+			for each (var line:ITextFlowLine in _lines)
+			{
+				// trace("validateLines:",lines.indexOf(line).toString()," ",line.start," ",line.textLength);
+				rslt += assert(line.absoluteStart == position, "Line start incorrect");
+				rslt += assert(line.textLength >= 0,"Invalind length");
+				if (validateControllers)
+				{
+					var lineController:IContainerController = line.controller;
+					if (lineController != null)
+					{
+						rslt += assert(overflow == false,"non overflow line after overflow line?");
+						rslt += assert(line.absoluteStart >= line.controller.absoluteStart,"bad container mapping");
+						rslt += assert(line.absoluteStart+line.textLength<= lineController.absoluteStart+lineController.textLength,"bad container mapping");
+					}
+					else
+						overflow = true;
+				}
+				position += line.textLength;
+			}
+			return rslt;
+		}		
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/FlowDamageType.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/FlowDamageType.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/FlowDamageType.as
new file mode 100644
index 0000000..5f76795
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/FlowDamageType.as
@@ -0,0 +1,60 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.compose
+{
+	/**
+	 *  The FlowDamageType class is an enumeration class that defines types of damage for damage methods and events.
+	 * When the text content is updated, these changes are reflected in the TextLines after an update. TextLines are 
+	 * marked with a flag that specifies whether or not they are valid, or up to date with all text
+	 * changes. When the text is first updated, all lines are marked valid or static. After the text has been changed,
+	 * and before the next update, lines will be marked with a FlowDamageType that specifies what about the line
+	 * is invalid. Once the update is done, lines will again be marked as valid or static.
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	public class FlowDamageType
+	{
+		/** 
+		 * Value is used to set the <code>validity</code> property if the text content has changed since the
+		 * line was originally created. Invalid lines needs to be recreated before they are used for selection
+		 * or to display the text content changes.
+		 *
+		 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 *
+	 	 * @see org.apache.flex.textLayout.compose.TextFlowLine#validity	 	 */
+		static public const INVALID:String = "invalid";
+		
+		/**
+		 * Value is used to set the <code>validity</code> property if the line has been invalidated by other lines 
+		 * moving around. For instance, a line above may have been created, so this line needs to be moved down.
+		 * The text line might or might not need recreating at the next compose operation. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 *
+	 	 * @see org.apache.flex.textLayout.compose.TextFlowLine#validity
+	 	 */
+		static public const GEOMETRY:String = "geometry";
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/IComposeState.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/IComposeState.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/IComposeState.as
new file mode 100644
index 0000000..cd7ffb2
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/IComposeState.as
@@ -0,0 +1,26 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.compose
+{
+	import org.apache.flex.textLayout.elements.ITextFlow;
+
+	public interface IComposeState extends IComposer
+	{
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/IComposer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/IComposer.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/IComposer.as
new file mode 100644
index 0000000..9f45d5e
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/IComposer.as
@@ -0,0 +1,42 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.compose
+{
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.textLayout.compose.ITextFlowLine;
+	import org.apache.flex.text.engine.ITextLine;
+	import org.apache.flex.textLayout.compose.ParcelList;
+	import org.apache.flex.textLayout.container.IContainerController;
+	import org.apache.flex.textLayout.compose.ISWFContext;
+
+	public interface IComposer
+	{
+		function releaseAnyReferences():void;
+
+		function composeTextFlow(textFlow:ITextFlow, composeToPosition:int, controllerEndIndex:int):int;
+
+		function computeTextFlowLineMinimumLogicalTop(line:ITextFlowLine, textLine:ITextLine):Number;
+
+		function get parcelList():ParcelList;
+
+		function get startController():IContainerController;
+
+		function get swfContext():ISWFContext;
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/IFactoryComposer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/IFactoryComposer.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/IFactoryComposer.as
new file mode 100644
index 0000000..89cabdc
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/IFactoryComposer.as
@@ -0,0 +1,28 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.compose
+{
+	import org.apache.flex.textLayout.container.IContainerController;
+
+	public interface IFactoryComposer extends IFlowComposer
+	{
+		function callTheComposer(absoluteEndPosition:int, controllerEndIndex:int):IContainerController;
+
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/IFlowComposer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/IFlowComposer.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/IFlowComposer.as
new file mode 100644
index 0000000..5e6ce19
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/IFlowComposer.as
@@ -0,0 +1,521 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.compose
+{
+	import org.apache.flex.text.engine.ITextLine;
+	import org.apache.flex.textLayout.container.IContainerController;
+	import org.apache.flex.textLayout.edit.ISelectionManager;
+	import org.apache.flex.textLayout.elements.IBackgroundManager;
+	import org.apache.flex.textLayout.elements.IContainerFormattedElement;
+	import org.apache.flex.textLayout.elements.IListItemElement;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+
+	/**
+	 * IFlowComposer defines the interface for managing the layout and display of a text flow.
+	 * 
+	 * <p>Text flows displayed with a flow composer implementation can be dynamic and interactive.
+	 * A flow composer manages one or more display controller. Each controller is associated with
+	 * a display object container (such as a Sprite) through which the lines created for the text
+	 * flow are ultimately displayed. The following diagram illustrates the relationship between TextFlow,
+	 * IFlowComposer, ContainerController, and DisplayObjectContainer objects:</p>
+	 * 
+	 * <p><img src="../../../images/textLayout_singleController.gif" alt="IFlowComposer"></img></p>
+	 *
+	 * <p>A flow composer calculates which portion of a text flow fits in each container and 
+	 * adds the appropriate text lines to the container's display object. The IFlowComposer interface 
+	 * defines separate methods for layout calculations and for updating the display. IFlowComposer also 
+	 * defines methods for incrementally composing and updating a text flow. These methods can be used 
+	 * to avoid blocking the user interface when updating long text flows.</p>
+	 * 
+	 * <p>In addition to managing text composition and display, a flow composer controls which container has focus, 
+	 * manages the display of the selection highlight (which can cross container boundaries), and provides
+	 * direct access to all the TextLine objects in the flow.</p>
+	 * 
+	 * <p>To use an IFlowComposer implementation, assign an instance of that implementation to the
+	 * <code>flowComposer</code> property of a TextFlow object. Call the <code>updateAllControllers()</code>
+	 * method to lay out and display the text in the containers attached to the flow composer.</p>
+	 * 
+	 * <p><b>Note:</b> For simple, static text flows, you can also use the one of the text line factory classes.
+	 * These factory classes will typically create lines with less overhead than a flow composer, but do not
+	 * support editing, dynamic changes, or user interaction.</p>
+	 * 
+	 * @see org.apache.flex.textLayout.container.ContainerController ContainerController
+	 * @see FlowComposerBase
+	 * @see StandardFlowComposer
+	 * @see org.apache.flex.textLayout.elements.TextFlow TextFlow
+	 * @see org.apache.flex.textLayout.factory.StringTextLineFactory StringTextLineFactory
+	 * @see org.apache.flex.textLayout.factory.TextFlowTextLineFactory TextFlowTextLineFactory
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	public interface IFlowComposer
+	{
+		/** 
+		 * The root element associated with this IFlowComposer instance. 
+		 * 
+		 * <p>Only a TextFlow object can be a root element.</p>
+		 *  
+		 * @see org.apache.flex.textLayout.elements.IContainerFormattedElement IContainerFormattedElement
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+		 */
+		function get rootElement():IContainerFormattedElement;
+
+		function setRootElement(newRootElement:IContainerFormattedElement):void;
+			
+		/** 
+		 * The first invalid position in the root element, as an absolute position from the start of the flow.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		function get damageAbsoluteStart():int;
+		
+		/** 
+		 * Composes the content of the root element and updates the display.  
+		 *
+		 * <p>Text layout is typically conducted in two phases: composition and display. In the composition phase,
+		 * the flow composer calculates how many lines are necesary to display the content as well as the position of these 
+		 * lines in the flow's display containers. In the display phase, 
+		 * the flow composer updates the display object children of its containers. The <code>updateAllControllers()</code>
+		 * method is expected to carry out both phases. An efficient implementation will keep track of changes to content
+		 * so that a full cycle of composition and display is only performed when necessary.</p>
+		 * 
+		 * <p>This method updates all the text lines and the display list immediately and synchronously.</p>
+		 *
+		 * <p>If the contents of any container is changed, the method must return <code>true</code>.</p>
+		 * 
+		 * @return true if anything changed.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 * 
+		 */
+		function updateAllControllers():Boolean;
+		
+		/** 
+		 * Composes and updates the display up to and including the container at the specified index.
+		 * 
+		 * <p>The <code>updateToController()</code> method is expected to both compose the content and 
+		 * update the display so that all containers up to and including the container at the specified index are current.
+		 * For example, if you have a chain of twenty containers and specify an index of 10, 
+		 * <code>updateToController()</code> must ensures that the first through the tenth (indexes 0-9) containers
+		 * are composed and displayed. Composition can stop at that point. If <code>controllerIndex</code> 
+		 * is -1 (or not specified), then all containers should be updated.</p>
+		 *
+		 * <p>This method updates all the text lines and the display list immediately and synchronously.</p>
+		 * 
+		 * <p>If the contents of any container is changed, the method must return <code>true</code>.</p>
+		 * 
+		 * @param controllerIndex index of the last container to update, by default will update all containers
+		 * @return true if anything changed.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 *
+		 */
+		 
+		function updateToController(index:int = 2147483647):Boolean;
+		
+		/** 
+		 * Sets the focus to the container that contains the location specified by the <code>absolutePosition</code>
+		 * parameter. 
+		 *
+		 * <p>It is the responsibility of the implementation to define what setting the focus means. For example, an 
+		 * implementation could use the built-in <code>focus</code> property of the Stage object (as long as the
+		 * containers were InteractiveObjects) or the implementation could manage the focus some other way.</p>
+		 * 
+		 * @param absolutePosition Specifies the position in the text flow of the container to receive focus.
+		 * @param preferPrevious If true and the position is the before the first character in a container, sets focus to the end of 
+		 *  the previous container.
+		 * 
+		 * @see flash.display.Stage#focus
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		function setFocus(absolutePosition:int,preferPrevious:Boolean=false):void;
+
+		/** 
+		 * Calculates how many lines are necessary to display the content in the root element of the flow and the positions of these 
+		 * lines in the flow's display containers.
+		 * 
+		 * <p>Implementations of this method should not update the display, but should save the results so that subsequent
+		 * calls to <code>compose()</code> or <code>updateAllControllers()</code> do not perform an additional recomposition
+		 * if the flow content has not changed.</p>
+		 * 
+		 * <p>If the contents of any container have changed, the method must return <code>true</code>.</p>
+		 * 
+		 * @return true if anything changed.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 *
+	 	 * @see #updateAllControllers()
+	 	 * @see #updateToController()
+		 */
+		 
+		function compose():Boolean;
+		
+		/** 
+		 * Composes the content of the root element up to the specified position.
+		 * 
+		 * <p>If the contents of any container up to and including the container holding the content at the specified
+		 * position has changed, the method returns <code>true</code>. If <code>absolutePosition</code> is greater than the length of the TextFlow 
+		 * (or not specified), then the entire flow is composed.</p>
+		 * 
+		 * @param absolutePosition compose at least up to this position in the TextFlow. By default or if absolutePosition is past the end of the flow compose to the end of the flow.
+		 * @return true if anything changed.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 *
+	 	 * @see #updateAllControllers()
+	 	 * @see #updateToController()
+		 */
+		 
+		function composeToPosition(absolutePosition:int = 2147483647):Boolean;
+		
+		/** 
+		 * Composes the content of the root element up to and including the container at the specified index.
+		 * 
+		 * <p>If the contents of any container up to and including the container at the specified
+		 * index has changed, the method returns <code>true</code>. If <code>index</code> is greater than the number of controllers
+		 * (or not specified), then all containers are composed.</p>
+		 * 
+		 * @param controllerIndex compose at least up to this container in the TextFlow. If controllerIndex is greater than the number of controllers, compose to the end of the last container.
+		 * @return true if anything changed.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 *
+	 	 * @see #updateAllControllers()
+	 	 * @see #updateToController()
+		 */
+		 
+		function composeToController(index:int = 2147483647):Boolean;
+
+		/** 
+		 * The number of containers assigned to this IFlowComposer instance. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		function get numControllers():int;
+		
+		/** 
+		 * Adds a controller to this IFlowComposer instance.
+		 *
+		 * <p>The container is added to the end of the container list.</p>
+		 * 
+		 * @param controller The ContainerController object to add.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+		 */
+		 
+		function addController(controller:IContainerController):void;
+		
+		/** 
+		 * Adds a controller to this IFlowComposer instance at the specified index.
+		 *
+		 * <p>The list of controllers is 0-based (the first controller has an index of 0).</p>
+		 * 
+		 * @param controller The ContainerController object to add.
+		 * @param index A numeric index that specifies the position in the controller list at which to insert the ContainerController object.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+		 */
+		 
+		function addControllerAt(controller:IContainerController, index:int):void;
+		
+		/** 
+		 * Removes a controller from this IFlowComposer instance. 
+		 * 
+		 * @param controller The ContainerController instance to remove.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+		 */
+		function removeController(controller:IContainerController):void;
+
+		/** 
+		 * Removes the controller at the specified index from this IFlowComposer instance.
+		 *
+		 * @param index The index of the ContainerController object to remove.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+		 */
+		 
+		function removeControllerAt(index:int):void;
+
+		/** 
+		 * Removes all controllers from this IFlowComposer instance. 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+		 */
+		function removeAllControllers():void;
+
+		/** 
+		 * Returns the ContainerController object at the specified index. 
+		 * 
+		 * @param index The index of the ContainerController object to return.
+		 * @return 	the ContainerController object at the specified position.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	
+		function getControllerAt(index:int):IContainerController;
+		
+		/** 
+		 * Returns the index of the specified ContainerController object. 
+		 * 
+		 * @param controller A reference to the ContainerController object to find.
+		 * @return the index of the specified ContainerController object or -1 if the controller is not attached to this flow composer.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	
+		function getControllerIndex(controller:IContainerController):int;
+		
+		/** 
+		 * Returns the index of the controller containing the content at the specified position. 
+		 * 
+		 * <p>A position can be considered to be the division between two characters or other elements of a text flow. If 
+		 * the value in <code>absolutePosition</code> is a position between the last character of one 
+		 * container and the first character of the next, then the preceding container is returned if
+		 * the <code>preferPrevious</code> parameter is set to <code>true</code> and the later container is returned if
+		 * the <code>preferPrevious</code> parameter is set to <code>false</code>.</p>
+		 *
+		 * <p>The method must return -1 if the content at the specified position is not in any container or is outside
+		 * the range of positions in the text flow.</p>
+		 * 
+		 * @param absolutePosition The position of the content for which the container index is sought.
+		 * @param preferPrevious Specifies which container index to return when the position is between the last element in 
+		 * one container and the first element in the next.
+		 * 
+		 * @return 	the index of the container controller or -1 if not found.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */ 
+	 	 
+		function findControllerIndexAtPosition(absolutePosition:int,preferPrevious:Boolean=false):int;
+
+		/** 
+		 * Returns the sequential line number of the ITextFlowLine object that contains the content at the specified position. 
+		 * 
+		 * <p>The number of the first line is 0 and the number of the last line is equal to the number of lines minus one.
+		 * If the position specified in <code>absolutePosition</code> is past the end of the text flow, this method must return
+		 * the number that will be assigned to the next new line added to the text flow (which is equal to the number of current lines).</p>
+		 *
+		 * <p>A position can be considered to be the division between two characters or other elements of a text flow. If 
+		 * the value in <code>absolutePosition</code> is a position between the last line of one 
+		 * container and the first line of the next, then the preceding container is returned if
+		 * the <code>preferPrevious</code> parameter is set to <code>true</code> and the later container is returned if
+		 * the <code>preferPrevious</code> parameter is set to <code>false</code>.</p>
+		 * 
+		 * @param absolutePosition	The position of the content for which you want the text line.
+		 * @param preferPrevious Specifies which container index to return when the position is between the last line in 
+		 * one container and the first line in the next.
+		 *
+		 * @return the index of the text line at the specified position. If not found, treats as past the end and returns the
+		 * number of lines.
+		 * 	 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		function findLineIndexAtPosition(absolutePosition:int,preferPrevious:Boolean = false):int;
+		
+		/** 
+		* Returns the ITextFlowLine object containing the content at the specified position.
+		*
+		* <p>A position can be considered to be the division between two characters or other elements of a text flow. If 
+		* the value in <code>absolutePosition</code> is a position between the last element of one 
+		* line and the first element of the next, then the preceding line is returned if
+		* the <code>preferPrevious</code> parameter is set to <code>true</code> and the later line is returned if
+		* the <code>preferPrevious</code> parameter is set to <code>false</code>.</p>
+		* 
+		* @param absolutePosition	The position of the content for which you want the ITextFlowLine object.
+		* @param preferPrevious		Specifies which line to return when the position is between the last element of 
+		* one line and the first element of the next.
+		*
+		* @return	the ITextFlowLine containing the content at the specified position, or null if not found.
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0
+	 	*/
+	 	
+		function findLineAtPosition(absolutePosition:int,preferPrevious:Boolean = false):ITextFlowLine;
+		
+		/** 
+		 * Returns the line with the specified line number. 
+		 *
+		 * <p>The list of lines is numbered from zero to the number of lines minus one. If the value in <code>index</code>
+		 * is outside the bounds of the list of lines, then this function returns <code>null</code>.</p>
+		 * 
+		 * @param index		The line number of the ITextFlowLine object to return.
+		 * @return	the ITextFlowLine with the specified line number, or <code>null</code>, if not found.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+		function getLineAt(index:int):ITextFlowLine;
+		
+		/** 
+		 * The total number of lines composed in the flow.  By default TLF does not compose the entire flow and this value may be innacruate.
+		 * Use composeToPosition to get all lines composed.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		function get numLines():int;
+		
+		/** 
+		 * Indicates whether any ITextFlowLine objects between the beginning of the flow and the line containing the content at 
+		 * the specified position are marked as damaged. 
+		 *
+		 * @param absolutePosition the last position in the area of interest
+		 * @return 	true if any of the ITextFlowLine objects from the start of the flow up to the line containing the content at
+		 * <code>absolutePosition</code> are marked as damaged.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		function isDamaged(absolutePosition:int):Boolean;
+
+		/**
+		 * Indicates whether any ITextFlowLine objects between the beginning of the flow and the line containing the content at
+		 * the specified position are marked as damaged OR if there are other clues that the textFlow should be rebuilt.
+		 *
+		 * @param absolutePosition the last position in the area of interest
+		 * @return 	true if any of the ITextFlowLine objects from the start of the flow up to the line containing the content at
+		 * <code>absolutePosition</code> are marked as damaged OR if there are other reasons to believe the textFlow is damaged.
+		 *
+         * @see org.apache.flex.textLayout.compose.IFlowComposer#isDamaged()
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+
+		function isPotentiallyDamaged(absolutePosition:int):Boolean;
+
+		
+		/** 
+		 * True, if the flow composer is currently performing a composition operation.
+		 *  
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+		 */
+		function get composing():Boolean;
+		
+		/** 
+		 * The ISWFContext instance to be used for calls that must be made in a specific SWF context  
+		 * 
+		 * <p>Implementations of IFlowComposer should allow this property to be set so that users
+		 * of the interface can create lines in a different SWF context than the one containing the 
+		 * implementation.  A default implementation of ISWFContext should also be supplied.</p>
+		 * 
+		 * @see flashx.elements.ISWFContext ISWFContext
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+		function get swfContext():ISWFContext;
+		function set swfContext(creator:ISWFContext):void;
+		
+		/**
+		 * Called by the TextFlow when the interaction manager changes. 
+		 * 
+		 * <p>Implementations of IFlowComposer should update event listeners and properties
+		 * that reference the interaction manager.</p>
+		 * 
+		 * @param newInteractionManager The new ISelectionManager instance.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+
+		function interactionManagerChanged(newInteractionManager:ISelectionManager):void;
+		
+		/** Update the lengths in the lines to maintain mapping to the TextFlow. 
+		 * 
+		 * @param startPosition beginning of change in length
+		 * @param deltaLength change in number of characters.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function updateLengths(startPosition:int,deltaLength:int):void;
+		
+		/** Mark lines as damaged and needing a recompose.
+		 * @param damageStart beginning of range to damage
+		 * @param damageLength number of characters to damage
+		 * @param damageType type of damage.  One of org.apache.flex.textLayout.compose.FlowDamageType
+		 * @see org.apache.flex.textLayout.compose.FlowDamageType
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function damage(startPosition:int, damageLength:int, damageType:String):void;
+		function createBackgroundManager():IBackgroundManager;
+		CONFIG::debug function debugCheckTextFlowLines(validateControllers:Boolean=true):int;
+		function get lines():Array;
+		function addLine(newLine:ITextFlowLine,workIndex:int):void;
+		function createNumberLine(listItemElement:IListItemElement, curParaElement:IParagraphElement, swfContext:ISWFContext, totalStartIndent:Number):ITextLine;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/ISWFContext.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/ISWFContext.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/ISWFContext.as
new file mode 100644
index 0000000..a903c84
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/ISWFContext.as
@@ -0,0 +1,76 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.compose
+{
+	/** 
+	 * The ISWFContext interface allows a SWF file to share its context with other SWF files that load it.
+	 * An application that loads a SWF file of type ISWFContext can call methods in the context of the loaded SWF file.
+	 * The main usage is for calling the FTE TextLine creation methods.
+	 * 
+	 * <p>There are two reasons for an application to use 
+	 * this interface to control TextLine creation: </p>
+	 * <ul>
+	 *   <li><strong>Reuse an embedded font: </strong> if an application wants to use a font embedded in a loaded SWF file,
+	 * the application can access the font if a TextLine
+	 * is created in the context of the loaded SWF file.</li>
+	 *   <li><strong>Reuse existing TextLine instances</strong>: reusing existing TextLine instances can result in faster recompose times. 
+	 * TLF reuses existing TextLine instances internally. TLF reuses 
+	 * a TextLine by calling <code>TextBlock.recreateTextLine()</code>
+	 * instead of <code>TextBlock.createTextLine()</code> when TLF recognizes that a TextLine is extant.</li>
+	 * </ul>
+	 *
+	 * 
+	 * <p>Your application may have additional TextLine instances that can be reused. 
+	 * To manually reuse existing TextLine instances:</p>
+	 * <ol>
+	 *   <li>trap calls to <code>TextBlock.createTextLine()</code>, then</li>
+	 *   <li>call <code>TextBlock.recreateTextLine()</code> with the extant TextLine instance instead 
+	 * of <code>TextBlock.createTextLine()</code>.</li>
+	 * </ol>
+	 * <p>Please note, however, that the <code>TextBlock.recreateTextLine()</code> is available
+	 * only in Flash Player 10.1 and later.</p>
+	 *
+	 * @see org.apache.flex.text.engine.TextBlock#createTextLine()
+	 * @see org.apache.flex.text.engine.TextBlock#recreateTextLine()
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	public interface ISWFContext
+	{
+	    /**
+	     *  A way to call a method in a client controlled context.
+	     *
+	     *  @param fn The function or method to call
+	     *  @param thisArg The this pointer for the function
+	     *  @param argArray The arguments for the function
+	     *  @param returns If true, the function returns a value
+	     *
+	     *  @return Whatever the function returns, if anything.
+	     *
+	     *  @see Function#apply()
+	
+	     *  @langversion 3.0
+	     *  @playerversion Flash 10
+	     *  @playerversion AIR 1.5
+	     */
+	    function callInContext(fn:Function, thisArg:Object, argArray:Array, returns:Boolean=true):*;
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/ISimpleCompose.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/ISimpleCompose.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/ISimpleCompose.as
new file mode 100644
index 0000000..d1dba86
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/ISimpleCompose.as
@@ -0,0 +1,36 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.compose
+{
+	import org.apache.flex.textLayout.elements.ITextFlow;
+
+	public interface ISimpleCompose extends IComposer
+	{
+
+		function swapLines(lines:Array):Array;
+
+		function get textFlow():ITextFlow;
+
+		function get resetLineHandler():Function;
+
+		function set resetLineHandler(val:Function):void;
+
+		function get lines():Array;
+	}
+}
\ No newline at end of file


[22/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/SelectionState.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/SelectionState.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/SelectionState.as
new file mode 100644
index 0000000..e2ca587
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/SelectionState.as
@@ -0,0 +1,147 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.edit {
+	import org.apache.flex.textLayout.elements.CellRange;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.textLayout.elements.TextRange;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+
+	
+
+	
+
+
+	/**
+	 * The SelectionState class represents a selection in a text flow.  
+	 * 
+	 * <p>A selection range has an anchor point, representing the point at which the selection of text began, and an
+	 * active point, representing the point to which the selection is extended. The active point can be before or after 
+	 * the anchor point in the text. If a selection is modified (for example, by a user shift-clicking with the mouse),
+	 * the active point changes while the anchor point always remains in the same position.</p>
+	 *
+	 * @see org.apache.flex.textLayout.edit.ISelectionManager#getSelectionState()
+	 * @see org.apache.flex.textLayout.elements.TextFlow
+	 * @see org.apache.flex.textLayout.elements.TextRange
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+ 	 * @langversion 3.0
+ 	 */
+	public class SelectionState extends TextRange
+	{		
+		/** Format that are associated with the caret position & will be applied to inserted text */
+		private var _pointFormat:ITextLayoutFormat;
+		
+		private var _cellRange:CellRange;
+		
+		private var _selectionManagerOperationState:Boolean;
+
+		/** 
+		 * Creates a SelectionState object.
+		 * 
+		 * <p><b>Note:</b> Do not construct a SelectionState object in order to create a selection. To
+		 * create a selection in a text flow, call the <code>setSelection()</code> method of the relevant
+		 * ISelectionManager instance (which is the SelectionManager or EditManager object assigned 
+		 * to the <code>interactionManager</code> property of the text flow).</p>
+		 * 
+		 * @param	root	The TextFlow associated with the selection.
+		 * @param anchorPosition	The anchor index of the selection.
+		 * @param activePosition	The active index of the selection.
+		 * @param	format	The TextLayoutFormat to be applied on next character typed when a point selection
+		 * 
+		 * @see org.apache.flex.textLayout.edit.ISelectionManager#getSelectionState()
+		 * @see org.apache.flex.textLayout.edit.SelectionManager
+		 * @see org.apache.flex.textLayout.edit.EditManager
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */		
+		public function SelectionState(root:ITextFlow,anchorPosition:int,activePosition:int,format:ITextLayoutFormat = null,cellRange:CellRange = null)
+		{
+			super(root, anchorPosition, activePosition);
+			if (format)
+				_pointFormat = format;
+			_cellRange = cellRange;
+		}
+		
+		/** 
+		 * Updates the selection range with new anchor or active position values.  
+		 * 
+		 * <p>The <code>pointFormat</code> styles are cleared if the selection is changed.</p>
+		 * 
+		 * @param newAnchorPosition	the anchor index of the selection.
+		 * @param newActivePosition	the active index of the selection.
+		 * @return true if selection is changed
+		 * 
+		 */
+		public override function updateRange(newAnchorPosition:int,newActivePosition:int):Boolean
+		{
+			if (super.updateRange(newAnchorPosition,newActivePosition) )
+			{
+				_pointFormat = null;
+				return true;
+			}
+			return false;
+		}
+		
+		/** 
+		 * The format attributes applied to inserted text. 
+		 * 
+		 * <p><b>Note:</b> The <code>pointFormat</code> object does not include inherited styles. To
+		 * get all the applicable style definitions, use the <code>getCommonCharacterFormat()</code>
+		 * method of the ISelectionManager class.</p>
+		 * 
+		 * @see ISelectionManager#getCommonCharacterFormat()
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */												
+		public function get pointFormat():ITextLayoutFormat
+		{ return _pointFormat; }
+		public function set pointFormat(format:ITextLayoutFormat):void
+		{ _pointFormat = format; } 
+		
+		/** @private used to tell an operation that the SelectionState is from the SelectionManager and that the SelectionManager pointFormat should be updated. */
+		public function get selectionManagerOperationState():Boolean
+		{ return _selectionManagerOperationState; }
+		/** @private */		
+		public function set selectionManagerOperationState(val:Boolean):void
+		{ _selectionManagerOperationState = val; }
+		/** @private */
+		public function clone():SelectionState
+		{ return new SelectionState(textFlow,anchorPosition,activePosition,pointFormat); }
+
+		/** Range of table cells in selection (null if no cells selected)*/
+		public function get cellRange():CellRange
+		{
+			return _cellRange;
+		}
+
+		/**
+		 * @private
+		 */
+		public function set cellRange(value:CellRange):void
+		{
+			_cellRange = value;
+		}
+
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/SelectionType.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/SelectionType.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/SelectionType.as
new file mode 100644
index 0000000..9a591b1
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/SelectionType.as
@@ -0,0 +1,27 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.edit
+{
+	public class SelectionType
+	{
+		public static const TEXT:String = "text";
+		public static const CELLS:String = "cells";
+		public static const NONE:String = "none";
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/TextClipboard.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/TextClipboard.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/TextClipboard.as
new file mode 100644
index 0000000..69d50b8
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/TextClipboard.as
@@ -0,0 +1,328 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.edit
+{
+	import org.apache.flex.textLayout.conversion.ConversionConstants;
+	import org.apache.flex.textLayout.conversion.ConversionType;
+	import org.apache.flex.textLayout.conversion.FormatDescriptor;
+	import org.apache.flex.textLayout.conversion.ITextExporter;
+	import org.apache.flex.textLayout.conversion.ITextImporter;
+	import org.apache.flex.textLayout.conversion.TextConverter;
+	import org.apache.flex.textLayout.dummy.Clipboard;
+	import org.apache.flex.textLayout.elements.FlowGroupElement;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+
+		
+
+
+	/**
+	 * The TextClipboard class copies and pastes TextScrap objects to and from the system clipboard.
+	 * 
+	 * <p>When you copy a TextScrap to the TextClipboard, the information is copied to the
+	 * system clipboard in two clipboard formats. One format is an XML string expressing the copied 
+	 * TextScrap object in Text Layout Markup syntax. This clipboard object uses the format name: 
+	 * "TEXT_LAYOUT_MARKUP". The second format is a plain-text string, which uses the standard 
+	 * Clipboard.TEXT_FORMAT name.</p>
+	 * 
+	 * <p>The methods of the TextClipboard class are static functions, you do not need to
+	 * create an instance of TextClipboard.</p>  
+	 * 
+	 * @see flash.desktop.Clipboard
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+ 	 * @langversion 3.0
+	*/
+	public class TextClipboard
+	{	
+		/** @private */
+		static public const TEXT_LAYOUT_MARKUP:String = "TEXT_LAYOUT_MARKUP";
+		
+		/**
+		 * Gets any text on the system clipboard as a TextScrap object.
+		 *  
+		 * <p>If the "TEXT_LAYOUT_MARKUP" format is available, this method converts the formatted
+		 * string into a TextScrap and returns it. Otherwise, if the Clipboard.TEXT_Format is available,
+		 * this method converts the plain-text string into a TextScrap. If neither clipboard format
+		 * is available, this method returns <code>null</code>.</p>
+		 * 
+		 * <p>Flash Player requires that the <code>getContents()</code> method be called in a paste event handler. In AIR, 
+		 * this restriction only applies to content outside of the application security sandbox.</p>
+		 * 
+		 * @see org.apache.flex.events.Event#PASTE
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+		 */										
+		public static function getContents():TextScrap
+		{
+			var systemClipboard:Clipboard = Clipboard.generalClipboard;	
+			return importScrap(getFromClipboard);
+
+			function getFromClipboard(clipboardFormat:String):String
+			{
+				return (systemClipboard.hasFormat(clipboardFormat)) ? String(systemClipboard.getData(clipboardFormat)) : null;
+			}
+			
+		}
+				
+		/** @private 
+		 * Internal function to import a scrap to available clipboard formats. It abstracts 
+		 * out the actual clipboard access so it can be called from testing code.
+		 **/
+		public static function importScrap(importFunctor:Function):TextScrap
+		{
+			var textScrap:TextScrap;
+			var textOnClipboard:String;
+
+			var numFormats:int = TextConverter.numFormats;
+			for (var i:int = 0; i < numFormats && !textScrap; ++i)
+			{
+				var descriptor:FormatDescriptor = TextConverter.getFormatDescriptorAt(i);
+				textOnClipboard = importFunctor(descriptor.clipboardFormat);
+				if (textOnClipboard && (textOnClipboard != ""))
+				{
+					textOnClipboard = textOnClipboard.replace(/\u000B/g,"\u2028");
+					textScrap = importToScrap(textOnClipboard, descriptor.format);
+				}
+			}
+			return textScrap;
+		}
+
+		/**
+		 * Puts a TextScrap onto the system clipboard.  
+		 * 
+		 * <p>The TextScrap is placed onto the system clipboard as both a Text Layout Markup
+		 * representation and a plain text representation.</p>
+		 * 
+		 * <p>Flash Player requires a user event (such as a key press or mouse click) before 
+		 * calling <code>setContents()</code>. In AIR, this restriction only applies to content outside of 
+		 * the application security sandbox. </p>
+		 * 
+		 * @param scrap The TextScrap to paste into the clipboard.
+		 * 
+		 * @see org.apache.flex.events.Event#COPY
+		 * @see org.apache.flex.events.Event#CUT
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+ 		 */										
+		public static function setContents(textScrap:TextScrap):void
+		{ 
+			if (!textScrap) 
+				return;
+
+			var systemClipboard:Clipboard = Clipboard.generalClipboard;
+			systemClipboard.clear();
+			
+			exportScrap(textScrap, addToClipboard);
+
+			function addToClipboard(clipboardFormat:String, clipboardData:String):void 
+			{ 						
+				systemClipboard.setData(clipboardFormat, clipboardData); 
+			}
+		}
+		
+		/** @private 
+		 * Internal function to export a scrap to available clipboard formats. It abstracts 
+		 * out the actual clipboard access so it can be called from testing code.
+		 **/
+		public static function exportScrap(scrap:TextScrap, exportFunctor:Function):void
+		{
+			var formatsPosted:Array = [];	// one clipboardFormat may have multiple formats, but we only post one result per clipboardFormat
+			
+			var numFormats:int = TextConverter.numFormats;
+			for (var i:int = 0; i < numFormats; i++)
+			{
+				var descriptor:FormatDescriptor = TextConverter.getFormatDescriptorAt(i);
+				if (descriptor.clipboardFormat && formatsPosted.indexOf(descriptor.clipboardFormat) < 0)
+				{
+					var exportString:String = exportForClipboard(scrap, descriptor.format);
+					if (exportString)
+					{
+						exportFunctor(descriptor.clipboardFormat, exportString);
+						formatsPosted.push(descriptor.clipboardFormat);
+					}
+				}
+			}
+		}
+		
+		/** @private */
+		public static function importToScrap(textOnClipboard:String, format:String):TextScrap
+		{
+			var textScrap:TextScrap;
+			var importer:ITextImporter = TextConverter.getImporter(format);
+			if (importer)
+			{
+				importer.useClipboardAnnotations = true;
+				var textFlow:ITextFlow = importer.importToFlow(textOnClipboard);
+				if (textFlow) {
+					textScrap = new TextScrap(textFlow);
+					
+					/** Hint to the scrap about whether text is plain or formatted. If not set, scrap will inspect text for attributes. */
+					if (format == TextConverter.PLAIN_TEXT_FORMAT)
+						textScrap.setPlainText(true);
+					else if (format == TextConverter.TEXT_LAYOUT_FORMAT)
+						textScrap.setPlainText(false);
+				}
+				
+				// Backwards compatibility: check for older scrap format
+				if (!textScrap && format == TextConverter.TEXT_LAYOUT_FORMAT)
+					textScrap = importOldTextLayoutFormatToScrap(textOnClipboard);
+			}
+			
+			return textScrap;
+		}
+		
+		/** @private */
+		public static function importOldTextLayoutFormatToScrap(textOnClipboard:String):TextScrap
+		{
+			var textScrap:TextScrap;
+			
+			// The clipboard format for TLF 1.0 and 1.1 had a root "TextScrap" object with a TextFlow child and
+			// encodings for the begin partial elements and the end partial elements. Convert the string to an XML object, 
+			// and then translate the children.
+			var originalSettings:Object = XML.settings();
+			try {
+				XML.ignoreProcessingInstructions = false;
+				XML.ignoreWhitespace = false;
+				var xmlTree:XML = new XML(textOnClipboard);
+				if (xmlTree.localName() == "TextScrap")
+				{		// read the old clipboard format
+					var beginArrayChild:XML = xmlTree..*::BeginMissingElements[0];
+					var endArrayChild:XML = xmlTree..*::EndMissingElements[0];
+					var textLayoutMarkup:XML = xmlTree..*::TextFlow[0];
+					var textFlow:ITextFlow = TextConverter.importToFlow(textLayoutMarkup, TextConverter.TEXT_LAYOUT_FORMAT);
+					if (textFlow)
+					{
+						textScrap = new TextScrap(textFlow);
+						var element:IFlowElement;
+						var endMissingArray:Array = getEndArray(endArrayChild, textFlow);
+						for each (element in endMissingArray)
+							element.setStyle(ConversionConstants.MERGE_TO_NEXT_ON_PASTE, "true");
+					}
+				}
+//TODO probably does not make sense for FlexJS
+//				if (Configuration.playerEnablesArgoFeatures)
+//					System["disposeXML"](xmlTree);
+
+			}
+			finally
+			{
+				XML.setSettings(originalSettings);
+			}		
+			return textScrap;
+		}
+		
+		/** @private */
+		public static function exportForClipboard(scrap:TextScrap, format:String):String
+		{
+			var exporter:ITextExporter = TextConverter.getExporter(format);
+			if (exporter)
+			{
+				exporter.useClipboardAnnotations = true;
+				return exporter.export(scrap.textFlow, ConversionType.STRING_TYPE) as String;
+			}
+			return null;
+		}
+		
+		private static function getBeginArray(beginArrayChild:XML, textFlow:ITextFlow):Array
+		{
+			var beginArray:Array = new Array();
+			var curFlElement:IFlowElement = textFlow;
+			if (beginArrayChild != null)
+			{
+				var value:String = (beginArrayChild.@value != undefined) ? String(beginArrayChild.@value) : "";
+				beginArray.push(textFlow);
+				var posOfComma:int = value.indexOf(",");
+				var startPos:int;
+				var endPos:int;
+				var curStr:String;
+				var indexIntoFlowElement:int;
+				while (posOfComma >= 0)
+				{
+					startPos = posOfComma + 1;
+					posOfComma = value.indexOf(",", startPos);
+					if (posOfComma >= 0)
+					{
+						endPos = posOfComma;
+					} else {
+						endPos = value.length;
+					}
+					curStr = value.substring(startPos, endPos);
+					if (curStr.length > 0)
+					{
+						indexIntoFlowElement = parseInt(curStr);
+						if (curFlElement is FlowGroupElement)
+						{
+							curFlElement = (curFlElement as FlowGroupElement).getChildAt(indexIntoFlowElement);
+							beginArray.push(curFlElement);
+						}
+					}
+				}				
+			}
+			return beginArray.reverse();
+		}
+		
+		private static function getEndArray(endArrayChild:XML, textFlow:ITextFlow):Array
+		{
+			var endArray:Array = new Array();
+			var curFlElement:IFlowElement = textFlow;
+			if (endArrayChild != null)
+			{
+				var value:String = (endArrayChild.@value != undefined) ? String(endArrayChild.@value) : "";
+				endArray.push(textFlow);
+				var posOfComma:int = value.indexOf(",");
+				var startPos:int;
+				var endPos:int;
+				var curStr:String;
+				var indexIntoFlowElement:int;
+				while (posOfComma >= 0)
+				{
+					startPos = posOfComma + 1;
+					posOfComma = value.indexOf(",", startPos);
+					if (posOfComma >= 0)
+					{
+						endPos = posOfComma;
+					} else {
+						endPos = value.length;
+					}
+					curStr = value.substring(startPos, endPos);
+					if (curStr.length > 0)
+					{
+						indexIntoFlowElement = parseInt(curStr);
+						if (curFlElement is FlowGroupElement)
+						{
+							curFlElement = (curFlElement as FlowGroupElement).getChildAt(indexIntoFlowElement);
+							endArray.push(curFlElement);
+						}
+					}
+				}				
+			}
+			return endArray.reverse();
+		}
+
+		
+	} // end TextClipboard class
+}
+
+class TextClipboardSingletonEnforcer {}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/TextFlowEdit.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/TextFlowEdit.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/TextFlowEdit.as
new file mode 100644
index 0000000..d922c08
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/TextFlowEdit.as
@@ -0,0 +1,1223 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.edit
+{
+	import org.apache.flex.textLayout.conversion.ConversionConstants;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.elements.ElementHelper;
+	import org.apache.flex.textLayout.elements.FlowElement;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	import org.apache.flex.textLayout.elements.IFlowGroupElement;
+	import org.apache.flex.textLayout.elements.IFlowLeafElement;
+	import org.apache.flex.textLayout.elements.ILinkElement;
+	import org.apache.flex.textLayout.elements.IListItemElement;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.ISpanElement;
+	import org.apache.flex.textLayout.elements.ISubParagraphGroupElementBase;
+	import org.apache.flex.textLayout.elements.ITCYElement;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+	
+
+
+
+	
+	// [ExcludeClass]
+	/**
+	 * Encapsulates all methods necessary for dynamic editing of a text.  The methods are all static member functions of this class.
+     * @private - because we can't make it tlf_internal. Used by the operations package 
+	 */	
+	public class TextFlowEdit
+	{
+		public static function deleteRange(textFlow:ITextFlow, startPos:int, endPos:int):IParagraphElement
+		{
+			var mergePara:IParagraphElement;
+
+			// If the range to be deleted contains the paragraph end, we may have to merge up the paragraphs when we're done.
+			if (endPos > startPos)
+			{
+				var firstLeafInRange:IFlowLeafElement = textFlow.findLeaf(startPos);
+				var lastLeafInRange:IFlowLeafElement = textFlow.findLeaf(endPos - 1);
+				var firstParagraphInRange:IParagraphElement = firstLeafInRange.getParagraph();
+				var lastParagraphInRange:IParagraphElement = lastLeafInRange.getParagraph();
+				var firstParaStart:int = firstParagraphInRange.getAbsoluteStart();
+				var lastParaEnd:int = lastParagraphInRange.getAbsoluteStart() + lastParagraphInRange.textLength;
+				// If the selection is inside a single paragraph, merge only if the terminator is included and the start of the paragraph is not.
+				// If the two paragraphs are different, merge unless the start and end match exactly
+				// Don't merge if the paragraph is an empty paragraph in a list item that has other content (it will just come back again in normalize)
+				var doMerge:Boolean = false;
+				if (firstParagraphInRange == lastParagraphInRange)
+					doMerge = (endPos == lastParaEnd && startPos != firstParaStart);
+				else
+					doMerge = (startPos != firstParaStart);
+				if (doMerge)
+				{
+					var followingLeaf:IFlowLeafElement = textFlow.findLeaf(endPos);
+					if (followingLeaf)
+					{
+						mergePara = followingLeaf.getParagraph();
+						if (mergePara.textLength == 1 && mergePara.parent is IListItemElement && mergePara.parent.numChildren > 1)
+							mergePara = null;
+					}
+				}
+			}
+
+			deleteRangeInternal(textFlow, startPos, endPos - startPos);
+	
+			if (mergePara)
+			{
+				var previousLeaf:IFlowLeafElement = mergePara.getFirstLeaf().getPreviousLeaf();
+				mergePara = previousLeaf ? previousLeaf.getParagraph() : null;
+			}
+			
+			return mergePara;
+		}
+		
+		/**
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.IFlowGroupElement
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.ISpanElement
+		 */
+		private static function deleteRangeInternal(element:IFlowGroupElement, relativeStart:int, numToDelete:int):void
+		{
+			var pendingDeleteStart:int = -1;
+			var pendingDeleteCount:int = 0;
+			
+			var childIndex:int = element.findChildIndexAtPosition(relativeStart);
+			while (numToDelete > 0 && childIndex < element.numChildren)
+			{
+				var child:IFlowElement = element.getChildAt(childIndex);
+				if (relativeStart <= child.parentRelativeStart && numToDelete >= child.textLength)	// remove the entire child
+				{
+					if (pendingDeleteStart < 0)
+						pendingDeleteStart = childIndex;
+					pendingDeleteCount++;
+					numToDelete -= child.textLength;
+				}
+				else // deleting part of the child
+				{
+					if (pendingDeleteStart >= 0)
+					{
+						element.replaceChildren(pendingDeleteStart, pendingDeleteStart + pendingDeleteCount);
+						childIndex -= pendingDeleteCount;
+						pendingDeleteStart = -1;
+						pendingDeleteCount = 0;
+					}
+					var childStart:int = child.parentRelativeStart;
+					var childRelativeStart:int = Math.max(relativeStart - childStart, 0);
+					var childNumToDelete:int = Math.min(child.textLength - childRelativeStart, numToDelete);
+					if (child is ISpanElement)
+					{
+						var span:ISpanElement = child as ISpanElement;
+						span.replaceText(childRelativeStart, childRelativeStart + childNumToDelete, "");
+						numToDelete -= childNumToDelete;
+					}
+					else
+					{
+						CONFIG::debug { assert (child is IFlowGroupElement, "Expected FlowGroupElement"); }
+						deleteRangeInternal(child as IFlowGroupElement, childRelativeStart, childNumToDelete);
+						numToDelete -= childNumToDelete;
+					}
+				}
+				childIndex++;
+			}
+			if (pendingDeleteStart >= 0)
+				element.replaceChildren(pendingDeleteStart, pendingDeleteStart + pendingDeleteCount);
+		}
+				
+		// Find the lowest possible FlowElement ancestor of element that can accept prospectiveChild as a child element.
+		private static function findLowestPossibleParent(element:IFlowGroupElement, prospectiveChild:IFlowElement):IFlowGroupElement
+		{
+			while (element && !element.canOwnFlowElement(prospectiveChild))
+				element = element.parent;
+			return element;
+		}
+		
+		private static function removePasteAttributes(element:IFlowElement):void
+		{
+			if (!element)
+				return;
+			
+			if (element is IFlowGroupElement && element.format)
+			{
+				var flowGroupElement:IFlowGroupElement = IFlowGroupElement(element);
+				if (element.format.getStyle(ConversionConstants.MERGE_TO_NEXT_ON_PASTE) !== undefined)
+					removePasteAttributes(flowGroupElement.getChildAt(flowGroupElement.numChildren - 1));
+			}
+			element.setStyle(ConversionConstants.MERGE_TO_NEXT_ON_PASTE, undefined);		
+		}
+		
+		// Apply the formatting attributes from the (soon to be) previous element to the insertThis element(s). Used when we're about to 
+		// insert the element(s) and we want it to adopt the formatting of its context.
+		private static function applyFormatToElement(destinationElement:IFlowGroupElement, childIndex:int, insertThis:Object):void
+		{
+			var formatSourceSibling:IFlowElement;
+			
+			// find the previous sibling and use its formats for the new siblings
+			if (childIndex > 0)
+				formatSourceSibling = destinationElement.getChildAt(childIndex - 1);
+			else
+				formatSourceSibling = destinationElement.getChildAt(0);
+			if (formatSourceSibling)
+			{ 
+				var spanFormat:ITextLayoutFormat;
+				if (formatSourceSibling is IFlowGroupElement)	// take all levels from the sibling down to the root into account
+				{
+					var element:IFlowElement = IFlowGroupElement(formatSourceSibling).getLastLeaf();
+					var concatFormat:TextLayoutFormat;
+					while (element != formatSourceSibling.parent)
+					{
+						if (element.format)
+						{
+							if (!concatFormat)
+								concatFormat = new TextLayoutFormat(element.format);
+							else 
+								concatFormat.concatInheritOnly(element.format);
+						}
+						element = element.parent;
+					}
+					spanFormat = concatFormat;
+				}
+				else 
+					spanFormat = formatSourceSibling.format;
+					
+				if (insertThis is Array)
+				{
+					for each (var scrapElement:FlowElement in insertThis)
+						if (scrapElement is IFlowLeafElement)
+							scrapElement.format = spanFormat;
+						else
+							scrapElement.format = formatSourceSibling.format;
+				}
+				else if (insertThis is IFlowLeafElement)
+					insertThis.format = spanFormat;
+				else
+					insertThis.format = formatSourceSibling.format;
+			}
+		}
+		/**
+		 * Replaces the range of text positions that the <code>startPos</code> and
+		 * <code>endPos</code> parameters specify with the <code>textScrap</code> parameter in
+		 * <code>theFlow</code>.
+		 * <p>To delete elements, pass <code>null</code> for <code>newTextFlow</code>.</p>
+		 * <p>To insert an element, pass the same value for <code>startPos</code> and <code>endPos</code>.
+		 * <p>The new element will be inserted before the specified index.</p>
+		 * <p>To append the ITextFlow, pass <code>theFlow.length</code> for <code>startPos</code> and <code>endPos</code>.</p>
+		 * 
+		 * @param destinationFlow The ITextFlow that is being inserted into.
+		 * @param absoluteStart The index value of the first position of the replacement range in the ITextFlow.
+		 * @param textScrap The TextScrap to be pasted into theFlow.
+		 */				
+		public static function insertTextScrap(destinationFlow:ITextFlow, absoluteStart:int, textScrap:TextScrap, applyFormat:Boolean):int
+		{
+			if (!textScrap)
+				return absoluteStart;
+			
+			var scrapFlow:ITextFlow = textScrap.textFlow.deepCopy() as ITextFlow;
+			var scrapLeaf:IFlowLeafElement = scrapFlow.getFirstLeaf();
+
+			var destinationLeaf:IFlowLeafElement = destinationFlow.findLeaf(absoluteStart);
+			var insertPosition:int = absoluteStart;
+			
+			var firstParagraph:Boolean = true;
+			var doSplit:Boolean = false;
+			var destinationElement:IFlowGroupElement;
+			
+			while (scrapLeaf)
+			{
+				removePasteAttributes(scrapLeaf);
+				var scrapElement:IFlowElement = scrapLeaf;		// highest level complete element in the scrap
+				var scrapParagraph:IParagraphElement = scrapLeaf.getParagraph();
+
+				// On the first paragraph, it always merges in to the destination paragraph if the destination paragraph has content
+				var destinationParagraph:IParagraphElement = destinationLeaf ? destinationLeaf.getParagraph() : destinationParagraph;
+				if (firstParagraph && (destinationParagraph.textLength > 1 || applyFormat))
+				{
+					if (!scrapParagraph.format || scrapParagraph.format.getStyle(ConversionConstants.MERGE_TO_NEXT_ON_PASTE) === undefined)
+						doSplit = true;
+					scrapElement = scrapParagraph.getChildAt(0);
+				}
+				else
+				{
+					if (applyFormat)
+					{
+						destinationElement = destinationLeaf ? findLowestPossibleParent(destinationLeaf.parent, scrapElement) : findLowestPossibleParent(destinationElement, scrapElement);
+						var currentIndex:int = destinationElement.findChildIndexAtPosition(insertPosition - destinationElement.getAbsoluteStart());
+						applyFormatToElement(destinationElement, currentIndex, scrapElement);
+					}
+					// Normally the root element of the scrap is marked as partial, but if not, just assume that its partial (we never paste the ITextFlow element)
+					while (scrapElement && scrapElement.parent && (!scrapElement.parent.format || scrapElement.parent.format.getStyle(ConversionConstants.MERGE_TO_NEXT_ON_PASTE) === undefined) && !(scrapElement.parent is ITextFlow))
+						scrapElement = scrapElement.parent;
+				}
+				
+
+				// Find the lowest level parent in the ITextFlow that can accept the scrapElement as a child. 
+				// If necessary, copy higher up the scrapElement hierarchy to find a match.
+				destinationElement = destinationLeaf ? findLowestPossibleParent(destinationLeaf.parent, scrapElement) : findLowestPossibleParent(destinationElement, scrapElement);
+				while (!destinationElement)
+				{
+					// Nothing in the ITextFlow element hierarchy can accept the incoming scrap element.
+					// Go up the scrapElement's hierarchy of partial nodes until we find one that can be inserted.
+					scrapElement = scrapElement.parent;
+					CONFIG::debug { assert(scrapElement != null, "Couldn't find scrapElement that could be pasted"); }
+					destinationElement = findLowestPossibleParent(destinationLeaf.parent, scrapElement);
+				}
+				CONFIG::debug { assert(destinationElement != null, "insertTextScrap failed to find a FlowElement that can take the scrap element"); }
+				
+				removePasteAttributes(scrapElement);
+
+				var destinationStart:int = destinationElement.getAbsoluteStart();
+				if (firstParagraph && doSplit)
+				{
+					// Split the paragraph, and merge the scrap paragraph to the end of the first paragraph of the destination
+					CONFIG::debug { assert(destinationElement is IParagraphElement, "We should be splitting a paragraph"); }
+					ModelEdit.splitElement(destinationFlow, destinationElement, insertPosition - destinationStart);
+					var scrapParent:IFlowGroupElement = scrapElement.parent;
+					var scrapChildren:Array = scrapParent.mxmlChildren;
+					scrapParent.replaceChildren(0, scrapParent.numChildren);
+					if (scrapParent.parent)
+						scrapParent.parent.removeChild(scrapParent);
+					if (applyFormat)
+						applyFormatToElement(destinationElement, destinationElement.numChildren, scrapChildren);
+					destinationElement.replaceChildren(destinationElement.numChildren, destinationElement.numChildren, scrapChildren);
+					scrapElement = destinationElement.getChildAt(destinationElement.numChildren - 1);		// last span pasted, so we'll paste next after this
+					firstParagraph = false;
+				}
+				else
+				{
+					// We're going to add scrapElement as a child of destinationElement at the insertPosition.
+					// Split the children of destinationElement if necessary.
+					var childIndex:int = destinationElement.findChildIndexAtPosition(insertPosition - destinationElement.getAbsoluteStart());
+					var child:IFlowElement = destinationElement.getChildAt(childIndex);
+					var childStart:int = child.getAbsoluteStart();
+					if (insertPosition == childStart + child.textLength)
+						++childIndex;
+					else if (insertPosition > childStart)
+					{
+						if (child is IFlowLeafElement)
+							child.splitAtPosition(insertPosition - childStart);
+						else
+							ModelEdit.splitElement(destinationFlow, child as IFlowGroupElement, insertPosition - childStart);
+						++childIndex;
+					}
+					if (applyFormat)
+						applyFormatToElement(destinationElement, childIndex, scrapElement);
+					destinationElement.replaceChildren(childIndex, childIndex, scrapElement);
+				}
+
+				
+				// Advance to the next destination leaf
+				destinationLeaf = scrapElement is IFlowLeafElement ? IFlowLeafElement(scrapElement).getNextLeaf() : IFlowGroupElement(scrapElement).getLastLeaf().getNextLeaf();
+				insertPosition = destinationLeaf ? destinationLeaf.getAbsoluteStart() : destinationFlow.textLength - 1;
+				
+				scrapLeaf = scrapFlow.getFirstLeaf();
+				// check to make sure we're inserting into the right paragraph
+				if(destinationLeaf && scrapLeaf && scrapLeaf.getParagraph() == scrapParagraph)
+				{
+					if(destinationLeaf.getParagraph() != destinationParagraph)
+					{
+						insertPosition--;
+						destinationLeaf = null;
+					}
+				}
+			}
+			// keep the cursor in the same paragraph unless a whole paragraph was inserted 
+			if(scrapParagraph.getStyle(ConversionConstants.MERGE_TO_NEXT_ON_PASTE) == "true" && insertPosition == destinationParagraph.getAbsoluteStart() + destinationParagraph.textLength)
+				insertPosition--;
+			
+			return insertPosition;
+		}
+
+		/**
+		 * Creates a TCY run out of the selected positions.
+		 * @param theFlow The ITextFlow of interest.
+		 * @param startPos The index value of the first position of the ITextFlow to be turned into a TCY run.
+		 * @param endPos The index value following the end position of the ITextFlow to be turned into a TCY run.
+		 */	
+		public static function makeTCY(theFlow:ITextFlow, startPos:int, endPos:int):Boolean
+		{
+			var madeTCY:Boolean = true;
+			var curPara:IParagraphElement = theFlow.findAbsoluteParagraph(startPos);
+			if(!curPara)
+				return false;
+			while(curPara)
+			{
+				var paraEnd:int = curPara.getAbsoluteStart() + curPara.textLength;
+				var curEndPos:int = Math.min(paraEnd, endPos);
+				
+				//we have an entire para selected and the para only contains a kParaTerminator char, which cannot be
+				//made into TCY. 
+				if(canInsertSPBlock(theFlow, startPos, curEndPos, "TCYElement") && curPara.textLength > 1)
+				{
+					var new_tcyElem:ITCYElement = ElementHelper.getTCY();
+					
+					//don't hide an error!
+					madeTCY = madeTCY && insertNewSPBlock(theFlow, startPos, curEndPos, new_tcyElem, "TCYElement");
+				}
+				else
+					madeTCY = false;
+				
+				if(paraEnd < endPos)
+				{
+					curPara = theFlow.findAbsoluteParagraph(curEndPos);	
+					startPos = curEndPos;
+				}
+				else
+					curPara = null;
+			}
+			
+			return madeTCY;
+		}
+		
+		/**
+		 * Creates one or more LinkElements out of the selected positions. It will go through
+		 * every paragraph within the selected position and make links.
+		 * @param theFlow The ITextFlow of interest.
+		 * @param startPos The index value of the first position of the ITextFlow to be turned into a link.
+		 * @param endPos The index value following the end position of the ITextFlow to be turned into a link.
+		 * @param urlString The url string to be associated with the link.
+		 */			
+		public static function makeLink(theFlow:ITextFlow, startPos:int, endPos:int, urlString:String, target:String):Boolean
+		{
+			var madeLink:Boolean = true;
+			var curPara:IParagraphElement = theFlow.findAbsoluteParagraph(startPos);
+			if(!curPara)
+				return false;
+				
+			while(curPara)
+			{
+				var paraEnd:int = curPara.getAbsoluteStart() + curPara.textLength;
+				var curEndPos:int = Math.min(paraEnd, endPos);
+				var linkEndPos:int = (curEndPos == paraEnd) ? (curEndPos - 1) : curEndPos;
+				if (linkEndPos > startPos)
+				{
+					//if the end of the paragraph is < endPos, we are going across bounds
+					if(!canInsertSPBlock(theFlow, startPos, linkEndPos, "LinkElement"))
+					{
+						return false;
+					}
+				
+					var newLinkElement:ILinkElement = ElementHelper.getLink();
+					newLinkElement.href = urlString;
+					newLinkElement.target = target;
+				
+					//don't hide an error!
+					madeLink = madeLink && insertNewSPBlock(theFlow, startPos, linkEndPos, newLinkElement, "LinkElement");
+				}	
+				if(paraEnd < endPos)
+				{
+					curPara = theFlow.findAbsoluteParagraph(curEndPos);	
+					startPos = curEndPos;
+				}
+				else
+					curPara = null;
+			}
+			
+			return madeLink;
+		}
+		
+		
+		/**
+		 * Removes the TCY block at the selected positions. 
+		 * @param theFlow The ITextFlow of interest.
+		 * @param startPos The index value of the first position of the ITextFlow.
+		 * @param endPos The index value following the end position of the ITextFlow.
+		 */			
+		public static function removeTCY(theFlow:ITextFlow, startPos:int, endPos:int):Boolean
+		{
+			if (endPos <= startPos)
+			{
+				return false;
+			}
+			
+			return findAndRemoveFlowGroupElement(theFlow, startPos, endPos, "TCYElement");
+		}
+		
+		/**
+		 * Removes all LinkElements under the selected positions. It will go through
+		 * every paragraph within the selected position and remove any link.
+		 * @param theFlow The ITextFlow of interest.
+		 * @param startPos The index value of the first position of the ITextFlow.
+		 * @param endPos The index value following the end position of the ITextFlow.
+		 */			
+		public static function removeLink(theFlow:ITextFlow, startPos:int, endPos:int):Boolean
+		{
+			if (endPos <= startPos)
+			{
+				return false;
+			}
+			
+			return findAndRemoveFlowGroupElement(theFlow, startPos, endPos, "LinkElement");
+		}
+		
+		/**
+		 * @private
+		 * insertNewSPBlock - add a SubParagraphGroupElementBase (spg) to <code>theFlow</code> at the indicies specified by <code>startPos</code> and
+		 * <code>endPos</code>.  The <code>newSPB</code> will take ownership of any FlowElements within the range and will split them
+		 * as needed.  If the parent of the FlowGroupElement indicated by <code>startPos</code> is the same as <code>spgClass</code> then
+		 * the method fails and returns false because a spg cannot own children of the same class as itself.  Any spg of type <code>spgClass</code>
+		 * found within the indicies, however, is subsumed into <code>newSPB</code>, effectively replacing it.
+		 *
+		 * @param theFlow:ITextFlow - The ITextFlow that is the destination for the newSPB
+		 * @param startPos:int - The absolute index value of the first position of the range in the ITextFlow to perform the insertion.
+		 * @param endPos:int - The index value following the end position of the range in the ITextFlow to perform the insertion.
+		 * @param newSPB:SubParagraphGroupElementBase - The new SubParagraphElement which is to be added into theFlow.
+		 * @param spgClass:Class - the class of the fbe we intend to add.
+		 * 
+		 * Examples: Simple and complex where insertion is of <code>spgClass</code> b.  Selection is l~o
+		 *		1) <a><span>ghijklmnop</span></a>
+		 * 		2) <a><span>ghij</span><b><span>klm</span></b><span>nop</span></a>
+		 * 		3) <a><span>ghijk</span><c><span>lmn</span></c><span>op</span></a>
+		 * 
+		 */
+		public static function insertNewSPBlock(theFlow:ITextFlow, startPos:int, endPos:int, newSPB:ISubParagraphGroupElementBase, spgClass:String):Boolean
+		{
+			var curPos:int = startPos;
+			var curFBE:IFlowGroupElement = theFlow.findAbsoluteFlowGroupElement(curPos);
+			var elementIdx:int = 0;
+			
+			CONFIG::debug{ assert(curFBE != null, "No FBE at location curPos(" + curPos + ")!");}
+			
+			//if we are at the last "real" glyph of the paragraph, include the terminator.
+			var paraEl:IParagraphElement = curFBE.getParagraph();
+			if(endPos == (paraEl.getAbsoluteStart() + paraEl.textLength - 1))
+				++endPos;
+			
+			//before processing this any further, we need to make sure that we are not
+			//splitting a spg which is contained within the same type of spg as the curFBE's parent.
+			//for example, if we had a tcyElement inside a linkElement, then we cannot allow a link element
+			//to be made within the tcyElement as the link would not function.  As a rule, a SubParagraphElement
+			//cannot own a child of the same class.
+			//
+			//However, if the curFBE is parented by a spg and the objects have the same start and end, then we are doing
+			//a replace and we're not splitting the parent. Check if the bounds are the same and if so, don't skip it...
+			var parentStart:int = curFBE.parent.getAbsoluteStart();
+			var curFBEStart:int = curFBE.getAbsoluteStart();
+			if(curFBE.parent && curFBE.parent.className == spgClass && 
+				!(parentStart == curFBEStart && parentStart + curFBE.parent.textLength == curFBEStart + curFBE.textLength))
+			{
+				return false;
+			}
+			
+			//entire FBE is selected and is not a paragraph, get its parent.
+			if(!(curFBE is IParagraphElement) && curPos == curFBEStart && curPos + curFBE.textLength <= endPos)
+			{
+				elementIdx = curFBE.parent.getChildIndex(curFBE);
+				curFBE = curFBE.parent;
+			}
+			//first, if the curFBE is of the same class as the newSPB, then we need to split it to allow for insertion
+			//of the new one IF the start position is > the start of the curFBE
+			//
+			//running example after this block:
+			//	1) <a><span>ghijk</span><span>lmnop</span></a>
+			//	2) <a><span>ghij</span><b><span>k</span></b><b><span>lm</span></b><span>nop</span></a>
+			//	3) <a><span>ghijk</span><c><span>lmn</span></c><span>op</span></a> - no change
+			if(curPos >= curFBEStart)
+			{
+				if(!(curFBE.className == spgClass))
+					elementIdx = findAndSplitElement(curFBE, elementIdx, curPos, true);
+				else
+				{
+					elementIdx = findAndSplitElement(curFBE.parent, curFBE.parent.getChildIndex(curFBE), curPos, false);
+					curFBE = curFBE.parent;
+				}
+			}
+			
+			//now that the curFBE has been split, we want to insert the newSPB into the flow and then start absorbing the
+			//contents...
+			//running example after this block:
+			//	1) <a><span>ghijk</span><b></b><span>lmnop</span></a>
+			//	2) <a><span>ghij</span><b><span>k</span></b><b></b><b><span>lm</span></b><span>nop</span></a>
+			//	3) <a><span>ghijk</span><b></b><c><span>lmn</span></c><span>op</span></a> - no change
+			//
+		//	we need another use case here where selection is entire sbp and selection runs from the head of a spg to
+		//	part way through it - so that a) does into parent and b) goes into spg
+			
+			// if this is case 2, then the new element must go into the parent...
+			if(curFBE && curFBE.className == spgClass)
+			{
+				curFBEStart = curFBE.getAbsoluteStart();
+				elementIdx = curFBE.parent.getChildIndex(curFBE);
+				if(curPos > curFBEStart)//we're splitting the element, not replacing it...
+					elementIdx += 1;
+				
+				//if the spg, curFBE is entirely selected then we want to use the parent, not the item itself.
+				while(endPos >= curFBEStart + curFBE.textLength)
+				{
+					//we need access to the parent, which contains both the start and end not the FBE we just split
+					curFBE = curFBE.parent;
+				}
+				curFBE.replaceChildren(elementIdx, elementIdx, newSPB);
+			}
+			else
+			{
+				//we're inserting into the curFBE
+				curFBE.replaceChildren(elementIdx, elementIdx, newSPB);
+			}
+			
+			//see subsumeElementsToSPBlock to see effects on running example
+			subsumeElementsToSPBlock(curFBE, elementIdx + 1, curPos, endPos, newSPB, spgClass);
+			
+			return true;
+		}
+		
+		
+		/**
+		 * @private
+		 * splitElement - split <code>elem</code> at the relative index of <code>splitPos</code>.  If <code>splitSubBlockContents</code>
+		 * is true, split the contents of <code>elem</code> if it is a ISubParagraphGroupElementBase, otherwise just split <code>elem</code>
+		 * 
+		 * @param elem:FlowElement - the FlowElement to split
+		 * @param splitPos:int - The elem relative index indicating where to split
+		 * @param splitSubBlockContents:Boolean - boolean indicating whether a ISubParagraphGroupElementBase is to be split OR that it's contents
+		 * should be split.  For example, are we splitting a link or are we splitting the child of the link
+		 * 
+		 * <spg><span>ABCDEF</span></spg>
+		 * 
+		 * if <code>splitPos</code> indicated index between C and D, then if <code>splitSubBlockContents</code> equals true,
+		 * result is:
+		 * 
+		 * <spg><span>ABC</span><span>DEF</span></spg>
+		 * 
+		 * if <code>splitSubBlockContents</code> equals false, result is:
+		 * 
+		 * <spg><span>ABC</span></spg><spg><span>DEF</span></spg>
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.ISpanElement
+		 */
+		public static function splitElement(elem:IFlowElement, splitPos:int, splitSubBlockContents:Boolean):void
+		{
+			CONFIG::debug{ assert(splitPos < elem.textLength, "trying to splic FlowElement at illegal index!"); }
+			if (elem is ISpanElement)
+			{
+				ISpanElement(elem).splitAtPosition(splitPos);
+			}
+			else if(elem is ISubParagraphGroupElementBase && splitSubBlockContents)
+			{
+				var subBlock:ISubParagraphGroupElementBase = ISubParagraphGroupElementBase(elem);
+				// Split the ISpanElement of the block at splitPos.  If the item at the splitPos is not a ISpanElement, no action occurs.
+				var tempElem:ISpanElement = subBlock.findLeaf(splitPos) as ISpanElement;
+				if (tempElem)
+					tempElem.splitAtPosition(splitPos - tempElem.getElementRelativeStart(subBlock));
+			}
+			else if (elem is IFlowGroupElement)
+			{
+				IFlowGroupElement(elem).splitAtPosition(splitPos);
+			}
+			else
+			{
+				CONFIG::debug { assert(false, "Trying to split on an illegal FlowElement"); }				
+			}
+		}
+		
+		/**
+		 * @private
+		 * findAndSplitElement - starting at the child <code>elementIdx</code> of <code>fbe</code>, iterate
+		 * through the elements untill we find the one located at the aboslute index of <code>startIdx</code>. Upon
+		 * locating the child, split either the element itself OR its children based on the value of <code>splitSubBlockContents</code>
+		 * 
+		 * @param fbe:FlowGroupElement - the FBE into which the newSPB is being inserted.
+		 * @param elementIdx:int - The index into the <code>fbe's</code> child list to start
+		 * @param startIdx:int - The absolute index value into the ITextFlow.
+		 * @param splitSubBlockContents:Boolean - boolean indicating whether a subElement is to be split OR that it's contents
+		 * should be split.  For example, are we splitting a link or are we splitting the child of the link
+		 * 
+		 * <p>ZYX<link>ABCDEF</link>123</p>
+		 * 
+		 * if we are inserting a TCY into the link, splitSubBlockContents should be false. We want to split the span ABCDEF such that result is:
+		 * <p>ZYX<link>AB<tcy>CD</tcy>EF</link>123</p>
+		 * 
+		 * if we are creating a new link from X to B, then we want the link to split and splitSubBlockContents should be false:
+		 * 
+		 * <p>ZY<link>XAB</link><link>CDEF</link>123</p>
+		 * 
+		 * @return int - the index of the last child of <code>fbe</code> processed.
+		 */
+		public static function findAndSplitElement(fbe:IFlowGroupElement, elementIdx:int, startIdx:int, splitSubBlockContents:Boolean):int
+		{
+			var curFlowEl:IFlowElement = null;
+			var curIndexInPar:int = startIdx - fbe.getAbsoluteStart();
+			
+			while(elementIdx < fbe.numChildren)
+			{
+				curFlowEl = fbe.getChildAt(elementIdx);
+				if (curIndexInPar == curFlowEl.parentRelativeStart)
+					return elementIdx;
+				if ((curIndexInPar > curFlowEl.parentRelativeStart) && (curIndexInPar < curFlowEl.parentRelativeEnd))
+				{
+					splitElement(curFlowEl, curIndexInPar - curFlowEl.parentRelativeStart, splitSubBlockContents); 
+				}
+				++elementIdx;
+			}
+			return elementIdx;
+		}
+		
+		/**
+		 * @private
+		 * subsumeElementsToSPBlock - incorporates all elements of <code>parentFBE</code> into
+		 * the <code>newSPB</code> between the <code>curPos</code> and <code>endPos</code>.  If a child of
+		 * <code>parentFBE</code> is of type <code>spgClass</code> then the child's contents are removed from the child,
+		 * added to the <code>newSPB</code>, the child is then removed from the <code>parentFBE</code>
+		 * 
+		 * @param parentFBE:FlowGroupElement - the FBE into which the newSPB is being inserted.
+		 * @param startPos:int - The index value of the first position of the replacement range in the ITextFlow.
+		 * @param endPos:int - The index value following the end position of the replacement range in the ITextFlow.
+		 * @param newSPB:ISubParagraphGroupElementBase - the new ISubParagraphGroupElementBase we intend to insert.
+		 * @param spgClass:Class - the class of the fbe we intend to insert.
+		 * 
+		 * @return int - the aboslute index in the text flow after insertion.
+		 * 
+		 *  Examples: Simple and complex where insertion is of <code>spgClass</class> b.  Selection is l~o
+		 *		1) <a><span>ghijk</span><b></b><span>lmnop</span></a>
+		 *		2) <a><span>ghij</span><b><span>k</span></b><b></b><b><span>lm</span></b><span>nop</span></a>
+		 * 
+		 * 	parentFBE = <a>
+		 *  elementIdx = 1) 2, 2) 3
+		 *  curPos = 5
+		 *  endPos = 9
+		 *  newSPB is of type <b>
+		 */
+		public static function subsumeElementsToSPBlock(parentFBE:IFlowGroupElement, elementIdx:int, curPos:int, endPos:int, newSPB:ISubParagraphGroupElementBase, spgClass:String):int
+		{
+			var curFlowEl:IFlowElement = null;
+			
+			//if we have an invalid index, then skip out.  elementIdx will always point one
+			//element beyond the one we are inserting....
+			if(elementIdx >= parentFBE.numChildren)
+				return curPos;
+			
+			while (curPos < endPos)
+			{
+				//running example: curFlowEl is the element immediately after the inserted newSPB:
+				//	1) <a><span>ghijk</span><b></b><span>lmnop</span></a>
+				//		points to span-lmnop
+				//	2) <a><span>ghij</span><b><span>k</span></b><b></b><b><span>lm</span></b><span>nop</span></a>
+				//		points to b-lm
+				curFlowEl = parentFBE.getChildAt(elementIdx);
+				
+				//if the curFlowEl is of the Class we are adding (spgClass), and the entire thing is selected,
+				//then we are adding the entire block, but not spliting it - perform the split on the next block
+				
+				//I think this can be safely removed from here as ownership of contents is handled below.
+				//leaving in commented out code in case we need to revert - gak 05.01.08
+			/*	if(curFlowEl is spgClass && curPos == curFlowEl.getAbsoluteStart() && curFlowEl.getAbsoluteStart() + curFlowEl.textLength <= endPos)
+				{
+					curPos = parentFBE.getAbsoluteStart() + parentFBE.textLength;
+					continue;
+				}*/
+				
+				//if the endPos is less than the length of the curFlowEl, then we need to split it.
+				//if the curFlowEl is NOT of class type spgClass, then we need to break it
+				//
+				//Use case: splitting a link in two (or three as will be the result with head and tail sharing
+				//attributes...
+				//running example 1 hits this, but 2 does not. Using variation of 2:
+				//
+				// example: 1) <a><span>ghijk</span><b></b><span>lmnop</span></a>
+				// 			2a) <a><span>fo</span><b></b><b><span>obar</span></b></a> - selection: from o~a
+				//
+				// after this code:
+				//			1) <a><span>ghijk</span><b></b><span>lmno</span><span>p</span></a>
+				//			2a) <a><span>fo</span><b></b><b><span>oba</span></b><b><span>or</span></b></a>
+				if ((curPos + curFlowEl.textLength) > endPos)
+				{
+					splitElement(curFlowEl, endPos - curFlowEl.getAbsoluteStart(), !(curFlowEl.className == spgClass));  //changed to curFlowEl from newSPB as newSPB should be of type spgClass
+				}
+				
+				//add the length before replacing the elements
+				curPos += curFlowEl.textLength;
+				
+				//running example: after parentFBE.replaceChildren
+				//
+				//	1) curFlowEl = <span>lmno</span>
+				//		<a><span>ghijk</span><b></b>{curFlowEl}<span>p</span></a>
+				//
+				//	2) curFlowEl = <b><span>lm</span></b>
+				//		<a><span>ghij</span><b><span>k</span></b><b></b>{curFlowEl}<span>nop</span></a>
+				parentFBE.replaceChildren(elementIdx, elementIdx + 1);
+				
+				//if the curFlowEl is of type spgClass, then we need to take its children and
+				//add them to the newSPB because a spg cannot contain a child of the same class
+				//as itself
+				//
+				// exmaple: 2) curFlowEl = <b><span>lm</span></b>
+				if (curFlowEl && curFlowEl.className == spgClass)
+				{
+					var subBlock:ISubParagraphGroupElementBase = curFlowEl as ISubParagraphGroupElementBase;
+					//elementCount == 1 - <span>lm</span>
+					while (subBlock.numChildren > 0)
+					{
+						//fe[0] = <span>lm</span>
+						var fe:IFlowElement = subBlock.getChildAt(0);
+						//<span></span>
+						subBlock.replaceChildren(0, 1);
+						//<b><span>lm</span></b>
+						newSPB.replaceChildren(newSPB.numChildren, newSPB.numChildren, fe);
+					}
+					//when compelete, example 2 is:
+					//2) <a><span>ghij</span><b><span>k</span></b><b><span>lm</span></b><span>nop</span></a>
+				}
+				else 
+				{
+					//example 1, curFlowEl is <span>lmno</span>, so this is not hit
+					//
+					// extending element <a> from foo~other
+					// <a>foo</a><b>bar<a>other</a><b>
+					// curFlowEl = <b>bar<a>other</a><b>
+					//
+					// since <b> is a spg, we need to walk it's contents and remove any <a> elements
+					if(curFlowEl is ISubParagraphGroupElementBase)
+					{
+						//we need to dive into this spgClass and remove any fbes of type spgClass
+						//pass in the curFlowEl as the newSPB, remove any spgs of type spgClass, then 
+						//perform the replace on the newSPB passed in here
+						//
+						//ignore the return value of the recursive call as the length has already been
+						//accounted for above
+						flushSPBlock(curFlowEl as ISubParagraphGroupElementBase, spgClass);
+					}
+					newSPB.replaceChildren(newSPB.numChildren, newSPB.numChildren, curFlowEl);
+					
+					if(newSPB.numChildren == 1 && curFlowEl is ISubParagraphGroupElementBase)
+					{
+						var childSPGE:ISubParagraphGroupElementBase = curFlowEl as ISubParagraphGroupElementBase;
+						//running example:
+						//a.precedence = 800, tcy.precedence = kMinSPGEPrecedence
+						//this = <tcy><a><span>fooBar</span></a><tcy>
+						//childSPGE = <a><span>fooBar</span></a>
+						if(childSPGE.textLength == newSPB.textLength && (curPos >= endPos))
+						{
+							CONFIG::debug { assert(childSPGE.precedence != newSPB.precedence, "normalizeRange found two equal SPGEs"); }
+	
+							//if the child's precedence is higher than mine, I need to swap
+							if(childSPGE.precedence > newSPB.precedence)
+							{
+								//first, remove the child
+								//this = <tcy></tcy>
+								newSPB.replaceChildren(0,1);
+								
+								//we need to flop this object for the child
+								while(childSPGE.numChildren > 0)
+								{
+									//tempFE = <span>fooBar</span>
+									var tempFE:IFlowElement = childSPGE.getChildAt(0);
+									//child = <a></a>
+									childSPGE.replaceChildren(0,1);
+									//this = <tcy><span>fooBar</span></tcy>
+									newSPB.replaceChildren(newSPB.numChildren, newSPB.numChildren, tempFE);
+								}
+								
+								var myIdx:int = newSPB.parent.getChildIndex(newSPB);
+								CONFIG::debug{ assert(myIdx >= 0, "Invalid index!  How can a SubParagraphGroupElementBase normalizing not have a parent!"); }
+								
+								//add childSPGE in my place
+								newSPB.parent.replaceChildren(myIdx, myIdx + 1, childSPGE);
+								
+								//childSPGE = <tcy><a><span>fooBar</span></a></tcy>
+								childSPGE.replaceChildren(0,0,newSPB);
+							}
+						}
+					}
+				}
+				
+			}
+	
+			return curPos;
+		}
+		
+		/**
+		 * @private
+		 * findAndRemoveFlowGroupElement 
+		 *
+		 * @param theFlow The ITextFlow that is containing the elements to remove.
+		 * @param startPos The index value of the first position of the range in the ITextFlow where we want to perform removal.
+		 * @param endPos The index value following the end position of the range in the ITextFlow where we want to perform removal.
+		 * @param fbeClass Class the class of the fbe we intend to remove.
+		 * 
+		 * Walks through the elements of <code>theFlow</code> looking for any FlowGroupElement of type <code>fbeClass</class>
+		 * On finding one, it removes the FBE's contents and adds them back into the FBE's parent.  If the class of object is
+		 * embedded within another spg and this removal would break the parent spg, then the method does nothing.
+		 * 
+		 * Example:
+		 * 	<link>ABC<tcy>DEF</tcy>GHI</link>
+		 * 	Selection is on E and removal of link is attempted.
+		 * 	Because E is a child of a spg (tcy), and removing the link from E would split the parent spg (link),
+		 *  the action is disallowed.
+		 * 
+		 * Running example:
+		 * 	1) <link><tcy><span>foo</span></tcy><span>bar</span></link>
+		 * @return Boolean - true if items are removed or none are found.  false if operation is illegal.
+		 */ 
+		public static function findAndRemoveFlowGroupElement(theFlow:ITextFlow, startPos:int, endPos:int, fbeClass:String):Boolean
+		{
+			var curPos:int = startPos;
+			var curEl:IFlowElement;
+			
+			//walk through the elements
+			while (curPos < endPos)
+			{
+				var containerFBE:IFlowGroupElement = theFlow.findAbsoluteFlowGroupElement(curPos);
+				
+				//if the start of the parent is the same as the start of the current containerFBE, then
+				//we potentially have the wrong object.  We need to walk up the parents until we get to
+				//the one which starts at our start AND is the topmost object at that index.
+				//example: <a><b>foo</b> bar</a> - getting the object at "f" will yield the <b> element, not <a>
+				while(containerFBE.parent && containerFBE.parent.getAbsoluteStart() == containerFBE.getAbsoluteStart() && 
+					!(containerFBE.parent is IParagraphElement) && !(containerFBE is IParagraphElement)) //don't go beyond paragraph
+				{
+					containerFBE = containerFBE.parent;
+				}
+				
+				//if the absoluteFBE is the item we are trying to remove, we need to work with its parent, so
+				//reassign containerFBE.  For example, if an entire link were selected, we'd need to get it's parent to
+				//perform the removal
+				if(containerFBE && containerFBE.className == fbeClass)
+					containerFBE = containerFBE.parent;
+					
+				//before processing this any further, we need to make sure that we are not
+				//splitting a spg which is contained within the same type of spg as the curFBE's parent.
+				//for example, if we had a tcyElement inside a linkElement, then we cannot allow a link element
+				//to be broken within the tcyElement as the link would have to split the TCY.
+				var ancestorOfFBE:IFlowGroupElement = containerFBE.parent;
+				while(ancestorOfFBE != null && !(ancestorOfFBE.className == fbeClass))
+				{
+					if(ancestorOfFBE.parent && ancestorOfFBE.parent.className == fbeClass)
+					{
+						return false;
+					}
+					ancestorOfFBE = ancestorOfFBE.parent;
+				}
+				
+				//if this is a sbe block contained in another sbe, and it is entire within the 
+				//selection bounds, we need to use the parent sbe's container.  If it is splitting
+				//the child sbe, we don't allow this and it is handled later...
+				var containerFBEStart:int = containerFBE.getAbsoluteStart();
+				if(ancestorOfFBE && ancestorOfFBE.className == fbeClass && (containerFBEStart >= curPos && containerFBEStart + containerFBE.textLength <= endPos))
+					containerFBE = ancestorOfFBE.parent;
+					
+				var childIdx:int = containerFBE.findChildIndexAtPosition(curPos - containerFBEStart);
+				curEl = containerFBE.getChildAt(childIdx);
+				if(curEl && curEl.className == fbeClass)
+				{
+					CONFIG::debug{ assert(curEl is ISubParagraphGroupElementBase, "Wrong FBE type!  Trying to remove illeage FBE!"); }
+					var curFBE:IFlowGroupElement = curEl as IFlowGroupElement;
+					
+					//get it's parent and the index of the curFBE
+					var parentBlock:IFlowGroupElement = curFBE.parent;
+					var idxInParent:int = parentBlock.getChildIndex(curFBE);
+					
+					//if the curPos is not at the head of the SPB, then we need to split it here
+					//curFBE will point to the FBE starting at curPos
+					if(curPos > curFBE.getAbsoluteStart())
+					{
+						splitElement(curFBE, curPos - curFBE.getAbsoluteStart(), false);
+						curPos = curFBE.getAbsoluteStart() + curFBE.textLength;
+						continue;
+					}
+					
+					//if curFBE goes beyond the endPos, then we need to split off the tail.
+					if (curFBE.getAbsoluteStart() + curFBE.textLength > endPos)
+					{
+						splitElement(curFBE, endPos - curFBE.getAbsoluteStart(), false);
+					}
+				
+					//apply the length of the curFBE to the curPos tracker.  Do this before 
+					//removing the contents or it will be 0!
+					curPos = curFBE.getAbsoluteStart() + curFBE.textLength;
+					
+					//walk all the contents of the FBE into it's parent container
+					while (curFBE.numChildren > 0)
+					{
+						var childFE:IFlowElement = curFBE.getChildAt(0);
+						curFBE.replaceChildren(0, 1);
+						parentBlock.replaceChildren(idxInParent, idxInParent, childFE);
+						idxInParent++; 
+					}
+					
+					//remove the curFBE
+					parentBlock.replaceChildren(idxInParent, idxInParent + 1);
+				}
+				else if(curEl is ISubParagraphGroupElementBase) //check all the parents...
+				{
+					var curSPB:ISubParagraphGroupElementBase = ISubParagraphGroupElementBase(curEl);
+					if(curSPB.numChildren == 1)
+						curPos = curSPB.getAbsoluteStart() + curSPB.textLength;
+					else
+					{
+						curEl = curSPB.getChildAt(curSPB.findChildIndexAtPosition(curPos - curSPB.getAbsoluteStart()));
+						curPos = curEl.getAbsoluteStart() + curEl.textLength;
+					}
+				}
+				else
+				{
+					//the current block isn't the type we're looking for, so just go to the end of the
+					//FlowElement and continue
+					curPos = curEl.getAbsoluteStart() + curEl.textLength;
+				}
+				
+			}
+			
+			return true;
+		}
+		
+		/**
+		 * @private
+		 * canInsertSPBlock 
+		 * 
+		 * validate that we a valid selection to allow for insertion of a subBlock.  The rules are as
+		 * follows:
+		 * 	endPos > start
+		 * 	the new block will not span multiple paragraphs
+		 *  if the block is going into a SubParagraphGroupElementBase, it must not split the block:
+		 * 		example:  Text 		- ABCDEFG with a link on CDE
+		 * 		legal new Block		- D, CD, CDE, [n-chars]CDE[n1-chars]
+		 * 		illegal new Block 	- [1 + n-chars]C[D], [D]E[1 + n-chars]
+		 * 			exception - if the newBlock is the same class as the one we are trying to split
+		 * 			then we can truncate the original and add its contents to the new one, or extend it
+		 * 			as appropriate
+		 * 
+		 * @param theFlow The ITextFlow that is containing the elements to validate.
+		 * @param startPos The index value of the first position of the range in the ITextFlow to test.
+		 * @param endPos The index value following the end position of the range in the ITextFlow to test.
+		 * @param blockClass Class the class of the fbe we intend to insert.
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.IFlowGroupElement
+		 */
+		public static function canInsertSPBlock(theFlow:ITextFlow, startPos:int, endPos:int, blockClass:String):Boolean
+		{
+			if(endPos <= startPos)
+				return false;
+				
+			var anchorFBE:IFlowGroupElement = theFlow.findAbsoluteFlowGroupElement(startPos);
+			if(anchorFBE.getParentByType(blockClass))
+				anchorFBE = anchorFBE.getParentByType(blockClass) as IFlowGroupElement;
+				
+			var tailFBE:IFlowGroupElement = theFlow.findAbsoluteFlowGroupElement(endPos - 1);
+			if(tailFBE.getParentByType(blockClass))
+				tailFBE = tailFBE.getParentByType(blockClass) as IFlowGroupElement;
+			
+			//if these are the same FBEs then we are safe to insert a SubParagraphGroupElementBase
+			if(anchorFBE == tailFBE)
+				return true;
+			//make sure that the two FBEs belong to the same paragraph!
+			else if(anchorFBE.getParagraph() != tailFBE.getParagraph())
+				return false;
+			else if(anchorFBE.className == blockClass && tailFBE.className == blockClass)//they're the same class, OK to merge, split, etc...
+				return true;
+			else if(anchorFBE.className == "SubParagraphGroupElementBase" && !(anchorFBE.className == blockClass))
+			{
+				var anchorStart:int = anchorFBE.getAbsoluteStart();
+				if(startPos > anchorStart && endPos > anchorStart + anchorFBE.textLength)
+					return false;
+			}
+			else if((anchorFBE.parent is ISubParagraphGroupElementBase || tailFBE.parent is ISubParagraphGroupElementBase)
+				&& anchorFBE.parent != tailFBE.parent)
+			{
+				//if either FBE parent is a SPGE and they are not the same, prevent the split.  
+				return false;
+			}	
+			
+			//if we got here, then the anchorFBE is OK, check the tail.  If endPos is pointing to the
+			//0th character of a FlowGroupElement, we don't need to worry about the tail.
+			if(tailFBE is ISubParagraphGroupElementBase && !(tailFBE.className == blockClass) && endPos > tailFBE.getAbsoluteStart())
+			{
+				var tailStart:int = tailFBE.getAbsoluteStart();
+				if(startPos < tailStart && endPos < tailStart + tailFBE.textLength)
+					return false;
+			}	
+			return true;
+		}
+		
+		/**
+		 * @private flushSPBlock recursively walk a spg looking for elements of type spgClass.  On finding one,
+		 * remove it's children and then remove the object itself.  Since spg's cannot hold children of the same type
+		 * as themselves, recursion is only needed for spg's of a class other than that of spgClass.
+		 * 
+		 * example: subPB = <b>bar<a>other</a><b> extending an <a> element to include all of "other"
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.IFlowGroupElement
+		 */ 
+		public static function flushSPBlock(subPB:ISubParagraphGroupElementBase, spgClass:String):void
+		{
+			var subParaIter:int = 0;
+	
+			//example, subPB has 2 elements, <span>bar</span> and <a><span>other</span></a>
+			while(subParaIter < subPB.numChildren)
+			{
+				//subParaIter == 0, subFE = <span>bar</span> skip the FE and move to next
+				//subParaIter == 1, subFE = <a><span>other</span></a> - is a spgClass
+				var subFE:IFlowElement = subPB.getChildAt(subParaIter);
+				if(subFE && subFE.className == spgClass)
+				{
+					//subParaIter == 1, subFE = <a><span>other</span></a>
+					var subChildFBE:IFlowGroupElement = subFE as IFlowGroupElement;
+					while(subChildFBE.numChildren > 0)
+					{
+						//subFEChild = <span>other</span>
+						var subFEChild:IFlowElement = subChildFBE.getChildAt(0);
+						//subFEChild = <a></a>
+						subChildFBE.replaceChildren(0, 1);
+						//subPB = <b>barother<a></a><b>
+						subPB.replaceChildren(subParaIter, subParaIter, subFEChild);
+					}
+					
+					//increment so that subParaIter points to the element we just emptied
+					++subParaIter;
+					//remove the empty child
+					//subPB = <b>barother<b>
+					subPB.replaceChildren(subParaIter, subParaIter + 1);
+				}
+				else if(subFE is ISubParagraphGroupElementBase)
+				{
+					flushSPBlock(subFE as ISubParagraphGroupElementBase, spgClass);
+					++subParaIter;
+				}
+				else
+					++subParaIter;//go to next child
+			}
+		}
+		
+		/** returns next paragraph in reading order after para. Used for merging paragraphs after delete.  */
+		public static function findNextParagraph(para:IParagraphElement):IParagraphElement
+		{
+			if (para)
+			{
+				var leaf:IFlowLeafElement = para.getLastLeaf();
+				leaf = leaf.getNextLeaf();
+				if (leaf)
+					return leaf.getParagraph();
+			}
+			return null;
+		/*	var sibParagraph:IParagraphElement;
+			if (para && para.parent)
+			{
+				var child:IFlowGroupElement = para;
+				var parent:IFlowGroupElement = para.parent;
+				
+				var myidx:int = parent.getChildIndex(child);
+				
+				// go up the chain till not on last child
+				while(myidx == parent.numChildren-1)
+				{
+					child = parent;
+					parent = parent.parent;
+					myidx = parent.getChildIndex(child);
+				}
+				if (myidx != parent.numChildren-1)
+				{
+					// go down the first child descendents till reach a paragraph
+					var sibElement:IFlowGroupElement = parent.getChildAt(myidx+1) as IFlowGroupElement;
+					while(sibElement && !(sibElement is IParagraphElement))
+					{
+						sibElement = sibElement.getChildAt(0) as IFlowGroupElement;	
+					}
+					sibParagraph = sibElement as IParagraphElement;
+				}
+			}
+			return sibParagraph; */
+		}
+		
+		/** if parent is a singleton element, deletes it, then repeats deletion of singletons up the parent chain.  Used after paragraph merge. */
+		public static function removeEmptyParentChain(parent:IFlowGroupElement):IMemento
+		{
+			if(parent is IParagraphElement)
+				IParagraphElement(parent).removeEmptyTerminator();
+			var mementoList:MementoList = new MementoList(parent.getTextFlow());
+			while(parent && (parent.numChildren == 0))
+			{
+				var grandParent:IFlowGroupElement = parent.parent;
+				if(grandParent is IParagraphElement)
+					IParagraphElement(grandParent).removeEmptyTerminator();
+				if(grandParent)
+				{
+					var parentIdx:int = grandParent.getChildIndex(parent);
+					mementoList.push(ModelEdit.removeElements(grandParent.getTextFlow(), grandParent, parentIdx, 1));
+					//grandParent.replaceChildren(parentIdx, parentIdx+1);
+				}
+				parent = grandParent;
+			}
+			return mementoList;
+		}
+		
+		/** Joins this paragraph's next sibling to this if it is a paragraph */
+		static public function joinNextParagraph(para:IParagraphElement, inSameParent:Boolean):IMemento
+		{		
+			var nextPara:IParagraphElement = findNextParagraph(para);
+			if (nextPara && (!inSameParent || para.parent == nextPara.parent))
+				return joinToElement(para, nextPara);
+			return null;
+		}
+
+		/** Joins this paragraph's next sibling to this if it is a paragraph */
+		static public function joinToNextParagraph(para:IParagraphElement, inSameParent:Boolean):MementoList
+		{		
+			var sibParagraph:IParagraphElement = findNextParagraph(para);
+			if (sibParagraph && (!inSameParent || para.parent == sibParagraph.parent))
+				return joinToNextElement(para, sibParagraph);
+			return null;
+		}
+
+		/** Joins this element2 to element1 -- all children of element2 added to end of element1 */
+		static public function joinToElement(element1:IFlowGroupElement, element2:IFlowGroupElement):IMemento
+		{	
+			var list:MementoList;
+			
+			if (element1 && element2)
+			{
+		/*		list = new MementoList(element1.getTextFlow());
+				
+				var elementList:Array = element2.mxmlChildren;
+				
+				list.push(ModelEdit.removeElements(element2.getTextFlow(), element2, 0, element2.numChildren)); // remove children of the second element
+
+				for(var i:int=0; i<elementList.length; ++i) // add them to the first element
+				{
+					list.push(ModelEdit.addElement(element1.getTextFlow(), elementList[i], element1, element1.numChildren));
+				}
+				// remove (empty) element2 and chain of any empty parents
+				list.push(removeEmptyParentChain(element2));
+				return list;
+				*/
+				return ModelEdit.joinElement(element2.getTextFlow(), element1, element2);
+			}
+			return list;
+		}
+		
+		/** Joins this element1 to element2 -- all children of element1 added to front of element2 */
+		static public function joinToNextElement(element1:IFlowGroupElement, element2:IFlowGroupElement):MementoList
+		{		
+			var list:MementoList;
+
+			if (element1 && element2)
+			{
+				list = new MementoList(element1.getTextFlow());
+
+				var elementList:Array = element1.mxmlChildren;
+				list.push(ModelEdit.removeElements(element1.getTextFlow(), element1, 0, element1.numChildren)); // remove children of the first element
+				for(var i:int=elementList.length - 1; i>=0; --i) // add them to the second element
+				{
+					list.push(ModelEdit.addElement(element2.getTextFlow(), elementList[i], element2, 0));
+				}
+				// remove (empty) element1 and chain of any empty parents
+				list.push(removeEmptyParentChain(element1));
+				return list;
+			}
+			return list;
+		}
+		
+								
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/TextScrap.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/TextScrap.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/TextScrap.as
new file mode 100644
index 0000000..2e38239
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/TextScrap.as
@@ -0,0 +1,187 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.edit
+{
+	import org.apache.flex.textLayout.conversion.ConversionConstants;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	import org.apache.flex.textLayout.elements.IParagraphElement;
+	import org.apache.flex.textLayout.elements.ISpanElement;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.textLayout.elements.TextRange;
+
+	
+
+
+	/**
+	 * The TextScrap class represents a fragment of a text flow.
+	 * 
+	 * <p>A TextScrap is a holding place for all or part of a TextFlow. A range of text can be copied 
+	 * from a TextFlow into a TextScrap, and pasted from the TextScrap into another TextFlow.</p>
+	 *
+	 * @see org.apache.flex.textLayout.elements.TextFlow
+	 * @see org.apache.flex.textLayout.edit.SelectionManager
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+ 	 * @langversion 3.0
+	*/	
+	public class TextScrap
+	{	
+		private var _textFlow:ITextFlow;
+		private var _plainText:int;		/* flag to tell if text in scrap is plain or formatted: -1 = unknown, 0 = false, 1 = true
+
+		// These are duplicates of same entries in TextConverter, here to avoid dragging in more code caused by compiler bug.
+		// Remove this when http://bugs.adobe.com/jira/browse/ASC-4092 is fixed. 
+		/** @private */
+		static public const MERGE_TO_NEXT_ON_PASTE:String = "mergeToNextOnPaste";
+		
+		/**
+		 * Creates a TextScrap object.
+		 * 
+		 * <p>Use the <code>createTextScrap()</code> method to create a TextScrap object from
+		 * a range of text represented by a TextRange object.</p>
+		 *  
+		 * @param textFlow if set, the new TextScrap object contains the entire text flow.
+		 * Otherwise, the TextScrap object is empty.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */												
+		public function TextScrap(textFlow:ITextFlow = null)
+		{
+			_textFlow = textFlow;
+			_textFlow.flowComposer = null;	// no flowcomposer in a TextScrap
+			_plainText = -1;
+		}
+
+		/**
+		 * Creates a TextScrap object from a range of text represented by a TextRange object.
+		 * 
+		 * @param range the TextRange object representing the range of text to copy.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */
+		public static function createTextScrap(range:TextRange):TextScrap
+		{
+			var startPos:int = range.absoluteStart;
+			var endPos:int = range.absoluteEnd;
+			var theFlow:ITextFlow = range.textFlow;
+			
+			if (!theFlow || startPos >= endPos) 
+				return null;
+			var newTextFlow:ITextFlow = theFlow.deepCopy(startPos, endPos) as ITextFlow;
+			newTextFlow.normalize();
+			var retTextScrap:TextScrap = new TextScrap(newTextFlow);
+			if (newTextFlow.textLength > 0)
+			{
+				var fl:IFlowElement = newTextFlow.getLastLeaf();
+				
+				var srcElem:IFlowElement = theFlow.findLeaf(endPos - 1);
+				var copyElem:IFlowElement = newTextFlow.getLastLeaf();
+				if ((copyElem is ISpanElement) && (!(srcElem is ISpanElement)))
+					copyElem = newTextFlow.findLeaf(newTextFlow.textLength - 2);
+				
+				while (copyElem && srcElem)
+				{
+					if (endPos < srcElem.getAbsoluteStart() + srcElem.textLength)
+						copyElem.setStyle(ConversionConstants.MERGE_TO_NEXT_ON_PASTE, "true");
+					copyElem = copyElem.parent;
+					srcElem = srcElem.parent;
+				}
+				return retTextScrap;
+			}
+			return null;
+		}
+		
+		/** 
+		 * Gets the TextFlow that is currently in the TextScrap.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */												
+		public function get textFlow():ITextFlow
+		{
+			return _textFlow;
+		}
+		
+		/**
+		 * Creates a duplicate copy of this TextScrap object.
+		 * 
+		 * @return TextScrap A copy of this TextScrap.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+ 	 	 * @langversion 3.0
+		 */
+		public function clone():TextScrap
+		{
+			return new TextScrap(textFlow.deepCopy() as ITextFlow);
+		}
+
+		/** Marks the TextScrap's content as being either plain or formatted */
+		public function setPlainText(plainText:Boolean):void
+		{
+			_plainText = plainText ? 0 : 1;
+		}
+		
+		/** 
+		 * Returns true if the text is plain text (not formatted)
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */												
+		public function isPlainText():Boolean
+		{
+			var foundAttributes:Boolean = false;
+			
+			if (_plainText == -1)
+			{
+				for (var i:int = _textFlow.numChildren - 1; i >= 0; --i)
+					_textFlow.getChildAt(i).applyFunctionToElements(isPlainElement);
+				_plainText = foundAttributes ? 1 : 0;
+			}
+			return _plainText == 0;
+			
+			function isPlainElement(element:IFlowElement):Boolean
+			{
+				if (!(element is IParagraphElement) && !(element is ISpanElement))
+				{
+					foundAttributes = true;
+					return true;
+				}
+				var styles:Object = element.styles;
+				if (styles)
+				{
+					for (var prop:String in styles)
+					{
+						if (prop != ConversionConstants.MERGE_TO_NEXT_ON_PASTE)
+						{
+							foundAttributes = true;
+							return true;		// stops iteration
+						}
+					}
+				}
+				return false;
+			}
+		}
+	} // end TextScrap class
+} // end package

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/mementos/AddElementMemento.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/mementos/AddElementMemento.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/mementos/AddElementMemento.as
new file mode 100644
index 0000000..59ffcd6
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/mementos/AddElementMemento.as
@@ -0,0 +1,71 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.edit.mementos {
+	import org.apache.flex.textLayout.edit.ElementMark;
+	import org.apache.flex.textLayout.edit.IMemento;
+	import org.apache.flex.textLayout.elements.IFlowElement;
+	import org.apache.flex.textLayout.elements.IFlowGroupElement;
+	import org.apache.flex.textLayout.elements.ITextFlow;
+
+	public class AddElementMemento extends BaseMemento implements IMemento {
+		private var _target:ElementMark;
+		private var _targetIndex:int;
+		private var _elemToAdd:IFlowElement;
+
+		public function AddElementMemento(textFlow:ITextFlow, elemToAdd:IFlowElement, target:ElementMark, index:int) {
+			super(textFlow);
+			_target = target;
+			_targetIndex = index;
+			_elemToAdd = elemToAdd;
+		}
+
+		/**
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.IFlowGroupElement
+		 */
+		static public function perform(textFlow:ITextFlow, elemToAdd:IFlowElement, parent:IFlowGroupElement, index:int, createMemento:Boolean):* {
+			var elem:IFlowElement = elemToAdd;
+			if (createMemento)
+				elemToAdd = elem.deepCopy();	// for redo
+
+			var target:ElementMark = new ElementMark(parent, 0);
+
+			var targetElement:IFlowGroupElement = target.findElement(textFlow) as IFlowGroupElement;
+			targetElement.addChildAt(index, elem);
+			if (createMemento)
+				return new AddElementMemento(textFlow, elemToAdd, target, index);
+			return null;
+		}
+
+		/**
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.IFlowGroupElement
+		 */
+		public function undo():* {
+			var target:IFlowGroupElement = _target.findElement(_textFlow) as IFlowGroupElement;
+			target.removeChildAt(_targetIndex);
+		}
+
+		/**
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.IFlowGroupElement
+		 */
+		public function redo():* {
+			var parent:IFlowGroupElement = _target.findElement(_textFlow) as IFlowGroupElement;
+			return perform(_textFlow, _elemToAdd, parent, _targetIndex, false);
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/mementos/BaseMemento.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/mementos/BaseMemento.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/mementos/BaseMemento.as
new file mode 100644
index 0000000..bc070eb
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/mementos/BaseMemento.as
@@ -0,0 +1,50 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.edit.mementos {
+	import org.apache.flex.textLayout.elements.ITextFlow;
+	import org.apache.flex.textLayout.debug.Debugging;
+
+	public class BaseMemento
+{
+	protected var _textFlow:ITextFlow;
+	
+	public function BaseMemento(textFlow:ITextFlow)
+	{ _textFlow = textFlow; }
+	
+	CONFIG::debug public function debugCheckTextFlow(s:String):void
+	{
+		trace(s);
+		var saveDebugCheckTextFlow:Boolean = Debugging.debugCheckTextFlow;
+		var saveVerbose:Boolean = Debugging.verbose;
+		Debugging.debugCheckTextFlow = true;
+		Debugging.verbose = true;
+		try
+		{
+			_textFlow.debugCheckTextFlow(false);
+		}
+		finally
+		{
+			Debugging.debugCheckTextFlow = saveDebugCheckTextFlow;
+			Debugging.verbose = saveVerbose;
+		}
+	}
+	
+}
+
+}
\ No newline at end of file


[18/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IConfiguration.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IConfiguration.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IConfiguration.as
new file mode 100644
index 0000000..65e0dc9
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IConfiguration.as
@@ -0,0 +1,364 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements {
+	import org.apache.flex.textLayout.edit.SelectionFormat;
+	import org.apache.flex.textLayout.formats.IListMarkerFormat;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	/** Read-only interface to a configuration object.  Used by TextFlow to guarantee it has an unchangeable 
+	 * configuration once its constructed.
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 */
+	public interface IConfiguration 
+	{
+		/** Creates a writeable clone of the IConfiguration object.
+		 *
+		 * @playerversion Flash 10.2
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function clone():IConfiguration;
+		
+		/** 
+		* Specifies whether the TAB key is entered as text by Text Layout Framework, or Flash Player or AIR handles it and 
+		* turns it into a tabbed panel event. 
+		*
+		* <p>Default value is <code>false</code>.</p>
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+		* @langversion 3.0
+		*/
+		
+		function get manageTabKey():Boolean;
+
+		/** 
+		* Specifies whether the Enter / Return key is entered as text by Text Layout Framework, to split a paragraph for example,
+		* or the client code handles it. The client code might handle it by committing a form that has a default button 
+		* for that purpose, for example. 
+		*
+		* <p>Default value is <code>true</code>.</p>
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+		* @langversion 3.0
+		*/
+		
+		function get manageEnterKey():Boolean;
+		
+		/** 
+		 * Determines how shift-enter is treated. Shift-enter can be treated as a soft return or hard return.
+		 * There are three possible levels. Level 0 means all shift-returns will be hard returns.
+		 * Level 1 means shift-returns inside lists will be treated as hard returns. Otherwise they will be treated as hard returns.
+		 * Level 2 means all shift-returns will be treated as soft returns.
+		 *
+		 * <p>Default value is <code>2</code>.</p>
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		
+		function get shiftEnterLevel():int;
+		/** 
+		* Policy used for deciding whether the last line of a container fits in the container, or whether it overflows.
+		* Use the constants of the OverflowPolicy class to set this property.
+		*
+		* <p>Default value is OverflowPolicy.FIT_DESCENDERS, which fits the line in the composition area if the area
+		* from the top to the baseline fits.</p>
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+		* @langversion 3.0
+		*
+		* @see OverflowPolicy
+		*/
+		
+		function get overflowPolicy():String;
+		
+		/** 
+		* Specifies whether accessibility support is turned on or not.  If <code>true</code>, screen readers can read the TextFlow contents.
+		*
+		* <p>Default value is <code>false</code>.</p>
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+		* @langversion 3.0
+		*
+		* @see TextFlow
+		*/
+		
+		function get enableAccessibility():Boolean;
+		
+		/** 
+		* Specifies the initial link attributes for all LinkElement objects in the text flow. These are default
+		* values for new LinkElement objects that don't specify values for these attributes.
+		*
+		* The default normal format displays the link in blue with underlining.
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+	 	* @langversion 3.0
+	 	*
+		* @see FlowElement#linkNormalFormat
+		* @see org.apache.flex.textLayout.formats.ITextLayoutFormat ITextLayoutFormat
+		* @see LinkElement
+		*/
+		
+		function get defaultLinkNormalFormat():ITextLayoutFormat;
+		
+		/** 
+		* Specifies the initial character format attributes that apply to a link (LinkElement) in the text flow when
+		* the cursor hovers over it. These are defaults for new LinkElement objects that don't specify values
+		* for these attributes.
+		*
+		* <p>Default is <code>null</code>.</p>
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+		* @langversion 3.0
+		*
+		* @see  FlowElement#linkHoverFormat
+		* @see org.apache.flex.textLayout.formats.ITextLayoutFormat ITextLayoutFormat
+		* @see LinkElement
+		*/
+		
+		function get defaultLinkHoverFormat():ITextLayoutFormat;
+		
+		/** 
+		* Specifies the active character format attributes that initially apply for all links (LinkElement objects) in the text 
+		* flow. These are defaults for new LinkElement objects that don't specify values for these attributes. 
+		*
+		* <p>Default is <code>null</code>.</p>
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+		* @langversion 3.0
+		*
+		* @see FlowElement#linkActiveFormat 
+		* @see org.apache.flex.textLayout.formats.ITextLayoutFormat ITextLayoutFormat
+		* @see LinkElement
+		*/
+		
+		function get defaultLinkActiveFormat():ITextLayoutFormat;
+
+		/** 
+		 * Specifies the active character format attributes that initially apply for all ListItems in the text 
+		 * flow. These are defaults for new ListItemElements objects that don't specify values for these attributes. 
+		 *
+		 * <p>Default is <code>null</code>.</p>
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * @see FlowElement#linkActiveFormat 
+		 * @see org.apache.flex.textLayout.formats.ITextLayoutFormat ITextLayoutFormat
+		 * @see LinkElement
+		 */
+		
+		function get defaultListMarkerFormat():IListMarkerFormat;
+			
+		/** 
+		* Specifies the initial format TextLayoutFormat configuration for a text flow (TextFlow object).
+		*
+		* <p>Default is <code>null</code>.</p>
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+		* @langversion 3.0
+		*
+		* @see TextFlow
+		* @see org.apache.flex.textLayout.formats.ITextLayoutFormat ITextLayoutFormat
+		*/
+		
+		function get textFlowInitialFormat():ITextLayoutFormat;
+		
+		/** 
+		* The initial selection format (SelectionFormat) for a text flow (TextFlow) when its window has focus. 
+		* Text Layout Framework uses <code>focusedSelectionFormat</code> to draw the selection when the window is active and one of 
+		* the containers in the TextFlow has focus. You can override this format using 
+		* <code>SelectionManager.focusedSelectionFormat</code>, if desired.
+		*
+		* <p>The SelectionFormat class specifies the default values, which invert the color of the text and its background.</p>
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+		* @langversion 3.0
+		*
+		* @see org.apache.flex.textLayout.edit.SelectionFormat SelectionFormat
+		* @see org.apache.flex.textLayout.edit.SelectionManager#focusedSelectionFormat SelectionManager.focusedSelectionFormat
+		* @see TextFlow
+		*/
+		
+		function get focusedSelectionFormat():SelectionFormat;
+		
+		/** 
+		* The initial selection format that Text Layout Framework uses to draw the selection when the window is active but none of the containers
+		* in the TextFlow have focus. You can override this format using <code>SelectionManager.unfocusedSelectionFormat</code>, if desired.
+		*
+		* <p>If you do not override <code>unfocusedSelectionFormat</code> the SelectionFormat values used are:</p>
+		*
+		* <ul>
+		*   <li><code>color = 0xffffff</code> (white)</li>
+		*   <li><code>alpha = 0</code></li>
+		*   <li><code>blendMode = flash.display.BlendMode.DIFFERENCE</code></li>
+		* </ul>
+		* <p>The result is no selection is displayed.</p>
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+		* @langversion 3.0
+		*
+		* @see org.apache.flex.textLayout.edit.SelectionFormat SelectionFormat
+		* @see org.apache.flex.textLayout.edit.SelectionManager#unfocusedSelectionFormat SelectionManager.unfocusedSelectionFormat
+		* @see TextFlow
+		*/
+		
+		function get unfocusedSelectionFormat():SelectionFormat;
+		
+		/** 
+		* The initial selection format (SelectionFormat) for a text flow (TextFlow) when its window is inactive. Text Layout Framework uses 
+		* <code>inactiveSelectionFormat</code> for drawing the selection when the window is inactive. You can override 
+		* this format using <code>SelectionManager.inactiveSelectionFormat</code>, if desired.
+		*
+		* <p>If you do not override <code>unfocusedSelectionFormat</code> the SelectionFormat values used are:</p> 
+		* <ul>
+		*   <li><code>color = 0xffffff</code> (white)</li>
+		*   <li><code>alpha = 0</code></li>
+		*   <li><code>blendMode = flash.display.BlendMode.DIFFERENCE</code></li>
+		* </ul>
+		* <p>The result is no selection is displayed.</p>
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+		* @langversion 3.0
+		*
+		* @see org.apache.flex.textLayout.edit.SelectionFormat SelectionFormat
+		* @see org.apache.flex.textLayout.edit.SelectionManager#inactiveSelectionFormat SelectionManager.inactiveSelectionFormat
+		* @see TextFlow
+		*/
+		
+		function get inactiveSelectionFormat():SelectionFormat;	
+		
+		/** 
+		* Specifies a timed delay between one scroll and the next to prevent scrolling from going 
+		* too fast. This value specifies what the delay is in milliseconds. The default value is 35.
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+		* @langversion 3.0
+		*/
+		
+		function get scrollDragDelay():Number;
+		
+		/** Specifies the default number of pixels to scroll when the user initiates auto scrolling by dragging 
+		* the selection. Default value is 20.
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+		* @langversion 3.0
+		*/
+		
+		function get scrollDragPixels():Number;
+		
+		/**
+		* Specifies the default percentage of the text flow to scroll for page scrolls. Default value is
+		* 7.0 / 8.0, or .875.
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+		* @langversion 3.0
+		*/
+		
+		function get scrollPagePercentage(): Number;
+		
+		/** Specifies the default number of pixels to scroll for Mouse wheel events. Default value is 20.
+		*
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+		* @langversion 3.0
+		*/
+		
+		function get scrollMouseWheelMultiplier(): Number;
+		
+		/** Specifies the type of flow composer to attach to a new TextFlow object by default. Default value is StandardFlowComposer.
+		*
+		* @see org.apache.flex.textLayout.compose.StandardFlowComposer StandardFlowComposer
+		* @see org.apache.flex.textLayout.elements.TextFlow TextFlow
+		* 
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+		* @langversion 3.0
+		*/
+		
+		function get flowComposerClass():Class;
+		
+		/** Requests that the process of composing text release line creation data after composing each paragraph.  
+		* This request saves memory but slows down the composing process.
+		*
+		* <p>Default value is <code>false</code>.</p>
+		*
+		* @see org.apache.flex.textLayout.compose.StandardFlowComposer StandardFlowComposer
+		* @see org.apache.flex.text.engine.TextBlock#releaseLineCreationData() TextBlock.releaseLineCreationData()
+		* 
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+		* @langversion 3.0
+		*/
+		function get releaseLineCreationData():Boolean;
+		
+		/** Specifies the callback used for resolving an inline graphic element.
+		* The callback takes a <code>org.apache.flex.textLayout.elements.InlineGraphicElement</code> object and returns
+		* the value to be used as the element's <code>org.apache.flex.textLayout.elements.InlineGraphicElement#source</code>.
+		* 
+		* This callback provides the mechanism to delay providing an inline graphic element's source until just before it is composed.
+		* <p><strong>Note:</strong> this callback will be invoked only if a 
+		* placeholder source of String type is already set. Moreover, it may be invoked
+		* multiple times. </p>
+		* 
+		* @see org.apache.flex.textLayout.elements.InlineGraphicElement InlineGraphicElement
+		* 
+		* @playerversion Flash 10
+		* @playerversion AIR 1.5
+		* @langversion 3.0
+		*/
+		function get inlineGraphicResolverFunction():Function;
+
+		/** Specifies the callback used for custom cursor.
+		 * The callback takes a <code>String</code> object, string is cursor name and returns the value to
+		 * be used in MouseCursor.cursor.
+		 * 
+		 * This callback provides the user to customize the cursor
+		 * 
+		 * 
+		 * 
+		 * @playerversion Flash 10.2
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function get cursorFunction():Function;
+
+		function set flowComposerClass(flowComposerClass:Class):void;
+
+		function set textFlowInitialFormat(textFlowInitialFormat:ITextLayoutFormat):void;
+		function getImmutableClone():IConfiguration;
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IContainerFormattedElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IContainerFormattedElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IContainerFormattedElement.as
new file mode 100644
index 0000000..bfac40a
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IContainerFormattedElement.as
@@ -0,0 +1,31 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements {
+	import org.apache.flex.textLayout.compose.IFlowComposer;
+
+	public interface IContainerFormattedElement extends IParagraphFormattedElement {
+		function get flowComposer():IFlowComposer;
+
+		function preCompose():void;
+		function set paddingTop(paddingTop:*):void;
+		function set paddingBottom(paddingBottom:*):void;
+		function set paddingLeft(paddingLeft:*):void;
+		function set paddingRight(paddingRight:*):void;
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IDivElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IDivElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IDivElement.as
new file mode 100644
index 0000000..0e9a680
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IDivElement.as
@@ -0,0 +1,24 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	public interface IDivElement extends IContainerFormattedElement
+	{
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IExplicitFormatResolver.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IExplicitFormatResolver.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IExplicitFormatResolver.as
new file mode 100644
index 0000000..06bcd82
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IExplicitFormatResolver.as
@@ -0,0 +1,45 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	/** Interface to a format resolver. Different from IFormatResolver, IExplicitFormatResolver allow you to
+	 *  set "before style" and "after style". "After Style" can override the local computedFormat explicitly, 
+	 *  which can be fetched by calling function resolveExplicitFormat(), "Before Style" is the format returned
+	 *  by function resolveFormat() defined in interface IFormatResolver.
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 * 
+	 * @see org.apache.flex.textLayout.elements.TextFlow#formatResolver TextFlow.formatResolver
+	 */
+	public interface IExplicitFormatResolver extends IFormatResolver
+	{
+		/** Given a FlowElement or ContainerController object, return any explicit format settings for it.
+		 *
+		 * @return format settings for the specified object.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		function resolveExplicitFormat(target:Object):ITextLayoutFormat;
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IFlowElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IFlowElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IFlowElement.as
new file mode 100644
index 0000000..6a5e88f
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IFlowElement.as
@@ -0,0 +1,109 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	import org.apache.flex.events.IEventDispatcher;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+
+	public interface IFlowElement extends ITextLayoutFormat
+	{
+		function getText(relativeStart:int = 0, relativeEnd:int = -1, paragraphSeparator:String = "\n"):String;
+
+		function getAncestorWithContainer():IContainerFormattedElement;
+		function getPrivateStyle(styleName:String):*;
+		function formatChanged(notifyModelChanged:Boolean = true):void;
+		function setStyle(styleProp:String, newValue:*):void;
+		function getEffectivePaddingLeft():Number;
+		function getEffectivePaddingRight():Number;
+		function getEffectivePaddingTop():Number;
+		function getEffectivePaddingBottom():Number;
+		function getEffectiveBorderLeftWidth():Number;
+		function getEffectiveBorderRightWidth():Number;
+		function getEffectiveBorderTopWidth():Number;
+		function getEffectiveBorderBottomWidth():Number;
+		function getEffectiveMarginLeft():Number;
+		function getEffectiveMarginRight():Number;
+		function getEffectiveMarginTop():Number;
+		function getEffectiveMarginBottom():Number;
+		function getAbsoluteStart():int;
+		function getElementRelativeStart(ancestorElement:IFlowElement):int;
+		function getTextFlow():ITextFlow;
+		function getParagraph():IParagraphElement;
+		function getParentCellElement():ITableCellElement;
+		function getParentByType(elementType:String):IFlowElement;
+		function getPreviousSibling():IFlowElement;
+		function getNextSibling():IFlowElement;
+		function getCharAtPosition(relativePosition:int):String;
+		function getCharCodeAtPosition(relativePosition:int):int;
+		function get className():String;
+		function get userStyles():Object;
+		function get coreStyles():Object;
+		function get styles():Object;
+		function get bindableElement():Boolean;
+		function get parent():IFlowGroupElement;
+		function get textLength():int;
+		function get parentRelativeStart():int;
+		function get parentRelativeEnd():int;
+		function get id():String;
+		function get typeName():String;
+		function get defaultTypeName():String;
+		function get impliedElement():Boolean;
+		function get formatForCascade():ITextLayoutFormat;
+		function get computedFormat():ITextLayoutFormat;
+		function set userStyles(styles:Object):void;
+		function set bindableElement(value:Boolean):void;
+		function getUserStyleWorker(styleProp:String):*;
+		function set id(val:String):void;
+		function modelChanged(changeType:String, element:IFlowElement, changeStart:int, changeLen:int, needNormalize:Boolean = true, bumpGeneration:Boolean = true):void;
+		function set typeName(val:String):void;
+		function set impliedElement(value:Boolean):void;
+		function set tracking(trackingValue:Object):void;
+		function splitAtPosition(i:int):IFlowElement;
+
+		// TODO add this back in after the compiler is fixed
+		// function set styleName(styleNameValue:*):void;
+		function set format(format:ITextLayoutFormat):void;
+		function get format():ITextLayoutFormat;
+		function hasActiveEventMirror():Boolean;
+		function deepCopy(relativeStart:int = 0, relativeEnd:int = -1):IFlowElement;
+		function shallowCopy(relativeStart:int = 0, relativeEnd:int = -1):IFlowElement;
+		function normalizeRange(normalizeStart:uint, normalizeEnd:uint):void;
+		function quickCloneTextLayoutFormat(sibling:IFlowElement):void;
+		function applyFunctionToElements(func:Function):Boolean;
+		function removed():void;
+		function setParentAndRelativeStart(newParent:IFlowGroupElement, newStart:int):void;
+		function setParentAndRelativeStartOnly(newParent:IFlowGroupElement, newStart:int):void;
+		function setParentRelativeStart(newStart:int):void;
+		function applyWhiteSpaceCollapse(collapse:String):void;
+		function appendElementsForDelayedUpdate(tf:ITextFlow, changeType:String):void;
+		function updateRange(len:int):void;
+		function releaseContentElement():void;
+		function createContentElement():void;
+		function updateLengths(startIdx:int, len:int, updateLines:Boolean):void;
+		function setStylesInternal(styles:Object):void;
+		CONFIG::debug function get name():String;
+		CONFIG::debug function debugCheckFlowElement(depth:int = 0, extraData:String = ""):int;
+		function mergeToPreviousIfPossible():Boolean;
+		function set backgroundAlpha(backgroundAlphaValue:*):void;
+		function set backgroundColor(backgroundColorValue:*):void;
+		function getEventMirror():IEventDispatcher;
+		function set listMarkerFormat(listMarkerFormat:*):void;
+		function calculateComputedFormat():ITextLayoutFormat;
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IFlowGroupElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IFlowGroupElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IFlowGroupElement.as
new file mode 100644
index 0000000..3933f38
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IFlowGroupElement.as
@@ -0,0 +1,52 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements {
+	import org.apache.flex.text.engine.GroupElement;
+	import org.apache.flex.text.engine.ContentElement;
+	public interface IFlowGroupElement extends IFlowElement {
+		function findLeaf(childRelativePos : int) : IFlowLeafElement;
+		function getFirstLeaf() : IFlowLeafElement;
+		function getLastLeaf() : IFlowLeafElement;
+		function findChildIndexAtPosition(begStart : int) : int;
+		function getChildAt(begChildIdx : int) : IFlowElement;
+		function getChildIndex(child:IFlowElement):int
+
+		function get numChildren() : int;
+
+		function addChildAt(index:uint, elem:IFlowElement):IFlowElement;
+		function splitAtIndex(childIdx : int) : IFlowGroupElement;
+		function replaceChildren(beginChildIndex:int, endChildIndex:int, ...rest):void;
+		function get mxmlChildren():Array;
+
+		function set mxmlChildren(array : Array) : void;
+
+		function addChild(child : IFlowElement) : IFlowElement;
+		function removeChild(child:IFlowElement):IFlowElement;
+		function removeChildAt(index:uint):IFlowElement;
+		function hasBlockElement():Boolean;
+		function insertBlockElement(child:IFlowElement, block:ContentElement):void;
+		function removeBlockElement(child:IFlowElement, block:ContentElement):void;
+		function canOwnFlowElement(elem:IFlowElement):Boolean;
+		function getNextLeafHelper(limitElement:IFlowGroupElement,child:IFlowElement):IFlowLeafElement;
+		function getPreviousLeafHelper(limitElement:IFlowGroupElement,child:IFlowElement):IFlowLeafElement;
+		function createContentAsGroup(pos:int=0):GroupElement;
+		function addChildAfterInternal(child:IFlowElement, newChild:IFlowElement):void;
+		
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IFlowLeafElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IFlowLeafElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IFlowLeafElement.as
new file mode 100644
index 0000000..5bf4164
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IFlowLeafElement.as
@@ -0,0 +1,37 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements {
+	import org.apache.flex.text.engine.TextElement;
+	import org.apache.flex.text.engine.FontMetrics;
+	import org.apache.flex.geom.Rectangle;
+	import org.apache.flex.text.engine.ITextLine;
+	import org.apache.flex.textLayout.compose.ISWFContext;
+
+	public interface IFlowLeafElement extends IFlowElement {
+		function getNextLeaf(elem : IFlowGroupElement = null) : IFlowLeafElement;
+
+		function getCSSInlineBox(bp : String, textLine : ITextLine, para : IParagraphElement = null, swfContext : ISWFContext = null) : Rectangle;
+		function getEffectiveLineHeight(bp : String) : Number;
+		function getComputedFontMetrics() : FontMetrics;
+		function getPreviousLeaf(elem : IFlowGroupElement = null) : IFlowLeafElement;
+		function getEffectiveFontSize() : Number;
+		function get text():String;
+		function quickInitializeForSplit(sibling:FlowLeafElement,newSpanLength:int,newSpanTextElement:TextElement):void;
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IFormatResolver.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IFormatResolver.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IFormatResolver.as
new file mode 100644
index 0000000..a170d24
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IFormatResolver.as
@@ -0,0 +1,86 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	/** Interface to a format resolver. An implementation allows you to attach a styling mechanism of your choosing, such as
+	 *  Flex CSS styling and named styles, to a ITextFlow.
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 * 
+	 * @see org.apache.flex.textLayout.elements.ITextFlow#formatResolver ITextFlow.formatResolver
+	 */
+	 
+	public interface IFormatResolver 
+	{
+		/** Invalidates any cached formatting information for a ITextFlow so that formatting must be recomputed.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		function invalidateAll(textFlow:ITextFlow):void;
+		
+		/** Invalidates cached formatting information on this element because, for example, the <code>parent</code> changed, 
+		 *  or the <code>id</code> or the <code>styleName</code> changed or the <code>typeName</code> changed. 
+		 *
+		 * @playerversion Flash 10
+	 	 * @playerversion AIR 1.5
+	  	 * @langversion 3.0*/
+	  	 
+		function invalidate(target:Object):void;
+		
+		/** Given a FlowElement or ContainerController object, return any format settings for it.
+		 *
+		 * @return format settings for the specified object.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+	 	 */
+	 	 
+		function resolveFormat(target:Object):ITextLayoutFormat;
+		
+		/** Given a FlowElement or ContainerController object and the name of a format property, return the format value
+		 * or <code>undefined</code> if the value is not found.
+		 *
+		 * @return the value of the specified format for the specified object.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		 
+		function resolveUserFormat(target:Object,userFormat:String):*;
+		
+		/** Returns the format resolver when a ITextFlow is copied.
+		 *
+		 * @return the format resolver for the copy of the ITextFlow.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		 
+		function getResolverForNewFlow(oldFlow:ITextFlow,newFlow:ITextFlow):IFormatResolver;
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IInlineGraphicElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IInlineGraphicElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IInlineGraphicElement.as
new file mode 100644
index 0000000..4ca8507
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IInlineGraphicElement.as
@@ -0,0 +1,44 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	import org.apache.flex.text.engine.ITextLine;
+	import org.apache.flex.core.IUIBase;
+	import org.apache.flex.core.IParentIUIBase;
+	public interface IInlineGraphicElement extends IFlowLeafElement
+	{
+		function get effectiveFloat():*;
+		function setEffectiveFloat(floatValue:String):void;
+		function get computedFloat():*;
+		function elementHeightWithMarginsAndPadding():Number;
+		function elementWidthWithMarginsAndPadding():Number;
+		function get elementWidth():Number;
+		function get elementHeight():Number;
+		function get placeholderGraphic():IParentIUIBase;
+		function get graphic():IUIBase;
+		function getTypographicAscent(textLine:ITextLine):Number;
+		function get height():*;
+		function get width():*;
+		function get status():String;
+		function set height(height:*):void;
+		function set width(width:*):void;
+		function set float(value:*):void;
+		function set source(source:Object):void;
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ILinkElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ILinkElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ILinkElement.as
new file mode 100644
index 0000000..ad19c1a
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ILinkElement.as
@@ -0,0 +1,69 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	import org.apache.flex.textLayout.events.FlowElementMouseEventManager;
+	import org.apache.flex.events.MouseEvent;
+	public interface ILinkElement extends ISubParagraphGroupElementBase
+	{
+		function chgLinkState(linkState:String):void;
+
+		function get linkState():String;
+
+		function mouseDownHandler(mgr:FlowElementMouseEventManager, evt:MouseEvent):void;
+		
+		/** @private
+		 * The ElementMouseEventManager calls this method directly. Note that the mouse
+		 * coordinates are unrelated to any coordinate in the container or this element.
+		 */
+		function mouseMoveHandler(mgr:FlowElementMouseEventManager, evt:MouseEvent):void;
+		
+		/** @private
+		 * The ElementMouseEventManager calls this method directly. Note that the mouse
+		 * coordinates are unrelated to any coordinate in the container or this element.
+		 */
+		function mouseOutHandler(mgr:FlowElementMouseEventManager, evt:MouseEvent):void;
+		
+		/** @private
+		 * The ElementMouseEventManager calls this method directly. Note that the mouse
+		 * coordinates are unrelated to any coordinate in the container or this element.
+		 */
+		function mouseOverHandler(mgr:FlowElementMouseEventManager, evt:MouseEvent):void;
+		
+		/** @private
+		 * The ElementMouseEventManager calls this method directly. Note that the mouse
+		 * coordinates are unrelated to any coordinate in the container or this element.
+		 */
+		function mouseUpHandler(mgr:FlowElementMouseEventManager, evt:MouseEvent):void;
+		
+		/** @private
+		 * The ElementMouseEventManager calls this method directly. Note that the mouse
+		 * coordinates are unrelated to any coordinate in the container or this element.
+		 */
+		function mouseClickHandler(mgr:FlowElementMouseEventManager, evt:MouseEvent):void;
+
+		function set href(href:String):void;
+
+		function set target(target:String):void;
+
+		function get href():String;
+
+		function get target():String;
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IListElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IListElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IListElement.as
new file mode 100644
index 0000000..2aa1882
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IListElement.as
@@ -0,0 +1,28 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	import org.apache.flex.textLayout.formats.IListMarkerFormat;
+	public interface IListElement extends IContainerFormattedElement
+	{
+		function computeListItemText(child:IListItemElement, listMarkerFormat:IListMarkerFormat):String;
+		function isNumberedList():Boolean;
+		function set listStyleType(listStyleTypeValue:*):void;
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IListItemElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IListItemElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IListItemElement.as
new file mode 100644
index 0000000..d4c823d
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IListItemElement.as
@@ -0,0 +1,28 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	import org.apache.flex.textLayout.formats.IListMarkerFormat;
+	public interface IListItemElement extends IContainerFormattedElement
+	{
+		function normalizeNeedsInitialParagraph():Boolean;
+		function computedListMarkerFormat():IListMarkerFormat;
+		function getListItemNumber(listMarkerFormat:IListMarkerFormat = null):int
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IParagraphElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IParagraphElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IParagraphElement.as
new file mode 100644
index 0000000..98a9e1b
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IParagraphElement.as
@@ -0,0 +1,51 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	import org.apache.flex.text.engine.ITextBlock;
+
+	public interface IParagraphElement extends IFlowGroupElement
+	{
+		function getTextBlock():ITextBlock;
+		function getNextParagraph():IParagraphElement;
+		function getEffectiveDominantBaseline():String;
+		function decInteractiveChildrenCount():void;
+		function incInteractiveChildrenCount():void;
+		function getEffectiveLeadingModel():String;
+		function getTextBlockAbsoluteStart(textBlock:ITextBlock):int;
+		function getTextBlocks():Vector.<ITextBlock>;
+		function getTextBlockAtPosition(i:int):ITextBlock;
+		function getEffectiveJustificationRule():String;
+		function isInTable():Boolean;
+		function releaseTextBlock(tb:ITextBlock = null):void;
+		function findNextWordBoundary(curPos:int):int;
+		function findPreviousWordBoundary(curPos:int):int;
+		function ensureTerminatorAfterReplace():void;
+		function createTextBlock():void;
+		function updateTerminatorSpan(spanElement:ISpanElement, newSpan:ISpanElement):void;
+
+		function get terminatorSpan():ISpanElement;
+
+		function releaseLineCreationData():void;
+
+		function hasInteractiveChildren():Boolean;
+
+		function removeEmptyTerminator():void;
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IParagraphFormattedElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IParagraphFormattedElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IParagraphFormattedElement.as
new file mode 100644
index 0000000..60de15e
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/IParagraphFormattedElement.as
@@ -0,0 +1,22 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements {
+	public interface IParagraphFormattedElement extends IFlowGroupElement{
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ISpanElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ISpanElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ISpanElement.as
new file mode 100644
index 0000000..bea33a3
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ISpanElement.as
@@ -0,0 +1,29 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements {
+	public interface ISpanElement extends IFlowLeafElement {
+		function removeParaTerminator() : void;
+
+		function set text(textValue : String) : void;
+		function get hasParagraphTerminator():Boolean;
+		function addParaTerminator():void;
+		function replaceText(relativeStartPosition:int, relativeEndPosition:int, textValue:String):void;
+		
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ISpecialCharacterElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ISpecialCharacterElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ISpecialCharacterElement.as
new file mode 100644
index 0000000..12d253b
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ISpecialCharacterElement.as
@@ -0,0 +1,24 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	public interface ISpecialCharacterElement extends ISpanElement
+	{
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ISubParagraphGroupElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ISubParagraphGroupElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ISubParagraphGroupElement.as
new file mode 100644
index 0000000..169bd26
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ISubParagraphGroupElement.as
@@ -0,0 +1,24 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	public interface ISubParagraphGroupElement extends ISubParagraphGroupElementBase
+	{
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ISubParagraphGroupElementBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ISubParagraphGroupElementBase.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ISubParagraphGroupElementBase.as
new file mode 100644
index 0000000..5b8be75
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ISubParagraphGroupElementBase.as
@@ -0,0 +1,29 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	public interface ISubParagraphGroupElementBase extends IFlowGroupElement
+	{
+		function get precedence():uint;
+
+		function acceptTextAfter():Boolean;
+
+		function acceptTextBefore():Boolean;
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ITCYElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ITCYElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ITCYElement.as
new file mode 100644
index 0000000..2d6fae5
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ITCYElement.as
@@ -0,0 +1,27 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	import org.apache.flex.geom.Rectangle;
+	import org.apache.flex.text.engine.ITextLine;
+
+	public interface ITCYElement extends ISubParagraphGroupElementBase
+	{
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ITableCellElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ITableCellElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ITableCellElement.as
new file mode 100644
index 0000000..fff33f5
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ITableCellElement.as
@@ -0,0 +1,43 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements {
+	public interface ITableCellElement extends ITableFormattedElement
+	{
+		function get rowIndex():int;
+		function getRow():ITableRowElement;
+		function get x():Number;
+		function get y():Number;
+		function get width():Number;
+		function get container():CellContainer;
+		function get colIndex():int;
+		function getPreviousCell():ITableCellElement;
+		function getNextCell():ITableCellElement;
+		function get textFlow():ITextFlow;
+		function set y(y:Number):void;
+		function set x(x:Number):void;
+		function get columnSpan():uint;
+		function damage():void;
+		function get rowSpan():uint;
+		function compose():Boolean;
+		function getComposedHeight():Number;
+		function set rowIndex(rowIndex:int):void;
+		function set colIndex(colIndex:int):void;
+		function updateCompositionShapes():void;
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ITableColElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ITableColElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ITableColElement.as
new file mode 100644
index 0000000..08b2871
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ITableColElement.as
@@ -0,0 +1,29 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	public interface ITableColElement extends ITableFormattedElement
+	{
+		function get x():Number;
+//		function set tableColumnWidth(tableColumnWidth:*):void;
+		function get colIndex():int;
+
+		function get cells():Vector.<ITableCellElement>;
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ITableColSetter.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ITableColSetter.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ITableColSetter.as
new file mode 100644
index 0000000..693c749
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ITableColSetter.as
@@ -0,0 +1,25 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	public interface ITableColSetter
+	{
+		function set tableColumnWidth(tableColumnWidth:*):void;
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ITableElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ITableElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ITableElement.as
new file mode 100644
index 0000000..2efdc9c
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ITableElement.as
@@ -0,0 +1,52 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	import org.apache.flex.textLayout.compose.ITextFlowTableBlock;
+	import org.apache.flex.textLayout.compose.TextFlowTableBlock;
+	public interface ITableElement extends ITableFormattedElement
+	{
+		function getRowAt(rIdx:int):ITableRowElement;
+		function addCellToBlock(cell:ITableCellElement, curTableBlock:ITextFlowTableBlock):void;
+		function composeCells():void;
+		function getColumnAt(colIndex:int):ITableColElement;
+		function getNextRow():Vector.<ITableCellElement>;
+		function getFirstBlock():ITextFlowTableBlock;
+		function normalizeColumnWidths(width:Number = 600):void;
+		function getCellsForColumn(column:ITableColElement):Vector.<ITableCellElement>;
+		function getNextCell(tableCellElement:ITableCellElement):ITableCellElement;
+		function getPreviousCell(tableCellElement:ITableCellElement):ITableCellElement;
+		function get hasCellDamage():Boolean;
+		function set hasCellDamage(hasCellDamage:Boolean):void;
+		function getTableBlocksInRange(anchorCoords:CellCoordinates, activeCoords:CellCoordinates):Vector.<ITextFlowTableBlock>;
+		function get numRows():int;
+		function get numColumns():int;
+		function get width():Number;
+		function getCellsInRange(anchorCoords:CellCoordinates, activeCoords:CellCoordinates, block:ITextFlowTableBlock = null):Vector.<ITableCellElement>;
+		function findCell(coords:CellCoordinates):ITableCellElement;
+		function getCellAt(rowIndex:int, colIndex:int):ITableCellElement;
+		function getCellsForRowArray(row:ITableRowElement):Array;
+		function getCellsForRowAtArray(index:int):Array;
+		function getCellsForRowAt(index:int):Vector.<ITableCellElement>;
+		function getCellsForRow(row:ITableRowElement):Vector.<ITableCellElement>;
+		function set numColumns(numColumns:int):void;
+		function insertRow(row:ITableRowElement=null,cells:Array = null):Boolean;
+		
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ITableFormattedElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ITableFormattedElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ITableFormattedElement.as
new file mode 100644
index 0000000..0366aa4
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ITableFormattedElement.as
@@ -0,0 +1,25 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements {
+	public interface ITableFormattedElement extends IContainerFormattedElement {
+		function get table():ITableElement;
+		function set table(value:ITableElement):void;
+
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ITableLeafElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ITableLeafElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ITableLeafElement.as
new file mode 100644
index 0000000..4307f16
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ITableLeafElement.as
@@ -0,0 +1,24 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	public interface ITableLeafElement extends IFlowLeafElement
+	{
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ITableRowElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ITableRowElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ITableRowElement.as
new file mode 100644
index 0000000..c9d606d
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ITableRowElement.as
@@ -0,0 +1,43 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	public interface ITableRowElement extends ITableFormattedElement
+	{
+		function get composedHeight():Number;
+
+		function get rowIndex():int;
+
+		function set rowIndex(rowIndex:int):void;
+
+		function set totalHeight(totalHeight:Number):void;
+
+		function get totalHeight():Number;
+
+		function set composedHeight(composedHeight:Number):void;
+
+		function set isMaxHeight(isMaxHeight:Boolean):void;
+
+		function get isMaxHeight():Boolean;
+
+		function get cells():Array;
+
+		function get numCells():int;
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ITextFlow.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ITextFlow.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ITextFlow.as
new file mode 100644
index 0000000..f14bc5e
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ITextFlow.as
@@ -0,0 +1,74 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.compose.IFlowComposer;
+	import org.apache.flex.textLayout.edit.ISelectionManager;
+	import org.apache.flex.textLayout.factory.ITLFFactory;
+	import org.apache.flex.events.Event;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+	public interface ITextFlow extends IContainerFormattedElement
+	{
+		function damage(damageStart:int, damageLen:int, damageType:String, needNormalize:Boolean = true):void;
+		function processModelChanged(changeType:String, elem:Object, changeStart:int, changeLen:int, needNormalize:Boolean, bumpGeneration:Boolean):void;
+		function get formatResolver(): IFormatResolver;
+		function getTextLayoutFormatStyle(elem:Object):TextLayoutFormat;
+		function getExplicitStyle(elem:Object):TextLayoutFormat;
+		function get parentElement():IFlowGroupElement;
+		function set parentElement(value:IFlowGroupElement):void;
+		function get interactiveObjectCount():int;
+		function incInteractiveObjectCount():void;
+		function decInteractiveObjectCount():void;
+		function get graphicObjectCount():int;
+		function incGraphicObjectCount():void;
+		function decGraphicObjectCount():void;
+		function hasEventListener(type:String):Boolean;
+		function dispatchEvent(event:Event):Boolean;
+		function getBackgroundManager():IBackgroundManager;
+		function get tlfFactory() : ITLFFactory;
+		function get backgroundManager():IBackgroundManager;
+		function get interactionManager():ISelectionManager;
+		function set interactionManager(newInteractionManager:ISelectionManager):void;
+		function get configuration():IConfiguration;
+		function getElementsByTypeName(typeNameValue:String):Array;
+		function appendOneElementForUpdate(elem:IFlowElement):void;
+		function processAutoSizeImageLoaded(elem:InlineGraphicElement):void;
+		function findAbsoluteParagraph(pos:int):IParagraphElement;
+		function nestedInTable():Boolean;
+		function get generation():uint;
+		function setGeneration(num:uint):void;
+		function normalize():void;
+		function findAbsoluteFlowGroupElement(pos:int):IFlowGroupElement;
+		function set flowComposer(composer:IFlowComposer):void;
+		function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void;
+		function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void;
+		function invalidateAllFormats():void;
+		function clearBackgroundManager():void;
+		function mustUseComposer():Boolean;
+		function changeFlowComposer(newComposer:IFlowComposer,okToUnloadGraphics:Boolean):void;
+		function set hostFormat(value:ITextLayoutFormat):void;
+		function get hostFormat():ITextLayoutFormat;
+		function applyUpdateElements(okToUnloadGraphics:Boolean):Boolean;
+		function unloadGraphics():void;
+
+		CONFIG::debug function debugCheckTextFlow(validateControllers:Boolean = true):int;
+
+	}
+}
\ No newline at end of file


[42/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
And here\u2019s TLF\u2026


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/fd08d137
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/fd08d137
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/fd08d137

Branch: refs/heads/tlf
Commit: fd08d137f21e3684dc1824ff8c36abbd109670b1
Parents: a77bfe4
Author: Harbs <ha...@in-tools.com>
Authored: Thu Mar 16 15:37:11 2017 +0200
Committer: Harbs <ha...@in-tools.com>
Committed: Thu Mar 16 15:37:11 2017 +0200

----------------------------------------------------------------------
 frameworks/js/FlexJS/projects/TLFJS/build.xml   |  176 +
 .../TLFJS/src/main/config/compile-js-config.xml |   98 +
 frameworks/js/FlexJS/projects/TextJS/build.xml  |    8 +-
 .../projects/Core/src/main/flex/CoreClasses.as  |    2 +-
 frameworks/projects/TLF/.vscode/tasks.json      |   11 +
 frameworks/projects/TLF/asconfig.json           |   33 +
 frameworks/projects/TLF/build.xml               |  172 +
 frameworks/projects/TLF/build_old.xml           |  186 +
 frameworks/projects/TLF/compile-config.xml      |   77 +
 .../TLF/src/main/config/compile-as-config.xml   |   90 +
 .../projects/TLF/src/main/flex/TLFClasses.as    |  170 +
 .../apache/flex/textLayout/ConversionClasses.as |   34 +
 .../org/apache/flex/textLayout/CoreClasses.as   |  174 +
 .../org/apache/flex/textLayout/EditClasses.as   |   69 +
 .../apache/flex/textLayout/TextLayoutVersion.as |  135 +
 .../textLayout/accessibility/TextAccImpl.as     |  426 ++
 .../flex/textLayout/compose/BaseCompose.as      | 2922 ++++++++++
 .../flex/textLayout/compose/ComposeState.as     |  466 ++
 .../flex/textLayout/compose/FactoryComposer.as  |   84 +
 .../textLayout/compose/FloatCompositionData.as  |   58 +
 .../flex/textLayout/compose/FlowComposerBase.as |  685 +++
 .../flex/textLayout/compose/FlowDamageType.as   |   60 +
 .../flex/textLayout/compose/IComposeState.as    |   26 +
 .../apache/flex/textLayout/compose/IComposer.as |   42 +
 .../flex/textLayout/compose/IFactoryComposer.as |   28 +
 .../flex/textLayout/compose/IFlowComposer.as    |  521 ++
 .../flex/textLayout/compose/ISWFContext.as      |   76 +
 .../flex/textLayout/compose/ISimpleCompose.as   |   36 +
 .../flex/textLayout/compose/ITextFlowLine.as    |  104 +
 .../textLayout/compose/ITextFlowTableBlock.as   |   46 +
 .../compose/IVerticalJustificationLine.as       |   95 +
 .../apache/flex/textLayout/compose/Parcel.as    |  376 ++
 .../flex/textLayout/compose/ParcelList.as       |  438 ++
 .../flex/textLayout/compose/SWFContext.as       |   85 +
 .../flex/textLayout/compose/SimpleCompose.as    |  442 ++
 .../org/apache/flex/textLayout/compose/Slug.as  |   32 +
 .../textLayout/compose/StandardFlowComposer.as  |  879 +++
 .../textLayout/compose/TCMFactoryComposer.as    |   47 +
 .../flex/textLayout/compose/TextFlowLine.as     | 2552 +++++++++
 .../textLayout/compose/TextFlowLineLocation.as  |   71 +
 .../textLayout/compose/TextFlowTableBlock.as    |  266 +
 .../flex/textLayout/compose/TextLineRecycler.as |  129 +
 .../textLayout/compose/VerticalJustifier.as     |  351 ++
 .../textLayout/compose/utils/AdornmentUtils.as  |  685 +++
 .../textLayout/compose/utils/ContextUtil.as     |   31 +
 .../textLayout/compose/utils/FactoryHelper.as   |   36 +
 .../compose/utils/NumberLineUserData.as         |   42 +
 .../textLayout/compose/utils/NumberlineUtil.as  |  160 +
 .../textLayout/compose/utils/StandardHelper.as  |   35 +
 .../textLayout/compose/utils/TextLineUtil.as    |  172 +
 .../flex/textLayout/container/ColumnState.as    |  427 ++
 .../textLayout/container/ContainerController.as | 5222 ++++++++++++++++++
 .../flex/textLayout/container/ContainerUtil.as  |   30 +
 .../container/IContainerController.as           |  122 +
 .../textLayout/container/ISandboxSupport.as     |   72 +
 .../container/ITextContainerManager.as          |   25 +
 .../flex/textLayout/container/ScrollPolicy.as   |   84 +
 .../container/TMContainerController.as          |  147 +
 .../container/TextContainerManager.as           | 2578 +++++++++
 .../conversion/BaseTextLayoutExporter.as        |  536 ++
 .../conversion/BaseTextLayoutImporter.as        |  717 +++
 .../conversion/ConversionConstants.as           |   45 +
 .../textLayout/conversion/ConversionType.as     |   51 +
 .../flex/textLayout/conversion/ConverterBase.as |  108 +
 .../conversion/CustomFormatImporter.as          |   45 +
 .../textLayout/conversion/FlowElementInfo.as    |   66 +
 .../textLayout/conversion/FormatDescriptor.as   |   90 +
 .../textLayout/conversion/IFormatImporter.as    |   29 +
 .../flex/textLayout/conversion/IHTMLImporter.as |   73 +
 .../textLayout/conversion/IPlainTextExporter.as |   57 +
 .../flex/textLayout/conversion/ITextExporter.as |  102 +
 .../flex/textLayout/conversion/ITextImporter.as |  108 +
 .../conversion/ITextLayoutImporter.as           |   48 +
 .../conversion/ImportExportConfiguration.as     |  125 +
 .../textLayout/conversion/PlainTextExporter.as  |  142 +
 .../textLayout/conversion/PlainTextImporter.as  |  116 +
 .../conversion/SingletonAttributeImporter.as    |   46 +
 .../textLayout/conversion/TLFormatImporter.as   |   65 +
 .../flex/textLayout/conversion/TextConverter.as |  649 +++
 .../conversion/TextFieldHtmlExporter.as         |  580 ++
 .../conversion/TextFieldHtmlImporter.as         | 1231 +++++
 .../textLayout/conversion/TextLayoutExporter.as |  297 +
 .../textLayout/conversion/TextLayoutImporter.as |  674 +++
 .../CaseInsensitiveTLFFormatImporter.as         |   54 +
 .../conversion/importers/FontImporter.as        |   38 +
 .../importers/HtmlCustomParaFormatImporter.as   |   35 +
 .../conversion/importers/TextFormatImporter.as  |   46 +
 .../apache/flex/textLayout/dummy/BitmapData.as  |   31 +
 .../apache/flex/textLayout/dummy/BoundsUtil.as  |   29 +
 .../apache/flex/textLayout/dummy/Clipboard.as   |   36 +
 .../flex/textLayout/dummy/ColorTransform.as     |   22 +
 .../apache/flex/textLayout/dummy/ContextMenu.as |   28 +
 .../textLayout/dummy/ContextMenuBuiltInItems.as |   31 +
 .../dummy/ContextMenuClipboardItems.as          |   28 +
 .../flex/textLayout/dummy/IBitmapDrawable.as    |   22 +
 .../org/apache/flex/textLayout/dummy/Mouse.as   |   29 +
 .../apache/flex/textLayout/dummy/MouseCursor.as |   28 +
 .../flex/textLayout/dummy/MouseCursorData.as    |   26 +
 .../flex/textLayout/edit/ClipboardFormats.as    |   23 +
 .../apache/flex/textLayout/edit/EditManager.as  | 2050 +++++++
 .../apache/flex/textLayout/edit/EditingMode.as  |   60 +
 .../apache/flex/textLayout/edit/ElementMark.as  |   86 +
 .../apache/flex/textLayout/edit/ElementRange.as |  426 ++
 .../apache/flex/textLayout/edit/IEditManager.as |  778 +++
 .../textLayout/edit/IInteractionEventHandler.as |  220 +
 .../apache/flex/textLayout/edit/IMEClient.as    |  434 ++
 .../org/apache/flex/textLayout/edit/IMemento.as |   34 +
 .../flex/textLayout/edit/ISelectionManager.as   |  515 ++
 .../org/apache/flex/textLayout/edit/Mark.as     |   38 +
 .../apache/flex/textLayout/edit/MementoList.as  |   78 +
 .../apache/flex/textLayout/edit/ModelEdit.as    |  159 +
 .../org/apache/flex/textLayout/edit/ParaEdit.as |  673 +++
 .../apache/flex/textLayout/edit/PointFormat.as  |  148 +
 .../flex/textLayout/edit/SelectionFormat.as     |  207 +
 .../textLayout/edit/SelectionFormatState.as     |   38 +
 .../flex/textLayout/edit/SelectionManager.as    | 3045 ++++++++++
 .../flex/textLayout/edit/SelectionState.as      |  147 +
 .../flex/textLayout/edit/SelectionType.as       |   27 +
 .../flex/textLayout/edit/TextClipboard.as       |  328 ++
 .../apache/flex/textLayout/edit/TextFlowEdit.as | 1223 ++++
 .../apache/flex/textLayout/edit/TextScrap.as    |  187 +
 .../edit/mementos/AddElementMemento.as          |   71 +
 .../textLayout/edit/mementos/BaseMemento.as     |   50 +
 .../edit/mementos/DeleteTextMemento.as          |  126 +
 .../edit/mementos/InternalSplitFGEMemento.as    |  131 +
 .../textLayout/edit/mementos/JoinMemento.as     |   91 +
 .../edit/mementos/MoveElementMemento.as         |   77 +
 .../edit/mementos/RemoveElementsMemento.as      |   75 +
 .../textLayout/edit/mementos/SplitMemento.as    |  126 +
 .../edit/mementos/TextRangeMemento.as           |   30 +
 .../textLayout/elements/BackgroundManager.as    |  378 ++
 .../flex/textLayout/elements/BreakElement.as    |   66 +
 .../flex/textLayout/elements/CellContainer.as   |   57 +
 .../flex/textLayout/elements/CellCoordinates.as |   89 +
 .../flex/textLayout/elements/CellRange.as       |  150 +
 .../flex/textLayout/elements/ConfigSettings.as  |   25 +
 .../flex/textLayout/elements/Configuration.as   |  623 +++
 .../textLayout/elements/ConfigurationHelper.as  |   31 +
 .../elements/ContainerFormattedElement.as       |   90 +
 .../flex/textLayout/elements/DivElement.as      |   49 +
 .../textLayout/elements/ElementConstants.as     |   27 +
 .../flex/textLayout/elements/ElementHelper.as   |  136 +
 .../flex/textLayout/elements/FlowElement.as     | 1454 +++++
 .../textLayout/elements/FlowGroupElement.as     | 1111 ++++
 .../flex/textLayout/elements/FlowGroupHelper.as |  103 +
 .../flex/textLayout/elements/FlowLeafElement.as |  441 ++
 .../flex/textLayout/elements/FlowValueHolder.as |   71 +
 .../flex/textLayout/elements/GlobalSettings.as  |  245 +
 .../textLayout/elements/IBackgroundManager.as   |   54 +
 .../flex/textLayout/elements/IBreakElement.as   |   24 +
 .../flex/textLayout/elements/IConfiguration.as  |  364 ++
 .../elements/IContainerFormattedElement.as      |   31 +
 .../flex/textLayout/elements/IDivElement.as     |   24 +
 .../elements/IExplicitFormatResolver.as         |   45 +
 .../flex/textLayout/elements/IFlowElement.as    |  109 +
 .../textLayout/elements/IFlowGroupElement.as    |   52 +
 .../textLayout/elements/IFlowLeafElement.as     |   37 +
 .../flex/textLayout/elements/IFormatResolver.as |   86 +
 .../elements/IInlineGraphicElement.as           |   44 +
 .../flex/textLayout/elements/ILinkElement.as    |   69 +
 .../flex/textLayout/elements/IListElement.as    |   28 +
 .../textLayout/elements/IListItemElement.as     |   28 +
 .../textLayout/elements/IParagraphElement.as    |   51 +
 .../elements/IParagraphFormattedElement.as      |   22 +
 .../flex/textLayout/elements/ISpanElement.as    |   29 +
 .../elements/ISpecialCharacterElement.as        |   24 +
 .../elements/ISubParagraphGroupElement.as       |   24 +
 .../elements/ISubParagraphGroupElementBase.as   |   29 +
 .../flex/textLayout/elements/ITCYElement.as     |   27 +
 .../textLayout/elements/ITableCellElement.as    |   43 +
 .../textLayout/elements/ITableColElement.as     |   29 +
 .../flex/textLayout/elements/ITableColSetter.as |   25 +
 .../flex/textLayout/elements/ITableElement.as   |   52 +
 .../elements/ITableFormattedElement.as          |   25 +
 .../textLayout/elements/ITableLeafElement.as    |   24 +
 .../textLayout/elements/ITableRowElement.as     |   43 +
 .../flex/textLayout/elements/ITextFlow.as       |   74 +
 .../textLayout/elements/InlineGraphicElement.as | 1165 ++++
 .../elements/InlineGraphicElementStatus.as      |   78 +
 .../flex/textLayout/elements/LeadingUtils.as    |   72 +
 .../flex/textLayout/elements/LinkElement.as     |  611 ++
 .../flex/textLayout/elements/LinkState.as       |   69 +
 .../flex/textLayout/elements/ListElement.as     |  645 +++
 .../flex/textLayout/elements/ListItemElement.as |  275 +
 .../flex/textLayout/elements/OverflowPolicy.as  |   63 +
 .../textLayout/elements/ParagraphElement.as     | 1358 +++++
 .../elements/ParagraphFormattedElement.as       |   49 +
 .../flex/textLayout/elements/SpanElement.as     |  608 ++
 .../elements/SpecialCharacterElement.as         |   96 +
 .../elements/SubParagraphGroupElement.as        |   95 +
 .../elements/SubParagraphGroupElementBase.as    |  387 ++
 .../flex/textLayout/elements/TCYElement.as      |  141 +
 .../flex/textLayout/elements/TabElement.as      |   69 +
 .../textLayout/elements/TableBlockContainer.as  |   50 +
 .../textLayout/elements/TableBodyElement.as     |   63 +
 .../textLayout/elements/TableCellElement.as     |  457 ++
 .../flex/textLayout/elements/TableColElement.as |  116 +
 .../textLayout/elements/TableColGroupElement.as |   63 +
 .../textLayout/elements/TableDataCellElement.as |  126 +
 .../flex/textLayout/elements/TableElement.as    | 1582 ++++++
 .../elements/TableFormattedElement.as           |   59 +
 .../textLayout/elements/TableLeafElement.as     |  139 +
 .../flex/textLayout/elements/TableRowElement.as |  224 +
 .../apache/flex/textLayout/elements/TextFlow.as | 1247 +++++
 .../flex/textLayout/elements/TextRange.as       |  171 +
 .../elements/utils/BackgroundHelper.as          |   26 +
 .../elements/utils/GeometricElementUtils.as     |  287 +
 .../elements/utils/ParagraphHelper.as           |   30 +
 .../flex/textLayout/events/ActivateEvent.as     |   26 +
 .../events/CompositionCompleteEvent.as          |  126 +
 .../flex/textLayout/events/ContextMenuEvent.as  |   31 +
 .../flex/textLayout/events/DamageEvent.as       |   93 +
 .../apache/flex/textLayout/events/EditEvent.as  |   26 +
 .../events/FlowElementEventDispatcher.as        |   93 +
 .../textLayout/events/FlowElementMouseEvent.as  |  216 +
 .../events/FlowElementMouseEventManager.as      |  732 +++
 .../textLayout/events/FlowOperationEvent.as     |  168 +
 .../apache/flex/textLayout/events/FocusEvent.as |   28 +
 .../flex/textLayout/events/ModelChange.as       |   38 +
 .../flex/textLayout/events/ScrollEvent.as       |  124 +
 .../textLayout/events/ScrollEventDirection.as   |   59 +
 .../flex/textLayout/events/SelectionEvent.as    |  107 +
 .../flex/textLayout/events/StatusChangeEvent.as |  124 +
 .../flex/textLayout/events/TextLayoutEvent.as   |   72 +
 .../textLayout/events/UpdateCompleteEvent.as    |  106 +
 .../textLayout/factory/INumberLineFactory.as    |   39 +
 .../factory/IStringTextLineFactory.as           |   24 +
 .../flex/textLayout/factory/ITLFFactory.as      |   30 +
 .../flex/textLayout/factory/ITextLineFactory.as |   24 +
 .../textLayout/factory/NumberLineFactory.as     |  138 +
 .../textLayout/factory/StandardTLFFactory.as    |   48 +
 .../textLayout/factory/StringTextLineFactory.as |  469 ++
 .../factory/TCMTextFlowTextLineFactory.as       |   50 +
 .../flex/textLayout/factory/TLFFactory.as       |   10 +
 .../factory/TextFlowTextLineFactory.as          |  285 +
 .../textLayout/factory/TextLineFactoryBase.as   |  437 ++
 .../textLayout/factory/TruncationOptions.as     |  154 +
 .../flex/textLayout/formats/BackgroundColor.as  |   41 +
 .../flex/textLayout/formats/BaselineOffset.as   |   68 +
 .../flex/textLayout/formats/BaselineShift.as    |   53 +
 .../flex/textLayout/formats/BlockProgression.as |   58 +
 .../flex/textLayout/formats/BorderColor.as      |   41 +
 .../flex/textLayout/formats/BorderStyle.as      |   88 +
 .../flex/textLayout/formats/BreakStyle.as       |   47 +
 .../apache/flex/textLayout/formats/Category.as  |   42 +
 .../flex/textLayout/formats/ClearFloats.as      |   89 +
 .../apache/flex/textLayout/formats/ColorName.as |   58 +
 .../apache/flex/textLayout/formats/Direction.as |   51 +
 .../org/apache/flex/textLayout/formats/Float.as |   47 +
 .../flex/textLayout/formats/FormatValue.as      |   64 +
 .../textLayout/formats/IListMarkerFormat.as     |   43 +
 .../apache/flex/textLayout/formats/IMEStatus.as |  103 +
 .../flex/textLayout/formats/ITabStopFormat.as   |   87 +
 .../textLayout/formats/ITextLayoutFormat.as     | 1388 +++++
 .../textLayout/formats/JustificationRule.as     |   60 +
 .../flex/textLayout/formats/LeadingModel.as     |  152 +
 .../apache/flex/textLayout/formats/LineBreak.as |   49 +
 .../flex/textLayout/formats/ListMarkerFormat.as |  370 ++
 .../textLayout/formats/ListStylePosition.as     |   50 +
 .../flex/textLayout/formats/ListStyleType.as    |  314 ++
 .../apache/flex/textLayout/formats/Suffix.as    |   51 +
 .../textLayout/formats/TLFTypographicCase.as    |   79 +
 .../flex/textLayout/formats/TabStopFormat.as    |  397 ++
 .../flex/textLayout/formats/TableFrame.as       |  113 +
 .../flex/textLayout/formats/TableRules.as       |   77 +
 .../apache/flex/textLayout/formats/TextAlign.as |   91 +
 .../flex/textLayout/formats/TextDecoration.as   |   53 +
 .../flex/textLayout/formats/TextJustify.as      |   55 +
 .../flex/textLayout/formats/TextLayoutFormat.as | 3791 +++++++++++++
 .../textLayout/formats/TextLayoutFormatBase.as  | 2260 ++++++++
 .../flex/textLayout/formats/VerticalAlign.as    |   68 +
 .../textLayout/formats/WhiteSpaceCollapse.as    |   51 +
 .../operations/ApplyElementIDOperation.as       |  103 +
 .../ApplyElementStyleNameOperation.as           |   98 +
 .../operations/ApplyElementTypeNameOperation.as |  101 +
 .../ApplyElementUserStyleOperation.as           |  118 +
 .../operations/ApplyFormatOperation.as          |  249 +
 .../operations/ApplyFormatToElementOperation.as |  115 +
 .../textLayout/operations/ApplyLinkOperation.as |  206 +
 .../textLayout/operations/ApplyTCYOperation.as  |  190 +
 .../operations/ClearFormatOnElementOperation.as |  123 +
 .../operations/ClearFormatOperation.as          |  237 +
 .../textLayout/operations/CompositeOperation.as |  221 +
 .../flex/textLayout/operations/CopyOperation.as |   86 +
 .../textLayout/operations/CreateDivOperation.as |  263 +
 .../operations/CreateListOperation.as           |  288 +
 .../CreateSubParagraphGroupOperation.as         |  271 +
 .../flex/textLayout/operations/CutOperation.as  |   98 +
 .../operations/DeleteTextOperation.as           |  159 +
 .../operations/FlowElementOperation.as          |  236 +
 .../flex/textLayout/operations/FlowOperation.as |  241 +
 .../textLayout/operations/FlowTextOperation.as  |  122 +
 .../operations/InsertInlineGraphicOperation.as  |  232 +
 .../operations/InsertTableElementOperation.as   |  134 +
 .../operations/InsertTextOperation.as           |  299 +
 .../operations/ModifyInlineGraphicOperation.as  |  166 +
 .../operations/MoveChildrenOperation.as         |  199 +
 .../textLayout/operations/PasteOperation.as     |  196 +
 .../flex/textLayout/operations/RedoOperation.as |   70 +
 .../operations/SplitElementOperation.as         |  191 +
 .../operations/SplitParagraphOperation.as       |   73 +
 .../flex/textLayout/operations/UndoOperation.as |   71 +
 .../flex/textLayout/property/ArrayProperty.as   |  201 +
 .../property/BooleanPropertyHandler.as          |   43 +
 .../property/CounterContentHandler.as           |  214 +
 .../textLayout/property/CounterPropHandler.as   |   65 +
 .../textLayout/property/EnumPropertyHandler.as  |   49 +
 .../property/FormatPropertyHandler.as           |   45 +
 .../textLayout/property/IntPropertyHandler.as   |   76 +
 .../property/NumberPropertyHandler.as           |   81 +
 .../property/PercentPropertyHandler.as          |   72 +
 .../flex/textLayout/property/PropConst.as       |   24 +
 .../apache/flex/textLayout/property/Property.as |  181 +
 .../flex/textLayout/property/PropertyFactory.as |  133 +
 .../flex/textLayout/property/PropertyHandler.as |   63 +
 .../flex/textLayout/property/PropertyUtil.as    |  177 +
 .../property/SpacingLimitPropertyHandler.as     |  137 +
 .../property/StringPropertyHandler.as           |   35 +
 .../textLayout/property/TabStopsProperty.as     |  202 +
 .../textLayout/property/UintPropertyHandler.as  |   75 +
 .../property/UndefinedPropertyHandler.as        |   44 +
 .../org/apache/flex/textLayout/tlf_internal.as  |   34 +
 .../flex/textLayout/utils/BackgroundUtil.as     |  262 +
 .../flex/textLayout/utils/CharacterUtil.as      |  167 +
 .../flex/textLayout/utils/ComposeUtils.as       |   48 +
 .../apache/flex/textLayout/utils/ConfigUtils.as |   24 +
 .../flex/textLayout/utils/CreateTLFUtil.as      |  197 +
 .../apache/flex/textLayout/utils/FactoryUtil.as |   46 +
 .../flex/textLayout/utils/GeometryUtil.as       |  128 +
 .../apache/flex/textLayout/utils/HitTestArea.as |  287 +
 .../apache/flex/textLayout/utils/LocaleUtil.as  |  211 +
 .../flex/textLayout/utils/NavigationUtil.as     | 1232 +++++
 .../flex/textLayout/utils/NumberFactoryUtil.as  |   30 +
 .../org/apache/flex/textLayout/utils/Twips.as   |   76 +
 .../src/main/resources/basic-as-manifest.xml    |   24 +
 .../TLF/src/main/resources/basic-manifest.xml   |   24 +
 .../TLF/src/main/resources/defaults.css         |   21 +
 frameworks/projects/Text/build.xml              |    1 -
 338 files changed, 82118 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/js/FlexJS/projects/TLFJS/build.xml
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/projects/TLFJS/build.xml b/frameworks/js/FlexJS/projects/TLFJS/build.xml
new file mode 100644
index 0000000..fe24115
--- /dev/null
+++ b/frameworks/js/FlexJS/projects/TLFJS/build.xml
@@ -0,0 +1,176 @@
+<?xml version="1.0"?>
+<!--
+
+  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
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+-->
+
+
+<project name="TLFJS" default="main" basedir=".">
+    <property name="FLEXJS_HOME" location="../../../../.."/>
+    
+    <property file="${FLEXJS_HOME}/env.properties"/>
+    <property environment="env"/>
+    <property file="${FLEXJS_HOME}/build.properties"/>
+    <property name="FLEX_HOME" value="${FLEXJS_HOME}"/>
+
+    <property name="dbg" value="false"/>
+    <property name="rel" value="true"/>
+    
+    <property name="target.name" value="${ant.project.name}.swc" />
+    <echo file="${basedir}/${target.name}.properties">target.name.nojs=${ant.project.name}</echo>
+    <replaceregexp file="${basedir}/${target.name}.properties" match="(.*)JS$" replace="\1" flags="m" />
+    <property file="${basedir}/${target.name}.properties"/>
+    <delete file="${basedir}/${target.name}.properties"/>
+    
+    <target name="main" depends="clean,check-compiler,compile-js-swc,compile-asjs" description="Full build of ${ant.project.name}.swc">
+    </target>
+    
+    <target name="clean">
+        <delete failonerror="false">
+            <fileset dir="${FLEXJS_HOME}/frameworks/js/FlexJS/libs">
+                <include name="${target.name}"/>
+            </fileset>
+        </delete>
+        <delete failonerror="false" includeemptydirs="true">
+            <fileset dir="${basedir}/target">
+                <include name="**/**"/>
+            </fileset>
+        </delete>
+    </target>
+    
+    <target name="compile-asjs" depends="check-compiler">
+        <echo message="Cross-compiling ${target.name}"/>
+        <echo message="FALCONJX_HOME: ${FALCONJX_HOME}"/>
+        <mkdir dir="${basedir}/target/generated-sources/flexjs"/>
+        <java jar="${FALCONJX_HOME}/lib/compc.jar" fork="true" >
+            <jvmarg value="-Xmx384m" />
+            <jvmarg value="-Dsun.io.useCanonCaches=false" />
+            <jvmarg value="-Dflexcompiler=${FALCONJX_HOME}/../compiler" />
+            <jvmarg value="-Dflexlib=${FLEXJS_HOME}/frameworks" />
+            <arg value="+flexlib=${FLEX_HOME}/frameworks" />
+            <arg value="-js-output-type=FLEXJS" />
+            <arg value="-compiler.strict-xml=true" />
+            <arg value="-keep-asdoc" /><!-- allows compiler to see @flexjsignorecoercion annotations -->
+            <!--<arg value="-output=${basedir}/../../../../projects/${target.name.nojs}/target/${target.name.nojs}.swc" />-->
+            <arg value="-output=${FLEX_HOME}/frameworks/projects/${target.name.nojs}/target/${target.name.nojs}.swc" />
+            <arg value="-load-config=${FLEX_HOME}/frameworks/js-config.xml" />
+            <arg value="-load-config+=${basedir}/src/main/config/compile-js-config.xml" />
+        </java>
+    </target>
+    
+    <target name="compile-js-swc" description="Compiles .as files into .swc used for cross-compiling other projects">
+        <echo message="Compiling target/${target.name}"/>
+        <echo message="FLEX_HOME: ${FLEX_HOME}"/>
+        <echo message="FALCON_HOME: ${FALCON_HOME}"/>
+        <mkdir dir="${FLEXJS_HOME}/frameworks/js/FlexJS/libs"/>
+        <mkdir dir="${basedir}/target"/>
+        
+        <compc fork="true"
+            output="${basedir}/target/${target.name}">
+            <jvmarg line="${compc.jvm.args}"/>
+            <arg value="-compiler.strict-xml=true" />
+            <define name="CONFIG::debug" value="${dbg}"/>
+            <define name="CONFIG::release" value="${rel}"/>
+            <load-config filename="${FLEX_HOME}/frameworks/js-config.xml" />
+            <load-config filename="src/main/config/compile-js-config.xml" />
+        </compc>
+        <copy file="${basedir}/target/${target.name}" tofile="${FLEXJS_HOME}/frameworks/js/FlexJS/libs/${target.name}" />
+    </target>
+    
+    <target name="copy-js" >
+        <mkdir dir="${FLEXJS_HOME}/frameworks/js/FlexJS/generated-sources"/>
+        <copy todir="${FLEXJS_HOME}/frameworks/js/FlexJS/generated-sources">
+            <fileset dir="${basedir}/target/generated-sources/flexjs">
+                <include name="**/**" />
+            </fileset>
+        </copy>
+    </target>
+    
+    <target name="check-compiler" depends="check-falcon-home, check-falconjx-home">
+        <path id="lib.path">
+            <fileset dir="${FALCON_HOME}/lib" includes="falcon-flexTasks.jar"/>
+        </path>
+        <taskdef resource="flexTasks.tasks" classpathref="lib.path"/>
+    </target>
+    
+    <target name="check-falcon-home" unless="FALCON_HOME"
+        description="Check FALCON_HOME is a directory.">
+        
+        <echo message="FALCON_HOME is ${env.FALCON_HOME}"/>
+        
+        <condition property="FALCON_HOME" value="${env.FALCON_HOME}">
+            <and>
+                <not>
+                    <isset property="FALCON_HOME" />
+                </not>
+                <available file="${env.FALCON_HOME}/lib/falcon-mxmlc.jar" type="file" />
+            </and>
+        </condition>
+        <condition property="FALCON_HOME" value="${FLEXJS_HOME}/../flex-falcon/compiler">
+            <and>
+                <not>
+                    <isset property="FALCON_HOME" />
+                </not>
+                <available file="${FLEXJS_HOME}/../flex-falcon/compiler/lib/falcon-mxmlc.jar" type="file" />
+            </and>
+        </condition>
+        <condition property="FALCON_HOME" value="${FLEXJS_HOME}">
+            <and>
+                <not>
+                    <isset property="FALCON_HOME" />
+                </not>
+                <available file="${FLEXJS_HOME}/lib/falcon-mxmlc.jar" type="file" />
+            </and>
+        </condition>
+        <fail message="FALCON_HOME must be set to a folder with a lib sub-folder containing falcon-mxmlc.jar such as the compiler folder in flex-falcon repo or a FlexJS SDK folder"
+        unless="FALCON_HOME"/>
+    </target>
+    
+    <target name="check-falconjx-home" unless="FALCONJX_HOME"
+        description="Check FALCON_HOME is a directory.">
+        
+        <echo message="FALCONJX_HOME is ${env.FALCONJX_HOME}"/>
+        
+        <condition property="FALCONJX_HOME" value="${env.FALCONJX_HOME}">
+            <and>
+                <not>
+                    <isset property="FALCONJX_HOME" />
+                </not>
+                <available file="${env.FALCONJX_HOME}/lib/jsc.jar" type="file" />
+            </and>
+        </condition>
+        <condition property="FALCONJX_HOME" value="${FLEXJS_HOME}/js">
+            <and>
+                <not>
+                    <isset property="FALCONJX_HOME" />
+                </not>
+                <available file="${FLEXJS_HOME}/js/lib/jsc.jar" type="file" />
+            </and>
+        </condition>
+        <condition property="FALCONJX_HOME" value="${FLEXJS_HOME}/../flex-falcon/compiler-jx">
+            <and>
+                <not>
+                    <isset property="FALCONJX_HOME" />
+                </not>
+                <available file="${FLEXJS_HOME}/../flex-falcon/compiler-jx/lib/jsc.jar" type="file" />
+            </and>
+        </condition>
+        <fail message="FALCONJX_HOME must be set to a folder with a lib sub-folder containing jsc.jar such as the compiler-jx folder in flex-falcon repo or the js folder of a FlexJS SDK"
+        unless="FALCONJX_HOME"/>
+    </target>
+    
+</project>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/js/FlexJS/projects/TLFJS/src/main/config/compile-js-config.xml
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/projects/TLFJS/src/main/config/compile-js-config.xml b/frameworks/js/FlexJS/projects/TLFJS/src/main/config/compile-js-config.xml
new file mode 100644
index 0000000..c74e940
--- /dev/null
+++ b/frameworks/js/FlexJS/projects/TLFJS/src/main/config/compile-js-config.xml
@@ -0,0 +1,98 @@
+<!--
+
+  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
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+-->
+<flex-config>
+
+    <compiler>
+        <accessible>false</accessible>
+                
+        <external-library-path append="true">
+        </external-library-path>
+        
+		<mxml>
+			<children-as-data>true</children-as-data>
+		</mxml>
+		<binding-value-change-event>org.apache.flex.events.ValueChangeEvent</binding-value-change-event>
+		<binding-value-change-event-kind>org.apache.flex.events.ValueChangeEvent</binding-value-change-event-kind>
+		<binding-value-change-event-type>valueChange</binding-value-change-event-type>
+
+        <define>
+            <name>COMPILE::SWF</name>
+            <value>false</value>
+        </define>
+        <define>
+            <name>COMPILE::JS</name>
+            <value>true</value>
+        </define>
+
+        <keep-as3-metadata>
+          <name>Bindable</name>
+          <name>Managed</name>
+          <name>ChangeEvent</name>
+          <name>NonCommittingChangeEvent</name>
+          <name>Transient</name>
+        </keep-as3-metadata>
+	  
+        <locale/>
+        
+        <!-- overwrite the default library-path setting -->
+        <library-path>
+            <path-element>../../../../../../../../js/libs/GCL.swc</path-element>
+            <!--<path-element>../../../../../../libs/GCL.swc</path-element>-->
+            <!-- asjscompc won't 'link' these classes in, but will list their requires
+                 if these swcs are on the external-library-path then their requires
+                 will not be listed -->
+            <path-element>../../../../../libs/CoreJS.swc</path-element>
+            <path-element>../../../../../libs/GraphicsJS.swc</path-element>
+            <path-element>../../../../../libs/HTMLJS.swc</path-element>
+            <path-element>../../../../../libs/NetworkJS.swc</path-element>
+            <path-element>../../../../../libs/ReflectionJS.swc</path-element>
+            <path-element>../../../../../libs/TextJS.swc</path-element>
+        </library-path>
+        
+        <namespaces>
+            <namespace>
+                <uri>library://ns.apache.org/flexjs/basic</uri>
+                <manifest>../../../../../../../projects/TLF/src/main/resources/basic-manifest.xml</manifest>
+            </namespace>
+        </namespaces>
+        
+        <source-path>
+            <!--<path-element>../../../../../../../projects/Text/src/main/flex</path-element>-->
+            <path-element>../../../../../../../projects/TLF/src/main/flex</path-element>
+        </source-path>
+        
+        <warn-no-constructor>false</warn-no-constructor>
+    </compiler>
+    
+    <include-file>
+    </include-file>
+
+    <include-sources>
+    </include-sources>
+    
+    <include-classes>
+        <class>TLFClasses</class>
+    </include-classes>
+    
+    <include-namespaces>
+        <uri>library://ns.apache.org/flexjs/basic</uri>
+    </include-namespaces>
+    
+
+</flex-config>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/js/FlexJS/projects/TextJS/build.xml
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/projects/TextJS/build.xml b/frameworks/js/FlexJS/projects/TextJS/build.xml
index b5c52e1..d3e7347 100644
--- a/frameworks/js/FlexJS/projects/TextJS/build.xml
+++ b/frameworks/js/FlexJS/projects/TextJS/build.xml
@@ -20,8 +20,8 @@
 
 
 <project name="TextJS" default="main" basedir=".">
-    <property name="FLEXJS_HOME" location="/FlexSDK/FlexJSNightly"/>
-    <!--<property name="FLEXJS_HOME" location="../../../../.."/>-->
+    <!--<property name="FLEXJS_HOME" location="/FlexSDK/FlexJSNightly"/>-->
+    <property name="FLEXJS_HOME" location="../../../../.."/>
     
     <property file="${FLEXJS_HOME}/env.properties"/>
     <property environment="env"/>
@@ -63,8 +63,8 @@
             <arg value="-js-output-type=FLEXJS" />
             <arg value="-compiler.strict-xml=true" />
             <arg value="-keep-asdoc" /><!-- allows compiler to see @flexjsignorecoercion annotations -->
-            <arg value="-output=${basedir}/../../../../projects/${target.name.nojs}/target/${target.name.nojs}.swc" />
-            <!--<arg value="-output=${FLEX_HOME}/frameworks/projects/${target.name.nojs}/target/${target.name.nojs}.swc" />-->
+            <!--<arg value="-output=${basedir}/../../../../projects/${target.name.nojs}/target/${target.name.nojs}.swc" />-->
+            <arg value="-output=${FLEX_HOME}/frameworks/projects/${target.name.nojs}/target/${target.name.nojs}.swc" />
             <arg value="-load-config=${FLEX_HOME}/frameworks/js-config.xml" />
             <arg value="-load-config+=${basedir}/src/main/config/compile-js-config.xml" />
         </java>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/Core/src/main/flex/CoreClasses.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/src/main/flex/CoreClasses.as b/frameworks/projects/Core/src/main/flex/CoreClasses.as
index 6233503..317c617 100644
--- a/frameworks/projects/Core/src/main/flex/CoreClasses.as
+++ b/frameworks/projects/Core/src/main/flex/CoreClasses.as
@@ -169,7 +169,7 @@ internal class CoreClasses
     import org.apache.flex.utils.StringPadder; StringPadder;
 	import org.apache.flex.utils.StringTrimmer; StringTrimmer;
 	import org.apache.flex.utils.StringUtil; StringUtil;
-	// import org.apache.flex.utils.ObjectMap; ObjectMap;
+	import org.apache.flex.utils.ObjectMap; ObjectMap;
 	import org.apache.flex.utils.ObjectUtil; ObjectUtil;
 	import org.apache.flex.utils.Timer; Timer;
 	import org.apache.flex.utils.UIDUtil; UIDUtil;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/.vscode/tasks.json
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/.vscode/tasks.json b/frameworks/projects/TLF/.vscode/tasks.json
new file mode 100644
index 0000000..d931ad0
--- /dev/null
+++ b/frameworks/projects/TLF/.vscode/tasks.json
@@ -0,0 +1,11 @@
+{
+	// See https://go.microsoft.com/fwlink/?LinkId=733558
+	// for the documentation about the tasks.json format
+	"version": "0.1.0",
+	"command": "asconfigc",
+	"isShellCommand": true,
+	"args": [
+		"--flexHome=/FlexSDK/FlexJSNightly"
+	],
+	"showOutput": "always"
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/asconfig.json
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/asconfig.json b/frameworks/projects/TLF/asconfig.json
new file mode 100644
index 0000000..73282fa
--- /dev/null
+++ b/frameworks/projects/TLF/asconfig.json
@@ -0,0 +1,33 @@
+{
+    "config": "flex",
+    "type": "app",
+    "compilerOptions": {
+        "debug": false,
+        "js-output-type": "flexjs",
+        "library-path": [
+            "libs"
+        ],
+        "define": [
+            {
+                "name": "COMPILE::SWF",
+                "value": true
+            },
+            {
+                "name": "COMPILE::JS",
+                "value": false
+            },
+            {
+                "name": "CONFIG::release",
+                "value":true
+            },
+            {
+                "name": "CONFIG::debug",
+                "value":false
+            }
+        ]
+    },
+    "files":
+    [
+        "src/TLFClasses.as"
+    ]
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/build.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/build.xml b/frameworks/projects/TLF/build.xml
new file mode 100644
index 0000000..2e66bcd
--- /dev/null
+++ b/frameworks/projects/TLF/build.xml
@@ -0,0 +1,172 @@
+<?xml version="1.0"?>
+<!--
+
+  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
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+-->
+
+
+<project name="TLF" default="main" basedir=".">
+    <property name="FLEXJS_HOME" location="../../.."/>
+    
+    <property file="${FLEXJS_HOME}/env.properties"/>
+    <property environment="env"/>
+    <property file="${FLEXJS_HOME}/build.properties"/>
+    <property name="FLEX_HOME" value="${FLEXJS_HOME}"/>
+    
+    <property name="target.name" value="${ant.project.name}.swc" />
+    <property name="dbg" value="false"/>
+    <property name="rel" value="true"/>
+    
+    <target name="main" depends="clean,check-compiler,compile,compile-js,copy-swc,test" description="Full build of ${ant.project.name}.swc">
+    </target>
+    
+    <target name="compile-js">
+        <ant dir="${FLEXJS_HOME}/frameworks/js/FlexJS/projects/${ant.project.name}JS/" inheritAll="false" />
+        <!--<ant dir="../../js/FlexJS/projects/${ant.project.name}JS/" inheritAll="false" />-->
+    </target>
+    
+    <target name="copy-swc">
+        <copy file="${basedir}/target/${target.name}" tofile="${FLEXJS_HOME}/frameworks/libs/${target.name}" />
+    </target>
+    
+    <target name="check-for-tests" >
+        <condition property="skip-tests" >
+            <not>
+                <available file="${basedir}/src/test/flex/build.xml" />
+            </not>
+        </condition>
+    </target>
+    
+    <target name="test" depends="check-for-tests" unless="skip-tests">
+        <ant dir="src/test/flex" />
+    </target>
+    
+    <target name="clean">
+        <delete failonerror="false">
+            <fileset dir="${FLEXJS_HOME}/frameworks/libs">
+                <include name="${target.name}"/>
+            </fileset>
+        </delete>
+        <delete failonerror="false" includeemptydirs="true">
+            <fileset dir="${basedir}/target">
+                <include name="**/**"/>
+            </fileset>
+        </delete>
+        <antcall target="clean-tests" />
+    </target>
+    
+    <target name="clean-tests" depends="check-for-tests" unless="skip-tests">
+        <ant dir="src/test/flex" target="clean"/>
+    </target>
+    
+    <target name="compile" description="Compiles .as files into .swc">
+        <echo message="Compiling libs/${ant.project.name}.swc"/>
+        <echo message="FLEX_HOME: ${FLEX_HOME}"/>
+        <echo message="FALCON_HOME: ${FALCON_HOME}"/>
+
+        <compc fork="true"
+            output="${basedir}/target/${target.name}">
+            <jvmarg line="${compc.jvm.args}"/>
+            <load-config filename="${basedir}/src/main/config/compile-as-config.xml" />
+            <arg value="+playerglobal.version=${playerglobal.version}" />
+            <arg value="+env.AIR_HOME=${env.AIR_HOME}" />
+            <arg value="-define=COMPILE::SWF,true" />
+            <arg value="-define=COMPILE::JS,false" />
+            <define name="CONFIG::debug" value="${dbg}"/>
+            <define name="CONFIG::release" value="${rel}"/>
+        </compc>
+    </target>
+
+    <target name="check-compiler" depends="check-falcon-home">
+        <path id="lib.path">
+            <fileset dir="${FALCON_HOME}/lib" includes="falcon-flexTasks.jar"/>
+        </path>
+        <taskdef resource="flexTasks.tasks" classpathref="lib.path"/>
+    </target>
+    
+    <target name="check-falcon-home" unless="FALCON_HOME"
+        description="Check FALCON_HOME is a directory.">
+        
+        <echo message="FALCON_HOME is ${env.FALCON_HOME}"/>
+        <condition property="FALCON_HOME" value="${env.FALCON_HOME}">
+            <and>
+                <not>
+                    <isset property="FALCON_HOME" />
+                </not>
+                <available file="${env.FALCON_HOME}/lib/falcon-mxmlc.jar" type="file" />
+            </and>
+        </condition>
+        <condition property="FALCON_HOME" value="${FLEXJS_HOME}/../flex-falcon/compiler">
+            <and>
+                <not>
+                    <isset property="FALCON_HOME" />
+                </not>
+                <available file="${FLEXJS_HOME}/../flex-falcon/compiler/lib/falcon-mxmlc.jar" type="file" />
+            </and>
+        </condition>
+        <condition property="FALCON_HOME" value="${FLEXJS_HOME}">
+            <and>
+                <not>
+                    <isset property="FALCON_HOME" />
+                </not>
+                <available file="${FLEXJS_HOME}/lib/falcon-mxmlc.jar" type="file" />
+            </and>
+        </condition>
+        <condition property="FALCONJX_HOME" value="${env.FALCONJX_HOME}">
+            <and>
+                <not>
+                    <isset property="FALCONJX_HOME" />
+                </not>
+                <available file="${env.FALCONJX_HOME}/lib/jsc.jar" type="file" />
+            </and>
+        </condition>
+        <condition property="FALCONJX_HOME" value="${FLEXJS_HOME}/js">
+            <and>
+                <not>
+                    <isset property="FALCONJX_HOME" />
+                </not>
+                <available file="${FLEXJS_HOME}/js/lib/jsc.jar" type="file" />
+            </and>
+        </condition>
+        <condition property="FALCONJX_HOME" value="${FLEXJS_HOME}/../flex-falcon/compiler-jx">
+            <and>
+                <not>
+                    <isset property="FALCONJX_HOME" />
+                </not>
+                <available file="${FLEXJS_HOME}/../flex-falcon/compiler-jx/lib/jsc.jar" type="file" />
+            </and>
+        </condition>
+        <condition property="GOOG_HOME" value="${env.GOOG_HOME}">
+            <and>
+                <not>
+                    <isset property="GOOG_HOME" />
+                </not>
+                <available file="${env.GOOG_HOME}/closure/goog/base.js" type="file" />
+            </and>
+        </condition>
+        <condition property="GOOG_HOME" value="${FLEXJS_HOME}/js/lib/google/closure-library">
+            <and>
+                <not>
+                    <isset property="GOOG_HOME" />
+                </not>
+                <available file="${FLEXJS_HOME}/js/lib/google/closure-library/closure/goog/base.js" type="file" />
+            </and>
+        </condition>        
+
+    </target>
+
+</project>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/build_old.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/build_old.xml b/frameworks/projects/TLF/build_old.xml
new file mode 100644
index 0000000..a0e42f1
--- /dev/null
+++ b/frameworks/projects/TLF/build_old.xml
@@ -0,0 +1,186 @@
+<?xml version="1.0"?>
+<!--
+
+  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
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+-->
+
+
+<project name="opentypejs" default="main" basedir=".">
+    <property name="FLEXJS_HOME" location="/FlexSDK/FlexJSNightly"/>
+    <!--<property name="FLEXJS_HOME" location="{env.FLEXJS_HOME}"/>-->
+    
+    <property file="${FLEXJS_HOME}/env.properties"/>
+    <property environment="env"/>
+    <property file="${FLEXJS_HOME}/build.properties"/>
+    <property name="FLEX_HOME" value="${FLEXJS_HOME}"/>
+    
+    <property name="target.name" value="${ant.project.name}.swc" />
+    <condition property="FALCON_HOME" value="${env.FALCON_HOME}">
+        <and>
+            <not>
+                <isset property="FALCON_HOME" />
+            </not>
+            <available file="${env.FALCON_HOME}/lib/falcon-mxmlc.jar" type="file" />
+        </and>
+    </condition>
+    <condition property="FALCON_HOME" value="${FLEXJS_HOME}/../flex-falcon/compiler">
+        <and>
+            <not>
+                <isset property="FALCON_HOME" />
+            </not>
+            <available file="${FLEXJS_HOME}/../flex-falcon/compiler/lib/falcon-mxmlc.jar" type="file" />
+        </and>
+    </condition>
+    <condition property="FALCON_HOME" value="${FLEXJS_HOME}">
+        <and>
+            <not>
+                <isset property="FALCON_HOME" />
+            </not>
+            <available file="${FLEXJS_HOME}/lib/falcon-mxmlc.jar" type="file" />
+        </and>
+    </condition>
+    <condition property="FALCONJX_HOME" value="${env.FALCONJX_HOME}">
+        <and>
+            <not>
+                <isset property="FALCONJX_HOME" />
+            </not>
+            <available file="${env.FALCONJX_HOME}/lib/jsc.jar" type="file" />
+        </and>
+    </condition>
+    <condition property="FALCONJX_HOME" value="${FLEXJS_HOME}/js">
+        <and>
+            <not>
+                <isset property="FALCONJX_HOME" />
+            </not>
+            <available file="${FLEXJS_HOME}/js/lib/jsc.jar" type="file" />
+        </and>
+    </condition>
+    <condition property="FALCONJX_HOME" value="${FLEXJS_HOME}/../flex-falcon/compiler-jx">
+        <and>
+            <not>
+                <isset property="FALCONJX_HOME" />
+            </not>
+            <available file="${FLEXJS_HOME}/../flex-falcon/compiler-jx/lib/jsc.jar" type="file" />
+        </and>
+    </condition>
+    <condition property="GOOG_HOME" value="${env.GOOG_HOME}">
+        <and>
+            <not>
+                <isset property="GOOG_HOME" />
+            </not>
+            <available file="${env.GOOG_HOME}/closure/goog/base.js" type="file" />
+        </and>
+    </condition>
+    <condition property="GOOG_HOME" value="${FLEXJS_HOME}/js/lib/google/closure-library">
+        <and>
+            <not>
+                <isset property="GOOG_HOME" />
+            </not>
+            <available file="${FLEXJS_HOME}/js/lib/google/closure-library/closure/goog/base.js" type="file" />
+        </and>
+    </condition>
+    
+    <target name="main" depends="clean,check-compiler,compile,copy" description="Full build of ${ant.project.name}.swc">
+    </target>
+    
+    <target name="check-js">
+        <uptodate property="js-not-needed" targetfile="${FLEXJS_HOME}/frameworks/js/FlexJS/projects/${ant.project.name}JS/target/${ant.project.name}JS.swc">
+            <srcfiles dir="${basedir}/src/main/flex" includes="**/**"/>
+        </uptodate>
+    </target>
+    <target name="js-if-needed" depends="check-js" unless="js-not-needed">
+        <ant dir="${FLEXJS_HOME}/frameworks/js/FlexJS/projects/${ant.project.name}JS/" inheritAll="false" />
+    </target>
+    
+    <target name="check-for-tests" >
+        <condition property="skip-tests" >
+            <not>
+                <available file="${basedir}/src/test/flex/build.xml" />
+            </not>
+        </condition>
+    </target>
+    
+    <target name="test" depends="check-for-tests" unless="skip-tests">
+        <ant dir="src/test/flex" />
+    </target>
+    
+    <target name="clean">
+        <delete failonerror="false">
+            <fileset dir="${FLEXJS_HOME}/frameworks/libs">
+                <include name="${target.name}"/>
+            </fileset>
+        </delete>
+        <delete failonerror="false" includeemptydirs="true">
+            <fileset dir="${basedir}/target">
+                <include name="**/**"/>
+            </fileset>
+        </delete>
+        <antcall target="clean-tests" />
+    </target>
+    
+    <target name="clean-tests" depends="check-for-tests" unless="skip-tests">
+        <ant dir="src/test/flex" target="clean"/>
+    </target>
+    
+    <target name="compile" description="Compiles .as files into .swc">
+        <echo message="Compiling libs/${ant.project.name}.swc"/>
+        <echo message="FLEX_HOME: ${FLEX_HOME}"/>
+        <echo message="FALCON_HOME: ${FALCON_HOME}"/>
+        <!-- make JS output folder now so include-file doesn't error -->
+        <mkdir dir="${basedir}/target/generated-sources/flexjs" />
+
+        <compc fork="true"
+            output="${basedir}/target/${target.name}">
+            <jvmarg line="${compc.jvm.args}"/>
+            <load-config filename="${basedir}/src/main/config/compile-as-config.xml" />
+            <arg value="+playerglobal.version=${playerglobal.version}" />
+            <arg value="+env.AIR_HOME=${env.AIR_HOME}" />
+            <arg value="-define=COMPILE::SWF,true" />
+            <arg value="-define=COMPILE::JS,false" />
+        </compc>
+    </target>
+
+    <target name="check-compiler" depends="check-falcon-home">
+        <path id="lib.path">
+            <fileset dir="${FALCON_HOME}/lib" includes="falcon-flexTasks.jar"/>
+        </path>
+        <taskdef resource="flexTasks.tasks" classpathref="lib.path"/>
+    </target>
+    <target name="copy">
+        <copy file="target/opentypejs.swc" todir="../projects/Text/libs"/>
+    </target>
+    
+    <target name="check-falcon-home" unless="FALCON_HOME"
+        description="Check FALCON_HOME is a directory.">
+        
+        <echo message="FALCON_HOME is ${env.FALCON_HOME}"/>
+        
+        <available file="${env.FALCON_HOME}/lib/falcon-mxmlc.jar"
+        type="file"
+        property="FALCON_HOME"
+        value="${env.FALCON_HOME}"/>
+        
+        <available file="${FLEXJS_HOME}/../flex-falcon/compiler/lib/falcon-mxmlc.jar"
+        type="file"
+        property="FALCON_HOME"
+        value="${FLEXJS_HOME}/../flex-falcon/compiler"/>
+        
+        <fail message="FALCON_HOME must be set to a folder with a lib sub-folder containing falcon-mxmlc.jar such as the compiler folder in flex-falcon repo or a FlexJS SDK folder"
+        unless="FALCON_HOME"/>
+    </target>
+
+</project>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/compile-config.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/compile-config.xml b/frameworks/projects/TLF/compile-config.xml
new file mode 100644
index 0000000..10748c7
--- /dev/null
+++ b/frameworks/projects/TLF/compile-config.xml
@@ -0,0 +1,77 @@
+<!--
+
+  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
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+-->
+<flex-config>
+
+    <compiler>
+        <accessible>false</accessible>
+        
+        <external-library-path>
+            <!--<path-element>typedefs/js.swc</path-element>-->
+            <path-element>typedefs/opentype.swc</path-element>
+            <path-element>typedefs/opentypejs.swc</path-element>
+            <path-element>/FlexSDK/FlexJSNightly/frameworks/libs/player/11.1/playerglobal.swc</path-element>
+            <!--<path-element>lib/CEP.swc</path-element>-->
+        </external-library-path>
+        
+		<mxml>
+			<children-as-data>true</children-as-data>
+		</mxml>
+		<binding-value-change-event>org.apache.flex.events.ValueChangeEvent</binding-value-change-event>
+		<binding-value-change-event-kind>org.apache.flex.events.ValueChangeEvent</binding-value-change-event-kind>
+		<binding-value-change-event-type>valueChange</binding-value-change-event-type>
+
+        <keep-as3-metadata>
+          <name>Bindable</name>
+          <name>Managed</name>
+          <name>ChangeEvent</name>
+          <name>NonCommittingChangeEvent</name>
+          <name>Transient</name>
+        </keep-as3-metadata>
+	  
+        <locale/>
+        
+        <library-path>
+            <path-element>/FlexSDK/FlexJSNightly/frameworks/libs/Core.swc</path-element>
+            <path-element>/FlexSDK/FlexJSNightly/frameworks/libs/Graphics.swc</path-element>
+            <path-element>/FlexSDK/FlexJSNightly/frameworks/libs/Language.swc</path-element>
+            <path-element>/FlexSDK/FlexJSNightly/frameworks/libs/Reflection.swc</path-element>
+            <path-element>/FlexSDK/FlexJSNightly/frameworks/libs/Network.swc</path-element>
+            <path-element>/FlexSDK/FlexJSNightly/frameworks/libs/HTML.swc</path-element>
+            <path-element>/FlexSDK/FlexJSNightly/frameworks/libs/XML.swc</path-element>
+            <path-element>libs/Text.swc</path-element>
+        </library-path>
+
+        
+        <source-path>
+            <path-element>src</path-element>
+        </source-path>
+        
+        <warn-no-constructor>false</warn-no-constructor>
+    </compiler>
+    
+    <include-classes>
+        <class>TLFClasses</class>
+        <!--<class>org.apache.flex.textLayout.ConversionClasses</class>
+        <class>org.apache.flex.textLayout.CoreClasses</class>
+        <class>org.apache.flex.textLayout.EditClasses</class>
+        <class>org.apache.flex.textLayout.TextLayoutVersion</class>-->
+    </include-classes>
+    	
+
+</flex-config>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/config/compile-as-config.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/config/compile-as-config.xml b/frameworks/projects/TLF/src/main/config/compile-as-config.xml
new file mode 100644
index 0000000..1d58fb5
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/config/compile-as-config.xml
@@ -0,0 +1,90 @@
+<!--
+
+  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
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+-->
+<flex-config>
+
+    <compiler>
+        <accessible>false</accessible>
+        
+        <external-library-path>
+            <path-element>${env.AIR_HOME}/frameworks/libs/air/airglobal.swc</path-element>
+            <path-element>../../../../../libs/Binding.swc</path-element>
+            <path-element>../../../../../libs/Core.swc</path-element>
+            <path-element>../../../../../libs/Graphics.swc</path-element>
+            <path-element>../../../../../libs/Collections.swc</path-element>
+            <path-element>../../../../../libs/HTML.swc</path-element>
+            <path-element>../../../../../libs/Collections.swc</path-element>
+            <path-element>../../../../../libs/Reflection.swc</path-element>
+            <path-element>../../../../../libs/Text.swc</path-element>
+        </external-library-path>
+        
+		<mxml>
+			<children-as-data>true</children-as-data>
+		</mxml>
+		<binding-value-change-event>org.apache.flex.events.ValueChangeEvent</binding-value-change-event>
+		<binding-value-change-event-kind>org.apache.flex.events.ValueChangeEvent</binding-value-change-event-kind>
+		<binding-value-change-event-type>valueChange</binding-value-change-event-type>
+
+        <keep-as3-metadata>
+          <name>Bindable</name>
+          <name>Managed</name>
+          <name>ChangeEvent</name>
+          <name>NonCommittingChangeEvent</name>
+          <name>Transient</name>
+        </keep-as3-metadata>
+	  
+        <locale/>
+        
+        <library-path/>
+
+        <namespaces>
+            <namespace>
+                <uri>library://ns.apache.org/flexjs/basic</uri>
+                <manifest>../resources/basic-manifest.xml</manifest>
+            </namespace>
+            <!--<namespace>
+                <uri>library://ns.apache.org/flexjs/svg</uri>
+                <manifest>../resources/svg-manifest.xml</manifest>
+            </namespace>-->
+        </namespaces>
+        
+        <source-path>
+            <path-element>../flex</path-element>
+        </source-path>
+        
+        <warn-no-constructor>false</warn-no-constructor>
+    </compiler>
+    
+    <include-file>
+        <name>defaults.css</name>
+        <path>../resources/defaults.css</path>
+    </include-file>
+
+    <include-classes>
+        <class>TLFClasses</class>
+    </include-classes>
+    
+    <include-namespaces>
+        <uri>library://ns.apache.org/flexjs/basic</uri>
+        <!--<uri>library://ns.apache.org/flexjs/svg</uri>-->
+    </include-namespaces>
+        
+    <target-player>${playerglobal.version}</target-player>
+	
+
+</flex-config>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/TLFClasses.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/TLFClasses.as b/frameworks/projects/TLF/src/main/flex/TLFClasses.as
new file mode 100644
index 0000000..51142c1
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/TLFClasses.as
@@ -0,0 +1,170 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package
+{
+ 	
+ 	internal class TLFClasses
+	{
+		
+		// import org.apache.flex.textLayout.accessibility.TextAccImpl; TextAccImpl;
+		
+		import org.apache.flex.textLayout.TextLayoutVersion; TextLayoutVersion;
+
+		import org.apache.flex.textLayout.compose.BaseCompose; BaseCompose;
+		import org.apache.flex.textLayout.compose.ComposeState; ComposeState;
+		import org.apache.flex.textLayout.compose.FactoryComposer; FactoryComposer;
+		import org.apache.flex.textLayout.compose.FlowComposerBase; FlowComposerBase;
+		import org.apache.flex.textLayout.compose.FloatCompositionData; FloatCompositionData;
+		import org.apache.flex.textLayout.compose.FlowDamageType; FlowDamageType;
+		import org.apache.flex.textLayout.compose.IFlowComposer; IFlowComposer;
+		import org.apache.flex.textLayout.compose.ISWFContext; ISWFContext;
+		import org.apache.flex.textLayout.compose.IVerticalJustificationLine; IVerticalJustificationLine;
+		import org.apache.flex.textLayout.compose.Parcel; Parcel;
+		import org.apache.flex.textLayout.compose.ParcelList; ParcelList;
+		import org.apache.flex.textLayout.compose.SimpleCompose; SimpleCompose;
+		import org.apache.flex.textLayout.compose.Slug; Slug;
+		import org.apache.flex.textLayout.compose.TextFlowLine; TextFlowLine;
+		import org.apache.flex.textLayout.compose.TextFlowLineLocation; TextFlowLineLocation;
+		import org.apache.flex.textLayout.compose.TextLineRecycler; TextLineRecycler;
+		import org.apache.flex.textLayout.compose.StandardFlowComposer; StandardFlowComposer;
+		import org.apache.flex.textLayout.compose.VerticalJustifier; VerticalJustifier;
+		
+		import org.apache.flex.textLayout.container.ColumnState; ColumnState;		
+		import org.apache.flex.textLayout.container.ContainerController; ContainerController;
+		import org.apache.flex.textLayout.container.ISandboxSupport; ISandboxSupport;
+		import org.apache.flex.textLayout.container.ScrollPolicy; ScrollPolicy;
+				
+		import org.apache.flex.textLayout.debug.assert;assert;
+		import org.apache.flex.textLayout.debug.Debugging; Debugging;
+		
+		import org.apache.flex.textLayout.edit.EditingMode; EditingMode;
+		import org.apache.flex.textLayout.edit.IInteractionEventHandler; IInteractionEventHandler;
+		import org.apache.flex.textLayout.edit.ISelectionManager; ISelectionManager;
+		import org.apache.flex.textLayout.edit.SelectionFormat; SelectionFormat;
+		import org.apache.flex.textLayout.edit.SelectionState; SelectionState;
+		import org.apache.flex.textLayout.edit.SelectionType; SelectionType;
+		
+		import org.apache.flex.textLayout.elements.SubParagraphGroupElementBase; SubParagraphGroupElementBase;
+		import org.apache.flex.textLayout.elements.BreakElement; BreakElement;
+		import org.apache.flex.textLayout.elements.Configuration; Configuration;
+		import org.apache.flex.textLayout.elements.ContainerFormattedElement; ContainerFormattedElement;
+		import org.apache.flex.textLayout.elements.DivElement; DivElement;
+		import org.apache.flex.textLayout.elements.FlowElement; FlowElement;
+		import org.apache.flex.textLayout.elements.FlowGroupElement; FlowGroupElement;
+		import org.apache.flex.textLayout.elements.FlowLeafElement; FlowLeafElement;
+		import org.apache.flex.textLayout.elements.GlobalSettings; GlobalSettings;
+		import org.apache.flex.textLayout.elements.IConfiguration; IConfiguration;
+		import org.apache.flex.textLayout.elements.IExplicitFormatResolver; IExplicitFormatResolver;
+		import org.apache.flex.textLayout.elements.IFormatResolver; IFormatResolver;
+		import org.apache.flex.textLayout.elements.InlineGraphicElement; InlineGraphicElement;
+		import org.apache.flex.textLayout.elements.InlineGraphicElementStatus; InlineGraphicElementStatus;
+		import org.apache.flex.textLayout.elements.ListElement; ListElement;
+		import org.apache.flex.textLayout.elements.ListItemElement; ListItemElement;
+		import org.apache.flex.textLayout.elements.LinkElement; LinkElement;
+		import org.apache.flex.textLayout.elements.LinkState; LinkState;
+		import org.apache.flex.textLayout.elements.OverflowPolicy; OverflowPolicy;
+		import org.apache.flex.textLayout.elements.ParagraphElement; ParagraphElement;
+		import org.apache.flex.textLayout.elements.ParagraphFormattedElement; ParagraphFormattedElement;
+		import org.apache.flex.textLayout.elements.SpanElement; SpanElement;
+		import org.apache.flex.textLayout.elements.SpecialCharacterElement; SpecialCharacterElement;
+		import org.apache.flex.textLayout.elements.SubParagraphGroupElement; SubParagraphGroupElement;
+		import org.apache.flex.textLayout.elements.TabElement; TabElement;
+		import org.apache.flex.textLayout.elements.TableElement; TableElement;
+		import org.apache.flex.textLayout.elements.TableBodyElement; TableBodyElement;
+		import org.apache.flex.textLayout.elements.TableColElement; TableColElement;
+		import org.apache.flex.textLayout.elements.TableColGroupElement; TableColGroupElement;
+		import org.apache.flex.textLayout.elements.TableCellElement; TableCellElement;
+		import org.apache.flex.textLayout.elements.TableRowElement; TableRowElement;
+		import org.apache.flex.textLayout.elements.TCYElement; TCYElement;
+		import org.apache.flex.textLayout.elements.TextFlow; TextFlow;
+		import org.apache.flex.textLayout.elements.TextRange; TextRange;
+
+		
+		import org.apache.flex.textLayout.events.CompositionCompleteEvent; CompositionCompleteEvent;
+		import org.apache.flex.textLayout.events.DamageEvent; DamageEvent;
+		import org.apache.flex.textLayout.events.FlowElementMouseEvent; FlowElementMouseEvent;
+		import org.apache.flex.textLayout.events.FlowElementMouseEventManager; FlowElementMouseEventManager;
+		import org.apache.flex.textLayout.events.FlowElementEventDispatcher; FlowElementEventDispatcher;
+		import org.apache.flex.textLayout.events.ModelChange; ModelChange;
+		import org.apache.flex.textLayout.events.ScrollEvent; ScrollEvent;
+		import org.apache.flex.textLayout.events.ScrollEventDirection; ScrollEventDirection;
+		import org.apache.flex.textLayout.events.StatusChangeEvent; StatusChangeEvent;
+		import org.apache.flex.textLayout.events.TextLayoutEvent; TextLayoutEvent;
+		
+		import org.apache.flex.textLayout.factory.TextLineFactoryBase; TextLineFactoryBase;
+		import org.apache.flex.textLayout.factory.StringTextLineFactory; StringTextLineFactory;
+		import org.apache.flex.textLayout.factory.TextFlowTextLineFactory; TextFlowTextLineFactory;
+		import org.apache.flex.textLayout.factory.TruncationOptions; TruncationOptions;		
+
+		import org.apache.flex.textLayout.formats.BaselineOffset; BaselineOffset;
+		import org.apache.flex.textLayout.formats.BaselineShift; BaselineShift;
+		import org.apache.flex.textLayout.formats.BlockProgression; BlockProgression;
+		import org.apache.flex.textLayout.formats.BreakStyle; BreakStyle;
+
+		import org.apache.flex.textLayout.formats.Category; Category;
+		import org.apache.flex.textLayout.formats.ClearFloats; ClearFloats;
+		import org.apache.flex.textLayout.formats.Direction; Direction;
+		import org.apache.flex.textLayout.formats.Float; Float;
+		import org.apache.flex.textLayout.formats.FormatValue; FormatValue;
+		import org.apache.flex.textLayout.formats.IMEStatus; IMEStatus;
+		import org.apache.flex.textLayout.formats.IListMarkerFormat; IListMarkerFormat;
+		import org.apache.flex.textLayout.formats.ITabStopFormat; ITabStopFormat;
+		import org.apache.flex.textLayout.formats.ITextLayoutFormat; ITextLayoutFormat;
+		import org.apache.flex.textLayout.formats.JustificationRule; JustificationRule;
+		import org.apache.flex.textLayout.formats.LeadingModel; LeadingModel;
+		import org.apache.flex.textLayout.formats.LineBreak; LineBreak;
+		import org.apache.flex.textLayout.formats.ListMarkerFormat; ListMarkerFormat;
+		import org.apache.flex.textLayout.formats.Suffix; Suffix;
+		import org.apache.flex.textLayout.formats.TabStopFormat; TabStopFormat;
+		import org.apache.flex.textLayout.formats.TextAlign; TextAlign;
+		import org.apache.flex.textLayout.formats.TextDecoration; TextDecoration;
+		import org.apache.flex.textLayout.formats.TextJustify; TextJustify;
+		import org.apache.flex.textLayout.formats.TextLayoutFormat; TextLayoutFormat;		
+		import org.apache.flex.textLayout.formats.VerticalAlign; VerticalAlign;
+		import org.apache.flex.textLayout.formats.WhiteSpaceCollapse; WhiteSpaceCollapse;
+
+		import org.apache.flex.textLayout.property.ArrayProperty; ArrayProperty;
+		import org.apache.flex.textLayout.property.Property; Property;
+		
+		// new property classes
+		import org.apache.flex.textLayout.property.PropertyHandler; PropertyHandler;
+		import org.apache.flex.textLayout.property.BooleanPropertyHandler; BooleanPropertyHandler;
+		import org.apache.flex.textLayout.property.EnumPropertyHandler; EnumPropertyHandler;
+		import org.apache.flex.textLayout.property.FormatPropertyHandler; FormatPropertyHandler;
+		import org.apache.flex.textLayout.property.StringPropertyHandler; StringPropertyHandler;
+		import org.apache.flex.textLayout.property.IntPropertyHandler; IntPropertyHandler;
+		import org.apache.flex.textLayout.property.UintPropertyHandler; UintPropertyHandler;
+		import org.apache.flex.textLayout.property.NumberPropertyHandler; NumberPropertyHandler;
+		import org.apache.flex.textLayout.property.UndefinedPropertyHandler; UndefinedPropertyHandler;
+		import org.apache.flex.textLayout.property.PercentPropertyHandler; PercentPropertyHandler;
+		import org.apache.flex.textLayout.property.CounterContentHandler; CounterContentHandler;
+		import org.apache.flex.textLayout.property.CounterPropHandler; CounterPropHandler;
+		
+		import org.apache.flex.textLayout.utils.CharacterUtil; CharacterUtil;
+		import org.apache.flex.textLayout.utils.GeometryUtil; GeometryUtil;
+		import org.apache.flex.textLayout.utils.HitTestArea; HitTestArea;
+		import org.apache.flex.textLayout.utils.Twips; Twips;
+				
+		// CONFIG::release public function exportAssert():void
+		// {
+		// 	assert();
+		// }
+	}
+}
+

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/ConversionClasses.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/ConversionClasses.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/ConversionClasses.as
new file mode 100644
index 0000000..4f4bed4
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/ConversionClasses.as
@@ -0,0 +1,34 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout
+{
+	internal class ConversionClasses
+	{
+		import org.apache.flex.textLayout.conversion.ConversionType; ConversionType;
+		import org.apache.flex.textLayout.conversion.FormatDescriptor; FormatDescriptor;
+		import org.apache.flex.textLayout.conversion.IHTMLImporter; IHTMLImporter; 
+		import org.apache.flex.textLayout.conversion.IPlainTextExporter; IPlainTextExporter; 
+		import org.apache.flex.textLayout.conversion.ITextImporter; ITextImporter; 
+		import org.apache.flex.textLayout.conversion.ITextExporter; ITextExporter; 
+		import org.apache.flex.textLayout.conversion.ITextLayoutImporter; ITextLayoutImporter; 
+		import org.apache.flex.textLayout.conversion.TextConverter; TextConverter;
+		import org.apache.flex.textLayout.conversion.TextLayoutImporter; TextLayoutImporter;
+		// Alphabetical list of classes to be included as part of text_conversion.swc
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/CoreClasses.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/CoreClasses.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/CoreClasses.as
new file mode 100644
index 0000000..ce2d507
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/CoreClasses.as
@@ -0,0 +1,174 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout
+{
+ 	
+ 	import org.apache.flex.textLayout.compose.IComposeState;
+ 	import org.apache.flex.textLayout.compose.IComposer;
+ 	import org.apache.flex.textLayout.compose.IFactoryComposer;
+ 	import org.apache.flex.textLayout.compose.ISimpleCompose;
+ 	internal class CoreClasses
+	{
+		
+		// import org.apache.flex.textLayout.accessibility.TextAccImpl; TextAccImpl;
+		
+		import org.apache.flex.textLayout.TextLayoutVersion; TextLayoutVersion;
+
+		import org.apache.flex.textLayout.compose.BaseCompose; IComposer;
+		import org.apache.flex.textLayout.compose.ComposeState; IComposeState;
+		import org.apache.flex.textLayout.compose.FlowComposerBase; FlowComposerBase;
+		import org.apache.flex.textLayout.compose.FloatCompositionData; FloatCompositionData;
+		import org.apache.flex.textLayout.compose.FlowDamageType; FlowDamageType;
+		import org.apache.flex.textLayout.compose.IFlowComposer; IFlowComposer;
+		import org.apache.flex.textLayout.compose.ISWFContext; ISWFContext;
+		import org.apache.flex.textLayout.compose.IVerticalJustificationLine; IVerticalJustificationLine;
+		import org.apache.flex.textLayout.compose.Parcel; Parcel;
+		import org.apache.flex.textLayout.compose.ParcelList; ParcelList;
+		import org.apache.flex.textLayout.compose.SimpleCompose; ISimpleCompose;
+		import org.apache.flex.textLayout.compose.Slug; Slug;
+		import org.apache.flex.textLayout.compose.TextFlowLine; TextFlowLine;
+		import org.apache.flex.textLayout.compose.TextFlowLineLocation; TextFlowLineLocation;
+		import org.apache.flex.textLayout.compose.TextLineRecycler; TextLineRecycler;
+		import org.apache.flex.textLayout.compose.StandardFlowComposer; StandardFlowComposer;
+		import org.apache.flex.textLayout.compose.VerticalJustifier; VerticalJustifier;
+		
+		import org.apache.flex.textLayout.container.ColumnState; ColumnState;		
+		import org.apache.flex.textLayout.container.ContainerController; ContainerController;
+		import org.apache.flex.textLayout.container.ISandboxSupport; ISandboxSupport;
+		import org.apache.flex.textLayout.container.ScrollPolicy; ScrollPolicy;
+				
+		import org.apache.flex.textLayout.debug.assert;assert;
+		import org.apache.flex.textLayout.debug.Debugging; Debugging;
+		
+		import org.apache.flex.textLayout.edit.EditingMode; EditingMode;
+		import org.apache.flex.textLayout.edit.IInteractionEventHandler; IInteractionEventHandler;
+		import org.apache.flex.textLayout.edit.ISelectionManager; ISelectionManager;
+		import org.apache.flex.textLayout.edit.SelectionFormat; SelectionFormat;
+		import org.apache.flex.textLayout.edit.SelectionState; SelectionState;
+		import org.apache.flex.textLayout.edit.SelectionType; SelectionType;
+		
+		import org.apache.flex.textLayout.elements.SubParagraphGroupElementBase; SubParagraphGroupElementBase;
+		import org.apache.flex.textLayout.elements.BreakElement; BreakElement;
+		import org.apache.flex.textLayout.elements.Configuration; Configuration;
+		import org.apache.flex.textLayout.elements.ContainerFormattedElement; ContainerFormattedElement;
+		import org.apache.flex.textLayout.elements.DivElement; DivElement;
+		import org.apache.flex.textLayout.elements.FlowElement; FlowElement;
+		import org.apache.flex.textLayout.elements.FlowGroupElement; FlowGroupElement;
+		import org.apache.flex.textLayout.elements.FlowLeafElement; FlowLeafElement;
+		import org.apache.flex.textLayout.elements.GlobalSettings; GlobalSettings;
+		import org.apache.flex.textLayout.elements.IConfiguration; IConfiguration;
+		import org.apache.flex.textLayout.elements.IExplicitFormatResolver; IExplicitFormatResolver;
+		import org.apache.flex.textLayout.elements.IFormatResolver; IFormatResolver;
+		import org.apache.flex.textLayout.elements.InlineGraphicElement; InlineGraphicElement;
+		import org.apache.flex.textLayout.elements.InlineGraphicElementStatus; InlineGraphicElementStatus;
+		import org.apache.flex.textLayout.elements.ListElement; ListElement;
+		import org.apache.flex.textLayout.elements.ListItemElement; ListItemElement;
+		import org.apache.flex.textLayout.elements.LinkElement; LinkElement;
+		import org.apache.flex.textLayout.elements.LinkState; LinkState;
+		import org.apache.flex.textLayout.elements.OverflowPolicy; OverflowPolicy;
+		import org.apache.flex.textLayout.elements.ParagraphElement; ParagraphElement;
+		import org.apache.flex.textLayout.elements.ParagraphFormattedElement; ParagraphFormattedElement;
+		import org.apache.flex.textLayout.elements.SpanElement; SpanElement;
+		import org.apache.flex.textLayout.elements.SpecialCharacterElement; SpecialCharacterElement;
+		import org.apache.flex.textLayout.elements.SubParagraphGroupElement; SubParagraphGroupElement;
+		import org.apache.flex.textLayout.elements.TabElement; TabElement;
+		import org.apache.flex.textLayout.elements.TableElement; TableElement;
+		import org.apache.flex.textLayout.elements.TableBodyElement; TableBodyElement;
+		import org.apache.flex.textLayout.elements.TableColElement; TableColElement;
+		import org.apache.flex.textLayout.elements.TableColGroupElement; TableColGroupElement;
+		import org.apache.flex.textLayout.elements.TableCellElement; TableCellElement;
+		import org.apache.flex.textLayout.elements.TableRowElement; TableRowElement;
+		import org.apache.flex.textLayout.elements.TCYElement; TCYElement;
+		import org.apache.flex.textLayout.elements.TextFlow; TextFlow;
+		import org.apache.flex.textLayout.elements.TextRange; TextRange;
+
+		
+		import org.apache.flex.textLayout.events.CompositionCompleteEvent; CompositionCompleteEvent;
+		import org.apache.flex.textLayout.events.DamageEvent; DamageEvent;
+		import org.apache.flex.textLayout.events.FlowElementMouseEvent; FlowElementMouseEvent;
+		import org.apache.flex.textLayout.events.FlowElementMouseEventManager; FlowElementMouseEventManager;
+		import org.apache.flex.textLayout.events.FlowElementEventDispatcher; FlowElementEventDispatcher;
+		import org.apache.flex.textLayout.events.ModelChange; ModelChange;
+		import org.apache.flex.textLayout.events.ScrollEvent; ScrollEvent;
+		import org.apache.flex.textLayout.events.ScrollEventDirection; ScrollEventDirection;
+		import org.apache.flex.textLayout.events.StatusChangeEvent; StatusChangeEvent;
+		import org.apache.flex.textLayout.events.TextLayoutEvent; TextLayoutEvent;
+		
+		import org.apache.flex.textLayout.compose.FactoryComposer; FactoryComposer;
+		import org.apache.flex.textLayout.factory.TextLineFactoryBase; TextLineFactoryBase;
+		import org.apache.flex.textLayout.factory.StringTextLineFactory; StringTextLineFactory;
+		import org.apache.flex.textLayout.factory.TextFlowTextLineFactory; TextFlowTextLineFactory;
+		import org.apache.flex.textLayout.factory.TruncationOptions; TruncationOptions;		
+
+		import org.apache.flex.textLayout.formats.BaselineOffset; BaselineOffset;
+		import org.apache.flex.textLayout.formats.BaselineShift; BaselineShift;
+		import org.apache.flex.textLayout.formats.BlockProgression; BlockProgression;
+		import org.apache.flex.textLayout.formats.BreakStyle; BreakStyle;
+
+		import org.apache.flex.textLayout.formats.Category; Category;
+		import org.apache.flex.textLayout.formats.ClearFloats; ClearFloats;
+		import org.apache.flex.textLayout.formats.Direction; Direction;
+		import org.apache.flex.textLayout.formats.Float; Float;
+		import org.apache.flex.textLayout.formats.FormatValue; FormatValue;
+		import org.apache.flex.textLayout.formats.IMEStatus; IMEStatus;
+		import org.apache.flex.textLayout.formats.IListMarkerFormat; IListMarkerFormat;
+		import org.apache.flex.textLayout.formats.ITabStopFormat; ITabStopFormat;
+		import org.apache.flex.textLayout.formats.ITextLayoutFormat; ITextLayoutFormat;
+		import org.apache.flex.textLayout.formats.JustificationRule; JustificationRule;
+		import org.apache.flex.textLayout.formats.LeadingModel; LeadingModel;
+		import org.apache.flex.textLayout.formats.LineBreak; LineBreak;
+		import org.apache.flex.textLayout.formats.ListMarkerFormat; ListMarkerFormat;
+		import org.apache.flex.textLayout.formats.Suffix; Suffix;
+		import org.apache.flex.textLayout.formats.TabStopFormat; TabStopFormat;
+		import org.apache.flex.textLayout.formats.TextAlign; TextAlign;
+		import org.apache.flex.textLayout.formats.TextDecoration; TextDecoration;
+		import org.apache.flex.textLayout.formats.TextJustify; TextJustify;
+		import org.apache.flex.textLayout.formats.TextLayoutFormat; TextLayoutFormat;		
+		import org.apache.flex.textLayout.formats.VerticalAlign; VerticalAlign;
+		import org.apache.flex.textLayout.formats.WhiteSpaceCollapse; WhiteSpaceCollapse;
+
+		import org.apache.flex.textLayout.property.ArrayProperty; ArrayProperty;
+		import org.apache.flex.textLayout.property.Property; Property;
+		
+		// new property classes
+		import org.apache.flex.textLayout.property.PropertyHandler; PropertyHandler;
+		import org.apache.flex.textLayout.property.BooleanPropertyHandler; BooleanPropertyHandler;
+		import org.apache.flex.textLayout.property.EnumPropertyHandler; EnumPropertyHandler;
+		import org.apache.flex.textLayout.property.FormatPropertyHandler; FormatPropertyHandler;
+		import org.apache.flex.textLayout.property.StringPropertyHandler; StringPropertyHandler;
+		import org.apache.flex.textLayout.property.IntPropertyHandler; IntPropertyHandler;
+		import org.apache.flex.textLayout.property.UintPropertyHandler; UintPropertyHandler;
+		import org.apache.flex.textLayout.property.NumberPropertyHandler; NumberPropertyHandler;
+		import org.apache.flex.textLayout.property.UndefinedPropertyHandler; UndefinedPropertyHandler;
+		import org.apache.flex.textLayout.property.PercentPropertyHandler; PercentPropertyHandler;
+		import org.apache.flex.textLayout.property.CounterContentHandler; CounterContentHandler;
+		import org.apache.flex.textLayout.property.CounterPropHandler; CounterPropHandler;
+		
+		import org.apache.flex.textLayout.utils.CharacterUtil; CharacterUtil;
+		import org.apache.flex.textLayout.utils.GeometryUtil; GeometryUtil;
+		import org.apache.flex.textLayout.utils.HitTestArea; HitTestArea;
+		import org.apache.flex.textLayout.utils.Twips; Twips;
+				
+		// CONFIG::release public function exportAssert():void
+		// {
+		// 	assert();
+		// }
+	}
+}
+


[34/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/ColumnState.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/ColumnState.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/ColumnState.as
new file mode 100644
index 0000000..625bb6f
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/ColumnState.as
@@ -0,0 +1,427 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.container
+{
+	import org.apache.flex.geom.Rectangle;
+	
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.elements.TableCellElement;
+	import org.apache.flex.textLayout.formats.BlockProgression;
+	import org.apache.flex.textLayout.formats.Direction;
+	import org.apache.flex.textLayout.formats.FormatValue;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.formats.LineBreak;
+
+	import org.apache.flex.textLayout.utils.Twips;
+		
+
+
+	/** 
+	 * The ColumnState class calculates the sizes and locations of columns using
+	 * the width of the container and the container attributes. You can create instances of this class 
+	 * independently to calculate column values, or you can get the column values that 
+	 * were used for the text after the container has been composed or updated (redrawn).
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 *
+	 * @see ContainerController
+	 */
+
+	public class ColumnState 
+	{
+		// input information
+		private var _inputsChanged:Boolean;
+		private var _blockProgression:String;
+		private var _columnDirection:String;
+		private var _paddingTop:Number;
+		private var _paddingBottom:Number;
+		private var _paddingLeft:Number;
+		private var _paddingRight:Number;
+		private var _compositionWidth:Number;
+		private var _compositionHeight:Number;
+		private var _forceSingleColumn:Boolean;
+		
+		private var _inputColumnWidth:Object;
+		private var _inputColumnGap:Number;
+		private var _inputColumnCount:Object;
+		
+		// Generated column information		
+		private var _columnWidth:Number;	
+		private var _columnCount:int;		
+		private var _columnGap:Number;	
+		private var _inset:Number;
+		
+		// and the array of columns
+		private var _columnArray:Array;
+		private var _tableCellArray:Array;
+		private var _singleColumn:Rectangle;
+		
+		/**
+		 * Constructor function - creates a ColumnState object.
+		 *
+		 * If the values of <code>controller.compositionWidth</code> and <code>controller.compositionHeight</code> equal
+		 * <code>NaN</code> (not a number), the constructor measures the container's contents to determine the actual 
+		 * composition width and height that feed into ColumnState.
+		 *
+		 * Use the constants defined by the <code>org.apache.flex.textLayout.formats.BlockProgression</code> class to 
+		 * specify the value of the <code>blockProgression</code> parameter. Use the constants defined by
+		 * <code>org.apache.flex.textLayout.formats.Direction</code> to specify the value of the <code>columnDirection</code> 
+		 * parameter.
+		 *
+		 * @param blockProgression The direction of lines for the textflow, either BlockProgression.TB (top-to-bottom) or 
+		 * 		BlockProgression.RL (right-to-left).
+		 * @param columnDirection The direction of column layout for the text flow, either Direction.RTL (right-to-left) or 
+		 * 		Direction.LTR (left-to-right).
+		 * @param controller A ContainerController instance whose attributes are used to calculate the column values.
+		 * @param compositionWidth The horizontal extent, in pixels, allowed for text inside the container.
+		 * @param compositionHeight The vertical extent, in pixels, allowed for text inside the container.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 * @see org.apache.flex.textLayout.formats.BlockProgression BlockProgression
+		 * @see org.apache.flex.textLayout.formats.Direction Direction
+	 	 */
+		
+		public function ColumnState(blockProgression:String, columnDirection:String, controller:IContainerController, compositionWidth:Number, compositionHeight:Number)
+		{
+			_inputsChanged = true;
+			_columnCount = 0;
+
+			if (blockProgression != null)		// if values are legit, recalculate now. They might not be, if this is called from a containerController constructor.
+			{		
+				updateInputs(blockProgression, columnDirection, controller, compositionWidth, compositionHeight);
+				computeColumns();
+			}
+		}
+		
+		/** 
+		 * The width of columns, in pixels, in the container. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		public function get columnWidth():Number
+		{ return _columnWidth; }
+
+		/** 
+		 * The number of columns in the container. 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		public function get columnCount():int
+		{ return _columnCount; }
+		
+		/** 
+		 * The number of cells in the container. 
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		
+		public function get cellCount():int
+		{ 
+			if ( _tableCellArray )
+				return _tableCellArray.length;
+			return -1;
+		}
+
+		/** 
+		 * The amount of space, in pixels, left between columns in the container.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+	 	 * @langversion 3.0
+	 	 */
+	 	 
+		public function get columnGap():Number
+		{ return _columnGap; }
+		
+		/** 
+		 * Returns the area that a column takes within the container. Allows you to access the area for a 
+		 * specific column.
+		 *
+		 * @param index The relative position of the column among all columns in the container, with the first
+		 * 	column at position 0.
+		 *
+		 * @return The area of the specified column.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		 
+		public function getColumnAt(index:int):Rectangle
+		{
+			return _columnCount == 1 ? _singleColumn : _columnArray[index];
+		}
+		
+		public function getCellAt(index:int):TableCellElement
+		{
+			return _tableCellArray[index];
+		}
+		
+		public function pushTableCell(cell:TableCellElement):void
+		{
+			if ( _tableCellArray == null )
+				_tableCellArray = new Array();
+			_tableCellArray.push(cell);
+		}
+		
+		public function clearCellList():void
+		{
+			_tableCellArray = null;
+		}
+
+		/** Recalculate actual column settings based on attributes and width
+		 * from the container. Call this after either the attributes or the
+		 * width has been changed to get the new values.
+		 *
+		 * @param newBlockProgression block progression for the textflow
+		 * @param newColumnDirection column layout direction for the textflow
+		 * @param containerAttr		Formatting attributes from the container
+		 * @param containerWidth		Width of the container
+		 * @return Boolean			true if the actual column settings have changed
+		 * @private 
+		 */
+		public function updateInputs(newBlockProgression:String, newColumnDirection:String, controller:IContainerController, newCompositionWidth:Number, newCompositionHeight:Number ):void
+		{
+			var newPaddingTop:Number = controller.getTotalPaddingTop();
+			var newPaddingBottom:Number = controller.getTotalPaddingBottom();
+			var newPaddingLeft:Number = controller.getTotalPaddingLeft();
+			var newPaddingRight:Number = controller.getTotalPaddingRight();
+			
+			var containerAttr:ITextLayoutFormat = controller.computedFormat;
+			
+			var newColumnWidth:Object = containerAttr.columnWidth;
+			var newColumnGap:Number = containerAttr.columnGap;
+			var newColumnCount:Object = containerAttr.columnCount;
+			
+			var newForceSingleColumn:Boolean = ((containerAttr.columnCount == FormatValue.AUTO && (containerAttr.columnWidth == FormatValue.AUTO || Number(containerAttr.columnWidth) == 0)) ||
+				controller.rootElement.computedFormat.lineBreak == LineBreak.EXPLICIT) || isNaN(newBlockProgression == BlockProgression.RL ? newCompositionHeight : newCompositionWidth);
+			
+			if (_inputsChanged == false) 
+				_inputsChanged = newCompositionWidth != _compositionHeight || newCompositionHeight != _compositionHeight
+				|| _paddingTop != newPaddingTop || _paddingBottom != newPaddingBottom || _paddingLeft != newPaddingLeft || _paddingRight != newPaddingRight
+				|| _blockProgression != _blockProgression || _columnDirection != newColumnDirection || _forceSingleColumn != newForceSingleColumn
+				|| _inputColumnWidth != newColumnWidth || _inputColumnGap != newColumnGap || _inputColumnCount != newColumnCount;
+				
+			if (_inputsChanged)
+			{
+				_blockProgression = newBlockProgression;
+				_columnDirection = newColumnDirection;
+				_paddingTop = newPaddingTop;
+				_paddingBottom = newPaddingBottom;
+				_paddingLeft = newPaddingLeft;
+				_paddingRight = newPaddingRight;
+				_compositionWidth = newCompositionWidth;
+				_compositionHeight = newCompositionHeight;
+				_forceSingleColumn = newForceSingleColumn;
+				
+				_inputColumnWidth = newColumnWidth;
+				_inputColumnGap = newColumnGap;
+				_inputColumnCount = newColumnCount;
+			}
+		}
+
+		/** Compute the actual columns based on the input values @private */
+		public function computeColumns():void
+		{
+			if (!_inputsChanged)
+				return;
+				
+			// Recalculate all the column settings. Returns true if settings have changed as a result.
+			// See http://www.w3.org/TR/2005/WD-css3-multicol-20051215/#the-number
+			var newColumnGap:Number;
+			var newColumnCount:int;
+			var newColumnWidth:Number;
+			
+			// calculate the width to divy the columns up among
+			var totalColumnWidth:Number = _blockProgression == BlockProgression.RL ? _compositionHeight : _compositionWidth;
+			// inset to use
+			var newColumnInset:Number   = _blockProgression == BlockProgression.RL ? _paddingTop + _paddingBottom : _paddingLeft + _paddingRight;
+				
+			totalColumnWidth = (totalColumnWidth > newColumnInset && !isNaN(totalColumnWidth)) ? totalColumnWidth - newColumnInset : 0;
+			
+			// columnCount is auto && columnWidth is auto || 0 --> one column
+			if (_forceSingleColumn)
+			{
+				// This case deviates from the spec.  Spec is no columns.  
+				// TextLayout does either one auto full width column or a zero width column
+				newColumnCount = 1;
+				newColumnWidth = totalColumnWidth; 
+				newColumnGap = 0;
+			}
+			else
+			{
+				newColumnGap   = _inputColumnGap;
+				
+				if (_inputColumnWidth == FormatValue.AUTO)		// auto
+				{
+					newColumnCount = Number(_inputColumnCount);
+					// Column width is not specified, we'll use columnCount and columnGap to figure it out
+					if ((newColumnCount-1)*newColumnGap < totalColumnWidth)
+					{
+						newColumnWidth = (totalColumnWidth - (newColumnCount-1)*newColumnGap) / newColumnCount;
+					}
+					else if (newColumnGap > totalColumnWidth)
+					{
+						newColumnCount = 1;
+						newColumnWidth = totalColumnWidth;
+						newColumnGap = 0;
+					}
+					else
+					{
+						newColumnCount = Math.floor(totalColumnWidth/newColumnGap);
+						newColumnWidth = (totalColumnWidth-(newColumnCount-1)*newColumnGap)/newColumnCount;
+						// newColumnGap = newColumnCount == 1 ? 0 : (totalColumnWidth - newColumnWidth*newColumnCount) / (newColumnCount-1);
+					}
+				}
+				else if (_inputColumnCount == FormatValue.AUTO)	// auto
+				{
+					newColumnWidth = Number(_inputColumnWidth);
+					if (newColumnWidth >= totalColumnWidth)
+					{
+						newColumnCount = 1;
+						newColumnWidth = totalColumnWidth;
+						newColumnGap   = 0;
+					}
+					else
+					{
+						newColumnCount = Math.floor((totalColumnWidth+newColumnGap)/(newColumnWidth+newColumnGap));
+						newColumnWidth = ((totalColumnWidth+newColumnGap)/newColumnCount) - newColumnGap;
+					}
+				}
+				else
+				{
+					newColumnCount = Number(_inputColumnCount);
+					newColumnWidth = Number(_inputColumnWidth);
+					if (newColumnCount*newColumnWidth+(newColumnCount-1)*newColumnGap <= totalColumnWidth)
+					{
+						// done
+					}
+					else if (newColumnWidth >= totalColumnWidth)
+					{
+						newColumnCount = 1;
+						newColumnGap = 0;
+						// use newColumnWidth
+					}
+					else
+					{
+						newColumnCount = Math.floor( (totalColumnWidth+newColumnGap) / (newColumnWidth+newColumnGap) );
+						newColumnWidth = ((totalColumnWidth+newColumnGap) / newColumnCount) - newColumnGap;
+					}
+				}
+			}
+				
+			_columnWidth = newColumnWidth;
+			_columnCount = newColumnCount;
+			_columnGap = newColumnGap;
+			_inset = newColumnInset;			
+	
+			// setup these values for each case
+			var xPos:Number;
+			var yPos:Number;
+			var delX:Number;
+			var delY:Number;
+			var colH:Number;
+			var colW:Number;
+			
+			// scratch vars
+			var insetHeight:Number;
+			
+			// TODO: USE DIRECTION!!!
+			if (_blockProgression == BlockProgression.TB)
+			{
+				if (_columnDirection == Direction.LTR)
+				{
+					xPos = _paddingLeft;
+					delX = _columnWidth + _columnGap;
+					colW = _columnWidth;
+				}
+				else
+				{
+					CONFIG::debug { assert(_columnDirection == Direction.RTL,"bad columndirection in ColumnState.computeColumns"); }
+					xPos = isNaN(_compositionWidth) ? _paddingLeft : _compositionWidth-_paddingRight-_columnWidth;
+					delX = -(_columnWidth + _columnGap);
+					colW = _columnWidth;
+				}
+				yPos = _paddingTop;
+				delY = 0;
+				insetHeight = _paddingTop + _paddingBottom;
+				colH = (_compositionHeight > insetHeight && !isNaN(_compositionHeight)) ? (_compositionHeight - insetHeight) : 0;
+			}
+			else if (_blockProgression == BlockProgression.RL)
+			{
+				xPos = isNaN(_compositionWidth) ? -_paddingRight : _paddingLeft -_compositionWidth;
+				yPos = _paddingTop;
+				delX = 0;
+				delY = _columnWidth + _columnGap;
+				insetHeight = _paddingLeft + _paddingRight;
+				colW = (_compositionWidth > insetHeight) ? (_compositionWidth - insetHeight) : 0;
+				colH = _columnWidth;
+			}
+			
+			// make colW and colH just off zero so that we don't get empties
+			if (colW == 0)
+			{
+				colW = Twips.ONE_TWIP;	// MINIMUM VALUE OF ONE TWIP
+				if (_blockProgression == BlockProgression.RL)
+					xPos -= colW;
+			}
+			if (colH == 0)
+				colH = Twips.ONE_TWIP;	// MINIMUM VALUE OF ONE TWIP
+			
+			if (_columnCount == 1)
+			{
+				_singleColumn = new Rectangle(xPos, yPos, colW, colH);
+				_columnArray = null;
+			}
+			else if (_columnCount == 0)
+			{
+				_singleColumn = null;
+				_columnArray = null;
+			}
+			else
+			{
+				if (_columnArray)
+					_columnArray.splice(0);
+				else
+					_columnArray = new Array();
+				for (var i:int = 0; i < _columnCount; ++i)
+				{
+					_columnArray.push(new Rectangle(xPos, yPos, colW, colH));
+					xPos += delX;
+					yPos += delY;
+				}
+			}	
+		}
+	}
+		
+
+} // end package


[20/42] flex-asjs git commit: And here’s TLF…

Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ContainerFormattedElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ContainerFormattedElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ContainerFormattedElement.as
new file mode 100644
index 0000000..3a0d83e
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ContainerFormattedElement.as
@@ -0,0 +1,90 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements {
+	import org.apache.flex.textLayout.compose.IFlowComposer;
+	CONFIG::debug{
+		import org.apache.flex.textLayout.container.IContainerController;
+	}
+	
+
+	/** 
+	* ContainerFormattedElement is the root class for all container-level block elements, such as DivElement
+	* and TextFlow objects. Container-level block elements are grouping elements for other FlowElement objects.
+	*
+	* @playerversion Flash 10
+	* @playerversion AIR 1.5
+	* @langversion 3.0
+	*
+	* @see DivElement
+	* @see TextFlow
+	*/	
+	public class ContainerFormattedElement extends ParagraphFormattedElement implements IContainerFormattedElement
+	{
+		override public function get className():String
+		{
+			return "ContainerFormattedElement";
+		}
+		/** @private */
+		public function get flowComposer():IFlowComposer
+		{ 
+			// TODO: this is here for legacy purposes.  What we really want to do is determine if a given element has its own physical representation
+			// That used to be the containerController and may be again.  This is all intermediate for now.  Reinvestigate when Tables are enabled and Div's with containers are implemented.
+			return null; 
+		}
+		
+		/** @private */
+		public override function formatChanged(notifyModelChanged:Boolean = true):void
+		{
+			super.formatChanged(notifyModelChanged);
+			// The associated container, if there is one, inherits its container
+			// attributes from here. So we need to tell it that these attributes
+			// have changed.
+			if (flowComposer)
+			{
+				for (var idx:int = 0; idx < flowComposer.numControllers; idx++)
+					flowComposer.getControllerAt(idx).formatChanged();
+			}
+		}
+		
+		/** @private */
+		public function preCompose():void
+		{ return; }
+		
+		/** @private */
+		CONFIG::debug public override function debugCheckFlowElement(depth:int = 0, extraData:String = ""):int
+		{
+			// debugging function that asserts if the flow element tree is in an invalid state
+			if (flowComposer && flowComposer.numControllers)
+			{
+				var controller:IContainerController = flowComposer.getControllerAt(0);
+				extraData = getDebugIdentity(controller.container)+" b:"+controller.absoluteStart+" l:" +controller.textLength+extraData;
+				extraData = extraData+" w:"+controller.compositionWidth+" h:"+controller.compositionHeight;
+			}
+			return super.debugCheckFlowElement(depth,extraData);
+		}
+		
+		
+		/** @private */
+		public override function normalizeRange(normalizeStart:uint,normalizeEnd:uint):void
+		{
+			super.normalizeRange(normalizeStart,normalizeEnd);
+			ElementHelper.normalizeContainerFormatRange(this);
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/DivElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/DivElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/DivElement.as
new file mode 100644
index 0000000..cb0e451
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/DivElement.as
@@ -0,0 +1,49 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+
+
+	
+	/** 
+	 * The DivElement class defines an element for grouping paragraphs (ParagraphElement objects). If you want a group of paragraphs
+	 * to share the same formatting attributes, you can group them in a DivElement object and apply the attributes to it. The paragraphs
+	 * will inherit the attributes from the DivElement object.
+	 * 
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 *
+	 * @see ParagraphElement
+	 * @see TextFlow
+	 */
+	public final class DivElement extends ContainerFormattedElement implements IDivElement
+	{	
+		override public function get className():String{
+			return "DivElement";
+		}
+		/** @private */
+		override protected function get abstract():Boolean
+		{ return false; }
+		
+		/** @private */
+		public override function get defaultTypeName():String
+		{ return "div"; }		
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ElementConstants.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ElementConstants.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ElementConstants.as
new file mode 100644
index 0000000..15db3ea
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ElementConstants.as
@@ -0,0 +1,27 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	public class ElementConstants
+	{
+				/** @private */
+		public static const kParagraphTerminator:String = '\u2029';
+		
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ElementHelper.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ElementHelper.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ElementHelper.as
new file mode 100644
index 0000000..235cf7b
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/ElementHelper.as
@@ -0,0 +1,136 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	import org.apache.flex.reflection.getQualifiedClassName;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.factory.ITLFFactory;
+	import org.apache.flex.textLayout.factory.TLFFactory;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	
+	public class ElementHelper
+	{
+		static public function normalizeContainerFormatRange(container:IContainerFormattedElement):void
+		{
+			// is this an absolutely element?
+			if (container.numChildren == 0)
+			{
+				var p:IParagraphElement = ElementHelper.getParagraph();
+				if (container.canOwnFlowElement(p))
+				{
+					p.replaceChildren(0,0,ElementHelper.getSpan());
+					container.replaceChildren(0,0,p);	
+					CONFIG::debug { assert(container.textLength == 1,"bad textlength"); }
+					p.normalizeRange(0,p.textLength);	
+				}
+			}	
+		}
+		static public function normalizeSubParagraphRange(range:ISubParagraphGroupElementBase):void
+		{
+						// empty subparagraphgroups not allowed after normalize
+			if (range.numChildren == 0 && range.parent != null)
+			{
+				var s:SpanElement = new SpanElement();
+				range.replaceChildren(0,0,s);
+				s.normalizeRange(0,s.textLength);
+			}
+			
+		}
+
+
+		public static function getDefaultTextFlow(factory:ITLFFactory=null):ITextFlow
+		{
+			if(!factory)
+				factory = TLFFactory.defaultTLFFactory;
+			return new TextFlow(factory);
+		}
+		public static function getTerminator(para:IParagraphElement,newLeaf:IFlowElement):ISpanElement
+		{
+			var s:SpanElement = new SpanElement();
+			s.format = newLeaf ? newLeaf.format : para.terminatorSpan.format;
+			s.addParaTerminator();
+			return s;
+		}
+		public static function getList():IListElement
+		{
+			return new ListElement();
+		}
+		public static function getListItem():IListItemElement
+		{
+			return new ListItemElement();
+		}
+		public static function getParagraph():IParagraphElement
+		{
+			var p:IParagraphElement = new ParagraphElement();
+			p.replaceChildren(0, 0, new SpanElement());
+			p.normalizeRange(0, p.textLength);
+			return p;
+		}
+		public static function getSpan():ISpanElement
+		{
+			return new SpanElement();
+		}
+		public static function getLink():ILinkElement
+		{
+			return new LinkElement();
+		}
+		public static function getTCY():ITCYElement
+		{
+			return new TCYElement();
+		}
+		public static function getInline():IInlineGraphicElement
+		{
+			return new InlineGraphicElement();
+		}
+		public static function getTableCell():ITableCellElement
+		{
+			return new TableCellElement();
+		}
+		public static function getTableRow(format:ITextLayoutFormat=null):ITableRowElement
+		{
+			return new TableRowElement(format);
+		}
+		public static function getSpanText(children:Array):String
+		{
+			var str:String = "";
+			var len:int = children.length;
+			for(var i:int=0;i<len;i++)
+			{
+				var elem:Object = children[i];
+				if (elem is String)
+					str += elem as String;
+				else if (elem is Number)	// TODO: remove the Number else if when we can test with the most recent compilers.  The [RichTextContent] metadata fixes the issue
+					str += elem.toString();
+				else if (elem is BreakElement)
+					str += String.fromCharCode(0x2028);
+				else if (elem is TabElement)
+				{
+					// Add a placeholder (from Unicode private use area) instead of '\t' because the latter is 
+					// stripped during white space collapse. After white space collapse, we will change the placeholder
+					// to '\t' 
+					str += String.fromCharCode(0xE000);
+				}	
+				else if (elem != null)
+					throw new TypeError(GlobalSettings.resourceStringFunction("badMXMLChildrenArgument",[ getQualifiedClassName(elem) ]));	// NO PMD
+					
+			}
+			return str;
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/FlowElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/FlowElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/FlowElement.as
new file mode 100644
index 0000000..5bafe7e
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/FlowElement.as
@@ -0,0 +1,1454 @@
+// //////////////////////////////////////////////////////////////////////////////
+//
+// 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
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// //////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.elements
+{
+	import org.apache.flex.events.IEventDispatcher;
+	import org.apache.flex.reflection.getDefinitionByName;
+	import org.apache.flex.reflection.getQualifiedClassName;
+	import org.apache.flex.textLayout.compose.IFlowComposer;
+	import org.apache.flex.textLayout.container.IContainerController;
+	import org.apache.flex.textLayout.debug.Debugging;
+	import org.apache.flex.textLayout.debug.assert;
+	import org.apache.flex.textLayout.events.ModelChange;
+	import org.apache.flex.textLayout.formats.FormatValue;
+	import org.apache.flex.textLayout.formats.ITextLayoutFormat;
+	import org.apache.flex.textLayout.formats.TextLayoutFormat;
+	import org.apache.flex.textLayout.formats.TextLayoutFormatBase;
+	import org.apache.flex.textLayout.property.PropertyUtil;
+	import org.apache.flex.textLayout.utils.CreateTLFUtil;
+	import org.apache.flex.utils.ObjectMap;
+
+	[IMXMLObject]
+	/**
+	 * The text in a flow is stored in tree form with the elements of the tree representing logical
+	 * divisions within the text. The FlowElement class is the abstract base class of all the objects in this tree.
+	 * FlowElement objects represent paragraphs, spans of text within paragraphs, and
+	 * groups of paragraphs.
+	 *
+	 * <p>The root of a composable FlowElement tree is always a TextFlow object. Leaf elements of the tree are always 
+	 * subclasses of the FlowLeafElement class. All leaves arranged in a composable TextFlow have a ParagraphElement ancestor.
+	 * </p> 
+	 *
+	 * <p>You cannot create a FlowElement object directly. Invoking <code>new FlowElement()</code> throws an error 
+	 * exception.</p>
+	 *
+	 * @playerversion Flash 10
+	 * @playerversion AIR 1.5
+	 * @langversion 3.0
+	 * 
+	 * @see IFlowGroupElement
+	 * @see FlowLeafElement
+	 * @see InlineGraphicElement
+	 * @see ParagraphElement
+	 * @see SpanElement
+	 * @see TextFlow
+	 */
+	public class FlowElement extends TextLayoutFormatBase implements IFlowElement
+	{
+		/** every FlowElement has at most one parent */
+		private var _parent:IFlowGroupElement;
+		/** @private computed formats applied to the element */
+		protected var _computedFormat:TextLayoutFormat;
+		/** start, _start of element, relative to parent; tlf_internal to eliminate getter calls  */
+		private var _parentRelativeStart:int = 0;
+		/** _textLength (number of chars) in the element, including child content; tlf_internal to eliminate getter calls */
+		private var _textLength:int = 0;
+
+		/** Base class - invoking <code>new FlowElement()</code> throws an error exception.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function FlowElement()
+		{
+			// not a valid FlowElement class
+			if (abstract)
+				throw new Error(GlobalSettings.resourceStringFunction("invalidFlowElementConstruct"));
+		}
+
+		public function get className():String
+		{
+			return "FlowElement";
+		}
+
+		/** Called for MXML objects after the implementing object has been created and all component properties specified on the MXML tag have been initialized. 
+		 * @param document The MXML document that created the object.
+		 * @param id The identifier used by document to refer to this object.
+		 **/
+		public function initialized(document:Object, id:String):void
+		{
+			this.id = id;
+		}
+
+		/** Returns true if the class is an abstract base class,
+		 * false if its OK to construct. Attempting to instantiate an
+		 * abstract FlowElement class will cause an exception.
+		 * @return Boolean 	true if this is an abstract class
+		 * @private
+		 */
+		protected function get abstract():Boolean
+		{
+			return true;
+		}
+
+		/** Allows you to read and write user styles on a FlowElement object.  Note that reading this property
+		 * makes a copy of the userStyles set in the format of this element. 
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 */
+		public function get userStyles():Object
+		{
+			return _format ? _format.userStyles : null;
+		}
+
+		public function set userStyles(styles:Object):void
+		{
+			var val:String;
+			// clear the existing userstyles
+			for (val in userStyles)
+				this.setStyle(val, undefined);
+
+			// set the new ones
+			for (val in styles)
+			{
+				if (!TextLayoutFormat.description.hasOwnProperty(val))
+					this.setStyle(val, styles[val]);
+			}
+		}
+
+		public function setBorderWidth(width:Number):void
+		{
+			this.borderBottomWidth = width;
+			this.borderLeftWidth = width;
+			this.borderRightWidth = width;
+			this.borderTopWidth = width;
+		}
+
+		public function setBorderColor(color:uint):void
+		{
+			this.borderBottomColor = color;
+			this.borderLeftColor = color;
+			this.borderRightColor = color;
+			this.borderTopColor = color;
+		}
+
+		/** Returns the <code>coreStyles</code> on this FlowElement.  Note that the getter makes a copy of the core 
+		 * styles dictionary. The coreStyles object encapsulates the formats that are defined by TextLayoutFormat and are in TextLayoutFormat.description. The
+		 * <code>coreStyles</code> object consists of an array of <em>stylename-value</em> pairs.
+		 * 
+		 * @see org.apache.flex.textLayout.formats.TextLayoutFormat
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get coreStyles():Object
+		{
+			return _format ? _format.coreStyles : null;
+		}
+
+		/** Returns the styles on this FlowElement.  Note that the getter makes a copy of the  
+		 * styles dictionary. The returned object encapsulates all styles set in the format property including core and user styles. The
+		 * returned object consists of an array of <em>stylename-value</em> pairs.
+		 * 
+		 * @see org.apache.flex.textLayout.formats.TextLayoutFormat
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get styles():Object
+		{
+			return _format ? _format.styles : null;
+		}
+
+		/** @private */
+		public function setStylesInternal(styles:Object):void
+		{
+			if (styles)
+				writableTextLayoutFormat().setStyles(PropertyUtil.shallowCopy(styles), false);
+			else if (_format)
+				_format.clearStyles();
+
+			formatChanged();
+		}
+
+		/** Compare the userStyles of this with otherElement's userStyles. 
+		 *
+		 * @param otherElement the FlowElement object with which to compare user styles
+		 *
+		 * @return 	true if the user styles are equal; false otherwise.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * 
+		 * @see #getStyle()
+		 * @see #setStyle()
+		 * @see #userStyles
+		 */
+		public function equalUserStyles(otherElement:IFlowElement):Boolean
+		{
+			return PropertyUtil.equalStyles(this.userStyles, otherElement.userStyles, null);
+		}
+
+		/** @private Compare the styles of two elements for merging.  Return true if they can be merged. */
+		public function equalStylesForMerge(elem:FlowElement):Boolean
+		{
+			return this.id == elem.id && this.typeName == elem.typeName && TextLayoutFormat.isEqual(elem.format, format);
+		}
+
+		/**
+		 * Makes a copy of this FlowElement object, copying the content between two specified character positions.
+		 * It returns the copy as a new FlowElement object. Unlike <code>deepCopy()</code>, <code>shallowCopy()</code> does
+		 * not copy any of the children of this FlowElement object. 
+		 * 
+		 * <p>With no arguments, <code>shallowCopy()</code> defaults to copying all of the content.</p>
+		 *
+		 * @param relativeStart	The relative text position of the first character to copy. First position is 0.
+		 * @param relativeEnd	The relative text position of the last character to copy. A value of -1 indicates copy to end.
+		 *
+		 * @return 	the object created by the copy operation.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 *
+		 * @see #deepCopy()
+		 */
+		public function shallowCopy(relativeStart:int = 0, relativeEnd:int = -1):IFlowElement
+		{
+			var retFlow:FlowElement = new (getDefinitionByName(getQualifiedClassName(this)) as Class);
+			if (_format != null)
+				retFlow._format = new FlowValueHolder(_format);
+
+			CONFIG::debug
+			{
+				assert(retFlow.styleName == styleName, "Failed top copy styleName"); }
+			CONFIG::debug
+			{
+				assert(retFlow.typeName == typeName, "Failed top copy typeName"); }
+			CONFIG::debug
+			{
+				assert(retFlow.id == id, "Failed top copy id"); }
+
+			return retFlow;
+		}
+
+		/**
+		 * Makes a deep copy of this FlowElement object, including any children, copying the content between the two specified
+		 * character positions and returning the copy as a FlowElement object.
+		 * 
+		 * <p>With no arguments, <code>deepCopy()</code> defaults to copying the entire element.</p>
+		 * 
+		 * @param relativeStart	relative text position of the first character to copy. First position is 0.
+		 * @param relativeEnd	relative text position of the last character to copy. A value of -1 indicates copy to end.
+		 *
+		 * @return 	the object created by the deep copy operation.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * 
+		 * @see #shallowCopy()
+		 */
+		public function deepCopy(relativeStart:int = 0, relativeEnd:int = -1):IFlowElement
+		{
+			if (relativeEnd == -1)
+				relativeEnd = _textLength;
+
+			return shallowCopy(relativeStart, relativeEnd);
+		}
+
+		/** 
+		 * Gets the specified range of text from a flow element.
+		 * 
+		 * @param relativeStart The starting position of the range of text to be retrieved, relative to the start of the FlowElement
+		 * @param relativeEnd The ending position of the range of text to be retrieved, relative to the start of the FlowElement, -1 for up to the end of the element
+		 * @param paragraphSeparator character to put between paragraphs
+		 * 
+		 * @return The requested text.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function getText(relativeStart:int = 0, relativeEnd:int = -1, paragraphSeparator:String = "\n"):String
+		{
+			return "";
+		}
+
+		/** 
+		 * Splits this FlowElement object at the position specified by the <code>relativePosition</code> parameter, which is
+		 * a relative position in the text for this element. This method splits only SpanElement and IFlowGroupElement 
+		 * objects.
+		 *
+		 * @param relativePosition the position at which to split the content of the original object, with the first position being 0.
+		 * 
+		 * @return	the new object, which contains the content of the original object, starting at the specified position.
+		 *
+		 * @throws RangeError if <code>relativePosition</code> is greater than <code>textLength</code>, or less than 0.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function splitAtPosition(relativePosition:int):IFlowElement
+		{
+			if ((relativePosition < 0) || (relativePosition > _textLength))
+				throw RangeError(GlobalSettings.resourceStringFunction("invalidSplitAtPosition"));
+			return this;
+		}
+
+		/** @private Set to indicate the element may be "bound" in Flex - only used on FlowLeafElement and SubParagraphBlock elements. */
+		public function get bindableElement():Boolean
+		{
+			return getPrivateStyle("bindable") == true;
+		}
+
+		/** @private */
+		public function set bindableElement(value:Boolean):void
+		{
+			setPrivateStyle("bindable", value);
+		}
+
+		/** Merge flow element into previous flow element if possible.
+		 * @private
+		 * Return true--> did the merge
+		 */
+		public function mergeToPreviousIfPossible():Boolean
+		{
+			return false;
+		}
+
+		/** @private 
+		 * Create and initialize the FTE data structure that corresponds to the FlowElement
+		 */
+		public function createContentElement():void
+		{
+			// overridden in the base class -- we should not get here
+			CONFIG::debug
+			{
+				assert(false, "invalid call to createContentElement"); }
+		}
+
+		/** @private 
+		 * Release the FTE data structure that corresponds to the FlowElement, so it can be gc'ed
+		 */
+		public function releaseContentElement():void
+		{
+			// overridden in the base class -- we should not get here
+			CONFIG::debug
+			{
+				assert(false, "invalid call to createContentElement"); }
+		}
+
+		/** Returns the parent of this FlowElement object. Every FlowElement has at most one parent.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get parent():IFlowGroupElement
+		{
+			// must be final to prevent overrides for safe internal access to _parent
+			return _parent;
+		}
+
+		/** @private parent setter. */
+		public function setParentAndRelativeStart(newParent:IFlowGroupElement, newStart:int):void
+		{
+			_parent = newParent;
+			_parentRelativeStart = newStart;
+			attributesChanged(false);
+		}
+
+		/** @private Used when the textBlock.content is already correctly configured. */
+		public function setParentAndRelativeStartOnly(newParent:IFlowGroupElement, newStart:int):void
+		{
+			_parent = newParent;
+			_parentRelativeStart = newStart;
+		}
+
+		/**
+		 * Returns the total length of text owned by this FlowElement object and its children.  If an element has no text, the 
+		 * value of <code>textLength</code> is usually zero. 
+		 * 
+		 * <p>ParagraphElement objects have a final span with a paragraph terminator character for the last 
+		 * SpanElement object.The paragraph terminator is included in the value of the <code>textLength</code> of that 
+		 * SpanElement object and all its parents.  It is not included in <code>text</code> property of the SpanElement
+		 * object.</p>
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * @see #textLength
+		 */
+		public function get textLength():int
+		{
+			return _textLength;
+		}
+
+		/** @private textLength setter.  */
+		public function setTextLength(newLength:int):void
+		{
+			_textLength = newLength;
+		}
+
+		/** Returns the relative start of this FlowElement object in the parent. If parent is null, this value is always zero.  
+		 * If parent is not null, the value is the sum of the text lengths of all previous siblings.
+		 *
+		 * @return offset
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 * @see #textLength
+		 */
+		public function get parentRelativeStart():int
+		{
+			// make final to prevent overrides and enable direct internal read access
+			return _parentRelativeStart;
+		}
+
+		/** @private start setter. */
+		public function setParentRelativeStart(newStart:int):void
+		{
+			_parentRelativeStart = newStart;
+		}
+
+		/** Returns the relative end of this FlowElement object in the parent. If the parent is null this is always equal to <code>textLength</code>.  If 
+		 * the parent is not null, the value is the sum of the text lengths of this and all previous siblings, which is effectively
+		 * the first character in the next FlowElement object.
+		 *
+		 * @return offset
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * @see IFlowGroupElement
+		 * @see #textLength
+		 */
+		public function get parentRelativeEnd():int
+		{
+			return _parentRelativeStart + _textLength;
+		}
+		/**
+		 * Tag for the item, used for debugging.
+		 */
+		CONFIG::debug
+		public function get name():String
+		{
+			return getQualifiedClassName(this);
+		}
+
+		/** Returns the ContainerFormattedElement that specifies its containers for filling. This ContainerFormattedElement
+		 * object has its own columns and can control ColumnDirection and BlockProgression. 
+		 *
+		 * @return 	the ancestor, with its container, of this FlowElement object.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 * @private
+		 */
+		public function getAncestorWithContainer():IContainerFormattedElement
+		{
+			var elem:IFlowElement = this;
+			while (elem)
+			{
+				var contElement:IContainerFormattedElement = elem as IContainerFormattedElement;
+				if (contElement)
+				{
+					if (!contElement.parent || contElement.flowComposer)
+						return contElement;
+				}
+				elem = elem.parent;
+			}
+			return null;
+		}
+
+		/**
+		 * @private
+		 * Generic mechanism for fetching private data from the element.
+		 * @param styleName	name of the property
+		 */
+		public function getPrivateStyle(styleName:String):*
+		{
+			return _format ? _format.getPrivateData(styleName) : undefined;
+		}
+
+		/**
+		 * @private
+		 * Generic mechanism for adding private data to the element.
+		 * @param styleName	name of the property
+		 * @param val value of the property
+		 */
+		public function setPrivateStyle(styleName:String, val:*):void
+		{
+			if (getPrivateStyle(styleName) != val)
+			{
+				writableTextLayoutFormat().setPrivateData(styleName, val);
+				modelChanged(ModelChange.STYLE_SELECTOR_CHANGED, this, 0, this._textLength);
+			}
+		}
+
+		private static const idString:String = "id";
+
+		/**
+		 * Assigns an identifying name to the element, making it possible to set a style for the element
+		 * by referencing the <code>id</code>. For example, the following line sets the color for
+		 * a SpanElement object that has an id of span1:
+		 *
+		 * <listing version="3.0" >
+		 * textFlow.getElementByID("span1").setStyle("color", 0xFF0000);
+		 * </listing>
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * @see TextFlow#getElementByID()
+		 */
+		public function get id():String
+		{
+			return getPrivateStyle(idString);
+		}
+
+		public function set id(val:String):void
+		{
+			return setPrivateStyle(idString, val);
+		}
+
+		private static const typeNameString:String = "typeName";
+
+		/**
+		 * Each FlowElement has a <code>typeName</code>.  <code>typeName</code> defaults to the string the <code>textLayoutFormat</code> TextConverter uses.  This API
+		 * can be used to set a different <code>typeName</code> to a <code>FlowElement</code>.  Typically this is done to support <code>type</code> selectors in CSS.  
+		 * 
+		 * <p>See the <code>TEXT_FIELD_HTML_FORMAT</code> documentation for how this used..</p>
+		 * 
+		 * @see org.apache.flex.textLayout.conversion.TextConverter
+		 * @see org.apache.flex.textLayout.conversion.TextConverter#TEXT_FIELD_HTML_FORMAT
+		 * @see org.apache.flex.textLayout.conversion.IHTMLImporter
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 */
+		public function get typeName():String
+		{
+			var typeName:String = getPrivateStyle(typeNameString);
+			return typeName ? typeName : defaultTypeName;
+		}
+
+		public function set typeName(val:String):void
+		{
+			// extra testing here to avoid saving defaultTypeName in privateStyles
+			if (val != typeName)
+				setPrivateStyle(typeNameString, val == defaultTypeName ? undefined : val);
+		}
+
+		/** @private */
+		public function get defaultTypeName():String
+		{
+			return null;
+		}
+
+		private static const impliedElementString:String = "impliedElement";
+
+		/** @private */
+		public function get impliedElement():Boolean
+		{
+			return getPrivateStyle(impliedElementString) !== undefined;
+		}
+
+		/** @private */
+		public function set impliedElement(value:Boolean):void
+		{
+			// CONFIG::debug{assert(value === true || value === undefined, "Bad value to FlowElement.impliedElement"); }
+			setPrivateStyle(impliedElementString, value);
+		}
+
+		// ****************************************
+		// Begin TLFFormat Related code
+		// ****************************************
+		// include "../formats/TextLayoutFormatInc.as";
+		/** This gets called when an element has changed its attributes. This may happen because an
+		 * ancestor element changed it attributes.
+		 * @private 
+		 */
+		public override function formatChanged(notifyModelChanged:Boolean = true):void
+		{
+			if (notifyModelChanged)
+				modelChanged(ModelChange.TEXTLAYOUT_FORMAT_CHANGED, this, 0, _textLength);
+			// require recompute of computedFormat
+			_computedFormat = null;
+		}
+
+		/** This gets called when an element has changed its style selection related attributes. This may happen because an
+		 * ancestor element changed it attributes.
+		 * @private 
+		 */
+		public override function styleSelectorChanged():void
+		{
+			modelChanged(ModelChange.STYLE_SELECTOR_CHANGED, this, 0, this._textLength);
+			_computedFormat = null;
+		}
+
+		/** 
+		 * Concatenates tlf attributes with any other tlf attributes
+		 * 
+		 * Return the concatenated result
+		 * 
+		 * @private
+		 */
+		public function get formatForCascade():ITextLayoutFormat
+		{
+			var tf:ITextFlow = getTextFlow();
+			if (tf)
+			{
+				var elemStyle:TextLayoutFormat = tf.getTextLayoutFormatStyle(this);
+				var explicitStyle:TextLayoutFormat = tf.getExplicitStyle(this);
+
+				if (elemStyle || explicitStyle)
+				{
+					var localFormat:ITextLayoutFormat = format;
+					var rslt:TextLayoutFormat = new TextLayoutFormat();
+					if (elemStyle)
+						rslt.apply(elemStyle);
+					if (localFormat)
+						rslt.apply(localFormat);
+					if (explicitStyle)
+						rslt.apply(explicitStyle);
+					return rslt;
+				}
+			}
+			return _format;
+		}
+
+		/** @private  Shared scratch element for use in computedFormat methods only */
+		static public var _scratchTextLayoutFormat:TextLayoutFormat = new TextLayoutFormat();
+
+		/** 
+		 * Returns the computed format attributes that are in effect for this element.
+		 * Takes into account the inheritance of attributes from parent elements.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * @see org.apache.flex.textLayout.formats.ITextLayoutFormat ITextLayoutFormat
+		 */
+		public function get computedFormat():ITextLayoutFormat
+		{
+			if (_computedFormat == null)
+				_computedFormat = doComputeTextLayoutFormat();
+			return _computedFormat;
+		}
+
+		public function calculateComputedFormat():ITextLayoutFormat
+		{
+			// use the class-sppecific getter
+			return computedFormat;
+		}
+
+		/** @private */
+		public function doComputeTextLayoutFormat():TextLayoutFormat
+		{
+			var parentPrototype:TextLayoutFormat = _parent ? TextLayoutFormat(_parent.computedFormat) : null;
+			return CreateTLFUtil.createTLF(formatForCascade, parentPrototype);
+		}
+
+		// ****************************************
+		// End CharacterFormat Related code
+		// ****************************************
+		/** @private */
+		public function attributesChanged(notifyModelChanged:Boolean = true):void
+		{
+			// TODO: REMOVE ME???
+			formatChanged(notifyModelChanged);
+		}
+
+		/** Returns the value of the style specified by the <code>styleProp</code> parameter, which specifies
+		 * the style name and can include any user style name. Accesses an existing span, paragraph, text flow,
+		 * or container style. Searches the parent tree if the style's value is <code>undefined</code> on a 
+		 * particular element.
+		 *
+		 * @param styleProp The name of the style whose value is to be retrieved.
+		 *
+		 * @return The value of the specified style. The type varies depending on the type of the style being
+		 * accessed. Returns <code>undefined</code> if the style is not set.
+		 * 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 *
+		 * @see #clearStyle()
+		 * @see #setStyle()
+		 * @see #userStyles
+		 */
+		override public function getStyle(styleProp:String):*
+		{
+			if (TextLayoutFormat.description.hasOwnProperty(styleProp))
+				return computedFormat.getStyle(styleProp);
+
+			var tf:ITextFlow = getTextFlow();
+			if (!tf || !tf.formatResolver)
+				return computedFormat.getStyle(styleProp);
+
+			return getUserStyleWorker(styleProp);
+		}
+
+		// { return TextLayoutFormat.description.hasOwnProperty(styleProp) ? computedFormat.getStyle(styleProp) : getUserStyleWorker(styleProp); } }
+		/** @private worker function - any styleProp */
+		public function getUserStyleWorker(styleProp:String):*
+		{
+			// CONFIG::debug { assert(TextLayoutFormat.description[styleProp] === undefined,"bad call to getUserStyleWorker"); }
+
+			if (_format != null)
+			{
+				var userStyle:* = _format.getStyle(styleProp);
+				if (userStyle !== undefined)
+					return userStyle;
+			}
+
+			var tf:ITextFlow = getTextFlow();
+			if (tf && tf.formatResolver)
+			{
+				userStyle = tf.formatResolver.resolveUserFormat(this, styleProp);
+				if (userStyle !== undefined)
+					return userStyle;
+			}
+			// TODO: does TextFlow need to ask a "psuedo parent"
+			return _parent ? _parent.getUserStyleWorker(styleProp) : undefined;
+		}
+
+		/** Sets the style specified by the <code>styleProp</code> parameter to the value specified by the
+		 * <code>newValue</code> parameter. You can set a span, paragraph, text flow, or container style, including
+		 * any user name-value pair.
+		 *
+		 * <p><strong>Note:</strong> If you assign a custom style, Text Layout Framework can import and export it but
+		 * compiled MXML cannot support it.</p>
+		 *
+		 * @param styleProp The name of the style to set.
+		 * @param newValue The value to which to set the style.
+		 *.
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 *		
+		 * @see #clearStyle()
+		 * @see #getStyle()
+		 * @see #userStyles
+		 */
+		public function setStyle(styleProp:String, newValue:*):void
+		{
+			if (TextLayoutFormat.description[styleProp])
+				this[styleProp] = newValue;
+			else
+			{
+				writableTextLayoutFormat().setStyle(styleProp, newValue);
+				formatChanged();
+			}
+		}
+
+		/** Clears the style specified by the <code>styleProp</code> parameter from this FlowElement object. Sets 
+		 * the value to <code>undefined</code>.
+		 *
+		 * @param styleProp The name of the style to clear.
+		 
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 *
+		 * @see #getStyle()
+		 * @see #setStyle()
+		 * @see #userStyles
+		 * 
+		 */
+		public function clearStyle(styleProp:String):void
+		{
+			setStyle(styleProp, undefined);
+		}
+
+		/**
+		 * Called when an element is removed. Used for container elements to run any clean up code. 
+		 **/
+		public function removed():void
+		{
+			// override in sub classes
+		}
+
+		/**
+		 * Called whenever the model is modified.  Updates the TextFlow and notifies the selection manager - if it is set.
+		 * This method has to be called while the element is still in the flow
+		 * @param changeType - type of change
+		 * @param element - the actual element that is modified
+		 * @param start - elem relative offset of start of damage
+		 * @param len - length of damage
+		 * @see flow.model.ModelChange
+		 * @private
+		 */
+		public function modelChanged(changeType:String, element:IFlowElement, changeStart:int, changeLen:int, needNormalize:Boolean = true, bumpGeneration:Boolean = true):void
+		{
+			var tf:ITextFlow = this.getTextFlow();
+			if (tf)
+				tf.processModelChanged(changeType, element, getAbsoluteStart() + changeStart, changeLen, needNormalize, bumpGeneration);
+		}
+
+		/** @private */
+		public function appendElementsForDelayedUpdate(tf:ITextFlow, changeType:String):void
+		{
+		}
+
+		/** @private */
+		public function applyDelayedElementUpdate(textFlow:ITextFlow, okToUnloadGraphics:Boolean, hasController:Boolean):void
+		{
+		}
+
+		/** @private */
+		public function getEffectivePaddingLeft():Number
+		{
+			return computedFormat.paddingLeft == FormatValue.AUTO ? 0 : computedFormat.paddingLeft;
+		}
+
+		/** @private */
+		public function getEffectivePaddingRight():Number
+		{
+			return computedFormat.paddingRight == FormatValue.AUTO ? 0 : computedFormat.paddingRight;
+		}
+
+		/** @private */
+		public function getEffectivePaddingTop():Number
+		{
+			return computedFormat.paddingTop == FormatValue.AUTO ? 0 : computedFormat.paddingTop;
+		}
+
+		/** @private */
+		public function getEffectivePaddingBottom():Number
+		{
+			return computedFormat.paddingBottom == FormatValue.AUTO ? 0 : computedFormat.paddingBottom;
+		}
+
+		/** @private */
+		public function getEffectiveBorderLeftWidth():Number
+		{
+			return computedFormat.borderLeftWidth;
+		}
+
+		/** @private */
+		public function getEffectiveBorderRightWidth():Number
+		{
+			return computedFormat.borderRightWidth;
+		}
+
+		/** @private */
+		public function getEffectiveBorderTopWidth():Number
+		{
+			return computedFormat.borderTopWidth;
+		}
+
+		/** @private */
+		public function getEffectiveBorderBottomWidth():Number
+		{
+			return computedFormat.borderBottomWidth;
+		}
+
+		/** @private */
+		public function getEffectiveMarginLeft():Number
+		{
+			return computedFormat.marginLeft;
+		}
+
+		/** @private */
+		public function getEffectiveMarginRight():Number
+		{
+			return computedFormat.marginRight;
+		}
+
+		/** @private */
+		public function getEffectiveMarginTop():Number
+		{
+			return computedFormat.marginTop;
+		}
+
+		/** @private */
+		public function getEffectiveMarginBottom():Number
+		{
+			return computedFormat.marginBottom;
+		}
+
+		// ****************************************
+		// Begin tracking property Related code
+		// ****************************************
+		/**
+		 * Sets the tracking and is synonymous with the <code>trackingRight</code> property. Specified as a number of
+		 * pixels or a percent of <code>fontSize</code>.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * @see #trackingRight
+		 */
+		public function set tracking(trackingValue:Object):void
+		{
+			trackingRight = trackingValue;
+		}
+
+		// ****************************************
+		// End tracking property Related code
+		// ****************************************
+		// ****************************************
+		// Begin import helper code
+		// ****************************************
+		/** Strips white space from the element and its children, according to the whitespaceCollaspse
+		 *  value that has been applied to the element or inherited from its parent.
+		 *  If a FlowLeafElement's attrs are set to WhiteSpaceCollapse.PRESERVE, then collapse is
+		 *  skipped.
+		 *  @see text.formats.WhiteSpaceCollapse
+		 * @private 
+		 */
+		public function applyWhiteSpaceCollapse(collapse:String):void
+		{
+			// clear it if its set
+			if (whiteSpaceCollapse !== undefined)
+				whiteSpaceCollapse = undefined;
+
+			setPrivateStyle(impliedElementString, undefined);
+		}
+
+		// ****************************************
+		// End import helper code
+		// ****************************************
+		// ****************************************
+		// Begin tree navigation code
+		// ****************************************
+		/**
+		 * Returns the start location of the element in the text flow as an absolute index. The first character in the flow
+		 * is position 0.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 * 
+		 *
+		 * @return The index of the start of the element from the start of the TextFlow object.
+		 *
+		 * @see #parentRelativeStart
+		 * @see TextFlow
+		 */
+		public function getAbsoluteStart():int
+		{
+			var rslt:int = _parentRelativeStart;
+			for (var elem:IFlowElement = _parent; elem; elem = elem.parent)
+				rslt += elem.parentRelativeStart;
+			return rslt;
+		}
+
+		/**
+		 * Returns the start of this element relative to an ancestor element. Assumes that the
+		 * ancestor element is in the parent chain. If the ancestor element is the parent, this is the
+		 * same as <code>this.parentRelativeStart</code>.  If the ancestor element is the grandparent, this is the same as 
+		 * <code>parentRelativeStart</code> plus <code>parent.parentRelativeStart</code> and so on.
+		 * 
+		 * @param ancestorElement The element from which you want to find the relative start of this element.
+		 *
+		 * @return  the offset of this element.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * 
+		 * @see #getAbsoluteStart()
+		 */
+		public function getElementRelativeStart(ancestorElement:IFlowElement):int
+		{
+			var rslt:int = _parentRelativeStart;
+			for (var elem:IFlowElement = _parent; elem && elem != ancestorElement; elem = elem.parent)
+				rslt += elem.parentRelativeStart;
+			return rslt;
+		}
+
+		/**
+		 * Climbs the text flow hierarchy to return the root TextFlow object for the element.
+		 *
+		 * @return	The root TextFlow object for this FlowElement object.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 *
+		 * @see TextFlow
+		 */
+		public function getTextFlow():ITextFlow
+		{
+			// find the root element entry and either return null or the containing textFlow
+			var elem:IFlowElement = this;
+			while (elem.parent != null)
+				elem = elem.parent;
+			return elem as ITextFlow;
+		}
+
+		/**
+		 * Returns the ParagraphElement object associated with this element. It looks up the text flow hierarchy and returns 
+		 * the first ParagraphElement object.
+		 *
+		 * @return	the ParagraphElement object that's associated with this FlowElement object.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * 
+		 * @see #getTextFlow()
+		 * @see ParagraphElement
+		 */
+		/**
+		 *  @flexjsignorecoercion org.apache.flex.textLayout.elements.IParagraphElement
+		 */
+		public function getParagraph():IParagraphElement
+		{
+			var rslt:IFlowElement = this;
+			while (rslt)
+			{
+				rslt = rslt.parent;
+				if (!rslt)
+					throw new Error("No ParagraphElement found!");
+			}
+			return rslt as IParagraphElement;
+		}
+
+		public function isInTable():Boolean
+		{
+			var tf:ITextFlow = getTextFlow();
+			return tf && tf.parentElement && tf.parentElement is ITableCellElement;
+		}
+		
+		/**
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.ITableCellElement
+		 */
+		public function getParentCellElement():ITableCellElement
+		{
+			var tf:ITextFlow = getTextFlow();
+
+			if (!tf)
+				return null;
+			if (tf.parentElement && tf.parentElement is ITableCellElement)
+				return tf.parentElement as ITableCellElement;
+			return null;
+		}
+
+		/** 
+		 * Returns the FlowElement object that contains this FlowElement object, if this element is contained within 
+		 * an element of a particular type. 
+		 * 
+		 * Returns the FlowElement it is contained in. Otherwise, it returns null.
+		 * 
+		 * @private
+		 *
+		 * @param elementType	type of element for which to check
+		 */
+		public function getParentByType(elementType:String):IFlowElement
+		{
+			var curElement:IFlowElement = _parent;
+			while (curElement)
+			{
+				if (curElement.className == elementType)
+					return curElement;
+				curElement = curElement.parent;
+			}
+			return null;
+		}
+
+		/** Returns the previous FlowElement sibling in the text flow hierarchy. 
+		 *
+		 *
+		 * @return 	the previous FlowElement object of the same type, or null if there is no previous sibling.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * @see #getNextSibling()
+		 */
+		public function getPreviousSibling():IFlowElement
+		{
+			// this can happen if FE is on the scrap and doesn't have a parent. - gak 06.25.08
+			if (!_parent)
+				return null;
+
+			var idx:int = _parent.getChildIndex(this);
+			return idx == 0 ? null : _parent.getChildAt(idx - 1);
+		}
+
+		/** Returns the next FlowElement sibling in the text flow hierarchy. 
+		 *
+		 * @return the next FlowElement object of the same type, or null if there is no sibling.
+		 *
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * @see #getPreviousSibling()
+		 */
+		public function getNextSibling():IFlowElement
+		{
+			if (!_parent)
+				return null;
+
+			var idx:int = _parent.getChildIndex(this);
+			return idx == _parent.numChildren - 1 ? null : _parent.getChildAt(idx + 1);
+		}
+
+		/** 
+		 * Returns the character at the specified position, relative to this FlowElement object. The first
+		 * character is at relative position 0.
+		 * 
+		 * @param relativePosition	The relative position of the character in this FlowElement object.
+		 * @return String containing the character.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * 
+		 * @see #getCharCodeAtPosition()
+		 */
+		public function getCharAtPosition(relativePosition:int):String
+		{
+			return null;
+		}
+
+		/** Returns the character code at the specified position, relative to this FlowElement. The first
+		 * character is at relative position 0.
+		 *
+		 * @param relativePosition 	The relative position of the character in this FlowElement object.
+		 *
+		 * @return	the Unicode value for the character at the specified position.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 *
+		 * @see #getCharAtPosition()
+		 */
+		public function getCharCodeAtPosition(relativePosition:int):int
+		{
+			var str:String = getCharAtPosition(relativePosition);
+			return str && str.length > 0 ? str.charCodeAt(0) : 0;
+		}
+
+		/** @private apply function to all elements until it says stop */
+		public function applyFunctionToElements(func:Function):Boolean
+		{
+			return func(IFlowElement);
+		}
+
+		/** @private
+		 * Gets the EventDispatcher associated with this FlowElement.  Use the functions
+		 * of EventDispatcher such as <code>setEventHandler()</code> and <code>removeEventHandler()</code> 
+		 * to capture events that happen over this FlowLeafElement object.  The
+		 * event handler that you specify will be called after this FlowElement object does
+		 * the processing it needs to do. If the FlowElement cannot dispatch events, the return
+		 * value is null.
+		 * 
+		 * Note that the event dispatcher will only dispatch FlowElementMouseEvent events.
+		 *
+		 * @playerversion Flash 10
+		 * @playerversion AIR 1.5
+		 * @langversion 3.0
+		 *
+		 * @see org.apache.flex.events.EventDispatcher
+		 * @see org.apache.flex.textLayout.events.FlowElementMouseEvent
+		 */
+		public function getEventMirror():IEventDispatcher
+		{
+			return null;
+		}
+
+		/** @private
+		 * Checks whether an event dispatcher is attached, and if so, if the event dispatcher
+		 * has any active listeners.
+		 */
+		public function hasActiveEventMirror():Boolean
+		{
+			return false;
+		}
+
+		// ****************************************
+		// End tree navigation code
+		// ****************************************
+		// ****************************************
+		// Begin tree modification support code
+		// ****************************************
+		/**
+		 * Update the FlowElement to account for text added before it.
+		 *
+		 * @param len	number of characters added (may be negative if deletion)
+		 */
+		public function updateRange(len:int):void
+		{
+			setParentRelativeStart(_parentRelativeStart + len);
+		}
+
+		/** Update the FlowElements in response to an insertion or deletion.
+		 *  The length of the element inserted to is updated, and the length of 
+		 *  each of its ancestor element. Each of the elements following siblings
+		 *  start index is updated (start index is relative to parent).
+		 * @private
+		 * @param startIdx		absolute index in flow where text was inserted
+		 * @param len			number of characters added (negative if removed)
+		 * updateLines			?? true if lines should be damaged??
+		 * @private 
+		 */
+		public function updateLengths(startIdx:int, len:int, updateLines:Boolean):void
+		{
+			setTextLength(_textLength + len);
+			var p:IFlowGroupElement = _parent;
+			if (p)
+			{
+				// update the elements following this in parent's children
+				var idx:int = p.getChildIndex(this) + 1;
+				CONFIG::debug
+				{
+					assert(idx != -1, "bad parent in FlowElement.updateLengths"); }
+
+				var pElementCount:int = p.numChildren;
+				while (idx < pElementCount)
+				{
+					var child:IFlowElement = p.getChildAt(idx++);
+					child.updateRange(len);
+				}
+
+				// go up the tree to the root and update ancestor's lengths
+				p.updateLengths(startIdx, len, updateLines);
+			}
+		}
+
+		/**
+		 *  @private 
+		 * @flexjsignorecoercion org.apache.flex.textLayout.elements.IContainerFormattedElement
+		 */
+		public function getEnclosingController(relativePos:int):IContainerController
+		{
+			// CONFIG::debug { assert(pos <= length,"getEnclosingController - bad pos"); }
+
+			var textFlow:ITextFlow = getTextFlow();
+
+			// more than likely, we are building up spans for the very first time.
+			// the container has not yet been created
+			if (textFlow == null || textFlow.flowComposer == null)
+				return null;
+
+			var curItem:IFlowElement = this;
+			while (curItem && (!(curItem is IContainerFormattedElement) || IContainerFormattedElement(curItem).flowComposer == null))
+			{
+				curItem = curItem.parent;
+			}
+
+			var flowComposer:IFlowComposer = IContainerFormattedElement(curItem).flowComposer;
+			if (!flowComposer)
+				return null;
+
+			var controllerIndex:int = IContainerFormattedElement(curItem).flowComposer.findControllerIndexAtPosition(getAbsoluteStart() + relativePos, false);
+			return controllerIndex != -1 ? flowComposer.getControllerAt(controllerIndex) : null;
+		}
+
+		/** @private */
+		public function deleteContainerText(endPos:int, deleteTotal:int):void
+		{
+			// update container counts
+
+			if (getTextFlow())		// update container lengths only for elements that are attached to the rootElement
+			{
+				var absoluteEndPos:int = getAbsoluteStart() + endPos;
+				var absStartIdx:int = absoluteEndPos - deleteTotal;
+
+				while (deleteTotal > 0)
+				{
+					var charsDeletedFromCurContainer:int;
+					var enclosingController:IContainerController = getEnclosingController(endPos - 1);
+					if (!enclosingController)
+					{
+						// The end of the deleted text may be overset, so it doesn't appear in a container.
+						// Find the last container that contains the deleted text.
+						enclosingController = getEnclosingController(endPos - deleteTotal);
+						if (enclosingController)
+						{
+							var flowComposer:IFlowComposer = enclosingController.flowComposer;
+							var myIdx:int = flowComposer.getControllerIndex(enclosingController);
+							var previousEnclosingWithContent:IContainerController = enclosingController;
+							CONFIG::debug
+							{
+								assert(myIdx >= 0, "FlowElement.deleteContainerText: bad return from getContainerControllerIndex"); }
+							while (myIdx + 1 < flowComposer.numControllers && enclosingController.absoluteStart + enclosingController.textLength < endPos)
+							{
+								enclosingController = flowComposer.getControllerAt(myIdx + 1);
+								if (enclosingController.textLength)
+								{
+									previousEnclosingWithContent = enclosingController;
+									break;
+								}
+								myIdx++;
+							}
+						}
+						if (!enclosingController || !enclosingController.textLength)
+							enclosingController = previousEnclosingWithContent;
+						if (!enclosingController)
+							break;
+					}
+					var enclosingControllerBeginningPos:int = enclosingController.absoluteStart;
+					if (absStartIdx < enclosingControllerBeginningPos)
+					{
+						charsDeletedFromCurContainer = absoluteEndPos - enclosingControllerBeginningPos + 1;
+					}
+					else if (absStartIdx < enclosingControllerBeginningPos + enclosingController.textLength)
+					{
+						charsDeletedFromCurContainer = deleteTotal;
+					}
+					// Container textFlowLength may contain fewer characters than the those to be deleted in case of overset text.
+					var containerTextLengthDelta:int = enclosingController.textLength < charsDeletedFromCurContainer ? enclosingController.textLength : charsDeletedFromCurContainer;
+					if (containerTextLengthDelta <= 0)
+						break;		// overset text is not in the last container -- we've deleted the container count, so exit
+					// working backwards - can't call setTextLength as it examines previous controllers and gets confused in the composeCompleteRatio logic
+					enclosingController.setTextLengthOnly(enclosingController.textLength - containerTextLengthDelta);
+					deleteTotal -= containerTextLengthDelta;
+					absoluteEndPos -= containerTextLengthDelta;
+					endPos -= containerTextLengthDelta;
+				}
+			}
+		}
+
+		/** @private */
+		public function normalizeRange(normalizeStart:uint, normalizeEnd:uint):void
+		{
+			// default is do nothing
+		}
+
+		/**
+		 *  Support for splitting FlowLeafElements.  Does a quick copy of _characterFormat if necessary.
+		 *  @private 
+		 *  @flexjsignorecoercion org.apache.flex.textLayout.elements.FlowValueHolder
+		 */
+		public function quickCloneTextLayoutFormat(sibling:IFlowElement):void
+		{
+			_format = sibling.format as FlowValueHolder ? new FlowValueHolder(sibling.format as FlowValueHolder) : null;
+			_computedFormat = null;
+		}
+
+		// ****************************************
+		// End tree modification support code
+		// ****************************************
+		/** @private This API supports the inputmanager */
+		public function updateForMustUseComposer(textFlow:ITextFlow):Boolean
+		{
+			return false;
+		}
+		// ****************************************
+		// Begin debug support code
+		// ****************************************
+		CONFIG::debug
+		static private var debugDictionary:ObjectMap = new ObjectMap(true);
+		CONFIG::debug
+		static private var nextKey:int = 1;
+		CONFIG::debug
+		static public function getDebugIdentity(o:Object):String
+		{
+			if (debugDictionary[o] == null)
+			{
+				var s:String = getQualifiedClassName(o);
+				if (s)
+					s = s.substr(s.lastIndexOf(":") + 1);
+				else
+					s = "";
+				debugDictionary[o] = s + "." + nextKey.toString();
+				nextKey++;
+			}
+			return debugDictionary[o];
+		}
+		/**
+		 * Check FlowElement for internal consistency.
+		 * @private
+		 * Lots of internal checks are done on FlowElements, some are dependent
+		 * on the type of element. 
+		 * @return Number of errors found
+		 */
+		CONFIG::debug
+		public function debugCheckFlowElement(depth:int = 0, extraData:String = ""):int
+		{
+			if (Debugging.verbose)
+			{
+				if (depth == 0)
+					trace("----------------------------------");
+
+				trace("FlowElement:", depth.toString(), getDebugIdentity(this), "start:", _parentRelativeStart.toString(), "length:", _textLength.toString(), extraData);
+			}
+			return 0;
+		}
+		CONFIG::debug
+		public static function elementPath(element:IFlowElement):String
+		{
+			var result:String;
+
+			if (element != null)
+			{
+				if (element.parent != null)
+					result = elementPath(element.parent) + "." + element.name + "[" + element.parent.getChildIndex(element) + "]";
+				else
+					result = element.name;
+			}
+			return result;
+		}
+		/**
+		 * debugging only - show element as string
+		 */
+		CONFIG::debug
+		public function toString():String
+		{
+			return "flowElement:" + name + " start:" + _parentRelativeStart.toString() + " absStart:" + this.getAbsoluteStart().toString() + " textLength:" + _textLength.toString();
+		}
+
+		// ****************************************
+		// End debug support code
+		// ****************************************
+		// //////////////////////////////////////////////////////////////////////
+		// BEGIN PROTOTYPING CASCADE SUPPORT
+		// //////////////////////////////////////////////////////////////////////
+		/** @private */
+	}
+}