У меня есть этот код и работает нормально из командной строки ...
Но когда я помещаю это в апплет, я получаю следующую ошибку
com.sun.star.lang.IllegalArgumentException
на com.sun.star.comp.bridgefactory.BridgeFactory.createBridge (BridgeFactory.java:158)
в
com.sun.star.comp.urlresolver.UrlResolver $ _UrlResolver.resolve (UrlResolver.java:130)
У кого-нибудь есть решение этой проблемы? Где я могу найти источник BridgeFactory?
Runtime.getRuntime().exec("C:/Program Files/OpenOffice.org 3/program/soffice.exe -accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager"); // oooUrlW - the url of soffice.exe
Thread.sleep(5000);
XComponentContext xLocalContext = com.sun.star.comp.helper.Bootstrap.createInitialComponentContext(null);
XMultiComponentFactory xLocalServiceManager = xLocalContext.getServiceManager();
Object urlResolver = xLocalServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver",xLocalContext);
XUnoUrlResolver xUnoUrlResolver = (XUnoUrlResolver) UnoRuntime.queryInterface(XUnoUrlResolver.class,urlResolver);
Object initialObject = xUnoUrlResolver.resolve("uno:socket,host=localhost,port=8100;urp;StarOffice.ServiceManager");
XPropertySet xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,initialObject);
XComponentContext remoteContext = (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class, xPropertySet.getPropertyValue("DefaultContext"));
XMultiComponentFactory remoteServiceManager = remoteContext.getServiceManager();
Object desktop = remoteServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop", remoteContext);
xDesktop =(XDesktop) UnoRuntime.queryInterface( XDesktop.class, desktop);
XComponent xCalcComponent =
newDocComponent(xDesktop, "scalc");
XSpreadsheetDocument xCalcDocument =
(XSpreadsheetDocument)UnoRuntime.queryInterface(
XSpreadsheetDocument.class, xCalcComponent);
XSpreadsheets a=xCalcDocument.getSheets();
Object o = a.getByName("Sheet1");
XSpreadsheet sheet = (XSpreadsheet)UnoRuntime.queryInterface(
XSpreadsheet.class, o);
XCell jjjj = sheet.getCellByPosition(0, 0);
jjjj.setFormula("Some Text ");