Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 95F93200D17 for ; Wed, 30 Aug 2017 22:37:18 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 94DFC169EC2; Wed, 30 Aug 2017 20:37:18 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 9B819169EED for ; Wed, 30 Aug 2017 22:37:17 +0200 (CEST) Received: (qmail 81338 invoked by uid 500); 30 Aug 2017 20:37:15 -0000 Mailing-List: contact commits-help@flex.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flex.apache.org Delivered-To: mailing list commits@flex.apache.org Received: (qmail 80768 invoked by uid 99); 30 Aug 2017 20:37:15 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Aug 2017 20:37:15 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 11CA6F55BB; Wed, 30 Aug 2017 20:37:14 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: pent@apache.org To: commits@flex.apache.org Date: Wed, 30 Aug 2017 20:37:38 -0000 Message-Id: <3b9b51b18c7e4ddbbb42b74c58c23097@git.apache.org> In-Reply-To: <6c8bc2bcd1ef43ec851ec0b28a908a83@git.apache.org> References: <6c8bc2bcd1ef43ec851ec0b28a908a83@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [26/32] git commit: [flex-asjs] [refs/heads/feature/dragAndDrop] - Added missing pieces for TextBlock management Fixed bug in GroupElement.replaceElements() archived-at: Wed, 30 Aug 2017 20:37:18 -0000 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 Authored: Sun Aug 27 07:46:55 2017 +0300 Committer: Harbs 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.(); } @@ -67,6 +71,7 @@ package org.apache.flex.text.engine } public function replaceElements(beginIndex:int, endIndex:int, newElements:Vector.):Vector. { + 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.):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