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
Родитель 84cced84b0
Коммит f67f43cace
4 изменённых файлов: 42 добавлений и 52 удалений

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

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

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

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

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

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

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

@ -1,31 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsEditorMode_h__
#define nsEditorMode_h__
#include "nsError.h"
class nsIDOMDocument;
class nsIPresShell;
class nsITextEditor;
extern nsresult NS_InitEditorMode(nsIDOMDocument * aDOMDocument, nsIPresShell* aPresShell);
extern nsITextEditor * GetEditor();
#endif //nsEditorMode_h__