You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flex.apache.org by "dimitri kara (JIRA)" <ji...@apache.org> on 2014/11/20 16:47:34 UTC

[jira] [Updated] (FLEX-34592) Can't use optionnal importer for TLF plainTextFormat and TextLayoutFormat

     [ https://issues.apache.org/jira/browse/FLEX-34592?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

dimitri kara updated FLEX-34592:
--------------------------------
    Attachment: PoundFirstTextImporter.as
                BasicTextImporter.as
                TLFImporterBugTestCase.as

Bug test case with two Importer classes

> Can't use optionnal importer for TLF plainTextFormat and TextLayoutFormat
> -------------------------------------------------------------------------
>
>                 Key: FLEX-34592
>                 URL: https://issues.apache.org/jira/browse/FLEX-34592
>             Project: Apache Flex
>          Issue Type: Bug
>          Components: .Unspecified - Framework
>    Affects Versions: Apache Flex 4.13.0
>            Reporter: dimitri kara
>            Assignee: Frédéric THOMAS
>            Priority: Minor
>              Labels: importer, tlf
>         Attachments: BasicTextImporter.as, PoundFirstTextImporter.as, TLFImporterBugTestCase.as
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> When you add importer to the TextConverter class, you should be able to let the importer decline the conversion by having its importToFlow method returning null (as it is stated in the TLF blogpost http://blogs.adobe.com/tlf/2010/11/custom-clipboard-formats.htm ).
> It works for all format except plainTextFormat and textLayoutFormat because of these lines in flashx.textLayout.edit.TextClipboard, method importToScrap #170:
> {quote}
> var textFlow:TextFlow = importer.importToFlow(textOnClipboard);
> 				*if (textFlow)*
> 					textScrap = new TextScrap(textFlow); 				
> 				
> 				if (format == TextConverter.PLAIN_TEXT_FORMAT)
> 					*textScrap.setPlainText(true);* 
> 				else if (format == TextConverter.TEXT_LAYOUT_FORMAT)
> 					*textScrap.setPlainText(false);*
> {quote}
> If the importer return null, textFlow==null, so textScrap==null and textScrap.setPlainText(...) cause a null object error.
> The solution is trivial. This method should not assume these formats will always have the importer return a non-null textFlow, and should test either the existence of the textFlow or the existence of the textScrap. The correct code would be:
> {quote}
> var textFlow:TextFlow = importer.importToFlow(textOnClipboard);
> 				if (textFlow)
> 					textScrap = new TextScrap(textFlow);
> 				
> 			
> 				if (format == TextConverter.PLAIN_TEXT_FORMAT *&& textScrap*)
> 					textScrap.setPlainText(true);
> 				else if (format == TextConverter.TEXT_LAYOUT_FORMAT  *&& textScrap*)
> 					textScrap.setPlainText(false);
> {quote}
> This bug prevent me from having some converter that check for patterns in a plain text from clipboard and chose to handle the conversion if the patterns are found.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)