TranslationExtensions.pas 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. {
  2. File: HIToolbox/TranslationExtensions.h
  3. Contains: Macintosh Easy Open Translation Extension Interfaces.
  4. Version: HIToolbox-219.4.81~2
  5. Copyright: © 1993-2005 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. {
  12. Modified for use with Free Pascal
  13. Version 200
  14. Please report any bugs to <[email protected]>
  15. }
  16. {$mode macpas}
  17. {$packenum 1}
  18. {$macro on}
  19. {$inline on}
  20. {$CALLING MWPASCAL}
  21. unit TranslationExtensions;
  22. interface
  23. {$setc UNIVERSAL_INTERFACES_VERSION := $0342}
  24. {$setc GAP_INTERFACES_VERSION := $0200}
  25. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  26. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  27. {$endc}
  28. {$ifc defined CPUPOWERPC and defined CPUI386}
  29. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  30. {$endc}
  31. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  32. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  33. {$endc}
  34. {$ifc not defined __ppc__ and defined CPUPOWERPC}
  35. {$setc __ppc__ := 1}
  36. {$elsec}
  37. {$setc __ppc__ := 0}
  38. {$endc}
  39. {$ifc not defined __i386__ and defined CPUI386}
  40. {$setc __i386__ := 1}
  41. {$elsec}
  42. {$setc __i386__ := 0}
  43. {$endc}
  44. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  45. {$error Conflicting definitions for __ppc__ and __i386__}
  46. {$endc}
  47. {$ifc defined __ppc__ and __ppc__}
  48. {$setc TARGET_CPU_PPC := TRUE}
  49. {$setc TARGET_CPU_X86 := FALSE}
  50. {$elifc defined __i386__ and __i386__}
  51. {$setc TARGET_CPU_PPC := FALSE}
  52. {$setc TARGET_CPU_X86 := TRUE}
  53. {$elsec}
  54. {$error Neither __ppc__ nor __i386__ is defined.}
  55. {$endc}
  56. {$setc TARGET_CPU_PPC_64 := FALSE}
  57. {$ifc defined FPC_BIG_ENDIAN}
  58. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  59. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  60. {$elifc defined FPC_LITTLE_ENDIAN}
  61. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  62. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  63. {$elsec}
  64. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  65. {$endc}
  66. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  67. {$setc CALL_NOT_IN_CARBON := FALSE}
  68. {$setc OLDROUTINENAMES := FALSE}
  69. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  70. {$setc OPAQUE_UPP_TYPES := TRUE}
  71. {$setc OTCARBONAPPLICATION := TRUE}
  72. {$setc OTKERNEL := FALSE}
  73. {$setc PM_USE_SESSION_APIS := TRUE}
  74. {$setc TARGET_API_MAC_CARBON := TRUE}
  75. {$setc TARGET_API_MAC_OS8 := FALSE}
  76. {$setc TARGET_API_MAC_OSX := TRUE}
  77. {$setc TARGET_CARBON := TRUE}
  78. {$setc TARGET_CPU_68K := FALSE}
  79. {$setc TARGET_CPU_MIPS := FALSE}
  80. {$setc TARGET_CPU_SPARC := FALSE}
  81. {$setc TARGET_OS_MAC := TRUE}
  82. {$setc TARGET_OS_UNIX := FALSE}
  83. {$setc TARGET_OS_WIN32 := FALSE}
  84. {$setc TARGET_RT_MAC_68881 := FALSE}
  85. {$setc TARGET_RT_MAC_CFM := FALSE}
  86. {$setc TARGET_RT_MAC_MACHO := TRUE}
  87. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  88. {$setc TYPE_BOOL := FALSE}
  89. {$setc TYPE_EXTENDED := FALSE}
  90. {$setc TYPE_LONGLONG := TRUE}
  91. uses MacTypes,Files,Quickdraw,Components;
  92. {$ALIGN MAC68K}
  93. {
  94. Translation Extensions are no longer supported. Carbon clients interested in extending translations
  95. should use filter services as described in TranslationServices.h. The definitions below will NOT work
  96. for Carbon and are only defined for those files that need to build pre-Carbon applications.
  97. }
  98. const
  99. kSupportsFileTranslation = 1;
  100. kSupportsScrapTranslation = 2;
  101. kTranslatorCanGenerateFilename = 4;
  102. {****************************************************************************************}
  103. { better names for 4-char codes}
  104. type
  105. FileType = OSType;
  106. FileTypePtr = ^FileType;
  107. ScrapType = ResType;
  108. {****************************************************************************************}
  109. type
  110. TranslationAttributes = UInt32;
  111. const
  112. taDstDocNeedsResourceFork = 1;
  113. taDstIsAppTranslation = 2;
  114. {****************************************************************************************}
  115. type
  116. FileTypeSpecPtr = ^FileTypeSpec;
  117. FileTypeSpec = record
  118. format: FileType;
  119. hint: SInt32;
  120. flags: TranslationAttributes; { taDstDocNeedsResourceFork, taDstIsAppTranslation}
  121. catInfoType: OSType;
  122. catInfoCreator: OSType;
  123. end;
  124. type
  125. FileTranslationList = record
  126. modDate: UInt32;
  127. groupCount: UInt32;
  128. { conceptual declarations:}
  129. { unsigned long group1SrcCount;}
  130. { unsigned long group1SrcEntrySize = sizeof(FileTypeSpec);}
  131. { FileTypeSpec group1SrcTypes[group1SrcCount]}
  132. { unsigned long group1DstCount;}
  133. { unsigned long group1DstEntrySize = sizeof(FileTypeSpec);}
  134. { FileTypeSpec group1DstTypes[group1DstCount]}
  135. end;
  136. FileTranslationListPtr = ^FileTranslationList;
  137. FileTranslationListHandle = ^FileTranslationListPtr;
  138. {****************************************************************************************}
  139. type
  140. ScrapTypeSpecPtr = ^ScrapTypeSpec;
  141. ScrapTypeSpec = record
  142. format: ScrapType;
  143. hint: SInt32;
  144. end;
  145. type
  146. ScrapTranslationList = record
  147. modDate: UInt32;
  148. groupCount: UInt32;
  149. { conceptual declarations:}
  150. { unsigned long group1SrcCount;}
  151. { unsigned long group1SrcEntrySize = sizeof(ScrapTypeSpec);}
  152. { ScrapTypeSpec group1SrcTypes[group1SrcCount]}
  153. { unsigned long group1DstCount;}
  154. { unsigned long group1DstEntrySize = sizeof(ScrapTypeSpec);}
  155. { ScrapTypeSpec group1DstTypes[group1DstCount]}
  156. end;
  157. ScrapTranslationListPtr = ^ScrapTranslationList;
  158. ScrapTranslationListHandle = ^ScrapTranslationListPtr;
  159. {******************************************************************************************
  160. definition of callbacks to update progress dialog
  161. ******************************************************************************************}
  162. type
  163. TranslationRefNum = SInt32;
  164. {******************************************************************************************
  165. This routine sets the advertisement in the top half of the progress dialog.
  166. It is called once at the beginning of your DoTranslateFile routine.
  167. Enter : refNum Translation reference supplied to DoTranslateFile.
  168. advertisement A handle to the picture to display. This must be non-purgable.
  169. Before returning from DoTranslateFile, you should dispose
  170. of the memory. (Normally, it is in the temp translation heap
  171. so it is cleaned up for you.)
  172. Exit : returns noErr, paramErr, or memFullErr
  173. ******************************************************************************************}
  174. {
  175. * SetTranslationAdvertisement() *** DEPRECATED ***
  176. *
  177. * Deprecated:
  178. * There is no direct replacement at this time.
  179. *
  180. * Mac OS X threading:
  181. * Not thread safe
  182. *
  183. * Availability:
  184. * Mac OS X: in version 10.0 and later in Carbon.framework but deprecated in 10.3
  185. * CarbonLib: in CarbonLib 1.0 thru 1.0.2
  186. * Non-Carbon CFM: in Translation 1.0 and later
  187. }
  188. function SetTranslationAdvertisement( refNum: TranslationRefNum; advertisement: PicHandle ): OSErr; external name '_SetTranslationAdvertisement';
  189. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3 *)
  190. {******************************************************************************************
  191. This routine updates the progress bar in the progress dialog.
  192. It is called repeatedly from within your DoTranslateFile routine.
  193. It should be called often, so that the user will get feedback if
  194. he tries to cancel.
  195. Enter : refNum translation reference supplied to DoTranslateFile.
  196. progress percent complete (0-100)
  197. Exit : canceled TRUE if the user clicked the Cancel button, FALSE otherwise
  198. Return : noErr, paramErr, or memFullErr
  199. ******************************************************************************************}
  200. {
  201. * UpdateTranslationProgress() *** DEPRECATED ***
  202. *
  203. * Deprecated:
  204. * There is no direct replacement at this time.
  205. *
  206. * Mac OS X threading:
  207. * Not thread safe
  208. *
  209. * Availability:
  210. * Mac OS X: in version 10.0 and later in Carbon.framework but deprecated in 10.3
  211. * CarbonLib: in CarbonLib 1.0 thru 1.0.2
  212. * Non-Carbon CFM: in Translation 1.0 and later
  213. }
  214. function UpdateTranslationProgress( refNum: TranslationRefNum; percentDone: SInt16; var canceled: Boolean ): OSErr; external name '_UpdateTranslationProgress';
  215. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3 *)
  216. {******************************************************************************************
  217. Component Manager component selectors for translation extension routines
  218. ******************************************************************************************}
  219. const
  220. kTranslateGetFileTranslationList = 0;
  221. kTranslateIdentifyFile = 1;
  222. kTranslateTranslateFile = 2;
  223. kTranslateGetTranslatedFilename = 3;
  224. kTranslateGetScrapTranslationList = 10;
  225. kTranslateIdentifyScrap = 11;
  226. kTranslateTranslateScrap = 12;
  227. kTranslateGetScrapTranslationListConsideringData = 13;
  228. {******************************************************************************************
  229. routines which implement translation extensions
  230. ******************************************************************************************}
  231. type
  232. DoGetFileTranslationListProcPtr = function( self: ComponentInstance; translationList: FileTranslationListHandle ): ComponentResult;
  233. DoIdentifyFileProcPtr = function( self: ComponentInstance; const (*var*) theDocument: FSSpec; var docType: FileType ): ComponentResult;
  234. DoTranslateFileProcPtr = function( self: ComponentInstance; refNum: TranslationRefNum; const (*var*) sourceDocument: FSSpec; srcType: FileType; srcTypeHint: SInt32; const (*var*) dstDoc: FSSpec; dstType: FileType; dstTypeHint: SInt32 ): ComponentResult;
  235. DoGetTranslatedFilenameProcPtr = function( self: ComponentInstance; dstType: FileType; dstTypeHint: SInt32; var theDocument: FSSpec ): ComponentResult;
  236. DoGetScrapTranslationListProcPtr = function( self: ComponentInstance; list: ScrapTranslationListHandle ): ComponentResult;
  237. DoIdentifyScrapProcPtr = function( self: ComponentInstance; dataPtr: {const} UnivPtr; dataLength: Size; var dataFormat: ScrapType ): ComponentResult;
  238. DoTranslateScrapProcPtr = function( self: ComponentInstance; refNum: TranslationRefNum; srcDataPtr: {const} UnivPtr; srcDataLength: Size; srcType: ScrapType; srcTypeHint: SInt32; dstData: Handle; dstType: ScrapType; dstTypeHint: SInt32 ): ComponentResult;
  239. end.