Apache OpenOffice (AOO) Bugzilla – Issue 111491
Defect in XStorable.storeToURL( "Private:stream", xPropertySet)
Last modified: 2023-02-06 17:17:15 UTC
It seems to be impossible in OO3.2 to store a Database document to an XOuputStream via the code sequence: [code] XComponent xComponent; // Maybe Writer, Impress, Calc or Database document. java.io.OutputStream output; PropertyValue [ ] xPropertyValue = new PropertyValue [ 2 ]; xPropertyValue [ 0 ] = new PropertyValue ( ); xPropertyValue [ 0 ] . Name = "FilterName"; ReportOutputStream document; XStorable xStorable; xPropertyValue [ 0 ] . Value = "writer8"; // for example document = new DocumentOutputStream ( output ); xPropertyValue [ 1 ] = new PropertyValue ( ); xPropertyValue [ 1 ] . Name = "OutputStream"; xPropertyValue [ 1 ] . Value = document; try { xStorable = ( XStorable ) UnoRuntime . queryInterface ( XStorable.class, xComponent ); xStorable . storeToURL ( "private:stream", xPropertyValue ); } catch ( final com.sun.star.io.IOException exception ) { final String message = exception . getMessage ( ); throw new DatabaseException ( message ); } [/code] The reported error message is as follows (The text "Could not save document" is transcribed from the underlying OO stack) com.entropy.reporting.database.DatabaseException: Could not save the document: com.sun.star.ucb.ContentCreationException: No Content Provider available for given URL! THIS IS IMPORTANT BECAUSE THE METHOD PROVIDES A DIRECT TRANSCRIPTION IF A DYNAMICALLY GENERATED DOCUMENT TO A SERVLET HTTPServletResponse OutputStream. THE APPROACH WORKS for Writer, Calc and Impress. IT SHOULD ALSO WORK FOR DATABASE IN MY VIEW. I THINK, THEREFORE, THAT THIS BUG SHOULD HAVE A HIGH PRIORITY! The Writer, Calc and Impress documents are typically created as follows: [code] XDesktop XDesktop; xComponentLoader = ( XComponentLoader ) UnoRuntime . queryInterface ( XComponentLoader.class, xDesktop ); PropertyValue [ ] xDeskProps = new PropertyValue [ 1 ]; xDeskProps [ 0 ] = new PropertyValue ( ); xDeskProps [ 0 ] . Name = "Hidden"; xDeskProps [ 0 ] . Value = false; xComponent = xComponentLoader . loadComponentFromURL ( "private:factory/swriter", "_blank", 0, xDeskProps ); xComponent = xComponentLoader . loadComponentFromURL ( "private:factory/simpress", "_blank", 0, xDeskProps ); xComponent = xComponentLoader . loadComponentFromURL ( "private:factory/scalc", "_blank", 0, xDeskProps ); [/code] Note that the same empty document instantiation works for Database also. There is however no (not even any empty) XDataSource object. NEITHER CAN THIS BE CREATED USING THE APPROACH OUTLINED IN THE MANUAL / USER-GUIDE (SEE http://www.openoffice.org/issues/show_bug.cgi?id=111454 ). Your effort (and any reasonable work-around) would be much appreciated.
Change component to none, priority to P3.
Why use storeToUrl and not storeAsUrl?