I have a situation that I'm wrapping some document processing in a batch 
editing scope to hide the intermediate document state from the view.  If the 
processing runs into problems, I would like to revert the document state to 
that before the processing (analogous to a database rollback).  I cannot figure 
out how to rollback the document state in XXE, so I'm using the undo manager as 
shown below:

try {
  app.getActiveDocument().beginBatchEditing();
  .. do stuff that might throw an exception 
  if(successful) {
    app.getActiveDocument().endBatchEditing();
  }
}
catch(FooException e) {
  .. error handling
}
catch(BarException e) {
  .. different kind of error handling
}
finally {
  if(!successful) {
    //
    // manually rollback the changes
    //
    app.getActiveDocument.endBatchEditing();
    app.getActiveDocumentView.getUndoManager().undo();
  }
}

While this accomplishes what I want, it adds an entry onto the undo/redo stack 
that can be redone.  What I would like to do is something like this:

try {
  app.getActiveDocument().beginBatchEditing();
  .. do stuff that might throw an exception 
  if(successful) {
    app.getActiveDocument().endBatchEditing();
  }
}
catch(FooException e) {
  .. error handling
}
catch(BarException e) {
  .. different kind of error handling
}
finally {
  if(!successful) {
    app.getActiveDocument.rollbackBatchEditing();
  }
}

After rollback, it is like the processing never happened.  Is there a way to 
accomplish this in XXE?

Cheers,
Mike
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.xmlmind.com/pipermail/xmleditor-support/attachments/20071119/0d035f2e/attachment.htm
 

Reply via email to