X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FTemplate%2FOpenDocument.pm;h=b4ea1f2a5d24d2f4a64da6c224766354a8c9f562;hb=3b4068e20d8f7b044b9f85eccacac99ba3d453b3;hp=b1267c1c8bbef676c5ae97eb47539c4fdd47f827;hpb=f2af9def6777d0192a83c8a86f1332569c742051;p=kivitendo-erp.git diff --git a/SL/Template/OpenDocument.pm b/SL/Template/OpenDocument.pm index b1267c1c8..b4ea1f2a5 100644 --- a/SL/Template/OpenDocument.pm +++ b/SL/Template/OpenDocument.pm @@ -22,7 +22,7 @@ sub new { my $self = $type->SUPER::new(@_); $self->{"rnd"} = int(rand(1000000)); - $self->{"iconv"} = SL::Iconv->new($main::dbcharset, "UTF-8"); + $self->{"iconv"} = SL::Iconv->new($::lx_office_conf{system}->{dbcharset}, "UTF-8"); $self->set_tag_style('<%', '%>'); $self->{quot_re} = '"'; @@ -37,7 +37,7 @@ sub parse_foreach { my $ary = $self->_get_loop_variable($var, 1, @indices); - for (my $i = 0; $i < scalar(@{$ary}); $i++) { + for (my $i = 0; $i < scalar(@{$ary || []}); $i++) { $form->{"__first__"} = $i == 0; $form->{"__last__"} = ($i + 1) == scalar(@{$ary}); $form->{"__odd__"} = (($i + 1) % 2) == 1; @@ -270,14 +270,14 @@ sub parse { $zip->contents("content.xml", Encode::encode('utf-8-strict', $new_contents)); - my $styles = $zip->contents("styles.xml"); + my $styles = Encode::decode('utf-8-strict', $zip->contents("styles.xml")); if ($contents) { my $new_styles = $self->parse_block($styles); if (!defined($new_contents)) { $main::lxdebug->leave_sub(); return 0; } - $zip->contents("styles.xml", $new_styles); + $zip->contents("styles.xml", Encode::encode('utf-8-strict', $new_styles)); } $zip->writeToFileNamed($form->{"tmpfile"}, 1); @@ -389,7 +389,7 @@ sub spawn_xvfb { local *OUT; my $dfname = $self->{"userspath"} . "/xvfb_display"; - if (!open(OUT, ">$dfname")) { + if (!open(OUT, ">", $dfname)) { $self->{"error"} = "Conversion to PDF failed because OpenOffice could not be started ($dfname: $!)"; unlink($xauthority); kill($pid); @@ -419,7 +419,8 @@ sub spawn_xvfb { sub is_openoffice_running { $main::lxdebug->enter_sub(); - my $output = `./scripts/oo-uno-test-conn.py $main::openofficeorg_daemon_port 2> /dev/null`; + my $cmd = "./scripts/oo-uno-test-conn.py " . $::lx_office_conf{print_templates}->{openofficeorg_daemon_port} . " 2> /dev/null"; + my $output = `$cmd`; chomp $output; my $res = ($? == 0) || $output; @@ -461,7 +462,7 @@ sub spawn_openoffice { "-minimized", "-norestore", "-nologo", "-nolockcheck", "-headless", "-accept=socket,host=localhost,port=" . - $main::openofficeorg_daemon_port . ";urp;"); + $::lx_office_conf{print_templates}->{openofficeorg_daemon_port} . ";urp;"); exec(@cmdline); } @@ -508,7 +509,7 @@ sub convert_to_pdf { } my @cmdline; - if (!$main::openofficeorg_daemon) { + if (!$::lx_office_conf{print_templates}->{openofficeorg_daemon}) { @cmdline = ($::lx_office_conf{applications}->{openofficeorg_writer}, "-minimized", "-norestore", "-nologo", "-nolockcheck", "-headless", @@ -522,7 +523,7 @@ sub convert_to_pdf { } @cmdline = ("./scripts/oo-uno-convert-pdf.py", - $main::openofficeorg_daemon_port, + $::lx_office_conf{print_templates}->{openofficeorg_daemon_port}, "${filename}.odt"); }