Guest
2012-11-16, 01:02 AM
Quote:
Originally Posted by hmarstra
Would it be difficult to make a version of the second script that would just be a fixed bookmark for a given place in a OO document ?
|
If you select a row in an OO3 document, and run the code below, it should generate and place in the clipboard a custom bookmark script for jumping back to that particular document and row.
You can then paste the generated code into Applescript Editor.
Code:
property pTitle : "Make OO Bookmark Code"
property pVer : "00.2"
tell application id "OOut"
set lstDocs to documents
if length of lstDocs < 1 then return
tell item 1 of lstDocs
set lstRows to selected rows
if length of lstRows < 1 then return
set strPath to path
tell first item of lstRows to set {strID, strTopic} to {id, topic}
end tell
end tell
set the clipboard to "
property pTitle : \"OO3 Bookmark\"
property pVer : \"00.2\"
property pstrTopic : \"" & strTopic & "\"
property pstrDocPath : \"" & strPath & "\"
property pstrID : \"" & strID & "\"
GotoBookMark(pstrDocPath, pstrID, pstrTopic)
on GotoBookMark(strPath, strID, strTopic)
if FileExists(strPath) then
tell application id \"OOut\"
set oDoc to (open (POSIX file strPath as alias))
my SelectRow(oDoc, strID, strTopic)
end tell
else
display dialog \"File not found at this location\" & return & return & strPath buttons {\"OK\"} ¬
default button \"OK\" with title pTitle & \" ver. \" & pVer
return missing value
end if
end GotoBookMark
on SelectRow(oDoc, strID, strTopic)
tell application id \"OOut\"
tell oDoc
try
set oTgt to row id strID
on error
activate
display dialog \"Row id \" & strID & return & return & \"'\" & strTopic & \"'\" & return & return & \"not found in \" & name of oDoc ¬
buttons {\"OK\"} default button \"OK\" with title pTitle & \" ver. \" & pVer
return false
end try
tell oTgt
if level > 1 then
tell last item of ancestors
set expanded to true
set expanded of rows to true
end tell
end if
select
hoist
activate
tell application id \"sevs\" to click my GetMenuItem(\"OOut\", {\"View\", \"Unhoist\"})
select
end tell
return true
end tell
end tell
end SelectRow
on FileExists(strPath)
(do shell script (\"test -e \" & quoted form of strPath & \"; echo $?\")) = \"0\"
end FileExists
-- RETURNS A REFERENCE TO A CLICKABLE MENU ITEM
-- E.G. set mnuZoomFit to GetMenuItem(\"OGfl\", {\"View\", \"Zoom\", \"Zoom to Selection\"})
on GetMenuItem(strAppCode, lstMenu)
set lngChain to length of lstMenu
if lngChain < 2 then return missing value
tell application id \"sevs\"
set lstApps to application processes where its creator type = strAppCode
if length of lstApps < 1 then return missing value
tell first item of lstApps
-- GET THE TOP LEVEL MENU
set strMenu to item 1 of lstMenu
set oMenu to menu strMenu of menu bar item strMenu of menu bar 1
-- TRAVEL DOWN THROUGH ANY SUB-MENUS
repeat with i from 2 to (lngChain - 1)
set strMenu to item i of lstMenu
set oMenu to menu strMenu of menu item strMenu of oMenu
end repeat
-- AND RETURN THE FINAL MENU ITEM
return menu item (item -1 of lstMenu) of oMenu
end tell
end tell
end GetMenuItem
on GUIEnabled()
tell application id \"sevs\"
if UI elements enabled then
return true
else
activate
display dialog \"This script depends on enabling access for assistive devices in system preferences\" buttons \"OK\" default button \"OK\" with title pTitle & \" \" & pVer
tell application id \"sprf\"
activate
set current pane to pane id \"com.apple.preference.universalaccess\"
end tell
return false
end if
end tell
end GUIEnabled
"
display dialog "Bookmark script for \"" & strTopic & "\" now in clipboard." & return & return & ¬
"Paste into Applescript Editor." buttons {"OK"} default button "OK" with title pTitle & " ver. " & pVer
Last edited by RobTrew; 2012-11-16 at 07:33 AM..
Reason: Some edits to code → ver 0.002