I'm building a Java aplication using the OOo SDK where I'm manipulating slides in an OpenOffice Impress presentation. I know how to get an object containing a single slide, now I'm looking for a way to copy a slide from a presentation to another.
That's (shortened) what I do to open the files and selecting the slide:
String filename = "file://....odp";
int offset = 2;
XComponent xSourceComponent = xComponentLoader.loadComponentFromURL(filename, "_blank", 0, loadProps);
XComponent xTargetComponent = xComponentLoader.loadComponentFromURL("private:factory/simpress", "_blank", 0, loadProps);
XDrawPages xDrawPages = ((XDrawPagesSupplier)UnoRuntime.queryInterface(
XDrawPagesSupplier.class, xSourceComponent)).getDrawPages();
XPresentationPage xPage = (XPresentationPage)UnoRuntime.queryInterface(XPresentationPage.class,
xDrawPages.getByIndex(offset));
Based on I tried to get a transferable object like this:
XTransferable t = (XTransferable)UnoRuntime.queryInterface(
XTransferable.class, xPage);
But that doesn't seem to be supported. Anybody has an idea how to do this?
Oh man, good luck. I looked at trying to do something like this about a year ago and ended up using Apache POI instead -- not necessarily sure the OO SDK can't do this, but the documentation for the API is so esoteric that I couldn't figure it out. In POI it's as easy as
That may not really help you since you're dealing with OO not PPT, but if you're desperate for a solution and not getting help on the OpenOffice front, you could probably string together JODConverter (http://www.artofsolving.com/opensource/jodconverter) and POI.