зеркало из https://github.com/mozilla/pjs.git
Adding API to map charset name to language. bug #26240 r=erik
This commit is contained in:
Родитель
54c0bf4393
Коммит
2f9cc254a0
|
@ -26,6 +26,7 @@
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
#include "nsError.h"
|
#include "nsError.h"
|
||||||
#include "nsISupports.h"
|
#include "nsISupports.h"
|
||||||
|
#include "nsIAtom.h"
|
||||||
#include "nsIUnicodeEncoder.h"
|
#include "nsIUnicodeEncoder.h"
|
||||||
#include "nsIUnicodeDecoder.h"
|
#include "nsIUnicodeDecoder.h"
|
||||||
|
|
||||||
|
@ -39,33 +40,19 @@
|
||||||
// XXX change to NS_CHARSETCONVERTERMANAGER_PID
|
// XXX change to NS_CHARSETCONVERTERMANAGER_PID
|
||||||
#define NS_CHARSETCONVERTERMANAGER_PROGID "charset-converter-manager"
|
#define NS_CHARSETCONVERTERMANAGER_PROGID "charset-converter-manager"
|
||||||
|
|
||||||
|
#define NS_REGISTRY_UCONV_BASE "software/netscape/intl/uconv/"
|
||||||
#define NS_REGISTRY_UCONV_BASE "software/netscape/intl/uconv/"
|
// XXX change "xuconv" to "uconv" when the new enc&dec trees are in place
|
||||||
|
#define NS_DATA_BUNDLE_REGISTRY_KEY "software/netscape/intl/xuconv/data/"
|
||||||
|
#define NS_TITLE_BUNDLE_REGISTRY_KEY "software/netscape/intl/xuconv/titles/"
|
||||||
|
|
||||||
#define NS_ERROR_UCONV_NOCONV \
|
#define NS_ERROR_UCONV_NOCONV \
|
||||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_UCONV, 0x01)
|
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_UCONV, 0x01)
|
||||||
|
|
||||||
#define SET_FOR_BROWSER(_val) (_val |= 0x00000001)
|
|
||||||
#define SET_NOT_FOR_BROWSER(_val) (_val |= (!0x00000001))
|
|
||||||
#define GET_FOR_BROWSER(_val) ((_val &= 0x00000001) != 0)
|
|
||||||
|
|
||||||
#define SET_FOR_EDITOR(_val) (_val |= 0x00000001)
|
|
||||||
#define SET_NOT_FOR_EDITOR(_val) (_val |= (!0x00000001))
|
|
||||||
#define GET_FOR_EDITOR(_val) ((_val &= 0x00000001) != 0)
|
|
||||||
|
|
||||||
#define SET_FOR_MAILNEWS(_val) (_val |= 0x00000002)
|
|
||||||
#define SET_NOT_FOR_MAILNEWS(_val) (_val |= (!0x00000002))
|
|
||||||
#define GET_FOR_MAILNEWS(_val) ((_val &= 0x00000002) != 0)
|
|
||||||
|
|
||||||
#define SET_FOR_MAILNEWSEDITOR(_val) (_val |= 0x00000002)
|
|
||||||
#define SET_NOT_FOR_MAILNEWSEDITOR(_val) (_val |= (!0x00000002))
|
|
||||||
#define GET_FOR_MAILNEWSEDITOR(_val) ((_val &= 0x00000002) != 0)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for a Manager of Charset Converters.
|
* Interface for a Manager of Charset Converters.
|
||||||
*
|
*
|
||||||
* This Manager's data is a cacheing of Registry available stuff. But the
|
* This Manager's data is a cache of the stuff available directly through
|
||||||
* access methods are also doing all the work to get it and provide it.
|
* Registry and Extensible String Bundles. Plus a set of convenient APIs.
|
||||||
*
|
*
|
||||||
* Note: The term "Charset" used in the classes, interfaces and file names
|
* Note: The term "Charset" used in the classes, interfaces and file names
|
||||||
* should be read as "Coded Character Set". I am saying "charset" only for
|
* should be read as "Coded Character Set". I am saying "charset" only for
|
||||||
|
@ -76,6 +63,12 @@
|
||||||
* A DECODER converts from a random encoding into Unicode.
|
* A DECODER converts from a random encoding into Unicode.
|
||||||
* An ENCODER converts from Unicode into a random encoding.
|
* An ENCODER converts from Unicode into a random encoding.
|
||||||
* All our data structures and APIs are divided like that.
|
* All our data structures and APIs are divided like that.
|
||||||
|
* However, when you have a charset data, you may have 3 cases:
|
||||||
|
* a) the data is charset-dependet, but it is common for encoders and decoders
|
||||||
|
* b) the data is different for the two of them, thus needing different APIs
|
||||||
|
* and different "aProp" identifying it.
|
||||||
|
* c) the data is relevant only for one: encoder or decoder; its nature making
|
||||||
|
* the distinction.
|
||||||
*
|
*
|
||||||
* @created 15/Nov/1999
|
* @created 15/Nov/1999
|
||||||
* @author Catalin Rotaru [CATA]
|
* @author Catalin Rotaru [CATA]
|
||||||
|
@ -89,14 +82,18 @@ public:
|
||||||
nsIUnicodeEncoder ** aResult) = 0;
|
nsIUnicodeEncoder ** aResult) = 0;
|
||||||
NS_IMETHOD GetUnicodeDecoder(const nsString * aSrc,
|
NS_IMETHOD GetUnicodeDecoder(const nsString * aSrc,
|
||||||
nsIUnicodeDecoder ** aResult) = 0;
|
nsIUnicodeDecoder ** aResult) = 0;
|
||||||
|
|
||||||
NS_IMETHOD GetDecoderList(nsString *** aResult, PRInt32 * aCount) = 0;
|
NS_IMETHOD GetDecoderList(nsString *** aResult, PRInt32 * aCount) = 0;
|
||||||
NS_IMETHOD GetEncoderList(nsString *** aResult, PRInt32 * aCount) = 0;
|
NS_IMETHOD GetEncoderList(nsString *** aResult, PRInt32 * aCount) = 0;
|
||||||
NS_IMETHOD GetMIMEMailCharset(nsString * aCharset, nsString ** aResult) = 0;
|
|
||||||
NS_IMETHOD GetMIMEHeaderEncodingMethod(nsString * aCharset,
|
|
||||||
nsString ** aResult) = 0;
|
|
||||||
NS_IMETHOD GetCharsetData(nsString * aCharset, nsString * aProp,
|
NS_IMETHOD GetCharsetData(nsString * aCharset, nsString * aProp,
|
||||||
nsString ** aResult) = 0;
|
nsString ** aResult) = 0;
|
||||||
NS_IMETHOD GetCharsetTitle(nsString * aCharset, nsString ** aResult) = 0;
|
NS_IMETHOD GetCharsetTitle(nsString * aCharset, nsString ** aResult) = 0;
|
||||||
|
NS_IMETHOD GetCharsetLangGroup(nsString * aCharset, nsIAtom ** aResult) = 0;
|
||||||
|
|
||||||
|
NS_IMETHOD GetMIMEMailCharset(nsString * aCharset, nsString ** aResult) = 0;
|
||||||
|
NS_IMETHOD GetMIMEHeaderEncodingMethod(nsString * aCharset,
|
||||||
|
nsString ** aResult) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* nsICharsetConverterManager_h___ */
|
#endif /* nsICharsetConverterManager_h___ */
|
||||||
|
|
|
@ -23,28 +23,56 @@
|
||||||
## comparision in the code faster.
|
## comparision in the code faster.
|
||||||
|
|
||||||
## Format of this file:
|
## Format of this file:
|
||||||
|
##
|
||||||
## charset_name.notForBrowser = anything - specifies that this charset is
|
## charset_name.notForBrowser = anything - specifies that this charset is
|
||||||
## not to be used in the browser
|
## not to be used in the browser
|
||||||
##
|
##
|
||||||
|
## charset_name.LangGroup =
|
||||||
|
##
|
||||||
## charset_name.MIMEHeaderEncodingMethod =
|
## charset_name.MIMEHeaderEncodingMethod =
|
||||||
##
|
##
|
||||||
## charset_name.MIMEMailCharset =
|
## charset_name.MIMEMailCharset =
|
||||||
|
|
||||||
t.61-8bit.notForBrowser = true
|
t.61-8bit.notForBrowser = true
|
||||||
utf-32le.notForBrowser = true
|
utf-32le.notForBrowser = true
|
||||||
utf-32be.notForBrowser = true
|
utf-32be.notForBrowser = true
|
||||||
utf-16le.notForBrowser = true
|
utf-16le.notForBrowser = true
|
||||||
utf-16be.notForBrowser = true
|
utf-16be.notForBrowser = true
|
||||||
x-imap4-modified-utf7.notForBrowser = true
|
x-imap4-modified-utf7.notForBrowser = true
|
||||||
x-u-escaped.notForBrowser = true
|
x-u-escaped.notForBrowser = true
|
||||||
us-ascii.notForBrowser = true
|
hz-gb-2312.notForBrowser = true
|
||||||
x-obsoleted-euc-jp.notForBrowser = true
|
x-gbk.notForBrowser = true
|
||||||
x-obsoleted-iso-2022-jp.notForBrowser = true
|
windows-936.notForBrowser = true
|
||||||
x-obsoleted-shift_jis.notForBrowser = true
|
us-ascii.notForBrowser = true
|
||||||
hz-gb-2312.notForBrowser = true
|
x-obsoleted-euc-jp.notForBrowser = true
|
||||||
x-gbk.notForBrowser = true
|
x-obsoleted-iso-2022-jp.notForBrowser = true
|
||||||
windows-936.notForBrowser = true
|
x-obsoleted-shift_jis.notForBrowser = true
|
||||||
|
|
||||||
utf-8.MIMEHeaderEncodingMethod = B
|
|
||||||
|
|
||||||
utf-8.MIMEMailCharset = utf-8
|
shift_jis.LangGroup = ja
|
||||||
|
big5.LangGroup = zh-TW
|
||||||
|
euc-jp.LangGroup = ja
|
||||||
|
euc-kr.LangGroup = ko
|
||||||
|
gb2312.LangGroup = zh-CN
|
||||||
|
hz-gb-2312.LangGroup = zh-CN
|
||||||
|
iso-2022-jp.LangGroup = ja
|
||||||
|
iso-2022-kr.LangGroup = ko
|
||||||
|
iso-8859-1.LangGroup = x-western
|
||||||
|
iso-8859-2.LangGroup = x-central-euro
|
||||||
|
iso-8859-5.LangGroup = x-cyrillic
|
||||||
|
iso-8859-7.LangGroup = el
|
||||||
|
iso-8859-9.LangGroup = tr
|
||||||
|
koi8-r.LangGroup = x-cyrillic
|
||||||
|
utf-8.LangGroup = x-unicode
|
||||||
|
us-ascii.LangGroup = x-western
|
||||||
|
windows-1250.LangGroup = x-central-euro
|
||||||
|
windows-1251.LangGroup = x-cyrillic
|
||||||
|
x-euc-tw.LangGroup = zh-TW
|
||||||
|
x-mac-ce.LangGroup = x-central-euro
|
||||||
|
x-mac-cyrillic.LangGroup = x-cyrillic
|
||||||
|
x-mac-greek.LangGroup = el
|
||||||
|
x-mac-roman.LangGroup = x-western
|
||||||
|
x-mac-turkish.LangGroup = tr
|
||||||
|
|
||||||
|
utf-8.MIMEHeaderEncodingMethod = B
|
||||||
|
utf-8.MIMEMailCharset = utf-8
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "nsILocaleService.h"
|
#include "nsILocaleService.h"
|
||||||
#include "nsUConvDll.h"
|
#include "nsUConvDll.h"
|
||||||
#include "nsObjectArray.h"
|
#include "nsObjectArray.h"
|
||||||
|
#include "prmem.h"
|
||||||
|
|
||||||
// just for CIDs
|
// just for CIDs
|
||||||
#include "nsIUnicodeDecodeHelper.h"
|
#include "nsIUnicodeDecodeHelper.h"
|
||||||
|
@ -41,10 +42,6 @@ static NS_DEFINE_CID(kRegistryCID, NS_REGISTRY_CID);
|
||||||
static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
|
static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
|
||||||
static NS_DEFINE_CID(kLocaleServiceCID, NS_LOCALESERVICE_CID);
|
static NS_DEFINE_CID(kLocaleServiceCID, NS_LOCALESERVICE_CID);
|
||||||
|
|
||||||
// XXX change "xuconv" to "uconv" when the new enc&dec trees are in place
|
|
||||||
#define DATA_BUNDLE_REGISTRY_KEY "software/netscape/intl/xuconv/data/"
|
|
||||||
#define TITLE_BUNDLE_REGISTRY_KEY "software/netscape/intl/xuconv/titles/"
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// Class nsConverterInfo [declaration]
|
// Class nsConverterInfo [declaration]
|
||||||
|
|
||||||
|
@ -99,6 +96,9 @@ private:
|
||||||
nsresult GetBundleValue(nsIStringBundle * aBundle, nsString * aName,
|
nsresult GetBundleValue(nsIStringBundle * aBundle, nsString * aName,
|
||||||
nsString * aProp, nsString ** aResult);
|
nsString * aProp, nsString ** aResult);
|
||||||
|
|
||||||
|
nsresult GetBundleValue(nsIStringBundle * aBundle, nsString * aName,
|
||||||
|
nsString * aProp, nsIAtom ** aResult);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
nsCharsetConverterManager();
|
nsCharsetConverterManager();
|
||||||
|
@ -113,14 +113,18 @@ public:
|
||||||
nsIUnicodeEncoder ** aResult);
|
nsIUnicodeEncoder ** aResult);
|
||||||
NS_IMETHOD GetUnicodeDecoder(const nsString * aSrc,
|
NS_IMETHOD GetUnicodeDecoder(const nsString * aSrc,
|
||||||
nsIUnicodeDecoder ** aResult);
|
nsIUnicodeDecoder ** aResult);
|
||||||
|
|
||||||
NS_IMETHOD GetDecoderList(nsString *** aResult, PRInt32 * aCount);
|
NS_IMETHOD GetDecoderList(nsString *** aResult, PRInt32 * aCount);
|
||||||
NS_IMETHOD GetEncoderList(nsString *** aResult, PRInt32 * aCount);
|
NS_IMETHOD GetEncoderList(nsString *** aResult, PRInt32 * aCount);
|
||||||
NS_IMETHOD GetMIMEMailCharset(nsString * aCharset, nsString ** aResult);
|
|
||||||
NS_IMETHOD GetMIMEHeaderEncodingMethod(nsString * aCharset, nsString **
|
|
||||||
aResult);
|
|
||||||
NS_IMETHOD GetCharsetData(nsString * aCharset, nsString * aProp,
|
NS_IMETHOD GetCharsetData(nsString * aCharset, nsString * aProp,
|
||||||
nsString ** aResult);
|
nsString ** aResult);
|
||||||
NS_IMETHOD GetCharsetTitle(nsString * aCharset, nsString ** aResult);
|
NS_IMETHOD GetCharsetTitle(nsString * aCharset, nsString ** aResult);
|
||||||
|
NS_IMETHOD GetCharsetLangGroup(nsString * aCharset, nsIAtom ** aResult);
|
||||||
|
|
||||||
|
NS_IMETHOD GetMIMEMailCharset(nsString * aCharset, nsString ** aResult);
|
||||||
|
NS_IMETHOD GetMIMEHeaderEncodingMethod(nsString * aCharset, nsString **
|
||||||
|
aResult);
|
||||||
};
|
};
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -204,8 +208,8 @@ nsresult nsCharsetConverterManager::RegisterConverterManagerData()
|
||||||
if (NS_FAILED(res)) return res;
|
if (NS_FAILED(res)) return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
RegisterConverterTitles(registry, TITLE_BUNDLE_REGISTRY_KEY);
|
RegisterConverterTitles(registry, NS_TITLE_BUNDLE_REGISTRY_KEY);
|
||||||
RegisterConverterData(registry, DATA_BUNDLE_REGISTRY_KEY);
|
RegisterConverterData(registry, NS_DATA_BUNDLE_REGISTRY_KEY);
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -404,18 +408,36 @@ nsresult nsCharsetConverterManager::GetBundleValue(nsIStringBundle * aBundle,
|
||||||
{
|
{
|
||||||
nsresult res = NS_OK;
|
nsresult res = NS_OK;
|
||||||
|
|
||||||
nsAutoString key(aName->GetUnicode());
|
nsAutoString key(*aName);
|
||||||
key.Append(*aProp);
|
if (aProp != NULL) key.Append(*aProp); // yes, this parameter may be NULL
|
||||||
|
|
||||||
PRUnichar * value = NULL;
|
PRUnichar * value = NULL;
|
||||||
res = aBundle->GetStringFromName(key.GetUnicode(), &value);
|
res = aBundle->GetStringFromName(key.GetUnicode(), &value);
|
||||||
if (NS_FAILED(res)) return res;
|
if (NS_FAILED(res)) return res;
|
||||||
|
|
||||||
*aResult = new nsString(value);
|
*aResult = new nsString(value);
|
||||||
delete value;
|
PR_Free(value);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsresult nsCharsetConverterManager::GetBundleValue(nsIStringBundle * aBundle,
|
||||||
|
nsString * aName,
|
||||||
|
nsString * aProp,
|
||||||
|
nsIAtom ** aResult)
|
||||||
|
{
|
||||||
|
nsresult res = NS_OK;
|
||||||
|
|
||||||
|
nsAutoString key(*aName);
|
||||||
|
if (aProp != NULL) key.Append(*aProp); // yes, this parameter may be NULL
|
||||||
|
|
||||||
|
PRUnichar * value = NULL;
|
||||||
|
res = aBundle->GetStringFromName(key.GetUnicode(), &value);
|
||||||
|
if (NS_FAILED(res)) return res;
|
||||||
|
|
||||||
|
*aResult = NS_NewAtom(value);
|
||||||
|
PR_Free(value);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// Interface nsICharsetConverterManager [implementation]
|
// Interface nsICharsetConverterManager [implementation]
|
||||||
|
@ -478,10 +500,14 @@ NS_IMETHODIMP nsCharsetConverterManager::GetCharsetData(nsString * aCharset,
|
||||||
nsString * aProp,
|
nsString * aProp,
|
||||||
nsString ** aResult)
|
nsString ** aResult)
|
||||||
{
|
{
|
||||||
nsresult res = NS_OK;;
|
if (aCharset == NULL) return NS_ERROR_NULL_POINTER;
|
||||||
|
if (aResult == NULL) return NS_ERROR_NULL_POINTER;
|
||||||
|
*aResult = NULL;
|
||||||
|
|
||||||
|
nsresult res = NS_OK;
|
||||||
|
|
||||||
if (mDataBundle == NULL) {
|
if (mDataBundle == NULL) {
|
||||||
res = LoadExtensibleBundle(DATA_BUNDLE_REGISTRY_KEY, &mDataBundle);
|
res = LoadExtensibleBundle(NS_DATA_BUNDLE_REGISTRY_KEY, &mDataBundle);
|
||||||
if (NS_FAILED(res)) return res;
|
if (NS_FAILED(res)) return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -492,11 +518,15 @@ NS_IMETHODIMP nsCharsetConverterManager::GetCharsetData(nsString * aCharset,
|
||||||
NS_IMETHODIMP nsCharsetConverterManager::GetCharsetTitle(nsString * aCharset,
|
NS_IMETHODIMP nsCharsetConverterManager::GetCharsetTitle(nsString * aCharset,
|
||||||
nsString ** aResult)
|
nsString ** aResult)
|
||||||
{
|
{
|
||||||
nsresult res = NS_OK;;
|
if (aCharset == NULL) return NS_ERROR_NULL_POINTER;
|
||||||
|
if (aResult == NULL) return NS_ERROR_NULL_POINTER;
|
||||||
|
*aResult = NULL;
|
||||||
|
|
||||||
|
nsresult res = NS_OK;
|
||||||
nsAutoString prop(".title");
|
nsAutoString prop(".title");
|
||||||
|
|
||||||
if (mTitleBundle == NULL) {
|
if (mTitleBundle == NULL) {
|
||||||
res = LoadExtensibleBundle(TITLE_BUNDLE_REGISTRY_KEY, &mTitleBundle);
|
res = LoadExtensibleBundle(NS_TITLE_BUNDLE_REGISTRY_KEY, &mTitleBundle);
|
||||||
if (NS_FAILED(res)) return res;
|
if (NS_FAILED(res)) return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -504,6 +534,26 @@ NS_IMETHODIMP nsCharsetConverterManager::GetCharsetTitle(nsString * aCharset,
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP nsCharsetConverterManager::GetCharsetLangGroup(
|
||||||
|
nsString * aCharset,
|
||||||
|
nsIAtom ** aResult)
|
||||||
|
{
|
||||||
|
if (aCharset == NULL) return NS_ERROR_NULL_POINTER;
|
||||||
|
if (aResult == NULL) return NS_ERROR_NULL_POINTER;
|
||||||
|
*aResult = NULL;
|
||||||
|
|
||||||
|
nsresult res = NS_OK;;
|
||||||
|
nsAutoString prop(".LangGroup");
|
||||||
|
|
||||||
|
if (mDataBundle == NULL) {
|
||||||
|
res = LoadExtensibleBundle(NS_DATA_BUNDLE_REGISTRY_KEY, &mDataBundle);
|
||||||
|
if (NS_FAILED(res)) return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
res = GetBundleValue(mDataBundle, aCharset, &prop, aResult);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsCharsetConverterManager::GetMIMEMailCharset(
|
NS_IMETHODIMP nsCharsetConverterManager::GetMIMEMailCharset(
|
||||||
nsString * aCharset,
|
nsString * aCharset,
|
||||||
nsString ** aResult)
|
nsString ** aResult)
|
||||||
|
|
|
@ -116,6 +116,9 @@ private:
|
||||||
nsresult AddItemToContainer(nsIRDFService * aRDFServ,
|
nsresult AddItemToContainer(nsIRDFService * aRDFServ,
|
||||||
nsICharsetConverterManager * aCCMan, nsIRDFContainer * aContainer,
|
nsICharsetConverterManager * aCCMan, nsIRDFContainer * aContainer,
|
||||||
nsMenuItem * aItem);
|
nsMenuItem * aItem);
|
||||||
|
nsresult AddFromStringToMenu(char * aCharsetList,
|
||||||
|
nsIRDFService * aRDFServ, nsICharsetConverterManager * aCCMan,
|
||||||
|
nsObjectArray * aObjectArray, nsIRDFContainer * aContainer);
|
||||||
nsresult AddFromPrefsToMenu(nsIPref * aPref, nsIRDFService * aRDFServ,
|
nsresult AddFromPrefsToMenu(nsIPref * aPref, nsIRDFService * aRDFServ,
|
||||||
nsICharsetConverterManager * aCCMan, nsObjectArray * aObjectArray,
|
nsICharsetConverterManager * aCCMan, nsObjectArray * aObjectArray,
|
||||||
nsIRDFContainer * aContainer, char * aKey);
|
nsIRDFContainer * aContainer, char * aKey);
|
||||||
|
@ -532,6 +535,31 @@ nsresult nsCharsetMenu::AddItemToContainer(nsIRDFService * aRDFServ,
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsresult nsCharsetMenu::AddFromStringToMenu(char * aCharsetList,
|
||||||
|
nsIRDFService * aRDFServ,
|
||||||
|
nsICharsetConverterManager * aCCMan,
|
||||||
|
nsObjectArray * aObjectArray,
|
||||||
|
nsIRDFContainer * aContainer)
|
||||||
|
{
|
||||||
|
char * p = aCharsetList;
|
||||||
|
char * q = p;
|
||||||
|
while (*p != 0) {
|
||||||
|
for (; (*q != ',') && (*q != ' ') && (*q != 0); q++);
|
||||||
|
char temp = *q;
|
||||||
|
*q = 0;
|
||||||
|
|
||||||
|
nsAutoString str(p);
|
||||||
|
nsresult res = AddItemToMenu(aRDFServ, aCCMan, aObjectArray, aContainer, &str);
|
||||||
|
NS_ASSERTION(NS_SUCCEEDED(res), "failed to add item to menu");
|
||||||
|
|
||||||
|
*q = temp;
|
||||||
|
for (; (*q == ',') || (*q == ' '); q++);
|
||||||
|
p=q;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
nsresult nsCharsetMenu::AddFromPrefsToMenu(nsIPref * aPref,
|
nsresult nsCharsetMenu::AddFromPrefsToMenu(nsIPref * aPref,
|
||||||
nsIRDFService * aRDFServ,
|
nsIRDFService * aRDFServ,
|
||||||
nsICharsetConverterManager * aCCMan,
|
nsICharsetConverterManager * aCCMan,
|
||||||
|
@ -546,21 +574,7 @@ nsresult nsCharsetMenu::AddFromPrefsToMenu(nsIPref * aPref,
|
||||||
if (NS_FAILED(res)) return res;
|
if (NS_FAILED(res)) return res;
|
||||||
|
|
||||||
if (value != NULL) {
|
if (value != NULL) {
|
||||||
char * p = value;
|
res = AddFromStringToMenu(value, aRDFServ, aCCMan, aObjectArray, aContainer);
|
||||||
char * q = p;
|
|
||||||
while (*p != 0) {
|
|
||||||
for (; (*q != ',') && (*q != ' ') && (*q != 0); q++);
|
|
||||||
char temp = *q;
|
|
||||||
*q = 0;
|
|
||||||
|
|
||||||
nsAutoString str(p);
|
|
||||||
AddItemToMenu(aRDFServ, aCCMan, aObjectArray, aContainer, &str);
|
|
||||||
|
|
||||||
*q = temp;
|
|
||||||
for (; (*q == ',') || (*q == ' '); q++);
|
|
||||||
p=q;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsAllocator::Free(value);
|
nsAllocator::Free(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче