jl165 merging heads
[LibreOffice.git] / testgraphical / source / ConvwatchHelper.pm
blob8f157641b1f4655a122979e9e1e6423edac15fc7
1 package ConvwatchHelper;
3 use English;
4 use warnings;
5 use strict;
6 use Cwd;
7 use Cwd 'chdir';
9 use CallExternals;
10 use stringhelper;
11 use filehelper;
12 use oshelper;
13 use loghelper;
15 BEGIN {
16 use Exporter ();
17 our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
19 $VERSION = 1.00;
20 # if using RCS/CVS, this may be preferred
21 $VERSION = do { my @r = (q$Revision: 1.39 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; # must be all one line, for MakeMaker
22 @ISA = qw(Exporter);
23 @EXPORT = qw(&getQADEVToolsPath &setProjectRoot &getProjectRoot &checkForStop &getSofficeExe &setINPATH);
24 %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
25 # your exported package globals go here,
26 # as well as any optionally exported functions
27 @EXPORT_OK = ( ); # qw($Var1 %Hashit &func3);
30 # ------------------------------------------------------------------------------
31 our $tempprefix;
33 # sub getTempDir()
34 # {
35 # my $sTempDir;
36 # if (! $tempprefix)
37 # {
38 # if ($OSNAME eq "MSWin32" || $OSNAME eq "cygwin")
39 # {
40 # # $tempdir = "C:/gfxcmp/temp";
41 # $tempprefix = "//so-gfxcmp-lin/gfxcmp-data/wntmsci/temp";
42 # }
43 # elsif ($OSNAME eq "linux")
44 # {
45 # $tempprefix = "/net/so-gfxcmp-lin/export/gfxcmp/data/unxlngi/temp";
46 # }
47 # elsif ($OSNAME eq "solaris")
48 # {
49 # # $tempdir = "/space/gfxcmp/temp";
50 # $tempprefix = "/net/so-gfxcmp-lin/export/gfxcmp/data/unxsoli/temp";
51 # }
52 # else
53 # {
54 # print "Error: This environment isn't supported yet.\n";
55 # exit(1);
56 # }
57 # }
58 # $sTempDir = $tempprefix;
59 # return $sTempDir;
60 # }
61 # ------------------------------------------------------------------------------
62 # in filehelper
63 # our $programprefix;
65 # sub getProgramPrefix($)
66 # {
67 # my $sDBDistinct = shift;
69 # my $sProgramPrefix;
70 # if (! $programprefix)
71 # {
72 # if ($OSNAME eq "MSWin32")
73 # {
74 # # $programprefix = "C:/gfxcmp/programs";
75 # $programprefix = "C:/gp";
76 # }
77 # elsif ($OSNAME eq "linux")
78 # {
79 # $programprefix = "/space/gfxcmp/programs";
80 # }
81 # elsif ($OSNAME eq "solaris")
82 # {
83 # $programprefix = "/space/gfxcmp/programs";
84 # }
85 # else
86 # {
87 # print "Error: This environment isn't supported yet.\n";
88 # exit(1);
89 # }
90 # }
91 # $sProgramPrefix = appendPath($programprefix, substr($sDBDistinct, 0, 19));
92 # return $sProgramPrefix;
93 # }
94 # ------------------------------------------------------------------------------
95 sub getQADEVToolsPath()
97 my $sNewPath = appendPath(getToolsPrefix(), "qadev");
98 $sNewPath = appendPath($sNewPath, "scripts");
99 $sNewPath = appendPath($sNewPath, "gfxcmp_ui");
100 return $sNewPath;
103 # in filehelper
104 # our $toolsprefix;
106 # sub getToolsPrefix()
108 # my $sToolsPrefix;
109 # if (! $toolsprefix)
111 # if ($OSNAME eq "MSWin32")
113 # $toolsprefix = "C:/gfxcmp/tools";
115 # elsif ($OSNAME eq "linux")
117 # $toolsprefix = "/space/gfxcmp/tools";
119 # elsif ($OSNAME eq "solaris")
121 # $toolsprefix = "/space/gfxcmp/tools";
123 # else
125 # print "Error: This environment isn't supported yet.\n";
126 # exit(1);
129 # $sToolsPrefix = $toolsprefix;
130 # return $sToolsPrefix;
132 # ------------------------------------------------------------------------------
133 our $sProjectRoot;
134 sub setProjectRoot($)
136 $sProjectRoot = shift;
137 log_print "\$sProjectRoot := $sProjectRoot\n";
139 sub getProjectRoot()
141 if ($sProjectRoot)
143 return $sProjectRoot;
145 die "setProjectRoot(PATH) not set.\n";
148 our $sINPATH;
149 sub setINPATH($)
151 $sINPATH = shift;
153 sub getINPATH()
155 if ($sINPATH)
157 return $sINPATH;
159 die "setINPATH(PATH) not set.\n";
161 our $dataprefix;
163 # sub getDataPrefix()
165 # my $sDataPrefix;
166 # if (! $dataprefix)
168 # if ($OSNAME eq "MSWin32" || $OSNAME eq "cygwin")
170 # # $dataprefix = "C:/gfxcmp/data";
171 # # $dataprefix = "//so-gfxcmp-lin/gfxcmp-data/wntmsci";
172 # $dataprefix = getProjectRoot();
174 # elsif ($OSNAME eq "linux")
176 # # $dataprefix = "/space/gfxcmp/data";
177 # # $dataprefix = "/net/so-gfxcmp-lin/export/gfxcmp/data/unxlngi";
178 # $dataprefix = getProjectRoot();
180 # elsif ($OSNAME eq "solaris")
182 # # $dataprefix = "/space/gfxcmp/data";
183 # # $dataprefix = "/net/so-gfxcmp-lin/export/gfxcmp/data/unxsoli";
184 # $dataprefix = getProjectRoot();
186 # else
188 # print "Error: This environment isn't supported yet.\n";
189 # exit(1);
191 # $dataprefix = appendPath(getProjectRoot(), getINPATH());
192 # $dataprefix = appendPath($dataprefix, "data");
194 # $sDataPrefix = $dataprefix;
195 # return $sDataPrefix;
198 # ------------------------------------------------------------------------------
200 # sub _shortsleep($)
202 # # sleep 1;
203 # select(undef, undef, undef, 0.333);
206 # sub _waitInSeconds($)
208 # my $nLength = shift;
209 # my $i;
210 # my $j;
212 # for ($j=0;$j<$nLength;$j++)
214 # for ($i=0;$i<$j;$i++)
216 # print ".";
218 # for ($i=$j;$i<$nLength;$i++)
220 # print " ";
222 # _shortsleep( 1 );
223 # print "\r";
226 # for ($j=0;$j<=$nLength;$j++)
228 # for ($i=0;$i<$j;$i++)
230 # print " ";
232 # for ($i=$j;$i<$nLength;$i++)
234 # print ".";
236 # _shortsleep( 1 );
237 # print "\r";
241 # sub wait30seconds()
243 # _waitInSeconds(20);
244 # _waitInSeconds(20);
247 sub checkForStop($)
249 my $sStopFilename = shift;
250 my $sStopFilePath;
251 if ($OSNAME eq "MSWin32")
253 $sStopFilePath = "C:/temp/";
255 else
257 $sStopFilePath = "/tmp/";
259 my $sStopFile = $sStopFilePath . $sStopFilename;
260 if ( -e "$sStopFile" )
262 print "Stop of Convwatch tool forced!\n";
263 unlink($sStopFile);
264 exit(2);
268 # ----------------------------------------------------------------------------------------
269 sub readdirectory($$$);
271 sub readdirectory($$$)
273 my $startdir = shift;
274 my $sUserParameter = shift;
275 my $hook = shift;
277 my $myfile;
279 local *DIR;
280 chdir $startdir;
281 cwd();
283 my $nCountFiles = 0;
284 if (opendir (DIR, $startdir)) # Directory oeffnen
286 while ($myfile = readdir(DIR))
287 { # ein filename holen
288 #if (! -l $myfile) # not a link
290 if (-d $myfile ) # is a directory
292 if ( -l $myfile)
294 next;
296 # if ( $myfile eq "help" ||
297 # $myfile eq "presets" ||
298 # $myfile eq "registry" ||
299 # $myfile eq "uno_packages" ||
300 # $myfile eq "lib" ||
301 # $myfile eq "user_tree" )
303 # next;
306 if ($myfile ne "." && $myfile ne "..")
308 my $sNewStartDir = appendPath($startdir, $myfile); # neuen Directorystring erstellen
309 # if ($sNewStartDir =~ "^\/proc" ||
310 # $sNewStartDir =~ "^\/dev" ||
311 # $sNewStartDir =~ "^\/udev" ||
312 # $sNewStartDir =~ "lost+found" )
314 # next;
316 # my $sNewSUserParameter = $sUserParameter . $myfile ."/";
317 # do a recursive call
318 # $nCountFiles++;
319 my $nFileCount = readdirectory($sNewStartDir, $sUserParameter, $hook);
320 # workOnDir($sNewDir, $nFileCount);
321 $nCountFiles += $nFileCount;
323 chdir ($startdir); # zurueckwechseln.
324 cwd();
327 else
329 # File must exist, be a regular file and must not be the $onlyOnFile
330 if (-f $myfile)
332 # print STDERR " $startdir" . "$myfile\n";
333 $nCountFiles++;
334 # workOnFile($startdir, $myfile, $destdir);
335 $hook->($startdir, $myfile, $sUserParameter);
339 #else
341 # print STDERR "linked file: $dir/$myfile\n";
344 closedir(DIR);
346 else
348 print STDERR "could not open $startdir\n";
350 return $nCountFiles;
353 our $lcl_sSofficeBinPath;
354 our $lcl_sSofficeBinName;
356 sub searchSofficeBin($$$)
358 my $currentDir = shift;
359 my $currentFile = shift;
360 my $sUserParameter = shift;
362 if ($currentFile eq $sUserParameter)
364 my $sSourceFilename;
365 $sSourceFilename = appendPath($currentDir, $currentFile);
367 if ( -e "$sSourceFilename" )
369 $lcl_sSofficeBinPath = $currentDir;
370 $lcl_sSofficeBinName = $currentFile;
375 # our $lcl_sUnoPkgPath;
377 # sub searchUnoPkgBin($$$)
379 # my $currentDir = shift;
380 # my $currentFile = shift;
381 # my $sUserParameter = shift;
383 # if ($currentFile eq $sUserParameter)
385 # my $sSourceFilename;
386 # $sSourceFilename = appendPath($currentDir, $currentFile);
387 # if ( -e "$sSourceFilename" )
389 # $lcl_sUnoPkgPath = $currentDir;
394 # our $lcl_sJARPath;
396 # sub searchJARFile($$$)
398 # my $currentDir = shift;
399 # my $currentFile = shift;
400 # my $sUserParameter = shift;
402 # if ($currentFile eq $sUserParameter)
404 # my $sSourceFilename;
405 # $sSourceFilename = appendPath($currentDir, $currentFile);
406 # if ( -e "$sSourceFilename" )
408 # $lcl_sJARPath = $currentDir;
413 # return the PATH, where the file was found
414 # sub searchForJAR($$)
416 # my $sPathToInstallOffice = shift;
417 # my $sJARFileName = shift;
419 # my $sCurrentPath = cwd();
421 # $lcl_sJARPath = "";
422 # readdirectory(${sPathToInstallOffice}, ${sJARFileName}, \&searchJARFile);
424 # chdir $sCurrentPath;
425 # cwd();
427 # return $lcl_sJARPath;
430 # sub getUnoPkg($)
432 # my $sPathToInstallOffice = shift;
434 # my $sUnoPkgName = "unopkg.bin";
435 # if (isWindowsEnvironment())
437 # $sUnoPkgName = "unopkg.exe";
440 # my $sCurrentPath = cwd();
442 # $lcl_sUnoPkgPath = "";
443 # readdirectory(${sPathToInstallOffice}, ${sUnoPkgName}, \&searchUnoPkgBin);
445 # chdir $sCurrentPath;
446 # cwd();
448 # return ($lcl_sUnoPkgPath, $sUnoPkgName);
451 sub getSofficeExe($)
453 my $sPathToOffice = shift;
455 my $sSofficeExeName = "soffice";
456 if (isWindowsEnvironment())
458 $sSofficeExeName = "soffice.exe";
461 my $sCurrentPath = cwd();
463 $lcl_sSofficeBinPath = "";
464 $lcl_sSofficeBinName = "";
465 readdirectory(${sPathToOffice}, ${sSofficeExeName}, \&searchSofficeBin);
467 chdir $sCurrentPath;
468 cwd();
470 return ($lcl_sSofficeBinPath, $lcl_sSofficeBinName);
473 # sub checkOfficeAlreadyInstalled($)
475 # my $sOfficePath = shift;
477 # my $sCurrentPath = cwd();
479 # $lcl_sSofficeBinPath = "";
480 # my $sOldOfficePath = appendPath($sOfficePath, "program");
481 # if ( -d "$sOldOfficePath" )
483 # $sOldOfficePath = appendPath($sOldOfficePath, "soffice.bin");
484 # if ( -e $sOldOfficePath )
486 # return 1;
489 # else
491 # if (isWindowsEnvironment())
493 # my $sThreeLayerOffice = appendPath($sOfficePath, "Sun");
494 # $sThreeLayerOffice = appendPath($sThreeLayerOffice, "StarOffice 9");
495 # $sThreeLayerOffice = appendPath($sThreeLayerOffice, "program");
496 # $sThreeLayerOffice = appendPath($sThreeLayerOffice, "soffice.bin");
498 # if ( -e "$sThreeLayerOffice" )
500 # return 1;
503 # else
505 # my $sThreeLayerOffice = appendPath($sOfficePath, "staroffice9");
506 # $sThreeLayerOffice = appendPath($sThreeLayerOffice, "program");
507 # $sThreeLayerOffice = appendPath($sThreeLayerOffice, "soffice.bin");
508 # if ( -e "$sThreeLayerOffice" )
510 # return 1;
515 # # soffice.bin not found in fast path
516 # readdirectory($sOfficePath, "soffice.bin", \&searchSofficeBin);
517 # chdir $sCurrentPath;
518 # cwd();
520 # if ( $lcl_sSofficeBinPath ne "" )
522 # return 1;
524 # return 0;
525 # # this is the old check
526 # # my $sOfficePathCheck = appendPath(${sPathToInstallOffice}, "program");
527 # # $sOfficePathCheck = appendPath($sOfficePathCheck, "soffice.bin");
528 # # if ( -e $sOfficePathCheck )
529 # # {
530 # # return 1;
531 # # }
533 # # # check path system of tree layer office
534 # # if ( isWindowsEnvironment() )
535 # # {
536 # # $sOfficePathCheck = appendPath(${sPathToInstallOffice}, "Sun");
537 # # if ( ! -e $sOfficePathCheck)
538 # # {
539 # # # could be an OpenOffice.org
540 # # return 0;
541 # # }
542 # # else
543 # # {
545 # # $sOfficePathCheck = appendPath($sOfficePathCheck, "StarOffice 9");
546 # # $sOfficePathCheck = appendPath($sOfficePathCheck, "program");
547 # # $sOfficePathCheck = appendPath($sOfficePathCheck, "soffice.bin");
548 # # if ( -e $sOfficePathCheck )
549 # # {
550 # # return 1;
551 # # }
552 # # print "Error: There exist no Office, maybe an unsupported version?\n";
553 # # }
554 # # }
555 # # elsif ( isUnixEnvironment() )
556 # # {
557 # # $sOfficePathCheck = appendPath(${sPathToInstallOffice}, "staroffice9");
558 # # $sOfficePathCheck = appendPath($sOfficePathCheck, "staroffice9");
559 # # $sOfficePathCheck = appendPath($sOfficePathCheck, "program");
560 # # $sOfficePathCheck = appendPath($sOfficePathCheck, "soffice.bin");
561 # # if ( -e $sOfficePathCheck )
562 # # {
563 # # return 1;
564 # # }
565 # # print "Error: There exist no Office, maybe an unsupported version?\n";
566 # # }
567 # # else
568 # # {
569 # # print "Error: There exist no Office, maybe an unsupported version?\n";
570 # # }
571 # # return 0;