Apache OpenOffice (AOO) Bugzilla – Issue 109492
insertDocumentFromURL does not support inputstream
Last modified: 2013-02-24 21:10:15 UTC
problem was mentioned e.g. in #57047. Issue owner was asked to include this into #57407, but did not do include it (probably due to one problem - one issue - rule).
jsc -> tl: to you because it's a writer specific interface.
.
I've the same problem. Test platforms: Windows XP Professional - OOO320m18 Build 9502 Ubuntu Linux 2.6.27-17-server - OO 2.4.1
This is my work around. I don't know if works for each content. private void insertDocumentFromStreamWorkAround(XTextDocument xTextDocument, XTextRange xSearchTextRange, XInputStream xInputStream) throws IOException, IllegalArgumentException, CloseVetoException, UnsupportedFlavorException { OODocumentHelper insertingDocumentHelper = new OODocumentHelper(ooConnection, xInputStream); XTextDocument insertingTextDocument = (XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, insertingDocumentHelper.getDocument()); XController insertingController = insertingTextDocument.getCurrentController(); XTextViewCursorSupplier insertingSupplier = (XTextViewCursorSupplier)UnoRuntime.queryInterface(XTextViewCursorSupplier.class, insertingController); XTextViewCursor insertingCursor = insertingSupplier.getViewCursor(); insertingCursor.gotoStart(false); // Select all insertingCursor.gotoEnd(true); XTransferableSupplier insertingTransferSupplier = (XTransferableSupplier)UnoRuntime.queryInterface(XTransferableSupplier.class, insertingController); XTransferable xTransferable = insertingTransferSupplier.getTransferable(); XController targetController = xTextDocument.getCurrentController(); XTextViewCursorSupplier targetSupplier = (XTextViewCursorSupplier)UnoRuntime.queryInterface(XTextViewCursorSupplier.class, targetController); XTextViewCursor targetCursor = targetSupplier.getViewCursor(); targetCursor.gotoRange(xSearchTextRange.getStart(), false); // Select my searched piece. targetCursor.gotoRange(xSearchTextRange.getEnd(), true); XTransferableSupplier targetTransferSupplier = (XTransferableSupplier)UnoRuntime.queryInterface(XTransferableSupplier.class, targetController); targetTransferSupplier.insertTransferable(xTransferable); insertingDocumentHelper.closeDocumentUploaded(); } OODocumentHelper is a class of mine to manage documents. It opens an odt with a loadDocumentFromUrl. I hope this can help.