Hello! I have several documets (XComponents), but i don't know, how i can insert it into one document? After this i save document to a file.
Any help in this?
Thanks in advance.
[Solved] Insert Writer Documents in single one with Java
[Solved] Insert Writer Documents in single one with Java
Last edited by Hagar Delest on Thu May 23, 2013 8:09 am, edited 1 time in total.
Reason: tagged [Solved].
Reason: tagged [Solved].
OpenOffice 3.4.1 on Windows 7
Re: Insert Writer Documents in single document with Java
Start a new OpenOffice document, then /Insert /File and select each file in turn, with your cursor positioned where in the new document you wish the file to be inserted.
Apache OpenOffice 4.1.16 on Xubuntu 24.04.4 LTS
Re: Insert Writer Documents in single document with Java
Can you talk in detail? I can't understand, how i can do this? What i must use for this?
OpenOffice 3.4.1 on Windows 7
Re: Insert Writer Documents in single document with Java
Hi,
If they are writer documents which you want to insert, you can use the XDocumentInsertable interface whose method 'insertDocumentFromURL()' will aid you in this. If the documents to be inserted are of other types like Calc, Draw, etc, then you might want to use the service TextEmbeddedObject to directly embed the document through their CLSIDs (although I'm not sure if this technique works for existing documents like Calc, etc. I've posted a question too regarding this but have got no reply yet).
Hope I could help.
If they are writer documents which you want to insert, you can use the XDocumentInsertable interface whose method 'insertDocumentFromURL()' will aid you in this. If the documents to be inserted are of other types like Calc, Draw, etc, then you might want to use the service TextEmbeddedObject to directly embed the document through their CLSIDs (although I'm not sure if this technique works for existing documents like Calc, etc. I've posted a question too regarding this but have got no reply yet).
Hope I could help.
OpenOffice 3.1 on Windows Vista
(Libreoffice 4.0.0 on Windows 7)
(Libreoffice 4.0.0 on Windows 7)
Re: Insert Writer Documents in single document with Java
Thanks! It solve my problem!
Code:
Code:
Code: Select all
public void addTemplate(String tempDocument) //путь к файлу
throws Exception {
XTextCursor cur = doc.getText().createTextCursor();//XTextDocument doc
cur.gotoEnd(false);
XDocumentInsertable xDocI = (XDocumentInsertable)
UnoRuntime.queryInterface(XDocumentInsertable.class, cur);
xDocI.insertDocumentFromURL((new File(tempDocument)).toURI().toString(), new PropertyValue[0]);
}OpenOffice 3.4.1 on Windows 7