Skip to main content
Participant
November 29, 2023
Answered

Find Cell Style Override?

  • November 29, 2023
  • 7 replies
  • 2440 views

Hi folks,

Is there anyway or method to find out if any cellStyle has been overridden through InDesign JavaScript?

Thanks

AP

This topic has been closed for replies.

7 replies

Legend
December 4, 2023

This type of scripting problem are the most annoying to me as I know the answer is just there. Hidden from the scripter.

 

In the C++ SDK you can call QueryCellOverrides which returns all the overrides in one nice simple call.  You would have thought it would have been exposed to the scripting world, its been there since the beggining of time.

Peter Kahrel
Community Expert
Community Expert
December 4, 2023

_.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.

Robert at ID-Tasker
Legend
December 4, 2023

But the link I've provided says, that it will return list of differences? Not just true / false?

 

Peter Kahrel
Community Expert
Community Expert
December 4, 2023

I didn't see that when I tried. But the point is that the function can't be used for cells because cells will always be flagged as different. The OP wants to know whether any cells differ (from the aplied style), not how they differ.

Robert at ID-Tasker
Legend
December 4, 2023

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

 

https://javascript.plainenglish.io/how-to-get-the-difference-between-two-javascript-objects-e885e09382cb

 

[...] 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? 

 

Robert at ID-Tasker
Legend
December 4, 2023

Or JSON.stringify() route... 

 

Peter Kahrel
Community Expert
Community Expert
November 29, 2023

This came up earlier this year, and someone had a very clever solution. Unfortunately I can't find that thread now.

Robert at ID-Tasker
Legend
November 29, 2023

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...

 

Participant
November 29, 2023

I don't want to clear it.

I want to find out if cell has any cell style override.

Thanks
AP

Brito Haroldo
Inspiring
November 29, 2023

The panel "preflight" dont work to you? If you just want to find it, it works for that.

Participant
November 29, 2023

I want to find out if any cell has appliedCellStyle override through InDesign JavaScript not manually..

 

Thanks

AP

Robert at ID-Tasker
Legend
November 29, 2023

Do you want to FIND or do you want to just REMOVE overrides? 

 

Brito Haroldo
Inspiring
November 29, 2023

This script by Gregor Fellenz may be useful to you: https://github.com/grefel/clearOverrides