Here is a script allowing you to edit a template to set the inset in cells to 0 or 1.
--[SCRIPT changeCellsInsetInTemplate]
(*
Définir le modèle à modifier (theTemplate)
Définir la taille de papier (nomIndex).
Il s'agit de choisir le format A4 ("index-iso.xml") ou le format USletter que nos amis Américains ont nommé ("index-trad.xml").
Exécuter le script.
Il modifie le modèle en ramenant à 0 (ou 1) la marge par défaut dans les cellules des tables.
Par mesure de sécurité, on crée une copie de sécurité du fichier index à modifier.
--=====
Define the template to modify (theTemplate)
Define the paper size (nomIndex)
This means choose between format A4 which uses ("index-iso.xml") or format USletter which uses ("index-trad.xml").
Run the script.
It will modify the template setting the inset margins of default tables to 0 or 1.
For safe it will also create a gzipped backup of the original Index-xxx.xml file.
Yvan KOENIG (Vallauris, FRANCE)
2011/04/27
*)
property bakup : "backup_"
--=====
on run
local theTemplate, nomIndex, chemin, leTexte
(*
Définir le modèle à modifier.
Define the template of your choice.
*)
set theTemplate to "Blank.template:"
(*
Définir la taille de papier.
Define the paper size "index-iso.xml" or "index-trad.xml"
*)
set nomIndex to "index-iso.xml"
-- set nomIndex to "index-trad.xml"
set new_inset to "0"
-- set new_inset to "1"
if theTemplate does not end with ":" then set theTemplate to theTemplate & ":"
set chemin to "" & (path to applications folder) & "iWork '09:Pages.app:Contents:Resources:Templates:" & theTemplate
my prepareIndex(chemin, nomIndex)
set leTexte to lisIndexXml(chemin & nomIndex)
set inset_before to "<sf:padding><sf:padding sf:top=" & quote & "5" & quote & " sf:left=" & quote & "5" & quote & " sf:bottom=" & quote & "5" & quote & " sf:right=" & quote & "5" & quote
set inset_after to "<sf:padding><sf:padding sf:top=" & quote & new_inset & quote & " sf:left=" & quote & new_inset & quote & " sf:bottom=" & quote & new_inset & quote & " sf:right=" & quote & new_inset & quote
set leTexte to my remplace(leTexte, inset_before, inset_after)
my enregistre(leTexte, (chemin & nomIndex) as alias)
tell application "Finder" to open (chemin as alias)
end run
--=====
on prepareIndex(chemin_, nomindex_)
local cheminIndex, flagGz, flag
set cheminIndex to chemin_ & nomindex_
tell application "Finder"
set flagGz to exists file (cheminIndex & ".gz")
set flag to existsfile (cheminIndex)
if flagGz then (*
the file (cheminIndex & ".gz") exists *)
if flag then delete file (cheminIndex)
if not (exists file (chemin_ & bakup & nomindex_ & ".gz")) then my archive(chemin_, nomindex_ & ".gz")
my decompacte(quoted form of POSIX path of (cheminIndex & ".gz"))
else if flag then (*
the file (cheminIndex & ".gz") doesn't exist
but the file cheminIndex exists *)
if (exists file (chemin_ & bakup & nomindex_ & ".gz")) then
try
deletefile (chemin_ & bakup & nomindex_)
end try
else
if not (existsfile (chemin_ & bakup & nomindex_)) then my archive(chemin_, nomindex_)
my compacte(quoted form of POSIX path of (chemin_ & bakup & nomindex_))
end if
else (*
the file (cheminIndex & ".gz") doesn't exist
and the file cheminIndex doesn't exist *)
if my parle_anglais() then
error "The file “" & nomindex_ & "” is unavailable !"
else
error "Le fichier «" & nomindex_ & "» n'existe pas !"
end if
end if -- flagGz
end tell -- Finder
end prepareIndex
--=====
on decompacte(posixPath)
do shell script "gunzip " & posixPath
end decompacte
--=====
on compacte(posixPath)
do shell script "gzip " & posixPath
end compacte
--=====
on lisIndexXml(f)
local t
try
set t to ""
set t to (read file f)
end try
if t is "" then
if my parle_anglais() then
error "Unable to read : “" & f & "” !"
else
error "Le fichier «" & f & "» est illisible !"
end if
end if
return t
end lisIndexXml
--=====
on enregistre(t, nDoc) (* nDoc is an alias *)
writettonDocstarting at 0
do shell script "gzip " & quoted form of POSIX path of nDoc
end enregistre
--=====
on remplace(t, TID1, TID2)
local l, oTID
set oTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to TID1
set l to (text items of t)
set AppleScript's text item delimiters to TID2
set t to l as text
set AppleScript's text item delimiters to oTID
return t
end remplace
--=====
on archive(d, n)
local nt, nf, df, df_nt, dup
tell application "Finder"
set nt to "temporary_yraropmet"
set nf to name of (d as alias)
set df to (container of (d as alias)) as text
set name of (d as alias) to nt
set df_nt to df & nt
repeat until exists folder df_nt
delay 0.1
end repeat
try
set dup to duplicate file (df_nt & ":" & n) to folder df_nt without replacing
end try
try
set name of dup to bakup & n
end try
try
set name of folder df_nt to nf
end try
end tell -- Finder
end archive
--=====
on parle_anglais()
return (do shell script "defaults read 'Apple Global Domain' AppleLocale") does not start with "fr_"
end parle_anglais
--=====
--[/SCRIPT]
Yvan KOENIG (VALLAURIS, France) mercredi 27 avril 2011 22:02:25