From 4192db5431c3fe154bb05fc449db75d530136cba Mon Sep 17 00:00:00 2001 From: "cmanske%netscape.com" Date: Wed, 1 Sep 1999 19:58:25 +0000 Subject: [PATCH] Changed IsNodeBlock to NodeIsBlock for JS. Fixed all compiler warnings. Added Advanced property Edit files git-svn-id: svn://10.0.0.236/trunk@45482 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/editor/base/EditTable.cpp | 7 +-- mozilla/editor/base/nsEditor.cpp | 13 ++--- mozilla/editor/base/nsEditor.h | 5 +- mozilla/editor/base/nsEditorShell.cpp | 6 +-- mozilla/editor/composer/src/nsEditorShell.cpp | 6 +-- mozilla/editor/idl/nsIEditorShell.idl | 2 +- mozilla/editor/libeditor/base/nsEditor.cpp | 13 ++--- mozilla/editor/libeditor/base/nsEditor.h | 5 +- mozilla/editor/public/nsIEditor.h | 7 ++- .../ui/dialogs/content/EdAdvancedEdit.js | 53 +++++++++++++++++++ .../ui/dialogs/content/EdAdvancedEdit.xul | 49 +++++++++++++++++ mozilla/editor/ui/dialogs/content/MANIFEST | 2 + mozilla/editor/ui/dialogs/content/Makefile.in | 2 + .../editor/ui/dialogs/content/makefile.win | 6 +++ .../dialogs/locale/en-US/EdAdvancedEdit.dtd | 23 ++++++++ .../editor/ui/dialogs/locale/en-US/MANIFEST | 2 + .../ui/dialogs/locale/en-US/Makefile.in | 1 + .../ui/dialogs/locale/en-US/makefile.win | 4 ++ 18 files changed, 169 insertions(+), 37 deletions(-) create mode 100644 mozilla/editor/ui/dialogs/content/EdAdvancedEdit.js create mode 100644 mozilla/editor/ui/dialogs/content/EdAdvancedEdit.xul create mode 100644 mozilla/editor/ui/dialogs/locale/en-US/EdAdvancedEdit.dtd diff --git a/mozilla/editor/base/EditTable.cpp b/mozilla/editor/base/EditTable.cpp index e1fdd92d36f..a56bc7e4ce9 100644 --- a/mozilla/editor/base/EditTable.cpp +++ b/mozilla/editor/base/EditTable.cpp @@ -159,14 +159,9 @@ nsHTMLEditor::DeleteTable() if(NS_FAILED(GetChildOffset(table, tableParent, tableOffset))) return NS_ERROR_FAILURE; - // Place selection just before the table - nsCOMPtrselection; - res = nsEditor::GetSelection(getter_AddRefs(selection)); - if (NS_FAILED(res) || !selection) - return res; - res = DeleteNode(table); + // Place selection just before the table selection->Collapse(tableParent, tableOffset); } return res; diff --git a/mozilla/editor/base/nsEditor.cpp b/mozilla/editor/base/nsEditor.cpp index f2f462b854d..e1c0306175e 100644 --- a/mozilla/editor/base/nsEditor.cpp +++ b/mozilla/editor/base/nsEditor.cpp @@ -671,7 +671,7 @@ nsEditor::SetDocumentCharacterSet(const PRUnichar* characterSet) } NS_IMETHODIMP -nsEditor::SaveFile(nsFileSpec *aFileSpec, PRBool aReplaceExisting, PRBool aSaveCopy, ESaveFileType aSaveFileType) +nsEditor::SaveFile(nsFileSpec *aFileSpec, PRBool aReplaceExisting, PRBool aSaveCopy, nsIDiskDocument::ESaveFileType aSaveFileType) { if (!aFileSpec) return NS_ERROR_NULL_POINTER; @@ -688,11 +688,8 @@ nsEditor::SaveFile(nsFileSpec *aFileSpec, PRBool aReplaceExisting, PRBool aSaveC nsAutoString useDocCharset(""); - typedef enum {eSaveFileText = 0, eSaveFileHTML = 1 } ESaveFileType; - res = diskDoc->SaveFile(aFileSpec, aReplaceExisting, aSaveCopy, - aSaveFileType == eSaveFileText ? nsIDiskDocument::eSaveFileText : nsIDiskDocument::eSaveFileHTML, - useDocCharset); + aSaveFileType, useDocCharset); if (NS_SUCCEEDED(res)) DoAfterDocumentSave(); @@ -2095,10 +2092,10 @@ nsEditor::GetLengthOfDOMNode(nsIDOMNode *aNode, PRUint32 &aCount) // Non-static version for the nsIEditor interface and JavaScript NS_IMETHODIMP -nsEditor::IsNodeBlock(nsIDOMNode *aNode, PRBool *aIsBlock) +nsEditor::NodeIsBlock(nsIDOMNode *aNode, PRBool &aIsBlock) { - if (!aNode || !aIsBlock) { return NS_ERROR_NULL_POINTER; } - return IsNodeBlock(aNode, *aIsBlock); + if (!aNode) { return NS_ERROR_NULL_POINTER; } + return IsNodeBlock(aNode, aIsBlock); } // The list of block nodes is shorter, so do the real work here... diff --git a/mozilla/editor/base/nsEditor.h b/mozilla/editor/base/nsEditor.h index d79dcaf7913..2938eca723d 100644 --- a/mozilla/editor/base/nsEditor.h +++ b/mozilla/editor/base/nsEditor.h @@ -27,6 +27,7 @@ #include "nsIEditorIMESupport.h" #include "nsIDOMDocument.h" +#include "nsIDiskDocument.h" #include "nsIDOMSelection.h" #include "nsIDOMCharacterData.h" #include "nsIDOMEventListener.h" @@ -124,7 +125,7 @@ public: NS_IMETHOD GetDocumentModified(PRBool *outDocModified); NS_IMETHOD GetDocumentCharacterSet(PRUnichar** characterSet); NS_IMETHOD SetDocumentCharacterSet(const PRUnichar* characterSet); - NS_IMETHOD SaveFile(nsFileSpec *aFileSpec, PRBool aReplaceExisting, PRBool aSaveCopy, ESaveFileType aSaveFileType); + NS_IMETHOD SaveFile(nsFileSpec *aFileSpec, PRBool aReplaceExisting, PRBool aSaveCopy, nsIDiskDocument::ESaveFileType aSaveFileType); // these are pure virtual in this base class NS_IMETHOD Cut() = 0; @@ -412,7 +413,7 @@ public: static nsresult IsNodeBlock(nsIDOMNode *aNode, PRBool &aIsBlock); /** This version is for exposure to JavaScript */ - NS_IMETHOD IsNodeBlock(nsIDOMNode *aNode, PRBool *aIsBlock); + NS_IMETHOD NodeIsBlock(nsIDOMNode *aNode, PRBool &aIsBlock); /** returns the closest block parent of aNode, not including aNode itself. * can return null, for example if aNode is in a document fragment. diff --git a/mozilla/editor/base/nsEditorShell.cpp b/mozilla/editor/base/nsEditorShell.cpp index d7d347fc035..391d2b6efbf 100644 --- a/mozilla/editor/base/nsEditorShell.cpp +++ b/mozilla/editor/base/nsEditorShell.cpp @@ -1150,7 +1150,7 @@ SkipFilters: // TODO: Get the file type (from the extension?) the user set for the file // How do we do this in an XP way??? // For now, just save as HTML type - res = editor->SaveFile(&docFileSpec, replacing, saveCopy, nsIEditor::eSaveFileHTML); + res = editor->SaveFile(&docFileSpec, replacing, saveCopy, nsIDiskDocument::eSaveFileHTML); if (NS_FAILED(res)) { Alert(GetString("SaveFileFailed"), GetString("SaveDocument")); @@ -1305,7 +1305,7 @@ nsEditorShell::GetLocalFileURL(nsIDOMWindow *parent, const PRUnichar *filterType } NS_IMETHODIMP -nsEditorShell::IsNodeBlock(nsIDOMNode *node, PRBool *_retval) +nsEditorShell::NodeIsBlock(nsIDOMNode *node, PRBool *_retval) { if (!node || !_retval) { return NS_ERROR_NULL_POINTER; } nsresult rv = NS_NOINTERFACE; @@ -1317,7 +1317,7 @@ nsEditorShell::IsNodeBlock(nsIDOMNode *node, PRBool *_retval) { nsCOMPtr editor = do_QueryInterface(mEditor); if (editor) - rv = editor->IsNodeBlock(node, _retval); + rv = editor->NodeIsBlock(node, *_retval); } break; diff --git a/mozilla/editor/composer/src/nsEditorShell.cpp b/mozilla/editor/composer/src/nsEditorShell.cpp index d7d347fc035..391d2b6efbf 100644 --- a/mozilla/editor/composer/src/nsEditorShell.cpp +++ b/mozilla/editor/composer/src/nsEditorShell.cpp @@ -1150,7 +1150,7 @@ SkipFilters: // TODO: Get the file type (from the extension?) the user set for the file // How do we do this in an XP way??? // For now, just save as HTML type - res = editor->SaveFile(&docFileSpec, replacing, saveCopy, nsIEditor::eSaveFileHTML); + res = editor->SaveFile(&docFileSpec, replacing, saveCopy, nsIDiskDocument::eSaveFileHTML); if (NS_FAILED(res)) { Alert(GetString("SaveFileFailed"), GetString("SaveDocument")); @@ -1305,7 +1305,7 @@ nsEditorShell::GetLocalFileURL(nsIDOMWindow *parent, const PRUnichar *filterType } NS_IMETHODIMP -nsEditorShell::IsNodeBlock(nsIDOMNode *node, PRBool *_retval) +nsEditorShell::NodeIsBlock(nsIDOMNode *node, PRBool *_retval) { if (!node || !_retval) { return NS_ERROR_NULL_POINTER; } nsresult rv = NS_NOINTERFACE; @@ -1317,7 +1317,7 @@ nsEditorShell::IsNodeBlock(nsIDOMNode *node, PRBool *_retval) { nsCOMPtr editor = do_QueryInterface(mEditor); if (editor) - rv = editor->IsNodeBlock(node, _retval); + rv = editor->NodeIsBlock(node, *_retval); } break; diff --git a/mozilla/editor/idl/nsIEditorShell.idl b/mozilla/editor/idl/nsIEditorShell.idl index 390e9845ca1..d9d1daffb5d 100644 --- a/mozilla/editor/idl/nsIEditorShell.idl +++ b/mozilla/editor/idl/nsIEditorShell.idl @@ -295,7 +295,7 @@ interface nsIEditorShell : nsISupports * Tests if a node is a BLOCK element according the the HTML 4.0 DTD * This does NOT consider CSS effect on display type */ - boolean IsNodeBlock(in nsIDOMNode node); + boolean NodeIsBlock(in nsIDOMNode node); void BeginBatchChanges(); void EndBatchChanges(); diff --git a/mozilla/editor/libeditor/base/nsEditor.cpp b/mozilla/editor/libeditor/base/nsEditor.cpp index f2f462b854d..e1c0306175e 100644 --- a/mozilla/editor/libeditor/base/nsEditor.cpp +++ b/mozilla/editor/libeditor/base/nsEditor.cpp @@ -671,7 +671,7 @@ nsEditor::SetDocumentCharacterSet(const PRUnichar* characterSet) } NS_IMETHODIMP -nsEditor::SaveFile(nsFileSpec *aFileSpec, PRBool aReplaceExisting, PRBool aSaveCopy, ESaveFileType aSaveFileType) +nsEditor::SaveFile(nsFileSpec *aFileSpec, PRBool aReplaceExisting, PRBool aSaveCopy, nsIDiskDocument::ESaveFileType aSaveFileType) { if (!aFileSpec) return NS_ERROR_NULL_POINTER; @@ -688,11 +688,8 @@ nsEditor::SaveFile(nsFileSpec *aFileSpec, PRBool aReplaceExisting, PRBool aSaveC nsAutoString useDocCharset(""); - typedef enum {eSaveFileText = 0, eSaveFileHTML = 1 } ESaveFileType; - res = diskDoc->SaveFile(aFileSpec, aReplaceExisting, aSaveCopy, - aSaveFileType == eSaveFileText ? nsIDiskDocument::eSaveFileText : nsIDiskDocument::eSaveFileHTML, - useDocCharset); + aSaveFileType, useDocCharset); if (NS_SUCCEEDED(res)) DoAfterDocumentSave(); @@ -2095,10 +2092,10 @@ nsEditor::GetLengthOfDOMNode(nsIDOMNode *aNode, PRUint32 &aCount) // Non-static version for the nsIEditor interface and JavaScript NS_IMETHODIMP -nsEditor::IsNodeBlock(nsIDOMNode *aNode, PRBool *aIsBlock) +nsEditor::NodeIsBlock(nsIDOMNode *aNode, PRBool &aIsBlock) { - if (!aNode || !aIsBlock) { return NS_ERROR_NULL_POINTER; } - return IsNodeBlock(aNode, *aIsBlock); + if (!aNode) { return NS_ERROR_NULL_POINTER; } + return IsNodeBlock(aNode, aIsBlock); } // The list of block nodes is shorter, so do the real work here... diff --git a/mozilla/editor/libeditor/base/nsEditor.h b/mozilla/editor/libeditor/base/nsEditor.h index d79dcaf7913..2938eca723d 100644 --- a/mozilla/editor/libeditor/base/nsEditor.h +++ b/mozilla/editor/libeditor/base/nsEditor.h @@ -27,6 +27,7 @@ #include "nsIEditorIMESupport.h" #include "nsIDOMDocument.h" +#include "nsIDiskDocument.h" #include "nsIDOMSelection.h" #include "nsIDOMCharacterData.h" #include "nsIDOMEventListener.h" @@ -124,7 +125,7 @@ public: NS_IMETHOD GetDocumentModified(PRBool *outDocModified); NS_IMETHOD GetDocumentCharacterSet(PRUnichar** characterSet); NS_IMETHOD SetDocumentCharacterSet(const PRUnichar* characterSet); - NS_IMETHOD SaveFile(nsFileSpec *aFileSpec, PRBool aReplaceExisting, PRBool aSaveCopy, ESaveFileType aSaveFileType); + NS_IMETHOD SaveFile(nsFileSpec *aFileSpec, PRBool aReplaceExisting, PRBool aSaveCopy, nsIDiskDocument::ESaveFileType aSaveFileType); // these are pure virtual in this base class NS_IMETHOD Cut() = 0; @@ -412,7 +413,7 @@ public: static nsresult IsNodeBlock(nsIDOMNode *aNode, PRBool &aIsBlock); /** This version is for exposure to JavaScript */ - NS_IMETHOD IsNodeBlock(nsIDOMNode *aNode, PRBool *aIsBlock); + NS_IMETHOD NodeIsBlock(nsIDOMNode *aNode, PRBool &aIsBlock); /** returns the closest block parent of aNode, not including aNode itself. * can return null, for example if aNode is in a document fragment. diff --git a/mozilla/editor/public/nsIEditor.h b/mozilla/editor/public/nsIEditor.h index 9beeedd5097..344b04c78ad 100644 --- a/mozilla/editor/public/nsIEditor.h +++ b/mozilla/editor/public/nsIEditor.h @@ -20,6 +20,7 @@ #define nsIEditor_h__ #include "nsISupports.h" #include "nscore.h" +#include "nsIDiskDocument.h" #define NS_IEDITOR_IID \ {/* A3C5EE71-742E-11d2-8F2C-006008310194*/ \ @@ -45,8 +46,6 @@ class nsIEditor : public nsISupports public: static const nsIID& GetIID() { static nsIID iid = NS_IEDITOR_IID; return iid; } - typedef enum {eSaveFileText = 0, eSaveFileHTML = 1 } ESaveFileType; - /* An enum used to describe how to collpase a non-collapsed selection */ typedef enum { eDoNothing, @@ -132,7 +131,7 @@ public: * This would correspond to a 'Save Copy As' menu command * (currently not in our UI) */ - NS_IMETHOD SaveFile(nsFileSpec *aFileSpec, PRBool aReplaceExisting, PRBool aSaveCopy, ESaveFileType aSaveFileType)=0; + NS_IMETHOD SaveFile(nsFileSpec *aFileSpec, PRBool aReplaceExisting, PRBool aSaveCopy, nsIDiskDocument::ESaveFileType aSaveFileType)=0; /* ------------ Transaction methods -------------- */ @@ -242,7 +241,7 @@ public: * * @param aNode the node to test */ - NS_IMETHOD IsNodeBlock(nsIDOMNode *aNode, PRBool *aIsBlock)=0; + NS_IMETHOD NodeIsBlock(nsIDOMNode *aNode, PRBool &aIsBlock)=0; /** * SetAttribute() sets the attribute of aElement. diff --git a/mozilla/editor/ui/dialogs/content/EdAdvancedEdit.js b/mozilla/editor/ui/dialogs/content/EdAdvancedEdit.js new file mode 100644 index 00000000000..8e412ce6568 --- /dev/null +++ b/mozilla/editor/ui/dialogs/content/EdAdvancedEdit.js @@ -0,0 +1,53 @@ +/* + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998-1999 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + + +//Cancel() is in EdDialogCommon.js +var tagname; +var element; + +// dialog initialization code +function Startup() +{ + if (!InitEditorShell()) + return; + + doSetOKCancel(onOK, null); + + // Create dialog object to store controls for easy access + dialog = new Object; + // GET EACH CONTROL -- E.G.: + dialog.editBox = document.getElementById("editBox"); + element = window.arguments[1]); + + dump("*** Element passed into Advanced Edit: "+element+" ***\n"); + + // SET FOCUS TO FIRST CONTROL + //dialog.editBox.focus(); +} + +function onOK() +{ +// Set attribute example: +// imageElement.setAttribute("src",dialog.srcInput.value); + return true; // do close the window +} diff --git a/mozilla/editor/ui/dialogs/content/EdAdvancedEdit.xul b/mozilla/editor/ui/dialogs/content/EdAdvancedEdit.xul new file mode 100644 index 00000000000..72353cc3bc2 --- /dev/null +++ b/mozilla/editor/ui/dialogs/content/EdAdvancedEdit.xul @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + +