25#include "KoTextObject.h"
26#include "KoTextParag.h"
27#include "KoTextIterator.h"
29#include <tdespell2/broker.h>
30#include <tdespell2/filter.h>
40using namespace KSpell2;
49 KoTextDocument *lastTxtDocument;
52KoSpell::KoSpell(
const Broker::Ptr& broker, TQObject *parent,
54 : BackgroundChecker( broker, parent,
name )
60 d->needsIncrement =
false;
61 d->lastTxtDocument = 0;
77 connect( d->itr, TQ_SIGNAL( currentParagraphDeleted() ), TQ_SLOT( slotCurrentParagraphDeleted() ) );
78 d->lastTxtDocument = d->itr->currentTextObject()->textDocument();
79 d->needsIncrement =
false;
80 ret = !d->itr->atEnd();
92 d->lastTxtDocument = d->parag->textDocument();
100 TQString& foundWord,
int& start )
108 d->lastTxtDocument = d->parag->textDocument();
109 TQString str = parag->string()->stringToSpellCheck();
112 filter.setBuffer( str );
113 filter.setSettings( broker()->
settings() );
114 Word w = filter.wordAtPosition( pos );
118 kdDebug()<<
"KoSpell: WORD IS " << w.word <<
", pos = "<< pos
119 <<
", start = "<< w.start <<endl;
121 return checkWord( w.word );
124TQString KoSpell::getMoreText()
127 kdDebug()<<
"getMoreText: dialog = " << d->dialog <<
", itr = "
128 << d->itr <<
", atEnd = "
129 << ( ( d->itr ) ? d->itr->
atEnd() :
true )
130 <<
" d->parag=" << d->parag
134 if ( d->needsIncrement && d->itr && !d->itr->
atEnd() ) {
136 if ( !d->itr->
atEnd() )
140 if ( d->itr && d->itr->atEnd() )
143 if ( !d->dialog && !d->itr ) {
144 TQString str = d->parag ? d->parag->string()->stringToSpellCheck() : TQString();
145 if ( !str.isEmpty() )
146 emit aboutToFeedText();
150 d->needsIncrement =
true;
152 TQString text = d->itr->currentText();
153 d->parag = d->itr->currentParag();
155 emit aboutToFeedText();
157 while ( !d->dialog && d->parag ) {
158 if ( d->parag->string()->needsSpellCheck() &&
159 d->parag->length() > 1 )
162 if ( d->itr->atEnd() ) {
163 d->needsIncrement =
false;
166 d->parag = d->itr->currentParag();
167 d->lastTxtDocument = d->parag->textDocument();
168 text = d->itr->currentText();
171 d->parag->string()->setNeedsSpellCheck(
false );
176void KoSpell::finishedCurrentFeed()
181KoTextParag *KoSpell::currentParag()
const
188 if ( d->itr && !d->itr->atEnd() )
189 return d->itr->currentTextObject();
193int KoSpell::currentStartIndex()
const
195 if ( d->itr && !d->itr->atEnd() )
196 return d->itr->currentStartIndex();
200void KoSpell::slotCurrentParagraphDeleted()
203 kdDebug() <<
"KoSpell::slotCurrentParagraphDeleted itr=" << d->itr << endl;
207 d->needsIncrement =
false;
208 d->parag = d->itr->currentParag();
210 kdDebug() <<
"KoSpell::slotCurrentParagraphDeleted d->parag=" << d->parag << endl;
221 kdDebug()<<
"KoSpell::checking: itr=" << d->itr
222 <<
", atEnd=" << ( ( d->itr ) ? d->itr->atEnd() :
false )
223 <<
", filter()->atEnd()=" << filter()->atEnd()
227 if ( d->itr->atEnd() &&
233 return !filter()->atEnd();
236KoTextDocument * KoSpell::textDocument()
const
238 return d->lastTxtDocument;
243 return broker()->settings();
246#include "KoSpell.moc"
bool checking() const
Returns whether the speller is already checking something.
void paragraphChecked(KoTextParag *)
Emitted after a paragraph has been checked.
virtual bool check(KoTextIterator *itr, bool dialog=false)
Spellchecks a buffer of many words in plain text format.
KSpell2::Settings * settings() const
Returns the Settings object used by the broker.
virtual ~KoSpell()
The destructor instructs ISpell/ASpell to write out the personal dictionary and then terminates ISpel...
virtual bool checkWordInParagraph(KoTextParag *parag, int pos, TQString &word, int &start)
A convenient way to iterate over paragraphs, possibly in multiple textobjects, with many options (fro...
KoTextObject * currentTextObject() const
The KoTextObject is the high-level object that contains a KoTextDocument (the list of paragraphs),...
KoTextDocument * textDocument() const
Return the text document contained in this KoTextObject.
const char * name(StdAction id)