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

Public Member Functions

 SnpApplyTextStyleAttributes ()
 
virtual ~SnpApplyTextStyleAttributes ()
 
ErrorCode ToggleUnderline (ITextAttributeSuite *suite)
 
ErrorCode CycleSmallAllCaps (ITextAttributeSuite *suite)
 
ErrorCode ApplyFontVariant (ITextAttributeSuite *suite, const PMString &typeStyle)
 
ErrorCode ToggleBold (ITextAttributeSuite *suite)
 
ErrorCode ToggleItalic (ITextAttributeSuite *suite)
 
ErrorCode ApplyAlignment (ITextAttributeSuite *suite, const ICompositionStyle::TextAlignment alignment)
 
const UID CreateSDKStyleGroup (IDocument *document, IStyleGroupManager *styleGroupMgr)
 
ErrorCode CreateParaStyle (ITextAttributeSuite *suite, const PMString &styleName, IDocument *document)
 
ErrorCode ApplyParaStyle (ITextAttributeSuite *suite, const PMString &styleName, IDocument *document)
 
ErrorCode CreateCharStyle (ITextAttributeSuite *suite, const PMString &styleName, IDocument *document)
 
ErrorCode ApplyCharStyle (ITextAttributeSuite *suite, const PMString &styleName, IDocument *document)
 
ErrorCode IncrementalCharRotation (ITextAttributeSuite *suite, const PMReal angle)
 
ErrorCode ApplyTsume (ITextAttributeSuite *suite, const PMReal tsume)
 
ErrorCode ApplyMojikumiSpacing (ITextAttributeSuite *suite, const PMReal space, const bool16 isBefore=kTrue)
 
ErrorCode ApplyJidori (ITextAttributeSuite *suite, const int16 jidori)
 
ErrorCode ApplyShatai (ITextAttributeSuite *suite, const PMReal lens, const PMReal angle)
 
ErrorCode SetSingleColumn (ITextModel *textModel, const RangeData &range)
 
ErrorCode SetSpanColumns (ITextModel *textModel, const RangeData &range, int16 spanNumber)
 
ErrorCode SetSplitColumns (ITextModel *textModel, const RangeData &range, int16 splitNumber, PMReal insideGutter, PMReal outsideGutter)
 
const UID ResolveRGBColorSwatch (const PMString &swatchName, const PMReal rRed, const PMReal rGreen, const PMReal rBlue, IDocument *document)
 
ErrorCode ToggleParaBorder (ITextAttributeSuite *suite)
 
ErrorCode ToggleParaShading (ITextAttributeSuite *suite)
 

Detailed Description

  • How to apply text attributes that control by high level ITextAttributeSuite API,
  • How to create and apply of paragraph style and character style,
  • The attributes that control Underline, SmallAllCaps, Font Variant, Alignment, and Japanese Features Character rotete, Tsume, Mojikumi spacing, Jidori, Shatai,
  • This code snippet is the same as the sample code TextStyler of InDesign 2.0 SDK.
See Also
ITextAttributeSuite

Constructor & Destructor Documentation

SnpApplyTextStyleAttributes::SnpApplyTextStyleAttributes ()
inline

Constructor.

virtual SnpApplyTextStyleAttributes::~SnpApplyTextStyleAttributes ()
inlinevirtual

Destructor.

Member Function Documentation

ErrorCode SnpApplyTextStyleAttributes::ApplyAlignment (ITextAttributeSuitesuite,
const ICompositionStyle::TextAlignment alignment 
)

Alignment is applied by creating a "alignment" attribute applied to text. kTextAttrAlignBodyBoss and kTextAttrAlignLastBoss are obsolete, and have been replaced with kTextAttrAlignmentBoss.

Parameters
suiteThe active ITextAttributeSuite for the current text selection.
alignmentThe text alignment.
Returns
kSuccess on success, other ErrorCode otherwise.
ErrorCode SnpApplyTextStyleAttributes::ApplyCharStyle (ITextAttributeSuitesuite,
const PMStringstyleName,
IDocumentdocument 
)

Looks up the character style in the corresponding style table. The name of the style is hardcoded. If the UID is found to be valid, the style is applied using the TextAttributeSuite.

Parameters
suiteThe active ITextAttributeSuite for the current text selection.
styleNamePMSString for the character style name.
documentActive document.
Returns
kSuccess if value is successfully set, kFailure otherwise.
ErrorCode SnpApplyTextStyleAttributes::ApplyFontVariant (ITextAttributeSuitesuite,
const PMStringtypeStyle 
)

Applies the specified font face, by taking the name of the font variant (e.g., "Bold"), and then querying the text attribute suite to determine how many instances of the font variant exist.

Parameters
suiteThe active ITextAttributeSuite for the current text selection.
typeStylePMString for the type face name.
Returns
kSuccess on success, other ErrorCode otherwise.
ErrorCode SnpApplyTextStyleAttributes::ApplyJidori (ITextAttributeSuitesuite,
const int16 jidori 
)

InDesign Japanese Feature. Applies Jidori (effective EmBoxes to occupy) in the selected text. Jidori composes the selected characters in the specified number of character-widths.

Parameters
suiteThe active ITextAttributeSuite for the current text selection.
jidoriNumber of characters for jidori.
Returns
kSuccess if value is successfully set, kFailure otherwise.
ErrorCode SnpApplyTextStyleAttributes::ApplyMojikumiSpacing (ITextAttributeSuitesuite,
const PMReal space,
const bool16 isBefore = kTrue 
)

InDesign Japanese Feature. Inserts mojikumi space before or after the characters in the selected text. Default is "insert before".

Parameters
spaceThe percent of the mojikumi spacing.
isBeforeFlag indicating if we want to set the mojikumi spacing before or after. Default is "before"(kTrue).
ErrorCode SnpApplyTextStyleAttributes::ApplyParaStyle (ITextAttributeSuitesuite,
const PMStringstyleName,
IDocumentdocument 
)

Looks up the paragraph style in the corresponding style table. The name of the style is hardcoded. If the UID is found to be valid, the style is applied using the TextAttributeSuite.

Parameters
suiteThe active ITextAttributeSuite for the current text selection.
styleNamePMSString for the paragraph style name.
documentActive document.
Returns
kSuccess if value is successfully set, kFailure otherwise.
ErrorCode SnpApplyTextStyleAttributes::ApplyShatai (ITextAttributeSuitesuite,
const PMReal lens,
const PMReal angle 
)

InDesign Japanese Feature. Apply shatai in the selected text. Shatai is not Italic, It is an optical effect applied by a lens. Shatai uses a lens magnification (Reduction rate) and an angle parameter.

Parameters
suiteThe active ITextAttributeSuite for the current text selection.
lensLens magnification (Reduction rate).
angleShatai angle.
Returns
kSuccess if value is successfully set, kFailure otherwise.
ErrorCode SnpApplyTextStyleAttributes::ApplyTsume (ITextAttributeSuitesuite,
const PMReal tsume 
)

InDesign Japanese Feature. Set the tsume value on the selected text.

Parameters
suiteThe active ITextAttributeSuite for the current text selection.
tsumeThe Moji-Tsume of the characters by the percent.
Returns
kSuccess if value is successfully set, kFailure otherwise.
ErrorCode SnpApplyTextStyleAttributes::CreateCharStyle (ITextAttributeSuitesuite,
const PMStringstyleName,
IDocumentdocument 
)

Creates a character style with defaults, but blue. The character style table is first queried so that we can be sure the style is not already in the document – if it is, a log message will inform the user that the style has already been created and choose a different name. If the style does not exist, it is created.

Parameters
suiteThe active ITextAttributeSuite for the current text selection.
styleNamePMSString for the character style name.
documentActive document.
Returns
kSuccess if value is successfully set, kFailure otherwise.
ErrorCode SnpApplyTextStyleAttributes::CreateParaStyle (ITextAttributeSuitesuite,
const PMStringstyleName,
IDocumentdocument 
)

Creates a paragraph style with all the defaults, but 18 point font size. The paragraph style table is first queried so that we can be sure the style is not already in the document – if it is, a log message will inform the user that the style has already been created and choose a different name. If the style does not exist, it is created.

Parameters
suiteThe active ITextAttributeSuite for the current text selection.
styleNamePMSString for the paragraph style name.
Returns
kSuccess on success, other ErrorCode otherwise.
const UID SnpApplyTextStyleAttributes::CreateSDKStyleGroup (IDocumentdocument,
IStyleGroupManagerstyleGroupMgr 
)

Create a SDK group to organize the styles created in this snippets, also to demo the new feature available in CS3

Parameters
documentWe are creating the style as part of doc workspace, this is the doc associated with the style
styleGroupMgrthe doc's style group manager, could be either for char or para style, depends on how you query it.
ErrorCode SnpApplyTextStyleAttributes::CycleSmallAllCaps (ITextAttributeSuitesuite)

Queries the TextAttributeSuite for the CapsMode attribute. Finding one instance of the normal/small/all caps attribute in the selected text range means that it may or may not be applied, and the mode must be queried to determine this. Finding multiple instances means that there is a mix of modes (part of the text is small/all caps, part is not).

Parameters
suiteThe active ITextAttributeSuite for the current text selection.
Returns
kSuccess on success, other ErrorCode otherwise.
ErrorCode SnpApplyTextStyleAttributes::IncrementalCharRotation (ITextAttributeSuitesuite,
const PMReal angle 
)

InDesign Japanese Feature. Incremental rotation to characters individually in the specified angle.

Parameters
suiteThe active ITextAttributeSuite for the current text selection.
angleAngle of character rotation.
Returns
kSuccess if value is successfully set, kFailure otherwise.
const UID SnpApplyTextStyleAttributes::ResolveRGBColorSwatch (const PMStringswatchName,
const PMReal rRed,
const PMReal rGreen,
const PMReal rBlue,
IDocumentdocument 
)

Finds or creates a color in the swatch list, returning a UID to the color. We use a color swatch for the character style.

Parameters
swatchNameSwatch Name
rRedRed (0.0...1.0)
rGreenGreen (0.0...1.0)
rBlueBlue (0.0...1.0)
documentActive document.
Returns
returning a UID to the color.
ErrorCode SnpApplyTextStyleAttributes::SetSingleColumn (ITextModeltextModel,
const RangeDatarange 
)

For paragraphy layout, set single column.

Parameters
textModelThe text model for the current text selection.
rangeThe text range.
Returns
kSuccess on success, other ErrorCode otherwise.
ErrorCode SnpApplyTextStyleAttributes::SetSpanColumns (ITextModeltextModel,
const RangeDatarange,
int16 spanNumber 
)

For paragraphy layout, set span columns.

Parameters
textModelThe text model for the current text selection.
rangeThe text range.
spanNumberThe number of the columns which need be spanned.
Returns
kSuccess on success, other ErrorCode otherwise.
ErrorCode SnpApplyTextStyleAttributes::SetSplitColumns (ITextModeltextModel,
const RangeDatarange,
int16 splitNumber,
PMReal insideGutter,
PMReal outsideGutter 
)

For paragraphy layout, set split columns.

Parameters
textModelThe text model for the current text selection.
rangeThe text range.
splitNumberThe number of the sub-columns.
insideGutterThe inside gutter of split columns.
outsideGutterThe outside gutter of split columns.
Returns
kSuccess on success, other ErrorCode otherwise.
ErrorCode SnpApplyTextStyleAttributes::ToggleBold (ITextAttributeSuitesuite)

Toggles the Bold font style state.

Parameters
suiteThe active ITextAttributeSuite for the current text selection.
Returns
kSuccess on success, other ErrorCode otherwise.
ErrorCode SnpApplyTextStyleAttributes::ToggleItalic (ITextAttributeSuitesuite)

Toggles the Italic font style state.

Parameters
suiteThe active ITextAttributeSuite for the current text selection.
Returns
kSuccess on success, other ErrorCode otherwise.
ErrorCode SnpApplyTextStyleAttributes::ToggleUnderline (ITextAttributeSuitesuite)

Toggles the underline state.

Parameters
suiteThe active ITextAttributeSuite for the current text selection.
Returns
kSuccess on success, other ErrorCode otherwise.