mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-04-11 02:18:01 +00:00
check in backout code after nhotta fix other problem. fix bug 14914
This commit is contained in:
parent
4f6df1a721
commit
2fdd6d014e
@ -133,11 +133,6 @@ private:
|
|||||||
nsICharsetConverterInfo * GetICharsetConverterInfo(ConverterInfo * ci,
|
nsICharsetConverterInfo * GetICharsetConverterInfo(ConverterInfo * ci,
|
||||||
PRInt32 aIndex, PRInt32 * aSize);
|
PRInt32 aIndex, PRInt32 * aSize);
|
||||||
|
|
||||||
/**
|
|
||||||
* General method for finding and instantiating a Converter.
|
|
||||||
*/
|
|
||||||
nsresult GetCharsetConverter(const nsString * aSrc, void ** aResult,
|
|
||||||
const nsCID * aCID, const ConverterInfo * aArray, PRInt32 aSize);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -381,31 +376,6 @@ reduceArray:
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsCharsetConverterManager::GetCharsetConverter(
|
|
||||||
const nsString * aSrc,
|
|
||||||
void ** aResult,
|
|
||||||
const nsCID * aCID,
|
|
||||||
const ConverterInfo * aArray,
|
|
||||||
PRInt32 aSize)
|
|
||||||
{
|
|
||||||
nsresult res = NS_ERROR_UCONV_NOCONV;
|
|
||||||
nsString * str;
|
|
||||||
GetCharsetName(aSrc, &str);
|
|
||||||
|
|
||||||
*aResult = NULL;
|
|
||||||
for (PRInt32 i=0; i<aSize; i++) if (str->EqualsIgnoreCase(*(aArray[i].mCharset))) {
|
|
||||||
res = nsComponentManager::CreateInstance(*(aArray[i].mCID),NULL,*aCID,aResult);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete str;
|
|
||||||
|
|
||||||
// well, we didn't found any converter. Damn, life sucks!
|
|
||||||
if ((*aResult == NULL) && (NS_SUCCEEDED(res)))
|
|
||||||
res = NS_ERROR_UCONV_NOCONV;
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// Interface nsICharsetConverterManager [implementation]
|
// Interface nsICharsetConverterManager [implementation]
|
||||||
@ -414,28 +384,42 @@ NS_IMETHODIMP nsCharsetConverterManager::GetUnicodeEncoder(
|
|||||||
const nsString * aDest,
|
const nsString * aDest,
|
||||||
nsIUnicodeEncoder ** aResult)
|
nsIUnicodeEncoder ** aResult)
|
||||||
{
|
{
|
||||||
|
*aResult= nsnull;
|
||||||
|
nsIComponentManager* comMgr;
|
||||||
nsresult res;
|
nsresult res;
|
||||||
if (!mMappingDone) {
|
res = NS_GetGlobalComponentManager(&comMgr);
|
||||||
res = CreateMapping();
|
if(NS_FAILED(res))
|
||||||
if NS_FAILED(res) return res;
|
return res;
|
||||||
}
|
PRInt32 baselen = nsCRT::strlen(NS_UNICODEENCODER_PROGID_BASE);
|
||||||
|
char progid[256];
|
||||||
return GetCharsetConverter(aDest, (void **) aResult, &kIUnicodeEncoderIID,
|
PL_strncpy(progid, NS_UNICODEENCODER_PROGID_BASE, 256);
|
||||||
mEncArray, mEncSize);
|
aDest->ToCString(progid + baselen, 256 - baselen);
|
||||||
|
res = comMgr->CreateInstanceByProgID(progid,NULL,
|
||||||
|
kIUnicodeEncoderIID ,(void**)aResult);
|
||||||
|
if(NS_FAILED(res))
|
||||||
|
res = NS_ERROR_UCONV_NOCONV;
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsCharsetConverterManager::GetUnicodeDecoder(
|
NS_IMETHODIMP nsCharsetConverterManager::GetUnicodeDecoder(
|
||||||
const nsString * aSrc,
|
const nsString * aSrc,
|
||||||
nsIUnicodeDecoder ** aResult)
|
nsIUnicodeDecoder ** aResult)
|
||||||
{
|
{
|
||||||
|
*aResult= nsnull;
|
||||||
|
nsIComponentManager* comMgr;
|
||||||
nsresult res;
|
nsresult res;
|
||||||
if (!mMappingDone) {
|
res = NS_GetGlobalComponentManager(&comMgr);
|
||||||
res = CreateMapping();
|
if(NS_FAILED(res))
|
||||||
if NS_FAILED(res) return res;
|
return res;
|
||||||
}
|
PRInt32 baselen = nsCRT::strlen(NS_UNICODEDECODER_PROGID_BASE);
|
||||||
|
char progid[256];
|
||||||
return GetCharsetConverter(aSrc, (void **) aResult, &kIUnicodeDecoderIID,
|
PL_strncpy(progid, NS_UNICODEDECODER_PROGID_BASE, 256);
|
||||||
mDecArray, mDecSize);
|
aSrc->ToCString(progid + baselen, 256 - baselen);
|
||||||
|
res = comMgr->CreateInstanceByProgID(progid,NULL,
|
||||||
|
kIUnicodeDecoderIID,(void**)aResult);
|
||||||
|
if(NS_FAILED(res))
|
||||||
|
res = NS_ERROR_UCONV_NOCONV;
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsCharsetConverterManager::GetEncodableCharsets(
|
NS_IMETHODIMP nsCharsetConverterManager::GetEncodableCharsets(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user