Table editing (bug 20973): added support for rowspan/colspan=0, Rewrote Spelling Dictionary dialog (bug 24264), removed beep from forceInteger filter, r=akkana

This commit is contained in:
cmanske%netscape.com 2000-01-26 14:57:43 +00:00
parent acb4eb592c
commit 1a85d5b775
13 changed files with 331 additions and 138 deletions

View File

@ -130,10 +130,11 @@ nsHTMLEditor::InsertTableCell(PRInt32 aNumber, PRBool aAfter)
if (NS_FAILED(res)) return res;
// Get more data for current cell in row we are inserting at (we need COLSPAN)
PRInt32 curStartRowIndex, curStartColIndex, rowSpan, colSpan;
PRInt32 curStartRowIndex, curStartColIndex, rowSpan, colSpan, actualRowSpan, actualColSpan;
PRBool isSelected;
res = GetCellDataAt(table, startRowIndex, startColIndex, *getter_AddRefs(curCell),
curStartRowIndex, curStartColIndex, rowSpan, colSpan, isSelected);
curStartRowIndex, curStartColIndex, rowSpan, colSpan,
actualRowSpan, actualColSpan, isSelected);
if (NS_FAILED(res)) return res;
if (!curCell) return NS_ERROR_FAILURE;
PRInt32 newCellIndex = aAfter ? (startColIndex+colSpan) : startColIndex;
@ -154,6 +155,28 @@ nsHTMLEditor::InsertTableCell(PRInt32 aNumber, PRBool aAfter)
return res;
}
nsresult nsHTMLEditor::GetRowAt(nsCOMPtr<nsIDOMElement> &aTable, PRInt32 rowIndex, nsCOMPtr<nsIDOMElement> &aRow)
{
aRow = nsnull;
nsCOMPtr<nsIDOMElement> nextRow;
PRInt32 index = 0;
nsAutoString tagName("tr");
nsresult res = GetNextElementByTagName(aTable, &tagName, getter_AddRefs(nextRow));
if (NS_FAILED(res)) return res;
if (!nextRow) return NS_OK;
nsCOMPtr<nsIDOMElement> parentTable;
res = GetElementOrParentByTagName("table", nextRow, getter_AddRefs(parentTable));
if (NS_FAILED(res)) return res;
if (!parentTable) return NS_ERROR_NULL_POINTER;
if (parentTable == aTable)
aRow = nextRow;
return res;
}
NS_IMETHODIMP
nsHTMLEditor::InsertTableColumn(PRInt32 aNumber, PRBool aAfter)
{
@ -166,10 +189,11 @@ nsHTMLEditor::InsertTableColumn(PRInt32 aNumber, PRBool aAfter)
if (NS_FAILED(res)) return res;
// Get more data for current cell (we need ROWSPAN)
PRInt32 curStartRowIndex, curStartColIndex, rowSpan, colSpan;
PRInt32 curStartRowIndex, curStartColIndex, rowSpan, colSpan, actualRowSpan, actualColSpan;
PRBool isSelected;
res = GetCellDataAt(table, startRowIndex, startColIndex, *getter_AddRefs(curCell),
curStartRowIndex, curStartColIndex, rowSpan, colSpan, isSelected);
curStartRowIndex, curStartColIndex, rowSpan, colSpan,
actualRowSpan, actualColSpan, isSelected);
if (NS_FAILED(res)) return res;
if (!curCell) return NS_ERROR_FAILURE;
@ -192,7 +216,8 @@ nsHTMLEditor::InsertTableColumn(PRInt32 aNumber, PRBool aAfter)
{
// We are inserting before an existing column
res = GetCellDataAt(table, row, startColIndex, *getter_AddRefs(curCell),
curStartRowIndex, curStartColIndex, rowSpan, colSpan, isSelected);
curStartRowIndex, curStartColIndex, rowSpan, colSpan,
actualRowSpan, actualColSpan, isSelected);
if (NS_FAILED(res)) return res;
// Don't fail entire process if we fail to find a cell
@ -201,11 +226,16 @@ nsHTMLEditor::InsertTableColumn(PRInt32 aNumber, PRBool aAfter)
{
if (curStartColIndex < startColIndex)
{
// We have a cell spanning this location
// Simply increase its colspan to keep table rectangular
nsAutoString newColSpan;
newColSpan.Append(colSpan+aNumber, 10);
SetAttribute(curCell, "colspan", newColSpan);
if (colSpan > 0)
{
// We have a cell spanning this location
// Simply increase its colspan to keep table rectangular
nsAutoString newColSpan;
newColSpan.Append(colSpan+aNumber, 10);
SetAttribute(curCell, "colspan", newColSpan);
}
// Note: we do nothing if colsSpan=0,
// since it should automatically span the new column
} else {
// Simply set selection to the current cell
// so we can let InsertTableCell() do the work
@ -215,13 +245,16 @@ nsHTMLEditor::InsertTableColumn(PRInt32 aNumber, PRBool aAfter)
}
}
} else {
// We are inserting after all existing columns
//TODO: A better strategy is to get the row at index "row"
// and append a cell to the end of it.
// Need to write "GetRowAt()" to do this
// Get last cell in row and insert new cell after it
res = GetCellDataAt(table, row, lastColumn, *getter_AddRefs(curCell),
curStartRowIndex, curStartColIndex, rowSpan, colSpan, isSelected);
curStartRowIndex, curStartColIndex, rowSpan, colSpan,
actualRowSpan, actualColSpan, isSelected);
if (NS_FAILED(res)) return res;
if (curCell)
{
@ -245,10 +278,11 @@ nsHTMLEditor::InsertTableRow(PRInt32 aNumber, PRBool aAfter)
if (NS_FAILED(res)) return res;
// Get more data for current cell in row we are inserting at (we need COLSPAN)
PRInt32 curStartRowIndex, curStartColIndex, rowSpan, colSpan;
PRInt32 curStartRowIndex, curStartColIndex, rowSpan, colSpan, actualRowSpan, actualColSpan;
PRBool isSelected;
res = GetCellDataAt(table, startRowIndex, startColIndex, *getter_AddRefs(curCell),
curStartRowIndex, curStartColIndex, rowSpan, colSpan, isSelected);
curStartRowIndex, curStartColIndex, rowSpan, colSpan,
actualRowSpan, actualColSpan, isSelected);
if (NS_FAILED(res)) return res;
if (!curCell) return NS_ERROR_FAILURE;
@ -272,9 +306,9 @@ nsHTMLEditor::InsertTableRow(PRInt32 aNumber, PRBool aAfter)
if (aAfter)
{
// Use row after current cell
startRowIndex += rowSpan;
startRowIndex += actualRowSpan;
// offset to use for new row insert
newRowOffset += rowSpan;
newRowOffset += actualRowSpan;
}
nsAutoEditBatch beginBatching(this);
@ -290,31 +324,50 @@ nsHTMLEditor::InsertTableRow(PRInt32 aNumber, PRBool aAfter)
// This returns NS_TABLELAYOUT_CELL_NOT_FOUND when we run past end of row,
// which passes the NS_SUCCEEDED macro
while ( NS_OK == GetCellDataAt(table, newRowOffset, colIndex, *getter_AddRefs(curCell),
curStartRowIndex, curStartColIndex, rowSpan, colSpan, isSelected) )
curStartRowIndex, curStartColIndex, rowSpan, colSpan,
actualRowSpan, actualColSpan, isSelected) )
{
if (curCell)
{
if (curStartRowIndex < startRowIndex)
{
// We have a cell spanning this location
// Simply increase its colspan to keep table rectangular
nsAutoString newRowSpan;
newRowSpan.Append(rowSpan+aNumber, 10);
SetAttribute(curCell, "rowspan", newRowSpan);
if (rowSpan > 0)
{
// We have a cell spanning this location
// Simply increase its rowspan
nsAutoString newRowSpan;
newRowSpan.Append(rowSpan+aNumber, 10);
SetAttribute(curCell, "rowspan", newRowSpan);
}
//Note that if rowSpan == 0, we do nothing,
// since that cell should automatically extend into the new row
} else {
// Count the number of cells we need to add to the new row
cellsInRow += colSpan;
cellsInRow += actualColSpan;
}
// Next cell in row
colIndex += colSpan;
colIndex += actualColSpan;
}
else
colIndex++;
}
} else {
// We are adding after existing rows,
// so use max number of cells in a row
// We are adding a new row after all others
// If it weren't for colspan=0 effect,
// we could simply use colCount for number of new cells...
cellsInRow = colCount;
// ...but we must compensate for all cells with rowSpan = 0 in the last row
PRInt32 lastRow = rowCount-1;
PRInt32 tempColIndex = 0;
while ( NS_OK == GetCellDataAt(table, lastRow, tempColIndex, *getter_AddRefs(curCell),
curStartRowIndex, curStartColIndex, rowSpan, colSpan,
actualRowSpan, actualColSpan, isSelected) )
{
if (rowSpan == 0)
cellsInRow -= actualColSpan;
}
tempColIndex += actualColSpan;
}
if (cellsInRow > 0)
@ -527,7 +580,7 @@ nsHTMLEditor::DeleteTableColumn(PRInt32 aNumber)
// Scan through cells in row to do rowspan adjustments
nsCOMPtr<nsIDOMElement> curCell;
PRInt32 curStartRowIndex, curStartColIndex, rowSpan, colSpan;
PRInt32 curStartRowIndex, curStartColIndex, rowSpan, colSpan, actualRowSpan, actualColSpan;
PRBool isSelected;
PRInt32 rowIndex = 0;
@ -535,40 +588,44 @@ nsHTMLEditor::DeleteTableColumn(PRInt32 aNumber)
{
do {
res = GetCellDataAt(table, rowIndex, startColIndex, *getter_AddRefs(curCell),
curStartRowIndex, curStartColIndex, rowSpan, colSpan, isSelected);
curStartRowIndex, curStartColIndex, rowSpan, colSpan,
actualRowSpan, actualColSpan, isSelected);
if (NS_FAILED(res)) return res;
NS_ASSERTION((colSpan > 0),"COLSPAN = 0 in DeleteTableColumn");
NS_ASSERTION((rowSpan > 0),"ROWSPAN = 0 in DeleteTableColumn");
NS_ASSERTION((actualColSpan > 0),"Effective COLSPAN = 0 in DeleteTableColumn");
NS_ASSERTION((actualRowSpan > 0),"Effective ROWSPAN = 0 in DeleteTableColumn");
if (curCell)
{
// Find cells that don't start in column we are deleting
if (curStartColIndex < startColIndex || colSpan > 1)
if (curStartColIndex < startColIndex || colSpan > 1 || colSpan == 0)
{
NS_ASSERTION((colSpan > 1),"Bad COLSPAN in DeleteTableColumn");
// We have a cell spanning this location
// Decrease its colspan to keep table rectangular
nsAutoString newColSpan;
//This calculates final span for all columns deleted,
// but we are iterating aNumber times through here so
// just decrement current value by 1
//PRInt32 minSpan = startColIndex - curStartColIndex;
//PRInt32 newSpan = PR_MAX(minSpan, colSpan - aNumber);
//newColSpan.Append(newSpan, 10);
newColSpan.Append(colSpan-1, 10);
SetAttribute(curCell, "colspan", newColSpan);
// Delete contents of cell instead of cell itself
// Decrease its colspan to keep table rectangular,
// but if colSpan=0, it will adjust automatically
if (colSpan > 0)
{
NS_ASSERTION((colSpan > 1),"Bad COLSPAN in DeleteTableColumn");
nsAutoString newColSpan;
//This calculates final span for all columns deleted,
// but we are iterating aNumber times through here so
// just decrement current value by 1
//PRInt32 minSpan = startColIndex - curStartColIndex;
//PRInt32 newSpan = PR_MAX(minSpan, colSpan - aNumber);
//newColSpan.Append(newSpan, 10);
newColSpan.Append(colSpan-1, 10);
SetAttribute(curCell, "colspan", newColSpan);
}
if (curStartColIndex == startColIndex)
{
// Cell is in column to be deleted,
// but delete contents of cell instead of cell itself
selection->Collapse(curCell,0);
DeleteTableCellContents();
}
// To next cell in row
rowIndex++;
// To next cell in column
rowIndex += actualRowSpan;
} else {
// Delete the cell
if (1 == GetNumberOfCellsInRow(table, rowIndex))
@ -603,7 +660,7 @@ nsHTMLEditor::DeleteTableColumn(PRInt32 aNumber)
if (NS_FAILED(res)) return res;
//Skipover any rows spanned by this cell
rowIndex +=rowSpan;
rowIndex += actualRowSpan;
}
}
} else {
@ -649,15 +706,16 @@ nsHTMLEditor::DeleteTableRow(PRInt32 aNumber)
// Scan through cells in row to do rowspan adjustments
nsCOMPtr<nsIDOMElement> curCell;
PRInt32 curStartRowIndex, curStartColIndex, rowSpan, colSpan;
PRInt32 curStartRowIndex, curStartColIndex, rowSpan, colSpan, actualRowSpan, actualColSpan;
PRBool isSelected;
PRInt32 colIndex = 0;
do {
res = GetCellDataAt(table, startRowIndex, colIndex, *getter_AddRefs(curCell),
curStartRowIndex, curStartColIndex, rowSpan, colSpan, isSelected);
curStartRowIndex, curStartColIndex, rowSpan, colSpan,
actualRowSpan, actualColSpan, isSelected);
NS_ASSERTION((colSpan > 0),"COLSPAN = 0 in DeleteTableRow");
NS_ASSERTION((rowSpan > 0),"ROWSPAN = 0 in DeleteTableRow");
NS_ASSERTION((actualColSpan > 0),"Effective COLSPAN = 0 in DeleteTableRow");
NS_ASSERTION((actualRowSpan > 0),"Effective ROWSPAN = 0 in DeleteTableRow");
// Find cells that don't start in row we are deleting
if (NS_SUCCEEDED(res) && curCell)
@ -666,14 +724,18 @@ nsHTMLEditor::DeleteTableRow(PRInt32 aNumber)
{
// We have a cell spanning this location
// Decrease its rowspan to keep table rectangular
nsAutoString newRowSpan;
PRInt32 minSpan = startRowIndex - curStartRowIndex;
PRInt32 newSpan = PR_MAX(minSpan, rowSpan - aNumber);
newRowSpan.Append(newSpan, 10);
SetAttribute(curCell, "rowspan", newRowSpan);
// but we don't need to do this if rowspan=0,
// since it will automatically adjust
if (rowSpan > 0)
{
nsAutoString newRowSpan;
PRInt32 newSpan = PR_MAX((startRowIndex - curStartRowIndex), actualRowSpan - aNumber);
newRowSpan.Append(newSpan, 10);
SetAttribute(curCell, "rowspan", newRowSpan);
}
}
// Skip over locations spanned by this cell
colIndex += colSpan;
colIndex += actualColSpan;
}
else
colIndex++;
@ -776,10 +838,11 @@ PRBool nsHTMLEditor::GetNumberOfCellsInRow(nsIDOMElement* aTable, PRInt32 rowInd
PRInt32 colIndex = 0;
nsresult res;
do {
PRInt32 startRowIndex, startColIndex, rowSpan, colSpan;
PRInt32 startRowIndex, startColIndex, rowSpan, colSpan, actualRowSpan, actualColSpan;
PRBool isSelected;
res = GetCellDataAt(aTable, rowIndex, colIndex, *getter_AddRefs(cell),
startRowIndex, startColIndex, rowSpan, colSpan, isSelected);
startRowIndex, startColIndex, rowSpan, colSpan,
actualRowSpan, actualColSpan, isSelected);
if (NS_FAILED(res)) return res;
if (cell)
{
@ -788,7 +851,7 @@ PRBool nsHTMLEditor::GetNumberOfCellsInRow(nsIDOMElement* aTable, PRInt32 rowInd
cellCount++;
//Next possible location for a cell
colIndex += colSpan;
colIndex += actualColSpan;
}
else
colIndex++;
@ -830,7 +893,9 @@ nsHTMLEditor::GetTableSize(nsIDOMElement *aTable, PRInt32& aRowCount, PRInt32& a
NS_IMETHODIMP
nsHTMLEditor::GetCellDataAt(nsIDOMElement* aTable, PRInt32 aRowIndex, PRInt32 aColIndex, nsIDOMElement* &aCell,
PRInt32& aStartRowIndex, PRInt32& aStartColIndex,
PRInt32& aRowSpan, PRInt32& aColSpan, PRBool& aIsSelected)
PRInt32& aRowSpan, PRInt32& aColSpan,
PRInt32& aActualRowSpan, PRInt32& aActualColSpan,
PRBool& aIsSelected)
{
nsresult res=NS_ERROR_FAILURE;
aCell = nsnull;
@ -838,6 +903,8 @@ nsHTMLEditor::GetCellDataAt(nsIDOMElement* aTable, PRInt32 aRowIndex, PRInt32 aC
aStartColIndex = 0;
aRowSpan = 0;
aColSpan = 0;
aActualRowSpan = 0;
aActualColSpan = 0;
aIsSelected = PR_FALSE;
if (!aTable)
@ -862,17 +929,20 @@ nsHTMLEditor::GetCellDataAt(nsIDOMElement* aTable, PRInt32 aRowIndex, PRInt32 aC
// the index(es) are out of bounds
return tableLayoutObject->GetCellDataAt(aRowIndex, aColIndex, aCell,
aStartRowIndex, aStartColIndex,
aRowSpan, aColSpan, aIsSelected);
aRowSpan, aColSpan,
aActualRowSpan, aActualColSpan,
aIsSelected);
}
// When all you want is the cell
NS_IMETHODIMP
nsHTMLEditor::GetCellAt(nsIDOMElement* aTable, PRInt32 aRowIndex, PRInt32 aColIndex, nsIDOMElement* &aCell)
{
PRInt32 startRowIndex, startColIndex, rowSpan, colSpan;
PRInt32 startRowIndex, startColIndex, rowSpan, colSpan, actualRowSpan, actualColSpan;
PRBool isSelected;
return GetCellDataAt(aTable, aRowIndex, aColIndex, aCell,
startRowIndex, startColIndex, rowSpan, colSpan, isSelected);
startRowIndex, startColIndex, rowSpan, colSpan,
actualRowSpan, actualColSpan, isSelected);
}
NS_IMETHODIMP

View File

@ -3256,11 +3256,15 @@ nsEditorShell::GetCellAt(nsIDOMElement *tableElement, PRInt32 rowIndex, PRInt32
NS_IMETHODIMP
nsEditorShell::GetCellDataAt(nsIDOMElement *tableElement, PRInt32 rowIndex, PRInt32 colIndex,
PRInt32 *aStartRowIndex, PRInt32 *aStartColIndex,
PRInt32 *aRowSpan, PRInt32 *aColSpan, PRBool *aIsSelected, nsIDOMElement **_retval)
PRInt32 *aRowSpan, PRInt32 *aColSpan,
PRInt32 *aActualRowSpan, PRInt32 *aActualColSpan,
PRBool *aIsSelected, nsIDOMElement **_retval)
{
if (!_retval ||
!aStartRowIndex || !aStartColIndex ||
!aRowSpan || !aColSpan || !aIsSelected )
!aRowSpan || !aColSpan ||
!aActualRowSpan || !aActualColSpan ||
!aIsSelected )
return NS_ERROR_NULL_POINTER;
nsresult result = NS_NOINTERFACE;
@ -3271,7 +3275,10 @@ nsEditorShell::GetCellDataAt(nsIDOMElement *tableElement, PRInt32 rowIndex, PRIn
nsCOMPtr<nsITableEditor> tableEditor = do_QueryInterface(mEditor);
if (tableEditor)
result = tableEditor->GetCellDataAt(tableElement, rowIndex, colIndex, *_retval,
*aStartRowIndex, *aStartColIndex, *aRowSpan, *aColSpan, *aIsSelected);
*aStartRowIndex, *aStartColIndex,
*aRowSpan, *aColSpan,
*aActualRowSpan, *aActualColSpan,
*aIsSelected);
}
break;
default:

View File

@ -7246,3 +7246,48 @@ nsHTMLEditor::CollapseAdjacentTextNodes(nsIDOMSelection *aInSelection)
return result;
}
NS_IMETHODIMP
nsHTMLEditor::GetNextElementByTagName(nsIDOMElement *aCurrentElement,
const nsString *aTagName,
nsIDOMElement **aReturn)
{
nsresult res = NS_OK;
if (!aCurrentElement || !aTagName || !aReturn)
return NS_ERROR_NULL_POINTER;
nsIAtom *tagAtom = NS_NewAtom(*aTagName);
if (!tagAtom) { return NS_ERROR_NULL_POINTER; }
if (tagAtom==nsIEditProperty::th)
tagAtom=nsIEditProperty::td;
nsCOMPtr<nsIDOMNode> currentNode = do_QueryInterface(aCurrentElement);
if (!currentNode)
return NS_ERROR_FAILURE;
*aReturn = nsnull;
nsCOMPtr<nsIDOMNode> nextNode;
PRBool done = PR_FALSE;
do {
res = GetNextNode(currentNode, PR_TRUE, getter_AddRefs(nextNode));
if (NS_FAILED(res)) return res;
if (!nextNode) break;
nsCOMPtr<nsIAtom> atom = GetTag(currentNode);
if (tagAtom==atom)
{
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(currentNode);
if (!element) return NS_ERROR_NULL_POINTER;
*aReturn = element;
NS_ADDREF(*aReturn);
done = PR_TRUE;
return NS_OK;
}
currentNode = nextNode;
} while (!done);
return res;
}

View File

@ -138,6 +138,8 @@ public:
NS_IMETHOD GetElementOrParentByTagName(const nsString& aTagName, nsIDOMNode *aNode, nsIDOMElement** aReturn);
NS_IMETHOD GetSelectedElement(const nsString& aTagName, nsIDOMElement** aReturn);
NS_IMETHOD CreateElementWithDefaults(const nsString& aTagName, nsIDOMElement** aReturn);
NS_IMETHOD GetNextElementByTagName(nsIDOMElement *aCurrentElement, const nsString *aTagName, nsIDOMElement **aReturn);
NS_IMETHOD InsertLinkAroundSelection(nsIDOMElement* aAnchorElement);
@ -187,7 +189,9 @@ public:
NS_IMETHOD GetCellAt(nsIDOMElement* aTable, PRInt32 aRowIndex, PRInt32 aColIndex, nsIDOMElement* &aCell);
NS_IMETHOD GetCellDataAt(nsIDOMElement* aTable, PRInt32 aRowIndex, PRInt32 aColIndex, nsIDOMElement* &aCell,
PRInt32& aStartRowIndex, PRInt32& aStartColIndex,
PRInt32& aRowSpan, PRInt32& aColSpan, PRBool& aIsSelected);
PRInt32& aRowSpan, PRInt32& aColSpan,
PRInt32& aActualRowSpan, PRInt32& aActualColSpan,
PRBool& aIsSelected);
NS_IMETHOD SetCaretAfterTableEdit(nsIDOMElement* aTable, PRInt32 aRow, PRInt32 aCol, PRInt32 aDirection);
NS_IMETHOD GetSelectedOrParentTableElement(nsCOMPtr<nsIDOMElement> &aTableElement, nsString& aTagName, PRBool &aIsSelected);
@ -318,7 +322,8 @@ protected:
NS_IMETHOD GetTableLayoutObject(nsIDOMElement* aTable, nsITableLayout **tableLayoutObject);
// Needed to do appropriate deleting when last cell or row is about to be deleted
// This doesn't count cells that don't start in the given row (are spanning from row above)
PRInt32 GetNumberOfCellsInRow(nsIDOMElement* aTable, PRInt32 rowIndex);
PRInt32 GetNumberOfCellsInRow(nsIDOMElement* aTable, PRInt32 rowIndex);
nsresult GetRowAt(nsCOMPtr<nsIDOMElement> &aTable, PRInt32 rowIndex, nsCOMPtr<nsIDOMElement> &aRow);
// Most insert methods need to get the same basic context data
NS_IMETHOD GetCellContext(nsCOMPtr<nsIDOMSelection> &aSelection,

View File

@ -3256,11 +3256,15 @@ nsEditorShell::GetCellAt(nsIDOMElement *tableElement, PRInt32 rowIndex, PRInt32
NS_IMETHODIMP
nsEditorShell::GetCellDataAt(nsIDOMElement *tableElement, PRInt32 rowIndex, PRInt32 colIndex,
PRInt32 *aStartRowIndex, PRInt32 *aStartColIndex,
PRInt32 *aRowSpan, PRInt32 *aColSpan, PRBool *aIsSelected, nsIDOMElement **_retval)
PRInt32 *aRowSpan, PRInt32 *aColSpan,
PRInt32 *aActualRowSpan, PRInt32 *aActualColSpan,
PRBool *aIsSelected, nsIDOMElement **_retval)
{
if (!_retval ||
!aStartRowIndex || !aStartColIndex ||
!aRowSpan || !aColSpan || !aIsSelected )
!aRowSpan || !aColSpan ||
!aActualRowSpan || !aActualColSpan ||
!aIsSelected )
return NS_ERROR_NULL_POINTER;
nsresult result = NS_NOINTERFACE;
@ -3271,7 +3275,10 @@ nsEditorShell::GetCellDataAt(nsIDOMElement *tableElement, PRInt32 rowIndex, PRIn
nsCOMPtr<nsITableEditor> tableEditor = do_QueryInterface(mEditor);
if (tableEditor)
result = tableEditor->GetCellDataAt(tableElement, rowIndex, colIndex, *_retval,
*aStartRowIndex, *aStartColIndex, *aRowSpan, *aColSpan, *aIsSelected);
*aStartRowIndex, *aStartColIndex,
*aRowSpan, *aColSpan,
*aActualRowSpan, *aActualColSpan,
*aIsSelected);
}
break;
default:

View File

@ -327,10 +327,15 @@ interface nsIEditorShell : nsISupports
/* Get a cell and associated data from the layout frame based on cell map coordinates (0 index) */
nsIDOMElement GetCellAt(in nsIDOMElement tableElement, in PRInt32 rowIndex, in PRInt32 colIndex);
/* Get cell at a location in the layout's cellmap with associated data
returns null when past last cell in a row or column */
returns null when past last cell in a row or column
Note that rowSpan and/or colSpan may be 0 (for extending across entire table),
so actualRowSpan and actualColSpan are the real number of cells spanned
*/
nsIDOMElement GetCellDataAt(in nsIDOMElement tableElement, in PRInt32 rowIndex, in PRInt32 colIndex,
out PRInt32 startRowIndex, out PRInt32 startColIndex,
out PRInt32 rowSpan, out PRInt32 colSpan, out boolean isSelected);
out PRInt32 rowSpan, out PRInt32 colSpan,
out PRInt32 actualRowSpan, out PRInt32 actualColSpan,
out boolean isSelected);
/**** end of table editing *****/

View File

@ -7246,3 +7246,48 @@ nsHTMLEditor::CollapseAdjacentTextNodes(nsIDOMSelection *aInSelection)
return result;
}
NS_IMETHODIMP
nsHTMLEditor::GetNextElementByTagName(nsIDOMElement *aCurrentElement,
const nsString *aTagName,
nsIDOMElement **aReturn)
{
nsresult res = NS_OK;
if (!aCurrentElement || !aTagName || !aReturn)
return NS_ERROR_NULL_POINTER;
nsIAtom *tagAtom = NS_NewAtom(*aTagName);
if (!tagAtom) { return NS_ERROR_NULL_POINTER; }
if (tagAtom==nsIEditProperty::th)
tagAtom=nsIEditProperty::td;
nsCOMPtr<nsIDOMNode> currentNode = do_QueryInterface(aCurrentElement);
if (!currentNode)
return NS_ERROR_FAILURE;
*aReturn = nsnull;
nsCOMPtr<nsIDOMNode> nextNode;
PRBool done = PR_FALSE;
do {
res = GetNextNode(currentNode, PR_TRUE, getter_AddRefs(nextNode));
if (NS_FAILED(res)) return res;
if (!nextNode) break;
nsCOMPtr<nsIAtom> atom = GetTag(currentNode);
if (tagAtom==atom)
{
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(currentNode);
if (!element) return NS_ERROR_NULL_POINTER;
*aReturn = element;
NS_ADDREF(*aReturn);
done = PR_TRUE;
return NS_OK;
}
currentNode = nextNode;
} while (!done);
return res;
}

View File

@ -138,6 +138,8 @@ public:
NS_IMETHOD GetElementOrParentByTagName(const nsString& aTagName, nsIDOMNode *aNode, nsIDOMElement** aReturn);
NS_IMETHOD GetSelectedElement(const nsString& aTagName, nsIDOMElement** aReturn);
NS_IMETHOD CreateElementWithDefaults(const nsString& aTagName, nsIDOMElement** aReturn);
NS_IMETHOD GetNextElementByTagName(nsIDOMElement *aCurrentElement, const nsString *aTagName, nsIDOMElement **aReturn);
NS_IMETHOD InsertLinkAroundSelection(nsIDOMElement* aAnchorElement);
@ -187,7 +189,9 @@ public:
NS_IMETHOD GetCellAt(nsIDOMElement* aTable, PRInt32 aRowIndex, PRInt32 aColIndex, nsIDOMElement* &aCell);
NS_IMETHOD GetCellDataAt(nsIDOMElement* aTable, PRInt32 aRowIndex, PRInt32 aColIndex, nsIDOMElement* &aCell,
PRInt32& aStartRowIndex, PRInt32& aStartColIndex,
PRInt32& aRowSpan, PRInt32& aColSpan, PRBool& aIsSelected);
PRInt32& aRowSpan, PRInt32& aColSpan,
PRInt32& aActualRowSpan, PRInt32& aActualColSpan,
PRBool& aIsSelected);
NS_IMETHOD SetCaretAfterTableEdit(nsIDOMElement* aTable, PRInt32 aRow, PRInt32 aCol, PRInt32 aDirection);
NS_IMETHOD GetSelectedOrParentTableElement(nsCOMPtr<nsIDOMElement> &aTableElement, nsString& aTagName, PRBool &aIsSelected);
@ -318,7 +322,8 @@ protected:
NS_IMETHOD GetTableLayoutObject(nsIDOMElement* aTable, nsITableLayout **tableLayoutObject);
// Needed to do appropriate deleting when last cell or row is about to be deleted
// This doesn't count cells that don't start in the given row (are spanning from row above)
PRInt32 GetNumberOfCellsInRow(nsIDOMElement* aTable, PRInt32 rowIndex);
PRInt32 GetNumberOfCellsInRow(nsIDOMElement* aTable, PRInt32 rowIndex);
nsresult GetRowAt(nsCOMPtr<nsIDOMElement> &aTable, PRInt32 rowIndex, nsCOMPtr<nsIDOMElement> &aRow);
// Most insert methods need to get the same basic context data
NS_IMETHOD GetCellContext(nsCOMPtr<nsIDOMSelection> &aSelection,

View File

@ -134,15 +134,27 @@ public:
* A "layout column" is all cells sharing the same left edge
* This is important to determine what to do when inserting or deleting a column or row
*
* @param aTable A table in the document
* @param aRowIndex, aColIndex The 0-based cellmap indexes
* @param aTable A table in the document
* @param aRowIndex, aColIndex The 0-based cellmap indexes
* returns values:
* @param aCell The cell at this cellmap location
* @param aStartRowIndex The row index where cell starts
* @param aStartColIndex The col index where cell starts
* @param aRowSpan May be 0 (to span down entire table) or number of cells spanned
* @param aColSpan May be 0 (to span across entire table) or number of cells spanned
* @param aActualRowSpan The actual number of cellmap locations (rows) spanned by the cell
* @param aActualColSpan The actual number of cellmap locations (columns) spanned by the cell
* @param aIsSelected
* @param
*
* Note that this returns NS_TABLELAYOUT_CELL_NOT_FOUND
* when a cell is not found at the given indexes (see note for GetCellAt())
*/
NS_IMETHOD GetCellDataAt(nsIDOMElement* aTable, PRInt32 aRowIndex, PRInt32 aColIndex, nsIDOMElement* &aCell,
PRInt32& aStartRowIndex, PRInt32& aStartColIndex,
PRInt32& aRowSpan, PRInt32& aColSpan, PRBool& aIsSelected)=0;
PRInt32& aRowSpan, PRInt32& aColSpan,
PRInt32& aActualRowSpan, PRInt32& aActualColSpan,
PRBool& aIsSelected)=0;
/** Preferred direction to search for neighboring cell

View File

@ -118,11 +118,15 @@ function EditorTestTableLayout()
var startColIndexObj = new Object();
var rowSpanObj = new Object();
var colSpanObj = new Object();
var actualRowSpanObj = new Object();
var actualColSpanObj = new Object();
var isSelectedObj = new Object();
var startRowIndex = 0;
var startColIndex = 0;
var rowSpan;
var colSpan;
var actualRowSpan;
var actualColSpan;
var isSelected;
var col = 0;
var row = 0;
@ -138,19 +142,24 @@ function EditorTestTableLayout()
while (!doneWithRow) // Iterate through rows
{
dump("* Data for ROW="+row+":\n");
while(!doneWithCol) // Iterate through cells in the row
{
try {
cell = editorShell.GetCellDataAt(table, row, col, startRowIndexObj, startColIndexObj,
rowSpanObj, colSpanObj, isSelectedObj);
rowSpanObj, colSpanObj, actualRowSpanObj, actualColSpanObj,
isSelectedObj);
if (cell)
{
rowSpan = rowSpanObj.value;
colSpan = colSpanObj.value;
actualRowSpan = actualRowSpanObj.value;
actualColSpan = actualColSpanObj.value;
isSelected = isSelectedObj.value;
dump("Row,Col: "+row+","+col+" StartRow,StartCol: "+startRowIndexObj.value+","+startColIndexObj.value+" RowSpan="+rowSpan+" ColSpan="+colSpan);
dump(" Row="+row+", Col="+col+" StartRow="+startRowIndexObj.value+", StartCol="+startColIndexObj.value+"\n");
dump(" RowSpan="+rowSpan+", ColSpan="+colSpan+" ActualRowSpan="+actualRowSpan+", ActualColSpan="+actualColSpan);
if (isSelected)
dump(" Cell is selected\n");
else
@ -172,12 +181,12 @@ function EditorTestTableLayout()
// Get maximum number of cells in any row
if (col > maxColCount)
maxColCount = col;
dump(" End of row found\n\n");
dump(" End of row found\n\n");
}
}
catch (e) {
dump(" *** GetCellDataAt barfed at Row,Col:"+row+","+col+" ***\n\n");
col++;
dump(" *** GetCellDataAt failed at Row="+row+, Col="+col+" ***\n\n");
return;
}
}
if (col == 0) {
@ -191,7 +200,6 @@ function EditorTestTableLayout()
col = 0;
row++;
doneWithCol = false;
dump("Setup for next row\n");
}
}
dump("Counted during scan: Number of rows="+rowCount+" Number of Columns="+maxColCount+"\n");

View File

@ -121,9 +121,8 @@ box#DisplayModeBar titledbutton.DisplayModeButton {
border-left: 1px solid darkgray;
padding: 0px 4px 0px 4px;
margin: 0px;
/* Same as toolbar.standard titledbutton */
color: #CCFFFF;
background-color: #003366;
color: black;
background-color: #CCCCCC;
}
box#DisplayModeBar titledbutton.DisplayModeButton:hover {
@ -143,8 +142,6 @@ box#DisplayModeBar titledbutton.DisplayModeButton[selected="1"] {
padding: 0px 4px 0px 4px;
margin: -2px 0px 0px 0px;
font-weight: bold;
color: black;
background-color: #CCCCCC;
}
box#DisplayModeBar titledbutton.DisplayModeButton[selected="1"]:hover {

View File

@ -357,8 +357,9 @@ function SetPixelOrPercentByID(elementID, percentString)
// USE onkeyup!
// forceInteger by petejc (pete@postpagan.com)
var sysBeep = Components.classes["component://netscape/sound"].createInstance();
sysBeep = sysBeep.QueryInterface(Components.interfaces.nsISound);
// No one likes the beep!
//var sysBeep = Components.classes["component://netscape/sound"].createInstance();
//sysBeep = sysBeep.QueryInterface(Components.interfaces.nsISound);
function forceInteger(elementID)
{
@ -375,7 +376,7 @@ function forceInteger(elementID)
// we hope to remove the following line for blur() once xp widgets land
// cmanske (9/15) testing this now that GFX ender widget is active
//editField.blur();
sysBeep.Beep();
//sysBeep.Beep();
}
}

View File

@ -24,52 +24,38 @@
<?xml-stylesheet href="chrome://editor/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://editor/skin/EditorDialog.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://editor/locale/EditorPersonalDictionary.dtd">
<xul:window class="dialog" title="&windowTitle.label;"
xmlns:xul ="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns="http://www.w3.org/TR/REC-html40"
<window class="dialog" title="&windowTitle.label;"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/TR/REC-html40"
onload = "Startup()"
align="vertical">
<!-- Methods common to all editor dialogs -->
<script language="JavaScript" src="chrome://editor/content/EdDialogCommon.js">
</script>
<script language="JavaScript" src="chrome://editor/content/EdDictionary.js">
</script>
<html:script language="JavaScript" src="chrome://editor/content/EdDialogCommon.js"/>
<html:script language="JavaScript" src="chrome://editor/content/EdDictionary.js"/>
<xul:broadcaster id="args" value=""/>
<table>
<tr>
<td colspan="2">
&wordEditField.label;<br/>
</td>
</tr>
<tr>
<td>
<input type="text" class="SpellCheckWord" id="WordInput" size="10"/>
</td>
<td>
<xul:titledbutton class="push SizeToParent" id="AddWord" onclick="AddWord()" value="&AddButton.label;"/>
</td>
</tr>
<tr>
<td colspan="2">
&DictionaryList.label;
</td>
</tr>
<tr>
<td>
<select class="SpellCheckList" id="DictionaryList" size="10">
</select>
</td>
<td>
<xul:titledbutton class="push SizeToParent" id="ReplaceWord" onclick="ReplaceWord()" value="&ReplaceButton.label;"/>
<br/>
<xul:titledbutton class="push SizeToParent" id="RemoveWord" onclick="RemoveWord()" value="&RemoveButton.label;"/>
<br/>
<!-- This simply closes the window -->
<xul:titledbutton class="push CloseButton" id="Close" onclick="onCancel()" value="&CloseButton.label;"/>
</td>
</tr>
</table>
</xul:window>
<broadcaster id="args" value=""/>
<box align="vertical">
<html:label for="WordInput">&wordEditField.label;</html:label>
<box align="horizontal">
<html:input type="text" class="SpellCheckWord" id="WordInput"/>
<spring class="bigspacer"/>
<titledbutton class="push SizeToParent" flex="100%" id="AddWord" onclick="AddWord()" value="&AddButton.label;"/>
</box>
<spring class="bigspacer"/>
<html:label for="WordInput">&DictionaryList.label;</html:label>
<spring class="bigspacer"/>
<box align="horizontal">
<html:select class="SpellCheckList" id="DictionaryList" size="10"/>
<spring class="bigspacer"/>
<box align="vertical">
<titledbutton class="push SizeToParent" id="ReplaceWord" onclick="ReplaceWord()" value="&ReplaceButton.label;"/>
<spring class="spacer"/>
<titledbutton class="push SizeToParent" id="RemoveWord" onclick="RemoveWord()" value="&RemoveButton.label;"/>
<spring flex="100%"/>
<titledbutton class="push CloseButton" id="Close" onclick="onCancel()" value="&CloseButton.label;"/>
</box>
</box>
</box>
</window>