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.

98 lines
2.3 KiB

  1. // AttrLoc.cpp : Implementation of CMLStrAttrLocale
  2. #include "private.h"
  3. #ifdef NEWMLSTR
  4. #include "attrloc.h"
  5. /////////////////////////////////////////////////////////////////////////////
  6. // CMLStrAttrLocale
  7. CMLStrAttrLocale::CMLStrAttrLocale() :
  8. m_lLen(0),
  9. m_lcid(0)
  10. {
  11. }
  12. STDMETHODIMP CMLStrAttrLocale::SetClient(IUnknown* pUnk)
  13. {
  14. return E_NOTIMPL; // CMLStrAttrLocale::SetClient()
  15. }
  16. STDMETHODIMP CMLStrAttrLocale::GetClient(IUnknown** ppUnk)
  17. {
  18. return E_NOTIMPL; // CMLStrAttrLocale::GetClient()
  19. }
  20. STDMETHODIMP CMLStrAttrLocale::QueryAttr(REFIID riid, LPARAM lParam, IUnknown** ppUnk, long* lConf)
  21. {
  22. return E_NOTIMPL; // CMLStrAttrLocale::QueryAttr()
  23. }
  24. STDMETHODIMP CMLStrAttrLocale::GetAttrInterface(IID* pIID, LPARAM* plParam)
  25. {
  26. return E_NOTIMPL; // CMLStrAttrLocale::GetAttrInterface()
  27. }
  28. STDMETHODIMP CMLStrAttrLocale::SetMLStr(long lDestPos, long lDestLen, IUnknown* pSrcMLStr, long lSrcPos, long lSrcLen)
  29. {
  30. if (pSrcMLStr)
  31. {
  32. return E_NOTIMPL; // CMLStrAttrLocale::SetMLStr()
  33. }
  34. else
  35. {
  36. HRESULT hr = ::RegularizePosLen(m_lLen, &lDestPos, &lDestLen);
  37. m_lLen -= lDestLen;
  38. m_lLen += lSrcLen; // Insert default
  39. return S_OK;
  40. }
  41. }
  42. STDMETHODIMP CMLStrAttrLocale::SetLong(long lDestPos, long lDestLen, long lValue)
  43. {
  44. ASSERT_THIS;
  45. HRESULT hr = ::RegularizePosLen(m_lLen, &lDestPos, &lDestLen);
  46. if (SUCCEEDED(hr) && lDestPos == 0)
  47. m_lcid = (LCID)lValue; // In this version, saves only first locale.
  48. return hr;
  49. }
  50. STDMETHODIMP CMLStrAttrLocale::GetLong(long lSrcPos, long lSrcLen, long* plValue, long* plActualPos, long* plActualLen)
  51. {
  52. ASSERT_THIS;
  53. ASSERT_WRITE_PTR_OR_NULL(plValue);
  54. ASSERT_WRITE_PTR_OR_NULL(plActualPos);
  55. ASSERT_WRITE_PTR_OR_NULL(plActualLen);
  56. HRESULT hr = ::RegularizePosLen(m_lLen, &lSrcPos, &lSrcLen);
  57. if (SUCCEEDED(hr))
  58. {
  59. if (plValue)
  60. *plValue = (long)m_lcid;
  61. if (plActualPos)
  62. *plActualPos = lSrcPos;
  63. if (plActualLen)
  64. *plActualLen = lSrcLen;
  65. }
  66. else
  67. {
  68. if (plValue)
  69. *plValue = 0;
  70. if (plActualPos)
  71. *plActualPos = 0;
  72. if (plActualLen)
  73. *plActualLen = 0;
  74. }
  75. return hr;
  76. }
  77. #endif // NEWMLSTR