summaryrefslogtreecommitdiff
path: root/qadevOOo/runner/helper/OfficeProvider.java
diff options
context:
space:
mode:
authorOliver Bolte <obo@openoffice.org>2004-03-19 13:29:16 +0000
committerOliver Bolte <obo@openoffice.org>2004-03-19 13:29:16 +0000
commitfbd72be142ed23b3b526c8d0c3e002f15ca7ec74 (patch)
tree6466acf751dc2b37d4b7c455696612edf1019baa /qadevOOo/runner/helper/OfficeProvider.java
parentb997522980304a5a173e17e61120b09bbdf11b3b (diff)
INTEGRATION: CWS qadev16 (1.8.12); FILE MERGED
2004/02/06 12:24:47 sw 1.8.12.3: #114831# 2004/02/03 14:59:21 sw 1.8.12.2: #114831# 2004/01/13 12:26:22 sw 1.8.12.1: #114831#
Diffstat (limited to 'qadevOOo/runner/helper/OfficeProvider.java')
-rw-r--r--qadevOOo/runner/helper/OfficeProvider.java100
1 files changed, 73 insertions, 27 deletions
diff --git a/qadevOOo/runner/helper/OfficeProvider.java b/qadevOOo/runner/helper/OfficeProvider.java
index 070295631223..0d06b4163da9 100644
--- a/qadevOOo/runner/helper/OfficeProvider.java
+++ b/qadevOOo/runner/helper/OfficeProvider.java
@@ -2,9 +2,9 @@
*
* $RCSfile: OfficeProvider.java,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change:$Date: 2003-11-18 16:14:32 $
+ * last change:$Date: 2004-03-19 14:29:16 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -74,6 +74,7 @@ import com.sun.star.uno.XComponentContext;
import com.sun.star.uno.XInterface;
import com.sun.star.uno.XNamingService;
import com.sun.star.util.XCloseable;
+
import lib.TestParameters;
@@ -121,18 +122,20 @@ public class OfficeProvider implements AppProvider {
* Method to get the ServiceManager of an Office
*/
public Object getManager(lib.TestParameters param) {
- String additionalArgs = (String) param.get("AdditionalConnectionArguments");
- if ( additionalArgs == null) {
+ String additionalArgs = (String) param.get(
+ "AdditionalConnectionArguments");
+
+ if (additionalArgs == null) {
additionalArgs = ";";
} else {
- additionalArgs = ","+additionalArgs+";";
+ additionalArgs = "," + additionalArgs + ";";
}
- String cncstr = "uno:" + param.get("ConnectionString") +
- ";urp"+additionalArgs+"StarOffice.ServiceManager";
+ String cncstr = "uno:" + param.get("ConnectionString") + ";urp" +
+ additionalArgs + "StarOffice.ServiceManager";
System.out.print("Connecting the Office");
- System.out.println(" with "+cncstr);
+ System.out.println(" with " + cncstr);
debug = param.getBool("DebugIsActive");
@@ -151,6 +154,14 @@ public class OfficeProvider implements AppProvider {
"Local Connection trying to start the Office");
}
+ //ensure that a pending officewatcher gets finished before a new
+ //office is started
+ OfficeWatcher ow_old = (OfficeWatcher) param.get("Watcher");
+
+ if (ow_old != null) {
+ ow_old.finish = true;
+ }
+
String cmd = (String) param.get("AppExecutionCommand");
ProcessHandler ph = new ProcessHandler(cmd);
isExecutable = ph.executeAsynchronously();
@@ -248,12 +259,10 @@ public class OfficeProvider implements AppProvider {
ProcessHandler ph = (ProcessHandler) param.get("AppProvider");
if (ph != null) {
- disposeOffice(msf,param);
-
+ disposeOffice(msf, param);
// dispose watcher in case it's still running.
//System.out.println("INFO: disposing the office and terminate the watcher process.");
-
OfficeWatcher ow = (OfficeWatcher) param.get("Watcher");
if ((ow != null) && ow.isAlive()) {
@@ -298,9 +307,12 @@ public class OfficeProvider implements AppProvider {
return msf;
}
- private boolean disposeOffice(XMultiServiceFactory msf, TestParameters param) {
+ private synchronized boolean disposeOffice(XMultiServiceFactory msf,
+ TestParameters param) {
XDesktop desk = null;
+ boolean result = true;
+
if (msf != null) {
try {
desk = (XDesktop) UnoRuntime.queryInterface(XDesktop.class,
@@ -310,37 +322,70 @@ public class OfficeProvider implements AppProvider {
if (desk != null) {
boolean allClosed = closeAllWindows(desk);
- if(!allClosed)
- if(debug) System.out.println("Couldn't close all office windows!");
- if(debug) System.out.println("Trying to terminate the desktop");
+
+ if (!allClosed) {
+ if (debug) {
+ System.out.println(
+ "Couldn't close all office windows!");
+ }
+ }
+
+ if (debug) {
+ System.out.println("Trying to terminate the desktop");
+ }
+
desk.terminate();
- if(debug) System.out.println("Desktop terminated");
- param.remove("AppProvider");
- param.remove("ServiceFactory");
+
+ if (debug) {
+ System.out.println("Desktop terminated");
+ }
try {
Thread.sleep(5000);
- } catch (java.lang.InterruptedException ie) {
+ } catch (java.lang.InterruptedException e) {
}
}
} catch (com.sun.star.uno.Exception ue) {
- return false;
+ result = false;
+ } catch (com.sun.star.lang.DisposedException ue) {
+ result = false;
}
}
- return true;
+ ProcessHandler ph = (ProcessHandler) param.get("AppProvider");
+
+ if (ph != null) {
+ // dispose watcher in case it's still running.
+ OfficeWatcher ow = (OfficeWatcher) param.get("Watcher");
+
+ if ((ow != null) && ow.isAlive()) {
+ ow.finish = true;
+ }
+
+ ph.kill();
+ }
+
+ param.remove("AppProvider");
+ param.remove("ServiceFactory");
+
+ return result;
}
protected boolean closeAllWindows(XDesktop desk) {
XEnumerationAccess compEnumAccess = desk.getComponents();
XEnumeration compEnum = compEnumAccess.createEnumeration();
boolean res = true;
+
try {
- while (compEnum.hasMoreElements()){
- XCloseable closer = (XCloseable) UnoRuntime.queryInterface(XCloseable.class, compEnum.nextElement());
- if(closer != null)
- closer.close(true);
- }
+ while (compEnum.hasMoreElements()) {
+ XCloseable closer = (XCloseable) UnoRuntime.queryInterface(
+ XCloseable.class,
+ compEnum.nextElement());
+
+ if (closer != null) {
+ closer.close(true);
+ }
+ }
} catch (com.sun.star.util.CloseVetoException cve) {
res = false;
} catch (com.sun.star.container.NoSuchElementException nsee) {
@@ -348,6 +393,7 @@ public class OfficeProvider implements AppProvider {
} catch (com.sun.star.lang.WrappedTargetException wte) {
res = false;
}
+
return res;
}
-}
+} \ No newline at end of file