summaryrefslogtreecommitdiff
path: root/qadevOOo/runner/convwatch/OfficePrint.java
diff options
context:
space:
mode:
Diffstat (limited to 'qadevOOo/runner/convwatch/OfficePrint.java')
-rw-r--r--qadevOOo/runner/convwatch/OfficePrint.java184
1 files changed, 92 insertions, 92 deletions
diff --git a/qadevOOo/runner/convwatch/OfficePrint.java b/qadevOOo/runner/convwatch/OfficePrint.java
index c9a656ac84b4..3feebdfa5336 100644
--- a/qadevOOo/runner/convwatch/OfficePrint.java
+++ b/qadevOOo/runner/convwatch/OfficePrint.java
@@ -1,7 +1,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -66,7 +66,7 @@ public class OfficePrint {
// static long m_nStartTime;
// // static Date m_aDateCache = null;
-//
+//
// /*
// simple helper functions to start/stop a timer, to know how long a process need in milliseconds
// */
@@ -85,7 +85,7 @@ public class OfficePrint {
// // {
// // System.out.println("Forgotten to initialise start timer.");
// // return 0;
-// // }
+// // }
// // long m_nStopTime = m_aDateCache.getTime();
// if (m_nStartTime == 0)
// {
@@ -95,8 +95,8 @@ public class OfficePrint {
// long m_nStopTime = System.currentTimeMillis();
// return m_nStopTime - m_nStartTime;
// }
-
-
+
+
private static void showProperty(PropertyValue _aValue)
{
String sName = _aValue.Name;
@@ -112,8 +112,8 @@ public class OfficePrint {
GlobalLogWriter.get().println("Property " + sName + ":= a Object which can't convert by AnyConverter()");
}
}
-
- /**
+
+ /**
* shows the FilterName and MediaType from the given XComponent
*/
static String getDocumentType( XComponent _aDoc )
@@ -153,7 +153,7 @@ public class OfficePrint {
String _sInputURL)
{
XComponent aDoc = null;
- try
+ try
{
if (_aGTA.getMultiServiceFactory() == null)
{
@@ -162,7 +162,7 @@ public class OfficePrint {
}
Object oDsk = _aGTA.getMultiServiceFactory().createInstance("com.sun.star.frame.Desktop");
XDesktop aDesktop = UnoRuntime.queryInterface(XDesktop.class, oDsk);
-
+
if (aDesktop != null)
{
GlobalLogWriter.get().println("com.sun.star.frame.Desktop created.");
@@ -170,7 +170,7 @@ public class OfficePrint {
// String sOutputURL = aCurrentParameter.sOutputURL;
// String sPrintFileURL = aCurrentParameter.sPrintToFileURL;
// System.out.println(_sInputURL);
-
+
// set here the loadComponentFromURL() properties
// at the moment only 'Hidden' is set, so no window is opened at work
@@ -211,9 +211,9 @@ public class OfficePrint {
GlobalLogWriter.get().println(DateHelper.getDateTimeForHumanreadableLog() + " Load document");
// GlobalLogWriter.get().flush();
-
+
XComponentLoader aCompLoader = UnoRuntime.queryInterface( XComponentLoader.class, aDesktop);
-
+
// XComponent aDoc = null;
_aGTA.getPerformance().startTime(PerformanceContainer.Load);
@@ -250,14 +250,14 @@ public class OfficePrint {
}
return aDoc;
}
-
+
static boolean exportToPDF(XComponent _xComponent, String _sDestinationName)
{
XServiceInfo xServiceInfo =
UnoRuntime.queryInterface(
XServiceInfo.class, _xComponent
);
-
+
ArrayList<PropertyValue> aPropertyList = new ArrayList<PropertyValue>();
PropertyValue aFiltername = new PropertyValue();
aFiltername.Name = "FilterName";
@@ -265,7 +265,7 @@ public class OfficePrint {
aPropertyList.add(aFiltername);
showProperty(aFiltername);
boolean bWorked = true;
-
+
try
{
XStorable store =
@@ -280,14 +280,14 @@ public class OfficePrint {
GlobalLogWriter.get().println("Message: " + e.getMessage());
bWorked = false;
}
-
+
return bWorked;
}
-
+
static String getFilterName_forPDF(XServiceInfo xServiceInfo)
{
String filterName = "";
-
+
if (xServiceInfo.supportsService("com.sun.star.text.TextDocument"))
{
//writer
@@ -323,9 +323,9 @@ public class OfficePrint {
//math document
filterName = "math_pdf_Export";
}
-
+
return filterName;
- }
+ }
// -----------------------------------------------------------------------------
@@ -335,7 +335,7 @@ public class OfficePrint {
{
boolean bBack = false;
XComponent aDoc = loadFromURL(_aGTA, _sInputURL);
-
+
if (aDoc == null)
{
GlobalLogWriter.get().println("Can't load document.");
@@ -348,7 +348,7 @@ public class OfficePrint {
aDoc.dispose();
return bBack;
}
-
+
public static boolean storeAsPDF(GraphicalTestArguments _aGTA,
XComponent _aDoc,
String _sOutputURL)
@@ -366,7 +366,7 @@ public class OfficePrint {
}
return bBack;
}
-
+
// -----------------------------------------------------------------------------
/**
@@ -390,7 +390,7 @@ public class OfficePrint {
{
// waitInSeconds(1);
boolean bBack = false;
-
+
XComponent aDoc = loadFromURL(_aGTA, _sInputURL);
if (aDoc != null)
{
@@ -402,7 +402,7 @@ public class OfficePrint {
_aGTA.disallowStore();
}
bBack = impl_printToFileWithOOo(_aGTA, aDoc, _sOutputURL, _sPrintFileURL);
-
+
GlobalLogWriter.get().println("Close document.");
aDoc.dispose();
}
@@ -418,7 +418,7 @@ public class OfficePrint {
{
createInfoFile(_sFile, _aGTA, "");
}
-
+
public static void createInfoFile(String _sFile, GraphicalTestArguments _aGTA, String _sSpecial)
{
String sFilename;
@@ -478,7 +478,7 @@ public class OfficePrint {
// out.write("# time is given in milli seconds" + ls);
// out.write("time=" + nTime + ls);
// }
-
+
out.write(ls);
out.write("# Values out of System.getProperty(...)" + ls);
out.write("os.name=" + System.getProperty("os.name") + ls);
@@ -491,7 +491,7 @@ public class OfficePrint {
out.write("# Performance output, values are given in milli sec." + ls);
_aGTA.getPerformance().print(out);
}
-
+
out.flush();
out.close();
}
@@ -500,13 +500,13 @@ public class OfficePrint {
GlobalLogWriter.get().println("can't create Info file.");
e.printStackTrace();
}
-
+
String sExtension = FileHelper.getSuffix(_aGTA.getInputFile());
if (sExtension.startsWith("."))
{
sExtension = sExtension.substring(1);
}
-
+
DB.writeToDB(_aGTA.getInputFile(),
sNameNoSuffix,
sExtension,
@@ -515,8 +515,8 @@ public class OfficePrint {
_aGTA.getResolutionInDPI()
);
}
-
-
+
+
// -----------------------------------------------------------------------------
private static boolean impl_printToFileWithOOo(GraphicalTestArguments _aGTA,
@@ -531,8 +531,8 @@ public class OfficePrint {
GlobalLogWriter.get().println("No document is given.");
return bBack;
}
-
- try
+
+ try
{
if (_sOutputURL != null)
{
@@ -543,7 +543,7 @@ public class OfficePrint {
if (aStorable != null)
{
PropertyValue [] szEmptyArgs = new PropertyValue [0];
-
+
GlobalLogWriter.get().println(DateHelper.getDateTimeForHumanreadableLog() + " Store document.");
_aGTA.getPerformance().startTime(PerformanceContainer.Store);
aStorable.storeAsURL(_sOutputURL, szEmptyArgs);
@@ -571,12 +571,12 @@ public class OfficePrint {
bBack = false;
}
- try
+ try
{
-
+
// System.out.println("Document loaded.");
// Change Pagesettings to DIN A4
-
+
GlobalLogWriter.get().println(DateHelper.getDateTimeForHumanreadableLog() + " Print document.");
XPrintable aPrintable = UnoRuntime.queryInterface( XPrintable.class, _aDoc);
if (aPrintable != null)
@@ -594,9 +594,9 @@ public class OfficePrint {
// aPrinterProps[nPropIndex].Value = com.sun.star.view.PaperFormat.A4;
// aPrintable.setPrinter(aPrinterProps);
// }
-
+
// configure Office to allow to execute macos
-
+
// TODO: We need a possiblity to set the printer name also for StarOffice/OpenOffice
if (OSHelper.isWindows())
{
@@ -613,7 +613,7 @@ public class OfficePrint {
aPrintable.setPrinter(PropertyHelper.createPropertyValueArrayFormArrayList(aPropertyList));
}
}
-
+
// set property values for XPrintable.print()
// more can be found at "http://api.openoffice.org/docs/common/ref/com/sun/star/view/PrintOptions.html"
@@ -624,7 +624,7 @@ public class OfficePrint {
// nProperties ++;
// }
// int nPropsCount = 0;
-
+
// If we are a SpreadSheet (calc), we need to set PrintAllSheets property to 'true'
XServiceInfo xServiceInfo = UnoRuntime.queryInterface( XServiceInfo.class, _aDoc );
if ( xServiceInfo.supportsService( "com.sun.star.sheet.SpreadsheetDocument" ) )
@@ -638,7 +638,7 @@ public class OfficePrint {
GlobalLogWriter.get().println("PrintAllSheets := true");
}
}
-
+
ArrayList<PropertyValue> aPrintProps = new ArrayList<PropertyValue>();
// GlobalLogWriter.get().println("Property FileName:=" + _sPrintFileURL);
@@ -665,20 +665,20 @@ public class OfficePrint {
}
sPages += String.valueOf(_aGTA.getOnlyPages());
}
-
+
Arg = new PropertyValue();
Arg.Name = "Pages";
Arg.Value = sPages;
aPrintProps.add(Arg);
showProperty(Arg);
}
-
+
// GlobalLogWriter.get().println("Start printing.");
_aGTA.getPerformance().startTime(PerformanceContainer.Print);
aPrintable.print(PropertyHelper.createPropertyValueArrayFormArrayList(aPrintProps));
TimeHelper.waitInSeconds(1, "Start waiting for print ready.");
-
+
GlobalLogWriter.get().println("Wait until document is printed.");
boolean isBusy = true;
int nPrintCount = 0;
@@ -703,7 +703,7 @@ public class OfficePrint {
}
_aGTA.getPerformance().stopTime(PerformanceContainer.Print);
GlobalLogWriter.get().println(DateHelper.getDateTimeForHumanreadableLog() + " Print document done.");
-
+
// Create a .info file near the printed '.ps' or '.prn' file.
createInfoFile(_sPrintFileURL, _aGTA);
}
@@ -723,7 +723,7 @@ public class OfficePrint {
e.printStackTrace();
bBack = false;
}
-
+
if (bFailed == true)
{
GlobalLogWriter.get().println("convwatch.OfficePrint: FAILED");
@@ -735,7 +735,7 @@ public class OfficePrint {
return bBack;
}
-
+
/**
* @param _aGTA
* @param _sAbsoluteOutputPath
@@ -752,7 +752,7 @@ public class OfficePrint {
// throw new ConvWatchCancelException("Input file: " + _sAbsoluteInputFile + " does not exist.");
return false;
}
-
+
String fs = System.getProperty("file.separator");
// String sInputFileURL = URLHelper.getFileURLFromSystemPath(_sAbsoluteInputFile);
@@ -772,7 +772,7 @@ public class OfficePrint {
}
// sOutputFileURL = URLHelper.getFileURLFromSystemPath(sOutputPath + fs + sInputFileBasename);
// sOutputFileURL = null;
-
+
String sPrintFilename = FileHelper.getNameNoSuffix(sInputFileBasename);
// String sPrintFileURL;
@@ -784,19 +784,19 @@ public class OfficePrint {
}
return false;
}
-
+
// -----------------------------------------------------------------------------
/**
* create a reference file
- * _sAbsoluteInputPath contains the source file, if not exists, return with failure.
+ * _sAbsoluteInputPath contains the source file, if not exists, return with failure.
* _sAbsoluteOutputPath contains the destination, where the file will store after load with StarOffice/OpenOffice.org
* if is null, print only near the Input file path
* _sPrintType ".prn" Print input file with StarOffice/OpenOffice.org and the default printer as PostScript
- *
+ *
* @param _aGTA
* @param _sAbsoluteOutputPath
* @param _sAbsoluteInputFile
- * @return
+ * @return
* @throws ConvWatchCancelException
*/
public static boolean buildReference(GraphicalTestArguments _aGTA,
@@ -828,7 +828,7 @@ public class OfficePrint {
}
// sOutputFileURL = URLHelper.getFileURLFromSystemPath(sOutputPath + fs + sInputFileBasename);
sOutputFileURL = null;
-
+
String sPrintFilename = FileHelper.getNameNoSuffix(sInputFileBasename);
String sPrintFileURL;
@@ -838,14 +838,14 @@ public class OfficePrint {
GlobalLogWriter.get().println("Reference already exist, don't overwrite. Set " + PropertyName.DOC_COMPARATOR_OVERWRITE_REFERENCE + "=true to force overwrite.");
return true;
}
-
+
if (_aGTA.getReferenceType().toLowerCase().equals("msoffice"))
{
sPrintFileURL = URLHelper.getFileURLFromSystemPath(sAbsolutePrintFilename);
}
else if (_aGTA.getReferenceType().toLowerCase().equals("pdf"))
{
-// TODO: If we rename the stored file to *.pdf, we have to be sure that we use *.pdf also as a available reference
+// TODO: If we rename the stored file to *.pdf, we have to be sure that we use *.pdf also as a available reference
sPrintFileURL = URLHelper.getFileURLFromSystemPath(sAbsolutePrintFilename );
}
else if (_aGTA.getReferenceType().toLowerCase().equals("ooo"))
@@ -859,7 +859,7 @@ public class OfficePrint {
}
return printToFile(_aGTA, sInputFileURL, sOutputFileURL, sPrintFileURL);
}
-
+
public static boolean printToFile(GraphicalTestArguments _aGTA,
String _sInputFileURL,
String _sOutputFileURL,
@@ -877,11 +877,11 @@ public class OfficePrint {
{
return false;
}
-
-
+
+
// remember the current timer, to know how long a print process need.
// startTimer();
-
+
if (_aGTA.getReferenceType().toLowerCase().equals("ooo"))
{
bBack = printToFileWithOOo(_aGTA, _sInputFileURL, _sOutputFileURL, _sPrintFileURL);
@@ -938,7 +938,7 @@ public class OfficePrint {
{
return;
}
-
+
if (_xMSF == null)
{
GlobalLogWriter.get().println("MultiServiceFactory not set.");
@@ -964,14 +964,14 @@ public class OfficePrint {
// -----------------------------------------------------------------------------
- public static String getInternalFilterName(String _sFilterName, XMultiServiceFactory _xMSF)
+ public static String getInternalFilterName(String _sFilterName, XMultiServiceFactory _xMSF)
{
if (_sFilterName.length() == 0)
{
// System.out.println("No FilterName set.");
return null;
}
-
+
if (_xMSF == null)
{
GlobalLogWriter.get().println("MultiServiceFactory not set.");
@@ -993,7 +993,7 @@ public class OfficePrint {
XNameAccess aNameAccess = UnoRuntime.queryInterface(XNameAccess.class, aObj);
if (aNameAccess != null)
{
-
+
// if (_sFilterName.toLowerCase().equals("help"))
// {
// System.out.println("Show all possible ElementNames from current version." );
@@ -1005,13 +1005,13 @@ public class OfficePrint {
// System.out.println("Must quit.");
// System.out.exit(1);
// }
-
+
if (! aNameAccess.hasByName(_sFilterName))
{
GlobalLogWriter.get().println("FilterFactory.hasByName() says there exist no '" + _sFilterName + "'" );
return null;
}
-
+
Object[] aElements = null;
String[] aExtensions;
try
@@ -1052,17 +1052,17 @@ public class OfficePrint {
}
return null;
}
-
+
// -----------------------------------------------------------------------------
- static String getServiceNameFromFilterName(String _sFilterName, XMultiServiceFactory _xMSF)
+ static String getServiceNameFromFilterName(String _sFilterName, XMultiServiceFactory _xMSF)
{
if (_sFilterName.length() == 0)
{
// System.out.println("No FilterName set.");
return null;
}
-
+
if (_xMSF == null)
{
GlobalLogWriter.get().println("MultiServiceFactory not set.");
@@ -1083,13 +1083,13 @@ public class OfficePrint {
{
XNameAccess aNameAccess = UnoRuntime.queryInterface(XNameAccess.class, aObj);
if (aNameAccess != null)
- {
+ {
if (! aNameAccess.hasByName(_sFilterName))
{
GlobalLogWriter.get().println("FilterFactory.hasByName() says there exist no '" + _sFilterName + "'" );
return null;
}
-
+
Object[] aElements = null;
String[] aExtensions;
try
@@ -1132,14 +1132,14 @@ public class OfficePrint {
}
// -----------------------------------------------------------------------------
- public static String getFileExtension(String _sInternalFilterName, XMultiServiceFactory _xMSF)
+ public static String getFileExtension(String _sInternalFilterName, XMultiServiceFactory _xMSF)
{
if (_sInternalFilterName.length() == 0)
{
// System.out.println("No FilterName set.");
return null;
}
-
+
if (_xMSF == null)
{
GlobalLogWriter.get().println("MultiServiceFactory not set.");
@@ -1161,20 +1161,20 @@ public class OfficePrint {
XNameAccess aNameAccess = UnoRuntime.queryInterface(XNameAccess.class, aTypeDetection);
if (aNameAccess != null)
{
-
+
// System.out.println("Show ElementNames" );
// String[] aElementNames = aNameAccess.getElementNames();
// for (int i = 0; i<aElementNames.length; i++)
// {
// System.out.println(aElementNames[i]);
// }
-
+
if (! aNameAccess.hasByName(_sInternalFilterName))
{
GlobalLogWriter.get().println("TypeDetection.hasByName() says there exist no '" + _sInternalFilterName + "'" );
return null;
}
-
+
Object[] aElements = null;
String[] aExtensions;
try
@@ -1223,7 +1223,7 @@ public class OfficePrint {
}
return null;
}
-
+
// -----------------------------------------------------------------------------
public static void convertDocument(String _sInputFile, String _sOutputPath, GraphicalTestArguments _aGTA) throws ConvWatchCancelException
{
@@ -1233,7 +1233,7 @@ public class OfficePrint {
GlobalLogWriter.get().println("MultiServiceFactory in GraphicalTestArgument not set.");
return;
}
-
+
String sInputURL = URLHelper.getFileURLFromSystemPath(_sInputFile);
// showType(sInputURL, xMSF);
XComponent aDoc = loadFromURL( _aGTA, sInputURL);
@@ -1242,13 +1242,13 @@ public class OfficePrint {
GlobalLogWriter.get().println("Can't load document '"+ sInputURL + "'");
return;
}
-
+
if (_sOutputPath == null)
{
GlobalLogWriter.get().println("Outputpath not set.");
return;
}
-
+
if (! _aGTA.isStoreAllowed())
{
GlobalLogWriter.get().println("It's not allowed to store, check Input/Output path.");
@@ -1268,7 +1268,7 @@ public class OfficePrint {
GlobalLogWriter.get().println("com.sun.star.frame.XStorable is null");
return;
}
-
+
String sFilterName = _aGTA.getExportFilterName();
// check how many Properties should initialize
@@ -1277,19 +1277,19 @@ public class OfficePrint {
// {
// nPropertyCount ++;
// }
-
+
// initialize PropertyArray
// PropertyValue [] aStoreProps = new PropertyValue[ nPropertyCount ];
// int nPropertyIndex = 0;
ArrayList<PropertyValue> aPropertyList = new ArrayList<PropertyValue>();
-
+
String sExtension = "";
if (sFilterName != null && sFilterName.length() > 0)
{
String sInternalFilterName = getInternalFilterName(sFilterName, xMSF);
String sServiceName = getServiceNameFromFilterName(sFilterName, xMSF);
-
+
GlobalLogWriter.get().println("Filter detection:");
// check if service name from file filter is the same as from the loaded document
boolean bServiceFailed = false;
@@ -1328,7 +1328,7 @@ public class OfficePrint {
showProperty(Arg);
GlobalLogWriter.get().println("FilterName is set to: " + sFilterName);
}
-
+
String sOutputURL = "";
try
{
@@ -1351,7 +1351,7 @@ public class OfficePrint {
{
sOutputFile += sInputFileBasename;
}
-
+
if (FileHelper.exists(sOutputFile) && _aGTA.getOverwrite() == false)
{
GlobalLogWriter.get().println("File already exist, don't overwrite. Set " + PropertyName.DOC_COMPARATOR_OVERWRITE_REFERENCE + "=true to force overwrite.");
@@ -1359,7 +1359,7 @@ public class OfficePrint {
}
sOutputURL = URLHelper.getFileURLFromSystemPath(sOutputFile);
-
+
GlobalLogWriter.get().println("Store document as '" + sOutputURL + "'");
xStorable.storeAsURL(sOutputURL, PropertyHelper.createPropertyValueArrayFormArrayList(aPropertyList));
GlobalLogWriter.get().println("Document stored.");
@@ -1370,8 +1370,8 @@ public class OfficePrint {
}
// TODO: Do we need to wait?
TimeHelper.waitInSeconds(1, "unknown in OfficePrint.convertDocument()");
-
+
}
-
+
}
-
+