[Solved] Using java-UNO to insert slide

The Application Programming Interface and the OASIS Open Document Format

[Solved] Using java-UNO to insert slide

Postby victor_charlie » Thu Aug 23, 2012 2:56 am

Can anyone point me to, or provide a snippet, of obtaining the Impress Object and inserting a slide in Java? I have googled for a while trying to get a handle on the API. Unfortunate software names blocks me from getting results, e.g. 'uno java impress' gets me Italian / Spanish hits using javascript -> opción número uno.

Thanks FJCC! I tried to make-build a similar tool written in Java that (sadly) was overly complicated. The Python tool MRI was exactly what I needed.
Last edited by victor_charlie on Thu Aug 23, 2012 3:50 pm, edited 1 time in total.
LibreOffice 3.4.4 / OOO340m1(Build:402) on AMD64 Ubuntu 11.10
User avatar
Posts: 1
Joined: Thu Aug 23, 2012 2:44 am
Location: Texas Hill Country

Re: Using java-UNO to insert slide

Postby FJCC » Thu Aug 23, 2012 3:25 am

You can save yourself innumerable hours by getting an object inspector like MRI. I used it to record this Java code to add a slide to an existing presentation. oInitialTarget is the document.
Code: Select all   Expand viewCollapse view
import com.sun.star.drawing.XDrawPage;
import com.sun.star.drawing.XDrawPages;
import com.sun.star.drawing.XDrawPagesSupplier;
import com.sun.star.uno.UnoRuntime;

static public void snippet(Object oInitialTarget)
   XDrawPagesSupplier xDrawPagesSupplier = UnoRuntime.queryInterface(
      XDrawPagesSupplier.class, oInitialTarget);
   XDrawPages xDrawPages = xDrawPagesSupplier.getDrawPages();
   XDrawPage xDrawPage = xDrawPages.insertNewByIndex(1);
Windows 10 and Linux Mint, since 2017
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Posts: 8256
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: [Solved] Using java-UNO to insert slide

Postby jza » Sun Jan 20, 2013 10:48 am

Have you seen the developer guide, most of its snippets are in Java and also is divided by Modules, impress is a bit odd, since both impress and draw are builted under the same basic object.

The XDawPages is the right supplier to insert new pages. including the method pointed by FJCC insertNewByIndex() under DrawingMasterPages
AOO 4.1.1 on Arch Linux
User avatar
Posts: 239
Joined: Mon Nov 03, 2008 11:33 am
Location: Cancún, Mexico

Return to UNO API and ODF

Who is online

Users browsing this forum: No registered users and 2 guests