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.

166 lines
4.7 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1994.
  5. //
  6. // File: emf.h
  7. //
  8. // Contents: Declaration of CEMfObject
  9. //
  10. // Classes: CEMfObject
  11. //
  12. // History: dd-mmm-yy Author Comment
  13. // 01-Feb-95 t-ScottH add Dump method to CEMfObject
  14. // 12-May-94 DavePl created
  15. //
  16. //--------------------------------------------------------------------------
  17. #include "olepres.h"
  18. #include "olecache.h"
  19. #include "cachenod.h"
  20. // The following number adjusts the count of records processed by
  21. // our EMF enumeration function before the user's callback function
  22. // is run.
  23. #define EMF_RECORD_COUNT 20
  24. // Enumeration to indicate which format a hEMF is to be serialized as.
  25. // Values are not indicative of anything, just non-zero and non-one to
  26. // make it easier to catch bogus values while debugging
  27. typedef enum tagEMFWRITETYPE
  28. {
  29. WRITE_AS_WMF = 13,
  30. WRITE_AS_EMF = 17
  31. } EMFWRITETYPE;
  32. //+-------------------------------------------------------------------------
  33. //
  34. // Class: CEMfObject
  35. //
  36. // Purpose: Enhanced Metafile presentation object
  37. //
  38. // Interface: IOlePresObj
  39. //
  40. // History: dd-mmm-yy Author Comment
  41. // 01-Feb-95 t-ScottH add Dump method (_DEBUG only) (this method
  42. // is also a method in IOlePresObj
  43. // 12-May-94 DavePl Created
  44. //
  45. //--------------------------------------------------------------------------
  46. class FAR CEMfObject : public IOlePresObj, public CPrivAlloc
  47. {
  48. public:
  49. CEMfObject(LPCACHENODE pCacheNode, DWORD dwAspect);
  50. ~CEMfObject();
  51. STDMETHOD (QueryInterface) (THIS_ REFIID riid,
  52. void ** ppvObj);
  53. STDMETHOD_(ULONG,AddRef) (THIS);
  54. STDMETHOD_(ULONG,Release) (THIS);
  55. STDMETHOD (GetData) (THIS_ LPFORMATETC pformatetcIn,
  56. LPSTGMEDIUM pmedium );
  57. STDMETHOD (GetDataHere) (THIS_ LPFORMATETC pformatetcIn,
  58. LPSTGMEDIUM pmedium );
  59. STDMETHOD (SetDataWDO) (THIS_ LPFORMATETC pformatetc,
  60. STGMEDIUM FAR * pmedium,
  61. BOOL fRelease, IDataObject * pdo);
  62. STDMETHOD (Draw) (THIS_ void * pvAspect,
  63. HDC hicTargetDev,
  64. HDC hdcDraw,
  65. LPCRECTL lprcBounds,
  66. LPCRECTL lprcWBounds,
  67. int (CALLBACK * pfnContinue)(ULONG_PTR),
  68. ULONG_PTR dwContinue);
  69. STDMETHOD (Load) (THIS_ LPSTREAM pstm,
  70. BOOL fReadHeaderOnly);
  71. STDMETHOD (Save) (THIS_ LPSTREAM pstm);
  72. STDMETHOD (GetExtent) (THIS_ DWORD dwAspect,
  73. LPSIZEL lpsizel);
  74. STDMETHOD (GetColorSet) (void * pvAspect,
  75. HDC hicTargetDev,
  76. LPLOGPALETTE * ppColorSet);
  77. STDMETHOD_(BOOL, IsBlank) (void);
  78. STDMETHOD_(void, DiscardHPRES) (void);
  79. int CALLBACK CallbackFuncForDraw (HDC hdc,
  80. HANDLETABLE * lpHTable,
  81. const ENHMETARECORD * lpEMFR,
  82. int nObj,
  83. LPARAM lpobj);
  84. #ifdef _DEBUG
  85. STDMETHOD(Dump) (THIS_ char **ppszDump, ULONG ulFlag, int nIndentLevel);
  86. #endif // _DEBUG
  87. private:
  88. INTERNAL ChangeData (HENHMETAFILE hEMfp, BOOL fDelete);
  89. INTERNAL_(HENHMETAFILE) LoadHPRES (void);
  90. INTERNAL_(HENHMETAFILE) GetCopyOfHPRES (void);
  91. inline HENHMETAFILE M_HPRES(void);
  92. ULONG m_ulRefs;
  93. HENHMETAFILE m_hPres;
  94. BOOL m_fMetaDC;
  95. int m_nRecord;
  96. HRESULT m_error;
  97. LPLOGPALETTE m_pColorSet;
  98. int (CALLBACK * m_pfnContinue)(ULONG_PTR);
  99. ULONG_PTR m_dwContinue;
  100. DWORD m_dwAspect;
  101. DWORD m_dwSize;
  102. LONG m_lWidth;
  103. LONG m_lHeight;
  104. LPCACHENODE m_pCacheNode;
  105. };
  106. // This is the prototype for the callback function which
  107. // will enumerate over the enhanced metafile records.
  108. int CALLBACK EMfCallbackFuncForDraw (HDC hdc,
  109. HANDLETABLE * pHTable,
  110. const ENHMETARECORD * pMFR,
  111. int nObj,
  112. LPARAM lpobj);
  113. // Utility function to de-serialize an enhanced metafile from
  114. // a stream, and create a usable handle to it
  115. FARINTERNAL UtGetHEMFFromEMFStm(LPSTREAM lpstream,
  116. DWORD * dwSize,
  117. HENHMETAFILE * lphPres);
  118. // Utility function which takes a handle to an enhanced metafile
  119. // and serializes the associated metafile to a stream
  120. FARINTERNAL UtHEMFToEMFStm(HENHMETAFILE hEMF,
  121. DWORD dwSize,
  122. LPSTREAM lpstream,
  123. EMFWRITETYPE type);
  124. // A utility function to check whether or not a DC in question
  125. // is a standard DC or a metafile DC.
  126. STDAPI_(BOOL) OleIsDcMeta (HDC hdc);
  127.