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.

1812 lines
47 KiB

  1. /******************************* Module Header *******************************
  2. * Module Name: OLE.C
  3. *
  4. * Purpose: Handles all API routines for the dde L&E sub-dll of the ole dll.
  5. *
  6. * PURPOSE: API routines for handling generic objects (which may be static,
  7. * linked, or embedded). These routines will be made into a DLL.
  8. *
  9. * Created: 1990
  10. *
  11. * Copyright (c) 1990, 1991 Microsoft Corporation
  12. *
  13. * History:
  14. * Raor, Srinik (../../90, 91) Designed/coded.
  15. *
  16. *****************************************************************************/
  17. #include <windows.h>
  18. #include <shellapi.h>
  19. #include "dll.h"
  20. extern DLL_ENTRY lpDllTable[];
  21. extern char packageClass[];
  22. extern OLECLIPFORMAT cfFileName;
  23. extern DWORD dwOleVer;
  24. DWORD dwVerFromFile;
  25. HANDLE hInfo = NULL;
  26. CLIENTDOC lockDoc = {{'C', 'D'}, 0L, 0L, 0, 0, 0, 0L, 0L};
  27. LHCLIENTDOC lhLockDoc = (LHCLIENTDOC) ((LPCLIENTDOC) &lockDoc);
  28. BOOL gbCreateInvisible = FALSE;
  29. BOOL gbLaunchServer;
  30. OLESTATUS INTERNAL LockServer (LPOBJECT_LE);
  31. #pragma alloc_text(_DDETEXT, OleLockServer, OleUnlockServer, LockServer, IsServerValid, DeleteSrvrEdit, InitSrvrConv, LeLaunchApp)
  32. //////////////////////////////////////////////////////////////////////////////
  33. //
  34. // LPVOID FAR PASCAL OleQueryProtocol (lpobj, lpprotocol)
  35. //
  36. // Tells whether the object supports the specified protocol.
  37. //
  38. // Arguments:
  39. //
  40. // lpobj - object pointer
  41. // lpprotocol - protocol string
  42. //
  43. // Returns:
  44. //
  45. // long ptr to object if the protocol is supported
  46. // NULL if not.
  47. //
  48. // Effects:
  49. //
  50. //////////////////////////////////////////////////////////////////////////////
  51. LPVOID FAR PASCAL OleQueryProtocol (lpobj, lpprotocol)
  52. LPOLEOBJECT lpobj;
  53. LPSTR lpprotocol;
  54. {
  55. if (!CheckObject(lpobj))
  56. return NULL;
  57. return (*lpobj->lpvtbl->QueryProtocol) (lpobj, lpprotocol);
  58. }
  59. //////////////////////////////////////////////////////////////////////////////
  60. //
  61. // OLESTATUS FAR PASCAL OleDelete (lpobj)
  62. //
  63. // Deletes the given object and all memory associated with its sub-parts.
  64. // The calling function should cease to use 'lpobj', as it is now invalid.
  65. // If handler dll is used reference count is reduced by one, and if it
  66. // reaches zero the hanlder dll will be freed up.
  67. //
  68. // Arguments:
  69. //
  70. // lpobj - object pointer
  71. //
  72. // Returns:
  73. //
  74. // OLE_OK
  75. // OLE_ERROR_OBJECT
  76. // OLE_WAIT_FOR_RELEASE
  77. //
  78. // Effects:
  79. //
  80. //////////////////////////////////////////////////////////////////////////////
  81. OLESTATUS FAR PASCAL OleDelete (lpobj)
  82. LPOLEOBJECT lpobj;
  83. {
  84. Puts("OleDelete");
  85. if (!CheckObject(lpobj))
  86. return OLE_ERROR_OBJECT;
  87. return (*lpobj->lpvtbl->Delete) (lpobj);
  88. }
  89. /***************************** Public Function ****************************\
  90. * OLESTATUS FAR PASCAL OleRelease (lpobj)
  91. *
  92. * OleRelease:
  93. *
  94. * Effects:
  95. *
  96. * History:
  97. * Wrote it.
  98. \***************************************************************************/
  99. OLESTATUS FAR PASCAL OleRelease (lpobj)
  100. LPOLEOBJECT lpobj;
  101. {
  102. Puts("OleRelease");
  103. if (!CheckObject(lpobj))
  104. return OLE_ERROR_OBJECT;
  105. return (*lpobj->lpvtbl->Release) (lpobj);
  106. }
  107. /***************************** Public Function ****************************\
  108. *
  109. * OLESTATUS FAR PASCAL OleSaveToStream (lpobj, lpstream)
  110. *
  111. * oleSaveToStream: This will read <hobj> to the stream based on the <hfile>
  112. * structure. It will return TRUE on success. This is the only object
  113. * function for which it is not an error to pass a NULL <hobj>. In the case
  114. * of NULL, this function will simply put a placemarker for an object.
  115. * See oleLoadFromStream.
  116. *
  117. * Effects:
  118. *
  119. * History:
  120. * Wrote it.
  121. \***************************************************************************/
  122. OLESTATUS FAR PASCAL OleSaveToStream (lpobj, lpstream)
  123. LPOLEOBJECT lpobj;
  124. LPOLESTREAM lpstream;
  125. {
  126. Puts("OleSaveToStream");
  127. if (!CheckObject(lpobj))
  128. return OLE_ERROR_OBJECT;
  129. PROBE_READ(lpstream);
  130. return ((*lpobj->lpvtbl->SaveToStream) (lpobj, lpstream));
  131. }
  132. /***************************** Public Function ****************************\
  133. *
  134. * OLESTATUS FAR PASCAL OleLoadFromStream (lpstream, lpprotcol, lpclient, lhclientdoc, lpobjname, lplpobj)
  135. *
  136. * oleLoadFromStream: This will read an object out of the stream based on the
  137. * <hfile> structure. It will return a HANDLE to the object it creates.
  138. * On error, the return value is NULL, but since NULL is also a valid object
  139. * in the file, the <error> parameter should be checked as well.
  140. *
  141. * Effects:
  142. *
  143. * History:
  144. * Wrote it.
  145. \***************************************************************************/
  146. OLESTATUS FAR PASCAL OleLoadFromStream (lpstream, lpprotocol, lpclient, lhclientdoc, lpobjname, lplpobj)
  147. LPOLESTREAM lpstream;
  148. LPSTR lpprotocol;
  149. LPOLECLIENT lpclient;
  150. LHCLIENTDOC lhclientdoc;
  151. LPSTR lpobjname;
  152. LPOLEOBJECT FAR * lplpobj;
  153. {
  154. LONG len;
  155. OLESTATUS retVal = OLE_ERROR_STREAM;
  156. char class[100];
  157. ATOM aClass;
  158. BOOL bEdit = FALSE, bStatic = FALSE;
  159. LONG ctype;
  160. int objCount;
  161. int iTable = INVALID_INDEX;
  162. Puts("OleLoadFromStream");
  163. *lplpobj = NULL;
  164. PROBE_MODE(bProtMode);
  165. if (!CheckClientDoc ((LPCLIENTDOC) lhclientdoc))
  166. return OLE_ERROR_HANDLE;
  167. PROBE_READ(lpstream);
  168. PROBE_WRITE(lplpobj);
  169. PROBE_READ(lpprotocol);
  170. PROBE_READ(lpclient);
  171. #ifdef FIREWALLS
  172. ASSERT (lpobjname, "NULL lpobjname passed to OleLoadFromStream\n");
  173. #endif
  174. PROBE_READ(lpobjname);
  175. if (!lpobjname[0])
  176. return OLE_ERROR_NAME;
  177. if (!(bEdit = !lstrcmpi (lpprotocol, PROTOCOL_EDIT)))
  178. if (!(bStatic = !lstrcmpi (lpprotocol, PROTOCOL_STATIC)))
  179. return OLE_ERROR_PROTOCOL;
  180. if (GetBytes (lpstream, (LPSTR) &dwVerFromFile, sizeof(LONG)))
  181. return OLE_ERROR_STREAM;
  182. if (GetBytes (lpstream, (LPSTR)&ctype, sizeof(LONG)))
  183. return OLE_ERROR_STREAM;
  184. if (ctype == CT_NULL)
  185. return (bStatic ? OLE_OK: OLE_ERROR_PROTOCOL);
  186. if (((ctype != CT_PICTURE) && (ctype != CT_STATIC) && bStatic) ||
  187. ((ctype != CT_LINK) && (ctype != CT_OLDLINK)
  188. && (ctype != CT_EMBEDDED) && bEdit))
  189. return OLE_ERROR_PROTOCOL;
  190. if ((ctype == CT_STATIC) && ((HIWORD(dwVerFromFile)) != OS_WIN16))
  191. return OLE_ERROR_STATIC_FROM_OTHER_OS;
  192. //** Get Class
  193. if (GetBytes(lpstream, (LPSTR)&len, sizeof(len)))
  194. return OLE_ERROR_STREAM;
  195. if (len == 0)
  196. return OLE_ERROR_STREAM;
  197. if (GetBytes(lpstream, (LPSTR)&class, len))
  198. return OLE_ERROR_STREAM;
  199. aClass = GlobalAddAtom (class);
  200. if ((ctype == CT_PICTURE) || (ctype == CT_STATIC))
  201. retVal = DefLoadFromStream (lpstream, lpprotocol, lpclient,
  202. lhclientdoc, lpobjname, lplpobj, ctype, aClass, NULL);
  203. //!!! It's the DLL's responsibility to delete the atom. But in case of
  204. // failure we delete the atom if our DefLoadFromStream().
  205. else if ((iTable = LoadDll (class)) == INVALID_INDEX) {
  206. retVal = DefLoadFromStream (lpstream, lpprotocol, lpclient,
  207. lhclientdoc, lpobjname, lplpobj, ctype, aClass, NULL);
  208. }
  209. else {
  210. objCount = lpDllTable[iTable].cObj;
  211. retVal = (*lpDllTable[iTable].Load) (lpstream, lpprotocol, lpclient,
  212. lhclientdoc, lpobjname, lplpobj, ctype, aClass, NULL);
  213. if (retVal > OLE_WAIT_FOR_RELEASE)
  214. lpDllTable[iTable].cObj = objCount - 1;
  215. else
  216. (*lplpobj)->iTable = iTable;
  217. }
  218. return retVal;
  219. }
  220. OLESTATUS FAR PASCAL OleClone (lpobjsrc, lpclient, lhclientdoc, lpobjname, lplpobj)
  221. LPOLEOBJECT lpobjsrc;
  222. LPOLECLIENT lpclient;
  223. LHCLIENTDOC lhclientdoc;
  224. LPSTR lpobjname;
  225. LPOLEOBJECT FAR * lplpobj;
  226. {
  227. OLESTATUS retVal;
  228. Puts("OleClone");
  229. if (!CheckObject(lpobjsrc))
  230. return OLE_ERROR_OBJECT;
  231. if (!CheckClientDoc ((LPCLIENTDOC) lhclientdoc))
  232. return OLE_ERROR_HANDLE;
  233. PROBE_READ(lpclient);
  234. #ifdef FIREWALLS
  235. ASSERT (lpobjname, "NULL lpobjname passed to OleClone\n");
  236. #endif
  237. PROBE_READ(lpobjname);
  238. if (!lpobjname[0])
  239. return OLE_ERROR_NAME;
  240. PROBE_WRITE(lplpobj);
  241. *lplpobj = NULL;
  242. retVal = (*lpobjsrc->lpvtbl->Clone) (lpobjsrc, lpclient,
  243. lhclientdoc, lpobjname, lplpobj);
  244. if ((lpobjsrc->iTable != INVALID_INDEX) && (retVal <= OLE_WAIT_FOR_RELEASE))
  245. lpDllTable[lpobjsrc->iTable].cObj++;
  246. return retVal;
  247. }
  248. OLESTATUS FAR PASCAL OleCopyFromLink (lpobjsrc, lpprotocol, lpclient, lhclientdoc, lpobjname, lplpobj)
  249. LPOLEOBJECT lpobjsrc;
  250. LPSTR lpprotocol;
  251. LPOLECLIENT lpclient;
  252. LHCLIENTDOC lhclientdoc;
  253. LPSTR lpobjname;
  254. LPOLEOBJECT FAR * lplpobj;
  255. {
  256. OLESTATUS retVal;
  257. Puts("OleCopyFromLnk");
  258. if (!CheckObject(lpobjsrc))
  259. return(OLE_ERROR_OBJECT);
  260. if (!CheckClientDoc ((LPCLIENTDOC) lhclientdoc))
  261. return OLE_ERROR_HANDLE;
  262. PROBE_READ(lpprotocol);
  263. PROBE_WRITE(lplpobj);
  264. PROBE_READ(lpclient);
  265. #ifdef FIREWALLS
  266. ASSERT (lpobjname, "NULL lpobjname passed to OleCopyFromLink\n");
  267. #endif
  268. PROBE_READ(lpobjname);
  269. if (!lpobjname[0])
  270. return OLE_ERROR_NAME;
  271. *lplpobj = NULL;
  272. if (lstrcmpi (lpprotocol, PROTOCOL_EDIT))
  273. return OLE_ERROR_PROTOCOL;
  274. retVal = (*lpobjsrc->lpvtbl->CopyFromLink) (lpobjsrc, lpclient,
  275. lhclientdoc, lpobjname, lplpobj);
  276. if ((lpobjsrc->iTable != INVALID_INDEX) && (retVal <= OLE_WAIT_FOR_RELEASE))
  277. lpDllTable[lpobjsrc->iTable].cObj++;
  278. return retVal;
  279. }
  280. OLESTATUS FAR PASCAL OleEqual (lpobj1, lpobj2)
  281. LPOLEOBJECT lpobj1;
  282. LPOLEOBJECT lpobj2;
  283. {
  284. if (!CheckObject(lpobj1))
  285. return OLE_ERROR_OBJECT;
  286. if (!CheckObject(lpobj2))
  287. return OLE_ERROR_OBJECT;
  288. if (lpobj1->ctype != lpobj2->ctype)
  289. return OLE_ERROR_NOT_EQUAL;
  290. return ((*lpobj1->lpvtbl->Equal) (lpobj1, lpobj2));
  291. }
  292. /***************************** Public Function ****************************\
  293. *
  294. * OLESTATUS FAR PASCAL OleQueryLinkFromClip (lpprotcol, optRender, cfFormat)
  295. *
  296. * oleQueryFromClip: Returns OLE_OK if a linked object can be created.
  297. *
  298. *
  299. * Effects:
  300. *
  301. * History:
  302. * Wrote it.
  303. \***************************************************************************/
  304. OLESTATUS FAR PASCAL OleQueryLinkFromClip (lpprotocol, optRender, cfFormat)
  305. LPSTR lpprotocol;
  306. OLEOPT_RENDER optRender;
  307. OLECLIPFORMAT cfFormat;
  308. {
  309. Puts("OleQueryLinkFromClip");
  310. return LeQueryCreateFromClip (lpprotocol, optRender, cfFormat, CT_LINK);
  311. }
  312. /***************************** Public Function ****************************\
  313. *
  314. * OLESTATUS FAR PASCAL OleQueryCreateFromClip (lpprotcol, optRender, cfFormat)
  315. *
  316. * oleQueryCreateFromClip: Returns true if a non-linked object can be
  317. * created.
  318. *
  319. *
  320. * Effects:
  321. *
  322. * History:
  323. * Wrote it.
  324. \***************************************************************************/
  325. OLESTATUS FAR PASCAL OleQueryCreateFromClip (lpprotocol, optRender, cfFormat)
  326. LPSTR lpprotocol;
  327. OLEOPT_RENDER optRender;
  328. OLECLIPFORMAT cfFormat;
  329. {
  330. Puts("OleQueryCreateFromClip");
  331. return (LeQueryCreateFromClip (lpprotocol, optRender,
  332. cfFormat, CT_EMBEDDED));
  333. }
  334. /***************************** Public Function ****************************\
  335. *
  336. * OLESTATUS FAR PASCAL OleCreateLinkFromClip (lpprotcol, lpclient, lhclientdoc, lpobjname, lplpoleobject, optRender, cfFormat)
  337. *
  338. *
  339. * oleCreateLinkFromClip: This function creates the LP to an object from the
  340. * clipboard. It will try to create a linked object. Return value is OLE_OK
  341. * is the object is successfully created it
  342. *
  343. * Effects:
  344. *
  345. * History:
  346. * Wrote it.
  347. \***************************************************************************/
  348. OLESTATUS FAR PASCAL OleCreateLinkFromClip (lpprotocol, lpclient, lhclientdoc, lpobjname, lplpobj, optRender, cfFormat)
  349. LPSTR lpprotocol;
  350. LPOLECLIENT lpclient;
  351. LHCLIENTDOC lhclientdoc;
  352. LPSTR lpobjname;
  353. LPOLEOBJECT FAR * lplpobj;
  354. OLEOPT_RENDER optRender;
  355. OLECLIPFORMAT cfFormat;
  356. {
  357. int objCount;
  358. int iTable = INVALID_INDEX;
  359. OLESTATUS retVal;
  360. LPSTR lpInfo;
  361. Puts("OleCreateLinkFromClip");
  362. PROBE_MODE(bProtMode);
  363. if (!CheckClientDoc ((LPCLIENTDOC) lhclientdoc))
  364. return OLE_ERROR_HANDLE;
  365. PROBE_READ(lpprotocol);
  366. PROBE_READ(lpclient);
  367. PROBE_WRITE(lplpobj);
  368. #ifdef FIREWALLS
  369. ASSERT (lpobjname, "NULL lpobjname passed to OleCreateLinkFromClip\n");
  370. #endif
  371. PROBE_READ(lpobjname);
  372. if (!lpobjname[0])
  373. return OLE_ERROR_NAME;
  374. *lplpobj = NULL;
  375. if (lstrcmpi (lpprotocol, PROTOCOL_EDIT))
  376. return OLE_ERROR_PROTOCOL;
  377. if (IsClipboardFormatAvailable (cfFileName))
  378. return CreatePackageFromClip (lpclient, lhclientdoc, lpobjname,
  379. lplpobj, optRender, cfFormat, CT_LINK);
  380. if (!(hInfo = GetClipboardData (cfObjectLink)))
  381. return OLE_ERROR_CLIPBOARD;
  382. if (!(lpInfo = GlobalLock(hInfo)))
  383. return OLE_ERROR_CLIPBOARD;
  384. iTable = LoadDll (lpInfo);
  385. GlobalUnlock (hInfo);
  386. if (iTable == INVALID_INDEX)
  387. retVal = DefCreateLinkFromClip (lpprotocol, lpclient, lhclientdoc,
  388. lpobjname, lplpobj, optRender, cfFormat);
  389. else {
  390. objCount = lpDllTable[iTable].cObj;
  391. retVal = (*lpDllTable[iTable].Link) (lpprotocol, lpclient,
  392. lhclientdoc, lpobjname, lplpobj, optRender, cfFormat);
  393. if (retVal > OLE_WAIT_FOR_RELEASE)
  394. lpDllTable[iTable].cObj = objCount - 1;
  395. else
  396. (*lplpobj)->iTable = iTable;
  397. }
  398. hInfo = NULL;
  399. return retVal;
  400. }
  401. /***************************** Public Function ****************************\
  402. *
  403. * OLESTATUS FAR PASCAL OleCreateFromClip (lpprotcol, lpclient, lplpoleobject, optRender, cfFormat)
  404. *
  405. *
  406. * oleCreateFromClip: This function creates the LP to an object
  407. * from the clipboard. It will try to create an embedded object if
  408. * OwnerLink and Native are available, otherwise it will create a static
  409. * picture. Return value is OLE_OK if the object is successfully
  410. * created it.
  411. *
  412. * Effects:
  413. *
  414. * History:
  415. * Wrote it.
  416. \***************************************************************************/
  417. OLESTATUS FAR PASCAL OleCreateFromClip (lpprotocol, lpclient, lhclientdoc, lpobjname, lplpobj, optRender, cfFormat)
  418. LPSTR lpprotocol;
  419. LPOLECLIENT lpclient;
  420. LHCLIENTDOC lhclientdoc;
  421. LPSTR lpobjname;
  422. LPOLEOBJECT FAR * lplpobj;
  423. OLEOPT_RENDER optRender;
  424. OLECLIPFORMAT cfFormat;
  425. {
  426. OLESTATUS retVal;
  427. LONG ctype;
  428. int iTable = INVALID_INDEX;
  429. LPSTR lpInfo;
  430. LPSTR lpClass = NULL;
  431. int objCount;
  432. OLECLIPFORMAT cfEnum = NULL;
  433. Puts("OleCreateFromClip");
  434. PROBE_MODE(bProtMode);
  435. if (!CheckClientDoc ((LPCLIENTDOC) lhclientdoc))
  436. return OLE_ERROR_HANDLE;
  437. PROBE_READ(lpprotocol);
  438. PROBE_READ(lpclient);
  439. PROBE_WRITE(lplpobj);
  440. #ifdef FIREWALLS
  441. ASSERT (lpobjname, "NULL lpobjname passed to OleCreateFromClip\n");
  442. #endif
  443. PROBE_READ(lpobjname);
  444. if (!lpobjname[0])
  445. return OLE_ERROR_NAME;
  446. *lplpobj = NULL;
  447. if (!lstrcmpi (lpprotocol, PROTOCOL_STATIC)) {
  448. if (optRender == olerender_none)
  449. return OLE_ERROR_OPTION;
  450. if ((optRender == olerender_format) && (cfFormat != CF_METAFILEPICT)
  451. && (cfFormat != CF_DIB) && (cfFormat != CF_BITMAP))
  452. return OLE_ERROR_FORMAT;
  453. if (!IsClipboardFormatAvailable (CF_METAFILEPICT)
  454. && !IsClipboardFormatAvailable (CF_DIB)
  455. && !IsClipboardFormatAvailable (CF_BITMAP))
  456. return OLE_ERROR_FORMAT;
  457. return CreatePictFromClip (lpclient, lhclientdoc,
  458. lpobjname, lplpobj, optRender,
  459. cfFormat, NULL, CT_STATIC);
  460. }
  461. else if (!lstrcmpi (lpprotocol, PROTOCOL_EDIT)) {
  462. if (IsClipboardFormatAvailable (cfFileName))
  463. return CreatePackageFromClip (lpclient, lhclientdoc, lpobjname,
  464. lplpobj, optRender, cfFormat, CT_EMBEDDED);
  465. if (!(hInfo = GetClipboardData (cfOwnerLink)))
  466. return OLE_ERROR_CLIPBOARD;
  467. while (TRUE) {
  468. cfEnum = EnumClipboardFormats (cfEnum);
  469. if (cfEnum == cfNative) {
  470. ctype = CT_EMBEDDED;
  471. break;
  472. }
  473. else if (cfEnum == cfOwnerLink) {
  474. ctype = CT_LINK;
  475. break;
  476. }
  477. }
  478. if (!(lpInfo = GlobalLock(hInfo)))
  479. return OLE_ERROR_CLIPBOARD;
  480. iTable = LoadDll (lpInfo);
  481. GlobalUnlock (hInfo);
  482. }
  483. else {
  484. return OLE_ERROR_PROTOCOL;
  485. }
  486. if (iTable == INVALID_INDEX)
  487. retVal = DefCreateFromClip (lpprotocol, lpclient, lhclientdoc,
  488. lpobjname, lplpobj, optRender, cfFormat, ctype);
  489. else {
  490. objCount = lpDllTable[iTable].cObj;
  491. retVal = (*lpDllTable[iTable].Clip) (lpprotocol, lpclient,
  492. lhclientdoc, lpobjname, lplpobj,
  493. optRender, cfFormat, ctype);
  494. if (retVal > OLE_WAIT_FOR_RELEASE)
  495. lpDllTable[iTable].cObj = objCount - 1;
  496. else
  497. (*lplpobj)->iTable = iTable;
  498. }
  499. hInfo = NULL;
  500. return retVal;
  501. }
  502. /***************************** Public Function ****************************\
  503. *
  504. * OLESTATUS FAR PASCAL OleCopyToClipboard (lpobj)
  505. *
  506. *
  507. * oleCopyToClipboard: This routine executes the standard "Copy" menu item
  508. * on the typical "Edit" menu. Returns TRUE if successful.
  509. *
  510. * Effects:
  511. *
  512. * History:
  513. * Wrote it.
  514. \***************************************************************************/
  515. OLESTATUS FAR PASCAL OleCopyToClipboard (lpobj)
  516. LPOLEOBJECT lpobj;
  517. {
  518. Puts("OleCopyToClipboard");
  519. if (!CheckObject(lpobj))
  520. return(OLE_ERROR_OBJECT);
  521. return ((*lpobj->lpvtbl->CopyToClipboard) (lpobj));
  522. }
  523. OLESTATUS FAR PASCAL OleSetHostNames (lpobj, lpclientName, lpdocName)
  524. LPOLEOBJECT lpobj;
  525. LPSTR lpclientName;
  526. LPSTR lpdocName;
  527. {
  528. Puts ("OleSetHostNames");
  529. if (!CheckObject(lpobj))
  530. return(OLE_ERROR_OBJECT);
  531. PROBE_READ(lpclientName);
  532. PROBE_READ(lpdocName);
  533. return ((*lpobj->lpvtbl->SetHostNames) (lpobj, lpclientName, lpdocName));
  534. }
  535. OLESTATUS FAR PASCAL OleSetTargetDevice (lpobj, hDevInfo)
  536. LPOLEOBJECT lpobj;
  537. HANDLE hDevInfo;
  538. {
  539. Puts("OleSetTargetDevice");
  540. if (!CheckObject(lpobj))
  541. return(OLE_ERROR_OBJECT);
  542. return ((*lpobj->lpvtbl->SetTargetDevice) (lpobj, hDevInfo));
  543. }
  544. OLESTATUS FAR PASCAL OleSetColorScheme (lpobj, lplogpal)
  545. LPOLEOBJECT lpobj;
  546. LPLOGPALETTE lplogpal;
  547. {
  548. Puts("OleSetColorScheme");
  549. if (!CheckObject(lpobj))
  550. return(OLE_ERROR_OBJECT);
  551. return ((*lpobj->lpvtbl->SetColorScheme) (lpobj, lplogpal));
  552. }
  553. OLESTATUS FAR PASCAL OleSetBounds(lpobj, lprc)
  554. LPOLEOBJECT lpobj;
  555. LPRECT lprc;
  556. {
  557. Puts("OleSetBounds");
  558. if (!CheckObject(lpobj))
  559. return OLE_ERROR_OBJECT;
  560. PROBE_READ(lprc);
  561. return ((*lpobj->lpvtbl->SetBounds) (lpobj, lprc));
  562. }
  563. /***************************** Public Function ****************************\
  564. * OLESTATUS FAR PASCAL OleQueryBounds (lpobj, lpRc)
  565. *
  566. * Returns the bounds of the object in question in MM_HIMETRIC mode.
  567. * width = lprc->right - lprc->left; in HIMETRIC units
  568. * height = lprc->top - lprc->bottom; in HIMETRIC units
  569. *
  570. * Returns OLE_OK or OLE_ERROR_MEMORY.
  571. *
  572. *
  573. * Effects:
  574. *
  575. * History:
  576. * Wrote it.
  577. \***************************************************************************/
  578. OLESTATUS FAR PASCAL OleQueryBounds (lpobj, lprc)
  579. LPOLEOBJECT lpobj;
  580. LPRECT lprc;
  581. {
  582. Puts("OleQueryBounds");
  583. if (!CheckObject(lpobj))
  584. return(OLE_ERROR_OBJECT);
  585. PROBE_WRITE(lprc);
  586. return (*lpobj->lpvtbl->QueryBounds) (lpobj, lprc);
  587. }
  588. /***************************** Public Function ****************************\
  589. * OLESTATUS FAR PASCAL OleQuerySize (lpobj, lpsize)
  590. *
  591. * Effects:
  592. *
  593. * History:
  594. * Wrote it.
  595. \***************************************************************************/
  596. OLESTATUS FAR PASCAL OleQuerySize (lpobj, lpdwSize)
  597. LPOLEOBJECT lpobj;
  598. DWORD FAR * lpdwSize;
  599. {
  600. Puts("OleQuerySize");
  601. if (!CheckObject(lpobj))
  602. return OLE_ERROR_OBJECT;
  603. PROBE_WRITE(lpdwSize);
  604. *lpdwSize = NULL;
  605. return (*lpobj->lpvtbl->QuerySize) (lpobj, lpdwSize);
  606. }
  607. /***************************** Public Function ****************************\
  608. * OLESTATUS FAR PASCAL OleDraw (lpobj, hdc, lprc, lpWrc, lphdcTarget)
  609. *
  610. * oleObjectDraw: This displays the given object on the device context <hcd>.
  611. * The <htargetdc> parameter is not currently used. Returns same as Draw().
  612. *
  613. * Expects rectangle coordinates in MM_HIMETRIC units.
  614. *
  615. *
  616. * Effects:
  617. *
  618. * History:
  619. * Wrote it.
  620. \***************************************************************************/
  621. OLESTATUS FAR PASCAL OleDraw (lpobj, hdc, lprc, lpWrc, hdcTarget)
  622. LPOLEOBJECT lpobj;
  623. HDC hdc;
  624. LPRECT lprc;
  625. LPRECT lpWrc;
  626. HDC hdcTarget;
  627. {
  628. Puts("OleObjectDraw");
  629. if (!FarCheckObject(lpobj))
  630. return(OLE_ERROR_OBJECT);
  631. PROBE_READ(lprc);
  632. if (lpWrc)
  633. PROBE_READ(lpWrc);
  634. return ((*lpobj->lpvtbl->Draw) (lpobj, hdc, lprc, lpWrc, hdcTarget));
  635. }
  636. /***************************** Public Function ****************************\
  637. *
  638. * OLESTATUS FAR PASCAL OleQueryOpen (lpobj)
  639. *
  640. * returns TRUE is an object has been activated.
  641. *
  642. *
  643. * Effects:
  644. *
  645. * History:
  646. * Wrote it.
  647. \***************************************************************************/
  648. OLESTATUS FAR PASCAL OleQueryOpen (lpobj)
  649. LPOLEOBJECT lpobj;
  650. {
  651. Puts("OleQueryOpen");
  652. if (!CheckObject(lpobj))
  653. return(OLE_ERROR_OBJECT);
  654. return (*lpobj->lpvtbl->QueryOpen) (lpobj);
  655. }
  656. /***************************** Public Function ****************************\
  657. *
  658. * OLESTATUS FAR PASCAL OleActivate (lpobj)
  659. *
  660. * Activates an object. For embeded objects always a new instance is
  661. * loaded and the instance is destroyed once the data is transferred
  662. * at close time. For linked objects, an instance of the render is created
  663. * only if one does not exist.
  664. * Effects:
  665. *
  666. * History:
  667. * Wrote it.
  668. \***************************************************************************/
  669. OLESTATUS FAR PASCAL OleActivate (lpobj, verb, fShow, fActivate, hWnd, lprc)
  670. LPOLEOBJECT lpobj;
  671. WORD verb;
  672. BOOL fShow;
  673. BOOL fActivate;
  674. HWND hWnd;
  675. LPRECT lprc;
  676. {
  677. Puts("OleActivate");
  678. if (!CheckObject(lpobj))
  679. return(OLE_ERROR_OBJECT);
  680. /* PROBE_READ(lprc); */
  681. return (*lpobj->lpvtbl->Activate) (lpobj, verb, fShow, fActivate, hWnd, lprc);
  682. }
  683. OLESTATUS FAR PASCAL OleClose (lpobj)
  684. LPOLEOBJECT lpobj;
  685. {
  686. Puts("OleClose");
  687. if (!CheckObject(lpobj))
  688. return(OLE_ERROR_OBJECT);
  689. return (*lpobj->lpvtbl->Close) (lpobj);
  690. }
  691. /***************************** Public Function ****************************\
  692. *
  693. * OLESTATUS FAR PASCAL OleUpdate (lpobj)
  694. *
  695. * If there exists a link, sends advise for getting the latest rendering
  696. * infromation. If there is no link, loads an instance, advises for the
  697. * render information and closes the instance once the data is available.
  698. * (If possible should not show the window).
  699. *
  700. * History:
  701. * Wrote it.
  702. \***************************************************************************/
  703. OLESTATUS FAR PASCAL OleUpdate (lpobj)
  704. LPOLEOBJECT lpobj;
  705. {
  706. Puts("OleUpdate");
  707. if (!CheckObject(lpobj))
  708. return(OLE_ERROR_OBJECT);
  709. return (*lpobj->lpvtbl->Update) (lpobj);
  710. }
  711. /***************************** Public Function ****************************\
  712. *
  713. * OLESTATUS FAR PASCAL OleReconnect (lpobj)
  714. *
  715. * Reconnects to the renderer if one does not exist already.
  716. *
  717. * History:
  718. * Wrote it.
  719. \***************************************************************************/
  720. OLESTATUS FAR PASCAL OleReconnect (lpobj)
  721. LPOLEOBJECT lpobj;
  722. {
  723. Puts("OleReconnect");
  724. if (!CheckObject(lpobj))
  725. return(OLE_ERROR_OBJECT);
  726. return (*lpobj->lpvtbl->Reconnect) (lpobj);
  727. }
  728. OLESTATUS FAR PASCAL OleGetLinkUpdateOptions (lpobj, lpOptions)
  729. LPOLEOBJECT lpobj;
  730. OLEOPT_UPDATE FAR * lpOptions;
  731. {
  732. Puts("OleGetLinkUpdateOptions");
  733. if (!CheckObject(lpobj))
  734. return(OLE_ERROR_OBJECT);
  735. PROBE_WRITE(lpOptions);
  736. return (*lpobj->lpvtbl->GetLinkUpdateOptions) (lpobj, lpOptions);
  737. }
  738. OLESTATUS FAR PASCAL OleSetLinkUpdateOptions (lpobj, options)
  739. LPOLEOBJECT lpobj;
  740. OLEOPT_UPDATE options;
  741. {
  742. Puts("OleSetLinkUpdateOptions");
  743. if (!CheckObject(lpobj))
  744. return(OLE_ERROR_OBJECT);
  745. return (*lpobj->lpvtbl->SetLinkUpdateOptions) (lpobj, options);
  746. }
  747. /***************************** Public Function ****************************\
  748. * OLESTATUS FAR PASCAL OleEnumFormats (lpobj, cfFormat)
  749. *
  750. * Returns OLE_YES if the object is of type LINK or EMBEDDED.
  751. *
  752. * Effects:
  753. *
  754. * History:
  755. * Wrote it.
  756. \***************************************************************************/
  757. OLECLIPFORMAT FAR PASCAL OleEnumFormats (lpobj, cfFormat)
  758. LPOLEOBJECT lpobj;
  759. OLECLIPFORMAT cfFormat;
  760. {
  761. Puts("OleEnumFormats");
  762. if (!CheckObject(lpobj))
  763. return NULL;
  764. return (*lpobj->lpvtbl->EnumFormats) (lpobj, cfFormat);
  765. }
  766. OLESTATUS FAR PASCAL OleRequestData (lpobj, cfFormat)
  767. LPOLEOBJECT lpobj;
  768. OLECLIPFORMAT cfFormat;
  769. {
  770. Puts("OleGetData");
  771. if (!CheckObject(lpobj))
  772. return(OLE_ERROR_OBJECT);
  773. if (!cfFormat)
  774. return OLE_ERROR_FORMAT;
  775. return (*lpobj->lpvtbl->RequestData) (lpobj, cfFormat);
  776. }
  777. OLESTATUS FAR PASCAL OleGetData (lpobj, cfFormat, lphandle)
  778. LPOLEOBJECT lpobj;
  779. OLECLIPFORMAT cfFormat;
  780. LPHANDLE lphandle;
  781. {
  782. Puts("OleGetData");
  783. if (!CheckObject(lpobj))
  784. return(OLE_ERROR_OBJECT);
  785. PROBE_WRITE(lphandle);
  786. return (*lpobj->lpvtbl->GetData) (lpobj, cfFormat, lphandle);
  787. }
  788. OLESTATUS FAR PASCAL OleSetData (lpobj, cfFormat, hData)
  789. LPOLEOBJECT lpobj;
  790. OLECLIPFORMAT cfFormat;
  791. HANDLE hData;
  792. {
  793. Puts("OleSetData");
  794. if (!CheckObject(lpobj))
  795. return(OLE_ERROR_OBJECT);
  796. return (*lpobj->lpvtbl->SetData) (lpobj, cfFormat, hData);
  797. }
  798. OLESTATUS FAR PASCAL OleQueryOutOfDate (lpobj)
  799. LPOLEOBJECT lpobj;
  800. {
  801. if (!CheckObject(lpobj))
  802. return(OLE_ERROR_OBJECT);
  803. return (*lpobj->lpvtbl->QueryOutOfDate) (lpobj);
  804. }
  805. OLESTATUS FAR PASCAL OleLockServer (lpobjsrc, lplhsrvr)
  806. LPOLEOBJECT lpobjsrc;
  807. LHSERVER FAR * lplhsrvr;
  808. {
  809. LPOBJECT_LE lpobj;
  810. OLESTATUS retVal = OLE_OK;
  811. ATOM aCliClass, aSvrClass;
  812. Puts ("OleLockServer");
  813. if (!FarCheckObject(lpobjsrc))
  814. return OLE_ERROR_OBJECT;
  815. if (lpobjsrc->ctype == CT_STATIC)
  816. return OLE_ERROR_STATIC;
  817. // Assumes all the creates are in order
  818. PROBE_CREATE_ASYNC(((LPOBJECT_LE)lpobjsrc));
  819. FARPROBE_WRITE(lplhsrvr);
  820. aCliClass = ((LPCLIENTDOC)(lpobjsrc->lhclientdoc))->aClass;
  821. aSvrClass = ((LPOBJECT_LE)lpobjsrc)->app;
  822. // See whether the server is already locked
  823. lpobj = (LPOBJECT_LE) (lockDoc.lpHeadObj);
  824. while (lpobj) {
  825. if ((lpobj->app == aSvrClass) && (lpobj->topic == aCliClass)) {
  826. if (!lpobj->head.cx) {
  827. // The unlocking process of server handle has started. This
  828. // is an asynchronous process. We want to let it complete.
  829. // Let's try the next handle
  830. ;
  831. }
  832. else {
  833. if (!IsServerValid (lpobj)) {
  834. DeleteSrvrEdit (lpobj);
  835. retVal = LockServer (lpobj);
  836. }
  837. else {
  838. // Lock count
  839. lpobj->head.cx++;
  840. }
  841. if (retVal == OLE_OK)
  842. *lplhsrvr = (LHSERVER) lpobj;
  843. return retVal;
  844. }
  845. }
  846. lpobj = (LPOBJECT_LE) (lpobj->head.lpNextObj);
  847. }
  848. if (!(lpobj = LeCreateBlank(lhLockDoc, NULL, OT_EMBEDDED)))
  849. return OLE_ERROR_MEMORY;
  850. lpobj->head.lpclient = NULL;
  851. lpobj->head.lpvtbl = lpobjsrc->lpvtbl;
  852. lpobj->app = DuplicateAtom (aSvrClass);
  853. lpobj->topic = DuplicateAtom (aCliClass);
  854. lpobj->aServer = DuplicateAtom(((LPOBJECT_LE)lpobjsrc)->aServer);
  855. lpobj->bOleServer = ((LPOBJECT_LE)lpobjsrc)->bOleServer;
  856. if ((retVal = LockServer (lpobj)) == OLE_OK) {
  857. // Change signature
  858. lpobj->head.objId[0] = 'S';
  859. lpobj->head.objId[1] = 'L';
  860. *lplhsrvr = (LHSERVER) lpobj;
  861. }
  862. else {
  863. LeRelease (lpobj);
  864. }
  865. return retVal;
  866. }
  867. OLESTATUS INTERNAL LockServer (lpobj)
  868. LPOBJECT_LE lpobj;
  869. {
  870. HANDLE hInst;
  871. if (!InitSrvrConv (lpobj, NULL)) {
  872. if (!lpobj->bOleServer)
  873. lpobj->fCmd = ACT_MINIMIZE;
  874. else
  875. lpobj->fCmd = NULL;
  876. if (!(hInst = LeLaunchApp (lpobj)))
  877. return OLE_ERROR_LAUNCH;
  878. if (!InitSrvrConv (lpobj, hInst))
  879. return OLE_ERROR_COMM;
  880. }
  881. // lock count
  882. lpobj->head.cx++;
  883. return OLE_OK;
  884. }
  885. OLESTATUS FAR PASCAL OleUnlockServer (lhsrvr)
  886. LHSERVER lhsrvr;
  887. {
  888. LPOBJECT_LE lpobj;
  889. OLESTATUS retval;
  890. Puts ("OleUnlockServer");
  891. if (!FarCheckPointer ((lpobj = (LPOBJECT_LE)lhsrvr), WRITE_ACCESS))
  892. return OLE_ERROR_HANDLE;
  893. if (lpobj->head.objId[0] != 'S' || lpobj->head.objId[1] != 'L')
  894. return OLE_ERROR_HANDLE;
  895. if (!lpobj->head.cx)
  896. return OLE_OK;
  897. if (--lpobj->head.cx)
  898. return OLE_OK;
  899. //change signature
  900. lpobj->head.objId[0] = 'L';
  901. lpobj->head.objId[1] = 'E';
  902. if ((retval = LeRelease (lpobj)) == OLE_WAIT_FOR_RELEASE)
  903. DocDeleteObject ((LPOLEOBJECT)lpobj);
  904. return retval;
  905. }
  906. OLESTATUS FAR PASCAL OleObjectConvert (lpobj, lpprotocol, lpclient, lhclientdoc, lpobjname, lplpobj)
  907. LPOLEOBJECT lpobj;
  908. LPSTR lpprotocol;
  909. LPOLECLIENT lpclient;
  910. LHCLIENTDOC lhclientdoc;
  911. LPSTR lpobjname;
  912. LPOLEOBJECT FAR * lplpobj;
  913. {
  914. if (!CheckObject(lpobj))
  915. return(OLE_ERROR_OBJECT);
  916. if (!CheckClientDoc ((LPCLIENTDOC) lhclientdoc))
  917. return OLE_ERROR_HANDLE;
  918. PROBE_READ(lpprotocol);
  919. PROBE_WRITE(lplpobj);
  920. #ifdef FIREWALLS
  921. ASSERT (lpobjname, "NULL lpobjname passed to OleObjectConvert\n");
  922. #endif
  923. PROBE_READ(lpobjname);
  924. if (!lpobjname[0])
  925. return OLE_ERROR_NAME;
  926. return (*lpobj->lpvtbl->ObjectConvert) (lpobj, lpprotocol, lpclient,
  927. lhclientdoc, lpobjname, lplpobj);
  928. }
  929. //OleCreateFromTemplate: Creates an embedded object from Template
  930. OLESTATUS FAR PASCAL OleCreateFromTemplate (lpprotocol, lpclient, lptemplate, lhclientdoc, lpobjname, lplpoleobject, optRender, cfFormat )
  931. LPSTR lpprotocol;
  932. LPOLECLIENT lpclient;
  933. LPSTR lptemplate;
  934. LHCLIENTDOC lhclientdoc;
  935. LPSTR lpobjname;
  936. LPOLEOBJECT FAR * lplpoleobject;
  937. OLEOPT_RENDER optRender;
  938. OLECLIPFORMAT cfFormat;
  939. {
  940. OLESTATUS retval = OLE_ERROR_MEMORY;
  941. char buf[MAX_STR];
  942. int objCount;
  943. int iTable = INVALID_INDEX;
  944. Puts("OleCreateFromTemplate");
  945. PROBE_MODE(bProtMode);
  946. if (!CheckClientDoc ((LPCLIENTDOC) lhclientdoc))
  947. return OLE_ERROR_HANDLE;
  948. PROBE_READ(lpprotocol);
  949. PROBE_READ(lpclient);
  950. PROBE_READ(lptemplate);
  951. PROBE_WRITE(lplpoleobject);
  952. #ifdef FIREWALLS
  953. ASSERT (lpobjname, "NULL lpobjname passed to OleCreateFromTemplate\n");
  954. #endif
  955. PROBE_READ(lpobjname);
  956. if (!lpobjname[0])
  957. return OLE_ERROR_NAME;
  958. if (lstrcmpi (lpprotocol, PROTOCOL_EDIT))
  959. return OLE_ERROR_PROTOCOL;
  960. if (!MapExtToClass (lptemplate, (LPSTR)buf, MAX_STR))
  961. return OLE_ERROR_CLASS;
  962. // !!! we found the class name. At this point, we need to load
  963. // the right library and call the right entry point;
  964. iTable = LoadDll ((LPSTR)buf);
  965. if (iTable == INVALID_INDEX)
  966. retval = DefCreateFromTemplate (lpprotocol, lpclient, lptemplate,
  967. lhclientdoc, lpobjname, lplpoleobject,
  968. optRender, cfFormat);
  969. else {
  970. objCount = lpDllTable[iTable].cObj;
  971. retval = (*lpDllTable[iTable].CreateFromTemplate) (lpprotocol,
  972. lpclient, lptemplate,
  973. lhclientdoc, lpobjname, lplpoleobject,
  974. optRender, cfFormat);
  975. if (retval > OLE_WAIT_FOR_RELEASE)
  976. lpDllTable[iTable].cObj = objCount - 1;
  977. else
  978. (*lplpoleobject)->iTable = iTable;
  979. }
  980. return retval;
  981. }
  982. //OleCreate: Creates an embedded object from the class.
  983. OLESTATUS FAR PASCAL OleCreate (lpprotocol, lpclient, lpclass, lhclientdoc, lpobjname, lplpoleobject, optRender, cfFormat)
  984. LPSTR lpprotocol;
  985. LPOLECLIENT lpclient;
  986. LPSTR lpclass;
  987. LHCLIENTDOC lhclientdoc;
  988. LPSTR lpobjname;
  989. LPOLEOBJECT FAR * lplpoleobject;
  990. OLEOPT_RENDER optRender;
  991. OLECLIPFORMAT cfFormat;
  992. {
  993. OLESTATUS retval = OLE_ERROR_MEMORY;
  994. int objCount;
  995. int iTable = INVALID_INDEX;
  996. Puts("OleCreate");
  997. PROBE_MODE(bProtMode);
  998. if (!CheckClientDoc ((LPCLIENTDOC) lhclientdoc))
  999. return OLE_ERROR_HANDLE;
  1000. PROBE_READ(lpprotocol);
  1001. PROBE_READ(lpclient);
  1002. PROBE_READ(lpclass);
  1003. PROBE_WRITE(lplpoleobject);
  1004. #ifdef FIREWALLS
  1005. ASSERT (lpobjname, "NULL lpobjname passed to OleCreate\n");
  1006. #endif
  1007. PROBE_READ(lpobjname);
  1008. if (!lpobjname[0])
  1009. return OLE_ERROR_NAME;
  1010. if (lstrcmpi (lpprotocol, PROTOCOL_EDIT))
  1011. return OLE_ERROR_PROTOCOL;
  1012. iTable = LoadDll (lpclass);
  1013. if (iTable == INVALID_INDEX)
  1014. retval = DefCreate (lpprotocol, lpclient, lpclass,
  1015. lhclientdoc, lpobjname, lplpoleobject,
  1016. optRender, cfFormat);
  1017. else {
  1018. objCount = lpDllTable[iTable].cObj;
  1019. retval = (*lpDllTable[iTable].Create) (lpprotocol,
  1020. lpclient, lpclass,
  1021. lhclientdoc, lpobjname, lplpoleobject,
  1022. optRender, cfFormat);
  1023. if (retval > OLE_WAIT_FOR_RELEASE)
  1024. lpDllTable[iTable].cObj = objCount - 1;
  1025. else
  1026. (*lplpoleobject)->iTable = iTable;
  1027. }
  1028. return retval;
  1029. }
  1030. //////////////////////////////////////////////////////////////////////////////
  1031. //
  1032. // OLESTATUS FAR PASCAL OleCreateInvisible (lpprotocol, lpclient, lpclass, lhclientdoc, lpobjname, lplpoleobject, optRender, cfFormat, bLaunchServer)
  1033. //
  1034. // Creates an embedded object from the class.
  1035. //
  1036. // Arguments:
  1037. //
  1038. // lpprotocol -
  1039. // lpclient -
  1040. // lpclass -
  1041. // lhclientdoc -
  1042. // lpobjname -
  1043. // lplpoleobject -
  1044. // optRender -
  1045. // cfFormat -
  1046. // bLaunchServer -
  1047. //
  1048. // Returns:
  1049. //
  1050. // OLE_ERROR_HANDLE -
  1051. // OLE_ERROR_NAME -
  1052. // OLE_ERROR_PROTOCOL -
  1053. //
  1054. // Effects:
  1055. //
  1056. //////////////////////////////////////////////////////////////////////////////
  1057. OLESTATUS FAR PASCAL OleCreateInvisible (lpprotocol, lpclient, lpclass, lhclientdoc, lpobjname, lplpoleobject, optRender, cfFormat, bLaunchServer)
  1058. LPSTR lpprotocol;
  1059. LPOLECLIENT lpclient;
  1060. LPSTR lpclass;
  1061. LHCLIENTDOC lhclientdoc;
  1062. LPSTR lpobjname;
  1063. LPOLEOBJECT FAR * lplpoleobject;
  1064. OLEOPT_RENDER optRender;
  1065. OLECLIPFORMAT cfFormat;
  1066. BOOL bLaunchServer;
  1067. {
  1068. OLESTATUS retval = OLE_ERROR_MEMORY;
  1069. int objCount;
  1070. int iTable = INVALID_INDEX;
  1071. Puts("OleCreateInvisible");
  1072. PROBE_MODE(bProtMode);
  1073. if (!CheckClientDoc ((LPCLIENTDOC) lhclientdoc))
  1074. return OLE_ERROR_HANDLE;
  1075. PROBE_READ(lpprotocol);
  1076. PROBE_READ(lpclient);
  1077. PROBE_READ(lpclass);
  1078. PROBE_WRITE(lplpoleobject);
  1079. #ifdef FIREWALLS
  1080. ASSERT (lpobjname, "NULL lpobjname passed to OleCreate\n");
  1081. #endif
  1082. PROBE_READ(lpobjname);
  1083. if (!lpobjname[0])
  1084. return OLE_ERROR_NAME;
  1085. if (lstrcmpi (lpprotocol, PROTOCOL_EDIT))
  1086. return OLE_ERROR_PROTOCOL;
  1087. iTable = LoadDll (lpclass);
  1088. if (iTable == INVALID_INDEX) {
  1089. retval = DefCreateInvisible (lpprotocol, lpclient, lpclass,
  1090. lhclientdoc, lpobjname, lplpoleobject,
  1091. optRender, cfFormat, bLaunchServer);
  1092. }
  1093. else {
  1094. objCount = lpDllTable[iTable].cObj;
  1095. if (!(lpDllTable[iTable].CreateInvisible)) {
  1096. // dll didn't export this function. Lets call DllCreate, so that
  1097. // handler will get a chance to replace the methods. The flag is
  1098. // used to tell the internal functions that this call infact wants
  1099. // to achieve the effect of CreateInvisble.
  1100. gbCreateInvisible = TRUE;
  1101. gbLaunchServer = bLaunchServer;
  1102. retval = (*lpDllTable[iTable].Create) (lpprotocol,
  1103. lpclient, lpclass,
  1104. lhclientdoc, lpobjname, lplpoleobject,
  1105. optRender, cfFormat);
  1106. gbCreateInvisible = FALSE;
  1107. }
  1108. else {
  1109. retval = (*lpDllTable[iTable].CreateInvisible) (lpprotocol,
  1110. lpclient, lpclass,
  1111. lhclientdoc, lpobjname, lplpoleobject,
  1112. optRender, cfFormat, bLaunchServer);
  1113. }
  1114. if (retval > OLE_WAIT_FOR_RELEASE)
  1115. lpDllTable[iTable].cObj = objCount - 1;
  1116. else
  1117. (*lplpoleobject)->iTable = iTable;
  1118. }
  1119. return retval;
  1120. }
  1121. //OleCreateFromFile: Creates an embedded object from file
  1122. OLESTATUS FAR PASCAL OleCreateFromFile (lpprotocol, lpclient, lpclass, lpfile, lhclientdoc, lpobjname, lplpoleobject, optRender, cfFormat )
  1123. LPSTR lpprotocol;
  1124. LPOLECLIENT lpclient;
  1125. LPSTR lpclass;
  1126. LPSTR lpfile;
  1127. LHCLIENTDOC lhclientdoc;
  1128. LPSTR lpobjname;
  1129. LPOLEOBJECT FAR * lplpoleobject;
  1130. OLEOPT_RENDER optRender;
  1131. OLECLIPFORMAT cfFormat;
  1132. {
  1133. OLESTATUS retval = OLE_ERROR_MEMORY;
  1134. char buf[MAX_STR];
  1135. int objCount;
  1136. int iTable = INVALID_INDEX;
  1137. Puts("OleCreateFromFile");
  1138. PROBE_MODE(bProtMode);
  1139. if (!CheckClientDoc ((LPCLIENTDOC) lhclientdoc))
  1140. return OLE_ERROR_HANDLE;
  1141. PROBE_READ(lpprotocol);
  1142. PROBE_READ(lpclient);
  1143. PROBE_READ(lpfile);
  1144. PROBE_WRITE(lplpoleobject);
  1145. #ifdef FIREWALLS
  1146. ASSERT (lpobjname, "NULL lpobjname passed to OleCreateFromFile\n");
  1147. #endif
  1148. PROBE_READ(lpobjname);
  1149. if (!lpobjname[0])
  1150. return OLE_ERROR_NAME;
  1151. if (lpclass)
  1152. PROBE_READ(lpclass);
  1153. if (lstrcmpi (lpprotocol, PROTOCOL_EDIT))
  1154. return OLE_ERROR_PROTOCOL;
  1155. if (lpclass) {
  1156. if (!QueryApp (lpclass, lpprotocol, buf))
  1157. return OLE_ERROR_CLASS;
  1158. if (!lstrcmp (lpclass, packageClass))
  1159. iTable = INVALID_INDEX;
  1160. else
  1161. iTable = LoadDll (lpclass);
  1162. }
  1163. else if (MapExtToClass (lpfile, (LPSTR)buf, MAX_STR))
  1164. iTable = LoadDll (buf);
  1165. else
  1166. return OLE_ERROR_CLASS;
  1167. if (iTable == INVALID_INDEX)
  1168. retval = DefCreateFromFile (lpprotocol,
  1169. lpclient, lpclass, lpfile,
  1170. lhclientdoc, lpobjname, lplpoleobject,
  1171. optRender, cfFormat);
  1172. else {
  1173. objCount = lpDllTable[iTable].cObj;
  1174. retval = (*lpDllTable[iTable].CreateFromFile) (lpprotocol,
  1175. lpclient, lpclass, lpfile,
  1176. lhclientdoc, lpobjname, lplpoleobject,
  1177. optRender, cfFormat);
  1178. if (retval > OLE_WAIT_FOR_RELEASE)
  1179. lpDllTable[iTable].cObj = objCount - 1;
  1180. else
  1181. (*lplpoleobject)->iTable = iTable;
  1182. }
  1183. return retval;
  1184. }
  1185. //OleCreateLinkFromFile: Creates a linked object from file
  1186. OLESTATUS FAR PASCAL OleCreateLinkFromFile (lpprotocol, lpclient, lpclass, lpfile, lpitem, lhclientdoc, lpobjname, lplpoleobject, optRender, cfFormat )
  1187. LPSTR lpprotocol;
  1188. LPOLECLIENT lpclient;
  1189. LPSTR lpclass;
  1190. LPSTR lpfile;
  1191. LPSTR lpitem;
  1192. LHCLIENTDOC lhclientdoc;
  1193. LPSTR lpobjname;
  1194. LPOLEOBJECT FAR * lplpoleobject;
  1195. OLEOPT_RENDER optRender;
  1196. OLECLIPFORMAT cfFormat;
  1197. {
  1198. OLESTATUS retval = OLE_ERROR_MEMORY;
  1199. char buf[MAX_STR+6];
  1200. int objCount;
  1201. int iTable = INVALID_INDEX;
  1202. Puts("OleCreateLinkFromFile");
  1203. PROBE_MODE(bProtMode);
  1204. if (!CheckClientDoc ((LPCLIENTDOC) lhclientdoc))
  1205. return OLE_ERROR_HANDLE;
  1206. PROBE_READ(lpprotocol);
  1207. PROBE_READ(lpclient);
  1208. PROBE_READ(lpfile);
  1209. PROBE_WRITE(lplpoleobject);
  1210. #ifdef FIREWALLS
  1211. ASSERT (lpobjname, "NULL lpobjname passed to OleCreateLinkFromFile\n");
  1212. #endif
  1213. PROBE_READ(lpobjname);
  1214. if (!lpobjname[0])
  1215. return OLE_ERROR_NAME;
  1216. if (lpclass)
  1217. PROBE_READ(lpclass);
  1218. if (lpitem)
  1219. PROBE_READ(lpitem);
  1220. if (lstrcmpi (lpprotocol, PROTOCOL_EDIT))
  1221. return OLE_ERROR_PROTOCOL;
  1222. if (lpclass) {
  1223. if (!QueryApp (lpclass, lpprotocol, buf))
  1224. return OLE_ERROR_CLASS;
  1225. if (!lstrcmp (lpclass, packageClass)) {
  1226. lstrcpy (buf, lpfile);
  1227. lstrcat (buf, "/Link");
  1228. return CreateEmbLnkFromFile (lpclient, packageClass, buf,
  1229. NULL, lhclientdoc, lpobjname, lplpoleobject,
  1230. optRender, cfFormat, OT_EMBEDDED);
  1231. }
  1232. else
  1233. iTable = LoadDll (lpclass);
  1234. }
  1235. else if (MapExtToClass (lpfile, (LPSTR)buf, MAX_STR))
  1236. iTable = LoadDll (buf);
  1237. else
  1238. return OLE_ERROR_CLASS;
  1239. if (iTable == INVALID_INDEX)
  1240. retval = DefCreateLinkFromFile (lpprotocol,
  1241. lpclient, lpclass, lpfile, lpitem,
  1242. lhclientdoc, lpobjname, lplpoleobject,
  1243. optRender, cfFormat);
  1244. else {
  1245. objCount = lpDllTable[iTable].cObj;
  1246. retval = (*lpDllTable[iTable].CreateLinkFromFile) (lpprotocol,
  1247. lpclient, lpclass, lpfile, lpitem,
  1248. lhclientdoc, lpobjname, lplpoleobject,
  1249. optRender, cfFormat);
  1250. if (retval > OLE_WAIT_FOR_RELEASE)
  1251. lpDllTable[iTable].cObj = objCount - 1;
  1252. else
  1253. (*lplpoleobject)->iTable = iTable;
  1254. }
  1255. return retval;
  1256. }
  1257. // Routines related to asynchronous operations.
  1258. OLESTATUS FAR PASCAL OleQueryReleaseStatus (lpobj)
  1259. LPOLEOBJECT lpobj;
  1260. {
  1261. if (!CheckPointer (lpobj, WRITE_ACCESS))
  1262. return OLE_ERROR_OBJECT;
  1263. // make sure that it is a long pointer to L&E object or a lock handle
  1264. if (!(lpobj->objId[0] == 'L' && lpobj->objId[1] == 'E')
  1265. && !(lpobj->objId[0] == 'S' && lpobj->objId[1] == 'L'))
  1266. return OLE_ERROR_OBJECT;
  1267. return (*lpobj->lpvtbl->QueryReleaseStatus) (lpobj);
  1268. }
  1269. OLESTATUS FAR PASCAL OleQueryReleaseError (lpobj)
  1270. LPOLEOBJECT lpobj;
  1271. {
  1272. if (!CheckObject(lpobj))
  1273. return(OLE_ERROR_OBJECT);
  1274. return (*lpobj->lpvtbl->QueryReleaseError) (lpobj);
  1275. }
  1276. OLE_RELEASE_METHOD FAR PASCAL OleQueryReleaseMethod (lpobj)
  1277. LPOLEOBJECT lpobj;
  1278. {
  1279. if (!CheckObject(lpobj))
  1280. return(OLE_ERROR_OBJECT);
  1281. return (*lpobj->lpvtbl->QueryReleaseMethod) (lpobj);
  1282. }
  1283. OLESTATUS FAR PASCAL OleRename (lpobj, lpNewName)
  1284. LPOLEOBJECT lpobj;
  1285. LPSTR lpNewName;
  1286. {
  1287. if (!CheckObject(lpobj))
  1288. return OLE_ERROR_OBJECT;
  1289. return (*lpobj->lpvtbl->Rename) (lpobj, lpNewName);
  1290. }
  1291. OLESTATUS FAR PASCAL OleExecute (lpobj, hCmds, wReserved)
  1292. LPOLEOBJECT lpobj;
  1293. HANDLE hCmds;
  1294. WORD wReserved;
  1295. {
  1296. if (!CheckObject(lpobj))
  1297. return OLE_ERROR_OBJECT;
  1298. return (*lpobj->lpvtbl->Execute) (lpobj, hCmds, wReserved);
  1299. }
  1300. OLESTATUS FAR PASCAL OleQueryName (lpobj, lpBuf, lpcbBuf)
  1301. LPOLEOBJECT lpobj;
  1302. LPSTR lpBuf;
  1303. WORD FAR * lpcbBuf;
  1304. {
  1305. if (!CheckObject(lpobj))
  1306. return OLE_ERROR_OBJECT;
  1307. return (*lpobj->lpvtbl->QueryName) (lpobj, lpBuf, lpcbBuf);
  1308. }
  1309. OLESTATUS FAR PASCAL OleQueryType (lpobj, lptype)
  1310. LPOLEOBJECT lpobj;
  1311. LPLONG lptype;
  1312. {
  1313. Puts("OleQueryType");
  1314. if (!CheckObject(lpobj))
  1315. return(OLE_ERROR_OBJECT);
  1316. PROBE_WRITE(lptype);
  1317. return (*lpobj->lpvtbl->QueryType) (lpobj, lptype);
  1318. }
  1319. DWORD FAR PASCAL OleQueryClientVersion ()
  1320. {
  1321. return dwOleVer;
  1322. }
  1323. OLESTATUS INTERNAL LeQueryCreateFromClip (lpprotocol, optRender, cfFormat, cType)
  1324. LPSTR lpprotocol;
  1325. OLEOPT_RENDER optRender;
  1326. OLECLIPFORMAT cfFormat;
  1327. LONG cType;
  1328. {
  1329. OLESTATUS retVal = TRUE;
  1330. BOOL bEdit = FALSE, bStatic = FALSE;
  1331. PROBE_MODE(bProtMode);
  1332. PROBE_READ(lpprotocol);
  1333. if (bEdit = !lstrcmpi (lpprotocol, PROTOCOL_EDIT)) {
  1334. if (IsClipboardFormatAvailable (cfFileName))
  1335. return OLE_OK;
  1336. if (cType == CT_LINK)
  1337. retVal = IsClipboardFormatAvailable (cfObjectLink);
  1338. #ifdef OLD
  1339. || IsClipboardFormatAvailable (cfLink) ;
  1340. #endif
  1341. else if (cType == CT_EMBEDDED)
  1342. retVal = IsClipboardFormatAvailable (cfOwnerLink);
  1343. if (!retVal)
  1344. return OLE_ERROR_FORMAT;
  1345. if (optRender == olerender_none)
  1346. return OLE_OK;
  1347. }
  1348. else if (bStatic = !lstrcmpi (lpprotocol, PROTOCOL_STATIC)) {
  1349. if (cType == CT_LINK)
  1350. return OLE_ERROR_PROTOCOL;
  1351. if (optRender == olerender_none)
  1352. return OLE_ERROR_FORMAT;
  1353. }
  1354. else {
  1355. return OLE_ERROR_PROTOCOL;
  1356. }
  1357. if (optRender == olerender_draw) {
  1358. if (!IsClipboardFormatAvailable (CF_METAFILEPICT) &&
  1359. !IsClipboardFormatAvailable (CF_DIB) &&
  1360. !IsClipboardFormatAvailable (CF_BITMAP) &&
  1361. !(bEdit && QueryHandler((cType == CT_LINK) ? cfObjectLink : cfOwnerLink)))
  1362. return OLE_ERROR_FORMAT;
  1363. }
  1364. else if (optRender == olerender_format) {
  1365. if (!IsClipboardFormatAvailable (cfFormat))
  1366. return OLE_ERROR_FORMAT;
  1367. if (bStatic && (cfFormat != CF_METAFILEPICT)
  1368. && (cfFormat != CF_DIB) && (cfFormat != CF_BITMAP))
  1369. return OLE_ERROR_FORMAT;
  1370. }
  1371. else {
  1372. return OLE_ERROR_FORMAT;
  1373. }
  1374. return OLE_OK;
  1375. }
  1376. BOOL INTERNAL CheckObject(lpobj)
  1377. LPOLEOBJECT lpobj;
  1378. {
  1379. if (!CheckPointer(lpobj, WRITE_ACCESS))
  1380. return FALSE;
  1381. if (lpobj->objId[0] == 'L' && lpobj->objId[1] == 'E')
  1382. return TRUE;
  1383. return FALSE;
  1384. }
  1385. BOOL FARINTERNAL FarCheckObject(lpobj)
  1386. LPOLEOBJECT lpobj;
  1387. {
  1388. return (CheckObject (lpobj));
  1389. }