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