Apache OpenOffice (AOO) Bugzilla – Issue 463
File Properties must be NoArgs
Last modified: 2013-02-24 21:10:04 UTC
I have one problem that appears to be a bug with the NT SDK. The problem appears to be a bug with the NT SDK. (Please note that people have NOT found the same bug in their Unix (suse) version of the SDK.) The problem is explained below: a. There seems to be a bug in the jar files coming with the SDK for Windows/NT that prevents us from using any FileProperties except for NoArgs. b. I am running on NT (Version 4.0 Build 1381-Service Pack 6), StarOffice 5.2 and JDK 1.3.1 & 1.2.1 under Oracle's JDeveloper (Version 3.1 Build 681) and under MSDOS. c. The StarOffice SDK seven examples written Java using the StarOfficeApi do not include an example using any FileProperties except for NoArgs. d. Others have found this problem. http://api.openoffice.org/api-dev/msg00035.html. e. Please notice the following code. 1. It is not a complete program. 2. It is a portion of the program at the bottom of this description. 3. This code runs on a Suse (Unix) installation, but not on NT. i. It was run successfully by Sascha Mvllering [SaschaMoe@gmx.net] ii. He ran it under suse 6.3, StarOffice 5.2, JDK 1.3 4. The error we get is: Exception java.lang.ClassCastException: java.lang.StackOverflowError XStorable xstore = (XStorable) UnoRuntime.queryInterface( XStorable.class, aDoc ); PropertyValue [] szArgs = new PropertyValue [1]; szArgs[0] = new PropertyValue(); szArgs[0].Name = "FilterName"; szArgs[0].Value= new String("swriter: HTML (StarWriter)"); //URL storeurl = new URL("file:///home/moelle/OS.html"); //xstore.storeAsURL("file://home/moelle/OS.html", szArgs); xstore.storeAsURL("file://staroffice_sdk/addon/java/Test.html", szArgs); f. If we make the following changes, the code executes. 1. You can notice that it will run with no arguments. 2. This is not a solution, because we need to use the FilterName property for our application. 3. Without setting the FilterName property, the document cannot be translated to another format. 4. Translation to another format is our entire purpose of using StarOffice SDK. XStorable xstore = (XStorable) UnoRuntime.queryInterface( XStorable.class, aDoc ); PropertyValue [] szArgs = new PropertyValue [0]; // szArgs[0] = new PropertyValue(); // szArgs[0].Name = "FilterName"; //szArgs[0].Value= new String("swriter: HTML (StarWriter)"); //URL storeurl = new URL("file:///home/moelle/OS.html"); //xstore.storeAsURL("file://home/moelle/OS.html", szArgs); xstore.storeAsURL("file://staroffice_sdk/addon/java/Test.html", szArgs); h. I am enclosing the entire program below. //base interface import com.sun.star.uno.XInterface; //access the implementations via names import com.sun.star.comp.servicemanager.ServiceManager; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.connection.XConnector; import com.sun.star.connection.XConnection; import com.sun.star.uno.IBridge; import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.XInterface; import com.sun.star.uno.XNamingService; import com.sun.star.document.XDocumentInfo; import com.sun.star.document.XDocumentInfoSupplier; // staroffice interfaces to provide desktop and componentloader // and components i.e. spreadsheets, writerdocs etc. import com.sun.star.frame.XDesktop; import com.sun.star.frame.XComponentLoader; // additional classes required import com.sun.star.sheet.*; import com.sun.star.container.*; import com.sun.star.table.*; import com.sun.star.beans.*; import com.sun.star.style.*; import com.sun.star.lang.*; import com.sun.star.text.*; import com.sun.star.drawing.*; import com.sun.star.awt.KeyFunction; import com.sun.star.awt.Size; import com.sun.star.frame.*; import java.net.URL; //import java.net.*; //import com.sun.star.registry.*; public class DocReadTest { static String neededServices[] = new String[] { "com.sun.star.comp.servicemanager.ServiceManager", "com.sun.star.comp.loader.JavaLoader", "com.sun.star.comp.connections.Connector", "com.sun.star.comp.connections.Acceptor" }; /** * Constructor */ public DocReadTest() { } public static XMultiServiceFactory connect ( String connectStr ) throws com.sun.star.uno.Exception, com.sun.star.uno.RuntimeException, Exception { XMultiServiceFactory xMSF = null; // initial serviceManager ServiceManager serviceManager = new ServiceManager(); serviceManager.addFactories( neededServices ); // create a connector, so that it can contact the office Object connector = serviceManager.createInstance ( "com.sun.star.connection.Connector" ); XConnector connector_xConnector = (XConnector) UnoRuntime.queryInterface( XConnector.class, connector ); // connect to the office XConnection xConnection = connector_xConnector.connect( connectStr ); // now map the initial object, the parts in **** may change, when the bridge is usable as a service // ************* String rootOid = "classic_uno"; IBridge iBridge = UnoRuntime.getBridgeByName( "java", null, "remote",null, new Object[]{"iiop", xConnection, null}); Object rInitialObject = iBridge.mapInterfaceFrom( rootOid, XInterface.class ); XNamingService rName = (XNamingService)UnoRuntime.queryInterface (XNamingService.class, rInitialObject ); if( rName != null ) { System.err.println( "got the remote naming service !" ); Object rXsmgr = rName.getRegisteredObject ("StarOffice.ServiceManager" ); xMSF = (XMultiServiceFactory) UnoRuntime.queryInterface( XMultiServiceFactory.class, rXsmgr ); } return ( xMSF ); } /// finish connect public static XTextDocument openWriter(XMultiServiceFactory oMSF) { //define variables XInterface oInterface; XDesktop oDesktop; XComponentLoader oCLoader; XTextDocument oDoc = null; XComponent aDoc = null; try { oInterface = (XInterface) oMSF.createInstance( "com.sun.star.frame.Desktop" ); oDesktop = ( XDesktop ) UnoRuntime.queryInterface( XDesktop.class, oInterface ); oCLoader = ( XComponentLoader ) UnoRuntime.queryInterface( XComponentLoader.class, oDesktop ); PropertyValue [] szEmptyArgs = new PropertyValue [0]; // load document into StarOffice //aDoc = oCLoader.loadComponentFromURL("file:///mnt/dosb/OS_2.sdw", "_blank", 0, szEmptyArgs ); aDoc = oCLoader.loadComponentFromURL ("D:\\staroffice_sdk\\addon\\java\\samples\\Test.doc", "_blank", 0, szEmptyArgs ); XDocumentInfoSupplier xDIS = (XDocumentInfoSupplier) UnoRuntime.queryInterface (XDocumentInfoSupplier.class, aDoc); XDocumentInfo xDI = xDIS.getDocumentInfo(); XPropertySet xPS = (XPropertySet) UnoRuntime.queryInterface (XPropertySet.class, xDI); XStorable xstore = (XStorable) UnoRuntime.queryInterface( XStorable.class, aDoc ); PropertyValue [] szArgs = new PropertyValue [1]; szArgs[0] = new PropertyValue(); szArgs[0].Name = "FilterName"; szArgs[0].Value= new String("swriter: HTML (StarWriter)"); //URL storeurl = new URL("file:///home/moelle/OS.html"); //xstore.storeAsURL("file://home/moelle/OS.html", szArgs); xstore.storeAsURL("file://staroffice_sdk/addon/java/Test.html", szArgs); aDoc.dispose(); System.out.println("dispose!!!"); //???XDataImporter dimporter = //System.out.println("this is the getText " + oDoc.getText().getClass ().getName()); // } // end of try catch(Exception e){ System.out.println(" Exception " + e); } // end of catch return oDoc; }//end of openWriter /** * main * @param args */ public static void main(String[] args) { //****************************************************************************// // connect to the office to get the MultiServiceFactory // // this is necessary to create instances of services // //****************************************************************************// String connectStr = ""; String systemError = ""; XMultiServiceFactory xMSF = null; XTextDocument myDoc = null; //****************************************************************************// // step 1. // // create connection(s) and get multiservice factory // // the connection string to connect the office // //****************************************************************************// connectStr = "socket, host=localhost,port=8100"; //****************************************************************************// // create connection(s) and get multiservice factory // //****************************************************************************// System.out.println("getting MultiServicefactory"); try { xMSF = connect( connectStr ); } catch (Exception e) { systemError = "Internal error #001 (DocReadTest.main) Could not get MSF. "; System.out.println(systemError); System.out.println(e.toString()); return; } //****************************************************************************// // step 2. // // copen an empty documetn. In this case it's a writer document // // // //****************************************************************************// // open writer document System.out.println("Opening a document"); myDoc = openWriter(xMSF); } }
Created attachment 80 [details] java code showing bug
You are speaking about a problem with StarOffice 5.2, aren't you? StarOffice 5.2 is not topic of this IssueZilla. But please check the mailinglist archives of dev@api.openoffice.org for your problem, it was discussed there. If I misunderstood and you really meant OpenOffice build 619 (as specified in the form, but not in your text), you can reassign this issue. In that case I will forward it to the responsible person.
this one should have been furthermore marked invalid instead of wontfix, but it's time to close this one