Kaydet (Commit) fbd72be1 authored tarafından Oliver Bolte's avatar Oliver Bolte

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#
üst b9975229
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: OfficeProvider.java,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -74,6 +74,7 @@ import com.sun.star.uno.XComponentContext; ...@@ -74,6 +74,7 @@ import com.sun.star.uno.XComponentContext;
import com.sun.star.uno.XInterface; import com.sun.star.uno.XInterface;
import com.sun.star.uno.XNamingService; import com.sun.star.uno.XNamingService;
import com.sun.star.util.XCloseable; import com.sun.star.util.XCloseable;
import lib.TestParameters; import lib.TestParameters;
...@@ -121,18 +122,20 @@ public class OfficeProvider implements AppProvider { ...@@ -121,18 +122,20 @@ public class OfficeProvider implements AppProvider {
* Method to get the ServiceManager of an Office * Method to get the ServiceManager of an Office
*/ */
public Object getManager(lib.TestParameters param) { public Object getManager(lib.TestParameters param) {
String additionalArgs = (String) param.get("AdditionalConnectionArguments"); String additionalArgs = (String) param.get(
if ( additionalArgs == null) { "AdditionalConnectionArguments");
if (additionalArgs == null) {
additionalArgs = ";"; additionalArgs = ";";
} else { } else {
additionalArgs = ","+additionalArgs+";"; additionalArgs = "," + additionalArgs + ";";
} }
String cncstr = "uno:" + param.get("ConnectionString") + String cncstr = "uno:" + param.get("ConnectionString") + ";urp" +
";urp"+additionalArgs+"StarOffice.ServiceManager"; additionalArgs + "StarOffice.ServiceManager";
System.out.print("Connecting the Office"); System.out.print("Connecting the Office");
System.out.println(" with "+cncstr); System.out.println(" with " + cncstr);
debug = param.getBool("DebugIsActive"); debug = param.getBool("DebugIsActive");
...@@ -151,6 +154,14 @@ public class OfficeProvider implements AppProvider { ...@@ -151,6 +154,14 @@ public class OfficeProvider implements AppProvider {
"Local Connection trying to start the Office"); "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"); String cmd = (String) param.get("AppExecutionCommand");
ProcessHandler ph = new ProcessHandler(cmd); ProcessHandler ph = new ProcessHandler(cmd);
isExecutable = ph.executeAsynchronously(); isExecutable = ph.executeAsynchronously();
...@@ -248,12 +259,10 @@ public class OfficeProvider implements AppProvider { ...@@ -248,12 +259,10 @@ public class OfficeProvider implements AppProvider {
ProcessHandler ph = (ProcessHandler) param.get("AppProvider"); ProcessHandler ph = (ProcessHandler) param.get("AppProvider");
if (ph != null) { if (ph != null) {
disposeOffice(msf,param); disposeOffice(msf, param);
// dispose watcher in case it's still running. // dispose watcher in case it's still running.
//System.out.println("INFO: disposing the office and terminate the watcher process."); //System.out.println("INFO: disposing the office and terminate the watcher process.");
OfficeWatcher ow = (OfficeWatcher) param.get("Watcher"); OfficeWatcher ow = (OfficeWatcher) param.get("Watcher");
if ((ow != null) && ow.isAlive()) { if ((ow != null) && ow.isAlive()) {
...@@ -298,9 +307,12 @@ public class OfficeProvider implements AppProvider { ...@@ -298,9 +307,12 @@ public class OfficeProvider implements AppProvider {
return msf; return msf;
} }
private boolean disposeOffice(XMultiServiceFactory msf, TestParameters param) { private synchronized boolean disposeOffice(XMultiServiceFactory msf,
TestParameters param) {
XDesktop desk = null; XDesktop desk = null;
boolean result = true;
if (msf != null) { if (msf != null) {
try { try {
desk = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, desk = (XDesktop) UnoRuntime.queryInterface(XDesktop.class,
...@@ -310,37 +322,70 @@ public class OfficeProvider implements AppProvider { ...@@ -310,37 +322,70 @@ public class OfficeProvider implements AppProvider {
if (desk != null) { if (desk != null) {
boolean allClosed = closeAllWindows(desk); boolean allClosed = closeAllWindows(desk);
if(!allClosed)
if(debug) System.out.println("Couldn't close all office windows!"); if (!allClosed) {
if(debug) System.out.println("Trying to terminate the desktop"); if (debug) {
System.out.println(
"Couldn't close all office windows!");
}
}
if (debug) {
System.out.println("Trying to terminate the desktop");
}
desk.terminate(); desk.terminate();
if(debug) System.out.println("Desktop terminated");
param.remove("AppProvider"); if (debug) {
param.remove("ServiceFactory"); System.out.println("Desktop terminated");
}
try { try {
Thread.sleep(5000); Thread.sleep(5000);
} catch (java.lang.InterruptedException ie) { } catch (java.lang.InterruptedException e) {
} }
} }
} catch (com.sun.star.uno.Exception ue) { } 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) { protected boolean closeAllWindows(XDesktop desk) {
XEnumerationAccess compEnumAccess = desk.getComponents(); XEnumerationAccess compEnumAccess = desk.getComponents();
XEnumeration compEnum = compEnumAccess.createEnumeration(); XEnumeration compEnum = compEnumAccess.createEnumeration();
boolean res = true; boolean res = true;
try { try {
while (compEnum.hasMoreElements()){ while (compEnum.hasMoreElements()) {
XCloseable closer = (XCloseable) UnoRuntime.queryInterface(XCloseable.class, compEnum.nextElement()); XCloseable closer = (XCloseable) UnoRuntime.queryInterface(
if(closer != null) XCloseable.class,
closer.close(true); compEnum.nextElement());
}
if (closer != null) {
closer.close(true);
}
}
} catch (com.sun.star.util.CloseVetoException cve) { } catch (com.sun.star.util.CloseVetoException cve) {
res = false; res = false;
} catch (com.sun.star.container.NoSuchElementException nsee) { } catch (com.sun.star.container.NoSuchElementException nsee) {
...@@ -348,6 +393,7 @@ public class OfficeProvider implements AppProvider { ...@@ -348,6 +393,7 @@ public class OfficeProvider implements AppProvider {
} catch (com.sun.star.lang.WrappedTargetException wte) { } catch (com.sun.star.lang.WrappedTargetException wte) {
res = false; res = false;
} }
return res; return res;
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment