Kaydet (Commit) 4c3e5e96 authored tarafından Rüdiger Timm's avatar Rüdiger Timm

INTEGRATION: CWS sdksample (1.4.40); FILE MERGED

2004/08/06 14:36:51 jsc 1.4.40.2: #i29308# use System.err for error output
2004/06/07 13:07:46 jsc 1.4.40.1: #i29308# use new bootstrap feature
üst 1e23001a
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: ConnectionTask.java,v $ * $RCSfile: ConnectionTask.java,v $
* *
* $Revision: 1.4 $ * $Revision: 1.5 $
* *
* last change: $Author: hr $ $Date: 2004-02-02 19:49:49 $ * last change: $Author: rt $ $Date: 2005-01-31 16:02:37 $
* *
* 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
* the BSD license. * the BSD license.
...@@ -62,15 +62,6 @@ class ConnectionTask ...@@ -62,15 +62,6 @@ class ConnectionTask
Init (xListener); Init (xListener);
} }
public ConnectionTask (EventListenerProxy xListener, int nPortNumber, String sHostName)
{
mnPortNumber = nPortNumber;
msHostName = sHostName;
Init (xListener);
}
private void Init (EventListenerProxy xListener) private void Init (EventListenerProxy xListener)
{ {
mxListener = xListener; mxListener = xListener;
...@@ -150,8 +141,7 @@ class ConnectionTask ...@@ -150,8 +141,7 @@ class ConnectionTask
*/ */
private XExtendedToolkit getToolkit () private XExtendedToolkit getToolkit ()
{ {
// Connect to Office. XMultiServiceFactory xFactory = connectToOffice();
XMultiServiceFactory xFactory = connectToOffice (msHostName, mnPortNumber);
// Get toolkit. // Get toolkit.
XExtendedToolkit xToolkit = null; XExtendedToolkit xToolkit = null;
...@@ -176,42 +166,32 @@ class ConnectionTask ...@@ -176,42 +166,32 @@ class ConnectionTask
/** Connect to a running (Star|Open)Office application that has /** Connect to a running (Star|Open)Office application
been started with a command line argument like
"-accept=socket,host=localhost,port=5678;urp;"
*/ */
private XMultiServiceFactory connectToOffice (String hostname, int portnumber) private XMultiServiceFactory connectToOffice ()
{ {
// Set up connection string.
String sConnectString = "uno:socket,host=" + hostname + ",port=" + portnumber
+ ";urp;StarOffice.ServiceManager";
// connect to a running office and get the ServiceManager // connect to a running office and get the ServiceManager
try try
{ {
// Create a URL Resolver. com.sun.star.uno.XComponentContext xCmpContext = null;
XMultiServiceFactory aLocalServiceManager =
com.sun.star.comp.helper.Bootstrap.createSimpleServiceManager(); // get the remote office component context
XUnoUrlResolver aURLResolver = (XUnoUrlResolver) UnoRuntime.queryInterface ( xCmpContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
XUnoUrlResolver.class, if( xCmpContext != null )
aLocalServiceManager.createInstance ("com.sun.star.bridge.UnoUrlResolver") System.out.println("Connected to a running office ...");
);
// get the remote office service manager
com.sun.star.lang.XMultiComponentFactory xMCF =
xCmpContext.getServiceManager();
return (XMultiServiceFactory) UnoRuntime.queryInterface ( return (XMultiServiceFactory) UnoRuntime.queryInterface (
XMultiServiceFactory.class, XMultiServiceFactory.class, xMCF);
aURLResolver.resolve (sConnectString));
} }
catch (Exception e) catch (Exception e)
{ {
if ( ! mbInitialized) if ( ! mbInitialized)
{
MessageArea.println ("Could not connect to office"); MessageArea.println ("Could not connect to office");
MessageArea.println ("Please start OpenOffice/StarOffice with "
+ "\"-accept=socket,host=" + msHostName
+",port=" + mnPortNumber
+ ";urp;\"");
}
else else
MessageArea.print ("."); MessageArea.print (".");
} }
...@@ -219,14 +199,6 @@ class ConnectionTask ...@@ -219,14 +199,6 @@ class ConnectionTask
return null; return null;
} }
/// Default port number.
private int mnPortNumber = 2083;
/// Default host name.
private String msHostName = "localhost";
/** Time in milliseconds between two attempts to connect to an Office /** Time in milliseconds between two attempts to connect to an Office
application. application.
*/ */
......
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