added DeleteElementTxn and DeleteRangeTxn, and added merging of text insertions.

added some better error checking on all transactions.


git-svn-id: svn://10.0.0.236/trunk@17740 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
buster%netscape.com
1999-01-14 18:02:45 +00:00
parent f062e83a76
commit dceac9452d
40 changed files with 1616 additions and 92 deletions

View File

@@ -20,6 +20,8 @@
#include "editor.h"
#include "nsIDOMCharacterData.h"
static NS_DEFINE_IID(kInsertTextTxnIID, INSERTTEXTTXN_IID);
// note that aEditor is not refcounted
InsertTextTxn::InsertTextTxn(nsEditor *aEditor,
nsIDOMCharacterData *aElement,
@@ -52,6 +54,23 @@ nsresult InsertTextTxn::GetIsTransient(PRBool *aIsTransient)
nsresult InsertTextTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
{
// set out param default value
if (nsnull!=aDidMerge)
*aDidMerge=PR_FALSE;
if ((nsnull!=aDidMerge) && (nsnull!=aTransaction))
{
// if aTransaction isa InsertTextTxn, absorb it
nsCOMPtr<InsertTextTxn> otherTxn;
nsresult result = aTransaction->QueryInterface(kInsertTextTxnIID, getter_AddRefs(otherTxn));
if (NS_SUCCEEDED(result) && (otherTxn))
{
nsString otherData;
otherTxn->GetData(otherData);
mStringToInsert += otherData;
}
*aDidMerge = PR_TRUE;
}
return NS_OK;
}
@@ -79,3 +98,27 @@ nsresult InsertTextTxn::GetRedoString(nsString **aString)
}
return NS_OK;
}
/* ============= nsISupports implementation ====================== */
nsresult
InsertTextTxn::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (nsnull == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
if (aIID.Equals(kInsertTextTxnIID)) {
*aInstancePtr = (void*)(InsertTextTxn*)this;
NS_ADDREF_THIS();
return NS_OK;
}
return (EditTxn::QueryInterface(aIID, aInstancePtr));
}
/* ============ protected methods ================== */
nsresult InsertTextTxn::GetData(nsString& aResult)
{
aResult = mStringToInsert;
return NS_OK;
}