nsresult rv = aServMgr->QueryInterface(nsIComponentManager::GetIID(), (void**)&gCompMgr);
nsresult rv; nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &rv)); if (NS_FAILED(rv)) return rv;  rv = servMgr->GetService(kComponentManagerCID, nsIComponentManager::GetIID(), (nsISupports**)&gCompMgr);
extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports * aServMgr,                                            const nsCID & aClass,                                            const char *aClassName,                                           const char *aProgID,                                           nsIFactory ** aFactory){  if (nsnull == aFactory) {    return NS_ERROR_NULL_POINTER;  }  *aFactory = nsnull;  nsresult rv = aServMgr->QueryInterface(nsIComponentManager::GetIID(), (void**)&gCompMgr);  if (NS_FAILED(rv)) return rv;  if (aClass.Equals(kEditorCID)) {    return GetEditFactory(aFactory, aClass);  }  else if (aClass.Equals(kTextEditorCID)) {    return GetTextEditFactory(aFactory, aClass);  }  else if (aClass.Equals(kHTMLEditorCID)) {    return GetHTMLEditFactory(aFactory, aClass);  }  return NS_NOINTERFACE;}