#include <ISnipRunSuite.h>
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.
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.
Context Type
| Enumerator |
|---|
| kSnpRunCustomContext | selecting custom requires overriding SetupContext in your SnpRunnable derived class |
| virtual bool16 ISnipRunSuite::CanRun | ( | const SnippetName & | snippetName | ) | const |
| pure virtual |
Can the snippet run? The snippet will check if pre-conditions it requires before running are met.
- Parameters
- Returns
- kTrue if the snippet can run, kFalse otherwise.
Implemented in SnipRunSuiteCSB, and SnipRunSuiteASB.
| virtual void ISnipRunSuite::GetCategories | ( | const SnippetName & | snippetName, | | | Categories & | categories | | ) | | const |
| pure virtual |
Get the categories a given snippet belongs to.
- Precondition
- ISnipRunSuite::IsRegistered returns kTrue for the snippet.
- Parameters
| snippetName | IN |
| categories | OUT categories the snippet registered as belonging to (sdk_text, sdk_layout etc.). |
Implemented in SnipRunSuiteASB.
| virtual void ISnipRunSuite::GetDescription | ( | const SnippetName & | snippetName, | | | PMString & | description | | ) | | 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
| snippetName | IN |
| description | OUT informative text string describing what the snippet does. |
Implemented in SnipRunSuiteCSB, and SnipRunSuiteASB.
| virtual void ISnipRunSuite::GetPreconditions | ( | const SnippetName & | snippetName, | | | PMString & | preconditions | | ) | | 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
| snippetName | IN |
| preconditions | OUT informative text string describing preconditions required before ISnipRunSuite::CanRun will return kTrue. |
Implemented in SnipRunSuiteCSB, and SnipRunSuiteASB.
| virtual void ISnipRunSuite::GetSnippetNames | ( | SnippetNames & | snippetNames | ) | const |
| pure virtual |
| virtual bool16 ISnipRunSuite::IsRegistered | ( | const SnippetName & | snippetName | ) | const |
| pure virtual |
| virtual ErrorCode ISnipRunSuite::Run | ( | const SnippetName & | snippetName, | | | PMString & | parameters, | | | bool16 | enableParameterDialog = kFalse | | ) | | const |
| pure virtual |
Run the snippet.
- Parameters
| snippetName | IN. |
| parameters | IN/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. |
| enableParameterDialog | IN 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 SnippetName & | snippetName | ) | |
| pure virtual |
Set up the proper InDesign context for the snippert so that it can be run.
- Parameters
- Returns
- kSuccess on success, other ErrorCode otherwise
Implemented in SnipRunSuiteCSB, and SnipRunSuiteASB.