Thursday, September 15, 2005


Text Processing -- Applying Those Styles

We return to Tuesday's function. The one that looked like this when we left it
function applyParaStyles(theTable) {
 // Returns true if all OK,
 // else loads logs error to global variable myErr and returns false
 var myLim = myTable.columns.length;
 for (var j = 0; myLim > j; j++) {
  var myStyle = getParaStyle(theTable.cells[j].contents);
It turns out that it only takes a couple more lines of code to complete this script (although there might be more needed later to deal with error conditions that I so far haven't thought of. After we get the style for a column, we can apply it to all the text in the column with a single command:
  theTable.columns[j].cells.everyItem().texts[0].appliedParagraphStyle = myStyle;
Notice that we applied the style not to the cells but to the texts[0] of the cells. Why? Because some of the cells could be overset and we still want to apply the style to the overset text.

Finally, we need to indicate to the calling routine that all is well by returning true.

Comments: Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?