A variant of the expand & collapse scripts in an earlier post which offers a list of expansion options for the front document.
Options are listed in both relative and absolute terms.
(The default selection shows the deepest current level of expansion).
Can also be used through LaunchBar. Choose the script with a LaunchBar abbreviation, and tap the space-bar to pass arguments like 1, 2, 3 etc. to increase the level of expansion by one two or three levels, or -1, -2, -3 etc to collapse by some degree.
Options are listed in both relative and absolute terms.
(The default selection shows the deepest current level of expansion).
Can also be used through LaunchBar. Choose the script with a LaunchBar abbreviation, and tap the space-bar to pass arguments like 1, 2, 3 etc. to increase the level of expansion by one two or three levels, or -1, -2, -3 etc to collapse by some degree.
Code:
property pTitle : "Expand / Collapse Outline" property pVer : "Ver .03" -- For use from LaunchBar to increase or decrease expansion level on handle_string(strChange) -- e.g. 1, 2, 3 or -1, -2 -3 etc try set lngDelta to strChange as integer on error return end try AdjustExpansion(lngDelta) end handle_string -- For use through a dialogue on run AdjustExpansion(GetDelta()) end run on GetDelta() tell application id "OOut" set oDoc to front document set lngDeepest to (my DeepestLevel(oDoc, false)) set lngDeepestExpanded to (my DeepestLevel(oDoc, true)) set lstOptions to {} repeat with i from 1 to (lngDeepest) set lngDelta to (i - lngDeepestExpanded) - 1 set strDelta to lngDelta as string if lngDelta > 0 then set strOption to ("+" & strDelta & " (Level " & i as string) & ")" else if lngDelta = 0 then set strOption to ("0 (Level " & i as string) & ")" set strDefault to strOption else set strOption to (strDelta & " (Level " & i as string) & ")" end if set end of lstOptions to strOption end repeat lstOptions set varChoice to choose from list lstOptions with title pTitle & " " & pVer with prompt "Choose level of expansion" default items {strDefault} if varChoice is false then return 0 set my text item delimiters to space (first text item of (first item of varChoice)) as integer end tell end GetDelta on AdjustExpansion(lngDelta) tell application id "OOut" if (count of documents) < 1 then return set oDoc to front document set lngNewMax to (my DeepestLevel(oDoc, true)) + lngDelta tell oDoc set expanded of (rows where level ≤ lngNewMax) to true set expanded of (rows where level > lngNewMax) to false end tell end tell end AdjustExpansion on DeepestLevel(oDoc, blnExpandedOnly) set lngMax to 0 tell application id "OOut" if blnExpandedOnly then set lstLevel to level of rows of oDoc where expanded is true else set lstLevel to level of rows of oDoc end if repeat with oLevel in lstLevel if oLevel > lngMax then set lngMax to oLevel end repeat end tell lngMax as integer end DeepestLevel
Last edited by RobTrew; 2012-02-01 at 02:26 PM..