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

raeburn raeburn at source.lon-capa.org
Thu Sep 15 15:10:45 EDT 2011


raeburn		Thu Sep 15 19:10:45 2011 EDT

  Modified files:              (Branch: version_2_10_X)
    /loncom/xml	londefdef.pm 
  Log:
  - Backport 1.428, 1.429, 1.432, 1.433.
  
  
Index: loncom/xml/londefdef.pm
diff -u loncom/xml/londefdef.pm:1.415.4.3 loncom/xml/londefdef.pm:1.415.4.4
--- loncom/xml/londefdef.pm:1.415.4.3	Sat Dec 25 00:10:16 2010
+++ loncom/xml/londefdef.pm	Thu Sep 15 19:10:45 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.415.4.3 2010/12/25 00:10:16 raeburn Exp $
+# $Id: londefdef.pm,v 1.415.4.4 2011/09/15 19:10:45 raeburn Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -2045,9 +2045,6 @@
     } elsif ($target eq 'tex') {
 	&disable_para();	# Can't have paras in a table.
 
-
-	#  New table code:
-
 	#  Get the parameters that we can do something about:
 
 	my $border = &Apache::lonxml::get_param('border', $parstack, $safeeval, undef, 0);
@@ -2064,16 +2061,24 @@
         if ((defined $border) && ($border > 0)) {
         #    &Apache::lonnet::logthis("Turning on table borders: $border");
             $table->table_border(1);
-            if ($cell_border ne 'none') {
-                $table->cell_border(1); # html specs that border turns on both...unless rules='none'.
+            if (!defined $cell_border) {
+                $table->cell_border(1); # Default for rules is all if rules not defined.
             }
         }
-        # Only all or nothing for cell borders for now:
 
-        if ((defined $cell_border) && ($cell_border ne 'none')) {
-        #    &Apache::lonnet::logthis("Turning on cell borders: $cell_border");
-	    $table->cell_border(1);
-	}
+        if ((defined $cell_border)) {
+            if ($cell_border eq 'all') {
+                $table->cell_border(1);
+            } elsif ($cell_border eq 'rows') {
+                $table->cell_border(2);
+            } elsif ($cell_border eq 'cols') {
+                $table->cell_border(3);
+            } elsif($cell_border eq 'groups') {
+                $table->cell_border(4);
+            } else {
+                $table->cell_border(0);
+            }
+        }
         if (defined $theme) {
 	    $table->theme($theme);
 	}
@@ -2101,88 +2106,6 @@
 	push(@Apache::londefdef::table, $table);
         $currentstring.=' \keephidden{NEW TABLE ENTRY}';
 
-	#--------------------------------------------------------
-	#  Old table code here.
-	#--------------------------------------------------------
-
-
-	if (0) {
-	push(@Apache::londefdef::table, {}); 
-	$Apache::londefdef::table[-1]{'row_number'} = -1;
-        #maximum table's width (default coincides with text line length)
-	if ($#Apache::londefdef::table==0) {
-	    $textwidth=&recalc($env{'form.textwidth'}); #result is always in mm
-	    $textwidth=~/(\d+\.?\d*)/;
-	    $textwidth=0.85*$1; #accounts "internal" LaTeX space for table frame
-	} else {
-	    if ($Apache::londefdef::table[-2]{'TeXlen'}[$Apache::londefdef::table[-2]{'row_number'}][$Apache::londefdef::table[-2]{'counter_columns'}]=~/\d/) {
-		#the maximum width of nested table is determined by LATeX width of parent cell
-		$textwidth=$Apache::londefdef::table[-2]{'TeXlen'}[$Apache::londefdef::table[-2]{'row_number'}][$Apache::londefdef::table[-2]{'counter_columns'}]; 
-	    } else {
-              #try to use all space not used before (minus 5% for LaTeX table internal) - rather silly
-		$textwidth=$Apache::londefdef::table[-2]{'width'};
-		for (my $i=0;$i<$Apache::londefdef::table[-2]{'counter_columns'};$i++) {
-		    $textwidth=$textwidth-$Apache::londefdef::table[-2]{'TeXlen'}[0][$i];
-		}
-	    }
-	}
-
-	# width either comes forced from the TeXwidth or the width parameters.
-	# in either case it can be a percentage or absolute width.
-	# in the width case we ignore absolute width 
-	my $TeXwidth = &Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval,undef,0);
-	if (!defined($TeXwidth)) {
-	    my $htmlwidth = &Apache::lonxml::get_param('width',$parstack,
-						       $safeeval,undef,1);
-	    if ($htmlwidth =~ /%/) {
-		$TeXwidth = $htmlwidth;
-	    } else { 
-		$TeXwidth = $textwidth;
-	    }
-	}
-	# if the width is specified as a % it is converted to an absolute width.
-	# otherwise.. just plugged right in the hash
-
-	if ($TeXwidth=~/%/) {
-	    $TeXwidth=~/(\d+)/;
-            $Apache::londefdef::table[-1]{'width'}=$1*$textwidth/100;
-	} else {
-	    $Apache::londefdef::table[-1]{'width'}=$TeXwidth;
-	}
-        #  In the end, however the table width cannot be wider than $textwidth...
-	
-	if ($Apache::londefdef::table[-1]{'width'} > $textwidth) {
-	    $Apache::londefdef::table[-1]{'width'} = $textwidth;
-	}
-        #table's border
-	my $border = &Apache::lonxml::get_param('border',$parstack,$safeeval); 
-        my $permission=&Apache::lonxml::get_param('TeXDropEmptyColumns',$parstack,$safeeval,undef,0);
-	unless (defined $border) { $border = 0; }
-	if ($border) { 
-	    $Apache::londefdef::table[-1]{'hinc'} = '\hline '; 
-	    $Apache::londefdef::table[-1]{'vinc'} = '&'; 
-	    $Apache::londefdef::table[-1]{'vvinc'} = '|';
-	} else {
-	    $Apache::londefdef::table[-1]{'hinc'} = ''; 
-	    $Apache::londefdef::table[-1]{'vinc'} = '&'; 
-	    $Apache::londefdef::table[-1]{'vvinc'} = '';
-	}
-	if ($#Apache::londefdef::table==0) {
-	    #    Note that \newline seems to destroy the alignment envs.
-	    # $Apache::londefdef::table[-1]{'output'}='\strut\newline\strut\setlength{\tabcolsep}{1 mm}';
-	    $Apache::londefdef::table[-1]{'output'}='\strut'.'\\\\'."\n".'\strut\setlength{\tabcolsep}{1 mm}';
-	}
-	$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'}=[];
-        $Apache::londefdef::table[-1]{'align'}=[];
-        $currentstring.=' \keephidden{NEW TABLE ENTRY}';
-    }
-
     }
     return $currentstring;
 }
@@ -2195,8 +2118,6 @@
     } elsif ($target eq 'tex') {
 
 
-	#  New table code:
-
 	my $table = pop(@Apache::londefdef::table);
 	my $t     = $table->generate();
 	$currentstring = $t->generate_string();




More information about the LON-CAPA-cvs mailing list