Important: The information in this document is obsolete and should not be used for new development.
Calling an Edition Opener
You use theCallEditionOpenerProcfunction to call an edition opener. Since the Edition Manager is a package that may move, a real pointer cannot be safely returned for the standard opener and I/O routines. The system opener and the
I/O routines are returned as a value that is not a valid address to a procedure. TheCallEditionOpenerProcandCallFormatIOProcfunctions check for these values and call the system openers.You should never assume that a value for a system opener is a fixed constant.
err := CallEditionOpenerProc (selector, PB, routine);Set theselectorparameter to one of the edition opener verbs. The edition opener verbs include
The
eoCanSubscribeeoOpeneoCloseeoOpenNeweoCloseNew
PBparameter of theCallEditionOpenerProcfunction is an edition opener parameter block.
TYPE EditionOpenerParamBlock = RECORD info: EditionInfoRecord; {edition container to } { be subscribed to} sectionH: SectionHandle; {publisher or } { subscriber } { requesting open} document: FSSpecPtr; {document passed} fdCreator: OSType; {Finder creator type} ioRefNum: LongInt; {reference number} ioProc: FormatIOProcPtr; {routine to read } { formats} success: Boolean; {reading or writing } { was successful} formatsMask: SignedByte; {formats required to } { subscribe} END;Theroutineparameter of theCallEditionOpenerProcfunction is a pointer to an edition opener function.The following list shows which fields of the edition opener parameter block are used by the edition opener verbs:
Opener verb Field Description Called by eoCanSubscribe --> infoEdition container to subscribe to. NewSubscriberDialogfunction for a subscriber--> formatsMaskFormats required to subscribe. <-- Return value A noErrcode indicates that an edition container can be subscribed to. AnoTypeErrcode indicates that an edition container cannot be subscribed to.eoOpen --> infoEdition container to open for reading. OpenEditionandGetStandardFormatsfunctions for a subscriber--> sectionHSubscriber section requesting open or NIL.<-- ioRefNumReference number for use by I/O routine. Not the same as EditionRefNum.<-- ioProcI/O routine to call to read formats. <-- Return value A noErrcode or appropriate error code.eoClose --> infoEdition container to be closed for reading. CloseEditionandGetStandardFormatsfunctions for a subscriber--> sectionHSubscriber section requesting close or NIL.--> ioRefNumValue returned by eoOpen.--> ioProcValue returned by eoOpen.--> successSuccess value passed to the CloseEditionfunction.<-- Return value A noErrcode or appropriate error code.eoOpenNew --> infoEdition container to open for writing. OpenNewEditionfunction for a publisher--> sectionHPublisher section requesting open or NIL.--> documentDocument pointer passed into the OpenNewEditionfunction.--> fdCreatorThe fdCreatorpassed into theOpenNewEditionfunction.<-- ioRefNumReference number for use by I/O routine. Not the same as EditionRefNum.<-- ioProcI/O routine to call to write formats. <-- Return value A noErrcode or appropriate error code.eoCloseNew --> infoEdition container to be closed after writing. CloseEditionfunction for a publisher--> sectionHPublisher section requesting close or NIL.--> ioRefNumValue returned by eoOpenNew.--> ioProcValue returned by eoOpenNew.--> successSuccess value passed to the CloseEditionfunction.<-- Return value A noErrcode or appropriate error code.As Listing 2-9 demonstrates, you install your own edition opener function by first saving the current opener and then installing your own opener. The listing also shows an edition opener, the
MyEditionOpenerfunction. When it receives theeoCanSubscribeopener verb, theMyEditionOpenerfunction calls another application-defined routine,MyCanSubscribe. The Edition Manager sends your edition opener this verb to help it build the list of files displayed by theNewSubscriberfunction. TheMyCanSubscribefunction returnsnoErrif it can subscribe to the file; otherwise, it calls the original edition opener to handle the request.Listing 2-9 Using your own edition opener function
VAR gOriginalOpener: EditionOpenerProcPtr;{global variable} PROCEDURE MyInstallMyOpener; BEGIN FailOSErr(GetEditionOpenerProc(gOriginalOpener)); FailOSErr(SetEditionOpenerProc(@MyEditionOpener)); END; {MyInstallMyOpener} FUNCTION MyEditionOpener (selector: EditionOpenerVerb; VAR PB: EditionOpenerParamBlock) : OSErr; BEGIN WITH PB DO BEGIN CASE selector OF eoCanSubscribe: MyEditionOpener := MyCanSubscribe(PB); eoOpen: MyEditionOpener := MyEditionOpen(PB); eoClose: MyEditionOpener := MyEditionClose(PB); OTHERWISE {call the original edition opener} MyEditionOpener := CallEditionOpenerProc(selector, PB, gOriginalOpener); END; {of CASE} END; {of WITH} END; {MyEditionOpener} FUNCTION MyCanSubscribe (VAR PB: EditionOpenerParamBlock): OSErr; BEGIN {check file type to see if it is a file you can emulate as an } { edition} IF PB.info.fdType = {for example}'PICT' THEN MyCanSubscribe := noErr ELSE {otherwise, let the saved edition opener decide} MyCanSubscribe := CallEditionOpenerProc(eoCanSubscribe, PB, gOriginalOpener); END; {MyCanSubscribe}