Hi Tom, please add this snippet to the snippet database.
Greetings, Tobias
<?xml version="1.0"?> <!-- $RCSfile: $ last change: $Revision: $ $Author: $ $Date: $ (c)2003 by the copyright holders listed with the author-tags. If no explicit copyright holder is mentioned with a certain author, the author him-/herself is the copyright holder. All rights reserved. Public Documentation License Notice: The contents of this Documentation are subject to the Public Documentation License Version 1.0 (the "License"); you may only use this Documentation if you comply with the terms of this License. A copy of the License is available at http://www.openoffice.org/licenses/PDL.html The Original Documentation can be found in the CVS archives of openoffice.org at the place specified by RCSfile: in this header. The Initial Writer(s) of the Original Documentation are listed with the author-tags below. The Contributor(s) are listed with the author-tags below without the marker for being an initial author. All Rights Reserved. --> <snippet language="Java" application="Writer"> <keywords> <keyword>insert</keyword> <keyword>document</keyword> </keywords> <authors> <author id="tobiaskrais" initial="true" email="[EMAIL PROTECTED]" copyright="GNU Public liscense">Tobias Krais</author> </authors> <question heading="Inserting a Document in an other">How to insert a document in an other one? </question> <answer> <listing>import com.sun.star.document.XDocumentInsertable; import com.sun.star.lang.XComponent; import com.sun.star.text.XText; import com.sun.star.text.XTextCursor; import com.sun.star.text.XTextDocument; import com.sun.star.uno.UnoRuntime; /** * Inserts a document a the cursors point. * @param unoDocumentURL File name that is UNO URL conform. * How to create this, see [EMAIL PROTECTED] ../Office/Office.CreateUNOCompatibleURL.snip} */ public void insertDocument(String unoDocumentURL) { // How to get the XComponent, see [EMAIL PROTECTED] ../Office/Office.OpenDocumentFromURL.snip} XTextDocumen xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, xComponent); XText xText = xTextDocument.getText(); // create a text cursor from the cells XText interface XTextCursor xTextCursor = xText.createTextCursor(); XDocumentInsertable xDocInsert = (XDocumentInsertable) UnoRuntime.queryInterface(XDocumentInsertable.class, xTextCursor); try { xDocInsert.insertDocumentFromURL(unoDocumentURL, null); } catch (Exception e) { if (debug > 1) e.printStackTrace(); } }</listing> </answer> <versions> <version number="2.0.x" status="tested"/> </versions> <operating-systems> <operating-system name="All"/> </operating-systems> <changelog> <change author-id="tobiaskrais" date="2006-11-30">Initial version</change> </changelog> </snippet>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]