21 #include "tdespell_aspelldict.h"
25 #include <tqtextcodec.h>
29 ASpellDict::ASpellDict(
const TQString& lang )
32 m_config = new_aspell_config();
33 aspell_config_replace( m_config,
"lang", lang.latin1() );
36 aspell_config_replace( m_config,
"encoding",
"utf-8" );
38 AspellCanHaveError * possible_err = new_aspell_speller( m_config );
40 if ( aspell_error_number( possible_err ) != 0 )
41 kdDebug()<<
"Error : "<< aspell_error_message( possible_err ) <<endl;
43 m_speller = to_aspell_speller( possible_err );
47 ASpellDict::~ASpellDict()
49 delete_aspell_speller( m_speller );
50 delete_aspell_config( m_config );
57 int correct = aspell_speller_check( m_speller, word.utf8(), word.utf8().length() );
64 TQTextCodec *codec = TQTextCodec::codecForName(
"utf8");
68 const AspellWordList * suggestions = aspell_speller_suggest( m_speller,
70 word.utf8().length() );
72 AspellStringEnumeration * elements = aspell_word_list_elements( suggestions );
77 while ( (cword = aspell_string_enumeration_next( elements )) ) {
80 qsug.append( codec->toUnicode( cword ) );
83 delete_aspell_string_enumeration( elements );
88 TQStringList& suggestions )
90 bool c =
check( word );
97 const TQString& good )
101 return aspell_speller_store_replacement( m_speller,
102 bad.utf8(), bad.utf8().length(),
103 good.utf8(), good.utf8().length() );
108 kdDebug() <<
"ASpellDict::addToPersonal: word = " << word << endl;
111 aspell_speller_add_to_personal( m_speller, word.utf8(),
112 word.utf8().length() );
116 return aspell_speller_save_all_word_lists( m_speller );
123 return aspell_speller_add_to_session( m_speller, word.utf8(),
124 word.utf8().length() );
virtual bool check(const TQString &word)
Checks the given word.
virtual bool storeReplacement(const TQString &bad, const TQString &good)
Stores user defined good replacement for the bad word.
virtual bool addToSession(const TQString &word)
Adds word to the words recognizable in the current session.
virtual bool addToPersonal(const TQString &word)
Adds word to the list of of personal words.
virtual TQStringList suggest(const TQString &word)
Fetches suggestions for the word.
virtual bool checkAndSuggest(const TQString &word, TQStringList &suggestions)
Checks the word and fetches suggestions for it.
Class is returned by from Broker.