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

Windows编程

开发平台:

Visual C++

  1. /*
  2.  * COSMOLE.H
  3.  * Cosmo Chapter 23
  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. //CHAPTER23MOD
  21. //This is for simplification of CCosmoFrame::CheckLineSelection
  22. extern PCToolBar    g_pInPlaceTB;
  23. #define ID_HATCHWINDOW  2000
  24. //End CHAPTER23MOD
  25. //Function for the object to notify on destruction.
  26. void ObjectDestroyed(void);
  27. //ICLASSF.CPP
  28. class CFigureClassFactory : public IClassFactory
  29.     {
  30.     protected:
  31.         ULONG           m_cRef;
  32.         PCCosmoFrame    m_pFR;
  33.         BOOL            m_fCreated;     //Created one object yet?
  34.     public:
  35.         CFigureClassFactory(PCCosmoFrame);
  36.         ~CFigureClassFactory(void);
  37.         //IUnknown members
  38.         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
  39.         STDMETHODIMP_(ULONG) AddRef(void);
  40.         STDMETHODIMP_(ULONG) Release(void);
  41.         //IClassFactory members
  42.         STDMETHODIMP         CreateInstance(LPUNKNOWN, REFIID
  43.                                  , PPVOID);
  44.         STDMETHODIMP         LockServer(BOOL);
  45.     };
  46. typedef CFigureClassFactory *PCFigureClassFactory;
  47. //FIGURE.CPP
  48. //This is what the class factory creates
  49. #define CFORMATETCGET   5
  50. class CImpIPersistStorage;
  51. typedef class CImpIPersistStorage *PCImpIPersistStorage;
  52. class CImpIDataObject;
  53. typedef class CImpIDataObject *PCImpIDataObject;
  54. class CImpIOleObject;
  55. typedef class CImpIOleObject *PCImpIOleObject;
  56. class CImpIPersistFile;
  57. typedef class CImpIPersistFile *PCImpIPersistFile;
  58. //CHAPTER23MOD
  59. class CImpIOleInPlaceObject;
  60. typedef class CImpIOleInPlaceObject *PCImpIOleInPlaceObject;
  61. class CImpIOleInPlaceActiveObject;
  62. typedef class CImpIOleInPlaceActiveObject *PCImpIOleInPlaceActiveObject;
  63. //End CHAPTER23MOD
  64. class CFigure : public IUnknown
  65.     {
  66.     friend class CImpIPersistStorage;
  67.     friend class CImpIDataObject;
  68.     friend class CImpIOleObject;
  69.     friend class CImpIPersistFile;
  70.     //CHAPTER23MOD
  71.     friend class CImpIOleInPlaceObject;
  72.     friend class CImpIOleInPlaceActiveObject;
  73.     //End CHAPTER23MOD
  74.     protected:
  75.         ULONG               m_cRef;
  76.         PCCosmoFrame        m_pFR;      //Frame (for UI changes)
  77.         PCCosmoDoc          m_pDoc;     //What holds real polyline
  78.         PCPolyline          m_pPL;      //Copy of m_pDoc->m_pPL
  79.         BOOL                m_fEmbedded;
  80.         PFNDESTROYED        m_pfnDestroy;
  81.         PCStringTable       m_pST;      //Object strings
  82.         //Things for IPersistStorage
  83.         PCImpIPersistStorage m_pImpIPersistStorage;
  84.         LPSTORAGE           m_pIStorage;
  85.         LPSTREAM            m_pIStream;
  86.         CLSID               m_clsID;
  87.         //Things for IDataObject
  88.         PCImpIDataObject    m_pImpIDataObject;      //Implemented
  89.         LPDATAADVISEHOLDER  m_pIDataAdviseHolder;   //Used
  90.         UINT                m_cf;                   //pDoc->m_cf
  91.         ULONG               m_cfeGet;
  92.         FORMATETC           m_rgfeGet[CFORMATETCGET];
  93.         //Things for IOleObject
  94.         PCImpIOleObject     m_pImpIOleObject;       //Implemented
  95.         LPOLEADVISEHOLDER   m_pIOleAdviseHolder;    //Used
  96.         LPOLECLIENTSITE     m_pIOleClientSite;      //Used
  97.         LPMONIKER           m_pMoniker;
  98.         DWORD               m_dwRegROT;
  99.         PCImpIPersistFile   m_pImpIPersistFile;     //Implemented
  100.         //CHAPTER23MOD
  101.         LPOLEINPLACESITE            m_pIOleIPSite;
  102.         LPOLEINPLACEFRAME           m_pIOleIPFrame;
  103.         LPOLEINPLACEUIWINDOW        m_pIOleIPUIWindow;
  104.         PCImpIOleInPlaceObject       m_pImpIOleIPObject;
  105.         PCImpIOleInPlaceActiveObject m_pImpIOleIPActiveObject;
  106.         HMENU                       m_hMenuShared;
  107.         HOLEMENU                    m_hOLEMenu;
  108.         HACCEL                      m_hAccel;
  109.         PCHatchWin                  m_pHW;      //Hatch window
  110.         PCToolBar                   m_pTB;      //In-place toolbar
  111.         UINT                        m_cyBar;    //Copy of m_pFR->m_cyBar
  112.         BOOL                        m_fUndoDeactivates;
  113.         BOOL                        m_fAllowInPlace;
  114.         BOOL                        m_fForceSave;
  115.         //End CHAPTER23MOD
  116.     public:
  117.         CFigure(PFNDESTROYED, PCCosmoDoc);
  118.         ~CFigure(void);
  119.         //Non-delegating IUnknown:  we don't support aggregation
  120.         STDMETHODIMP QueryInterface(REFIID, PPVOID);
  121.         STDMETHODIMP_(ULONG) AddRef(void);
  122.         STDMETHODIMP_(ULONG) Release(void);
  123.         BOOL Init(void);
  124.         void FrameSet(PCCosmoFrame);
  125.         BOOL FIsDirty(void);
  126.         BOOL FIsEmbedded(void);
  127.         void SendAdvise(UINT);
  128.         //CHAPTER23MOD
  129.         HRESULT  InPlaceActivate(LPOLECLIENTSITE, BOOL);
  130.         void     InPlaceDeactivate(void);
  131.         HRESULT  UIActivate(void);
  132.         void     UIDeactivate(void);
  133.         BOOL     InPlaceMenuCreate(void);
  134.         BOOL     InPlaceMenuDestroy(void);
  135.         BOOL     InPlaceToolsCreate(void);
  136.         BOOL     InPlaceToolsDestroy(void);
  137.         BOOL     InPlaceToolsRenegotiate(void);
  138.         void     OpenIntoWindow(void);
  139.         BOOL     Undo(void);
  140.         //End CHAPTER23MOD
  141.     };
  142. typedef CFigure *PCFigure;
  143. //Codes for CFigure::SendAdvise
  144. //......Code......................Method called in CFigureSendAdvise...
  145. #define OBJECTCODE_SAVED       0  //IOleAdviseHolder::SendOnSave
  146. #define OBJECTCODE_CLOSED      1  //IOleAdviseHolder::SendOnClose
  147. #define OBJECTCODE_RENAMED     2  //IOleAdviseHolder::SendOnRename
  148. #define OBJECTCODE_SAVEOBJECT  3  //IOleClientSite::SaveObject
  149. #define OBJECTCODE_DATACHANGED 4  //IDataAdviseHolder::SendOnDataChange
  150. #define OBJECTCODE_SHOWWINDOW  5  //IOleClientSite::OnShowWindow(TRUE)
  151. #define OBJECTCODE_HIDEWINDOW  6  //IOleClientSite::OnShowWindow(FALSE)
  152. #define OBJECTCODE_SHOWOBJECT  7  //IOleClientSite::ShowObject
  153. //IPERSTOR.CPP
  154. class CImpIPersistStorage : public IPersistStorage
  155.     {
  156.     protected:
  157.         ULONG               m_cRef;
  158.         PCFigure            m_pObj;
  159.         LPUNKNOWN           m_pUnkOuter;
  160.         PSSTATE             m_psState;      //Storage state
  161.         BOOL                m_fConvert;     //Are we Converting?
  162.     public:
  163.         CImpIPersistStorage(PCFigure, LPUNKNOWN);
  164.         ~CImpIPersistStorage(void);
  165.         STDMETHODIMP QueryInterface(REFIID, PPVOID);
  166.         STDMETHODIMP_(ULONG) AddRef(void);
  167.         STDMETHODIMP_(ULONG) Release(void);
  168.         STDMETHODIMP GetClassID(LPCLSID);
  169.         STDMETHODIMP IsDirty(void);
  170.         STDMETHODIMP InitNew(LPSTORAGE);
  171.         STDMETHODIMP Load(LPSTORAGE);
  172.         STDMETHODIMP Save(LPSTORAGE, BOOL);
  173.         STDMETHODIMP SaveCompleted(LPSTORAGE);
  174.         STDMETHODIMP HandsOffStorage(void);
  175.     };
  176. //IDATAOBJ.CPP
  177. class CImpIDataObject : public IDataObject
  178.     {
  179.     private:
  180.         ULONG           m_cRef;
  181.         PCFigure        m_pObj;
  182.         LPUNKNOWN       m_pUnkOuter;
  183.     public:
  184.         CImpIDataObject(PCFigure, LPUNKNOWN);
  185.         ~CImpIDataObject(void);
  186.         //IUnknown members that delegate to m_pUnkOuter.
  187.         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
  188.         STDMETHODIMP_(ULONG) AddRef(void);
  189.         STDMETHODIMP_(ULONG) Release(void);
  190.         //IDataObject members
  191.         STDMETHODIMP GetData(LPFORMATETC, LPSTGMEDIUM);
  192.         STDMETHODIMP GetDataHere(LPFORMATETC, LPSTGMEDIUM);
  193.         STDMETHODIMP QueryGetData(LPFORMATETC);
  194.         STDMETHODIMP GetCanonicalFormatEtc(LPFORMATETC, LPFORMATETC);
  195.         STDMETHODIMP SetData(LPFORMATETC, LPSTGMEDIUM, BOOL);
  196.         STDMETHODIMP EnumFormatEtc(DWORD, LPENUMFORMATETC *);
  197.         STDMETHODIMP DAdvise(LPFORMATETC, DWORD,  LPADVISESINK
  198.                          , DWORD *);
  199.         STDMETHODIMP DUnadvise(DWORD);
  200.         STDMETHODIMP EnumDAdvise(LPENUMSTATDATA *);
  201.     };
  202. //IOLEOBJ.CPP
  203. class CImpIOleObject : public IOleObject
  204.     {
  205.     private:
  206.         ULONG           m_cRef;
  207.         PCFigure        m_pObj;
  208.         LPUNKNOWN       m_pUnkOuter;
  209.     public:
  210.         CImpIOleObject(PCFigure, LPUNKNOWN);
  211.         ~CImpIOleObject(void);
  212.         //IUnknown members that delegate to m_pUnkOuter.
  213.         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
  214.         STDMETHODIMP_(ULONG) AddRef(void);
  215.         STDMETHODIMP_(ULONG) Release(void);
  216.         //IOleObject members
  217.         STDMETHODIMP SetClientSite(LPOLECLIENTSITE);
  218.         STDMETHODIMP GetClientSite(LPOLECLIENTSITE *);
  219.         STDMETHODIMP SetHostNames(LPCOLESTR, LPCOLESTR);
  220.         STDMETHODIMP Close(DWORD);
  221.         STDMETHODIMP SetMoniker(DWORD, LPMONIKER);
  222.         STDMETHODIMP GetMoniker(DWORD, DWORD, LPMONIKER *);
  223.         STDMETHODIMP InitFromData(LPDATAOBJECT, BOOL, DWORD);
  224.         STDMETHODIMP GetClipboardData(DWORD, LPDATAOBJECT *);
  225.         STDMETHODIMP DoVerb(LONG, LPMSG, LPOLECLIENTSITE, LONG, HWND
  226.                          , LPCRECT);
  227.         STDMETHODIMP EnumVerbs(LPENUMOLEVERB *);
  228.         STDMETHODIMP Update(void);
  229.         STDMETHODIMP IsUpToDate(void);
  230.         STDMETHODIMP GetUserClassID(CLSID *);
  231.         STDMETHODIMP GetUserType(DWORD, LPOLESTR *);
  232.         STDMETHODIMP SetExtent(DWORD, LPSIZEL);
  233.         STDMETHODIMP GetExtent(DWORD, LPSIZEL);
  234.         STDMETHODIMP Advise(LPADVISESINK, DWORD *);
  235.         STDMETHODIMP Unadvise(DWORD);
  236.         STDMETHODIMP EnumAdvise(LPENUMSTATDATA *);
  237.         STDMETHODIMP GetMiscStatus(DWORD, DWORD *);
  238.         STDMETHODIMP SetColorScheme(LPLOGPALETTE);
  239.     };
  240. class CImpIPersistFile : public IPersistFile
  241.     {
  242.     protected:
  243.         ULONG               m_cRef;
  244.         PCFigure            m_pObj;
  245.         LPUNKNOWN           m_pUnkOuter;
  246.     public:
  247.         CImpIPersistFile(PCFigure, LPUNKNOWN);
  248.         ~CImpIPersistFile(void);
  249.         STDMETHODIMP QueryInterface(REFIID, PPVOID);
  250.         STDMETHODIMP_(ULONG) AddRef(void);
  251.         STDMETHODIMP_(ULONG) Release(void);
  252.         STDMETHODIMP GetClassID(LPCLSID);
  253.         STDMETHODIMP IsDirty(void);
  254.         STDMETHODIMP Load(LPCOLESTR, DWORD);
  255.         STDMETHODIMP Save(LPCOLESTR, BOOL);
  256.         STDMETHODIMP SaveCompleted(LPCOLESTR);
  257.         STDMETHODIMP GetCurFile(LPOLESTR *);
  258.     };
  259. //CHAPTER23MOD
  260. //IIPOBJ.CPP
  261. class CImpIOleInPlaceObject : public IOleInPlaceObject
  262.     {
  263.     protected:
  264.         ULONG               m_cRef;
  265.         PCFigure            m_pObj;
  266.         LPUNKNOWN           m_pUnkOuter;
  267.     public:
  268.         CImpIOleInPlaceObject(PCFigure, LPUNKNOWN);
  269.         ~CImpIOleInPlaceObject(void);
  270.         STDMETHODIMP QueryInterface(REFIID, PPVOID);
  271.         STDMETHODIMP_(ULONG) AddRef(void);
  272.         STDMETHODIMP_(ULONG) Release(void);
  273.         STDMETHODIMP GetWindow(HWND *);
  274.         STDMETHODIMP ContextSensitiveHelp(BOOL);
  275.         STDMETHODIMP InPlaceDeactivate(void);
  276.         STDMETHODIMP UIDeactivate(void);
  277.         STDMETHODIMP SetObjectRects(LPCRECT, LPCRECT);
  278.         STDMETHODIMP ReactivateAndUndo(void);
  279.     };
  280. //IIPAOBJ.CPP
  281. class CImpIOleInPlaceActiveObject
  282.     : public IOleInPlaceActiveObject
  283.     {
  284.     protected:
  285.         ULONG               m_cRef;
  286.         PCFigure            m_pObj;
  287.         LPUNKNOWN           m_pUnkOuter;
  288.     public:
  289.         CImpIOleInPlaceActiveObject(PCFigure, LPUNKNOWN);
  290.         ~CImpIOleInPlaceActiveObject(void);
  291.         STDMETHODIMP QueryInterface(REFIID, PPVOID);
  292.         STDMETHODIMP_(ULONG) AddRef(void);
  293.         STDMETHODIMP_(ULONG) Release(void);
  294.         STDMETHODIMP GetWindow(HWND *);
  295.         STDMETHODIMP ContextSensitiveHelp(BOOL);
  296.         STDMETHODIMP TranslateAccelerator(LPMSG);
  297.         STDMETHODIMP OnFrameWindowActivate(BOOL);
  298.         STDMETHODIMP OnDocWindowActivate(BOOL);
  299.         STDMETHODIMP ResizeBorder(LPCRECT, LPOLEINPLACEUIWINDOW
  300.                          , BOOL);
  301.         STDMETHODIMP EnableModeless(BOOL);
  302.     };
  303. //End CHAPTER23MOD
  304. #endif _COSMOLE_H_