[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

 

LDocApplication



Overview:

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:

 

LDocApplication()  
~LDocApplication()  
ChooseDocument()  
CountSubModels()  
DoAEOpenOrPrintDoc()  
FindCommandStatus()  
GetPositionOfSubModel()  
GetSubModelByName()  
GetSubModelByPosition()  
HandleAppleEvent()  
HandleCreateElementEvent()  
MakeNewDocument()  
ObeyCommand()  
OpenDocument()  
PrintDocument()  
SendAECreateDocument()  
SendAEOpenDoc()  
SetupPage()  

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:

(Commander Classes)

LDocApplication.h

LDocApplication.cp

See also:

LApplication

LDocument

LDocApplication()

Purpose:

Default constructor. Override in derived class.

Access :

Public

Prototype:

LDocApplication();
Parameters:

None

Return:

No return value for a constructor

~LDocApplication()

Purpose:

Virtual function, override in derived calss if appropriate.

Access :

Public

Prototype:

~LDocApplication();
Parameters:

None

Return:

No return value for a destructor

ChooseDocument()

Purpose:

Virtual function, must be overridden by your derived class

Access :

Public

Prototype:

virtual void ChooseDocument();
Parameters:

None

Return:

None

Remarks:

See the Text Document demo on the CodeWarrior Reference CD for a good example.

CountSubModels()

Purpose:

Return the number of AppleEvent submodels of a particular type.

Access :

Public

Prototype:

virtual SInt32 CountSubModels(

	DescType inModelID) const;
Parameters:

 

DescType  
inModelID  
AppleEvent model ID  

Return:

Number of AE submodels.

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.

DoAEOpenOrPrintDoc()

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 :

Public

Prototype:

virtual void DoAEOpenOrPrintDoc(

	const AppleEvent& inAppleEvent,

	AppleEvent& /* outAEReply */,

	SInt32 inAENumber);
Parameters:

 

const AppleEvent&  
inAppleEvent  
AppleEvent  
AppleEvent&  
outAEReply  
ignored  
SInt32  
inAENumber  
number of items to open or print  

Return:

None

Remarks:

aeOutReply is not used in this function and is commented out so that the code will compile without warning messages.

FindCommandStatus()

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 :

Public

Prototype:

virtual void FindCommandStatus(

	CommandT inCommand,

	Boolean& outEnabled,

	Boolean& outUsesMark,

	UInt16& outMark,

	Str255 outName);
Return:

None

Remarks:

Always enables cmd_New, cmd_Open, and cmd_PageSetup. For all other commands, calls the overridden LApplication::FindCommandStatus().

GetPositionOfSubModel()

Purpose:

Virtual function returns the position (1 = first) of a SubModel within an Application.

Access :

Public

Prototype:

Virtual SInt32 GetPositionOfSubModel(

	DescType inModelID,

	const LModelObject* inSubModel) const;
Return:

Always returns 1 for `cDocument' model IDs, otherwise calls LApplication::GetPositionOfSubModel().

GetSubModelByName()

Purpose:

Pass back an AppleEvent token representing an AppleEvent submodel identified by its name.

Access :

Public

Prototype:

virtual void GetSubModelByName(

	DescType inModelID,

	Str255 inName,

	AEDesc& outToken) const;
Return:

None

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().

GetSubModelByPosition()

Purpose:

Pass back an AppleEvent token representing an AppleEvent submodel identified by its numerical position.

Access :

Public

Prototype:

virtual void GetSubModelByPosition(

	DescType inModelID,

	SInt32 inPosition,

	AEDesc& outToken) const;
Return:

None

Remarks:

If inModelID is `cDocument', throws an error exception for `errAENoSuchObject', otherwise calls the overridden LApplication::GetSubModelByPostion().

HandleAppleEvent()

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 :

Public

Prototype:

virtual void HandleAppleEvent(

	const AppleEvent& inAppleEvent,

	AppleEvent& outAEReply,

	AEDesc& outResult,

	long inAENumber);
Return:

None

HandleCreateElementEvent()

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 :

Public

Prototype:

virtual LModelObject* HandleCreateElementEvent(

	DescType inElemClass,

	DescType inInsertPosition,

	LModelObject* inTargetObject,

	const AppleEvent& inAppleEvent,

	AppleEvent& outAEReply);

MakeNewDocument()

Purpose:

Create a new Document and pass back an AppleEvent Model object representing that Document.

Access :

Public

Prototype:

virtual LModelObject* MakeNewDocument();

ObeyCommand()

Purpose:

Respond to commands

Access :

Public

Prototype:

virtual Boolean ObeyCommand(

	CommandT	inCommand,

	void		*ioParam);

OpenDocument()

Purpose:

Open a Document specified by an FSSpec. Subclass must override.

Access :

Public

Prototype:

virtual void OpenDocument(

	FSSpec* /* inMacFSSpec */);

PrintDocument()

Purpose:

Print a Document specified by an FSSpec. Subclass must override.

Access :

Public

Prototype:

virtual void PrintDocument(

	FSSpec* /* inMacFSSpec */);

SendAECreateDocument()

Purpose:

Self-send an AppleEvent to create a new Document (so that AppleScript can record the action).

Access :

Public

Prototype:

virtual void SendAECreateDocument();

SendAEOpenDoc()

Purpose:

Self-send an AppleEvent to open a document (so that AppleScript can record the action).

Access :

Public

Prototype:

virtual void SendAEOpenDoc(

	FSSpec	&inFileSpec);

SetupPage()

Purpose:

Handle the Page Setup command.

Access :

Public

Prototype:

virtual void SetupPage();

 


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: July 21, 2000