Diff for /loncom/interface/spreadsheet/Spreadsheet.pm between versions 1.53 and 1.54

version 1.53, 2005/08/24 18:14:47 version 1.54, 2005/08/26 20:46:46
Line 968  sub formulas { Line 968  sub formulas {
         $self->{'formulas'} = $formulas;          $self->{'formulas'} = $formulas;
         $self->{'rows'} = [];          $self->{'rows'} = [];
         $self->{'template_cells'} = [];          $self->{'template_cells'} = [];
    $self->{'loaded'} = 1;
         return;          return;
     } else {      } else {
  if (!$self->{'loaded'}) {   $self->check_formulas_loaded();
     $self->{'loaded'}=1;  
     # Load in the spreadsheet definition  
     if (exists($env{'form.workcopy'}) &&   
  $self->{'type'} eq $env{'form.workcopy'}) {  
  $self->load_tmp();  
     } else {  
  $self->load();  
     }  
  }  
         return %{$self->{'formulas'}};          return %{$self->{'formulas'}};
     }      }
 }  }
   
   sub check_formulas_loaded {
       my $self=shift;
       if (!$self->{'loaded'}) {
    $self->{'loaded'}=1;
    # Load in the spreadsheet definition
    if (exists($env{'form.workcopy'}) && 
       $self->{'type'} eq $env{'form.workcopy'}) {
       $self->load_tmp();
    } else {
       $self->load();
    }
       }
   }
   
 sub set_formula {  sub set_formula {
     my $self = shift;      my $self = shift;
     my ($cell,$formula) = @_;      my ($cell,$formula) = @_;
       $self->check_formulas_loaded();
     $self->{'formulas'}->{$cell}=$formula;      $self->{'formulas'}->{$cell}=$formula;
     return;      return;
 }  }
Line 996  sub set_formula { Line 1003  sub set_formula {
 ##  ##
 sub formulas_keys {  sub formulas_keys {
     my $self = shift;      my $self = shift;
     my @keys = keys(%{$self->{'formulas'}});      $self->check_formulas_loaded();
     return keys(%{$self->{'formulas'}});      return keys(%{$self->{'formulas'}});
 }  }
   
Line 1007  sub formulas_keys { Line 1014  sub formulas_keys {
 sub formula {  sub formula {
     my $self = shift;      my $self = shift;
     my $cell = shift;      my $cell = shift;
       $self->check_formulas_loaded();
     if (defined($cell) && exists($self->{'formulas'}->{$cell})) {      if (defined($cell) && exists($self->{'formulas'}->{$cell})) {
         return $self->{'formulas'}->{$cell};          return $self->{'formulas'}->{$cell};
     }      }
Line 1085  sub rebuild_stats { Line 1093  sub rebuild_stats {
     my $self = shift;      my $self = shift;
     $self->{'rows'}=[];      $self->{'rows'}=[];
     $self->{'template_cells'}=[];      $self->{'template_cells'}=[];
       $self->check_formulas_loaded();
     while (my ($cell,$formula) = each(%{$self->{'formulas'}})) {      while (my ($cell,$formula) = each(%{$self->{'formulas'}})) {
         push(@{$self->{'rows'}},$1) if ($cell =~ /^A(\d+)/ && $1 != 0);          push(@{$self->{'rows'}},$1) if ($cell =~ /^A(\d+)/ && $1 != 0);
         push(@{$self->{'template_cells'}},$1) if ($cell =~ /^template_(\w+)/);          push(@{$self->{'template_cells'}},$1) if ($cell =~ /^template_(\w+)/);
Line 1525  sub outsheet_xml   { Line 1534  sub outsheet_xml   {
     ## Will be rendered for the user      ## Will be rendered for the user
     ## But not on this day      ## But not on this day
     my $Str = '<spreadsheet type="'.$self->{'type'}.'">'."\n";      my $Str = '<spreadsheet type="'.$self->{'type'}.'">'."\n";
       $self->check_formulas_loaded();
     while (my ($cell,$formula) = each(%{$self->{'formulas'}})) {      while (my ($cell,$formula) = each(%{$self->{'formulas'}})) {
         if ($cell =~ /^template_(\w+)/) {          if ($cell =~ /^template_(\w+)/) {
             my $col = $1;              my $col = $1;
Line 1674  sub load { Line 1684  sub load {
   
 sub set_row_sources {  sub set_row_sources {
     my $self = shift;      my $self = shift;
       $self->check_formulas_loaded();
     while (my ($cell,$value) = each(%{$self->{'formulas'}})) {      while (my ($cell,$value) = each(%{$self->{'formulas'}})) {
         next if ($cell !~ /^A(\d+)/ || $1 < 1);          next if ($cell !~ /^A(\d+)/ || $1 < 1);
         my $row = $1;          my $row = $1;
Line 1684  sub set_row_sources { Line 1695  sub set_row_sources {
   
 sub set_row_numbers {  sub set_row_numbers {
     my $self = shift;      my $self = shift;
       $self->check_formulas_loaded();
     while (my ($cell,$value) = each(%{$self->{'formulas'}})) {      while (my ($cell,$value) = each(%{$self->{'formulas'}})) {
  next if ($cell !~ /^A(\d+)$/);   next if ($cell !~ /^A(\d+)$/);
         next if (! defined($value));          next if (! defined($value));

Removed from v.1.53  
changed lines
  Added in v.1.54


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