Solutions 60

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

CHAPTER 2: Text Text formatting 60

Inserting page numbering and title heading into a Story


Solution

The text composition engine provided with the application automatically replaces special characters in
the text stream with page numbering and/or section header text (the exact format defined by the
preferences). For page numbering, insert the kTextChar_PageNumber character into the text story. For
headings, insert the kTextChar_SectionName special character into the text model.

Text formatting
This section contains use cases related to formatting text and managing text styles within the application.

Text is formatted to give it a particular look, like underlined or in a particular font face. The desired look of
text can be described by a set of attributes; for example, a point size or text color. Attributes are defined to
be either character or paragraph based. Character attributes can be applied to text at any granularity, from
a single character to the entire story. Paragraph attributes are settings that work at the granularity of a
paragraph (for example, hyphenation behavior or horizontal justification).

Generally, attributes are grouped together to describe a common theme (for example, a heading or body
text); these themes are called styles. Attributes also can be applied to text independently of any applied
style. These attributes are said to be overrides, as they override the definition of that attribute in the style.

A style is a mechanism for identifying groups of attributes. In the application, character and paragraph
styles are supported (along with table styles, which are not considered here). Character styles contain only
character-based attributes. Paragraph styles can contain either character- or paragraph-based attributes.
The style can be queried to determine its type (IStyleInfo::GetStyleType). All text has a character and
paragraph style applied to it (represented on the character and paragraph attribute strands, respectively).

For more information, see the “Text Fundamentals” chapters of Adobe InDesign Programming Guide.

Accessing the set of supported styles


Styles can exist for all documents on a session or a particular document. They are accessed through the
workspace and are modeled within the application using the persistent kStyleBoss. Session workspace
styles are inherited into the document workspace (thus preventing the style not being available at a later
date or on another machine).

You can access the set of styles available to a particular document.

Solution

Styles can exist on either the session or document workspace. Session workspace styles are available for all
documents; document workspace styles are available only for that document. The workspace boss classes
support two implementations of the IStyleGroupManager interface, IID_IPARASTYLEGROUPMANAGER for
paragraph styles and IID_ICHARSTYLEGROUPMANAGER for character styles. The interface provides the
GetRootHierarchy() API, which returns a pointer to IStyleGroupHierarchy at the root level. Use
IStyleGroupHierarchy to iterate across the supported styles.

You might also like