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.

145 lines
5.5 KiB

  1. #ifndef _SELWORD_H
  2. #define _SELWORD_H
  3. #include "sapilayr.h"
  4. typedef struct _SearchRun
  5. {
  6. ULONG ulStart;
  7. ULONG ulEnd;
  8. BOOL fStartToEnd;
  9. } SEARCHRUN;
  10. typedef enum
  11. {
  12. SearchRun_Selection = 0,
  13. SearchRun_LargeSelection = 1,
  14. SearchRun_BeforeSelection = 2,
  15. SearchRun_AfterSelection = 3,
  16. SearchRun_MaxRuns = 4
  17. } Search_Run_Id;
  18. class CSearchString
  19. {
  20. public:
  21. CSearchString( );
  22. ~CSearchString( );
  23. HRESULT Initialize(WCHAR *SrchStr, WCHAR *SrchFromStr, LANGID langid, ULONG ulSelStartOff, ULONG ulSelLen);
  24. BOOL Search(ULONG *pulOffset, ULONG *pulSelSize=NULL);
  25. private:
  26. BOOL _SearchOneRun(Search_Run_Id idSearchRun);
  27. BOOL _InitSearchRun(ULONG ulSelStartOff, ULONG ulSelLen);
  28. void _SetRun(Search_Run_Id idSearchRun, ULONG ulStart, ULONG ulEnd, BOOL fStartToEnd);
  29. CSpDynamicString m_dstrTextToSrch;
  30. LANGID m_langid;
  31. WCHAR *m_pwszTextSrchFrom;
  32. ULONG m_ulSrchLen;
  33. ULONG m_ulSrchFromLen;
  34. SEARCHRUN m_pSearchRun[SearchRun_MaxRuns];
  35. BOOL m_fInitialized;
  36. ULONG m_ulFoundOffset; // Offset in m_pwszTextSrchFrom that matches SearchStr.
  37. };
  38. class CSapiIMX;
  39. class CSpTask;
  40. typedef enum
  41. {
  42. SELECTWORD_NONE = 0,
  43. SELECTWORD_SELECT = 1,
  44. SELECTWORD_DELETE = 2,
  45. SELECTWORD_INSERTBEFORE = 3,
  46. SELECTWORD_INSERTAFTER = 4,
  47. SELECTWORD_CORRECT = 5,
  48. SELECTWORD_SELTHROUGH = 6, // Select xxx through yyy
  49. SELECTWORD_DELTHROUGH = 7, // Delete xxx through yyy
  50. SELECTWORD_MAXTEXTBUFF = 11,
  51. SELECTWORD_UNSELECT = 11,
  52. SELECTWORD_SELECTPREV = 12, // Select previous phrase.
  53. SELECTWORD_SELECTNEXT = 13, // Select next phrase.
  54. SELECTWORD_CORRECTPREV = 14, // Correct previous phrase.
  55. SELECTWORD_CORRECTNEXT = 15, // Correct next phrase.
  56. SELECTWORD_GOTOBOTTOM = 16, // Go To Bottom
  57. SELECTWORD_GOTOTOP = 17, // Go To Top
  58. SELECTWORD_SELSENTENCE = 18, // Select Sentence
  59. SELECTWORD_SELPARAGRAPH = 19, // Select Paragraph
  60. SELECTWORD_SELWORD = 20, // Select Word
  61. SELECTWORD_SELTHAT = 21, // Select That
  62. SELECTWORD_MAXCMDID = 100
  63. } SELECTWORD_OPERATION;
  64. class __declspec(novtable) CSelectWord
  65. {
  66. public:
  67. CSelectWord(CSapiIMX *psi);
  68. virtual ~CSelectWord( );
  69. HRESULT ProcessSelectWord(WCHAR *pwszSelectedWord, ULONG ulLen, SELECTWORD_OPERATION m_sw_type, ULONG ulLenXXX = 0);
  70. HRESULT _HandleSelectWord(TfEditCookie ec,ITfContext *pic,WCHAR *pwszSelectedWord, ULONG ulLen, SELECTWORD_OPERATION m_sw_type, ULONG ulLenXXX = 0);
  71. HRESULT UpdateTextBuffer(ISpRecoContext *pRecoCtxt, ISpRecoGrammar *pCmdGrammar);
  72. HRESULT _UpdateTextBuffer(TfEditCookie ec,ITfContext *pic, ISpRecoContext *pRecoCtxt, ISpRecoGrammar *pCmdGrammar);
  73. HRESULT _GetPrevOrNextPhrase(TfEditCookie ec,ITfContext *pic, BOOL fPrev, ITfRange **ppRangeOut);
  74. HRESULT _ShiftComplete(TfEditCookie ec, ITfRange *pRange, LONG cchLenToShift, BOOL fStart);
  75. HRESULT _GetActiveViewRange(TfEditCookie ec, ITfContext *pic, ITfRange **ppRangeView);
  76. private:
  77. HRESULT _SelectWord(TfEditCookie ec,ITfContext *pic);
  78. HRESULT _DeleteWord(TfEditCookie ec,ITfContext *pic);
  79. HRESULT _InsertAfterWord(TfEditCookie ec,ITfContext *pic);
  80. HRESULT _InsertBeforeWord(TfEditCookie ec,ITfContext *pic);
  81. HRESULT _SelectThrough(TfEditCookie ec, ITfContext *pic, WCHAR *pwszText, ULONG ulLen, ULONG ulLenXXX);
  82. HRESULT _DeleteThrough(TfEditCookie ec, ITfContext *pic, WCHAR *pwszText, ULONG ulLen, ULONG ulLenXXX);
  83. HRESULT _GetThroughRange(TfEditCookie ec, ITfContext *pic, WCHAR *pwszText, ULONG ulLen, ULONG ulLenXXX, ITfRange **ppRange);
  84. HRESULT _GetTextAndSelectInCurrentView(TfEditCookie ec,ITfContext *pic, ULONG *pulOffSelStart=NULL, ULONG *pulSelLen=NULL);
  85. HRESULT _FindSelect(TfEditCookie ec, ITfContext *pic, BOOL *fFound);
  86. HRESULT _GetCUASCompositionRange(TfEditCookie ec, ITfContext *pic, ITfRange **ppRangeView);
  87. HRESULT _GetTextFromRange(TfEditCookie ec, ITfRange *pRange, CSpDynamicString &dstr);
  88. HRESULT _Unselect(TfEditCookie ec,ITfContext *pic);
  89. HRESULT _CorrectWord(TfEditCookie ec,ITfContext *pic);
  90. HRESULT _SelectPrevOrNextPhrase(TfEditCookie ec, ITfContext *pic, BOOL fPrev);
  91. HRESULT _SelectPreviousPhrase(TfEditCookie ec,ITfContext *pic);
  92. HRESULT _SelectNextPhrase(TfEditCookie ec,ITfContext *pic);
  93. HRESULT _SelectThat(TfEditCookie ec,ITfContext *pic);
  94. HRESULT _CorrectPrevOrNextPhrase(TfEditCookie ec,ITfContext *pic, BOOL fPrev);
  95. HRESULT _CorrectNextPhrase(TfEditCookie ec,ITfContext *pic);
  96. HRESULT _CorrectPreviousPhrase(TfEditCookie ec,ITfContext *pic);
  97. HRESULT _GoToBottom(TfEditCookie ec,ITfContext *pic);
  98. HRESULT _GoToTop(TfEditCookie ec,ITfContext *pic);
  99. HRESULT _SelectSpecialText(TfEditCookie ec,ITfContext *pic, SELECTWORD_OPERATION sw_Type);
  100. BOOL _IsSentenceDelimiter(WCHAR wch);
  101. BOOL _IsParagraphDelimiter(WCHAR wch);
  102. BOOL _IsWordDelimiter(WCHAR wch);
  103. CSapiIMX *m_psi;
  104. WCHAR *m_pwszSelectedWord;
  105. ULONG m_ulLenSelected;
  106. CComPtr<ITfRange> m_cpActiveRange;
  107. CComPtr<ITfRange> m_cpSelectRange;
  108. CSpDynamicString m_dstrActiveText;
  109. };
  110. #endif // _SELWORD_H