Leaked source code of windows server 2003
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.

1776 lines
58 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1994.
  5. //
  6. // File: wrapstub.cpp
  7. //
  8. // Contents: ANSI to Unicode wrappers and Unicode stubs
  9. //
  10. // Classes: WrappedIOleUILinkContainer
  11. // WrappedIOleUIObjInfo
  12. // WrappedIOleUILinkInfo
  13. //
  14. // Functions:
  15. #ifdef UNICODE
  16. // OleUIAddVerbMenuA
  17. // OleUIInsertObjectA
  18. // OleUIPasteSpecialA
  19. // OleUIEditLinksA
  20. // OleUIChangeIconA
  21. // OleUIConvertA
  22. // OleUIBusyA
  23. // OleUIUpdateLinksA
  24. // OleUIObjectPropertiesA
  25. // OleUIChangeSourceA
  26. // OleUIPromptUserA
  27. #else
  28. // OleUIAddVerbMenuW
  29. // OleUIInsertObjectW
  30. // OleUIPasteSpecialW
  31. // OleUIEditLinksW
  32. // OleUIChangeIconW
  33. // OleUIConvertW
  34. // OleUIBusyW
  35. // OleUIUpdateLinksW
  36. // OleUIObjectPropertiesW
  37. // OleUIChangeSourceW
  38. // OleUIPromptUserW
  39. #endif
  40. //
  41. // History: 11-02-94 stevebl Created
  42. //
  43. //----------------------------------------------------------------------------
  44. #include "precomp.h"
  45. #include "common.h"
  46. #ifdef UNICODE
  47. // ANSI to Unicode Wrappers
  48. //+---------------------------------------------------------------------------
  49. //
  50. // Function: OleUIAddVerbMenuA
  51. //
  52. // Synopsis: converts call to ANSI version into call to Unicode version
  53. //
  54. // Arguments: [lpOleObj] -
  55. // [lpszShortType] - [in] on heap
  56. // [hMenu] -
  57. // [uPos] -
  58. // [uIDVerbMin] -
  59. // [uIDVerbMax] -
  60. // [bAddConvert] -
  61. // [idConvert] -
  62. // [lphMenu] -
  63. //
  64. // History: 11-04-94 stevebl Created
  65. //
  66. //----------------------------------------------------------------------------
  67. STDAPI_(BOOL) OleUIAddVerbMenuA(LPOLEOBJECT lpOleObj, LPCSTR lpszShortType,
  68. HMENU hMenu, UINT uPos, UINT uIDVerbMin, UINT uIDVerbMax,
  69. BOOL bAddConvert, UINT idConvert, HMENU FAR *lphMenu)
  70. {
  71. LPWSTR lpwszShortType = NULL;
  72. if (lpszShortType && !IsBadReadPtr(lpszShortType, 1))
  73. {
  74. UINT uSize = ATOWLEN(lpszShortType);
  75. lpwszShortType = (LPWSTR)OleStdMalloc(sizeof(WCHAR) * uSize);
  76. if (lpwszShortType)
  77. {
  78. ATOW(lpwszShortType, lpszShortType, uSize);
  79. }
  80. }
  81. // NOTE - if OleStdMalloc fails, this routine must still go ahead and
  82. // succeed as best as it can since there is no way to report failure.
  83. BOOL fReturn = OleUIAddVerbMenuW(lpOleObj, lpwszShortType, hMenu, uPos,
  84. uIDVerbMin, uIDVerbMax, bAddConvert, idConvert, lphMenu);
  85. if (lpwszShortType)
  86. OleStdFree((LPVOID)lpwszShortType);
  87. return(fReturn);
  88. }
  89. //+---------------------------------------------------------------------------
  90. //
  91. // Function: OleUIInsertObjectA
  92. //
  93. // Synopsis: converts call to ANSI version into call to Unicode version
  94. //
  95. // Arguments: [psA] - ANSI structure
  96. //
  97. // History: 11-04-94 stevebl Created
  98. //
  99. // Structure members converted or passed back out (everything is passed in):
  100. // lpszCaption [in] on stack
  101. // lpszTemplate [in] on stack
  102. // lpszFile [in, out] on stack
  103. // dwFlags [out]
  104. // clsid [out]
  105. // lpIStorage [out]
  106. // ppvObj [out]
  107. // sc [out]
  108. // hMetaPict [out]
  109. //
  110. //----------------------------------------------------------------------------
  111. STDAPI_(UINT) OleUIInsertObjectA(LPOLEUIINSERTOBJECTA psA)
  112. {
  113. UINT uRet = UStandardValidation((LPOLEUISTANDARD)psA, sizeof(*psA), NULL);
  114. // If the caller is using a private template, UStandardValidation will
  115. // always return OLEUI_ERR_FINDTEMPLATEFAILURE here. This is because we
  116. // haven't converted the template name to UNICODE yet, so the
  117. // FindResource call in UStandardValidation won't find the caller's
  118. // template. This is OK for two reasons: (1) it's the last thing that
  119. // UStandardValidation checks so by this time it's basically done its
  120. // job, and (2) UStandardValidation will be called again when we forward
  121. // this call on to the Unicode version.
  122. if (OLEUI_SUCCESS != uRet && OLEUI_ERR_FINDTEMPLATEFAILURE != uRet)
  123. return uRet;
  124. if (NULL != psA->lpszFile &&
  125. (psA->cchFile <= 0 || psA->cchFile > MAX_PATH))
  126. {
  127. return(OLEUI_IOERR_CCHFILEINVALID);
  128. }
  129. // NULL is NOT valid for lpszFile
  130. if (psA->lpszFile == NULL)
  131. {
  132. return(OLEUI_IOERR_LPSZFILEINVALID);
  133. }
  134. if (IsBadWritePtr(psA->lpszFile, psA->cchFile*sizeof(char)))
  135. return(OLEUI_IOERR_LPSZFILEINVALID);
  136. OLEUIINSERTOBJECTW sW;
  137. WCHAR szCaption[MAX_PATH], szTemplate[MAX_PATH], szFile[MAX_PATH];
  138. memcpy(&sW, psA, sizeof(OLEUIINSERTOBJECTW));
  139. if (psA->lpszCaption)
  140. {
  141. ATOW(szCaption, psA->lpszCaption, MAX_PATH);
  142. sW.lpszCaption = szCaption;
  143. }
  144. if (0 != HIWORD(PtrToUlong(psA->lpszTemplate)))
  145. {
  146. ATOW(szTemplate, psA->lpszTemplate, MAX_PATH);
  147. sW.lpszTemplate = szTemplate;
  148. }
  149. if (psA->lpszFile)
  150. {
  151. ATOW(szFile, psA->lpszFile, MAX_PATH);
  152. sW.lpszFile = szFile;
  153. }
  154. uRet = OleUIInsertObjectW(&sW);
  155. if (psA->lpszFile)
  156. {
  157. WTOA(psA->lpszFile, sW.lpszFile, psA->cchFile);
  158. }
  159. memcpy(&psA->clsid, &sW.clsid, sizeof(CLSID));
  160. psA->dwFlags = sW.dwFlags;
  161. psA->lpIStorage = sW.lpIStorage;
  162. psA->ppvObj = sW.ppvObj;
  163. psA->sc = sW.sc;
  164. psA->hMetaPict = sW.hMetaPict;
  165. return(uRet);
  166. }
  167. //+---------------------------------------------------------------------------
  168. //
  169. // Function: OleUIPasteSpecialA
  170. //
  171. // Synopsis: convers call to ANSI version into call to Unicode version
  172. //
  173. // Arguments: [psA] - ANSI structure
  174. //
  175. // History: 11-04-94 stevebl Created
  176. //
  177. // Structure members converted or passed back out (everything is passed in):
  178. // lpszCaption [in] on stack
  179. // lpszTemplate [in] on stack
  180. // arrPasteEntries [in] on heap
  181. // arrPasteEntries[n].lpstrFormatName [in] on heap
  182. // dwFlags [out]
  183. // nSelectedIndex [out]
  184. // fLink [out]
  185. // hMetaPict [out]
  186. // sizel [out]
  187. //
  188. //----------------------------------------------------------------------------
  189. STDAPI_(UINT) OleUIPasteSpecialA(LPOLEUIPASTESPECIALA psA)
  190. {
  191. UINT uRet = UStandardValidation((LPOLEUISTANDARD)psA, sizeof(*psA), NULL);
  192. // If the caller is using a private template, UStandardValidation will
  193. // always return OLEUI_ERR_FINDTEMPLATEFAILURE here. This is because we
  194. // haven't converted the template name to UNICODE yet, so the
  195. // FindResource call in UStandardValidation won't find the caller's
  196. // template. This is OK for two reasons: (1) it's the last thing that
  197. // UStandardValidation checks so by this time it's basically done its
  198. // job, and (2) UStandardValidation will be called again when we forward
  199. // this call on to the Unicode version.
  200. if (OLEUI_SUCCESS != uRet && OLEUI_ERR_FINDTEMPLATEFAILURE != uRet)
  201. return uRet;
  202. // Validate PasteSpecial specific fields
  203. if (NULL == psA->arrPasteEntries || IsBadReadPtr(psA->arrPasteEntries, psA->cPasteEntries * sizeof(OLEUIPASTEENTRYA)))
  204. return(OLEUI_IOERR_ARRPASTEENTRIESINVALID);
  205. OLEUIPASTESPECIALW sW;
  206. WCHAR szCaption[MAX_PATH], szTemplate[MAX_PATH];
  207. uRet = OLEUI_ERR_LOCALMEMALLOC;
  208. UINT uIndex;
  209. memcpy(&sW, psA, sizeof(OLEUIPASTESPECIALW));
  210. if (psA->lpszCaption)
  211. {
  212. ATOW(szCaption, psA->lpszCaption, MAX_PATH);
  213. sW.lpszCaption = szCaption;
  214. }
  215. if (0 != HIWORD(PtrToUlong(psA->lpszTemplate)))
  216. {
  217. ATOW(szTemplate, psA->lpszTemplate, MAX_PATH);
  218. sW.lpszTemplate = szTemplate;
  219. }
  220. if (psA->cPasteEntries)
  221. {
  222. sW.arrPasteEntries = new OLEUIPASTEENTRYW[psA->cPasteEntries];
  223. if (NULL == sW.arrPasteEntries)
  224. {
  225. return(uRet);
  226. }
  227. for (uIndex = psA->cPasteEntries; uIndex--;)
  228. {
  229. sW.arrPasteEntries[uIndex].lpstrFormatName = NULL;
  230. sW.arrPasteEntries[uIndex].lpstrResultText = NULL;
  231. }
  232. for (uIndex = psA->cPasteEntries; uIndex--;)
  233. {
  234. sW.arrPasteEntries[uIndex].fmtetc = psA->arrPasteEntries[uIndex].fmtetc;
  235. sW.arrPasteEntries[uIndex].dwFlags = psA->arrPasteEntries[uIndex].dwFlags;
  236. sW.arrPasteEntries[uIndex].dwScratchSpace = psA->arrPasteEntries[uIndex].dwScratchSpace;
  237. if (psA->arrPasteEntries[uIndex].lpstrFormatName)
  238. {
  239. UINT uLength = ATOWLEN(psA->arrPasteEntries[uIndex].lpstrFormatName);
  240. sW.arrPasteEntries[uIndex].lpstrFormatName = new WCHAR[uLength];
  241. if (NULL == sW.arrPasteEntries[uIndex].lpstrFormatName)
  242. {
  243. goto oom_error;
  244. }
  245. ATOW((WCHAR *)sW.arrPasteEntries[uIndex].lpstrFormatName,
  246. psA->arrPasteEntries[uIndex].lpstrFormatName,
  247. uLength);
  248. }
  249. if (psA->arrPasteEntries[uIndex].lpstrResultText)
  250. {
  251. UINT uLength = ATOWLEN(psA->arrPasteEntries[uIndex].lpstrResultText);
  252. sW.arrPasteEntries[uIndex].lpstrResultText = new WCHAR[uLength];
  253. if (NULL == sW.arrPasteEntries[uIndex].lpstrResultText)
  254. {
  255. goto oom_error;
  256. }
  257. ATOW((WCHAR *)sW.arrPasteEntries[uIndex].lpstrResultText,
  258. psA->arrPasteEntries[uIndex].lpstrResultText,
  259. uLength);
  260. }
  261. }
  262. }
  263. uRet = OleUIPasteSpecialW(&sW);
  264. psA->lpSrcDataObj = sW.lpSrcDataObj;
  265. psA->dwFlags = sW.dwFlags;
  266. psA->nSelectedIndex = sW.nSelectedIndex;
  267. psA->fLink = sW.fLink;
  268. psA->hMetaPict = sW.hMetaPict;
  269. psA->sizel = sW.sizel;
  270. oom_error:
  271. for (uIndex = psA->cPasteEntries; uIndex--;)
  272. {
  273. if (sW.arrPasteEntries[uIndex].lpstrFormatName)
  274. {
  275. delete[] (WCHAR*)sW.arrPasteEntries[uIndex].lpstrFormatName;
  276. }
  277. if (sW.arrPasteEntries[uIndex].lpstrResultText)
  278. {
  279. delete[] (WCHAR *)sW.arrPasteEntries[uIndex].lpstrResultText;
  280. }
  281. }
  282. delete[] sW.arrPasteEntries;
  283. return(uRet);
  284. }
  285. //+---------------------------------------------------------------------------
  286. //
  287. // Class: WrappedIOleUILinkContainer
  288. //
  289. // Purpose: Wraps IOleUILinkContainerA with IOleUILinkContainerW methods
  290. // so it can be passed on to Unicode methods within OLE2UI32.
  291. //
  292. // Interface: QueryInterface --
  293. // AddRef --
  294. // Release --
  295. // GetNextLink --
  296. // SetLinkUpdateOptions --
  297. // GetLinkUpdateOptions --
  298. // SetLinkSource -- requires string conversion
  299. // GetLinkSource -- requires string conversion
  300. // OpenLinkSource --
  301. // UpdateLink --
  302. // CancelLink --
  303. // WrappedIOleUILinkContainer -- constructor
  304. // ~WrappedIOleUILinkContainer -- destructor
  305. //
  306. // History: 11-04-94 stevebl Created
  307. //
  308. // Notes: This is a private interface wrapper. QueryInterface is not
  309. // supported and the wrapped interface may not be used outside
  310. // of the OLE2UI32 code.
  311. //
  312. //----------------------------------------------------------------------------
  313. class WrappedIOleUILinkContainer: public IOleUILinkContainerW
  314. {
  315. public:
  316. // *** IUnknown methods *** //
  317. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj);
  318. STDMETHOD_(ULONG,AddRef) (THIS);
  319. STDMETHOD_(ULONG,Release) (THIS);
  320. // *** IOleUILinkContainer *** //
  321. STDMETHOD_(DWORD,GetNextLink) (THIS_ DWORD dwLink);
  322. STDMETHOD(SetLinkUpdateOptions) (THIS_ DWORD dwLink,
  323. DWORD dwUpdateOpt);
  324. STDMETHOD(GetLinkUpdateOptions) (THIS_ DWORD dwLink,
  325. DWORD FAR* lpdwUpdateOpt);
  326. STDMETHOD(SetLinkSource) (THIS_ DWORD dwLink, LPWSTR lpszDisplayName,
  327. ULONG lenFileName, ULONG FAR* pchEaten, BOOL fValidateSource);
  328. STDMETHOD(GetLinkSource) (THIS_ DWORD dwLink,
  329. LPWSTR FAR* lplpszDisplayName, ULONG FAR* lplenFileName,
  330. LPWSTR FAR* lplpszFullLinkType, LPWSTR FAR* lplpszShortLinkType,
  331. BOOL FAR* lpfSourceAvailable, BOOL FAR* lpfIsSelected);
  332. STDMETHOD(OpenLinkSource) (THIS_ DWORD dwLink);
  333. STDMETHOD(UpdateLink) (THIS_ DWORD dwLink,
  334. BOOL fErrorMessage, BOOL fErrorAction);
  335. STDMETHOD(CancelLink) (THIS_ DWORD dwLink);
  336. // *** Constructor and Destructor *** //
  337. WrappedIOleUILinkContainer(IOleUILinkContainerA *pilc);
  338. ~WrappedIOleUILinkContainer();
  339. private:
  340. IOleUILinkContainerA * m_pilc;
  341. ULONG m_uRefCount;
  342. };
  343. // *** IUnknown methods *** //
  344. HRESULT STDMETHODCALLTYPE WrappedIOleUILinkContainer::QueryInterface(THIS_ REFIID riid, LPVOID FAR* ppvObj)
  345. {
  346. return(E_NOTIMPL);
  347. }
  348. ULONG STDMETHODCALLTYPE WrappedIOleUILinkContainer::AddRef()
  349. {
  350. return(m_uRefCount++);
  351. }
  352. ULONG STDMETHODCALLTYPE WrappedIOleUILinkContainer::Release()
  353. {
  354. ULONG uRet = --m_uRefCount;
  355. if (0 == uRet)
  356. {
  357. delete(this);
  358. }
  359. return(uRet);
  360. }
  361. // *** IOleUILinkContainer *** //
  362. DWORD STDMETHODCALLTYPE WrappedIOleUILinkContainer::GetNextLink(DWORD dwLink)
  363. {
  364. return(m_pilc->GetNextLink(dwLink));
  365. }
  366. HRESULT STDMETHODCALLTYPE WrappedIOleUILinkContainer::SetLinkUpdateOptions (DWORD dwLink,
  367. DWORD dwUpdateOpt)
  368. {
  369. return(m_pilc->SetLinkUpdateOptions(dwLink, dwUpdateOpt));
  370. }
  371. HRESULT STDMETHODCALLTYPE WrappedIOleUILinkContainer::GetLinkUpdateOptions (DWORD dwLink,
  372. DWORD FAR* lpdwUpdateOpt)
  373. {
  374. return(m_pilc->GetLinkUpdateOptions(dwLink, lpdwUpdateOpt));
  375. }
  376. //+---------------------------------------------------------------------------
  377. //
  378. // Member: WrappedIOleUILinkContainer::SetLinkSource
  379. //
  380. // Synopsis: forwards Unicode method call on to the ANSI version
  381. //
  382. // Arguments: [dwLink] -
  383. // [lpszDisplayName] - [in] converted on stack
  384. // [lenFileName] -
  385. // [pchEaten] -
  386. // [fValidateSource] -
  387. //
  388. // History: 11-04-94 stevebl Created
  389. //
  390. //----------------------------------------------------------------------------
  391. HRESULT STDMETHODCALLTYPE WrappedIOleUILinkContainer::SetLinkSource (DWORD dwLink, LPWSTR lpszDisplayName,
  392. ULONG lenFileName, ULONG FAR* pchEaten, BOOL fValidateSource)
  393. {
  394. char szDisplayName[MAX_PATH];
  395. char * lpszDisplayNameA;
  396. if (lpszDisplayName)
  397. {
  398. WTOA(szDisplayName, lpszDisplayName, MAX_PATH);
  399. lpszDisplayNameA = szDisplayName;
  400. }
  401. else
  402. lpszDisplayNameA = NULL;
  403. return(m_pilc->SetLinkSource(dwLink, lpszDisplayNameA, lenFileName, pchEaten, fValidateSource));
  404. }
  405. //+---------------------------------------------------------------------------
  406. //
  407. // Member: WrappedIOleUILinkContainer::GetLinkSource
  408. //
  409. // Synopsis: forwards Unicode method call on to the ANSI version
  410. //
  411. // Arguments: [dwLink] -
  412. // [lplpszDisplayName] - [out] converted on heap
  413. // [lplenFileName] -
  414. // [lplpszFullLinkType] - [out] converted on heap
  415. // [lplpszShortLinkType] - [out] converted on heap
  416. // [lpfSourceAvailable] -
  417. // [lpfIsSelected] -
  418. //
  419. // History: 11-04-94 stevebl Created
  420. //
  421. //----------------------------------------------------------------------------
  422. HRESULT STDMETHODCALLTYPE WrappedIOleUILinkContainer::GetLinkSource (DWORD dwLink,
  423. LPWSTR FAR* lplpszDisplayName, ULONG FAR* lplenFileName,
  424. LPWSTR FAR* lplpszFullLinkType, LPWSTR FAR* lplpszShortLinkType,
  425. BOOL FAR* lpfSourceAvailable, BOOL FAR* lpfIsSelected)
  426. {
  427. LPSTR lpszDisplayName = NULL;
  428. LPSTR lpszFullLinkType = NULL;
  429. LPSTR lpszShortLinkType = NULL;
  430. LPSTR * lplpszDisplayNameA = NULL;
  431. LPSTR * lplpszFullLinkTypeA = NULL;
  432. LPSTR * lplpszShortLinkTypeA = NULL;
  433. if (lplpszDisplayName)
  434. {
  435. lplpszDisplayNameA = &lpszDisplayName;
  436. }
  437. if (lplpszFullLinkType)
  438. {
  439. lplpszFullLinkTypeA = &lpszFullLinkType;
  440. }
  441. if (lplpszShortLinkType)
  442. {
  443. lplpszShortLinkTypeA = &lpszShortLinkType;
  444. }
  445. HRESULT hrReturn = m_pilc->GetLinkSource(dwLink,
  446. lplpszDisplayNameA,
  447. lplenFileName,
  448. lplpszFullLinkTypeA,
  449. lplpszShortLinkTypeA,
  450. lpfSourceAvailable,
  451. lpfIsSelected);
  452. if (lplpszDisplayName)
  453. {
  454. *lplpszDisplayName = NULL;
  455. if (lpszDisplayName)
  456. {
  457. UINT uLen = ATOWLEN(lpszDisplayName);
  458. *lplpszDisplayName = (LPWSTR)OleStdMalloc(uLen * sizeof(WCHAR));
  459. if (*lplpszDisplayName)
  460. {
  461. ATOW(*lplpszDisplayName, lpszDisplayName, uLen);
  462. }
  463. else
  464. hrReturn = E_OUTOFMEMORY;
  465. OleStdFree((LPVOID)lpszDisplayName);
  466. }
  467. }
  468. if (lplpszFullLinkType)
  469. {
  470. *lplpszFullLinkType = NULL;
  471. if (lpszFullLinkType)
  472. {
  473. UINT uLen = ATOWLEN(lpszFullLinkType);
  474. *lplpszFullLinkType = (LPWSTR)OleStdMalloc(uLen * sizeof(WCHAR));
  475. if (*lplpszFullLinkType)
  476. {
  477. ATOW(*lplpszFullLinkType, lpszFullLinkType, uLen);
  478. }
  479. else
  480. hrReturn = E_OUTOFMEMORY;
  481. OleStdFree((LPVOID)lpszFullLinkType);
  482. }
  483. }
  484. if (lplpszShortLinkType)
  485. {
  486. *lplpszShortLinkType = NULL;
  487. if (lpszShortLinkType)
  488. {
  489. UINT uLen = ATOWLEN(lpszShortLinkType);
  490. *lplpszShortLinkType = (LPWSTR)OleStdMalloc(uLen * sizeof(WCHAR));
  491. if (*lplpszShortLinkType)
  492. {
  493. ATOW(*lplpszShortLinkType, lpszShortLinkType, uLen);
  494. }
  495. else
  496. hrReturn = E_OUTOFMEMORY;
  497. OleStdFree((LPVOID)lpszShortLinkType);
  498. }
  499. }
  500. return(hrReturn);
  501. }
  502. HRESULT STDMETHODCALLTYPE WrappedIOleUILinkContainer::OpenLinkSource (DWORD dwLink)
  503. {
  504. return(m_pilc->OpenLinkSource(dwLink));
  505. }
  506. HRESULT STDMETHODCALLTYPE WrappedIOleUILinkContainer::UpdateLink (DWORD dwLink,
  507. BOOL fErrorMessage, BOOL fErrorAction)
  508. {
  509. return(m_pilc->UpdateLink(dwLink, fErrorMessage, fErrorAction));
  510. }
  511. HRESULT STDMETHODCALLTYPE WrappedIOleUILinkContainer::CancelLink (DWORD dwLink)
  512. {
  513. return(m_pilc->CancelLink(dwLink));
  514. }
  515. WrappedIOleUILinkContainer::WrappedIOleUILinkContainer(IOleUILinkContainerA *pilc)
  516. {
  517. m_pilc = pilc;
  518. m_pilc->AddRef();
  519. m_uRefCount=1;
  520. }
  521. WrappedIOleUILinkContainer::~WrappedIOleUILinkContainer()
  522. {
  523. m_pilc->Release();
  524. }
  525. //+---------------------------------------------------------------------------
  526. //
  527. // Function: OleUIEditLinksA
  528. //
  529. // Synopsis: converts call to ANSI version into call to Unicode version
  530. //
  531. // Arguments: [psA] - ANSI structure
  532. //
  533. // History: 11-04-94 stevebl Created
  534. //
  535. // Notes: Uses the WrappedIOleUILinkContainer interface wrapper.
  536. //
  537. // Structure members converted or passed back out (everything is passed in):
  538. // lpszCaption [in] on stack
  539. // lpszTemplate [in] on stack
  540. // dwFlags [out]
  541. // lpOleUILinkContainer [in] wrapped interface
  542. //
  543. //----------------------------------------------------------------------------
  544. STDAPI_(UINT) OleUIEditLinksA(LPOLEUIEDITLINKSA psA)
  545. {
  546. UINT uRet = UStandardValidation((LPOLEUISTANDARD)psA, sizeof(*psA), NULL);
  547. // If the caller is using a private template, UStandardValidation will
  548. // always return OLEUI_ERR_FINDTEMPLATEFAILURE here. This is because we
  549. // haven't converted the template name to UNICODE yet, so the
  550. // FindResource call in UStandardValidation won't find the caller's
  551. // template. This is OK for two reasons: (1) it's the last thing that
  552. // UStandardValidation checks so by this time it's basically done its
  553. // job, and (2) UStandardValidation will be called again when we forward
  554. // this call on to the Unicode version.
  555. if (OLEUI_SUCCESS != uRet && OLEUI_ERR_FINDTEMPLATEFAILURE != uRet)
  556. return uRet;
  557. uRet = OLEUI_SUCCESS;
  558. // Validate interface.
  559. if (NULL == psA->lpOleUILinkContainer)
  560. {
  561. uRet = OLEUI_ELERR_LINKCNTRNULL;
  562. }
  563. else if(IsBadReadPtr(psA->lpOleUILinkContainer, sizeof(IOleUILinkContainerA)))
  564. {
  565. uRet = OLEUI_ELERR_LINKCNTRINVALID;
  566. }
  567. if (OLEUI_SUCCESS != uRet)
  568. {
  569. return(uRet);
  570. }
  571. OLEUIEDITLINKSW sW;
  572. WCHAR szCaption[MAX_PATH], szTemplate[MAX_PATH];
  573. uRet = OLEUI_ERR_LOCALMEMALLOC;
  574. memcpy(&sW, psA, sizeof(OLEUIEDITLINKSW));
  575. if (psA->lpszCaption)
  576. {
  577. ATOW(szCaption, psA->lpszCaption, MAX_PATH);
  578. sW.lpszCaption = szCaption;
  579. }
  580. if (0 != HIWORD(PtrToUlong(psA->lpszTemplate)))
  581. {
  582. ATOW(szTemplate, psA->lpszTemplate, MAX_PATH);
  583. sW.lpszTemplate = szTemplate;
  584. }
  585. sW.lpOleUILinkContainer = new WrappedIOleUILinkContainer(psA->lpOleUILinkContainer);
  586. if (NULL == sW.lpOleUILinkContainer)
  587. {
  588. return(uRet);
  589. }
  590. uRet = OleUIEditLinksW(&sW);
  591. psA->dwFlags = sW.dwFlags;
  592. sW.lpOleUILinkContainer->Release();
  593. return(uRet);
  594. }
  595. //+---------------------------------------------------------------------------
  596. //
  597. // Function: OleUIChangeIconA
  598. //
  599. // Synopsis: converts call to ANSI version into call to Unicode version
  600. //
  601. // Arguments: [psA] - ANSI structure
  602. //
  603. // History: 11-04-94 stevebl Created
  604. //
  605. // Structure members converted or passed back out (everything is passed in):
  606. // lpszCaption [in] on stack
  607. // lpszTemplate [in] on stack
  608. // szIconExe [in] array embedded in structure
  609. // dwFlags [out]
  610. // hMetaPict [out]
  611. //
  612. //----------------------------------------------------------------------------
  613. STDAPI_(UINT) OleUIChangeIconA(LPOLEUICHANGEICONA psA)
  614. {
  615. UINT uRet = UStandardValidation((LPOLEUISTANDARD)psA, sizeof(*psA), NULL);
  616. // If the caller is using a private template, UStandardValidation will
  617. // always return OLEUI_ERR_FINDTEMPLATEFAILURE here. This is because we
  618. // haven't converted the template name to UNICODE yet, so the
  619. // FindResource call in UStandardValidation won't find the caller's
  620. // template. This is OK for two reasons: (1) it's the last thing that
  621. // UStandardValidation checks so by this time it's basically done its
  622. // job, and (2) UStandardValidation will be called again when we forward
  623. // this call on to the Unicode version.
  624. if (OLEUI_SUCCESS != uRet && OLEUI_ERR_FINDTEMPLATEFAILURE != uRet)
  625. return uRet;
  626. OLEUICHANGEICONW sW;
  627. WCHAR szCaption[MAX_PATH], szTemplate[MAX_PATH];
  628. memcpy(&sW, psA, sizeof(OLEUICHANGEICONA));
  629. sW.cbStruct = sizeof(OLEUICHANGEICONW);
  630. if (psA->lpszCaption)
  631. {
  632. ATOW(szCaption, psA->lpszCaption, MAX_PATH);
  633. sW.lpszCaption = szCaption;
  634. }
  635. if (0 != HIWORD(PtrToUlong(psA->lpszTemplate)))
  636. {
  637. ATOW(szTemplate, psA->lpszTemplate, MAX_PATH);
  638. sW.lpszTemplate = szTemplate;
  639. }
  640. ATOW(sW.szIconExe, psA->szIconExe, MAX_PATH);
  641. sW.cchIconExe = psA->cchIconExe;
  642. uRet = OleUIChangeIconW(&sW);
  643. psA->dwFlags = sW.dwFlags;
  644. psA->hMetaPict = sW.hMetaPict;
  645. return(uRet);
  646. }
  647. //+---------------------------------------------------------------------------
  648. //
  649. // Function: OleUIConvertA
  650. //
  651. // Synopsis: converts a call to ANSI version into call to Unicode version
  652. //
  653. // Arguments: [psA] - ANSI structure
  654. //
  655. // History: 11-04-94 stevebl Created
  656. //
  657. // Structure members converted or passed back out (everything is passed in):
  658. // lpszCaption [in] on stack
  659. // lpszTemplate [in] on stack
  660. // lpszUserType [in] on heap
  661. // [out] always freed and returned as NULL
  662. // lpszDefLabel [in] on heap
  663. // lpszDefLabel [out] always freed and returned as NULL
  664. // dwFlags [out]
  665. // clsidNew [out]
  666. // dvAspect [out]
  667. // hMetaPict [out]
  668. //
  669. //----------------------------------------------------------------------------
  670. STDAPI_(UINT) OleUIConvertA(LPOLEUICONVERTA psA)
  671. {
  672. UINT uRet = UStandardValidation((LPOLEUISTANDARD)psA, sizeof(*psA), NULL);
  673. // If the caller is using a private template, UStandardValidation will
  674. // always return OLEUI_ERR_FINDTEMPLATEFAILURE here. This is because we
  675. // haven't converted the template name to UNICODE yet, so the
  676. // FindResource call in UStandardValidation won't find the caller's
  677. // template. This is OK for two reasons: (1) it's the last thing that
  678. // UStandardValidation checks so by this time it's basically done its
  679. // job, and (2) UStandardValidation will be called again when we forward
  680. // this call on to the Unicode version.
  681. if (OLEUI_SUCCESS != uRet && OLEUI_ERR_FINDTEMPLATEFAILURE != uRet)
  682. return uRet;
  683. if ((NULL != psA->lpszUserType)
  684. && (IsBadReadPtr(psA->lpszUserType, 1)))
  685. return(OLEUI_CTERR_STRINGINVALID);
  686. if ( (NULL != psA->lpszDefLabel)
  687. && (IsBadReadPtr(psA->lpszDefLabel, 1)) )
  688. return(OLEUI_CTERR_STRINGINVALID);
  689. OLEUICONVERTW sW;
  690. WCHAR szCaption[MAX_PATH], szTemplate[MAX_PATH];
  691. uRet = OLEUI_ERR_LOCALMEMALLOC;
  692. memcpy(&sW, psA, sizeof(OLEUICONVERTW));
  693. if (psA->lpszCaption)
  694. {
  695. ATOW(szCaption, psA->lpszCaption, MAX_PATH);
  696. sW.lpszCaption = szCaption;
  697. }
  698. if (0 != HIWORD(PtrToUlong(psA->lpszTemplate)))
  699. {
  700. ATOW(szTemplate, psA->lpszTemplate, MAX_PATH);
  701. sW.lpszTemplate = szTemplate;
  702. }
  703. sW.lpszUserType = sW.lpszDefLabel = NULL;
  704. if (psA->lpszUserType)
  705. {
  706. UINT uLen = ATOWLEN(psA->lpszUserType);
  707. sW.lpszUserType = (LPWSTR)OleStdMalloc(uLen * sizeof(WCHAR));
  708. if (!sW.lpszUserType)
  709. {
  710. goto oom_error;
  711. }
  712. ATOW(sW.lpszUserType, psA->lpszUserType, uLen);
  713. }
  714. if (psA->lpszDefLabel)
  715. {
  716. UINT uLen = ATOWLEN(psA->lpszDefLabel);
  717. sW.lpszDefLabel = (LPWSTR)OleStdMalloc(uLen * sizeof(WCHAR));
  718. if (!sW.lpszDefLabel)
  719. {
  720. goto oom_error;
  721. }
  722. ATOW(sW.lpszDefLabel, psA->lpszDefLabel, uLen);
  723. }
  724. uRet = OleUIConvertW(&sW);
  725. psA->dwFlags = sW.dwFlags;
  726. memcpy(&psA->clsidNew, &sW.clsidNew, sizeof(CLSID));
  727. psA->dvAspect = sW.dvAspect;
  728. psA->hMetaPict = sW.hMetaPict;
  729. psA->fObjectsIconChanged = sW.fObjectsIconChanged;
  730. oom_error:
  731. if (sW.lpszUserType)
  732. {
  733. OleStdFree((LPVOID)sW.lpszUserType);
  734. }
  735. if (sW.lpszDefLabel)
  736. {
  737. OleStdFree((LPVOID)sW.lpszDefLabel);
  738. }
  739. if (psA->lpszUserType)
  740. {
  741. OleStdFree((LPVOID)psA->lpszUserType);
  742. psA->lpszUserType = NULL;
  743. }
  744. if (psA->lpszDefLabel)
  745. {
  746. OleStdFree((LPVOID)psA->lpszDefLabel);
  747. psA->lpszDefLabel = NULL;
  748. }
  749. return(uRet);
  750. }
  751. //+---------------------------------------------------------------------------
  752. //
  753. // Function: OleUIBusyA
  754. //
  755. // Synopsis: converts call to ANSI version into call to Unicode version
  756. //
  757. // Arguments: [psA] - ANSI structure
  758. //
  759. // History: 11-04-94 stevebl Created
  760. //
  761. // Structure members converted or passed back out (everything is passed in):
  762. // lpszCaption [in] on stack
  763. // lpszTemplate [in] on stack
  764. // dwFlags [out]
  765. //
  766. //----------------------------------------------------------------------------
  767. STDAPI_(UINT) OleUIBusyA(LPOLEUIBUSYA psA)
  768. {
  769. UINT uRet = UStandardValidation((LPOLEUISTANDARD)psA, sizeof(*psA), NULL);
  770. // If the caller is using a private template, UStandardValidation will
  771. // always return OLEUI_ERR_FINDTEMPLATEFAILURE here. This is because we
  772. // haven't converted the template name to UNICODE yet, so the
  773. // FindResource call in UStandardValidation won't find the caller's
  774. // template. This is OK for two reasons: (1) it's the last thing that
  775. // UStandardValidation checks so by this time it's basically done its
  776. // job, and (2) UStandardValidation will be called again when we forward
  777. // this call on to the Unicode version.
  778. if (OLEUI_SUCCESS != uRet && OLEUI_ERR_FINDTEMPLATEFAILURE != uRet)
  779. return uRet;
  780. OLEUIBUSYW sW;
  781. WCHAR szCaption[MAX_PATH], szTemplate[MAX_PATH];
  782. memcpy(&sW, psA, sizeof(OLEUIBUSYW));
  783. if (psA->lpszCaption)
  784. {
  785. ATOW(szCaption, psA->lpszCaption, MAX_PATH);
  786. sW.lpszCaption = szCaption;
  787. }
  788. if (0 != HIWORD(PtrToUlong(psA->lpszTemplate)))
  789. {
  790. ATOW(szTemplate, psA->lpszTemplate, MAX_PATH);
  791. sW.lpszTemplate = szTemplate;
  792. }
  793. uRet = OleUIBusyW(&sW);
  794. psA->dwFlags = sW.dwFlags;
  795. return(uRet);
  796. }
  797. //+---------------------------------------------------------------------------
  798. //
  799. // Function: OleUIUpdateLinksA
  800. //
  801. // Synopsis: converts call to ANSI version into call to Unicode version
  802. //
  803. // Arguments: [lpOleUILinkCntr] - [in] wrapped with Unicode version
  804. // [hwndParent] -
  805. // [lpszTitle] - [in] on stack
  806. // [cLinks] -
  807. //
  808. // History: 11-04-94 stevebl Created
  809. //
  810. //----------------------------------------------------------------------------
  811. STDAPI_(BOOL) OleUIUpdateLinksA(LPOLEUILINKCONTAINERA lpOleUILinkCntr,
  812. HWND hwndParent, LPSTR lpszTitle, int cLinks)
  813. {
  814. WrappedIOleUILinkContainer * lpWrappedOleUILinkCntr = NULL;
  815. if (NULL != lpszTitle && IsBadReadPtr(lpszTitle, 1))
  816. return(FALSE);
  817. if (NULL == lpOleUILinkCntr || IsBadReadPtr(lpOleUILinkCntr, sizeof(IOleUILinkContainerA)))
  818. return(FALSE);
  819. lpWrappedOleUILinkCntr = new WrappedIOleUILinkContainer(lpOleUILinkCntr);
  820. if (NULL == lpWrappedOleUILinkCntr)
  821. return(FALSE); // ran out of memory
  822. WCHAR wszTitle[MAX_PATH];
  823. WCHAR *lpwszTitle;
  824. if (lpszTitle)
  825. {
  826. ATOW(wszTitle, lpszTitle, MAX_PATH);
  827. lpwszTitle = wszTitle;
  828. }
  829. else
  830. lpwszTitle = NULL;
  831. BOOL fReturn = OleUIUpdateLinksW(lpWrappedOleUILinkCntr, hwndParent, lpwszTitle, cLinks);
  832. lpWrappedOleUILinkCntr->Release();
  833. return(fReturn);
  834. }
  835. //+---------------------------------------------------------------------------
  836. //
  837. // Class: WrappedIOleUIObjInfo
  838. //
  839. // Purpose: Wraps IOleUIObjInfoA with IOleUIObjInfoW methods
  840. // so it can be passed on to Unicode methods within OLE2UI32.
  841. //
  842. // Interface: QueryInterface --
  843. // AddRef --
  844. // Release --
  845. // GetObjectInfo -- requires string conversion
  846. // GetConvertInfo --
  847. // ConvertObject --
  848. // GetViewInfo --
  849. // SetViewInfo --
  850. // WrappedIOleUIObjInfo -- constructor
  851. // ~WrappedIOleUIObjInfo -- destructor
  852. //
  853. // History: 11-08-94 stevebl Created
  854. //
  855. // Notes: This is a private interface wrapper. QueryInterface is not
  856. // supported and the wrapped interface may not be used outside
  857. // of the OLE2UI32 code.
  858. //
  859. //----------------------------------------------------------------------------
  860. class WrappedIOleUIObjInfo: public IOleUIObjInfoW
  861. {
  862. public:
  863. // *** IUnknown methods *** //
  864. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj);
  865. STDMETHOD_(ULONG,AddRef) (THIS);
  866. STDMETHOD_(ULONG,Release) (THIS);
  867. // *** extra for General Properties *** //
  868. STDMETHOD(GetObjectInfo) (THIS_ DWORD dwObject,
  869. DWORD FAR* lpdwObjSize, LPWSTR FAR* lplpszLabel,
  870. LPWSTR FAR* lplpszType, LPWSTR FAR* lplpszShortType,
  871. LPWSTR FAR* lplpszLocation);
  872. STDMETHOD(GetConvertInfo) (THIS_ DWORD dwObject,
  873. CLSID FAR* lpClassID, WORD FAR* lpwFormat,
  874. CLSID FAR* lpConvertDefaultClassID,
  875. LPCLSID FAR* lplpClsidExclude, UINT FAR* lpcClsidExclude);
  876. STDMETHOD(ConvertObject) (THIS_ DWORD dwObject, REFCLSID clsidNew);
  877. // *** extra for View Properties *** //
  878. STDMETHOD(GetViewInfo) (THIS_ DWORD dwObject,
  879. HGLOBAL FAR* phMetaPict, DWORD* pdvAspect, int* pnCurrentScale);
  880. STDMETHOD(SetViewInfo) (THIS_ DWORD dwObject,
  881. HGLOBAL hMetaPict, DWORD dvAspect,
  882. int nCurrentScale, BOOL bRelativeToOrig);
  883. // *** Constructor and Destructor *** //
  884. WrappedIOleUIObjInfo(IOleUIObjInfoA * pioi);
  885. ~WrappedIOleUIObjInfo();
  886. private:
  887. IOleUIObjInfoA * m_pioi;
  888. ULONG m_uRefCount;
  889. };
  890. // *** IUnknown methods *** //
  891. HRESULT STDMETHODCALLTYPE WrappedIOleUIObjInfo::QueryInterface(THIS_ REFIID riid, LPVOID FAR* ppvObj)
  892. {
  893. return(E_NOTIMPL);
  894. }
  895. ULONG STDMETHODCALLTYPE WrappedIOleUIObjInfo::AddRef()
  896. {
  897. return(m_uRefCount++);
  898. }
  899. ULONG STDMETHODCALLTYPE WrappedIOleUIObjInfo::Release()
  900. {
  901. ULONG uRet = --m_uRefCount;
  902. if (0 == uRet)
  903. {
  904. delete(this);
  905. }
  906. return(uRet);
  907. }
  908. //+---------------------------------------------------------------------------
  909. //
  910. // Member: WrappedIOleUIObjInfo::GetObjectInfo
  911. //
  912. // Synopsis: forwards Unicode method call on to the ANSI version
  913. //
  914. // Arguments: [dwObject] -
  915. // [lpdwObjSize] -
  916. // [lplpszLabel] - [out] converted on heap
  917. // [lplpszType] - [out] converted on heap
  918. // [lplpszShortType] - [out] converted on heap
  919. // [lplpszLocation] - [out] converted on heap
  920. //
  921. // History: 11-09-94 stevebl Created
  922. //
  923. //----------------------------------------------------------------------------
  924. HRESULT STDMETHODCALLTYPE WrappedIOleUIObjInfo::GetObjectInfo(DWORD dwObject,
  925. DWORD FAR* lpdwObjSize, LPWSTR FAR* lplpszLabel,
  926. LPWSTR FAR* lplpszType, LPWSTR FAR* lplpszShortType,
  927. LPWSTR FAR* lplpszLocation)
  928. {
  929. LPSTR lpszLabel = NULL;
  930. LPSTR lpszType = NULL;
  931. LPSTR lpszShortType = NULL;
  932. LPSTR lpszLocation = NULL;
  933. LPSTR * lplpszLabelA = NULL;
  934. LPSTR * lplpszTypeA = NULL;
  935. LPSTR * lplpszShortTypeA = NULL;
  936. LPSTR * lplpszLocationA = NULL;
  937. if (lplpszLabel)
  938. {
  939. lplpszLabelA = &lpszLabel;
  940. }
  941. if (lplpszType)
  942. {
  943. lplpszTypeA = &lpszType;
  944. }
  945. if (lplpszShortType)
  946. {
  947. lplpszShortTypeA = &lpszShortType;
  948. }
  949. if (lplpszLocation)
  950. {
  951. lplpszLocationA = &lpszLocation;
  952. }
  953. HRESULT hrReturn = m_pioi->GetObjectInfo(dwObject,
  954. lpdwObjSize,
  955. lplpszLabelA,
  956. lplpszTypeA,
  957. lplpszShortTypeA,
  958. lplpszLocationA);
  959. if (lplpszLabel)
  960. {
  961. *lplpszLabel = NULL;
  962. if (lpszLabel)
  963. {
  964. UINT uLen = ATOWLEN(lpszLabel);
  965. *lplpszLabel = (LPWSTR)OleStdMalloc(uLen * sizeof(WCHAR));
  966. if (*lplpszLabel)
  967. {
  968. ATOW(*lplpszLabel, lpszLabel, uLen);
  969. }
  970. else
  971. hrReturn = E_OUTOFMEMORY;
  972. OleStdFree((LPVOID)lpszLabel);
  973. }
  974. }
  975. if (lplpszType)
  976. {
  977. *lplpszType = NULL;
  978. if (lpszType)
  979. {
  980. UINT uLen = ATOWLEN(lpszType);
  981. *lplpszType = (LPWSTR)OleStdMalloc(uLen * sizeof(WCHAR));
  982. if (*lplpszType)
  983. {
  984. ATOW(*lplpszType, lpszType, uLen);
  985. }
  986. else
  987. hrReturn = E_OUTOFMEMORY;
  988. OleStdFree((LPVOID)lpszType);
  989. }
  990. }
  991. if (lplpszShortType)
  992. {
  993. *lplpszShortType = NULL;
  994. if (lpszShortType)
  995. {
  996. UINT uLen = ATOWLEN(lpszShortType);
  997. *lplpszShortType = (LPWSTR)OleStdMalloc(uLen * sizeof(WCHAR));
  998. if (*lplpszShortType)
  999. {
  1000. ATOW(*lplpszShortType, lpszShortType, uLen);
  1001. }
  1002. else
  1003. hrReturn = E_OUTOFMEMORY;
  1004. OleStdFree((LPVOID)lpszShortType);
  1005. }
  1006. }
  1007. if (lplpszLocation)
  1008. {
  1009. *lplpszLocation = NULL;
  1010. if (lpszLocation)
  1011. {
  1012. UINT uLen = ATOWLEN(lpszLocation);
  1013. *lplpszLocation = (LPWSTR)OleStdMalloc(uLen * sizeof(WCHAR));
  1014. if (*lplpszLocation)
  1015. {
  1016. ATOW(*lplpszLocation, lpszLocation, uLen);
  1017. }
  1018. else
  1019. hrReturn = E_OUTOFMEMORY;
  1020. OleStdFree((LPVOID)lpszLocation);
  1021. }
  1022. }
  1023. return(hrReturn);
  1024. }
  1025. HRESULT STDMETHODCALLTYPE WrappedIOleUIObjInfo::GetConvertInfo(DWORD dwObject,
  1026. CLSID FAR* lpClassID, WORD FAR* lpwFormat,
  1027. CLSID FAR* lpConvertDefaultClassID,
  1028. LPCLSID FAR* lplpClsidExclude, UINT FAR* lpcClsidExclude)
  1029. {
  1030. return(m_pioi->GetConvertInfo(dwObject,
  1031. lpClassID,
  1032. lpwFormat,
  1033. lpConvertDefaultClassID,
  1034. lplpClsidExclude,
  1035. lpcClsidExclude));
  1036. }
  1037. HRESULT STDMETHODCALLTYPE WrappedIOleUIObjInfo::ConvertObject(DWORD dwObject, REFCLSID clsidNew)
  1038. {
  1039. return(m_pioi->ConvertObject(dwObject, clsidNew));
  1040. }
  1041. HRESULT STDMETHODCALLTYPE WrappedIOleUIObjInfo::GetViewInfo(DWORD dwObject,
  1042. HGLOBAL FAR* phMetaPict, DWORD* pdvAspect, int* pnCurrentScale)
  1043. {
  1044. return(m_pioi->GetViewInfo(dwObject, phMetaPict, pdvAspect, pnCurrentScale));
  1045. }
  1046. HRESULT STDMETHODCALLTYPE WrappedIOleUIObjInfo::SetViewInfo(DWORD dwObject,
  1047. HGLOBAL hMetaPict, DWORD dvAspect,
  1048. int nCurrentScale, BOOL bRelativeToOrig)
  1049. {
  1050. return(m_pioi->SetViewInfo(dwObject, hMetaPict, dvAspect, nCurrentScale, bRelativeToOrig));
  1051. }
  1052. WrappedIOleUIObjInfo::WrappedIOleUIObjInfo(IOleUIObjInfoA *pioi)
  1053. {
  1054. m_pioi = pioi;
  1055. m_pioi->AddRef();
  1056. m_uRefCount=1;
  1057. }
  1058. WrappedIOleUIObjInfo::~WrappedIOleUIObjInfo()
  1059. {
  1060. m_pioi->Release();
  1061. }
  1062. //+---------------------------------------------------------------------------
  1063. //
  1064. // Class: WrappedIOleUILinkInfo
  1065. //
  1066. // Purpose: Wraps IOleUILinkInfoA with IOleUILinkInfoW methods
  1067. // so it can be passed on to Unicode methods within OLE2UI32.
  1068. //
  1069. // Interface: QueryInterface --
  1070. // AddRef --
  1071. // Release --
  1072. // GetNextLink --
  1073. // SetLinkUpdateOptions --
  1074. // GetLinkUpdateOptions --
  1075. // SetLinkSource -- requires string conversion
  1076. // GetLinkSource -- requires string conversion
  1077. // OpenLinkSource --
  1078. // UpdateLink --
  1079. // CancelLink --
  1080. // GetLastUpdate --
  1081. // WrappedIOleUILinkInfo -- constructor
  1082. // ~WrappedIOleUILinkInfo -- destructor
  1083. //
  1084. // History: 11-08-94 stevebl Created
  1085. //
  1086. // Notes: This is a private interface wrapper. QueryInterface is not
  1087. // supported and the wrapped interface may not be used outside
  1088. // of the OLE2UI32 code.
  1089. //
  1090. //----------------------------------------------------------------------------
  1091. class WrappedIOleUILinkInfo: public IOleUILinkInfoW
  1092. {
  1093. public:
  1094. // *** IUnknown methods *** //
  1095. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj);
  1096. STDMETHOD_(ULONG,AddRef) (THIS);
  1097. STDMETHOD_(ULONG,Release) (THIS);
  1098. // *** IOleUILinkContainer *** //
  1099. STDMETHOD_(DWORD,GetNextLink) (THIS_ DWORD dwLink);
  1100. STDMETHOD(SetLinkUpdateOptions) (THIS_ DWORD dwLink,
  1101. DWORD dwUpdateOpt);
  1102. STDMETHOD(GetLinkUpdateOptions) (THIS_ DWORD dwLink,
  1103. DWORD FAR* lpdwUpdateOpt);
  1104. STDMETHOD(SetLinkSource) (THIS_ DWORD dwLink, LPWSTR lpszDisplayName,
  1105. ULONG lenFileName, ULONG FAR* pchEaten, BOOL fValidateSource);
  1106. STDMETHOD(GetLinkSource) (THIS_ DWORD dwLink,
  1107. LPWSTR FAR* lplpszDisplayName, ULONG FAR* lplenFileName,
  1108. LPWSTR FAR* lplpszFullLinkType, LPWSTR FAR* lplpszShortLinkType,
  1109. BOOL FAR* lpfSourceAvailable, BOOL FAR* lpfIsSelected);
  1110. STDMETHOD(OpenLinkSource) (THIS_ DWORD dwLink);
  1111. STDMETHOD(UpdateLink) (THIS_ DWORD dwLink,
  1112. BOOL fErrorMessage, BOOL fErrorAction);
  1113. STDMETHOD(CancelLink) (THIS_ DWORD dwLink);
  1114. // *** extra for Link Properties ***//
  1115. STDMETHOD(GetLastUpdate) (THIS_ DWORD dwLink,
  1116. FILETIME FAR* lpLastUpdate);
  1117. // *** Constructor and Destructor *** //
  1118. WrappedIOleUILinkInfo(IOleUILinkInfoA *pili);
  1119. ~WrappedIOleUILinkInfo();
  1120. private:
  1121. IOleUILinkInfoA * m_pili;
  1122. ULONG m_uRefCount;
  1123. };
  1124. // *** IUnknown methods *** //
  1125. HRESULT STDMETHODCALLTYPE WrappedIOleUILinkInfo::QueryInterface(THIS_ REFIID riid, LPVOID FAR* ppvObj)
  1126. {
  1127. return(E_NOTIMPL);
  1128. }
  1129. ULONG STDMETHODCALLTYPE WrappedIOleUILinkInfo::AddRef()
  1130. {
  1131. return(m_uRefCount++);
  1132. }
  1133. ULONG STDMETHODCALLTYPE WrappedIOleUILinkInfo::Release()
  1134. {
  1135. ULONG uRet = --m_uRefCount;
  1136. if (0 == uRet)
  1137. {
  1138. delete(this);
  1139. }
  1140. return(uRet);
  1141. }
  1142. // *** IOleUILinkInfo *** //
  1143. DWORD STDMETHODCALLTYPE WrappedIOleUILinkInfo::GetNextLink(DWORD dwLink)
  1144. {
  1145. return(m_pili->GetNextLink(dwLink));
  1146. }
  1147. HRESULT STDMETHODCALLTYPE WrappedIOleUILinkInfo::SetLinkUpdateOptions (DWORD dwLink,
  1148. DWORD dwUpdateOpt)
  1149. {
  1150. return(m_pili->SetLinkUpdateOptions(dwLink, dwUpdateOpt));
  1151. }
  1152. HRESULT STDMETHODCALLTYPE WrappedIOleUILinkInfo::GetLinkUpdateOptions (DWORD dwLink,
  1153. DWORD FAR* lpdwUpdateOpt)
  1154. {
  1155. return(m_pili->GetLinkUpdateOptions(dwLink, lpdwUpdateOpt));
  1156. }
  1157. //+---------------------------------------------------------------------------
  1158. //
  1159. // Member: WrappedIOleUILinkInfo::SetLinkSource
  1160. //
  1161. // Synopsis: forwards Unicode method call on to the ANSI version
  1162. //
  1163. // Arguments: [dwLink] -
  1164. // [lpszDisplayName] - [in] converted on stack
  1165. // [lenFileName] -
  1166. // [pchEaten] -
  1167. // [fValidateSource] -
  1168. //
  1169. // History: 11-04-94 stevebl Created
  1170. //
  1171. //----------------------------------------------------------------------------
  1172. HRESULT STDMETHODCALLTYPE WrappedIOleUILinkInfo::SetLinkSource (DWORD dwLink, LPWSTR lpszDisplayName,
  1173. ULONG lenFileName, ULONG FAR* pchEaten, BOOL fValidateSource)
  1174. {
  1175. char szDisplayName[MAX_PATH];
  1176. char * lpszDisplayNameA;
  1177. if (lpszDisplayName)
  1178. {
  1179. WTOA(szDisplayName, lpszDisplayName, MAX_PATH);
  1180. lpszDisplayNameA = szDisplayName;
  1181. }
  1182. else
  1183. lpszDisplayNameA = NULL;
  1184. return(m_pili->SetLinkSource(dwLink, lpszDisplayNameA, lenFileName, pchEaten, fValidateSource));
  1185. }
  1186. //+---------------------------------------------------------------------------
  1187. //
  1188. // Member: WrappedIOleUILinkInfo::GetLinkSource
  1189. //
  1190. // Synopsis: forwards Unicode method call on to the ANSI version
  1191. //
  1192. // Arguments: [dwLink] -
  1193. // [lplpszDisplayName] - [out] converted on heap
  1194. // [lplenFileName] -
  1195. // [lplpszFullLinkType] - [out] converted on heap
  1196. // [lplpszShortLinkType] - [out] converted on heap
  1197. // [lpfSourceAvailable] -
  1198. // [lpfIsSelected] -
  1199. //
  1200. // History: 11-04-94 stevebl Created
  1201. //
  1202. //----------------------------------------------------------------------------
  1203. HRESULT STDMETHODCALLTYPE WrappedIOleUILinkInfo::GetLinkSource (DWORD dwLink,
  1204. LPWSTR FAR* lplpszDisplayName, ULONG FAR* lplenFileName,
  1205. LPWSTR FAR* lplpszFullLinkType, LPWSTR FAR* lplpszShortLinkType,
  1206. BOOL FAR* lpfSourceAvailable, BOOL FAR* lpfIsSelected)
  1207. {
  1208. LPSTR lpszDisplayName = NULL;
  1209. LPSTR lpszFullLinkType = NULL;
  1210. LPSTR lpszShortLinkType = NULL;
  1211. LPSTR * lplpszDisplayNameA = NULL;
  1212. LPSTR * lplpszFullLinkTypeA = NULL;
  1213. LPSTR * lplpszShortLinkTypeA = NULL;
  1214. if (lplpszDisplayName)
  1215. {
  1216. lplpszDisplayNameA = &lpszDisplayName;
  1217. }
  1218. if (lplpszFullLinkType)
  1219. {
  1220. lplpszFullLinkTypeA = &lpszFullLinkType;
  1221. }
  1222. if (lplpszShortLinkType)
  1223. {
  1224. lplpszShortLinkTypeA = &lpszShortLinkType;
  1225. }
  1226. HRESULT hrReturn = m_pili->GetLinkSource(dwLink,
  1227. lplpszDisplayNameA,
  1228. lplenFileName,
  1229. lplpszFullLinkTypeA,
  1230. lplpszShortLinkTypeA,
  1231. lpfSourceAvailable,
  1232. lpfIsSelected);
  1233. if (lplpszDisplayName)
  1234. {
  1235. *lplpszDisplayName = NULL;
  1236. if (lpszDisplayName)
  1237. {
  1238. UINT uLen = ATOWLEN(lpszDisplayName);
  1239. *lplpszDisplayName = (LPWSTR)OleStdMalloc(uLen * sizeof(WCHAR));
  1240. if (*lplpszDisplayName)
  1241. {
  1242. ATOW(*lplpszDisplayName, lpszDisplayName, uLen);
  1243. }
  1244. else
  1245. hrReturn = E_OUTOFMEMORY;
  1246. OleStdFree((LPVOID)lpszDisplayName);
  1247. }
  1248. }
  1249. if (lplpszFullLinkType)
  1250. {
  1251. *lplpszFullLinkType = NULL;
  1252. if (lpszFullLinkType)
  1253. {
  1254. UINT uLen = ATOWLEN(lpszFullLinkType);
  1255. *lplpszFullLinkType = (LPWSTR)OleStdMalloc(uLen * sizeof(WCHAR));
  1256. if (*lplpszFullLinkType)
  1257. {
  1258. ATOW(*lplpszFullLinkType, lpszFullLinkType, uLen);
  1259. }
  1260. else
  1261. hrReturn = E_OUTOFMEMORY;
  1262. OleStdFree((LPVOID)lpszFullLinkType);
  1263. }
  1264. }
  1265. if (lplpszShortLinkType)
  1266. {
  1267. *lplpszShortLinkType = NULL;
  1268. if (lpszShortLinkType)
  1269. {
  1270. UINT uLen = ATOWLEN(lpszShortLinkType);
  1271. *lplpszShortLinkType = (LPWSTR)OleStdMalloc(uLen * sizeof(WCHAR));
  1272. if (*lplpszShortLinkType)
  1273. {
  1274. ATOW(*lplpszShortLinkType, lpszShortLinkType, uLen);
  1275. }
  1276. else
  1277. hrReturn = E_OUTOFMEMORY;
  1278. OleStdFree((LPVOID)lpszShortLinkType);
  1279. }
  1280. }
  1281. return(hrReturn);
  1282. }
  1283. HRESULT STDMETHODCALLTYPE WrappedIOleUILinkInfo::OpenLinkSource (DWORD dwLink)
  1284. {
  1285. return(m_pili->OpenLinkSource(dwLink));
  1286. }
  1287. HRESULT STDMETHODCALLTYPE WrappedIOleUILinkInfo::UpdateLink (DWORD dwLink,
  1288. BOOL fErrorMessage, BOOL fErrorAction)
  1289. {
  1290. return(m_pili->UpdateLink(dwLink, fErrorMessage, fErrorAction));
  1291. }
  1292. HRESULT STDMETHODCALLTYPE WrappedIOleUILinkInfo::CancelLink (DWORD dwLink)
  1293. {
  1294. return(m_pili->CancelLink(dwLink));
  1295. }
  1296. HRESULT STDMETHODCALLTYPE WrappedIOleUILinkInfo::GetLastUpdate (DWORD dwLink,
  1297. FILETIME FAR* lpLastUpdate)
  1298. {
  1299. return(m_pili->GetLastUpdate(dwLink, lpLastUpdate));
  1300. }
  1301. WrappedIOleUILinkInfo::WrappedIOleUILinkInfo(IOleUILinkInfoA *pili)
  1302. {
  1303. m_pili = pili;
  1304. m_pili->AddRef();
  1305. m_uRefCount=1;
  1306. }
  1307. WrappedIOleUILinkInfo::~WrappedIOleUILinkInfo()
  1308. {
  1309. m_pili->Release();
  1310. }
  1311. //+---------------------------------------------------------------------------
  1312. //
  1313. // Function: OleUIObjectPropertiesA
  1314. //
  1315. // Synopsis: converts call to ANSI version into call to Unicode version
  1316. //
  1317. // Arguments: [psA] - ANSI structure
  1318. //
  1319. // History: 11-04-94 stevebl Created
  1320. //
  1321. // Structure members converted or passed back out (everything is passed in):
  1322. // lpPS [in]
  1323. // lpObjInfo [in] wrapped with Unicode interface
  1324. // lpLinkInfo [in] wrapped with Unicode interface
  1325. // lpGP [in] (no data conversion, only type conversion)
  1326. // lpVP [in] (no data conversion, only type conversion)
  1327. // lpLP [in] (no data conversion, only type conversion)
  1328. //
  1329. // dwFlags [out]
  1330. //
  1331. //----------------------------------------------------------------------------
  1332. STDAPI_(UINT) OleUIObjectPropertiesA(LPOLEUIOBJECTPROPSA psA)
  1333. {
  1334. if (NULL == psA)
  1335. {
  1336. return(OLEUI_ERR_STRUCTURENULL);
  1337. }
  1338. if (IsBadWritePtr(psA, sizeof(OLEUIOBJECTPROPSA)))
  1339. return OLEUI_ERR_STRUCTUREINVALID;
  1340. LPOLEUIOBJECTPROPSW psW;
  1341. UINT uRet = OLEUI_ERR_LOCALMEMALLOC;
  1342. if (NULL == psA->lpObjInfo)
  1343. {
  1344. return(OLEUI_OPERR_OBJINFOINVALID);
  1345. }
  1346. if (IsBadReadPtr(psA->lpObjInfo, sizeof(IOleUIObjInfoA)))
  1347. {
  1348. return(OLEUI_OPERR_OBJINFOINVALID);
  1349. }
  1350. if (psA->dwFlags & OPF_OBJECTISLINK)
  1351. {
  1352. if (NULL == psA->lpLinkInfo)
  1353. {
  1354. return(OLEUI_OPERR_LINKINFOINVALID);
  1355. }
  1356. if (IsBadReadPtr(psA->lpLinkInfo, sizeof(IOleUILinkInfoA)))
  1357. {
  1358. return(OLEUI_OPERR_LINKINFOINVALID);
  1359. }
  1360. }
  1361. BOOL fWrappedIOleUILinkInfo = FALSE;
  1362. psW = (LPOLEUIOBJECTPROPSW) OleStdMalloc(sizeof(OLEUIOBJECTPROPSW));
  1363. if (NULL != psW)
  1364. {
  1365. memcpy(psW, psA, sizeof(OLEUIOBJECTPROPSW));
  1366. psW->lpObjInfo = new WrappedIOleUIObjInfo(psA->lpObjInfo);
  1367. if (NULL == psW->lpObjInfo)
  1368. {
  1369. OleStdFree(psW);
  1370. return(uRet);
  1371. }
  1372. if (psW->dwFlags & OPF_OBJECTISLINK)
  1373. {
  1374. psW->lpLinkInfo = new WrappedIOleUILinkInfo(psA->lpLinkInfo);
  1375. if (NULL == psW->lpLinkInfo)
  1376. {
  1377. psW->lpObjInfo->Release();
  1378. OleStdFree(psW);
  1379. return(uRet);
  1380. }
  1381. fWrappedIOleUILinkInfo = TRUE;
  1382. }
  1383. uRet = InternalObjectProperties(psW, FALSE);
  1384. psA->dwFlags = psW->dwFlags;
  1385. psW->lpObjInfo->Release();
  1386. if (fWrappedIOleUILinkInfo)
  1387. {
  1388. psW->lpLinkInfo->Release();
  1389. }
  1390. OleStdFree(psW);
  1391. }
  1392. return(uRet);
  1393. }
  1394. //+---------------------------------------------------------------------------
  1395. //
  1396. // Function: OleUIChangeSourceA
  1397. //
  1398. // Synopsis: converts call to ANSI version into call to Unicode version
  1399. //
  1400. // Arguments: [psA] - ANSI structure
  1401. //
  1402. // History: 11-04-94 stevebl Created
  1403. //
  1404. // Structure members converted or passed back out (everything is passed in):
  1405. // lpszCaption [in] on stack
  1406. // lpszTemplate [in] on stack
  1407. // lpszDisplayName [in, out] on heap
  1408. // lpszFrom [out] on heap
  1409. // lpszTo [out] on heap
  1410. // lpOleUILinkContainer [in] wrapped interface
  1411. // dwFlags [out]
  1412. // nFileLength [out]
  1413. //
  1414. //----------------------------------------------------------------------------
  1415. STDAPI_(UINT) OleUIChangeSourceA(LPOLEUICHANGESOURCEA psA)
  1416. {
  1417. UINT uRet = UStandardValidation((LPOLEUISTANDARD)psA, sizeof(*psA), NULL);
  1418. // If the caller is using a private template, UStandardValidation will
  1419. // always return OLEUI_ERR_FINDTEMPLATEFAILURE here. This is because we
  1420. // haven't converted the template name to UNICODE yet, so the
  1421. // FindResource call in UStandardValidation won't find the caller's
  1422. // template. This is OK for two reasons: (1) it's the last thing that
  1423. // UStandardValidation checks so by this time it's basically done its
  1424. // job, and (2) UStandardValidation will be called again when we forward
  1425. // this call on to the Unicode version.
  1426. if (OLEUI_SUCCESS != uRet && OLEUI_ERR_FINDTEMPLATEFAILURE != uRet)
  1427. return uRet;
  1428. // lpszFrom and lpszTo must be NULL (they are out only)
  1429. if (psA->lpszFrom != NULL)
  1430. {
  1431. return(OLEUI_CSERR_FROMNOTNULL);
  1432. }
  1433. if (psA->lpszTo != NULL)
  1434. {
  1435. return(OLEUI_CSERR_TONOTNULL);
  1436. }
  1437. // lpszDisplayName must be valid or NULL
  1438. if (psA->lpszDisplayName != NULL &&
  1439. IsBadReadPtr(psA->lpszDisplayName, 1))
  1440. {
  1441. return(OLEUI_CSERR_SOURCEINVALID);
  1442. }
  1443. OLEUICHANGESOURCEW sW;
  1444. WCHAR szCaption[MAX_PATH], szTemplate[MAX_PATH];
  1445. uRet = OLEUI_ERR_LOCALMEMALLOC;
  1446. memcpy(&sW, psA, sizeof(OLEUICHANGESOURCEW));
  1447. if (psA->lpszCaption != NULL)
  1448. {
  1449. ATOW(szCaption, psA->lpszCaption, MAX_PATH);
  1450. sW.lpszCaption = szCaption;
  1451. }
  1452. if (0 != HIWORD(PtrToUlong(psA->lpszTemplate)))
  1453. {
  1454. ATOW(szTemplate, psA->lpszTemplate, MAX_PATH);
  1455. sW.lpszTemplate = szTemplate;
  1456. }
  1457. if (psA->lpszDisplayName)
  1458. {
  1459. UINT uLen = ATOWLEN(psA->lpszDisplayName);
  1460. sW.lpszDisplayName = (LPWSTR)OleStdMalloc(uLen * sizeof(WCHAR));
  1461. if (!sW.lpszDisplayName)
  1462. {
  1463. return(uRet);
  1464. }
  1465. ATOW(sW.lpszDisplayName, psA->lpszDisplayName, uLen);
  1466. }
  1467. if (NULL != psA->lpOleUILinkContainer)
  1468. {
  1469. if (IsBadReadPtr(psA->lpOleUILinkContainer, sizeof(IOleUILinkContainerA)))
  1470. {
  1471. return(OLEUI_CSERR_LINKCNTRINVALID);
  1472. }
  1473. sW.lpOleUILinkContainer = new WrappedIOleUILinkContainer(psA->lpOleUILinkContainer);
  1474. if (NULL == sW.lpOleUILinkContainer)
  1475. {
  1476. return(uRet);
  1477. }
  1478. }
  1479. uRet = OleUIChangeSourceW(&sW);
  1480. if (psA->lpszDisplayName)
  1481. {
  1482. OleStdFree((LPVOID)psA->lpszDisplayName);
  1483. psA->lpszDisplayName = NULL;
  1484. }
  1485. if (sW.lpszDisplayName)
  1486. {
  1487. UINT uLen = WTOALEN(sW.lpszDisplayName);
  1488. psA->lpszDisplayName = (LPSTR)OleStdMalloc(uLen * sizeof(char));
  1489. if (!psA->lpszDisplayName)
  1490. {
  1491. uRet = OLEUI_ERR_LOCALMEMALLOC;
  1492. }
  1493. else
  1494. {
  1495. WTOA(psA->lpszDisplayName, sW.lpszDisplayName, uLen);
  1496. }
  1497. OleStdFree((LPVOID)sW.lpszDisplayName);
  1498. }
  1499. if (sW.lpszFrom)
  1500. {
  1501. UINT uLen = WTOALEN(sW.lpszFrom);
  1502. psA->lpszFrom = (LPSTR)OleStdMalloc(uLen * sizeof(char));
  1503. if (!psA->lpszFrom)
  1504. {
  1505. uRet = OLEUI_ERR_LOCALMEMALLOC;
  1506. }
  1507. else
  1508. {
  1509. WTOA(psA->lpszFrom, sW.lpszFrom, uLen);
  1510. }
  1511. OleStdFree((LPVOID)sW.lpszFrom);
  1512. }
  1513. if (sW.lpszTo)
  1514. {
  1515. UINT uLen = WTOALEN(sW.lpszTo);
  1516. psA->lpszTo = (LPSTR)OleStdMalloc(uLen * sizeof(char));
  1517. if (!psA->lpszTo)
  1518. {
  1519. uRet = OLEUI_ERR_LOCALMEMALLOC;
  1520. }
  1521. else
  1522. {
  1523. WTOA(psA->lpszTo, sW.lpszTo, uLen);
  1524. }
  1525. OleStdFree((LPVOID)sW.lpszTo);
  1526. }
  1527. psA->dwFlags = sW.dwFlags;
  1528. psA->nFileLength = sW.nFileLength;
  1529. if (NULL != sW.lpOleUILinkContainer)
  1530. {
  1531. sW.lpOleUILinkContainer->Release();
  1532. }
  1533. return(uRet);
  1534. }
  1535. int OleUIPromptUserInternal(int nTemplate, HWND hwndParent, LPTSTR szTitle, va_list arglist);
  1536. //+---------------------------------------------------------------------------
  1537. //
  1538. // Function: OleUIPromptUserA
  1539. //
  1540. // Synopsis: converts call to ANSI version into call to Unicode version
  1541. //
  1542. // Arguments: [nTemplate] - template ID
  1543. // [hwndParent] - parent's HWND
  1544. // [lpszTitle] - title of the window
  1545. // [...] - variable argument list
  1546. //
  1547. // History: 11-30-94 stevebl Created
  1548. //
  1549. // Notes: The first parameter passed in by this function is always the
  1550. // title for the dialog. It must be converted to Unicode before
  1551. // forwarding the call. The other parameters do not need to
  1552. // be converted because the template ID will indicate the dialog
  1553. // that contains the correct wsprintf formatting string for
  1554. // converting the other ANSI parameters to Unicode when the
  1555. // function calls wsprintf to build it's text.
  1556. //
  1557. //----------------------------------------------------------------------------
  1558. int FAR CDECL OleUIPromptUserA(int nTemplate, HWND hwndParent, ...)
  1559. {
  1560. WCHAR wszTemp[MAX_PATH];
  1561. WCHAR * wszTitle = NULL;
  1562. va_list arglist;
  1563. va_start(arglist, hwndParent);
  1564. LPSTR szTitle = va_arg(arglist, LPSTR);
  1565. if (szTitle != NULL)
  1566. {
  1567. ATOW(wszTemp, szTitle, MAX_PATH);
  1568. wszTitle = wszTemp;
  1569. }
  1570. int nRet = OleUIPromptUserInternal(nTemplate, hwndParent, wszTitle, arglist);
  1571. va_end(arglist);
  1572. return(nRet);
  1573. }
  1574. #else // UNICODE not defined
  1575. // Stubbed out Wide entry points
  1576. STDAPI_(BOOL) OleUIAddVerbMenuW(LPOLEOBJECT lpOleObj, LPCWSTR lpszShortType,
  1577. HMENU hMenu, UINT uPos, UINT uIDVerbMin, UINT uIDVerbMax,
  1578. BOOL bAddConvert, UINT idConvert, HMENU FAR *lphMenu)
  1579. {
  1580. return(FALSE);
  1581. }
  1582. //+---------------------------------------------------------------------------
  1583. //
  1584. // Function: ReturnError
  1585. //
  1586. // Synopsis: Used to stub out the following entry points:
  1587. // OleUIInsertObjectW
  1588. // OleUIPasteSpecialW
  1589. // OleUIEditLinksW
  1590. // OleUIChangeIconW
  1591. // OleUIConvertW
  1592. // OleUIBusyW
  1593. // OleUIObjectPropertiesW
  1594. // OleUIChangeSourceW
  1595. //
  1596. // Returns: OLEUI_ERR_DIALOGFAILURE
  1597. //
  1598. // History: 12-29-94 stevebl Created
  1599. //
  1600. // Notes: The entry points listed above are all mapped to this function
  1601. // in the Chicago version of OLEDLG.DEF.
  1602. //
  1603. //----------------------------------------------------------------------------
  1604. STDAPI_(UINT) ReturnError(void * p)
  1605. {
  1606. return(OLEUI_ERR_DIALOGFAILURE);
  1607. }
  1608. STDAPI_(BOOL) OleUIUpdateLinksW(LPOLEUILINKCONTAINERW lpOleUILinkCntr,
  1609. HWND hwndParent, LPWSTR lpszTitle, int cLinks)
  1610. {
  1611. return(FALSE);
  1612. }
  1613. int FAR CDECL OleUIPromptUserW(int nTemplate, HWND hwndParent, LPWSTR lpszTitle, ...)
  1614. {
  1615. return(2); // same as if user had cancelled the dialog
  1616. }
  1617. #endif // UNICODE