{
// TODO: some more checks
if (! FileHelper.exists(_sAbsoluteInputFile))
{
throw new ConvWatchCancelException("createPostscriptStartCheck: Input file: " + _sAbsoluteInputFile + " does not exist.");
}
if (_sAbsoluteReferenceFile == null)
{
// we assume, that the prn file is near the document
String sAbsoluteInputFileNoSuffix = FileHelper.getNameNoSuffix(_sAbsoluteInputFile);
_sAbsoluteReferenceFile = sAbsoluteInputFileNoSuffix + ".prn";
}
String fs = System.getProperty("file.separator");
File aAbsoluteReferenceFile = new File(_sAbsoluteReferenceFile);
if (aAbsoluteReferenceFile.isDirectory())
{
String sBasename = FileHelper.getBasename(_sAbsoluteInputFile);
String sNameNoSuffix = FileHelper.getNameNoSuffix(sBasename);
String sAbsoluteReferenceFileInfo = _sAbsoluteReferenceFile + fs + sNameNoSuffix + ".info";
_sAbsoluteReferenceFile = _sAbsoluteReferenceFile + fs + sNameNoSuffix + ".prn";
// Read the reference from the info file
String sRefBuildID = "";
if (FileHelper.exists(sAbsoluteReferenceFileInfo))
{
sRefBuildID = getBuildID_FromFile(sAbsoluteReferenceFileInfo);
}
_aGTA.setRefBuildID(sRefBuildID);
}
else
{
// java file has problems to check for directories, if the given directory doesn't exist.
String sName = FileHelper.getBasename(_sAbsoluteReferenceFile);
// thanks to Mircosoft, every document has a suffix, so if a name doesn't have a suffix, it must be a directory name
int nIdx = sName.indexOf('.');
if (nIdx == -1)
{
// must be a directory
throw new ConvWatchCancelException("createPostscriptStartCheck: Given reference directory: '" + _sAbsoluteReferenceFile + "' does not exist.");
}
}
boolean bAbsoluteReferenceFile = true;
if (! FileHelper.exists(_sAbsoluteReferenceFile))
{
if (_aGTA.createDefaultReference())
{
GlobalLogWriter.get().println("Reference File doesn't exist, will create a default");
bAbsoluteReferenceFile = false;
}
else
{
throw new ConvWatchCancelException("createPostscriptStartCheck: Given reference file: " + _sAbsoluteReferenceFile + " does not exist.");
}
}
FileHelper.makeDirectories("", _sOutputPath);
// runner.convwatch.compare();
String sAbsoluteInputFileURL = URLHelper.getFileURLFromSystemPath(_sAbsoluteInputFile);
String sInputFile = FileHelper.getBasename(_sAbsoluteInputFile);
// System.out.println("InputFile: " + sInputFile);
String sInputFileNoSuffix = FileHelper.getNameNoSuffix(sInputFile);
// System.out.println("BasenameNoSuffix: " + sInputFileNoSuffix);
String sAbsoluteOutputFile = _sOutputPath + fs + sInputFile;
String sAbsoluteOutputFileURL = URLHelper.getFileURLFromSystemPath(sAbsoluteOutputFile);
String sReferenceFile = FileHelper.getBasename(_sAbsoluteReferenceFile);
String sReferenceFileNoSuffix = FileHelper.getNameNoSuffix(sReferenceFile);
String sPostScriptFile = sReferenceFileNoSuffix + ".ps";
// System.out.println("PostscriptFile: " + sPostScriptFile);
String sAbsolutePrintFile = _sOutputPath + fs + sPostScriptFile;
String sAbsolutePrintFileURL = URLHelper.getFileURLFromSystemPath(sAbsolutePrintFile);
// System.out.println("AbsoluteInputFileURL: " + sAbsoluteInputFileURL);
// System.out.println("AbsoluteOutputFileURL: " + sAbsoluteOutputFileURL);
// System.out.println("AbsolutePrintFileURL: " + sAbsolutePrintFileURL);
// store and print the sAbsoluteInputFileURL file with StarOffice / OpenOffice.org
OfficePrint.printToFile(_aGTA, sAbsoluteInputFileURL, sAbsoluteOutputFileURL, sAbsolutePrintFileURL);
// wait(2);
if (! FileHelper.exists(sAbsolutePrintFile))
{
throw new ConvWatchCancelException("createPostscriptStartCheck: Printed file " + sAbsolutePrintFile + " does not exist.");
}
if (bAbsoluteReferenceFile == false)
{
// copy AbsolutePrintFile to AbsoluteReferenceFile
String sDestinationFile = sAbsolutePrintFile; // URLHelper.getSystemPathFromFileURL(...)
String sSourceFile = _sAbsoluteReferenceFile;
FileHelper.copy(sDestinationFile, sSourceFile);
// now the fix reference of the AbsoluteReferenceFile should exist.
if (! FileHelper.exists(_sAbsoluteReferenceFile))
{
throw new ConvWatchCancelException("createPostscriptStartCheck: Given reference file: " + _sAbsoluteReferenceFile + " does not exist, after try to copy.");
}
}
PRNCompare a = new PRNCompare();
String sInputPath = FileHelper.getPath(_sAbsoluteInputFile);