Hi Tobias,

I've corrected the errors. I'll attach you the corrected snippet. The
key point is that:
- linking internal (snippet) sources is done using
  {%internal relative-path}
- linking IDL-Docu:
  - {%see fully.qualified.class.Name}
  - {%see fully.qualified.class.Name|Shortname}

Tom

Tobias Krais schrieb:
> Hi Tom,
> 
>> Thanks for your contribution your snippet has been added
>> here:http://codesnippets.services.openoffice.org/Writer/Writer.InsertingADocumentInAnOther.snip
> 
> something went wrong. Please tell me what I have to fix in this snippet,
> because linking did not work.
> 
> Greetings, Tobias
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

<?xml version="1.0"?>
<!--
$RCSfile: Writer.InsertingADocumentInAnOther.snip,v $
last change: $Revision: 1.1 $ $Author: tomsontom $ $Date: 2006/11/30 17:00:04 $

(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 {%see com.sun.star.document.XDocumentInsertable};
import {%see com.sun.star.lang.XComponent};
import {%see com.sun.star.text.XText};
import {%see com.sun.star.text.XTextCursor};
import {%see com.sun.star.text.XTextDocument};
import {%see 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 {%internal ../Office/Office.CreateUNOCompatibleURL.snip}
 */
public void insertDocument(String unoDocumentURL) {
    // How to get the XComponent, see {%internal ../Office/Office.OpenDocumentFromURL.snip}
    {%see com.sun.star.text.XTextDocument|XTextDocument} xTextDocument = ({%see com.sun.star.text.XTextDocument|XTextDocument})
	UnoRuntime.queryInterface({%see com.sun.star.text.XTextDocument|XTextDocument}.class, xComponent);
    {%see com.sun.star.text.XText|XText} xText = xTextDocument.getText();
        
    // create a text cursor from the cells XText interface
    {%see com.sun.star.text.XTextCursor|XTextCursor} xTextCursor = xText.createTextCursor();
    {%see com.sun.star.document.XDocumentInsertable|XDocumentInsertable} xDocInsert = ({%see com.sun.star.document.XDocumentInsertable|XDocumentInsertable})
        UnoRuntime.queryInterface({%see com.sun.star.document.XDocumentInsertable|XDocumentInsertable}.class, xTextCursor);
    try {
        xDocInsert.insertDocumentFromURL(unoDocumentURL, null);
    }
    catch (Exception e) {
        if (debug &gt; 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>

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to