Create Publisher Event
If your application supports publish and subscribe capabilities, it should also
---------------------------------------------------
Create Publisher event create a publisher
Event class kAEMiscStdSuite
Event ID kAECreatePublisher
Required parameter None
Keyword keyDirectObject
Descriptor type typeObjectSpecifier
Data The part of the document to publish. If this parameter is omitted, publish the current
selection.
Keyword keyAEEditionFileLoc
Descriptor type typeAlias
Data An alias record that contains the location of the edition container to create. If this
parameter is omitted, use the default
edition container.
Requested action Create a publisher for the specified data
using the specified location for the
edition container. If the data isn't specified,
publish the current selection. If the location
of the edition isn't specified, use the default
location.
---------------------------------------------------
When your application receives the Create Publisher event, it should
create a publisher by writing the publisher's data to an edition. The data of the
publisher, and the location and name of the edition, are defined by the
Apple event. If the Create Publisher event includes a keyDirectObject
parameter, then your application should publish the data contained in the
parameter. If the keyDirectObject parameter is missing, then your application
should publish the current selection. If the document doesn't have a current
selection, your handler for the event should return a nonzero result code.
If the Create Publisher event includes a keyAEEditionFileLoc parameter,
then your application should use the location and name contained in the
parameter as the default location and name of the edition. If the
keyAEEditionFileLoc parameter is missing, then your application should use
the default location and name your application normally uses to specify the
edition container.
The following program shows a handler for the Create Publisher event.
This handler checks for the keyDirectObject parameter and the
keyAEEditionFileLoc parameter. If either of these is not specified, the handler
uses default values. The handler uses the DoNewPublisher function, an
application- defined function, to create the publisher and its edition, create a
section record, and update other data structures associated with the document.
whether user interaction is allowed. If user interaction is allowed, the handler
sets the promptForDialog variable to TRUE, indicating that the DoNewPublisher function should display the publisher dialog box. If user
interaction is not allowed, the handler sets the promptForDialog variable to
FALSE, and the DoNewPublisher function does not prompt the user for the location or name of the edition.
// A handler for the Create Publisher event
// Assuming inclusion of
#include <Script.h>
#include <Editions.h>
#include <AppleEvents.h>
void MyGetDocumentPtr (MyDocumentInfoPtr thisDocument);
Handle MyGetPreviewForSelection (MyDocumentInfoPtr thisDocument);
void MySetInfoForPreview(AEDesc *thePublisherDataDesc, MyDocumentInfoPtr thisDocument,
void DoError (OSErr myErr); OSErr MyGetDefaultEditionSpec(MyDocumentInfoPtr thisDocument, OSErr DoNewPublisher(MyDocumentInfoPtr thisDocument, {
long actualSize;
MyDocumentInfoPtr thisDocument;
MyGetDocumentPtr( thisDocument);
typeObjectSpecifier,&thePublisherDataDesc);
switch ( myErr) {
case errAEDescNotFound:
// use the current selection as the publisher and set up
// info for later when DoNewPublisher displays preview
preview = MyGetPreviewForSelection( thisDocument);
previewFormat = 'TEXT';
break;
case noErr:
// use the data in keyDirectObject parameter as the
// publisher (which is returned in the
// thePublisherDataDesc variable), and set up info for
// later when DoNewPublisher displays preview
MySetInfoForPreview(&thePublisherDataDesc, thisDocument,
preview, previewFormat);
break;
default:
DoError( myErr);
break;
}
typeFSS, & returnedType,
(Ptr)& defaultLocation.theFile,
sizeof(FSSpec), & actualSize);
switch ( myErr) {
case errAEDescNotFound:
// use the default location as the edition container
myErr = MyGetDefaultEditionSpec( thisDocument,
defaultLocation);
break;
case noErr:
// the keyAEEditionFileLoc parameter
// contained a default location
defaultLocation.thePart = kPartsNotUsed;
defaultLocation.theFileScript = smSystemScript;
break;
default:
DoError( myErr);
break;
}
myErr = MyGotRequiredParams( theAppleEvent);
if ( myErr) {
// handle the error appropriately
return myErr;
}
&MyIdleFunction);
if (myErr == noErr)
else
myErr = DoNewPublisher( thisDocument, promptForDialog,
preview, previewFormat, defaultLocation);
// add keyErrorNumber and keyErrorString parameters if desired
return myErr;
}
You can find a listing of MyGotRequiredParams may be found under