Solutions 56

You might also like

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

CHAPTER 2: Text Story text 56

With this background, the solution becomes apparent. For each text story thread dictionary obtained from
ITextStoryThreadDictHier::NextUID, obtain the supported set of text story thread keys using
ITextStoryThreadDict::GetFirstKey/GetNextKey before calling ITextStoryThreadDict::QueryThread.

Sample code

 SnpIterTableUseDictHier

 SnpInspectTextModel::InspectStoryThreadDicts

Obtaining the text story thread for the current selection


If you have a valid text selection, you can determine the text story thread that maintains the contents,

Solution

When dealing with a selection, you need to implement a selection extension pattern, which allows you to
participate in the selection subsystem. As part of this extension pattern, you provide an add-in
implementation of a concrete selection interface on the kTextSuiteBoss (and associated add-in
implementation of an abstract selection interface on the kIntegratorSuiteBoss). For details on
implementing this extension pattern, see the “Selection” chapter of Adobe InDesign Products Programming
Guide.

Use ISelectionUtils::GetActiveSelection to obtain your abstract selection, which can then provide access to
the concrete selection.

ITextTarget (on kTextSuiteBoss) resides on the same boss class as your concrete selection.

ITextTarget::QueryTextModel provides the text model for the current selection. This interface provides
access to the text model as well as information on the range to which the selection applies.

Use ITextModel::QueryStoryThread along with the index provided by the ITextTarget, to obtain the text
story thread.

Inserting an inline graphic into a story


You can insert an inline graphic into the story at a particular position.

Solution

An inline graphic is represented within the text of a story using the special character kTextChar_Inline;
known as the anchor character. This character indicates to the text subsystem that there is an inline item
embedded at this position. The inline itself is represented on the owned item strand
(kOwnedItemStrandBoss). The owned item strand maintains a (persistent/UID-based) reference to the
actual inline item (kInlineBoss) through the IItemStrand interface.

Two actions are required to add an inline to a story:

 Add the anchor character to the story at the required text index.This is done using standard text
content manipulation.

You might also like