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

Identify paragraph style override

Community Beginner ,
Feb 12, 2024 Feb 12, 2024

Copy link to clipboard

Copied

Hi is there any way to identify that paragraph style is an override or not using indesign sdk?

Thanks in advance.

TOPICS
How to , SDK

Views

489

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 2 Correct answers

Contributor , Feb 12, 2024 Feb 12, 2024

Hi @Jethika27555372y6gg ,

 

Using InDesign SDK, You can use the following code snippet to check whether para style is overridden for the underlying text or not -

 

InterfacePtr<IAttributeStrand> iParaAttributeStrand(((IAttributeStrand*)iTextModel->QueryStrand(kParaAttrStrandBoss, IAttributeStrand::kDefaultIID)));

 

DataWrapper<AttributeBossList> paraStyleAttrListOverrides = iParaAttributeStrand->GetLocalOverrides(startIndex, &paraStyleOverrideLength, &outStartIndex);

 

if(paraStyleAttrListOverri

...

Votes

Translate

Translate
Contributor , Feb 14, 2024 Feb 14, 2024

You need to know the boss class of the attribute that you want to fetch. For that you need to search InDesign SDK or use InDesign debug build.

 

Also, internal attribute boss names might differ what is shown in the UI. It won't be exactly the same.

 

Refer the below code -

 

InterfacePtr<ITextAttrBreakBeforeMode> iTextAttrBreakBeforeMode((ITextAttrBreakBeforeMode*)paraStyleAttrListOverrides->QueryByClassID(kTextAttrGotoNextXBoss, IID_ITEXTATTRBREAKBEFOREMODE));

if(!iTextAttrBreakBeforeMode)

brea

...

Votes

Translate

Translate
Community Expert ,
Feb 12, 2024 Feb 12, 2024

Copy link to clipboard

Copied

You can identify type which has an override of a paragraph style by using the Style Override Highlighter icon at the upper right of the Paragraph Styles panel:

 

Screenshot 2024-02-12 at 8.05.01 AM.png

Votes

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
Participant ,
Feb 12, 2024 Feb 12, 2024

Copy link to clipboard

Copied

The following method seems to work with a textStyleRange (but I'm having trouble getting it to work consistently for a paragraph).

textHasOverrides (charOrParaStyle:StyleType, [charStyleAsOverride:Boolean=Boolean])
  • charOrParaStyle: StyleType.CHARACTER_STYLE_TYPE or StyleType.PARAGRAPH_STYLE_TYPE

    Style type to look at.

  • charStyleAsOverride: Boolean
    Whether to consider character styles as overrides or not (Optional)

    (default: true)

Votes

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
Community Expert ,
Feb 12, 2024 Feb 12, 2024

Copy link to clipboard

Copied

Hi @Jethika27555372y6gg , As @danaken3 suggests you would have to check the story’s text ranges—at least with JavaScript. If you check the paragraph with JS, it would only return true if the entire paragraph is overriden. So here I have 3 paragraphs with one word overridden:

 

Screen Shot 24.png

 

This loop through textStyleRanges returns false, true, false:

var dp = app.documents[0].stories.everyItem().textStyleRanges.everyItem().getElements();

for (var i = 0; i < dp.length; i++){
    $.writeln(dp[i].textHasOverrides(StyleType.PARAGRAPH_STYLE_TYPE))
    //returns false, true, false
};   

 

But this loop through paragraphs returns false, false, false because only one word in paragraph 2 is overridden

 

var dp = app.documents[0].stories.everyItem().paragraphs.everyItem().getElements();

for (var i = 0; i < dp.length; i++){
    $.writeln(dp[i].textHasOverrides(StyleType.PARAGRAPH_STYLE_TYPE))
    //returns false, false, false
};   

Votes

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
Community Expert ,
Feb 13, 2024 Feb 13, 2024

Copy link to clipboard

Copied

There is no "textHasOverrides" in VB6?? Will have to use DoScript().

 

Is there any way - from JS - to get what exactly is different?

 

Votes

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 ,
Feb 12, 2024 Feb 12, 2024

Copy link to clipboard

Copied

Hi @Jethika27555372y6gg ,

 

Using InDesign SDK, You can use the following code snippet to check whether para style is overridden for the underlying text or not -

 

InterfacePtr<IAttributeStrand> iParaAttributeStrand(((IAttributeStrand*)iTextModel->QueryStrand(kParaAttrStrandBoss, IAttributeStrand::kDefaultIID)));

 

DataWrapper<AttributeBossList> paraStyleAttrListOverrides = iParaAttributeStrand->GetLocalOverrides(startIndex, &paraStyleOverrideLength, &outStartIndex);

 

if(paraStyleAttrListOverrides->CountBosses() == 0)

CAlert::InformationAlert("There are no para overrides");

else

CAlert::InformationAlert("para style is overridden")

 

To get the which parastyle is overridden you can use iParaAttributeStrand->GetStyleUID()

 

 

- Rahul Rastogi

InDesign SDK C++ Custom Plugin Architect

 

 

 

Votes

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
New Here ,
Feb 13, 2024 Feb 13, 2024

Copy link to clipboard

Copied

Thank you @Rahul_Rastogi this method works. 

Votes

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
Community Beginner ,
Feb 13, 2024 Feb 13, 2024

Copy link to clipboard

Copied

Hi @Rahul_Rastogi  there is one antoher question lets say i override a paragraph using keep option ->In Next Column 

Jethika27555372y6gg_0-1707895457341.png

 

is there any way to get this next column attribute as a string variable 

Votes

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 ,
Feb 14, 2024 Feb 14, 2024

Copy link to clipboard

Copied

LATEST

You need to know the boss class of the attribute that you want to fetch. For that you need to search InDesign SDK or use InDesign debug build.

 

Also, internal attribute boss names might differ what is shown in the UI. It won't be exactly the same.

 

Refer the below code -

 

InterfacePtr<ITextAttrBreakBeforeMode> iTextAttrBreakBeforeMode((ITextAttrBreakBeforeMode*)paraStyleAttrListOverrides->QueryByClassID(kTextAttrGotoNextXBoss, IID_ITEXTATTRBREAKBEFOREMODE));

if(!iTextAttrBreakBeforeMode)

break;

 

if(iTextAttrBreakBeforeMode->Get() == Text::kAtColumn)

CAlert::InformationAlert("At next column");

 

// As per InDesign SDK for possible values of break mode -

kNoForcedBreak
kStartAnywhere
kAtColumn
kAtPage
kAtFrameBox
kAtOddPage
kAtEvenPage

 

 

- Rahul Rastogi

InDesign SDK C++ Custom Plugin Architect

Votes

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