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/. */
9 #include "EditTxn.h" // base class
10 #include "nsAutoPtr.h" // mTextNode, mRanges
11 #include "nsCycleCollectionParticipant.h" // various macros
12 #include "nsString.h" // mStringToInsert
16 #define NS_IMETEXTTXN_IID \
17 { 0xb391355d, 0x346c, 0x43d1, \
18 { 0x85, 0xed, 0x9e, 0x65, 0xbe, 0xe7, 0x7e, 0x48 } }
29 * A transaction that inserts text into a content node.
31 class IMETextTxn
: public EditTxn
34 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IMETEXTTXN_IID
)
36 /** @param aTextNode the text content node
37 * @param aOffset the location in aTextNode to do the insertion
38 * @param aReplaceLength the length of text to replace (0 == no replacement)
39 * @param aTextRangeArray clauses and/or caret information. This may be null.
40 * @param aString the new text to insert
41 * @param aEditor used to get and set the selection
43 IMETextTxn(Text
& aTextNode
, uint32_t aOffset
, uint32_t aReplaceLength
,
44 TextRangeArray
* aTextRangeArray
, const nsAString
& aString
,
47 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IMETextTxn
, EditTxn
)
49 NS_DECL_ISUPPORTS_INHERITED
53 NS_IMETHOD
Merge(nsITransaction
* aTransaction
, bool* aDidMerge
) MOZ_OVERRIDE
;
60 nsresult
SetSelectionForRanges();
62 /** The text element to operate upon */
63 nsRefPtr
<Text
> mTextNode
;
65 /** The offsets into mTextNode where the insertion should be placed */
68 uint32_t mReplaceLength
;
70 /** The range list **/
71 nsRefPtr
<mozilla::TextRangeArray
> mRanges
;
73 /** The text to insert into mTextNode at mOffset */
74 nsString mStringToInsert
;
76 /** The editor, which is used to get the selection controller */
82 NS_DEFINE_STATIC_IID_ACCESSOR(IMETextTxn
, NS_IMETEXTTXN_IID
)