2001-09-26 02:53:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 18:21:17 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1999-03-15 03:57:32 +03:00
|
|
|
*
|
2004-04-18 18:21:17 +04:00
|
|
|
* The contents of this file are subject to the Mozilla 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/MPL/
|
1999-03-15 03:57:32 +03:00
|
|
|
*
|
2001-09-26 02:53:13 +04:00
|
|
|
* 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.
|
1999-03-15 03:57:32 +03:00
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 18:21:17 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-26 02:53:13 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998-1999
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:43:54 +03:00
|
|
|
*
|
2001-09-26 02:53:13 +04:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 18:21:17 +04:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-26 02:53:13 +04:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 18:21:17 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-26 02:53:13 +04:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 18:21:17 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-26 02:53:13 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-03-15 03:57:32 +03:00
|
|
|
|
|
|
|
#ifndef AggregatePlaceholderTxn_h__
|
|
|
|
#define AggregatePlaceholderTxn_h__
|
|
|
|
|
|
|
|
#include "EditAggregateTxn.h"
|
2000-01-31 13:30:12 +03:00
|
|
|
#include "nsEditorUtils.h"
|
1999-09-30 00:08:15 +04:00
|
|
|
#include "nsIAbsorbingTransaction.h"
|
|
|
|
#include "nsIDOMNode.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsWeakPtr.h"
|
|
|
|
#include "nsWeakReference.h"
|
2007-01-11 17:38:02 +03:00
|
|
|
#include "nsAutoPtr.h"
|
1999-03-15 03:57:32 +03:00
|
|
|
|
1999-09-30 00:08:15 +04:00
|
|
|
class nsHTMLEditor;
|
1999-10-26 22:54:47 +04:00
|
|
|
class IMETextTxn;
|
1999-09-30 00:08:15 +04:00
|
|
|
|
1999-03-15 03:57:32 +03:00
|
|
|
/**
|
|
|
|
* An aggregate transaction that knows how to absorb all subsequent
|
|
|
|
* transactions with the same name. This transaction does not "Do" anything.
|
|
|
|
* But it absorbs other transactions via merge, and can undo/redo the
|
|
|
|
* transactions it has absorbed.
|
|
|
|
*/
|
1999-09-30 00:08:15 +04:00
|
|
|
|
|
|
|
class PlaceholderTxn : public EditAggregateTxn,
|
|
|
|
public nsIAbsorbingTransaction,
|
|
|
|
public nsSupportsWeakReference
|
1999-03-15 03:57:32 +03:00
|
|
|
{
|
|
|
|
public:
|
1999-09-30 00:08:15 +04:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
1999-03-15 03:57:32 +03:00
|
|
|
PlaceholderTxn();
|
|
|
|
|
2009-05-09 08:59:25 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(PlaceholderTxn, EditAggregateTxn)
|
1999-09-30 00:08:15 +04:00
|
|
|
// ------------ EditAggregateTxn -----------------------
|
|
|
|
|
2007-01-11 17:38:02 +03:00
|
|
|
NS_DECL_EDITTXN
|
1999-09-30 00:08:15 +04:00
|
|
|
|
2007-01-11 17:38:02 +03:00
|
|
|
NS_IMETHOD RedoTransaction();
|
2001-03-09 17:23:59 +03:00
|
|
|
NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
|
|
|
|
|
1999-09-30 00:08:15 +04:00
|
|
|
// ------------ nsIAbsorbingTransaction -----------------------
|
|
|
|
|
2000-06-30 08:58:34 +04:00
|
|
|
NS_IMETHOD Init(nsIAtom *aName, nsSelectionState *aSelState, nsIEditor *aEditor);
|
1999-09-30 00:08:15 +04:00
|
|
|
|
|
|
|
NS_IMETHOD GetTxnName(nsIAtom **aName);
|
|
|
|
|
2000-01-31 13:30:12 +03:00
|
|
|
NS_IMETHOD StartSelectionEquals(nsSelectionState *aSelState, PRBool *aResult);
|
1999-09-30 00:08:15 +04:00
|
|
|
|
|
|
|
NS_IMETHOD EndPlaceHolderBatch();
|
|
|
|
|
|
|
|
NS_IMETHOD ForwardEndBatchTo(nsIAbsorbingTransaction *aForwardingAddress);
|
1999-03-15 03:57:32 +03:00
|
|
|
|
1999-10-26 22:54:47 +04:00
|
|
|
NS_IMETHOD Commit();
|
|
|
|
|
2000-01-31 13:30:12 +03:00
|
|
|
NS_IMETHOD RememberEndingSelection();
|
1999-03-15 03:57:32 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
1999-09-30 00:08:15 +04:00
|
|
|
/** the presentation shell, which we'll need to get the selection */
|
1999-10-26 22:54:47 +04:00
|
|
|
PRBool mAbsorb; // do we auto absorb any and all transaction?
|
|
|
|
nsWeakPtr mForwarding;
|
|
|
|
IMETextTxn *mIMETextTxn; // first IME txn in this placeholder - used for IME merging
|
2005-11-26 00:57:13 +03:00
|
|
|
// non-owning for now - can't nsCOMPtr it due to broken transaction interfaces
|
1999-10-26 22:54:47 +04:00
|
|
|
PRBool mCommitted; // do we stop auto absorbing any matching placeholder txns?
|
2000-01-31 13:30:12 +03:00
|
|
|
// these next two members store the state of the selection in a safe way.
|
|
|
|
// selection at the start of the txn is stored, as is the selection at the end.
|
2001-03-09 17:23:59 +03:00
|
|
|
// This is so that UndoTransaction() and RedoTransaction() can restore the
|
|
|
|
// selection properly.
|
2007-01-11 17:38:02 +03:00
|
|
|
nsAutoPtr<nsSelectionState> mStartSel; // use a pointer because this is constructed before we exist
|
2000-01-31 13:30:12 +03:00
|
|
|
nsSelectionState mEndSel;
|
2000-06-30 08:58:34 +04:00
|
|
|
nsIEditor* mEditor; /** the editor for this transaction */
|
1999-03-15 03:57:32 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|