InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
SnpFindAndReplace Class Reference

Public Member Functions

 SnpFindAndReplace (void)
 
 ~SnpFindAndReplace (void)
 
IFindChangeService::FindChangeResult Do_FindText (const IFindChangeOptions::SearchMode searchMode, const PMString &findString, const IWalkerScopeFactoryUtils::WalkScopeType findScope, const bool16 entireWord=kFalse, const bool16 caseSensitive=kFalse, const bool16 distinguishKanaType=kFalse, const bool16 distinguishKanaWidths=kTrue)
 
IFindChangeService::FindChangeResult Do_ReplaceText (const IFindChangeOptions::SearchMode searchMode, const PMString &findString, const PMString &replaceString, const IWalkerScopeFactoryUtils::WalkScopeType findScope, const ClassID &replaceMode, const bool16 entireWord=kFalse, const bool16 caseSensitive=kFalse, const bool16 distinguishKanaType=kFalse, const bool16 distinguishKanaWidths=kTrue)
 
IFindChangeService::FindChangeResult Do_FindGlyph (const Text::GlyphID findGlyphID, const IWalkerScopeFactoryUtils::WalkScopeType findScope)
 
IFindChangeService::FindChangeResult Do_ReplaceGlyph (const Text::GlyphID findGlyphID, const Text::GlyphID replaceGlyphID, const IWalkerScopeFactoryUtils::WalkScopeType findScope, const ClassID &replaceMode)
 
ErrorCode ReportError (const IFindChangeService::FindChangeResult status)
 

Detailed Description

  • How to set up and perform find change text,
  • How to set up and perform find change text use grep (Grep search),
  • How to set up and perform find change glyph,
  • How to set up and perform find change frame object.

This snippet shows you how to do the equivalent of a search/replace in the find/change dialog. With this code snippet, you can either:

  • find text,
  • replace text.
  • find text with grep,
  • replace text with grep.
  • find glyph,
  • replace glyph.
  • find object,
  • replace object.

One of the most important interface for find/change is IFindChangeOptions. It caches/stores options that are needed to perform search or replace.

InDesign support find/change text, grep, glyph and object. They are specified in SearchMode in IFindChangeOptions, as kTextSearch, kGrepSearch, kGlyphSearch and kObjectSearch respectively.

Find/change functionalilty can be achive in following two steps:

  • Set up find/change options
  • Perform find or change Although these two step are coupled together in our sample code, they can separated executed. For example, you can set find/change text string and find/change glyph IDs first, then set search mode to kTextSearch and search for text. After that, reset search mode to kGlyphSearch and search for glyphs.

While this code snippet processes a multitude of commands to perform each task, there are still some useful find/change related commands that are not used in this code snippet.
[Commands for find/change based on formats]

See Also
IK2ServiceRegistry
IK2ServiceProvider
IFindChangeOptions
IFindChangeCmdData
ITextWalker
ITextWalkerScope
IWalkerScopeFactoryUtils
ITextWalkerSelectionUtils
IStringData
IIntData
IBoolData
kFindStringCmdBoss
kReplaceStringCmdBoss
kScopeCmdBoss
kFindTextCmdBoss
kTWReplaceTextCmdBoss
kReplaceFindTextCmdBoss
kReplaceAllTextCmdBoss
kEntireWordCmdBoss
kCaseSensitiveCmdBoss
kKanaSensitiveCmdBoss
kWidthSensitiveCmdBoss

Constructor & Destructor Documentation

SnpFindAndReplace::SnpFindAndReplace (void )
inline

Constructor.

SnpFindAndReplace::~SnpFindAndReplace (void )
inline

Destructor.

Member Function Documentation

IFindChangeService::FindChangeResult SnpFindAndReplace::Do_FindGlyph (const Text::GlyphID findGlyphID,
const IWalkerScopeFactoryUtils::WalkScopeType findScope 
)

Calls a series of commands to find glyph.

Parameters
findGlyphIDIN The glyph to find.
findScopeIN The scope of the find and replace.
IFindChangeService::FindChangeResult SnpFindAndReplace::Do_FindText (const IFindChangeOptions::SearchMode searchMode,
const PMStringfindString,
const IWalkerScopeFactoryUtils::WalkScopeType findScope,
const bool16 entireWord = kFalse,
const bool16 caseSensitive = kFalse,
const bool16 distinguishKanaType = kFalse,
const bool16 distinguishKanaWidths = kTrue 
)

Calls a series of commands to find text or grep.

Parameters
searchModeIN The serach mode. This method support either kTextSearch or kGrepSearch.
findStringIN The text or grep string to find.
findScopeIN The scope of the find.
entireWordIN Whether to match the entire word or not. kTrue = match entire word. Default is kFalse.
caseSensitiveIN Whether to match in a case-sensitive manner or not. kTrue = case-sensitive. Default is kFalse
distinguishKanaTypeIN Whether to match based on the type of kana (hiragana or katakana). kTrue = match based on type of kana. Default is kFalse.
distinguishKanaWidthsIN Whether to match based on kana width (half-width "hankaku", or full-width "zenkaku"). kTrue = match based on kana width. Default is kTrue.
Returns
Status code. See IFindChangeService::FindChangeResult
See Also
IFindChangeService::FindChangeResult
IFindChangeService::FindChangeResult SnpFindAndReplace::Do_ReplaceGlyph (const Text::GlyphID findGlyphID,
const Text::GlyphID replaceGlyphID,
const IWalkerScopeFactoryUtils::WalkScopeType findScope,
const ClassIDreplaceMode 
)

Calls a series of commands to find and replace glyph.

Parameters
findGlyphIDIN The glyph to find.
replaceGlyphIDIN The glyph to replace with.
findScopeIN The scope of the find and replace.
replaceModeIN A command class ID that specifies which replacement mode to use. Only three are supported by this code snippet: (1) kTWReplaceTextCmdBoss, (2) kReplaceFindTextCmdBoss and (3) kReplaceAllCmdBoss.
See Also
IFindChangeService::FindChangeResult
IFindChangeService::FindChangeResult SnpFindAndReplace::Do_ReplaceText (const IFindChangeOptions::SearchMode searchMode,
const PMStringfindString,
const PMStringreplaceString,
const IWalkerScopeFactoryUtils::WalkScopeType findScope,
const ClassIDreplaceMode,
const bool16 entireWord = kFalse,
const bool16 caseSensitive = kFalse,
const bool16 distinguishKanaType = kFalse,
const bool16 distinguishKanaWidths = kTrue 
)

Calls a series of commands to find and replace text or with grep.

Parameters
searchModeIN The serach mode. This method support either kTextSearch or kGrepSearch.
findStringIN The text/grep string to find.
findStringIN The text/grep string to replace with.
findScopeIN The scope of the find and replace.
replaceModeIN A command class ID that specifies which replacement mode to use. Only three are supported by this code snippet: (1) kTWReplaceTextCmdBoss, (2) kReplaceFindTextCmdBoss and (3) kReplaceAllCmdBoss.
entireWordIN Whether to match the entire word or not. kTrue = match entire word. Default is kFalse.
caseSensitiveIN Whether to match in a case-sensitive manner or not. kTrue = case-sensitive. Default is kFalse
distinguishKanaTypeIN Whether to match based on the type of kana (hiragana or katakana). kTrue = match based on type of kana. Default is kFalse.
distinguishKanaWidthsIN Whether to match based on kana width (half-width "hankaku", or full-width "zenkaku"). kTrue = match based on kana width. Default is kTrue.
Returns
Status code. See IFindChangeService::FindChangeResult
See Also
IFindChangeService::FindChangeResult
ErrorCode SnpFindAndReplace::ReportError (const IFindChangeService::FindChangeResult status)

Reports the status returned from either Do_FindText or Do_ReplaceText.

Parameters
statusIN IFindChangeService::FindChangeResult returned from either Do_FindText or Do_ReplaceText.
Returns
General status code, indicating whether the code snippet succeeded or failed.
See Also
IFindChangeService::FindChangeResult
Do_FindText
Do_ReplaceText