Professional Documents
Culture Documents
Solutions 65
Solutions 65
To get the style from an arbitrary position in the story, navigate to the appropriate strand—either the
paragraph (kParaAttrStrandBoss) or character (kCharAttrStrandBoss) attribute strands. Obtain the
IAttributeStrand interface, which supports the IAttributeStrand::GetStyleUID method, returning the style
for a particular text position.
Sample code
See SnpManipulateTextStyle::UpdateParaStyle for an example of accessing the style at a given text index.
Solution
If you have a selection, obtaining the text attribute suite interface (ITextAttributeSuite) from the same boss
class as the text selection (ISelectionUtils::QueryActiveTextSelectionSuite) provides you with methods that
expose the state of a particular attribute (see ITextAttributeSuite::FeatureState). For example,
ITextAttributeSuite::GetCapsModeState indicates whether a certain mode applies to all the text, none of
the text, or some of the text (if the attribute changes along the selection).
To get the attribute value from an arbitrary position in the story, use the IComposeScanner interface (on
kTextStoryBoss). The method IComposeScanner::QueryAttributeAt provides the attribute that applies to
the identified text index.
There is an iterator class (TextAttributeRunIterator) that allows the set of attributes that apply to a range of
text to be accessed, dealing with the changes in attributes that can occur across ranges.
Sample code