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.

180 lines
4.6 KiB

  1. //
  2. // icpriv.cpp
  3. //
  4. #include "private.h"
  5. #include "korimx.h"
  6. #include "gdata.h"
  7. #include "icpriv.h"
  8. #include "helpers.h"
  9. #include "funcprv.h"
  10. #include "editcb.h"
  11. //+---------------------------------------------------------------------------
  12. //
  13. // IUnknown
  14. //
  15. //----------------------------------------------------------------------------
  16. STDAPI CICPriv::QueryInterface(REFIID riid, void **ppvObj)
  17. {
  18. *ppvObj = NULL;
  19. if (IsEqualIID(riid, IID_IUnknown))
  20. {
  21. *ppvObj = SAFECAST(this, IUnknown *);
  22. }
  23. if (*ppvObj)
  24. {
  25. AddRef();
  26. return S_OK;
  27. }
  28. return E_NOINTERFACE;
  29. }
  30. STDAPI_(ULONG) CICPriv::AddRef()
  31. {
  32. return ++m_cRef;
  33. }
  34. STDAPI_(ULONG) CICPriv::Release()
  35. {
  36. long cr;
  37. cr = --m_cRef;
  38. Assert(cr >= 0);
  39. if (cr == 0)
  40. {
  41. delete this;
  42. }
  43. return cr;
  44. }
  45. //+---------------------------------------------------------------------------
  46. //
  47. // ctor
  48. //
  49. //----------------------------------------------------------------------------
  50. CICPriv::CICPriv()
  51. {
  52. m_fInitialized = fFalse;
  53. m_pimx = NULL;
  54. m_pic = NULL;
  55. m_pActiveCompositon = NULL;
  56. #if 0
  57. m_pActiveRange = NULL;
  58. m_pBackupRange = NULL;
  59. #endif
  60. m_pCompartmentSink = NULL;
  61. m_guidMBias = NULL;
  62. m_fTransaction = fFalse;
  63. m_pMouseSink = NULL;
  64. m_pIP = NULL;
  65. m_fInitializedIPoint = fFalse;
  66. m_cRef = 1;
  67. // initialize Shared memory. If this is only IME in the system
  68. // Shared memory will be created as file mapping object.
  69. //////////////////////////////////////////////////////////////////////
  70. m_pCIMEData = new CIMEData;
  71. Assert(m_pCIMEData != 0);
  72. if (m_pCIMEData)
  73. {
  74. m_pCIMEData->InitImeData();
  75. }
  76. //////////////////////////////////////////////////////////////////////////
  77. // Create All three IME Automata instances
  78. m_rgpHangulAutomata[KL_2BEOLSIK] = new CHangulAutomata2;
  79. Assert(m_rgpHangulAutomata[KL_2BEOLSIK] != NULL);
  80. m_rgpHangulAutomata[KL_3BEOLSIK_390] = new CHangulAutomata3;
  81. Assert(m_rgpHangulAutomata[KL_3BEOLSIK_390] != NULL);
  82. m_rgpHangulAutomata[KL_3BEOLSIK_FINAL] = new CHangulAutomata3Final;
  83. Assert(m_rgpHangulAutomata[KL_3BEOLSIK_FINAL] != NULL);
  84. }
  85. //+---------------------------------------------------------------------------
  86. //
  87. // dtor
  88. //
  89. //----------------------------------------------------------------------------
  90. CICPriv::~CICPriv()
  91. {
  92. if (m_pCIMEData)
  93. {
  94. delete m_pCIMEData;
  95. m_pCIMEData = NULL;
  96. }
  97. // Delete Automata array
  98. for (INT i=0; i<NUM_OF_IME_KL; i++)
  99. {
  100. if (m_rgpHangulAutomata[i])
  101. delete m_rgpHangulAutomata[i];
  102. }
  103. }
  104. #if 0
  105. /*---------------------------------------------------------------------------
  106. CKorIMX::_TextEventCallback
  107. ---------------------------------------------------------------------------*/
  108. HRESULT CICPriv::_TextEventCallback(UINT uCode, VOID *pv, VOID *pvData)
  109. {
  110. CICPriv *picp = (CICPriv*)pv;
  111. CKorIMX *pKorIMX;
  112. CEditSession2 *pes;
  113. ESSTRUCT ess;
  114. ITfContext *pic;
  115. BOOL fInWriteSession;
  116. TESENDEDIT *pTESEndEdit = (TESENDEDIT*)pvData;
  117. IEnumTfRanges *pEnumText = NULL;
  118. HRESULT hr;
  119. static const GUID *rgProperties[] = { &GUID_PROP_TEXTOWNER, &GUID_PROP_LANGID,
  120. &GUID_PROP_ATTRIBUTE, /* &GUID_PROP_READING,*/
  121. &GUID_PROP_MODEBIAS };
  122. if (picp == NULL)
  123. return S_OK;
  124. pKorIMX = picp->GetIMX();
  125. if (pKorIMX == NULL)
  126. return S_OK;
  127. if (uCode != ICF_TEXTDELTA)
  128. return S_OK;
  129. pic = picp->GetIC();
  130. pic->InWriteSession(pKorIMX->GetTID(), &fInWriteSession);
  131. if (fInWriteSession)
  132. return S_OK; // own change.
  133. hr = pTESEndEdit->pEditRecord->GetTextAndPropertyUpdates(0 /*TF_GTP_INCL_TEXT*/, rgProperties, ARRAYSIZE(rgProperties), &pEnumText );
  134. if (FAILED(hr))
  135. return hr;
  136. if (pEnumText == NULL)
  137. return S_OK;
  138. ESStructInit(&ess, ESCB_TEXTEVENT);
  139. ess.pEnumRange = pEnumText;
  140. hr = E_OUTOFMEMORY;
  141. if (pes = new CEditSession2(pic, pKorIMX, &ess, CKorIMX::_EditSessionCallback2))
  142. {
  143. pes->Invoke(ES2_READWRITE | ES2_ASYNC, &hr);
  144. pes->Release();
  145. }
  146. return S_OK;
  147. }
  148. #endif