--- loncom/interface/spreadsheet/Spreadsheet.pm 2003/12/05 22:24:20 1.21.2.1 +++ loncom/interface/spreadsheet/Spreadsheet.pm 2003/09/05 01:57:54 1.23 @@ -1,5 +1,5 @@ # -# $Id: Spreadsheet.pm,v 1.21.2.1 2003/12/05 22:24:20 matthew Exp $ +# $Id: Spreadsheet.pm,v 1.23 2003/09/05 01:57:54 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -48,6 +48,8 @@ Spreadsheet package Apache::Spreadsheet; use strict; +use warnings FATAL=>'all'; +no warnings 'uninitialized'; use Apache::Constants qw(:common :http); use Apache::lonnet; use Safe; @@ -90,7 +92,7 @@ sub new { type => $stype, symb => $usymb, errorlog => '', - maxrow => '', + maxrow => 0, cid => $ENV{'request.course.id'}, cnum => $ENV{'course.'.$ENV{'request.course.id'}.'.num'}, cdom => $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, @@ -229,6 +231,16 @@ sub initialize { # the descendents of the spreadsheet class. } +sub clear_package { + # This method is here to remind you that it will be overridden by + # the descendents of the spreadsheet class. +} + +sub cleanup { + my $self = shift(); + $self->clear_package(); +} + sub initialize_spreadsheet_package { &load_spreadsheet_expirationdates(); &clear_spreadsheet_definition_cache(); @@ -248,6 +260,7 @@ sub load_spreadsheet_expirationdates { sub check_expiration_time { my $self = shift; my ($time)=@_; + return 0 if (! defined($time)); my ($key1,$key2,$key3,$key4,$key5); # Description of keys # @@ -659,7 +672,7 @@ sub calc { return $lastcalc.': Maximum calculation depth exceeded'; } } - return 'okay'; + return ''; } # ------------------------------------------- End of "Inside of the safe space" @@ -1121,51 +1134,9 @@ sub calcsheet { # $self->logthis($self->get_errorlog()); %{$self->{'values'}} = %{$self->{'safe'}->varglob('sheet_values')}; # $self->logthis($self->get_errorlog()); - if ($result ne 'okay') { - $self->set_calcerror($result); - } return $result; } - -sub set_badcalc { - my $self = shift(); - $self->{'badcalc'} =1; - return; -} - -sub badcalc { - my $self = shift; - if (exists($self->{'badcalc'}) && $self->{'badcalc'}) { - return 1; - } else { - return 0; - } -} - -sub set_calcerror { - my $self = shift; - if (@_) { - $self->set_badcalc(); - if (exists($self->{'calcerror'})) { - $self->{'calcerror'}.="\n".$_[0]; - } else { - $self->{'calcerror'}.=$_[0]; - } - } -} - -sub calcerror { - my $self = shift; - if ($self->badcalc()) { - if (exists($self->{'calcerror'})) { - return $self->{'calcerror'}; - } - } - return; -} - - ########################################################### ## ## Output Helpers @@ -1186,24 +1157,13 @@ sub display { } elsif ($outputmode eq 'csv') { $self->outsheet_csv($r); } + $self->cleanup(); return; } ############################################ ## HTML output routines ## ############################################ -sub html_report_error { - my $self = shift(); - my $Str = ''; - if ($self->badcalc()) { - $Str = '
'.$self->calcerror()."\n"; - } - return $Str; -} - sub html_export_row { my $self = shift(); my ($color) = @_; @@ -1391,6 +1351,7 @@ sub create_excel_spreadsheet { sub outsheet_excel { my $self = shift; my ($r) = @_; + my $connection = $r->connection(); $r->print("