--=====
property permittedK4 : {"com.apple.iWork.keynote.sffkey", "com.apple.iWork.keynote.sffkth"}
property permittedK5 : {"com.apple.iwork.keynote.key", "com.apple.iwork.keynote.kth"}
property permittedKey : permittedK5 & permittedK4
(* Keynote documents are treated differently *)
property permitted4 : {"com.apple.iWork.pages.sffpages", "com.apple.iWork.pages.sfftemplate", "com.apple.iwork.numbers.sffnumbers", "com.apple.iWork.numbers.sfftemplate"} & permittedK4
property permitted5 : {"com.apple.iwork.pages.pages", "com.apple.iwork.pages.template", "com.apple.iwork.numbers.numbers", "com.apple.iwork.numbers.template"} & permittedK5
property permitted : permitted5 & permitted4
--=====
on run (*
lignes exécutées si on double clique sur l'icône du script application
• lines executed if one double click the application script's icon *)
tell application "System Events"
if my parleAnglais() then
set myPrompt to "Choose an iWork’s document"
else
set myPrompt to "Choisir un document iWork"
end if -- parleAnglais
if 5 = (system attribute "sys2") then (*
it's Mac OS X 10.5.x with a bug with Choose File *)
set allowed to {}
else (*
if Mac Os X 10.4.x or 10.6.x *)
set allowed to my permitted
end if -- 5 = (system…
my commun(choose file with prompt myPrompt of type allowed) (* un alias *)
end tell
end run
--=====
on open (sel) (*
sel contient une liste d'alias des élémentsqu'on a déposés sur l'icône du script (la sélection)
• sel contains a list of aliases of the items dropped on the script's icon (the selection) *)
my commun(item 1 of sel) (* an alias *)
end open
--=====
on commun(thePack) (*
• thePack is an alias *)
local pFold, pName, path2Index, texteXML
my nettoie()
tell application "System Events" to tell disk item (thePack as text)
set typeID to (type identifier) as text
set pFold to package folder
set pName to name
end tell
if typeID is not in my permitted then
if my parleAnglais() then
error "“" & (thePack as text) & "” is not an iWork’s document!"
else
error "«" & (thePack as text) & "» n’est pas un document iWork !"
end if -- my parleAnglais()
end if -- typeID
if pFold then
set wasFlat to false
else
set wasFlat to true
my expandFlat(thePack) (* an alias *)
end if
if typeID is in my permittedKey then (*
special case Keynote *)
set path2Index to "" & thePack & "Index.apxl"
else (*
Pages or Numbers *)
set path2Index to "" & thePack & "Index.xml"
end if -- typeID starts …
end commun
--=====
on parleAnglais()
local z
try
tell application "Pages" to set z to localized string "Cancel"
on error
set z to "Cancel"
end try
return (z is not "Annuler")
end parleAnglais
--=====
Yvan KOENIG (VALLAURIS, France) jeudi 4 novembre 2010 15:09:37