InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
IScriptUtils Class Referenceabstract
Inheritance diagram for IScriptUtils:
IPMUnknown

Public Types

enum  { kDefaultIID = IID_ISCRIPTUTILS }
 

Public Member Functions

virtual IScriptQueryApplicationScript () const =0
 
virtual IScriptInfoManagerQueryScriptInfoManager (const RequestContext &context) const =0
 
virtual IScriptRequestHandlerQueryScriptRequestHandler (const RequestContext &context) const =0
 
virtual void GetScriptManagers (ScriptManagerList &mgrs) const =0
 
virtual IScriptManagerQueryScriptManager (ClassID boss) const =0
 
virtual IScriptRunnerQueryScriptRunner (const IDFile &) const =0
 
virtual bool16 IsScriptActive ()=0
 
virtual bool16 IsINX (const RequestContext &context)=0
 
virtual bool16 IsINX ()=0
 
virtual bool16 IsINXTraditional (const RequestContext &context)=0
 
virtual bool16 IsINXExpanded (const RequestContext &context)=0
 
virtual bool16 IsINXExport (const RequestContext &context)=0
 
virtual PMString GetScriptID (const ScriptID &scriptID)=0
 
virtual IScriptCreateProxyScriptObject (const RequestContext &context, const ClassID &classID, const ScriptID &objectID, const IPMUnknown *parent, int32 index=0)=0
 
virtual void ReleaseAllObjectsInDatabase (IDataBase *db) const =0
 
virtual IWorkspaceQueryWorkspaceFromScript (const IScript *script, const RequestContext &context)=0
 
virtual IDocumentQueryDocumentFromScript (const IScript *script, const RequestContext &context)=0
 
virtual ErrorCode ExtractInsertionLocation (IScript *inScript, IScriptRequestData *inData, const ScriptID &objectType, ScriptID &outLocation, InterfacePtr< IScript > &outScript)=0
 
virtual ErrorCode GetMoveLocation (const IScriptRequestData *inData, ScriptID &outLocation, InterfacePtr< IScript > &outScript)=0
 
virtual bool16 IsNothing (const ScriptData &scriptData)=0
 
virtual ErrorCode GenerateSpecifier (const EngineContext &context, const IScript *object, PMString &specifier, SpecifierForm form=kFormDefault)=0
 
virtual ErrorCode GenerateSpecifier (const EngineContext &context, const IScript *object, PMString &workSpaceSpecifier, PMString &objectSpecifier, SpecifierForm form=kFormDefault)=0
 
virtual ErrorCode GenerateListSpecifier (const EngineContext &context, const ScriptList &objects, PMString &specifier, SpecifierForm form=kFormDefault)=0
 
virtual ErrorCode GenerateRangeSpecifier (const EngineContext &context, const PMString &fromSpecifier, const PMString &toSpecifier, PMString &specifier)=0
 
virtual ErrorCode AppendSpecifier (const EngineContext &context, const ScriptInfo::ObjectScriptElement *objectScriptElement, const ScriptObject &scriptObject, PMString &specifier)=0
 
virtual ErrorCode ResolveSpecifier (const EngineContext &context, const PMString &specifier, ScriptList &resolvedObjects)=0
 
virtual ErrorCode ResolveSpecifier (const EngineContext &context, const PMString &workSpaceSpecifier, const PMString &objectSpecifier, ScriptList &resolvedObjects)=0
 
virtual const ObjectScriptElementGetCommonBaseInfo (const ObjectScriptElement *si1, const ObjectScriptElement *si2) const =0
 
virtual ErrorCode GetScriptingSupportFolder (const RequestContext &context, IDFile &outFolder) const =0
 
virtual void AppendDirectoryForDOMVersion (const RequestContext &context, IDFile &sysFile) const =0
 
virtual ErrorCode SetScriptingTag (const ScriptList &scriptList, const EngineContext &context, const IScriptLabel::ScriptLabelValue &label, const IScriptLabel::ScriptLabelKey &key=IScriptLabel::kDefaultScriptLabelKey) const =0
 
virtual ErrorCode SetScriptingTags (const ScriptList &scriptList, const EngineContext &context, const IScriptLabel::ScriptLabelKeyValueList &labels, bool16 replaceExistingLabels=kFalse) const =0
 
virtual ErrorCode GetScriptsFolder (IDFile &scriptsFolder, bool16 resolveAlias) const =0
 
virtual ErrorCode ExtractVersion (IScriptRequestData *data, ScriptVersion &internalVersion) const =0
 
virtual ErrorCode DispatchScriptRunner (IScriptRunner *scriptRunner, const ScriptData &script, const ScriptRecordData &arguments, ScriptData &result, PMString &errorString, const bool16 showErrorAlert, const bool16 invokeDebugger=kFalse, const RunScriptParams::UndoMode undoMode=RunScriptParams::kUndoScriptRequest, const PMString &undoName=PMString(), const ScriptVersion &domVersion=ScriptVersion()) const =0
 
virtual void ClearScriptProviders () const =0
 
virtual ErrorCode SetAppScriptPrefs (bool16 redraw) const =0
 
virtual bool16 TranslateKeyStringFromScriptClient (PMString &s) const =0
 
virtual void DisableIdleProcessingDuringScripts ()=0
 
virtual void EnableIdleProcessingDuringScripts ()=0
 
virtual bool16 IsIdleProcessingEnabledDuringScripts () const =0
 
virtual ErrorCode DispatchScriptRunner (IScriptRunner *scriptRunner, const ScriptData &script, bool16 evalStringAsFilePath, const ScriptRecordData &arguments, ScriptData &result, PMString &errorString, const bool16 showErrorAlert, const bool16 invokeDebugger=kFalse, const RunScriptParams::UndoMode undoMode=RunScriptParams::kUndoScriptRequest, const PMString &undoName=PMString(), const ScriptVersion &domVersion=ScriptVersion()) const =0
 
- Public Member Functions inherited from IPMUnknown
virtual IPMUnknownQueryInterface (PMIID interfaceID) const =0
 
virtual void AddRef () const =0
 
virtual void Release () const =0
 

Member Function Documentation

virtual void IScriptUtils::AppendDirectoryForDOMVersion (const RequestContextcontext,
IDFilesysFile 
) const
pure virtual

Appends the folder in which scripting resources such as VB typelibs, AETE resources are stored.

Parameters
&sysFileIDFile of scripting support folder to append to
virtual ErrorCode IScriptUtils::AppendSpecifier (const EngineContextcontext,
const ScriptInfo::ObjectScriptElementobjectScriptElement,
const ScriptObjectscriptObject,
PMStringspecifier 
)
pure virtual

Append the specifier for a scripting object to an existing specifier.

Parameters
contextIN the request context
objectScriptElementIN an ObjectScriptElement describing the object
scriptObjectIN a ScriptObject describing the specific instance of the object
specifierIN/OUT the specifier onto which to append
virtual void IScriptUtils::ClearScriptProviders () const
pure virtual

Clear the script provider cache. Call this if you are implementing your own script manager when the active script state changes.

See Also
IncrementActiveScriptCount and
DecrementActiveScriptCount.
virtual IScript* IScriptUtils::CreateProxyScriptObject (const RequestContextcontext,
const ClassIDclassID,
const ScriptIDobjectID,
const IPMUnknownparent,
int32 index = 0 
)
pure virtual

Create a proxy script object

virtual void IScriptUtils::DisableIdleProcessingDuringScripts ()
pure virtual

Turns off idle processing during scripting. When idle processing is disabled, scheduled command will NOT be executed, idle task handlers will NOT be executed, and no user cancel events will be detected. Note: Must be paired with EnableIdleProcessingDuringScripts() call. Given the effect on command processing, use this API with extreme caution.

virtual ErrorCode IScriptUtils::DispatchScriptRunner (IScriptRunnerscriptRunner,
const ScriptDatascript,
const ScriptRecordData & arguments,
ScriptDataresult,
PMStringerrorString,
const bool16 showErrorAlert,
const bool16 invokeDebugger = kFalse,
const RunScriptParams::UndoMode undoMode = RunScriptParams::kUndoScriptRequest,
const PMStringundoName = PMString(),
const ScriptVersiondomVersion = ScriptVersion() 
) const
pure virtual

Dispatch a script to the appropriate script runner.

Parameters
scriptRunneris the desired script runner to use to execute the script (or nil if not known) IN
scriptis the script to execute (may be a String, a File, or a Function) IN
argumentsis used to pass arguments to the script IN
resultis the return value OUT
errorStringis the error string OUT
showErrorAlertif kTrue show an error alert if an error occurs IN
invokeDebuggerindicates whether to load script into debugger for execution IN
undoModeindicates how to handle undo for document changes made by the script IN
undoNameis the name for the undo step in single undo step mode IN
domVersionis the desired version of the DOM in which to execute the script. For script files, defaults to the version of the DOM corresponding to the current version of the application (unless the file is in a "Version X.X Folder"). Ignored for text scripts, which use the version of the DOM currently set. Ignored for function callbacks, which use the version of the DOM in the function's context.
Returns
kSuccess or an error
virtual ErrorCode IScriptUtils::DispatchScriptRunner (IScriptRunnerscriptRunner,
const ScriptDatascript,
bool16 evalStringAsFilePath,
const ScriptRecordData & arguments,
ScriptDataresult,
PMStringerrorString,
const bool16 showErrorAlert,
const bool16 invokeDebugger = kFalse,
const RunScriptParams::UndoMode undoMode = RunScriptParams::kUndoScriptRequest,
const PMStringundoName = PMString(),
const ScriptVersiondomVersion = ScriptVersion() 
) const
pure virtual

INTERNAL USE ONLY Dispatch a script to the appropriate script runner.

Parameters
scriptRunneris the desired script runner to use to execute the script (or nil if not known) IN
scriptis the script to execute (may be a String, a File, or a Function) IN
evalStringAsFilePathif kTrue evaluate if the script string is a file path IN
argumentsis used to pass arguments to the script IN
resultis the return value OUT
errorStringis the error string OUT
showErrorAlertif kTrue show an error alert if an error occurs IN
invokeDebuggerindicates whether to load script into debugger for execution IN
undoModeindicates how to handle undo for document changes made by the script IN
undoNameis the name for the undo step in single undo step mode IN
domVersionis the desired version of the DOM in which to execute the script. For script files, defaults to the version of the DOM corresponding to the current version of the application (unless the file is in a "Version X.X Folder"). Ignored for text scripts, which use the version of the DOM currently set. Ignored for function callbacks, which use the version of the DOM in the function's context.
Returns
kSuccess or an error
virtual void IScriptUtils::EnableIdleProcessingDuringScripts ()
pure virtual

Turns back on idle processing during scripting. Note: Used with DisableIdleProcessingDuringScripts() call.

virtual ErrorCode IScriptUtils::ExtractInsertionLocation (IScriptinScript,
IScriptRequestDatainData,
const ScriptIDobjectType,
ScriptIDoutLocation,
InterfacePtr< IScript > & outScript 
)
pure virtual

A utility for script providers during their handling of e_Create. When handling the create event, there are several cases providers need to deal with:

  1. The simplest case is when no insertion location is provided. In this case ExtractInsertionLocation simply populates outLocation with en_Unknown and it is up to the script provider to determine the default behavior.
  2. The user can provide an insertion location of en_Begin or en_End. In this case ExtractInsertionLocation populates outLocation with either en_Begin or en_End. outScript will be nil.
  3. The user can also provide another object to insert before or after. In this case ExtractInsertionLocation populates outLocation with either en_Before or en_After. outScript will be the object to insert before or after. The utility will verify that outScript is in the same database as inScript, but the script provider must verify that outScript is a valid type.
Parameters
inScriptis the IScript off the parent object. This is the IScript passed to a create event handler.
inDatais the IScriptRequestData passed to the create event.
objectTypeis the type of object being created.
outLocationwill be set to one of five values: en_Unknown, en_Before, en_After, en_Begin, or en_End.
outScript- if outLocation is en_Before or en_After, then this will also be populated with the object to insert before or after.
virtual ErrorCode IScriptUtils::ExtractVersion (IScriptRequestDatadata,
ScriptVersioninternalVersion 
) const
pure virtual

Extracts a ScriptVersion from a p_Version property.

Parameters
dataIN The IScriptRequestData to get the
internalVersionOUT Will be set based on data
Returns
kSuccess if the property can be extracted, otherwise an appropriate error code.
virtual ErrorCode IScriptUtils::GenerateListSpecifier (const EngineContextcontext,
const ScriptList & objects,
PMStringspecifier,
SpecifierForm form = kFormDefault 
)
pure virtual

Generate a text specifier for a list of scriptable objects. This specifier can be resolved to retrieve the objects.

Parameters
contextIN the request context
objectsIN the objects to convert
specifierOUT the generated specifier
formIN the desired specifier format
virtual ErrorCode IScriptUtils::GenerateRangeSpecifier (const EngineContextcontext,
const PMStringfromSpecifier,
const PMStringtoSpecifier,
PMStringspecifier 
)
pure virtual

Combine two specfiers to generate a range specifier for scriptable objects. This specifier can be resolved to retrieve the objects.

Parameters
contextIN is the request context
fromSpecifierIN a specifier for the "from" part of the range
toSpecifierIN a specifier for the "to" part of the range
specifierOUT the generated specifier
virtual ErrorCode IScriptUtils::GenerateSpecifier (const EngineContextcontext,
const IScriptobject,
PMStringspecifier,
SpecifierForm form = kFormDefault 
)
pure virtual

Generate a text specifier for a scriptable object. This specifier can be resolved to retrieve the object.

Parameters
contextIN the request context
objectIN the object to convert
specifierOUT the generated specifier
formIN the desired specifier format
virtual ErrorCode IScriptUtils::GenerateSpecifier (const EngineContextcontext,
const IScriptobject,
PMStringworkSpaceSpecifier,
PMStringobjectSpecifier,
SpecifierForm form = kFormDefault 
)
pure virtual

Generate a text specifier for a scriptable object as two parts: the workspace and the object. This specifier can be concatenated and resolved to retrieve the object.

Parameters
contextIN the request context
objectIN the object to convert
workSpaceSpecifierOUT the generated specifier for the workspace
objectSpecifierOUT the generated specifier for the object
formIN the desired specifier format
virtual ErrorCode IScriptUtils::GetMoveLocation (const IScriptRequestDatainData,
ScriptIDoutLocation,
InterfacePtr< IScript > & outScript 
)
pure virtual

A utility for script providers during their handling of e_Move and e_Duplicate.

Parameters
outLocationis one of the following: en_Before/en_After/en_Begin/en_End
outScriptis the object to move before/after at the beginning/end of
virtual PMString IScriptUtils::GetScriptID (const ScriptIDscriptID)
pure virtual

Translate a scriptID into its four character code

virtual ErrorCode IScriptUtils::GetScriptingSupportFolder (const RequestContextcontext,
IDFileoutFolder 
) const
pure virtual

Returns the folder in which scripting support files are stored.

Parameters
&outFolderIDFile of scripting support folder
Returns
kSuccess or kFailure
virtual void IScriptUtils::GetScriptManagers (ScriptManagerListmgrs) const
pure virtual

Get all script managers

virtual ErrorCode IScriptUtils::GetScriptsFolder (IDFilescriptsFolder,
bool16 resolveAlias 
) const
pure virtual

GetScriptsFolder returns the folder containing the user's scripts panel scripts. This is the folder the Scripts Panel displays for User scripts. In CS2, this was the folder named "Scripts" in the application's "Presets" folder. In CS3, this is the folder named "Scripts Panel" in the user's InDesign preferences' "Scripts" folder.

Parameters
scriptsFolderis the scripts folder [out]
resolveAlias- if true, the value returned in the scriptsFolder parameter is resolved if it's an alias/shortcut [in]
virtual bool16 IScriptUtils::IsIdleProcessingEnabledDuringScripts () const
pure virtual

Checks if idle processing is enabled during scripting. When idle processing is disabled, scheduled command will NOT be executed, idle task handlers will NOT be executed, and no user cancel events will be detected.

virtual bool16 IScriptUtils::IsINX (const RequestContextcontext)
pure virtual

Returns kTrue if the active script context is the script manager for saving to InDesign interchange format

virtual bool16 IScriptUtils::IsINXExpanded (const RequestContextcontext)
pure virtual

Returns kTrue if the active script context is the script manager for INX expanded

virtual bool16 IScriptUtils::IsINXExport (const RequestContextcontext)
pure virtual

Returns kTrue if the active script context is the INX script manager during export session

virtual bool16 IScriptUtils::IsINXTraditional (const RequestContextcontext)
pure virtual

Returns kTrue if the active script context is the script manager for INX traditional

virtual bool16 IScriptUtils::IsNothing (const ScriptDatascriptData)
pure virtual

Returns kTrue if the value of the param is the Nothing enumeration

virtual bool16 IScriptUtils::IsScriptActive ()
pure virtual

Return kTrue if any Script Manager has an active script

virtual IScript* IScriptUtils::QueryApplicationScript () const
pure virtual

Obtain the IScript interface to the application object

virtual IDocument* IScriptUtils::QueryDocumentFromScript (const IScriptscript,
const RequestContextcontext 
)
pure virtual

Access the document containing a script object

Parameters
scriptis the script object
contextis the request context
Returns
the document containing the script object (or nil if not in a document)
virtual IScriptInfoManager* IScriptUtils::QueryScriptInfoManager (const RequestContextcontext) const
pure virtual

Query a particular ScriptInfoManager

virtual IScriptManager* IScriptUtils::QueryScriptManager (ClassID boss) const
pure virtual

Finds a particular script manager

virtual IScriptRequestHandler* IScriptUtils::QueryScriptRequestHandler (const RequestContextcontext) const
pure virtual

Query a particular ScriptRequestHandler

virtual IScriptRunner* IScriptUtils::QueryScriptRunner (const IDFile) const
pure virtual

Finds a script runner that can handle a script file

Returns
nil if no script runner can handle the file
virtual IWorkspace* IScriptUtils::QueryWorkspaceFromScript (const IScriptscript,
const RequestContextcontext 
)
pure virtual

Return the workspace (document or application) for the script object

Parameters
scriptis the script object
contextis the request context
Returns
the workspace for the script object
virtual void IScriptUtils::ReleaseAllObjectsInDatabase (IDataBasedb) const
pure virtual

Release all references to script objects in the database (i.e., because the database is closing)

virtual ErrorCode IScriptUtils::ResolveSpecifier (const EngineContextcontext,
const PMStringspecifier,
ScriptList & resolvedObjects 
)
pure virtual

Resolve an object specifier into a list of objects.

Parameters
contextIN the request context
specifierIN the object specifier to resolve
resolvedObjectsOUT the list of objects that were specified
virtual ErrorCode IScriptUtils::ResolveSpecifier (const EngineContextcontext,
const PMStringworkSpaceSpecifier,
const PMStringobjectSpecifier,
ScriptList & resolvedObjects 
)
pure virtual

Resolve an object specifier into a list of objects.

Parameters
contextIN the request context
workSpaceSpecifierIN the workspace specifier to resolve
objectSpecifierIN the object specifier to resolve
resolvedObjectsOUT the list of objects that were specified
virtual ErrorCode IScriptUtils::SetAppScriptPrefs (bool16 redraw) const
pure virtual

Execute a command to set the application script prefs

Parameters
redrawis whether to enable redraw during script execution
virtual ErrorCode IScriptUtils::SetScriptingTag (const ScriptList & scriptList,
const EngineContextcontext,
const IScriptLabel::ScriptLabelValuelabel,
const IScriptLabel::ScriptLabelKeykey = IScriptLabel::kDefaultScriptLabelKey 
) const
pure virtual

Executes the command to set a script label

Parameters
scriptListis the list of target objects
contextis the request context
labelis the label to set
keyis the key for the label, if any
virtual ErrorCode IScriptUtils::SetScriptingTags (const ScriptList & scriptList,
const EngineContextcontext,
const IScriptLabel::ScriptLabelKeyValueListlabels,
bool16 replaceExistingLabels = kFalse 
) const
pure virtual

Executes the command to set multiple script labels

Parameters
scriptListis the list of target objects
contextis the request context
labelsare the labels to set
replaceExistingLabelsif kTrue, instructs command to first remove all existing labels and insert the newly supplied ones; if kFalse, instructs command to append labels whose keys are not found in the existing set of labels, and replace labels whose keys are found in the existing set of labels
virtual bool16 IScriptUtils::TranslateKeyStringFromScriptClient (PMStrings) const
pure virtual

If a scripting client hands us a string that begins with the keyStringPrefix ("$ID/"), we assume it is a key string, and we use this method to translate it (after dropping the prefix).

Parameters
sis the string to translate
Returns
is kTrue if the string was a key string (and got translated)