COSMOLE.H
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:9k
源码类别:

Windows编程

开发平台:

Visual C++

  1. /*
  2.  * COSMOLE.H
  3.  * Cosmo Chapter 21
  4.  *
  5.  * Include file containing all compound document related
  6.  * definitions.
  7.  *
  8.  * Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
  9.  *
  10.  * Kraig Brockschmidt, Microsoft
  11.  * Internet  :  kraigb@microsoft.com
  12.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  13.  */
  14. #ifndef _COSMOLE_H_
  15. #define _COSMOLE_H_
  16. //These are global for simplification of object implementation.
  17. extern ULONG g_cObj;
  18. extern ULONG g_cLock;
  19. extern HWND  g_hWnd;
  20. //Function for the object to notify on destruction.
  21. void ObjectDestroyed(void);
  22. //ICLASSF.CPP
  23. class CFigureClassFactory : public IClassFactory
  24.     {
  25.     protected:
  26.         ULONG           m_cRef;
  27.         PCCosmoFrame    m_pFR;
  28.         BOOL            m_fCreated;     //Created one object yet?
  29.     public:
  30.         CFigureClassFactory(PCCosmoFrame);
  31.         ~CFigureClassFactory(void);
  32.         //IUnknown members
  33.         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
  34.         STDMETHODIMP_(ULONG) AddRef(void);
  35.         STDMETHODIMP_(ULONG) Release(void);
  36.         //IClassFactory members
  37.         STDMETHODIMP         CreateInstance(LPUNKNOWN, REFIID
  38.                                  , PPVOID);
  39.         STDMETHODIMP         LockServer(BOOL);
  40.     };
  41. typedef CFigureClassFactory *PCFigureClassFactory;
  42. //FIGURE.CPP
  43. //This is what the class factory creates
  44. #define CFORMATETCGET   5
  45. class CImpIPersistStorage;
  46. typedef class CImpIPersistStorage *PCImpIPersistStorage;
  47. class CImpIDataObject;
  48. typedef class CImpIDataObject *PCImpIDataObject;
  49. class CImpIOleObject;
  50. typedef class CImpIOleObject *PCImpIOleObject;
  51. //CHAPTER21MOD
  52. class CImpIPersistFile;
  53. typedef class CImpIPersistFile *PCImpIPersistFile;
  54. //End CHAPTER21MOD
  55. class CFigure : public IUnknown
  56.     {
  57.     friend class CImpIPersistStorage;
  58.     friend class CImpIDataObject;
  59.     friend class CImpIOleObject;
  60.     //CHAPTER21MOD
  61.     friend class CImpIPersistFile;
  62.     //End CHAPTER21MOD
  63.     protected:
  64.         ULONG               m_cRef;
  65.         PCCosmoFrame        m_pFR;      //Frame (for UI changes)
  66.         PCCosmoDoc          m_pDoc;     //What holds real polyline
  67.         PCPolyline          m_pPL;      //Copy of m_pDoc->m_pPL
  68.         BOOL                m_fEmbedded;
  69.         PFNDESTROYED        m_pfnDestroy;
  70.         PCStringTable       m_pST;      //Object strings
  71.         //Things for IPersistStorage
  72.         PCImpIPersistStorage m_pImpIPersistStorage;
  73.         LPSTORAGE           m_pIStorage;
  74.         LPSTREAM            m_pIStream;
  75.         CLSID               m_clsID;
  76.         //Things for IDataObject
  77.         PCImpIDataObject    m_pImpIDataObject;      //Implemented
  78.         LPDATAADVISEHOLDER  m_pIDataAdviseHolder;   //Used
  79.         UINT                m_cf;                   //pDoc->m_cf
  80.         ULONG               m_cfeGet;
  81.         FORMATETC           m_rgfeGet[CFORMATETCGET];
  82.         //Things for IOleObject
  83.         PCImpIOleObject     m_pImpIOleObject;       //Implemented
  84.         LPOLEADVISEHOLDER   m_pIOleAdviseHolder;    //Used
  85.         LPOLECLIENTSITE     m_pIOleClientSite;      //Used
  86.         //CHAPTER21MOD
  87.         LPMONIKER           m_pMoniker;
  88.         DWORD               m_dwRegROT;
  89.         PCImpIPersistFile   m_pImpIPersistFile;     //Implemented
  90.         //End CHAPTER21MOD
  91.     public:
  92.         CFigure(PFNDESTROYED, PCCosmoDoc);
  93.         ~CFigure(void);
  94.         //Non-delegating IUnknown:  we don't support aggregation
  95.         STDMETHODIMP QueryInterface(REFIID, PPVOID);
  96.         STDMETHODIMP_(ULONG) AddRef(void);
  97.         STDMETHODIMP_(ULONG) Release(void);
  98.         BOOL Init(void);
  99.         void FrameSet(PCCosmoFrame);
  100.         BOOL FIsDirty(void);
  101.         BOOL FIsEmbedded(void);
  102.         void SendAdvise(UINT);
  103.     };
  104. typedef CFigure *PCFigure;
  105. //Codes for CFigure::SendAdvise
  106. //......Code......................Method called in CFigureSendAdvise...
  107. #define OBJECTCODE_SAVED       0  //IOleAdviseHolder::SendOnSave
  108. #define OBJECTCODE_CLOSED      1  //IOleAdviseHolder::SendOnClose
  109. #define OBJECTCODE_RENAMED     2  //IOleAdviseHolder::SendOnRename
  110. #define OBJECTCODE_SAVEOBJECT  3  //IOleClientSite::SaveObject
  111. #define OBJECTCODE_DATACHANGED 4  //IDataAdviseHolder::SendOnDataChange
  112. #define OBJECTCODE_SHOWWINDOW  5  //IOleClientSite::OnShowWindow(TRUE)
  113. #define OBJECTCODE_HIDEWINDOW  6  //IOleClientSite::OnShowWindow(FALSE)
  114. #define OBJECTCODE_SHOWOBJECT  7  //IOleClientSite::ShowObject
  115. //IPERSTOR.CPP
  116. class CImpIPersistStorage : public IPersistStorage
  117.     {
  118.     protected:
  119.         ULONG               m_cRef;
  120.         PCFigure            m_pObj;
  121.         LPUNKNOWN           m_pUnkOuter;
  122.         PSSTATE             m_psState;      //Storage state
  123.         BOOL                m_fConvert;     //Are we Converting?
  124.     public:
  125.         CImpIPersistStorage(PCFigure, LPUNKNOWN);
  126.         ~CImpIPersistStorage(void);
  127.         STDMETHODIMP QueryInterface(REFIID, PPVOID);
  128.         STDMETHODIMP_(ULONG) AddRef(void);
  129.         STDMETHODIMP_(ULONG) Release(void);
  130.         STDMETHODIMP GetClassID(LPCLSID);
  131.         STDMETHODIMP IsDirty(void);
  132.         STDMETHODIMP InitNew(LPSTORAGE);
  133.         STDMETHODIMP Load(LPSTORAGE);
  134.         STDMETHODIMP Save(LPSTORAGE, BOOL);
  135.         STDMETHODIMP SaveCompleted(LPSTORAGE);
  136.         STDMETHODIMP HandsOffStorage(void);
  137.     };
  138. //IDATAOBJ.CPP
  139. class CImpIDataObject : public IDataObject
  140.     {
  141.     private:
  142.         ULONG           m_cRef;
  143.         PCFigure        m_pObj;
  144.         LPUNKNOWN       m_pUnkOuter;
  145.     public:
  146.         CImpIDataObject(PCFigure, LPUNKNOWN);
  147.         ~CImpIDataObject(void);
  148.         //IUnknown members that delegate to m_pUnkOuter.
  149.         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
  150.         STDMETHODIMP_(ULONG) AddRef(void);
  151.         STDMETHODIMP_(ULONG) Release(void);
  152.         //IDataObject members
  153.         STDMETHODIMP GetData(LPFORMATETC, LPSTGMEDIUM);
  154.         STDMETHODIMP GetDataHere(LPFORMATETC, LPSTGMEDIUM);
  155.         STDMETHODIMP QueryGetData(LPFORMATETC);
  156.         STDMETHODIMP GetCanonicalFormatEtc(LPFORMATETC, LPFORMATETC);
  157.         STDMETHODIMP SetData(LPFORMATETC, LPSTGMEDIUM, BOOL);
  158.         STDMETHODIMP EnumFormatEtc(DWORD, LPENUMFORMATETC *);
  159.         STDMETHODIMP DAdvise(LPFORMATETC, DWORD,  LPADVISESINK
  160.                          , DWORD *);
  161.         STDMETHODIMP DUnadvise(DWORD);
  162.         STDMETHODIMP EnumDAdvise(LPENUMSTATDATA *);
  163.     };
  164. //IOLEOBJ.CPP
  165. class CImpIOleObject : public IOleObject
  166.     {
  167.     private:
  168.         ULONG           m_cRef;
  169.         PCFigure        m_pObj;
  170.         LPUNKNOWN       m_pUnkOuter;
  171.     public:
  172.         CImpIOleObject(PCFigure, LPUNKNOWN);
  173.         ~CImpIOleObject(void);
  174.         //IUnknown members that delegate to m_pUnkOuter.
  175.         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
  176.         STDMETHODIMP_(ULONG) AddRef(void);
  177.         STDMETHODIMP_(ULONG) Release(void);
  178.         //IOleObject members
  179.         STDMETHODIMP SetClientSite(LPOLECLIENTSITE);
  180.         STDMETHODIMP GetClientSite(LPOLECLIENTSITE *);
  181.         STDMETHODIMP SetHostNames(LPCOLESTR, LPCOLESTR);
  182.         STDMETHODIMP Close(DWORD);
  183.         STDMETHODIMP SetMoniker(DWORD, LPMONIKER);
  184.         STDMETHODIMP GetMoniker(DWORD, DWORD, LPMONIKER *);
  185.         STDMETHODIMP InitFromData(LPDATAOBJECT, BOOL, DWORD);
  186.         STDMETHODIMP GetClipboardData(DWORD, LPDATAOBJECT *);
  187.         STDMETHODIMP DoVerb(LONG, LPMSG, LPOLECLIENTSITE, LONG, HWND
  188.                          , LPCRECT);
  189.         STDMETHODIMP EnumVerbs(LPENUMOLEVERB *);
  190.         STDMETHODIMP Update(void);
  191.         STDMETHODIMP IsUpToDate(void);
  192.         STDMETHODIMP GetUserClassID(CLSID *);
  193.         STDMETHODIMP GetUserType(DWORD, LPOLESTR *);
  194.         STDMETHODIMP SetExtent(DWORD, LPSIZEL);
  195.         STDMETHODIMP GetExtent(DWORD, LPSIZEL);
  196.         STDMETHODIMP Advise(LPADVISESINK, DWORD *);
  197.         STDMETHODIMP Unadvise(DWORD);
  198.         STDMETHODIMP EnumAdvise(LPENUMSTATDATA *);
  199.         STDMETHODIMP GetMiscStatus(DWORD, DWORD *);
  200.         STDMETHODIMP SetColorScheme(LPLOGPALETTE);
  201.     };
  202. //CHAPTER21MOD
  203. class CImpIPersistFile : public IPersistFile
  204.     {
  205.     protected:
  206.         ULONG               m_cRef;
  207.         PCFigure            m_pObj;
  208.         LPUNKNOWN           m_pUnkOuter;
  209.     public:
  210.         CImpIPersistFile(PCFigure, LPUNKNOWN);
  211.         ~CImpIPersistFile(void);
  212.         STDMETHODIMP QueryInterface(REFIID, PPVOID);
  213.         STDMETHODIMP_(ULONG) AddRef(void);
  214.         STDMETHODIMP_(ULONG) Release(void);
  215.         STDMETHODIMP GetClassID(LPCLSID);
  216.         STDMETHODIMP IsDirty(void);
  217.         STDMETHODIMP Load(LPCOLESTR, DWORD);
  218.         STDMETHODIMP Save(LPCOLESTR, BOOL);
  219.         STDMETHODIMP SaveCompleted(LPCOLESTR);
  220.         STDMETHODIMP GetCurFile(LPOLESTR *);
  221.     };
  222. //End CHAPTER21MOD
  223. #endif _COSMOLE_H_