-
1. Re: applying paragraph styles
John Hawkinson Nov 11, 2011 7:53 PM (in response to winterm)This is not the correct approach. It only works by accident.
mysel.paragraphs[0].insertionPoints are all the insertion points in the current paragraph. If there are 100 characters, then there are 101 insertPoints (on each side of each character). insertionPoint[0] is to the left of the first characer, [1] is to the right of the first character, [2] is to the right of the 2nd character, etc., up to [101] to the right of the last character.
insertionPoints[-1] refers to the last insertionPoint, [101], which is actually after the paragraph, per se, so formats the next paragraph.
insertionPoints[-2] refers to the 2nd-to-last insertionPoint, [100], which is the the left of the last character.
I'm not sure what the best way to deal with this is. Perhaps:
mySel=app.selection[0]; p = mySel.paragraphs[0]; p.appliedParagraphStyle="myPstyle1"; p = p.insertionPoints[-1].paragraphs[0]; p.appliedParagraphStyle="myPstyle2"; p = p.insertionPoints[-1].paragraphs[0]; p.appliedParagraphStyle="myPstyle3"; ...
I suppose the exact method depends on what you're trying to do.
-
2. Re: applying paragraph styles
winterm Nov 12, 2011 4:32 AM (in response to John Hawkinson)THANK YOU, John!
That's exactly what I needed!
Especially thank you for clear explanation of InsertionPoints - now I realize I had no idea how it really works... couldn't find this nowhere on the net...
-
3. Re: applying paragraph styles
[Jongware] Nov 12, 2011 5:45 AM (in response to winterm)Use previousItem on your current paragraph:
http://jongware.mit.edu/idcsjs5.5/pc_Paragraphs.html#previousItem
-
4. Re: applying paragraph styles
winterm Nov 12, 2011 7:11 AM (in response to [Jongware])yeah, I know your impressive source, but it is for those one step beyond... I still must discover the very basics...




