home *** CD-ROM | disk | FTP | other *** search
/ ActiveX Programming Unleashed CD / AXU.iso / source / chap18 / doserver / oleobjct.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-02  |  7.2 KB  |  238 lines

  1. // oleobjct.cpp : implementation of the DocObject OLE server
  2. //    document class IOleObject interface
  3.  
  4. // This is a part of the Microsoft Foundation Classes C++ library.
  5. // Copyright (C) 1992-1996 Microsoft Corporation
  6. // All rights reserved.
  7. //
  8. // This source code is only intended as a supplement to the
  9. // Microsoft Foundation Classes Reference and related
  10. // electronic documentation provided with the library.
  11. // See these sources for detailed information regarding the
  12. // Microsoft Foundation Classes product.
  13.  
  14. #include "stdafx.h"
  15. #include "binddoc.h"
  16.  
  17. #ifdef _DEBUG
  18. #undef THIS_FILE
  19. static char BASED_CODE THIS_FILE[] = __FILE__;
  20. #endif
  21.  
  22. STDMETHODIMP_(ULONG) CDocObjectServerDoc::XDocOleObject::AddRef()
  23. {
  24.     METHOD_PROLOGUE_EX(CDocObjectServerDoc, DocOleObject)
  25.     return pThis->ExternalAddRef();
  26. }
  27.  
  28. STDMETHODIMP_(ULONG) CDocObjectServerDoc::XDocOleObject::Release()
  29. {
  30.     METHOD_PROLOGUE_EX(CDocObjectServerDoc, DocOleObject)
  31.     return pThis->ExternalRelease();
  32. }
  33.  
  34. STDMETHODIMP CDocObjectServerDoc::XDocOleObject::QueryInterface(
  35.     REFIID iid, LPVOID* ppvObj)
  36. {
  37.     METHOD_PROLOGUE_EX(CDocObjectServerDoc, DocOleObject)
  38.     return pThis->ExternalQueryInterface(&iid, ppvObj);
  39. }
  40.  
  41. STDMETHODIMP CDocObjectServerDoc::XDocOleObject::SetClientSite(
  42.     LPOLECLIENTSITE pClientSite)
  43. {
  44.     METHOD_PROLOGUE_EX(CDocObjectServerDoc, DocOleObject)
  45.     ASSERT_VALID(pThis);
  46.     HRESULT hr = NOERROR;
  47.  
  48.     // Perform normal SetClientSite processing.
  49.     hr = pThis->m_xOleObject.SetClientSite(pClientSite);
  50.     if (hr != S_OK)
  51.         return hr;
  52.  
  53.     // If we currently have a document site pointer, 
  54.     // release it.
  55.     if (pThis->m_pDocSite != NULL)
  56.     {
  57.         pThis->m_pDocSite->Release();
  58.         pThis->m_pDocSite = NULL;
  59.     }
  60.  
  61.     // Check to see whether this object should act
  62.     // as a document object by querying for 
  63.     // IOleDocumentSite.
  64.     if (pClientSite != NULL)
  65.         hr = pClientSite->QueryInterface(IID_IOleDocumentSite,
  66.             (LPVOID*)&pThis->m_pDocSite);
  67.     return hr;
  68. }
  69.  
  70. STDMETHODIMP CDocObjectServerDoc::XDocOleObject::GetClientSite(
  71.     LPOLECLIENTSITE* ppClientSite)
  72. {
  73.     METHOD_PROLOGUE_EX(CDocObjectServerDoc, DocOleObject)
  74.     ASSERT_VALID(pThis);
  75.     return pThis->m_xOleObject.GetClientSite(ppClientSite);
  76. }
  77.  
  78. STDMETHODIMP CDocObjectServerDoc::XDocOleObject::SetHostNames(
  79.     LPCOLESTR lpszContainerApp, LPCOLESTR lpszContainerObj)
  80. {
  81.     METHOD_PROLOGUE_EX(CDocObjectServerDoc, DocOleObject)
  82.     ASSERT_VALID(pThis);
  83.    return pThis->m_xOleObject.SetHostNames(lpszContainerApp,
  84.                                            lpszContainerObj);
  85. }
  86.  
  87. STDMETHODIMP CDocObjectServerDoc::XDocOleObject::Close(DWORD dwSaveOption)
  88. {
  89.     METHOD_PROLOGUE_EX(CDocObjectServerDoc, DocOleObject)
  90.     ASSERT_VALID(pThis);
  91.     return pThis->m_xOleObject.Close(dwSaveOption);
  92. }
  93.  
  94. STDMETHODIMP CDocObjectServerDoc::XDocOleObject::SetMoniker(
  95.     DWORD dwWhichMoniker, LPMONIKER pmk)
  96. {
  97.     METHOD_PROLOGUE_EX(CDocObjectServerDoc, DocOleObject)
  98.     ASSERT_VALID(pThis);
  99.     return pThis->m_xOleObject.SetMoniker(dwWhichMoniker, pmk);
  100. }
  101.  
  102. STDMETHODIMP CDocObjectServerDoc::XDocOleObject::GetMoniker(
  103.     DWORD dwAssign, DWORD dwWhichMoniker, LPMONIKER* ppMoniker)
  104. {
  105.     METHOD_PROLOGUE_EX(CDocObjectServerDoc, DocOleObject)
  106.     ASSERT_VALID(pThis);
  107.     return pThis->m_xOleObject.GetMoniker(dwAssign, dwWhichMoniker,
  108.                                          ppMoniker);
  109. }
  110.  
  111. STDMETHODIMP CDocObjectServerDoc::XDocOleObject::InitFromData(
  112.     LPDATAOBJECT pDataObject, BOOL bCreation, DWORD dwReserved)
  113. {
  114.     METHOD_PROLOGUE_EX(CDocObjectServerDoc, DocOleObject)
  115.     ASSERT_VALID(pThis);
  116.     return pThis->m_xOleObject.InitFromData(pDataObject, bCreation,
  117.                                            dwReserved);
  118. }
  119.  
  120. STDMETHODIMP CDocObjectServerDoc::XDocOleObject::GetClipboardData(
  121.     DWORD dwReserved, LPDATAOBJECT* ppDataObject)
  122. {
  123.     METHOD_PROLOGUE_EX(CDocObjectServerDoc, DocOleObject)
  124.     ASSERT_VALID(pThis);
  125.     return pThis->m_xOleObject.GetClipboardData(dwReserved, 
  126.                                                ppDataObject);
  127.  
  128. }
  129.  
  130. STDMETHODIMP CDocObjectServerDoc::XDocOleObject::DoVerb(
  131.     LONG iVerb, LPMSG lpmsg, LPOLECLIENTSITE pActiveSite, LONG lindex,
  132.     HWND hwndParent, LPCRECT lpPosRect)
  133. {
  134.     METHOD_PROLOGUE_EX(CDocObjectServerDoc, DocOleObject)
  135.     ASSERT_VALID(pThis);
  136.     return pThis->m_xOleObject.DoVerb(iVerb, lpmsg, 
  137.                                      pActiveSite, lindex,
  138.                                       hwndParent, lpPosRect);
  139. }
  140.  
  141. STDMETHODIMP CDocObjectServerDoc::XDocOleObject::EnumVerbs(
  142.     IEnumOLEVERB** ppenumOleVerb)
  143. {
  144.     METHOD_PROLOGUE_EX(CDocObjectServerDoc, DocOleObject)
  145.     ASSERT_VALID(pThis);
  146.     return pThis->m_xOleObject.EnumVerbs(ppenumOleVerb);
  147. }
  148.  
  149. STDMETHODIMP CDocObjectServerDoc::XDocOleObject::Update()
  150. {
  151.     METHOD_PROLOGUE_EX(CDocObjectServerDoc, DocOleObject)
  152.     ASSERT_VALID(pThis);
  153.     return pThis->m_xOleObject.Update();
  154. }
  155.  
  156. STDMETHODIMP CDocObjectServerDoc::XDocOleObject::IsUpToDate()
  157. {
  158.     METHOD_PROLOGUE_EX(CDocObjectServerDoc, DocOleObject)
  159.     ASSERT_VALID(pThis);
  160.     return pThis->m_xOleObject.IsUpToDate();
  161. }
  162.  
  163. STDMETHODIMP CDocObjectServerDoc::XDocOleObject::GetUserClassID(CLSID* lpClassID)
  164. {
  165.     METHOD_PROLOGUE_EX(CDocObjectServerDoc, DocOleObject)
  166.     ASSERT_VALID(pThis);
  167.     return pThis->m_xOleObject.GetUserClassID(lpClassID);
  168. }
  169.  
  170. STDMETHODIMP CDocObjectServerDoc::XDocOleObject::GetUserType(
  171.     DWORD dwFormOfType, LPOLESTR* ppszUserType)
  172. {
  173.     METHOD_PROLOGUE_EX(CDocObjectServerDoc, DocOleObject)
  174.     ASSERT_VALID(pThis);
  175.     return pThis->m_xOleObject.GetUserType(dwFormOfType, ppszUserType);
  176. }
  177.  
  178. STDMETHODIMP CDocObjectServerDoc::XDocOleObject::SetExtent(
  179.     DWORD dwDrawAspect, LPSIZEL lpsizel)
  180. {
  181.     METHOD_PROLOGUE_EX(CDocObjectServerDoc, DocOleObject)
  182.     ASSERT_VALID(pThis);
  183.  
  184.    // DocObjects ignore SetExtent calls, so returne E_FAIL
  185.    if (pThis->IsDocObject())
  186.       return E_FAIL;
  187.  
  188.    // Otherwise, just do the normal processing
  189.    return pThis->m_xOleObject.SetExtent(dwDrawAspect, lpsizel);
  190. }
  191.  
  192. STDMETHODIMP CDocObjectServerDoc::XDocOleObject::GetExtent(
  193.     DWORD dwDrawAspect, LPSIZEL lpsizel)
  194. {
  195.     METHOD_PROLOGUE_EX(CDocObjectServerDoc, DocOleObject)
  196.     ASSERT_VALID(pThis);
  197.     return pThis->m_xOleObject.GetExtent(dwDrawAspect, lpsizel);
  198. }
  199.  
  200. STDMETHODIMP CDocObjectServerDoc::XDocOleObject::Advise(
  201.     LPADVISESINK pAdvSink, DWORD* pdwConnection)
  202. {
  203.     METHOD_PROLOGUE_EX(CDocObjectServerDoc, DocOleObject)
  204.     ASSERT_VALID(pThis);
  205.     return pThis->m_xOleObject.Advise(pAdvSink, pdwConnection);
  206. }
  207.  
  208. STDMETHODIMP CDocObjectServerDoc::XDocOleObject::Unadvise(DWORD dwConnection)
  209. {
  210.     METHOD_PROLOGUE_EX(CDocObjectServerDoc, DocOleObject)
  211.     ASSERT_VALID(pThis);
  212.     return pThis->m_xOleObject.Unadvise(dwConnection);
  213. }
  214.  
  215. STDMETHODIMP CDocObjectServerDoc::XDocOleObject::EnumAdvise(
  216.     LPENUMSTATDATA* ppenumStatData)
  217. {
  218.     METHOD_PROLOGUE_EX(CDocObjectServerDoc, DocOleObject)
  219.     ASSERT_VALID(pThis);
  220.     return pThis->m_xOleObject.EnumAdvise(ppenumStatData);
  221. }
  222.  
  223. STDMETHODIMP CDocObjectServerDoc::XDocOleObject::GetMiscStatus(
  224.     DWORD dwAspect, DWORD* pdwStatus)
  225. {
  226.     METHOD_PROLOGUE_EX(CDocObjectServerDoc, DocOleObject)
  227.     ASSERT_VALID(pThis);
  228.     return pThis->m_xOleObject.GetMiscStatus(dwAspect, pdwStatus);
  229. }
  230.  
  231. STDMETHODIMP CDocObjectServerDoc::XDocOleObject::SetColorScheme(LPLOGPALETTE lpLogpal)
  232. {
  233.     METHOD_PROLOGUE_EX(CDocObjectServerDoc, DocOleObject)
  234.     ASSERT_VALID(pThis);
  235.     return pThis->m_xOleObject.SetColorScheme(lpLogpal);
  236. }
  237.  
  238.