本文整理汇总了C++中ContentChild::GetAvailableDictionaries方法的典型用法代码示例。如果您正苦于以下问题:C++ ContentChild::GetAvailableDictionaries方法的具体用法?C++ ContentChild::GetAvailableDictionaries怎么用?C++ ContentChild::GetAvailableDictionaries使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContentChild
的用法示例。
在下文中一共展示了ContentChild::GetAvailableDictionaries方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetEngineList
NS_IMETHODIMP
mozSpellChecker::GetDictionaryList(nsTArray<nsString> *aDictionaryList)
{
if (XRE_IsContentProcess()) {
ContentChild *child = ContentChild::GetSingleton();
child->GetAvailableDictionaries(*aDictionaryList);
return NS_OK;
}
nsresult rv;
// For catching duplicates
nsTHashtable<nsStringHashKey> dictionaries;
nsCOMArray<mozISpellCheckingEngine> spellCheckingEngines;
rv = GetEngineList(&spellCheckingEngines);
NS_ENSURE_SUCCESS(rv, rv);
for (int32_t i = 0; i < spellCheckingEngines.Count(); i++) {
nsCOMPtr<mozISpellCheckingEngine> engine = spellCheckingEngines[i];
uint32_t count = 0;
char16_t **words = nullptr;
engine->GetDictionaryList(&words, &count);
for (uint32_t k = 0; k < count; k++) {
nsAutoString dictName;
dictName.Assign(words[k]);
// Skip duplicate dictionaries. Only take the first one
// for each name.
if (dictionaries.Contains(dictName))
continue;
dictionaries.PutEntry(dictName);
if (!aDictionaryList->AppendElement(dictName)) {
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, words);
return NS_ERROR_OUT_OF_MEMORY;
}
}
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, words);
}
return NS_OK;
}