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:41 UTC
[21/42] flex-asjs git commit: And here’s TLF…
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