home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / Borland / Cplus45 / BC45 / BOLEUI.PAK / OLESTD.H < prev   
C/C++ Source or Header  |  1995-08-29  |  30KB  |  860 lines

  1. //
  2. /*************************************************************************
  3. **
  4. **    OLE 2.0 Standard Utilities
  5. **
  6. **    olestd.h
  7. **
  8. **    This file contains file contains data structure defintions,
  9. **    function prototypes, constants, etc. for the common OLE 2.0
  10. **    utilities.
  11. **    These utilities include the following:
  12. **          Debuging Assert/Verify macros
  13. **          HIMETRIC conversion routines
  14. **          reference counting debug support
  15. **          OleStd API's for common compound-document app support
  16. **
  17. *************************************************************************/
  18. /*
  19.  *      C/C++ Run Time Library - Version 6.5
  20.  *
  21.  *      Copyright (c) 1994 by Borland International
  22.  *      All Rights Reserved.
  23.  *
  24.  */
  25.  
  26. #if !defined( _OLESTD_H_ )
  27. #define _OLESTD_H_
  28.  
  29. // String table defines...
  30. #define  IDS_OLESTDNOCREATEFILE   700
  31. #define  IDS_OLESTDNOOPENFILE     701
  32. #define  IDS_OLESTDDISKFULL       702
  33.  
  34.  
  35. #ifndef RC_INVOKED
  36.  
  37. //#pragma message ("INCLUDING OLESTD.H from " __FILE__)
  38.  
  39. #if defined( __TURBOC__ ) || defined( WIN32 )
  40. #define _based(a)
  41. #endif
  42.  
  43. #include <dos.h>        // needed for filetime
  44. #include <commdlg.h>    // needed for LPPRINTDLG
  45. #include <shellapi.h>   // needed for HKEY
  46.  
  47. /*
  48.  * Some C interface declaration stuff
  49.  */
  50.  
  51. #if ! defined(__cplusplus)
  52. typedef struct tagINTERFACEIMPL {
  53.         IUnknownVtbl FAR*       lpVtbl;
  54.         LPVOID                  lpBack;
  55.         int                     cRef;   // interface specific ref count.
  56. } INTERFACEIMPL, FAR* LPINTERFACEIMPL;
  57.  
  58. #define INIT_INTERFACEIMPL(lpIFace, pVtbl, pBack)   \
  59.         ((lpIFace)->lpVtbl = pVtbl, \
  60.             ((LPINTERFACEIMPL)(lpIFace))->lpBack = (LPVOID)pBack,   \
  61.             ((LPINTERFACEIMPL)(lpIFace))->cRef = 0  \
  62.         )
  63.  
  64. #if defined( _DEBUG )
  65. #define OleDbgQueryInterfaceMethod(lpUnk)   \
  66.         ((lpUnk) != NULL ? ((LPINTERFACEIMPL)(lpUnk))->cRef++ : 0)
  67. #define OleDbgAddRefMethod(lpThis, iface)   \
  68.         ((LPINTERFACEIMPL)(lpThis))->cRef++
  69.  
  70. #if _DEBUGLEVEL >= 2
  71. #define OleDbgReleaseMethod(lpThis, iface) \
  72.         (--((LPINTERFACEIMPL)(lpThis))->cRef == 0 ? \
  73.             OleDbgOut("\t" iface "* RELEASED (cRef == 0)\r\n"),1 : \
  74.              (((LPINTERFACEIMPL)(lpThis))->cRef < 0) ? \
  75.                 ( \
  76.                     DebugBreak(), \
  77.                     OleDbgOut(  \
  78.                         "\tERROR: " iface "* RELEASED TOO MANY TIMES\r\n") \
  79.                 ),1 : \
  80.                 1)
  81.  
  82. #else       // if _DEBUGLEVEL < 2
  83. #define OleDbgReleaseMethod(lpThis, iface) \
  84.         (--((LPINTERFACEIMPL)(lpThis))->cRef == 0 ? \
  85.             1 : \
  86.              (((LPINTERFACEIMPL)(lpThis))->cRef < 0) ? \
  87.                 ( \
  88.                     OleDbgOut(  \
  89.                         "\tERROR: " iface "* RELEASED TOO MANY TIMES\r\n") \
  90.         ),1 : \
  91.                 1)
  92.  
  93. #endif      // if _DEBUGLEVEL < 2
  94.  
  95. #else       // ! defined (_DEBUG)
  96.  
  97. #define OleDbgQueryInterfaceMethod(lpUnk)
  98. #define OleDbgAddRefMethod(lpThis, iface)
  99. #define OleDbgReleaseMethod(lpThis, iface)
  100.  
  101. #endif      // if defined( _DEBUG )
  102.  
  103. #endif      // ! defined(__cplusplus)
  104.  
  105. /*
  106.  * Some docfiles stuff
  107.  */
  108.  
  109. #define STGM_DFRALL (STGM_READWRITE | STGM_TRANSACTED | STGM_SHARE_DENY_WRITE)
  110. #define STGM_DFALL (STGM_READWRITE | STGM_TRANSACTED | STGM_SHARE_EXCLUSIVE)
  111. #define STGM_SALL (STGM_READWRITE | STGM_SHARE_EXCLUSIVE)
  112.  
  113. /*
  114.  * Some moniker stuff
  115.  */
  116.  
  117. // Delimeter used to separate ItemMoniker pieces of a composite moniker
  118. #if defined( _MAC )
  119. #define OLESTDDELIM ":"
  120. #else
  121. #define OLESTDDELIM "\\"
  122. #endif
  123.  
  124. /*
  125.  * Some Concurrency stuff
  126.  */
  127.  
  128. /* standard Delay (in msec) to wait before retrying an LRPC call.
  129. **    this value is returned from IMessageFilter::RetryRejectedCall
  130. */
  131. #define OLESTDRETRYDELAY    (DWORD)5000
  132.  
  133. /* Cancel the pending outgoing LRPC call.
  134. **    this value is returned from IMessageFilter::RetryRejectedCall
  135. */
  136. #define OLESTDCANCELRETRY   (DWORD)-1
  137.  
  138. /*
  139.  * Some Icon support stuff.
  140.  *
  141.  * The following API's are now OBSOLETE because equivalent API's have been
  142.  * added to the OLE2.DLL library
  143.  *      GetIconOfFile       superceeded by OleGetIconOfFile
  144.  *      GetIconOfClass      superceeded by OleGetIconOfClass
  145.  *      OleUIMetafilePictFromIconAndLabel
  146.  *                          superceeded by OleMetafilePictFromIconAndLabel
  147.  *
  148.  * The following macros are defined for backward compatibility with previous
  149.  * versions of the OLE2UI library. It is recommended that the new Ole* API's
  150.  * should be used instead.
  151.  */
  152. #define GetIconOfFile(hInst, lpszFileName, fUseFileAsLabel) \
  153.     OleGetIconOfFile(lpszFileName, fUseFileAsLabel)
  154.  
  155. #define GetIconOfClass(hInst, rclsid, lpszLabel, fUseTypeAsLabel) \
  156.     OleGetIconOfClass(rclsid, lpszLabel, fUseTypeAsLabel)
  157.  
  158. #define OleUIMetafilePictFromIconAndLabel(hIcon,pszLabel,pszSourceFile,iIcon)\
  159.     OleMetafilePictFromIconAndLabel(hIcon, pszLabel, pszSourceFile, iIcon)
  160.  
  161.  
  162. /*
  163.  * Some Clipboard Copy/Paste & Drag/Drop support stuff
  164.  */
  165.  
  166. //Macro to set all FormatEtc fields
  167. #define SETFORMATETC(fe, cf, asp, td, med, li)   \
  168.     ((fe).cfFormat=cf, \
  169.      (fe).dwAspect=asp, \
  170.      (fe).ptd=td, \
  171.      (fe).tymed=med, \
  172.      (fe).lindex=li)
  173.  
  174. //Macro to set interesting FormatEtc fields defaulting the others.
  175. #define SETDEFAULTFORMATETC(fe, cf, med)  \
  176.     ((fe).cfFormat=cf, \
  177.      (fe).dwAspect=DVASPECT_CONTENT, \
  178.      (fe).ptd=NULL, \
  179.      (fe).tymed=med, \
  180.      (fe).lindex=-1)
  181.  
  182. // Macro to test if two FormatEtc structures are an exact match
  183. #define IsEqualFORMATETC(fe1, fe2)  \
  184.     (OleStdCompareFormatEtc(&(fe1), &(fe2))==0)
  185.  
  186. // Clipboard format strings
  187. #define CF_EMBEDSOURCE      "Embed Source"
  188. #define CF_EMBEDDEDOBJECT   "Embedded Object"
  189. #define CF_LINKSOURCE       "Link Source"
  190. #define CF_CUSTOMLINKSOURCE "Custom Link Source"
  191. #define CF_OBJECTDESCRIPTOR "Object Descriptor"
  192. #define CF_LINKSRCDESCRIPTOR "Link Source Descriptor"
  193. #define CF_OWNERLINK        "OwnerLink"
  194. #define CF_FILENAME         "FileName"
  195.  
  196. #define OleStdQueryOleObjectData(lpformatetc)   \
  197.     (((lpformatetc)->tymed & TYMED_ISTORAGE) ?    \
  198.             NOERROR : ResultFromScode(DV_E_FORMATETC))
  199.  
  200. #define OleStdQueryLinkSourceData(lpformatetc)   \
  201.     (((lpformatetc)->tymed & TYMED_ISTREAM) ?    \
  202.             NOERROR : ResultFromScode(DV_E_FORMATETC))
  203.  
  204. #define OleStdQueryObjectDescriptorData(lpformatetc)    \
  205.     (((lpformatetc)->tymed & TYMED_HGLOBAL) ?    \
  206.             NOERROR : ResultFromScode(DV_E_FORMATETC))
  207.  
  208. #define OleStdQueryFormatMedium(lpformatetc, tymd)  \
  209.     (((lpformatetc)->tymed & tymd) ?    \
  210.             NOERROR : ResultFromScode(DV_E_FORMATETC))
  211.  
  212. // Make an independent copy of a MetafilePict
  213. #define OleStdCopyMetafilePict(hpictin, phpictout)  \
  214.     (*(phpictout) = OleDuplicateData(hpictin,CF_METAFILEPICT,GHND|GMEM_SHARE))
  215.  
  216.  
  217. // REVIEW: these need to be added to OLE2.H
  218. #if !defined( DD_DEFSCROLLINTERVAL )
  219. #define DD_DEFSCROLLINTERVAL    50
  220. #endif
  221.  
  222. #if !defined( DD_DEFDRAGDELAY )
  223. #define DD_DEFDRAGDELAY         200
  224. #endif
  225.  
  226. #if !defined( DD_DEFDRAGMINDIST )
  227. #define DD_DEFDRAGMINDIST       2
  228. #endif
  229.  
  230.  
  231. /* OleStdGetDropEffect
  232. ** -------------------
  233. **
  234. ** Convert a keyboard state into a DROPEFFECT.
  235. **
  236. ** returns the DROPEFFECT value derived from the key state.
  237. **    the following is the standard interpretation:
  238. **          no modifier -- Default Drop     (NULL is returned)
  239. **          CTRL        -- DROPEFFECT_COPY
  240. **          SHIFT       -- DROPEFFECT_MOVE
  241. **          CTRL-SHIFT  -- DROPEFFECT_LINK
  242. **
  243. **    Default Drop: this depends on the type of the target application.
  244. **    this is re-interpretable by each target application. a typical
  245. **    interpretation is if the drag is local to the same document
  246. **    (which is source of the drag) then a MOVE operation is
  247. **    performed. if the drag is not local, then a COPY operation is
  248. **    performed.
  249. */
  250. #define OleStdGetDropEffect(grfKeyState)    \
  251.     ( (grfKeyState & MK_CONTROL) ?          \
  252.         ( (grfKeyState & MK_SHIFT) ? DROPEFFECT_LINK : DROPEFFECT_COPY ) :  \
  253.         ( (grfKeyState & MK_SHIFT) ? DROPEFFECT_MOVE : 0 ) )
  254.  
  255.  
  256. /* The OLEUIPASTEFLAG enumeration is used by the OLEUIPASTEENTRY structure.
  257.  *
  258.  * OLEUIPASTE_ENABLEICON    If the container does not specify this flag for the entry in the
  259.  *   OLEUIPASTEENTRY array passed as input to OleUIPasteSpecial, the DisplayAsIcon button will be
  260.  *   unchecked and disabled when the the user selects the format that corresponds to the entry.
  261.  *
  262.  * OLEUIPASTE_PASTEONLY     Indicates that the entry in the OLEUIPASTEENTRY array is valid for pasting only.
  263.  * OLEUIPASTE_PASTE         Indicates that the entry in the OLEUIPASTEENTRY array is valid for pasting. It
  264.  *   may also be valid for linking if any of the following linking flags are specified.
  265.  *
  266.  * If the entry in the OLEUIPASTEENTRY array is valid for linking, the following flags indicate which link
  267.  * types are acceptable by OR'ing together the appropriate OLEUIPASTE_LINKTYPE<#> values.
  268.  * These values correspond as follows to the array of link types passed to OleUIPasteSpecial:
  269.  *   OLEUIPASTE_LINKTYPE1=arrLinkTypes[0]
  270.  *   OLEUIPASTE_LINKTYPE2=arrLinkTypes[1]
  271.  *   OLEUIPASTE_LINKTYPE3=arrLinkTypes[2]
  272.  *   OLEUIPASTE_LINKTYPE4=arrLinkTypes[3]
  273.  *   OLEUIPASTE_LINKTYPE5=arrLinkTypes[4]
  274.  *   OLEUIPASTE_LINKTYPE6=arrLinkTypes[5]
  275.  *   OLEUIPASTE_LINKTYPE7=arrLinkTypes[6]
  276.  *  OLEUIPASTE_LINKTYPE8=arrLinkTypes[7]
  277.  *
  278.  * where,
  279.  *   UINT arrLinkTypes[8] is an array of registered clipboard formats for linking. A maximium of 8 link
  280.  *   types are allowed.
  281.  */
  282.  
  283. typedef enum tagOLEUIPASTEFLAG
  284. {
  285.    OLEUIPASTE_ENABLEICON    = 2048,     // enable display as icon
  286.    OLEUIPASTE_PASTEONLY     = 0,
  287.    OLEUIPASTE_PASTE         = 512,
  288.    OLEUIPASTE_LINKANYTYPE   = 1024,
  289.    OLEUIPASTE_LINKTYPE1     = 1,
  290.    OLEUIPASTE_LINKTYPE2     = 2,
  291.    OLEUIPASTE_LINKTYPE3     = 4,
  292.    OLEUIPASTE_LINKTYPE4     = 8,
  293.    OLEUIPASTE_LINKTYPE5     = 16,
  294.    OLEUIPASTE_LINKTYPE6     = 32,
  295.    OLEUIPASTE_LINKTYPE7     = 64,
  296.    OLEUIPASTE_LINKTYPE8     = 128
  297. } OLEUIPASTEFLAG;
  298.  
  299. /*
  300.  * PasteEntry structure
  301.  * --------------------
  302.  * An array of OLEUIPASTEENTRY entries is specified for the PasteSpecial dialog
  303.  * box. Each entry includes a FORMATETC which specifies the formats that are
  304.  * acceptable, a string that is to represent the format in the  dialog's list
  305.  * box, a string to customize the result text of the dialog and a set of flags
  306.  * from the OLEUIPASTEFLAG enumeration.  The flags indicate if the entry is
  307.  * valid for pasting only, linking only or both pasting and linking. If the
  308.  * entry is valid for linking, the flags indicate which link types are
  309.  * acceptable by OR'ing together the appropriate OLEUIPASTE_LINKTYPE<#> values.
  310.  * These values correspond to the array of link types as follows:
  311.  *   OLEUIPASTE_LINKTYPE1=arrLinkTypes[0]
  312.  *   OLEUIPASTE_LINKTYPE2=arrLinkTypes[1]
  313.  *   OLEUIPASTE_LINKTYPE3=arrLinkTypes[2]
  314.  *   OLEUIPASTE_LINKTYPE4=arrLinkTypes[3]
  315.  *   OLEUIPASTE_LINKTYPE5=arrLinkTypes[4]
  316.  *   OLEUIPASTE_LINKTYPE6=arrLinkTypes[5]
  317.  *   OLEUIPASTE_LINKTYPE7=arrLinkTypes[6]
  318.  *   OLEUIPASTE_LINKTYPE8=arrLinkTypes[7]
  319.  *   UINT arrLinkTypes[8]; is an array of registered clipboard formats
  320.  *                        for linking. A maximium of 8 link types are allowed.
  321.  */
  322.  
  323. typedef struct tagOLEUIPASTEENTRY
  324. {
  325.    FORMATETC        fmtetc;            // Format that is acceptable. The paste
  326.                                        //   dialog checks if this format is
  327.                                        //   offered by the object on the
  328.                                        //   clipboard and if so offers it for
  329.                                        //   selection to the user.
  330.    LPCSTR           lpstrFormatName;   // String that represents the format to the user. Any %s
  331.                                        //   in this string is replaced by the FullUserTypeName
  332.                                        //   of the object on the clipboard and the resulting string
  333.                                        //   is placed in the list box of the dialog. Atmost
  334.                                        //   one %s is allowed. The presence or absence of %s indicates
  335.                                        //   if the result text is to indicate that data is
  336.                                        //   being pasted or that an object that can be activated by
  337.                                        //   an application is being pasted. If %s is
  338.                                        //   present, the result-text says that an object is being pasted.
  339.                                        //   Otherwise it says that data is being pasted.
  340.    LPCSTR           lpstrResultText;   // String to customize the result text of the dialog when
  341.                                        //  the user selects the format correspoding to this
  342.                                        //  entry. Any %s in this string is replaced by the the application
  343.                                        //  name or FullUserTypeName of the object on
  344.                                        //  the clipboard. Atmost one %s is allowed.
  345.    DWORD            dwFlags;           // Values from OLEUIPASTEFLAG enum
  346.    DWORD            dwScratchSpace;    // Scratch space available to be used
  347.                                        //   by routines which loop through an
  348.                                        //   IEnumFORMATETC* to mark if the
  349.                                        //   PasteEntry format is available.
  350.                                        //   this field CAN be left uninitialized.
  351. } OLEUIPASTEENTRY, *POLEUIPASTEENTRY, FAR *LPOLEUIPASTEENTRY;
  352.  
  353. #define OLESTDDROP_NONE         0
  354. #define OLESTDDROP_DEFAULT      1
  355. #define OLESTDDROP_NONDEFAULT   2
  356.  
  357.  
  358. /*
  359.  * Some misc stuff
  360.  */
  361.  
  362. #define EMBEDDINGFLAG "Embedding"     // Cmd line switch for launching a srvr
  363.  
  364. #define HIMETRIC_PER_INCH   2540      // number HIMETRIC units per inch
  365. #define PTS_PER_INCH        72        // number points (font size) per inch
  366.  
  367. #if 0
  368.     #if 0
  369.     #define MAP_PIX_TO_LOGHIM(x,ppli)   MulDiv(HIMETRIC_PER_INCH, (x), (ppli))
  370.     #define MAP_LOGHIM_TO_PIX(x,ppli)   MulDiv((ppli), (x), HIMETRIC_PER_INCH)
  371.     #else
  372.  
  373.     #define MAP_PIX_TO_LOGHIM(pixel, pixelsPerInch) \
  374.         ((ULONG) ((((ULONG)HIMETRIC_PER_INCH) * pixel) / pixelsPerInch))
  375.  
  376.     #define MAP_LOGHIM_TO_PIX(hiMetric, pixelsPerInch) \
  377.         (UINT) ((((double) hiMetric) * pixelsPerInch) / HIMETRIC_PER_INCH)
  378.  
  379.     #endif
  380. #else
  381.     #define MAP_PIX_TO_LOGHIM(pixel, pixelsPerInch) \
  382.         ((ULONG) ((((ULONG)HIMETRIC_PER_INCH) * pixel + (pixelsPerInch >> 1)) / pixelsPerInch))
  383.     #define MAP_LOGHIM_TO_PIX(hiMetric, pixelsPerInch) \
  384.      (UINT) ((((double) hiMetric) * pixelsPerInch + (HIMETRIC_PER_INCH >> 1)) / HIMETRIC_PER_INCH)
  385. #endif
  386.  
  387. // Returns TRUE if all fields of the two Rect's are equal, else FALSE.
  388. #define AreRectsEqual(lprc1, lprc2)     \
  389.     (((lprc1->top == lprc2->top) &&     \
  390.       (lprc1->left == lprc2->left) &&   \
  391.       (lprc1->right == lprc2->right) && \
  392.       (lprc1->bottom == lprc2->bottom)) ? TRUE : FALSE)
  393.  
  394. #define LSTRCPYN(lpdst, lpsrc, cch) \
  395. (\
  396.     (lpdst)[(cch)-1] = '\0', \
  397.     (cch>1 ? lstrcpyn(lpdst, lpsrc, (cch)-1) : 0)\
  398. )
  399.  
  400.  
  401. /****** DEBUG Stuff *****************************************************/
  402.  
  403. #ifdef _DEBUG
  404.  
  405. #if !defined( _DBGTRACE )
  406. #define _DEBUGLEVEL 2
  407. #else
  408. #define _DEBUGLEVEL _DBGTRACE
  409. #endif
  410.  
  411.  
  412. #if defined( NOASSERT )
  413.  
  414. #define OLEDBGASSERTDATA
  415. #define OleDbgAssert(a)
  416. #define OleDbgAssertSz(a, b)
  417. #define OleDbgVerify(a)
  418. #define OleDbgVerifySz(a, b)
  419.  
  420. #else   // ! NOASSERT
  421.  
  422. #define OLEDBGASSERTDATA    \
  423.         static char _based(_segname("_CODE")) _szAssertFile[]= __FILE__;
  424.  
  425. #define OleDbgAssert(a) \
  426.         (!(a) ? FnAssert(#a, NULL, _szAssertFile, __LINE__) : (HRESULT)1)
  427.  
  428. #define OleDbgAssertSz(a, b)    \
  429.         (!(a) ? FnAssert(#a, b, _szAssertFile, __LINE__) : (HRESULT)1)
  430.  
  431. #define OleDbgVerify(a) \
  432.         OleDbgAssert(a)
  433.  
  434. #define OleDbgVerifySz(a, b)    \
  435.         OleDbgAssertSz(a, b)
  436.  
  437. #endif  // ! NOASSERT
  438.  
  439.  
  440. #define OLEDBGDATA_MAIN(szPrefix)   \
  441.         char near g_szDbgPrefix[] = szPrefix;    \
  442.         OLEDBGASSERTDATA
  443. #define OLEDBGDATA  \
  444.         extern char near g_szDbgPrefix[];    \
  445.         OLEDBGASSERTDATA
  446.  
  447. #define OLEDBG_BEGIN(lpsz) \
  448.         OleDbgPrintAlways(g_szDbgPrefix,lpsz,1);
  449.  
  450. #define OLEDBG_END  \
  451.         OleDbgPrintAlways(g_szDbgPrefix,"End\r\n",-1);
  452.  
  453. #define OleDbgOut(lpsz) \
  454.         OleDbgPrintAlways(g_szDbgPrefix,lpsz,0)
  455.  
  456. #define OleDbgOutNoPrefix(lpsz) \
  457.         OleDbgPrintAlways("",lpsz,0)
  458.  
  459. #define OleDbgOutRefCnt(lpsz,lpObj,refcnt)      \
  460.         OleDbgPrintRefCntAlways(g_szDbgPrefix,lpsz,lpObj,(ULONG)refcnt)
  461.  
  462. #define OleDbgOutRect(lpsz,lpRect)      \
  463.         OleDbgPrintRectAlways(g_szDbgPrefix,lpsz,lpRect)
  464.  
  465. #define OleDbgOutHResult(lpsz,hr)   \
  466.         OleDbgPrintScodeAlways(g_szDbgPrefix,lpsz,GetScode(hr))
  467.  
  468. #define OleDbgOutScode(lpsz,sc) \
  469.         OleDbgPrintScodeAlways(g_szDbgPrefix,lpsz,sc)
  470.  
  471. #define OleDbgOut1(lpsz)    \
  472.         OleDbgPrint(1,g_szDbgPrefix,lpsz,0)
  473.  
  474. #define OleDbgOutNoPrefix1(lpsz)    \
  475.         OleDbgPrint(1,"",lpsz,0)
  476.  
  477. #define OLEDBG_BEGIN1(lpsz)    \
  478.         OleDbgPrint(1,g_szDbgPrefix,lpsz,1);
  479.  
  480. #define OLEDBG_END1 \
  481.         OleDbgPrint(1,g_szDbgPrefix,"End\r\n",-1);
  482.  
  483. #define OleDbgOutRefCnt1(lpsz,lpObj,refcnt)     \
  484.         OleDbgPrintRefCnt(1,g_szDbgPrefix,lpsz,lpObj,(ULONG)refcnt)
  485.  
  486. #define OleDbgOutRect1(lpsz,lpRect)     \
  487.         OleDbgPrintRect(1,g_szDbgPrefix,lpsz,lpRect)
  488.  
  489. #define OleDbgOut2(lpsz)    \
  490.         OleDbgPrint(2,g_szDbgPrefix,lpsz,0)
  491.  
  492. #define OleDbgOutNoPrefix2(lpsz)    \
  493.         OleDbgPrint(2,"",lpsz,0)
  494.  
  495. #define OLEDBG_BEGIN2(lpsz)    \
  496.         OleDbgPrint(2,g_szDbgPrefix,lpsz,1);
  497.  
  498. #define OLEDBG_END2 \
  499.         OleDbgPrint(2,g_szDbgPrefix,"End\r\n",-1);
  500.  
  501. #define OleDbgOutRefCnt2(lpsz,lpObj,refcnt)     \
  502.         OleDbgPrintRefCnt(2,g_szDbgPrefix,lpsz,lpObj,(ULONG)refcnt)
  503.  
  504. #define OleDbgOutRect2(lpsz,lpRect)     \
  505.         OleDbgPrintRect(2,g_szDbgPrefix,lpsz,lpRect)
  506.  
  507. #define OleDbgOut3(lpsz)    \
  508.         OleDbgPrint(3,g_szDbgPrefix,lpsz,0)
  509.  
  510. #define OleDbgOutNoPrefix3(lpsz)    \
  511.         OleDbgPrint(3,"",lpsz,0)
  512.  
  513. #define OLEDBG_BEGIN3(lpsz)    \
  514.         OleDbgPrint(3,g_szDbgPrefix,lpsz,1);
  515.  
  516. #define OLEDBG_END3 \
  517.         OleDbgPrint(3,g_szDbgPrefix,"End\r\n",-1);
  518.  
  519. #define OleDbgOutRefCnt3(lpsz,lpObj,refcnt)     \
  520.         OleDbgPrintRefCnt(3,g_szDbgPrefix,lpsz,lpObj,(ULONG)refcnt)
  521.  
  522. #define OleDbgOutRect3(lpsz,lpRect)     \
  523.         OleDbgPrintRect(3,g_szDbgPrefix,lpsz,lpRect)
  524.  
  525. #define OleDbgOut4(lpsz)    \
  526.         OleDbgPrint(4,g_szDbgPrefix,lpsz,0)
  527.  
  528. #define OleDbgOutNoPrefix4(lpsz)    \
  529.         OleDbgPrint(4,"",lpsz,0)
  530.  
  531. #define OLEDBG_BEGIN4(lpsz)    \
  532.         OleDbgPrint(4,g_szDbgPrefix,lpsz,1);
  533.  
  534. #define OLEDBG_END4 \
  535.         OleDbgPrint(4,g_szDbgPrefix,"End\r\n",-1);
  536.  
  537. #define OleDbgOutRefCnt4(lpsz,lpObj,refcnt)     \
  538.         OleDbgPrintRefCnt(4,g_szDbgPrefix,lpsz,lpObj,(ULONG)refcnt)
  539.  
  540. #define OleDbgOutRect4(lpsz,lpRect)     \
  541.         OleDbgPrintRect(4,g_szDbgPrefix,lpsz,lpRect)
  542.  
  543. #else   //  !_DEBUG
  544.  
  545. #define OLEDBGDATA_MAIN(szPrefix)
  546. #define OLEDBGDATA
  547. #define OleDbgAssert(a)
  548. #define OleDbgAssertSz(a, b)
  549. #define OleDbgVerify(a)         (a)
  550. #define OleDbgVerifySz(a, b)    (a)
  551. #define OleDbgOutHResult(lpsz,hr)
  552. #define OleDbgOutScode(lpsz,sc)
  553. #define OLEDBG_BEGIN(lpsz)
  554. #define OLEDBG_END
  555. #define OleDbgOut(lpsz)
  556. #define OleDbgOut1(lpsz)
  557. #define OleDbgOut2(lpsz)
  558. #define OleDbgOut3(lpsz)
  559. #define OleDbgOut4(lpsz)
  560. #define OleDbgOutNoPrefix(lpsz)
  561. #define OleDbgOutNoPrefix1(lpsz)
  562. #define OleDbgOutNoPrefix2(lpsz)
  563. #define OleDbgOutNoPrefix3(lpsz)
  564. #define OleDbgOutNoPrefix4(lpsz)
  565. #define OLEDBG_BEGIN1(lpsz)
  566. #define OLEDBG_BEGIN2(lpsz)
  567. #define OLEDBG_BEGIN3(lpsz)
  568. #define OLEDBG_BEGIN4(lpsz)
  569. #define OLEDBG_END1
  570. #define OLEDBG_END2
  571. #define OLEDBG_END3
  572. #define OLEDBG_END4
  573. #define OleDbgOutRefCnt(lpsz,lpObj,refcnt)
  574. #define OleDbgOutRefCnt1(lpsz,lpObj,refcnt)
  575. #define OleDbgOutRefCnt2(lpsz,lpObj,refcnt)
  576. #define OleDbgOutRefCnt3(lpsz,lpObj,refcnt)
  577. #define OleDbgOutRefCnt4(lpsz,lpObj,refcnt)
  578. #define OleDbgOutRect(lpsz,lpRect)
  579. #define OleDbgOutRect1(lpsz,lpRect)
  580. #define OleDbgOutRect2(lpsz,lpRect)
  581. #define OleDbgOutRect3(lpsz,lpRect)
  582. #define OleDbgOutRect4(lpsz,lpRect)
  583.  
  584. #endif  //  _DEBUG
  585.  
  586.  
  587. /*************************************************************************
  588. ** Function prototypes
  589. *************************************************************************/
  590.  
  591.  
  592. //OLESTD.C
  593. STDAPI_(int) SetDCToAnisotropic(HDC hDC, LPRECT lprcPhysical, LPRECT lprcLogical, LPRECT lprcWindowOld, LPRECT lprcViewportOld);
  594. STDAPI_(int) SetDCToDrawInHimetricRect(HDC, LPRECT, LPRECT, LPRECT, LPRECT);
  595. STDAPI_(int) ResetOrigDC(HDC, int, LPRECT, LPRECT);
  596.  
  597. STDAPI_(int)        XformWidthInHimetricToPixels(HDC, int);
  598. STDAPI_(int)        XformWidthInPixelsToHimetric(HDC, int);
  599. STDAPI_(int)        XformHeightInHimetricToPixels(HDC, int);
  600. STDAPI_(int)        XformHeightInPixelsToHimetric(HDC, int);
  601.  
  602. STDAPI_(void) XformRectInPixelsToHimetric(HDC, LPRECT, LPRECT);
  603. STDAPI_(void) XformRectInHimetricToPixels(HDC, LPRECT, LPRECT);
  604. STDAPI_(void) XformSizeInPixelsToHimetric(HDC, LPSIZEL, LPSIZEL);
  605. STDAPI_(void) XformSizeInHimetricToPixels(HDC, LPSIZEL, LPSIZEL);
  606. STDAPI_(int) XformWidthInHimetricToPixels(HDC, int);
  607. STDAPI_(int) XformWidthInPixelsToHimetric(HDC, int);
  608. STDAPI_(int) XformHeightInHimetricToPixels(HDC, int);
  609. STDAPI_(int) XformHeightInPixelsToHimetric(HDC, int);
  610.  
  611. STDAPI_(void) ParseCmdLine(LPSTR, BOOL FAR *, LPSTR);
  612.  
  613. STDAPI_(BOOL) OleStdIsOleLink(LPUNKNOWN lpUnk);
  614. STDAPI_(LPUNKNOWN) OleStdQueryInterface(LPUNKNOWN lpUnk, REFIID riid);
  615. STDAPI_(LPSTORAGE) OleStdCreateRootStorage(LPSTR lpszStgName, DWORD grfMode);
  616. STDAPI_(LPSTORAGE) OleStdOpenRootStorage(LPSTR lpszStgName, DWORD grfMode);
  617. STDAPI_(LPSTORAGE) OleStdOpenOrCreateRootStorage(LPSTR lpszStgName, DWORD grfMode);
  618. STDAPI_(LPSTORAGE) OleStdCreateChildStorage(LPSTORAGE lpStg, LPSTR lpszStgName);
  619. STDAPI_(LPSTORAGE) OleStdOpenChildStorage(LPSTORAGE lpStg, LPSTR lpszStgName, DWORD grfMode);
  620. STDAPI_(BOOL) OleStdCommitStorage(LPSTORAGE lpStg);
  621. STDAPI OleStdDestroyAllElements(LPSTORAGE lpStg);
  622.  
  623. STDAPI_(LPSTORAGE) OleStdCreateStorageOnHGlobal(
  624.         HANDLE hGlobal,
  625.         BOOL fDeleteOnRelease,
  626.         DWORD dwgrfMode
  627. );
  628. STDAPI_(LPSTORAGE) OleStdCreateTempStorage(BOOL fUseMemory, DWORD grfMode);
  629. STDAPI OleStdDoConvert(LPSTORAGE lpStg, REFCLSID rClsidNew);
  630. STDAPI_(BOOL) OleStdGetTreatAsFmtUserType(
  631.         REFCLSID        rClsidApp,
  632.         LPSTORAGE       lpStg,
  633.         CLSID FAR*      lpclsid,
  634.         CLIPFORMAT FAR* lpcfFmt,
  635.         LPSTR FAR*      lplpszType
  636. );
  637. STDAPI OleStdDoTreatAsClass(LPSTR lpszUserType, REFCLSID rclsid, REFCLSID rclsidNew);
  638. STDAPI_(BOOL) OleStdSetupAdvises(LPOLEOBJECT lpOleObject, DWORD dwDrawAspect,
  639.                     LPSTR lpszContainerApp, LPSTR lpszContainerObj,
  640.                     LPADVISESINK lpAdviseSink, BOOL fCreate);
  641. STDAPI OleStdSwitchDisplayAspect(
  642.         LPOLEOBJECT             lpOleObj,
  643.         LPDWORD                 lpdwCurAspect,
  644.         DWORD                   dwNewAspect,
  645.         HGLOBAL                 hMetaPict,
  646.         BOOL                    fDeleteOldAspect,
  647.         BOOL                    fSetupViewAdvise,
  648.         LPADVISESINK            lpAdviseSink,
  649.         BOOL FAR*               lpfMustUpdate
  650. );
  651. STDAPI OleStdSetIconInCache(LPOLEOBJECT lpOleObj, HGLOBAL hMetaPict);
  652. STDAPI_(HGLOBAL) OleStdGetData(
  653.         LPDATAOBJECT        lpDataObj,
  654.         CLIPFORMAT          cfFormat,
  655.         DVTARGETDEVICE FAR* lpTargetDevice,
  656.         DWORD               dwAspect,
  657.         LPSTGMEDIUM         lpMedium
  658. );
  659. STDAPI_(void) OleStdMarkPasteEntryList(
  660.         LPDATAOBJECT        lpSrcDataObj,
  661.         LPOLEUIPASTEENTRY   lpPriorityList,
  662.         int                 cEntries
  663. );
  664. STDAPI_(int) OleStdGetPriorityClipboardFormat(
  665.         LPDATAOBJECT        lpSrcDataObj,
  666.         LPOLEUIPASTEENTRY   lpPriorityList,
  667.         int                 cEntries
  668. );
  669. STDAPI_(BOOL) OleStdIsDuplicateFormat(
  670.         LPFORMATETC         lpFmtEtc,
  671.         LPFORMATETC         arrFmtEtc,
  672.         int                 nFmtEtc
  673. );
  674. STDAPI_(void) OleStdRegisterAsRunning(LPUNKNOWN lpUnk, LPMONIKER lpmkFull, DWORD FAR* lpdwRegister);
  675. STDAPI_(void) OleStdRevokeAsRunning(DWORD FAR* lpdwRegister);
  676. STDAPI_(void) OleStdNoteFileChangeTime(LPSTR lpszFileName, DWORD dwRegister);
  677. STDAPI_(void) OleStdNoteObjectChangeTime(DWORD dwRegister);
  678. STDAPI OleStdGetOleObjectData(
  679.         LPPERSISTSTORAGE    lpPStg,
  680.         LPFORMATETC         lpformatetc,
  681.         LPSTGMEDIUM         lpMedium,
  682.         BOOL                fUseMemory
  683. );
  684. STDAPI OleStdGetLinkSourceData(
  685.         LPMONIKER           lpmk,
  686.         LPCLSID             lpClsID,
  687.         LPFORMATETC         lpformatetc,
  688.         LPSTGMEDIUM         lpMedium
  689. );
  690. STDAPI_(HGLOBAL) OleStdGetObjectDescriptorData(
  691.         CLSID               clsid,
  692.         DWORD               dwAspect,
  693.         SIZEL               sizel,
  694.         POINTL              pointl,
  695.         DWORD               dwStatus,
  696.         LPSTR               lpszFullUserTypeName,
  697.         LPSTR               lpszSrcOfCopy
  698. );
  699. STDAPI_(HGLOBAL) OleStdGetObjectDescriptorDataFromOleObject(
  700.         LPOLEOBJECT         lpOleObj,
  701.         LPSTR               lpszSrcOfCopy,
  702.         DWORD               dwAspect,
  703.         POINTL              pointl,
  704.         LPSIZEL             lpSizelHim
  705. );
  706. STDAPI_(HGLOBAL) OleStdFillObjectDescriptorFromData(
  707.         LPDATAOBJECT       lpDataObject,
  708.         LPSTGMEDIUM        lpmedium,
  709.         CLIPFORMAT FAR*    lpcfFmt
  710. );
  711. STDAPI_(HANDLE) OleStdGetMetafilePictFromOleObject(
  712.         LPOLEOBJECT         lpOleObj,
  713.         DWORD               dwDrawAspect,
  714.         LPSIZEL             lpSizelHim,
  715.         DVTARGETDEVICE FAR* ptd
  716. );
  717.  
  718. STDAPI_(void) OleStdCreateTempFileMoniker(LPSTR lpszPrefixString, UINT FAR* lpuUnique, LPSTR lpszName, LPMONIKER FAR* lplpmk);
  719. STDAPI_(LPMONIKER) OleStdGetFirstMoniker(LPMONIKER lpmk);
  720. STDAPI_(ULONG) OleStdGetLenFilePrefixOfMoniker(LPMONIKER lpmk);
  721. STDAPI OleStdMkParseDisplayName(
  722.         REFCLSID        rClsid,
  723.         LPBC            lpbc,
  724.         LPSTR           lpszUserName,
  725.         ULONG FAR*      lpchEaten,
  726.         LPMONIKER FAR*  lplpmk
  727. );
  728. STDAPI_(LPVOID) OleStdMalloc(ULONG ulSize);
  729. STDAPI_(LPVOID) OleStdRealloc(LPVOID pmem, ULONG ulSize);
  730. STDAPI_(void) OleStdFree(LPVOID pmem);
  731. STDAPI_(ULONG) OleStdGetSize(LPVOID pmem);
  732. STDAPI_(void) OleStdFreeString(LPSTR lpsz, LPMALLOC lpMalloc);
  733. STDAPI_(LPSTR) OleStdCopyString(LPSTR lpszSrc, LPMALLOC lpMalloc);
  734. STDAPI_(ULONG) OleStdGetItemToken(LPSTR lpszSrc, LPSTR lpszDst,int nMaxChars);
  735.  
  736. STDAPI_(UINT)     OleStdIconLabelTextOut(HDC        hDC,
  737.                                          HFONT      hFont,
  738.                                          int        nXStart,
  739.                                          int        nYStart,
  740.                                          UINT       fuOptions,
  741.                                          RECT FAR * lpRect,
  742.                                          LPSTR      lpszString,
  743.                                          UINT       cchString,
  744.                                          int FAR *  lpDX);
  745.  
  746. // registration database query functions
  747. STDAPI_(UINT)     OleStdGetAuxUserType(REFCLSID rclsid,
  748.                                       WORD   wAuxUserType,
  749.                                       LPSTR  lpszAuxUserType,
  750.                                       int    cch,
  751.                                       HKEY   hKey);
  752.  
  753. STDAPI_(UINT)     OleStdGetUserTypeOfClass(REFCLSID rclsid,
  754.                                            LPSTR lpszUserType,
  755.                                            UINT cch,
  756.                                            HKEY hKey);
  757.  
  758. STDAPI_(BOOL) OleStdGetMiscStatusOfClass(REFCLSID, HKEY, DWORD FAR *);
  759. STDAPI_(CLIPFORMAT) OleStdGetDefaultFileFormatOfClass(
  760.         REFCLSID        rclsid,
  761.         HKEY            hKey
  762. );
  763.  
  764. STDAPI_(void) OleStdInitVtbl(LPVOID lpVtbl, UINT nSizeOfVtbl);
  765. STDMETHODIMP OleStdNullMethod(LPUNKNOWN lpThis);
  766. STDAPI_(BOOL) OleStdCheckVtbl(LPVOID lpVtbl, UINT nSizeOfVtbl, LPSTR lpszIface);
  767. STDAPI_(ULONG) OleStdVerifyRelease(LPUNKNOWN lpUnk, LPSTR lpszMsg);
  768. STDAPI_(ULONG) OleStdRelease(LPUNKNOWN lpUnk);
  769.  
  770. STDAPI_(HDC) OleStdCreateDC(DVTARGETDEVICE FAR* ptd);
  771. STDAPI_(HDC) OleStdCreateIC(DVTARGETDEVICE FAR* ptd);
  772. STDAPI_(DVTARGETDEVICE FAR*) OleStdCreateTargetDevice(LPPRINTDLG lpPrintDlg);
  773. STDAPI_(BOOL) OleStdDeleteTargetDevice(DVTARGETDEVICE FAR* ptd);
  774. STDAPI_(DVTARGETDEVICE FAR*) OleStdCopyTargetDevice(DVTARGETDEVICE FAR* ptdSrc);
  775. STDAPI_(BOOL) OleStdCopyFormatEtc(LPFORMATETC petcDest, LPFORMATETC petcSrc);
  776. STDAPI_(int) OleStdCompareFormatEtc(FORMATETC FAR* pFetcLeft, FORMATETC FAR* pFetcRight);
  777. STDAPI_(BOOL) OleStdCompareTargetDevice
  778.     (DVTARGETDEVICE FAR* ptdLeft, DVTARGETDEVICE FAR* ptdRight);
  779.  
  780.  
  781. STDAPI_(void) OleDbgPrint(
  782.         int     nDbgLvl,
  783.         LPSTR   lpszPrefix,
  784.         LPSTR   lpszMsg,
  785.         int     nIndent
  786. );
  787. STDAPI_(void) OleDbgPrintAlways(LPSTR lpszPrefix, LPSTR lpszMsg, int nIndent);
  788. STDAPI_(void) OleDbgSetDbgLevel(int nDbgLvl);
  789. STDAPI_(int) OleDbgGetDbgLevel( void );
  790. STDAPI_(void) OleDbgIndent(int n);
  791. STDAPI_(void) OleDbgPrintRefCnt(
  792.         int         nDbgLvl,
  793.         LPSTR       lpszPrefix,
  794.         LPSTR       lpszMsg,
  795.         LPVOID      lpObj,
  796.         ULONG       refcnt
  797. );
  798. STDAPI_(void) OleDbgPrintRefCntAlways(
  799.         LPSTR       lpszPrefix,
  800.         LPSTR       lpszMsg,
  801.         LPVOID      lpObj,
  802.         ULONG       refcnt
  803. );
  804. STDAPI_(void) OleDbgPrintRect(
  805.         int         nDbgLvl,
  806.         LPSTR       lpszPrefix,
  807.         LPSTR       lpszMsg,
  808.         LPRECT      lpRect
  809. );
  810. STDAPI_(void) OleDbgPrintRectAlways(
  811.         LPSTR       lpszPrefix,
  812.         LPSTR       lpszMsg,
  813.         LPRECT      lpRect
  814. );
  815. STDAPI_(void) OleDbgPrintScodeAlways(LPSTR lpszPrefix, LPSTR lpszMsg, SCODE sc);
  816.  
  817. // debug implementation of the IMalloc interface.
  818. STDAPI OleStdCreateDbAlloc(ULONG reserved, IMalloc FAR* FAR* ppmalloc);
  819.  
  820.  
  821. STDAPI_(LPENUMFORMATETC)
  822.   OleStdEnumFmtEtc_Create(ULONG nCount, LPFORMATETC lpEtc);
  823.  
  824. STDAPI_(LPENUMSTATDATA)
  825.   OleStdEnumStatData_Create(ULONG nCount, LPSTATDATA lpStat);
  826.  
  827. STDAPI_(BOOL)
  828.   OleStdCopyStatData(LPSTATDATA pDest, LPSTATDATA pSrc);
  829.  
  830. STDAPI_(HPALETTE)
  831.   OleStdCreateStandardPalette(void);
  832.  
  833. #if defined( OBSOLETE )
  834.  
  835. /*************************************************************************
  836. ** The following API's have been converted into macros:
  837. **          OleStdQueryOleObjectData
  838. **          OleStdQueryLinkSourceData
  839. **          OleStdQueryObjectDescriptorData
  840. **          OleStdQueryFormatMedium
  841. **          OleStdCopyMetafilePict
  842. **          AreRectsEqual
  843. **          OleStdGetDropEffect
  844. **
  845. **    These macros are defined above
  846. *************************************************************************/
  847. STDAPI_(BOOL) AreRectsEqual(LPRECT lprc1, LPRECT lprc2);
  848. STDAPI_(BOOL) OleStdCopyMetafilePict(HANDLE hpictin, HANDLE FAR* phpictout);
  849. STDAPI OleStdQueryOleObjectData(LPFORMATETC lpformatetc);
  850. STDAPI OleStdQueryLinkSourceData(LPFORMATETC lpformatetc);
  851. STDAPI OleStdQueryObjectDescriptorData(LPFORMATETC lpformatetc);
  852. STDAPI OleStdQueryFormatMedium(LPFORMATETC lpformatetc, TYMED tymed);
  853. STDAPI_(DWORD) OleStdGetDropEffect ( DWORD grfKeyState );
  854. #endif  // OBSOLETE
  855.  
  856. #endif  /* RC_INVOKED */
  857.  
  858. #endif // _OLESTD_H_
  859.  
  860.