POW -- Word Count dialog

Paul Rohr (paul@abisource.com)
Sun, 17 Oct 1999 13:52:01 -0700

(( Whoops! We were so busy this past week that we forgot to post another
POW. Since this one's going out on the weekend, I'll make it *really*
easy. ))

The spelling dialog is lonely. :-(

Justin implemented it under the Edit menu, because even though it belongs
under the Tools menu, we didn't have anything else to put there. Having it
all by itself there looks silly, and we didn't have any other working
dialogs to go under the Tools menu.

So as a quick and easy POW, we're looking for someone to create and hook up
a Word Count dialog, and stick it under a new Tools menu along with the
Justin's Spelling dialog and the Options dialog that Stephen Hack is
currently working on.

To complete this POW, you need to go through the same steps as you would for
adding any new dialog. Shaw's already given an in-depth overview of this
process for a previous POW:


Specific steps for this dialog:
1. Unlike the other unimplemented dialogs in AbiWord, this one doesn't even
have a placeholder menu item, so you'll need to do that first. Begin by
stubbing a new dlgWordCount edit method:


See the current stub for another unimplemented dialog, such as dlgOptions,
for ideas on how to do this.

Then add a new top-level Tools menu between the Format and Window menus, with
three submenus as follows (forgive the ASCII art):

&Word Count

To do so, you'll need to update the usual set of menu files:


While you're at it, you may want to rename the AP_MENU_ID_EDIT_ constants
for the spelling and options menu items. If so, be sure to locate all
instances across the tree.

2. Do the dialog work for both XP code and the platform of your choice.
A screenshot of Microsoft Word 97's dialog can be found at


This is a very simple dialog, with a minimal amount of platform-specific
logic. If you do your job right in XP code, and stub out the other platform
implementations, it should be trivial for the other platforms to add
matching implementations.

3. Add an API call into FV_View to perform the relevant counts. You'll
need to walk through the document counting various kinds of data, with the
following caveats:

- header and footer sections should never be counted
- don't count UCS_TAB, UCS_LF, UCS_VTAB, UCS_FF, UCS_CR as characters

There may be other characters to skip. If so, make sure you add definitions
for the appropriate constants to:


One final hint -- make sure that you only count a paragraph once, even if it
gets divided across multiple columns or pages.

4. Update your dlgWordCount edit method to hook everything together and
you're done!



PS: For more background on the whole POW / ZAP / SHAZAM concept, see the
following introduction:


This archive was generated by hypermail 1.03b2.