Re: spelling check dialog

Paul Rohr (
Wed, 29 Sep 1999 21:30:43 -0700

At 07:27 PM 9/29/99 -0500, Justin Bradford wrote:
>Ok, I'll make the XAP_Spell object, and then add a protected XAP_Spell *
>to XAP_App, along with a getSpell() method to XAP_App. The XAP_Spell
>pointer will be initialized in "initialize" which will load any relevant
>dictionary information (according to prefs).

Bingo. Sounds perfect.

>Ok, as I said before, we just need a hash table, so I propose adding a
>protected UT_HashTable to AD_Document,

I think if you make it a UT_AlphaHashTable instead, that'll make it easier
to persist the words in sorted order (but I haven't looked at those classes
in a while).

>along with with two functions:
>UT_Bool isSpellIgnore(UT_UCSChar * word);
>UT_Bool addSpellIgnore(UT_UCSChar * word);

To follow Jeff's naming convention in this class, I'd suggest the following
API, shamelessly cribbed from the existing (incomplete) document API for

UT_Bool appendIgnore(const UT_UCSChar * pszWord);

// "ignore all" list for spell check

UT_Bool isIgnore(UT_UCSChar * pszWord) const;
UT_Bool enumIgnores(UT_uint32 k, const UT_UCSChar * pszWord) const;
UT_Bool clearIgnores(void);

A few notes here:

1. I added the extra API calls you'll eventually need when persisting the
ignore all list to the file format, as well as a clear all method (needed
when you want to recheck a document from scratch).

2. The existing PD_Document APIs tend to use const XML_Char instead of
UT_UCSChar, because that's what expat wants to pass around (on import). If
you look in the view methods, we tend to do a lot of casting tricks between
the two to keep the document happy.

3. appendIgnore() was addSpellIgnore(), and isIgnore() was isSpellIgnore()

4. I think I got the consts right so that ownership of the relevant strings
is clear. If not, it should be pretty easy to figure out.

>If this sounds ok, I'll add the "ignore all" stuff to AD_Document, make
>the spelling dialog use it, and add the single line to fl_BlockLayout
>necessary to make the squiggles follow it, too.


>Once I do part 1, if that also sounds like a good place to put
>xap_Spell to you, I'll look at context menu spelling suggestions (which
>ought to be very simple at that point).

Yeah, Jeff's already stubbed in most of the EV_EMC_MISSPELLEDTEXT mechanism,
so "all" you need to do is use it to trigger a new contextMisspellText edit

The one place you may need to do a little work is extending the XP menu
mechanism to allow you to prepend a variable list of suggestions before the
rest of that context menu. If so, a decent place to start might be the
tricks we use to populate the recent and window menus on the main bar.

Or, if that gets hairy, let us know and we'll sic Jeff on that problem. In
the mean time, you could always cheat and only put the best suggestion on
the popup (which at least makes menu population easier).


This archive was generated by hypermail 1.03b2.