Get unused text styles using Extendscript
I use Extendscript to help me review students' work in InDesign. I run a script (.jsx) that goes through a document and creates a report. The point is to avoid manual, tedious and error-prone work for about 5 InDesign files x 60 students per semester. The report already includes many things like page size, bleed, margins, parent page columns and application, text style options, baseline grid, etc. This script saves me a HUGE amount of time and makes it less likely that I'll forget to check for anything in particular.
What I cannot do yet is to include in this report wether or nor unused paragraph and character styles exist, preferably listing their names.
I tried:
Searching the documentation for a property that might indicate if the paragraph/character style is being used or not.
Invoking (.invoke() method) the Select All Unused menu action from the Paragraph Styles panel. I explored adding event listeners and looking for any results, and also checked the Panel javascript documentation for any way to access a selection. According to what little I found, this is not possible because there's nothing relative to a selection regarding UI elements.
I also considered looping through all stories and paragraphs, checking for the styles in use, and accounting for styles used inside other styles (like "based on"). I've yet to explore scripting with find/replace, because that option would not tell me wether a style with zero uses is the basis for another style. Also, I feel there should be a simpler alternative. Does anyone know of one?
