I need to apply adornment to selected text range (selection can be single line or multi line)
I checked with BasicTextAdornment but instead of applying adornment to selected text range it applies adornment to each char style text range (in our selection if I have 2 or more character style or overrides then it applies the adornment to each style range.)
I need to draw symbol [ at the start of selection and ] to the end of selection.
Nothing wrong with multiple style ranges. Text adornments are output produced by the composer for storage within wax (rendered text). Consider them as objectized chance to draw, what you draw is up to you. In preparation (your factory code within the attribute) you can look around your actual composed text, consider the environment (left side, right side, within, also be prepared to encounter multiple chunks / bindings of your own data lumped into a single range, or even overlaps after inconsistent edits) and remember to draw accordingly - store the resulting information in an additional data object of the adornment. For example kTextAdornmentUnderlineBoss would store all data from underline related attributes as seen in the composition state, producing a kTextAdornmentUnderlineDataBoss . That "look around" process would depend on additional objects that is not demonstrated by the BTA example (e.g. hyperlink text source). Handling text adornment data at line wraps, or even across pages, was also left as exercise.
Note that the BTA example is very old, it predates the CS5 split between UI and model plug-in by roughly a decade. Nowadays the IgnoreTag in the .fr is a bad hack. For real world use move most of the plug-in into a model plug-in and only keep the action component in the UI.
Note also that the XML subsystem does not use text adornments, it uses a (page item) adornment and a draw event. I did not look which of them draws the brackets.
Help me to understand how
IGlobalTextAdornment::draw function gets invoke when using IGLOBALTEXTADORNMENT in my fr
While InDesign occasionally uses the same interface with multiple IIDs, you should always watch out for a separate interface, in this case IGlobalTextAdornment. Use a good text editor independent from your particular IDE to search the SDK by file extension. That would lead you to the header and even examples such as the SpellPanel.
Change AddIn to Class solved my problem
I make some hook into HiddenText sample plugin to make it work for applying adornment between selected text range (single/multi-line) and frame selection.