home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / Borland / Cplus45 / BC45 / BOCOLE.PAK / BOLESITE.H < prev    next >
C/C++ Source or Header  |  1995-08-29  |  11KB  |  320 lines

  1.  
  2. //**************************************************************************
  3. // 
  4. // BOleSite.h -- Interface of the Bolero half of the OLE2 server object.
  5. //               BOleSite objects impersonate the client application
  6. //               from the point of view of the Bolero customer who's
  7. //                  writing a server object (IPart)
  8. //
  9. //               Since the server object only has to implement IPart, it's
  10. //               convenient to have only one helper object (BOleSite) which
  11. //               inherits from all the required Bolero container interfaces
  12. //
  13. // Copyright (c) 1993,94 by Borland International, Inc. All rights reserved
  14. //
  15. //**************************************************************************
  16.  
  17. #ifndef _BOLESITE_H
  18. #define _BOLESITE_H 
  19.  
  20. #include "BOleComp.h"
  21. #include "BOleFact.h"
  22. #include "BHatch.h"
  23.  
  24. class _ICLASS BOleService;
  25.  
  26. class _ICLASS BOleSite :     public BOleComponent, public IBSite,
  27.                            public IBContainer,   public IBLinkable,
  28.  
  29.                            public IPersistStorage, public IDataObject,
  30.                                     public IOleObject,      public IOleInPlaceObject,     
  31.                            public IDropSource,     public IEnumFORMATETC,
  32.                            public IOleInPlaceActiveObject
  33. {
  34.     // to have separate IBWindow implementation
  35.     class _ICLASS IBApplicationImpl : public IBApplication {
  36.     public:
  37.         IBUnknownMain *pOuter;
  38.         BOleSite *pThis;
  39.  
  40.         IBApplicationImpl::IBApplicationImpl(BOleSite *pT, IBUnknownMain *pO)
  41.         : pThis (pT), pOuter (pO) {}
  42.         DEFINE_IUNKNOWN(pOuter);
  43.         
  44.         // IBApplication methods
  45.         //
  46.         virtual HWND     _IFUNC GetWindow ();
  47.         virtual HRESULT  _IFUNC GetWindowRect (LPRECT);
  48.         virtual LPCOLESTR _IFUNC GetWindowTitle ();
  49.         virtual void     _IFUNC AppendWindowTitle (LPCOLESTR);
  50.         virtual HRESULT  _IFUNC SetStatusText (LPCOLESTR);
  51.  
  52.         virtual HRESULT  _IFUNC RequestBorderSpace (LPCRECT);
  53.         virtual HRESULT  _IFUNC SetBorderSpace (LPCRECT);
  54.  
  55.         virtual HRESULT  _IFUNC InsertContainerMenus (HMENU,BOleMenuWidths FAR*);
  56.         virtual HRESULT  _IFUNC SetFrameMenu (HMENU);
  57.         virtual void     _IFUNC RestoreUI ();
  58.         virtual HRESULT  _IFUNC Accelerator (LPMSG);
  59.         virtual HRESULT  _IFUNC GetAccelerators (HACCEL FAR*, int FAR*);
  60.  
  61.         virtual LPCOLESTR _IFUNC GetAppName ();
  62.         virtual BOleHelp _IFUNC HelpMode (BOleHelp);
  63.         virtual HRESULT  _IFUNC CanLink ();
  64.         virtual HRESULT  _IFUNC CanEmbed ();
  65.         virtual HRESULT  _IFUNC IsMDI ();
  66.         virtual HRESULT  _IFUNC OnModalDialog (BOOL);
  67.         virtual void     _IFUNC DialogHelpNotify (BOleDialogHelp);
  68.         virtual void     _IFUNC ShutdownMaybe ();
  69.     } iApplication;
  70.     
  71.     friend IBApplicationImpl;
  72.     friend class BOleHatchWindow;
  73.     
  74.     
  75. public:
  76.     IDataAdviseHolder * pDAdvHolder;
  77.     IOleAdviseHolder  * pAdvHolder;
  78.     LPUNKNOWN            pDocument;
  79.  
  80. protected:
  81.     BOleService         * pService;
  82.     PIBPart               pPart;
  83.     PIBDataProvider       pProvider;
  84.     IMoniker            * pmkDoc;    // moniker of server doc
  85.     IOleClientSite      * pClientSite;
  86.     IOleInPlaceSite     * pIPSite;
  87.     IOleInPlaceFrame    * pIPFrame;
  88.     IOleInPlaceUIWindow * pIPDoc;
  89.     IStorage            * pStg;
  90.     
  91.     BOOL fShown          : 1;
  92.     BOOL fInPlaceActive  : 1;
  93.     BOOL fInPlaceVisible : 1;
  94.     BOOL fInsideOut      : 1;
  95.     BOOL fUIActive       : 1;
  96.     BOOL fInHelpMode     : 1;
  97.     BOOL fIsDirty        : 1;
  98.     BOOL fHandsOff       : 1;
  99.     BOOL fInClose        : 1;
  100.  
  101.     CLSID cid;
  102.     DWORD regLink;               // to register full moniker
  103.     
  104.     LPOLESTR pszProgID;
  105.     LPOLESTR pszInstName;
  106.     OLEINPLACEFRAMEINFO frameInfo;
  107.     RECT rcPosRect;
  108.     RECT rcClipRect;
  109.     
  110.     HWND hWndParent;
  111.     HWND hWndInPlace;
  112.  
  113.     OLEMENUGROUPWIDTHS  menuGroupWidths;
  114.     HOLEMENU            hOleMenu;
  115.     HMENU               hMenuShared;
  116.  
  117.     BOleHatchWindow *pHatchWnd;
  118.     POINT hatchOffset;
  119.     ULONG enumFmtIndex;
  120.  
  121.     LPOLESTR pAppName;        // Container app's name (not used in current OLE UI spec)
  122.     LPOLESTR pWindowTitle;    // Container app's document (used in open editing)
  123.     LPOLESTR pInPlaceName;    // Server object name for SetActiveObject
  124.  
  125.     LPFORMATETC formatList;
  126.     UINT             formatCount;
  127.     BOOL formatLink;
  128.     BOOL formatEmbed;
  129.     
  130.     BOleScaleFactor scale;
  131.  
  132. public:
  133.  
  134.     BOleSite(BOleClassManager * pFact, IBUnknownMain *pOuter, BOleService*);
  135.     ~BOleSite ();
  136.  
  137.     // IUnknown methods
  138.     //
  139.     DEFINE_IUNKNOWN(pObjOuter)
  140.  
  141.     virtual HRESULT _IFUNC QueryInterfaceMain(REFIID iid, LPVOID FAR* pif);
  142.  
  143.     // IDataObject methods
  144.     //
  145.     HRESULT _IFUNC GetData(LPFORMATETC pformatetcIn, LPSTGMEDIUM pmedium);
  146.     HRESULT _IFUNC GetDataHere(LPFORMATETC pformatetc, LPSTGMEDIUM pmedium);
  147.     HRESULT _IFUNC QueryGetData(LPFORMATETC pformatetc);
  148.     HRESULT _IFUNC GetCanonicalFormatEtc(LPFORMATETC pformatetc,
  149.                                          LPFORMATETC pformatetcOut);
  150.     HRESULT _IFUNC SetData(LPFORMATETC pformatetc, STGMEDIUM FAR* pmedium,
  151.                            BOOL fRelease);
  152.     HRESULT _IFUNC EnumFormatEtc(DWORD dwDirection,
  153.                                  LPENUMFORMATETC FAR* ppenumFormatEtc);
  154.     HRESULT _IFUNC DAdvise(FORMATETC FAR* pFormatetc, DWORD advf, 
  155.                            IAdviseSink* pAdvSink, DWORD FAR* pdwConnection);
  156.     HRESULT _IFUNC DUnadvise(DWORD dwConnection);
  157.     HRESULT _IFUNC EnumDAdvise(IEnumSTATDATA* FAR* ppenumAdvise);
  158.  
  159.     // IEnumFORMATETC methods
  160.     //
  161.     HRESULT _IFUNC Next (ULONG celt, FORMATETC FAR * rgelt, ULONG FAR* pceltFetched);
  162.     HRESULT _IFUNC Skip (ULONG celt);
  163.     HRESULT _IFUNC Reset ();
  164.     HRESULT _IFUNC Clone (IEnumFORMATETC FAR* FAR* ppenum);
  165.  
  166.     // IOleObject methods
  167.     //
  168.     HRESULT _IFUNC SetClientSite(IOleClientSite* pClientSite);
  169.     HRESULT _IFUNC GetClientSite(IOleClientSite* FAR* ppClientSite);
  170.     HRESULT _IFUNC SetHostNames(LPCOLESTR szContainerApp, LPCOLESTR szContainerObj);
  171.     HRESULT _IFUNC Close(DWORD dwSaveOption);
  172.     HRESULT _IFUNC SetMoniker(DWORD dwWhichMoniker, IMoniker* pmk);
  173.     HRESULT _IFUNC GetMoniker(DWORD dwAssign, DWORD dwWhichMoniker, 
  174.                               IMoniker* FAR* ppmk);
  175.     HRESULT _IFUNC InitFromData(IDataObject* pDataObject, BOOL fCreation,
  176.                               DWORD dwReserved);
  177.     HRESULT _IFUNC GetClipboardData(DWORD dwReserved, 
  178.                                     IDataObject* FAR* ppDataObject);
  179.     HRESULT _IFUNC DoVerb(LONG iVerb, LPMSG lpmsg,
  180.                            IOleClientSite* pActiveSite, LONG lindex,
  181.                            HWND hwndParent, LPCRECT lprcPosRect);
  182.     HRESULT _IFUNC EnumVerbs(IEnumOLEVERB* FAR* ppenumOleVerb);
  183.     HRESULT _IFUNC Update();
  184.     HRESULT _IFUNC IsUpToDate();
  185.     HRESULT _IFUNC GetUserClassID(CLSID FAR* pClsid);
  186.     HRESULT _IFUNC GetUserType(DWORD dwFormOfType, LPOLESTR FAR* pszUserType);
  187.     HRESULT _IFUNC SetExtent(DWORD dwDrawAspect, LPSIZEL lpsizel);
  188.     HRESULT _IFUNC GetExtent(DWORD dwDrawAspect, LPSIZEL lpsizel);
  189.     HRESULT _IFUNC Advise(IAdviseSink* pAdvSink, DWORD FAR* pdwConnection);
  190.     HRESULT _IFUNC Unadvise(DWORD dwConnection);
  191.     HRESULT _IFUNC EnumAdvise(IEnumSTATDATA* FAR* ppenumAdvise);
  192.     HRESULT _IFUNC GetMiscStatus(DWORD dwAspect, DWORD FAR* pdwStatus);
  193.     HRESULT _IFUNC SetColorScheme(LPLOGPALETTE lpLogpal);
  194.  
  195.     // IPersistStorage and IPersistFile Common methods
  196.     //
  197.     HRESULT _IFUNC GetClassID(LPCLSID lpClassID);
  198.     HRESULT _IFUNC IsDirty();
  199.     
  200.     // IPersistStorage methods
  201.     //
  202.     HRESULT _IFUNC InitNew(IStorage* pStg);
  203.     HRESULT _IFUNC Load(IStorage* pStg);
  204.     HRESULT _IFUNC Save(IStorage* pStgSave,BOOL fSameAsLoad);
  205.     HRESULT _IFUNC SaveCompleted(IStorage* pStgSaved);
  206.     HRESULT _IFUNC HandsOffStorage(); 
  207.     
  208.     // IOleWindow methods 
  209.     //
  210.     HRESULT _IFUNC GetWindow (HWND FAR* lphwnd);
  211.     HRESULT _IFUNC ContextSensitiveHelp (BOOL fEnterMode);
  212.     
  213.     // IOleInPlaceObject methods 
  214.     //
  215.     HRESULT _IFUNC InPlaceDeactivate ();   
  216.     HRESULT _IFUNC UIDeactivate ();
  217.     HRESULT _IFUNC SetObjectRects (LPCRECT pPos,    LPCRECT pClip);
  218.     HRESULT _IFUNC ReactivateAndUndo ();   
  219.     
  220.     // IOleInPlaceActiveObject methods 
  221.     //
  222.     HRESULT _IFUNC TranslateAccelerator (LPMSG lpmsg);   
  223.     HRESULT _IFUNC OnFrameWindowActivate (BOOL fActivate);           
  224.     HRESULT _IFUNC OnDocWindowActivate (BOOL fActivate);
  225.     HRESULT _IFUNC ResizeBorder (LPCRECT lprectBorder, LPOLEINPLACEUIWINDOW lpUIWindow, BOOL fFrameWindow);          
  226.     HRESULT _IFUNC EnableModeless (BOOL fEnable);
  227.     
  228.     // IDropSource methods
  229.     //
  230.     HRESULT _IFUNC QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState);
  231.     HRESULT _IFUNC GiveFeedback(DWORD dwEffect);
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.     // IBWindow methods
  247.     //
  248.     virtual HWND      _IFUNC GetWindow ();
  249.     virtual HRESULT   _IFUNC GetWindowRect (LPRECT);
  250.     virtual LPCOLESTR _IFUNC GetWindowTitle ();
  251.     virtual void      _IFUNC AppendWindowTitle (LPCOLESTR);
  252.     virtual HRESULT   _IFUNC SetStatusText (LPCOLESTR);
  253.      
  254.     virtual HRESULT   _IFUNC RequestBorderSpace (LPCRECT);
  255.     virtual HRESULT   _IFUNC SetBorderSpace (LPCRECT);
  256.      
  257.     virtual HRESULT   _IFUNC InsertContainerMenus (HMENU,BOleMenuWidths FAR*);
  258.     virtual HRESULT   _IFUNC SetFrameMenu (HMENU);
  259.     virtual void      _IFUNC RestoreUI ();
  260.     virtual HRESULT   _IFUNC Accelerator (LPMSG);
  261.     virtual HRESULT   _IFUNC GetAccelerators (HACCEL FAR*, int FAR*);
  262.  
  263.     // IBContainer methods
  264.     //
  265.     virtual HRESULT   _IFUNC AllowInPlace ();
  266.     virtual HRESULT   _IFUNC BringToFront ();
  267.     virtual HRESULT   _IFUNC FindDropDest (LPPOINT, PIBDropDest FAR*);
  268.  
  269.     // ISite methods
  270.     //
  271.     virtual HRESULT _IFUNC SiteShow(BOOL);
  272.     virtual HRESULT _IFUNC DiscardUndo();
  273.     virtual HRESULT _IFUNC GetSiteRect(LPRECT,LPRECT);
  274.     virtual HRESULT _IFUNC SetSiteRect(LPCRECT);
  275.     virtual HRESULT _IFUNC SetSiteExtent(LPCSIZE);
  276.     virtual void    _IFUNC Invalidate(BOleInvalidate);
  277.     virtual void    _IFUNC OnSetFocus(BOOL);
  278.     virtual HRESULT _IFUNC Init(PIBDataProvider pP, PIBPart pPart, LPCOLESTR psz, BOOL fHatchWnd);
  279.     virtual void    _IFUNC Disconnect ();
  280.     virtual HRESULT _IFUNC GetZoom (BOleScaleFactor *pScale);
  281.     virtual HRESULT _IFUNC CalcZoom (LPCRECT rcposRect);
  282.  
  283.     // ILinkable methods
  284.     //
  285.     virtual HRESULT _IFUNC GetMoniker(IMoniker FAR* FAR* ppMon);
  286.     virtual HRESULT _IFUNC OnRename(PIBLinkable pILContainer, LPCOLESTR szName);
  287.     
  288. protected:
  289.  
  290.     // Implementation methods
  291.     //
  292.     HRESULT      _IFUNC GetMetaFileData (HGLOBAL&);
  293.     HGLOBAL   _IFUNC GetObjDescData ();
  294.     HRESULT   _IFUNC GetEmbeddedObjectData (LPFORMATETC, LPSTGMEDIUM);
  295.     HRESULT   _IFUNC GetLinkSourceData(LPMONIKER, REFCLSID, LPFORMATETC, LPSTGMEDIUM);
  296.     void    _IFUNC GetFormatFlags(BOOL *fEmbed, BOOL *fLinkable);
  297.     void    _IFUNC GetFormatList(LPFORMATETC *ppList, UINT *pCount);
  298.     void    _IFUNC GetFormatCount(UINT *pCount);
  299.     void    _IFUNC GetFormatInfo(BOOL *fEmbed, BOOL *fLinkable, LPFORMATETC *ppList, UINT *pCount);
  300.     
  301.     LPSTORAGE _IFUNC CreateStorageInMemory (DWORD);
  302.  
  303.     HRESULT _IFUNC Lock (BOOL fLock, BOOL fLastUnlockReleases);
  304.     HRESULT _IFUNC ShowWindow ();
  305.     HRESULT _IFUNC HideWindow (BOOL fShutdown);
  306.     HRESULT _IFUNC AssembleMenus ();
  307.     void      _IFUNC DisassembleMenus ();
  308.     HRESULT _IFUNC DoInPlaceActivate (BOOL fActivateOnly);
  309.     HRESULT _IFUNC DoInPlaceShow (BOOL fActivateOnly);
  310.     HRESULT _IFUNC DoUIActivate ();
  311.     HRESULT _IFUNC DoInPlaceDeactivate ();
  312.     HRESULT _IFUNC DoUIDeactivate ();
  313.     HRESULT _IFUNC DoInPlaceHide ();
  314.     HRESULT _IFUNC DoClose ();
  315. };
  316.  
  317. #endif
  318.  
  319.  
  320.