In an outline document, the use of levels (idents) is designed to convey the relationship between segments of data. To further highlight the hierarchical roles of segments and rows of data, distinct text styling is often applied to rows based upon their position in the outline hierarchy.
By default, a plain blank OmniOutliner document contains no defined level styles and will apply the properties of the whole document styles to every level.
As you add children (indented rows), a new level style is automatically added to the document for each level of hierarchical row added to the outline. The new level style will contain no defined settings of its own.
For example, the following script uses the levelStyles property of the Outline class to retrieve an array of references to the current level styles in the document. The length of the array will indicate how many level styles there are:
To derive a reference to a specific level style, use the levelStyle() method of the Outline class with a passed parameter that is an integer representing the level of the specific style to be referenced. Remember, since Omni Automation is JavaScript, the first level will be level 0 to the script (not level 1) although in the application interface it the style will appear a Level 1 Style. To reiterate, although the document interface will call the style “Level 1 Rows,” to a script it is referenced as: levelStyle(0)
levelStyle(depth:Number) (Style) • Returns the level style for the specified nesting level, possibly extending the levelStyles array.
Any missing level syles will be added to the document, up to and including the level you specified in the script.
Automating the Setting of a Level Style Property
When defining the level styles for a document, a script can use a for loop to assign the values of a specific property for each level, like this example that sets the font size for each level:
numLevels = 5
fontSizes = [36, 24, 18, 14, 12]
for (i = 0; i
Here’s an example of using automation to create a new document with defined properties for a hierarchical set of level styles:
Document.makeNewAndShow(function(doc){
// get the rootItem of the new document
baseItem = doc.editors[0].rootNode.object
// clear any whole document style attributes
doc.outline.baseStyle.clear()
// style data for the level styles
styleRecords = [{"name":"Level 1","fontFamily":"Helvetica","fontSize":32,"fontName":"Helvetica Bold","fontWeight":7,"isItalic":false},{"name":"Level 2","fontFamily":"Helvetica","fontSize":24,"fontName":"Helvetica","fontWeight":4,"isItalic":false},{"name":"Level 3","fontFamily":"Helvetica","fontSize":18,"fontName":"Helvetica Light","fontWeight":2,"isItalic":false},{"name":"Level 4","fontFamily":"Times New Roman","fontSize":14,"fontName":"Times New Roman","fontWeight":4,"isItalic":false},{"name":"Level 5","fontFamily":"Times New Roman","fontSize":12,"fontName":"Times New Roman Italic","fontWeight":3,"isItalic":true}]
// define level styles
for (i = 0; i
styleRecords = [{"name":"Level 1","fontFamily":"Helvetica","fontSize":32,"fontName":"Helvetica Bold","fontWeight":7,"isItalic":false},{"name":"Level 2","fontFamily":"Helvetica","fontSize":24,"fontName":"Helvetica","fontWeight":4,"isItalic":false},{"name":"Level 3","fontFamily":"Helvetica","fontSize":18,"fontName":"Helvetica Light","fontWeight":2,"isItalic":false},{"name":"Level 4","fontFamily":"Times New Roman","fontSize":14,"fontName":"Times New Roman","fontWeight":4,"isItalic":false},{"name":"Level 5","fontFamily":"Times New Roman","fontSize":12,"fontName":"Times New Roman Italic","fontWeight":3,"isItalic":true}]