[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 9:00:56
Message-ID: 200405021100.57054.montel () kde ! org
[Download RAW message or body]

Le Sunday 02 May 2004 10:02, Laurent Montel a écrit :
> 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.

I adapted kpresenter to use kspell2
But for the moment it doesn't work because for the moment kpresenter doesn't 
use kotextiterator. I will adapt kpresenter to use kotextiterator (sync with 
kword)

Background spell check into kword works very well.
Spell check into kword doesn't work very well, it doesn't highlight good text, 
and it crashed when we close spell check dialogbox.

Regards.

["kpresenter.patch" (text/x-diff)]

cvs diff: Diffing .
Index: Makefile.am
===================================================================
RCS file: /home/kde/koffice/kpresenter/Makefile.am,v
retrieving revision 1.214
diff -u -u -p -r1.214 Makefile.am
--- Makefile.am	18 Apr 2004 11:49:30 -0000	1.214
+++ Makefile.am	2 May 2004 08:58:07 -0000
@@ -52,7 +52,7 @@ libkpresenterpart_la_SOURCES = koPointAr
 	imageEffectDia.cc imageEffectBase.ui
 
 libkpresenterpart_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN)
-libkpresenterpart_la_LIBADD = autoformEdit/libaf.la $(LIB_KOFFICEUI) $(LIB_KOTEXT) \
-lkspell $(LIBKOSPELL) -lartskde -lkdefx +libkpresenterpart_la_LIBADD = \
autoformEdit/libaf.la $(LIB_KOFFICEUI) $(LIB_KOTEXT) $(LIBKOSPELL) -lartskde -lkdefx  \
libkpresenterpart_la_METASOURCES = AUTO  
 ## The kdeinit loadable module and the executable
Index: kprbgspellcheck.cc
===================================================================
RCS file: /home/kde/koffice/kpresenter/kprbgspellcheck.cc,v
retrieving revision 1.8
diff -u -u -p -r1.8 kprbgspellcheck.cc
--- kprbgspellcheck.cc	27 Aug 2003 14:45:39 -0000	1.8
+++ kprbgspellcheck.cc	2 May 2004 08:58:07 -0000
@@ -21,48 +21,41 @@
 
 
 #include "kprbgspellcheck.h"
-#include <kdebug.h>
-#include <kotextobject.h>
 #include "kpresenter_doc.h"
 #include "kptextobject.h"
 
+
+#include "kotextiterator.h"
+#include "kotextobject.h"
+
+#include <kspell2/broker.h>
+using namespace KSpell2;
+
+#include <kdebug.h>
+#include <kconfig.h>
+#include <klocale.h>
+
 KPrBgSpellCheck::KPrBgSpellCheck(KPresenterDoc *_doc)
-    : KoBgSpellCheck()
+    : KoBgSpellCheck(Broker::openBroker( KSharedConfig::openConfig( "kpresenterrc" ) \
), +                      _doc )
 {
     m_doc=_doc;
     m_currentObj=0L;
-    objectForSpell(m_currentObj);
 }
 
 KPrBgSpellCheck::~KPrBgSpellCheck()
 {
 }
 
-void KPrBgSpellCheck::objectForSpell(KPTextObject *curr)
-{
-    m_currentObj=curr;
-    if( m_currentObj && m_currentObj->textObject())
-        m_bgSpell.currentTextObj=m_currentObj->textObject();
-    else
-        m_bgSpell.currentTextObj=0L;
-}
 
-void KPrBgSpellCheck::slotRepaintChanged(KoTextObject *obj)
+KoTextIterator *KPrBgSpellCheck::createWholeDocIterator() const
 {
-    if( m_currentObj->textObject()==obj)
-        m_doc->repaint(m_currentObj);
-}
+    QValueList<KoTextObject *> objects = m_doc->visibleTextObjects( );
 
-KoTextObject *KPrBgSpellCheck::nextTextObject( KoTextObject *obj )
-{
-    m_currentObj=m_doc->nextTextFrameSet(m_currentObj);
-    if(!m_currentObj)
-        return 0L;
-    else
-        return m_currentObj->textObject();
-}
+    kdDebug()<<"Number of visible text objects = "<< objects.count() << endl;
 
-void KPrBgSpellCheck::configurateSpellChecker()
-{
-    m_doc->configureSpellChecker();
+    if ( objects.isEmpty() )
+        return 0;
+
+    return new KoTextIterator( objects, 0, 0 );
 }
Index: kprbgspellcheck.h
===================================================================
RCS file: /home/kde/koffice/kpresenter/kprbgspellcheck.h,v
retrieving revision 1.8
diff -u -u -p -r1.8 kprbgspellcheck.h
--- kprbgspellcheck.h	27 Aug 2003 14:45:39 -0000	1.8
+++ kprbgspellcheck.h	2 May 2004 08:58:07 -0000
@@ -24,25 +24,15 @@
 
 class KPresenterDoc;
 class KPTextObject;
-
-#include <koBgSpellCheck.h>
+#include "kobgspellcheck.h"
 
 class KPrBgSpellCheck : public KoBgSpellCheck
 {
 public:
     KPrBgSpellCheck(KPresenterDoc *_doc);
     virtual ~KPrBgSpellCheck();
+    virtual KoTextIterator *createWholeDocIterator() const;
 
-    void objectForSpell(KPTextObject *curr);
-    //repaint object when we spell check
-    virtual void slotRepaintChanged(KoTextObject *obj);
-
-    KPTextObject *currentCheckSpellingFrame() const { return m_currentObj; }
-
-    KoTextObject *nextTextObject( KoTextObject *obj );
-
-    //spell checker is not configurate.
-    virtual void configurateSpellChecker();
 
 private:
     KPresenterDoc *m_doc;
Index: kpresenter_dlg_config.cc
===================================================================
RCS file: /home/kde/koffice/kpresenter/kpresenter_dlg_config.cc,v
retrieving revision 1.117
diff -u -u -p -r1.117 kpresenter_dlg_config.cc
--- kpresenter_dlg_config.cc	23 Apr 2004 08:21:10 -0000	1.117
+++ kpresenter_dlg_config.cc	2 May 2004 08:58:08 -0000
@@ -48,7 +48,6 @@
 #include <koUnit.h>
 
 #include <float.h>
-#include <kspell.h>
 #include <knumvalidator.h>
 #include <qlineedit.h>
 #include "kprcommand.h"
@@ -61,9 +60,7 @@
 #include <kurlrequesterdlg.h>
 #include <klistview.h>
 #include <kfiledialog.h>
-#include <koSpellConfig.h>
 #include <koeditpath.h>
-#include <koSconfig.h>
 
 KPConfig::KPConfig( KPresenterView* parent )
     : KDialogBase(KDialogBase::IconList,i18n("Configure KPresenter") ,
@@ -358,52 +355,25 @@ configureSpellPage::configureSpellPage( 
 {
     m_pView=_view;
     config = KPresenterFactory::global()->config();
-    m_spellConfigWidget = new KoSpellConfigWidget( parent, \
                m_pView->kPresenterDoc()->getKOSpellConfig(), true);
-#if 0
-    if( config->hasGroup("KSpell kpresenter") )
-    {
-        config->setGroup( "KSpell kpresenter" );
-        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->kPresenterDoc()->backgroundSpellCheckEnabled() );
-    m_spellConfigWidget->addIgnoreList( \
m_pView->kPresenterDoc()->spellListIgnoreAll() );  }
 
 void configureSpellPage::apply()
 {
 
-    KOSpellConfig *_spellConfig = m_spellConfigWidget->spellConfig();
-    config->setGroup( "KSpell kpresenter" );
-    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_dont_check_upper_word", \
                (int)_spellConfig->dontCheckUpperWord());
-    config->writeEntry ("KSpell_IgnoreCase",(int) _spellConfig->ignoreCase());
-    config->writeEntry( "KSpell_IgnoreAccent", (int) _spellConfig->ignoreAccent());
-    config->writeEntry( "KSpell_SpellWordWithNumber", \
                (int)_spellConfig->spellWordWithNumber());
-    m_spellConfigWidget->saveDictionary();
     KPresenterDoc* doc = m_pView->kPresenterDoc();
-    doc->setKOSpellConfig(*_spellConfig);
 
-    bool state = m_spellConfigWidget->backgroundSpellCheck();
-    config->writeEntry( "SpellCheck", (int)state );
+    //bool state = m_spellConfigWidget->backgroundSpellCheck();
+    //config->writeEntry( "SpellCheck", (int)state );
 
-    doc->addIgnoreWordAllList( m_spellConfigWidget->ignoreList() );
+    //doc->addIgnoreWordAllList( m_spellConfigWidget->ignoreList() );
 
-    doc->reactivateBgSpellChecking(state);
+    //doc->reactivateBgSpellChecking(state);
     //FIXME reactivate just if there is a changes.
-    doc->enableBackgroundSpellCheck( state );
+    //doc->enableBackgroundSpellCheck( state );
 }
 
 void configureSpellPage::slotDefault()
 {
-    m_spellConfigWidget->setDefault();
 }
 
 configureMiscPage::configureMiscPage( KPresenterView *_view, QWidget *parent, char \
                *name )
Index: kpresenter_dlg_config.h
===================================================================
RCS file: /home/kde/koffice/kpresenter/kpresenter_dlg_config.h,v
retrieving revision 1.46
diff -u -u -p -r1.46 kpresenter_dlg_config.h
--- kpresenter_dlg_config.h	27 Aug 2003 14:45:39 -0000	1.46
+++ kpresenter_dlg_config.h	2 May 2004 08:58:08 -0000
@@ -28,7 +28,6 @@ class KPresenterDoc;
 class KIntNumInput;
 class KColorButton;
 class KConfig;
-class KSpellConfig;
 class QCheckBox;
 class KLineEdit;
 class KDoubleNumInput;
Index: kpresenter_doc.cc
===================================================================
RCS file: /home/kde/koffice/kpresenter/kpresenter_doc.cc,v
retrieving revision 1.743
diff -u -u -p -r1.743 kpresenter_doc.cc
--- kpresenter_doc.cc	26 Apr 2004 14:21:56 -0000	1.743
+++ kpresenter_doc.cc	2 May 2004 08:58:09 -0000
@@ -202,7 +202,6 @@ KPresenterDoc::KPresenterDoc( QWidget *p
     _yRnd = 20;
     _txtBackCol = lightGray;
     _otxtBackCol = lightGray;
-    m_pKOSpellConfig = 0;
 
     m_bShowRuler=true;
     m_bAllowAutoFormat = true;
@@ -369,25 +368,13 @@ void KPresenterDoc::initConfig()
         setGridColor(config->readColorEntry( "GridColor", &oldGridColor ));
     }
 
-    KOSpellConfig kosconfig;
 
     if( config->hasGroup("KSpell kpresenter" ) )
     {
         config->setGroup( "KSpell kpresenter" );
-        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", KS_E_ASCII));
-        kosconfig.setClient(config->readNumEntry ("KSpell_Client", \
                KS_CLIENT_ISPELL));
-        kosconfig.setDontCheckUpperWord(config->readBoolEntry("KSpell_dont_check_upper_word",false));
                
-        kosconfig.setDontCheckTitleCase(config->readBoolEntry("KSpell_dont_check_title_case",false));
                
-        kosconfig.setIgnoreCase( config->readNumEntry( "KSpell_IgnoreCase", 0));
-        kosconfig.setIgnoreAccent( config->readNumEntry( "KSpell_IgnoreAccent", 0));
-        kosconfig.setSpellWordWithNumber( \
                config->readNumEntry("KSpell_SpellWordWithNumber", false));
-        setKOSpellConfig(kosconfig);
 
-        m_bgSpellCheck->enableBackgroundSpellCheck(config->readBoolEntry( \
"SpellCheck", false )); +        //TODO FIXME
+        //m_bgSpellCheck->enableBackgroundSpellCheck(config->readBoolEntry( \
"SpellCheck", false ));  
     }
     int undo=30;
@@ -439,7 +426,6 @@ KPresenterDoc::~KPresenterDoc()
     delete m_stickyPage;
     delete m_bgSpellCheck;
     delete m_styleColl;
-    delete m_pKOSpellConfig;
 
     m_pageList.setAutoDelete( true );
     m_pageList.clear();
@@ -1639,7 +1625,7 @@ bool KPresenterDoc::loadXML( const QDomD
                 }
                 spellWord=spellWord.nextSibling().toElement();
             }
-            m_bgSpellCheck->addIgnoreWordAllList( m_spellListIgnoreAll );
+            //m_bgSpellCheck->addIgnoreWordAllList( m_spellListIgnoreAll );
         }else if(elem.tagName()=="ATTRIBUTES" && _clean) {
             if(elem.hasAttribute("activePage"))
                 activePage=elem.attribute("activePage").toInt();
@@ -3301,15 +3287,14 @@ void KPresenterDoc::startBackgroundSpell
     {
         if(m_initialActivePage->allTextObjects().count()>0)
         {
-            m_bgSpellCheck->objectForSpell(m_initialActivePage->textFrameSet(0));
-            m_bgSpellCheck->startBackgroundSpellCheck();
+            m_bgSpellCheck->start();
         }
     }
 }
 
 void KPresenterDoc::enableBackgroundSpellCheck( bool b )
 {
-    m_bgSpellCheck->enableBackgroundSpellCheck(b);
+    //m_bgSpellCheck->enableBackgroundSpellCheck(b);
     QPtrListIterator<KoView> it( views() );
     for( ; it.current(); ++it )
         ((KPresenterView*)it.current())->updateBgSpellCheckingState();
@@ -3317,7 +3302,7 @@ void KPresenterDoc::enableBackgroundSpel
 
 bool KPresenterDoc::backgroundSpellCheckEnabled() const
 {
-    return m_bgSpellCheck->backgroundSpellCheckEnabled();
+    return true; //m_bgSpellCheck->backgroundSpellCheckEnabled();
 }
 
 void KPresenterDoc::reactivateBgSpellChecking(bool refreshTextObj)
@@ -3349,37 +3334,19 @@ QPtrList<KoTextObject> KPresenterDoc::al
     return lst;
 }
 
-KPTextObject* KPresenterDoc::nextTextFrameSet(KPTextObject *obj)
+QValueList<KoTextObject *> KPresenterDoc::visibleTextObjects( ) const
 {
-    if(m_initialActivePage)
-    {
-        bool findObject = m_initialActivePage->findTextObject( bgObjSpellChecked );
-        if ( !findObject )
+    QValueList<KoTextObject *> lst;
+    QPtrList<KoTextObject> textFramesets = allTextObjects(  );
+
+    KoTextObject *frm;
+    for ( frm=textFramesets.first(); frm != 0; frm=textFramesets.next() ) {
+        if ( frm && !frm->protectContent() )
         {
-            findObject = m_stickyPage->findTextObject( bgObjSpellChecked );
-            if ( findObject )
-            {
-                bgObjSpellChecked = m_stickyPage->nextTextObject( obj );
-                if ( bgObjSpellChecked )
-                    return bgObjSpellChecked->nextTextObject();
-                else
-                    return 0L;
-            }
+            lst.append( frm );
         }
-        bgObjSpellChecked = m_initialActivePage->nextTextObject( obj );
-        if ( bgObjSpellChecked )
-            return bgObjSpellChecked->nextTextObject();
-        else
-        {
-            bgObjSpellChecked = m_stickyPage->nextTextObject( obj );
-            if ( bgObjSpellChecked )
-                return bgObjSpellChecked->nextTextObject();
-            else
-                return 0L;
-        }
-        return 0L;
     }
-    return 0L;
+    return lst;
 }
 
 void KPresenterDoc::setShowHelplines(bool b)
@@ -3548,13 +3515,13 @@ void KPresenterDoc::addIgnoreWordAll( co
 {
     if( m_spellListIgnoreAll.findIndex( word )==-1)
         m_spellListIgnoreAll.append( word );
-    m_bgSpellCheck->addIgnoreWordAll( word );
+    //m_bgSpellCheck->addIgnoreWordAll( word );
 }
 
 void KPresenterDoc::clearIgnoreWordAll( )
 {
     m_spellListIgnoreAll.clear();
-    m_bgSpellCheck->clearIgnoreWordAll( );
+    //m_bgSpellCheck->clearIgnoreWordAll( );
 }
 
 void KPresenterDoc::updateObjectStatusBarItem()
@@ -3653,7 +3620,7 @@ void KPresenterDoc::insertFile(const QSt
 
 void KPresenterDoc::spellCheckParagraphDeleted( KoTextParag *_parag,  KPTextObject \
*frm)  {
-    m_bgSpellCheck->spellCheckParagraphDeleted( _parag, frm->textObject());
+    //m_bgSpellCheck->spellCheckParagraphDeleted( _parag, frm->textObject());
 }
 
 void KPresenterDoc::configureSpellChecker()
@@ -3731,27 +3698,9 @@ KPresenterView *KPresenterDoc::firstView
 
 void KPresenterDoc::addWordToDictionary( const QString & word)
 {
-    if ( m_bgSpellCheck )
-        m_bgSpellCheck->addPersonalDictonary( word );
+    //if ( m_bgSpellCheck )
+    //m_bgSpellCheck->addPersonalDictonary( word );
 }
 
-void KPresenterDoc::setKOSpellConfig(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->setDontCheckTitleCase( _kspell.dontCheckTitleCase());
-    m_pKOSpellConfig->setDontCheckUpperWord( _kspell.dontCheckUpperWord() );
-    m_pKOSpellConfig->setIgnoreCase ( _kspell.ignoreCase ());
-    m_pKOSpellConfig->setIgnoreAccent( _kspell.ignoreAccent());
-    m_pKOSpellConfig->setSpellWordWithNumber( _kspell.spellWordWithNumber());
-    m_pKOSpellConfig->setClient (_kspell.client());
-    m_bgSpellCheck->setKSpellConfig(_kspell);
-}
 
 #include "kpresenter_doc.moc"
Index: kpresenter_doc.h
===================================================================
RCS file: /home/kde/koffice/kpresenter/kpresenter_doc.h,v
retrieving revision 1.358
diff -u -u -p -r1.358 kpresenter_doc.h
--- kpresenter_doc.h	25 Apr 2004 16:37:53 -0000	1.358
+++ kpresenter_doc.h	2 May 2004 08:58:09 -0000
@@ -45,7 +45,6 @@ class KoTextObject;
 class KPRLoadingInfo;
 class KPGroupObject;
 
-class KOSpellConfig;
 class KoOasisContext;
 class KoXmlWriter;
 
@@ -292,8 +291,6 @@ class KPresenterDoc : public KoDocument
     /**
      * get custom kspell config
      */
-    void setKOSpellConfig(KOSpellConfig _kspell);
-    KOSpellConfig * getKOSpellConfig()const {return m_pKOSpellConfig;}
 
     bool showStatusBar() const { return m_bShowStatusBar;}
     void setShowStatusBar( bool _status ) { m_bShowStatusBar = _status;}
@@ -368,8 +365,8 @@ class KPresenterDoc : public KoDocument
 
     //refresh obj when we active or disactive
     void reactivateBgSpellChecking(bool refreshTextObj=false);
-    KPTextObject* nextTextFrameSet(KPTextObject *obj); // deprecated
     QPtrList<KoTextObject> allTextObjects() const;
+    QValueList<KoTextObject *> visibleTextObjects( ) const;
 
     bool allowAutoFormat() const { return m_bAllowAutoFormat; }
     void setAllowAutoFormat(bool _b){ m_bAllowAutoFormat=_b; }
@@ -479,6 +476,7 @@ class KPresenterDoc : public KoDocument
     void saveEmbeddedObject(KPrPage *page, const QPtrList<KoDocumentChild>& \
                childList ,QDomDocument &doc,QDomElement &presenter );
     void insertEmbedded( KoStore *store, QDomElement elem, KMacroCommand * macroCmd, \
KPrPage *page );  
+    KPrBgSpellCheck* backSpeller() const { return m_bgSpellCheck; }
 
 public slots:
     void movePage( int from, int to );
@@ -587,7 +585,6 @@ protected:
     KoZoomHandler* m_zoomHandler;
     QFont m_defaultFont;
     KoAutoFormat * m_autoFormat;
-    KOSpellConfig *m_pKOSpellConfig;
 
     bool m_bShowRuler;
     bool m_bShowStatusBar;
Index: kpresenter_view.cc
===================================================================
RCS file: /home/kde/koffice/kpresenter/kpresenter_view.cc,v
retrieving revision 1.1008
diff -u -u -p -r1.1008 kpresenter_view.cc
--- kpresenter_view.cc	23 Apr 2004 08:21:10 -0000	1.1008
+++ kpresenter_view.cc	2 May 2004 08:58:09 -0000
@@ -67,7 +67,6 @@
 #include <kmessagebox.h>
 #include <kstdaction.h>
 #include <kapplication.h>
-#include <kspelldlg.h>
 #include <kio/netaccess.h>
 
 #include "kpresenter_view.h"
@@ -149,7 +148,12 @@
 #include <koStore.h>
 #include <koStoreDrag.h>
 
-#include <koSpell.h>
+
+#include <kspell2/dialog.h>
+#include <kspell2/broker.h>
+#include <kspell2/defaultdictionary.h>
+#include "kospell.h"
+using namespace KSpell2;
 
 #define DEBUG
 
@@ -4859,93 +4863,32 @@ void KPresenterView::spellAddTextObject(
     }
 }
 
-void KPresenterView::spellCheckerReplaceAll( const QString &orig, const QString & \
                replacement)
-{
-    m_spell.replaceAll.append( orig);
-    m_spell.replaceAll.append( replacement);
-}
 
 void KPresenterView::startKSpell()
 {
     // m_spellCurrFrameSetNum is supposed to be set by the caller of this method
-    if(m_pKPresenterDoc->getKOSpellConfig())
-    {
-        m_pKPresenterDoc->getKOSpellConfig()->setIgnoreList(m_pKPresenterDoc->spellListIgnoreAll());
                
-        m_pKPresenterDoc->getKOSpellConfig()->setReplaceAllList(m_spell.replaceAll);
-
-    }
-    m_spell.kospell =KOSpell::createKoSpell( this, i18n( "Spell Checking" ), \
this,SLOT( spellCheckerReady() ) ,m_pKPresenterDoc->getKOSpellConfig(), true,true \
/*FIXME !!!!!!!!!*/ );  //new KSpell( this, i18n( "Spell Checking" ),
     //                           this, SLOT( spellCheckerReady() ), \
m_pKPresenterDoc->getKSpellConfig() );  
 
-    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()));
-}
-
-void KPresenterView::spellCheckerIgnoreAll( const QString & word)
-{
-    m_pKPresenterDoc->addIgnoreWordAll( word );
-}
-
-void KPresenterView::spellCheckerReady()
-{
-    for ( unsigned int i = m_spell.spellCurrTextObjNum + 1; i < \
                m_spell.textObject.count(); i++ ) {
-        KPTextObject *textobj = m_spell.textObject.at( i );
-        m_spell.spellCurrTextObjNum = i; // store as number, not as pointer, to \
                implement "go to next frameset" when done
-        //kdDebug(33001) << "KPresenterView::spellCheckerReady spell-checking \
                frameset " << spellCurrTextObjNum << endl;
-        QString text = textobj->textDocument()->plainText();
-        if ( m_spell.bSpellSelection)
-            text = textobj->textDocument()->selectedText(KoTextDocument::Standard);
-        bool textIsEmpty=true;
-        // 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)
-            continue;
-        text += '\n'; // end of last paragraph
-        text += '\n'; // empty line required by kspell
-        m_spell.kospell->check( text);
-        textobj->textObject()->setNeedSpellCheck(true);
+    if ( !m_spell.kospell )
+        m_spell.kospell = new KoSpell( Broker::openBroker( \
KSharedConfig::openConfig( "kpresenterrc" ) ), this  ); +//FIXME !!!!!!!!!!!!!!!
+//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();
 
-
-        return;
-    }
-    //kdDebug(33001) << "KPresenterView::spellCheckerReady done" << endl;
-    if(!switchInOtherPage(i18n( "Do you want to spellcheck new slide?")))
-    {
-        // Done
-        m_pKPresenterDoc->setReadWrite(true);
-        delete m_spell.kospell;
-        m_spell.kospell=0;
-#if 0
-        m_spell.kspell->cleanUp();
-        delete m_spell.kspell;
-        m_spell.kspell = 0;
-#endif
-        clearSpellChecker();
-    }
-    else
-    {
-        spellAddTextObject();
-        spellCheckerReady();
-    }
 }
 
+
+
 void KPresenterView::clearSpellChecker()
 {
     m_initSwitchPage = -1;
@@ -4958,7 +4901,7 @@ void KPresenterView::clearSpellChecker()
     m_spell.selectionStartPos = 0;
 }
 
-void KPresenterView::spellCheckerMisspelling( const QString &old, const QStringList \
&, unsigned int pos ) +void KPresenterView::spellCheckerMisspelling( const QString \
&old, int pos )  {
     //kdDebug(33001) << "KPresenterView::spellCheckerMisspelling old=" << old << " \
                pos=" << pos << endl;
     KPTextObject * textobj = m_spell.textObject.at( m_spell.spellCurrTextObjNum ) ;
@@ -4977,7 +4920,7 @@ void KPresenterView::spellCheckerMisspel
     textobj->highlightPortion( p, pos, old.length(), m_canvas, true /*repaint*/ );
 }
 
-void KPresenterView::spellCheckerCorrected( const QString &old, const QString &corr, \
unsigned int pos ) +void KPresenterView::spellCheckerCorrected( const QString &old, \
int pos , const QString &cor)  {
     //kdDebug(33001) << "KWView::spellCheckerCorrected old=" << old << " corr=" << \
corr << " pos=" << pos << endl;  
@@ -5000,7 +4943,7 @@ void KPresenterView::spellCheckerCorrect
     if(!m_spell.macroCmdSpellCheck)
         m_spell.macroCmdSpellCheck=new KMacroCommand(i18n("Correct Misspelled \
                Word"));
     m_spell.macroCmdSpellCheck->addCommand(textobj->textObject()->replaceSelectionCommand(
                
-                                               &cursor, corr, \
KoTextObject::HighlightSelection, QString::null )); +                                 \
&cursor, cor, KoTextObject::HighlightSelection, QString::null ));  }
 
 void KPresenterView::spellCheckerDone( const QString & )
@@ -5013,7 +4956,9 @@ void KPresenterView::spellCheckerDone( c
         if ( textobj )
             textobj->removeHighlight();
     }
-    int result;
+
+#if 0
+
 #if 0 //FIXME !!!!!!!!!!!
     result= m_spell.kospell->dlgResult();
     //delete m_spell.kospell;
@@ -5061,11 +5006,12 @@ void KPresenterView::spellCheckerDone( c
             m_pKPresenterDoc->addCommand(m_spell.macroCmdSpellCheck);
         m_spell.macroCmdSpellCheck=0L;
     }
+#endif
 }
 
 void KPresenterView::spellCheckerFinished()
 {
-    KOSpell::spellStatus status = m_spell.kospell->status();
+    //KOSpell::spellStatus status = m_spell.kospell->status();
     bool kspellNoConfigured=false;
 #if 0
 
@@ -7051,9 +6997,9 @@ void KPresenterView::spellAddAutoCorrect
 QPtrList<KAction> KPresenterView::listOfResultOfCheckWord( const QString &word )
 {
  //not perfect, improve API!!!!
-    KOSpell *tmpSpell = KOSpell::createKoSpell( this, i18n( "Spell Checking" ), \
                this, 0,m_pKPresenterDoc->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 );
     QPtrList<KAction> listAction=QPtrList<KAction>();
     if ( !lst.contains( word ))
     {
Index: kpresenter_view.h
===================================================================
RCS file: /home/kde/koffice/kpresenter/kpresenter_view.h,v
retrieving revision 1.324
diff -u -u -p -r1.324 kpresenter_view.h
--- kpresenter_view.h	23 Apr 2004 08:21:10 -0000	1.324
+++ kpresenter_view.h	2 May 2004 08:58:10 -0000
@@ -76,7 +76,6 @@ class KFontSizeAction;
 class KColorAction;
 class KSelectAction;
 class KFontAction;
-class KSpell;
 class KoParagCounter;
 class KActionMenu;
 class KoSearchContext;
@@ -89,7 +88,7 @@ class KPresenterDoc;
 class KPrPage;
 class KPTextObject;
 
-class KOSpell;
+class KoSpell;
 
 class PageBase : public QWidget
 {
@@ -352,14 +351,12 @@ public slots:
     void extraSpelling();
 
 
-    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 startKSpell();
-    void spellCheckerReplaceAll( const QString &, const QString & );
     void spellAddAutoCorrect (const QString & originalword, const QString & \
newword);  
     void alignChanged( int );
@@ -1164,7 +1161,7 @@ private:
 
     // Spell-checking
     struct {
-        KOSpell *kospell;
+        KoSpell *kospell;
         int spellCurrTextObjNum;
         QPtrList<KPTextObject> textObject;
         KMacroCommand * macroCmdSpellCheck;
Index: kptextobject.cc
===================================================================
RCS file: /home/kde/koffice/kpresenter/kptextobject.cc,v
retrieving revision 1.422
diff -u -u -p -r1.422 kptextobject.cc
--- kptextobject.cc	23 Apr 2004 13:45:11 -0000	1.422
+++ kptextobject.cc	2 May 2004 08:58:10 -0000
@@ -36,7 +36,7 @@
 
 #include "kpresenter_view.h"
 #include "kpresenter_doc.h"
-
+#include "kprbgspellcheck.h"
 #include <korichtext.h>
 #include <kotextobject.h>
 #include <kostyle.h>
@@ -110,6 +110,7 @@ KPTextObject::KPTextObject(  KPresenterD
 
     m_textobj = new KoTextObject( textdoc, m_doc->styleCollection()->findStyle( \
"Standard" ), this );  
+    m_doc->backSpeller()->registerNewTextObject( m_textobj );
     brush = Qt::NoBrush;
     brush.setColor(QColor());
     pen = defaultPen();
cvs diff: Diffing autoformEdit
cvs diff: Diffing autoforms
cvs diff: Diffing autoforms/Arrows
cvs diff: Diffing autoforms/Connections
cvs diff: Diffing dtd
cvs diff: Diffing pics
cvs diff: Diffing scripts
cvs diff: Diffing slideshow
cvs diff: Diffing templates
cvs diff: Diffing templates/A4
cvs diff: Diffing templates/Screen
cvs diff: Diffing templates/Screenpresentations
cvs diff: Diffing templates/common_desktop
cvs diff: Diffing templates/common_icon
cvs diff: Diffing templates/legal
cvs diff: Diffing templates/letter
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