Created
May 1, 2015 08:34
-
-
Save milligramme/53ca43fe14950b350ef1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var used_charstyle_ids_in_nestedstyle = function (parastyles) { | |
| var ret = []; | |
| for (var i=0, len=parastyles.length; i < len ; i++) { | |
| var used_c_style_ids = []; | |
| var p_style = parastyles[i]; | |
| var ng_styles = p_style.nestedGrepStyles; | |
| var nl_styles = p_style.nestedLineStyles; | |
| var n_styles = p_style.nestedStyles; | |
| used_c_style_ids = used_c_style_ids.concat(used_charstyle_ids(ng_styles)); | |
| used_c_style_ids = used_c_style_ids.concat(used_charstyle_ids(nl_styles)); | |
| used_c_style_ids = used_c_style_ids.concat(used_charstyle_ids(n_styles)); | |
| ret = ret.concat(used_c_style_ids); | |
| }; | |
| return ret | |
| } | |
| var used_charstyle_ids = function (x_styles) { | |
| var ret = []; | |
| for (var i=0, len=x_styles.length; i < len ; i++) { | |
| var c_style = x_styles[i].appliedCharacterStyle; | |
| ret.push(c_style.id); | |
| }; | |
| return ret | |
| } | |
| var is_included = function (item, list) { | |
| for (var i=0, len=list.length; i < len ; i++) { | |
| if (list[i] === item) { | |
| return true | |
| } | |
| }; | |
| return false | |
| } | |
| // main | |
| var doc = app.documents[0]; | |
| $.writeln(all_used_charstyle_ids(doc)); | |
| function all_used_charstyle_ids(doc) { | |
| var no_charstyle_id = doc.characterStyles.item("$ID/[No Character Style]").id; | |
| var p = doc.allParagraphStyles; | |
| var ids = used_charstyle_ids_in_nestedstyle(p).concat(no_charstyle_id); | |
| return ids | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment