1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Original Code is mozilla.org code.
16 : *
17 : * The Initial Developer of the Original Code is
18 : * Netscape Communications Corporation.
19 : * Portions created by the Initial Developer are Copyright (C) 1998-1999
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : *
24 : * Alternatively, the contents of this file may be used under the terms of
25 : * either of the GNU General Public License Version 2 or later (the "GPL"),
26 : * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 : * in which case the provisions of the GPL or the LGPL are applicable instead
28 : * of those above. If you wish to allow use of your version of this file only
29 : * under the terms of either the GPL or the LGPL, and not to allow others to
30 : * use your version of this file under the terms of the MPL, indicate your
31 : * decision by deleting the provisions above and replace them with the notice
32 : * and other provisions required by the GPL or the LGPL. If you do not delete
33 : * the provisions above, a recipient may use your version of this file under
34 : * the terms of any one of the MPL, the GPL or the LGPL.
35 : *
36 : * ***** END LICENSE BLOCK ***** */
37 :
38 : #ifndef InsertTextTxn_h__
39 : #define InsertTextTxn_h__
40 :
41 : #include "EditTxn.h"
42 : #include "nsIDOMCharacterData.h"
43 : #include "nsIEditor.h"
44 : #include "nsCOMPtr.h"
45 :
46 : #define INSERT_TEXT_TXN_CID \
47 : {/* 93276f00-ab2c-11d2-8f4b-006008159b0c*/ \
48 : 0x93276f00, 0xab2c, 0x11d2, \
49 : {0x8f, 0xb4, 0x0, 0x60, 0x8, 0x15, 0x9b, 0xc} }
50 :
51 : /**
52 : * A transaction that inserts text into a content node.
53 : */
54 : class InsertTextTxn : public EditTxn
55 0 : {
56 : public:
57 :
58 0 : static const nsIID& GetCID() { static const nsIID iid = INSERT_TEXT_TXN_CID; return iid; }
59 :
60 : /** initialize the transaction
61 : * @param aElement the text content node
62 : * @param aOffset the location in aElement to do the insertion
63 : * @param aString the new text to insert
64 : * @param aPresShell used to get and set the selection
65 : */
66 : NS_IMETHOD Init(nsIDOMCharacterData *aElement,
67 : PRUint32 aOffset,
68 : const nsAString& aString,
69 : nsIEditor *aEditor);
70 :
71 : InsertTextTxn();
72 :
73 : NS_DECL_ISUPPORTS_INHERITED
74 1464 : NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(InsertTextTxn, EditTxn)
75 :
76 : NS_DECL_EDITTXN
77 :
78 : NS_IMETHOD Merge(nsITransaction *aTransaction, bool *aDidMerge);
79 :
80 : /** return the string data associated with this transaction */
81 : NS_IMETHOD GetData(nsString& aResult);
82 :
83 : protected:
84 :
85 : /** return true if aOtherTxn immediately follows this txn */
86 : virtual bool IsSequentialInsert(InsertTextTxn *aOtherTxn);
87 :
88 : /** the text element to operate upon */
89 : nsCOMPtr<nsIDOMCharacterData> mElement;
90 :
91 : /** the offset into mElement where the insertion is to take place */
92 : PRUint32 mOffset;
93 :
94 : /** the text to insert into mElement at mOffset */
95 : nsString mStringToInsert;
96 :
97 : /** the editor, which we'll need to get the selection */
98 : nsIEditor *mEditor;
99 : };
100 :
101 : #endif
|