зеркало из https://github.com/mozilla/gecko-dev.git
Fixed spellchecker recheck bug.
mozilla/editor/base/nsEditorShell.cpp mozilla/editor/idl/nsIEditorSpellCheck.idl - Modified StartSpellChecking() so that it no longer calls NextMisspelledWord(). - Renamed Start/CloseSpellChecking() to Init/UninitSpellChecker(). - Changed prototype of GetCurrentDictionary() in the idl file. - Replaced all references of NS_SPELLCHECKER_CID with NS_SPELLCHECKER_PROGID. mozilla/editor/txtsvc/public/nsISpellChecker.h - Added NS_SPELLCHECKER_PROGID. mozilla/editor/txtsvc/public/nsTextServicesCID.h - Removed NS_SPELLCHECKER_CID. mozilla/editor/ui/composer/content/ComposerCommands.js - Replaced all calls to Start/CloseSpellChecking() with Init/UninitSpellChecker(). - We now call GetNextMisspelledWord() after initing the spellchecker. mozilla/editor/ui/dialogs/content/EdSpellCheck.js - Dialog now assumes the spellchecker language has been set before the dialog is invoked. - Fixed Recheck() so that it now sets the language.
This commit is contained in:
Родитель
d37caab48c
Коммит
c4f863915d
|
@ -130,7 +130,6 @@
|
|||
static NS_DEFINE_IID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
|
||||
static NS_DEFINE_CID(kHTMLEditorCID, NS_HTMLEDITOR_CID);
|
||||
static NS_DEFINE_CID(kCTextServicesDocumentCID, NS_TEXTSERVICESDOCUMENT_CID);
|
||||
static NS_DEFINE_CID(kCSpellCheckerCID, NS_SPELLCHECKER_CID);
|
||||
static NS_DEFINE_IID(kCFileWidgetCID, NS_FILEWIDGET_CID);
|
||||
static NS_DEFINE_CID(kCStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
|
||||
static NS_DEFINE_CID(kCommonDialogsCID, NS_CommonDialog_CID );
|
||||
|
@ -1050,8 +1049,6 @@ nsEditorShell::ApplyStyleSheet(const PRUnichar *url)
|
|||
NS_IMETHODIMP
|
||||
nsEditorShell::SetDisplayMode(PRInt32 aDisplayMode)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
|
||||
// Reqesting SourceMode and we are already doing that
|
||||
if (aDisplayMode == eDisplayModeSource && mDisplayMode == eDisplayModeSource)
|
||||
return NS_OK;
|
||||
|
@ -4028,10 +4025,10 @@ nsEditorShell::GetEmbeddedObjects(nsISupportsArray **aObjectArray)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorShell::StartSpellChecking(PRUnichar **aFirstMisspelledWord)
|
||||
nsEditorShell::InitSpellChecker()
|
||||
{
|
||||
nsresult result = NS_NOINTERFACE;
|
||||
nsAutoString firstMisspelledWord;
|
||||
|
||||
// We can spell check with any editor type
|
||||
if (mEditor)
|
||||
{
|
||||
|
@ -4059,7 +4056,7 @@ nsEditorShell::StartSpellChecking(PRUnichar **aFirstMisspelledWord)
|
|||
if (NS_FAILED(result))
|
||||
return result;
|
||||
|
||||
result = nsComponentManager::CreateInstance(kCSpellCheckerCID,
|
||||
result = nsComponentManager::CreateInstance(NS_SPELLCHECKER_PROGID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsISpellChecker),
|
||||
(void **)getter_AddRefs(mSpellChecker));
|
||||
|
@ -4076,10 +4073,8 @@ nsEditorShell::StartSpellChecking(PRUnichar **aFirstMisspelledWord)
|
|||
return result;
|
||||
|
||||
DeleteSuggestedWordList();
|
||||
// Return the first misspelled word and initialize the suggested list
|
||||
result = mSpellChecker->NextMisspelledWord(&firstMisspelledWord, &mSuggestedWordList);
|
||||
}
|
||||
*aFirstMisspelledWord = firstMisspelledWord.ToNewUnicode();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -4322,7 +4317,7 @@ nsEditorShell::SetCurrentDictionary(const PRUnichar *aDictionary)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorShell::CloseSpellChecking()
|
||||
nsEditorShell::UninitSpellChecker()
|
||||
{
|
||||
nsresult result = NS_NOINTERFACE;
|
||||
// We can spell check with any editor type
|
||||
|
|
|
@ -130,7 +130,6 @@
|
|||
static NS_DEFINE_IID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
|
||||
static NS_DEFINE_CID(kHTMLEditorCID, NS_HTMLEDITOR_CID);
|
||||
static NS_DEFINE_CID(kCTextServicesDocumentCID, NS_TEXTSERVICESDOCUMENT_CID);
|
||||
static NS_DEFINE_CID(kCSpellCheckerCID, NS_SPELLCHECKER_CID);
|
||||
static NS_DEFINE_IID(kCFileWidgetCID, NS_FILEWIDGET_CID);
|
||||
static NS_DEFINE_CID(kCStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
|
||||
static NS_DEFINE_CID(kCommonDialogsCID, NS_CommonDialog_CID );
|
||||
|
@ -1050,8 +1049,6 @@ nsEditorShell::ApplyStyleSheet(const PRUnichar *url)
|
|||
NS_IMETHODIMP
|
||||
nsEditorShell::SetDisplayMode(PRInt32 aDisplayMode)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
|
||||
// Reqesting SourceMode and we are already doing that
|
||||
if (aDisplayMode == eDisplayModeSource && mDisplayMode == eDisplayModeSource)
|
||||
return NS_OK;
|
||||
|
@ -4028,10 +4025,10 @@ nsEditorShell::GetEmbeddedObjects(nsISupportsArray **aObjectArray)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorShell::StartSpellChecking(PRUnichar **aFirstMisspelledWord)
|
||||
nsEditorShell::InitSpellChecker()
|
||||
{
|
||||
nsresult result = NS_NOINTERFACE;
|
||||
nsAutoString firstMisspelledWord;
|
||||
|
||||
// We can spell check with any editor type
|
||||
if (mEditor)
|
||||
{
|
||||
|
@ -4059,7 +4056,7 @@ nsEditorShell::StartSpellChecking(PRUnichar **aFirstMisspelledWord)
|
|||
if (NS_FAILED(result))
|
||||
return result;
|
||||
|
||||
result = nsComponentManager::CreateInstance(kCSpellCheckerCID,
|
||||
result = nsComponentManager::CreateInstance(NS_SPELLCHECKER_PROGID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsISpellChecker),
|
||||
(void **)getter_AddRefs(mSpellChecker));
|
||||
|
@ -4076,10 +4073,8 @@ nsEditorShell::StartSpellChecking(PRUnichar **aFirstMisspelledWord)
|
|||
return result;
|
||||
|
||||
DeleteSuggestedWordList();
|
||||
// Return the first misspelled word and initialize the suggested list
|
||||
result = mSpellChecker->NextMisspelledWord(&firstMisspelledWord, &mSuggestedWordList);
|
||||
}
|
||||
*aFirstMisspelledWord = firstMisspelledWord.ToNewUnicode();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -4322,7 +4317,7 @@ nsEditorShell::SetCurrentDictionary(const PRUnichar *aDictionary)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorShell::CloseSpellChecking()
|
||||
nsEditorShell::UninitSpellChecker()
|
||||
{
|
||||
nsresult result = NS_NOINTERFACE;
|
||||
// We can spell check with any editor type
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
interface nsIEditorSpellCheck : nsISupports
|
||||
{
|
||||
|
||||
wstring StartSpellChecking();
|
||||
void InitSpellChecker();
|
||||
wstring GetNextMisspelledWord();
|
||||
wstring GetSuggestedWord();
|
||||
boolean CheckCurrentWord(in wstring suggestedWord);
|
||||
|
@ -37,8 +37,8 @@ interface nsIEditorSpellCheck : nsISupports
|
|||
void AddWordToDictionary(in wstring word);
|
||||
void RemoveWordFromDictionary(in wstring word);
|
||||
void GetDictionaryList([array, size_is(count)] out wstring dictionaryList, out PRUint32 count);
|
||||
void GetCurrentDictionary(out wstring dictionary);
|
||||
wstring GetCurrentDictionary();
|
||||
void SetCurrentDictionary(in wstring dictionary);
|
||||
void CloseSpellChecking();
|
||||
void UninitSpellChecker();
|
||||
|
||||
};
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
#include "nsISupports.h"
|
||||
|
||||
#define NS_SPELLCHECKER_PROGID "mozilla.spellchecker.1"
|
||||
|
||||
#define NS_ISPELLCHECKER_IID \
|
||||
{ /* F72A52F1-F83B-11d2-8D54-000064657374 */ \
|
||||
0xf72a52f1, 0xf83b, 0x11d2, \
|
||||
|
|
|
@ -33,9 +33,4 @@
|
|||
0x019718e3, 0xcdb5, 0x11d2, \
|
||||
{ 0x8d, 0x3c, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
|
||||
|
||||
#define NS_SPELLCHECKER_CID \
|
||||
{ /* 019718E4-CDB5-11d2-8D3C-000000000000 */ \
|
||||
0x019718e4, 0xcdb5, 0x11d2, \
|
||||
{ 0x8d, 0x3c, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
|
||||
|
||||
#endif /* nsTextServicesCID_h__ */
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
#include "nsISupports.h"
|
||||
|
||||
#define NS_SPELLCHECKER_PROGID "mozilla.spellchecker.1"
|
||||
|
||||
#define NS_ISPELLCHECKER_IID \
|
||||
{ /* F72A52F1-F83B-11d2-8D54-000064657374 */ \
|
||||
0xf72a52f1, 0xf83b, 0x11d2, \
|
||||
|
|
|
@ -33,9 +33,4 @@
|
|||
0x019718e3, 0xcdb5, 0x11d2, \
|
||||
{ 0x8d, 0x3c, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
|
||||
|
||||
#define NS_SPELLCHECKER_CID \
|
||||
{ /* 019718E4-CDB5-11d2-8D3C-000000000000 */ \
|
||||
0x019718e4, 0xcdb5, 0x11d2, \
|
||||
{ 0x8d, 0x3c, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
|
||||
|
||||
#endif /* nsTextServicesCID_h__ */
|
||||
|
|
|
@ -225,19 +225,25 @@ var nsSpellingCommand =
|
|||
// dump("Check Spelling starting...\n");
|
||||
// Start the spell checker module. Return is first misspelled word
|
||||
try {
|
||||
firstMisspelledWord = spellChecker.StartSpellChecking();
|
||||
spellChecker.InitSpellChecker();
|
||||
|
||||
// XXX: We need to read in a pref here so we can set the
|
||||
// default language for the spellchecker!
|
||||
// spellChecker.SetCurrentDictionary();
|
||||
|
||||
firstMisspelledWord = spellChecker.GetNextMisspelledWord();
|
||||
}
|
||||
catch(ex) {
|
||||
dump("*** Exception error: StartSpellChecking\n");
|
||||
dump("*** Exception error: InitSpellChecker\n");
|
||||
return;
|
||||
}
|
||||
if( firstMisspelledWord == "")
|
||||
{
|
||||
try {
|
||||
spellChecker.CloseSpellChecking();
|
||||
spellChecker.UninitSpellChecker();
|
||||
}
|
||||
catch(ex) {
|
||||
dump("*** Exception error: CloseSpellChecking\n");
|
||||
dump("*** Exception error: UnInitSpellChecker\n");
|
||||
return;
|
||||
}
|
||||
// No misspelled word - tell user
|
||||
|
|
|
@ -76,14 +76,28 @@ function Startup()
|
|||
dialog.ReplaceWordInput.value = MisspelledWord;
|
||||
|
||||
if (dialog.LanguageMenulist)
|
||||
InitLanguageMenu("");
|
||||
{
|
||||
// Fill in the language menulist and sync it up
|
||||
// with the spellchecker's current language.
|
||||
|
||||
var curLang;
|
||||
|
||||
try {
|
||||
curLang = spellChecker.GetCurrentDictionary();
|
||||
} catch(ex) {
|
||||
dump(ex);
|
||||
curLang = "";
|
||||
}
|
||||
|
||||
InitLanguageMenu(curLang);
|
||||
}
|
||||
|
||||
DoEnabling();
|
||||
|
||||
dialog.SuggestedList.focus();
|
||||
}
|
||||
|
||||
function InitLanguageMenu(defaultLangStr)
|
||||
function InitLanguageMenu(curLang)
|
||||
{
|
||||
ClearMenulist(dialog.LanguageMenulist);
|
||||
|
||||
|
@ -113,7 +127,7 @@ function InitLanguageMenu(defaultLangStr)
|
|||
if (!menuStr)
|
||||
menuStr = dictList[i];
|
||||
|
||||
if (defaultLangStr && dictList[i] == defaultLangStr)
|
||||
if (curLang && dictList[i] == curLang)
|
||||
defaultIndex = i;
|
||||
} catch (ex) {
|
||||
// GetStringFromName throws an exception when
|
||||
|
@ -126,14 +140,10 @@ function InitLanguageMenu(defaultLangStr)
|
|||
AppendValueAndDataToMenulist(dialog.LanguageMenulist, menuStr, dictList[i]);
|
||||
}
|
||||
|
||||
// Now make sure the correct item in the menu list
|
||||
// is selected and that the spellchecker is in sync!
|
||||
// Now make sure the correct item in the menu list is selected.
|
||||
|
||||
if (dictList.length > 0)
|
||||
{
|
||||
dialog.LanguageMenulist.selectedIndex = defaultIndex;
|
||||
// SelectLanguage();
|
||||
}
|
||||
}
|
||||
|
||||
function DoEnabling()
|
||||
|
@ -289,15 +299,23 @@ function SelectLanguage()
|
|||
function Recheck()
|
||||
{
|
||||
//TODO: Should we bother to add a "Recheck" method to interface?
|
||||
spellChecker.CloseSpellChecking();
|
||||
MisspelledWord = spellChecker.StartSpellChecking();
|
||||
SetWidgetsForMisspelledWord();
|
||||
try {
|
||||
var curLang = spellChecker.GetCurrentDictionary();
|
||||
|
||||
spellChecker.UninitSpellChecker();
|
||||
spellChecker.InitSpellChecker();
|
||||
spellChecker.SetCurrentDictionary(curLang);
|
||||
MisspelledWord = spellChecker.GetNextMisspelledWord();
|
||||
SetWidgetsForMisspelledWord();
|
||||
} catch(ex) {
|
||||
dump(ex);
|
||||
}
|
||||
}
|
||||
|
||||
function Close()
|
||||
{
|
||||
// Shutdown the spell check and close the dialog
|
||||
spellChecker.CloseSpellChecking();
|
||||
spellChecker.UninitSpellChecker();
|
||||
window.close();
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче