home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / BOCOLE.PAK / BOLEDATA.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  4.6 KB  |  147 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectComponents
  3. // Copyright (c) 1994, 1996 by Borland International, All Rights Reserved
  4. //
  5. // $Revision:   2.2  $
  6. //
  7. // Implements a data cache object which is used for delayed rendering.
  8. //
  9. //  Bolero customers aren't required to use this object (or delayed rendering 
  10. //  at all) but when we cut/copy an embedded object (i.e. embed from 
  11. //  embedding) we need the data cache to avoid getting changes to the 
  12. //  original object when the user expects a snapshot (the usual delayed 
  13. //  rendering problem).
  14. //----------------------------------------------------------------------------
  15. #ifndef _BOLEDATA_H
  16. #define _BOLEDATA_H 
  17.  
  18. #include "BOle.h"
  19. #include "BOleComp.h"
  20.  
  21. // This is where the cached data actually lives.
  22. //
  23. typedef struct FAR tagBOleDataItem {
  24.     struct FAR tagBOleDataItem FAR *pNext;
  25.     FORMATETC    fmtEtc;
  26.     STGMEDIUM    tymed;
  27. } BOleDataItem;
  28.  
  29. // BOleData -- Provides a data cache object for use when copying from
  30. //             an embedding.
  31. //
  32. class _ICLASS BOleData : public BOleComponent, 
  33.                          public IDataObject
  34. {
  35.     public:
  36.  
  37.         BOleData (BOleClassManager *, PIBUnknownMain);
  38.         ~BOleData ();
  39.  
  40.         // IUnknown Methods
  41.         //
  42.         DEFINE_IUNKNOWN (pObjOuter);
  43.         HRESULT _IFUNC QueryInterfaceMain (REFIID iid, LPVOID FAR* pif);
  44.  
  45.     protected:
  46.  
  47.         BOleDataItem FAR *pFirstItem;
  48.         BOleDataItem FAR *pLastItem;
  49.         void FreeItems();
  50.  
  51.         friend  class _ICLASS  BOleEnumFormatEtc;
  52.  
  53.         // IDataObject methods
  54.         //
  55.         virtual HRESULT _IFUNC GetData (LPFORMATETC, LPSTGMEDIUM);
  56.         virtual HRESULT _IFUNC GetDataHere (LPFORMATETC, LPSTGMEDIUM);
  57.         virtual HRESULT _IFUNC QueryGetData (LPFORMATETC);
  58.         virtual HRESULT _IFUNC GetCanonicalFormatEtc (LPFORMATETC, LPFORMATETC);
  59.         virtual HRESULT _IFUNC SetData (LPFORMATETC, STGMEDIUM FAR *, BOOL);
  60.         virtual HRESULT _IFUNC EnumFormatEtc (DWORD, LPENUMFORMATETC FAR*);
  61.         virtual HRESULT _IFUNC DAdvise (FORMATETC FAR*, DWORD, LPADVISESINK, DWORD FAR*);
  62.         virtual HRESULT _IFUNC DUnadvise (DWORD);
  63.         virtual HRESULT _IFUNC EnumDAdvise (LPENUMSTATDATA FAR*);
  64.  
  65. };
  66.  
  67. // BOleEnumFormatEtc -- Provides a "cursor" on the list of formats
  68. //                      offered by BOleData
  69. //
  70. class _ICLASS BOleEnumFormatEtc : public IEnumFORMATETC
  71. {
  72.     public:
  73.  
  74.     BOleEnumFormatEtc( BOleData *Data );
  75.  
  76.     // IUnknown methods
  77.     //
  78.     HRESULT _IFUNC QueryInterface(REFIID iid, void FAR* FAR* pif);
  79.     ULONG _IFUNC AddRef();
  80.     ULONG _IFUNC Release();
  81.  
  82.     // IEnumFORMATETC methods
  83.     //
  84.     HRESULT _IFUNC Next (ULONG celt, FORMATETC FAR * rgelt,
  85.                                 ULONG FAR* pceltFetched);
  86.     HRESULT _IFUNC Skip (ULONG celt);
  87.     HRESULT _IFUNC Reset ();
  88.     HRESULT _IFUNC Clone (IEnumFORMATETC FAR* FAR* ppenum);
  89.  
  90.     // Private methods
  91.     //
  92.     void Resync();
  93.  
  94.     BOleDataItem FAR *pCurItem;
  95.     BOleDataItem FAR *pFirstItem;
  96.     BOleDataItem FAR *pLastItem;
  97.     BOleData *pData;
  98.     LONG nRef;
  99. };
  100.  
  101. // BOleShadowData -- The execution of EmptyClipboard() causes OLE2 to call
  102. //                   CoDisconnectObject on the data object which has been 
  103. //                   posted to the clipboard. 
  104. //
  105. //                   The consequence is that if we post the original objects
  106. //                   (as opposed to clones of them), OLE2 might FORCE the 
  107. //                   refcount of such objects to zero on our behalf. 
  108. //
  109. //                   To solve this we post a small shadow object which 
  110. //                   delegates IDataObject to the real object, but implements
  111. //                   IUnknown here (stopping CoDisconnectObject from 
  112. //                   decrementing the real object until it goes to zero).
  113. //
  114. class _ICLASS BOleShadowData : public BOleComponent, public IDataObject
  115. {
  116.     public:
  117.  
  118.         BOleShadowData (BOleClassManager *pCM, LPDATAOBJECT pDeleg);
  119.         virtual ~BOleShadowData();
  120.         LPDATAOBJECT GetRealData() {return pDelegate;}
  121.     
  122.         DEFINE_IUNKNOWN(pObjOuter);
  123.  
  124.         // IDataObject
  125.         //
  126.         virtual HRESULT _IFUNC GetData (LPFORMATETC, LPSTGMEDIUM);
  127.         virtual HRESULT _IFUNC GetDataHere (LPFORMATETC, LPSTGMEDIUM);
  128.         virtual HRESULT _IFUNC QueryGetData (LPFORMATETC);
  129.         virtual HRESULT _IFUNC GetCanonicalFormatEtc (LPFORMATETC, LPFORMATETC);
  130.         virtual HRESULT _IFUNC SetData (LPFORMATETC, STGMEDIUM FAR *, BOOL);
  131.         virtual HRESULT _IFUNC EnumFormatEtc (DWORD, LPENUMFORMATETC FAR*);
  132.         virtual HRESULT _IFUNC DAdvise (FORMATETC FAR*, DWORD, LPADVISESINK, DWORD FAR*);
  133.         virtual HRESULT _IFUNC DUnadvise (DWORD);
  134.         virtual HRESULT _IFUNC EnumDAdvise (LPENUMSTATDATA FAR*);
  135.  
  136.         // IUnknown
  137.         //
  138.         virtual HRESULT _IFUNC QueryInterfaceMain(REFIID iid, void FAR* FAR* pif);
  139.  
  140.     protected:
  141.  
  142.         LPDATAOBJECT pDelegate;
  143. };
  144.  
  145. #endif
  146.  
  147.