michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef IMETextTxn_h__ michael@0: #define IMETextTxn_h__ michael@0: michael@0: #include "EditTxn.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsCycleCollectionParticipant.h" michael@0: #include "nsID.h" michael@0: #include "nsIDOMCharacterData.h" michael@0: #include "nsString.h" michael@0: #include "nscore.h" michael@0: #include "mozilla/TextRange.h" michael@0: michael@0: class nsITransaction; michael@0: michael@0: // {D4D25721-2813-11d3-9EA3-0060089FE59B} michael@0: #define IME_TEXT_TXN_CID \ michael@0: {0xd4d25721, 0x2813, 0x11d3, \ michael@0: {0x9e, 0xa3, 0x0, 0x60, 0x8, 0x9f, 0xe5, 0x9b }} michael@0: michael@0: michael@0: class nsIEditor; michael@0: michael@0: michael@0: /** michael@0: * A transaction that inserts text into a content node. michael@0: */ michael@0: class IMETextTxn : public EditTxn michael@0: { michael@0: public: michael@0: static const nsIID& GetCID() { static const nsIID iid = IME_TEXT_TXN_CID; return iid; } michael@0: michael@0: /** initialize the transaction michael@0: * @param aElement the text content node michael@0: * @param aOffset the location in aElement to do the insertion michael@0: * @param aReplaceLength the length of text to replace (0 == no replacement) michael@0: * @param aTextRangeArray clauses and/or caret information. This may be null. michael@0: * @param aString the new text to insert michael@0: * @param aSelCon used to get and set the selection michael@0: */ michael@0: NS_IMETHOD Init(nsIDOMCharacterData *aElement, michael@0: uint32_t aOffset, michael@0: uint32_t aReplaceLength, michael@0: mozilla::TextRangeArray* aTextRangeArray, michael@0: const nsAString& aString, michael@0: nsIEditor* aEditor); michael@0: michael@0: IMETextTxn(); michael@0: michael@0: NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IMETextTxn, EditTxn) michael@0: michael@0: NS_DECL_EDITTXN michael@0: michael@0: NS_IMETHOD Merge(nsITransaction *aTransaction, bool *aDidMerge); michael@0: michael@0: NS_IMETHOD MarkFixed(void); michael@0: michael@0: // nsISupports declarations michael@0: michael@0: // override QueryInterface to handle IMETextTxn request michael@0: NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); michael@0: michael@0: protected: michael@0: michael@0: nsresult SetSelectionForRanges(); michael@0: michael@0: /** the text element to operate upon */ michael@0: nsCOMPtr mElement; michael@0: michael@0: /** the offsets into mElement where the insertion should be placed*/ michael@0: uint32_t mOffset; michael@0: michael@0: uint32_t mReplaceLength; michael@0: michael@0: /** the text to insert into mElement at mOffset */ michael@0: nsString mStringToInsert; michael@0: michael@0: /** the range list **/ michael@0: nsRefPtr mRanges; michael@0: michael@0: /** the editor, which is used to get the selection controller */ michael@0: nsIEditor *mEditor; michael@0: michael@0: bool mFixed; michael@0: }; michael@0: michael@0: #endif