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.

215 lines
7.4 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // File:
  4. // cachenode.h
  5. //
  6. // Classes:
  7. // CCacheNode
  8. //
  9. // Functions:
  10. //
  11. // History:
  12. // Gopalk Creation Aug 23, 1996
  13. //-----------------------------------------------------------------------------
  14. #ifndef _CACHENODE_H_
  15. #define _CACHENODE_H_
  16. #include <olepres.h>
  17. #define CNFLAG_FROZENSTATE 0x00000001 /* In Frozen State */
  18. #define CNFLAG_LOADEDSTATE 0x00000002 /* In Loaded State */
  19. #define CNFLAG_DATAPRESENT 0x00000004 /* Data Present */
  20. #define CNFLAG_NATIVECACHE 0x00000008 /* Native Cache Node */
  21. #define CNFLAG_LOADEDCACHE 0x00000010 /* Loaded Cache Node */
  22. #define CNFLAG_OUTOFMEMORY 0x00000020 /* Out of Memory */
  23. #ifdef _DEBUG
  24. #define CN_PRESOBJ_GEN 0x00000001
  25. #define CN_PRESOBJ_EMF 0x00000010
  26. #define CN_PRESOBJ_MF 0x00000100
  27. #endif // _DEBUG
  28. class CCacheNode
  29. {
  30. public:
  31. CCacheNode(void);
  32. CCacheNode(LPFORMATETC lpFormatEtc, DWORD advf, LPSTORAGE pStg);
  33. CCacheNode(LPFORMATETC lpFormatEtc) {
  34. CCacheNode(lpFormatEtc, 0, NULL);
  35. }
  36. ~CCacheNode();
  37. void SetClsid(const CLSID& clsid) {
  38. m_clsid = clsid;
  39. return;
  40. }
  41. CLSID GetClsid(void) {
  42. return m_clsid;
  43. }
  44. LPOLEPRESOBJECT GetPresObj(void) {
  45. return(m_pPresObj);
  46. }
  47. const FORMATETC* GetFormatEtc(void) {
  48. return(&m_foretc);
  49. }
  50. HRESULT SetAdvf(DWORD dwAdvf) {
  51. m_advf = dwAdvf;
  52. ClearLoadedStateFlag();
  53. return NOERROR;
  54. }
  55. DWORD GetAdvf(void) {
  56. return(m_advf);
  57. }
  58. HRESULT SetStg(LPSTORAGE pStg);
  59. void ResetStg(void) {
  60. m_pStg = NULL;
  61. }
  62. LPSTORAGE GetStg(void) {
  63. return(m_pStg);
  64. }
  65. void HandsOffStorage(void) {
  66. m_pStg = NULL;
  67. return;
  68. }
  69. void SaveCompleted(LPSTORAGE pStgNew) {
  70. if(pStgNew)
  71. m_pStg = pStgNew;
  72. return;
  73. }
  74. BOOL InFrozenState() {
  75. return(m_dwFlags & CNFLAG_FROZENSTATE);
  76. }
  77. BOOL InLoadedState() {
  78. return(m_dwFlags & CNFLAG_LOADEDSTATE);
  79. }
  80. BOOL IsBlank() {
  81. return(!(m_dwFlags & CNFLAG_DATAPRESENT));
  82. }
  83. BOOL IsNativeCache() {
  84. return(m_dwFlags & CNFLAG_NATIVECACHE);
  85. }
  86. BOOL IsNormalCache() {
  87. return(!(m_dwFlags & CNFLAG_NATIVECACHE));
  88. }
  89. BOOL IsOutOfMemory() {
  90. return(m_dwFlags & CNFLAG_OUTOFMEMORY);
  91. }
  92. void MakeNativeCache() {
  93. m_dwFlags |= CNFLAG_NATIVECACHE;
  94. return;
  95. }
  96. void MakeNormalCache() {
  97. m_dwFlags &= ~CNFLAG_NATIVECACHE;
  98. return;
  99. }
  100. BOOL IsLoadedCache() {
  101. Win4Assert(IsNormalCache());
  102. return(m_dwFlags & CNFLAG_LOADEDCACHE);
  103. }
  104. void ClearAdviseConnection(void) {
  105. m_pDataObject = NULL;
  106. m_dwAdvConnId = 0;
  107. }
  108. HRESULT LoadNativeData(void) {
  109. Win4Assert(IsNativeCache());
  110. return CreateAndLoadPresObj(FALSE);
  111. }
  112. HRESULT LoadPresentation(void) {
  113. Win4Assert(IsNormalCache());
  114. return CreateAndLoadPresObj(FALSE);
  115. }
  116. HRESULT Load(LPSTREAM lpstream, int iStreamNum, BOOL fDelayLoad);
  117. HRESULT Save(LPSTORAGE pstgSave, BOOL fSameAsLoad, int iStreamNum);
  118. HRESULT Update(LPDATAOBJECT pDataObj, DWORD grfUpdf, BOOL& fUpdated);
  119. HRESULT SetDataWDO(LPFORMATETC lpForetc, LPSTGMEDIUM lpStgmed,
  120. BOOL fRelease, BOOL& fUpdated, IDataObject* pdo);
  121. HRESULT SetData(LPFORMATETC lpForetc, LPSTGMEDIUM lpStgmed,
  122. BOOL fRelease, BOOL& fUpdated) {
  123. return SetDataWDO(lpForetc, lpStgmed, fRelease, fUpdated, NULL);
  124. }
  125. HRESULT GetExtent(DWORD dwAspect, SIZEL* psize);
  126. HRESULT CCacheNode::GetData(LPFORMATETC pforetc, LPSTGMEDIUM pmedium);
  127. HRESULT CCacheNode::GetDataHere(LPFORMATETC pforetc, LPSTGMEDIUM pmedium);
  128. HRESULT CCacheNode::Draw(void* pvAspect, HDC hicTargetDev, HDC hdcDraw,
  129. LPCRECTL lprcBounds, LPCRECTL lprcWBounds,
  130. BOOL (CALLBACK *pfnContinue)(ULONG_PTR), ULONG_PTR dwContinue);
  131. HRESULT CCacheNode::GetColorSet(void* pvAspect, HDC hicTargetDev,
  132. LPLOGPALETTE* ppColorSet);
  133. HRESULT Freeze (void);
  134. HRESULT Unfreeze (BOOL& fUpdated);
  135. LPSTREAM GetStm(BOOL fSeekToPresBits, DWORD dwStgAccess);
  136. HRESULT SetupAdviseConnection(LPDATAOBJECT pDataObj, IAdviseSink* pAdviseSink);
  137. HRESULT TearDownAdviseConnection(LPDATAOBJECT pDataObj);
  138. HRESULT DiscardPresentation(LPSTREAM pGivenStream=NULL);
  139. HRESULT SaveTOCEntry(LPSTREAM pStream, BOOL fSameAsLoad);
  140. HRESULT LoadTOCEntry(LPSTREAM pStream, int& iStreamNum);
  141. const CCacheNode& operator=(const CCacheNode& rCN);
  142. private:
  143. CLSID m_clsid; // set to clsid of the native object for
  144. // native cache node
  145. FORMATETC m_foretc; // the formatetc for this cache node
  146. DWORD m_advf; // the advise control flags requested
  147. // for this cache node
  148. long m_lWidth; // width of the presentation
  149. long m_lHeight; // height of the presentation
  150. DWORD m_dwFlags; // flags for the cache node
  151. LPSTORAGE m_pStg; // storage containing this presentation
  152. int m_iStreamNum; // presentation stream number
  153. DWORD m_dwPresBitsPos; // byte offset to presentation bits in stream
  154. DWORD m_dwSavedPresBitsPos; // byte offset to presentation bits in stream
  155. // saved with fSameAsLoad set to FALSE
  156. BOOL m_fConvert; // set if the presentation is in MAC CfFormat
  157. LPOLEPRESOBJECT m_pPresObj; // pres object
  158. LPOLEPRESOBJECT m_pPresObjAfterFreeze; // pres object that holds changes
  159. // when the main pres object is frozen
  160. LPDATAOBJECT m_pDataObject; // data object on which DAdvise is set up
  161. DWORD m_dwAdvConnId; // the connection ID of the above DAdvise
  162. #ifdef _DEBUG
  163. DWORD m_dwPresFlag; // type of pres object
  164. #endif // _DEBUG
  165. // Private methods
  166. void Initialize(DWORD advf, LPSTORAGE pStg);
  167. BOOL QueryFormatSupport(LPDATAOBJECT lpDataObj);
  168. HRESULT CreateOlePresObj(LPOLEPRESOBJECT* ppPresObj, BOOL fMacPict);
  169. HRESULT CreateAndLoadPresObj(BOOL fHeaderOnly);
  170. void SetPresBitsPos(LPSTREAM lpStream,DWORD& dwPresBitsPos);
  171. void SetFrozenStateFlag() {
  172. m_dwFlags |= CNFLAG_FROZENSTATE;
  173. return;
  174. }
  175. void ClearFrozenStateFlag() {
  176. m_dwFlags &= ~CNFLAG_FROZENSTATE;
  177. return;
  178. }
  179. void SetLoadedStateFlag() {
  180. m_dwFlags |= CNFLAG_LOADEDSTATE;
  181. return;
  182. }
  183. void ClearLoadedStateFlag() {
  184. m_dwFlags &= ~CNFLAG_LOADEDSTATE;
  185. return;
  186. }
  187. void SetDataPresentFlag() {
  188. m_dwFlags |= CNFLAG_DATAPRESENT;
  189. return;
  190. }
  191. void ClearDataPresentFlag() {
  192. m_dwFlags &= ~CNFLAG_DATAPRESENT;
  193. return;
  194. }
  195. void SetOutOfMemoryFlag() {
  196. m_dwFlags |= CNFLAG_OUTOFMEMORY;
  197. }
  198. void SetLoadedCacheFlag() {
  199. m_dwFlags |= CNFLAG_LOADEDCACHE;
  200. }
  201. void ClearLoadedCacheFlag() {
  202. m_dwFlags &= ~CNFLAG_LOADEDCACHE;
  203. }
  204. };
  205. typedef CCacheNode *PCACHENODE;
  206. typedef CCacheNode *LPCACHENODE;
  207. #endif // _CACHENODE_H_