Copy link to clipboard
Copied
Hello All,
I am checking text for style overrides. Now if a piece of text has a character style applied over it and has an override of auto leading. The styleoverridden property returns false. How do we explain this? Is it a bug or am i missing something?
-Manan
Hi,
Could you not use textHasOverrides, as this takes a paragraph or character style.
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Character.html#d1e461137__d1e469100
Boolean textHasOverrides (charOrParaStyle:StyleType, [charStyleAsOverride:Boolean=Boolean])
If true, text has local overrides
Parameter | Type | Description |
---|---|---|
charOrParaStyle | StyleType.CHARACTER_STYLE_TYPE StyleType.PARAGRAPH_STYLE_TYPE | Style type to look at. |
charStyleAsOverride | Whether to consider character styles |
Copy link to clipboard
Copied
Hi Manan,
just tested this and I see that texts[0].styleOverridden returns true.
Do you have a sample document where you are seeing this?
Regards,
Uwe
Copy link to clipboard
Copied
Hi Uwe,
I get it even on a fresh document that i create. I have tested it on CC2017 MAC and CC2018 WIN. See the video cast i attach below
-Manan
Copy link to clipboard
Copied
My explanation is:
styleOverridden is showing if the paragraph style is overridden.
In your sample the applied character style is overridden.
FWIW: In my test before the paragraph style was overridden.
Regards,
Uwe
Copy link to clipboard
Copied
Seems the DOM documentation lacks to state that this property will work only for ParagraphStyle overrides.
styleOverridden | readonly | If true, the applied style has been overridden with additional attributes. |
I tested that if i apply a paragraph style on to it that has leading set to something other than auto and hence has override, i do get the result as true when checking styleOveridden.
Is then there no way to identify the override for the case that i specified?
-Manan
Copy link to clipboard
Copied
Hi,
Could you not use textHasOverrides, as this takes a paragraph or character style.
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Character.html#d1e461137__d1e469100
Boolean textHasOverrides (charOrParaStyle:StyleType, [charStyleAsOverride:Boolean=Boolean])
If true, text has local overrides
Parameter | Type | Description |
---|---|---|
charOrParaStyle | StyleType.CHARACTER_STYLE_TYPE StyleType.PARAGRAPH_STYLE_TYPE | Style type to look at. |
charStyleAsOverride | Whether to consider character styles as overrides or not (Optional) (default: true) |
Copy link to clipboard
Copied
Hi BarlaeDC ,
thank you very much for this. It seems that method textHasOverrides() was introduced with InDesign version 11.
https://www.indesignjs.de/extendscriptAPI/indesign11/#Text.html#d1e409488
Just testing this 🙂
Regards,
Uwe
Copy link to clipboard
Copied
Thanks, seems promising, i will test it and update you guys back.
-Manan
Copy link to clipboard
Copied
Hm. If we follow the DOM discription in InDesign version 11 textHasOverrides() has only one argument:
https://www.indesignjs.de/extendscriptAPI/indesign11/#Text.html#d1e411934__d1e417388
With InDesign version 12, 13 and 14 it has two arguments:
https://www.indesignjs.de/extendscriptAPI/indesign12/#Text.html#d1e446908__d1e454077
Regards,
Uwe
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I had to investigate in more depth the Text.styleOverridden and Text.textHasOverrides() features for a personal project. These results could complement and qualify some of the information presented here.
→ “Private Investigation into Style Overrides” (April 2024)
Best,
Marc