Using ISpellCheckCallbacks do to spell check *from code*  SOLVED

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Using ISpellCheckCallbacks do to spell check *from code*

Post by zarkogajic »

Hi Support,

Please shed some light on the usage of ISpellCheckCallbacks.

I'm trying to do some spell checking *from code* - without involving the IPXV_SpellChecker pane, so without the UI part.

After a lot of try-fail hits, I think the following does not work correctly:

1. The CheckWord() method

The CheckWord() method will result in SpellCheckRes_NoLang if the specified LangID is *not* selected in the "Spell Checker Settings" dialog - even though the dictionary does exist and is loaded.

So for example:

nCheckRes = ISpellCheckCallbacks.CheckWord(1033, "spell"); //1033 is en-US

will result in SpellCheckRes_NoLang if the following:

image.png
image.png (14.81 KiB) Viewed 1263 times

But, having the en-us box checked, as in:

image(1).png
image(1).png (8.73 KiB) Viewed 1263 times

The nCheckRes will be SpellCheckRes_OK.

Q1: Is this a bug? Why would a specific locale need to be checked for CheckWord() to work? If so, how to check it from code?

2. The GetLang() method

I would expect the following call (pseudo):

itLangID = GetLang("it-it",...)

would result in 1040 never mind if the IT dictionary (/.oxt) exists and if the Italian language is checked in Checker Settings. But seems it is not the case. Somehow, as with CheckWord, the GetLang is dependent on Checker Settings.

What's even more strange, if "en-us" is selected in Checker Settings, GetLang("it-it",...) would result in 1033 (which is "en-us" - but has nothing to do with "it-it")

Q2: What is then the real purpose of GetLang()?

And one extra:
Q3. The Get_Capabilities() method - what is it for?



To sum up:

I would expect CheckWord(1033, 'spell') to return SpellCheckRes_OK if the dictionary (dict-en.oxt) is loaded, SpellCheckRes_NoLang if not - never mind if the specific language locale is checked in the Checker Settings dialog or not.

How to "check" a specific locale (like en-us) from code - so the above issue gets duck taped?

p.s.
The 1033 = en-us, 1040 = it-it ... Windows LCID values.

-žarko
User avatar
TrackerSupp-Daniel
Site Admin
Posts: 8436
Joined: Wed Jan 03, 2018 6:52 pm

Re: Using ISpellCheckCallbacks do to spell check *from code*

Post by TrackerSupp-Daniel »

Hello, zarkogajic

I had to call in some help from the Dev team for this one, here is what they had to say:
1. CheckWord function depends on loaded dictionaries in SpellChecker plugin so it will return SpellCheckRes_NoLang if dictionary for nLangID was not loaded. Also code like CheckWord(0, "spell") should work - it will try to find best loaded dictionary for word. Dictionaries can be installed or enabled only by UI in SpellChecker plugin settings.

2. GetLang() method will return possible LangID for specified word depending on loaded dictionaries.

3. get_Capabilities will return flags that indicates if SpellChecker can spell (SpellCheck_Spelling) or hyphenate (SpellCheck_Hyphenation) text.
I hope it helps!

Kind regards,
Dan McIntyre - Support Technician
Tracker Software Products (Canada) LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Using ISpellCheckCallbacks do to spell check *from code*

Post by zarkogajic »

Hi Daniel,
CheckWord function depends on loaded dictionaries
I have the dictionary installed/loaded but still CheckWord results in SpellCheckRes_NoLang, because of:
Dictionaries can be installed *or enabled* only by UI
So, how to enable a loaded/installed dictionary from code?

If not possible, how to then call and display the "Spell Checker Settings" dialog from code (and let user enable/disable loaded dictionaries)? Note: I want to avoid using the "spellView" pane - as it is per document - while I need to enable a dictionary in general - not really having ipxv_documents.

image.png

The IPXV_SpellChecker does have ShowPrefs() which I guess displays that dialog. However, I do not know how to get my hands on that interface?


-žarko
User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 2352
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: Using ISpellCheckCallbacks do to spell check *from code*

Post by Vasyl-Tracker Dev Team »

Hi Zarko.

You may use this way:

IPXV_SpellChecker spell = (IPXV_SpellChecker)pxvInst.GetExtension("SpellChecker");

Cheers.
Vasyl Yaremyn
Tracker Software Products
Project Developer

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Using ISpellCheckCallbacks do to spell check *from code*

Post by zarkogajic »

Hi Vasyl,

Thanks!

How about enabling dicts from code? Not possible?

User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 2352
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: Using ISpellCheckCallbacks do to spell check *from code*

Post by Vasyl-Tracker Dev Team »

I'm afraid this is not possible at the moment...
Vasyl Yaremyn
Tracker Software Products
Project Developer

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Using ISpellCheckCallbacks do to spell check *from code*  SOLVED

Post by zarkogajic »

Ok, thanks.


User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17820
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Using ISpellCheckCallbacks do to spell check *from code*

Post by Tracker Supp-Stefan »

:)
Post Reply