Article View: adobe.scripting.indesign
Article #15450Re: JS: Copy/Paste
From: Dave_Saunders
Date: Sat, 29 Nov 2003 12:54
Date: Sat, 29 Nov 2003 12:54
16 lines
2114 bytes
2114 bytes
The object model is tough to come to grips with, isn't it. I've actually embarked on a project to document it in my own words for JavaScript users. I actually put up the first page just yesterday evening (and it stills needs my wife to do a copy-editing pass over it). It's on Nested Styles (chosen for two reasons: 1. I have a project involving nested styles right now; 2. The number of properties of nested styles is small enough that a chatty presentation doesn't go on for ever.
You can find it here: Nested Styles Object Model <http://www.pdsassoc.com/index.php?Nav=scriptsub&Ban=NestedStyles&Info=jsobjectmodel/NestedStyles/index.html>.
One of the things that quickly becomes apparent that there are general rules that apply to just about any part of the object model, but each area has its own peculiarities. For example, the object hierarchy in tables. The text in a cell is parented by the cell which is parented by the table.
So, if you select text in a table, you need .parent twice to get to the table while if you select the cell you only need one. Probably a script should do something like:
myTable = app.selection[0].parent
until (myTable.constructor.name == "Table") {
myTable = myTable.parent;
}
except that that's a bit dangerous if the selection is not inside a table. Some kind of exit must be built-in to deal with reaching the top of the hierarchy without finding a table.
Dave
Technical Details
Message-ID:
<2cce9b87.3@webx.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.arcor-online.net!newsfeed01.sul.t-online.de!t-online.de!webxReferences:
<2cce9b87.-1@webx.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,a3cad43350bb7b3d X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2003-11-29 05:07:30 PST From: Dave_Saunders@adobeforums.com Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.arcor-online.net!newsfeed01.sul.t-online.de!t-online.de!webx Newsgroups: adobe.scripting.indesign Subject: Re: JS: Copy/Paste Message-ID: <2cce9b87.3@webx.la2eafNXanI> Date: Sat, 29 Nov 2003 04:54:11 -0800 References: <2cce9b87.-1@webx.la2eafNXanI> Lines: 32 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit