X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FTemplate%2FOpenDocument.pm;h=a90a9aeea89ff164f263ea038c693a9e360f0664;hb=ef840a08311cefcb169c1887f41082ae04760998;hp=b4ea1f2a5d24d2f4a64da6c224766354a8c9f562;hpb=5829f39dc57db589b830a4adc4053538ddec0ee5;p=kivitendo-erp.git diff --git a/SL/Template/OpenDocument.pm b/SL/Template/OpenDocument.pm index b4ea1f2a5..a90a9aeea 100644 --- a/SL/Template/OpenDocument.pm +++ b/SL/Template/OpenDocument.pm @@ -22,7 +22,6 @@ sub new { my $self = $type->SUPER::new(@_); $self->{"rnd"} = int(rand(1000000)); - $self->{"iconv"} = SL::Iconv->new($::lx_office_conf{system}->{dbcharset}, "UTF-8"); $self->set_tag_style('<%', '%>'); $self->{quot_re} = '"'; @@ -260,7 +259,14 @@ sub parse { $contents =~ s||${new_styles}|; $contents =~ s|[\n\r]||gm; - my $new_contents = $self->parse_block($contents); + my $new_contents; + if ($self->{use_template_toolkit}) { + my $additional_params = $::form; + + $::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; @@ -416,11 +422,21 @@ sub spawn_xvfb { return $display; } +sub _run_python_uno { + my ($self, @args) = @_; + + local $ENV{PYTHONPATH}; + $ENV{PYTHONPATH} = $::lx_office_conf{environment}->{python_uno_path} . ':' . $ENV{PYTHONPATH} if $::lx_office_conf{environment}->{python_uno_path}; + my $cmd = $::lx_office_conf{applications}->{python_uno} . ' ' . join(' ', @args); + return `$cmd`; +} + sub is_openoffice_running { + my ($self) = @_; + $main::lxdebug->enter_sub(); - my $cmd = "./scripts/oo-uno-test-conn.py " . $::lx_office_conf{print_templates}->{openofficeorg_daemon_port} . " 2> /dev/null"; - my $output = `$cmd`; + my $output = $self->_run_python_uno('./scripts/oo-uno-test-conn.py', $::lx_office_conf{print_templates}->{openofficeorg_daemon_port}, ' 2> /dev/null'); chomp $output; my $res = ($? == 0) || $output; @@ -447,10 +463,19 @@ sub spawn_openoffice { last; } + if ($::dispatcher->interface_type eq 'FastCGI') { + $::dispatcher->{request}->Detach; + } + if (!$spawned_oo) { my $pid = fork(); if (0 == $pid) { $main::lxdebug->message(LXDebug->DEBUG2(), " Child daemonizing\n"); + + if ($::dispatcher->interface_type eq 'FastCGI') { + $::dispatcher->{request}->Finish; + $::dispatcher->{request}->LastCall; + } chdir('/'); open(STDIN, '/dev/null'); open(STDOUT, '>/dev/null'); @@ -464,6 +489,11 @@ sub spawn_openoffice { "-accept=socket,host=localhost,port=" . $::lx_office_conf{print_templates}->{openofficeorg_daemon_port} . ";urp;"); exec(@cmdline); + } else { + # parent + if ($::dispatcher->interface_type eq 'FastCGI') { + $::dispatcher->{request}->Attach; + } } $main::lxdebug->message(LXDebug->DEBUG2(), " Parent after fork\n"); @@ -508,27 +538,20 @@ sub convert_to_pdf { return 0; } - my @cmdline; if (!$::lx_office_conf{print_templates}->{openofficeorg_daemon}) { - @cmdline = ($::lx_office_conf{applications}->{openofficeorg_writer}, - "-minimized", "-norestore", "-nologo", "-nolockcheck", - "-headless", - "file:${filename}.odt", - "macro://" . (split('/', $filename))[-1] . - "/Standard.Conversion.ConvertSelfToPDF()"); + system($::lx_office_conf{applications}->{openofficeorg_writer}, + "-minimized", "-norestore", "-nologo", "-nolockcheck", "-headless", + "file:${filename}.odt", + "macro://" . (split('/', $filename))[-1] . "/Standard.Conversion.ConvertSelfToPDF()"); } else { if (!$self->spawn_openoffice()) { $main::lxdebug->leave_sub(); return 0; } - @cmdline = ("./scripts/oo-uno-convert-pdf.py", - $::lx_office_conf{print_templates}->{openofficeorg_daemon_port}, - "${filename}.odt"); + $self->_run_python_uno('./scripts/oo-uno-convert-pdf.py', $::lx_office_conf{print_templates}->{openofficeorg_daemon_port}, "${filename}.odt"); } - system(@cmdline); - my $res = $?; if ((0 == $?) || (-f "${filename}.pdf" && -s "${filename}.pdf")) { $form->{"tmpfile"} =~ s/odt$/pdf/; @@ -551,7 +574,6 @@ sub convert_to_pdf { sub format_string { my ($self, $variable) = @_; my $form = $self->{"form"}; - my $iconv = $self->{"iconv"}; $variable = $main::locale->quote_special_chars('Template/OpenDocument', $variable); @@ -567,7 +589,7 @@ sub format_string { $variable =~ s|\</${key}\>||gi; } - return $iconv->convert($variable); + return $variable; } sub get_mime_type() {