Page 1 of 1

Using XStorable Interface on New Document

PostPosted: Tue Feb 09, 2016 12:04 pm
by Niklas.Ardey

I have a question (well thats quiet obvious when i am here :D)

I am trying to use the XStorable interface on the Document that is currently open in Open Office Writer. The Document was never before saved and I only want to save it in the Temp folder of the Users Pc cause i only need the Document to Convert it into a Byte[] that I can send to our server.
This is what I tried but I realy dont know how I can get it to work:
Code: Select all   Expand viewCollapse view
                XModel xDocModel = this.frame.getController().getModel();

                XTextDocument xtextdocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, xDocModel);
                XStorable xStorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, xtextdocument);
                PropertyValue[] storeProbs = new PropertyValue[1];
                xStorable.storeAsURL("C:\\Windows\\Temp\\Test.odt", storeProbs);

Maybe you have a step by step Tutorial or you can provide anything else that may Help me.

BTW I am using Java and Netbeans to programm it.

Re: Using XStorable Interface on New Document

PostPosted: Tue Feb 09, 2016 3:00 pm
by B Marcelly
Your question has no relation to an extension, but to programming OpenOffice in Java. It should have been posted either in Macros and UNO API or one of its sub-sections.

Storing a document is basic knowledge in OpenOffice programming. The reference, especially for Java programming, is of course the Developer's Guide : Storing Documents.

The last instruction of your code uses method storeAsURL(). As the name implies, it needs an URL as argument.