dimitri kara created FLEX-34592:
-----------------------------------
Summary: 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
Priority: Minor
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)