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 IMETextTxn_h__
39 : #define IMETextTxn_h__
40 :
41 : #include "EditTxn.h"
42 : #include "nsIDOMCharacterData.h"
43 : #include "nsIPrivateTextRange.h"
44 : #include "nsCOMPtr.h"
45 : #include "nsWeakPtr.h"
46 : #include "nsIAtom.h"
47 :
48 : // {D4D25721-2813-11d3-9EA3-0060089FE59B}
49 : #define IME_TEXT_TXN_CID \
50 : {0xd4d25721, 0x2813, 0x11d3, \
51 : {0x9e, 0xa3, 0x0, 0x60, 0x8, 0x9f, 0xe5, 0x9b }}
52 :
53 :
54 : class nsIEditor;
55 :
56 :
57 : /**
58 : * A transaction that inserts text into a content node.
59 : */
60 : class IMETextTxn : public EditTxn
61 0 : {
62 : public:
63 0 : static const nsIID& GetCID() { static const nsIID iid = IME_TEXT_TXN_CID; return iid; }
64 :
65 : /** initialize the transaction
66 : * @param aElement the text content node
67 : * @param aOffset the location in aElement to do the insertion
68 : * @param aReplaceLength the length of text to replace (0 == no replacement)
69 : * @param aString the new text to insert
70 : * @param aSelCon used to get and set the selection
71 : */
72 : NS_IMETHOD Init(nsIDOMCharacterData *aElement,
73 : PRUint32 aOffset,
74 : PRUint32 aReplaceLength,
75 : nsIPrivateTextRangeList* aTextRangeList,
76 : const nsAString& aString,
77 : nsIEditor* aEditor);
78 :
79 : IMETextTxn();
80 :
81 1464 : NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IMETextTxn, EditTxn)
82 :
83 : NS_DECL_EDITTXN
84 :
85 : NS_IMETHOD Merge(nsITransaction *aTransaction, bool *aDidMerge);
86 :
87 : NS_IMETHOD MarkFixed(void);
88 :
89 : // nsISupports declarations
90 :
91 : // override QueryInterface to handle IMETextTxn request
92 : NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
93 :
94 : /** return the string data associated with this transaction */
95 : NS_IMETHOD GetData(nsString& aResult, nsIPrivateTextRangeList** aTextRangeList);
96 :
97 : protected:
98 :
99 : NS_IMETHOD CollapseTextSelection(void);
100 :
101 : /** the text element to operate upon */
102 : nsCOMPtr<nsIDOMCharacterData> mElement;
103 :
104 : /** the offsets into mElement where the insertion should be placed*/
105 : PRUint32 mOffset;
106 :
107 : PRUint32 mReplaceLength;
108 :
109 : /** the text to insert into mElement at mOffset */
110 : nsString mStringToInsert;
111 :
112 : /** the range list **/
113 : nsCOMPtr<nsIPrivateTextRangeList> mRangeList;
114 :
115 : /** the editor, which is used to get the selection controller */
116 : nsIEditor *mEditor;
117 :
118 : bool mFixed;
119 : };
120 :
121 : #endif
|