Page 1 of 1

[Solved] Using java-UNO to insert slide

PostPosted: Thu Aug 23, 2012 2:56 am
by victor_charlie
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.



edit:::::::::::::
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.

Re: Using java-UNO to insert slide

PostPosted: Thu Aug 23, 2012 3:25 am
by FJCC
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);
   
}

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

PostPosted: Sun Jan 20, 2013 10:48 am
by jza
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.
Image

The XDawPages is the right supplier to insert new pages. including the method pointed by FJCC insertNewByIndex() under DrawingMasterPages