Table editing work (bug 20973). Fixed background colorpicker (bug 21410), disable unimplemented menu items (25137), make property bundle strings more localizable (26050). r=mjudge

This commit is contained in:
cmanske%netscape.com 2000-02-10 05:14:52 +00:00
Родитель 95a762e96a
Коммит afecaab477
34 изменённых файлов: 2904 добавлений и 248 удалений

Просмотреть файл

@ -45,7 +45,7 @@ CPPSRCS = \
ChangeAttributeTxn.cpp \
EditTxn.cpp \
EditAggregateTxn.cpp \
EditTable.cpp \
nsTableEditor.cpp \
InsertTextTxn.cpp \
PlaceholderTxn.cpp \
DeleteTextTxn.cpp \

Просмотреть файл

@ -52,7 +52,7 @@ CPPSRCS = \
TransactionFactory.cpp \
TypeInState.cpp \
nsHTMLEditor.cpp \
EditTable.cpp \
nsTableEditor.cpp \
nsInternetCiter.cpp \
nsAOLCiter.cpp \
nsInterfaceState.cpp \
@ -88,7 +88,7 @@ CPP_OBJS = \
.\$(OBJDIR)\TransactionFactory.obj \
.\$(OBJDIR)\TypeInState.obj \
.\$(OBJDIR)\nsHTMLEditor.obj \
.\$(OBJDIR)\EditTable.obj \
.\$(OBJDIR)\nsTableEditor.obj \
.\$(OBJDIR)\nsInternetCiter.obj \
.\$(OBJDIR)\nsAOLCiter.obj \
.\$(OBJDIR)\nsInterfaceState.obj \

Просмотреть файл

@ -106,6 +106,7 @@
static NS_DEFINE_CID(kCRangeCID, NS_RANGE_CID);
static NS_DEFINE_CID(kCContentIteratorCID, NS_CONTENTITERATOR_CID);
static NS_DEFINE_CID(kCDOMRangeCID, NS_RANGE_CID);
// transaction manager
static NS_DEFINE_CID(kCTransactionManagerCID, NS_TRANSACTIONMANAGER_CID);
@ -4949,3 +4950,100 @@ nsEditor::CreateTxnForDeleteInsertionPoint(nsIDOMRange *aRange,
return result;
}
nsresult
nsEditor::CreateRange(nsIDOMNode *aStartParent, PRInt32 aStartOffset,
nsIDOMNode *aEndParent, PRInt32 aEndOffset,
nsIDOMRange **aRange)
{
nsresult result;
result = nsComponentManager::CreateInstance(kCDOMRangeCID, nsnull,
NS_GET_IID(nsIDOMRange),
(void **)aRange);
if (NS_FAILED(result))
return result;
if (!*aRange)
return NS_ERROR_NULL_POINTER;
result = (*aRange)->SetStart(aStartParent, aStartOffset);
if (NS_SUCCEEDED(result))
result = (*aRange)->SetEnd(aEndParent, aEndOffset);
if (NS_FAILED(result))
{
NS_RELEASE((*aRange));
*aRange = 0;
}
return result;
}
nsresult
nsEditor::GetFirstNodeInRange(nsIDOMRange *aRange, nsIDOMNode **aNode)
{
if (!aRange || !aNode) return NS_ERROR_NULL_POINTER;
*aNode = nsnull;
nsCOMPtr<nsIDOMNode> startParent;
nsresult res = aRange->GetStartParent(getter_AddRefs(startParent));
if (NS_FAILED(res)) return res;
if (!startParent) return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMNode> startNode;
PRInt32 offset;
res = aRange->GetStartOffset(&offset);
if (NS_FAILED(res)) return res;
nsCOMPtr<nsIDOMNodeList> nodeList;
res = startParent->GetChildNodes(getter_AddRefs(nodeList));
if (NS_FAILED(res)) return res;
if (!nodeList) return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMNode> child;
res = nodeList->Item(offset,getter_AddRefs(child));
if (NS_FAILED(res)) return res;
if (!child) return NS_ERROR_FAILURE;
*aNode = child.get();
NS_ADDREF(*aNode);
return res;
}
nsresult
nsEditor::AppendNodeToSelectionAsRange(nsIDOMNode *aNode)
{
if (!aNode) return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIDOMSelection> selection;
nsresult res = GetSelection(getter_AddRefs(selection));
if (NS_FAILED(res)) return res;
if(!selection) return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMNode> parentNode;
res = aNode->GetParentNode(getter_AddRefs(parentNode));
if (NS_FAILED(res)) return res;
if (!parentNode) return NS_ERROR_NULL_POINTER;
PRInt32 offset;
res = GetChildOffset(aNode, parentNode, offset);
if (NS_FAILED(res)) return res;
nsCOMPtr<nsIDOMRange> range;
res = CreateRange(parentNode, offset, parentNode, offset+1, getter_AddRefs(range));
if (NS_FAILED(res)) return res;
if (!range) return NS_ERROR_NULL_POINTER;
return selection->AddRange(range);
}
nsresult nsEditor::ClearSelection()
{
nsCOMPtr<nsIDOMSelection> selection;
nsresult res = nsEditor::GetSelection(getter_AddRefs(selection));
if (NS_FAILED(res)) return res;
if (!selection) return NS_ERROR_FAILURE;
return selection->ClearSelection();
}

Просмотреть файл

@ -650,6 +650,19 @@ public:
static nsresult GetStartNodeAndOffset(nsIDOMSelection *aSelection, nsCOMPtr<nsIDOMNode> *outStartNode, PRInt32 *outStartOffset);
static nsresult GetEndNodeAndOffset(nsIDOMSelection *aSelection, nsCOMPtr<nsIDOMNode> *outEndNode, PRInt32 *outEndOffset);
// Helpers to add a node to the selection.
// Used by table cell selection methods
nsresult CreateRange(nsIDOMNode *aStartParent, PRInt32 aStartOffset,
nsIDOMNode *aEndParent, PRInt32 aEndOffset,
nsIDOMRange **aRange);
// Gets the node at the StartOffset of StartParent in aRange
// (this is a table cell in cell selection mode)
nsresult GetFirstNodeInRange(nsIDOMRange *aRange, nsIDOMNode **aNode);
// Creates a range with just the supplied node and appends that to the selection
nsresult AppendNodeToSelectionAsRange(nsIDOMNode *aNode);
// When you are using AppendNodeToSelectionAsRange, call this first to start a new selection
nsresult ClearSelection();
nsresult IsPreformatted(nsIDOMNode *aNode, PRBool *aResult);
nsresult IsNextCharWhitespace(nsIDOMNode *aParentNode,
PRInt32 aOffset,

Просмотреть файл

@ -1248,15 +1248,7 @@ nsEditorShell::CheckAndSaveDocument(const PRUnichar *reasonToSave, PRBool *_retv
nsAutoString tmp2 = GetString("DontSave");
nsAutoString title;
GetDocumentTitleString(title);
nsAutoString saveMsg = GetString("SaveFilePrompt")+" "+"\""+title+"\"";
if (ReasonToSave.Length() > 0)
{
saveMsg += " ";
saveMsg += ReasonToSave;
saveMsg += GetString("QuestionMark");
} else {
saveMsg += GetString("QuestionMark");
}
nsAutoString saveMsg = ((GetString("SaveFilePrompt")).ReplaceSubstring("%title%",title)).ReplaceSubstring("%reason%",ReasonToSave);
EConfirmResult result = ConfirmWithCancel(GetString("SaveDocument"), saveMsg,
&tmp1, &tmp2);
@ -3104,6 +3096,101 @@ nsEditorShell::JoinTableCells()
return result;
}
NS_IMETHODIMP
nsEditorShell::SelectTableCell()
{
nsresult result = NS_NOINTERFACE;
switch (mEditorType)
{
case eHTMLTextEditorType:
{
nsCOMPtr<nsITableEditor> tableEditor = do_QueryInterface(mEditor);
if (tableEditor)
result = tableEditor->SelectTableCell();
}
break;
default:
result = NS_ERROR_NOT_IMPLEMENTED;
}
return result;
}
NS_IMETHODIMP
nsEditorShell::SelectTableRow()
{
nsresult result = NS_NOINTERFACE;
switch (mEditorType)
{
case eHTMLTextEditorType:
{
nsCOMPtr<nsITableEditor> tableEditor = do_QueryInterface(mEditor);
if (tableEditor)
result = tableEditor->SelectTableRow();
}
break;
default:
result = NS_ERROR_NOT_IMPLEMENTED;
}
return result;
}
NS_IMETHODIMP
nsEditorShell::SelectTableColumn()
{
nsresult result = NS_NOINTERFACE;
switch (mEditorType)
{
case eHTMLTextEditorType:
{
nsCOMPtr<nsITableEditor> tableEditor = do_QueryInterface(mEditor);
if (tableEditor)
result = tableEditor->SelectTableColumn();
}
break;
default:
result = NS_ERROR_NOT_IMPLEMENTED;
}
return result;
}
NS_IMETHODIMP
nsEditorShell::SelectTable()
{
nsresult result = NS_NOINTERFACE;
switch (mEditorType)
{
case eHTMLTextEditorType:
{
nsCOMPtr<nsITableEditor> tableEditor = do_QueryInterface(mEditor);
if (tableEditor)
result = tableEditor->SelectTable();
}
break;
default:
result = NS_ERROR_NOT_IMPLEMENTED;
}
return result;
}
NS_IMETHODIMP
nsEditorShell::SelectAllTableCells()
{
nsresult result = NS_NOINTERFACE;
switch (mEditorType)
{
case eHTMLTextEditorType:
{
nsCOMPtr<nsITableEditor> tableEditor = do_QueryInterface(mEditor);
if (tableEditor)
result = tableEditor->SelectAllTableCells();
}
break;
default:
result = NS_ERROR_NOT_IMPLEMENTED;
}
return result;
}
NS_IMETHODIMP
nsEditorShell::NormalizeTable(nsIDOMElement *aTable)
{

Просмотреть файл

@ -2636,7 +2636,9 @@ NODE_FOUND:
NS_ADDREF(*aReturn);
}
}
return NS_OK;
else res = NS_EDITOR_ELEMENT_NOT_FOUND;
return res;
}
NS_IMETHODIMP
@ -2835,7 +2837,9 @@ nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aRetu
// Getters must addref
NS_ADDREF(*aReturn);
}
}
}
else res = NS_EDITOR_ELEMENT_NOT_FOUND;
return res;
}
@ -4990,7 +4994,7 @@ void nsHTMLEditor::ResetTextSelectionForRange(nsIDOMNode *aParent,
//================================================================
// HTML Editor methods
//
// Note: Table Editing methods are implemented in EditTable.cpp
// Note: Table Editing methods are implemented in nsTableEditor.cpp
//
NS_IMETHODIMP
@ -7375,6 +7379,19 @@ nsHTMLEditor::GetNextElementByTagName(nsIDOMElement *aCurrentElement,
return res;
}
NS_IMETHODIMP
nsHTMLEditor::SetSelectionAtDocumentStart(nsIDOMSelection *aSelection)
{
nsCOMPtr<nsIDOMElement> bodyElement;
nsresult res = GetBodyElement(getter_AddRefs(bodyElement));
if (NS_SUCCEEDED(res))
{
if (!bodyElement) return NS_ERROR_NULL_POINTER;
res = aSelection->Collapse(bodyElement,0);
}
return res;
}
#ifdef XP_MAC
#pragma mark -
#endif
@ -7739,4 +7756,3 @@ nsHTMLEditor::InsertContainerAbove(nsIDOMNode *inNode,
return NS_OK;
}

Просмотреть файл

@ -182,6 +182,11 @@ public:
NS_IMETHOD DeleteTableCellContents();
NS_IMETHOD DeleteTableColumn(PRInt32 aNumber);
NS_IMETHOD DeleteTableRow(PRInt32 aNumber);
NS_IMETHOD SelectTableCell();
NS_IMETHOD SelectTableRow();
NS_IMETHOD SelectTableColumn();
NS_IMETHOD SelectTable();
NS_IMETHOD SelectAllTableCells();
NS_IMETHOD JoinTableCells();
NS_IMETHOD NormalizeTable(nsIDOMElement *aTable);
NS_IMETHOD GetCellIndexes(nsIDOMElement *aCell, PRInt32& aRowIndex, PRInt32& aColIndex);
@ -321,7 +326,7 @@ protected:
NS_IMETHOD CreateBR(nsIDOMNode *aNode, PRInt32 aOffset, nsCOMPtr<nsIDOMNode> *outBRNode);
NS_IMETHOD InsertBR(nsCOMPtr<nsIDOMNode> *outBRNode);
// Table Editing (implemented in EditTable.cpp)
// Table Editing (implemented in nsTableEditor.cpp)
// Table utilities
@ -346,8 +351,15 @@ protected:
nsCOMPtr<nsIDOMNode> &aCellParent, PRInt32& aCellOffset,
PRInt32& aRow, PRInt32& aCol);
// Use the selection iterator to find the first cell in the selection
NS_IMETHOD GetFirstSelectedCell(nsCOMPtr<nsIDOMElement> &aCell);
// Finds the first selected cell in first range of selection
// This is in the *order of selection*, not order in the table
// (i.e., each cell added to selection is added in another range
// in the selection's rangelist, independent of location in table)
NS_IMETHOD GetFirstSelectedCell(nsIDOMElement **aCell);
// Fallback method: Call this after using ClearSelection() and you
// failed to set selection to some other content in the document
NS_IMETHOD SetSelectionAtDocumentStart(nsIDOMSelection *aSelection);
NS_IMETHOD ReParentContentOfNode(nsIDOMNode *aNode,
nsString &aParentTag,

Просмотреть файл

@ -504,6 +504,160 @@ nsHTMLEditorLog::SetBodyAttribute(const nsString& aAttr, const nsString& aValue)
return nsHTMLEditor::SetBodyAttribute(aAttr, aValue);
}
NS_IMETHODIMP
nsHTMLEditorLog:: InsertTableCell(PRInt32 aNumber, PRBool aAfter)
{
nsAutoHTMLEditorLogLock logLock(this);
if (!mLocked && mFileSpec)
{
Write("window.editorShell.InsertTableCell(\"");
Write("\");\n");
Flush();
}
return nsHTMLEditor::InsertTableCell(aNumber, aAfter);
}
NS_IMETHODIMP
nsHTMLEditorLog:: InsertTableColumn(PRInt32 aNumber, PRBool aAfter)
{
nsAutoHTMLEditorLogLock logLock(this);
if (!mLocked && mFileSpec)
{
Write("window.editorShell.InsertTableColumn(\"");
Write("\");\n");
Flush();
}
return nsHTMLEditor::InsertTableColumn(aNumber, aAfter);
}
NS_IMETHODIMP
nsHTMLEditorLog:: InsertTableRow(PRInt32 aNumber, PRBool aAfter)
{
nsAutoHTMLEditorLogLock logLock(this);
if (!mLocked && mFileSpec)
{
Write("window.editorShell.InsertTableRow(\"");
Write("\");\n");
Flush();
}
return nsHTMLEditor::InsertTableRow(aNumber, aAfter);
}
NS_IMETHODIMP
nsHTMLEditorLog:: DeleteTable()
{
nsAutoHTMLEditorLogLock logLock(this);
if (!mLocked && mFileSpec)
{
Write("window.editorShell.DeleteTable();\n");
Flush();
}
return nsHTMLEditor::DeleteTable();
}
NS_IMETHODIMP
nsHTMLEditorLog:: DeleteTableCell(PRInt32 aNumber)
{
nsAutoHTMLEditorLogLock logLock(this);
if (!mLocked && mFileSpec)
{
Write("window.editorShell.DeleteTableCell(\"");
Write("\");\n");
Flush();
}
return nsHTMLEditor::DeleteTableCell(aNumber);
}
NS_IMETHODIMP
nsHTMLEditorLog:: DeleteTableCellContents()
{
nsAutoHTMLEditorLogLock logLock(this);
if (!mLocked && mFileSpec)
{
Write("window.editorShell.DeleteTableCellContents();\n");
Flush();
}
return nsHTMLEditor::DeleteTableCellContents();
}
NS_IMETHODIMP
nsHTMLEditorLog:: DeleteTableColumn(PRInt32 aNumber)
{
nsAutoHTMLEditorLogLock logLock(this);
if (!mLocked && mFileSpec)
{
Write("window.editorShell.DeleteTableColumn(\"");
Write("\");\n");
Flush();
}
return nsHTMLEditor::DeleteTableColumn(aNumber);
}
NS_IMETHODIMP
nsHTMLEditorLog:: DeleteTableRow(PRInt32 aNumber)
{
nsAutoHTMLEditorLogLock logLock(this);
if (!mLocked && mFileSpec)
{
Write("window.editorShell.DeleteTableRow(\"");
Write("\");\n");
Flush();
}
return nsHTMLEditor::DeleteTableRow(aNumber);
}
NS_IMETHODIMP
nsHTMLEditorLog:: JoinTableCells()
{
nsAutoHTMLEditorLogLock logLock(this);
if (!mLocked && mFileSpec)
{
Write("window.editorShell.JoinTableCells();\n");
Flush();
}
return nsHTMLEditor::JoinTableCells();
}
NS_IMETHODIMP
nsHTMLEditorLog:: NormalizeTable(nsIDOMElement *aTable)
{
nsAutoHTMLEditorLogLock logLock(this);
if (!mLocked && mFileSpec)
{
Write("window.editorShell.NormalizeTable(\"");
Write("\");\n");
Flush();
}
return nsHTMLEditor::NormalizeTable(aTable);
}
NS_IMETHODIMP
nsHTMLEditorLog::MakeOrChangeList(const nsString& aListType)
{

Просмотреть файл

@ -93,6 +93,18 @@ public:
NS_IMETHOD Align(const nsString& aAlign);
NS_IMETHOD InsertElementAtSelection(nsIDOMElement* aElement, PRBool aDeleteSelection);
NS_IMETHOD InsertLinkAroundSelection(nsIDOMElement* aAnchorElement);
/* Table Editing */
NS_IMETHOD InsertTableCell(PRInt32 aNumber, PRBool aAfter);
NS_IMETHOD InsertTableColumn(PRInt32 aNumber, PRBool aAfter);
NS_IMETHOD InsertTableRow(PRInt32 aNumber, PRBool aAfter);
NS_IMETHOD DeleteTable();
NS_IMETHOD DeleteTableCell(PRInt32 aNumber);
NS_IMETHOD DeleteTableCellContents();
NS_IMETHOD DeleteTableColumn(PRInt32 aNumber);
NS_IMETHOD DeleteTableRow(PRInt32 aNumber);
NS_IMETHOD JoinTableCells();
NS_IMETHOD NormalizeTable(nsIDOMElement *aTable);
NS_IMETHOD StartLogging(nsIFileSpec *aLogFile);
NS_IMETHOD StopLogging();

Просмотреть файл

@ -171,6 +171,8 @@ nsHTMLEditor::InsertTableCell(PRInt32 aNumber, PRBool aAfter)
PRInt32 cellOffset, startRowIndex, startColIndex;
nsresult res = GetCellContext(selection, table, curCell, cellParent, cellOffset, startRowIndex, startColIndex);
if (NS_FAILED(res)) return res;
// Don't fail if no cell found
if (!curCell) return NS_EDITOR_ELEMENT_NOT_FOUND;
// Get more data for current cell in row we are inserting at (we need COLSPAN)
PRInt32 curStartRowIndex, curStartColIndex, rowSpan, colSpan, actualRowSpan, actualColSpan;
@ -337,6 +339,8 @@ nsHTMLEditor::InsertTableColumn(PRInt32 aNumber, PRBool aAfter)
PRInt32 cellOffset, startRowIndex, startColIndex;
nsresult res = GetCellContext(selection, table, curCell, cellParent, cellOffset, startRowIndex, startColIndex);
if (NS_FAILED(res)) return res;
// Don't fail if no cell found
if (!curCell) return NS_EDITOR_ELEMENT_NOT_FOUND;
// Get more data for current cell (we need ROWSPAN)
PRInt32 curStartRowIndex, curStartColIndex, rowSpan, colSpan, actualRowSpan, actualColSpan;
@ -448,6 +452,8 @@ nsHTMLEditor::InsertTableRow(PRInt32 aNumber, PRBool aAfter)
PRInt32 cellOffset, startRowIndex, startColIndex;
nsresult res = GetCellContext(selection, table, curCell, cellParent, cellOffset, startRowIndex, startColIndex);
if (NS_FAILED(res)) return res;
// Don't fail if no cell found
if (!curCell) return NS_EDITOR_ELEMENT_NOT_FOUND;
// Get more data for current cell in row we are inserting at (we need COLSPAN)
PRInt32 curStartRowIndex, curStartColIndex, rowSpan, colSpan, actualRowSpan, actualColSpan;
@ -642,7 +648,8 @@ nsHTMLEditor::DeleteTableCell(PRInt32 aNumber)
{
res = GetCellContext(selection, table, cell, cellParent, cellOffset, startRowIndex, startColIndex);
if (NS_FAILED(res)) return res;
if (!cell) return NS_ERROR_NULL_POINTER;
// Don't fail if no cell found
if (!cell) return NS_EDITOR_ELEMENT_NOT_FOUND;
if (1 == GetNumberOfCellsInRow(table, startRowIndex))
{
@ -695,8 +702,8 @@ nsHTMLEditor::DeleteTableCellContents()
res = GetCellContext(selection, table, cell, cellParent, cellOffset, startRowIndex, startColIndex);
if (NS_FAILED(res)) return res;
if (!cell) return NS_ERROR_NULL_POINTER;
// Don't fail if no cell found
if (!cell) return NS_EDITOR_ELEMENT_NOT_FOUND;
// We clear the selection to avoid problems when nodes in the selection are deleted,
selection->ClearSelection();
@ -740,7 +747,8 @@ nsHTMLEditor::DeleteTableColumn(PRInt32 aNumber)
res = GetCellContext(selection, table, cell, cellParent, cellOffset, startRowIndex, startColIndex);
if (NS_FAILED(res)) return res;
if(!cell) return NS_ERROR_NULL_POINTER;
// Don't fail if no cell found
if (!cell) return NS_EDITOR_ELEMENT_NOT_FOUND;
res = GetTableSize(table, rowCount, colCount);
if (NS_FAILED(res)) return res;
@ -856,7 +864,8 @@ nsHTMLEditor::DeleteTableRow(PRInt32 aNumber)
res = GetCellContext(selection, table, cell, cellParent, cellOffset, startRowIndex, startColIndex);
if (NS_FAILED(res)) return res;
if(!cell) return NS_ERROR_NULL_POINTER;
// Don't fail if no cell found
if (!cell) return NS_EDITOR_ELEMENT_NOT_FOUND;
res = GetTableSize(table, rowCount, colCount);
if (NS_FAILED(res)) return res;
@ -928,6 +937,69 @@ nsHTMLEditor::DeleteTableRow(PRInt32 aNumber)
return res;
}
NS_IMETHODIMP
nsHTMLEditor::SelectTable()
{
nsCOMPtr<nsIDOMElement> table;
nsresult res = NS_ERROR_FAILURE;
res = GetElementOrParentByTagName("table", nsnull, getter_AddRefs(table));
if (NS_FAILED(res)) return res;
// Don't fail if we didn't find a table
if (!table) return NS_OK;
nsCOMPtr<nsIDOMNode> tableNode = do_QueryInterface(table);
if (tableNode)
{
res = ClearSelection();
if (NS_SUCCEEDED(res))
res = AppendNodeToSelectionAsRange(table);
}
return res;
}
NS_IMETHODIMP
nsHTMLEditor::SelectTableCell()
{
nsCOMPtr<nsIDOMElement> cell;
nsresult res = NS_ERROR_FAILURE;
res = GetElementOrParentByTagName("td", nsnull, getter_AddRefs(cell));
if (NS_FAILED(res)) return res;
// Don't fail if we didn't find a table
if (!cell) return NS_EDITOR_ELEMENT_NOT_FOUND;
nsCOMPtr<nsIDOMNode> cellNode = do_QueryInterface(cell);
if (cellNode)
{
res = ClearSelection();
if (NS_SUCCEEDED(res))
res = AppendNodeToSelectionAsRange(cellNode);
}
return res;
}
NS_IMETHODIMP
nsHTMLEditor::SelectAllTableCells()
{
nsresult res = NS_OK;
return res;
}
NS_IMETHODIMP
nsHTMLEditor::SelectTableRow()
{
nsresult res = NS_OK;
return res;
}
NS_IMETHODIMP
nsHTMLEditor::SelectTableColumn()
{
nsresult res = NS_OK;
return res;
}
NS_IMETHODIMP
nsHTMLEditor::JoinTableCells()
{
@ -1275,11 +1347,14 @@ nsHTMLEditor::GetCellDataAt(nsIDOMElement* aTable, PRInt32 aRowIndex, PRInt32 aC
// Note that this returns NS_TABLELAYOUT_CELL_NOT_FOUND when
// the index(es) are out of bounds
return tableLayoutObject->GetCellDataAt(aRowIndex, aColIndex, aCell,
aStartRowIndex, aStartColIndex,
aRowSpan, aColSpan,
aActualRowSpan, aActualColSpan,
aIsSelected);
res = tableLayoutObject->GetCellDataAt(aRowIndex, aColIndex, aCell,
aStartRowIndex, aStartColIndex,
aRowSpan, aColSpan,
aActualRowSpan, aActualColSpan,
aIsSelected);
// Convert to editor's generic "not found" return value
if (res == NS_TABLELAYOUT_CELL_NOT_FOUND) res = NS_EDITOR_ELEMENT_NOT_FOUND;
return res;
}
// When all you want is the cell
@ -1304,7 +1379,7 @@ nsHTMLEditor::GetCellContext(nsCOMPtr<nsIDOMSelection> &aSelection,
if (!aSelection) return NS_ERROR_FAILURE;
// Find the first selected cell
res = GetFirstSelectedCell(aCell);
res = GetFirstSelectedCell(getter_AddRefs(aCell));
if (!aCell)
{
//If a cell wasn't selected, then assume the selection is INSIDE
@ -1338,15 +1413,18 @@ nsHTMLEditor::GetCellContext(nsCOMPtr<nsIDOMSelection> &aSelection,
}
NS_IMETHODIMP
nsHTMLEditor::GetFirstSelectedCell(nsCOMPtr<nsIDOMElement> &aCell)
nsHTMLEditor::GetFirstSelectedCell(nsIDOMElement **aCell)
{
if (!aCell) return NS_ERROR_NULL_POINTER;
*aCell = nsnull;
nsCOMPtr<nsIDOMSelection> selection;
nsresult res = nsEditor::GetSelection(getter_AddRefs(selection));
if (NS_FAILED(res)) return res;
if (!selection) return NS_ERROR_FAILURE;
// The most straight forward way of finding a selected cell
// is to use the selection iterator
//TODO: Replace this with code below new "table cell mode" flag is implemented
nsCOMPtr<nsIEnumerator> enumerator;
res = selection->GetEnumerator(getter_AddRefs(enumerator));
@ -1381,13 +1459,42 @@ nsHTMLEditor::GetFirstSelectedCell(nsCOMPtr<nsIDOMElement> &aCell)
atom.get() == nsIEditProperty::th )
{
// We found a cell
aCell = do_QueryInterface(content);
break;
nsCOMPtr<nsIDOMElement> cellElement = do_QueryInterface(content);
if (cellElement)
{
*aCell = cellElement.get();
NS_ADDREF(*aCell);
}
return NS_OK;
}
iter->Next();
}
}
return res;
return NS_EDITOR_ELEMENT_NOT_FOUND;
#if 0
//TODO: Do this only after checking the new "table cell mode" flag
// The first cell is the starting node in the first selection range
nsCOMPtr<nsIDOMRange> firstRange;
res = selection->GetRangeAt(0, getter_AddRefs(firstRange));
if (NS_FAILED(res)) return res;
if (!firstRange) return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMNode> cellNode;
res = GetFirstNodeInRange(firstRange, getter_AddRefs(cellNode));
if (NS_FAILED(res)) return res;
if (!cellNode) return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMElement> cellElement = do_QueryInterface(cellNode);
if (cellElement)
{
*aCell = cellElement.get();
NS_ADDREF(*aCell);
}
else res = NS_EDITOR_ELEMENT_NOT_FOUND;
return res;
#endif
}
NS_IMETHODIMP
@ -1468,17 +1575,10 @@ nsHTMLEditor::SetCaretAfterTableEdit(nsIDOMElement* aTable, PRInt32 aRow, PRInt3
{
if(NS_SUCCEEDED(GetChildOffset(aTable, tableParent, tableOffset)))
return selection->Collapse(tableParent, tableOffset);
// Still failing! Set selection to start of doc
nsCOMPtr<nsIDOMElement> bodyElement;
res = GetBodyElement(getter_AddRefs(bodyElement));
if (NS_SUCCEEDED(res))
{
if (!bodyElement) return NS_ERROR_NULL_POINTER;
res = selection->Collapse(bodyElement,0);
}
}
return res;
// Last resort: Set selection to start of doc
// (it's very bad to not have a valid selection!)
return SetSelectionAtDocumentStart(selection);
}
NS_IMETHODIMP
@ -1504,7 +1604,7 @@ nsHTMLEditor::GetSelectedOrParentTableElement(nsIDOMElement* &aTableElement, nsS
nsCOMPtr<nsIDOMElement> firstCell;
nsCOMPtr<nsIDOMElement> tableElement;
res = GetFirstSelectedCell(tableElement);
res = GetFirstSelectedCell(getter_AddRefs(tableElement));
if(NS_FAILED(res)) return res;
if (tableElement)
{

Просмотреть файл

@ -1248,15 +1248,7 @@ nsEditorShell::CheckAndSaveDocument(const PRUnichar *reasonToSave, PRBool *_retv
nsAutoString tmp2 = GetString("DontSave");
nsAutoString title;
GetDocumentTitleString(title);
nsAutoString saveMsg = GetString("SaveFilePrompt")+" "+"\""+title+"\"";
if (ReasonToSave.Length() > 0)
{
saveMsg += " ";
saveMsg += ReasonToSave;
saveMsg += GetString("QuestionMark");
} else {
saveMsg += GetString("QuestionMark");
}
nsAutoString saveMsg = ((GetString("SaveFilePrompt")).ReplaceSubstring("%title%",title)).ReplaceSubstring("%reason%",ReasonToSave);
EConfirmResult result = ConfirmWithCancel(GetString("SaveDocument"), saveMsg,
&tmp1, &tmp2);
@ -3104,6 +3096,101 @@ nsEditorShell::JoinTableCells()
return result;
}
NS_IMETHODIMP
nsEditorShell::SelectTableCell()
{
nsresult result = NS_NOINTERFACE;
switch (mEditorType)
{
case eHTMLTextEditorType:
{
nsCOMPtr<nsITableEditor> tableEditor = do_QueryInterface(mEditor);
if (tableEditor)
result = tableEditor->SelectTableCell();
}
break;
default:
result = NS_ERROR_NOT_IMPLEMENTED;
}
return result;
}
NS_IMETHODIMP
nsEditorShell::SelectTableRow()
{
nsresult result = NS_NOINTERFACE;
switch (mEditorType)
{
case eHTMLTextEditorType:
{
nsCOMPtr<nsITableEditor> tableEditor = do_QueryInterface(mEditor);
if (tableEditor)
result = tableEditor->SelectTableRow();
}
break;
default:
result = NS_ERROR_NOT_IMPLEMENTED;
}
return result;
}
NS_IMETHODIMP
nsEditorShell::SelectTableColumn()
{
nsresult result = NS_NOINTERFACE;
switch (mEditorType)
{
case eHTMLTextEditorType:
{
nsCOMPtr<nsITableEditor> tableEditor = do_QueryInterface(mEditor);
if (tableEditor)
result = tableEditor->SelectTableColumn();
}
break;
default:
result = NS_ERROR_NOT_IMPLEMENTED;
}
return result;
}
NS_IMETHODIMP
nsEditorShell::SelectTable()
{
nsresult result = NS_NOINTERFACE;
switch (mEditorType)
{
case eHTMLTextEditorType:
{
nsCOMPtr<nsITableEditor> tableEditor = do_QueryInterface(mEditor);
if (tableEditor)
result = tableEditor->SelectTable();
}
break;
default:
result = NS_ERROR_NOT_IMPLEMENTED;
}
return result;
}
NS_IMETHODIMP
nsEditorShell::SelectAllTableCells()
{
nsresult result = NS_NOINTERFACE;
switch (mEditorType)
{
case eHTMLTextEditorType:
{
nsCOMPtr<nsITableEditor> tableEditor = do_QueryInterface(mEditor);
if (tableEditor)
result = tableEditor->SelectAllTableCells();
}
break;
default:
result = NS_ERROR_NOT_IMPLEMENTED;
}
return result;
}
NS_IMETHODIMP
nsEditorShell::NormalizeTable(nsIDOMElement *aTable)
{

Просмотреть файл

@ -298,6 +298,15 @@ interface nsIEditorShell : nsISupports
void DeleteTableRow(in PRInt32 number);
void DeleteTableColumn(in PRInt32 number);
void JoinTableCells();
/** Table selection methods
* Selecting a row or column actually
* selects all cells (not TR in the case of rows)
*/
void SelectTableCell();
void SelectTableRow();
void SelectTableColumn();
void SelectTable();
void SelectAllTableCells();
/** Scan through all rows and add cells as needed so
* all locations in the cellmap are occupied.

Просмотреть файл

@ -106,6 +106,7 @@
static NS_DEFINE_CID(kCRangeCID, NS_RANGE_CID);
static NS_DEFINE_CID(kCContentIteratorCID, NS_CONTENTITERATOR_CID);
static NS_DEFINE_CID(kCDOMRangeCID, NS_RANGE_CID);
// transaction manager
static NS_DEFINE_CID(kCTransactionManagerCID, NS_TRANSACTIONMANAGER_CID);
@ -4949,3 +4950,100 @@ nsEditor::CreateTxnForDeleteInsertionPoint(nsIDOMRange *aRange,
return result;
}
nsresult
nsEditor::CreateRange(nsIDOMNode *aStartParent, PRInt32 aStartOffset,
nsIDOMNode *aEndParent, PRInt32 aEndOffset,
nsIDOMRange **aRange)
{
nsresult result;
result = nsComponentManager::CreateInstance(kCDOMRangeCID, nsnull,
NS_GET_IID(nsIDOMRange),
(void **)aRange);
if (NS_FAILED(result))
return result;
if (!*aRange)
return NS_ERROR_NULL_POINTER;
result = (*aRange)->SetStart(aStartParent, aStartOffset);
if (NS_SUCCEEDED(result))
result = (*aRange)->SetEnd(aEndParent, aEndOffset);
if (NS_FAILED(result))
{
NS_RELEASE((*aRange));
*aRange = 0;
}
return result;
}
nsresult
nsEditor::GetFirstNodeInRange(nsIDOMRange *aRange, nsIDOMNode **aNode)
{
if (!aRange || !aNode) return NS_ERROR_NULL_POINTER;
*aNode = nsnull;
nsCOMPtr<nsIDOMNode> startParent;
nsresult res = aRange->GetStartParent(getter_AddRefs(startParent));
if (NS_FAILED(res)) return res;
if (!startParent) return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMNode> startNode;
PRInt32 offset;
res = aRange->GetStartOffset(&offset);
if (NS_FAILED(res)) return res;
nsCOMPtr<nsIDOMNodeList> nodeList;
res = startParent->GetChildNodes(getter_AddRefs(nodeList));
if (NS_FAILED(res)) return res;
if (!nodeList) return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMNode> child;
res = nodeList->Item(offset,getter_AddRefs(child));
if (NS_FAILED(res)) return res;
if (!child) return NS_ERROR_FAILURE;
*aNode = child.get();
NS_ADDREF(*aNode);
return res;
}
nsresult
nsEditor::AppendNodeToSelectionAsRange(nsIDOMNode *aNode)
{
if (!aNode) return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIDOMSelection> selection;
nsresult res = GetSelection(getter_AddRefs(selection));
if (NS_FAILED(res)) return res;
if(!selection) return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMNode> parentNode;
res = aNode->GetParentNode(getter_AddRefs(parentNode));
if (NS_FAILED(res)) return res;
if (!parentNode) return NS_ERROR_NULL_POINTER;
PRInt32 offset;
res = GetChildOffset(aNode, parentNode, offset);
if (NS_FAILED(res)) return res;
nsCOMPtr<nsIDOMRange> range;
res = CreateRange(parentNode, offset, parentNode, offset+1, getter_AddRefs(range));
if (NS_FAILED(res)) return res;
if (!range) return NS_ERROR_NULL_POINTER;
return selection->AddRange(range);
}
nsresult nsEditor::ClearSelection()
{
nsCOMPtr<nsIDOMSelection> selection;
nsresult res = nsEditor::GetSelection(getter_AddRefs(selection));
if (NS_FAILED(res)) return res;
if (!selection) return NS_ERROR_FAILURE;
return selection->ClearSelection();
}

Просмотреть файл

@ -650,6 +650,19 @@ public:
static nsresult GetStartNodeAndOffset(nsIDOMSelection *aSelection, nsCOMPtr<nsIDOMNode> *outStartNode, PRInt32 *outStartOffset);
static nsresult GetEndNodeAndOffset(nsIDOMSelection *aSelection, nsCOMPtr<nsIDOMNode> *outEndNode, PRInt32 *outEndOffset);
// Helpers to add a node to the selection.
// Used by table cell selection methods
nsresult CreateRange(nsIDOMNode *aStartParent, PRInt32 aStartOffset,
nsIDOMNode *aEndParent, PRInt32 aEndOffset,
nsIDOMRange **aRange);
// Gets the node at the StartOffset of StartParent in aRange
// (this is a table cell in cell selection mode)
nsresult GetFirstNodeInRange(nsIDOMRange *aRange, nsIDOMNode **aNode);
// Creates a range with just the supplied node and appends that to the selection
nsresult AppendNodeToSelectionAsRange(nsIDOMNode *aNode);
// When you are using AppendNodeToSelectionAsRange, call this first to start a new selection
nsresult ClearSelection();
nsresult IsPreformatted(nsIDOMNode *aNode, PRBool *aResult);
nsresult IsNextCharWhitespace(nsIDOMNode *aParentNode,
PRInt32 aOffset,

Просмотреть файл

@ -2636,7 +2636,9 @@ NODE_FOUND:
NS_ADDREF(*aReturn);
}
}
return NS_OK;
else res = NS_EDITOR_ELEMENT_NOT_FOUND;
return res;
}
NS_IMETHODIMP
@ -2835,7 +2837,9 @@ nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aRetu
// Getters must addref
NS_ADDREF(*aReturn);
}
}
}
else res = NS_EDITOR_ELEMENT_NOT_FOUND;
return res;
}
@ -4990,7 +4994,7 @@ void nsHTMLEditor::ResetTextSelectionForRange(nsIDOMNode *aParent,
//================================================================
// HTML Editor methods
//
// Note: Table Editing methods are implemented in EditTable.cpp
// Note: Table Editing methods are implemented in nsTableEditor.cpp
//
NS_IMETHODIMP
@ -7375,6 +7379,19 @@ nsHTMLEditor::GetNextElementByTagName(nsIDOMElement *aCurrentElement,
return res;
}
NS_IMETHODIMP
nsHTMLEditor::SetSelectionAtDocumentStart(nsIDOMSelection *aSelection)
{
nsCOMPtr<nsIDOMElement> bodyElement;
nsresult res = GetBodyElement(getter_AddRefs(bodyElement));
if (NS_SUCCEEDED(res))
{
if (!bodyElement) return NS_ERROR_NULL_POINTER;
res = aSelection->Collapse(bodyElement,0);
}
return res;
}
#ifdef XP_MAC
#pragma mark -
#endif
@ -7739,4 +7756,3 @@ nsHTMLEditor::InsertContainerAbove(nsIDOMNode *inNode,
return NS_OK;
}

Просмотреть файл

@ -182,6 +182,11 @@ public:
NS_IMETHOD DeleteTableCellContents();
NS_IMETHOD DeleteTableColumn(PRInt32 aNumber);
NS_IMETHOD DeleteTableRow(PRInt32 aNumber);
NS_IMETHOD SelectTableCell();
NS_IMETHOD SelectTableRow();
NS_IMETHOD SelectTableColumn();
NS_IMETHOD SelectTable();
NS_IMETHOD SelectAllTableCells();
NS_IMETHOD JoinTableCells();
NS_IMETHOD NormalizeTable(nsIDOMElement *aTable);
NS_IMETHOD GetCellIndexes(nsIDOMElement *aCell, PRInt32& aRowIndex, PRInt32& aColIndex);
@ -321,7 +326,7 @@ protected:
NS_IMETHOD CreateBR(nsIDOMNode *aNode, PRInt32 aOffset, nsCOMPtr<nsIDOMNode> *outBRNode);
NS_IMETHOD InsertBR(nsCOMPtr<nsIDOMNode> *outBRNode);
// Table Editing (implemented in EditTable.cpp)
// Table Editing (implemented in nsTableEditor.cpp)
// Table utilities
@ -346,8 +351,15 @@ protected:
nsCOMPtr<nsIDOMNode> &aCellParent, PRInt32& aCellOffset,
PRInt32& aRow, PRInt32& aCol);
// Use the selection iterator to find the first cell in the selection
NS_IMETHOD GetFirstSelectedCell(nsCOMPtr<nsIDOMElement> &aCell);
// Finds the first selected cell in first range of selection
// This is in the *order of selection*, not order in the table
// (i.e., each cell added to selection is added in another range
// in the selection's rangelist, independent of location in table)
NS_IMETHOD GetFirstSelectedCell(nsIDOMElement **aCell);
// Fallback method: Call this after using ClearSelection() and you
// failed to set selection to some other content in the document
NS_IMETHOD SetSelectionAtDocumentStart(nsIDOMSelection *aSelection);
NS_IMETHOD ReParentContentOfNode(nsIDOMNode *aNode,
nsString &aParentTag,

Просмотреть файл

@ -504,6 +504,160 @@ nsHTMLEditorLog::SetBodyAttribute(const nsString& aAttr, const nsString& aValue)
return nsHTMLEditor::SetBodyAttribute(aAttr, aValue);
}
NS_IMETHODIMP
nsHTMLEditorLog:: InsertTableCell(PRInt32 aNumber, PRBool aAfter)
{
nsAutoHTMLEditorLogLock logLock(this);
if (!mLocked && mFileSpec)
{
Write("window.editorShell.InsertTableCell(\"");
Write("\");\n");
Flush();
}
return nsHTMLEditor::InsertTableCell(aNumber, aAfter);
}
NS_IMETHODIMP
nsHTMLEditorLog:: InsertTableColumn(PRInt32 aNumber, PRBool aAfter)
{
nsAutoHTMLEditorLogLock logLock(this);
if (!mLocked && mFileSpec)
{
Write("window.editorShell.InsertTableColumn(\"");
Write("\");\n");
Flush();
}
return nsHTMLEditor::InsertTableColumn(aNumber, aAfter);
}
NS_IMETHODIMP
nsHTMLEditorLog:: InsertTableRow(PRInt32 aNumber, PRBool aAfter)
{
nsAutoHTMLEditorLogLock logLock(this);
if (!mLocked && mFileSpec)
{
Write("window.editorShell.InsertTableRow(\"");
Write("\");\n");
Flush();
}
return nsHTMLEditor::InsertTableRow(aNumber, aAfter);
}
NS_IMETHODIMP
nsHTMLEditorLog:: DeleteTable()
{
nsAutoHTMLEditorLogLock logLock(this);
if (!mLocked && mFileSpec)
{
Write("window.editorShell.DeleteTable();\n");
Flush();
}
return nsHTMLEditor::DeleteTable();
}
NS_IMETHODIMP
nsHTMLEditorLog:: DeleteTableCell(PRInt32 aNumber)
{
nsAutoHTMLEditorLogLock logLock(this);
if (!mLocked && mFileSpec)
{
Write("window.editorShell.DeleteTableCell(\"");
Write("\");\n");
Flush();
}
return nsHTMLEditor::DeleteTableCell(aNumber);
}
NS_IMETHODIMP
nsHTMLEditorLog:: DeleteTableCellContents()
{
nsAutoHTMLEditorLogLock logLock(this);
if (!mLocked && mFileSpec)
{
Write("window.editorShell.DeleteTableCellContents();\n");
Flush();
}
return nsHTMLEditor::DeleteTableCellContents();
}
NS_IMETHODIMP
nsHTMLEditorLog:: DeleteTableColumn(PRInt32 aNumber)
{
nsAutoHTMLEditorLogLock logLock(this);
if (!mLocked && mFileSpec)
{
Write("window.editorShell.DeleteTableColumn(\"");
Write("\");\n");
Flush();
}
return nsHTMLEditor::DeleteTableColumn(aNumber);
}
NS_IMETHODIMP
nsHTMLEditorLog:: DeleteTableRow(PRInt32 aNumber)
{
nsAutoHTMLEditorLogLock logLock(this);
if (!mLocked && mFileSpec)
{
Write("window.editorShell.DeleteTableRow(\"");
Write("\");\n");
Flush();
}
return nsHTMLEditor::DeleteTableRow(aNumber);
}
NS_IMETHODIMP
nsHTMLEditorLog:: JoinTableCells()
{
nsAutoHTMLEditorLogLock logLock(this);
if (!mLocked && mFileSpec)
{
Write("window.editorShell.JoinTableCells();\n");
Flush();
}
return nsHTMLEditor::JoinTableCells();
}
NS_IMETHODIMP
nsHTMLEditorLog:: NormalizeTable(nsIDOMElement *aTable)
{
nsAutoHTMLEditorLogLock logLock(this);
if (!mLocked && mFileSpec)
{
Write("window.editorShell.NormalizeTable(\"");
Write("\");\n");
Flush();
}
return nsHTMLEditor::NormalizeTable(aTable);
}
NS_IMETHODIMP
nsHTMLEditorLog::MakeOrChangeList(const nsString& aListType)
{

Просмотреть файл

@ -93,6 +93,18 @@ public:
NS_IMETHOD Align(const nsString& aAlign);
NS_IMETHOD InsertElementAtSelection(nsIDOMElement* aElement, PRBool aDeleteSelection);
NS_IMETHOD InsertLinkAroundSelection(nsIDOMElement* aAnchorElement);
/* Table Editing */
NS_IMETHOD InsertTableCell(PRInt32 aNumber, PRBool aAfter);
NS_IMETHOD InsertTableColumn(PRInt32 aNumber, PRBool aAfter);
NS_IMETHOD InsertTableRow(PRInt32 aNumber, PRBool aAfter);
NS_IMETHOD DeleteTable();
NS_IMETHOD DeleteTableCell(PRInt32 aNumber);
NS_IMETHOD DeleteTableCellContents();
NS_IMETHOD DeleteTableColumn(PRInt32 aNumber);
NS_IMETHOD DeleteTableRow(PRInt32 aNumber);
NS_IMETHOD JoinTableCells();
NS_IMETHOD NormalizeTable(nsIDOMElement *aTable);
NS_IMETHOD StartLogging(nsIFileSpec *aLogFile);
NS_IMETHOD StopLogging();

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -30,6 +30,8 @@
0x4805e683, 0x49b9, 0x11d3, \
{ 0x9c, 0xe4, 0xed, 0x60, 0xbd, 0x6c, 0xb5, 0xbc } }
#define NS_EDITOR_ELEMENT_NOT_FOUND \
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_EDITOR, 1)
class nsString;
class nsStringArray;
@ -297,6 +299,7 @@ public:
*
* @param aNode The node in the document to start the search
* If it is null, the anchor node of the current selection is used
* Returns NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found (passes NS_SUCCEEDED macro)
*/
NS_IMETHOD GetElementOrParentByTagName(const nsString& aTagName, nsIDOMNode *aNode, nsIDOMElement** aReturn)=0;
@ -314,6 +317,7 @@ public:
* (an "A" tag with the "href" attribute set)
* Use "anchor" or "namedanchor" to get a named anchor node
* (an "A" tag with the "name" attribute set)
* Returns NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found (passes NS_SUCCEEDED macro)
*/
NS_IMETHOD GetSelectedElement(const nsString& aTagName, nsIDOMElement** aReturn)=0;

Просмотреть файл

@ -77,6 +77,16 @@ public:
NS_IMETHOD DeleteTableColumn(PRInt32 aNumber)=0;
NS_IMETHOD DeleteTableRow(PRInt32 aNumber)=0;
/** Table Selection methods
* Selecting a row or column actually
* selects all cells (not TR in the case of rows)
*/
NS_IMETHOD SelectTableCell()=0;
NS_IMETHOD SelectTableRow()=0;
NS_IMETHOD SelectTableColumn()=0;
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.
@ -119,10 +129,8 @@ public:
* @param aTable A table in the document
* @param aRowIndex, aColIndex The 0-based cellmap indexes
*
* Note that this returns NS_TABLELAYOUT_CELL_NOT_FOUND
* when a cell is not found at the given indexes,
* but this passes the NS_SUCCEEDED() test,
* so you can scan for all cells in a row or column
* 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 aCell is null
*/
@ -150,8 +158,7 @@ public:
* @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())
* Returns NS_EDITOR_ELEMENT_NOT_FOUND if a cell is not found (passes NS_SUCCEEDED macro)
*/
NS_IMETHOD GetCellDataAt(nsIDOMElement* aTable, PRInt32 aRowIndex, PRInt32 aColIndex, nsIDOMElement* &aCell,
PRInt32& aStartRowIndex, PRInt32& aStartColIndex,
@ -167,6 +174,7 @@ public:
* Returns:
* @param aRow The row at the requested index
* Returns null if there are no rows in table
* Returns NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found (passes NS_SUCCEEDED macro)
*/
NS_IMETHOD GetFirstRow(nsIDOMElement* aTableElement, nsIDOMElement* &aRow)=0;
@ -178,6 +186,7 @@ public:
* @param aRow The row to start search from
* and the row returned from the search
* Returns null if there isn't another row
* Returns NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found (passes NS_SUCCEEDED macro)
*/
NS_IMETHOD GetNextRow(nsIDOMElement* aTableElement, nsIDOMElement* &aRow)=0;
@ -219,6 +228,7 @@ public:
* Note that "td" will be returned if name is actually "th"
* @param aIsSelected Tells if element returned is a selected element
* (false if element is a parent cell of selection)
* Returns NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found (passes NS_SUCCEEDED macro)
*/
NS_IMETHOD GetSelectedOrParentTableElement(nsIDOMElement* &aTableElement, nsString& aTagName, PRBool &aIsSelected)=0;

Просмотреть файл

@ -27,7 +27,9 @@
var editorShell;
var documentModified;
var prefAuthorString = "";
var EditorDisplayMode = 0; // Normal Editor mode
var WebCompose = false; // Set true for Web Composer, leave false for Messenger Composer
// These must be kept in synch with the XUL <options> lists
var gParagraphTagNames = new Array("","P","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","ADDRESS","PRE","DT","DD");
@ -49,6 +51,14 @@ function EditorOnLoad() {
}
// Continue with normal startup.
EditorStartup( 'html', document.getElementById("content-frame"));
// Active menu items that are initially hidden in XUL
// because they are not needed by Messenger Composer
var styleMenu = document.getElementById("stylesheetMenu")
if (styleMenu)
styleMenu.removeAttribute("hidden");
WebCompose = true;
window.tryToClose = EditorClose;
}
@ -67,9 +77,12 @@ function TextEditorOnLoad() {
var DocumentStateListener =
{
NotifyDocumentCreated: function()
{
EditorSetDefaultPrefs();
},
{
EditorSetDefaultPrefs();
// Call EditorSetDefaultPrefs first
// so it gets the default author before initing toolbars
EditorInitToolbars();
},
NotifyDocumentWillBeDestroyed: function() {},
NotifyDocumentStateChanged:function( isNowDirty ) {}
};
@ -79,11 +92,6 @@ function EditorStartup(editorType, editorElement)
dump("Doing Editor Startup...\n");
contentWindow = window.content;
// set up event listeners
window.addEventListener("load", EditorDocumentLoaded, true, false);
dump("Trying to make an Editor Shell through the component manager...\n");
// store the editor shell in the window, so that child windows can get to it.
var editorShell = window.editorShell = editorElement.editorShell;
@ -278,8 +286,13 @@ function EditorOpen()
filePicker = filePicker.QueryInterface(Components.interfaces.nsIFileSpecWithUI);
/* doesn't handle *.shtml files */
filePicker.chooseInputFile(editorShell.GetString("OpenHTMLFile"), filePicker.eHTMLFiles+filePicker.eTextFiles+filePicker.eAllFiles, 0, 0);
/* need to handle cancel (uncaught exception at present) */
try {
filePicker.chooseInputFile(editorShell.GetString("OpenHTMLFile"), filePicker.eHTMLFiles+filePicker.eTextFiles+filePicker.eAllFiles, 0, 0);
/* need to handle cancel (uncaught exception at present) */
}
catch (ex) {
dump("filePicker.chooseInputFile threw an exception\n");
}
/* check for already open window and activate it... */
var found = FindAndSelectEditorWindowWithURL(filePicker.URLString);
@ -927,20 +940,46 @@ function EditorSetDisplayStyle(mode)
{
EditorDisplayMode = mode;
editorShell.SetDisplayMode(mode);
editButton = document.getElementById("EditModeButton");
browserButton = document.getElementById("BrowserModeButton");
var editButton = document.getElementById("EditModeButton");
var browserButton = document.getElementById("BrowserModeButton");
var showMenu = document.getElementById("ShowExtraMarkup");
var hideMenu = document.getElementById("HideExtraMarkup");
var editSelected = 0;
var browserSelected = 0;
if (mode == 0) editSelected = 1;
if (mode == 1) browserSelected = 1;
dump(editButton+browserButton+" Display mode: EditSelected="+editSelected+" BrowserSelected="+browserSelected+"\n");
if (mode == 0)
{
editSelected = 1;
showMenu.setAttribute("hidden","true");
hideMenu.removeAttribute("hidden");
}
if (mode == 1)
{
browserSelected = 1;
showMenu.removeAttribute("hidden");
hideMenu.setAttribute("hidden","true");
}
editButton.setAttribute("selected",Number(editSelected));
browserButton.setAttribute("selected",Number(browserSelected));
contentWindow.focus();
}
function EditorPreview()
{
contentWindow.focus();
}
function EditorPrintSetup()
{
// Old code? Browser no longer is doing this
//window.openDialog("resource:/res/samples/printsetup.html", "_blank", "chrome,close,titlebar", "");
_EditorNotImplemented();
contentWindow.focus();
}
function EditorPrintPreview()
{
window.openDialog("resource:/res/samples/printsetup.html", "_blank", "chrome,close,titlebar", "");
_EditorNotImplemented();
contentWindow.focus();
}
@ -977,11 +1016,80 @@ function CheckSpelling()
contentWindow.focus();
}
function OnCreateAlignmentPopup()
function EditorInitEditMenu()
{
dump("Creating Alignment popup window\n");
}
}
function EditorInitFormatMenu()
{
var propertiesMenu = document.getElementById("objectProperties");
if (propertiesMenu)
{
var element = editorShell.GetSelectedElement("");
dump("EditorObjectProperties: element="+element+"\n");
if (element)
{
dump("TagName="+element.nodeName+"\n");
if (element.nodeName)
{
propertiesMenu.removeAttribute("hidden");
var objStr;
var menuStr = editorShell.GetString("ObjectProperties");
switch (element.nodeName)
{
case 'IMG':
objStr = "Image";
break;
case 'HR':
objStr = "H.Line";
break;
case 'TABLE':
objStr = "Table";
break;
case 'A':
if(element.href)
{
objStr = "Link";
EditorInsertOrEditLink();
} else if (element.name)
{
objStr = "Named Anchor";
EditorInsertOrEditNamedAnchor();
}
break;
}
menuStr = menuStr.replace(/%obj%/,objStr);
propertiesMenu.setAttribute("value", menuStr)
} else {
propertiesMenu.setAttribute("hidden","true");
}
}
}
dump("Calling EditorInitViewMenu()\n");
}
function EditorInitToolbars()
{
// Set title edit field
var domdoc;
try { domdoc = window.editorShell.editorDocument; } catch (e) { dump( e + "\n"); }
if ( !domdoc )
{
dump("EditorInitToolbars: EDITOR DOCUMENT NOT FOUND\n");
return;
}
var title = domdoc.title;
var titleInput = document.getElementById("PageTitleInput");
if (!title) title = "";
titleInput.setAttribute("value", title);
var authorInput = document.getElementById("AuthorInput");
if (authorInput)
{
}
}
function EditorSetDefaultPrefs()
{
/* only set defaults for new documents */
@ -992,7 +1100,10 @@ function EditorSetDefaultPrefs()
var domdoc;
try { domdoc = window.editorShell.editorDocument; } catch (e) { dump( e + "\n"); }
if ( !domdoc )
{
dump("EditorSetDefaultPrefs: EDITOR DOCUMENT NOT FOUND\n");
return;
}
// try to get preferences service
var prefs = null;
@ -1011,7 +1122,7 @@ function EditorSetDefaultPrefs()
// if not, create one and make it a child of the head tag
// and set its content attribute to the value of the editor.author preference.
var prefAuthorString = prefs.CopyCharPref("editor.author");
prefAuthorString = prefs.CopyCharPref("editor.author");
if ( prefAuthorString && prefAuthorString != 0)
{
var nodelist = domdoc.getElementsByTagName("meta");
@ -1123,18 +1234,6 @@ function AddAttrToElem(dom, attr_name, attr_value, elem)
}
}
function EditorDocumentLoaded()
{
dump("The document was loaded in the content area\n");
//window.addEventListener("keyup", EditorReflectDocState, true, false); // post process, no capture
//window.addEventListener("dblclick", EditorDoDoubleClick, true, false);
documentModified = (window.editorShell.documentStatus != 0);
return true;
}
function UpdateSaveButton(modified)
{
var saveButton = document.getElementById("saveButton");
@ -1315,91 +1414,33 @@ function EditorInsertOrEditTable(insertAllowed)
}
}
function GetChildOffset(parent,child)
{
if (!parent || !child)
return null;
var nodeList = parent.childNodes;
var i;
if (nodeList)
{
for ( i = 0; i<nodeList.length; i++)
{
if (nodeList.item(i) == child)
return i;
}
}
return null;
}
function AppendNodeToSelection(selection, node)
{
if (selection && node)
{
var parent = node.parentNode;
var offset = GetChildOffset(parent,node);
if (offset)
{
var range = editorShell.editorDocument.createRange();
if (range)
{
range.setStart(parent,offset);
range.setEnd(parent,offset+1);
selection.addRange(range);
}
}
}
}
function EditorSelectTableCell()
{
var selection = editorShell.editorSelection;
if (selection)
{
var cellNode = editorShell.GetElementOrParentByTagName("td",selection.anchorNode);
if (cellNode)
{
selection.clearSelection();
AppendNodeToSelection(selection, cellNode);
}
}
editorShell.SelectTableCell();
contentWindow.focus();
}
function EditorSelectAllTableCells()
{
editorShell.SelectAllTableCells();
contentWindow.focus();
}
function EditorSelectTable()
{
var selection = editorShell.editorSelection;
if (selection)
{
var tableNode = editorShell.GetElementOrParentByTagName("table",selection.anchorNode);
if (tableNode)
{
selection.clearSelection();
AppendNodeToSelection(selection, tableNode);
}
}
editorShell.SelectTableCell();
contentWindow.focus();
}
function EditorSelectTableRow()
{
var tagNameObj = new Object();
var isSelectedObj = new Object();
var tagName;
var isSelected;
var tableElement = editorShell.GetSelectedOrParentTableElement(tagNameObj,isSelectedObj);
tagName = tagNameObj.value;
isSelected = isSelectedObj.value;
dump("Table element="+tableElement+" Tagname="+tagName+" IsSelected="+isSelected+"\n");
//TODO: FINISH THIS!
editorShell.SelectTableRow();
contentWindow.focus();
}
function EditorSelectTableColumn()
{
//TODO: FINISH THIS!
editorShell.SelectTableColumn();
contentWindow.focus();
}
@ -1474,3 +1515,4 @@ function EditorDeleteTableCellContents()
editorShell.DeleteTableCellContents();
contentWindow.focus();
}

Просмотреть файл

@ -74,14 +74,16 @@
<menubar id="main-menubar" chromeclass="menubar">
<menu id="fileMenu"/>
<menu id="editMenu"/>
<menu id="editMenu" oncreate="EditorInitEditMenu()"/>
<menu value="&viewMenu.label;" accesskey="&viewmenu.accesskey;">
<!-- id pulls in "Show Sidebar" item from sidebarOverlay -->
<menupopup id="menu_View_Popup">
<menu id="viewToolbar"/>
<menuseparator/>
<!-- item with "disable=true" will be hidden -->
<menuitem id="ShowExtraMarkup" value="&showExtraMarkup.label;" accesskey="&extraMarkup.accesskey;" oncommand="EditorSetDisplayStyle(0)" hidden="true"/>
<menuitem id="HideExtraMarkup" value="&hideExtraMarkup.label;" accesskey="&extraMarkup.accesskey;" oncommand="EditorSetDisplayStyle(1)"/>
<menuitem id="viewSourceMenuitem"/>
<menuseparator />
<menu id="charsetMenu"/>
@ -97,7 +99,8 @@
<menu id="formatMenu" value="&formatMenu.label;" accesskey="&formatmenu.accesskey;">
<menupopup id="formatMenuPopup">
<!-- Property items that are only in web composer -->
<menuitem id="objectProperties" hidden="true"/>
<menuitem id="colorsAndBackground"/>
<menuitem id="pageProperties"/>
</menupopup>
</menu>
@ -124,11 +127,10 @@
<titledbutton id="newButton"/>
<titledbutton id="openButton"/>
<titledbutton id="saveButton"/>
<toolbarseparator/>
<titledbutton id="printButton"/>
<titledbutton id="previewButton"/>
<titledbutton id="printButton" />
<titledbutton id="findButton"/>
<titledbutton id="spellingButton"/>
<toolbarseparator/>
<titledbutton id="imageButton"/>
<titledbutton id="hlineButton"/>
<titledbutton id="tableButton"/>
@ -143,6 +145,21 @@
</box>
</toolbar>
<toolbar id="TitleToolbar" persist="collapsed">
<box align="vertical">
<spring flex="1"/>
<html:label>Title:</html:label>
<spring flex="1"/>
</box>
<html:input type="text" id="PageTitleInput" flex="70%"/>
<box align="vertical">
<spring flex="3"/>
<html:label>Author:</html:label>
<spring flex="2"/>
</box>
<html:input type="text" id="PageAuthorInput" flex="30%"/>
<spring class="spacer-throbber" flex="5%"/>
</toolbar>
<toolbar id="FormatToolbar" persist="collapsed">
<html:div>
<!-- items are filled out from editorOverlay -->
@ -187,8 +204,8 @@
<html:div>&displayMode.label;</html:div>
</box>
<spring class="spacer3"/>
<titledbutton id="EditModeButton" class="DisplayModeButton" selected="1" value="&editModeButton.label;" onclick="EditorSetDisplayStyle(0)"/>
<titledbutton id="BrowserModeButton" class="DisplayModeButton" selected="0" value="&browserModeButton.label;" onclick="EditorSetDisplayStyle(1)"/>
<titledbutton id="EditModeButton" class="DisplayModeButton" selected="1" value="&showExtraMarkup.label;" onclick="EditorSetDisplayStyle(0)"/>
<titledbutton id="BrowserModeButton" class="DisplayModeButton" selected="0" value="&hideExtraMarkup.label;" onclick="EditorSetDisplayStyle(1)"/>
<html:div class="VerticalSeparator"/>
<spring flex="100%"/>
<!--

Просмотреть файл

@ -148,13 +148,15 @@
<broadcaster id="Editor:Font:Size" fontsize=""/>
<!-- Command Broadcaster nodes -->
<broadcaster id="Editor:Open" value="&openCmd.label;" oncommand="EditorOpen()"/>
<broadcaster id="Editor:Save" value="&saveCmd.label;" disabled="true" oncommand="EditorSave()"/>
<!-- Don't set value on items whose text should be different for different observers -->
<broadcaster id="Editor:Open" oncommand="EditorOpen()"/>
<broadcaster id="Editor:Save" value="&saveCmd.label;" oncommand="EditorSave()" disabled="true"/>
<broadcaster id="Editor:SaveAs" value="&saveAsCmd.label;" oncommand="EditorSaveAs()"/>
<broadcaster id="Editor:Preview" value="&previewCmd.label;" oncommand="EditorPreview()"/>
<broadcaster id="Editor:Close" value="&closeCmd.label;" oncommand="EditorClose()"/>
<broadcaster id="Editor:PrintSetup" value="&printSetupCmd.label;" oncommand="_EditorNotImplemented()"/>
<broadcaster id="Editor:PrintPreview" value="&printPreviewCmd.label;" oncommand="EditorPrintPreview()"/>
<broadcaster id="Editor:Print" value="&printCmd.label;" oncommand="EditorPrint()"/>
<broadcaster id="Editor:PrintSetup" value="&printSetupCmd.label;" oncommand="EditorPrintSetup()" disabled="true"/>
<broadcaster id="Editor:PrintPreview" value="&printPreviewCmd.label;" oncommand="EditorPrintPreview()" disabled="true"/>
<broadcaster id="Editor:Print" oncommand="EditorPrint()"/>
<broadcaster id="Editor:Exit" value="&exitCmd.label;" oncommand="EditorExit()"/>
<broadcaster id="Editor:Undo" value="&undoCmd.label;" oncommand="EditorUndo()"/>
@ -163,15 +165,15 @@
<broadcaster id="Editor:Copy" value="&copyCmd.label;" oncommand="EditorCopy()"/>
<broadcaster id="Editor:Paste" value="&pasteCmd.label;" oncommand="EditorPaste()"/>
<broadcaster id="Editor:PasteQuote" value="&pasteAsQuotationCmd.label;" oncommand="EditorPasteAsQuotation()"/>
<broadcaster id="Editor:Clear" value="&clearCmd.label;" oncommand="_EditorNotImplemented()"/>
<broadcaster id="Editor:Clear" value="&clearCmd.label;" oncommand="_EditorNotImplemented()" disabled="true"/>
<broadcaster id="Editor:SelectAll" value="&selectAllCmd.label;" oncommand="EditorSelectAll()"/>
<broadcaster id="Editor:Find" value="&findCmd.label;" oncommand="EditorFind()"/>
<broadcaster id="Editor:Find" oncommand="EditorFind()"/>
<broadcaster id="Editor:FindNext" value="&findAgainCmd.label;" oncommand="EditorFindNext()"/>
<broadcaster id="Editor:CheckSpelling" value="&checkSpellingCmd.label;" oncommand="CheckSpelling()"/>
<!-- need to toggle the menu item text through style -->
<broadcaster id="Editor:ToggleCompositionToolbar" value="&hideCompositionToolbarCmd.label;" showing="true" oncommand="_EditorNotImplemented()"/>
<broadcaster id="Editor:ToggleFormattingToolbar" value="&hideFormattingToolbarCmd.label;" showing="true" oncommand="_EditorNotImplemented()"/>
<broadcaster id="Editor:ToggleCompositionToolbar" value="&hideCompositionToolbarCmd.label;" showing="true" oncommand="_EditorNotImplemented()" disabled="true"/>
<broadcaster id="Editor:ToggleFormattingToolbar" value="&hideFormattingToolbarCmd.label;" showing="true" oncommand="_EditorNotImplemented()" disabled="true"/>
<broadcaster id="Editor:InsertLink" value="&insertLinkCmd.label;" oncommand="EditorInsertOrEditLink()"/>
<broadcaster id="Editor:InsertAnchor" value="&insertAnchorCmd.label;" oncommand="EditorInsertOrEditNamedAnchor()"/>
@ -179,8 +181,8 @@
<broadcaster id="Editor:InsertHLine" value="&insertHLineCmd.label;" oncommand="EditorInsertOrEditHLine()"/>
<broadcaster id="Editor:InsertTable" value="&insertTableCmd.label;" oncommand="EditorInsertTable()"/>
<broadcaster id="Editor:InsertHTML" value="&insertHTMLSourceCmd.label;" oncommand="EditorInsertHTML()"/>
<broadcaster id="Editor:InsertBreak" value="&insertLineBreakCmd.label;" oncommand="_EditorNotImplemented()"/>
<broadcaster id="Editor:InsertBreakAll" value="&insertBreakBelowImagesCmd.label;" oncommand="_EditorNotImplemented()"/>
<broadcaster id="Editor:InsertBreak" value="&insertLineBreakCmd.label;" oncommand="_EditorNotImplemented()" disabled="true"/>
<broadcaster id="Editor:InsertBreakAll" value="&insertBreakBelowImagesCmd.label;" oncommand="_EditorNotImplemented()" disabled="true"/>
<broadcaster id="cmd_preferences"/>
</broadcasterset>
@ -202,15 +204,18 @@
</menupopup>
</menu>
<menuitem accesskey="&fileopenremote.accesskey;" value="&openremoteCmd.label;" key="openremoteeditorkb" oncommand="EditorOpenRemote()"/>
<menuitem accesskey="&fileopen.accesskey;" key="openeditorkb" observes="Editor:Open"/>
<menuitem accesskey="&fileopen.accesskey;" key="openeditorkb" observes="Editor:Open" value="&openFileCmd.label;"/>
<menuseparator />
<menuitem accesskey="&fileclose.accesskey;" key="closekb" observes="Editor:Close"/>
<menuitem accesskey="&filesave.accesskey;" key="savekb" observes="Editor:Save"/>
<menuitem accesskey="&filesaveas.accesskey;" observes="Editor:SaveAs"/>
<menuseparator />
<menuitem accesskey="&fileprintsetup.accesskey;" observes="Editor:PrintSetup"/>
<!-- SEND PAGE, FRAME, LINK should go here, but nav must put them in global files -->
<menuitem accesskey="&filepreview.accesskey;" observes="Editor:Preview"/>
<menuseparator />
<menuitem accesskey="&fileprintsetup.accesskey;" observes="Editor:PrintSetup" />
<menuitem accesskey="&fileprintpreview.accesskey;" observes="Editor:PrintPreview"/>
<menuitem accesskey="&fileprint.accesskey;" key="printkb" observes="Editor:Print"/>
<menuitem accesskey="&fileprint.accesskey;" key="printkb" observes="Editor:Print" value="&printCmd.label;"/>
<menuseparator />
<menuitem accesskey="&fileexit.accesskey;" key="exitkb" observes="Editor:Exit"/>
</menupopup>
@ -229,7 +234,7 @@
<menuseparator />
<menuitem accesskey="&editselectall.accesskey;" key="selectallkb" observes="Editor:SelectAll"/>
<menuseparator />
<menuitem accesskey="&editfind.accesskey;" key="findkb" observes="Editor:Find"/>
<menuitem accesskey="&editfind.accesskey;" key="findkb" observes="Editor:Find" value="&findCmd.label;"/>
<menuitem accesskey="&editfindnext.accesskey;" key="findnextkb" observes="Editor:FindNext"/>
<menuseparator />
<menuitem accesskey="&editcheckspelling.accesskey;" key="checkspellingkb" observes="Editor:CheckSpelling"/>
@ -240,14 +245,14 @@
</menu>
<!-- view menu items -->
<menu id="viewToolbar" value="&viewToolbarsMenu.label;" accesskey="viewToolbarsMenu.accesskey">
<menu id="viewToolbar" value="&viewToolbarsMenu.label;" accesskey="&viewToolbarsMenu.accesskey;">
<menupopup>
<menuitem id="compToolbarMenuitem" accesskey="&viewcompositiontb.accesskey;" observes="Editor:ToggleCompositionToolbar"/>
<menuitem id="formatToolbarMenuitem" accesskey="&viewformattingtb.accesskey;" observes="Editor:ToggleFormattingToolbar"/>
<menuitem id="editorTaskBar" value="&showTaskbarCmd.label;" accesskey="&showTaskbarCmd.accesskey;" oncommand="goToggleToolbar('taskbar','cmd_viewtaskbar');" checked="true"/>
</menupopup>
</menu>
<menuitem id="viewSourceMenuitem" value="&viewPageSource.label;" accesskey="&viewpagesource.accesskey;" oncommand="EditorViewSource();" />
<menuitem id="viewSourceMenuitem" value="&viewPageSource.label;" accesskey="&viewpagesource.accesskey;" oncommand="EditorViewSource();"/>
<menu id="charsetMenu" value="&dcharMenu.label;" accesskey="&viewcharsetmenu.accesskey;">
<menupopup>
@ -340,13 +345,13 @@
<menuitem accesskey="&inserttable.accesskey;" observes="Editor:InsertTable"/>
<menuitem accesskey="&insertsource.accesskey;" key="inserthtmlkb" observes="Editor:InsertHTML"/>
<menuseparator />
<menuitem accesskey="&insertlinebreak.accesskey;" observes="Editor:InsertBreak"/>
<menuitem accesskey="&insertbreak.accesskey;" observes="Editor:InsertBreakAll"/>
<menuitem accesskey="&insertlinebreak.accesskey;" disabled="true" observes="Editor:InsertBreak"/>
<menuitem accesskey="&insertbreak.accesskey;" disabled="true" observes="Editor:InsertBreakAll"/>
</menupopup>
</menu>
<!-- Format Menu -->
<menupopup id="formatMenuPopup">
<menupopup id="formatMenuPopup" oncreate="EditorInitFormatMenu()">
<!-- Font face submenu -->
<menu id="fontFaceMenu" value="&fontfaceMenu.label;"
accesskey="&formatfontmenu.accesskey;" position="1">
@ -465,7 +470,7 @@
position="10">
<menupopup>
<menuitem value="&paragraphNormalCmd.label;" accesskey="&paragraphnormal.accesskey;" oncommand="EditorSetParagraphFormat('normal')"/>
<menuitem value="&paragraphParagraphCmd.label;" accesskey="&paragraphparagraph.accesskey;" oncommand="EditorSetParagraphFormat('p')"/>
<menuitem value="&paragraphParagraphCmd.label;" accesskey="&paragraphparagraph.accesskey;" oncommand="EditorSetParagraphFormat('p')" disabled="true"/>
<menuitem value="&paragraphBlockquoteCmd.label;" accesskey="&paragraphblockquote.accesskey;" oncommand="EditorSetParagraphFormat('blockquote')"/>
<menuitem value="&paragraphAddressCmd.label;" accesskey="&paragraphaddress.accesskey;" oncommand="EditorSetParagraphFormat('address')"/>
<menuitem value="&paragraphPreformatCmd.label;" accesskey="&paragraphpreformat.accesskey;" oncommand="EditorSetParagraphFormat('pre')"/>
@ -484,7 +489,7 @@
<!-- Stylesheet submenu -->
<menu id="stylesheetMenu" value="&stylesheetMenu.label;"
accesskey="&formatstylesheetmenu.accesskey;"
position="13">
position="13" hidden="true" disabled="true">
<menupopup>
<menuitem value="&stylesheetOldstyleCmd.label;" accesskey="&ssoldstyle.accesskey;" oncommand="EditorApplyStyleSheet('http://www.w3.org/StyleSheets/Core/Oldstyle')"/>
<menuitem value="&stylesheetModernistCmd.label;" accesskey="&ssmodernist.accesskey;" oncommand="EditorApplyStyleSheet('http://www.w3.org/StyleSheets/Core/Modernist')"/>
@ -519,20 +524,20 @@
oncommand="EditorIndent('outdent')"
position="17"/>
<menuseparator position="18"/>
<menuitem id="objectProperties" value="&properties.label;"
accesskey="&properties.accesskey;"
oncommand="EditorObjectProperties()"
position="19"/>
<menuitem id="colorsAndBackground" value="&colorsAndBackground.label;"
accesskey="&colorsandbackground.accesskey;"
oncommand="EditorPageProperties('ColorTab')"
position="20"/>
<!-- Merge page property items here -->
<!-- Merge Table Menu and separator in Messenger Composer here -->
<!-- Merge property items here -->
</menupopup>
<!-- Items to append at the bottom of the formatMenuPopup -->
<menuitem id="objectProperties" value="&properties.label;"
accesskey="&properties.accesskey;"
oncommand="EditorObjectProperties()"/>
<menuitem id="pageProperties" value="&pageProperties.label;"
accesskey="&pageproperties.accesskey;"
oncommand="EditorPageProperties('GeneralTab')"/>
<menuitem id="colorsAndBackground" value="&colorsAndBackground.label;"
accesskey="&colorsandbackground.accesskey;"
oncommand="EditorPageProperties('ColorTab')"/>
<menu id="tableMenu" value="&tableMenu.label;" accesskey="&tablemenu.accesskey;">
<menupopup>
@ -568,9 +573,9 @@
</menupopup>
</menu>
<menuseparator />
<menuitem id="tableFixupMenuitem" value="&tableFixup.label;" accesskey="&tablefixup.accesskey;" oncommand="EditorNormalizeTable()"/>
<menuitem id="tableJoinCellsMenuitem" value="&tableJoinCells.label;" accesskey="&tablejoin.accesskey;" oncommand="EditorJoinTableCells()"/>
<menuitem id="tablePropertiesMenuitem" value="&properties.label;" accesskey="&properties.accesskey;" oncommand="EditorInsertOrEditTable(false)"/>
<menuitem id="tableFixupMenuitem" value="&tableFixup.label;" accesskey="&tablefixup.accesskey;" oncommand="EditorNormalizeTable()"/>
<menuitem id="tableJoinCellsMenuitem" value="&tableJoinCells.label;" accesskey="&tablejoin.accesskey;" oncommand="EditorJoinTableCells()"/>
<menuitem id="tablePropertiesMenuitem" value="&tableProperties.label;" accesskey="&properties.accesskey;" oncommand="EditorInsertOrEditTable(false)"/>
</menupopup>
</menu>
@ -625,11 +630,12 @@
<!-- Editor toolbar items -->
<!-- note that we override the submenu item label "Blank Window" with "New" used for the menu -->
<titledbutton id="newButton" class="button28" observes="cmd_newEditor" value="&newMenu.label;" />
<titledbutton id="openButton" class="button28" observes="Editor:Open"/>
<titledbutton id="newButton" class="button28" observes="cmd_newEditor" value="&newMenu.label;" />
<titledbutton id="openButton" class="button28" observes="Editor:Open" value="&openToolbarCmd.label;"/>
<titledbutton id="saveButton" class="button28" observes="Editor:Save"/>
<titledbutton id="printButton" class="other28" observes="Editor:Print"/>
<titledbutton id="findButton" class="other28" observes="Editor:Find"/>
<titledbutton id="previewButton" class="button28" observes="Editor:Preview"/>
<titledbutton id="printButton" class="other28" observes="Editor:Print" value="&printToolbarCmd.label;"/>
<titledbutton id="findButton" class="other28" observes="Editor:Find" value="&findToolbarCmd.label;"/>
<titledbutton id="spellingButton" class="other28" value="&spellToolbarCmd.label;" onclick="CheckSpelling()"/>
<titledbutton id="imageButton" class="other28" value="&imageToolbarCmd.label;" onclick="EditorInsertOrEditImage()"/>

Просмотреть файл

@ -41,8 +41,9 @@
<!-- Display Mode Toolbar -->
<!ENTITY displayMode.label "Edit Mode:">
<!ENTITY editModeButton.label "Normal">
<!ENTITY browserModeButton.label "Browser">
<!ENTITY showExtraMarkup.label "Show Extra Markup">
<!ENTITY extraMarkup.accesskey "e">
<!ENTITY hideExtraMarkup.label "Hide Extra Markup">
<!ENTITY viewModeButton.label "View Mode:">
<!ENTITY htmlModeButton.label "HTML Source">
<!ENTITY treeModeButton.label "Tag Tree">

Просмотреть файл

@ -3,6 +3,8 @@
#
# Note: embeded "\n" translate into breaks (<br>)
# Don't tranalate!!!
# Don't translate strings like this: %variable%
# as they will be replaced using JavaScript
#
Yes=Yes
No=No
@ -33,9 +35,9 @@ HTMLFiles=HTML Files
IMGFiles=Image Files
TextFiles=Text Files
AllFiles=All Files
SaveFilePrompt=Save changes to
BeforeClosing= before closing
QuestionMark=?
#Don't translate %title% and %reason% (this is the reason for asking user to close, such as "before closing")
SaveFilePrompt=Save changes to "%title%"%reason%?
SaveFileFailed=Saving file failed!
DocumentTitle=Document Title
NeedDocTitle=Enter a title for the current page. The title identifies the page in the window title and bookmarks.
@ -45,11 +47,11 @@ EmptyHREFError=You must enter or choose a location (URL) to create a new link.
LinkText=Link text:
EnterLinkText=Enter text to display for the link:
EmptyLinkTextError=You must enter some text for this link.
ValidateNumber1=The number you entered (
ValidateNumber2=) is outside of allowed range. Please enter a number between
ValidateNumber3=and
#Don't translate: %n% %min% %max%
ValidateNumber=The number you entered (%n%) is outside of the allowed range. Please enter a number between %min% and %max%
MissingAnchorNameError=You must enter a name for this anchor.
DuplicateAnchorNameError=already exists in this page. Please enter a different name.
#Don't translate %name%
DuplicateAnchorNameError="%name%" already exists in this page. Please enter a different name.
BulletStyle=Bullet Style:
SolidCircle=Solid circle
OpenCircle=Open circle
@ -71,3 +73,12 @@ NoHeadings=(No headings without anchors)
PageBackColor=Page Background Color
CallBackColor=Cell Background Color
TableBackColor=Table Background Color
Table=Table
TableCell=Table Cell
HLine=H.Line
Link=Link
Image=Image
NamedAnchor=Named Anchor
Tag=Tag
#Don't translate "%obj%" it will be replaced with one of above object nouns
ObjectProperties=%obj% Properties

Просмотреть файл

@ -29,7 +29,7 @@
<!ENTITY newBlankPage.accesskey "b" >
<!ENTITY newMenu.label "New">
<!ENTITY newMenu.accesskey "n">
<!ENTITY openCmd.label "Open File...">
<!ENTITY openFileCmd.label "Open File...">
<!ENTITY fileopen.accesskey "o">
<!ENTITY fileopen.keybinding "o">
<!ENTITY openremoteCmd.label "Open Web Location...">
@ -40,11 +40,14 @@
<!ENTITY filesave.keybinding "s">
<!ENTITY saveAsCmd.label "Save As...">
<!ENTITY filesaveas.accesskey "a">
<!ENTITY printSetupCmd.label ".Print Setup...">
<!ENTITY previewCmd.label "Preview">
<!ENTITY filepreview.accesskey "v">
<!ENTITY printSetupCmd.label "Print Setup...">
<!ENTITY fileprintsetup.accesskey "t">
<!ENTITY printPreviewCmd.label "Print Preview">
<!ENTITY fileprintpreview.accesskey "r">
<!ENTITY printCmd.label "Print...">
<!ENTITY printButtonCmd.label "Print...">
<!ENTITY fileprint.accesskey "p">
<!ENTITY fileprint.keybinding "p">
<!ENTITY closeCmd.label "Close">
@ -74,7 +77,7 @@
<!ENTITY editpaste.keybinding "v"> <!-- also used for pasteAsQuotationCmd -->
<!ENTITY pasteAsQuotationCmd.label "Paste As Quotation">
<!ENTITY editpastequotation.accesskey "q">
<!ENTITY clearCmd.label ".Clear">
<!ENTITY clearCmd.label "Clear">
<!ENTITY editclear.accesskey "l">
<!ENTITY selectAllCmd.label "Select All">
<!ENTITY editselectall.accesskey "a">
@ -93,12 +96,12 @@
<!ENTITY viewMenu.label "View">
<!ENTITY viewToolbarsMenu.label "Toolbars">
<!ENTITY viewToolbarsMenu.accesskey "t">
<!ENTITY hideCompositionToolbarCmd.label ".Hide Composition Toolbar">
<!ENTITY hideCompositionToolbarCmd.label "Hide Composition Toolbar">
<!ENTITY viewcompositiontb.accesskey "c">
<!ENTITY showCompositionToolbarCmd.label ".Show Composition Toolbar">
<!ENTITY hideFormattingToolbarCmd.label ".Hide Format Toolbar">
<!ENTITY showCompositionToolbarCmd.label "Show Composition Toolbar">
<!ENTITY hideFormattingToolbarCmd.label "Hide Format Toolbar">
<!ENTITY viewformattingtb.accesskey "f">
<!ENTITY showFormattingToolbarCmd.label ".Show Format Toolbar">
<!ENTITY showFormattingToolbarCmd.label "Show Format Toolbar">
<!ENTITY showTaskbarCmd.label "Show Taskbar">
<!ENTITY showTaskbarCmd.accesskey "t">
<!ENTITY viewPageSource.label "Page Source">
@ -232,9 +235,9 @@
<!ENTITY inserttable.accesskey "t">
<!ENTITY insertHTMLSourceCmd.label "HTML Source...">
<!ENTITY insertsource.accesskey "s">
<!ENTITY insertLineBreakCmd.label ".Line Break">
<!ENTITY insertLineBreakCmd.label "Line Break">
<!ENTITY insertlinebreak.accesskey "n">
<!ENTITY insertBreakBelowImagesCmd.label ".Break Below Image(s)">
<!ENTITY insertBreakBelowImagesCmd.label "Break Below Image(s)">
<!ENTITY insertbreak.accesskey "b">
<!-- Format Menu -->
@ -423,21 +426,23 @@
<!ENTITY tabletable.accesskey "t">
<!ENTITY tableRow.label "Row">
<!ENTITY tablerow.accesskey "r">
<!ENTITY tableRowAbove.label "Row above">
<!ENTITY tableRowAbove.label "Row Above">
<!-- uses tablerow.accesskey -->
<!ENTITY tableRowBelow.label "Row below">
<!ENTITY tableRowBelow.label "Row Below">
<!ENTITY tablerowbelow.accesskey "b">
<!ENTITY tableColumn.label "Column">
<!ENTITY tablecolumn.accesskey "o">
<!ENTITY tableColumnBefore.label "Column before">
<!ENTITY tableColumnBefore.label "Column Before">
<!-- uses tablecolumn.accesskey -->
<!ENTITY tableColumnAfter.label "Column after">
<!ENTITY tableColumnAfter.label "Column After">
<!ENTITY tablecolumnafter.accesskey "a">
<!ENTITY tableCell.label "Cell">
<!ENTITY tablecell.accesskey "c">
<!ENTITY tableCellBefore.label "Cell before">
<!ENTITY tableAllCells.label "All Cells">
<!ENTITY tableCellBefore.label "Cell Before">
<!ENTITY tableallcells.accesskey "a">
<!-- uses tablecell.accesskey -->
<!ENTITY tableCellAfter.label "Cell after">
<!ENTITY tableCellAfter.label "Cell After">
<!ENTITY tablecellafter.accesskey "f">
<!-- Delete SubMenu -->
<!ENTITY tableDeleteMenu.label "Delete">
@ -447,6 +452,7 @@
<!ENTITY tablefixup.accesskey "f">
<!ENTITY tableJoinCells.label "Join Cells">
<!ENTITY tablejoin.accesskey "j">
<!ENTITY tableProperties.label "Table Properties...">
<!-- These may be shared in other menus -->
<!ENTITY properties.label "Properties...">
<!ENTITY properties.accesskey "o">
@ -478,13 +484,8 @@
<!ENTITY runLogCmd.label "Run Log">
<!ENTITY setFocusCmd.label "Set Focus">
<!-- toolbar items -->
<!ENTITY newToolbarCmd.label "New">
<!-- toolbar-only items -->
<!ENTITY openToolbarCmd.label "Open">
<!ENTITY saveToolbarCmd.label "Save">
<!ENTITY publishToolbarCmd.label "Publish">
<!ENTITY previewToolbarCmd.label "Preview">
<!ENTITY editmodeToolbarCmd.label "Edit Mode">
<!ENTITY printToolbarCmd.label "Print">
<!ENTITY findToolbarCmd.label "Find">
<!ENTITY linkToolbarCmd.label "Link">
@ -493,7 +494,6 @@
<!ENTITY hruleToolbarCmd.label "H.Line">
<!ENTITY tableToolbarCmd.label "Table">
<!ENTITY spellToolbarCmd.label "Spell">
<!ENTITY toolspellcheck.accesskey "s">
<!ENTITY textColorCaption.label "Text Color">
<!-- editor toolbar -->

Просмотреть файл

@ -57,6 +57,7 @@ images:savefile.gif
images:savemod.gif
images:publish.gif
images:print.gif
images:preview.gif
images:find.gif
images:link-white.gif
images:anchor-white.gif

Просмотреть файл

@ -57,6 +57,7 @@ EXPORT_RESOURCE_TOOLBAR = \
$(srcdir)/images/savefile.gif \
$(srcdir)/images/savemod.gif \
$(srcdir)/images/publish.gif \
$(srcdir)/images/preview.gif \
$(srcdir)/images/print.gif \
$(srcdir)/images/find.gif \
$(srcdir)/images/img-align-bottom.gif \

Просмотреть файл

@ -33,7 +33,7 @@ toolbox#EditorToolbox {
min-width: 1px;
}
toolbar#FormatToolbar {
toolbar#FormatToolbar, toolbar#TitleToolbar {
border-bottom: 1px solid #003366;
}
@ -105,6 +105,10 @@ toolbar#FormatToolbar titledbutton#underlineButton {
text-decoration: underline;
}
input#PageTitle, input#PageAuthor {
min-width: 5em;
}
div.toolbar-middle {
/* trying to center vertically in the toolbar! */
vertical-align: middle;
@ -163,6 +167,11 @@ box#DisplayModeBar div.VerticalSeparator {
margin: 1px 0px;
}
/* SHOULD BE IN GLOBAL.CSS */
menuitem[hidden="true"] {
visibility: collapse;
}
spring.spacer3 {
width: 3px;
height: 3px;
@ -173,6 +182,10 @@ spring.spacer5 {
height: 5px;
}
spring.spacer-throbber {
/* this is throbber box width - 12 */
width: 56px;
}
/* Image URLs for all Editor toolbar buttons */
titledbutton#newButton {
@ -192,6 +205,9 @@ titledbutton#saveButton[dirty="true"] {
titledbutton#publishButton {
list-style-image:url("chrome://editor/skin/images/publish.gif");
}
titledbutton#previewButton {
list-style-image:url("chrome://editor/skin/images/preview.gif");
}
titledbutton#printButton {
list-style-image:url("chrome://editor/skin/images/print.gif");
}

Просмотреть файл

@ -53,6 +53,7 @@ install:: $(DLL)
$(MAKE_INSTALL) images\savefile.gif $(DIST)\bin\chrome\editor\skin\default\images
$(MAKE_INSTALL) images\savemod.gif $(DIST)\bin\chrome\editor\skin\default\images
$(MAKE_INSTALL) images\publish.gif $(DIST)\bin\chrome\editor\skin\default\images
$(MAKE_INSTALL) images\preview.gif $(DIST)\bin\chrome\editor\skin\default\images
$(MAKE_INSTALL) images\print.gif $(DIST)\bin\chrome\editor\skin\default\images
$(MAKE_INSTALL) images\find.gif $(DIST)\bin\chrome\editor\skin\default\images
$(MAKE_INSTALL) images\img-align-bottom.gif $(DIST)\bin\chrome\editor\skin\default\images
@ -98,6 +99,7 @@ clobber::
rm -f $(DIST)\bin\chrome\editor\skin\default\images\savefile.gif
rm -f $(DIST)\bin\chrome\editor\skin\default\images\savemod.gif
rm -f $(DIST)\bin\chrome\editor\skin\default\images\publish.gif
rm -f $(DIST)\bin\chrome\editor\skin\default\images\preview.gif
rm -f $(DIST)\bin\chrome\editor\skin\default\images\print.gif
rm -f $(DIST)\bin\chrome\editor\skin\default\images\find.gif
rm -f $(DIST)\bin\chrome\editor\skin\default\images\img-align-bottom.gif

Просмотреть файл

@ -131,7 +131,9 @@ function ValidateNumberString(value, minValue, maxValue)
return number + "";
}
}
message = editorShell.GetString("ValidateNumber1")+number+editorShell.GetString("ValidateNumber2")+" "+minValue+" "+editorShell.GetString("ValidateNumber3")+" "+maxValue;
message = editorShell.GetString("ValidateNumber");
// Replace variable placeholders in message with number values
message = ((message.replace(/%n%/,number)).replace(/%min%/,minValue)).replace(/%max%/,maxValue);
ShowInputErrorMessage(message);
// Return an empty string to indicate error

Просмотреть файл

@ -110,7 +110,7 @@ function ValidateData()
// Replace spaces with "_" else it causes trouble in URL parsing
name = PrepareStringForURL(name);
if (AnchorNameExists(name)) {
ShowInputErrorMessage("\""+name+"\" "+GetString("DuplicateAnchorNameError"));
ShowInputErrorMessage(GetString("DuplicateAnchorNameError").replace(/%name%/,name));
nameInput.focus();
return false;
}

Просмотреть файл

@ -27,6 +27,7 @@
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
<?xul-overlay href="chrome://editor/content/EdDialogOverlay.xul"?>
<?xul-overlay href="chrome://editor/content/EdColorsOverlay.xul"?>
<!DOCTYPE window SYSTEM "chrome://editor/locale/EditorPageProperties.dtd">