Changed editor AppCore to use nsHTMLEditor instead of nsTextEditor

This commit is contained in:
cmanske%netscape.com 1999-03-02 05:32:25 +00:00
parent b71d9e04d6
commit 08d2ae207b
4 changed files with 44 additions and 23 deletions

View File

@ -68,6 +68,7 @@
#include "nsIEditor.h" #include "nsIEditor.h"
#include "nsITextEditor.h" #include "nsITextEditor.h"
#include "nsIHTMLEditor.h"
#include "nsEditorCID.h" #include "nsEditorCID.h"
#include "nsRepository.h" #include "nsRepository.h"
@ -504,6 +505,14 @@ nsEditorAppCore::SetToEditorMode(nsIDOMDocument *aDOMDocument, nsIPresShell* aPr
if (PR_TRUE==needsInit) if (PR_TRUE==needsInit)
{ {
needsInit=PR_FALSE; needsInit=PR_FALSE;
result = nsRepository::RegisterFactory(kHTMLEditorCID, EDITOR_DLL,
PR_FALSE, PR_FALSE);
if (NS_ERROR_FACTORY_EXISTS!=result)
{
if (NS_FAILED(result))
return result;
}
result = nsRepository::RegisterFactory(kTextEditorCID, EDITOR_DLL, result = nsRepository::RegisterFactory(kTextEditorCID, EDITOR_DLL,
PR_FALSE, PR_FALSE); PR_FALSE, PR_FALSE);
if (NS_ERROR_FACTORY_EXISTS!=result) if (NS_ERROR_FACTORY_EXISTS!=result)
@ -511,6 +520,7 @@ nsEditorAppCore::SetToEditorMode(nsIDOMDocument *aDOMDocument, nsIPresShell* aPr
if (NS_FAILED(result)) if (NS_FAILED(result))
return result; return result;
} }
result = nsRepository::RegisterFactory(kEditorCID, EDITOR_DLL, result = nsRepository::RegisterFactory(kEditorCID, EDITOR_DLL,
PR_FALSE, PR_FALSE); PR_FALSE, PR_FALSE);
if (NS_ERROR_FACTORY_EXISTS!=result) if (NS_ERROR_FACTORY_EXISTS!=result)
@ -522,19 +532,19 @@ nsEditorAppCore::SetToEditorMode(nsIDOMDocument *aDOMDocument, nsIPresShell* aPr
/** end temp code **/ /** end temp code **/
/* /*
nsISupports *isup = nsnull; nsISupports *isup = nsnull;
result = nsServiceManager::GetService(kTextEditorCID, result = nsServiceManager::GetService(kHTMLEditorCID,
kITextEditorIID, &isup); kIHTMLEditorIID, &isup);
*/ */
result = nsRepository::CreateInstance(kTextEditorCID, result = nsRepository::CreateInstance(kHTMLEditorCID,
nsnull, nsnull,
kITextEditorIID, (void **)&gEditor); kIHTMLEditorIID, (void **)&gEditor);
if (NS_FAILED(result)) if (NS_FAILED(result))
return result; return result;
if (!gEditor) { if (!gEditor) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
gEditor->InitTextEditor(aDOMDocument, aPresShell); gEditor->InitHTMLEditor(aDOMDocument, aPresShell);
gEditor->EnableUndo(PR_TRUE); gEditor->EnableUndo(PR_TRUE);
#endif #endif
return result; return result;

View File

@ -36,7 +36,7 @@ class nsIDOMWindow;
class nsIURL; class nsIURL;
class nsIWebShellWindow; class nsIWebShellWindow;
class nsIPresShell; class nsIPresShell;
class nsITextEditor; class nsIHTMLEditor;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// nsEditorAppCore: // nsEditorAppCore:
@ -92,7 +92,7 @@ class nsEditorAppCore : public nsBaseAppCore,
nsIWebShellWindow *mWebShellWin; nsIWebShellWindow *mWebShellWin;
nsIWebShell * mWebShell; nsIWebShell * mWebShell;
nsITextEditor * mEditor; nsIHTMLEditor * mEditor;
nsIDOMDocument* mDomDoc; nsIDOMDocument* mDomDoc;
nsIDOMNode* mCurrentNode; nsIDOMNode* mCurrentNode;

View File

@ -19,18 +19,21 @@
#include "nsString.h" #include "nsString.h"
#include "nsIDOMDocument.h" #include "nsIDOMDocument.h"
#include "nsITextEditor.h" #include "nsIHTMLEditor.h"
#include "nsEditorCID.h" #include "nsEditorCID.h"
#include "nsRepository.h" #include "nsRepository.h"
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
static nsITextEditor *gEditor; static nsIHTMLEditor *gEditor;
static NS_DEFINE_IID(kITextEditorIID, NS_ITEXTEDITOR_IID); static NS_DEFINE_IID(kIHTMLEditorIID, NS_IHTMLEDITOR_IID);
static NS_DEFINE_CID(kTextEditorCID, NS_TEXTEDITOR_CID); static NS_DEFINE_CID(kHTMLEditorCID, NS_HTMLEDITOR_CID);
static NS_DEFINE_IID(kIEditorIID, NS_IEDITOR_IID); static NS_DEFINE_IID(kIEditorIID, NS_IEDITOR_IID);
static NS_DEFINE_CID(kEditorCID, NS_EDITOR_CID); static NS_DEFINE_CID(kEditorCID, NS_EDITOR_CID);
static NS_DEFINE_CID(kTextEditorCID, NS_TEXTEDITOR_CID); // Still needed to register factory
//Don't think we these - switched to using HTMLEditor
//static NS_DEFINE_IID(kITextEditorIID, NS_ITEXTEDITOR_IID);
#ifdef XP_PC #ifdef XP_PC
#define EDITOR_DLL "ender.dll" #define EDITOR_DLL "ender.dll"
@ -42,7 +45,7 @@ static NS_DEFINE_CID(kEditorCID, NS_EDITOR_CID);
#endif #endif
#endif #endif
nsITextEditor * GetEditor() nsIHTMLEditor * GetEditor()
{ {
return gEditor; return gEditor;
} }
@ -65,15 +68,22 @@ nsresult NS_InitEditorMode(nsIDOMDocument *aDOMDocument, nsIPresShell* aPresShel
if (PR_TRUE==needsInit) if (PR_TRUE==needsInit)
{ {
needsInit=PR_FALSE; needsInit=PR_FALSE;
result = nsRepository::RegisterComponent(kTextEditorCID, NULL, NULL, result = nsRepository::RegisterComponent(kHTMLEditorCID, NULL, NULL, EDITOR_DLL,
EDITOR_DLL, PR_FALSE, PR_FALSE); PR_FALSE, PR_FALSE);
if (NS_ERROR_FACTORY_EXISTS!=result) if (NS_ERROR_FACTORY_EXISTS!=result)
{ {
if (NS_FAILED(result)) if (NS_FAILED(result))
return result; return result;
} }
result = nsRepository::RegisterComponent(kEditorCID, NULL, NULL, result = nsRepository::RegisterComponent(kTextEditorCID, NULL, NULL, EDITOR_DLL,
EDITOR_DLL, PR_FALSE, PR_FALSE); PR_FALSE, PR_FALSE);
if (NS_ERROR_FACTORY_EXISTS!=result)
{
if (NS_FAILED(result))
return result;
}
result = nsRepository::RegisterComponent(kEditorCID, NULL, NULL, EDITOR_DLL,
PR_FALSE, PR_FALSE);
if (NS_ERROR_FACTORY_EXISTS!=result) if (NS_ERROR_FACTORY_EXISTS!=result)
{ {
if (NS_FAILED(result)) if (NS_FAILED(result))
@ -83,20 +93,21 @@ nsresult NS_InitEditorMode(nsIDOMDocument *aDOMDocument, nsIPresShell* aPresShel
/** end temp code **/ /** end temp code **/
/* /*
nsISupports *isup = nsnull; nsISupports *isup = nsnull;
result = nsServiceManager::GetService(kTextEditorCID, result = nsServiceManager::GetService(kHTMLEditorCID,
kITextEditorIID, &isup); kIHTMLEditorIID, &isup);
*/ */
result = nsRepository::CreateInstance(kTextEditorCID, result = nsRepository::CreateInstance(kHTMLEditorCID,
nsnull, nsnull,
kITextEditorIID, (void **)&gEditor); kIHTMLEditorIID, (void **)&gEditor);
if (NS_FAILED(result)) if (NS_FAILED(result))
return result; return result;
if (!gEditor) { if (!gEditor) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
gEditor->InitTextEditor(aDOMDocument, aPresShell); gEditor->InitHTMLEditor(aDOMDocument, aPresShell);
gEditor->EnableUndo(PR_TRUE); gEditor->EnableUndo(PR_TRUE);
return result; return result;
} }

View File

@ -23,9 +23,9 @@
class nsIDOMDocument; class nsIDOMDocument;
class nsIPresShell; class nsIPresShell;
class nsITextEditor; class nsIHTMLEditor;
extern nsresult NS_InitEditorMode(nsIDOMDocument * aDOMDocument, nsIPresShell* aPresShell); extern nsresult NS_InitEditorMode(nsIDOMDocument * aDOMDocument, nsIPresShell* aPresShell);
extern nsITextEditor * GetEditor(); extern nsIHTMLEditor * GetEditor();
#endif //nsEditorMode_h__ #endif //nsEditorMode_h__