You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ha...@apache.org on 2017/03/16 13:37:50 UTC
[30/42] flex-asjs git commit: And here’s TLF…
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/BaseTextLayoutExporter.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/BaseTextLayoutExporter.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/BaseTextLayoutExporter.as
new file mode 100644
index 0000000..5437104
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/BaseTextLayoutExporter.as
@@ -0,0 +1,536 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion
+{
+ import org.apache.flex.reflection.getQualifiedClassName;
+ import org.apache.flex.textLayout.TextLayoutVersion;
+ import org.apache.flex.textLayout.debug.assert;
+ import org.apache.flex.textLayout.elements.FlowGroupElement;
+ import org.apache.flex.textLayout.elements.IContainerFormattedElement;
+ import org.apache.flex.textLayout.elements.IFlowElement;
+ import org.apache.flex.textLayout.elements.IParagraphFormattedElement;
+ import org.apache.flex.textLayout.elements.SpanElement;
+ import org.apache.flex.textLayout.elements.TableCellElement;
+ import org.apache.flex.textLayout.elements.TableElement;
+ import org.apache.flex.textLayout.elements.TableRowElement;
+ import org.apache.flex.textLayout.elements.ITextFlow;
+
+ /**
+ * Base export converter for TextLayout format.
+ */
+ public class BaseTextLayoutExporter extends ConverterBase implements ITextExporter
+ {
+ private var _rootTag:XML;
+ private var _ns:Namespace;
+
+ public function BaseTextLayoutExporter(ns:Namespace, rootTag:XML, configuration:ImportExportConfiguration)
+ {
+ config = configuration;
+ _ns = ns;
+ _rootTag = rootTag;
+ }
+
+ /**
+ * @copy ITextExporter#export()
+ */
+ public function export(source:ITextFlow, conversionType:String):Object
+ {
+ clear();
+
+ var result:XML = exportToXML(source);
+ return conversionType == ConversionType.STRING_TYPE ? convertXMLToString(result) : result;
+ }
+
+ /**
+ * Export text content of a TextFlow into XFL format.
+ *
+ * @param source the text to export
+ * @return XML the exported content
+ */
+ protected function exportToXML(textFlow:ITextFlow) : XML
+ {
+ var result:XML;
+ if (_rootTag)
+ {
+ result = new XML(_rootTag);
+ result.addNamespace(_ns);
+ result.appendChild(exportChild(textFlow));
+ }
+ else
+ {
+ result = XML(exportTextFlow(this, textFlow));
+ result.addNamespace(_ns);
+ }
+ return result;
+ }
+
+ /**
+ * Export text content as a string
+ *
+ * @param xml the XML to convert
+ * @return String the exported content
+ * @private
+ */
+ static public function convertXMLToString(xml:XML):String
+ {
+ var result:String;
+ // Adjust settings so that leading and trailing spaces in the XML don't get dropped when it is converted to a string
+ var originalSettings:Object = XML.settings();
+ try
+ {
+ XML.ignoreProcessingInstructions = false;
+ XML.ignoreWhitespace = false;
+ XML.prettyPrinting = false;
+ result = xml.toXMLString();
+//TODO probably does not make sense for FlexJS
+// if (Configuration.playerEnablesArgoFeatures)
+// System["disposeXML"](xml);
+ XML.setSettings(originalSettings);
+ }
+ catch(e:Error)
+ {
+ XML.setSettings(originalSettings);
+ throw(e);
+ }
+ return result;
+ }
+
+
+ /**
+ * Base functionality for exporting a FlowElement.
+ *
+ * @param exporter Root object for the export
+ * @param flowElement Element to export
+ * @return XMLList XML for the element
+ */
+ static public function exportFlowElement(exporter:BaseTextLayoutExporter, flowElement:IFlowElement):XMLList
+ {
+ return exporter.exportFlowElement(flowElement);
+ }
+
+ /**
+ * Overridable worker method for exporting a FlowElement. Creates the XMLList.
+ *
+ * @param flowElement Element to export
+ * @return XMLList XML for the element
+ */
+ protected function exportFlowElement (flowElement:IFlowElement):XMLList
+ {
+ var className:String = getQualifiedClassName(flowElement);
+ var elementName:String = config.lookupName(className); // NO PMD
+ var output:XML = <{elementName}/>;
+ output.setNamespace(_ns);
+ return XMLList(output);
+ }
+
+ static public function exportSpanText(destination:XML, span:SpanElement, replacementRegex:RegExp, replacementXMLCallback:Function):void
+ {
+ //get the text for this span
+ var spanText:String = span.text;
+
+ // Check to see if it has text that needs to be converted
+ var matchLocation:Array = spanText.match(replacementRegex);
+
+ if(matchLocation)
+ {
+ var dummy:XML;
+
+ // We have text that has characters to be converted. Break it up into runs of text interspersed with elements corresponding to match these characters
+ while(matchLocation != null)
+ {
+ var ix:int = matchLocation.index;
+ var tempStr:String = spanText.substr(0, ix);
+
+ //if we have some text which does not need to be replaced, then write it now
+ if(tempStr.length > 0)
+ {
+ // output[0].appendChild(tempStr); // extraneous tags can appear around a string child added after an XML element: see bug 1852072
+
+ // workaround for above-mentioned bug
+ dummy = <dummy/>;
+ dummy.appendChild(tempStr); // no extraneous tags here since there is no preceding XML element sibling
+ destination.appendChild(dummy.text()[0]);
+ }
+
+ var replacementXML:XML = replacementXMLCallback(spanText.charAt(ix));
+ CONFIG::debug{ assert(replacementXML != null, "Specified match regex, but provided null replacement XML"); }
+ destination.appendChild(replacementXML);
+
+ //remove the text up to this point
+ spanText = spanText.slice(ix + 1, spanText.length);
+
+ //look for another character to be replaced
+ matchLocation = spanText.match(replacementRegex);
+
+ //if we don't have any more matches, but there is still text, write that out as the last span
+ if(!matchLocation && spanText.length > 0)
+ {
+ // output[0].appendChild(spanText); // extraneous tags can appear around a string child added after an XML element: see bug 1852072
+
+ // workaround for above-mentioned bug
+ dummy = <dummy/>;
+ dummy.appendChild(spanText); // no extraneous tags here since there is no preceding XML element sibling
+ destination.appendChild(dummy.text()[0]);
+ }
+ }
+ }
+ else
+ {
+ //this is the simple case where we don't have a character to replace
+ destination.appendChild(spanText);
+ }
+ }
+
+ /**
+ * Base functionality for exporting a Span. Exports as a FlowElement,
+ * and exports the text of the span.
+ *
+ * @param exporter Root object for the export
+ * @param span Element to export
+ * @return XMLList XML for the element
+ */
+ static public function exportSpan(exporter:BaseTextLayoutExporter, span:SpanElement):XMLList
+ {
+ var output:XMLList = exportFlowElement(exporter, span);
+ exportSpanText(output[0], span, exporter.spanTextReplacementRegex, exporter.getSpanTextReplacementXML);
+ return output;
+ }
+
+//TODO regex
+ static private const brRegEx:RegExp = /foo/;// /\u2028/;
+ // static private const brRegEx:RegExp = /\u2028/;
+
+ /**
+ * Gets the regex that specifies characters in span text to be replaced with XML elements.
+ * Note: Each match is a single character
+ */
+ protected function get spanTextReplacementRegex():RegExp
+ {
+ return brRegEx;
+ }
+
+ /**
+ * Gets the xml element used to represent a character in the export format
+ */
+ protected function getSpanTextReplacementXML(ch:String):XML
+ {
+ CONFIG::debug {assert(ch == '\u2028', "Did not recognize character to be replaced with XML"); }
+ var breakXML:XML = <br/>;
+ breakXML.setNamespace(flowNS);
+ return breakXML;
+ }
+
+ /**
+ * Base functionality for exporting a FlowGroupElement. Exports as a FlowElement,
+ * and exports the children of a element.
+ *
+ * @param exporter Root object for the export
+ * @param flowBlockElement Element to export
+ * @return XMLList XML for the element
+ */
+ static public function exportFlowGroupElement(exporter:BaseTextLayoutExporter, flowBlockElement:FlowGroupElement):XMLList
+ {
+ var output:XMLList = exportFlowElement(exporter, flowBlockElement);
+ var count:int = flowBlockElement.numChildren;
+
+ // output each child
+ for(var index:int; index < count; ++index)
+ {
+ var flowChild:IFlowElement = flowBlockElement.getChildAt(index);
+ var childXML:XMLList = exporter.exportChild(flowChild);
+
+ if (childXML) {
+ output.appendChild(childXML);
+ }
+ }
+
+ return output;
+ }
+
+ /**
+ * Base functionality for exporting a IParagraphFormattedElement. Exports as a FlowGroupElement,
+ * and exports paragraph attributes.
+ *
+ * @param exporter Root object for the export
+ * @param flowParagraph Element to export
+ * @return XMLList XML for the element
+ */
+ static public function exportParagraphFormattedElement(exporter:BaseTextLayoutExporter, flowParagraph:IParagraphFormattedElement):XMLList
+ {
+ return exporter.exportParagraphFormattedElement(flowParagraph);
+ }
+
+ static public function exportList(exporter:BaseTextLayoutExporter, flowParagraph:IParagraphFormattedElement):XMLList
+ {
+ return exporter.exportList(flowParagraph);
+ }
+
+ protected function exportList(flowElement:IFlowElement):XMLList
+ {
+ var result:XMLList = exportFlowElement(flowElement);
+ var count:int = FlowGroupElement(flowElement).numChildren;
+
+ // output each child
+ for(var index:int; index < count; ++index)
+ {
+ var flowChild:IFlowElement = FlowGroupElement(flowElement).getChildAt(index);
+ result.appendChild(exportChild(flowChild));
+ }
+
+ return result;
+ }
+
+ static public function exportListItem(exporter:BaseTextLayoutExporter, flowParagraph:IParagraphFormattedElement):XMLList
+ {
+ return exporter.exportListItem(flowParagraph);
+ }
+
+ protected function exportListItem(flowElement:IFlowElement):XMLList
+ {
+ var result:XMLList = exportFlowElement(flowElement);
+ var count:int = FlowGroupElement(flowElement).numChildren;
+
+ // output each child
+ for(var index:int; index < count; ++index)
+ {
+ var flowChild:IFlowElement = FlowGroupElement(flowElement).getChildAt(index);
+ result.appendChild(exportChild(flowChild));
+ }
+
+ return result;
+ }
+
+ /**
+ * Base functionality for exporting a IContainerFormattedElement. Exports as a IParagraphFormattedElement,
+ * and exports container attributes.
+ *
+ * @param exporter Root object for the export
+ * @param container Element to export
+ * @return XMLList XML for the element
+ */
+ static public function exportContainerFormattedElement(exporter:BaseTextLayoutExporter, container:IContainerFormattedElement):XMLList
+ {
+ return exporter.exportContainerFormattedElement(container);
+ }
+
+ /**
+ * Overridable worker method for exporting a IParagraphFormattedElement. Creates the XMLList.
+ *
+ * @param flowElement Element to export
+ * @return XMLList XML for the element
+ */
+ protected function exportContainerFormattedElement(flowElement:IFlowElement):XMLList
+ {
+ return exportParagraphFormattedElement(flowElement);
+ }
+
+ /**
+ * Base functionality for exporting a TableElement. Exports as a TableElement,
+ * and exports table attributes.
+ *
+ * @param exporter Root object for the export
+ * @param container Element to export
+ * @return XMLList XML for the element
+ */
+ static public function exportTableElement(exporter:BaseTextLayoutExporter, table:TableElement):XMLList
+ {
+ return exporter.exportTableElement(table);
+ }
+
+ /**
+ * Overridable worker method for exporting a TableElement. Creates the XMLList.
+ *
+ * @param flowElement Element to export
+ * @return XMLList XML for the element
+ */
+ protected function exportTableElement(tableElement:TableElement):XMLList
+ {
+ var result:XMLList = exportFlowElement(tableElement);
+ var count:int = tableElement.numRows;
+
+ // output each child
+ for(var index:int = 0; index < count; ++index)
+ {
+ var flowChild:IFlowElement = tableElement.getRowAt(index);
+ result.appendChild(exportChild(flowChild));
+ }
+
+ return result;
+ }
+
+ /**
+ * Base functionality for exporting a TableRowElement. Exports as a TableRowElement,
+ * and exports table row attributes.
+ *
+ * @param exporter Root object for the export
+ * @param container Element to export
+ * @return XMLList XML for the element
+ */
+ static public function exportTableRowElement(exporter:BaseTextLayoutExporter, tableRow:TableRowElement):XMLList
+ {
+ return exporter.exportTableRowElement(tableRow);
+ }
+
+ /**
+ * Overridable worker method for exporting a TableRowElement. Creates the XMLList.
+ *
+ * @param flowElement Element to export
+ * @return XMLList XML for the element
+ */
+ protected function exportTableRowElement(tableRowElement:TableRowElement):XMLList
+ {
+ var result:XMLList = exportFlowElement(tableRowElement);
+ var count:int = tableRowElement.numCells;
+
+ // output each child
+ for(var index:int; index < count; ++index)
+ {
+ var flowChild:IFlowElement = tableRowElement.getCellAt(index);
+ result.appendChild(exportChild(flowChild));
+ }
+
+ return result;
+ }
+
+ /**
+ * Base functionality for exporting a TableCellElement. Exports as a TableCellElement,
+ * and exports table cell attributes.
+ *
+ * @param exporter Root object for the export
+ * @param container Element to export
+ * @return XMLList XML for the element
+ */
+ static public function exportTableCellElement(exporter:BaseTextLayoutExporter, tableCell:TableCellElement):XMLList
+ {
+ return exporter.exportTableCellElement(tableCell);
+ }
+
+ /**
+ * Overridable worker method for exporting a TableCellElement. Creates the XMLList.
+ *
+ * @param flowElement Element to export
+ * @return XMLList XML for the element
+ */
+ protected function exportTableCellElement(tableCellElement:TableCellElement):XMLList
+ {
+ var result:XMLList = exportFlowElement(tableCellElement);
+
+ return result;
+ }
+
+ /**
+ * Overridable worker method for exporting a IParagraphFormattedElement. Creates the XMLList.
+ *
+ * @param flowElement Element to export
+ * @return XMLList XML for the element
+ */
+ protected function exportParagraphFormattedElement(flowElement:IFlowElement):XMLList
+ {
+ var result:XMLList = exportFlowElement(flowElement);
+ var count:int = IParagraphFormattedElement(flowElement).numChildren;
+
+ // output each child
+ for(var index:int; index < count; ++index)
+ {
+ var flowChild:IFlowElement = IParagraphFormattedElement(flowElement).getChildAt(index);
+ result.appendChild(exportChild(flowChild));
+ }
+
+ return result;
+ }
+
+ /**
+ * Base functionality for exporting a TextFlow. Exports as a ContainerElement,
+ * and exports container attributes.
+ *
+ * @param exporter Root object for the export
+ * @param textFlow Element to export
+ * @return XMLList XML for the element
+ */
+ static public function exportTextFlow(exporter:BaseTextLayoutExporter, textFlow:ITextFlow):XMLList
+ {
+ var output:XMLList = exportContainerFormattedElement(exporter, textFlow);
+
+ if (exporter.config.whiteSpaceCollapse) {
+ // TextLayout will use PRESERVE on output
+//TODO @
+ // output.@[TextLayoutFormat.whiteSpaceCollapseProperty.name] = exporter.config.whiteSpaceCollapse;
+ }
+
+ // TextLayout adds version information
+ output.@version = TextLayoutVersion.getVersionString(TextLayoutVersion.CURRENT_VERSION);
+
+ return output;
+ }
+
+
+ /**
+ * Exports the object. It will find the appropriate exporter and use it to
+ * export the object.
+ *
+ * @param exporter Root object for the export
+ * @param flowElement Element to export
+ * @return XMLList XML for the flowElement
+ */
+ public function exportChild(flowElement:IFlowElement):XMLList
+ {
+ var className:String = getQualifiedClassName(flowElement);
+ var info:FlowElementInfo = config.lookupByClass(className);
+ if (info != null)
+ return info.exporter(this, flowElement);
+ return null;
+ }
+
+ /**
+ * Helper function to export styles (core or user) in the form of xml attributes or xml children.
+ *
+ * @param xml object to which attributes/children are added
+ * @param sortableStyles an array of objects (xmlName,xmlVal) members that is sorted and exported.
+ */
+ protected function exportStyles(xml:XMLList, sortableStyles:Array):void
+ {
+ // Sort the styles based on name for predictable export order
+ sortableStyles.sortOn("xmlName");
+
+ for each(var exportInfo:Object in sortableStyles)
+ {
+ var xmlVal:Object = exportInfo.xmlVal;
+ CONFIG::debug{ assert(useClipboardAnnotations || exportInfo.xmlName != ConversionConstants.MERGE_TO_NEXT_ON_PASTE, "Found paste merge attribute in exported TextFlow"); }
+ /* Filter out paste attributes */
+ if (!useClipboardAnnotations && exportInfo.xmlName == ConversionConstants.MERGE_TO_NEXT_ON_PASTE)
+ continue;
+//TODO @
+ // if (xmlVal is String)
+ // xml.@[exportInfo.xmlName] = xmlVal; // as an attribute
+ // else if (xmlVal is XMLList)
+ xml.appendChild(xmlVal); // as a child
+ }
+ }
+
+ internal function get flowNS():Namespace
+ {
+ return _ns;
+ }
+
+ protected function get formatDescription():Object
+ {
+ return null;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/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
new file mode 100644
index 0000000..dc9cd2f
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/BaseTextLayoutImporter.as
@@ -0,0 +1,717 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.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;
+ import org.apache.flex.textLayout.elements.ElementHelper;
+ import org.apache.flex.textLayout.elements.FlowGroupElement;
+ import org.apache.flex.textLayout.elements.GlobalSettings;
+ import org.apache.flex.textLayout.elements.IConfiguration;
+ import org.apache.flex.textLayout.elements.IContainerFormattedElement;
+ import org.apache.flex.textLayout.elements.IFlowElement;
+ import org.apache.flex.textLayout.elements.IFlowGroupElement;
+ import org.apache.flex.textLayout.elements.IFlowLeafElement;
+ import org.apache.flex.textLayout.elements.IListElement;
+ import org.apache.flex.textLayout.elements.IListItemElement;
+ import org.apache.flex.textLayout.elements.IParagraphElement;
+ import org.apache.flex.textLayout.elements.IParagraphFormattedElement;
+ import org.apache.flex.textLayout.elements.ISpanElement;
+ import org.apache.flex.textLayout.elements.ITextFlow;
+ import org.apache.flex.textLayout.elements.SpanElement;
+ 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;
+
+ /**
+ * 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;
+
+ 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
+ {
+ PropertyUtil.errorHandler = importPropertyErrorHandler;
+ rslt = importToFlowCanThrow(source);
+ }
+ catch (e:Error)
+ {
+ reportError(e.toString());
+ }
+ 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
+ {
+ reportError(PropertyUtil.createErrorString(p,value));
+ }
+
+ private function importToFlowCanThrow(source:Object):TextFlow
+ {
+ if (source is String)
+ return importFromString(String(source));
+ else if (source is XML)
+ 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
+ * to importFromXML to be processed. The source must be capable of being cast as an XML
+ * object (E4X).
+ */
+ protected function importFromString(source:String):TextFlow
+ {
+ var originalSettings:Object = XML.settings();
+ try
+ {
+ XML.ignoreProcessingInstructions = false;
+ XML.ignoreWhitespace = false;
+ 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);
+ 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.
+ {
+ return parseContent(xmlSource[0]);
+ }
+
+ // This routine imports a TextFlow
+ protected function parseContent(rootStory:XML):TextFlow
+ {
+ // If the root element isn't a textFlow we know how to parse, keep descending the hierarchy.
+ var child:XML = rootStory..*::TextFlow[0];
+ if (child)
+ 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
+ {
+ 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;
+ // Tab, line feed, and carriage return
+//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
+ {
+ // Replace the newlines and tabs inside the element with spaces.
+ return insertString.replace(tabNewLinePattern, " ");
+ }
+
+ /** Parse XML and convert to TextFlow.
+ * @param importer parser object
+ * @param xmlToParse content to parse
+ * @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
+ {
+ return importer.createTextFlowFromXML(xmlToParse, null);
+ }
+
+ /**
+ * Static method to parse the supplied XML into a paragrph.
+ * Parse the <p ...> tag and it's children.
+ *
+ * @param importer parser object
+ * @param xmlToParse content to parse
+ * @param parent the parent for the new content
+ */
+ static public function parsePara(importer:BaseTextLayoutImporter, xmlToParse:XML, parent:FlowGroupElement):void
+ {
+ var paraElem:IParagraphElement = importer.createParagraphFromXML(xmlToParse);
+ if (importer.addChild(parent, paraElem))
+ {
+ importer.parseFlowGroupElementChildren(xmlToParse, paraElem);
+ //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
+ {
+ dst.format = src.format;
+ 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
+ *
+ * @param importer parser object
+ * @param xmlToParse content to parse
+ * @param parent the parent for the new content
+ */
+ 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)
+ {
+ // 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);
+ return;
+ }
+
+ 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
+ {
+ firstSpan.text = child.toString();
+ importer.addChild(parent, firstSpan);
+ }
+ else
+ {
+ var s:SpanElement = new SpanElement(); // No PMD
+ copyAllStyleProps(s,firstSpan);
+ s.text = child.toString();
+ importer.addChild(parent, s);
+ }
+ }
+ else if (elemName == "br")
+ {
+ var brElem:BreakElement = importer.createBreakFromXML(child); // may be null
+ if (brElem)
+ {
+ copyAllStyleProps(brElem,firstSpan);
+ importer.addChild(parent, brElem);
+ }
+ else
+ importer.reportError(GlobalSettings.resourceStringFunction("unexpectedXMLElementInSpan",[ elemName ]));
+ }
+ else if (elemName == "tab")
+ {
+ var tabElem:TabElement = importer.createTabFromXML(child); // may be null
+ if (tabElem)
+ {
+ copyAllStyleProps(tabElem,firstSpan);
+ importer.addChild(parent, tabElem);
+ }
+ else
+ importer.reportError(GlobalSettings.resourceStringFunction("unexpectedXMLElementInSpan",[ elemName ]));
+ }
+ else
+ 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
+ *
+ * @param importer parser object
+ * @param xmlToParse content to parse
+ * @param parent the parent for the new content
+ */
+ static public function parseBreak(importer:BaseTextLayoutImporter, xmlToParse:XML, parent:IFlowGroupElement):void
+ {
+ 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
+ *
+ * @param importer parser object
+ * @param xmlToParse content to parse
+ * @param parent the parent for the new content
+ */
+ static public function parseTab(importer:BaseTextLayoutImporter, xmlToParse:XML, parent:IFlowGroupElement):void
+ {
+ var tabElem:TabElement = importer.createTabFromXML(xmlToParse); // may be null
+ if (tabElem)
+ importer.addChild(parent, tabElem);
+ }
+
+ /**
+ * Static method for constructing a list element from XML.
+ *
+ * @param importer parser object
+ * @param xmlToParse content to parse
+ * @param parent the parent for the new content
+ */
+ static public function parseList(importer:BaseTextLayoutImporter, xmlToParse:XML, parent:IFlowGroupElement):void
+ {
+ var listElem:IListElement = importer.createListFromXML(xmlToParse);
+ if (importer.addChild(parent, listElem))
+ {
+ importer.parseFlowGroupElementChildren(xmlToParse, listElem);
+ }
+ }
+
+ /**
+ * Static method for constructing a list item from XML.
+ *
+ * @param importer parser object
+ * @param xmlToParse content to parse
+ * @param parent the parent for the new content
+ */
+ static public function parseListItem(importer:BaseTextLayoutImporter, xmlToParse:XML, parent:IFlowGroupElement):void
+ {
+ var listItem:IListItemElement = importer.createListItemFromXML(xmlToParse);
+ if (importer.addChild(parent, listItem))
+ {
+ importer.parseFlowGroupElementChildren(xmlToParse, listItem);
+ //if parsing an empty list item, create a Paragraph for it.
+ if (listItem.numChildren == 0)
+ 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)
+ {
+ reportError(GlobalSettings.resourceStringFunction("unexpectedNamespace", [elementNS.toString()]));
+ return false;
+ }
+ _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)
+ {
+ reportError(GlobalSettings.resourceStringFunction("unexpectedNamespace", [elementNS.toString()]));
+ return false;
+ }
+
+ return true;
+ }
+
+ 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"))
+ continue;
+ for each (importer in formatImporters)
+ {
+ if (importer.importOneFormat(propertyName,propertyValue))
+ {
+ imported = true;
+ break;
+ }
+ }
+ if (!imported) // not a supported attribute
+ 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.
+ *
+ * @param xmlToParse content to parse
+ * @param textFlow TextFlow we're parsing. If null, create or find a new TextFlow based on XML content
+ * @return TextFlow the new TextFlow created as a result of the parse
+ */
+ public function createTextFlowFromXML(xmlToParse:XML, newFlow:TextFlow = null):TextFlow // No PMD
+ {
+ 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"); }
+ return null;
+ }
+
+ public function createSpanFromXML(xmlToParse:XML):ISpanElement // No PMD
+ {
+ CONFIG::debug { assert(false,"missing override for createSpanFromXML"); }
+ return null;
+ }
+
+ public function createBreakFromXML(xmlToParse:XML):BreakElement
+ {
+ 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"); }
+ return null;
+ }
+
+ public function createListItemFromXML(xmlToParse:XML):IListItemElement // No PMD
+ {
+ CONFIG::debug { assert(false,"missing override for createListItemFromXML"); }
+ return null;
+ }
+
+ public function createTabFromXML(xmlToParse:XML):TabElement
+ {
+ parseAttributes(xmlToParse,null); // reports errors
+ return new TabElement();
+ }
+
+ /**
+ * Parse XML, convert to FlowElements and add to the parent.
+ *
+ * @param xmlToParse content to parse
+ * @param parent the parent for the new content
+ */
+ public function parseFlowChildren(xmlToParse:XML, parent:FlowGroupElement):void
+ {
+ parseFlowGroupElementChildren(xmlToParse, parent);
+ }
+
+ /**
+ * Parse XML, convert to FlowElements and add to the parent.
+ *
+ * @param xmlToParse content to parse
+ * @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
+ {
+ for each (var child:XML in xmlToParse.children())
+ {
+ if (child.nodeKind() == "element")
+ {
+ 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)
+ {
+ strip = txt.search(anyPrintChar) == -1;
+ }
+
+ 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
+ *
+ * @param xmlToParse content to parse
+ * @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
+ {
+ var textFlow:TextFlow;
+
+ for each (var child:XML in xmlToParse.children())
+ {
+ if (child.nodeKind() == "element")
+ {
+ if (child.name().localName=="p") {
+ textFlow = new TextFlow(FactoryUtil.defaultTLFFactory);
+ parseObject(child.name().localName, child, textFlow, exceptionElements);
+ }
+ else if (child.name().localName=="TextFlow") {
+ TableCellElement(parent).textFlow = createTextFlowFromXML(child);
+ }
+ }
+ // 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)
+ {
+ strip = txt.search(anyPrintChar) == -1;
+ }
+
+ if (!strip) {
+ textFlow = new TextFlow(FactoryUtil.defaultTLFFactory);
+ parseObject(child.name().localName, child, textFlow, exceptionElements);
+ //addChild(textFlow, createImpliedSpan(txt));
+ }
+ }
+
+ if (textFlow) {
+ TableCellElement(parent).textFlow = textFlow;
+ textFlow = null;
+ }
+ }
+ }
+
+ /** create an implied span with specified text */
+ public function createImpliedSpan(text:String):SpanElement
+ {
+ var span:SpanElement = new SpanElement(); // No PMD
+ 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
+ return null;
+ }
+
+ public function parseObject(name:String, xmlToParse:XML, parent:IFlowGroupElement, exceptionElements:Object=null):void
+ {
+ if (!checkNamespace(xmlToParse))
+ return;
+
+ var info:FlowElementInfo = _config.lookup(name);
+ if (!info)
+ {
+ if (exceptionElements == null || exceptionElements[name] === undefined)
+ 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 ]));
+ }
+
+ protected function handleUnknownAttribute(elementName:String, propertyName:String):void
+ {
+ 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
+ // 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;
+
+ /** @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)
+ {
+ // Reset due to possibly intervening FlowParagrahElement; See note 2. above
+ resetImpliedPara();
+ }
+ else if (parent is IContainerFormattedElement)
+ {
+ // See note 1. above
+ 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
+ _impliedPara = createImpliedParagraph();
+ parent.addChild(_impliedPara);
+ }
+
+ parent = _impliedPara;
+ }
+
+ if (throwOnError)
+ parent.addChild(child);
+ else
+ {
+ try
+ {
+ parent.addChild(child);
+ }
+ catch (e:*)
+ {
+ reportError(e);
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ public function resetImpliedPara():void
+ {
+ if (_impliedPara)
+ {
+ onResetImpliedPara(_impliedPara);
+ _impliedPara = null;
+ }
+ }
+
+ protected function onResetImpliedPara(para:IParagraphElement):void
+ {
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ConversionConstants.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ConversionConstants.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ConversionConstants.as
new file mode 100644
index 0000000..c20e9f4
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ConversionConstants.as
@@ -0,0 +1,45 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion
+{
+
+ public class ConversionConstants
+ {
+ /** A converter that converts clipboard data into a TextFlow should use the MERGE_TO_NEXT_ON_PASTE property
+ * to control how the elements are treated when they are merged into an existing TextFlow on paste. This is useful
+ * if you want special handling for the case where only part of the element is copied. For instance, wheh a list
+ * is copied, if only part of the list is copied, and you paste it into another list, it merges into the list as
+ * additional items. If the entire list is copied, it appears as a nested list. When TLF creates a TextFlow for use
+ * on the clipboard, it decorates any partial elements with user properties that control whether the end of the element
+ * should be merged with the one after it. This user property is never pasted into the final TextFlow, but it may go
+ * on the elements in the TextScrap.textFlow. When copying text, the converter has the option to look for these properties
+ * to propagate them into the format that is posted on the clipboard. For instance, the plain text exporter checks the
+ * "mergeToNextOnPaste" property on paragraphs and supresses the paragraph terminator if it is found set to true.
+ * Likewise on import if the incoming String has no terminator, and useClipboardAnnotations is true, then it calls
+ * <code>setStyle(MERGE_TO_NEXT_ON_PASTE, "true")</code> on the corresponding paragraph so that when it is pasted
+ * it will blend into the paragraph where its pasted. This property should only be set on elements in a TextScrap, and
+ * only on the last element in the scrap.
+ *
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @langversion 3.0
+ */
+ static public const MERGE_TO_NEXT_ON_PASTE:String = "mergeToNextOnPaste";
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ConversionType.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ConversionType.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ConversionType.as
new file mode 100644
index 0000000..f2a25cd
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ConversionType.as
@@ -0,0 +1,51 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion
+{
+ /**
+ * Values for the format of exported text.
+ * The values <code>STRING_TYPE</code> and <code>XML_TYPE</code>
+ * can be used for the <code>conversionType</code> parameter for
+ * the export() method in the ITextExporter interface and the
+ * TextConverter class.
+ *
+ * @see org.apache.flex.textLayout.conversion.ITextExporter#export()
+ * @see org.apache.flex.textLayout.conversion.TextConverter#export()
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @langversion 3.0
+ */
+ public final class ConversionType
+ {
+ /**
+ * Export as type String.
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @langversion 3.0
+ */
+ public static const STRING_TYPE:String = "stringType";
+ /**
+ * Export as type XML.
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @langversion 3.0
+ */
+ public static const XML_TYPE:String = "xmlType";
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ConverterBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ConverterBase.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ConverterBase.as
new file mode 100644
index 0000000..c9281c4
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ConverterBase.as
@@ -0,0 +1,108 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion {
+
+
+
+ /**
+ * This is a base class for importers as well as exporters. It implements the error handling
+ * plus property getters and setters that generate an error when invoked.
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.0
+ * @langversion 3.0
+ */
+ public class ConverterBase
+ {
+ private var _errors:Vector.<String> = null;
+ private var _throwOnError:Boolean = false;
+ private var _useClipboardAnnotations:Boolean = false;
+ private var _config:ImportExportConfiguration;
+
+
+ /** Errors encountered while parsing.
+ * Value is a vector of Strings.
+ */
+ public function get errors():Vector.<String>
+ {
+ return _errors;
+ }
+
+ /** @copy ITextImporter#throwOnError()
+ */
+ public function get throwOnError():Boolean
+ {
+ return _throwOnError;
+ }
+
+ public function set throwOnError(value:Boolean):void
+ {
+ _throwOnError = value;
+ }
+
+ /** @private
+ * Clear errors.
+ */
+ public function clear():void
+ {
+ _errors = null;
+ }
+
+ /** @private
+ * Register an error that was encountered while parsing. If throwOnError
+ * is true, the error causes an exception. Otherwise it is logged and parsing
+ * continues.
+ * @param error the String that describes the error
+ */
+ public function reportError(error:String):void
+ {
+ if (_throwOnError)
+ throw new Error(error);
+
+ if (!_errors)
+ _errors = new Vector.<String>();
+ _errors.push(error);
+ }
+
+ /** @copy ITextImporter#useClipboardAnnotations()
+ */
+ public function get useClipboardAnnotations():Boolean
+ {
+ return _useClipboardAnnotations;
+ }
+ public function set useClipboardAnnotations(value:Boolean):void
+ {
+ _useClipboardAnnotations = value;
+ }
+
+ /**
+ * Returns the import and export configuration.
+ **/
+ public function get config():ImportExportConfiguration {
+ return _config;
+ }
+
+ /**
+ * @private
+ **/
+ public function set config(value:ImportExportConfiguration):void {
+ _config = value;
+ }
+
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/CustomFormatImporter.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/CustomFormatImporter.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/CustomFormatImporter.as
new file mode 100644
index 0000000..fb0fed0
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/CustomFormatImporter.as
@@ -0,0 +1,45 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion
+{
+ import org.apache.flex.utils.ObjectMap;
+
+ // [ExcludeClass]
+ /**
+ * @private
+ */
+ internal class CustomFormatImporter implements IFormatImporter
+ {
+ private var _rslt:ObjectMap = null;
+
+ public function CustomFormatImporter()
+ { }
+ public function reset():void
+ { _rslt = null; }
+ public function get result():Object
+ { return _rslt; }
+ public function importOneFormat(key:String,val:String):Boolean
+ {
+ if (_rslt == null)
+ _rslt = new ObjectMap();
+ _rslt[key] = val;
+ return true;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/FlowElementInfo.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/FlowElementInfo.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/FlowElementInfo.as
new file mode 100644
index 0000000..9947f4a
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/FlowElementInfo.as
@@ -0,0 +1,66 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion {
+ import org.apache.flex.reflection.getQualifiedClassName;
+
+ // [ExcludeClass]
+ /**
+ * @private
+ * Contains configuration data about FlowElement types.
+ */
+ internal class FlowElementInfo
+ {
+ /** Class used for the FlowElement sub-type */
+ private var _flowClass:Class;
+ /** Fully qualified class name */
+ private var _flowClassName:String;
+ /** Parsing function used for reading in data on a FlowElement instance */
+ private var _parser:Function;
+ /** Class for the object's XFL import/export interface */
+ private var _exporter:Function;
+
+ /** Construct a FlowElementInfo
+ * @param flowClass Class used to represent the FlowElement
+ * @param parser Function used for parsing XML description of a FlowElement
+ * @param exporter Class used to represent the FlowElement's exporter
+ * @param isParagraphFormattedElement Boolean indicating if this class is a subclass of ParagraphFormattedElement
+ */
+ public function FlowElementInfo(flowClass:Class, parser:Function, exporter:Function)
+ {
+ this._flowClass = flowClass;
+ this._parser = parser;
+ this._exporter = exporter;
+ this._flowClassName = getQualifiedClassName(flowClass);
+ }
+
+ /** Class used for the FlowElement sub-type */
+ public function get flowClass():Class
+ { return _flowClass; }
+ /** Fully qualified class name */
+ public function get flowClassName():String
+ { return _flowClassName; }
+ /** Parsing function used for reading in data on a FlowElement instance */
+ public function get parser():Function
+ { return _parser; }
+ /** Class for the object's XFL import/export interface */
+ public function get exporter():Function
+ { return _exporter; }
+ /** Boolean indicating if flowClass is a subclass of ParagraphFormattedElement */
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/FormatDescriptor.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/FormatDescriptor.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/FormatDescriptor.as
new file mode 100644
index 0000000..5cb57d6
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/FormatDescriptor.as
@@ -0,0 +1,90 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion
+{
+ /** Contains information about a format.
+ *
+ * @playerversion Flash 10.0
+ * @playerversion AIR 2.0
+ * @langversion 3.0
+ */
+ public class FormatDescriptor
+ {
+ private var _format:String;
+ private var _clipboardFormat:String;
+ private var _importerClass:Class;
+ private var _exporterClass:Class;
+
+ /** Constructor.
+ *
+ * @playerversion Flash 10.0
+ * @playerversion AIR 2.0
+ * @langversion 3.0
+ */
+ public function FormatDescriptor(format:String, importerClass:Class, exporterClass:Class, clipboardFormat:String)
+ {
+ _format = format;
+ _clipboardFormat = clipboardFormat;
+ _importerClass = importerClass;
+ _exporterClass = exporterClass;
+ }
+
+ /** Returns the data format used by the converter.
+ *
+ * @playerversion Flash 10.0
+ * @playerversion AIR 2.0
+ * @langversion 3.0
+ */
+ public function get format():String
+ { return _format; }
+
+ /** Descriptor used when matching this format to the formats posted on the external clipboard. If the format supports importing,
+ * (it's importerClass is not null), it will be called when pasting from the clipboard, if the clipboard contents include data
+ * in this format. If the format supports exporting, it will be called when copying to the clipboard, and the output it creates
+ * will be posted to the clipboard with this clipboardFormat.
+ *
+ * @playerversion Flash 10.0
+ * @playerversion AIR 2.0
+ * @langversion 3.0
+ *
+ * @see flash.desktop.Clipboard
+ * @see flash.desktop.ClipboardFormats
+ */
+ public function get clipboardFormat():String
+ { return _clipboardFormat; }
+
+ /** Returns the class used for converting data from the format.
+ *
+ * @playerversion Flash 10.0
+ * @playerversion AIR 2.0
+ * @langversion 3.0
+ */
+ public function get importerClass():Class
+ { return _importerClass; }
+
+ /** Returns the class used for converting to the format.
+ *
+ * @playerversion Flash 10.0
+ * @playerversion AIR 2.0
+ * @langversion 3.0
+ */
+ public function get exporterClass():Class
+ { return _exporterClass; }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/IFormatImporter.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/IFormatImporter.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/IFormatImporter.as
new file mode 100644
index 0000000..0374752
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/IFormatImporter.as
@@ -0,0 +1,29 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion {
+
+ // [ExcludeClass]
+ /** Interface for exporting text content from a TextFlow to either a String or XML. */
+ public interface IFormatImporter
+ {
+ function reset():void;
+ function get result():Object;
+ function importOneFormat(key:String,val:String):Boolean
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/IHTMLImporter.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/IHTMLImporter.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/IHTMLImporter.as
new file mode 100644
index 0000000..569f871
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/IHTMLImporter.as
@@ -0,0 +1,73 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion
+{
+ /** This interface should be implemented by converters that import HTML or HTML-structured data. Clients that have explicitly
+ * created an importer using TextConverter.getImporter may control the import process by calling into these methods on the
+ * importer.
+ *
+ * @playerversion Flash 10.0
+ * @playerversion AIR 2.0
+ * @langversion 3.0
+ */
+ public interface IHTMLImporter extends ITextImporter
+ {
+ /** This property allows specification of a function to modify the source property supplied to an <code><img></code> element.
+ * Sample use would be to modify relative paths to some caller specified root path. The function takes the string set in the markup and returns the actual string
+ * to be used.
+ *
+ * <p>Note that by default relative paths are relative to the loaded SWF. One use of this function is to make relative paths relative to some other location.</p>
+ *
+ * <p>The resolver function should look like this:</p>
+ * <code>function resolver(src:String):String</code>
+ * <p>It takes as an input parameter the value of src on the incoming img element, and returns the adjusted value.</p>
+ *
+ * @playerversion Flash 10.0
+ * @playerversion AIR 2.0
+ * @langversion 3.0
+ */
+ function get imageSourceResolveFunction():Function;
+ function set imageSourceResolveFunction(resolver:Function):void;
+
+ /** This property tells the importer to create an element for the <code>BODY</code> tag in HTML markup.
+ *
+ * <p>The element will normally be a <code>DivElement</code> with <code>typeName</code> set to <code>BODY</code>.</p>
+ * <p>This will also trigger parsing of <code>class</code> and <code>id</code> on the element.</p>
+ *
+ * @playerversion Flash 10.0
+ * @playerversion AIR 2.0
+ * @langversion 3.0
+ */
+ function get preserveBodyElement():Boolean;
+ function set preserveBodyElement(value:Boolean):void;
+
+ /** This property tells the importer to create an element for the <code>HTML</code> tag in HTML markup.
+ *
+ * <p>The element will normally be the top-level <code>TextFlow</code> element with <code>typeName</code> set to <code>HTML</code>.</p>
+ * <p>This will also trigger parsing of <code>class</code> and <code>id</code> on the element.</p>
+ *
+ * @playerversion Flash 10.0
+ * @playerversion AIR 2.0
+ * @langversion 3.0
+ */
+ function get preserveHTMLElement():Boolean;
+ function set preserveHTMLElement(value:Boolean):void;
+
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/IPlainTextExporter.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/IPlainTextExporter.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/IPlainTextExporter.as
new file mode 100644
index 0000000..938c3e4
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/IPlainTextExporter.as
@@ -0,0 +1,57 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion
+{
+ /** This interface should be implemented by converters that export plain text. Clients that have explicitly
+ * created an exporter using TextConverter.getExporter may control the export process by calling into these methods on the
+ * exporter.
+ *
+ * @playerversion Flash 10.0
+ * @playerversion AIR 2.0
+ * @langversion 3.0
+ */
+ public interface IPlainTextExporter extends ITextExporter
+ {
+ /** Specifies the character sequence used (in a text flow's plain-text equivalent) to separate paragraphs.
+ * The paragraph separator is not added after the last paragraph.
+ *
+ * <p>This property applies to the <code>PLAIN_TEXT_FORMAT</code> exporter.</p>
+ *
+ * <p>The default value is "\n".</p>
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @langversion 3.0
+ */
+ function get paragraphSeparator():String;
+ function set paragraphSeparator(value:String):void;
+
+ /** This property indicates whether discretionary hyphens in the text should be stripped during the export process.
+ * Discretionary hyphens, also known as "soft hyphens", indicate where to break a word in case the word must be
+ * split between two lines. The Unicode character for discretionary hyphens is <code>\u00AD</code>.
+ * <p>If this property is set to <code>true</code>, discretionary hyphens that are in the original text will not be in the exported text,
+ * even if they are part of the original text. If <code>false</code>, discretionary hyphens will be in the exported text.</p>
+ *
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @langversion 3.0
+ */
+ function get stripDiscretionaryHyphens():Boolean;
+ function set stripDiscretionaryHyphens(value:Boolean):void;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ITextExporter.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ITextExporter.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ITextExporter.as
new file mode 100644
index 0000000..733368d
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ITextExporter.as
@@ -0,0 +1,102 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion {
+ import org.apache.flex.textLayout.elements.ITextFlow;
+
+ /**
+ * Interface for exporting text content from a TextFlow instance to a given format,
+ * which may for example be String or XML format, or a user-defined format. Exporters support the getting
+ * and setting of properties to control the export of data. These properties are implemented
+ * as public properties, but the direct access of these properties should be avoided, since
+ * a user might replace the converter class in the TextConverter registry, causing a downcast
+ * to fail.
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @langversion 3.0
+ */
+ public interface ITextExporter
+ {
+ /**
+ * Export text content from a TextFlow instance in String, or XML, or a user defined format.
+ * <p>Set the <code>conversionType</code> parameter to either of the following values,
+ * or a user defined format in user-defined exporters.
+ * <ul>
+ * <li><code>org.apache.flex.textLayout.conversion.ConversionType.STRING_TYPE</code>;</li>
+ * <li><code>org.apache.flex.textLayout.conversion.ConversionType.XML_TYPE</code>.</li>
+ * </ul>
+ * </p>
+ * @param source The TextFlow to export
+ * @param conversionType Return a String (STRING_TYPE) or XML (XML_TYPE), or any user defined format.
+ * @return Object The exported content
+ * @see org.apache.flex.textLayout.conversion.ConversionType
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @langversion 3.0
+ */
+ function export(source:ITextFlow, conversionType:String):Object;
+
+ /**
+ * This property contains a vector of error messages as strings after a call
+ * to an exporter method is the <code>throwOnError</code> property is set to
+ * <code>false</code>, which is the default. If there were no errors, the
+ * property returns <code>null</code>. The property is reset on each method
+ * call.
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.0
+ * @langversion 3.0
+ */
+ function get errors():Vector.<String>;
+
+ /**
+ * The throwOnError property controls how the exporter handles errors.
+ * If set to <code>true</code>, methods throw an Error instance on errors.
+ * If set to <code>false</code>, which is the default, errors are collected
+ * into a vector of strings and stored in the <code>errors</code> property,
+ * and the exporter does not throw.
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.0
+ * @langversion 3.0
+ */
+ function get throwOnError():Boolean;
+ function set throwOnError(value:Boolean):void;
+
+ /**
+ * The <code>useClipboardAnnotations</code> property controls whether or not the
+ * importer should handle the extra information necessary for the clipboard.
+ * When data is in a TextFlow, paragraphs are always complete, and include a
+ * terminator character. When a range of text is pasted to the clipboard, it
+ * will form paragraphs, but the range may not include in the final terminator.
+ * In this case, the paragraph needs to be marked as a partial paragraph if it
+ * is intended for the clipboard, so that if it is later pasted it will merge
+ * into the new text correctly. If the content is intended for the clipboard,
+ * useClipboardAnnotations will be true.
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @langversion 3.0
+ */
+ function get useClipboardAnnotations():Boolean;
+ function set useClipboardAnnotations(value:Boolean):void;
+
+ /**
+ * Accesses the config options for the exporter.
+ **/
+ function get config():ImportExportConfiguration;
+ function set config(value:ImportExportConfiguration):void;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ITextImporter.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ITextImporter.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ITextImporter.as
new file mode 100644
index 0000000..6d3e43e
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ITextImporter.as
@@ -0,0 +1,108 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion
+{
+ import org.apache.flex.textLayout.elements.ITextFlow;
+ import org.apache.flex.textLayout.elements.IConfiguration;
+
+ /**
+ * Interface for importing text content into a TextFlow from an external source.
+ * The TextConverter class creates importers with no constructor arguments.
+ *
+ * @see org.apache.flex.textLayout.elements.TextFlow
+ *
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @langversion 3.0
+ */
+ public interface ITextImporter
+ {
+ /**
+ * Import text content from an external source and convert it into a TextFlow.
+ * @param source The data to convert.
+ * @return TextFlow Created from the source.
+ *
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @langversion 3.0
+ */
+ function importToFlow(source:Object):ITextFlow;
+
+ /**
+ * This property contains a vector of error messages as strings after a call
+ * to an importer method is the <code>throwOnError</code> property is set to
+ * <code>false</code>, which is the default. If there were no errors, the
+ * property returns <code>null</code>. The property is reset on each method
+ * call.
+ *
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @langversion 3.0
+ */
+ function get errors():Vector.<String>;
+
+ /**
+ * The <code>throwOnError</code> property controls how the importer handles errors.
+ * If set to <code>true</code>, methods throw an Error instance on errors.
+ * If set to <code>false</code>, which is the default, errors are collected
+ * into a vector of strings and stored in the <code>errors</code> property,
+ * and the importer does not throw.
+ *
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @langversion 3.0
+ */
+ function get throwOnError():Boolean;
+ function set throwOnError(value:Boolean):void;
+
+ /**
+ * Controls whether or not the
+ * importer should handle the extra information necessary for the clipboard.
+ * When data comes in from the clipboard, it might contain partial paragraphs;
+ * paragraphs that are missing the terminator or newline character. If <code>useClipboardAnnotations</code>
+ * is <code>true</code>, the importer marks these partial paragraphs with a
+ * <code>ConverterBase.MERGE_TO_NEXT_ON_PASTE</code> attribute. This causes the paste
+ * operation to correctly handle merging of the pasted paragraph (and any list or div elements
+ * that may include the paragraph) into the text.
+ *
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @langversion 3.0
+ *
+ * @see org.apache.flex.textLayout.conversion.ConverterBase.MERGE_TO_NEXT_ON_PASTE
+ */
+ function get useClipboardAnnotations():Boolean;
+ function set useClipboardAnnotations(value:Boolean):void;
+
+ /**
+ * The <code>configuration</code> property contains the IConfiguration instance that
+ * the importer needs when creating new TextFlow instances. This property
+ * is initially set to <code>null</code>.
+ *
+ * @see org.apache.flex.textLayout.elements.TextFlow
+ *
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.0
+ * @langversion 3.0
+ */
+ function get configuration():IConfiguration;
+ function set configuration(value:IConfiguration):void;
+
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fd08d137/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ITextLayoutImporter.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ITextLayoutImporter.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ITextLayoutImporter.as
new file mode 100644
index 0000000..ac0bf75
--- /dev/null
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/conversion/ITextLayoutImporter.as
@@ -0,0 +1,48 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.textLayout.conversion
+{
+ /** This interface should be implemented by converters that import TextLayout structured data. Clients that have explicitly
+ * created an importer using TextConverter.getImporter may control the import process by calling into these methods on the
+ * importer.
+ *
+ * @playerversion Flash 10.0
+ * @playerversion AIR 2.0
+ * @langversion 3.0
+ */
+ public interface ITextLayoutImporter extends ITextImporter
+ {
+ /** This property allows specification of a function to modify the source property supplied to an <code><img></code> element.
+ * Sample use would be to modify relative paths to some caller specified root path. The function takes the string set in the markup and returns the actual string
+ * to be used.
+ *
+ * <p>Note that by default relative paths are relative to the loaded SWF. One use of this function is to make relative paths relative to some other location.</p>
+ *
+ * <p>The resolver function should look like this:</p>
+ * <code>function resolver(src:String):String</code>
+ * <p>It takes as an input parameter the value of src on the incoming img element, and returns the adjusted value.</p>
+ *
+ * @playerversion Flash 10.0
+ * @playerversion AIR 2.0
+ * @langversion 3.0
+ */
+ function get imageSourceResolveFunction():Function;
+ function set imageSourceResolveFunction(resolver:Function):void;
+ }
+}
\ No newline at end of file