Article View: adobe.scripting.indesign
Article #1488Re: Extracting info from Links panel
From: Harbs
Date: Wed, 11 Feb 2009 11:19
Date: Wed, 11 Feb 2009 11:19
52 lines
2613 bytes
2613 bytes
Hi Peter,
I've reworked that function to make it more complete.
Here's my current version...
var FindWhere = function (obj, where){
var kAppVersion = parseFloat(app.version);
var getTextContainer = function (s){
if(kAppVersion<5){return s.textFrames[-1]}else{return s.textContainers[s.textContainers.length-1]}
}
var getobj = function (fm){//returns the parent text frame, or the last one of the parent story
if(fm != undefined){return fm;}else{return getTextContainer(obj.parentStory);}
}
var getobj_ptf = function (obj){//get the parent text frame or return the original object (necessary for Notes)
try{ return obj.parentTextFrames[0]}catch(e){return obj}
}
var getobj_cell = function (fm){//returns the parent text frame, or the last one of the parnet story -- for cells
if(fm != undefined){return fm;}else{return getTextContainer(obj.insertionPoints[0].parentStory);}
}
var getnote_tf = function (note){//gets the note location for both footnotes and notes in all versions...
if(kAppVersion<5){
if(note.hasOwnProperty("footnoteTextFrame")){var parentFrame = note.footnoteTextFrame}//no good for overset...
else{var parentFrame = note.parentTextFrame}
if(parentFrame){return parentFrame}
else{return note.parent}
}
else{return note.storyOffset}
}
var e;
if(!obj){return null}
if(where == undefined){var where = Page;}
if(obj.hasOwnProperty("baseline")){obj = getobj(getobj_ptf (obj))}
while(obj){
switch(obj.constructor){
case where: return obj;
case Story: obj = getTextContainer(obj);break;
case Character: obj = getobj(getobj_ptf (obj));break;
case Cell: obj = getobj_cell(getobj_ptf(obj.insertionPoints[0]));break;
case Note:
case Footnote: obj = getnote_tf(obj);break;
case Application: return null;
}
if (!obj) return null;
obj = obj.parent;
}
return null;
}
Technical Details
Message-ID:
<59b7d3ce.8@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!newshub.sdsu.edu!webcrossingReferences:
<59b7d3ce.-1@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,bd0091c62c2e8cba X-Google-Attributes: gidf939a,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: Harbs Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!newshub.sdsu.edu!webcrossing Newsgroups: adobe.scripting.indesign Subject: Re: Extracting info from Links panel Message-ID: <59b7d3ce.8@webcrossing.la2eafNXanI> Date: Wed, 11 Feb 2009 03:19:27 -0800 References: <59b7d3ce.-1@webcrossing.la2eafNXanI> Lines: 66 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit