Source code of Windows XP (NT5)
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.

189 lines
8.3 KiB

  1. // MLMain.h : Declaration of the CMultiLanguage
  2. #ifndef __MLMAIN_H_
  3. #define __MLMAIN_H_
  4. #include "mlflink.h"
  5. #include "mllbcons.h"
  6. /////////////////////////////////////////////////////////////////////////////
  7. // CMultiLanguage
  8. class ATL_NO_VTABLE CMultiLanguage :
  9. public CComObjectRoot,
  10. public CComCoClass<CMultiLanguage, &CLSID_CMultiLanguage>,
  11. public IMultiLanguage
  12. {
  13. MIMECONTF dwMimeSource;
  14. CMimeDatabase *m_pMimeDatabase;
  15. public:
  16. CMultiLanguage(void)
  17. {
  18. DllAddRef();
  19. m_pMimeDatabase = new CMimeDatabase;
  20. dwMimeSource = MIMECONTF_MIME_IE4;
  21. if (m_pMimeDatabase)
  22. m_pMimeDatabase->SetMimeDBSource(MIMECONTF_MIME_IE4);
  23. }
  24. ~CMultiLanguage(void)
  25. {
  26. if (m_pMimeDatabase)
  27. delete m_pMimeDatabase;
  28. DllRelease();
  29. }
  30. DECLARE_NO_REGISTRY()
  31. BEGIN_COM_MAP(CMultiLanguage)
  32. COM_INTERFACE_ENTRY(IMultiLanguage)
  33. COM_INTERFACE_ENTRY_TEAR_OFF(IID_IMLangCodePages, CMLFLink)
  34. COM_INTERFACE_ENTRY_TEAR_OFF(IID_IMLangFontLink, CMLFLink)
  35. COM_INTERFACE_ENTRY_TEAR_OFF(IID_IMLangFontLink2, CMLFLink2)
  36. COM_INTERFACE_ENTRY_TEAR_OFF(IID_IMultiLanguage2, CMultiLanguage2)
  37. COM_INTERFACE_ENTRY_TEAR_OFF(IID_IMLangLineBreakConsole, CMLLBCons)
  38. COM_INTERFACE_ENTRY_TEAR_OFF(IID_IMultiLanguage3, CMultiLanguage2)
  39. END_COM_MAP()
  40. public:
  41. // IMultiLanguage
  42. virtual STDMETHODIMP GetNumberOfCodePageInfo(UINT *pcCodePage);
  43. virtual STDMETHODIMP GetCodePageInfo(UINT uiCodePage, PMIMECPINFO pcpInfo);
  44. virtual STDMETHODIMP GetFamilyCodePage(UINT uiCodePage, UINT *puiFamilyCodePage);
  45. virtual STDMETHODIMP EnumCodePages(DWORD grfFlags, IEnumCodePage **ppEnumCodePage);
  46. virtual STDMETHODIMP GetCharsetInfo(BSTR Charset, PMIMECSETINFO pcsetInfo);
  47. virtual STDMETHODIMP IsConvertible(DWORD dwSrcEncoding, DWORD dwDstEncoding);
  48. virtual STDMETHODIMP ConvertString(LPDWORD lpdwMode, DWORD dwSrcEncoding, DWORD dwDstEncoding, BYTE *pSrcStr, UINT *pcSrcSize, BYTE *pDstStr, UINT *pcDstSize);
  49. virtual STDMETHODIMP ConvertStringToUnicode(LPDWORD lpdwMode, DWORD dwEncoding, CHAR *pSrcStr, UINT *pcSrcSize, WCHAR *pDstStr, UINT *pcDstSize);
  50. virtual STDMETHODIMP ConvertStringFromUnicode(LPDWORD lpdwMode, DWORD dwEncoding, WCHAR *pSrcStr, UINT *pcSrcSize, CHAR *pDstStr, UINT *pcDstSize);
  51. virtual STDMETHODIMP ConvertStringReset(void);
  52. virtual STDMETHODIMP GetRfc1766FromLcid(LCID Locale, BSTR *pbstrRfc1766);
  53. virtual STDMETHODIMP GetLcidFromRfc1766(PLCID pLocale, BSTR bstrRfc1766);
  54. virtual STDMETHODIMP EnumRfc1766(IEnumRfc1766 **ppEnumRfc1766);
  55. virtual STDMETHODIMP GetRfc1766Info(LCID Locale, PRFC1766INFO pRfc1766Info);
  56. virtual STDMETHODIMP CreateConvertCharset(UINT uiSrcCodePage, UINT uiDstCodePage, DWORD dwProperty, IMLangConvertCharset **ppMLangConvertCharset);
  57. };
  58. class ATL_NO_VTABLE CMultiLanguage2 :
  59. public CComTearOffObjectBase<CMultiLanguage>,
  60. public IMultiLanguage3
  61. {
  62. IMultiLanguage * m_pIML;
  63. MIMECONTF dwMimeSource;
  64. CMimeDatabase * m_pMimeDatabase;
  65. public:
  66. DECLARE_NO_REGISTRY()
  67. BEGIN_COM_MAP(CMultiLanguage2)
  68. COM_INTERFACE_ENTRY(IMultiLanguage2)
  69. COM_INTERFACE_ENTRY(IMultiLanguage3)
  70. END_COM_MAP()
  71. CMultiLanguage2(void);
  72. ~CMultiLanguage2(void);
  73. virtual STDMETHODIMP GetNumberOfCodePageInfo(UINT *pcCodePage);
  74. virtual STDMETHODIMP GetCodePageInfo(UINT uiCodePage, LANGID LangId, PMIMECPINFO pcpInfo);
  75. virtual STDMETHODIMP GetFamilyCodePage(UINT uiCodePage, UINT *puiFamilyCodePage);
  76. virtual STDMETHODIMP EnumCodePages(DWORD grfFlags, LANGID LangId, IEnumCodePage **ppEnumCodePage);
  77. virtual STDMETHODIMP GetCharsetInfo(BSTR Charset, PMIMECSETINFO pcsetInfo);
  78. virtual STDMETHODIMP IsConvertible(DWORD dwSrcEncoding, DWORD dwDstEncoding)
  79. {
  80. if (m_pIML)
  81. return m_pIML->IsConvertible(dwSrcEncoding, dwDstEncoding);
  82. else
  83. return E_FAIL;
  84. }
  85. virtual STDMETHODIMP ConvertString(LPDWORD lpdwMode, DWORD dwSrcEncoding, DWORD dwDstEncoding, BYTE *pSrcStr, UINT *pcSrcSize, BYTE *pDstStr, UINT *pcDstSize)
  86. {
  87. if (m_pIML)
  88. return m_pIML->ConvertString(lpdwMode, dwSrcEncoding, dwDstEncoding, pSrcStr, pcSrcSize, pDstStr, pcDstSize);
  89. else
  90. return E_FAIL;
  91. }
  92. virtual STDMETHODIMP ConvertStringToUnicode(LPDWORD lpdwMode, DWORD dwEncoding, CHAR *pSrcStr, UINT *pcSrcSize, WCHAR *pDstStr, UINT *pcDstSize)
  93. {
  94. if (m_pIML)
  95. return m_pIML->ConvertStringToUnicode(lpdwMode, dwEncoding, pSrcStr, pcSrcSize, pDstStr, pcDstSize);
  96. else
  97. return E_FAIL;
  98. }
  99. virtual STDMETHODIMP ConvertStringFromUnicode(LPDWORD lpdwMode, DWORD dwEncoding, WCHAR *pSrcStr, UINT *pcSrcSize, CHAR *pDstStr, UINT *pcDstSize)
  100. {
  101. if (m_pIML)
  102. return m_pIML->ConvertStringFromUnicode(lpdwMode, dwEncoding, pSrcStr, pcSrcSize, pDstStr, pcDstSize);
  103. else
  104. return E_FAIL;
  105. }
  106. virtual STDMETHODIMP ConvertStringReset(void)
  107. {
  108. if (m_pIML)
  109. return m_pIML->ConvertStringReset();
  110. else
  111. return E_FAIL;
  112. }
  113. virtual STDMETHODIMP GetRfc1766FromLcid(LCID Locale, BSTR *pbstrRfc1766)
  114. {
  115. if (m_pIML)
  116. return m_pIML->GetRfc1766FromLcid(Locale, pbstrRfc1766);
  117. else
  118. return E_FAIL;
  119. }
  120. virtual STDMETHODIMP GetLcidFromRfc1766(PLCID pLocale, BSTR bstrRfc1766)
  121. {
  122. if (m_pIML)
  123. return m_pIML->GetLcidFromRfc1766(pLocale, bstrRfc1766);
  124. else
  125. return E_FAIL;
  126. }
  127. virtual STDMETHODIMP EnumRfc1766(LANGID LangId, IEnumRfc1766 **ppEnumRfc1766);
  128. virtual STDMETHODIMP GetRfc1766Info(LCID Locale, LANGID LangId, PRFC1766INFO pRfc1766Info);
  129. virtual STDMETHODIMP CreateConvertCharset(UINT uiSrcCodePage, UINT uiDstCodePage, DWORD dwProperty, IMLangConvertCharset **ppMLangConvertCharset)
  130. {
  131. if (m_pIML)
  132. return m_pIML->CreateConvertCharset(uiSrcCodePage, uiDstCodePage, dwProperty, ppMLangConvertCharset);
  133. else
  134. return E_FAIL;
  135. }
  136. virtual STDMETHODIMP ConvertStringInIStream(LPDWORD lpdwMode, DWORD dwFlag, WCHAR *lpFallBack, DWORD dwSrcEncoding, DWORD dwDstEncoding, IStream *pstmIn, IStream *pstmOut);
  137. virtual STDMETHODIMP ConvertStringToUnicodeEx(LPDWORD lpdwMode, DWORD dwEncoding, CHAR *pSrcStr, UINT *pcSrcSize, WCHAR *pDstStr, UINT *pcDstSize, DWORD dwFlag=0, WCHAR *lpFallBack = NULL);
  138. virtual STDMETHODIMP ConvertStringFromUnicodeEx(LPDWORD lpdwMode, DWORD dwEncoding, WCHAR *pSrcStr, UINT *pcSrcSize, CHAR *pDstStr, UINT *pcDstSize, DWORD dwFlag=0, WCHAR *lpFallBack = NULL);
  139. virtual STDMETHODIMP DetectCodepageInIStream(DWORD dwFlag, DWORD uiPrefWinCodepage, IStream *pstmIn, DetectEncodingInfo *lpEncoding, INT *pnScores);
  140. virtual STDMETHODIMP DetectInputCodepage(DWORD dwFlag, DWORD uiPrefWinCodepage, CHAR *pSrcStr, INT *pcSrcSize, DetectEncodingInfo *lpEncoding, INT *pnScores);
  141. virtual STDMETHODIMP ValidateCodePage(UINT uiCodePage, HWND hwnd);
  142. virtual STDMETHODIMP GetCodePageDescription(UINT uiCodePage, LCID lcid, LPWSTR lpWideCharStr, int cchWideChar);
  143. virtual STDMETHODIMP IsCodePageInstallable(UINT uiCodePage);
  144. virtual STDMETHODIMP SetMimeDBSource(MIMECONTF dwSource);
  145. virtual STDMETHODIMP GetNumberOfScripts(UINT *pnScripts);
  146. virtual STDMETHODIMP EnumScripts(DWORD dwFlags, LANGID LangId, IEnumScript **ppEnumScript);
  147. virtual STDMETHODIMP ValidateCodePageEx(UINT uiCodePage, HWND hwnd, DWORD dwfIODControl);
  148. virtual STDMETHODIMP DetectOutboundCodePage(DWORD dwFlags, LPCWSTR lpWideCharStr, UINT cchWideChar, UINT* puiPreferredCodePages, UINT nPreferredCodePages, UINT* puiDetectedCodePages, UINT* pnDetectedCodePages, WCHAR* lpSpecialChar);
  149. virtual STDMETHODIMP DetectOutboundCodePageInIStream(DWORD dwFlags, IStream* pStrIn, UINT* puiPreferredCodePages, UINT nPreferredCodePages, UINT* puiDetectedCodePages, UINT* pnDetectedCodePages, WCHAR* lpSpecialChar);
  150. protected:
  151. HRESULT EnsureIEStatus(void);
  152. class CIEStatus
  153. {
  154. public:
  155. CIEStatus(void) { _IEFlags.fJITDisabled = FALSE;}
  156. HRESULT Init(void);
  157. BOOL IsJITEnabled(void)
  158. {
  159. return !_IEFlags.fJITDisabled;
  160. }
  161. protected:
  162. struct {
  163. BOOL fJITDisabled:1;
  164. } _IEFlags;
  165. };
  166. CIEStatus *m_pIEStat;
  167. };
  168. #endif //__MLMAIN_H_