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.

1653 lines
48 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // File:
  4. // utils.h
  5. //
  6. // Contents:
  7. // prototypes and constants for OLE internal utility routines
  8. //
  9. // Classes:
  10. //
  11. // Functions:
  12. //
  13. // History:
  14. // 11/28/93 - ChrisWe - file inspection and cleanup begins
  15. // 11/29/93 - ChrisWe - remove signature for non-existent
  16. // function UtGlobalHandlCpy; moved manifest constants
  17. // to be with functions they are used with (OPCODE_*,
  18. // CONVERT_*); removed default parameters from functions;
  19. // replace '!' with '~' in STREAMTYPE_OTHER definition
  20. // 04/07/94 - AlexGo - added UtCreateStorageOnHGlobal
  21. //
  22. //-----------------------------------------------------------------------------
  23. #ifndef _UTILS_H_
  24. #define _UTILS_H_
  25. // We need to serialize the placeable metafile structure in the same format
  26. // that was used by WIN16, since RECT used LONGs under Win32.
  27. // We ensure that no padding is added by using the #pragma pack() calls.
  28. #pragma pack(1)
  29. typedef struct tagWIN16RECT
  30. {
  31. WORD left;
  32. WORD top;
  33. WORD right;
  34. WORD bottom;
  35. } WIN16RECT;
  36. typedef struct tagPLACEABLEMETAHEADER
  37. {
  38. DWORD key; /* must be PMF_KEY */
  39. #define PMF_KEY 0x9ac6cdd7
  40. WORD hmf; /* must be zero */
  41. WIN16RECT bbox; /* bounding rectangle of the metafile */
  42. WORD inch; /* # of metafile units per inch must be < 1440 */
  43. /* most apps use 576 or 1000 */
  44. DWORD reserved; /* must be zero */
  45. WORD checksum;
  46. } PLACEABLEMETAHEADER;
  47. #pragma pack()
  48. //+-------------------------------------------------------------------------
  49. //
  50. // Function: UtGetUNICODEData, PRIVATE INTERNAL
  51. //
  52. // Synopsis: Given a string length, and two pointers (one ANSI, one
  53. // OLESTR), returns the UNICODE version of whichever string
  54. // is valid.
  55. //
  56. // Effects: Memory is allocated on the caller's pointer for new OLESTR
  57. //
  58. // Arguments: [ulLength] -- length of string in CHARACTERS (not bytes)
  59. // (including terminator)
  60. // [szANSI] -- candidate ANSI string
  61. // [szOLESTR] -- candidate OLESTR string
  62. // [pstr] -- OLESTR OUT parameter
  63. //
  64. // Returns: NOERROR on success
  65. // E_OUTOFMEMORY on allocation failure
  66. // E_ANSITOUNICODE if ANSI cannot be converted to UNICODE
  67. //
  68. // Algorithm: If szOLESTR is available, a simple copy is performed
  69. // If szOLESTR is not available, szANSI is converted to UNICODE
  70. // and the result is copied.
  71. //
  72. // History: dd-mmm-yy Author Comment
  73. // 08-Mar-94 davepl Created
  74. //
  75. // Notes: Only one of the two input strings (ANSI or UNICODE) should
  76. // be set on entry.
  77. //
  78. //--------------------------------------------------------------------------
  79. INTERNAL UtGetUNICODEData( ULONG, LPSTR, LPOLESTR, LPOLESTR *);
  80. //+-------------------------------------------------------------------------
  81. //
  82. // Function: UtPutUNICODEData, PRIVATE INTERNAL
  83. //
  84. // Synopsis: Given an OLESTR and two possible buffer pointer, one ANSI
  85. // and the other OLESTR, this fn tries to convert the string
  86. // down to ANSI. If it succeeds, it allocates memory on the
  87. // ANSI ptr for the result. If it fails, it allocates memory
  88. // on the UNICODE ptr and copies the input string over. The
  89. // length of the final result (ANSI or UNICODE) is returned
  90. // in dwResultLen.
  91. //
  92. // Arguments: [ulLength] -- input length of OLESTR str
  93. // [str] -- the OLESTR to store
  94. // [pszANSI] -- candidate ANSI str ptr
  95. // [pszOLESTR] -- candidate OLESTR str ptr
  96. // [pdwResultLen] -- where to store the length of result
  97. //
  98. // Returns: NOERROR on success
  99. // E_OUTOFMEMORY on allocation failure
  100. //
  101. // History: dd-mmm-yy Author Comment
  102. // 08-Mar-94 davepl Created
  103. //
  104. //--------------------------------------------------------------------------
  105. INTERNAL UtPutUNICODEData(
  106. ULONG ulLength,
  107. LPOLESTR str,
  108. LPSTR * pszANSI,
  109. LPOLESTR * pszOLESTR,
  110. DWORD * pdwResultLen );
  111. //+----------------------------------------------------------------------------
  112. //
  113. // Function:
  114. // UtDupGlobal, internal
  115. //
  116. // Synopsis:
  117. // Duplicate the contents of an HGlobal into a new HGlobal. If
  118. // there is no allocated memory, no new global is allocated.
  119. //
  120. // Arguments:
  121. // [hsrc] -- the source HGLobal; need not be locked
  122. // [uiFlags] -- flags to be passed on to GlobalAlloc()
  123. //
  124. // Returns:
  125. // The new HGLOBAL, if successful, or NULL
  126. //
  127. // History:
  128. // 11/28/93 - ChrisWe - file inspection and cleanup
  129. //
  130. //-----------------------------------------------------------------------------
  131. FARINTERNAL_(HANDLE) UtDupGlobal(HANDLE hSrc, UINT uiFlags);
  132. //+----------------------------------------------------------------------------
  133. //
  134. // Function:
  135. // UtIsFormatSupported, internal
  136. //
  137. // Synopsis:
  138. // Checks a data object to see if it will accept
  139. // IDataObject::SetData() and/or IDataObject::GetData() calls
  140. // on the specified format. The direction of transfer is specified
  141. // with the dwDirection flags. The function returns TRUE only
  142. // if all requested transfers are possible.
  143. //
  144. // Arguments:
  145. // [lpObj] -- the data object to check for the format
  146. // [dwDirection] -- a combination of values from DATADIR_*
  147. // [cfFormat] -- the format to look for
  148. //
  149. // Returns:
  150. // TRUE, if transfers of [cfFormat] are supported in [dwDirection],
  151. // FALSE otherwise
  152. //
  153. // Notes:
  154. //
  155. // History:
  156. // 11/29/93 - ChrisWe - file inspection and cleanup; noted that
  157. // enumerators are expected to be able to return
  158. // formats for multiple DATADIR_* flags
  159. //
  160. //-----------------------------------------------------------------------------
  161. FARINTERNAL_(BOOL) UtIsFormatSupported(LPDATAOBJECT lpObj, DWORD dwDirection,
  162. CLIPFORMAT cfFormat);
  163. //+----------------------------------------------------------------------------
  164. //
  165. // Function:
  166. // UtDupString, internal
  167. //
  168. // Synopsis:
  169. // Copies the argument string into a new string allocated
  170. // using the task allocator
  171. //
  172. // Arguments:
  173. // [lpszIn] -- the string to duplicate
  174. //
  175. // Returns:
  176. // a pointer to a copy of [lpszIn], or NULL if the allocator
  177. // could not be acquired, or was out of memory
  178. //
  179. // History:
  180. // 11/28/93 - ChrisWe - file cleanup and inspection
  181. //
  182. //-----------------------------------------------------------------------------
  183. FARINTERNAL_(LPOLESTR) UtDupString(LPCOLESTR lpszIn);
  184. //+-------------------------------------------------------------------------
  185. //
  186. // Function: utGetProtseqFromTowerId
  187. //
  188. // Synopsis: Get protseq string from DCE TowerID
  189. //
  190. // Effects:
  191. //
  192. // Arguments: [wTowerId] -- TowerID to retrieve
  193. //
  194. // Returns: protseq string - NULL if not found
  195. //
  196. // History: dd-mmm-yy Author Comment
  197. // 28-Oct-96 t-KevinH Created as findProtseq
  198. // 06-Feb-97 Ronans Converted to utility fn
  199. //
  200. //--------------------------------------------------------------------------
  201. FARINTERNAL_(LPCWSTR) utGetProtseqFromTowerId(USHORT wTowerId);
  202. //+-------------------------------------------------------------------------
  203. //
  204. // Function: utGetTowerId
  205. //
  206. // Synopsis: Get DCE TowerId for protseq string
  207. //
  208. // Effects:
  209. //
  210. // Arguments: [pwszProtseq] -- string to look up
  211. //
  212. // Returns: protseq string - NULL if not found
  213. //
  214. // History: dd-mmm-yy Author Comment
  215. // 28-Oct-96 t-KevinH Created as findProtseq
  216. // 06-Feb-97 Ronans Converted to utility fn
  217. //
  218. //--------------------------------------------------------------------------
  219. FARINTERNAL_(USHORT) utGetTowerId(LPCWSTR pwszProtseq);
  220. //+-------------------------------------------------------------------------
  221. //
  222. // Function: UtDupStringA
  223. //
  224. // Synopsis: Duplicates an ANSI string using the TASK allocator
  225. //
  226. // Effects:
  227. //
  228. // Arguments: [pszAnsi] -- the string to duplicate
  229. //
  230. // Requires:
  231. //
  232. // Returns: the newly allocated string duplicate or NULL
  233. //
  234. // Signals:
  235. //
  236. // Modifies:
  237. //
  238. // Algorithm:
  239. //
  240. // History: dd-mmm-yy Author Comment
  241. // 04-Jun-94 alexgo author
  242. //
  243. // Notes:
  244. //
  245. //--------------------------------------------------------------------------
  246. LPSTR UtDupStringA( LPCSTR pszAnsi );
  247. //+----------------------------------------------------------------------------
  248. //
  249. // Function:
  250. // UtCopyFormatEtc, internal
  251. //
  252. // Synopsis:
  253. // Copies a format etc, creating copies of data structures
  254. // pointed to inside (the target device descriptor.)
  255. //
  256. // Arguments:
  257. // [pFetcIn] -- pointer to the FORMATETC to copy
  258. // [pFetcCopy] -- pointer to where to copy the FORMATETC to
  259. //
  260. // Returns:
  261. // FALSE if pointed to data could not be copied because it
  262. // could not be allocated
  263. // TRUE otherwise
  264. //
  265. // Notes:
  266. //
  267. // History:
  268. // 11/01/93 - ChrisWe - file inspection and cleanup
  269. //
  270. //-----------------------------------------------------------------------------
  271. FARINTERNAL_(BOOL) UtCopyFormatEtc(FORMATETC FAR* pFetcIn,
  272. FORMATETC FAR* pFetcCopy);
  273. //+----------------------------------------------------------------------------
  274. //
  275. // Function:
  276. // UtCompareFormatEtc, internal
  277. //
  278. // Synopsis:
  279. //
  280. // Arguments:
  281. // [pFetcLeft] -- pointer to a FORMATETC
  282. // [pFetcRight] -- pointer to a FORMATETC
  283. //
  284. // Returns:
  285. // UTCMPFETC_EQ is the two FORMATETCs match exactly
  286. // UTCMPFETC_NEQ if the two FORMATETCs do not match
  287. // UTCMPFETC_PARTIAL if the left FORMATETC is a subset of the
  288. // right: fewer aspects, null target device, or
  289. // fewer media
  290. //
  291. // Notes:
  292. //
  293. // History:
  294. // 11/01/93 - ChrisWe - file inspection and cleanup
  295. //
  296. //-----------------------------------------------------------------------------
  297. FARINTERNAL_(int) UtCompareFormatEtc(FORMATETC FAR* pFetcLeft,
  298. FORMATETC FAR* pFetcRight);
  299. #define UTCMPFETC_EQ 0 /* exact match */
  300. #define UTCMPFETC_NEQ 1 /* no match */
  301. #define UTCMPFETC_PARTIAL (-1) /* partial match; left is subset of right */
  302. //+----------------------------------------------------------------------------
  303. //
  304. // Function:
  305. // UtCompareTargetDevice, internal
  306. //
  307. // Synopsis:
  308. // Compares two target devices to see if they are the same
  309. //
  310. // Arguments:
  311. // [ptdLeft] -- pointer to a target device description
  312. // [ptdRight] -- pointer to a target device description
  313. //
  314. // Returns:
  315. // TRUE if the two devices are the same, FALSE otherwise
  316. //
  317. // Notes:
  318. //
  319. // History:
  320. // 11/01/93 - ChrisWe - file inspection and cleanup
  321. //
  322. //-----------------------------------------------------------------------------
  323. FARINTERNAL_(BOOL) UtCompareTargetDevice(DVTARGETDEVICE FAR* ptdLeft,
  324. DVTARGETDEVICE FAR* ptdRight);
  325. //+----------------------------------------------------------------------------
  326. //
  327. // Function:
  328. // UtCopyStatData, internal
  329. //
  330. // Synopsis:
  331. // Copies the contents of one STATDATA into another, including
  332. // creating a copy of data pointed to, and incrementing the
  333. // reference count on the advise sink to reflect the copy.
  334. //
  335. // Arguments:
  336. // [pSDIn] -- the source STATDATA
  337. // [pSDCopy] -- where to copy the information to
  338. //
  339. // Returns:
  340. // FALSE if memory could not be allocated for the copy of
  341. // the target device, TRUE otherwise
  342. //
  343. // Notes:
  344. //
  345. // History:
  346. // 11/01/93 - ChrisWe - file inspection and cleanup
  347. //
  348. //-----------------------------------------------------------------------------
  349. FARINTERNAL_(BOOL) UtCopyStatData(STATDATA FAR* pSDIn, STATDATA FAR* pSDCopy);
  350. //+----------------------------------------------------------------------------
  351. //
  352. // Function:
  353. // UtReleaseStatData, internal
  354. //
  355. // Synopsis:
  356. // Release resources associated with the argument STATDATA; this
  357. // frees the device description within the FORMATETC, and releases
  358. // the advise sink, if there is one.
  359. //
  360. // Arguments:
  361. // [pStatData] -- The STATDATA to clean up
  362. //
  363. // Notes:
  364. //
  365. // History:
  366. // 11/01/93 - ChrisWe - file inspection and cleanup
  367. //
  368. //-----------------------------------------------------------------------------
  369. FARINTERNAL_(void) UtReleaseStatData(STATDATA FAR* pStatData);
  370. //+----------------------------------------------------------------------------
  371. //
  372. // Function:
  373. // UtDupPalette, internal
  374. //
  375. // Synopsis:
  376. // Creates a duplicate palette.
  377. //
  378. // Arguments:
  379. // [hpalette] -- the palette to duplicate
  380. //
  381. // Returns:
  382. // if successful, a handle to the duplicate palette; if any
  383. // allocations or calls fail during the duplication process, NULL
  384. //
  385. // History:
  386. // 11/29//93 - ChrisWe - file inspection and cleanup
  387. //
  388. //-----------------------------------------------------------------------------
  389. FARINTERNAL_(HPALETTE) UtDupPalette(HPALETTE hpalette);
  390. //+----------------------------------------------------------------------------
  391. //
  392. // Function:
  393. // UtPaletteSize, internal
  394. //
  395. // Synopsis:
  396. // Returns the size of a color table for a palette given the
  397. // number of bits of color desired.
  398. //
  399. // Arguments:
  400. // [lpHeader] -- ptr to BITMAPINFOHEADER structure
  401. //
  402. // Returns:
  403. // Size in bytes of color information
  404. //
  405. // Notes:
  406. //
  407. // History:
  408. // 11/29/93 - ChrisWe - change bit count argument to unsigned,
  409. // and return value to size_t
  410. //
  411. // 07/18/94 - DavePl - Fixed for 16, 24, 32bpp DIBs
  412. //
  413. //-----------------------------------------------------------------------------
  414. FARINTERNAL_(size_t) UtPaletteSize(BITMAPINFOHEADER *);
  415. //+----------------------------------------------------------------------------
  416. //
  417. // Function:
  418. // UtFormatToTymed, internal
  419. //
  420. // Synopsis:
  421. // Maps a clipboard format to a medium used to transport it.
  422. //
  423. // Arguments:
  424. // [cf] -- the clipboard format to map
  425. //
  426. // Returns:
  427. // a TYMED_* value
  428. //
  429. // Notes:
  430. //
  431. // History:
  432. // 11/29/93 - ChrisWe - file inspection and cleanup
  433. //
  434. //-----------------------------------------------------------------------------
  435. FARINTERNAL_(DWORD) UtFormatToTymed(CLIPFORMAT cf);
  436. //+----------------------------------------------------------------------------
  437. //
  438. // Function:
  439. // UtQueryPictFormat, internal
  440. //
  441. // Synopsis:
  442. // Check to see if the argument data object supports one of
  443. // our preferred data formats for presentations:
  444. // CF_METAFILEPICT, CF_DIB, CF_BITMAP, in that order. Returns
  445. // TRUE, if success, and alters the given format descriptor
  446. // to match the supported format. The given format descriptor
  447. // is not altered if there is no match.
  448. //
  449. // Arguments:
  450. // [lpSrcDataObj] -- the data object to query
  451. // [lpforetc] - the format descriptor
  452. //
  453. // Returns:
  454. // TRUE if a preferred format is found, FALSE otherwise
  455. //
  456. // Notes:
  457. //
  458. // History:
  459. // 11/09/93 - ChrisWe - modified to not alter the descriptor
  460. // if no match is found
  461. // 11/09/93 - ChrisWe - file inspection and cleanup
  462. //
  463. //-----------------------------------------------------------------------------
  464. FARINTERNAL_(BOOL) UtQueryPictFormat(LPDATAOBJECT lpSrcDataObj,
  465. LPFORMATETC lpforetc);
  466. //+----------------------------------------------------------------------------
  467. //
  468. // Function:
  469. // UtConvertDibToBitmap, internal
  470. //
  471. // Synopsis:
  472. // Converts a DIB to a bitmap, returning a new handle to the
  473. // bitmap. The original DIB is left untouched.
  474. //
  475. // Arguments:
  476. // [hDib] -- handle to the DIB to convert
  477. //
  478. // Returns:
  479. // if successful, and handle to the new bitmap
  480. //
  481. // Notes:
  482. // REVIEW, the function uses the screen DC when creating the
  483. // new bitmap. It may be the case that the bitmap was intended
  484. // for another target, in which case this may not be appropriate.
  485. // It may be necessary to alter this function to take a DC as
  486. // an argument.
  487. //
  488. // History:
  489. // 11/29/93 - ChrisWe - file inspection and cleanup
  490. //
  491. //-----------------------------------------------------------------------------
  492. FARINTERNAL_(HBITMAP) UtConvertDibToBitmap(HANDLE hDib);
  493. //+----------------------------------------------------------------------------
  494. //
  495. // Function:
  496. // UtConvertBitmapToDib, internal
  497. //
  498. // Synopsis:
  499. // Creates a Device Independent Bitmap capturing the content of
  500. // the argument bitmap.
  501. //
  502. // Arguments:
  503. // [hBitmap] -- Handle to the bitmap to convert
  504. // [hpal] -- color palette for the bitmap; may be null for
  505. // default stock palette
  506. //
  507. // Returns:
  508. // Handle to the DIB. May be null if any part of the conversion
  509. // failed.
  510. //
  511. // Notes:
  512. //
  513. // History:
  514. // 11/29/93 - ChrisWe - file inspection and cleanup
  515. //
  516. //-----------------------------------------------------------------------------
  517. FARINTERNAL_(HANDLE) UtConvertBitmapToDib(HBITMAP hBitmap, HPALETTE hpal);
  518. //+----------------------------------------------------------------------------
  519. //
  520. // Function:
  521. // UtGetClassId, internal
  522. //
  523. // Synopsis:
  524. // Attempt to find the class id of the object. First,
  525. // query for IOleObject, and if successful, call
  526. // IOleObject::GetUserClassID(). If that fails, query for
  527. // IPersist, and if successful, call IPersist::GetClassID.
  528. //
  529. // Arguments:
  530. // [lpUnk] -- pointer to an IUnknown instance
  531. // [lpClsid] -- pointer to where to copy the class id to
  532. //
  533. // Returns:
  534. // TRUE, if the class id was obtained, or FALSE otherwise
  535. // If unsuccessful, *[lpClsid] is set to CLSID_NULL
  536. //
  537. // Notes:
  538. //
  539. // History:
  540. // 11/29/93 - ChrisWe - change to return BOOL to indicate success
  541. //
  542. //-----------------------------------------------------------------------------
  543. FARINTERNAL_(BOOL) UtGetClassID(LPUNKNOWN lpUnk, CLSID FAR* lpClsid);
  544. //+----------------------------------------------------------------------------
  545. //
  546. // Function:
  547. // UtCopyTargetDevice, internal
  548. //
  549. // Synopsis:
  550. // Allocates a new target device description, and copies
  551. // the given one into it
  552. //
  553. // Arguments:
  554. // [ptd] -- pointer to a target device
  555. //
  556. // Returns:
  557. // NULL, if the no memory can be allocated
  558. //
  559. // Notes:
  560. //
  561. // History:
  562. // 11/01/93 - ChrisWe - file inspection and cleanup
  563. //
  564. //-----------------------------------------------------------------------------
  565. FARINTERNAL_(DVTARGETDEVICE FAR*) UtCopyTargetDevice(DVTARGETDEVICE FAR* ptd);
  566. //+----------------------------------------------------------------------------
  567. //
  568. // Function:
  569. // UtGetIconData, internal
  570. //
  571. // Synopsis:
  572. // Attempts to get the icon for an object.
  573. //
  574. // Arguments:
  575. // [lpSrcDataObj] -- The source data object
  576. // [rclsid] -- the class id the object is known to be
  577. // (may be CLSID_NULL)
  578. // [lpforetc] -- the format of the data to fetch
  579. // [lpstgmed] -- a place to return the medium it was fetched on
  580. //
  581. // Returns:
  582. // E_OUTOFMEMORY, S_OK
  583. //
  584. // Notes:
  585. // REVIEW, this method seems to assume that the contents of
  586. // lpforetc are correct for fetching an icon. It passes this
  587. // on to [lpSrcDataObj]->GetData first, and if that fails,
  588. // calls OleGetIconOfClass, without checking the requested
  589. // format in lpforetc. This could fetch anything
  590. //
  591. // History:
  592. // 11/30/93 - ChrisWe - file inspection and cleanup
  593. //
  594. //-----------------------------------------------------------------------------
  595. FARINTERNAL UtGetIconData(LPDATAOBJECT lpSrcDataObj, REFCLSID rclsid,
  596. LPFORMATETC lpforetc, LPSTGMEDIUM lpstgmed);
  597. //+----------------------------------------------------------------------------
  598. //
  599. // Function:
  600. // UtDoStreamOperation, internal
  601. //
  602. // Synopsis:
  603. // Iterate over the streams in [pstgSrc], performing the
  604. // operation indicated by [iOpCode] to those that are specified
  605. // by [grfAllowedStmTypes].
  606. //
  607. // Arguments:
  608. // [pstgSrc] -- source IStorage instance
  609. // [pstgDst] -- destination IStorage instance; may be null for
  610. // some operations (OPCODE_REMOVE)
  611. // [iOpCode] -- 1 value from the OPCODE_* values below
  612. // [grfAllowedStmTypes] -- a logical or of one or more of the
  613. // STREAMTYPE_* values below
  614. //
  615. // Returns:
  616. // HRESULT
  617. //
  618. // Notes:
  619. //
  620. // History:
  621. // 11/30/93 - ChrisWe - file inspection and cleanup
  622. //
  623. //-----------------------------------------------------------------------------
  624. STDAPI UtDoStreamOperation(LPSTORAGE pstgSrc, LPSTORAGE pstgDst,
  625. int iOpCode, DWORD grfAllowedStmTypes);
  626. #define OPCODE_COPY 1 /* copy the stream from pstgSrc to pstgDst */
  627. #define OPCODE_REMOVE 2 /* delete the stream from pstgSrc */
  628. #define OPCODE_MOVE 3 /* move the stream from pstgSrc to pstgDst */
  629. #define OPCODE_EXCLUDEFROMCOPY 4
  630. /* unimplemented, undocumented, intent unknown */
  631. #define STREAMTYPE_CONTROL 0x00000001 /* OLE 0x1 stream (REVIEW const) */
  632. #define STREAMTYPE_CACHE 0x00000002 /* OLE 0x2 stream (REVIEW const) */
  633. #define STREAMTYPE_CONTAINER 0x00000004 /* OLE 0x3 stream (REVIEW const) */
  634. #define STREAMTYPE_OTHER \
  635. (~(STREAMTYPE_CONTROL | STREAMTYPE_CACHE | STREAMTYPE_CONTAINER))
  636. #define STREAMTYPE_ALL 0xFFFFFFFF /* all stream types are allowed */
  637. //+----------------------------------------------------------------------------
  638. //
  639. // Function:
  640. // UtGetPresStreamName, internal
  641. //
  642. // Synopsis:
  643. // Modify [lpszName] to be a presentation stream name based
  644. // on [iStreamNum].
  645. //
  646. // Arguments:
  647. // [lpszName] -- a copy of OLE_PRESENTATION_STREAM; see below
  648. // [iStreamNum] -- the number of the stream
  649. //
  650. // Notes:
  651. // The digit field of [lpszName] is always completely overwritten,
  652. // allowing repeated use of UtGetPresStreamName() on the same
  653. // string; this removes the need to repeatedly start with a fresh
  654. // copy of OLE_PRESENTATION_STREAM each time this is used in a
  655. // loop.
  656. //
  657. // The validity of the implementation depends on the values of
  658. // OLE_PRESENTATION_STREAM and OLE_MAX_PRES_STREAMS; if those
  659. // change, the implementation must change
  660. //
  661. // History:
  662. // 11/30/93 - ChrisWe - file inspection and cleanup
  663. //
  664. //-----------------------------------------------------------------------------
  665. FARINTERNAL_(void)UtGetPresStreamName(LPOLESTR lpszName, int iStreamNum);
  666. //+----------------------------------------------------------------------------
  667. //
  668. // Function:
  669. // UtRemoveExtraOlePresStreams, internal
  670. //
  671. // Synopsis:
  672. // Deletes presentation streams in [pstg] starting with the
  673. // presentation numbered [iStart]. All streams after that one
  674. // (numbered sequentially) are deleted, up to OLE_MAX_PRES_STREAMS.
  675. //
  676. // Arguments:
  677. // [pstg] -- the IStorage instance to operate on
  678. // [iStart] -- the number of the first stream to remove
  679. //
  680. // Returns:
  681. //
  682. // Notes:
  683. // The presentation stream names are generated with
  684. // UtGetPresStreamName().
  685. //
  686. // History:
  687. // 11/30/93 - ChrisWe - file inspection and cleanup
  688. //
  689. //-----------------------------------------------------------------------------
  690. FARINTERNAL_(void) UtRemoveExtraOlePresStreams(LPSTORAGE pstg, int iStart);
  691. //+-------------------------------------------------------------------------
  692. //
  693. // Function: UtCreateStorageOnHGlobal
  694. //
  695. // Synopsis: creates a storage on top of an HGlobal
  696. //
  697. // Effects:
  698. //
  699. // Arguments: [hGlobal] -- the memory on which to create the
  700. // storage
  701. // [fDeleteOnRelease] -- if TRUE, then delete the memory
  702. // ILockBytes once the storage is
  703. // released.
  704. // [ppStg] -- where to put the storage interface
  705. // [ppILockBytes] -- where to put the underlying ILockBytes,
  706. // maybe NULL. The ILB must be released.
  707. //
  708. // Requires:
  709. //
  710. // Returns: HRESULT
  711. //
  712. // Signals:
  713. //
  714. // Modifies:
  715. //
  716. // Algorithm: create an ILockBytes on HGLOBAL and then create the docfile
  717. // on top of the ILockBytes
  718. //
  719. // History: dd-mmm-yy Author Comment
  720. // 07-Apr-94 alexgo author
  721. //
  722. // Notes:
  723. //
  724. //--------------------------------------------------------------------------
  725. HRESULT UtCreateStorageOnHGlobal( HGLOBAL hGlobal, BOOL fDeleteOnRelease,
  726. IStorage **ppStg, ILockBytes **ppILockBytes );
  727. //+-------------------------------------------------------------------------
  728. //
  729. // Function: UtGetTempFileName
  730. //
  731. // Synopsis: retrieves a temporary filename (for use in GetData, TYMED_FILE
  732. // and temporary docfiles)
  733. //
  734. // Effects:
  735. //
  736. // Arguments: [pszPrefix] -- prefix of the temp filename
  737. // [pszTempName] -- buffer that will receive the temp path.
  738. // must be MAX_PATH or greater.
  739. //
  740. // Requires:
  741. //
  742. // Returns: HRESULT;
  743. //
  744. // Signals:
  745. //
  746. // Modifies:
  747. //
  748. // Algorithm: tries to get a file in the temp directory, failing that, in
  749. // the windows directory
  750. //
  751. // History: dd-mmm-yy Author Comment
  752. // 07-Apr-94 alexgo author
  753. //
  754. // Notes:
  755. //
  756. //--------------------------------------------------------------------------
  757. HRESULT UtGetTempFileName( LPOLESTR pszPrefix, LPOLESTR pszTempName );
  758. //+----------------------------------------------------------------------------
  759. //
  760. // Function:
  761. // UtHGLOBALToStm, internal
  762. //
  763. // Synopsis:
  764. // Write the contents of an HGLOBAL to a stream
  765. //
  766. // Arguments:
  767. // [hdata] -- handle to the data to write out
  768. // [dwSize] -- size of the data to write out
  769. // [pstm] -- stream to write the data out to; on exit, the
  770. // stream is positioned after the written data
  771. //
  772. // Returns:
  773. // HRESULT
  774. //
  775. // Notes:
  776. //
  777. // History:
  778. // 11/30/93 - ChrisWe - file inspection and cleanup
  779. //
  780. //-----------------------------------------------------------------------------
  781. HRESULT UtHGLOBALtoStm(HANDLE hdata, DWORD dwSize, LPSTREAM pstm);
  782. //+-------------------------------------------------------------------------
  783. //
  784. // Function: UtHGLOBALtoHGLOBAL, internal
  785. //
  786. // Synopsis: Copies the source HGLOBAL into the target HGLOBAL
  787. //
  788. // Effects:
  789. //
  790. // Arguments: [hGlobalSrc] -- the source HGLOBAL
  791. // [dwSize] -- the number of bytes to copy
  792. // [hGlobalTgt] -- the target HGLOBAL
  793. //
  794. // Requires:
  795. //
  796. // Returns: HRESULT
  797. //
  798. // Signals:
  799. //
  800. // Modifies:
  801. //
  802. // Algorithm:
  803. //
  804. // History: dd-mmm-yy Author Comment
  805. // 10-Apr-94 alexgo author
  806. //
  807. // Notes: this function will fail if the target hglobal is not large
  808. // enough
  809. //
  810. //--------------------------------------------------------------------------
  811. HRESULT UtHGLOBALtoHGLOBAL( HGLOBAL hGlobalSrc, DWORD dwSize,
  812. HGLOBAL hGlobalTgt);
  813. //+-------------------------------------------------------------------------
  814. //
  815. // Function: UtHGLOBALtoStorage, internal
  816. //
  817. // Synopsis: Copies the source HGLOBAL into the target storage
  818. //
  819. // Effects:
  820. //
  821. // Arguments: [hGlobalSrc] -- the source HGLOBAL
  822. // [hpStg] -- the target storage
  823. //
  824. // Requires:
  825. //
  826. // Returns: HRESULT
  827. //
  828. // Signals:
  829. //
  830. // Modifies:
  831. //
  832. // Algorithm:
  833. //
  834. // History: dd-mmm-yy Author Comment
  835. // 10-Apr-94 alexgo author
  836. //
  837. // Notes: this function will fail if the source HGLOBAL did not
  838. // originally have a storage layered on top of it.
  839. //
  840. //--------------------------------------------------------------------------
  841. HRESULT UtHGLOBALtoStorage( HGLOBAL hGlobalSrc, IStorage *pStg);
  842. //+-------------------------------------------------------------------------
  843. //
  844. // Function: UtHGLOBALtoFile, internal
  845. //
  846. // Synopsis: Copies the source HGLOBAL into the target file
  847. //
  848. // Effects:
  849. //
  850. // Arguments: [hGlobalSrc] -- the source HGLOBAL
  851. // [dwSize] -- the number of bytes to copy
  852. // [pszFileName] -- the target file
  853. //
  854. // Requires:
  855. //
  856. // Returns: HRESULT
  857. //
  858. // Signals:
  859. //
  860. // Modifies:
  861. //
  862. // Algorithm:
  863. //
  864. // History: dd-mmm-yy Author Comment
  865. // 10-Apr-94 alexgo author
  866. //
  867. // Notes:
  868. //
  869. //--------------------------------------------------------------------------
  870. HRESULT UtHGLOBALtoFile( HGLOBAL hGlobalSrc, DWORD dwSize,
  871. LPCOLESTR pszFileName);
  872. /*** Following routines can be found in convert.cpp *****/
  873. //+----------------------------------------------------------------------------
  874. //
  875. // Function:
  876. // UtGetHGLOBALFromStm, internal
  877. //
  878. // Synopsis:
  879. // Create a new HGLOBAL, and read [dwSize] bytes into it
  880. // from [lpstream].
  881. //
  882. // Arguments:
  883. // [lpstream] -- the stream to read the content of the new
  884. // HGLOBAL from; on exit, points just past the data read
  885. // [dwSize] -- the amount of material to read from the stream
  886. // [lphPres] -- pointer to where to return the new handle
  887. //
  888. // Returns:
  889. // HRESULT
  890. //
  891. // Notes:
  892. // In case of any error, the new handle is freed. If the
  893. // amount of material expected from [lpstream] is less than
  894. // [dwSize], nothing is returned.
  895. //
  896. // History:
  897. // 11/30/93 - ChrisWe - file inspection and cleanup
  898. //
  899. //-----------------------------------------------------------------------------
  900. FARINTERNAL UtGetHGLOBALFromStm(LPSTREAM lpstream, DWORD dwSize,
  901. HANDLE FAR* lphPres);
  902. //+----------------------------------------------------------------------------
  903. //
  904. // Function:
  905. // UtGetHDIBFromDIBFileStm, internal
  906. //
  907. // Synopsis:
  908. // Produce a handle to a DIB from a file stream
  909. //
  910. // Arguments:
  911. // [pstm] -- the stream to read the DIB from; on exit, the
  912. // stream is positioned just past the data read
  913. // [lphdata] -- pointer to where to return the handle to the data
  914. //
  915. // Returns:
  916. // HRESULT
  917. //
  918. // Notes:
  919. //
  920. // History:
  921. // 11/30/93 - ChrisWe - file inspection and cleanup
  922. //
  923. //-----------------------------------------------------------------------------
  924. FARINTERNAL UtGetHDIBFromDIBFileStm(LPSTREAM pstm, HANDLE FAR* lphdata);
  925. //+----------------------------------------------------------------------------
  926. //
  927. // Function:
  928. // UtGetHMFPICT, internal
  929. //
  930. // Synopsis:
  931. // Given a handle to a METAFILE, conjure up a handle to a
  932. // METAFILEPICT, based on the metafile
  933. //
  934. // Arguments:
  935. // [hMF] -- handle to the METAFILE
  936. // [fDeleteOnError] -- if TRUE, delete the METAFILE [hMF] in there
  937. // is any error
  938. // [xExt] -- the x extent of the desired METAFILEPICT
  939. // [yExt] -- the y extent of the desired METAFILEPICT
  940. //
  941. // Returns:
  942. // Handle to the new METAFILEPICT, if successful, or NULL
  943. //
  944. // Notes:
  945. //
  946. // History:
  947. // 11/30/93 - ChrisWe - file inspection and cleanup
  948. //
  949. //-----------------------------------------------------------------------------
  950. FARINTERNAL_(HANDLE) UtGetHMFPICT(HMETAFILE hMF, BOOL fDeletOnError,
  951. DWORD xExt, DWORD yExt);
  952. //+----------------------------------------------------------------------------
  953. //
  954. // Function:
  955. // UtGetHMFFromMFStm, internal
  956. //
  957. // Synopsis:
  958. // Create a handle to a METAFILE, loaded with content from
  959. // the given stream
  960. //
  961. // Arguments:
  962. // [lpstream] -- the source stream to initialize the METAFILE with;
  963. // on exit, the stream is positioned just past the
  964. // data read
  965. // [dwSize] -- the amount of material to read from [lpstream]
  966. // [fConvert] -- if TRUE, tries to convert a Macintosh QuickDraw
  967. // file to METAFILE format
  968. // [lphPres] -- pointer to where to return the new handle to
  969. // the metafile
  970. //
  971. // Returns:
  972. // HRESULT
  973. //
  974. // Notes:
  975. // If [dwSize] is too large, and goes past the end of the
  976. // stream, the error causes everything allocated to be freed,
  977. // and nothing is returned in [lphPres].
  978. //
  979. // History:
  980. // 11/30/93 - ChrisWe - file inspection and cleanup
  981. //
  982. //-----------------------------------------------------------------------------
  983. FARINTERNAL UtGetHMFFromMFStm(LPSTREAM lpstream, DWORD dwSize,
  984. BOOL fConvert, HANDLE FAR* lphPres);
  985. //+----------------------------------------------------------------------------
  986. //
  987. // Function:
  988. // UtGetSizeAndExtentsFromPlaceableMFStm, internal
  989. //
  990. // Synopsis:
  991. // Obtain the size, width, and height of the metafile stored
  992. // in a placeable metafile stream.
  993. //
  994. // Arguments:
  995. // [lpstream] -- the stream to read the placeable metafile
  996. // from; on exit, the stream is positioned at the
  997. // beginning of the metafile header, after the
  998. // placeable metafile header.
  999. // [pdwSize] -- a pointer to where to return the size of the
  1000. // metafile; may be NULL
  1001. // [plWidth] -- a pointer to where to return the width of the
  1002. // metafile; may be NULL
  1003. // [plHeight] -- a pointer to where to return the height of the
  1004. // metafile; may be NULL
  1005. //
  1006. // Returns:
  1007. // HRESULT
  1008. //
  1009. // Notes:
  1010. //
  1011. // History:
  1012. // 11/30/93 - ChrisWe - file inspection and cleanup
  1013. //
  1014. //-----------------------------------------------------------------------------
  1015. FARINTERNAL UtGetSizeAndExtentsFromPlaceableMFStm(LPSTREAM pstm,
  1016. DWORD FAR* dwSize, LONG FAR* plWidth, LONG FAR* plHeight);
  1017. //+----------------------------------------------------------------------------
  1018. //
  1019. // Function:
  1020. // UtGetHMFPICTFromPlaceableMFStm, internal
  1021. //
  1022. // Synopsis:
  1023. // Create a handle to a METAFILEPICT initialized from a
  1024. // placeable METAFILE stream.
  1025. //
  1026. // Arguments:
  1027. // [pstm] -- the stream to load the METAFILE from; on exit
  1028. // points just past the METAFILE data
  1029. // [lphdata] -- pointer to where to return the handle to the
  1030. // new METAFILEPICT
  1031. //
  1032. // Returns:
  1033. // HRESULT
  1034. //
  1035. // Notes:
  1036. //
  1037. // History:
  1038. // 11/30/93 - ChrisWe - file inspection and cleanup
  1039. //
  1040. //-----------------------------------------------------------------------------
  1041. FARINTERNAL UtGetHMFPICTFromPlaceableMFStm(LPSTREAM pstm, HANDLE FAR* lphdata);
  1042. //+----------------------------------------------------------------------------
  1043. //
  1044. // Function:
  1045. // UtGetDibExtents, internal
  1046. //
  1047. // Synopsis:
  1048. // Return the width and height of a DIB, in HIMETRIC units
  1049. // per pixel.
  1050. //
  1051. // Arguments:
  1052. // [lpbmi] -- pointer to a BITMAPINFOHEADER
  1053. // [plWidth] -- pointer to where to return the width
  1054. // REVIEW, this should be a DWORD
  1055. // [plHeight] -- pointer to where to return the height
  1056. // REVIEW, this should be a DWORD
  1057. //
  1058. // Notes:
  1059. //
  1060. // History:
  1061. // 12/02/93 - ChrisWe - file inspection and cleanup
  1062. //
  1063. //-----------------------------------------------------------------------------
  1064. FARINTERNAL_(void) UtGetDibExtents(LPBITMAPINFOHEADER lpbmi,
  1065. LONG FAR* plWidth, LONG FAR* plHeight);
  1066. #ifdef LATER
  1067. FARINTERNAL_(void) UtGetDibExtents(LPBITMAPINFOHEADER lpbmi,
  1068. DWORD FAR* pdwWidth, DWORD FAR* pdwHeight);
  1069. #endif
  1070. //+----------------------------------------------------------------------------
  1071. //
  1072. // Function:
  1073. // UtHDIBToDIBFileStm, internal
  1074. //
  1075. // Synopsis:
  1076. // Given a handle to a DIB, write out out a DIB file stream.
  1077. //
  1078. // Arguments:
  1079. // [hdata] -- handle to the DIB
  1080. // [dwSize] -- the size of the DIB
  1081. // [pstm] -- the stream to write the DIB out to; on exit, the
  1082. // stream is positioned after the DIB data; the DIB
  1083. // data is prepended with a BITMAPFILEHEADER
  1084. //
  1085. // Returns:
  1086. // HRESULT
  1087. //
  1088. // Notes:
  1089. //
  1090. // History:
  1091. // 12/02/93 - ChrisWe - file inspection and cleanup
  1092. //
  1093. //-----------------------------------------------------------------------------
  1094. FARINTERNAL UtHDIBToDIBFileStm(HANDLE hdata, DWORD dwSize, LPSTREAM pstm);
  1095. //+----------------------------------------------------------------------------
  1096. //
  1097. // Function:
  1098. // UtDIBStmToDIBFileStm, internal
  1099. //
  1100. // Synopsis:
  1101. // copy convert a DIB in a stream to a DIB file stream
  1102. //
  1103. // Arguments:
  1104. // [pstmDIB] -- the source DIB
  1105. // REVIEW, what does CopyTo do to the stream pointer?
  1106. // [dwSize] -- the size of the source DIB
  1107. // [pstmDIBFile] -- where to write the converted DIB file stream;
  1108. // should not be the same as [pstmDIB]; on exit, the
  1109. // stream is positioned after the DIB file data
  1110. //
  1111. // Returns:
  1112. // HRESULT
  1113. //
  1114. // Notes:
  1115. //
  1116. // History:
  1117. // 12/02/93 - ChrisWe - file inspection and cleanup
  1118. //
  1119. //-----------------------------------------------------------------------------
  1120. FARINTERNAL UtDIBStmToDIBFileStm(LPSTREAM pstmDIB, DWORD dwSize,
  1121. LPSTREAM pstmDIBFile);
  1122. //+----------------------------------------------------------------------------
  1123. //
  1124. // Function:
  1125. // UtHDIBFileToOlePresStm, internal
  1126. //
  1127. // Synopsis:
  1128. // Given a handle to a DIB file, write it out to a stream
  1129. //
  1130. // Arguments:
  1131. // [hdata] -- the handle to the DIB file
  1132. // [pstm] -- the stream to write it out to; on exit, the
  1133. // stream is positioned after the written data
  1134. //
  1135. // Returns:
  1136. // HRESULT
  1137. //
  1138. // Notes:
  1139. // A small header with size information precedes the DIB file
  1140. // data.
  1141. //
  1142. // History:
  1143. // 12/02/93 - ChrisWe - file inspection and cleanup
  1144. //
  1145. //-----------------------------------------------------------------------------
  1146. FARINTERNAL UtHDIBFileToOlePresStm(HANDLE hdata, LPSTREAM pstm);
  1147. //+----------------------------------------------------------------------------
  1148. //
  1149. // Function:
  1150. // UtHMFToMFStm, internal
  1151. //
  1152. // Synopsis:
  1153. // Given a handle to a METAFILE, write it out to a METAFILE stream
  1154. //
  1155. // Arguments:
  1156. // [lphMF] -- a *pointer* to a handle to a METAFILE
  1157. // REVIEW, why is this a pointer?
  1158. // [dwSize] -- the size of the METAFILE
  1159. // [lpstream] -- the stream to write the METAFILE out to; on
  1160. // exit, the stream is positioned after the written data
  1161. //
  1162. // Returns:
  1163. // HRESULT
  1164. //
  1165. // Notes:
  1166. //
  1167. // History:
  1168. // 12/02/93 - ChrisWe - file inspection and cleanup
  1169. //
  1170. //-----------------------------------------------------------------------------
  1171. FARINTERNAL UtHMFToMFStm(HANDLE FAR* lphMF, DWORD dwSize, LPSTREAM lpstream);
  1172. //+----------------------------------------------------------------------------
  1173. //
  1174. // Function:
  1175. // UtHMFToPlaceableMFStm, internal
  1176. //
  1177. // Synopsis:
  1178. // Given a handle to a METAFILE, write it to a stream as a
  1179. // placeable METAFILE
  1180. //
  1181. // Arguments:
  1182. // [lphMF] -- a *pointer* to a METAFILE handle
  1183. // REVIEW, why is this a pointer?
  1184. // [dwSize] -- size of the METAFILE
  1185. // [lWidth] -- width of the metafile
  1186. // REVIEW, in what units?
  1187. // REVIEW, why isn't this a DWORD?
  1188. // [lHeight] -- height of the metafile
  1189. // REVIEW, in what units?
  1190. // REVIEW, why isn't this a DWORD?
  1191. // [pstm] -- the stream to write the data to; on exit, the stream
  1192. // is positioned after the written data
  1193. //
  1194. // Returns:
  1195. // HRESULT
  1196. //
  1197. // Notes:
  1198. //
  1199. // History:
  1200. // 12/02/93 - ChrisWe - file inspection and cleanup
  1201. //
  1202. //-----------------------------------------------------------------------------
  1203. FARINTERNAL UtHMFToPlaceableMFStm(HANDLE FAR* lphMF, DWORD dwSize,
  1204. LONG lWidth, LONG lHeight, LPSTREAM pstm);
  1205. //+----------------------------------------------------------------------------
  1206. //
  1207. // Function:
  1208. // UtNFStmToPlaceableMFStm, internal
  1209. //
  1210. // Synopsis:
  1211. // Copy converts a METAFILE in a stream to a placeable METAFILE
  1212. // in another stream.
  1213. //
  1214. // Arguments:
  1215. // [pstmMF] -- the IStream instance from which to read the
  1216. // original METAFILE, positioned at the METAFILE
  1217. // REVIEW, where does CopyTo leave this stream pointer?
  1218. // [dwSize] -- the size of the source METAFILE
  1219. // [lWidth] -- the width of the source METAFILE
  1220. // REVIEW, in what units?
  1221. // REVIEW, why isn't this a DWORD?
  1222. // [lHeight] -- the height of the source METAFILE
  1223. // REVIEW, in what units?
  1224. // REVIEW, why isn't this a DWORD?
  1225. // [pstmPMF] -- the IStream instance to which to write the
  1226. // placeable METAFILE; on exit, the stream is positioned
  1227. // after the written data
  1228. //
  1229. // Returns:
  1230. // HRESULT
  1231. //
  1232. // Notes:
  1233. //
  1234. // History:
  1235. // 12/02/93 - ChrisWe - file inspection and cleanup
  1236. //
  1237. //-----------------------------------------------------------------------------
  1238. FARINTERNAL UtMFStmToPlaceableMFStm(LPSTREAM pstmMF, DWORD dwSize,
  1239. LONG lWidth, LONG lHeight, LPSTREAM pstmPMF);
  1240. //+----------------------------------------------------------------------------
  1241. //
  1242. // Function:
  1243. // UtWriteOlePresStmHeader, internal
  1244. //
  1245. // Synopsis:
  1246. // Write out the header information for an Ole presentation stream.
  1247. //
  1248. // Arguments:
  1249. // [lpstream] -- the stream to write to; on exit, the stream is
  1250. // positioned after the header information
  1251. // [pforetc] -- pointer to the FORMATETC for the presentation
  1252. // data
  1253. // [dwAdvf] -- the advise control flags for this presentation
  1254. //
  1255. // Returns:
  1256. // HRESULT
  1257. //
  1258. // Notes:
  1259. // This writes the clipboard information, the target device
  1260. // information, if any, some FORMATETC data, and the advise
  1261. // control flags.
  1262. //
  1263. // History:
  1264. // 12/02/93 - ChrisWe - file inspection and cleanup
  1265. //
  1266. //-----------------------------------------------------------------------------
  1267. FARINTERNAL UtWriteOlePresStmHeader(LPSTREAM lppstream, LPFORMATETC pforetc,
  1268. DWORD dwAdvf);
  1269. //+----------------------------------------------------------------------------
  1270. //
  1271. // Function:
  1272. // UtReadOlePresStmHeader, internal
  1273. //
  1274. // Synopsis:
  1275. // Reads the presentation description information from an Ole
  1276. // presentation stream, as written by
  1277. // UtWriteOlePresStmHeader().
  1278. //
  1279. // Arguments:
  1280. // [pstm] -- the IStream instance to read the presentation
  1281. // description data from
  1282. // [pforetc] -- pointer to the FORMATETC to initialize based
  1283. // on data in the stream
  1284. // [pdwAdvf] -- pointer to where to put the advise flags for
  1285. // this presentation; may be NULL
  1286. // [pfConvert] -- pointer to a flag that is set to TRUE if
  1287. // the presentation will require conversion from
  1288. // Macintosh PICT format.
  1289. //
  1290. // Returns:
  1291. // HRESULT
  1292. //
  1293. // Notes:
  1294. //
  1295. // History:
  1296. // 12/02/93 - ChrisWe - file inspection and cleanup
  1297. //
  1298. //-----------------------------------------------------------------------------
  1299. FARINTERNAL UtReadOlePresStmHeader(LPSTREAM pstm, LPFORMATETC pforetc,
  1300. DWORD FAR* pdwAdvf, BOOL FAR* pfConvert);
  1301. //+----------------------------------------------------------------------------
  1302. //
  1303. // Function:
  1304. // UtOlePresStmToContentsStm, internal
  1305. //
  1306. // Synopsis:
  1307. // Copy the content of a presentation stream to a contents stream,
  1308. // adjusting the format as necessary.
  1309. //
  1310. // Arguments:
  1311. // [pstg] -- the IStorage instance in which the presentation
  1312. // stream is, and in which to create the contents stream
  1313. // [lpszPresStm] -- the name of the source presentation stream
  1314. // [fDeletePresStm] -- flag that indicates that the presentation
  1315. // stream should be deleted if the copy and convert is
  1316. // successful. This is ignored if the source was
  1317. // DVASPECT_ICON.
  1318. // [puiStatus] -- pointer to a UINT where status bits from
  1319. // the CONVERT_* values below may be returned.
  1320. //
  1321. // Returns:
  1322. // HRESULT
  1323. //
  1324. // Notes:
  1325. // The content stream is named by the constant OLE_CONTENTS_STREAM.
  1326. //
  1327. // History:
  1328. // 12/05/93 - ChrisWe - file inspection and cleanup
  1329. //
  1330. //-----------------------------------------------------------------------------
  1331. FARINTERNAL UtOlePresStmToContentsStm(LPSTORAGE pstg, LPOLESTR lpszPresStm,
  1332. BOOL fDeletePresStm, UINT FAR* puiStatus);
  1333. #define CONVERT_NOSOURCE 0x0001
  1334. #define CONVERT_NODESTINATION 0x0002
  1335. #define CONVERT_SOURCEISICON 0x0004
  1336. // 2nd variation
  1337. FARINTERNAL UtOlePresStmToContentsStm(LPSTORAGE pSrcStg, LPOLESTR lpszPresStm,
  1338. LPSTREAM pDestStm, UINT FAR* puiStatus);
  1339. FARINTERNAL UtGetHMFPICTFromMSDrawNativeStm(LPSTREAM pstm, DWORD dwSize,
  1340. HANDLE FAR* lphdata);
  1341. FARINTERNAL UtPlaceableMFStmToMSDrawNativeStm(LPSTREAM pstmPMF,
  1342. LPSTREAM pstmMSDraw);
  1343. FARINTERNAL UtDIBFileStmToPBrushNativeStm(LPSTREAM pstmDIBFile,
  1344. LPSTREAM pstmPBrush);
  1345. FARINTERNAL UtContentsStmTo10NativeStm(LPSTORAGE pstg, REFCLSID rclsid,
  1346. BOOL fDeleteContents, UINT FAR* puiStatus);
  1347. FARINTERNAL Ut10NativeStmToContentsStm(LPSTORAGE pstg, REFCLSID rclsid,
  1348. BOOL fDeleteSrcStm);
  1349. //+----------------------------------------------------------------------------
  1350. //
  1351. // Function:
  1352. // UtGetHPRESFromNative, internal
  1353. //
  1354. // Synopsis:
  1355. // Get a handle to a presentation from a native representation.
  1356. //
  1357. // Arguments:
  1358. // [pstg] -- the storage in which the native content is
  1359. // [cfFormat] -- the native format to attempt to read
  1360. // [fOle10Native] -- attempt to read the OLE10_NATIVE_STREAM
  1361. // stream in that format; if this is FALSE, we read the
  1362. // OLE_CONTENTS_STREAM
  1363. //
  1364. // Returns:
  1365. // HRESULT
  1366. //
  1367. // Notes:
  1368. //
  1369. // History:
  1370. // 12/05/93 - ChrisWe - file inspection and cleanup
  1371. //
  1372. //-----------------------------------------------------------------------------
  1373. FARINTERNAL_(HANDLE) UtGetHPRESFromNative(LPSTORAGE pstg,
  1374. LPSTREAM pstm, CLIPFORMAT cfFormat, BOOL fOle10Native);
  1375. //+-------------------------------------------------------------------------
  1376. //
  1377. // Function: ConvertPixelsToHIMETRIC
  1378. //
  1379. // Synopsis: Converts a pixel dimension to HIMETRIC units
  1380. //
  1381. // Effects:
  1382. //
  1383. // Arguments: [hdcRef] -- the reference DC
  1384. // [ulPels] -- dimension in pixel measurement
  1385. // [pulHIMETRIC] -- OUT param of converted HIMETRIC result
  1386. // [tDimension] -- indicates XDIMENSION or YDIMENSION of input
  1387. //
  1388. // Returns: S_OK, E_FAIL
  1389. //
  1390. // Algorithm: screen_mm * input_pels HIMETRICS/
  1391. // ---------------------- * / == HIMETRICS
  1392. // screen_pels /mm
  1393. //
  1394. // History: dd-mmm-yy Author Comment
  1395. // 04-Aug-94 Davepl Created
  1396. //
  1397. // Notes: We need to know whether the input size is in the X or
  1398. // Y dimension, since the aspect ratio could vary
  1399. //
  1400. //--------------------------------------------------------------------------
  1401. // This enumeration is used to indicate in which diretion a
  1402. // dimension, when passed as a parameter, is to be relative to.
  1403. // This is needed for our Pixel -> HIMETRIC conversion function,
  1404. // since the aspect ratio could vary by dimension.
  1405. typedef enum tagDIMENSION
  1406. {
  1407. XDIMENSION = 'X',
  1408. YDIMENSION = 'Y'
  1409. } DIMENSION;
  1410. FARINTERNAL ConvertPixelsToHIMETRIC (HDC hdcRef,
  1411. ULONG lPels,
  1412. ULONG * pulHIMETRIC,
  1413. DIMENSION tDimension);
  1414. //+-------------------------------------------------------------------------
  1415. //
  1416. // Function: IsTaskName
  1417. //
  1418. // Synopsis: Determines if the passed name is the current task
  1419. //
  1420. // Effects:
  1421. //
  1422. // Arguments: [lpszIn] -- Task name
  1423. //
  1424. // Returns: TRUE, FALSE
  1425. //
  1426. // History: dd-mmm-yy Author Comment
  1427. // 03-Mar-95 Scottsk Created
  1428. //
  1429. // Notes:
  1430. //
  1431. //--------------------------------------------------------------------------
  1432. FARINTERNAL_(BOOL) IsTaskName(LPCWSTR lpszIn);
  1433. //+-------------------------------------------------------------------------
  1434. //
  1435. // Function: utGetModuleName
  1436. //
  1437. // Synopsis: Get Module Name for current module
  1438. //
  1439. // Effects:
  1440. //
  1441. // Arguments: [lpszModuleName] -- Buffer to hold module name
  1442. // [dwLength] -- length in characters
  1443. //
  1444. // Returns: S_OK, E_UNEXPECTED, E_OUTOFMEMORY
  1445. //
  1446. // History: dd-mmm-yy Author Comment
  1447. // 06-Feb-97 Ronans Created
  1448. //
  1449. //--------------------------------------------------------------------------
  1450. FARINTERNAL utGetModuleName(LPWSTR lpszModuleName, DWORD dwLength);
  1451. //+-------------------------------------------------------------------------
  1452. //
  1453. // Function: utGetAppIdForModule
  1454. //
  1455. // Synopsis: Get AppID for the current module in string form
  1456. //
  1457. // Effects:
  1458. //
  1459. // Arguments: [lpszAppId] -- Buffer to hold string represntation of AppId
  1460. // [dwLength] -- length of buffer in characters
  1461. //
  1462. // Returns: S_OK, E_UNEXPECTED, E_OUTOFMEMORY or error value from
  1463. // registry functions.
  1464. //
  1465. // History: dd-mmm-yy Author Comment
  1466. // 06-Feb-97 Ronans Created
  1467. //
  1468. //--------------------------------------------------------------------------
  1469. FARINTERNAL utGetAppIdForModule(LPWSTR lpszAppId, DWORD dwLength);
  1470. //+-------------------------------------------------------------------------
  1471. //
  1472. // Function: UtGetDvtd16Info
  1473. // UtConvertDvtd16toDvtd32
  1474. //
  1475. // UtGetDvtd32Info
  1476. // UtConvertDvtd32toDvtd16
  1477. //
  1478. // Synopsis: Utility functions for converting Ansi to Unicode DVTARGETDEVICEs
  1479. //
  1480. // Algorithm: UtGetDvtdXXInfo gets sizing data, which is then passed to
  1481. // UtConvertDvtdXXtoDvtdXX to perform the conversion.
  1482. //
  1483. // History: 06-May-94 AlexT Created
  1484. //
  1485. // Notes: Here's a sample usage of these functions:
  1486. //
  1487. // // pdvtd16 is a Ansi DVTARGETDEVICE
  1488. // DVTDINFO dvtdInfo;
  1489. // DVTARGETDEVICE pdvtd32;
  1490. //
  1491. // hr = UtGetDvtd16Info(pdvtd16, &dvtdInfo);
  1492. // // check hr
  1493. // pdvtd32 = CoTaskMemAlloc(dvtdInfo.cbConvertSize);
  1494. // // check pdvtd32
  1495. // hr = UtConvertDvtd16toDvtd32(pdvtd16, &dvtdInfo, pdvtd32);
  1496. // // check hr
  1497. // // pdvtd32 now contains the converted data
  1498. //
  1499. //--------------------------------------------------------------------------
  1500. typedef struct
  1501. {
  1502. UINT cbConvertSize;
  1503. UINT cchDrvName;
  1504. UINT cchDevName;
  1505. UINT cchPortName;
  1506. } DVTDINFO, *PDVTDINFO;
  1507. extern "C" HRESULT UtGetDvtd16Info(DVTARGETDEVICE const UNALIGNED *pdvtd16,
  1508. PDVTDINFO pdvtdInfo);
  1509. extern "C" HRESULT UtConvertDvtd16toDvtd32(DVTARGETDEVICE const UNALIGNED *pdvtd16,
  1510. DVTDINFO const *pdvtdInfo,
  1511. DVTARGETDEVICE *pdvtd32);
  1512. extern "C" HRESULT UtGetDvtd32Info(DVTARGETDEVICE const *pdvtd32,
  1513. PDVTDINFO pdvtdInfo);
  1514. extern "C" HRESULT UtConvertDvtd32toDvtd16(DVTARGETDEVICE const *pdvtd32,
  1515. DVTDINFO const *pdvtdInfo,
  1516. DVTARGETDEVICE UNALIGNED *pdvtd16);
  1517. class CStdIdentity;
  1518. HRESULT CreateEmbeddingServerHandler(CStdIdentity *pStdId, IUnknown **ppunkServerHandler);
  1519. // Number to wide-char conversion routine. See xtow.c for description.
  1520. extern "C" BOOL __cdecl our_ultow(
  1521. unsigned long val,
  1522. wchar_t *buf,
  1523. int bufsize,
  1524. int radix
  1525. );
  1526. #endif // _UTILS_H