InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ISnipRunSuite Class Referenceabstract

#include <ISnipRunSuite.h>

Inheritance diagram for ISnipRunSuite:
IPMUnknownCPMUnknown< ISnipRunSuite >SnipRunSuiteASBSnipRunSuiteCSB

Public Types

enum  { kDefaultIID = IID_ISNIPRUNSUITE }
 
enum  eSnpRunContextType {
  kSnpRunNoContext, kSnpRunWorkspaceContext, kSnpRunFrontDocContext, kSnpRunLayoutTargetContext,
  kSnpRunTextTargetContext, kSnpRunTextSelectionTargetContext, kSnpRunTableTargetContext, kSnpRunCustomContext
}
 
typedef PMString SnippetName
 
typedef K2Vector< SnippetNameSnippetNames
 
typedef PMString Category
 
typedef K2Vector< CategoryCategories
 

Public Member Functions

virtual void GetSnippetNames (SnippetNames &snippetNames) const =0
 
virtual bool16 IsRegistered (const SnippetName &snippetName) const =0
 
virtual void GetCategories (const SnippetName &snippetName, Categories &categories) const =0
 
virtual void GetDescription (const SnippetName &snippetName, PMString &description) const =0
 
virtual void GetPreconditions (const SnippetName &snippetName, PMString &preconditions) const =0
 
virtual bool16 CanRun (const SnippetName &snippetName) const =0
 
virtual ErrorCode Run (const SnippetName &snippetName, PMString &parameters, bool16 enableParameterDialog=kFalse) const =0
 
virtual ErrorCode SetupContext (const SnippetName &snippetName)=0
 
- Public Member Functions inherited from IPMUnknown
virtual IPMUnknownQueryInterface (PMIID interfaceID) const =0
 
virtual void AddRef () const =0
 
virtual void Release () const =0
 

Detailed Description

From SDK sample; interface that provides information about registered code snippets and allows them to be run. Clients should check ISnipRunSuite::CanRun returns kTrue before calling ISnipRunSuite::Run.

Member Typedef Documentation

K2Vector of Categories's, a snippet can belong to more than one category.

A category a snippet belongs to e.g. "sdk_text", "sdk_layout". See header sdkdoxygengroups.h for the list of valid categories.

Name of a snippet, only one snippet of a given name can be registered with the framework.

Member Enumeration Documentation

anonymous enum

kDefaultIID

Context Type
Enumerator
kSnpRunCustomContext 

selecting custom requires overriding SetupContext in your SnpRunnable derived class

Member Function Documentation

virtual bool16 ISnipRunSuite::CanRun (const SnippetNamesnippetName) const
pure virtual

Can the snippet run? The snippet will check if pre-conditions it requires before running are met.

Parameters
snippetNameIN.
Returns
kTrue if the snippet can run, kFalse otherwise.

Implemented in SnipRunSuiteCSB, and SnipRunSuiteASB.

virtual void ISnipRunSuite::GetCategories (const SnippetNamesnippetName,
Categoriescategories 
) const
pure virtual

Get the categories a given snippet belongs to.

Precondition
ISnipRunSuite::IsRegistered returns kTrue for the snippet.
Parameters
snippetNameIN
categoriesOUT categories the snippet registered as belonging to (sdk_text, sdk_layout etc.).

Implemented in SnipRunSuiteASB.

virtual void ISnipRunSuite::GetDescription (const SnippetNamesnippetName,
PMStringdescription 
) const
pure virtual

Get the description of what the snippet does e.g. "creates a text frame".

Precondition
ISnipRunSuite::IsRegistered returns kTrue for the snippet.
Parameters
snippetNameIN
descriptionOUT informative text string describing what the snippet does.

Implemented in SnipRunSuiteCSB, and SnipRunSuiteASB.

virtual void ISnipRunSuite::GetPreconditions (const SnippetNamesnippetName,
PMStringpreconditions 
) const
pure virtual

Get the preconditions that must be met before the snippet can be run. In the case where CanRun returns kFalse this string indicates to the user what they must do in order to run the snippet. For example "layout selection" would indicate the user has to have at least one object selected by a pointer selection tool.

Precondition
ISnipRunSuite::IsRegistered returns kTrue for the snippet.
Parameters
snippetNameIN
preconditionsOUT informative text string describing preconditions required before ISnipRunSuite::CanRun will return kTrue.

Implemented in SnipRunSuiteCSB, and SnipRunSuiteASB.

virtual void ISnipRunSuite::GetSnippetNames (SnippetNamessnippetNames) const
pure virtual

Get the names of all registered snippets.

Parameters
snippetNamesOUT

Implemented in SnipRunSuiteCSB, and SnipRunSuiteASB.

virtual bool16 ISnipRunSuite::IsRegistered (const SnippetNamesnippetName) const
pure virtual
Returns
kTrue if given snippet is available.
Parameters
snippetNameIN

Implemented in SnipRunSuiteCSB, and SnipRunSuiteASB.

virtual ErrorCode ISnipRunSuite::Run (const SnippetNamesnippetName,
PMStringparameters,
bool16 enableParameterDialog = kFalse 
) const
pure virtual

Run the snippet.

Parameters
snippetNameIN.
parametersIN/OUT pass in an empty string to run the code snippet using its hard coded default parameter values, otherwise pass a string containing comma separated parameter values. If enableParameterDialog is kTrue the user will be given the chance to override these parameter values. If a bad parameter value is detected and enableParameterDialog is kTrue the code snippet's hard coded default is taken and the user is given a chance to edit the parameter value. If a bad parameter is detected and enableParameterDialog is kFalse a message is output in the log and a failure status returned to the caller (provided that the snippet author respects ISnipRunParameterUtils::WasDialogCancelled after acquiring each parameter value). The parameter tokenisor uses a comma character , as a separator. To pass a comma in a parameter value enclose it in quotes e.g. "my, parameter". The parameter values used to run the snippet are recorded and passed back to the caller here.
enableParameterDialogIN kTrue to allow the user to override the parameter values to be used, kFalse(default) otherwise. Note that if enableParameterDialog is kTrue the parameter values passed back in the parameters argument mey be different from those passed in by the caller.
Returns
kSuccess on success, kCancel on cancel, other ErrorCode otherwise.

Implemented in SnipRunSuiteCSB, and SnipRunSuiteASB.

virtual ErrorCode ISnipRunSuite::SetupContext (const SnippetNamesnippetName)
pure virtual

Set up the proper InDesign context for the snippert so that it can be run.

Parameters
runnableContext
Returns
kSuccess on success, other ErrorCode otherwise

Implemented in SnipRunSuiteCSB, and SnipRunSuiteASB.