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/05/03 08:28:37 UTC
[1/2] git commit: [flex-asjs] [refs/heads/tlf] - Implemented
GroupElement methods
Repository: flex-asjs
Updated Branches:
refs/heads/tlf 3ea20315c -> 495cc0cd7
Implemented GroupElement methods
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/3ec05bc1
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/3ec05bc1
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/3ec05bc1
Branch: refs/heads/tlf
Commit: 3ec05bc17121245822f857a6c75d38d367993053
Parents: 3ea2031
Author: Harbs <ha...@in-tools.com>
Authored: Wed May 3 10:30:55 2017 +0300
Committer: Harbs <ha...@in-tools.com>
Committed: Wed May 3 10:30:55 2017 +0300
----------------------------------------------------------------------
.../org/apache/flex/text/engine/GroupElement.as | 54 +++++++++++++++++---
1 file changed, 46 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3ec05bc1/frameworks/projects/Text/src/main/flex/org/apache/flex/text/engine/GroupElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Text/src/main/flex/org/apache/flex/text/engine/GroupElement.as b/frameworks/projects/Text/src/main/flex/org/apache/flex/text/engine/GroupElement.as
index 10ae494..7d6681b 100644
--- a/frameworks/projects/Text/src/main/flex/org/apache/flex/text/engine/GroupElement.as
+++ b/frameworks/projects/Text/src/main/flex/org/apache/flex/text/engine/GroupElement.as
@@ -19,30 +19,43 @@
package org.apache.flex.text.engine
{
import org.apache.flex.events.EventDispatcher;
+ import org.apache.flex.text.engine.TextElement;
public class GroupElement extends ContentElement
{
public function GroupElement(elements:Vector.<ContentElement> = null, elementFormat:ElementFormat = null, eventMirror:EventDispatcher = null, textRotation:String = "rotate0")
{
super(elementFormat, eventMirror, textRotation);
+ if(elements)
+ _elements = elements;
+ else
+ _elements = new Vector.<ContentElement>();
}
- private var _elementCount:int=0;
public function get elementCount():int
{
- return _elementCount;
+ return _elements.length;
}
-
+ private var _elements:Vector.<ContentElement>;
public function getElementAt(index:int):ContentElement
{
- return null;
+ return _elements[index];
}
public function getElementAtCharIndex(charIndex:int):ContentElement
{
+ var curIdx:int = 0;
+ var len:int = elementCount;
+ for(var i:int=0;i<len;i++)
+ {
+ curIdx += _elements[i].rawText.length;
+ if(curIdx > charIndex)
+ return _elements[i];
+ }
+
return null;
}
public function getElementIndex(element:ContentElement):int
{
- return -1;
+ return _elements.indexOf(element);
}
public function groupElements(beginIndex:int, endIndex:int):GroupElement
{
@@ -54,20 +67,45 @@ package org.apache.flex.text.engine
}
public function replaceElements(beginIndex:int, endIndex:int, newElements:Vector.<ContentElement>):Vector.<ContentElement>
{
- return null;
+ //TODO will this work correctly in Flash? -- using Array.concat with a Vector and Vector splice with an array.
+ var args:Array = [beginIndex, endIndex-beginIndex].concat(newElements);
+ _elements.splice.apply(_elements, args);
+ // _elements.splice(beginIndex,endIndex-beginIndex);
+ return _elements;
}
public function setElements(value:Vector.<ContentElement>):void
{
- //TODO
+ _elements = value;
}
public function splitTextElement(elementIndex:int, splitIndex:int):TextElement
{
- return null;
+ var elem:ContentElement = _elements[elementIndex];
+ if(!elem is TextElement)
+ throw new Error("Specified element is not a TextElement");
+ var textElem:TextElement = elem as TextElement;
+ if(splitIndex >= textElem.rawText.length)
+ throw new Error("Split index is out of range");
+ var firstText:String = textElem.rawText.substr(0,splitIndex);
+ var nextText:String = textElem.rawText.substr(splitIndex);
+ var newElem:TextElement = new TextElement(nextText,textElem.elementFormat,textElem.eventMirror,textElem.textRotation);
+ textElem.text = firstText;
+ _elements.splice(elementIndex+1,0,newElem);
+ return newElem;
}
public function ungroupElements(groupIndex:int):void
{
//TODO
}
+ override public function get rawText():String
+ {
+ var val:String = "";
+ var len:int = elementCount;
+ for(var i:int = 0;i<len;i++)
+ {
+ val += _elements[i].rawText;
+ }
+ return val;
+ }
}
}
\ No newline at end of file
[2/2] git commit: [flex-asjs] [refs/heads/tlf] - Re-added paragraph
return
Posted by ha...@apache.org.
Re-added paragraph return
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/495cc0cd
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/495cc0cd
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/495cc0cd
Branch: refs/heads/tlf
Commit: 495cc0cd7f54ca6032a98ab393c6cd829ef4056a
Parents: 3ec05bc
Author: Harbs <ha...@in-tools.com>
Authored: Wed May 3 11:28:33 2017 +0300
Committer: Harbs <ha...@in-tools.com>
Committed: Wed May 3 11:28:33 2017 +0300
----------------------------------------------------------------------
.../main/flex/org/apache/flex/textLayout/elements/SpanElement.as | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/495cc0cd/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
index 4a4a9ea..114c496 100644
--- 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
@@ -77,7 +77,7 @@ package org.apache.flex.textLayout.elements
return;
calculateComputedFormat(); // BEFORE creating the element
- _blockElement = new TextElement(text,null);
+ _blockElement = new TextElement(_text,null);
CONFIG::debug { Debugging.traceFTECall(_blockElement,null,"new TextElement()"); }
CONFIG::debug { Debugging.traceFTEAssign(_blockElement, "text", _text); }
super.createContentElement();