Finished Personal Dictionary dialog. Added 4th button to generic message dialog. Cleaned up syntax errors for in params for spell checking methods

git-svn-id: svn://10.0.0.236/trunk@39531 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
cmanske%netscape.com
1999-07-15 14:43:48 +00:00
parent 1b730ce55e
commit 48cf0087a1
12 changed files with 326 additions and 127 deletions

View File

@@ -130,19 +130,20 @@ NS_NewEditorShell(nsIEditorShell** aEditorShell)
/////////////////////////////////////////////////////////////////////////
nsEditorShell::nsEditorShell()
: mSuggestedWordIndex(0)
, mToolbarWindow(nsnull)
: mToolbarWindow(nsnull)
, mContentWindow(nsnull)
, mWebShellWin(nsnull)
, mWebShell(nsnull)
, mContentAreaWebShell(nsnull)
, mEditorType(eUninitializedEditorType)
, mWrapColumn(0)
, mSuggestedWordIndex(0)
, mDictionaryIndex(0)
{
#ifdef APP_DEBUG
printf("Created nsEditorShell\n");
#endif
NS_INIT_REFCNT();
}
@@ -609,6 +610,13 @@ NS_IMETHODIMP nsEditorShell::SetBackgroundColor(const PRUnichar *color)
result = htmlEditor->SetBackgroundColor(aColor);
break;
}
case ePlainTextEditorType:
{
nsCOMPtr<nsITextEditor> textEditor = do_QueryInterface(mEditor);
if (textEditor)
result = textEditor->SetBackgroundColor(aColor);
}
break;
default:
result = NS_ERROR_NOT_IMPLEMENTED;
}
@@ -2019,10 +2027,10 @@ nsEditorShell::SetSelectionAfterElement(nsIDOMElement* aElement)
}
NS_IMETHODIMP
nsEditorShell::StartSpellChecking(PRUnichar **firstMisspelledWord)
nsEditorShell::StartSpellChecking(PRUnichar **aFirstMisspelledWord)
{
nsresult result = NS_NOINTERFACE;
nsAutoString aFirstMisspelledWord;
nsAutoString firstMisspelledWord;
// We can spell check with any editor type
if (mEditor)
{
@@ -2068,125 +2076,148 @@ nsEditorShell::StartSpellChecking(PRUnichar **firstMisspelledWord)
DeleteSuggestedWordList();
// Return the first misspelled word and initialize the suggested list
result = mSpellChecker->NextMisspelledWord(&aFirstMisspelledWord, &mSuggestedWordList);
result = mSpellChecker->NextMisspelledWord(&firstMisspelledWord, &mSuggestedWordList);
}
*firstMisspelledWord = aFirstMisspelledWord.ToNewUnicode();
*aFirstMisspelledWord = firstMisspelledWord.ToNewUnicode();
return result;
}
NS_IMETHODIMP
nsEditorShell::GetNextMisspelledWord(PRUnichar **nextMisspelledWord)
nsEditorShell::GetNextMisspelledWord(PRUnichar **aNextMisspelledWord)
{
nsresult result = NS_NOINTERFACE;
nsAutoString aNextMisspelledWord;
nsAutoString nextMisspelledWord;
// We can spell check with any editor type
if (mEditor && mSpellChecker)
{
DeleteSuggestedWordList();
result = mSpellChecker->NextMisspelledWord(&aNextMisspelledWord, &mSuggestedWordList);
result = mSpellChecker->NextMisspelledWord(&nextMisspelledWord, &mSuggestedWordList);
}
*nextMisspelledWord = aNextMisspelledWord.ToNewUnicode();
*aNextMisspelledWord = nextMisspelledWord.ToNewUnicode();
return result;
}
NS_IMETHODIMP
nsEditorShell::GetSuggestedWord(PRUnichar **suggestedWord)
nsEditorShell::GetSuggestedWord(PRUnichar **aSuggestedWord)
{
nsresult result = NS_NOINTERFACE;
nsAutoString aSuggestedWord;
nsAutoString word;
// We can spell check with any editor type
if (mEditor)
{
if ( mSuggestedWordIndex < mSuggestedWordList.Count())
{
mSuggestedWordList.StringAt(mSuggestedWordIndex, aSuggestedWord);
mSuggestedWordList.StringAt(mSuggestedWordIndex, word);
mSuggestedWordIndex++;
} else {
// A blank string signals that there are no more strings
aSuggestedWord = "";
word = "";
}
result = NS_OK;
}
*suggestedWord = aSuggestedWord.ToNewUnicode();
*aSuggestedWord = word.ToNewUnicode();
return result;
}
NS_IMETHODIMP
nsEditorShell::CheckCurrentWord(const PRUnichar *suggestedWord, PRBool *aIsMisspelled)
nsEditorShell::CheckCurrentWord(const PRUnichar *aSuggestedWord, PRBool *aIsMisspelled)
{
nsresult result = NS_NOINTERFACE;
nsAutoString aSuggestedWord(suggestedWord);
nsAutoString suggestedWord(aSuggestedWord);
// We can spell check with any editor type
if (mEditor && mSpellChecker)
{
DeleteSuggestedWordList();
result = mSpellChecker->CheckWord(&aSuggestedWord, aIsMisspelled, &mSuggestedWordList);
result = mSpellChecker->CheckWord(&suggestedWord, aIsMisspelled, &mSuggestedWordList);
}
return result;
}
NS_IMETHODIMP
nsEditorShell::ReplaceWord(const PRUnichar *misspelledWord, const PRUnichar *replaceWord, PRBool allOccurrences)
nsEditorShell::ReplaceWord(const PRUnichar *aMisspelledWord, const PRUnichar *aReplaceWord, PRBool allOccurrences)
{
nsresult result = NS_NOINTERFACE;
nsAutoString aMisspelledWord(misspelledWord);
nsAutoString aReplaceWord(replaceWord);
nsAutoString misspelledWord(aMisspelledWord);
nsAutoString replaceWord(aReplaceWord);
if (mEditor && mSpellChecker)
{
result = mSpellChecker->Replace(&aMisspelledWord, &aReplaceWord, allOccurrences);
result = mSpellChecker->Replace(&misspelledWord, &replaceWord, allOccurrences);
}
return result;
}
NS_IMETHODIMP
nsEditorShell::IgnoreWordAllOccurrences(const PRUnichar *word)
nsEditorShell::IgnoreWordAllOccurrences(const PRUnichar *aWord)
{
nsresult result = NS_NOINTERFACE;
nsAutoString aWord(word);
nsAutoString word(aWord);
if (mEditor && mSpellChecker)
{
result = mSpellChecker->IgnoreAll(&aWord);
result = mSpellChecker->IgnoreAll(&word);
}
return result;
}
NS_IMETHODIMP
nsEditorShell::AddWordToDictionary(const PRUnichar *word)
nsEditorShell::GetPersonalDictionary()
{
nsresult result = NS_NOINTERFACE;
nsAutoString aWord(word);
// We can spell check with any editor type
if (mEditor && mSpellChecker)
{
result = mSpellChecker->AddWordToPersonalDictionary(&aWord);
mDictionaryList.Clear();
mDictionaryIndex = 0;
result = mSpellChecker->GetPersonalDictionary(&mDictionaryList);
}
return result;
}
NS_IMETHODIMP
nsEditorShell::RemoveWordFromDictionary(const PRUnichar *word)
nsEditorShell::GetPersonalDictionaryWord(PRUnichar **aDictionaryWord)
{
nsresult result = NS_NOINTERFACE;
nsAutoString aWord(word);
nsAutoString word;
if (mEditor)
{
if ( mDictionaryIndex < mDictionaryList.Count())
{
mDictionaryList.StringAt(mDictionaryIndex, word);
mDictionaryIndex++;
} else {
// A blank string signals that there are no more strings
word = "";
}
result = NS_OK;
}
*aDictionaryWord = word.ToNewUnicode();
return result;
}
NS_IMETHODIMP
nsEditorShell::AddWordToDictionary(const PRUnichar *aWord)
{
nsresult result = NS_NOINTERFACE;
nsString word(aWord);
if (mEditor && mSpellChecker)
{
result = mSpellChecker->RemoveWordFromPersonalDictionary(&aWord);
result = mSpellChecker->AddWordToPersonalDictionary(&word);
}
return result;
}
NS_IMETHODIMP
nsEditorShell::GetPersonalDictionaryWord(const PRUnichar *word, PRUnichar **suggestedWord)
nsEditorShell::RemoveWordFromDictionary(const PRUnichar *aWord)
{
nsresult result = NS_NOINTERFACE;
nsString word(aWord);
if (mEditor && mSpellChecker)
{
printf("GetPersonalDictionaryWord NOT IMPLEMENTED\n");
result = mSpellChecker->RemoveWordFromPersonalDictionary(&word);
}
return result;
}
NS_IMETHODIMP
nsEditorShell::CloseSpellChecking()
{
@@ -2196,6 +2227,8 @@ nsEditorShell::CloseSpellChecking()
{
// Cleanup - kill the spell checker
DeleteSuggestedWordList();
mDictionaryList.Clear();
mDictionaryIndex = 0;
mSpellChecker = 0;
result = NS_OK;
}

View File

@@ -184,16 +184,17 @@ class nsEditorShell : public nsIEditorShell,
/* Spell check interface */
NS_IMETHOD StartSpellChecking(PRUnichar **_retval);
NS_IMETHOD GetNextMisspelledWord(PRUnichar **_retval);
NS_IMETHOD GetSuggestedWord(PRUnichar **_retval);
NS_IMETHOD CheckCurrentWord(const PRUnichar *suggestedWord, PRBool *_retval);
NS_IMETHOD ReplaceWord(const PRUnichar *misspelledWord, const PRUnichar *replaceWord, PRBool allOccurrences);
NS_IMETHOD IgnoreWordAllOccurrences(const PRUnichar *word);
NS_IMETHOD AddWordToDictionary(const PRUnichar *word);
NS_IMETHOD RemoveWordFromDictionary(const PRUnichar *word);
NS_IMETHOD GetPersonalDictionaryWord(const PRUnichar *word, PRUnichar **_retval);
NS_IMETHOD CloseSpellChecking();
NS_IMETHOD StartSpellChecking(PRUnichar **_retval);
NS_IMETHOD GetNextMisspelledWord(PRUnichar **_retval);
NS_IMETHOD GetSuggestedWord(PRUnichar **_retval);
NS_IMETHOD CheckCurrentWord(const PRUnichar *suggestedWord, PRBool *_retval);
NS_IMETHOD ReplaceWord(const PRUnichar *misspelledWord, const PRUnichar *replaceWord, PRBool allOccurrences);
NS_IMETHOD IgnoreWordAllOccurrences(const PRUnichar *word);
NS_IMETHOD GetPersonalDictionary();
NS_IMETHOD GetPersonalDictionaryWord(PRUnichar **_retval);
NS_IMETHOD AddWordToDictionary(const PRUnichar *word);
NS_IMETHOD RemoveWordFromDictionary(const PRUnichar *word);
NS_IMETHOD CloseSpellChecking();
// nsIDocumentLoaderObserver

View File

@@ -130,19 +130,20 @@ NS_NewEditorShell(nsIEditorShell** aEditorShell)
/////////////////////////////////////////////////////////////////////////
nsEditorShell::nsEditorShell()
: mSuggestedWordIndex(0)
, mToolbarWindow(nsnull)
: mToolbarWindow(nsnull)
, mContentWindow(nsnull)
, mWebShellWin(nsnull)
, mWebShell(nsnull)
, mContentAreaWebShell(nsnull)
, mEditorType(eUninitializedEditorType)
, mWrapColumn(0)
, mSuggestedWordIndex(0)
, mDictionaryIndex(0)
{
#ifdef APP_DEBUG
printf("Created nsEditorShell\n");
#endif
NS_INIT_REFCNT();
}
@@ -609,6 +610,13 @@ NS_IMETHODIMP nsEditorShell::SetBackgroundColor(const PRUnichar *color)
result = htmlEditor->SetBackgroundColor(aColor);
break;
}
case ePlainTextEditorType:
{
nsCOMPtr<nsITextEditor> textEditor = do_QueryInterface(mEditor);
if (textEditor)
result = textEditor->SetBackgroundColor(aColor);
}
break;
default:
result = NS_ERROR_NOT_IMPLEMENTED;
}
@@ -2019,10 +2027,10 @@ nsEditorShell::SetSelectionAfterElement(nsIDOMElement* aElement)
}
NS_IMETHODIMP
nsEditorShell::StartSpellChecking(PRUnichar **firstMisspelledWord)
nsEditorShell::StartSpellChecking(PRUnichar **aFirstMisspelledWord)
{
nsresult result = NS_NOINTERFACE;
nsAutoString aFirstMisspelledWord;
nsAutoString firstMisspelledWord;
// We can spell check with any editor type
if (mEditor)
{
@@ -2068,125 +2076,148 @@ nsEditorShell::StartSpellChecking(PRUnichar **firstMisspelledWord)
DeleteSuggestedWordList();
// Return the first misspelled word and initialize the suggested list
result = mSpellChecker->NextMisspelledWord(&aFirstMisspelledWord, &mSuggestedWordList);
result = mSpellChecker->NextMisspelledWord(&firstMisspelledWord, &mSuggestedWordList);
}
*firstMisspelledWord = aFirstMisspelledWord.ToNewUnicode();
*aFirstMisspelledWord = firstMisspelledWord.ToNewUnicode();
return result;
}
NS_IMETHODIMP
nsEditorShell::GetNextMisspelledWord(PRUnichar **nextMisspelledWord)
nsEditorShell::GetNextMisspelledWord(PRUnichar **aNextMisspelledWord)
{
nsresult result = NS_NOINTERFACE;
nsAutoString aNextMisspelledWord;
nsAutoString nextMisspelledWord;
// We can spell check with any editor type
if (mEditor && mSpellChecker)
{
DeleteSuggestedWordList();
result = mSpellChecker->NextMisspelledWord(&aNextMisspelledWord, &mSuggestedWordList);
result = mSpellChecker->NextMisspelledWord(&nextMisspelledWord, &mSuggestedWordList);
}
*nextMisspelledWord = aNextMisspelledWord.ToNewUnicode();
*aNextMisspelledWord = nextMisspelledWord.ToNewUnicode();
return result;
}
NS_IMETHODIMP
nsEditorShell::GetSuggestedWord(PRUnichar **suggestedWord)
nsEditorShell::GetSuggestedWord(PRUnichar **aSuggestedWord)
{
nsresult result = NS_NOINTERFACE;
nsAutoString aSuggestedWord;
nsAutoString word;
// We can spell check with any editor type
if (mEditor)
{
if ( mSuggestedWordIndex < mSuggestedWordList.Count())
{
mSuggestedWordList.StringAt(mSuggestedWordIndex, aSuggestedWord);
mSuggestedWordList.StringAt(mSuggestedWordIndex, word);
mSuggestedWordIndex++;
} else {
// A blank string signals that there are no more strings
aSuggestedWord = "";
word = "";
}
result = NS_OK;
}
*suggestedWord = aSuggestedWord.ToNewUnicode();
*aSuggestedWord = word.ToNewUnicode();
return result;
}
NS_IMETHODIMP
nsEditorShell::CheckCurrentWord(const PRUnichar *suggestedWord, PRBool *aIsMisspelled)
nsEditorShell::CheckCurrentWord(const PRUnichar *aSuggestedWord, PRBool *aIsMisspelled)
{
nsresult result = NS_NOINTERFACE;
nsAutoString aSuggestedWord(suggestedWord);
nsAutoString suggestedWord(aSuggestedWord);
// We can spell check with any editor type
if (mEditor && mSpellChecker)
{
DeleteSuggestedWordList();
result = mSpellChecker->CheckWord(&aSuggestedWord, aIsMisspelled, &mSuggestedWordList);
result = mSpellChecker->CheckWord(&suggestedWord, aIsMisspelled, &mSuggestedWordList);
}
return result;
}
NS_IMETHODIMP
nsEditorShell::ReplaceWord(const PRUnichar *misspelledWord, const PRUnichar *replaceWord, PRBool allOccurrences)
nsEditorShell::ReplaceWord(const PRUnichar *aMisspelledWord, const PRUnichar *aReplaceWord, PRBool allOccurrences)
{
nsresult result = NS_NOINTERFACE;
nsAutoString aMisspelledWord(misspelledWord);
nsAutoString aReplaceWord(replaceWord);
nsAutoString misspelledWord(aMisspelledWord);
nsAutoString replaceWord(aReplaceWord);
if (mEditor && mSpellChecker)
{
result = mSpellChecker->Replace(&aMisspelledWord, &aReplaceWord, allOccurrences);
result = mSpellChecker->Replace(&misspelledWord, &replaceWord, allOccurrences);
}
return result;
}
NS_IMETHODIMP
nsEditorShell::IgnoreWordAllOccurrences(const PRUnichar *word)
nsEditorShell::IgnoreWordAllOccurrences(const PRUnichar *aWord)
{
nsresult result = NS_NOINTERFACE;
nsAutoString aWord(word);
nsAutoString word(aWord);
if (mEditor && mSpellChecker)
{
result = mSpellChecker->IgnoreAll(&aWord);
result = mSpellChecker->IgnoreAll(&word);
}
return result;
}
NS_IMETHODIMP
nsEditorShell::AddWordToDictionary(const PRUnichar *word)
nsEditorShell::GetPersonalDictionary()
{
nsresult result = NS_NOINTERFACE;
nsAutoString aWord(word);
// We can spell check with any editor type
if (mEditor && mSpellChecker)
{
result = mSpellChecker->AddWordToPersonalDictionary(&aWord);
mDictionaryList.Clear();
mDictionaryIndex = 0;
result = mSpellChecker->GetPersonalDictionary(&mDictionaryList);
}
return result;
}
NS_IMETHODIMP
nsEditorShell::RemoveWordFromDictionary(const PRUnichar *word)
nsEditorShell::GetPersonalDictionaryWord(PRUnichar **aDictionaryWord)
{
nsresult result = NS_NOINTERFACE;
nsAutoString aWord(word);
nsAutoString word;
if (mEditor)
{
if ( mDictionaryIndex < mDictionaryList.Count())
{
mDictionaryList.StringAt(mDictionaryIndex, word);
mDictionaryIndex++;
} else {
// A blank string signals that there are no more strings
word = "";
}
result = NS_OK;
}
*aDictionaryWord = word.ToNewUnicode();
return result;
}
NS_IMETHODIMP
nsEditorShell::AddWordToDictionary(const PRUnichar *aWord)
{
nsresult result = NS_NOINTERFACE;
nsString word(aWord);
if (mEditor && mSpellChecker)
{
result = mSpellChecker->RemoveWordFromPersonalDictionary(&aWord);
result = mSpellChecker->AddWordToPersonalDictionary(&word);
}
return result;
}
NS_IMETHODIMP
nsEditorShell::GetPersonalDictionaryWord(const PRUnichar *word, PRUnichar **suggestedWord)
nsEditorShell::RemoveWordFromDictionary(const PRUnichar *aWord)
{
nsresult result = NS_NOINTERFACE;
nsString word(aWord);
if (mEditor && mSpellChecker)
{
printf("GetPersonalDictionaryWord NOT IMPLEMENTED\n");
result = mSpellChecker->RemoveWordFromPersonalDictionary(&word);
}
return result;
}
NS_IMETHODIMP
nsEditorShell::CloseSpellChecking()
{
@@ -2196,6 +2227,8 @@ nsEditorShell::CloseSpellChecking()
{
// Cleanup - kill the spell checker
DeleteSuggestedWordList();
mDictionaryList.Clear();
mDictionaryIndex = 0;
mSpellChecker = 0;
result = NS_OK;
}

View File

@@ -184,16 +184,17 @@ class nsEditorShell : public nsIEditorShell,
/* Spell check interface */
NS_IMETHOD StartSpellChecking(PRUnichar **_retval);
NS_IMETHOD GetNextMisspelledWord(PRUnichar **_retval);
NS_IMETHOD GetSuggestedWord(PRUnichar **_retval);
NS_IMETHOD CheckCurrentWord(const PRUnichar *suggestedWord, PRBool *_retval);
NS_IMETHOD ReplaceWord(const PRUnichar *misspelledWord, const PRUnichar *replaceWord, PRBool allOccurrences);
NS_IMETHOD IgnoreWordAllOccurrences(const PRUnichar *word);
NS_IMETHOD AddWordToDictionary(const PRUnichar *word);
NS_IMETHOD RemoveWordFromDictionary(const PRUnichar *word);
NS_IMETHOD GetPersonalDictionaryWord(const PRUnichar *word, PRUnichar **_retval);
NS_IMETHOD CloseSpellChecking();
NS_IMETHOD StartSpellChecking(PRUnichar **_retval);
NS_IMETHOD GetNextMisspelledWord(PRUnichar **_retval);
NS_IMETHOD GetSuggestedWord(PRUnichar **_retval);
NS_IMETHOD CheckCurrentWord(const PRUnichar *suggestedWord, PRBool *_retval);
NS_IMETHOD ReplaceWord(const PRUnichar *misspelledWord, const PRUnichar *replaceWord, PRBool allOccurrences);
NS_IMETHOD IgnoreWordAllOccurrences(const PRUnichar *word);
NS_IMETHOD GetPersonalDictionary();
NS_IMETHOD GetPersonalDictionaryWord(PRUnichar **_retval);
NS_IMETHOD AddWordToDictionary(const PRUnichar *word);
NS_IMETHOD RemoveWordFromDictionary(const PRUnichar *word);
NS_IMETHOD CloseSpellChecking();
// nsIDocumentLoaderObserver

View File

@@ -28,9 +28,10 @@ interface nsIEditorSpellCheck : nsISupports
boolean CheckCurrentWord(in wstring suggestedWord);
void ReplaceWord(in wstring misspelledWord, in wstring replaceWord, in boolean allOccurrences);
void IgnoreWordAllOccurrences(in wstring word);
void GetPersonalDictionary();
wstring GetPersonalDictionaryWord();
void AddWordToDictionary(in wstring word);
void RemoveWordFromDictionary(in wstring word);
wstring GetPersonalDictionaryWord(in wstring word);
void CloseSpellChecking();
};

View File

@@ -27,6 +27,37 @@ function ClearList(list)
}
}
function ReplaceStringInList(list, index, string)
{
//Hmmm... We should be able to simply set the "text" and "value"
// properties of the option element, but setting "text" doesn't work.
// Replace with a new node instead:
if (index < list.options.length)
{
/*
node = list.options[index];
dump("BEFORE Option node text: "+node.text+" Value: "+node.value+"\n");
node.text = string;
node.value = string;
dump("AFTER Option node text: "+node.text+" Value: "+node.value+"\n");
*/
// Save and remove selection else we have trouble below!
// (This must be a bug!)
selIndex = list.selectedIndex;
list.selectedIndex = -1;
optionNode = new Option(string, string);
// Remove existing option node
//list.remove(index);
list.options[index] = null;
// Insert the new node
list.options[index] = optionNode;
// NOTE: If we insert, then remove, we crash!
// Reset the selected item
list.selectedIndex = selIndex;
}
}
function AppendStringToList(list, string)
{

View File

@@ -1,4 +1,7 @@
var spellChecker;
var WordToAdd;
var WordInput;
var DictionaryList;
function Startup()
{
@@ -12,38 +15,125 @@ function Startup()
dump("SpellChecker not found!!!\n");
window.close();
}
// The word to add word is passed as the 2nd extra parameter in window.openDialog()
WordToAdd = window.arguments[1];
// Create dialog object to store controls for easy access
dialog = new Object;
// GET EACH CONTROL -- E.G.:
//dialog.editBox = document.getElementById("editBox");
// SET FOCUS TO FIRST CONTROL
//dialog.editBox.focus();
WordInput = document.getElementById("WordInput");
DictionaryList = document.getElementById("DictionaryList");
WordInput.value = WordToAdd;
FillDictionaryList();
// Select the supplied word if it is already in the list
SelectWordToAddInList();
WordInput.focus();
}
function SelectWord()
function ValidateWordToAdd()
{
dump("SelectWord\n");
WordToAdd = TrimString(WordInput.value);
if (WordToAdd.length > 0) {
return true;
} else {
return false;
}
}
function SelectWordToAddInList()
{
for (index = 0; index < DictionaryList.length; index++) {
if (WordToAdd.toLowerCase() == DictionaryList.options[index].text.toLowerCase()) {
DictionaryList.selectedIndex = index;
break;
}
}
}
function AddWord()
{
dump("AddWord\n");
if (ValidateWordToAdd()) {
try {
spellChecker.AddWordToDictionary(WordToAdd);
}
catch (e) {
dump("Exception occured in spellChecker.AddWordToDictionary\nWord to add probably already existed");
}
// Rebuild the dialog list
FillDictionaryList();
SelectWordToAddInList();
}
}
function ReplaceWord()
{
dump("ReplaceWord\n");
if (ValidateWordToAdd()) {
selIndex = DictionaryList.selectedIndex;
if (selIndex >= 0) {
WordToRemove = DictionaryList.options[selIndex].text;
dump("Word to remove: "+WordToRemove+"\n");
spellChecker.RemoveWordFromDictionary(WordToRemove);
try {
// Add to the dictionary list
spellChecker.AddWordToDictionary(WordToAdd);
// Just change the text on the selected item
// instead of rebuilding the list
ReplaceStringInList(DictionaryList, selIndex, WordToAdd);
} catch (e) {
// Rebuild list and select the word - it was probably already in the list
dump("Exception occured adding word in ReplaceWord\n");
FillDictionaryList();
SelectWordToAddInList();
}
}
}
}
function RemoveWord()
{
dump("RemoveWord\n");
selIndex = DictionaryList.selectedIndex;
if (selIndex >= 0) {
word = TrimString(DictionaryList.options[selIndex].text);
// Remove word from list
DictionaryList.options[selIndex] = null;
// Remove from dictionary
spellChecker.RemoveWordFromDictionary(word);
ResetSelectedItem(selIndex);
}
}
function onOK()
function FillDictionaryList()
{
window.close();
selIndex = DictionaryList.selectedIndex;
// Clear the current contents of the list
ClearList(DictionaryList);
// Get the list from the spell checker
spellChecker.GetPersonalDictionary()
// Get words until an empty string is returned
do {
word = spellChecker.GetPersonalDictionaryWord();
if (word != "") {
AppendStringToList(DictionaryList, word);
}
} while (word != "");
ResetSelectedItem(selIndex);
}
function ResetSelectedItem(index)
{
lastIndex = DictionaryList.length - 1;
if (index > lastIndex)
index = lastIndex;
// If we didn't have a selected item,
// set it to the first item
if (index == -1 && lastIndex >= 0)
index = 0;
DictionaryList.selectedIndex = index;
}

View File

@@ -20,12 +20,12 @@
<table>
<tr>
<td colspan="2">
NewWord<br/>
New word:<br/>
</td>
</tr>
<tr>
<td>
<input type="text" class="SpellCheckWord" id="Word" size="10"/>
<input type="text" class="SpellCheckWord" id="WordInput" size="10"/>
</td>
<td>
<xul:titledbutton class="SizeToCell" id="AddWord" onclick="AddWord()" value="Add"/>
@@ -33,31 +33,22 @@
</tr>
<tr>
<td colspan="2">
Words:
Words in dictionary:
</td>
</tr>
<tr>
<td>
<select class="SpellCheckList" id="SuggestedList" size="6" onchange="SelectWord()">
<option>Sample contents 1</option>
<option>Sample contents 2</option>
<option>Sample contents 3</option>
<select class="SpellCheckList" id="DictionaryList" size="10">
</select>
</td>
</tr>
<tr>
<td>
<xul:titledbutton class="SizeToCell" id="ReplaceWord" onclick="ReplaceWord()" value="Replace"/>
<br/>
<xul:titledbutton class="SizeToCell" id="RemoveWord" onclick="RemoveWord()" value="Remove"/>
<br/>
<!-- This simply closes the window -->
<xul:titledbutton class="CloseButton" id="Close" onclick="onCancel()" value="Close"/>
</td>
</tr>
</table>
<xul:box>
<xul:spring flex="100%"/>
<xul:titledbutton class="spaced" id="OK" onclick="onOK()" value="OK"/>
<xul:titledbutton class="spaced" id="Cancel" onclick="onCancel()" value="Cancel"/>
<xul:spring flex="100%"/>
</xul:box>
</xul:window>

View File

@@ -57,6 +57,7 @@ function Startup()
button1 = document.getElementById("button1");
button2 = document.getElementById("button2");
button3 = document.getElementById("button3");
button4 = document.getElementById("button4");
// All buttons must have the same parent
buttonParent = button1.parentNode;
@@ -87,6 +88,15 @@ function Startup()
} else {
buttonParent.removeChild(button3);
}
button4Text = window.arguments[6];
if (button4Text && button4Text.length > 0)
{
dump(button4Text+"\n");
button4.setAttribute("value", button4Text);
} else {
buttonParent.removeChild(button4);
}
}
function onButton1()
@@ -106,3 +116,9 @@ function onButton3()
window.opener.msgResult = 3;
window.close();
}
function onButton3()
{
window.opener.msgResult = 4;
window.close();
}

View File

@@ -24,6 +24,7 @@
<titledbutton class="MsgButton" id="button1" onclick="onButton1()"/>
<titledbutton class="MsgButton" id="button2" onclick="onButton2()"/>
<titledbutton class="MsgButton" id="button3" onclick="onButton3()"/>
<titledbutton class="MsgButton" id="button4" onclick="onButton4()"/>
<spring flex="100%"/>
</box>
</window>

View File

@@ -67,9 +67,6 @@
<tr>
<td rowspan="5">
<select class="SpellCheckList" id="SuggestedList" size="8" onchange="SelectSuggestedWord()">
<option>Sample contents 1</option>
<option>Sample contents 2</option>
<option>Sample contents 3</option>
</select>
</td>
<!-- THIS IS A BOGUS HACK TO COMPENSATE FOR A DISPLAY BUG -->

View File

@@ -153,8 +153,12 @@ titledbutton.PixelOrPercent {
}
titledbutton.SizeToCell {
/* BUG: Setting this to 100% chops off right border of button */
width: 90%;
width: 100%;
}
titledbutton.CloseButton {
width: 100%;
margin-top: 10px;
}
titledbutton.MsgButton {