Script help: Quick way to check if a paragraph style has been moded
Hello
is there method or something alreay within indesign API to check if there are paragraph style overrides which can product a boole result?
I have the following:
// Function to check if the paragraph style has been overridden
function isParagraphStyleOverridden(paragraph) {
return paragraph.styleOverrides.length > 0; // Returns true if there are overrides
}
The reason being I had this stupid bit of code from a few months ago which really is terrible and would prefer a dynamic approach
// Function to check if the paragraph matches its base paragraph style
function isStyleUnmodified(paragraph) {
// Get the paragraph style applied to the paragraph
var paragraphStyle = paragraph.appliedParagraphStyle;
// If there's no style applied, return false
if (!paragraphStyle) {
return false;
}
// Get the properties to check
var styleProperties = ['appliedFont', 'pointSize', 'fillColor', 'fillTint', 'justification',
'leading', 'firstLineIndent', 'baselineShift', 'tracking',
'capitalization', 'alignToBaseline', 'ruleAbove', 'ruleBelow',
'spaceBefore', 'spaceAfter'];
// Check each property against the paragraph style
for (var i = 0; i < styleProperties.length; i++) {
var prop = styleProperties[i];
if (paragraph[prop] !== paragraphStyle[prop]) {
return false; // If any property is different, return false
}
}
// If all properties match, return true
return true;
}
But not sure if there are other ways of doing this?
Thank you,
Smyth

