🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #838

Re: [CS3 JS] Question about collecting overridden style settings

#838
From: Andreas_Jansson
Date: Thu, 05 Mar 2009 14:07
23 lines
2209 bytes
Ah, it looks like it's beginning to work now :-)
I thought I had tried some of these things before, but obviously not. Thanks Peter, for your assistance. Now even assigning the whole properties collection of the TextStyleRange objects to the new character style object works! There's a lot of properties created, which I'd really would have preferred not to show up (in the summary of the character style dialogue box), since they are (as far as I can see) the default values, but I like the easy code this approach results in:

var selText = app.selection;
var srs = selText[0].textStyleRanges;

for (var iTSR=srs.length-1; iTSR>=0; iTSR--){ 

      	if (srs[iTSR].styleOverridden){ >		// This is an overridden style we
      need to create a style for >		var ch = srs[iTSR]; >		newStyle = app.activeDocument.characterStyles.add(ch.properties);
      >		if (app.activeDocument.characterStyles.item('newstyle'+iTSR.toString())!=null)
      app.activeDocument.characterStyles.item('newstyle'+iTSR.toString()).remove();
      >		newStyle.name = 'newstyle'+iTSR.toString(); 	} }





I'm not yet quite clear on how to treat overridden paragraph styles. Perhaps I need to check whether the properties of the new character style are already the same as the ones of an possibly applied paragraph style, and if so, not assign (or remove) that property from the new character style.

Also... possible need to name all uniquley auto-generated styles and find a way to apply the same style again (not to risk creating a large number of character styles just setting "bold").

Andreas
Technical Details
Message-ID: <59b81cad.4@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newshub.sdsu.edu!webcrossing
References: <59b81cad.-1@webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,ae48fa806cc37e1a
X-Google-Attributes: gidf939a,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: Andreas_Jansson@adobeforums.com
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newshub.sdsu.edu!webcrossing
Newsgroups: adobe.scripting.indesign
Subject: Re: [CS3 JS] Question about collecting overridden style settings
Message-ID: <59b81cad.4@webcrossing.la2eafNXanI>
Date: Thu, 5 Mar 2009 06:07:21 -0800
References: <59b81cad.-1@webcrossing.la2eafNXanI>
Lines: 35
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit