CWS-TOOLING: integrate CWS perftest09b
2009-07-22 08:34:25 +0200 lla r274216 : #i103694# use bash as shell 2009-07-21 12:33:51 +0200 lla r274178 : #160203# 2009-07-20 13:42:20 +0200 lla r274124 : #106358# add helper tool to get access to rpm in the environment for SOI 2009-07-20 12:43:26 +0200 lla r274119 : #i103656# compatiblity
This commit is contained in:
@@ -60,12 +60,13 @@ import stats.Summarizer;
|
|||||||
|
|
||||||
import util.DynamicClassLoader;
|
import util.DynamicClassLoader;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The testbase for executing basic tests.
|
* The testbase for executing basic tests.
|
||||||
* @see lib.TestBase
|
* @see lib.TestBase
|
||||||
*/
|
*/
|
||||||
public class basic_fat implements TestBase {
|
public class basic_fat implements TestBase
|
||||||
|
{
|
||||||
|
|
||||||
public static boolean debug = false;
|
public static boolean debug = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -73,7 +74,8 @@ public class basic_fat implements TestBase {
|
|||||||
* @param param The test parameters.
|
* @param param The test parameters.
|
||||||
* @param return True, if the test was executed.
|
* @param return True, if the test was executed.
|
||||||
*/
|
*/
|
||||||
public boolean executeTest(TestParameters param) {
|
public boolean executeTest(TestParameters param)
|
||||||
|
{
|
||||||
DescGetter dg = new APIDescGetter();
|
DescGetter dg = new APIDescGetter();
|
||||||
String job = (String) param.get("TestJob");
|
String job = (String) param.get("TestJob");
|
||||||
OfficeProvider office = null;
|
OfficeProvider office = null;
|
||||||
@@ -88,7 +90,8 @@ public class basic_fat implements TestBase {
|
|||||||
"DescriptionPath"),
|
"DescriptionPath"),
|
||||||
debug);
|
debug);
|
||||||
|
|
||||||
if (entries == null) {
|
if (entries == null)
|
||||||
|
{
|
||||||
System.out.println("Couldn't get Description for Job");
|
System.out.println("Couldn't get Description for Job");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -97,7 +100,8 @@ public class basic_fat implements TestBase {
|
|||||||
String ExclusionFile = (String) param.get("ExclusionList");
|
String ExclusionFile = (String) param.get("ExclusionList");
|
||||||
Vector exclusions = null;
|
Vector exclusions = null;
|
||||||
|
|
||||||
if (ExclusionFile != null) {
|
if (ExclusionFile != null)
|
||||||
|
{
|
||||||
exclusions = getExclusionList(ExclusionFile, debug);
|
exclusions = getExclusionList(ExclusionFile, debug);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,8 +110,10 @@ public class basic_fat implements TestBase {
|
|||||||
System.out.print("> Connecting the Office ");
|
System.out.print("> Connecting the Office ");
|
||||||
System.out.println("With " + conStr);
|
System.out.println("With " + conStr);
|
||||||
|
|
||||||
for (int l = 0; l < entries.length; l++) {
|
for (int l = 0; l < entries.length; l++)
|
||||||
if (entries[l].hasErrorMsg) {
|
{
|
||||||
|
if (entries[l].hasErrorMsg)
|
||||||
|
{
|
||||||
System.out.println(entries[l].ErrorMsg);
|
System.out.println(entries[l].ErrorMsg);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
@@ -118,7 +124,8 @@ public class basic_fat implements TestBase {
|
|||||||
XMultiServiceFactory msf = (XMultiServiceFactory) office.getManager(
|
XMultiServiceFactory msf = (XMultiServiceFactory) office.getManager(
|
||||||
param);
|
param);
|
||||||
|
|
||||||
if (msf == null) {
|
if (msf == null)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,7 +141,8 @@ public class basic_fat implements TestBase {
|
|||||||
|
|
||||||
tCase = (TestCase) new BasicTestCase(entry);
|
tCase = (TestCase) new BasicTestCase(entry);
|
||||||
|
|
||||||
if (tCase == null) {
|
if (tCase == null)
|
||||||
|
{
|
||||||
sumIt.summarizeDown(entry, entry.ErrorMsg);
|
sumIt.summarizeDown(entry, entry.ErrorMsg);
|
||||||
|
|
||||||
LogWriter sumObj = OutProducerFactory.createOutProducer(param);
|
LogWriter sumObj = OutProducerFactory.createOutProducer(param);
|
||||||
@@ -152,16 +160,21 @@ public class basic_fat implements TestBase {
|
|||||||
entry.UserDefinedParams = param;
|
entry.UserDefinedParams = param;
|
||||||
tCase.setLogWriter((PrintWriter) log);
|
tCase.setLogWriter((PrintWriter) log);
|
||||||
|
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
tCase.initializeTestCase(param);
|
tCase.initializeTestCase(param);
|
||||||
} catch (RuntimeException e) {
|
}
|
||||||
|
catch (RuntimeException e)
|
||||||
|
{
|
||||||
helper.ProcessHandler ph = (helper.ProcessHandler) param.get(
|
helper.ProcessHandler ph = (helper.ProcessHandler) param.get(
|
||||||
"AppProvider");
|
"AppProvider");
|
||||||
|
|
||||||
if (ph != null) {
|
if (ph != null)
|
||||||
|
{
|
||||||
OfficeWatcher ow = (OfficeWatcher) param.get("Watcher");
|
OfficeWatcher ow = (OfficeWatcher) param.get("Watcher");
|
||||||
|
|
||||||
if ((ow != null) && ow.isAlive()) {
|
if ((ow != null) && ow.isAlive())
|
||||||
|
{
|
||||||
ow.finish = true;
|
ow.finish = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,7 +187,8 @@ public class basic_fat implements TestBase {
|
|||||||
|
|
||||||
TestEnvironment tEnv = tCase.getTestEnvironment(param);
|
TestEnvironment tEnv = tCase.getTestEnvironment(param);
|
||||||
|
|
||||||
if (tEnv == null) {
|
if (tEnv == null)
|
||||||
|
{
|
||||||
sumIt.summarizeDown(entry, "Unable to create testcase");
|
sumIt.summarizeDown(entry, "Unable to create testcase");
|
||||||
|
|
||||||
LogWriter sumObj = OutProducerFactory.createOutProducer(param);
|
LogWriter sumObj = OutProducerFactory.createOutProducer(param);
|
||||||
@@ -184,10 +198,12 @@ public class basic_fat implements TestBase {
|
|||||||
helper.ProcessHandler ph = (helper.ProcessHandler) param.get(
|
helper.ProcessHandler ph = (helper.ProcessHandler) param.get(
|
||||||
"AppProvider");
|
"AppProvider");
|
||||||
|
|
||||||
if (ph != null) {
|
if (ph != null)
|
||||||
|
{
|
||||||
OfficeWatcher ow = (OfficeWatcher) param.get("Watcher");
|
OfficeWatcher ow = (OfficeWatcher) param.get("Watcher");
|
||||||
|
|
||||||
if ((ow != null) && ow.isAlive()) {
|
if ((ow != null) && ow.isAlive())
|
||||||
|
{
|
||||||
ow.finish = true;
|
ow.finish = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,8 +216,10 @@ public class basic_fat implements TestBase {
|
|||||||
|
|
||||||
System.out.println("created " + tCase.getObjectName());
|
System.out.println("created " + tCase.getObjectName());
|
||||||
|
|
||||||
for (int j = 0; j < entry.SubEntryCount; j++) {
|
for (int j = 0; j < entry.SubEntryCount; j++)
|
||||||
if (!entry.SubEntries[j].isToTest) {
|
{
|
||||||
|
if (!entry.SubEntries[j].isToTest)
|
||||||
|
{
|
||||||
Summarizer.summarizeDown(entry.SubEntries[j],
|
Summarizer.summarizeDown(entry.SubEntries[j],
|
||||||
"not part of the job");
|
"not part of the job");
|
||||||
|
|
||||||
@@ -209,7 +227,8 @@ public class basic_fat implements TestBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((exclusions != null) &&
|
if ((exclusions != null) &&
|
||||||
(exclusions.contains(entry.SubEntries[j].longName))) {
|
(exclusions.contains(entry.SubEntries[j].longName)))
|
||||||
|
{
|
||||||
Summarizer.summarizeDown(entry.SubEntries[j],
|
Summarizer.summarizeDown(entry.SubEntries[j],
|
||||||
"known issue");
|
"known issue");
|
||||||
|
|
||||||
@@ -225,11 +244,13 @@ public class basic_fat implements TestBase {
|
|||||||
entry.SubEntries[j].UserDefinedParams = param;
|
entry.SubEntries[j].UserDefinedParams = param;
|
||||||
entry.SubEntries[j].Logger = ifclog;
|
entry.SubEntries[j].Logger = ifclog;
|
||||||
|
|
||||||
if ((tEnv == null) || tEnv.isDisposed()) {
|
if ((tEnv == null) || tEnv.isDisposed())
|
||||||
|
{
|
||||||
helper.ProcessHandler ph = (helper.ProcessHandler) param.get(
|
helper.ProcessHandler ph = (helper.ProcessHandler) param.get(
|
||||||
"AppProvider");
|
"AppProvider");
|
||||||
|
|
||||||
if (ph != null) {
|
if (ph != null)
|
||||||
|
{
|
||||||
office.closeExistingOffice(param, true);
|
office.closeExistingOffice(param, true);
|
||||||
shortWait(5000);
|
shortWait(5000);
|
||||||
}
|
}
|
||||||
@@ -250,15 +271,19 @@ public class basic_fat implements TestBase {
|
|||||||
sumIfc.summary(entry.SubEntries[j]);
|
sumIfc.summary(entry.SubEntries[j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
tCase.cleanupTestCase(param);
|
tCase.cleanupTestCase(param);
|
||||||
} catch (Exception e) {
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
log.println("TestCase already gone");
|
log.println("TestCase already gone");
|
||||||
|
|
||||||
helper.ProcessHandler ph = (helper.ProcessHandler) param.get(
|
helper.ProcessHandler ph = (helper.ProcessHandler) param.get(
|
||||||
"AppProvider");
|
"AppProvider");
|
||||||
|
|
||||||
if (ph != null) {
|
if (ph != null)
|
||||||
|
{
|
||||||
office.closeExistingOffice(param, true);
|
office.closeExistingOffice(param, true);
|
||||||
shortWait(5000);
|
shortWait(5000);
|
||||||
}
|
}
|
||||||
@@ -271,15 +296,18 @@ public class basic_fat implements TestBase {
|
|||||||
sumObj.summary(entry);
|
sumObj.summary(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entries.length > 1) {
|
if (entries.length > 1)
|
||||||
|
{
|
||||||
System.out.println();
|
System.out.println();
|
||||||
|
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
System.out.println(
|
System.out.println(
|
||||||
"Failures that appeared during scenario execution:");
|
"Failures that appeared during scenario execution:");
|
||||||
|
|
||||||
for (int i = 0; i < entries.length; i++) {
|
for (int i = 0; i < entries.length; i++)
|
||||||
if (!entries[i].State.endsWith("OK")) {
|
{
|
||||||
|
if (!entries[i].State.endsWith("OK"))
|
||||||
|
{
|
||||||
System.out.println("\t " + entries[i].longName);
|
System.out.println("\t " + entries[i].longName);
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
@@ -292,19 +320,22 @@ public class basic_fat implements TestBase {
|
|||||||
helper.ProcessHandler ph = (helper.ProcessHandler) param.get(
|
helper.ProcessHandler ph = (helper.ProcessHandler) param.get(
|
||||||
"AppProvider");
|
"AppProvider");
|
||||||
|
|
||||||
if (ph != null) {
|
if (ph != null)
|
||||||
|
{
|
||||||
office.closeExistingOffice(param, true);
|
office.closeExistingOffice(param, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected TestEnvironment getEnv(DescEntry entry, TestParameters param) {
|
protected TestEnvironment getEnv(DescEntry entry, TestParameters param)
|
||||||
|
{
|
||||||
DynamicClassLoader dcl = new DynamicClassLoader();
|
DynamicClassLoader dcl = new DynamicClassLoader();
|
||||||
String officeProviderName = (String) param.get("OfficeProvider");
|
String officeProviderName = (String) param.get("OfficeProvider");
|
||||||
AppProvider office = (AppProvider) dcl.getInstance(officeProviderName);
|
AppProvider office = (AppProvider) dcl.getInstance(officeProviderName);
|
||||||
|
|
||||||
if (office == null) {
|
if (office == null)
|
||||||
|
{
|
||||||
System.out.println("ERROR: Wrong parameter 'OfficeProvider', " +
|
System.out.println("ERROR: Wrong parameter 'OfficeProvider', " +
|
||||||
" it cannot be instantiated.");
|
" it cannot be instantiated.");
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
@@ -313,7 +344,8 @@ public class basic_fat implements TestBase {
|
|||||||
XMultiServiceFactory msf = (XMultiServiceFactory) office.getManager(
|
XMultiServiceFactory msf = (XMultiServiceFactory) office.getManager(
|
||||||
param);
|
param);
|
||||||
|
|
||||||
if (msf == null) {
|
if (msf == null)
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -331,16 +363,20 @@ public class basic_fat implements TestBase {
|
|||||||
|
|
||||||
TestEnvironment tEnv = null;
|
TestEnvironment tEnv = null;
|
||||||
|
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
tCase.initializeTestCase(param);
|
tCase.initializeTestCase(param);
|
||||||
tEnv = tCase.getTestEnvironment(param);
|
tEnv = tCase.getTestEnvironment(param);
|
||||||
} catch (java.lang.RuntimeException e) {
|
}
|
||||||
|
catch (java.lang.RuntimeException e)
|
||||||
|
{
|
||||||
System.out.println(e.getMessage());
|
System.out.println(e.getMessage());
|
||||||
|
|
||||||
helper.ProcessHandler ph = (helper.ProcessHandler) param.get(
|
helper.ProcessHandler ph = (helper.ProcessHandler) param.get(
|
||||||
"AppProvider");
|
"AppProvider");
|
||||||
|
|
||||||
if (ph != null) {
|
if (ph != null)
|
||||||
|
{
|
||||||
office.closeExistingOffice(param, true);
|
office.closeExistingOffice(param, true);
|
||||||
shortWait(5000);
|
shortWait(5000);
|
||||||
}
|
}
|
||||||
@@ -352,37 +388,52 @@ public class basic_fat implements TestBase {
|
|||||||
return tEnv;
|
return tEnv;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void shortWait(int millis) {
|
protected void shortWait(int millis)
|
||||||
try {
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
Thread.sleep(millis);
|
Thread.sleep(millis);
|
||||||
} catch (java.lang.InterruptedException ie) {
|
}
|
||||||
|
catch (java.lang.InterruptedException ie)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Vector getExclusionList(String url, boolean debug) {
|
protected Vector getExclusionList(String url, boolean debug)
|
||||||
|
{
|
||||||
Vector entryList = new Vector();
|
Vector entryList = new Vector();
|
||||||
String line = "#";
|
String line = "#";
|
||||||
BufferedReader exclusion = null;
|
BufferedReader exclusion = null;
|
||||||
|
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
exclusion = new BufferedReader(new FileReader(url));
|
exclusion = new BufferedReader(new FileReader(url));
|
||||||
} catch (java.io.FileNotFoundException fnfe) {
|
}
|
||||||
if (debug) {
|
catch (java.io.FileNotFoundException fnfe)
|
||||||
|
{
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
System.out.println("Couldn't find file " + url);
|
System.out.println("Couldn't find file " + url);
|
||||||
}
|
}
|
||||||
|
|
||||||
return entryList;
|
return entryList;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (line != null) {
|
while (line != null)
|
||||||
try {
|
{
|
||||||
if (!line.startsWith("#")) {
|
try
|
||||||
|
{
|
||||||
|
if (!line.startsWith("#"))
|
||||||
|
{
|
||||||
entryList.add(line);
|
entryList.add(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
line = exclusion.readLine();
|
line = exclusion.readLine();
|
||||||
} catch (java.io.IOException ioe) {
|
}
|
||||||
if (debug) {
|
catch (java.io.IOException ioe)
|
||||||
|
{
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
System.out.println(
|
System.out.println(
|
||||||
"Exception while reading exclusion list");
|
"Exception while reading exclusion list");
|
||||||
}
|
}
|
||||||
@@ -391,10 +442,14 @@ public class basic_fat implements TestBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
exclusion.close();
|
exclusion.close();
|
||||||
} catch (java.io.IOException ioe) {
|
}
|
||||||
if (debug) {
|
catch (java.io.IOException ioe)
|
||||||
|
{
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
System.out.println("Couldn't close file " + url);
|
System.out.println("Couldn't close file " + url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -44,6 +44,8 @@ import java.lang.reflect.Method;
|
|||||||
*/
|
*/
|
||||||
public class Assurance
|
public class Assurance
|
||||||
{
|
{
|
||||||
|
public static final boolean CONTINUE = true;
|
||||||
|
|
||||||
/** State of the current test method **/
|
/** State of the current test method **/
|
||||||
protected boolean state = true;
|
protected boolean state = true;
|
||||||
|
|
||||||
|
@@ -58,7 +58,8 @@ public abstract class ComplexTestCase extends Assurance implements ComplexTest
|
|||||||
**/
|
**/
|
||||||
protected int mThreadTimeOut = 0;
|
protected int mThreadTimeOut = 0;
|
||||||
/** Continue a test even if it did fail **/
|
/** Continue a test even if it did fail **/
|
||||||
public static final boolean CONTINUE = true;
|
// public static final boolean CONTINUE = true;
|
||||||
|
|
||||||
/** End a test if it did fail **/
|
/** End a test if it did fail **/
|
||||||
public static final boolean BREAK = true;
|
public static final boolean BREAK = true;
|
||||||
|
|
||||||
|
@@ -27,9 +27,9 @@
|
|||||||
* for a copy of the LGPLv3 License.
|
* for a copy of the LGPLv3 License.
|
||||||
*
|
*
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
package graphical;
|
package graphical;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.RandomAccessFile;
|
import java.io.RandomAccessFile;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -41,6 +41,7 @@ import java.util.Enumeration;
|
|||||||
/* public */ // is only need, if we need this class outside package convwatch
|
/* public */ // is only need, if we need this class outside package convwatch
|
||||||
public class IniFile implements Enumeration
|
public class IniFile implements Enumeration
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* internal representation of the ini file content.
|
* internal representation of the ini file content.
|
||||||
* Problem, if ini file changed why other write something difference, we don't realise this.
|
* Problem, if ini file changed why other write something difference, we don't realise this.
|
||||||
@@ -48,8 +49,8 @@ public class IniFile implements Enumeration
|
|||||||
private String m_sFilename;
|
private String m_sFilename;
|
||||||
private ArrayList m_aList;
|
private ArrayList m_aList;
|
||||||
boolean m_bListContainUnsavedChanges = false;
|
boolean m_bListContainUnsavedChanges = false;
|
||||||
|
|
||||||
private int m_aEnumerationPos = 0;
|
private int m_aEnumerationPos = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
open a ini file by it's name
|
open a ini file by it's name
|
||||||
@param _sFilename string a filename, if the file doesn't exist, a new empty ini file will create.
|
@param _sFilename string a filename, if the file doesn't exist, a new empty ini file will create.
|
||||||
@@ -90,6 +91,7 @@ public class IniFile implements Enumeration
|
|||||||
return aLines;
|
return aLines;
|
||||||
}
|
}
|
||||||
RandomAccessFile aReader = null;
|
RandomAccessFile aReader = null;
|
||||||
|
// BufferedReader aReader;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
aReader = new RandomAccessFile(aFile, "r");
|
aReader = new RandomAccessFile(aFile, "r");
|
||||||
@@ -135,6 +137,7 @@ public class IniFile implements Enumeration
|
|||||||
{
|
{
|
||||||
return m_aList.size() > 1 ? true : false;
|
return m_aList.size() > 1 ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a given Section and Key exists in the ini file
|
* Check if a given Section and Key exists in the ini file
|
||||||
* @param _sSectionName
|
* @param _sSectionName
|
||||||
@@ -173,6 +176,7 @@ public class IniFile implements Enumeration
|
|||||||
String sFindSection = "[" + _sSectionName + "]";
|
String sFindSection = "[" + _sSectionName + "]";
|
||||||
return sFindSection;
|
return sFindSection;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String sectionToString(String _sSectionName)
|
private String sectionToString(String _sSectionName)
|
||||||
{
|
{
|
||||||
String sKeyName = _sSectionName;
|
String sKeyName = _sSectionName;
|
||||||
@@ -183,6 +187,7 @@ public class IniFile implements Enumeration
|
|||||||
}
|
}
|
||||||
return sKeyName;
|
return sKeyName;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String toLowerIfNeed(String _sName)
|
private String toLowerIfNeed(String _sName)
|
||||||
{
|
{
|
||||||
return _sName.toLowerCase();
|
return _sName.toLowerCase();
|
||||||
@@ -332,7 +337,6 @@ public class IniFile implements Enumeration
|
|||||||
*/
|
*/
|
||||||
// private int m_nCurrentPosition;
|
// private int m_nCurrentPosition;
|
||||||
// private String m_sOldKey;
|
// private String m_sOldKey;
|
||||||
|
|
||||||
public String getValue(String _sSection, String _sKey)
|
public String getValue(String _sSection, String _sKey)
|
||||||
{
|
{
|
||||||
String sValue = "";
|
String sValue = "";
|
||||||
@@ -359,7 +363,6 @@ public class IniFile implements Enumeration
|
|||||||
// }
|
// }
|
||||||
// return "";
|
// return "";
|
||||||
// }
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the value at Section, Key converted to an integer
|
* Returns the value at Section, Key converted to an integer
|
||||||
* Check with hasValue(Section, Key) to check before you get into trouble.
|
* Check with hasValue(Section, Key) to check before you get into trouble.
|
||||||
@@ -390,6 +393,7 @@ public class IniFile implements Enumeration
|
|||||||
{
|
{
|
||||||
store();
|
store();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
write back the ini file to the disk, only if there exist changes
|
write back the ini file to the disk, only if there exist changes
|
||||||
* @deprecated use close() instead!
|
* @deprecated use close() instead!
|
||||||
@@ -426,12 +430,16 @@ public class IniFile implements Enumeration
|
|||||||
for (int i = 0; i < m_aList.size(); i++)
|
for (int i = 0; i < m_aList.size(); i++)
|
||||||
{
|
{
|
||||||
String sLine = getItem(i);
|
String sLine = getItem(i);
|
||||||
|
if (sLine.startsWith("["))
|
||||||
|
{
|
||||||
|
// write an extra empty line before next section.
|
||||||
|
aWriter.writeByte((int) '\n');
|
||||||
|
}
|
||||||
aWriter.writeBytes(sLine);
|
aWriter.writeBytes(sLine);
|
||||||
aWriter.writeByte((int) '\n');
|
aWriter.writeByte((int) '\n');
|
||||||
}
|
}
|
||||||
aWriter.close();
|
aWriter.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (java.io.FileNotFoundException fne)
|
catch (java.io.FileNotFoundException fne)
|
||||||
{
|
{
|
||||||
GlobalLogWriter.get().println("couldn't open file for writing " + m_sFilename);
|
GlobalLogWriter.get().println("couldn't open file for writing " + m_sFilename);
|
||||||
@@ -446,12 +454,16 @@ public class IniFile implements Enumeration
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void insertValue(String _sSection, String _sKey, int _nValue)
|
public void insertValue(String _sSection, String _sKey, int _nValue)
|
||||||
{
|
{
|
||||||
insertValue(_sSection, _sKey, String.valueOf(_nValue));
|
insertValue(_sSection, _sKey, String.valueOf(_nValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void insertValue(String _sSection, String _sKey, long _nValue)
|
||||||
|
{
|
||||||
|
insertValue(_sSection, _sKey, String.valueOf(_nValue));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
insert a value
|
insert a value
|
||||||
there are 3 cases
|
there are 3 cases
|
||||||
@@ -551,12 +563,12 @@ public class IniFile implements Enumeration
|
|||||||
//
|
//
|
||||||
// return sLocalValue;
|
// return sLocalValue;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public void removeSection(String _sSectionToRemove)
|
public void removeSection(String _sSectionToRemove)
|
||||||
{
|
{
|
||||||
// first, search for the name
|
// first, search for the name
|
||||||
int i = findSection(_sSectionToRemove);
|
int i = findSection(_sSectionToRemove);
|
||||||
if (i == -1) {
|
if (i == -1)
|
||||||
|
{
|
||||||
// Section to remove not found, do nothing.
|
// Section to remove not found, do nothing.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -579,7 +591,8 @@ public void removeSection(String _sSectionToRemove)
|
|||||||
/**
|
/**
|
||||||
* some tests for this class
|
* some tests for this class
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args)
|
||||||
|
{
|
||||||
String sTempFile = System.getProperty("java.io.tmpdir");
|
String sTempFile = System.getProperty("java.io.tmpdir");
|
||||||
sTempFile += "inifile";
|
sTempFile += "inifile";
|
||||||
|
|
||||||
@@ -602,7 +615,6 @@ public void removeSection(String _sSectionToRemove)
|
|||||||
aIniFile.close();
|
aIniFile.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enumeration Interface
|
* Enumeration Interface
|
||||||
* @return true, if there are more Key values
|
* @return true, if there are more Key values
|
||||||
|
@@ -430,8 +430,8 @@ public class APIDescGetter extends DescGetter
|
|||||||
|
|
||||||
return getDescArray(makeArray(ifc_names));
|
return getDescArray(makeArray(ifc_names));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String entryType;
|
private static String entryType;
|
||||||
|
|
||||||
private static DescEntry createDescEntry(String meth_name, String ifc_name, DescEntry parent)
|
private static DescEntry createDescEntry(String meth_name, String ifc_name, DescEntry parent)
|
||||||
{
|
{
|
||||||
entryType = "service";
|
entryType = "service";
|
||||||
@@ -472,8 +472,8 @@ public class APIDescGetter extends DescGetter
|
|||||||
|
|
||||||
private static void createIfcName(String ifc_name, ArrayList meth_names, DescEntry ifcDesc)
|
private static void createIfcName(String ifc_name, ArrayList meth_names, DescEntry ifcDesc)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method ensures that XComponent will be the last in the list of interfaces
|
* This method ensures that XComponent will be the last in the list of interfaces
|
||||||
*/
|
*/
|
||||||
|
@@ -36,6 +36,9 @@ import java.io.PrintStream;
|
|||||||
import java.io.LineNumberReader;
|
import java.io.LineNumberReader;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
import lib.TestParameters;
|
import lib.TestParameters;
|
||||||
import util.PropertyName;
|
import util.PropertyName;
|
||||||
import util.utils;
|
import util.utils;
|
||||||
@@ -492,6 +495,29 @@ public class ProcessHandler
|
|||||||
isStarted = false;
|
isStarted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the time in seconds since 1st January 1970
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static long getSystemTime()
|
||||||
|
{
|
||||||
|
// Calendar cal = new GregorianCalendar();
|
||||||
|
// final long nTime = cal.getTimeInMillis();
|
||||||
|
final long nTime = System.currentTimeMillis();
|
||||||
|
return nTime;
|
||||||
|
}
|
||||||
|
private long m_nExactStartTimeInMillisec;
|
||||||
|
|
||||||
|
private void initialExactStartTime()
|
||||||
|
{
|
||||||
|
m_nExactStartTimeInMillisec = getSystemTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getProcessStartTime()
|
||||||
|
{
|
||||||
|
return m_nExactStartTimeInMillisec;
|
||||||
|
}
|
||||||
|
|
||||||
protected void execute()
|
protected void execute()
|
||||||
{
|
{
|
||||||
if (isStarted())
|
if (isStarted())
|
||||||
@@ -511,7 +537,7 @@ public class ProcessHandler
|
|||||||
log.print(" ");
|
log.print(" ");
|
||||||
}
|
}
|
||||||
log.println("");
|
log.println("");
|
||||||
|
initialExactStartTime();
|
||||||
m_aProcess = runtime.exec(cmdLineArray, envVars);
|
m_aProcess = runtime.exec(cmdLineArray, envVars);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -547,6 +573,9 @@ public class ProcessHandler
|
|||||||
stderr = new Pump(m_aProcess.getErrorStream(), log, "err > ");
|
stderr = new Pump(m_aProcess.getErrorStream(), log, "err > ");
|
||||||
stdIn = new PrintStream(m_aProcess.getOutputStream());
|
stdIn = new PrintStream(m_aProcess.getOutputStream());
|
||||||
|
|
||||||
|
// int nExitValue = m_aProcess.exitValue();
|
||||||
|
// int dummy = 0;
|
||||||
|
|
||||||
dbg("execute: flush io-streams");
|
dbg("execute: flush io-streams");
|
||||||
|
|
||||||
flushInput();
|
flushInput();
|
||||||
|
@@ -48,7 +48,7 @@ public class Runner
|
|||||||
|
|
||||||
private static long m_nStartTime;
|
private static long m_nStartTime;
|
||||||
|
|
||||||
private static long getStartTime()
|
public static long getRunnerStartTime()
|
||||||
{
|
{
|
||||||
return m_nStartTime;
|
return m_nStartTime;
|
||||||
}
|
}
|
||||||
@@ -69,7 +69,7 @@ public class Runner
|
|||||||
/*
|
/*
|
||||||
return the time, which is done until last startTime()
|
return the time, which is done until last startTime()
|
||||||
*/
|
*/
|
||||||
private static long meanTime(long _nCurrentTimer)
|
public static long meanTime(long _nCurrentTimer)
|
||||||
{
|
{
|
||||||
if (_nCurrentTimer == 0)
|
if (_nCurrentTimer == 0)
|
||||||
{
|
{
|
||||||
@@ -109,6 +109,7 @@ public class Runner
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean checkPathVariable(String _sPath, String delim)
|
private static boolean checkPathVariable(String _sPath, String delim)
|
||||||
{
|
{
|
||||||
String sPath = System.getProperty(_sPath);
|
String sPath = System.getProperty(_sPath);
|
||||||
@@ -240,7 +241,7 @@ public class Runner
|
|||||||
checkAllVariablesForCygwinPath(param);
|
checkAllVariablesForCygwinPath(param);
|
||||||
|
|
||||||
boolean worked = toExecute.executeTest(param);
|
boolean worked = toExecute.executeTest(param);
|
||||||
long nTime = meanTime(getStartTime());
|
long nTime = meanTime(getRunnerStartTime());
|
||||||
String sBeautifyTime = beautifyTime(nTime);
|
String sBeautifyTime = beautifyTime(nTime);
|
||||||
|
|
||||||
System.out.println("Job run took: " + nTime + "ms " + " [" + sBeautifyTime + "]");
|
System.out.println("Job run took: " + nTime + "ms " + " [" + sBeautifyTime + "]");
|
||||||
|
@@ -56,18 +56,20 @@ import helper.ConfigHelper;
|
|||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import lib.StatusException;
|
import lib.StatusException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* contains helper methods for the Desktop
|
* contains helper methods for the Desktop
|
||||||
*/
|
*/
|
||||||
public class DesktopTools {
|
public class DesktopTools
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Queries the XComponentLoader
|
* Queries the XComponentLoader
|
||||||
*
|
*
|
||||||
* @param xMSF the MultiServiceFactory
|
* @param xMSF the MultiServiceFactory
|
||||||
* @return the gained XComponentLoader
|
* @return the gained XComponentLoader
|
||||||
*/
|
*/
|
||||||
public static XComponentLoader getCLoader(XMultiServiceFactory xMSF) {
|
public static XComponentLoader getCLoader(XMultiServiceFactory xMSF)
|
||||||
|
{
|
||||||
XDesktop oDesktop = (XDesktop) UnoRuntime.queryInterface(
|
XDesktop oDesktop = (XDesktop) UnoRuntime.queryInterface(
|
||||||
XDesktop.class, createDesktop(xMSF));
|
XDesktop.class, createDesktop(xMSF));
|
||||||
|
|
||||||
@@ -83,12 +85,16 @@ public class DesktopTools {
|
|||||||
* @param xMSF the MultiServiceFactory
|
* @param xMSF the MultiServiceFactory
|
||||||
* @return the gained Object
|
* @return the gained Object
|
||||||
*/
|
*/
|
||||||
public static Object createDesktop(XMultiServiceFactory xMSF) {
|
public static Object createDesktop(XMultiServiceFactory xMSF)
|
||||||
|
{
|
||||||
Object oInterface;
|
Object oInterface;
|
||||||
|
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
oInterface = xMSF.createInstance("com.sun.star.comp.framework.Desktop");
|
oInterface = xMSF.createInstance("com.sun.star.comp.framework.Desktop");
|
||||||
} catch (com.sun.star.uno.Exception e) {
|
}
|
||||||
|
catch (com.sun.star.uno.Exception e)
|
||||||
|
{
|
||||||
throw new IllegalArgumentException("Desktop Service not available");
|
throw new IllegalArgumentException("Desktop Service not available");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +106,8 @@ public class DesktopTools {
|
|||||||
* @param xMSF the XMultiServiceFactory
|
* @param xMSF the XMultiServiceFactory
|
||||||
* @return XEnumeration of all components on the desktop
|
* @return XEnumeration of all components on the desktop
|
||||||
*/
|
*/
|
||||||
public static XEnumeration getAllComponents(XMultiServiceFactory xMSF) {
|
public static XEnumeration getAllComponents(XMultiServiceFactory xMSF)
|
||||||
|
{
|
||||||
XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(
|
XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(
|
||||||
XDesktop.class, createDesktop(xMSF));
|
XDesktop.class, createDesktop(xMSF));
|
||||||
return xDesktop.getComponents().createEnumeration();
|
return xDesktop.getComponents().createEnumeration();
|
||||||
@@ -111,7 +118,8 @@ public class DesktopTools {
|
|||||||
* @param xMSF the XMultiServiceFactory
|
* @param xMSF the XMultiServiceFactory
|
||||||
* @return XComponent of the current component on the desktop
|
* @return XComponent of the current component on the desktop
|
||||||
*/
|
*/
|
||||||
public static XComponent getCurrentComponent(XMultiServiceFactory xMSF) {
|
public static XComponent getCurrentComponent(XMultiServiceFactory xMSF)
|
||||||
|
{
|
||||||
XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(
|
XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(
|
||||||
XDesktop.class, createDesktop(xMSF));
|
XDesktop.class, createDesktop(xMSF));
|
||||||
return xDesktop.getCurrentComponent();
|
return xDesktop.getCurrentComponent();
|
||||||
@@ -122,7 +130,8 @@ public class DesktopTools {
|
|||||||
* @param xMSF the XMultiServiceFactory
|
* @param xMSF the XMultiServiceFactory
|
||||||
* @return XComponent of the current component on the desktop
|
* @return XComponent of the current component on the desktop
|
||||||
*/
|
*/
|
||||||
public static XFrame getCurrentFrame(XMultiServiceFactory xMSF) {
|
public static XFrame getCurrentFrame(XMultiServiceFactory xMSF)
|
||||||
|
{
|
||||||
XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(
|
XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(
|
||||||
XDesktop.class, createDesktop(xMSF));
|
XDesktop.class, createDesktop(xMSF));
|
||||||
return xDesktop.getCurrentFrame();
|
return xDesktop.getCurrentFrame();
|
||||||
@@ -138,22 +147,33 @@ public class DesktopTools {
|
|||||||
* @param xMSF the XMultiSerivceFactory
|
* @param xMSF the XMultiSerivceFactory
|
||||||
* @return returns an array of all open documents
|
* @return returns an array of all open documents
|
||||||
*/
|
*/
|
||||||
public static Object[] getAllOpenDocuments(XMultiServiceFactory xMSF) {
|
public static Object[] getAllOpenDocuments(XMultiServiceFactory xMSF)
|
||||||
|
{
|
||||||
Vector components = new Vector();
|
Vector components = new Vector();
|
||||||
XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(
|
XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(
|
||||||
XDesktop.class, createDesktop(xMSF));
|
XDesktop.class, createDesktop(xMSF));
|
||||||
|
|
||||||
XEnumeration allComp = getAllComponents(xMSF);
|
XEnumeration allComp = getAllComponents(xMSF);
|
||||||
|
|
||||||
while (allComp.hasMoreElements()){
|
while (allComp.hasMoreElements())
|
||||||
try{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
XComponent xComponent = (XComponent) UnoRuntime.queryInterface(
|
XComponent xComponent = (XComponent) UnoRuntime.queryInterface(
|
||||||
XComponent.class, allComp.nextElement());
|
XComponent.class, allComp.nextElement());
|
||||||
|
|
||||||
if (getDocumentType(xComponent) != null) components.add(xComponent);
|
if (getDocumentType(xComponent) != null)
|
||||||
|
{
|
||||||
|
components.add(xComponent);
|
||||||
|
}
|
||||||
|
|
||||||
} catch (com.sun.star.container.NoSuchElementException e) {
|
}
|
||||||
} catch ( com.sun.star.lang.WrappedTargetException e) {}
|
catch (com.sun.star.container.NoSuchElementException e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
catch (com.sun.star.lang.WrappedTargetException e)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return components.toArray();
|
return components.toArray();
|
||||||
}
|
}
|
||||||
@@ -170,28 +190,41 @@ public class DesktopTools {
|
|||||||
* </ul>
|
* </ul>
|
||||||
* or <CODE>null</CODE>
|
* or <CODE>null</CODE>
|
||||||
*/
|
*/
|
||||||
public static String getDocumentType(XComponent xComponent) {
|
public static String getDocumentType(XComponent xComponent)
|
||||||
|
{
|
||||||
XServiceInfo sInfo = (XServiceInfo) UnoRuntime.queryInterface(
|
XServiceInfo sInfo = (XServiceInfo) UnoRuntime.queryInterface(
|
||||||
XServiceInfo.class, xComponent);
|
XServiceInfo.class, xComponent);
|
||||||
|
|
||||||
if (sInfo == null) {
|
if (sInfo == null)
|
||||||
|
{
|
||||||
return "";
|
return "";
|
||||||
} else if (sInfo.supportsService("com.sun.star.sheet.SpreadsheetDocument")) {
|
}
|
||||||
|
else if (sInfo.supportsService("com.sun.star.sheet.SpreadsheetDocument"))
|
||||||
|
{
|
||||||
return "scalc";
|
return "scalc";
|
||||||
} else if (sInfo.supportsService("com.sun.star.text.TextDocument")) {
|
}
|
||||||
|
else if (sInfo.supportsService("com.sun.star.text.TextDocument"))
|
||||||
|
{
|
||||||
return "swriter";
|
return "swriter";
|
||||||
} else if (sInfo.supportsService("com.sun.star.drawing.DrawingDocument")) {
|
}
|
||||||
|
else if (sInfo.supportsService("com.sun.star.drawing.DrawingDocument"))
|
||||||
|
{
|
||||||
return "sdraw";
|
return "sdraw";
|
||||||
} else if (sInfo.supportsService("com.sun.star.presentation.PresentationDocument")) {
|
}
|
||||||
|
else if (sInfo.supportsService("com.sun.star.presentation.PresentationDocument"))
|
||||||
|
{
|
||||||
return "simpress";
|
return "simpress";
|
||||||
} else if (sInfo.supportsService("com.sun.star.formula.FormulaProperties")) {
|
}
|
||||||
|
else if (sInfo.supportsService("com.sun.star.formula.FormulaProperties"))
|
||||||
|
{
|
||||||
return "smath";
|
return "smath";
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens a new document of a given kind
|
* Opens a new document of a given kind
|
||||||
* with arguments
|
* with arguments
|
||||||
@@ -208,14 +241,17 @@ public class DesktopTools {
|
|||||||
* @param xMSF the MultiServiceFactory
|
* @param xMSF the MultiServiceFactory
|
||||||
*/
|
*/
|
||||||
public static XComponent openNewDoc(XMultiServiceFactory xMSF, String kind,
|
public static XComponent openNewDoc(XMultiServiceFactory xMSF, String kind,
|
||||||
PropertyValue[] Args) {
|
PropertyValue[] Args)
|
||||||
|
{
|
||||||
XComponent oDoc = null;
|
XComponent oDoc = null;
|
||||||
|
|
||||||
try {
|
try
|
||||||
oDoc = getCLoader(xMSF)
|
{
|
||||||
.loadComponentFromURL("private:factory/" + kind,
|
oDoc = getCLoader(xMSF).loadComponentFromURL("private:factory/" + kind,
|
||||||
"_blank", 0, Args);
|
"_blank", 0, Args);
|
||||||
} catch (com.sun.star.uno.Exception e) {
|
}
|
||||||
|
catch (com.sun.star.uno.Exception e)
|
||||||
|
{
|
||||||
throw new IllegalArgumentException("Document could not be opened");
|
throw new IllegalArgumentException("Document could not be opened");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,7 +267,8 @@ public class DesktopTools {
|
|||||||
* @param xMSF the MultiServiceFactory
|
* @param xMSF the MultiServiceFactory
|
||||||
*/
|
*/
|
||||||
public static XComponent loadDoc(XMultiServiceFactory xMSF, String url,
|
public static XComponent loadDoc(XMultiServiceFactory xMSF, String url,
|
||||||
PropertyValue[] Args) {
|
PropertyValue[] Args)
|
||||||
|
{
|
||||||
XComponent oDoc = null;
|
XComponent oDoc = null;
|
||||||
if (Args == null)
|
if (Args == null)
|
||||||
{
|
{
|
||||||
@@ -254,34 +291,48 @@ public class DesktopTools {
|
|||||||
* closes a given document
|
* closes a given document
|
||||||
* @param DocumentToClose the document to close
|
* @param DocumentToClose the document to close
|
||||||
*/
|
*/
|
||||||
public static void closeDoc(XInterface DocumentToClose) {
|
public static void closeDoc(XInterface DocumentToClose)
|
||||||
|
{
|
||||||
if (DocumentToClose == null)
|
if (DocumentToClose == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String kd = System.getProperty("KeepDocument");
|
String kd = System.getProperty("KeepDocument");
|
||||||
if (kd != null ) {
|
if (kd != null)
|
||||||
|
{
|
||||||
System.out.println("The property 'KeepDocument' is set and so the document won't be disposed");
|
System.out.println("The property 'KeepDocument' is set and so the document won't be disposed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
XModifiable modified = (XModifiable) UnoRuntime.queryInterface(
|
XModifiable modified = (XModifiable) UnoRuntime.queryInterface(XModifiable.class, DocumentToClose);
|
||||||
XModifiable.class, DocumentToClose);
|
XCloseable closer = (XCloseable) UnoRuntime.queryInterface(XCloseable.class, DocumentToClose);
|
||||||
XCloseable closer = (XCloseable) UnoRuntime.queryInterface(
|
|
||||||
XCloseable.class, DocumentToClose);
|
|
||||||
|
|
||||||
try {
|
try
|
||||||
if (modified != null){
|
{
|
||||||
|
if (modified != null)
|
||||||
|
{
|
||||||
modified.setModified(false);
|
modified.setModified(false);
|
||||||
}
|
}
|
||||||
closer.close(true);
|
closer.close(true);
|
||||||
} catch (com.sun.star.util.CloseVetoException e) {
|
}
|
||||||
|
catch (com.sun.star.util.CloseVetoException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
System.out.println("Couldn't close document");
|
System.out.println("Couldn't close document");
|
||||||
} catch (com.sun.star.lang.DisposedException e) {
|
}
|
||||||
|
catch (com.sun.star.lang.DisposedException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
System.out.println("Couldn't close document");
|
System.out.println("Couldn't close document");
|
||||||
} catch (java.lang.NullPointerException e) {
|
}
|
||||||
|
catch (java.lang.NullPointerException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
System.out.println("Couldn't close document");
|
System.out.println("Couldn't close document");
|
||||||
} catch (com.sun.star.beans.PropertyVetoException e) {
|
}
|
||||||
|
catch (com.sun.star.beans.PropertyVetoException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
System.out.println("Couldn't close document");
|
System.out.println("Couldn't close document");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -293,9 +344,11 @@ public class DesktopTools {
|
|||||||
* @return a floating XWindow
|
* @return a floating XWindow
|
||||||
*/
|
*/
|
||||||
public static XWindowPeer createFloatingWindow(XMultiServiceFactory xMSF)
|
public static XWindowPeer createFloatingWindow(XMultiServiceFactory xMSF)
|
||||||
throws StatusException{
|
throws StatusException
|
||||||
|
{
|
||||||
return createFloatingWindow(xMSF, 500, 100, 400, 600);
|
return createFloatingWindow(xMSF, 500, 100, 400, 600);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a floating XWindow on the given position and size.
|
* Creates a floating XWindow on the given position and size.
|
||||||
* @return a floating XWindow
|
* @return a floating XWindow
|
||||||
@@ -307,13 +360,17 @@ public class DesktopTools {
|
|||||||
* @throws lib.StatusException if it is not possible to create a floating window a lib.StatusException was thrown
|
* @throws lib.StatusException if it is not possible to create a floating window a lib.StatusException was thrown
|
||||||
*/
|
*/
|
||||||
public static XWindowPeer createFloatingWindow(XMultiServiceFactory xMSF, int X, int Y, int width, int height)
|
public static XWindowPeer createFloatingWindow(XMultiServiceFactory xMSF, int X, int Y, int width, int height)
|
||||||
throws StatusException{
|
throws StatusException
|
||||||
|
{
|
||||||
|
|
||||||
XInterface oObj = null;
|
XInterface oObj = null;
|
||||||
|
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
oObj = (XInterface) xMSF.createInstance("com.sun.star.awt.Toolkit");
|
oObj = (XInterface) xMSF.createInstance("com.sun.star.awt.Toolkit");
|
||||||
} catch (com.sun.star.uno.Exception e) {
|
}
|
||||||
|
catch (com.sun.star.uno.Exception e)
|
||||||
|
{
|
||||||
throw new StatusException("Couldn't get toolkit", e);
|
throw new StatusException("Couldn't get toolkit", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -341,9 +398,12 @@ public class DesktopTools {
|
|||||||
|
|
||||||
XWindowPeer xWindow = null;
|
XWindowPeer xWindow = null;
|
||||||
|
|
||||||
try{
|
try
|
||||||
|
{
|
||||||
xWindow = tk.createWindow(descriptor);
|
xWindow = tk.createWindow(descriptor);
|
||||||
}catch ( com.sun.star.lang.IllegalArgumentException e){
|
}
|
||||||
|
catch (com.sun.star.lang.IllegalArgumentException e)
|
||||||
|
{
|
||||||
throw new StatusException("Could not create window", e);
|
throw new StatusException("Could not create window", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,27 +415,28 @@ public class DesktopTools {
|
|||||||
* zoom to have a view over the hole page
|
* zoom to have a view over the hole page
|
||||||
* @param xDoc the document to zoom
|
* @param xDoc the document to zoom
|
||||||
*/
|
*/
|
||||||
public static void zoomToEntirePage( XInterface xDoc){
|
public static void zoomToEntirePage(XInterface xDoc)
|
||||||
try {
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
XModel xMod = (XModel) UnoRuntime.queryInterface(XModel.class, xDoc);
|
XModel xMod = (XModel) UnoRuntime.queryInterface(XModel.class, xDoc);
|
||||||
XInterface oCont = xMod.getCurrentController();
|
XInterface oCont = xMod.getCurrentController();
|
||||||
XViewSettingsSupplier oVSSupp = (XViewSettingsSupplier)
|
XViewSettingsSupplier oVSSupp = (XViewSettingsSupplier) UnoRuntime.queryInterface(XViewSettingsSupplier.class, oCont);
|
||||||
UnoRuntime.queryInterface(XViewSettingsSupplier.class, oCont);
|
|
||||||
|
|
||||||
XInterface oViewSettings = oVSSupp.getViewSettings();
|
XInterface oViewSettings = oVSSupp.getViewSettings();
|
||||||
XPropertySet oViewProp = (XPropertySet)
|
XPropertySet oViewProp = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oViewSettings);
|
||||||
UnoRuntime.queryInterface(XPropertySet.class, oViewSettings);
|
|
||||||
oViewProp.setPropertyValue("ZoomType",
|
oViewProp.setPropertyValue("ZoomType",
|
||||||
new Short(com.sun.star.view.DocumentZoomType.ENTIRE_PAGE));
|
new Short(com.sun.star.view.DocumentZoomType.ENTIRE_PAGE));
|
||||||
|
|
||||||
utils.shortWait(5000);
|
utils.shortWait(5000);
|
||||||
} catch (Exception e){
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
System.out.println("Could not zoom to entire page: " + e.toString());
|
System.out.println("Could not zoom to entire page: " + e.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function docks the Stylist onto the right side of the window.</p>
|
* This function docks the Stylist onto the right side of the window.</p>
|
||||||
* Note:<P>
|
* Note:<P>
|
||||||
@@ -383,9 +444,11 @@ public class DesktopTools {
|
|||||||
* the chage of the docking will be effective at a restart.
|
* the chage of the docking will be effective at a restart.
|
||||||
* @param xMSF the XMultiServiceFactory
|
* @param xMSF the XMultiServiceFactory
|
||||||
*/
|
*/
|
||||||
public static void dockStylist(XMultiServiceFactory xMSF){
|
public static void dockStylist(XMultiServiceFactory xMSF)
|
||||||
|
{
|
||||||
// prepare Window-Settings
|
// prepare Window-Settings
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
ConfigHelper aConfig = new ConfigHelper(xMSF,
|
ConfigHelper aConfig = new ConfigHelper(xMSF,
|
||||||
"org.openoffice.Office.Views", false);
|
"org.openoffice.Office.Views", false);
|
||||||
|
|
||||||
@@ -407,7 +470,9 @@ public class DesktopTools {
|
|||||||
aConfig.flush();
|
aConfig.flush();
|
||||||
aConfig = null;
|
aConfig = null;
|
||||||
|
|
||||||
} catch (com.sun.star.uno.Exception e) {
|
}
|
||||||
|
catch (com.sun.star.uno.Exception e)
|
||||||
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -418,7 +483,8 @@ public class DesktopTools {
|
|||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static void bringWindowToFromt(XModel xModel){
|
public static void bringWindowToFromt(XModel xModel)
|
||||||
|
{
|
||||||
bringWindowToFront(xModel);
|
bringWindowToFront(xModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -428,7 +494,8 @@ public class DesktopTools {
|
|||||||
* Only the order of Office documents are changeable.
|
* Only the order of Office documents are changeable.
|
||||||
* @param xModel the XModel of the document to bring to top
|
* @param xModel the XModel of the document to bring to top
|
||||||
*/
|
*/
|
||||||
public static void bringWindowToFront(XModel xModel){
|
public static void bringWindowToFront(XModel xModel)
|
||||||
|
{
|
||||||
// System.out.println("DEBUG: bring to front xModel");
|
// System.out.println("DEBUG: bring to front xModel");
|
||||||
|
|
||||||
XTopWindow xTopWindow =
|
XTopWindow xTopWindow =
|
||||||
@@ -439,10 +506,12 @@ public class DesktopTools {
|
|||||||
xTopWindow.toFront();
|
xTopWindow.toFront();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void bringWindowToFront(XComponent xComponent){
|
public static void bringWindowToFront(XComponent xComponent)
|
||||||
|
{
|
||||||
// System.out.println("DEBUG: bring to front xComponent");
|
// System.out.println("DEBUG: bring to front xComponent");
|
||||||
XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, xComponent);
|
XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, xComponent);
|
||||||
if (xModel != null){
|
if (xModel != null)
|
||||||
|
{
|
||||||
bringWindowToFront(xModel);
|
bringWindowToFront(xModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -186,7 +186,13 @@ public class utils {
|
|||||||
} else {
|
} else {
|
||||||
if (fullDocPath.startsWith("/")) {
|
if (fullDocPath.startsWith("/")) {
|
||||||
prefix = "file://";
|
prefix = "file://";
|
||||||
} else {
|
// if (helper.OSHelper.isLinuxIntel())
|
||||||
|
// {
|
||||||
|
// prefix = "file:/";
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
prefix = "file:///";
|
prefix = "file:///";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user