Skip to main content
Participant
February 12, 2024
Answered

Identify paragraph style override

  • February 12, 2024
  • 2 replies
  • 1076 views

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

Thanks in advance.

This topic has been closed for replies.
Correct answer Rahul_Rastogi

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

2 replies

Inspiring
February 13, 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(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

 

 

 

Participant
February 14, 2024

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

 

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

Rahul_RastogiCorrect answer
Inspiring
February 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)

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

Steve Werner
Community Expert
Community Expert
February 12, 2024

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:

 

danaken3
Participating Frequently
February 12, 2024

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)

rob day
Community Expert
Community Expert
February 12, 2024

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:

 

 

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
};