1*bb113e63SAndrew Rist# ************************************************************* 2*bb113e63SAndrew Rist# 3*bb113e63SAndrew Rist# Licensed to the Apache Software Foundation (ASF) under one 4*bb113e63SAndrew Rist# or more contributor license agreements. See the NOTICE file 5*bb113e63SAndrew Rist# distributed with this work for additional information 6*bb113e63SAndrew Rist# regarding copyright ownership. The ASF licenses this file 7*bb113e63SAndrew Rist# to you under the Apache License, Version 2.0 (the 8*bb113e63SAndrew Rist# "License"); you may not use this file except in compliance 9*bb113e63SAndrew Rist# with the License. You may obtain a copy of the License at 10*bb113e63SAndrew Rist# 11*bb113e63SAndrew Rist# http://www.apache.org/licenses/LICENSE-2.0 12*bb113e63SAndrew Rist# 13*bb113e63SAndrew Rist# Unless required by applicable law or agreed to in writing, 14*bb113e63SAndrew Rist# software distributed under the License is distributed on an 15*bb113e63SAndrew Rist# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*bb113e63SAndrew Rist# KIND, either express or implied. See the License for the 17*bb113e63SAndrew Rist# specific language governing permissions and limitations 18*bb113e63SAndrew Rist# under the License. 19*bb113e63SAndrew Rist# 20*bb113e63SAndrew Rist# ************************************************************* 21cdf0e10cSrcweirpackage ConvwatchHelper; 22cdf0e10cSrcweir 23cdf0e10cSrcweiruse English; 24cdf0e10cSrcweiruse warnings; 25cdf0e10cSrcweiruse strict; 26cdf0e10cSrcweiruse Cwd; 27cdf0e10cSrcweiruse Cwd 'chdir'; 28cdf0e10cSrcweir 29cdf0e10cSrcweiruse CallExternals; 30cdf0e10cSrcweiruse stringhelper; 31cdf0e10cSrcweiruse filehelper; 32cdf0e10cSrcweiruse oshelper; 33cdf0e10cSrcweiruse loghelper; 34cdf0e10cSrcweir 35cdf0e10cSrcweirBEGIN { 36cdf0e10cSrcweir use Exporter (); 37cdf0e10cSrcweir our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); 38cdf0e10cSrcweir 39cdf0e10cSrcweir $VERSION = 1.00; 40cdf0e10cSrcweir # if using RCS/CVS, this may be preferred 41cdf0e10cSrcweir $VERSION = do { my @r = (q$Revision: 1.39 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; # must be all one line, for MakeMaker 42cdf0e10cSrcweir @ISA = qw(Exporter); 43cdf0e10cSrcweir @EXPORT = qw(&getQADEVToolsPath &setProjectRoot &getProjectRoot &checkForStop &getSofficeExe &setINPATH); 44cdf0e10cSrcweir %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ], 45cdf0e10cSrcweir # your exported package globals go here, 46cdf0e10cSrcweir # as well as any optionally exported functions 47cdf0e10cSrcweir @EXPORT_OK = ( ); # qw($Var1 %Hashit &func3); 48cdf0e10cSrcweir} 49cdf0e10cSrcweir 50cdf0e10cSrcweir# ------------------------------------------------------------------------------ 51cdf0e10cSrcweirour $tempprefix; 52cdf0e10cSrcweir 53cdf0e10cSrcweir# sub getTempDir() 54cdf0e10cSrcweir# { 55cdf0e10cSrcweir# my $sTempDir; 56cdf0e10cSrcweir# if (! $tempprefix) 57cdf0e10cSrcweir# { 58cdf0e10cSrcweir# if ($OSNAME eq "MSWin32" || $OSNAME eq "cygwin") 59cdf0e10cSrcweir# { 60cdf0e10cSrcweir# # $tempdir = "C:/gfxcmp/temp"; 61cdf0e10cSrcweir# $tempprefix = "//so-gfxcmp-lin/gfxcmp-data/wntmsci/temp"; 62cdf0e10cSrcweir# } 63cdf0e10cSrcweir# elsif ($OSNAME eq "linux") 64cdf0e10cSrcweir# { 65cdf0e10cSrcweir# $tempprefix = "/net/so-gfxcmp-lin/export/gfxcmp/data/unxlngi/temp"; 66cdf0e10cSrcweir# } 67cdf0e10cSrcweir# elsif ($OSNAME eq "solaris") 68cdf0e10cSrcweir# { 69cdf0e10cSrcweir# # $tempdir = "/space/gfxcmp/temp"; 70cdf0e10cSrcweir# $tempprefix = "/net/so-gfxcmp-lin/export/gfxcmp/data/unxsoli/temp"; 71cdf0e10cSrcweir# } 72cdf0e10cSrcweir# else 73cdf0e10cSrcweir# { 74cdf0e10cSrcweir# print "Error: This environment isn't supported yet.\n"; 75cdf0e10cSrcweir# exit(1); 76cdf0e10cSrcweir# } 77cdf0e10cSrcweir# } 78cdf0e10cSrcweir# $sTempDir = $tempprefix; 79cdf0e10cSrcweir# return $sTempDir; 80cdf0e10cSrcweir# } 81cdf0e10cSrcweir# ------------------------------------------------------------------------------ 82cdf0e10cSrcweir# in filehelper 83cdf0e10cSrcweir# our $programprefix; 84cdf0e10cSrcweir# 85cdf0e10cSrcweir# sub getProgramPrefix($) 86cdf0e10cSrcweir# { 87cdf0e10cSrcweir# my $sDBDistinct = shift; 88cdf0e10cSrcweir# 89cdf0e10cSrcweir# my $sProgramPrefix; 90cdf0e10cSrcweir# if (! $programprefix) 91cdf0e10cSrcweir# { 92cdf0e10cSrcweir# if ($OSNAME eq "MSWin32") 93cdf0e10cSrcweir# { 94cdf0e10cSrcweir# # $programprefix = "C:/gfxcmp/programs"; 95cdf0e10cSrcweir# $programprefix = "C:/gp"; 96cdf0e10cSrcweir# } 97cdf0e10cSrcweir# elsif ($OSNAME eq "linux") 98cdf0e10cSrcweir# { 99cdf0e10cSrcweir# $programprefix = "/space/gfxcmp/programs"; 100cdf0e10cSrcweir# } 101cdf0e10cSrcweir# elsif ($OSNAME eq "solaris") 102cdf0e10cSrcweir# { 103cdf0e10cSrcweir# $programprefix = "/space/gfxcmp/programs"; 104cdf0e10cSrcweir# } 105cdf0e10cSrcweir# else 106cdf0e10cSrcweir# { 107cdf0e10cSrcweir# print "Error: This environment isn't supported yet.\n"; 108cdf0e10cSrcweir# exit(1); 109cdf0e10cSrcweir# } 110cdf0e10cSrcweir# } 111cdf0e10cSrcweir# $sProgramPrefix = appendPath($programprefix, substr($sDBDistinct, 0, 19)); 112cdf0e10cSrcweir# return $sProgramPrefix; 113cdf0e10cSrcweir# } 114cdf0e10cSrcweir# ------------------------------------------------------------------------------ 115cdf0e10cSrcweirsub getQADEVToolsPath() 116cdf0e10cSrcweir{ 117cdf0e10cSrcweir my $sNewPath = appendPath(getToolsPrefix(), "qadev"); 118cdf0e10cSrcweir $sNewPath = appendPath($sNewPath, "scripts"); 119cdf0e10cSrcweir $sNewPath = appendPath($sNewPath, "gfxcmp_ui"); 120cdf0e10cSrcweir return $sNewPath; 121cdf0e10cSrcweir} 122cdf0e10cSrcweir 123cdf0e10cSrcweir# in filehelper 124cdf0e10cSrcweir# our $toolsprefix; 125cdf0e10cSrcweir# 126cdf0e10cSrcweir# sub getToolsPrefix() 127cdf0e10cSrcweir# { 128cdf0e10cSrcweir# my $sToolsPrefix; 129cdf0e10cSrcweir# if (! $toolsprefix) 130cdf0e10cSrcweir# { 131cdf0e10cSrcweir# if ($OSNAME eq "MSWin32") 132cdf0e10cSrcweir# { 133cdf0e10cSrcweir# $toolsprefix = "C:/gfxcmp/tools"; 134cdf0e10cSrcweir# } 135cdf0e10cSrcweir# elsif ($OSNAME eq "linux") 136cdf0e10cSrcweir# { 137cdf0e10cSrcweir# $toolsprefix = "/space/gfxcmp/tools"; 138cdf0e10cSrcweir# } 139cdf0e10cSrcweir# elsif ($OSNAME eq "solaris") 140cdf0e10cSrcweir# { 141cdf0e10cSrcweir# $toolsprefix = "/space/gfxcmp/tools"; 142cdf0e10cSrcweir# } 143cdf0e10cSrcweir# else 144cdf0e10cSrcweir# { 145cdf0e10cSrcweir# print "Error: This environment isn't supported yet.\n"; 146cdf0e10cSrcweir# exit(1); 147cdf0e10cSrcweir# } 148cdf0e10cSrcweir# } 149cdf0e10cSrcweir# $sToolsPrefix = $toolsprefix; 150cdf0e10cSrcweir# return $sToolsPrefix; 151cdf0e10cSrcweir# } 152cdf0e10cSrcweir# ------------------------------------------------------------------------------ 153cdf0e10cSrcweirour $sProjectRoot; 154cdf0e10cSrcweirsub setProjectRoot($) 155cdf0e10cSrcweir{ 156cdf0e10cSrcweir $sProjectRoot = shift; 157cdf0e10cSrcweir log_print "\$sProjectRoot := $sProjectRoot\n"; 158cdf0e10cSrcweir} 159cdf0e10cSrcweirsub getProjectRoot() 160cdf0e10cSrcweir{ 161cdf0e10cSrcweir if ($sProjectRoot) 162cdf0e10cSrcweir { 163cdf0e10cSrcweir return $sProjectRoot; 164cdf0e10cSrcweir } 165cdf0e10cSrcweir die "setProjectRoot(PATH) not set.\n"; 166cdf0e10cSrcweir} 167cdf0e10cSrcweir 168cdf0e10cSrcweirour $sINPATH; 169cdf0e10cSrcweirsub setINPATH($) 170cdf0e10cSrcweir{ 171cdf0e10cSrcweir $sINPATH = shift; 172cdf0e10cSrcweir} 173cdf0e10cSrcweirsub getINPATH() 174cdf0e10cSrcweir{ 175cdf0e10cSrcweir if ($sINPATH) 176cdf0e10cSrcweir { 177cdf0e10cSrcweir return $sINPATH; 178cdf0e10cSrcweir } 179cdf0e10cSrcweir die "setINPATH(PATH) not set.\n"; 180cdf0e10cSrcweir} 181cdf0e10cSrcweirour $dataprefix; 182cdf0e10cSrcweir 183cdf0e10cSrcweir# sub getDataPrefix() 184cdf0e10cSrcweir# { 185cdf0e10cSrcweir# my $sDataPrefix; 186cdf0e10cSrcweir# if (! $dataprefix) 187cdf0e10cSrcweir# { 188cdf0e10cSrcweir# if ($OSNAME eq "MSWin32" || $OSNAME eq "cygwin") 189cdf0e10cSrcweir# { 190cdf0e10cSrcweir# # $dataprefix = "C:/gfxcmp/data"; 191cdf0e10cSrcweir# # $dataprefix = "//so-gfxcmp-lin/gfxcmp-data/wntmsci"; 192cdf0e10cSrcweir# $dataprefix = getProjectRoot(); 193cdf0e10cSrcweir# } 194cdf0e10cSrcweir# elsif ($OSNAME eq "linux") 195cdf0e10cSrcweir# { 196cdf0e10cSrcweir# # $dataprefix = "/space/gfxcmp/data"; 197cdf0e10cSrcweir# # $dataprefix = "/net/so-gfxcmp-lin/export/gfxcmp/data/unxlngi"; 198cdf0e10cSrcweir# $dataprefix = getProjectRoot(); 199cdf0e10cSrcweir# } 200cdf0e10cSrcweir# elsif ($OSNAME eq "solaris") 201cdf0e10cSrcweir# { 202cdf0e10cSrcweir# # $dataprefix = "/space/gfxcmp/data"; 203cdf0e10cSrcweir# # $dataprefix = "/net/so-gfxcmp-lin/export/gfxcmp/data/unxsoli"; 204cdf0e10cSrcweir# $dataprefix = getProjectRoot(); 205cdf0e10cSrcweir# } 206cdf0e10cSrcweir# else 207cdf0e10cSrcweir# { 208cdf0e10cSrcweir# print "Error: This environment isn't supported yet.\n"; 209cdf0e10cSrcweir# exit(1); 210cdf0e10cSrcweir# } 211cdf0e10cSrcweir# $dataprefix = appendPath(getProjectRoot(), getINPATH()); 212cdf0e10cSrcweir# $dataprefix = appendPath($dataprefix, "data"); 213cdf0e10cSrcweir# } 214cdf0e10cSrcweir# $sDataPrefix = $dataprefix; 215cdf0e10cSrcweir# return $sDataPrefix; 216cdf0e10cSrcweir# } 217cdf0e10cSrcweir 218cdf0e10cSrcweir# ------------------------------------------------------------------------------ 219cdf0e10cSrcweir 220cdf0e10cSrcweir# sub _shortsleep($) 221cdf0e10cSrcweir# { 222cdf0e10cSrcweir# # sleep 1; 223cdf0e10cSrcweir# select(undef, undef, undef, 0.333); 224cdf0e10cSrcweir# } 225cdf0e10cSrcweir# 226cdf0e10cSrcweir# sub _waitInSeconds($) 227cdf0e10cSrcweir# { 228cdf0e10cSrcweir# my $nLength = shift; 229cdf0e10cSrcweir# my $i; 230cdf0e10cSrcweir# my $j; 231cdf0e10cSrcweir# 232cdf0e10cSrcweir# for ($j=0;$j<$nLength;$j++) 233cdf0e10cSrcweir# { 234cdf0e10cSrcweir# for ($i=0;$i<$j;$i++) 235cdf0e10cSrcweir# { 236cdf0e10cSrcweir# print "."; 237cdf0e10cSrcweir# } 238cdf0e10cSrcweir# for ($i=$j;$i<$nLength;$i++) 239cdf0e10cSrcweir# { 240cdf0e10cSrcweir# print " "; 241cdf0e10cSrcweir# } 242cdf0e10cSrcweir# _shortsleep( 1 ); 243cdf0e10cSrcweir# print "\r"; 244cdf0e10cSrcweir# } 245cdf0e10cSrcweir# 246cdf0e10cSrcweir# for ($j=0;$j<=$nLength;$j++) 247cdf0e10cSrcweir# { 248cdf0e10cSrcweir# for ($i=0;$i<$j;$i++) 249cdf0e10cSrcweir# { 250cdf0e10cSrcweir# print " "; 251cdf0e10cSrcweir# } 252cdf0e10cSrcweir# for ($i=$j;$i<$nLength;$i++) 253cdf0e10cSrcweir# { 254cdf0e10cSrcweir# print "."; 255cdf0e10cSrcweir# } 256cdf0e10cSrcweir# _shortsleep( 1 ); 257cdf0e10cSrcweir# print "\r"; 258cdf0e10cSrcweir# } 259cdf0e10cSrcweir# } 260cdf0e10cSrcweir# 261cdf0e10cSrcweir# sub wait30seconds() 262cdf0e10cSrcweir# { 263cdf0e10cSrcweir# _waitInSeconds(20); 264cdf0e10cSrcweir# _waitInSeconds(20); 265cdf0e10cSrcweir# } 266cdf0e10cSrcweir 267cdf0e10cSrcweirsub checkForStop($) 268cdf0e10cSrcweir{ 269cdf0e10cSrcweir my $sStopFilename = shift; 270cdf0e10cSrcweir my $sStopFilePath; 271cdf0e10cSrcweir if ($OSNAME eq "MSWin32") 272cdf0e10cSrcweir { 273cdf0e10cSrcweir $sStopFilePath = "C:/temp/"; 274cdf0e10cSrcweir } 275cdf0e10cSrcweir else 276cdf0e10cSrcweir { 277cdf0e10cSrcweir $sStopFilePath = "/tmp/"; 278cdf0e10cSrcweir } 279cdf0e10cSrcweir my $sStopFile = $sStopFilePath . $sStopFilename; 280cdf0e10cSrcweir if ( -e "$sStopFile" ) 281cdf0e10cSrcweir { 282cdf0e10cSrcweir print "Stop of Convwatch tool forced!\n"; 283cdf0e10cSrcweir unlink($sStopFile); 284cdf0e10cSrcweir exit(2); 285cdf0e10cSrcweir } 286cdf0e10cSrcweir} 287cdf0e10cSrcweir 288cdf0e10cSrcweir# ---------------------------------------------------------------------------------------- 289cdf0e10cSrcweirsub readdirectory($$$); 290cdf0e10cSrcweir 291cdf0e10cSrcweirsub readdirectory($$$) 292cdf0e10cSrcweir{ 293cdf0e10cSrcweir my $startdir = shift; 294cdf0e10cSrcweir my $sUserParameter = shift; 295cdf0e10cSrcweir my $hook = shift; 296cdf0e10cSrcweir 297cdf0e10cSrcweir my $myfile; 298cdf0e10cSrcweir 299cdf0e10cSrcweir local *DIR; 300cdf0e10cSrcweir chdir $startdir; 301cdf0e10cSrcweir cwd(); 302cdf0e10cSrcweir 303cdf0e10cSrcweir my $nCountFiles = 0; 304cdf0e10cSrcweir if (opendir (DIR, $startdir)) # Directory oeffnen 305cdf0e10cSrcweir { 306cdf0e10cSrcweir while ($myfile = readdir(DIR)) 307cdf0e10cSrcweir { # ein filename holen 308cdf0e10cSrcweir #if (! -l $myfile) # not a link 309cdf0e10cSrcweir #{ 310cdf0e10cSrcweir if (-d $myfile ) # is a directory 311cdf0e10cSrcweir { 312cdf0e10cSrcweir if ( -l $myfile) 313cdf0e10cSrcweir { 314cdf0e10cSrcweir next; 315cdf0e10cSrcweir } 316cdf0e10cSrcweir # if ( $myfile eq "help" || 317cdf0e10cSrcweir # $myfile eq "presets" || 318cdf0e10cSrcweir # $myfile eq "registry" || 319cdf0e10cSrcweir # $myfile eq "uno_packages" || 320cdf0e10cSrcweir # $myfile eq "lib" || 321cdf0e10cSrcweir # $myfile eq "user_tree" ) 322cdf0e10cSrcweir # { 323cdf0e10cSrcweir # next; 324cdf0e10cSrcweir # } 325cdf0e10cSrcweir 326cdf0e10cSrcweir if ($myfile ne "." && $myfile ne "..") 327cdf0e10cSrcweir { 328cdf0e10cSrcweir my $sNewStartDir = appendPath($startdir, $myfile); # neuen Directorystring erstellen 329cdf0e10cSrcweir # if ($sNewStartDir =~ "^\/proc" || 330cdf0e10cSrcweir # $sNewStartDir =~ "^\/dev" || 331cdf0e10cSrcweir # $sNewStartDir =~ "^\/udev" || 332cdf0e10cSrcweir # $sNewStartDir =~ "lost+found" ) 333cdf0e10cSrcweir # { 334cdf0e10cSrcweir # next; 335cdf0e10cSrcweir # } 336cdf0e10cSrcweir # my $sNewSUserParameter = $sUserParameter . $myfile ."/"; 337cdf0e10cSrcweir # do a recursive call 338cdf0e10cSrcweir # $nCountFiles++; 339cdf0e10cSrcweir my $nFileCount = readdirectory($sNewStartDir, $sUserParameter, $hook); 340cdf0e10cSrcweir # workOnDir($sNewDir, $nFileCount); 341cdf0e10cSrcweir $nCountFiles += $nFileCount; 342cdf0e10cSrcweir 343cdf0e10cSrcweir chdir ($startdir); # zurueckwechseln. 344cdf0e10cSrcweir cwd(); 345cdf0e10cSrcweir } 346cdf0e10cSrcweir } 347cdf0e10cSrcweir else 348cdf0e10cSrcweir { 349cdf0e10cSrcweir # File must exist, be a regular file and must not be the $onlyOnFile 350cdf0e10cSrcweir if (-f $myfile) 351cdf0e10cSrcweir { 352cdf0e10cSrcweir # print STDERR " $startdir" . "$myfile\n"; 353cdf0e10cSrcweir $nCountFiles++; 354cdf0e10cSrcweir # workOnFile($startdir, $myfile, $destdir); 355cdf0e10cSrcweir $hook->($startdir, $myfile, $sUserParameter); 356cdf0e10cSrcweir } 357cdf0e10cSrcweir } 358cdf0e10cSrcweir #} 359cdf0e10cSrcweir #else 360cdf0e10cSrcweir #{ 361cdf0e10cSrcweir # print STDERR "linked file: $dir/$myfile\n"; 362cdf0e10cSrcweir #} 363cdf0e10cSrcweir } 364cdf0e10cSrcweir closedir(DIR); 365cdf0e10cSrcweir } 366cdf0e10cSrcweir else 367cdf0e10cSrcweir { 368cdf0e10cSrcweir print STDERR "could not open $startdir\n"; 369cdf0e10cSrcweir } 370cdf0e10cSrcweir return $nCountFiles; 371cdf0e10cSrcweir} 372cdf0e10cSrcweir 373cdf0e10cSrcweirour $lcl_sSofficeBinPath; 374cdf0e10cSrcweirour $lcl_sSofficeBinName; 375cdf0e10cSrcweir 376cdf0e10cSrcweirsub searchSofficeBin($$$) 377cdf0e10cSrcweir{ 378cdf0e10cSrcweir my $currentDir = shift; 379cdf0e10cSrcweir my $currentFile = shift; 380cdf0e10cSrcweir my $sUserParameter = shift; 381cdf0e10cSrcweir 382cdf0e10cSrcweir if ($currentFile eq $sUserParameter) 383cdf0e10cSrcweir { 384cdf0e10cSrcweir my $sSourceFilename; 385cdf0e10cSrcweir $sSourceFilename = appendPath($currentDir, $currentFile); 386cdf0e10cSrcweir 387cdf0e10cSrcweir if ( -e "$sSourceFilename" ) 388cdf0e10cSrcweir { 389cdf0e10cSrcweir $lcl_sSofficeBinPath = $currentDir; 390cdf0e10cSrcweir $lcl_sSofficeBinName = $currentFile; 391cdf0e10cSrcweir } 392cdf0e10cSrcweir } 393cdf0e10cSrcweir} 394cdf0e10cSrcweir 395cdf0e10cSrcweir# our $lcl_sUnoPkgPath; 396cdf0e10cSrcweir# 397cdf0e10cSrcweir# sub searchUnoPkgBin($$$) 398cdf0e10cSrcweir# { 399cdf0e10cSrcweir# my $currentDir = shift; 400cdf0e10cSrcweir# my $currentFile = shift; 401cdf0e10cSrcweir# my $sUserParameter = shift; 402cdf0e10cSrcweir# 403cdf0e10cSrcweir# if ($currentFile eq $sUserParameter) 404cdf0e10cSrcweir# { 405cdf0e10cSrcweir# my $sSourceFilename; 406cdf0e10cSrcweir# $sSourceFilename = appendPath($currentDir, $currentFile); 407cdf0e10cSrcweir# if ( -e "$sSourceFilename" ) 408cdf0e10cSrcweir# { 409cdf0e10cSrcweir# $lcl_sUnoPkgPath = $currentDir; 410cdf0e10cSrcweir# } 411cdf0e10cSrcweir# } 412cdf0e10cSrcweir# } 413cdf0e10cSrcweir 414cdf0e10cSrcweir# our $lcl_sJARPath; 415cdf0e10cSrcweir 416cdf0e10cSrcweir# sub searchJARFile($$$) 417cdf0e10cSrcweir# { 418cdf0e10cSrcweir# my $currentDir = shift; 419cdf0e10cSrcweir# my $currentFile = shift; 420cdf0e10cSrcweir# my $sUserParameter = shift; 421cdf0e10cSrcweir# 422cdf0e10cSrcweir# if ($currentFile eq $sUserParameter) 423cdf0e10cSrcweir# { 424cdf0e10cSrcweir# my $sSourceFilename; 425cdf0e10cSrcweir# $sSourceFilename = appendPath($currentDir, $currentFile); 426cdf0e10cSrcweir# if ( -e "$sSourceFilename" ) 427cdf0e10cSrcweir# { 428cdf0e10cSrcweir# $lcl_sJARPath = $currentDir; 429cdf0e10cSrcweir# } 430cdf0e10cSrcweir# } 431cdf0e10cSrcweir# } 432cdf0e10cSrcweir 433cdf0e10cSrcweir# return the PATH, where the file was found 434cdf0e10cSrcweir# sub searchForJAR($$) 435cdf0e10cSrcweir# { 436cdf0e10cSrcweir# my $sPathToInstallOffice = shift; 437cdf0e10cSrcweir# my $sJARFileName = shift; 438cdf0e10cSrcweir# 439cdf0e10cSrcweir# my $sCurrentPath = cwd(); 440cdf0e10cSrcweir# 441cdf0e10cSrcweir# $lcl_sJARPath = ""; 442cdf0e10cSrcweir# readdirectory(${sPathToInstallOffice}, ${sJARFileName}, \&searchJARFile); 443cdf0e10cSrcweir# 444cdf0e10cSrcweir# chdir $sCurrentPath; 445cdf0e10cSrcweir# cwd(); 446cdf0e10cSrcweir# 447cdf0e10cSrcweir# return $lcl_sJARPath; 448cdf0e10cSrcweir# } 449cdf0e10cSrcweir 450cdf0e10cSrcweir# sub getUnoPkg($) 451cdf0e10cSrcweir# { 452cdf0e10cSrcweir# my $sPathToInstallOffice = shift; 453cdf0e10cSrcweir# 454cdf0e10cSrcweir# my $sUnoPkgName = "unopkg.bin"; 455cdf0e10cSrcweir# if (isWindowsEnvironment()) 456cdf0e10cSrcweir# { 457cdf0e10cSrcweir# $sUnoPkgName = "unopkg.exe"; 458cdf0e10cSrcweir# } 459cdf0e10cSrcweir# 460cdf0e10cSrcweir# my $sCurrentPath = cwd(); 461cdf0e10cSrcweir# 462cdf0e10cSrcweir# $lcl_sUnoPkgPath = ""; 463cdf0e10cSrcweir# readdirectory(${sPathToInstallOffice}, ${sUnoPkgName}, \&searchUnoPkgBin); 464cdf0e10cSrcweir# 465cdf0e10cSrcweir# chdir $sCurrentPath; 466cdf0e10cSrcweir# cwd(); 467cdf0e10cSrcweir# 468cdf0e10cSrcweir# return ($lcl_sUnoPkgPath, $sUnoPkgName); 469cdf0e10cSrcweir# } 470cdf0e10cSrcweir 471cdf0e10cSrcweirsub getSofficeExe($) 472cdf0e10cSrcweir{ 473cdf0e10cSrcweir my $sPathToOffice = shift; 474cdf0e10cSrcweir 475cdf0e10cSrcweir my $sSofficeExeName = "soffice"; 476cdf0e10cSrcweir if (isWindowsEnvironment()) 477cdf0e10cSrcweir { 478cdf0e10cSrcweir $sSofficeExeName = "soffice.exe"; 479cdf0e10cSrcweir } 480cdf0e10cSrcweir 481cdf0e10cSrcweir my $sCurrentPath = cwd(); 482cdf0e10cSrcweir 483cdf0e10cSrcweir $lcl_sSofficeBinPath = ""; 484cdf0e10cSrcweir $lcl_sSofficeBinName = ""; 485cdf0e10cSrcweir readdirectory(${sPathToOffice}, ${sSofficeExeName}, \&searchSofficeBin); 486cdf0e10cSrcweir 487cdf0e10cSrcweir chdir $sCurrentPath; 488cdf0e10cSrcweir cwd(); 489cdf0e10cSrcweir 490cdf0e10cSrcweir return ($lcl_sSofficeBinPath, $lcl_sSofficeBinName); 491cdf0e10cSrcweir} 492cdf0e10cSrcweir 493cdf0e10cSrcweir# sub checkOfficeAlreadyInstalled($) 494cdf0e10cSrcweir# { 495cdf0e10cSrcweir# my $sOfficePath = shift; 496cdf0e10cSrcweir# 497cdf0e10cSrcweir# my $sCurrentPath = cwd(); 498cdf0e10cSrcweir# 499cdf0e10cSrcweir# $lcl_sSofficeBinPath = ""; 500cdf0e10cSrcweir# my $sOldOfficePath = appendPath($sOfficePath, "program"); 501cdf0e10cSrcweir# if ( -d "$sOldOfficePath" ) 502cdf0e10cSrcweir# { 503cdf0e10cSrcweir# $sOldOfficePath = appendPath($sOldOfficePath, "soffice.bin"); 504cdf0e10cSrcweir# if ( -e $sOldOfficePath ) 505cdf0e10cSrcweir# { 506cdf0e10cSrcweir# return 1; 507cdf0e10cSrcweir# } 508cdf0e10cSrcweir# } 509cdf0e10cSrcweir# else 510cdf0e10cSrcweir# { 511cdf0e10cSrcweir# if (isWindowsEnvironment()) 512cdf0e10cSrcweir# { 513cdf0e10cSrcweir# my $sThreeLayerOffice = appendPath($sOfficePath, "Sun"); 514cdf0e10cSrcweir# $sThreeLayerOffice = appendPath($sThreeLayerOffice, "StarOffice 9"); 515cdf0e10cSrcweir# $sThreeLayerOffice = appendPath($sThreeLayerOffice, "program"); 516cdf0e10cSrcweir# $sThreeLayerOffice = appendPath($sThreeLayerOffice, "soffice.bin"); 517cdf0e10cSrcweir# 518cdf0e10cSrcweir# if ( -e "$sThreeLayerOffice" ) 519cdf0e10cSrcweir# { 520cdf0e10cSrcweir# return 1; 521cdf0e10cSrcweir# } 522cdf0e10cSrcweir# } 523cdf0e10cSrcweir# else 524cdf0e10cSrcweir# { 525cdf0e10cSrcweir# my $sThreeLayerOffice = appendPath($sOfficePath, "staroffice9"); 526cdf0e10cSrcweir# $sThreeLayerOffice = appendPath($sThreeLayerOffice, "program"); 527cdf0e10cSrcweir# $sThreeLayerOffice = appendPath($sThreeLayerOffice, "soffice.bin"); 528cdf0e10cSrcweir# if ( -e "$sThreeLayerOffice" ) 529cdf0e10cSrcweir# { 530cdf0e10cSrcweir# return 1; 531cdf0e10cSrcweir# } 532cdf0e10cSrcweir# } 533cdf0e10cSrcweir# } 534cdf0e10cSrcweir# 535cdf0e10cSrcweir# # soffice.bin not found in fast path 536cdf0e10cSrcweir# readdirectory($sOfficePath, "soffice.bin", \&searchSofficeBin); 537cdf0e10cSrcweir# chdir $sCurrentPath; 538cdf0e10cSrcweir# cwd(); 539cdf0e10cSrcweir# 540cdf0e10cSrcweir# if ( $lcl_sSofficeBinPath ne "" ) 541cdf0e10cSrcweir# { 542cdf0e10cSrcweir# return 1; 543cdf0e10cSrcweir# } 544cdf0e10cSrcweir# return 0; 545cdf0e10cSrcweir# # this is the old check 546cdf0e10cSrcweir# # my $sOfficePathCheck = appendPath(${sPathToInstallOffice}, "program"); 547cdf0e10cSrcweir# # $sOfficePathCheck = appendPath($sOfficePathCheck, "soffice.bin"); 548cdf0e10cSrcweir# # if ( -e $sOfficePathCheck ) 549cdf0e10cSrcweir# # { 550cdf0e10cSrcweir# # return 1; 551cdf0e10cSrcweir# # } 552cdf0e10cSrcweir# # 553cdf0e10cSrcweir# # # check path system of tree layer office 554cdf0e10cSrcweir# # if ( isWindowsEnvironment() ) 555cdf0e10cSrcweir# # { 556cdf0e10cSrcweir# # $sOfficePathCheck = appendPath(${sPathToInstallOffice}, "Sun"); 557cdf0e10cSrcweir# # if ( ! -e $sOfficePathCheck) 558cdf0e10cSrcweir# # { 559cdf0e10cSrcweir# # # could be an OpenOffice.org 560cdf0e10cSrcweir# # return 0; 561cdf0e10cSrcweir# # } 562cdf0e10cSrcweir# # else 563cdf0e10cSrcweir# # { 564cdf0e10cSrcweir# # 565cdf0e10cSrcweir# # $sOfficePathCheck = appendPath($sOfficePathCheck, "StarOffice 9"); 566cdf0e10cSrcweir# # $sOfficePathCheck = appendPath($sOfficePathCheck, "program"); 567cdf0e10cSrcweir# # $sOfficePathCheck = appendPath($sOfficePathCheck, "soffice.bin"); 568cdf0e10cSrcweir# # if ( -e $sOfficePathCheck ) 569cdf0e10cSrcweir# # { 570cdf0e10cSrcweir# # return 1; 571cdf0e10cSrcweir# # } 572cdf0e10cSrcweir# # print "Error: There exist no Office, maybe an unsupported version?\n"; 573cdf0e10cSrcweir# # } 574cdf0e10cSrcweir# # } 575cdf0e10cSrcweir# # elsif ( isUnixEnvironment() ) 576cdf0e10cSrcweir# # { 577cdf0e10cSrcweir# # $sOfficePathCheck = appendPath(${sPathToInstallOffice}, "staroffice9"); 578cdf0e10cSrcweir# # $sOfficePathCheck = appendPath($sOfficePathCheck, "staroffice9"); 579cdf0e10cSrcweir# # $sOfficePathCheck = appendPath($sOfficePathCheck, "program"); 580cdf0e10cSrcweir# # $sOfficePathCheck = appendPath($sOfficePathCheck, "soffice.bin"); 581cdf0e10cSrcweir# # if ( -e $sOfficePathCheck ) 582cdf0e10cSrcweir# # { 583cdf0e10cSrcweir# # return 1; 584cdf0e10cSrcweir# # } 585cdf0e10cSrcweir# # print "Error: There exist no Office, maybe an unsupported version?\n"; 586cdf0e10cSrcweir# # } 587cdf0e10cSrcweir# # else 588cdf0e10cSrcweir# # { 589cdf0e10cSrcweir# # print "Error: There exist no Office, maybe an unsupported version?\n"; 590cdf0e10cSrcweir# # } 591cdf0e10cSrcweir# # return 0; 592cdf0e10cSrcweir# } 593cdf0e10cSrcweir 594cdf0e10cSrcweir1; 595