Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: More Macintosh Toolbox /
Chapter 7 - Translation Manager / Translation Extension Reference
Translation Extension-Defined Routines / Scrap Translation Extension Routines


DoTranslateScrap

A scrap translation extension must respond to the kTranslateTranslateScrap request code. The Translation Manager sends this request code to allow the extension to translate scraps from one format to another. You can handle this request by calling the CallComponentFunctionWithStorage function and passing it a pointer to a function with the syntax defined by the DoTranslateScrap function.

FUNCTION DoTranslateScrap (self: ComponentInstance;
                           refNum: TranslationRefNum;
                           srcDataPtr: Ptr;
                           srcDataLength: Size;
                           srcType: ScrapType;
                           srcTypeHint: LongInt;
                           dstData: Handle;
                           dstType: ScrapType;
                           dstTypeHint: LongInt) 
                           : ComponentResult;
self
A component instance that identifies the component containing the translation extension.
refNum
The translation reference number for this translation.
srcDataPtr
A pointer to the scrap to be translated.
srcDataLength
The size of the scrap to be translated.
srcType
The format of the scrap to be translated.
srcTypeHint
The value in the hint field of the source document's scrap type specification.
dstData
A handle to the destination to be filled in.
dstType
The format into which to translate the source scrap.
dstTypeHint
The value in the hint field of the destination document's scrap type specification.
DESCRIPTION
The DoTranslateScrap function translates a scrap from one format into another. The scrap to be translated is specified by the srcDataPtr and srcDataLength parameters, and your routine should put the translated data into the block specified by the dstData parameter. Your function should resize that block as necessary and fill it with the appropriate translated data.

The refNum parameter is a reference number that Macintosh Easy Open assigns to the translation. Each translation is assigned a unique number to distinguish the translation from any other translations that might be occurring. You need to pass this reference number to any Macintosh Easy Open routines you call from within the scrap translation extension; for instance, if you display the progress dialog box by calling the SetTranslationAdvertisement function, you'll pass that reference number in the refNum parameter.

The DoTranslateScrap function can translate the source file itself or rely upon external translators. If it cannot translate the source scrap, your function should return a result code different from noErr.

Your translation extension should call the SetTranslationAdvertisement function to display the progress dialog box and the UpdateTranslationProgress function to update the dialog box periodically.

RESULT CODES
The DoTranslateScrap function should return noErr if successful, or an appropriate result code otherwise.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996