Changes to turn gfxps into a true component. Thanks to alecf@netscape.com

for providing the base patch.
This commit is contained in:
ramiro%netscape.com 1999-06-25 09:46:59 +00:00
Родитель d8d97c2ae3
Коммит 962bba7c73
3 изменённых файлов: 236 добавлений и 0 удалений

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

@ -0,0 +1,168 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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.
*/
#include "nscore.h"
#include "nsIFactory.h"
#include "nsDeviceContextPS.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsGfxPSCID.h"
#include "nsCOMPtr.h"
static NS_DEFINE_CID(kCDeviceContextPS, NS_DEVICECONTEXTPS_CID);
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
class nsGfxFactoryPS : public nsIFactory
{
public:
NS_DECL_ISUPPORTS
NS_IMETHOD CreateInstance(nsISupports *aOuter,
const nsIID &aIID,
void **aResult);
NS_IMETHOD LockFactory(PRBool aLock);
nsGfxFactoryPS(const nsCID &aClass);
virtual ~nsGfxFactoryPS();
private:
nsCID mClassID;
};
nsGfxFactoryPS::nsGfxFactoryPS(const nsCID &aClass) :
mRefCnt(0),
mClassID(aClass)
{
}
nsGfxFactoryPS::~nsGfxFactoryPS()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMPL_ISUPPORTS(nsGfxFactoryPS, nsIFactory::GetIID())
NS_IMETHODIMP
nsGfxFactoryPS::CreateInstance(nsISupports *aOuter,
const nsIID &aIID,
void **aResult)
{
if (aResult == nsnull) {
return NS_ERROR_NULL_POINTER;
}
*aResult = nsnull;
nsISupports *inst = nsnull;
if (mClassID.Equals(kCDeviceContextPS)) {
inst = (nsISupports *)(nsIDeviceContextPS*)new nsDeviceContextPS();
}
if (inst == nsnull) {
return NS_ERROR_OUT_OF_MEMORY;
}
nsresult rv = inst->QueryInterface(aIID, aResult);
if (rv != NS_OK) {
delete inst;
}
return rv;
}
nsresult nsGfxFactoryPS::LockFactory(PRBool aLock)
{
// Not implemented in simplest case.
return NS_OK;
}
nsresult
NSGetFactory(nsISupports* servMgr,
const nsCID &aClass,
const char *aClassName,
const char *aProgID,
nsIFactory **aFactory)
{
if (nsnull == aFactory) {
return NS_ERROR_NULL_POINTER;
}
*aFactory = new nsGfxFactoryPS(aClass);
if (nsnull == aFactory) {
return NS_ERROR_OUT_OF_MEMORY;
}
return (*aFactory)->QueryInterface(nsIFactory::GetIID(), (void**)aFactory);
}
PRBool
NSCanUnload(nsISupports* aServMgr)
{
return PR_TRUE;
}
nsresult
NSRegisterSelf(nsISupports* aServMgr, const char *fullpath)
{
nsresult rv;
#ifdef NS_DEBUG
printf("*** Registering GFX Postscript\n");
#endif
nsCOMPtr<nsIServiceManager>
serviceManager(do_QueryInterface(aServMgr, &rv));
if (NS_FAILED(rv)) return rv;
NS_WITH_SERVICE(nsIComponentManager, compMgr, kComponentManagerCID, &rv);
if (NS_FAILED(rv)) return rv;
rv = compMgr->RegisterComponent(kCDeviceContextPS,
"GFX Postscript Device Context",
"component://netscape/gfx/devicecontext/ps",
fullpath,
PR_TRUE, PR_TRUE);
return rv;
}
nsresult
NSUnregisterSelf(nsISupports* aServMgr, const char *fullpath)
{
nsresult rv;
nsCOMPtr<nsIServiceManager>
serviceManager(do_QueryInterface(aServMgr, &rv));
if (NS_FAILED(rv)) return rv;
NS_WITH_SERVICE(nsIComponentManager, compMgr, kComponentManagerCID, &rv);
if (NS_FAILED(rv)) return rv;
compMgr->UnregisterComponent(kCDeviceContextPS, fullpath);
return NS_OK;
}

27
gfx/src/ps/nsGfxPSCID.h Normal file
Просмотреть файл

@ -0,0 +1,27 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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 nsGfxFactoryPS_h__
#define nsGfxFactoryPS_h__
/* {4c2bb896-13c9-11d3-9304-006008948010} */
#define NS_DEVICECONTEXTPS_CID \
{0x4c2bb896, 0x13c9, 0x11d3, \
{0x93, 0x04, 0x00, 0x60, 0x08, 0x94, 0x80, 0x10}}
#endif

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

@ -0,0 +1,41 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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.
*/
#include "nsISupports.h"
#ifndef __nsIDeviceContextPS_h
#define __nsIDeviceContextPS_h
/* {35efd8b6-13cc-11d3-9d3a-006008948010} */
#define NS_IDEVICECONTEXTPS_IID \
{0x35efd8b6, 0x13cc, 0x11d3, \
{0x9d, 0x3a, 0x00, 0x60, 0x08, 0x94, 0x80, 0x10}}
class nsIDeviceContextPS : public nsISupports
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDEVICECONTEXTPS_IID);
NS_IMETHOD SetSpec(nsIDeviceContextSpec *aSpec) = 0;
NS_IMETHOD InitDeviceContextPS(nsIDeviceContext *aCreatingDeviceContext,
nsIDeviceContext *aPrinterContext) = 0;
};
#endif