You are currently viewing a snapshot of taken on April 21, 2008. Most of this content is highly out of date (some pages haven't been updated since the project began in 1998) and exists for historical purposes only. If there are any pages on this archive site that you think should be added back to, please file a bug.

Date last modified: Wed Feb 10 16:03:33 PST 1999

Transaction Interface Class:

class nsITransaction  : public nsISupports{

  virtual nsresult Do(void) = 0;
  virtual nsresult Undo(void) = 0;
  virtual nsresult Redo(void) = 0;
  virtual nsresult GetIsTransient(PRBool *aIsTransient) = 0;
  virtual nsresult Merge(PRBool *aDidMerge, nsITransaction *aTransaction) = 0;
  virtual nsresult Write(nsIOutputStream *aOutputStream) = 0;
  virtual nsresult GetUndoString(nsString *aString) = 0;
  virtual nsresult GetRedoString(nsString *aString) = 0;

Transaction Interface Methods:

nsresult Do(void)

Executes the transaction.

nsresult Undo(void)

Restores the state to what it was before the transaction was executed.

nsresult Redo(void)

Executes the transaction again. Can only be called on a transaction that was previously undone.

In most cases, the Redo() method will actually call the Do() method to execute the transaction again.

nsresult GetIsTransient(PRBool *aIsTransient)

Retrieves the transaction's transient state. This method is called by the transaction manager after the transaction's Do() method is executed. If the transient state is false, a reference to the transaction is held by the transaction manager so that the transactions' Undo() and Redo() methods can be called. If the transient state is true, the transaction manager returns immediately after the transaction's Do() method is executed, no references to the transaction are maintained. Transient transactions cannot be undone or redone by the transaction manager.


aIsTransient - will contain the transaction's transient state.

nsresult Merge(PRBool *aDidMerge, nsITransaction *aTransaction)

Attempts to merge a transaction into "this" transaction. Both transactions must be in their undo state, Do() methods already executed. The transaction manager calls this method to coalesce a new transaction with the transaction on the top of the undo stack.


aDidMerge - will contain merge result. True if transactions were merged successfully. False if merge is not possible or failed. If true, the transaction manager will Release() the new transacton instead of pushing it on the undo stack.

aTransaction - the previously executed transaction to merge.

nsresult Write(nsIOutputStream *aOutputStream)

Write a stream representation of the current state of the transaction.


aOutputStream - the stream to write to.

nsresult GetUndoString(nsString *aString)

Retrieves the string to display for the undo menu item.


aString - will contain the string to display.

virtual nsresult GetRedoString(nsString *aString)

Retrieves the string to display for the redo menu item.


aString - will contain the string to display.