Copy link to clipboard
Copied
Hi folks,
Is there anyway or method to find out if any cellStyle has been overridden through InDesign JavaScript?
Thanks
AP
Copy link to clipboard
Copied
This script by Gregor Fellenz may be useful to you: https://github.com/grefel/clearOverrides
Copy link to clipboard
Copied
Do you want to FIND or do you want to just REMOVE overrides?
Copy link to clipboard
Copied
I don't want to clear it.
I want to find out if cell has any cell style override.
Thanks
AP
Copy link to clipboard
Copied
The panel "preflight" dont work to you? If you just want to find it, it works for that.
Copy link to clipboard
Copied
I want to find out if any cell has appliedCellStyle override through InDesign JavaScript not manually..
Thanks
AP
Copy link to clipboard
Copied
It's not so easy - as there is no "overriden" flag - so you'd have to check EVERY property of the Cell...
Copy link to clipboard
Copied
This came up earlier this year, and someone had a very clever solution. Unfortunately I can't find that thread now.
Copy link to clipboard
Copied
In JS it should be pretty easy - get list of all properties of both objects and compare - JS offers a quick and easy way to do this - but I'm not JS guy...
Copy link to clipboard
Copied
Copy link to clipboard
Copied
@Dirk Becker, but this only returns cells that have overrides - not which property has been overriden?
Copy link to clipboard
Copied
The original request was "find out if any cellStyle has been overridden"
The approach could even work across all cells of each row, or the entire table at once, then nail it down with binary search.
Copy link to clipboard
Copied
Yeah, it can be used as a starting point for more detailed "fishing expedition".
Copy link to clipboard
Copied
This solution is close so far desktop application scripting. Unfortunetly this will not work in InDesign Server Scripting.
Atleast we have something now for dekstop application atleast.
Thanks
AP
Copy link to clipboard
Copied
Why not? It doesn't use clipboard so there is no reason why it shouldn't work on IDS?
Copy link to clipboard
Copied
InDesign Server doesn't have menus, therefore no menuActions.
Copy link to clipboard
Copied
Right... So the only solution is a "brute force" approach - check / compare every property...
Copy link to clipboard
Copied
Wait a second... If you are working on a Server - how can you have any kind of overrides??
Copy link to clipboard
Copied
A script 🙂
Copy link to clipboard
Copied
A script 🙂
By @Peter Kahrel
??
Are you replying to my question how there can be overrides on IDS ?
Copy link to clipboard
Copied
Yes.
Copy link to clipboard
Copied
I'm not JS guy at all so maybe I'm barking the wrong tree, but this in Google:
"js find differences between two objects"
returns articles about:
Lodash _.isEqual() Method
[...] Calling this with two objects will return an array of the names of keys on the objects whose values are not equal, and also includes the names of keys that do not exist on both objects [...]
Or it won't work in the JS version that is used in the InDesign?
Copy link to clipboard
Copied
Or JSON.stringify() route...
Copy link to clipboard
Copied
_.isEqual() is UXP-only. It works on JavaScript objects such as strings, arrays, and JSON objects, but not on most InDesign objects. For instance, cells have a name, and no two cells have the same name, and therefore _isEqual() always returns false when you compare two cells.
Copy link to clipboard
Copied
But the link I've provided says, that it will return list of differences? Not just true / false?