2001-09-26 02:53:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
2001-03-28 03:11:08 +04:00
|
|
|
*
|
2001-09-26 02:53:13 +04:00
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.1 (the "License"); you may not use this file except in
|
|
|
|
* compliance with the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/NPL/
|
2001-03-28 03:11:08 +04:00
|
|
|
*
|
2001-09-26 02:53:13 +04:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
2001-03-28 03:11:08 +04:00
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2001-09-26 02:53:13 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
2001-03-28 03:11:08 +04:00
|
|
|
*
|
2001-09-26 02:53:13 +04:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the NPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
|
|
|
|
#include "nsISupports.idl"
|
|
|
|
|
2002-03-15 01:11:14 +03:00
|
|
|
interface nsIDOMNode;
|
|
|
|
interface nsIDOMElement;
|
|
|
|
interface nsIDOMRange;
|
|
|
|
|
2001-03-28 03:11:08 +04:00
|
|
|
[scriptable, uuid(4805e684-49b9-11d3-9ce4-ed60bd6cb5bc)]
|
|
|
|
|
|
|
|
interface nsITableEditor : nsISupports
|
|
|
|
{
|
2002-03-15 01:11:14 +03:00
|
|
|
const short eNoSearch = 0;
|
|
|
|
const short ePreviousColumn = 1;
|
|
|
|
const short ePreviousRow = 2;
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/* ------------ Table editing Methods -------------- */
|
|
|
|
|
|
|
|
/** 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
|
|
|
|
*
|
|
|
|
* @param aNumber Number of items to insert
|
|
|
|
* @param aAfter If TRUE, insert after the current cell,
|
|
|
|
* else insert before current cell
|
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
void insertTableCell(in long aNumber, in boolean aAfter);
|
|
|
|
void insertTableColumn(in long aNumber, in boolean aAfter);
|
|
|
|
void insertTableRow(in long aNumber, in boolean aAfter);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/** 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
|
|
|
|
*
|
|
|
|
* @param aNumber Number of items to insert/delete
|
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
void deleteTable();
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/** Delete just the cell contents
|
|
|
|
* This is what should happen when Delete key is used
|
|
|
|
* for selected cells, to minimize upsetting the table layout
|
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
void deleteTableCellContents();
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/** Delete cell elements as well as contents
|
|
|
|
* @param aNumber Number of contiguous cells, rows, or columns
|
|
|
|
*
|
|
|
|
* When there are more than 1 selected cells, aNumber 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.
|
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
void deleteTableCell(in long aNumber);
|
|
|
|
void deleteTableColumn(in long aNumber);
|
|
|
|
void deleteTableRow(in long aNumber);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/** Table Selection methods
|
|
|
|
* Selecting a row or column actually
|
|
|
|
* selects all cells (not TR in the case of rows)
|
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
void selectTableCell();
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/** Select a rectangular block of cells:
|
|
|
|
* all cells falling within the row/column index of aStartCell
|
|
|
|
* to through the row/column index of the aEndCell
|
|
|
|
* aStartCell can be any location relative to aEndCell,
|
|
|
|
* as long as they are in the same table
|
|
|
|
* @param aStartCell starting cell in block
|
|
|
|
* @param aEndCell ending cell in block
|
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
void selectBlockOfCells(in nsIDOMElement aStartCell,
|
|
|
|
in nsIDOMElement aEndCell);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
2002-03-15 01:11:14 +03:00
|
|
|
void selectTableRow();
|
|
|
|
void selectTableColumn();
|
|
|
|
void selectTable();
|
|
|
|
void selectAllTableCells();
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/** Create a new TD or TH element, the opposite type of the supplied aSourceCell
|
|
|
|
* 1. Copy all attributes from aSourceCell to the new cell
|
|
|
|
* 2. Move all contents of aSourceCell to the new cell
|
|
|
|
* 3. Replace aSourceCell in the table with the new cell
|
|
|
|
*
|
|
|
|
* @param aSourceCell The cell to be replaced
|
2002-03-15 01:11:14 +03:00
|
|
|
* @return The new cell that replaces aSourceCell
|
2001-03-28 03:11:08 +04:00
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
nsIDOMElement switchTableCellHeaderType(in nsIDOMElement aSourceCell);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/** 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
|
|
|
|
*
|
|
|
|
* @param aMergeNonContiguousContents:
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
* If there are no selected cells,
|
|
|
|
* and selection or caret is in a cell,
|
|
|
|
* that cell and the one to the right
|
|
|
|
* are merged
|
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
void joinTableCells(in boolean aMergeNonContiguousContents);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/** 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
|
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
void splitTableCell();
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/** 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 aTable 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
|
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
void normalizeTable(in nsIDOMElement aTable);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/** Get the row an column index from the layout's cellmap
|
|
|
|
* If aTable is null, it will try to find enclosing table of selection ancho
|
|
|
|
*
|
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
void getCellIndexes(in nsIDOMElement aCell,
|
|
|
|
out long aRowIndex, out long aColIndex);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/** Get the number of rows and columns in a table from the layout's cellmap
|
|
|
|
* If aTable 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)
|
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
void getTableSize(in nsIDOMElement aTable,
|
|
|
|
out long aRowCount, out long aColCount);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/** 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
|
|
|
|
*
|
|
|
|
* @param aTable A table in the document
|
|
|
|
* @param aRowIndex, aColIndex The 0-based cellmap indexes
|
|
|
|
*
|
2002-03-15 01:11:14 +03:00
|
|
|
* Returns NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found
|
|
|
|
* (passes NS_SUCCEEDED macro)
|
2001-03-28 03:11:08 +04:00
|
|
|
* You can scan for all cells in a row or column
|
|
|
|
* by iterating through the appropriate indexes
|
|
|
|
* until the returned aCell is null
|
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
nsIDOMElement getCellAt(in nsIDOMElement aTable,
|
|
|
|
in long aRowIndex, in long aColIndex);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/** 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 aStartRowIndex and aStartColIndex 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
|
|
|
|
*
|
|
|
|
* @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
|
|
|
|
*
|
|
|
|
* Returns NS_EDITOR_ELEMENT_NOT_FOUND if a cell is not found (passes NS_SUCCEEDED macro)
|
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
void getCellDataAt(in nsIDOMElement aTable,
|
|
|
|
in long aRowIndex, in long aColIndex,
|
|
|
|
out nsIDOMElement aCell,
|
|
|
|
out long aStartRowIndex, out long aStartColIndex,
|
|
|
|
out long aRowSpan, out long aColSpan,
|
|
|
|
out long aActualRowSpan, out long aActualColSpan,
|
|
|
|
out boolean aIsSelected);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/** Get the first row element in a table
|
|
|
|
*
|
2002-03-15 01:11:14 +03:00
|
|
|
* @return The row at the requested index
|
2001-03-28 03:11:08 +04:00
|
|
|
* Returns null if there are no rows in table
|
2002-03-15 01:11:14 +03:00
|
|
|
* Returns (to C++) NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found
|
|
|
|
* (passes NS_SUCCEEDED macro)
|
2001-03-28 03:11:08 +04:00
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
nsIDOMNode getFirstRow(in nsIDOMElement aTableElement);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/** Get the next row element starting the search from aTableElement
|
|
|
|
*
|
|
|
|
* @param aTableElement Any TR or child-of-TR element in the document
|
|
|
|
*
|
2002-03-15 01:11:14 +03:00
|
|
|
* @return The row to start search from
|
2001-03-28 03:11:08 +04:00
|
|
|
* and the row returned from the search
|
|
|
|
* Returns null if there isn't another row
|
2002-03-15 01:11:14 +03:00
|
|
|
* Returns (to C++) NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found
|
|
|
|
* (passes NS_SUCCEEDED macro)
|
2001-03-28 03:11:08 +04:00
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
nsIDOMNode getNextRow(in nsIDOMNode aTableElement);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/** Preferred direction to search for neighboring cell
|
|
|
|
* when trying to locate a cell to place caret in after
|
|
|
|
* a table editing action.
|
|
|
|
* Used for aDirection param in SetSelectionAfterTableEdit
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** Reset a selected cell or collapsed selection (the caret) after table editing
|
|
|
|
*
|
|
|
|
* @param aTable A table in the document
|
|
|
|
* @param aRow The row ...
|
|
|
|
* @param aCol ... and column defining the cell
|
|
|
|
* where we will try to place the caret
|
|
|
|
* @param aSelected If true, we select the whole cell instead of setting caret
|
|
|
|
* @param aDirection If cell at (aCol, aRow) 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.
|
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
void setSelectionAfterTableEdit(in nsIDOMElement aTable,
|
|
|
|
in long aRow, in long aCol,
|
|
|
|
in long aDirection, in boolean aSelected);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/** 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.
|
|
|
|
*
|
2002-03-15 01:11:14 +03:00
|
|
|
* @param aTableElement The table element (table, row, or cell) returned
|
|
|
|
* @param aTagName The tagname of returned element
|
|
|
|
* Note that "td" will be returned if name
|
|
|
|
* is actually "th"
|
|
|
|
* @return How many table elements were selected
|
|
|
|
* This tells us if we have multiple cells selected
|
|
|
|
* (0 if element is a parent cell of selection)
|
2001-03-28 03:11:08 +04:00
|
|
|
*
|
2002-03-15 01:11:14 +03:00
|
|
|
* Returns NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found
|
|
|
|
* (passes NS_SUCCEEDED macro)
|
2001-03-28 03:11:08 +04:00
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
long getSelectedOrParentTableElement(out nsIDOMElement aTableElement,
|
|
|
|
out AString aTagName);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/** Generally used after GetSelectedOrParentTableElement
|
|
|
|
* to test if selected cells are complete rows or columns
|
|
|
|
*
|
2002-03-15 01:11:14 +03:00
|
|
|
* @param aElement Any table or cell element or any element
|
|
|
|
* inside a table
|
2001-03-28 03:11:08 +04:00
|
|
|
* Used to get enclosing table.
|
|
|
|
* If null, selection's anchorNode is used
|
|
|
|
*
|
2002-03-15 01:11:14 +03:00
|
|
|
* @return
|
|
|
|
* 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
|
2001-03-28 03:11:08 +04:00
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
PRUint32 getSelectedCellsType(in nsIDOMElement aElement);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/** Get first selected element from first selection range.
|
|
|
|
* Assumes cell-selection model where each cell
|
|
|
|
* is in a separate range (selection parent node is table row)
|
2002-03-15 01:11:14 +03:00
|
|
|
* @param aCell [OUT] Selected cell or null if ranges don't contain
|
|
|
|
* cell selections
|
|
|
|
* @param aRange [OUT] Optional: if not null, return the selection range
|
2001-03-28 03:11:08 +04:00
|
|
|
* associated with the cell
|
2002-03-15 01:11:14 +03:00
|
|
|
* Returns NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found
|
|
|
|
* (passes NS_SUCCEEDED macro)
|
2001-03-28 03:11:08 +04:00
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
void getFirstSelectedCell(out nsIDOMElement aCell, out nsIDOMRange aRange);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/** Get first selected element from first selection range.
|
|
|
|
* Assumes cell-selection model where each cell
|
|
|
|
* is in a separate range (selection parent node is table row)
|
2002-03-15 01:11:14 +03:00
|
|
|
* @param aCell Selected cell or null if ranges don't contain
|
|
|
|
* cell selections
|
|
|
|
* @param aRowIndex Optional: if not null, return row index of 1st cell
|
|
|
|
* @param aColIndex Optional: if not null, return column index of 1st cell
|
2001-03-28 03:11:08 +04:00
|
|
|
*
|
2002-03-15 01:11:14 +03:00
|
|
|
* Returns NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found
|
|
|
|
* (passes NS_SUCCEEDED macro)
|
2001-03-28 03:11:08 +04:00
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
void getFirstSelectedCellInTable(out nsIDOMElement aCell,
|
|
|
|
out long aRowIndex, out long aColIndex);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/** 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
|
|
|
|
* @param aCell Selected cell or null if no more selected cells
|
|
|
|
* or ranges don't contain cell selections
|
|
|
|
* @param aRange Optional: if not null, return the selection range
|
|
|
|
* associated with the cell
|
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
void getNextSelectedCell(out nsIDOMElement aCell, out nsIDOMRange aRange);
|
2001-03-28 03:11:08 +04:00
|
|
|
};
|
|
|
|
|