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.

167 lines
7.2 KiB

  1. #ifndef NEWMLSTR
  2. // MLStrA.h : Declaration of the CMLStrA
  3. #ifndef __MLSTRA_H_
  4. #define __MLSTRA_H_
  5. #include "mlatl.h"
  6. class CMLStr;
  7. /////////////////////////////////////////////////////////////////////////////
  8. // CMLStrA
  9. class ATL_NO_VTABLE CMLStrA :
  10. public CComTearOffObjectBase<CMLStr>,
  11. public IMLangStringAStr
  12. {
  13. typedef CComObject<CMLStr>* POWNER;
  14. public:
  15. #ifdef ASTRIMPL
  16. CMLStrA(void);
  17. #endif
  18. DECLARE_NO_REGISTRY()
  19. BEGIN_COM_MAP(CMLStrA)
  20. COM_INTERFACE_ENTRY(IMLangString)
  21. COM_INTERFACE_ENTRY(IMLangStringAStr)
  22. END_COM_MAP()
  23. public:
  24. // IMLangString
  25. STDMETHOD(Sync)(/*[in]*/ BOOL fNoAccess);
  26. STDMETHOD(GetLength)(/*[out, retval]*/ long* plLen);
  27. STDMETHOD(SetMLStr)(/*[in]*/ long lDestPos, /*[in]*/ long lDestLen, /*[in]*/ IUnknown* pSrcMLStr, /*[in]*/ long lSrcPos, /*[in]*/ long lSrcLen);
  28. STDMETHOD(GetMLStr)(/*[in]*/ long lSrcPos, /*[in]*/ long lSrcLen, /*[in]*/ IUnknown* pUnkOuter, /*[in]*/ DWORD dwClsContext, /*[in]*/ const IID* piid, /*[out]*/ IUnknown** ppDestMLStr, /*[out]*/ long* plDestPos, /*[out]*/ long* plDestLen);
  29. // IMLangStringAStr
  30. STDMETHOD(SetAStr)(/*[in]*/ long lDestPos, /*[in]*/ long lDestLen, /*[in]*/ UINT uCodePage, /*[in, size_is(cchSrc)]*/ const CHAR* pszSrc, /*[in]*/ long cchSrc, /*[out]*/ long* pcchActual, /*[out]*/ long* plActualLen);
  31. STDMETHOD(SetStrBufA)(/*[in]*/ long lDestPos, /*[in]*/ long lDestLen, /*[in]*/ UINT uCodePage, /*[in]*/ IMLangStringBufA* pSrcBuf, /*[out]*/ long* pcchActual, /*[out]*/ long* plActualLen);
  32. STDMETHOD(GetAStr)(/*[in]*/ long lSrcPos, /*[in]*/ long lSrcLen, /*[in]*/ UINT uCodePageIn, /*[out]*/ UINT* puCodePageOut, /*[out, size_is(cchDest)]*/ CHAR* pszDest, /*[in]*/ long cchDest, /*[out]*/ long* pcchActual, /*[out]*/ long* plActualLen);
  33. STDMETHOD(GetStrBufA)(/*[in]*/ long lSrcPos, /*[in]*/ long lSrcMaxLen, /*[out]*/ UINT* puDestCodePage, /*[out]*/ IMLangStringBufA** ppDestBuf, /*[out]*/ long* plDestLen);
  34. STDMETHOD(LockAStr)(/*[in]*/ long lSrcPos, /*[in]*/ long lSrcLen, /*[in]*/ long lFlags, /*[in]*/ UINT uCodePageIn, /*[in]*/ long cchRequest, /*[out]*/ UINT* puCodePageOut, /*[out, size_is(,*pcchDest)]*/ CHAR** ppszDest, /*[out]*/ long* pcchDest, /*[out]*/ long* plDestLen);
  35. STDMETHOD(UnlockAStr)(/*[in, size_is(cchSrc)]*/ const CHAR* pszSrc, /*[in]*/ long cchSrc, /*[out]*/ long* pcchActual, /*[out]*/ long* plActualLen);
  36. STDMETHOD(SetLocale)(/*[in]*/ long lDestPos, /*[in]*/ long lDestLen, /*[in]*/ LCID locale);
  37. STDMETHOD(GetLocale)(/*[in]*/ long lSrcPos, /*[in]*/ long lSrcMaxLen, /*[out]*/ LCID* plocale, /*[out]*/ long* plLocalePos, /*[out]*/ long* plLocaleLen);
  38. protected:
  39. #ifdef ASTRIMPL
  40. ~CMLStrA(void);
  41. #endif
  42. POWNER GetOwner(void) const {return m_pOwner;}
  43. #ifdef ASTRIMPL
  44. HRESULT PrepareMLangCodePages(void)
  45. {
  46. HRESULT hr = S_OK;
  47. if (!m_pMLCPs)
  48. hr = ::CoCreateInstance(CLSID_CMultiLanguage, NULL, CLSCTX_INPROC_SERVER, IID_IMLangCodePages, (void**)&m_pMLCPs);
  49. return hr;
  50. }
  51. IMLangCodePages* GetMLangCodePages(void) const {return m_pMLCPs;}
  52. IMLangCodePages* m_pMLCPs;
  53. #endif
  54. };
  55. #endif //__MLSTRA_H_
  56. #else // NEWMLSTR
  57. // MLStrA.h : Declaration of the CMLStrA
  58. #ifndef __MLSTRA_H_
  59. #define __MLSTRA_H_
  60. #include "mlatl.h"
  61. class CMLStr;
  62. /////////////////////////////////////////////////////////////////////////////
  63. // CMLStrA
  64. class ATL_NO_VTABLE CMLStrA :
  65. public CComTearOffObjectBase<CMLStr>,
  66. public IMLangStringAStr
  67. {
  68. typedef CComObject<CMLStr>* POWNER;
  69. public:
  70. CMLStrA(void);
  71. DECLARE_NO_REGISTRY()
  72. BEGIN_COM_MAP(CMLStrA)
  73. COM_INTERFACE_ENTRY(IMLangString)
  74. COM_INTERFACE_ENTRY(IMLangStringAStr)
  75. END_COM_MAP()
  76. public:
  77. // IMLangString
  78. STDMETHOD(LockMLStr)(/*[in]*/ long lPos, /*[in]*/ long lLen, /*[in]*/ DWORD dwFlags, /*[out]*/ DWORD* pdwCookie, /*[out]*/ long* plActualPos, /*[out]*/ long* plActualLen);
  79. STDMETHOD(UnlockMLStr)(/*[in]*/ DWORD dwCookie);
  80. STDMETHOD(GetLength)(/*[out, retval]*/ long* plLen);
  81. STDMETHOD(SetMLStr)(/*[in]*/ long lDestPos, /*[in]*/ long lDestLen, /*[in]*/ IUnknown* pSrcMLStr, /*[in]*/ long lSrcPos, /*[in]*/ long lSrcLen);
  82. STDMETHOD(RegisterAttr)(/*[in]*/ IUnknown* pUnk, /*[out]*/ DWORD* pdwCookie);
  83. STDMETHOD(UnregisterAttr)(/*[in]*/ DWORD dwCookie);
  84. STDMETHOD(EnumAttr)(/*[out]*/ IEnumUnknown** ppEnumUnk);
  85. STDMETHOD(FindAttr)(/*[in]*/ REFIID riid, /*[in]*/ LPARAM lParam, /*[out]*/ IUnknown** ppUnk);
  86. // IMLangStringAStr
  87. STDMETHOD(SetAStr)(/*[in]*/ long lDestPos, /*[in]*/ long lDestLen, /*[in]*/ UINT uCodePage, /*[in, size_is(cchSrc)]*/ const CHAR* pszSrc, /*[in]*/ long cchSrc, /*[out]*/ long* pcchActual, /*[out]*/ long* plActualLen);
  88. STDMETHOD(SetStrBufA)(/*[in]*/ long lDestPos, /*[in]*/ long lDestLen, /*[in]*/ UINT uCodePage, /*[in]*/ IMLangStringBufA* pSrcBuf, /*[out]*/ long* pcchActual, /*[out]*/ long* plActualLen);
  89. STDMETHOD(GetAStr)(/*[in]*/ long lSrcPos, /*[in]*/ long lSrcLen, /*[in]*/ UINT uCodePageIn, /*[out]*/ UINT* puCodePageOut, /*[out, size_is(cchDest)]*/ CHAR* pszDest, /*[in]*/ long cchDest, /*[out]*/ long* pcchActual, /*[out]*/ long* plActualLen);
  90. STDMETHOD(GetStrBufA)(/*[in]*/ long lSrcPos, /*[in]*/ long lSrcMaxLen, /*[out]*/ UINT* puDestCodePage, /*[out]*/ IMLangStringBufA** ppDestBuf, /*[out]*/ long* plDestLen);
  91. STDMETHOD(LockAStr)(/*[in]*/ long lSrcPos, /*[in]*/ long lSrcLen, /*[in]*/ long lFlags, /*[in]*/ UINT uCodePageIn, /*[in]*/ long cchRequest, /*[out]*/ UINT* puCodePageOut, /*[out, size_is(,*pcchDest)]*/ CHAR** ppszDest, /*[out]*/ long* pcchDest, /*[out]*/ long* plDestLen);
  92. STDMETHOD(UnlockAStr)(/*[in, size_is(cchSrc)]*/ const CHAR* pszSrc, /*[in]*/ long cchSrc, /*[out]*/ long* pcchActual, /*[out]*/ long* plActualLen);
  93. STDMETHOD(SetLocale)(/*[in]*/ long lDestPos, /*[in]*/ long lDestLen, /*[in]*/ LCID locale);
  94. STDMETHOD(GetLocale)(/*[in]*/ long lSrcPos, /*[in]*/ long lSrcMaxLen, /*[out]*/ LCID* plocale, /*[out]*/ long* plLocalePos, /*[out]*/ long* plLocaleLen);
  95. protected:
  96. ~CMLStrA(void);
  97. POWNER GetOwner(void) const {return m_pOwner;}
  98. inline HRESULT GetAttrAStr(IMLStrAttrAStr** ppAttr);
  99. inline HRESULT GetAttrLocale(IMLStrAttrLocale** ppAttr);
  100. HRESULT GetAttrAStrReal(IMLStrAttrAStr** ppAttr);
  101. HRESULT GetAttrLocaleReal(IMLStrAttrLocale** ppAttr);
  102. CRITICAL_SECTION m_cs;
  103. IMLStrAttrAStr* m_pAttrAStr;
  104. IMLStrAttrLocale* m_pAttrLocale;
  105. DWORD m_dwAttrAStrCookie; // Returned by RegisterAttr
  106. DWORD m_dwAttrLocaleCookie; // Returned by RegisterAttr
  107. };
  108. /////////////////////////////////////////////////////////////////////////////
  109. // CMLStrA inline-line functions
  110. HRESULT CMLStrA::GetAttrAStr(IMLStrAttrAStr** ppAttr)
  111. {
  112. if (m_pAttrAStr)
  113. {
  114. if (ppAttr)
  115. *ppAttr = m_pAttrAStr;
  116. return S_OK;
  117. }
  118. else
  119. {
  120. return GetAttrAStrReal(ppAttr);
  121. }
  122. }
  123. HRESULT CMLStrA::GetAttrLocale(IMLStrAttrLocale** ppAttr)
  124. {
  125. if (m_pAttrLocale)
  126. {
  127. if (ppAttr)
  128. *ppAttr = m_pAttrLocale;
  129. return S_OK;
  130. }
  131. else
  132. {
  133. return GetAttrLocaleReal(ppAttr);
  134. }
  135. }
  136. #endif //__MLSTRA_H_
  137. #endif // NEWMLSTR