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.

310 lines
8.1 KiB

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