Diff for /loncom/xml/lontable.pm between versions 1.19 and 1.22

version 1.19, 2011/04/19 22:30:42 version 1.22, 2014/12/15 00:52:40
Line 1 Line 1
   
 # The LearningOnline Network with CAPA  # The LearningOnline Network with CAPA
 #  Generating TeX tables.  #  Generating TeX tables.
 #  #
Line 8 Line 7
 # Copyright Michigan State University Board of Trustees  # Copyright Michigan State University Board of Trustees
 #  #
 # This file is part of the LearningOnline Network with CAPA (LON-CAPA).  # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
   #
   # LON-CAPA is free software; you can redistribute it and/or modify
   # it under the terms of the GNU General Public License as published by
   # the Free Software Foundation; either version 2 of the License, or
 # (at your option) any later version.  # (at your option) any later version.
 #  #
 # LON-CAPA is distributed in the hope that it will be useful,  # LON-CAPA is distributed in the hope that it will be useful,
Line 54  package Apache::lontable; Line 57  package Apache::lontable;
 use strict;  use strict;
 use Apache::lonlatextable;  use Apache::lonlatextable;
 use Apache::lonnet; # for trace logging.  use Apache::lonnet; # for trace logging.
 use Data::Dumper;  
   
 my $tracing = 0; # Set to 1 to enable log tracing. 2 for local sub tracing.  my $tracing = 0; # Set to 1 to enable log tracing. 2 for local sub tracing.
   
Line 274  sub new { Line 276  sub new {
   
     };      };
   
     foreach my $key (keys %$configuration) {      foreach my $key (keys(%$configuration)) {
  $self->{$key} = $$configuration{$key};   $self->{$key} = $$configuration{$key};
     }      }
   
Line 498  sub start_row { Line 500  sub start_row {
     # Override the defaults if the config hash is present:      # Override the defaults if the config hash is present:
   
     if (defined($config)) {      if (defined($config)) {
  foreach my $key  (keys %$config) {   foreach my $key  (keys(%$config)) {
     $row_hash->{$key} = $config->{$key};      $row_hash->{$key} = $config->{$key};
  }   }
     }      }
Line 581  sub configure_row { Line 583  sub configure_row {
     }      }
           
     my $row = $self->{'rows'}->{$self->{'part'}}->[-1];      my $row = $self->{'rows'}->{$self->{'part'}}->[-1];
     foreach my $config_item (keys %$config) {      foreach my $config_item (keys(%$config)) {
  $row->{$config_item} = $config->{$config_item};   $row->{$config_item} = $config->{$config_item};
     }      }
 }  }
Line 994  sub generate { Line 996  sub generate {
   
  my $specified_width = 0.0;   my $specified_width = 0.0;
  my $specified_cols   = 0;   my $specified_cols   = 0;
  foreach my $col (keys %$colwidths) {   foreach my $col (keys(%$colwidths)) {
     $specified_width = $specified_width + $colwidths->{$col};      $specified_width = $specified_width + $colwidths->{$col};
     $specified_cols++;      $specified_cols++;
  }   }
Line 1024  sub generate { Line 1026  sub generate {
     $default_width = ($tablewidth/$unspecified_cols);                     # 'fair' default width.      $default_width = ($tablewidth/$unspecified_cols);                     # 'fair' default width.
     my $width_remaining = $tablewidth - $default_width*$unspecified_cols; # What's left for the specified cols.      my $width_remaining = $tablewidth - $default_width*$unspecified_cols; # What's left for the specified cols.
     my $reduction       = $tablewidth/$width_remaining;                    # Reduction fraction for specified cols      my $reduction       = $tablewidth/$width_remaining;                    # Reduction fraction for specified cols
     foreach my $col (keys %$colwidths) {      foreach my $col (keys(%$colwidths)) {
  $colwidths->{$col} = $colwidths->{$col}/$reduction;   $colwidths->{$col} = $colwidths->{$col}/$reduction;
     }      }
           
Line 1094  sub generate { Line 1096  sub generate {
   
   
 #---------------------------------------------------------------------------  #---------------------------------------------------------------------------
 #  
 #  Private methods:  
 #  
   
 #   
 # Convert size with units -> size in cm.  
 # The resulting size is floating point with no  units so that it can be used in  
 # computation.  Note that an illegal or missing unit is treated silently as  
 #  cm for now.  
 #  
 sub size_to_cm {  
     my ($this, $size_spec) = @_;  
     my ($size, $units) = split(/ /, $size_spec);  
     if (lc($units) eq 'mm') {  
  return $size / 10.0;  
     }  
     if (lc($units) eq 'in') {  
  return $size * 2.54;  
     }  
       
     return $size; # Default is cm.  
 }   
   
   
   
 #---------------------------------------------------------------------------  
 #  #
 #  Private methods:  #  Private methods:
 #  #

Removed from v.1.19  
changed lines
  Added in v.1.22


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>