 import flashx.textLayout.edit.IUndoManager;
 import flashx.textLayout.edit.SelectionFormat;
 import flashx.textLayout.edit.SelectionManager;
+import flashx.textLayout.edit.SelectionState;
+import flashx.textLayout.edit.TextScrap;
 import flashx.textLayout.edit.UndoManager;
 import flashx.textLayout.elements.Configuration;
 import flashx.textLayout.elements.FlowElement;

                        event:FlowOperationEvent):void
    {
        //trace("operationEnd");

        // Since the text may have changed, set a flag which will
        // cause the 'text' getter to call extractText() to extract

        newEvent.operation = event.operation;
        dispatchEvent(newEvent);
    }

    private function handlePasteOperation(op:PasteOperation):void
    {
        if (!restrict && !maxChars && !displayAsPassword)
            return;
            
        var textScrap:TextScrap = op.scrapToPaste();
        var pastedText:String = TextUtil.extractText(textScrap.textFlow);

        // We know it's an EditManager or we wouldn't have gotten here.
        var editManager:EditManager = EditManager(textFlow.interactionManager);

        // Generate a CHANGING event for the PasteOperation but not for the
        // DeleteTextOperation or the InsertTextOperation which are also part
        // of the paste.
        dispatchChangingEvent = false;
                        
        var selectionState:SelectionState = 
            new SelectionState(textFlow, op.absoluteStart, 
                    op.absoluteStart + pastedText.length);             
        editManager.deleteText(selectionState);

        // Insert the same text, the same place where the paste was done.
        // This will go thru the InsertPasteOperation and do the right
        // things with restrict, maxChars and displayAsPassword.
        selectionState = 
            new SelectionState(textFlow, op.absoluteStart, op.absoluteStart);
        editManager.insertText(pastedText, selectionState);        

        dispatchChangingEvent = true;
    }
}

}
