Skip to main content
Known Participant
May 18, 2009
Answered

CompositeOperation problem?

  • May 18, 2009
  • 1 reply
  • 2020 views

Hey there,

I have a question concerning CompositeOperations and undo-ing them.

Imagine this example:

var c:CompositeOperation = new CompositeOperation();
var s:SelectionState = new SelectionState(textFlow,1,1);


c.addOperation(new InsertInlineGraphicOperation(s,'images/testgfx.gif','auto','auto',Float.NONE));
c.addOperation(new InsertInlineGraphicOperation(s,'images/testgfx.gif','auto','auto',Float.NONE));
c.addOperation(new InsertInlineGraphicOperation(s,'images/testgfx.gif','auto','auto',Float.NONE));
               
(textFlow.interactionManager as IEditManager).doOperation(c);

if I run this code it works like a charm, three images are added in a row.

Only after calling this:

(textFlow.interactionManager as IEditManager).undo();

The operations aren't being undone...

Am I doing something wrong, or is this a bug?

thanks a lot in advance,

Roland

This topic has been closed for replies.
Correct answer rdermer

Hi again,

I see that the uploads aren't working still in the forums.

I have therefore uploaded a sample application at this URL:

http://www.brakkecode.nl/TLF/InlineGraphicUndoTest.html

'View Source' is enabled. The application showcases the two different ways of adding the image, the undo button shows the result quite clearly.

As far as I can tell I'm doing nothing wrong here, I'd appreciate if someone can confirm the issue.

Thanks a lot in advance,

Roland


Thanks for the example.  I see the problem and will get it in the bug database.

Richard

1 reply

Adobe Employee
May 18, 2009

You need to let the EditManager create and manage the CompositeOperation.  The class is publicly exposed so that you can see the operation in any flowOperationBegin event handlers.  So your code would be something like:

var em:IEditManager = textFlow.interactionManager as IEditManager;
em.beginCompositeOperation()
em.doOperation(new InsertInlineGraphicOperation(s,'images/testgfx.gif','auto','auto',Float.NONE));
em.doOperation(new InsertInlineGraphicOperation(s,'images/testgfx.gif','auto','auto',Float.NONE));
em.doOperation(new InsertInlineGraphicOperation(s,'images/testgfx.gif','auto','auto',Float.NONE));
em.endCompositeOperation()

Note that failing to begin/end calls can be nested.  Failing to nest them properly will result in some sort of failure - though hard to say where.

Richard

mech-headAuthor
Known Participant
May 18, 2009

Hi there Richard,

thank you for your quickly  reply (as per usual).

Your comment helped me out partially. I now understand the right way of calling the API, yet, I still think I found a problem.

If I use this code:

var em:IEditManager = textFlow.interactionManager as IEditManager;
em.beginCompositeOperation();
em.doOperation(new InsertInlineGraphicOperation(s,'images/testgfx.gif','auto','auto',Float.NONE));
em.doOperation(new InsertInlineGraphicOperation(s,'images/testgfx.gif','auto','auto',Float.NONE));
em.doOperation(new InsertInlineGraphicOperation(s,'images/testgfx.gif','auto','auto',Float.NONE));
em.endCompositeOperation();

And the than call the undo() function, I'm very sorry, but it's not working, the graphics appear, but do not disappear after calling undo().

This made me think that it might just be a problem with the InsertInlineGraphicOperation. So I tried this code instead:

var em:IEditManager = editor2.textFlow.interactionManager as IEditManager;
em.beginCompositeOperation();
var s:SelectionState = new SelectionState(editor2.textFlow,pos,pos)
em.doOperation(new InsertTextOperation(s,'this is insertedtext1, '));
em.doOperation(new InsertTextOperation(s,'this is insertedtext2, '));
em.doOperation(new InsertTextOperation(s,'this is insertedtext3 '));
em.endCompositeOperation();

And there you are, calling undo() *does* work correctly.

Could anyone please confirm this behaviour?

By the way, I'm using build 432, just to be clear

As always, thanks a lot in advance for any kind of help and advice.

cheers,

Roland

mech-headAuthor
Known Participant
May 18, 2009

FYI,

I believe the InsertInlineGraphicOperation isn't working at all with the UndoManager, because this code doesn't work either:

var em:IEditManager = editor2.textFlow.interactionManager as IEditManager;
var s:SelectionState = new SelectionState(editor2.textFlow,1,1);
em.doOperation(new InsertInlineGraphicOperation(s,'
images/testgfx.gif','auto','auto',Float.NONE));

The inline graphic appears as normal but afterwards when calling undo() doesn't seem to do anything.

cheers,

Roland