Those sample files were perfect, thanks. I've written a quick script. First select some cells and run. See what you think. I've set it up so that the cell width doesn't matter—you can change the width later without wrecking the leader.
- Mark
function main() {
var doc = app.activeDocument,
cells = getCells(doc.selection[0]);
addLeaderLineTabStopToCells(cells);
}
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Add Cell Leader Dots');
/**
* To the text of `cells`, add a right-indent-tab
* and set tab stop with leader.
* @7111211 m1b
* @version 2023-03-22
* @9397041 {Array<Cell>|Cells} cells - the cells to process.
*/
function addLeaderLineTabStopToCells(cells) {
app.scriptPreferences.measurementUnit = MeasurementUnits.POINTS;
for (var i = 0; i < cells.length; i++) {
var cell = cells[i],
text = cell.texts[0];
// set up the tab stop
text.tabStops.add(
{
alignment: TabStopAlignment.RIGHT_ALIGN,
leader: '.',
position: cell.width,
}
);
// insert right-indent tab
text.insertionPoints.lastItem().contents = '\u0008';
}
};
/**
* Attempts to return array of cell, given an object.
* @7111211 m1b
* @version 2023-02-06
* @9397041 {InsertionPoint|Text|Cells|Cells|Table} obj - an object related to a Cell.
* @Returns {Array<Cell>}
*/
function getCells(obj) {
if (obj == undefined)
return;
if (
obj.hasOwnProperty('cells')
&& obj.cells.length > 0
)
return obj.cells;
if (obj.constructor.name == 'Cell')
return [obj];
if (obj.parent.constructor.name == 'Cell')
return [obj.parent];
if (obj.constructor.name == 'Table')
return obj.cells;
};