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.

252 lines
7.2 KiB

  1. //+-------------------------------------------------------------------
  2. // File: ipersist.cxx
  3. //
  4. // Contents: IPersist and IPersistStorage methods of CPersistStorage class.
  5. //
  6. // Classes: CPersistStorage - IPersist, IPersistStorage implementations
  7. //
  8. // History: 7-Dec-92 DeanE Created
  9. //---------------------------------------------------------------------
  10. #include <pch.cxx>
  11. #pragma hdrstop
  12. #pragma optimize("",off)
  13. #include <persist.hxx>
  14. //+-------------------------------------------------------------------
  15. // Member: CPersistStorage::CPersistStorage()
  16. //
  17. // Synopsis: The constructor for CPersistStorage.
  18. //
  19. // Arguments: None
  20. //
  21. // History: 7-Dec-92 DeanE Created
  22. //--------------------------------------------------------------------
  23. CPersistStorage::CPersistStorage(CTestEmbed *pteObject)
  24. {
  25. _cRef = 1;
  26. _pteObject = pteObject;
  27. _fDirty = FALSE;
  28. }
  29. //+-------------------------------------------------------------------
  30. // Member: CPersistStorage::~CPersistStorage()
  31. //
  32. // Synopsis: The destructor for CPersistStorage.
  33. //
  34. // History: 7-Dec-92 DeanE Created
  35. //--------------------------------------------------------------------
  36. CPersistStorage::~CPersistStorage()
  37. {
  38. // _cRef should be 1
  39. if (1 != _cRef)
  40. {
  41. // BUGBUG - Log error, someone hasn't released
  42. }
  43. return;
  44. }
  45. //+-------------------------------------------------------------------
  46. // Method: CPersistStorage::QueryInterface
  47. //
  48. // Synopsis: Forward this to the object we're associated with
  49. //
  50. // Parameters: [iid] - Interface ID to return.
  51. // [ppv] - Pointer to pointer to object.
  52. //
  53. // Returns: S_OK if iid is supported, or E_NOINTERFACE if not.
  54. //
  55. // History: 7-Dec-92 DeanE Created
  56. //--------------------------------------------------------------------
  57. STDMETHODIMP CPersistStorage::QueryInterface(REFIID iid, void FAR * FAR *ppv)
  58. {
  59. return(_pteObject->QueryInterface(iid, ppv));
  60. }
  61. //+-------------------------------------------------------------------
  62. // Method: CPersistStorage::AddRef
  63. //
  64. // Synopsis: Forward this to the object we're associated with
  65. //
  66. // Returns: New reference count.
  67. //
  68. // History: 7-Dec-92 DeanE Created
  69. //--------------------------------------------------------------------
  70. STDMETHODIMP_(ULONG) CPersistStorage::AddRef(void)
  71. {
  72. ++_cRef;
  73. return(_pteObject->AddRef());
  74. }
  75. //+-------------------------------------------------------------------
  76. // Method: CPersistStorage::Release
  77. //
  78. // Synopsis: Forward this to the object we're associated with
  79. //
  80. // Returns: New reference count.
  81. //
  82. // History: 7-Dec-92 DeanE Created
  83. //--------------------------------------------------------------------
  84. STDMETHODIMP_(ULONG) CPersistStorage::Release(void)
  85. {
  86. --_cRef;
  87. return(_pteObject->Release());
  88. }
  89. //+-------------------------------------------------------------------
  90. // Method: CPersistStorage::GetClassId
  91. //
  92. // Synopsis: See spec 2.00.09 p197. Answer the Class ID of this
  93. // object.
  94. //
  95. // Parameters: [pClassId] -
  96. //
  97. // Returns: S_OK
  98. //
  99. // History: 7-Dec-92 DeanE Created
  100. //--------------------------------------------------------------------
  101. STDMETHODIMP CPersistStorage::GetClassID(LPCLSID pClassId)
  102. {
  103. if (NULL != pClassId)
  104. {
  105. *pClassId = CLSID_TestEmbed;
  106. }
  107. return(S_OK);
  108. }
  109. //+-------------------------------------------------------------------
  110. // Method: CPersistStorage::IsDirty
  111. //
  112. // Synopsis: See spec 2.00.09 p200. Return S_OK if the object needs
  113. // to be saved in order to avoid data loss, or S_FALSE
  114. // if not.
  115. //
  116. // Parameters: None
  117. //
  118. // Returns: S_OK or S_FALSE
  119. //
  120. // History: 7-Dec-92 DeanE Created
  121. //--------------------------------------------------------------------
  122. STDMETHODIMP CPersistStorage::IsDirty()
  123. {
  124. // BUGBUG - NYI
  125. // Because we are NYI, just return S_FALSE
  126. return(S_FALSE);
  127. }
  128. //+-------------------------------------------------------------------
  129. // Method: CPersistStorage::InitNew
  130. //
  131. // Synopsis: See spec 2.00.09 p197. This method provides a way
  132. // for a container to provide persistent storage to this
  133. // object. Call AddRef on the pStg passed if we do save
  134. // it.
  135. //
  136. // Parameters: [pStg] - IStorage instance this object can use.
  137. //
  138. // Returns: S_OK
  139. //
  140. // History: 7-Dec-92 DeanE Created
  141. //--------------------------------------------------------------------
  142. STDMETHODIMP CPersistStorage::InitNew(LPSTORAGE pStg)
  143. {
  144. // BUGBUG - NYI
  145. return(S_OK);
  146. }
  147. //+-------------------------------------------------------------------
  148. // Method: CPersistStorage::Load
  149. //
  150. // Synopsis: See spec 2.00.09 p200. Called by handler to put this
  151. // object into the running state. Object should use the
  152. // pStg passed to "initialize" itself. We can hold onto
  153. // this pStg, but when ::Save is called, this can be
  154. // a different IStorage.
  155. //
  156. // Parameters: [pStg] - IStorage to initialize object from.
  157. //
  158. // Returns: S_OK?
  159. //
  160. // History: 7-Dec-92 DeanE Created
  161. //--------------------------------------------------------------------
  162. STDMETHODIMP CPersistStorage::Load(LPSTORAGE pStg)
  163. {
  164. // BUGBUG - NYI
  165. // Initialize the object here, though, just as if we had obtained
  166. // data from an IStorage
  167. return(S_OK);
  168. }
  169. //+-------------------------------------------------------------------
  170. // Method: CPersistStorage::Save
  171. //
  172. // Synopsis: See spec 2.00.09 p197. Save the data in the IStorage
  173. // passed. Ignore flags for now.
  174. //
  175. // Parameters: [pStgSave] - Save data in here.
  176. // [fSameAsLoad] - Indicates this object is the same one
  177. // that was initially started.
  178. // [fRemember] - Only matters if fSameAsLoad is FALSE.
  179. //
  180. // Returns: STG_E_MEDIUMFULL - why???
  181. //
  182. // History: 7-Dec-92 DeanE Created
  183. //--------------------------------------------------------------------
  184. STDMETHODIMP CPersistStorage::Save(
  185. LPSTORAGE pStgSave,
  186. BOOL fSameAsLoad)
  187. {
  188. // BUGBUG - NYI
  189. return(STG_E_MEDIUMFULL);
  190. }
  191. //+-------------------------------------------------------------------
  192. // Method: CPersistStorage::SaveCompleted
  193. //
  194. // Synopsis: See spec 2.00.09 p198. Used only in certain circumstances.
  195. //
  196. // Parameters: [pStgSaved] -
  197. //
  198. // Returns: S_OK
  199. //
  200. // History: 7-Dec-92 DeanE Created
  201. //--------------------------------------------------------------------
  202. STDMETHODIMP CPersistStorage::SaveCompleted(LPSTORAGE pStgSaved)
  203. {
  204. // BUGBUG - NYI
  205. // We don't have to worry about this unless we allow a "Save As"
  206. // operation
  207. return(S_OK);
  208. }
  209. //+-------------------------------------------------------------------
  210. // Method: CPersistStorage::HandsOffStorage
  211. //
  212. // Synopsis: See spec 2.00.09 p198. Used only in certain circumstances.
  213. //
  214. // Parameters: [pStgSaved] -
  215. //
  216. // Returns: S_OK
  217. //
  218. // History: 7-Dec-92 DeanE Created
  219. //--------------------------------------------------------------------
  220. STDMETHODIMP CPersistStorage::HandsOffStorage(void)
  221. {
  222. // BUGBUG - NYI
  223. // We don't have to worry about this unless we allow a "Save As"
  224. // operation
  225. return(S_OK);
  226. }