Page 1 of 1

[Solved] Show Calc window

Posted: Sat Sep 26, 2009 1:05 pm
by morpheus9187
Hi, i have a problem. I am not able to show a window of Calc from Uno. i'm using Eclipse with UNO and i write this code.

Code: Select all

String oooExeFolder = "C:/Programmi/OpenOffice.org3/program/";
            	XComponentContext xContext = BootstrapSocketConnector.bootstrap(oooExeFolder);
                XMultiComponentFactory xMultiComponentFactory = xContext.getServiceManager();
                XComponentLoader xcomponentloader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class,xMultiComponentFactory.createInstanceWithContext("com.sun.star.frame.Desktop", xContext));
                PropertyValue[] loadProps = new PropertyValue[1];
                loadProps[0] = new PropertyValue();
                loadProps[0].Name = "Hidden";
                loadProps[0].Value = new Boolean(false);
                
                         
                XComponent xComponent = xcomponentloader.loadComponentFromURL(docURL, "_blank", 0,loadProps);
It doesn't give any errors, but it do nothing.

Re: Show Calc window

Posted: Sat Sep 26, 2009 4:31 pm
by Villeroy
[Solved][Java]How do I know what interfaces supported?
I used the search box right of the forum logo and searched for "Solved Java loadcomponentfromurl"

Re: Show Calc window

Posted: Sun Sep 27, 2009 11:01 am
by morpheus9187
I appended the code found in the post you have reported me in my code but the situation isn't changed. :(

Re: Show Calc window

Posted: Mon Sep 28, 2009 2:09 pm
by morpheus9187
i've modify some code and now it's

Code: Select all

String oooExeFolder = "C:/Programmi/OpenOffice.org3/program/";
            	XComponentContext xContext = BootstrapSocketConnector.bootstrap(oooExeFolder);
                XMultiComponentFactory xMultiComponentFactory = xContext.getServiceManager();
                XComponentLoader xcomponentloader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class,xMultiComponentFactory.createInstanceWithContext("com.sun.star.frame.Desktop", xContext));
                
                PropertyValue[] loadProps = new PropertyValue[1];
                String loadUrl = "private:factory/scalc";
                
                
                XComponent xSpreadsheetComponent = xcomponentloader.loadComponentFromURL(
                		"private:factory/scalc", "_blank", 0, loadProps);
                		//Get XSpreadsheetDocument interface
                		XSpreadsheetDocument xSpreadsheetDocument = (XSpreadsheetDocument)UnoRuntime.queryInterface(
                		XSpreadsheetDocument.class, xSpreadsheetComponent);
                		//Get XModel interface
                		XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, xSpreadsheetComponent);
it gives me an error

Code: Select all

Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/star/comp/helper/BootstrapException
	at org.openoffice.example.comp.OooImpl.main(OooImpl.java:33)
Caused by: java.lang.ClassNotFoundException: com.sun.star.comp.helper.BootstrapException
	at java.net.URLClassLoader$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(Unknown Source)
	at sun.misc.Launcher$ExtClassLoader.findClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClassInternal(Unknown Source)
	... 1 more
anyone has a solution?

Re: Show Calc window

Posted: Mon Sep 28, 2009 2:49 pm
by Villeroy
All I know for sure is that it is possible to load a spreadsheet using the Java language. I can't since I have only a Java runtime, no JDK. Can you run one of the example programs that is shipped with the OOo software development kit (SDK)?

Re: Show Calc window

Posted: Tue Sep 29, 2009 9:23 am
by morpheus9187
Thanks for the help, i have solved :)