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.

149 lines
4.2 KiB

  1. /****************************************************************************
  2. MODEBIAS.CPP : Handling ModeBias. Sync conversion mode with Cicero's ModeBias
  3. History:
  4. 2-JUL-2000 CSLim Created
  5. ****************************************************************************/
  6. #include "private.h"
  7. #include "korimx.h"
  8. #include "immxutil.h"
  9. #include "helpers.h"
  10. /*---------------------------------------------------------------------------
  11. CKorIMX::SyncModeBias
  12. ---------------------------------------------------------------------------*/
  13. BOOL CKorIMX::CheckModeBias(TfEditCookie ec, ITfContext *pic, ITfRange *pSelection)
  14. {
  15. BOOL fChanged = fFalse;
  16. ITfReadOnlyProperty *pProp = NULL;
  17. ITfRange* pRange = NULL;
  18. VARIANT var;
  19. CICPriv* pPriv;
  20. HRESULT hr;
  21. if (pSelection == NULL)
  22. return fFalse;
  23. if (FAILED(hr = pic->GetAppProperty(GUID_PROP_MODEBIAS, &pProp)))
  24. return fFalse;
  25. pRange = pSelection;
  26. QuickVariantInit(&var);
  27. hr = pProp->GetValue(ec, pRange, &var);
  28. pProp->Release();
  29. if (!SUCCEEDED(hr))
  30. goto lEnd;
  31. Assert(var.vt == VT_I4);
  32. if (var.vt != VT_I4)
  33. goto lEnd;
  34. if ((pPriv = GetInputContextPriv(pic)) == NULL)
  35. goto lEnd;
  36. // check if changed
  37. if (pPriv->GetModeBias() != (TfGuidAtom)var.lVal)
  38. {
  39. GUID guidModeBias;
  40. fChanged = TRUE;
  41. // Keep modebias update
  42. pPriv->SetModeBias(var.lVal);
  43. // ISSUE: !!! WARNING !!!
  44. // Yutakas said, Aimm should handle this.
  45. // Kor IME set Open status automatically when conversion mode to Hangul or Full shape.
  46. // GUID_COMPARTMENT_KEYBOARD_OPENCLOSE has higher priority than modebias
  47. GetGUIDFromGUIDATOM(&m_libTLS, (TfGuidAtom)var.lVal, &guidModeBias);
  48. // Multiple bias will bot be allowed.
  49. // GUID_MODEBIAS_NONE == ignore modebias
  50. if (IsEqualGUID(guidModeBias, GUID_MODEBIAS_NONE))
  51. goto lEnd;
  52. // Office 10 #182239
  53. if (IsEqualGUID(guidModeBias, GUID_MODEBIAS_HANGUL))
  54. {
  55. Assert(IsOn(pic) == fTrue);
  56. SetConvMode(pic, TIP_HANGUL_MODE);
  57. goto lEnd;
  58. }
  59. if (IsEqualGUID(guidModeBias, GUID_MODEBIAS_FULLWIDTHHANGUL))
  60. {
  61. Assert(IsOn(pic) == fFalse);
  62. SetConvMode(pic, TIP_HANGUL_MODE | TIP_JUNJA_MODE);
  63. goto lEnd;
  64. }
  65. if (IsEqualGUID(guidModeBias, GUID_MODEBIAS_FULLWIDTHALPHANUMERIC))
  66. {
  67. Assert(IsOn(pic) == fTrue);
  68. SetConvMode(pic, TIP_JUNJA_MODE);
  69. goto lEnd;
  70. }
  71. if (IsEqualGUID(guidModeBias, GUID_MODEBIAS_HALFWIDTHALPHANUMERIC))
  72. {
  73. Assert(IsOn(pic) == fFalse);
  74. SetConvMode(pic, TIP_ALPHANUMERIC_MODE);
  75. goto lEnd;
  76. }
  77. }
  78. lEnd:
  79. VariantClear(&var);
  80. return fChanged;
  81. }
  82. /*---------------------------------------------------------------------------
  83. CKorIMX::InitializeModeBias
  84. ---------------------------------------------------------------------------*/
  85. BOOL CKorIMX::InitializeModeBias(TfEditCookie ec, ITfContext *pic)
  86. {
  87. ITfRange* pSelection;
  88. if (pic == NULL)
  89. return fFalse;
  90. //
  91. // current selection is in the pRangeIP?
  92. //
  93. if (FAILED(GetSelectionSimple(ec, pic, &pSelection)))
  94. return fFalse;
  95. //
  96. // check mode bias
  97. //
  98. CheckModeBias(ec, pic, pSelection);
  99. SafeRelease(pSelection); // release it
  100. return fTrue;
  101. }
  102. /*---------------------------------------------------------------------------
  103. CKorIMX::CheckModeBias
  104. This will submit async call of InitializeModeBias
  105. ---------------------------------------------------------------------------*/
  106. void CKorIMX::CheckModeBias(ITfContext* pic)
  107. {
  108. CEditSession2 *pes;
  109. ESSTRUCT ess;
  110. HRESULT hr;
  111. ESStructInit(&ess, ESCB_INIT_MODEBIAS);
  112. if ((pes = new CEditSession2(pic, this, &ess, _EditSessionCallback2)) != NULL)
  113. {
  114. pes->Invoke(ES2_READONLY | ES2_SYNC, &hr);
  115. pes->Release();
  116. }
  117. }