Drop Cap Style - remove and preserve formatting, find and replace others using same
Hiya,
I've written the below code to "flatten" (I'm more a Photoshop guy, so that makes more sense to me as a term) nested styles, and find and replace any other text using the same nested styles.
I'd like to do the same for Drop Cap Styles but am a bit of a loss where to start. There are no corresponding textPreferences for Drop Caps so that's out, beyond that I'm lost.
Any pointers would be greatly appreciated,
Tim
function removeStyles(check, whitelist) {
for (i = doc.allParagraphStyles.length - 1; i >= 0; i--) {
var clientItem = whitelist[3].arr[i];
var hostItem = doc.allParagraphStyles[i];
try {
if (clientItem.checked === check && clientItem.name === hostItem.name) {
applyNestedStyles(hostItem, hostItem.nestedStyles);
applyNestedStyles(hostItem, hostItem.nestedLineStyles);
hostItem.dropCapStyle.remove();
hostItem.remove();
}
}
catch (e) {
}
}
};
function applyNestedStyles(hostItem, nestedStyles) {
for (j = nestedStyles.length -1; j>=0; j--) {
resetFindReplace();
var charStyle = hostItem.nestedStyles[j].appliedCharacterStyle;
app.findTextPreferences.appliedParagraphStyle = hostItem;
app.findTextPreferences.appliedCharacterStyle = charStyle;
app.changeTextPreferences.appliedCharacterStyle = charStyle;
doc.changeText();
}
}
function resetFindReplace() {
app.findTextPreferences = null;
app.changeTextPreferences = null;
app.findChangeTextOptions.properties = {
includeLockedStoriesForFind: true,
includeLockedLayersForFind: true,
includeHiddenLayers: true,
includeMasterPages: true,
includeFootnotes: true,
wholeWord: false,
caseSensitive: false
}
}
}
