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.

282 lines
9.9 KiB

  1. /*
  2. * spell.h
  3. *
  4. * Declarations for spelling
  5. *
  6. * Owner:
  7. * v-brakol
  8. * bradk@directeq.com
  9. */
  10. /*
  11. * Capone Specific Definitions for the spelling subsystem
  12. */
  13. #ifndef _SPELL_H
  14. #define _SPELL_H
  15. #include "proofbse.h"
  16. #include "spellapi.h"
  17. #define cchMaxPathName MAX_PATH
  18. #define cchMaxSuggestBuff (2048)
  19. #ifdef BACKGROUNDSPELL
  20. #define MAX_SPELLSTACK (1024)
  21. #endif // BACKGROUNDSPELL
  22. #define sobitStdOptions (sobitFindRepeatWord)
  23. #define cchMaxDicts 64
  24. class CBody;
  25. // Size of current edit block. Leave this a small value for the DEBUG
  26. // version to help track down bugs with inter-buffer processing.
  27. #ifdef DEBUG
  28. #define cchEditBufferMax 512
  29. #else
  30. #define cchEditBufferMax 512
  31. #endif
  32. #define chCRSpell 0x0D
  33. #define chLFSpell 0x0A
  34. #define chHyphen 0x2D
  35. // Scode sources
  36. #define FACILITY_MAIL (0x0100)
  37. #define FACILITY_MAPI (0x0200)
  38. #define FACILITY_WIN (0x0300)
  39. #define FACILITY_MASK (0x0700)
  40. #define MAKE_MAIL_S_SCODE(_str) \
  41. MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_MAIL, (_str))
  42. #define MAKE_MAIL_E_SCODE(_str) \
  43. MAKE_SCODE(SEVERITY_ERROR, FACILITY_MAIL, (_str))
  44. #define MAKE_MAIL_X_SCODE(_str) \
  45. MAKE_SCODE(SEVERITY_ERROR, FACILITY_MAIL, (_str) | CRITICAL_FLAG)
  46. #define MAIL_E_SPELLGENERICSPELL MAKE_MAIL_E_SCODE(idsErrSpellGenericSpell)
  47. #define MAIL_E_SPELLGENERICLOAD MAKE_MAIL_E_SCODE(idsErrSpellGenericLoad)
  48. #define MAIL_E_SPELLMAINDICTLOAD MAKE_MAIL_E_SCODE(idsErrSpellMainDictLoad)
  49. #define MAIL_E_SPELLVERSION MAKE_MAIL_E_SCODE(idsErrSpellVersion)
  50. #define MAIL_E_SPELLUSERDICT MAKE_MAIL_E_SCODE(idsErrSpellUserDict)
  51. #define MAIL_E_SPELLUSERDICTLOAD MAKE_MAIL_E_SCODE(idsErrSpellUserDictLoad)
  52. #define MAIL_E_SPELLUSERDICTOPENRO MAKE_MAIL_E_SCODE(idsErrSpellUserDictOpenRO)
  53. #define MAIL_E_SPELLUSERDICTSAVE MAKE_MAIL_E_SCODE(idsErrSpellUserDictSave)
  54. #define MAIL_E_SPELLUSERDICTWORDLEN MAKE_MAIL_E_SCODE(idsErrSpellUserDictWordLen)
  55. #define MAIL_E_SPELLCACHEWORDLEN MAKE_MAIL_E_SCODE(idsErrSpellCacheWordLen)
  56. #define MAIL_E_SPELLEDIT MAKE_MAIL_E_SCODE(idsErrSpellEdit)
  57. // the order is important
  58. enum
  59. {
  60. SEL,
  61. SELENDDOCEND,
  62. DOCSTARTSELSTART,
  63. STATEMAX
  64. };
  65. /*
  66. * CSApi Function typedefs. Note these are *not* Unicode enabled. Thus need to use
  67. * LPSTR and not LPTSTR.
  68. */
  69. #ifdef BACKGROUNDSPELL
  70. struct CCell
  71. {
  72. IHTMLTxtRange *pTextRange;
  73. ULONG cb;
  74. };
  75. class CSpellStack
  76. {
  77. public:
  78. CSpellStack();
  79. ~CSpellStack();
  80. ULONG AddRef();
  81. ULONG Release();
  82. HRESULT HrGetRange(IHTMLTxtRange **ppTxtRange);
  83. BOOL fEmpty();
  84. HRESULT push(IHTMLTxtRange *pTxtRange);
  85. HRESULT pop();
  86. private:
  87. ULONG m_cRef;
  88. int m_sp; // stack pointer.
  89. CCell m_rgStack[MAX_SPELLSTACK];
  90. };
  91. #endif // BACKGROUNDSPELL
  92. class CSpell :
  93. #ifdef BACKGROUNDSPELL
  94. public IDispatch
  95. #else
  96. public IUnknown
  97. #endif // BACKGROUNDSPELL
  98. {
  99. public:
  100. CSpell(IHTMLDocument2* pDoc, IOleCommandTarget* pParentCmdTarget, DWORD dwSpellOpt);
  101. ~CSpell();
  102. // IUnknown methods
  103. ULONG STDMETHODCALLTYPE AddRef();
  104. ULONG STDMETHODCALLTYPE Release();
  105. HRESULT STDMETHODCALLTYPE QueryInterface(REFIID, LPVOID FAR *);
  106. // IDispatch methods
  107. #ifdef BACKGROUNDSPELL
  108. STDMETHODIMP Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS FAR* pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr);
  109. #endif // BACKGROUNDSPELL
  110. STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR **rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId);
  111. STDMETHODIMP GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo);
  112. STDMETHODIMP GetTypeInfoCount(UINT *pctinfo);
  113. HRESULT HrSpellReset();
  114. HRESULT HrSpellChecking(IHTMLTxtRange *pRangeIgnore, HWND hwndMain, BOOL fSuppressDoneMsg);
  115. HRESULT OnWMCommand(int id, IHTMLTxtRange *pTxtRange);
  116. #ifdef BACKGROUNDSPELL
  117. HRESULT HrHasSquiggle(IHTMLTxtRange *pTxtRange);
  118. #endif // BACKGROUNDSPELL
  119. HRESULT HrInitRanges(IHTMLTxtRange *pRangeIgnore, HWND hwndMain, BOOL fSuppressDoneMsg);
  120. VOID DeInitRanges();
  121. BOOL OpenSpeller();
  122. VOID CloseSpeller();
  123. BOOL OpenUserDictionaries();
  124. BOOL OpenUserDictionary(LPTSTR lpszDict);
  125. HRESULT HrFindErrors();
  126. HRESULT HrReplaceErrorText(BOOL fChangeAll, BOOL fAddToUdr);
  127. HRESULT HrSpellSuggest();
  128. VOID FillSuggestLbx();
  129. BOOL FVerifyThisText(LPSTR szThisText, BOOL fProcessOnly);
  130. VOID SpellSaveUndo(INT idButton);
  131. VOID SpellDoUndo();
  132. #ifdef BACKGROUNDSPELL
  133. HRESULT HrBkgrndSpellTimer();
  134. HRESULT HrBkgrndSpellCheck(IHTMLTxtRange *pTxtRange);
  135. HRESULT HrSetSquiggle(IHTMLTxtRange *pTxtRange);
  136. HRESULT HrDeleteSquiggle(IHTMLTxtRange *pTxtRange);
  137. #endif // BACKGROUNDSPELL
  138. HRESULT HrInsertMenu(HMENU hmenu, IHTMLTxtRange *pTxtRange);
  139. HRESULT HrReplaceBySuggest(IHTMLTxtRange *pTxtRange, INT index);
  140. #ifdef BACKGROUNDSPELL
  141. HRESULT HrRegisterKeyPressNotify(BOOL fRegister);
  142. #endif // BACKGROUNDSPELL
  143. HRESULT AddToUdrW(WCHAR* pwsz, PROOFLEX lex); // [email protected] - can now specify dict index - 53193
  144. HRESULT AddToUdrA(CHAR* psz, PROOFLEX lex); // [email protected] - can now specify dict index - 53193
  145. HRESULT HrCheckWord(LPCSTR pszWord);
  146. BOOL m_fSpellSelection: 1,
  147. m_fUdrReadOnly: 1,
  148. m_fSuggestions: 1,
  149. m_fNoneSuggested: 1,
  150. m_fAlwaysSuggest: 1,
  151. m_fEditWasEmpty: 1,
  152. m_fRepeat: 1,
  153. m_fCanUndo: 1,
  154. m_fUndoChange: 1,
  155. m_fShowDoneMsg: 1,
  156. m_fIgnoreScope: 1,
  157. m_fSpellContinue: 1, // [email protected] - "repeat word" bug fix - 2757, 13573, 56057
  158. m_junk: 3,
  159. m_fCSAPI3T1: 1;
  160. HWND m_hwndDlg; // the spelling dialog using thie SPELLFO structure
  161. TCHAR m_szWrongWord[cchEditBufferMax]; // current misspelled word
  162. TCHAR m_szEdited[cchEditBufferMax]; // current replacement word
  163. WCHAR m_wszIn[cchEditBufferMax];
  164. WCHAR m_wszRet[cchEditBufferMax];
  165. PROOFID m_pid;
  166. WSIB m_wsib;
  167. WSRB m_wsrb;
  168. LANGID m_langid;
  169. DWORD m_clex;
  170. PROOFLEX m_rgprflex[cchMaxDicts];
  171. PROOFVERSION m_pfnSpellerVersion;
  172. PROOFINIT m_pfnSpellerInit;
  173. PROOFTERMINATE m_pfnSpellerTerminate;
  174. PROOFSETOPTIONS m_pfnSpellerSetOptions;
  175. PROOFOPENLEX m_pfnSpellerOpenLex;
  176. PROOFCLOSELEX m_pfnSpellerCloseLex;
  177. SPELLERCHECK m_pfnSpellerCheck;
  178. SPELLERADDUDR m_pfnSpellerAddUdr;
  179. SPELLERBUILTINUDR m_pfnSpellerBuiltInUdr;
  180. SPELLERADDCHANGEUDR m_pfnSpellerAddChangeUdr;
  181. PROOFSETDLLNAME m_pfnSpellerSetDllName;
  182. CHARRANGE m_chrgCurrent; // current selection in edit control
  183. TCHAR m_szErrType[256]; // string describing type of spelling error
  184. TCHAR m_szTempBuffer[256]; // temporary buffer used for LoadString()
  185. TCHAR m_szSuggest[cchMaxSuggestBuff];
  186. IHTMLTxtRange* m_pRangeChecking;// text range currently checked
  187. IHTMLTxtRange* m_pRangeIgnore;// ignore text
  188. private:
  189. ULONG m_cRef;
  190. INT m_State;
  191. IHTMLTxtRange* m_pRangeDocStartSelStart;//from document start to selection start.
  192. IHTMLTxtRange* m_pRangeSel; //from selection start to selection end
  193. IHTMLTxtRange* m_pRangeSelExpand; //from selection start to selection end
  194. IHTMLTxtRange* m_pRangeSelEndDocEnd;// from selection end to document end
  195. IHTMLTxtRange* m_pRangeUndoSave;// from selection end to document end
  196. #ifdef BACKGROUNDSPELL
  197. CSpellStack m_Stack;
  198. #endif // BACKGROUNDSPELL
  199. IHTMLDocument2* m_pDoc;
  200. IOleCommandTarget* m_pParentCmdTarget;
  201. HINSTANCE m_hinstDll; // spell dll
  202. HWND m_hwndNote; // body edit field
  203. LONG m_soCur; // current spelling options.
  204. HRESULT m_hr;
  205. DWORD m_dwOpt;
  206. DWORD m_dwCookieNotify;
  207. IMarkupServices* m_pMarkup;
  208. IHTMLBodyElement* m_pBodyElem;
  209. HRESULT HrGetSel();
  210. HRESULT HrReplaceSel(LPTSTR szWord);
  211. HRESULT HrProcessSpellErrors();
  212. VOID CleanupState();
  213. HRESULT HrCheckRange(IHTMLTxtRange* pRange);
  214. BOOL FIgnore(IHTMLTxtRange* pRangeChecking);
  215. BOOL FIgnoreNumber();
  216. BOOL FIgnoreUpper();
  217. BOOL FIgnoreDBCS();
  218. BOOL FIgnoreProtect();
  219. BOOL FAlwaysSuggest();
  220. BOOL FCheckOnSend();
  221. BOOL FIgnoreURL();
  222. HRESULT HrGetNextWordRange(IHTMLTxtRange* pRange);
  223. HRESULT HrGetText(IHTMLTxtRange* pRange, LPSTR *ppszText);
  224. HRESULT HrGetText(IMarkupPointer* pRangeStart, IMarkupPointer* pRangeEnd, LPSTR *ppszText);
  225. HRESULT HrStripTrailingPeriod(IHTMLTxtRange* pRange, BOOL* pfResult);
  226. HRESULT HrHasWhitespace(IMarkupPointer* pRangeStart, IMarkupPointer* pRangeEnd, BOOL *pfResult);
  227. HRESULT HrUpdateSelection();
  228. HRESULT GetSelection(IHTMLTxtRange **ppRange);
  229. HRESULT HrGetSpaces(LPSTR pszText, INT* pnSpaces);
  230. BOOL LoadOldSpeller();
  231. BOOL LoadNewSpeller();
  232. BOOL GetNewSpellerEngine(LANGID, TCHAR*, DWORD, TCHAR*, DWORD);
  233. UINT GetCodePage();
  234. HRESULT _EnsureInited();
  235. };
  236. INT_PTR CALLBACK SpellingDlgProc(HWND hwndDlg, UINT wMsg, WPARAM wparam, LPARAM lparam);
  237. BOOL SpellingOnCommand(HWND hwndDlg, UINT wMsg, WPARAM wparam, LPARAM lparam);
  238. VOID UpdateEditedFromSuggest(HWND, HWND, HWND);
  239. BOOL FCheckSpellAvail(IOleCommandTarget* pParentCmdTarget);
  240. #endif // _SPELL_H