home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c480 / 18.ddi / MFC / INCLUDE / AFXOLE.H_ / AFXOLE.H
Encoding:
C/C++ Source or Header  |  1993-02-08  |  20.8 KB  |  635 lines

  1. // Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992 Microsoft Corporation,
  3. // All rights reserved.
  4.  
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and Microsoft
  7. // QuickHelp and/or WinHelp documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10.  
  11.  
  12. #ifndef __AFXOLE_H__
  13. #define __AFXOLE_H__
  14.  
  15. #ifndef __AFXWIN_H__
  16. #include "afxwin.h"
  17. #endif
  18.  
  19. /////////////////////////////////////////////////////////////////////////////
  20. // AFXOLE - MFC OLE support
  21.  
  22. // Classes declared in this file
  23.  
  24.     //CException
  25.         class COleException;    // caught by client
  26.  
  27.     //CDocument
  28.         class COleDocument;           // OLE compatible document
  29.             class COleClientDoc; // contains client items
  30.             class COleServerDoc; // contains server items only
  31.  
  32.     class CDocItem;                 // part of a document
  33.         class COleClientItem;       // embedded ole object from outside
  34.         class COleServerItem;       // ole object to export
  35.  
  36.     class COleServer;               // server
  37.         class COleTemplateServer;   // server using DocTemplates
  38.  
  39. /////////////////////////////////////////////////////////////////////////////
  40.  
  41. #define SERVERONLY
  42. #include "ole.h"
  43.  
  44. // max size of OLE name buffer (255 actual characters)
  45. #define OLE_MAXNAMESIZE     256
  46.  
  47. // AFXDLL support
  48. #undef AFXAPP_DATA
  49. #define AFXAPP_DATA     AFXAPI_DATA
  50.  
  51. /////////////////////////////////////////////////////////////////////////////
  52. // COleException - something going wrong
  53.  
  54. class COleException : public CException
  55. {
  56.     DECLARE_DYNAMIC(COleException)
  57. public:
  58.     OLESTATUS m_status;
  59.     static OLESTATUS PASCAL Process(CException*);   // helper
  60.  
  61. // Implementation (use AfxThrowOleException to create)
  62.     COleException(OLESTATUS status);
  63. };
  64.  
  65. void AFXAPI AfxThrowOleException(OLESTATUS status);
  66.  
  67. //////////////////////////////////////////////////////////////////////////////
  68. // DocItem support
  69.  
  70. class CDocItem : public CObject
  71. {
  72.     DECLARE_DYNAMIC(CDocItem)
  73.  
  74. // Constructors
  75. protected:      // abstract class
  76.     CDocItem();
  77.  
  78. // Attributes
  79. public:
  80.     CDocument* GetDocument() const; // return container
  81.  
  82. // Operations
  83. public:
  84.  
  85. // Overridables
  86. public:
  87.     // Raw data access (native format)
  88.     virtual void Serialize(CArchive& ar) = 0; // for Native data
  89.  
  90. // Implementation
  91. protected:
  92.     COleDocument* m_pDocument;
  93. public:
  94.     virtual ~CDocItem();
  95. #ifdef _DEBUG
  96.     virtual void AssertValid() const;
  97.     virtual void Dump(CDumpContext& dc) const;
  98. #endif //_DEBUG
  99.     friend class COleDocument;              // for access to back pointer
  100. };
  101.  
  102. //////////////////////////////////////////////////////////////////////////////
  103. // COleDocument - common OLE container behavior (enables server functionality)
  104.  
  105. class COleDocument : public CDocument
  106. {
  107.     DECLARE_DYNAMIC(COleDocument)
  108.  
  109. // Constructors
  110. protected:
  111.     COleDocument();
  112.  
  113. // Attributes
  114. public:
  115.     BOOL IsOpenClientDoc() const;
  116.     BOOL IsOpenServerDoc() const;
  117.  
  118. // Operations
  119.     // iterating over existing items
  120.     virtual POSITION GetStartPosition() const;
  121.     virtual CDocItem* GetNextItem(POSITION& rPosition);
  122.  
  123.     // adding new items - for implementation in derived classes
  124.     void AddItem(CDocItem* pItem);
  125.     void RemoveItem(CDocItem* pItem);
  126.  
  127. // Implementation
  128. public:
  129.     LHCLIENTDOC m_lhClientDoc;          // registered handle
  130.     LHSERVERDOC m_lhServerDoc;          // registered handle
  131.     CPtrList m_docItemList;      // not owned items
  132.  
  133. public:
  134.     virtual ~COleDocument();
  135.     virtual void DeleteContents(); // delete doc items in list
  136. #ifdef _DEBUG
  137.     virtual void AssertValid() const;
  138.     virtual void Dump(CDumpContext& dc) const;
  139. #endif
  140. };
  141.  
  142. /////////////////////////////////////////////////////////////////////////////
  143. // COleClientItem - Client view of an OLEOBJECT + OLECLIENT for callbacks
  144.  
  145. class COleClientItem : public CDocItem
  146. {
  147.     DECLARE_DYNAMIC(COleClientItem)
  148.  
  149. // Constructors
  150. public:
  151.     COleClientItem(COleClientDoc* pContainerDoc);
  152.  
  153.     // create from the clipboard
  154.     BOOL CreateFromClipboard(LPCSTR lpszItemName,
  155.                 OLEOPT_RENDER renderopt = olerender_draw,
  156.                 OLECLIPFORMAT cfFormat = 0);
  157.     BOOL CreateStaticFromClipboard(LPCSTR lpszItemName,
  158.                 OLEOPT_RENDER renderopt = olerender_draw,
  159.                 OLECLIPFORMAT cfFormat = 0);
  160.     BOOL CreateLinkFromClipboard(LPCSTR lpszItemName,
  161.                 OLEOPT_RENDER renderopt = olerender_draw,
  162.                 OLECLIPFORMAT cfFormat = 0);
  163.  
  164.     // create from a protocol name (Insert New Object dialog)
  165.     BOOL CreateNewObject(LPCSTR lpszTypeName, LPCSTR lpszItemName,
  166.                 OLEOPT_RENDER renderopt = olerender_draw,
  167.                 OLECLIPFORMAT cfFormat = 0);
  168.     // special create for invisible
  169.     BOOL CreateInvisibleObject(LPCSTR lpszTypeName, LPCSTR lpszItemName,
  170.                 OLEOPT_RENDER renderopt = olerender_draw,
  171.                 OLECLIPFORMAT cfFormat = 0, BOOL bActivate = FALSE);
  172.  
  173.     // create a copy
  174.     BOOL CreateCloneFrom(COleClientItem* pSrcItem, LPCSTR lpszItemName);
  175.  
  176. // General Attributes
  177.     OLESTATUS GetLastStatus() const;
  178.     UINT GetType();  // OT_LINK, OT_EMBEDDED or OT_STATIC
  179.     CString GetName();
  180.  
  181.     DWORD GetSize();                // return size of item
  182.     BOOL GetBounds(LPRECT lpBounds); // return FALSE if BLANK
  183.  
  184.     BOOL IsOpen();                   // currently open on server side
  185.  
  186.     // Data access
  187.     OLECLIPFORMAT EnumFormats(OLECLIPFORMAT nFormat) const;
  188.     HANDLE GetData(OLECLIPFORMAT nFormat, BOOL& bMustDelete);
  189.     void SetData(OLECLIPFORMAT nFormat, HANDLE hData);
  190.     void RequestData(OLECLIPFORMAT nFormat);
  191.  
  192.     // Other rare access information
  193.     BOOL IsEqual(COleClientItem* pOtherItem);
  194.     COleClientDoc* GetDocument() const; // return container
  195.  
  196.     // global state - if anyone waiting for release => not normal operations
  197.     static BOOL PASCAL InWaitForRelease();
  198.  
  199.     // Helpers for checking clipboard data availability
  200.     static BOOL PASCAL CanPaste(OLEOPT_RENDER renderopt = olerender_draw,
  201.                 OLECLIPFORMAT cfFormat = 0);
  202.     static BOOL PASCAL CanPasteLink(OLEOPT_RENDER renderopt = olerender_draw,
  203.                 OLECLIPFORMAT cfFormat = 0);
  204.  
  205. // General Operations
  206.     // Clean up
  207.     void Release();              // detach (close if needed)
  208.     void Delete();               // get rid of it then detach
  209.  
  210.     // Drawing
  211.     BOOL Draw(CDC* pDC, LPCRECT lpBounds,
  212.             LPCRECT lpWBounds = NULL, CDC* pFormatDC = NULL);
  213.  
  214.     // Activation
  215.     virtual BOOL DoVerb(UINT nVerb);    // general run verb, calls Activate
  216.     void Activate(UINT nVerb, BOOL bShow = TRUE, BOOL bTakeFocus = TRUE,
  217.                 CWnd* pWndContainer = NULL, LPCRECT lpBounds = NULL);
  218.  
  219.     // more advanced operations
  220.     void Rename(LPCSTR lpszNewname);    // call to rename item
  221.     void CopyToClipboard();
  222.     void SetTargetDevice(HGLOBAL hData);
  223.             // handle to an OLETARGETDEVICE
  224.  
  225. // Operations that apply to Embedded Objects only
  226.     void SetHostNames(LPCSTR lpszHost, LPCSTR lpszHostObj);
  227.     void SetBounds(LPCRECT lpRect);
  228.     void SetColorScheme(const LOGPALETTE FAR* lpLogPalette);
  229.  
  230. // Operations that apply to Linked Objects only
  231.     // Link options are rarely changed (except through Links dialog)
  232.     OLEOPT_UPDATE GetLinkUpdateOptions();
  233.     void SetLinkUpdateOptions(OLEOPT_UPDATE updateOpt);
  234.  
  235.     void UpdateLink();               // make up-to-date
  236.     void CloseLink();                // close connection
  237.                                         // can be used for embedded (rare)
  238.     void ReconnectLink();            // reactivate connection
  239.  
  240. // Overridables (notifications of OLECLIENT)
  241. protected:
  242.     // notifications from the server you must implement
  243.     virtual void OnChange(OLE_NOTIFICATION wNotification) = 0;
  244.             // Change due to link update (OLE_CHANGED),
  245.             //   document save (OLE_SAVED) or document close (OLE_CLOSED)
  246.  
  247.     // notifications you do not have to implement
  248.     virtual void OnRenamed();           // document has been renamed
  249.  
  250. // Implementation
  251. protected:
  252.     OLECLIENT m_oleClient; // must be first member variable in this class
  253.     OLESTATUS m_lastStatus;
  254.  
  255. public: // in case you want direct access
  256.     LPOLEOBJECT m_lpObject;
  257.  
  258. public:
  259.     virtual ~COleClientItem();
  260. #ifdef _DEBUG
  261.     virtual void AssertValid() const;
  262.     virtual void Dump(CDumpContext& dc) const;
  263. #endif
  264.     virtual void Serialize(CArchive& ar);
  265.  
  266. public:
  267.     // Implementation helpers
  268.     virtual BOOL ReportOleError(OLESTATUS status);
  269.     virtual BOOL FreezeLink(LPCSTR lpszFrozenName); // link -> embedded
  270.     // Advanced Overridables for implementation
  271.     static COleClientItem* PASCAL FromLp(LPOLECLIENT lpClient);
  272.     HGLOBAL GetLinkFormatData();
  273.  
  274. protected:
  275.     // Advanced Overridables for implementation
  276.     virtual int ClientCallBack(OLE_NOTIFICATION wNotification);
  277.     virtual BOOL CheckCreate(OLESTATUS status);
  278.     virtual void CheckAsync(OLESTATUS status);
  279.     virtual void CheckGeneral(OLESTATUS status);
  280.     virtual void WaitForServer();
  281.     virtual void OnRelease();
  282.  
  283.     friend struct _afxOleCliImpl;
  284.     friend class COleClientDoc;
  285. };
  286.  
  287. //////////////////////////////////////////////////////////////////////////////
  288. // COleClientDoc - document that registered client document
  289.  
  290. class COleClientDoc : public COleDocument
  291. {
  292.     DECLARE_DYNAMIC(COleClientDoc)
  293.  
  294. // Constructors and Destructors
  295. public:
  296.     COleClientDoc();
  297.     BOOL RegisterClientDoc(LPCSTR lpszTypeName, LPCSTR lpszDoc);
  298.     void Revoke();           // called by destructor
  299.  
  300. // Operations (notify the global registry)
  301.     void NotifyRename(LPCSTR lpszNewName);
  302.                                 // call this after document is renamed
  303.     void NotifyRevert();     // call this after document reverts to original
  304.     void NotifySaved();      // call this after document is saved
  305.  
  306.     virtual COleClientItem* GetPrimarySelectedItem(CView*);
  307.                     // return primary selected item or NULL if none
  308.  
  309. // Implementation
  310. public:
  311.     virtual ~COleClientDoc();
  312. #ifdef _DEBUG
  313.     virtual void AssertValid() const;
  314.     virtual void Dump(CDumpContext& dc) const;
  315. #endif
  316.     // Advanced Overridables for implementation
  317.     virtual void CheckGeneral(OLESTATUS status) const;
  318.  
  319. protected:
  320.     virtual BOOL OnNewDocument();
  321.     virtual BOOL OnOpenDocument(const char* pszPathName);
  322.     virtual BOOL OnSaveDocument(const char* pszPathName);
  323.     virtual void OnCloseDocument();
  324.     virtual BOOL CanCloseFrame(CFrameWnd* pFrame);
  325.     virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra,
  326.         AFX_CMDHANDLERINFO* pHandlerInfo);
  327.     //{{AFX_MSG(COleClientDoc)
  328.     afx_msg void OnUpdatePasteMenu(CCmdUI* pCmdUI);
  329.     afx_msg void OnUpdatePasteLinkMenu(CCmdUI* pCmdUI);
  330.     afx_msg void OnUpdateEditLinksMenu(CCmdUI* pCmdUI);
  331.     afx_msg void OnEditLinks();
  332.     afx_msg void OnUpdateObjectVerbMenu(CCmdUI* pCmdUI);
  333.     //}}AFX_MSG
  334.     DECLARE_MESSAGE_MAP()
  335. };
  336.  
  337. /////////////////////////////////////////////////////////////////////////////
  338. // User interface helper functions
  339.  
  340. void AFXAPI AfxOleSetEditMenu(COleClientItem* pClient, CMenu* pMenu,
  341.                 UINT iMenuItem, UINT nIDVerbMin);
  342. BOOL AFXAPI AfxOleInsertDialog(CString& name);
  343. BOOL AFXAPI AfxOleLinksDialog(COleClientDoc* pDoc, CView* pView);
  344.  
  345. /////////////////////////////////////////////////////////////////////////////
  346. /////////////////////////////////////////////////////////////////////////////
  347. // COleServerItem - Server view of an OLEOBJECT + OLECLIENT
  348.  
  349. class COleServerItem : public CDocItem
  350. {
  351.     DECLARE_DYNAMIC(COleServerItem)
  352. protected:
  353.     // NOTE: most members in this class are protected - since everything
  354.     //   in this class is designed for implementing an OLE server.
  355.     // Requests will come from OLE Clients through non-C++ mechanisms,
  356.     //   which will result in virtual functions in this class being
  357.     //   called.
  358.  
  359. // Constructors
  360.     COleServerItem(COleServerDoc* pContainerDoc);
  361.  
  362. // Public Attributes
  363. public:
  364.     COleServerDoc* GetDocument() const; // return container
  365.     BOOL IsConnected() const;  // TRUE if connected to client
  366.     const CString& GetItemName() const;     // get name of linked item
  367.     void SetItemName(const char* pszItemName);  // set name of linked item
  368.  
  369. // Operations
  370. public:
  371.     void NotifyChanged();        // call this after you change item
  372.     void Revoke();               // revoke client connection and wait
  373.     BOOL CopyToClipboard(BOOL bIncludeNative, BOOL bIncludeLink);
  374.                                 // for implementing server 'copy to clipboard'
  375.  
  376. // Overridables you must implement for yourself
  377.     // Raw data access
  378.     virtual void Serialize(CArchive& ar) = 0; // for Native data
  379.  
  380.     // Drawing for metafile format (return FALSE if not supported or error)
  381.     virtual BOOL OnDraw(CDC* pDC) = 0; // draw to boundaries set in m_rectBounds
  382.  
  383. // Overridables you may want to implement yourself
  384.     virtual OLESTATUS OnExtraVerb(UINT nVerb);
  385.                             // do extra verbs - default is not implemented
  386.     virtual OLESTATUS OnSetTargetDevice(LPOLETARGETDEVICE lpTargetDevice);
  387.                             // track target device changes - default ignores
  388.     virtual OLESTATUS OnSetBounds(LPCRECT lpRect);
  389.                             // track size changes - default updates m_rectBounds
  390.  
  391.     virtual OLESTATUS OnShow(BOOL bTakeFocus);
  392.                             // show item in the user interface
  393.     virtual BOOL OnGetTextData(CString& rStringReturn) const;
  394.                             // get data as text
  395.  
  396.     // more advanced implementation
  397.     virtual OLESTATUS OnGetData(OLECLIPFORMAT nFormat, LPHANDLE lphReturn);
  398.  
  399. protected:
  400. // Overridables you do not have to implement
  401.     virtual OLESTATUS OnSetColorScheme(const LOGPALETTE FAR* lpLogPalette);
  402.                             // default does nothing
  403.     virtual OLECLIPFORMAT OnEnumFormats(OLECLIPFORMAT nFormat) const;
  404.                             // default handles native + std. formats
  405.     virtual OLESTATUS OnSetData(OLECLIPFORMAT nFormat, HANDLE hData);
  406.                             // default routes to GetNativeData
  407.     virtual OLESTATUS OnDoVerb(UINT nVerb, BOOL bShow, BOOL bTakeFocus);
  408.                             // default routes to OnShow &/or OnExtraVerb
  409.  
  410. // Implementation
  411. protected:
  412.     OLEOBJECT m_oleObject;        // must be first member variable
  413.     LPOLECLIENT m_lpClient;
  414.     CRect m_rectBounds;       // HIMETRIC. If IsRectNull => not set yet
  415.     CString m_strItemName;    // simple item name
  416.  
  417. public:
  418.     void BeginRevoke();          // revoke client connection
  419.     int NotifyClient(OLE_NOTIFICATION wNotification);
  420.     virtual ~COleServerItem();
  421. #ifdef _DEBUG
  422.     virtual void AssertValid() const;
  423.     virtual void Dump(CDumpContext& dc) const;
  424. #endif
  425. protected:
  426.     // Advanced Overridables for implementation
  427.     virtual HGLOBAL GetLinkFormatData(BOOL bObjectLink);
  428.     virtual HGLOBAL GetMetafileData();   // calls 'OnDraw(...)'
  429.     virtual HGLOBAL GetNativeData();     // calls 'Serialize(...)'
  430.     virtual LPVOID OnQueryProtocol(LPCSTR lpszProtocol) const;
  431.                             // default handles "StdFileEditing"
  432.     virtual OLESTATUS OnRelease();
  433.  
  434.     // Implementation helpers
  435.     static COleServerItem* PASCAL FromLp(LPOLEOBJECT lpObject);
  436.     friend struct _afxOleSvrItemImpl;
  437.     friend class COleServerDoc;
  438.     friend struct _afxOleSvrDocImpl;
  439. };
  440.  
  441. //////////////////////////////////////////////////////////////////////////////
  442. // COleServerDoc - registered server document containing COleServerItems
  443.  
  444. class COleServerDoc : public COleDocument
  445. {
  446.     DECLARE_DYNAMIC(COleServerDoc)
  447.  
  448. // Constructors and Destructors
  449. public:
  450.     COleServerDoc();
  451.  
  452. // Special construction routines if opened by user (or linked file)
  453.     BOOL RegisterServerDoc(COleServer* pServer, LPCSTR lpszDoc);
  454.                             // call if opened by user (eg: File Open)
  455.     void Revoke();       // Revoke and wait to finish
  456.  
  457. // Operations
  458.     // changes to the entire document (automatically notifies clients)
  459.     void NotifyRename(LPCSTR lpszNewName);
  460.     void NotifyRevert();
  461.     void NotifySaved();
  462.  
  463.     // specific notifications for clients
  464.     void NotifyClosed();         // call this after you close document
  465.     void NotifyChanged();        // call this after you change some
  466.                                     // global attibute like doc dimensions
  467. protected:
  468. // Overridables you must implement for yourself
  469.     virtual COleServerItem* OnGetEmbeddedItem() = 0;
  470.                 // return new item representing entire [embedded] document
  471.     virtual COleServerItem* OnGetLinkedItem(LPCSTR lpszItemName);
  472.                 // return new item for the named linked item
  473.  
  474. // Overridables you may want to implement yourself
  475.     virtual OLESTATUS OnClose();
  476.     virtual OLESTATUS OnExecute(LPVOID lpCommands);
  477.     virtual OLESTATUS OnSetDocDimensions(LPCRECT lpRect);
  478.  
  479. // Overridables you do not have to implement
  480.     virtual OLESTATUS OnSetHostNames(LPCSTR lpszHost, LPCSTR lpszHostObj);
  481.     virtual OLESTATUS OnSetColorScheme(const LOGPALETTE FAR* lpLogPalette);
  482.  
  483. // Overridables for standard user interface (full server)
  484.     virtual BOOL OnUpdateDocument(); // implementation of embedded update
  485.  
  486. // Implementation
  487. protected:
  488.     OLESERVERDOC m_oleServerDoc;        // must be first member variable
  489.     BOOL m_bWaiting;
  490. public:
  491.     COleServer* m_pServer;
  492.  
  493. public:
  494.     virtual ~COleServerDoc();
  495. #ifdef _DEBUG
  496.     virtual void AssertValid() const;
  497.     virtual void Dump(CDumpContext& dc) const;
  498. #endif
  499. protected:
  500.     // Advanced Overridables for implementation
  501.     virtual void CheckAsync(OLESTATUS status);
  502.     virtual OLESTATUS OnRelease();
  503.     virtual OLESTATUS OnSave(); // not used in V1
  504.  
  505.     // Implementation helpers
  506.     static COleServerDoc* PASCAL FromLp(LPOLESERVERDOC lpServerDoc);
  507.     void NotifyAllClients(OLE_NOTIFICATION wNotification);
  508.     OLESTATUS BeginRevoke();  // Revoke but don't wait
  509.     void RegisterIfServerAttached(const char* pszPathName);
  510.  
  511.     virtual BOOL OnNewDocument();
  512.     virtual BOOL OnOpenDocument(const char* pszPathName);
  513.     virtual BOOL OnSaveDocument(const char* pszPathName);
  514.     virtual void OnCloseDocument();
  515.     virtual BOOL SaveModified(); // return TRUE if ok to continue
  516.  
  517.     friend struct _afxOleSvrDocImpl;
  518.     friend class COleServer;
  519.     friend struct _afxSvrImpl;
  520.     //{{AFX_MSG(COleServerDoc)
  521.     afx_msg void OnUpdateFileSaveMenu(CCmdUI* pCmdUI);
  522.     afx_msg void OnFileSaveOrUpdate();
  523.     afx_msg void OnFileSaveAs();
  524.     //}}AFX_MSG
  525.     DECLARE_MESSAGE_MAP()
  526. };
  527.  
  528. //////////////////////////////////////////////////////////////////////////////
  529. // COleServer - registered server application
  530.  
  531. class COleServer : public CObject
  532. {
  533.     DECLARE_DYNAMIC(COleServer)
  534.  
  535. // Constructors and Destructors
  536. public:
  537.     COleServer(BOOL bLaunchEmbedded);
  538.     BOOL Register(LPCSTR lpszTypeName, BOOL bMultiInstance);
  539.     void BeginRevoke();
  540.  
  541. // Attributes
  542. public:
  543.     BOOL IsOpen() const;         // TRUE if successfully registered
  544.     const CString& GetServerName() const;       // registered name
  545.  
  546. // Overridables you must implement for yourself
  547. protected:
  548.     // for those supporting embedding
  549.     virtual COleServerDoc* OnCreateDoc(LPCSTR lpszTypeName, LPCSTR lpszDoc) = 0;
  550.     virtual COleServerDoc* OnEditDoc(LPCSTR lpszTypeName, LPCSTR lpszDoc) = 0;
  551.  
  552. // Overridables you may want to implement yourself
  553.     // for those supporting links
  554.     virtual COleServerDoc* OnOpenDoc(LPCSTR lpszDoc);
  555.     // for those supporting embedding from template files (not CDocTemplates!)
  556.     virtual COleServerDoc* OnCreateDocFromTemplateFile(LPCSTR lpszTypeName,
  557.                 LPCSTR lpszDoc, LPCSTR lpszTemplate);
  558.     // for those supporting DDE execute commands
  559.     virtual OLESTATUS OnExecute(LPVOID lpCommands);
  560.  
  561.     // Overridables you do not have to implement
  562.     virtual OLESTATUS OnExit();     // default to BeginRevoke
  563.  
  564. // Implementation support of managing # of open documents
  565. protected:
  566.     void AddDocument(COleServerDoc* pDoc, LHSERVERDOC lhServerDoc);
  567.     void RemoveDocument(COleServerDoc* pDoc);
  568.  
  569. // Implementation
  570. protected:
  571.     OLESERVER m_oleServer;          // must be first member variable
  572.     LHSERVER m_lhServer;            // registered handle
  573.     CString m_strServerName;        // registered name
  574. public:
  575.     // Public attributes - access only if you know what you are doing
  576.     BOOL m_bLaunchEmbedded;
  577.     int m_cOpenDocuments;
  578.  
  579.     virtual ~COleServer();
  580. #ifdef _DEBUG
  581.     virtual void AssertValid() const;
  582.     virtual void Dump(CDumpContext& dc) const;
  583. #endif
  584.  
  585. protected:
  586.     // Advanced Overridables for implementation
  587.     virtual OLESTATUS OnRelease();  // default to cleanup
  588.     // Implementation helpers
  589.     static COleServer* PASCAL FromLp(LPOLESERVER lpServer);
  590.     friend class COleServerDoc;
  591.     friend struct _afxSvrImpl;
  592. };
  593.  
  594. // Helper to register server in case of no .REG file loaded
  595. BOOL AFXAPI AfxOleRegisterServerName(LPCSTR lpszTypeName,
  596.                 LPCSTR lpszLocalTypeName);
  597.  
  598. //////////////////////////////////////////////////////////////////////////////
  599. // COleTemplateServer - COleServer using CDocTemplates
  600.  
  601. class COleTemplateServer : public COleServer
  602. {
  603. public:
  604.     COleTemplateServer();
  605.     BOOL RunEmbedded(CDocTemplate* pDocTemplate,
  606.         BOOL bMultiInstance, LPCSTR lpszCmdLine);
  607.         // return TRUE if running embedded (may open file on cmd line)
  608.  
  609. // Implementation
  610. protected:
  611. // Overridables for OLE Server requests
  612.     virtual COleServerDoc* OnOpenDoc(LPCSTR lpszDoc);
  613.     virtual COleServerDoc* OnCreateDoc(LPCSTR lpszTypeName, LPCSTR lpszDoc);
  614.     virtual COleServerDoc* OnEditDoc(LPCSTR lpszTypeName, LPCSTR lpszDoc);
  615.  
  616. // Implementation
  617.     CDocTemplate* m_pDocTemplate;
  618. };
  619.  
  620. /////////////////////////////////////////////////////////////////////////////
  621. // Inline function declarations
  622.  
  623. #ifdef _AFX_ENABLE_INLINES
  624. #define _AFXOLE_INLINE inline
  625. #define _AFXOLECLI_INLINE inline
  626. #define _AFXOLESVR_INLINE inline
  627. #include "afxole.inl"
  628. #endif
  629.  
  630. #undef AFXAPP_DATA
  631. #define AFXAPP_DATA     NEAR
  632.  
  633. //////////////////////////////////////////////////////////////////////////////
  634. #endif //__AFXOLE_H__
  635.