mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-28 13:21:28 +00:00
Removing files no longer used.
This commit is contained in:
parent
b9725f19d8
commit
0558a8dd75
@ -1,181 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "InsertTableCellTxn.h"
|
||||
#include "nsEditor.h"
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsIDOMSelection.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "EditAggregateTxn.h"
|
||||
|
||||
static NS_DEFINE_IID(kInsertTableCellTxnIID, INSERT_CELL_TXN_IID);
|
||||
static NS_DEFINE_IID(kIDOMSelectionIID, NS_IDOMSELECTION_IID);
|
||||
|
||||
nsIAtom *InsertTableCellTxn::gInsertTableCellTxnName;
|
||||
|
||||
nsresult InsertTableCellTxn::ClassInit()
|
||||
{
|
||||
if (nsnull==gInsertTableCellTxnName)
|
||||
gInsertTableCellTxnName = NS_NewAtom("NS_InsertTableCellTxn");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
InsertTableCellTxn::InsertTableCellTxn()
|
||||
: EditTxn()
|
||||
{
|
||||
}
|
||||
|
||||
InsertTableCellTxn::~InsertTableCellTxn()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertTableCellTxn::Init(nsIDOMCharacterData *aElement,
|
||||
PRUint32 aOffset,
|
||||
nsIDOMNode *aNode,
|
||||
nsIPresShell* aPresShell)
|
||||
{
|
||||
mElement = do_QueryInterface(aElement);
|
||||
mOffset = aOffset;
|
||||
mNodeToInsert = aNode;
|
||||
mPresShell = aPresShell;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertTableCellTxn::Do(void)
|
||||
{
|
||||
//nsresult res = mElement->InsertData(mOffset, mStringToInsert);
|
||||
// advance caret: This requires the presentation shell to get the selection.
|
||||
nsresult res = NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDOMSelection> selection;
|
||||
res = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
res = selection->Collapse(mElement, mOffset+1 /*+mStringToInsert.Length()*/);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertTableCellTxn::Undo(void)
|
||||
{
|
||||
nsresult result = NS_ERROR_FAILURE;
|
||||
#if 0
|
||||
PRUint32 length = mStringToInsert.Length();
|
||||
result = mElement->DeleteData(mOffset, length);
|
||||
if (NS_SUCCEEDED(result))
|
||||
{ // set the selection to the insertion point where the string was removed
|
||||
nsCOMPtr<nsIDOMSelection> selection;
|
||||
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
result = selection->Collapse(mElement, mOffset);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
#if 0
|
||||
NS_IMETHODIMP InsertTableCellTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
{
|
||||
// set out param default value
|
||||
if (nsnull!=aDidMerge)
|
||||
*aDidMerge=PR_FALSE;
|
||||
if ((nsnull!=aDidMerge) && (nsnull!=aTransaction))
|
||||
{
|
||||
// if aTransaction isa InsertTableCellTxn, and if the selection hasn't changed,
|
||||
// then absorb it
|
||||
nsCOMPtr<InsertTableCellTxn> otherTxn(aTransaction);
|
||||
if (otherTxn)
|
||||
{
|
||||
if (PR_TRUE==IsSequentialInsert(otherTxn))
|
||||
{
|
||||
nsAutoString otherData;
|
||||
otherTxn->GetData(otherData);
|
||||
mStringToInsert += otherData;
|
||||
*aDidMerge = PR_TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // the next InsertTableCellTxn might be inside an aggregate that we have special knowledge of
|
||||
nsCOMPtr<EditAggregateTxn> otherTxn(aTransaction);
|
||||
if (otherTxn)
|
||||
{
|
||||
nsCOMPtr<nsIAtom> txnName;
|
||||
otherTxn->GetName(getter_AddRefs(txnName));
|
||||
if (txnName==gInsertTableCellTxnName)
|
||||
{ // yep, it's one of ours. By definition, it must contain only
|
||||
// a single InsertTableCellTxn
|
||||
nsCOMPtr<EditTxn> childTxn;
|
||||
otherTxn->GetTxnAt(0, getter_AddRefs(childTxn));
|
||||
nsCOMPtr<InsertTableCellTxn> otherInsertTxn(childTxn);
|
||||
if (otherInsertTxn)
|
||||
{
|
||||
if (PR_TRUE==IsSequentialInsert(otherInsertTxn))
|
||||
{
|
||||
nsAutoString otherData;
|
||||
otherInsertTxn->GetData(otherData);
|
||||
mStringToInsert += otherData;
|
||||
*aDidMerge = PR_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP InsertTableCellTxn::Write(nsIOutputStream *aOutputStream)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertTableCellTxn::GetUndoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
*aString="Remove Table";
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertTableCellTxn::GetRedoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
*aString="Insert Table";
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* ============= nsISupports implementation ====================== */
|
||||
|
||||
NS_IMETHODIMP
|
||||
InsertTableCellTxn::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if (nsnull == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aIID.Equals(kInsertTableCellTxnIID)) {
|
||||
*aInstancePtr = (void*)(InsertTableCellTxn*)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return (EditTxn::QueryInterface(aIID, aInstancePtr));
|
||||
}
|
||||
|
@ -1,112 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef InsertTableCell_h__
|
||||
#define InsertTableCell_h__
|
||||
|
||||
#include "EditTxn.h"
|
||||
#include "nsIEditor.h"
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
|
||||
#define INSERT_CELL_TXN_IID \
|
||||
{/* 12D65E50-C6CA-11d2-9839-00805F8AA8B8*/ \
|
||||
0x12d65e50, 0xc6ca, 0x11d2, \
|
||||
{ 0x98, 0x39, 0x0, 0x80, 0x5f, 0x8a, 0xa8, 0xb8} }
|
||||
|
||||
class nsIPresShell;
|
||||
|
||||
/**
|
||||
* A transaction that inserts Table into a content node.
|
||||
*/
|
||||
class InsertTableCellTxn : public EditTxn
|
||||
{
|
||||
public:
|
||||
virtual ~InsertTableCellTxn();
|
||||
|
||||
/** used to name aggregate transactions that consist only of a single InsertTableCellTxn,
|
||||
* or a DeleteSelection followed by an InsertTableCellTxn.
|
||||
*/
|
||||
static nsIAtom *gInsertTableCellTxnName;
|
||||
|
||||
/** initialize the transaction
|
||||
* @param aElement the current content node
|
||||
* @param aOffset the location in aElement to do the insertion
|
||||
* @param aNode the new Table to insert
|
||||
* @param aPresShell used to get and set the selection
|
||||
*/
|
||||
NS_IMETHOD Init(nsIDOMCharacterData *aElement,
|
||||
PRUint32 aOffset,
|
||||
nsIDOMNode *aNode,
|
||||
nsIPresShell* aPresShell);
|
||||
|
||||
private:
|
||||
|
||||
InsertTableCellTxn();
|
||||
|
||||
public:
|
||||
|
||||
NS_IMETHOD Do(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
|
||||
//NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
|
||||
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
||||
|
||||
NS_IMETHOD GetUndoString(nsString *aString);
|
||||
|
||||
NS_IMETHOD GetRedoString(nsString *aString);
|
||||
|
||||
// nsISupports declarations
|
||||
|
||||
// override QueryInterface to handle InsertTableCellTxn request
|
||||
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
|
||||
|
||||
static const nsIID& GetIID() { static nsIID iid = INSERT_CELL_TXN_IID; return iid; }
|
||||
|
||||
|
||||
/** return the string data associated with this transaction */
|
||||
// NS_IMETHOD GetData(nsString& aResult);
|
||||
|
||||
/** must be called before any InsertTableCellTxn is instantiated */
|
||||
static nsresult ClassInit();
|
||||
|
||||
protected:
|
||||
|
||||
// /* return PR_TRUE if aOtherTxn immediately follows this txn */
|
||||
// virtual PRBool IsSequentialInsert(InsertTableCellTxn *aOtherTxn);
|
||||
|
||||
/** the element to operate upon */
|
||||
nsCOMPtr<nsIDOMCharacterData> mElement;
|
||||
|
||||
/** the offset into mElement where the insertion is to take place */
|
||||
PRUint32 mOffset;
|
||||
|
||||
/** the element to insert into mElement at mOffset */
|
||||
nsIDOMNode *mNodeToInsert;
|
||||
|
||||
/** the presentation shell, which we'll need to get the selection */
|
||||
nsIPresShell* mPresShell;
|
||||
|
||||
friend class TransactionFactory;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
@ -1,181 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "InsertTableColumnTxn.h"
|
||||
#include "nsEditor.h"
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsIDOMSelection.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "EditAggregateTxn.h"
|
||||
|
||||
static NS_DEFINE_IID(kInsertTableColumnTxnIID, INSERT_COLUMN_TXN_IID);
|
||||
static NS_DEFINE_IID(kIDOMSelectionIID, NS_IDOMSELECTION_IID);
|
||||
|
||||
nsIAtom *InsertTableColumnTxn::gInsertTableColumnTxnName;
|
||||
|
||||
nsresult InsertTableColumnTxn::ClassInit()
|
||||
{
|
||||
if (nsnull==gInsertTableColumnTxnName)
|
||||
gInsertTableColumnTxnName = NS_NewAtom("NS_InsertTableColumnTxn");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
InsertTableColumnTxn::InsertTableColumnTxn()
|
||||
: EditTxn()
|
||||
{
|
||||
}
|
||||
|
||||
InsertTableColumnTxn::~InsertTableColumnTxn()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertTableColumnTxn::Init(nsIDOMCharacterData *aElement,
|
||||
PRUint32 aOffset,
|
||||
nsIDOMNode *aNode,
|
||||
nsIPresShell* aPresShell)
|
||||
{
|
||||
mElement = do_QueryInterface(aElement);
|
||||
mOffset = aOffset;
|
||||
mNodeToInsert = aNode;
|
||||
mPresShell = aPresShell;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertTableColumnTxn::Do(void)
|
||||
{
|
||||
//nsresult res = mElement->InsertData(mOffset, mStringToInsert);
|
||||
// advance caret: This requires the presentation shell to get the selection.
|
||||
nsresult res = NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDOMSelection> selection;
|
||||
res = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
res = selection->Collapse(mElement, mOffset+1 /*+mStringToInsert.Length()*/);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertTableColumnTxn::Undo(void)
|
||||
{
|
||||
nsresult result = NS_ERROR_FAILURE;
|
||||
#if 0
|
||||
PRUint32 length = mStringToInsert.Length();
|
||||
result = mElement->DeleteData(mOffset, length);
|
||||
if (NS_SUCCEEDED(result))
|
||||
{ // set the selection to the insertion point where the string was removed
|
||||
nsCOMPtr<nsIDOMSelection> selection;
|
||||
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
result = selection->Collapse(mElement, mOffset);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
#if 0
|
||||
NS_IMETHODIMP InsertTableColumnTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
{
|
||||
// set out param default value
|
||||
if (nsnull!=aDidMerge)
|
||||
*aDidMerge=PR_FALSE;
|
||||
if ((nsnull!=aDidMerge) && (nsnull!=aTransaction))
|
||||
{
|
||||
// if aTransaction isa InsertTableColumnTxn, and if the selection hasn't changed,
|
||||
// then absorb it
|
||||
nsCOMPtr<InsertTableColumnTxn> otherTxn(aTransaction);
|
||||
if (otherTxn)
|
||||
{
|
||||
if (PR_TRUE==IsSequentialInsert(otherTxn))
|
||||
{
|
||||
nsAutoString otherData;
|
||||
otherTxn->GetData(otherData);
|
||||
mStringToInsert += otherData;
|
||||
*aDidMerge = PR_TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // the next InsertTableColumnTxn might be inside an aggregate that we have special knowledge of
|
||||
nsCOMPtr<EditAggregateTxn> otherTxn(aTransaction);
|
||||
if (otherTxn)
|
||||
{
|
||||
nsCOMPtr<nsIAtom> txnName;
|
||||
otherTxn->GetName(getter_AddRefs(txnName));
|
||||
if (txnName==gInsertTableColumnTxnName)
|
||||
{ // yep, it's one of ours. By definition, it must contain only
|
||||
// a single InsertTableColumnTxn
|
||||
nsCOMPtr<EditTxn> childTxn;
|
||||
otherTxn->GetTxnAt(0, getter_AddRefs(childTxn));
|
||||
nsCOMPtr<InsertTableColumnTxn> otherInsertTxn(childTxn);
|
||||
if (otherInsertTxn)
|
||||
{
|
||||
if (PR_TRUE==IsSequentialInsert(otherInsertTxn))
|
||||
{
|
||||
nsAutoString otherData;
|
||||
otherInsertTxn->GetData(otherData);
|
||||
mStringToInsert += otherData;
|
||||
*aDidMerge = PR_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP InsertTableColumnTxn::Write(nsIOutputStream *aOutputStream)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertTableColumnTxn::GetUndoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
*aString="Remove Table";
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertTableColumnTxn::GetRedoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
*aString="Insert Table";
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* ============= nsISupports implementation ====================== */
|
||||
|
||||
NS_IMETHODIMP
|
||||
InsertTableColumnTxn::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if (nsnull == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aIID.Equals(kInsertTableColumnTxnIID)) {
|
||||
*aInstancePtr = (void*)(InsertTableColumnTxn*)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return (EditTxn::QueryInterface(aIID, aInstancePtr));
|
||||
}
|
||||
|
@ -1,113 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef InsertTableColumn_h__
|
||||
#define InsertTableColumn_h__
|
||||
|
||||
#include "EditTxn.h"
|
||||
#include "nsIEditor.h"
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
|
||||
#define INSERT_COLUMN_TXN_IID \
|
||||
{/* 50956DE1-C843-11d2-B1C3-004095E27A10*/ \
|
||||
0x50956de1, 0xc843, 0x11d2, \
|
||||
{ 0xb1, 0xc3, 0x0, 0x40, 0x95, 0xe2, 0x7a, 0x10 } }
|
||||
|
||||
|
||||
class nsIPresShell;
|
||||
|
||||
/**
|
||||
* A transaction that inserts Table into a content node.
|
||||
*/
|
||||
class InsertTableColumnTxn : public EditTxn
|
||||
{
|
||||
public:
|
||||
virtual ~InsertTableColumnTxn();
|
||||
|
||||
/** used to name aggregate transactions that consist only of a single InsertTableColumnTxn,
|
||||
* or a DeleteSelection followed by an InsertTableColumnTxn.
|
||||
*/
|
||||
static nsIAtom *gInsertTableColumnTxnName;
|
||||
|
||||
/** initialize the transaction
|
||||
* @param aElement the current content node
|
||||
* @param aOffset the location in aElement to do the insertion
|
||||
* @param aNode the new Table to insert
|
||||
* @param aPresShell used to get and set the selection
|
||||
*/
|
||||
NS_IMETHOD Init(nsIDOMCharacterData *aElement,
|
||||
PRUint32 aOffset,
|
||||
nsIDOMNode *aNode,
|
||||
nsIPresShell* aPresShell);
|
||||
|
||||
private:
|
||||
|
||||
InsertTableColumnTxn();
|
||||
|
||||
public:
|
||||
|
||||
NS_IMETHOD Do(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
|
||||
//NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
|
||||
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
||||
|
||||
NS_IMETHOD GetUndoString(nsString *aString);
|
||||
|
||||
NS_IMETHOD GetRedoString(nsString *aString);
|
||||
|
||||
// nsISupports declarations
|
||||
|
||||
// override QueryInterface to handle InsertTableColumnTxn request
|
||||
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
|
||||
|
||||
static const nsIID& GetIID() { static nsIID iid = INSERT_COLUMN_TXN_IID; return iid; }
|
||||
|
||||
|
||||
/** return the string data associated with this transaction */
|
||||
// NS_IMETHOD GetData(nsString& aResult);
|
||||
|
||||
/** must be called before any InsertTableColumnTxn is instantiated */
|
||||
static nsresult ClassInit();
|
||||
|
||||
protected:
|
||||
|
||||
// /* return PR_TRUE if aOtherTxn immediately follows this txn */
|
||||
// virtual PRBool IsSequentialInsert(InsertTableColumnTxn *aOtherTxn);
|
||||
|
||||
/** the element to operate upon */
|
||||
nsCOMPtr<nsIDOMCharacterData> mElement;
|
||||
|
||||
/** the offset into mElement where the insertion is to take place */
|
||||
PRUint32 mOffset;
|
||||
|
||||
/** the element to insert into mElement at mOffset */
|
||||
nsIDOMNode *mNodeToInsert;
|
||||
|
||||
/** the presentation shell, which we'll need to get the selection */
|
||||
nsIPresShell* mPresShell;
|
||||
|
||||
friend class TransactionFactory;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
@ -1,181 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "InsertTableRowTxn.h"
|
||||
#include "nsEditor.h"
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsIDOMSelection.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "EditAggregateTxn.h"
|
||||
|
||||
static NS_DEFINE_IID(kInsertTableRowTxnIID, INSERT_ROW_TXN_IID);
|
||||
static NS_DEFINE_IID(kIDOMSelectionIID, NS_IDOMSELECTION_IID);
|
||||
|
||||
nsIAtom *InsertTableRowTxn::gInsertTableRowTxnName;
|
||||
|
||||
nsresult InsertTableRowTxn::ClassInit()
|
||||
{
|
||||
if (nsnull==gInsertTableRowTxnName)
|
||||
gInsertTableRowTxnName = NS_NewAtom("NS_InsertTableRowTxn");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
InsertTableRowTxn::InsertTableRowTxn()
|
||||
: EditTxn()
|
||||
{
|
||||
}
|
||||
|
||||
InsertTableRowTxn::~InsertTableRowTxn()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertTableRowTxn::Init(nsIDOMCharacterData *aElement,
|
||||
PRUint32 aOffset,
|
||||
nsIDOMNode *aNode,
|
||||
nsIPresShell* aPresShell)
|
||||
{
|
||||
mElement = do_QueryInterface(aElement);
|
||||
mOffset = aOffset;
|
||||
mNodeToInsert = aNode;
|
||||
mPresShell = aPresShell;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertTableRowTxn::Do(void)
|
||||
{
|
||||
//nsresult res = mElement->InsertData(mOffset, mStringToInsert);
|
||||
// advance caret: This requires the presentation shell to get the selection.
|
||||
nsresult res = NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDOMSelection> selection;
|
||||
res = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
res = selection->Collapse(mElement, mOffset+1 /*+mStringToInsert.Length()*/);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertTableRowTxn::Undo(void)
|
||||
{
|
||||
nsresult result = NS_ERROR_FAILURE;
|
||||
#if 0
|
||||
PRUint32 length = mStringToInsert.Length();
|
||||
result = mElement->DeleteData(mOffset, length);
|
||||
if (NS_SUCCEEDED(result))
|
||||
{ // set the selection to the insertion point where the string was removed
|
||||
nsCOMPtr<nsIDOMSelection> selection;
|
||||
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
result = selection->Collapse(mElement, mOffset);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
#if 0
|
||||
NS_IMETHODIMP InsertTableRowTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
{
|
||||
// set out param default value
|
||||
if (nsnull!=aDidMerge)
|
||||
*aDidMerge=PR_FALSE;
|
||||
if ((nsnull!=aDidMerge) && (nsnull!=aTransaction))
|
||||
{
|
||||
// if aTransaction isa InsertTableRowTxn, and if the selection hasn't changed,
|
||||
// then absorb it
|
||||
nsCOMPtr<InsertTableRowTxn> otherTxn(aTransaction);
|
||||
if (otherTxn)
|
||||
{
|
||||
if (PR_TRUE==IsSequentialInsert(otherTxn))
|
||||
{
|
||||
nsAutoString otherData;
|
||||
otherTxn->GetData(otherData);
|
||||
mStringToInsert += otherData;
|
||||
*aDidMerge = PR_TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // the next InsertTableRowTxn might be inside an aggregate that we have special knowledge of
|
||||
nsCOMPtr<EditAggregateTxn> otherTxn(aTransaction);
|
||||
if (otherTxn)
|
||||
{
|
||||
nsCOMPtr<nsIAtom> txnName;
|
||||
otherTxn->GetName(getter_AddRefs(txnName));
|
||||
if (txnName==gInsertTableRowTxnName)
|
||||
{ // yep, it's one of ours. By definition, it must contain only
|
||||
// a single InsertTableRowTxn
|
||||
nsCOMPtr<EditTxn> childTxn;
|
||||
otherTxn->GetTxnAt(0, getter_AddRefs(childTxn));
|
||||
nsCOMPtr<InsertTableRowTxn> otherInsertTxn(childTxn);
|
||||
if (otherInsertTxn)
|
||||
{
|
||||
if (PR_TRUE==IsSequentialInsert(otherInsertTxn))
|
||||
{
|
||||
nsAutoString otherData;
|
||||
otherInsertTxn->GetData(otherData);
|
||||
mStringToInsert += otherData;
|
||||
*aDidMerge = PR_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP InsertTableRowTxn::Write(nsIOutputStream *aOutputStream)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertTableRowTxn::GetUndoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
*aString="Remove Table";
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertTableRowTxn::GetRedoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
*aString="Insert Table";
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* ============= nsISupports implementation ====================== */
|
||||
|
||||
NS_IMETHODIMP
|
||||
InsertTableRowTxn::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if (nsnull == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aIID.Equals(kInsertTableRowTxnIID)) {
|
||||
*aInstancePtr = (void*)(InsertTableRowTxn*)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return (EditTxn::QueryInterface(aIID, aInstancePtr));
|
||||
}
|
||||
|
@ -1,113 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef InsertTableRow_h__
|
||||
#define InsertTableRow_h__
|
||||
|
||||
#include "EditTxn.h"
|
||||
#include "nsIEditor.h"
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
|
||||
#define INSERT_ROW_TXN_IID \
|
||||
{/*50956DE2-C843-11d2-B1C3-004095E27A10*/ \
|
||||
0x50956de2, 0xc843, 0x11d2, \
|
||||
{ 0xb1, 0xc3, 0x0, 0x40, 0x95, 0xe2, 0x7a, 0x10 } }
|
||||
|
||||
|
||||
class nsIPresShell;
|
||||
|
||||
/**
|
||||
* A transaction that inserts Table into a content node.
|
||||
*/
|
||||
class InsertTableRowTxn : public EditTxn
|
||||
{
|
||||
public:
|
||||
virtual ~InsertTableRowTxn();
|
||||
|
||||
/** used to name aggregate transactions that consist only of a single InsertTableRowTxn,
|
||||
* or a DeleteSelection followed by an InsertTableRowTxn.
|
||||
*/
|
||||
static nsIAtom *gInsertTableRowTxnName;
|
||||
|
||||
/** initialize the transaction
|
||||
* @param aElement the current content node
|
||||
* @param aOffset the location in aElement to do the insertion
|
||||
* @param aNode the new Table to insert
|
||||
* @param aPresShell used to get and set the selection
|
||||
*/
|
||||
NS_IMETHOD Init(nsIDOMCharacterData *aElement,
|
||||
PRUint32 aOffset,
|
||||
nsIDOMNode *aNode,
|
||||
nsIPresShell* aPresShell);
|
||||
|
||||
private:
|
||||
|
||||
InsertTableRowTxn();
|
||||
|
||||
public:
|
||||
|
||||
NS_IMETHOD Do(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
|
||||
//NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
|
||||
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
||||
|
||||
NS_IMETHOD GetUndoString(nsString *aString);
|
||||
|
||||
NS_IMETHOD GetRedoString(nsString *aString);
|
||||
|
||||
// nsISupports declarations
|
||||
|
||||
// override QueryInterface to handle InsertTableRowTxn request
|
||||
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
|
||||
|
||||
static const nsIID& GetIID() { static nsIID iid = INSERT_ROW_TXN_IID; return iid; }
|
||||
|
||||
|
||||
/** return the string data associated with this transaction */
|
||||
// NS_IMETHOD GetData(nsString& aResult);
|
||||
|
||||
/** must be called before any InsertTableRowTxn is instantiated */
|
||||
static nsresult ClassInit();
|
||||
|
||||
protected:
|
||||
|
||||
// /* return PR_TRUE if aOtherTxn immediately follows this txn */
|
||||
// virtual PRBool IsSequentialInsert(InsertTableRowTxn *aOtherTxn);
|
||||
|
||||
/** the element to operate upon */
|
||||
nsCOMPtr<nsIDOMCharacterData> mElement;
|
||||
|
||||
/** the offset into mElement where the insertion is to take place */
|
||||
PRUint32 mOffset;
|
||||
|
||||
/** the element to insert into mElement at mOffset */
|
||||
nsIDOMNode *mNodeToInsert;
|
||||
|
||||
/** the presentation shell, which we'll need to get the selection */
|
||||
nsIPresShell* mPresShell;
|
||||
|
||||
friend class TransactionFactory;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
@ -1,181 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "InsertTableTxn.h"
|
||||
#include "nsEditor.h"
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsIDOMSelection.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "EditAggregateTxn.h"
|
||||
|
||||
static NS_DEFINE_IID(kInsertTableTxnIID, INSERT_TABLE_TXN_IID);
|
||||
static NS_DEFINE_IID(kIDOMSelectionIID, NS_IDOMSELECTION_IID);
|
||||
|
||||
nsIAtom *InsertTableTxn::gInsertTableTxnName;
|
||||
|
||||
nsresult InsertTableTxn::ClassInit()
|
||||
{
|
||||
if (nsnull==gInsertTableTxnName)
|
||||
gInsertTableTxnName = NS_NewAtom("NS_InsertTableTxn");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
InsertTableTxn::InsertTableTxn()
|
||||
: EditTxn()
|
||||
{
|
||||
}
|
||||
|
||||
InsertTableTxn::~InsertTableTxn()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertTableTxn::Init(nsIDOMCharacterData *aElement,
|
||||
PRUint32 aOffset,
|
||||
nsIDOMNode *aNode,
|
||||
nsIPresShell* aPresShell)
|
||||
{
|
||||
mElement = do_QueryInterface(aElement);
|
||||
mOffset = aOffset;
|
||||
mTableToInsert = aNode;
|
||||
mPresShell = aPresShell;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertTableTxn::Do(void)
|
||||
{
|
||||
//nsresult res = mElement->InsertData(mOffset, mStringToInsert);
|
||||
// advance caret: This requires the presentation shell to get the selection.
|
||||
nsresult res = NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDOMSelection> selection;
|
||||
res = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
res = selection->Collapse(mElement, mOffset+1 /*+mStringToInsert.Length()*/);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertTableTxn::Undo(void)
|
||||
{
|
||||
nsresult result = NS_ERROR_FAILURE;
|
||||
#if 0
|
||||
PRUint32 length = mStringToInsert.Length();
|
||||
result = mElement->DeleteData(mOffset, length);
|
||||
if (NS_SUCCEEDED(result))
|
||||
{ // set the selection to the insertion point where the string was removed
|
||||
nsCOMPtr<nsIDOMSelection> selection;
|
||||
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
result = selection->Collapse(mElement, mOffset);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertTableTxn::Merge(PRBool *aDidMerge, nsITransaction *aTransaction)
|
||||
{
|
||||
#if 0
|
||||
// set out param default value
|
||||
if (nsnull!=aDidMerge)
|
||||
*aDidMerge=PR_FALSE;
|
||||
if ((nsnull!=aDidMerge) && (nsnull!=aTransaction))
|
||||
{
|
||||
// if aTransaction isa InsertTableTxn, and if the selection hasn't changed,
|
||||
// then absorb it
|
||||
nsCOMPtr<InsertTableTxn> otherTxn(aTransaction);
|
||||
if (otherTxn)
|
||||
{
|
||||
if (PR_TRUE==IsSequentialInsert(otherTxn))
|
||||
{
|
||||
nsAutoString otherData;
|
||||
otherTxn->GetData(otherData);
|
||||
mStringToInsert += otherData;
|
||||
*aDidMerge = PR_TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // the next InsertTableTxn might be inside an aggregate that we have special knowledge of
|
||||
nsCOMPtr<EditAggregateTxn> otherTxn(aTransaction);
|
||||
if (otherTxn)
|
||||
{
|
||||
nsCOMPtr<nsIAtom> txnName;
|
||||
otherTxn->GetName(getter_AddRefs(txnName));
|
||||
if (txnName==gInsertTableTxnName)
|
||||
{ // yep, it's one of ours. By definition, it must contain only
|
||||
// a single InsertTableTxn
|
||||
nsCOMPtr<EditTxn> childTxn;
|
||||
otherTxn->GetTxnAt(0, getter_AddRefs(childTxn));
|
||||
nsCOMPtr<InsertTableTxn> otherInsertTxn(childTxn);
|
||||
if (otherInsertTxn)
|
||||
{
|
||||
if (PR_TRUE==IsSequentialInsert(otherInsertTxn))
|
||||
{
|
||||
nsAutoString otherData;
|
||||
otherInsertTxn->GetData(otherData);
|
||||
mStringToInsert += otherData;
|
||||
*aDidMerge = PR_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertTableTxn::Write(nsIOutputStream *aOutputStream)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertTableTxn::GetUndoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
*aString="Remove Table";
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP InsertTableTxn::GetRedoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
*aString="Insert Table";
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* ============= nsISupports implementation ====================== */
|
||||
|
||||
NS_IMETHODIMP
|
||||
InsertTableTxn::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if (nsnull == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aIID.Equals(kInsertTableTxnIID)) {
|
||||
*aInstancePtr = (void*)(InsertTableTxn*)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return (EditTxn::QueryInterface(aIID, aInstancePtr));
|
||||
}
|
||||
|
@ -1,112 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef InsertTable_h__
|
||||
#define InsertTable_h__
|
||||
|
||||
#include "EditTxn.h"
|
||||
#include "nsIEditor.h"
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
|
||||
#define INSERT_TABLE_TXN_IID \
|
||||
{/*12D65E51-C6CA-11d2-9839-00805F8AA8B8*/ \
|
||||
0x12d65e51, 0xc6ca, 0x11d2, \
|
||||
{ 0x98, 0x39, 0x0, 0x80, 0x5f, 0x8a, 0xa8, 0xb8 } }
|
||||
|
||||
class nsIPresShell;
|
||||
|
||||
/**
|
||||
* A transaction that inserts Table into a content node.
|
||||
*/
|
||||
class InsertTableTxn : public EditTxn
|
||||
{
|
||||
public:
|
||||
virtual ~InsertTableTxn();
|
||||
|
||||
/** used to name aggregate transactions that consist only of a single InsertTableTxn,
|
||||
* or a DeleteSelection followed by an InsertTableTxn.
|
||||
*/
|
||||
static nsIAtom *gInsertTableTxnName;
|
||||
|
||||
/** initialize the transaction
|
||||
* @param aElement the current content node
|
||||
* @param aOffset the location in aElement to do the insertion
|
||||
* @param aNode the new Table to insert
|
||||
* @param aPresShell used to get and set the selection
|
||||
*/
|
||||
NS_IMETHOD Init(nsIDOMCharacterData *aElement,
|
||||
PRUint32 aOffset,
|
||||
nsIDOMNode *aNode,
|
||||
nsIPresShell* aPresShell);
|
||||
|
||||
private:
|
||||
|
||||
InsertTableTxn();
|
||||
|
||||
public:
|
||||
|
||||
NS_IMETHOD Do(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
|
||||
NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
|
||||
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
||||
|
||||
NS_IMETHOD GetUndoString(nsString *aString);
|
||||
|
||||
NS_IMETHOD GetRedoString(nsString *aString);
|
||||
|
||||
// nsISupports declarations
|
||||
|
||||
// override QueryInterface to handle InsertTableTxn request
|
||||
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
|
||||
|
||||
static const nsIID& GetIID() { static nsIID iid = INSERT_TABLE_TXN_IID; return iid; }
|
||||
|
||||
|
||||
/** return the string data associated with this transaction */
|
||||
// NS_IMETHOD GetData(nsString& aResult);
|
||||
|
||||
/** must be called before any InsertTableTxn is instantiated */
|
||||
static nsresult ClassInit();
|
||||
|
||||
protected:
|
||||
|
||||
// /* return PR_TRUE if aOtherTxn immediately follows this txn */
|
||||
// virtual PRBool IsSequentialInsert(InsertTableTxn *aOtherTxn);
|
||||
|
||||
/** the element to operate upon */
|
||||
nsCOMPtr<nsIDOMCharacterData> mElement;
|
||||
|
||||
/** the offset into mElement where the insertion is to take place */
|
||||
PRUint32 mOffset;
|
||||
|
||||
/** the Table to insert into mElement at mOffset */
|
||||
nsIDOMNode *mTableToInsert;
|
||||
|
||||
/** the presentation shell, which we'll need to get the selection */
|
||||
nsIPresShell* mPresShell;
|
||||
|
||||
friend class TransactionFactory;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
@ -1,127 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "JoinTableCellsTxn.h"
|
||||
#include "nsEditor.h"
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsIDOMSelection.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "EditAggregateTxn.h"
|
||||
|
||||
static NS_DEFINE_IID(kJoinTableCellsTxnIID, JOIN_CELLS_TXN_IID);
|
||||
static NS_DEFINE_IID(kIDOMSelectionIID, NS_IDOMSELECTION_IID);
|
||||
|
||||
nsIAtom *JoinTableCellsTxn::gJoinTableCellsTxnName;
|
||||
|
||||
nsresult JoinTableCellsTxn::ClassInit()
|
||||
{
|
||||
if (nsnull==gJoinTableCellsTxnName)
|
||||
gJoinTableCellsTxnName = NS_NewAtom("NS_JoinTableCellsTxn");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
JoinTableCellsTxn::JoinTableCellsTxn()
|
||||
: EditTxn()
|
||||
{
|
||||
}
|
||||
|
||||
JoinTableCellsTxn::~JoinTableCellsTxn()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP JoinTableCellsTxn::Init(nsIDOMCharacterData *aElement,
|
||||
nsIDOMNode *aNode,
|
||||
nsIPresShell* aPresShell)
|
||||
{
|
||||
mElement = do_QueryInterface(aElement);
|
||||
mNodeToInsert = aNode;
|
||||
mPresShell = aPresShell;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP JoinTableCellsTxn::Do(void)
|
||||
{
|
||||
//nsresult res = mElement->InsertData(mOffset, mStringToInsert);
|
||||
// advance caret: This requires the presentation shell to get the selection.
|
||||
nsresult res = NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDOMSelection> selection;
|
||||
res = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
res = selection->Collapse(mElement, 0 /*mOffset+1*/ /*+mStringToInsert.Length()*/);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP JoinTableCellsTxn::Undo(void)
|
||||
{
|
||||
nsresult result = NS_ERROR_FAILURE;
|
||||
#if 0
|
||||
PRUint32 length = mStringToInsert.Length();
|
||||
result = mElement->DeleteData(mOffset, length);
|
||||
if (NS_SUCCEEDED(result))
|
||||
{ // set the selection to the insertion point where the string was removed
|
||||
nsCOMPtr<nsIDOMSelection> selection;
|
||||
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
result = selection->Collapse(mElement, mOffset);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP JoinTableCellsTxn::Write(nsIOutputStream *aOutputStream)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP JoinTableCellsTxn::GetUndoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
*aString="Remove Table";
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP JoinTableCellsTxn::GetRedoString(nsString *aString)
|
||||
{
|
||||
if (nsnull!=aString)
|
||||
{
|
||||
*aString="Insert Table";
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* ============= nsISupports implementation ====================== */
|
||||
|
||||
NS_IMETHODIMP
|
||||
JoinTableCellsTxn::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if (nsnull == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aIID.Equals(kJoinTableCellsTxnIID)) {
|
||||
*aInstancePtr = (void*)(JoinTableCellsTxn*)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return (EditTxn::QueryInterface(aIID, aInstancePtr));
|
||||
}
|
||||
|
@ -1,104 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef JoinTableCells_h__
|
||||
#define JoinTableCells_h__
|
||||
|
||||
#include "EditTxn.h"
|
||||
#include "nsIEditor.h"
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#define JOIN_CELLS_TXN_IID \
|
||||
{/*50956DE6-C843-11d2-B1C3-004095E27A10*/ \
|
||||
0x50956de6, 0xc843, 0x11d2, \
|
||||
{ 0xb1, 0xc3, 0x0, 0x40, 0x95, 0xe2, 0x7a, 0x10 } }
|
||||
|
||||
class nsIPresShell;
|
||||
|
||||
/**
|
||||
* A transaction that inserts Table into a content node.
|
||||
*/
|
||||
class JoinTableCellsTxn : public EditTxn
|
||||
{
|
||||
public:
|
||||
virtual ~JoinTableCellsTxn();
|
||||
/** used to name aggregate transactions that consist only of a single JoinTableCellsTxn,
|
||||
* or a DeleteSelection followed by an JoinTableCellsTxn.
|
||||
*/
|
||||
static nsIAtom *gJoinTableCellsTxnName;
|
||||
|
||||
/** initialize the transaction
|
||||
* @param aElement the current content node
|
||||
* @param aNode the new Table to insert
|
||||
* @param aPresShell used to get and set the selection
|
||||
*/
|
||||
NS_IMETHOD Init(nsIDOMCharacterData *aElement,
|
||||
nsIDOMNode *aNode,
|
||||
nsIPresShell* aPresShell);
|
||||
|
||||
private:
|
||||
|
||||
JoinTableCellsTxn();
|
||||
|
||||
public:
|
||||
|
||||
NS_IMETHOD Do(void);
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
|
||||
//NS_IMETHOD Merge(PRBool *aDidMerge, nsITransaction *aTransaction);
|
||||
|
||||
NS_IMETHOD Write(nsIOutputStream *aOutputStream);
|
||||
|
||||
NS_IMETHOD GetUndoString(nsString *aString);
|
||||
|
||||
NS_IMETHOD GetRedoString(nsString *aString);
|
||||
|
||||
// nsISupports declarations
|
||||
|
||||
// override QueryInterface to handle JoinTableCellsTxn request
|
||||
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
|
||||
|
||||
static const nsIID& GetIID() { static nsIID iid = JOIN_CELLS_TXN_IID; return iid; }
|
||||
|
||||
|
||||
/** return the string data associated with this transaction */
|
||||
// NS_IMETHOD GetData(nsString& aResult);
|
||||
|
||||
/** must be called before any JoinTableCellsTxn is instantiated */
|
||||
static nsresult ClassInit();
|
||||
|
||||
protected:
|
||||
|
||||
// /* return PR_TRUE if aOtherTxn immediately follows this txn */
|
||||
// virtual PRBool IsSequentialInsert(JoinTableCellsTxn *aOtherTxn);
|
||||
|
||||
/** the element to operate upon */
|
||||
nsCOMPtr<nsIDOMCharacterData> mElement;
|
||||
|
||||
nsIDOMNode *mNodeToInsert;
|
||||
|
||||
/** the presentation shell, which we'll need to get the selection */
|
||||
nsIPresShell* mPresShell;
|
||||
|
||||
friend class TransactionFactory;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user