koSpell.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "koSpell.h"
00020 #include "koSpell.moc"
00021 #include "koSconfig.h"
00022
00023 #ifdef HAVE_CONFIG_H
00024 #include <config.h>
00025 #endif
00026
00027 #ifdef HAVE_LIBASPELL
00028 #include "koaspell.h"
00029 #endif
00030
00031 #include "koispell.h"
00032 #include <qtextcodec.h>
00033 #include <kdebug.h>
00034 #include "koSpelldlg.h"
00035
00036 KOSpell *KOSpell::createKoSpell( QWidget *parent, const QString &caption, QObject *receiver, const char *slot, KOSpellConfig *_kcs, bool modal, bool _autocorrect, KOSpellerType type )
00037 {
00038 KOSpellConfig *ksc;
00039 if (_kcs!=0)
00040 ksc = new KOSpellConfig (*_kcs);
00041 else
00042 ksc = new KOSpellConfig;
00043
00044 int clt = ksc->client();
00045 kdDebug(30006)<<" client :"<<clt<<endl;
00046 if( clt == KOS_CLIENT_ISPELL || clt == KOS_CLIENT_HSPELL)
00047 {
00048 kdDebug(30006)<<" KOS_CLIENT_ISPELL :*************\n";
00049 return new KOISpell(parent, caption,
00050 receiver, slot, ksc, type );
00051 }
00052 #ifdef HAVE_LIBASPELL
00053 else if (clt == KOS_CLIENT_ASPELL)
00054 {
00055 kdDebug(30006)<<" KOS_CLIENT_ASPELL :**************\n";
00056 KOASpell* aspell = new KOASpell(parent,caption,ksc,modal,_autocorrect, type);
00057 connect( aspell, SIGNAL(ready(KOSpell*)), receiver, slot );
00058 return aspell;
00059 }
00060 #endif
00061 #if 0
00062
00063 else if( clt == KOS_CLIENT_MYSPELL)
00064 getAvailDictsMyspell();
00065 #endif
00066 kdDebug(30006)<<" default !!!!!!!!!!!!!!!!!!!!!!!!!\n";
00067 return new KOISpell(parent, caption,
00068 receiver, slot, ksc, type );
00069
00070 }
00071
00072 int KOSpell::modalCheck( QString& text, KOSpellConfig * _ksc )
00073 {
00074 KOSpellConfig *ksc;
00075 if (_ksc!=0)
00076 ksc = new KOSpellConfig (*_ksc);
00077 else
00078 ksc = new KOSpellConfig;
00079 int clt = ksc->client();
00080 kdDebug(30006)<<" client :"<<clt<<endl;
00081 if( clt == KOS_CLIENT_ISPELL)
00082 return KOISpell::modalCheck( text, ksc );
00083 #ifdef HAVE_LIBASPELL
00084 else if (clt == KOS_CLIENT_ASPELL)
00085 return KOASpell::modalCheck( text, ksc );
00086 #endif
00087 #if 0
00088
00089 else if( clt == KOS_CLIENT_MYSPELL)
00090 return KOMySpell::modalCheck( text, ksc );
00091 #endif
00092 return KOISpell::modalCheck( text, ksc );
00093
00094 }
00095
00096
00097 KOSpell::KOSpell(QWidget *_parent, const QString &_caption,KOSpellConfig *kcs,
00098 bool modal, bool _autocorrect, KOSpellerType _type )
00099 {
00100 type=_type;
00101 ksdlg = 0L;
00102 parent=_parent;
00103 modaldlg=modal;
00104 autocorrect = _autocorrect;
00105 caption = _caption;
00106 initSpell( kcs );
00107
00108 }
00109
00110 KOSpell::KOSpell( KOSpellConfig *_ksc )
00111 {
00112 ksdlg = 0L;
00113 parent= 0L;
00114 modaldlg=false;
00115 autocorrect = false;
00116 initSpell( _ksc);
00117 }
00118
00119 KOSpell::~KOSpell()
00120 {
00121 delete ksconfig;
00122 delete ksdlg;
00123 }
00124
00125 void KOSpell::misspellingWord (const QString & originalword, const QStringList & suggestions, unsigned int pos)
00126 {
00127 m_bNoMisspellingsEncountered = false;
00128 emit misspelling (originalword, suggestions, pos);
00129 }
00130
00131
00132 void KOSpell::initSpell( KOSpellConfig *_ksc )
00133 {
00134 m_bNoMisspellingsEncountered = true;
00135 autoDelete = false;
00136
00137 if (_ksc!=0)
00138 ksconfig = new KOSpellConfig (*_ksc);
00139 else
00140 ksconfig = new KOSpellConfig;
00141
00142 codec = 0;
00143 switch (ksconfig->encoding())
00144 {
00145 case KOS_E_LATIN1:
00146 codec = QTextCodec::codecForName("ISO 8859-1");
00147 break;
00148 case KOS_E_LATIN2:
00149 codec = QTextCodec::codecForName("ISO 8859-2");
00150 break;
00151 case KOS_E_LATIN3:
00152 codec = QTextCodec::codecForName("ISO 8859-3");
00153 break;
00154 case KOS_E_LATIN4:
00155 codec = QTextCodec::codecForName("ISO 8859-4");
00156 break;
00157 case KOS_E_LATIN5:
00158 codec = QTextCodec::codecForName("ISO 8859-5");
00159 break;
00160 case KOS_E_LATIN7:
00161 codec = QTextCodec::codecForName("ISO 8859-7");
00162 break;
00163 case KOS_E_LATIN8:
00164 codec = QTextCodec::codecForName("ISO 8859-8-i");
00165 break;
00166 case KOS_E_LATIN9:
00167 codec = QTextCodec::codecForName("ISO 8859-9");
00168 break;
00169 case KOS_E_LATIN13:
00170 codec = QTextCodec::codecForName("ISO 8859-13");
00171 break;
00172 case KOS_E_LATIN15:
00173 codec = QTextCodec::codecForName("ISO 8859-15");
00174 break;
00175 case KOS_E_UTF8:
00176 codec = QTextCodec::codecForName("UTF-8");
00177 break;
00178 case KOS_E_KOI8R:
00179 codec = QTextCodec::codecForName("KOI8-R");
00180 break;
00181 case KOS_E_KOI8U:
00182 codec = QTextCodec::codecForName("KOI8-U");
00183 break;
00184 case KOS_E_CP1251:
00185 codec = QTextCodec::codecForName("CP1251");
00186 break;
00187 default:
00188 break;
00189 }
00190
00191 kdDebug(30006) << __FILE__ << ":" << __LINE__ << " Codec = " << (codec ? codec->name() : "<default>") << endl;
00192
00193
00194 ignorelist += ksconfig->ignoreList();
00195
00196 replacelist += ksconfig->replaceAllList();
00197 m_status = Starting;
00198 }
00199
00200 void KOSpell::setIgnoreUpperWords(bool _ignore)
00201 {
00202 m_bIgnoreUpperWords=_ignore;
00203 }
00204
00205 void KOSpell::setIgnoreTitleCase(bool _ignore)
00206 {
00207 m_bIgnoreTitleCase=_ignore;
00208 }
00209
00210 KOSpellConfig KOSpell::ksConfig () const
00211 {
00212 ksconfig->setIgnoreList(ignorelist);
00213 ksconfig->setReplaceAllList(replacelist);
00214 return *ksconfig;
00215 }
00216
00217 void KOSpell::hide()
00218 {
00219 if ( ksdlg )
00220 ksdlg->hide();
00221 }
00222
00223 int KOSpell::heightDlg() const
00224 {
00225 if ( ksdlg )
00226 return ksdlg->height();
00227 else
00228 return -1;
00229 }
00230
00231 int KOSpell::widthDlg() const
00232 {
00233 if ( ksdlg )
00234 return ksdlg->width();
00235 else
00236 return -1;
00237 }
00238
00239 void KOSpell::moveDlg (int x, int y)
00240 {
00241 if ( !ksdlg )
00242 return;
00243 QPoint pt (x,y), pt2;
00244 pt2=parent->mapToGlobal (pt);
00245 ksdlg->move (pt2.x(),pt2.y());
00246 }
00247
00248 QString KOSpell::modaltext;
00249 int KOSpell::modalreturn = 0;
This file is part of the documentation for lib Library Version 1.3.5.