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.

129 lines
4.2 KiB

  1. #include "priv.h"
  2. #include "ishcut.h"
  3. STDMETHODIMP Intshcut::GetData(FORMATETC *pfmtetc, STGMEDIUM *pstgmed)
  4. {
  5. HRESULT hr;
  6. ZeroMemory(pstgmed, SIZEOF(*pstgmed));
  7. if (pfmtetc->cfFormat == g_cfURL || pfmtetc->cfFormat == g_cfURLW)
  8. hr = TransferUniformResourceLocator(pfmtetc, pstgmed);
  9. else if ((pfmtetc->cfFormat == CF_TEXT) || (pfmtetc->cfFormat == CF_UNICODETEXT))
  10. hr = TransferText(pfmtetc, pstgmed);
  11. else if (pfmtetc->cfFormat == g_cfFileDescA)
  12. hr = TransferFileGroupDescriptorA(pfmtetc, pstgmed);
  13. else if (pfmtetc->cfFormat == g_cfFileDescW)
  14. hr = TransferFileGroupDescriptorW(pfmtetc, pstgmed);
  15. else if (pfmtetc->cfFormat == g_cfFileContents)
  16. hr = TransferFileContents(pfmtetc, pstgmed);
  17. else
  18. hr = DV_E_FORMATETC;
  19. return hr;
  20. }
  21. STDMETHODIMP Intshcut::GetDataHere(FORMATETC *pfmtetc, STGMEDIUM *pstgpmed)
  22. {
  23. return E_NOTIMPL;
  24. }
  25. STDMETHODIMP Intshcut::QueryGetData(FORMATETC *pfmtetc)
  26. {
  27. HRESULT hr;
  28. if ((pfmtetc->cfFormat == g_cfURL) ||
  29. (pfmtetc->cfFormat == g_cfURLW) ||
  30. (pfmtetc->cfFormat == CF_TEXT) ||
  31. (pfmtetc->cfFormat == CF_UNICODETEXT) ||
  32. (pfmtetc->cfFormat == g_cfFileDescA) ||
  33. (pfmtetc->cfFormat == g_cfFileDescW))
  34. {
  35. hr = (pfmtetc->tymed & TYMED_HGLOBAL) ? S_OK : DV_E_TYMED;
  36. }
  37. else if (pfmtetc->cfFormat == g_cfFileContents)
  38. {
  39. if (pfmtetc->dwAspect == DVASPECT_COPY)
  40. hr = (pfmtetc->tymed & TYMED_ISTREAM) ? S_OK : DV_E_TYMED;
  41. else if ((pfmtetc->dwAspect == DVASPECT_CONTENT) ||
  42. (pfmtetc->dwAspect == DVASPECT_LINK))
  43. hr = (pfmtetc->tymed & TYMED_HGLOBAL) ? S_OK : DV_E_TYMED;
  44. else
  45. hr = DV_E_FORMATETC;
  46. }
  47. else
  48. hr = DV_E_FORMATETC;
  49. return hr;
  50. }
  51. STDMETHODIMP Intshcut::GetCanonicalFormatEtc(FORMATETC *pfmtetcIn, FORMATETC *pfmtetcOut)
  52. {
  53. HRESULT hr = QueryGetData(pfmtetcIn);
  54. if (hr == S_OK)
  55. {
  56. *pfmtetcOut = *pfmtetcIn;
  57. if (pfmtetcIn->ptd == NULL)
  58. hr = DATA_S_SAMEFORMATETC;
  59. else
  60. {
  61. pfmtetcIn->ptd = NULL;
  62. ASSERT(hr == S_OK);
  63. }
  64. }
  65. else
  66. ZeroMemory(pfmtetcOut, SIZEOF(*pfmtetcOut));
  67. return hr;
  68. }
  69. STDMETHODIMP Intshcut::SetData(FORMATETC *pfmtetc, STGMEDIUM *pstgmed, BOOL bRelease)
  70. {
  71. return DV_E_FORMATETC;
  72. }
  73. STDMETHODIMP Intshcut::EnumFormatEtc(DWORD dwDirFlags, IEnumFORMATETC **ppiefe)
  74. {
  75. if (dwDirFlags == DATADIR_GET)
  76. {
  77. FORMATETC rgfmtetc[] =
  78. {
  79. // the order here defines the accuarcy of rendering
  80. { g_cfFileContents, NULL, DVASPECT_LINK, 0, TYMED_HGLOBAL },
  81. { g_cfFileDescW, NULL, DVASPECT_LINK, -1, TYMED_HGLOBAL },
  82. { g_cfFileDescA, NULL, DVASPECT_LINK, -1, TYMED_HGLOBAL },
  83. { g_cfFileContents, NULL, DVASPECT_COPY, 0, TYMED_ISTREAM },
  84. { g_cfFileDescW, NULL, DVASPECT_COPY, -1, TYMED_HGLOBAL },
  85. { g_cfFileDescA, NULL, DVASPECT_COPY, -1, TYMED_HGLOBAL },
  86. { g_cfFileContents, NULL, DVASPECT_CONTENT, 0, TYMED_HGLOBAL },
  87. { g_cfFileDescW, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL },
  88. { g_cfFileDescA, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL },
  89. { g_cfURLW, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL },
  90. { CF_UNICODETEXT, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL },
  91. { g_cfURL, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL },
  92. { CF_TEXT, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL },
  93. };
  94. return SHCreateStdEnumFmtEtc(ARRAYSIZE(rgfmtetc), rgfmtetc, ppiefe);
  95. }
  96. *ppiefe = NULL;
  97. return E_NOTIMPL;
  98. }
  99. STDMETHODIMP Intshcut::DAdvise(FORMATETC *pfmtetc, DWORD dwAdviseFlags, IAdviseSink *piadvsink, DWORD *pdwConnection)
  100. {
  101. *pdwConnection = 0;
  102. return OLE_E_ADVISENOTSUPPORTED;
  103. }
  104. STDMETHODIMP Intshcut::DUnadvise( DWORD dwConnection)
  105. {
  106. return OLE_E_ADVISENOTSUPPORTED;
  107. }
  108. STDMETHODIMP Intshcut::EnumDAdvise(IEnumSTATDATA **ppiesd)
  109. {
  110. *ppiesd = NULL;
  111. return OLE_E_ADVISENOTSUPPORTED;
  112. }