зеркало из https://github.com/mozilla/gecko-dev.git
Updated nsITransaction and nsITransactionManager to match current spec.
This commit is contained in:
Родитель
cb2770d554
Коммит
5c09bb55a3
|
@ -18,8 +18,11 @@
|
||||||
|
|
||||||
#ifndef nsITransaction_h__
|
#ifndef nsITransaction_h__
|
||||||
#define nsITransaction_h__
|
#define nsITransaction_h__
|
||||||
|
|
||||||
#include "nsISupports.h"
|
#include "nsISupports.h"
|
||||||
#include "nsIOutputStream.h"
|
#include "nsIOutputStream.h"
|
||||||
|
#include "nsString.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Transaction interface to outside world
|
Transaction interface to outside world
|
||||||
*/
|
*/
|
||||||
|
@ -33,34 +36,49 @@ Transaction interface to outside world
|
||||||
/**
|
/**
|
||||||
* A transaction specific interface.
|
* A transaction specific interface.
|
||||||
* <P>
|
* <P>
|
||||||
* It's implemented by an object that executes some behavior that must be tracked
|
* It's implemented by an object that executes some behavior that must be
|
||||||
* by the transaction manager.
|
* tracked by the transaction manager.
|
||||||
*/
|
*/
|
||||||
class nsITransaction : public nsISupports{
|
class nsITransaction : public nsISupports{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute() tells the implementation of nsITransaction to execute itself.
|
* Executes the transaction.
|
||||||
*/
|
*/
|
||||||
virtual nsresult Execute(void) = 0;
|
virtual nsresult Do(void) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undo() tells the implementation of nsITransaction to undo it's execution.
|
* Restores the state to what it was before the transaction was executed.
|
||||||
*/
|
*/
|
||||||
virtual nsresult Undo(void) = 0;
|
virtual nsresult Undo(void) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Redo() tells the implementation of nsITransaction to redo it's execution.
|
* 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.
|
||||||
*/
|
*/
|
||||||
virtual nsresult Redo(void) = 0;
|
virtual nsresult Redo(void) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write() tells the implementation of nsITransaction to write a representation
|
* Write a stream representation of the current state of the transaction.
|
||||||
* of itself.
|
* @param aOutputStream the stream to write to.
|
||||||
* @param nsIOutputStream *
|
|
||||||
*/
|
*/
|
||||||
virtual nsresult Write(nsIOutputStream *) = 0;
|
virtual nsresult Write(nsIOutputStream *aOutputStream) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the string to display for the undo menu item.
|
||||||
|
* @param aString will point to string to display.
|
||||||
|
*/
|
||||||
|
virtual nsresult GetUndoString(nsString **aString) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the string to display for the redo menu item.
|
||||||
|
* @param aString will point to string to display.
|
||||||
|
*/
|
||||||
|
virtual nsresult GetRedoString(nsString **aString) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // nsITransaction
|
#endif // nsITransaction_h__
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,11 @@
|
||||||
|
|
||||||
#ifndef nsITransactionManager_h__
|
#ifndef nsITransactionManager_h__
|
||||||
#define nsITransactionManager_h__
|
#define nsITransactionManager_h__
|
||||||
|
|
||||||
#include "nsISupports.h"
|
#include "nsISupports.h"
|
||||||
#include "nsIOutputStream.h"
|
#include "nsIOutputStream.h"
|
||||||
#include "nsITransaction.h"
|
#include "nsITransaction.h"
|
||||||
// #include "nsITransactionListener.h"
|
#include "nsITransactionListener.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Transaction Manager interface to outside world
|
Transaction Manager interface to outside world
|
||||||
|
@ -42,62 +43,64 @@ class nsITransactionManager : public nsISupports{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute() calls the transaction's Execute() method and pushes it
|
* Places a transaction on the do stack and calls it's Do() method.
|
||||||
* on the undo queue. Execute() calls the transaction's AddRef() method.
|
* <P>
|
||||||
|
* This method calls the transaction's AddRef() method.
|
||||||
* The transaction's Release() method will be called when the undo or redo
|
* The transaction's Release() method will be called when the undo or redo
|
||||||
* stack is pruned or when the transaction manager is destroyed.
|
* stack is pruned or when the transaction manager is destroyed.
|
||||||
*
|
* @param aTransaction the transaction to do.
|
||||||
* @param nsITransaction *tx the transaction to execute.
|
|
||||||
*/
|
*/
|
||||||
virtual nsresult Execute(nsITransaction *tx) = 0;
|
virtual nsresult Do(nsITransaction *aTransaction) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undo() pops the specified number of transactions off the undo stack,
|
* Pops the topmost transaction on the do stack, pushes it on the undo
|
||||||
* calls their Undo() method, and pushes them onto the redo stack.
|
* stack, then calls it's Undo() method.
|
||||||
*
|
|
||||||
* @param PRInt32 n number of transactions to undo. n <= 0 means undo all
|
|
||||||
* transactions.
|
|
||||||
*/
|
*/
|
||||||
virtual nsresult Undo(PRInt32 n) = 0;
|
virtual nsresult Undo(void) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Redo() pops the specified number of transactions off the redo stack,
|
* Pops the topmost transaction on the undo stack, pushes it on the redo
|
||||||
* calls their Redo() method, and pushes them onto the undo stack.
|
* stack, then calls it's Redo() method.
|
||||||
*
|
|
||||||
* @param PRInt32 n number of transactions to redo. n <= 0 means redo all
|
|
||||||
* transactions previously undone.
|
|
||||||
*/
|
*/
|
||||||
virtual nsresult Redo(PRInt32 n) = 0;
|
virtual nsresult Redo(void) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write() allows the transaction manager to output a stream representation
|
* Returns the number of items on the undo stack.
|
||||||
* of itself, it then calls the Write() method of each transaction on the
|
* @param aNumItems will contain number of items.
|
||||||
* undo and redo stacks.
|
|
||||||
*
|
|
||||||
* @param nsIOutputStream *os output stream for writing.
|
|
||||||
*/
|
*/
|
||||||
virtual nsresult Write(nsIOutputStream *os) = 0;
|
virtual nsresult GetNumberOfUndoItems(PRInt32 *aNumItems) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AddListener() adds the specified listener to the transaction manager's
|
* Returns the number of items on the redo stack.
|
||||||
* list of listeners. The listener is notified whenever a transaction is
|
* @param aNumItems will contain number of items.
|
||||||
* executed, undone, or redone. AddListener() calls the listener's AddRef()
|
|
||||||
* method.
|
|
||||||
*
|
|
||||||
* @param nsITransactionListener *l the lister to add.
|
|
||||||
*/
|
*/
|
||||||
// virtual nsresult AddListener(nsITransactionListener *l) = 0;
|
virtual nsresult GetNumberOfRedoItems(PRInt32 *aNumItems) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RemoveListener() removes the specified listener from the transaction
|
* Writes a stream representation of the transaction manager and it's
|
||||||
* manager's list of listeners. Removing a listener that is not on the
|
* execution stacks. Calls the Write() method of each transaction on the
|
||||||
* transaction manager's list does nothing. RemoveListener() calls the
|
* execution stacks.
|
||||||
* listener's Release() method.
|
* @param aOutputStream the stream to write to.
|
||||||
*
|
|
||||||
* @param nsITransactionListener *l the lister to add.
|
|
||||||
*/
|
*/
|
||||||
// virtual nsresult RemoveListener(nsITransactionListener *l) = 0;
|
virtual nsresult 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.
|
||||||
|
*/
|
||||||
|
virtual nsresult 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.
|
||||||
|
*/
|
||||||
|
virtual nsresult RemoveListener(nsITransactionListener *aListener) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // nsITransactionManager
|
#endif // nsITransactionManager_h__
|
||||||
|
|
||||||
|
|
|
@ -31,25 +31,55 @@ NS_IMPL_ADDREF(nsTransactionManager)
|
||||||
NS_IMPL_RELEASE(nsTransactionManager)
|
NS_IMPL_RELEASE(nsTransactionManager)
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsTransactionManager::Execute(nsITransaction *tx)
|
nsTransactionManager::Do(nsITransaction *aTransaction)
|
||||||
{
|
{
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsTransactionManager::Undo(PRInt32 n)
|
nsTransactionManager::Undo()
|
||||||
{
|
{
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsTransactionManager::Redo(PRInt32 n)
|
nsTransactionManager::Redo()
|
||||||
{
|
{
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsTransactionManager::Write(nsIOutputStream *os)
|
nsTransactionManager::GetNumberOfUndoItems(PRInt32 *aNumItems)
|
||||||
|
{
|
||||||
|
if (aNumItems)
|
||||||
|
*aNumItems = 0;
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
nsTransactionManager::GetNumberOfRedoItems(PRInt32 *aNumItems)
|
||||||
|
{
|
||||||
|
if (aNumItems)
|
||||||
|
*aNumItems = 0;
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
nsTransactionManager::Write(nsIOutputStream *aOutputStream)
|
||||||
|
{
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
nsTransactionManager::AddListener(nsITransactionListener *aListener)
|
||||||
|
{
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
nsTransactionManager::RemoveListener(nsITransactionListener *aListener)
|
||||||
{
|
{
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,12 +39,15 @@ public:
|
||||||
/* Macro for AddRef(), Release(), and QueryInterface() */
|
/* Macro for AddRef(), Release(), and QueryInterface() */
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
|
|
||||||
virtual nsresult Execute(nsITransaction *tx);
|
/* nsITransactionManager method implementations. */
|
||||||
virtual nsresult Undo(PRInt32 n);
|
virtual nsresult Do(nsITransaction *aTransaction);
|
||||||
virtual nsresult Redo(PRInt32 n);
|
virtual nsresult Undo(void);
|
||||||
virtual nsresult Write(nsIOutputStream *os);
|
virtual nsresult Redo(void);
|
||||||
// virtual nsresult AddListener(nsITransactionListener *l);
|
virtual nsresult GetNumberOfUndoItems(PRInt32 *aNumItems);
|
||||||
// virtual nsresult RemoveListener(nsITransactionListener *l);
|
virtual nsresult GetNumberOfRedoItems(PRInt32 *aNumItems);
|
||||||
|
virtual nsresult Write(nsIOutputStream *aOutputStream);
|
||||||
|
virtual nsresult AddListener(nsITransactionListener *aListener);
|
||||||
|
virtual nsresult RemoveListener(nsITransactionListener *aListener);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // nsTransactionManager_h__
|
#endif // nsTransactionManager_h__
|
||||||
|
|
Загрузка…
Ссылка в новой задаче