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

#include <ISnipRunParameterUtils.h>

Inheritance diagram for ISnipRunParameterUtils:
IPMUnknownCPMUnknown< ISnipRunParameterUtils >SnipRunParameterUtils

Public Types

enum  { kDefaultIID = IID_ISNIPRUNPARAMETERUTILS }
 

Public Member Functions

virtual PMString GetPMString (const PMString &prompt, const PMString &defaultValue="") const =0
 
virtual int32 GetInt32 (const PMString &prompt, const int32 defaultValue=0, const int32 lowerLimit=0, const int32 upperLimit=0) const =0
 
virtual PMReal GetPMReal (const PMString &prompt, const PMReal &defaultValue=0, const PMReal &lowerLimit=0, const PMReal &upperLimit=0) const =0
 
virtual int32 GetChoice (const PMString &prompt, const K2Vector< PMString > &choices, const int32 defaultChoiceIndex=0) const =0
 
virtual bool16 WasDialogCancelled () const =0
 
virtual void EnableDialog (const bool16 enable)=0
 
virtual bool16 IsDialogEnabled () const =0
 
virtual void EnableTranslation (const bool16 enable)=0
 
virtual bool16 IsTranslationEnabled () const =0
 
virtual void SetParameters (const PMString &params)=0
 
virtual PMString GetParameters ()=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; utility interface for parameter gathering that allows snippets to prompt

for a data type value(for example PMString, int32). The normal behavour

of this interface will be to pop a dialog and request a value to

be entered by the user. This allows code snippets to acquire parameter

values when they run.



The code below shows how to declare and use the interface to get the 

value of a PMString:

<pre>

Utils<ISnipRunParameterUtils> parameterUtils;

PMString swatchName = parameterUtils->GetPMString("Swatch name", "Black");

if (parameterUtils->WasDialogCancelled()) {

The user cancelled and you should too, don't prompt for any more parameters, }

Member Enumeration Documentation

anonymous enum

kDefaultIID

Member Function Documentation

virtual void ISnipRunParameterUtils::EnableDialog (const bool16 enable)
pure virtual

For the use of the SnippetRunner framework, please avoid. Controls the display of parameter dialogs(enabled by default). If ISnipRunParameterUtils::IsDailogEnabled is kFalse, no parameter dialogs will be displayed. In that case, ISnipRunParameterUtils calls will return the default value passed into the call.

You should not need to call this method but if you do please save the state of the flag before you change it and restore it after you are done, thank you.

Parameters
enableIN kTrue to prompt the user for parameter values, kFalse otherwise.

Implemented in SnipRunParameterUtils.

virtual void ISnipRunParameterUtils::EnableTranslation (const bool16 enable)
pure virtual

For the use of the SnippetRunner framework, please avoid. Controls whether or not PMString's passed into parameter prompt calls are translatable. By default PMString's must be translatable.

You should not need to call this method but if you do please save the state of the flag before you change it and restore it after you are done, thank you.

Code snippets don't have to call this method. By default the strings used in snippets are not translatable and the SnippetRunner framework will make sure this API expects untranslatable strings to be passed.

If ISnipRunParameterUtils::IsTranslationEnabled is kFalse, PMString's passed into ISnipRunParameterUtils will be marked as untranslatable by calling PMString::SetTranslatable(kFalse).

Parameters
enableIN kTrue to pass translatable strings, kFalse otherwise.

Implemented in SnipRunParameterUtils.

virtual int32 ISnipRunParameterUtils::GetChoice (const PMStringprompt,
const K2Vector< PMString > & choices,
const int32 defaultChoiceIndex = 0 
) const
pure virtual
    Return the index of a selected choice from a list of choices described 

    by a vector of PMString's.



    The code below requests a choice between "DoThis" and "DoThat" to be made.


K2Vector<PMString> choices;

choices.push_back(PMString("DoThis"));

choices.push_back(PMString("DoThat"));

enum {kDoThis, kDoThat};

int32 choice  = parameterUtils->GetChoice("What do you want to do.", choices);

if (parameterUtils->WasDialogCancelled() == kFalse) {

    switch (choice) 

    {

    case kDoThis:

    case kDoThat:

    }

}

Parameters
promptIN describing what the choice represents
choicesIN vector of strings representing the choices available
defaultChoiceIndexIN (default 0)
Returns
the index of the selected choice

Implemented in SnipRunParameterUtils.

virtual int32 ISnipRunParameterUtils::GetInt32 (const PMStringprompt,
const int32 defaultValue = 0,
const int32 lowerLimit = 0,
const int32 upperLimit = 0 
) const
pure virtual
    Return an int32 value.



    The code below requests an int32 that represents a page number with a default value

    of 1 and no range checking.


int32 pageNumber = parameterUtils->GetInt32("Page  number", 1);

    The code below checks the page number entered is in the range 1 to 9999:


int32 pageNumber = parameterUtils->GetInt32("Number of pages", 1, 1, 9999);

Parameters
promptIN describing what the int32 represents
defaultValueIN (default 0)
lowerLimitIN (default 0, if both lowerLimit and upperlimit are 0 range checking is switched off)
upperLimitIN (default 0)
Returns
an int32 value

Implemented in SnipRunParameterUtils.

virtual PMString ISnipRunParameterUtils::GetParameters ()
pure virtual

Get the parameters the snippet was run with. If the user enters parameter values in the parameter dialog these values are recorded and can be returned by this method after the snippet has run.

Returns
a CSV string containing parameter values.

Implemented in SnipRunParameterUtils.

virtual PMReal ISnipRunParameterUtils::GetPMReal (const PMStringprompt,
const PMRealdefaultValue = 0,
const PMReallowerLimit = 0,
const PMRealupperLimit = 0 
) const
pure virtual
    Return a PMReal value.



    The code below requests a PMReal that represents stroke weight with a default value of 1.0

    and no range checking.


PMReal strokeWeight = parameterUtils->GetPMReal("Stroke weight", 1);

    The code below checks the stroke weight entered is in the range 1 to 1000:


int32 pageNumber = parameterUtils->GetInt32("Number of pages", 1, 1, 1000);

Parameters
promptIN describing what the PMReal represents
defaultValueIN (default 0)
lowerLimitIN (default 0, if both lowerLimit and upperlimit are 0 range checking is switched off)
upperLimitIN (default 0)
Returns
a PMReal value

Implemented in SnipRunParameterUtils.

virtual PMString ISnipRunParameterUtils::GetPMString (const PMStringprompt,
const PMStringdefaultValue = "" 
) const
pure virtual
    Return a PMString value. 



    The code below requests a string that represents the name of a swatch that defaults to "Black".


PMString swatchName = parameterUtils->GetPMString("Swatch name", "Black");

Parameters
promptIN describing what the string represents
defaultValueIN (default "")
Returns
a PMString value

Implemented in SnipRunParameterUtils.

virtual bool16 ISnipRunParameterUtils::IsDialogEnabled () const
pure virtual

For the use of the SnippetRunner framework, please avoid.

Returns
kTrue if the user should be prompted for parameter values, kFalse otherwise.

Implemented in SnipRunParameterUtils.

virtual bool16 ISnipRunParameterUtils::IsTranslationEnabled () const
pure virtual

For the use of the SnippetRunner framework, please avoid.

Returns
kTrue if PMString's passing through this API are translatable, kFalse otherwise.

Implemented in SnipRunParameterUtils.

virtual void ISnipRunParameterUtils::SetParameters (const PMStringparams)
pure virtual

Set the parameters the snippet should run with.

Parameters
paramsa CSV string containing parameter values or empty string if the user should be prompted for parameters.

Implemented in SnipRunParameterUtils.

virtual bool16 ISnipRunParameterUtils::WasDialogCancelled () const
pure virtual

Return kTrue if the user cancelled instead of supplying a value, kFalse otherwise. When cancel is detected your snippet should stop and return control to its caller, don't prompt for any more values

Returns
kTrue if the user cancelled, kFalse otherwise.

Implemented in SnipRunParameterUtils.