((  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:

  http://www.abisource.com/mailinglists/abiword-dev/99/October/0009.html

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:

  abi/src/wp/ap/xp/ap_EditMethods.cpp

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):

  &Tools
    &Spelling
    &Word Count
    --------------
    &Options

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

  abi/src/wp/ap/xp/ap_Menu_ActionSet.cpp
  abi/src/wp/ap/xp/ap_Menu_Id.h
  abi/src/wp/ap/xp/ap_Menu_LabelSet_*.h
  abi/src/wp/ap/xp/ap_Menu_Layouts_MainMenu.h

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

  http://www.abisource.com/~paul/wc.gif

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
  - spaces include UCS_SPACE, UCS_NBSP, UCS_EN_SPACE, UCS_EM_SPACE

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

  abi/src/af/util/ut_types.h

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!

Enjoy!

Paul

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

  http://www.abisource.com/mailinglists/abiword-dev/99/September/0097.html

Reply via email to