- opendir TEMPLATEDIR, $::lx_office_conf{paths}->{templates} or $form->error($::lx_office_conf{paths}->{templates} . " : $ERRNO");
- my @templates = grep /$form->{mastertemplates}.*?\.(html|tex|sty|odt|xml|txb)$/,
- readdir TEMPLATEDIR;
- closedir TEMPLATEDIR;
-
- foreach my $file (@templates) {
- open(TEMP, $::lx_office_conf{paths}->{templates} . "/$file")
- or $form->error($::lx_office_conf{paths}->{templates} . "/$file : $ERRNO");
-
- $file =~ s/\Q$form->{mastertemplates}\E-//;
- open(NEW, ">$form->{templates}/$file")
- or $form->error("$form->{templates}/$file : $ERRNO");
-
- while (my $line = <TEMP>) {
- print NEW $line;
- }
- close(TEMP);
- close(NEW);
+
+ my $oldcurrdir = getcwd();
+ if (!chdir("$::lx_office_conf{paths}->{templates}/print/$form->{mastertemplates}")) {
+ $form->error("$ERRNO: chdir $::lx_office_conf{paths}->{templates}/print/$form->{mastertemplates}");