Connect failed: Connection timed out

[GastForen Programme Print/Bildbearbeitung Adobe InDesign

  • Suche
  • Hilfe
  • Lesezeichen
  • Benutzerliste

Suche Script: Mache Textframe aus selektiertem Text

Stephan_M
Beiträge gesamt: 480

15. Mär 2018, 15:03
Bewertung:

gelesen: 3949

Beitrag als Lesezeichen
Omg, ist das lang her. 10 Jahre!!! Und ich benutze deses Skript immer noch täglich und ständig. Es gehört zu meinen Handgriffen. :)

Wenn der selektierte Text aber Spaltenspannend war (diese tolle neue Funktion die irgendwann mit CS5 oder CS6 dazu kam), dann hat das Skript nicht genau funktioniert, das hab ich endlich mal gefixt. *lach*

Code
// SelectedTextToNewFrames.jsx 

// Script expects selected text. It will put the selected text into its own textframe at the same location, the same width of the column and height of the selected text.
// It's a shortcut for the tedious CTRL-dragging of text out to a new framne, or cutting&pasting it out .... for instance if you simply want to move a headline into its own textframe.
// lastEdit 15.03.2018, Stephan Möbius, to make it work with column spanning paragaphs and right- or center-aligned text.

if (app.documents.length > 0 && app.selection.length == 1 && app.selection[0].hasOwnProperty("baseline") && app.selection[0].characters.length > 0) {
var sT = "selectedTextToNewFrame(app.selection[0])";
app.doScript(sT, ScriptLanguage.JAVASCRIPT, [], UndoModes.ENTIRE_SCRIPT, "Text to new frame");
}

function selectedTextToNewFrame(sText) {
var uRuler = app.documents[0].viewPreferences.rulerOrigin;
app.documents[0].viewPreferences.rulerOrigin = RulerOrigin.SPREAD_ORIGIN;
var p = sText.paragraphs[0];
var tf = sText.parentTextFrames[0];
var colType = p.spanColumnType;
var spanColCount = p.spanSplitColumnCount;
spanColCount = (colType != SpanColumnTypeOptions.SPAN_COLUMNS) ? 1 : (spanColCount == SpanColumnCountOptions.ALL ? tf.textFramePreferences.textColumnCount : Math.min(tf.textFramePreferences.textColumnCount,spanColCount));
var uJustification = p.justification;
p.justification = Justification.LEFT_ALIGN;
hProps = [
p.horizontalOffset - p.leftIndent - sText.paragraphs[0].firstLineIndent,
tf.textFramePreferences.textColumnFixedWidth * spanColCount + ((spanColCount-1) * tf.textFramePreferences.textColumnGutter)
];
nFrame = sText.parentTextFrames[0].parent.textFrames.add();
nFrame.geometricBounds = [sText.lines[-1].baseline, hProps[0], sText.lines[0].baseline - sText.lines[0].ascent, hProps[0] + hProps[1]];
nFrame.textFramePreferences.firstBaselineOffset = FirstBaseline.ascentOffset;
nFrame.textWrapPreferences.textWrapMode = TextWrapModes.BOUNDING_BOX_TEXT_WRAP;
nFrame.textWrapPreferences.textWrapOffset = [p.spaceBefore,0,sText.paragraphs[-1].spaceAfter+sText.paragraphs.nextItem(p).spaceBefore,0];
sText.move(LocationOptions.atBeginning, nFrame.insertionPoints.item(0));
//restore users measurement preferences
app.documents[0].viewPreferences.rulerOrigin = uRuler;
nFrame.insertionPoints.item(0).paragraphs[0].justification = uJustification;
}


herzliche Grüße,
Stephan

(Dieser Beitrag wurde von Stephan_M am 15. Mär 2018, 15:05 geändert)
Änderungsverlauf:
Beitrag geändert von Stephan_M (User) am 15. Mär 2018, 15:05