X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/9c63c1600059dca1ca295e264413e911da3d15bf..703f76b624a9c447bf77e40db2cd3d5f3cc19e51:/SL/Template.pm diff --git a/SL/Template.pm b/SL/Template.pm index 4cbde74e6..40169339c 100644 --- a/SL/Template.pm +++ b/SL/Template.pm @@ -172,6 +172,8 @@ sub parse_foreach { my $sum = 0; my $current_page = 1; my ($current_line, $corrent_row) = (0, 1); + my $description_array = $self->_get_loop_variable("description",1); + my $longdescription_array = $self->_get_loop_variable("longdescription",1); for (my $i = 0; $i < scalar(@{$ary}); $i++) { $form->{"__first__"} = $i == 0; @@ -179,14 +181,12 @@ sub parse_foreach { $form->{"__odd__"} = (($i + 1) % 2) == 1; $form->{"__counter__"} = $i + 1; - if ((scalar(@{$form->{"description"}}) == scalar(@{$ary})) && - $self->{"chars_per_line"}) { - my $lines = - int(length($form->{"description"}->[$i]) / $self->{"chars_per_line"}); + if (scalar @{$description_array} == scalar @{$ary} && $self->{"chars_per_line"} != 0) { + my $lines = int(length($description_array->[$i]) / $self->{"chars_per_line"}); my $lpp; - $form->{"description"}->[$i] =~ s/(\\newline\s?)*$//; - my $_description = $form->{"description"}->[$i]; + $description_array->[$i] =~ s/(\\newline\s?)*$//; + my $_description = $description_array->[$i]; while ($_description =~ /\\newline/) { $lines++; $_description =~ s/\\newline//; @@ -200,7 +200,7 @@ sub parse_foreach { } # Yes we need a manual page break -- or the user has forced one - if ((($current_line + $lines) > $lpp) || ($form->{"description"}->[$i] =~ //) || ($form->{"longdescription"}->[$i] =~ //)) { + if ((($current_line + $lines) > $lpp) || ($description_array->[$i] =~ //) || ($longdescription_array->[$i] =~ //)) { my $pb = $self->{"pagebreak_block"}; # replace the special variables <%sumcarriedforward%> @@ -223,9 +223,9 @@ sub parse_foreach { $sum += $form->parse_amount($self->{"myconfig"}, $form->{"linetotal"}->[$i]); } - + $form->{"cumulatelinetotal"}[$i] = $form->format_amount($self->{"myconfig"}, $sum, 2); - + my $new_text = $self->parse_block($text, (@indices, $i)); return undef unless (defined($new_text)); $new_contents .= $start_tag . $new_text . $end_tag; @@ -350,7 +350,11 @@ sub parse_block { return undef; } - my $value = $self->{"form"}->{$var}; + my $form = $self->{form}; + $form = $form->{TEMPLATE_ARRAYS} if @indices + && ref $form->{TEMPLATE_ARRAYS} eq 'HASH' + && ref $form->{TEMPLATE_ARRAYS}->{$var} eq 'ARRAY'; + my $value = $form->{$var}; for (my $i = 0; $i < scalar(@indices); $i++) { last unless (ref($value) eq "ARRAY"); $value = $value->[$indices[$i]]; @@ -519,8 +523,10 @@ sub convert_to_postscript { $form->{tmpfile} =~ s/\Q$userspath\E\///g; + my $latex = $self->_get_latex_path(); + for (my $run = 1; $run <= 2; $run++) { - system("latex --interaction=nonstopmode $form->{tmpfile} " . + system("${latex} --interaction=nonstopmode $form->{tmpfile} " . "> $form->{tmpfile}.err"); if ($?) { $self->{"error"} = $form->cleanup(); @@ -558,8 +564,10 @@ sub convert_to_pdf { $form->{tmpfile} =~ s/\Q$userspath\E\///g; + my $latex = $self->_get_latex_path(); + for (my $run = 1; $run <= 2; $run++) { - system("pdflatex --interaction=nonstopmode $form->{tmpfile} " . + system("${latex} --interaction=nonstopmode $form->{tmpfile} " . "> $form->{tmpfile}.err"); if ($?) { $self->{"error"} = $form->cleanup(); @@ -573,6 +581,10 @@ sub convert_to_pdf { $self->cleanup(); } +sub _get_latex_path { + return $main::latex_bin || 'pdflatex'; +} + sub get_mime_type() { my ($self) = @_; @@ -1365,7 +1377,7 @@ sub uses_temp_file { #### ########################################################## -package XMLTemplate; +package XMLTemplate; use vars qw(@ISA);