Fixes for bug #66308 ([embed] XPIDL'ize transaction manager)

sr=sfraser@netscape.com,mscott@netscape.com r=jfrancis@netscape.com

* nsITransaction, nsITransactionListenter, nsITransactionManager have
  been XPIDL'ized and moved into mozilla/editor/txmgr/idl. The versions
  of these interfaces in mozilla/editor/txmgr/public are being CVS removed.

* Renamed Do(), Undo(), and Redo() to DoTransaction(), UndoTransaction(),
  and RedoTransaction() to avoid reserved word problems in languages like
  JS. I did a sweep through editor and mailnews to remove these methods.

* PeekUndoStack() and PeekRedoStack() now return an AddRef'd pointer.

* Removed GetUndoString(), GetRedoString() and Write() from the
  nsITransaction interface. Neither editor or mailnews really made
  use of these methods.

* Removed Write() from the nsITransactionManager.cpp interface.

* The Transaction Manager now supports weak references.

* Added support for nsITransactionList to the TransactionManager
  to allow access to all transactions on the Undo and Redo stacks, as
  well as auto-aggregated transactions.

* Removed all references to nsITransactionDescription from txmgr and editor.

* Added nsPIEditorTransaction and made all Editor internal transactions
  inherit from it so we can distinguish between our transactions and
  ones from 3rd parties.

New files checked in:

  editor/txmgr/idl/nsITransaction.idl
  editor/txmgr/idl/nsITransactionList.idl
  editor/txmgr/idl/nsITransactionListener.idl
  editor/txmgr/idl/nsITransactionManager.idl
  editor/txmgr/src/nsITransactionList.cpp
  editor/txmgr/src/nsITransactionList.h
  editor/idl/nsPIEditorTransaction.idl

Files that were CVS removed:

  editor/txmgr/public/nsITransaction.h
  editor/txmgr/public/nsITransactionListener.h
  editor/txmgr/public/nsITransactionManager.h
  editor/txmgr/idl/nsITransactionDescription.h
  editor/base/IMECommitTxn.cpp
  editor/base/IMECommitTxn.h

Files modified:

  editor/Makefile.in
  editor/makefile.win
  editor/base/ChangeAttributeTxn.cpp
  editor/base/ChangeAttributeTxn.h
  editor/base/CreateElementTxn.cpp
  editor/base/CreateElementTxn.h
  editor/base/DeleteElementTxn.cpp
  editor/base/DeleteElementTxn.h
  editor/base/DeleteRangeTxn.cpp
  editor/base/DeleteRangeTxn.h
  editor/base/DeleteTextTxn.cpp
  editor/base/DeleteTextTxn.h
  editor/base/EditAggregateTxn.cpp
  editor/base/EditAggregateTxn.h
  editor/base/EditTxn.cpp
  editor/base/EditTxn.h
  editor/base/IMECommitTxn.cpp
  editor/base/IMECommitTxn.h
  editor/base/IMETextTxn.cpp
  editor/base/IMETextTxn.h
  editor/base/InsertElementTxn.cpp
  editor/base/InsertElementTxn.h
  editor/base/InsertTextTxn.cpp
  editor/base/InsertTextTxn.h
  editor/base/JoinElementTxn.cpp
  editor/base/JoinElementTxn.h
  editor/base/nsEditor.cpp
  editor/base/nsEditorShell.cpp
  editor/base/nsEditorShell.h
  editor/base/nsEditorTxnLog.cpp
  editor/base/nsStyleSheetTxns.cpp
  editor/base/nsStyleSheetTxns.h
  editor/base/PlaceholderTxn.cpp
  editor/base/PlaceholderTxn.h
  editor/base/SetDocTitleTxn.cpp
  editor/base/SetDocTitleTxn.h
  editor/base/SplitElementTxn.cpp
  editor/base/SplitElementTxn.h
  editor/idl/Makefile.in
  editor/idl/makefile.win
  editor/idl/MANIFEST
  editor/idl/nsIEditorShell.idl
  editor/macbuild/editor.mcp
  editor/macbuild/EditorIDL.mcp
  editor/txmgr/idl/Makefile.in
  editor/txmgr/idl/makefile.win
  editor/txmgr/idl/MANIFEST
  editor/txmgr/idl/nsITransactionManager.idl
  editor/txmgr/macbuild/txmgr.mcp
  editor/txmgr/macbuild/txmgrIDL.mcp
  editor/txmgr/public/Makefile.in
  editor/txmgr/public/makefile.win
  editor/txmgr/public/MANIFEST
  editor/txmgr/src/Makefile.in
  editor/txmgr/src/makefile.win
  editor/txmgr/src/nsTransactionItem.cpp
  editor/txmgr/src/nsTransactionItem.h
  editor/txmgr/src/nsTransactionList.cpp
  editor/txmgr/src/nsTransactionList.h
  editor/txmgr/src/nsTransactionManager.cpp
  editor/txmgr/src/nsTransactionManager.h
  editor/txmgr/src/nsTransactionManagerFactory.cpp
  editor/txmgr/src/nsTransactionStack.cpp
  editor/txmgr/src/nsTransactionStack.h
  editor/txmgr/tests/TestTXMgr.cpp
  editor/ui/composer/content/EditorCommandsDebug.js
  editor/ui/composer/content/editorOverlay.xul
  editor/ui/composer/locale/en-US/editorOverlay.dtd
  mailnews/base/src/nsMessenger.cpp
  mailnews/base/util/nsMsgTxn.cpp
  mailnews/base/util/nsMsgTxn.h
  mailnews/imap/src/nsImapMailFolder.cpp
  mailnews/imap/src/nsImapUndoTxn.cpp
  mailnews/imap/src/nsImapUndoTxn.h
  mailnews/local/src/nsLocalMailFolder.cpp
  mailnews/local/src/nsLocalUndoTxn.cpp
  mailnews/local/src/nsLocalUndoTxn.h
This commit is contained in:
kin%netscape.com 2001-03-09 14:32:06 +00:00
parent f23a6ad8b2
commit d6e1d32f46
6 changed files with 0 additions and 743 deletions

View File

@ -1,111 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "IMECommitTxn.h"
#include "nsEditor.h"
// #define DEBUG_IME
nsIAtom *IMECommitTxn::gIMECommitTxnName = nsnull;
nsresult IMECommitTxn::ClassInit()
{
if (nsnull==gIMECommitTxnName)
gIMECommitTxnName = NS_NewAtom("NS_IMECommitTxn");
return NS_OK;
}
nsresult IMECommitTxn::ClassShutdown()
{
NS_IF_RELEASE(gIMECommitTxnName);
return NS_OK;
}
IMECommitTxn::IMECommitTxn()
: EditTxn()
{
}
IMECommitTxn::~IMECommitTxn()
{
}
NS_IMETHODIMP IMECommitTxn::Init(void)
{
return NS_OK;
}
NS_IMETHODIMP IMECommitTxn::DoTransaction(void)
{
#ifdef DEBUG_IME
printf("Do IME Commit");
#endif
return NS_OK;
}
NS_IMETHODIMP IMECommitTxn::UndoTransaction(void)
{
#ifdef DEBUG_IME
printf("Undo IME Commit");
#endif
return NS_OK;
}
NS_IMETHODIMP IMECommitTxn::Merge(nsITransaction *aTransaction, PRBool *aDidMerge)
{
#ifdef DEBUG_IME
printf("Merge IME Commit");
#endif
NS_ASSERTION(aDidMerge, "null ptr- aDidMerge");
NS_ASSERTION(aTransaction, "null ptr- aTransaction");
if((nsnull == aDidMerge) || (nsnull == aTransaction))
return NS_ERROR_NULL_POINTER;
*aDidMerge=PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP IMECommitTxn::GetTxnDescription(nsAWritableString& aString)
{
aString.Assign(NS_LITERAL_STRING("IMECommitTxn"));
return NS_OK;
}
/* ============= nsISupports implementation ====================== */
NS_IMETHODIMP
IMECommitTxn::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (nsnull == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
if (aIID.Equals(IMECommitTxn::GetCID())) {
*aInstancePtr = (void*)(IMECommitTxn*)this;
NS_ADDREF_THIS();
return NS_OK;
}
return (EditTxn::QueryInterface(aIID, aInstancePtr));
}

View File

@ -1,85 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef IMECommitTxn_h__
#define IMECommitTxn_h__
#include "EditTxn.h"
#include "nsIDOMCharacterData.h"
#include "nsCOMPtr.h"
// {9C4994A1-281C-11d3-9EA3-0060089FE59B}
#define IME_COMMIT_TXN_CID \
{ 0x9c4994a1, 0x281c, 0x11d3, \
{ 0x9e, 0xa3, 0x0, 0x60, 0x8, 0x9f, 0xe5, 0x9b }}
/**
* A transaction representing an IME commit operation
*/
class IMECommitTxn : public EditTxn
{
public:
static const nsIID& GetCID() { static nsIID iid = IME_COMMIT_TXN_CID; return iid; }
virtual ~IMECommitTxn();
static nsIAtom *gIMECommitTxnName;
/** initialize the transaction
*/
NS_IMETHOD Init(void);
private:
IMECommitTxn();
public:
NS_IMETHOD DoTransaction(void);
NS_IMETHOD UndoTransaction(void);
NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
NS_IMETHOD GetTxnDescription(nsAWritableString& aTxnDescription);
// nsISupports declarations
// override QueryInterface to handle IMECommitTxn request
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
/** must be called before any IMECommitTxn is instantiated */
static nsresult ClassInit();
/** must be called once we are guaranteed all IMECommitTxn have completed */
static nsresult ClassShutdown();
protected:
friend class TransactionFactory;
friend class nsDerivedSafe<IMECommitTxn>; // work around for a compiler bug
};
#endif

View File

@ -1,62 +0,0 @@
/*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator client code, released
* March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
/**
* UI Transaction interface to outside world
* A transaction specific interface for handling its user-interface needs.
* <P>
* It's implemented by an object that can get and set strings and IDs for
* a particular transaction.
*/
[scriptable, uuid(32a805cc-1dd2-11b2-b8b1-f9648fb9df5e)]
interface nsITransactionDescription : nsISupports
{
/**
* Returns a string which might be used with logging or other purposes.
* @param aString will be set to the transactions description string.
*/
wstring getLogDescription();
/**
* Sets a string for later query (for example, it might be associated with logging).
* @param aString will be used as the new description string for a given transaction.
*/
void setLogDescription(in wstring aString);
/**
* Returns an id for a particular transaction.
* @param aTransactionID will contain the transaction's id.
*/
PRInt32 getTransactionDescriptionID();
/**
* Sets the id for a particular transaction.
* @param aTransactionID will contain the transaction's id.
*/
void setTransactionDescriptionID(in PRInt32 aTransactionID);
};

View File

@ -1,117 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsITransaction_h__
#define nsITransaction_h__
#include "nsISupports.h"
#include "nsIOutputStream.h"
#include "nsString.h"
/*
Transaction interface to outside world
*/
#define NS_ITRANSACTION_IID \
{ /* 58E330C1-7B48-11d2-98B9-00805F297D89 */ \
0x58e330c1, 0x7b48, 0x11d2, \
{ 0x98, 0xb9, 0x0, 0x80, 0x5f, 0x29, 0x7d, 0x89 } }
/**
* A transaction specific interface.
* <P>
* It's implemented by an object that executes some behavior that must be
* tracked by the transaction manager.
*/
class nsITransaction : public nsISupports{
public:
static const nsIID& GetIID() { static nsIID iid = NS_ITRANSACTION_IID; return iid; }
/**
* Executes the transaction.
*/
NS_IMETHOD Do(void) = 0;
/**
* Restores the state to what it was before the transaction was executed.
*/
NS_IMETHOD Undo(void) = 0;
/**
* Executes the transaction again. Can only be called on a transaction that
* was previously undone.
* <P>
* In most cases, the Redo() method will actually call the Do() method to
* execute the transaction again.
*/
NS_IMETHOD Redo(void) = 0;
/**
* 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.
* @param aIsTransient will contain the transaction's transient state.
*/
NS_IMETHOD GetIsTransient(PRBool *aIsTransient) = 0;
/**
* 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.
* @param 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.
* @param aTransaction the previously executed transaction to merge.
*/
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction) = 0;
/**
* Write a stream representation of the current state of the transaction.
* @param aOutputStream the stream to write to.
*/
NS_IMETHOD Write(nsIOutputStream *aOutputStream) = 0;
/**
* Returns the string to display for the undo menu item.
* @param aString will be set to the string to display.
*/
NS_IMETHOD GetUndoString(nsString *aString) = 0;
/**
* Returns the string to display for the redo menu item.
* @param aString will be set to the string to display.
*/
NS_IMETHOD GetRedoString(nsString *aString) = 0;
};
#endif // nsITransaction_h__

View File

@ -1,210 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsITransactionListener_h__
#define nsITransactionListener_h__
#include "nsISupports.h"
class nsITransaction;
class nsITransactionManager;
/*
Transaction Listener interface to outside world
*/
#define NS_ITRANSACTIONLISTENER_IID \
{ /* 58E330C4-7B48-11d2-98B9-00805F297D89 */ \
0x58e330c4, 0x7b48, 0x11d2, \
{ 0x98, 0xb9, 0x0, 0x80, 0x5f, 0x29, 0x7d, 0x89 } }
/**
* A transaction listener specific interface.
* <P>
* It's implemented by an object that tracks transactions.
*/
class nsITransactionListener : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_ITRANSACTIONLISTENER_IID; return iid; }
/**
* Called before a transaction manager calls a transaction's
* Do() method.
* @param aManager the transaction manager doing the transaction.
* @param aTransaction the transaction being done.
* @param aInterrupt listeners should set this to PR_TRUE if they
* want to interrupt normal control flow, without throwing an error.
* @result error status returned by the listener. NS_OK
* should be used to indicate no error, proceed with normal control flow.
*/
NS_IMETHOD WillDo(nsITransactionManager *aManager,
nsITransaction *aTransaction,
PRBool *aInterrupt) = 0;
/**
* Called after a transaction manager calls the Do() method of
* a transaction.
* @param aManager the transaction manager that did the transaction.
* @param aTransaction the transaction that was done.
* @param aDoResult the nsresult returned after doing the transaction.
* @result error status returned by the listener.
*/
NS_IMETHOD DidDo(nsITransactionManager *aManager,
nsITransaction *aTransaction,
nsresult aDoResult) = 0;
/**
* Called before a transaction manager calls the Undo() method of
* a transaction.
* @param aManager the transaction manager undoing the transaction.
* @param aTransaction the transaction being undone.
* @param aInterrupt listeners should set this to PR_TRUE if they
* want to interrupt normal control flow, without throwing an error.
* @result error status returned by the listener. NS_OK
* should be used to indicate no error, proceed with normal control flow.
*/
NS_IMETHOD WillUndo(nsITransactionManager *aManager,
nsITransaction *aTransaction,
PRBool *aInterrupt) = 0;
/**
* Called after a transaction manager calls the Undo() method of
* a transaction.
* @param aManager the transaction manager undoing the transaction.
* @param aTransaction the transaction being undone.
* @param aUndoResult the nsresult returned after undoing the transaction.
* @result error status returned by the listener.
*/
NS_IMETHOD DidUndo(nsITransactionManager *aManager,
nsITransaction *aTransaction,
nsresult aUndoResult) = 0;
/**
* Called before a transaction manager calls the Redo() method of
* a transaction.
* @param aManager the transaction manager redoing the transaction.
* @param aTransaction the transaction being redone.
* @param aInterrupt listeners should set this to PR_TRUE if they
* want to interrupt normal control flow, without throwing an error.
* @result error status returned by the listener. NS_OK
* should be used to indicate no error, proceed with normal control flow.
*/
NS_IMETHOD WillRedo(nsITransactionManager *aManager,
nsITransaction *aTransaction,
PRBool *aInterrupt) = 0;
/**
* Called after a transaction manager calls the Redo() method of
* a transaction.
* @param aManager the transaction manager redoing the transaction.
* @param aTransaction the transaction being redone.
* @param aRedoResult the nsresult returned after redoing the transaction.
* @result error status returned by the listener.
*/
NS_IMETHOD DidRedo(nsITransactionManager *aManager,
nsITransaction *aTransaction,
nsresult aRedoResult) = 0;
/**
* Called before a transaction manager begins a batch.
* @param aManager the transaction manager beginning a batch.
* @param aInterrupt listeners should set this to PR_TRUE if they
* want to interrupt normal control flow, without throwing an error.
* @result error status returned by the listener. NS_OK
* should be used to indicate no error, proceed with normal control flow.
*/
NS_IMETHOD WillBeginBatch(nsITransactionManager *aManager,
PRBool *aInterrupt) = 0;
/**
* Called after a transaction manager begins a batch.
* @param aManager the transaction manager that began a batch.
* @param aResult the nsresult returned after beginning a batch.
* @result error status returned by the listener.
*/
NS_IMETHOD DidBeginBatch(nsITransactionManager *aManager,
nsresult aResult) = 0;
/**
* Called before a transaction manager ends a batch.
* @param aManager the transaction manager ending a batch.
* @param aInterrupt listeners should set this to PR_TRUE if they
* want to interrupt normal control flow, without throwing an error.
* @result error status returned by the listener. NS_OK
* should be used to indicate no error, proceed with normal control flow.
*/
NS_IMETHOD WillEndBatch(nsITransactionManager *aManager,
PRBool *aInterrupt) = 0;
/**
* Called after a transaction manager ends a batch.
* @param aManager the transaction manager ending a batch.
* @param aResult the nsresult returned after ending a batch.
* @result error status returned by the listener.
*/
NS_IMETHOD DidEndBatch(nsITransactionManager *aManager,
nsresult aResult) = 0;
/**
* Called before a transaction manager tries to merge
* a transaction, that was just executed, with the
* transaction at the top of the undo stack.
* @param aManager the transaction manager ending a batch.
* @param aTopTransaction the transaction at the top of the undo stack.
* @param aTransactionToMerge the transaction to merge.
* @param aInterrupt listeners should set this to PR_TRUE if they
* want to interrupt normal control flow, without throwing an error.
* @result error status returned by the listener. NS_OK
* should be used to indicate no error, proceed with normal control flow.
*/
NS_IMETHOD WillMerge(nsITransactionManager *aManager,
nsITransaction *aTopTransaction,
nsITransaction *aTransactionToMerge,
PRBool *aInterrupt) = 0;
/**
* Called after a transaction manager tries to merge
* a transaction, that was just executed, with the
* transaction at the top of the undo stack.
* @param aManager the transaction manager ending a batch.
* @param aTopTransaction the transaction at the top of the undo stack.
* @param aTransactionToMerge the transaction to merge.
* @param aDidMerge true if transaction was merged, else false.
* @param aMergeResult the nsresult returned after the merge attempt.
* @param aInterrupt listeners should set this to PR_TRUE if they
* want to interrupt normal control flow, without throwing an error.
* @result error status returned by the listener. NS_OK
* should be used to indicate no error, proceed with normal control flow.
*/
NS_IMETHOD DidMerge(nsITransactionManager *aManager,
nsITransaction *aTopTransaction,
nsITransaction *aTransactionToMerge,
PRBool aDidMerge,
nsresult aMergeResult) = 0;
/* XXX: We should probably add pruning notification methods. */
};
#endif // nsITransactionListener_h__

View File

@ -1,158 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsITransactionManager_h__
#define nsITransactionManager_h__
#include "nsISupports.h"
#include "nsIOutputStream.h"
#include "nsITransaction.h"
#include "nsITransactionListener.h"
/*
Transaction Manager interface to outside world
*/
#define NS_ITRANSACTIONMANAGER_IID \
{ /* 58E330C2-7B48-11d2-98B9-00805F297D89 */ \
0x58e330c2, 0x7b48, 0x11d2, \
{ 0x98, 0xb9, 0x0, 0x80, 0x5f, 0x29, 0x7d, 0x89 } }
/**
* A transaction manager specific interface.
* <P>
* It's implemented by an object that tracks transactions.
*/
class nsITransactionManager : public nsISupports{
public:
static const nsIID& GetIID() { static nsIID iid = NS_ITRANSACTIONMANAGER_IID; return iid; }
/**
* Calls a transaction's Do() method, then pushes it on the undo stack.
* <P>
* This method calls the transaction's AddRef() method.
* The transaction's Release() method will be called when the undo or redo
* stack is pruned or when the transaction manager is destroyed.
* @param aTransaction the transaction to do.
*/
NS_IMETHOD Do(nsITransaction *aTransaction) = 0;
/**
* Pops the topmost transaction on the undo stack, calls it's Undo() method,
* then pushes it on the redo stack.
*/
NS_IMETHOD Undo(void) = 0;
/**
* Pops the topmost transaction on the redo stack, calls it's Redo() method,
* then pushes it on the undo stack.
*/
NS_IMETHOD Redo(void) = 0;
/**
* Clears the undo and redo stacks.
*/
NS_IMETHOD Clear(void) = 0;
/**
* Turns on the transaction manager's batch mode, forcing all transactions
* executed by the transaction manager's Do() method to be aggregated
* together until EndBatch() is called. This mode allows an application to
* execute and group together several independent transactions so they
* can be undone with a single call to Undo().
*/
NS_IMETHOD BeginBatch() = 0;
/**
* Turns off the transaction manager's batch mode.
*/
NS_IMETHOD EndBatch() = 0;
/**
* Returns the number of items on the undo stack.
* @param aNumItems will contain number of items.
*/
NS_IMETHOD GetNumberOfUndoItems(PRInt32 *aNumItems) = 0;
/**
* Returns the number of items on the redo stack.
* @param aNumItems will contain number of items.
*/
NS_IMETHOD GetNumberOfRedoItems(PRInt32 *aNumItems) = 0;
/**
* Sets the maximum number of transaction items the transaction manager will
* maintain at any time. This is commonly referred to as the number of levels
* of undo.
* @param aMaxCount A value of -1 means no limit. A value of zero means the
* transaction manager will execute each transaction, then immediately release
* all references it has to the transaction without pushing it on the undo
* stack. A value greater than zero indicates the max number of transactions
* that can exist at any time on both the undo and redo stacks. This method
* will prune the neccessary number of transactions on the undo and redo
* stacks if the value specified is less than the number of items that exist
* on both the undo and redo stacks.
*/
NS_IMETHOD SetMaxTransactionCount(PRInt32 aMaxCount) = 0;
/**
* Returns a pointer to the transaction at the top of the undo stack.
* @param aTransaction will contain pointer to the transaction.
*/
NS_IMETHOD PeekUndoStack(nsITransaction **aTransaction) = 0;
/**
* Returns a pointer to the transaction at the top of the redo stack.
* @param aTransaction will contain pointer to the transaction.
*/
NS_IMETHOD PeekRedoStack(nsITransaction **aTransaction) = 0;
/**
* Writes a stream representation of the transaction manager and it's
* execution stacks. Calls the Write() method of each transaction on the
* execution stacks.
* @param aOutputStream the stream to write to.
*/
NS_IMETHOD Write(nsIOutputStream *aOutputStream) = 0;
/**
* Adds a listener to the transaction manager's notification list. Listeners
* are notified whenever a transaction is done, undone, or redone.
* <P>
* The listener's AddRef() method is called.
* @param aListener the lister to add.
*/
NS_IMETHOD AddListener(nsITransactionListener *aListener) = 0;
/**
* Removes a listener from the transaction manager's notification list.
* <P>
* The listener's Release() method is called.
* @param aListener the lister to remove.
*/
NS_IMETHOD RemoveListener(nsITransactionListener *aListener) = 0;
};
#endif // nsITransactionManager_h__