Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision c510d88b

Von Sven Schöling vor etwa 15 Jahren hinzugefügt

und die restlichen .pm Module.

Unterschiede anzeigen:

SL/Template.pm
5 5
# Web http://www.lx-office.org
6 6
#
7 7
#====================================================================
8
#
9
#
10
#    NOTE: strict checks are package global. don't check this file
11
#            with perl -sc, it will only capture SimpleTemplate
12
#
13
#
8 14

  
9 15
package SimpleTemplate;
10 16

  
17
use strict;
18

  
11 19
# Parameters:
12 20
#   1. The template's file name
13 21
#   2. A reference to the Form object
......
219 227

  
220 228
@ISA = qw(SimpleTemplate);
221 229

  
230
use strict;
231

  
222 232
sub new {
223 233
  my $type = shift;
224 234

  
......
666 676

  
667 677
@ISA = qw(LaTeXTemplate);
668 678

  
679
use strict;
680

  
669 681
sub new {
670 682
  my $type = shift;
671 683

  
......
790 802

  
791 803
@ISA = qw(LaTeXTemplate);
792 804

  
805
use strict;
806

  
793 807
sub new {
794 808
  my $type = shift;
795 809

  
......
828 842

  
829 843
@ISA = qw(SimpleTemplate);
830 844

  
845
use strict;
846

  
831 847
sub new {
832 848
  my $type = shift;
833 849

  
834
  $self = $type->SUPER::new(@_);
850
  my $self = $type->SUPER::new(@_);
835 851

  
836 852
  foreach my $module (qw(Archive::Zip Text::Iconv)) {
837 853
    eval("use ${module};");
......
1040 1056
  }
1041 1057

  
1042 1058
  my $zip = Archive::Zip->new();
1043
  if (Archive::Zip::AZ_OK != $zip->read($file_name)) {
1059
  if (Archive::Zip->AZ_OK != $zip->read($file_name)) {
1044 1060
    $self->{"error"} = "File not found/is not a OpenDocument file.";
1045 1061
    $main::lxdebug->leave_sub();
1046 1062
    return 0;
......
1117 1133
  my $dfname = $self->{"userspath"} . "/xvfb_display";
1118 1134
  my $display;
1119 1135

  
1120
  $main::lxdebug->message(LXDebug::DEBUG2, "    Looking for $dfname\n");
1136
  $main::lxdebug->message(LXDebug->DEBUG2(), "    Looking for $dfname\n");
1121 1137
  if ((-f $dfname) && open(IN, $dfname)) {
1122 1138
    my $pid = <IN>;
1123 1139
    chomp($pid);
......
1127 1143
    chomp($xauthority);
1128 1144
    close(IN);
1129 1145

  
1130
    $main::lxdebug->message(LXDebug::DEBUG2, "      found with $pid and $display\n");
1146
    $main::lxdebug->message(LXDebug->DEBUG2(), "      found with $pid and $display\n");
1131 1147

  
1132 1148
    if ((! -d "/proc/$pid") || !open(IN, "/proc/$pid/cmdline")) {
1133
      $main::lxdebug->message(LXDebug::DEBUG2, "  no/wrong process #1\n");
1149
      $main::lxdebug->message(LXDebug->DEBUG2(), "  no/wrong process #1\n");
1134 1150
      unlink($dfname, $xauthority);
1135 1151
      $main::lxdebug->leave_sub();
1136 1152
      return undef;
......
1138 1154
    my $line = <IN>;
1139 1155
    close(IN);
1140 1156
    if ($line !~ /xvfb/i) {
1141
      $main::lxdebug->message(LXDebug::DEBUG2, "      no/wrong process #2\n");
1157
      $main::lxdebug->message(LXDebug->DEBUG2(), "      no/wrong process #2\n");
1142 1158
      unlink($dfname, $xauthority);
1143 1159
      $main::lxdebug->leave_sub();
1144 1160
      return undef;
......
1147 1163
    $ENV{"XAUTHORITY"} = $xauthority;
1148 1164
    $ENV{"DISPLAY"} = $display;
1149 1165
  } else {
1150
    $main::lxdebug->message(LXDebug::DEBUG2, "      not found\n");
1166
    $main::lxdebug->message(LXDebug->DEBUG2(), "      not found\n");
1151 1167
  }
1152 1168

  
1153 1169
  $main::lxdebug->leave_sub();
......
1160 1176

  
1161 1177
  my ($self) = @_;
1162 1178

  
1163
  $main::lxdebug->message(LXDebug::DEBUG2, "spawn_xvfb()\n");
1179
  $main::lxdebug->message(LXDebug->DEBUG2, "spawn_xvfb()\n");
1164 1180

  
1165 1181
  my $display = $self->is_xvfb_running();
1166 1182

  
......
1174 1190
    $display++;
1175 1191
  }
1176 1192
  $display = ":${display}";
1177
  $main::lxdebug->message(LXDebug::DEBUG2, "  display $display\n");
1193
  $main::lxdebug->message(LXDebug->DEBUG2(), "  display $display\n");
1178 1194

  
1179 1195
  my $mcookie = `mcookie`;
1180 1196
  die("Installation error: mcookie not found.") if ($? != 0);
1181 1197
  chomp($mcookie);
1182 1198

  
1183
  $main::lxdebug->message(LXDebug::DEBUG2, "  mcookie $mcookie\n");
1199
  $main::lxdebug->message(LXDebug->DEBUG2(), "  mcookie $mcookie\n");
1184 1200

  
1185 1201
  my $xauthority = "/tmp/.Xauthority-" . $$ . "-" . time() . "-" . int(rand(9999999));
1186 1202
  $ENV{"XAUTHORITY"} = $xauthority;
1187 1203

  
1188
  $main::lxdebug->message(LXDebug::DEBUG2, "  xauthority $xauthority\n");
1204
  $main::lxdebug->message(LXDebug->DEBUG2(), "  xauthority $xauthority\n");
1189 1205

  
1190 1206
  system("xauth add \"${display}\" . \"${mcookie}\"");
1191 1207
  if ($? != 0) {
......
1194 1210
    return undef;
1195 1211
  }
1196 1212

  
1197
  $main::lxdebug->message(LXDebug::DEBUG2, "  about to fork()\n");
1213
  $main::lxdebug->message(LXDebug->DEBUG2(), "  about to fork()\n");
1198 1214

  
1199 1215
  my $pid = fork();
1200 1216
  if (0 == $pid) {
1201
    $main::lxdebug->message(LXDebug::DEBUG2, "  Child execing\n");
1217
    $main::lxdebug->message(LXDebug->DEBUG2(), "  Child execing\n");
1202 1218
    exec($main::xvfb_bin, $display, "-screen", "0", "640x480x8", "-nolisten", "tcp");
1203 1219
  }
1204 1220
  sleep(3);
1205
  $main::lxdebug->message(LXDebug::DEBUG2, "  parent dont sleeping\n");
1221
  $main::lxdebug->message(LXDebug->DEBUG2(), "  parent dont sleeping\n");
1206 1222

  
1207 1223
  local *OUT;
1208 1224
  my $dfname = $self->{"userspath"} . "/xvfb_display";
......
1216 1232
  print(OUT "$pid\n$display\n$xauthority\n");
1217 1233
  close(OUT);
1218 1234

  
1219
  $main::lxdebug->message(LXDebug::DEBUG2, "  parent re-testing\n");
1235
  $main::lxdebug->message(LXDebug->DEBUG2(), "  parent re-testing\n");
1220 1236

  
1221 1237
  if (!$self->is_xvfb_running()) {
1222 1238
    $self->{"error"} = "Conversion to PDF failed because OpenOffice could not be started.";
......
1226 1242
    return undef;
1227 1243
  }
1228 1244

  
1229
  $main::lxdebug->message(LXDebug::DEBUG2, "  spawn OK\n");
1245
  $main::lxdebug->message(LXDebug->DEBUG2(), "  spawn OK\n");
1230 1246

  
1231 1247
  $main::lxdebug->leave_sub();
1232 1248

  
......
1239 1255
  system("./scripts/oo-uno-test-conn.py $main::openofficeorg_daemon_port " .
1240 1256
         "> /dev/null 2> /dev/null");
1241 1257
  my $res = $? == 0;
1242
  $main::lxdebug->message(LXDebug::DEBUG2, "  is_openoffice_running(): $?\n");
1258
  $main::lxdebug->message(LXDebug->DEBUG2(), "  is_openoffice_running(): $?\n");
1243 1259

  
1244 1260
  $main::lxdebug->leave_sub();
1245 1261

  
......
1251 1267

  
1252 1268
  my ($self) = @_;
1253 1269

  
1254
  $main::lxdebug->message(LXDebug::DEBUG2, "spawn_openoffice()\n");
1270
  $main::lxdebug->message(LXDebug->DEBUG2(), "spawn_openoffice()\n");
1255 1271

  
1256 1272
  my ($try, $spawned_oo, $res);
1257 1273

  
......
1265 1281
    if (!$spawned_oo) {
1266 1282
      my $pid = fork();
1267 1283
      if (0 == $pid) {
1268
        $main::lxdebug->message(LXDebug::DEBUG2, "  Child daemonizing\n");
1284
        $main::lxdebug->message(LXDebug->DEBUG2(), "  Child daemonizing\n");
1269 1285
        chdir('/');
1270 1286
        open(STDIN, '/dev/null');
1271 1287
        open(STDOUT, '>/dev/null');
1272 1288
        my $new_pid = fork();
1273 1289
        exit if ($new_pid);
1274 1290
        my $ssres = setsid();
1275
        $main::lxdebug->message(LXDebug::DEBUG2, "  Child execing\n");
1291
        $main::lxdebug->message(LXDebug->DEBUG2(), "  Child execing\n");
1276 1292
        my @cmdline = ($main::openofficeorg_writer_bin,
1277 1293
                       "-minimized", "-norestore", "-nologo", "-nolockcheck",
1278 1294
                       "-headless",
......
1281 1297
        exec(@cmdline);
1282 1298
      }
1283 1299

  
1284
      $main::lxdebug->message(LXDebug::DEBUG2, "  Parent after fork\n");
1300
      $main::lxdebug->message(LXDebug->DEBUG2(), "  Parent after fork\n");
1285 1301
      $spawned_oo = 1;
1286 1302
      sleep(3);
1287 1303
    }
......
1386 1402
}
1387 1403

  
1388 1404
sub get_mime_type() {
1405
  my ($self) = @_;
1406

  
1389 1407
  if ($self->{"form"}->{"format"} =~ /pdf/) {
1390 1408
    return "application/pdf";
1391 1409
  } else {
......
1410 1428

  
1411 1429
@ISA = qw(HTMLTemplate);
1412 1430

  
1431
use strict;
1432

  
1413 1433
sub new {
1414 1434
  #evtl auskommentieren
1415 1435
  my $type = shift;

Auch abrufbar als: Unified diff