[prev in list] [next in list] [prev in thread] [next in thread]
List: koffice-devel
Subject: Re: kspell2
From: Laurent Montel <montel () kde ! org>
Date: 2004-05-02 8:02:28
Message-ID: 200405021002.29017.montel () kde ! org
[Download RAW message or body]
Le Sunday 02 May 2004 08:30, Zack Rusin a écrit :
> Ave,
>
> KSpell2 is in kdelibs. If you've got it installed I'd appreciate some
> help/testers. The koText patch pretty much comes down to :
> - kospell - implements KSpell2::BackgroundChecker class. It's the
> "engine" used by both the dialog and the highlighter in kspell2. Thanks
> to which no additional code is necessary for for example checking just
> the selected text - you just pass the right kotextiterator or parag to
> it.
> - kobgspellcheck.h - which uses kospell to actually highlight the
> misspelled word.
>
> In order to get background spellchecking for your application you need
> to implement
> KoTextIterator *KoBgSpellCheck::createWholeDocIterator() const;
> method which of course create a KoTextIterator for your whole document.
> Besides doing that you need to remember to call
> KoBgSpellCheck::registerNewTextObject( KoTextObject *object ) function
> which registers new text object with the background checker.
>
> The createWholeDocIterator is called on startup and the background
> checker goes into action and starts checking. It also goes into
> interactive mode. Interactive mode means that it listens for
> paragraphCreated/Modified/Deleted signals from the registered text
> objects and acts as follows:
> a) if paragraph created is catch, the paragraph is added to the queue of
> the ones which need to be checked,
> b) if modified is catched and the length of the modified text is less
> than 3 (it's 1 of course as you're typing) then background checker
> fetches just the modifed word and checks just it. If the length is
> greater or equal to 3 then it acts just during the catch of
> paragraphCreated signal. This makes it _very_ _very_ fast. It also
> takes very little cpu.
> c) if paragraphDeleted is cought then the list of paras about to be
> checked is searched and if that para is in it, it's removed.
>
> So yeah, I'm sending the kotext patch which is done and the kword patch
> which is missing the configuration page in the config dialog (it's just
> a matter of adding KSpell2::ConfigWidget there) and for some reason
> crashes randomly when checking with the dialog. While background
> checking is virtually perfect, the dialog is acting up and I need to
> figure out what's wrong there. Either way, it's ok to try it out
> (assuming you have kdelibs HEAD compiled).
>
> Zack
I adapted your patch.
It didn't compile before.
Regards.
PS: I didn't test it for the moment.
["kword.patch" (text/x-diff)]
cvs diff: Diffing .
Index: Makefile.am
===================================================================
RCS file: /home/kde/koffice/kword/Makefile.am,v
retrieving revision 1.213
diff -u -u -p -r1.213 Makefile.am
--- Makefile.am 15 Apr 2004 11:06:07 -0000 1.213
+++ Makefile.am 2 May 2004 08:00:44 -0000
@@ -46,7 +46,7 @@ libkwordpart_la_SOURCES = kwtableframese
libkwordpart_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN)
-libkwordpart_la_LIBADD = $(LIB_KOFFICEUI) $(LIB_KOTEXT) \
../lib/kformula/libkformula.la -lkspell $(LIBKOSPELL) ./libkwmailmerge_interface.la \
+libkwordpart_la_LIBADD = $(LIB_KOFFICEUI) $(LIB_KOTEXT) \
../lib/kformula/libkformula.la ./libkwmailmerge_interface.la METASOURCES = AUTO
lib_LTLIBRARIES = libkwmailmerge_interface.la
Index: kwbgspellcheck.cc
===================================================================
RCS file: /home/kde/koffice/kword/kwbgspellcheck.cc,v
retrieving revision 1.6
diff -u -u -p -r1.6 kwbgspellcheck.cc
--- kwbgspellcheck.cc 22 Jun 2002 15:51:22 -0000 1.6
+++ kwbgspellcheck.cc 2 May 2004 08:00:44 -0000
@@ -20,51 +20,42 @@
#include "kwbgspellcheck.h"
-#include <koBgSpellCheck.h>
-#include <kdebug.h>
-#include <kotextobject.h>
-#include <klocale.h>
+
#include "kwdoc.h"
#include "kwtextframeset.h"
+#include "kotextiterator.h"
+#include "kotextobject.h"
+
+#include <kspell2/broker.h>
+using namespace KSpell2;
+
+#include <kdebug.h>
+#include <kconfig.h>
+#include <klocale.h>
+
+
KWBgSpellCheck::KWBgSpellCheck(KWDocument *_doc)
- : KoBgSpellCheck()
+ : KoBgSpellCheck( Broker::openBroker( KSharedConfig::openConfig( "kwordrc" ) ),
+ _doc )
{
m_doc=_doc;
m_currentFrame=0L;
- objectForSpell(m_currentFrame);
}
KWBgSpellCheck::~KWBgSpellCheck()
{
}
-void KWBgSpellCheck::objectForSpell(KWTextFrameSet *curr)
+KoTextIterator *KWBgSpellCheck::createWholeDocIterator() const
{
- m_currentFrame=curr;
- if( m_currentFrame && m_currentFrame->textObject())
- m_bgSpell.currentTextObj=m_currentFrame->textObject();
- else
- m_bgSpell.currentTextObj=0L;
-}
+ QValueList<KoTextObject *> objects = m_doc->visibleTextObjects( 0 );
-void KWBgSpellCheck::slotRepaintChanged(KoTextObject *obj)
-{
- if( m_currentFrame->textObject()==obj)
- m_doc->slotRepaintChanged(m_currentFrame);
-}
+ kdDebug()<<"Number of visible text objects = "<< objects.count() << endl;
-KoTextObject *KWBgSpellCheck::nextTextObject( KoTextObject * /*obj*/ )
-{
- m_currentFrame=m_doc->nextTextFrameSet(m_currentFrame);
- if(!m_currentFrame)
- return 0L;
- else
- return m_currentFrame->textObject();
-}
+ if ( objects.isEmpty() )
+ return 0;
-void KWBgSpellCheck::configurateSpellChecker()
-{
- m_doc->configureSpellChecker();
+ return new KoTextIterator( objects, 0, 0 );
}
Index: kwbgspellcheck.h
===================================================================
RCS file: /home/kde/koffice/kword/kwbgspellcheck.h,v
retrieving revision 1.4
diff -u -u -p -r1.4 kwbgspellcheck.h
--- kwbgspellcheck.h 22 Jun 2002 15:51:22 -0000 1.4
+++ kwbgspellcheck.h 2 May 2004 08:00:44 -0000
@@ -1,6 +1,7 @@
/* This file is part of the KDE project
Copyright (C) 2002 David Faure <david@mandrakesoft.com>
2002 Laurent Montel <lmontel@mandrakesoft.com>
+ 2004 Zack Rusin <zack@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -24,8 +25,9 @@
class KWDocument;
class KWTextFrameSet;
+#include "kobgspellcheck.h"
+
#include <qobject.h>
-#include <koBgSpellCheck.h>
class KWBgSpellCheck : public KoBgSpellCheck
{
@@ -33,16 +35,7 @@ public:
KWBgSpellCheck(KWDocument *_doc);
virtual ~KWBgSpellCheck();
- void objectForSpell(KWTextFrameSet *curr);
- //repaint object when we spell check
- virtual void slotRepaintChanged(KoTextObject *obj);
-
- //spell checker is not configurate.
- virtual void configurateSpellChecker();
-
- KWTextFrameSet *currentCheckSpellingFrame()const{ return m_currentFrame;}
-
- virtual KoTextObject *nextTextObject( KoTextObject *obj );
+ virtual KoTextIterator *createWholeDocIterator() const;
private:
KWDocument *m_doc;
Index: kwconfig.cc
===================================================================
RCS file: /home/kde/koffice/kword/kwconfig.cc,v
retrieving revision 1.167
diff -u -u -p -r1.167 kwconfig.cc
--- kwconfig.cc 23 Apr 2004 08:21:12 -0000 1.167
+++ kwconfig.cc 2 May 2004 08:00:45 -0000
@@ -23,7 +23,6 @@
#include <koUnitWidgets.h>
#include <knuminput.h>
#include <knumvalidator.h>
-#include <kspell.h>
#include <kfontdialog.h>
#include <kdebug.h>
@@ -44,7 +43,6 @@
#include "kwcommand.h"
#include "kwvariable.h"
#include "koeditpath.h"
-#include <koSconfig.h>
#include <kovariable.h>
#include <kformulaconfigpage.h>
@@ -60,7 +58,6 @@
#include <kfiledialog.h>
#include <qtabwidget.h>
#include <keditlistbox.h>
-#include <koSpellConfig.h>
#include <koGlobal.h>
// little helper stolen from kmail
@@ -200,52 +197,23 @@ ConfigureSpellPage::ConfigureSpellPage(
m_pView=_view;
config = KWFactory::global()->config();
- m_spellConfigWidget = new KoSpellConfigWidget( box, \
m_pView->kWordDocument()->getKOSpellConfig(), true);
-#if 0
- if( config->hasGroup("KSpell kword") )
- {
- config->setGroup( "KSpell kword" );
- m_spellConfigWidget->setDontCheckUpperWord(config->readBoolEntry("KSpell_dont_check_upper_word",false));
- m_spellConfigWidget->setDontCheckTitleCase(config->readBoolEntry("KSpell_dont_check_title_case",false));
- }
-#endif
- m_spellConfigWidget->setBackgroundSpellCheck( \
m_pView->kWordDocument()->backgroundSpellCheckEnabled() );
- m_spellConfigWidget->addIgnoreList( \
m_pView->kWordDocument()->spellListIgnoreAll() );
-
}
void ConfigureSpellPage::apply()
{
- KOSpellConfig *_spellConfig = m_spellConfigWidget->spellConfig();
- config->setGroup( "KSpell kword" );
- config->writeEntry ("KSpell_NoRootAffix",(int) _spellConfig->noRootAffix ());
- config->writeEntry ("KSpell_RunTogether", (int) _spellConfig->runTogether ());
- config->writeEntry ("KSpell_Dictionary", _spellConfig->dictionary ());
- config->writeEntry ("KSpell_DictFromList",(int) _spellConfig->dictFromList());
- config->writeEntry ("KSpell_Encoding", (int) _spellConfig->encoding());
- config->writeEntry ("KSpell_Client", _spellConfig->client());
- config->writeEntry( "KSpell_dont_check_title_case", \
(int)_spellConfig->dontCheckTitleCase());
- config->writeEntry ("KSpell_IgnoreCase",(int) _spellConfig->ignoreCase());
- config->writeEntry( "KSpell_IgnoreAccent", (int) _spellConfig->ignoreAccent());
- config->writeEntry( "KSpell_dont_check_upper_word", \
(int)_spellConfig->dontCheckUpperWord());
- config->writeEntry( "KSpell_SpellWordWithNumber", \
(int)_spellConfig->spellWordWithNumber());
- m_spellConfigWidget->saveDictionary();
KWDocument* doc = m_pView->kWordDocument();
- doc->setKOSpellConfig(*_spellConfig);
-
- bool state=m_spellConfigWidget->backgroundSpellCheck();
- config->writeEntry( "SpellCheck", (int)state );
+ //bool state=m_spellConfigWidget->backgroundSpellCheck();
+ //config->writeEntry( "SpellCheck", (int)state );
- m_pView->kWordDocument()->addIgnoreWordAllList( m_spellConfigWidget->ignoreList() \
); + //m_pView->kWordDocument()->addIgnoreWordAllList( \
m_spellConfigWidget->ignoreList() ); //FIXME reactivate just if there is a changes.
- doc->enableBackgroundSpellCheck( state );
+ //doc->enableBackgroundSpellCheck( state );
doc->reactivateBgSpellChecking();
}
void ConfigureSpellPage::slotDefault()
{
- m_spellConfigWidget->setDefault();
}
ConfigureInterfacePage::ConfigureInterfacePage( KWView *_view, QVBox *box, char \
*name )
Index: kwconfig.h
===================================================================
RCS file: /home/kde/koffice/kword/kwconfig.h,v
retrieving revision 1.56
diff -u -u -p -r1.56 kwconfig.h
--- kwconfig.h 25 Feb 2004 01:18:33 -0000 1.56
+++ kwconfig.h 2 May 2004 08:00:45 -0000
@@ -30,7 +30,6 @@ class KWView;
class QCheckBox;
class KIntNumInput;
class KoUnitDoubleSpinBox;
-class KSpellConfig;
class KConfig;
class QComboBox;
class KIntNumInput;
Index: kwdoc.cc
===================================================================
RCS file: /home/kde/koffice/kword/kwdoc.cc,v
retrieving revision 1.661
diff -u -u -p -r1.661 kwdoc.cc
--- kwdoc.cc 27 Apr 2004 22:30:48 -0000 1.661
+++ kwdoc.cc 2 May 2004 08:00:46 -0000
@@ -138,7 +138,6 @@ KWDocument::KWDocument(QWidget *parentWi
dcop = 0;
m_pages = 1;
m_tabStop = MM_TO_POINT( 15.0 );
- bgFrameSpellChecked = 0L;
m_processingType = WP;
m_lstViews.setAutoDelete( false );
@@ -229,8 +228,6 @@ KWDocument::KWDocument(QWidget *parentWi
m_syntaxVersion = CURRENT_SYNTAX_VERSION;
- m_pKOSpellConfig = 0;
-
m_hasTOC=false;
// It's important to call this to have the kformula actions
@@ -319,7 +316,6 @@ KWDocument::~KWDocument()
delete m_frameStyleColl;
delete m_tableStyleColl;
delete m_tableTemplateColl;
- delete m_pKOSpellConfig;
delete m_viewMode;
delete m_bufPixmap;
delete m_pictureCollection;
@@ -328,31 +324,16 @@ KWDocument::~KWDocument()
void KWDocument::initConfig()
{
KConfig *config = KWFactory::global()->config();
- KOSpellConfig kosconfig;
if( config->hasGroup("KSpell kword" ) )
{
config->setGroup( "KSpell kword" );
- kosconfig.setNoRootAffix(config->readNumEntry ("KSpell_NoRootAffix", 0));
- kosconfig.setRunTogether(config->readNumEntry ("KSpell_RunTogether", 0));
- kosconfig.setDictionary(config->readEntry ("KSpell_Dictionary", ""));
- kosconfig.setDictFromList(config->readNumEntry ("KSpell_DictFromList", \
FALSE));
- kosconfig.setEncoding(config->readNumEntry ("KSpell_Encoding", KOS_E_ASCII));
- kosconfig.setClient(config->readNumEntry ("KSpell_Client", \
KOS_CLIENT_ISPELL));
-
- kosconfig.setIgnoreCase( config->readNumEntry( "KSpell_IgnoreCase", 0));
- kosconfig.setIgnoreAccent( config->readNumEntry( "KSpell_IgnoreAccent", 0));
- kosconfig.setDontCheckUpperWord(config->readBoolEntry("KSpell_dont_check_upper_word",false));
- kosconfig.setDontCheckTitleCase(config->readBoolEntry("KSpell_dont_check_title_case",false));
- kosconfig.setSpellWordWithNumber( \
config->readNumEntry("KSpell_SpellWordWithNumber", false));
-
- setKOSpellConfig( kosconfig );
// Default is false for spellcheck, but the spell-check config dialog
// should write out "true" when the user configures spell checking.
if ( isReadWrite() )
- m_bgSpellCheck->enableBackgroundSpellCheck(config->readBoolEntry( \
"SpellCheck", false )); + m_bgSpellCheck->setEnabled(config->readBoolEntry( \
"SpellCheck", false )); else
- m_bgSpellCheck->enableBackgroundSpellCheck( false );
+ m_bgSpellCheck->setEnabled( false );
}
@@ -1564,7 +1545,7 @@ bool KWDocument::loadXML( QIODevice *, c
spellWord=spellWord.nextSibling().toElement();
}
}
- m_bgSpellCheck->addIgnoreWordAllList( m_spellListIgnoreAll );
+ //m_bgSpellCheck->addIgnoreWordAllList( m_spellListIgnoreAll );
emit sigProgress(25);
@@ -1740,8 +1721,7 @@ void KWDocument::startBackgroundSpellChe
//don't start bg spell checking if
if(backgroundSpellCheckEnabled() && isReadWrite())
{
- m_bgSpellCheck->objectForSpell(textFrameSet(0));
- m_bgSpellCheck->startBackgroundSpellCheck();
+ m_bgSpellCheck->start();
}
}
@@ -4124,9 +4104,6 @@ void KWDocument::removeFrameSet( KWFrame
{
emit sig_terminateEditing( f );
m_lstFrameSet.take( m_lstFrameSet.find(f) );
- if ( m_bgSpellCheck->currentCheckSpellingFrame() == f )
- // TODO nextTextFrameSet instead of:
- m_bgSpellCheck->objectForSpell( 0L);
setModified( true );
}
@@ -4163,27 +4140,6 @@ void KWDocument::slotCommandExecuted()
setModified( true );
}
-
-void KWDocument::setKOSpellConfig(const KOSpellConfig& _kspell)
-{
- if(m_pKOSpellConfig==0)
- m_pKOSpellConfig=new KOSpellConfig();
-
- m_pKOSpellConfig->setNoRootAffix(_kspell.noRootAffix ());
- m_pKOSpellConfig->setRunTogether(_kspell.runTogether ());
- m_pKOSpellConfig->setDictionary(_kspell.dictionary ());
- m_pKOSpellConfig->setDictFromList(_kspell.dictFromList());
- m_pKOSpellConfig->setEncoding(_kspell.encoding());
- m_pKOSpellConfig->setEncoding(_kspell.encoding());
- m_pKOSpellConfig->setIgnoreCase ( _kspell.ignoreCase ());
- m_pKOSpellConfig->setIgnoreAccent( _kspell.ignoreAccent());
- m_pKOSpellConfig->setDontCheckTitleCase( _kspell.dontCheckTitleCase());
- m_pKOSpellConfig->setDontCheckUpperWord( _kspell.dontCheckUpperWord() );
- m_pKOSpellConfig->setSpellWordWithNumber( _kspell.spellWordWithNumber());
- m_pKOSpellConfig->setClient (_kspell.client());
- m_bgSpellCheck->setKSpellConfig(_kspell);
-}
-
#ifndef NDEBUG
void KWDocument::printStyleDebug()
{
@@ -4626,14 +4582,14 @@ void KWDocument::refreshGUIButton()
void KWDocument::enableBackgroundSpellCheck( bool b )
{
- m_bgSpellCheck->enableBackgroundSpellCheck(b);
+ m_bgSpellCheck->setEnabled(b);
for ( KWView *viewPtr = m_lstViews.first(); viewPtr != 0; viewPtr = \
m_lstViews.next() ) viewPtr->updateBgSpellCheckingState();
}
bool KWDocument::backgroundSpellCheckEnabled() const
{
- return m_bgSpellCheck->backgroundSpellCheckEnabled();
+ return m_bgSpellCheck->enabled();
}
void KWDocument::reactivateBgSpellChecking()
@@ -4648,43 +4604,6 @@ void KWDocument::reactivateBgSpellChecki
startBackgroundSpellCheck();
}
-// to be removed
-KWTextFrameSet* KWDocument::nextTextFrameSet(KWTextFrameSet *obj)
-{
- int pos = -1;
- if ( bgFrameSpellChecked )
- pos=m_lstFrameSet.findNextRef(bgFrameSpellChecked);
- if(pos !=-1)
- {
- KWFrameSet *frm=0L;
- for ( frm=m_lstFrameSet.at(pos); frm != 0; frm=m_lstFrameSet.next() ){
- KWTextFrameSet *newFrm = frm->nextTextObject( obj );
- if(newFrm && !newFrm->isDeleted() && \
newFrm->textObject()->needSpellCheck())
- {
- //kdDebug() << "KWDocument::nextTextFrameSet checking " << \
bgFrameSpellChecked << endl;
- bgFrameSpellChecked = frm;
- return newFrm;
- }
- }
- }
- else
- {
- KWFrameSet *frm=0L;
- for ( frm=m_lstFrameSet.first(); frm != 0; frm=m_lstFrameSet.next() ){
- KWTextFrameSet *newFrm = frm->nextTextObject( obj );
- if(newFrm && !newFrm->isDeleted() && \
newFrm->textObject()->needSpellCheck())
- {
- //kdDebug() << "KWDocument::nextTextFrameSet checking " << \
bgFrameSpellChecked << endl;
- bgFrameSpellChecked = frm;
- return newFrm;
- }
- }
- }
- //kdDebug() << "KWDocument::nextTextFrameSet returning 0L" << endl;
- bgFrameSpellChecked = 0L;
- return 0L;
-}
-
void KWDocument::slotChapterParagraphFormatted( KoTextParag* /*parag*/ )
{
// Attempt at invalidating from the parag's page only
@@ -4804,15 +4723,14 @@ void KWDocument::addIgnoreWordAll( const
{
if( m_spellListIgnoreAll.findIndex( word )==-1)
m_spellListIgnoreAll.append( word );
- m_bgSpellCheck->addIgnoreWordAll( word );
+ //m_bgSpellCheck->addIgnoreWordAll( word );
}
void KWDocument::clearIgnoreWordAll( )
{
m_spellListIgnoreAll.clear();
- m_bgSpellCheck->clearIgnoreWordAll();
-
+ //m_bgSpellCheck->clearIgnoreWordAll();
}
int KWDocument::maxZOrder( int pageNum) const
@@ -5091,7 +5009,8 @@ void KWDocument::paragraphModified(KoTex
void KWDocument::spellCheckParagraphDeleted( KoTextParag *_parag, KWTextFrameSet \
*frm) {
- m_bgSpellCheck->spellCheckParagraphDeleted( _parag, frm->textObject());
+ //FIXME: do we need that?
+ //m_bgSpellCheck->paragraphDeleted( _parag, frm->textObject());
}
void KWDocument::paragraphDeleted( KoTextParag *_parag, KWFrameSet *frm )
@@ -5211,11 +5130,11 @@ void KWDocument::setHorizontalLinePath(
}
#endif
-void KWDocument::addWordToDictionary( const QString & word)
+void KWDocument::addWordToDictionary( const QString & /*word*/ )
{
if ( m_bgSpellCheck )
{
- m_bgSpellCheck->addPersonalDictonary( word );
+ //m_bgSpellCheck->addPersonalDictonary( word );
}
}
Index: kwdoc.h
===================================================================
RCS file: /home/kde/koffice/kword/kwdoc.h,v
retrieving revision 1.308
diff -u -u -p -r1.308 kwdoc.h
--- kwdoc.h 27 Apr 2004 22:30:48 -0000 1.308
+++ kwdoc.h 2 May 2004 08:00:46 -0000
@@ -45,8 +45,6 @@ class KWViewMode;
class KMacroCommand;
class KoDocumentEntry;
class QPainter;
-class KSpellConfig;
-class KSpell;
class KoAutoFormat;
class KCommand;
class KoCommandHistory;
@@ -69,8 +67,6 @@ class QFont;
class QStringList;
class QRect;
-class KOSpellConfig;
-
namespace KFormula {
class Document;
class DocumentWrapper;
@@ -535,13 +531,6 @@ public:
return defaultValue;
}
- /**
- * get custom kspell config
- */
-
- void setKOSpellConfig(const KOSpellConfig& _kspell);
- KOSpellConfig * getKOSpellConfig()const {return m_pKOSpellConfig;}
-
#ifndef NDEBUG
void printStyleDebug();
void printDebug();
@@ -680,8 +669,6 @@ public:
void initUnit();
void startBackgroundSpellCheck();
void reactivateBgSpellChecking();
- //to be removed
- KWTextFrameSet* nextTextFrameSet(KWTextFrameSet *obj);
void updateHeaderButton();
void updateFooterButton();
@@ -775,6 +762,8 @@ public:
KWLoadingInfo* loadingInfo() const { return m_loadingInfo; }
+ KWBgSpellCheck* backSpeller() const { return m_bgSpellCheck; }
+
signals:
void sig_insertObject( KWChild *_child, KWPartFrameSet* );
@@ -940,7 +929,6 @@ private:
QString m_lastViewMode;
KWVariableCollection *m_varColl;
KWBgSpellCheck *m_bgSpellCheck;
- KOSpellConfig *m_pKOSpellConfig;
KoStyleCollection *m_styleColl;
KWFrameStyleCollection *m_frameStyleColl;
KWTableStyleCollection *m_tableStyleColl;
@@ -961,7 +949,6 @@ private:
double m_tabStop;
QStringList m_spellListIgnoreAll;
- KWFrameSet * bgFrameSpellChecked;
QPixmap* m_bufPixmap;
KWLoadingInfo* m_loadingInfo;
Index: kwtextframeset.cc
===================================================================
RCS file: /home/kde/koffice/kword/kwtextframeset.cc,v
retrieving revision 1.752
diff -u -u -p -r1.752 kwtextframeset.cc
--- kwtextframeset.cc 11 Apr 2004 19:10:52 -0000 1.752
+++ kwtextframeset.cc 2 May 2004 08:00:48 -0000
@@ -30,6 +30,7 @@
#include "kwcommand.h"
#include "kwdrag.h"
#include "kwformulaframe.h"
+#include "kwbgspellcheck.h"
#include <koparagcounter.h>
#include "contents.h"
#include <koVariableDlgs.h>
@@ -135,6 +136,7 @@ void KWTextFrameSet::init()
m_textobj = new KoTextObject( textdoc, m_doc->styleCollection()->findStyle( \
"Standard" ), this, (m_name+"-textobj").utf8() );
+ m_doc->backSpeller()->registerNewTextObject( m_textobj );
connect( m_textobj, SIGNAL( availableHeightNeeded() ),
SLOT( slotAvailableHeightNeeded() ) );
Index: kwview.cc
===================================================================
RCS file: /home/kde/koffice/kword/kwview.cc,v
retrieving revision 1.1014
diff -u -u -p -r1.1014 kwview.cc
--- kwview.cc 25 Apr 2004 23:08:21 -0000 1.1014
+++ kwview.cc 2 May 2004 08:00:49 -0000
@@ -89,6 +89,12 @@
#include <kotextobject.h>
#include <tkcoloractions.h>
+#include <kspell2/dialog.h>
+#include <kspell2/broker.h>
+#include <kspell2/defaultdictionary.h>
+#include "kospell.h"
+using namespace KSpell2;
+
#include <kaccel.h>
#include <kaccelgen.h>
#include <kdebug.h>
@@ -118,9 +124,6 @@
#include <stdlib.h>
-#include <koSpell.h>
-#include <kspelldlg.h> // for KS_* (hmm)
-
KWView::KWView( KWViewMode* viewMode, QWidget *_parent, const char *_name, \
KWDocument* _doc ) : KoView( _doc, _parent, _name )
{
@@ -3618,6 +3621,7 @@ void KWView::slotSpellCheck()
objects = m_gui->canvasWidget()->kWordDocument()->visibleTextObjects(m_gui->canvasWidget()->viewMode());
}
m_spell.textIterator = new KoTextIterator( objects, edit, options );
+ kdDebug()<<"Created iterator with "<< objects.count() <<endl;
startKSpell();
}
@@ -5294,79 +5298,28 @@ void KWView::openPopupMenuEditFrame( con
void KWView::startKSpell()
{
kdDebug()<<"void KWView::startKSpell()**************\n";
- if(m_doc->getKOSpellConfig())
- {
- m_doc->getKOSpellConfig()->setIgnoreList(m_doc->spellListIgnoreAll());
- m_doc->getKOSpellConfig()->setReplaceAllList(m_spell.replaceAll);
- }
- m_spell.kospell = KOSpell::createKoSpell( this, i18n( "Spell Checking" ), \
this,SLOT( spellCheckerReady() ) ,m_doc->getKOSpellConfig(), true,true /*FIXME \
!!!!!!!!!*/ );
- //new KOSpell( this, i18n( "Spell Checking" ), this, SLOT( spellCheckerReady() \
), m_doc->getKOSpellConfig() );
-
-
- QObject::connect( m_spell.kospell, SIGNAL( death() ),
- this, SLOT( spellCheckerFinished() ) );
- QObject::connect( m_spell.kospell, SIGNAL( misspelling( const QString &, const \
QStringList &, unsigned int ) ),
- this, SLOT( spellCheckerMisspelling( const QString &, const \
QStringList &, unsigned int ) ) );
- QObject::connect( m_spell.kospell, SIGNAL( corrected( const QString &, const \
QString &, unsigned int ) ),
- this, SLOT( spellCheckerCorrected( const QString &, const \
QString &, unsigned int ) ) );
- QObject::connect( m_spell.kospell, SIGNAL( done( const QString & ) ),
- this, SLOT( spellCheckerDone( const QString & ) ) );
- QObject::connect( m_spell.kospell, SIGNAL( ignoreall (const QString & ) ),
- this, SLOT( spellCheckerIgnoreAll( const QString & ) ) );
-
- QObject::connect( m_spell.kospell, SIGNAL( replaceall( const QString & , const \
QString & )), this, SLOT( spellCheckerReplaceAll( const QString & , const QString & \
)));
- QObject::connect( m_spell.kospell, SIGNAL( spellCheckerReady()), this, SLOT( \
spellCheckerReady()));
-
- kdDebug()<<" end void KWView::startKSpell() \n";
-}
+ if ( !m_spell.kospell )
+ m_spell.kospell = new KoSpell( Broker::openBroker( \
KSharedConfig::openConfig( "kwordrc" ) ), this );
-void KWView::spellCheckerReady()
-{
- kdDebug()<<"void KWView::spellCheckerReady() ******************\n";
// Spell-check the next paragraph
Q_ASSERT( m_spell.textIterator );
- if ( !m_spell.textIterator->atEnd() )
- {
- bool textIsEmpty = true;
- QString text;
- while ( textIsEmpty && !m_spell.textIterator->atEnd() )
- {
- text = m_spell.textIterator->currentText();
- // Determine if text has any non-space character, otherwise there's \
nothing to spellcheck
- for ( uint i = 0 ; i < text.length() ; ++ i )
- if ( !text[i].isSpace() ) {
- textIsEmpty = false;
- break;
- }
- if ( textIsEmpty )
- ++(*m_spell.textIterator);
- }
- if ( !textIsEmpty )
- {
- kdDebug(32001) << "Checking " << text << endl;
- text += '\n'; // end of paragraph
- text += '\n'; // empty line required by kspell
- m_spell.kospell->check( text);
- kdDebug()<<" check :"<<text<<endl;
- // ??? textfs->textObject()->setNeedSpellCheck(true);
- return;
- }
- }
- //kdDebug(32001) << "KWView::spellCheckerReady done" << endl;
+ kdDebug()<<"void KWView::spellCheckerReady() ******************\n" << \
m_spell.textIterator->currentText() <<endl;
- // Done
- if ( m_spell.textIterator->options() & KFindDialog::SelectedText )
- {
- KMessageBox::information(this,
- i18n("Spellcheck selection finished."),
- i18n("Spell Checking"));
- }
- //m_doc->setReadWrite(true);
- kdDebug()<<" clearSpellChecker();************************\n";
- clearSpellChecker();
+ m_spell.kospell->check( m_spell.textIterator, true );
+
+ KSpell2::Dialog *dlg = new KSpell2::Dialog( m_spell.kospell, this );
+ QObject::connect( dlg, SIGNAL(misspelling(const QString&, int)),
+ this, SLOT(spellCheckerMisspelling(const QString&, int)) );
+ QObject::connect( dlg, SIGNAL(replace(const QString&, int, const QString&)),
+ this, SLOT(spellCheckerCorrected(const QString&, int, const \
QString&)) ); + QObject::connect( dlg, SIGNAL(done(const QString&) ),
+ this, SLOT(spellCheckerDone(const QString&)) );
+ dlg->show();
+
+ //clearSpellChecker();
}
-void KWView::spellCheckerMisspelling( const QString &old, const QStringList &, \
unsigned int pos ) +void KWView::spellCheckerMisspelling( const QString &old, int pos \
) {
//kdDebug(32001) << "KWView::spellCheckerMisspelling old=" << old << " pos=" << \
pos << endl; KoTextObject* textobj = m_spell.textIterator->currentTextObject();
@@ -5382,7 +5335,7 @@ void KWView::spellCheckerMisspelling( co
textdoc->textFrameSet()->highlightPortion( parag, pos, old.length(), \
m_gui->canvasWidget() ); }
-void KWView::spellCheckerCorrected( const QString &old, const QString &corr, \
unsigned int pos ) +void KWView::spellCheckerCorrected( const QString &old, int pos , \
const QString &corr ) {
//kdDebug(32001) << "KWView::spellCheckerCorrected old=" << old << " corr=" << \
corr << " pos=" << pos << endl; KoTextObject* textobj = \
m_spell.textIterator->currentTextObject(); @@ -5415,28 +5368,14 @@ void \
KWView::spellCheckerDone( const QSt if ( textdoc )
textdoc->textFrameSet()->removeHighlight();
- int result = m_spell.kospell->dlgResult();
- if ( result != KS_CANCEL && result != KS_STOP )
- {
- // Move on to next paragraph
- ++(*m_spell.textIterator);
- spellCheckerReady();
- }
- else // aborted
- {
clearSpellChecker();
- }
}
void KWView::clearSpellChecker()
{
kdDebug(32001) << "KWView::clearSpellChecker" << endl;
- if ( m_spell.kospell ) {
- m_spell.kospell->cleanUp();
delete m_spell.kospell;
- m_spell.kospell = 0;
- }
-
+ m_spell.kospell=0;
delete m_spell.textIterator;
m_spell.textIterator = 0L;
if(m_spell.macroCmdSpellCheck)
@@ -5494,17 +5433,6 @@ void KWView::configureSpellChecker()
configDia.exec();
}
-void KWView::spellCheckerIgnoreAll( const QString & word)
-{
- m_doc->addIgnoreWordAll( word );
-}
-
-void KWView::spellCheckerReplaceAll( const QString & origword , const QString & \
replacement)
-{
- m_spell.replaceAll.append( origword );
- m_spell.replaceAll.append( replacement );
-}
-
void KWView::spellAddAutoCorrect (const QString & originalword, const QString & \
newword) {
m_doc->getAutoFormat()->addAutoFormatEntry( originalword, newword );
@@ -7236,9 +7164,9 @@ QPtrList<KAction> KWView::listOfResultOf
{
QPtrList<KAction> listAction;
//not perfect, improve API!!!!
- KOSpell *tmpSpell = KOSpell::createKoSpell( this, i18n( "Spell Checking" ), \
this, 0 ,m_doc->getKOSpellConfig(), true,true /*FIXME !!!!!!!!!*/ );
- QStringList lst = tmpSpell->resultCheckWord(word );
- delete tmpSpell;
+ KSpell2::Broker::Ptr broker = Broker::openBroker( KSharedConfig::openConfig( \
"kwordrc" ) ); + DefaultDictionary *dict = broker->defaultDictionary();
+ QStringList lst = dict->suggest( word );
if ( !lst.contains( word ) )
{
QStringList::ConstIterator it = lst.begin();
Index: kwview.h
===================================================================
RCS file: /home/kde/koffice/kword/kwview.h,v
retrieving revision 1.264
diff -u -u -p -r1.264 kwview.h
--- kwview.h 23 Apr 2004 08:21:12 -0000 1.264
+++ kwview.h 2 May 2004 08:00:49 -0000
@@ -51,7 +51,7 @@ class KWStyleManager;
class KWTableDia;
class KWView;
class QResizeEvent;
-class KSpell;
+//class KSpell;
class QScrollView;
class QSplitter;
class KAction;
@@ -80,7 +80,7 @@ class KWTableStyle;
class KoTextIterator;
class KWTableFrameSet;
-class KOSpell;
+class KoSpell;
/******************************************************************/
/* Class: KWView */
@@ -437,13 +437,10 @@ protected slots:
virtual void slotChildActivated( bool a ); // from KoView
void slotSetInitialPosition();
- void spellCheckerReady();
- void spellCheckerMisspelling( const QString &, const QStringList &, unsigned int \
);
- void spellCheckerCorrected( const QString &, const QString &, unsigned int);
+ void spellCheckerMisspelling( const QString &, int );
+ void spellCheckerCorrected( const QString &, int, const QString & );
void spellCheckerDone( const QString & );
void spellCheckerFinished( );
- void spellCheckerIgnoreAll( const QString &);
- void spellCheckerReplaceAll( const QString &, const QString &);
void spellAddAutoCorrect (const QString & originalword, const QString & \
newword); void slotApplyFont();
void slotApplyParag();
@@ -742,7 +739,7 @@ private:
// Spell-checking
struct {
- KOSpell *kospell;
+ KoSpell *kospell;
KMacroCommand * macroCmdSpellCheck;
QStringList replaceAll;
KoTextIterator * textIterator;
cvs diff: Diffing data
cvs diff: Diffing demos
cvs diff: Diffing dtd
cvs diff: Diffing expression
cvs diff: Diffing horizontalline
cvs diff: Diffing mailmerge
cvs diff: Diffing mailmerge/kabc
cvs diff: Diffing mailmerge/sql
cvs diff: Diffing pics
cvs diff: Diffing templates
cvs diff: Diffing templates/CardsAndLabels
cvs diff: Diffing templates/DTP
cvs diff: Diffing templates/Envelopes
cvs diff: Diffing templates/Wordprocessing
cvs diff: Diffing toolbar
_______________________________________________
koffice-devel mailing list
koffice-devel@mail.kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic