Merge branch 'master' of vc.linet-services.de:public/lx-office-erp
[kivitendo-erp.git] / SL / Template / OpenDocument.pm
index e2f7dcd..12a7bc8 100644 (file)
@@ -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;
@@ -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);