Bug 454708 - storage-Legacy can throw when calling ConvertToUnicode. r=gavin
[wine-gecko.git] / editor / idl / nsITableEditor.idl
blob194806fca8831e6bd6f4e5490122116917ddabfc
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
24 * Alternatively, the contents of this file may be used under the terms of
25 * either of the GNU General Public License Version 2 or later (the "GPL"),
26 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
39 #include "nsISupports.idl"
41 interface nsIDOMNode;
42 interface nsIDOMElement;
43 interface nsIDOMRange;
45 [scriptable, uuid(4805e684-49b9-11d3-9ce4-ed60bd6cb5bc)]
47 interface nsITableEditor : nsISupports
49 const short eNoSearch = 0;
50 const short ePreviousColumn = 1;
51 const short ePreviousRow = 2;
53 /* ------------ Table editing Methods -------------- */
55 /** Insert table methods
56 * Insert relative to the selected cell or the
57 * cell enclosing the selection anchor
58 * The selection is collapsed and is left in the new cell
59 * at the same row,col location as the original anchor cell
61 * @param aNumber Number of items to insert
62 * @param aAfter If TRUE, insert after the current cell,
63 * else insert before current cell
65 void insertTableCell(in long aNumber, in boolean aAfter);
66 void insertTableColumn(in long aNumber, in boolean aAfter);
67 void insertTableRow(in long aNumber, in boolean aAfter);
69 /** Delete table methods
70 * Delete starting at the selected cell or the
71 * cell (or table) enclosing the selection anchor
72 * The selection is collapsed and is left in the
73 * cell at the same row,col location as
74 * the previous selection anchor, if possible,
75 * else in the closest neigboring cell
77 * @param aNumber Number of items to insert/delete
79 void deleteTable();
81 /** Delete just the cell contents
82 * This is what should happen when Delete key is used
83 * for selected cells, to minimize upsetting the table layout
85 void deleteTableCellContents();
87 /** Delete cell elements as well as contents
88 * @param aNumber Number of contiguous cells, rows, or columns
90 * When there are more than 1 selected cells, aNumber is ignored.
91 * For Delete Rows or Columns, the complete columns or rows are
92 * determined by the selected cells. E.g., to delete 2 complete rows,
93 * user simply selects a cell in each, and they don't
94 * have to be contiguous.
96 void deleteTableCell(in long aNumber);
97 void deleteTableColumn(in long aNumber);
98 void deleteTableRow(in long aNumber);
100 /** Table Selection methods
101 * Selecting a row or column actually
102 * selects all cells (not TR in the case of rows)
104 void selectTableCell();
106 /** Select a rectangular block of cells:
107 * all cells falling within the row/column index of aStartCell
108 * to through the row/column index of the aEndCell
109 * aStartCell can be any location relative to aEndCell,
110 * as long as they are in the same table
111 * @param aStartCell starting cell in block
112 * @param aEndCell ending cell in block
114 void selectBlockOfCells(in nsIDOMElement aStartCell,
115 in nsIDOMElement aEndCell);
117 void selectTableRow();
118 void selectTableColumn();
119 void selectTable();
120 void selectAllTableCells();
122 /** Create a new TD or TH element, the opposite type of the supplied aSourceCell
123 * 1. Copy all attributes from aSourceCell to the new cell
124 * 2. Move all contents of aSourceCell to the new cell
125 * 3. Replace aSourceCell in the table with the new cell
127 * @param aSourceCell The cell to be replaced
128 * @return The new cell that replaces aSourceCell
130 nsIDOMElement switchTableCellHeaderType(in nsIDOMElement aSourceCell);
132 /** Merges contents of all selected cells
133 * for selected cells that are adjacent,
134 * this will result in a larger cell with appropriate
135 * rowspan and colspan, and original cells are deleted
136 * The resulting cell is in the location of the
137 * cell at the upper-left corner of the adjacent
138 * block of selected cells
140 * @param aMergeNonContiguousContents:
141 * If true:
142 * Non-contiguous cells are not deleted,
143 * but their contents are still moved
144 * to the upper-left cell
145 * If false: contiguous cells are ignored
147 * If there are no selected cells,
148 * and selection or caret is in a cell,
149 * that cell and the one to the right
150 * are merged
152 void joinTableCells(in boolean aMergeNonContiguousContents);
154 /** Split a cell that has rowspan and/or colspan > 0
155 * into cells such that all new cells have
156 * rowspan = 1 and colspan = 1
157 * All of the contents are not touched --
158 * they will appear to be in the upper-left cell
160 void splitTableCell();
162 /** Scan through all rows and add cells as needed so
163 * all locations in the cellmap are occupied.
164 * Used after inserting single cells or pasting
165 * a collection of cells that extend past the
166 * previous size of the table
167 * If aTable is null, it uses table enclosing the selection anchor
168 * This doesn't doesn't change the selection,
169 * thus it can be used to fixup all tables
170 * in a page independant of the selection
172 void normalizeTable(in nsIDOMElement aTable);
174 /** Get the row an column index from the layout's cellmap
175 * If aCell is null, it will try to find enclosing table of selection anchor
178 void getCellIndexes(in nsIDOMElement aCell,
179 out long aRowIndex, out long aColIndex);
181 /** Get the number of rows and columns in a table from the layout's cellmap
182 * If aTable is null, it will try to find enclosing table of selection ancho
183 * Note that all rows in table will not have this many because of
184 * ROWSPAN effects or if table is not "rectangular" (has short rows)
186 void getTableSize(in nsIDOMElement aTable,
187 out long aRowCount, out long aColCount);
189 /** Get a cell element at cellmap grid coordinates
190 * A cell that spans across multiple cellmap locations will
191 * be returned multiple times, once for each location it occupies
193 * @param aTable A table in the document
194 * @param aRowIndex, aColIndex The 0-based cellmap indexes
196 * (in C++ returns: NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found
197 * passes NS_SUCCEEDED macro)
199 * You can scan for all cells in a row or column
200 * by iterating through the appropriate indexes
201 * until the returned aCell is null
203 nsIDOMElement getCellAt(in nsIDOMElement aTable,
204 in long aRowIndex, in long aColIndex);
206 /** Get a cell at cellmap grid coordinates and associated data
207 * A cell that spans across multiple cellmap locations will
208 * be returned multiple times, once for each location it occupies
209 * Examine the returned aStartRowIndex and aStartColIndex to see
210 * if it is in the same layout column or layout row:
211 * A "layout row" is all cells sharing the same top edge
212 * A "layout column" is all cells sharing the same left edge
213 * This is important to determine what to do when inserting or deleting a column or row
215 * @param aTable A table in the document
216 * @param aRowIndex, aColIndex The 0-based cellmap indexes
217 * returns values:
218 * @param aCell The cell at this cellmap location
219 * @param aStartRowIndex The row index where cell starts
220 * @param aStartColIndex The col index where cell starts
221 * @param aRowSpan May be 0 (to span down entire table) or number of cells spanned
222 * @param aColSpan May be 0 (to span across entire table) or number of cells spanned
223 * @param aActualRowSpan The actual number of cellmap locations (rows) spanned by the cell
224 * @param aActualColSpan The actual number of cellmap locations (columns) spanned by the cell
225 * @param aIsSelected
226 * @param
228 * (in C++ returns: NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found
229 * passes NS_SUCCEEDED macro)
231 void getCellDataAt(in nsIDOMElement aTable,
232 in long aRowIndex, in long aColIndex,
233 out nsIDOMElement aCell,
234 out long aStartRowIndex, out long aStartColIndex,
235 out long aRowSpan, out long aColSpan,
236 out long aActualRowSpan, out long aActualColSpan,
237 out boolean aIsSelected);
239 /** Get the first row element in a table
241 * @return The row at the requested index
242 * Returns null if there are no rows in table
243 * (in C++ returns: NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found
244 * passes NS_SUCCEEDED macro)
246 nsIDOMNode getFirstRow(in nsIDOMElement aTableElement);
248 /** Get the next row element starting the search from aTableElement
250 * @param aTableElement Any TR or child-of-TR element in the document
252 * @return The row to start search from
253 * and the row returned from the search
254 * Returns null if there isn't another row
255 * (in C++ returns: NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found
256 * passes NS_SUCCEEDED macro)
258 nsIDOMNode getNextRow(in nsIDOMNode aTableElement);
260 /** Preferred direction to search for neighboring cell
261 * when trying to locate a cell to place caret in after
262 * a table editing action.
263 * Used for aDirection param in SetSelectionAfterTableEdit
266 /** Reset a selected cell or collapsed selection (the caret) after table editing
268 * @param aTable A table in the document
269 * @param aRow The row ...
270 * @param aCol ... and column defining the cell
271 * where we will try to place the caret
272 * @param aSelected If true, we select the whole cell instead of setting caret
273 * @param aDirection If cell at (aCol, aRow) is not found,
274 * search for previous cell in the same
275 * column (aPreviousColumn) or row (ePreviousRow)
276 * or don't search for another cell (aNoSearch)
277 * If no cell is found, caret is place just before table;
278 * and if that fails, at beginning of document.
279 * Thus we generally don't worry about the return value
280 * and can use the nsSetSelectionAfterTableEdit stack-based
281 * object to insure we reset the caret in a table-editing method.
283 void setSelectionAfterTableEdit(in nsIDOMElement aTable,
284 in long aRow, in long aCol,
285 in long aDirection, in boolean aSelected);
287 /** Examine the current selection and find
288 * a selected TABLE, TD or TH, or TR element.
289 * or return the parent TD or TH if selection is inside a table cell
290 * Returns null if no table element is found.
292 * @param aTagName The tagname of returned element
293 * Note that "td" will be returned if name
294 * is actually "th"
295 * @param aCount How many table elements were selected
296 * This tells us if we have multiple cells selected
297 * (0 if element is a parent cell of selection)
298 * @return The table element (table, row, or first selected cell)
301 nsIDOMElement getSelectedOrParentTableElement(out AString aTagName, out long aCount);
303 /** Generally used after GetSelectedOrParentTableElement
304 * to test if selected cells are complete rows or columns
306 * @param aElement Any table or cell element or any element
307 * inside a table
308 * Used to get enclosing table.
309 * If null, selection's anchorNode is used
311 * @return
312 * 0 aCellElement was not a cell
313 * (returned result = NS_ERROR_FAILURE)
314 * TABLESELECTION_CELL There are 1 or more cells selected but
315 * complete rows or columns are not selected
316 * TABLESELECTION_ROW All cells are in 1 or more rows
317 * and in each row, all cells selected
318 * Note: This is the value if all rows
319 * (thus all cells) are selected
320 * TABLESELECTION_COLUMN All cells are in 1 or more columns
321 * and in each column, all cells are selected
323 PRUint32 getSelectedCellsType(in nsIDOMElement aElement);
325 /** Get first selected element from first selection range.
326 * (If multiple cells were selected this is the first in the order they were selected)
327 * Assumes cell-selection model where each cell
328 * is in a separate range (selection parent node is table row)
329 * @param aCell [OUT] Selected cell or null if ranges don't contain
330 * cell selections
331 * @param aRange [OUT] Optional: if not null, return the selection range
332 * associated with the cell
333 * Returns the DOM cell element
334 * (in C++: returns NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found
335 * passes NS_SUCCEEDED macro)
337 nsIDOMElement getFirstSelectedCell(out nsIDOMRange aRange);
339 /** Get first selected element in the table
340 * This is the upper-left-most selected cell in table,
341 * ignoring the order that the user selected them (order in the selection ranges)
342 * Assumes cell-selection model where each cell
343 * is in a separate range (selection parent node is table row)
344 * @param aCell Selected cell or null if ranges don't contain
345 * cell selections
346 * @param aRowIndex Optional: if not null, return row index of 1st cell
347 * @param aColIndex Optional: if not null, return column index of 1st cell
349 * Returns the DOM cell element
350 * (in C++: returns NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found
351 * passes NS_SUCCEEDED macro)
353 nsIDOMElement getFirstSelectedCellInTable(out long aRowIndex, out long aColIndex);
355 /** Get next selected cell element from first selection range.
356 * Assumes cell-selection model where each cell
357 * is in a separate range (selection parent node is table row)
358 * Always call GetFirstSelectedCell() to initialize stored index of "next" cell
359 * @param aCell Selected cell or null if no more selected cells
360 * or ranges don't contain cell selections
361 * @param aRange Optional: if not null, return the selection range
362 * associated with the cell
364 * Returns the DOM cell element
365 * (in C++: returns NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found
366 * passes NS_SUCCEEDED macro)
368 nsIDOMElement getNextSelectedCell(out nsIDOMRange aRange);