home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The CDPD Public Domain Collection for CDTV 4
/
CDPD_IV.bin
/
fish
/
911-930
/
ff925
/
donsgenies
/
frenchgenies.lha
/
Rexx
/
AligneTexteSurGrille.pprx
< prev
next >
Wrap
Text File
|
1993-08-03
|
6KB
|
191 lines
/*
@BAligneTexteSurGrille @B @I Ecrit et © par Don Cox en août 1992
@IN'est pas du Domaine Publique. Tous Droits Réservés.
Traduit par Fabien Larini le 02/08/93.
Ce Génie permet d'espacer les lignes de texte de la valeur de la hauteur
de la grille. Par exemple, si votre grille fait 1.2 picas de haut, chaque
ligne de texte sera espacée de 1.2 picas de la suivante. Ce Génie est
utile pour arranger des colonnes parallèles. Il suffit de clicker dans une
boîte de la chaîne ou dans une boîte ou plusieurs boîtes simples. Si la
hauteur de grille est grande, vous aurez 2 ou 3 lignes de texte dans la
hauteur de Grille.
*/
/* TextToGrid*/
/* This Genie fits text to the Y spacing of the grid. For instance, if your
grid Y setting is 1.2 picas, all the text in an article will be spaced with
lines 14 points apart. This is useful for tidying up parallel columns. You
need only click on one box in each article: all the text in a box or linked
chain will be changed.
If the grid spacing is large, you may get two or three lines of text in each
grid unit. In this version the bounding boxes of the letters are fitted to
the grid; in a later version it may be possible to place the baselines on
the grid.
Written by Don Cox Aug 92 Copyright. Not Public Domain. All rights resrved. */
trace n
signal on error
signal on syntax
address command
call SafeEndEdit.rexx()
call ppm_AutoUpdate(0)
cr="0a"x
cpage = ppm_CurrentPage()
counter=0
do forever
box=ppm_ClickOnBox("Clickez dans les Boîtes contenant le Texte à espacer")
if box=0 then break
counter=counter+1
boxes.counter=box
call ppm_SelectBox(box)
end
if counter=0 then exit_msg("Pas de Boîte Sélectionnée")
currentunits=ppm_GetUnits()
call ppm_SetUnits(2)
randval = (randu() * time(s)) % 1 /* mark boxes with random number to avoid doing them twice */
gridsize = ppm_GetGridSize()
spacing = word(gridsize,2) /* we only want the Y value */
call ppm_ShowStatus("Espacement du Texte ...")
do i=1 to counter
box=boxes.i
boxtype = upper(word(ppm_GetBoxInfo(box), 1))
if boxtype~="TEXTE" then iterate
oldbox = box
box = ppm_ArtFirstBox(box)
boxone = box
do forever /* Tops of boxes to grid */
Ypos = word(ppm_GetBoxPosition(box),2)
Xpos = word(ppm_GetBoxPosition(box),1)
oddbit = Ypos//spacing
if oddbit<= spacing/2 then call ppm_SetBoxPosition(box,Xpos, Ypos-oddbit)
else call ppm_SetBoxPosition(box,Xpos, Ypos+spacing-oddbit)
box = ArtNextBox(box)
if box = 0 then break
end
box = boxone
text = ppm_GetArticleText(box,1)
text = RespaceText(text,spacing)
gone = ppm_DeleteContents(box)
overflow = ppm_TextIntoBox(box,text)
do while box ~= 0 /* mark all the other boxes in this chain */
call ppm_SetBoxUserData(box, randval)
box = ppm_ArtNextBox(box)
end
box = oldbox /* back to the box we are working on */
end
newpage = ppm_GoToPage(cpage)
call ppm_SetUnits(currentunits)
call exit_msg()
end
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
RespaceText: procedure
parse arg text, spacing
position = 1
position2 = 1
do forever /* we have to open up style tags to get sizes */
position = pos("\dS<",text,position2)
if position = 0 then break
position2 = pos(">",text,position)
if position2 = 0 then break
styletag = substr(text,position+4, position2-position-4)
styledef = ppm_GetStyleTagData(styletag)
styledef = left(styledef,pos("}",styledef)-1) /* remove name of tag */
styledef = substr(styledef,pos("{",styledef)+1)
text = delstr(text,position, (position2-position+1)) /* delete tag name */
text = insert("\ds"styledef,text,(position-1))
end
position2 = 1
do forever /* first, for relative spacing we need font sizes */
position = pos("\fs<",text,position2)+4
if position = 4 then break /* would be 0 but we added 4 */
position2 = pos(">",text,position)
if position2 = 0 then break
fontsize = substr(text,position, position2-position)
fontsize = fontsize/28.346457 /* convert to cm */
position = pos("\lr<",text,position2)+4
if position = 4 then break /* would be 0 but we added 4 */
position2 = pos(">",text,position)
if position2 = 0 then break
relspace = substr(text,position, position2-position)
text = delstr(text,position, position2-position) /* delete old size */
newspace = spacing%((relspace/100)*fontsize)
if newspace = 0 then newspace = 1
newspace = spacing/newspace*28.346457 /* back to points */
text = overlay("lf",text,position-3)
text = insert(newspace,text,position-1)
end
position2 = 1
do forever /* now fixed line spacings */
position = pos("\lf<",text,position2)+4
if position = 4 then break /* would be 0 but we added 4 */
position2 = pos(">",text,position)
if position2 = 0 then break
oldsize = substr(text,position, position2-position)
text = delstr(text,position, position2-position) /* delete old size */
oldsize = oldsize/28.346457
newspace = (spacing%oldsize)
if newspace = 0 then newspace = 1
newspace = spacing/newspace*28.346457
text = insert(newspace,text,position-1)
end
position2 = 1
do forever /* and fixed leading */
position = pos("\fs<",text,position2)+4
if position = 4 then break /* would be 0 but we added 4 */
position2 = pos(">",text,position)
if position2 = 0 then break
fontsize = substr(text,position, position2-position)
position = pos("\ll<",text,position2)+4
if position = 4 then break /* would be 0 but we added 4 */
position2 = pos(">",text,position)
if position2 = 0 then break
leading = substr(text,position, position2-position)
text = delstr(text,position, position2-position) /* delete old size */
newspace = (leading+fontsize)/28.346457
newspace = (spacing%newspace)
if newspace = 0 then newspace = 1
newspace = spacing/newspace*28.346457
text = overlay("lf",text,position-3)
text = insert(newspace,text,position-1)
end
return text
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
error:
syntax:
do
exit_msg("Arrêt du Génie dû à l'erreur: "errortext(rc))
end
exit_msg:
do
parse arg message
if message ~= "" then
call ppm_Inform(1,message,)
call ppm_ClearStatus()
call ppm_AutoUpdate(1)
exit
end