1999-06-29 20:31:22 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 03:43:54 +00:00
|
|
|
* The contents of this file are subject to the Netscape Public
|
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.mozilla.org/NPL/
|
1999-06-29 20:31:22 +00:00
|
|
|
*
|
1999-11-06 03:43:54 +00:00
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
1999-06-29 20:31:22 +00:00
|
|
|
*
|
1999-11-06 03:43:54 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1999-06-29 20:31:22 +00:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 03:43:54 +00:00
|
|
|
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1999-06-29 20:31:22 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "IMECommitTxn.h"
|
|
|
|
#include "nsEditor.h"
|
|
|
|
|
1999-12-01 00:35:31 +00:00
|
|
|
// #define DEBUG_IME
|
1999-06-29 20:31:22 +00:00
|
|
|
nsIAtom *IMECommitTxn::gIMECommitTxnName = nsnull;
|
|
|
|
|
|
|
|
nsresult IMECommitTxn::ClassInit()
|
|
|
|
{
|
|
|
|
if (nsnull==gIMECommitTxnName)
|
|
|
|
gIMECommitTxnName = NS_NewAtom("NS_IMECommitTxn");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-10-06 20:27:41 +00:00
|
|
|
nsresult IMECommitTxn::ClassShutdown()
|
|
|
|
{
|
|
|
|
NS_IF_RELEASE(gIMECommitTxnName);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-06-29 20:31:22 +00:00
|
|
|
IMECommitTxn::IMECommitTxn()
|
|
|
|
: EditTxn()
|
|
|
|
{
|
1999-09-21 22:31:27 +00:00
|
|
|
SetTransactionDescriptionID( kTransactionID );
|
|
|
|
/* log description initialized in parent constructor */
|
1999-06-29 20:31:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
IMECommitTxn::~IMECommitTxn()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP IMECommitTxn::Init(void)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP IMECommitTxn::Do(void)
|
|
|
|
{
|
1999-12-01 00:35:31 +00:00
|
|
|
#ifdef DEBUG_IME
|
1999-06-29 21:12:43 +00:00
|
|
|
printf("Do IME Commit");
|
1999-06-29 20:31:22 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP IMECommitTxn::Undo(void)
|
|
|
|
{
|
1999-12-01 00:35:31 +00:00
|
|
|
#ifdef DEBUG_IME
|
1999-06-29 20:31:22 +00:00
|
|
|
printf("Undo IME Commit");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP IMECommitTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
|
|
|
{
|
1999-12-01 00:35:31 +00:00
|
|
|
#ifdef DEBUG_IME
|
1999-06-29 20:31:22 +00:00
|
|
|
printf("Merge IME Commit");
|
|
|
|
#endif
|
|
|
|
|
1999-10-18 14:48:41 +00:00
|
|
|
NS_ASSERTION(aDidMerge, "null ptr- aDidMerge");
|
|
|
|
NS_ASSERTION(aTransaction, "null ptr- aTransaction");
|
|
|
|
if((nsnull == aDidMerge) || (nsnull == aTransaction))
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
1999-06-29 20:31:22 +00:00
|
|
|
*aDidMerge=PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP IMECommitTxn::Write(nsIOutputStream *aOutputStream)
|
|
|
|
{
|
1999-10-18 14:48:41 +00:00
|
|
|
NS_ASSERTION(aOutputStream, "null ptr- aOutputStream");
|
|
|
|
if(nsnull == aOutputStream)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
else
|
|
|
|
return NS_OK;
|
1999-06-29 20:31:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP IMECommitTxn::GetUndoString(nsString *aString)
|
|
|
|
{
|
1999-10-18 14:48:41 +00:00
|
|
|
NS_ASSERTION(aString, "null ptr- aString");
|
|
|
|
if(nsnull == aString) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
} else {
|
1999-06-29 20:31:22 +00:00
|
|
|
*aString="Remove IMECommit: ";
|
1999-10-18 14:48:41 +00:00
|
|
|
return NS_OK;
|
1999-06-29 20:31:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP IMECommitTxn::GetRedoString(nsString *aString)
|
|
|
|
{
|
1999-10-18 14:48:41 +00:00
|
|
|
NS_ASSERTION(aString, "null ptr- aString");
|
|
|
|
if(nsnull == aString) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
} else {
|
1999-06-29 20:31:22 +00:00
|
|
|
*aString="Insert IMECommit: ";
|
1999-10-18 14:48:41 +00:00
|
|
|
return NS_OK;
|
1999-06-29 20:31:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ============= nsISupports implementation ====================== */
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
IMECommitTxn::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
|
|
|
{
|
|
|
|
if (nsnull == aInstancePtr) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1999-07-15 19:13:46 +00:00
|
|
|
if (aIID.Equals(IMECommitTxn::GetCID())) {
|
1999-06-29 20:31:22 +00:00
|
|
|
*aInstancePtr = (void*)(IMECommitTxn*)this;
|
|
|
|
NS_ADDREF_THIS();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return (EditTxn::QueryInterface(aIID, aInstancePtr));
|
|
|
|
}
|
|
|
|
|
|
|
|
|