TranslationExtensions.pas 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. {
  2. File: HIToolbox/TranslationExtensions.h
  3. Contains: Macintosh Easy Open Translation Extension Interfaces.
  4. Version: HIToolbox-437~1
  5. Copyright: © 1993-2008 by Apple Computer, Inc., all rights reserved.
  6. Bugs?: For bug reports, consult the following page on
  7. the World Wide Web:
  8. http://www.freepascal.org/bugs.html
  9. }
  10. { Pascal Translation Updated: Peter N Lewis, <[email protected]>, August 2005 }
  11. { Pascal Translation Updated: Jonas Maebe, <[email protected]>, October 2009 }
  12. {
  13. Modified for use with Free Pascal
  14. Version 308
  15. Please report any bugs to <[email protected]>
  16. }
  17. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  18. {$mode macpas}
  19. {$packenum 1}
  20. {$macro on}
  21. {$inline on}
  22. {$calling mwpascal}
  23. unit TranslationExtensions;
  24. interface
  25. {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
  26. {$setc GAP_INTERFACES_VERSION := $0308}
  27. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  28. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  29. {$endc}
  30. {$ifc defined CPUPOWERPC and defined CPUI386}
  31. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  32. {$endc}
  33. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  34. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  35. {$endc}
  36. {$ifc not defined __ppc__ and defined CPUPOWERPC32}
  37. {$setc __ppc__ := 1}
  38. {$elsec}
  39. {$setc __ppc__ := 0}
  40. {$endc}
  41. {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
  42. {$setc __ppc64__ := 1}
  43. {$elsec}
  44. {$setc __ppc64__ := 0}
  45. {$endc}
  46. {$ifc not defined __i386__ and defined CPUI386}
  47. {$setc __i386__ := 1}
  48. {$elsec}
  49. {$setc __i386__ := 0}
  50. {$endc}
  51. {$ifc not defined __x86_64__ and defined CPUX86_64}
  52. {$setc __x86_64__ := 1}
  53. {$elsec}
  54. {$setc __x86_64__ := 0}
  55. {$endc}
  56. {$ifc not defined __arm__ and defined CPUARM}
  57. {$setc __arm__ := 1}
  58. {$elsec}
  59. {$setc __arm__ := 0}
  60. {$endc}
  61. {$ifc defined cpu64}
  62. {$setc __LP64__ := 1}
  63. {$elsec}
  64. {$setc __LP64__ := 0}
  65. {$endc}
  66. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  67. {$error Conflicting definitions for __ppc__ and __i386__}
  68. {$endc}
  69. {$ifc defined __ppc__ and __ppc__}
  70. {$setc TARGET_CPU_PPC := TRUE}
  71. {$setc TARGET_CPU_PPC64 := FALSE}
  72. {$setc TARGET_CPU_X86 := FALSE}
  73. {$setc TARGET_CPU_X86_64 := FALSE}
  74. {$setc TARGET_CPU_ARM := FALSE}
  75. {$setc TARGET_OS_MAC := TRUE}
  76. {$setc TARGET_OS_IPHONE := FALSE}
  77. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  78. {$elifc defined __ppc64__ and __ppc64__}
  79. {$setc TARGET_CPU_PPC := FALSE}
  80. {$setc TARGET_CPU_PPC64 := TRUE}
  81. {$setc TARGET_CPU_X86 := FALSE}
  82. {$setc TARGET_CPU_X86_64 := FALSE}
  83. {$setc TARGET_CPU_ARM := FALSE}
  84. {$setc TARGET_OS_MAC := TRUE}
  85. {$setc TARGET_OS_IPHONE := FALSE}
  86. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  87. {$elifc defined __i386__ and __i386__}
  88. {$setc TARGET_CPU_PPC := FALSE}
  89. {$setc TARGET_CPU_PPC64 := FALSE}
  90. {$setc TARGET_CPU_X86 := TRUE}
  91. {$setc TARGET_CPU_X86_64 := FALSE}
  92. {$setc TARGET_CPU_ARM := FALSE}
  93. {$ifc defined(iphonesim)}
  94. {$setc TARGET_OS_MAC := FALSE}
  95. {$setc TARGET_OS_IPHONE := TRUE}
  96. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  97. {$elsec}
  98. {$setc TARGET_OS_MAC := TRUE}
  99. {$setc TARGET_OS_IPHONE := FALSE}
  100. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  101. {$endc}
  102. {$elifc defined __x86_64__ and __x86_64__}
  103. {$setc TARGET_CPU_PPC := FALSE}
  104. {$setc TARGET_CPU_PPC64 := FALSE}
  105. {$setc TARGET_CPU_X86 := FALSE}
  106. {$setc TARGET_CPU_X86_64 := TRUE}
  107. {$setc TARGET_CPU_ARM := FALSE}
  108. {$setc TARGET_OS_MAC := TRUE}
  109. {$setc TARGET_OS_IPHONE := FALSE}
  110. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  111. {$elifc defined __arm__ and __arm__}
  112. {$setc TARGET_CPU_PPC := FALSE}
  113. {$setc TARGET_CPU_PPC64 := FALSE}
  114. {$setc TARGET_CPU_X86 := FALSE}
  115. {$setc TARGET_CPU_X86_64 := FALSE}
  116. {$setc TARGET_CPU_ARM := TRUE}
  117. { will require compiler define when/if other Apple devices with ARM cpus ship }
  118. {$setc TARGET_OS_MAC := FALSE}
  119. {$setc TARGET_OS_IPHONE := TRUE}
  120. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  121. {$elsec}
  122. {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ is defined.}
  123. {$endc}
  124. {$ifc defined __LP64__ and __LP64__ }
  125. {$setc TARGET_CPU_64 := TRUE}
  126. {$elsec}
  127. {$setc TARGET_CPU_64 := FALSE}
  128. {$endc}
  129. {$ifc defined FPC_BIG_ENDIAN}
  130. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  131. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  132. {$elifc defined FPC_LITTLE_ENDIAN}
  133. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  134. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  135. {$elsec}
  136. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  137. {$endc}
  138. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  139. {$setc CALL_NOT_IN_CARBON := FALSE}
  140. {$setc OLDROUTINENAMES := FALSE}
  141. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  142. {$setc OPAQUE_UPP_TYPES := TRUE}
  143. {$setc OTCARBONAPPLICATION := TRUE}
  144. {$setc OTKERNEL := FALSE}
  145. {$setc PM_USE_SESSION_APIS := TRUE}
  146. {$setc TARGET_API_MAC_CARBON := TRUE}
  147. {$setc TARGET_API_MAC_OS8 := FALSE}
  148. {$setc TARGET_API_MAC_OSX := TRUE}
  149. {$setc TARGET_CARBON := TRUE}
  150. {$setc TARGET_CPU_68K := FALSE}
  151. {$setc TARGET_CPU_MIPS := FALSE}
  152. {$setc TARGET_CPU_SPARC := FALSE}
  153. {$setc TARGET_OS_UNIX := FALSE}
  154. {$setc TARGET_OS_WIN32 := FALSE}
  155. {$setc TARGET_RT_MAC_68881 := FALSE}
  156. {$setc TARGET_RT_MAC_CFM := FALSE}
  157. {$setc TARGET_RT_MAC_MACHO := TRUE}
  158. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  159. {$setc TYPE_BOOL := FALSE}
  160. {$setc TYPE_EXTENDED := FALSE}
  161. {$setc TYPE_LONGLONG := TRUE}
  162. uses MacTypes,Files,QuickdrawTypes,Components;
  163. {$endc} {not MACOSALLINCLUDE}
  164. {$ifc TARGET_OS_MAC}
  165. {$ALIGN MAC68K}
  166. {
  167. Translation Extensions are no longer supported. Carbon clients interested in extending translations
  168. should use filter services as described in TranslationServices.h. The definitions below will NOT work
  169. for Carbon and are only defined for those files that need to build pre-Carbon applications.
  170. }
  171. const
  172. kSupportsFileTranslation = 1;
  173. kSupportsScrapTranslation = 2;
  174. kTranslatorCanGenerateFilename = 4;
  175. {****************************************************************************************}
  176. { better names for 4-char codes}
  177. type
  178. FileType = OSType;
  179. FileTypePtr = ^FileType;
  180. ScrapType = ResType;
  181. {****************************************************************************************}
  182. type
  183. TranslationAttributes = UInt32;
  184. const
  185. taDstDocNeedsResourceFork = 1;
  186. taDstIsAppTranslation = 2;
  187. {****************************************************************************************}
  188. type
  189. FileTypeSpecPtr = ^FileTypeSpec;
  190. FileTypeSpec = record
  191. format: FileType;
  192. hint: SIGNEDLONG;
  193. flags: TranslationAttributes; { taDstDocNeedsResourceFork, taDstIsAppTranslation}
  194. catInfoType: OSType;
  195. catInfoCreator: OSType;
  196. end;
  197. type
  198. FileTranslationList = record
  199. modDate: UNSIGNEDLONG;
  200. groupCount: UNSIGNEDLONG;
  201. { conceptual declarations:}
  202. { unsigned long group1SrcCount;}
  203. { unsigned long group1SrcEntrySize = sizeof(FileTypeSpec);}
  204. { FileTypeSpec group1SrcTypes[group1SrcCount]}
  205. { unsigned long group1DstCount;}
  206. { unsigned long group1DstEntrySize = sizeof(FileTypeSpec);}
  207. { FileTypeSpec group1DstTypes[group1DstCount]}
  208. end;
  209. FileTranslationListPtr = ^FileTranslationList;
  210. FileTranslationListHandle = ^FileTranslationListPtr;
  211. {****************************************************************************************}
  212. type
  213. ScrapTypeSpecPtr = ^ScrapTypeSpec;
  214. ScrapTypeSpec = record
  215. format: ScrapType;
  216. hint: SIGNEDLONG;
  217. end;
  218. type
  219. ScrapTranslationList = record
  220. modDate: UNSIGNEDLONG;
  221. groupCount: UNSIGNEDLONG;
  222. { conceptual declarations:}
  223. { unsigned long group1SrcCount;}
  224. { unsigned long group1SrcEntrySize = sizeof(ScrapTypeSpec);}
  225. { ScrapTypeSpec group1SrcTypes[group1SrcCount]}
  226. { unsigned long group1DstCount;}
  227. { unsigned long group1DstEntrySize = sizeof(ScrapTypeSpec);}
  228. { ScrapTypeSpec group1DstTypes[group1DstCount]}
  229. end;
  230. ScrapTranslationListPtr = ^ScrapTranslationList;
  231. ScrapTranslationListHandle = ^ScrapTranslationListPtr;
  232. {******************************************************************************************
  233. definition of callbacks to update progress dialog
  234. ******************************************************************************************}
  235. type
  236. TranslationRefNum = SIGNEDLONG;
  237. {******************************************************************************************
  238. This routine sets the advertisement in the top half of the progress dialog.
  239. It is called once at the beginning of your DoTranslateFile routine.
  240. Enter : refNum Translation reference supplied to DoTranslateFile.
  241. advertisement A handle to the picture to display. This must be non-purgable.
  242. Before returning from DoTranslateFile, you should dispose
  243. of the memory. (Normally, it is in the temp translation heap
  244. so it is cleaned up for you.)
  245. Exit : returns noErr, paramErr, or memFullErr
  246. ******************************************************************************************}
  247. {$ifc not TARGET_CPU_64}
  248. {
  249. * SetTranslationAdvertisement() *** DEPRECATED ***
  250. *
  251. * Deprecated:
  252. * There is no direct replacement at this time.
  253. *
  254. * Mac OS X threading:
  255. * Not thread safe
  256. *
  257. * Availability:
  258. * Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only] but deprecated in 10.3
  259. * CarbonLib: in CarbonLib 1.0 thru 1.0.2
  260. * Non-Carbon CFM: in Translation 1.0 and later
  261. }
  262. function SetTranslationAdvertisement( refNum: TranslationRefNum; advertisement: PicHandle ): OSErr; external name '_SetTranslationAdvertisement';
  263. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3 *)
  264. {******************************************************************************************
  265. This routine updates the progress bar in the progress dialog.
  266. It is called repeatedly from within your DoTranslateFile routine.
  267. It should be called often, so that the user will get feedback if
  268. he tries to cancel.
  269. Enter : refNum translation reference supplied to DoTranslateFile.
  270. progress percent complete (0-100)
  271. Exit : canceled TRUE if the user clicked the Cancel button, FALSE otherwise
  272. Return : noErr, paramErr, or memFullErr
  273. ******************************************************************************************}
  274. {
  275. * UpdateTranslationProgress() *** DEPRECATED ***
  276. *
  277. * Deprecated:
  278. * There is no direct replacement at this time.
  279. *
  280. * Mac OS X threading:
  281. * Not thread safe
  282. *
  283. * Availability:
  284. * Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only] but deprecated in 10.3
  285. * CarbonLib: in CarbonLib 1.0 thru 1.0.2
  286. * Non-Carbon CFM: in Translation 1.0 and later
  287. }
  288. function UpdateTranslationProgress( refNum: TranslationRefNum; percentDone: SInt16; var canceled: Boolean ): OSErr; external name '_UpdateTranslationProgress';
  289. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3 *)
  290. {******************************************************************************************
  291. Component Manager component selectors for translation extension routines
  292. ******************************************************************************************}
  293. {$endc} {not TARGET_CPU_64}
  294. const
  295. kTranslateGetFileTranslationList = 0;
  296. kTranslateIdentifyFile = 1;
  297. kTranslateTranslateFile = 2;
  298. kTranslateGetTranslatedFilename = 3;
  299. kTranslateGetScrapTranslationList = 10;
  300. kTranslateIdentifyScrap = 11;
  301. kTranslateTranslateScrap = 12;
  302. kTranslateGetScrapTranslationListConsideringData = 13;
  303. {******************************************************************************************
  304. routines which implement translation extensions
  305. ******************************************************************************************}
  306. type
  307. DoGetFileTranslationListProcPtr = function( self: ComponentInstance; translationList: FileTranslationListHandle ): ComponentResult;
  308. DoIdentifyFileProcPtr = function( self: ComponentInstance; const (*var*) theDocument: FSSpec; var docType: FileType ): ComponentResult;
  309. DoTranslateFileProcPtr = function( self: ComponentInstance; refNum: TranslationRefNum; const (*var*) sourceDocument: FSSpec; srcType: FileType; srcTypeHint: SIGNEDLONG; const (*var*) dstDoc: FSSpec; dstType: FileType; dstTypeHint: SIGNEDLONG ): ComponentResult;
  310. DoGetTranslatedFilenameProcPtr = function( self: ComponentInstance; dstType: FileType; dstTypeHint: SIGNEDLONG; var theDocument: FSSpec ): ComponentResult;
  311. DoGetScrapTranslationListProcPtr = function( self: ComponentInstance; list: ScrapTranslationListHandle ): ComponentResult;
  312. DoIdentifyScrapProcPtr = function( self: ComponentInstance; dataPtr: {const} UnivPtr; dataLength: Size; var dataFormat: ScrapType ): ComponentResult;
  313. DoTranslateScrapProcPtr = function( self: ComponentInstance; refNum: TranslationRefNum; srcDataPtr: {const} UnivPtr; srcDataLength: Size; srcType: ScrapType; srcTypeHint: SIGNEDLONG; dstData: Handle; dstType: ScrapType; dstTypeHint: SIGNEDLONG ): ComponentResult;
  314. {$endc} {TARGET_OS_MAC}
  315. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  316. end.
  317. {$endc} {not MACOSALLINCLUDE}