Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

384 lines
19 KiB

  1. /********************************************************************
  2. spellAPI.h - API definitions for CSAPI, the Speller
  3. You are not entitled to any support or assistance from Microsoft Corporation
  4. regarding your use of the documentation, this C-header file, or any sample source
  5. code associated with the Common Speller Application Programming Interface (CSAPI).
  6. We regret that Microsoft is unable to support or
  7. assist you should you have problems using these files.
  8. To use the CSAPI (including without limitation, the documentation,
  9. C-header file, and any sample source code), you must have executed the
  10. CSAPI end user license agreement (EULA),
  11. available through Microsoft.
  12. IF YOU HAVE NOT SIGNED THE CSAPI EULA,
  13. YOU ARE NOT AUTHORIZED TO USE THE CSAPI.
  14. Version 3.0 - all api's
  15. History:
  16. 5/97 DougP Created
  17. 11/97 DougP This separate speller part
  18. The Natural Language Group maintains this file.
  19. 1997 Microsoft Corporation
  20. ********************************************************************/
  21. #if !defined(SPELLAPI_H)
  22. #define SPELLAPI_H
  23. /**********************************************************
  24. The Speller, Hyphenator, and Thesaurus share 7 functions.
  25. The prototypes, etc. for these functions are in ProofBase.h
  26. **********************************************************/
  27. #if !defined(PROOFBASE_H)
  28. #include "ProofBse.h"
  29. #endif
  30. /*************************************************************
  31. PART 1 - Structure Defs
  32. **************************************************************/
  33. #pragma pack(push, proofapi_h, 8) // default alignment
  34. // eliminate Wizard Special Characters */
  35. /* all this array are well defined Unicode (and Latin-1) characters. */
  36. typedef PROOFPARAMS SpellerParams; // spm
  37. typedef DWORD SpellerState; // sstate
  38. STRUCTUREBEGIN(WSIB) /* Spell Input Buffer - sib */
  39. const WCHAR *pwsz; /* Ptr to buffer of text to be processed */
  40. PROOFLEX *prglex; /* List of dicts to use */
  41. size_t cch; /* Count of characters in pwsz */
  42. size_t clex; /* Count of dicts specified in prglex */
  43. /* State relative to prev. SpellerCheck call */
  44. SpellerState sstate; // sstate
  45. DWORD ichStart; /* position in pwsz to start (New) */
  46. size_t cchUse; /* count of characters in pwsz to consider (New) */
  47. STRUCTUREEND2(WSIB, ichStart(0), sstate(0))
  48. typedef enum { /* Spell Check Return Status */
  49. sstatNoErrors, /* All buffer processed. */
  50. sstatUnknownInputWord, /* Unknown word. */
  51. sstatReturningChangeAlways, /* Returning a Change Always word in SRB. */
  52. sstatReturningChangeOnce, /* Returning a Change Once word in SRB. */
  53. sstatInvalidHyphenation, /* obsolete - Error in hyphenation point.*/
  54. sstatErrorCapitalization, /* Cap pattern not valid. */
  55. sstatWordConsideredAbbreviation, /* Word is considered an abbreviation. */
  56. sstatHyphChangesSpelling, /* obsolete - Word changes spelling when not hyphenated. */
  57. sstatNoMoreSuggestions, /* All methods used. */
  58. sstatMoreInfoThanBufferCouldHold, /* More suggestions than could fit in SRB. */
  59. sstatNoSentenceStartCap, /* obsolete - Start of sentence was not capitalized. */
  60. sstatRepeatWord, /* Repeat word found. */
  61. sstatExtraSpaces, /* obsolete - Too many spaces for context.*/
  62. sstatMissingSpace, /* obsolete - Too few space(s) between words or sentences. */
  63. sstatInitialNumeral, /* Word starts with numeral & sobitFlagInitialNumeral set */
  64. sstatNoErrorsUDHit, /* obsolete - No errors, but at least 1 word found in user dicts */
  65. sstatReturningAutoReplace, /* Returning an AutoReplace suggestion in WSRB */
  66. sstatErrorAccent, /* accents not valid - returns correctly accented word */
  67. } SPELLERSTATUS; // sstat
  68. typedef struct {
  69. WCHAR *pwsz; // pointer to the suggestion (in pwsz)
  70. DWORD ichSugg; // position in input buffer corresponding to suggestion
  71. DWORD cchSugg; // length in input buffer corresponding to suggestion
  72. DWORD iRating; // rating value of this suggestion (0 - 255)
  73. } SPELLERSUGGESTION; // sugg
  74. STRUCTUREBEGIN(WSRB) /* Spell Return Buffer - srb */
  75. WCHAR *pwsz; /* Ptr to suggestion buffer.
  76. Format: word\0word\0...word\0\0 */
  77. SPELLERSUGGESTION *prgsugg; // ptr to array of suggestions (see above)
  78. DWORD ichError; /* Position of verif. error in SIB */
  79. DWORD cchError; /* Length of verif. error in SIB.*/
  80. DWORD ichProcess; /* position where processing began */
  81. DWORD cchProcess; /* length of processed region */
  82. SPELLERSTATUS sstat; /* Spell check return status */
  83. DWORD csz; /* Count of wsz's in pwsz
  84. can be greater than cszAlloc,
  85. in which case you got sstatMoreInfoThanBufferCouldHold */
  86. DWORD cszAlloc; /* number of entries allocated in pSuggestion
  87. (set by App) */
  88. DWORD cchMac; /* Current chars used in pwsz (incl all trailing nulls) */
  89. DWORD cchAlloc; /* Size in chars of pwsz (Set by App) */
  90. STRUCTUREEND2(WSRB, pwsz(0), prgsugg(0))
  91. // for a null response (no returns), csz=0, cchMac=1 (for the trailing null)
  92. // and *pwsz = L'\0'. To be really safe, pwsz[1] = L'\0' as well
  93. /*
  94. Client typically allocates arrays for pwsz and rgSuggestion:
  95. #define MAXSUGGBUFF 512
  96. #define MAXSUGG 20
  97. SPELLERSUGGESTION rgsugg[MAXSUGG];
  98. WCHAR SuggestionBuffer[MAXSUGGBUF];
  99. WSRB srb;
  100. srb.pwsz = SuggestionBuffer;
  101. srb.prgsugg = rgsugg;
  102. srb.cszAlloc = MAXSUGG;
  103. srb.cchAlloc = MAXSUGGBUFF;
  104. Now the return buffer is ready to receive suggestions lists. The list
  105. comes back as a list of null terminated strings in pwsz. It also comes
  106. back in the array that rgSugg points to. rgSugg also contains information
  107. for each suggestion as to the area of the input buffer that the suggestion
  108. applies to.
  109. */
  110. // rating guidelines - these guidelines apply to both the AutoReplaceThreshold
  111. // and the ratings optionally returned in the WSRB
  112. // These give clients guidelines for setting the AutoReplace Threshold
  113. // Spellers can deviate from these guidelines as appropriate for a language.
  114. enum
  115. {
  116. SpellerRatingNone =256, // this rating is so high it turns off all AutoReplace
  117. SpellerRatingCapit =255, // capitalization and accent errors
  118. SpellerRatingDropDoubleConsonant =255-13, // dropped one of a doubled consonant
  119. SpellerRatingDropDoubleVowel =255-15, // dropped one of a doubled vowel
  120. SpellerRatingAddDoubleConsonant =255-13, // doubled a consonant
  121. SpellerRatingAddDoubleVowel =255-15, // doubled a vowel
  122. SpellerRatingTransposeVowel =255-14, // transposed vowels
  123. SpellerRatingTransposeConsonant =255-17, // transposed consonants
  124. SpellerRatingTranspose =255-18, // other transpositions
  125. SpellerRatingSubstituteVowel =255-20, // substitute vowels
  126. SpellerRatingDrop =255-30, // drop a letter
  127. SpellerRatingSubstituteConsonant =255-40, // substitute Consonants
  128. SpellerRatingAdd =255-34, // add a letter
  129. SpellerRatingSubstitute =255-42, // other substitutions
  130. };
  131. /*************************************************************
  132. PART 2 - Function Defs
  133. **************************************************************/
  134. #if defined(__cplusplus)
  135. extern "C" {
  136. #endif
  137. /* -------------- Speller Section --------------
  138. --------------------------------------------- */
  139. //PTEC WINAPI SpellerVersion(PROOFINFO *pinfo);
  140. //PTEC WINAPI SpellerInit(PROOFID *psid, const SpellerParams *pspm);
  141. //PTEC WINAPI SpellerTerminate(PROOFID sid, BOOL fForce);
  142. enum {
  143. sobitSuggestFromUserLex = 0x00000001L, /* Suggest from user dictionaries. */
  144. sobitIgnoreAllCaps = 0x00000002L, /* Ignore words in all UPPERCASE. */
  145. sobitIgnoreMixedDigits = 0x00000004L, /* Ignore words with any numbers in it. */
  146. sobitIgnoreRomanNumerals = 0x00000008L, /* Ignore words composed of all roman numerals. */
  147. sobitFindRepeatWord = 0x00000040L, /* Flag repeated words. */
  148. sobitRateSuggestions = 0x00000400L, /* Rate the suggestions on scale
  149. * of 1-255, 255 being most likely
  150. */
  151. sobitFindInitialNumerals = 0x00000800L, /* Flag words starting with number(s) */
  152. sobitSglStepSugg = 0x00010000L, /* Break after each suggestion task for faster
  153. * return of control to the application.
  154. */
  155. sobitIgnoreSingleLetter = 0x00020000L, /* Do not check single letters: e.g., "a)".
  156. */
  157. sobitIgnoreInitialCap = 0x00040000L, /* ignore words with initial letter capped */
  158. sobitLangMode = 0xF0000000L, /* Language Mode mask */
  159. /* Hebrew Language Modes -- (CT only) */
  160. sobitHebrewFullScript = 0x00000000L,
  161. sobitHebrewPartialScript = 0x10000000L,
  162. sobitHebrewMixedScript = 0x20000000L,
  163. sobitHebrewMixedAuthorizedScript = 0x30000000L,
  164. /* French Language Modes -- (HM only) */
  165. sobitFrenchDialectDefault = 0x00000000L,
  166. sobitFrenchUnaccentedUppercase = 0x10000000L,
  167. sobitFrenchAccentedUppercase = 0x20000000L,
  168. /* Russian Language Modes -- (HM only) */
  169. sobitRussianDialectDefault = 0x00000000L,
  170. sobitRussianIE = 0x10000000L,
  171. sobitRussianIO = 0x20000000L,
  172. /* Korean Language Modes */
  173. sobitKoreanNoAuxCombine = 0x10000000L, /* Auxiliary verb and Auxiliary adjective can combine together. */
  174. sobitKoreanNoMissSpellDictSearch = 0x20000000L, /* Search frequently-misspelled-word dictionary. */
  175. sobitKoreanNoCompoundNounProc = 0x40000000L, /* Do not search frequently-misspelled word dictionary */
  176. sobitKoreanDefault = 0, /* Korean default */
  177. /* German Language Modes */
  178. sobitGermanUsePrereform = 0x10000000L, /* use prereform spelling */
  179. };
  180. /* Option Set and Get Codes */
  181. enum {
  182. soselBits, /* Set bit-oriented options (as before). */
  183. soselPossibleBits, /* GetOptions only. The returned value in *piOptRet shows which options can be turned on. */
  184. soselAutoReplace, /* AutoReplaceThreshold (0-255) */
  185. };
  186. typedef DWORD SPELLEROPTIONSELECT; // sosel
  187. //PTEC WINAPI SpellerSetOptions(PROOFID sid, SPELLEROPTIONSELECT sosel, const DWORD iOptVal);
  188. //PTEC WINAPI SpellerGetOptions(PROOFID sid, SPELLEROPTIONSELECT sosel, DWORD *piOptVal);
  189. //PTEC WINAPI SpellerOpenLex(PROOFID sid, const PROOFLEXIN *plxin, PROOFLEXOUT *plxout);
  190. //PTEC WINAPI SpellerCloseLex(PROOFID sid, PROOFLEX lex, BOOL fforce);
  191. /* Flag values for dwSpellState field in Sib. */
  192. enum {
  193. sstateIsContinued = 0x0001,
  194. /* Call is continuing from where last call returned. Must be cleared
  195. * for first call into SpellCheck().
  196. */
  197. sstateStartsSentence = 0x0002,
  198. /* First word in buffer is known to be start of
  199. * sentence/paragraph/document. This is only used if the
  200. * fSibIsContinued bit is not set. It should not be needed if the
  201. * fSibIsContinued bit is being used. If this bit is set during a
  202. * suggestion request, suggestions will be capitalized.
  203. */
  204. sstateIsEditedChange = 0x0004,
  205. /* The run of text represented in the SIB is a change from either
  206. * a change pair (change always or change once) edit, or from a
  207. * user specified change, possibly from a suggestion list presented
  208. * to the user. This text should be checked for repeat word
  209. * problems, and possibly sentence status, but should not be subject
  210. * to subsequent spell verification or change pair substitutions.
  211. * Note that if an app is not using the fSibIsContinued support,
  212. * they do not need to pass in these edited changes, thus bypassing
  213. * the potential problem, and working faster.
  214. */
  215. sstateNoStateInfo = 0x0000,
  216. /* App is responsible for checking for all repeat word and sentence
  217. * punctuation, and avoiding processing loops such as change always
  218. * can=can can.
  219. */
  220. }; /* End of Sib Spell State flag definitions. */
  221. typedef enum {
  222. scmdVerifyBuffer=2,
  223. scmdSuggest,
  224. scmdSuggestMore,
  225. scmdWildcard=6, // no reason to support this
  226. scmdAnagram, // or this
  227. scmdVerifyBufferAutoReplace=10, // Same as VerifyBuffer - but offer AutoReplacements
  228. } SPELLERCOMMAND; // scmd
  229. //PTEC WINAPI SpellerCheck(PROOFID sid, SPELLERCOMMAND scmd, const WSIB *psib, WSRB *psrb);
  230. typedef PTEC (WINAPI *SPELLERCHECK)(PROOFID sid, SPELLERCOMMAND scmd, const WSIB *psib, WSRB *psrb);
  231. /* Add the string referenced in pwszAdd to the specified UDR.
  232. The UDR must be either the built-in UserLex UDR or a
  233. UDR opened with UserLex. */
  234. //PTEC WINAPI SpellerAddUdr(PROOFID sid, PROOFLEX lex, const WCHAR *pwszAdd);
  235. typedef PTEC (WINAPI *SPELLERADDUDR) (PROOFID sid, PROOFLEX lex, const WCHAR *pwszAdd);
  236. /* Add the pair of strings referenced in pwszAdd and pwszChange to the specified UDR.
  237. Since this call can only refer to the built-in ChangeOnce or ChangeAlways UDRs, we need
  238. only specify the type. */
  239. //PTEC WINAPI SpellerAddChangeUdr(PROOFID sid, PROOFLEXTYPE lxt, const WCHAR *pwszAdd, const WCHAR *pwszChange);
  240. typedef PTEC (WINAPI *SPELLERADDCHANGEUDR)(PROOFID sid, PROOFLEXTYPE lxt, const WCHAR *pwszAdd, const WCHAR *pwszChange);
  241. /* Delete the specified word referenced in pwszDel from the
  242. specified user dictionary. If the string is not in dictionary,
  243. the routine still returns success.
  244. If the string found in the specified UDR is the first part
  245. of a change pair entry, then both strings of the change pair
  246. is removed from the word list, i.e., the entire entry is deleted.
  247. The UDR can reference any of the built-in UDR's or a legally
  248. open user dictionary. */
  249. //PTEC WINAPI SpellerDelUdr(PROOFID sid, PROOFLEX lex, const WCHAR *pwszDel);
  250. typedef PTEC (WINAPI *SPELLERDELUDR)(PROOFID sid, PROOFLEX lex, const WCHAR *pwszDel);
  251. /* Completely clears the specified built-in UDR of all entries.
  252. Note that in order to completely purge the built-in UDR's, this
  253. call would have to be made once for each of UserLex,
  254. lxtChangeOnce, and lxtChangeAlways.
  255. Note:
  256. v1 API spellers may not support
  257. SpellerClearUdr for non-built-in dictionary files. This function
  258. allows multiple document spell checks to clear out the built-in
  259. UDR's between documents, without stopping and restarting a spell
  260. session between every document.
  261. */
  262. //PTEC WINAPI SpellerClearUdr(PROOFID sid, PROOFLEX lex);
  263. typedef PTEC (WINAPI *SPELLERCLEARUDR)(PROOFID sid, PROOFLEX lex);
  264. /* Determines the number of entries in any of the opened
  265. user dictionaries, including the built-in dictionaries.
  266. Note that spell pair entries are considered a single entry.
  267. */
  268. //PTEC WINAPI SpellerGetSizeUdr(PROOFID sid, PROOFLEX lex, DWORD *pcWords);
  269. typedef PTEC (WINAPI *SPELLERGETSIZEUDR)(PROOFID sid, PROOFLEX lex, DWORD *pcWords);
  270. /* This function lists the contents of any of the open user
  271. dictionaries, which includes the exclusion or built-in
  272. dictionaries.
  273. The WSRB is filled with null terminated strings (Sz's) from the
  274. specified UDR starting at the entry indexed by the iszStart
  275. parameter until the buffer is full, or until the end of the file
  276. is reached. Note that the buffer in the WSRB is overwritten
  277. from the beginning on each call.
  278. For dictionaries with the ChangeAlways or ChangeOnce property,
  279. the entries are returned in a slightly modified way. Each word
  280. pair entry is stripped of any embedded formatting and divided
  281. into its two parts, and each part is added as a separate Sz
  282. into the WSRB buffer. Therefore, these types of dictionaries
  283. or word lists always yield an even number of Sz strings in the
  284. WSRB buffer, and represents two Sz's strings for every entry
  285. in the list.
  286. When getting all the words from a dictionary, it is important
  287. to remember that SpellerGetSizeUdr finds the number of entries,
  288. while SpellerGetListUdr gives back a count of strings (WSRB.csz)
  289. in the buffer. The only way to know when all the words have been
  290. retrieved is by checking WSRB.sstat. It should contain
  291. SpellRetNoErrors when all words have been returned and
  292. SpellRetMoreInfoThanBufferCouldHold when more words remain.
  293. Although user dictionary entries have embedded formatting to
  294. distinguish their property type, the strings returned in the
  295. WSRB buffer are completely stripped of any formatting or padding,
  296. and are simply terminated as an Sz string.
  297. This routine does not use or reference the ichError or cchError
  298. fields of WSRB, which are used in the SpellerCheck function.
  299. */
  300. //PTEC WINAPI SpellerGetListUdr(PROOFID sid, PROOFLEX lex, DWORD iszStart, WSRB *psrb);
  301. typedef PTEC (WINAPI *SPELLERGETLISTUDR)(PROOFID sid, PROOFLEX lex, DWORD iszStart, WSRB *psrb);
  302. /* Return the UDR id of one of the built-in user dictionarys. */
  303. //PROOFLEX WINAPI SpellerBuiltinUdr(PROOFID sid, PROOFLEXTYPE lxt);
  304. typedef PROOFLEX (WINAPI *SPELLERBUILTINUDR)(PROOFID sid, PROOFLEXTYPE lxt);
  305. // Optional Prototypes for possible static linking (not recommended)
  306. #if defined(WINCE) || defined(PROTOTYPES)
  307. PTEC WINAPI SpellerVersion(PROOFINFO *pInfo);
  308. PTEC WINAPI SpellerInit(PROOFID *pSpellerid, const SpellerParams *pParams);
  309. PTEC WINAPI SpellerTerminate(PROOFID splid, BOOL fForce);
  310. PTEC WINAPI SpellerSetOptions(PROOFID splid, DWORD iOptionSelect, const DWORD iOptVal);
  311. PTEC WINAPI SpellerGetOptions(PROOFID splid, DWORD iOptionSelect, DWORD *piOptVal);
  312. PTEC WINAPI SpellerOpenLex(PROOFID splid, const PROOFLEXIN *plxin, PROOFLEXOUT *plxout);
  313. PTEC WINAPI SpellerCloseLex(PROOFID splid, PROOFLEX lex, BOOL fforce);
  314. PTEC WINAPI SpellerCheck(PROOFID splid, SPELLERCOMMAND iScc, const WSIB *pSib, WSRB *pSrb);
  315. PTEC WINAPI SpellerAddUdr(PROOFID splid, PROOFLEX udr, const WCHAR *pwszAdd);
  316. PTEC WINAPI SpellerAddChangeUdr(PROOFID splid, PROOFLEXTYPE utype, const WCHAR *pwszAdd, const WCHAR *pwszChange);
  317. PTEC WINAPI SpellerDelUdr(PROOFID splid, PROOFLEX udr, const WCHAR *pwszDel);
  318. PTEC WINAPI SpellerClearUdr(PROOFID splid, PROOFLEX udr);
  319. PTEC WINAPI SpellerGetSizeUdr(PROOFID splid, PROOFLEX udr, DWORD *pcWords);
  320. PTEC WINAPI SpellerGetListUdr(PROOFID splid, PROOFLEX udr, DWORD iszStart, WSRB *pSrb);
  321. PROOFLEX WINAPI SpellerBuiltinUdr(PROOFID splid, PROOFLEXTYPE udrtype);
  322. BOOL WINAPI SpellerSetDllName(const WCHAR *pwszDllName, const UINT uCodePage);
  323. #endif
  324. #if defined(__cplusplus)
  325. }
  326. #endif
  327. #pragma pack(pop, proofapi_h) // restore to whatever was before
  328. #endif // SPELLAPI_H