Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Protected Attributes
mozPersonalDictionary Class Reference

#include <mozPersonalDictionary.h>

Inheritance diagram for mozPersonalDictionary:
Inheritance graph
[legend]
Collaboration diagram for mozPersonalDictionary:
Collaboration graph
[legend]

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_MOZIPERSONALDICTIONARY
NS_DECL_NSIOBSERVER 
mozPersonalDictionary ()
 This is the most braindead implementation of a personal dictionary possible.
virtual ~mozPersonalDictionary ()
nsresult Init ()
void load ()
 Load the dictionary.
void save ()
 Save the dictionary.
boolean check (in wstring word, in wstring lang)
 Check a unicode string.
void addWord (in wstring word, in wstring lang)
 Add a word to the personal dictionary.
void removeWord (in wstring word, in wstring lang)
 Remove a word from the personal dictionary.
void ignoreWord (in wstring word)
 Add a word to the ignore all list.
void endSession ()
 Clear the ignore list.
void addCorrection (in wstring word, in wstring correction, in wstring lang)
 These three functions are here in case we want to store previous misspellings and return them at the head of the misspell list.
void removeCorrection (in wstring word, in wstring correction, in wstring lang)
 Remove a misspelling from the list of corrections.
void getCorrection (in wstring word,[array, size_is(count)] out wstring words, out PRUint32 count)
 Get a list of previous corrections for the word.
void observe (in nsISupports aSubject, in string aTopic, in wstring aData)
 Observe will be called when there is a notification for the topic |aTopic|.

Public Attributes

readonly attribute
nsIStringEnumerator 
wordList
 Get the (lexicographically sorted) list of words.

Protected Attributes

nsStringArray mDictionary
PRBool mDirty
nsTHashtable< nsUniCharEntrymDictionaryTable
nsTHashtable< nsUniCharEntrymIgnoreTable
nsCOMPtr< nsIUnicodeEncodermEncoder

Detailed Description

Definition at line 90 of file mozPersonalDictionary.h.


Constructor & Destructor Documentation

This is the most braindead implementation of a personal dictionary possible.

There is not much complexity needed, though. It could be made much faster, and probably should, but I don't see much need for more in terms of interface.

Allowing personal words to be associated with only certain dictionaries maybe.

TODO: Implement the suggestion record.

Definition at line 73 of file mozPersonalDictionary.cpp.

 : mDirty(PR_FALSE)
{
}

Definition at line 78 of file mozPersonalDictionary.cpp.

{
}

Member Function Documentation

void mozIPersonalDictionary::addCorrection ( in wstring  word,
in wstring  correction,
in wstring  lang 
) [inherited]

These three functions are here in case we want to store previous misspellings and return them at the head of the misspell list.

Add a misspelling to the list of corrections

void mozIPersonalDictionary::addWord ( in wstring  word,
in wstring  lang 
) [inherited]

Add a word to the personal dictionary.

boolean mozIPersonalDictionary::check ( in wstring  word,
in wstring  lang 
) [inherited]

Check a unicode string.

Clear the ignore list.

void mozIPersonalDictionary::getCorrection ( in wstring  word,
[array, size_is(count)] out wstring  words,
out PRUint32  count 
) [inherited]

Get a list of previous corrections for the word.

void mozIPersonalDictionary::ignoreWord ( in wstring  word) [inherited]

Add a word to the ignore all list.

Definition at line 82 of file mozPersonalDictionary.cpp.

{
  if (!mDictionaryTable.Init() || !mIgnoreTable.Init())
    return NS_ERROR_OUT_OF_MEMORY;

  nsresult rv;
  nsCOMPtr<nsIObserverService> svc = 
           do_GetService("@mozilla.org/observer-service;1", &rv);
   
  if (NS_SUCCEEDED(rv) && svc) 
    rv = svc->AddObserver(this, "profile-do-change", PR_TRUE); // we want to reload the dictionary if the profile switches

  if (NS_FAILED(rv)) return rv;

  Load();
  
  return NS_OK;
}

Here is the call graph for this function:

Load the dictionary.

void nsIObserver::observe ( in nsISupports  aSubject,
in string  aTopic,
in wstring  aData 
) [inherited]

Observe will be called when there is a notification for the topic |aTopic|.

This assumes that the object implementing this interface has been registered with an observer service such as the nsIObserverService.

If you expect multiple topics/subjects, the impl is responsible for filtering.

You should not modify, add, remove, or enumerate notifications in the implemention of observe.

Parameters:
aSubject: Notification specific interface pointer.
aTopic: The notification topic or subject.
aData: Notification specific wide string. subject event.
void mozIPersonalDictionary::removeCorrection ( in wstring  word,
in wstring  correction,
in wstring  lang 
) [inherited]

Remove a misspelling from the list of corrections.

void mozIPersonalDictionary::removeWord ( in wstring  word,
in wstring  lang 
) [inherited]

Remove a word from the personal dictionary.

Save the dictionary.


Member Data Documentation

nsStringArray mozPersonalDictionary::mDictionary [protected]

Definition at line 105 of file mozPersonalDictionary.h.

Definition at line 107 of file mozPersonalDictionary.h.

Definition at line 106 of file mozPersonalDictionary.h.

Definition at line 109 of file mozPersonalDictionary.h.

Definition at line 108 of file mozPersonalDictionary.h.

Get the (lexicographically sorted) list of words.

Definition at line 63 of file mozIPersonalDictionary.idl.


The documentation for this class was generated from the following files: