Using Publisher and Subscriber Options
Using Publisher and Subscriber Options
There are special options associated with publishers and subscribers within
documents. Your application can use the publisher and subscriber options
dialog boxes provided by the Edition Manager to make these choices
available to the user. You should make these dialog boxes available to the user
by creating a menu command in the Edit menu that toggles between
publisher options (when the user has selected a publisher within a document)
and Subscriber Options (when a user has selected a subscriber within a
document).
When a user chooses these menu commands, you need to display the
corresponding publisher or subscriber options dialog box. Use the
SectionOptionsDialog function to display the appropriate dialog box on the
user's screen.
Each dialog box contains information regarding the section and its edition. As
a shortcut for the user, you should display the publisher options dialog box
when the user double-clicks on a publisher section within a document. You
should display the subscriber options dialog box when the user double-clicks
on a subscriber section within a document.
You pass a SectionOptionsReply record as a parameter to the
Set the sectionH field of the SectionOptionsReply structure to the handle to the
section record for the section the user selected.
Upon return of the SectionOptionsDialog function, the canceled and
changed fields are set. If the canceled parameter is set to TRUE, the user
canceled the dialog box. Otherwise, this parameter is FALSE. If the changed
parameter is TRUE, the section record is changed. For example, the user may
have changed the update mode .
The action parameter contains the code for one of five user actions. All
action codes dismiss the publisher and subscriber options dialog boxes when
complete.
action code is 'read' for user selection of the Get Edition Now button
action code is 'writ' for user selection of the Send Edition Now
button
action code is 'goto' for user selection of the Open Publisher button
action code is 'cncl' for user selection of the Cancel Publisher or
Cancel Subscriber button
action code is ' ' (0x20202020) for user selection of the OK
button
The Listing below shows an example of how your application can respond to
the action codes received from the section options reply record. There are
several different techniques that your application can use to accomplish
this--this listing shows one technique.
// Responding to action codes
// Assuming inclusion of MacHeaders
#include <Editions.h>
// This is a sample declaration for the pointer to your document information.
typedef struct {
short resForkRefNum;
FSSpec fileSpec;
short nextSectionID;
} *MyDocumentInfoPtr;
// Prototype your routine like this prior to calling it
void DoOptionsDialog(SectionHandle);
void DoOptionsDialog(SectionHandle theSection)
{
EditionInfoRecord theEditionInfo;
ResType action;
OSErr sodErr;
OSErr geiErr;
OSErr gpsErr;
// User defined function proto types
void SectionHasChanged(SectionHandle);
void DoReadEdition(SectionHandle);
void DoWriteEdition(SectionHandle);
void MyErrHandler(OSErr);
reply.sectionH = theSection;
// Determine what the user did and handle appropriately.
if ( reply. canceled )
// The user changed his/her mind; simply return.
return;
if ( reply.changed )
// The section record has changed; make note of this.
// SectionHasChanged is a routine to accomplish this.
SectionHasChanged(theSection);
// If you customize, you may want to do some post-processing now.
action = reply. action; // Get the action code.
if ( action = 'read') {
// User selected Get Edition Now button.
DoReadEdition(theSection);
return;
}
if ( action = 'writ') {
// User selected Send Edition Now button.
DoWriteEdition(theSection);
return;
}
if ( action = 'goto') {
// User selected Open Publisher button.
geiErr = GetEditionInfo(theSection, &theEditionInfo);
// There's usually no error returned here, but if
// there is, then don't continue with this operation.
if ( geiErr )
MyErrHandler(geiErr);
gpsErr = GoToPublisherSection(&theEditionInfo. container);
// Same comment as above. Pass control to MyErrHandler
// if there's an error.
if ( gpsErr )
MyErrHandler(gpsErr);
return;
}
if ( action = 'cncl')
// User selected Cancel Publisher or Cancel Subscriber button.
// Call the UnRegisterSection function and dispose of the
// section record and the alias record.
return;
}
The following sections describe the features of the publisher and subscriber
options dialog boxes.