X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/8084ef359515031ec8429b49baf0ab09858f55d2..29185b688ec990bdb801cd8736a12c403095db0c:/SL/Template/LaTeX.pm diff --git a/SL/Template/LaTeX.pm b/SL/Template/LaTeX.pm index c7d51e0e0..02ad31761 100644 --- a/SL/Template/LaTeX.pm +++ b/SL/Template/LaTeX.pm @@ -17,7 +17,6 @@ sub new { sub format_string { my ($self, $variable) = @_; - my $form = $self->{"form"}; $variable = $main::locale->quote_special_chars('Template/LaTeX', $variable); @@ -63,6 +62,7 @@ sub parse_foreach { $form->{"__odd__"} = (($i + 1) % 2) == 1; $form->{"__counter__"} = $i + 1; + #everything from here to the next marker should be removed after the release of 2.7.0 if ( ref $description_array eq 'ARRAY' && scalar @{$description_array} == scalar @{$ary} && $self->{"chars_per_line"} != 0) @@ -103,6 +103,7 @@ sub parse_foreach { } $current_line += $lines; } + #stop removing code here. if ( ref $linetotal_array eq 'ARRAY' && $i < scalar(@{$linetotal_array})) { @@ -255,6 +256,9 @@ sub _parse_config_option { if ($key eq 'tag-style') { $self->set_tag_style(split(m/\s+/, $value, 2)); } + if ($key eq 'use-template-toolkit') { + $self->set_use_template_toolkit($value); + } } sub _parse_config_lines { @@ -348,7 +352,18 @@ sub parse { $self->{"forced_pagebreaks"} = []; - my $new_contents = $self->parse_block($contents); + my $new_contents; + if ($self->{use_template_toolkit}) { + my $additional_params = $::form; + + if ($self->{custom_tag_style}) { + $contents = "[% TAGS $self->{tag_start} $self->{tag_end} %]\n" . $contents; + } + + $::form->init_template->process(\$contents, $additional_params, \$new_contents) || die $::form->template->error; + } else { + $new_contents = $self->parse_block($contents); + } if (!defined($new_contents)) { $main::lxdebug->leave_sub(); return 0; @@ -387,13 +402,16 @@ sub convert_to_postscript { my $latex = $self->_get_latex_path(); my $old_home = $ENV{HOME}; - $ENV{HOME} = $userspath =~ m|^/| ? $userspath : getcwd() . "/" . $userspath; + my $old_openin_any = $ENV{openin_any}; + $ENV{HOME} = $userspath =~ m|^/| ? $userspath : getcwd(); + $ENV{openin_any} = "p"; for (my $run = 1; $run <= 2; $run++) { system("${latex} --interaction=nonstopmode $form->{tmpfile} " . "> $form->{tmpfile}.err"); if ($?) { $ENV{HOME} = $old_home; + $ENV{openin_any} = $old_openin_any; $self->{"error"} = $form->cleanup($latex); return 0; } @@ -403,6 +421,7 @@ sub convert_to_postscript { system("dvips $form->{tmpfile} -o -q > /dev/null"); $ENV{HOME} = $old_home; + $ENV{openin_any} = $old_openin_any; if ($?) { $self->{"error"} = "dvips : $!"; @@ -432,19 +451,23 @@ sub convert_to_pdf { my $latex = $self->_get_latex_path(); my $old_home = $ENV{HOME}; - $ENV{HOME} = $userspath =~ m|^/| ? $userspath : getcwd() . "/" . $userspath; + my $old_openin_any = $ENV{openin_any}; + $ENV{HOME} = $userspath =~ m|^/| ? $userspath : getcwd(); + $ENV{openin_any} = "p"; for (my $run = 1; $run <= 2; $run++) { system("${latex} --interaction=nonstopmode $form->{tmpfile} " . "> $form->{tmpfile}.err"); if ($?) { $ENV{HOME} = $old_home; + $ENV{openin_any} = $old_openin_any; $self->{error} = $form->cleanup($latex); return 0; } } $ENV{HOME} = $old_home; + $ENV{openin_any} = $old_openin_any; $form->{tmpfile} =~ s/tex$/pdf/; $self->cleanup();