editor/libeditor/base/IMETextTxn.h

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:4b8182bf7e25
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 #ifndef IMETextTxn_h__
7 #define IMETextTxn_h__
8
9 #include "EditTxn.h"
10 #include "nsCOMPtr.h"
11 #include "nsCycleCollectionParticipant.h"
12 #include "nsID.h"
13 #include "nsIDOMCharacterData.h"
14 #include "nsString.h"
15 #include "nscore.h"
16 #include "mozilla/TextRange.h"
17
18 class nsITransaction;
19
20 // {D4D25721-2813-11d3-9EA3-0060089FE59B}
21 #define IME_TEXT_TXN_CID \
22 {0xd4d25721, 0x2813, 0x11d3, \
23 {0x9e, 0xa3, 0x0, 0x60, 0x8, 0x9f, 0xe5, 0x9b }}
24
25
26 class nsIEditor;
27
28
29 /**
30 * A transaction that inserts text into a content node.
31 */
32 class IMETextTxn : public EditTxn
33 {
34 public:
35 static const nsIID& GetCID() { static const nsIID iid = IME_TEXT_TXN_CID; return iid; }
36
37 /** initialize the transaction
38 * @param aElement the text content node
39 * @param aOffset the location in aElement to do the insertion
40 * @param aReplaceLength the length of text to replace (0 == no replacement)
41 * @param aTextRangeArray clauses and/or caret information. This may be null.
42 * @param aString the new text to insert
43 * @param aSelCon used to get and set the selection
44 */
45 NS_IMETHOD Init(nsIDOMCharacterData *aElement,
46 uint32_t aOffset,
47 uint32_t aReplaceLength,
48 mozilla::TextRangeArray* aTextRangeArray,
49 const nsAString& aString,
50 nsIEditor* aEditor);
51
52 IMETextTxn();
53
54 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IMETextTxn, EditTxn)
55
56 NS_DECL_EDITTXN
57
58 NS_IMETHOD Merge(nsITransaction *aTransaction, bool *aDidMerge);
59
60 NS_IMETHOD MarkFixed(void);
61
62 // nsISupports declarations
63
64 // override QueryInterface to handle IMETextTxn request
65 NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
66
67 protected:
68
69 nsresult SetSelectionForRanges();
70
71 /** the text element to operate upon */
72 nsCOMPtr<nsIDOMCharacterData> mElement;
73
74 /** the offsets into mElement where the insertion should be placed*/
75 uint32_t mOffset;
76
77 uint32_t mReplaceLength;
78
79 /** the text to insert into mElement at mOffset */
80 nsString mStringToInsert;
81
82 /** the range list **/
83 nsRefPtr<mozilla::TextRangeArray> mRanges;
84
85 /** the editor, which is used to get the selection controller */
86 nsIEditor *mEditor;
87
88 bool mFixed;
89 };
90
91 #endif

mercurial