Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1085 lines
27 KiB

  1. //**********************************************************************
  2. // File name: IOO.CPP
  3. //
  4. // Implementation file for the COleObject Class
  5. //
  6. // Functions:
  7. //
  8. // See ioo.h for a list of member functions.
  9. //
  10. // Copyright (c) 1993 Microsoft Corporation. All rights reserved.
  11. //**********************************************************************
  12. #include "pre.h"
  13. #include "obj.h"
  14. #include "ioo.h"
  15. #include "app.h"
  16. #include "doc.h"
  17. #define VERB_OPEN 1
  18. //**********************************************************************
  19. //
  20. // COleObject::QueryInterface
  21. //
  22. // Purpose:
  23. // Used for interface negotiation
  24. //
  25. // Parameters:
  26. //
  27. // REFIID riid - Interface being queried for.
  28. //
  29. // LPVOID FAR *ppvObj - Out pointer for the interface.
  30. //
  31. // Return Value:
  32. //
  33. // S_OK - Success
  34. // E_NOINTERFACE - Failure
  35. //
  36. // Function Calls:
  37. // Function Location
  38. //
  39. // CSimpSvrObj::QueryInterface OBJ.CPP
  40. //
  41. //
  42. //********************************************************************
  43. STDMETHODIMP COleObject::QueryInterface ( REFIID riid, LPVOID FAR* ppvObj)
  44. {
  45. TestDebugOut(TEXT("In COleObject::QueryInterface\r\n"));
  46. return m_lpObj->QueryInterface(riid, ppvObj);
  47. }
  48. //**********************************************************************
  49. //
  50. // COleObject::AddRef
  51. //
  52. // Purpose:
  53. //
  54. // Increments the reference count on CSimpSvrObj. Since COleObject
  55. // is a nested class of CSimpSvrObj, we don't need an extra reference
  56. // count for COleObject. We can safely use the reference count of
  57. // CSimpSvrObj.
  58. //
  59. // Parameters:
  60. //
  61. // None
  62. //
  63. // Return Value:
  64. //
  65. // The new reference count on the CSimpSvrObj
  66. //
  67. // Function Calls:
  68. // Function Location
  69. //
  70. // OuputDebugString Windows API
  71. // CSimpSvrObj::AddRef OBJ.CPP
  72. //
  73. //
  74. //********************************************************************
  75. STDMETHODIMP_(ULONG) COleObject::AddRef ()
  76. {
  77. TestDebugOut(TEXT("In COleObject::AddRef\r\n"));
  78. return m_lpObj->AddRef();
  79. }
  80. //**********************************************************************
  81. //
  82. // COleObject::Release
  83. //
  84. // Purpose:
  85. //
  86. // Decrements the reference count on CSimpSvrObj. Since COleObject
  87. // is a nested class of CSimpSvrObj, we don't need an extra reference
  88. // count for COleObject. We can safely use the reference count of
  89. // CSimpSvrObj.
  90. //
  91. // Parameters:
  92. //
  93. // None
  94. //
  95. // Return Value:
  96. //
  97. // The new reference count of CSimpSvrObj
  98. //
  99. // Function Calls:
  100. // Function Location
  101. //
  102. // TestDebugOut Windows API
  103. // CSimpSvrObj::Release OBJ.CPP
  104. //
  105. //
  106. //********************************************************************
  107. STDMETHODIMP_(ULONG) COleObject::Release ()
  108. {
  109. TestDebugOut(TEXT("In COleObject::Release\r\n"));
  110. return m_lpObj->Release();
  111. }
  112. //**********************************************************************
  113. //
  114. // COleObject::SetClientSite
  115. //
  116. // Purpose:
  117. //
  118. // Called to notify the object of it's client site.
  119. //
  120. // Parameters:
  121. //
  122. // LPOLECLIENTSITE pClientSite - ptr to new client site
  123. //
  124. // Return Value:
  125. //
  126. // S_OK
  127. //
  128. // Function Calls:
  129. // Function Location
  130. //
  131. // TestDebugOut Windows API
  132. // IOleClientSite::Release Container
  133. // IOleClientSite::AddRef Container
  134. //
  135. //
  136. //********************************************************************
  137. STDMETHODIMP COleObject::SetClientSite ( LPOLECLIENTSITE pClientSite)
  138. {
  139. TestDebugOut(TEXT("In COleObject::SetClientSite\r\n"));
  140. // if we already have a client site, release it.
  141. if (m_lpObj->m_lpOleClientSite)
  142. {
  143. m_lpObj->m_lpOleClientSite->Release();
  144. m_lpObj->m_lpOleClientSite = NULL;
  145. }
  146. // store copy of the client site.
  147. m_lpObj->m_lpOleClientSite = pClientSite;
  148. // AddRef it so it doesn't go away.
  149. if (m_lpObj->m_lpOleClientSite)
  150. m_lpObj->m_lpOleClientSite->AddRef();
  151. return ResultFromScode(S_OK);
  152. }
  153. //**********************************************************************
  154. //
  155. // COleObject::Advise
  156. //
  157. // Purpose:
  158. //
  159. // Called to set up an advise on the OLE object.
  160. //
  161. // Parameters:
  162. //
  163. // LPADVISESINK pAdvSink - ptr to the Advise Sink for notification
  164. //
  165. // DWORD FAR* pdwConnection - place to return the connection ID.
  166. //
  167. // Return Value:
  168. //
  169. // Passed back from IOleAdviseHolder::Advise.
  170. //
  171. // Function Calls:
  172. // Function Location
  173. //
  174. // TestDebugOut Windows API
  175. // CreateOleAdviseHolder OLE API
  176. // IOleAdviseHolder::Advise OLE
  177. //
  178. //
  179. //********************************************************************
  180. STDMETHODIMP COleObject::Advise ( LPADVISESINK pAdvSink, DWORD FAR* pdwConnection)
  181. {
  182. TestDebugOut(TEXT("In COleObject::Advise\r\n"));
  183. // if we haven't made an OleAdviseHolder yet, make one.
  184. if (!m_lpObj->m_lpOleAdviseHolder)
  185. {
  186. HRESULT hRes;
  187. if ((hRes=CreateOleAdviseHolder(&m_lpObj->m_lpOleAdviseHolder))!=S_OK)
  188. {
  189. TestDebugOut(TEXT("CreateOleAdviseHolder fails\n"));
  190. return(hRes);
  191. }
  192. }
  193. // pass this call onto the OleAdviseHolder.
  194. return m_lpObj->m_lpOleAdviseHolder->Advise(pAdvSink, pdwConnection);
  195. }
  196. //**********************************************************************
  197. //
  198. // COleObject::SetHostNames
  199. //
  200. // Purpose:
  201. //
  202. // Called to pass strings for Window titles.
  203. //
  204. // Parameters:
  205. //
  206. // LPCOLESTR szContainerApp - ptr to string describing Container App
  207. //
  208. // LPCOLESTR szContainerObj - ptr to string describing Object
  209. //
  210. // Return Value:
  211. //
  212. // S_OK
  213. //
  214. // Function Calls:
  215. // Function Location
  216. //
  217. // TestDebugOut Windows API
  218. //
  219. // Comments:
  220. //
  221. // This routine is called so that the server application can
  222. // set the window title appropriately.
  223. //
  224. //********************************************************************
  225. STDMETHODIMP COleObject::SetHostNames ( LPCOLESTR szContainerApp, LPCOLESTR szContainerObj)
  226. {
  227. TestDebugOut(TEXT("In COleObject::SetHostNames\r\n"));
  228. return ResultFromScode( S_OK);
  229. }
  230. //**********************************************************************
  231. //
  232. // COleObject::DoVerb
  233. //
  234. // Purpose:
  235. //
  236. // Called by the container application to invoke a verb.
  237. //
  238. // Parameters:
  239. //
  240. // LONG iVerb - The value of the verb to be
  241. // invoked.
  242. //
  243. // LPMSG lpmsg - The message that caused the
  244. // verb to be invoked.
  245. //
  246. // LPOLECLIENTSITE pActiveSite - Ptr to the active client site.
  247. //
  248. // LONG lindex - Used in extended layout
  249. //
  250. // HWND hwndParent - This should be the window handle of
  251. // the window in which we are contained.
  252. // This value could be used to "fake"
  253. // inplace activation in a manner similar
  254. // to Video for Windows in OLE 1.0.
  255. //
  256. // LPCRECT lprcPosRect - The rectangle that contains the object
  257. // within hwndParent. Also used to
  258. // "fake" inplace activation.
  259. //
  260. // Return Value:
  261. //
  262. // OLE_E_NOTINPLACEACTIVE - Returned if attempted to undo while not
  263. // inplace active.
  264. // S_OK
  265. //
  266. // Function Calls:
  267. // Function Location
  268. //
  269. // TestDebugOut Windows API
  270. // ShowWindow Windows API
  271. // CSimpSvrObj::DoInPlaceActivate OBJ.CPP
  272. // CSimpSvrObj::DoInPlaceHide OBJ.CPP
  273. // COleObject::OpenEdit IOO.CPP
  274. // CSimpSvrDoc::GethDocWnd DOC.H
  275. // COleInPlaceObj::InPlaceDeactivate IOIPO.CPP
  276. //
  277. // Comments:
  278. //
  279. // Be sure to look at TECHNOTES.WRI included with the OLE
  280. // SDK for a description of handling the inplace verbs
  281. // properly.
  282. //
  283. //********************************************************************
  284. STDMETHODIMP COleObject::DoVerb ( LONG iVerb,
  285. LPMSG lpmsg,
  286. LPOLECLIENTSITE pActiveSite,
  287. LONG lindex,
  288. HWND hwndParent,
  289. LPCRECT lprcPosRect)
  290. {
  291. TestDebugOut(TEXT("In COleObject::DoVerb\r\n"));
  292. switch (iVerb)
  293. {
  294. case OLEIVERB_SHOW:
  295. case OLEIVERB_PRIMARY:
  296. if (m_fOpen)
  297. SetFocus(m_lpObj->m_lpDoc->GethAppWnd());
  298. else if (m_lpObj->DoInPlaceActivate(iVerb) == FALSE)
  299. OpenEdit(pActiveSite);
  300. break;
  301. case OLEIVERB_UIACTIVATE:
  302. if (m_fOpen)
  303. return ResultFromScode (E_FAIL);
  304. // inplace activate
  305. if (!m_lpObj->DoInPlaceActivate(iVerb))
  306. return ResultFromScode (E_FAIL);
  307. break;
  308. case OLEIVERB_DISCARDUNDOSTATE:
  309. // don't have to worry about this situation as we don't
  310. // support an undo state.
  311. if (!m_lpObj->m_fInPlaceActive)
  312. return ResultFromScode(OLE_E_NOT_INPLACEACTIVE);
  313. break;
  314. case OLEIVERB_HIDE:
  315. // if inplace active, do an "inplace" hide, otherwise
  316. // just hide the app window.
  317. if (m_lpObj->m_fInPlaceActive)
  318. {
  319. // clear inplace flag
  320. m_lpObj->m_fInPlaceActive = FALSE;
  321. // deactivate the UI
  322. m_lpObj->DeactivateUI();
  323. m_lpObj->DoInPlaceHide();
  324. }
  325. else
  326. m_lpObj->m_lpDoc->GetApp()->HideAppWnd();
  327. break;
  328. case OLEIVERB_OPEN:
  329. case VERB_OPEN:
  330. // if inplace active, deactivate
  331. if (m_lpObj->m_fInPlaceActive)
  332. m_lpObj->m_OleInPlaceObject.InPlaceDeactivate();
  333. // open into another window.
  334. OpenEdit(pActiveSite);
  335. break;
  336. default:
  337. if (iVerb < 0)
  338. return ResultFromScode(E_FAIL);
  339. }
  340. return ResultFromScode( S_OK);
  341. }
  342. //**********************************************************************
  343. //
  344. // COleObject::GetExtent
  345. //
  346. // Purpose:
  347. //
  348. // Returns the extent of the object.
  349. //
  350. // Parameters:
  351. //
  352. // DWORD dwDrawAspect - The aspect in which to get the size.
  353. //
  354. // LPSIZEL lpsizel - Out ptr to return the size.
  355. //
  356. // Return Value:
  357. // S_OK if the aspect is DVASPECT_CONTENT
  358. // E_FAIL otherwise
  359. //
  360. // Function Calls:
  361. // Function Location
  362. //
  363. // TestDebugOut Windows API
  364. // XformWidthInPixelsToHimetric OLE2UI
  365. // XformHeightInPixelsToHimetric OLE2UI
  366. //
  367. //
  368. //********************************************************************
  369. STDMETHODIMP COleObject::GetExtent ( DWORD dwDrawAspect, LPSIZEL lpsizel)
  370. {
  371. TestDebugOut(TEXT("In COleObject::GetExtent\r\n"));
  372. SCODE sc = E_FAIL;
  373. // Only DVASPECT_CONTENT is supported....
  374. if (dwDrawAspect == DVASPECT_CONTENT)
  375. {
  376. sc = S_OK;
  377. // return the correct size in HIMETRIC...
  378. lpsizel->cx = XformWidthInPixelsToHimetric(NULL, m_lpObj->m_size.x);
  379. lpsizel->cy = XformHeightInPixelsToHimetric(NULL, m_lpObj->m_size.y);
  380. }
  381. return ResultFromScode( sc );
  382. }
  383. //**********************************************************************
  384. //
  385. // COleObject::Update
  386. //
  387. // Purpose:
  388. //
  389. // Called to get the most up to date data
  390. //
  391. // Parameters:
  392. //
  393. // None
  394. //
  395. // Return Value:
  396. //
  397. // S_OK
  398. //
  399. // Function Calls:
  400. // Function Location
  401. //
  402. // TestDebugOut Windows API
  403. // IDataAdviseHolder::SendOnDataChange OLE
  404. //
  405. //
  406. //********************************************************************
  407. STDMETHODIMP COleObject::Update()
  408. {
  409. TestDebugOut(TEXT("In COleObject::Update\r\n"));
  410. // force an update
  411. m_lpObj->SendOnDataChange();
  412. return ResultFromScode( S_OK );
  413. }
  414. //**********************************************************************
  415. //
  416. // COleObject::Close
  417. //
  418. // Purpose:
  419. //
  420. // Called when the OLE object needs to be closed
  421. //
  422. // Parameters:
  423. //
  424. // DWORD dwSaveOption - Flags to instruct the server how to prompt
  425. // the user.
  426. //
  427. // Return Value:
  428. //
  429. // S_OK
  430. //
  431. // Function Calls:
  432. // Function Location
  433. //
  434. // TestDebugOut Windows API
  435. // CSimpSvrDoc::Close DOC.CPP
  436. //
  437. //
  438. //********************************************************************
  439. STDMETHODIMP COleObject::Close ( DWORD dwSaveOption)
  440. {
  441. TestDebugOut(TEXT("In COleObject::Close\r\n"));
  442. // delegate to the document object.
  443. m_lpObj->m_lpDoc->Close();
  444. return ResultFromScode( S_OK );
  445. }
  446. //**********************************************************************
  447. //
  448. // COleObject::Unadvise
  449. //
  450. // Purpose:
  451. //
  452. // Breaks down an OLE advise that has been set up on this object.
  453. //
  454. // Parameters:
  455. //
  456. // DWORD dwConnection - Connection that needs to be broken down
  457. //
  458. // Return Value:
  459. //
  460. // Passed back from IOleAdviseHolder::Unadvise
  461. //
  462. // Function Calls:
  463. // Function Location
  464. //
  465. // TestDebugOut Windows API
  466. // IOleAdviseHolder::Unadvise OLE
  467. //
  468. //
  469. //********************************************************************
  470. STDMETHODIMP COleObject::Unadvise ( DWORD dwConnection)
  471. {
  472. TestDebugOut(TEXT("In COleObject::Unadvise\r\n"));
  473. // pass on to OleAdviseHolder.
  474. return m_lpObj->m_lpOleAdviseHolder->Unadvise(dwConnection);
  475. }
  476. //**********************************************************************
  477. //
  478. // COleObject::EnumVerbs
  479. //
  480. // Purpose:
  481. //
  482. // Enumerates the verbs associated with this object.
  483. //
  484. // Parameters:
  485. //
  486. // LPENUMOLEVERB FAR* ppenumOleVerb - Out ptr in which to return
  487. // the enumerator
  488. //
  489. // Return Value:
  490. //
  491. // OLE_S_USEREG - Instructs OLE to use the verbs found in the
  492. // REG DB for this server.
  493. //
  494. // Function Calls:
  495. // Function Location
  496. //
  497. // TestDebugOut Windows API
  498. //
  499. // Comments:
  500. //
  501. // In a .DLL, an application cannot return OLE_S_USEREG. This is
  502. // due to the fact that the default object handler is not being
  503. // used, and the container is really making direct function calls
  504. // into the server .DLL.
  505. //
  506. //********************************************************************
  507. STDMETHODIMP COleObject::EnumVerbs ( LPENUMOLEVERB FAR* ppenumOleVerb)
  508. {
  509. TestDebugOut(TEXT("In COleObject::EnumVerbs\r\n"));
  510. return ResultFromScode( OLE_S_USEREG );
  511. }
  512. //**********************************************************************
  513. //
  514. // COleObject::GetClientSite
  515. //
  516. // Purpose:
  517. //
  518. // Called to get the current client site of the object.
  519. //
  520. // Parameters:
  521. //
  522. // LPOLECLIENTSITE FAR* ppClientSite - Out ptr in which to return the
  523. // client site.
  524. //
  525. // Return Value:
  526. //
  527. // S_OK
  528. //
  529. // Function Calls:
  530. // Function Location
  531. //
  532. // TestDebugOut Windows API
  533. //
  534. //
  535. //********************************************************************
  536. STDMETHODIMP COleObject::GetClientSite ( LPOLECLIENTSITE FAR* ppClientSite)
  537. {
  538. TestDebugOut(TEXT("In COleObject::GetClientSite\r\n"));
  539. *ppClientSite = m_lpObj->m_lpOleClientSite;
  540. return ResultFromScode( S_OK );
  541. }
  542. //**********************************************************************
  543. //
  544. // COleObject::SetMoniker
  545. //
  546. // Purpose:
  547. //
  548. // Used to set the objects moniker
  549. //
  550. // Parameters:
  551. //
  552. // DWORD dwWhichMoniker - Type of moniker being set
  553. //
  554. // LPMONIKER pmk - Pointer to the moniker
  555. //
  556. // Return Value:
  557. // S_OK
  558. // E_FAIL if the Moniker cannot be set
  559. //
  560. // Function Calls:
  561. // Function Location
  562. //
  563. // TestDebugOut Windows API
  564. //
  565. //
  566. //********************************************************************
  567. STDMETHODIMP COleObject::SetMoniker ( DWORD dwWhichMoniker, LPMONIKER pmk)
  568. {
  569. TestDebugOut(TEXT("In COleObject::SetMoniker\r\n"));
  570. LPMONIKER lpmk;
  571. HRESULT hRes;
  572. if (! m_lpObj->GetOleClientSite())
  573. return ResultFromScode (E_FAIL);
  574. if (m_lpObj->GetOleClientSite()->GetMoniker (OLEGETMONIKER_ONLYIFTHERE, OLEWHICHMK_OBJFULL, &lpmk) != NOERROR)
  575. return ResultFromScode (E_FAIL);
  576. if (m_lpObj->GetOleAdviseHolder())
  577. {
  578. if ((hRes=m_lpObj->GetOleAdviseHolder()->SendOnRename(lpmk))!=S_OK)
  579. TestDebugOut(TEXT("SendOnRename fails\n"));
  580. }
  581. LPRUNNINGOBJECTTABLE lpRot;
  582. if (GetRunningObjectTable(0, &lpRot) == NOERROR)
  583. {
  584. if (m_lpObj->m_dwRegister)
  585. lpRot->Revoke(m_lpObj->m_dwRegister);
  586. if ( ((hRes=lpRot->Register(0, m_lpObj, lpmk,
  587. &m_lpObj->m_dwRegister))!=S_OK) ||
  588. (hRes!=ResultFromScode(MK_S_MONIKERALREADYREGISTERED)))
  589. TestDebugOut(TEXT("Running Object Table Register fails\n"));
  590. lpRot->Release();
  591. }
  592. return ResultFromScode( S_OK );
  593. }
  594. //**********************************************************************
  595. //
  596. // COleObject::GetMoniker
  597. //
  598. // Purpose:
  599. // returns a moniker from the client site
  600. //
  601. // Parameters:
  602. //
  603. // DWORD dwAssign - Assignment for the moniker
  604. //
  605. // DWORD dwWhichMoniker - Which moniker to return
  606. //
  607. // LPMONIKER FAR* ppmk - An out ptr to return the moniker
  608. //
  609. // Return Value:
  610. //
  611. //
  612. // Function Calls:
  613. // Function Location
  614. //
  615. // TestDebugOut Windows API
  616. //
  617. //
  618. //********************************************************************
  619. STDMETHODIMP COleObject::GetMoniker ( DWORD dwAssign, DWORD dwWhichMoniker,
  620. LPMONIKER FAR* ppmk)
  621. {
  622. TestDebugOut(TEXT("In COleObject::GetMoniker\r\n"));
  623. // need to NULL the out parameter
  624. *ppmk = NULL;
  625. return m_lpObj->GetOleClientSite()->GetMoniker(OLEGETMONIKER_ONLYIFTHERE,
  626. OLEWHICHMK_OBJFULL, ppmk);
  627. }
  628. //**********************************************************************
  629. //
  630. // COleObject::InitFromData
  631. //
  632. // Purpose:
  633. //
  634. // Initialize the object from the passed pDataObject.
  635. //
  636. // Parameters:
  637. //
  638. // LPDATAOBJECT pDataObject - Pointer to data transfer object
  639. // to be used in the initialization
  640. //
  641. // BOOL fCreation - TRUE if the object is currently being
  642. // created.
  643. //
  644. // DWORD dwReserved - Reserved
  645. //
  646. // Return Value:
  647. //
  648. // S_FALSE
  649. //
  650. // Function Calls:
  651. // Function Location
  652. //
  653. // TestDebugOut Windows API
  654. //
  655. // Comments:
  656. //
  657. // We don't support this functionality, so we will always return
  658. // error.
  659. //
  660. //********************************************************************
  661. STDMETHODIMP COleObject::InitFromData ( LPDATAOBJECT pDataObject,
  662. BOOL fCreation,
  663. DWORD dwReserved)
  664. {
  665. TestDebugOut(TEXT("In COleObject::InitFromData\r\n"));
  666. return ResultFromScode( S_FALSE );
  667. }
  668. //**********************************************************************
  669. //
  670. // COleObject::GetClipboardData
  671. //
  672. // Purpose:
  673. //
  674. // Returns an IDataObject that is the same as doing an OleSetClipboard
  675. //
  676. // Parameters:
  677. //
  678. // DWORD dwReserved - Reserved
  679. //
  680. // LPDATAOBJECT FAR* ppDataObject - Out ptr for the Data Object.
  681. //
  682. // Return Value:
  683. //
  684. // OLE_E_NOTSUPPORTED
  685. //
  686. // Function Calls:
  687. // Function Location
  688. //
  689. // TestDebugOut Windows API
  690. //
  691. // Comments:
  692. //
  693. // Support of this method is optional.
  694. //
  695. //********************************************************************
  696. STDMETHODIMP COleObject::GetClipboardData ( DWORD dwReserved,
  697. LPDATAOBJECT FAR* ppDataObject)
  698. {
  699. TestDebugOut(TEXT("In COleObject::GetClipboardData\r\n"));
  700. // NULL the out ptr
  701. *ppDataObject = NULL;
  702. return ResultFromScode( E_NOTIMPL );
  703. }
  704. //**********************************************************************
  705. //
  706. // COleObject::IsUpToDate
  707. //
  708. // Purpose:
  709. //
  710. // Determines if an object is up to date
  711. //
  712. // Parameters:
  713. //
  714. // None
  715. //
  716. // Return Value:
  717. //
  718. // S_OK
  719. //
  720. // Function Calls:
  721. // Function Location
  722. //
  723. // TestDebugOut Windows API
  724. //
  725. // Comments:
  726. //
  727. // Our embedded object is always up to date. This function is
  728. // particularly useful in linking situations.
  729. //
  730. //********************************************************************
  731. STDMETHODIMP COleObject::IsUpToDate()
  732. {
  733. TestDebugOut(TEXT("In COleObject::IsUpToDate\r\n"));
  734. return ResultFromScode( S_OK );
  735. }
  736. //**********************************************************************
  737. //
  738. // COleObject::GetUserClassID
  739. //
  740. // Purpose:
  741. //
  742. // Returns the applications CLSID
  743. //
  744. // Parameters:
  745. //
  746. // CLSID FAR* pClsid - Out ptr to return the CLSID
  747. //
  748. // Return Value:
  749. //
  750. // S_OK
  751. //
  752. // Function Calls:
  753. // Function Location
  754. //
  755. // TestDebugOut Windows API
  756. // CPersistStorage::GetClassID IPS.CPP
  757. //
  758. // Comments:
  759. //
  760. // This function is just delegated to IPS::GetClassID.
  761. //
  762. //********************************************************************
  763. STDMETHODIMP COleObject::GetUserClassID ( CLSID FAR* pClsid)
  764. {
  765. TestDebugOut(TEXT("In COleObject::GetUserClassID\r\n"));
  766. return ( m_lpObj->m_PersistStorage.GetClassID(pClsid) );
  767. }
  768. //**********************************************************************
  769. //
  770. // COleObject::GetUserType
  771. //
  772. // Purpose:
  773. //
  774. // Used to get a user presentable id for this object
  775. //
  776. // Parameters:
  777. //
  778. // DWORD dwFormOfType - The ID requested
  779. //
  780. // LPOLESTR FAR* pszUserType - Out ptr to return the string
  781. //
  782. // Return Value:
  783. //
  784. // OLE_S_USEREG - Use the reg db to get these entries.
  785. //
  786. // Function Calls:
  787. // Function Location
  788. //
  789. // TestDebugOut Windows API
  790. //
  791. // Comment:
  792. // In this implementation, we delegate to the default handler's
  793. // implementation using the registration database to provide
  794. // the requested info.
  795. //
  796. //********************************************************************
  797. STDMETHODIMP COleObject::GetUserType ( DWORD dwFormOfType,
  798. LPOLESTR FAR* pszUserType)
  799. {
  800. TestDebugOut(TEXT("In COleObject::GetUserType\r\n"));
  801. return ResultFromScode( OLE_S_USEREG );
  802. }
  803. //**********************************************************************
  804. //
  805. // COleObject::SetExtent
  806. //
  807. // Purpose:
  808. //
  809. // Called to set the extent of the object.
  810. //
  811. // Parameters:
  812. //
  813. // DWORD dwDrawAspect - Aspect to have its size set
  814. //
  815. // LPSIZEL lpsizel - New size of the object.
  816. //
  817. // Return Value:
  818. //
  819. // E_NOTIMPL - This function is not curently implemented.
  820. //
  821. // Function Calls:
  822. // Function Location
  823. //
  824. // TestDebugOut Windows API
  825. //
  826. // Comments:
  827. //
  828. // See TECHNOTES.WRI include with the OLE SDK for proper
  829. // implementation of this function.
  830. //
  831. //
  832. //********************************************************************
  833. STDMETHODIMP COleObject::SetExtent ( DWORD dwDrawAspect, LPSIZEL lpsizel)
  834. {
  835. TestDebugOut(TEXT("In COleObject::SetExtent\r\n"));
  836. return ResultFromScode( E_NOTIMPL);
  837. }
  838. //**********************************************************************
  839. //
  840. // COleObject::EnumAdvise
  841. //
  842. // Purpose:
  843. //
  844. // Returns an enumerate which enumerates the outstanding advises
  845. // associated with this OLE object.
  846. //
  847. // Parameters:
  848. //
  849. // LPENUMSTATDATA FAR* ppenumAdvise - Out ptr in which to return
  850. // the enumerator.
  851. //
  852. // Return Value:
  853. //
  854. // Passed on from IOleAdviseHolder::EnumAdvise.
  855. //
  856. // Function Calls:
  857. // Function Location
  858. //
  859. // TestDebugOut Windows API
  860. // IOleAdviseHolder::EnumAdvise OLE
  861. //
  862. //
  863. //********************************************************************
  864. STDMETHODIMP COleObject::EnumAdvise ( LPENUMSTATDATA FAR* ppenumAdvise)
  865. {
  866. TestDebugOut(TEXT("In COleObject::EnumAdvise\r\n"));
  867. // need to NULL the out parameter
  868. *ppenumAdvise = NULL;
  869. // pass on to the OLE Advise holder.
  870. return m_lpObj->m_lpOleAdviseHolder->EnumAdvise(ppenumAdvise);
  871. }
  872. //**********************************************************************
  873. //
  874. // COleObject::GetMiscStatus
  875. //
  876. // Purpose:
  877. //
  878. // Return status information about the object
  879. //
  880. // Parameters:
  881. //
  882. // DWORD dwAspect - Aspect interested in.
  883. //
  884. // DWORD FAR* pdwStatus - Out ptr in which to return the bits.
  885. //
  886. // Return Value:
  887. //
  888. // OLE_S_USEREG - Use the reg db to get these entries.
  889. //
  890. // Function Calls:
  891. // Function Location
  892. //
  893. // TestDebugOut Windows API
  894. //
  895. // Comment:
  896. // In this implementation, we delegate to the default handler's
  897. // implementation using the registration database to provide
  898. // the requested info.
  899. //
  900. //
  901. //********************************************************************
  902. STDMETHODIMP COleObject::GetMiscStatus ( DWORD dwAspect, DWORD FAR* pdwStatus)
  903. {
  904. TestDebugOut(TEXT("In COleObject::GetMiscStatus\r\n"));
  905. // need to NULL the out parameter
  906. *pdwStatus = NULL;
  907. return ResultFromScode( OLE_S_USEREG );
  908. }
  909. //**********************************************************************
  910. //
  911. // COleObject::SetColorScheme
  912. //
  913. // Purpose:
  914. //
  915. // Used to set the palette for the object to use.
  916. //
  917. // Parameters:
  918. //
  919. // LPLOGPALETTE lpLogpal - Pointer to the LOGPALETTE to be used.
  920. //
  921. // Return Value:
  922. //
  923. // S_OK
  924. //
  925. // Function Calls:
  926. // Function Location
  927. //
  928. // TestDebugOut Windows API
  929. //
  930. // Comments:
  931. //
  932. // This server ignores this method.
  933. //
  934. //********************************************************************
  935. STDMETHODIMP COleObject::SetColorScheme ( LPLOGPALETTE lpLogpal)
  936. {
  937. TestDebugOut(TEXT("In COleObject::SetColorScheme\r\n"));
  938. return ResultFromScode( S_OK );
  939. }
  940. //**********************************************************************
  941. //
  942. // COleObject::OpenEdit
  943. //
  944. // Purpose:
  945. //
  946. // Used to Open the object into a seperate window.
  947. //
  948. // Parameters:
  949. //
  950. // LPOLECLIENTSITE pActiveSite - Pointer to the Active clientsite.
  951. //
  952. // Return Value:
  953. //
  954. // None.
  955. //
  956. // Function Calls:
  957. // Function Location
  958. //
  959. // IOleClientSite::OnShowWindow Container
  960. // ShowWindow Windows API
  961. // UpdateWindow Windows API
  962. // TestDebugOut Windows API
  963. // CSimpSvrDoc::GethAppWnd DOC.H
  964. // CSimpSvrDoc::GethHatchWnd DOC.H
  965. //
  966. //
  967. //********************************************************************
  968. void COleObject::OpenEdit(LPOLECLIENTSITE pActiveSite)
  969. {
  970. if (m_lpObj->GetOleClientSite())
  971. m_lpObj->GetOleClientSite()->ShowObject();
  972. m_fOpen = TRUE;
  973. // tell the site we are opening so the object can be hatched out.
  974. if (m_lpObj->GetOleClientSite())
  975. m_lpObj->GetOleClientSite()->OnShowWindow(TRUE);
  976. m_lpObj->m_lpDoc->ShowDocWnd();
  977. m_lpObj->m_lpDoc->HideHatchWnd();
  978. // Show app window.
  979. m_lpObj->m_lpDoc->GetApp()->ShowAppWnd();
  980. SetFocus(m_lpObj->m_lpDoc->GethAppWnd());
  981. }