• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

BasicTextAdornment for paragraph or selected text range single or multiline

Contributor ,
Sep 29, 2022 Sep 29, 2022

Copy link to clipboard

Copied

Hi All

 

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.

 

Regards,

Alam

TOPICS
SDK

Views

116

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Contributor , Nov 01, 2022 Nov 01, 2022

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. 

Likes

Translate

Translate
Guide ,
Sep 29, 2022 Sep 29, 2022

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Sep 30, 2022 Sep 30, 2022

Copy link to clipboard

Copied

Thanks for reply, After looking into BTA sample I found that following code is used to hook into composition system

Class
{
kBscTAAttrBoss,
kAttrBossReferencingBoss,
{
/** Hooks into the text composer by telling it that
a text adornment needs to be added. Also provides
a description of the added text adornment.
See BscTAAttrReport.
*/
IID_IATTRREPORT, kBscTAAttrReportImpl,
/** Holds the current state of the text attribute
(adornment). By default, it is OFF. (API-provided implementation)
*/
IID_ITEXTATTRBOOLEAN, kTextAttrBooleanOffImpl,
}
},
 
/** Provides the adornment behavior.

@ingroup basictextadornment
*/
Class
{
kBscTAAdornmentBoss,
kInvalidClass,
{
/** Provides the drawing behavior and other adornment
properties.
See BscTAAdornment.
*/
IID_ITEXTADORNMENT, kBscTAAdornmentImpl,
}
},

and BscTAAttrReport::TellComposition, is the function from which we are invoking BscTAAdornment::draw function

so can someone tell me how I could invoke adornment::draw function if I used IID_IGLOBALTEXTADORNMENT.
I added following code in my fr

 AddIn

    {

        kJMTAdornmentBoss,

        kInvalidClass,

        {

            IID_IK2SERVICEPROVIDER,         kGlobalTextAdornmentServiceImpl,

            IID_IGLOBALTEXTADORNMENT,         kJMTAdornmentImpl,

        }

    }

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Sep 30, 2022 Sep 30, 2022

Copy link to clipboard

Copied

Help me to understand how IGlobalTextAdornment::draw function gets invoke when using IGLOBALTEXTADORNMENT in my fr

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 01, 2022 Oct 01, 2022

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 01, 2022 Nov 01, 2022

Copy link to clipboard

Copied

Change AddIn to Class solved my problem

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 01, 2022 Nov 01, 2022

Copy link to clipboard

Copied

LATEST

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. 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines