[REVIEW][3.5]fdo#46531, spell checking display fun
Michael Meeks
michael.meeks at suse.com
Tue Feb 28 06:13:19 PST 2012
On Tue, 2012-02-28 at 12:26 +0000, Caolán McNamara wrote:
> FWIW, the nastiness in that SpellDialog is that there are a bunch of
> things which would be natural to put directly into the ctor, but they
> would require calling virtual methods during construction, which doesn't
> work in c++, so there's some lame post-an-event hack and complete the
> construction steps that want to call virtuals in the event-callback
> which gets called on the next iteration of the main loop after the
> construction has completed.
Oh - that sounds pretty horrible lifecycle wise.
> Dialog is fragile and tricky :-(
So - given that the dialog was moved to cui, is not public, and has
only one constructor in the factory method - would something like the
appended clean that up rather pleasantly ?
Thoughts on the appended appreciated ...
All the best,
Michael.
diff --git a/cui/source/dialogs/SpellDialog.cxx b/cui/source/dialogs/SpellDialog.cxx
index cd9b273..8fe8036 100644
--- a/cui/source/dialogs/SpellDialog.cxx
+++ b/cui/source/dialogs/SpellDialog.cxx
@@ -284,9 +284,6 @@ SpellDialog::SpellDialog(
// disable controls if service is missing
if (!xSpell.is())
Enable( sal_False );
-
- Application::PostUserEvent( STATIC_LINK(
- this, SpellDialog, InitHdl ) );
}
// -----------------------------------------------------------------------
@@ -530,34 +527,33 @@ void SpellDialog::SpellContinue_Impl(bool bUseSavedSentence, bool bIgnoreCurrent
/* Initialize, asynchronous to prevent virtial calls
from a constructor
*/
-IMPL_STATIC_LINK( SpellDialog, InitHdl, SpellDialog *, EMPTYARG )
+void SpellDialog::LateInit()
{
- pThis->SetUpdateMode( sal_False );
+ SetUpdateMode( sal_False );
//show or hide AutoCorrect depending on the modules abilities
- pThis->aAutoCorrPB.Show(pThis->rParent.HasAutoCorrection());
- pThis->SpellContinue_Impl();
- pThis->aSentenceED.ResetUndo();
- pThis->aUndoPB.Enable(sal_False);
+ aAutoCorrPB.Show(rParent.HasAutoCorrection());
+ SpellContinue_Impl();
+ aSentenceED.ResetUndo();
+ aUndoPB.Enable(sal_False);
// get current language
- pThis->UpdateBoxes_Impl();
+ UpdateBoxes_Impl();
// fill dictionary PopupMenu
- pThis->InitUserDicts();
-
- pThis->LockFocusChanges(true);
- if( pThis->aChangePB.IsEnabled() )
- pThis->aChangePB.GrabFocus();
- else if( pThis->aIgnorePB.IsEnabled() )
- pThis->aIgnorePB.GrabFocus();
- else if( pThis->aClosePB.IsEnabled() )
- pThis->aClosePB.GrabFocus();
- pThis->LockFocusChanges(false);
+ InitUserDicts();
+
+ LockFocusChanges(true);
+ if( aChangePB.IsEnabled() )
+ aChangePB.GrabFocus();
+ else if( aIgnorePB.IsEnabled() )
+ aIgnorePB.GrabFocus();
+ else if( aClosePB.IsEnabled() )
+ aClosePB.GrabFocus();
+ LockFocusChanges(false);
//show grammar CheckBox depending on the modules abilities
- pThis->aCheckGrammarCB.Check( pThis->rParent.IsGrammarChecking() );
- pThis->SetUpdateMode( sal_True );
- pThis->Show();
- return 0;
+ aCheckGrammarCB.Check( rParent.IsGrammarChecking() );
+ SetUpdateMode( sal_True );
+ Show();
};
// -----------------------------------------------------------------------
diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx
index 5825421..c3f53e8 100644
--- a/cui/source/factory/dlgfact.cxx
+++ b/cui/source/factory/dlgfact.cxx
@@ -1184,6 +1184,7 @@ AbstractSpellDialog * AbstractDialogFactory_Impl::CreateSvxSpellDialog(
svx::SpellDialogChildWindow* pSpellChildWindow )
{
svx::SpellDialog* pDlg = new svx::SpellDialog(pSpellChildWindow, pParent, pBindings);
+ pDlg->LateInit();
return new AbstractSpellDialog_Impl(pDlg);
}
diff --git a/cui/source/inc/SpellDialog.hxx b/cui/source/inc/SpellDialog.hxx
index 71d502c..bf496c3 100644
--- a/cui/source/inc/SpellDialog.hxx
+++ b/cui/source/inc/SpellDialog.hxx
@@ -217,8 +217,6 @@ private:
DECL_LINK( DialogUndoHdl, SpellUndoAction_Impl* );
DECL_LINK( HandleHyperlink, svt::FixedHyperlink * );
- DECL_STATIC_LINK( SpellDialog, InitHdl, SpellDialog * );
-
void StartSpellOptDlg_Impl();
void InitUserDicts();
void UpdateBoxes_Impl();
@@ -251,10 +249,10 @@ public:
SfxBindings* pBindings);
~SpellDialog();
- void SetLanguage( sal_uInt16 nLang );
- virtual sal_Bool Close();
-
- void InvalidateDialog();
+ void LateInit();
+ void SetLanguage( sal_uInt16 nLang );
+ virtual sal_Bool Close();
+ void InvalidateDialog();
};
} //namespace svx
--
michael.meeks at suse.com <><, Pseudo Engineer, itinerant idiot
More information about the LibreOffice
mailing list