1999-01-14 21:02:45 +03:00
|
|
|
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
|
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* NPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
|
|
* Reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef DeleteRangeTxn_h__
|
|
|
|
#define DeleteRangeTxn_h__
|
|
|
|
|
1999-01-21 04:51:09 +03:00
|
|
|
#include "EditAggregateTxn.h"
|
1999-01-14 21:02:45 +03:00
|
|
|
#include "nsIDOMNode.h"
|
1999-03-09 23:04:59 +03:00
|
|
|
#include "nsIDOMRange.h"
|
1999-01-21 04:51:09 +03:00
|
|
|
#include "nsIEditor.h"
|
1999-01-14 21:02:45 +03:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
|
|
|
|
class nsIDOMDocument;
|
1999-01-21 04:51:09 +03:00
|
|
|
|
|
|
|
#define DELETE_RANGE_TXN_IID \
|
|
|
|
{/* 5ec6b260-ac49-11d2-86d8-000064657374 */ \
|
|
|
|
0x5ec6b260, 0xac49, 0x11d2, \
|
|
|
|
{0x86, 0xd8, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74} }
|
1999-01-14 21:02:45 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A transaction that deletes an entire range in the content tree
|
|
|
|
*/
|
1999-01-21 04:51:09 +03:00
|
|
|
class DeleteRangeTxn : public EditAggregateTxn
|
1999-01-14 21:02:45 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
1999-02-15 21:25:30 +03:00
|
|
|
/** initialize the transaction.
|
1999-02-17 22:42:29 +03:00
|
|
|
* @param aEditor the object providing basic editing operations
|
1999-02-15 21:25:30 +03:00
|
|
|
* @param aRange the range to delete
|
|
|
|
*/
|
1999-03-02 08:30:53 +03:00
|
|
|
NS_IMETHOD Init(nsIEditor *aEditor, nsIDOMRange *aRange);
|
1999-01-21 04:51:09 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
DeleteRangeTxn();
|
|
|
|
|
|
|
|
public:
|
1999-01-14 21:02:45 +03:00
|
|
|
|
|
|
|
virtual ~DeleteRangeTxn();
|
|
|
|
|
1999-03-02 08:30:53 +03:00
|
|
|
NS_IMETHOD Do(void);
|
1999-01-14 21:02:45 +03:00
|
|
|
|
1999-03-02 08:30:53 +03:00
|
|
|
NS_IMETHOD Undo(void);
|
1999-01-14 21:02:45 +03:00
|
|
|
|
1999-03-02 08:30:53 +03:00
|
|
|
NS_IMETHOD Redo(void);
|
1999-01-14 21:02:45 +03:00
|
|
|
|
1999-03-02 08:30:53 +03:00
|
|
|
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
1999-01-14 21:02:45 +03:00
|
|
|
|
1999-03-02 08:30:53 +03:00
|
|
|
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
1999-01-14 21:02:45 +03:00
|
|
|
|
1999-03-02 08:30:53 +03:00
|
|
|
NS_IMETHOD GetUndoString(nsString **aString);
|
1999-01-14 21:02:45 +03:00
|
|
|
|
1999-03-02 08:30:53 +03:00
|
|
|
NS_IMETHOD GetRedoString(nsString **aString);
|
1999-01-14 21:02:45 +03:00
|
|
|
|
1999-01-21 04:51:09 +03:00
|
|
|
protected:
|
|
|
|
|
1999-03-02 08:30:53 +03:00
|
|
|
NS_IMETHOD CreateTxnsToDeleteBetween(nsIDOMNode *aStartParent,
|
1999-01-21 04:51:09 +03:00
|
|
|
PRUint32 aStartOffset,
|
|
|
|
PRUint32 aEndOffset);
|
|
|
|
|
1999-03-09 22:22:48 +03:00
|
|
|
NS_IMETHOD CreateTxnsToDeleteNodesBetween();
|
1999-01-21 04:51:09 +03:00
|
|
|
|
1999-03-02 08:30:53 +03:00
|
|
|
NS_IMETHOD CreateTxnsToDeleteContent(nsIDOMNode *aParent,
|
1999-01-21 04:51:09 +03:00
|
|
|
PRUint32 aOffset,
|
|
|
|
nsIEditor::Direction aDir);
|
|
|
|
|
1999-01-14 21:02:45 +03:00
|
|
|
protected:
|
|
|
|
|
1999-03-09 22:22:48 +03:00
|
|
|
/** p1 in the range */
|
|
|
|
nsCOMPtr<nsIDOMRange> mRange;
|
|
|
|
|
1999-01-14 21:02:45 +03:00
|
|
|
/** p1 in the range */
|
|
|
|
nsCOMPtr<nsIDOMNode> mStartParent;
|
|
|
|
|
|
|
|
/** p1 offset */
|
|
|
|
PRInt32 mStartOffset;
|
|
|
|
|
|
|
|
/** p2 in the range */
|
|
|
|
nsCOMPtr<nsIDOMNode> mEndParent;
|
|
|
|
|
1999-01-21 04:51:09 +03:00
|
|
|
/** the closest common parent of p1 and p2 */
|
|
|
|
nsCOMPtr<nsIDOMNode> mCommonParent;
|
|
|
|
|
1999-01-14 21:02:45 +03:00
|
|
|
/** p2 offset */
|
|
|
|
PRInt32 mEndOffset;
|
|
|
|
|
1999-02-17 22:42:29 +03:00
|
|
|
/** the editor for this transaction */
|
|
|
|
nsCOMPtr<nsIEditor> mEditor;
|
|
|
|
|
1999-01-21 04:51:09 +03:00
|
|
|
friend class TransactionFactory;
|
|
|
|
|
1999-01-14 21:02:45 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|