How to ensure Undo/Redo for multiple different IOperations  SOLVED

PDF-XChange Editor SDK for Developers

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Paul - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
zarkogajic
User
Posts: 1503
Joined: Thu Sep 05, 2019 12:35 pm

How to ensure Undo/Redo for multiple different IOperations

Post by zarkogajic »

Hi Support,

If I do

Code: Select all

IPXV_Document.OperationHistory.BeginMacro ...

-> Multiple executions of *the same* IOperation type

IPXV_Document.OperationHistory.EndMacro ...
Hit Undo - all is undone - as expected.

BUT, if I do:

Code: Select all

IPXV_Document.OperationHistory.BeginMacro ...

loop through entries
  if something do IOperation_1 for entry
  if something_else do IOperation_2 for entry
  do IOperation_3 for entry
 
IPXV_Document.OperationHistory.EndMacro ...
In short: for some entry all three IOperations can get executed, for another maybe only IOperation_3.

Problem: the Undo action will only undo IOperation_3 (for all entries).

Expected: all executed IOperations undone for the entry for all entries.

So, the question: how to ensure Undo/Redo works for a set of different IOperations ?

-žarko
zarkogajic
User
Posts: 1503
Joined: Thu Sep 05, 2019 12:35 pm

Re: How to ensure Undo/Redo for multiple different IOperations

Post by zarkogajic »

Hi Support,

To clarify further:

Even if the code looks like:

Code: Select all

IPXV_Document.OperationHistory.BeginMacro ...

loop through entries
  do IOperation_1 for entry
  do IOperation_2 for entry
  do IOperation_3 for entry
 
IPXV_Document.OperationHistory.EndMacro ...
Upon "Undo" only IOperation_3 is undone (for all entries).


If of any value, the 3 operations done are: op.annot.setData, op.annots.setProps and op.document.replaceFonts

zarkogajic
User
Posts: 1503
Joined: Thu Sep 05, 2019 12:35 pm

Re: How to ensure Undo/Redo for multiple different IOperations

Post by zarkogajic »

Hi Support,

After some more testing of "what's happening" ... it seems that op.annot.setData cannot be undone.

I've tried executing only that operation - and Undo does not do anything.

So, not really the problem of multiple IOperations being done - but this one particularly.


-žarko
zarkogajic
User
Posts: 1503
Joined: Thu Sep 05, 2019 12:35 pm

Re: How to ensure Undo/Redo for multiple different IOperations  SOLVED

Post by zarkogajic »

Hi Support,

OMG! All works as expected, sorry.

I was using the op.annot.setData BUT was also setting the IPXC_Annotation.Set_Data(...)

Shame on me ;)

-žarko
User avatar
MishaH
User
Posts: 12
Joined: Wed Sep 11, 2024 1:43 pm

Re: How to ensure Undo/Redo for multiple different IOperations

Post by MishaH »

Hello zarkogajic,

Sorry that we didn't follow up on the initial post! And glad to see that it is working well for you!

Kind regards,
Misha