X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FTemplate%2FOpenDocument.pm;h=4eed5eae20ad54151a841438974fa0bf9ed94c4f;hb=1b9d0f70b5e58c510ed2ab4337eb0f6512d779ca;hp=b4ea1f2a5d24d2f4a64da6c224766354a8c9f562;hpb=5829f39dc57db589b830a4adc4053538ddec0ee5;p=kivitendo-erp.git diff --git a/SL/Template/OpenDocument.pm b/SL/Template/OpenDocument.pm index b4ea1f2a5..4eed5eae2 100644 --- a/SL/Template/OpenDocument.pm +++ b/SL/Template/OpenDocument.pm @@ -260,7 +260,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 +423,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 +464,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 +490,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 +539,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/;