Deleting A Style; Importing Paragraph And Character Styles; Finding And Changing Text - Adobe 65009333 - InCopy CS4 - PC Manual

Scripting guide: javascript
Hide thumbs Also See for 65009333 - InCopy CS4 - PC:
Table of Contents

Advertisement

Text and Type

Deleting a style

When you delete a style using the user interface, you can choose how you want to format any text tagged
with that style. InCopy scripting works the same way, as shown in the following script fragment (from the
RemoveStyle tutorial script):
//Remove the paragraph style myParagraphStyleA and replace with myParagraphStyleB.
myParagraphStyleA.remove(myDocument.paragraphStyles.item("myParagraphStyleB"));

Importing paragraph and character styles

You can import paragraph and character styles from other InCopy documents. The following script
fragment shows how (for the complete script, see ImportTextStyles):
//Import the styles from the saved document.
//importStyles parameters:
//Format as ImportFormat enumeration. Options for text styles are:
//
ImportFormat.paragraphStylesFormat
//
ImportFormat.characterStylesFormat
//
ImportFormat.textStylesFormat
//From as File
//GlobalStrategy as GlobalClashResolutionStrategy enumeration. Options are:
//
GlobalClashResolutionStrategy.doNotLoadTheStyle
//
GlobalClashResolutionStrategy.loadAllWithOverwrite
//
GlobalClashResolutionStrategy.loadAllWithRename
myDocument.importStyles(ImportFormat.textStylesFormat, File(myFilePath),
GlobalClashResolutionStrategy.loadAllWithOverwrite);

Finding and changing text

The find/change feature is one of the most powerful InCopy tools for working with text. It is fully
supported by scripting, and scripts can use find/change to go far beyond what can be done using the
InCopy user interface. InCopy has three ways of searching for text:
You can find text and text formatting and change it to other text and/or text formatting. This type of
find and change operation uses the
specify parameters for the
You can find text using regular expressions, or "grep. " This type of find and change operation uses the
findGrepPreferences
and
changeGrep
You can find specific glyphs (and their formatting) and replace them with other glyphs and formatting.
This type of find and change operation uses the
changeGlyphPreferences
methods.
All find and change methods take a single optional parameter,
which the results of the search are returned. If you are processing the results of a find or change operation
in a way that adds or removes text from a story, you might face the problem of invalid text references, as
discussed in
iterate backward through the collection of returned text objects, or you can have the search operation
return the results in reverse order and then iterate through the collection normally.
findText
and
changeGrepPreferences
methods.
objects to specify parameters for the
"Text objects and iteration" on page
findTextPreferences
and
methods.
changeText
objects to specify parameters for the
findGlyphPreferences
reverseOrder
37. In this case, you can either construct your loops to
Finding and changing text 45
and
changeTextPreferences
and
and
findGlyph
changeGlyph
, which specifies the order in
objects to
findGrep

Advertisement

Table of Contents
loading

This manual is also suitable for:

Incopy cs4

Table of Contents