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.

82 lines
2.6 KiB

  1. //
  2. // LMOBJ.CPP
  3. //
  4. // implements a wrapper for external LM that we use for
  5. // pre-processing SR lattice
  6. //
  7. //
  8. #include "private.h"
  9. #include "globals.h"
  10. #include "sapilayr.h"
  11. #include "fnrecon.h"
  12. //#include "lmobj.h"
  13. //#include "catutil.h"
  14. //
  15. // CMasterLMWrap implementation
  16. //
  17. //+---------------------------------------------------------------------------
  18. //
  19. // CMasterLMWrap::_EnsureMasterLM
  20. //
  21. //----------------------------------------------------------------------------
  22. void CMasterLMWrap::_EnsureMasterLM(LANGID langidRequested)
  23. {
  24. // langidRequested is given based on langid of reconversion range
  25. // m_langidMasterLM is based on the last master LMTIP we worked with
  26. //
  27. if (TRUE == m_fLMInited)
  28. return;
  29. if (!m_psi->_MasterLMEnabled())
  30. return;
  31. if ( !m_cpMasterLM || m_langidMasterLM != langidRequested )
  32. {
  33. m_cpMasterLM.Release();
  34. CComPtr<IEnumGUID> cpEnum;
  35. HRESULT hr = LibEnumItemsInCategory(m_psi->_GetLibTLS(), GUID_TFCAT_TIP_MASTERLM, &cpEnum);
  36. if (S_OK == hr)
  37. {
  38. GUID guidLMTIP;
  39. BOOL fLangOK = FALSE;
  40. while(cpEnum->Next(1, &guidLMTIP, NULL) == S_OK && !fLangOK)
  41. {
  42. ITfFunctionProvider *pFuncPrv = NULL;
  43. // check if the TIP can accomodate the language
  44. Assert(m_psi->_tim);
  45. hr = m_psi->_tim->GetFunctionProvider(guidLMTIP, &pFuncPrv);
  46. if (S_OK == hr)
  47. {
  48. CComPtr<IUnknown> cpunk;
  49. CComPtr<ITfFnLMProcessor> cpLMTIP;
  50. hr = pFuncPrv->GetFunction(GUID_NULL, IID_ITfFnLMProcessor, &cpunk);
  51. if (S_OK == hr)
  52. {
  53. hr = cpunk->QueryInterface(IID_ITfFnLMProcessor, (void **)&cpLMTIP);
  54. }
  55. if (S_OK == hr)
  56. {
  57. hr = cpLMTIP->QueryLangID(langidRequested, &fLangOK);
  58. }
  59. if (fLangOK == TRUE)
  60. {
  61. m_cpMasterLM = cpLMTIP;
  62. m_langidMasterLM = langidRequested;
  63. }
  64. SafeReleaseClear(pFuncPrv);
  65. } // if S_OK == GetFunctionProvider()
  66. } // while next
  67. } // if LibEnumItemsInCategory() == S_OK
  68. m_fLMInited = TRUE;
  69. } // if !m_cpMasterLM
  70. }