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.

306 lines
8.1 KiB

  1. //+-------------------------------------------------------------------
  2. // File: idataobj.cxx
  3. //
  4. // Contents: IDataObject methods of CTestEmbed class.
  5. //
  6. // Classes: CTestEmbed - IDataObject implementation
  7. //
  8. // History: 7-Dec-92 DeanE Created
  9. //---------------------------------------------------------------------
  10. #pragma optimize("",off)
  11. #include <windows.h>
  12. #include <ole2.h>
  13. #include "testsrv.hxx"
  14. //+-------------------------------------------------------------------
  15. // Member: CDataObject::CDataObject()
  16. //
  17. // Synopsis: The constructor for CDataObject.
  18. //
  19. // Arguments: None
  20. //
  21. // History: 7-Dec-92 DeanE Created
  22. //--------------------------------------------------------------------
  23. CDataObject::CDataObject(CTestEmbed *pteObject)
  24. {
  25. _cRef = 1;
  26. _pDAHolder = NULL;
  27. _pteObject = pteObject;
  28. }
  29. //+-------------------------------------------------------------------
  30. // Member: CDataObject::~CDataObject()
  31. //
  32. // Synopsis: The destructor for CDataObject.
  33. //
  34. // History: 7-Dec-92 DeanE Created
  35. //--------------------------------------------------------------------
  36. CDataObject::~CDataObject()
  37. {
  38. // _cRef count should be 1
  39. if (1 != _cRef)
  40. {
  41. // BUGBUG - Log error
  42. // Someone hasn't released one of these - Log error
  43. }
  44. return;
  45. }
  46. //+-------------------------------------------------------------------
  47. // Method: CDataObject::QueryInterface
  48. //
  49. // Synopsis: Forward this to the object we're associated with
  50. //
  51. // Parameters: [iid] - Interface ID to return.
  52. // [ppv] - Pointer to pointer to object.
  53. //
  54. // Returns: S_OK if iid is supported, or E_NOINTERFACE if not.
  55. //
  56. // History: 7-Dec-92 DeanE Created
  57. //--------------------------------------------------------------------
  58. STDMETHODIMP CDataObject::QueryInterface(REFIID iid, void FAR * FAR *ppv)
  59. {
  60. return(_pteObject->QueryInterface(iid, ppv));
  61. }
  62. //+-------------------------------------------------------------------
  63. // Method: CDataObject::AddRef
  64. //
  65. // Synopsis: Forward this to the object we're associated with
  66. //
  67. // Returns: New reference count.
  68. //
  69. // History: 7-Dec-92 DeanE Created
  70. //--------------------------------------------------------------------
  71. STDMETHODIMP_(ULONG) CDataObject::AddRef(void)
  72. {
  73. ++_cRef;
  74. return(_pteObject->AddRef());
  75. }
  76. //+-------------------------------------------------------------------
  77. // Method: CDataObject::Release
  78. //
  79. // Synopsis: Forward this to the object we're associated with
  80. //
  81. // Returns: New reference count.
  82. //
  83. // History: 7-Dec-92 DeanE Created
  84. //--------------------------------------------------------------------
  85. STDMETHODIMP_(ULONG) CDataObject::Release(void)
  86. {
  87. --_cRef;
  88. return(_pteObject->Release());
  89. }
  90. //+-------------------------------------------------------------------
  91. // Method: CDataObject::GetData
  92. //
  93. // Synopsis: See spec 2.00.09 p129. Retrieve data for this object
  94. // using the FORMATETC passed.
  95. //
  96. // Parameters: [pformatetcIn] - The format caller wants returned data
  97. // [pmedium] - Returned data
  98. //
  99. // Returns: S_OK, or E_FORMAT if we don't support the format requested
  100. //
  101. // History: 7-Dec-92 DeanE Created
  102. //--------------------------------------------------------------------
  103. STDMETHODIMP CDataObject::GetData(
  104. LPFORMATETC pformatetcIn,
  105. LPSTGMEDIUM pmedium)
  106. {
  107. // BUGBUG - NYI
  108. return(E_FAIL);
  109. }
  110. //+-------------------------------------------------------------------
  111. // Method: CDataObject::GetDataHere
  112. //
  113. // Synopsis: See spec 2.00.09 p130. Like GetData, but the pmedium is
  114. // allocated and ready for us to use.
  115. //
  116. // Parameters: [pformatetc] - The format caller wants returned data
  117. // [pmedium] - STGMEDIUM object ready for our use
  118. //
  119. // Returns: S_OK, E_FORMAT
  120. //
  121. // History: 7-Dec-92 DeanE Created
  122. //--------------------------------------------------------------------
  123. STDMETHODIMP CDataObject::GetDataHere(
  124. LPFORMATETC pformatetc,
  125. LPSTGMEDIUM pmedium)
  126. {
  127. // BUGBUG - NYI
  128. return(E_FAIL);
  129. }
  130. //+-------------------------------------------------------------------
  131. // Method: CDataObject::QueryGetData
  132. //
  133. // Synopsis: See spec 2.00.09 p130. Answer if the format requested
  134. // would be honored by GetData.
  135. //
  136. // Parameters: [pformatetc] - The format being queried about
  137. //
  138. // Returns: S_OK or S_FALSE
  139. //
  140. // History: 7-Dec-92 DeanE Created
  141. //--------------------------------------------------------------------
  142. STDMETHODIMP CDataObject::QueryGetData(LPFORMATETC pformatetc)
  143. {
  144. // BUGBUG - NYI
  145. return(E_FAIL);
  146. }
  147. //+-------------------------------------------------------------------
  148. // Method: CDataObject::GetCanonicalFormatEtc
  149. //
  150. // Synopsis: See spec 2.00.09 p131
  151. //
  152. // Parameters: [pformatetc] -
  153. // [pformatetcOut] -
  154. //
  155. // Returns: S_OK
  156. //
  157. // History: 7-Dec-92 DeanE Created
  158. //--------------------------------------------------------------------
  159. STDMETHODIMP CDataObject::GetCanonicalFormatEtc(
  160. LPFORMATETC pformatetc,
  161. LPFORMATETC pformatetcOut)
  162. {
  163. // BUGBUG - NYI
  164. return(E_FAIL);
  165. }
  166. //+-------------------------------------------------------------------
  167. // Method: CDataObject::SetData
  168. //
  169. // Synopsis: See spec 2.00.09 p131.
  170. //
  171. // Parameters: [pformatetc] -
  172. // [pmedium] -
  173. // [fRelease] -
  174. //
  175. // Returns: S_OK
  176. //
  177. // History: 7-Dec-92 DeanE Created
  178. //--------------------------------------------------------------------
  179. STDMETHODIMP CDataObject::SetData(
  180. LPFORMATETC pformatetc,
  181. STGMEDIUM FAR *pmedium,
  182. BOOL fRelease)
  183. {
  184. // BUGBUG - NYI
  185. return(DV_E_CLIPFORMAT);
  186. }
  187. //+-------------------------------------------------------------------
  188. // Method: CDataObject::EnumFormatEtc
  189. //
  190. // Synopsis: See spec 2.00.09 p131.
  191. //
  192. // Parameters: [dwDirection] -
  193. // [ppenmFormatEtc] -
  194. //
  195. // Returns: S_OK
  196. //
  197. // History: 7-Dec-92 DeanE Created
  198. //--------------------------------------------------------------------
  199. STDMETHODIMP CDataObject::EnumFormatEtc(
  200. DWORD dwDirection,
  201. LPENUMFORMATETC FAR *ppenmFormatEtc)
  202. {
  203. // BUGBUG - NYI
  204. *ppenmFormatEtc = NULL;
  205. return(E_FAIL);
  206. }
  207. //+-------------------------------------------------------------------
  208. // Method: CDataObject::DAdvise
  209. //
  210. // Synopsis: See spec 2.00.09 p132
  211. //
  212. // Parameters: [pFormatetc] -
  213. // [advf] -
  214. // [pAdvSink] -
  215. // [pdwConnection] -
  216. //
  217. // Returns: S_OK
  218. //
  219. // History: 7-Dec-92 DeanE Created
  220. //--------------------------------------------------------------------
  221. STDMETHODIMP CDataObject::DAdvise(
  222. FORMATETC FAR *pFormatetc,
  223. DWORD advf,
  224. LPADVISESINK pAdvSink,
  225. DWORD FAR *pdwConnection)
  226. {
  227. if (NULL == _pDAHolder)
  228. {
  229. if (S_OK != CreateDataAdviseHolder(&_pDAHolder))
  230. {
  231. return(E_OUTOFMEMORY);
  232. }
  233. }
  234. return(_pDAHolder->Advise(this, pFormatetc, advf, pAdvSink, pdwConnection));
  235. }
  236. //+-------------------------------------------------------------------
  237. // Method: CDataObject::DUnadvise
  238. //
  239. // Synopsis: See spec 2.00.09 p133
  240. //
  241. // Parameters: [dwConnection] -
  242. //
  243. // Returns: S_OK
  244. //
  245. // History: 7-Dec-92 DeanE Created
  246. //--------------------------------------------------------------------
  247. STDMETHODIMP CDataObject::DUnadvise(DWORD dwConnection)
  248. {
  249. if (NULL == _pDAHolder)
  250. {
  251. // Nobody is registered
  252. return(E_INVALIDARG);
  253. }
  254. return(_pDAHolder->Unadvise(dwConnection));
  255. }
  256. //+-------------------------------------------------------------------
  257. // Method: CDataObject::EnumDAdvise
  258. //
  259. // Synopsis: See spec 2.00.09 p133
  260. //
  261. // Parameters: [ppenmAdvise] -
  262. //
  263. // Returns: S_OK
  264. //
  265. // History: 7-Dec-92 DeanE Created
  266. //--------------------------------------------------------------------
  267. STDMETHODIMP CDataObject::EnumDAdvise(LPENUMSTATDATA FAR *ppenmAdvise)
  268. {
  269. if (NULL == _pDAHolder)
  270. {
  271. return(E_FAIL);
  272. }
  273. return(_pDAHolder->EnumAdvise(ppenmAdvise));
  274. }