зеркало из https://github.com/mozilla/gecko-dev.git
Added 'Split Cell' and fixed initialization of 'Join Cells' in table menu. Added stubs for 'Split Cell'
This commit is contained in:
Родитель
d9cf80630b
Коммит
7237e38781
|
@ -3581,6 +3581,25 @@ nsEditorShell::JoinTableCells()
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorShell::SplitTableCell()
|
||||
{
|
||||
nsresult result = NS_NOINTERFACE;
|
||||
switch (mEditorType)
|
||||
{
|
||||
case eHTMLTextEditorType:
|
||||
{
|
||||
nsCOMPtr<nsITableEditor> tableEditor = do_QueryInterface(mEditor);
|
||||
if (tableEditor)
|
||||
result = tableEditor->SplitTableCell();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
result = NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorShell::SelectTableCell()
|
||||
{
|
||||
|
|
|
@ -192,6 +192,7 @@ public:
|
|||
NS_IMETHOD SelectTable();
|
||||
NS_IMETHOD SelectAllTableCells();
|
||||
NS_IMETHOD JoinTableCells();
|
||||
NS_IMETHOD SplitTableCell();
|
||||
NS_IMETHOD NormalizeTable(nsIDOMElement *aTable);
|
||||
NS_IMETHOD GetCellIndexes(nsIDOMElement *aCell, PRInt32& aRowIndex, PRInt32& aColIndex);
|
||||
NS_IMETHOD GetTableSize(nsIDOMElement *aTable, PRInt32& aRowCount, PRInt32& aColCount);
|
||||
|
|
|
@ -636,6 +636,20 @@ nsHTMLEditorLog:: JoinTableCells()
|
|||
return nsHTMLEditor::JoinTableCells();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditorLog:: SplitTableCell()
|
||||
{
|
||||
nsAutoHTMLEditorLogLock logLock(this);
|
||||
|
||||
if (!mLocked && mFileSpec)
|
||||
{
|
||||
Write("window.editorShell.SplitTableCell();\n");
|
||||
Flush();
|
||||
}
|
||||
|
||||
return nsHTMLEditor::SplitTableCell();
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditorLog:: NormalizeTable(nsIDOMElement *aTable)
|
||||
|
|
|
@ -100,6 +100,7 @@ public:
|
|||
NS_IMETHOD DeleteTableColumn(PRInt32 aNumber);
|
||||
NS_IMETHOD DeleteTableRow(PRInt32 aNumber);
|
||||
NS_IMETHOD JoinTableCells();
|
||||
NS_IMETHOD SplitTableCell();
|
||||
NS_IMETHOD NormalizeTable(nsIDOMElement *aTable);
|
||||
|
||||
NS_IMETHOD StartLogging(nsIFileSpec *aLogFile);
|
||||
|
|
|
@ -1315,6 +1315,35 @@ nsHTMLEditor::SelectTableColumn()
|
|||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditor::SplitTableCell()
|
||||
{
|
||||
nsCOMPtr<nsIDOMElement> table;
|
||||
nsCOMPtr<nsIDOMElement> targetCell;
|
||||
PRInt32 startRowIndex, startColIndex, rowSpan, colSpan, actualRowSpan, actualColSpan;
|
||||
PRBool isSelected;
|
||||
nsCOMPtr<nsIDOMElement> cell2;
|
||||
PRInt32 startRowIndex2, startColIndex2, rowSpan2, colSpan2, actualRowSpan2, actualColSpan2;
|
||||
PRBool isSelected2;
|
||||
|
||||
// Get cell and table at selection anchor node (and other data)
|
||||
nsresult res = GetCellContext(nsnull,
|
||||
getter_AddRefs(table),
|
||||
getter_AddRefs(targetCell),
|
||||
nsnull, nsnull,
|
||||
&startRowIndex, &startColIndex);
|
||||
if (NS_FAILED(res)) return res;
|
||||
if(!table || !targetCell) return NS_EDITOR_ELEMENT_NOT_FOUND;
|
||||
|
||||
// We need rowspan and colspan data
|
||||
res = GetCellDataAt(table, startRowIndex, startColIndex, *getter_AddRefs(targetCell),
|
||||
startRowIndex, startColIndex, rowSpan, colSpan,
|
||||
actualRowSpan, actualColSpan, isSelected);
|
||||
|
||||
//TODO: FINISH THIS!
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditor::JoinTableCells()
|
||||
{
|
||||
|
@ -1358,7 +1387,7 @@ nsHTMLEditor::JoinTableCells()
|
|||
|
||||
if (firstCell)
|
||||
{
|
||||
// Merge selected cells
|
||||
// Merge selected cells into uppper-left-most cell
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -3581,6 +3581,25 @@ nsEditorShell::JoinTableCells()
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorShell::SplitTableCell()
|
||||
{
|
||||
nsresult result = NS_NOINTERFACE;
|
||||
switch (mEditorType)
|
||||
{
|
||||
case eHTMLTextEditorType:
|
||||
{
|
||||
nsCOMPtr<nsITableEditor> tableEditor = do_QueryInterface(mEditor);
|
||||
if (tableEditor)
|
||||
result = tableEditor->SplitTableCell();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
result = NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorShell::SelectTableCell()
|
||||
{
|
||||
|
|
|
@ -321,7 +321,31 @@ interface nsIEditorShell : nsISupports
|
|||
void DeleteTableCellContents();
|
||||
void DeleteTableRow(in PRInt32 number);
|
||||
void DeleteTableColumn(in PRInt32 number);
|
||||
/** 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
|
||||
* Non-adjacent cells are not deleted,
|
||||
* but their contents are still moved
|
||||
* to the upper-left cell
|
||||
* If there are no selected cells,
|
||||
* and selection or caret is in a cell,
|
||||
* that cell and the one to the right
|
||||
* are merged
|
||||
*/
|
||||
void JoinTableCells();
|
||||
|
||||
/** 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
|
||||
*/
|
||||
void SplitTableCell();
|
||||
|
||||
/** Table selection methods
|
||||
* Selecting a row or column actually
|
||||
* selects all cells (not TR in the case of rows)
|
||||
|
|
|
@ -192,6 +192,7 @@ public:
|
|||
NS_IMETHOD SelectTable();
|
||||
NS_IMETHOD SelectAllTableCells();
|
||||
NS_IMETHOD JoinTableCells();
|
||||
NS_IMETHOD SplitTableCell();
|
||||
NS_IMETHOD NormalizeTable(nsIDOMElement *aTable);
|
||||
NS_IMETHOD GetCellIndexes(nsIDOMElement *aCell, PRInt32& aRowIndex, PRInt32& aColIndex);
|
||||
NS_IMETHOD GetTableSize(nsIDOMElement *aTable, PRInt32& aRowCount, PRInt32& aColCount);
|
||||
|
|
|
@ -636,6 +636,20 @@ nsHTMLEditorLog:: JoinTableCells()
|
|||
return nsHTMLEditor::JoinTableCells();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditorLog:: SplitTableCell()
|
||||
{
|
||||
nsAutoHTMLEditorLogLock logLock(this);
|
||||
|
||||
if (!mLocked && mFileSpec)
|
||||
{
|
||||
Write("window.editorShell.SplitTableCell();\n");
|
||||
Flush();
|
||||
}
|
||||
|
||||
return nsHTMLEditor::SplitTableCell();
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditorLog:: NormalizeTable(nsIDOMElement *aTable)
|
||||
|
|
|
@ -100,6 +100,7 @@ public:
|
|||
NS_IMETHOD DeleteTableColumn(PRInt32 aNumber);
|
||||
NS_IMETHOD DeleteTableRow(PRInt32 aNumber);
|
||||
NS_IMETHOD JoinTableCells();
|
||||
NS_IMETHOD SplitTableCell();
|
||||
NS_IMETHOD NormalizeTable(nsIDOMElement *aTable);
|
||||
|
||||
NS_IMETHOD StartLogging(nsIFileSpec *aLogFile);
|
||||
|
|
|
@ -1315,6 +1315,35 @@ nsHTMLEditor::SelectTableColumn()
|
|||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditor::SplitTableCell()
|
||||
{
|
||||
nsCOMPtr<nsIDOMElement> table;
|
||||
nsCOMPtr<nsIDOMElement> targetCell;
|
||||
PRInt32 startRowIndex, startColIndex, rowSpan, colSpan, actualRowSpan, actualColSpan;
|
||||
PRBool isSelected;
|
||||
nsCOMPtr<nsIDOMElement> cell2;
|
||||
PRInt32 startRowIndex2, startColIndex2, rowSpan2, colSpan2, actualRowSpan2, actualColSpan2;
|
||||
PRBool isSelected2;
|
||||
|
||||
// Get cell and table at selection anchor node (and other data)
|
||||
nsresult res = GetCellContext(nsnull,
|
||||
getter_AddRefs(table),
|
||||
getter_AddRefs(targetCell),
|
||||
nsnull, nsnull,
|
||||
&startRowIndex, &startColIndex);
|
||||
if (NS_FAILED(res)) return res;
|
||||
if(!table || !targetCell) return NS_EDITOR_ELEMENT_NOT_FOUND;
|
||||
|
||||
// We need rowspan and colspan data
|
||||
res = GetCellDataAt(table, startRowIndex, startColIndex, *getter_AddRefs(targetCell),
|
||||
startRowIndex, startColIndex, rowSpan, colSpan,
|
||||
actualRowSpan, actualColSpan, isSelected);
|
||||
|
||||
//TODO: FINISH THIS!
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditor::JoinTableCells()
|
||||
{
|
||||
|
@ -1358,7 +1387,7 @@ nsHTMLEditor::JoinTableCells()
|
|||
|
||||
if (firstCell)
|
||||
{
|
||||
// Merge selected cells
|
||||
// Merge selected cells into uppper-left-most cell
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -100,15 +100,30 @@ public:
|
|||
NS_IMETHOD SelectTable()=0;
|
||||
NS_IMETHOD SelectAllTableCells()=0;
|
||||
|
||||
/** Join the contents of the selected cells into one cell,
|
||||
* expanding that cells ROWSPAN and COLSPAN to take up
|
||||
* the same number of cellmap locations as before.
|
||||
* Cells whose contents were moved are deleted.
|
||||
* If there's one cell selected or caret is in one cell,
|
||||
* it is joined with the cell to the right, if it exists
|
||||
/** 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
|
||||
* Non-adjacent cells are not deleted,
|
||||
* but their contents are still moved
|
||||
* to the upper-left cell
|
||||
* If there are no selected cells,
|
||||
* and selection or caret is in a cell,
|
||||
* that cell and the one to the right
|
||||
* are merged
|
||||
*/
|
||||
NS_IMETHOD JoinTableCells()=0;
|
||||
|
||||
/** 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
|
||||
*/
|
||||
NS_IMETHOD SplitTableCell()=0;
|
||||
|
||||
/** Scan through all rows and add cells as needed so
|
||||
* all locations in the cellmap are occupied.
|
||||
|
@ -286,6 +301,27 @@ public:
|
|||
* associated with the cell
|
||||
*/
|
||||
NS_IMETHOD GetNextSelectedCell(nsIDOMElement **aCell, nsIDOMRange **aRange)=0;
|
||||
|
||||
/** 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)
|
||||
* @param aCell Selected cell or null if ranges don't contain cell selections
|
||||
* @param aRange Optional: if not null, return the selection range
|
||||
* associated with the cell
|
||||
* Returns NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found (passes NS_SUCCEEDED macro)
|
||||
*/
|
||||
NS_IMETHOD GetFirstSelectedCell(nsIDOMElement **aCell, nsIDOMRange **aRange)=0;
|
||||
|
||||
/** 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
|
||||
*/
|
||||
NS_IMETHOD GetNextSelectedCell(nsIDOMElement **aCell, nsIDOMRange **aRange)=0;
|
||||
};
|
||||
|
||||
#endif // nsITableEditor_h__
|
||||
|
|
|
@ -1104,10 +1104,26 @@ function EditorInitFormatMenu()
|
|||
menuStr = menuStr.replace(/%obj%/,"").replace(/^\s+/, "");
|
||||
|
||||
}
|
||||
menuItem.setAttribute("value", menuStr)
|
||||
menuItem.setAttribute("value", menuStr);
|
||||
}
|
||||
}
|
||||
|
||||
function InitTableMenu()
|
||||
{
|
||||
// Change text on the "Join..." item depending if we
|
||||
// are joining selected cells or just cell to right
|
||||
// TODO: What to do about normal selection that crosses
|
||||
// table border? Try to figure out all cells
|
||||
// included in the selection?
|
||||
var menuText;
|
||||
if (editorShell.GetFirstSelectedCell())
|
||||
menuText = editorShell.GetString("JoinSelectedCells");
|
||||
else
|
||||
menuText = editorShell.GetString("JoinCellToRight");
|
||||
|
||||
document.getElementById("tableJoinCells").setAttribute("value",menuText);
|
||||
}
|
||||
|
||||
function EditorInitToolbars()
|
||||
{
|
||||
// Nothing to do now, but we might want some state updating here
|
||||
|
@ -1573,6 +1589,12 @@ function EditorJoinTableCells()
|
|||
contentWindow.focus();
|
||||
}
|
||||
|
||||
function EditorSplitTableCell()
|
||||
{
|
||||
editorShell.SplitTableCell();
|
||||
contentWindow.focus();
|
||||
}
|
||||
|
||||
function EditorDeleteTable()
|
||||
{
|
||||
editorShell.DeleteTable();
|
||||
|
|
|
@ -293,7 +293,6 @@
|
|||
<menuitem value="&compositionToolbarCmd.label;" accesskey="&compositiontb.accesskey;" observes="cmd_viewCompToolbar" />
|
||||
<menuitem value="&formattingToolbarCmd.label;" accesskey="&formattingtb.accesskey;" observes="cmd_viewFormatToolbar" />
|
||||
<menuitem value="&taskbarCmd.label;" accesskey="&taskbarCmd.accesskey;" observes="cmd_viewtaskbar" />
|
||||
|
||||
</menupopup>
|
||||
</menu>
|
||||
<menuitem id="showEditModeBar" value="&editmodeToolbarCmd.label;" accesskey="&editmodetb.accesskey;" observes="cmd_viewEditModeToolbar" />
|
||||
|
@ -595,7 +594,7 @@
|
|||
oncommand="goDoCommand('cmd_colorProperties')"/>
|
||||
|
||||
<menu id="tableMenu" value="&tableMenu.label;" accesskey="&tablemenu.accesskey;">
|
||||
<menupopup>
|
||||
<menupopup oncreate="InitTableMenu()">
|
||||
<menu id="tableSelectMenu" value="&tableSelectMenu.label;"
|
||||
accesskey="&tableselectmenu.accesskey;">
|
||||
<menupopup>
|
||||
|
@ -629,10 +628,10 @@
|
|||
</menupopup>
|
||||
</menu>
|
||||
<menuseparator />
|
||||
<menuitem id="tableFixupMenuitem" value="&tableFixup.label;" accesskey="&tablefixup.accesskey;" oncommand="EditorNormalizeTable()"/>
|
||||
<!-- menu text set in InitTableMenu -->
|
||||
<menuitem id="tableJoinCellsMenuitem" value="TEST Join" accesskey="&tablejoin.accesskey;" oncommand="EditorJoinTableCells()" oncreate="InitTableMenu()"/>
|
||||
<menuitem id="tablePropertiesMenuitem" value="&tableProperties.label;" accesskey="&properties.accesskey;" observes="cmd_editTable"/>
|
||||
<menuitem id="tableNormalizeTable" accesskey="&tablefixup.accesskey;" oncommand="EditorNormalizeTable()" value="&tableFixup.label;" />
|
||||
<menuitem id="tableJoinCells" accesskey="&tablejoincells.accesskey;" oncommand="EditorJoinTableCells()"/><!-- menu text set in InitTableMenu -->
|
||||
<menuitem id="tableSlitCell" accesskey="&tablesplitcell.accesskey;" oncommand="EditorSplitTableCell()" value="&tableSplitCell.label;" />
|
||||
<menuitem id="tableProperties" accesskey="&properties.accesskey;" observes="cmd_editTable" value="&tableProperties.label;" />
|
||||
</menupopup>
|
||||
</menu>
|
||||
|
||||
|
|
|
@ -97,6 +97,6 @@ NamedAnchor=Named Anchor
|
|||
Tag=Tag
|
||||
#Don't translate "%obj%" it will be replaced with one of above object nouns
|
||||
ObjectProperties=%obj% Properties...
|
||||
#Next 2 must contain the "tablejoin.accesskey" letter in editorOverlay.dtd
|
||||
#Next 2 must contain the "tablejoincells.accesskey" letter in editorOverlay.dtd
|
||||
JoinSelectedCells=Join Selected Cells
|
||||
JoinCellToRight=Join with Cell to the Right
|
||||
|
|
|
@ -490,7 +490,9 @@ Menu item text for "[Page|Table|Cell] Background color" is filled from
|
|||
("JoinSelectedCells" and "JoinCellToRight")
|
||||
the access key must exist in both of those strings
|
||||
-->
|
||||
<!ENTITY tablejoin.accesskey "j">
|
||||
<!ENTITY tablejoincells.accesskey "j">
|
||||
<!ENTITY tableSplitCell.label "Split cell">
|
||||
<!ENTITY tablesplitcell.accesskey "i">
|
||||
<!ENTITY tableProperties.label "Table Properties...">
|
||||
<!-- These may be shared in other menus -->
|
||||
<!ENTITY properties.label "Properties...">
|
||||
|
|
Загрузка…
Ссылка в новой задаче