[LON-CAPA-cvs] cvs: loncom /xml londefdef.pm

sakharuk lon-capa-cvs@mail.lon-capa.org
Thu, 11 Jul 2002 19:32:06 -0000


sakharuk		Thu Jul 11 15:32:06 2002 EDT

  Modified files:              
    /loncom/xml	londefdef.pm 
  Log:
  Now aomatically adjust the width of parbox in any table cell. 
  
  
Index: loncom/xml/londefdef.pm
diff -u loncom/xml/londefdef.pm:1.70 loncom/xml/londefdef.pm:1.71
--- loncom/xml/londefdef.pm:1.70	Thu Jul 11 14:20:00 2002
+++ loncom/xml/londefdef.pm	Thu Jul 11 15:32:06 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.70 2002/07/11 18:20:00 sakharuk Exp $
+# $Id: londefdef.pm,v 1.71 2002/07/11 19:32:06 sakharuk Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -1311,6 +1311,16 @@
 		    chop $output;
 		    $output .= ' \\\\ ';
 		}
+                my @length = split(/,/,$Apache::londefdef::table[-1]{'length'});
+                my $how_many_columns = $#length+1;
+                my $parboxlength = '(\textwidth';
+                for (my $io=0; $io<=$#length;$io++) {
+		    if ($length[$io] ne '') {
+			$parboxlength .= ' - '.$length[$io].' ';
+		    }
+		}
+		$parboxlength .= ')/'.$how_many_columns.' - 7 mm';
+		$output =~ s/\\parbox{}/\\parbox{$parboxlength}/g;
 		$Apache::londefdef::table[-1]{'output'} .= $header_of_table.$output.$Apache::londefdef::table[-1]{'hinc'}.'\end{tabular}\vskip 0 mm ';
 		if ($#Apache::londefdef::table > 0) {
 		    $inmemory = $Apache::londefdef::table[-1]{'output'};
@@ -1340,6 +1350,7 @@
 		}
 		push ( @{ $Apache::londefdef::table[-1]{'rowdata'} }, $Apache::londefdef::table[-1]{'hinc'});
 		$Apache::londefdef::table[-1]{'counter_columns'} = -1;
+		$Apache::londefdef::table[-1]{'length'} = ''; #just added
 
 	    } 
 	   return $currentstring;
@@ -1380,7 +1391,10 @@
 	    } elsif ($target eq 'tex') {
 		my $current_row = $Apache::londefdef::table[-1]{'row_number'};
 		my $data=&Apache::lonxml::endredirection();
-		@{ $Apache::londefdef::table[-1]{'rowdata'} }[$current_row] .= $data.' '.$Apache::londefdef::table[-1]{'vinc'};
+		if ($data=~m/width\s*=\s*(\d+\.*\d*\s*(mm|cm))/) {                 #just added
+                    $Apache::londefdef::table[-1]{'length'} .= $1.',';             #just added
+		}                                                                  #just added
+		@{ $Apache::londefdef::table[-1]{'rowdata'} }[$current_row] .= '\parbox{'.$1.'}{'.$data.'} '.$Apache::londefdef::table[-1]{'vinc'};
 	    }
 	   return $currentstring;
 	}