Added new files for Editor Gui Manager

This commit is contained in:
cmanske%netscape.com 1998-12-09 19:23:49 +00:00
Родитель 3b50597020
Коммит 04ee987583
2 изменённых файлов: 186 добавлений и 0 удалений

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

@ -0,0 +1,123 @@
/* -*- Mode: C++; tab-width: 2; 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://wwwt.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.
*/
#include "nsGuiManagerFactory.h"
#include "nsIEditor.h"
#include "editor.h"
#include "nsRepository.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
static NS_DEFINE_IID(kIEditGuiManagerIID, NS_IEDITGUIMANAGER_IID);
static NS_DEFINE_IID(kIGuiManagerFactoryIID, NS_IGUIMANAGERFACTORY_IID);
nsresult
getGuiManagerFactory(nsIFactory **aFactory)
{
static COM_auto_ptr<nsIFactory> g_pNSIFactory;
PR_EnterMonitor(getEditorMonitor());
nsresult result = NS_ERROR_FAILURE;
if (!g_pNSIFactory)
{
nsGuiManagerFactory *factory = new nsGuiManagerFactory(getter_AddRefs(g_pNSIFactory));
*aFactory = g_pNSIFactory;
NS_IF_ADDREF(*aFactory);
if (factory)
result = NS_OK;
}
else
result = g_pNSIFactory->QueryInterface(kIFactoryIID, (void **)aFactory);
PR_ExitMonitor(getEditorMonitor());
return result;
}
////////////////////////////////////////////////////////////////////////////
// from nsISupports
NS_METHOD
nsGuiManagerFactory::QueryInterface(const nsIID& aIID, void** aInstancePtr)
{
if (NULL == aInstancePtr) {
NS_NOTREACHED("!nsEditGuiManager");
return NS_ERROR_NULL_POINTER;
}
if (aIID.Equals(kIFactoryIID) ||
aIID.Equals(kISupportsIID)) {
*aInstancePtr = (void*) this;
AddRef();
return NS_OK;
}
return NS_NOINTERFACE;
}
NS_IMPL_ADDREF(nsGuiManagerFactory)
NS_IMPL_RELEASE(nsGuiManagerFactory)
////////////////////////////////////////////////////////////////////////////
// from nsIFactory:
NS_METHOD
nsGuiManagerFactory::CreateInstance(nsISupports *aOuter, REFNSIID aIID, void **aResult)
{
nsEditGuiManager *guimgr = NULL;
*aResult = NULL;
if (aOuter && !aIID.Equals(kISupportsIID))
return NS_NOINTERFACE; // XXX right error?
guimgr = new nsEditGuiManager();
if (NS_FAILED(guimgr->QueryInterface(aIID,(void**)aResult))) {
// then we're trying get a interface other than nsISupports and nsIEditGuiManager
delete guimgr;
return NS_ERROR_FAILURE;
}
return NS_OK;
}
NS_METHOD
nsGuiManagerFactory::LockFactory(PRBool aLock)
{
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////
// from nsFactory:
nsGuiManagerFactory::nsGuiManagerFactory(nsIFactory **aFactory)
{
NS_INIT_REFCNT();
nsresult err = NS_OK;
if (aFactory)
{
err = this->QueryInterface(kIFactoryIID, (void**)aFactory);
}
}
nsGuiManagerFactory::~nsGuiManagerFactory()
{
nsRepository::UnregisterFactory(kIGuiManagerFactoryIID, (nsIFactory *)this); //we are out of ref counts anyway
}

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

@ -0,0 +1,63 @@
/* -*- Mode: C++; tab-width: 2; 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://wwwt.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 nsGuiManagerFactory_h___
#define nsGuiManagerFactory_h___
#include "nsISupports.h"
#include "nsIFactory.h"
class nsEditGuiManager;
/*
GuiManagerFactory that can make an editor GUI manager
*/
/**
* This supplies the neccessary entrance to the edit module. it will return any
* instantiations that we need.
*/
class nsGuiManagerFactory;
nsresult getGuiManagerFactory(nsIFactory **);
class nsGuiManagerFactory : public nsIFactory {
public:
////////////////////////////////////////////////////////////////////////////
// from nsISupports and AggregatedQueryInterface:
NS_DECL_ISUPPORTS
////////////////////////////////////////////////////////////////////////////
// from nsIFactory:
NS_IMETHOD
CreateInstance(nsISupports *aOuter, REFNSIID aIID, void **aResult);
NS_IMETHOD
LockFactory(PRBool aLock);
////////////////////////////////////////////////////////////////////////////
// from nsFactory:
virtual ~nsGuiManagerFactory(void);
private:
nsGuiManagerFactory(nsIFactory **aFactory); //will fill the aFactory with the result from queryinterface
friend nsresult getGuiManagerFactory(nsIFactory **);
};
#endif //nsGuiManagerFactory_h___