[Solved] Insert Writer Documents in single one with Java

Java, C++, C#, Delphi, ??? - Using the UNO bridges

[Solved] Insert Writer Documents in single one with Java

Postby VV_RIP » Sun May 19, 2013 2:20 pm

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

Re: Insert Writer Documents in single document with Java

Postby RoryOF » Sun May 19, 2013 3:18 pm

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.7 on Xubuntu 18.04.3 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 29912
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Insert Writer Documents in single document with Java

Postby VV_RIP » Sun May 19, 2013 11:18 pm

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

Re: Insert Writer Documents in single document with Java

Postby SNM90 » Tue May 21, 2013 5:42 am

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

Re: Insert Writer Documents in single document with Java

Postby VV_RIP » Wed May 22, 2013 11:04 pm

Thanks! It solve my problem!
Code:
Code: Select all   Expand viewCollapse view
   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
VV_RIP
 
Posts: 11
Joined: Sun May 19, 2013 1:58 pm


Return to External Programs

Who is online

Users browsing this forum: No registered users and 1 guest