1 eval 'exec perl -wS $0 ${1+\"$@\"}'
4 #*************************************************************************
6 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 # Copyright 2000, 2010 Oracle and/or its affiliates.
10 # OpenOffice.org - a multi-platform office productivity suite
12 # This file is part of OpenOffice.org.
14 # OpenOffice.org is free software: you can redistribute it and/or modify
15 # it under the terms of the GNU Lesser General Public License version 3
16 # only, as published by the Free Software Foundation.
18 # OpenOffice.org is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU Lesser General Public License version 3 for more details
22 # (a copy is included in the LICENSE file that accompanied this code).
24 # You should have received a copy of the GNU Lesser General Public License
25 # version 3 along with OpenOffice.org. If not, see
26 # <http://www.openoffice.org/license.html>
27 # for a copy of the LGPLv3 License.
29 #*************************************************************************
33 # Adding the path of this script file to the include path in the hope
34 # that all used modules can be found in it.
37 # print "PATH: " . $1 . "\n";
41 # foreach $e (keys %ENV)
43 # print "$e := $ENV{$e}" . "\n";
47 use graphical_compare
;
56 use English
; # $OSNAME, ...
60 our $help; # Help option flag
61 our $version; # Version option flag
74 our $connectionstring;
82 # my $old_handle = select (STDOUT); # "select" STDOUT and save # previously selected handle
83 # $| = 1; # perform flush after each write to STDOUT
84 # select ($old_handle); # restore previously selected handle
86 $OUTPUT_AUTOFLUSH=1; # works only if use English is used.
88 our $version_info = 'compare.pl';
91 # "MAJOR=s" => \$MAJOR,
92 # "MINOR=s" => \$MINOR,
93 # "cwsname=s" => \$cwsname,
95 "document=s" => \
$document,
96 "creatortype=s" => \
$creatortype,
97 "prepareonly=s" => \
$prepareonly,
98 "connectionstring=s" => \
$connectionstring,
101 "verbose" => \
$verbose,
106 "version" => \
$version
111 print_usage
(*STDOUT
);
114 # Check for version option
117 print STDERR
"$version_info\n";
127 if ($connectionstring)
129 setConnectionString
($connectionstring);
132 my $sDocumentPool = appendPath
(getProjectRoot
(), "document-pool");
133 # print "ProjectRoot: " . getProjectRoot() . "\n";
134 if ($ENV{DOCUMENTPOOL
})
136 if ( -d
$ENV{DOCUMENTPOOL
})
138 print "overwrite default Documentpool: '$sDocumentPool'\n";
139 print " with \$ENV{DOCUMENTPOOL}: $ENV{DOCUMENTPOOL}\n";
140 $sDocumentPool = $ENV{DOCUMENTPOOL
};
144 print "Given \$DOCUMENTPOOL doesn't exist.\n";
149 my $nCompareTime = getTime
();
151 # if we want to check one file, give -pool and -document
152 # if we want to check the whole pool, give -pool
153 # if we want to check all, call without parameters
158 $err = SingleDocumentCompare
( $sDocumentPool,
168 $err = CompareFiles
($sDocumentPool, $pool);
174 if (opendir (DIR
, $sDocumentPool)) # Directory oeffnen
177 while ($myfile = readdir(DIR
))
178 { # ein filename holen
179 if ($myfile eq "." ||
184 my $sDocumentPath = appendPath
($sDocumentPool, $myfile);
185 if ( -d
$sDocumentPath )
187 $err += CompareFiles
($sDocumentPool, $myfile);
189 elsif ( -f
$sDocumentPath )
191 print "Warning: the file '$myfile' will not compared.\n";
196 # my $sPool = "eis-chart";
197 # $err += CompareFiles($sDocumentPool, "eis-chart");
198 # $err += CompareFiles($sDocumentPool, "eis-impress");
199 # $err += CompareFiles($sDocumentPool, "eis-writer");
200 # $err += CompareFiles($sDocumentPool, "eis-calc");
204 printTime
(endTime
($nCompareTime));
207 # ------------------------------------------------------------------------------
211 my $sDocumentPath = shift;
214 my $startdir = appendPath
($sDocumentPath, $sPool);
217 if (opendir (DIR
, $startdir)) # Directory oeffnen
220 while ($myfile = readdir(DIR
))
221 { # ein filename holen
222 if ($myfile eq "knownissues.xcl")
226 my $sAbsoluteFile = appendPath
($startdir, $myfile);
227 if (-f
$sAbsoluteFile)
231 ($nIssue, $sIssueText) = checkForKnownIssue
($startdir, $myfile);
234 $err = SingleDocumentCompare
(
235 # "/net/so-gfxcmp-documents.germany.sun.com/export/gfxcmp/document-pool", # $documentpoolpath,
237 $sPool, # $documentpool,
238 $myfile, # $documentname);
239 $creatortype, # $destinationcreatortype,
243 $aFailedHash{$myfile} = $err;
247 print "$myfile [KNOWN ISSUE: #$sIssueText#]\n";
254 print "***** State for graphical compare of pool: '$sPool' ******\n";
257 foreach $file (keys %aFailedHash)
259 if ($aFailedHash{$file} != 0)
261 print "Failed: $file\n";
265 print "Whole unit: ";
266 if ($nErrorCount > 0)
268 print "PASSED.FAILED\n";
274 print "************************************************************\n";
277 # ------------------------------------------------------------------------------
278 # return issue number if file exists in knownissues.xcl file
279 sub checkForKnownIssue
($$)
281 my $startdir = shift;
289 my $sKnownIssueFile = appendPath
($startdir, "knownissues.xcl");
290 my $sIssueText = "unknown";
295 if (open(ISSUES
, $sKnownIssueFile))
298 while ($line = <ISSUES
>)
301 if ($line =~ /\[(.*)\]/ )
303 $sCurrentSection = $1;
306 if ($sCurrentSection eq $creatortype)
308 if ($line =~ /\#\#\# (.*) \#\#\#/ )
312 if ($line =~ /^${myfile}$/ )
321 return $nIssue, $sIssueText;
323 # ------------------------------------------------------------------------------
326 # directory structure:
327 # documents will be found in
328 # ../document-pool/eis-tests
330 # references will be found in
331 # ../references/unxlngi/eis-tests
332 # ../references/wntmsci/eis-tests
335 # ../unxlngi6.pro/misc
345 if ($OSNAME eq "linux")
348 setINPATH
("unxlngi6.pro");
353 setINPATH
($ENV{INPATH
});
362 print "Current Directory: $cwd\n" if ($verbose);
366 # print "cwd:=$cwd\n";
367 # print "PRJ:=$ENV{PRJ}\n";
368 $sProjectBase = appendPath
($cwd, $ENV{PRJ
});
372 $sProjectBase = dirname
($cwd);
374 if ($OSNAME eq "cygwin")
376 $sProjectBase = `cygpath -w $sProjectBase`;
377 chomp($sProjectBase);
378 $sProjectBase = unixpath
($sProjectBase);
379 # print "cygwin patch \$sProjectBase := $sProjectBase\n";
381 # print "Project base path: $sProjectBase\n";
382 setProjectRoot
($sProjectBase);
388 # ------------------------------------------------------------------------------
391 local *HANDLE
= $_[0];
392 my $tool_name = basename
($0);
394 print(HANDLE
<<END_OF_USAGE);
396 Usage: $tool_name [OPTIONS]
398 -pool Give pool name out of document-pool directory.
399 But all documents list in knownissues.xcl will not check.
400 -document Give a single document to test, the known issue list will ignored.
401 -creatortype=s s:ps create postscript files via print to file.
402 s:pdf create PDF file via export to pdf.
403 -h, --help Print this help, then exit
404 -v, --version Print version number, then exit