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

#include <SnpRunnable.h>

Inheritance diagram for SnpRunnable:
_SnpCreateCrossReference_SnpCreateQRCode_SnpHelloBridgeTalk_SnpHelloCSXS_SnpPlugPlug_SnpRunnerAccessTableContent_SnpRunnerAddMediaFile_SnpRunnerApplyTextStyleAttributes_SnpRunnerChooseFile_SnpRunnerContentDropper_SnpRunnerCopyPasteTable_SnpRunnerCreateAndManipulateSharedLink_SnpRunnerCreateCustomAnimation_SnpRunnerCreateDocument_SnpRunnerCreateFrame_SnpRunnerCreateFrameGrid_SnpRunnerCreateInddPreview_SnpRunnerCreateTable_SnpRunnerEstimateTextDepth_SnpRunnerExportBookAsPDF_SnpRunnerExportDocAsPDF_SnpRunnerExportEPub_SnpRunnerFindAndReplace_SnpRunnerGetTableParcel_SnpRunnerHitTestFrame_SnpRunnerHyphenation_SnpRunnerImportExportSnippet_SnpRunnerImportExportXML_SnpRunnerInsertGlyph_SnpRunnerInspectFontMgr_SnpRunnerInspectLayoutGrid_SnpRunnerInspectLayoutModel_SnpRunnerInspectPathInfo_SnpRunnerInspectSelectionXMLProperties_SnpRunnerInspectTableModel_SnpRunnerInspectTextModel_SnpRunnerInspectTextStyles_SnpRunnerInspectXMPMetaData_SnpRunnerIterTableStories_SnpRunnerIterTableUseDictHier_SnpRunnerManipulateArticles_SnpRunnerManipulateAssignment_SnpRunnerManipulateConditionalText_SnpRunnerManipulateDisplayPerformance_SnpRunnerManipulateGraphicAttributes_SnpRunnerManipulateInCopyCJKGridAttributes_SnpRunnerManipulateInline_SnpRunnerManipulatePathandGraphics_SnpRunnerManipulatePrintStyles_SnpRunnerManipulateSpreadsAndPages_SnpRunnerManipulateStructureView_SnpRunnerManipulateSwatch_SnpRunnerManipulateTableAndCellStyle_SnpRunnerManipulateTextEndnotes_SnpRunnerManipulateTextFootnotes_SnpRunnerManipulateTextFrame_SnpRunnerManipulateTextModel_SnpRunnerManipulateTextOnPath_SnpRunnerManipulateTextStyle_SnpRunnerManipulateTrapStyles_SnpRunnerManipulateXMLElements_SnpRunnerManipulateXMLSelection_SnpRunnerManipulateXMLTags_SnpRunnerModifyLayoutGrid_SnpRunnerModifyTable_SnpRunnerPerformCompFont_SnpRunnerPerformFontGroupIterator_SnpRunnerPerformKinsokuTable_SnpRunnerPerformNamedGrid_SnpRunnerPerformNoteFunction_SnpRunnerPerformTextAttrKenten_SnpRunnerPerformTextAttrLanguage_SnpRunnerPerformTextAttrRuby_SnpRunnerPerformTextAttrTateChuYoko_SnpRunnerPerformTextAttrWarichu_SnpRunnerPerformXMPCommands_SnpRunnerPlaceFile_SnpRunnerPrintDocument_SnpRunnerProcessDocumentLayerCmds_SnpRunnerSelectShape_SnpRunnerSetTableFill_SnpRunnerShareAppResources_SnpRunnerShowPalette_SnpRunnerSortTable_SnpRunnerTemplate_SnpRunnerTransformPageItems_SnpRunnerXMLSampleHelper

Public Member Functions

 SnpRunnable (ConstCString name)
 
virtual ~SnpRunnable ()
 
virtual ConstCString GetName () const
 
virtual ConstCString GetDescription () const
 
virtual ConstCString GetPreconditions () const
 
virtual ConstCString GetCategories () const
 
virtual bool16 CanRun (ISnpRunnableContext *runnableContext)=0
 
virtual ErrorCode Run (ISnpRunnableContext *runnableContext)=0
 
virtual ErrorCode RunUnitTest (ISnpRunnableContext *runnableContext)
 
virtual bool16 CanLoad () const
 
virtual ErrorCode SetupContext (ISnpRunnableContext *runnableContext)
 
virtual
ISnipRunSuite::eSnpRunContextType 
GetContext (void)=0
 

Protected Member Functions

virtual void SetDescription (ConstCString description)
 
virtual void SetPreconditions (ConstCString preconditions)
 
virtual void SetCategories (ConstCString categories)
 

Detailed Description

The hook used to make a snippet of code callable by the SnippetRunner framework and to describe the snippet in the UI. To register the snippet with the framework a static instance of the snippet must be declared. The constructor registers the snippet via SnipRunManager.

This registration happens each time the plug-in is loaded into memory. It's an approach that is ok for a development tool type plug-in like SnippetRunner but is not one that should be used for functional plug-ins.

Constructor & Destructor Documentation

SnpRunnable::SnpRunnable (ConstCString name)

Constructor adds the snippet to the dictionary maintained by SnipRunManager.

Parameters
nameof the snippet.
SnpRunnable::~SnpRunnable ()
virtual

Destructor removes the snippet from the dictionary maintained by SnipRunManager.

Member Function Documentation

virtual bool16 SnpRunnable::CanLoad (void ) const
inlinevirtual

Define this method if your snippet should only be available to be chosen to run under a specific product(InDesign, InCopy, etc) or language (Roman, Japanese), your snippet won't be presented in the framework's UI if you return kFalse. For example if you don't want your snippet to be available to the user under InCopy implement this method and check the product.

Added for 1036945.

The code below shows how your CanLoad method can detect which product or language feature set your snippet is running under.


#include "FeatureSets.h"

#include "LocaleSetting.h"
bool16 isInCopyProductFS = LocaleSetting::GetLocale().IsProductFS(kInCopyProductFS);

bool16 isInDesignProductFS = LocaleSetting::GetLocale().IsProductFS(kInDesignProductFS);

bool16 isRomanLanguageFS = LocaleSetting::GetLocale().IsLanguageFS(kRomanLanguageFS);

bool16 isJapaneseLanguageFS = LocaleSetting::GetLocale().IsLanguageFS(kJapaneseLanguageFS);

Returns
kTrue (default) if the snippet should be presented in the framework's UI, kFalse otherwise.

Reimplemented in _SnpRunnerManipulateTextFrame, _SnpRunnerModifyLayoutGrid, _SnpRunnerPerformTextAttrRuby, _SnpRunnerTransformPageItems, _SnpRunnerManipulatePathandGraphics, _SnpRunnerInspectLayoutGrid, _SnpRunnerPerformTextAttrKenten, _SnpRunnerPerformNamedGrid, _SnpRunnerCreateFrameGrid, _SnpRunnerExportBookAsPDF, _SnpRunnerPerformTextAttrTateChuYoko, _SnpRunnerShowPalette, _SnpRunnerManipulateAssignment, _SnpRunnerManipulateInCopyCJKGridAttributes, _SnpRunnerPerformTextAttrWarichu, _SnpRunnerManipulateGraphicAttributes, _SnpRunnerManipulateDisplayPerformance, _SnpRunnerInspectPathInfo, _SnpRunnerManipulateTextOnPath, and _SnpRunnerExportDocAsPDF.

virtual bool16 SnpRunnable::CanRun (ISnpRunnableContextrunnableContext)
pure virtual

Can the snippet run? Snippets must implement this method and use the given ISnpRunnableContext to figure out if they can run.

Parameters
runnableContext
Returns
kTrue if preconditions for running are met, kFalse otherwise.

Implemented in _SnpRunnerManipulateTextFrame, _SnpRunnerModifyLayoutGrid, _SnpRunnerInspectTextModel, _SnpRunnerApplyTextStyleAttributes, _SnpRunnerManipulateConditionalText, _SnpRunnerManipulateSpreadsAndPages, _SnpRunnerInspectLayoutModel, _SnpRunnerPerformCompFont, _SnpRunnerPerformTextAttrRuby, _SnpRunnerManipulateTextFootnotes, _SnpRunnerManipulateTextEndnotes, _SnpRunnerManipulateXMLElements, _SnpRunnerManipulateTableAndCellStyle, _SnpRunnerManipulateXMLTags, _SnpRunnerInsertGlyph, _SnpRunnerFindAndReplace, _SnpRunnerSortTable, _SnpRunnerPerformKinsokuTable, _SnpRunnerManipulateTextModel, _SnpRunnerTransformPageItems, _SnpRunnerManipulatePathandGraphics, _SnpRunnerManipulateTextStyle, _SnpRunnerManipulatePrintStyles, _SnpRunnerInspectFontMgr, _SnpRunnerInspectLayoutGrid, _SnpRunnerHyphenation, _SnpRunnerPerformTextAttrKenten, _SnpRunnerPerformNamedGrid, _SnpRunnerManipulateSwatch, _SnpRunnerXMLSampleHelper, _SnpRunnerManipulateTrapStyles, _SnpRunnerProcessDocumentLayerCmds, _SnpRunnerPerformTextAttrLanguage, _SnpRunnerInspectTextStyles, _SnpRunnerCreateFrameGrid, _SnpRunnerManipulateXMLSelection, _SnpRunnerImportExportXML, _SnpRunnerPerformFontGroupIterator, _SnpRunnerExportBookAsPDF, _SnpRunnerInspectSelectionXMLProperties, _SnpRunnerPerformXMPCommands, _SnpRunnerShareAppResources, _SnpRunnerChooseFile, _SnpRunnerPerformTextAttrTateChuYoko, _SnpRunnerShowPalette, _SnpRunnerPrintDocument, _SnpRunnerEstimateTextDepth, _SnpRunnerManipulateInline, _SnpRunnerPerformNoteFunction, _SnpRunnerManipulateAssignment, _SnpRunnerManipulateInCopyCJKGridAttributes, _SnpRunnerPerformTextAttrWarichu, _SnpRunnerCreateFrame, _SnpRunnerManipulateArticles, _SnpRunnerManipulateGraphicAttributes, _SnpRunnerManipulateDisplayPerformance, _SnpRunnerImportExportSnippet, _SnpRunnerInspectXMPMetaData, _SnpRunnerContentDropper, _SnpRunnerInspectPathInfo, _SnpRunnerCreateInddPreview, _SnpRunnerIterTableUseDictHier, _SnpCreateCrossReference, _SnpRunnerAddMediaFile, _SnpRunnerManipulateStructureView, _SnpRunnerInspectTableModel, _SnpRunnerModifyTable, _SnpRunnerCreateCustomAnimation, _SnpRunnerCreateAndManipulateSharedLink, _SnpRunnerIterTableStories, _SnpRunnerManipulateTextOnPath, _SnpRunnerExportDocAsPDF, _SnpRunnerHitTestFrame, _SnpRunnerSelectShape, _SnpRunnerGetTableParcel, _SnpRunnerSetTableFill, _SnpRunnerAccessTableContent, _SnpRunnerPlaceFile, _SnpRunnerCopyPasteTable, _SnpRunnerExportEPub, _SnpCreateQRCode, _SnpRunnerCreateTable, _SnpRunnerTemplate, _SnpRunnerCreateDocument, _SnpHelloCSXS, _SnpHelloBridgeTalk, and _SnpPlugPlug.

virtual ConstCString SnpRunnable::GetCategories () const
inlinevirtual

Return the categories this snippet belongs to, formatted as a CSV string e,g, "sdk_snippet, sdk_layout".

virtual ISnipRunSuite::eSnpRunContextType SnpRunnable::GetContext (void )
pure virtual

get the snippet context

Returns
eSnpRunContextType for this snippet

Implemented in _SnpRunnerManipulateTextFrame, _SnpRunnerModifyLayoutGrid, _SnpRunnerInspectTextModel, _SnpRunnerApplyTextStyleAttributes, _SnpRunnerManipulateConditionalText, _SnpRunnerManipulateSpreadsAndPages, _SnpRunnerInspectLayoutModel, _SnpRunnerPerformCompFont, _SnpRunnerPerformTextAttrRuby, _SnpRunnerManipulateTextFootnotes, _SnpRunnerManipulateTextEndnotes, _SnpRunnerManipulateXMLElements, _SnpRunnerManipulateTableAndCellStyle, _SnpRunnerManipulateXMLTags, _SnpRunnerInsertGlyph, _SnpRunnerFindAndReplace, _SnpRunnerSortTable, _SnpRunnerPerformKinsokuTable, _SnpRunnerManipulateTextModel, _SnpRunnerTransformPageItems, _SnpRunnerManipulatePathandGraphics, _SnpRunnerManipulateTextStyle, _SnpRunnerManipulatePrintStyles, _SnpRunnerInspectFontMgr, _SnpRunnerInspectLayoutGrid, _SnpRunnerHyphenation, _SnpRunnerPerformTextAttrKenten, _SnpRunnerPerformNamedGrid, _SnpRunnerManipulateSwatch, _SnpRunnerXMLSampleHelper, _SnpRunnerManipulateTrapStyles, _SnpRunnerProcessDocumentLayerCmds, _SnpRunnerPerformTextAttrLanguage, _SnpRunnerInspectTextStyles, _SnpRunnerCreateFrameGrid, _SnpRunnerManipulateXMLSelection, _SnpRunnerExportBookAsPDF, _SnpRunnerImportExportXML, _SnpRunnerPerformFontGroupIterator, _SnpRunnerInspectSelectionXMLProperties, _SnpRunnerPerformXMPCommands, _SnpRunnerShareAppResources, _SnpRunnerChooseFile, _SnpRunnerPerformTextAttrTateChuYoko, _SnpRunnerShowPalette, _SnpRunnerPrintDocument, _SnpRunnerEstimateTextDepth, _SnpRunnerManipulateAssignment, _SnpRunnerManipulateInline, _SnpRunnerPerformNoteFunction, _SnpRunnerManipulateInCopyCJKGridAttributes, _SnpRunnerPerformTextAttrWarichu, _SnpRunnerCreateFrame, _SnpRunnerManipulateArticles, _SnpRunnerManipulateGraphicAttributes, _SnpRunnerManipulateDisplayPerformance, _SnpRunnerImportExportSnippet, _SnpRunnerInspectPathInfo, _SnpRunnerContentDropper, _SnpRunnerInspectXMPMetaData, _SnpRunnerCreateInddPreview, _SnpRunnerIterTableUseDictHier, _SnpCreateCrossReference, _SnpRunnerAddMediaFile, _SnpRunnerManipulateStructureView, _SnpRunnerInspectTableModel, _SnpRunnerModifyTable, _SnpRunnerCreateCustomAnimation, _SnpRunnerCreateAndManipulateSharedLink, _SnpRunnerManipulateTextOnPath, _SnpRunnerIterTableStories, _SnpRunnerExportDocAsPDF, _SnpRunnerHitTestFrame, _SnpRunnerSelectShape, _SnpRunnerGetTableParcel, _SnpRunnerSetTableFill, _SnpRunnerAccessTableContent, _SnpRunnerPlaceFile, _SnpRunnerCopyPasteTable, _SnpRunnerExportEPub, _SnpCreateQRCode, _SnpRunnerCreateTable, _SnpRunnerTemplate, _SnpRunnerCreateDocument, _SnpHelloCSXS, _SnpHelloBridgeTalk, and _SnpPlugPlug.

virtual ConstCString SnpRunnable::GetDescription () const
inlinevirtual

Return a description of what the snippet does.

virtual ConstCString SnpRunnable::GetName (void ) const
inlinevirtual

Return name of snippet.

virtual ConstCString SnpRunnable::GetPreconditions () const
inlinevirtual

Return dscription of the preconditions necessary for successful execution of the snippet.

virtual ErrorCode SnpRunnable::Run (ISnpRunnableContextrunnableContext)
pure virtual

Run the snippet using the context given by ISnpRunnableContext.

Parameters
runnableContextparameters
Returns
kSuccess on success, other ErrorCode otherwise

Implemented in _SnpRunnerManipulateTextFrame, _SnpRunnerModifyLayoutGrid, _SnpRunnerInspectTextModel, _SnpRunnerApplyTextStyleAttributes, _SnpRunnerManipulateConditionalText, _SnpRunnerManipulateSpreadsAndPages, _SnpRunnerInspectLayoutModel, _SnpRunnerPerformCompFont, _SnpRunnerPerformTextAttrRuby, _SnpRunnerManipulateTextFootnotes, _SnpRunnerManipulateTextEndnotes, _SnpRunnerManipulateXMLElements, _SnpRunnerManipulateTableAndCellStyle, _SnpRunnerManipulateXMLTags, _SnpRunnerInsertGlyph, _SnpRunnerFindAndReplace, _SnpRunnerSortTable, _SnpRunnerPerformKinsokuTable, _SnpRunnerManipulateTextModel, _SnpRunnerTransformPageItems, _SnpRunnerManipulatePathandGraphics, _SnpRunnerManipulateTextStyle, _SnpRunnerManipulatePrintStyles, _SnpRunnerInspectFontMgr, _SnpRunnerInspectLayoutGrid, _SnpRunnerHyphenation, _SnpRunnerPerformTextAttrKenten, _SnpRunnerPerformNamedGrid, _SnpRunnerManipulateSwatch, _SnpRunnerXMLSampleHelper, _SnpRunnerManipulateTrapStyles, _SnpRunnerProcessDocumentLayerCmds, _SnpRunnerPerformTextAttrLanguage, _SnpRunnerInspectTextStyles, _SnpRunnerCreateFrameGrid, _SnpRunnerManipulateXMLSelection, _SnpRunnerImportExportXML, _SnpRunnerPerformFontGroupIterator, _SnpRunnerExportBookAsPDF, _SnpRunnerInspectSelectionXMLProperties, _SnpRunnerPerformXMPCommands, _SnpRunnerShareAppResources, _SnpRunnerChooseFile, _SnpRunnerPerformTextAttrTateChuYoko, _SnpRunnerShowPalette, _SnpRunnerPrintDocument, _SnpRunnerEstimateTextDepth, _SnpRunnerManipulateInline, _SnpRunnerPerformNoteFunction, _SnpRunnerManipulateAssignment, _SnpRunnerManipulateInCopyCJKGridAttributes, _SnpRunnerPerformTextAttrWarichu, _SnpRunnerCreateFrame, _SnpRunnerManipulateArticles, _SnpRunnerManipulateGraphicAttributes, _SnpRunnerManipulateDisplayPerformance, _SnpRunnerImportExportSnippet, _SnpRunnerInspectXMPMetaData, _SnpRunnerContentDropper, _SnpRunnerInspectPathInfo, _SnpRunnerCreateInddPreview, _SnpRunnerIterTableUseDictHier, _SnpCreateCrossReference, _SnpRunnerAddMediaFile, _SnpRunnerManipulateStructureView, _SnpRunnerInspectTableModel, _SnpRunnerModifyTable, _SnpRunnerCreateCustomAnimation, _SnpRunnerCreateAndManipulateSharedLink, _SnpRunnerIterTableStories, _SnpRunnerManipulateTextOnPath, _SnpRunnerExportDocAsPDF, _SnpRunnerHitTestFrame, _SnpRunnerSelectShape, _SnpRunnerGetTableParcel, _SnpRunnerSetTableFill, _SnpRunnerAccessTableContent, _SnpRunnerPlaceFile, _SnpRunnerCopyPasteTable, _SnpRunnerExportEPub, _SnpCreateQRCode, _SnpRunnerCreateTable, _SnpRunnerTemplate, _SnpRunnerCreateDocument, _SnpHelloCSXS, _SnpHelloBridgeTalk, and _SnpPlugPlug.

ErrorCode SnpRunnable::RunUnitTest (ISnpRunnableContextrunnableContext)
virtual

default behavior for snippet unit test

Parameters
runnableContextparameters, this is the same context as in the Run method
Returns
kSuccess on success, other ErrorCode otherwise

Reimplemented in _SnpRunnerCreateFrame, and _SnpRunnerCreateDocument.

virtual void SnpRunnable::SetCategories (ConstCString categories)
inlineprotectedvirtual

To be called by sub-classes in their constructor to describe the categories the snippet belongs too as a CSV string of the form "sdk_snippet, sdk_layout".

Parameters
categories
See Also
sdkdoxygengroups.h for valid categories.
virtual void SnpRunnable::SetDescription (ConstCString description)
inlineprotectedvirtual

To be called by sub-classes in their constructor to describe what the snippet does.

Parameters
description
virtual void SnpRunnable::SetPreconditions (ConstCString preconditions)
inlineprotectedvirtual

To be called by sub-classes in their constructor to describe the preconditions that must be met before SnpRunnable::CanRun will return kTrue.

Parameters
preconditions
ErrorCode SnpRunnable::SetupContext (ISnpRunnableContextrunnableContext)
virtual

default behavior for snippet setup context

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

Parameters
runnableContext
Returns
kSuccess on success, other ErrorCode otherwise

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

Parameters
runnableContext
Returns
kSuccess on success, other ErrorCode otherwise

Reimplemented in _SnpRunnerExportBookAsPDF, and _SnpRunnerExportDocAsPDF.