VAOS SpellChecker Implementation


The spellchecker in VAOS was implemented with the following goals in mind:

  • It should work in as similar a way to the spellchecker in VA5 as possible
  • It should use a freely available Open Source spellchecker engine
  • It should be pluggable – allowing support different spellchecker engines to be provided if required
  • It should support multiple dictionaries/languages

After some research and playing around it was decided to use the GNU ASpell spellchecker as the bases for the initial implementation. The MySpell spellchecker from the Lingucomponent project of was also considered, but it offered a less rich interface (there was no API support for personal dictionaries, for example) and its future was in doubt as were planning to replace MySpell with Hunspell, which is itself based on ASpell (as, indeed, they did starting with OO 2.0.2).

To ensure pluggability, the VAOS spellchecker is written as a DLL separate from the main application. The main VAOS program has no absolute dependency upon the spellchecker and can run without any spellchecker DLL being installed (but, of course, spellchecking will then not be available). Initially a single DLL wrapping GNU ASpell has been written, but it is intended that it should be possible to write alternative DLLs supporting the same VAOS spellchecker API and wrapping different spellchecker engines.

Application Support

Within the VA application spellchecker support is handled by the VASpellChecker class. This is a lightweight wrapper around spellchecker functionality that introduces few dependencies between the spellchecker and other VA code. In VA builds that support spellchcking every instance of a message editor window owns a VASpellChecker object that is used to check the spelling of the window. Spellchecking may be initiated by the user at any time, and may be invoked automatically when the message editor is closed.

The VASpellChecker class uses an EditSpellChecker object. An EditSpellChecker checks the spelling of a Windows Edit control (such as the VA message editor window). The EditSpellChecker uses a SpellChecker object to check the spelling and an EditWindowBufferManager object to handle the text buffer from the edit control.

The SpellChecker class is a thin wrapper around the VAOS Spellchecker API as exposed by a spellchecker DLL. The class also had responsibility for loading and unloading the DLL.

When an EditSpellChecker object checks spelling it uses a SpellDialog object to manage interaction with the user. The dialog is not initially displayed, but as soon as one questionable spelling is found the dialog is displayed and kept onscreen until the spellcheck operation is complete.


Global spllchecker options are set using the "Spell" tab of the main VA configuration dialog box, accessed from the "Tools" | "Options" menu. This dialog can be used to set the default configuration of any spellchecker created by VA, but does not affect the configuration of any existing spellchecker objects.

Options for the spellchecker associated with a particular message editor window can be set from the (new) "Spelling" button on the "Options" dialog for the editor. Options can also be changed by selecting the "Options" button in the spellchek dialog.

Whichever way options are set, the same dialog box resource is used – either for the "Spell" tab of the "Tools" | "Options" dialog or for the SpellOptionsDialog used for an individual spellchecker's options. The actual code used is different in each case, but should be equivalent (it might have been better to use the same code, but I didn't feel like rewriting and refactoring the whole of tpconfig.cpp").

"Auto-Correct as you Type"

The old VA5 code for autocorrection has been reinstated, and works as well as before.

Dictionary Maintenance

There is no GUI within VA to manage the dictionaries used by the main spellchecker. This is seen as a task that should be supported by the underlying spellchecker (which may be used by several different applications, and is not the responsibility of any one of them).

The Auto-Correct functionality is managed entirely by VA, and so VA provides an interface whereby the Auto-Correct dictionary may be edited. This is all new code, but is modelled on the behaviour of the VA5 implementation.

devinfo/spellcheckerimpl.txt · Last modified: 06.05.2007 20:41 by daniel
Recent changes RSS feed Driven by DokuWiki