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 16:23:47 UTC
[6/6] git commit: [flex-asjs] [refs/heads/tlf] - Cleaned up imports
Cleaned up imports
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/19b26fe5
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/19b26fe5
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/19b26fe5
Branch: refs/heads/tlf
Commit: 19b26fe544b08dd95ddfefc0ef68a43d3ab598da
Parents: fd08d13
Author: Harbs <ha...@in-tools.com>
Authored: Thu Mar 16 18:23:39 2017 +0200
Committer: Harbs <ha...@in-tools.com>
Committed: Thu Mar 16 18:23:39 2017 +0200
----------------------------------------------------------------------
.../org/apache/flex/textLayout/CoreClasses.as | 10 +-
.../flex/textLayout/compose/FactoryComposer.as | 36 +-
.../flex/textLayout/compose/IComposeState.as | 2 -
.../textLayout/compose/ITextFlowTableBlock.as | 5 +-
.../compose/IVerticalJustificationLine.as | 44 +-
.../flex/textLayout/compose/TextFlowLine.as | 28 +-
.../textLayout/compose/TextFlowTableBlock.as | 28 +-
.../container/IContainerController.as | 23 +-
.../container/TMContainerController.as | 28 +-
.../conversion/BaseTextLayoutImporter.as | 324 +-
.../conversion/TextFieldHtmlImporter.as | 28 +-
.../apache/flex/textLayout/edit/ElementMark.as | 28 +-
.../apache/flex/textLayout/edit/ElementRange.as | 715 ++-
.../apache/flex/textLayout/edit/IMEClient.as | 261 +-
.../apache/flex/textLayout/edit/ModelEdit.as | 28 +-
.../apache/flex/textLayout/edit/PointFormat.as | 3 -
.../flex/textLayout/edit/SelectionManager.as | 5087 +++++++++---------
.../flex/textLayout/elements/BreakElement.as | 28 +-
.../flex/textLayout/elements/FlowElement.as | 28 +-
.../textLayout/elements/FlowGroupElement.as | 28 +-
.../flex/textLayout/elements/FlowLeafElement.as | 238 +-
.../flex/textLayout/elements/ITCYElement.as | 3 -
.../flex/textLayout/elements/ITableElement.as | 1 -
.../textLayout/elements/InlineGraphicElement.as | 2265 ++++----
.../flex/textLayout/elements/LinkElement.as | 211 +-
.../elements/SpecialCharacterElement.as | 28 +-
.../flex/textLayout/events/ScrollEvent.as | 3 +-
.../flex/textLayout/formats/TextLayoutFormat.as | 28 +-
.../operations/ApplyElementIDOperation.as | 37 +-
.../operations/ApplyElementTypeNameOperation.as | 44 +-
.../ApplyElementUserStyleOperation.as | 62 +-
.../operations/ApplyFormatOperation.as | 89 +-
.../textLayout/operations/ApplyTCYOperation.as | 66 +-
.../operations/ClearFormatOnElementOperation.as | 63 +-
.../apache/flex/textLayout/property/Property.as | 7 +-
35 files changed, 4960 insertions(+), 4947 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/19b26fe5/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/CoreClasses.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/CoreClasses.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/CoreClasses.as
index ce2d507..50c59bb 100644
--- a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/CoreClasses.as
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/CoreClasses.as
@@ -19,10 +19,6 @@
package org.apache.flex.textLayout
{
- import org.apache.flex.textLayout.compose.IComposeState;
- import org.apache.flex.textLayout.compose.IComposer;
- import org.apache.flex.textLayout.compose.IFactoryComposer;
- import org.apache.flex.textLayout.compose.ISimpleCompose;
internal class CoreClasses
{
@@ -30,8 +26,8 @@ package org.apache.flex.textLayout
import org.apache.flex.textLayout.TextLayoutVersion; TextLayoutVersion;
- import org.apache.flex.textLayout.compose.BaseCompose; IComposer;
- import org.apache.flex.textLayout.compose.ComposeState; IComposeState;
+ import org.apache.flex.textLayout.compose.BaseCompose; BaseCompose;
+ import org.apache.flex.textLayout.compose.ComposeState; ComposeState;
import org.apache.flex.textLayout.compose.FlowComposerBase; FlowComposerBase;
import org.apache.flex.textLayout.compose.FloatCompositionData; FloatCompositionData;
import org.apache.flex.textLayout.compose.FlowDamageType; FlowDamageType;
@@ -40,7 +36,7 @@ package org.apache.flex.textLayout
import org.apache.flex.textLayout.compose.IVerticalJustificationLine; IVerticalJustificationLine;
import org.apache.flex.textLayout.compose.Parcel; Parcel;
import org.apache.flex.textLayout.compose.ParcelList; ParcelList;
- import org.apache.flex.textLayout.compose.SimpleCompose; ISimpleCompose;
+ import org.apache.flex.textLayout.compose.SimpleCompose; SimpleCompose;
import org.apache.flex.textLayout.compose.Slug; Slug;
import org.apache.flex.textLayout.compose.TextFlowLine; TextFlowLine;
import org.apache.flex.textLayout.compose.TextFlowLineLocation; TextFlowLineLocation;
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/19b26fe5/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/FactoryComposer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/FactoryComposer.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/FactoryComposer.as
index 16da8ec..ad897d4 100644
--- a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/FactoryComposer.as
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/FactoryComposer.as
@@ -18,67 +18,65 @@
////////////////////////////////////////////////////////////////////////////////
package org.apache.flex.textLayout.compose
{
-
import org.apache.flex.textLayout.compose.utils.FactoryHelper;
import org.apache.flex.textLayout.container.IContainerController;
import org.apache.flex.textLayout.elements.IBackgroundManager;
- import org.apache.flex.textLayout.factory.TextLineFactoryBase;
-
-
-
// [ExcludeClass]
/** @private
- * FactoryDisplayComposer - overridable
+ * FactoryDisplayComposer - overridable
*/
- public class FactoryComposer extends StandardFlowComposer implements IFactoryComposer {
+ public class FactoryComposer extends StandardFlowComposer implements IFactoryComposer
+ {
public function FactoryComposer()
- { super(); }
-
+ {
+ super();
+ }
+
public override function callTheComposer(absoluteEndPosition:int, controllerEndIndex:int):IContainerController
{
// always do a full compose
clearCompositionResults();
-
+
var state:ISimpleCompose = FactoryHelper.staticComposer;
state.composeTextFlow(textFlow, -1, -1);
state.releaseAnyReferences();
return getControllerAt(0);
}
-
+
/** Returns true if composition is necessary, false otherwise */
protected override function preCompose():Boolean
{
return true;
}
-
+
/** @private */
public override function createBackgroundManager():IBackgroundManager
- { return new FactoryBackgroundManager(); }
+ {
+ return new FactoryBackgroundManager();
+ }
}
}
-import org.apache.flex.textLayout.compose.ITextFlowLine;
import org.apache.flex.text.engine.ITextLine;
-
+import org.apache.flex.textLayout.compose.ITextFlowLine;
import org.apache.flex.textLayout.elements.BackgroundManager;
class FactoryBackgroundManager extends BackgroundManager
{
-
public override function finalizeLine(line:ITextFlowLine):void
{
var textLine:ITextLine = line.getTextLine();
-
+
var array:Array = _lineDict[textLine];
if (array)
{
// attach the columnRect and the ITextLine to the first object in the Array
var obj:Object = array[0];
-
+
if (obj) // check not needed?
obj.columnRect = line.controller.columnState.getColumnAt(line.columnIndex);
}
}
-}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/19b26fe5/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/IComposeState.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/IComposeState.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/IComposeState.as
index cd7ffb2..70c9dad 100644
--- a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/IComposeState.as
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/IComposeState.as
@@ -18,8 +18,6 @@
////////////////////////////////////////////////////////////////////////////////
package org.apache.flex.textLayout.compose
{
- import org.apache.flex.textLayout.elements.ITextFlow;
-
public interface IComposeState extends IComposer
{
}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/19b26fe5/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/ITextFlowTableBlock.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/ITextFlowTableBlock.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/ITextFlowTableBlock.as
index 6ad273a..89e9214 100644
--- a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/ITextFlowTableBlock.as
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/ITextFlowTableBlock.as
@@ -18,12 +18,11 @@
////////////////////////////////////////////////////////////////////////////////
package org.apache.flex.textLayout.compose
{
+ import org.apache.flex.textLayout.elements.CellContainer;
import org.apache.flex.textLayout.elements.CellCoordinates;
+ import org.apache.flex.textLayout.elements.ITableCellElement;
import org.apache.flex.textLayout.elements.ITableElement;
import org.apache.flex.textLayout.elements.TableBlockContainer;
- import org.apache.flex.textLayout.elements.CellContainer;
- import org.apache.flex.textLayout.elements.ITableCellElement;
- import org.apache.flex.textLayout.elements.TableCellElement;
public interface ITextFlowTableBlock extends ITextFlowLine
{
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/19b26fe5/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/IVerticalJustificationLine.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/IVerticalJustificationLine.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/IVerticalJustificationLine.as
index ee6a315..6ff3cb7 100644
--- a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/IVerticalJustificationLine.as
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/IVerticalJustificationLine.as
@@ -16,17 +16,15 @@
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////
-package org.apache.flex.textLayout.compose {
- import org.apache.flex.textLayout.elements.IParagraphElement;
- import org.apache.flex.text.engine.ITextLine;
-
+package org.apache.flex.textLayout.compose
+{
/**
* The IVerticalJustificationLine interface defines the methods and properties required to allow
* the vertical justification of text lines.
*
* @playerversion Flash 10
* @playerversion AIR 1.5
- * @langversion 3.0
+ * @langversion 3.0
*/
public interface IVerticalJustificationLine
{
@@ -36,60 +34,58 @@ package org.apache.flex.textLayout.compose {
*
* @playerversion Flash 10
* @playerversion AIR 1.5
- * @langversion 3.0
- *
- * @see #y
+ * @langversion 3.0
+ *
+ * @see #y
*/
function get x():Number;
-
+
/** Set X location for the line. Used only during vertical justification. @private */
function set x(val:Number):void;
-
+
/**
* The vertical position of the line relative to its container, expressed as the offset in pixels from the top
* of the container.
*
* @playerversion Flash 10
* @playerversion AIR 1.5
- * @langversion 3.0
- *
- * @see #x
+ * @langversion 3.0
+ *
+ * @see #x
*/
function get y():Number;
-
+
/** Set Y location for the line. Used only during vertical justification. @private */
function set y(val:Number):void;
-
+
/**
* @copy org.apache.flex.text.engine.TextLine#ascent
*
* @playerversion Flash 10
* @playerversion AIR 1.5
- * @langversion 3.0
+ * @langversion 3.0
*/
function get ascent():Number;
-
+
/**
* @copy org.apache.flex.text.engine.TextLine#descent
*
* @playerversion Flash 10
* @playerversion AIR 1.5
- * @langversion 3.0
+ * @langversion 3.0
*/
function get descent():Number;
-
+
/** The height of the line in pixels.
*
* @playerversion Flash 10
* @playerversion AIR 1.5
- * @langversion 3.0
- *
+ * @langversion 3.0
+ *
*/
function get height():Number;
-
// TODO for TextFlowTableBloack
function set height(value:Number):void;
}
-
-}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/19b26fe5/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/TextFlowLine.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/TextFlowLine.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/TextFlowLine.as
index 6f417c1..75377ba 100644
--- a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/TextFlowLine.as
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/TextFlowLine.as
@@ -1,21 +1,21 @@
-// //////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
//
-// Licensed to the Apache Software Foundation (ASF) under one or more
-// contributor license agreements. See the NOTICE file distributed with
-// this work for additional information regarding copyright ownership.
-// The ASF licenses this file to You under the Apache License, Version 2.0
-// (the "License"); you may not use this file except in compliance with
-// the License. You may obtain a copy of the License at
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// http://www.apache.org/licenses/LICENSE-2.0
//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
//
-// //////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
package org.apache.flex.textLayout.compose
{
import org.apache.flex.core.IParentIUIBase;
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/19b26fe5/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/TextFlowTableBlock.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/TextFlowTableBlock.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/TextFlowTableBlock.as
index a1189c2..9ecf408 100644
--- a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/TextFlowTableBlock.as
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/compose/TextFlowTableBlock.as
@@ -1,21 +1,21 @@
-// //////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
//
-// Licensed to the Apache Software Foundation (ASF) under one or more
-// contributor license agreements. See the NOTICE file distributed with
-// this work for additional information regarding copyright ownership.
-// The ASF licenses this file to You under the Apache License, Version 2.0
-// (the "License"); you may not use this file except in compliance with
-// the License. You may obtain a copy of the License at
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// http://www.apache.org/licenses/LICENSE-2.0
//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
//
-// //////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
package org.apache.flex.textLayout.compose
{
import org.apache.flex.textLayout.container.IContainerController;
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/19b26fe5/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/IContainerController.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/IContainerController.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/IContainerController.as
index 66f34aa..a71f4bd 100644
--- a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/IContainerController.as
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/IContainerController.as
@@ -18,26 +18,24 @@
////////////////////////////////////////////////////////////////////////////////
package org.apache.flex.textLayout.container
{
+ import org.apache.flex.core.IParentIUIBase;
import org.apache.flex.core.IUIBase;
import org.apache.flex.geom.Matrix;
+ import org.apache.flex.geom.Point;
+ import org.apache.flex.geom.Rectangle;
import org.apache.flex.text.engine.ITextLine;
+ import org.apache.flex.textLayout.compose.FloatCompositionData;
+ import org.apache.flex.textLayout.compose.IFlowComposer;
import org.apache.flex.textLayout.compose.ITextFlowLine;
+ import org.apache.flex.textLayout.compose.ITextFlowTableBlock;
import org.apache.flex.textLayout.edit.ISelectionManager;
- import org.apache.flex.textLayout.elements.ITextFlow;
- import org.apache.flex.geom.Point;
- import org.apache.flex.geom.Rectangle;
import org.apache.flex.textLayout.edit.SelectionFormat;
- import org.apache.flex.textLayout.formats.TextLayoutFormat;
+ import org.apache.flex.textLayout.elements.CellCoordinates;
import org.apache.flex.textLayout.elements.IContainerFormattedElement;
- import org.apache.flex.textLayout.compose.IFlowComposer;
+ import org.apache.flex.textLayout.elements.ITextFlow;
+ import org.apache.flex.textLayout.elements.TableBlockContainer;
import org.apache.flex.textLayout.formats.ITextLayoutFormat;
import org.apache.flex.utils.ObjectMap;
- import org.apache.flex.textLayout.elements.TableBlockContainer;
- import org.apache.flex.textLayout.compose.ITextFlowTableBlock;
- import org.apache.flex.textLayout.compose.TextFlowTableBlock;
- import org.apache.flex.textLayout.elements.CellCoordinates;
- import org.apache.flex.core.IParentIUIBase;
- import org.apache.flex.textLayout.compose.FloatCompositionData;
public interface IContainerController
{
@@ -71,11 +69,8 @@ package org.apache.flex.textLayout.container
function get contentHeight():Number;
function get rootElement():IContainerFormattedElement;
function get verticalScrollPolicy():String;
-
function get horizontalScrollPolicy():String;
-
function get format():ITextLayoutFormat;
-
function set format(format:ITextLayoutFormat):void;
function addSelectionShapes(selFormat:SelectionFormat, selectionAbsoluteStart:int, selectionAbsoluteEnd:int):void;
function getContentBounds():Rectangle;
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/19b26fe5/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/TMContainerController.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/TMContainerController.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/TMContainerController.as
index ed7be1b..7043e49 100644
--- a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/TMContainerController.as
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/TMContainerController.as
@@ -1,21 +1,21 @@
-// //////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
//
-// Licensed to the Apache Software Foundation (ASF) under one or more
-// contributor license agreements. See the NOTICE file distributed with
-// this work for additional information regarding copyright ownership.
-// The ASF licenses this file to You under the Apache License, Version 2.0
-// (the "License"); you may not use this file except in compliance with
-// the License. You may obtain a copy of the License at
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// http://www.apache.org/licenses/LICENSE-2.0
//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
//
-// //////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
package org.apache.flex.textLayout.container
{
import org.apache.flex.core.IParentIUIBase;
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/19b26fe5/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/BaseTextLayoutImporter.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/BaseTextLayoutImporter.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/BaseTextLayoutImporter.as
index dc9cd2f..55a3a9b 100644
--- a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/BaseTextLayoutImporter.as
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/BaseTextLayoutImporter.as
@@ -16,9 +16,8 @@
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////
-package org.apache.flex.textLayout.conversion
+package org.apache.flex.textLayout.conversion
{
- import org.apache.flex.textLayout.utils.FactoryUtil;
import org.apache.flex.textLayout.TextLayoutVersion;
import org.apache.flex.textLayout.debug.assert;
import org.apache.flex.textLayout.elements.BreakElement;
@@ -40,54 +39,50 @@ package org.apache.flex.textLayout.conversion
import org.apache.flex.textLayout.elements.TabElement;
import org.apache.flex.textLayout.elements.TableCellElement;
import org.apache.flex.textLayout.elements.TextFlow;
- import org.apache.flex.textLayout.factory.ITLFFactory;
- import org.apache.flex.textLayout.factory.StandardTLFFactory;
import org.apache.flex.textLayout.property.Property;
import org.apache.flex.textLayout.property.PropertyUtil;
+ import org.apache.flex.textLayout.utils.FactoryUtil;
/**
* BaseTextLayoutImporter is a base class for handling the import/export of TextLayout text
* in the native format.
- */
+ */
internal class BaseTextLayoutImporter extends ConverterBase implements ITextImporter
- {
+ {
private var _ns:Namespace; // namespace of expected in imported/exported content
-
private var _textFlowNamespace:Namespace; // namespace of the TextFlow element against which the namespaces of the following elements are validated
-
protected var _config:ImportExportConfiguration;
protected var _textFlowConfiguration:IConfiguration = null;
protected var _importVersion:uint;
-
// static private const anyPrintChar:RegExp = /[^\s]/g;
- // Consider only tab, line feed, carriage return, and space as characters used for pretty-printing.
- // While debatable, this is consistent with what CSS does.
- static private const anyPrintChar:RegExp = /foo/;// = /[^\u0009\u000a\u000d\u0020]/g;
-//TODO
- // static private const anyPrintChar:RegExp = /[^\u0009\u000a\u000d\u0020]/g;
+ // Consider only tab, line feed, carriage return, and space as characters used for pretty-printing.
+ // While debatable, this is consistent with what CSS does.
+ static private const anyPrintChar:RegExp = /foo/;// = /[^\u0009\u000a\u000d\u0020]/g;
+ // TODO
+ // static private const anyPrintChar:RegExp = /[^\u0009\u000a\u000d\u0020]/g;
public function BaseTextLayoutImporter(nsValue:Namespace, config:ImportExportConfiguration)
{
_ns = nsValue;
_config = config;
}
-
+
public override function clear():void
{
super.clear();
_textFlowNamespace = null;
_impliedPara = null;
}
-
+
/** @copy ITextImporter#importToFlow()
*/
public function importToFlow(source:Object):ITextFlow
{
clear(); // empty results of previous imports
-
+
if (throwOnError)
return importToFlowCanThrow(source);
-
+
var rslt:TextFlow = null;
var savedErrorHandler:Function = PropertyUtil.errorHandler;
try
@@ -102,25 +97,25 @@ package org.apache.flex.textLayout.conversion
PropertyUtil.errorHandler = savedErrorHandler;
return rslt;
}
-
+
/** @copy ITextImporter#get configuration()
*/
public function get configuration():IConfiguration
{
return _textFlowConfiguration;
}
-
+
public function set configuration(value:IConfiguration):void
{
_textFlowConfiguration = value;
}
/** @private */
- protected function importPropertyErrorHandler(p:Property,value:Object):void
+ protected function importPropertyErrorHandler(p:Property, value:Object):void
{
- reportError(PropertyUtil.createErrorString(p,value));
+ reportError(PropertyUtil.createErrorString(p, value));
}
-
+
private function importToFlowCanThrow(source:Object):TextFlow
{
if (source is String)
@@ -129,7 +124,7 @@ package org.apache.flex.textLayout.conversion
return importFromXML(XML(source));
return null;
}
-
+
/** Parse and convert input data.
*
* @param source - a string which is in XFL format. String is applied to an XML object then passed
@@ -141,34 +136,34 @@ package org.apache.flex.textLayout.conversion
var originalSettings:Object = XML.settings();
try
{
- XML.ignoreProcessingInstructions = false;
+ XML.ignoreProcessingInstructions = false;
XML.ignoreWhitespace = false;
- var xmlTree:XML = new XML(source);
- }
+ var xmlTree:XML = new XML(source);
+ }
finally
{
XML.setSettings(originalSettings);
- }
-
+ }
+
var textFlow:TextFlow = importFromXML(xmlTree);
-//TODO probably does not make sense for FlexJS
-// if (Configuration.playerEnablesArgoFeatures)
-// System["disposeXML"](xmlTree);
+ // TODO probably does not make sense for FlexJS
+ // if (Configuration.playerEnablesArgoFeatures)
+ // System["disposeXML"](xmlTree);
return textFlow;
}
-
+
/** Parse and convert input data.
*
* xflSource is a XFL formated object which must be capable of being cast as an XML
* object (E4X).
*/
protected function importFromXML(xmlSource:XML):TextFlow
- // Parse an XFL hierarchy into a TextFlow, using the geometry supplied by a TextFrame
- // to host child containers (e.g. tables). This is the main entry point into this class.
+ // Parse an XFL hierarchy into a TextFlow, using the geometry supplied by a TextFrame
+ // to host child containers (e.g. tables). This is the main entry point into this class.
{
return parseContent(xmlSource[0]);
}
-
+
// This routine imports a TextFlow
protected function parseContent(rootStory:XML):TextFlow
{
@@ -178,23 +173,24 @@ package org.apache.flex.textLayout.conversion
return parseTextFlow(this, rootStory);
return null;
}
-
+
/** Returns the namespace used in for writing XML/XFL
*
* @return the Namespace being used.
*/
- public function get ns(): Namespace
+ public function get ns():Namespace
{
return _ns;
}
-
+
// Remove double spaces, tabs, and newlines.
// If I have a sequence of different sorts of spaces (e.g., en quad, hair space), would I want them converted down to one space? Probably not.
- // For now, u0020 is the only space character we consider for eliminating duplicates, though u00A0 (non-breaking space) is potentially eligible.
-// static private const dblSpacePattern:RegExp = /[\u0020]{2,}/g;
+ // For now, u0020 is the only space character we consider for eliminating duplicates, though u00A0 (non-breaking space) is potentially eligible.
+ // static private const dblSpacePattern:RegExp = /[\u0020]{2,}/g;
// Tab, line feed, and carriage return
-//TODO regex
+ // TODO regex
static private const tabNewLinePattern:RegExp = /foo/g;
+
// static private const tabNewLinePattern:RegExp = /[\u0009\u000a\u000d]/g;
protected static function stripWhitespace(insertString:String):String
{
@@ -208,11 +204,11 @@ package org.apache.flex.textLayout.conversion
* @param parent always null - this parameter is only provided to match FlowElementInfo.importer signature
* @return TextFlow the new TextFlow created as a result of the parse
*/
- static public function parseTextFlow(importer:BaseTextLayoutImporter, xmlToParse:XML, parent:Object=null):TextFlow
+ static public function parseTextFlow(importer:BaseTextLayoutImporter, xmlToParse:XML, parent:Object = null):TextFlow
{
return importer.createTextFlowFromXML(xmlToParse, null);
- }
-
+ }
+
/**
* Static method to parse the supplied XML into a paragrph.
* Parse the <p ...> tag and it's children.
@@ -227,19 +223,19 @@ package org.apache.flex.textLayout.conversion
if (importer.addChild(parent, paraElem))
{
importer.parseFlowGroupElementChildren(xmlToParse, paraElem);
- //if parsing an empty paragraph, create a Span for it.
+ // if parsing an empty paragraph, create a Span for it.
if (paraElem.numChildren == 0)
paraElem.addChild(new SpanElement());
}
}
-
- static protected function copyAllStyleProps(dst:IFlowLeafElement,src:IFlowLeafElement):void
+
+ static protected function copyAllStyleProps(dst:IFlowLeafElement, src:IFlowLeafElement):void
{
dst.format = src.format;
- dst.typeName = src.typeName;
- dst.id = src.id;
+ dst.typeName = src.typeName;
+ dst.id = src.id;
}
-
+
/**
* Static method for constructing a span from XML. Parse the <span> ... </span> tag.
* Insert the span into its parent
@@ -251,20 +247,20 @@ package org.apache.flex.textLayout.conversion
static public function parseSpan(importer:BaseTextLayoutImporter, xmlToParse:XML, parent:IFlowGroupElement):void
{
var firstSpan:ISpanElement = importer.createSpanFromXML(xmlToParse);
-
+
var elemList:XMLList = xmlToParse[0].children();
- if(elemList.length() == 0)
+ if (elemList.length() == 0)
{
- // Empty span, but may have formatting, so don't strip it out.
+ // Empty span, but may have formatting, so don't strip it out.
// Note: the normalizer may yet strip it out if it is not the last child, but that's the normalizer's business.
- importer.addChild(parent, firstSpan);
+ importer.addChild(parent, firstSpan);
return;
}
-
- for each (var child:XML in elemList)
+
+ for each (var child:XML in elemList)
{
var elemName:String = child.name() ? child.name().localName : null;
-
+
if (elemName == null) // span text
{
if (firstSpan.parent == null) // hasn't been used yet
@@ -275,7 +271,7 @@ package org.apache.flex.textLayout.conversion
else
{
var s:SpanElement = new SpanElement(); // No PMD
- copyAllStyleProps(s,firstSpan);
+ copyAllStyleProps(s, firstSpan);
s.text = child.toString();
importer.addChild(parent, s);
}
@@ -285,28 +281,28 @@ package org.apache.flex.textLayout.conversion
var brElem:BreakElement = importer.createBreakFromXML(child); // may be null
if (brElem)
{
- copyAllStyleProps(brElem,firstSpan);
+ copyAllStyleProps(brElem, firstSpan);
importer.addChild(parent, brElem);
}
else
- importer.reportError(GlobalSettings.resourceStringFunction("unexpectedXMLElementInSpan",[ elemName ]));
+ importer.reportError(GlobalSettings.resourceStringFunction("unexpectedXMLElementInSpan", [elemName]));
}
else if (elemName == "tab")
{
var tabElem:TabElement = importer.createTabFromXML(child); // may be null
if (tabElem)
{
- copyAllStyleProps(tabElem,firstSpan);
+ copyAllStyleProps(tabElem, firstSpan);
importer.addChild(parent, tabElem);
}
else
- importer.reportError(GlobalSettings.resourceStringFunction("unexpectedXMLElementInSpan",[ elemName ]));
+ importer.reportError(GlobalSettings.resourceStringFunction("unexpectedXMLElementInSpan", [elemName]));
}
else
- importer.reportError(GlobalSettings.resourceStringFunction("unexpectedXMLElementInSpan",[ elemName ]));
+ importer.reportError(GlobalSettings.resourceStringFunction("unexpectedXMLElementInSpan", [elemName]));
}
}
-
+
/**
* Static method for constructing a break element from XML. Validate the <br> ... </br> tag.
* Use "\u2028" as the text; Insert the new element into its parent
@@ -320,7 +316,7 @@ package org.apache.flex.textLayout.conversion
var breakElem:BreakElement = importer.createBreakFromXML(xmlToParse);
importer.addChild(parent, breakElem);
}
-
+
/**
* Static method for constructing a tab element from XML. Validate the <tab> ... </tab> tag.
* Use "\t" as the text; Insert the new element into its parent
@@ -335,7 +331,7 @@ package org.apache.flex.textLayout.conversion
if (tabElem)
importer.addChild(parent, tabElem);
}
-
+
/**
* Static method for constructing a list element from XML.
*
@@ -351,7 +347,7 @@ package org.apache.flex.textLayout.conversion
importer.parseFlowGroupElementChildren(xmlToParse, listElem);
}
}
-
+
/**
* Static method for constructing a list item from XML.
*
@@ -365,19 +361,19 @@ package org.apache.flex.textLayout.conversion
if (importer.addChild(parent, listItem))
{
importer.parseFlowGroupElementChildren(xmlToParse, listItem);
- //if parsing an empty list item, create a Paragraph for it.
+ // if parsing an empty list item, create a Paragraph for it.
if (listItem.numChildren == 0)
- listItem.addChild(ElementHelper.getParagraph());
+ listItem.addChild(ElementHelper.getParagraph());
}
}
-
+
protected function checkNamespace(xmlToParse:XML):Boolean
{
var elementNS:Namespace = xmlToParse.namespace();
if (!_textFlowNamespace) // Not set yet; must be parsing the TextFlow element
{
// TextFlow element: allow only empty namespace and flow namespace
- if (elementNS != ns)
+ if (elementNS != ns)
{
reportError(GlobalSettings.resourceStringFunction("unexpectedNamespace", [elementNS.toString()]));
return false;
@@ -385,67 +381,66 @@ package org.apache.flex.textLayout.conversion
_textFlowNamespace = elementNS;
}
// Other elements: must match the namespace of the TextFlow element
- // Specifically, can't be empty unless the TextFlow element's namespace is also empty
- else if (elementNS != _textFlowNamespace)
+ // Specifically, can't be empty unless the TextFlow element's namespace is also empty
+ else if (elementNS != _textFlowNamespace)
{
reportError(GlobalSettings.resourceStringFunction("unexpectedNamespace", [elementNS.toString()]));
return false;
}
-
+
return true;
}
-
- public function parseAttributes(xmlToParse:XML,formatImporters:Array):void
+
+ public function parseAttributes(xmlToParse:XML, formatImporters:Array):void
{
var importer:IFormatImporter;
// reset them all
for each (importer in formatImporters)
importer.reset();
-
+
if (!xmlToParse)
return;
-
+
for each (var item:XML in xmlToParse.attributes())
{
var propertyName:String = item.name().localName;
var propertyValue:String = item.toString();
var imported:Boolean = false;
-
+
// Strip out padding properties from XML coming in before TLF 2.0, since they were ignored but are no longer. This preserves the look of the text.
if (xmlToParse.localName() == "TextFlow")
{
if (propertyName == "version") // skip over the version attribute, we've already processed it
continue;
}
- else if (_importVersion < TextLayoutVersion.VERSION_2_0 &&
- (propertyName == "paddingLeft" || propertyName == "paddingTop" || propertyName == "paddingRight" || propertyName == "paddingBottom"))
+ else if (_importVersion < TextLayoutVersion.VERSION_2_0 && (propertyName == "paddingLeft" || propertyName == "paddingTop" || propertyName == "paddingRight" || propertyName == "paddingBottom"))
continue;
for each (importer in formatImporters)
{
- if (importer.importOneFormat(propertyName,propertyValue))
+ if (importer.importOneFormat(propertyName, propertyValue))
{
imported = true;
break;
}
}
if (!imported) // not a supported attribute
- handleUnknownAttribute (xmlToParse.name().localName, propertyName);
+ handleUnknownAttribute(xmlToParse.name().localName, propertyName);
}
}
-
+
static protected function extractAttributesHelper(curAttrs:Object, importer:TLFormatImporter):Object
{
if (curAttrs == null)
return importer.result;
-
+
if (importer.result == null)
return curAttrs;
-
+
var workAttrs:Object = new importer.classType(curAttrs);
workAttrs.apply(importer.result);
return workAttrs;
- }
-
+ }
+
/**
* Parse XML and convert to TextFlow.
*
@@ -455,46 +450,56 @@ package org.apache.flex.textLayout.conversion
*/
public function createTextFlowFromXML(xmlToParse:XML, newFlow:TextFlow = null):TextFlow // No PMD
{
- CONFIG::debug { assert(false,"missing override for createTextFlowFromXML"); }
+ CONFIG::debug
+ {
+ assert(false, "missing override for createTextFlowFromXML"); }
return null;
}
public function createParagraphFromXML(xmlToParse:XML):IParagraphElement // No PMD
{
- CONFIG::debug { assert(false,"missing override for createParagraphFromXML"); }
+ CONFIG::debug
+ {
+ assert(false, "missing override for createParagraphFromXML"); }
return null;
}
-
+
public function createSpanFromXML(xmlToParse:XML):ISpanElement // No PMD
{
- CONFIG::debug { assert(false,"missing override for createSpanFromXML"); }
+ CONFIG::debug
+ {
+ assert(false, "missing override for createSpanFromXML"); }
return null;
}
-
+
public function createBreakFromXML(xmlToParse:XML):BreakElement
{
- parseAttributes(xmlToParse,null); // no attributes allowed - reports errors
+ parseAttributes(xmlToParse, null); // no attributes allowed - reports errors
return new BreakElement();
}
-
+
public function createListFromXML(xmlToParse:XML):IListElement // No PMD
{
- CONFIG::debug { assert(false,"missing override for createListFromXML"); }
+ CONFIG::debug
+ {
+ assert(false, "missing override for createListFromXML"); }
return null;
}
public function createListItemFromXML(xmlToParse:XML):IListItemElement // No PMD
{
- CONFIG::debug { assert(false,"missing override for createListItemFromXML"); }
+ CONFIG::debug
+ {
+ assert(false, "missing override for createListItemFromXML"); }
return null;
}
-
+
public function createTabFromXML(xmlToParse:XML):TabElement
{
- parseAttributes(xmlToParse,null); // reports errors
+ parseAttributes(xmlToParse, null); // reports errors
return new TabElement();
}
-
+
/**
* Parse XML, convert to FlowElements and add to the parent.
*
@@ -505,7 +510,7 @@ package org.apache.flex.textLayout.conversion
{
parseFlowGroupElementChildren(xmlToParse, parent);
}
-
+
/**
* Parse XML, convert to FlowElements and add to the parent.
*
@@ -513,7 +518,7 @@ package org.apache.flex.textLayout.conversion
* @param parent the parent for the new content
* @param chainedParent whether parent actually corresponds to xmlToParse or has been chained (such as when xmlToParse is a formatting element)
*/
- public function parseFlowGroupElementChildren(xmlToParse:XML, parent:IFlowGroupElement, exceptionElements:Object = null, chainedParent:Boolean=false):void
+ public function parseFlowGroupElementChildren(xmlToParse:XML, parent:IFlowGroupElement, exceptionElements:Object = null, chainedParent:Boolean = false):void
{
for each (var child:XML in xmlToParse.children())
{
@@ -522,26 +527,26 @@ package org.apache.flex.textLayout.conversion
parseObject(child.name().localName, child, parent, exceptionElements);
}
// look for mixed content here
- else if (child.nodeKind() == "text")
- {
- var txt:String = child.toString();
- // Strip whitespace-only text appearing as a child of a container-formatted element
- var strip:Boolean = false;
- if (parent is IContainerFormattedElement)
- {
+ else if (child.nodeKind() == "text")
+ {
+ var txt:String = child.toString();
+ // Strip whitespace-only text appearing as a child of a container-formatted element
+ var strip:Boolean = false;
+ if (parent is IContainerFormattedElement)
+ {
strip = txt.search(anyPrintChar) == -1;
}
-
- if (!strip)
+
+ if (!strip)
addChild(parent, createImpliedSpan(txt));
}
}
-
+
// no implied paragraph should extend across container elements
if (!chainedParent && parent is IContainerFormattedElement)
resetImpliedPara();
}
-
+
/**
* Parse XML, convert XML to FlowElements and TextFlow and add to the parent table cell
*
@@ -549,24 +554,26 @@ package org.apache.flex.textLayout.conversion
* @param parent the parent for the new content
* @param chainedParent whether parent actually corresponds to xmlToParse or has been chained (such as when xmlToParse is a formatting element)
*/
- public function parseTableCellElementChildren(xmlToParse:XML, parent:IFlowGroupElement, exceptionElements:Object = null, chainedParent:Boolean=false):void
+ public function parseTableCellElementChildren(xmlToParse:XML, parent:IFlowGroupElement, exceptionElements:Object = null, chainedParent:Boolean = false):void
{
var textFlow:TextFlow;
-
+
for each (var child:XML in xmlToParse.children())
{
if (child.nodeKind() == "element")
{
- if (child.name().localName=="p") {
+ if (child.name().localName == "p")
+ {
textFlow = new TextFlow(FactoryUtil.defaultTLFFactory);
parseObject(child.name().localName, child, textFlow, exceptionElements);
}
- else if (child.name().localName=="TextFlow") {
+ else if (child.name().localName == "TextFlow")
+ {
TableCellElement(parent).textFlow = createTextFlowFromXML(child);
}
}
- // look for mixed content here
- else if (child.nodeKind() == "text")
+ // look for mixed content here
+ else if (child.nodeKind() == "text")
{
var txt:String = child.toString();
// Strip whitespace-only text appearing as a child of a container-formatted element
@@ -575,21 +582,23 @@ package org.apache.flex.textLayout.conversion
{
strip = txt.search(anyPrintChar) == -1;
}
-
- if (!strip) {
+
+ if (!strip)
+ {
textFlow = new TextFlow(FactoryUtil.defaultTLFFactory);
parseObject(child.name().localName, child, textFlow, exceptionElements);
- //addChild(textFlow, createImpliedSpan(txt));
+ // addChild(textFlow, createImpliedSpan(txt));
}
}
-
- if (textFlow) {
+
+ if (textFlow)
+ {
TableCellElement(parent).textFlow = textFlow;
textFlow = null;
}
}
}
-
+
/** create an implied span with specified text */
public function createImpliedSpan(text:String):SpanElement
{
@@ -597,14 +606,16 @@ package org.apache.flex.textLayout.conversion
span.text = text;
return span;
}
-
+
public function createParagraphFlowFromXML(xmlToParse:XML, newFlow:TextFlow = null):TextFlow // No PMD
{
- CONFIG::debug { assert(false,"missing override for createParagraphFlowFromXML"); } // client must override
+ CONFIG::debug
+ {
+ assert(false, "missing override for createParagraphFlowFromXML"); } // client must override
return null;
}
-
- public function parseObject(name:String, xmlToParse:XML, parent:IFlowGroupElement, exceptionElements:Object=null):void
+
+ public function parseObject(name:String, xmlToParse:XML, parent:IFlowGroupElement, exceptionElements:Object = null):void
{
if (!checkNamespace(xmlToParse))
return;
@@ -613,54 +624,54 @@ package org.apache.flex.textLayout.conversion
if (!info)
{
if (exceptionElements == null || exceptionElements[name] === undefined)
- handleUnknownElement (name, xmlToParse, parent);
+ handleUnknownElement(name, xmlToParse, parent);
}
else
info.parser(this, xmlToParse, parent);
}
-
+
protected function handleUnknownElement(name:String, xmlToParse:XML, parent:IFlowGroupElement):void
{
- reportError(GlobalSettings.resourceStringFunction("unknownElement", [ name ]));
+ reportError(GlobalSettings.resourceStringFunction("unknownElement", [name]));
}
-
+
protected function handleUnknownAttribute(elementName:String, propertyName:String):void
{
- reportError(GlobalSettings.resourceStringFunction("unknownAttribute", [ propertyName, elementName ]));
+ reportError(GlobalSettings.resourceStringFunction("unknownAttribute", [propertyName, elementName]));
}
-
+
protected function getElementInfo(xmlToParse:XML):FlowElementInfo
{
return _config.lookup(xmlToParse.name().localName);
}
-
+
protected function GetClass(xmlToParse:XML):Class
{
var info:FlowElementInfo = _config.lookup(xmlToParse.name().localName);
return info ? info.flowClass : null;
}
-
+
// In the text model, non-FlowParagraphElements (i.e. spans, images, links, TCY) cannot be children of a ContainerElement (TextFlow, Div etc.)
- // They can only be children of paragraphs or subparagraph blocks.
- // In XML, however, <p> elements can be implied (for example, a <span> may appear as a direct child of <flow>).
- // So, while parsing the XML, if we enounter a non-FlowParagraphElement child of a ContainerElement
+ // They can only be children of paragraphs or subparagraph blocks.
+ // In XML, however, <p> elements can be implied (for example, a <span> may appear as a direct child of <flow>).
+ // So, while parsing the XML, if we enounter a non-FlowParagraphElement child of a ContainerElement
// 1. an explicitly created paragraph is used as the parent instead
- // 2. such explicitly created paragraphs are shared by adjacent flow elements provided there isn't an intervening FlowParagraphElement
- private var _impliedPara:IParagraphElement = null;
-
+ // 2. such explicitly created paragraphs are shared by adjacent flow elements provided there isn't an intervening FlowParagraphElement
+ private var _impliedPara:IParagraphElement = null;
+
/** @private */
public function createImpliedParagraph():IParagraphElement
{
return createParagraphFromXML(<p/>);
}
-
+
/**
* @private
* Helper function for adding a child flow element that honors throwOnError setting and uses the parent override
* NOTE: You MUST NOT call addChild directly unless you are sure
* - There is not possibility of an implied paragraph, and
* - Parent is of type that can contain child
- */
+ */
public function addChild(parent:IFlowGroupElement, child:IFlowElement):Boolean
{
if (child is IParagraphFormattedElement)
@@ -674,14 +685,14 @@ package org.apache.flex.textLayout.conversion
if (!_impliedPara)
{
// Derived classes may have special behavior for <p> tags. Implied paragraphs may need the same behavior.
- // So call createParagraphFromXML, don't just instantiate a ParagraphElement
+ // So call createParagraphFromXML, don't just instantiate a ParagraphElement
_impliedPara = createImpliedParagraph();
parent.addChild(_impliedPara);
}
-
+
parent = _impliedPara;
- }
-
+ }
+
if (throwOnError)
parent.addChild(child);
else
@@ -692,14 +703,14 @@ package org.apache.flex.textLayout.conversion
}
catch (e:*)
{
- reportError(e);
+ reportError(e);
return false;
}
}
-
+
return true;
- }
-
+ }
+
public function resetImpliedPara():void
{
if (_impliedPara)
@@ -708,10 +719,9 @@ package org.apache.flex.textLayout.conversion
_impliedPara = null;
}
}
-
+
protected function onResetImpliedPara(para:IParagraphElement):void
{
}
}
-}
-
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/19b26fe5/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/TextFieldHtmlImporter.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/TextFieldHtmlImporter.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/TextFieldHtmlImporter.as
index 042084c..867bea9 100644
--- a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/TextFieldHtmlImporter.as
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/TextFieldHtmlImporter.as
@@ -1,21 +1,21 @@
-// //////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
//
-// Licensed to the Apache Software Foundation (ASF) under one or more
-// contributor license agreements. See the NOTICE file distributed with
-// this work for additional information regarding copyright ownership.
-// The ASF licenses this file to You under the Apache License, Version 2.0
-// (the "License"); you may not use this file except in compliance with
-// the License. You may obtain a copy of the License at
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// http://www.apache.org/licenses/LICENSE-2.0
//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
//
-// //////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
package org.apache.flex.textLayout.conversion
{
import org.apache.flex.text.engine.Kerning;
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/19b26fe5/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/ElementMark.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/ElementMark.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/ElementMark.as
index e658f1d..074d8d9 100644
--- a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/ElementMark.as
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/ElementMark.as
@@ -1,21 +1,21 @@
-// //////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
//
-// Licensed to the Apache Software Foundation (ASF) under one or more
-// contributor license agreements. See the NOTICE file distributed with
-// this work for additional information regarding copyright ownership.
-// The ASF licenses this file to You under the Apache License, Version 2.0
-// (the "License"); you may not use this file except in compliance with
-// the License. You may obtain a copy of the License at
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// http://www.apache.org/licenses/LICENSE-2.0
//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
//
-// //////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
package org.apache.flex.textLayout.edit
{
import org.apache.flex.textLayout.debug.Debugging;
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/19b26fe5/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/ElementRange.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/ElementRange.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/ElementRange.as
index f29f776..c458a16 100644
--- a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/ElementRange.as
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/ElementRange.as
@@ -18,26 +18,8 @@
////////////////////////////////////////////////////////////////////////////////
package org.apache.flex.textLayout.edit
{
- import org.apache.flex.textLayout.container.IContainerController;
- import org.apache.flex.textLayout.elements.IFlowLeafElement;
- import org.apache.flex.textLayout.property.PropertyUtil;
-
-/**
- * The ElementRange class represents the range of objects selected within a text flow.
- *
- * <p>The beginning elements
- * (such as <code>firstLeaf</code>) are always less than or equal to the end elements (in this case, <code>lastLeaf</code>)
- * for each pair of values in an element range.</p>
- *
- * @see org.apache.flex.textLayout.elements.TextFlow
- *
- * @playerversion Flash 10
- * @playerversion AIR 1.5
- * @langversion 3.0
- */
-public class ElementRange
-{
import org.apache.flex.textLayout.compose.IFlowComposer;
+ import org.apache.flex.textLayout.container.IContainerController;
import org.apache.flex.textLayout.elements.IFlowLeafElement;
import org.apache.flex.textLayout.elements.IParagraphElement;
import org.apache.flex.textLayout.elements.ISubParagraphGroupElementBase;
@@ -45,382 +27,395 @@ public class ElementRange
import org.apache.flex.textLayout.formats.Category;
import org.apache.flex.textLayout.formats.ITextLayoutFormat;
import org.apache.flex.textLayout.formats.TextLayoutFormat;
- import org.apache.flex.textLayout.property.Property;
-
-
+ import org.apache.flex.textLayout.property.PropertyUtil;
-
- private var _absoluteStart:int;
- private var _absoluteEnd:int;
- private var _firstLeaf:IFlowLeafElement;
- private var _lastLeaf:IFlowLeafElement;
- private var _firstParagraph:IParagraphElement;
- private var _lastParagraph:IParagraphElement;
- private var _textFlow:ITextFlow;
-
- /**
- * The absolute text position of the IFlowLeafElement object that contains the start of the range.
- *
- * @playerversion Flash 10
- * @playerversion AIR 1.5
- * @langversion 3.0
- */
- public function get absoluteStart():int
- {
- return _absoluteStart;
- }
- public function set absoluteStart(value:int):void
- {
- _absoluteStart = value;
- }
-
- /**
- * The absolute text position of the IFlowLeafElement object that contains the end of the range.
+ /**
+ * The ElementRange class represents the range of objects selected within a text flow.
*
- * @playerversion Flash 10
- * @playerversion AIR 1.5
- * @langversion 3.0
- */
- public function get absoluteEnd():int
- {
- return _absoluteEnd;
- }
- public function set absoluteEnd(value:int):void
- {
- _absoluteEnd = value;
- }
-
- /**
- * The IFlowLeafElement object that contains the start of the range.
+ * <p>The beginning elements
+ * (such as <code>firstLeaf</code>) are always less than or equal to the end elements (in this case, <code>lastLeaf</code>)
+ * for each pair of values in an element range.</p>
+ *
+ * @see org.apache.flex.textLayout.elements.TextFlow
*
* @playerversion Flash 10
* @playerversion AIR 1.5
- * @langversion 3.0
+ * @langversion 3.0
*/
- public function get firstLeaf():IFlowLeafElement
+ public class ElementRange
{
- return _firstLeaf;
- }
- public function set firstLeaf(value:IFlowLeafElement):void
- {
- _firstLeaf = value;
- }
+ private var _absoluteStart:int;
+ private var _absoluteEnd:int;
+ private var _firstLeaf:IFlowLeafElement;
+ private var _lastLeaf:IFlowLeafElement;
+ private var _firstParagraph:IParagraphElement;
+ private var _lastParagraph:IParagraphElement;
+ private var _textFlow:ITextFlow;
- /**
- * The IFlowLeafElement object that contains the end of the range.
- *
- * @playerversion Flash 10
- * @playerversion AIR 1.5
- * @langversion 3.0
- */
- public function get lastLeaf():IFlowLeafElement
- {
- return _lastLeaf;
- }
- public function set lastLeaf(value:IFlowLeafElement):void
- {
- _lastLeaf = value;
- }
+ /**
+ * The absolute text position of the IFlowLeafElement object that contains the start of the range.
+ *
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @langversion 3.0
+ */
+ public function get absoluteStart():int
+ {
+ return _absoluteStart;
+ }
- /**
- * The IParagraphElement object that contains the start of the range.
- *
- * @playerversion Flash 10
- * @playerversion AIR 1.5
- * @langversion 3.0
- */
- public function get firstParagraph():IParagraphElement
- {
- return _firstParagraph;
- }
- public function set firstParagraph(value:IParagraphElement):void
- {
- _firstParagraph = value;
- }
-
- /**
- * The IParagraphElement object that contains the end of the range.
- *
- * @playerversion Flash 10
- * @playerversion AIR 1.5
- * @langversion 3.0
- */
- public function get lastParagraph():IParagraphElement
- {
- return _lastParagraph;
- }
- public function set lastParagraph(value:IParagraphElement):void
- {
- _lastParagraph = value;
- }
-
- /**
- * The TextFlow object that contains the range.
- *
- * @playerversion Flash 10
- * @playerversion AIR 1.5
- * @langversion 3.0
- */
- public function get textFlow():ITextFlow
- {
- return _textFlow;
- }
- public function set textFlow(value:ITextFlow):void
- {
- _textFlow = value;
- }
-
- // This constructor function is here just to silence a compile warning in Eclipse. There
- // appears to be no way to turn the warning off selectively.
- /** @private */
- CONFIG::debug public function ElementRange()
- {
- super();
- }
-
- // NOTE: We've been back and forth on this - should a range selection show null attributes or beginning of range attributes?
- // After looking at this for a while I want it to show beginning of range attributes. Two main reasons
- // 1. If the range contains different objects but homogoneous settings we should show the attributes.
- // 2. If we show null attributes on a range selection there's no way to, for example, turn BOLD off.
- // Try this at home - restore the old code. Select the entire text. Turn Bold on. Can't turn bold off.
- // Please don't revert this without further discussion.
- // Ideally we would have a way of figuring out which attributes are homogoneous over the selection range
- // and which were not and showing, for example, a "half-checked" bold item. We'd have to work this out for all the properties.
-
- // OLD CODE that shows null attribute settings on a range selection
- // var charAttr:ICharacterFormat = selRange.begElem == selRange.endElem ? selRange.begElem.computedCharacterFormat : new CharacterFormat();
- // var paraAttr:IParagraphFormat = selRange.begPara == selRange.endPara ? selRange.begPara.computedParagraphFormat : new ParagraphFormat();
+ public function set absoluteStart(value:int):void
+ {
+ _absoluteStart = value;
+ }
+ /**
+ * The absolute text position of the IFlowLeafElement object that contains the end of the range.
+ *
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @langversion 3.0
+ */
+ public function get absoluteEnd():int
+ {
+ return _absoluteEnd;
+ }
- /**
- * The format attributes of the container displaying the range.
- *
- * <p>If the range spans more than one container, the format of the first container is returned.</p>
- *
- * @playerversion Flash 10
- * @playerversion AIR 1.5
- * @langversion 3.0
- */
- public function get containerFormat():ITextLayoutFormat
- {
- // see NOTE above before changing!!
- var container:IContainerController;
- var flowComposer:IFlowComposer = _textFlow.flowComposer;
- if (flowComposer)
+ public function set absoluteEnd(value:int):void
{
- var idx:int = flowComposer.findControllerIndexAtPosition(absoluteStart);
- if (idx != -1)
- container = flowComposer.getControllerAt(idx);
+ _absoluteEnd = value;
}
- return container ? container.computedFormat : _textFlow.computedFormat;
- }
-
- /**
- * The format attributes of the paragraph containing the range.
- *
- * <p>If the range spans more than one paragraph, the format of the first paragraph is returned.</p>
- *
- * @playerversion Flash 10
- * @playerversion AIR 1.5
- * @langversion 3.0
- */
- public function get paragraphFormat():ITextLayoutFormat
- {
- // see NOTE above before changing!!
- return firstParagraph.computedFormat;
- }
-
- /**
- * The format attributes of the characters in the range.
- *
- * <p>If the range spans more than one FlowElement object, which means that more than one
- * character format may exist within the range, the format of the first FlowElement object is returned.</p>
- *
- * @playerversion Flash 10
- * @playerversion AIR 1.5
- * @langversion 3.0
- */
- public function get characterFormat():ITextLayoutFormat
- {
- // see NOTE above before changing!!
- return firstLeaf.computedFormat;
- }
-
- /**
- * Gets the character format attributes that are common to all characters in the text range or current selection.
- *
- * <p>Format attributes that do not have the same value for all characters in the element range are set to
- * <code>null</code> in the returned TextLayoutFormat instance.</p>
- *
- * @return The common character style settings
- *
- * @playerversion Flash 10
- * @playerversion AIR 1.5
- * @langversion 3.0
- */
- public function getCommonCharacterFormat():TextLayoutFormat
- {
- var leaf:IFlowLeafElement = firstLeaf;
- var attr:TextLayoutFormat = new TextLayoutFormat(leaf.computedFormat);
-
- for (;;)
+
+ /**
+ * The IFlowLeafElement object that contains the start of the range.
+ *
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @langversion 3.0
+ */
+ public function get firstLeaf():IFlowLeafElement
{
- if (leaf == lastLeaf)
- break;
- leaf = leaf.getNextLeaf();
- attr.removeClashing(leaf.computedFormat);
+ return _firstLeaf;
}
- return PropertyUtil.extractInCategory(TextLayoutFormat, TextLayoutFormat.description, attr, Category.CHARACTER, false) as TextLayoutFormat;
- }
-
- /**
- * Gets the paragraph format attributes that are common to all paragraphs in the element range.
- *
- * <p>Format attributes that do not have the same value for all paragraphs in the element range are set to
- * <code>null</code> in the returned TextLayoutFormat instance.</p>
- *
- * @return The common paragraph style settings
- *
- * @see org.apache.flex.textLayout.edit.ISelectionManager#getCommonParagraphFormat
- *
- * @playerversion Flash 10
- * @playerversion AIR 1.5
- * @langversion 3.0
- */
- public function getCommonParagraphFormat():TextLayoutFormat
- {
- var para:IParagraphElement = firstParagraph;
- var attr:TextLayoutFormat = new TextLayoutFormat(para.computedFormat);
- for (;;)
+ public function set firstLeaf(value:IFlowLeafElement):void
{
- if (para == lastParagraph)
- break;
- para = _textFlow.findAbsoluteParagraph(para.getAbsoluteStart()+para.textLength);
- attr.removeClashing(para.computedFormat);
+ _firstLeaf = value;
}
- return PropertyUtil.extractInCategory(TextLayoutFormat,TextLayoutFormat.description,attr,Category.PARAGRAPH, false) as TextLayoutFormat;
- }
-
- /**
- * Gets the container format attributes that are common to all containers in the element range.
- *
- * <p>Format attributes that do not have the same value for all containers in the element range are set to
- * <code>null</code> in the returned TextLayoutFormat instance.</p>
- *
- * @return The common paragraph style settings
- *
- * @see org.apache.flex.textLayout.edit.ISelectionManager#getCommonParagraphFormat *
- * @playerversion Flash 10
- * @playerversion AIR 1.5
- * @langversion 3.0
- */
- public function getCommonContainerFormat():TextLayoutFormat
- {
- var flowComposer:IFlowComposer = _textFlow.flowComposer;
- if (!flowComposer)
- return null;
- var index:int = flowComposer.findControllerIndexAtPosition(this.absoluteStart);
- if (index == -1)
- return null;
- var controller:IContainerController = flowComposer.getControllerAt(index);
- var attr:TextLayoutFormat = new TextLayoutFormat(controller.computedFormat);
- while (controller.absoluteStart+controller.textLength < absoluteEnd)
+ /**
+ * The IFlowLeafElement object that contains the end of the range.
+ *
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @langversion 3.0
+ */
+ public function get lastLeaf():IFlowLeafElement
{
- index++;
- if (index == flowComposer.numControllers)
- break;
- controller = flowComposer.getControllerAt(index);
- attr.removeClashing(controller.computedFormat);
+ return _lastLeaf;
}
-
- return PropertyUtil.extractInCategory(TextLayoutFormat,TextLayoutFormat.description,attr,Category.CONTAINER, false) as TextLayoutFormat;
- }
-
- /**
- * Creates an ElementRange object.
- *
- * @param textFlow the text flow
- * @param beginIndex absolute text position of the first character in the text range
- * @param endIndex one beyond the absolute text position of the last character in the text range
- *
- * @playerversion Flash 10
- * @playerversion AIR 1.5
- * @langversion 3.0
- */
- static public function createElementRange(textFlow:ITextFlow, absoluteStart:int, absoluteEnd:int):ElementRange
- {
- var rslt:ElementRange = new ElementRange();
- if (absoluteStart == absoluteEnd)
+
+ public function set lastLeaf(value:IFlowLeafElement):void
+ {
+ _lastLeaf = value;
+ }
+
+ /**
+ * The IParagraphElement object that contains the start of the range.
+ *
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @langversion 3.0
+ */
+ public function get firstParagraph():IParagraphElement
{
- rslt.absoluteStart = rslt.absoluteEnd = absoluteStart;
- rslt.firstLeaf = textFlow.findLeaf(rslt.absoluteStart);
- rslt.firstParagraph = rslt.firstLeaf.getParagraph();
- // rslt.begContainer = rslt.endContainer = selState.textFlow.findAbsoluteContainer(rslt.begElemIdx);
- adjustForLeanLeft(rslt);
- rslt.lastLeaf = rslt.firstLeaf;
- rslt.lastParagraph = rslt.firstParagraph;
+ return _firstParagraph;
}
- else
+
+ public function set firstParagraph(value:IParagraphElement):void
+ {
+ _firstParagraph = value;
+ }
+
+ /**
+ * The IParagraphElement object that contains the end of the range.
+ *
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @langversion 3.0
+ */
+ public function get lastParagraph():IParagraphElement
{
- // order the selection points
- if (absoluteStart < absoluteEnd)
+ return _lastParagraph;
+ }
+
+ public function set lastParagraph(value:IParagraphElement):void
+ {
+ _lastParagraph = value;
+ }
+
+ /**
+ * The TextFlow object that contains the range.
+ *
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @langversion 3.0
+ */
+ public function get textFlow():ITextFlow
+ {
+ return _textFlow;
+ }
+
+ public function set textFlow(value:ITextFlow):void
+ {
+ _textFlow = value;
+ }
+ // This constructor function is here just to silence a compile warning in Eclipse. There
+ // appears to be no way to turn the warning off selectively.
+ /** @private */
+ CONFIG::debug
+ public function ElementRange()
+ {
+ super();
+ }
+
+ // NOTE: We've been back and forth on this - should a range selection show null attributes or beginning of range attributes?
+ // After looking at this for a while I want it to show beginning of range attributes. Two main reasons
+ // 1. If the range contains different objects but homogoneous settings we should show the attributes.
+ // 2. If we show null attributes on a range selection there's no way to, for example, turn BOLD off.
+ // Try this at home - restore the old code. Select the entire text. Turn Bold on. Can't turn bold off.
+ // Please don't revert this without further discussion.
+ // Ideally we would have a way of figuring out which attributes are homogoneous over the selection range
+ // and which were not and showing, for example, a "half-checked" bold item. We'd have to work this out for all the properties.
+ // OLD CODE that shows null attribute settings on a range selection
+ // var charAttr:ICharacterFormat = selRange.begElem == selRange.endElem ? selRange.begElem.computedCharacterFormat : new CharacterFormat();
+ // var paraAttr:IParagraphFormat = selRange.begPara == selRange.endPara ? selRange.begPara.computedParagraphFormat : new ParagraphFormat();
+ /**
+ * The format attributes of the container displaying the range.
+ *
+ * <p>If the range spans more than one container, the format of the first container is returned.</p>
+ *
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @langversion 3.0
+ */
+ public function get containerFormat():ITextLayoutFormat
+ {
+ // see NOTE above before changing!!
+ var container:IContainerController;
+ var flowComposer:IFlowComposer = _textFlow.flowComposer;
+ if (flowComposer)
{
- rslt.absoluteStart = absoluteStart;
- rslt.absoluteEnd = absoluteEnd;
+ var idx:int = flowComposer.findControllerIndexAtPosition(absoluteStart);
+ if (idx != -1)
+ container = flowComposer.getControllerAt(idx);
}
- else
+ return container ? container.computedFormat : _textFlow.computedFormat;
+ }
+
+ /**
+ * The format attributes of the paragraph containing the range.
+ *
+ * <p>If the range spans more than one paragraph, the format of the first paragraph is returned.</p>
+ *
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @langversion 3.0
+ */
+ public function get paragraphFormat():ITextLayoutFormat
+ {
+ // see NOTE above before changing!!
+ return firstParagraph.computedFormat;
+ }
+
+ /**
+ * The format attributes of the characters in the range.
+ *
+ * <p>If the range spans more than one FlowElement object, which means that more than one
+ * character format may exist within the range, the format of the first FlowElement object is returned.</p>
+ *
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @langversion 3.0
+ */
+ public function get characterFormat():ITextLayoutFormat
+ {
+ // see NOTE above before changing!!
+ return firstLeaf.computedFormat;
+ }
+
+ /**
+ * Gets the character format attributes that are common to all characters in the text range or current selection.
+ *
+ * <p>Format attributes that do not have the same value for all characters in the element range are set to
+ * <code>null</code> in the returned TextLayoutFormat instance.</p>
+ *
+ * @return The common character style settings
+ *
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @langversion 3.0
+ */
+ public function getCommonCharacterFormat():TextLayoutFormat
+ {
+ var leaf:IFlowLeafElement = firstLeaf;
+ var attr:TextLayoutFormat = new TextLayoutFormat(leaf.computedFormat);
+
+ for (;;)
{
- rslt.absoluteStart = absoluteEnd;
- rslt.absoluteEnd = absoluteStart;
+ if (leaf == lastLeaf)
+ break;
+ leaf = leaf.getNextLeaf();
+ attr.removeClashing(leaf.computedFormat);
}
- rslt.firstLeaf = textFlow.findLeaf(rslt.absoluteStart);
- rslt.lastLeaf = textFlow.findLeaf(rslt.absoluteEnd);
- // back up one element if the end of the selection is the start of an element
- // otherwise a block selection of a span looks like it includes discreet selection ranges
- if (((rslt.lastLeaf == null) && (rslt.absoluteEnd == textFlow.textLength)) || (rslt.absoluteEnd == rslt.lastLeaf.getAbsoluteStart()))
- rslt.lastLeaf = textFlow.findLeaf(rslt.absoluteEnd-1);
-
- rslt.firstParagraph = rslt.firstLeaf.getParagraph();
- rslt.lastParagraph = rslt.lastLeaf.getParagraph();
-
- // rslt.begContainer = selState.textFlow.findAbsoluteContainer(rslt.begElemIdx);
- // rslt.endContainer = selState.textFlow.findAbsoluteContainer(rslt.endElemIdx);
- // if (rslt.endElemIdx == rslt.endContainer.relativeStart)
- // rslt.endContainer = rslt.endContainer.preventextContainer;
-
- // if the end of the range includes the next to last character in a paragraph
- // expand it to include the paragraph teriminate character
- if (rslt.absoluteEnd == rslt.lastParagraph.getAbsoluteStart() + rslt.lastParagraph.textLength - 1)
+
+ return PropertyUtil.extractInCategory(TextLayoutFormat, TextLayoutFormat.description, attr, Category.CHARACTER, false) as TextLayoutFormat;
+ }
+
+ /**
+ * Gets the paragraph format attributes that are common to all paragraphs in the element range.
+ *
+ * <p>Format attributes that do not have the same value for all paragraphs in the element range are set to
+ * <code>null</code> in the returned TextLayoutFormat instance.</p>
+ *
+ * @return The common paragraph style settings
+ *
+ * @see org.apache.flex.textLayout.edit.ISelectionManager#getCommonParagraphFormat
+ *
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @langversion 3.0
+ */
+ public function getCommonParagraphFormat():TextLayoutFormat
+ {
+ var para:IParagraphElement = firstParagraph;
+ var attr:TextLayoutFormat = new TextLayoutFormat(para.computedFormat);
+ for (;;)
{
- rslt.absoluteEnd++;
- rslt.lastLeaf = rslt.lastParagraph.getLastLeaf();
+ if (para == lastParagraph)
+ break;
+ para = _textFlow.findAbsoluteParagraph(para.getAbsoluteStart() + para.textLength);
+ attr.removeClashing(para.computedFormat);
}
+ return PropertyUtil.extractInCategory(TextLayoutFormat, TextLayoutFormat.description, attr, Category.PARAGRAPH, false) as TextLayoutFormat;
+ }
+
+ /**
+ * Gets the container format attributes that are common to all containers in the element range.
+ *
+ * <p>Format attributes that do not have the same value for all containers in the element range are set to
+ * <code>null</code> in the returned TextLayoutFormat instance.</p>
+ *
+ * @return The common paragraph style settings
+ *
+ * @see org.apache.flex.textLayout.edit.ISelectionManager#getCommonParagraphFormat *
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @langversion 3.0
+ */
+ public function getCommonContainerFormat():TextLayoutFormat
+ {
+ var flowComposer:IFlowComposer = _textFlow.flowComposer;
+ if (!flowComposer)
+ return null;
+ var index:int = flowComposer.findControllerIndexAtPosition(this.absoluteStart);
+ if (index == -1)
+ return null;
+ var controller:IContainerController = flowComposer.getControllerAt(index);
+ var attr:TextLayoutFormat = new TextLayoutFormat(controller.computedFormat);
+ while (controller.absoluteStart + controller.textLength < absoluteEnd)
+ {
+ index++;
+ if (index == flowComposer.numControllers)
+ break;
+ controller = flowComposer.getControllerAt(index);
+ attr.removeClashing(controller.computedFormat);
+ }
+
+ return PropertyUtil.extractInCategory(TextLayoutFormat, TextLayoutFormat.description, attr, Category.CONTAINER, false) as TextLayoutFormat;
}
- rslt.textFlow = textFlow;
-
- return rslt;
- }
-
- static private function adjustForLeanLeft(rslt:ElementRange):void
- {
- // If we're at the start of a leaf element, look to the previous leaf element and see if it shares the same
- // parent. If so, we're going to move the selection to the end of the previous element so it takes on
- // the formatting of the character to the left. We don't want to do this if the previous element is in
- // a different character, across link or tcy boundaries, etc.
- if (rslt.firstLeaf.getAbsoluteStart() == rslt.absoluteStart)
+
+ /**
+ * Creates an ElementRange object.
+ *
+ * @param textFlow the text flow
+ * @param beginIndex absolute text position of the first character in the text range
+ * @param endIndex one beyond the absolute text position of the last character in the text range
+ *
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @langversion 3.0
+ */
+ static public function createElementRange(textFlow:ITextFlow, absoluteStart:int, absoluteEnd:int):ElementRange
+ {
+ var rslt:ElementRange = new ElementRange();
+ if (absoluteStart == absoluteEnd)
+ {
+ rslt.absoluteStart = rslt.absoluteEnd = absoluteStart;
+ rslt.firstLeaf = textFlow.findLeaf(rslt.absoluteStart);
+ rslt.firstParagraph = rslt.firstLeaf.getParagraph();
+ // rslt.begContainer = rslt.endContainer = selState.textFlow.findAbsoluteContainer(rslt.begElemIdx);
+ adjustForLeanLeft(rslt);
+ rslt.lastLeaf = rslt.firstLeaf;
+ rslt.lastParagraph = rslt.firstParagraph;
+ }
+ else
+ {
+ // order the selection points
+ if (absoluteStart < absoluteEnd)
+ {
+ rslt.absoluteStart = absoluteStart;
+ rslt.absoluteEnd = absoluteEnd;
+ }
+ else
+ {
+ rslt.absoluteStart = absoluteEnd;
+ rslt.absoluteEnd = absoluteStart;
+ }
+ rslt.firstLeaf = textFlow.findLeaf(rslt.absoluteStart);
+ rslt.lastLeaf = textFlow.findLeaf(rslt.absoluteEnd);
+ // back up one element if the end of the selection is the start of an element
+ // otherwise a block selection of a span looks like it includes discreet selection ranges
+ if (((rslt.lastLeaf == null) && (rslt.absoluteEnd == textFlow.textLength)) || (rslt.absoluteEnd == rslt.lastLeaf.getAbsoluteStart()))
+ rslt.lastLeaf = textFlow.findLeaf(rslt.absoluteEnd - 1);
+
+ rslt.firstParagraph = rslt.firstLeaf.getParagraph();
+ rslt.lastParagraph = rslt.lastLeaf.getParagraph();
+
+ // rslt.begContainer = selState.textFlow.findAbsoluteContainer(rslt.begElemIdx);
+ // rslt.endContainer = selState.textFlow.findAbsoluteContainer(rslt.endElemIdx);
+ // if (rslt.endElemIdx == rslt.endContainer.relativeStart)
+ // rslt.endContainer = rslt.endContainer.preventextContainer;
+
+ // if the end of the range includes the next to last character in a paragraph
+ // expand it to include the paragraph teriminate character
+ if (rslt.absoluteEnd == rslt.lastParagraph.getAbsoluteStart() + rslt.lastParagraph.textLength - 1)
+ {
+ rslt.absoluteEnd++;
+ rslt.lastLeaf = rslt.lastParagraph.getLastLeaf();
+ }
+ }
+ rslt.textFlow = textFlow;
+
+ return rslt;
+ }
+
+ static private function adjustForLeanLeft(rslt:ElementRange):void
{
- var previousNode:IFlowLeafElement = rslt.firstLeaf.getPreviousLeaf(rslt.firstParagraph);
- if (previousNode && previousNode.getParagraph() == rslt.firstLeaf.getParagraph())
+ // If we're at the start of a leaf element, look to the previous leaf element and see if it shares the same
+ // parent. If so, we're going to move the selection to the end of the previous element so it takes on
+ // the formatting of the character to the left. We don't want to do this if the previous element is in
+ // a different character, across link or tcy boundaries, etc.
+ if (rslt.firstLeaf.getAbsoluteStart() == rslt.absoluteStart)
{
- if((!(previousNode.parent is ISubParagraphGroupElementBase) || (previousNode.parent as ISubParagraphGroupElementBase).acceptTextAfter())
- && (!(rslt.firstLeaf.parent is ISubParagraphGroupElementBase) || previousNode.parent === rslt.firstLeaf.parent))
- rslt.firstLeaf = previousNode;
+ var previousNode:IFlowLeafElement = rslt.firstLeaf.getPreviousLeaf(rslt.firstParagraph);
+ if (previousNode && previousNode.getParagraph() == rslt.firstLeaf.getParagraph())
+ {
+ if ((!(previousNode.parent is ISubParagraphGroupElementBase) || (previousNode.parent as ISubParagraphGroupElementBase).acceptTextAfter()) && (!(rslt.firstLeaf.parent is ISubParagraphGroupElementBase) || previousNode.parent === rslt.firstLeaf.parent))
+ rslt.firstLeaf = previousNode;
+ }
}
-
}
}
-}
}
\ No newline at end of file