From 84c77414a8e4d09da1682c4d9a6df00a645a67d4 Mon Sep 17 00:00:00 2001 From: "sfraser%netscape.com" Date: Fri, 11 Jun 1999 19:01:07 +0000 Subject: [PATCH] Add factory for EditorShell, and fix case of GetMonitor call. git-svn-id: svn://10.0.0.236/trunk@34815 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/editor/base/nsEditFactory.cpp | 4 +-- mozilla/editor/base/nsEditor.cpp | 40 +++++++++++++++++----- mozilla/editor/base/nsEditor.h | 2 +- mozilla/editor/libeditor/base/nsEditor.cpp | 40 +++++++++++++++++----- mozilla/editor/libeditor/base/nsEditor.h | 2 +- 5 files changed, 66 insertions(+), 22 deletions(-) diff --git a/mozilla/editor/base/nsEditFactory.cpp b/mozilla/editor/base/nsEditFactory.cpp index e16233a0300..e4092384a49 100644 --- a/mozilla/editor/base/nsEditFactory.cpp +++ b/mozilla/editor/base/nsEditFactory.cpp @@ -31,7 +31,7 @@ nsresult GetEditFactory(nsIFactory **aFactory, const nsCID & aClass) { static nsCOMPtr g_pNSIFactory; - PR_EnterMonitor(getEditorMonitor()); + PR_EnterMonitor(GetEditorMonitor()); nsresult result = NS_ERROR_FAILURE; if (!g_pNSIFactory) { @@ -41,7 +41,7 @@ GetEditFactory(nsIFactory **aFactory, const nsCID & aClass) result = NS_OK; } result = g_pNSIFactory->QueryInterface(nsIFactory::GetIID(), (void **)aFactory); - PR_ExitMonitor(getEditorMonitor()); + PR_ExitMonitor(GetEditorMonitor()); return result; } diff --git a/mozilla/editor/base/nsEditor.cpp b/mozilla/editor/base/nsEditor.cpp index b2d87f082ae..e6b3a8a8228 100644 --- a/mozilla/editor/base/nsEditor.cpp +++ b/mozilla/editor/base/nsEditor.cpp @@ -50,6 +50,9 @@ #include "nsIStyleContext.h" #include "nsIEditActionListener.h" +#include "nsEditorShell.h" +#include "nsEditorShellFactory.h" + #include "nsIContent.h" #include "nsIContentIterator.h" #include "nsLayoutCID.h" @@ -98,7 +101,8 @@ static NS_DEFINE_CID(kCRangeCID, NS_RANGE_CID); static NS_DEFINE_CID(kEditorCID, NS_EDITOR_CID); static NS_DEFINE_CID(kTextEditorCID, NS_TEXTEDITOR_CID); static NS_DEFINE_CID(kHTMLEditorCID, NS_HTMLEDITOR_CID); -static NS_DEFINE_CID(kCContentIteratorCID, NS_CONTENTITERATOR_CID); +static NS_DEFINE_IID(kEditorShellCID, NS_EDITORAPPCORE_CID); +static NS_DEFINE_CID(kCContentIteratorCID, NS_CONTENTITERATOR_CID); // transaction manager static NS_DEFINE_CID(kCTransactionManagerCID, NS_TRANSACTIONMANAGER_CID); @@ -162,7 +166,7 @@ PRInt32 nsEditor::gInstanceCount = 0; -PRMonitor *getEditorMonitor() //if more than one person asks for the monitor at the same time for the FIRST time, we are screwed +PRMonitor *GetEditorMonitor() //if more than one person asks for the monitor at the same time for the FIRST time, we are screwed { static PRMonitor *ns_editlock = nsnull; if (nsnull == ns_editlock) @@ -171,7 +175,7 @@ PRMonitor *getEditorMonitor() //if more than one person asks for the monitor at ns_editlock = PR_NewMonitor(); } else if ((PRMonitor *)1 == ns_editlock) - return getEditorMonitor(); + return GetEditorMonitor(); return ns_editlock; } @@ -202,6 +206,7 @@ extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports * aServMgr, if (NS_FAILED(rv)) return rv; rv = NS_NOINTERFACE; + if (aClass.Equals(kEditorCID)) { rv = GetEditFactory(aFactory, aClass); if (NS_FAILED(rv)) goto done; @@ -214,7 +219,11 @@ extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports * aServMgr, rv = GetHTMLEditFactory(aFactory, aClass); if (NS_FAILED(rv)) goto done; } - + else if (aClass.Equals(kEditorShellCID)) { + rv = GetEditorShellFactory(aFactory, aClass, aClassName, aProgID); + if (NS_FAILED(rv)) goto done; + } + done: (void)servMgr->ReleaseService(kComponentManagerCID, gCompMgr); @@ -252,6 +261,17 @@ NSRegisterSelf(nsISupports* aServMgr, const char *path) if (NS_FAILED(rv)) goto done; rv = compMgr->RegisterComponent(kHTMLEditorCID, NULL, NULL, path, PR_TRUE, PR_TRUE); + if (NS_FAILED(rv)) goto done; + rv = compMgr->RegisterComponent(kEditorShellCID, + "Editor Shell Component", + "component://netscape/editor/editorshell", + path, PR_TRUE, PR_TRUE); + + if (NS_FAILED(rv)) goto done; + rv = compMgr->RegisterComponent(kEditorShellCID, + "Editor Shell Spell Checker", + "component://netscape/editor/editorspellcheck", + path, PR_TRUE, PR_TRUE); done: (void)servMgr->ReleaseService(kComponentManagerCID, compMgr); @@ -272,11 +292,13 @@ NSUnregisterSelf(nsISupports* aServMgr, const char *path) (nsISupports**)&compMgr); if (NS_FAILED(rv)) return rv; - rv = compMgr->UnregisterComponent(kIEditFactoryIID, path); + rv = compMgr->UnregisterComponent(kEditorCID, path); if (NS_FAILED(rv)) goto done; - rv = compMgr->UnregisterComponent(kITextEditFactoryIID, path); + rv = compMgr->UnregisterComponent(kTextEditorCID, path); if (NS_FAILED(rv)) goto done; - rv = compMgr->UnregisterComponent(kIHTMLEditFactoryIID, path); + rv = compMgr->UnregisterComponent(kHTMLEditorCID, path); + if (NS_FAILED(rv)) goto done; + rv = compMgr->UnregisterComponent(kEditorShellCID, path); done: (void)servMgr->ReleaseService(kComponentManagerCID, compMgr); @@ -301,10 +323,10 @@ nsEditor::nsEditor() //initialize member variables here NS_INIT_REFCNT(); mIMEFirstTransaction=PR_FALSE; - PR_EnterMonitor(getEditorMonitor()); + PR_EnterMonitor(GetEditorMonitor()); gInstanceCount++; mActionListeners = 0; - PR_ExitMonitor(getEditorMonitor()); + PR_ExitMonitor(GetEditorMonitor()); mPrefs = 0; } diff --git a/mozilla/editor/base/nsEditor.h b/mozilla/editor/base/nsEditor.h index b15ce5eb25b..c113c0900d0 100644 --- a/mozilla/editor/base/nsEditor.h +++ b/mozilla/editor/base/nsEditor.h @@ -58,7 +58,7 @@ class nsJSEditorLog; #endif // ENABLE_JS_EDITOR_LOG //This is the monitor for the editor. -PRMonitor *getEditorMonitor(); +PRMonitor *GetEditorMonitor(); /** implementation of an editor object. it will be the controler/focal point diff --git a/mozilla/editor/libeditor/base/nsEditor.cpp b/mozilla/editor/libeditor/base/nsEditor.cpp index b2d87f082ae..e6b3a8a8228 100644 --- a/mozilla/editor/libeditor/base/nsEditor.cpp +++ b/mozilla/editor/libeditor/base/nsEditor.cpp @@ -50,6 +50,9 @@ #include "nsIStyleContext.h" #include "nsIEditActionListener.h" +#include "nsEditorShell.h" +#include "nsEditorShellFactory.h" + #include "nsIContent.h" #include "nsIContentIterator.h" #include "nsLayoutCID.h" @@ -98,7 +101,8 @@ static NS_DEFINE_CID(kCRangeCID, NS_RANGE_CID); static NS_DEFINE_CID(kEditorCID, NS_EDITOR_CID); static NS_DEFINE_CID(kTextEditorCID, NS_TEXTEDITOR_CID); static NS_DEFINE_CID(kHTMLEditorCID, NS_HTMLEDITOR_CID); -static NS_DEFINE_CID(kCContentIteratorCID, NS_CONTENTITERATOR_CID); +static NS_DEFINE_IID(kEditorShellCID, NS_EDITORAPPCORE_CID); +static NS_DEFINE_CID(kCContentIteratorCID, NS_CONTENTITERATOR_CID); // transaction manager static NS_DEFINE_CID(kCTransactionManagerCID, NS_TRANSACTIONMANAGER_CID); @@ -162,7 +166,7 @@ PRInt32 nsEditor::gInstanceCount = 0; -PRMonitor *getEditorMonitor() //if more than one person asks for the monitor at the same time for the FIRST time, we are screwed +PRMonitor *GetEditorMonitor() //if more than one person asks for the monitor at the same time for the FIRST time, we are screwed { static PRMonitor *ns_editlock = nsnull; if (nsnull == ns_editlock) @@ -171,7 +175,7 @@ PRMonitor *getEditorMonitor() //if more than one person asks for the monitor at ns_editlock = PR_NewMonitor(); } else if ((PRMonitor *)1 == ns_editlock) - return getEditorMonitor(); + return GetEditorMonitor(); return ns_editlock; } @@ -202,6 +206,7 @@ extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports * aServMgr, if (NS_FAILED(rv)) return rv; rv = NS_NOINTERFACE; + if (aClass.Equals(kEditorCID)) { rv = GetEditFactory(aFactory, aClass); if (NS_FAILED(rv)) goto done; @@ -214,7 +219,11 @@ extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports * aServMgr, rv = GetHTMLEditFactory(aFactory, aClass); if (NS_FAILED(rv)) goto done; } - + else if (aClass.Equals(kEditorShellCID)) { + rv = GetEditorShellFactory(aFactory, aClass, aClassName, aProgID); + if (NS_FAILED(rv)) goto done; + } + done: (void)servMgr->ReleaseService(kComponentManagerCID, gCompMgr); @@ -252,6 +261,17 @@ NSRegisterSelf(nsISupports* aServMgr, const char *path) if (NS_FAILED(rv)) goto done; rv = compMgr->RegisterComponent(kHTMLEditorCID, NULL, NULL, path, PR_TRUE, PR_TRUE); + if (NS_FAILED(rv)) goto done; + rv = compMgr->RegisterComponent(kEditorShellCID, + "Editor Shell Component", + "component://netscape/editor/editorshell", + path, PR_TRUE, PR_TRUE); + + if (NS_FAILED(rv)) goto done; + rv = compMgr->RegisterComponent(kEditorShellCID, + "Editor Shell Spell Checker", + "component://netscape/editor/editorspellcheck", + path, PR_TRUE, PR_TRUE); done: (void)servMgr->ReleaseService(kComponentManagerCID, compMgr); @@ -272,11 +292,13 @@ NSUnregisterSelf(nsISupports* aServMgr, const char *path) (nsISupports**)&compMgr); if (NS_FAILED(rv)) return rv; - rv = compMgr->UnregisterComponent(kIEditFactoryIID, path); + rv = compMgr->UnregisterComponent(kEditorCID, path); if (NS_FAILED(rv)) goto done; - rv = compMgr->UnregisterComponent(kITextEditFactoryIID, path); + rv = compMgr->UnregisterComponent(kTextEditorCID, path); if (NS_FAILED(rv)) goto done; - rv = compMgr->UnregisterComponent(kIHTMLEditFactoryIID, path); + rv = compMgr->UnregisterComponent(kHTMLEditorCID, path); + if (NS_FAILED(rv)) goto done; + rv = compMgr->UnregisterComponent(kEditorShellCID, path); done: (void)servMgr->ReleaseService(kComponentManagerCID, compMgr); @@ -301,10 +323,10 @@ nsEditor::nsEditor() //initialize member variables here NS_INIT_REFCNT(); mIMEFirstTransaction=PR_FALSE; - PR_EnterMonitor(getEditorMonitor()); + PR_EnterMonitor(GetEditorMonitor()); gInstanceCount++; mActionListeners = 0; - PR_ExitMonitor(getEditorMonitor()); + PR_ExitMonitor(GetEditorMonitor()); mPrefs = 0; } diff --git a/mozilla/editor/libeditor/base/nsEditor.h b/mozilla/editor/libeditor/base/nsEditor.h index b15ce5eb25b..c113c0900d0 100644 --- a/mozilla/editor/libeditor/base/nsEditor.h +++ b/mozilla/editor/libeditor/base/nsEditor.h @@ -58,7 +58,7 @@ class nsJSEditorLog; #endif // ENABLE_JS_EDITOR_LOG //This is the monitor for the editor. -PRMonitor *getEditorMonitor(); +PRMonitor *GetEditorMonitor(); /** implementation of an editor object. it will be the controler/focal point