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.

328 lines
10 KiB

  1. /*************************************************************************
  2. **
  3. ** OLE 2.0 Utility Library
  4. **
  5. ** olestd.h
  6. **
  7. ** This file contains file contains data structure defintions,
  8. ** function prototypes, constants, etc. for the common OLE 2.0
  9. ** utilities.
  10. ** These utilities include the following:
  11. ** Debuging Assert/Verify macros
  12. ** HIMETRIC conversion routines
  13. ** reference counting debug support
  14. ** OleStd API's for common compound-document app support
  15. **
  16. ** (c) Copyright Microsoft Corp. 1990 - 1995 All Rights Reserved
  17. **
  18. *************************************************************************/
  19. #ifndef _OLESTD_H_
  20. #define _OLESTD_H_
  21. #include <commdlg.h> // needed for LPPRINTDLG
  22. #include <shellapi.h> // needed for HKEY
  23. #include <oledlg.h> // need some paste special defines
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. STDAPI_(void) OleStdInitialize(HINSTANCE hInstance, HINSTANCE hResInstance);
  28. // Clipboard Copy/Paste & Drag/Drop support support
  29. // Clipboard format strings
  30. #define CF_EMBEDSOURCE TEXT("Embed Source")
  31. #define CF_EMBEDDEDOBJECT TEXT("Embedded Object")
  32. #define CF_LINKSOURCE TEXT("Link Source")
  33. #define CF_OBJECTDESCRIPTOR TEXT("Object Descriptor")
  34. #define CF_LINKSRCDESCRIPTOR TEXT("Link Source Descriptor")
  35. #define CF_OWNERLINK TEXT("OwnerLink")
  36. #define CF_FILENAME TEXT("FileName")
  37. #define CF_FILENAMEW TEXT("FileNameW")
  38. // Other useful defines
  39. #define HIMETRIC_PER_INCH 2540 // number HIMETRIC units per inch
  40. #define MAP_LOGHIM_TO_PIX(x,ppli) MulDiv((ppli), (x), HIMETRIC_PER_INCH)
  41. /****** DEBUG Support *****************************************************/
  42. #ifdef _DEBUG
  43. #ifndef _DBGTRACE
  44. #define _DEBUGLEVEL 2
  45. #else
  46. #define _DEBUGLEVEL _DBGTRACE
  47. #endif
  48. #ifdef NOASSERT
  49. #define OLEDBGASSERTDATA
  50. #define OleDbgAssert(a)
  51. #define OleDbgAssertSz(a, b)
  52. #define OleDbgVerify(a)
  53. #define OleDbgVerifySz(a, b)
  54. #else // ! NOASSERT
  55. STDAPI OleStdAssert(LPTSTR lpstrExpr, LPTSTR lpstrMsg,
  56. LPTSTR lpstrFileName, UINT iLine);
  57. #define OLEDBGASSERTDATA \
  58. static TCHAR _szAssertFile[]= TEXT(__FILE__);
  59. #define OleDbgAssert(a) \
  60. (!(a) ? OleStdAssert(TEXT(#a), NULL, _szAssertFile, __LINE__) : (HRESULT)1)
  61. #define OleDbgAssertSz(a, b) \
  62. (!(a) ? OleStdAssert(TEXT(#a), b, _szAssertFile, __LINE__) : (HRESULT)1)
  63. #endif
  64. #define OleDbgVerify(a) \
  65. OleDbgAssert(a)
  66. #define OleDbgVerifySz(a, b) \
  67. OleDbgAssertSz(a, b)
  68. #define OLEDBGDATA_MAIN(szPrefix) \
  69. TCHAR g_szDbgPrefix[] = szPrefix; \
  70. OLEDBGASSERTDATA
  71. #define OLEDBGDATA \
  72. extern TCHAR g_szDbgPrefix[]; \
  73. OLEDBGASSERTDATA
  74. #define OLEDBG_BEGIN(lpsz) \
  75. OleDbgPrintAlways(g_szDbgPrefix,lpsz,1);
  76. #define OLEDBG_END \
  77. OleDbgPrintAlways(g_szDbgPrefix,TEXT("End\r\n"),-1);
  78. #define OleDbgOut(lpsz) \
  79. OleDbgPrintAlways(g_szDbgPrefix,lpsz,0)
  80. #define OleDbgOutNoPrefix(lpsz) \
  81. OleDbgPrintAlways(TEXT(""),lpsz,0)
  82. #define OleDbgOutRefCnt(lpsz,lpObj,refcnt) \
  83. OleDbgPrintRefCntAlways(g_szDbgPrefix,lpsz,lpObj,(ULONG)refcnt)
  84. #define OleDbgOutRect(lpsz,lpRect) \
  85. OleDbgPrintRectAlways(g_szDbgPrefix,lpsz,lpRect)
  86. #define OleDbgOutHResult(lpsz,hr) \
  87. OleDbgPrintScodeAlways(g_szDbgPrefix,lpsz,GetScode(hr))
  88. #define OleDbgOutScode(lpsz,sc) \
  89. OleDbgPrintScodeAlways(g_szDbgPrefix,lpsz,sc)
  90. #define OleDbgOut1(lpsz) \
  91. OleDbgPrint(1,g_szDbgPrefix,lpsz,0)
  92. #define OleDbgOutNoPrefix1(lpsz) \
  93. OleDbgPrint(1,TEXT(""),lpsz,0)
  94. #define OLEDBG_BEGIN1(lpsz) \
  95. OleDbgPrint(1,g_szDbgPrefix,lpsz,1);
  96. #define OLEDBG_END1 \
  97. OleDbgPrint(1,g_szDbgPrefix,TEXT("End\r\n"),-1);
  98. #define OleDbgOutRefCnt1(lpsz,lpObj,refcnt) \
  99. OleDbgPrintRefCnt(1,g_szDbgPrefix,lpsz,lpObj,(ULONG)refcnt)
  100. #define OleDbgOutRect1(lpsz,lpRect) \
  101. OleDbgPrintRect(1,g_szDbgPrefix,lpsz,lpRect)
  102. #define OleDbgOut2(lpsz) \
  103. OleDbgPrint(2,g_szDbgPrefix,lpsz,0)
  104. #define OleDbgOutNoPrefix2(lpsz) \
  105. OleDbgPrint(2,TEXT(""),lpsz,0)
  106. #define OLEDBG_BEGIN2(lpsz) \
  107. OleDbgPrint(2,g_szDbgPrefix,lpsz,1);
  108. #define OLEDBG_END2 \
  109. OleDbgPrint(2,g_szDbgPrefix, TEXT("End\r\n"),-1);
  110. #define OleDbgOutRefCnt2(lpsz,lpObj,refcnt) \
  111. OleDbgPrintRefCnt(2,g_szDbgPrefix,lpsz,lpObj,(ULONG)refcnt)
  112. #define OleDbgOutRect2(lpsz,lpRect) \
  113. OleDbgPrintRect(2,g_szDbgPrefix,lpsz,lpRect)
  114. #define OleDbgOut3(lpsz) \
  115. OleDbgPrint(3,g_szDbgPrefix,lpsz,0)
  116. #define OleDbgOutNoPrefix3(lpsz) \
  117. OleDbgPrint(3,TEXT(""),lpsz,0)
  118. #define OLEDBG_BEGIN3(lpsz) \
  119. OleDbgPrint(3,g_szDbgPrefix,lpsz,1);
  120. #define OLEDBG_END3 \
  121. OleDbgPrint(3,g_szDbgPrefix,TEXT("End\r\n"),-1);
  122. #define OleDbgOutRefCnt3(lpsz,lpObj,refcnt) \
  123. OleDbgPrintRefCnt(3,g_szDbgPrefix,lpsz,lpObj,(ULONG)refcnt)
  124. #define OleDbgOutRect3(lpsz,lpRect) \
  125. OleDbgPrintRect(3,g_szDbgPrefix,lpsz,lpRect)
  126. #define OleDbgOut4(lpsz) \
  127. OleDbgPrint(4,g_szDbgPrefix,lpsz,0)
  128. #define OleDbgOutNoPrefix4(lpsz) \
  129. OleDbgPrint(4,TEXT(""),lpsz,0)
  130. #define OLEDBG_BEGIN4(lpsz) \
  131. OleDbgPrint(4,g_szDbgPrefix,lpsz,1);
  132. #define OLEDBG_END4 \
  133. OleDbgPrint(4,g_szDbgPrefix,TEXT("End\r\n"),-1);
  134. #define OleDbgOutRefCnt4(lpsz,lpObj,refcnt) \
  135. OleDbgPrintRefCnt(4,g_szDbgPrefix,lpsz,lpObj,(ULONG)refcnt)
  136. #define OleDbgOutRect4(lpsz,lpRect) \
  137. OleDbgPrintRect(4,g_szDbgPrefix,lpsz,lpRect)
  138. #else // !_DEBUG
  139. #define OLEDBGDATA_MAIN(szPrefix)
  140. #define OLEDBGDATA
  141. #define OleDbgAssert(a)
  142. #define OleDbgAssertSz(a, b)
  143. #define OleDbgVerify(a) (a)
  144. #define OleDbgVerifySz(a, b) (a)
  145. #define OleDbgOutHResult(lpsz,hr)
  146. #define OleDbgOutScode(lpsz,sc)
  147. #define OLEDBG_BEGIN(lpsz)
  148. #define OLEDBG_END
  149. #define OleDbgOut(lpsz)
  150. #define OleDbgOut1(lpsz)
  151. #define OleDbgOut2(lpsz)
  152. #define OleDbgOut3(lpsz)
  153. #define OleDbgOut4(lpsz)
  154. #define OleDbgOutNoPrefix(lpsz)
  155. #define OleDbgOutNoPrefix1(lpsz)
  156. #define OleDbgOutNoPrefix2(lpsz)
  157. #define OleDbgOutNoPrefix3(lpsz)
  158. #define OleDbgOutNoPrefix4(lpsz)
  159. #define OLEDBG_BEGIN1(lpsz)
  160. #define OLEDBG_BEGIN2(lpsz)
  161. #define OLEDBG_BEGIN3(lpsz)
  162. #define OLEDBG_BEGIN4(lpsz)
  163. #define OLEDBG_END1
  164. #define OLEDBG_END2
  165. #define OLEDBG_END3
  166. #define OLEDBG_END4
  167. #define OleDbgOutRefCnt(lpsz,lpObj,refcnt)
  168. #define OleDbgOutRefCnt1(lpsz,lpObj,refcnt)
  169. #define OleDbgOutRefCnt2(lpsz,lpObj,refcnt)
  170. #define OleDbgOutRefCnt3(lpsz,lpObj,refcnt)
  171. #define OleDbgOutRefCnt4(lpsz,lpObj,refcnt)
  172. #define OleDbgOutRect(lpsz,lpRect)
  173. #define OleDbgOutRect1(lpsz,lpRect)
  174. #define OleDbgOutRect2(lpsz,lpRect)
  175. #define OleDbgOutRect3(lpsz,lpRect)
  176. #define OleDbgOutRect4(lpsz,lpRect)
  177. #endif // _DEBUG
  178. /*************************************************************************
  179. ** Function prototypes
  180. *************************************************************************/
  181. // OLESTD.CPP
  182. STDAPI_(int) XformWidthInHimetricToPixels(HDC, int);
  183. STDAPI_(int) XformHeightInHimetricToPixels(HDC, int);
  184. STDAPI_(BOOL) OleStdIsOleLink(LPUNKNOWN lpUnk);
  185. STDAPI_(LPUNKNOWN) OleStdQueryInterface(LPUNKNOWN lpUnk, REFIID riid);
  186. STDAPI_(HGLOBAL) OleStdGetData(
  187. LPDATAOBJECT lpDataObj,
  188. CLIPFORMAT cfFormat,
  189. DVTARGETDEVICE FAR* lpTargetDevice,
  190. DWORD dwAspect,
  191. LPSTGMEDIUM lpMedium
  192. );
  193. STDAPI_(void) OleStdMarkPasteEntryList(
  194. LPDATAOBJECT lpSrcDataObj,
  195. LPOLEUIPASTEENTRY lpPriorityList,
  196. int cEntries
  197. );
  198. STDAPI_(HGLOBAL) OleStdGetObjectDescriptorData(
  199. CLSID clsid,
  200. DWORD dwAspect,
  201. SIZEL sizel,
  202. POINTL pointl,
  203. DWORD dwStatus,
  204. LPTSTR lpszFullUserTypeName,
  205. LPTSTR lpszSrcOfCopy
  206. );
  207. STDAPI_(HGLOBAL) OleStdFillObjectDescriptorFromData(
  208. LPDATAOBJECT lpDataObject,
  209. LPSTGMEDIUM lpmedium,
  210. CLIPFORMAT FAR* lpcfFmt
  211. );
  212. STDAPI_(LPVOID) OleStdMalloc(ULONG ulSize);
  213. STDAPI_(LPVOID) OleStdRealloc(LPVOID pmem, ULONG ulSize);
  214. STDAPI_(void) OleStdFree(LPVOID pmem);
  215. STDAPI_(ULONG) OleStdGetSize(LPVOID pmem);
  216. STDAPI_(LPTSTR) OleStdCopyString(LPTSTR lpszSrc);
  217. STDAPI_(LPTSTR) OleStdLoadString(HINSTANCE hInst, UINT nID);
  218. STDAPI_(ULONG) OleStdRelease(LPUNKNOWN lpUnk);
  219. STDAPI_(BOOL) OleStdCompareTargetDevice
  220. (DVTARGETDEVICE FAR* ptdLeft, DVTARGETDEVICE FAR* ptdRight);
  221. STDAPI_(void) OleDbgPrint(
  222. int nDbgLvl,
  223. LPTSTR lpszPrefix,
  224. LPTSTR lpszMsg,
  225. int nIndent
  226. );
  227. STDAPI_(void) OleDbgPrintAlways(LPTSTR lpszPrefix, LPTSTR lpszMsg, int nIndent);
  228. STDAPI_(void) OleDbgSetDbgLevel(int nDbgLvl);
  229. STDAPI_(int) OleDbgGetDbgLevel( void );
  230. STDAPI_(void) OleDbgIndent(int n);
  231. STDAPI_(void) OleDbgPrintRefCnt(
  232. int nDbgLvl,
  233. LPTSTR lpszPrefix,
  234. LPTSTR lpszMsg,
  235. LPVOID lpObj,
  236. ULONG refcnt
  237. );
  238. STDAPI_(void) OleDbgPrintRefCntAlways(
  239. LPTSTR lpszPrefix,
  240. LPTSTR lpszMsg,
  241. LPVOID lpObj,
  242. ULONG refcnt
  243. );
  244. STDAPI_(void) OleDbgPrintRect(
  245. int nDbgLvl,
  246. LPTSTR lpszPrefix,
  247. LPTSTR lpszMsg,
  248. LPRECT lpRect
  249. );
  250. STDAPI_(void) OleDbgPrintRectAlways(
  251. LPTSTR lpszPrefix,
  252. LPTSTR lpszMsg,
  253. LPRECT lpRect
  254. );
  255. STDAPI_(void) OleDbgPrintScodeAlways(LPTSTR lpszPrefix, LPTSTR lpszMsg, SCODE sc);
  256. #ifdef __cplusplus
  257. }
  258. #endif
  259. #define ATOW(wsz, sz, cch) MultiByteToWideChar(CP_ACP, 0, sz, -1, wsz, cch)
  260. #define WTOA(sz, wsz, cch) WideCharToMultiByte(CP_ACP, 0, wsz, -1, sz, cch, NULL, NULL)
  261. #define ATOWLEN(sz) MultiByteToWideChar(CP_ACP, 0, sz, -1, NULL, 0)
  262. #define WTOALEN(wsz) WideCharToMultiByte(CP_ACP, 0, wsz, -1, NULL, 0, NULL, NULL)
  263. #endif // _OLESTD_H_