[Solved] Insert Writer Documents in single one with Java

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
VV_RIP
Posts: 11
Joined: Sun May 19, 2013 1:58 pm

[Solved] Insert Writer Documents in single one with Java

Post by VV_RIP »

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.
Last edited by Hagar Delest on Thu May 23, 2013 8:09 am, edited 1 time in total.
Reason: tagged [Solved].
OpenOffice 3.4.1 on Windows 7
User avatar
RoryOF
Moderator
Posts: 35210
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Insert Writer Documents in single document with Java

Post by RoryOF »

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
VV_RIP
Posts: 11
Joined: Sun May 19, 2013 1:58 pm

Re: Insert Writer Documents in single document with Java

Post by VV_RIP »

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
SNM90
Posts: 21
Joined: Fri Mar 01, 2013 6:56 am

Re: Insert Writer Documents in single document with Java

Post by SNM90 »

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.
OpenOffice 3.1 on Windows Vista
(Libreoffice 4.0.0 on Windows 7)
VV_RIP
Posts: 11
Joined: Sun May 19, 2013 1:58 pm

Re: Insert Writer Documents in single document with Java

Post by VV_RIP »

Thanks! It solve my problem!
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
Post Reply