LDocApplication is a PowerPlant class that is used for applications
tath open and maniputlate one or more documents. LDocApplication
also handles the ae_OpenDoc and ae_PrintDoc Apple Events.
Methods :
The methods in this class are:
Data Members:
There are no data members for this class.
Operation:
LDocApplication is almost an abstract class (some functions are virtual, designed to be overridden). You should always create a subclass rather than use this one.
To learn more about handling documents, refer to The PowerPlant Book. Also be sure to examine the TextDocument demo on the CodeWarrior Reference CD.
Source files:
See also:
Purpose:
Default constructor. Override in derived class.
Access :
Prototype:
LDocApplication();Parameters:
Return:
No return value for a constructor
Purpose:
Virtual function, override in derived calss if appropriate.
Access :
Prototype:
~LDocApplication();Parameters:
Return:
No return value for a destructor
Purpose:
Virtual function, must be overridden by your derived class
Access :
Prototype:
virtual void ChooseDocument();Parameters:
Return:
Remarks:
See the Text Document demo on the CodeWarrior Reference CD for a good example.
Purpose:
Return the number of AppleEvent submodels of a particular type.
Access :
Prototype:
virtual SInt32 CountSubModels(
DescType inModelID) const;Parameters:
Return:
Remarks:
If inModelID is `cDocument', calls LApplication::CountSubModels() to return the number of `cWindow' elements (in this case, a window
= a document). Otherwise, calls the overridden member function
LApplication::CountSubModels() with inModelID.
Purpose:
Respond to an AppleEvent (usually from the Finder) to open or print a number of documents. Loops through the list to extract the descriptor and builds an FSSpec for each document, then open or print it as appropriate. Uses exceptions to catch OS errors.
Access :
Prototype:
virtual void DoAEOpenOrPrintDoc(
const AppleEvent& inAppleEvent,
AppleEvent& /* outAEReply */,
SInt32 inAENumber);Parameters:
Return:
Remarks:
aeOutReply is not used in this function and is commented out so that the
code will compile without warning messages.
Purpose:
Process and return the status of a menu command. The inCommand parameter specifies the command. On return, outEnabled indicates whether the command is enabled, outUsesMark tells whether it is marked, outMark returns the mark character (if any), and outName returns the name of the command.
Access :
Prototype:
virtual void FindCommandStatus(
CommandT inCommand,
Boolean& outEnabled,
Boolean& outUsesMark,
UInt16& outMark,
Str255 outName);Return:
Remarks:
Always enables cmd_New, cmd_Open, and cmd_PageSetup. For all other commands, calls the overridden LApplication::FindCommandStatus().
Purpose:
Virtual function returns the position (1 = first) of a SubModel within an Application.
Access :
Prototype:
Virtual SInt32 GetPositionOfSubModel(
DescType inModelID,
const LModelObject* inSubModel) const;Return:
Always returns 1 for `cDocument' model IDs, otherwise calls LApplication::GetPositionOfSubModel().
Purpose:
Pass back an AppleEvent token representing an AppleEvent submodel identified by its name.
Access :
Prototype:
virtual void GetSubModelByName(
DescType inModelID,
Str255 inName,
AEDesc& outToken) const;Return:
Remarks:
If the inModelID is `cDocument', calls LDocument::FindNamedDocument() to find the name, put it in a token. If it can't be found, throw
and exception. All other ids get sent to LApplication::GetSubModelByName().
Purpose:
Pass back an AppleEvent token representing an AppleEvent submodel identified by its numerical position.
Access :
Prototype:
virtual void GetSubModelByPosition(
DescType inModelID,
SInt32 inPosition,
AEDesc& outToken) const;Return:
Remarks:
If inModelID is `cDocument', throws an error exception for `errAENoSuchObject',
otherwise calls the overridden LApplication::GetSubModelByPostion().
Purpose:
Called when the application gets an Apple Event, usually a command
to Open or Print a document in the Finder. Handles ae_OpenDoc and ae_PrintDoc. All other events get passed back to LApplication.
Access :
Prototype:
virtual void HandleAppleEvent(
const AppleEvent& inAppleEvent,
AppleEvent& outAEReply,
AEDesc& outResult,
long inAENumber);Return:
Purpose:
Respond to an AppleEvent to create a new `cDocument' or `cWindow'
element, often created in LDocApplication::SendAECreateDocument(). For other element classes, calls LMOdelObject::HandleCreateElementEvent()
(via LApplication).
Access :
Prototype:
virtual LModelObject* HandleCreateElementEvent(
DescType inElemClass,
DescType inInsertPosition,
LModelObject* inTargetObject,
const AppleEvent& inAppleEvent,
AppleEvent& outAEReply);
Purpose:
Create a new Document and pass back an AppleEvent Model object representing that Document.
Access :
Prototype:
virtual LModelObject* MakeNewDocument();
Purpose:
Access :
Prototype:
virtual Boolean ObeyCommand(
CommandT inCommand,
void *ioParam);
Purpose:
Open a Document specified by an FSSpec. Subclass must override.
Access :
Prototype:
virtual void OpenDocument(
FSSpec* /* inMacFSSpec */);
Purpose:
Print a Document specified by an FSSpec. Subclass must override.
Access :
Prototype:
virtual void PrintDocument(
FSSpec* /* inMacFSSpec */);
Purpose:
Self-send an AppleEvent to create a new Document (so that AppleScript can record the action).
Access :
Prototype:
virtual void SendAECreateDocument();
Purpose:
Self-send an AppleEvent to open a document (so that AppleScript can record the action).
Access :
Prototype:
virtual void SendAEOpenDoc(
FSSpec &inFileSpec);
Purpose:
Handle the Page Setup command.
Access :
Prototype:
virtual void SetupPage();