2001-09-26 02:53:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-01-07 04:02:32 +03:00
|
|
|
|
|
|
|
#ifndef InsertTextTxn_h__
|
|
|
|
#define InsertTextTxn_h__
|
|
|
|
|
2012-07-13 10:33:42 +04:00
|
|
|
#include "EditTxn.h" // for EditTxn, NS_DECL_EDITTXN
|
|
|
|
#include "nsCOMPtr.h" // for nsCOMPtr
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsID.h" // for nsIID
|
|
|
|
#include "nsIDOMCharacterData.h" // for nsIDOMCharacterData
|
|
|
|
#include "nsISupportsImpl.h" // for NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
#include "nsString.h" // for nsString
|
|
|
|
#include "nscore.h" // for NS_IMETHOD, nsAString
|
|
|
|
|
|
|
|
class nsIEditor;
|
|
|
|
class nsITransaction;
|
|
|
|
|
1999-01-07 04:02:32 +03:00
|
|
|
|
1999-07-15 23:13:46 +04:00
|
|
|
#define INSERT_TEXT_TXN_CID \
|
1999-01-14 21:02:45 +03:00
|
|
|
{/* 93276f00-ab2c-11d2-8f4b-006008159b0c*/ \
|
|
|
|
0x93276f00, 0xab2c, 0x11d2, \
|
|
|
|
{0x8f, 0xb4, 0x0, 0x60, 0x8, 0x15, 0x9b, 0xc} }
|
|
|
|
|
1999-01-07 04:02:32 +03:00
|
|
|
/**
|
1999-02-15 21:25:30 +03:00
|
|
|
* A transaction that inserts text into a content node.
|
|
|
|
*/
|
1999-01-07 04:02:32 +03:00
|
|
|
class InsertTextTxn : public EditTxn
|
|
|
|
{
|
|
|
|
public:
|
1999-07-15 23:13:46 +04:00
|
|
|
|
2002-06-26 07:38:55 +04:00
|
|
|
static const nsIID& GetCID() { static const nsIID iid = INSERT_TEXT_TXN_CID; return iid; }
|
1999-07-15 23:13:46 +04:00
|
|
|
|
1999-02-15 21:25:30 +03:00
|
|
|
/** initialize the transaction
|
|
|
|
* @param aElement the text content node
|
|
|
|
* @param aOffset the location in aElement to do the insertion
|
|
|
|
* @param aString the new text to insert
|
|
|
|
* @param aPresShell used to get and set the selection
|
|
|
|
*/
|
1999-03-02 08:30:53 +03:00
|
|
|
NS_IMETHOD Init(nsIDOMCharacterData *aElement,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aOffset,
|
2002-03-24 01:16:54 +03:00
|
|
|
const nsAString& aString,
|
2000-01-04 06:09:41 +03:00
|
|
|
nsIEditor *aEditor);
|
1999-01-07 04:02:32 +03:00
|
|
|
|
2009-04-25 02:45:34 +04:00
|
|
|
InsertTextTxn();
|
1999-01-15 03:03:41 +03:00
|
|
|
|
2011-02-20 01:18:37 +03:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2009-05-09 08:59:25 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(InsertTextTxn, EditTxn)
|
1999-01-15 03:03:41 +03:00
|
|
|
|
2007-01-11 17:38:02 +03:00
|
|
|
NS_DECL_EDITTXN
|
1999-01-07 04:02:32 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHOD Merge(nsITransaction *aTransaction, bool *aDidMerge);
|
1999-01-07 04:02:32 +03:00
|
|
|
|
1999-01-28 22:00:14 +03:00
|
|
|
/** return the string data associated with this transaction */
|
1999-03-02 08:30:53 +03:00
|
|
|
NS_IMETHOD GetData(nsString& aResult);
|
1999-01-14 21:02:45 +03:00
|
|
|
|
1999-01-07 04:02:32 +03:00
|
|
|
protected:
|
2014-07-09 01:23:18 +04:00
|
|
|
virtual ~InsertTextTxn();
|
1999-01-28 22:00:14 +03:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
/** return true if aOtherTxn immediately follows this txn */
|
2011-09-29 10:19:26 +04:00
|
|
|
virtual bool IsSequentialInsert(InsertTextTxn *aOtherTxn);
|
1999-01-07 04:02:32 +03:00
|
|
|
|
|
|
|
/** the text element to operate upon */
|
1999-01-21 04:51:09 +03:00
|
|
|
nsCOMPtr<nsIDOMCharacterData> mElement;
|
1999-01-07 04:02:32 +03:00
|
|
|
|
|
|
|
/** the offset into mElement where the insertion is to take place */
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mOffset;
|
1999-01-07 04:02:32 +03:00
|
|
|
|
|
|
|
/** the text to insert into mElement at mOffset */
|
|
|
|
nsString mStringToInsert;
|
|
|
|
|
2000-01-04 06:09:41 +03:00
|
|
|
/** the editor, which we'll need to get the selection */
|
|
|
|
nsIEditor *mEditor;
|
1999-01-07 04:02:32 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|