flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@apache.org
Subject [26/32] git commit: [flex-asjs] [refs/heads/feature/dragAndDrop] - Added missing pieces for TextBlock management Fixed bug in GroupElement.replaceElements()
Date Wed, 30 Aug 2017 20:37:38 GMT
Added missing pieces for TextBlock management
Fixed bug in GroupElement.replaceElements()


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

Branch: refs/heads/feature/dragAndDrop
Commit: f4276e0dd628a0a3a22a33d1890ea3c1e1943b5a
Parents: daca90f
Author: Harbs <harbs@in-tools.com>
Authored: Sun Aug 27 07:46:55 2017 +0300
Committer: Harbs <harbs@in-tools.com>
Committed: Sun Aug 27 07:46:55 2017 +0300

----------------------------------------------------------------------
 .../apache/flex/text/engine/ContentElement.as   | 25 ++++++++++++++++----
 .../org/apache/flex/text/engine/GroupElement.as | 21 ++++++++++++++--
 .../org/apache/flex/text/engine/ITextBlock.as   |  3 +++
 .../flex/org/apache/flex/text/html/TextBlock.as |  4 ++++
 4 files changed, 47 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f4276e0d/frameworks/projects/Text/src/main/flex/org/apache/flex/text/engine/ContentElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Text/src/main/flex/org/apache/flex/text/engine/ContentElement.as
b/frameworks/projects/Text/src/main/flex/org/apache/flex/text/engine/ContentElement.as
index 1b35305..e1358a4 100644
--- a/frameworks/projects/Text/src/main/flex/org/apache/flex/text/engine/ContentElement.as
+++ b/frameworks/projects/Text/src/main/flex/org/apache/flex/text/engine/ContentElement.as
@@ -44,10 +44,18 @@ package org.apache.flex.text.engine
 		/**
 		 * The parent
 		 */
-		public function get groupElement() : GroupElement
+		private var _groupElement:GroupElement;
+		public function get groupElement():GroupElement
 		{
+			if(_groupElement)
+				return _groupElement.getElementIndex(this) < 0 ? null : _groupElement;
 			return null;
 		}
+		public function set groupElement(value:GroupElement):void
+		{
+			_groupElement = value;
+		}
+		
 		public function get rawText() : String
 		{
 			return null;
@@ -56,13 +64,22 @@ package org.apache.flex.text.engine
 		{
 			return null;
 		}
-		public function get textBlock() : ITextBlock
+
+		private var _textBlock:ITextBlock;
+		public function get textBlock():ITextBlock
 		{
-			return null;
+			if(groupElement)
+				return groupElement.textBlock;
+			return _textBlock;
 		}
+		public function set textBlock(value:ITextBlock):void
+		{
+			_textBlock = value;
+		}
+		
 		public function get textBlockBeginIndex() : int
 		{
-			return null;
+			return textBlock ? textBlock.getRelativeStart(this) : 0;
 		}
 
 		public var textRotation : String

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f4276e0d/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 a61c97f..7d5d928 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
@@ -20,6 +20,7 @@ package org.apache.flex.text.engine
 {
 	import org.apache.flex.events.EventDispatcher;
 	import org.apache.flex.text.engine.TextElement;
+	import org.apache.flex.text.engine.GroupElement;
 	
 	public class GroupElement extends ContentElement
 	{
@@ -27,7 +28,10 @@ package org.apache.flex.text.engine
 		{
 			super(elementFormat, eventMirror, textRotation);
 			if(elements)
+			{
 				_elements = elements;
+				setElementsGroup(this);
+			}	
 			else
 				_elements = new Vector.<ContentElement>();
 		}
@@ -67,6 +71,7 @@ package org.apache.flex.text.engine
 		}
 		public function replaceElements(beginIndex:int, endIndex:int, newElements:Vector.<ContentElement>):Vector.<ContentElement>
 		{
+			setElementsGroup(null);
             COMPILE::SWF
             {
                 var args:Array = [beginIndex, endIndex-beginIndex];
@@ -79,15 +84,25 @@ package org.apache.flex.text.engine
             }
             COMPILE::JS
             {
-    			var args:Array = [beginIndex, endIndex-beginIndex].concat(newElements);
+    			var args:Array = [beginIndex, endIndex-beginIndex];
+				// don't concat null
+				if(newElements)
+					args = args.concat(newElements);
 			// _elements.splice(beginIndex,endIndex-beginIndex);
             }
-            _elements.splice.apply(_elements, args);                    
+            _elements.splice.apply(_elements, args);
+			setElementsGroup(this);
 			return _elements;
 		}
 		public function setElements(value:Vector.<ContentElement>):void
 		{
 			_elements = value;
+			setElementsGroup(this);
+		}
+		private function setElementsGroup(group:GroupElement):void
+		{
+			for(var i:int=0; i<_elements.length; i++)
+				_elements[i].groupElement = group;
 		}
 		public function splitTextElement(elementIndex:int, splitIndex:int):TextElement
 		{
@@ -101,7 +116,9 @@ package org.apache.flex.text.engine
 			var nextText:String = textElem.rawText.substr(splitIndex);
 			var newElem:TextElement = new TextElement(nextText,textElem.elementFormat,textElem.eventMirror,textElem.textRotation);
 			textElem.text = firstText;
+			newElem.groupElement = this;
 			_elements.splice(elementIndex+1,0,newElem);
+			
 			return newElem;
 		}
 		public function ungroupElements(groupIndex:int):void

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f4276e0d/frameworks/projects/Text/src/main/flex/org/apache/flex/text/engine/ITextBlock.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Text/src/main/flex/org/apache/flex/text/engine/ITextBlock.as
b/frameworks/projects/Text/src/main/flex/org/apache/flex/text/engine/ITextBlock.as
index 7f9be7c..8d51b90 100644
--- a/frameworks/projects/Text/src/main/flex/org/apache/flex/text/engine/ITextBlock.as
+++ b/frameworks/projects/Text/src/main/flex/org/apache/flex/text/engine/ITextBlock.as
@@ -19,6 +19,7 @@
 package org.apache.flex.text.engine
 {
 	import org.apache.flex.text.engine.ITextFactory;
+	import org.apache.flex.text.engine.ContentElement;
 
 	public interface ITextBlock
 	{
@@ -64,5 +65,7 @@ package org.apache.flex.text.engine
 		function releaseLineCreationData():void;
 		function releaseLines(firstLine:ITextLine, lastLine:ITextLine):void;
 
+		function getRelativeStart(element:ContentElement):int;
+
 	}
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f4276e0d/frameworks/projects/Text/src/main/flex/org/apache/flex/text/html/TextBlock.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Text/src/main/flex/org/apache/flex/text/html/TextBlock.as
b/frameworks/projects/Text/src/main/flex/org/apache/flex/text/html/TextBlock.as
index cb9cd5d..45f461a 100644
--- a/frameworks/projects/Text/src/main/flex/org/apache/flex/text/html/TextBlock.as
+++ b/frameworks/projects/Text/src/main/flex/org/apache/flex/text/html/TextBlock.as
@@ -279,6 +279,10 @@ package org.apache.flex.text.html
 		{
 			lines.length = 0;
 		}
+		public function getRelativeStart(element:ContentElement):int
+		{
+			return 0;
+		}
 
 	}
 }
\ No newline at end of file


Mime
View raw message