本文整理了Java中com.sun.star.connection.XConnector.connect()
方法的一些代码示例,展示了XConnector.connect()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XConnector.connect()
方法的具体详情如下:
包路径:com.sun.star.connection.XConnector
类名称:XConnector
方法名:connect
暂无
代码示例来源:origin: org.libreoffice/jurt
= ((XConnector) Implementation.getConnectionService(
serviceFactory, connectionDescription, XConnector.class,
"Connector")).connect(connectionDescription);
connected = true;
return con;
代码示例来源:origin: org.openoffice/jurt
= ((XConnector) Implementation.getConnectionService(
serviceFactory, connectionDescription, XConnector.class,
"Connector")).connect(connectionDescription);
connected = true;
return con;
代码示例来源:origin: org.libreoffice/jurt
XConnection xConnection = connector_xConnector.connect(conDcp);
try {
xBridge = xBridgeFactory.createBridge(conDcp + ";" + protDcp, protDcp, xConnection, null);
代码示例来源:origin: org.libreoffice/officebean
XConnection xConnection = connector_xConnector.connect(conDcp);
代码示例来源:origin: org.openoffice/jurt
XConnection xConnection = connector_xConnector.connect(conDcp);
try {
xBridge = xBridgeFactory.createBridge(conDcp + ";" + protDcp, protDcp, xConnection, null);
代码示例来源:origin: com.github.livesense/jodconverter-core
public void connect() throws ConnectException {
logger.fine(String.format("connecting with connectString '%s'", unoUrl));
try {
XComponentContext localContext = Bootstrap.createInitialComponentContext(null);
XMultiComponentFactory localServiceManager = localContext.getServiceManager();
XConnector connector = OfficeUtils.cast(XConnector.class, localServiceManager.createInstanceWithContext("com.sun.star.connection.Connector", localContext));
XConnection connection = connector.connect(unoUrl.getConnectString());
XBridgeFactory bridgeFactory = OfficeUtils.cast(XBridgeFactory.class, localServiceManager.createInstanceWithContext("com.sun.star.bridge.BridgeFactory", localContext));
String bridgeName = "jodconverter_" + bridgeIndex.getAndIncrement();
XBridge bridge = bridgeFactory.createBridge(bridgeName, "urp", connection, null);
bridgeComponent = OfficeUtils.cast(XComponent.class, bridge);
bridgeComponent.addEventListener(bridgeListener);
serviceManager = OfficeUtils.cast(XMultiComponentFactory.class, bridge.getInstance("StarOffice.ServiceManager"));
XPropertySet properties = OfficeUtils.cast(XPropertySet.class, serviceManager);
componentContext = OfficeUtils.cast(XComponentContext.class, properties.getPropertyValue("DefaultContext"));
connected = true;
logger.info(String.format("connected: '%s'", unoUrl));
OfficeConnectionEvent connectionEvent = new OfficeConnectionEvent(this);
for (OfficeConnectionEventListener listener : connectionEventListeners) {
listener.connected(connectionEvent);
}
} catch (NoConnectException connectException) {
throw new ConnectException(String.format("connection failed: '%s'; %s", unoUrl, connectException.getMessage()));
} catch (Exception exception) {
throw new OfficeException("connection failed: "+ unoUrl, exception);
}
}
代码示例来源:origin: com.bbossgroups.plugins/bboss-jodconverter-core
public void connect() throws ConnectException {
logger.info(String.format("connecting with connectString '%s'", unoUrl));
try {
XComponentContext localContext = Bootstrap.createInitialComponentContext(null);
XMultiComponentFactory localServiceManager = localContext.getServiceManager();
XConnector connector = OfficeUtils.cast(XConnector.class, localServiceManager.createInstanceWithContext("com.sun.star.connection.Connector", localContext));
XConnection connection = connector.connect(unoUrl.getConnectString());
XBridgeFactory bridgeFactory = OfficeUtils.cast(XBridgeFactory.class, localServiceManager.createInstanceWithContext("com.sun.star.bridge.BridgeFactory", localContext));
String bridgeName = "jodconverter_" + bridgeIndex.getAndIncrement();
XBridge bridge = bridgeFactory.createBridge(bridgeName, "urp", connection, null);
bridgeComponent = OfficeUtils.cast(XComponent.class, bridge);
bridgeComponent.addEventListener(bridgeListener);
serviceManager = OfficeUtils.cast(XMultiComponentFactory.class, bridge.getInstance("StarOffice.ServiceManager"));
XPropertySet properties = OfficeUtils.cast(XPropertySet.class, serviceManager);
componentContext = OfficeUtils.cast(XComponentContext.class, properties.getPropertyValue("DefaultContext"));
connected = true;
logger.info(String.format("connected: '%s'", unoUrl));
OfficeConnectionEvent connectionEvent = new OfficeConnectionEvent(this);
for (OfficeConnectionEventListener listener : connectionEventListeners) {
listener.connected(connectionEvent);
}
} catch (NoConnectException connectException) {
throw new ConnectException(String.format("connection failed: '%s'; %s", unoUrl, connectException.getMessage()));
} catch (Exception exception) {
throw new OfficeException("connection failed: "+ unoUrl, exception);
}
}
代码示例来源:origin: mirkonasato/jodconverter
public void connect() throws ConnectException {
logger.fine(String.format("connecting with connectString '%s'", unoUrl));
try {
XComponentContext localContext = Bootstrap.createInitialComponentContext(null);
XMultiComponentFactory localServiceManager = localContext.getServiceManager();
XConnector connector = OfficeUtils.cast(XConnector.class, localServiceManager.createInstanceWithContext("com.sun.star.connection.Connector", localContext));
XConnection connection = connector.connect(unoUrl.getConnectString());
XBridgeFactory bridgeFactory = OfficeUtils.cast(XBridgeFactory.class, localServiceManager.createInstanceWithContext("com.sun.star.bridge.BridgeFactory", localContext));
String bridgeName = "jodconverter_" + bridgeIndex.getAndIncrement();
XBridge bridge = bridgeFactory.createBridge(bridgeName, "urp", connection, null);
bridgeComponent = OfficeUtils.cast(XComponent.class, bridge);
bridgeComponent.addEventListener(bridgeListener);
serviceManager = OfficeUtils.cast(XMultiComponentFactory.class, bridge.getInstance("StarOffice.ServiceManager"));
XPropertySet properties = OfficeUtils.cast(XPropertySet.class, serviceManager);
componentContext = OfficeUtils.cast(XComponentContext.class, properties.getPropertyValue("DefaultContext"));
connected = true;
logger.info(String.format("connected: '%s'", unoUrl));
OfficeConnectionEvent connectionEvent = new OfficeConnectionEvent(this);
for (OfficeConnectionEventListener listener : connectionEventListeners) {
listener.connected(connectionEvent);
}
} catch (NoConnectException connectException) {
throw new ConnectException(String.format("connection failed: '%s'; %s", unoUrl, connectException.getMessage()));
} catch (Exception exception) {
throw new OfficeException("connection failed: "+ unoUrl, exception);
}
}
代码示例来源:origin: com.artofsolving/jodconverter
public synchronized void connect() throws ConnectException {
logger.debug("connecting");
try {
XComponentContext localContext = Bootstrap.createInitialComponentContext(null);
XMultiComponentFactory localServiceManager = localContext.getServiceManager();
XConnector connector = (XConnector) UnoRuntime.queryInterface(XConnector.class,
localServiceManager.createInstanceWithContext("com.sun.star.connection.Connector", localContext));
XConnection connection = connector.connect(connectionString);
XBridgeFactory bridgeFactory = (XBridgeFactory) UnoRuntime.queryInterface(XBridgeFactory.class,
localServiceManager.createInstanceWithContext("com.sun.star.bridge.BridgeFactory", localContext));
bridge = bridgeFactory.createBridge("", "urp", connection, null);
bridgeComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, bridge);
bridgeComponent.addEventListener(this);
serviceManager = (XMultiComponentFactory) UnoRuntime.queryInterface(XMultiComponentFactory.class,
bridge.getInstance("StarOffice.ServiceManager"));
XPropertySet properties = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, serviceManager);
componentContext = (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class,
properties.getPropertyValue("DefaultContext"));
connected = true;
logger.info("connected");
} catch (NoConnectException connectException) {
throw new ConnectException("connection failed: "+ connectionString +": " + connectException.getMessage());
} catch (Exception exception) {
throw new OpenOfficeException("connection failed: "+ connectionString, exception);
}
}
代码示例来源:origin: com.haulmont.yarg/yarg
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);
}
}
}
代码示例来源:origin: cuba-platform/yarg
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);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!