From dfe289850f068f19ba4a83ab4e7e22a7e09c13c9 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sat, 26 Jan 2013 13:17:21 -0600 Subject: Rename a number of libraries and executables to avoid conflicts with KDE4 --- tdespell2/plugins/aspell/tdespell_aspelldict.cpp | 125 +++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 tdespell2/plugins/aspell/tdespell_aspelldict.cpp (limited to 'tdespell2/plugins/aspell/tdespell_aspelldict.cpp') diff --git a/tdespell2/plugins/aspell/tdespell_aspelldict.cpp b/tdespell2/plugins/aspell/tdespell_aspelldict.cpp new file mode 100644 index 000000000..c88508c6f --- /dev/null +++ b/tdespell2/plugins/aspell/tdespell_aspelldict.cpp @@ -0,0 +1,125 @@ +/** + * tdespell_aspelldict.cpp + * + * Copyright (C) 2003 Zack Rusin + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA + */ +#include "tdespell_aspelldict.h" + +#include + +#include + +using namespace KSpell2; + +ASpellDict::ASpellDict( const TQString& lang ) + : Dictionary( lang ) +{ + m_config = new_aspell_config(); + aspell_config_replace( m_config, "lang", lang.latin1() ); + /* All communication with Aspell is done in UTF-8 */ + /* For reference, please look at BR#87250 */ + aspell_config_replace( m_config, "encoding", "utf-8" ); + + AspellCanHaveError * possible_err = new_aspell_speller( m_config ); + + if ( aspell_error_number( possible_err ) != 0 ) + kdDebug()<< "Error : "<< aspell_error_message( possible_err ) <toUnicode( cword ) ); + } + + delete_aspell_string_enumeration( elements ); + return qsug; +} + +bool ASpellDict::checkAndSuggest( const TQString& word, + TQStringList& suggestions ) +{ + bool c = check( word ); + if ( c ) + suggestions = suggest( word ); + return c; +} + +bool ASpellDict::storeReplacement( const TQString& bad, + const TQString& good ) +{ + /* ASpell is expecting length of a string in char representation */ + /* word.length() != word.utf8().length() for nonlatin strings */ + return aspell_speller_store_replacement( m_speller, + bad.utf8(), bad.utf8().length(), + good.utf8(), good.utf8().length() ); +} + +bool ASpellDict::addToPersonal( const TQString& word ) +{ + kdDebug() << "ASpellDict::addToPersonal: word = " << word << endl; + /* ASpell is expecting length of a string in char representation */ + /* word.length() != word.utf8().length() for nonlatin strings */ + aspell_speller_add_to_personal( m_speller, word.utf8(), + word.utf8().length() ); + /* Add is not enough, one has to save it. This is not documented */ + /* in ASpell's API manual. I found it in */ + /* aspell-0.60.2/example/example-c.c */ + return aspell_speller_save_all_word_lists( m_speller ); +} + +bool ASpellDict::addToSession( const TQString& word ) +{ + /* ASpell is expecting length of a string in char representation */ + /* word.length() != word.utf8().length() for nonlatin strings */ + return aspell_speller_add_to_session( m_speller, word.utf8(), + word.utf8().length() ); +} -- cgit v1.2.1