X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FTemplate%2FOpenDocument.pm;h=f9507f9ba4982127640aaadd5f612f5c8170c575;hb=072c82159a805189a5c6e39c6e5fb35f91cc01d0;hp=b4ea1f2a5d24d2f4a64da6c224766354a8c9f562;hpb=d72dd9ab9b02a72c63ab06bf8472a43bf0ba45a5;p=kivitendo-erp.git diff --git a/SL/Template/OpenDocument.pm b/SL/Template/OpenDocument.pm index b4ea1f2a5..f9507f9ba 100644 --- a/SL/Template/OpenDocument.pm +++ b/SL/Template/OpenDocument.pm @@ -416,11 +416,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 +457,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 +483,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 +532,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/;