Translation.h
上传用户:xjjlds
上传日期:2015-12-05
资源大小:22823k
文件大小:15k
源码类别:

多媒体编程

开发平台:

Visual C++

  1. /*
  2.      File:       Translation.h
  3.  
  4.      Contains:   Translation Manager (Macintosh Easy Open) Interfaces.
  5.  
  6.      Version:    Technology: Macintosh Easy Open 1.1
  7.                  Release:    QuickTime 6.0.2
  8.  
  9.      Copyright:  (c) 1991-2001 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:      For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __TRANSLATION__
  18. #define __TRANSLATION__
  19. #ifndef __MACTYPES__
  20. #include "MacTypes.h"
  21. #endif
  22. #ifndef __FILES__
  23. #include "Files.h"
  24. #endif
  25. #ifndef __COMPONENTS__
  26. #include "Components.h"
  27. #endif
  28. #ifndef __TRANSLATIONEXTENSIONS__
  29. #include "TranslationExtensions.h"
  30. #endif
  31. #if PRAGMA_ONCE
  32. #pragma once
  33. #endif
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif
  37. #if PRAGMA_IMPORT
  38. #pragma import on
  39. #endif
  40. #if PRAGMA_STRUCT_ALIGN
  41.     #pragma options align=mac68k
  42. #elif PRAGMA_STRUCT_PACKPUSH
  43.     #pragma pack(push, 2)
  44. #elif PRAGMA_STRUCT_PACK
  45.     #pragma pack(2)
  46. #endif
  47. /* enumerated types on how a document can be opened*/
  48. typedef short                           DocOpenMethod;
  49. enum {
  50.     domCannot                   = 0,
  51.     domNative                   = 1,
  52.     domTranslateFirst           = 2,
  53.     domWildcard                 = 3
  54. };
  55. /* 0L terminated array of OSTypes, or FileTypes*/
  56. typedef OSType                          TypesBlock[64];
  57. typedef OSType *                        TypesBlockPtr;
  58. /* Progress dialog resource ID*/
  59. enum {
  60.     kTranslationScrapProgressDialogID = -16555
  61. };
  62. /* block of data that describes how to translate*/
  63. struct FileTranslationSpec {
  64.     OSType                          componentSignature;
  65.     const void *                    translationSystemInfo;
  66.     FileTypeSpec                    src;
  67.     FileTypeSpec                    dst;
  68. };
  69. typedef struct FileTranslationSpec      FileTranslationSpec;
  70. typedef FileTranslationSpec *           FileTranslationSpecArrayPtr;
  71. typedef FileTranslationSpecArrayPtr *   FileTranslationSpecArrayHandle;
  72. /*****************************************************************************************
  73. *   GetFileTypesThatAppCanNativelyOpen
  74. *  This routine returns a list of all FileTypes that an application can open by itself
  75. *  Enter:   appVRefNumHint      volume where application resides (can be wrong, and if is, will be used as a starting point)
  76. *           appSignature        signature (creator) of application
  77. *           nativeTypes         pointer to a buffer to be filled with up to 64 FileTypes
  78. *  Exit:    nativeTypes         zero terminated array of FileTypes that can be opened by app
  79. */
  80. EXTERN_API( OSErr )
  81. GetFileTypesThatAppCanNativelyOpen (short               appVRefNumHint,
  82.                                  OSType                 appSignature,
  83.                                  FileType *             nativeTypes)                        TWOWORDINLINE(0x701C, 0xABFC);
  84. /*****************************************************************************************
  85. *  ExtendFileTypeList
  86. *  This routine makes a new list of file types that can be translated into a type in the given list
  87. *  Used by StandardFile
  88. *  Enter:   originalTypeList        pointer to list of file types that can be opened
  89. *           numberOriginalTypes     number of file types in orgTypeList
  90. *           extendedTypeList        pointer to a buffer to be filled with file types
  91. *           numberExtendedTypes     max number of file types that can be put in extendedTypeList
  92. *  Exit:    extendedTypeList        buffer filled in with file types that can be translated
  93. *           numberExtendedTypes     number of file types put in extendedTypeList
  94. */
  95. EXTERN_API( OSErr )
  96. ExtendFileTypeList              (const FileType *       originalTypeList,
  97.                                  short                  numberOriginalTypes,
  98.                                  FileType *             extendedTypeList,
  99.                                  short *                numberExtendedTypes)                TWOWORDINLINE(0x7009, 0xABFC);
  100. /*****************************************************************************************
  101. *  This routine checks if a file can be opened by a particular application.
  102. *  If so, it returns if it needs to be translated first, and if so then how.
  103. *  The FileTypes that the app can open are specified by nativelyOpenableTypes,
  104. *  or if it is NULL, GetFileTypesThatAppCanNativelyOpen is called.
  105. *  Enter:   targetDocument      document to check if it can be opened
  106. *           appVRefNumHint      vRefNum of application to open doc ( can be wrong, and if is, will be used as a starting point)
  107. *           appSignature        signature (creator) of application to open doc
  108. *           nativeTypes         zero terminated list of FileTypes app can open natively, or NULL to use default list
  109. *           onlyNative          whether to consider if document can be translated before opening
  110. *           howToOpen           pointer to buffer in which to put how the document can be opened
  111. *           howToTranslate      pointer to buffer in which to put a FileTranslationSpec record
  112. *  Exit:    howToOpen           whether file needs to be translated to be read
  113. *           howToTranslate      if file can be translated, buffer filled in with how to translate
  114. *           returns             noErr, noPrefAppErr
  115. */
  116. EXTERN_API( OSErr )
  117. CanDocBeOpened                  (const FSSpec *         targetDocument,
  118.                                  short                  appVRefNumHint,
  119.                                  OSType                 appSignature,
  120.                                  const FileType *       nativeTypes,
  121.                                  Boolean                onlyNative,
  122.                                  DocOpenMethod *        howToOpen,
  123.                                  FileTranslationSpec *  howToTranslate)                     TWOWORDINLINE(0x701E, 0xABFC);
  124. /*****************************************************************************************
  125. *  GetFileTranslationPaths
  126. *  This routine returns a list of all ways a translation can occure to or from a FileType.
  127. *  The app is checked to exist.  The hint for each app is the VRefNum and DTRefNum
  128. *  Enter:   srcDoc          source file or NULL for all matches
  129. *           dstDoc          destination FileType or 0 for all matches
  130. *           maxResultCount
  131. *           resultBuffer
  132. *  Exit:    number of paths
  133. */
  134. EXTERN_API( short )
  135. GetFileTranslationPaths         (FSSpec *               srcDocument,
  136.                                  FileType               dstDocType,
  137.                                  unsigned short         maxResultCount,
  138.                                  FileTranslationSpecArrayPtr  resultBuffer)                 TWOWORDINLINE(0x7038, 0xABFC);
  139. /*****************************************************************************************
  140. *  GetPathFromTranslationDialog
  141. *  This routine, with a given document, application, and a passed typelist will display the
  142. *  Macintosh Easy Open translation dialog allowing the user to make a choice.  The choice
  143. *  made will be written as a preference (so the next call to CanDocBeOpened() will work).
  144. *  The routine returns the translation path information.
  145. *  Enter:   theDocument         FSSpec to document to open
  146. *           theApplication      FSSpec to application to open document
  147. *           typeList            Nil terminated list of FileType's (e.g. SFTypeList-like) of types
  148. *                               you would like the documented translated to.  Order most perferred
  149. *                               to least.
  150. *  Exit:    howToOpen           Translation method needed to open document
  151. *           howToTranslate      Translation specification
  152. *           returns             Any errors that might occur.
  153. */
  154. EXTERN_API( OSErr )
  155. GetPathFromTranslationDialog    (const FSSpec *         theDocument,
  156.                                  const FSSpec *         theApplication,
  157.                                  TypesBlockPtr          typeList,
  158.                                  DocOpenMethod *        howToOpen,
  159.                                  FileTranslationSpec *  howToTranslate)                     TWOWORDINLINE(0x7037, 0xABFC);
  160. /*****************************************************************************************
  161. *   TranslateFile
  162. *  This routine reads a file of one format and writes it to another file in another format. 
  163. *  The information on how to translated is generated by the routine CanDocBeOpened.
  164. *  TranslateFile calls through to the TranslateFile Extension's DoTranslateFile routine.  
  165. *  The destination file must not exist.  It is created by this routine.  
  166. *  Enter:   sourceDocument          input file to translate
  167. *           destinationDocument     output file of translation
  168. *           howToTranslate          pointer to info on how to translate
  169. *  Exit:    returns                 noErr, badTranslationSpecErr 
  170. */
  171. EXTERN_API( OSErr )
  172. TranslateFile                   (const FSSpec *         sourceDocument,
  173.                                  const FSSpec *         destinationDocument,
  174.                                  const FileTranslationSpec * howToTranslate)                TWOWORDINLINE(0x700C, 0xABFC);
  175. /*****************************************************************************************
  176. *   GetDocumentKindString
  177. *  This routine returns the string the Finder should show for the "kind" of a document
  178. *  in the GetInfo window and in the kind column of a list view.  
  179. *  Enter:   docVRefNum      The volume containing the document
  180. *           docType         The catInfo.fdType of the document
  181. *           docCreator      The catInfo.fdCreator of the document
  182. *           kindString      pointer to where to return the string
  183. *  Exit:    kindString      pascal string.  Ex: "pSurfCalc spreadsheet"
  184. *           returns         noErr, or afpItemNoFound if kind could not be determined
  185. */
  186. EXTERN_API( OSErr )
  187. GetDocumentKindString           (short                  docVRefNum,
  188.                                  OSType                 docType,
  189.                                  OSType                 docCreator,
  190.                                  Str63                  kindString)                         TWOWORDINLINE(0x7016, 0xABFC);
  191. /*****************************************************************************************
  192. *  GetTranslationExtensionName
  193. *  This routine returns the translation system name from a specified TranslationSpec
  194. *  Enter:   translationMethod   The translation path to get the translation name from
  195. *  Exit:    extensionName       The name of the translation system
  196. *           returns             Any errors that might occur
  197. */
  198. EXTERN_API( OSErr )
  199. GetTranslationExtensionName     (const FileTranslationSpec * translationMethod,
  200.                                  Str31                  extensionName)                      TWOWORDINLINE(0x7036, 0xABFC);
  201. /*****************************************************************************************
  202. *  GetScrapDataProcPtr
  203. *  This is a prototype for the function you must supply to TranslateScrap. It is called to 
  204. *  get the data to be translated.  The first call TranslateScrap will make to this is to
  205. *  ask for the 'fmts' data.  That is a special.   You should resize and fill in the handle
  206. *  with a list all the formats that you have available to be translated, and the length of each.
  207. *  (See I.M. VI 4-23 for details of 'fmts').  It will then be called again asking for one of  
  208. *  the formats that 'fmts' list said was available.
  209. *  Enter:   requestedFormat         Format of data that TranslateScrap needs.
  210. *           dataH                   Handle in which to put the requested data
  211. *           srcDataGetterRefCon     Extra parameter for you passed to TranslateScrap
  212. *           
  213. *  Exit:    dataH                   Handle is resized and filled with data in requested format
  214. */
  215. typedef CALLBACK_API( OSErr , GetScrapDataProcPtr )(ScrapType requestedFormat, Handle dataH, void *srcDataGetterRefCon);
  216. typedef STACK_UPP_TYPE(GetScrapDataProcPtr)                     GetScrapDataUPP;
  217. #if OPAQUE_UPP_TYPES
  218.     EXTERN_API(GetScrapDataUPP)
  219.     NewGetScrapDataUPP             (GetScrapDataProcPtr     userRoutine);
  220.     EXTERN_API(void)
  221.     DisposeGetScrapDataUPP         (GetScrapDataUPP         userUPP);
  222.     EXTERN_API(OSErr)
  223.     InvokeGetScrapDataUPP          (ScrapType               requestedFormat,
  224.                                     Handle                  dataH,
  225.                                     void *                  srcDataGetterRefCon,
  226.                                     GetScrapDataUPP         userUPP);
  227. #else
  228.     enum { uppGetScrapDataProcInfo = 0x00000FE0 };                  /* pascal 2_bytes Func(4_bytes, 4_bytes, 4_bytes) */
  229.     #define NewGetScrapDataUPP(userRoutine)                         (GetScrapDataUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppGetScrapDataProcInfo, GetCurrentArchitecture())
  230.     #define DisposeGetScrapDataUPP(userUPP)                         DisposeRoutineDescriptor(userUPP)
  231.     #define InvokeGetScrapDataUPP(requestedFormat, dataH, srcDataGetterRefCon, userUPP)  (OSErr)CALL_THREE_PARAMETER_UPP((userUPP), uppGetScrapDataProcInfo, (requestedFormat), (dataH), (srcDataGetterRefCon))
  232. #endif
  233. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  234. #define NewGetScrapDataProc(userRoutine)                        NewGetScrapDataUPP(userRoutine)
  235. #define CallGetScrapDataProc(userRoutine, requestedFormat, dataH, srcDataGetterRefCon) InvokeGetScrapDataUPP(requestedFormat, dataH, srcDataGetterRefCon, userRoutine)
  236. typedef GetScrapDataUPP                 GetScrapData;
  237. /*****************************************************************************************
  238. *  TranslateScrap
  239. *  This routine resizes the destination handle and fills it with data of the requested format.
  240. *  The data is generated by translated one or more source formats of data supplied by
  241. *  the procedure srcDataGetter.  
  242. *  This routine is automatically called by GetScrap and ReadEdition.  You only need to call
  243. *  this if you need to translated scrap style data, but are not using the ScrapMgr or EditionMgr.
  244. *  Enter:   sourceDataGetter            Pointer to routine that can get src data
  245. *           sourceDataGetterRefCon      Extra parameter for dataGetter
  246. *           destinationFormat           Format of data desired
  247. *           destinationData             Handle in which to store translated data
  248. *           
  249. *  Exit:    dstData                     Handle is resized and filled with data in requested format
  250. */
  251. EXTERN_API( OSErr )
  252. TranslateScrap                  (GetScrapDataUPP        sourceDataGetter,
  253.                                  void *                 sourceDataGetterRefCon,
  254.                                  ScrapType              destinationFormat,
  255.                                  Handle                 destinationData,
  256.                                  short                  progressDialogID)                   TWOWORDINLINE(0x700E, 0xABFC);
  257. #if PRAGMA_STRUCT_ALIGN
  258.     #pragma options align=reset
  259. #elif PRAGMA_STRUCT_PACKPUSH
  260.     #pragma pack(pop)
  261. #elif PRAGMA_STRUCT_PACK
  262.     #pragma pack()
  263. #endif
  264. #ifdef PRAGMA_IMPORT_OFF
  265. #pragma import off
  266. #elif PRAGMA_IMPORT
  267. #pragma import reset
  268. #endif
  269. #ifdef __cplusplus
  270. }
  271. #endif
  272. #endif /* __TRANSLATION__ */