You are on page 1of 1

CHAPTER 2: Text Text composition 85

static void MyRecomposeAllStories(IDocument* document)


{
InterfacePtr<IGlobalRecompose> globalRecompose(document, UseDefaultIID());
if (globalRecompose != nil) {
globalRecompose->RecomposeAllStories();
globalRecompose->ForceRecompositionToComplete();
}
}

Getting notified when text is recomposed


It is hard to observe recomposition, because to do so, you need to maintain an observer on each frame
(kFrameItemBoss). See “Observing changes that affect text” for an alternative approach that relies on
observing the cause rather than the effect.

Observing changes that affect text


Because many types of changes affect text, observing changes quickly becomes complex; for example:

 Changes to the geometry of the text layout (such as resize and text inset) are observed using a
document observer.

 Changes to character and text attributes are observed by attaching an observer to each text model of
interest.

 Changes to text styles are observed by attaching observers to the style name tables in the workspace.

An optimal strategy is to be aware recomposition has occurred and not try to observe everything that
might happen.

Any change to text, attributes, styles, or layout that affects lines breaks causes damage. The change
counter on the frame list (IFrameList::GetChangeCounter) is incremented any time something happens
that requires recomposition. No notification is broadcast when the change counter is incremented, so you
cannot catch the change immediately. In general, though, immediate feedback is not needed; the fact that
something changed in a way that affects text needs to be determined only at fixed times.

For example, export a story from InDesign to a copy-editor application. When the story is imported back
into InDesign, you may want to tell the user about changes to the layout or text styling that were made
through InDesign. To arrange this, cache the value of IFrameList::GetChangeCounter when you export the
story. You can then compare this cached value to the actual value when the story is imported. To notify
users when layout changes are made that affect text, check IFrameList::GetChangeCounter using an idle
task.

Controlling the paragraph composer used to compose text


In the “Text Fundamentals” chapter of Adobe InDesign Programming Guide, see the section on “Paragraph
Composers” for information on how to control the paragraph composer used to compose text.
Programmatically, set the kTextAttrComposerBoss paragraph attribute to reference the paragraph
composer to be used.

You might also like