Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions | Variables
nsEditorRegistration.cpp File Reference
#include "nsIGenericFactory.h"
#include "nsEditorCID.h"
#include "nsEditor.h"
#include "nsPlaintextEditor.h"
#include "nsEditorController.h"
#include "nsIController.h"
#include "nsIControllerContext.h"
#include "nsIControllerCommandTable.h"
#include "nsIServiceManager.h"
#include "nsIObserver.h"
#include "nsIObserverService.h"
#include "nsCOMPtr.h"
#include "nsIParserService.h"
#include "nsHTMLEditor.h"
#include "nsTextServicesDocument.h"
#include "nsTextServicesCID.h"

Go to the source code of this file.

Classes

class  EditorShutdownObserver

Defines

#define NS_EDITORCOMMANDTABLE_CID   { 0x4f5e62b8, 0xd659, 0x4156, { 0x84, 0xfc, 0x2f, 0x60, 0x99, 0x40, 0x03, 0x69 }}

Functions

static NS_DEFINE_CID (kEditorCommandTableCID, NS_EDITORCOMMANDTABLE_CID)
 PR_STATIC_CALLBACK (nsresult) Initialize(nsIModule *self)
static void Shutdown ()
 Initialize (nsIModule *self)
static NS_METHOD nsEditorControllerConstructor (nsISupports *aOuter, REFNSIID aIID, void **aResult)
static NS_METHOD nsEditorCommandTableConstructor (nsISupports *aOuter, REFNSIID aIID, void **aResult)

Variables

static PRBool gInitialized = PR_FALSE
nsIParserServicesParserService
static const nsModuleComponentInfo components []

Define Documentation

#define NS_EDITORCOMMANDTABLE_CID   { 0x4f5e62b8, 0xd659, 0x4156, { 0x84, 0xfc, 0x2f, 0x60, 0x99, 0x40, 0x03, 0x69 }}

Definition at line 60 of file nsEditorRegistration.cpp.


Function Documentation

Initialize ( nsIModule self)

Definition at line 92 of file nsEditorRegistration.cpp.

{
  NS_PRECONDITION(!gInitialized, "module already initialized");
  if (gInitialized) {
    return NS_OK;
  }

  gInitialized = PR_TRUE;

  nsresult rv = CallGetService("@mozilla.org/parser/parser-service;1",
                               &sParserService);
  if (NS_FAILED(rv)) {
    gInitialized = PR_FALSE;

    return rv;
  }
#ifndef MOZILLA_PLAINTEXT_EDITOR_ONLY
  nsEditProperty::RegisterAtoms();
  nsTextServicesDocument::RegisterAtoms();
#endif

  // Add our shutdown observer.
  nsCOMPtr<nsIObserverService> observerService =
    do_GetService("@mozilla.org/observer-service;1");

  if (observerService) {
    nsCOMPtr<EditorShutdownObserver> observer =
      new EditorShutdownObserver();

    if (!observer) {
      Shutdown();

      return NS_ERROR_OUT_OF_MEMORY;
    }

    observerService->AddObserver(observer, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE);
  } else {
    NS_WARNING("Could not get an observer service.  We will leak on shutdown.");
  }

  return NS_OK;
}

Here is the call graph for this function:

static NS_DEFINE_CID ( kEditorCommandTableCID  ,
NS_EDITORCOMMANDTABLE_CID   
) [static]
static NS_METHOD nsEditorCommandTableConstructor ( nsISupports *  aOuter,
REFNSIID  aIID,
void **  aResult 
) [static]

Definition at line 182 of file nsEditorRegistration.cpp.

{
  nsresult rv;
  nsCOMPtr<nsIControllerCommandTable> commandTable =
      do_CreateInstance(NS_CONTROLLERCOMMANDTABLE_CONTRACTID, &rv);
  if (NS_FAILED(rv)) return rv;
  
  rv = nsEditorController::RegisterEditorCommands(commandTable);
  if (NS_FAILED(rv)) return rv;
  
  // we don't know here whether we're being created as an instance,
  // or a service, so we can't become immutable

  return commandTable->QueryInterface(aIID, aResult);
}

Here is the call graph for this function:

static NS_METHOD nsEditorControllerConstructor ( nsISupports *  aOuter,
REFNSIID  aIID,
void **  aResult 
) [static]

Definition at line 157 of file nsEditorRegistration.cpp.

{
  nsresult rv;
  nsCOMPtr<nsIController> controller = do_CreateInstance("@mozilla.org/embedcomp/base-command-controller;1", &rv);
  if (NS_FAILED(rv)) return rv;

  nsCOMPtr<nsIControllerCommandTable> editorCommandTable = do_GetService(kEditorCommandTableCID, &rv);
  if (NS_FAILED(rv)) return rv;
  
  // this guy is a singleton, so make it immutable
  editorCommandTable->MakeImmutable();
  
  nsCOMPtr<nsIControllerContext> controllerContext = do_QueryInterface(controller, &rv);
  if (NS_FAILED(rv)) return rv;
  
  rv = controllerContext->Init(editorCommandTable);
  if (NS_FAILED(rv)) return rv;
  
  return controller->QueryInterface(aIID, aResult);
}

Here is the call graph for this function:

Definition at line 602 of file nsNetModule.cpp.

{
    gNetStrings = new nsNetStrings();
    return gNetStrings ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
void Shutdown ( void  ) [static]

Definition at line 137 of file nsEditorRegistration.cpp.

{
  NS_PRECONDITION(gInitialized, "module not initialized");
  if (!gInitialized)
    return;

  NS_IF_RELEASE(sParserService);

#ifndef MOZILLA_PLAINTEXT_EDITOR_ONLY
  nsHTMLEditor::Shutdown();
  nsTextServicesDocument::Shutdown();
#endif
}

Here is the call graph for this function:


Variable Documentation

Initial value:
 {
    { "Text Editor", NS_TEXTEDITOR_CID,
      "@mozilla.org/editor/texteditor;1", nsPlaintextEditorConstructor, },






    { "HTML Editor", NS_HTMLEDITOR_CID,
      "@mozilla.org/editor/htmleditor;1", nsHTMLEditorConstructor, },



    { "Editor Controller", NS_EDITORCONTROLLER_CID,
      "@mozilla.org/editor/editorcontroller;1",
      nsEditorControllerConstructor, },

    { "Editor Command Table", NS_EDITORCOMMANDTABLE_CID,
      "",   
      nsEditorCommandTableConstructor, },


    { NULL, NS_TEXTSERVICESDOCUMENT_CID,
      "@mozilla.org/textservices/textservicesdocument;1",
      nsTextServicesDocumentConstructor },

}

Definition at line 215 of file nsEditorRegistration.cpp.

Definition at line 87 of file nsEditorRegistration.cpp.

Definition at line 89 of file nsEditorRegistration.cpp.