nsITableEditor
| IID: | 4805e684-49b9-11d3-9ce4-ed60bd6cb5bc |
| Inherits From: | nsISupports |
This interface is implemented by the following components:
Constants
| PRInt16 | eNoSearch | = 0 |
| PRInt16 | ePreviousColumn | = 1 |
| PRInt16 | ePreviousRow | = 2 |
Methods
void deleteTable ( )
void deleteTableCell ( PRInt32 number )
void deleteTableCellContents ( )
void deleteTableColumn ( PRInt32 number )
void deleteTableRow ( PRInt32 number )
nsIDOMElement getCellAt ( nsIDOMElement table , PRInt32 rowIndex , PRInt32 colIndex )
void getCellDataAt ( nsIDOMElement table , PRInt32 rowIndex , PRInt32 colIndex , out nsIDOMElement cell , out PRInt32 startRowIndex , out PRInt32 startColIndex , out PRInt32 rowSpan , out PRInt32 colSpan , out PRInt32 actualRowSpan , out PRInt32 actualColSpan , out PRBool isSelected )
void getCellIndexes ( nsIDOMElement cell , out PRInt32 rowIndex , out PRInt32 colIndex )
nsIDOMNode getFirstRow ( nsIDOMElement tableElement )
nsIDOMElement getFirstSelectedCell ( out nsIDOMRange range )
nsIDOMElement getFirstSelectedCellInTable ( out PRInt32 rowIndex , out PRInt32 colIndex )
nsIDOMNode getNextRow ( nsIDOMNode tableElement )
nsIDOMElement getNextSelectedCell ( out nsIDOMRange range )
PRUint32 getSelectedCellsType ( nsIDOMElement element )
nsIDOMElement getSelectedOrParentTableElement ( out AString tagName , out PRInt32 count )
void getTableSize ( nsIDOMElement table , out PRInt32 rowCount , out PRInt32 colCount )
void insertTableCell ( PRInt32 number , PRBool after )
void insertTableColumn ( PRInt32 number , PRBool after )
void insertTableRow ( PRInt32 number , PRBool after )
void joinTableCells ( PRBool mergeNonContiguousContents )
void normalizeTable ( nsIDOMElement table )
void selectAllTableCells ( )
void selectBlockOfCells ( nsIDOMElement startCell , nsIDOMElement endCell )
void selectTable ( )
void selectTableCell ( )
void selectTableColumn ( )
void selectTableRow ( )
void setSelectionAfterTableEdit ( nsIDOMElement table , PRInt32 row , PRInt32 col , PRInt32 direction , PRBool selected )
void splitTableCell ( )
nsIDOMElement switchTableCellHeaderType ( nsIDOMElement sourceCell )
Delete table methods Delete starting at the selected cell or the cell (or table) enclosing the selection anchor The selection is collapsed and is left in the cell at the same row,col location as the previous selection anchor, if possible, else in the closest neigboring cell
void deleteTableCell ( PRInt32 number )
Delete cell elements as well as contents
When there are more than 1 selected cells, number is ignored. For Delete Rows or Columns, the complete columns or rows are determined by the selected cells. E.g., to delete 2 complete rows, user simply selects a cell in each, and they don't have to be contiguous.
- Arguments:
- number: Number of contiguous cells, rows, or columns
void deleteTableCellContents ( )
Delete just the cell contents This is what should happen when Delete key is used for selected cells, to minimize upsetting the table layout
nsIDOMElement getCellAt ( nsIDOMElement table , PRInt32 rowIndex , PRInt32 colIndex )
Get a cell element at cellmap grid coordinates A cell that spans across multiple cellmap locations will be returned multiple times, once for each location it occupies
(in C++ returns: NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found passes NS_SUCCEEDED macro)
You can scan for all cells in a row or column by iterating through the appropriate indexes until the returned cell is null
- Arguments:
- table: A table in the document
- rowIndex: , colIndex The 0-based cellmap indexes
- colIndex
void getCellDataAt ( nsIDOMElement table , PRInt32 rowIndex , PRInt32 colIndex , out nsIDOMElement cell , out PRInt32 startRowIndex , out PRInt32 startColIndex , out PRInt32 rowSpan , out PRInt32 colSpan , out PRInt32 actualRowSpan , out PRInt32 actualColSpan , out PRBool isSelected )
Get a cell at cellmap grid coordinates and associated data A cell that spans across multiple cellmap locations will be returned multiple times, once for each location it occupies Examine the returned startRowIndex and startColIndex to see if it is in the same layout column or layout row: A "layout row" is all cells sharing the same top edge 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
(in C++ returns: NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found passes NS_SUCCEEDED macro)
- Arguments:
- table: A table in the document
- rowIndex: , colIndex The 0-based cellmap indexes returns values:
- colIndex
- cell: The cell at this cellmap location
- startRowIndex: The row index where cell starts
- startColIndex: The col index where cell starts
- rowSpan: May be 0 (to span down entire table) or number of cells spanned
- colSpan: May be 0 (to span across entire table) or number of cells spanned
- actualRowSpan: The actual number of cellmap locations (rows) spanned by the cell
- actualColSpan: The actual number of cellmap locations (columns) spanned by the cell
- isSelected
void getCellIndexes ( nsIDOMElement cell , out PRInt32 rowIndex , out PRInt32 colIndex )
Get the row an column index from the layout's cellmap If cell is null, it will try to find enclosing table of selection anchor
- Arguments:
- cell
- rowIndex
- colIndex
nsIDOMNode getFirstRow ( nsIDOMElement tableElement )
Get the first row element in a table
- Arguments:
- tableElement
- Returns:
- The row at the requested index Returns null if there are no rows in table (in C++ returns: NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found passes NS_SUCCEEDED macro)
nsIDOMElement getFirstSelectedCell ( out nsIDOMRange range )
Get first selected element from first selection range. (If multiple cells were selected this is the first in the order they were selected) Assumes cell-selection model where each cell is in a separate range (selection parent node is table row)
- Arguments:
- range: [OUT] Optional: if not null, return the selection range associated with the cell Returns the DOM cell element (in C++: returns NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found passes NS_SUCCEEDED macro)
nsIDOMElement getFirstSelectedCellInTable ( out PRInt32 rowIndex , out PRInt32 colIndex )
Get first selected element in the table This is the upper-left-most selected cell in table, ignoring the order that the user selected them (order in the selection ranges) Assumes cell-selection model where each cell is in a separate range (selection parent node is table row)
Returns the DOM cell element (in C++: returns NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found passes NS_SUCCEEDED macro)
- Arguments:
- rowIndex: Optional: if not null, return row index of 1st cell
- colIndex: Optional: if not null, return column index of 1st cell
nsIDOMNode getNextRow ( nsIDOMNode tableElement )
Get the next row element starting the search from tableElement
- Arguments:
- tableElement: Any TR or child-of-TR element in the document
- Returns:
- The row to start search from and the row returned from the search Returns null if there isn't another row (in C++ returns: NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found passes NS_SUCCEEDED macro)
nsIDOMElement getNextSelectedCell ( out nsIDOMRange range )
Get next selected cell element from first selection range. Assumes cell-selection model where each cell is in a separate range (selection parent node is table row) Always call GetFirstSelectedCell() to initialize stored index of "next" cell
Returns the DOM cell element (in C++: returns NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found passes NS_SUCCEEDED macro)
- Arguments:
- range: Optional: if not null, return the selection range associated with the cell
PRUint32 getSelectedCellsType ( nsIDOMElement element )
Generally used after GetSelectedOrParentTableElement to test if selected cells are complete rows or columns
- Arguments:
- element: Any table or cell element or any element inside a table Used to get enclosing table. If null, selection's anchorNode is used
- Returns:
- 0 aCellElement was not a cell (returned result = NS_ERROR_FAILURE) TABLESELECTION_CELL There are 1 or more cells selected but complete rows or columns are not selected TABLESELECTION_ROW All cells are in 1 or more rows and in each row, all cells selected Note: This is the value if all rows (thus all cells) are selected TABLESELECTION_COLUMN All cells are in 1 or more columns and in each column, all cells are selected
nsIDOMElement getSelectedOrParentTableElement ( out AString tagName , out PRInt32 count )
Examine the current selection and find a selected TABLE, TD or TH, or TR element. or return the parent TD or TH if selection is inside a table cell Returns null if no table element is found.
- Arguments:
- tagName: The tagname of returned element Note that "td" will be returned if name is actually "th"
- count: How many table elements were selected This tells us if we have multiple cells selected (0 if element is a parent cell of selection)
- Returns:
- The table element (table, row, or first selected cell)
void getTableSize ( nsIDOMElement table , out PRInt32 rowCount , out PRInt32 colCount )
Get the number of rows and columns in a table from the layout's cellmap If table is null, it will try to find enclosing table of selection ancho Note that all rows in table will not have this many because of ROWSPAN effects or if table is not "rectangular" (has short rows)
- Arguments:
- table
- rowCount
- colCount
void insertTableCell ( PRInt32 number , PRBool after )
Insert table methods Insert relative to the selected cell or the cell enclosing the selection anchor The selection is collapsed and is left in the new cell at the same row,col location as the original anchor cell
- Arguments:
- number: Number of items to insert
- after: If TRUE, insert after the current cell, else insert before current cell
void joinTableCells ( PRBool mergeNonContiguousContents )
Merges contents of all selected cells for selected cells that are adjacent, this will result in a larger cell with appropriate rowspan and colspan, and original cells are deleted The resulting cell is in the location of the cell at the upper-left corner of the adjacent block of selected cells
If there are no selected cells, and selection or caret is in a cell, that cell and the one to the right are merged
- Arguments:
- mergeNonContiguousContents: : If true: Non-contiguous cells are not deleted, but their contents are still moved to the upper-left cell If false: contiguous cells are ignored
void normalizeTable ( nsIDOMElement table )
Scan through all rows and add cells as needed so all locations in the cellmap are occupied. Used after inserting single cells or pasting a collection of cells that extend past the previous size of the table If table is null, it uses table enclosing the selection anchor This doesn't doesn't change the selection, thus it can be used to fixup all tables in a page independant of the selection
- Arguments:
- table
void selectBlockOfCells ( nsIDOMElement startCell , nsIDOMElement endCell )
Select a rectangular block of cells: all cells falling within the row/column index of startCell to through the row/column index of the endCell startCell can be any location relative to endCell, as long as they are in the same table
- Arguments:
- startCell: starting cell in block
- endCell: ending cell in block
Table Selection methods Selecting a row or column actually selects all cells (not TR in the case of rows)
void setSelectionAfterTableEdit ( nsIDOMElement table , PRInt32 row , PRInt32 col , PRInt32 direction , PRBool selected )
Reset a selected cell or collapsed selection (the caret) after table editing
- Arguments:
- table: A table in the document
- row: The row ...
- col: ... and column defining the cell where we will try to place the caret
- direction: If cell at (aCol, row) is not found, search for previous cell in the same column (aPreviousColumn) or row (ePreviousRow) or don't search for another cell (aNoSearch) If no cell is found, caret is place just before table; and if that fails, at beginning of document. Thus we generally don't worry about the return value and can use the nsSetSelectionAfterTableEdit stack-based object to insure we reset the caret in a table-editing method.
- selected: If true, we select the whole cell instead of setting caret
Split a cell that has rowspan and/or colspan > 0 into cells such that all new cells have rowspan = 1 and colspan = 1 All of the contents are not touched -- they will appear to be in the upper-left cell
nsIDOMElement switchTableCellHeaderType ( nsIDOMElement sourceCell )
Create a new TD or TH element, the opposite type of the supplied sourceCell 1. Copy all attributes from sourceCell to the new cell 2. Move all contents of sourceCell to the new cell 3. Replace sourceCell in the table with the new cell
- Arguments:
- sourceCell: The cell to be replaced
- Returns:
- The new cell that replaces aSourceCell
Reference documentation is generated from Mozilla's source.
