[GastForen Programme Print/Bildbearbeitung Adobe InDesign Skriptwerkstatt

  • Suche
  • Hilfe
  • Lesezeichen
  • Benutzerliste

Seite eines Absatzes ermitteln

Martin Fischer
  
Beiträge gesamt: 12783

18. Dez 2019, 11:51
Bewertung:

gelesen: 2455

Beitrag als Lesezeichen
Hallo Gerald,

guter Hinweis.

Einen Fehler wirft's nicht.
theObj.parentTextFrames[0] ist einfach undefined.

Aber Du hast recht:
Dafür sollte man den Rückgabewert der Funktion noch auf null setzen wie überall dort, wo keine Seite ermittelt werden konnte.

Code
// Dave Saunders (6.5.2010)   
// Gregor Fellenz (26.7.2010)
// http://forums.adobe.com/message/3003131#3003131

function findPage(theObj) {
if (theObj.hasOwnProperty("baseline")) {
theObj = theObj.parentTextFrames[0];
}
while (theObj != null) {
if (theObj.hasOwnProperty ("parentPage")) return theObj.parentPage;
var whatIsIt = theObj.constructor;
switch (whatIsIt) {
case Page : return theObj;
case Character : theObj = theObj.parentTextFrames[0]; break;
case Footnote :; // drop through
case Cell : theObj = theObj.insertionPoints[0].parentTextFrames[0]; break;
case Note : theObj = theObj.storyOffset.parentTextFrames[0]; break;
case XMLElement : if (theObj.insertionPoints[0] != null) { theObj = theObj.insertionPoints[0].parentTextFrames[0]; break; }
case Application : return null;
default: theObj = theObj.parent;
}
if (theObj == null) return null;
}
if (theObj == undefined) theObj = null;
return theObj
} // end findPage


(Dieser Beitrag wurde von Martin Fischer am 18. Dez 2019, 11:57 geändert)
Änderungsverlauf:
Beitrag geändert von Martin Fischer (Moderator) am 18. Dez 2019, 11:56
Beitrag geändert von Martin Fischer (Moderator) am 18. Dez 2019, 11:57