[LON-CAPA-cvs] cvs: loncom /xml londefdef.pm
sakharuk
lon-capa-cvs@mail.lon-capa.org
Thu, 15 Jul 2004 15:13:53 -0000
sakharuk Thu Jul 15 11:13:53 2004 EDT
Modified files:
/loncom/xml londefdef.pm
Log:
Bug 3103 (things that print on s10 don't print on data) is fixed. I changed algorithm (table) to rescale the size of images in the case of unsufficient space. It works for static images only (at this stage). I mean that it could not work for randomlabel problems. But I did not see any example with the whole random label problem in one table cell. Nevertheless I will continue to work with table algorithm to take into account all possible cases.
Index: loncom/xml/londefdef.pm
diff -u loncom/xml/londefdef.pm:1.228 loncom/xml/londefdef.pm:1.229
--- loncom/xml/londefdef.pm:1.228 Wed Jul 14 09:49:09 2004
+++ loncom/xml/londefdef.pm Thu Jul 15 11:13:52 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Tags Default Definition Module
#
-# $Id: londefdef.pm,v 1.228 2004/07/14 13:49:09 sakharuk Exp $
+# $Id: londefdef.pm,v 1.229 2004/07/15 15:13:52 sakharuk Exp $
#
#
# Copyright Michigan State University Board of Trustees
@@ -1153,15 +1153,15 @@
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
my @tempo=@$tagstack;
- my $sygnal=0;
+ my $signal=0;
for (my $i=$#tempo;$i>=0;$i--) {
if (($tempo[$i] eq 'b') || ($tempo[$i] eq 'strong') ||
($tempo[$i] eq 'ol') || ($tempo[$i] eq 'ul')) {
- $sygnal=1;
+ $signal=1;
last;
}
}
- if ($sygnal) {
+ if ($signal) {
$currentstring .= ' \vskip 0 mm ';
} elsif ($$tagstack[-2] ne 'sub' && $$tagstack[-2] ne 'sup') {
$currentstring .= '\strut \\\\ \strut ';
@@ -1846,6 +1846,7 @@
$Apache::londefdef::table[-1]{'output'}.=' \noindent \begin{tabular} ';
$Apache::londefdef::table[-1]{'TeXlen'}=[];
$Apache::londefdef::table[-1]{'objectlen'}=[];
+ $Apache::londefdef::table[-1]{'objectsignal'}=[];
$Apache::londefdef::table[-1]{'maxlen'}=[];
$Apache::londefdef::table[-1]{'minlen'}=[];
$Apache::londefdef::table[-1]{'content'}=[];
@@ -1905,8 +1906,14 @@
$localmin=$Apache::londefdef::table[-1]{'objectlen'}[$in][$jn];
}
}
- if ($max_len[$jn]<$localmin) {$max_len[$jn]=$localmin;}#object size is bigger
- if ($min_len[$jn]<$localmin) {$min_len[$jn]=$localmin;}#object size is bigger
+ if ($max_len[$jn]<$localmin) {
+ $max_len[$jn]=$localmin;
+ $Apache::londefdef::table[-1]{'objectsignal'}[$jn]=1;
+ }#object size is bigger
+ if ($min_len[$jn]<$localmin) {
+ $min_len[$jn]=$localmin;
+ $Apache::londefdef::table[-1]{'objectsignal'}[$jn]=1;
+ }#object size is bigger
if ($Apache::londefdef::table[-1]{'TeXlen'}[0][$jn]!=0) {
$min_len[$jn]=0;
$max_len[$jn]=0;
@@ -1939,6 +1946,36 @@
$fwidth[$jn]=$min_len[$jn];
}
}
+ #check if we have objects which can be scaled
+ my $how_many_to_scale=0;
+ my @to_scale=();
+ for (my $jn=0;$jn<=$#max_len;$jn++) {
+ if ($Apache::londefdef::table[-1]{'objectsignal'}[$jn] eq '1') {
+ $how_many_to_scale++;
+ push @to_scale, $jn;
+ }
+ }
+ if ($how_many_to_scale>0) {
+ my $space_to_adjust=($space_neeeded-$available_space)/$how_many_to_scale;
+ foreach my $jn (@to_scale) {
+ for (my $in=0;$in<=$Apache::londefdef::table[-1]{'row_number'};$in++) {
+ $Apache::londefdef::table[-1]{'content'}[$in][$jn]=~m/width\s*=\s*(\d+\.?\d*\s*(mm|cm|in|pc|pt)*)/;
+ if ($1 ne '') {
+ my $current_length=&recalc($1);
+ $current_length=~/(\d+\.?\d*)/;
+ $current_length=$current_length-$space_to_adjust;
+ $Apache::londefdef::table[-1]{'content'}[$in][$jn]=~s/width\s*=\s*(\d+\.?\d*\s*(mm|cm|in|pc|pt)*)/width=$current_length mm/;
+ }
+ $Apache::londefdef::table[-1]{'content'}[$in][$jn]=~m/\[(\d+\.?\d*)\s*mm\]/;
+ if ($1 ne '') {
+ my $current_length=$1;
+ $current_length=$current_length-$space_to_adjust;
+ $Apache::londefdef::table[-1]{'content'}[$in][$jn]=~s/\[(\d+\.?\d*)\s*mm\]/\[$current_length mm\]/;
+ }
+ }
+ $fwidth[$jn]=$fwidth[$jn]-$space_to_adjust;
+ }
+ }
} else {
#step 3. adjustment over minimal + corrections
my $enlarge_coef=$available_space/$space_neeeded;