From: Moritz Bunkus Date: Thu, 31 Jan 2008 15:19:36 +0000 (+0000) Subject: Forcieren, dass bei LaTeX-Vorlagen das Paket "textcomp" eingebunden wird, das für... X-Git-Tag: release-2.6.0beta1~260 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=e7361d77e6e37bf1f5a3137e237ab03d6dbb316f;p=kivitendo-erp.git Forcieren, dass bei LaTeX-Vorlagen das Paket "textcomp" eingebunden wird, das für das Euro-Zeichen benötigt wird. --- diff --git a/SL/Template.pm b/SL/Template.pm index e6d7e1060..a268ae6c9 100644 --- a/SL/Template.pm +++ b/SL/Template.pm @@ -415,6 +415,31 @@ sub _parse_config_lines { } } +sub _force_mandatory_packages { + my $self = shift; + my $lines = shift; + + my (%used_packages, $document_start_line); + + foreach my $i (0 .. scalar @{ $lines } - 1) { + if ($lines->[$i] =~ m/\\usepackage[^{]*{(.*?)}/) { + $used_packages{$1} = 1; + + } elsif ($lines->[$i] =~ m/\\begin{document}/) { + $document_start_line = $i; + last; + + } + } + + $document_start_line = scalar @{ $lines } - 1 if (!defined $document_start_line); + + if (!$used_packages{textcomp}) { + splice @{ $lines }, $document_start_line, 0, "\\usepackage{textcomp}\n"; + $document_start_line++; + } +} + sub parse { my $self = $_[0]; local *OUT = $_[1]; @@ -428,6 +453,7 @@ sub parse { close(IN); $self->_parse_config_lines(\@lines); + $self->_force_mandatory_packages(\@lines); my $contents = join("", @lines);