Prevent Pasting

Oxygen general issues.
neon096
Posts: 45
Joined: Wed May 23, 2012 11:20 am

Prevent Pasting

Post by neon096 »

I'm trying to prevent a user pasting over a mandatory heading. I've tried using the AuthorDocumentFilter.insertFragment but this is too late in the call hierarchy. So I'm now using AuthorSchemaAwareEditingHandlerAdapter.handlePaste however the API suggests the selection removal has already been removed before the method call. The question I have is how do I put the selection back?
neon096
Posts: 45
Joined: Wed May 23, 2012 11:20 am

Re: Prevent Pasting

Post by neon096 »

Please note that the following doesn't seem to work.

Code: Select all

access.getDocumentController().getUndoManager().undo();
Radu
Posts: 9055
Joined: Fri Jul 09, 2004 5:18 pm

Re: Prevent Pasting

Post by Radu »

Hi Neil,

Your AuthorSchemaAwareEditingHandlerAdapter.handlePaste() code gets called while a compound edit is still opened (in order to have the Undo action undo all changes, both delete and insert).

Please try to use this API method to cancel the edit:

Code: Select all

ro.sync.ecss.extensions.api.AuthorDocumentController.cancelCompoundEdit()
The method should also undo the deletion of the selection.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply