2002-02-27 06:47:14 -07:00
|
|
|
#!/usr/bin/perl -w
|
|
|
|
|
|
|
|
#
|
|
|
|
# Script to rewrite colspecs from relative values to absolute values
|
|
|
|
#
|
|
|
|
|
2002-03-14 15:35:00 +10:00
|
|
|
# arjen 2002-03-14 append "cm" specifier to colwidth field.
|
|
|
|
|
2002-02-27 06:47:14 -07:00
|
|
|
use strict;
|
|
|
|
|
|
|
|
my $table_width = 12.75; # cm
|
|
|
|
my $gutter_width = 0.09; # cm
|
|
|
|
|
|
|
|
my $str = join '', <>;
|
|
|
|
|
|
|
|
$str =~ s{([\t ]*(<colspec colwidth=\".+?\" />\s*)+)}
|
|
|
|
{&rel2abs($1)}ges;
|
|
|
|
|
|
|
|
print STDOUT $str;
|
|
|
|
exit;
|
|
|
|
|
|
|
|
#
|
|
|
|
# Definitions for helper sub-routines
|
|
|
|
#
|
|
|
|
|
|
|
|
sub msg {
|
|
|
|
print STDERR shift, "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
sub rel2abs {
|
|
|
|
my $str = shift;
|
|
|
|
|
|
|
|
my @widths = ();
|
|
|
|
my $total = 0;
|
|
|
|
my $output = '';
|
|
|
|
|
|
|
|
$str =~ /^(\s+)/;
|
|
|
|
my $ws = $1;
|
|
|
|
|
|
|
|
while ($str =~ m/<colspec colwidth="(\d+)\*" \/>/g) {
|
|
|
|
$total += $1;
|
|
|
|
push @widths, $1;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $unit = ($table_width - ($#widths * $gutter_width)) / ($total);
|
|
|
|
|
|
|
|
foreach (@widths) {
|
2002-03-14 15:35:00 +10:00
|
|
|
$output .= $ws . '<colspec colwidth="'. sprintf ("%0.2f", $_ * $unit) .'cm" />' . "\n";
|
2002-02-27 06:47:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return $output . "\n$ws";
|
|
|
|
}
|