Team Fortress 2 Source Code as on 22/4/2020
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.

478 lines
17 KiB

  1. /*
  2. File: Translation.h
  3. Contains: Translation Manager (Macintosh Easy Open) Interfaces.
  4. Version: QuickTime 7.3
  5. Copyright: (c) 2007 (c) 1991-2001 by Apple Computer, Inc., all rights reserved.
  6. Bugs?: For bug reports, consult the following page on
  7. the World Wide Web:
  8. http://developer.apple.com/bugreporter/
  9. */
  10. #ifndef __TRANSLATION__
  11. #define __TRANSLATION__
  12. #ifndef __MACTYPES__
  13. #include <MacTypes.h>
  14. #endif
  15. #ifndef __FILES__
  16. #include <Files.h>
  17. #endif
  18. #ifndef __COMPONENTS__
  19. #include <Components.h>
  20. #endif
  21. #ifndef __TRANSLATIONEXTENSIONS__
  22. #include <TranslationExtensions.h>
  23. #endif
  24. #if PRAGMA_ONCE
  25. #pragma once
  26. #endif
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. #if PRAGMA_IMPORT
  31. #pragma import on
  32. #endif
  33. #if PRAGMA_STRUCT_ALIGN
  34. #pragma options align=mac68k
  35. #elif PRAGMA_STRUCT_PACKPUSH
  36. #pragma pack(push, 2)
  37. #elif PRAGMA_STRUCT_PACK
  38. #pragma pack(2)
  39. #endif
  40. /* enumerated types on how a document can be opened*/
  41. typedef short DocOpenMethod;
  42. enum {
  43. domCannot = 0,
  44. domNative = 1,
  45. domTranslateFirst = 2,
  46. domWildcard = 3
  47. };
  48. /* 0L terminated array of OSTypes, or FileTypes*/
  49. typedef OSType TypesBlock[64];
  50. typedef OSType * TypesBlockPtr;
  51. /* Progress dialog resource ID*/
  52. enum {
  53. kTranslationScrapProgressDialogID = -16555
  54. };
  55. /* block of data that describes how to translate*/
  56. struct FileTranslationSpec {
  57. OSType componentSignature;
  58. const void * translationSystemInfo;
  59. FileTypeSpec src;
  60. FileTypeSpec dst;
  61. };
  62. typedef struct FileTranslationSpec FileTranslationSpec;
  63. typedef FileTranslationSpec * FileTranslationSpecArrayPtr;
  64. typedef FileTranslationSpecArrayPtr * FileTranslationSpecArrayHandle;
  65. /*****************************************************************************************
  66. *
  67. * GetFileTypesThatAppCanNativelyOpen
  68. *
  69. * This routine returns a list of all FileTypes that an application can open by itself
  70. *
  71. * Enter: appVRefNumHint volume where application resides (can be wrong, and if is, will be used as a starting point)
  72. * appSignature signature (creator) of application
  73. * nativeTypes pointer to a buffer to be filled with up to 64 FileTypes
  74. *
  75. * Exit: nativeTypes zero terminated array of FileTypes that can be opened by app
  76. */
  77. /*
  78. * GetFileTypesThatAppCanNativelyOpen()
  79. *
  80. * Availability:
  81. * Non-Carbon CFM: in Translation 1.0 and later
  82. * CarbonLib: in CarbonLib 1.0 and later
  83. * Mac OS X: in version 10.0 and later
  84. */
  85. EXTERN_API( OSErr )
  86. GetFileTypesThatAppCanNativelyOpen(
  87. short appVRefNumHint,
  88. OSType appSignature,
  89. FileType * nativeTypes) TWOWORDINLINE(0x701C, 0xABFC);
  90. /*****************************************************************************************
  91. *
  92. * ExtendFileTypeList
  93. *
  94. * This routine makes a new list of file types that can be translated into a type in the given list
  95. * Used by StandardFile
  96. *
  97. * Enter: originalTypeList pointer to list of file types that can be opened
  98. * numberOriginalTypes number of file types in orgTypeList
  99. * extendedTypeList pointer to a buffer to be filled with file types
  100. * numberExtendedTypes max number of file types that can be put in extendedTypeList
  101. *
  102. * Exit: extendedTypeList buffer filled in with file types that can be translated
  103. * numberExtendedTypes number of file types put in extendedTypeList
  104. */
  105. /*
  106. * ExtendFileTypeList()
  107. *
  108. * Availability:
  109. * Non-Carbon CFM: in Translation 1.0 and later
  110. * CarbonLib: in CarbonLib 1.0 and later
  111. * Mac OS X: in version 10.0 and later
  112. */
  113. EXTERN_API( OSErr )
  114. ExtendFileTypeList(
  115. const FileType * originalTypeList,
  116. short numberOriginalTypes,
  117. FileType * extendedTypeList,
  118. short * numberExtendedTypes) TWOWORDINLINE(0x7009, 0xABFC);
  119. /*****************************************************************************************
  120. *
  121. *
  122. * This routine checks if a file can be opened by a particular application.
  123. * If so, it returns if it needs to be translated first, and if so then how.
  124. * The FileTypes that the app can open are specified by nativelyOpenableTypes,
  125. * or if it is NULL, GetFileTypesThatAppCanNativelyOpen is called.
  126. *
  127. * Enter: targetDocument document to check if it can be opened
  128. * appVRefNumHint vRefNum of application to open doc ( can be wrong, and if is, will be used as a starting point)
  129. * appSignature signature (creator) of application to open doc
  130. * nativeTypes zero terminated list of FileTypes app can open natively, or NULL to use default list
  131. * onlyNative whether to consider if document can be translated before opening
  132. * howToOpen pointer to buffer in which to put how the document can be opened
  133. * howToTranslate pointer to buffer in which to put a FileTranslationSpec record
  134. *
  135. * Exit: howToOpen whether file needs to be translated to be read
  136. * howToTranslate if file can be translated, buffer filled in with how to translate
  137. * returns noErr, noPrefAppErr
  138. */
  139. /*
  140. * CanDocBeOpened()
  141. *
  142. * Availability:
  143. * Non-Carbon CFM: in Translation 1.0 and later
  144. * CarbonLib: in CarbonLib 1.0 and later
  145. * Mac OS X: in version 10.0 and later
  146. */
  147. EXTERN_API( OSErr )
  148. CanDocBeOpened(
  149. const FSSpec * targetDocument,
  150. short appVRefNumHint,
  151. OSType appSignature,
  152. const FileType * nativeTypes,
  153. Boolean onlyNative,
  154. DocOpenMethod * howToOpen,
  155. FileTranslationSpec * howToTranslate) TWOWORDINLINE(0x701E, 0xABFC);
  156. /*****************************************************************************************
  157. *
  158. * GetFileTranslationPaths
  159. *
  160. * This routine returns a list of all ways a translation can occure to or from a FileType.
  161. * The app is checked to exist. The hint for each app is the VRefNum and DTRefNum
  162. *
  163. * Enter: srcDoc source file or NULL for all matches
  164. * dstDoc destination FileType or 0 for all matches
  165. * maxResultCount
  166. * resultBuffer
  167. * Exit: number of paths
  168. */
  169. /*
  170. * GetFileTranslationPaths()
  171. *
  172. * Availability:
  173. * Non-Carbon CFM: in Translation 1.0 and later
  174. * CarbonLib: in CarbonLib 1.0 and later
  175. * Mac OS X: in version 10.0 and later
  176. */
  177. EXTERN_API( short )
  178. GetFileTranslationPaths(
  179. const FSSpec * srcDocument,
  180. FileType dstDocType,
  181. unsigned short maxResultCount,
  182. FileTranslationSpecArrayPtr resultBuffer) TWOWORDINLINE(0x7038, 0xABFC);
  183. /*****************************************************************************************
  184. *
  185. * GetPathFromTranslationDialog
  186. *
  187. * This routine, with a given document, application, and a passed typelist will display the
  188. * Macintosh Easy Open translation dialog allowing the user to make a choice. The choice
  189. * made will be written as a preference (so the next call to CanDocBeOpened() will work).
  190. * The routine returns the translation path information.
  191. *
  192. * Enter: theDocument FSSpec to document to open
  193. * theApplication FSSpec to application to open document
  194. * typeList Nil terminated list of FileType's (e.g. SFTypeList-like) of types
  195. * you would like the documented translated to. Order most perferred
  196. * to least.
  197. *
  198. * Exit: howToOpen Translation method needed to open document
  199. * howToTranslate Translation specification
  200. * returns Any errors that might occur.
  201. */
  202. /*
  203. * GetPathFromTranslationDialog()
  204. *
  205. * Availability:
  206. * Non-Carbon CFM: in Translation 1.0 and later
  207. * CarbonLib: in CarbonLib 1.0 and later
  208. * Mac OS X: in version 10.0 and later
  209. */
  210. EXTERN_API( OSErr )
  211. GetPathFromTranslationDialog(
  212. const FSSpec * theDocument,
  213. const FSSpec * theApplication,
  214. TypesBlockPtr typeList,
  215. DocOpenMethod * howToOpen,
  216. FileTranslationSpec * howToTranslate) TWOWORDINLINE(0x7037, 0xABFC);
  217. /*****************************************************************************************
  218. *
  219. * TranslateFile
  220. *
  221. * This routine reads a file of one format and writes it to another file in another format.
  222. * The information on how to translated is generated by the routine CanDocBeOpened.
  223. * TranslateFile calls through to the TranslateFile Extension's DoTranslateFile routine.
  224. * The destination file must not exist. It is created by this routine.
  225. *
  226. * Enter: sourceDocument input file to translate
  227. * destinationDocument output file of translation
  228. * howToTranslate pointer to info on how to translate
  229. * Exit: returns noErr, badTranslationSpecErr
  230. */
  231. /*
  232. * TranslateFile()
  233. *
  234. * Availability:
  235. * Non-Carbon CFM: in Translation 1.0 and later
  236. * CarbonLib: in CarbonLib 1.0 and later
  237. * Mac OS X: in version 10.0 and later
  238. */
  239. EXTERN_API( OSErr )
  240. TranslateFile(
  241. const FSSpec * sourceDocument,
  242. const FSSpec * destinationDocument,
  243. const FileTranslationSpec * howToTranslate) TWOWORDINLINE(0x700C, 0xABFC);
  244. /*****************************************************************************************
  245. *
  246. * GetDocumentKindString
  247. *
  248. * This routine returns the string the Finder should show for the "kind" of a document
  249. * in the GetInfo window and in the kind column of a list view.
  250. *
  251. * Enter: docVRefNum The volume containing the document
  252. * docType The catInfo.fdType of the document
  253. * docCreator The catInfo.fdCreator of the document
  254. * kindString pointer to where to return the string
  255. *
  256. * Exit: kindString pascal string. Ex: "\pSurfCalc spreadsheet"
  257. * returns noErr, or afpItemNoFound if kind could not be determined
  258. */
  259. /*
  260. * GetDocumentKindString()
  261. *
  262. * Availability:
  263. * Non-Carbon CFM: in Translation 1.0 and later
  264. * CarbonLib: in CarbonLib 1.0 and later
  265. * Mac OS X: in version 10.0 and later
  266. */
  267. EXTERN_API( OSErr )
  268. GetDocumentKindString(
  269. short docVRefNum,
  270. OSType docType,
  271. OSType docCreator,
  272. Str63 kindString) TWOWORDINLINE(0x7016, 0xABFC);
  273. /*****************************************************************************************
  274. *
  275. * GetTranslationExtensionName
  276. *
  277. * This routine returns the translation system name from a specified TranslationSpec
  278. *
  279. * Enter: translationMethod The translation path to get the translation name from
  280. *
  281. * Exit: extensionName The name of the translation system
  282. * returns Any errors that might occur
  283. */
  284. /*
  285. * GetTranslationExtensionName()
  286. *
  287. * Availability:
  288. * Non-Carbon CFM: in Translation 1.0 and later
  289. * CarbonLib: in CarbonLib 1.0 and later
  290. * Mac OS X: in version 10.0 and later
  291. */
  292. EXTERN_API( OSErr )
  293. GetTranslationExtensionName(
  294. const FileTranslationSpec * translationMethod,
  295. Str31 extensionName) TWOWORDINLINE(0x7036, 0xABFC);
  296. /*****************************************************************************************
  297. *
  298. * GetScrapDataProcPtr
  299. *
  300. * This is a prototype for the function you must supply to TranslateScrap. It is called to
  301. * get the data to be translated. The first call TranslateScrap will make to this is to
  302. * ask for the 'fmts' data. That is a special. You should resize and fill in the handle
  303. * with a list all the formats that you have available to be translated, and the length of each.
  304. * (See I.M. VI 4-23 for details of 'fmts'). It will then be called again asking for one of
  305. * the formats that 'fmts' list said was available.
  306. *
  307. * Enter: requestedFormat Format of data that TranslateScrap needs.
  308. * dataH Handle in which to put the requested data
  309. * srcDataGetterRefCon Extra parameter for you passed to TranslateScrap
  310. *
  311. * Exit: dataH Handle is resized and filled with data in requested format
  312. */
  313. typedef CALLBACK_API( OSErr , GetScrapDataProcPtr )(ScrapType requestedFormat, Handle dataH, void *srcDataGetterRefCon);
  314. typedef STACK_UPP_TYPE(GetScrapDataProcPtr) GetScrapDataUPP;
  315. /*
  316. * NewGetScrapDataUPP()
  317. *
  318. * Availability:
  319. * Non-Carbon CFM: available as macro/inline
  320. * CarbonLib: in CarbonLib 1.0 and later
  321. * Mac OS X: in version 10.0 and later
  322. */
  323. EXTERN_API_C( GetScrapDataUPP )
  324. NewGetScrapDataUPP(GetScrapDataProcPtr userRoutine);
  325. #if !OPAQUE_UPP_TYPES
  326. enum { uppGetScrapDataProcInfo = 0x00000FE0 }; /* pascal 2_bytes Func(4_bytes, 4_bytes, 4_bytes) */
  327. #ifdef __cplusplus
  328. inline DEFINE_API_C(GetScrapDataUPP) NewGetScrapDataUPP(GetScrapDataProcPtr userRoutine) { return (GetScrapDataUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppGetScrapDataProcInfo, GetCurrentArchitecture()); }
  329. #else
  330. #define NewGetScrapDataUPP(userRoutine) (GetScrapDataUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppGetScrapDataProcInfo, GetCurrentArchitecture())
  331. #endif
  332. #endif
  333. /*
  334. * DisposeGetScrapDataUPP()
  335. *
  336. * Availability:
  337. * Non-Carbon CFM: available as macro/inline
  338. * CarbonLib: in CarbonLib 1.0 and later
  339. * Mac OS X: in version 10.0 and later
  340. */
  341. EXTERN_API_C( void )
  342. DisposeGetScrapDataUPP(GetScrapDataUPP userUPP);
  343. #if !OPAQUE_UPP_TYPES
  344. #ifdef __cplusplus
  345. inline DEFINE_API_C(void) DisposeGetScrapDataUPP(GetScrapDataUPP userUPP) { DisposeRoutineDescriptor((UniversalProcPtr)userUPP); }
  346. #else
  347. #define DisposeGetScrapDataUPP(userUPP) DisposeRoutineDescriptor(userUPP)
  348. #endif
  349. #endif
  350. /*
  351. * InvokeGetScrapDataUPP()
  352. *
  353. * Availability:
  354. * Non-Carbon CFM: available as macro/inline
  355. * CarbonLib: in CarbonLib 1.0 and later
  356. * Mac OS X: in version 10.0 and later
  357. */
  358. EXTERN_API_C( OSErr )
  359. InvokeGetScrapDataUPP(
  360. ScrapType requestedFormat,
  361. Handle dataH,
  362. void * srcDataGetterRefCon,
  363. GetScrapDataUPP userUPP);
  364. #if !OPAQUE_UPP_TYPES
  365. #ifdef __cplusplus
  366. inline DEFINE_API_C(OSErr) InvokeGetScrapDataUPP(ScrapType requestedFormat, Handle dataH, void * srcDataGetterRefCon, GetScrapDataUPP userUPP) { return (OSErr)CALL_THREE_PARAMETER_UPP(userUPP, uppGetScrapDataProcInfo, requestedFormat, dataH, srcDataGetterRefCon); }
  367. #else
  368. #define InvokeGetScrapDataUPP(requestedFormat, dataH, srcDataGetterRefCon, userUPP) (OSErr)CALL_THREE_PARAMETER_UPP((userUPP), uppGetScrapDataProcInfo, (requestedFormat), (dataH), (srcDataGetterRefCon))
  369. #endif
  370. #endif
  371. #if CALL_NOT_IN_CARBON || OLDROUTINENAMES
  372. /* support for pre-Carbon UPP routines: New...Proc and Call...Proc */
  373. #define NewGetScrapDataProc(userRoutine) NewGetScrapDataUPP(userRoutine)
  374. #define CallGetScrapDataProc(userRoutine, requestedFormat, dataH, srcDataGetterRefCon) InvokeGetScrapDataUPP(requestedFormat, dataH, srcDataGetterRefCon, userRoutine)
  375. #endif /* CALL_NOT_IN_CARBON */
  376. typedef GetScrapDataUPP GetScrapData;
  377. /*****************************************************************************************
  378. *
  379. * TranslateScrap
  380. *
  381. * This routine resizes the destination handle and fills it with data of the requested format.
  382. * The data is generated by translated one or more source formats of data supplied by
  383. * the procedure srcDataGetter.
  384. * This routine is automatically called by GetScrap and ReadEdition. You only need to call
  385. * this if you need to translated scrap style data, but are not using the ScrapMgr or EditionMgr.
  386. *
  387. * Enter: sourceDataGetter Pointer to routine that can get src data
  388. * sourceDataGetterRefCon Extra parameter for dataGetter
  389. * destinationFormat Format of data desired
  390. * destinationData Handle in which to store translated data
  391. *
  392. * Exit: dstData Handle is resized and filled with data in requested format
  393. */
  394. /*
  395. * TranslateScrap()
  396. *
  397. * Availability:
  398. * Non-Carbon CFM: in Translation 1.0 and later
  399. * CarbonLib: in CarbonLib 1.0 and later
  400. * Mac OS X: in version 10.0 and later
  401. */
  402. EXTERN_API( OSErr )
  403. TranslateScrap(
  404. GetScrapDataUPP sourceDataGetter,
  405. void * sourceDataGetterRefCon,
  406. ScrapType destinationFormat,
  407. Handle destinationData,
  408. short progressDialogID) TWOWORDINLINE(0x700E, 0xABFC);
  409. #if PRAGMA_STRUCT_ALIGN
  410. #pragma options align=reset
  411. #elif PRAGMA_STRUCT_PACKPUSH
  412. #pragma pack(pop)
  413. #elif PRAGMA_STRUCT_PACK
  414. #pragma pack()
  415. #endif
  416. #ifdef PRAGMA_IMPORT_OFF
  417. #pragma import off
  418. #elif PRAGMA_IMPORT
  419. #pragma import reset
  420. #endif
  421. #ifdef __cplusplus
  422. }
  423. #endif
  424. #endif /* __TRANSLATION__ */