Hi Mathias, Peter, Thx for all the help, I got it finally working! I tried in the past the queryInterface to get to our XTransferableSupplier but then I got stuck since the resulting xTransferable was empty. You must select contents first apparently.
I'm using a XTextViewCursor for this, don't know how/if you can this more cleanly. This is my code snippet for all you out there, which copies the code of one document to another (yes there is a insertDocumentFromURL code snippet also). I will use it also for my paragraphs (just select the textRange via the aragraph.getAnchor()). XComponent xComponent_sourceDoc = xComponentLoader.loadComponentFromURL( url_odt_contents, "_blank", 0, myProperties); XComponent xComponent_targetDoc = xComponentLoader.loadComponentFromURL( url_template, "_blank", 0, myProperties); XTextDocument xTextDocument_sourceDoc = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, xComponent_sourceDoc); XTextDocument xTextDocument_targetDoc = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, xComponent_targetDoc); //the controllers XController xController_sourceDoc = xTextDocument_sourceDoc.getCurrentController(); XController xController_targetDoc = xTextDocument_targetDoc.getCurrentController(); //the cursor for the source document XTextViewCursorSupplier xViewCursorSupplier_sourceDoc = (XTextViewCursorSupplier) UnoRuntime.queryInterface(XTextViewCursorSupplier.class, xController_sourceDoc); //selecting the whole source document XTextViewCursor xTextViewCursor_sourceDoc = xViewCursorSupplier_sourceDoc.getViewCursor(); xTextViewCursor_sourceDoc.gotoEnd(true); //getting the data supplier of our source doc XTransferableSupplier xTransferableSupplier_sourceDoc = (XTransferableSupplier) UnoRuntime.queryInterface( XTransferableSupplier.class, xController_sourceDoc ); //saving the selected contents XTransferable xTransferable = xTransferableSupplier_sourceDoc.getTransferable(); //getting the data supplier of our target doc XTransferableSupplier xTransferableSupplier_targetDoc = (XTransferableSupplier) UnoRuntime.queryInterface( XTransferableSupplier.class, xController_targetDoc ); //the cursor for the target document XTextViewCursorSupplier xViewCursorSupplier_targetDoc = (XTextViewCursorSupplier) UnoRuntime.queryInterface(XTextViewCursorSupplier.class, xController_targetDoc); //going to the end of the source document XTextViewCursor xTextViewCursor_targetDoc = xViewCursorSupplier_targetDoc.getViewCursor(); xTextViewCursor_targetDoc.gotoEnd(false); //inserting the source document there xTransferableSupplier_targetDoc.insertTransferable(xTransferable); On 3/20/07, Mathias Bauer <[EMAIL PROTECTED]> wrote:
Dominique De Munck wrote: > I'm working in Java and I'm not able to get those objects. Are those > fields private or something ? > XComponent (= return type of loadComponentFromURL) does not offer any > field "CurrentController". Of course. You have to use the css.frame.XModel interface of the returned component. > XTextDocument has a a method getCurrentController() , but this returns a > XController, and a cast to XTransferableSupplier gives me an error. You mean calling queryInterface from it, right? Casting doesn't work here. That's exactly the right object. Which version of OOo are you using? Ciao, Mathias -- Mathias Bauer (mba) - Project Lead OpenOffice.org Writer OpenOffice.org Engineering at Sun: http://blogs.sun.com/GullFOSS Please don't reply to "[EMAIL PROTECTED]". I use it for the OOo lists and only rarely read other mails sent to it. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- -- tel: (32)/(0)486 23 81 33 --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]