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