I am using WPTools 6.08 with Delphi 6 and Addict 3.5. I have everything installed (I believe) properly - spell check and thesaurus both work fine. However I am having an issue getting the spellcheck to ignore WPTools objects included in the SpellIgnoredForObj property - specifically, merge fields.
The merge fields in my system are actually fields from one of several database tables. I create the merge fields using WPTools' InputMergeField command, passing it a calculated fieldname (consisting of the database name, table name, and column name of the merge variable) and the actual column name for the DisplayText parameter.
For example, for a column named ADDR1 in my Patient table, my InputMergeField call looks something like:
InputMergeField('MRG|DB:Client|TBL😛atient|COL:Addr1', 'ADDR1')
Merging works correctly.
However, when I try to use spellcheck, the display text of my merge variable "ADDR1" is flagged as being misspelled. The SpellIgnoredForObj property of the WPTools editor includes the [wpobjMergeField] option.
What else do i need to do to skip these merge fields?
The Ignore option should disable the curly red underline for the field - that part is controlled by WPTools.
The specllcheck itself happens in the Addict unit.
WPSpell will use this code to skip the fields in future - hopefully You find the correct spot to put it in in Addicts unit.
// Skip hidden text and merge fields
while (pos < par.CharCount) and (par.IsWordDelimiter(pos) or IsHidden(par, pos)) do
begin
obj := par.ObjectRef[pos];
if obj<>nil then obj := obj.EndTag;
if (obj<>nil) and
(par.ObjectRef[pos].ObjType in [wpobjMergeField]) then
begin
par := obj.ParentPar;
pos := obj.ParentPosInPar;
end;
inc(pos);
end;
That should be in function TWPToolsControlParser.MoveNext:Boolean;
Okay, I found the spot to insert this code but I have a couple of questions I hope you can assist with.
First, the body of the TWPToolsControlParser.MoveNext is:
function TWPToolsControlParser.MoveNext: Boolean;
begin
{$IFDEF WPTOOLS5}
FEdit.HideSelection;
repeat
Result := FEdit.CPMoveNext;
// we use the WPAT_ParFlag property here (requires WPTools V5.18.5 or later)
// we use the constants WPAT_ParFlag=127; WFLG_NOPROOF = 4;
until (not Result) or ((FEdit.ActiveParagraph.AGetDef (127, 0) and 4) = 0);
{$ELSE}
Result := FEdit.CPMoveNext;
{$ENDIF}
if FUsingEnd and (FEdit.CPPosition > FEnd) then
begin
Result := False;
end;
end;
I believe I should be able to insert your code following the ENDIF directive. However I just want to make sure I am using the proper values.
You used a variable named "pos" in your WHILE loop. I assume this value is the same as FEdit.CPPosition. Correct?
You use an object named "par" in your code. I assume this is the active paragraph, or FEdit.ActiveParagraph. Correct?
The third portion of your WHILE condition is "IsHidden". I can only find two references to anything named IsHidden is all of the source for WPTools. Both are properties of records, TWPPaintExtraParams and TWPFontCacheInput, not methods. Is this something new?
As a further followup, I tried simply commenting out the IsHidden method (not expecting that to be a good idea) and tested the spell check.
The good news: Addict correctly skipped all of my merge fields!
The bad news: Addict now flags EVERYTHING as being mispelled! It seems that all words on a line within a single data block are read without the spaces and analyzed as if they were a single word. :-(
For example, the title of one of my documents is: Writing MTS and COM+ Components in Delphi. Note there is a single space between each word. When I run the spell check before adding the new code, everything is processed properly. However, with the new code Addict reads this sentence as if it was the single word WritingMTSandCOM+ComponentsinDelphi and flags it as being misspelled.
I assume this is because of my commenting out the unknown IsHidden method. Correct?
Sorry to keep bringing this one up, but could you possibly shed some light on exactly what the IsHidden method you reference is? The only IsHidden I have anywhere in your source (I have the Premium edition) is properties of two records.