Back to index

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

#include <mozMySpell.h>

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

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_MOZISPELLCHECKINGENGINE
NS_DECL_NSIOBSERVER 
mozMySpell ()
virtual ~mozMySpell ()
nsresult Init ()
void LoadDictionaryList ()
void LoadDictionariesFromDir (nsIFile *aDir)
nsresult ConvertCharset (const PRUnichar *aStr, char **aDst)
void getDictionaryList ([array, size_is(count)] out wstring dictionaries, out PRUint32 count)
 Get the list of dictionaries.
boolean check (in wstring word)
 check a word
void suggest (in wstring word,[array, size_is(count)] out wstring suggestions, out PRUint32 count)
 get a list of suggestions for a misspelled 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

attribute wstring dictionary
 The name of the current dictionary.
readonly attribute wstring language
 The language this spellchecker is using when checking.
readonly attribute boolean providesPersonalDictionary
 Does the engine provide its own personal dictionary?
readonly attribute boolean providesWordUtils
 Does the engine provide its own word utils?
readonly attribute wstring name
 The name of the engine.
readonly attribute wstring copyright
 a string indicating the copyright of the engine
attribute mozIPersonalDictionary personalDictionary
 the personal dictionary

Protected Attributes

nsCOMPtr< mozIPersonalDictionarymPersonalDictionary
nsCOMPtr< nsIUnicodeEncodermEncoder
nsCOMPtr< nsIUnicodeDecodermDecoder
nsInterfaceHashtable
< nsStringHashKey, nsIFile
mDictionaries
nsString mDictionary
nsString mLanguage
MySpellmMySpell

Detailed Description

Definition at line 76 of file mozMySpell.h.


Constructor & Destructor Documentation

NS_DECL_ISUPPORTS NS_DECL_MOZISPELLCHECKINGENGINE NS_DECL_NSIOBSERVER mozMySpell::mozMySpell ( ) [inline]

Definition at line 85 of file mozMySpell.h.

mozMySpell::~mozMySpell ( ) [virtual]

Definition at line 101 of file mozMySpell.cpp.


Member Function Documentation

boolean mozISpellCheckingEngine::check ( in wstring  word) [inherited]

check a word

Here is the caller graph for this function:

nsresult mozMySpell::ConvertCharset ( const PRUnichar aStr,
char **  aDst 
)

Definition at line 391 of file mozMySpell.cpp.

{
  NS_ENSURE_ARG_POINTER(aDst);
  NS_ENSURE_TRUE(mEncoder, NS_ERROR_NULL_POINTER);

  PRInt32 outLength;
  PRInt32 inLength = nsCRT::strlen(aStr);
  nsresult rv = mEncoder->GetMaxLength(aStr, inLength, &outLength);
  NS_ENSURE_SUCCESS(rv, rv);

  *aDst = (char *) nsMemory::Alloc(sizeof(char) * (outLength+1));
  NS_ENSURE_TRUE(*aDst, NS_ERROR_OUT_OF_MEMORY);

  rv = mEncoder->Convert(aStr, &inLength, *aDst, &outLength);
  if (NS_SUCCEEDED(rv))
    (*aDst)[outLength] = '\0'; 

  return rv;
}

Here is the call graph for this function:

void mozISpellCheckingEngine::getDictionaryList ( [array, size_is(count)] out wstring  dictionaries,
out PRUint32  count 
) [inherited]

Get the list of dictionaries.

Definition at line 343 of file mozMySpell.cpp.

{
  nsresult rv;

  PRBool check = PR_FALSE;
  rv = aDir->Exists(&check);
  if (NS_FAILED(rv) || !check)
    return;

  rv = aDir->IsDirectory(&check);
  if (NS_FAILED(rv) || !check)
    return;

  nsCOMPtr<nsISimpleEnumerator> e;
  rv = aDir->GetDirectoryEntries(getter_AddRefs(e));
  if (NS_FAILED(rv))
    return;

  nsCOMPtr<nsIDirectoryEnumerator> files(do_QueryInterface(e));
  if (!files)
    return;

  nsCOMPtr<nsIFile> file;
  while (NS_SUCCEEDED(files->GetNextFile(getter_AddRefs(file))) && file) {
    nsAutoString leafName;
    file->GetLeafName(leafName);
    if (!StringEndsWith(leafName, NS_LITERAL_STRING(".dic")))
      continue;

    nsAutoString dict(leafName);
    dict.SetLength(dict.Length() - 4); // magic length of ".dic"

    // check for the presence of the .aff file
    leafName = dict;
    leafName.AppendLiteral(".aff");
    file->SetLeafName(leafName);
    rv = file->Exists(&check);
    if (NS_FAILED(rv) || !check)
      continue;

#ifdef DEBUG_bsmedberg
    printf("Adding dictionary: %s\n", NS_ConvertUTF16toUTF8(dict).get());
#endif

    mDictionaries.Put(dict, file);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 299 of file mozMySpell.cpp.

{
  mDictionaries.Clear();

  nsresult rv;

  nsCOMPtr<nsIProperties> dirSvc =
    do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID);
  if (!dirSvc)
    return;

  nsCOMPtr<nsIFile> dictDir;
  rv = dirSvc->Get(DICTIONARY_SEARCH_DIRECTORY,
                   NS_GET_IID(nsIFile), getter_AddRefs(dictDir));
  if (NS_FAILED(rv)) {
    // default to appdir/dictionaries
    rv = dirSvc->Get(NS_XPCOM_CURRENT_PROCESS_DIR,
                     NS_GET_IID(nsIFile), getter_AddRefs(dictDir));
    if (NS_FAILED(rv))
      return;

    dictDir->AppendNative(NS_LITERAL_CSTRING("dictionaries"));
  }

  LoadDictionariesFromDir(dictDir);

  nsCOMPtr<nsISimpleEnumerator> dictDirs;
  rv = dirSvc->Get(DICTIONARY_SEARCH_DIRECTORY_LIST,
                   NS_GET_IID(nsISimpleEnumerator), getter_AddRefs(dictDirs));
  if (NS_FAILED(rv))
    return;

  PRBool hasMore;
  while (NS_SUCCEEDED(dictDirs->HasMoreElements(&hasMore)) && hasMore) {
    nsCOMPtr<nsISupports> elem;
    dictDirs->GetNext(getter_AddRefs(elem));

    dictDir = do_QueryInterface(elem);
    if (dictDir)
      LoadDictionariesFromDir(dictDir);
  }
}

Here is the call graph for this function:

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 mozISpellCheckingEngine::suggest ( in wstring  word,
[array, size_is(count)] out wstring  suggestions,
out PRUint32  count 
) [inherited]

get a list of suggestions for a misspelled word


Member Data Documentation

readonly attribute wstring mozISpellCheckingEngine::copyright [inherited]

a string indicating the copyright of the engine

Definition at line 77 of file mozISpellCheckingEngine.idl.

The name of the current dictionary.

Definition at line 52 of file mozISpellCheckingEngine.idl.

readonly attribute wstring mozISpellCheckingEngine::language [inherited]

The language this spellchecker is using when checking.

Definition at line 57 of file mozISpellCheckingEngine.idl.

Definition at line 100 of file mozMySpell.h.

Definition at line 103 of file mozMySpell.h.

Definition at line 104 of file mozMySpell.h.

Definition at line 99 of file mozMySpell.h.

Definition at line 105 of file mozMySpell.h.

Definition at line 107 of file mozMySpell.h.

Definition at line 98 of file mozMySpell.h.

readonly attribute wstring mozISpellCheckingEngine::name [inherited]

The name of the engine.

Definition at line 72 of file mozISpellCheckingEngine.idl.

the personal dictionary

Definition at line 82 of file mozISpellCheckingEngine.idl.

Does the engine provide its own personal dictionary?

Definition at line 62 of file mozISpellCheckingEngine.idl.

Does the engine provide its own word utils?

Definition at line 67 of file mozISpellCheckingEngine.idl.


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