fix for 22921; use nsIModule;
This commit is contained in:
Родитель
83b9b7ba19
Коммит
fefa085c9e
|
@ -39,51 +39,71 @@
|
|||
// Class ID for our UnicodeToTeXCMSYttf (TeX Symbol -TTF) charset converter
|
||||
// {e332db00-e076-11d3-b32f-004005a7a7e4}
|
||||
NS_DECLARE_ID(kUnicodeToTeXCMSYttfCID,
|
||||
0xe332db00, 0xe076, 0x11d3, 0xb3, 0x2f, 0x0, 0x40, 0x05, 0xa7, 0xa7, 0xe4);
|
||||
0xe332db00, 0xe076, 0x11d3, 0xb3, 0x2f, 0x0, 0x40, 0x05, 0xa7, 0xa7, 0xe4);
|
||||
#define NS_UNICODETOTEXCMSYTTF_CID \
|
||||
{ 0xe332db00, 0xe076, 0x11d3, {0xb3, 0x2f, 0x0, 0x40, 0x05, 0xa7, 0xa7, 0xe4}}
|
||||
|
||||
// Class ID for our UnicodeToTeXCMEXttf (TeX Extension -TTF) charset converter
|
||||
// {e91f9440-e076-11d3-b32f-004005a7a7e4}
|
||||
NS_DECLARE_ID(kUnicodeToTeXCMEXttfCID,
|
||||
0xe91f9440, 0xe076, 0x11d3, 0xb3, 0x2f, 0x0, 0x40, 0x05, 0xa7, 0xa7, 0xe4);
|
||||
0xe91f9440, 0xe076, 0x11d3, 0xb3, 0x2f, 0x0, 0x40, 0x05, 0xa7, 0xa7, 0xe4);
|
||||
#define NS_UNICODETOTEXCMEXTTF_CID \
|
||||
{ 0xe91f9440, 0xe076, 0x11d3, {0xb3, 0x2f, 0x0, 0x40, 0x05, 0xa7, 0xa7, 0xe4}}
|
||||
|
||||
// Class ID for our UnicodeToTeXCMSYt1 (TeX Symbol -Type1) charset converter
|
||||
// {e768ebef-70f9-4fe3-8835-4f4f3fd996e2}
|
||||
NS_DECLARE_ID(kUnicodeToTeXCMSYt1CID,
|
||||
0xe768ebef, 0x70f9, 0x4fe3, 0x88, 0x35, 0x4f, 0x4f, 0x3f, 0xd9, 0x96, 0xe2);
|
||||
0xe768ebef, 0x70f9, 0x4fe3, 0x88, 0x35, 0x4f, 0x4f, 0x3f, 0xd9, 0x96, 0xe2);
|
||||
#define NS_UNICODETOTEXCMSYT1_CID \
|
||||
{ 0xe768ebef, 0x70f9, 0x4fe3, {0x88, 0x35, 0x4f, 0x4f, 0x3f, 0xd9, 0x96, 0xe2}}
|
||||
|
||||
// Class ID for our UnicodeToTeXCMEXt1 (TeX Extension -Type1) charset converter
|
||||
// {f01cb3e7-4ace-414e-a2b7-eaba03e9c86c}
|
||||
NS_DECLARE_ID(kUnicodeToTeXCMEXt1CID,
|
||||
0xf01cb3e7, 0x4ace, 0x414e, 0xa2, 0xb7, 0xea, 0xba, 0x03, 0xe9, 0xc8, 0x6c);
|
||||
0xf01cb3e7, 0x4ace, 0x414e, 0xa2, 0xb7, 0xea, 0xba, 0x03, 0xe9, 0xc8, 0x6c);
|
||||
#define NS_UNICODETOTEXCMEXT1_CID \
|
||||
{ 0xf01cb3e7, 0x4ace, 0x414e, {0xa2, 0xb7, 0xea, 0xba, 0x03, 0xe9, 0xc8, 0x6c}}
|
||||
|
||||
// Class ID for our UnicodeToMathematica1 charset converter
|
||||
// {758e4f20-e2f2-11d3-b32f-004005a7a7e4}
|
||||
NS_DECLARE_ID(kUnicodeToMathematica1CID,
|
||||
0x758e4f20, 0xe2f2, 0x11d3, 0xb3, 0x2f, 0x0, 0x40, 0x05, 0xa7, 0xa7, 0xe4);
|
||||
0x758e4f20, 0xe2f2, 0x11d3, 0xb3, 0x2f, 0x0, 0x40, 0x05, 0xa7, 0xa7, 0xe4);
|
||||
#define NS_UNICODETOMATHEMATICA1_CID \
|
||||
{ 0x758e4f20, 0xe2f2, 0x11d3, {0xb3, 0x2f, 0x0, 0x40, 0x05, 0xa7, 0xa7, 0xe4}}
|
||||
|
||||
// Class ID for our UnicodeToMathematica2 charset converter
|
||||
// {7e6e57c0-e2f2-11d3-b32f-004005a7a7e4}
|
||||
NS_DECLARE_ID(kUnicodeToMathematica2CID,
|
||||
0x7e6e57c0, 0xe2f2, 0x11d3, 0xb3, 0x2f, 0x0, 0x40, 0x05, 0xa7, 0xa7, 0xe4);
|
||||
0x7e6e57c0, 0xe2f2, 0x11d3, 0xb3, 0x2f, 0x0, 0x40, 0x05, 0xa7, 0xa7, 0xe4);
|
||||
#define NS_UNICODETOMATHEMATICA2_CID \
|
||||
{ 0x7e6e57c0, 0xe2f2, 0x11d3, {0xb3, 0x2f, 0x0, 0x40, 0x05, 0xa7, 0xa7, 0xe4}}
|
||||
|
||||
// Class ID for our UnicodeToMathematica3 charset converter
|
||||
// {830b5f80-11d3-b32f-004005a7a7e4}
|
||||
NS_DECLARE_ID(kUnicodeToMathematica3CID,
|
||||
0x830b5f80, 0xe2f2, 0x11d3, 0xb3, 0x2f, 0x0, 0x40, 0x05, 0xa7, 0xa7, 0xe4);
|
||||
0x830b5f80, 0xe2f2, 0x11d3, 0xb3, 0x2f, 0x0, 0x40, 0x05, 0xa7, 0xa7, 0xe4);
|
||||
#define NS_UNICODETOMATHEMATICA3_CID \
|
||||
{ 0x830b5f80, 0xe2f2, 0x11d3, {0xb3, 0x2f, 0x0, 0x40, 0x05, 0xa7, 0xa7, 0xe4}}
|
||||
|
||||
// Class ID for our UnicodeToMathematica4 charset converter
|
||||
// {87ed1160-e2f2-11d3-b32f-004005a7a7e4}
|
||||
NS_DECLARE_ID(kUnicodeToMathematica4CID,
|
||||
0x87ed1160, 0xe2f2, 0x11d3, 0xb3, 0x2f, 0x0, 0x40, 0x05, 0xa7, 0xa7, 0xe4);
|
||||
0x87ed1160, 0xe2f2, 0x11d3, 0xb3, 0x2f, 0x0, 0x40, 0x05, 0xa7, 0xa7, 0xe4);
|
||||
#define NS_UNICODETOMATHEMATICA4_CID \
|
||||
{ 0x87ed1160, 0xe2f2, 0x11d3, {0xb3, 0x2f, 0x0, 0x40, 0x05, 0xa7, 0xa7, 0xe4}}
|
||||
|
||||
// Class ID for our UnicodeToMathematica5 charset converter
|
||||
// {8a0dce80-e2f2-11d3-b32f-004005a7a7e4}
|
||||
NS_DECLARE_ID(kUnicodeToMathematica5CID,
|
||||
0x8a0dce80, 0xe2f2, 0x11d3, 0xb3, 0x2f, 0x0, 0x40, 0x05, 0xa7, 0xa7, 0xe4);
|
||||
0x8a0dce80, 0xe2f2, 0x11d3, 0xb3, 0x2f, 0x0, 0x40, 0x05, 0xa7, 0xa7, 0xe4);
|
||||
#define NS_UNICODETOMATHEMATICA5_CID \
|
||||
{ 0x8a0dce80, 0xe2f2, 0x11d3, {0xb3, 0x2f, 0x0, 0x40, 0x05, 0xa7, 0xa7, 0xe4}}
|
||||
|
||||
// Class ID for our UnicodeToMTExtra charset converter
|
||||
// {0cb0d9a0-f503-11d3-b32f-004005a7a7e4}
|
||||
NS_DECLARE_ID(kUnicodeToMTExtraCID,
|
||||
0x0cb0d9a0, 0xf503, 0x11d3, 0xb3, 0x2f, 0x0, 0x40, 0x05, 0xa7, 0xa7, 0xe4);
|
||||
0x0cb0d9a0, 0xf503, 0x11d3, 0xb3, 0x2f, 0x0, 0x40, 0x05, 0xa7, 0xa7, 0xe4);
|
||||
#define NS_UNICODETOMTEXTRA_CID \
|
||||
{ 0x0cb0d9a0, 0xf503, 0x11d3, {0xb3, 0x2f, 0x0, 0x40, 0x05, 0xa7, 0xa7, 0xe4}}
|
||||
|
||||
#endif /* nsUCvMathCID_h___ */
|
||||
|
|
|
@ -39,7 +39,9 @@
|
|||
#include "nsCOMPtr.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIRegistry.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsIModule.h"
|
||||
#include "nsUCvMathCID.h"
|
||||
#include "nsUCvMathDll.h"
|
||||
|
@ -66,386 +68,93 @@ static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
|||
PRInt32 g_InstanceCount = 0;
|
||||
PRInt32 g_LockCount = 0;
|
||||
|
||||
typedef nsresult (* fpCreateInstance) (nsISupports **);
|
||||
NS_IMPL_NSUCONVERTERREGSELF
|
||||
|
||||
struct FactoryData
|
||||
NS_UCONV_REG_UNREG(nsUnicodeToTeXCMSYttf, "Unicode", "x-ttf-cmsy", NS_UNICODETOTEXCMSYTTF_CID);
|
||||
NS_UCONV_REG_UNREG(nsUnicodeToTeXCMSYt1, "Unicode", "x-t1-cmsy", NS_UNICODETOTEXCMSYT1_CID);
|
||||
NS_UCONV_REG_UNREG(nsUnicodeToTeXCMEXttf, "Unicode", "x-ttf-cmex", NS_UNICODETOTEXCMEXTTF_CID);
|
||||
NS_UCONV_REG_UNREG(nsUnicodeToTeXCMEXt1, "Unicode", "x-t1-cmex", NS_UNICODETOTEXCMEXT1_CID);
|
||||
NS_UCONV_REG_UNREG(nsUnicodeToMathematica1, "Unicode", "x-mathematica1", NS_UNICODETOMATHEMATICA1_CID);
|
||||
NS_UCONV_REG_UNREG(nsUnicodeToMathematica2, "Unicode", "x-mathematica2", NS_UNICODETOMATHEMATICA2_CID);
|
||||
NS_UCONV_REG_UNREG(nsUnicodeToMathematica3, "Unicode", "x-mathematica3", NS_UNICODETOMATHEMATICA3_CID);
|
||||
NS_UCONV_REG_UNREG(nsUnicodeToMathematica4, "Unicode", "x-mathematica4", NS_UNICODETOMATHEMATICA4_CID);
|
||||
NS_UCONV_REG_UNREG(nsUnicodeToMathematica5, "Unicode", "x-mathematica5", NS_UNICODETOMATHEMATICA5_CID);
|
||||
NS_UCONV_REG_UNREG(nsUnicodeToMTExtra, "Unicode", "x-mtextra", NS_UNICODETOMTEXTRA_CID);
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUnicodeToTeXCMSYttf);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUnicodeToTeXCMSYt1);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUnicodeToTeXCMEXttf);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUnicodeToTeXCMEXt1);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUnicodeToMathematica1);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUnicodeToMathematica2);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUnicodeToMathematica3);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUnicodeToMathematica4);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUnicodeToMathematica5);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUnicodeToMTExtra);
|
||||
|
||||
static nsModuleComponentInfo components[] =
|
||||
{
|
||||
const nsCID * mCID;
|
||||
fpCreateInstance CreateInstance;
|
||||
char * mCharsetSrc;
|
||||
char * mCharsetDest;
|
||||
{
|
||||
ENCODER_NAME_BASE "x-ttf-cmsy" , NS_UNICODETOTEXCMSYTTF_CID,
|
||||
NS_UNICODEENCODER_CONTRACTID_BASE "x-ttf-cmsy",
|
||||
nsUnicodeToTeXCMSYttfConstructor,
|
||||
nsUnicodeToTeXCMSYttfRegSelf, nsUnicodeToTeXCMSYttfUnRegSelf
|
||||
},
|
||||
{
|
||||
ENCODER_NAME_BASE "x-t1-cmsy" , NS_UNICODETOTEXCMSYT1_CID,
|
||||
NS_UNICODEENCODER_CONTRACTID_BASE "x-t1-cmsy",
|
||||
nsUnicodeToTeXCMSYt1Constructor,
|
||||
nsUnicodeToTeXCMSYt1RegSelf, nsUnicodeToTeXCMSYt1UnRegSelf
|
||||
},
|
||||
{
|
||||
ENCODER_NAME_BASE "x-ttf-cmex" , NS_UNICODETOTEXCMEXTTF_CID,
|
||||
NS_UNICODEENCODER_CONTRACTID_BASE "x-ttf-cmex",
|
||||
nsUnicodeToTeXCMEXttfConstructor,
|
||||
nsUnicodeToTeXCMEXttfRegSelf, nsUnicodeToTeXCMEXttfUnRegSelf
|
||||
},
|
||||
{
|
||||
ENCODER_NAME_BASE "x-t1-cmex" , NS_UNICODETOTEXCMEXT1_CID,
|
||||
NS_UNICODEENCODER_CONTRACTID_BASE "x-t1-cmex",
|
||||
nsUnicodeToTeXCMEXt1Constructor,
|
||||
nsUnicodeToTeXCMEXt1RegSelf, nsUnicodeToTeXCMEXt1UnRegSelf
|
||||
},
|
||||
{
|
||||
ENCODER_NAME_BASE "x-mathematica1" , NS_UNICODETOMATHEMATICA1_CID,
|
||||
NS_UNICODEENCODER_CONTRACTID_BASE "x-mathematica1",
|
||||
nsUnicodeToMathematica1Constructor,
|
||||
nsUnicodeToMathematica1RegSelf, nsUnicodeToMathematica1UnRegSelf
|
||||
},
|
||||
{
|
||||
ENCODER_NAME_BASE "x-mathematica2" , NS_UNICODETOMATHEMATICA2_CID,
|
||||
NS_UNICODEENCODER_CONTRACTID_BASE "x-mathematica2",
|
||||
nsUnicodeToMathematica2Constructor,
|
||||
nsUnicodeToMathematica2RegSelf, nsUnicodeToMathematica2UnRegSelf
|
||||
},
|
||||
{
|
||||
ENCODER_NAME_BASE "x-mathematica3" , NS_UNICODETOMATHEMATICA3_CID,
|
||||
NS_UNICODEENCODER_CONTRACTID_BASE "x-mathematica3",
|
||||
nsUnicodeToMathematica3Constructor,
|
||||
nsUnicodeToMathematica3RegSelf, nsUnicodeToMathematica3UnRegSelf
|
||||
},
|
||||
{
|
||||
ENCODER_NAME_BASE "x-mathematica4" , NS_UNICODETOMATHEMATICA4_CID,
|
||||
NS_UNICODEENCODER_CONTRACTID_BASE "x-mathematica4",
|
||||
nsUnicodeToMathematica4Constructor,
|
||||
nsUnicodeToMathematica4RegSelf, nsUnicodeToMathematica4UnRegSelf
|
||||
},
|
||||
{
|
||||
ENCODER_NAME_BASE "x-mathematica5" , NS_UNICODETOMATHEMATICA5_CID,
|
||||
NS_UNICODEENCODER_CONTRACTID_BASE "x-mathematica5",
|
||||
nsUnicodeToMathematica5Constructor,
|
||||
nsUnicodeToMathematica5RegSelf, nsUnicodeToMathematica5UnRegSelf
|
||||
},
|
||||
{
|
||||
ENCODER_NAME_BASE "x-mtextra" , NS_UNICODETOMTEXTRA_CID,
|
||||
NS_UNICODEENCODER_CONTRACTID_BASE "x-mtextra",
|
||||
nsUnicodeToMTExtraConstructor,
|
||||
nsUnicodeToMTExtraRegSelf, nsUnicodeToMTExtraUnRegSelf
|
||||
}
|
||||
};
|
||||
|
||||
static FactoryData g_FactoryData[] =
|
||||
{
|
||||
/* TeX */
|
||||
{
|
||||
&kUnicodeToTeXCMSYttfCID,
|
||||
nsUnicodeToTeXCMSYttf::CreateInstance,
|
||||
"Unicode",
|
||||
"x-ttf-cmsy"
|
||||
},
|
||||
{
|
||||
&kUnicodeToTeXCMSYt1CID,
|
||||
nsUnicodeToTeXCMSYt1::CreateInstance,
|
||||
"Unicode",
|
||||
"x-t1-cmsy"
|
||||
},
|
||||
{
|
||||
&kUnicodeToTeXCMEXttfCID,
|
||||
nsUnicodeToTeXCMEXttf::CreateInstance,
|
||||
"Unicode",
|
||||
"x-ttf-cmex"
|
||||
},
|
||||
{
|
||||
&kUnicodeToTeXCMEXt1CID,
|
||||
nsUnicodeToTeXCMEXt1::CreateInstance,
|
||||
"Unicode",
|
||||
"x-t1-cmex"
|
||||
},
|
||||
/* Mathematica */
|
||||
{
|
||||
&kUnicodeToMathematica1CID,
|
||||
nsUnicodeToMathematica1::CreateInstance,
|
||||
"Unicode",
|
||||
"x-mathematica1"
|
||||
},
|
||||
{
|
||||
&kUnicodeToMathematica2CID,
|
||||
nsUnicodeToMathematica2::CreateInstance,
|
||||
"Unicode",
|
||||
"x-mathematica2"
|
||||
},
|
||||
{
|
||||
&kUnicodeToMathematica2CID,
|
||||
nsUnicodeToMathematica2::CreateInstance,
|
||||
"Unicode",
|
||||
"x-mathematica2"
|
||||
},
|
||||
{
|
||||
&kUnicodeToMathematica3CID,
|
||||
nsUnicodeToMathematica3::CreateInstance,
|
||||
"Unicode",
|
||||
"x-mathematica3"
|
||||
},
|
||||
{
|
||||
&kUnicodeToMathematica4CID,
|
||||
nsUnicodeToMathematica4::CreateInstance,
|
||||
"Unicode",
|
||||
"x-mathematica4"
|
||||
},
|
||||
{
|
||||
&kUnicodeToMathematica5CID,
|
||||
nsUnicodeToMathematica5::CreateInstance,
|
||||
"Unicode",
|
||||
"x-mathematica5"
|
||||
},
|
||||
/* MathType Extra */
|
||||
{
|
||||
&kUnicodeToMTExtraCID,
|
||||
nsUnicodeToMTExtra::CreateInstance,
|
||||
"Unicode",
|
||||
"x-mtextra"
|
||||
},
|
||||
};
|
||||
|
||||
#define ARRAY_SIZE(_array) \
|
||||
(sizeof(_array) / sizeof(_array[0]))
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Class nsConverterFactory [declaration]
|
||||
|
||||
/**
|
||||
* General factory class for converter objects.
|
||||
*
|
||||
* @created 24/Feb/1998
|
||||
* @author Catalin Rotaru [CATA]
|
||||
*/
|
||||
class nsConverterFactory : public nsIFactory
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
private:
|
||||
|
||||
FactoryData * mData;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
nsConverterFactory(FactoryData * aData);
|
||||
|
||||
/**
|
||||
* Class destructor.
|
||||
*/
|
||||
virtual ~nsConverterFactory();
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Interface nsIFactory [declaration]
|
||||
|
||||
NS_IMETHOD CreateInstance(nsISupports *aDelegate, const nsIID &aIID,
|
||||
void **aResult);
|
||||
NS_IMETHOD LockFactory(PRBool aLock);
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Class nsConverterModule [declaration]
|
||||
|
||||
class nsConverterModule : public nsIModule
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIMODULE
|
||||
|
||||
private:
|
||||
|
||||
PRBool mInitialized;
|
||||
|
||||
void Shutdown();
|
||||
|
||||
public:
|
||||
|
||||
nsConverterModule();
|
||||
|
||||
virtual ~nsConverterModule();
|
||||
|
||||
nsresult Initialize();
|
||||
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Global functions and data [implementation]
|
||||
|
||||
static nsConverterModule * gModule = NULL;
|
||||
|
||||
extern "C" NS_EXPORT nsresult NSGetModule(nsIComponentManager * compMgr,
|
||||
nsIFile* location,
|
||||
nsIModule** return_cobj)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
NS_ENSURE_ARG_POINTER(return_cobj);
|
||||
NS_ENSURE_FALSE(gModule, NS_ERROR_FAILURE);
|
||||
|
||||
// Create an initialize the module instance
|
||||
nsConverterModule * m = new nsConverterModule();
|
||||
if (!m) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
// Increase refcnt and store away nsIModule interface to m in return_cobj
|
||||
rv = m->QueryInterface(NS_GET_IID(nsIModule), (void**)return_cobj);
|
||||
if (NS_FAILED(rv)) {
|
||||
delete m;
|
||||
m = nsnull;
|
||||
}
|
||||
gModule = m; // WARNING: Weak Reference
|
||||
return rv;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Class nsConverterFactory [implementation]
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsConverterFactory, NS_GET_IID(nsIFactory));
|
||||
|
||||
nsConverterFactory::nsConverterFactory(FactoryData * aData)
|
||||
{
|
||||
mData = aData;
|
||||
|
||||
NS_INIT_REFCNT();
|
||||
PR_AtomicIncrement(&g_InstanceCount);
|
||||
}
|
||||
|
||||
nsConverterFactory::~nsConverterFactory()
|
||||
{
|
||||
PR_AtomicDecrement(&g_InstanceCount);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Interface nsIFactory [implementation]
|
||||
|
||||
NS_IMETHODIMP nsConverterFactory::CreateInstance(nsISupports *aDelegate,
|
||||
const nsIID &aIID,
|
||||
void **aResult)
|
||||
{
|
||||
if (aResult == NULL) return NS_ERROR_NULL_POINTER;
|
||||
if (aDelegate != NULL) return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
nsISupports * t;
|
||||
mData->CreateInstance(&t);
|
||||
if (t == NULL) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(t); // Stabilize
|
||||
|
||||
nsresult res = t->QueryInterface(aIID, aResult);
|
||||
|
||||
NS_RELEASE(t); // Destabilize and avoid leaks. Avoid calling delete <interface pointer>
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsConverterFactory::LockFactory(PRBool aLock)
|
||||
{
|
||||
if (aLock) PR_AtomicIncrement(&g_LockCount);
|
||||
else PR_AtomicDecrement(&g_LockCount);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Class nsConverterModule [implementation]
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsConverterModule, NS_GET_IID(nsIModule))
|
||||
|
||||
nsConverterModule::nsConverterModule()
|
||||
: mInitialized(PR_FALSE)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsConverterModule::~nsConverterModule()
|
||||
{
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
nsresult nsConverterModule::Initialize()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsConverterModule::Shutdown()
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Interface nsIModule [implementation]
|
||||
|
||||
NS_IMETHODIMP nsConverterModule::GetClassObject(nsIComponentManager *aCompMgr,
|
||||
const nsCID& aClass,
|
||||
const nsIID& aIID,
|
||||
void ** r_classObj)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// Defensive programming: Initialize *r_classObj in case of error below
|
||||
if (!r_classObj) {
|
||||
return NS_ERROR_INVALID_POINTER;
|
||||
}
|
||||
*r_classObj = NULL;
|
||||
|
||||
if (!mInitialized) {
|
||||
rv = Initialize();
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
mInitialized = PR_TRUE;
|
||||
}
|
||||
|
||||
FactoryData * data;
|
||||
nsConverterFactory * fact;
|
||||
|
||||
// XXX cache these factories
|
||||
for (PRUint32 i=0; i<ARRAY_SIZE(g_FactoryData); i++) {
|
||||
data = &(g_FactoryData[i]);
|
||||
if (aClass.Equals(*(data->mCID))) {
|
||||
fact = new nsConverterFactory(data);
|
||||
if (fact == NULL) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
rv = fact->QueryInterface(aIID, (void **) r_classObj);
|
||||
if (NS_FAILED(rv)) delete fact;
|
||||
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_ERROR_FACTORY_NOT_REGISTERED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsConverterModule::RegisterSelf(nsIComponentManager *aCompMgr,
|
||||
nsIFile* aPath,
|
||||
const char* registryLocation,
|
||||
const char* componentType)
|
||||
{
|
||||
nsresult res;
|
||||
PRUint32 i;
|
||||
nsIRegistry * registry = NULL;
|
||||
nsRegistryKey key;
|
||||
char buff[1024];
|
||||
|
||||
// get the registry
|
||||
res = nsServiceManager::GetService(NS_REGISTRY_CONTRACTID,
|
||||
NS_GET_IID(nsIRegistry), (nsISupports**)®istry);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
|
||||
// open the registry
|
||||
res = registry->OpenWellKnownRegistry(
|
||||
nsIRegistry::ApplicationComponentRegistry);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
|
||||
char name[128];
|
||||
char contractid[128];
|
||||
char * cid_string;
|
||||
for (i=0; i<ARRAY_SIZE(g_FactoryData); i++) {
|
||||
if(0==PL_strcmp(g_FactoryData[i].mCharsetSrc,"Unicode"))
|
||||
{
|
||||
PL_strcpy(name, ENCODER_NAME_BASE);
|
||||
PL_strcat(name, g_FactoryData[i].mCharsetDest);
|
||||
PL_strcpy(contractid, NS_UNICODEENCODER_CONTRACTID_BASE);
|
||||
PL_strcat(contractid, g_FactoryData[i].mCharsetDest);
|
||||
} else {
|
||||
PL_strcpy(name, DECODER_NAME_BASE);
|
||||
PL_strcat(name, g_FactoryData[i].mCharsetSrc);
|
||||
PL_strcpy(contractid, NS_UNICODEDECODER_CONTRACTID_BASE);
|
||||
PL_strcat(contractid, g_FactoryData[i].mCharsetSrc);
|
||||
}
|
||||
// register component
|
||||
res = aCompMgr->RegisterComponentSpec(*(g_FactoryData[i].mCID), name,
|
||||
contractid, aPath, PR_TRUE, PR_TRUE);
|
||||
if(NS_FAILED(res) && (NS_ERROR_FACTORY_EXISTS != res)) goto done;
|
||||
|
||||
// register component info
|
||||
// XXX take these KONSTANTS out of here; refine this code
|
||||
cid_string = g_FactoryData[i].mCID->ToString();
|
||||
sprintf(buff, "%s/%s", "software/netscape/intl/uconv", cid_string);
|
||||
nsCRT::free(cid_string);
|
||||
res = registry -> AddSubtree(nsIRegistry::Common, buff, &key);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
res = registry -> SetStringUTF8(key, "source", g_FactoryData[i].mCharsetSrc);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
res = registry -> SetStringUTF8(key, "destination", g_FactoryData[i].mCharsetDest);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
}
|
||||
|
||||
done:
|
||||
if (registry != NULL) {
|
||||
nsServiceManager::ReleaseService(NS_REGISTRY_CONTRACTID, registry);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsConverterModule::UnregisterSelf(nsIComponentManager *aCompMgr,
|
||||
nsIFile* aPath,
|
||||
const char* registryLocation)
|
||||
{
|
||||
// XXX also delete the stuff I added to the registry
|
||||
nsresult rv;
|
||||
|
||||
for (PRUint32 i=0; i<ARRAY_SIZE(g_FactoryData); i++) {
|
||||
rv = aCompMgr->UnregisterComponentSpec(*(g_FactoryData[i].mCID), aPath);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsConverterModule::CanUnload(nsIComponentManager *aCompMgr,
|
||||
PRBool *okToUnload)
|
||||
{
|
||||
if (!okToUnload) {
|
||||
return NS_ERROR_INVALID_POINTER;
|
||||
}
|
||||
*okToUnload = (g_InstanceCount == 0 && g_LockCount == 0);
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMPL_NSGETMODULE("nsUCvMathModule", components);
|
||||
|
||||
|
|
|
@ -54,12 +54,6 @@ nsUnicodeToMTExtra::nsUnicodeToMTExtra()
|
|||
{
|
||||
}
|
||||
|
||||
nsresult nsUnicodeToMTExtra::CreateInstance(nsISupports ** aResult)
|
||||
{
|
||||
*aResult = (nsIUnicodeEncoder*) new nsUnicodeToMTExtra();
|
||||
return (*aResult == NULL)? NS_ERROR_OUT_OF_MEMORY : NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Subclassing of nsTableEncoderSupport class [implementation]
|
||||
|
||||
|
|
|
@ -52,11 +52,6 @@ public:
|
|||
*/
|
||||
nsUnicodeToMTExtra();
|
||||
|
||||
/**
|
||||
* Static class constructor.
|
||||
*/
|
||||
static nsresult CreateInstance(nsISupports **aResult);
|
||||
|
||||
protected:
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
|
|
@ -54,12 +54,6 @@ nsUnicodeToMathematica1::nsUnicodeToMathematica1()
|
|||
{
|
||||
}
|
||||
|
||||
nsresult nsUnicodeToMathematica1::CreateInstance(nsISupports ** aResult)
|
||||
{
|
||||
*aResult = (nsIUnicodeEncoder*) new nsUnicodeToMathematica1();
|
||||
return (*aResult == NULL)? NS_ERROR_OUT_OF_MEMORY : NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Subclassing of nsTableEncoderSupport class [implementation]
|
||||
|
||||
|
|
|
@ -52,11 +52,6 @@ public:
|
|||
*/
|
||||
nsUnicodeToMathematica1();
|
||||
|
||||
/**
|
||||
* Static class constructor.
|
||||
*/
|
||||
static nsresult CreateInstance(nsISupports **aResult);
|
||||
|
||||
protected:
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
|
|
@ -54,12 +54,6 @@ nsUnicodeToMathematica2::nsUnicodeToMathematica2()
|
|||
{
|
||||
}
|
||||
|
||||
nsresult nsUnicodeToMathematica2::CreateInstance(nsISupports ** aResult)
|
||||
{
|
||||
*aResult = (nsIUnicodeEncoder*) new nsUnicodeToMathematica2();
|
||||
return (*aResult == NULL)? NS_ERROR_OUT_OF_MEMORY : NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Subclassing of nsTableEncoderSupport class [implementation]
|
||||
|
||||
|
|
|
@ -52,11 +52,6 @@ public:
|
|||
*/
|
||||
nsUnicodeToMathematica2();
|
||||
|
||||
/**
|
||||
* Static class constructor.
|
||||
*/
|
||||
static nsresult CreateInstance(nsISupports **aResult);
|
||||
|
||||
protected:
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
|
|
@ -54,12 +54,6 @@ nsUnicodeToMathematica3::nsUnicodeToMathematica3()
|
|||
{
|
||||
}
|
||||
|
||||
nsresult nsUnicodeToMathematica3::CreateInstance(nsISupports ** aResult)
|
||||
{
|
||||
*aResult = (nsIUnicodeEncoder*) new nsUnicodeToMathematica3();
|
||||
return (*aResult == NULL)? NS_ERROR_OUT_OF_MEMORY : NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Subclassing of nsTableEncoderSupport class [implementation]
|
||||
|
||||
|
|
|
@ -52,11 +52,6 @@ public:
|
|||
*/
|
||||
nsUnicodeToMathematica3();
|
||||
|
||||
/**
|
||||
* Static class constructor.
|
||||
*/
|
||||
static nsresult CreateInstance(nsISupports **aResult);
|
||||
|
||||
protected:
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
|
|
@ -54,12 +54,6 @@ nsUnicodeToMathematica4::nsUnicodeToMathematica4()
|
|||
{
|
||||
}
|
||||
|
||||
nsresult nsUnicodeToMathematica4::CreateInstance(nsISupports ** aResult)
|
||||
{
|
||||
*aResult = (nsIUnicodeEncoder*) new nsUnicodeToMathematica4();
|
||||
return (*aResult == NULL)? NS_ERROR_OUT_OF_MEMORY : NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Subclassing of nsTableEncoderSupport class [implementation]
|
||||
|
||||
|
|
|
@ -52,11 +52,6 @@ public:
|
|||
*/
|
||||
nsUnicodeToMathematica4();
|
||||
|
||||
/**
|
||||
* Static class constructor.
|
||||
*/
|
||||
static nsresult CreateInstance(nsISupports **aResult);
|
||||
|
||||
protected:
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
|
|
@ -54,12 +54,6 @@ nsUnicodeToMathematica5::nsUnicodeToMathematica5()
|
|||
{
|
||||
}
|
||||
|
||||
nsresult nsUnicodeToMathematica5::CreateInstance(nsISupports ** aResult)
|
||||
{
|
||||
*aResult = (nsIUnicodeEncoder*) new nsUnicodeToMathematica5();
|
||||
return (*aResult == NULL)? NS_ERROR_OUT_OF_MEMORY : NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Subclassing of nsTableEncoderSupport class [implementation]
|
||||
|
||||
|
|
|
@ -52,11 +52,6 @@ public:
|
|||
*/
|
||||
nsUnicodeToMathematica5();
|
||||
|
||||
/**
|
||||
* Static class constructor.
|
||||
*/
|
||||
static nsresult CreateInstance(nsISupports **aResult);
|
||||
|
||||
protected:
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
|
|
@ -54,12 +54,6 @@ nsUnicodeToTeXCMEXt1::nsUnicodeToTeXCMEXt1()
|
|||
{
|
||||
}
|
||||
|
||||
nsresult nsUnicodeToTeXCMEXt1::CreateInstance(nsISupports ** aResult)
|
||||
{
|
||||
*aResult = (nsIUnicodeEncoder*) new nsUnicodeToTeXCMEXt1();
|
||||
return (*aResult == NULL)? NS_ERROR_OUT_OF_MEMORY : NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Subclassing of nsTableEncoderSupport class [implementation]
|
||||
|
||||
|
|
|
@ -52,11 +52,6 @@ public:
|
|||
*/
|
||||
nsUnicodeToTeXCMEXt1();
|
||||
|
||||
/**
|
||||
* Static class constructor.
|
||||
*/
|
||||
static nsresult CreateInstance(nsISupports **aResult);
|
||||
|
||||
protected:
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
|
|
@ -54,12 +54,6 @@ nsUnicodeToTeXCMEXttf::nsUnicodeToTeXCMEXttf()
|
|||
{
|
||||
}
|
||||
|
||||
nsresult nsUnicodeToTeXCMEXttf::CreateInstance(nsISupports ** aResult)
|
||||
{
|
||||
*aResult = (nsIUnicodeEncoder*) new nsUnicodeToTeXCMEXttf();
|
||||
return (*aResult == NULL)? NS_ERROR_OUT_OF_MEMORY : NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Subclassing of nsTableEncoderSupport class [implementation]
|
||||
|
||||
|
|
|
@ -52,11 +52,6 @@ public:
|
|||
*/
|
||||
nsUnicodeToTeXCMEXttf();
|
||||
|
||||
/**
|
||||
* Static class constructor.
|
||||
*/
|
||||
static nsresult CreateInstance(nsISupports **aResult);
|
||||
|
||||
protected:
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
|
|
@ -54,12 +54,6 @@ nsUnicodeToTeXCMSYt1::nsUnicodeToTeXCMSYt1()
|
|||
{
|
||||
}
|
||||
|
||||
nsresult nsUnicodeToTeXCMSYt1::CreateInstance(nsISupports ** aResult)
|
||||
{
|
||||
*aResult = (nsIUnicodeEncoder*) new nsUnicodeToTeXCMSYt1();
|
||||
return (*aResult == NULL)? NS_ERROR_OUT_OF_MEMORY : NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Subclassing of nsTableEncoderSupport class [implementation]
|
||||
|
||||
|
|
|
@ -52,11 +52,6 @@ public:
|
|||
*/
|
||||
nsUnicodeToTeXCMSYt1();
|
||||
|
||||
/**
|
||||
* Static class constructor.
|
||||
*/
|
||||
static nsresult CreateInstance(nsISupports **aResult);
|
||||
|
||||
protected:
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
|
|
@ -54,12 +54,6 @@ nsUnicodeToTeXCMSYttf::nsUnicodeToTeXCMSYttf()
|
|||
{
|
||||
}
|
||||
|
||||
nsresult nsUnicodeToTeXCMSYttf::CreateInstance(nsISupports ** aResult)
|
||||
{
|
||||
*aResult = (nsIUnicodeEncoder*) new nsUnicodeToTeXCMSYttf();
|
||||
return (*aResult == NULL)? NS_ERROR_OUT_OF_MEMORY : NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Subclassing of nsTableEncoderSupport class [implementation]
|
||||
|
||||
|
|
|
@ -52,11 +52,6 @@ public:
|
|||
*/
|
||||
nsUnicodeToTeXCMSYttf();
|
||||
|
||||
/**
|
||||
* Static class constructor.
|
||||
*/
|
||||
static nsresult CreateInstance(nsISupports **aResult);
|
||||
|
||||
protected:
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
|
Загрузка…
Ссылка в новой задаче