Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "nsISupports.idl" |
michael@0 | 7 | #include "nsITransaction.idl" |
michael@0 | 8 | #include "nsITransactionList.idl" |
michael@0 | 9 | #include "nsITransactionListener.idl" |
michael@0 | 10 | |
michael@0 | 11 | %{ C++ |
michael@0 | 12 | |
michael@0 | 13 | #define NS_TRANSACTIONMANAGER_CONTRACTID "@mozilla.org/transactionmanager;1" |
michael@0 | 14 | |
michael@0 | 15 | %} C++ |
michael@0 | 16 | |
michael@0 | 17 | /** |
michael@0 | 18 | * The nsITransactionManager interface. |
michael@0 | 19 | * <P> |
michael@0 | 20 | * This interface is implemented by an object that wants to |
michael@0 | 21 | * manage/track transactions. |
michael@0 | 22 | */ |
michael@0 | 23 | [scriptable, builtinclass, uuid(c77763df-0fb9-41a8-8074-8e882f605755)] |
michael@0 | 24 | interface nsITransactionManager : nsISupports |
michael@0 | 25 | { |
michael@0 | 26 | /** |
michael@0 | 27 | * Calls a transaction's doTransaction() method, then pushes it on the |
michael@0 | 28 | * undo stack. |
michael@0 | 29 | * <P> |
michael@0 | 30 | * This method calls the transaction's AddRef() method. |
michael@0 | 31 | * The transaction's Release() method will be called when the undo or redo |
michael@0 | 32 | * stack is pruned or when the transaction manager is destroyed. |
michael@0 | 33 | * @param aTransaction the transaction to do. |
michael@0 | 34 | */ |
michael@0 | 35 | void doTransaction(in nsITransaction aTransaction); |
michael@0 | 36 | |
michael@0 | 37 | /** |
michael@0 | 38 | * Pops the topmost transaction on the undo stack, calls its |
michael@0 | 39 | * undoTransaction() method, then pushes it on the redo stack. |
michael@0 | 40 | */ |
michael@0 | 41 | void undoTransaction(); |
michael@0 | 42 | |
michael@0 | 43 | /** |
michael@0 | 44 | * Pops the topmost transaction on the redo stack, calls its |
michael@0 | 45 | * redoTransaction() method, then pushes it on the undo stack. |
michael@0 | 46 | */ |
michael@0 | 47 | void redoTransaction(); |
michael@0 | 48 | |
michael@0 | 49 | /** |
michael@0 | 50 | * Clears the undo and redo stacks. |
michael@0 | 51 | */ |
michael@0 | 52 | void clear(); |
michael@0 | 53 | |
michael@0 | 54 | /** |
michael@0 | 55 | * Clears the undo stack only. |
michael@0 | 56 | */ |
michael@0 | 57 | void clearUndoStack(); |
michael@0 | 58 | |
michael@0 | 59 | /** |
michael@0 | 60 | * Clears the redo stack only. |
michael@0 | 61 | */ |
michael@0 | 62 | void clearRedoStack(); |
michael@0 | 63 | |
michael@0 | 64 | /** |
michael@0 | 65 | * Turns on the transaction manager's batch mode, forcing all transactions |
michael@0 | 66 | * executed by the transaction manager's doTransaction() method to be |
michael@0 | 67 | * aggregated together until EndBatch() is called. This mode allows an |
michael@0 | 68 | * application to execute and group together several independent transactions |
michael@0 | 69 | * so they can be undone with a single call to undoTransaction(). |
michael@0 | 70 | * @param aData An arbitrary nsISupports object that is associated with the |
michael@0 | 71 | * batch. Can be retrieved from nsITransactionList. |
michael@0 | 72 | */ |
michael@0 | 73 | void beginBatch(in nsISupports aData); |
michael@0 | 74 | |
michael@0 | 75 | /** |
michael@0 | 76 | * Turns off the transaction manager's batch mode. |
michael@0 | 77 | * @param aAllowEmpty If true, a batch containing no children will be |
michael@0 | 78 | * pushed onto the undo stack. Otherwise, ending a batch with no |
michael@0 | 79 | * children will result in no transactions being pushed on the undo stack. |
michael@0 | 80 | */ |
michael@0 | 81 | void endBatch(in boolean aAllowEmpty); |
michael@0 | 82 | |
michael@0 | 83 | /** |
michael@0 | 84 | * The number of items on the undo stack. |
michael@0 | 85 | */ |
michael@0 | 86 | readonly attribute long numberOfUndoItems; |
michael@0 | 87 | |
michael@0 | 88 | /** |
michael@0 | 89 | * The number of items on the redo stack. |
michael@0 | 90 | */ |
michael@0 | 91 | readonly attribute long numberOfRedoItems; |
michael@0 | 92 | |
michael@0 | 93 | /** |
michael@0 | 94 | * Sets the maximum number of transaction items the transaction manager will |
michael@0 | 95 | * maintain at any time. This is commonly referred to as the number of levels |
michael@0 | 96 | * of undo. |
michael@0 | 97 | * @param aMaxCount A value of -1 means no limit. A value of zero means the |
michael@0 | 98 | * transaction manager will execute each transaction, then immediately release |
michael@0 | 99 | * all references it has to the transaction without pushing it on the undo |
michael@0 | 100 | * stack. A value greater than zero indicates the max number of transactions |
michael@0 | 101 | * that can exist at any time on both the undo and redo stacks. This method |
michael@0 | 102 | * will prune the necessary number of transactions on the undo and redo |
michael@0 | 103 | * stacks if the value specified is less than the number of items that exist |
michael@0 | 104 | * on both the undo and redo stacks. |
michael@0 | 105 | */ |
michael@0 | 106 | attribute long maxTransactionCount; |
michael@0 | 107 | |
michael@0 | 108 | /** |
michael@0 | 109 | * Combines the transaction at the top of the undo stack (if any) with the |
michael@0 | 110 | * preceding undo transaction (if any) into a batch transaction. Thus, |
michael@0 | 111 | * a call to undoTransaction() will undo both transactions. |
michael@0 | 112 | */ |
michael@0 | 113 | void batchTopUndo(); |
michael@0 | 114 | |
michael@0 | 115 | /** |
michael@0 | 116 | * Removes the transaction at the top of the undo stack (if any) without |
michael@0 | 117 | * transacting. |
michael@0 | 118 | */ |
michael@0 | 119 | void removeTopUndo(); |
michael@0 | 120 | |
michael@0 | 121 | /** |
michael@0 | 122 | * Returns an AddRef'd pointer to the transaction at the top of the |
michael@0 | 123 | * undo stack. Callers should be aware that this method could return |
michael@0 | 124 | * return a null in some implementations if there is a batch at the top |
michael@0 | 125 | * of the undo stack. |
michael@0 | 126 | */ |
michael@0 | 127 | nsITransaction peekUndoStack(); |
michael@0 | 128 | |
michael@0 | 129 | /** |
michael@0 | 130 | * Returns an AddRef'd pointer to the transaction at the top of the |
michael@0 | 131 | * redo stack. Callers should be aware that this method could return |
michael@0 | 132 | * return a null in some implementations if there is a batch at the top |
michael@0 | 133 | * of the redo stack. |
michael@0 | 134 | */ |
michael@0 | 135 | nsITransaction peekRedoStack(); |
michael@0 | 136 | |
michael@0 | 137 | /** |
michael@0 | 138 | * Returns the list of transactions on the undo stack. Note that the |
michael@0 | 139 | * transaction at the top of the undo stack will actually be at the |
michael@0 | 140 | * index 'n-1' in the list, where 'n' is the number of items in the list. |
michael@0 | 141 | */ |
michael@0 | 142 | nsITransactionList getUndoList(); |
michael@0 | 143 | |
michael@0 | 144 | /** |
michael@0 | 145 | * Returns the list of transactions on the redo stack. Note that the |
michael@0 | 146 | * transaction at the top of the redo stack will actually be at the |
michael@0 | 147 | * index 'n-1' in the list, where 'n' is the number of items in the list. |
michael@0 | 148 | */ |
michael@0 | 149 | nsITransactionList getRedoList(); |
michael@0 | 150 | |
michael@0 | 151 | /** |
michael@0 | 152 | * Adds a listener to the transaction manager's notification list. Listeners |
michael@0 | 153 | * are notified whenever a transaction is done, undone, or redone. |
michael@0 | 154 | * <P> |
michael@0 | 155 | * The listener's AddRef() method is called. |
michael@0 | 156 | * @param aListener the lister to add. |
michael@0 | 157 | */ |
michael@0 | 158 | void AddListener(in nsITransactionListener aListener); |
michael@0 | 159 | |
michael@0 | 160 | /** |
michael@0 | 161 | * Removes a listener from the transaction manager's notification list. |
michael@0 | 162 | * <P> |
michael@0 | 163 | * The listener's Release() method is called. |
michael@0 | 164 | * @param aListener the lister to remove. |
michael@0 | 165 | */ |
michael@0 | 166 | void RemoveListener(in nsITransactionListener aListener); |
michael@0 | 167 | }; |
michael@0 | 168 |