![]() | InDesign SDK 20.5 |
#include <Command.h>

Public Types | |
| enum | CommandDummyArg { kItemList = 1 } |
Public Types inherited from ICommand | |
| enum | { kDefaultIID = IID_ICOMMAND } |
| enum | CommandState { kNotDone, kDoneDynamic, kDone } |
| enum | Undoability { kAutoUndo = 0, kRegularUndo } |
| enum | { kUniqueCreatorID = ~(int32)0, kPassthroughCreatorID = ~(int32)1 } |
| enum | Priority { kLowestPriority, kLowPriority, kMediumPriority, kHighPriority, kHighestPriority } |
| typedef UIDRef | Target |
Public Member Functions | |
| Command (IPMUnknown *boss) | |
| virtual void | GetName (PMString *name) const |
| virtual void | SetName (const PMString &newName) |
| virtual bool16 | IsNameRequired () const |
| virtual const UIDList * | GetItemList () const |
| virtual const UIDList & | GetItemListReference () const |
| virtual void | SetItemList (const UIDList &newItemList) |
| virtual void | DoImmediate (bool16 isDynamic=kFalse) |
| virtual void | LWDoImmediate () |
| virtual void | DoDynamic () |
| virtual CommandState | GetCommandState () const |
| virtual bool16 | IsDone () const |
| virtual bool16 | CanJoin (const ICommand *pNewCmd) const |
| virtual void | SetCreatorID (int32 creatorID) |
| virtual int32 | GetCreatorID () const |
| virtual bool16 | LowMemIsOK () const |
| virtual const Target & | GetTarget () const |
| virtual Undoability | GetUndoability () const |
| virtual void | SetUndoability (Undoability newUndoability) |
| virtual void | SetActive (bool16 isActive) |
| virtual bool16 | IsActive () const |
| virtual bool8 | IsLWProcessed () const |
Protected Types | |
| enum | PredefinedTarget { kSessionWorkspaceTarget, kSessionTarget } |
Protected Member Functions | |
| virtual void | Do ()=0 |
| virtual void | DoNotify () |
| virtual void | SetCommandState (CommandState state) |
| virtual PMString * | CreateName () |
| virtual void | SetUpTarget () |
| virtual void | PreVerify (CommandState state) |
| virtual void | PostVerify (CommandState state) |
| void | SetTarget (const Target &newTarget) |
| void | SetTarget (PredefinedTarget newTarget) |
| void | SetTarget (IDataBase *db) |
Protected Attributes | |
| UIDList | fItemList |
Base class for implementing ICommand. If you are defining a new command, inherit from this class. To implement a new command: Define a boss in your plug-in that provides a command, for instance: <pre>
Class { kYourCmdBoss, kInvalidClass, { IID_ICOMMAND, kYourCmdImpl, IID_IYOURDATA, kYourDataImpl, } },
If you require to pass additional parameters to your command aggregate data interfaces on your command boss. For example, you could implement a custom data interface, IYourData as shown above. Or you could re-use a data interface provided by the API.
Provide an implementation of the ICommand interface, for instance:
class YourCmd : public Command { public: YourCmd(IPMUnknown* boss); ~YourCmd();
protected:
void Do();
void DoNotify();
PMString* CreateName();
};Define bodies for your methods.
add IDs to your your ID.h file. For example:
Once you've done all this, you can add code to your plug-in that processes your new command using CmdUtils.
| protected |
Identifies a pre-defined target database that contains the objects to be changed by a command.
| Enumerator | |
|---|---|
| kSessionWorkspaceTarget | Changes objects that persist in application defaults (kWorkspaceBoss) |
| kSessionTarget | Changes objects that persist in SavedData |
| virtual |
Join a command to this command. Should return true if the command was able to join the new command pNewCmd.
| pNewCmd | the command to join with. |
Implements ICommand.
| protectedvirtual |
Returns the name that appears in undo or redo menu items to identify this command.
Reimplemented in BPISetDataCmd, PstLstNewDataCmd, PstLstDeletePageItemCmd, PstLstDeleteDataCmd, PstLstModifyDataCmd, HidTxtModelCopyCmd, FrmLblCmd, NewCdlChartCmd, HidTxtModelCreateCmd, HidTxtModelDeleteCmd, HidTxtModelModifyTextCmd, ModifyCdlChartCmd, WritePDFVTDataSourceInfoCmd, XDocBkImageSizerCmd, XDocBkChangeServiceXMLImportPrefsCmd, PnlTrvChangeOptionsCmd, CusDtLnkChangeOptionsCmd, SnapSetPrefsCmd, XCatHndChangeEntityMappingCmd, XDocBkChangeOptionsCmd, CusCondTxtTagChangeCmd, FrmLblPrintPrefsCmd, and CompoundSequenceCmd.
| protectedpure virtual |
Changes the model and must be defined by all commands. If you encounter an error condition within your Do method you normally set the global error code and return.
Implemented in BPISetDataCmd, PstLstNewDataCmd, PstLstDeletePageItemCmd, PstLstDeleteDataCmd, HidTxtModelCopyCmd, PstLstModifyDataCmd, NewCdlChartCmd, FrmLblCmd, HidTxtModelCreateCmd, HidTxtModelDeleteCmd, HidTxtModelModifyTextCmd, XDocBkImageSizerCmd, PnlTrvChangeOptionsCmd, SnapSetPrefsCmd, ModifyCdlChartCmd, XDocBkChangeServiceXMLImportPrefsCmd, WritePDFVTDataSourceInfoCmd, SnipRunRestoreLogCmd, XCatHndChangeEntityMappingCmd, CusDtLnkChangeOptionsCmd, XDocBkChangeOptionsCmd, CusCondTxtTagChangeCmd, FrmLblPrintPrefsCmd, CompoundSequenceCmd, and SequenceCmd.
| virtual |
DEPRICATED Avoid using this function if possible - this is legacy and is deprecated.
| protectedvirtual |
Initiates notification, commands that want to perform notification define this method. It is called after the Do method has been called.
Reimplemented in BPISetDataCmd, PstLstNewDataCmd, PstLstDeletePageItemCmd, PstLstDeleteDataCmd, PstLstModifyDataCmd, HidTxtModelCopyCmd, FrmLblCmd, HidTxtModelCreateCmd, HidTxtModelDeleteCmd, HidTxtModelModifyTextCmd, ModifyCdlChartCmd, WritePDFVTDataSourceInfoCmd, SnapSetPrefsCmd, CusDtLnkChangeOptionsCmd, PnlTrvChangeOptionsCmd, and CusCondTxtTagChangeCmd.
| virtual |
Returns the command state; observers (see IObserver::Update) can check this state is not yet done (pre-notification) or done.
Implements ICommand.
| virtual |
| virtual |
Get the a pointer to the item list; the item list references the objects (by UID) the command should work on and the target database (IDataBase) that contains them. If the target to be worked on is not passed to the command via this item list then the command must be self targetting (see Command::SetTarget, Command::SetUpTarget).
Implements ICommand.
| virtual |
Get a reference to the item list.
Implements ICommand.
| virtual |
Get the name of the command; commands with the undoability kRegularUndo must have a name, for use in the undo/redo menu items (unless they override IsNameRequired to return kFalse).
| name | a pointer to the name for the command. |
Implements ICommand.
| virtual |
| virtual |
Returns kTrue if the command state is kDone or kDoneDynamic, kFalse otherwise.
Implements ICommand.
| virtual |
Is command required to have a name? By default, the return value is kTrue when undoability is equal kRegularUndo and kFalse otherwise. Override this virtual function when you have a command with regular undo and you want to use the name of another command (nested within the scope of the current one) to appear on the undo menu.
Implements ICommand.
| virtual |
Tell whether a command can operate under low memory conditions.
Implements ICommand.
Reimplemented in BPISetDataCmd, PstLstNewDataCmd, PstLstDeletePageItemCmd, PstLstDeleteDataCmd, NewCdlChartCmd, PstLstModifyDataCmd, FrmLblCmd, ModifyCdlChartCmd, and WritePDFVTDataSourceInfoCmd.
| protectedvirtual |
See Command::PreVerify.
| state |
| protectedvirtual |
Verification is called from SetCommandState as the command changes state. PreVerify is called as the command changes to kNotDone. PostVerify is called as the state changes to kDone. Verification routines should verify the particular state of an object or document when a change is completed and assert if there is something wrong. Possible additions to this mechanism is the ability to "turn off" verification under certain circumstances. Verification is only called for debug builds. [LDM]
| state |
| protectedvirtual |
Sets the command state.
| state |
| virtual |
Set the creator ID. The creator id is important in the context of a previewable dialog. The dialog command interceptor uses it to tell whether two commands are the same.
| creatorID | the new creator ID to use |
Implements ICommand.
| virtual |
Set the item list.
| newItemList | reference to item list to be copied into command |
Implements ICommand.
| virtual |
| protected |
See Command::SetTarget(IDataBase*).
| newTarget |
| protected |
See Command::SetTarget(IDataBase*).
| newTarget |
| protected |
Call this method from your constructor or your SetUpTarget method if the target of your command is not equivalent to the command manager of the database of the command's item list at the time of processing.
| db |
| virtual |
Set the undoability of the command. This function allows changing the undoability of a command. Typically, SetUndoability is called to override the default undoability. Call this function before the Do() function of the command gets called (we recommend setting the undoability within the constructor of the command interface or within the implementation of the SetupTarget function).
| newUndoability | the new undoability value for the command |
Implements ICommand.
| protectedvirtual |
Sets up the target, the database that contains the objects changed by the command. Define if your command has a target that is not known at construction time and is not equivalent to the database passed in the command's item list when the command is processed.
Reimplemented in NewCdlChartCmd, HidTxtModelCopyCmd, and CompoundSequenceCmd.
| protected |
The command's item list.