editor/libeditor/base/IMETextTxn.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/editor/libeditor/base/IMETextTxn.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,91 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef IMETextTxn_h__
    1.10 +#define IMETextTxn_h__
    1.11 +
    1.12 +#include "EditTxn.h"
    1.13 +#include "nsCOMPtr.h"
    1.14 +#include "nsCycleCollectionParticipant.h"
    1.15 +#include "nsID.h"
    1.16 +#include "nsIDOMCharacterData.h"
    1.17 +#include "nsString.h"
    1.18 +#include "nscore.h"
    1.19 +#include "mozilla/TextRange.h"
    1.20 +
    1.21 +class nsITransaction;
    1.22 +
    1.23 +// {D4D25721-2813-11d3-9EA3-0060089FE59B}
    1.24 +#define IME_TEXT_TXN_CID							\
    1.25 +{0xd4d25721, 0x2813, 0x11d3,						\
    1.26 +{0x9e, 0xa3, 0x0, 0x60, 0x8, 0x9f, 0xe5, 0x9b }}
    1.27 +
    1.28 +
    1.29 +class nsIEditor;
    1.30 +
    1.31 +
    1.32 +/**
    1.33 +  * A transaction that inserts text into a content node. 
    1.34 +  */
    1.35 +class IMETextTxn : public EditTxn
    1.36 +{
    1.37 +public:
    1.38 +  static const nsIID& GetCID() { static const nsIID iid = IME_TEXT_TXN_CID; return iid; }
    1.39 +
    1.40 +  /** initialize the transaction
    1.41 +    * @param aElement the text content node
    1.42 +    * @param aOffset  the location in aElement to do the insertion
    1.43 +    * @param aReplaceLength the length of text to replace (0 == no replacement)
    1.44 +    * @param aTextRangeArray clauses and/or caret information. This may be null.
    1.45 +    * @param aString  the new text to insert
    1.46 +    * @param aSelCon used to get and set the selection
    1.47 +    */
    1.48 +  NS_IMETHOD Init(nsIDOMCharacterData *aElement,
    1.49 +                  uint32_t aOffset,
    1.50 +                  uint32_t aReplaceLength,
    1.51 +                  mozilla::TextRangeArray* aTextRangeArray,
    1.52 +                  const nsAString& aString,
    1.53 +                  nsIEditor* aEditor);
    1.54 +
    1.55 +  IMETextTxn();
    1.56 +
    1.57 +  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IMETextTxn, EditTxn)
    1.58 +
    1.59 +  NS_DECL_EDITTXN
    1.60 +
    1.61 +  NS_IMETHOD Merge(nsITransaction *aTransaction, bool *aDidMerge);
    1.62 +
    1.63 +  NS_IMETHOD MarkFixed(void);
    1.64 +
    1.65 +// nsISupports declarations
    1.66 +
    1.67 +  // override QueryInterface to handle IMETextTxn request
    1.68 +  NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
    1.69 +
    1.70 +protected:
    1.71 +
    1.72 +  nsresult SetSelectionForRanges();
    1.73 +
    1.74 +  /** the text element to operate upon */
    1.75 +  nsCOMPtr<nsIDOMCharacterData> mElement;
    1.76 +  
    1.77 +  /** the offsets into mElement where the insertion should be placed*/
    1.78 +  uint32_t mOffset;
    1.79 +
    1.80 +  uint32_t mReplaceLength;
    1.81 +
    1.82 +  /** the text to insert into mElement at mOffset */
    1.83 +  nsString mStringToInsert;
    1.84 +
    1.85 +  /** the range list **/
    1.86 +  nsRefPtr<mozilla::TextRangeArray> mRanges;
    1.87 +
    1.88 +  /** the editor, which is used to get the selection controller */
    1.89 +  nsIEditor *mEditor;
    1.90 +
    1.91 +  bool	mFixed;
    1.92 +};
    1.93 +
    1.94 +#endif

mercurial