/** * Connects to an OOo server using the specified host and port for the * socket and returns a component context for using the connection to the * OOo server. * * @param host The host * @param port The port * @return The component context */ public XComponentContext connect(String host, int port) throws BootstrapException { String unoConnectString = "uno:socket,host=" + host + ",port=" + port + ";urp;StarOffice.ComponentContext"; return connect(unoConnectString); } }
/** * Connects to an OOo server using the specified host and port for the * socket and returns a component context for using the connection to the * OOo server. * * @param host The host * @param port The port * @return The component context */ public XComponentContext connect(String host, int port) throws BootstrapException { String unoConnectString = "uno:socket,host=" + host + ",port=" + port + ";urp;StarOffice.ComponentContext"; return connect(unoConnectString); } }
public void open() throws OpenOfficeException { if (this.closed) { try { XComponentContext localContext = bsc.connect("127.0.0.1", port); String connectionString = "socket,host=127.0.0.1,port=" + port; XMultiComponentFactory localServiceManager = localContext.getServiceManager(); XConnector connector = as(XConnector.class, localServiceManager.createInstanceWithContext("com.sun.star.connection.Connector", localContext)); XConnection connection = connector.connect(connectionString); XBridgeFactory bridgeFactory = as(XBridgeFactory.class, localServiceManager.createInstanceWithContext("com.sun.star.bridge.BridgeFactory", localContext)); String bridgeName = "yarg_" + bridgeIndex.incrementAndGet(); XBridge bridge = bridgeFactory.createBridge(bridgeName, "urp", connection, null); XMultiComponentFactory serviceManager = as(XMultiComponentFactory.class, bridge.getInstance("StarOffice.ServiceManager")); XPropertySet properties = as(XPropertySet.class, serviceManager); xComponentContext = as(XComponentContext.class, properties.getPropertyValue("DefaultContext")); officeResourceProvider = new OfficeResourceProvider(xComponentContext, officeIntegration); closed = false; } catch (Exception e) { close(); throw new OpenOfficeException("Unable to create Open office components.", e); } } }
public void open() throws OpenOfficeException { if (this.closed) { try { XComponentContext localContext = bsc.connect("127.0.0.1", port); String connectionString = "socket,host=127.0.0.1,port=" + port; XMultiComponentFactory localServiceManager = localContext.getServiceManager(); XConnector connector = as(XConnector.class, localServiceManager.createInstanceWithContext("com.sun.star.connection.Connector", localContext)); XConnection connection = connector.connect(connectionString); XBridgeFactory bridgeFactory = as(XBridgeFactory.class, localServiceManager.createInstanceWithContext("com.sun.star.bridge.BridgeFactory", localContext)); String bridgeName = "yarg_" + bridgeIndex.incrementAndGet(); XBridge bridge = bridgeFactory.createBridge(bridgeName, "urp", connection, null); XMultiComponentFactory serviceManager = as(XMultiComponentFactory.class, bridge.getInstance("StarOffice.ServiceManager")); XPropertySet properties = as(XPropertySet.class, serviceManager); xComponentContext = as(XComponentContext.class, properties.getPropertyValue("DefaultContext")); officeResourceProvider = new OfficeResourceProvider(xComponentContext, officeIntegration); closed = false; } catch (Exception e) { close(); throw new OpenOfficeException("Unable to create Open office components.", e); } } }