| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
@tablefont = []; |
|---|
| 5 |
@tableproc = []; |
|---|
| 6 |
$nb_labels = 0; |
|---|
| 7 |
|
|---|
| 8 |
sub traite_label { |
|---|
| 9 |
my ($label_tex, @tablefont) = @_; |
|---|
| 10 |
local ($process, $tex_file, $dvi_file, $ps_file, $tmp_file, $label_ps, $dim_label, |
|---|
| 11 |
$BBline, $lx, $ly, $ux, $uy, $log_file, $tex, $latex, $i); |
|---|
| 12 |
$process = $$; |
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
if ($label_tex =~ /<tex>/) { |
|---|
| 16 |
$tex = 1; |
|---|
| 17 |
$latex = 0; |
|---|
| 18 |
} |
|---|
| 19 |
if ($label_tex =~ /<latex>/) { |
|---|
| 20 |
$tex = 0; |
|---|
| 21 |
$latex = 1; |
|---|
| 22 |
} |
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
$TMP_DIR = "/tmp/"; |
|---|
| 26 |
$tex_file = $TMP_DIR . "tex" . $process . ".tex"; |
|---|
| 27 |
$aux_file = $TMP_DIR . "tex" . $process . ".aux"; |
|---|
| 28 |
$dvi_file = $TMP_DIR . "tex" . $process . ".dvi"; |
|---|
| 29 |
$ps_file = $TMP_DIR . "tex" . $process . ".ps"; |
|---|
| 30 |
$log_file = $TMP_DIR . "tex" . $process . ".log"; |
|---|
| 31 |
$tmp_file = $TMP_DIR . "bof" . $process . ".ps"; |
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
if ($tex) { |
|---|
| 35 |
$label_tex =~ s/<tex>.*\n//; |
|---|
| 36 |
$label_tex =~ s/<\/tex>.*\n//; |
|---|
| 37 |
$format = $JPS2PS_DIR . "jps.tex"; |
|---|
| 38 |
open (TEX, ">$tex_file") or die "impossible d'ouvrir $tex_file"; |
|---|
| 39 |
print (TEX "\\input $format\n"); |
|---|
| 40 |
print (TEX "\\vtop {\\tvi $label_tex}\n"); |
|---|
| 41 |
print (TEX "\\vfill\n"); |
|---|
| 42 |
print (TEX "\\eject \\bye\n"); |
|---|
| 43 |
close (TEX); |
|---|
| 44 |
`cd $TMP_DIR \; tex $tex_file`; |
|---|
| 45 |
} |
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
if ($latex) { |
|---|
| 49 |
$label_tex =~ s/<latex>.*\n//; |
|---|
| 50 |
$label_tex =~ s/<\/latex>.*\n//; |
|---|
| 51 |
open (TEX, ">$tex_file") or die "impossible d'ouvrir $tex_file"; |
|---|
| 52 |
print (TEX "\\documentclass{article}\n"); |
|---|
| 53 |
print (TEX "\\usepackage[francais]{babel}\n"); |
|---|
| 54 |
print (TEX "\\usepackage[T1]{fontenc}\n"); |
|---|
| 55 |
print (TEX "\\usepackage{amsfonts,amssymb}\n"); |
|---|
| 56 |
print (TEX "\\begin{document}\n"); |
|---|
| 57 |
print (TEX "\\pagestyle{empty}\n"); |
|---|
| 58 |
print (TEX "\\parindent=0cm\n"); |
|---|
| 59 |
print (TEX $label_tex); |
|---|
| 60 |
print (TEX "\\end{document}\n"); |
|---|
| 61 |
close (TEX); |
|---|
| 62 |
`cd $TMP_DIR \; latex $tex_file`; |
|---|
| 63 |
`rm $aux_file`; |
|---|
| 64 |
} |
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 |
`cd $TMP_DIR \; dvips -E -Pcmz -Pamz -j0 $dvi_file -o $ps_file`; |
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
|
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 |
|
|---|
| 93 |
|
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 |
$i = $#tablefont; |
|---|
| 100 |
|
|---|
| 101 |
while ($i > 0) { |
|---|
| 102 |
$font = $tablefont[$i]; |
|---|
| 103 |
|
|---|
| 104 |
`cat $ps_file | $filtre '$font' '%%EndFont' > $tmp_file`; |
|---|
| 105 |
`mv $tmp_file $ps_file`; |
|---|
| 106 |
$i--; |
|---|
| 107 |
} |
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 |
@newtablefont = `cat $ps_file | grep "BeginFont"|sort|uniq`; |
|---|
| 111 |
$i = 0; |
|---|
| 112 |
foreach $font (@newtablefont) { |
|---|
| 113 |
$newtablefont[$i] =~ s/\n//; |
|---|
| 114 |
|
|---|
| 115 |
$i++; |
|---|
| 116 |
} |
|---|
| 117 |
push (@tablefont, @newtablefont); |
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 |
|
|---|
| 123 |
|
|---|
| 124 |
|
|---|
| 125 |
|
|---|
| 126 |
|
|---|
| 127 |
$BBline = `cat $ps_file | grep "%%BoundingBox:"`; |
|---|
| 128 |
$BBline =~ s/%%BoundingBox: //; |
|---|
| 129 |
|
|---|
| 130 |
($lx, $ly, $ux, $uy) = split (/ /, $BBline); |
|---|
| 131 |
|
|---|
| 132 |
$nb_lignes = `cat $ps_file | wc -l`; |
|---|
| 133 |
$nb_lignes =~ s/[ \n]//g; |
|---|
| 134 |
$nb_lignes = $nb_lignes - 11; |
|---|
| 135 |
|
|---|
| 136 |
$resultat = `cat $ps_file | tail -n $nb_lignes`; |
|---|
| 137 |
$resultat =~ s/showpage/{}/s; |
|---|
| 138 |
|
|---|
| 139 |
$oppose_lx = -$lx; |
|---|
| 140 |
$oppose_ly = -$ly; |
|---|
| 141 |
|
|---|
| 142 |
if ($latex) { |
|---|
| 143 |
$lx = $lx - 133; |
|---|
| 144 |
$ux = $ux - 133; |
|---|
| 145 |
$ly = $ly - 656; |
|---|
| 146 |
$uy = $uy - 656; |
|---|
| 147 |
} else { |
|---|
| 148 |
$lx = $lx - 71; |
|---|
| 149 |
$ux = $ux - 71; |
|---|
| 150 |
$ly = $ly - 600; |
|---|
| 151 |
$uy = $uy - 600; |
|---|
| 152 |
} |
|---|
| 153 |
|
|---|
| 154 |
|
|---|
| 155 |
if ($resultat =~ /%%EndFont *\nTeXDict begin /) { |
|---|
| 156 |
|
|---|
| 157 |
$resultat =~ s/(%%EndFont *\n)(TeXDict begin )/$1\/label$nb_labels {\n$2/s; |
|---|
| 158 |
$resultat =~ s/%%EndSetup\n/%%EndSetup\n $oppose_lx $oppose_ly translate\n/s; |
|---|
| 159 |
$resultat =~ s/%%EOF/} def \/label {label$nb_labels} def/s; |
|---|
| 160 |
} else { |
|---|
| 161 |
|
|---|
| 162 |
$resultat =~ s/(TeXDict begin .*\nTeXDict begin *\n)/\/label$nb_labels {\n$1/sg; |
|---|
| 163 |
$resultat =~ s/%%EndSetup\n/%%EndSetup\n $oppose_lx $oppose_ly translate\n/s; |
|---|
| 164 |
$resultat =~ s/%%EOF/} def \/label {label$nb_labels} def/s; |
|---|
| 165 |
} ; |
|---|
| 166 |
|
|---|
| 167 |
$wx = $ux-$lx; |
|---|
| 168 |
$wy = $uy-$ly; |
|---|
| 169 |
|
|---|
| 170 |
$BBline = "/dim_label {$wx $wy} bind def |
|---|
| 171 |
|
|---|
| 172 |
|
|---|
| 173 |
|
|---|
| 174 |
|
|---|
| 175 |
|
|---|
| 176 |
|
|---|
| 177 |
|
|---|
| 178 |
|
|---|
| 179 |
|
|---|
| 180 |
; |
|---|
| 181 |
|
|---|
| 182 |
|
|---|
| 183 |
`rm $tex_file`; |
|---|
| 184 |
`rm $dvi_file`; |
|---|
| 185 |
`rm $ps_file`; |
|---|
| 186 |
`rm $log_file`; |
|---|
| 187 |
|
|---|
| 188 |
$nb_labels++; |
|---|
| 189 |
return ($resultat, $BBline, @tablefont); |
|---|
| 190 |
}; |
|---|
| 191 |
|
|---|
| 192 |
1; |
|---|